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{2018-02-12.17}
7%
8% Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
9% 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
10% 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
11% Free Software Foundation, Inc.
12%
13% This texinfo.tex file is free software: you can redistribute it and/or
14% modify it under the terms of the GNU General Public License as
15% published by the Free Software Foundation, either version 3 of the
16% License, or (at your option) any later version.
17%
18% This texinfo.tex file is distributed in the hope that it will be
19% useful, but WITHOUT ANY WARRANTY; without even the implied warranty
20% of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21% General Public License for more details.
22%
23% You should have received a copy of the GNU General Public License
24% along with this program.  If not, see <https://www.gnu.org/licenses/>.
25%
26% As a special exception, when this file is read by TeX when processing
27% a Texinfo source document, you may use the result without
28% restriction. This Exception is an additional permission under section 7
29% of the GNU General Public License, version 3 ("GPLv3").
30%
31% Please try the latest version of texinfo.tex before submitting bug
32% reports; you can get the latest version from:
33%   https://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or
34%   https://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or
35%   https://www.gnu.org/software/texinfo/ (the Texinfo home page)
36% The texinfo.tex in any given distribution could well be out
37% of date, so if that's what you're using, please check.
38%
39% Send bug reports to bug-texinfo@gnu.org.  Please include including a
40% complete document in each bug report with which we can reproduce the
41% problem.  Patches are, of course, greatly appreciated.
42%
43% To process a Texinfo manual with TeX, it's most reliable to use the
44% texi2dvi shell script that comes with the distribution.  For a simple
45% manual foo.texi, however, you can get away with this:
46%   tex foo.texi
47%   texindex foo.??
48%   tex foo.texi
49%   tex foo.texi
50%   dvips foo.dvi -o  # or whatever; this makes foo.ps.
51% The extra TeX runs get the cross-reference information correct.
52% Sometimes one run after texindex suffices, and sometimes you need more
53% than two; texi2dvi does it as many times as necessary.
54%
55% It is possible to adapt texinfo.tex for other languages, to some
56% extent.  You can get the existing language-specific files from the
57% full Texinfo distribution.
58%
59% The GNU Texinfo home page is https://www.gnu.org/software/texinfo.
60
61
62\message{Loading texinfo [version \texinfoversion]:}
63
64% If in a .fmt file, print the version number
65% and turn on active characters that we couldn't do earlier because
66% they might have appeared in the input file name.
67\everyjob{\message{[Texinfo version \texinfoversion]}%
68  \catcode`+=\active \catcode`\_=\active}
69
70% LaTeX's \typeout.  This ensures that the messages it is used for
71% are identical in format to the corresponding ones from latex/pdflatex.
72\def\typeout{\immediate\write17}%
73
74\chardef\other=12
75
76% We never want plain's \outer definition of \+ in Texinfo.
77% For @tex, we can use \tabalign.
78\let\+ = \relax
79
80% Save some plain tex macros whose names we will redefine.
81\let\ptexb=\b
82\let\ptexbullet=\bullet
83\let\ptexc=\c
84\let\ptexcomma=\,
85\let\ptexdot=\.
86\let\ptexdots=\dots
87\let\ptexend=\end
88\let\ptexequiv=\equiv
89\let\ptexexclam=\!
90\let\ptexfootnote=\footnote
91\let\ptexgtr=>
92\let\ptexhat=^
93\let\ptexi=\i
94\let\ptexindent=\indent
95\let\ptexinsert=\insert
96\let\ptexlbrace=\{
97\let\ptexless=<
98\let\ptexnewwrite\newwrite
99\let\ptexnoindent=\noindent
100\let\ptexplus=+
101\let\ptexraggedright=\raggedright
102\let\ptexrbrace=\}
103\let\ptexslash=\/
104\let\ptexsp=\sp
105\let\ptexstar=\*
106\let\ptexsup=\sup
107\let\ptext=\t
108\let\ptextop=\top
109{\catcode`\'=\active \global\let\ptexquoteright'}% active in plain's math mode
110
111% If this character appears in an error message or help string, it
112% starts a new line in the output.
113\newlinechar = `^^J
114
115% Use TeX 3.0's \inputlineno to get the line number, for better error
116% messages, but if we're using an old version of TeX, don't do anything.
117%
118\ifx\inputlineno\thisisundefined
119  \let\linenumber = \empty % Pre-3.0.
120\else
121  \def\linenumber{l.\the\inputlineno:\space}
122\fi
123
124% Set up fixed words for English if not already set.
125\ifx\putwordAppendix\undefined  \gdef\putwordAppendix{Appendix}\fi
126\ifx\putwordChapter\undefined   \gdef\putwordChapter{Chapter}\fi
127\ifx\putworderror\undefined     \gdef\putworderror{error}\fi
128\ifx\putwordfile\undefined      \gdef\putwordfile{file}\fi
129\ifx\putwordin\undefined        \gdef\putwordin{in}\fi
130\ifx\putwordIndexIsEmpty\undefined       \gdef\putwordIndexIsEmpty{(Index is empty)}\fi
131\ifx\putwordIndexNonexistent\undefined   \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi
132\ifx\putwordInfo\undefined      \gdef\putwordInfo{Info}\fi
133\ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi
134\ifx\putwordMethodon\undefined  \gdef\putwordMethodon{Method on}\fi
135\ifx\putwordNoTitle\undefined   \gdef\putwordNoTitle{No Title}\fi
136\ifx\putwordof\undefined        \gdef\putwordof{of}\fi
137\ifx\putwordon\undefined        \gdef\putwordon{on}\fi
138\ifx\putwordpage\undefined      \gdef\putwordpage{page}\fi
139\ifx\putwordsection\undefined   \gdef\putwordsection{section}\fi
140\ifx\putwordSection\undefined   \gdef\putwordSection{Section}\fi
141\ifx\putwordsee\undefined       \gdef\putwordsee{see}\fi
142\ifx\putwordSee\undefined       \gdef\putwordSee{See}\fi
143\ifx\putwordShortTOC\undefined  \gdef\putwordShortTOC{Short Contents}\fi
144\ifx\putwordTOC\undefined       \gdef\putwordTOC{Table of Contents}\fi
145%
146\ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi
147\ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi
148\ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi
149\ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi
150\ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi
151\ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi
152\ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi
153\ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi
154\ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi
155\ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi
156\ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi
157\ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi
158%
159\ifx\putwordDefmac\undefined    \gdef\putwordDefmac{Macro}\fi
160\ifx\putwordDefspec\undefined   \gdef\putwordDefspec{Special Form}\fi
161\ifx\putwordDefvar\undefined    \gdef\putwordDefvar{Variable}\fi
162\ifx\putwordDefopt\undefined    \gdef\putwordDefopt{User Option}\fi
163\ifx\putwordDeffunc\undefined   \gdef\putwordDeffunc{Function}\fi
164
165% Give the space character the catcode for a space.
166\def\spaceisspace{\catcode`\ =10\relax}
167
168% Likewise for ^^M, the end of line character.
169\def\endlineisspace{\catcode13=10\relax}
170
171\chardef\dashChar  = `\-
172\chardef\slashChar = `\/
173\chardef\underChar = `\_
174
175% Ignore a token.
176%
177\def\gobble#1{}
178
179% The following is used inside several \edef's.
180\def\makecsname#1{\expandafter\noexpand\csname#1\endcsname}
181
182% Hyphenation fixes.
183\hyphenation{
184  Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script
185  auto-ma-ti-cal-ly ap-pen-dix bit-map bit-maps
186  data-base data-bases eshell fall-ing half-way long-est man-u-script
187  man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm
188  par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces
189  spell-ing spell-ings
190  stand-alone strong-est time-stamp time-stamps which-ever white-space
191  wide-spread wrap-around
192}
193
194% Sometimes it is convenient to have everything in the transcript file
195% and nothing on the terminal.  We don't just call \tracingall here,
196% since that produces some useless output on the terminal.  We also make
197% some effort to order the tracing commands to reduce output in the log
198% file; cf. trace.sty in LaTeX.
199%
200\def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
201\def\loggingall{%
202  \tracingstats2
203  \tracingpages1
204  \tracinglostchars2  % 2 gives us more in etex
205  \tracingparagraphs1
206  \tracingoutput1
207  \tracingmacros2
208  \tracingrestores1
209  \showboxbreadth\maxdimen \showboxdepth\maxdimen
210  \ifx\eTeXversion\thisisundefined\else % etex gives us more logging
211    \tracingscantokens1
212    \tracingifs1
213    \tracinggroups1
214    \tracingnesting2
215    \tracingassigns1
216  \fi
217  \tracingcommands3  % 3 gives us more in etex
218  \errorcontextlines16
219}%
220
221% @errormsg{MSG}.  Do the index-like expansions on MSG, but if things
222% aren't perfect, it's not the end of the world, being an error message,
223% after all.
224%
225\def\errormsg{\begingroup \indexnofonts \doerrormsg}
226\def\doerrormsg#1{\errmessage{#1}}
227
228% add check for \lastpenalty to plain's definitions.  If the last thing
229% we did was a \nobreak, we don't want to insert more space.
230%
231\def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount
232  \removelastskip\penalty-50\smallskip\fi\fi}
233\def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount
234  \removelastskip\penalty-100\medskip\fi\fi}
235\def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount
236  \removelastskip\penalty-200\bigskip\fi\fi}
237
238% Output routine
239%
240
241% For a final copy, take out the rectangles
242% that mark overfull boxes (in case you have decided
243% that the text looks ok even though it passes the margin).
244%
245\def\finalout{\overfullrule=0pt }
246
247% Do @cropmarks to get crop marks.
248%
249\newif\ifcropmarks
250\let\cropmarks = \cropmarkstrue
251%
252% Dimensions to add cropmarks at corners.
253% Added by P. A. MacKay, 12 Nov. 1986
254%
255\newdimen\outerhsize \newdimen\outervsize % set by the paper size routines
256\newdimen\cornerlong  \cornerlong=1pc
257\newdimen\cornerthick \cornerthick=.3pt
258\newdimen\topandbottommargin \topandbottommargin=.75in
259
260% Output a mark which sets \thischapter, \thissection and \thiscolor.
261% We dump everything together because we only have one kind of mark.
262% This works because we only use \botmark / \topmark, not \firstmark.
263%
264% A mark contains a subexpression of the \ifcase ... \fi construct.
265% \get*marks macros below extract the needed part using \ifcase.
266%
267% Another complication is to let the user choose whether \thischapter
268% (\thissection) refers to the chapter (section) in effect at the top
269% of a page, or that at the bottom of a page.
270
271% \domark is called twice inside \chapmacro, to add one
272% mark before the section break, and one after.
273%   In the second call \prevchapterdefs is the same as \lastchapterdefs,
274% and \prevsectiondefs is the same as \lastsectiondefs.
275%   Then if the page is not broken at the mark, some of the previous
276% section appears on the page, and we can get the name of this section
277% from \firstmark for @everyheadingmarks top.
278%   @everyheadingmarks bottom uses \botmark.
279%
280% See page 260 of The TeXbook.
281\def\domark{%
282  \toks0=\expandafter{\lastchapterdefs}%
283  \toks2=\expandafter{\lastsectiondefs}%
284  \toks4=\expandafter{\prevchapterdefs}%
285  \toks6=\expandafter{\prevsectiondefs}%
286  \toks8=\expandafter{\lastcolordefs}%
287  \mark{%
288                   \the\toks0 \the\toks2  % 0: marks for @everyheadingmarks top
289      \noexpand\or \the\toks4 \the\toks6  % 1: for @everyheadingmarks bottom
290    \noexpand\else \the\toks8             % 2: color marks
291  }%
292}
293
294% \gettopheadingmarks, \getbottomheadingmarks,
295% \getcolormarks - extract needed part of mark.
296%
297% \topmark doesn't work for the very first chapter (after the title
298% page or the contents), so we use \firstmark there -- this gets us
299% the mark with the chapter defs, unless the user sneaks in, e.g.,
300% @setcolor (or @url, or @link, etc.) between @contents and the very
301% first @chapter.
302\def\gettopheadingmarks{%
303  \ifcase0\topmark\fi
304  \ifx\thischapter\empty \ifcase0\firstmark\fi \fi
305}
306\def\getbottomheadingmarks{\ifcase1\botmark\fi}
307\def\getcolormarks{\ifcase2\topmark\fi}
308
309% Avoid "undefined control sequence" errors.
310\def\lastchapterdefs{}
311\def\lastsectiondefs{}
312\def\lastsection{}
313\def\prevchapterdefs{}
314\def\prevsectiondefs{}
315\def\lastcolordefs{}
316
317% Margin to add to right of even pages, to left of odd pages.
318\newdimen\bindingoffset
319\newdimen\normaloffset
320\newdimen\txipagewidth \newdimen\txipageheight
321
322% Main output routine.
323%
324\chardef\PAGE = 255
325\output = {\onepageout{\pagecontents\PAGE}}
326
327\newbox\headlinebox
328\newbox\footlinebox
329
330% \onepageout takes a vbox as an argument.
331% \shipout a vbox for a single page, adding an optional header, footer,
332% cropmarks, and footnote.  This also causes index entries for this page
333% to be written to the auxiliary files.
334%
335\def\onepageout#1{%
336  \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi
337  %
338  \ifodd\pageno  \advance\hoffset by \bindingoffset
339  \else \advance\hoffset by -\bindingoffset\fi
340  %
341  % Common context changes for both heading and footing.
342  % Do this outside of the \shipout so @code etc. will be expanded in
343  % the headline as they should be, not taken literally (outputting ''code).
344  \def\commmonheadfootline{\let\hsize=\txipagewidth \texinfochars}
345  %
346  % Retrieve the information for the headings from the marks in the page,
347  % and call Plain TeX's \makeheadline and \makefootline, which use the
348  % values in \headline and \footline.
349  %
350  % This is used to check if we are on the first page of a chapter.
351  \ifcase1\topmark\fi
352  \let\prevchaptername\thischaptername
353  \ifcase0\firstmark\fi
354  \let\curchaptername\thischaptername
355  %
356  \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi
357  \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi
358  %
359  \ifx\curchaptername\prevchaptername
360    \let\thischapterheading\thischapter
361  \else
362    % \thischapterheading is the same as \thischapter except it is blank
363    % for the first page of a chapter.  This is to prevent the chapter name
364    % being shown twice.
365    \def\thischapterheading{}%
366  \fi
367  %
368  \global\setbox\headlinebox = \vbox{\commmonheadfootline \makeheadline}%
369  \global\setbox\footlinebox = \vbox{\commmonheadfootline \makefootline}%
370  %
371  {%
372    % Set context for writing to auxiliary files like index files.
373    % Have to do this stuff outside the \shipout because we want it to
374    % take effect in \write's, yet the group defined by the \vbox ends
375    % before the \shipout runs.
376    %
377    \indexdummies         % don't expand commands in the output.
378    \normalturnoffactive  % \ in index entries must not stay \, e.g., if
379               % the page break happens to be in the middle of an example.
380               % We don't want .vr (or whatever) entries like this:
381               % \entry{{\indexbackslash }acronym}{32}{\code {\acronym}}
382               % "\acronym" won't work when it's read back in;
383               % it needs to be
384               % {\code {{\backslashcurfont }acronym}
385    \shipout\vbox{%
386      % Do this early so pdf references go to the beginning of the page.
387      \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi
388      %
389      \ifcropmarks \vbox to \outervsize\bgroup
390        \hsize = \outerhsize
391        \vskip-\topandbottommargin
392        \vtop to0pt{%
393          \line{\ewtop\hfil\ewtop}%
394          \nointerlineskip
395          \line{%
396            \vbox{\moveleft\cornerthick\nstop}%
397            \hfill
398            \vbox{\moveright\cornerthick\nstop}%
399          }%
400          \vss}%
401        \vskip\topandbottommargin
402        \line\bgroup
403          \hfil % center the page within the outer (page) hsize.
404          \ifodd\pageno\hskip\bindingoffset\fi
405          \vbox\bgroup
406      \fi
407      %
408      \unvbox\headlinebox
409      \pagebody{#1}%
410      \ifdim\ht\footlinebox > 0pt
411        % Only leave this space if the footline is nonempty.
412        % (We lessened \vsize for it in \oddfootingyyy.)
413        % The \baselineskip=24pt in plain's \makefootline has no effect.
414        \vskip 24pt
415        \unvbox\footlinebox
416      \fi
417      %
418      \ifcropmarks
419          \egroup % end of \vbox\bgroup
420        \hfil\egroup % end of (centering) \line\bgroup
421        \vskip\topandbottommargin plus1fill minus1fill
422        \boxmaxdepth = \cornerthick
423        \vbox to0pt{\vss
424          \line{%
425            \vbox{\moveleft\cornerthick\nsbot}%
426            \hfill
427            \vbox{\moveright\cornerthick\nsbot}%
428          }%
429          \nointerlineskip
430          \line{\ewbot\hfil\ewbot}%
431        }%
432      \egroup % \vbox from first cropmarks clause
433      \fi
434    }% end of \shipout\vbox
435  }% end of group with \indexdummies
436  \advancepageno
437  \ifnum\outputpenalty>-20000 \else\dosupereject\fi
438}
439
440\newinsert\margin \dimen\margin=\maxdimen
441
442% Main part of page, including any footnotes
443\def\pagebody#1{\vbox to\txipageheight{\boxmaxdepth=\maxdepth #1}}
444{\catcode`\@ =11
445\gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
446% marginal hacks, juha@viisa.uucp (Juha Takala)
447\ifvoid\margin\else % marginal info is present
448  \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi
449\dimen@=\dp#1\relax \unvbox#1\relax
450\ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
451\ifr@ggedbottom \kern-\dimen@ \vfil \fi}
452}
453
454% Here are the rules for the cropmarks.  Note that they are
455% offset so that the space between them is truly \outerhsize or \outervsize
456% (P. A. MacKay, 12 November, 1986)
457%
458\def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
459\def\nstop{\vbox
460  {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
461\def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
462\def\nsbot{\vbox
463  {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
464
465
466% Argument parsing
467
468% Parse an argument, then pass it to #1.  The argument is the rest of
469% the input line (except we remove a trailing comment).  #1 should be a
470% macro which expects an ordinary undelimited TeX argument.
471% For example, \def\foo{\parsearg\fooxxx}.
472%
473\def\parsearg{\parseargusing{}}
474\def\parseargusing#1#2{%
475  \def\argtorun{#2}%
476  \begingroup
477    \obeylines
478    \spaceisspace
479    #1%
480    \parseargline\empty% Insert the \empty token, see \finishparsearg below.
481}
482
483{\obeylines %
484  \gdef\parseargline#1^^M{%
485    \endgroup % End of the group started in \parsearg.
486    \argremovecomment #1\comment\ArgTerm%
487  }%
488}
489
490% First remove any @comment, then any @c comment.  Also remove a @texinfoc
491% comment (see \scanmacro for details).  Pass the result on to \argcheckspaces.
492\def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm}
493\def\argremovec#1\c#2\ArgTerm{\argremovetexinfoc #1\texinfoc\ArgTerm}
494\def\argremovetexinfoc#1\texinfoc#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
495
496% Each occurrence of `\^^M' or `<space>\^^M' is replaced by a single space.
497%
498% \argremovec might leave us with trailing space, e.g.,
499%    @end itemize  @c foo
500% This space token undergoes the same procedure and is eventually removed
501% by \finishparsearg.
502%
503\def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M}
504\def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M}
505\def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{%
506  \def\temp{#3}%
507  \ifx\temp\empty
508    % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp:
509    \let\temp\finishparsearg
510  \else
511    \let\temp\argcheckspaces
512  \fi
513  % Put the space token in:
514  \temp#1 #3\ArgTerm
515}
516
517% If a _delimited_ argument is enclosed in braces, they get stripped; so
518% to get _exactly_ the rest of the line, we had to prevent such situation.
519% We prepended an \empty token at the very beginning and we expand it now,
520% just before passing the control to \argtorun.
521% (Similarly, we have to think about #3 of \argcheckspacesY above: it is
522% either the null string, or it ends with \^^M---thus there is no danger
523% that a pair of braces would be stripped.
524%
525% But first, we have to remove the trailing space token.
526%
527\def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}}
528
529
530% \parseargdef - define a command taking an argument on the line
531%
532% \parseargdef\foo{...}
533%	is roughly equivalent to
534% \def\foo{\parsearg\Xfoo}
535% \def\Xfoo#1{...}
536\def\parseargdef#1{%
537  \expandafter \doparseargdef \csname\string#1\endcsname #1%
538}
539\def\doparseargdef#1#2{%
540  \def#2{\parsearg#1}%
541  \def#1##1%
542}
543
544% Several utility definitions with active space:
545{
546  \obeyspaces
547  \gdef\obeyedspace{ }
548
549  % Make each space character in the input produce a normal interword
550  % space in the output.  Don't allow a line break at this space, as this
551  % is used only in environments like @example, where each line of input
552  % should produce a line of output anyway.
553  %
554  \gdef\sepspaces{\obeyspaces\let =\tie}
555
556  % If an index command is used in an @example environment, any spaces
557  % therein should become regular spaces in the raw index file, not the
558  % expansion of \tie (\leavevmode \penalty \@M \ ).
559  \gdef\unsepspaces{\let =\space}
560}
561
562
563\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
564
565% Define the framework for environments in texinfo.tex.  It's used like this:
566%
567%   \envdef\foo{...}
568%   \def\Efoo{...}
569%
570% It's the responsibility of \envdef to insert \begingroup before the
571% actual body; @end closes the group after calling \Efoo.  \envdef also
572% defines \thisenv, so the current environment is known; @end checks
573% whether the environment name matches.  The \checkenv macro can also be
574% used to check whether the current environment is the one expected.
575%
576% Non-false conditionals (@iftex, @ifset) don't fit into this, so they
577% are not treated as environments; they don't open a group.  (The
578% implementation of @end takes care not to call \endgroup in this
579% special case.)
580
581
582% At run-time, environments start with this:
583\def\startenvironment#1{\begingroup\def\thisenv{#1}}
584% initialize
585\let\thisenv\empty
586
587% ... but they get defined via ``\envdef\foo{...}'':
588\long\def\envdef#1#2{\def#1{\startenvironment#1#2}}
589\def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}}
590
591% Check whether we're in the right environment:
592\def\checkenv#1{%
593  \def\temp{#1}%
594  \ifx\thisenv\temp
595  \else
596    \badenverr
597  \fi
598}
599
600% Environment mismatch, #1 expected:
601\def\badenverr{%
602  \errhelp = \EMsimple
603  \errmessage{This command can appear only \inenvironment\temp,
604    not \inenvironment\thisenv}%
605}
606\def\inenvironment#1{%
607  \ifx#1\empty
608    outside of any environment%
609  \else
610    in environment \expandafter\string#1%
611  \fi
612}
613
614% @end foo executes the definition of \Efoo.
615% But first, it executes a specialized version of \checkenv
616%
617\parseargdef\end{%
618  \if 1\csname iscond.#1\endcsname
619  \else
620    % The general wording of \badenverr may not be ideal.
621    \expandafter\checkenv\csname#1\endcsname
622    \csname E#1\endcsname
623    \endgroup
624  \fi
625}
626
627\newhelp\EMsimple{Press RETURN to continue.}
628
629
630% Be sure we're in horizontal mode when doing a tie, since we make space
631% equivalent to this in @example-like environments. Otherwise, a space
632% at the beginning of a line will start with \penalty -- and
633% since \penalty is valid in vertical mode, we'd end up putting the
634% penalty on the vertical list instead of in the new paragraph.
635{\catcode`@ = 11
636 % Avoid using \@M directly, because that causes trouble
637 % if the definition is written into an index file.
638 \global\let\tiepenalty = \@M
639 \gdef\tie{\leavevmode\penalty\tiepenalty\ }
640}
641
642% @: forces normal size whitespace following.
643\def\:{\spacefactor=1000 }
644
645% @* forces a line break.
646\def\*{\unskip\hfil\break\hbox{}\ignorespaces}
647
648% @/ allows a line break.
649\let\/=\allowbreak
650
651% @. is an end-of-sentence period.
652\def\.{.\spacefactor=\endofsentencespacefactor\space}
653
654% @! is an end-of-sentence bang.
655\def\!{!\spacefactor=\endofsentencespacefactor\space}
656
657% @? is an end-of-sentence query.
658\def\?{?\spacefactor=\endofsentencespacefactor\space}
659
660% @frenchspacing on|off  says whether to put extra space after punctuation.
661%
662\def\onword{on}
663\def\offword{off}
664%
665\parseargdef\frenchspacing{%
666  \def\temp{#1}%
667  \ifx\temp\onword \plainfrenchspacing
668  \else\ifx\temp\offword \plainnonfrenchspacing
669  \else
670    \errhelp = \EMsimple
671    \errmessage{Unknown @frenchspacing option `\temp', must be on|off}%
672  \fi\fi
673}
674
675% @w prevents a word break.  Without the \leavevmode, @w at the
676% beginning of a paragraph, when TeX is still in vertical mode, would
677% produce a whole line of output instead of starting the paragraph.
678\def\w#1{\leavevmode\hbox{#1}}
679
680% @group ... @end group forces ... to be all on one page, by enclosing
681% it in a TeX vbox.  We use \vtop instead of \vbox to construct the box
682% to keep its height that of a normal line.  According to the rules for
683% \topskip (p.114 of the TeXbook), the glue inserted is
684% max (\topskip - \ht (first item), 0).  If that height is large,
685% therefore, no glue is inserted, and the space between the headline and
686% the text is small, which looks bad.
687%
688% Another complication is that the group might be very large.  This can
689% cause the glue on the previous page to be unduly stretched, because it
690% does not have much material.  In this case, it's better to add an
691% explicit \vfill so that the extra space is at the bottom.  The
692% threshold for doing this is if the group is more than \vfilllimit
693% percent of a page (\vfilllimit can be changed inside of @tex).
694%
695\newbox\groupbox
696\def\vfilllimit{0.7}
697%
698\envdef\group{%
699  \ifnum\catcode`\^^M=\active \else
700    \errhelp = \groupinvalidhelp
701    \errmessage{@group invalid in context where filling is enabled}%
702  \fi
703  \startsavinginserts
704  %
705  \setbox\groupbox = \vtop\bgroup
706    % Do @comment since we are called inside an environment such as
707    % @example, where each end-of-line in the input causes an
708    % end-of-line in the output.  We don't want the end-of-line after
709    % the `@group' to put extra space in the output.  Since @group
710    % should appear on a line by itself (according to the Texinfo
711    % manual), we don't worry about eating any user text.
712    \comment
713}
714%
715% The \vtop produces a box with normal height and large depth; thus, TeX puts
716% \baselineskip glue before it, and (when the next line of text is done)
717% \lineskip glue after it.  Thus, space below is not quite equal to space
718% above.  But it's pretty close.
719\def\Egroup{%
720    % To get correct interline space between the last line of the group
721    % and the first line afterwards, we have to propagate \prevdepth.
722    \endgraf % Not \par, as it may have been set to \lisppar.
723    \global\dimen1 = \prevdepth
724  \egroup           % End the \vtop.
725  \addgroupbox
726  \prevdepth = \dimen1
727  \checkinserts
728}
729
730\def\addgroupbox{
731  % \dimen0 is the vertical size of the group's box.
732  \dimen0 = \ht\groupbox  \advance\dimen0 by \dp\groupbox
733  % \dimen2 is how much space is left on the page (more or less).
734  \dimen2 = \txipageheight   \advance\dimen2 by -\pagetotal
735  % if the group doesn't fit on the current page, and it's a big big
736  % group, force a page break.
737  \ifdim \dimen0 > \dimen2
738    \ifdim \pagetotal < \vfilllimit\txipageheight
739      \page
740    \fi
741  \fi
742  \box\groupbox
743}
744
745%
746% TeX puts in an \escapechar (i.e., `@') at the beginning of the help
747% message, so this ends up printing `@group can only ...'.
748%
749\newhelp\groupinvalidhelp{%
750group can only be used in environments such as @example,^^J%
751where each line of input produces a line of output.}
752
753% @need space-in-mils
754% forces a page break if there is not space-in-mils remaining.
755
756\newdimen\mil  \mil=0.001in
757
758\parseargdef\need{%
759  % Ensure vertical mode, so we don't make a big box in the middle of a
760  % paragraph.
761  \par
762  %
763  % If the @need value is less than one line space, it's useless.
764  \dimen0 = #1\mil
765  \dimen2 = \ht\strutbox
766  \advance\dimen2 by \dp\strutbox
767  \ifdim\dimen0 > \dimen2
768    %
769    % Do a \strut just to make the height of this box be normal, so the
770    % normal leading is inserted relative to the preceding line.
771    % And a page break here is fine.
772    \vtop to #1\mil{\strut\vfil}%
773    %
774    % TeX does not even consider page breaks if a penalty added to the
775    % main vertical list is 10000 or more.  But in order to see if the
776    % empty box we just added fits on the page, we must make it consider
777    % page breaks.  On the other hand, we don't want to actually break the
778    % page after the empty box.  So we use a penalty of 9999.
779    %
780    % There is an extremely small chance that TeX will actually break the
781    % page at this \penalty, if there are no other feasible breakpoints in
782    % sight.  (If the user is using lots of big @group commands, which
783    % almost-but-not-quite fill up a page, TeX will have a hard time doing
784    % good page breaking, for example.)  However, I could not construct an
785    % example where a page broke at this \penalty; if it happens in a real
786    % document, then we can reconsider our strategy.
787    \penalty9999
788    %
789    % Back up by the size of the box, whether we did a page break or not.
790    \kern -#1\mil
791    %
792    % Do not allow a page break right after this kern.
793    \nobreak
794  \fi
795}
796
797% @br   forces paragraph break (and is undocumented).
798
799\let\br = \par
800
801% @page forces the start of a new page.
802%
803\def\page{\par\vfill\supereject}
804
805% @exdent text....
806% outputs text on separate line in roman font, starting at standard page margin
807
808% This records the amount of indent in the innermost environment.
809% That's how much \exdent should take out.
810\newskip\exdentamount
811
812% This defn is used inside fill environments such as @defun.
813\parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}
814
815% This defn is used inside nofill environments such as @example.
816\parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount
817  \leftline{\hskip\leftskip{\rm#1}}}}
818
819% @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current
820% paragraph.  For more general purposes, use the \margin insertion
821% class.  WHICH is `l' or `r'.  Not documented, written for gawk manual.
822%
823\newskip\inmarginspacing \inmarginspacing=1cm
824\def\strutdepth{\dp\strutbox}
825%
826\def\doinmargin#1#2{\strut\vadjust{%
827  \nobreak
828  \kern-\strutdepth
829  \vtop to \strutdepth{%
830    \baselineskip=\strutdepth
831    \vss
832    % if you have multiple lines of stuff to put here, you'll need to
833    % make the vbox yourself of the appropriate size.
834    \ifx#1l%
835      \llap{\ignorespaces #2\hskip\inmarginspacing}%
836    \else
837      \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}%
838    \fi
839    \null
840  }%
841}}
842\def\inleftmargin{\doinmargin l}
843\def\inrightmargin{\doinmargin r}
844%
845% @inmargin{TEXT [, RIGHT-TEXT]}
846% (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right;
847% else use TEXT for both).
848%
849\def\inmargin#1{\parseinmargin #1,,\finish}
850\def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing.
851  \setbox0 = \hbox{\ignorespaces #2}%
852  \ifdim\wd0 > 0pt
853    \def\lefttext{#1}%  have both texts
854    \def\righttext{#2}%
855  \else
856    \def\lefttext{#1}%  have only one text
857    \def\righttext{#1}%
858  \fi
859  %
860  \ifodd\pageno
861    \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin
862  \else
863    \def\temp{\inleftmargin\lefttext}%
864  \fi
865  \temp
866}
867
868% @include FILE -- \input text of FILE.
869%
870\def\include{\parseargusing\filenamecatcodes\includezzz}
871\def\includezzz#1{%
872  \pushthisfilestack
873  \def\thisfile{#1}%
874  {%
875    \makevalueexpandable  % we want to expand any @value in FILE.
876    \turnoffactive        % and allow special characters in the expansion
877    \indexnofonts         % Allow `@@' and other weird things in file names.
878    \wlog{texinfo.tex: doing @include of #1^^J}%
879    \edef\temp{\noexpand\input #1 }%
880    %
881    % This trickery is to read FILE outside of a group, in case it makes
882    % definitions, etc.
883    \expandafter
884  }\temp
885  \popthisfilestack
886}
887\def\filenamecatcodes{%
888  \catcode`\\=\other
889  \catcode`~=\other
890  \catcode`^=\other
891  \catcode`_=\other
892  \catcode`|=\other
893  \catcode`<=\other
894  \catcode`>=\other
895  \catcode`+=\other
896  \catcode`-=\other
897  \catcode`\`=\other
898  \catcode`\'=\other
899}
900
901\def\pushthisfilestack{%
902  \expandafter\pushthisfilestackX\popthisfilestack\StackTerm
903}
904\def\pushthisfilestackX{%
905  \expandafter\pushthisfilestackY\thisfile\StackTerm
906}
907\def\pushthisfilestackY #1\StackTerm #2\StackTerm {%
908  \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}%
909}
910
911\def\popthisfilestack{\errthisfilestackempty}
912\def\errthisfilestackempty{\errmessage{Internal error:
913  the stack of filenames is empty.}}
914%
915\def\thisfile{}
916
917% @center line
918% outputs that line, centered.
919%
920\parseargdef\center{%
921  \ifhmode
922    \let\centersub\centerH
923  \else
924    \let\centersub\centerV
925  \fi
926  \centersub{\hfil \ignorespaces#1\unskip \hfil}%
927  \let\centersub\relax % don't let the definition persist, just in case
928}
929\def\centerH#1{{%
930  \hfil\break
931  \advance\hsize by -\leftskip
932  \advance\hsize by -\rightskip
933  \line{#1}%
934  \break
935}}
936%
937\newcount\centerpenalty
938\def\centerV#1{%
939  % The idea here is the same as in \startdefun, \cartouche, etc.: if
940  % @center is the first thing after a section heading, we need to wipe
941  % out the negative parskip inserted by \sectionheading, but still
942  % prevent a page break here.
943  \centerpenalty = \lastpenalty
944  \ifnum\centerpenalty>10000 \vskip\parskip \fi
945  \ifnum\centerpenalty>9999 \penalty\centerpenalty \fi
946  \line{\kern\leftskip #1\kern\rightskip}%
947}
948
949% @sp n   outputs n lines of vertical space
950%
951\parseargdef\sp{\vskip #1\baselineskip}
952
953% @comment ...line which is ignored...
954% @c is the same as @comment
955% @ignore ... @end ignore  is another way to write a comment
956
957
958\def\c{\begingroup \catcode`\^^M=\active%
959\catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
960\cxxx}
961{\catcode`\^^M=\active \gdef\cxxx#1^^M{\endgroup}}
962%
963\let\comment\c
964
965% @paragraphindent NCHARS
966% We'll use ems for NCHARS, close enough.
967% NCHARS can also be the word `asis' or `none'.
968% We cannot feasibly implement @paragraphindent asis, though.
969%
970\def\asisword{asis} % no translation, these are keywords
971\def\noneword{none}
972%
973\parseargdef\paragraphindent{%
974  \def\temp{#1}%
975  \ifx\temp\asisword
976  \else
977    \ifx\temp\noneword
978      \defaultparindent = 0pt
979    \else
980      \defaultparindent = #1em
981    \fi
982  \fi
983  \parindent = \defaultparindent
984}
985
986% @exampleindent NCHARS
987% We'll use ems for NCHARS like @paragraphindent.
988% It seems @exampleindent asis isn't necessary, but
989% I preserve it to make it similar to @paragraphindent.
990\parseargdef\exampleindent{%
991  \def\temp{#1}%
992  \ifx\temp\asisword
993  \else
994    \ifx\temp\noneword
995      \lispnarrowing = 0pt
996    \else
997      \lispnarrowing = #1em
998    \fi
999  \fi
1000}
1001
1002% @firstparagraphindent WORD
1003% If WORD is `none', then suppress indentation of the first paragraph
1004% after a section heading.  If WORD is `insert', then do indent at such
1005% paragraphs.
1006%
1007% The paragraph indentation is suppressed or not by calling
1008% \suppressfirstparagraphindent, which the sectioning commands do.
1009% We switch the definition of this back and forth according to WORD.
1010% By default, we suppress indentation.
1011%
1012\def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent}
1013\def\insertword{insert}
1014%
1015\parseargdef\firstparagraphindent{%
1016  \def\temp{#1}%
1017  \ifx\temp\noneword
1018    \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent
1019  \else\ifx\temp\insertword
1020    \let\suppressfirstparagraphindent = \relax
1021  \else
1022    \errhelp = \EMsimple
1023    \errmessage{Unknown @firstparagraphindent option `\temp'}%
1024  \fi\fi
1025}
1026
1027% Here is how we actually suppress indentation.  Redefine \everypar to
1028% \kern backwards by \parindent, and then reset itself to empty.
1029%
1030% We also make \indent itself not actually do anything until the next
1031% paragraph.
1032%
1033\gdef\dosuppressfirstparagraphindent{%
1034  \gdef\indent  {\restorefirstparagraphindent \indent}%
1035  \gdef\noindent{\restorefirstparagraphindent \noindent}%
1036  \global\everypar = {\kern -\parindent \restorefirstparagraphindent}%
1037}
1038%
1039\gdef\restorefirstparagraphindent{%
1040  \global\let\indent = \ptexindent
1041  \global\let\noindent = \ptexnoindent
1042  \global\everypar = {}%
1043}
1044
1045
1046% @refill is a no-op.
1047\let\refill=\relax
1048
1049% @setfilename INFO-FILENAME - ignored
1050\let\setfilename=\comment
1051
1052% @bye.
1053\outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
1054
1055
1056\message{pdf,}
1057% adobe `portable' document format
1058\newcount\tempnum
1059\newcount\lnkcount
1060\newtoks\filename
1061\newcount\filenamelength
1062\newcount\pgn
1063\newtoks\toksA
1064\newtoks\toksB
1065\newtoks\toksC
1066\newtoks\toksD
1067\newbox\boxA
1068\newbox\boxB
1069\newcount\countA
1070\newif\ifpdf
1071\newif\ifpdfmakepagedest
1072
1073%
1074% For LuaTeX
1075%
1076
1077\newif\iftxiuseunicodedestname
1078\txiuseunicodedestnamefalse % For pdfTeX etc.
1079
1080\ifx\luatexversion\thisisundefined
1081\else
1082  % Use Unicode destination names
1083  \txiuseunicodedestnametrue
1084  % Escape PDF strings with converting UTF-16 from UTF-8
1085  \begingroup
1086    \catcode`\%=12
1087    \directlua{
1088      function UTF16oct(str)
1089        tex.sprint(string.char(0x5c) .. '376' .. string.char(0x5c) .. '377')
1090        for c in string.utfvalues(str) do
1091          if c < 0x10000 then
1092            tex.sprint(
1093              string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
1094                            string.char(0x5c) .. string.char(0x25) .. '03o',
1095                            (c / 256), (c % 256)))
1096          else
1097            c = c - 0x10000
1098            local c_hi = c / 1024 + 0xd800
1099            local c_lo = c % 1024 + 0xdc00
1100            tex.sprint(
1101              string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
1102                            string.char(0x5c) .. string.char(0x25) .. '03o' ..
1103                            string.char(0x5c) .. string.char(0x25) .. '03o' ..
1104                            string.char(0x5c) .. string.char(0x25) .. '03o',
1105                            (c_hi / 256), (c_hi % 256),
1106                            (c_lo / 256), (c_lo % 256)))
1107          end
1108        end
1109      end
1110    }
1111  \endgroup
1112  \def\pdfescapestrutfsixteen#1{\directlua{UTF16oct('\luaescapestring{#1}')}}
1113  % Escape PDF strings without converting
1114  \begingroup
1115    \directlua{
1116      function PDFescstr(str)
1117        for c in string.bytes(str) do
1118          if c <= 0x20 or c >= 0x80 or c == 0x28 or c == 0x29 or c == 0x5c then
1119            tex.sprint(
1120              string.format(string.char(0x5c) .. string.char(0x25) .. '03o',
1121                            c))
1122          else
1123            tex.sprint(string.char(c))
1124          end
1125        end
1126      end
1127    }
1128  \endgroup
1129  \def\pdfescapestring#1{\directlua{PDFescstr('\luaescapestring{#1}')}}
1130  \ifnum\luatexversion>84
1131    % For LuaTeX >= 0.85
1132    \def\pdfdest{\pdfextension dest}
1133    \let\pdfoutput\outputmode
1134    \def\pdfliteral{\pdfextension literal}
1135    \def\pdfcatalog{\pdfextension catalog}
1136    \def\pdftexversion{\numexpr\pdffeedback version\relax}
1137    \let\pdfximage\saveimageresource
1138    \let\pdfrefximage\useimageresource
1139    \let\pdflastximage\lastsavedimageresourceindex
1140    \def\pdfendlink{\pdfextension endlink\relax}
1141    \def\pdfoutline{\pdfextension outline}
1142    \def\pdfstartlink{\pdfextension startlink}
1143    \def\pdffontattr{\pdfextension fontattr}
1144    \def\pdfobj{\pdfextension obj}
1145    \def\pdflastobj{\numexpr\pdffeedback lastobj\relax}
1146    \let\pdfpagewidth\pagewidth
1147    \let\pdfpageheight\pageheight
1148    \edef\pdfhorigin{\pdfvariable horigin}
1149    \edef\pdfvorigin{\pdfvariable vorigin}
1150  \fi
1151\fi
1152
1153% when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1
1154% can be set).  So we test for \relax and 0 as well as being undefined.
1155\ifx\pdfoutput\thisisundefined
1156\else
1157  \ifx\pdfoutput\relax
1158  \else
1159    \ifcase\pdfoutput
1160    \else
1161      \pdftrue
1162    \fi
1163  \fi
1164\fi
1165
1166% PDF uses PostScript string constants for the names of xref targets,
1167% for display in the outlines, and in other places.  Thus, we have to
1168% double any backslashes.  Otherwise, a name like "\node" will be
1169% interpreted as a newline (\n), followed by o, d, e.  Not good.
1170%
1171% See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and
1172% related messages.  The final outcome is that it is up to the TeX user
1173% to double the backslashes and otherwise make the string valid, so
1174% that's what we do.  pdftex 1.30.0 (ca.2005) introduced a primitive to
1175% do this reliably, so we use it.
1176
1177% #1 is a control sequence in which to do the replacements,
1178% which we \xdef.
1179\def\txiescapepdf#1{%
1180  \ifx\pdfescapestring\thisisundefined
1181    % No primitive available; should we give a warning or log?
1182    % Many times it won't matter.
1183    \xdef#1{#1}%
1184  \else
1185    % The expandable \pdfescapestring primitive escapes parentheses,
1186    % backslashes, and other special chars.
1187    \xdef#1{\pdfescapestring{#1}}%
1188  \fi
1189}
1190\def\txiescapepdfutfsixteen#1{%
1191  \ifx\pdfescapestrutfsixteen\thisisundefined
1192    % No UTF-16 converting macro available.
1193    \txiescapepdf{#1}%
1194  \else
1195    \xdef#1{\pdfescapestrutfsixteen{#1}}%
1196  \fi
1197}
1198
1199\newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images
1200with PDF output, and none of those formats could be found.  (.eps cannot
1201be supported due to the design of the PDF format; use regular TeX (DVI
1202output) for that.)}
1203
1204\ifpdf
1205  %
1206  % Color manipulation macros using ideas from pdfcolor.tex,
1207  % except using rgb instead of cmyk; the latter is said to render as a
1208  % very dark gray on-screen and a very dark halftone in print, instead
1209  % of actual black. The dark red here is dark enough to print on paper as
1210  % nearly black, but still distinguishable for online viewing.  We use
1211  % black by default, though.
1212  \def\rgbDarkRed{0.50 0.09 0.12}
1213  \def\rgbBlack{0 0 0}
1214  %
1215  % rg sets the color for filling (usual text, etc.);
1216  % RG sets the color for stroking (thin rules, e.g., normal _'s).
1217  \def\pdfsetcolor#1{\pdfliteral{#1 rg  #1 RG}}
1218  %
1219  % Set color, and create a mark which defines \thiscolor accordingly,
1220  % so that \makeheadline knows which color to restore.
1221  \def\setcolor#1{%
1222    \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}%
1223    \domark
1224    \pdfsetcolor{#1}%
1225  }
1226  %
1227  \def\maincolor{\rgbBlack}
1228  \pdfsetcolor{\maincolor}
1229  \edef\thiscolor{\maincolor}
1230  \def\lastcolordefs{}
1231  %
1232  \def\makefootline{%
1233    \baselineskip24pt
1234    \line{\pdfsetcolor{\maincolor}\the\footline}%
1235  }
1236  %
1237  \def\makeheadline{%
1238    \vbox to 0pt{%
1239      \vskip-22.5pt
1240      \line{%
1241        \vbox to8.5pt{}%
1242        % Extract \thiscolor definition from the marks.
1243        \getcolormarks
1244        % Typeset the headline with \maincolor, then restore the color.
1245        \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
1246      }%
1247      \vss
1248    }%
1249    \nointerlineskip
1250  }
1251  %
1252  %
1253  \pdfcatalog{/PageMode /UseOutlines}
1254  %
1255  % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
1256  \def\dopdfimage#1#2#3{%
1257    \def\pdfimagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
1258    \def\pdfimageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
1259    %
1260    % pdftex (and the PDF format) support .pdf, .png, .jpg (among
1261    % others).  Let's try in that order, PDF first since if
1262    % someone has a scalable image, presumably better to use that than a
1263    % bitmap.
1264    \let\pdfimgext=\empty
1265    \begingroup
1266      \openin 1 #1.pdf \ifeof 1
1267        \openin 1 #1.PDF \ifeof 1
1268          \openin 1 #1.png \ifeof 1
1269            \openin 1 #1.jpg \ifeof 1
1270              \openin 1 #1.jpeg \ifeof 1
1271                \openin 1 #1.JPG \ifeof 1
1272                  \errhelp = \nopdfimagehelp
1273                  \errmessage{Could not find image file #1 for pdf}%
1274                \else \gdef\pdfimgext{JPG}%
1275                \fi
1276              \else \gdef\pdfimgext{jpeg}%
1277              \fi
1278            \else \gdef\pdfimgext{jpg}%
1279            \fi
1280          \else \gdef\pdfimgext{png}%
1281          \fi
1282        \else \gdef\pdfimgext{PDF}%
1283        \fi
1284      \else \gdef\pdfimgext{pdf}%
1285      \fi
1286      \closein 1
1287    \endgroup
1288    %
1289    % without \immediate, ancient pdftex seg faults when the same image is
1290    % included twice.  (Version 3.14159-pre-1.0-unofficial-20010704.)
1291    \ifnum\pdftexversion < 14
1292      \immediate\pdfimage
1293    \else
1294      \immediate\pdfximage
1295    \fi
1296      \ifdim \wd0 >0pt width \pdfimagewidth \fi
1297      \ifdim \wd2 >0pt height \pdfimageheight \fi
1298      \ifnum\pdftexversion<13
1299         #1.\pdfimgext
1300       \else
1301         {#1.\pdfimgext}%
1302       \fi
1303    \ifnum\pdftexversion < 14 \else
1304      \pdfrefximage \pdflastximage
1305    \fi}
1306  %
1307  \def\setpdfdestname#1{{%
1308    % We have to set dummies so commands such as @code, and characters
1309    % such as \, aren't expanded when present in a section title.
1310    \indexnofonts
1311    \makevalueexpandable
1312    \turnoffactive
1313    \iftxiuseunicodedestname
1314      \ifx \declaredencoding \latone
1315        % Pass through Latin-1 characters.
1316        % LuaTeX with byte wise I/O converts Latin-1 characters to Unicode.
1317      \else
1318        \ifx \declaredencoding \utfeight
1319          % Pass through Unicode characters.
1320        \else
1321          % Use ASCII approximations in destination names.
1322          \passthroughcharsfalse
1323        \fi
1324      \fi
1325    \else
1326      % Use ASCII approximations in destination names.
1327      \passthroughcharsfalse
1328    \fi
1329    \def\pdfdestname{#1}%
1330    \txiescapepdf\pdfdestname
1331  }}
1332  %
1333  \def\setpdfoutlinetext#1{{%
1334    \indexnofonts
1335    \makevalueexpandable
1336    \turnoffactive
1337    \ifx \declaredencoding \latone
1338      % The PDF format can use an extended form of Latin-1 in bookmark
1339      % strings.  See Appendix D of the PDF Reference, Sixth Edition, for
1340      % the "PDFDocEncoding".
1341      \passthroughcharstrue
1342      % Pass through Latin-1 characters.
1343      %   LuaTeX: Convert to Unicode
1344      %   pdfTeX: Use Latin-1 as PDFDocEncoding
1345      \def\pdfoutlinetext{#1}%
1346    \else
1347      \ifx \declaredencoding \utfeight
1348        \ifx\luatexversion\thisisundefined
1349          % For pdfTeX  with UTF-8.
1350          % TODO: the PDF format can use UTF-16 in bookmark strings,
1351          % but the code for this isn't done yet.
1352          % Use ASCII approximations.
1353          \passthroughcharsfalse
1354          \def\pdfoutlinetext{#1}%
1355        \else
1356          % For LuaTeX with UTF-8.
1357          % Pass through Unicode characters for title texts.
1358          \passthroughcharstrue
1359          \def\pdfoutlinetext{#1}%
1360        \fi
1361      \else
1362        % For non-Latin-1 or non-UTF-8 encodings.
1363        % Use ASCII approximations.
1364        \passthroughcharsfalse
1365        \def\pdfoutlinetext{#1}%
1366      \fi
1367    \fi
1368    % LuaTeX: Convert to UTF-16
1369    % pdfTeX: Use Latin-1 as PDFDocEncoding
1370    \txiescapepdfutfsixteen\pdfoutlinetext
1371  }}
1372  %
1373  \def\pdfmkdest#1{%
1374    \setpdfdestname{#1}%
1375    \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
1376  }
1377  %
1378  % used to mark target names; must be expandable.
1379  \def\pdfmkpgn#1{#1}
1380  %
1381  % by default, use black for everything.
1382  \def\urlcolor{\rgbBlack}
1383  \def\linkcolor{\rgbBlack}
1384  \def\endlink{\setcolor{\maincolor}\pdfendlink}
1385  %
1386  % Adding outlines to PDF; macros for calculating structure of outlines
1387  % come from Petr Olsak
1388  \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
1389    \else \csname#1\endcsname \fi}
1390  \def\advancenumber#1{\tempnum=\expnumber{#1}\relax
1391    \advance\tempnum by 1
1392    \expandafter\xdef\csname#1\endcsname{\the\tempnum}}
1393  %
1394  % #1 is the section text, which is what will be displayed in the
1395  % outline by the pdf viewer.  #2 is the pdf expression for the number
1396  % of subentries (or empty, for subsubsections).  #3 is the node text,
1397  % which might be empty if this toc entry had no corresponding node.
1398  % #4 is the page number
1399  %
1400  \def\dopdfoutline#1#2#3#4{%
1401    % Generate a link to the node text if that exists; else, use the
1402    % page number.  We could generate a destination for the section
1403    % text in the case where a section has no node, but it doesn't
1404    % seem worth the trouble, since most documents are normally structured.
1405    \setpdfoutlinetext{#1}
1406    \setpdfdestname{#3}
1407    \ifx\pdfdestname\empty
1408      \def\pdfdestname{#4}%
1409    \fi
1410    %
1411    \pdfoutline goto name{\pdfmkpgn{\pdfdestname}}#2{\pdfoutlinetext}%
1412  }
1413  %
1414  \def\pdfmakeoutlines{%
1415    \begingroup
1416      % Read toc silently, to get counts of subentries for \pdfoutline.
1417      \def\partentry##1##2##3##4{}% ignore parts in the outlines
1418      \def\numchapentry##1##2##3##4{%
1419	\def\thischapnum{##2}%
1420	\def\thissecnum{0}%
1421	\def\thissubsecnum{0}%
1422      }%
1423      \def\numsecentry##1##2##3##4{%
1424	\advancenumber{chap\thischapnum}%
1425	\def\thissecnum{##2}%
1426	\def\thissubsecnum{0}%
1427      }%
1428      \def\numsubsecentry##1##2##3##4{%
1429	\advancenumber{sec\thissecnum}%
1430	\def\thissubsecnum{##2}%
1431      }%
1432      \def\numsubsubsecentry##1##2##3##4{%
1433	\advancenumber{subsec\thissubsecnum}%
1434      }%
1435      \def\thischapnum{0}%
1436      \def\thissecnum{0}%
1437      \def\thissubsecnum{0}%
1438      %
1439      % use \def rather than \let here because we redefine \chapentry et
1440      % al. a second time, below.
1441      \def\appentry{\numchapentry}%
1442      \def\appsecentry{\numsecentry}%
1443      \def\appsubsecentry{\numsubsecentry}%
1444      \def\appsubsubsecentry{\numsubsubsecentry}%
1445      \def\unnchapentry{\numchapentry}%
1446      \def\unnsecentry{\numsecentry}%
1447      \def\unnsubsecentry{\numsubsecentry}%
1448      \def\unnsubsubsecentry{\numsubsubsecentry}%
1449      \readdatafile{toc}%
1450      %
1451      % Read toc second time, this time actually producing the outlines.
1452      % The `-' means take the \expnumber as the absolute number of
1453      % subentries, which we calculated on our first read of the .toc above.
1454      %
1455      % We use the node names as the destinations.
1456      \def\numchapentry##1##2##3##4{%
1457        \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}%
1458      \def\numsecentry##1##2##3##4{%
1459        \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}%
1460      \def\numsubsecentry##1##2##3##4{%
1461        \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}%
1462      \def\numsubsubsecentry##1##2##3##4{% count is always zero
1463        \dopdfoutline{##1}{}{##3}{##4}}%
1464      %
1465      % PDF outlines are displayed using system fonts, instead of
1466      % document fonts.  Therefore we cannot use special characters,
1467      % since the encoding is unknown.  For example, the eogonek from
1468      % Latin 2 (0xea) gets translated to a | character.  Info from
1469      % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100.
1470      %
1471      % TODO this right, we have to translate 8-bit characters to
1472      % their "best" equivalent, based on the @documentencoding.  Too
1473      % much work for too little return.  Just use the ASCII equivalents
1474      % we use for the index sort strings.
1475      %
1476      \indexnofonts
1477      \setupdatafile
1478      % We can have normal brace characters in the PDF outlines, unlike
1479      % Texinfo index files.  So set that up.
1480      \def\{{\lbracecharliteral}%
1481      \def\}{\rbracecharliteral}%
1482      \catcode`\\=\active \otherbackslash
1483      \input \tocreadfilename
1484    \endgroup
1485  }
1486  {\catcode`[=1 \catcode`]=2
1487   \catcode`{=\other \catcode`}=\other
1488   \gdef\lbracecharliteral[{]%
1489   \gdef\rbracecharliteral[}]%
1490  ]
1491  %
1492  \def\skipspaces#1{\def\PP{#1}\def\D{|}%
1493    \ifx\PP\D\let\nextsp\relax
1494    \else\let\nextsp\skipspaces
1495      \addtokens{\filename}{\PP}%
1496      \advance\filenamelength by 1
1497    \fi
1498    \nextsp}
1499  \def\getfilename#1{%
1500    \filenamelength=0
1501    % If we don't expand the argument now, \skipspaces will get
1502    % snagged on things like "@value{foo}".
1503    \edef\temp{#1}%
1504    \expandafter\skipspaces\temp|\relax
1505  }
1506  \ifnum\pdftexversion < 14
1507    \let \startlink \pdfannotlink
1508  \else
1509    \let \startlink \pdfstartlink
1510  \fi
1511  % make a live url in pdf output.
1512  \def\pdfurl#1{%
1513    \begingroup
1514      % it seems we really need yet another set of dummies; have not
1515      % tried to figure out what each command should do in the context
1516      % of @url.  for now, just make @/ a no-op, that's the only one
1517      % people have actually reported a problem with.
1518      %
1519      \normalturnoffactive
1520      \def\@{@}%
1521      \let\/=\empty
1522      \makevalueexpandable
1523      % do we want to go so far as to use \indexnofonts instead of just
1524      % special-casing \var here?
1525      \def\var##1{##1}%
1526      %
1527      \leavevmode\setcolor{\urlcolor}%
1528      \startlink attr{/Border [0 0 0]}%
1529        user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
1530    \endgroup}
1531  \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1532  \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1533  \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1534  \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1535  \def\maketoks{%
1536    \expandafter\poptoks\the\toksA|ENDTOKS|\relax
1537    \ifx\first0\adn0
1538    \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1539    \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
1540    \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
1541    \else
1542      \ifnum0=\countA\else\makelink\fi
1543      \ifx\first.\let\next=\done\else
1544        \let\next=\maketoks
1545        \addtokens{\toksB}{\the\toksD}
1546        \ifx\first,\addtokens{\toksB}{\space}\fi
1547      \fi
1548    \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1549    \next}
1550  \def\makelink{\addtokens{\toksB}%
1551    {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1552  \def\pdflink#1{%
1553    \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}}
1554    \setcolor{\linkcolor}#1\endlink}
1555  \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1556\else
1557  % non-pdf mode
1558  \let\pdfmkdest = \gobble
1559  \let\pdfurl = \gobble
1560  \let\endlink = \relax
1561  \let\setcolor = \gobble
1562  \let\pdfsetcolor = \gobble
1563  \let\pdfmakeoutlines = \relax
1564\fi  % \ifx\pdfoutput
1565
1566%
1567% For XeTeX
1568%
1569\ifx\XeTeXrevision\thisisundefined
1570\else
1571  %
1572  % XeTeX version check
1573  %
1574  \ifnum\strcmp{\the\XeTeXversion\XeTeXrevision}{0.99996}>-1
1575    % TeX Live 2016 contains XeTeX 0.99996 and xdvipdfmx 20160307.
1576    % It can use the `dvipdfmx:config' special (from TeX Live SVN r40941).
1577    % For avoiding PDF destination name replacement, we use this special
1578    % instead of xdvipdfmx's command line option `-C 0x0010'.
1579    \special{dvipdfmx:config C 0x0010}
1580    % XeTeX 0.99995+ comes with xdvipdfmx 20160307+.
1581    % It can handle Unicode destination names for PDF.
1582    \txiuseunicodedestnametrue
1583  \else
1584    % XeTeX < 0.99996 (TeX Live < 2016) cannot use the
1585    % `dvipdfmx:config' special.
1586    % So for avoiding PDF destination name replacement,
1587    % xdvipdfmx's command line option `-C 0x0010' is necessary.
1588    %
1589    % XeTeX < 0.99995 can not handle Unicode destination names for PDF
1590    % because xdvipdfmx 20150315 has a UTF-16 conversion issue.
1591    % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753).
1592    \txiuseunicodedestnamefalse
1593  \fi
1594  %
1595  % Color support
1596  %
1597  \def\rgbDarkRed{0.50 0.09 0.12}
1598  \def\rgbBlack{0 0 0}
1599  %
1600  \def\pdfsetcolor#1{\special{pdf:scolor [#1]}}
1601  %
1602  % Set color, and create a mark which defines \thiscolor accordingly,
1603  % so that \makeheadline knows which color to restore.
1604  \def\setcolor#1{%
1605    \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}%
1606    \domark
1607    \pdfsetcolor{#1}%
1608  }
1609  %
1610  \def\maincolor{\rgbBlack}
1611  \pdfsetcolor{\maincolor}
1612  \edef\thiscolor{\maincolor}
1613  \def\lastcolordefs{}
1614  %
1615  \def\makefootline{%
1616    \baselineskip24pt
1617    \line{\pdfsetcolor{\maincolor}\the\footline}%
1618  }
1619  %
1620  \def\makeheadline{%
1621    \vbox to 0pt{%
1622      \vskip-22.5pt
1623      \line{%
1624        \vbox to8.5pt{}%
1625        % Extract \thiscolor definition from the marks.
1626        \getcolormarks
1627        % Typeset the headline with \maincolor, then restore the color.
1628        \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
1629      }%
1630      \vss
1631    }%
1632    \nointerlineskip
1633  }
1634  %
1635  % PDF outline support
1636  %
1637  % Emulate pdfTeX primitive
1638  \def\pdfdest name#1 xyz{%
1639    \special{pdf:dest (#1) [@thispage /XYZ @xpos @ypos null]}%
1640  }
1641  %
1642  \def\setpdfdestname#1{{%
1643    % We have to set dummies so commands such as @code, and characters
1644    % such as \, aren't expanded when present in a section title.
1645    \indexnofonts
1646    \makevalueexpandable
1647    \turnoffactive
1648    \iftxiuseunicodedestname
1649      % Pass through Unicode characters.
1650    \else
1651      % Use ASCII approximations in destination names.
1652      \passthroughcharsfalse
1653    \fi
1654    \def\pdfdestname{#1}%
1655    \txiescapepdf\pdfdestname
1656  }}
1657  %
1658  \def\setpdfoutlinetext#1{{%
1659    \turnoffactive
1660    % Always use Unicode characters in title texts.
1661    \def\pdfoutlinetext{#1}%
1662    % For XeTeX, xdvipdfmx converts to UTF-16.
1663    % So we do not convert.
1664    \txiescapepdf\pdfoutlinetext
1665  }}
1666  %
1667  \def\pdfmkdest#1{%
1668    \setpdfdestname{#1}%
1669    \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
1670  }
1671  %
1672  % by default, use black for everything.
1673  \def\urlcolor{\rgbBlack}
1674  \def\linkcolor{\rgbBlack}
1675  \def\endlink{\setcolor{\maincolor}\pdfendlink}
1676  %
1677  \def\dopdfoutline#1#2#3#4{%
1678    \setpdfoutlinetext{#1}
1679    \setpdfdestname{#3}
1680    \ifx\pdfdestname\empty
1681      \def\pdfdestname{#4}%
1682    \fi
1683    %
1684    \special{pdf:out [-] #2 << /Title (\pdfoutlinetext) /A
1685      << /S /GoTo /D (\pdfdestname) >> >> }%
1686  }
1687  %
1688  \def\pdfmakeoutlines{%
1689    \begingroup
1690      %
1691      % For XeTeX, counts of subentries are not necessary.
1692      % Therefore, we read toc only once.
1693      %
1694      % We use node names as destinations.
1695      \def\partentry##1##2##3##4{}% ignore parts in the outlines
1696      \def\numchapentry##1##2##3##4{%
1697        \dopdfoutline{##1}{1}{##3}{##4}}%
1698      \def\numsecentry##1##2##3##4{%
1699        \dopdfoutline{##1}{2}{##3}{##4}}%
1700      \def\numsubsecentry##1##2##3##4{%
1701        \dopdfoutline{##1}{3}{##3}{##4}}%
1702      \def\numsubsubsecentry##1##2##3##4{%
1703        \dopdfoutline{##1}{4}{##3}{##4}}%
1704      %
1705      \let\appentry\numchapentry%
1706      \let\appsecentry\numsecentry%
1707      \let\appsubsecentry\numsubsecentry%
1708      \let\appsubsubsecentry\numsubsubsecentry%
1709      \let\unnchapentry\numchapentry%
1710      \let\unnsecentry\numsecentry%
1711      \let\unnsubsecentry\numsubsecentry%
1712      \let\unnsubsubsecentry\numsubsubsecentry%
1713      %
1714      % For XeTeX, xdvipdfmx converts strings to UTF-16.
1715      % Therefore, the encoding and the language may not be considered.
1716      %
1717      \indexnofonts
1718      \setupdatafile
1719      % We can have normal brace characters in the PDF outlines, unlike
1720      % Texinfo index files.  So set that up.
1721      \def\{{\lbracecharliteral}%
1722      \def\}{\rbracecharliteral}%
1723      \catcode`\\=\active \otherbackslash
1724      \input \tocreadfilename
1725    \endgroup
1726  }
1727  {\catcode`[=1 \catcode`]=2
1728   \catcode`{=\other \catcode`}=\other
1729   \gdef\lbracecharliteral[{]%
1730   \gdef\rbracecharliteral[}]%
1731  ]
1732
1733  \special{pdf:docview << /PageMode /UseOutlines >> }
1734  % ``\special{pdf:tounicode ...}'' is not necessary
1735  % because xdvipdfmx converts strings from UTF-8 to UTF-16 without it.
1736  % However, due to a UTF-16 conversion issue of xdvipdfmx 20150315,
1737  % ``\special{pdf:dest ...}'' cannot handle non-ASCII strings.
1738  % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753).
1739%
1740  \def\skipspaces#1{\def\PP{#1}\def\D{|}%
1741    \ifx\PP\D\let\nextsp\relax
1742    \else\let\nextsp\skipspaces
1743      \addtokens{\filename}{\PP}%
1744      \advance\filenamelength by 1
1745    \fi
1746    \nextsp}
1747  \def\getfilename#1{%
1748    \filenamelength=0
1749    % If we don't expand the argument now, \skipspaces will get
1750    % snagged on things like "@value{foo}".
1751    \edef\temp{#1}%
1752    \expandafter\skipspaces\temp|\relax
1753  }
1754  % make a live url in pdf output.
1755  \def\pdfurl#1{%
1756    \begingroup
1757      % it seems we really need yet another set of dummies; have not
1758      % tried to figure out what each command should do in the context
1759      % of @url.  for now, just make @/ a no-op, that's the only one
1760      % people have actually reported a problem with.
1761      %
1762      \normalturnoffactive
1763      \def\@{@}%
1764      \let\/=\empty
1765      \makevalueexpandable
1766      % do we want to go so far as to use \indexnofonts instead of just
1767      % special-casing \var here?
1768      \def\var##1{##1}%
1769      %
1770      \leavevmode\setcolor{\urlcolor}%
1771      \special{pdf:bann << /Border [0 0 0]
1772        /Subtype /Link /A << /S /URI /URI (#1) >> >>}%
1773    \endgroup}
1774  \def\endlink{\setcolor{\maincolor}\special{pdf:eann}}
1775  \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1776  \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1777  \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1778  \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1779  \def\maketoks{%
1780    \expandafter\poptoks\the\toksA|ENDTOKS|\relax
1781    \ifx\first0\adn0
1782    \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1783    \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
1784    \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
1785    \else
1786      \ifnum0=\countA\else\makelink\fi
1787      \ifx\first.\let\next=\done\else
1788        \let\next=\maketoks
1789        \addtokens{\toksB}{\the\toksD}
1790        \ifx\first,\addtokens{\toksB}{\space}\fi
1791      \fi
1792    \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1793    \next}
1794  \def\makelink{\addtokens{\toksB}%
1795    {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1796  \def\pdflink#1{%
1797    \special{pdf:bann << /Border [0 0 0]
1798      /Type /Annot /Subtype /Link /A << /S /GoTo /D (#1) >> >>}%
1799    \setcolor{\linkcolor}#1\endlink}
1800  \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1801%
1802  %
1803  % @image support
1804  %
1805  % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
1806  \def\doxeteximage#1#2#3{%
1807    \def\xeteximagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
1808    \def\xeteximageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
1809    %
1810    % XeTeX (and the PDF format) supports .pdf, .png, .jpg (among
1811    % others).  Let's try in that order, PDF first since if
1812    % someone has a scalable image, presumably better to use that than a
1813    % bitmap.
1814    \let\xeteximgext=\empty
1815    \begingroup
1816      \openin 1 #1.pdf \ifeof 1
1817        \openin 1 #1.PDF \ifeof 1
1818          \openin 1 #1.png \ifeof 1
1819            \openin 1 #1.jpg \ifeof 1
1820              \openin 1 #1.jpeg \ifeof 1
1821                \openin 1 #1.JPG \ifeof 1
1822                  \errmessage{Could not find image file #1 for XeTeX}%
1823                \else \gdef\xeteximgext{JPG}%
1824                \fi
1825              \else \gdef\xeteximgext{jpeg}%
1826              \fi
1827            \else \gdef\xeteximgext{jpg}%
1828            \fi
1829          \else \gdef\xeteximgext{png}%
1830          \fi
1831        \else \gdef\xeteximgext{PDF}%
1832        \fi
1833      \else \gdef\xeteximgext{pdf}%
1834      \fi
1835      \closein 1
1836    \endgroup
1837    %
1838    \def\xetexpdfext{pdf}%
1839    \ifx\xeteximgext\xetexpdfext
1840      \XeTeXpdffile "#1".\xeteximgext ""
1841    \else
1842      \def\xetexpdfext{PDF}%
1843      \ifx\xeteximgext\xetexpdfext
1844        \XeTeXpdffile "#1".\xeteximgext ""
1845      \else
1846        \XeTeXpicfile "#1".\xeteximgext ""
1847      \fi
1848    \fi
1849    \ifdim \wd0 >0pt width \xeteximagewidth \fi
1850    \ifdim \wd2 >0pt height \xeteximageheight \fi \relax
1851  }
1852\fi
1853
1854
1855%
1856\message{fonts,}
1857
1858% Set the baselineskip to #1, and the lineskip and strut size
1859% correspondingly.  There is no deep meaning behind these magic numbers
1860% used as factors; they just match (closely enough) what Knuth defined.
1861%
1862\def\lineskipfactor{.08333}
1863\def\strutheightpercent{.70833}
1864\def\strutdepthpercent {.29167}
1865%
1866% can get a sort of poor man's double spacing by redefining this.
1867\def\baselinefactor{1}
1868%
1869\newdimen\textleading
1870\def\setleading#1{%
1871  \dimen0 = #1\relax
1872  \normalbaselineskip = \baselinefactor\dimen0
1873  \normallineskip = \lineskipfactor\normalbaselineskip
1874  \normalbaselines
1875  \setbox\strutbox =\hbox{%
1876    \vrule width0pt height\strutheightpercent\baselineskip
1877                    depth \strutdepthpercent \baselineskip
1878  }%
1879}
1880
1881% PDF CMaps.  See also LaTeX's t1.cmap.
1882%
1883% do nothing with this by default.
1884\expandafter\let\csname cmapOT1\endcsname\gobble
1885\expandafter\let\csname cmapOT1IT\endcsname\gobble
1886\expandafter\let\csname cmapOT1TT\endcsname\gobble
1887
1888% if we are producing pdf, and we have \pdffontattr, then define cmaps.
1889% (\pdffontattr was introduced many years ago, but people still run
1890% older pdftex's; it's easy to conditionalize, so we do.)
1891\ifpdf \ifx\pdffontattr\thisisundefined \else
1892  \begingroup
1893    \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
1894    \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
1895%%DocumentNeededResources: ProcSet (CIDInit)
1896%%IncludeResource: ProcSet (CIDInit)
1897%%BeginResource: CMap (TeX-OT1-0)
1898%%Title: (TeX-OT1-0 TeX OT1 0)
1899%%Version: 1.000
1900%%EndComments
1901/CIDInit /ProcSet findresource begin
190212 dict begin
1903begincmap
1904/CIDSystemInfo
1905<< /Registry (TeX)
1906/Ordering (OT1)
1907/Supplement 0
1908>> def
1909/CMapName /TeX-OT1-0 def
1910/CMapType 2 def
19111 begincodespacerange
1912<00> <7F>
1913endcodespacerange
19148 beginbfrange
1915<00> <01> <0393>
1916<09> <0A> <03A8>
1917<23> <26> <0023>
1918<28> <3B> <0028>
1919<3F> <5B> <003F>
1920<5D> <5E> <005D>
1921<61> <7A> <0061>
1922<7B> <7C> <2013>
1923endbfrange
192440 beginbfchar
1925<02> <0398>
1926<03> <039B>
1927<04> <039E>
1928<05> <03A0>
1929<06> <03A3>
1930<07> <03D2>
1931<08> <03A6>
1932<0B> <00660066>
1933<0C> <00660069>
1934<0D> <0066006C>
1935<0E> <006600660069>
1936<0F> <00660066006C>
1937<10> <0131>
1938<11> <0237>
1939<12> <0060>
1940<13> <00B4>
1941<14> <02C7>
1942<15> <02D8>
1943<16> <00AF>
1944<17> <02DA>
1945<18> <00B8>
1946<19> <00DF>
1947<1A> <00E6>
1948<1B> <0153>
1949<1C> <00F8>
1950<1D> <00C6>
1951<1E> <0152>
1952<1F> <00D8>
1953<21> <0021>
1954<22> <201D>
1955<27> <2019>
1956<3C> <00A1>
1957<3D> <003D>
1958<3E> <00BF>
1959<5C> <201C>
1960<5F> <02D9>
1961<60> <2018>
1962<7D> <02DD>
1963<7E> <007E>
1964<7F> <00A8>
1965endbfchar
1966endcmap
1967CMapName currentdict /CMap defineresource pop
1968end
1969end
1970%%EndResource
1971%%EOF
1972    }\endgroup
1973  \expandafter\edef\csname cmapOT1\endcsname#1{%
1974    \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
1975  }%
1976%
1977% \cmapOT1IT
1978  \begingroup
1979    \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
1980    \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
1981%%DocumentNeededResources: ProcSet (CIDInit)
1982%%IncludeResource: ProcSet (CIDInit)
1983%%BeginResource: CMap (TeX-OT1IT-0)
1984%%Title: (TeX-OT1IT-0 TeX OT1IT 0)
1985%%Version: 1.000
1986%%EndComments
1987/CIDInit /ProcSet findresource begin
198812 dict begin
1989begincmap
1990/CIDSystemInfo
1991<< /Registry (TeX)
1992/Ordering (OT1IT)
1993/Supplement 0
1994>> def
1995/CMapName /TeX-OT1IT-0 def
1996/CMapType 2 def
19971 begincodespacerange
1998<00> <7F>
1999endcodespacerange
20008 beginbfrange
2001<00> <01> <0393>
2002<09> <0A> <03A8>
2003<25> <26> <0025>
2004<28> <3B> <0028>
2005<3F> <5B> <003F>
2006<5D> <5E> <005D>
2007<61> <7A> <0061>
2008<7B> <7C> <2013>
2009endbfrange
201042 beginbfchar
2011<02> <0398>
2012<03> <039B>
2013<04> <039E>
2014<05> <03A0>
2015<06> <03A3>
2016<07> <03D2>
2017<08> <03A6>
2018<0B> <00660066>
2019<0C> <00660069>
2020<0D> <0066006C>
2021<0E> <006600660069>
2022<0F> <00660066006C>
2023<10> <0131>
2024<11> <0237>
2025<12> <0060>
2026<13> <00B4>
2027<14> <02C7>
2028<15> <02D8>
2029<16> <00AF>
2030<17> <02DA>
2031<18> <00B8>
2032<19> <00DF>
2033<1A> <00E6>
2034<1B> <0153>
2035<1C> <00F8>
2036<1D> <00C6>
2037<1E> <0152>
2038<1F> <00D8>
2039<21> <0021>
2040<22> <201D>
2041<23> <0023>
2042<24> <00A3>
2043<27> <2019>
2044<3C> <00A1>
2045<3D> <003D>
2046<3E> <00BF>
2047<5C> <201C>
2048<5F> <02D9>
2049<60> <2018>
2050<7D> <02DD>
2051<7E> <007E>
2052<7F> <00A8>
2053endbfchar
2054endcmap
2055CMapName currentdict /CMap defineresource pop
2056end
2057end
2058%%EndResource
2059%%EOF
2060    }\endgroup
2061  \expandafter\edef\csname cmapOT1IT\endcsname#1{%
2062    \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
2063  }%
2064%
2065% \cmapOT1TT
2066  \begingroup
2067    \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
2068    \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
2069%%DocumentNeededResources: ProcSet (CIDInit)
2070%%IncludeResource: ProcSet (CIDInit)
2071%%BeginResource: CMap (TeX-OT1TT-0)
2072%%Title: (TeX-OT1TT-0 TeX OT1TT 0)
2073%%Version: 1.000
2074%%EndComments
2075/CIDInit /ProcSet findresource begin
207612 dict begin
2077begincmap
2078/CIDSystemInfo
2079<< /Registry (TeX)
2080/Ordering (OT1TT)
2081/Supplement 0
2082>> def
2083/CMapName /TeX-OT1TT-0 def
2084/CMapType 2 def
20851 begincodespacerange
2086<00> <7F>
2087endcodespacerange
20885 beginbfrange
2089<00> <01> <0393>
2090<09> <0A> <03A8>
2091<21> <26> <0021>
2092<28> <5F> <0028>
2093<61> <7E> <0061>
2094endbfrange
209532 beginbfchar
2096<02> <0398>
2097<03> <039B>
2098<04> <039E>
2099<05> <03A0>
2100<06> <03A3>
2101<07> <03D2>
2102<08> <03A6>
2103<0B> <2191>
2104<0C> <2193>
2105<0D> <0027>
2106<0E> <00A1>
2107<0F> <00BF>
2108<10> <0131>
2109<11> <0237>
2110<12> <0060>
2111<13> <00B4>
2112<14> <02C7>
2113<15> <02D8>
2114<16> <00AF>
2115<17> <02DA>
2116<18> <00B8>
2117<19> <00DF>
2118<1A> <00E6>
2119<1B> <0153>
2120<1C> <00F8>
2121<1D> <00C6>
2122<1E> <0152>
2123<1F> <00D8>
2124<20> <2423>
2125<27> <2019>
2126<60> <2018>
2127<7F> <00A8>
2128endbfchar
2129endcmap
2130CMapName currentdict /CMap defineresource pop
2131end
2132end
2133%%EndResource
2134%%EOF
2135    }\endgroup
2136  \expandafter\edef\csname cmapOT1TT\endcsname#1{%
2137    \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
2138  }%
2139\fi\fi
2140
2141
2142% Set the font macro #1 to the font named \fontprefix#2.
2143% #3 is the font's design size, #4 is a scale factor, #5 is the CMap
2144% encoding (only OT1, OT1IT and OT1TT are allowed, or empty to omit).
2145% Example:
2146% #1 = \textrm
2147% #2 = \rmshape
2148% #3 = 10
2149% #4 = \mainmagstep
2150% #5 = OT1
2151%
2152\def\setfont#1#2#3#4#5{%
2153  \font#1=\fontprefix#2#3 scaled #4
2154  \csname cmap#5\endcsname#1%
2155}
2156% This is what gets called when #5 of \setfont is empty.
2157\let\cmap\gobble
2158%
2159% (end of cmaps)
2160
2161% Use cm as the default font prefix.
2162% To specify the font prefix, you must define \fontprefix
2163% before you read in texinfo.tex.
2164\ifx\fontprefix\thisisundefined
2165\def\fontprefix{cm}
2166\fi
2167% Support font families that don't use the same naming scheme as CM.
2168\def\rmshape{r}
2169\def\rmbshape{bx}               % where the normal face is bold
2170\def\bfshape{b}
2171\def\bxshape{bx}
2172\def\ttshape{tt}
2173\def\ttbshape{tt}
2174\def\ttslshape{sltt}
2175\def\itshape{ti}
2176\def\itbshape{bxti}
2177\def\slshape{sl}
2178\def\slbshape{bxsl}
2179\def\sfshape{ss}
2180\def\sfbshape{ss}
2181\def\scshape{csc}
2182\def\scbshape{csc}
2183
2184% Definitions for a main text size of 11pt.  (The default in Texinfo.)
2185%
2186\def\definetextfontsizexi{%
2187% Text fonts (11.2pt, magstep1).
2188\def\textnominalsize{11pt}
2189\edef\mainmagstep{\magstephalf}
2190\setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
2191\setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
2192\setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
2193\setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
2194\setfont\textsl\slshape{10}{\mainmagstep}{OT1}
2195\setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
2196\setfont\textsc\scshape{10}{\mainmagstep}{OT1}
2197\setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
2198\font\texti=cmmi10 scaled \mainmagstep
2199\font\textsy=cmsy10 scaled \mainmagstep
2200\def\textecsize{1095}
2201
2202% A few fonts for @defun names and args.
2203\setfont\defbf\bfshape{10}{\magstep1}{OT1}
2204\setfont\deftt\ttshape{10}{\magstep1}{OT1TT}
2205\setfont\defsl\slshape{10}{\magstep1}{OT1TT}
2206\setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT}
2207\def\df{\let\ttfont=\deftt \let\bffont = \defbf
2208\let\ttslfont=\defttsl \let\slfont=\defsl \bf}
2209
2210% Fonts for indices, footnotes, small examples (9pt).
2211\def\smallnominalsize{9pt}
2212\setfont\smallrm\rmshape{9}{1000}{OT1}
2213\setfont\smalltt\ttshape{9}{1000}{OT1TT}
2214\setfont\smallbf\bfshape{10}{900}{OT1}
2215\setfont\smallit\itshape{9}{1000}{OT1IT}
2216\setfont\smallsl\slshape{9}{1000}{OT1}
2217\setfont\smallsf\sfshape{9}{1000}{OT1}
2218\setfont\smallsc\scshape{10}{900}{OT1}
2219\setfont\smallttsl\ttslshape{10}{900}{OT1TT}
2220\font\smalli=cmmi9
2221\font\smallsy=cmsy9
2222\def\smallecsize{0900}
2223
2224% Fonts for small examples (8pt).
2225\def\smallernominalsize{8pt}
2226\setfont\smallerrm\rmshape{8}{1000}{OT1}
2227\setfont\smallertt\ttshape{8}{1000}{OT1TT}
2228\setfont\smallerbf\bfshape{10}{800}{OT1}
2229\setfont\smallerit\itshape{8}{1000}{OT1IT}
2230\setfont\smallersl\slshape{8}{1000}{OT1}
2231\setfont\smallersf\sfshape{8}{1000}{OT1}
2232\setfont\smallersc\scshape{10}{800}{OT1}
2233\setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
2234\font\smalleri=cmmi8
2235\font\smallersy=cmsy8
2236\def\smallerecsize{0800}
2237
2238% Fonts for math mode superscripts (7pt).
2239\def\sevennominalsize{7pt}
2240\setfont\sevenrm\rmshape{7}{1000}{OT1}
2241\setfont\seventt\ttshape{10}{700}{OT1TT}
2242\setfont\sevenbf\bfshape{10}{700}{OT1}
2243\setfont\sevenit\itshape{7}{1000}{OT1IT}
2244\setfont\sevensl\slshape{10}{700}{OT1}
2245\setfont\sevensf\sfshape{10}{700}{OT1}
2246\setfont\sevensc\scshape{10}{700}{OT1}
2247\setfont\seventtsl\ttslshape{10}{700}{OT1TT}
2248\font\seveni=cmmi7
2249\font\sevensy=cmsy7
2250\def\sevenecsize{0700}
2251
2252% Fonts for title page (20.4pt):
2253\def\titlenominalsize{20pt}
2254\setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
2255\setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
2256\setfont\titlesl\slbshape{10}{\magstep4}{OT1}
2257\setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
2258\setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
2259\setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
2260\let\titlebf=\titlerm
2261\setfont\titlesc\scbshape{10}{\magstep4}{OT1}
2262\font\titlei=cmmi12 scaled \magstep3
2263\font\titlesy=cmsy10 scaled \magstep4
2264\def\titleecsize{2074}
2265
2266% Chapter (and unnumbered) fonts (17.28pt).
2267\def\chapnominalsize{17pt}
2268\setfont\chaprm\rmbshape{12}{\magstep2}{OT1}
2269\setfont\chapit\itbshape{10}{\magstep3}{OT1IT}
2270\setfont\chapsl\slbshape{10}{\magstep3}{OT1}
2271\setfont\chaptt\ttbshape{12}{\magstep2}{OT1TT}
2272\setfont\chapttsl\ttslshape{10}{\magstep3}{OT1TT}
2273\setfont\chapsf\sfbshape{17}{1000}{OT1}
2274\let\chapbf=\chaprm
2275\setfont\chapsc\scbshape{10}{\magstep3}{OT1}
2276\font\chapi=cmmi12 scaled \magstep2
2277\font\chapsy=cmsy10 scaled \magstep3
2278\def\chapecsize{1728}
2279
2280% Section fonts (14.4pt).
2281\def\secnominalsize{14pt}
2282\setfont\secrm\rmbshape{12}{\magstep1}{OT1}
2283\setfont\secrmnotbold\rmshape{12}{\magstep1}{OT1}
2284\setfont\secit\itbshape{10}{\magstep2}{OT1IT}
2285\setfont\secsl\slbshape{10}{\magstep2}{OT1}
2286\setfont\sectt\ttbshape{12}{\magstep1}{OT1TT}
2287\setfont\secttsl\ttslshape{10}{\magstep2}{OT1TT}
2288\setfont\secsf\sfbshape{12}{\magstep1}{OT1}
2289\let\secbf\secrm
2290\setfont\secsc\scbshape{10}{\magstep2}{OT1}
2291\font\seci=cmmi12 scaled \magstep1
2292\font\secsy=cmsy10 scaled \magstep2
2293\def\sececsize{1440}
2294
2295% Subsection fonts (13.15pt).
2296\def\ssecnominalsize{13pt}
2297\setfont\ssecrm\rmbshape{12}{\magstephalf}{OT1}
2298\setfont\ssecit\itbshape{10}{1315}{OT1IT}
2299\setfont\ssecsl\slbshape{10}{1315}{OT1}
2300\setfont\ssectt\ttbshape{12}{\magstephalf}{OT1TT}
2301\setfont\ssecttsl\ttslshape{10}{1315}{OT1TT}
2302\setfont\ssecsf\sfbshape{12}{\magstephalf}{OT1}
2303\let\ssecbf\ssecrm
2304\setfont\ssecsc\scbshape{10}{1315}{OT1}
2305\font\sseci=cmmi12 scaled \magstephalf
2306\font\ssecsy=cmsy10 scaled 1315
2307\def\ssececsize{1200}
2308
2309% Reduced fonts for @acronym in text (10pt).
2310\def\reducednominalsize{10pt}
2311\setfont\reducedrm\rmshape{10}{1000}{OT1}
2312\setfont\reducedtt\ttshape{10}{1000}{OT1TT}
2313\setfont\reducedbf\bfshape{10}{1000}{OT1}
2314\setfont\reducedit\itshape{10}{1000}{OT1IT}
2315\setfont\reducedsl\slshape{10}{1000}{OT1}
2316\setfont\reducedsf\sfshape{10}{1000}{OT1}
2317\setfont\reducedsc\scshape{10}{1000}{OT1}
2318\setfont\reducedttsl\ttslshape{10}{1000}{OT1TT}
2319\font\reducedi=cmmi10
2320\font\reducedsy=cmsy10
2321\def\reducedecsize{1000}
2322
2323\textleading = 13.2pt % line spacing for 11pt CM
2324\textfonts            % reset the current fonts
2325\rm
2326} % end of 11pt text font size definitions, \definetextfontsizexi
2327
2328
2329% Definitions to make the main text be 10pt Computer Modern, with
2330% section, chapter, etc., sizes following suit.  This is for the GNU
2331% Press printing of the Emacs 22 manual.  Maybe other manuals in the
2332% future.  Used with @smallbook, which sets the leading to 12pt.
2333%
2334\def\definetextfontsizex{%
2335% Text fonts (10pt).
2336\def\textnominalsize{10pt}
2337\edef\mainmagstep{1000}
2338\setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
2339\setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
2340\setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
2341\setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
2342\setfont\textsl\slshape{10}{\mainmagstep}{OT1}
2343\setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
2344\setfont\textsc\scshape{10}{\mainmagstep}{OT1}
2345\setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
2346\font\texti=cmmi10 scaled \mainmagstep
2347\font\textsy=cmsy10 scaled \mainmagstep
2348\def\textecsize{1000}
2349
2350% A few fonts for @defun names and args.
2351\setfont\defbf\bfshape{10}{\magstephalf}{OT1}
2352\setfont\deftt\ttshape{10}{\magstephalf}{OT1TT}
2353\setfont\defsl\slshape{10}{\magstephalf}{OT1TT}
2354\setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT}
2355\def\df{\let\ttfont=\deftt \let\bffont = \defbf
2356\let\slfont=\defsl \let\ttslfont=\defttsl \bf}
2357
2358% Fonts for indices, footnotes, small examples (9pt).
2359\def\smallnominalsize{9pt}
2360\setfont\smallrm\rmshape{9}{1000}{OT1}
2361\setfont\smalltt\ttshape{9}{1000}{OT1TT}
2362\setfont\smallbf\bfshape{10}{900}{OT1}
2363\setfont\smallit\itshape{9}{1000}{OT1IT}
2364\setfont\smallsl\slshape{9}{1000}{OT1}
2365\setfont\smallsf\sfshape{9}{1000}{OT1}
2366\setfont\smallsc\scshape{10}{900}{OT1}
2367\setfont\smallttsl\ttslshape{10}{900}{OT1TT}
2368\font\smalli=cmmi9
2369\font\smallsy=cmsy9
2370\def\smallecsize{0900}
2371
2372% Fonts for small examples (8pt).
2373\def\smallernominalsize{8pt}
2374\setfont\smallerrm\rmshape{8}{1000}{OT1}
2375\setfont\smallertt\ttshape{8}{1000}{OT1TT}
2376\setfont\smallerbf\bfshape{10}{800}{OT1}
2377\setfont\smallerit\itshape{8}{1000}{OT1IT}
2378\setfont\smallersl\slshape{8}{1000}{OT1}
2379\setfont\smallersf\sfshape{8}{1000}{OT1}
2380\setfont\smallersc\scshape{10}{800}{OT1}
2381\setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
2382\font\smalleri=cmmi8
2383\font\smallersy=cmsy8
2384\def\smallerecsize{0800}
2385
2386% Fonts for math mode superscripts (7pt).
2387\def\sevennominalsize{7pt}
2388\setfont\sevenrm\rmshape{7}{1000}{OT1}
2389\setfont\seventt\ttshape{10}{700}{OT1TT}
2390\setfont\sevenbf\bfshape{10}{700}{OT1}
2391\setfont\sevenit\itshape{7}{1000}{OT1IT}
2392\setfont\sevensl\slshape{10}{700}{OT1}
2393\setfont\sevensf\sfshape{10}{700}{OT1}
2394\setfont\sevensc\scshape{10}{700}{OT1}
2395\setfont\seventtsl\ttslshape{10}{700}{OT1TT}
2396\font\seveni=cmmi7
2397\font\sevensy=cmsy7
2398\def\sevenecsize{0700}
2399
2400% Fonts for title page (20.4pt):
2401\def\titlenominalsize{20pt}
2402\setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
2403\setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
2404\setfont\titlesl\slbshape{10}{\magstep4}{OT1}
2405\setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
2406\setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
2407\setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
2408\let\titlebf=\titlerm
2409\setfont\titlesc\scbshape{10}{\magstep4}{OT1}
2410\font\titlei=cmmi12 scaled \magstep3
2411\font\titlesy=cmsy10 scaled \magstep4
2412\def\titleecsize{2074}
2413
2414% Chapter fonts (14.4pt).
2415\def\chapnominalsize{14pt}
2416\setfont\chaprm\rmbshape{12}{\magstep1}{OT1}
2417\setfont\chapit\itbshape{10}{\magstep2}{OT1IT}
2418\setfont\chapsl\slbshape{10}{\magstep2}{OT1}
2419\setfont\chaptt\ttbshape{12}{\magstep1}{OT1TT}
2420\setfont\chapttsl\ttslshape{10}{\magstep2}{OT1TT}
2421\setfont\chapsf\sfbshape{12}{\magstep1}{OT1}
2422\let\chapbf\chaprm
2423\setfont\chapsc\scbshape{10}{\magstep2}{OT1}
2424\font\chapi=cmmi12 scaled \magstep1
2425\font\chapsy=cmsy10 scaled \magstep2
2426\def\chapecsize{1440}
2427
2428% Section fonts (12pt).
2429\def\secnominalsize{12pt}
2430\setfont\secrm\rmbshape{12}{1000}{OT1}
2431\setfont\secit\itbshape{10}{\magstep1}{OT1IT}
2432\setfont\secsl\slbshape{10}{\magstep1}{OT1}
2433\setfont\sectt\ttbshape{12}{1000}{OT1TT}
2434\setfont\secttsl\ttslshape{10}{\magstep1}{OT1TT}
2435\setfont\secsf\sfbshape{12}{1000}{OT1}
2436\let\secbf\secrm
2437\setfont\secsc\scbshape{10}{\magstep1}{OT1}
2438\font\seci=cmmi12
2439\font\secsy=cmsy10 scaled \magstep1
2440\def\sececsize{1200}
2441
2442% Subsection fonts (10pt).
2443\def\ssecnominalsize{10pt}
2444\setfont\ssecrm\rmbshape{10}{1000}{OT1}
2445\setfont\ssecit\itbshape{10}{1000}{OT1IT}
2446\setfont\ssecsl\slbshape{10}{1000}{OT1}
2447\setfont\ssectt\ttbshape{10}{1000}{OT1TT}
2448\setfont\ssecttsl\ttslshape{10}{1000}{OT1TT}
2449\setfont\ssecsf\sfbshape{10}{1000}{OT1}
2450\let\ssecbf\ssecrm
2451\setfont\ssecsc\scbshape{10}{1000}{OT1}
2452\font\sseci=cmmi10
2453\font\ssecsy=cmsy10
2454\def\ssececsize{1000}
2455
2456% Reduced fonts for @acronym in text (9pt).
2457\def\reducednominalsize{9pt}
2458\setfont\reducedrm\rmshape{9}{1000}{OT1}
2459\setfont\reducedtt\ttshape{9}{1000}{OT1TT}
2460\setfont\reducedbf\bfshape{10}{900}{OT1}
2461\setfont\reducedit\itshape{9}{1000}{OT1IT}
2462\setfont\reducedsl\slshape{9}{1000}{OT1}
2463\setfont\reducedsf\sfshape{9}{1000}{OT1}
2464\setfont\reducedsc\scshape{10}{900}{OT1}
2465\setfont\reducedttsl\ttslshape{10}{900}{OT1TT}
2466\font\reducedi=cmmi9
2467\font\reducedsy=cmsy9
2468\def\reducedecsize{0900}
2469
2470\divide\parskip by 2  % reduce space between paragraphs
2471\textleading = 12pt   % line spacing for 10pt CM
2472\textfonts            % reset the current fonts
2473\rm
2474} % end of 10pt text font size definitions, \definetextfontsizex
2475
2476% Fonts for short table of contents.
2477\setfont\shortcontrm\rmshape{12}{1000}{OT1}
2478\setfont\shortcontbf\bfshape{10}{\magstep1}{OT1}  % no cmb12
2479\setfont\shortcontsl\slshape{12}{1000}{OT1}
2480\setfont\shortconttt\ttshape{12}{1000}{OT1TT}
2481
2482
2483% We provide the user-level command
2484%   @fonttextsize 10
2485% (or 11) to redefine the text font size.  pt is assumed.
2486%
2487\def\xiword{11}
2488\def\xword{10}
2489\def\xwordpt{10pt}
2490%
2491\parseargdef\fonttextsize{%
2492  \def\textsizearg{#1}%
2493  %\wlog{doing @fonttextsize \textsizearg}%
2494  %
2495  % Set \globaldefs so that documents can use this inside @tex, since
2496  % makeinfo 4.8 does not support it, but we need it nonetheless.
2497  %
2498 \begingroup \globaldefs=1
2499  \ifx\textsizearg\xword \definetextfontsizex
2500  \else \ifx\textsizearg\xiword \definetextfontsizexi
2501  \else
2502    \errhelp=\EMsimple
2503    \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'}
2504  \fi\fi
2505 \endgroup
2506}
2507
2508%
2509% Change the current font style to #1, remembering it in \curfontstyle.
2510% For now, we do not accumulate font styles: @b{@i{foo}} prints foo in
2511% italics, not bold italics.
2512%
2513\def\setfontstyle#1{%
2514  \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd.
2515  \csname #1font\endcsname  % change the current font
2516}
2517
2518\def\rm{\fam=0 \setfontstyle{rm}}
2519\def\it{\fam=\itfam \setfontstyle{it}}
2520\def\sl{\fam=\slfam \setfontstyle{sl}}
2521\def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf}
2522\def\tt{\fam=\ttfam \setfontstyle{tt}}
2523
2524% Texinfo sort of supports the sans serif font style, which plain TeX does not.
2525% So we set up a \sf.
2526\newfam\sffam
2527\def\sf{\fam=\sffam \setfontstyle{sf}}
2528
2529% We don't need math for this font style.
2530\def\ttsl{\setfontstyle{ttsl}}
2531
2532
2533% In order for the font changes to affect most math symbols and letters,
2534% we have to define the \textfont of the standard families.
2535% We don't bother to reset \scriptscriptfont; awaiting user need.
2536%
2537\def\resetmathfonts{%
2538  \textfont0=\rmfont \textfont1=\ifont \textfont2=\syfont
2539  \textfont\itfam=\itfont \textfont\slfam=\slfont \textfont\bffam=\bffont
2540  \textfont\ttfam=\ttfont \textfont\sffam=\sffont
2541  %
2542  % Fonts for superscript.  Note that the 7pt fonts are used regardless
2543  % of the current font size.
2544  \scriptfont0=\sevenrm \scriptfont1=\seveni \scriptfont2=\sevensy
2545  \scriptfont\itfam=\sevenit \scriptfont\slfam=\sevensl
2546  \scriptfont\bffam=\sevenbf \scriptfont\ttfam=\seventt
2547  \scriptfont\sffam=\sevensf
2548}
2549
2550%
2551
2552% The font-changing commands (all called \...fonts) redefine the meanings
2553% of \STYLEfont, instead of just \STYLE.  We do this because \STYLE needs
2554% to also set the current \fam for math mode.  Our \STYLE (e.g., \rm)
2555% commands hardwire \STYLEfont to set the current font.
2556%
2557% The fonts used for \ifont are for "math italics"  (\itfont is for italics
2558% in regular text).  \syfont is also used in math mode only.
2559%
2560% Each font-changing command also sets the names \lsize (one size lower)
2561% and \lllsize (three sizes lower).  These relative commands are used
2562% in, e.g., the LaTeX logo and acronyms.
2563%
2564% This all needs generalizing, badly.
2565%
2566
2567\def\assignfonts#1{%
2568  \expandafter\let\expandafter\rmfont\csname #1rm\endcsname
2569  \expandafter\let\expandafter\itfont\csname #1it\endcsname
2570  \expandafter\let\expandafter\slfont\csname #1sl\endcsname
2571  \expandafter\let\expandafter\bffont\csname #1bf\endcsname
2572  \expandafter\let\expandafter\ttfont\csname #1tt\endcsname
2573  \expandafter\let\expandafter\smallcaps\csname #1sc\endcsname
2574  \expandafter\let\expandafter\sffont  \csname #1sf\endcsname
2575  \expandafter\let\expandafter\ifont   \csname #1i\endcsname
2576  \expandafter\let\expandafter\syfont  \csname #1sy\endcsname
2577  \expandafter\let\expandafter\ttslfont\csname #1ttsl\endcsname
2578}
2579
2580\newif\ifrmisbold
2581
2582% Select smaller font size with the current style.  Used to change font size
2583% in, e.g., the LaTeX logo and acronyms.  If we are using bold fonts for
2584% normal roman text, also use bold fonts for roman text in the smaller size.
2585\def\switchtolllsize{%
2586   \expandafter\assignfonts\expandafter{\lllsize}%
2587   \ifrmisbold
2588     \let\rmfont\bffont
2589   \fi
2590   \csname\curfontstyle\endcsname
2591}%
2592
2593\def\switchtolsize{%
2594   \expandafter\assignfonts\expandafter{\lsize}%
2595   \ifrmisbold
2596     \let\rmfont\bffont
2597   \fi
2598   \csname\curfontstyle\endcsname
2599}%
2600
2601\def\definefontsetatsize#1#2#3#4#5{%
2602\expandafter\def\csname #1fonts\endcsname{%
2603  \def\curfontsize{#1}%
2604  \def\lsize{#2}\def\lllsize{#3}%
2605  \csname rmisbold#5\endcsname
2606  \assignfonts{#1}%
2607  \resetmathfonts
2608  \setleading{#4}%
2609}}
2610
2611\definefontsetatsize{text}   {reduced}{smaller}{\textleading}{false}
2612\definefontsetatsize{title}  {chap}   {subsec} {27pt}  {true}
2613\definefontsetatsize{chap}   {sec}    {text}   {19pt}  {true}
2614\definefontsetatsize{sec}    {subsec} {reduced}{17pt}  {true}
2615\definefontsetatsize{ssec}   {text}   {small}  {15pt}  {true}
2616\definefontsetatsize{reduced}{small}  {smaller}{10.5pt}{false}
2617\definefontsetatsize{small}  {smaller}{smaller}{10.5pt}{false}
2618\definefontsetatsize{smaller}{smaller}{smaller}{9.5pt} {false}
2619
2620\def\titlefont#1{{\titlefonts\rm #1}}
2621\let\subsecfonts = \ssecfonts
2622\let\subsubsecfonts = \ssecfonts
2623
2624% Define these just so they can be easily changed for other fonts.
2625\def\angleleft{$\langle$}
2626\def\angleright{$\rangle$}
2627
2628% Set the fonts to use with the @small... environments.
2629\let\smallexamplefonts = \smallfonts
2630
2631% About \smallexamplefonts.  If we use \smallfonts (9pt), @smallexample
2632% can fit this many characters:
2633%   8.5x11=86   smallbook=72  a4=90  a5=69
2634% If we use \scriptfonts (8pt), then we can fit this many characters:
2635%   8.5x11=90+  smallbook=80  a4=90+  a5=77
2636% For me, subjectively, the few extra characters that fit aren't worth
2637% the additional smallness of 8pt.  So I'm making the default 9pt.
2638%
2639% By the way, for comparison, here's what fits with @example (10pt):
2640%   8.5x11=71  smallbook=60  a4=75  a5=58
2641% --karl, 24jan03.
2642
2643% Set up the default fonts, so we can use them for creating boxes.
2644%
2645\definetextfontsizexi
2646
2647
2648\message{markup,}
2649
2650% Check if we are currently using a typewriter font.  Since all the
2651% Computer Modern typewriter fonts have zero interword stretch (and
2652% shrink), and it is reasonable to expect all typewriter fonts to have
2653% this property, we can check that font parameter.
2654%
2655\def\ifmonospace{\ifdim\fontdimen3\font=0pt }
2656
2657% Markup style infrastructure.  \defmarkupstylesetup\INITMACRO will
2658% define and register \INITMACRO to be called on markup style changes.
2659% \INITMACRO can check \currentmarkupstyle for the innermost
2660% style.
2661
2662\let\currentmarkupstyle\empty
2663
2664\def\setupmarkupstyle#1{%
2665  \def\currentmarkupstyle{#1}%
2666  \markupstylesetup
2667}
2668
2669\let\markupstylesetup\empty
2670
2671\def\defmarkupstylesetup#1{%
2672  \expandafter\def\expandafter\markupstylesetup
2673    \expandafter{\markupstylesetup #1}%
2674  \def#1%
2675}
2676
2677% Markup style setup for left and right quotes.
2678\defmarkupstylesetup\markupsetuplq{%
2679  \expandafter\let\expandafter \temp
2680    \csname markupsetuplq\currentmarkupstyle\endcsname
2681  \ifx\temp\relax \markupsetuplqdefault \else \temp \fi
2682}
2683
2684\defmarkupstylesetup\markupsetuprq{%
2685  \expandafter\let\expandafter \temp
2686    \csname markupsetuprq\currentmarkupstyle\endcsname
2687  \ifx\temp\relax \markupsetuprqdefault \else \temp \fi
2688}
2689
2690{
2691\catcode`\'=\active
2692\catcode`\`=\active
2693
2694\gdef\markupsetuplqdefault{\let`\lq}
2695\gdef\markupsetuprqdefault{\let'\rq}
2696
2697\gdef\markupsetcodequoteleft{\let`\codequoteleft}
2698\gdef\markupsetcodequoteright{\let'\codequoteright}
2699}
2700
2701\let\markupsetuplqcode \markupsetcodequoteleft
2702\let\markupsetuprqcode \markupsetcodequoteright
2703%
2704\let\markupsetuplqexample \markupsetcodequoteleft
2705\let\markupsetuprqexample \markupsetcodequoteright
2706%
2707\let\markupsetuplqkbd     \markupsetcodequoteleft
2708\let\markupsetuprqkbd     \markupsetcodequoteright
2709%
2710\let\markupsetuplqsamp \markupsetcodequoteleft
2711\let\markupsetuprqsamp \markupsetcodequoteright
2712%
2713\let\markupsetuplqverb \markupsetcodequoteleft
2714\let\markupsetuprqverb \markupsetcodequoteright
2715%
2716\let\markupsetuplqverbatim \markupsetcodequoteleft
2717\let\markupsetuprqverbatim \markupsetcodequoteright
2718
2719% Allow an option to not use regular directed right quote/apostrophe
2720% (char 0x27), but instead the undirected quote from cmtt (char 0x0d).
2721% The undirected quote is ugly, so don't make it the default, but it
2722% works for pasting with more pdf viewers (at least evince), the
2723% lilypond developers report.  xpdf does work with the regular 0x27.
2724%
2725\def\codequoteright{%
2726  \ifmonospace
2727    \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax
2728      \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax
2729        '%
2730      \else \char'15 \fi
2731    \else \char'15 \fi
2732   \else
2733     '%
2734   \fi
2735}
2736%
2737% and a similar option for the left quote char vs. a grave accent.
2738% Modern fonts display ASCII 0x60 as a grave accent, so some people like
2739% the code environments to do likewise.
2740%
2741\def\codequoteleft{%
2742  \ifmonospace
2743    \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax
2744      \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax
2745        % [Knuth] pp. 380,381,391
2746        % \relax disables Spanish ligatures ?` and !` of \tt font.
2747        \relax`%
2748      \else \char'22 \fi
2749    \else \char'22 \fi
2750   \else
2751     \relax`%
2752   \fi
2753}
2754
2755% Commands to set the quote options.
2756%
2757\parseargdef\codequoteundirected{%
2758  \def\temp{#1}%
2759  \ifx\temp\onword
2760    \expandafter\let\csname SETtxicodequoteundirected\endcsname
2761      = t%
2762  \else\ifx\temp\offword
2763    \expandafter\let\csname SETtxicodequoteundirected\endcsname
2764      = \relax
2765  \else
2766    \errhelp = \EMsimple
2767    \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}%
2768  \fi\fi
2769}
2770%
2771\parseargdef\codequotebacktick{%
2772  \def\temp{#1}%
2773  \ifx\temp\onword
2774    \expandafter\let\csname SETtxicodequotebacktick\endcsname
2775      = t%
2776  \else\ifx\temp\offword
2777    \expandafter\let\csname SETtxicodequotebacktick\endcsname
2778      = \relax
2779  \else
2780    \errhelp = \EMsimple
2781    \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}%
2782  \fi\fi
2783}
2784
2785% [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font.
2786\def\noligaturesquoteleft{\relax\lq}
2787
2788% Count depth in font-changes, for error checks
2789\newcount\fontdepth \fontdepth=0
2790
2791% Font commands.
2792
2793% #1 is the font command (\sl or \it), #2 is the text to slant.
2794% If we are in a monospaced environment, however, 1) always use \ttsl,
2795% and 2) do not add an italic correction.
2796\def\dosmartslant#1#2{%
2797  \ifusingtt
2798    {{\ttsl #2}\let\next=\relax}%
2799    {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}%
2800  \next
2801}
2802\def\smartslanted{\dosmartslant\sl}
2803\def\smartitalic{\dosmartslant\it}
2804
2805% Output an italic correction unless \next (presumed to be the following
2806% character) is such as not to need one.
2807\def\smartitaliccorrection{%
2808  \ifx\next,%
2809  \else\ifx\next-%
2810  \else\ifx\next.%
2811  \else\ifx\next\.%
2812  \else\ifx\next\comma%
2813  \else\ptexslash
2814  \fi\fi\fi\fi\fi
2815  \aftersmartic
2816}
2817
2818% Unconditional use \ttsl, and no ic.  @var is set to this for defuns.
2819\def\ttslanted#1{{\ttsl #1}}
2820
2821% @cite is like \smartslanted except unconditionally use \sl.  We never want
2822% ttsl for book titles, do we?
2823\def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection}
2824
2825\def\aftersmartic{}
2826\def\var#1{%
2827  \let\saveaftersmartic = \aftersmartic
2828  \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}%
2829  \smartslanted{#1}%
2830}
2831
2832\let\i=\smartitalic
2833\let\slanted=\smartslanted
2834\let\dfn=\smartslanted
2835\let\emph=\smartitalic
2836
2837% Explicit font changes: @r, @sc, undocumented @ii.
2838\def\r#1{{\rm #1}}              % roman font
2839\def\sc#1{{\smallcaps#1}}       % smallcaps font
2840\def\ii#1{{\it #1}}             % italic font
2841
2842% @b, explicit bold.  Also @strong.
2843\def\b#1{{\bf #1}}
2844\let\strong=\b
2845
2846% @sansserif, explicit sans.
2847\def\sansserif#1{{\sf #1}}
2848
2849% We can't just use \exhyphenpenalty, because that only has effect at
2850% the end of a paragraph.  Restore normal hyphenation at the end of the
2851% group within which \nohyphenation is presumably called.
2852%
2853\def\nohyphenation{\hyphenchar\font = -1  \aftergroup\restorehyphenation}
2854\def\restorehyphenation{\hyphenchar\font = `- }
2855
2856% Set sfcode to normal for the chars that usually have another value.
2857% Can't use plain's \frenchspacing because it uses the `\x notation, and
2858% sometimes \x has an active definition that messes things up.
2859%
2860\catcode`@=11
2861  \def\plainfrenchspacing{%
2862    \sfcode`\.=\@m \sfcode`\?=\@m \sfcode`\!=\@m
2863    \sfcode`\:=\@m \sfcode`\;=\@m \sfcode`\,=\@m
2864    \def\endofsentencespacefactor{1000}% for @. and friends
2865  }
2866  \def\plainnonfrenchspacing{%
2867    \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000
2868    \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250
2869    \def\endofsentencespacefactor{3000}% for @. and friends
2870  }
2871\catcode`@=\other
2872\def\endofsentencespacefactor{3000}% default
2873
2874% @t, explicit typewriter.
2875\def\t#1{%
2876  {\tt \rawbackslash \plainfrenchspacing #1}%
2877  \null
2878}
2879
2880% @samp.
2881\def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}}
2882
2883% @indicateurl is \samp, that is, with quotes.
2884\let\indicateurl=\samp
2885
2886% @code (and similar) prints in typewriter, but with spaces the same
2887% size as normal in the surrounding text, without hyphenation, etc.
2888% This is a subroutine for that.
2889\def\tclose#1{%
2890  {%
2891    % Change normal interword space to be same as for the current font.
2892    \spaceskip = \fontdimen2\font
2893    %
2894    % Switch to typewriter.
2895    \tt
2896    %
2897    % But `\ ' produces the large typewriter interword space.
2898    \def\ {{\spaceskip = 0pt{} }}%
2899    %
2900    % Turn off hyphenation.
2901    \nohyphenation
2902    %
2903    \rawbackslash
2904    \plainfrenchspacing
2905    #1%
2906  }%
2907  \null % reset spacefactor to 1000
2908}
2909
2910% We *must* turn on hyphenation at `-' and `_' in @code.
2911% (But see \codedashfinish below.)
2912% Otherwise, it is too hard to avoid overfull hboxes
2913% in the Emacs manual, the Library manual, etc.
2914%
2915% Unfortunately, TeX uses one parameter (\hyphenchar) to control
2916% both hyphenation at - and hyphenation within words.
2917% We must therefore turn them both off (\tclose does that)
2918% and arrange explicitly to hyphenate at a dash. -- rms.
2919{
2920  \catcode`\-=\active \catcode`\_=\active
2921  \catcode`\'=\active \catcode`\`=\active
2922  \global\let'=\rq \global\let`=\lq  % default definitions
2923  %
2924  \global\def\code{\begingroup
2925    \setupmarkupstyle{code}%
2926    % The following should really be moved into \setupmarkupstyle handlers.
2927    \catcode\dashChar=\active  \catcode\underChar=\active
2928    \ifallowcodebreaks
2929     \let-\codedash
2930     \let_\codeunder
2931    \else
2932     \let-\normaldash
2933     \let_\realunder
2934    \fi
2935    % Given -foo (with a single dash), we do not want to allow a break
2936    % after the hyphen.
2937    \global\let\codedashprev=\codedash
2938    %
2939    \codex
2940  }
2941  %
2942  \gdef\codedash{\futurelet\next\codedashfinish}
2943  \gdef\codedashfinish{%
2944    \normaldash % always output the dash character itself.
2945    %
2946    % Now, output a discretionary to allow a line break, unless
2947    % (a) the next character is a -, or
2948    % (b) the preceding character is a -.
2949    % E.g., given --posix, we do not want to allow a break after either -.
2950    % Given --foo-bar, we do want to allow a break between the - and the b.
2951    \ifx\next\codedash \else
2952      \ifx\codedashprev\codedash
2953      \else \discretionary{}{}{}\fi
2954    \fi
2955    % we need the space after the = for the case when \next itself is a
2956    % space token; it would get swallowed otherwise.  As in @code{- a}.
2957    \global\let\codedashprev= \next
2958  }
2959}
2960\def\normaldash{-}
2961%
2962\def\codex #1{\tclose{#1}\endgroup}
2963
2964\def\codeunder{%
2965  % this is all so @math{@code{var_name}+1} can work.  In math mode, _
2966  % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.)
2967  % will therefore expand the active definition of _, which is us
2968  % (inside @code that is), therefore an endless loop.
2969  \ifusingtt{\ifmmode
2970               \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_.
2971             \else\normalunderscore \fi
2972             \discretionary{}{}{}}%
2973            {\_}%
2974}
2975
2976% An additional complication: the above will allow breaks after, e.g.,
2977% each of the four underscores in __typeof__.  This is bad.
2978% @allowcodebreaks provides a document-level way to turn breaking at -
2979% and _ on and off.
2980%
2981\newif\ifallowcodebreaks  \allowcodebreakstrue
2982
2983\def\keywordtrue{true}
2984\def\keywordfalse{false}
2985
2986\parseargdef\allowcodebreaks{%
2987  \def\txiarg{#1}%
2988  \ifx\txiarg\keywordtrue
2989    \allowcodebreakstrue
2990  \else\ifx\txiarg\keywordfalse
2991    \allowcodebreaksfalse
2992  \else
2993    \errhelp = \EMsimple
2994    \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}%
2995  \fi\fi
2996}
2997
2998% For @command, @env, @file, @option quotes seem unnecessary,
2999% so use \code rather than \samp.
3000\let\command=\code
3001\let\env=\code
3002\let\file=\code
3003\let\option=\code
3004
3005% @uref (abbreviation for `urlref') aka @url takes an optional
3006% (comma-separated) second argument specifying the text to display and
3007% an optional third arg as text to display instead of (rather than in
3008% addition to) the url itself.  First (mandatory) arg is the url.
3009
3010% TeX-only option to allow changing PDF output to show only the second
3011% arg (if given), and not the url (which is then just the link target).
3012\newif\ifurefurlonlylink
3013
3014% The main macro is \urefbreak, which allows breaking at expected
3015% places within the url.  (There used to be another version, which
3016% didn't support automatic breaking.)
3017\def\urefbreak{\begingroup \urefcatcodes \dourefbreak}
3018\let\uref=\urefbreak
3019%
3020\def\dourefbreak#1{\urefbreakfinish #1,,,\finish}
3021\def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example
3022  \unsepspaces
3023  \pdfurl{#1}%
3024  \setbox0 = \hbox{\ignorespaces #3}%
3025  \ifdim\wd0 > 0pt
3026    \unhbox0 % third arg given, show only that
3027  \else
3028    \setbox0 = \hbox{\ignorespaces #2}% look for second arg
3029    \ifdim\wd0 > 0pt
3030      \ifpdf
3031        % For pdfTeX and LuaTeX
3032        \ifurefurlonlylink
3033          % PDF plus option to not display url, show just arg
3034          \unhbox0
3035        \else
3036          % PDF, normally display both arg and url for consistency,
3037          % visibility, if the pdf is eventually used to print, etc.
3038          \unhbox0\ (\urefcode{#1})%
3039        \fi
3040      \else
3041        \ifx\XeTeXrevision\thisisundefined
3042          \unhbox0\ (\urefcode{#1})% DVI, always show arg and url
3043        \else
3044          % For XeTeX
3045          \ifurefurlonlylink
3046            % PDF plus option to not display url, show just arg
3047            \unhbox0
3048          \else
3049            % PDF, normally display both arg and url for consistency,
3050            % visibility, if the pdf is eventually used to print, etc.
3051            \unhbox0\ (\urefcode{#1})%
3052          \fi
3053        \fi
3054      \fi
3055    \else
3056      \urefcode{#1}% only url given, so show it
3057    \fi
3058  \fi
3059  \endlink
3060\endgroup}
3061
3062% Allow line breaks around only a few characters (only).
3063\def\urefcatcodes{%
3064  \catcode`\&=\active \catcode`\.=\active
3065  \catcode`\#=\active \catcode`\?=\active
3066  \catcode`\/=\active
3067}
3068{
3069  \urefcatcodes
3070  %
3071  \global\def\urefcode{\begingroup
3072    \setupmarkupstyle{code}%
3073    \urefcatcodes
3074    \let&\urefcodeamp
3075    \let.\urefcodedot
3076    \let#\urefcodehash
3077    \let?\urefcodequest
3078    \let/\urefcodeslash
3079    \codex
3080  }
3081  %
3082  % By default, they are just regular characters.
3083  \global\def&{\normalamp}
3084  \global\def.{\normaldot}
3085  \global\def#{\normalhash}
3086  \global\def?{\normalquest}
3087  \global\def/{\normalslash}
3088}
3089
3090% we put a little stretch before and after the breakable chars, to help
3091% line breaking of long url's.  The unequal skips make look better in
3092% cmtt at least, especially for dots.
3093\def\urefprestretchamount{.13em}
3094\def\urefpoststretchamount{.1em}
3095\def\urefprestretch{\urefprebreak \hskip0pt plus\urefprestretchamount\relax}
3096\def\urefpoststretch{\urefpostbreak \hskip0pt plus\urefprestretchamount\relax}
3097%
3098\def\urefcodeamp{\urefprestretch \&\urefpoststretch}
3099\def\urefcodedot{\urefprestretch .\urefpoststretch}
3100\def\urefcodehash{\urefprestretch \#\urefpoststretch}
3101\def\urefcodequest{\urefprestretch ?\urefpoststretch}
3102\def\urefcodeslash{\futurelet\next\urefcodeslashfinish}
3103{
3104  \catcode`\/=\active
3105  \global\def\urefcodeslashfinish{%
3106    \urefprestretch \slashChar
3107    % Allow line break only after the final / in a sequence of
3108    % slashes, to avoid line break between the slashes in http://.
3109    \ifx\next/\else \urefpoststretch \fi
3110  }
3111}
3112
3113% One more complication: by default we'll break after the special
3114% characters, but some people like to break before the special chars, so
3115% allow that.  Also allow no breaking at all, for manual control.
3116%
3117\parseargdef\urefbreakstyle{%
3118  \def\txiarg{#1}%
3119  \ifx\txiarg\wordnone
3120    \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak}
3121  \else\ifx\txiarg\wordbefore
3122    \def\urefprebreak{\allowbreak}\def\urefpostbreak{\nobreak}
3123  \else\ifx\txiarg\wordafter
3124    \def\urefprebreak{\nobreak}\def\urefpostbreak{\allowbreak}
3125  \else
3126    \errhelp = \EMsimple
3127    \errmessage{Unknown @urefbreakstyle setting `\txiarg'}%
3128  \fi\fi\fi
3129}
3130\def\wordafter{after}
3131\def\wordbefore{before}
3132\def\wordnone{none}
3133
3134\urefbreakstyle after
3135
3136% @url synonym for @uref, since that's how everyone uses it.
3137%
3138\let\url=\uref
3139
3140% rms does not like angle brackets --karl, 17may97.
3141% So now @email is just like @uref, unless we are pdf.
3142%
3143%\def\email#1{\angleleft{\tt #1}\angleright}
3144\ifpdf
3145  \def\email#1{\doemail#1,,\finish}
3146  \def\doemail#1,#2,#3\finish{\begingroup
3147    \unsepspaces
3148    \pdfurl{mailto:#1}%
3149    \setbox0 = \hbox{\ignorespaces #2}%
3150    \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
3151    \endlink
3152  \endgroup}
3153\else
3154  \ifx\XeTeXrevision\thisisundefined
3155    \let\email=\uref
3156  \else
3157    \def\email#1{\doemail#1,,\finish}
3158    \def\doemail#1,#2,#3\finish{\begingroup
3159      \unsepspaces
3160      \pdfurl{mailto:#1}%
3161      \setbox0 = \hbox{\ignorespaces #2}%
3162      \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
3163      \endlink
3164    \endgroup}
3165  \fi
3166\fi
3167
3168% @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
3169%   `example' (@kbd uses ttsl only inside of @example and friends),
3170%   or `code' (@kbd uses normal tty font always).
3171\parseargdef\kbdinputstyle{%
3172  \def\txiarg{#1}%
3173  \ifx\txiarg\worddistinct
3174    \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
3175  \else\ifx\txiarg\wordexample
3176    \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
3177  \else\ifx\txiarg\wordcode
3178    \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
3179  \else
3180    \errhelp = \EMsimple
3181    \errmessage{Unknown @kbdinputstyle setting `\txiarg'}%
3182  \fi\fi\fi
3183}
3184\def\worddistinct{distinct}
3185\def\wordexample{example}
3186\def\wordcode{code}
3187
3188% Default is `distinct'.
3189\kbdinputstyle distinct
3190
3191% @kbd is like @code, except that if the argument is just one @key command,
3192% then @kbd has no effect.
3193\def\kbd#1{{\def\look{#1}\expandafter\kbdsub\look??\par}}
3194
3195\def\xkey{\key}
3196\def\kbdsub#1#2#3\par{%
3197  \def\one{#1}\def\three{#3}\def\threex{??}%
3198  \ifx\one\xkey\ifx\threex\three \key{#2}%
3199  \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
3200  \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
3201}
3202
3203% definition of @key that produces a lozenge.  Doesn't adjust to text size.
3204%\setfont\keyrm\rmshape{8}{1000}{OT1}
3205%\font\keysy=cmsy9
3206%\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
3207%  \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
3208%    \vbox{\hrule\kern-0.4pt
3209%     \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
3210%    \kern-0.4pt\hrule}%
3211%  \kern-.06em\raise0.4pt\hbox{\angleright}}}}
3212
3213% definition of @key with no lozenge.  If the current font is already
3214% monospace, don't change it; that way, we respect @kbdinputstyle.  But
3215% if it isn't monospace, then use \tt.
3216%
3217\def\key#1{{\setupmarkupstyle{key}%
3218  \nohyphenation
3219  \ifmonospace\else\tt\fi
3220  #1}\null}
3221
3222% @clicksequence{File @click{} Open ...}
3223\def\clicksequence#1{\begingroup #1\endgroup}
3224
3225% @clickstyle @arrow   (by default)
3226\parseargdef\clickstyle{\def\click{#1}}
3227\def\click{\arrow}
3228
3229% Typeset a dimension, e.g., `in' or `pt'.  The only reason for the
3230% argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
3231%
3232\def\dmn#1{\thinspace #1}
3233
3234% @acronym for "FBI", "NATO", and the like.
3235% We print this one point size smaller, since it's intended for
3236% all-uppercase.
3237%
3238\def\acronym#1{\doacronym #1,,\finish}
3239\def\doacronym#1,#2,#3\finish{%
3240  {\switchtolsize #1}%
3241  \def\temp{#2}%
3242  \ifx\temp\empty \else
3243    \space ({\unsepspaces \ignorespaces \temp \unskip})%
3244  \fi
3245  \null % reset \spacefactor=1000
3246}
3247
3248% @abbr for "Comput. J." and the like.
3249% No font change, but don't do end-of-sentence spacing.
3250%
3251\def\abbr#1{\doabbr #1,,\finish}
3252\def\doabbr#1,#2,#3\finish{%
3253  {\plainfrenchspacing #1}%
3254  \def\temp{#2}%
3255  \ifx\temp\empty \else
3256    \space ({\unsepspaces \ignorespaces \temp \unskip})%
3257  \fi
3258  \null % reset \spacefactor=1000
3259}
3260
3261% @asis just yields its argument.  Used with @table, for example.
3262%
3263\def\asis#1{#1}
3264
3265% @math outputs its argument in math mode.
3266%
3267% One complication: _ usually means subscripts, but it could also mean
3268% an actual _ character, as in @math{@var{some_variable} + 1}.  So make
3269% _ active, and distinguish by seeing if the current family is \slfam,
3270% which is what @var uses.
3271{
3272  \catcode`\_ = \active
3273  \gdef\mathunderscore{%
3274    \catcode`\_=\active
3275    \def_{\ifnum\fam=\slfam \_\else\sb\fi}%
3276  }
3277}
3278% Another complication: we want \\ (and @\) to output a math (or tt) \.
3279% FYI, plain.tex uses \\ as a temporary control sequence (for no
3280% particular reason), but this is not advertised and we don't care.
3281%
3282% The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\.
3283\def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi}
3284%
3285\def\math{%
3286  \ifmmode\else % only go into math if not in math mode already
3287    \tex
3288    \mathunderscore
3289    \let\\ = \mathbackslash
3290    \mathactive
3291    % make the texinfo accent commands work in math mode
3292    \let\"=\ddot
3293    \let\'=\acute
3294    \let\==\bar
3295    \let\^=\hat
3296    \let\`=\grave
3297    \let\u=\breve
3298    \let\v=\check
3299    \let\~=\tilde
3300    \let\dotaccent=\dot
3301    % have to provide another name for sup operator
3302    \let\mathopsup=\sup
3303  $\expandafter\finishmath\fi
3304}
3305\def\finishmath#1{#1$\endgroup}  % Close the group opened by \tex.
3306
3307% Some active characters (such as <) are spaced differently in math.
3308% We have to reset their definitions in case the @math was an argument
3309% to a command which sets the catcodes (such as @item or @section).
3310%
3311{
3312  \catcode`^ = \active
3313  \catcode`< = \active
3314  \catcode`> = \active
3315  \catcode`+ = \active
3316  \catcode`' = \active
3317  \gdef\mathactive{%
3318    \let^ = \ptexhat
3319    \let< = \ptexless
3320    \let> = \ptexgtr
3321    \let+ = \ptexplus
3322    \let' = \ptexquoteright
3323  }
3324}
3325
3326% for @sub and @sup, if in math mode, just do a normal sub/superscript.
3327% If in text, use math to place as sub/superscript, but switch
3328% into text mode, with smaller fonts.  This is a different font than the
3329% one used for real math sub/superscripts (8pt vs. 7pt), but let's not
3330% fix it (significant additions to font machinery) until someone notices.
3331%
3332\def\sub{\ifmmode \expandafter\sb \else \expandafter\finishsub\fi}
3333\def\finishsub#1{$\sb{\hbox{\switchtolllsize #1}}$}%
3334%
3335\def\sup{\ifmmode \expandafter\ptexsp \else \expandafter\finishsup\fi}
3336\def\finishsup#1{$\ptexsp{\hbox{\switchtolllsize #1}}$}%
3337
3338% @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}.
3339% Ignore unless FMTNAME == tex; then it is like @iftex and @tex,
3340% except specified as a normal braced arg, so no newlines to worry about.
3341%
3342\def\outfmtnametex{tex}
3343%
3344\long\def\inlinefmt#1{\doinlinefmt #1,\finish}
3345\long\def\doinlinefmt#1,#2,\finish{%
3346  \def\inlinefmtname{#1}%
3347  \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi
3348}
3349%
3350% @inlinefmtifelse{FMTNAME,THEN-TEXT,ELSE-TEXT} expands THEN-TEXT if
3351% FMTNAME is tex, else ELSE-TEXT.
3352\long\def\inlinefmtifelse#1{\doinlinefmtifelse #1,,,\finish}
3353\long\def\doinlinefmtifelse#1,#2,#3,#4,\finish{%
3354  \def\inlinefmtname{#1}%
3355  \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\else \ignorespaces #3\fi
3356}
3357%
3358% For raw, must switch into @tex before parsing the argument, to avoid
3359% setting catcodes prematurely.  Doing it this way means that, for
3360% example, @inlineraw{html, foo{bar} gets a parse error instead of being
3361% ignored.  But this isn't important because if people want a literal
3362% *right* brace they would have to use a command anyway, so they may as
3363% well use a command to get a left brace too.  We could re-use the
3364% delimiter character idea from \verb, but it seems like overkill.
3365%
3366\long\def\inlineraw{\tex \doinlineraw}
3367\long\def\doinlineraw#1{\doinlinerawtwo #1,\finish}
3368\def\doinlinerawtwo#1,#2,\finish{%
3369  \def\inlinerawname{#1}%
3370  \ifx\inlinerawname\outfmtnametex \ignorespaces #2\fi
3371  \endgroup % close group opened by \tex.
3372}
3373
3374% @inlineifset{VAR, TEXT} expands TEXT if VAR is @set.
3375%
3376\long\def\inlineifset#1{\doinlineifset #1,\finish}
3377\long\def\doinlineifset#1,#2,\finish{%
3378  \def\inlinevarname{#1}%
3379  \expandafter\ifx\csname SET\inlinevarname\endcsname\relax
3380  \else\ignorespaces#2\fi
3381}
3382
3383% @inlineifclear{VAR, TEXT} expands TEXT if VAR is not @set.
3384%
3385\long\def\inlineifclear#1{\doinlineifclear #1,\finish}
3386\long\def\doinlineifclear#1,#2,\finish{%
3387  \def\inlinevarname{#1}%
3388  \expandafter\ifx\csname SET\inlinevarname\endcsname\relax \ignorespaces#2\fi
3389}
3390
3391
3392\message{glyphs,}
3393% and logos.
3394
3395% @@ prints an @, as does @atchar{}.
3396\def\@{\char64 }
3397\let\atchar=\@
3398
3399% @{ @} @lbracechar{} @rbracechar{} all generate brace characters.
3400\def\lbracechar{{\ifmonospace\char123\else\ensuremath\lbrace\fi}}
3401\def\rbracechar{{\ifmonospace\char125\else\ensuremath\rbrace\fi}}
3402\let\{=\lbracechar
3403\let\}=\rbracechar
3404
3405% @comma{} to avoid , parsing problems.
3406\let\comma = ,
3407
3408% Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
3409% Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H.
3410\let\, = \ptexc
3411\let\dotaccent = \ptexdot
3412\def\ringaccent#1{{\accent23 #1}}
3413\let\tieaccent = \ptext
3414\let\ubaraccent = \ptexb
3415\let\udotaccent = \d
3416
3417% Other special characters: @questiondown @exclamdown @ordf @ordm
3418% Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss.
3419\def\questiondown{?`}
3420\def\exclamdown{!`}
3421\def\ordf{\leavevmode\raise1ex\hbox{\switchtolllsize \underbar{a}}}
3422\def\ordm{\leavevmode\raise1ex\hbox{\switchtolllsize \underbar{o}}}
3423
3424% Dotless i and dotless j, used for accents.
3425\def\imacro{i}
3426\def\jmacro{j}
3427\def\dotless#1{%
3428  \def\temp{#1}%
3429  \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi
3430  \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi
3431  \else \errmessage{@dotless can be used only with i or j}%
3432  \fi\fi
3433}
3434
3435% The \TeX{} logo, as in plain, but resetting the spacing so that a
3436% period following counts as ending a sentence.  (Idea found in latex.)
3437%
3438\edef\TeX{\TeX \spacefactor=1000 }
3439
3440% @LaTeX{} logo.  Not quite the same results as the definition in
3441% latex.ltx, since we use a different font for the raised A; it's most
3442% convenient for us to use an explicitly smaller font, rather than using
3443% the \scriptstyle font (since we don't reset \scriptstyle and
3444% \scriptscriptstyle).
3445%
3446\def\LaTeX{%
3447  L\kern-.36em
3448  {\setbox0=\hbox{T}%
3449   \vbox to \ht0{\hbox{%
3450     \ifx\textnominalsize\xwordpt
3451       % for 10pt running text, lllsize (8pt) is too small for the A in LaTeX.
3452       % Revert to plain's \scriptsize, which is 7pt.
3453       \count255=\the\fam $\fam\count255 \scriptstyle A$%
3454     \else
3455       % For 11pt, we can use our lllsize.
3456       \switchtolllsize A%
3457     \fi
3458     }%
3459     \vss
3460  }}%
3461  \kern-.15em
3462  \TeX
3463}
3464
3465% Some math mode symbols.  Define \ensuremath to switch into math mode
3466% unless we are already there.  Expansion tricks may not be needed here,
3467% but safer, and can't hurt.
3468\def\ensuremath{\ifmmode \expandafter\asis \else\expandafter\ensuredmath \fi}
3469\def\ensuredmath#1{$\relax#1$}
3470%
3471\def\bullet{\ensuremath\ptexbullet}
3472\def\geq{\ensuremath\ge}
3473\def\leq{\ensuremath\le}
3474\def\minus{\ensuremath-}
3475
3476% @dots{} outputs an ellipsis using the current font.
3477% We do .5em per period so that it has the same spacing in the cm
3478% typewriter fonts as three actual period characters; on the other hand,
3479% in other typewriter fonts three periods are wider than 1.5em.  So do
3480% whichever is larger.
3481%
3482\def\dots{%
3483  \leavevmode
3484  \setbox0=\hbox{...}% get width of three periods
3485  \ifdim\wd0 > 1.5em
3486    \dimen0 = \wd0
3487  \else
3488    \dimen0 = 1.5em
3489  \fi
3490  \hbox to \dimen0{%
3491    \hskip 0pt plus.25fil
3492    .\hskip 0pt plus1fil
3493    .\hskip 0pt plus1fil
3494    .\hskip 0pt plus.5fil
3495  }%
3496}
3497
3498% @enddots{} is an end-of-sentence ellipsis.
3499%
3500\def\enddots{%
3501  \dots
3502  \spacefactor=\endofsentencespacefactor
3503}
3504
3505% @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
3506%
3507% Since these characters are used in examples, they should be an even number of
3508% \tt widths. Each \tt character is 1en, so two makes it 1em.
3509%
3510\def\point{$\star$}
3511\def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}}
3512\def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
3513\def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}}
3514\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
3515\def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}}
3516
3517% The @error{} command.
3518% Adapted from the TeXbook's \boxit.
3519%
3520\newbox\errorbox
3521%
3522{\ttfont \global\dimen0 = 3em}% Width of the box.
3523\dimen2 = .55pt % Thickness of rules
3524% The text. (`r' is open on the right, `e' somewhat less so on the left.)
3525\setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt}
3526%
3527\setbox\errorbox=\hbox to \dimen0{\hfil
3528   \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
3529   \advance\hsize by -2\dimen2 % Rules.
3530   \vbox{%
3531      \hrule height\dimen2
3532      \hbox{\vrule width\dimen2 \kern3pt          % Space to left of text.
3533         \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
3534         \kern3pt\vrule width\dimen2}% Space to right.
3535      \hrule height\dimen2}
3536    \hfil}
3537%
3538\def\error{\leavevmode\lower.7ex\copy\errorbox}
3539
3540% @pounds{} is a sterling sign, which Knuth put in the CM italic font.
3541%
3542\def\pounds{{\it\$}}
3543
3544% @euro{} comes from a separate font, depending on the current style.
3545% We use the free feym* fonts from the eurosym package by Henrik
3546% Theiling, which support regular, slanted, bold and bold slanted (and
3547% "outlined" (blackboard board, sort of) versions, which we don't need).
3548% It is available from http://www.ctan.org/tex-archive/fonts/eurosym.
3549%
3550% Although only regular is the truly official Euro symbol, we ignore
3551% that.  The Euro is designed to be slightly taller than the regular
3552% font height.
3553%
3554% feymr - regular
3555% feymo - slanted
3556% feybr - bold
3557% feybo - bold slanted
3558%
3559% There is no good (free) typewriter version, to my knowledge.
3560% A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide.
3561% Hmm.
3562%
3563% Also doesn't work in math.  Do we need to do math with euro symbols?
3564% Hope not.
3565%
3566%
3567\def\euro{{\eurofont e}}
3568\def\eurofont{%
3569  % We set the font at each command, rather than predefining it in
3570  % \textfonts and the other font-switching commands, so that
3571  % installations which never need the symbol don't have to have the
3572  % font installed.
3573  %
3574  % There is only one designed size (nominal 10pt), so we always scale
3575  % that to the current nominal size.
3576  %
3577  % By the way, simply using "at 1em" works for cmr10 and the like, but
3578  % does not work for cmbx10 and other extended/shrunken fonts.
3579  %
3580  \def\eurosize{\csname\curfontsize nominalsize\endcsname}%
3581  %
3582  \ifx\curfontstyle\bfstylename
3583    % bold:
3584    \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize
3585  \else
3586    % regular:
3587    \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize
3588  \fi
3589  \thiseurofont
3590}
3591
3592% Glyphs from the EC fonts.  We don't use \let for the aliases, because
3593% sometimes we redefine the original macro, and the alias should reflect
3594% the redefinition.
3595%
3596% Use LaTeX names for the Icelandic letters.
3597\def\DH{{\ecfont \char"D0}} % Eth
3598\def\dh{{\ecfont \char"F0}} % eth
3599\def\TH{{\ecfont \char"DE}} % Thorn
3600\def\th{{\ecfont \char"FE}} % thorn
3601%
3602\def\guillemetleft{{\ecfont \char"13}}
3603\def\guillemotleft{\guillemetleft}
3604\def\guillemetright{{\ecfont \char"14}}
3605\def\guillemotright{\guillemetright}
3606\def\guilsinglleft{{\ecfont \char"0E}}
3607\def\guilsinglright{{\ecfont \char"0F}}
3608\def\quotedblbase{{\ecfont \char"12}}
3609\def\quotesinglbase{{\ecfont \char"0D}}
3610%
3611% This positioning is not perfect (see the ogonek LaTeX package), but
3612% we have the precomposed glyphs for the most common cases.  We put the
3613% tests to use those glyphs in the single \ogonek macro so we have fewer
3614% dummy definitions to worry about for index entries, etc.
3615%
3616% ogonek is also used with other letters in Lithuanian (IOU), but using
3617% the precomposed glyphs for those is not so easy since they aren't in
3618% the same EC font.
3619\def\ogonek#1{{%
3620  \def\temp{#1}%
3621  \ifx\temp\macrocharA\Aogonek
3622  \else\ifx\temp\macrochara\aogonek
3623  \else\ifx\temp\macrocharE\Eogonek
3624  \else\ifx\temp\macrochare\eogonek
3625  \else
3626    \ecfont \setbox0=\hbox{#1}%
3627    \ifdim\ht0=1ex\accent"0C #1%
3628    \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}%
3629    \fi
3630  \fi\fi\fi\fi
3631  }%
3632}
3633\def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A}
3634\def\aogonek{{\ecfont \char"A1}}\def\macrochara{a}
3635\def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E}
3636\def\eogonek{{\ecfont \char"A6}}\def\macrochare{e}
3637%
3638% Use the European Computer Modern fonts (cm-super in outline format)
3639% for non-CM glyphs.  That is ec* for regular text and tc* for the text
3640% companion symbols (LaTeX TS1 encoding).  Both are part of the ec
3641% package and follow the same conventions.
3642%
3643\def\ecfont{\etcfont{e}}
3644\def\tcfont{\etcfont{t}}
3645%
3646\def\etcfont#1{%
3647  % We can't distinguish serif/sans and italic/slanted, but this
3648  % is used for crude hacks anyway (like adding French and German
3649  % quotes to documents typeset with CM, where we lose kerning), so
3650  % hopefully nobody will notice/care.
3651  \edef\ecsize{\csname\curfontsize ecsize\endcsname}%
3652  \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}%
3653  \ifmonospace
3654    % typewriter:
3655    \font\thisecfont = #1ctt\ecsize \space at \nominalsize
3656  \else
3657    \ifx\curfontstyle\bfstylename
3658      % bold:
3659      \font\thisecfont = #1cb\ifusingit{i}{x}\ecsize \space at \nominalsize
3660    \else
3661      % regular:
3662      \font\thisecfont = #1c\ifusingit{ti}{rm}\ecsize \space at \nominalsize
3663    \fi
3664  \fi
3665  \thisecfont
3666}
3667
3668% @registeredsymbol - R in a circle.  The font for the R should really
3669% be smaller yet, but lllsize is the best we can do for now.
3670% Adapted from the plain.tex definition of \copyright.
3671%
3672\def\registeredsymbol{%
3673  $^{{\ooalign{\hfil\raise.07ex\hbox{\switchtolllsize R}%
3674               \hfil\crcr\Orb}}%
3675    }$%
3676}
3677
3678% @textdegree - the normal degrees sign.
3679%
3680\def\textdegree{$^\circ$}
3681
3682% Laurent Siebenmann reports \Orb undefined with:
3683%  Textures 1.7.7 (preloaded format=plain 93.10.14)  (68K)  16 APR 2004 02:38
3684% so we'll define it if necessary.
3685%
3686\ifx\Orb\thisisundefined
3687\def\Orb{\mathhexbox20D}
3688\fi
3689
3690% Quotes.
3691\chardef\quotedblleft="5C
3692\chardef\quotedblright=`\"
3693\chardef\quoteleft=`\`
3694\chardef\quoteright=`\'
3695
3696
3697\message{page headings,}
3698
3699\newskip\titlepagetopglue \titlepagetopglue = 1.5in
3700\newskip\titlepagebottomglue \titlepagebottomglue = 2pc
3701
3702% First the title page.  Must do @settitle before @titlepage.
3703\newif\ifseenauthor
3704\newif\iffinishedtitlepage
3705
3706% @setcontentsaftertitlepage used to do an implicit @contents or
3707% @shortcontents after @end titlepage, but it is now obsolete.
3708\def\setcontentsaftertitlepage{%
3709  \errmessage{@setcontentsaftertitlepage has been removed as a Texinfo
3710              command; move your @contents command if you want the contents
3711              after the title page.}}%
3712\def\setshortcontentsaftertitlepage{%
3713  \errmessage{@setshortcontentsaftertitlepage has been removed as a Texinfo
3714              command; move your @shortcontents and @contents commands if you
3715              want the contents after the title page.}}%
3716
3717\parseargdef\shorttitlepage{%
3718  \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}%
3719  \endgroup\page\hbox{}\page}
3720
3721\envdef\titlepage{%
3722  % Open one extra group, as we want to close it in the middle of \Etitlepage.
3723  \begingroup
3724    \parindent=0pt \textfonts
3725    % Leave some space at the very top of the page.
3726    \vglue\titlepagetopglue
3727    % No rule at page bottom unless we print one at the top with @title.
3728    \finishedtitlepagetrue
3729    %
3730    % Most title ``pages'' are actually two pages long, with space
3731    % at the top of the second.  We don't want the ragged left on the second.
3732    \let\oldpage = \page
3733    \def\page{%
3734      \iffinishedtitlepage\else
3735	 \finishtitlepage
3736      \fi
3737      \let\page = \oldpage
3738      \page
3739      \null
3740    }%
3741}
3742
3743\def\Etitlepage{%
3744    \iffinishedtitlepage\else
3745	\finishtitlepage
3746    \fi
3747    % It is important to do the page break before ending the group,
3748    % because the headline and footline are only empty inside the group.
3749    % If we use the new definition of \page, we always get a blank page
3750    % after the title page, which we certainly don't want.
3751    \oldpage
3752  \endgroup
3753  %
3754  % Need this before the \...aftertitlepage checks so that if they are
3755  % in effect the toc pages will come out with page numbers.
3756  \HEADINGSon
3757}
3758
3759\def\finishtitlepage{%
3760  \vskip4pt \hrule height 2pt width \hsize
3761  \vskip\titlepagebottomglue
3762  \finishedtitlepagetrue
3763}
3764
3765% Settings used for typesetting titles: no hyphenation, no indentation,
3766% don't worry much about spacing, ragged right.  This should be used
3767% inside a \vbox, and fonts need to be set appropriately first. \par should
3768% be specified before the end of the \vbox, since a vbox is a group.
3769%
3770\def\raggedtitlesettings{%
3771  \rm
3772  \hyphenpenalty=10000
3773  \parindent=0pt
3774  \tolerance=5000
3775  \ptexraggedright
3776}
3777
3778% Macros to be used within @titlepage:
3779
3780\let\subtitlerm=\rmfont
3781\def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}
3782
3783\parseargdef\title{%
3784  \checkenv\titlepage
3785  \vbox{\titlefonts \raggedtitlesettings #1\par}%
3786  % print a rule at the page bottom also.
3787  \finishedtitlepagefalse
3788  \vskip4pt \hrule height 4pt width \hsize \vskip4pt
3789}
3790
3791\parseargdef\subtitle{%
3792  \checkenv\titlepage
3793  {\subtitlefont \rightline{#1}}%
3794}
3795
3796% @author should come last, but may come many times.
3797% It can also be used inside @quotation.
3798%
3799\parseargdef\author{%
3800  \def\temp{\quotation}%
3801  \ifx\thisenv\temp
3802    \def\quotationauthor{#1}% printed in \Equotation.
3803  \else
3804    \checkenv\titlepage
3805    \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi
3806    {\secfonts\rm \leftline{#1}}%
3807  \fi
3808}
3809
3810
3811% Set up page headings and footings.
3812
3813\let\thispage=\folio
3814
3815\newtoks\evenheadline    % headline on even pages
3816\newtoks\oddheadline     % headline on odd pages
3817\newtoks\evenfootline    % footline on even pages
3818\newtoks\oddfootline     % footline on odd pages
3819
3820% Now make \makeheadline and \makefootline in Plain TeX use those variables
3821\headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
3822                            \else \the\evenheadline \fi}}
3823\footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
3824                            \else \the\evenfootline \fi}\HEADINGShook}
3825\let\HEADINGShook=\relax
3826
3827% Commands to set those variables.
3828% For example, this is what  @headings on  does
3829% @evenheading @thistitle|@thispage|@thischapter
3830% @oddheading @thischapter|@thispage|@thistitle
3831% @evenfooting @thisfile||
3832% @oddfooting ||@thisfile
3833
3834
3835\def\evenheading{\parsearg\evenheadingxxx}
3836\def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish}
3837\def\evenheadingyyy #1\|#2\|#3\|#4\finish{%
3838\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3839
3840\def\oddheading{\parsearg\oddheadingxxx}
3841\def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish}
3842\def\oddheadingyyy #1\|#2\|#3\|#4\finish{%
3843\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3844
3845\parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
3846
3847\def\evenfooting{\parsearg\evenfootingxxx}
3848\def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish}
3849\def\evenfootingyyy #1\|#2\|#3\|#4\finish{%
3850\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3851
3852\def\oddfooting{\parsearg\oddfootingxxx}
3853\def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish}
3854\def\oddfootingyyy #1\|#2\|#3\|#4\finish{%
3855  \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}%
3856  %
3857  % Leave some space for the footline.  Hopefully ok to assume
3858  % @evenfooting will not be used by itself.
3859  \global\advance\txipageheight by -12pt
3860  \global\advance\vsize by -12pt
3861}
3862
3863\parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}}
3864
3865% @evenheadingmarks top     \thischapter <- chapter at the top of a page
3866% @evenheadingmarks bottom  \thischapter <- chapter at the bottom of a page
3867%
3868% The same set of arguments for:
3869%
3870% @oddheadingmarks
3871% @evenfootingmarks
3872% @oddfootingmarks
3873% @everyheadingmarks
3874% @everyfootingmarks
3875
3876% These define \getoddheadingmarks, \getevenheadingmarks,
3877% \getoddfootingmarks, and \getevenfootingmarks, each to one of
3878% \gettopheadingmarks, \getbottomheadingmarks.
3879%
3880\def\evenheadingmarks{\headingmarks{even}{heading}}
3881\def\oddheadingmarks{\headingmarks{odd}{heading}}
3882\def\evenfootingmarks{\headingmarks{even}{footing}}
3883\def\oddfootingmarks{\headingmarks{odd}{footing}}
3884\parseargdef\everyheadingmarks{\headingmarks{even}{heading}{#1}
3885                          \headingmarks{odd}{heading}{#1} }
3886\parseargdef\everyfootingmarks{\headingmarks{even}{footing}{#1}
3887                          \headingmarks{odd}{footing}{#1} }
3888% #1 = even/odd, #2 = heading/footing, #3 = top/bottom.
3889\def\headingmarks#1#2#3 {%
3890  \expandafter\let\expandafter\temp \csname get#3headingmarks\endcsname
3891  \global\expandafter\let\csname get#1#2marks\endcsname \temp
3892}
3893
3894\everyheadingmarks bottom
3895\everyfootingmarks bottom
3896
3897% @headings double      turns headings on for double-sided printing.
3898% @headings single      turns headings on for single-sided printing.
3899% @headings off         turns them off.
3900% @headings on          same as @headings double, retained for compatibility.
3901% @headings after       turns on double-sided headings after this page.
3902% @headings doubleafter turns on double-sided headings after this page.
3903% @headings singleafter turns on single-sided headings after this page.
3904% By default, they are off at the start of a document,
3905% and turned `on' after @end titlepage.
3906
3907\parseargdef\headings{\csname HEADINGS#1\endcsname}
3908
3909\def\headingsoff{% non-global headings elimination
3910  \evenheadline={\hfil}\evenfootline={\hfil}%
3911   \oddheadline={\hfil}\oddfootline={\hfil}%
3912}
3913
3914\def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting
3915\HEADINGSoff  % it's the default
3916
3917% When we turn headings on, set the page number to 1.
3918% For double-sided printing, put current file name in lower left corner,
3919% chapter name on inside top of right hand pages, document
3920% title on inside top of left hand pages, and page numbers on outside top
3921% edge of all pages.
3922\def\HEADINGSdouble{%
3923\global\pageno=1
3924\global\evenfootline={\hfil}
3925\global\oddfootline={\hfil}
3926\global\evenheadline={\line{\folio\hfil\thistitle}}
3927\global\oddheadline={\line{\thischapterheading\hfil\folio}}
3928\global\let\contentsalignmacro = \chapoddpage
3929}
3930\let\contentsalignmacro = \chappager
3931
3932% For single-sided printing, chapter title goes across top left of page,
3933% page number on top right.
3934\def\HEADINGSsingle{%
3935\global\pageno=1
3936\global\evenfootline={\hfil}
3937\global\oddfootline={\hfil}
3938\global\evenheadline={\line{\thischapterheading\hfil\folio}}
3939\global\oddheadline={\line{\thischapterheading\hfil\folio}}
3940\global\let\contentsalignmacro = \chappager
3941}
3942\def\HEADINGSon{\HEADINGSdouble}
3943
3944\def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
3945\let\HEADINGSdoubleafter=\HEADINGSafter
3946\def\HEADINGSdoublex{%
3947\global\evenfootline={\hfil}
3948\global\oddfootline={\hfil}
3949\global\evenheadline={\line{\folio\hfil\thistitle}}
3950\global\oddheadline={\line{\thischapterheading\hfil\folio}}
3951\global\let\contentsalignmacro = \chapoddpage
3952}
3953
3954\def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
3955\def\HEADINGSsinglex{%
3956\global\evenfootline={\hfil}
3957\global\oddfootline={\hfil}
3958\global\evenheadline={\line{\thischapterheading\hfil\folio}}
3959\global\oddheadline={\line{\thischapterheading\hfil\folio}}
3960\global\let\contentsalignmacro = \chappager
3961}
3962
3963% Subroutines used in generating headings
3964% This produces Day Month Year style of output.
3965% Only define if not already defined, in case a txi-??.tex file has set
3966% up a different format (e.g., txi-cs.tex does this).
3967\ifx\today\thisisundefined
3968\def\today{%
3969  \number\day\space
3970  \ifcase\month
3971  \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr
3972  \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug
3973  \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec
3974  \fi
3975  \space\number\year}
3976\fi
3977
3978% @settitle line...  specifies the title of the document, for headings.
3979% It generates no output of its own.
3980\def\thistitle{\putwordNoTitle}
3981\def\settitle{\parsearg{\gdef\thistitle}}
3982
3983
3984\message{tables,}
3985% Tables -- @table, @ftable, @vtable, @item(x).
3986
3987% default indentation of table text
3988\newdimen\tableindent \tableindent=.8in
3989% default indentation of @itemize and @enumerate text
3990\newdimen\itemindent  \itemindent=.3in
3991% margin between end of table item and start of table text.
3992\newdimen\itemmargin  \itemmargin=.1in
3993
3994% used internally for \itemindent minus \itemmargin
3995\newdimen\itemmax
3996
3997% Note @table, @ftable, and @vtable define @item, @itemx, etc., with
3998% these defs.
3999% They also define \itemindex
4000% to index the item name in whatever manner is desired (perhaps none).
4001
4002\newif\ifitemxneedsnegativevskip
4003
4004\def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
4005
4006\def\internalBitem{\smallbreak \parsearg\itemzzz}
4007\def\internalBitemx{\itemxpar \parsearg\itemzzz}
4008
4009\def\itemzzz #1{\begingroup %
4010  \advance\hsize by -\rightskip
4011  \advance\hsize by -\tableindent
4012  \setbox0=\hbox{\itemindicate{#1}}%
4013  \itemindex{#1}%
4014  \nobreak % This prevents a break before @itemx.
4015  %
4016  % If the item text does not fit in the space we have, put it on a line
4017  % by itself, and do not allow a page break either before or after that
4018  % line.  We do not start a paragraph here because then if the next
4019  % command is, e.g., @kindex, the whatsit would get put into the
4020  % horizontal list on a line by itself, resulting in extra blank space.
4021  \ifdim \wd0>\itemmax
4022    %
4023    % Make this a paragraph so we get the \parskip glue and wrapping,
4024    % but leave it ragged-right.
4025    \begingroup
4026      \advance\leftskip by-\tableindent
4027      \advance\hsize by\tableindent
4028      \advance\rightskip by0pt plus1fil\relax
4029      \leavevmode\unhbox0\par
4030    \endgroup
4031    %
4032    % We're going to be starting a paragraph, but we don't want the
4033    % \parskip glue -- logically it's part of the @item we just started.
4034    \nobreak \vskip-\parskip
4035    %
4036    % Stop a page break at the \parskip glue coming up.  However, if
4037    % what follows is an environment such as @example, there will be no
4038    % \parskip glue; then the negative vskip we just inserted would
4039    % cause the example and the item to crash together.  So we use this
4040    % bizarre value of 10001 as a signal to \aboveenvbreak to insert
4041    % \parskip glue after all.  Section titles are handled this way also.
4042    %
4043    \penalty 10001
4044    \endgroup
4045    \itemxneedsnegativevskipfalse
4046  \else
4047    % The item text fits into the space.  Start a paragraph, so that the
4048    % following text (if any) will end up on the same line.
4049    \noindent
4050    % Do this with kerns and \unhbox so that if there is a footnote in
4051    % the item text, it can migrate to the main vertical list and
4052    % eventually be printed.
4053    \nobreak\kern-\tableindent
4054    \dimen0 = \itemmax  \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0
4055    \unhbox0
4056    \nobreak\kern\dimen0
4057    \endgroup
4058    \itemxneedsnegativevskiptrue
4059  \fi
4060}
4061
4062\def\item{\errmessage{@item while not in a list environment}}
4063\def\itemx{\errmessage{@itemx while not in a list environment}}
4064
4065% @table, @ftable, @vtable.
4066\envdef\table{%
4067  \let\itemindex\gobble
4068  \tablecheck{table}%
4069}
4070\envdef\ftable{%
4071  \def\itemindex ##1{\doind {fn}{\code{##1}}}%
4072  \tablecheck{ftable}%
4073}
4074\envdef\vtable{%
4075  \def\itemindex ##1{\doind {vr}{\code{##1}}}%
4076  \tablecheck{vtable}%
4077}
4078\def\tablecheck#1{%
4079  \ifnum \the\catcode`\^^M=\active
4080    \endgroup
4081    \errmessage{This command won't work in this context; perhaps the problem is
4082      that we are \inenvironment\thisenv}%
4083    \def\next{\doignore{#1}}%
4084  \else
4085    \let\next\tablex
4086  \fi
4087  \next
4088}
4089\def\tablex#1{%
4090  \def\itemindicate{#1}%
4091  \parsearg\tabley
4092}
4093\def\tabley#1{%
4094  {%
4095    \makevalueexpandable
4096    \edef\temp{\noexpand\tablez #1\space\space\space}%
4097    \expandafter
4098  }\temp \endtablez
4099}
4100\def\tablez #1 #2 #3 #4\endtablez{%
4101  \aboveenvbreak
4102  \ifnum 0#1>0 \advance \leftskip by #1\mil \fi
4103  \ifnum 0#2>0 \tableindent=#2\mil \fi
4104  \ifnum 0#3>0 \advance \rightskip by #3\mil \fi
4105  \itemmax=\tableindent
4106  \advance \itemmax by -\itemmargin
4107  \advance \leftskip by \tableindent
4108  \exdentamount=\tableindent
4109  \parindent = 0pt
4110  \parskip = \smallskipamount
4111  \ifdim \parskip=0pt \parskip=2pt \fi
4112  \let\item = \internalBitem
4113  \let\itemx = \internalBitemx
4114}
4115\def\Etable{\endgraf\afterenvbreak}
4116\let\Eftable\Etable
4117\let\Evtable\Etable
4118\let\Eitemize\Etable
4119\let\Eenumerate\Etable
4120
4121% This is the counter used by @enumerate, which is really @itemize
4122
4123\newcount \itemno
4124
4125\envdef\itemize{\parsearg\doitemize}
4126
4127\def\doitemize#1{%
4128  \aboveenvbreak
4129  \itemmax=\itemindent
4130  \advance\itemmax by -\itemmargin
4131  \advance\leftskip by \itemindent
4132  \exdentamount=\itemindent
4133  \parindent=0pt
4134  \parskip=\smallskipamount
4135  \ifdim\parskip=0pt \parskip=2pt \fi
4136  %
4137  % Try typesetting the item mark so that if the document erroneously says
4138  % something like @itemize @samp (intending @table), there's an error
4139  % right away at the @itemize.  It's not the best error message in the
4140  % world, but it's better than leaving it to the @item.  This means if
4141  % the user wants an empty mark, they have to say @w{} not just @w.
4142  \def\itemcontents{#1}%
4143  \setbox0 = \hbox{\itemcontents}%
4144  %
4145  % @itemize with no arg is equivalent to @itemize @bullet.
4146  \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi
4147  %
4148  \let\item=\itemizeitem
4149}
4150
4151% Definition of @item while inside @itemize and @enumerate.
4152%
4153\def\itemizeitem{%
4154  \advance\itemno by 1  % for enumerations
4155  {\let\par=\endgraf \smallbreak}% reasonable place to break
4156  {%
4157   % If the document has an @itemize directly after a section title, a
4158   % \nobreak will be last on the list, and \sectionheading will have
4159   % done a \vskip-\parskip.  In that case, we don't want to zero
4160   % parskip, or the item text will crash with the heading.  On the
4161   % other hand, when there is normal text preceding the item (as there
4162   % usually is), we do want to zero parskip, or there would be too much
4163   % space.  In that case, we won't have a \nobreak before.  At least
4164   % that's the theory.
4165   \ifnum\lastpenalty<10000 \parskip=0in \fi
4166   \noindent
4167   \hbox to 0pt{\hss \itemcontents \kern\itemmargin}%
4168   %
4169   \ifinner\else
4170     \vadjust{\penalty 1200}% not good to break after first line of item.
4171   \fi
4172   % We can be in inner vertical mode in a footnote, although an
4173   % @itemize looks awful there.
4174  }%
4175  \flushcr
4176}
4177
4178% \splitoff TOKENS\endmark defines \first to be the first token in
4179% TOKENS, and \rest to be the remainder.
4180%
4181\def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
4182
4183% Allow an optional argument of an uppercase letter, lowercase letter,
4184% or number, to specify the first label in the enumerated list.  No
4185% argument is the same as `1'.
4186%
4187\envparseargdef\enumerate{\enumeratey #1  \endenumeratey}
4188\def\enumeratey #1 #2\endenumeratey{%
4189  % If we were given no argument, pretend we were given `1'.
4190  \def\thearg{#1}%
4191  \ifx\thearg\empty \def\thearg{1}\fi
4192  %
4193  % Detect if the argument is a single token.  If so, it might be a
4194  % letter.  Otherwise, the only valid thing it can be is a number.
4195  % (We will always have one token, because of the test we just made.
4196  % This is a good thing, since \splitoff doesn't work given nothing at
4197  % all -- the first parameter is undelimited.)
4198  \expandafter\splitoff\thearg\endmark
4199  \ifx\rest\empty
4200    % Only one token in the argument.  It could still be anything.
4201    % A ``lowercase letter'' is one whose \lccode is nonzero.
4202    % An ``uppercase letter'' is one whose \lccode is both nonzero, and
4203    %   not equal to itself.
4204    % Otherwise, we assume it's a number.
4205    %
4206    % We need the \relax at the end of the \ifnum lines to stop TeX from
4207    % continuing to look for a <number>.
4208    %
4209    \ifnum\lccode\expandafter`\thearg=0\relax
4210      \numericenumerate % a number (we hope)
4211    \else
4212      % It's a letter.
4213      \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
4214        \lowercaseenumerate % lowercase letter
4215      \else
4216        \uppercaseenumerate % uppercase letter
4217      \fi
4218    \fi
4219  \else
4220    % Multiple tokens in the argument.  We hope it's a number.
4221    \numericenumerate
4222  \fi
4223}
4224
4225% An @enumerate whose labels are integers.  The starting integer is
4226% given in \thearg.
4227%
4228\def\numericenumerate{%
4229  \itemno = \thearg
4230  \startenumeration{\the\itemno}%
4231}
4232
4233% The starting (lowercase) letter is in \thearg.
4234\def\lowercaseenumerate{%
4235  \itemno = \expandafter`\thearg
4236  \startenumeration{%
4237    % Be sure we're not beyond the end of the alphabet.
4238    \ifnum\itemno=0
4239      \errmessage{No more lowercase letters in @enumerate; get a bigger
4240                  alphabet}%
4241    \fi
4242    \char\lccode\itemno
4243  }%
4244}
4245
4246% The starting (uppercase) letter is in \thearg.
4247\def\uppercaseenumerate{%
4248  \itemno = \expandafter`\thearg
4249  \startenumeration{%
4250    % Be sure we're not beyond the end of the alphabet.
4251    \ifnum\itemno=0
4252      \errmessage{No more uppercase letters in @enumerate; get a bigger
4253                  alphabet}
4254    \fi
4255    \char\uccode\itemno
4256  }%
4257}
4258
4259% Call \doitemize, adding a period to the first argument and supplying the
4260% common last two arguments.  Also subtract one from the initial value in
4261% \itemno, since @item increments \itemno.
4262%
4263\def\startenumeration#1{%
4264  \advance\itemno by -1
4265  \doitemize{#1.}\flushcr
4266}
4267
4268% @alphaenumerate and @capsenumerate are abbreviations for giving an arg
4269% to @enumerate.
4270%
4271\def\alphaenumerate{\enumerate{a}}
4272\def\capsenumerate{\enumerate{A}}
4273\def\Ealphaenumerate{\Eenumerate}
4274\def\Ecapsenumerate{\Eenumerate}
4275
4276
4277% @multitable macros
4278% Amy Hendrickson, 8/18/94, 3/6/96
4279%
4280% @multitable ... @end multitable will make as many columns as desired.
4281% Contents of each column will wrap at width given in preamble.  Width
4282% can be specified either with sample text given in a template line,
4283% or in percent of \hsize, the current width of text on page.
4284
4285% Table can continue over pages but will only break between lines.
4286
4287% To make preamble:
4288%
4289% Either define widths of columns in terms of percent of \hsize:
4290%   @multitable @columnfractions .25 .3 .45
4291%   @item ...
4292%
4293%   Numbers following @columnfractions are the percent of the total
4294%   current hsize to be used for each column. You may use as many
4295%   columns as desired.
4296
4297
4298% Or use a template:
4299%   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
4300%   @item ...
4301%   using the widest term desired in each column.
4302
4303% Each new table line starts with @item, each subsequent new column
4304% starts with @tab. Empty columns may be produced by supplying @tab's
4305% with nothing between them for as many times as empty columns are needed,
4306% ie, @tab@tab@tab will produce two empty columns.
4307
4308% @item, @tab do not need to be on their own lines, but it will not hurt
4309% if they are.
4310
4311% Sample multitable:
4312
4313%   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
4314%   @item first col stuff @tab second col stuff @tab third col
4315%   @item
4316%   first col stuff
4317%   @tab
4318%   second col stuff
4319%   @tab
4320%   third col
4321%   @item first col stuff @tab second col stuff
4322%   @tab Many paragraphs of text may be used in any column.
4323%
4324%         They will wrap at the width determined by the template.
4325%   @item@tab@tab This will be in third column.
4326%   @end multitable
4327
4328% Default dimensions may be reset by user.
4329% @multitableparskip is vertical space between paragraphs in table.
4330% @multitableparindent is paragraph indent in table.
4331% @multitablecolmargin is horizontal space to be left between columns.
4332% @multitablelinespace is space to leave between table items, baseline
4333%                                                            to baseline.
4334%   0pt means it depends on current normal line spacing.
4335%
4336\newskip\multitableparskip
4337\newskip\multitableparindent
4338\newdimen\multitablecolspace
4339\newskip\multitablelinespace
4340\multitableparskip=0pt
4341\multitableparindent=6pt
4342\multitablecolspace=12pt
4343\multitablelinespace=0pt
4344
4345% Macros used to set up halign preamble:
4346%
4347\let\endsetuptable\relax
4348\def\xendsetuptable{\endsetuptable}
4349\let\columnfractions\relax
4350\def\xcolumnfractions{\columnfractions}
4351\newif\ifsetpercent
4352
4353% #1 is the @columnfraction, usually a decimal number like .5, but might
4354% be just 1.  We just use it, whatever it is.
4355%
4356\def\pickupwholefraction#1 {%
4357  \global\advance\colcount by 1
4358  \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}%
4359  \setuptable
4360}
4361
4362\newcount\colcount
4363\def\setuptable#1{%
4364  \def\firstarg{#1}%
4365  \ifx\firstarg\xendsetuptable
4366    \let\go = \relax
4367  \else
4368    \ifx\firstarg\xcolumnfractions
4369      \global\setpercenttrue
4370    \else
4371      \ifsetpercent
4372         \let\go\pickupwholefraction
4373      \else
4374         \global\advance\colcount by 1
4375         \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a
4376                   % separator; typically that is always in the input, anyway.
4377         \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
4378      \fi
4379    \fi
4380    \ifx\go\pickupwholefraction
4381      % Put the argument back for the \pickupwholefraction call, so
4382      % we'll always have a period there to be parsed.
4383      \def\go{\pickupwholefraction#1}%
4384    \else
4385      \let\go = \setuptable
4386    \fi%
4387  \fi
4388  \go
4389}
4390
4391% multitable-only commands.
4392%
4393% @headitem starts a heading row, which we typeset in bold.  Assignments
4394% have to be global since we are inside the implicit group of an
4395% alignment entry.  \everycr below resets \everytab so we don't have to
4396% undo it ourselves.
4397\def\headitemfont{\b}% for people to use in the template row; not changeable
4398\def\headitem{%
4399  \checkenv\multitable
4400  \crcr
4401  \gdef\headitemcrhook{\nobreak}% attempt to avoid page break after headings
4402  \global\everytab={\bf}% can't use \headitemfont since the parsing differs
4403  \the\everytab % for the first item
4404}%
4405%
4406% default for tables with no headings.
4407\let\headitemcrhook=\relax
4408%
4409% A \tab used to include \hskip1sp.  But then the space in a template
4410% line is not enough.  That is bad.  So let's go back to just `&' until
4411% we again encounter the problem the 1sp was intended to solve.
4412%					--karl, nathan@acm.org, 20apr99.
4413\def\tab{\checkenv\multitable &\the\everytab}%
4414
4415% @multitable ... @end multitable definitions:
4416%
4417\newtoks\everytab  % insert after every tab.
4418%
4419\envdef\multitable{%
4420  \vskip\parskip
4421  \startsavinginserts
4422  %
4423  % @item within a multitable starts a normal row.
4424  % We use \def instead of \let so that if one of the multitable entries
4425  % contains an @itemize, we don't choke on the \item (seen as \crcr aka
4426  % \endtemplate) expanding \doitemize.
4427  \def\item{\crcr}%
4428  %
4429  \tolerance=9500
4430  \hbadness=9500
4431  \setmultitablespacing
4432  \parskip=\multitableparskip
4433  \parindent=\multitableparindent
4434  \overfullrule=0pt
4435  \global\colcount=0
4436  %
4437  \everycr = {%
4438    \noalign{%
4439      \global\everytab={}% Reset from possible headitem.
4440      \global\colcount=0 % Reset the column counter.
4441      %
4442      % Check for saved footnotes, etc.:
4443      \checkinserts
4444      %
4445      % Perhaps a \nobreak, then reset:
4446      \headitemcrhook
4447      \global\let\headitemcrhook=\relax
4448    }%
4449  }%
4450  %
4451  \parsearg\domultitable
4452}
4453\def\domultitable#1{%
4454  % To parse everything between @multitable and @item:
4455  \setuptable#1 \endsetuptable
4456  %
4457  % This preamble sets up a generic column definition, which will
4458  % be used as many times as user calls for columns.
4459  % \vtop will set a single line and will also let text wrap and
4460  % continue for many paragraphs if desired.
4461  \halign\bgroup &%
4462    \global\advance\colcount by 1
4463    \multistrut
4464    \vtop{%
4465      % Use the current \colcount to find the correct column width:
4466      \hsize=\expandafter\csname col\the\colcount\endcsname
4467      %
4468      % In order to keep entries from bumping into each other
4469      % we will add a \leftskip of \multitablecolspace to all columns after
4470      % the first one.
4471      %
4472      % If a template has been used, we will add \multitablecolspace
4473      % to the width of each template entry.
4474      %
4475      % If the user has set preamble in terms of percent of \hsize we will
4476      % use that dimension as the width of the column, and the \leftskip
4477      % will keep entries from bumping into each other.  Table will start at
4478      % left margin and final column will justify at right margin.
4479      %
4480      % Make sure we don't inherit \rightskip from the outer environment.
4481      \rightskip=0pt
4482      \ifnum\colcount=1
4483	% The first column will be indented with the surrounding text.
4484	\advance\hsize by\leftskip
4485      \else
4486	\ifsetpercent \else
4487	  % If user has not set preamble in terms of percent of \hsize
4488	  % we will advance \hsize by \multitablecolspace.
4489	  \advance\hsize by \multitablecolspace
4490	\fi
4491       % In either case we will make \leftskip=\multitablecolspace:
4492      \leftskip=\multitablecolspace
4493      \fi
4494      % Ignoring space at the beginning and end avoids an occasional spurious
4495      % blank line, when TeX decides to break the line at the space before the
4496      % box from the multistrut, so the strut ends up on a line by itself.
4497      % For example:
4498      % @multitable @columnfractions .11 .89
4499      % @item @code{#}
4500      % @tab Legal holiday which is valid in major parts of the whole country.
4501      % Is automatically provided with highlighting sequences respectively
4502      % marking characters.
4503      \noindent\ignorespaces##\unskip\multistrut
4504    }\cr
4505}
4506\def\Emultitable{%
4507  \crcr
4508  \egroup % end the \halign
4509  \global\setpercentfalse
4510}
4511
4512\def\setmultitablespacing{%
4513  \def\multistrut{\strut}% just use the standard line spacing
4514  %
4515  % Compute \multitablelinespace (if not defined by user) for use in
4516  % \multitableparskip calculation.  We used define \multistrut based on
4517  % this, but (ironically) that caused the spacing to be off.
4518  % See bug-texinfo report from Werner Lemberg, 31 Oct 2004 12:52:20 +0100.
4519\ifdim\multitablelinespace=0pt
4520\setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip
4521\global\advance\multitablelinespace by-\ht0
4522\fi
4523% Test to see if parskip is larger than space between lines of
4524% table. If not, do nothing.
4525%        If so, set to same dimension as multitablelinespace.
4526\ifdim\multitableparskip>\multitablelinespace
4527\global\multitableparskip=\multitablelinespace
4528\global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
4529                                      % than skip between lines in the table.
4530\fi%
4531\ifdim\multitableparskip=0pt
4532\global\multitableparskip=\multitablelinespace
4533\global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
4534                                      % than skip between lines in the table.
4535\fi}
4536
4537
4538\message{conditionals,}
4539
4540% @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext,
4541% @ifnotxml always succeed.  They currently do nothing; we don't
4542% attempt to check whether the conditionals are properly nested.  But we
4543% have to remember that they are conditionals, so that @end doesn't
4544% attempt to close an environment group.
4545%
4546\def\makecond#1{%
4547  \expandafter\let\csname #1\endcsname = \relax
4548  \expandafter\let\csname iscond.#1\endcsname = 1
4549}
4550\makecond{iftex}
4551\makecond{ifnotdocbook}
4552\makecond{ifnothtml}
4553\makecond{ifnotinfo}
4554\makecond{ifnotplaintext}
4555\makecond{ifnotxml}
4556
4557% Ignore @ignore, @ifhtml, @ifinfo, and the like.
4558%
4559\def\direntry{\doignore{direntry}}
4560\def\documentdescription{\doignore{documentdescription}}
4561\def\docbook{\doignore{docbook}}
4562\def\html{\doignore{html}}
4563\def\ifdocbook{\doignore{ifdocbook}}
4564\def\ifhtml{\doignore{ifhtml}}
4565\def\ifinfo{\doignore{ifinfo}}
4566\def\ifnottex{\doignore{ifnottex}}
4567\def\ifplaintext{\doignore{ifplaintext}}
4568\def\ifxml{\doignore{ifxml}}
4569\def\ignore{\doignore{ignore}}
4570\def\menu{\doignore{menu}}
4571\def\xml{\doignore{xml}}
4572
4573% Ignore text until a line `@end #1', keeping track of nested conditionals.
4574%
4575% A count to remember the depth of nesting.
4576\newcount\doignorecount
4577
4578\def\doignore#1{\begingroup
4579  % Scan in ``verbatim'' mode:
4580  \obeylines
4581  \catcode`\@ = \other
4582  \catcode`\{ = \other
4583  \catcode`\} = \other
4584  %
4585  % Make sure that spaces turn into tokens that match what \doignoretext wants.
4586  \spaceisspace
4587  %
4588  % Count number of #1's that we've seen.
4589  \doignorecount = 0
4590  %
4591  % Swallow text until we reach the matching `@end #1'.
4592  \dodoignore{#1}%
4593}
4594
4595{ \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source.
4596  \obeylines %
4597  %
4598  \gdef\dodoignore#1{%
4599    % #1 contains the command name as a string, e.g., `ifinfo'.
4600    %
4601    % Define a command to find the next `@end #1'.
4602    \long\def\doignoretext##1^^M@end #1{%
4603      \doignoretextyyy##1^^M@#1\_STOP_}%
4604    %
4605    % And this command to find another #1 command, at the beginning of a
4606    % line.  (Otherwise, we would consider a line `@c @ifset', for
4607    % example, to count as an @ifset for nesting.)
4608    \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}%
4609    %
4610    % And now expand that command.
4611    \doignoretext ^^M%
4612  }%
4613}
4614
4615\def\doignoreyyy#1{%
4616  \def\temp{#1}%
4617  \ifx\temp\empty			% Nothing found.
4618    \let\next\doignoretextzzz
4619  \else					% Found a nested condition, ...
4620    \advance\doignorecount by 1
4621    \let\next\doignoretextyyy		% ..., look for another.
4622    % If we're here, #1 ends with ^^M\ifinfo (for example).
4623  \fi
4624  \next #1% the token \_STOP_ is present just after this macro.
4625}
4626
4627% We have to swallow the remaining "\_STOP_".
4628%
4629\def\doignoretextzzz#1{%
4630  \ifnum\doignorecount = 0	% We have just found the outermost @end.
4631    \let\next\enddoignore
4632  \else				% Still inside a nested condition.
4633    \advance\doignorecount by -1
4634    \let\next\doignoretext      % Look for the next @end.
4635  \fi
4636  \next
4637}
4638
4639% Finish off ignored text.
4640{ \obeylines%
4641  % Ignore anything after the last `@end #1'; this matters in verbatim
4642  % environments, where otherwise the newline after an ignored conditional
4643  % would result in a blank line in the output.
4644  \gdef\enddoignore#1^^M{\endgroup\ignorespaces}%
4645}
4646
4647
4648% @set VAR sets the variable VAR to an empty value.
4649% @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
4650%
4651% Since we want to separate VAR from REST-OF-LINE (which might be
4652% empty), we can't just use \parsearg; we have to insert a space of our
4653% own to delimit the rest of the line, and then take it out again if we
4654% didn't need it.
4655% We rely on the fact that \parsearg sets \catcode`\ =10.
4656%
4657\parseargdef\set{\setyyy#1 \endsetyyy}
4658\def\setyyy#1 #2\endsetyyy{%
4659  {%
4660    \makevalueexpandable
4661    \def\temp{#2}%
4662    \edef\next{\gdef\makecsname{SET#1}}%
4663    \ifx\temp\empty
4664      \next{}%
4665    \else
4666      \setzzz#2\endsetzzz
4667    \fi
4668  }%
4669}
4670% Remove the trailing space \setxxx inserted.
4671\def\setzzz#1 \endsetzzz{\next{#1}}
4672
4673% @clear VAR clears (i.e., unsets) the variable VAR.
4674%
4675\parseargdef\clear{%
4676  {%
4677    \makevalueexpandable
4678    \global\expandafter\let\csname SET#1\endcsname=\relax
4679  }%
4680}
4681
4682% @value{foo} gets the text saved in variable foo.
4683\def\value{\begingroup\makevalueexpandable\valuexxx}
4684\def\valuexxx#1{\expandablevalue{#1}\endgroup}
4685{
4686  \catcode`\-=\active \catcode`\_=\active
4687  %
4688  \gdef\makevalueexpandable{%
4689    \let\value = \expandablevalue
4690    % We don't want these characters active, ...
4691    \catcode`\-=\other \catcode`\_=\other
4692    % ..., but we might end up with active ones in the argument if
4693    % we're called from @code, as @code{@value{foo-bar_}}, though.
4694    % So \let them to their normal equivalents.
4695    \let-\normaldash \let_\normalunderscore
4696  }
4697}
4698
4699% We have this subroutine so that we can handle at least some @value's
4700% properly in indexes (we call \makevalueexpandable in \indexdummies).
4701% The command has to be fully expandable (if the variable is set), since
4702% the result winds up in the index file.  This means that if the
4703% variable's value contains other Texinfo commands, it's almost certain
4704% it will fail (although perhaps we could fix that with sufficient work
4705% to do a one-level expansion on the result, instead of complete).
4706%
4707% Unfortunately, this has the consequence that when _ is in the *value*
4708% of an @set, it does not print properly in the roman fonts (get the cmr
4709% dot accent at position 126 instead).  No fix comes to mind, and it's
4710% been this way since 2003 or earlier, so just ignore it.
4711%
4712\def\expandablevalue#1{%
4713  \expandafter\ifx\csname SET#1\endcsname\relax
4714    {[No value for ``#1'']}%
4715    \message{Variable `#1', used in @value, is not set.}%
4716  \else
4717    \csname SET#1\endcsname
4718  \fi
4719}
4720
4721% Like \expandablevalue, but completely expandable (the \message in the
4722% definition above operates at the execution level of TeX).  Used when
4723% writing to auxiliary files, due to the expansion that \write does.
4724% If flag is undefined, pass through an unexpanded @value command: maybe it
4725% will be set by the time it is read back in.
4726%
4727% NB flag names containing - or _ may not work here.
4728\def\dummyvalue#1{%
4729  \expandafter\ifx\csname SET#1\endcsname\relax
4730    \noexpand\value{#1}%
4731  \else
4732    \csname SET#1\endcsname
4733  \fi
4734}
4735
4736% Used for @value's in index entries to form the sort key: expand the @value
4737% if possible, otherwise sort late.
4738\def\indexnofontsvalue#1{%
4739  \expandafter\ifx\csname SET#1\endcsname\relax
4740    ZZZZZZZ
4741  \else
4742    \csname SET#1\endcsname
4743  \fi
4744}
4745
4746% @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
4747% with @set.
4748%
4749% To get the special treatment we need for `@end ifset,' we call
4750% \makecond and then redefine.
4751%
4752\makecond{ifset}
4753\def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}}
4754\def\doifset#1#2{%
4755  {%
4756    \makevalueexpandable
4757    \let\next=\empty
4758    \expandafter\ifx\csname SET#2\endcsname\relax
4759      #1% If not set, redefine \next.
4760    \fi
4761    \expandafter
4762  }\next
4763}
4764\def\ifsetfail{\doignore{ifset}}
4765
4766% @ifclear VAR ... @end executes the `...' iff VAR has never been
4767% defined with @set, or has been undefined with @clear.
4768%
4769% The `\else' inside the `\doifset' parameter is a trick to reuse the
4770% above code: if the variable is not set, do nothing, if it is set,
4771% then redefine \next to \ifclearfail.
4772%
4773\makecond{ifclear}
4774\def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}}
4775\def\ifclearfail{\doignore{ifclear}}
4776
4777% @ifcommandisdefined CMD ... @end executes the `...' if CMD (written
4778% without the @) is in fact defined.  We can only feasibly check at the
4779% TeX level, so something like `mathcode' is going to considered
4780% defined even though it is not a Texinfo command.
4781%
4782\makecond{ifcommanddefined}
4783\def\ifcommanddefined{\parsearg{\doifcmddefined{\let\next=\ifcmddefinedfail}}}
4784%
4785\def\doifcmddefined#1#2{{%
4786    \makevalueexpandable
4787    \let\next=\empty
4788    \expandafter\ifx\csname #2\endcsname\relax
4789      #1% If not defined, \let\next as above.
4790    \fi
4791    \expandafter
4792  }\next
4793}
4794\def\ifcmddefinedfail{\doignore{ifcommanddefined}}
4795
4796% @ifcommandnotdefined CMD ... handled similar to @ifclear above.
4797\makecond{ifcommandnotdefined}
4798\def\ifcommandnotdefined{%
4799  \parsearg{\doifcmddefined{\else \let\next=\ifcmdnotdefinedfail}}}
4800\def\ifcmdnotdefinedfail{\doignore{ifcommandnotdefined}}
4801
4802% Set the `txicommandconditionals' variable, so documents have a way to
4803% test if the @ifcommand...defined conditionals are available.
4804\set txicommandconditionals
4805
4806% @dircategory CATEGORY  -- specify a category of the dir file
4807% which this file should belong to.  Ignore this in TeX.
4808\let\dircategory=\comment
4809
4810% @defininfoenclose.
4811\let\definfoenclose=\comment
4812
4813
4814\message{indexing,}
4815% Index generation facilities
4816
4817% Define \newwrite to be identical to plain tex's \newwrite
4818% except not \outer, so it can be used within macros and \if's.
4819\edef\newwrite{\makecsname{ptexnewwrite}}
4820
4821% \newindex {foo} defines an index named IX.
4822% It automatically defines \IXindex such that
4823% \IXindex ...rest of line... puts an entry in the index IX.
4824% It also defines \IXindfile to be the number of the output channel for
4825% the file that accumulates this index.  The file's extension is IX.
4826% The name of an index should be no more than 2 characters long
4827% for the sake of vms.
4828%
4829\def\newindex#1{%
4830  \expandafter\chardef\csname#1indfile\endcsname=0
4831  \expandafter\xdef\csname#1index\endcsname{%     % Define @#1index
4832    \noexpand\doindex{#1}}
4833}
4834
4835% @defindex foo  ==  \newindex{foo}
4836%
4837\def\defindex{\parsearg\newindex}
4838
4839% Define @defcodeindex, like @defindex except put all entries in @code.
4840%
4841\def\defcodeindex{\parsearg\newcodeindex}
4842%
4843\def\newcodeindex#1{%
4844  \expandafter\chardef\csname#1indfile\endcsname=0
4845  \expandafter\xdef\csname#1index\endcsname{%
4846    \noexpand\docodeindex{#1}}%
4847}
4848
4849% The default indices:
4850\newindex{cp}%      concepts,
4851\newcodeindex{fn}%  functions,
4852\newcodeindex{vr}%  variables,
4853\newcodeindex{tp}%  types,
4854\newcodeindex{ky}%  keys
4855\newcodeindex{pg}%  and programs.
4856
4857
4858% @synindex foo bar    makes index foo feed into index bar.
4859% Do this instead of @defindex foo if you don't want it as a separate index.
4860%
4861% @syncodeindex foo bar   similar, but put all entries made for index foo
4862% inside @code.
4863%
4864\def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}}
4865\def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}}
4866
4867% #1 is \doindex or \docodeindex, #2 the index getting redefined (foo),
4868% #3 the target index (bar).
4869\def\dosynindex#1#2#3{%
4870  \requireopenindexfile{#3}%
4871  % redefine \fooindfile:
4872  \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname
4873  \expandafter\let\csname#2indfile\endcsname=\temp
4874  % redefine \fooindex:
4875  \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}%
4876}
4877
4878% Define \doindex, the driver for all index macros.
4879% Argument #1 is generated by the calling \fooindex macro,
4880% and it is the two-letter name of the index.
4881
4882\def\doindex#1{\edef\indexname{#1}\parsearg\doindexxxx}
4883\def\doindexxxx #1{\doind{\indexname}{#1}}
4884
4885% like the previous two, but they put @code around the argument.
4886\def\docodeindex#1{\edef\indexname{#1}\parsearg\docodeindexxxx}
4887\def\docodeindexxxx #1{\doind{\indexname}{\code{#1}}}
4888
4889
4890% Used when writing an index entry out to an index file to prevent
4891% expansion of Texinfo commands that can appear in an index entry.
4892%
4893\def\indexdummies{%
4894  \escapechar = `\\     % use backslash in output files.
4895  \definedummyletter\@%
4896  \definedummyletter\ %
4897  %
4898  % For texindex which always views { and } as separators.
4899  \def\{{\lbracechar{}}%
4900  \def\}{\rbracechar{}}%
4901  %
4902  % Do the redefinitions.
4903  \definedummies
4904}
4905
4906% Used for the aux and toc files, where @ is the escape character.
4907%
4908\def\atdummies{%
4909  \definedummyletter\@%
4910  \definedummyletter\ %
4911  \definedummyletter\{%
4912  \definedummyletter\}%
4913  %
4914  % Do the redefinitions.
4915  \definedummies
4916  \otherbackslash
4917}
4918
4919% \definedummyword defines \#1 as \string\#1\space, thus effectively
4920% preventing its expansion.  This is used only for control words,
4921% not control letters, because the \space would be incorrect for
4922% control characters, but is needed to separate the control word
4923% from whatever follows.
4924%
4925% These can be used both for control words that take an argument and
4926% those that do not.  If it is followed by {arg} in the input, then
4927% that will dutifully get written to the index (or wherever).
4928%
4929% For control letters, we have \definedummyletter, which omits the
4930% space.
4931%
4932\def\definedummyword  #1{\def#1{\string#1\space}}%
4933\def\definedummyletter#1{\def#1{\string#1}}%
4934\let\definedummyaccent\definedummyletter
4935
4936% Called from \indexdummies and \atdummies, to effectively prevent
4937% the expansion of commands.
4938%
4939\def\definedummies{%
4940  %
4941  \let\commondummyword\definedummyword
4942  \let\commondummyletter\definedummyletter
4943  \let\commondummyaccent\definedummyaccent
4944  \commondummiesnofonts
4945  %
4946  \definedummyletter\_%
4947  \definedummyletter\-%
4948  %
4949  % Non-English letters.
4950  \definedummyword\AA
4951  \definedummyword\AE
4952  \definedummyword\DH
4953  \definedummyword\L
4954  \definedummyword\O
4955  \definedummyword\OE
4956  \definedummyword\TH
4957  \definedummyword\aa
4958  \definedummyword\ae
4959  \definedummyword\dh
4960  \definedummyword\exclamdown
4961  \definedummyword\l
4962  \definedummyword\o
4963  \definedummyword\oe
4964  \definedummyword\ordf
4965  \definedummyword\ordm
4966  \definedummyword\questiondown
4967  \definedummyword\ss
4968  \definedummyword\th
4969  %
4970  % Although these internal commands shouldn't show up, sometimes they do.
4971  \definedummyword\bf
4972  \definedummyword\gtr
4973  \definedummyword\hat
4974  \definedummyword\less
4975  \definedummyword\sf
4976  \definedummyword\sl
4977  \definedummyword\tclose
4978  \definedummyword\tt
4979  %
4980  \definedummyword\LaTeX
4981  \definedummyword\TeX
4982  %
4983  % Assorted special characters.
4984  \definedummyword\atchar
4985  \definedummyword\arrow
4986  \definedummyword\bullet
4987  \definedummyword\comma
4988  \definedummyword\copyright
4989  \definedummyword\registeredsymbol
4990  \definedummyword\dots
4991  \definedummyword\enddots
4992  \definedummyword\entrybreak
4993  \definedummyword\equiv
4994  \definedummyword\error
4995  \definedummyword\euro
4996  \definedummyword\expansion
4997  \definedummyword\geq
4998  \definedummyword\guillemetleft
4999  \definedummyword\guillemetright
5000  \definedummyword\guilsinglleft
5001  \definedummyword\guilsinglright
5002  \definedummyword\lbracechar
5003  \definedummyword\leq
5004  \definedummyword\mathopsup
5005  \definedummyword\minus
5006  \definedummyword\ogonek
5007  \definedummyword\pounds
5008  \definedummyword\point
5009  \definedummyword\print
5010  \definedummyword\quotedblbase
5011  \definedummyword\quotedblleft
5012  \definedummyword\quotedblright
5013  \definedummyword\quoteleft
5014  \definedummyword\quoteright
5015  \definedummyword\quotesinglbase
5016  \definedummyword\rbracechar
5017  \definedummyword\result
5018  \definedummyword\sub
5019  \definedummyword\sup
5020  \definedummyword\textdegree
5021  %
5022  % We want to disable all macros so that they are not expanded by \write.
5023  \macrolist
5024  \let\value\dummyvalue
5025  %
5026  \normalturnoffactive
5027}
5028
5029% \commondummiesnofonts: common to \definedummies and \indexnofonts.
5030% Define \commondummyletter, \commondummyaccent and \commondummyword before
5031% using.  Used for accents, font commands, and various control letters.
5032%
5033\def\commondummiesnofonts{%
5034  % Control letters and accents.
5035  \commondummyletter\!%
5036  \commondummyaccent\"%
5037  \commondummyaccent\'%
5038  \commondummyletter\*%
5039  \commondummyaccent\,%
5040  \commondummyletter\.%
5041  \commondummyletter\/%
5042  \commondummyletter\:%
5043  \commondummyaccent\=%
5044  \commondummyletter\?%
5045  \commondummyaccent\^%
5046  \commondummyaccent\`%
5047  \commondummyaccent\~%
5048  \commondummyword\u
5049  \commondummyword\v
5050  \commondummyword\H
5051  \commondummyword\dotaccent
5052  \commondummyword\ogonek
5053  \commondummyword\ringaccent
5054  \commondummyword\tieaccent
5055  \commondummyword\ubaraccent
5056  \commondummyword\udotaccent
5057  \commondummyword\dotless
5058  %
5059  % Texinfo font commands.
5060  \commondummyword\b
5061  \commondummyword\i
5062  \commondummyword\r
5063  \commondummyword\sansserif
5064  \commondummyword\sc
5065  \commondummyword\slanted
5066  \commondummyword\t
5067  %
5068  % Commands that take arguments.
5069  \commondummyword\abbr
5070  \commondummyword\acronym
5071  \commondummyword\anchor
5072  \commondummyword\cite
5073  \commondummyword\code
5074  \commondummyword\command
5075  \commondummyword\dfn
5076  \commondummyword\dmn
5077  \commondummyword\email
5078  \commondummyword\emph
5079  \commondummyword\env
5080  \commondummyword\file
5081  \commondummyword\image
5082  \commondummyword\indicateurl
5083  \commondummyword\inforef
5084  \commondummyword\kbd
5085  \commondummyword\key
5086  \commondummyword\math
5087  \commondummyword\option
5088  \commondummyword\pxref
5089  \commondummyword\ref
5090  \commondummyword\samp
5091  \commondummyword\strong
5092  \commondummyword\tie
5093  \commondummyword\U
5094  \commondummyword\uref
5095  \commondummyword\url
5096  \commondummyword\var
5097  \commondummyword\verb
5098  \commondummyword\w
5099  \commondummyword\xref
5100}
5101
5102% For testing: output @{ and @} in index sort strings as \{ and \}.
5103\newif\ifusebracesinindexes
5104
5105\let\indexlbrace\relax
5106\let\indexrbrace\relax
5107
5108{\catcode`\@=0
5109\catcode`\\=13
5110  @gdef@backslashdisappear{@def\{}}
5111}
5112
5113{
5114\catcode`\<=13
5115\catcode`\-=13
5116\catcode`\`=13
5117  \gdef\indexnonalnumdisappear{%
5118    \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax\else
5119      % @set txiindexlquoteignore makes us ignore left quotes in the sort term.
5120      % (Introduced for FSFS 2nd ed.)
5121      \let`=\empty
5122    \fi
5123    %
5124    \expandafter\ifx\csname SETtxiindexbackslashignore\endcsname\relax\else
5125      \backslashdisappear
5126    \fi
5127    %
5128    \expandafter\ifx\csname SETtxiindexhyphenignore\endcsname\relax\else
5129      \def-{}%
5130    \fi
5131    \expandafter\ifx\csname SETtxiindexlessthanignore\endcsname\relax\else
5132      \def<{}%
5133    \fi
5134    \expandafter\ifx\csname SETtxiindexatsignignore\endcsname\relax\else
5135      \def\@{}%
5136    \fi
5137  }
5138
5139  \gdef\indexnonalnumreappear{%
5140    \useindexbackslash
5141    \let-\normaldash
5142    \let<\normalless
5143    \def\@{@}%
5144  }
5145}
5146
5147
5148% \indexnofonts is used when outputting the strings to sort the index
5149% by, and when constructing control sequence names.  It eliminates all
5150% control sequences and just writes whatever the best ASCII sort string
5151% would be for a given command (usually its argument).
5152%
5153\def\indexnofonts{%
5154  % Accent commands should become @asis.
5155  \def\commondummyaccent##1{\let##1\asis}%
5156  % We can just ignore other control letters.
5157  \def\commondummyletter##1{\let##1\empty}%
5158  % All control words become @asis by default; overrides below.
5159  \let\commondummyword\commondummyaccent
5160  \commondummiesnofonts
5161  %
5162  % Don't no-op \tt, since it isn't a user-level command
5163  % and is used in the definitions of the active chars like <, >, |, etc.
5164  % Likewise with the other plain tex font commands.
5165  %\let\tt=\asis
5166  %
5167  \def\ { }%
5168  \def\@{@}%
5169  \def\_{\normalunderscore}%
5170  \def\-{}% @- shouldn't affect sorting
5171  %
5172  \uccode`\1=`\{ \uppercase{\def\{{1}}%
5173  \uccode`\1=`\} \uppercase{\def\}{1}}%
5174  \let\lbracechar\{%
5175  \let\rbracechar\}%
5176  %
5177  % Non-English letters.
5178  \def\AA{AA}%
5179  \def\AE{AE}%
5180  \def\DH{DZZ}%
5181  \def\L{L}%
5182  \def\OE{OE}%
5183  \def\O{O}%
5184  \def\TH{TH}%
5185  \def\aa{aa}%
5186  \def\ae{ae}%
5187  \def\dh{dzz}%
5188  \def\exclamdown{!}%
5189  \def\l{l}%
5190  \def\oe{oe}%
5191  \def\ordf{a}%
5192  \def\ordm{o}%
5193  \def\o{o}%
5194  \def\questiondown{?}%
5195  \def\ss{ss}%
5196  \def\th{th}%
5197  %
5198  \def\LaTeX{LaTeX}%
5199  \def\TeX{TeX}%
5200  %
5201  % Assorted special characters.  \defglyph gives the control sequence a
5202  % definition that removes the {} that follows its use.
5203  \defglyph\atchar{@}%
5204  \defglyph\arrow{->}%
5205  \defglyph\bullet{bullet}%
5206  \defglyph\comma{,}%
5207  \defglyph\copyright{copyright}%
5208  \defglyph\dots{...}%
5209  \defglyph\enddots{...}%
5210  \defglyph\equiv{==}%
5211  \defglyph\error{error}%
5212  \defglyph\euro{euro}%
5213  \defglyph\expansion{==>}%
5214  \defglyph\geq{>=}%
5215  \defglyph\guillemetleft{<<}%
5216  \defglyph\guillemetright{>>}%
5217  \defglyph\guilsinglleft{<}%
5218  \defglyph\guilsinglright{>}%
5219  \defglyph\leq{<=}%
5220  \defglyph\lbracechar{\{}%
5221  \defglyph\minus{-}%
5222  \defglyph\point{.}%
5223  \defglyph\pounds{pounds}%
5224  \defglyph\print{-|}%
5225  \defglyph\quotedblbase{"}%
5226  \defglyph\quotedblleft{"}%
5227  \defglyph\quotedblright{"}%
5228  \defglyph\quoteleft{`}%
5229  \defglyph\quoteright{'}%
5230  \defglyph\quotesinglbase{,}%
5231  \defglyph\rbracechar{\}}%
5232  \defglyph\registeredsymbol{R}%
5233  \defglyph\result{=>}%
5234  \defglyph\textdegree{o}%
5235  %
5236  % We need to get rid of all macros, leaving only the arguments (if present).
5237  % Of course this is not nearly correct, but it is the best we can do for now.
5238  % makeinfo does not expand macros in the argument to @deffn, which ends up
5239  % writing an index entry, and texindex isn't prepared for an index sort entry
5240  % that starts with \.
5241  %
5242  % Since macro invocations are followed by braces, we can just redefine them
5243  % to take a single TeX argument.  The case of a macro invocation that
5244  % goes to end-of-line is not handled.
5245  %
5246  \macrolist
5247  \let\value\indexnofontsvalue
5248}
5249\def\defglyph#1#2{\def#1##1{#2}} % see above
5250
5251
5252
5253
5254\let\SETmarginindex=\relax % put index entries in margin (undocumented)?
5255
5256% Most index entries go through here, but \dosubind is the general case.
5257% #1 is the index name, #2 is the entry text.
5258\def\doind#1#2{\dosubind{#1}{#2}{}}
5259
5260% There is also \dosubind {index}{topic}{subtopic}
5261% which makes an entry in a two-level index such as the operation index.
5262% TODO: Two-level index?  Operation index?
5263
5264% Workhorse for all indexes.
5265% #1 is name of index, #2 is stuff to put there, #3 is subentry --
5266% empty if called from \doind, as we usually are (the main exception
5267% is with most defuns, which call us directly).
5268%
5269\def\dosubind#1#2#3{%
5270  \iflinks
5271  {%
5272    \requireopenindexfile{#1}%
5273    % Store the main index entry text (including the third arg).
5274    \toks0 = {#2}%
5275    % If third arg is present, precede it with a space.
5276    \def\thirdarg{#3}%
5277    \ifx\thirdarg\empty \else
5278      \toks0 = \expandafter{\the\toks0 \space #3}%
5279    \fi
5280    %
5281    \edef\writeto{\csname#1indfile\endcsname}%
5282    %
5283    \safewhatsit\dosubindwrite
5284  }%
5285  \fi
5286}
5287
5288% Check if an index file has been opened, and if not, open it.
5289\def\requireopenindexfile#1{%
5290\ifnum\csname #1indfile\endcsname=0
5291  \expandafter\newwrite \csname#1indfile\endcsname
5292  \edef\suffix{#1}%
5293  % A .fls suffix would conflict with the file extension for the output
5294  % of -recorder, so use .f1s instead.
5295  \ifx\suffix\indexisfl\def\suffix{f1}\fi
5296  % Open the file
5297  \immediate\openout\csname#1indfile\endcsname \jobname.\suffix
5298  % Using \immediate above here prevents an object entering into the current
5299  % box, which could confound checks such as those in \safewhatsit for
5300  % preceding skips.
5301  \typeout{Writing index file \jobname.\suffix}%
5302\fi}
5303\def\indexisfl{fl}
5304
5305% Output \ as {\indexbackslash}, because \ is an escape character in
5306% the index files.
5307\let\indexbackslash=\relax
5308{\catcode`\@=0 \catcode`\\=\active
5309  @gdef@useindexbackslash{@def\{{@indexbackslash}}}
5310}
5311
5312% Definition for writing index entry text.
5313\def\sortas#1{\ignorespaces}%
5314
5315% Definition for writing index entry sort key.  Should occur at the at
5316% the beginning of the index entry, like
5317%     @cindex @sortas{september} \september
5318% The \ignorespaces takes care of following space, but there's no way
5319% to remove space before it.
5320{
5321\catcode`\-=13
5322\gdef\indexwritesortas{%
5323  \begingroup
5324  \indexnonalnumreappear
5325  \indexwritesortasxxx}
5326\gdef\indexwritesortasxxx#1{%
5327  \xdef\indexsortkey{#1}\endgroup}
5328}
5329
5330
5331% Write the entry in \toks0 to the index file.
5332%
5333\def\dosubindwrite{%
5334  % Put the index entry in the margin if desired.
5335  \ifx\SETmarginindex\relax\else
5336    \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}%
5337  \fi
5338  %
5339  % Remember, we are within a group.
5340  \indexdummies % Must do this here, since \bf, etc expand at this stage
5341  \useindexbackslash % \indexbackslash isn't defined now so it will be output
5342                     % as is; and it will print as backslash.
5343  % The braces around \indexbrace are recognized by texindex.
5344  %
5345  % Get the string to sort by, by processing the index entry with all
5346  % font commands turned off.
5347  {\indexnofonts
5348   \def\lbracechar{{\indexlbrace}}%
5349   \def\rbracechar{{\indexrbrace}}%
5350   \let\{=\lbracechar
5351   \let\}=\rbracechar
5352   \indexnonalnumdisappear
5353   \xdef\indexsortkey{}%
5354   \let\sortas=\indexwritesortas
5355   \edef\temp{\the\toks0}%
5356   \setbox\dummybox = \hbox{\temp}% Make sure to execute any \sortas
5357   \ifx\indexsortkey\empty
5358     \xdef\indexsortkey{\temp}%
5359     \ifx\indexsortkey\empty\xdef\indexsortkey{ }\fi
5360   \fi
5361  }%
5362  %
5363  % Set up the complete index entry, with both the sort key and
5364  % the original text, including any font commands.  We write
5365  % three arguments to \entry to the .?? file (four in the
5366  % subentry case), texindex reduces to two when writing the .??s
5367  % sorted result.
5368  \edef\temp{%
5369    \write\writeto{%
5370      \string\entry{\indexsortkey}{\noexpand\folio}{\the\toks0}}%
5371  }%
5372  \temp
5373}
5374\newbox\dummybox % used above
5375
5376% Take care of unwanted page breaks/skips around a whatsit:
5377%
5378% If a skip is the last thing on the list now, preserve it
5379% by backing up by \lastskip, doing the \write, then inserting
5380% the skip again.  Otherwise, the whatsit generated by the
5381% \write or \pdfdest will make \lastskip zero.  The result is that
5382% sequences like this:
5383% @end defun
5384% @tindex whatever
5385% @defun ...
5386% will have extra space inserted, because the \medbreak in the
5387% start of the @defun won't see the skip inserted by the @end of
5388% the previous defun.
5389%
5390% But don't do any of this if we're not in vertical mode.  We
5391% don't want to do a \vskip and prematurely end a paragraph.
5392%
5393% Avoid page breaks due to these extra skips, too.
5394%
5395% But wait, there is a catch there:
5396% We'll have to check whether \lastskip is zero skip.  \ifdim is not
5397% sufficient for this purpose, as it ignores stretch and shrink parts
5398% of the skip.  The only way seems to be to check the textual
5399% representation of the skip.
5400%
5401% The following is almost like \def\zeroskipmacro{0.0pt} except that
5402% the ``p'' and ``t'' characters have catcode \other, not 11 (letter).
5403%
5404\edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname}
5405%
5406\newskip\whatsitskip
5407\newcount\whatsitpenalty
5408%
5409% ..., ready, GO:
5410%
5411\def\safewhatsit#1{\ifhmode
5412  #1%
5413 \else
5414  % \lastskip and \lastpenalty cannot both be nonzero simultaneously.
5415  \whatsitskip = \lastskip
5416  \edef\lastskipmacro{\the\lastskip}%
5417  \whatsitpenalty = \lastpenalty
5418  %
5419  % If \lastskip is nonzero, that means the last item was a
5420  % skip.  And since a skip is discardable, that means this
5421  % -\whatsitskip glue we're inserting is preceded by a
5422  % non-discardable item, therefore it is not a potential
5423  % breakpoint, therefore no \nobreak needed.
5424  \ifx\lastskipmacro\zeroskipmacro
5425  \else
5426    \vskip-\whatsitskip
5427  \fi
5428  %
5429  #1%
5430  %
5431  \ifx\lastskipmacro\zeroskipmacro
5432    % If \lastskip was zero, perhaps the last item was a penalty, and
5433    % perhaps it was >=10000, e.g., a \nobreak.  In that case, we want
5434    % to re-insert the same penalty (values >10000 are used for various
5435    % signals); since we just inserted a non-discardable item, any
5436    % following glue (such as a \parskip) would be a breakpoint.  For example:
5437    %   @deffn deffn-whatever
5438    %   @vindex index-whatever
5439    %   Description.
5440    % would allow a break between the index-whatever whatsit
5441    % and the "Description." paragraph.
5442    \ifnum\whatsitpenalty>9999 \penalty\whatsitpenalty \fi
5443  \else
5444    % On the other hand, if we had a nonzero \lastskip,
5445    % this make-up glue would be preceded by a non-discardable item
5446    % (the whatsit from the \write), so we must insert a \nobreak.
5447    \nobreak\vskip\whatsitskip
5448  \fi
5449\fi}
5450
5451% The index entry written in the file actually looks like
5452%  \entry {sortstring}{page}{topic}
5453% or
5454%  \entry {sortstring}{page}{topic}{subtopic}
5455% The texindex program reads in these files and writes files
5456% containing these kinds of lines:
5457%  \initial {c}
5458%     before the first topic whose initial is c
5459%  \entry {topic}{pagelist}
5460%     for a topic that is used without subtopics
5461%  \primary {topic}
5462%     for the beginning of a topic that is used with subtopics
5463%  \secondary {subtopic}{pagelist}
5464%     for each subtopic.
5465
5466% Define the user-accessible indexing commands
5467% @findex, @vindex, @kindex, @cindex.
5468
5469\def\findex {\fnindex}
5470\def\kindex {\kyindex}
5471\def\cindex {\cpindex}
5472\def\vindex {\vrindex}
5473\def\tindex {\tpindex}
5474\def\pindex {\pgindex}
5475
5476\def\cindexsub {\begingroup\obeylines\cindexsub}
5477{\obeylines %
5478\gdef\cindexsub "#1" #2^^M{\endgroup %
5479\dosubind{cp}{#2}{#1}}}
5480
5481% Define the macros used in formatting output of the sorted index material.
5482
5483% @printindex causes a particular index (the ??s file) to get printed.
5484% It does not print any chapter heading (usually an @unnumbered).
5485%
5486\parseargdef\printindex{\begingroup
5487  \dobreak \chapheadingskip{10000}%
5488  %
5489  \smallfonts \rm
5490  \tolerance = 9500
5491  \plainfrenchspacing
5492  \everypar = {}% don't want the \kern\-parindent from indentation suppression.
5493  %
5494  % See if the index file exists and is nonempty.
5495  % Change catcode of @ here so that if the index file contains
5496  % \initial {@}
5497  % as its first line, TeX doesn't complain about mismatched braces
5498  % (because it thinks @} is a control sequence).
5499  \catcode`\@ = 12
5500  % See comment in \requireopenindexfile.
5501  \def\indexname{#1}\ifx\indexname\indexisfl\def\indexname{f1}\fi
5502  \openin 1 \jobname.\indexname s
5503  \ifeof 1
5504    % \enddoublecolumns gets confused if there is no text in the index,
5505    % and it loses the chapter title and the aux file entries for the
5506    % index.  The easiest way to prevent this problem is to make sure
5507    % there is some text.
5508    \putwordIndexNonexistent
5509    \typeout{No file \jobname.\indexname s.}%
5510  \else
5511    \catcode`\\ = 0
5512    %
5513    % If the index file exists but is empty, then \openin leaves \ifeof
5514    % false.  We have to make TeX try to read something from the file, so
5515    % it can discover if there is anything in it.
5516    \read 1 to \thisline
5517    \ifeof 1
5518      \putwordIndexIsEmpty
5519    \else
5520      % Index files are almost Texinfo source, but we use \ as the escape
5521      % character.  It would be better to use @, but that's too big a change
5522      % to make right now.
5523      \def\indexbackslash{\ttbackslash}%
5524      \let\indexlbrace\{   % Likewise, set these sequences for braces
5525      \let\indexrbrace\}   % used in the sort key.
5526      \begindoublecolumns
5527      \let\dotheinsertentrybox\dotheinsertentryboxwithpenalty
5528      %
5529      % Read input from the index file line by line.
5530      \loopdo
5531        \ifeof1 \else
5532          \read 1 to \nextline
5533        \fi
5534        %
5535        \indexinputprocessing
5536        \thisline
5537        %
5538        \ifeof1\else
5539        \let\thisline\nextline
5540      \repeat
5541      %%
5542      \enddoublecolumns
5543    \fi
5544  \fi
5545  \closein 1
5546\endgroup}
5547\def\loopdo#1\repeat{\def\body{#1}\loopdoxxx}
5548\def\loopdoxxx{\let\next=\relax\body\let\next=\loopdoxxx\fi\next}
5549
5550\def\indexinputprocessing{%
5551  \ifeof1
5552    \let\firsttoken\relax
5553  \else
5554    \edef\act{\gdef\noexpand\firsttoken{\getfirsttoken\nextline}}%
5555    \act
5556  \fi
5557}
5558\def\getfirsttoken#1{\expandafter\getfirsttokenx#1\endfirsttoken}
5559\long\def\getfirsttokenx#1#2\endfirsttoken{\noexpand#1}
5560
5561
5562% These macros are used by the sorted index file itself.
5563% Change them to control the appearance of the index.
5564
5565{\catcode`\/=13 \catcode`\-=13 \catcode`\^=13 \catcode`\~=13 \catcode`\_=13
5566\catcode`\|=13 \catcode`\<=13 \catcode`\>=13 \catcode`\+=13 \catcode`\"=13
5567\catcode`\$=3
5568\gdef\initialglyphs{%
5569  % Some changes for non-alphabetic characters.  Using the glyphs from the
5570  % math fonts looks more consistent than the typewriter font used elsewhere
5571  % for these characters.
5572  \def\indexbackslash{\math{\backslash}}%
5573  \let\\=\indexbackslash
5574  %
5575  % Can't get bold backslash so don't use bold forward slash
5576  \catcode`\/=13
5577  \def/{{\secrmnotbold \normalslash}}%
5578  \def-{{\normaldash\normaldash}}% en dash `--'
5579  \def^{{\chapbf \normalcaret}}%
5580  \def~{{\chapbf \normaltilde}}%
5581  \def\_{%
5582     \leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }%
5583  \def|{$\vert$}%
5584  \def<{$\less$}%
5585  \def>{$\gtr$}%
5586  \def+{$\normalplus$}%
5587}}
5588
5589\def\initial{%
5590  \bgroup
5591  \initialglyphs
5592  \initialx
5593}
5594
5595\def\initialx#1{%
5596  % Remove any glue we may have, we'll be inserting our own.
5597  \removelastskip
5598  %
5599  % We like breaks before the index initials, so insert a bonus.
5600  % The glue before the bonus allows a little bit of space at the
5601  % bottom of a column to reduce an increase in inter-line spacing.
5602  \nobreak
5603  \vskip 0pt plus 5\baselineskip
5604  \penalty -300
5605  \vskip 0pt plus -5\baselineskip
5606  %
5607  % Typeset the initial.  Making this add up to a whole number of
5608  % baselineskips increases the chance of the dots lining up from column
5609  % to column.  It still won't often be perfect, because of the stretch
5610  % we need before each entry, but it's better.
5611  %
5612  % No shrink because it confuses \balancecolumns.
5613  \vskip 1.67\baselineskip plus 1\baselineskip
5614  \leftline{\secfonts \kern-0.05em \secbf #1}%
5615  % \secfonts is inside the argument of \leftline so that the change of
5616  % \baselineskip will not affect any glue inserted before the vbox that
5617  % \leftline creates.
5618  % Do our best not to break after the initial.
5619  \nobreak
5620  \vskip .33\baselineskip plus .1\baselineskip
5621  \egroup % \initialglyphs
5622}
5623
5624\newdimen\entryrightmargin
5625\entryrightmargin=0pt
5626
5627% \entry typesets a paragraph consisting of the text (#1), dot leaders, and
5628% then page number (#2) flushed to the right margin.  It is used for index
5629% and table of contents entries.  The paragraph is indented by \leftskip.
5630%
5631\def\entry{%
5632  \begingroup
5633    %
5634    % For pdfTeX and XeTeX.
5635    % The redefinition of \domark stops marks being added in \pdflink to
5636    % preserve coloured links across page boundaries.  Otherwise the marks
5637    % would get in the way of \lastbox in \insertentrybox.
5638    \let\domark\relax
5639    %
5640    % Start a new paragraph if necessary, so our assignments below can't
5641    % affect previous text.
5642    \par
5643    %
5644    % No extra space above this paragraph.
5645    \parskip = 0in
5646    %
5647    % When reading the text of entry, convert explicit line breaks
5648    % from @* into spaces.  The user might give these in long section
5649    % titles, for instance.
5650    \def\*{\unskip\space\ignorespaces}%
5651    \def\entrybreak{\hfil\break}% An undocumented command
5652    %
5653    % Swallow the left brace of the text (first parameter):
5654    \afterassignment\doentry
5655    \let\temp =
5656}
5657\def\entrybreak{\unskip\space\ignorespaces}%
5658\def\doentry{%
5659    % Save the text of the entry
5660    \global\setbox\boxA=\hbox\bgroup
5661    \bgroup % Instead of the swallowed brace.
5662      \noindent
5663      \aftergroup\finishentry
5664      % And now comes the text of the entry.
5665      % Not absorbing as a macro argument reduces the chance of problems
5666      % with catcodes occurring.
5667}
5668{\catcode`\@=11
5669\gdef\finishentry#1{%
5670    \egroup % end box A
5671    \dimen@ = \wd\boxA % Length of text of entry
5672    \global\setbox\boxA=\hbox\bgroup\unhbox\boxA
5673    % #1 is the page number.
5674    %
5675    % Get the width of the page numbers, and only use
5676    % leaders if they are present.
5677    \global\setbox\boxB = \hbox{#1}%
5678    \ifdim\wd\boxB = 0pt
5679      \null\nobreak\hfill\ %
5680    \else
5681      %
5682      \null\nobreak\indexdotfill % Have leaders before the page number.
5683      %
5684      \ifpdf
5685        \pdfgettoks#1.%
5686        \hskip\skip\thinshrinkable\the\toksA
5687      \else
5688        \ifx\XeTeXrevision\thisisundefined
5689          \hskip\skip\thinshrinkable #1%
5690        \else
5691          \pdfgettoks#1.%
5692          \hskip\skip\thinshrinkable\the\toksA
5693        \fi
5694      \fi
5695    \fi
5696    \egroup % end \boxA
5697    \ifdim\wd\boxB = 0pt
5698      \global\setbox\entrybox=\vbox{\unhbox\boxA}%
5699    \else
5700    \global\setbox\entrybox=\vbox\bgroup
5701      % We want the text of the entries to be aligned to the left, and the
5702      % page numbers to be aligned to the right.
5703      %
5704      \parindent = 0pt
5705      \advance\leftskip by 0pt plus 1fil
5706      \advance\leftskip by 0pt plus -1fill
5707      \rightskip = 0pt plus -1fil
5708      \advance\rightskip by 0pt plus 1fill
5709      % Cause last line, which could consist of page numbers on their own
5710      % if the list of page numbers is long, to be aligned to the right.
5711      \parfillskip=0pt plus -1fill
5712      %
5713      \advance\rightskip by \entryrightmargin
5714      % Determine how far we can stretch into the margin.
5715      % This allows, e.g., "Appendix H  GNU Free Documentation License" to
5716      % fit on one line in @letterpaper format.
5717      \ifdim\entryrightmargin>2.1em
5718        \dimen@i=2.1em
5719      \else
5720        \dimen@i=0em
5721      \fi
5722      \advance \parfillskip by 0pt minus 1\dimen@i
5723      %
5724      \dimen@ii = \hsize
5725      \advance\dimen@ii by -1\leftskip
5726      \advance\dimen@ii by -1\entryrightmargin
5727      \advance\dimen@ii by 1\dimen@i
5728      \ifdim\wd\boxA > \dimen@ii % If the entry doesn't fit in one line
5729      \ifdim\dimen@ > 0.8\dimen@ii   % due to long index text
5730        % Try to split the text roughly evenly.  \dimen@ will be the length of
5731        % the first line.
5732        \dimen@ = 0.7\dimen@
5733        \dimen@ii = \hsize
5734        \ifnum\dimen@>\dimen@ii
5735          % If the entry is too long (for example, if it needs more than
5736          % two lines), use all the space in the first line.
5737          \dimen@ = \dimen@ii
5738        \fi
5739        \advance\leftskip by 0pt plus 1fill % ragged right
5740        \advance \dimen@ by 1\rightskip
5741        \parshape = 2 0pt \dimen@ 0em \dimen@ii
5742        % Ideally we'd add a finite glue at the end of the first line only,
5743        % instead of using \parshape with explicit line lengths, but TeX
5744        % doesn't seem to provide a way to do such a thing.
5745        %
5746        % Indent all lines but the first one.
5747        \advance\leftskip by 1em
5748        \advance\parindent by -1em
5749      \fi\fi
5750      \indent % start paragraph
5751      \unhbox\boxA
5752      %
5753      % Do not prefer a separate line ending with a hyphen to fewer lines.
5754      \finalhyphendemerits = 0
5755      %
5756      % Word spacing - no stretch
5757      \spaceskip=\fontdimen2\font minus \fontdimen4\font
5758      %
5759      \linepenalty=1000  % Discourage line breaks.
5760      \hyphenpenalty=5000  % Discourage hyphenation.
5761      %
5762      \par % format the paragraph
5763    \egroup % The \vbox
5764    \fi
5765  \endgroup
5766  \dotheinsertentrybox
5767}}
5768
5769\newskip\thinshrinkable
5770\skip\thinshrinkable=.15em minus .15em
5771
5772\newbox\entrybox
5773\def\insertentrybox{%
5774  \ourunvbox\entrybox
5775}
5776
5777% default definition
5778\let\dotheinsertentrybox\insertentrybox
5779
5780% Use \lastbox to take apart vbox box by box, and add each sub-box
5781% to the current vertical list.
5782\def\ourunvbox#1{%
5783\bgroup % for local binding of \delayedbox
5784  % Remove the last box from box #1
5785  \global\setbox#1=\vbox{%
5786    \unvbox#1%
5787    \unskip % remove any glue
5788    \unpenalty
5789    \global\setbox\interbox=\lastbox
5790  }%
5791  \setbox\delayedbox=\box\interbox
5792  \ifdim\ht#1=0pt\else
5793    \ourunvbox#1 % Repeat on what's left of the box
5794    \nobreak
5795  \fi
5796  \box\delayedbox
5797\egroup
5798}
5799\newbox\delayedbox
5800\newbox\interbox
5801
5802% Used from \printindex.  \firsttoken should be the first token
5803% after the \entry.  If it's not another \entry, we are at the last
5804% line of a group of index entries, so insert a penalty to discourage
5805% widowed index entries.
5806\def\dotheinsertentryboxwithpenalty{%
5807  \ifx\firsttoken\isentry
5808  \else
5809    \penalty 9000
5810  \fi
5811  \insertentrybox
5812}
5813\def\isentry{\entry}%
5814
5815% Like plain.tex's \dotfill, except uses up at least 1 em.
5816% The filll stretch here overpowers both the fil and fill stretch to push
5817% the page number to the right.
5818\def\indexdotfill{\cleaders
5819  \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1filll}
5820
5821
5822\def\primary #1{\line{#1\hfil}}
5823
5824\newskip\secondaryindent \secondaryindent=0.5cm
5825\def\secondary#1#2{{%
5826  \parfillskip=0in
5827  \parskip=0in
5828  \hangindent=1in
5829  \hangafter=1
5830  \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill
5831  \ifpdf
5832    \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
5833  \else
5834    \ifx\XeTeXrevision\thisisundefined
5835      #2
5836    \else
5837      \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
5838    \fi
5839  \fi
5840  \par
5841}}
5842
5843% Define two-column mode, which we use to typeset indexes.
5844% Adapted from the TeXbook, page 416, which is to say,
5845% the manmac.tex format used to print the TeXbook itself.
5846\catcode`\@=11  % private names
5847
5848\newbox\partialpage
5849\newdimen\doublecolumnhsize
5850
5851% Use inside an output routine to save \topmark and \firstmark
5852\def\savemarks{%
5853  \global\savedtopmark=\expandafter{\topmark }%
5854  \global\savedfirstmark=\expandafter{\firstmark }%
5855}
5856\newtoks\savedtopmark
5857\newtoks\savedfirstmark
5858
5859% Set \topmark and \firstmark for next time \output runs.
5860% Can't be run from withinside \output (because any material
5861% added while an output routine is active, including
5862% penalties, is saved for after it finishes).  The page so far
5863% should be empty, otherwise what's on it will be thrown away.
5864\def\restoremarks{%
5865  \mark{\the\savedtopmark}%
5866  \bgroup\output = {%
5867    \setbox\dummybox=\box\PAGE
5868  }abc\eject\egroup
5869  % "abc" because output routine doesn't fire for a completely empty page.
5870  \mark{\the\savedfirstmark}%
5871}
5872
5873\def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
5874  % If not much space left on page, start a new page.
5875  \ifdim\pagetotal>0.8\vsize\vfill\eject\fi
5876  %
5877  % Grab any single-column material above us.
5878  \output = {%
5879    %
5880    % Here is a possibility not foreseen in manmac: if we accumulate a
5881    % whole lot of material, we might end up calling this \output
5882    % routine twice in a row (see the doublecol-lose test, which is
5883    % essentially a couple of indexes with @setchapternewpage off).  In
5884    % that case we just ship out what is in \partialpage with the normal
5885    % output routine.  Generally, \partialpage will be empty when this
5886    % runs and this will be a no-op.  See the indexspread.tex test case.
5887    \ifvoid\partialpage \else
5888      \onepageout{\pagecontents\partialpage}%
5889    \fi
5890    %
5891    \global\setbox\partialpage = \vbox{%
5892      % Unvbox the main output page.
5893      \unvbox\PAGE
5894      \kern-\topskip \kern\baselineskip
5895    }%
5896    \savemarks
5897  }%
5898  \eject % run that output routine to set \partialpage
5899  \restoremarks
5900  %
5901  % We recover the two marks that the last output routine saved in order
5902  % to propagate the information in marks added around a chapter heading,
5903  % which could be otherwise be lost by the time the final page is output.
5904  %
5905  %
5906  % Use the double-column output routine for subsequent pages.
5907  \output = {\doublecolumnout}%
5908  %
5909  % Change the page size parameters.  We could do this once outside this
5910  % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
5911  % format, but then we repeat the same computation.  Repeating a couple
5912  % of assignments once per index is clearly meaningless for the
5913  % execution time, so we may as well do it in one place.
5914  %
5915  % First we halve the line length, less a little for the gutter between
5916  % the columns.  We compute the gutter based on the line length, so it
5917  % changes automatically with the paper format.  The magic constant
5918  % below is chosen so that the gutter has the same value (well, +-<1pt)
5919  % as it did when we hard-coded it.
5920  %
5921  % We put the result in a separate register, \doublecolumhsize, so we
5922  % can restore it in \pagesofar, after \hsize itself has (potentially)
5923  % been clobbered.
5924  %
5925  \doublecolumnhsize = \hsize
5926    \advance\doublecolumnhsize by -.04154\hsize
5927    \divide\doublecolumnhsize by 2
5928  \hsize = \doublecolumnhsize
5929  %
5930  % Double the \vsize as well.
5931  \advance\vsize by -\ht\partialpage
5932  \vsize = 2\vsize
5933  %
5934  % For the benefit of balancing columns
5935  \advance\baselineskip by 0pt plus 0.5pt
5936}
5937
5938% The double-column output routine for all double-column pages except
5939% the last, which is done by \balancecolumns.
5940%
5941\def\doublecolumnout{%
5942  %
5943  \splittopskip=\topskip \splitmaxdepth=\maxdepth
5944  % Get the available space for the double columns -- the normal
5945  % (undoubled) page height minus any material left over from the
5946  % previous page.
5947  \dimen@ = \vsize
5948  \divide\dimen@ by 2
5949  %
5950  % box0 will be the left-hand column, box2 the right.
5951  \setbox0=\vsplit\PAGE to\dimen@ \setbox2=\vsplit\PAGE to\dimen@
5952  \global\advance\vsize by 2\ht\partialpage
5953  \onepageout\pagesofar
5954  \unvbox\PAGE
5955  \penalty\outputpenalty
5956}
5957%
5958% Re-output the contents of the output page -- any previous material,
5959% followed by the two boxes we just split, in box0 and box2.
5960\def\pagesofar{%
5961  \unvbox\partialpage
5962  %
5963  \hsize = \doublecolumnhsize
5964  \wd0=\hsize \wd2=\hsize
5965  \hbox to\txipagewidth{\box0\hfil\box2}%
5966}
5967
5968
5969% Finished with with double columns.
5970\def\enddoublecolumns{%
5971  % The following penalty ensures that the page builder is exercised
5972  % _before_ we change the output routine.  This is necessary in the
5973  % following situation:
5974  %
5975  % The last section of the index consists only of a single entry.
5976  % Before this section, \pagetotal is less than \pagegoal, so no
5977  % break occurs before the last section starts.  However, the last
5978  % section, consisting of \initial and the single \entry, does not
5979  % fit on the page and has to be broken off.  Without the following
5980  % penalty the page builder will not be exercised until \eject
5981  % below, and by that time we'll already have changed the output
5982  % routine to the \balancecolumns version, so the next-to-last
5983  % double-column page will be processed with \balancecolumns, which
5984  % is wrong:  The two columns will go to the main vertical list, with
5985  % the broken-off section in the recent contributions.  As soon as
5986  % the output routine finishes, TeX starts reconsidering the page
5987  % break.  The two columns and the broken-off section both fit on the
5988  % page, because the two columns now take up only half of the page
5989  % goal.  When TeX sees \eject from below which follows the final
5990  % section, it invokes the new output routine that we've set after
5991  % \balancecolumns below; \onepageout will try to fit the two columns
5992  % and the final section into the vbox of \txipageheight (see
5993  % \pagebody), causing an overfull box.
5994  %
5995  % Note that glue won't work here, because glue does not exercise the
5996  % page builder, unlike penalties (see The TeXbook, pp. 280-281).
5997  \penalty0
5998  %
5999  \output = {%
6000    % Split the last of the double-column material.
6001    \savemarks
6002    \balancecolumns
6003  }%
6004  \eject % call the \output just set
6005  \ifdim\pagetotal=0pt
6006    % Having called \balancecolumns once, we do not
6007    % want to call it again.  Therefore, reset \output to its normal
6008    % definition right away.
6009    \global\output = {\onepageout{\pagecontents\PAGE}}%
6010    %
6011    \endgroup % started in \begindoublecolumns
6012    \restoremarks
6013    % Leave the double-column material on the current page, no automatic
6014    % page break.
6015    \box\balancedcolumns
6016    %
6017    % \pagegoal was set to the doubled \vsize above, since we restarted
6018    % the current page.  We're now back to normal single-column
6019    % typesetting, so reset \pagegoal to the normal \vsize.
6020    \global\vsize = \txipageheight %
6021    \pagegoal = \txipageheight %
6022  \else
6023    % We had some left-over material.  This might happen when \doublecolumnout
6024    % is called in \balancecolumns.  Try again.
6025    \expandafter\enddoublecolumns
6026  \fi
6027}
6028\newbox\balancedcolumns
6029\setbox\balancedcolumns=\vbox{shouldnt see this}%
6030%
6031% Only called for the last of the double column material.  \doublecolumnout
6032% does the others.
6033\def\balancecolumns{%
6034  \setbox0 = \vbox{\unvbox\PAGE}% like \box255 but more efficient, see p.120.
6035  \dimen@ = \ht0
6036  \advance\dimen@ by \topskip
6037  \advance\dimen@ by-\baselineskip
6038  \ifdim\dimen@<5\baselineskip
6039    % Don't split a short final column in two.
6040    \setbox2=\vbox{}%
6041    \global\setbox\balancedcolumns=\vbox{\pagesofar}%
6042  \else
6043    \divide\dimen@ by 2 % target to split to
6044    \dimen@ii = \dimen@
6045    \splittopskip = \topskip
6046    % Loop until left column is at least as high as the right column.
6047    {%
6048      \vbadness = 10000
6049      \loop
6050        \global\setbox3 = \copy0
6051        \global\setbox1 = \vsplit3 to \dimen@
6052      \ifdim\ht1<\ht3
6053        \global\advance\dimen@ by 1pt
6054      \repeat
6055    }%
6056    % Now the left column is in box 1, and the right column in box 3.
6057    %
6058    % Check whether the left column has come out higher than the page itself.
6059    % (Note that we have doubled \vsize for the double columns, so
6060    % the actual height of the page is 0.5\vsize).
6061    \ifdim2\ht1>\vsize
6062      % It appears that we have been called upon to balance too much material.
6063      % Output some of it with \doublecolumnout, leaving the rest on the page.
6064      \setbox\PAGE=\box0
6065      \doublecolumnout
6066    \else
6067      % Compare the heights of the two columns.
6068      \ifdim4\ht1>5\ht3
6069        % Column heights are too different, so don't make their bottoms
6070        % flush with each other.
6071        \setbox2=\vbox to \ht1 {\unvbox3\vfill}%
6072        \setbox0=\vbox to \ht1 {\unvbox1\vfill}%
6073      \else
6074        % Make column bottoms flush with each other.
6075        \setbox2=\vbox to\ht1{\unvbox3\unskip}%
6076        \setbox0=\vbox to\ht1{\unvbox1\unskip}%
6077      \fi
6078      \global\setbox\balancedcolumns=\vbox{\pagesofar}%
6079    \fi
6080  \fi
6081  %
6082}
6083\catcode`\@ = \other
6084
6085
6086\message{sectioning,}
6087% Chapters, sections, etc.
6088
6089% Let's start with @part.
6090\outer\parseargdef\part{\partzzz{#1}}
6091\def\partzzz#1{%
6092  \chapoddpage
6093  \null
6094  \vskip.3\vsize  % move it down on the page a bit
6095  \begingroup
6096    \noindent \titlefonts\rm #1\par % the text
6097    \let\lastnode=\empty      % no node to associate with
6098    \writetocentry{part}{#1}{}% but put it in the toc
6099    \headingsoff              % no headline or footline on the part page
6100    % This outputs a mark at the end of the page that clears \thischapter
6101    % and \thissection, as is done in \startcontents.
6102    \let\pchapsepmacro\relax
6103    \chapmacro{}{Yomitfromtoc}{}%
6104    \chapoddpage
6105  \endgroup
6106}
6107
6108% \unnumberedno is an oxymoron.  But we count the unnumbered
6109% sections so that we can refer to them unambiguously in the pdf
6110% outlines by their "section number".  We avoid collisions with chapter
6111% numbers by starting them at 10000.  (If a document ever has 10000
6112% chapters, we're in trouble anyway, I'm sure.)
6113\newcount\unnumberedno \unnumberedno = 10000
6114\newcount\chapno
6115\newcount\secno        \secno=0
6116\newcount\subsecno     \subsecno=0
6117\newcount\subsubsecno  \subsubsecno=0
6118
6119% This counter is funny since it counts through charcodes of letters A, B, ...
6120\newcount\appendixno  \appendixno = `\@
6121%
6122% \def\appendixletter{\char\the\appendixno}
6123% We do the following ugly conditional instead of the above simple
6124% construct for the sake of pdftex, which needs the actual
6125% letter in the expansion, not just typeset.
6126%
6127\def\appendixletter{%
6128  \ifnum\appendixno=`A A%
6129  \else\ifnum\appendixno=`B B%
6130  \else\ifnum\appendixno=`C C%
6131  \else\ifnum\appendixno=`D D%
6132  \else\ifnum\appendixno=`E E%
6133  \else\ifnum\appendixno=`F F%
6134  \else\ifnum\appendixno=`G G%
6135  \else\ifnum\appendixno=`H H%
6136  \else\ifnum\appendixno=`I I%
6137  \else\ifnum\appendixno=`J J%
6138  \else\ifnum\appendixno=`K K%
6139  \else\ifnum\appendixno=`L L%
6140  \else\ifnum\appendixno=`M M%
6141  \else\ifnum\appendixno=`N N%
6142  \else\ifnum\appendixno=`O O%
6143  \else\ifnum\appendixno=`P P%
6144  \else\ifnum\appendixno=`Q Q%
6145  \else\ifnum\appendixno=`R R%
6146  \else\ifnum\appendixno=`S S%
6147  \else\ifnum\appendixno=`T T%
6148  \else\ifnum\appendixno=`U U%
6149  \else\ifnum\appendixno=`V V%
6150  \else\ifnum\appendixno=`W W%
6151  \else\ifnum\appendixno=`X X%
6152  \else\ifnum\appendixno=`Y Y%
6153  \else\ifnum\appendixno=`Z Z%
6154  % The \the is necessary, despite appearances, because \appendixletter is
6155  % expanded while writing the .toc file.  \char\appendixno is not
6156  % expandable, thus it is written literally, thus all appendixes come out
6157  % with the same letter (or @) in the toc without it.
6158  \else\char\the\appendixno
6159  \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
6160  \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
6161
6162% Each @chapter defines these (using marks) as the number+name, number
6163% and name of the chapter.  Page headings and footings can use
6164% these.  @section does likewise.
6165\def\thischapter{}
6166\def\thischapternum{}
6167\def\thischaptername{}
6168\def\thissection{}
6169\def\thissectionnum{}
6170\def\thissectionname{}
6171
6172\newcount\absseclevel % used to calculate proper heading level
6173\newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count
6174
6175% @raisesections: treat @section as chapter, @subsection as section, etc.
6176\def\raisesections{\global\advance\secbase by -1}
6177\let\up=\raisesections % original BFox name
6178
6179% @lowersections: treat @chapter as section, @section as subsection, etc.
6180\def\lowersections{\global\advance\secbase by 1}
6181\let\down=\lowersections % original BFox name
6182
6183% we only have subsub.
6184\chardef\maxseclevel = 3
6185%
6186% A numbered section within an unnumbered changes to unnumbered too.
6187% To achieve this, remember the "biggest" unnum. sec. we are currently in:
6188\chardef\unnlevel = \maxseclevel
6189%
6190% Trace whether the current chapter is an appendix or not:
6191% \chapheadtype is "N" or "A", unnumbered chapters are ignored.
6192\def\chapheadtype{N}
6193
6194% Choose a heading macro
6195% #1 is heading type
6196% #2 is heading level
6197% #3 is text for heading
6198\def\genhead#1#2#3{%
6199  % Compute the abs. sec. level:
6200  \absseclevel=#2
6201  \advance\absseclevel by \secbase
6202  % Make sure \absseclevel doesn't fall outside the range:
6203  \ifnum \absseclevel < 0
6204    \absseclevel = 0
6205  \else
6206    \ifnum \absseclevel > 3
6207      \absseclevel = 3
6208    \fi
6209  \fi
6210  % The heading type:
6211  \def\headtype{#1}%
6212  \if \headtype U%
6213    \ifnum \absseclevel < \unnlevel
6214      \chardef\unnlevel = \absseclevel
6215    \fi
6216  \else
6217    % Check for appendix sections:
6218    \ifnum \absseclevel = 0
6219      \edef\chapheadtype{\headtype}%
6220    \else
6221      \if \headtype A\if \chapheadtype N%
6222	\errmessage{@appendix... within a non-appendix chapter}%
6223      \fi\fi
6224    \fi
6225    % Check for numbered within unnumbered:
6226    \ifnum \absseclevel > \unnlevel
6227      \def\headtype{U}%
6228    \else
6229      \chardef\unnlevel = 3
6230    \fi
6231  \fi
6232  % Now print the heading:
6233  \if \headtype U%
6234    \ifcase\absseclevel
6235	\unnumberedzzz{#3}%
6236    \or \unnumberedseczzz{#3}%
6237    \or \unnumberedsubseczzz{#3}%
6238    \or \unnumberedsubsubseczzz{#3}%
6239    \fi
6240  \else
6241    \if \headtype A%
6242      \ifcase\absseclevel
6243	  \appendixzzz{#3}%
6244      \or \appendixsectionzzz{#3}%
6245      \or \appendixsubseczzz{#3}%
6246      \or \appendixsubsubseczzz{#3}%
6247      \fi
6248    \else
6249      \ifcase\absseclevel
6250	  \chapterzzz{#3}%
6251      \or \seczzz{#3}%
6252      \or \numberedsubseczzz{#3}%
6253      \or \numberedsubsubseczzz{#3}%
6254      \fi
6255    \fi
6256  \fi
6257  \suppressfirstparagraphindent
6258}
6259
6260% an interface:
6261\def\numhead{\genhead N}
6262\def\apphead{\genhead A}
6263\def\unnmhead{\genhead U}
6264
6265% @chapter, @appendix, @unnumbered.  Increment top-level counter, reset
6266% all lower-level sectioning counters to zero.
6267%
6268% Also set \chaplevelprefix, which we prepend to @float sequence numbers
6269% (e.g., figures), q.v.  By default (before any chapter), that is empty.
6270\let\chaplevelprefix = \empty
6271%
6272\outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz
6273\def\chapterzzz#1{%
6274  % section resetting is \global in case the chapter is in a group, such
6275  % as an @include file.
6276  \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6277    \global\advance\chapno by 1
6278  %
6279  % Used for \float.
6280  \gdef\chaplevelprefix{\the\chapno.}%
6281  \resetallfloatnos
6282  %
6283  % \putwordChapter can contain complex things in translations.
6284  \toks0=\expandafter{\putwordChapter}%
6285  \message{\the\toks0 \space \the\chapno}%
6286  %
6287  % Write the actual heading.
6288  \chapmacro{#1}{Ynumbered}{\the\chapno}%
6289  %
6290  % So @section and the like are numbered underneath this chapter.
6291  \global\let\section = \numberedsec
6292  \global\let\subsection = \numberedsubsec
6293  \global\let\subsubsection = \numberedsubsubsec
6294}
6295
6296\outer\parseargdef\appendix{\apphead0{#1}} % normally calls appendixzzz
6297%
6298\def\appendixzzz#1{%
6299  \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6300    \global\advance\appendixno by 1
6301  \gdef\chaplevelprefix{\appendixletter.}%
6302  \resetallfloatnos
6303  %
6304  % \putwordAppendix can contain complex things in translations.
6305  \toks0=\expandafter{\putwordAppendix}%
6306  \message{\the\toks0 \space \appendixletter}%
6307  %
6308  \chapmacro{#1}{Yappendix}{\appendixletter}%
6309  %
6310  \global\let\section = \appendixsec
6311  \global\let\subsection = \appendixsubsec
6312  \global\let\subsubsection = \appendixsubsubsec
6313}
6314
6315% normally unnmhead0 calls unnumberedzzz:
6316\outer\parseargdef\unnumbered{\unnmhead0{#1}}
6317\def\unnumberedzzz#1{%
6318  \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6319    \global\advance\unnumberedno by 1
6320  %
6321  % Since an unnumbered has no number, no prefix for figures.
6322  \global\let\chaplevelprefix = \empty
6323  \resetallfloatnos
6324  %
6325  % This used to be simply \message{#1}, but TeX fully expands the
6326  % argument to \message.  Therefore, if #1 contained @-commands, TeX
6327  % expanded them.  For example, in `@unnumbered The @cite{Book}', TeX
6328  % expanded @cite (which turns out to cause errors because \cite is meant
6329  % to be executed, not expanded).
6330  %
6331  % Anyway, we don't want the fully-expanded definition of @cite to appear
6332  % as a result of the \message, we just want `@cite' itself.  We use
6333  % \the<toks register> to achieve this: TeX expands \the<toks> only once,
6334  % simply yielding the contents of <toks register>.  (We also do this for
6335  % the toc entries.)
6336  \toks0 = {#1}%
6337  \message{(\the\toks0)}%
6338  %
6339  \chapmacro{#1}{Ynothing}{\the\unnumberedno}%
6340  %
6341  \global\let\section = \unnumberedsec
6342  \global\let\subsection = \unnumberedsubsec
6343  \global\let\subsubsection = \unnumberedsubsubsec
6344}
6345
6346% @centerchap is like @unnumbered, but the heading is centered.
6347\outer\parseargdef\centerchap{%
6348  \let\centerparametersmaybe = \centerparameters
6349  \unnmhead0{#1}%
6350  \let\centerparametersmaybe = \relax
6351}
6352
6353% @top is like @unnumbered.
6354\let\top\unnumbered
6355
6356% Sections.
6357%
6358\outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
6359\def\seczzz#1{%
6360  \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
6361  \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}%
6362}
6363
6364% normally calls appendixsectionzzz:
6365\outer\parseargdef\appendixsection{\apphead1{#1}}
6366\def\appendixsectionzzz#1{%
6367  \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
6368  \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}%
6369}
6370\let\appendixsec\appendixsection
6371
6372% normally calls unnumberedseczzz:
6373\outer\parseargdef\unnumberedsec{\unnmhead1{#1}}
6374\def\unnumberedseczzz#1{%
6375  \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
6376  \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%
6377}
6378
6379% Subsections.
6380%
6381% normally calls numberedsubseczzz:
6382\outer\parseargdef\numberedsubsec{\numhead2{#1}}
6383\def\numberedsubseczzz#1{%
6384  \global\subsubsecno=0  \global\advance\subsecno by 1
6385  \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}%
6386}
6387
6388% normally calls appendixsubseczzz:
6389\outer\parseargdef\appendixsubsec{\apphead2{#1}}
6390\def\appendixsubseczzz#1{%
6391  \global\subsubsecno=0  \global\advance\subsecno by 1
6392  \sectionheading{#1}{subsec}{Yappendix}%
6393                 {\appendixletter.\the\secno.\the\subsecno}%
6394}
6395
6396% normally calls unnumberedsubseczzz:
6397\outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}}
6398\def\unnumberedsubseczzz#1{%
6399  \global\subsubsecno=0  \global\advance\subsecno by 1
6400  \sectionheading{#1}{subsec}{Ynothing}%
6401                 {\the\unnumberedno.\the\secno.\the\subsecno}%
6402}
6403
6404% Subsubsections.
6405%
6406% normally numberedsubsubseczzz:
6407\outer\parseargdef\numberedsubsubsec{\numhead3{#1}}
6408\def\numberedsubsubseczzz#1{%
6409  \global\advance\subsubsecno by 1
6410  \sectionheading{#1}{subsubsec}{Ynumbered}%
6411                 {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}%
6412}
6413
6414% normally appendixsubsubseczzz:
6415\outer\parseargdef\appendixsubsubsec{\apphead3{#1}}
6416\def\appendixsubsubseczzz#1{%
6417  \global\advance\subsubsecno by 1
6418  \sectionheading{#1}{subsubsec}{Yappendix}%
6419                 {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}%
6420}
6421
6422% normally unnumberedsubsubseczzz:
6423\outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}}
6424\def\unnumberedsubsubseczzz#1{%
6425  \global\advance\subsubsecno by 1
6426  \sectionheading{#1}{subsubsec}{Ynothing}%
6427                 {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}%
6428}
6429
6430% These macros control what the section commands do, according
6431% to what kind of chapter we are in (ordinary, appendix, or unnumbered).
6432% Define them by default for a numbered chapter.
6433\let\section = \numberedsec
6434\let\subsection = \numberedsubsec
6435\let\subsubsection = \numberedsubsubsec
6436
6437% Define @majorheading, @heading and @subheading
6438
6439\def\majorheading{%
6440  {\advance\chapheadingskip by 10pt \chapbreak }%
6441  \parsearg\chapheadingzzz
6442}
6443
6444\def\chapheading{\chapbreak \parsearg\chapheadingzzz}
6445\def\chapheadingzzz#1{%
6446  \vbox{\chapfonts \raggedtitlesettings #1\par}%
6447  \nobreak\bigskip \nobreak
6448  \suppressfirstparagraphindent
6449}
6450
6451% @heading, @subheading, @subsubheading.
6452\parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{}
6453  \suppressfirstparagraphindent}
6454\parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{}
6455  \suppressfirstparagraphindent}
6456\parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{}
6457  \suppressfirstparagraphindent}
6458
6459% These macros generate a chapter, section, etc. heading only
6460% (including whitespace, linebreaking, etc. around it),
6461% given all the information in convenient, parsed form.
6462
6463% Args are the skip and penalty (usually negative)
6464\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
6465
6466% Parameter controlling skip before chapter headings (if needed)
6467\newskip\chapheadingskip
6468
6469% Define plain chapter starts, and page on/off switching for it.
6470\def\chapbreak{\dobreak \chapheadingskip {-4000}}
6471
6472% Start a new page
6473\def\chappager{\par\vfill\supereject}
6474
6475% \chapoddpage - start on an odd page for a new chapter
6476% Because \domark is called before \chapoddpage, the filler page will
6477% get the headings for the next chapter, which is wrong.  But we don't
6478% care -- we just disable all headings on the filler page.
6479\def\chapoddpage{%
6480  \chappager
6481  \ifodd\pageno \else
6482    \begingroup
6483      \headingsoff
6484      \null
6485      \chappager
6486    \endgroup
6487  \fi
6488}
6489
6490\parseargdef\setchapternewpage{\csname CHAPPAG#1\endcsname}
6491
6492\def\CHAPPAGoff{%
6493\global\let\contentsalignmacro = \chappager
6494\global\let\pchapsepmacro=\chapbreak
6495\global\let\pagealignmacro=\chappager}
6496
6497\def\CHAPPAGon{%
6498\global\let\contentsalignmacro = \chappager
6499\global\let\pchapsepmacro=\chappager
6500\global\let\pagealignmacro=\chappager
6501\global\def\HEADINGSon{\HEADINGSsingle}}
6502
6503\def\CHAPPAGodd{%
6504\global\let\contentsalignmacro = \chapoddpage
6505\global\let\pchapsepmacro=\chapoddpage
6506\global\let\pagealignmacro=\chapoddpage
6507\global\def\HEADINGSon{\HEADINGSdouble}}
6508
6509\CHAPPAGon
6510
6511% \chapmacro - Chapter opening.
6512%
6513% #1 is the text, #2 is the section type (Ynumbered, Ynothing,
6514% Yappendix, Yomitfromtoc), #3 the chapter number.
6515% Not used for @heading series.
6516%
6517% To test against our argument.
6518\def\Ynothingkeyword{Ynothing}
6519\def\Yappendixkeyword{Yappendix}
6520\def\Yomitfromtockeyword{Yomitfromtoc}
6521%
6522\def\chapmacro#1#2#3{%
6523  \expandafter\ifx\thisenv\titlepage\else
6524    \checkenv{}% chapters, etc., should not start inside an environment.
6525  \fi
6526  % FIXME: \chapmacro is currently called from inside \titlepage when
6527  % \setcontentsaftertitlepage to print the "Table of Contents" heading, but
6528  % this should probably be done by \sectionheading with an option to print
6529  % in chapter size.
6530  %
6531  % Insert the first mark before the heading break (see notes for \domark).
6532  \let\prevchapterdefs=\lastchapterdefs
6533  \let\prevsectiondefs=\lastsectiondefs
6534  \gdef\lastsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}%
6535                        \gdef\thissection{}}%
6536  %
6537  \def\temptype{#2}%
6538  \ifx\temptype\Ynothingkeyword
6539    \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
6540                          \gdef\thischapter{\thischaptername}}%
6541  \else\ifx\temptype\Yomitfromtockeyword
6542    \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
6543                          \gdef\thischapter{}}%
6544  \else\ifx\temptype\Yappendixkeyword
6545    \toks0={#1}%
6546    \xdef\lastchapterdefs{%
6547      \gdef\noexpand\thischaptername{\the\toks0}%
6548      \gdef\noexpand\thischapternum{\appendixletter}%
6549      % \noexpand\putwordAppendix avoids expanding indigestible
6550      % commands in some of the translations.
6551      \gdef\noexpand\thischapter{\noexpand\putwordAppendix{}
6552                                 \noexpand\thischapternum:
6553                                 \noexpand\thischaptername}%
6554    }%
6555  \else
6556    \toks0={#1}%
6557    \xdef\lastchapterdefs{%
6558      \gdef\noexpand\thischaptername{\the\toks0}%
6559      \gdef\noexpand\thischapternum{\the\chapno}%
6560      % \noexpand\putwordChapter avoids expanding indigestible
6561      % commands in some of the translations.
6562      \gdef\noexpand\thischapter{\noexpand\putwordChapter{}
6563                                 \noexpand\thischapternum:
6564                                 \noexpand\thischaptername}%
6565    }%
6566  \fi\fi\fi
6567  %
6568  % Output the mark.  Pass it through \safewhatsit, to take care of
6569  % the preceding space.
6570  \safewhatsit\domark
6571  %
6572  % Insert the chapter heading break.
6573  \pchapsepmacro
6574  %
6575  % Now the second mark, after the heading break.  No break points
6576  % between here and the heading.
6577  \let\prevchapterdefs=\lastchapterdefs
6578  \let\prevsectiondefs=\lastsectiondefs
6579  \domark
6580  %
6581  {%
6582    \chapfonts \rm
6583    \let\footnote=\errfootnoteheading % give better error message
6584    %
6585    % Have to define \lastsection before calling \donoderef, because the
6586    % xref code eventually uses it.  On the other hand, it has to be called
6587    % after \pchapsepmacro, or the headline will change too soon.
6588    \gdef\lastsection{#1}%
6589    %
6590    % Only insert the separating space if we have a chapter/appendix
6591    % number, and don't print the unnumbered ``number''.
6592    \ifx\temptype\Ynothingkeyword
6593      \setbox0 = \hbox{}%
6594      \def\toctype{unnchap}%
6595    \else\ifx\temptype\Yomitfromtockeyword
6596      \setbox0 = \hbox{}% contents like unnumbered, but no toc entry
6597      \def\toctype{omit}%
6598    \else\ifx\temptype\Yappendixkeyword
6599      \setbox0 = \hbox{\putwordAppendix{} #3\enspace}%
6600      \def\toctype{app}%
6601    \else
6602      \setbox0 = \hbox{#3\enspace}%
6603      \def\toctype{numchap}%
6604    \fi\fi\fi
6605    %
6606    % Write the toc entry for this chapter.  Must come before the
6607    % \donoderef, because we include the current node name in the toc
6608    % entry, and \donoderef resets it to empty.
6609    \writetocentry{\toctype}{#1}{#3}%
6610    %
6611    % For pdftex, we have to write out the node definition (aka, make
6612    % the pdfdest) after any page break, but before the actual text has
6613    % been typeset.  If the destination for the pdf outline is after the
6614    % text, then jumping from the outline may wind up with the text not
6615    % being visible, for instance under high magnification.
6616    \donoderef{#2}%
6617    %
6618    % Typeset the actual heading.
6619    \nobreak % Avoid page breaks at the interline glue.
6620    \vbox{\raggedtitlesettings \hangindent=\wd0 \centerparametersmaybe
6621          \unhbox0 #1\par}%
6622  }%
6623  \nobreak\bigskip % no page break after a chapter title
6624  \nobreak
6625}
6626
6627% @centerchap -- centered and unnumbered.
6628\let\centerparametersmaybe = \relax
6629\def\centerparameters{%
6630  \advance\rightskip by 3\rightskip
6631  \leftskip = \rightskip
6632  \parfillskip = 0pt
6633}
6634
6635
6636% Section titles.  These macros combine the section number parts and
6637% call the generic \sectionheading to do the printing.
6638%
6639\newskip\secheadingskip
6640\def\secheadingbreak{\dobreak \secheadingskip{-1000}}
6641
6642% Subsection titles.
6643\newskip\subsecheadingskip
6644\def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}}
6645
6646% Subsubsection titles.
6647\def\subsubsecheadingskip{\subsecheadingskip}
6648\def\subsubsecheadingbreak{\subsecheadingbreak}
6649
6650
6651% Print any size, any type, section title.
6652%
6653% #1 is the text of the title,
6654% #2 is the section level (sec/subsec/subsubsec),
6655% #3 is the section type (Ynumbered, Ynothing, Yappendix, Yomitfromtoc),
6656% #4 is the section number.
6657%
6658\def\seckeyword{sec}
6659%
6660\def\sectionheading#1#2#3#4{%
6661  {%
6662    \def\sectionlevel{#2}%
6663    \def\temptype{#3}%
6664    %
6665    % It is ok for the @heading series commands to appear inside an
6666    % environment (it's been historically allowed, though the logic is
6667    % dubious), but not the others.
6668    \ifx\temptype\Yomitfromtockeyword\else
6669      \checkenv{}% non-@*heading should not be in an environment.
6670    \fi
6671    \let\footnote=\errfootnoteheading
6672    %
6673    % Switch to the right set of fonts.
6674    \csname #2fonts\endcsname \rm
6675    %
6676    % Insert first mark before the heading break (see notes for \domark).
6677    \let\prevsectiondefs=\lastsectiondefs
6678    \ifx\temptype\Ynothingkeyword
6679      \ifx\sectionlevel\seckeyword
6680        \gdef\lastsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}%
6681                              \gdef\thissection{\thissectionname}}%
6682      \fi
6683    \else\ifx\temptype\Yomitfromtockeyword
6684      % Don't redefine \thissection.
6685    \else\ifx\temptype\Yappendixkeyword
6686      \ifx\sectionlevel\seckeyword
6687        \toks0={#1}%
6688        \xdef\lastsectiondefs{%
6689          \gdef\noexpand\thissectionname{\the\toks0}%
6690          \gdef\noexpand\thissectionnum{#4}%
6691          % \noexpand\putwordSection avoids expanding indigestible
6692          % commands in some of the translations.
6693          \gdef\noexpand\thissection{\noexpand\putwordSection{}
6694                                     \noexpand\thissectionnum:
6695                                     \noexpand\thissectionname}%
6696        }%
6697      \fi
6698    \else
6699      \ifx\sectionlevel\seckeyword
6700        \toks0={#1}%
6701        \xdef\lastsectiondefs{%
6702          \gdef\noexpand\thissectionname{\the\toks0}%
6703          \gdef\noexpand\thissectionnum{#4}%
6704          % \noexpand\putwordSection avoids expanding indigestible
6705          % commands in some of the translations.
6706          \gdef\noexpand\thissection{\noexpand\putwordSection{}
6707                                     \noexpand\thissectionnum:
6708                                     \noexpand\thissectionname}%
6709        }%
6710      \fi
6711    \fi\fi\fi
6712    %
6713    % Go into vertical mode.  Usually we'll already be there, but we
6714    % don't want the following whatsit to end up in a preceding paragraph
6715    % if the document didn't happen to have a blank line.
6716    \par
6717    %
6718    % Output the mark.  Pass it through \safewhatsit, to take care of
6719    % the preceding space.
6720    \safewhatsit\domark
6721    %
6722    % Insert space above the heading.
6723    \csname #2headingbreak\endcsname
6724    %
6725    % Now the second mark, after the heading break.  No break points
6726    % between here and the heading.
6727    \global\let\prevsectiondefs=\lastsectiondefs
6728    \domark
6729    %
6730    % Only insert the space after the number if we have a section number.
6731    \ifx\temptype\Ynothingkeyword
6732      \setbox0 = \hbox{}%
6733      \def\toctype{unn}%
6734      \gdef\lastsection{#1}%
6735    \else\ifx\temptype\Yomitfromtockeyword
6736      % for @headings -- no section number, don't include in toc,
6737      % and don't redefine \lastsection.
6738      \setbox0 = \hbox{}%
6739      \def\toctype{omit}%
6740      \let\sectionlevel=\empty
6741    \else\ifx\temptype\Yappendixkeyword
6742      \setbox0 = \hbox{#4\enspace}%
6743      \def\toctype{app}%
6744      \gdef\lastsection{#1}%
6745    \else
6746      \setbox0 = \hbox{#4\enspace}%
6747      \def\toctype{num}%
6748      \gdef\lastsection{#1}%
6749    \fi\fi\fi
6750    %
6751    % Write the toc entry (before \donoderef).  See comments in \chapmacro.
6752    \writetocentry{\toctype\sectionlevel}{#1}{#4}%
6753    %
6754    % Write the node reference (= pdf destination for pdftex).
6755    % Again, see comments in \chapmacro.
6756    \donoderef{#3}%
6757    %
6758    % Interline glue will be inserted when the vbox is completed.
6759    % That glue will be a valid breakpoint for the page, since it'll be
6760    % preceded by a whatsit (usually from the \donoderef, or from the
6761    % \writetocentry if there was no node).  We don't want to allow that
6762    % break, since then the whatsits could end up on page n while the
6763    % section is on page n+1, thus toc/etc. are wrong.  Debian bug 276000.
6764    \nobreak
6765    %
6766    % Output the actual section heading.
6767    \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright
6768          \hangindent=\wd0  % zero if no section number
6769          \unhbox0 #1}%
6770  }%
6771  % Add extra space after the heading -- half of whatever came above it.
6772  % Don't allow stretch, though.
6773  \kern .5 \csname #2headingskip\endcsname
6774  %
6775  % Do not let the kern be a potential breakpoint, as it would be if it
6776  % was followed by glue.
6777  \nobreak
6778  %
6779  % We'll almost certainly start a paragraph next, so don't let that
6780  % glue accumulate.  (Not a breakpoint because it's preceded by a
6781  % discardable item.)  However, when a paragraph is not started next
6782  % (\startdefun, \cartouche, \center, etc.), this needs to be wiped out
6783  % or the negative glue will cause weirdly wrong output, typically
6784  % obscuring the section heading with something else.
6785  \vskip-\parskip
6786  %
6787  % This is so the last item on the main vertical list is a known
6788  % \penalty > 10000, so \startdefun, etc., can recognize the situation
6789  % and do the needful.
6790  \penalty 10001
6791}
6792
6793
6794\message{toc,}
6795% Table of contents.
6796\newwrite\tocfile
6797
6798% Write an entry to the toc file, opening it if necessary.
6799% Called from @chapter, etc.
6800%
6801% Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno}
6802% We append the current node name (if any) and page number as additional
6803% arguments for the \{chap,sec,...}entry macros which will eventually
6804% read this.  The node name is used in the pdf outlines as the
6805% destination to jump to.
6806%
6807% We open the .toc file for writing here instead of at @setfilename (or
6808% any other fixed time) so that @contents can be anywhere in the document.
6809% But if #1 is `omit', then we don't do anything.  This is used for the
6810% table of contents chapter openings themselves.
6811%
6812\newif\iftocfileopened
6813\def\omitkeyword{omit}%
6814%
6815\def\writetocentry#1#2#3{%
6816  \edef\writetoctype{#1}%
6817  \ifx\writetoctype\omitkeyword \else
6818    \iftocfileopened\else
6819      \immediate\openout\tocfile = \jobname.toc
6820      \global\tocfileopenedtrue
6821    \fi
6822    %
6823    \iflinks
6824      {\atdummies
6825       \edef\temp{%
6826         \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}%
6827       \temp
6828      }%
6829    \fi
6830  \fi
6831  %
6832  % Tell \shipout to create a pdf destination on each page, if we're
6833  % writing pdf.  These are used in the table of contents.  We can't
6834  % just write one on every page because the title pages are numbered
6835  % 1 and 2 (the page numbers aren't printed), and so are the first
6836  % two pages of the document.  Thus, we'd have two destinations named
6837  % `1', and two named `2'.
6838  \ifpdf
6839    \global\pdfmakepagedesttrue
6840  \else
6841    \ifx\XeTeXrevision\thisisundefined
6842    \else
6843      \global\pdfmakepagedesttrue
6844    \fi
6845  \fi
6846}
6847
6848
6849% These characters do not print properly in the Computer Modern roman
6850% fonts, so we must take special care.  This is more or less redundant
6851% with the Texinfo input format setup at the end of this file.
6852%
6853\def\activecatcodes{%
6854  \catcode`\"=\active
6855  \catcode`\$=\active
6856  \catcode`\<=\active
6857  \catcode`\>=\active
6858  \catcode`\\=\active
6859  \catcode`\^=\active
6860  \catcode`\_=\active
6861  \catcode`\|=\active
6862  \catcode`\~=\active
6863}
6864
6865
6866% Read the toc file, which is essentially Texinfo input.
6867\def\readtocfile{%
6868  \setupdatafile
6869  \activecatcodes
6870  \input \tocreadfilename
6871}
6872
6873\newskip\contentsrightmargin \contentsrightmargin=1in
6874\newcount\savepageno
6875\newcount\lastnegativepageno \lastnegativepageno = -1
6876
6877% Prepare to read what we've written to \tocfile.
6878%
6879\def\startcontents#1{%
6880  % If @setchapternewpage on, and @headings double, the contents should
6881  % start on an odd page, unlike chapters.  Thus, we maintain
6882  % \contentsalignmacro in parallel with \pagealignmacro.
6883  % From: Torbjorn Granlund <tege@matematik.su.se>
6884  \contentsalignmacro
6885  \immediate\closeout\tocfile
6886  %
6887  % Don't need to put `Contents' or `Short Contents' in the headline.
6888  % It is abundantly clear what they are.
6889  \chapmacro{#1}{Yomitfromtoc}{}%
6890  %
6891  \savepageno = \pageno
6892  \begingroup                  % Set up to handle contents files properly.
6893    \raggedbottom              % Worry more about breakpoints than the bottom.
6894    \entryrightmargin=\contentsrightmargin % Don't use the full line length.
6895    %
6896    % Roman numerals for page numbers.
6897    \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
6898}
6899
6900% redefined for the two-volume lispref.  We always output on
6901% \jobname.toc even if this is redefined.
6902%
6903\def\tocreadfilename{\jobname.toc}
6904
6905% Normal (long) toc.
6906%
6907\def\contents{%
6908  \startcontents{\putwordTOC}%
6909    \openin 1 \tocreadfilename\space
6910    \ifeof 1 \else
6911      \readtocfile
6912    \fi
6913    \vfill \eject
6914    \contentsalignmacro % in case @setchapternewpage odd is in effect
6915    \ifeof 1 \else
6916      \pdfmakeoutlines
6917    \fi
6918    \closein 1
6919  \endgroup
6920  \lastnegativepageno = \pageno
6921  \global\pageno = \savepageno
6922}
6923
6924% And just the chapters.
6925\def\summarycontents{%
6926  \startcontents{\putwordShortTOC}%
6927    %
6928    \let\partentry = \shortpartentry
6929    \let\numchapentry = \shortchapentry
6930    \let\appentry = \shortchapentry
6931    \let\unnchapentry = \shortunnchapentry
6932    % We want a true roman here for the page numbers.
6933    \secfonts
6934    \let\rm=\shortcontrm \let\bf=\shortcontbf
6935    \let\sl=\shortcontsl \let\tt=\shortconttt
6936    \rm
6937    \hyphenpenalty = 10000
6938    \advance\baselineskip by 1pt % Open it up a little.
6939    \def\numsecentry##1##2##3##4{}
6940    \let\appsecentry = \numsecentry
6941    \let\unnsecentry = \numsecentry
6942    \let\numsubsecentry = \numsecentry
6943    \let\appsubsecentry = \numsecentry
6944    \let\unnsubsecentry = \numsecentry
6945    \let\numsubsubsecentry = \numsecentry
6946    \let\appsubsubsecentry = \numsecentry
6947    \let\unnsubsubsecentry = \numsecentry
6948    \openin 1 \tocreadfilename\space
6949    \ifeof 1 \else
6950      \readtocfile
6951    \fi
6952    \closein 1
6953    \vfill \eject
6954    \contentsalignmacro % in case @setchapternewpage odd is in effect
6955  \endgroup
6956  \lastnegativepageno = \pageno
6957  \global\pageno = \savepageno
6958}
6959\let\shortcontents = \summarycontents
6960
6961% Typeset the label for a chapter or appendix for the short contents.
6962% The arg is, e.g., `A' for an appendix, or `3' for a chapter.
6963%
6964\def\shortchaplabel#1{%
6965  % This space should be enough, since a single number is .5em, and the
6966  % widest letter (M) is 1em, at least in the Computer Modern fonts.
6967  % But use \hss just in case.
6968  % (This space doesn't include the extra space that gets added after
6969  % the label; that gets put in by \shortchapentry above.)
6970  %
6971  % We'd like to right-justify chapter numbers, but that looks strange
6972  % with appendix letters.  And right-justifying numbers and
6973  % left-justifying letters looks strange when there is less than 10
6974  % chapters.  Have to read the whole toc once to know how many chapters
6975  % there are before deciding ...
6976  \hbox to 1em{#1\hss}%
6977}
6978
6979% These macros generate individual entries in the table of contents.
6980% The first argument is the chapter or section name.
6981% The last argument is the page number.
6982% The arguments in between are the chapter number, section number, ...
6983
6984% Parts, in the main contents.  Replace the part number, which doesn't
6985% exist, with an empty box.  Let's hope all the numbers have the same width.
6986% Also ignore the page number, which is conventionally not printed.
6987\def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}}
6988\def\partentry#1#2#3#4{%
6989  % Add stretch and a bonus for breaking the page before the part heading.
6990  % This reduces the chance of the page being broken immediately after the
6991  % part heading, before a following chapter heading.
6992  \vskip 0pt plus 5\baselineskip
6993  \penalty-300
6994  \vskip 0pt plus -5\baselineskip
6995  \dochapentry{\numeralbox\labelspace#1}{}%
6996}
6997%
6998% Parts, in the short toc.
6999\def\shortpartentry#1#2#3#4{%
7000  \penalty-300
7001  \vskip.5\baselineskip plus.15\baselineskip minus.1\baselineskip
7002  \shortchapentry{{\bf #1}}{\numeralbox}{}{}%
7003}
7004
7005% Chapters, in the main contents.
7006\def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}}
7007
7008% Chapters, in the short toc.
7009% See comments in \dochapentry re vbox and related settings.
7010\def\shortchapentry#1#2#3#4{%
7011  \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}%
7012}
7013
7014% Appendices, in the main contents.
7015% Need the word Appendix, and a fixed-size box.
7016%
7017\def\appendixbox#1{%
7018  % We use M since it's probably the widest letter.
7019  \setbox0 = \hbox{\putwordAppendix{} M}%
7020  \hbox to \wd0{\putwordAppendix{} #1\hss}}
7021%
7022\def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\hskip.7em#1}{#4}}
7023
7024% Unnumbered chapters.
7025\def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}}
7026\def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}}
7027
7028% Sections.
7029\def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}}
7030\let\appsecentry=\numsecentry
7031\def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}}
7032
7033% Subsections.
7034\def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}}
7035\let\appsubsecentry=\numsubsecentry
7036\def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}}
7037
7038% And subsubsections.
7039\def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}}
7040\let\appsubsubsecentry=\numsubsubsecentry
7041\def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}}
7042
7043% This parameter controls the indentation of the various levels.
7044% Same as \defaultparindent.
7045\newdimen\tocindent \tocindent = 15pt
7046
7047% Now for the actual typesetting. In all these, #1 is the text and #2 is the
7048% page number.
7049%
7050% If the toc has to be broken over pages, we want it to be at chapters
7051% if at all possible; hence the \penalty.
7052\def\dochapentry#1#2{%
7053   \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
7054   \begingroup
7055     % Move the page numbers slightly to the right
7056     \advance\entryrightmargin by -0.05em
7057     \chapentryfonts
7058     \tocentry{#1}{\dopageno\bgroup#2\egroup}%
7059   \endgroup
7060   \nobreak\vskip .25\baselineskip plus.1\baselineskip
7061}
7062
7063\def\dosecentry#1#2{\begingroup
7064  \secentryfonts \leftskip=\tocindent
7065  \tocentry{#1}{\dopageno\bgroup#2\egroup}%
7066\endgroup}
7067
7068\def\dosubsecentry#1#2{\begingroup
7069  \subsecentryfonts \leftskip=2\tocindent
7070  \tocentry{#1}{\dopageno\bgroup#2\egroup}%
7071\endgroup}
7072
7073\def\dosubsubsecentry#1#2{\begingroup
7074  \subsubsecentryfonts \leftskip=3\tocindent
7075  \tocentry{#1}{\dopageno\bgroup#2\egroup}%
7076\endgroup}
7077
7078% We use the same \entry macro as for the index entries.
7079\let\tocentry = \entry
7080
7081% Space between chapter (or whatever) number and the title.
7082\def\labelspace{\hskip1em \relax}
7083
7084\def\dopageno#1{{\rm #1}}
7085\def\doshortpageno#1{{\rm #1}}
7086
7087\def\chapentryfonts{\secfonts \rm}
7088\def\secentryfonts{\textfonts}
7089\def\subsecentryfonts{\textfonts}
7090\def\subsubsecentryfonts{\textfonts}
7091
7092
7093\message{environments,}
7094% @foo ... @end foo.
7095
7096% @tex ... @end tex    escapes into raw TeX temporarily.
7097% One exception: @ is still an escape character, so that @end tex works.
7098% But \@ or @@ will get a plain @ character.
7099
7100\envdef\tex{%
7101  \setupmarkupstyle{tex}%
7102  \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
7103  \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
7104  \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
7105  \catcode `\%=14
7106  \catcode `\+=\other
7107  \catcode `\"=\other
7108  \catcode `\|=\other
7109  \catcode `\<=\other
7110  \catcode `\>=\other
7111  \catcode `\`=\other
7112  \catcode `\'=\other
7113  %
7114  % ' is active in math mode (mathcode"8000).  So reset it, and all our
7115  % other math active characters (just in case), to plain's definitions.
7116  \mathactive
7117  %
7118  % Inverse of the list at the beginning of the file.
7119  \let\b=\ptexb
7120  \let\bullet=\ptexbullet
7121  \let\c=\ptexc
7122  \let\,=\ptexcomma
7123  \let\.=\ptexdot
7124  \let\dots=\ptexdots
7125  \let\equiv=\ptexequiv
7126  \let\!=\ptexexclam
7127  \let\i=\ptexi
7128  \let\indent=\ptexindent
7129  \let\noindent=\ptexnoindent
7130  \let\{=\ptexlbrace
7131  \let\+=\tabalign
7132  \let\}=\ptexrbrace
7133  \let\/=\ptexslash
7134  \let\sp=\ptexsp
7135  \let\*=\ptexstar
7136  %\let\sup=\ptexsup % do not redefine, we want @sup to work in math mode
7137  \let\t=\ptext
7138  \expandafter \let\csname top\endcsname=\ptextop  % we've made it outer
7139  \let\frenchspacing=\plainfrenchspacing
7140  %
7141  \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
7142  \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
7143  \def\@{@}%
7144}
7145% There is no need to define \Etex.
7146
7147% Define @lisp ... @end lisp.
7148% @lisp environment forms a group so it can rebind things,
7149% including the definition of @end lisp (which normally is erroneous).
7150
7151% Amount to narrow the margins by for @lisp.
7152\newskip\lispnarrowing \lispnarrowing=0.4in
7153
7154% This is the definition that ^^M gets inside @lisp, @example, and other
7155% such environments.  \null is better than a space, since it doesn't
7156% have any width.
7157\def\lisppar{\null\endgraf}
7158
7159% This space is always present above and below environments.
7160\newskip\envskipamount \envskipamount = 0pt
7161
7162% Make spacing and below environment symmetrical.  We use \parskip here
7163% to help in doing that, since in @example-like environments \parskip
7164% is reset to zero; thus the \afterenvbreak inserts no space -- but the
7165% start of the next paragraph will insert \parskip.
7166%
7167\def\aboveenvbreak{{%
7168  % =10000 instead of <10000 because of a special case in \itemzzz and
7169  % \sectionheading, q.v.
7170  \ifnum \lastpenalty=10000 \else
7171    \advance\envskipamount by \parskip
7172    \endgraf
7173    \ifdim\lastskip<\envskipamount
7174      \removelastskip
7175      \ifnum\lastpenalty<10000
7176        % Penalize breaking before the environment, because preceding text
7177        % often leads into it.
7178        \penalty100
7179      \fi
7180      \vskip\envskipamount
7181    \fi
7182  \fi
7183}}
7184
7185\def\afterenvbreak{{%
7186  % =10000 instead of <10000 because of a special case in \itemzzz and
7187  % \sectionheading, q.v.
7188  \ifnum \lastpenalty=10000 \else
7189    \advance\envskipamount by \parskip
7190    \endgraf
7191    \ifdim\lastskip<\envskipamount
7192      \removelastskip
7193      % it's not a good place to break if the last penalty was \nobreak
7194      % or better ...
7195      \ifnum\lastpenalty<10000 \penalty-50 \fi
7196      \vskip\envskipamount
7197    \fi
7198  \fi
7199}}
7200
7201% \nonarrowing is a flag.  If "set", @lisp etc don't narrow margins; it will
7202% also clear it, so that its embedded environments do the narrowing again.
7203\let\nonarrowing=\relax
7204
7205% @cartouche ... @end cartouche: draw rectangle w/rounded corners around
7206% environment contents.
7207\font\circle=lcircle10
7208\newdimen\circthick
7209\newdimen\cartouter\newdimen\cartinner
7210\newskip\normbskip\newskip\normpskip\newskip\normlskip
7211\circthick=\fontdimen8\circle
7212%
7213\def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
7214\def\ctr{{\hskip 6pt\circle\char'010}}
7215\def\cbl{{\circle\char'012\hskip -6pt}}
7216\def\cbr{{\hskip 6pt\circle\char'011}}
7217\def\carttop{\hbox to \cartouter{\hskip\lskip
7218        \ctl\leaders\hrule height\circthick\hfil\ctr
7219        \hskip\rskip}}
7220\def\cartbot{\hbox to \cartouter{\hskip\lskip
7221        \cbl\leaders\hrule height\circthick\hfil\cbr
7222        \hskip\rskip}}
7223%
7224\newskip\lskip\newskip\rskip
7225
7226\envdef\cartouche{%
7227  \ifhmode\par\fi  % can't be in the midst of a paragraph.
7228  \startsavinginserts
7229  \lskip=\leftskip \rskip=\rightskip
7230  \leftskip=0pt\rightskip=0pt % we want these *outside*.
7231  \cartinner=\hsize \advance\cartinner by-\lskip
7232  \advance\cartinner by-\rskip
7233  \cartouter=\hsize
7234  \advance\cartouter by 18.4pt	% allow for 3pt kerns on either
7235				% side, and for 6pt waste from
7236				% each corner char, and rule thickness
7237  \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
7238  %
7239  % If this cartouche directly follows a sectioning command, we need the
7240  % \parskip glue (backspaced over by default) or the cartouche can
7241  % collide with the section heading.
7242  \ifnum\lastpenalty>10000 \vskip\parskip \penalty\lastpenalty \fi
7243  %
7244  \setbox\groupbox=\vbox\bgroup
7245      \baselineskip=0pt\parskip=0pt\lineskip=0pt
7246      \carttop
7247      \hbox\bgroup
7248	  \hskip\lskip
7249	  \vrule\kern3pt
7250	  \vbox\bgroup
7251	      \kern3pt
7252	      \hsize=\cartinner
7253	      \baselineskip=\normbskip
7254	      \lineskip=\normlskip
7255	      \parskip=\normpskip
7256	      \vskip -\parskip
7257	      \comment % For explanation, see the end of def\group.
7258}
7259\def\Ecartouche{%
7260              \ifhmode\par\fi
7261	      \kern3pt
7262	  \egroup
7263	  \kern3pt\vrule
7264	  \hskip\rskip
7265      \egroup
7266      \cartbot
7267  \egroup
7268  \addgroupbox
7269  \checkinserts
7270}
7271
7272
7273% This macro is called at the beginning of all the @example variants,
7274% inside a group.
7275\newdimen\nonfillparindent
7276\def\nonfillstart{%
7277  \aboveenvbreak
7278  \ifdim\hfuzz < 12pt \hfuzz = 12pt \fi % Don't be fussy
7279  \sepspaces % Make spaces be word-separators rather than space tokens.
7280  \let\par = \lisppar % don't ignore blank lines
7281  \obeylines % each line of input is a line of output
7282  \parskip = 0pt
7283  % Turn off paragraph indentation but redefine \indent to emulate
7284  % the normal \indent.
7285  \nonfillparindent=\parindent
7286  \parindent = 0pt
7287  \let\indent\nonfillindent
7288  %
7289  \emergencystretch = 0pt % don't try to avoid overfull boxes
7290  \ifx\nonarrowing\relax
7291    \advance \leftskip by \lispnarrowing
7292    \exdentamount=\lispnarrowing
7293  \else
7294    \let\nonarrowing = \relax
7295  \fi
7296  \let\exdent=\nofillexdent
7297}
7298
7299\begingroup
7300\obeyspaces
7301% We want to swallow spaces (but not other tokens) after the fake
7302% @indent in our nonfill-environments, where spaces are normally
7303% active and set to @tie, resulting in them not being ignored after
7304% @indent.
7305\gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}%
7306\gdef\nonfillindentcheck{%
7307\ifx\temp %
7308\expandafter\nonfillindentgobble%
7309\else%
7310\leavevmode\nonfillindentbox%
7311\fi%
7312}%
7313\endgroup
7314\def\nonfillindentgobble#1{\nonfillindent}
7315\def\nonfillindentbox{\hbox to \nonfillparindent{\hss}}
7316
7317% If you want all examples etc. small: @set dispenvsize small.
7318% If you want even small examples the full size: @set dispenvsize nosmall.
7319% This affects the following displayed environments:
7320%    @example, @display, @format, @lisp
7321%
7322\def\smallword{small}
7323\def\nosmallword{nosmall}
7324\let\SETdispenvsize\relax
7325\def\setnormaldispenv{%
7326  \ifx\SETdispenvsize\smallword
7327    % end paragraph for sake of leading, in case document has no blank
7328    % line.  This is redundant with what happens in \aboveenvbreak, but
7329    % we need to do it before changing the fonts, and it's inconvenient
7330    % to change the fonts afterward.
7331    \ifnum \lastpenalty=10000 \else \endgraf \fi
7332    \smallexamplefonts \rm
7333  \fi
7334}
7335\def\setsmalldispenv{%
7336  \ifx\SETdispenvsize\nosmallword
7337  \else
7338    \ifnum \lastpenalty=10000 \else \endgraf \fi
7339    \smallexamplefonts \rm
7340  \fi
7341}
7342
7343% We often define two environments, @foo and @smallfoo.
7344% Let's do it in one command.  #1 is the env name, #2 the definition.
7345\def\makedispenvdef#1#2{%
7346  \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}%
7347  \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}%
7348  \expandafter\let\csname E#1\endcsname \afterenvbreak
7349  \expandafter\let\csname Esmall#1\endcsname \afterenvbreak
7350}
7351
7352% Define two environment synonyms (#1 and #2) for an environment.
7353\def\maketwodispenvdef#1#2#3{%
7354  \makedispenvdef{#1}{#3}%
7355  \makedispenvdef{#2}{#3}%
7356}
7357%
7358% @lisp: indented, narrowed, typewriter font;
7359% @example: same as @lisp.
7360%
7361% @smallexample and @smalllisp: use smaller fonts.
7362% Originally contributed by Pavel@xerox.
7363%
7364\maketwodispenvdef{lisp}{example}{%
7365  \nonfillstart
7366  \tt\setupmarkupstyle{example}%
7367  \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
7368  \gobble % eat return
7369}
7370% @display/@smalldisplay: same as @lisp except keep current font.
7371%
7372\makedispenvdef{display}{%
7373  \nonfillstart
7374  \gobble
7375}
7376
7377% @format/@smallformat: same as @display except don't narrow margins.
7378%
7379\makedispenvdef{format}{%
7380  \let\nonarrowing = t%
7381  \nonfillstart
7382  \gobble
7383}
7384
7385% @flushleft: same as @format, but doesn't obey \SETdispenvsize.
7386\envdef\flushleft{%
7387  \let\nonarrowing = t%
7388  \nonfillstart
7389  \gobble
7390}
7391\let\Eflushleft = \afterenvbreak
7392
7393% @flushright.
7394%
7395\envdef\flushright{%
7396  \let\nonarrowing = t%
7397  \nonfillstart
7398  \advance\leftskip by 0pt plus 1fill\relax
7399  \gobble
7400}
7401\let\Eflushright = \afterenvbreak
7402
7403
7404% @raggedright does more-or-less normal line breaking but no right
7405% justification.  From plain.tex.  Don't stretch around special
7406% characters in urls in this environment, since the stretch at the right
7407% should be enough.
7408\envdef\raggedright{%
7409  \rightskip0pt plus2.4em \spaceskip.3333em \xspaceskip.5em\relax
7410  \def\urefprestretchamount{0pt}%
7411  \def\urefpoststretchamount{0pt}%
7412}
7413\let\Eraggedright\par
7414
7415\envdef\raggedleft{%
7416  \parindent=0pt \leftskip0pt plus2em
7417  \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
7418  \hbadness=10000 % Last line will usually be underfull, so turn off
7419                  % badness reporting.
7420}
7421\let\Eraggedleft\par
7422
7423\envdef\raggedcenter{%
7424  \parindent=0pt \rightskip0pt plus1em \leftskip0pt plus1em
7425  \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
7426  \hbadness=10000 % Last line will usually be underfull, so turn off
7427                  % badness reporting.
7428}
7429\let\Eraggedcenter\par
7430
7431
7432% @quotation does normal linebreaking (hence we can't use \nonfillstart)
7433% and narrows the margins.  We keep \parskip nonzero in general, since
7434% we're doing normal filling.  So, when using \aboveenvbreak and
7435% \afterenvbreak, temporarily make \parskip 0.
7436%
7437\makedispenvdef{quotation}{\quotationstart}
7438%
7439\def\quotationstart{%
7440  \indentedblockstart % same as \indentedblock, but increase right margin too.
7441  \ifx\nonarrowing\relax
7442    \advance\rightskip by \lispnarrowing
7443  \fi
7444  \parsearg\quotationlabel
7445}
7446
7447% We have retained a nonzero parskip for the environment, since we're
7448% doing normal filling.
7449%
7450\def\Equotation{%
7451  \par
7452  \ifx\quotationauthor\thisisundefined\else
7453    % indent a bit.
7454    \leftline{\kern 2\leftskip \sl ---\quotationauthor}%
7455  \fi
7456  {\parskip=0pt \afterenvbreak}%
7457}
7458\def\Esmallquotation{\Equotation}
7459
7460% If we're given an argument, typeset it in bold with a colon after.
7461\def\quotationlabel#1{%
7462  \def\temp{#1}%
7463  \ifx\temp\empty \else
7464    {\bf #1: }%
7465  \fi
7466}
7467
7468% @indentedblock is like @quotation, but indents only on the left and
7469% has no optional argument.
7470%
7471\makedispenvdef{indentedblock}{\indentedblockstart}
7472%
7473\def\indentedblockstart{%
7474  {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
7475  \parindent=0pt
7476  %
7477  % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
7478  \ifx\nonarrowing\relax
7479    \advance\leftskip by \lispnarrowing
7480    \exdentamount = \lispnarrowing
7481  \else
7482    \let\nonarrowing = \relax
7483  \fi
7484}
7485
7486% Keep a nonzero parskip for the environment, since we're doing normal filling.
7487%
7488\def\Eindentedblock{%
7489  \par
7490  {\parskip=0pt \afterenvbreak}%
7491}
7492\def\Esmallindentedblock{\Eindentedblock}
7493
7494
7495% LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>}
7496% If we want to allow any <char> as delimiter,
7497% we need the curly braces so that makeinfo sees the @verb command, eg:
7498% `@verbx...x' would look like the '@verbx' command.  --janneke@gnu.org
7499%
7500% [Knuth]: Donald Ervin Knuth, 1996.  The TeXbook.
7501%
7502% [Knuth] p.344; only we need to do the other characters Texinfo sets
7503% active too.  Otherwise, they get lost as the first character on a
7504% verbatim line.
7505\def\dospecials{%
7506  \do\ \do\\\do\{\do\}\do\$\do\&%
7507  \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~%
7508  \do\<\do\>\do\|\do\@\do+\do\"%
7509  % Don't do the quotes -- if we do, @set txicodequoteundirected and
7510  % @set txicodequotebacktick will not have effect on @verb and
7511  % @verbatim, and ?` and !` ligatures won't get disabled.
7512  %\do\`\do\'%
7513}
7514%
7515% [Knuth] p. 380
7516\def\uncatcodespecials{%
7517  \def\do##1{\catcode`##1=\other}\dospecials}
7518%
7519% Setup for the @verb command.
7520%
7521% Eight spaces for a tab
7522\begingroup
7523  \catcode`\^^I=\active
7524  \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }}
7525\endgroup
7526%
7527\def\setupverb{%
7528  \tt  % easiest (and conventionally used) font for verbatim
7529  \def\par{\leavevmode\endgraf}%
7530  \setupmarkupstyle{verb}%
7531  \tabeightspaces
7532  % Respect line breaks,
7533  % print special symbols as themselves, and
7534  % make each space count
7535  % must do in this order:
7536  \obeylines \uncatcodespecials \sepspaces
7537}
7538
7539% Setup for the @verbatim environment
7540%
7541% Real tab expansion.
7542\newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
7543%
7544% We typeset each line of the verbatim in an \hbox, so we can handle
7545% tabs.  The \global is in case the verbatim line starts with an accent,
7546% or some other command that starts with a begin-group.  Otherwise, the
7547% entire \verbbox would disappear at the corresponding end-group, before
7548% it is typeset.  Meanwhile, we can't have nested verbatim commands
7549% (can we?), so the \global won't be overwriting itself.
7550\newbox\verbbox
7551\def\starttabbox{\global\setbox\verbbox=\hbox\bgroup}
7552%
7553\begingroup
7554  \catcode`\^^I=\active
7555  \gdef\tabexpand{%
7556    \catcode`\^^I=\active
7557    \def^^I{\leavevmode\egroup
7558      \dimen\verbbox=\wd\verbbox % the width so far, or since the previous tab
7559      \divide\dimen\verbbox by\tabw
7560      \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw
7561      \advance\dimen\verbbox by\tabw  % advance to next multiple of \tabw
7562      \wd\verbbox=\dimen\verbbox \box\verbbox \starttabbox
7563    }%
7564  }
7565\endgroup
7566
7567% start the verbatim environment.
7568\def\setupverbatim{%
7569  \let\nonarrowing = t%
7570  \nonfillstart
7571  \tt % easiest (and conventionally used) font for verbatim
7572  % The \leavevmode here is for blank lines.  Otherwise, we would
7573  % never \starttabox and the \egroup would end verbatim mode.
7574  \def\par{\leavevmode\egroup\box\verbbox\endgraf}%
7575  \tabexpand
7576  \setupmarkupstyle{verbatim}%
7577  % Respect line breaks,
7578  % print special symbols as themselves, and
7579  % make each space count.
7580  % Must do in this order:
7581  \obeylines \uncatcodespecials \sepspaces
7582  \everypar{\starttabbox}%
7583}
7584
7585% Do the @verb magic: verbatim text is quoted by unique
7586% delimiter characters.  Before first delimiter expect a
7587% right brace, after last delimiter expect closing brace:
7588%
7589%    \def\doverb'{'<char>#1<char>'}'{#1}
7590%
7591% [Knuth] p. 382; only eat outer {}
7592\begingroup
7593  \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other
7594  \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next]
7595\endgroup
7596%
7597\def\verb{\begingroup\setupverb\doverb}
7598%
7599%
7600% Do the @verbatim magic: define the macro \doverbatim so that
7601% the (first) argument ends when '@end verbatim' is reached, ie:
7602%
7603%     \def\doverbatim#1@end verbatim{#1}
7604%
7605% For Texinfo it's a lot easier than for LaTeX,
7606% because texinfo's \verbatim doesn't stop at '\end{verbatim}':
7607% we need not redefine '\', '{' and '}'.
7608%
7609% Inspired by LaTeX's verbatim command set [latex.ltx]
7610%
7611\begingroup
7612  \catcode`\ =\active
7613  \obeylines %
7614  % ignore everything up to the first ^^M, that's the newline at the end
7615  % of the @verbatim input line itself.  Otherwise we get an extra blank
7616  % line in the output.
7617  \xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}%
7618  % We really want {...\end verbatim} in the body of the macro, but
7619  % without the active space; thus we have to use \xdef and \gobble.
7620\endgroup
7621%
7622\envdef\verbatim{%
7623    \setupverbatim\doverbatim
7624}
7625\let\Everbatim = \afterenvbreak
7626
7627
7628% @verbatiminclude FILE - insert text of file in verbatim environment.
7629%
7630\def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude}
7631%
7632\def\doverbatiminclude#1{%
7633  {%
7634    \makevalueexpandable
7635    \setupverbatim
7636    \indexnofonts       % Allow `@@' and other weird things in file names.
7637    \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}%
7638    \input #1
7639    \afterenvbreak
7640  }%
7641}
7642
7643% @copying ... @end copying.
7644% Save the text away for @insertcopying later.
7645%
7646% We save the uninterpreted tokens, rather than creating a box.
7647% Saving the text in a box would be much easier, but then all the
7648% typesetting commands (@smallbook, font changes, etc.) have to be done
7649% beforehand -- and a) we want @copying to be done first in the source
7650% file; b) letting users define the frontmatter in as flexible order as
7651% possible is desirable.
7652%
7653\def\copying{\checkenv{}\begingroup\scanargctxt\docopying}
7654\def\docopying#1@end copying{\endgroup\def\copyingtext{#1}}
7655%
7656\def\insertcopying{%
7657  \begingroup
7658    \parindent = 0pt  % paragraph indentation looks wrong on title page
7659    \scanexp\copyingtext
7660  \endgroup
7661}
7662
7663
7664\message{defuns,}
7665% @defun etc.
7666
7667\newskip\defbodyindent \defbodyindent=.4in
7668\newskip\defargsindent \defargsindent=50pt
7669\newskip\deflastargmargin \deflastargmargin=18pt
7670\newcount\defunpenalty
7671
7672% Start the processing of @deffn:
7673\def\startdefun{%
7674  \ifnum\lastpenalty<10000
7675    \medbreak
7676    \defunpenalty=10003 % Will keep this @deffn together with the
7677                        % following @def command, see below.
7678  \else
7679    % If there are two @def commands in a row, we'll have a \nobreak,
7680    % which is there to keep the function description together with its
7681    % header.  But if there's nothing but headers, we need to allow a
7682    % break somewhere.  Check specifically for penalty 10002, inserted
7683    % by \printdefunline, instead of 10000, since the sectioning
7684    % commands also insert a nobreak penalty, and we don't want to allow
7685    % a break between a section heading and a defun.
7686    %
7687    % As a further refinement, we avoid "club" headers by signalling
7688    % with penalty of 10003 after the very first @deffn in the
7689    % sequence (see above), and penalty of 10002 after any following
7690    % @def command.
7691    \ifnum\lastpenalty=10002 \penalty2000 \else \defunpenalty=10002 \fi
7692    %
7693    % Similarly, after a section heading, do not allow a break.
7694    % But do insert the glue.
7695    \medskip  % preceded by discardable penalty, so not a breakpoint
7696  \fi
7697  %
7698  \parindent=0in
7699  \advance\leftskip by \defbodyindent
7700  \exdentamount=\defbodyindent
7701}
7702
7703\def\dodefunx#1{%
7704  % First, check whether we are in the right environment:
7705  \checkenv#1%
7706  %
7707  % As above, allow line break if we have multiple x headers in a row.
7708  % It's not a great place, though.
7709  \ifnum\lastpenalty=10002 \penalty3000 \else \defunpenalty=10002 \fi
7710  %
7711  % And now, it's time to reuse the body of the original defun:
7712  \expandafter\gobbledefun#1%
7713}
7714\def\gobbledefun#1\startdefun{}
7715
7716% \printdefunline \deffnheader{text}
7717%
7718\def\printdefunline#1#2{%
7719  \begingroup
7720    % call \deffnheader:
7721    #1#2 \endheader
7722    % common ending:
7723    \interlinepenalty = 10000
7724    \advance\rightskip by 0pt plus 1fil\relax
7725    \endgraf
7726    \nobreak\vskip -\parskip
7727    \penalty\defunpenalty  % signal to \startdefun and \dodefunx
7728    % Some of the @defun-type tags do not enable magic parentheses,
7729    % rendering the following check redundant.  But we don't optimize.
7730    \checkparencounts
7731  \endgroup
7732}
7733
7734\def\Edefun{\endgraf\medbreak}
7735
7736% \makedefun{deffn} creates \deffn, \deffnx and \Edeffn;
7737% the only thing remaining is to define \deffnheader.
7738%
7739\def\makedefun#1{%
7740  \expandafter\let\csname E#1\endcsname = \Edefun
7741  \edef\temp{\noexpand\domakedefun
7742    \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}%
7743  \temp
7744}
7745
7746% \domakedefun \deffn \deffnx \deffnheader { (defn. of \deffnheader) }
7747%
7748% Define \deffn and \deffnx, without parameters.
7749% \deffnheader has to be defined explicitly.
7750%
7751\def\domakedefun#1#2#3{%
7752  \envdef#1{%
7753    \startdefun
7754    \doingtypefnfalse    % distinguish typed functions from all else
7755    \parseargusing\activeparens{\printdefunline#3}%
7756  }%
7757  \def#2{\dodefunx#1}%
7758  \def#3%
7759}
7760
7761\newif\ifdoingtypefn       % doing typed function?
7762\newif\ifrettypeownline    % typeset return type on its own line?
7763
7764% @deftypefnnewline on|off says whether the return type of typed functions
7765% are printed on their own line.  This affects @deftypefn, @deftypefun,
7766% @deftypeop, and @deftypemethod.
7767%
7768\parseargdef\deftypefnnewline{%
7769  \def\temp{#1}%
7770  \ifx\temp\onword
7771    \expandafter\let\csname SETtxideftypefnnl\endcsname
7772      = \empty
7773  \else\ifx\temp\offword
7774    \expandafter\let\csname SETtxideftypefnnl\endcsname
7775      = \relax
7776  \else
7777    \errhelp = \EMsimple
7778    \errmessage{Unknown @txideftypefnnl value `\temp',
7779                must be on|off}%
7780  \fi\fi
7781}
7782
7783% Untyped functions:
7784
7785% @deffn category name args
7786\makedefun{deffn}{\deffngeneral{}}
7787
7788% @deffn category class name args
7789\makedefun{defop}#1 {\defopon{#1\ \putwordon}}
7790
7791% \defopon {category on}class name args
7792\def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
7793
7794% \deffngeneral {subind}category name args
7795%
7796\def\deffngeneral#1#2 #3 #4\endheader{%
7797  % Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}.
7798  \dosubind{fn}{\code{#3}}{#1}%
7799  \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
7800}
7801
7802% Typed functions:
7803
7804% @deftypefn category type name args
7805\makedefun{deftypefn}{\deftypefngeneral{}}
7806
7807% @deftypeop category class type name args
7808\makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}}
7809
7810% \deftypeopon {category on}class type name args
7811\def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
7812
7813% \deftypefngeneral {subind}category type name args
7814%
7815\def\deftypefngeneral#1#2 #3 #4 #5\endheader{%
7816  \dosubind{fn}{\code{#4}}{#1}%
7817  \doingtypefntrue
7818  \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
7819}
7820
7821% Typed variables:
7822
7823% @deftypevr category type var args
7824\makedefun{deftypevr}{\deftypecvgeneral{}}
7825
7826% @deftypecv category class type var args
7827\makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}}
7828
7829% \deftypecvof {category of}class type var args
7830\def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} }
7831
7832% \deftypecvgeneral {subind}category type var args
7833%
7834\def\deftypecvgeneral#1#2 #3 #4 #5\endheader{%
7835  \dosubind{vr}{\code{#4}}{#1}%
7836  \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
7837}
7838
7839% Untyped variables:
7840
7841% @defvr category var args
7842\makedefun{defvr}#1 {\deftypevrheader{#1} {} }
7843
7844% @defcv category class var args
7845\makedefun{defcv}#1 {\defcvof{#1\ \putwordof}}
7846
7847% \defcvof {category of}class var args
7848\def\defcvof#1#2 {\deftypecvof{#1}#2 {} }
7849
7850% Types:
7851
7852% @deftp category name args
7853\makedefun{deftp}#1 #2 #3\endheader{%
7854  \doind{tp}{\code{#2}}%
7855  \defname{#1}{}{#2}\defunargs{#3\unskip}%
7856}
7857
7858% Remaining @defun-like shortcuts:
7859\makedefun{defun}{\deffnheader{\putwordDeffunc} }
7860\makedefun{defmac}{\deffnheader{\putwordDefmac} }
7861\makedefun{defspec}{\deffnheader{\putwordDefspec} }
7862\makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} }
7863\makedefun{defvar}{\defvrheader{\putwordDefvar} }
7864\makedefun{defopt}{\defvrheader{\putwordDefopt} }
7865\makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} }
7866\makedefun{defmethod}{\defopon\putwordMethodon}
7867\makedefun{deftypemethod}{\deftypeopon\putwordMethodon}
7868\makedefun{defivar}{\defcvof\putwordInstanceVariableof}
7869\makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof}
7870
7871% \defname, which formats the name of the @def (not the args).
7872% #1 is the category, such as "Function".
7873% #2 is the return type, if any.
7874% #3 is the function name.
7875%
7876% We are followed by (but not passed) the arguments, if any.
7877%
7878\def\defname#1#2#3{%
7879  \par
7880  % Get the values of \leftskip and \rightskip as they were outside the @def...
7881  \advance\leftskip by -\defbodyindent
7882  %
7883  % Determine if we are typesetting the return type of a typed function
7884  % on a line by itself.
7885  \rettypeownlinefalse
7886  \ifdoingtypefn  % doing a typed function specifically?
7887    % then check user option for putting return type on its own line:
7888    \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else
7889      \rettypeownlinetrue
7890    \fi
7891  \fi
7892  %
7893  % How we'll format the category name.  Putting it in brackets helps
7894  % distinguish it from the body text that may end up on the next line
7895  % just below it.
7896  \def\temp{#1}%
7897  \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
7898  %
7899  % Figure out line sizes for the paragraph shape.  We'll always have at
7900  % least two.
7901  \tempnum = 2
7902  %
7903  % The first line needs space for \box0; but if \rightskip is nonzero,
7904  % we need only space for the part of \box0 which exceeds it:
7905  \dimen0=\hsize  \advance\dimen0 by -\wd0  \advance\dimen0 by \rightskip
7906  %
7907  % If doing a return type on its own line, we'll have another line.
7908  \ifrettypeownline
7909    \advance\tempnum by 1
7910    \def\maybeshapeline{0in \hsize}%
7911  \else
7912    \def\maybeshapeline{}%
7913  \fi
7914  %
7915  % The continuations:
7916  \dimen2=\hsize  \advance\dimen2 by -\defargsindent
7917  %
7918  % The final paragraph shape:
7919  \parshape \tempnum  0in \dimen0  \maybeshapeline  \defargsindent \dimen2
7920  %
7921  % Put the category name at the right margin.
7922  \noindent
7923  \hbox to 0pt{%
7924    \hfil\box0 \kern-\hsize
7925    % \hsize has to be shortened this way:
7926    \kern\leftskip
7927    % Intentionally do not respect \rightskip, since we need the space.
7928  }%
7929  %
7930  % Allow all lines to be underfull without complaint:
7931  \tolerance=10000 \hbadness=10000
7932  \exdentamount=\defbodyindent
7933  {%
7934    % defun fonts. We use typewriter by default (used to be bold) because:
7935    % . we're printing identifiers, they should be in tt in principle.
7936    % . in languages with many accents, such as Czech or French, it's
7937    %   common to leave accents off identifiers.  The result looks ok in
7938    %   tt, but exceedingly strange in rm.
7939    % . we don't want -- and --- to be treated as ligatures.
7940    % . this still does not fix the ?` and !` ligatures, but so far no
7941    %   one has made identifiers using them :).
7942    \df \tt
7943    \def\temp{#2}% text of the return type
7944    \ifx\temp\empty\else
7945      \tclose{\temp}% typeset the return type
7946      \ifrettypeownline
7947        % put return type on its own line; prohibit line break following:
7948        \hfil\vadjust{\nobreak}\break
7949      \else
7950        \space  % type on same line, so just followed by a space
7951      \fi
7952    \fi           % no return type
7953    #3% output function name
7954  }%
7955  {\rm\enskip}% hskip 0.5 em of \rmfont
7956  %
7957  \boldbrax
7958  % arguments will be output next, if any.
7959}
7960
7961% Print arguments in slanted roman (not ttsl), inconsistently with using
7962% tt for the name.  This is because literal text is sometimes needed in
7963% the argument list (groff manual), and ttsl and tt are not very
7964% distinguishable.  Prevent hyphenation at `-' chars.
7965%
7966\def\defunargs#1{%
7967  % use sl by default (not ttsl),
7968  % tt for the names.
7969  \df \sl \hyphenchar\font=0
7970  %
7971  % On the other hand, if an argument has two dashes (for instance), we
7972  % want a way to get ttsl.  We used to recommend @var for that, so
7973  % leave the code in, but it's strange for @var to lead to typewriter.
7974  % Nowadays we recommend @code, since the difference between a ttsl hyphen
7975  % and a tt hyphen is pretty tiny.  @code also disables ?` !`.
7976  \def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}%
7977  #1%
7978  \sl\hyphenchar\font=45
7979}
7980
7981% We want ()&[] to print specially on the defun line.
7982%
7983\def\activeparens{%
7984  \catcode`\(=\active \catcode`\)=\active
7985  \catcode`\[=\active \catcode`\]=\active
7986  \catcode`\&=\active
7987}
7988
7989% Make control sequences which act like normal parenthesis chars.
7990\let\lparen = ( \let\rparen = )
7991
7992% Be sure that we always have a definition for `(', etc.  For example,
7993% if the fn name has parens in it, \boldbrax will not be in effect yet,
7994% so TeX would otherwise complain about undefined control sequence.
7995{
7996  \activeparens
7997  \global\let(=\lparen \global\let)=\rparen
7998  \global\let[=\lbrack \global\let]=\rbrack
7999  \global\let& = \&
8000
8001  \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
8002  \gdef\magicamp{\let&=\amprm}
8003}
8004
8005\newcount\parencount
8006
8007% If we encounter &foo, then turn on ()-hacking afterwards
8008\newif\ifampseen
8009\def\amprm#1 {\ampseentrue{\bf\&#1 }}
8010
8011\def\parenfont{%
8012  \ifampseen
8013    % At the first level, print parens in roman,
8014    % otherwise use the default font.
8015    \ifnum \parencount=1 \rm \fi
8016  \else
8017    % The \sf parens (in \boldbrax) actually are a little bolder than
8018    % the contained text.  This is especially needed for [ and ] .
8019    \sf
8020  \fi
8021}
8022\def\infirstlevel#1{%
8023  \ifampseen
8024    \ifnum\parencount=1
8025      #1%
8026    \fi
8027  \fi
8028}
8029\def\bfafterword#1 {#1 \bf}
8030
8031\def\opnr{%
8032  \global\advance\parencount by 1
8033  {\parenfont(}%
8034  \infirstlevel \bfafterword
8035}
8036\def\clnr{%
8037  {\parenfont)}%
8038  \infirstlevel \sl
8039  \global\advance\parencount by -1
8040}
8041
8042\newcount\brackcount
8043\def\lbrb{%
8044  \global\advance\brackcount by 1
8045  {\bf[}%
8046}
8047\def\rbrb{%
8048  {\bf]}%
8049  \global\advance\brackcount by -1
8050}
8051
8052\def\checkparencounts{%
8053  \ifnum\parencount=0 \else \badparencount \fi
8054  \ifnum\brackcount=0 \else \badbrackcount \fi
8055}
8056% these should not use \errmessage; the glibc manual, at least, actually
8057% has such constructs (when documenting function pointers).
8058\def\badparencount{%
8059  \message{Warning: unbalanced parentheses in @def...}%
8060  \global\parencount=0
8061}
8062\def\badbrackcount{%
8063  \message{Warning: unbalanced square brackets in @def...}%
8064  \global\brackcount=0
8065}
8066
8067
8068\message{macros,}
8069% @macro.
8070
8071% To do this right we need a feature of e-TeX, \scantokens,
8072% which we arrange to emulate with a temporary file in ordinary TeX.
8073\ifx\eTeXversion\thisisundefined
8074  \newwrite\macscribble
8075  \def\scantokens#1{%
8076    \toks0={#1}%
8077    \immediate\openout\macscribble=\jobname.tmp
8078    \immediate\write\macscribble{\the\toks0}%
8079    \immediate\closeout\macscribble
8080    \input \jobname.tmp
8081  }
8082\fi
8083
8084% alias because \c means cedilla in @tex or @math
8085\let\texinfoc=\c
8086
8087\newcount\savedcatcodeone
8088\newcount\savedcatcodetwo
8089
8090% Used at the time of macro expansion.
8091% Argument is macro body with arguments substituted
8092\def\scanmacro#1{%
8093  \newlinechar`\^^M
8094  \def\xeatspaces{\eatspaces}%
8095  %
8096  % Temporarily undo catcode changes of \printindex.  Set catcode of @ to
8097  % 0 so that @-commands in macro expansions aren't printed literally when
8098  % formatting an index file, where \ is used as the escape character.
8099  \savedcatcodeone=\catcode`\@
8100  \savedcatcodetwo=\catcode`\\
8101  \catcode`\@=0
8102  \catcode`\\=\active
8103  %
8104  % Process the macro body under the current catcode regime.
8105  \scantokens{#1@texinfoc}%
8106  %
8107  \catcode`\@=\savedcatcodeone
8108  \catcode`\\=\savedcatcodetwo
8109  %
8110  % The \texinfoc is to remove the \newlinechar added by \scantokens, and
8111  % can be noticed by \parsearg.
8112  %   We avoid surrounding the call to \scantokens with \bgroup and \egroup
8113  % to allow macros to open or close groups themselves.
8114}
8115
8116% Used for copying and captions
8117\def\scanexp#1{%
8118  \expandafter\scanmacro\expandafter{#1}%
8119}
8120
8121\newcount\paramno   % Count of parameters
8122\newtoks\macname    % Macro name
8123\newif\ifrecursive  % Is it recursive?
8124
8125% List of all defined macros in the form
8126%    \commondummyword\macro1\commondummyword\macro2...
8127% Currently is also contains all @aliases; the list can be split
8128% if there is a need.
8129\def\macrolist{}
8130
8131% Add the macro to \macrolist
8132\def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname}
8133\def\addtomacrolistxxx#1{%
8134     \toks0 = \expandafter{\macrolist\commondummyword#1}%
8135     \xdef\macrolist{\the\toks0}%
8136}
8137
8138% Utility routines.
8139% This does \let #1 = #2, with \csnames; that is,
8140%   \let \csname#1\endcsname = \csname#2\endcsname
8141% (except of course we have to play expansion games).
8142%
8143\def\cslet#1#2{%
8144  \expandafter\let
8145  \csname#1\expandafter\endcsname
8146  \csname#2\endcsname
8147}
8148
8149% Trim leading and trailing spaces off a string.
8150% Concepts from aro-bend problem 15 (see CTAN).
8151{\catcode`\@=11
8152\gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }}
8153\gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@}
8154\gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @}
8155\def\unbrace#1{#1}
8156\unbrace{\gdef\trim@@@ #1 } #2@{#1}
8157}
8158
8159% Trim a single trailing ^^M off a string.
8160{\catcode`\^^M=\other \catcode`\Q=3%
8161\gdef\eatcr #1{\eatcra #1Q^^MQ}%
8162\gdef\eatcra#1^^MQ{\eatcrb#1Q}%
8163\gdef\eatcrb#1Q#2Q{#1}%
8164}
8165
8166% Macro bodies are absorbed as an argument in a context where
8167% all characters are catcode 10, 11 or 12, except \ which is active
8168% (as in normal texinfo). It is necessary to change the definition of \
8169% to recognize macro arguments; this is the job of \mbodybackslash.
8170%
8171% Non-ASCII encodings make 8-bit characters active, so un-activate
8172% them to avoid their expansion.  Must do this non-globally, to
8173% confine the change to the current group.
8174%
8175% It's necessary to have hard CRs when the macro is executed. This is
8176% done by making ^^M (\endlinechar) catcode 12 when reading the macro
8177% body, and then making it the \newlinechar in \scanmacro.
8178%
8179\def\scanctxt{% used as subroutine
8180  \catcode`\"=\other
8181  \catcode`\+=\other
8182  \catcode`\<=\other
8183  \catcode`\>=\other
8184  \catcode`\^=\other
8185  \catcode`\_=\other
8186  \catcode`\|=\other
8187  \catcode`\~=\other
8188  \passthroughcharstrue
8189}
8190
8191\def\scanargctxt{% used for copying and captions, not macros.
8192  \scanctxt
8193  \catcode`\@=\other
8194  \catcode`\\=\other
8195  \catcode`\^^M=\other
8196}
8197
8198\def\macrobodyctxt{% used for @macro definitions
8199  \scanctxt
8200  \catcode`\ =\other
8201  \catcode`\@=\other
8202  \catcode`\{=\other
8203  \catcode`\}=\other
8204  \catcode`\^^M=\other
8205  \usembodybackslash
8206}
8207
8208% Used when scanning braced macro arguments.  Note, however, that catcode
8209% changes here are ineffectual if the macro invocation was nested inside
8210% an argument to another Texinfo command.
8211\def\macroargctxt{%
8212  \scanctxt
8213  \catcode`\ =\active
8214  \catcode`\^^M=\other
8215  \catcode`\\=\active
8216}
8217
8218\def\macrolineargctxt{% used for whole-line arguments without braces
8219  \scanctxt
8220  \catcode`\{=\other
8221  \catcode`\}=\other
8222}
8223
8224% \mbodybackslash is the definition of \ in @macro bodies.
8225% It maps \foo\ => \csname macarg.foo\endcsname => #N
8226% where N is the macro parameter number.
8227% We define \csname macarg.\endcsname to be \realbackslash, so
8228% \\ in macro replacement text gets you a backslash.
8229%
8230{\catcode`@=0 @catcode`@\=@active
8231 @gdef@usembodybackslash{@let\=@mbodybackslash}
8232 @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname}
8233}
8234\expandafter\def\csname macarg.\endcsname{\realbackslash}
8235
8236\def\margbackslash#1{\char`\#1 }
8237
8238\def\macro{\recursivefalse\parsearg\macroxxx}
8239\def\rmacro{\recursivetrue\parsearg\macroxxx}
8240
8241\def\macroxxx#1{%
8242  \getargs{#1}% now \macname is the macname and \argl the arglist
8243  \ifx\argl\empty       % no arguments
8244     \paramno=0\relax
8245  \else
8246     \expandafter\parsemargdef \argl;%
8247     \if\paramno>256\relax
8248       \ifx\eTeXversion\thisisundefined
8249         \errhelp = \EMsimple
8250         \errmessage{You need eTeX to compile a file with macros with more than 256 arguments}
8251       \fi
8252     \fi
8253  \fi
8254  \if1\csname ismacro.\the\macname\endcsname
8255     \message{Warning: redefining \the\macname}%
8256  \else
8257     \expandafter\ifx\csname \the\macname\endcsname \relax
8258     \else \errmessage{Macro name \the\macname\space already defined}\fi
8259     \global\cslet{macsave.\the\macname}{\the\macname}%
8260     \global\expandafter\let\csname ismacro.\the\macname\endcsname=1%
8261     \addtomacrolist{\the\macname}%
8262  \fi
8263  \begingroup \macrobodyctxt
8264  \ifrecursive \expandafter\parsermacbody
8265  \else \expandafter\parsemacbody
8266  \fi}
8267
8268\parseargdef\unmacro{%
8269  \if1\csname ismacro.#1\endcsname
8270    \global\cslet{#1}{macsave.#1}%
8271    \global\expandafter\let \csname ismacro.#1\endcsname=0%
8272    % Remove the macro name from \macrolist:
8273    \begingroup
8274      \expandafter\let\csname#1\endcsname \relax
8275      \let\commondummyword\unmacrodo
8276      \xdef\macrolist{\macrolist}%
8277    \endgroup
8278  \else
8279    \errmessage{Macro #1 not defined}%
8280  \fi
8281}
8282
8283% Called by \do from \dounmacro on each macro.  The idea is to omit any
8284% macro definitions that have been changed to \relax.
8285%
8286\def\unmacrodo#1{%
8287  \ifx #1\relax
8288    % remove this
8289  \else
8290    \noexpand\commondummyword \noexpand#1%
8291  \fi
8292}
8293
8294% \getargs -- Parse the arguments to a @macro line.  Set \macname to
8295% the name of the macro, and \argl to the braced argument list.
8296\def\getargs#1{\getargsxxx#1{}}
8297\def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
8298\def\getmacname#1 #2\relax{\macname={#1}}
8299\def\getmacargs#1{\def\argl{#1}}
8300% This made use of the feature that if the last token of a
8301% <parameter list> is #, then the preceding argument is delimited by
8302% an opening brace, and that opening brace is not consumed.
8303
8304% Parse the optional {params} list to @macro or @rmacro.
8305% Set \paramno to the number of arguments,
8306% and \paramlist to a parameter text for the macro (e.g. #1,#2,#3 for a
8307% three-param macro.)  Define \macarg.BLAH for each BLAH in the params
8308% list to some hook where the argument is to be expanded.  If there are
8309% less than 10 arguments that hook is to be replaced by ##N where N
8310% is the position in that list, that is to say the macro arguments are to be
8311% defined `a la TeX in the macro body.
8312%
8313% That gets used by \mbodybackslash (above).
8314%
8315% If there are 10 or more arguments, a different technique is used: see
8316% \parsemmanyargdef.
8317%
8318\def\parsemargdef#1;{%
8319  \paramno=0\def\paramlist{}%
8320  \let\hash\relax
8321  % \hash is redefined to `#' later to get it into definitions
8322  \let\xeatspaces\relax
8323  \parsemargdefxxx#1,;,%
8324  \ifnum\paramno<10\relax\else
8325    \paramno0\relax
8326    \parsemmanyargdef@@#1,;,% 10 or more arguments
8327  \fi
8328}
8329\def\parsemargdefxxx#1,{%
8330  \if#1;\let\next=\relax
8331  \else \let\next=\parsemargdefxxx
8332    \advance\paramno by 1
8333    \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
8334        {\xeatspaces{\hash\the\paramno}}%
8335    \edef\paramlist{\paramlist\hash\the\paramno,}%
8336  \fi\next}
8337
8338% \parsemacbody, \parsermacbody
8339%
8340% Read recursive and nonrecursive macro bodies. (They're different since
8341% rec and nonrec macros end differently.)
8342%
8343% We are in \macrobodyctxt, and the \xdef causes backslashshes in the macro
8344% body to be transformed.
8345% Set \macrobody to the body of the macro, and call \defmacro.
8346%
8347{\catcode`\ =\other\long\gdef\parsemacbody#1@end macro{%
8348\xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}%
8349{\catcode`\ =\other\long\gdef\parsermacbody#1@end rmacro{%
8350\xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}%
8351
8352% Make @ a letter, so that we can make private-to-Texinfo macro names.
8353\edef\texiatcatcode{\the\catcode`\@}
8354\catcode `@=11\relax
8355
8356%%%%%%%%%%%%%% Code for > 10 arguments only   %%%%%%%%%%%%%%%%%%
8357
8358% If there are 10 or more arguments, a different technique is used, where the
8359% hook remains in the body, and when macro is to be expanded the body is
8360% processed again to replace the arguments.
8361%
8362% In that case, the hook is \the\toks N-1, and we simply set \toks N-1 to the
8363% argument N value and then \edef the body (nothing else will expand because of
8364% the catcode regime under which the body was input).
8365%
8366% If you compile with TeX (not eTeX), and you have macros with 10 or more
8367% arguments, no macro can have more than 256 arguments (else error).
8368%
8369% In case that there are 10 or more arguments we parse again the arguments
8370% list to set new definitions for the \macarg.BLAH macros corresponding to
8371% each BLAH argument. It was anyhow needed to parse already once this list
8372% in order to count the arguments, and as macros with at most 9 arguments
8373% are by far more frequent than macro with 10 or more arguments, defining
8374% twice the \macarg.BLAH macros does not cost too much processing power.
8375\def\parsemmanyargdef@@#1,{%
8376  \if#1;\let\next=\relax
8377  \else
8378    \let\next=\parsemmanyargdef@@
8379    \edef\tempb{\eatspaces{#1}}%
8380    \expandafter\def\expandafter\tempa
8381       \expandafter{\csname macarg.\tempb\endcsname}%
8382    % Note that we need some extra \noexpand\noexpand, this is because we
8383    % don't want \the  to be expanded in the \parsermacbody  as it uses an
8384    % \xdef .
8385    \expandafter\edef\tempa
8386      {\noexpand\noexpand\noexpand\the\toks\the\paramno}%
8387    \advance\paramno by 1\relax
8388  \fi\next}
8389
8390
8391\let\endargs@\relax
8392\let\nil@\relax
8393\def\nilm@{\nil@}%
8394\long\def\nillm@{\nil@}%
8395
8396% This macro is expanded during the Texinfo macro expansion, not during its
8397% definition.  It gets all the arguments' values and assigns them to macros
8398% macarg.ARGNAME
8399%
8400% #1 is the macro name
8401% #2 is the list of argument names
8402% #3 is the list of argument values
8403\def\getargvals@#1#2#3{%
8404  \def\macargdeflist@{}%
8405  \def\saveparamlist@{#2}% Need to keep a copy for parameter expansion.
8406  \def\paramlist{#2,\nil@}%
8407  \def\macroname{#1}%
8408  \begingroup
8409  \macroargctxt
8410  \def\argvaluelist{#3,\nil@}%
8411  \def\@tempa{#3}%
8412  \ifx\@tempa\empty
8413    \setemptyargvalues@
8414  \else
8415    \getargvals@@
8416  \fi
8417}
8418\def\getargvals@@{%
8419  \ifx\paramlist\nilm@
8420      % Some sanity check needed here that \argvaluelist is also empty.
8421      \ifx\argvaluelist\nillm@
8422      \else
8423        \errhelp = \EMsimple
8424        \errmessage{Too many arguments in macro `\macroname'!}%
8425      \fi
8426      \let\next\macargexpandinbody@
8427  \else
8428    \ifx\argvaluelist\nillm@
8429       % No more arguments values passed to macro.  Set remaining named-arg
8430       % macros to empty.
8431       \let\next\setemptyargvalues@
8432    \else
8433      % pop current arg name into \@tempb
8434      \def\@tempa##1{\pop@{\@tempb}{\paramlist}##1\endargs@}%
8435      \expandafter\@tempa\expandafter{\paramlist}%
8436       % pop current argument value into \@tempc
8437      \def\@tempa##1{\longpop@{\@tempc}{\argvaluelist}##1\endargs@}%
8438      \expandafter\@tempa\expandafter{\argvaluelist}%
8439       % Here \@tempb is the current arg name and \@tempc is the current arg value.
8440       % First place the new argument macro definition into \@tempd
8441       \expandafter\macname\expandafter{\@tempc}%
8442       \expandafter\let\csname macarg.\@tempb\endcsname\relax
8443       \expandafter\def\expandafter\@tempe\expandafter{%
8444         \csname macarg.\@tempb\endcsname}%
8445       \edef\@tempd{\long\def\@tempe{\the\macname}}%
8446       \push@\@tempd\macargdeflist@
8447       \let\next\getargvals@@
8448    \fi
8449  \fi
8450  \next
8451}
8452
8453\def\push@#1#2{%
8454  \expandafter\expandafter\expandafter\def
8455  \expandafter\expandafter\expandafter#2%
8456  \expandafter\expandafter\expandafter{%
8457  \expandafter#1#2}%
8458}
8459
8460% Replace arguments by their values in the macro body, and place the result
8461% in macro \@tempa.
8462%
8463\def\macvalstoargs@{%
8464  %  To do this we use the property that token registers that are \the'ed
8465  % within an \edef  expand only once. So we are going to place all argument
8466  % values into respective token registers.
8467  %
8468  % First we save the token context, and initialize argument numbering.
8469  \begingroup
8470    \paramno0\relax
8471    % Then, for each argument number #N, we place the corresponding argument
8472    % value into a new token list register \toks#N
8473    \expandafter\putargsintokens@\saveparamlist@,;,%
8474    % Then, we expand the body so that argument are replaced by their
8475    % values. The trick for values not to be expanded themselves is that they
8476    % are within tokens and that tokens expand only once in an \edef .
8477    \edef\@tempc{\csname mac.\macroname .body\endcsname}%
8478    % Now we restore the token stack pointer to free the token list registers
8479    % which we have used, but we make sure that expanded body is saved after
8480    % group.
8481    \expandafter
8482  \endgroup
8483  \expandafter\def\expandafter\@tempa\expandafter{\@tempc}%
8484  }
8485
8486% Define the named-macro outside of this group and then close this group.
8487%
8488\def\macargexpandinbody@{%
8489  \expandafter
8490  \endgroup
8491  \macargdeflist@
8492  % First the replace in body the macro arguments by their values, the result
8493  % is in \@tempa .
8494  \macvalstoargs@
8495  % Then we point at the \norecurse or \gobble (for recursive) macro value
8496  % with \@tempb .
8497  \expandafter\let\expandafter\@tempb\csname mac.\macroname .recurse\endcsname
8498  % Depending on whether it is recursive or not, we need some tailing
8499  % \egroup .
8500  \ifx\@tempb\gobble
8501     \let\@tempc\relax
8502  \else
8503     \let\@tempc\egroup
8504  \fi
8505  % And now we do the real job:
8506  \edef\@tempd{\noexpand\@tempb{\macroname}\noexpand\scanmacro{\@tempa}\@tempc}%
8507  \@tempd
8508}
8509
8510\def\putargsintokens@#1,{%
8511  \if#1;\let\next\relax
8512  \else
8513    \let\next\putargsintokens@
8514    % First we allocate the new token list register, and give it a temporary
8515    % alias \@tempb .
8516    \toksdef\@tempb\the\paramno
8517    % Then we place the argument value into that token list register.
8518    \expandafter\let\expandafter\@tempa\csname macarg.#1\endcsname
8519    \expandafter\@tempb\expandafter{\@tempa}%
8520    \advance\paramno by 1\relax
8521  \fi
8522  \next
8523}
8524
8525% Trailing missing arguments are set to empty.
8526%
8527\def\setemptyargvalues@{%
8528  \ifx\paramlist\nilm@
8529    \let\next\macargexpandinbody@
8530  \else
8531    \expandafter\setemptyargvaluesparser@\paramlist\endargs@
8532    \let\next\setemptyargvalues@
8533  \fi
8534  \next
8535}
8536
8537\def\setemptyargvaluesparser@#1,#2\endargs@{%
8538  \expandafter\def\expandafter\@tempa\expandafter{%
8539    \expandafter\def\csname macarg.#1\endcsname{}}%
8540  \push@\@tempa\macargdeflist@
8541  \def\paramlist{#2}%
8542}
8543
8544% #1 is the element target macro
8545% #2 is the list macro
8546% #3,#4\endargs@ is the list value
8547\def\pop@#1#2#3,#4\endargs@{%
8548   \def#1{#3}%
8549   \def#2{#4}%
8550}
8551\long\def\longpop@#1#2#3,#4\endargs@{%
8552   \long\def#1{#3}%
8553   \long\def#2{#4}%
8554}
8555
8556
8557%%%%%%%%%%%%%% End of code for > 10 arguments %%%%%%%%%%%%%%%%%%
8558
8559
8560% This defines a Texinfo @macro or @rmacro, called by \parsemacbody.
8561%    \macrobody has the body of the macro in it, with placeholders for
8562% its parameters, looking like "\xeatspaces{\hash 1}".
8563%    \paramno is the number of parameters
8564%    \paramlist is a TeX parameter text, e.g. "#1,#2,#3,"
8565% There are four cases: macros of zero, one, up to nine, and many arguments.
8566% \xdef is used so that macro definitions will survive the file
8567% they're defined in: @include reads the file inside a group.
8568%
8569\def\defmacro{%
8570  \let\hash=##% convert placeholders to macro parameter chars
8571  \ifnum\paramno=1
8572    \def\xeatspaces##1{##1}%
8573    % This removes the pair of braces around the argument.  We don't
8574    % use \eatspaces, because this can cause ends of lines to be lost
8575    % when the argument to \eatspaces is read, leading to line-based
8576    % commands like "@itemize" not being read correctly.
8577  \else
8578    \let\xeatspaces\relax % suppress expansion
8579  \fi
8580  \ifcase\paramno
8581  % 0
8582    \expandafter\xdef\csname\the\macname\endcsname{%
8583      \bgroup
8584        \noexpand\spaceisspace
8585        \noexpand\endlineisspace
8586        \noexpand\expandafter % skip any whitespace after the macro name.
8587        \expandafter\noexpand\csname\the\macname @@@\endcsname}%
8588    \expandafter\xdef\csname\the\macname @@@\endcsname{%
8589      \egroup
8590      \noexpand\scanmacro{\macrobody}}%
8591  \or % 1
8592    \expandafter\xdef\csname\the\macname\endcsname{%
8593       \bgroup
8594       \noexpand\braceorline
8595       \expandafter\noexpand\csname\the\macname @@@\endcsname}%
8596    \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8597      \egroup
8598      \noexpand\scanmacro{\macrobody}%
8599      }%
8600  \else % at most 9
8601    \ifnum\paramno<10\relax
8602      % @MACNAME sets the context for reading the macro argument
8603      % @MACNAME@@ gets the argument, processes backslashes and appends a
8604      % comma.
8605      % @MACNAME@@@ removes braces surrounding the argument list.
8606      % @MACNAME@@@@ scans the macro body with arguments substituted.
8607      \expandafter\xdef\csname\the\macname\endcsname{%
8608        \bgroup
8609        \noexpand\expandafter  % This \expandafter skip any spaces after the
8610        \noexpand\macroargctxt % macro before we change the catcode of space.
8611        \noexpand\expandafter
8612        \expandafter\noexpand\csname\the\macname @@\endcsname}%
8613      \expandafter\xdef\csname\the\macname @@\endcsname##1{%
8614          \noexpand\passargtomacro
8615          \expandafter\noexpand\csname\the\macname @@@\endcsname{##1,}}%
8616      \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8617          \expandafter\noexpand\csname\the\macname @@@@\endcsname ##1}%
8618      \expandafter\expandafter
8619      \expandafter\xdef
8620      \expandafter\expandafter
8621        \csname\the\macname @@@@\endcsname\paramlist{%
8622          \egroup\noexpand\scanmacro{\macrobody}}%
8623    \else % 10 or more:
8624      \expandafter\xdef\csname\the\macname\endcsname{%
8625        \noexpand\getargvals@{\the\macname}{\argl}%
8626      }%
8627      \global\expandafter\let\csname mac.\the\macname .body\endcsname\macrobody
8628      \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\gobble
8629    \fi
8630  \fi}
8631
8632\catcode `\@\texiatcatcode\relax % end private-to-Texinfo catcodes
8633
8634\def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
8635
8636
8637%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8638%
8639{\catcode`\@=0 \catcode`\\=13  % We need to manipulate \ so use @ as escape
8640@catcode`@_=11  % private names
8641@catcode`@!=11  % used as argument separator
8642
8643% \passargtomacro#1#2 -
8644% Call #1 with a list of tokens #2, with any doubled backslashes in #2
8645% compressed to one.
8646%
8647% This implementation works by expansion, and not execution (so we cannot use
8648% \def or similar).  This reduces the risk of this failing in contexts where
8649% complete expansion is done with no execution (for example, in writing out to
8650% an auxiliary file for an index entry).
8651%
8652% State is kept in the input stream: the argument passed to
8653% @look_ahead, @gobble_and_check_finish and @add_segment is
8654%
8655% THE_MACRO ARG_RESULT ! {PENDING_BS} NEXT_TOKEN  (... rest of input)
8656%
8657% where:
8658% THE_MACRO - name of the macro we want to call
8659% ARG_RESULT - argument list we build to pass to that macro
8660% PENDING_BS - either a backslash or nothing
8661% NEXT_TOKEN - used to look ahead in the input stream to see what's coming next
8662
8663@gdef@passargtomacro#1#2{%
8664  @add_segment #1!{}@relax#2\@_finish\%
8665}
8666@gdef@_finish{@_finishx} @global@let@_finishx@relax
8667
8668% #1 - THE_MACRO ARG_RESULT
8669% #2 - PENDING_BS
8670% #3 - NEXT_TOKEN
8671% #4 used to look ahead
8672%
8673% If the next token is not a backslash, process the rest of the argument;
8674% otherwise, remove the next token.
8675@gdef@look_ahead#1!#2#3#4{%
8676  @ifx#4\%
8677   @expandafter@gobble_and_check_finish
8678  @else
8679   @expandafter@add_segment
8680  @fi#1!{#2}#4#4%
8681}
8682
8683% #1 - THE_MACRO ARG_RESULT
8684% #2 - PENDING_BS
8685% #3 - NEXT_TOKEN
8686% #4 should be a backslash, which is gobbled.
8687% #5 looks ahead
8688%
8689% Double backslash found.  Add a single backslash, and look ahead.
8690@gdef@gobble_and_check_finish#1!#2#3#4#5{%
8691  @add_segment#1\!{}#5#5%
8692}
8693
8694@gdef@is_fi{@fi}
8695
8696% #1 - THE_MACRO ARG_RESULT
8697% #2 - PENDING_BS
8698% #3 - NEXT_TOKEN
8699% #4 is input stream until next backslash
8700%
8701% Input stream is either at the start of the argument, or just after a
8702% backslash sequence, either a lone backslash, or a doubled backslash.
8703% NEXT_TOKEN contains the first token in the input stream: if it is \finish,
8704% finish; otherwise, append to ARG_RESULT the segment of the argument up until
8705% the next backslash.  PENDING_BACKSLASH contains a backslash to represent
8706% a backslash just before the start of the input stream that has not been
8707% added to ARG_RESULT.
8708@gdef@add_segment#1!#2#3#4\{%
8709@ifx#3@_finish
8710  @call_the_macro#1!%
8711@else
8712  % append the pending backslash to the result, followed by the next segment
8713  @expandafter@is_fi@look_ahead#1#2#4!{\}@fi
8714  % this @fi is discarded by @look_ahead.
8715  % we can't get rid of it with \expandafter because we don't know how
8716  % long #4 is.
8717}
8718
8719% #1 - THE_MACRO
8720% #2 - ARG_RESULT
8721% #3 discards the res of the conditional in @add_segment, and @is_fi ends the
8722% conditional.
8723@gdef@call_the_macro#1#2!#3@fi{@is_fi #1{#2}}
8724
8725}
8726%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8727
8728% \braceorline MAC is used for a one-argument macro MAC.  It checks
8729% whether the next non-whitespace character is a {.  It sets the context
8730% for reading the argument (slightly different in the two cases).  Then,
8731% to read the argument, in the whole-line case, it then calls the regular
8732% \parsearg MAC; in the lbrace case, it calls \passargtomacro MAC.
8733%
8734\def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx}
8735\def\braceorlinexxx{%
8736  \ifx\nchar\bgroup
8737    \macroargctxt
8738    \expandafter\passargtomacro
8739  \else
8740    \macrolineargctxt\expandafter\parsearg
8741  \fi \macnamexxx}
8742
8743
8744% @alias.
8745% We need some trickery to remove the optional spaces around the equal
8746% sign.  Make them active and then expand them all to nothing.
8747%
8748\def\alias{\parseargusing\obeyspaces\aliasxxx}
8749\def\aliasxxx #1{\aliasyyy#1\relax}
8750\def\aliasyyy #1=#2\relax{%
8751  {%
8752    \expandafter\let\obeyedspace=\empty
8753    \addtomacrolist{#1}%
8754    \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}%
8755  }%
8756  \next
8757}
8758
8759
8760\message{cross references,}
8761
8762\newwrite\auxfile
8763\newif\ifhavexrefs    % True if xref values are known.
8764\newif\ifwarnedxrefs  % True if we warned once that they aren't known.
8765
8766% @inforef is relatively simple.
8767\def\inforef #1{\inforefzzz #1,,,,**}
8768\def\inforefzzz #1,#2,#3,#4**{%
8769  \putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
8770  node \samp{\ignorespaces#1{}}}
8771
8772% @node's only job in TeX is to define \lastnode, which is used in
8773% cross-references.  The @node line might or might not have commas, and
8774% might or might not have spaces before the first comma, like:
8775% @node foo , bar , ...
8776% We don't want such trailing spaces in the node name.
8777%
8778\parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse}
8779%
8780% also remove a trailing comma, in case of something like this:
8781% @node Help-Cross,  ,  , Cross-refs
8782\def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse}
8783\def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}}
8784
8785\let\nwnode=\node
8786\let\lastnode=\empty
8787
8788% Write a cross-reference definition for the current node.  #1 is the
8789% type (Ynumbered, Yappendix, Ynothing).
8790%
8791\def\donoderef#1{%
8792  \ifx\lastnode\empty\else
8793    \setref{\lastnode}{#1}%
8794    \global\let\lastnode=\empty
8795  \fi
8796}
8797
8798% @anchor{NAME} -- define xref target at arbitrary point.
8799%
8800\newcount\savesfregister
8801%
8802\def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi}
8803\def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi}
8804\def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces}
8805
8806% \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an
8807% anchor), which consists of three parts:
8808% 1) NAME-title - the current sectioning name taken from \lastsection,
8809%                 or the anchor name.
8810% 2) NAME-snt   - section number and type, passed as the SNT arg, or
8811%                 empty for anchors.
8812% 3) NAME-pg    - the page number.
8813%
8814% This is called from \donoderef, \anchor, and \dofloat.  In the case of
8815% floats, there is an additional part, which is not written here:
8816% 4) NAME-lof   - the text as it should appear in a @listoffloats.
8817%
8818\def\setref#1#2{%
8819  \pdfmkdest{#1}%
8820  \iflinks
8821    {%
8822      \requireauxfile
8823      \atdummies  % preserve commands, but don't expand them
8824      % match definition in \xrdef, \refx, \xrefX.
8825      \def\value##1{##1}%
8826      \edef\writexrdef##1##2{%
8827	\write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef
8828	  ##1}{##2}}% these are parameters of \writexrdef
8829      }%
8830      \toks0 = \expandafter{\lastsection}%
8831      \immediate \writexrdef{title}{\the\toks0 }%
8832      \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc.
8833      \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout
8834    }%
8835  \fi
8836}
8837
8838% @xrefautosectiontitle on|off says whether @section(ing) names are used
8839% automatically in xrefs, if the third arg is not explicitly specified.
8840% This was provided as a "secret" @set xref-automatic-section-title
8841% variable, now it's official.
8842%
8843\parseargdef\xrefautomaticsectiontitle{%
8844  \def\temp{#1}%
8845  \ifx\temp\onword
8846    \expandafter\let\csname SETxref-automatic-section-title\endcsname
8847      = \empty
8848  \else\ifx\temp\offword
8849    \expandafter\let\csname SETxref-automatic-section-title\endcsname
8850      = \relax
8851  \else
8852    \errhelp = \EMsimple
8853    \errmessage{Unknown @xrefautomaticsectiontitle value `\temp',
8854                must be on|off}%
8855  \fi\fi
8856}
8857
8858%
8859% @xref, @pxref, and @ref generate cross-references.  For \xrefX, #1 is
8860% the node name, #2 the name of the Info cross-reference, #3 the printed
8861% node name, #4 the name of the Info file, #5 the name of the printed
8862% manual.  All but the node name can be omitted.
8863%
8864\def\pxref{\putwordsee{} \xrefXX}
8865\def\xref{\putwordSee{} \xrefXX}
8866\def\ref{\xrefXX}
8867
8868\def\xrefXX#1{\def\xrefXXarg{#1}\futurelet\tokenafterxref\xrefXXX}
8869\def\xrefXXX{\expandafter\xrefX\expandafter[\xrefXXarg,,,,,,,]}
8870%
8871\newbox\toprefbox
8872\newbox\printedrefnamebox
8873\newbox\infofilenamebox
8874\newbox\printedmanualbox
8875%
8876\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
8877  \unsepspaces
8878  %
8879  % Get args without leading/trailing spaces.
8880  \def\printedrefname{\ignorespaces #3}%
8881  \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}%
8882  %
8883  \def\infofilename{\ignorespaces #4}%
8884  \setbox\infofilenamebox = \hbox{\infofilename\unskip}%
8885  %
8886  \def\printedmanual{\ignorespaces #5}%
8887  \setbox\printedmanualbox  = \hbox{\printedmanual\unskip}%
8888  %
8889  % If the printed reference name (arg #3) was not explicitly given in
8890  % the @xref, figure out what we want to use.
8891  \ifdim \wd\printedrefnamebox = 0pt
8892    % No printed node name was explicitly given.
8893    \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax
8894      % Not auto section-title: use node name inside the square brackets.
8895      \def\printedrefname{\ignorespaces #1}%
8896    \else
8897      % Auto section-title: use chapter/section title inside
8898      % the square brackets if we have it.
8899      \ifdim \wd\printedmanualbox > 0pt
8900        % It is in another manual, so we don't have it; use node name.
8901        \def\printedrefname{\ignorespaces #1}%
8902      \else
8903        \ifhavexrefs
8904          % We (should) know the real title if we have the xref values.
8905          \def\printedrefname{\refx{#1-title}{}}%
8906        \else
8907          % Otherwise just copy the Info node name.
8908          \def\printedrefname{\ignorespaces #1}%
8909        \fi%
8910      \fi
8911    \fi
8912  \fi
8913  %
8914  % Make link in pdf output.
8915  \ifpdf
8916    % For pdfTeX and LuaTeX
8917    {\indexnofonts
8918     \makevalueexpandable
8919     \turnoffactive
8920     % This expands tokens, so do it after making catcode changes, so _
8921     % etc. don't get their TeX definitions.  This ignores all spaces in
8922     % #4, including (wrongly) those in the middle of the filename.
8923     \getfilename{#4}%
8924     %
8925     % This (wrongly) does not take account of leading or trailing
8926     % spaces in #1, which should be ignored.
8927     \setpdfdestname{#1}%
8928     %
8929     \ifx\pdfdestname\empty
8930       \def\pdfdestname{Top}% no empty targets
8931     \fi
8932     %
8933     \leavevmode
8934     \startlink attr{/Border [0 0 0]}%
8935     \ifnum\filenamelength>0
8936       goto file{\the\filename.pdf} name{\pdfdestname}%
8937     \else
8938       goto name{\pdfmkpgn{\pdfdestname}}%
8939     \fi
8940    }%
8941    \setcolor{\linkcolor}%
8942  \else
8943    \ifx\XeTeXrevision\thisisundefined
8944    \else
8945      % For XeTeX
8946      {\indexnofonts
8947       \makevalueexpandable
8948       \turnoffactive
8949       % This expands tokens, so do it after making catcode changes, so _
8950       % etc. don't get their TeX definitions.  This ignores all spaces in
8951       % #4, including (wrongly) those in the middle of the filename.
8952       \getfilename{#4}%
8953       %
8954       % This (wrongly) does not take account of leading or trailing
8955       % spaces in #1, which should be ignored.
8956       \setpdfdestname{#1}%
8957       %
8958       \ifx\pdfdestname\empty
8959         \def\pdfdestname{Top}% no empty targets
8960       \fi
8961       %
8962       \leavevmode
8963       \ifnum\filenamelength>0
8964         % With default settings,
8965         % XeTeX (xdvipdfmx) replaces link destination names with integers.
8966         % In this case, the replaced destination names of
8967         % remote PDFs are no longer known.  In order to avoid a replacement,
8968         % you can use xdvipdfmx's command line option `-C 0x0010'.
8969         % If you use XeTeX 0.99996+ (TeX Live 2016+),
8970         % this command line option is no longer necessary
8971         % because we can use the `dvipdfmx:config' special.
8972         \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A
8973           << /S /GoToR /F (\the\filename.pdf) /D (\pdfdestname) >> >>}%
8974       \else
8975         \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A
8976           << /S /GoTo /D (\pdfdestname) >> >>}%
8977       \fi
8978      }%
8979      \setcolor{\linkcolor}%
8980    \fi
8981  \fi
8982  {%
8983    % Have to otherify everything special to allow the \csname to
8984    % include an _ in the xref name, etc.
8985    \indexnofonts
8986    \turnoffactive
8987    \def\value##1{##1}%
8988    \expandafter\global\expandafter\let\expandafter\Xthisreftitle
8989      \csname XR#1-title\endcsname
8990  }%
8991  %
8992  % Float references are printed completely differently: "Figure 1.2"
8993  % instead of "[somenode], p.3".  \iffloat distinguishes them by
8994  % \Xthisreftitle being set to a magic string.
8995  \iffloat\Xthisreftitle
8996    % If the user specified the print name (third arg) to the ref,
8997    % print it instead of our usual "Figure 1.2".
8998    \ifdim\wd\printedrefnamebox = 0pt
8999      \refx{#1-snt}{}%
9000    \else
9001      \printedrefname
9002    \fi
9003    %
9004    % If the user also gave the printed manual name (fifth arg), append
9005    % "in MANUALNAME".
9006    \ifdim \wd\printedmanualbox > 0pt
9007      \space \putwordin{} \cite{\printedmanual}%
9008    \fi
9009  \else
9010    % node/anchor (non-float) references.
9011    %
9012    % If we use \unhbox to print the node names, TeX does not insert
9013    % empty discretionaries after hyphens, which means that it will not
9014    % find a line break at a hyphen in a node names.  Since some manuals
9015    % are best written with fairly long node names, containing hyphens,
9016    % this is a loss.  Therefore, we give the text of the node name
9017    % again, so it is as if TeX is seeing it for the first time.
9018    %
9019    \ifdim \wd\printedmanualbox > 0pt
9020      % Cross-manual reference with a printed manual name.
9021      %
9022      \crossmanualxref{\cite{\printedmanual\unskip}}%
9023    %
9024    \else\ifdim \wd\infofilenamebox > 0pt
9025      % Cross-manual reference with only an info filename (arg 4), no
9026      % printed manual name (arg 5).  This is essentially the same as
9027      % the case above; we output the filename, since we have nothing else.
9028      %
9029      \crossmanualxref{\code{\infofilename\unskip}}%
9030    %
9031    \else
9032      % Reference within this manual.
9033      %
9034      % _ (for example) has to be the character _ for the purposes of the
9035      % control sequence corresponding to the node, but it has to expand
9036      % into the usual \leavevmode...\vrule stuff for purposes of
9037      % printing. So we \turnoffactive for the \refx-snt, back on for the
9038      % printing, back off for the \refx-pg.
9039      {\turnoffactive
9040       % Only output a following space if the -snt ref is nonempty; for
9041       % @unnumbered and @anchor, it won't be.
9042       \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
9043       \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
9044      }%
9045      % output the `[mynode]' via the macro below so it can be overridden.
9046      \xrefprintnodename\printedrefname
9047      %
9048      % But we always want a comma and a space:
9049      ,\space
9050      %
9051      % output the `page 3'.
9052      \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
9053      % Add a , if xref followed by a space
9054      \if\space\noexpand\tokenafterxref ,%
9055      \else\ifx\	\tokenafterxref ,% @TAB
9056      \else\ifx\*\tokenafterxref ,%   @*
9057      \else\ifx\ \tokenafterxref ,%   @SPACE
9058      \else\ifx\
9059                \tokenafterxref ,%    @NL
9060      \else\ifx\tie\tokenafterxref ,% @tie
9061      \fi\fi\fi\fi\fi\fi
9062    \fi\fi
9063  \fi
9064  \endlink
9065\endgroup}
9066
9067% Output a cross-manual xref to #1.  Used just above (twice).
9068%
9069% Only include the text "Section ``foo'' in" if the foo is neither
9070% missing or Top.  Thus, @xref{,,,foo,The Foo Manual} outputs simply
9071% "see The Foo Manual", the idea being to refer to the whole manual.
9072%
9073% But, this being TeX, we can't easily compare our node name against the
9074% string "Top" while ignoring the possible spaces before and after in
9075% the input.  By adding the arbitrary 7sp below, we make it much less
9076% likely that a real node name would have the same width as "Top" (e.g.,
9077% in a monospaced font).  Hopefully it will never happen in practice.
9078%
9079% For the same basic reason, we retypeset the "Top" at every
9080% reference, since the current font is indeterminate.
9081%
9082\def\crossmanualxref#1{%
9083  \setbox\toprefbox = \hbox{Top\kern7sp}%
9084  \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}%
9085  \ifdim \wd2 > 7sp  % nonempty?
9086    \ifdim \wd2 = \wd\toprefbox \else  % same as Top?
9087      \putwordSection{} ``\printedrefname'' \putwordin{}\space
9088    \fi
9089  \fi
9090  #1%
9091}
9092
9093% This macro is called from \xrefX for the `[nodename]' part of xref
9094% output.  It's a separate macro only so it can be changed more easily,
9095% since square brackets don't work well in some documents.  Particularly
9096% one that Bob is working on :).
9097%
9098\def\xrefprintnodename#1{[#1]}
9099
9100% Things referred to by \setref.
9101%
9102\def\Ynothing{}
9103\def\Yomitfromtoc{}
9104\def\Ynumbered{%
9105  \ifnum\secno=0
9106    \putwordChapter@tie \the\chapno
9107  \else \ifnum\subsecno=0
9108    \putwordSection@tie \the\chapno.\the\secno
9109  \else \ifnum\subsubsecno=0
9110    \putwordSection@tie \the\chapno.\the\secno.\the\subsecno
9111  \else
9112    \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno
9113  \fi\fi\fi
9114}
9115\def\Yappendix{%
9116  \ifnum\secno=0
9117     \putwordAppendix@tie @char\the\appendixno{}%
9118  \else \ifnum\subsecno=0
9119     \putwordSection@tie @char\the\appendixno.\the\secno
9120  \else \ifnum\subsubsecno=0
9121    \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno
9122  \else
9123    \putwordSection@tie
9124      @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno
9125  \fi\fi\fi
9126}
9127
9128% \refx{NAME}{SUFFIX} - reference a cross-reference string named NAME.  SUFFIX
9129% is output afterwards if non-empty.
9130\def\refx#1#2{%
9131  \requireauxfile
9132  {%
9133    \indexnofonts
9134    \otherbackslash
9135    \def\value##1{##1}%
9136    \expandafter\global\expandafter\let\expandafter\thisrefX
9137      \csname XR#1\endcsname
9138  }%
9139  \ifx\thisrefX\relax
9140    % If not defined, say something at least.
9141    \angleleft un\-de\-fined\angleright
9142    \iflinks
9143      \ifhavexrefs
9144        {\toks0 = {#1}% avoid expansion of possibly-complex value
9145         \message{\linenumber Undefined cross reference `\the\toks0'.}}%
9146      \else
9147        \ifwarnedxrefs\else
9148          \global\warnedxrefstrue
9149          \message{Cross reference values unknown; you must run TeX again.}%
9150        \fi
9151      \fi
9152    \fi
9153  \else
9154    % It's defined, so just use it.
9155    \thisrefX
9156  \fi
9157  #2% Output the suffix in any case.
9158}
9159
9160% This is the macro invoked by entries in the aux file.  Define a control
9161% sequence for a cross-reference target (we prepend XR to the control sequence
9162% name to avoid collisions).  The value is the page number.  If this is a float
9163% type, we have more work to do.
9164%
9165\def\xrdef#1#2{%
9166  {% Expand the node or anchor name to remove control sequences.
9167   % \turnoffactive stops 8-bit characters being changed to commands
9168   % like @'e.  \refx does the same to retrieve the value in the definition.
9169    \indexnofonts
9170    \turnoffactive
9171    \def\value##1{##1}%
9172    \xdef\safexrefname{#1}%
9173  }%
9174  %
9175  \bgroup
9176    \expandafter\gdef\csname XR\safexrefname\endcsname{#2}%
9177  \egroup
9178  % We put the \gdef inside a group to avoid the definitions building up on
9179  % TeX's save stack, which can cause it to run out of space for aux files with
9180  % thousands of lines.  \gdef doesn't use the save stack, but \csname does
9181  % when it defines an unknown control sequence as \relax.
9182  %
9183  % Was that xref control sequence that we just defined for a float?
9184  \expandafter\iffloat\csname XR\safexrefname\endcsname
9185    % it was a float, and we have the (safe) float type in \iffloattype.
9186    \expandafter\let\expandafter\floatlist
9187      \csname floatlist\iffloattype\endcsname
9188    %
9189    % Is this the first time we've seen this float type?
9190    \expandafter\ifx\floatlist\relax
9191      \toks0 = {\do}% yes, so just \do
9192    \else
9193      % had it before, so preserve previous elements in list.
9194      \toks0 = \expandafter{\floatlist\do}%
9195    \fi
9196    %
9197    % Remember this xref in the control sequence \floatlistFLOATTYPE,
9198    % for later use in \listoffloats.
9199    \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0
9200      {\safexrefname}}%
9201  \fi
9202}
9203
9204% If working on a large document in chapters, it is convenient to
9205% be able to disable indexing, cross-referencing, and contents, for test runs.
9206% This is done with @novalidate at the beginning of the file.
9207%
9208\newif\iflinks \linkstrue % by default we want the aux files.
9209\let\novalidate = \linksfalse
9210
9211% Used when writing to the aux file, or when using data from it.
9212\def\requireauxfile{%
9213  \iflinks
9214    \tryauxfile
9215    % Open the new aux file.  TeX will close it automatically at exit.
9216    \immediate\openout\auxfile=\jobname.aux
9217  \fi
9218  \global\let\requireauxfile=\relax   % Only do this once.
9219}
9220
9221% Read the last existing aux file, if any.  No error if none exists.
9222%
9223\def\tryauxfile{%
9224  \openin 1 \jobname.aux
9225  \ifeof 1 \else
9226    \readdatafile{aux}%
9227    \global\havexrefstrue
9228  \fi
9229  \closein 1
9230}
9231
9232\def\setupdatafile{%
9233  \catcode`\^^@=\other
9234  \catcode`\^^A=\other
9235  \catcode`\^^B=\other
9236  \catcode`\^^C=\other
9237  \catcode`\^^D=\other
9238  \catcode`\^^E=\other
9239  \catcode`\^^F=\other
9240  \catcode`\^^G=\other
9241  \catcode`\^^H=\other
9242  \catcode`\^^K=\other
9243  \catcode`\^^L=\other
9244  \catcode`\^^N=\other
9245  \catcode`\^^P=\other
9246  \catcode`\^^Q=\other
9247  \catcode`\^^R=\other
9248  \catcode`\^^S=\other
9249  \catcode`\^^T=\other
9250  \catcode`\^^U=\other
9251  \catcode`\^^V=\other
9252  \catcode`\^^W=\other
9253  \catcode`\^^X=\other
9254  \catcode`\^^Z=\other
9255  \catcode`\^^[=\other
9256  \catcode`\^^\=\other
9257  \catcode`\^^]=\other
9258  \catcode`\^^^=\other
9259  \catcode`\^^_=\other
9260  % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc.
9261  % in xref tags, i.e., node names.  But since ^^e4 notation isn't
9262  % supported in the main text, it doesn't seem desirable.  Furthermore,
9263  % that is not enough: for node names that actually contain a ^
9264  % character, we would end up writing a line like this: 'xrdef {'hat
9265  % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first
9266  % argument, and \hat is not an expandable control sequence.  It could
9267  % all be worked out, but why?  Either we support ^^ or we don't.
9268  %
9269  % The other change necessary for this was to define \auxhat:
9270  % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter
9271  % and then to call \auxhat in \setq.
9272  %
9273  \catcode`\^=\other
9274  %
9275  % Special characters.  Should be turned off anyway, but...
9276  \catcode`\~=\other
9277  \catcode`\[=\other
9278  \catcode`\]=\other
9279  \catcode`\"=\other
9280  \catcode`\_=\other
9281  \catcode`\|=\other
9282  \catcode`\<=\other
9283  \catcode`\>=\other
9284  \catcode`\$=\other
9285  \catcode`\#=\other
9286  \catcode`\&=\other
9287  \catcode`\%=\other
9288  \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
9289  %
9290  % This is to support \ in node names and titles, since the \
9291  % characters end up in a \csname.  It's easier than
9292  % leaving it active and making its active definition an actual \
9293  % character.  What I don't understand is why it works in the *value*
9294  % of the xrdef.  Seems like it should be a catcode12 \, and that
9295  % should not typeset properly.  But it works, so I'm moving on for
9296  % now.  --karl, 15jan04.
9297  \catcode`\\=\other
9298  %
9299  % @ is our escape character in .aux files, and we need braces.
9300  \catcode`\{=1
9301  \catcode`\}=2
9302  \catcode`\@=0
9303}
9304
9305\def\readdatafile#1{%
9306\begingroup
9307  \setupdatafile
9308  \input\jobname.#1
9309\endgroup}
9310
9311
9312\message{insertions,}
9313% including footnotes.
9314
9315\newcount \footnoteno
9316
9317% The trailing space in the following definition for supereject is
9318% vital for proper filling; pages come out unaligned when you do a
9319% pagealignmacro call if that space before the closing brace is
9320% removed. (Generally, numeric constants should always be followed by a
9321% space to prevent strange expansion errors.)
9322\def\supereject{\par\penalty -20000\footnoteno =0 }
9323
9324% @footnotestyle is meaningful for Info output only.
9325\let\footnotestyle=\comment
9326
9327{\catcode `\@=11
9328%
9329% Auto-number footnotes.  Otherwise like plain.
9330\gdef\footnote{%
9331  \global\advance\footnoteno by \@ne
9332  \edef\thisfootno{$^{\the\footnoteno}$}%
9333  %
9334  % In case the footnote comes at the end of a sentence, preserve the
9335  % extra spacing after we do the footnote number.
9336  \let\@sf\empty
9337  \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi
9338  %
9339  % Remove inadvertent blank space before typesetting the footnote number.
9340  \unskip
9341  \thisfootno\@sf
9342  \dofootnote
9343}%
9344
9345% Don't bother with the trickery in plain.tex to not require the
9346% footnote text as a parameter.  Our footnotes don't need to be so general.
9347%
9348% Oh yes, they do; otherwise, @ifset (and anything else that uses
9349% \parseargline) fails inside footnotes because the tokens are fixed when
9350% the footnote is read.  --karl, 16nov96.
9351%
9352\gdef\dofootnote{%
9353  \insert\footins\bgroup
9354  %
9355  % Nested footnotes are not supported in TeX, that would take a lot
9356  % more work.  (\startsavinginserts does not suffice.)
9357  \let\footnote=\errfootnotenest
9358  %
9359  % We want to typeset this text as a normal paragraph, even if the
9360  % footnote reference occurs in (for example) a display environment.
9361  % So reset some parameters.
9362  \hsize=\txipagewidth
9363  \interlinepenalty\interfootnotelinepenalty
9364  \splittopskip\ht\strutbox % top baseline for broken footnotes
9365  \splitmaxdepth\dp\strutbox
9366  \floatingpenalty\@MM
9367  \leftskip\z@skip
9368  \rightskip\z@skip
9369  \spaceskip\z@skip
9370  \xspaceskip\z@skip
9371  \parindent\defaultparindent
9372  %
9373  \smallfonts \rm
9374  %
9375  % Because we use hanging indentation in footnotes, a @noindent appears
9376  % to exdent this text, so make it be a no-op.  makeinfo does not use
9377  % hanging indentation so @noindent can still be needed within footnote
9378  % text after an @example or the like (not that this is good style).
9379  \let\noindent = \relax
9380  %
9381  % Hang the footnote text off the number.  Use \everypar in case the
9382  % footnote extends for more than one paragraph.
9383  \everypar = {\hang}%
9384  \textindent{\thisfootno}%
9385  %
9386  % Don't crash into the line above the footnote text.  Since this
9387  % expands into a box, it must come within the paragraph, lest it
9388  % provide a place where TeX can split the footnote.
9389  \footstrut
9390  %
9391  % Invoke rest of plain TeX footnote routine.
9392  \futurelet\next\fo@t
9393}
9394}%end \catcode `\@=11
9395
9396\def\errfootnotenest{%
9397  \errhelp=\EMsimple
9398  \errmessage{Nested footnotes not supported in texinfo.tex,
9399    even though they work in makeinfo; sorry}
9400}
9401
9402\def\errfootnoteheading{%
9403  \errhelp=\EMsimple
9404  \errmessage{Footnotes in chapters, sections, etc., are not supported}
9405}
9406
9407% In case a @footnote appears in a vbox, save the footnote text and create
9408% the real \insert just after the vbox finished.  Otherwise, the insertion
9409% would be lost.
9410% Similarly, if a @footnote appears inside an alignment, save the footnote
9411% text to a box and make the \insert when a row of the table is finished.
9412% And the same can be done for other insert classes.  --kasal, 16nov03.
9413%
9414% Replace the \insert primitive by a cheating macro.
9415% Deeper inside, just make sure that the saved insertions are not spilled
9416% out prematurely.
9417%
9418\def\startsavinginserts{%
9419  \ifx \insert\ptexinsert
9420    \let\insert\saveinsert
9421  \else
9422    \let\checkinserts\relax
9423  \fi
9424}
9425
9426% This \insert replacement works for both \insert\footins{foo} and
9427% \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}.
9428%
9429\def\saveinsert#1{%
9430  \edef\next{\noexpand\savetobox \makeSAVEname#1}%
9431  \afterassignment\next
9432  % swallow the left brace
9433  \let\temp =
9434}
9435\def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}}
9436\def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1}
9437
9438\def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi}
9439
9440\def\placesaveins#1{%
9441  \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname
9442    {\box#1}%
9443}
9444
9445% eat @SAVE -- beware, all of them have catcode \other:
9446{
9447  \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials  %  ;-)
9448  \gdef\gobblesave @SAVE{}
9449}
9450
9451% initialization:
9452\def\newsaveins #1{%
9453  \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}%
9454  \next
9455}
9456\def\newsaveinsX #1{%
9457  \csname newbox\endcsname #1%
9458  \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts
9459    \checksaveins #1}%
9460}
9461
9462% initialize:
9463\let\checkinserts\empty
9464\newsaveins\footins
9465\newsaveins\margin
9466
9467
9468% @image.  We use the macros from epsf.tex to support this.
9469% If epsf.tex is not installed and @image is used, we complain.
9470%
9471% Check for and read epsf.tex up front.  If we read it only at @image
9472% time, we might be inside a group, and then its definitions would get
9473% undone and the next image would fail.
9474\openin 1 = epsf.tex
9475\ifeof 1 \else
9476  % Do not bother showing banner with epsf.tex v2.7k (available in
9477  % doc/epsf.tex and on ctan).
9478  \def\epsfannounce{\toks0 = }%
9479  \input epsf.tex
9480\fi
9481\closein 1
9482%
9483% We will only complain once about lack of epsf.tex.
9484\newif\ifwarnednoepsf
9485\newhelp\noepsfhelp{epsf.tex must be installed for images to
9486  work.  It is also included in the Texinfo distribution, or you can get
9487  it from https://ctan.org/texarchive/macros/texinfo/texinfo/doc/epsf.tex.}
9488%
9489\def\image#1{%
9490  \ifx\epsfbox\thisisundefined
9491    \ifwarnednoepsf \else
9492      \errhelp = \noepsfhelp
9493      \errmessage{epsf.tex not found, images will be ignored}%
9494      \global\warnednoepsftrue
9495    \fi
9496  \else
9497    \imagexxx #1,,,,,\finish
9498  \fi
9499}
9500%
9501% Arguments to @image:
9502% #1 is (mandatory) image filename; we tack on .eps extension.
9503% #2 is (optional) width, #3 is (optional) height.
9504% #4 is (ignored optional) html alt text.
9505% #5 is (ignored optional) extension.
9506% #6 is just the usual extra ignored arg for parsing stuff.
9507\newif\ifimagevmode
9508\def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup
9509  \catcode`\^^M = 5     % in case we're inside an example
9510  \normalturnoffactive  % allow _ et al. in names
9511  \def\xprocessmacroarg{\eatspaces}% in case we are being used via a macro
9512  % If the image is by itself, center it.
9513  \ifvmode
9514    \imagevmodetrue
9515  \else \ifx\centersub\centerV
9516    % for @center @image, we need a vbox so we can have our vertical space
9517    \imagevmodetrue
9518    \vbox\bgroup % vbox has better behavior than vtop herev
9519  \fi\fi
9520  %
9521  \ifimagevmode
9522    \nobreak\medskip
9523    % Usually we'll have text after the image which will insert
9524    % \parskip glue, so insert it here too to equalize the space
9525    % above and below.
9526    \nobreak\vskip\parskip
9527    \nobreak
9528  \fi
9529  %
9530  % Leave vertical mode so that indentation from an enclosing
9531  %  environment such as @quotation is respected.
9532  % However, if we're at the top level, we don't want the
9533  %  normal paragraph indentation.
9534  % On the other hand, if we are in the case of @center @image, we don't
9535  %  want to start a paragraph, which will create a hsize-width box and
9536  %  eradicate the centering.
9537  \ifx\centersub\centerV\else \noindent \fi
9538  %
9539  % Output the image.
9540  \ifpdf
9541    % For pdfTeX and LuaTeX <= 0.80
9542    \dopdfimage{#1}{#2}{#3}%
9543  \else
9544    \ifx\XeTeXrevision\thisisundefined
9545      % For epsf.tex
9546      % \epsfbox itself resets \epsf?size at each figure.
9547      \setbox0 = \hbox{\ignorespaces #2}%
9548        \ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
9549      \setbox0 = \hbox{\ignorespaces #3}%
9550        \ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
9551      \epsfbox{#1.eps}%
9552    \else
9553      % For XeTeX
9554      \doxeteximage{#1}{#2}{#3}%
9555    \fi
9556  \fi
9557  %
9558  \ifimagevmode
9559    \medskip  % space after a standalone image
9560  \fi
9561  \ifx\centersub\centerV \egroup \fi
9562\endgroup}
9563
9564
9565% @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables,
9566% etc.  We don't actually implement floating yet, we always include the
9567% float "here".  But it seemed the best name for the future.
9568%
9569\envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish}
9570
9571% There may be a space before second and/or third parameter; delete it.
9572\def\eatcommaspace#1, {#1,}
9573
9574% #1 is the optional FLOATTYPE, the text label for this float, typically
9575% "Figure", "Table", "Example", etc.  Can't contain commas.  If omitted,
9576% this float will not be numbered and cannot be referred to.
9577%
9578% #2 is the optional xref label.  Also must be present for the float to
9579% be referable.
9580%
9581% #3 is the optional positioning argument; for now, it is ignored.  It
9582% will somehow specify the positions allowed to float to (here, top, bottom).
9583%
9584% We keep a separate counter for each FLOATTYPE, which we reset at each
9585% chapter-level command.
9586\let\resetallfloatnos=\empty
9587%
9588\def\dofloat#1,#2,#3,#4\finish{%
9589  \let\thiscaption=\empty
9590  \let\thisshortcaption=\empty
9591  %
9592  % don't lose footnotes inside @float.
9593  %
9594  % BEWARE: when the floats start float, we have to issue warning whenever an
9595  % insert appears inside a float which could possibly float. --kasal, 26may04
9596  %
9597  \startsavinginserts
9598  %
9599  % We can't be used inside a paragraph.
9600  \par
9601  %
9602  \vtop\bgroup
9603    \def\floattype{#1}%
9604    \def\floatlabel{#2}%
9605    \def\floatloc{#3}% we do nothing with this yet.
9606    %
9607    \ifx\floattype\empty
9608      \let\safefloattype=\empty
9609    \else
9610      {%
9611        % the floattype might have accents or other special characters,
9612        % but we need to use it in a control sequence name.
9613        \indexnofonts
9614        \turnoffactive
9615        \xdef\safefloattype{\floattype}%
9616      }%
9617    \fi
9618    %
9619    % If label is given but no type, we handle that as the empty type.
9620    \ifx\floatlabel\empty \else
9621      % We want each FLOATTYPE to be numbered separately (Figure 1,
9622      % Table 1, Figure 2, ...).  (And if no label, no number.)
9623      %
9624      \expandafter\getfloatno\csname\safefloattype floatno\endcsname
9625      \global\advance\floatno by 1
9626      %
9627      {%
9628        % This magic value for \lastsection is output by \setref as the
9629        % XREFLABEL-title value.  \xrefX uses it to distinguish float
9630        % labels (which have a completely different output format) from
9631        % node and anchor labels.  And \xrdef uses it to construct the
9632        % lists of floats.
9633        %
9634        \edef\lastsection{\floatmagic=\safefloattype}%
9635        \setref{\floatlabel}{Yfloat}%
9636      }%
9637    \fi
9638    %
9639    % start with \parskip glue, I guess.
9640    \vskip\parskip
9641    %
9642    % Don't suppress indentation if a float happens to start a section.
9643    \restorefirstparagraphindent
9644}
9645
9646% we have these possibilities:
9647% @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap
9648% @float Foo,lbl & no caption:    Foo 1.1
9649% @float Foo & @caption{Cap}:     Foo: Cap
9650% @float Foo & no caption:        Foo
9651% @float ,lbl & Caption{Cap}:     1.1: Cap
9652% @float ,lbl & no caption:       1.1
9653% @float & @caption{Cap}:         Cap
9654% @float & no caption:
9655%
9656\def\Efloat{%
9657    \let\floatident = \empty
9658    %
9659    % In all cases, if we have a float type, it comes first.
9660    \ifx\floattype\empty \else \def\floatident{\floattype}\fi
9661    %
9662    % If we have an xref label, the number comes next.
9663    \ifx\floatlabel\empty \else
9664      \ifx\floattype\empty \else % if also had float type, need tie first.
9665        \appendtomacro\floatident{\tie}%
9666      \fi
9667      % the number.
9668      \appendtomacro\floatident{\chaplevelprefix\the\floatno}%
9669    \fi
9670    %
9671    % Start the printed caption with what we've constructed in
9672    % \floatident, but keep it separate; we need \floatident again.
9673    \let\captionline = \floatident
9674    %
9675    \ifx\thiscaption\empty \else
9676      \ifx\floatident\empty \else
9677        \appendtomacro\captionline{: }% had ident, so need a colon between
9678      \fi
9679      %
9680      % caption text.
9681      \appendtomacro\captionline{\scanexp\thiscaption}%
9682    \fi
9683    %
9684    % If we have anything to print, print it, with space before.
9685    % Eventually this needs to become an \insert.
9686    \ifx\captionline\empty \else
9687      \vskip.5\parskip
9688      \captionline
9689      %
9690      % Space below caption.
9691      \vskip\parskip
9692    \fi
9693    %
9694    % If have an xref label, write the list of floats info.  Do this
9695    % after the caption, to avoid chance of it being a breakpoint.
9696    \ifx\floatlabel\empty \else
9697      % Write the text that goes in the lof to the aux file as
9698      % \floatlabel-lof.  Besides \floatident, we include the short
9699      % caption if specified, else the full caption if specified, else nothing.
9700      {%
9701        \requireauxfile
9702        \atdummies
9703        %
9704        \ifx\thisshortcaption\empty
9705          \def\gtemp{\thiscaption}%
9706        \else
9707          \def\gtemp{\thisshortcaption}%
9708        \fi
9709        \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident
9710          \ifx\gtemp\empty \else : \gtemp \fi}}%
9711      }%
9712    \fi
9713  \egroup  % end of \vtop
9714  %
9715  \checkinserts
9716}
9717
9718% Append the tokens #2 to the definition of macro #1, not expanding either.
9719%
9720\def\appendtomacro#1#2{%
9721  \expandafter\def\expandafter#1\expandafter{#1#2}%
9722}
9723
9724% @caption, @shortcaption
9725%
9726\def\caption{\docaption\thiscaption}
9727\def\shortcaption{\docaption\thisshortcaption}
9728\def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption}
9729\def\defcaption#1#2{\egroup \def#1{#2}}
9730
9731% The parameter is the control sequence identifying the counter we are
9732% going to use.  Create it if it doesn't exist and assign it to \floatno.
9733\def\getfloatno#1{%
9734  \ifx#1\relax
9735      % Haven't seen this figure type before.
9736      \csname newcount\endcsname #1%
9737      %
9738      % Remember to reset this floatno at the next chap.
9739      \expandafter\gdef\expandafter\resetallfloatnos
9740        \expandafter{\resetallfloatnos #1=0 }%
9741  \fi
9742  \let\floatno#1%
9743}
9744
9745% \setref calls this to get the XREFLABEL-snt value.  We want an @xref
9746% to the FLOATLABEL to expand to "Figure 3.1".  We call \setref when we
9747% first read the @float command.
9748%
9749\def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}%
9750
9751% Magic string used for the XREFLABEL-title value, so \xrefX can
9752% distinguish floats from other xref types.
9753\def\floatmagic{!!float!!}
9754
9755% #1 is the control sequence we are passed; we expand into a conditional
9756% which is true if #1 represents a float ref.  That is, the magic
9757% \lastsection value which we \setref above.
9758%
9759\def\iffloat#1{\expandafter\doiffloat#1==\finish}
9760%
9761% #1 is (maybe) the \floatmagic string.  If so, #2 will be the
9762% (safe) float type for this float.  We set \iffloattype to #2.
9763%
9764\def\doiffloat#1=#2=#3\finish{%
9765  \def\temp{#1}%
9766  \def\iffloattype{#2}%
9767  \ifx\temp\floatmagic
9768}
9769
9770% @listoffloats FLOATTYPE - print a list of floats like a table of contents.
9771%
9772\parseargdef\listoffloats{%
9773  \def\floattype{#1}% floattype
9774  {%
9775    % the floattype might have accents or other special characters,
9776    % but we need to use it in a control sequence name.
9777    \indexnofonts
9778    \turnoffactive
9779    \xdef\safefloattype{\floattype}%
9780  }%
9781  %
9782  % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE.
9783  \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax
9784    \ifhavexrefs
9785      % if the user said @listoffloats foo but never @float foo.
9786      \message{\linenumber No `\safefloattype' floats to list.}%
9787    \fi
9788  \else
9789    \begingroup
9790      \leftskip=\tocindent  % indent these entries like a toc
9791      \let\do=\listoffloatsdo
9792      \csname floatlist\safefloattype\endcsname
9793    \endgroup
9794  \fi
9795}
9796
9797% This is called on each entry in a list of floats.  We're passed the
9798% xref label, in the form LABEL-title, which is how we save it in the
9799% aux file.  We strip off the -title and look up \XRLABEL-lof, which
9800% has the text we're supposed to typeset here.
9801%
9802% Figures without xref labels will not be included in the list (since
9803% they won't appear in the aux file).
9804%
9805\def\listoffloatsdo#1{\listoffloatsdoentry#1\finish}
9806\def\listoffloatsdoentry#1-title\finish{{%
9807  % Can't fully expand XR#1-lof because it can contain anything.  Just
9808  % pass the control sequence.  On the other hand, XR#1-pg is just the
9809  % page number, and we want to fully expand that so we can get a link
9810  % in pdf output.
9811  \toksA = \expandafter{\csname XR#1-lof\endcsname}%
9812  %
9813  % use the same \entry macro we use to generate the TOC and index.
9814  \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}%
9815  \writeentry
9816}}
9817
9818
9819\message{localization,}
9820
9821% For single-language documents, @documentlanguage is usually given very
9822% early, just after @documentencoding.  Single argument is the language
9823% (de) or locale (de_DE) abbreviation.
9824%
9825{
9826  \catcode`\_ = \active
9827  \globaldefs=1
9828\parseargdef\documentlanguage{%
9829  \tex % read txi-??.tex file in plain TeX.
9830    % Read the file by the name they passed if it exists.
9831    \let_ = \normalunderscore  % normal _ character for filename test
9832    \openin 1 txi-#1.tex
9833    \ifeof 1
9834      \documentlanguagetrywithoutunderscore #1_\finish
9835    \else
9836      \globaldefs = 1  % everything in the txi-LL files needs to persist
9837      \input txi-#1.tex
9838    \fi
9839    \closein 1
9840  \endgroup % end raw TeX
9841}
9842%
9843% If they passed de_DE, and txi-de_DE.tex doesn't exist,
9844% try txi-de.tex.
9845%
9846\gdef\documentlanguagetrywithoutunderscore#1_#2\finish{%
9847  \openin 1 txi-#1.tex
9848  \ifeof 1
9849    \errhelp = \nolanghelp
9850    \errmessage{Cannot read language file txi-#1.tex}%
9851  \else
9852    \globaldefs = 1  % everything in the txi-LL files needs to persist
9853    \input txi-#1.tex
9854  \fi
9855  \closein 1
9856}
9857}% end of special _ catcode
9858%
9859\newhelp\nolanghelp{The given language definition file cannot be found or
9860is empty.  Maybe you need to install it?  Putting it in the current
9861directory should work if nowhere else does.}
9862
9863% This macro is called from txi-??.tex files; the first argument is the
9864% \language name to set (without the "\lang@" prefix), the second and
9865% third args are \{left,right}hyphenmin.
9866%
9867% The language names to pass are determined when the format is built.
9868% See the etex.log file created at that time, e.g.,
9869% /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log.
9870%
9871% With TeX Live 2008, etex now includes hyphenation patterns for all
9872% available languages.  This means we can support hyphenation in
9873% Texinfo, at least to some extent.  (This still doesn't solve the
9874% accented characters problem.)
9875%
9876\catcode`@=11
9877\def\txisetlanguage#1#2#3{%
9878  % do not set the language if the name is undefined in the current TeX.
9879  \expandafter\ifx\csname lang@#1\endcsname \relax
9880    \message{no patterns for #1}%
9881  \else
9882    \global\language = \csname lang@#1\endcsname
9883  \fi
9884  % but there is no harm in adjusting the hyphenmin values regardless.
9885  \global\lefthyphenmin = #2\relax
9886  \global\righthyphenmin = #3\relax
9887}
9888
9889% XeTeX and LuaTeX can handle Unicode natively.
9890% Their default I/O uses UTF-8 sequences instead of a byte-wise operation.
9891% Other TeX engines' I/O (pdfTeX, etc.) is byte-wise.
9892%
9893\newif\iftxinativeunicodecapable
9894\newif\iftxiusebytewiseio
9895
9896\ifx\XeTeXrevision\thisisundefined
9897  \ifx\luatexversion\thisisundefined
9898    \txinativeunicodecapablefalse
9899    \txiusebytewiseiotrue
9900  \else
9901    \txinativeunicodecapabletrue
9902    \txiusebytewiseiofalse
9903  \fi
9904\else
9905  \txinativeunicodecapabletrue
9906  \txiusebytewiseiofalse
9907\fi
9908
9909% Set I/O by bytes instead of UTF-8 sequence for XeTeX and LuaTex
9910% for non-UTF-8 (byte-wise) encodings.
9911%
9912\def\setbytewiseio{%
9913  \ifx\XeTeXrevision\thisisundefined
9914  \else
9915    \XeTeXdefaultencoding "bytes"  % For subsequent files to be read
9916    \XeTeXinputencoding "bytes"  % For document root file
9917    % Unfortunately, there seems to be no corresponding XeTeX command for
9918    % output encoding.  This is a problem for auxiliary index and TOC files.
9919    % The only solution would be perhaps to write out @U{...} sequences in
9920    % place of non-ASCII characters.
9921  \fi
9922
9923  \ifx\luatexversion\thisisundefined
9924  \else
9925    \directlua{
9926    local utf8_char, byte, gsub = unicode.utf8.char, string.byte, string.gsub
9927    local function convert_char (char)
9928      return utf8_char(byte(char))
9929    end
9930
9931    local function convert_line (line)
9932      return gsub(line, ".", convert_char)
9933    end
9934
9935    callback.register("process_input_buffer", convert_line)
9936
9937    local function convert_line_out (line)
9938      local line_out = ""
9939      for c in string.utfvalues(line) do
9940         line_out = line_out .. string.char(c)
9941      end
9942      return line_out
9943    end
9944
9945    callback.register("process_output_buffer", convert_line_out)
9946    }
9947  \fi
9948
9949  \txiusebytewiseiotrue
9950}
9951
9952
9953% Helpers for encodings.
9954% Set the catcode of characters 128 through 255 to the specified number.
9955%
9956\def\setnonasciicharscatcode#1{%
9957   \count255=128
9958   \loop\ifnum\count255<256
9959      \global\catcode\count255=#1\relax
9960      \advance\count255 by 1
9961   \repeat
9962}
9963
9964\def\setnonasciicharscatcodenonglobal#1{%
9965   \count255=128
9966   \loop\ifnum\count255<256
9967      \catcode\count255=#1\relax
9968      \advance\count255 by 1
9969   \repeat
9970}
9971
9972% @documentencoding sets the definition of non-ASCII characters
9973% according to the specified encoding.
9974%
9975\def\documentencoding{\parseargusing\filenamecatcodes\documentencodingzzz}
9976\def\documentencodingzzz#1{%
9977  %
9978  % Encoding being declared for the document.
9979  \def\declaredencoding{\csname #1.enc\endcsname}%
9980  %
9981  % Supported encodings: names converted to tokens in order to be able
9982  % to compare them with \ifx.
9983  \def\ascii{\csname US-ASCII.enc\endcsname}%
9984  \def\latnine{\csname ISO-8859-15.enc\endcsname}%
9985  \def\latone{\csname ISO-8859-1.enc\endcsname}%
9986  \def\lattwo{\csname ISO-8859-2.enc\endcsname}%
9987  \def\utfeight{\csname UTF-8.enc\endcsname}%
9988  %
9989  \ifx \declaredencoding \ascii
9990     \asciichardefs
9991  %
9992  \else \ifx \declaredencoding \lattwo
9993     \iftxinativeunicodecapable
9994       \setbytewiseio
9995     \fi
9996     \setnonasciicharscatcode\active
9997     \lattwochardefs
9998  %
9999  \else \ifx \declaredencoding \latone
10000     \iftxinativeunicodecapable
10001       \setbytewiseio
10002     \fi
10003     \setnonasciicharscatcode\active
10004     \latonechardefs
10005  %
10006  \else \ifx \declaredencoding \latnine
10007     \iftxinativeunicodecapable
10008       \setbytewiseio
10009     \fi
10010     \setnonasciicharscatcode\active
10011     \latninechardefs
10012  %
10013  \else \ifx \declaredencoding \utfeight
10014     \iftxinativeunicodecapable
10015       % For native Unicode handling (XeTeX and LuaTeX)
10016       \nativeunicodechardefs
10017     \else
10018       % For treating UTF-8 as byte sequences (TeX, eTeX and pdfTeX)
10019       \setnonasciicharscatcode\active
10020       % since we already invoked \utfeightchardefs at the top level
10021       % (below), do not re-invoke it, otherwise our check for duplicated
10022       % definitions gets triggered.  Making non-ascii chars active is
10023       % sufficient.
10024     \fi
10025  %
10026  \else
10027    \message{Ignoring unknown document encoding: #1.}%
10028  %
10029  \fi % utfeight
10030  \fi % latnine
10031  \fi % latone
10032  \fi % lattwo
10033  \fi % ascii
10034  %
10035  \ifx\XeTeXrevision\thisisundefined
10036  \else
10037    \ifx \declaredencoding \utfeight
10038    \else
10039      \ifx \declaredencoding \ascii
10040      \else
10041        \message{Warning: XeTeX with non-UTF-8 encodings cannot handle %
10042        non-ASCII characters in auxiliary files.}%
10043      \fi
10044    \fi
10045  \fi
10046}
10047
10048% emacs-page
10049% A message to be logged when using a character that isn't available
10050% the default font encoding (OT1).
10051%
10052\def\missingcharmsg#1{\message{Character missing, sorry: #1.}}
10053
10054% Take account of \c (plain) vs. \, (Texinfo) difference.
10055\def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi}
10056
10057% First, make active non-ASCII characters in order for them to be
10058% correctly categorized when TeX reads the replacement text of
10059% macros containing the character definitions.
10060\setnonasciicharscatcode\active
10061%
10062
10063\def\gdefchar#1#2{%
10064\gdef#1{%
10065   \ifpassthroughchars
10066     \string#1%
10067   \else
10068     #2%
10069   \fi
10070}}
10071
10072% Latin1 (ISO-8859-1) character definitions.
10073\def\latonechardefs{%
10074  \gdefchar^^a0{\tie}
10075  \gdefchar^^a1{\exclamdown}
10076  \gdefchar^^a2{{\tcfont \char162}} % cent
10077  \gdefchar^^a3{\pounds{}}
10078  \gdefchar^^a4{{\tcfont \char164}} % currency
10079  \gdefchar^^a5{{\tcfont \char165}} % yen
10080  \gdefchar^^a6{{\tcfont \char166}} % broken bar
10081  \gdefchar^^a7{\S}
10082  \gdefchar^^a8{\"{}}
10083  \gdefchar^^a9{\copyright{}}
10084  \gdefchar^^aa{\ordf}
10085  \gdefchar^^ab{\guillemetleft{}}
10086  \gdefchar^^ac{\ensuremath\lnot}
10087  \gdefchar^^ad{\-}
10088  \gdefchar^^ae{\registeredsymbol{}}
10089  \gdefchar^^af{\={}}
10090  %
10091  \gdefchar^^b0{\textdegree}
10092  \gdefchar^^b1{$\pm$}
10093  \gdefchar^^b2{$^2$}
10094  \gdefchar^^b3{$^3$}
10095  \gdefchar^^b4{\'{}}
10096  \gdefchar^^b5{$\mu$}
10097  \gdefchar^^b6{\P}
10098  \gdefchar^^b7{\ensuremath\cdot}
10099  \gdefchar^^b8{\cedilla\ }
10100  \gdefchar^^b9{$^1$}
10101  \gdefchar^^ba{\ordm}
10102  \gdefchar^^bb{\guillemetright{}}
10103  \gdefchar^^bc{$1\over4$}
10104  \gdefchar^^bd{$1\over2$}
10105  \gdefchar^^be{$3\over4$}
10106  \gdefchar^^bf{\questiondown}
10107  %
10108  \gdefchar^^c0{\`A}
10109  \gdefchar^^c1{\'A}
10110  \gdefchar^^c2{\^A}
10111  \gdefchar^^c3{\~A}
10112  \gdefchar^^c4{\"A}
10113  \gdefchar^^c5{\ringaccent A}
10114  \gdefchar^^c6{\AE}
10115  \gdefchar^^c7{\cedilla C}
10116  \gdefchar^^c8{\`E}
10117  \gdefchar^^c9{\'E}
10118  \gdefchar^^ca{\^E}
10119  \gdefchar^^cb{\"E}
10120  \gdefchar^^cc{\`I}
10121  \gdefchar^^cd{\'I}
10122  \gdefchar^^ce{\^I}
10123  \gdefchar^^cf{\"I}
10124  %
10125  \gdefchar^^d0{\DH}
10126  \gdefchar^^d1{\~N}
10127  \gdefchar^^d2{\`O}
10128  \gdefchar^^d3{\'O}
10129  \gdefchar^^d4{\^O}
10130  \gdefchar^^d5{\~O}
10131  \gdefchar^^d6{\"O}
10132  \gdefchar^^d7{$\times$}
10133  \gdefchar^^d8{\O}
10134  \gdefchar^^d9{\`U}
10135  \gdefchar^^da{\'U}
10136  \gdefchar^^db{\^U}
10137  \gdefchar^^dc{\"U}
10138  \gdefchar^^dd{\'Y}
10139  \gdefchar^^de{\TH}
10140  \gdefchar^^df{\ss}
10141  %
10142  \gdefchar^^e0{\`a}
10143  \gdefchar^^e1{\'a}
10144  \gdefchar^^e2{\^a}
10145  \gdefchar^^e3{\~a}
10146  \gdefchar^^e4{\"a}
10147  \gdefchar^^e5{\ringaccent a}
10148  \gdefchar^^e6{\ae}
10149  \gdefchar^^e7{\cedilla c}
10150  \gdefchar^^e8{\`e}
10151  \gdefchar^^e9{\'e}
10152  \gdefchar^^ea{\^e}
10153  \gdefchar^^eb{\"e}
10154  \gdefchar^^ec{\`{\dotless i}}
10155  \gdefchar^^ed{\'{\dotless i}}
10156  \gdefchar^^ee{\^{\dotless i}}
10157  \gdefchar^^ef{\"{\dotless i}}
10158  %
10159  \gdefchar^^f0{\dh}
10160  \gdefchar^^f1{\~n}
10161  \gdefchar^^f2{\`o}
10162  \gdefchar^^f3{\'o}
10163  \gdefchar^^f4{\^o}
10164  \gdefchar^^f5{\~o}
10165  \gdefchar^^f6{\"o}
10166  \gdefchar^^f7{$\div$}
10167  \gdefchar^^f8{\o}
10168  \gdefchar^^f9{\`u}
10169  \gdefchar^^fa{\'u}
10170  \gdefchar^^fb{\^u}
10171  \gdefchar^^fc{\"u}
10172  \gdefchar^^fd{\'y}
10173  \gdefchar^^fe{\th}
10174  \gdefchar^^ff{\"y}
10175}
10176
10177% Latin9 (ISO-8859-15) encoding character definitions.
10178\def\latninechardefs{%
10179  % Encoding is almost identical to Latin1.
10180  \latonechardefs
10181  %
10182  \gdefchar^^a4{\euro{}}
10183  \gdefchar^^a6{\v S}
10184  \gdefchar^^a8{\v s}
10185  \gdefchar^^b4{\v Z}
10186  \gdefchar^^b8{\v z}
10187  \gdefchar^^bc{\OE}
10188  \gdefchar^^bd{\oe}
10189  \gdefchar^^be{\"Y}
10190}
10191
10192% Latin2 (ISO-8859-2) character definitions.
10193\def\lattwochardefs{%
10194  \gdefchar^^a0{\tie}
10195  \gdefchar^^a1{\ogonek{A}}
10196  \gdefchar^^a2{\u{}}
10197  \gdefchar^^a3{\L}
10198  \gdefchar^^a4{\missingcharmsg{CURRENCY SIGN}}
10199  \gdefchar^^a5{\v L}
10200  \gdefchar^^a6{\'S}
10201  \gdefchar^^a7{\S}
10202  \gdefchar^^a8{\"{}}
10203  \gdefchar^^a9{\v S}
10204  \gdefchar^^aa{\cedilla S}
10205  \gdefchar^^ab{\v T}
10206  \gdefchar^^ac{\'Z}
10207  \gdefchar^^ad{\-}
10208  \gdefchar^^ae{\v Z}
10209  \gdefchar^^af{\dotaccent Z}
10210  %
10211  \gdefchar^^b0{\textdegree{}}
10212  \gdefchar^^b1{\ogonek{a}}
10213  \gdefchar^^b2{\ogonek{ }}
10214  \gdefchar^^b3{\l}
10215  \gdefchar^^b4{\'{}}
10216  \gdefchar^^b5{\v l}
10217  \gdefchar^^b6{\'s}
10218  \gdefchar^^b7{\v{}}
10219  \gdefchar^^b8{\cedilla\ }
10220  \gdefchar^^b9{\v s}
10221  \gdefchar^^ba{\cedilla s}
10222  \gdefchar^^bb{\v t}
10223  \gdefchar^^bc{\'z}
10224  \gdefchar^^bd{\H{}}
10225  \gdefchar^^be{\v z}
10226  \gdefchar^^bf{\dotaccent z}
10227  %
10228  \gdefchar^^c0{\'R}
10229  \gdefchar^^c1{\'A}
10230  \gdefchar^^c2{\^A}
10231  \gdefchar^^c3{\u A}
10232  \gdefchar^^c4{\"A}
10233  \gdefchar^^c5{\'L}
10234  \gdefchar^^c6{\'C}
10235  \gdefchar^^c7{\cedilla C}
10236  \gdefchar^^c8{\v C}
10237  \gdefchar^^c9{\'E}
10238  \gdefchar^^ca{\ogonek{E}}
10239  \gdefchar^^cb{\"E}
10240  \gdefchar^^cc{\v E}
10241  \gdefchar^^cd{\'I}
10242  \gdefchar^^ce{\^I}
10243  \gdefchar^^cf{\v D}
10244  %
10245  \gdefchar^^d0{\DH}
10246  \gdefchar^^d1{\'N}
10247  \gdefchar^^d2{\v N}
10248  \gdefchar^^d3{\'O}
10249  \gdefchar^^d4{\^O}
10250  \gdefchar^^d5{\H O}
10251  \gdefchar^^d6{\"O}
10252  \gdefchar^^d7{$\times$}
10253  \gdefchar^^d8{\v R}
10254  \gdefchar^^d9{\ringaccent U}
10255  \gdefchar^^da{\'U}
10256  \gdefchar^^db{\H U}
10257  \gdefchar^^dc{\"U}
10258  \gdefchar^^dd{\'Y}
10259  \gdefchar^^de{\cedilla T}
10260  \gdefchar^^df{\ss}
10261  %
10262  \gdefchar^^e0{\'r}
10263  \gdefchar^^e1{\'a}
10264  \gdefchar^^e2{\^a}
10265  \gdefchar^^e3{\u a}
10266  \gdefchar^^e4{\"a}
10267  \gdefchar^^e5{\'l}
10268  \gdefchar^^e6{\'c}
10269  \gdefchar^^e7{\cedilla c}
10270  \gdefchar^^e8{\v c}
10271  \gdefchar^^e9{\'e}
10272  \gdefchar^^ea{\ogonek{e}}
10273  \gdefchar^^eb{\"e}
10274  \gdefchar^^ec{\v e}
10275  \gdefchar^^ed{\'{\dotless{i}}}
10276  \gdefchar^^ee{\^{\dotless{i}}}
10277  \gdefchar^^ef{\v d}
10278  %
10279  \gdefchar^^f0{\dh}
10280  \gdefchar^^f1{\'n}
10281  \gdefchar^^f2{\v n}
10282  \gdefchar^^f3{\'o}
10283  \gdefchar^^f4{\^o}
10284  \gdefchar^^f5{\H o}
10285  \gdefchar^^f6{\"o}
10286  \gdefchar^^f7{$\div$}
10287  \gdefchar^^f8{\v r}
10288  \gdefchar^^f9{\ringaccent u}
10289  \gdefchar^^fa{\'u}
10290  \gdefchar^^fb{\H u}
10291  \gdefchar^^fc{\"u}
10292  \gdefchar^^fd{\'y}
10293  \gdefchar^^fe{\cedilla t}
10294  \gdefchar^^ff{\dotaccent{}}
10295}
10296
10297% UTF-8 character definitions.
10298%
10299% This code to support UTF-8 is based on LaTeX's utf8.def, with some
10300% changes for Texinfo conventions.  It is included here under the GPL by
10301% permission from Frank Mittelbach and the LaTeX team.
10302%
10303\newcount\countUTFx
10304\newcount\countUTFy
10305\newcount\countUTFz
10306
10307\gdef\UTFviiiTwoOctets#1#2{\expandafter
10308   \UTFviiiDefined\csname u8:#1\string #2\endcsname}
10309%
10310\gdef\UTFviiiThreeOctets#1#2#3{\expandafter
10311   \UTFviiiDefined\csname u8:#1\string #2\string #3\endcsname}
10312%
10313\gdef\UTFviiiFourOctets#1#2#3#4{\expandafter
10314   \UTFviiiDefined\csname u8:#1\string #2\string #3\string #4\endcsname}
10315
10316\gdef\UTFviiiDefined#1{%
10317  \ifx #1\relax
10318    \message{\linenumber Unicode char \string #1 not defined for Texinfo}%
10319  \else
10320    \expandafter #1%
10321  \fi
10322}
10323
10324% Give non-ASCII bytes the active definitions for processing UTF-8 sequences
10325\begingroup
10326  \catcode`\~13
10327  \catcode`\$12
10328  \catcode`\"12
10329
10330  % Loop from \countUTFx to \countUTFy, performing \UTFviiiTmp
10331  % substituting ~ and $ with a character token of that value.
10332  \def\UTFviiiLoop{%
10333    \global\catcode\countUTFx\active
10334    \uccode`\~\countUTFx
10335    \uccode`\$\countUTFx
10336    \uppercase\expandafter{\UTFviiiTmp}%
10337    \advance\countUTFx by 1
10338    \ifnum\countUTFx < \countUTFy
10339      \expandafter\UTFviiiLoop
10340    \fi}
10341
10342  % For bytes other than the first in a UTF-8 sequence.  Not expected to
10343  % be expanded except when writing to auxiliary files.
10344  \countUTFx = "80
10345  \countUTFy = "C2
10346  \def\UTFviiiTmp{%
10347    \gdef~{%
10348        \ifpassthroughchars $\fi}}%
10349  \UTFviiiLoop
10350
10351  \countUTFx = "C2
10352  \countUTFy = "E0
10353  \def\UTFviiiTmp{%
10354    \gdef~{%
10355        \ifpassthroughchars $%
10356        \else\expandafter\UTFviiiTwoOctets\expandafter$\fi}}%
10357  \UTFviiiLoop
10358
10359  \countUTFx = "E0
10360  \countUTFy = "F0
10361  \def\UTFviiiTmp{%
10362    \gdef~{%
10363        \ifpassthroughchars $%
10364        \else\expandafter\UTFviiiThreeOctets\expandafter$\fi}}%
10365  \UTFviiiLoop
10366
10367  \countUTFx = "F0
10368  \countUTFy = "F4
10369  \def\UTFviiiTmp{%
10370    \gdef~{%
10371        \ifpassthroughchars $%
10372        \else\expandafter\UTFviiiFourOctets\expandafter$\fi
10373        }}%
10374  \UTFviiiLoop
10375\endgroup
10376
10377\def\globallet{\global\let} % save some \expandafter's below
10378
10379% @U{xxxx} to produce U+xxxx, if we support it.
10380\def\U#1{%
10381  \expandafter\ifx\csname uni:#1\endcsname \relax
10382    \iftxinativeunicodecapable
10383      % All Unicode characters can be used if native Unicode handling is
10384      % active.  However, if the font does not have the glyph,
10385      % letters are missing.
10386      \begingroup
10387        \uccode`\.="#1\relax
10388        \uppercase{.}
10389      \endgroup
10390    \else
10391      \errhelp = \EMsimple
10392      \errmessage{Unicode character U+#1 not supported, sorry}%
10393    \fi
10394  \else
10395    \csname uni:#1\endcsname
10396  \fi
10397}
10398
10399% These macros are used here to construct the name of a control
10400% sequence to be defined.
10401\def\UTFviiiTwoOctetsName#1#2{%
10402  \csname u8:#1\string #2\endcsname}%
10403\def\UTFviiiThreeOctetsName#1#2#3{%
10404  \csname u8:#1\string #2\string #3\endcsname}%
10405\def\UTFviiiFourOctetsName#1#2#3#4{%
10406  \csname u8:#1\string #2\string #3\string #4\endcsname}%
10407
10408% For UTF-8 byte sequences (TeX, e-TeX and pdfTeX),
10409% provide a definition macro to replace a Unicode character;
10410% this gets used by the @U command
10411%
10412\begingroup
10413  \catcode`\"=12
10414  \catcode`\<=12
10415  \catcode`\.=12
10416  \catcode`\,=12
10417  \catcode`\;=12
10418  \catcode`\!=12
10419  \catcode`\~=13
10420  \gdef\DeclareUnicodeCharacterUTFviii#1#2{%
10421    \countUTFz = "#1\relax
10422    \begingroup
10423      \parseXMLCharref
10424
10425      % Give \u8:... its definition.  The sequence of seven \expandafter's
10426      % expands after the \gdef three times, e.g.
10427      %
10428      % 1.  \UTFviiTwoOctetsName B1 B2
10429      % 2.  \csname u8:B1 \string B2 \endcsname
10430      % 3.  \u8: B1 B2  (a single control sequence token)
10431      %
10432      \expandafter\expandafter
10433      \expandafter\expandafter
10434      \expandafter\expandafter
10435      \expandafter\gdef       \UTFviiiTmp{#2}%
10436      %
10437      \expandafter\ifx\csname uni:#1\endcsname \relax \else
10438       \message{Internal error, already defined: #1}%
10439      \fi
10440      %
10441      % define an additional control sequence for this code point.
10442      \expandafter\globallet\csname uni:#1\endcsname \UTFviiiTmp
10443    \endgroup}
10444  %
10445  % Given the value in \countUTFz as a Unicode code point, set \UTFviiiTmp
10446  % to the corresponding UTF-8 sequence.
10447  \gdef\parseXMLCharref{%
10448    \ifnum\countUTFz < "A0\relax
10449      \errhelp = \EMsimple
10450      \errmessage{Cannot define Unicode char value < 00A0}%
10451    \else\ifnum\countUTFz < "800\relax
10452      \parseUTFviiiA,%
10453      \parseUTFviiiB C\UTFviiiTwoOctetsName.,%
10454    \else\ifnum\countUTFz < "10000\relax
10455      \parseUTFviiiA;%
10456      \parseUTFviiiA,%
10457      \parseUTFviiiB E\UTFviiiThreeOctetsName.{,;}%
10458    \else
10459      \parseUTFviiiA;%
10460      \parseUTFviiiA,%
10461      \parseUTFviiiA!%
10462      \parseUTFviiiB F\UTFviiiFourOctetsName.{!,;}%
10463    \fi\fi\fi
10464  }
10465
10466  % Extract a byte from the end of the UTF-8 representation of \countUTFx.
10467  % It must be a non-initial byte in the sequence.
10468  % Change \uccode of #1 for it to be used in \parseUTFviiiB as one
10469  % of the bytes.
10470  \gdef\parseUTFviiiA#1{%
10471    \countUTFx = \countUTFz
10472    \divide\countUTFz by 64
10473    \countUTFy = \countUTFz  % Save to be the future value of \countUTFz.
10474    \multiply\countUTFz by 64
10475
10476    % \countUTFz is now \countUTFx with the last 5 bits cleared.  Subtract
10477    % in order to get the last five bits.
10478    \advance\countUTFx by -\countUTFz
10479
10480    % Convert this to the byte in the UTF-8 sequence.
10481    \advance\countUTFx by 128
10482    \uccode `#1\countUTFx
10483    \countUTFz = \countUTFy}
10484
10485  % Used to put a UTF-8 byte sequence into \UTFviiiTmp
10486  % #1 is the increment for \countUTFz to yield a the first byte of the UTF-8
10487  %    sequence.
10488  % #2 is one of the \UTFviii*OctetsName macros.
10489  % #3 is always a full stop (.)
10490  % #4 is a template for the other bytes in the sequence.  The values for these
10491  %    bytes is substituted in here with \uppercase using the \uccode's.
10492  \gdef\parseUTFviiiB#1#2#3#4{%
10493    \advance\countUTFz by "#10\relax
10494    \uccode `#3\countUTFz
10495    \uppercase{\gdef\UTFviiiTmp{#2#3#4}}}
10496\endgroup
10497
10498% For native Unicode handling (XeTeX and LuaTeX),
10499% provide a definition macro that sets a catcode to `other' non-globally
10500%
10501\def\DeclareUnicodeCharacterNativeOther#1#2{%
10502  \catcode"#1=\other
10503}
10504
10505% https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_M
10506% U+0000..U+007F = https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block)
10507% U+0080..U+00FF = https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)
10508% U+0100..U+017F = https://en.wikipedia.org/wiki/Latin_Extended-A
10509% U+0180..U+024F = https://en.wikipedia.org/wiki/Latin_Extended-B
10510%
10511% Many of our renditions are less than wonderful, and all the missing
10512% characters are available somewhere.  Loading the necessary fonts
10513% awaits user request.  We can't truly support Unicode without
10514% reimplementing everything that's been done in LaTeX for many years,
10515% plus probably using luatex or xetex, and who knows what else.
10516% We won't be doing that here in this simple file.  But we can try to at
10517% least make most of the characters not bomb out.
10518%
10519\def\unicodechardefs{%
10520  \DeclareUnicodeCharacter{00A0}{\tie}%
10521  \DeclareUnicodeCharacter{00A1}{\exclamdown}%
10522  \DeclareUnicodeCharacter{00A2}{{\tcfont \char162}}% 0242=cent
10523  \DeclareUnicodeCharacter{00A3}{\pounds{}}%
10524  \DeclareUnicodeCharacter{00A4}{{\tcfont \char164}}% 0244=currency
10525  \DeclareUnicodeCharacter{00A5}{{\tcfont \char165}}% 0245=yen
10526  \DeclareUnicodeCharacter{00A6}{{\tcfont \char166}}% 0246=brokenbar
10527  \DeclareUnicodeCharacter{00A7}{\S}%
10528  \DeclareUnicodeCharacter{00A8}{\"{ }}%
10529  \DeclareUnicodeCharacter{00A9}{\copyright{}}%
10530  \DeclareUnicodeCharacter{00AA}{\ordf}%
10531  \DeclareUnicodeCharacter{00AB}{\guillemetleft{}}%
10532  \DeclareUnicodeCharacter{00AC}{\ensuremath\lnot}%
10533  \DeclareUnicodeCharacter{00AD}{\-}%
10534  \DeclareUnicodeCharacter{00AE}{\registeredsymbol{}}%
10535  \DeclareUnicodeCharacter{00AF}{\={ }}%
10536  %
10537  \DeclareUnicodeCharacter{00B0}{\ringaccent{ }}%
10538  \DeclareUnicodeCharacter{00B1}{\ensuremath\pm}%
10539  \DeclareUnicodeCharacter{00B2}{$^2$}%
10540  \DeclareUnicodeCharacter{00B3}{$^3$}%
10541  \DeclareUnicodeCharacter{00B4}{\'{ }}%
10542  \DeclareUnicodeCharacter{00B5}{$\mu$}%
10543  \DeclareUnicodeCharacter{00B6}{\P}%
10544  \DeclareUnicodeCharacter{00B7}{\ensuremath\cdot}%
10545  \DeclareUnicodeCharacter{00B8}{\cedilla{ }}%
10546  \DeclareUnicodeCharacter{00B9}{$^1$}%
10547  \DeclareUnicodeCharacter{00BA}{\ordm}%
10548  \DeclareUnicodeCharacter{00BB}{\guillemetright{}}%
10549  \DeclareUnicodeCharacter{00BC}{$1\over4$}%
10550  \DeclareUnicodeCharacter{00BD}{$1\over2$}%
10551  \DeclareUnicodeCharacter{00BE}{$3\over4$}%
10552  \DeclareUnicodeCharacter{00BF}{\questiondown}%
10553  %
10554  \DeclareUnicodeCharacter{00C0}{\`A}%
10555  \DeclareUnicodeCharacter{00C1}{\'A}%
10556  \DeclareUnicodeCharacter{00C2}{\^A}%
10557  \DeclareUnicodeCharacter{00C3}{\~A}%
10558  \DeclareUnicodeCharacter{00C4}{\"A}%
10559  \DeclareUnicodeCharacter{00C5}{\AA}%
10560  \DeclareUnicodeCharacter{00C6}{\AE}%
10561  \DeclareUnicodeCharacter{00C7}{\cedilla{C}}%
10562  \DeclareUnicodeCharacter{00C8}{\`E}%
10563  \DeclareUnicodeCharacter{00C9}{\'E}%
10564  \DeclareUnicodeCharacter{00CA}{\^E}%
10565  \DeclareUnicodeCharacter{00CB}{\"E}%
10566  \DeclareUnicodeCharacter{00CC}{\`I}%
10567  \DeclareUnicodeCharacter{00CD}{\'I}%
10568  \DeclareUnicodeCharacter{00CE}{\^I}%
10569  \DeclareUnicodeCharacter{00CF}{\"I}%
10570  %
10571  \DeclareUnicodeCharacter{00D0}{\DH}%
10572  \DeclareUnicodeCharacter{00D1}{\~N}%
10573  \DeclareUnicodeCharacter{00D2}{\`O}%
10574  \DeclareUnicodeCharacter{00D3}{\'O}%
10575  \DeclareUnicodeCharacter{00D4}{\^O}%
10576  \DeclareUnicodeCharacter{00D5}{\~O}%
10577  \DeclareUnicodeCharacter{00D6}{\"O}%
10578  \DeclareUnicodeCharacter{00D7}{\ensuremath\times}%
10579  \DeclareUnicodeCharacter{00D8}{\O}%
10580  \DeclareUnicodeCharacter{00D9}{\`U}%
10581  \DeclareUnicodeCharacter{00DA}{\'U}%
10582  \DeclareUnicodeCharacter{00DB}{\^U}%
10583  \DeclareUnicodeCharacter{00DC}{\"U}%
10584  \DeclareUnicodeCharacter{00DD}{\'Y}%
10585  \DeclareUnicodeCharacter{00DE}{\TH}%
10586  \DeclareUnicodeCharacter{00DF}{\ss}%
10587  %
10588  \DeclareUnicodeCharacter{00E0}{\`a}%
10589  \DeclareUnicodeCharacter{00E1}{\'a}%
10590  \DeclareUnicodeCharacter{00E2}{\^a}%
10591  \DeclareUnicodeCharacter{00E3}{\~a}%
10592  \DeclareUnicodeCharacter{00E4}{\"a}%
10593  \DeclareUnicodeCharacter{00E5}{\aa}%
10594  \DeclareUnicodeCharacter{00E6}{\ae}%
10595  \DeclareUnicodeCharacter{00E7}{\cedilla{c}}%
10596  \DeclareUnicodeCharacter{00E8}{\`e}%
10597  \DeclareUnicodeCharacter{00E9}{\'e}%
10598  \DeclareUnicodeCharacter{00EA}{\^e}%
10599  \DeclareUnicodeCharacter{00EB}{\"e}%
10600  \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}}%
10601  \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}}%
10602  \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}}%
10603  \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}}%
10604  %
10605  \DeclareUnicodeCharacter{00F0}{\dh}%
10606  \DeclareUnicodeCharacter{00F1}{\~n}%
10607  \DeclareUnicodeCharacter{00F2}{\`o}%
10608  \DeclareUnicodeCharacter{00F3}{\'o}%
10609  \DeclareUnicodeCharacter{00F4}{\^o}%
10610  \DeclareUnicodeCharacter{00F5}{\~o}%
10611  \DeclareUnicodeCharacter{00F6}{\"o}%
10612  \DeclareUnicodeCharacter{00F7}{\ensuremath\div}%
10613  \DeclareUnicodeCharacter{00F8}{\o}%
10614  \DeclareUnicodeCharacter{00F9}{\`u}%
10615  \DeclareUnicodeCharacter{00FA}{\'u}%
10616  \DeclareUnicodeCharacter{00FB}{\^u}%
10617  \DeclareUnicodeCharacter{00FC}{\"u}%
10618  \DeclareUnicodeCharacter{00FD}{\'y}%
10619  \DeclareUnicodeCharacter{00FE}{\th}%
10620  \DeclareUnicodeCharacter{00FF}{\"y}%
10621  %
10622  \DeclareUnicodeCharacter{0100}{\=A}%
10623  \DeclareUnicodeCharacter{0101}{\=a}%
10624  \DeclareUnicodeCharacter{0102}{\u{A}}%
10625  \DeclareUnicodeCharacter{0103}{\u{a}}%
10626  \DeclareUnicodeCharacter{0104}{\ogonek{A}}%
10627  \DeclareUnicodeCharacter{0105}{\ogonek{a}}%
10628  \DeclareUnicodeCharacter{0106}{\'C}%
10629  \DeclareUnicodeCharacter{0107}{\'c}%
10630  \DeclareUnicodeCharacter{0108}{\^C}%
10631  \DeclareUnicodeCharacter{0109}{\^c}%
10632  \DeclareUnicodeCharacter{010A}{\dotaccent{C}}%
10633  \DeclareUnicodeCharacter{010B}{\dotaccent{c}}%
10634  \DeclareUnicodeCharacter{010C}{\v{C}}%
10635  \DeclareUnicodeCharacter{010D}{\v{c}}%
10636  \DeclareUnicodeCharacter{010E}{\v{D}}%
10637  \DeclareUnicodeCharacter{010F}{d'}%
10638  %
10639  \DeclareUnicodeCharacter{0110}{\DH}%
10640  \DeclareUnicodeCharacter{0111}{\dh}%
10641  \DeclareUnicodeCharacter{0112}{\=E}%
10642  \DeclareUnicodeCharacter{0113}{\=e}%
10643  \DeclareUnicodeCharacter{0114}{\u{E}}%
10644  \DeclareUnicodeCharacter{0115}{\u{e}}%
10645  \DeclareUnicodeCharacter{0116}{\dotaccent{E}}%
10646  \DeclareUnicodeCharacter{0117}{\dotaccent{e}}%
10647  \DeclareUnicodeCharacter{0118}{\ogonek{E}}%
10648  \DeclareUnicodeCharacter{0119}{\ogonek{e}}%
10649  \DeclareUnicodeCharacter{011A}{\v{E}}%
10650  \DeclareUnicodeCharacter{011B}{\v{e}}%
10651  \DeclareUnicodeCharacter{011C}{\^G}%
10652  \DeclareUnicodeCharacter{011D}{\^g}%
10653  \DeclareUnicodeCharacter{011E}{\u{G}}%
10654  \DeclareUnicodeCharacter{011F}{\u{g}}%
10655  %
10656  \DeclareUnicodeCharacter{0120}{\dotaccent{G}}%
10657  \DeclareUnicodeCharacter{0121}{\dotaccent{g}}%
10658  \DeclareUnicodeCharacter{0122}{\cedilla{G}}%
10659  \DeclareUnicodeCharacter{0123}{\cedilla{g}}%
10660  \DeclareUnicodeCharacter{0124}{\^H}%
10661  \DeclareUnicodeCharacter{0125}{\^h}%
10662  \DeclareUnicodeCharacter{0126}{\missingcharmsg{H WITH STROKE}}%
10663  \DeclareUnicodeCharacter{0127}{\missingcharmsg{h WITH STROKE}}%
10664  \DeclareUnicodeCharacter{0128}{\~I}%
10665  \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}}%
10666  \DeclareUnicodeCharacter{012A}{\=I}%
10667  \DeclareUnicodeCharacter{012B}{\={\dotless{i}}}%
10668  \DeclareUnicodeCharacter{012C}{\u{I}}%
10669  \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}}%
10670  \DeclareUnicodeCharacter{012E}{\ogonek{I}}%
10671  \DeclareUnicodeCharacter{012F}{\ogonek{i}}%
10672  %
10673  \DeclareUnicodeCharacter{0130}{\dotaccent{I}}%
10674  \DeclareUnicodeCharacter{0131}{\dotless{i}}%
10675  \DeclareUnicodeCharacter{0132}{IJ}%
10676  \DeclareUnicodeCharacter{0133}{ij}%
10677  \DeclareUnicodeCharacter{0134}{\^J}%
10678  \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}}%
10679  \DeclareUnicodeCharacter{0136}{\cedilla{K}}%
10680  \DeclareUnicodeCharacter{0137}{\cedilla{k}}%
10681  \DeclareUnicodeCharacter{0138}{\ensuremath\kappa}%
10682  \DeclareUnicodeCharacter{0139}{\'L}%
10683  \DeclareUnicodeCharacter{013A}{\'l}%
10684  \DeclareUnicodeCharacter{013B}{\cedilla{L}}%
10685  \DeclareUnicodeCharacter{013C}{\cedilla{l}}%
10686  \DeclareUnicodeCharacter{013D}{L'}% should kern
10687  \DeclareUnicodeCharacter{013E}{l'}% should kern
10688  \DeclareUnicodeCharacter{013F}{L\U{00B7}}%
10689  %
10690  \DeclareUnicodeCharacter{0140}{l\U{00B7}}%
10691  \DeclareUnicodeCharacter{0141}{\L}%
10692  \DeclareUnicodeCharacter{0142}{\l}%
10693  \DeclareUnicodeCharacter{0143}{\'N}%
10694  \DeclareUnicodeCharacter{0144}{\'n}%
10695  \DeclareUnicodeCharacter{0145}{\cedilla{N}}%
10696  \DeclareUnicodeCharacter{0146}{\cedilla{n}}%
10697  \DeclareUnicodeCharacter{0147}{\v{N}}%
10698  \DeclareUnicodeCharacter{0148}{\v{n}}%
10699  \DeclareUnicodeCharacter{0149}{'n}%
10700  \DeclareUnicodeCharacter{014A}{\missingcharmsg{ENG}}%
10701  \DeclareUnicodeCharacter{014B}{\missingcharmsg{eng}}%
10702  \DeclareUnicodeCharacter{014C}{\=O}%
10703  \DeclareUnicodeCharacter{014D}{\=o}%
10704  \DeclareUnicodeCharacter{014E}{\u{O}}%
10705  \DeclareUnicodeCharacter{014F}{\u{o}}%
10706  %
10707  \DeclareUnicodeCharacter{0150}{\H{O}}%
10708  \DeclareUnicodeCharacter{0151}{\H{o}}%
10709  \DeclareUnicodeCharacter{0152}{\OE}%
10710  \DeclareUnicodeCharacter{0153}{\oe}%
10711  \DeclareUnicodeCharacter{0154}{\'R}%
10712  \DeclareUnicodeCharacter{0155}{\'r}%
10713  \DeclareUnicodeCharacter{0156}{\cedilla{R}}%
10714  \DeclareUnicodeCharacter{0157}{\cedilla{r}}%
10715  \DeclareUnicodeCharacter{0158}{\v{R}}%
10716  \DeclareUnicodeCharacter{0159}{\v{r}}%
10717  \DeclareUnicodeCharacter{015A}{\'S}%
10718  \DeclareUnicodeCharacter{015B}{\'s}%
10719  \DeclareUnicodeCharacter{015C}{\^S}%
10720  \DeclareUnicodeCharacter{015D}{\^s}%
10721  \DeclareUnicodeCharacter{015E}{\cedilla{S}}%
10722  \DeclareUnicodeCharacter{015F}{\cedilla{s}}%
10723  %
10724  \DeclareUnicodeCharacter{0160}{\v{S}}%
10725  \DeclareUnicodeCharacter{0161}{\v{s}}%
10726  \DeclareUnicodeCharacter{0162}{\cedilla{T}}%
10727  \DeclareUnicodeCharacter{0163}{\cedilla{t}}%
10728  \DeclareUnicodeCharacter{0164}{\v{T}}%
10729  \DeclareUnicodeCharacter{0165}{\v{t}}%
10730  \DeclareUnicodeCharacter{0166}{\missingcharmsg{H WITH STROKE}}%
10731  \DeclareUnicodeCharacter{0167}{\missingcharmsg{h WITH STROKE}}%
10732  \DeclareUnicodeCharacter{0168}{\~U}%
10733  \DeclareUnicodeCharacter{0169}{\~u}%
10734  \DeclareUnicodeCharacter{016A}{\=U}%
10735  \DeclareUnicodeCharacter{016B}{\=u}%
10736  \DeclareUnicodeCharacter{016C}{\u{U}}%
10737  \DeclareUnicodeCharacter{016D}{\u{u}}%
10738  \DeclareUnicodeCharacter{016E}{\ringaccent{U}}%
10739  \DeclareUnicodeCharacter{016F}{\ringaccent{u}}%
10740  %
10741  \DeclareUnicodeCharacter{0170}{\H{U}}%
10742  \DeclareUnicodeCharacter{0171}{\H{u}}%
10743  \DeclareUnicodeCharacter{0172}{\ogonek{U}}%
10744  \DeclareUnicodeCharacter{0173}{\ogonek{u}}%
10745  \DeclareUnicodeCharacter{0174}{\^W}%
10746  \DeclareUnicodeCharacter{0175}{\^w}%
10747  \DeclareUnicodeCharacter{0176}{\^Y}%
10748  \DeclareUnicodeCharacter{0177}{\^y}%
10749  \DeclareUnicodeCharacter{0178}{\"Y}%
10750  \DeclareUnicodeCharacter{0179}{\'Z}%
10751  \DeclareUnicodeCharacter{017A}{\'z}%
10752  \DeclareUnicodeCharacter{017B}{\dotaccent{Z}}%
10753  \DeclareUnicodeCharacter{017C}{\dotaccent{z}}%
10754  \DeclareUnicodeCharacter{017D}{\v{Z}}%
10755  \DeclareUnicodeCharacter{017E}{\v{z}}%
10756  \DeclareUnicodeCharacter{017F}{\missingcharmsg{LONG S}}%
10757  %
10758  \DeclareUnicodeCharacter{01C4}{D\v{Z}}%
10759  \DeclareUnicodeCharacter{01C5}{D\v{z}}%
10760  \DeclareUnicodeCharacter{01C6}{d\v{z}}%
10761  \DeclareUnicodeCharacter{01C7}{LJ}%
10762  \DeclareUnicodeCharacter{01C8}{Lj}%
10763  \DeclareUnicodeCharacter{01C9}{lj}%
10764  \DeclareUnicodeCharacter{01CA}{NJ}%
10765  \DeclareUnicodeCharacter{01CB}{Nj}%
10766  \DeclareUnicodeCharacter{01CC}{nj}%
10767  \DeclareUnicodeCharacter{01CD}{\v{A}}%
10768  \DeclareUnicodeCharacter{01CE}{\v{a}}%
10769  \DeclareUnicodeCharacter{01CF}{\v{I}}%
10770  %
10771  \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}}%
10772  \DeclareUnicodeCharacter{01D1}{\v{O}}%
10773  \DeclareUnicodeCharacter{01D2}{\v{o}}%
10774  \DeclareUnicodeCharacter{01D3}{\v{U}}%
10775  \DeclareUnicodeCharacter{01D4}{\v{u}}%
10776  %
10777  \DeclareUnicodeCharacter{01E2}{\={\AE}}%
10778  \DeclareUnicodeCharacter{01E3}{\={\ae}}%
10779  \DeclareUnicodeCharacter{01E6}{\v{G}}%
10780  \DeclareUnicodeCharacter{01E7}{\v{g}}%
10781  \DeclareUnicodeCharacter{01E8}{\v{K}}%
10782  \DeclareUnicodeCharacter{01E9}{\v{k}}%
10783  %
10784  \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}}%
10785  \DeclareUnicodeCharacter{01F1}{DZ}%
10786  \DeclareUnicodeCharacter{01F2}{Dz}%
10787  \DeclareUnicodeCharacter{01F3}{dz}%
10788  \DeclareUnicodeCharacter{01F4}{\'G}%
10789  \DeclareUnicodeCharacter{01F5}{\'g}%
10790  \DeclareUnicodeCharacter{01F8}{\`N}%
10791  \DeclareUnicodeCharacter{01F9}{\`n}%
10792  \DeclareUnicodeCharacter{01FC}{\'{\AE}}%
10793  \DeclareUnicodeCharacter{01FD}{\'{\ae}}%
10794  \DeclareUnicodeCharacter{01FE}{\'{\O}}%
10795  \DeclareUnicodeCharacter{01FF}{\'{\o}}%
10796  %
10797  \DeclareUnicodeCharacter{021E}{\v{H}}%
10798  \DeclareUnicodeCharacter{021F}{\v{h}}%
10799  %
10800  \DeclareUnicodeCharacter{0226}{\dotaccent{A}}%
10801  \DeclareUnicodeCharacter{0227}{\dotaccent{a}}%
10802  \DeclareUnicodeCharacter{0228}{\cedilla{E}}%
10803  \DeclareUnicodeCharacter{0229}{\cedilla{e}}%
10804  \DeclareUnicodeCharacter{022E}{\dotaccent{O}}%
10805  \DeclareUnicodeCharacter{022F}{\dotaccent{o}}%
10806  %
10807  \DeclareUnicodeCharacter{0232}{\=Y}%
10808  \DeclareUnicodeCharacter{0233}{\=y}%
10809  \DeclareUnicodeCharacter{0237}{\dotless{j}}%
10810  %
10811  \DeclareUnicodeCharacter{02DB}{\ogonek{ }}%
10812  %
10813  % Greek letters upper case
10814  \DeclareUnicodeCharacter{0391}{{\it A}}%
10815  \DeclareUnicodeCharacter{0392}{{\it B}}%
10816  \DeclareUnicodeCharacter{0393}{\ensuremath{\mit\Gamma}}%
10817  \DeclareUnicodeCharacter{0394}{\ensuremath{\mit\Delta}}%
10818  \DeclareUnicodeCharacter{0395}{{\it E}}%
10819  \DeclareUnicodeCharacter{0396}{{\it Z}}%
10820  \DeclareUnicodeCharacter{0397}{{\it H}}%
10821  \DeclareUnicodeCharacter{0398}{\ensuremath{\mit\Theta}}%
10822  \DeclareUnicodeCharacter{0399}{{\it I}}%
10823  \DeclareUnicodeCharacter{039A}{{\it K}}%
10824  \DeclareUnicodeCharacter{039B}{\ensuremath{\mit\Lambda}}%
10825  \DeclareUnicodeCharacter{039C}{{\it M}}%
10826  \DeclareUnicodeCharacter{039D}{{\it N}}%
10827  \DeclareUnicodeCharacter{039E}{\ensuremath{\mit\Xi}}%
10828  \DeclareUnicodeCharacter{039F}{{\it O}}%
10829  \DeclareUnicodeCharacter{03A0}{\ensuremath{\mit\Pi}}%
10830  \DeclareUnicodeCharacter{03A1}{{\it P}}%
10831  %\DeclareUnicodeCharacter{03A2}{} % none - corresponds to final sigma
10832  \DeclareUnicodeCharacter{03A3}{\ensuremath{\mit\Sigma}}%
10833  \DeclareUnicodeCharacter{03A4}{{\it T}}%
10834  \DeclareUnicodeCharacter{03A5}{\ensuremath{\mit\Upsilon}}%
10835  \DeclareUnicodeCharacter{03A6}{\ensuremath{\mit\Phi}}%
10836  \DeclareUnicodeCharacter{03A7}{{\it X}}%
10837  \DeclareUnicodeCharacter{03A8}{\ensuremath{\mit\Psi}}%
10838  \DeclareUnicodeCharacter{03A9}{\ensuremath{\mit\Omega}}%
10839  %
10840  % Vowels with accents
10841  \DeclareUnicodeCharacter{0390}{\ensuremath{\ddot{\acute\iota}}}%
10842  \DeclareUnicodeCharacter{03AC}{\ensuremath{\acute\alpha}}%
10843  \DeclareUnicodeCharacter{03AD}{\ensuremath{\acute\epsilon}}%
10844  \DeclareUnicodeCharacter{03AE}{\ensuremath{\acute\eta}}%
10845  \DeclareUnicodeCharacter{03AF}{\ensuremath{\acute\iota}}%
10846  \DeclareUnicodeCharacter{03B0}{\ensuremath{\acute{\ddot\upsilon}}}%
10847  %
10848  % Standalone accent
10849  \DeclareUnicodeCharacter{0384}{\ensuremath{\acute{\ }}}%
10850  %
10851  % Greek letters lower case
10852  \DeclareUnicodeCharacter{03B1}{\ensuremath\alpha}%
10853  \DeclareUnicodeCharacter{03B2}{\ensuremath\beta}%
10854  \DeclareUnicodeCharacter{03B3}{\ensuremath\gamma}%
10855  \DeclareUnicodeCharacter{03B4}{\ensuremath\delta}%
10856  \DeclareUnicodeCharacter{03B5}{\ensuremath\epsilon}%
10857  \DeclareUnicodeCharacter{03B6}{\ensuremath\zeta}%
10858  \DeclareUnicodeCharacter{03B7}{\ensuremath\eta}%
10859  \DeclareUnicodeCharacter{03B8}{\ensuremath\theta}%
10860  \DeclareUnicodeCharacter{03B9}{\ensuremath\iota}%
10861  \DeclareUnicodeCharacter{03BA}{\ensuremath\kappa}%
10862  \DeclareUnicodeCharacter{03BB}{\ensuremath\lambda}%
10863  \DeclareUnicodeCharacter{03BC}{\ensuremath\mu}%
10864  \DeclareUnicodeCharacter{03BD}{\ensuremath\nu}%
10865  \DeclareUnicodeCharacter{03BE}{\ensuremath\xi}%
10866  \DeclareUnicodeCharacter{03BF}{{\it o}}% omicron
10867  \DeclareUnicodeCharacter{03C0}{\ensuremath\pi}%
10868  \DeclareUnicodeCharacter{03C1}{\ensuremath\rho}%
10869  \DeclareUnicodeCharacter{03C2}{\ensuremath\varsigma}%
10870  \DeclareUnicodeCharacter{03C3}{\ensuremath\sigma}%
10871  \DeclareUnicodeCharacter{03C4}{\ensuremath\tau}%
10872  \DeclareUnicodeCharacter{03C5}{\ensuremath\upsilon}%
10873  \DeclareUnicodeCharacter{03C6}{\ensuremath\phi}%
10874  \DeclareUnicodeCharacter{03C7}{\ensuremath\chi}%
10875  \DeclareUnicodeCharacter{03C8}{\ensuremath\psi}%
10876  \DeclareUnicodeCharacter{03C9}{\ensuremath\omega}%
10877  %
10878  % More Greek vowels with accents
10879  \DeclareUnicodeCharacter{03CA}{\ensuremath{\ddot\iota}}%
10880  \DeclareUnicodeCharacter{03CB}{\ensuremath{\ddot\upsilon}}%
10881  \DeclareUnicodeCharacter{03CC}{\ensuremath{\acute o}}%
10882  \DeclareUnicodeCharacter{03CD}{\ensuremath{\acute\upsilon}}%
10883  \DeclareUnicodeCharacter{03CE}{\ensuremath{\acute\omega}}%
10884  %
10885  % Variant Greek letters
10886  \DeclareUnicodeCharacter{03D1}{\ensuremath\vartheta}%
10887  \DeclareUnicodeCharacter{03D6}{\ensuremath\varpi}%
10888  \DeclareUnicodeCharacter{03F1}{\ensuremath\varrho}%
10889  %
10890  \DeclareUnicodeCharacter{1E02}{\dotaccent{B}}%
10891  \DeclareUnicodeCharacter{1E03}{\dotaccent{b}}%
10892  \DeclareUnicodeCharacter{1E04}{\udotaccent{B}}%
10893  \DeclareUnicodeCharacter{1E05}{\udotaccent{b}}%
10894  \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}}%
10895  \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}}%
10896  \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}}%
10897  \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}}%
10898  \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}}%
10899  \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}}%
10900  \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}}%
10901  \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}}%
10902  %
10903  \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}}%
10904  \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}}%
10905  %
10906  \DeclareUnicodeCharacter{1E20}{\=G}%
10907  \DeclareUnicodeCharacter{1E21}{\=g}%
10908  \DeclareUnicodeCharacter{1E22}{\dotaccent{H}}%
10909  \DeclareUnicodeCharacter{1E23}{\dotaccent{h}}%
10910  \DeclareUnicodeCharacter{1E24}{\udotaccent{H}}%
10911  \DeclareUnicodeCharacter{1E25}{\udotaccent{h}}%
10912  \DeclareUnicodeCharacter{1E26}{\"H}%
10913  \DeclareUnicodeCharacter{1E27}{\"h}%
10914  %
10915  \DeclareUnicodeCharacter{1E30}{\'K}%
10916  \DeclareUnicodeCharacter{1E31}{\'k}%
10917  \DeclareUnicodeCharacter{1E32}{\udotaccent{K}}%
10918  \DeclareUnicodeCharacter{1E33}{\udotaccent{k}}%
10919  \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}}%
10920  \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}}%
10921  \DeclareUnicodeCharacter{1E36}{\udotaccent{L}}%
10922  \DeclareUnicodeCharacter{1E37}{\udotaccent{l}}%
10923  \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}}%
10924  \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}}%
10925  \DeclareUnicodeCharacter{1E3E}{\'M}%
10926  \DeclareUnicodeCharacter{1E3F}{\'m}%
10927  %
10928  \DeclareUnicodeCharacter{1E40}{\dotaccent{M}}%
10929  \DeclareUnicodeCharacter{1E41}{\dotaccent{m}}%
10930  \DeclareUnicodeCharacter{1E42}{\udotaccent{M}}%
10931  \DeclareUnicodeCharacter{1E43}{\udotaccent{m}}%
10932  \DeclareUnicodeCharacter{1E44}{\dotaccent{N}}%
10933  \DeclareUnicodeCharacter{1E45}{\dotaccent{n}}%
10934  \DeclareUnicodeCharacter{1E46}{\udotaccent{N}}%
10935  \DeclareUnicodeCharacter{1E47}{\udotaccent{n}}%
10936  \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}}%
10937  \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}}%
10938  %
10939  \DeclareUnicodeCharacter{1E54}{\'P}%
10940  \DeclareUnicodeCharacter{1E55}{\'p}%
10941  \DeclareUnicodeCharacter{1E56}{\dotaccent{P}}%
10942  \DeclareUnicodeCharacter{1E57}{\dotaccent{p}}%
10943  \DeclareUnicodeCharacter{1E58}{\dotaccent{R}}%
10944  \DeclareUnicodeCharacter{1E59}{\dotaccent{r}}%
10945  \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}}%
10946  \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}}%
10947  \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}}%
10948  \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}}%
10949  %
10950  \DeclareUnicodeCharacter{1E60}{\dotaccent{S}}%
10951  \DeclareUnicodeCharacter{1E61}{\dotaccent{s}}%
10952  \DeclareUnicodeCharacter{1E62}{\udotaccent{S}}%
10953  \DeclareUnicodeCharacter{1E63}{\udotaccent{s}}%
10954  \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}}%
10955  \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}}%
10956  \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}}%
10957  \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}}%
10958  \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}}%
10959  \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}}%
10960  %
10961  \DeclareUnicodeCharacter{1E7C}{\~V}%
10962  \DeclareUnicodeCharacter{1E7D}{\~v}%
10963  \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}}%
10964  \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}}%
10965  %
10966  \DeclareUnicodeCharacter{1E80}{\`W}%
10967  \DeclareUnicodeCharacter{1E81}{\`w}%
10968  \DeclareUnicodeCharacter{1E82}{\'W}%
10969  \DeclareUnicodeCharacter{1E83}{\'w}%
10970  \DeclareUnicodeCharacter{1E84}{\"W}%
10971  \DeclareUnicodeCharacter{1E85}{\"w}%
10972  \DeclareUnicodeCharacter{1E86}{\dotaccent{W}}%
10973  \DeclareUnicodeCharacter{1E87}{\dotaccent{w}}%
10974  \DeclareUnicodeCharacter{1E88}{\udotaccent{W}}%
10975  \DeclareUnicodeCharacter{1E89}{\udotaccent{w}}%
10976  \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}}%
10977  \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}}%
10978  \DeclareUnicodeCharacter{1E8C}{\"X}%
10979  \DeclareUnicodeCharacter{1E8D}{\"x}%
10980  \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}}%
10981  \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}}%
10982  %
10983  \DeclareUnicodeCharacter{1E90}{\^Z}%
10984  \DeclareUnicodeCharacter{1E91}{\^z}%
10985  \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}}%
10986  \DeclareUnicodeCharacter{1E93}{\udotaccent{z}}%
10987  \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}}%
10988  \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}}%
10989  \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}}%
10990  \DeclareUnicodeCharacter{1E97}{\"t}%
10991  \DeclareUnicodeCharacter{1E98}{\ringaccent{w}}%
10992  \DeclareUnicodeCharacter{1E99}{\ringaccent{y}}%
10993  %
10994  \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}}%
10995  \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}}%
10996  %
10997  \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}}%
10998  \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}}%
10999  \DeclareUnicodeCharacter{1EBC}{\~E}%
11000  \DeclareUnicodeCharacter{1EBD}{\~e}%
11001  %
11002  \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}}%
11003  \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}}%
11004  \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}}%
11005  \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}}%
11006  %
11007  \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}}%
11008  \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}}%
11009  %
11010  \DeclareUnicodeCharacter{1EF2}{\`Y}%
11011  \DeclareUnicodeCharacter{1EF3}{\`y}%
11012  \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}}%
11013  %
11014  \DeclareUnicodeCharacter{1EF8}{\~Y}%
11015  \DeclareUnicodeCharacter{1EF9}{\~y}%
11016  %
11017  % Punctuation
11018  \DeclareUnicodeCharacter{2013}{--}%
11019  \DeclareUnicodeCharacter{2014}{---}%
11020  \DeclareUnicodeCharacter{2018}{\quoteleft{}}%
11021  \DeclareUnicodeCharacter{2019}{\quoteright{}}%
11022  \DeclareUnicodeCharacter{201A}{\quotesinglbase{}}%
11023  \DeclareUnicodeCharacter{201C}{\quotedblleft{}}%
11024  \DeclareUnicodeCharacter{201D}{\quotedblright{}}%
11025  \DeclareUnicodeCharacter{201E}{\quotedblbase{}}%
11026  \DeclareUnicodeCharacter{2020}{\ensuremath\dagger}%
11027  \DeclareUnicodeCharacter{2021}{\ensuremath\ddagger}%
11028  \DeclareUnicodeCharacter{2022}{\bullet{}}%
11029  \DeclareUnicodeCharacter{202F}{\thinspace}%
11030  \DeclareUnicodeCharacter{2026}{\dots{}}%
11031  \DeclareUnicodeCharacter{2039}{\guilsinglleft{}}%
11032  \DeclareUnicodeCharacter{203A}{\guilsinglright{}}%
11033  %
11034  \DeclareUnicodeCharacter{20AC}{\euro{}}%
11035  %
11036  \DeclareUnicodeCharacter{2192}{\expansion{}}%
11037  \DeclareUnicodeCharacter{21D2}{\result{}}%
11038  %
11039  % Mathematical symbols
11040  \DeclareUnicodeCharacter{2200}{\ensuremath\forall}%
11041  \DeclareUnicodeCharacter{2203}{\ensuremath\exists}%
11042  \DeclareUnicodeCharacter{2208}{\ensuremath\in}%
11043  \DeclareUnicodeCharacter{2212}{\minus{}}%
11044  \DeclareUnicodeCharacter{2217}{\ast}%
11045  \DeclareUnicodeCharacter{221E}{\ensuremath\infty}%
11046  \DeclareUnicodeCharacter{2225}{\ensuremath\parallel}%
11047  \DeclareUnicodeCharacter{2227}{\ensuremath\wedge}%
11048  \DeclareUnicodeCharacter{2229}{\ensuremath\cap}%
11049  \DeclareUnicodeCharacter{2261}{\equiv{}}%
11050  \DeclareUnicodeCharacter{2264}{\ensuremath\leq}%
11051  \DeclareUnicodeCharacter{2265}{\ensuremath\geq}%
11052  \DeclareUnicodeCharacter{2282}{\ensuremath\subset}%
11053  \DeclareUnicodeCharacter{2287}{\ensuremath\supseteq}%
11054  %
11055  \DeclareUnicodeCharacter{2016}{\ensuremath\Vert}%
11056  \DeclareUnicodeCharacter{2032}{\ensuremath\prime}%
11057  \DeclareUnicodeCharacter{210F}{\ensuremath\hbar}%
11058  \DeclareUnicodeCharacter{2111}{\ensuremath\Im}%
11059  \DeclareUnicodeCharacter{2113}{\ensuremath\ell}%
11060  \DeclareUnicodeCharacter{2118}{\ensuremath\wp}%
11061  \DeclareUnicodeCharacter{211C}{\ensuremath\Re}%
11062  \DeclareUnicodeCharacter{2135}{\ensuremath\aleph}%
11063  \DeclareUnicodeCharacter{2190}{\ensuremath\leftarrow}%
11064  \DeclareUnicodeCharacter{2191}{\ensuremath\uparrow}%
11065  \DeclareUnicodeCharacter{2193}{\ensuremath\downarrow}%
11066  \DeclareUnicodeCharacter{2194}{\ensuremath\leftrightarrow}%
11067  \DeclareUnicodeCharacter{2195}{\ensuremath\updownarrow}%
11068  \DeclareUnicodeCharacter{2196}{\ensuremath\nwarrow}%
11069  \DeclareUnicodeCharacter{2197}{\ensuremath\nearrow}%
11070  \DeclareUnicodeCharacter{2198}{\ensuremath\searrow}%
11071  \DeclareUnicodeCharacter{2199}{\ensuremath\swarrow}%
11072  \DeclareUnicodeCharacter{21A6}{\ensuremath\mapsto}%
11073  \DeclareUnicodeCharacter{21A9}{\ensuremath\hookleftarrow}%
11074  \DeclareUnicodeCharacter{21AA}{\ensuremath\hookrightarrow}%
11075  \DeclareUnicodeCharacter{21BC}{\ensuremath\leftharpoonup}%
11076  \DeclareUnicodeCharacter{21BD}{\ensuremath\leftharpoondown}%
11077  \DeclareUnicodeCharacter{21C0}{\ensuremath\rightharpoonup}%
11078  \DeclareUnicodeCharacter{21C1}{\ensuremath\rightharpoondown}%
11079  \DeclareUnicodeCharacter{21CC}{\ensuremath\rightleftharpoons}%
11080  \DeclareUnicodeCharacter{21D0}{\ensuremath\Leftarrow}%
11081  \DeclareUnicodeCharacter{21D1}{\ensuremath\Uparrow}%
11082  \DeclareUnicodeCharacter{21D3}{\ensuremath\Downarrow}%
11083  \DeclareUnicodeCharacter{21D4}{\ensuremath\Leftrightarrow}%
11084  \DeclareUnicodeCharacter{21D5}{\ensuremath\Updownarrow}%
11085  \DeclareUnicodeCharacter{2202}{\ensuremath\partial}%
11086  \DeclareUnicodeCharacter{2205}{\ensuremath\emptyset}%
11087  \DeclareUnicodeCharacter{2207}{\ensuremath\nabla}%
11088  \DeclareUnicodeCharacter{2209}{\ensuremath\notin}%
11089  \DeclareUnicodeCharacter{220B}{\ensuremath\owns}%
11090  \DeclareUnicodeCharacter{220F}{\ensuremath\prod}%
11091  \DeclareUnicodeCharacter{2210}{\ensuremath\coprod}%
11092  \DeclareUnicodeCharacter{2211}{\ensuremath\sum}%
11093  \DeclareUnicodeCharacter{2213}{\ensuremath\mp}%
11094  \DeclareUnicodeCharacter{2218}{\ensuremath\circ}%
11095  \DeclareUnicodeCharacter{221A}{\ensuremath\surd}%
11096  \DeclareUnicodeCharacter{221D}{\ensuremath\propto}%
11097  \DeclareUnicodeCharacter{2220}{\ensuremath\angle}%
11098  \DeclareUnicodeCharacter{2223}{\ensuremath\mid}%
11099  \DeclareUnicodeCharacter{2228}{\ensuremath\vee}%
11100  \DeclareUnicodeCharacter{222A}{\ensuremath\cup}%
11101  \DeclareUnicodeCharacter{222B}{\ensuremath\smallint}%
11102  \DeclareUnicodeCharacter{222E}{\ensuremath\oint}%
11103  \DeclareUnicodeCharacter{223C}{\ensuremath\sim}%
11104  \DeclareUnicodeCharacter{2240}{\ensuremath\wr}%
11105  \DeclareUnicodeCharacter{2243}{\ensuremath\simeq}%
11106  \DeclareUnicodeCharacter{2245}{\ensuremath\cong}%
11107  \DeclareUnicodeCharacter{2248}{\ensuremath\approx}%
11108  \DeclareUnicodeCharacter{224D}{\ensuremath\asymp}%
11109  \DeclareUnicodeCharacter{2250}{\ensuremath\doteq}%
11110  \DeclareUnicodeCharacter{2260}{\ensuremath\neq}%
11111  \DeclareUnicodeCharacter{226A}{\ensuremath\ll}%
11112  \DeclareUnicodeCharacter{226B}{\ensuremath\gg}%
11113  \DeclareUnicodeCharacter{227A}{\ensuremath\prec}%
11114  \DeclareUnicodeCharacter{227B}{\ensuremath\succ}%
11115  \DeclareUnicodeCharacter{2283}{\ensuremath\supset}%
11116  \DeclareUnicodeCharacter{2286}{\ensuremath\subseteq}%
11117  \DeclareUnicodeCharacter{228E}{\ensuremath\uplus}%
11118  \DeclareUnicodeCharacter{2291}{\ensuremath\sqsubseteq}%
11119  \DeclareUnicodeCharacter{2292}{\ensuremath\sqsupseteq}%
11120  \DeclareUnicodeCharacter{2293}{\ensuremath\sqcap}%
11121  \DeclareUnicodeCharacter{2294}{\ensuremath\sqcup}%
11122  \DeclareUnicodeCharacter{2295}{\ensuremath\oplus}%
11123  \DeclareUnicodeCharacter{2296}{\ensuremath\ominus}%
11124  \DeclareUnicodeCharacter{2297}{\ensuremath\otimes}%
11125  \DeclareUnicodeCharacter{2298}{\ensuremath\oslash}%
11126  \DeclareUnicodeCharacter{2299}{\ensuremath\odot}%
11127  \DeclareUnicodeCharacter{22A2}{\ensuremath\vdash}%
11128  \DeclareUnicodeCharacter{22A3}{\ensuremath\dashv}%
11129  \DeclareUnicodeCharacter{22A4}{\ensuremath\ptextop}%
11130  \DeclareUnicodeCharacter{22A5}{\ensuremath\bot}%
11131  \DeclareUnicodeCharacter{22A8}{\ensuremath\models}%
11132  \DeclareUnicodeCharacter{22C0}{\ensuremath\bigwedge}%
11133  \DeclareUnicodeCharacter{22C1}{\ensuremath\bigvee}%
11134  \DeclareUnicodeCharacter{22C2}{\ensuremath\bigcap}%
11135  \DeclareUnicodeCharacter{22C3}{\ensuremath\bigcup}%
11136  \DeclareUnicodeCharacter{22C4}{\ensuremath\diamond}%
11137  \DeclareUnicodeCharacter{22C5}{\ensuremath\cdot}%
11138  \DeclareUnicodeCharacter{22C6}{\ensuremath\star}%
11139  \DeclareUnicodeCharacter{22C8}{\ensuremath\bowtie}%
11140  \DeclareUnicodeCharacter{2308}{\ensuremath\lceil}%
11141  \DeclareUnicodeCharacter{2309}{\ensuremath\rceil}%
11142  \DeclareUnicodeCharacter{230A}{\ensuremath\lfloor}%
11143  \DeclareUnicodeCharacter{230B}{\ensuremath\rfloor}%
11144  \DeclareUnicodeCharacter{2322}{\ensuremath\frown}%
11145  \DeclareUnicodeCharacter{2323}{\ensuremath\smile}%
11146  %
11147  \DeclareUnicodeCharacter{25B3}{\ensuremath\triangle}%
11148  \DeclareUnicodeCharacter{25B7}{\ensuremath\triangleright}%
11149  \DeclareUnicodeCharacter{25BD}{\ensuremath\bigtriangledown}%
11150  \DeclareUnicodeCharacter{25C1}{\ensuremath\triangleleft}%
11151  \DeclareUnicodeCharacter{25C7}{\ensuremath\diamond}%
11152  \DeclareUnicodeCharacter{2660}{\ensuremath\spadesuit}%
11153  \DeclareUnicodeCharacter{2661}{\ensuremath\heartsuit}%
11154  \DeclareUnicodeCharacter{2662}{\ensuremath\diamondsuit}%
11155  \DeclareUnicodeCharacter{2663}{\ensuremath\clubsuit}%
11156  \DeclareUnicodeCharacter{266D}{\ensuremath\flat}%
11157  \DeclareUnicodeCharacter{266E}{\ensuremath\natural}%
11158  \DeclareUnicodeCharacter{266F}{\ensuremath\sharp}%
11159  \DeclareUnicodeCharacter{26AA}{\ensuremath\bigcirc}%
11160  \DeclareUnicodeCharacter{27B9}{\ensuremath\rangle}%
11161  \DeclareUnicodeCharacter{27C2}{\ensuremath\perp}%
11162  \DeclareUnicodeCharacter{27E8}{\ensuremath\langle}%
11163  \DeclareUnicodeCharacter{27F5}{\ensuremath\longleftarrow}%
11164  \DeclareUnicodeCharacter{27F6}{\ensuremath\longrightarrow}%
11165  \DeclareUnicodeCharacter{27F7}{\ensuremath\longleftrightarrow}%
11166  \DeclareUnicodeCharacter{27FC}{\ensuremath\longmapsto}%
11167  \DeclareUnicodeCharacter{29F5}{\ensuremath\setminus}%
11168  \DeclareUnicodeCharacter{2A00}{\ensuremath\bigodot}%
11169  \DeclareUnicodeCharacter{2A01}{\ensuremath\bigoplus}%
11170  \DeclareUnicodeCharacter{2A02}{\ensuremath\bigotimes}%
11171  \DeclareUnicodeCharacter{2A04}{\ensuremath\biguplus}%
11172  \DeclareUnicodeCharacter{2A06}{\ensuremath\bigsqcup}%
11173  \DeclareUnicodeCharacter{2A3F}{\ensuremath\amalg}%
11174  \DeclareUnicodeCharacter{2AAF}{\ensuremath\preceq}%
11175  \DeclareUnicodeCharacter{2AB0}{\ensuremath\succeq}%
11176  %
11177  \global\mathchardef\checkmark="1370% actually the square root sign
11178  \DeclareUnicodeCharacter{2713}{\ensuremath\checkmark}%
11179}% end of \unicodechardefs
11180
11181% UTF-8 byte sequence (pdfTeX) definitions (replacing and @U command)
11182% It makes the setting that replace UTF-8 byte sequence.
11183\def\utfeightchardefs{%
11184  \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterUTFviii
11185  \unicodechardefs
11186}
11187
11188% Whether the active definitions of non-ASCII characters expand to
11189% non-active tokens with the same character code.  This is used to
11190% write characters literally, instead of using active definitions for
11191% printing the correct glyphs.
11192\newif\ifpassthroughchars
11193\passthroughcharsfalse
11194
11195% For native Unicode handling (XeTeX and LuaTeX),
11196% provide a definition macro to replace/pass-through a Unicode character
11197%
11198\def\DeclareUnicodeCharacterNative#1#2{%
11199  \catcode"#1=\active
11200  \def\dodeclareunicodecharacternative##1##2##3{%
11201    \begingroup
11202      \uccode`\~="##2\relax
11203      \uppercase{\gdef~}{%
11204        \ifpassthroughchars
11205          ##1%
11206        \else
11207          ##3%
11208        \fi
11209      }
11210    \endgroup
11211  }
11212  \begingroup
11213    \uccode`\.="#1\relax
11214    \uppercase{\def\UTFNativeTmp{.}}%
11215    \expandafter\dodeclareunicodecharacternative\UTFNativeTmp{#1}{#2}%
11216  \endgroup
11217}
11218
11219% Native Unicode handling (XeTeX and LuaTeX) character replacing definition.
11220% It activates the setting that replaces Unicode characters.
11221\def\nativeunicodechardefs{%
11222  \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNative
11223  \unicodechardefs
11224}
11225
11226% For native Unicode handling (XeTeX and LuaTeX),
11227% make the character token expand
11228% to the sequences given in \unicodechardefs for printing.
11229\def\DeclareUnicodeCharacterNativeAtU#1#2{%
11230  \def\UTFAtUTmp{#2}
11231  \expandafter\globallet\csname uni:#1\endcsname \UTFAtUTmp
11232}
11233
11234% @U command definitions for native Unicode handling (XeTeX and LuaTeX).
11235\def\nativeunicodechardefsatu{%
11236  \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNativeAtU
11237  \unicodechardefs
11238}
11239
11240% US-ASCII character definitions.
11241\def\asciichardefs{% nothing need be done
11242   \relax
11243}
11244
11245% define all Unicode characters we know about, for the sake of @U.
11246\iftxinativeunicodecapable
11247  \nativeunicodechardefsatu
11248\else
11249  \utfeightchardefs
11250\fi
11251
11252
11253% Make non-ASCII characters printable again for compatibility with
11254% existing Texinfo documents that may use them, even without declaring a
11255% document encoding.
11256%
11257\setnonasciicharscatcode \other
11258
11259
11260\message{formatting,}
11261
11262\newdimen\defaultparindent \defaultparindent = 15pt
11263
11264\chapheadingskip = 15pt plus 4pt minus 2pt
11265\secheadingskip = 12pt plus 3pt minus 2pt
11266\subsecheadingskip = 9pt plus 2pt minus 2pt
11267
11268% Prevent underfull vbox error messages.
11269\vbadness = 10000
11270
11271% Don't be very finicky about underfull hboxes, either.
11272\hbadness = 6666
11273
11274% Following George Bush, get rid of widows and orphans.
11275\widowpenalty=10000
11276\clubpenalty=10000
11277
11278% Use TeX 3.0's \emergencystretch to help line breaking, but if we're
11279% using an old version of TeX, don't do anything.  We want the amount of
11280% stretch added to depend on the line length, hence the dependence on
11281% \hsize.  We call this whenever the paper size is set.
11282%
11283\def\setemergencystretch{%
11284  \ifx\emergencystretch\thisisundefined
11285    % Allow us to assign to \emergencystretch anyway.
11286    \def\emergencystretch{\dimen0}%
11287  \else
11288    \emergencystretch = .15\hsize
11289  \fi
11290}
11291
11292% Parameters in order: 1) textheight; 2) textwidth;
11293% 3) voffset; 4) hoffset; 5) binding offset; 6) topskip;
11294% 7) physical page height; 8) physical page width.
11295%
11296% We also call \setleading{\textleading}, so the caller should define
11297% \textleading.  The caller should also set \parskip.
11298%
11299\def\internalpagesizes#1#2#3#4#5#6#7#8{%
11300  \voffset = #3\relax
11301  \topskip = #6\relax
11302  \splittopskip = \topskip
11303  %
11304  \vsize = #1\relax
11305  \advance\vsize by \topskip
11306  \outervsize = \vsize
11307  \advance\outervsize by 2\topandbottommargin
11308  \txipageheight = \vsize
11309  %
11310  \hsize = #2\relax
11311  \outerhsize = \hsize
11312  \advance\outerhsize by 0.5in
11313  \txipagewidth = \hsize
11314  %
11315  \normaloffset = #4\relax
11316  \bindingoffset = #5\relax
11317  %
11318  \ifpdf
11319    \pdfpageheight #7\relax
11320    \pdfpagewidth #8\relax
11321    % if we don't reset these, they will remain at "1 true in" of
11322    % whatever layout pdftex was dumped with.
11323    \pdfhorigin = 1 true in
11324    \pdfvorigin = 1 true in
11325  \else
11326    \ifx\XeTeXrevision\thisisundefined
11327      \special{papersize=#8,#7}%
11328    \else
11329      \pdfpageheight #7\relax
11330      \pdfpagewidth #8\relax
11331      % XeTeX does not have \pdfhorigin and \pdfvorigin.
11332    \fi
11333  \fi
11334  %
11335  \setleading{\textleading}
11336  %
11337  \parindent = \defaultparindent
11338  \setemergencystretch
11339}
11340
11341% @letterpaper (the default).
11342\def\letterpaper{{\globaldefs = 1
11343  \parskip = 3pt plus 2pt minus 1pt
11344  \textleading = 13.2pt
11345  %
11346  % If page is nothing but text, make it come out even.
11347  \internalpagesizes{607.2pt}{6in}% that's 46 lines
11348                    {\voffset}{.25in}%
11349                    {\bindingoffset}{36pt}%
11350                    {11in}{8.5in}%
11351}}
11352
11353% Use @smallbook to reset parameters for 7x9.25 trim size.
11354\def\smallbook{{\globaldefs = 1
11355  \parskip = 2pt plus 1pt
11356  \textleading = 12pt
11357  %
11358  \internalpagesizes{7.5in}{5in}%
11359                    {-.2in}{0in}%
11360                    {\bindingoffset}{16pt}%
11361                    {9.25in}{7in}%
11362  %
11363  \lispnarrowing = 0.3in
11364  \tolerance = 700
11365  \contentsrightmargin = 0pt
11366  \defbodyindent = .5cm
11367}}
11368
11369% Use @smallerbook to reset parameters for 6x9 trim size.
11370% (Just testing, parameters still in flux.)
11371\def\smallerbook{{\globaldefs = 1
11372  \parskip = 1.5pt plus 1pt
11373  \textleading = 12pt
11374  %
11375  \internalpagesizes{7.4in}{4.8in}%
11376                    {-.2in}{-.4in}%
11377                    {0pt}{14pt}%
11378                    {9in}{6in}%
11379  %
11380  \lispnarrowing = 0.25in
11381  \tolerance = 700
11382  \contentsrightmargin = 0pt
11383  \defbodyindent = .4cm
11384}}
11385
11386% Use @afourpaper to print on European A4 paper.
11387\def\afourpaper{{\globaldefs = 1
11388  \parskip = 3pt plus 2pt minus 1pt
11389  \textleading = 13.2pt
11390  %
11391  % Double-side printing via postscript on Laserjet 4050
11392  % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm.
11393  % To change the settings for a different printer or situation, adjust
11394  % \normaloffset until the front-side and back-side texts align.  Then
11395  % do the same for \bindingoffset.  You can set these for testing in
11396  % your texinfo source file like this:
11397  % @tex
11398  % \global\normaloffset = -6mm
11399  % \global\bindingoffset = 10mm
11400  % @end tex
11401  \internalpagesizes{673.2pt}{160mm}% that's 51 lines
11402                    {\voffset}{\hoffset}%
11403                    {\bindingoffset}{44pt}%
11404                    {297mm}{210mm}%
11405  %
11406  \tolerance = 700
11407  \contentsrightmargin = 0pt
11408  \defbodyindent = 5mm
11409}}
11410
11411% Use @afivepaper to print on European A5 paper.
11412% From romildo@urano.iceb.ufop.br, 2 July 2000.
11413% He also recommends making @example and @lisp be small.
11414\def\afivepaper{{\globaldefs = 1
11415  \parskip = 2pt plus 1pt minus 0.1pt
11416  \textleading = 12.5pt
11417  %
11418  \internalpagesizes{160mm}{120mm}%
11419                    {\voffset}{\hoffset}%
11420                    {\bindingoffset}{8pt}%
11421                    {210mm}{148mm}%
11422  %
11423  \lispnarrowing = 0.2in
11424  \tolerance = 800
11425  \contentsrightmargin = 0pt
11426  \defbodyindent = 2mm
11427  \tableindent = 12mm
11428}}
11429
11430% A specific text layout, 24x15cm overall, intended for A4 paper.
11431\def\afourlatex{{\globaldefs = 1
11432  \afourpaper
11433  \internalpagesizes{237mm}{150mm}%
11434                    {\voffset}{4.6mm}%
11435                    {\bindingoffset}{7mm}%
11436                    {297mm}{210mm}%
11437  %
11438  % Must explicitly reset to 0 because we call \afourpaper.
11439  \globaldefs = 0
11440}}
11441
11442% Use @afourwide to print on A4 paper in landscape format.
11443\def\afourwide{{\globaldefs = 1
11444  \afourpaper
11445  \internalpagesizes{241mm}{165mm}%
11446                    {\voffset}{-2.95mm}%
11447                    {\bindingoffset}{7mm}%
11448                    {297mm}{210mm}%
11449  \globaldefs = 0
11450}}
11451
11452% @pagesizes TEXTHEIGHT[,TEXTWIDTH]
11453% Perhaps we should allow setting the margins, \topskip, \parskip,
11454% and/or leading, also. Or perhaps we should compute them somehow.
11455%
11456\parseargdef\pagesizes{\pagesizesyyy #1,,\finish}
11457\def\pagesizesyyy#1,#2,#3\finish{{%
11458  \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi
11459  \globaldefs = 1
11460  %
11461  \parskip = 3pt plus 2pt minus 1pt
11462  \setleading{\textleading}%
11463  %
11464  \dimen0 = #1\relax
11465  \advance\dimen0 by \voffset
11466  \advance\dimen0 by 1in % reference point for DVI is 1 inch from top of page
11467  %
11468  \dimen2 = \hsize
11469  \advance\dimen2 by \normaloffset
11470  \advance\dimen2 by 1in % reference point is 1 inch from left edge of page
11471  %
11472  \internalpagesizes{#1}{\hsize}%
11473                    {\voffset}{\normaloffset}%
11474                    {\bindingoffset}{44pt}%
11475                    {\dimen0}{\dimen2}%
11476}}
11477
11478% Set default to letter.
11479%
11480\letterpaper
11481
11482% Default value of \hfuzz, for suppressing warnings about overfull hboxes.
11483\hfuzz = 1pt
11484
11485
11486\message{and turning on texinfo input format.}
11487
11488\def^^L{\par} % remove \outer, so ^L can appear in an @comment
11489
11490% DEL is a comment character, in case @c does not suffice.
11491\catcode`\^^? = 14
11492
11493% Define macros to output various characters with catcode for normal text.
11494\catcode`\"=\other \def\normaldoublequote{"}
11495\catcode`\$=\other \def\normaldollar{$}%$ font-lock fix
11496\catcode`\+=\other \def\normalplus{+}
11497\catcode`\<=\other \def\normalless{<}
11498\catcode`\>=\other \def\normalgreater{>}
11499\catcode`\^=\other \def\normalcaret{^}
11500\catcode`\_=\other \def\normalunderscore{_}
11501\catcode`\|=\other \def\normalverticalbar{|}
11502\catcode`\~=\other \def\normaltilde{~}
11503
11504% This macro is used to make a character print one way in \tt
11505% (where it can probably be output as-is), and another way in other fonts,
11506% where something hairier probably needs to be done.
11507%
11508% #1 is what to print if we are indeed using \tt; #2 is what to print
11509% otherwise.  Since all the Computer Modern typewriter fonts have zero
11510% interword stretch (and shrink), and it is reasonable to expect all
11511% typewriter fonts to have this, we can check that font parameter.
11512%
11513\def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi}
11514
11515% Same as above, but check for italic font.  Actually this also catches
11516% non-italic slanted fonts since it is impossible to distinguish them from
11517% italic fonts.  But since this is only used by $ and it uses \sl anyway
11518% this is not a problem.
11519\def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi}
11520
11521% Set catcodes for Texinfo file
11522
11523% Active characters for printing the wanted glyph.
11524% Most of these we simply print from the \tt font, but for some, we can
11525% use math or other variants that look better in normal text.
11526%
11527\catcode`\"=\active
11528\def\activedoublequote{{\tt\char34}}
11529\let"=\activedoublequote
11530\catcode`\~=\active \def\activetilde{{\tt\char126}} \let~ = \activetilde
11531\chardef\hatchar=`\^
11532\catcode`\^=\active \def\activehat{{\tt \hatchar}} \let^ = \activehat
11533
11534\catcode`\_=\active
11535\def_{\ifusingtt\normalunderscore\_}
11536\def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }
11537\let\realunder=_
11538
11539\catcode`\|=\active \def|{{\tt\char124}}
11540
11541\chardef \less=`\<
11542\catcode`\<=\active \def\activeless{{\tt \less}}\let< = \activeless
11543\chardef \gtr=`\>
11544\catcode`\>=\active \def\activegtr{{\tt \gtr}}\let> = \activegtr
11545\catcode`\+=\active \def+{{\tt \char 43}}
11546\catcode`\$=\active \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix
11547\catcode`\-=\active \let-=\normaldash
11548
11549
11550% used for headline/footline in the output routine, in case the page
11551% breaks in the middle of an @tex block.
11552\def\texinfochars{%
11553  \let< = \activeless
11554  \let> = \activegtr
11555  \let~ = \activetilde
11556  \let^ = \activehat
11557  \markupsetuplqdefault \markupsetuprqdefault
11558  \let\b = \strong
11559  \let\i = \smartitalic
11560  % in principle, all other definitions in \tex have to be undone too.
11561}
11562
11563% Used sometimes to turn off (effectively) the active characters even after
11564% parsing them.
11565\def\turnoffactive{%
11566  \normalturnoffactive
11567  \otherbackslash
11568}
11569
11570\catcode`\@=0
11571
11572% \backslashcurfont outputs one backslash character in current font,
11573% as in \char`\\.
11574\global\chardef\backslashcurfont=`\\
11575\global\let\rawbackslashxx=\backslashcurfont  % let existing .??s files work
11576
11577% \realbackslash is an actual character `\' with catcode other, and
11578% \doublebackslash is two of them (for the pdf outlines).
11579{\catcode`\\=\other @gdef@realbackslash{\} @gdef@doublebackslash{\\}}
11580
11581% In Texinfo, backslash is an active character; it prints the backslash
11582% in fixed width font.
11583\catcode`\\=\active  % @ for escape char from now on.
11584
11585% Print a typewriter backslash.  For math mode, we can't simply use
11586% \backslashcurfont: the story here is that in math mode, the \char
11587% of \backslashcurfont ends up printing the roman \ from the math symbol
11588% font (because \char in math mode uses the \mathcode, and plain.tex
11589% sets \mathcode`\\="026E).  Hence we use an explicit \mathchar,
11590% which is the decimal equivalent of "715c (class 7, e.g., use \fam;
11591% ignored family value; char position "5C).  We can't use " for the
11592% usual hex value because it has already been made active.
11593
11594@def@ttbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}}
11595@let@backslashchar = @ttbackslash % @backslashchar{} is for user documents.
11596
11597% \rawbackslash defines an active \ to do \backslashcurfont.
11598% \otherbackslash defines an active \ to be a literal `\' character with
11599% catcode other.  We switch back and forth between these.
11600@gdef@rawbackslash{@let\=@backslashcurfont}
11601@gdef@otherbackslash{@let\=@realbackslash}
11602
11603% Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
11604% the literal character `\'.
11605%
11606{@catcode`- = @active
11607 @gdef@normalturnoffactive{%
11608   @passthroughcharstrue
11609   @let-=@normaldash
11610   @let"=@normaldoublequote
11611   @let$=@normaldollar %$ font-lock fix
11612   @let+=@normalplus
11613   @let<=@normalless
11614   @let>=@normalgreater
11615   @let^=@normalcaret
11616   @let_=@normalunderscore
11617   @let|=@normalverticalbar
11618   @let~=@normaltilde
11619   @let\=@ttbackslash
11620   @markupsetuplqdefault
11621   @markupsetuprqdefault
11622   @unsepspaces
11623 }
11624}
11625
11626% If a .fmt file is being used, characters that might appear in a file
11627% name cannot be active until we have parsed the command line.
11628% So turn them off again, and have @fixbackslash turn them back on.
11629@catcode`+=@other @catcode`@_=@other
11630
11631% \enablebackslashhack - allow file to begin `\input texinfo'
11632%
11633% If a .fmt file is being used, we don't want the `\input texinfo' to show up.
11634% That is what \eatinput is for; after that, the `\' should revert to printing
11635% a backslash.
11636% If the file did not have a `\input texinfo', then it is turned off after
11637% the first line; otherwise the first `\' in the file would cause an error.
11638% This is used on the very last line of this file, texinfo.tex.
11639% We also use @c to call @fixbackslash, in case ends of lines are hidden.
11640{
11641@catcode`@^=7
11642@catcode`@^^M=13@gdef@enablebackslashhack{%
11643  @global@let\ = @eatinput%
11644  @catcode`@^^M=13%
11645  @def@c{@fixbackslash@c}%
11646  % Definition for the newline at the end of this file.
11647  @def ^^M{@let^^M@secondlinenl}%
11648  % Definition for a newline in the main Texinfo file.
11649  @gdef @secondlinenl{@fixbackslash}%
11650  % In case the first line has a whole-line command on it
11651  @let@originalparsearg@parsearg
11652  @def@parsearg{@fixbackslash@originalparsearg}
11653}}
11654
11655{@catcode`@^=7 @catcode`@^^M=13%
11656@gdef@eatinput input texinfo#1^^M{@fixbackslash}}
11657
11658% Emergency active definition of newline, in case an active newline token
11659% appears by mistake.
11660{@catcode`@^=7 @catcode13=13%
11661@gdef@enableemergencynewline{%
11662  @gdef^^M{%
11663    @par%
11664    %<warning: active newline>@par%
11665}}}
11666
11667
11668@gdef@fixbackslash{%
11669  @ifx\@eatinput @let\ = @ttbackslash @fi
11670  @catcode13=5 % regular end of line
11671  @enableemergencynewline
11672  @let@c=@texinfoc
11673  @let@parsearg@originalparsearg
11674  % Also turn back on active characters that might appear in the input
11675  % file name, in case not using a pre-dumped format.
11676  @catcode`+=@active
11677  @catcode`@_=@active
11678  %
11679  % If texinfo.cnf is present on the system, read it.
11680  % Useful for site-wide @afourpaper, etc.  This macro, @fixbackslash, gets
11681  % called at the beginning of every Texinfo file.  Not opening texinfo.cnf
11682  % directly in this file, texinfo.tex, makes it possible to make a format
11683  % file for Texinfo.
11684  %
11685  @openin 1 texinfo.cnf
11686  @ifeof 1 @else @input texinfo.cnf @fi
11687  @closein 1
11688}
11689
11690
11691% Say @foo, not \foo, in error messages.
11692@escapechar = `@@
11693
11694% These (along with & and #) are made active for url-breaking, so need
11695% active definitions as the normal characters.
11696@def@normaldot{.}
11697@def@normalquest{?}
11698@def@normalslash{/}
11699
11700% These look ok in all fonts, so just make them not special.
11701% @hashchar{} gets its own user-level command, because of #line.
11702@catcode`@& = @other @def@normalamp{&}
11703@catcode`@# = @other @def@normalhash{#}
11704@catcode`@% = @other @def@normalpercent{%}
11705
11706@let @hashchar = @normalhash
11707
11708@c Finally, make ` and ' active, so that txicodequoteundirected and
11709@c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}.  If we
11710@c don't make ` and ' active, @code will not get them as active chars.
11711@c Do this last of all since we use ` in the previous @catcode assignments.
11712@catcode`@'=@active
11713@catcode`@`=@active
11714@markupsetuplqdefault
11715@markupsetuprqdefault
11716
11717@c Local variables:
11718@c eval: (add-hook 'write-file-hooks 'time-stamp)
11719@c page-delimiter: "^\\\\message\\|emacs-page"
11720@c time-stamp-start: "def\\\\texinfoversion{"
11721@c time-stamp-format: "%:y-%02m-%02d.%02H"
11722@c time-stamp-end: "}"
11723@c End:
11724
11725@c vim:sw=2:
11726
11727@enablebackslashhack
11728