Imported Upstream version 4.2
[platform/upstream/make.git] / config / texinfo.tex
1 % texinfo.tex -- TeX macros to handle Texinfo files.
2
3 % Load plain if necessary, i.e., if running under initex.
4 \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
5 %
6 \def\texinfoversion{2016-05-07.20}
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
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 <http://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 %   http://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or
34 %   http://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or
35 %   http://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 http://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 \chardef\dashChar  = `\-
169 \chardef\slashChar = `\/
170 \chardef\underChar = `\_
171
172 % Ignore a token.
173 %
174 \def\gobble#1{}
175
176 % The following is used inside several \edef's.
177 \def\makecsname#1{\expandafter\noexpand\csname#1\endcsname}
178
179 % Hyphenation fixes.
180 \hyphenation{
181   Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script
182   ap-pen-dix bit-map bit-maps
183   data-base data-bases eshell fall-ing half-way long-est man-u-script
184   man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm
185   par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces
186   spell-ing spell-ings
187   stand-alone strong-est time-stamp time-stamps which-ever white-space
188   wide-spread wrap-around
189 }
190
191 % Sometimes it is convenient to have everything in the transcript file
192 % and nothing on the terminal.  We don't just call \tracingall here,
193 % since that produces some useless output on the terminal.  We also make
194 % some effort to order the tracing commands to reduce output in the log
195 % file; cf. trace.sty in LaTeX.
196 %
197 \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
198 \def\loggingall{%
199   \tracingstats2
200   \tracingpages1
201   \tracinglostchars2  % 2 gives us more in etex
202   \tracingparagraphs1
203   \tracingoutput1
204   \tracingmacros2
205   \tracingrestores1
206   \showboxbreadth\maxdimen \showboxdepth\maxdimen
207   \ifx\eTeXversion\thisisundefined\else % etex gives us more logging
208     \tracingscantokens1
209     \tracingifs1
210     \tracinggroups1
211     \tracingnesting2
212     \tracingassigns1
213   \fi
214   \tracingcommands3  % 3 gives us more in etex
215   \errorcontextlines16
216 }%
217
218 % @errormsg{MSG}.  Do the index-like expansions on MSG, but if things
219 % aren't perfect, it's not the end of the world, being an error message,
220 % after all.
221
222 \def\errormsg{\begingroup \indexnofonts \doerrormsg}
223 \def\doerrormsg#1{\errmessage{#1}}
224
225 % add check for \lastpenalty to plain's definitions.  If the last thing
226 % we did was a \nobreak, we don't want to insert more space.
227 %
228 \def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount
229   \removelastskip\penalty-50\smallskip\fi\fi}
230 \def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount
231   \removelastskip\penalty-100\medskip\fi\fi}
232 \def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount
233   \removelastskip\penalty-200\bigskip\fi\fi}
234
235 %\f Output routine
236 %
237
238 % For a final copy, take out the rectangles
239 % that mark overfull boxes (in case you have decided
240 % that the text looks ok even though it passes the margin).
241 %
242 \def\finalout{\overfullrule=0pt }
243
244 % Do @cropmarks to get crop marks.
245 %
246 \newif\ifcropmarks
247 \let\cropmarks = \cropmarkstrue
248 %
249 % Dimensions to add cropmarks at corners.
250 % Added by P. A. MacKay, 12 Nov. 1986
251 %
252 \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines
253 \newdimen\cornerlong  \cornerlong=1pc
254 \newdimen\cornerthick \cornerthick=.3pt
255 \newdimen\topandbottommargin \topandbottommargin=.75in
256
257 % Output a mark which sets \thischapter, \thissection and \thiscolor.
258 % We dump everything together because we only have one kind of mark.
259 % This works because we only use \botmark / \topmark, not \firstmark.
260 %
261 % A mark contains a subexpression of the \ifcase ... \fi construct.
262 % \get*marks macros below extract the needed part using \ifcase.
263 %
264 % Another complication is to let the user choose whether \thischapter
265 % (\thissection) refers to the chapter (section) in effect at the top
266 % of a page, or that at the bottom of a page.
267
268 % \domark is called twice inside \chapmacro, to add one
269 % mark before the section break, and one after.
270 %   In the second call \prevchapterdefs is the same as \lastchapterdefs,
271 % and \prevsectiondefs is the same as \lastsectiondefs.
272 %   Then if the page is not broken at the mark, some of the previous
273 % section appears on the page, and we can get the name of this section
274 % from \firstmark for @everyheadingmarks top.
275 %   @everyheadingmarks bottom uses \botmark.
276 %
277 % See page 260 of The TeXbook.
278 \def\domark{%
279   \toks0=\expandafter{\lastchapterdefs}%
280   \toks2=\expandafter{\lastsectiondefs}%
281   \toks4=\expandafter{\prevchapterdefs}%
282   \toks6=\expandafter{\prevsectiondefs}%
283   \toks8=\expandafter{\lastcolordefs}%
284   \mark{%
285                    \the\toks0 \the\toks2  % 0: marks for @everyheadingmarks top
286       \noexpand\or \the\toks4 \the\toks6  % 1: for @everyheadingmarks bottom
287     \noexpand\else \the\toks8             % 2: color marks
288   }%
289 }
290
291 % \gettopheadingmarks, \getbottomheadingmarks,
292 % \getcolormarks - extract needed part of mark.
293 %
294 % \topmark doesn't work for the very first chapter (after the title
295 % page or the contents), so we use \firstmark there -- this gets us
296 % the mark with the chapter defs, unless the user sneaks in, e.g.,
297 % @setcolor (or @url, or @link, etc.) between @contents and the very
298 % first @chapter.
299 \def\gettopheadingmarks{%
300   \ifcase0\topmark\fi
301   \ifx\thischapter\empty \ifcase0\firstmark\fi \fi
302 }
303 \def\getbottomheadingmarks{\ifcase1\botmark\fi}
304 \def\getcolormarks{\ifcase2\topmark\fi}
305
306 % Avoid "undefined control sequence" errors.
307 \def\lastchapterdefs{}
308 \def\lastsectiondefs{}
309 \def\lastsection{}
310 \def\prevchapterdefs{}
311 \def\prevsectiondefs{}
312 \def\lastcolordefs{}
313
314 % Margin to add to right of even pages, to left of odd pages.
315 \newdimen\bindingoffset
316 \newdimen\normaloffset
317 \newdimen\txipagewidth \newdimen\txipageheight
318
319 % Main output routine.
320 %
321 \chardef\PAGE = 255
322 \output = {\onepageout{\pagecontents\PAGE}}
323
324 \newbox\headlinebox
325 \newbox\footlinebox
326
327 % \onepageout takes a vbox as an argument.
328 % \shipout a vbox for a single page, adding an optional header, footer,
329 % cropmarks, and footnote.  This also causes index entries for this page
330 % to be written to the auxiliary files.
331 %
332 \def\onepageout#1{%
333   \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi
334   %
335   \ifodd\pageno  \advance\hoffset by \bindingoffset
336   \else \advance\hoffset by -\bindingoffset\fi
337   %
338   % Common context changes for both heading and footing.
339   % Do this outside of the \shipout so @code etc. will be expanded in
340   % the headline as they should be, not taken literally (outputting ''code).
341   \def\commmonheadfootline{\let\hsize=\txipagewidth \texinfochars}
342   %
343   % Retrieve the information for the headings from the marks in the page,
344   % and call Plain TeX's \makeheadline and \makefootline, which use the
345   % values in \headline and \footline.
346   %
347   % This is used to check if we are on the first page of a chapter.
348   \ifcase1\topmark\fi
349   \let\prevchaptername\thischaptername
350   \ifcase0\firstmark\fi
351   \let\curchaptername\thischaptername
352   %
353   \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi
354   \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi
355   %
356   \ifx\curchaptername\prevchaptername
357     \let\thischapterheading\thischapter
358   \else
359     % \thischapterheading is the same as \thischapter except it is blank
360     % for the first page of a chapter.  This is to prevent the chapter name 
361     % being shown twice.
362     \def\thischapterheading{}%
363   \fi
364   %
365   \global\setbox\headlinebox = \vbox{\commmonheadfootline \makeheadline}%
366   \global\setbox\footlinebox = \vbox{\commmonheadfootline \makefootline}%
367   %
368   {%
369     % Set context for writing to auxiliary files like index files.
370     % Have to do this stuff outside the \shipout because we want it to
371     % take effect in \write's, yet the group defined by the \vbox ends
372     % before the \shipout runs.
373     %
374     \indexdummies         % don't expand commands in the output.
375     \normalturnoffactive  % \ in index entries must not stay \, e.g., if
376                % the page break happens to be in the middle of an example.
377                % We don't want .vr (or whatever) entries like this:
378                % \entry{{\indexbackslash }acronym}{32}{\code {\acronym}}
379                % "\acronym" won't work when it's read back in;
380                % it needs to be
381                % {\code {{\backslashcurfont }acronym}
382     \shipout\vbox{%
383       % Do this early so pdf references go to the beginning of the page.
384       \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi
385       %
386       \ifcropmarks \vbox to \outervsize\bgroup
387         \hsize = \outerhsize
388         \vskip-\topandbottommargin
389         \vtop to0pt{%
390           \line{\ewtop\hfil\ewtop}%
391           \nointerlineskip
392           \line{%
393             \vbox{\moveleft\cornerthick\nstop}%
394             \hfill
395             \vbox{\moveright\cornerthick\nstop}%
396           }%
397           \vss}%
398         \vskip\topandbottommargin
399         \line\bgroup
400           \hfil % center the page within the outer (page) hsize.
401           \ifodd\pageno\hskip\bindingoffset\fi
402           \vbox\bgroup
403       \fi
404       %
405       \unvbox\headlinebox
406       \pagebody{#1}%
407       \ifdim\ht\footlinebox > 0pt
408         % Only leave this space if the footline is nonempty.
409         % (We lessened \vsize for it in \oddfootingyyy.)
410         % The \baselineskip=24pt in plain's \makefootline has no effect.
411         \vskip 24pt
412         \unvbox\footlinebox
413       \fi
414       %
415       \ifcropmarks
416           \egroup % end of \vbox\bgroup
417         \hfil\egroup % end of (centering) \line\bgroup
418         \vskip\topandbottommargin plus1fill minus1fill
419         \boxmaxdepth = \cornerthick
420         \vbox to0pt{\vss
421           \line{%
422             \vbox{\moveleft\cornerthick\nsbot}%
423             \hfill
424             \vbox{\moveright\cornerthick\nsbot}%
425           }%
426           \nointerlineskip
427           \line{\ewbot\hfil\ewbot}%
428         }%
429       \egroup % \vbox from first cropmarks clause
430       \fi
431     }% end of \shipout\vbox
432   }% end of group with \indexdummies
433   \advancepageno
434   \ifnum\outputpenalty>-20000 \else\dosupereject\fi
435 }
436
437 \newinsert\margin \dimen\margin=\maxdimen
438
439 % Main part of page, including any footnotes
440 \def\pagebody#1{\vbox to\txipageheight{\boxmaxdepth=\maxdepth #1}}
441 {\catcode`\@ =11
442 \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
443 % marginal hacks, juha@viisa.uucp (Juha Takala)
444 \ifvoid\margin\else % marginal info is present
445   \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi
446 \dimen@=\dp#1\relax \unvbox#1\relax
447 \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
448 \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
449 }
450
451 % Here are the rules for the cropmarks.  Note that they are
452 % offset so that the space between them is truly \outerhsize or \outervsize
453 % (P. A. MacKay, 12 November, 1986)
454 %
455 \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
456 \def\nstop{\vbox
457   {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
458 \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
459 \def\nsbot{\vbox
460   {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
461
462
463 % Argument parsing
464
465 % Parse an argument, then pass it to #1.  The argument is the rest of
466 % the input line (except we remove a trailing comment).  #1 should be a
467 % macro which expects an ordinary undelimited TeX argument.
468 % For example, \def\foo{\parsearg\fooxxx}.
469 %
470 \def\parsearg{\parseargusing{}}
471 \def\parseargusing#1#2{%
472   \def\argtorun{#2}%
473   \begingroup
474     \obeylines
475     \spaceisspace
476     #1%
477     \parseargline\empty% Insert the \empty token, see \finishparsearg below.
478 }
479
480 {\obeylines %
481   \gdef\parseargline#1^^M{%
482     \endgroup % End of the group started in \parsearg.
483     \argremovecomment #1\comment\ArgTerm%
484   }%
485 }
486
487 % First remove any @comment, then any @c comment.  Also remove a @texinfoc
488 % comment (see \scanmacro for details).  Pass the result on to \argcheckspaces.
489 \def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm}
490 \def\argremovec#1\c#2\ArgTerm{\argremovetexinfoc #1\texinfoc\ArgTerm}
491 \def\argremovetexinfoc#1\texinfoc#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
492
493 % Each occurrence of `\^^M' or `<space>\^^M' is replaced by a single space.
494 %
495 % \argremovec might leave us with trailing space, e.g.,
496 %    @end itemize  @c foo
497 % This space token undergoes the same procedure and is eventually removed
498 % by \finishparsearg.
499 %
500 \def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M}
501 \def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M}
502 \def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{%
503   \def\temp{#3}%
504   \ifx\temp\empty
505     % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp:
506     \let\temp\finishparsearg
507   \else
508     \let\temp\argcheckspaces
509   \fi
510   % Put the space token in:
511   \temp#1 #3\ArgTerm
512 }
513
514 % If a _delimited_ argument is enclosed in braces, they get stripped; so
515 % to get _exactly_ the rest of the line, we had to prevent such situation.
516 % We prepended an \empty token at the very beginning and we expand it now,
517 % just before passing the control to \argtorun.
518 % (Similarly, we have to think about #3 of \argcheckspacesY above: it is
519 % either the null string, or it ends with \^^M---thus there is no danger
520 % that a pair of braces would be stripped.
521 %
522 % But first, we have to remove the trailing space token.
523 %
524 \def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}}
525
526
527 % \parseargdef - define a command taking an argument on the line
528 %
529 % \parseargdef\foo{...}
530 %       is roughly equivalent to
531 % \def\foo{\parsearg\Xfoo}
532 % \def\Xfoo#1{...}
533 \def\parseargdef#1{%
534   \expandafter \doparseargdef \csname\string#1\endcsname #1%
535 }
536 \def\doparseargdef#1#2{%
537   \def#2{\parsearg#1}%
538   \def#1##1%
539 }
540
541 % Several utility definitions with active space:
542 {
543   \obeyspaces
544   \gdef\obeyedspace{ }
545
546   % Make each space character in the input produce a normal interword
547   % space in the output.  Don't allow a line break at this space, as this
548   % is used only in environments like @example, where each line of input
549   % should produce a line of output anyway.
550   %
551   \gdef\sepspaces{\obeyspaces\let =\tie}
552
553   % If an index command is used in an @example environment, any spaces
554   % therein should become regular spaces in the raw index file, not the
555   % expansion of \tie (\leavevmode \penalty \@M \ ).
556   \gdef\unsepspaces{\let =\space}
557 }
558
559
560 \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
561
562 % Define the framework for environments in texinfo.tex.  It's used like this:
563 %
564 %   \envdef\foo{...}
565 %   \def\Efoo{...}
566 %
567 % It's the responsibility of \envdef to insert \begingroup before the
568 % actual body; @end closes the group after calling \Efoo.  \envdef also
569 % defines \thisenv, so the current environment is known; @end checks
570 % whether the environment name matches.  The \checkenv macro can also be
571 % used to check whether the current environment is the one expected.
572 %
573 % Non-false conditionals (@iftex, @ifset) don't fit into this, so they
574 % are not treated as environments; they don't open a group.  (The
575 % implementation of @end takes care not to call \endgroup in this
576 % special case.)
577
578
579 % At run-time, environments start with this:
580 \def\startenvironment#1{\begingroup\def\thisenv{#1}}
581 % initialize
582 \let\thisenv\empty
583
584 % ... but they get defined via ``\envdef\foo{...}'':
585 \long\def\envdef#1#2{\def#1{\startenvironment#1#2}}
586 \def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}}
587
588 % Check whether we're in the right environment:
589 \def\checkenv#1{%
590   \def\temp{#1}%
591   \ifx\thisenv\temp
592   \else
593     \badenverr
594   \fi
595 }
596
597 % Environment mismatch, #1 expected:
598 \def\badenverr{%
599   \errhelp = \EMsimple
600   \errmessage{This command can appear only \inenvironment\temp,
601     not \inenvironment\thisenv}%
602 }
603 \def\inenvironment#1{%
604   \ifx#1\empty
605     outside of any environment%
606   \else
607     in environment \expandafter\string#1%
608   \fi
609 }
610
611 % @end foo executes the definition of \Efoo.
612 % But first, it executes a specialized version of \checkenv
613 %
614 \parseargdef\end{%
615   \if 1\csname iscond.#1\endcsname
616   \else
617     % The general wording of \badenverr may not be ideal.
618     \expandafter\checkenv\csname#1\endcsname
619     \csname E#1\endcsname
620     \endgroup
621   \fi
622 }
623
624 \newhelp\EMsimple{Press RETURN to continue.}
625
626
627 % Be sure we're in horizontal mode when doing a tie, since we make space
628 % equivalent to this in @example-like environments. Otherwise, a space
629 % at the beginning of a line will start with \penalty -- and
630 % since \penalty is valid in vertical mode, we'd end up putting the
631 % penalty on the vertical list instead of in the new paragraph.
632 {\catcode`@ = 11
633  % Avoid using \@M directly, because that causes trouble
634  % if the definition is written into an index file.
635  \global\let\tiepenalty = \@M
636  \gdef\tie{\leavevmode\penalty\tiepenalty\ }
637 }
638
639 % @: forces normal size whitespace following.
640 \def\:{\spacefactor=1000 }
641
642 % @* forces a line break.
643 \def\*{\unskip\hfil\break\hbox{}\ignorespaces}
644
645 % @/ allows a line break.
646 \let\/=\allowbreak
647
648 % @. is an end-of-sentence period.
649 \def\.{.\spacefactor=\endofsentencespacefactor\space}
650
651 % @! is an end-of-sentence bang.
652 \def\!{!\spacefactor=\endofsentencespacefactor\space}
653
654 % @? is an end-of-sentence query.
655 \def\?{?\spacefactor=\endofsentencespacefactor\space}
656
657 % @frenchspacing on|off  says whether to put extra space after punctuation.
658 %
659 \def\onword{on}
660 \def\offword{off}
661 %
662 \parseargdef\frenchspacing{%
663   \def\temp{#1}%
664   \ifx\temp\onword \plainfrenchspacing
665   \else\ifx\temp\offword \plainnonfrenchspacing
666   \else
667     \errhelp = \EMsimple
668     \errmessage{Unknown @frenchspacing option `\temp', must be on|off}%
669   \fi\fi
670 }
671
672 % @w prevents a word break.  Without the \leavevmode, @w at the
673 % beginning of a paragraph, when TeX is still in vertical mode, would
674 % produce a whole line of output instead of starting the paragraph.
675 \def\w#1{\leavevmode\hbox{#1}}
676
677 % @group ... @end group forces ... to be all on one page, by enclosing
678 % it in a TeX vbox.  We use \vtop instead of \vbox to construct the box
679 % to keep its height that of a normal line.  According to the rules for
680 % \topskip (p.114 of the TeXbook), the glue inserted is
681 % max (\topskip - \ht (first item), 0).  If that height is large,
682 % therefore, no glue is inserted, and the space between the headline and
683 % the text is small, which looks bad.
684 %
685 % Another complication is that the group might be very large.  This can
686 % cause the glue on the previous page to be unduly stretched, because it
687 % does not have much material.  In this case, it's better to add an
688 % explicit \vfill so that the extra space is at the bottom.  The
689 % threshold for doing this is if the group is more than \vfilllimit
690 % percent of a page (\vfilllimit can be changed inside of @tex).
691 %
692 \newbox\groupbox
693 \def\vfilllimit{0.7}
694 %
695 \envdef\group{%
696   \ifnum\catcode`\^^M=\active \else
697     \errhelp = \groupinvalidhelp
698     \errmessage{@group invalid in context where filling is enabled}%
699   \fi
700   \startsavinginserts
701   %
702   \setbox\groupbox = \vtop\bgroup
703     % Do @comment since we are called inside an environment such as
704     % @example, where each end-of-line in the input causes an
705     % end-of-line in the output.  We don't want the end-of-line after
706     % the `@group' to put extra space in the output.  Since @group
707     % should appear on a line by itself (according to the Texinfo
708     % manual), we don't worry about eating any user text.
709     \comment
710 }
711 %
712 % The \vtop produces a box with normal height and large depth; thus, TeX puts
713 % \baselineskip glue before it, and (when the next line of text is done)
714 % \lineskip glue after it.  Thus, space below is not quite equal to space
715 % above.  But it's pretty close.
716 \def\Egroup{%
717     % To get correct interline space between the last line of the group
718     % and the first line afterwards, we have to propagate \prevdepth.
719     \endgraf % Not \par, as it may have been set to \lisppar.
720     \global\dimen1 = \prevdepth
721   \egroup           % End the \vtop.
722   \addgroupbox
723   \prevdepth = \dimen1
724   \checkinserts
725 }
726
727 \def\addgroupbox{
728   % \dimen0 is the vertical size of the group's box.
729   \dimen0 = \ht\groupbox  \advance\dimen0 by \dp\groupbox
730   % \dimen2 is how much space is left on the page (more or less).
731   \dimen2 = \txipageheight   \advance\dimen2 by -\pagetotal
732   % if the group doesn't fit on the current page, and it's a big big
733   % group, force a page break.
734   \ifdim \dimen0 > \dimen2
735     \ifdim \pagetotal < \vfilllimit\txipageheight
736       \page
737     \fi
738   \fi
739   \box\groupbox
740 }
741
742 %
743 % TeX puts in an \escapechar (i.e., `@') at the beginning of the help
744 % message, so this ends up printing `@group can only ...'.
745 %
746 \newhelp\groupinvalidhelp{%
747 group can only be used in environments such as @example,^^J%
748 where each line of input produces a line of output.}
749
750 % @need space-in-mils
751 % forces a page break if there is not space-in-mils remaining.
752
753 \newdimen\mil  \mil=0.001in
754
755 \parseargdef\need{%
756   % Ensure vertical mode, so we don't make a big box in the middle of a
757   % paragraph.
758   \par
759   %
760   % If the @need value is less than one line space, it's useless.
761   \dimen0 = #1\mil
762   \dimen2 = \ht\strutbox
763   \advance\dimen2 by \dp\strutbox
764   \ifdim\dimen0 > \dimen2
765     %
766     % Do a \strut just to make the height of this box be normal, so the
767     % normal leading is inserted relative to the preceding line.
768     % And a page break here is fine.
769     \vtop to #1\mil{\strut\vfil}%
770     %
771     % TeX does not even consider page breaks if a penalty added to the
772     % main vertical list is 10000 or more.  But in order to see if the
773     % empty box we just added fits on the page, we must make it consider
774     % page breaks.  On the other hand, we don't want to actually break the
775     % page after the empty box.  So we use a penalty of 9999.
776     %
777     % There is an extremely small chance that TeX will actually break the
778     % page at this \penalty, if there are no other feasible breakpoints in
779     % sight.  (If the user is using lots of big @group commands, which
780     % almost-but-not-quite fill up a page, TeX will have a hard time doing
781     % good page breaking, for example.)  However, I could not construct an
782     % example where a page broke at this \penalty; if it happens in a real
783     % document, then we can reconsider our strategy.
784     \penalty9999
785     %
786     % Back up by the size of the box, whether we did a page break or not.
787     \kern -#1\mil
788     %
789     % Do not allow a page break right after this kern.
790     \nobreak
791   \fi
792 }
793
794 % @br   forces paragraph break (and is undocumented).
795
796 \let\br = \par
797
798 % @page forces the start of a new page.
799 %
800 \def\page{\par\vfill\supereject}
801
802 % @exdent text....
803 % outputs text on separate line in roman font, starting at standard page margin
804
805 % This records the amount of indent in the innermost environment.
806 % That's how much \exdent should take out.
807 \newskip\exdentamount
808
809 % This defn is used inside fill environments such as @defun.
810 \parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}
811
812 % This defn is used inside nofill environments such as @example.
813 \parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount
814   \leftline{\hskip\leftskip{\rm#1}}}}
815
816 % @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current
817 % paragraph.  For more general purposes, use the \margin insertion
818 % class.  WHICH is `l' or `r'.  Not documented, written for gawk manual.
819 %
820 \newskip\inmarginspacing \inmarginspacing=1cm
821 \def\strutdepth{\dp\strutbox}
822 %
823 \def\doinmargin#1#2{\strut\vadjust{%
824   \nobreak
825   \kern-\strutdepth
826   \vtop to \strutdepth{%
827     \baselineskip=\strutdepth
828     \vss
829     % if you have multiple lines of stuff to put here, you'll need to
830     % make the vbox yourself of the appropriate size.
831     \ifx#1l%
832       \llap{\ignorespaces #2\hskip\inmarginspacing}%
833     \else
834       \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}%
835     \fi
836     \null
837   }%
838 }}
839 \def\inleftmargin{\doinmargin l}
840 \def\inrightmargin{\doinmargin r}
841 %
842 % @inmargin{TEXT [, RIGHT-TEXT]}
843 % (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right;
844 % else use TEXT for both).
845 %
846 \def\inmargin#1{\parseinmargin #1,,\finish}
847 \def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing.
848   \setbox0 = \hbox{\ignorespaces #2}%
849   \ifdim\wd0 > 0pt
850     \def\lefttext{#1}%  have both texts
851     \def\righttext{#2}%
852   \else
853     \def\lefttext{#1}%  have only one text
854     \def\righttext{#1}%
855   \fi
856   %
857   \ifodd\pageno
858     \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin
859   \else
860     \def\temp{\inleftmargin\lefttext}%
861   \fi
862   \temp
863 }
864
865 % @| inserts a changebar to the left of the current line.  It should
866 % surround any changed text.  This approach does *not* work if the
867 % change spans more than two lines of output.  To handle that, we would
868 % have adopt a much more difficult approach (putting marks into the main
869 % vertical list for the beginning and end of each change).  This command
870 % is not documented, not supported, and doesn't work.
871 %
872 \def\|{%
873   % \vadjust can only be used in horizontal mode.
874   \leavevmode
875   %
876   % Append this vertical mode material after the current line in the output.
877   \vadjust{%
878     % We want to insert a rule with the height and depth of the current
879     % leading; that is exactly what \strutbox is supposed to record.
880     \vskip-\baselineskip
881     %
882     % \vadjust-items are inserted at the left edge of the type.  So
883     % the \llap here moves out into the left-hand margin.
884     \llap{%
885       %
886       % For a thicker or thinner bar, change the `1pt'.
887       \vrule height\baselineskip width1pt
888       %
889       % This is the space between the bar and the text.
890       \hskip 12pt
891     }%
892   }%
893 }
894
895 % @include FILE -- \input text of FILE.
896 %
897 \def\include{\parseargusing\filenamecatcodes\includezzz}
898 \def\includezzz#1{%
899   \pushthisfilestack
900   \def\thisfile{#1}%
901   {%
902     \makevalueexpandable  % we want to expand any @value in FILE.
903     \turnoffactive        % and allow special characters in the expansion
904     \indexnofonts         % Allow `@@' and other weird things in file names.
905     \wlog{texinfo.tex: doing @include of #1^^J}%
906     \edef\temp{\noexpand\input #1 }%
907     %
908     % This trickery is to read FILE outside of a group, in case it makes
909     % definitions, etc.
910     \expandafter
911   }\temp
912   \popthisfilestack
913 }
914 \def\filenamecatcodes{%
915   \catcode`\\=\other
916   \catcode`~=\other
917   \catcode`^=\other
918   \catcode`_=\other
919   \catcode`|=\other
920   \catcode`<=\other
921   \catcode`>=\other
922   \catcode`+=\other
923   \catcode`-=\other
924   \catcode`\`=\other
925   \catcode`\'=\other
926 }
927
928 \def\pushthisfilestack{%
929   \expandafter\pushthisfilestackX\popthisfilestack\StackTerm
930 }
931 \def\pushthisfilestackX{%
932   \expandafter\pushthisfilestackY\thisfile\StackTerm
933 }
934 \def\pushthisfilestackY #1\StackTerm #2\StackTerm {%
935   \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}%
936 }
937
938 \def\popthisfilestack{\errthisfilestackempty}
939 \def\errthisfilestackempty{\errmessage{Internal error:
940   the stack of filenames is empty.}}
941 %
942 \def\thisfile{}
943
944 % @center line
945 % outputs that line, centered.
946 %
947 \parseargdef\center{%
948   \ifhmode
949     \let\centersub\centerH
950   \else
951     \let\centersub\centerV
952   \fi
953   \centersub{\hfil \ignorespaces#1\unskip \hfil}%
954   \let\centersub\relax % don't let the definition persist, just in case
955 }
956 \def\centerH#1{{%
957   \hfil\break
958   \advance\hsize by -\leftskip
959   \advance\hsize by -\rightskip
960   \line{#1}%
961   \break
962 }}
963 %
964 \newcount\centerpenalty
965 \def\centerV#1{%
966   % The idea here is the same as in \startdefun, \cartouche, etc.: if
967   % @center is the first thing after a section heading, we need to wipe
968   % out the negative parskip inserted by \sectionheading, but still
969   % prevent a page break here.
970   \centerpenalty = \lastpenalty
971   \ifnum\centerpenalty>10000 \vskip\parskip \fi
972   \ifnum\centerpenalty>9999 \penalty\centerpenalty \fi
973   \line{\kern\leftskip #1\kern\rightskip}%
974 }
975
976 % @sp n   outputs n lines of vertical space
977 %
978 \parseargdef\sp{\vskip #1\baselineskip}
979
980 % @comment ...line which is ignored...
981 % @c is the same as @comment
982 % @ignore ... @end ignore  is another way to write a comment
983 %
984 \def\comment{\begingroup \catcode`\^^M=\active%
985 \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other\commentxxx}%
986
987 {\catcode`\^^M=\active%
988 \gdef\commentxxx#1^^M{\endgroup%
989 \futurelet\nexttoken\commentxxxx}%
990 \gdef\commentxxxx{\ifx\nexttoken\aftermacro\expandafter\comment\fi}%
991 }
992
993 \def\c{\begingroup \catcode`\^^M=\active%
994 \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
995 \cxxx}
996 {\catcode`\^^M=\active \gdef\cxxx#1^^M{\endgroup}}
997 % See comment in \scanmacro about why the definitions of @c and @comment differ
998
999 % @paragraphindent NCHARS
1000 % We'll use ems for NCHARS, close enough.
1001 % NCHARS can also be the word `asis' or `none'.
1002 % We cannot feasibly implement @paragraphindent asis, though.
1003 %
1004 \def\asisword{asis} % no translation, these are keywords
1005 \def\noneword{none}
1006 %
1007 \parseargdef\paragraphindent{%
1008   \def\temp{#1}%
1009   \ifx\temp\asisword
1010   \else
1011     \ifx\temp\noneword
1012       \defaultparindent = 0pt
1013     \else
1014       \defaultparindent = #1em
1015     \fi
1016   \fi
1017   \parindent = \defaultparindent
1018 }
1019
1020 % @exampleindent NCHARS
1021 % We'll use ems for NCHARS like @paragraphindent.
1022 % It seems @exampleindent asis isn't necessary, but
1023 % I preserve it to make it similar to @paragraphindent.
1024 \parseargdef\exampleindent{%
1025   \def\temp{#1}%
1026   \ifx\temp\asisword
1027   \else
1028     \ifx\temp\noneword
1029       \lispnarrowing = 0pt
1030     \else
1031       \lispnarrowing = #1em
1032     \fi
1033   \fi
1034 }
1035
1036 % @firstparagraphindent WORD
1037 % If WORD is `none', then suppress indentation of the first paragraph
1038 % after a section heading.  If WORD is `insert', then do indent at such
1039 % paragraphs.
1040 %
1041 % The paragraph indentation is suppressed or not by calling
1042 % \suppressfirstparagraphindent, which the sectioning commands do.
1043 % We switch the definition of this back and forth according to WORD.
1044 % By default, we suppress indentation.
1045 %
1046 \def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent}
1047 \def\insertword{insert}
1048 %
1049 \parseargdef\firstparagraphindent{%
1050   \def\temp{#1}%
1051   \ifx\temp\noneword
1052     \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent
1053   \else\ifx\temp\insertword
1054     \let\suppressfirstparagraphindent = \relax
1055   \else
1056     \errhelp = \EMsimple
1057     \errmessage{Unknown @firstparagraphindent option `\temp'}%
1058   \fi\fi
1059 }
1060
1061 % Here is how we actually suppress indentation.  Redefine \everypar to
1062 % \kern backwards by \parindent, and then reset itself to empty.
1063 %
1064 % We also make \indent itself not actually do anything until the next
1065 % paragraph.
1066 %
1067 \gdef\dosuppressfirstparagraphindent{%
1068   \gdef\indent  {\restorefirstparagraphindent \indent}%
1069   \gdef\noindent{\restorefirstparagraphindent \noindent}%
1070   \global\everypar = {\kern -\parindent \restorefirstparagraphindent}%
1071 }
1072 %
1073 \gdef\restorefirstparagraphindent{%
1074   \global\let\indent = \ptexindent
1075   \global\let\noindent = \ptexnoindent
1076   \global\everypar = {}%
1077 }
1078
1079
1080 % @refill is a no-op.
1081 \let\refill=\relax
1082
1083 % @setfilename INFO-FILENAME - ignored
1084 \let\setfilename=\comment
1085
1086 % @bye.
1087 \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
1088
1089
1090 \message{pdf,}
1091 % adobe `portable' document format
1092 \newcount\tempnum
1093 \newcount\lnkcount
1094 \newtoks\filename
1095 \newcount\filenamelength
1096 \newcount\pgn
1097 \newtoks\toksA
1098 \newtoks\toksB
1099 \newtoks\toksC
1100 \newtoks\toksD
1101 \newbox\boxA
1102 \newbox\boxB
1103 \newcount\countA
1104 \newif\ifpdf
1105 \newif\ifpdfmakepagedest
1106
1107 %
1108 % For LuaTeX
1109 %
1110
1111 \ifx\luatexversion\thisisundefined
1112 \else
1113   % Escape PDF strings UTF-8 to UTF-16
1114   \begingroup
1115     \catcode`\%=12
1116     \directlua{
1117       function UTF16oct(str)
1118         tex.sprint(string.char(0x5c) .. '376' .. string.char(0x5c) .. '377')
1119         for c in string.utfvalues(str) do
1120           if c < 0x10000 then
1121             tex.sprint(
1122               string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
1123                             string.char(0x5c) .. string.char(0x25) .. '03o',
1124                             (c / 256), (c % 256)))
1125           else
1126             c = c - 0x10000
1127             local c_hi = c / 1024 + 0xd800
1128             local c_lo = c % 1024 + 0xdc00
1129             tex.sprint(
1130               string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
1131                             string.char(0x5c) .. string.char(0x25) .. '03o' ..
1132                             string.char(0x5c) .. string.char(0x25) .. '03o' ..
1133                             string.char(0x5c) .. string.char(0x25) .. '03o',
1134                             (c_hi / 256), (c_hi % 256),
1135                             (c_lo / 256), (c_lo % 256)))
1136           end
1137         end
1138       end
1139     }
1140   \endgroup
1141   \def\pdfescapestring#1{\directlua{UTF16oct('\luaescapestring{#1}')}}
1142   \ifnum\luatexversion>84
1143     % For LuaTeX >= 0.85
1144     \def\pdfdest{\pdfextension dest}
1145     \let\pdfoutput\outputmode
1146     \def\pdfliteral{\pdfextension literal}
1147     \def\pdfcatalog{\pdfextension catalog}
1148     \def\pdftexversion{\numexpr\pdffeedback version\relax}
1149     \let\pdfximage\saveimageresource
1150     \let\pdfrefximage\useimageresource
1151     \let\pdflastximage\lastsavedimageresourceindex
1152     \def\pdfendlink{\pdfextension endlink\relax}
1153     \def\pdfoutline{\pdfextension outline}
1154     \def\pdfstartlink{\pdfextension startlink}
1155     \def\pdffontattr{\pdfextension fontattr}
1156     \def\pdfobj{\pdfextension obj}
1157     \def\pdflastobj{\numexpr\pdffeedback lastobj\relax}
1158     \let\pdfpagewidth\pagewidth
1159     \let\pdfpageheight\pageheight
1160     \edef\pdfhorigin{\pdfvariable horigin}
1161     \edef\pdfvorigin{\pdfvariable vorigin}
1162   \fi
1163 \fi
1164
1165 % when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1
1166 % can be set).  So we test for \relax and 0 as well as being undefined.
1167 \ifx\pdfoutput\thisisundefined
1168 \else
1169   \ifx\pdfoutput\relax
1170   \else
1171     \ifcase\pdfoutput
1172     \else
1173       \pdftrue
1174     \fi
1175   \fi
1176 \fi
1177
1178 % PDF uses PostScript string constants for the names of xref targets,
1179 % for display in the outlines, and in other places.  Thus, we have to
1180 % double any backslashes.  Otherwise, a name like "\node" will be
1181 % interpreted as a newline (\n), followed by o, d, e.  Not good.
1182
1183 % See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and
1184 % related messages.  The final outcome is that it is up to the TeX user
1185 % to double the backslashes and otherwise make the string valid, so
1186 % that's what we do.  pdftex 1.30.0 (ca.2005) introduced a primitive to
1187 % do this reliably, so we use it.
1188
1189 % #1 is a control sequence in which to do the replacements,
1190 % which we \xdef.
1191 \def\txiescapepdf#1{%
1192   \ifx\pdfescapestring\thisisundefined
1193     % No primitive available; should we give a warning or log?
1194     % Many times it won't matter.
1195   \else
1196     % The expandable \pdfescapestring primitive escapes parentheses,
1197     % backslashes, and other special chars.
1198     \xdef#1{\pdfescapestring{#1}}%
1199   \fi
1200 }
1201
1202 \newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images
1203 with PDF output, and none of those formats could be found.  (.eps cannot
1204 be supported due to the design of the PDF format; use regular TeX (DVI
1205 output) for that.)}
1206
1207 \ifpdf
1208   %
1209   % Color manipulation macros using ideas from pdfcolor.tex,
1210   % except using rgb instead of cmyk; the latter is said to render as a
1211   % very dark gray on-screen and a very dark halftone in print, instead
1212   % of actual black. The dark red here is dark enough to print on paper as
1213   % nearly black, but still distinguishable for online viewing.  We use
1214   % black by default, though.
1215   \def\rgbDarkRed{0.50 0.09 0.12}
1216   \def\rgbBlack{0 0 0}
1217   %
1218   % rg sets the color for filling (usual text, etc.);
1219   % RG sets the color for stroking (thin rules, e.g., normal _'s).
1220   \def\pdfsetcolor#1{\pdfliteral{#1 rg  #1 RG}}
1221   %
1222   % Set color, and create a mark which defines \thiscolor accordingly,
1223   % so that \makeheadline knows which color to restore.
1224   \def\setcolor#1{%
1225     \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}%
1226     \domark
1227     \pdfsetcolor{#1}%
1228   }
1229   %
1230   \def\maincolor{\rgbBlack}
1231   \pdfsetcolor{\maincolor}
1232   \edef\thiscolor{\maincolor}
1233   \def\lastcolordefs{}
1234   %
1235   \def\makefootline{%
1236     \baselineskip24pt
1237     \line{\pdfsetcolor{\maincolor}\the\footline}%
1238   }
1239   %
1240   \def\makeheadline{%
1241     \vbox to 0pt{%
1242       \vskip-22.5pt
1243       \line{%
1244         \vbox to8.5pt{}%
1245         % Extract \thiscolor definition from the marks.
1246         \getcolormarks
1247         % Typeset the headline with \maincolor, then restore the color.
1248         \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
1249       }%
1250       \vss
1251     }%
1252     \nointerlineskip
1253   }
1254   %
1255   %
1256   \pdfcatalog{/PageMode /UseOutlines}
1257   %
1258   % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
1259   \def\dopdfimage#1#2#3{%
1260     \def\pdfimagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
1261     \def\pdfimageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
1262     %
1263     % pdftex (and the PDF format) support .pdf, .png, .jpg (among
1264     % others).  Let's try in that order, PDF first since if
1265     % someone has a scalable image, presumably better to use that than a
1266     % bitmap.
1267     \let\pdfimgext=\empty
1268     \begingroup
1269       \openin 1 #1.pdf \ifeof 1
1270         \openin 1 #1.PDF \ifeof 1
1271           \openin 1 #1.png \ifeof 1
1272             \openin 1 #1.jpg \ifeof 1
1273               \openin 1 #1.jpeg \ifeof 1
1274                 \openin 1 #1.JPG \ifeof 1
1275                   \errhelp = \nopdfimagehelp
1276                   \errmessage{Could not find image file #1 for pdf}%
1277                 \else \gdef\pdfimgext{JPG}%
1278                 \fi
1279               \else \gdef\pdfimgext{jpeg}%
1280               \fi
1281             \else \gdef\pdfimgext{jpg}%
1282             \fi
1283           \else \gdef\pdfimgext{png}%
1284           \fi
1285         \else \gdef\pdfimgext{PDF}%
1286         \fi
1287       \else \gdef\pdfimgext{pdf}%
1288       \fi
1289       \closein 1
1290     \endgroup
1291     %
1292     % without \immediate, ancient pdftex seg faults when the same image is
1293     % included twice.  (Version 3.14159-pre-1.0-unofficial-20010704.)
1294     \ifnum\pdftexversion < 14
1295       \immediate\pdfimage
1296     \else
1297       \immediate\pdfximage
1298     \fi
1299       \ifdim \wd0 >0pt width \pdfimagewidth \fi
1300       \ifdim \wd2 >0pt height \pdfimageheight \fi
1301       \ifnum\pdftexversion<13
1302          #1.\pdfimgext
1303        \else
1304          {#1.\pdfimgext}%
1305        \fi
1306     \ifnum\pdftexversion < 14 \else
1307       \pdfrefximage \pdflastximage
1308     \fi}
1309   %
1310   \def\pdfmkdest#1{{%
1311     % We have to set dummies so commands such as @code, and characters
1312     % such as \, aren't expanded when present in a section title.
1313     \indexnofonts
1314     \turnoffactive
1315     \makevalueexpandable
1316     \def\pdfdestname{#1}%
1317     \txiescapepdf\pdfdestname
1318     \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
1319   }}
1320   %
1321   % used to mark target names; must be expandable.
1322   \def\pdfmkpgn#1{#1}
1323   %
1324   % by default, use black for everything.
1325   \def\urlcolor{\rgbBlack}
1326   \def\linkcolor{\rgbBlack}
1327   \def\endlink{\setcolor{\maincolor}\pdfendlink}
1328   %
1329   % Adding outlines to PDF; macros for calculating structure of outlines
1330   % come from Petr Olsak
1331   \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
1332     \else \csname#1\endcsname \fi}
1333   \def\advancenumber#1{\tempnum=\expnumber{#1}\relax
1334     \advance\tempnum by 1
1335     \expandafter\xdef\csname#1\endcsname{\the\tempnum}}
1336   %
1337   % #1 is the section text, which is what will be displayed in the
1338   % outline by the pdf viewer.  #2 is the pdf expression for the number
1339   % of subentries (or empty, for subsubsections).  #3 is the node text,
1340   % which might be empty if this toc entry had no corresponding node.
1341   % #4 is the page number
1342   %
1343   \def\dopdfoutline#1#2#3#4{%
1344     % Generate a link to the node text if that exists; else, use the
1345     % page number.  We could generate a destination for the section
1346     % text in the case where a section has no node, but it doesn't
1347     % seem worth the trouble, since most documents are normally structured.
1348     {
1349       \ifx\luatexversion\thisisundefined \else
1350         \turnoffactive % LuaTeX can use Unicode strings for PDF
1351       \fi
1352       \edef\pdfoutlinedest{#3}%
1353       \ifx\pdfoutlinedest\empty
1354         \def\pdfoutlinedest{#4}%
1355       \else
1356         \txiescapepdf\pdfoutlinedest
1357       \fi
1358       %
1359       % Also escape PDF chars in the display string.
1360       \edef\pdfoutlinetext{#1}%
1361       \txiescapepdf\pdfoutlinetext
1362       %
1363       \pdfoutline goto name{\pdfmkpgn{\pdfoutlinedest}}#2{\pdfoutlinetext}%
1364     }
1365   }
1366   %
1367   \def\pdfmakeoutlines{%
1368     \begingroup
1369       % Read toc silently, to get counts of subentries for \pdfoutline.
1370       \def\partentry##1##2##3##4{}% ignore parts in the outlines
1371       \def\numchapentry##1##2##3##4{%
1372         \def\thischapnum{##2}%
1373         \def\thissecnum{0}%
1374         \def\thissubsecnum{0}%
1375       }%
1376       \def\numsecentry##1##2##3##4{%
1377         \advancenumber{chap\thischapnum}%
1378         \def\thissecnum{##2}%
1379         \def\thissubsecnum{0}%
1380       }%
1381       \def\numsubsecentry##1##2##3##4{%
1382         \advancenumber{sec\thissecnum}%
1383         \def\thissubsecnum{##2}%
1384       }%
1385       \def\numsubsubsecentry##1##2##3##4{%
1386         \advancenumber{subsec\thissubsecnum}%
1387       }%
1388       \def\thischapnum{0}%
1389       \def\thissecnum{0}%
1390       \def\thissubsecnum{0}%
1391       %
1392       % use \def rather than \let here because we redefine \chapentry et
1393       % al. a second time, below.
1394       \def\appentry{\numchapentry}%
1395       \def\appsecentry{\numsecentry}%
1396       \def\appsubsecentry{\numsubsecentry}%
1397       \def\appsubsubsecentry{\numsubsubsecentry}%
1398       \def\unnchapentry{\numchapentry}%
1399       \def\unnsecentry{\numsecentry}%
1400       \def\unnsubsecentry{\numsubsecentry}%
1401       \def\unnsubsubsecentry{\numsubsubsecentry}%
1402       \readdatafile{toc}%
1403       %
1404       % Read toc second time, this time actually producing the outlines.
1405       % The `-' means take the \expnumber as the absolute number of
1406       % subentries, which we calculated on our first read of the .toc above.
1407       %
1408       % We use the node names as the destinations.
1409       \def\numchapentry##1##2##3##4{%
1410         \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}%
1411       \def\numsecentry##1##2##3##4{%
1412         \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}%
1413       \def\numsubsecentry##1##2##3##4{%
1414         \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}%
1415       \def\numsubsubsecentry##1##2##3##4{% count is always zero
1416         \dopdfoutline{##1}{}{##3}{##4}}%
1417       %
1418       % PDF outlines are displayed using system fonts, instead of
1419       % document fonts.  Therefore we cannot use special characters,
1420       % since the encoding is unknown.  For example, the eogonek from
1421       % Latin 2 (0xea) gets translated to a | character.  Info from
1422       % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100.
1423       %
1424       % TODO this right, we have to translate 8-bit characters to
1425       % their "best" equivalent, based on the @documentencoding.  Too
1426       % much work for too little return.  Just use the ASCII equivalents
1427       % we use for the index sort strings.
1428       % 
1429       \indexnofonts
1430       \setupdatafile
1431       % We can have normal brace characters in the PDF outlines, unlike
1432       % Texinfo index files.  So set that up.
1433       \def\{{\lbracecharliteral}%
1434       \def\}{\rbracecharliteral}%
1435       \catcode`\\=\active \otherbackslash
1436       \input \tocreadfilename
1437     \endgroup
1438   }
1439   {\catcode`[=1 \catcode`]=2
1440    \catcode`{=\other \catcode`}=\other
1441    \gdef\lbracecharliteral[{]%
1442    \gdef\rbracecharliteral[}]%
1443   ]
1444   %
1445   \def\skipspaces#1{\def\PP{#1}\def\D{|}%
1446     \ifx\PP\D\let\nextsp\relax
1447     \else\let\nextsp\skipspaces
1448       \addtokens{\filename}{\PP}%
1449       \advance\filenamelength by 1
1450     \fi
1451     \nextsp}
1452   \def\getfilename#1{%
1453     \filenamelength=0
1454     % If we don't expand the argument now, \skipspaces will get
1455     % snagged on things like "@value{foo}".
1456     \edef\temp{#1}%
1457     \expandafter\skipspaces\temp|\relax
1458   }
1459   \ifnum\pdftexversion < 14
1460     \let \startlink \pdfannotlink
1461   \else
1462     \let \startlink \pdfstartlink
1463   \fi
1464   % make a live url in pdf output.
1465   \def\pdfurl#1{%
1466     \begingroup
1467       % it seems we really need yet another set of dummies; have not
1468       % tried to figure out what each command should do in the context
1469       % of @url.  for now, just make @/ a no-op, that's the only one
1470       % people have actually reported a problem with.
1471       %
1472       \normalturnoffactive
1473       \def\@{@}%
1474       \let\/=\empty
1475       \makevalueexpandable
1476       % do we want to go so far as to use \indexnofonts instead of just
1477       % special-casing \var here?
1478       \def\var##1{##1}%
1479       %
1480       \leavevmode\setcolor{\urlcolor}%
1481       \startlink attr{/Border [0 0 0]}%
1482         user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
1483     \endgroup}
1484   \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1485   \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1486   \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1487   \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1488   \def\maketoks{%
1489     \expandafter\poptoks\the\toksA|ENDTOKS|\relax
1490     \ifx\first0\adn0
1491     \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1492     \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
1493     \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
1494     \else
1495       \ifnum0=\countA\else\makelink\fi
1496       \ifx\first.\let\next=\done\else
1497         \let\next=\maketoks
1498         \addtokens{\toksB}{\the\toksD}
1499         \ifx\first,\addtokens{\toksB}{\space}\fi
1500       \fi
1501     \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1502     \next}
1503   \def\makelink{\addtokens{\toksB}%
1504     {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1505   \def\pdflink#1{%
1506     \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}}
1507     \setcolor{\linkcolor}#1\endlink}
1508   \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1509 \else
1510   % non-pdf mode
1511   \let\pdfmkdest = \gobble
1512   \let\pdfurl = \gobble
1513   \let\endlink = \relax
1514   \let\setcolor = \gobble
1515   \let\pdfsetcolor = \gobble
1516   \let\pdfmakeoutlines = \relax
1517 \fi  % \ifx\pdfoutput
1518
1519 %
1520 % For XeTeX
1521 %
1522 \newif\iftxiuseunicodedestname
1523 \ifx\XeTeXrevision\thisisundefined
1524 \else
1525   %
1526   % XeTeX version check
1527   %
1528   \ifnum\strcmp{\the\XeTeXversion\XeTeXrevision}{0.99995}>-1
1529     % XeTeX 0.99995+ contains xdvipdfmx 20160307+.
1530     % It can handle Unicode destination name for PDF.
1531     \txiuseunicodedestnametrue
1532   \else
1533     % XeTeX < 0.99995 can not handle Unicode destination name for PDF
1534     % because xdvipdfmx 20150315 has UTF-16 convert issue.
1535     % It fixed by xdvipdfmx 20160106 (TeX Live SVN r39753).
1536     \txiuseunicodedestnamefalse
1537   \fi
1538   %
1539   % PDF outline support
1540   %
1541   % Emulate the primitive of pdfTeX
1542   \def\pdfdest name#1 xyz{%
1543     \special{pdf:dest (name#1) [@thispage /XYZ @xpos @ypos]}%
1544   }
1545   \def\pdfmkdest#1{{%
1546     % We have to set dummies so commands such as @code, and characters
1547     % such as \, aren't expanded when present in a section title.
1548     \indexnofonts
1549     \iftxiuseunicodedestname
1550       \def\pdfdestname{#1}% Pass through Unicode characters.
1551     \else
1552       \edef\pdfdestname{#1}% Replace Unicode characters to ASCII.
1553     \fi
1554     \turnoffactive
1555     \makevalueexpandable
1556     \txiescapepdf\pdfdestname
1557     \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
1558   }}
1559   %
1560   \def\dopdfoutline#1#2#3#4{%
1561     \iftxiuseunicodedestname
1562       \def\pdfoutlinedest{#3}% Pass through Unicode characters.
1563     \else
1564       \edef\pdfoutlinedest{#3}% Replace Unicode characters to ASCII.
1565     \fi
1566     \ifx\pdfoutlinedest\empty
1567       \def\pdfoutlinedest{#4}%
1568     \fi
1569     {
1570       \turnoffactive
1571       \txiescapepdf\pdfoutlinedest
1572       \edef\pdfoutlinetext{#1}%
1573       \txiescapepdf\pdfoutlinetext
1574       %
1575       \special{pdf:out [-] #2 << /Title (\pdfoutlinetext) /A
1576         << /S /GoTo /D (name\pdfoutlinedest) >> >> }%
1577     }
1578   }
1579   %
1580   \def\pdfmakeoutlines{%
1581     \begingroup
1582       %
1583       % In the case of XeTeX, counts of subentries is not necesary.
1584       % Therefore, read toc only once.
1585       %
1586       % We use the node names as the destinations.
1587       \def\partentry##1##2##3##4{}% ignore parts in the outlines
1588       \def\numchapentry##1##2##3##4{%
1589         \dopdfoutline{##1}{1}{##3}{##4}}%
1590       \def\numsecentry##1##2##3##4{%
1591         \dopdfoutline{##1}{2}{##3}{##4}}%
1592       \def\numsubsecentry##1##2##3##4{%
1593         \dopdfoutline{##1}{3}{##3}{##4}}%
1594       \def\numsubsubsecentry##1##2##3##4{%
1595         \dopdfoutline{##1}{4}{##3}{##4}}%
1596       %
1597       \let\appentry\numchapentry%
1598       \let\appsecentry\numsecentry%
1599       \let\appsubsecentry\numsubsecentry%
1600       \let\appsubsubsecentry\numsubsubsecentry%
1601       \let\unnchapentry\numchapentry%
1602       \let\unnsecentry\numsecentry%
1603       \let\unnsubsecentry\numsubsecentry%
1604       \let\unnsubsubsecentry\numsubsubsecentry%
1605       %
1606       % In the case of XeTeX, xdvipdfmx converts strings to UTF-16.
1607       % Therefore, the encoding and the language may not be considered.
1608       %
1609       \indexnofonts
1610       \setupdatafile
1611       % We can have normal brace characters in the PDF outlines, unlike
1612       % Texinfo index files.  So set that up.
1613       \def\{{\lbracecharliteral}%
1614       \def\}{\rbracecharliteral}%
1615       \catcode`\\=\active \otherbackslash
1616       \input \tocreadfilename
1617     \endgroup
1618   }
1619   {\catcode`[=1 \catcode`]=2
1620    \catcode`{=\other \catcode`}=\other
1621    \gdef\lbracecharliteral[{]%
1622    \gdef\rbracecharliteral[}]%
1623   ]
1624
1625   \special{pdf:docview << /PageMode /UseOutlines >> }
1626   % ``\special{pdf:tounicode ...}'' is not necessary
1627   % because xdvipdfmx converts strings from UTF-8 to UTF-16 without it.
1628   % However, due to UTF-16 convert issue of xdvipdfmx 20150315,
1629   % ``\special{pdf:dest ...}'' can not handle non-ASCII strings.
1630   % It fixed by xdvipdfmx 20160106 (TeX Live SVN r39753).
1631 %
1632   \def\skipspaces#1{\def\PP{#1}\def\D{|}%
1633     \ifx\PP\D\let\nextsp\relax
1634     \else\let\nextsp\skipspaces
1635       \addtokens{\filename}{\PP}%
1636       \advance\filenamelength by 1
1637     \fi
1638     \nextsp}
1639   \def\getfilename#1{%
1640     \filenamelength=0
1641     % If we don't expand the argument now, \skipspaces will get
1642     % snagged on things like "@value{foo}".
1643     \edef\temp{#1}%
1644     \expandafter\skipspaces\temp|\relax
1645   }
1646   % make a live url in pdf output.
1647   \def\pdfurl#1{%
1648     \begingroup
1649       % it seems we really need yet another set of dummies; have not
1650       % tried to figure out what each command should do in the context
1651       % of @url.  for now, just make @/ a no-op, that's the only one
1652       % people have actually reported a problem with.
1653       %
1654       \normalturnoffactive
1655       \def\@{@}%
1656       \let\/=\empty
1657       \makevalueexpandable
1658       % do we want to go so far as to use \indexnofonts instead of just
1659       % special-casing \var here?
1660       \def\var##1{##1}%
1661       %
1662       \leavevmode\setcolor{\urlcolor}%
1663       \special{pdf:bann << /Border [0 0 0]
1664         /Subtype /Link /A << /S /URI /URI (#1) >> >>}%
1665     \endgroup}
1666   \def\endlink{\setcolor{\maincolor}\special{pdf:eann}}
1667   \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1668   \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1669   \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1670   \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1671   \def\maketoks{%
1672     \expandafter\poptoks\the\toksA|ENDTOKS|\relax
1673     \ifx\first0\adn0
1674     \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1675     \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
1676     \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
1677     \else
1678       \ifnum0=\countA\else\makelink\fi
1679       \ifx\first.\let\next=\done\else
1680         \let\next=\maketoks
1681         \addtokens{\toksB}{\the\toksD}
1682         \ifx\first,\addtokens{\toksB}{\space}\fi
1683       \fi
1684     \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1685     \next}
1686   \def\makelink{\addtokens{\toksB}%
1687     {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1688   \def\pdflink#1{%
1689     \special{pdf:bann << /Border [0 0 0]
1690       /Type /Annot /Subtype /Link /A << /S /GoTo /D (name#1) >> >>}%
1691     \setcolor{\linkcolor}#1\endlink}
1692   \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1693 %
1694   %
1695   % @image support
1696   %
1697   % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
1698   \def\doxeteximage#1#2#3{%
1699     \def\xeteximagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
1700     \def\xeteximageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
1701     %
1702     % XeTeX (and the PDF format) support .pdf, .png, .jpg (among
1703     % others).  Let's try in that order, PDF first since if
1704     % someone has a scalable image, presumably better to use that than a
1705     % bitmap.
1706     \let\xeteximgext=\empty
1707     \begingroup
1708       \openin 1 #1.pdf \ifeof 1
1709         \openin 1 #1.PDF \ifeof 1
1710           \openin 1 #1.png \ifeof 1
1711             \openin 1 #1.jpg \ifeof 1
1712               \openin 1 #1.jpeg \ifeof 1
1713                 \openin 1 #1.JPG \ifeof 1
1714                   \errmessage{Could not find image file #1 for XeTeX}%
1715                 \else \gdef\xeteximgext{JPG}%
1716                 \fi
1717               \else \gdef\xeteximgext{jpeg}%
1718               \fi
1719             \else \gdef\xeteximgext{jpg}%
1720             \fi
1721           \else \gdef\xeteximgext{png}%
1722           \fi
1723         \else \gdef\xeteximgext{PDF}%
1724         \fi
1725       \else \gdef\xeteximgext{pdf}%
1726       \fi
1727       \closein 1
1728     \endgroup
1729     %
1730     \def\xetexpdfext{pdf}%
1731     \ifx\xeteximgext\xetexpdfext
1732       \XeTeXpdffile "#1".\xeteximgext ""
1733     \else
1734       \def\xetexpdfext{PDF}%
1735       \ifx\xeteximgext\xetexpdfext
1736         \XeTeXpdffile "#1".\xeteximgext ""
1737       \else
1738         \XeTeXpicfile "#1".\xeteximgext ""
1739       \fi
1740     \fi
1741     \ifdim \wd0 >0pt width \xeteximagewidth \fi
1742     \ifdim \wd2 >0pt height \xeteximageheight \fi \relax
1743   }
1744 \fi
1745
1746 \message{fonts,}
1747
1748 % Change the current font style to #1, remembering it in \curfontstyle.
1749 % For now, we do not accumulate font styles: @b{@i{foo}} prints foo in
1750 % italics, not bold italics.
1751 %
1752 \def\setfontstyle#1{%
1753   \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd.
1754   \csname ten#1\endcsname  % change the current font
1755 }
1756
1757 % Select #1 fonts with the current style.
1758 %
1759 \def\selectfonts#1{\csname #1fonts\endcsname \csname\curfontstyle\endcsname}
1760
1761 \def\rm{\fam=0 \setfontstyle{rm}}
1762 \def\it{\fam=\itfam \setfontstyle{it}}
1763 \def\sl{\fam=\slfam \setfontstyle{sl}}
1764 \def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf}
1765 \def\tt{\fam=\ttfam \setfontstyle{tt}}
1766
1767 % Unfortunately, we have to override this for titles and the like, since
1768 % in those cases "rm" is bold.  Sigh.
1769 \def\rmisbold{\rm\def\curfontstyle{bf}}
1770
1771 % Texinfo sort of supports the sans serif font style, which plain TeX does not.
1772 % So we set up a \sf.
1773 \newfam\sffam
1774 \def\sf{\fam=\sffam \setfontstyle{sf}}
1775 \let\li = \sf % Sometimes we call it \li, not \sf.
1776
1777 % We don't need math for this font style.
1778 \def\ttsl{\setfontstyle{ttsl}}
1779
1780
1781 % Set the baselineskip to #1, and the lineskip and strut size
1782 % correspondingly.  There is no deep meaning behind these magic numbers
1783 % used as factors; they just match (closely enough) what Knuth defined.
1784 %
1785 \def\lineskipfactor{.08333}
1786 \def\strutheightpercent{.70833}
1787 \def\strutdepthpercent {.29167}
1788 %
1789 % can get a sort of poor man's double spacing by redefining this.
1790 \def\baselinefactor{1}
1791 %
1792 \newdimen\textleading
1793 \def\setleading#1{%
1794   \dimen0 = #1\relax
1795   \normalbaselineskip = \baselinefactor\dimen0
1796   \normallineskip = \lineskipfactor\normalbaselineskip
1797   \normalbaselines
1798   \setbox\strutbox =\hbox{%
1799     \vrule width0pt height\strutheightpercent\baselineskip
1800                     depth \strutdepthpercent \baselineskip
1801   }%
1802 }
1803
1804 % PDF CMaps.  See also LaTeX's t1.cmap.
1805 %
1806 % do nothing with this by default.
1807 \expandafter\let\csname cmapOT1\endcsname\gobble
1808 \expandafter\let\csname cmapOT1IT\endcsname\gobble
1809 \expandafter\let\csname cmapOT1TT\endcsname\gobble
1810
1811 % if we are producing pdf, and we have \pdffontattr, then define cmaps.
1812 % (\pdffontattr was introduced many years ago, but people still run
1813 % older pdftex's; it's easy to conditionalize, so we do.)
1814 \ifpdf \ifx\pdffontattr\thisisundefined \else
1815   \begingroup
1816     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
1817     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
1818 %%DocumentNeededResources: ProcSet (CIDInit)
1819 %%IncludeResource: ProcSet (CIDInit)
1820 %%BeginResource: CMap (TeX-OT1-0)
1821 %%Title: (TeX-OT1-0 TeX OT1 0)
1822 %%Version: 1.000
1823 %%EndComments
1824 /CIDInit /ProcSet findresource begin
1825 12 dict begin
1826 begincmap
1827 /CIDSystemInfo
1828 << /Registry (TeX)
1829 /Ordering (OT1)
1830 /Supplement 0
1831 >> def
1832 /CMapName /TeX-OT1-0 def
1833 /CMapType 2 def
1834 1 begincodespacerange
1835 <00> <7F>
1836 endcodespacerange
1837 8 beginbfrange
1838 <00> <01> <0393>
1839 <09> <0A> <03A8>
1840 <23> <26> <0023>
1841 <28> <3B> <0028>
1842 <3F> <5B> <003F>
1843 <5D> <5E> <005D>
1844 <61> <7A> <0061>
1845 <7B> <7C> <2013>
1846 endbfrange
1847 40 beginbfchar
1848 <02> <0398>
1849 <03> <039B>
1850 <04> <039E>
1851 <05> <03A0>
1852 <06> <03A3>
1853 <07> <03D2>
1854 <08> <03A6>
1855 <0B> <00660066>
1856 <0C> <00660069>
1857 <0D> <0066006C>
1858 <0E> <006600660069>
1859 <0F> <00660066006C>
1860 <10> <0131>
1861 <11> <0237>
1862 <12> <0060>
1863 <13> <00B4>
1864 <14> <02C7>
1865 <15> <02D8>
1866 <16> <00AF>
1867 <17> <02DA>
1868 <18> <00B8>
1869 <19> <00DF>
1870 <1A> <00E6>
1871 <1B> <0153>
1872 <1C> <00F8>
1873 <1D> <00C6>
1874 <1E> <0152>
1875 <1F> <00D8>
1876 <21> <0021>
1877 <22> <201D>
1878 <27> <2019>
1879 <3C> <00A1>
1880 <3D> <003D>
1881 <3E> <00BF>
1882 <5C> <201C>
1883 <5F> <02D9>
1884 <60> <2018>
1885 <7D> <02DD>
1886 <7E> <007E>
1887 <7F> <00A8>
1888 endbfchar
1889 endcmap
1890 CMapName currentdict /CMap defineresource pop
1891 end
1892 end
1893 %%EndResource
1894 %%EOF
1895     }\endgroup
1896   \expandafter\edef\csname cmapOT1\endcsname#1{%
1897     \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
1898   }%
1899 %
1900 % \cmapOT1IT
1901   \begingroup
1902     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
1903     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
1904 %%DocumentNeededResources: ProcSet (CIDInit)
1905 %%IncludeResource: ProcSet (CIDInit)
1906 %%BeginResource: CMap (TeX-OT1IT-0)
1907 %%Title: (TeX-OT1IT-0 TeX OT1IT 0)
1908 %%Version: 1.000
1909 %%EndComments
1910 /CIDInit /ProcSet findresource begin
1911 12 dict begin
1912 begincmap
1913 /CIDSystemInfo
1914 << /Registry (TeX)
1915 /Ordering (OT1IT)
1916 /Supplement 0
1917 >> def
1918 /CMapName /TeX-OT1IT-0 def
1919 /CMapType 2 def
1920 1 begincodespacerange
1921 <00> <7F>
1922 endcodespacerange
1923 8 beginbfrange
1924 <00> <01> <0393>
1925 <09> <0A> <03A8>
1926 <25> <26> <0025>
1927 <28> <3B> <0028>
1928 <3F> <5B> <003F>
1929 <5D> <5E> <005D>
1930 <61> <7A> <0061>
1931 <7B> <7C> <2013>
1932 endbfrange
1933 42 beginbfchar
1934 <02> <0398>
1935 <03> <039B>
1936 <04> <039E>
1937 <05> <03A0>
1938 <06> <03A3>
1939 <07> <03D2>
1940 <08> <03A6>
1941 <0B> <00660066>
1942 <0C> <00660069>
1943 <0D> <0066006C>
1944 <0E> <006600660069>
1945 <0F> <00660066006C>
1946 <10> <0131>
1947 <11> <0237>
1948 <12> <0060>
1949 <13> <00B4>
1950 <14> <02C7>
1951 <15> <02D8>
1952 <16> <00AF>
1953 <17> <02DA>
1954 <18> <00B8>
1955 <19> <00DF>
1956 <1A> <00E6>
1957 <1B> <0153>
1958 <1C> <00F8>
1959 <1D> <00C6>
1960 <1E> <0152>
1961 <1F> <00D8>
1962 <21> <0021>
1963 <22> <201D>
1964 <23> <0023>
1965 <24> <00A3>
1966 <27> <2019>
1967 <3C> <00A1>
1968 <3D> <003D>
1969 <3E> <00BF>
1970 <5C> <201C>
1971 <5F> <02D9>
1972 <60> <2018>
1973 <7D> <02DD>
1974 <7E> <007E>
1975 <7F> <00A8>
1976 endbfchar
1977 endcmap
1978 CMapName currentdict /CMap defineresource pop
1979 end
1980 end
1981 %%EndResource
1982 %%EOF
1983     }\endgroup
1984   \expandafter\edef\csname cmapOT1IT\endcsname#1{%
1985     \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
1986   }%
1987 %
1988 % \cmapOT1TT
1989   \begingroup
1990     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
1991     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
1992 %%DocumentNeededResources: ProcSet (CIDInit)
1993 %%IncludeResource: ProcSet (CIDInit)
1994 %%BeginResource: CMap (TeX-OT1TT-0)
1995 %%Title: (TeX-OT1TT-0 TeX OT1TT 0)
1996 %%Version: 1.000
1997 %%EndComments
1998 /CIDInit /ProcSet findresource begin
1999 12 dict begin
2000 begincmap
2001 /CIDSystemInfo
2002 << /Registry (TeX)
2003 /Ordering (OT1TT)
2004 /Supplement 0
2005 >> def
2006 /CMapName /TeX-OT1TT-0 def
2007 /CMapType 2 def
2008 1 begincodespacerange
2009 <00> <7F>
2010 endcodespacerange
2011 5 beginbfrange
2012 <00> <01> <0393>
2013 <09> <0A> <03A8>
2014 <21> <26> <0021>
2015 <28> <5F> <0028>
2016 <61> <7E> <0061>
2017 endbfrange
2018 32 beginbfchar
2019 <02> <0398>
2020 <03> <039B>
2021 <04> <039E>
2022 <05> <03A0>
2023 <06> <03A3>
2024 <07> <03D2>
2025 <08> <03A6>
2026 <0B> <2191>
2027 <0C> <2193>
2028 <0D> <0027>
2029 <0E> <00A1>
2030 <0F> <00BF>
2031 <10> <0131>
2032 <11> <0237>
2033 <12> <0060>
2034 <13> <00B4>
2035 <14> <02C7>
2036 <15> <02D8>
2037 <16> <00AF>
2038 <17> <02DA>
2039 <18> <00B8>
2040 <19> <00DF>
2041 <1A> <00E6>
2042 <1B> <0153>
2043 <1C> <00F8>
2044 <1D> <00C6>
2045 <1E> <0152>
2046 <1F> <00D8>
2047 <20> <2423>
2048 <27> <2019>
2049 <60> <2018>
2050 <7F> <00A8>
2051 endbfchar
2052 endcmap
2053 CMapName currentdict /CMap defineresource pop
2054 end
2055 end
2056 %%EndResource
2057 %%EOF
2058     }\endgroup
2059   \expandafter\edef\csname cmapOT1TT\endcsname#1{%
2060     \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
2061   }%
2062 \fi\fi
2063
2064
2065 % Set the font macro #1 to the font named \fontprefix#2.
2066 % #3 is the font's design size, #4 is a scale factor, #5 is the CMap
2067 % encoding (only OT1, OT1IT and OT1TT are allowed, or empty to omit).
2068 % Example:
2069 % #1 = \textrm
2070 % #2 = \rmshape
2071 % #3 = 10
2072 % #4 = \mainmagstep
2073 % #5 = OT1
2074 %
2075 \def\setfont#1#2#3#4#5{%
2076   \font#1=\fontprefix#2#3 scaled #4
2077   \csname cmap#5\endcsname#1%
2078 }
2079 % This is what gets called when #5 of \setfont is empty.
2080 \let\cmap\gobble
2081 %
2082 % (end of cmaps)
2083
2084 % Use cm as the default font prefix.
2085 % To specify the font prefix, you must define \fontprefix
2086 % before you read in texinfo.tex.
2087 \ifx\fontprefix\thisisundefined
2088 \def\fontprefix{cm}
2089 \fi
2090 % Support font families that don't use the same naming scheme as CM.
2091 \def\rmshape{r}
2092 \def\rmbshape{bx}               % where the normal face is bold
2093 \def\bfshape{b}
2094 \def\bxshape{bx}
2095 \def\ttshape{tt}
2096 \def\ttbshape{tt}
2097 \def\ttslshape{sltt}
2098 \def\itshape{ti}
2099 \def\itbshape{bxti}
2100 \def\slshape{sl}
2101 \def\slbshape{bxsl}
2102 \def\sfshape{ss}
2103 \def\sfbshape{ss}
2104 \def\scshape{csc}
2105 \def\scbshape{csc}
2106
2107 % Definitions for a main text size of 11pt.  (The default in Texinfo.)
2108 %
2109 \def\definetextfontsizexi{%
2110 % Text fonts (11.2pt, magstep1).
2111 \def\textnominalsize{11pt}
2112 \edef\mainmagstep{\magstephalf}
2113 \setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
2114 \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
2115 \setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
2116 \setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
2117 \setfont\textsl\slshape{10}{\mainmagstep}{OT1}
2118 \setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
2119 \setfont\textsc\scshape{10}{\mainmagstep}{OT1}
2120 \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
2121 \font\texti=cmmi10 scaled \mainmagstep
2122 \font\textsy=cmsy10 scaled \mainmagstep
2123 \def\textecsize{1095}
2124
2125 % A few fonts for @defun names and args.
2126 \setfont\defbf\bfshape{10}{\magstep1}{OT1}
2127 \setfont\deftt\ttshape{10}{\magstep1}{OT1TT}
2128 \setfont\defsl\slshape{10}{\magstep1}{OT1TT}
2129 \setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT}
2130 \def\df{\let\tentt=\deftt \let\tenbf = \defbf
2131 \let\tenttsl=\defttsl \let\tensl=\defsl \bf}
2132
2133 % Fonts for indices, footnotes, small examples (9pt).
2134 \def\smallnominalsize{9pt}
2135 \setfont\smallrm\rmshape{9}{1000}{OT1}
2136 \setfont\smalltt\ttshape{9}{1000}{OT1TT}
2137 \setfont\smallbf\bfshape{10}{900}{OT1}
2138 \setfont\smallit\itshape{9}{1000}{OT1IT}
2139 \setfont\smallsl\slshape{9}{1000}{OT1}
2140 \setfont\smallsf\sfshape{9}{1000}{OT1}
2141 \setfont\smallsc\scshape{10}{900}{OT1}
2142 \setfont\smallttsl\ttslshape{10}{900}{OT1TT}
2143 \font\smalli=cmmi9
2144 \font\smallsy=cmsy9
2145 \def\smallecsize{0900}
2146
2147 % Fonts for small examples (8pt).
2148 \def\smallernominalsize{8pt}
2149 \setfont\smallerrm\rmshape{8}{1000}{OT1}
2150 \setfont\smallertt\ttshape{8}{1000}{OT1TT}
2151 \setfont\smallerbf\bfshape{10}{800}{OT1}
2152 \setfont\smallerit\itshape{8}{1000}{OT1IT}
2153 \setfont\smallersl\slshape{8}{1000}{OT1}
2154 \setfont\smallersf\sfshape{8}{1000}{OT1}
2155 \setfont\smallersc\scshape{10}{800}{OT1}
2156 \setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
2157 \font\smalleri=cmmi8
2158 \font\smallersy=cmsy8
2159 \def\smallerecsize{0800}
2160
2161 % Fonts for title page (20.4pt):
2162 \def\titlenominalsize{20pt}
2163 \setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
2164 \setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
2165 \setfont\titlesl\slbshape{10}{\magstep4}{OT1}
2166 \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
2167 \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
2168 \setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
2169 \let\titlebf=\titlerm
2170 \setfont\titlesc\scbshape{10}{\magstep4}{OT1}
2171 \font\titlei=cmmi12 scaled \magstep3
2172 \font\titlesy=cmsy10 scaled \magstep4
2173 \def\titleecsize{2074}
2174
2175 % Chapter (and unnumbered) fonts (17.28pt).
2176 \def\chapnominalsize{17pt}
2177 \setfont\chaprm\rmbshape{12}{\magstep2}{OT1}
2178 \setfont\chapit\itbshape{10}{\magstep3}{OT1IT}
2179 \setfont\chapsl\slbshape{10}{\magstep3}{OT1}
2180 \setfont\chaptt\ttbshape{12}{\magstep2}{OT1TT}
2181 \setfont\chapttsl\ttslshape{10}{\magstep3}{OT1TT}
2182 \setfont\chapsf\sfbshape{17}{1000}{OT1}
2183 \let\chapbf=\chaprm
2184 \setfont\chapsc\scbshape{10}{\magstep3}{OT1}
2185 \font\chapi=cmmi12 scaled \magstep2
2186 \font\chapsy=cmsy10 scaled \magstep3
2187 \def\chapecsize{1728}
2188
2189 % Section fonts (14.4pt).
2190 \def\secnominalsize{14pt}
2191 \setfont\secrm\rmbshape{12}{\magstep1}{OT1}
2192 \setfont\secrmnotbold\rmshape{12}{\magstep1}{OT1}
2193 \setfont\secit\itbshape{10}{\magstep2}{OT1IT}
2194 \setfont\secsl\slbshape{10}{\magstep2}{OT1}
2195 \setfont\sectt\ttbshape{12}{\magstep1}{OT1TT}
2196 \setfont\secttsl\ttslshape{10}{\magstep2}{OT1TT}
2197 \setfont\secsf\sfbshape{12}{\magstep1}{OT1}
2198 \let\secbf\secrm
2199 \setfont\secsc\scbshape{10}{\magstep2}{OT1}
2200 \font\seci=cmmi12 scaled \magstep1
2201 \font\secsy=cmsy10 scaled \magstep2
2202 \def\sececsize{1440}
2203
2204 % Subsection fonts (13.15pt).
2205 \def\ssecnominalsize{13pt}
2206 \setfont\ssecrm\rmbshape{12}{\magstephalf}{OT1}
2207 \setfont\ssecit\itbshape{10}{1315}{OT1IT}
2208 \setfont\ssecsl\slbshape{10}{1315}{OT1}
2209 \setfont\ssectt\ttbshape{12}{\magstephalf}{OT1TT}
2210 \setfont\ssecttsl\ttslshape{10}{1315}{OT1TT}
2211 \setfont\ssecsf\sfbshape{12}{\magstephalf}{OT1}
2212 \let\ssecbf\ssecrm
2213 \setfont\ssecsc\scbshape{10}{1315}{OT1}
2214 \font\sseci=cmmi12 scaled \magstephalf
2215 \font\ssecsy=cmsy10 scaled 1315
2216 \def\ssececsize{1200}
2217
2218 % Reduced fonts for @acro in text (10pt).
2219 \def\reducednominalsize{10pt}
2220 \setfont\reducedrm\rmshape{10}{1000}{OT1}
2221 \setfont\reducedtt\ttshape{10}{1000}{OT1TT}
2222 \setfont\reducedbf\bfshape{10}{1000}{OT1}
2223 \setfont\reducedit\itshape{10}{1000}{OT1IT}
2224 \setfont\reducedsl\slshape{10}{1000}{OT1}
2225 \setfont\reducedsf\sfshape{10}{1000}{OT1}
2226 \setfont\reducedsc\scshape{10}{1000}{OT1}
2227 \setfont\reducedttsl\ttslshape{10}{1000}{OT1TT}
2228 \font\reducedi=cmmi10
2229 \font\reducedsy=cmsy10
2230 \def\reducedecsize{1000}
2231
2232 \textleading = 13.2pt % line spacing for 11pt CM
2233 \textfonts            % reset the current fonts
2234 \rm
2235 } % end of 11pt text font size definitions, \definetextfontsizexi
2236
2237
2238 % Definitions to make the main text be 10pt Computer Modern, with
2239 % section, chapter, etc., sizes following suit.  This is for the GNU
2240 % Press printing of the Emacs 22 manual.  Maybe other manuals in the
2241 % future.  Used with @smallbook, which sets the leading to 12pt.
2242 %
2243 \def\definetextfontsizex{%
2244 % Text fonts (10pt).
2245 \def\textnominalsize{10pt}
2246 \edef\mainmagstep{1000}
2247 \setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
2248 \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
2249 \setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
2250 \setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
2251 \setfont\textsl\slshape{10}{\mainmagstep}{OT1}
2252 \setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
2253 \setfont\textsc\scshape{10}{\mainmagstep}{OT1}
2254 \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
2255 \font\texti=cmmi10 scaled \mainmagstep
2256 \font\textsy=cmsy10 scaled \mainmagstep
2257 \def\textecsize{1000}
2258
2259 % A few fonts for @defun names and args.
2260 \setfont\defbf\bfshape{10}{\magstephalf}{OT1}
2261 \setfont\deftt\ttshape{10}{\magstephalf}{OT1TT}
2262 \setfont\defsl\slshape{10}{\magstephalf}{OT1TT}
2263 \setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT}
2264 \def\df{\let\tentt=\deftt \let\tenbf = \defbf
2265 \let\tensl=\defsl \let\tenttsl=\defttsl \bf}
2266
2267 % Fonts for indices, footnotes, small examples (9pt).
2268 \def\smallnominalsize{9pt}
2269 \setfont\smallrm\rmshape{9}{1000}{OT1}
2270 \setfont\smalltt\ttshape{9}{1000}{OT1TT}
2271 \setfont\smallbf\bfshape{10}{900}{OT1}
2272 \setfont\smallit\itshape{9}{1000}{OT1IT}
2273 \setfont\smallsl\slshape{9}{1000}{OT1}
2274 \setfont\smallsf\sfshape{9}{1000}{OT1}
2275 \setfont\smallsc\scshape{10}{900}{OT1}
2276 \setfont\smallttsl\ttslshape{10}{900}{OT1TT}
2277 \font\smalli=cmmi9
2278 \font\smallsy=cmsy9
2279 \def\smallecsize{0900}
2280
2281 % Fonts for small examples (8pt).
2282 \def\smallernominalsize{8pt}
2283 \setfont\smallerrm\rmshape{8}{1000}{OT1}
2284 \setfont\smallertt\ttshape{8}{1000}{OT1TT}
2285 \setfont\smallerbf\bfshape{10}{800}{OT1}
2286 \setfont\smallerit\itshape{8}{1000}{OT1IT}
2287 \setfont\smallersl\slshape{8}{1000}{OT1}
2288 \setfont\smallersf\sfshape{8}{1000}{OT1}
2289 \setfont\smallersc\scshape{10}{800}{OT1}
2290 \setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
2291 \font\smalleri=cmmi8
2292 \font\smallersy=cmsy8
2293 \def\smallerecsize{0800}
2294
2295 % Fonts for title page (20.4pt):
2296 \def\titlenominalsize{20pt}
2297 \setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
2298 \setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
2299 \setfont\titlesl\slbshape{10}{\magstep4}{OT1}
2300 \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
2301 \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
2302 \setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
2303 \let\titlebf=\titlerm
2304 \setfont\titlesc\scbshape{10}{\magstep4}{OT1}
2305 \font\titlei=cmmi12 scaled \magstep3
2306 \font\titlesy=cmsy10 scaled \magstep4
2307 \def\titleecsize{2074}
2308
2309 % Chapter fonts (14.4pt).
2310 \def\chapnominalsize{14pt}
2311 \setfont\chaprm\rmbshape{12}{\magstep1}{OT1}
2312 \setfont\chapit\itbshape{10}{\magstep2}{OT1IT}
2313 \setfont\chapsl\slbshape{10}{\magstep2}{OT1}
2314 \setfont\chaptt\ttbshape{12}{\magstep1}{OT1TT}
2315 \setfont\chapttsl\ttslshape{10}{\magstep2}{OT1TT}
2316 \setfont\chapsf\sfbshape{12}{\magstep1}{OT1}
2317 \let\chapbf\chaprm
2318 \setfont\chapsc\scbshape{10}{\magstep2}{OT1}
2319 \font\chapi=cmmi12 scaled \magstep1
2320 \font\chapsy=cmsy10 scaled \magstep2
2321 \def\chapecsize{1440}
2322
2323 % Section fonts (12pt).
2324 \def\secnominalsize{12pt}
2325 \setfont\secrm\rmbshape{12}{1000}{OT1}
2326 \setfont\secit\itbshape{10}{\magstep1}{OT1IT}
2327 \setfont\secsl\slbshape{10}{\magstep1}{OT1}
2328 \setfont\sectt\ttbshape{12}{1000}{OT1TT}
2329 \setfont\secttsl\ttslshape{10}{\magstep1}{OT1TT}
2330 \setfont\secsf\sfbshape{12}{1000}{OT1}
2331 \let\secbf\secrm
2332 \setfont\secsc\scbshape{10}{\magstep1}{OT1}
2333 \font\seci=cmmi12
2334 \font\secsy=cmsy10 scaled \magstep1
2335 \def\sececsize{1200}
2336
2337 % Subsection fonts (10pt).
2338 \def\ssecnominalsize{10pt}
2339 \setfont\ssecrm\rmbshape{10}{1000}{OT1}
2340 \setfont\ssecit\itbshape{10}{1000}{OT1IT}
2341 \setfont\ssecsl\slbshape{10}{1000}{OT1}
2342 \setfont\ssectt\ttbshape{10}{1000}{OT1TT}
2343 \setfont\ssecttsl\ttslshape{10}{1000}{OT1TT}
2344 \setfont\ssecsf\sfbshape{10}{1000}{OT1}
2345 \let\ssecbf\ssecrm
2346 \setfont\ssecsc\scbshape{10}{1000}{OT1}
2347 \font\sseci=cmmi10
2348 \font\ssecsy=cmsy10
2349 \def\ssececsize{1000}
2350
2351 % Reduced fonts for @acro in text (9pt).
2352 \def\reducednominalsize{9pt}
2353 \setfont\reducedrm\rmshape{9}{1000}{OT1}
2354 \setfont\reducedtt\ttshape{9}{1000}{OT1TT}
2355 \setfont\reducedbf\bfshape{10}{900}{OT1}
2356 \setfont\reducedit\itshape{9}{1000}{OT1IT}
2357 \setfont\reducedsl\slshape{9}{1000}{OT1}
2358 \setfont\reducedsf\sfshape{9}{1000}{OT1}
2359 \setfont\reducedsc\scshape{10}{900}{OT1}
2360 \setfont\reducedttsl\ttslshape{10}{900}{OT1TT}
2361 \font\reducedi=cmmi9
2362 \font\reducedsy=cmsy9
2363 \def\reducedecsize{0900}
2364
2365 \divide\parskip by 2  % reduce space between paragraphs
2366 \textleading = 12pt   % line spacing for 10pt CM
2367 \textfonts            % reset the current fonts
2368 \rm
2369 } % end of 10pt text font size definitions, \definetextfontsizex
2370
2371
2372 % We provide the user-level command
2373 %   @fonttextsize 10
2374 % (or 11) to redefine the text font size.  pt is assumed.
2375 %
2376 \def\xiword{11}
2377 \def\xword{10}
2378 \def\xwordpt{10pt}
2379 %
2380 \parseargdef\fonttextsize{%
2381   \def\textsizearg{#1}%
2382   %\wlog{doing @fonttextsize \textsizearg}%
2383   %
2384   % Set \globaldefs so that documents can use this inside @tex, since
2385   % makeinfo 4.8 does not support it, but we need it nonetheless.
2386   %
2387  \begingroup \globaldefs=1
2388   \ifx\textsizearg\xword \definetextfontsizex
2389   \else \ifx\textsizearg\xiword \definetextfontsizexi
2390   \else
2391     \errhelp=\EMsimple
2392     \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'}
2393   \fi\fi
2394  \endgroup
2395 }
2396
2397 % In order for the font changes to affect most math symbols and letters,
2398 % we have to define the \textfont of the standard families.  We don't
2399 % bother to reset \scriptfont and \scriptscriptfont; awaiting user need.
2400 %
2401 \def\resetmathfonts{%
2402   \textfont0=\tenrm \textfont1=\teni \textfont2=\tensy
2403   \textfont\itfam=\tenit \textfont\slfam=\tensl \textfont\bffam=\tenbf
2404   \textfont\ttfam=\tentt \textfont\sffam=\tensf
2405 }
2406
2407 % The font-changing commands redefine the meanings of \tenSTYLE, instead
2408 % of just \STYLE.  We do this because \STYLE needs to also set the
2409 % current \fam for math mode.  Our \STYLE (e.g., \rm) commands hardwire
2410 % \tenSTYLE to set the current font.
2411 %
2412 % Each font-changing command also sets the names \lsize (one size lower)
2413 % and \lllsize (three sizes lower).  These relative commands are used
2414 % in, e.g., the LaTeX logo and acronyms.
2415 %
2416 % This all needs generalizing, badly.
2417 %
2418 \def\textfonts{%
2419   \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
2420   \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
2421   \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy
2422   \let\tenttsl=\textttsl
2423   \def\curfontsize{text}%
2424   \def\lsize{reduced}\def\lllsize{smaller}%
2425   \resetmathfonts \setleading{\textleading}}
2426 \def\titlefonts{%
2427   \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl
2428   \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc
2429   \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy
2430   \let\tenttsl=\titlettsl
2431   \def\curfontsize{title}%
2432   \def\lsize{chap}\def\lllsize{subsec}%
2433   \resetmathfonts \setleading{27pt}}
2434 \def\titlefont#1{{\titlefonts\rmisbold #1}}
2435 \def\chapfonts{%
2436   \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl
2437   \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
2438   \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy
2439   \let\tenttsl=\chapttsl
2440   \def\curfontsize{chap}%
2441   \def\lsize{sec}\def\lllsize{text}%
2442   \resetmathfonts \setleading{19pt}}
2443 \def\secfonts{%
2444   \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl
2445   \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc
2446   \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy
2447   \let\tenttsl=\secttsl
2448   \def\curfontsize{sec}%
2449   \def\lsize{subsec}\def\lllsize{reduced}%
2450   \resetmathfonts \setleading{17pt}}
2451 \def\subsecfonts{%
2452   \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl
2453   \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc
2454   \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy
2455   \let\tenttsl=\ssecttsl
2456   \def\curfontsize{ssec}%
2457   \def\lsize{text}\def\lllsize{small}%
2458   \resetmathfonts \setleading{15pt}}
2459 \let\subsubsecfonts = \subsecfonts
2460 \def\reducedfonts{%
2461   \let\tenrm=\reducedrm \let\tenit=\reducedit \let\tensl=\reducedsl
2462   \let\tenbf=\reducedbf \let\tentt=\reducedtt \let\reducedcaps=\reducedsc
2463   \let\tensf=\reducedsf \let\teni=\reducedi \let\tensy=\reducedsy
2464   \let\tenttsl=\reducedttsl
2465   \def\curfontsize{reduced}%
2466   \def\lsize{small}\def\lllsize{smaller}%
2467   \resetmathfonts \setleading{10.5pt}}
2468 \def\smallfonts{%
2469   \let\tenrm=\smallrm \let\tenit=\smallit \let\tensl=\smallsl
2470   \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc
2471   \let\tensf=\smallsf \let\teni=\smalli \let\tensy=\smallsy
2472   \let\tenttsl=\smallttsl
2473   \def\curfontsize{small}%
2474   \def\lsize{smaller}\def\lllsize{smaller}%
2475   \resetmathfonts \setleading{10.5pt}}
2476 \def\smallerfonts{%
2477   \let\tenrm=\smallerrm \let\tenit=\smallerit \let\tensl=\smallersl
2478   \let\tenbf=\smallerbf \let\tentt=\smallertt \let\smallcaps=\smallersc
2479   \let\tensf=\smallersf \let\teni=\smalleri \let\tensy=\smallersy
2480   \let\tenttsl=\smallerttsl
2481   \def\curfontsize{smaller}%
2482   \def\lsize{smaller}\def\lllsize{smaller}%
2483   \resetmathfonts \setleading{9.5pt}}
2484
2485 % Fonts for short table of contents.
2486 \setfont\shortcontrm\rmshape{12}{1000}{OT1}
2487 \setfont\shortcontbf\bfshape{10}{\magstep1}{OT1}  % no cmb12
2488 \setfont\shortcontsl\slshape{12}{1000}{OT1}
2489 \setfont\shortconttt\ttshape{12}{1000}{OT1TT}
2490
2491 % Define these just so they can be easily changed for other fonts.
2492 \def\angleleft{$\langle$}
2493 \def\angleright{$\rangle$}
2494
2495 % Set the fonts to use with the @small... environments.
2496 \let\smallexamplefonts = \smallfonts
2497
2498 % About \smallexamplefonts.  If we use \smallfonts (9pt), @smallexample
2499 % can fit this many characters:
2500 %   8.5x11=86   smallbook=72  a4=90  a5=69
2501 % If we use \scriptfonts (8pt), then we can fit this many characters:
2502 %   8.5x11=90+  smallbook=80  a4=90+  a5=77
2503 % For me, subjectively, the few extra characters that fit aren't worth
2504 % the additional smallness of 8pt.  So I'm making the default 9pt.
2505 %
2506 % By the way, for comparison, here's what fits with @example (10pt):
2507 %   8.5x11=71  smallbook=60  a4=75  a5=58
2508 % --karl, 24jan03.
2509
2510 % Set up the default fonts, so we can use them for creating boxes.
2511 %
2512 \definetextfontsizexi
2513
2514
2515 \message{markup,}
2516
2517 % Check if we are currently using a typewriter font.  Since all the
2518 % Computer Modern typewriter fonts have zero interword stretch (and
2519 % shrink), and it is reasonable to expect all typewriter fonts to have
2520 % this property, we can check that font parameter.
2521 %
2522 \def\ifmonospace{\ifdim\fontdimen3\font=0pt }
2523
2524 % Markup style infrastructure.  \defmarkupstylesetup\INITMACRO will
2525 % define and register \INITMACRO to be called on markup style changes.
2526 % \INITMACRO can check \currentmarkupstyle for the innermost
2527 % style and the set of \ifmarkupSTYLE switches for all styles
2528 % currently in effect.
2529 \newif\ifmarkupvar
2530 \newif\ifmarkupsamp
2531 \newif\ifmarkupkey
2532 %\newif\ifmarkupfile % @file == @samp.
2533 %\newif\ifmarkupoption % @option == @samp.
2534 \newif\ifmarkupcode
2535 \newif\ifmarkupkbd
2536 %\newif\ifmarkupenv % @env == @code.
2537 %\newif\ifmarkupcommand % @command == @code.
2538 \newif\ifmarkuptex % @tex (and part of @math, for now).
2539 \newif\ifmarkupexample
2540 \newif\ifmarkupverb
2541 \newif\ifmarkupverbatim
2542
2543 \let\currentmarkupstyle\empty
2544
2545 \def\setupmarkupstyle#1{%
2546   \csname markup#1true\endcsname
2547   \def\currentmarkupstyle{#1}%
2548   \markupstylesetup
2549 }
2550
2551 \let\markupstylesetup\empty
2552
2553 \def\defmarkupstylesetup#1{%
2554   \expandafter\def\expandafter\markupstylesetup
2555     \expandafter{\markupstylesetup #1}%
2556   \def#1%
2557 }
2558
2559 % Markup style setup for left and right quotes.
2560 \defmarkupstylesetup\markupsetuplq{%
2561   \expandafter\let\expandafter \temp
2562     \csname markupsetuplq\currentmarkupstyle\endcsname
2563   \ifx\temp\relax \markupsetuplqdefault \else \temp \fi
2564 }
2565
2566 \defmarkupstylesetup\markupsetuprq{%
2567   \expandafter\let\expandafter \temp
2568     \csname markupsetuprq\currentmarkupstyle\endcsname
2569   \ifx\temp\relax \markupsetuprqdefault \else \temp \fi
2570 }
2571
2572 {
2573 \catcode`\'=\active
2574 \catcode`\`=\active
2575
2576 \gdef\markupsetuplqdefault{\let`\lq}
2577 \gdef\markupsetuprqdefault{\let'\rq}
2578
2579 \gdef\markupsetcodequoteleft{\let`\codequoteleft}
2580 \gdef\markupsetcodequoteright{\let'\codequoteright}
2581 }
2582
2583 \let\markupsetuplqcode \markupsetcodequoteleft
2584 \let\markupsetuprqcode \markupsetcodequoteright
2585 %
2586 \let\markupsetuplqexample \markupsetcodequoteleft
2587 \let\markupsetuprqexample \markupsetcodequoteright
2588 %
2589 \let\markupsetuplqkbd     \markupsetcodequoteleft
2590 \let\markupsetuprqkbd     \markupsetcodequoteright
2591 %
2592 \let\markupsetuplqsamp \markupsetcodequoteleft
2593 \let\markupsetuprqsamp \markupsetcodequoteright
2594 %
2595 \let\markupsetuplqverb \markupsetcodequoteleft
2596 \let\markupsetuprqverb \markupsetcodequoteright
2597 %
2598 \let\markupsetuplqverbatim \markupsetcodequoteleft
2599 \let\markupsetuprqverbatim \markupsetcodequoteright
2600
2601 % Allow an option to not use regular directed right quote/apostrophe
2602 % (char 0x27), but instead the undirected quote from cmtt (char 0x0d).
2603 % The undirected quote is ugly, so don't make it the default, but it
2604 % works for pasting with more pdf viewers (at least evince), the
2605 % lilypond developers report.  xpdf does work with the regular 0x27.
2606 %
2607 \def\codequoteright{%
2608   \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax
2609     \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax
2610       '%
2611     \else \char'15 \fi
2612   \else \char'15 \fi
2613 }
2614 %
2615 % and a similar option for the left quote char vs. a grave accent.
2616 % Modern fonts display ASCII 0x60 as a grave accent, so some people like
2617 % the code environments to do likewise.
2618 %
2619 \def\codequoteleft{%
2620   \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax
2621     \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax
2622       % [Knuth] pp. 380,381,391
2623       % \relax disables Spanish ligatures ?` and !` of \tt font.
2624       \relax`%
2625     \else \char'22 \fi
2626   \else \char'22 \fi
2627 }
2628
2629 % Commands to set the quote options.
2630
2631 \parseargdef\codequoteundirected{%
2632   \def\temp{#1}%
2633   \ifx\temp\onword
2634     \expandafter\let\csname SETtxicodequoteundirected\endcsname
2635       = t%
2636   \else\ifx\temp\offword
2637     \expandafter\let\csname SETtxicodequoteundirected\endcsname
2638       = \relax
2639   \else
2640     \errhelp = \EMsimple
2641     \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}%
2642   \fi\fi
2643 }
2644 %
2645 \parseargdef\codequotebacktick{%
2646   \def\temp{#1}%
2647   \ifx\temp\onword
2648     \expandafter\let\csname SETtxicodequotebacktick\endcsname
2649       = t%
2650   \else\ifx\temp\offword
2651     \expandafter\let\csname SETtxicodequotebacktick\endcsname
2652       = \relax
2653   \else
2654     \errhelp = \EMsimple
2655     \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}%
2656   \fi\fi
2657 }
2658
2659 % [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font.
2660 \def\noligaturesquoteleft{\relax\lq}
2661
2662 % Count depth in font-changes, for error checks
2663 \newcount\fontdepth \fontdepth=0
2664
2665 % Font commands.
2666
2667 % #1 is the font command (\sl or \it), #2 is the text to slant.
2668 % If we are in a monospaced environment, however, 1) always use \ttsl,
2669 % and 2) do not add an italic correction.
2670 \def\dosmartslant#1#2{%
2671   \ifusingtt 
2672     {{\ttsl #2}\let\next=\relax}%
2673     {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}%
2674   \next
2675 }
2676 \def\smartslanted{\dosmartslant\sl}
2677 \def\smartitalic{\dosmartslant\it}
2678
2679 % Output an italic correction unless \next (presumed to be the following
2680 % character) is such as not to need one.
2681 \def\smartitaliccorrection{%
2682   \ifx\next,%
2683   \else\ifx\next-%
2684   \else\ifx\next.%
2685   \else\ifx\next\.%
2686   \else\ifx\next\comma%
2687   \else\ptexslash
2688   \fi\fi\fi\fi\fi
2689   \aftersmartic
2690 }
2691
2692 % Unconditional use \ttsl, and no ic.  @var is set to this for defuns.
2693 \def\ttslanted#1{{\ttsl #1}}
2694
2695 % @cite is like \smartslanted except unconditionally use \sl.  We never want
2696 % ttsl for book titles, do we?
2697 \def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection}
2698
2699 \def\aftersmartic{}
2700 \def\var#1{%
2701   \let\saveaftersmartic = \aftersmartic
2702   \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}%
2703   \smartslanted{#1}%
2704 }
2705
2706 \let\i=\smartitalic
2707 \let\slanted=\smartslanted
2708 \let\dfn=\smartslanted
2709 \let\emph=\smartitalic
2710
2711 % Explicit font changes: @r, @sc, undocumented @ii.
2712 \def\r#1{{\rm #1}}              % roman font
2713 \def\sc#1{{\smallcaps#1}}       % smallcaps font
2714 \def\ii#1{{\it #1}}             % italic font
2715
2716 % @b, explicit bold.  Also @strong.
2717 \def\b#1{{\bf #1}}
2718 \let\strong=\b
2719
2720 % @sansserif, explicit sans.
2721 \def\sansserif#1{{\sf #1}}
2722
2723 % We can't just use \exhyphenpenalty, because that only has effect at
2724 % the end of a paragraph.  Restore normal hyphenation at the end of the
2725 % group within which \nohyphenation is presumably called.
2726 %
2727 \def\nohyphenation{\hyphenchar\font = -1  \aftergroup\restorehyphenation}
2728 \def\restorehyphenation{\hyphenchar\font = `- }
2729
2730 % Set sfcode to normal for the chars that usually have another value.
2731 % Can't use plain's \frenchspacing because it uses the `\x notation, and
2732 % sometimes \x has an active definition that messes things up.
2733 %
2734 \catcode`@=11
2735   \def\plainfrenchspacing{%
2736     \sfcode`\.=\@m \sfcode`\?=\@m \sfcode`\!=\@m
2737     \sfcode`\:=\@m \sfcode`\;=\@m \sfcode`\,=\@m
2738     \def\endofsentencespacefactor{1000}% for @. and friends
2739   }
2740   \def\plainnonfrenchspacing{%
2741     \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000
2742     \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250
2743     \def\endofsentencespacefactor{3000}% for @. and friends
2744   }
2745 \catcode`@=\other
2746 \def\endofsentencespacefactor{3000}% default
2747
2748 % @t, explicit typewriter.
2749 \def\t#1{%
2750   {\tt \rawbackslash \plainfrenchspacing #1}%
2751   \null
2752 }
2753
2754 % @samp.
2755 \def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}}
2756
2757 % @indicateurl is \samp, that is, with quotes.
2758 \let\indicateurl=\samp
2759
2760 % @code (and similar) prints in typewriter, but with spaces the same
2761 % size as normal in the surrounding text, without hyphenation, etc.
2762 % This is a subroutine for that.
2763 \def\tclose#1{%
2764   {%
2765     % Change normal interword space to be same as for the current font.
2766     \spaceskip = \fontdimen2\font
2767     %
2768     % Switch to typewriter.
2769     \tt
2770     %
2771     % But `\ ' produces the large typewriter interword space.
2772     \def\ {{\spaceskip = 0pt{} }}%
2773     %
2774     % Turn off hyphenation.
2775     \nohyphenation
2776     %
2777     \rawbackslash
2778     \plainfrenchspacing
2779     #1%
2780   }%
2781   \null % reset spacefactor to 1000
2782 }
2783
2784 % We *must* turn on hyphenation at `-' and `_' in @code.
2785 % (But see \codedashfinish below.)
2786 % Otherwise, it is too hard to avoid overfull hboxes
2787 % in the Emacs manual, the Library manual, etc.
2788 %
2789 % Unfortunately, TeX uses one parameter (\hyphenchar) to control
2790 % both hyphenation at - and hyphenation within words.
2791 % We must therefore turn them both off (\tclose does that)
2792 % and arrange explicitly to hyphenate at a dash. -- rms.
2793 {
2794   \catcode`\-=\active \catcode`\_=\active
2795   \catcode`\'=\active \catcode`\`=\active
2796   \global\let'=\rq \global\let`=\lq  % default definitions
2797   %
2798   \global\def\code{\begingroup
2799     \setupmarkupstyle{code}%
2800     % The following should really be moved into \setupmarkupstyle handlers.
2801     \catcode\dashChar=\active  \catcode\underChar=\active
2802     \ifallowcodebreaks
2803      \let-\codedash
2804      \let_\codeunder
2805     \else
2806      \let-\normaldash
2807      \let_\realunder
2808     \fi
2809     % Given -foo (with a single dash), we do not want to allow a break
2810     % after the hyphen.
2811     \global\let\codedashprev=\codedash
2812     %
2813     \codex
2814   }
2815   %
2816   \gdef\codedash{\futurelet\next\codedashfinish}
2817   \gdef\codedashfinish{%
2818     \normaldash % always output the dash character itself.
2819     % 
2820     % Now, output a discretionary to allow a line break, unless
2821     % (a) the next character is a -, or
2822     % (b) the preceding character is a -.
2823     % E.g., given --posix, we do not want to allow a break after either -.
2824     % Given --foo-bar, we do want to allow a break between the - and the b.
2825     \ifx\next\codedash \else
2826       \ifx\codedashprev\codedash 
2827       \else \discretionary{}{}{}\fi
2828     \fi
2829     % we need the space after the = for the case when \next itself is a
2830     % space token; it would get swallowed otherwise.  As in @code{- a}.
2831     \global\let\codedashprev= \next
2832   }
2833 }
2834 \def\normaldash{-}
2835 %
2836 \def\codex #1{\tclose{#1}\endgroup}
2837
2838 \def\codeunder{%
2839   % this is all so @math{@code{var_name}+1} can work.  In math mode, _
2840   % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.)
2841   % will therefore expand the active definition of _, which is us
2842   % (inside @code that is), therefore an endless loop.
2843   \ifusingtt{\ifmmode
2844                \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_.
2845              \else\normalunderscore \fi
2846              \discretionary{}{}{}}%
2847             {\_}%
2848 }
2849
2850 % An additional complication: the above will allow breaks after, e.g.,
2851 % each of the four underscores in __typeof__.  This is bad.
2852 % @allowcodebreaks provides a document-level way to turn breaking at -
2853 % and _ on and off.
2854 %
2855 \newif\ifallowcodebreaks  \allowcodebreakstrue
2856
2857 \def\keywordtrue{true}
2858 \def\keywordfalse{false}
2859
2860 \parseargdef\allowcodebreaks{%
2861   \def\txiarg{#1}%
2862   \ifx\txiarg\keywordtrue
2863     \allowcodebreakstrue
2864   \else\ifx\txiarg\keywordfalse
2865     \allowcodebreaksfalse
2866   \else
2867     \errhelp = \EMsimple
2868     \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}%
2869   \fi\fi
2870 }
2871
2872 % For @command, @env, @file, @option quotes seem unnecessary,
2873 % so use \code rather than \samp.
2874 \let\command=\code
2875 \let\env=\code
2876 \let\file=\code
2877 \let\option=\code
2878
2879 % @uref (abbreviation for `urlref') aka @url takes an optional
2880 % (comma-separated) second argument specifying the text to display and
2881 % an optional third arg as text to display instead of (rather than in
2882 % addition to) the url itself.  First (mandatory) arg is the url.
2883
2884 % TeX-only option to allow changing PDF output to show only the second
2885 % arg (if given), and not the url (which is then just the link target).
2886 \newif\ifurefurlonlylink
2887
2888 % The main macro is \urefbreak, which allows breaking at expected
2889 % places within the url.  (There used to be another version, which
2890 % didn't support automatic breaking.)
2891 \def\urefbreak{\begingroup \urefcatcodes \dourefbreak}
2892 \let\uref=\urefbreak
2893 %
2894 \def\dourefbreak#1{\urefbreakfinish #1,,,\finish}
2895 \def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example
2896   \unsepspaces
2897   \pdfurl{#1}%
2898   \setbox0 = \hbox{\ignorespaces #3}%
2899   \ifdim\wd0 > 0pt
2900     \unhbox0 % third arg given, show only that
2901   \else
2902     \setbox0 = \hbox{\ignorespaces #2}% look for second arg
2903     \ifdim\wd0 > 0pt
2904       \ifpdf
2905         % For pdfTeX and LuaTeX
2906         \ifurefurlonlylink
2907           % PDF plus option to not display url, show just arg
2908           \unhbox0             
2909         \else
2910           % PDF, normally display both arg and url for consistency,
2911           % visibility, if the pdf is eventually used to print, etc.
2912           \unhbox0\ (\urefcode{#1})%
2913         \fi
2914       \else
2915         \ifx\XeTeXrevision\thisisundefined
2916           \unhbox0\ (\urefcode{#1})% DVI, always show arg and url
2917         \else
2918           % For XeTeX
2919           \ifurefurlonlylink
2920             % PDF plus option to not display url, show just arg
2921             \unhbox0             
2922           \else
2923             % PDF, normally display both arg and url for consistency,
2924             % visibility, if the pdf is eventually used to print, etc.
2925             \unhbox0\ (\urefcode{#1})%
2926           \fi
2927         \fi
2928       \fi
2929     \else
2930       \urefcode{#1}% only url given, so show it
2931     \fi
2932   \fi
2933   \endlink
2934 \endgroup}
2935
2936 % Allow line breaks around only a few characters (only).
2937 \def\urefcatcodes{%
2938   \catcode`\&=\active \catcode`\.=\active
2939   \catcode`\#=\active \catcode`\?=\active
2940   \catcode`\/=\active
2941 }
2942 {
2943   \urefcatcodes
2944   %
2945   \global\def\urefcode{\begingroup
2946     \setupmarkupstyle{code}%
2947     \urefcatcodes
2948     \let&\urefcodeamp
2949     \let.\urefcodedot
2950     \let#\urefcodehash
2951     \let?\urefcodequest
2952     \let/\urefcodeslash
2953     \codex
2954   }
2955   %
2956   % By default, they are just regular characters.
2957   \global\def&{\normalamp}
2958   \global\def.{\normaldot}
2959   \global\def#{\normalhash}
2960   \global\def?{\normalquest}
2961   \global\def/{\normalslash}
2962 }
2963
2964 % we put a little stretch before and after the breakable chars, to help
2965 % line breaking of long url's.  The unequal skips make look better in
2966 % cmtt at least, especially for dots.
2967 \def\urefprestretchamount{.13em}
2968 \def\urefpoststretchamount{.1em}
2969 \def\urefprestretch{\urefprebreak \hskip0pt plus\urefprestretchamount\relax}
2970 \def\urefpoststretch{\urefpostbreak \hskip0pt plus\urefprestretchamount\relax}
2971 %
2972 \def\urefcodeamp{\urefprestretch \&\urefpoststretch}
2973 \def\urefcodedot{\urefprestretch .\urefpoststretch}
2974 \def\urefcodehash{\urefprestretch \#\urefpoststretch}
2975 \def\urefcodequest{\urefprestretch ?\urefpoststretch}
2976 \def\urefcodeslash{\futurelet\next\urefcodeslashfinish}
2977 {
2978   \catcode`\/=\active
2979   \global\def\urefcodeslashfinish{%
2980     \urefprestretch \slashChar
2981     % Allow line break only after the final / in a sequence of
2982     % slashes, to avoid line break between the slashes in http://.
2983     \ifx\next/\else \urefpoststretch \fi
2984   }
2985 }
2986
2987 % One more complication: by default we'll break after the special
2988 % characters, but some people like to break before the special chars, so
2989 % allow that.  Also allow no breaking at all, for manual control.
2990
2991 \parseargdef\urefbreakstyle{%
2992   \def\txiarg{#1}%
2993   \ifx\txiarg\wordnone
2994     \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak}
2995   \else\ifx\txiarg\wordbefore
2996     \def\urefprebreak{\allowbreak}\def\urefpostbreak{\nobreak}
2997   \else\ifx\txiarg\wordafter
2998     \def\urefprebreak{\nobreak}\def\urefpostbreak{\allowbreak}
2999   \else
3000     \errhelp = \EMsimple
3001     \errmessage{Unknown @urefbreakstyle setting `\txiarg'}%
3002   \fi\fi\fi
3003 }
3004 \def\wordafter{after}
3005 \def\wordbefore{before}
3006 \def\wordnone{none}
3007
3008 \urefbreakstyle after
3009
3010 % @url synonym for @uref, since that's how everyone uses it.
3011 %
3012 \let\url=\uref
3013
3014 % rms does not like angle brackets --karl, 17may97.
3015 % So now @email is just like @uref, unless we are pdf.
3016 %
3017 %\def\email#1{\angleleft{\tt #1}\angleright}
3018 \ifpdf
3019   \def\email#1{\doemail#1,,\finish}
3020   \def\doemail#1,#2,#3\finish{\begingroup
3021     \unsepspaces
3022     \pdfurl{mailto:#1}%
3023     \setbox0 = \hbox{\ignorespaces #2}%
3024     \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
3025     \endlink
3026   \endgroup}
3027 \else
3028   \ifx\XeTeXrevision\thisisundefined
3029     \let\email=\uref
3030   \else
3031     \def\email#1{\doemail#1,,\finish}
3032     \def\doemail#1,#2,#3\finish{\begingroup
3033       \unsepspaces
3034       \pdfurl{mailto:#1}%
3035       \setbox0 = \hbox{\ignorespaces #2}%
3036       \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
3037       \endlink
3038     \endgroup}
3039   \fi
3040 \fi
3041
3042 % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
3043 %   `example' (@kbd uses ttsl only inside of @example and friends),
3044 %   or `code' (@kbd uses normal tty font always).
3045 \parseargdef\kbdinputstyle{%
3046   \def\txiarg{#1}%
3047   \ifx\txiarg\worddistinct
3048     \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
3049   \else\ifx\txiarg\wordexample
3050     \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
3051   \else\ifx\txiarg\wordcode
3052     \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
3053   \else
3054     \errhelp = \EMsimple
3055     \errmessage{Unknown @kbdinputstyle setting `\txiarg'}%
3056   \fi\fi\fi
3057 }
3058 \def\worddistinct{distinct}
3059 \def\wordexample{example}
3060 \def\wordcode{code}
3061
3062 % Default is `distinct'.
3063 \kbdinputstyle distinct
3064
3065 % @kbd is like @code, except that if the argument is just one @key command,
3066 % then @kbd has no effect.
3067 \def\kbd#1{{\def\look{#1}\expandafter\kbdsub\look??\par}}
3068
3069 \def\xkey{\key}
3070 \def\kbdsub#1#2#3\par{%
3071   \def\one{#1}\def\three{#3}\def\threex{??}%
3072   \ifx\one\xkey\ifx\threex\three \key{#2}%
3073   \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
3074   \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
3075 }
3076
3077 % definition of @key that produces a lozenge.  Doesn't adjust to text size.
3078 %\setfont\keyrm\rmshape{8}{1000}{OT1}
3079 %\font\keysy=cmsy9
3080 %\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
3081 %  \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
3082 %    \vbox{\hrule\kern-0.4pt
3083 %     \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
3084 %    \kern-0.4pt\hrule}%
3085 %  \kern-.06em\raise0.4pt\hbox{\angleright}}}}
3086
3087 % definition of @key with no lozenge.  If the current font is already
3088 % monospace, don't change it; that way, we respect @kbdinputstyle.  But
3089 % if it isn't monospace, then use \tt.
3090 %
3091 \def\key#1{{\setupmarkupstyle{key}%
3092   \nohyphenation
3093   \ifmonospace\else\tt\fi
3094   #1}\null}
3095
3096 % @clicksequence{File @click{} Open ...}
3097 \def\clicksequence#1{\begingroup #1\endgroup}
3098
3099 % @clickstyle @arrow   (by default)
3100 \parseargdef\clickstyle{\def\click{#1}}
3101 \def\click{\arrow}
3102
3103 % Typeset a dimension, e.g., `in' or `pt'.  The only reason for the
3104 % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
3105 %
3106 \def\dmn#1{\thinspace #1}
3107
3108 % @acronym for "FBI", "NATO", and the like.
3109 % We print this one point size smaller, since it's intended for
3110 % all-uppercase.
3111 %
3112 \def\acronym#1{\doacronym #1,,\finish}
3113 \def\doacronym#1,#2,#3\finish{%
3114   {\selectfonts\lsize #1}%
3115   \def\temp{#2}%
3116   \ifx\temp\empty \else
3117     \space ({\unsepspaces \ignorespaces \temp \unskip})%
3118   \fi
3119   \null % reset \spacefactor=1000
3120 }
3121
3122 % @abbr for "Comput. J." and the like.
3123 % No font change, but don't do end-of-sentence spacing.
3124 %
3125 \def\abbr#1{\doabbr #1,,\finish}
3126 \def\doabbr#1,#2,#3\finish{%
3127   {\plainfrenchspacing #1}%
3128   \def\temp{#2}%
3129   \ifx\temp\empty \else
3130     \space ({\unsepspaces \ignorespaces \temp \unskip})%
3131   \fi
3132   \null % reset \spacefactor=1000
3133 }
3134
3135 % @asis just yields its argument.  Used with @table, for example.
3136 %
3137 \def\asis#1{#1}
3138
3139 % @math outputs its argument in math mode.
3140 %
3141 % One complication: _ usually means subscripts, but it could also mean
3142 % an actual _ character, as in @math{@var{some_variable} + 1}.  So make
3143 % _ active, and distinguish by seeing if the current family is \slfam,
3144 % which is what @var uses.
3145 {
3146   \catcode`\_ = \active
3147   \gdef\mathunderscore{%
3148     \catcode`\_=\active
3149     \def_{\ifnum\fam=\slfam \_\else\sb\fi}%
3150   }
3151 }
3152 % Another complication: we want \\ (and @\) to output a math (or tt) \.
3153 % FYI, plain.tex uses \\ as a temporary control sequence (for no
3154 % particular reason), but this is not advertised and we don't care.
3155 %
3156 % The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\.
3157 \def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi}
3158 %
3159 \def\math{%
3160   \ifmmode\else % only go into math if not in math mode already
3161     \tex
3162     \mathunderscore
3163     \let\\ = \mathbackslash
3164     \mathactive
3165     % make the texinfo accent commands work in math mode
3166     \let\"=\ddot
3167     \let\'=\acute
3168     \let\==\bar
3169     \let\^=\hat
3170     \let\`=\grave
3171     \let\u=\breve
3172     \let\v=\check
3173     \let\~=\tilde
3174     \let\dotaccent=\dot
3175     % have to provide another name for sup operator
3176     \let\mathopsup=\sup
3177   $\expandafter\finishmath\fi
3178 }
3179 \def\finishmath#1{#1$\endgroup}  % Close the group opened by \tex.
3180
3181 % Some active characters (such as <) are spaced differently in math.
3182 % We have to reset their definitions in case the @math was an argument
3183 % to a command which sets the catcodes (such as @item or @section).
3184 %
3185 {
3186   \catcode`^ = \active
3187   \catcode`< = \active
3188   \catcode`> = \active
3189   \catcode`+ = \active
3190   \catcode`' = \active
3191   \gdef\mathactive{%
3192     \let^ = \ptexhat
3193     \let< = \ptexless
3194     \let> = \ptexgtr
3195     \let+ = \ptexplus
3196     \let' = \ptexquoteright
3197   }
3198 }
3199
3200 % for @sub and @sup, if in math mode, just do a normal sub/superscript.
3201 % If in text, use math to place as sub/superscript, but switch
3202 % into text mode, with smaller fonts.  This is a different font than the
3203 % one used for real math sub/superscripts (8pt vs. 7pt), but let's not
3204 % fix it (significant additions to font machinery) until someone notices.
3205 %
3206 \def\sub{\ifmmode \expandafter\sb \else \expandafter\finishsub\fi}
3207 \def\finishsub#1{$\sb{\hbox{\selectfonts\lllsize #1}}$}%
3208 %
3209 \def\sup{\ifmmode \expandafter\ptexsp \else \expandafter\finishsup\fi}
3210 \def\finishsup#1{$\ptexsp{\hbox{\selectfonts\lllsize #1}}$}%
3211
3212 % @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}.
3213 % Ignore unless FMTNAME == tex; then it is like @iftex and @tex,
3214 % except specified as a normal braced arg, so no newlines to worry about.
3215
3216 \def\outfmtnametex{tex}
3217 %
3218 \long\def\inlinefmt#1{\doinlinefmt #1,\finish}
3219 \long\def\doinlinefmt#1,#2,\finish{%
3220   \def\inlinefmtname{#1}%
3221   \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi
3222 }
3223
3224 % @inlinefmtifelse{FMTNAME,THEN-TEXT,ELSE-TEXT} expands THEN-TEXT if
3225 % FMTNAME is tex, else ELSE-TEXT.
3226 \long\def\inlinefmtifelse#1{\doinlinefmtifelse #1,,,\finish}
3227 \long\def\doinlinefmtifelse#1,#2,#3,#4,\finish{%
3228   \def\inlinefmtname{#1}%
3229   \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\else \ignorespaces #3\fi
3230 }
3231 %
3232 % For raw, must switch into @tex before parsing the argument, to avoid
3233 % setting catcodes prematurely.  Doing it this way means that, for
3234 % example, @inlineraw{html, foo{bar} gets a parse error instead of being
3235 % ignored.  But this isn't important because if people want a literal
3236 % *right* brace they would have to use a command anyway, so they may as
3237 % well use a command to get a left brace too.  We could re-use the
3238 % delimiter character idea from \verb, but it seems like overkill.
3239
3240 \long\def\inlineraw{\tex \doinlineraw}
3241 \long\def\doinlineraw#1{\doinlinerawtwo #1,\finish}
3242 \def\doinlinerawtwo#1,#2,\finish{%
3243   \def\inlinerawname{#1}%
3244   \ifx\inlinerawname\outfmtnametex \ignorespaces #2\fi
3245   \endgroup % close group opened by \tex.
3246 }
3247
3248 % @inlineifset{VAR, TEXT} expands TEXT if VAR is @set.
3249 %
3250 \long\def\inlineifset#1{\doinlineifset #1,\finish}
3251 \long\def\doinlineifset#1,#2,\finish{%
3252   \def\inlinevarname{#1}%
3253   \expandafter\ifx\csname SET\inlinevarname\endcsname\relax
3254   \else\ignorespaces#2\fi
3255 }
3256
3257 % @inlineifclear{VAR, TEXT} expands TEXT if VAR is not @set.
3258 %
3259 \long\def\inlineifclear#1{\doinlineifclear #1,\finish}
3260 \long\def\doinlineifclear#1,#2,\finish{%
3261   \def\inlinevarname{#1}%
3262   \expandafter\ifx\csname SET\inlinevarname\endcsname\relax \ignorespaces#2\fi
3263 }
3264
3265
3266 \message{glyphs,}
3267 % and logos.
3268
3269 % @@ prints an @, as does @atchar{}.
3270 \def\@{\char64 }
3271 \let\atchar=\@
3272
3273 % @{ @} @lbracechar{} @rbracechar{} all generate brace characters.
3274 % Unless we're in typewriter, use \ecfont because the CM text fonts do
3275 % not have braces, and we don't want to switch into math.
3276 \def\mylbrace{{\ifmonospace\char123\else\ensuremath\lbrace\fi}}
3277 \def\myrbrace{{\ifmonospace\char125\else\ensuremath\rbrace\fi}}
3278 \let\{=\mylbrace \let\lbracechar=\{
3279 \let\}=\myrbrace \let\rbracechar=\}
3280 \begingroup
3281   % Definitions to produce \{ and \} commands for indices,
3282   % and @{ and @} for the aux/toc files.
3283   \catcode`\{ = \other \catcode`\} = \other
3284   \catcode`\[ = 1 \catcode`\] = 2
3285   \catcode`\! = 0 \catcode`\\ = \other
3286   !gdef!lbracecmd[\{]%
3287   !gdef!rbracecmd[\}]%
3288   !gdef!lbraceatcmd[@{]%
3289   !gdef!rbraceatcmd[@}]%
3290 !endgroup
3291
3292 % @comma{} to avoid , parsing problems.
3293 \let\comma = ,
3294
3295 % Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
3296 % Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H.
3297 \let\, = \ptexc
3298 \let\dotaccent = \ptexdot
3299 \def\ringaccent#1{{\accent23 #1}}
3300 \let\tieaccent = \ptext
3301 \let\ubaraccent = \ptexb
3302 \let\udotaccent = \d
3303
3304 % Other special characters: @questiondown @exclamdown @ordf @ordm
3305 % Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss.
3306 \def\questiondown{?`}
3307 \def\exclamdown{!`}
3308 \def\ordf{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{a}}}
3309 \def\ordm{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{o}}}
3310
3311 % Dotless i and dotless j, used for accents.
3312 \def\imacro{i}
3313 \def\jmacro{j}
3314 \def\dotless#1{%
3315   \def\temp{#1}%
3316   \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi
3317   \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi
3318   \else \errmessage{@dotless can be used only with i or j}%
3319   \fi\fi
3320 }
3321
3322 % The \TeX{} logo, as in plain, but resetting the spacing so that a
3323 % period following counts as ending a sentence.  (Idea found in latex.)
3324 %
3325 \edef\TeX{\TeX \spacefactor=1000 }
3326
3327 % @LaTeX{} logo.  Not quite the same results as the definition in
3328 % latex.ltx, since we use a different font for the raised A; it's most
3329 % convenient for us to use an explicitly smaller font, rather than using
3330 % the \scriptstyle font (since we don't reset \scriptstyle and
3331 % \scriptscriptstyle).
3332 %
3333 \def\LaTeX{%
3334   L\kern-.36em
3335   {\setbox0=\hbox{T}%
3336    \vbox to \ht0{\hbox{%
3337      \ifx\textnominalsize\xwordpt
3338        % for 10pt running text, \lllsize (8pt) is too small for the A in LaTeX.
3339        % Revert to plain's \scriptsize, which is 7pt.
3340        \count255=\the\fam $\fam\count255 \scriptstyle A$%
3341      \else
3342        % For 11pt, we can use our lllsize.
3343        \selectfonts\lllsize A%
3344      \fi
3345      }%
3346      \vss
3347   }}%
3348   \kern-.15em
3349   \TeX
3350 }
3351
3352 % Some math mode symbols.  Define \ensuremath to switch into math mode
3353 % unless we are already there.  Expansion tricks may not be needed here,
3354 % but safer, and can't hurt.
3355 \def\ensuremath{\ifmmode \expandafter\asis \else\expandafter\ensuredmath \fi}
3356 \def\ensuredmath#1{$\relax#1$}
3357 %
3358 \def\bullet{\ensuremath\ptexbullet}
3359 \def\geq{\ensuremath\ge}
3360 \def\leq{\ensuremath\le}
3361 \def\minus{\ensuremath-}
3362
3363 % @dots{} outputs an ellipsis using the current font.
3364 % We do .5em per period so that it has the same spacing in the cm
3365 % typewriter fonts as three actual period characters; on the other hand,
3366 % in other typewriter fonts three periods are wider than 1.5em.  So do
3367 % whichever is larger.
3368 %
3369 \def\dots{%
3370   \leavevmode
3371   \setbox0=\hbox{...}% get width of three periods
3372   \ifdim\wd0 > 1.5em
3373     \dimen0 = \wd0
3374   \else
3375     \dimen0 = 1.5em
3376   \fi
3377   \hbox to \dimen0{%
3378     \hskip 0pt plus.25fil
3379     .\hskip 0pt plus1fil
3380     .\hskip 0pt plus1fil
3381     .\hskip 0pt plus.5fil
3382   }%
3383 }
3384
3385 % @enddots{} is an end-of-sentence ellipsis.
3386 %
3387 \def\enddots{%
3388   \dots
3389   \spacefactor=\endofsentencespacefactor
3390 }
3391
3392 % @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
3393 %
3394 % Since these characters are used in examples, they should be an even number of
3395 % \tt widths. Each \tt character is 1en, so two makes it 1em.
3396 %
3397 \def\point{$\star$}
3398 \def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}}
3399 \def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
3400 \def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}}
3401 \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
3402 \def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}}
3403
3404 % The @error{} command.
3405 % Adapted from the TeXbook's \boxit.
3406 %
3407 \newbox\errorbox
3408 %
3409 {\tentt \global\dimen0 = 3em}% Width of the box.
3410 \dimen2 = .55pt % Thickness of rules
3411 % The text. (`r' is open on the right, `e' somewhat less so on the left.)
3412 \setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt}
3413 %
3414 \setbox\errorbox=\hbox to \dimen0{\hfil
3415    \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
3416    \advance\hsize by -2\dimen2 % Rules.
3417    \vbox{%
3418       \hrule height\dimen2
3419       \hbox{\vrule width\dimen2 \kern3pt          % Space to left of text.
3420          \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
3421          \kern3pt\vrule width\dimen2}% Space to right.
3422       \hrule height\dimen2}
3423     \hfil}
3424 %
3425 \def\error{\leavevmode\lower.7ex\copy\errorbox}
3426
3427 % @pounds{} is a sterling sign, which Knuth put in the CM italic font.
3428 %
3429 \def\pounds{{\it\$}}
3430
3431 % @euro{} comes from a separate font, depending on the current style.
3432 % We use the free feym* fonts from the eurosym package by Henrik
3433 % Theiling, which support regular, slanted, bold and bold slanted (and
3434 % "outlined" (blackboard board, sort of) versions, which we don't need).
3435 % It is available from http://www.ctan.org/tex-archive/fonts/eurosym.
3436 %
3437 % Although only regular is the truly official Euro symbol, we ignore
3438 % that.  The Euro is designed to be slightly taller than the regular
3439 % font height.
3440 %
3441 % feymr - regular
3442 % feymo - slanted
3443 % feybr - bold
3444 % feybo - bold slanted
3445 %
3446 % There is no good (free) typewriter version, to my knowledge.
3447 % A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide.
3448 % Hmm.
3449 %
3450 % Also doesn't work in math.  Do we need to do math with euro symbols?
3451 % Hope not.
3452 %
3453 %
3454 \def\euro{{\eurofont e}}
3455 \def\eurofont{%
3456   % We set the font at each command, rather than predefining it in
3457   % \textfonts and the other font-switching commands, so that
3458   % installations which never need the symbol don't have to have the
3459   % font installed.
3460   %
3461   % There is only one designed size (nominal 10pt), so we always scale
3462   % that to the current nominal size.
3463   %
3464   % By the way, simply using "at 1em" works for cmr10 and the like, but
3465   % does not work for cmbx10 and other extended/shrunken fonts.
3466   %
3467   \def\eurosize{\csname\curfontsize nominalsize\endcsname}%
3468   %
3469   \ifx\curfontstyle\bfstylename
3470     % bold:
3471     \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize
3472   \else
3473     % regular:
3474     \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize
3475   \fi
3476   \thiseurofont
3477 }
3478
3479 % Glyphs from the EC fonts.  We don't use \let for the aliases, because
3480 % sometimes we redefine the original macro, and the alias should reflect
3481 % the redefinition.
3482 %
3483 % Use LaTeX names for the Icelandic letters.
3484 \def\DH{{\ecfont \char"D0}} % Eth
3485 \def\dh{{\ecfont \char"F0}} % eth
3486 \def\TH{{\ecfont \char"DE}} % Thorn
3487 \def\th{{\ecfont \char"FE}} % thorn
3488 %
3489 \def\guillemetleft{{\ecfont \char"13}}
3490 \def\guillemotleft{\guillemetleft}
3491 \def\guillemetright{{\ecfont \char"14}}
3492 \def\guillemotright{\guillemetright}
3493 \def\guilsinglleft{{\ecfont \char"0E}}
3494 \def\guilsinglright{{\ecfont \char"0F}}
3495 \def\quotedblbase{{\ecfont \char"12}}
3496 \def\quotesinglbase{{\ecfont \char"0D}}
3497 %
3498 % This positioning is not perfect (see the ogonek LaTeX package), but
3499 % we have the precomposed glyphs for the most common cases.  We put the
3500 % tests to use those glyphs in the single \ogonek macro so we have fewer
3501 % dummy definitions to worry about for index entries, etc.
3502 %
3503 % ogonek is also used with other letters in Lithuanian (IOU), but using
3504 % the precomposed glyphs for those is not so easy since they aren't in
3505 % the same EC font.
3506 \def\ogonek#1{{%
3507   \def\temp{#1}%
3508   \ifx\temp\macrocharA\Aogonek
3509   \else\ifx\temp\macrochara\aogonek
3510   \else\ifx\temp\macrocharE\Eogonek
3511   \else\ifx\temp\macrochare\eogonek
3512   \else
3513     \ecfont \setbox0=\hbox{#1}%
3514     \ifdim\ht0=1ex\accent"0C #1%
3515     \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}%
3516     \fi
3517   \fi\fi\fi\fi
3518   }%
3519 }
3520 \def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A}
3521 \def\aogonek{{\ecfont \char"A1}}\def\macrochara{a}
3522 \def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E}
3523 \def\eogonek{{\ecfont \char"A6}}\def\macrochare{e}
3524 %
3525 % Use the European Computer Modern fonts (cm-super in outline format)
3526 % for non-CM glyphs.  That is ec* for regular text and tc* for the text
3527 % companion symbols (LaTeX TS1 encoding).  Both are part of the ec
3528 % package and follow the same conventions.
3529
3530 \def\ecfont{\etcfont{e}}
3531 \def\tcfont{\etcfont{t}}
3532 %
3533 \def\etcfont#1{%
3534   % We can't distinguish serif/sans and italic/slanted, but this
3535   % is used for crude hacks anyway (like adding French and German
3536   % quotes to documents typeset with CM, where we lose kerning), so
3537   % hopefully nobody will notice/care.
3538   \edef\ecsize{\csname\curfontsize ecsize\endcsname}%
3539   \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}%
3540   \ifmonospace
3541     % typewriter:
3542     \font\thisecfont = #1ctt\ecsize \space at \nominalsize
3543   \else
3544     \ifx\curfontstyle\bfstylename
3545       % bold:
3546       \font\thisecfont = #1cb\ifusingit{i}{x}\ecsize \space at \nominalsize
3547     \else
3548       % regular:
3549       \font\thisecfont = #1c\ifusingit{ti}{rm}\ecsize \space at \nominalsize
3550     \fi
3551   \fi
3552   \thisecfont
3553 }
3554
3555 % @registeredsymbol - R in a circle.  The font for the R should really
3556 % be smaller yet, but lllsize is the best we can do for now.
3557 % Adapted from the plain.tex definition of \copyright.
3558 %
3559 \def\registeredsymbol{%
3560   $^{{\ooalign{\hfil\raise.07ex\hbox{\selectfonts\lllsize R}%
3561                \hfil\crcr\Orb}}%
3562     }$%
3563 }
3564
3565 % @textdegree - the normal degrees sign.
3566 %
3567 \def\textdegree{$^\circ$}
3568
3569 % Laurent Siebenmann reports \Orb undefined with:
3570 %  Textures 1.7.7 (preloaded format=plain 93.10.14)  (68K)  16 APR 2004 02:38
3571 % so we'll define it if necessary.
3572 %
3573 \ifx\Orb\thisisundefined
3574 \def\Orb{\mathhexbox20D}
3575 \fi
3576
3577 % Quotes.
3578 \chardef\quotedblleft="5C
3579 \chardef\quotedblright=`\"
3580 \chardef\quoteleft=`\`
3581 \chardef\quoteright=`\'
3582
3583
3584 \message{page headings,}
3585
3586 \newskip\titlepagetopglue \titlepagetopglue = 1.5in
3587 \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
3588
3589 % First the title page.  Must do @settitle before @titlepage.
3590 \newif\ifseenauthor
3591 \newif\iffinishedtitlepage
3592
3593 % @setcontentsaftertitlepage used to do an implicit @contents or
3594 % @shortcontents after @end titlepage, but it is now obsolete.
3595 \def\setcontentsaftertitlepage{%
3596   \errmessage{@setcontentsaftertitlepage has been removed as a Texinfo
3597               command; move your @contents command if you want the contents
3598               after the title page.}}%
3599 \def\setshortcontentsaftertitlepage{%
3600   \errmessage{@setshortcontentsaftertitlepage has been removed as a Texinfo
3601               command; move your @shortcontents and @contents commands if you 
3602               want the contents after the title page.}}%
3603
3604 \parseargdef\shorttitlepage{%
3605   \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}%
3606   \endgroup\page\hbox{}\page}
3607
3608 \envdef\titlepage{%
3609   % Open one extra group, as we want to close it in the middle of \Etitlepage.
3610   \begingroup
3611     \parindent=0pt \textfonts
3612     % Leave some space at the very top of the page.
3613     \vglue\titlepagetopglue
3614     % No rule at page bottom unless we print one at the top with @title.
3615     \finishedtitlepagetrue
3616     %
3617     % Most title ``pages'' are actually two pages long, with space
3618     % at the top of the second.  We don't want the ragged left on the second.
3619     \let\oldpage = \page
3620     \def\page{%
3621       \iffinishedtitlepage\else
3622          \finishtitlepage
3623       \fi
3624       \let\page = \oldpage
3625       \page
3626       \null
3627     }%
3628 }
3629
3630 \def\Etitlepage{%
3631     \iffinishedtitlepage\else
3632         \finishtitlepage
3633     \fi
3634     % It is important to do the page break before ending the group,
3635     % because the headline and footline are only empty inside the group.
3636     % If we use the new definition of \page, we always get a blank page
3637     % after the title page, which we certainly don't want.
3638     \oldpage
3639   \endgroup
3640   %
3641   % Need this before the \...aftertitlepage checks so that if they are
3642   % in effect the toc pages will come out with page numbers.
3643   \HEADINGSon
3644 }
3645
3646 \def\finishtitlepage{%
3647   \vskip4pt \hrule height 2pt width \hsize
3648   \vskip\titlepagebottomglue
3649   \finishedtitlepagetrue
3650 }
3651
3652 % Settings used for typesetting titles: no hyphenation, no indentation,
3653 % don't worry much about spacing, ragged right.  This should be used
3654 % inside a \vbox, and fonts need to be set appropriately first.  Because
3655 % it is always used for titles, nothing else, we call \rmisbold.  \par
3656 % should be specified before the end of the \vbox, since a vbox is a group.
3657
3658 \def\raggedtitlesettings{%
3659   \rmisbold
3660   \hyphenpenalty=10000
3661   \parindent=0pt
3662   \tolerance=5000
3663   \ptexraggedright
3664 }
3665
3666 % Macros to be used within @titlepage:
3667
3668 \let\subtitlerm=\tenrm
3669 \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}
3670
3671 \parseargdef\title{%
3672   \checkenv\titlepage
3673   \vbox{\titlefonts \raggedtitlesettings #1\par}%
3674   % print a rule at the page bottom also.
3675   \finishedtitlepagefalse
3676   \vskip4pt \hrule height 4pt width \hsize \vskip4pt
3677 }
3678
3679 \parseargdef\subtitle{%
3680   \checkenv\titlepage
3681   {\subtitlefont \rightline{#1}}%
3682 }
3683
3684 % @author should come last, but may come many times.
3685 % It can also be used inside @quotation.
3686 %
3687 \parseargdef\author{%
3688   \def\temp{\quotation}%
3689   \ifx\thisenv\temp
3690     \def\quotationauthor{#1}% printed in \Equotation.
3691   \else
3692     \checkenv\titlepage
3693     \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi
3694     {\secfonts\rmisbold \leftline{#1}}%
3695   \fi
3696 }
3697
3698
3699 % Set up page headings and footings.
3700
3701 \let\thispage=\folio
3702
3703 \newtoks\evenheadline    % headline on even pages
3704 \newtoks\oddheadline     % headline on odd pages
3705 \newtoks\evenfootline    % footline on even pages
3706 \newtoks\oddfootline     % footline on odd pages
3707
3708 % Now make \makeheadline and \makefootline in Plain TeX use those variables
3709 \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
3710                             \else \the\evenheadline \fi}}
3711 \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
3712                             \else \the\evenfootline \fi}\HEADINGShook}
3713 \let\HEADINGShook=\relax
3714
3715 % Commands to set those variables.
3716 % For example, this is what  @headings on  does
3717 % @evenheading @thistitle|@thispage|@thischapter
3718 % @oddheading @thischapter|@thispage|@thistitle
3719 % @evenfooting @thisfile||
3720 % @oddfooting ||@thisfile
3721
3722
3723 \def\evenheading{\parsearg\evenheadingxxx}
3724 \def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish}
3725 \def\evenheadingyyy #1\|#2\|#3\|#4\finish{%
3726 \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3727
3728 \def\oddheading{\parsearg\oddheadingxxx}
3729 \def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish}
3730 \def\oddheadingyyy #1\|#2\|#3\|#4\finish{%
3731 \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3732
3733 \parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
3734
3735 \def\evenfooting{\parsearg\evenfootingxxx}
3736 \def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish}
3737 \def\evenfootingyyy #1\|#2\|#3\|#4\finish{%
3738 \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3739
3740 \def\oddfooting{\parsearg\oddfootingxxx}
3741 \def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish}
3742 \def\oddfootingyyy #1\|#2\|#3\|#4\finish{%
3743   \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}%
3744   %
3745   % Leave some space for the footline.  Hopefully ok to assume
3746   % @evenfooting will not be used by itself.
3747   \global\advance\txipageheight by -12pt
3748   \global\advance\vsize by -12pt
3749 }
3750
3751 \parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}}
3752
3753 % @evenheadingmarks top     \thischapter <- chapter at the top of a page
3754 % @evenheadingmarks bottom  \thischapter <- chapter at the bottom of a page
3755 %
3756 % The same set of arguments for:
3757 %
3758 % @oddheadingmarks
3759 % @evenfootingmarks
3760 % @oddfootingmarks
3761 % @everyheadingmarks
3762 % @everyfootingmarks
3763
3764 % These define \getoddheadingmarks, \getevenheadingmarks,
3765 % \getoddfootingmarks, and \getevenfootingmarks, each to one of
3766 % \gettopheadingmarks, \getbottomheadingmarks.
3767 %
3768 \def\evenheadingmarks{\headingmarks{even}{heading}}
3769 \def\oddheadingmarks{\headingmarks{odd}{heading}}
3770 \def\evenfootingmarks{\headingmarks{even}{footing}}
3771 \def\oddfootingmarks{\headingmarks{odd}{footing}}
3772 \parseargdef\everyheadingmarks{\headingmarks{even}{heading}{#1}
3773                           \headingmarks{odd}{heading}{#1} }
3774 \parseargdef\everyfootingmarks{\headingmarks{even}{footing}{#1}
3775                           \headingmarks{odd}{footing}{#1} }
3776 % #1 = even/odd, #2 = heading/footing, #3 = top/bottom.
3777 \def\headingmarks#1#2#3 {%
3778   \expandafter\let\expandafter\temp \csname get#3headingmarks\endcsname
3779   \global\expandafter\let\csname get#1#2marks\endcsname \temp
3780 }
3781
3782 \everyheadingmarks bottom
3783 \everyfootingmarks bottom
3784
3785 % @headings double      turns headings on for double-sided printing.
3786 % @headings single      turns headings on for single-sided printing.
3787 % @headings off         turns them off.
3788 % @headings on          same as @headings double, retained for compatibility.
3789 % @headings after       turns on double-sided headings after this page.
3790 % @headings doubleafter turns on double-sided headings after this page.
3791 % @headings singleafter turns on single-sided headings after this page.
3792 % By default, they are off at the start of a document,
3793 % and turned `on' after @end titlepage.
3794
3795 \parseargdef\headings{\csname HEADINGS#1\endcsname}
3796
3797 \def\headingsoff{% non-global headings elimination
3798   \evenheadline={\hfil}\evenfootline={\hfil}%
3799    \oddheadline={\hfil}\oddfootline={\hfil}%
3800 }
3801
3802 \def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting
3803 \HEADINGSoff  % it's the default
3804
3805 % When we turn headings on, set the page number to 1.
3806 % For double-sided printing, put current file name in lower left corner,
3807 % chapter name on inside top of right hand pages, document
3808 % title on inside top of left hand pages, and page numbers on outside top
3809 % edge of all pages.
3810 \def\HEADINGSdouble{%
3811 \global\pageno=1
3812 \global\evenfootline={\hfil}
3813 \global\oddfootline={\hfil}
3814 \global\evenheadline={\line{\folio\hfil\thistitle}}
3815 \global\oddheadline={\line{\thischapterheading\hfil\folio}}
3816 \global\let\contentsalignmacro = \chapoddpage
3817 }
3818 \let\contentsalignmacro = \chappager
3819
3820 % For single-sided printing, chapter title goes across top left of page,
3821 % page number on top right.
3822 \def\HEADINGSsingle{%
3823 \global\pageno=1
3824 \global\evenfootline={\hfil}
3825 \global\oddfootline={\hfil}
3826 \global\evenheadline={\line{\thischapterheading\hfil\folio}}
3827 \global\oddheadline={\line{\thischapterheading\hfil\folio}}
3828 \global\let\contentsalignmacro = \chappager
3829 }
3830 \def\HEADINGSon{\HEADINGSdouble}
3831
3832 \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
3833 \let\HEADINGSdoubleafter=\HEADINGSafter
3834 \def\HEADINGSdoublex{%
3835 \global\evenfootline={\hfil}
3836 \global\oddfootline={\hfil}
3837 \global\evenheadline={\line{\folio\hfil\thistitle}}
3838 \global\oddheadline={\line{\thischapterheading\hfil\folio}}
3839 \global\let\contentsalignmacro = \chapoddpage
3840 }
3841
3842 \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
3843 \def\HEADINGSsinglex{%
3844 \global\evenfootline={\hfil}
3845 \global\oddfootline={\hfil}
3846 \global\evenheadline={\line{\thischapterheading\hfil\folio}}
3847 \global\oddheadline={\line{\thischapterheading\hfil\folio}}
3848 \global\let\contentsalignmacro = \chappager
3849 }
3850
3851 % Subroutines used in generating headings
3852 % This produces Day Month Year style of output.
3853 % Only define if not already defined, in case a txi-??.tex file has set
3854 % up a different format (e.g., txi-cs.tex does this).
3855 \ifx\today\thisisundefined
3856 \def\today{%
3857   \number\day\space
3858   \ifcase\month
3859   \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr
3860   \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug
3861   \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec
3862   \fi
3863   \space\number\year}
3864 \fi
3865
3866 % @settitle line...  specifies the title of the document, for headings.
3867 % It generates no output of its own.
3868 \def\thistitle{\putwordNoTitle}
3869 \def\settitle{\parsearg{\gdef\thistitle}}
3870
3871
3872 \message{tables,}
3873 % Tables -- @table, @ftable, @vtable, @item(x).
3874
3875 % default indentation of table text
3876 \newdimen\tableindent \tableindent=.8in
3877 % default indentation of @itemize and @enumerate text
3878 \newdimen\itemindent  \itemindent=.3in
3879 % margin between end of table item and start of table text.
3880 \newdimen\itemmargin  \itemmargin=.1in
3881
3882 % used internally for \itemindent minus \itemmargin
3883 \newdimen\itemmax
3884
3885 % Note @table, @ftable, and @vtable define @item, @itemx, etc., with
3886 % these defs.
3887 % They also define \itemindex
3888 % to index the item name in whatever manner is desired (perhaps none).
3889
3890 \newif\ifitemxneedsnegativevskip
3891
3892 \def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
3893
3894 \def\internalBitem{\smallbreak \parsearg\itemzzz}
3895 \def\internalBitemx{\itemxpar \parsearg\itemzzz}
3896
3897 \def\itemzzz #1{\begingroup %
3898   \advance\hsize by -\rightskip
3899   \advance\hsize by -\tableindent
3900   \setbox0=\hbox{\itemindicate{#1}}%
3901   \itemindex{#1}%
3902   \nobreak % This prevents a break before @itemx.
3903   %
3904   % If the item text does not fit in the space we have, put it on a line
3905   % by itself, and do not allow a page break either before or after that
3906   % line.  We do not start a paragraph here because then if the next
3907   % command is, e.g., @kindex, the whatsit would get put into the
3908   % horizontal list on a line by itself, resulting in extra blank space.
3909   \ifdim \wd0>\itemmax
3910     %
3911     % Make this a paragraph so we get the \parskip glue and wrapping,
3912     % but leave it ragged-right.
3913     \begingroup
3914       \advance\leftskip by-\tableindent
3915       \advance\hsize by\tableindent
3916       \advance\rightskip by0pt plus1fil\relax
3917       \leavevmode\unhbox0\par
3918     \endgroup
3919     %
3920     % We're going to be starting a paragraph, but we don't want the
3921     % \parskip glue -- logically it's part of the @item we just started.
3922     \nobreak \vskip-\parskip
3923     %
3924     % Stop a page break at the \parskip glue coming up.  However, if
3925     % what follows is an environment such as @example, there will be no
3926     % \parskip glue; then the negative vskip we just inserted would
3927     % cause the example and the item to crash together.  So we use this
3928     % bizarre value of 10001 as a signal to \aboveenvbreak to insert
3929     % \parskip glue after all.  Section titles are handled this way also.
3930     %
3931     \penalty 10001
3932     \endgroup
3933     \itemxneedsnegativevskipfalse
3934   \else
3935     % The item text fits into the space.  Start a paragraph, so that the
3936     % following text (if any) will end up on the same line.
3937     \noindent
3938     % Do this with kerns and \unhbox so that if there is a footnote in
3939     % the item text, it can migrate to the main vertical list and
3940     % eventually be printed.
3941     \nobreak\kern-\tableindent
3942     \dimen0 = \itemmax  \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0
3943     \unhbox0
3944     \nobreak\kern\dimen0
3945     \endgroup
3946     \itemxneedsnegativevskiptrue
3947   \fi
3948 }
3949
3950 \def\item{\errmessage{@item while not in a list environment}}
3951 \def\itemx{\errmessage{@itemx while not in a list environment}}
3952
3953 % @table, @ftable, @vtable.
3954 \envdef\table{%
3955   \let\itemindex\gobble
3956   \tablecheck{table}%
3957 }
3958 \envdef\ftable{%
3959   \def\itemindex ##1{\doind {fn}{\code{##1}}}%
3960   \tablecheck{ftable}%
3961 }
3962 \envdef\vtable{%
3963   \def\itemindex ##1{\doind {vr}{\code{##1}}}%
3964   \tablecheck{vtable}%
3965 }
3966 \def\tablecheck#1{%
3967   \ifnum \the\catcode`\^^M=\active
3968     \endgroup
3969     \errmessage{This command won't work in this context; perhaps the problem is
3970       that we are \inenvironment\thisenv}%
3971     \def\next{\doignore{#1}}%
3972   \else
3973     \let\next\tablex
3974   \fi
3975   \next
3976 }
3977 \def\tablex#1{%
3978   \def\itemindicate{#1}%
3979   \parsearg\tabley
3980 }
3981 \def\tabley#1{%
3982   {%
3983     \makevalueexpandable
3984     \edef\temp{\noexpand\tablez #1\space\space\space}%
3985     \expandafter
3986   }\temp \endtablez
3987 }
3988 \def\tablez #1 #2 #3 #4\endtablez{%
3989   \aboveenvbreak
3990   \ifnum 0#1>0 \advance \leftskip by #1\mil \fi
3991   \ifnum 0#2>0 \tableindent=#2\mil \fi
3992   \ifnum 0#3>0 \advance \rightskip by #3\mil \fi
3993   \itemmax=\tableindent
3994   \advance \itemmax by -\itemmargin
3995   \advance \leftskip by \tableindent
3996   \exdentamount=\tableindent
3997   \parindent = 0pt
3998   \parskip = \smallskipamount
3999   \ifdim \parskip=0pt \parskip=2pt \fi
4000   \let\item = \internalBitem
4001   \let\itemx = \internalBitemx
4002 }
4003 \def\Etable{\endgraf\afterenvbreak}
4004 \let\Eftable\Etable
4005 \let\Evtable\Etable
4006 \let\Eitemize\Etable
4007 \let\Eenumerate\Etable
4008
4009 % This is the counter used by @enumerate, which is really @itemize
4010
4011 \newcount \itemno
4012
4013 \envdef\itemize{\parsearg\doitemize}
4014
4015 \def\doitemize#1{%
4016   \aboveenvbreak
4017   \itemmax=\itemindent
4018   \advance\itemmax by -\itemmargin
4019   \advance\leftskip by \itemindent
4020   \exdentamount=\itemindent
4021   \parindent=0pt
4022   \parskip=\smallskipamount
4023   \ifdim\parskip=0pt \parskip=2pt \fi
4024   %
4025   % Try typesetting the item mark so that if the document erroneously says
4026   % something like @itemize @samp (intending @table), there's an error
4027   % right away at the @itemize.  It's not the best error message in the
4028   % world, but it's better than leaving it to the @item.  This means if
4029   % the user wants an empty mark, they have to say @w{} not just @w.
4030   \def\itemcontents{#1}%
4031   \setbox0 = \hbox{\itemcontents}%
4032   %
4033   % @itemize with no arg is equivalent to @itemize @bullet.
4034   \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi
4035   %
4036   \let\item=\itemizeitem
4037 }
4038
4039 % Definition of @item while inside @itemize and @enumerate.
4040 %
4041 \def\itemizeitem{%
4042   \advance\itemno by 1  % for enumerations
4043   {\let\par=\endgraf \smallbreak}% reasonable place to break
4044   {%
4045    % If the document has an @itemize directly after a section title, a
4046    % \nobreak will be last on the list, and \sectionheading will have
4047    % done a \vskip-\parskip.  In that case, we don't want to zero
4048    % parskip, or the item text will crash with the heading.  On the
4049    % other hand, when there is normal text preceding the item (as there
4050    % usually is), we do want to zero parskip, or there would be too much
4051    % space.  In that case, we won't have a \nobreak before.  At least
4052    % that's the theory.
4053    \ifnum\lastpenalty<10000 \parskip=0in \fi
4054    \noindent
4055    \hbox to 0pt{\hss \itemcontents \kern\itemmargin}%
4056    %
4057    \ifinner\else
4058      \vadjust{\penalty 1200}% not good to break after first line of item.
4059    \fi
4060    % We can be in inner vertical mode in a footnote, although an
4061    % @itemize looks awful there.
4062   }%
4063   \flushcr
4064 }
4065
4066 % \splitoff TOKENS\endmark defines \first to be the first token in
4067 % TOKENS, and \rest to be the remainder.
4068 %
4069 \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
4070
4071 % Allow an optional argument of an uppercase letter, lowercase letter,
4072 % or number, to specify the first label in the enumerated list.  No
4073 % argument is the same as `1'.
4074 %
4075 \envparseargdef\enumerate{\enumeratey #1  \endenumeratey}
4076 \def\enumeratey #1 #2\endenumeratey{%
4077   % If we were given no argument, pretend we were given `1'.
4078   \def\thearg{#1}%
4079   \ifx\thearg\empty \def\thearg{1}\fi
4080   %
4081   % Detect if the argument is a single token.  If so, it might be a
4082   % letter.  Otherwise, the only valid thing it can be is a number.
4083   % (We will always have one token, because of the test we just made.
4084   % This is a good thing, since \splitoff doesn't work given nothing at
4085   % all -- the first parameter is undelimited.)
4086   \expandafter\splitoff\thearg\endmark
4087   \ifx\rest\empty
4088     % Only one token in the argument.  It could still be anything.
4089     % A ``lowercase letter'' is one whose \lccode is nonzero.
4090     % An ``uppercase letter'' is one whose \lccode is both nonzero, and
4091     %   not equal to itself.
4092     % Otherwise, we assume it's a number.
4093     %
4094     % We need the \relax at the end of the \ifnum lines to stop TeX from
4095     % continuing to look for a <number>.
4096     %
4097     \ifnum\lccode\expandafter`\thearg=0\relax
4098       \numericenumerate % a number (we hope)
4099     \else
4100       % It's a letter.
4101       \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
4102         \lowercaseenumerate % lowercase letter
4103       \else
4104         \uppercaseenumerate % uppercase letter
4105       \fi
4106     \fi
4107   \else
4108     % Multiple tokens in the argument.  We hope it's a number.
4109     \numericenumerate
4110   \fi
4111 }
4112
4113 % An @enumerate whose labels are integers.  The starting integer is
4114 % given in \thearg.
4115 %
4116 \def\numericenumerate{%
4117   \itemno = \thearg
4118   \startenumeration{\the\itemno}%
4119 }
4120
4121 % The starting (lowercase) letter is in \thearg.
4122 \def\lowercaseenumerate{%
4123   \itemno = \expandafter`\thearg
4124   \startenumeration{%
4125     % Be sure we're not beyond the end of the alphabet.
4126     \ifnum\itemno=0
4127       \errmessage{No more lowercase letters in @enumerate; get a bigger
4128                   alphabet}%
4129     \fi
4130     \char\lccode\itemno
4131   }%
4132 }
4133
4134 % The starting (uppercase) letter is in \thearg.
4135 \def\uppercaseenumerate{%
4136   \itemno = \expandafter`\thearg
4137   \startenumeration{%
4138     % Be sure we're not beyond the end of the alphabet.
4139     \ifnum\itemno=0
4140       \errmessage{No more uppercase letters in @enumerate; get a bigger
4141                   alphabet}
4142     \fi
4143     \char\uccode\itemno
4144   }%
4145 }
4146
4147 % Call \doitemize, adding a period to the first argument and supplying the
4148 % common last two arguments.  Also subtract one from the initial value in
4149 % \itemno, since @item increments \itemno.
4150 %
4151 \def\startenumeration#1{%
4152   \advance\itemno by -1
4153   \doitemize{#1.}\flushcr
4154 }
4155
4156 % @alphaenumerate and @capsenumerate are abbreviations for giving an arg
4157 % to @enumerate.
4158 %
4159 \def\alphaenumerate{\enumerate{a}}
4160 \def\capsenumerate{\enumerate{A}}
4161 \def\Ealphaenumerate{\Eenumerate}
4162 \def\Ecapsenumerate{\Eenumerate}
4163
4164
4165 % @multitable macros
4166 % Amy Hendrickson, 8/18/94, 3/6/96
4167 %
4168 % @multitable ... @end multitable will make as many columns as desired.
4169 % Contents of each column will wrap at width given in preamble.  Width
4170 % can be specified either with sample text given in a template line,
4171 % or in percent of \hsize, the current width of text on page.
4172
4173 % Table can continue over pages but will only break between lines.
4174
4175 % To make preamble:
4176 %
4177 % Either define widths of columns in terms of percent of \hsize:
4178 %   @multitable @columnfractions .25 .3 .45
4179 %   @item ...
4180 %
4181 %   Numbers following @columnfractions are the percent of the total
4182 %   current hsize to be used for each column. You may use as many
4183 %   columns as desired.
4184
4185
4186 % Or use a template:
4187 %   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
4188 %   @item ...
4189 %   using the widest term desired in each column.
4190
4191 % Each new table line starts with @item, each subsequent new column
4192 % starts with @tab. Empty columns may be produced by supplying @tab's
4193 % with nothing between them for as many times as empty columns are needed,
4194 % ie, @tab@tab@tab will produce two empty columns.
4195
4196 % @item, @tab do not need to be on their own lines, but it will not hurt
4197 % if they are.
4198
4199 % Sample multitable:
4200
4201 %   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
4202 %   @item first col stuff @tab second col stuff @tab third col
4203 %   @item
4204 %   first col stuff
4205 %   @tab
4206 %   second col stuff
4207 %   @tab
4208 %   third col
4209 %   @item first col stuff @tab second col stuff
4210 %   @tab Many paragraphs of text may be used in any column.
4211 %
4212 %         They will wrap at the width determined by the template.
4213 %   @item@tab@tab This will be in third column.
4214 %   @end multitable
4215
4216 % Default dimensions may be reset by user.
4217 % @multitableparskip is vertical space between paragraphs in table.
4218 % @multitableparindent is paragraph indent in table.
4219 % @multitablecolmargin is horizontal space to be left between columns.
4220 % @multitablelinespace is space to leave between table items, baseline
4221 %                                                            to baseline.
4222 %   0pt means it depends on current normal line spacing.
4223 %
4224 \newskip\multitableparskip
4225 \newskip\multitableparindent
4226 \newdimen\multitablecolspace
4227 \newskip\multitablelinespace
4228 \multitableparskip=0pt
4229 \multitableparindent=6pt
4230 \multitablecolspace=12pt
4231 \multitablelinespace=0pt
4232
4233 % Macros used to set up halign preamble:
4234 %
4235 \let\endsetuptable\relax
4236 \def\xendsetuptable{\endsetuptable}
4237 \let\columnfractions\relax
4238 \def\xcolumnfractions{\columnfractions}
4239 \newif\ifsetpercent
4240
4241 % #1 is the @columnfraction, usually a decimal number like .5, but might
4242 % be just 1.  We just use it, whatever it is.
4243 %
4244 \def\pickupwholefraction#1 {%
4245   \global\advance\colcount by 1
4246   \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}%
4247   \setuptable
4248 }
4249
4250 \newcount\colcount
4251 \def\setuptable#1{%
4252   \def\firstarg{#1}%
4253   \ifx\firstarg\xendsetuptable
4254     \let\go = \relax
4255   \else
4256     \ifx\firstarg\xcolumnfractions
4257       \global\setpercenttrue
4258     \else
4259       \ifsetpercent
4260          \let\go\pickupwholefraction
4261       \else
4262          \global\advance\colcount by 1
4263          \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a
4264                    % separator; typically that is always in the input, anyway.
4265          \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
4266       \fi
4267     \fi
4268     \ifx\go\pickupwholefraction
4269       % Put the argument back for the \pickupwholefraction call, so
4270       % we'll always have a period there to be parsed.
4271       \def\go{\pickupwholefraction#1}%
4272     \else
4273       \let\go = \setuptable
4274     \fi%
4275   \fi
4276   \go
4277 }
4278
4279 % multitable-only commands.
4280
4281 % @headitem starts a heading row, which we typeset in bold.  Assignments
4282 % have to be global since we are inside the implicit group of an
4283 % alignment entry.  \everycr below resets \everytab so we don't have to
4284 % undo it ourselves.
4285 \def\headitemfont{\b}% for people to use in the template row; not changeable
4286 \def\headitem{%
4287   \checkenv\multitable
4288   \crcr
4289   \gdef\headitemcrhook{\nobreak}% attempt to avoid page break after headings
4290   \global\everytab={\bf}% can't use \headitemfont since the parsing differs
4291   \the\everytab % for the first item
4292 }%
4293 %
4294 % default for tables with no headings.
4295 \let\headitemcrhook=\relax
4296 %
4297 % A \tab used to include \hskip1sp.  But then the space in a template
4298 % line is not enough.  That is bad.  So let's go back to just `&' until
4299 % we again encounter the problem the 1sp was intended to solve.
4300 %                                       --karl, nathan@acm.org, 20apr99.
4301 \def\tab{\checkenv\multitable &\the\everytab}%
4302
4303 % @multitable ... @end multitable definitions:
4304 %
4305 \newtoks\everytab  % insert after every tab.
4306 %
4307 \envdef\multitable{%
4308   \vskip\parskip
4309   \startsavinginserts
4310   %
4311   % @item within a multitable starts a normal row.
4312   % We use \def instead of \let so that if one of the multitable entries
4313   % contains an @itemize, we don't choke on the \item (seen as \crcr aka
4314   % \endtemplate) expanding \doitemize.
4315   \def\item{\crcr}%
4316   %
4317   \tolerance=9500
4318   \hbadness=9500
4319   \setmultitablespacing
4320   \parskip=\multitableparskip
4321   \parindent=\multitableparindent
4322   \overfullrule=0pt
4323   \global\colcount=0
4324   %
4325   \everycr = {%
4326     \noalign{%
4327       \global\everytab={}% Reset from possible headitem.
4328       \global\colcount=0 % Reset the column counter.
4329       %
4330       % Check for saved footnotes, etc.:
4331       \checkinserts
4332       %
4333       % Perhaps a \nobreak, then reset:
4334       \headitemcrhook
4335       \global\let\headitemcrhook=\relax
4336     }%
4337   }%
4338   %
4339   \parsearg\domultitable
4340 }
4341 \def\domultitable#1{%
4342   % To parse everything between @multitable and @item:
4343   \setuptable#1 \endsetuptable
4344   %
4345   % This preamble sets up a generic column definition, which will
4346   % be used as many times as user calls for columns.
4347   % \vtop will set a single line and will also let text wrap and
4348   % continue for many paragraphs if desired.
4349   \halign\bgroup &%
4350     \global\advance\colcount by 1
4351     \multistrut
4352     \vtop{%
4353       % Use the current \colcount to find the correct column width:
4354       \hsize=\expandafter\csname col\the\colcount\endcsname
4355       %
4356       % In order to keep entries from bumping into each other
4357       % we will add a \leftskip of \multitablecolspace to all columns after
4358       % the first one.
4359       %
4360       % If a template has been used, we will add \multitablecolspace
4361       % to the width of each template entry.
4362       %
4363       % If the user has set preamble in terms of percent of \hsize we will
4364       % use that dimension as the width of the column, and the \leftskip
4365       % will keep entries from bumping into each other.  Table will start at
4366       % left margin and final column will justify at right margin.
4367       %
4368       % Make sure we don't inherit \rightskip from the outer environment.
4369       \rightskip=0pt
4370       \ifnum\colcount=1
4371         % The first column will be indented with the surrounding text.
4372         \advance\hsize by\leftskip
4373       \else
4374         \ifsetpercent \else
4375           % If user has not set preamble in terms of percent of \hsize
4376           % we will advance \hsize by \multitablecolspace.
4377           \advance\hsize by \multitablecolspace
4378         \fi
4379        % In either case we will make \leftskip=\multitablecolspace:
4380       \leftskip=\multitablecolspace
4381       \fi
4382       % Ignoring space at the beginning and end avoids an occasional spurious
4383       % blank line, when TeX decides to break the line at the space before the
4384       % box from the multistrut, so the strut ends up on a line by itself.
4385       % For example:
4386       % @multitable @columnfractions .11 .89
4387       % @item @code{#}
4388       % @tab Legal holiday which is valid in major parts of the whole country.
4389       % Is automatically provided with highlighting sequences respectively
4390       % marking characters.
4391       \noindent\ignorespaces##\unskip\multistrut
4392     }\cr
4393 }
4394 \def\Emultitable{%
4395   \crcr
4396   \egroup % end the \halign
4397   \global\setpercentfalse
4398 }
4399
4400 \def\setmultitablespacing{%
4401   \def\multistrut{\strut}% just use the standard line spacing
4402   %
4403   % Compute \multitablelinespace (if not defined by user) for use in
4404   % \multitableparskip calculation.  We used define \multistrut based on
4405   % this, but (ironically) that caused the spacing to be off.
4406   % See bug-texinfo report from Werner Lemberg, 31 Oct 2004 12:52:20 +0100.
4407 \ifdim\multitablelinespace=0pt
4408 \setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip
4409 \global\advance\multitablelinespace by-\ht0
4410 \fi
4411 % Test to see if parskip is larger than space between lines of
4412 % table. If not, do nothing.
4413 %        If so, set to same dimension as multitablelinespace.
4414 \ifdim\multitableparskip>\multitablelinespace
4415 \global\multitableparskip=\multitablelinespace
4416 \global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
4417                                       % than skip between lines in the table.
4418 \fi%
4419 \ifdim\multitableparskip=0pt
4420 \global\multitableparskip=\multitablelinespace
4421 \global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
4422                                       % than skip between lines in the table.
4423 \fi}
4424
4425
4426 \message{conditionals,}
4427
4428 % @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext,
4429 % @ifnotxml always succeed.  They currently do nothing; we don't
4430 % attempt to check whether the conditionals are properly nested.  But we
4431 % have to remember that they are conditionals, so that @end doesn't
4432 % attempt to close an environment group.
4433 %
4434 \def\makecond#1{%
4435   \expandafter\let\csname #1\endcsname = \relax
4436   \expandafter\let\csname iscond.#1\endcsname = 1
4437 }
4438 \makecond{iftex}
4439 \makecond{ifnotdocbook}
4440 \makecond{ifnothtml}
4441 \makecond{ifnotinfo}
4442 \makecond{ifnotplaintext}
4443 \makecond{ifnotxml}
4444
4445 % Ignore @ignore, @ifhtml, @ifinfo, and the like.
4446 %
4447 \def\direntry{\doignore{direntry}}
4448 \def\documentdescription{\doignore{documentdescription}}
4449 \def\docbook{\doignore{docbook}}
4450 \def\html{\doignore{html}}
4451 \def\ifdocbook{\doignore{ifdocbook}}
4452 \def\ifhtml{\doignore{ifhtml}}
4453 \def\ifinfo{\doignore{ifinfo}}
4454 \def\ifnottex{\doignore{ifnottex}}
4455 \def\ifplaintext{\doignore{ifplaintext}}
4456 \def\ifxml{\doignore{ifxml}}
4457 \def\ignore{\doignore{ignore}}
4458 \def\menu{\doignore{menu}}
4459 \def\xml{\doignore{xml}}
4460
4461 % Ignore text until a line `@end #1', keeping track of nested conditionals.
4462 %
4463 % A count to remember the depth of nesting.
4464 \newcount\doignorecount
4465
4466 \def\doignore#1{\begingroup
4467   % Scan in ``verbatim'' mode:
4468   \obeylines
4469   \catcode`\@ = \other
4470   \catcode`\{ = \other
4471   \catcode`\} = \other
4472   %
4473   % Make sure that spaces turn into tokens that match what \doignoretext wants.
4474   \spaceisspace
4475   %
4476   % Count number of #1's that we've seen.
4477   \doignorecount = 0
4478   %
4479   % Swallow text until we reach the matching `@end #1'.
4480   \dodoignore{#1}%
4481 }
4482
4483 { \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source.
4484   \obeylines %
4485   %
4486   \gdef\dodoignore#1{%
4487     % #1 contains the command name as a string, e.g., `ifinfo'.
4488     %
4489     % Define a command to find the next `@end #1'.
4490     \long\def\doignoretext##1^^M@end #1{%
4491       \doignoretextyyy##1^^M@#1\_STOP_}%
4492     %
4493     % And this command to find another #1 command, at the beginning of a
4494     % line.  (Otherwise, we would consider a line `@c @ifset', for
4495     % example, to count as an @ifset for nesting.)
4496     \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}%
4497     %
4498     % And now expand that command.
4499     \doignoretext ^^M%
4500   }%
4501 }
4502
4503 \def\doignoreyyy#1{%
4504   \def\temp{#1}%
4505   \ifx\temp\empty                       % Nothing found.
4506     \let\next\doignoretextzzz
4507   \else                                 % Found a nested condition, ...
4508     \advance\doignorecount by 1
4509     \let\next\doignoretextyyy           % ..., look for another.
4510     % If we're here, #1 ends with ^^M\ifinfo (for example).
4511   \fi
4512   \next #1% the token \_STOP_ is present just after this macro.
4513 }
4514
4515 % We have to swallow the remaining "\_STOP_".
4516 %
4517 \def\doignoretextzzz#1{%
4518   \ifnum\doignorecount = 0      % We have just found the outermost @end.
4519     \let\next\enddoignore
4520   \else                         % Still inside a nested condition.
4521     \advance\doignorecount by -1
4522     \let\next\doignoretext      % Look for the next @end.
4523   \fi
4524   \next
4525 }
4526
4527 % Finish off ignored text.
4528 { \obeylines%
4529   % Ignore anything after the last `@end #1'; this matters in verbatim
4530   % environments, where otherwise the newline after an ignored conditional
4531   % would result in a blank line in the output.
4532   \gdef\enddoignore#1^^M{\endgroup\ignorespaces}%
4533 }
4534
4535
4536 % @set VAR sets the variable VAR to an empty value.
4537 % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
4538 %
4539 % Since we want to separate VAR from REST-OF-LINE (which might be
4540 % empty), we can't just use \parsearg; we have to insert a space of our
4541 % own to delimit the rest of the line, and then take it out again if we
4542 % didn't need it.
4543 % We rely on the fact that \parsearg sets \catcode`\ =10.
4544 %
4545 \parseargdef\set{\setyyy#1 \endsetyyy}
4546 \def\setyyy#1 #2\endsetyyy{%
4547   {%
4548     \makevalueexpandable
4549     \def\temp{#2}%
4550     \edef\next{\gdef\makecsname{SET#1}}%
4551     \ifx\temp\empty
4552       \next{}%
4553     \else
4554       \setzzz#2\endsetzzz
4555     \fi
4556   }%
4557 }
4558 % Remove the trailing space \setxxx inserted.
4559 \def\setzzz#1 \endsetzzz{\next{#1}}
4560
4561 % @clear VAR clears (i.e., unsets) the variable VAR.
4562 %
4563 \parseargdef\clear{%
4564   {%
4565     \makevalueexpandable
4566     \global\expandafter\let\csname SET#1\endcsname=\relax
4567   }%
4568 }
4569
4570 % @value{foo} gets the text saved in variable foo.
4571 \def\value{\begingroup\makevalueexpandable\valuexxx}
4572 \def\valuexxx#1{\expandablevalue{#1}\endgroup}
4573 {
4574   \catcode`\-=\active \catcode`\_=\active
4575   %
4576   \gdef\makevalueexpandable{%
4577     \let\value = \expandablevalue
4578     % We don't want these characters active, ...
4579     \catcode`\-=\other \catcode`\_=\other
4580     % ..., but we might end up with active ones in the argument if
4581     % we're called from @code, as @code{@value{foo-bar_}}, though.
4582     % So \let them to their normal equivalents.
4583     \let-\normaldash \let_\normalunderscore
4584   }
4585 }
4586
4587 % We have this subroutine so that we can handle at least some @value's
4588 % properly in indexes (we call \makevalueexpandable in \indexdummies).
4589 % The command has to be fully expandable (if the variable is set), since
4590 % the result winds up in the index file.  This means that if the
4591 % variable's value contains other Texinfo commands, it's almost certain
4592 % it will fail (although perhaps we could fix that with sufficient work
4593 % to do a one-level expansion on the result, instead of complete).
4594
4595 % Unfortunately, this has the consequence that when _ is in the *value*
4596 % of an @set, it does not print properly in the roman fonts (get the cmr
4597 % dot accent at position 126 instead).  No fix comes to mind, and it's
4598 % been this way since 2003 or earlier, so just ignore it.
4599
4600 \def\expandablevalue#1{%
4601   \expandafter\ifx\csname SET#1\endcsname\relax
4602     {[No value for ``#1'']}%
4603     \message{Variable `#1', used in @value, is not set.}%
4604   \else
4605     \csname SET#1\endcsname
4606   \fi
4607 }
4608
4609 % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
4610 % with @set.
4611
4612 % To get the special treatment we need for `@end ifset,' we call
4613 % \makecond and then redefine.
4614 %
4615 \makecond{ifset}
4616 \def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}}
4617 \def\doifset#1#2{%
4618   {%
4619     \makevalueexpandable
4620     \let\next=\empty
4621     \expandafter\ifx\csname SET#2\endcsname\relax
4622       #1% If not set, redefine \next.
4623     \fi
4624     \expandafter
4625   }\next
4626 }
4627 \def\ifsetfail{\doignore{ifset}}
4628
4629 % @ifclear VAR ... @end executes the `...' iff VAR has never been
4630 % defined with @set, or has been undefined with @clear.
4631 %
4632 % The `\else' inside the `\doifset' parameter is a trick to reuse the
4633 % above code: if the variable is not set, do nothing, if it is set,
4634 % then redefine \next to \ifclearfail.
4635 %
4636 \makecond{ifclear}
4637 \def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}}
4638 \def\ifclearfail{\doignore{ifclear}}
4639
4640 % @ifcommandisdefined CMD ... @end executes the `...' if CMD (written
4641 % without the @) is in fact defined.  We can only feasibly check at the
4642 % TeX level, so something like `mathcode' is going to considered
4643 % defined even though it is not a Texinfo command.
4644
4645 \makecond{ifcommanddefined}
4646 \def\ifcommanddefined{\parsearg{\doifcmddefined{\let\next=\ifcmddefinedfail}}}
4647 %
4648 \def\doifcmddefined#1#2{{%
4649     \makevalueexpandable
4650     \let\next=\empty
4651     \expandafter\ifx\csname #2\endcsname\relax
4652       #1% If not defined, \let\next as above.
4653     \fi
4654     \expandafter
4655   }\next
4656 }
4657 \def\ifcmddefinedfail{\doignore{ifcommanddefined}}
4658
4659 % @ifcommandnotdefined CMD ... handled similar to @ifclear above.
4660 \makecond{ifcommandnotdefined}
4661 \def\ifcommandnotdefined{%
4662   \parsearg{\doifcmddefined{\else \let\next=\ifcmdnotdefinedfail}}}
4663 \def\ifcmdnotdefinedfail{\doignore{ifcommandnotdefined}}
4664
4665 % Set the `txicommandconditionals' variable, so documents have a way to
4666 % test if the @ifcommand...defined conditionals are available.
4667 \set txicommandconditionals
4668
4669 % @dircategory CATEGORY  -- specify a category of the dir file
4670 % which this file should belong to.  Ignore this in TeX.
4671 \let\dircategory=\comment
4672
4673 % @defininfoenclose.
4674 \let\definfoenclose=\comment
4675
4676
4677 \message{indexing,}
4678 % Index generation facilities
4679
4680 % Define \newwrite to be identical to plain tex's \newwrite
4681 % except not \outer, so it can be used within macros and \if's.
4682 \edef\newwrite{\makecsname{ptexnewwrite}}
4683
4684 % \newindex {foo} defines an index named IX.
4685 % It automatically defines \IXindex such that
4686 % \IXindex ...rest of line... puts an entry in the index IX.
4687 % It also defines \IXindfile to be the number of the output channel for
4688 % the file that accumulates this index.  The file's extension is IX.
4689 % The name of an index should be no more than 2 characters long
4690 % for the sake of vms.
4691 %
4692 \def\newindex#1{%
4693   \expandafter\chardef\csname#1indfile\endcsname=0
4694   \expandafter\xdef\csname#1index\endcsname{%     % Define @#1index
4695     \noexpand\doindex{#1}}
4696 }
4697
4698 % @defindex foo  ==  \newindex{foo}
4699 %
4700 \def\defindex{\parsearg\newindex}
4701
4702 % Define @defcodeindex, like @defindex except put all entries in @code.
4703 %
4704 \def\defcodeindex{\parsearg\newcodeindex}
4705 %
4706 \def\newcodeindex#1{%
4707   \expandafter\chardef\csname#1indfile\endcsname=0
4708   \expandafter\xdef\csname#1index\endcsname{%
4709     \noexpand\docodeindex{#1}}%
4710 }
4711
4712 % The default indices:
4713 \newindex{cp}%      concepts,
4714 \newcodeindex{fn}%  functions,
4715 \newcodeindex{vr}%  variables,
4716 \newcodeindex{tp}%  types,
4717 \newcodeindex{ky}%  keys
4718 \newcodeindex{pg}%  and programs.
4719
4720
4721 % @synindex foo bar    makes index foo feed into index bar.
4722 % Do this instead of @defindex foo if you don't want it as a separate index.
4723 %
4724 % @syncodeindex foo bar   similar, but put all entries made for index foo
4725 % inside @code.
4726 %
4727 \def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}}
4728 \def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}}
4729
4730 % #1 is \doindex or \docodeindex, #2 the index getting redefined (foo),
4731 % #3 the target index (bar).
4732 \def\dosynindex#1#2#3{%
4733   % Only do \closeout if we haven't already done it, else we'll end up
4734   % closing the target index.
4735   \expandafter \ifx\csname donesynindex#2\endcsname \relax
4736     % The \closeout helps reduce unnecessary open files; the limit on the
4737     % Acorn RISC OS is a mere 16 files.
4738     \expandafter\closeout\csname#2indfile\endcsname
4739     \expandafter\let\csname donesynindex#2\endcsname = 1
4740   \fi
4741   % redefine \fooindfile:
4742   \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname
4743   \expandafter\let\csname#2indfile\endcsname=\temp
4744   % redefine \fooindex:
4745   \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}%
4746 }
4747
4748 % Define \doindex, the driver for all index macros.
4749 % Argument #1 is generated by the calling \fooindex macro,
4750 % and it the two-letter name of the index.
4751
4752 \def\doindex#1{\edef\indexname{#1}\parsearg\doindexxxx}
4753 \def\doindexxxx #1{\doind{\indexname}{#1}}
4754
4755 % like the previous two, but they put @code around the argument.
4756 \def\docodeindex#1{\edef\indexname{#1}\parsearg\docodeindexxxx}
4757 \def\docodeindexxxx #1{\doind{\indexname}{\code{#1}}}
4758
4759 % Used when writing an index entry out to an index file to prevent
4760 % expansion of Texinfo commands that can appear in an index entry.
4761 %
4762 \def\indexdummies{%
4763   \escapechar = `\\     % use backslash in output files.
4764   \def\@{@}% change to @@ when we switch to @ as escape char in index files.
4765   \def\ {\realbackslash\space }%
4766   %
4767   % Need these unexpandable (because we define \tt as a dummy)
4768   % definitions when @{ or @} appear in index entry text.  Also, more
4769   % complicated, when \tex is in effect and \{ is a \delimiter again.
4770   % We can't use \lbracecmd and \rbracecmd because texindex assumes
4771   % braces and backslashes are used only as delimiters.  Perhaps we
4772   % should use @lbracechar and @rbracechar?
4773   \def\{{{\tt\char123}}%
4774   \def\}{{\tt\char125}}%
4775   %
4776   % Do the redefinitions.
4777   \commondummies
4778 }
4779
4780 % For the aux and toc files, @ is the escape character.  So we want to
4781 % redefine everything using @ as the escape character (instead of
4782 % \realbackslash, still used for index files).  When everything uses @,
4783 % this will be simpler.
4784 %
4785 \def\atdummies{%
4786   \def\@{@@}%
4787   \def\ {@ }%
4788   \let\{ = \lbraceatcmd
4789   \let\} = \rbraceatcmd
4790   %
4791   % Do the redefinitions.
4792   \commondummies
4793   \otherbackslash
4794 }
4795
4796 % Called from \indexdummies and \atdummies.
4797 %
4798 \def\commondummies{%
4799   % \definedummyword defines \#1 as \string\#1\space, thus effectively
4800   % preventing its expansion.  This is used only for control words,
4801   % not control letters, because the \space would be incorrect for
4802   % control characters, but is needed to separate the control word
4803   % from whatever follows.
4804   %
4805   % For control letters, we have \definedummyletter, which omits the
4806   % space.
4807   %
4808   % These can be used both for control words that take an argument and
4809   % those that do not.  If it is followed by {arg} in the input, then
4810   % that will dutifully get written to the index (or wherever).
4811   %
4812   \def\definedummyword  ##1{\def##1{\string##1\space}}%
4813   \def\definedummyletter##1{\def##1{\string##1}}%
4814   \let\definedummyaccent\definedummyletter
4815   %
4816   \commondummiesnofonts
4817   %
4818   \definedummyletter\_%
4819   \definedummyletter\-%
4820   %
4821   % Non-English letters.
4822   \definedummyword\AA
4823   \definedummyword\AE
4824   \definedummyword\DH
4825   \definedummyword\L
4826   \definedummyword\O
4827   \definedummyword\OE
4828   \definedummyword\TH
4829   \definedummyword\aa
4830   \definedummyword\ae
4831   \definedummyword\dh
4832   \definedummyword\exclamdown
4833   \definedummyword\l
4834   \definedummyword\o
4835   \definedummyword\oe
4836   \definedummyword\ordf
4837   \definedummyword\ordm
4838   \definedummyword\questiondown
4839   \definedummyword\ss
4840   \definedummyword\th
4841   %
4842   % Although these internal commands shouldn't show up, sometimes they do.
4843   \definedummyword\bf
4844   \definedummyword\gtr
4845   \definedummyword\hat
4846   \definedummyword\less
4847   \definedummyword\sf
4848   \definedummyword\sl
4849   \definedummyword\tclose
4850   \definedummyword\tt
4851   %
4852   \definedummyword\LaTeX
4853   \definedummyword\TeX
4854   %
4855   % Assorted special characters.
4856   \definedummyword\arrow
4857   \definedummyword\bullet
4858   \definedummyword\comma
4859   \definedummyword\copyright
4860   \definedummyword\registeredsymbol
4861   \definedummyword\dots
4862   \definedummyword\enddots
4863   \definedummyword\entrybreak
4864   \definedummyword\equiv
4865   \definedummyword\error
4866   \definedummyword\euro
4867   \definedummyword\expansion
4868   \definedummyword\geq
4869   \definedummyword\guillemetleft
4870   \definedummyword\guillemetright
4871   \definedummyword\guilsinglleft
4872   \definedummyword\guilsinglright
4873   \definedummyword\lbracechar
4874   \definedummyword\leq
4875   \definedummyword\mathopsup
4876   \definedummyword\minus
4877   \definedummyword\ogonek
4878   \definedummyword\pounds
4879   \definedummyword\point
4880   \definedummyword\print
4881   \definedummyword\quotedblbase
4882   \definedummyword\quotedblleft
4883   \definedummyword\quotedblright
4884   \definedummyword\quoteleft
4885   \definedummyword\quoteright
4886   \definedummyword\quotesinglbase
4887   \definedummyword\rbracechar
4888   \definedummyword\result
4889   \definedummyword\sub
4890   \definedummyword\sup
4891   \definedummyword\textdegree
4892   %
4893   % We want to disable all macros so that they are not expanded by \write.
4894   \macrolist
4895   \definedummyword\value
4896   %
4897   \normalturnoffactive
4898 }
4899
4900 % \commondummiesnofonts: common to \commondummies and \indexnofonts.
4901 % Define \definedumyletter, \definedummyaccent and \definedummyword before
4902 % using.
4903 %
4904 \def\commondummiesnofonts{%
4905   % Control letters and accents.
4906   \definedummyletter\!%
4907   \definedummyaccent\"%
4908   \definedummyaccent\'%
4909   \definedummyletter\*%
4910   \definedummyaccent\,%
4911   \definedummyletter\.%
4912   \definedummyletter\/%
4913   \definedummyletter\:%
4914   \definedummyaccent\=%
4915   \definedummyletter\?%
4916   \definedummyaccent\^%
4917   \definedummyaccent\`%
4918   \definedummyaccent\~%
4919   \definedummyword\u
4920   \definedummyword\v
4921   \definedummyword\H
4922   \definedummyword\dotaccent
4923   \definedummyword\ogonek
4924   \definedummyword\ringaccent
4925   \definedummyword\tieaccent
4926   \definedummyword\ubaraccent
4927   \definedummyword\udotaccent
4928   \definedummyword\dotless
4929   %
4930   % Texinfo font commands.
4931   \definedummyword\b
4932   \definedummyword\i
4933   \definedummyword\r
4934   \definedummyword\sansserif
4935   \definedummyword\sc
4936   \definedummyword\slanted
4937   \definedummyword\t
4938   %
4939   % Commands that take arguments.
4940   \definedummyword\abbr
4941   \definedummyword\acronym
4942   \definedummyword\anchor
4943   \definedummyword\cite
4944   \definedummyword\code
4945   \definedummyword\command
4946   \definedummyword\dfn
4947   \definedummyword\dmn
4948   \definedummyword\email
4949   \definedummyword\emph
4950   \definedummyword\env
4951   \definedummyword\file
4952   \definedummyword\image
4953   \definedummyword\indicateurl
4954   \definedummyword\inforef
4955   \definedummyword\kbd
4956   \definedummyword\key
4957   \definedummyword\math
4958   \definedummyword\option
4959   \definedummyword\pxref
4960   \definedummyword\ref
4961   \definedummyword\samp
4962   \definedummyword\strong
4963   \definedummyword\tie
4964   \definedummyword\U
4965   \definedummyword\uref
4966   \definedummyword\url
4967   \definedummyword\var
4968   \definedummyword\verb
4969   \definedummyword\w
4970   \definedummyword\xref
4971 }
4972
4973 % For testing: output @{ and @} in index sort strings as \{ and \}.
4974 \newif\ifusebracesinindexes
4975
4976 \let\indexlbrace\relax
4977 \let\indexrbrace\relax
4978
4979 {\catcode`\@=0
4980 \catcode`\\=13
4981   @gdef@backslashdisappear{@def\{}}
4982 }
4983
4984 {
4985 \catcode`\<=13
4986 \catcode`\-=13
4987 \catcode`\`=13
4988   \gdef\indexnonalnumdisappear{%
4989     \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax\else
4990       % @set txiindexlquoteignore makes us ignore left quotes in the sort term.
4991       % (Introduced for FSFS 2nd ed.)
4992       \let`=\empty
4993     \fi
4994     %
4995     \expandafter\ifx\csname SETtxiindexbackslashignore\endcsname\relax\else
4996       \backslashdisappear
4997     \fi
4998     %
4999     \expandafter\ifx\csname SETtxiindexhyphenignore\endcsname\relax\else
5000       \def-{}%
5001     \fi
5002     \expandafter\ifx\csname SETtxiindexlessthanignore\endcsname\relax\else
5003       \def<{}%
5004     \fi
5005     \expandafter\ifx\csname SETtxiindexatsignignore\endcsname\relax\else
5006       \def\@{}%
5007     \fi
5008   }
5009
5010   \gdef\indexnonalnumreappear{%
5011     \useindexbackslash
5012     \let-\normaldash
5013     \let<\normalless
5014     \def\@{@}%
5015   }
5016 }
5017
5018
5019 % \indexnofonts is used when outputting the strings to sort the index
5020 % by, and when constructing control sequence names.  It eliminates all
5021 % control sequences and just writes whatever the best ASCII sort string
5022 % would be for a given command (usually its argument).
5023 %
5024 \def\indexnofonts{%
5025   % Accent commands should become @asis.
5026   \def\definedummyaccent##1{\let##1\asis}%
5027   % We can just ignore other control letters.
5028   \def\definedummyletter##1{\let##1\empty}%
5029   % All control words become @asis by default; overrides below.
5030   \let\definedummyword\definedummyaccent
5031   \commondummiesnofonts
5032   %
5033   % Don't no-op \tt, since it isn't a user-level command
5034   % and is used in the definitions of the active chars like <, >, |, etc.
5035   % Likewise with the other plain tex font commands.
5036   %\let\tt=\asis
5037   %
5038   \def\ { }%
5039   \def\@{@}%
5040   \def\_{\normalunderscore}%
5041   \def\-{}% @- shouldn't affect sorting
5042   %
5043   \uccode`\1=`\{ \uppercase{\def\{{1}}%
5044   \uccode`\1=`\} \uppercase{\def\}{1}}%
5045   \let\lbracechar\{%
5046   \let\rbracechar\}%
5047   %
5048   % Non-English letters.
5049   \def\AA{AA}%
5050   \def\AE{AE}%
5051   \def\DH{DZZ}%
5052   \def\L{L}%
5053   \def\OE{OE}%
5054   \def\O{O}%
5055   \def\TH{TH}%
5056   \def\aa{aa}%
5057   \def\ae{ae}%
5058   \def\dh{dzz}%
5059   \def\exclamdown{!}%
5060   \def\l{l}%
5061   \def\oe{oe}%
5062   \def\ordf{a}%
5063   \def\ordm{o}%
5064   \def\o{o}%
5065   \def\questiondown{?}%
5066   \def\ss{ss}%
5067   \def\th{th}%
5068   %
5069   \def\LaTeX{LaTeX}%
5070   \def\TeX{TeX}%
5071   %
5072   % Assorted special characters.
5073   % (The following {} will end up in the sort string, but that's ok.)
5074   \def\arrow{->}%
5075   \def\bullet{bullet}%
5076   \def\comma{,}%
5077   \def\copyright{copyright}%
5078   \def\dots{...}%
5079   \def\enddots{...}%
5080   \def\equiv{==}%
5081   \def\error{error}%
5082   \def\euro{euro}%
5083   \def\expansion{==>}%
5084   \def\geq{>=}%
5085   \def\guillemetleft{<<}%
5086   \def\guillemetright{>>}%
5087   \def\guilsinglleft{<}%
5088   \def\guilsinglright{>}%
5089   \def\leq{<=}%
5090   \def\minus{-}%
5091   \def\point{.}%
5092   \def\pounds{pounds}%
5093   \def\print{-|}%
5094   \def\quotedblbase{"}%
5095   \def\quotedblleft{"}%
5096   \def\quotedblright{"}%
5097   \def\quoteleft{`}%
5098   \def\quoteright{'}%
5099   \def\quotesinglbase{,}%
5100   \def\registeredsymbol{R}%
5101   \def\result{=>}%
5102   \def\textdegree{o}%
5103   %
5104   % We need to get rid of all macros, leaving only the arguments (if present).
5105   % Of course this is not nearly correct, but it is the best we can do for now.
5106   % makeinfo does not expand macros in the argument to @deffn, which ends up
5107   % writing an index entry, and texindex isn't prepared for an index sort entry
5108   % that starts with \.
5109   %
5110   % Since macro invocations are followed by braces, we can just redefine them
5111   % to take a single TeX argument.  The case of a macro invocation that
5112   % goes to end-of-line is not handled.
5113   %
5114   \macrolist
5115 }
5116
5117
5118 \let\SETmarginindex=\relax % put index entries in margin (undocumented)?
5119
5120 % Most index entries go through here, but \dosubind is the general case.
5121 % #1 is the index name, #2 is the entry text.
5122 \def\doind#1#2{\dosubind{#1}{#2}{}}
5123
5124 % There is also \dosubind {index}{topic}{subtopic}
5125 % which makes an entry in a two-level index such as the operation index.
5126 % TODO: Two-level index?  Operation index?
5127
5128 % Workhorse for all indexes.
5129 % #1 is name of index, #2 is stuff to put there, #3 is subentry --
5130 % empty if called from \doind, as we usually are (the main exception
5131 % is with most defuns, which call us directly).
5132 %
5133 \def\dosubind#1#2#3{%
5134   \iflinks
5135   {%
5136     \requireopenindexfile{#1}%
5137     % Store the main index entry text (including the third arg).
5138     \toks0 = {#2}%
5139     % If third arg is present, precede it with a space.
5140     \def\thirdarg{#3}%
5141     \ifx\thirdarg\empty \else
5142       \toks0 = \expandafter{\the\toks0 \space #3}%
5143     \fi
5144     %
5145     \edef\writeto{\csname#1indfile\endcsname}%
5146     %
5147     \safewhatsit\dosubindwrite
5148   }%
5149   \fi
5150 }
5151
5152 % Check if an index file has been opened, and if not, open it.
5153 \def\requireopenindexfile#1{%
5154 \ifnum\csname #1indfile\endcsname=0
5155   \expandafter\newwrite \csname#1indfile\endcsname
5156   \edef\suffix{#1}%
5157   % A .fls suffix would conflict with the file extension for the output
5158   % of -recorder, so use .f1s instead.
5159   \ifx\suffix\indexisfl\def\suffix{f1}\fi
5160   % Open the file
5161   \immediate\openout\csname#1indfile\endcsname \jobname.\suffix
5162   % Using \immediate above here prevents an object entering into the current 
5163   % box, which could confound checks such as those in \safewhatsit for
5164   % preceding skips.
5165   \typeout{Writing index file \jobname.\suffix}%
5166 \fi}
5167 \def\indexisfl{fl}
5168
5169 % Output \ as {\indexbackslash}, because \ is an escape character in
5170 % the index files.
5171 \let\indexbackslash=\relax
5172 {\catcode`\@=0 \catcode`\\=\active
5173   @gdef@useindexbackslash{@def\{{@indexbackslash}}}
5174 }
5175
5176 % Definition for writing index entry text.
5177 \def\sortas#1{\ignorespaces}%
5178
5179 % Definition for writing index entry sort key.  Should occur at the at
5180 % the beginning of the index entry, like
5181 %     @cindex @sortas{september} \september
5182 % The \ignorespaces takes care of following space, but there's no way
5183 % to remove space before it.
5184 {
5185 \catcode`\-=13
5186 \gdef\indexwritesortas{%
5187   \begingroup
5188   \indexnonalnumreappear
5189   \indexwritesortasxxx}
5190 \gdef\indexwritesortasxxx#1{%
5191   \xdef\indexsortkey{#1}\endgroup}
5192 }
5193
5194
5195 % Write the entry in \toks0 to the index file.
5196 %
5197 \def\dosubindwrite{%
5198   % Put the index entry in the margin if desired.
5199   \ifx\SETmarginindex\relax\else
5200     \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}%
5201   \fi
5202   %
5203   % Remember, we are within a group.
5204   \indexdummies % Must do this here, since \bf, etc expand at this stage
5205   \useindexbackslash % \indexbackslash isn't defined now so it will be output 
5206                      % as is; and it will print as backslash.
5207   % The braces around \indexbrace are recognized by texindex.
5208   %
5209   % Get the string to sort by, by processing the index entry with all
5210   % font commands turned off.
5211   {\indexnofonts
5212    \def\lbracechar{{\indexlbrace}}%
5213    \def\rbracechar{{\indexrbrace}}%
5214    \let\{=\lbracechar
5215    \let\}=\rbracechar
5216    \indexnonalnumdisappear
5217    \xdef\indexsortkey{}%
5218    \let\sortas=\indexwritesortas
5219    \edef\temp{\the\toks0}%
5220    \setbox\dummybox = \hbox{\temp}% Make sure to execute any \sortas
5221    \ifx\indexsortkey\empty
5222      \xdef\indexsortkey{\temp}%
5223      \ifx\indexsortkey\empty\xdef\indexsortkey{ }\fi
5224    \fi
5225   }%
5226   %
5227   % Set up the complete index entry, with both the sort key and
5228   % the original text, including any font commands.  We write
5229   % three arguments to \entry to the .?? file (four in the
5230   % subentry case), texindex reduces to two when writing the .??s
5231   % sorted result.
5232   \edef\temp{%
5233     \write\writeto{%
5234       \string\entry{\indexsortkey}{\noexpand\folio}{\the\toks0}}%
5235   }%
5236   \temp
5237 }
5238 \newbox\dummybox % used above
5239
5240 % Take care of unwanted page breaks/skips around a whatsit:
5241 %
5242 % If a skip is the last thing on the list now, preserve it
5243 % by backing up by \lastskip, doing the \write, then inserting
5244 % the skip again.  Otherwise, the whatsit generated by the
5245 % \write or \pdfdest will make \lastskip zero.  The result is that
5246 % sequences like this:
5247 % @end defun
5248 % @tindex whatever
5249 % @defun ...
5250 % will have extra space inserted, because the \medbreak in the
5251 % start of the @defun won't see the skip inserted by the @end of
5252 % the previous defun.
5253 %
5254 % But don't do any of this if we're not in vertical mode.  We
5255 % don't want to do a \vskip and prematurely end a paragraph.
5256 %
5257 % Avoid page breaks due to these extra skips, too.
5258 %
5259 % But wait, there is a catch there:
5260 % We'll have to check whether \lastskip is zero skip.  \ifdim is not
5261 % sufficient for this purpose, as it ignores stretch and shrink parts
5262 % of the skip.  The only way seems to be to check the textual
5263 % representation of the skip.
5264 %
5265 % The following is almost like \def\zeroskipmacro{0.0pt} except that
5266 % the ``p'' and ``t'' characters have catcode \other, not 11 (letter).
5267 %
5268 \edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname}
5269 %
5270 \newskip\whatsitskip
5271 \newcount\whatsitpenalty
5272 %
5273 % ..., ready, GO:
5274 %
5275 \def\safewhatsit#1{\ifhmode
5276   #1%
5277  \else
5278   % \lastskip and \lastpenalty cannot both be nonzero simultaneously.
5279   \whatsitskip = \lastskip
5280   \edef\lastskipmacro{\the\lastskip}%
5281   \whatsitpenalty = \lastpenalty
5282   %
5283   % If \lastskip is nonzero, that means the last item was a
5284   % skip.  And since a skip is discardable, that means this
5285   % -\whatsitskip glue we're inserting is preceded by a
5286   % non-discardable item, therefore it is not a potential
5287   % breakpoint, therefore no \nobreak needed.
5288   \ifx\lastskipmacro\zeroskipmacro
5289   \else
5290     \vskip-\whatsitskip
5291   \fi
5292   %
5293   #1%
5294   %
5295   \ifx\lastskipmacro\zeroskipmacro
5296     % If \lastskip was zero, perhaps the last item was a penalty, and
5297     % perhaps it was >=10000, e.g., a \nobreak.  In that case, we want
5298     % to re-insert the same penalty (values >10000 are used for various
5299     % signals); since we just inserted a non-discardable item, any
5300     % following glue (such as a \parskip) would be a breakpoint.  For example:
5301     %   @deffn deffn-whatever
5302     %   @vindex index-whatever
5303     %   Description.
5304     % would allow a break between the index-whatever whatsit
5305     % and the "Description." paragraph.
5306     \ifnum\whatsitpenalty>9999 \penalty\whatsitpenalty \fi
5307   \else
5308     % On the other hand, if we had a nonzero \lastskip,
5309     % this make-up glue would be preceded by a non-discardable item
5310     % (the whatsit from the \write), so we must insert a \nobreak.
5311     \nobreak\vskip\whatsitskip
5312   \fi
5313 \fi}
5314
5315 % The index entry written in the file actually looks like
5316 %  \entry {sortstring}{page}{topic}
5317 % or
5318 %  \entry {sortstring}{page}{topic}{subtopic}
5319 % The texindex program reads in these files and writes files
5320 % containing these kinds of lines:
5321 %  \initial {c}
5322 %     before the first topic whose initial is c
5323 %  \entry {topic}{pagelist}
5324 %     for a topic that is used without subtopics
5325 %  \primary {topic}
5326 %     for the beginning of a topic that is used with subtopics
5327 %  \secondary {subtopic}{pagelist}
5328 %     for each subtopic.
5329
5330 % Define the user-accessible indexing commands
5331 % @findex, @vindex, @kindex, @cindex.
5332
5333 \def\findex {\fnindex}
5334 \def\kindex {\kyindex}
5335 \def\cindex {\cpindex}
5336 \def\vindex {\vrindex}
5337 \def\tindex {\tpindex}
5338 \def\pindex {\pgindex}
5339
5340 \def\cindexsub {\begingroup\obeylines\cindexsub}
5341 {\obeylines %
5342 \gdef\cindexsub "#1" #2^^M{\endgroup %
5343 \dosubind{cp}{#2}{#1}}}
5344
5345 % Define the macros used in formatting output of the sorted index material.
5346
5347 % @printindex causes a particular index (the ??s file) to get printed.
5348 % It does not print any chapter heading (usually an @unnumbered).
5349 %
5350 \parseargdef\printindex{\begingroup
5351   \dobreak \chapheadingskip{10000}%
5352   %
5353   \smallfonts \rm
5354   \tolerance = 9500
5355   \plainfrenchspacing
5356   \everypar = {}% don't want the \kern\-parindent from indentation suppression.
5357   %
5358   % See if the index file exists and is nonempty.
5359   % Change catcode of @ here so that if the index file contains
5360   % \initial {@}
5361   % as its first line, TeX doesn't complain about mismatched braces
5362   % (because it thinks @} is a control sequence).
5363   \catcode`\@ = 11
5364   % See comment in \requireopenindexfile.
5365   \def\indexname{#1}\ifx\indexname\indexisfl\def\indexname{f1}\fi
5366   \openin 1 \jobname.\indexname s
5367   \ifeof 1
5368     % \enddoublecolumns gets confused if there is no text in the index,
5369     % and it loses the chapter title and the aux file entries for the
5370     % index.  The easiest way to prevent this problem is to make sure
5371     % there is some text.
5372     \putwordIndexNonexistent
5373     \typeout{No file \jobname.\indexname s.}%
5374   \else
5375     \catcode`\\ = 0
5376     %
5377     % If the index file exists but is empty, then \openin leaves \ifeof
5378     % false.  We have to make TeX try to read something from the file, so
5379     % it can discover if there is anything in it.
5380     \read 1 to \thisline
5381     \ifeof 1
5382       \putwordIndexIsEmpty
5383     \else
5384       % Index files are almost Texinfo source, but we use \ as the escape
5385       % character.  It would be better to use @, but that's too big a change
5386       % to make right now.
5387       \def\indexbackslash{\ttbackslash}%
5388       \let\indexlbrace\{   % Likewise, set these sequences for braces
5389       \let\indexrbrace\}   % used in the sort key.
5390       \begindoublecolumns
5391       \let\entryorphanpenalty=\indexorphanpenalty
5392       %
5393       % Read input from the index file line by line.
5394       \loopdo
5395         \ifeof1
5396           \let\firsttoken\relax
5397         \else
5398           \read 1 to \nextline
5399           \edef\act{\gdef\noexpand\firsttoken{\getfirsttoken\nextline}}%
5400           \act
5401         \fi
5402         \thisline
5403         %
5404         \ifeof1\else
5405         \let\thisline\nextline
5406       \repeat
5407       %%
5408       \enddoublecolumns
5409     \fi
5410   \fi
5411   \closein 1
5412 \endgroup}
5413
5414 \def\getfirsttoken#1{\expandafter\getfirsttokenx#1\endfirsttoken}
5415 \long\def\getfirsttokenx#1#2\endfirsttoken{\noexpand#1}
5416
5417 \def\loopdo#1\repeat{\def\body{#1}\loopdoxxx}
5418 \def\loopdoxxx{\let\next=\relax\body\let\next=\loopdoxxx\fi\next}
5419
5420 % These macros are used by the sorted index file itself.
5421 % Change them to control the appearance of the index.
5422
5423 {\catcode`\/=13 \catcode`\-=13 \catcode`\^=13 \catcode`\~=13 \catcode`\_=13
5424 \catcode`\|=13 \catcode`\<=13 \catcode`\>=13 \catcode`\+=13 \catcode`\"=13
5425 \catcode`\$=3
5426 \gdef\initialglyphs{%
5427   % Some changes for non-alphabetic characters.  Using the glyphs from the
5428   % math fonts looks more consistent than the typewriter font used elsewhere
5429   % for these characters.
5430   \def\indexbackslash{\math{\backslash}}%
5431   \let\\=\indexbackslash
5432   %
5433   % Can't get bold backslash so don't use bold forward slash
5434   \catcode`\/=13
5435   \def/{{\secrmnotbold \normalslash}}%
5436   \def-{{\normaldash\normaldash}}% en dash `--'
5437   \def^{{\chapbf \normalcaret}}%
5438   \def~{{\chapbf \normaltilde}}%
5439   \def\_{%
5440      \leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }%
5441   \def|{$\vert$}%
5442   \def<{$\less$}%
5443   \def>{$\gtr$}%
5444   \def+{$\normalplus$}%
5445 }}
5446
5447 \def\initial{%
5448   \bgroup
5449   \initialglyphs
5450   \initialx
5451 }
5452
5453 \def\initialx#1{%
5454   % Remove any glue we may have, we'll be inserting our own.
5455   \removelastskip
5456   %
5457   % We like breaks before the index initials, so insert a bonus.
5458   % The glue before the bonus allows a little bit of space at the
5459   % bottom of a column to reduce an increase in inter-line spacing.
5460   \nobreak
5461   \vskip 0pt plus 5\baselineskip
5462   \penalty -300 
5463   \vskip 0pt plus -5\baselineskip
5464   %
5465   % Typeset the initial.  Making this add up to a whole number of
5466   % baselineskips increases the chance of the dots lining up from column
5467   % to column.  It still won't often be perfect, because of the stretch
5468   % we need before each entry, but it's better.
5469   %
5470   % No shrink because it confuses \balancecolumns.
5471   \vskip 1.67\baselineskip plus 1\baselineskip
5472   \leftline{\secfonts \kern-0.05em \secbf #1}%
5473   % \secfonts is inside the argument of \leftline so that the change of
5474   % \baselineskip will not affect any glue inserted before the vbox that
5475   % \leftline creates.
5476   % Do our best not to break after the initial.
5477   \nobreak
5478   \vskip .33\baselineskip plus .1\baselineskip
5479   \egroup % \initialglyphs
5480 }
5481
5482 \newdimen\entryrightmargin
5483 \entryrightmargin=0pt
5484
5485 % \entry typesets a paragraph consisting of the text (#1), dot leaders, and
5486 % then page number (#2) flushed to the right margin.  It is used for index
5487 % and table of contents entries.  The paragraph is indented by \leftskip.
5488 %
5489 \def\entry{%
5490   \begingroup
5491     %
5492     % Start a new paragraph if necessary, so our assignments below can't
5493     % affect previous text.
5494     \par
5495     %
5496     % No extra space above this paragraph.
5497     \parskip = 0in
5498     %
5499     % When reading the text of entry, convert explicit line breaks
5500     % from @* into spaces.  The user might give these in long section
5501     % titles, for instance.
5502     \def\*{\unskip\space\ignorespaces}%
5503     \def\entrybreak{\hfil\break}% An undocumented command
5504     %
5505     % A bit of stretch before each entry for the benefit of balancing
5506     % columns.
5507     \vskip 0pt plus0.5pt
5508     %
5509     % Swallow the left brace of the text (first parameter):
5510     \afterassignment\doentry
5511     \let\temp =
5512 }
5513 \def\entrybreak{\unskip\space\ignorespaces}%
5514 \def\doentry{%
5515     % Save the text of the entry
5516     \global\setbox\boxA=\hbox\bgroup
5517     \bgroup % Instead of the swallowed brace.
5518       \noindent
5519       \aftergroup\finishentry
5520       % And now comes the text of the entry.
5521       % Not absorbing as a macro argument reduces the chance of problems
5522       % with catcodes occurring.
5523 }
5524 {\catcode`\@=11
5525 \gdef\finishentry#1{%
5526     \egroup % end box A
5527     \dimen@ = \wd\boxA % Length of text of entry
5528     \global\setbox\boxA=\hbox\bgroup\unhbox\boxA
5529     % #1 is the page number.
5530     %
5531     % Get the width of the page numbers, and only use
5532     % leaders if they are present.
5533     \global\setbox\boxB = \hbox{#1}%
5534     \ifdim\wd\boxB = 0pt
5535       \null\nobreak\hfill\ %
5536     \else
5537       %
5538       \null\nobreak\indexdotfill % Have leaders before the page number.
5539       %
5540       \ifpdf
5541         \pdfgettoks#1.%
5542         \bgroup\let\domark\relax
5543           \hskip\skip\thinshrinkable\the\toksA
5544         \egroup
5545         % The redefinion of \domark stops marks being added in \pdflink to 
5546         % preserve coloured links across page boundaries.  Otherwise the marks
5547         % would get in the way of \lastbox in \insertindexentrybox.
5548       \else
5549         \ifx\XeTeXrevision\thisisundefined
5550           \hskip\skip\thinshrinkable #1%
5551         \else
5552           \pdfgettoks#1.%
5553           \bgroup\let\domark\relax
5554             \hskip\skip\thinshrinkable\the\toksA
5555           \egroup
5556         \fi
5557       \fi
5558     \fi
5559     \egroup % end \boxA
5560     \ifdim\wd\boxB = 0pt
5561       \global\setbox\entryindexbox=\vbox{\unhbox\boxA}%
5562     \else
5563     \global\setbox\entryindexbox=\vbox\bgroup
5564       \prevdepth=\entrylinedepth
5565       \noindent
5566       % We want the text of the entries to be aligned to the left, and the
5567       % page numbers to be aligned to the right.
5568       %
5569       \advance\leftskip by 0pt plus 1fil
5570       \advance\leftskip by 0pt plus -1fill
5571       \rightskip = 0pt plus -1fil
5572       \advance\rightskip by 0pt plus 1fill
5573       % Cause last line, which could consist of page numbers on their own
5574       % if the list of page numbers is long, to be aligned to the right.
5575       \parfillskip=0pt plus -1fill
5576       %
5577       \hangindent=1em
5578       %
5579       \advance\rightskip by \entryrightmargin
5580       % Determine how far we can stretch into the margin.
5581       % This allows, e.g., "Appendix H  GNU Free Documentation License" to
5582       % fit on one line in @letterpaper format.
5583       \ifdim\entryrightmargin>2.1em
5584         \dimen@i=2.1em
5585       \else
5586         \dimen@i=0em
5587       \fi
5588       \advance \parfillskip by 0pt minus 1\dimen@i
5589       %
5590       \dimen@ii = \hsize
5591       \advance\dimen@ii by -1\leftskip
5592       \advance\dimen@ii by -1\entryrightmargin
5593       \advance\dimen@ii by 1\dimen@i
5594       \ifdim\wd\boxA > \dimen@ii % If the entry doesn't fit in one line
5595       \ifdim\dimen@ > 0.8\dimen@ii   % due to long index text
5596         \dimen@ = 0.7\dimen@ % Try to split the text roughly evenly
5597         \dimen@ii = \hsize
5598         \advance \dimen@ii by -1em
5599         \ifnum\dimen@>\dimen@ii
5600           % If the entry is too long, use the whole line
5601           \dimen@ = \dimen@ii
5602         \fi
5603         \advance\leftskip by 0pt plus 1fill % ragged right
5604         \advance \dimen@ by 1\rightskip
5605         \parshape = 2 0pt \dimen@ 1em \dimen@ii
5606         % Ideally we'd add a finite glue at the end of the first line only, but
5607         % TeX doesn't seem to provide a way to do such a thing.
5608       \fi\fi
5609       \unhbox\boxA
5610       %
5611       % Do not prefer a separate line ending with a hyphen to fewer lines.
5612       \finalhyphendemerits = 0
5613       %
5614       % Word spacing - no stretch
5615       \spaceskip=\fontdimen2\font minus \fontdimen4\font
5616       %
5617       \linepenalty=1000  % Discourage line breaks.
5618       \hyphenpenalty=5000  % Discourage hyphenation.
5619       %
5620       \par % format the paragraph
5621     \egroup % The \vbox
5622     \fi
5623   \endgroup
5624   % delay text of entry until after penalty
5625   \bgroup\aftergroup\insertindexentrybox
5626   \entryorphanpenalty
5627 }}
5628
5629 \newskip\thinshrinkable
5630 \skip\thinshrinkable=.15em minus .15em
5631
5632 \newbox\entryindexbox
5633 \def\insertindexentrybox{%
5634   \copy\entryindexbox
5635   % The following gets the depth of the last box.  This is for even
5636   % line spacing when entries span several lines.
5637   \setbox\dummybox\vbox{%
5638     \unvbox\entryindexbox
5639     \nointerlineskip
5640     \lastbox
5641     \global\entrylinedepth=\prevdepth
5642   }%
5643   % Note that we couldn't simply \unvbox\entryindexbox followed by 
5644   % \nointerlineskip\lastbox to remove the last box and then reinstate it, 
5645   % because this resets how far the box has been \moveleft'ed to 0.  \unvbox
5646   % doesn't affect \prevdepth either.
5647 }
5648 \newdimen\entrylinedepth
5649
5650 % Default is no penalty
5651 \let\entryorphanpenalty\egroup
5652
5653 % Used from \printindex.  \firsttoken should be the first token
5654 % after the \entry.  If it's not another \entry, we are at the last
5655 % line of a group of index entries, so insert a penalty to discourage
5656 % orphaned index entries.
5657 \long\def\indexorphanpenalty{%
5658   \def\isentry{\entry}%
5659   \ifx\firsttoken\isentry
5660   \else
5661     \unskip\penalty 9000
5662     % The \unskip here stops breaking before the glue.  It relies on the
5663     % \vskip above being there, otherwise there is an error
5664     % "You can't use `\unskip' in vertical mode".  There has to be glue
5665     % in the current vertical list that hasn't been added to the
5666     % "current page".  See Chapter 24 of the TeXbook.  This contradicts
5667     % Section 8.3.7 in "TeX by Topic," though.
5668   \fi
5669   \egroup % now comes the box added with \aftergroup
5670 }
5671
5672 % Like plain.tex's \dotfill, except uses up at least 1 em.
5673 % The filll stretch here overpowers both the fil and fill stretch to push
5674 % the page number to the right.
5675 \def\indexdotfill{\cleaders
5676   \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1filll}
5677
5678
5679 \def\primary #1{\line{#1\hfil}}
5680
5681 \newskip\secondaryindent \secondaryindent=0.5cm
5682 \def\secondary#1#2{{%
5683   \parfillskip=0in
5684   \parskip=0in
5685   \hangindent=1in
5686   \hangafter=1
5687   \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill
5688   \ifpdf
5689     \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
5690   \else
5691     \ifx\XeTeXrevision\thisisundefined
5692       #2
5693     \else
5694       \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
5695     \fi
5696   \fi
5697   \par
5698 }}
5699
5700 % Define two-column mode, which we use to typeset indexes.
5701 % Adapted from the TeXbook, page 416, which is to say,
5702 % the manmac.tex format used to print the TeXbook itself.
5703 \catcode`\@=11  % private names
5704
5705 \newbox\partialpage
5706 \newdimen\doublecolumnhsize
5707 \newdimen\doublecolumntopgap
5708 \doublecolumntopgap = 0pt
5709
5710 % Use inside an output routine to save \topmark and \firstmark
5711 \def\savemarks{%
5712   \global\savedtopmark=\expandafter{\topmark }%
5713   \global\savedfirstmark=\expandafter{\firstmark }%
5714 }
5715 \newtoks\savedtopmark
5716 \newtoks\savedfirstmark
5717
5718 % Set \topmark and \firstmark for next time \output runs.
5719 % Can't be run from withinside \output (because any material
5720 % added while an output routine is active, including 
5721 % penalties, is saved for after it finishes).  The page so far
5722 % should be empty, otherwise what's on it will be thrown away.
5723 \def\restoremarks{%
5724   \mark{\the\savedtopmark}%
5725   \bgroup\output = {%
5726     \setbox\dummybox=\box\PAGE
5727   }abc\eject\egroup
5728   % "abc" because output routine doesn't fire for a completely empty page.
5729   \mark{\the\savedfirstmark}%
5730 }
5731
5732 \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
5733   % If not much space left on page, start a new page.
5734   \ifdim\pagetotal>0.8\vsize\vfill\eject\fi
5735   %
5736   % Grab any single-column material above us.
5737   \output = {%
5738     %
5739     % Here is a possibility not foreseen in manmac: if we accumulate a
5740     % whole lot of material, we might end up calling this \output
5741     % routine twice in a row (see the doublecol-lose test, which is
5742     % essentially a couple of indexes with @setchapternewpage off).  In
5743     % that case we just ship out what is in \partialpage with the normal
5744     % output routine.  Generally, \partialpage will be empty when this
5745     % runs and this will be a no-op.  See the indexspread.tex test case.
5746     \ifvoid\partialpage \else
5747       \onepageout{\pagecontents\partialpage}%
5748     \fi
5749     %
5750     \global\setbox\partialpage = \vbox{%
5751       % Unvbox the main output page.
5752       \unvbox\PAGE
5753       \kern-\topskip \kern\baselineskip
5754     }%
5755     \savemarks
5756   }%
5757   \eject % run that output routine to set \partialpage
5758   \restoremarks
5759   %
5760   % We recover the two marks that the last output routine saved in order
5761   % to propagate the information in marks added around a chapter heading,
5762   % which could be otherwise be lost by the time the final page is output.
5763   %
5764   %
5765   % Use the double-column output routine for subsequent pages.
5766   \output = {\doublecolumnout}%
5767   %
5768   % Change the page size parameters.  We could do this once outside this
5769   % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
5770   % format, but then we repeat the same computation.  Repeating a couple
5771   % of assignments once per index is clearly meaningless for the
5772   % execution time, so we may as well do it in one place.
5773   %
5774   % First we halve the line length, less a little for the gutter between
5775   % the columns.  We compute the gutter based on the line length, so it
5776   % changes automatically with the paper format.  The magic constant
5777   % below is chosen so that the gutter has the same value (well, +-<1pt)
5778   % as it did when we hard-coded it.
5779   %
5780   % We put the result in a separate register, \doublecolumhsize, so we
5781   % can restore it in \pagesofar, after \hsize itself has (potentially)
5782   % been clobbered.
5783   %
5784   \doublecolumnhsize = \hsize
5785     \advance\doublecolumnhsize by -.04154\hsize
5786     \divide\doublecolumnhsize by 2
5787   \hsize = \doublecolumnhsize
5788   %
5789   % Double the \vsize as well.  (We don't need a separate register here,
5790   % since nobody clobbers \vsize.)
5791   \global\doublecolumntopgap = \topskip
5792   \global\advance\doublecolumntopgap by -1\baselineskip
5793   \advance\vsize by -1\doublecolumntopgap
5794   \vsize = 2\vsize
5795   \topskip=0pt
5796   \global\entrylinedepth=0pt\relax
5797 }
5798
5799 % The double-column output routine for all double-column pages except
5800 % the last, which is done by \balancecolumns.
5801 %
5802 \def\doublecolumnout{%
5803   %
5804   \splittopskip=\topskip \splitmaxdepth=\maxdepth
5805   % Get the available space for the double columns -- the normal
5806   % (undoubled) page height minus any material left over from the
5807   % previous page.
5808   \dimen@ = \vsize
5809   \divide\dimen@ by 2
5810   \advance\dimen@ by -\ht\partialpage
5811   %
5812   % box0 will be the left-hand column, box2 the right.
5813   \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
5814   \onepageout\pagesofar
5815   \unvbox255
5816   \penalty\outputpenalty
5817 }
5818 %
5819 % Re-output the contents of the output page -- any previous material,
5820 % followed by the two boxes we just split, in box0 and box2.
5821 \def\pagesofar{%
5822   \unvbox\partialpage
5823   %
5824   \hsize = \doublecolumnhsize
5825   \wd0=\hsize \wd2=\hsize
5826   \vbox{%
5827     \vskip\doublecolumntopgap
5828     \hbox to\txipagewidth{\box0\hfil\box2}}%
5829 }
5830
5831
5832 % Finished with with double columns.
5833 \def\enddoublecolumns{%
5834   % The following penalty ensures that the page builder is exercised
5835   % _before_ we change the output routine.  This is necessary in the
5836   % following situation:
5837   %
5838   % The last section of the index consists only of a single entry.
5839   % Before this section, \pagetotal is less than \pagegoal, so no
5840   % break occurs before the last section starts.  However, the last
5841   % section, consisting of \initial and the single \entry, does not
5842   % fit on the page and has to be broken off.  Without the following
5843   % penalty the page builder will not be exercised until \eject
5844   % below, and by that time we'll already have changed the output
5845   % routine to the \balancecolumns version, so the next-to-last
5846   % double-column page will be processed with \balancecolumns, which
5847   % is wrong:  The two columns will go to the main vertical list, with
5848   % the broken-off section in the recent contributions.  As soon as
5849   % the output routine finishes, TeX starts reconsidering the page
5850   % break.  The two columns and the broken-off section both fit on the
5851   % page, because the two columns now take up only half of the page
5852   % goal.  When TeX sees \eject from below which follows the final
5853   % section, it invokes the new output routine that we've set after
5854   % \balancecolumns below; \onepageout will try to fit the two columns
5855   % and the final section into the vbox of \txipageheight (see
5856   % \pagebody), causing an overfull box.
5857   %
5858   % Note that glue won't work here, because glue does not exercise the
5859   % page builder, unlike penalties (see The TeXbook, pp. 280-281).
5860   \penalty0
5861   %
5862   \output = {%
5863     % Split the last of the double-column material.
5864     \savemarks
5865     \balancecolumns
5866     %
5867     % Having called \balancecolumns once, we do not
5868     % want to call it again.  Therefore, reset \output to its normal
5869     % definition right away.
5870     \global\output = {\onepageout{\pagecontents\PAGE}}%
5871   }%
5872   \eject
5873   \endgroup % started in \begindoublecolumns
5874   \restoremarks
5875   % Leave the double-column material on the current page, no automatic
5876   % page break.
5877   \box\balancedcolumns
5878   %
5879   % \pagegoal was set to the doubled \vsize above, since we restarted
5880   % the current page.  We're now back to normal single-column
5881   % typesetting, so reset \pagegoal to the normal \vsize (after the
5882   % \endgroup where \vsize got restored).
5883   \pagegoal = \vsize
5884 }
5885 \newbox\balancedcolumns
5886 \setbox\balancedcolumns=\vbox{shouldnt see this}%
5887 %
5888 % Only called for the last of the double column material.  \doublecolumnout 
5889 % does the others.
5890 \def\balancecolumns{%
5891   \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120.
5892   \dimen@ = \ht0
5893   \advance\dimen@ by \topskip
5894   \advance\dimen@ by-\baselineskip
5895   \ifdim\dimen@<14\baselineskip
5896     % Don't split a short final column in two.
5897     \setbox2=\vbox{}%
5898   \else
5899     \divide\dimen@ by 2 % target to split to
5900     \dimen@ii = \dimen@
5901     \splittopskip = \topskip
5902     % Loop until the second column is no higher than the first
5903     {%
5904       \vbadness = 10000
5905       \loop
5906         \global\setbox3 = \copy0
5907         \global\setbox1 = \vsplit3 to \dimen@
5908         % Remove glue from bottom of first column to
5909         % make sure it is higher than the second.
5910         \global\setbox1 = \vbox{\unvbox1\unpenalty\unskip}%
5911       \ifdim\ht3>\ht1
5912         \global\advance\dimen@ by 1pt
5913       \repeat
5914     }%
5915     \multiply\dimen@ii by 4
5916     \divide\dimen@ii by 5
5917     \ifdim\ht3<\dimen@ii
5918       % Column heights are too different, so don't make their bottoms
5919       % flush with each other.  The glue at the end of the second column
5920       % allows a second column to stretch, reducing the difference in
5921       % height between the two.
5922       \setbox0=\vbox to\dimen@{\unvbox1\vfill}%
5923       \setbox2=\vbox to\dimen@{\unvbox3\vskip 0pt plus 0.3\ht0}%
5924     \else
5925       \setbox0=\vbox to\dimen@{\unvbox1}%
5926       \setbox2=\vbox to\dimen@{\unvbox3}%
5927     \fi
5928   \fi
5929   %
5930   \global\setbox\balancedcolumns=\vbox{\pagesofar}%
5931 }
5932 \catcode`\@ = \other
5933
5934
5935 \message{sectioning,}
5936 % Chapters, sections, etc.
5937
5938 % Let's start with @part.
5939 \outer\parseargdef\part{\partzzz{#1}}
5940 \def\partzzz#1{%
5941   \chapoddpage
5942   \null
5943   \vskip.3\vsize  % move it down on the page a bit
5944   \begingroup
5945     \noindent \titlefonts\rmisbold #1\par % the text
5946     \let\lastnode=\empty      % no node to associate with
5947     \writetocentry{part}{#1}{}% but put it in the toc
5948     \headingsoff              % no headline or footline on the part page
5949     % This outputs a mark at the end of the page that clears \thischapter
5950     % and \thissection, as is done in \startcontents.
5951     \let\pchapsepmacro\relax
5952     \chapmacro{}{Yomitfromtoc}{}%
5953     \chapoddpage
5954   \endgroup
5955 }
5956
5957 % \unnumberedno is an oxymoron.  But we count the unnumbered
5958 % sections so that we can refer to them unambiguously in the pdf
5959 % outlines by their "section number".  We avoid collisions with chapter
5960 % numbers by starting them at 10000.  (If a document ever has 10000
5961 % chapters, we're in trouble anyway, I'm sure.)
5962 \newcount\unnumberedno \unnumberedno = 10000
5963 \newcount\chapno
5964 \newcount\secno        \secno=0
5965 \newcount\subsecno     \subsecno=0
5966 \newcount\subsubsecno  \subsubsecno=0
5967
5968 % This counter is funny since it counts through charcodes of letters A, B, ...
5969 \newcount\appendixno  \appendixno = `\@
5970 %
5971 % \def\appendixletter{\char\the\appendixno}
5972 % We do the following ugly conditional instead of the above simple
5973 % construct for the sake of pdftex, which needs the actual
5974 % letter in the expansion, not just typeset.
5975 %
5976 \def\appendixletter{%
5977   \ifnum\appendixno=`A A%
5978   \else\ifnum\appendixno=`B B%
5979   \else\ifnum\appendixno=`C C%
5980   \else\ifnum\appendixno=`D D%
5981   \else\ifnum\appendixno=`E E%
5982   \else\ifnum\appendixno=`F F%
5983   \else\ifnum\appendixno=`G G%
5984   \else\ifnum\appendixno=`H H%
5985   \else\ifnum\appendixno=`I I%
5986   \else\ifnum\appendixno=`J J%
5987   \else\ifnum\appendixno=`K K%
5988   \else\ifnum\appendixno=`L L%
5989   \else\ifnum\appendixno=`M M%
5990   \else\ifnum\appendixno=`N N%
5991   \else\ifnum\appendixno=`O O%
5992   \else\ifnum\appendixno=`P P%
5993   \else\ifnum\appendixno=`Q Q%
5994   \else\ifnum\appendixno=`R R%
5995   \else\ifnum\appendixno=`S S%
5996   \else\ifnum\appendixno=`T T%
5997   \else\ifnum\appendixno=`U U%
5998   \else\ifnum\appendixno=`V V%
5999   \else\ifnum\appendixno=`W W%
6000   \else\ifnum\appendixno=`X X%
6001   \else\ifnum\appendixno=`Y Y%
6002   \else\ifnum\appendixno=`Z Z%
6003   % The \the is necessary, despite appearances, because \appendixletter is
6004   % expanded while writing the .toc file.  \char\appendixno is not
6005   % expandable, thus it is written literally, thus all appendixes come out
6006   % with the same letter (or @) in the toc without it.
6007   \else\char\the\appendixno
6008   \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
6009   \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
6010
6011 % Each @chapter defines these (using marks) as the number+name, number
6012 % and name of the chapter.  Page headings and footings can use
6013 % these.  @section does likewise.
6014 \def\thischapter{}
6015 \def\thischapternum{}
6016 \def\thischaptername{}
6017 \def\thissection{}
6018 \def\thissectionnum{}
6019 \def\thissectionname{}
6020
6021 \newcount\absseclevel % used to calculate proper heading level
6022 \newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count
6023
6024 % @raisesections: treat @section as chapter, @subsection as section, etc.
6025 \def\raisesections{\global\advance\secbase by -1}
6026 \let\up=\raisesections % original BFox name
6027
6028 % @lowersections: treat @chapter as section, @section as subsection, etc.
6029 \def\lowersections{\global\advance\secbase by 1}
6030 \let\down=\lowersections % original BFox name
6031
6032 % we only have subsub.
6033 \chardef\maxseclevel = 3
6034 %
6035 % A numbered section within an unnumbered changes to unnumbered too.
6036 % To achieve this, remember the "biggest" unnum. sec. we are currently in:
6037 \chardef\unnlevel = \maxseclevel
6038 %
6039 % Trace whether the current chapter is an appendix or not:
6040 % \chapheadtype is "N" or "A", unnumbered chapters are ignored.
6041 \def\chapheadtype{N}
6042
6043 % Choose a heading macro
6044 % #1 is heading type
6045 % #2 is heading level
6046 % #3 is text for heading
6047 \def\genhead#1#2#3{%
6048   % Compute the abs. sec. level:
6049   \absseclevel=#2
6050   \advance\absseclevel by \secbase
6051   % Make sure \absseclevel doesn't fall outside the range:
6052   \ifnum \absseclevel < 0
6053     \absseclevel = 0
6054   \else
6055     \ifnum \absseclevel > 3
6056       \absseclevel = 3
6057     \fi
6058   \fi
6059   % The heading type:
6060   \def\headtype{#1}%
6061   \if \headtype U%
6062     \ifnum \absseclevel < \unnlevel
6063       \chardef\unnlevel = \absseclevel
6064     \fi
6065   \else
6066     % Check for appendix sections:
6067     \ifnum \absseclevel = 0
6068       \edef\chapheadtype{\headtype}%
6069     \else
6070       \if \headtype A\if \chapheadtype N%
6071         \errmessage{@appendix... within a non-appendix chapter}%
6072       \fi\fi
6073     \fi
6074     % Check for numbered within unnumbered:
6075     \ifnum \absseclevel > \unnlevel
6076       \def\headtype{U}%
6077     \else
6078       \chardef\unnlevel = 3
6079     \fi
6080   \fi
6081   % Now print the heading:
6082   \if \headtype U%
6083     \ifcase\absseclevel
6084         \unnumberedzzz{#3}%
6085     \or \unnumberedseczzz{#3}%
6086     \or \unnumberedsubseczzz{#3}%
6087     \or \unnumberedsubsubseczzz{#3}%
6088     \fi
6089   \else
6090     \if \headtype A%
6091       \ifcase\absseclevel
6092           \appendixzzz{#3}%
6093       \or \appendixsectionzzz{#3}%
6094       \or \appendixsubseczzz{#3}%
6095       \or \appendixsubsubseczzz{#3}%
6096       \fi
6097     \else
6098       \ifcase\absseclevel
6099           \chapterzzz{#3}%
6100       \or \seczzz{#3}%
6101       \or \numberedsubseczzz{#3}%
6102       \or \numberedsubsubseczzz{#3}%
6103       \fi
6104     \fi
6105   \fi
6106   \suppressfirstparagraphindent
6107 }
6108
6109 % an interface:
6110 \def\numhead{\genhead N}
6111 \def\apphead{\genhead A}
6112 \def\unnmhead{\genhead U}
6113
6114 % @chapter, @appendix, @unnumbered.  Increment top-level counter, reset
6115 % all lower-level sectioning counters to zero.
6116 %
6117 % Also set \chaplevelprefix, which we prepend to @float sequence numbers
6118 % (e.g., figures), q.v.  By default (before any chapter), that is empty.
6119 \let\chaplevelprefix = \empty
6120 %
6121 \outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz
6122 \def\chapterzzz#1{%
6123   % section resetting is \global in case the chapter is in a group, such
6124   % as an @include file.
6125   \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6126     \global\advance\chapno by 1
6127   %
6128   % Used for \float.
6129   \gdef\chaplevelprefix{\the\chapno.}%
6130   \resetallfloatnos
6131   %
6132   % \putwordChapter can contain complex things in translations.
6133   \toks0=\expandafter{\putwordChapter}%
6134   \message{\the\toks0 \space \the\chapno}%
6135   %
6136   % Write the actual heading.
6137   \chapmacro{#1}{Ynumbered}{\the\chapno}%
6138   %
6139   % So @section and the like are numbered underneath this chapter.
6140   \global\let\section = \numberedsec
6141   \global\let\subsection = \numberedsubsec
6142   \global\let\subsubsection = \numberedsubsubsec
6143 }
6144
6145 \outer\parseargdef\appendix{\apphead0{#1}} % normally calls appendixzzz
6146 %
6147 \def\appendixzzz#1{%
6148   \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6149     \global\advance\appendixno by 1
6150   \gdef\chaplevelprefix{\appendixletter.}%
6151   \resetallfloatnos
6152   %
6153   % \putwordAppendix can contain complex things in translations.
6154   \toks0=\expandafter{\putwordAppendix}%
6155   \message{\the\toks0 \space \appendixletter}%
6156   %
6157   \chapmacro{#1}{Yappendix}{\appendixletter}%
6158   %
6159   \global\let\section = \appendixsec
6160   \global\let\subsection = \appendixsubsec
6161   \global\let\subsubsection = \appendixsubsubsec
6162 }
6163
6164 % normally unnmhead0 calls unnumberedzzz:
6165 \outer\parseargdef\unnumbered{\unnmhead0{#1}}
6166 \def\unnumberedzzz#1{%
6167   \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6168     \global\advance\unnumberedno by 1
6169   %
6170   % Since an unnumbered has no number, no prefix for figures.
6171   \global\let\chaplevelprefix = \empty
6172   \resetallfloatnos
6173   %
6174   % This used to be simply \message{#1}, but TeX fully expands the
6175   % argument to \message.  Therefore, if #1 contained @-commands, TeX
6176   % expanded them.  For example, in `@unnumbered The @cite{Book}', TeX
6177   % expanded @cite (which turns out to cause errors because \cite is meant
6178   % to be executed, not expanded).
6179   %
6180   % Anyway, we don't want the fully-expanded definition of @cite to appear
6181   % as a result of the \message, we just want `@cite' itself.  We use
6182   % \the<toks register> to achieve this: TeX expands \the<toks> only once,
6183   % simply yielding the contents of <toks register>.  (We also do this for
6184   % the toc entries.)
6185   \toks0 = {#1}%
6186   \message{(\the\toks0)}%
6187   %
6188   \chapmacro{#1}{Ynothing}{\the\unnumberedno}%
6189   %
6190   \global\let\section = \unnumberedsec
6191   \global\let\subsection = \unnumberedsubsec
6192   \global\let\subsubsection = \unnumberedsubsubsec
6193 }
6194
6195 % @centerchap is like @unnumbered, but the heading is centered.
6196 \outer\parseargdef\centerchap{%
6197   \let\centerparametersmaybe = \centerparameters
6198   \unnmhead0{#1}%
6199   \let\centerparametersmaybe = \relax
6200 }
6201
6202 % @top is like @unnumbered.
6203 \let\top\unnumbered
6204
6205 % Sections.
6206
6207 \outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
6208 \def\seczzz#1{%
6209   \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
6210   \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}%
6211 }
6212
6213 % normally calls appendixsectionzzz:
6214 \outer\parseargdef\appendixsection{\apphead1{#1}}
6215 \def\appendixsectionzzz#1{%
6216   \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
6217   \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}%
6218 }
6219 \let\appendixsec\appendixsection
6220
6221 % normally calls unnumberedseczzz:
6222 \outer\parseargdef\unnumberedsec{\unnmhead1{#1}}
6223 \def\unnumberedseczzz#1{%
6224   \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
6225   \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%
6226 }
6227
6228 % Subsections.
6229
6230 % normally calls numberedsubseczzz:
6231 \outer\parseargdef\numberedsubsec{\numhead2{#1}}
6232 \def\numberedsubseczzz#1{%
6233   \global\subsubsecno=0  \global\advance\subsecno by 1
6234   \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}%
6235 }
6236
6237 % normally calls appendixsubseczzz:
6238 \outer\parseargdef\appendixsubsec{\apphead2{#1}}
6239 \def\appendixsubseczzz#1{%
6240   \global\subsubsecno=0  \global\advance\subsecno by 1
6241   \sectionheading{#1}{subsec}{Yappendix}%
6242                  {\appendixletter.\the\secno.\the\subsecno}%
6243 }
6244
6245 % normally calls unnumberedsubseczzz:
6246 \outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}}
6247 \def\unnumberedsubseczzz#1{%
6248   \global\subsubsecno=0  \global\advance\subsecno by 1
6249   \sectionheading{#1}{subsec}{Ynothing}%
6250                  {\the\unnumberedno.\the\secno.\the\subsecno}%
6251 }
6252
6253 % Subsubsections.
6254
6255 % normally numberedsubsubseczzz:
6256 \outer\parseargdef\numberedsubsubsec{\numhead3{#1}}
6257 \def\numberedsubsubseczzz#1{%
6258   \global\advance\subsubsecno by 1
6259   \sectionheading{#1}{subsubsec}{Ynumbered}%
6260                  {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}%
6261 }
6262
6263 % normally appendixsubsubseczzz:
6264 \outer\parseargdef\appendixsubsubsec{\apphead3{#1}}
6265 \def\appendixsubsubseczzz#1{%
6266   \global\advance\subsubsecno by 1
6267   \sectionheading{#1}{subsubsec}{Yappendix}%
6268                  {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}%
6269 }
6270
6271 % normally unnumberedsubsubseczzz:
6272 \outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}}
6273 \def\unnumberedsubsubseczzz#1{%
6274   \global\advance\subsubsecno by 1
6275   \sectionheading{#1}{subsubsec}{Ynothing}%
6276                  {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}%
6277 }
6278
6279 % These macros control what the section commands do, according
6280 % to what kind of chapter we are in (ordinary, appendix, or unnumbered).
6281 % Define them by default for a numbered chapter.
6282 \let\section = \numberedsec
6283 \let\subsection = \numberedsubsec
6284 \let\subsubsection = \numberedsubsubsec
6285
6286 % Define @majorheading, @heading and @subheading
6287
6288 \def\majorheading{%
6289   {\advance\chapheadingskip by 10pt \chapbreak }%
6290   \parsearg\chapheadingzzz
6291 }
6292
6293 \def\chapheading{\chapbreak \parsearg\chapheadingzzz}
6294 \def\chapheadingzzz#1{%
6295   \vbox{\chapfonts \raggedtitlesettings #1\par}%
6296   \nobreak\bigskip \nobreak
6297   \suppressfirstparagraphindent
6298 }
6299
6300 % @heading, @subheading, @subsubheading.
6301 \parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{}
6302   \suppressfirstparagraphindent}
6303 \parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{}
6304   \suppressfirstparagraphindent}
6305 \parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{}
6306   \suppressfirstparagraphindent}
6307
6308 % These macros generate a chapter, section, etc. heading only
6309 % (including whitespace, linebreaking, etc. around it),
6310 % given all the information in convenient, parsed form.
6311
6312 % Args are the skip and penalty (usually negative)
6313 \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
6314
6315 % Parameter controlling skip before chapter headings (if needed)
6316 \newskip\chapheadingskip
6317
6318 % Define plain chapter starts, and page on/off switching for it.
6319 \def\chapbreak{\dobreak \chapheadingskip {-4000}}
6320
6321 % Start a new page
6322 \def\chappager{\par\vfill\supereject}
6323
6324 % \chapoddpage - start on an odd page for a new chapter
6325 % Because \domark is called before \chapoddpage, the filler page will
6326 % get the headings for the next chapter, which is wrong.  But we don't
6327 % care -- we just disable all headings on the filler page.
6328 \def\chapoddpage{%
6329   \chappager
6330   \ifodd\pageno \else
6331     \begingroup
6332       \headingsoff
6333       \null
6334       \chappager
6335     \endgroup
6336   \fi
6337 }
6338
6339 \parseargdef\setchapternewpage{\csname CHAPPAG#1\endcsname}
6340
6341 \def\CHAPPAGoff{%
6342 \global\let\contentsalignmacro = \chappager
6343 \global\let\pchapsepmacro=\chapbreak
6344 \global\let\pagealignmacro=\chappager}
6345
6346 \def\CHAPPAGon{%
6347 \global\let\contentsalignmacro = \chappager
6348 \global\let\pchapsepmacro=\chappager
6349 \global\let\pagealignmacro=\chappager
6350 \global\def\HEADINGSon{\HEADINGSsingle}}
6351
6352 \def\CHAPPAGodd{%
6353 \global\let\contentsalignmacro = \chapoddpage
6354 \global\let\pchapsepmacro=\chapoddpage
6355 \global\let\pagealignmacro=\chapoddpage
6356 \global\def\HEADINGSon{\HEADINGSdouble}}
6357
6358 \CHAPPAGon
6359
6360 % \chapmacro - Chapter opening.
6361 %
6362 % #1 is the text, #2 is the section type (Ynumbered, Ynothing,
6363 % Yappendix, Yomitfromtoc), #3 the chapter number.
6364 % Not used for @heading series.
6365 %
6366 % To test against our argument.
6367 \def\Ynothingkeyword{Ynothing}
6368 \def\Yappendixkeyword{Yappendix}
6369 \def\Yomitfromtockeyword{Yomitfromtoc}
6370 %
6371 \def\chapmacro#1#2#3{%
6372   \expandafter\ifx\thisenv\titlepage\else
6373     \checkenv{}% chapters, etc., should not start inside an environment.
6374   \fi
6375   % FIXME: \chapmacro is currently called from inside \titlepage when
6376   % \setcontentsaftertitlepage to print the "Table of Contents" heading, but
6377   % this should probably be done by \sectionheading with an option to print
6378   % in chapter size.
6379   %
6380   % Insert the first mark before the heading break (see notes for \domark).
6381   \let\prevchapterdefs=\lastchapterdefs
6382   \let\prevsectiondefs=\lastsectiondefs
6383   \gdef\lastsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}%
6384                         \gdef\thissection{}}%
6385   %
6386   \def\temptype{#2}%
6387   \ifx\temptype\Ynothingkeyword
6388     \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
6389                           \gdef\thischapter{\thischaptername}}%
6390   \else\ifx\temptype\Yomitfromtockeyword
6391     \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
6392                           \gdef\thischapter{}}%
6393   \else\ifx\temptype\Yappendixkeyword
6394     \toks0={#1}%
6395     \xdef\lastchapterdefs{%
6396       \gdef\noexpand\thischaptername{\the\toks0}%
6397       \gdef\noexpand\thischapternum{\appendixletter}%
6398       % \noexpand\putwordAppendix avoids expanding indigestible
6399       % commands in some of the translations.
6400       \gdef\noexpand\thischapter{\noexpand\putwordAppendix{}
6401                                  \noexpand\thischapternum:
6402                                  \noexpand\thischaptername}%
6403     }%
6404   \else
6405     \toks0={#1}%
6406     \xdef\lastchapterdefs{%
6407       \gdef\noexpand\thischaptername{\the\toks0}%
6408       \gdef\noexpand\thischapternum{\the\chapno}%
6409       % \noexpand\putwordChapter avoids expanding indigestible
6410       % commands in some of the translations.
6411       \gdef\noexpand\thischapter{\noexpand\putwordChapter{}
6412                                  \noexpand\thischapternum:
6413                                  \noexpand\thischaptername}%
6414     }%
6415   \fi\fi\fi
6416   %
6417   % Output the mark.  Pass it through \safewhatsit, to take care of
6418   % the preceding space.
6419   \safewhatsit\domark
6420   %
6421   % Insert the chapter heading break.
6422   \pchapsepmacro
6423   %
6424   % Now the second mark, after the heading break.  No break points
6425   % between here and the heading.
6426   \let\prevchapterdefs=\lastchapterdefs
6427   \let\prevsectiondefs=\lastsectiondefs
6428   \domark
6429   %
6430   {%
6431     \chapfonts \rmisbold
6432     \let\footnote=\errfootnoteheading % give better error message
6433     %
6434     % Have to define \lastsection before calling \donoderef, because the
6435     % xref code eventually uses it.  On the other hand, it has to be called
6436     % after \pchapsepmacro, or the headline will change too soon.
6437     \gdef\lastsection{#1}%
6438     %
6439     % Only insert the separating space if we have a chapter/appendix
6440     % number, and don't print the unnumbered ``number''.
6441     \ifx\temptype\Ynothingkeyword
6442       \setbox0 = \hbox{}%
6443       \def\toctype{unnchap}%
6444     \else\ifx\temptype\Yomitfromtockeyword
6445       \setbox0 = \hbox{}% contents like unnumbered, but no toc entry
6446       \def\toctype{omit}%
6447     \else\ifx\temptype\Yappendixkeyword
6448       \setbox0 = \hbox{\putwordAppendix{} #3\enspace}%
6449       \def\toctype{app}%
6450     \else
6451       \setbox0 = \hbox{#3\enspace}%
6452       \def\toctype{numchap}%
6453     \fi\fi\fi
6454     %
6455     % Write the toc entry for this chapter.  Must come before the
6456     % \donoderef, because we include the current node name in the toc
6457     % entry, and \donoderef resets it to empty.
6458     \writetocentry{\toctype}{#1}{#3}%
6459     %
6460     % For pdftex, we have to write out the node definition (aka, make
6461     % the pdfdest) after any page break, but before the actual text has
6462     % been typeset.  If the destination for the pdf outline is after the
6463     % text, then jumping from the outline may wind up with the text not
6464     % being visible, for instance under high magnification.
6465     \donoderef{#2}%
6466     %
6467     % Typeset the actual heading.
6468     \nobreak % Avoid page breaks at the interline glue.
6469     \vbox{\raggedtitlesettings \hangindent=\wd0 \centerparametersmaybe
6470           \unhbox0 #1\par}%
6471   }%
6472   \nobreak\bigskip % no page break after a chapter title
6473   \nobreak
6474 }
6475
6476 % @centerchap -- centered and unnumbered.
6477 \let\centerparametersmaybe = \relax
6478 \def\centerparameters{%
6479   \advance\rightskip by 3\rightskip
6480   \leftskip = \rightskip
6481   \parfillskip = 0pt
6482 }
6483
6484
6485 % Section titles.  These macros combine the section number parts and
6486 % call the generic \sectionheading to do the printing.
6487 %
6488 \newskip\secheadingskip
6489 \def\secheadingbreak{\dobreak \secheadingskip{-1000}}
6490
6491 % Subsection titles.
6492 \newskip\subsecheadingskip
6493 \def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}}
6494
6495 % Subsubsection titles.
6496 \def\subsubsecheadingskip{\subsecheadingskip}
6497 \def\subsubsecheadingbreak{\subsecheadingbreak}
6498
6499
6500 % Print any size, any type, section title.
6501 %
6502 % #1 is the text of the title,
6503 % #2 is the section level (sec/subsec/subsubsec),
6504 % #3 is the section type (Ynumbered, Ynothing, Yappendix, Yomitfromtoc),
6505 % #4 is the section number.
6506 %
6507 \def\seckeyword{sec}
6508 %
6509 \def\sectionheading#1#2#3#4{%
6510   {%
6511     \def\sectionlevel{#2}%
6512     \def\temptype{#3}%
6513     %
6514     % It is ok for the @heading series commands to appear inside an
6515     % environment (it's been historically allowed, though the logic is
6516     % dubious), but not the others.
6517     \ifx\temptype\Yomitfromtockeyword\else
6518       \checkenv{}% non-@*heading should not be in an environment.
6519     \fi
6520     \let\footnote=\errfootnoteheading
6521     %
6522     % Switch to the right set of fonts.
6523     \csname #2fonts\endcsname \rmisbold
6524     %
6525     % Insert first mark before the heading break (see notes for \domark).
6526     \let\prevsectiondefs=\lastsectiondefs
6527     \ifx\temptype\Ynothingkeyword
6528       \ifx\sectionlevel\seckeyword
6529         \gdef\lastsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}%
6530                               \gdef\thissection{\thissectionname}}%
6531       \fi
6532     \else\ifx\temptype\Yomitfromtockeyword
6533       % Don't redefine \thissection.
6534     \else\ifx\temptype\Yappendixkeyword
6535       \ifx\sectionlevel\seckeyword
6536         \toks0={#1}%
6537         \xdef\lastsectiondefs{%
6538           \gdef\noexpand\thissectionname{\the\toks0}%
6539           \gdef\noexpand\thissectionnum{#4}%
6540           % \noexpand\putwordSection avoids expanding indigestible
6541           % commands in some of the translations.
6542           \gdef\noexpand\thissection{\noexpand\putwordSection{}
6543                                      \noexpand\thissectionnum:
6544                                      \noexpand\thissectionname}%
6545         }%
6546       \fi
6547     \else
6548       \ifx\sectionlevel\seckeyword
6549         \toks0={#1}%
6550         \xdef\lastsectiondefs{%
6551           \gdef\noexpand\thissectionname{\the\toks0}%
6552           \gdef\noexpand\thissectionnum{#4}%
6553           % \noexpand\putwordSection avoids expanding indigestible
6554           % commands in some of the translations.
6555           \gdef\noexpand\thissection{\noexpand\putwordSection{}
6556                                      \noexpand\thissectionnum:
6557                                      \noexpand\thissectionname}%
6558         }%
6559       \fi
6560     \fi\fi\fi
6561     %
6562     % Go into vertical mode.  Usually we'll already be there, but we
6563     % don't want the following whatsit to end up in a preceding paragraph
6564     % if the document didn't happen to have a blank line.
6565     \par
6566     %
6567     % Output the mark.  Pass it through \safewhatsit, to take care of
6568     % the preceding space.
6569     \safewhatsit\domark
6570     %
6571     % Insert space above the heading.
6572     \csname #2headingbreak\endcsname
6573     %
6574     % Now the second mark, after the heading break.  No break points
6575     % between here and the heading.
6576     \global\let\prevsectiondefs=\lastsectiondefs
6577     \domark
6578     %
6579     % Only insert the space after the number if we have a section number.
6580     \ifx\temptype\Ynothingkeyword
6581       \setbox0 = \hbox{}%
6582       \def\toctype{unn}%
6583       \gdef\lastsection{#1}%
6584     \else\ifx\temptype\Yomitfromtockeyword
6585       % for @headings -- no section number, don't include in toc,
6586       % and don't redefine \lastsection.
6587       \setbox0 = \hbox{}%
6588       \def\toctype{omit}%
6589       \let\sectionlevel=\empty
6590     \else\ifx\temptype\Yappendixkeyword
6591       \setbox0 = \hbox{#4\enspace}%
6592       \def\toctype{app}%
6593       \gdef\lastsection{#1}%
6594     \else
6595       \setbox0 = \hbox{#4\enspace}%
6596       \def\toctype{num}%
6597       \gdef\lastsection{#1}%
6598     \fi\fi\fi
6599     %
6600     % Write the toc entry (before \donoderef).  See comments in \chapmacro.
6601     \writetocentry{\toctype\sectionlevel}{#1}{#4}%
6602     %
6603     % Write the node reference (= pdf destination for pdftex).
6604     % Again, see comments in \chapmacro.
6605     \donoderef{#3}%
6606     %
6607     % Interline glue will be inserted when the vbox is completed.
6608     % That glue will be a valid breakpoint for the page, since it'll be
6609     % preceded by a whatsit (usually from the \donoderef, or from the
6610     % \writetocentry if there was no node).  We don't want to allow that
6611     % break, since then the whatsits could end up on page n while the
6612     % section is on page n+1, thus toc/etc. are wrong.  Debian bug 276000.
6613     \nobreak
6614     %
6615     % Output the actual section heading.
6616     \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright
6617           \hangindent=\wd0  % zero if no section number
6618           \unhbox0 #1}%
6619   }%
6620   % Add extra space after the heading -- half of whatever came above it.
6621   % Don't allow stretch, though.
6622   \kern .5 \csname #2headingskip\endcsname
6623   %
6624   % Do not let the kern be a potential breakpoint, as it would be if it
6625   % was followed by glue.
6626   \nobreak
6627   %
6628   % We'll almost certainly start a paragraph next, so don't let that
6629   % glue accumulate.  (Not a breakpoint because it's preceded by a
6630   % discardable item.)  However, when a paragraph is not started next
6631   % (\startdefun, \cartouche, \center, etc.), this needs to be wiped out
6632   % or the negative glue will cause weirdly wrong output, typically
6633   % obscuring the section heading with something else.
6634   \vskip-\parskip
6635   %
6636   % This is so the last item on the main vertical list is a known
6637   % \penalty > 10000, so \startdefun, etc., can recognize the situation
6638   % and do the needful.
6639   \penalty 10001
6640 }
6641
6642
6643 \message{toc,}
6644 % Table of contents.
6645 \newwrite\tocfile
6646
6647 % Write an entry to the toc file, opening it if necessary.
6648 % Called from @chapter, etc.
6649 %
6650 % Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno}
6651 % We append the current node name (if any) and page number as additional
6652 % arguments for the \{chap,sec,...}entry macros which will eventually
6653 % read this.  The node name is used in the pdf outlines as the
6654 % destination to jump to.
6655 %
6656 % We open the .toc file for writing here instead of at @setfilename (or
6657 % any other fixed time) so that @contents can be anywhere in the document.
6658 % But if #1 is `omit', then we don't do anything.  This is used for the
6659 % table of contents chapter openings themselves.
6660 %
6661 \newif\iftocfileopened
6662 \def\omitkeyword{omit}%
6663 %
6664 \def\writetocentry#1#2#3{%
6665   \edef\writetoctype{#1}%
6666   \ifx\writetoctype\omitkeyword \else
6667     \iftocfileopened\else
6668       \immediate\openout\tocfile = \jobname.toc
6669       \global\tocfileopenedtrue
6670     \fi
6671     %
6672     \iflinks
6673       {\atdummies
6674        \edef\temp{%
6675          \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}%
6676        \temp
6677       }%
6678     \fi
6679   \fi
6680   %
6681   % Tell \shipout to create a pdf destination on each page, if we're
6682   % writing pdf.  These are used in the table of contents.  We can't
6683   % just write one on every page because the title pages are numbered
6684   % 1 and 2 (the page numbers aren't printed), and so are the first
6685   % two pages of the document.  Thus, we'd have two destinations named
6686   % `1', and two named `2'.
6687   \ifpdf
6688     \global\pdfmakepagedesttrue
6689   \else
6690     \ifx\XeTeXrevision\thisisundefined
6691     \else
6692       \global\pdfmakepagedesttrue
6693     \fi
6694   \fi
6695 }
6696
6697
6698 % These characters do not print properly in the Computer Modern roman
6699 % fonts, so we must take special care.  This is more or less redundant
6700 % with the Texinfo input format setup at the end of this file.
6701 %
6702 \def\activecatcodes{%
6703   \catcode`\"=\active
6704   \catcode`\$=\active
6705   \catcode`\<=\active
6706   \catcode`\>=\active
6707   \catcode`\\=\active
6708   \catcode`\^=\active
6709   \catcode`\_=\active
6710   \catcode`\|=\active
6711   \catcode`\~=\active
6712 }
6713
6714
6715 % Read the toc file, which is essentially Texinfo input.
6716 \def\readtocfile{%
6717   \setupdatafile
6718   \activecatcodes
6719   \input \tocreadfilename
6720 }
6721
6722 \newskip\contentsrightmargin \contentsrightmargin=1in
6723 \newcount\savepageno
6724 \newcount\lastnegativepageno \lastnegativepageno = -1
6725
6726 % Prepare to read what we've written to \tocfile.
6727 %
6728 \def\startcontents#1{%
6729   % If @setchapternewpage on, and @headings double, the contents should
6730   % start on an odd page, unlike chapters.  Thus, we maintain
6731   % \contentsalignmacro in parallel with \pagealignmacro.
6732   % From: Torbjorn Granlund <tege@matematik.su.se>
6733   \contentsalignmacro
6734   \immediate\closeout\tocfile
6735   %
6736   % Don't need to put `Contents' or `Short Contents' in the headline.
6737   % It is abundantly clear what they are.
6738   \chapmacro{#1}{Yomitfromtoc}{}%
6739   %
6740   \savepageno = \pageno
6741   \begingroup                  % Set up to handle contents files properly.
6742     \raggedbottom              % Worry more about breakpoints than the bottom.
6743     \entryrightmargin=\contentsrightmargin % Don't use the full line length.
6744     %
6745     % Roman numerals for page numbers.
6746     \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
6747 }
6748
6749 % redefined for the two-volume lispref.  We always output on
6750 % \jobname.toc even if this is redefined.
6751 %
6752 \def\tocreadfilename{\jobname.toc}
6753
6754 % Normal (long) toc.
6755 %
6756 \def\contents{%
6757   \startcontents{\putwordTOC}%
6758     \openin 1 \tocreadfilename\space
6759     \ifeof 1 \else
6760       \readtocfile
6761     \fi
6762     \vfill \eject
6763     \contentsalignmacro % in case @setchapternewpage odd is in effect
6764     \ifeof 1 \else
6765       \pdfmakeoutlines
6766     \fi
6767     \closein 1
6768   \endgroup
6769   \lastnegativepageno = \pageno
6770   \global\pageno = \savepageno
6771 }
6772
6773 % And just the chapters.
6774 \def\summarycontents{%
6775   \startcontents{\putwordShortTOC}%
6776     %
6777     \let\partentry = \shortpartentry
6778     \let\numchapentry = \shortchapentry
6779     \let\appentry = \shortchapentry
6780     \let\unnchapentry = \shortunnchapentry
6781     % We want a true roman here for the page numbers.
6782     \secfonts
6783     \let\rm=\shortcontrm \let\bf=\shortcontbf
6784     \let\sl=\shortcontsl \let\tt=\shortconttt
6785     \rm
6786     \hyphenpenalty = 10000
6787     \advance\baselineskip by 1pt % Open it up a little.
6788     \def\numsecentry##1##2##3##4{}
6789     \let\appsecentry = \numsecentry
6790     \let\unnsecentry = \numsecentry
6791     \let\numsubsecentry = \numsecentry
6792     \let\appsubsecentry = \numsecentry
6793     \let\unnsubsecentry = \numsecentry
6794     \let\numsubsubsecentry = \numsecentry
6795     \let\appsubsubsecentry = \numsecentry
6796     \let\unnsubsubsecentry = \numsecentry
6797     \openin 1 \tocreadfilename\space
6798     \ifeof 1 \else
6799       \readtocfile
6800     \fi
6801     \closein 1
6802     \vfill \eject
6803     \contentsalignmacro % in case @setchapternewpage odd is in effect
6804   \endgroup
6805   \lastnegativepageno = \pageno
6806   \global\pageno = \savepageno
6807 }
6808 \let\shortcontents = \summarycontents
6809
6810 % Typeset the label for a chapter or appendix for the short contents.
6811 % The arg is, e.g., `A' for an appendix, or `3' for a chapter.
6812 %
6813 \def\shortchaplabel#1{%
6814   % This space should be enough, since a single number is .5em, and the
6815   % widest letter (M) is 1em, at least in the Computer Modern fonts.
6816   % But use \hss just in case.
6817   % (This space doesn't include the extra space that gets added after
6818   % the label; that gets put in by \shortchapentry above.)
6819   %
6820   % We'd like to right-justify chapter numbers, but that looks strange
6821   % with appendix letters.  And right-justifying numbers and
6822   % left-justifying letters looks strange when there is less than 10
6823   % chapters.  Have to read the whole toc once to know how many chapters
6824   % there are before deciding ...
6825   \hbox to 1em{#1\hss}%
6826 }
6827
6828 % These macros generate individual entries in the table of contents.
6829 % The first argument is the chapter or section name.
6830 % The last argument is the page number.
6831 % The arguments in between are the chapter number, section number, ...
6832
6833 % Parts, in the main contents.  Replace the part number, which doesn't
6834 % exist, with an empty box.  Let's hope all the numbers have the same width.
6835 % Also ignore the page number, which is conventionally not printed.
6836 \def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}}
6837 \def\partentry#1#2#3#4{\dochapentry{\numeralbox\labelspace#1}{}}
6838 %
6839 % Parts, in the short toc.
6840 \def\shortpartentry#1#2#3#4{%
6841   \penalty-300
6842   \vskip.5\baselineskip plus.15\baselineskip minus.1\baselineskip
6843   \shortchapentry{{\bf #1}}{\numeralbox}{}{}%
6844 }
6845
6846 % Chapters, in the main contents.
6847 \def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}}
6848
6849 % Chapters, in the short toc.
6850 % See comments in \dochapentry re vbox and related settings.
6851 \def\shortchapentry#1#2#3#4{%
6852   \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}%
6853 }
6854
6855 % Appendices, in the main contents.
6856 % Need the word Appendix, and a fixed-size box.
6857 %
6858 \def\appendixbox#1{%
6859   % We use M since it's probably the widest letter.
6860   \setbox0 = \hbox{\putwordAppendix{} M}%
6861   \hbox to \wd0{\putwordAppendix{} #1\hss}}
6862 %
6863 \def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\hskip.7em#1}{#4}}
6864
6865 % Unnumbered chapters.
6866 \def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}}
6867 \def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}}
6868
6869 % Sections.
6870 \def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}}
6871 \let\appsecentry=\numsecentry
6872 \def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}}
6873
6874 % Subsections.
6875 \def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}}
6876 \let\appsubsecentry=\numsubsecentry
6877 \def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}}
6878
6879 % And subsubsections.
6880 \def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}}
6881 \let\appsubsubsecentry=\numsubsubsecentry
6882 \def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}}
6883
6884 % This parameter controls the indentation of the various levels.
6885 % Same as \defaultparindent.
6886 \newdimen\tocindent \tocindent = 15pt
6887
6888 % Now for the actual typesetting. In all these, #1 is the text and #2 is the
6889 % page number.
6890 %
6891 % If the toc has to be broken over pages, we want it to be at chapters
6892 % if at all possible; hence the \penalty.
6893 \def\dochapentry#1#2{%
6894    \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
6895    \begingroup
6896      % Move the page numbers slightly to the right
6897      \advance\entryrightmargin by -0.05em
6898      \chapentryfonts
6899      \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6900    \endgroup
6901    \nobreak\vskip .25\baselineskip plus.1\baselineskip
6902 }
6903
6904 \def\dosecentry#1#2{\begingroup
6905   \secentryfonts \leftskip=\tocindent
6906   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6907 \endgroup}
6908
6909 \def\dosubsecentry#1#2{\begingroup
6910   \subsecentryfonts \leftskip=2\tocindent
6911   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6912 \endgroup}
6913
6914 \def\dosubsubsecentry#1#2{\begingroup
6915   \subsubsecentryfonts \leftskip=3\tocindent
6916   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6917 \endgroup}
6918
6919 % We use the same \entry macro as for the index entries.
6920 \let\tocentry = \entry
6921
6922 % Space between chapter (or whatever) number and the title.
6923 \def\labelspace{\hskip1em \relax}
6924
6925 \def\dopageno#1{{\rm #1}}
6926 \def\doshortpageno#1{{\rm #1}}
6927
6928 \def\chapentryfonts{\secfonts \rm}
6929 \def\secentryfonts{\textfonts}
6930 \def\subsecentryfonts{\textfonts}
6931 \def\subsubsecentryfonts{\textfonts}
6932
6933
6934 \message{environments,}
6935 % @foo ... @end foo.
6936
6937 % @tex ... @end tex    escapes into raw TeX temporarily.
6938 % One exception: @ is still an escape character, so that @end tex works.
6939 % But \@ or @@ will get a plain @ character.
6940
6941 \envdef\tex{%
6942   \setupmarkupstyle{tex}%
6943   \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
6944   \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
6945   \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
6946   \catcode `\%=14
6947   \catcode `\+=\other
6948   \catcode `\"=\other
6949   \catcode `\|=\other
6950   \catcode `\<=\other
6951   \catcode `\>=\other
6952   \catcode `\`=\other
6953   \catcode `\'=\other
6954   %
6955   % ' is active in math mode (mathcode"8000).  So reset it, and all our
6956   % other math active characters (just in case), to plain's definitions.
6957   \mathactive
6958   %
6959   % Inverse of the list at the beginning of the file.
6960   \let\b=\ptexb
6961   \let\bullet=\ptexbullet
6962   \let\c=\ptexc
6963   \let\,=\ptexcomma
6964   \let\.=\ptexdot
6965   \let\dots=\ptexdots
6966   \let\equiv=\ptexequiv
6967   \let\!=\ptexexclam
6968   \let\i=\ptexi
6969   \let\indent=\ptexindent
6970   \let\noindent=\ptexnoindent
6971   \let\{=\ptexlbrace
6972   \let\+=\tabalign
6973   \let\}=\ptexrbrace
6974   \let\/=\ptexslash
6975   \let\sp=\ptexsp
6976   \let\*=\ptexstar
6977   %\let\sup=\ptexsup % do not redefine, we want @sup to work in math mode
6978   \let\t=\ptext
6979   \expandafter \let\csname top\endcsname=\ptextop  % we've made it outer
6980   \let\frenchspacing=\plainfrenchspacing
6981   %
6982   \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
6983   \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
6984   \def\@{@}%
6985 }
6986 % There is no need to define \Etex.
6987
6988 % Define @lisp ... @end lisp.
6989 % @lisp environment forms a group so it can rebind things,
6990 % including the definition of @end lisp (which normally is erroneous).
6991
6992 % Amount to narrow the margins by for @lisp.
6993 \newskip\lispnarrowing \lispnarrowing=0.4in
6994
6995 % This is the definition that ^^M gets inside @lisp, @example, and other
6996 % such environments.  \null is better than a space, since it doesn't
6997 % have any width.
6998 \def\lisppar{\null\endgraf}
6999
7000 % This space is always present above and below environments.
7001 \newskip\envskipamount \envskipamount = 0pt
7002
7003 % Make spacing and below environment symmetrical.  We use \parskip here
7004 % to help in doing that, since in @example-like environments \parskip
7005 % is reset to zero; thus the \afterenvbreak inserts no space -- but the
7006 % start of the next paragraph will insert \parskip.
7007 %
7008 \def\aboveenvbreak{{%
7009   % =10000 instead of <10000 because of a special case in \itemzzz and
7010   % \sectionheading, q.v.
7011   \ifnum \lastpenalty=10000 \else
7012     \advance\envskipamount by \parskip
7013     \endgraf
7014     \ifdim\lastskip<\envskipamount
7015       \removelastskip
7016       \ifnum\lastpenalty<10000
7017         % Penalize breaking before the environment, because preceding text
7018         % often leads into it.
7019         \penalty100
7020       \fi
7021       \vskip\envskipamount
7022     \fi
7023   \fi
7024 }}
7025
7026 \def\afterenvbreak{{%
7027   % =10000 instead of <10000 because of a special case in \itemzzz and
7028   % \sectionheading, q.v.
7029   \ifnum \lastpenalty=10000 \else
7030     \advance\envskipamount by \parskip
7031     \endgraf
7032     \ifdim\lastskip<\envskipamount
7033       \removelastskip
7034       % it's not a good place to break if the last penalty was \nobreak
7035       % or better ...
7036       \ifnum\lastpenalty<10000 \penalty-50 \fi
7037       \vskip\envskipamount
7038     \fi
7039   \fi
7040 }}
7041
7042 % \nonarrowing is a flag.  If "set", @lisp etc don't narrow margins; it will
7043 % also clear it, so that its embedded environments do the narrowing again.
7044 \let\nonarrowing=\relax
7045
7046 % @cartouche ... @end cartouche: draw rectangle w/rounded corners around
7047 % environment contents.
7048 \font\circle=lcircle10
7049 \newdimen\circthick
7050 \newdimen\cartouter\newdimen\cartinner
7051 \newskip\normbskip\newskip\normpskip\newskip\normlskip
7052 \circthick=\fontdimen8\circle
7053 %
7054 \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
7055 \def\ctr{{\hskip 6pt\circle\char'010}}
7056 \def\cbl{{\circle\char'012\hskip -6pt}}
7057 \def\cbr{{\hskip 6pt\circle\char'011}}
7058 \def\carttop{\hbox to \cartouter{\hskip\lskip
7059         \ctl\leaders\hrule height\circthick\hfil\ctr
7060         \hskip\rskip}}
7061 \def\cartbot{\hbox to \cartouter{\hskip\lskip
7062         \cbl\leaders\hrule height\circthick\hfil\cbr
7063         \hskip\rskip}}
7064 %
7065 \newskip\lskip\newskip\rskip
7066
7067 \envdef\cartouche{%
7068   \ifhmode\par\fi  % can't be in the midst of a paragraph.
7069   \startsavinginserts
7070   \lskip=\leftskip \rskip=\rightskip
7071   \leftskip=0pt\rightskip=0pt % we want these *outside*.
7072   \cartinner=\hsize \advance\cartinner by-\lskip
7073   \advance\cartinner by-\rskip
7074   \cartouter=\hsize
7075   \advance\cartouter by 18.4pt  % allow for 3pt kerns on either
7076                                 % side, and for 6pt waste from
7077                                 % each corner char, and rule thickness
7078   \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
7079   %
7080   % If this cartouche directly follows a sectioning command, we need the
7081   % \parskip glue (backspaced over by default) or the cartouche can
7082   % collide with the section heading.
7083   \ifnum\lastpenalty>10000 \vskip\parskip \penalty\lastpenalty \fi
7084   %
7085   \setbox\groupbox=\vbox\bgroup
7086       \baselineskip=0pt\parskip=0pt\lineskip=0pt
7087       \carttop
7088       \hbox\bgroup
7089           \hskip\lskip
7090           \vrule\kern3pt
7091           \vbox\bgroup
7092               \kern3pt
7093               \hsize=\cartinner
7094               \baselineskip=\normbskip
7095               \lineskip=\normlskip
7096               \parskip=\normpskip
7097               \vskip -\parskip
7098               \comment % For explanation, see the end of def\group.
7099 }
7100 \def\Ecartouche{%
7101               \ifhmode\par\fi
7102               \kern3pt
7103           \egroup
7104           \kern3pt\vrule
7105           \hskip\rskip
7106       \egroup
7107       \cartbot
7108   \egroup
7109   \addgroupbox
7110   \checkinserts
7111 }
7112
7113
7114 % This macro is called at the beginning of all the @example variants,
7115 % inside a group.
7116 \newdimen\nonfillparindent
7117 \def\nonfillstart{%
7118   \aboveenvbreak
7119   \ifdim\hfuzz < 12pt \hfuzz = 12pt \fi % Don't be fussy
7120   \sepspaces % Make spaces be word-separators rather than space tokens.
7121   \let\par = \lisppar % don't ignore blank lines
7122   \obeylines % each line of input is a line of output
7123   \parskip = 0pt
7124   % Turn off paragraph indentation but redefine \indent to emulate
7125   % the normal \indent.
7126   \nonfillparindent=\parindent
7127   \parindent = 0pt
7128   \let\indent\nonfillindent
7129   %
7130   \emergencystretch = 0pt % don't try to avoid overfull boxes
7131   \ifx\nonarrowing\relax
7132     \advance \leftskip by \lispnarrowing
7133     \exdentamount=\lispnarrowing
7134   \else
7135     \let\nonarrowing = \relax
7136   \fi
7137   \let\exdent=\nofillexdent
7138 }
7139
7140 \begingroup
7141 \obeyspaces
7142 % We want to swallow spaces (but not other tokens) after the fake
7143 % @indent in our nonfill-environments, where spaces are normally
7144 % active and set to @tie, resulting in them not being ignored after
7145 % @indent.
7146 \gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}%
7147 \gdef\nonfillindentcheck{%
7148 \ifx\temp %
7149 \expandafter\nonfillindentgobble%
7150 \else%
7151 \leavevmode\nonfillindentbox%
7152 \fi%
7153 }%
7154 \endgroup
7155 \def\nonfillindentgobble#1{\nonfillindent}
7156 \def\nonfillindentbox{\hbox to \nonfillparindent{\hss}}
7157
7158 % If you want all examples etc. small: @set dispenvsize small.
7159 % If you want even small examples the full size: @set dispenvsize nosmall.
7160 % This affects the following displayed environments:
7161 %    @example, @display, @format, @lisp
7162 %
7163 \def\smallword{small}
7164 \def\nosmallword{nosmall}
7165 \let\SETdispenvsize\relax
7166 \def\setnormaldispenv{%
7167   \ifx\SETdispenvsize\smallword
7168     % end paragraph for sake of leading, in case document has no blank
7169     % line.  This is redundant with what happens in \aboveenvbreak, but
7170     % we need to do it before changing the fonts, and it's inconvenient
7171     % to change the fonts afterward.
7172     \ifnum \lastpenalty=10000 \else \endgraf \fi
7173     \smallexamplefonts \rm
7174   \fi
7175 }
7176 \def\setsmalldispenv{%
7177   \ifx\SETdispenvsize\nosmallword
7178   \else
7179     \ifnum \lastpenalty=10000 \else \endgraf \fi
7180     \smallexamplefonts \rm
7181   \fi
7182 }
7183
7184 % We often define two environments, @foo and @smallfoo.
7185 % Let's do it in one command.  #1 is the env name, #2 the definition.
7186 \def\makedispenvdef#1#2{%
7187   \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}%
7188   \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}%
7189   \expandafter\let\csname E#1\endcsname \afterenvbreak
7190   \expandafter\let\csname Esmall#1\endcsname \afterenvbreak
7191 }
7192
7193 % Define two environment synonyms (#1 and #2) for an environment.
7194 \def\maketwodispenvdef#1#2#3{%
7195   \makedispenvdef{#1}{#3}%
7196   \makedispenvdef{#2}{#3}%
7197 }
7198 %
7199 % @lisp: indented, narrowed, typewriter font;
7200 % @example: same as @lisp.
7201 %
7202 % @smallexample and @smalllisp: use smaller fonts.
7203 % Originally contributed by Pavel@xerox.
7204 %
7205 \maketwodispenvdef{lisp}{example}{%
7206   \nonfillstart
7207   \tt\setupmarkupstyle{example}%
7208   \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
7209   \gobble % eat return
7210 }
7211 % @display/@smalldisplay: same as @lisp except keep current font.
7212 %
7213 \makedispenvdef{display}{%
7214   \nonfillstart
7215   \gobble
7216 }
7217
7218 % @format/@smallformat: same as @display except don't narrow margins.
7219 %
7220 \makedispenvdef{format}{%
7221   \let\nonarrowing = t%
7222   \nonfillstart
7223   \gobble
7224 }
7225
7226 % @flushleft: same as @format, but doesn't obey \SETdispenvsize.
7227 \envdef\flushleft{%
7228   \let\nonarrowing = t%
7229   \nonfillstart
7230   \gobble
7231 }
7232 \let\Eflushleft = \afterenvbreak
7233
7234 % @flushright.
7235 %
7236 \envdef\flushright{%
7237   \let\nonarrowing = t%
7238   \nonfillstart
7239   \advance\leftskip by 0pt plus 1fill\relax
7240   \gobble
7241 }
7242 \let\Eflushright = \afterenvbreak
7243
7244
7245 % @raggedright does more-or-less normal line breaking but no right
7246 % justification.  From plain.tex.  Don't stretch around special
7247 % characters in urls in this environment, since the stretch at the right
7248 % should be enough.
7249 \envdef\raggedright{%
7250   \rightskip0pt plus2.4em \spaceskip.3333em \xspaceskip.5em\relax
7251   \def\urefprestretchamount{0pt}%
7252   \def\urefpoststretchamount{0pt}%
7253 }
7254 \let\Eraggedright\par
7255
7256 \envdef\raggedleft{%
7257   \parindent=0pt \leftskip0pt plus2em
7258   \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
7259   \hbadness=10000 % Last line will usually be underfull, so turn off
7260                   % badness reporting.
7261 }
7262 \let\Eraggedleft\par
7263
7264 \envdef\raggedcenter{%
7265   \parindent=0pt \rightskip0pt plus1em \leftskip0pt plus1em
7266   \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
7267   \hbadness=10000 % Last line will usually be underfull, so turn off
7268                   % badness reporting.
7269 }
7270 \let\Eraggedcenter\par
7271
7272
7273 % @quotation does normal linebreaking (hence we can't use \nonfillstart)
7274 % and narrows the margins.  We keep \parskip nonzero in general, since
7275 % we're doing normal filling.  So, when using \aboveenvbreak and
7276 % \afterenvbreak, temporarily make \parskip 0.
7277 %
7278 \makedispenvdef{quotation}{\quotationstart}
7279 %
7280 \def\quotationstart{%
7281   \indentedblockstart % same as \indentedblock, but increase right margin too.
7282   \ifx\nonarrowing\relax
7283     \advance\rightskip by \lispnarrowing
7284   \fi
7285   \parsearg\quotationlabel
7286 }
7287
7288 % We have retained a nonzero parskip for the environment, since we're
7289 % doing normal filling.
7290 %
7291 \def\Equotation{%
7292   \par
7293   \ifx\quotationauthor\thisisundefined\else
7294     % indent a bit.
7295     \leftline{\kern 2\leftskip \sl ---\quotationauthor}%
7296   \fi
7297   {\parskip=0pt \afterenvbreak}%
7298 }
7299 \def\Esmallquotation{\Equotation}
7300
7301 % If we're given an argument, typeset it in bold with a colon after.
7302 \def\quotationlabel#1{%
7303   \def\temp{#1}%
7304   \ifx\temp\empty \else
7305     {\bf #1: }%
7306   \fi
7307 }
7308
7309 % @indentedblock is like @quotation, but indents only on the left and
7310 % has no optional argument.
7311
7312 \makedispenvdef{indentedblock}{\indentedblockstart}
7313 %
7314 \def\indentedblockstart{%
7315   {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
7316   \parindent=0pt
7317   %
7318   % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
7319   \ifx\nonarrowing\relax
7320     \advance\leftskip by \lispnarrowing
7321     \exdentamount = \lispnarrowing
7322   \else
7323     \let\nonarrowing = \relax
7324   \fi
7325 }
7326
7327 % Keep a nonzero parskip for the environment, since we're doing normal filling.
7328 %
7329 \def\Eindentedblock{%
7330   \par
7331   {\parskip=0pt \afterenvbreak}%
7332 }
7333 \def\Esmallindentedblock{\Eindentedblock}
7334
7335
7336 % LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>}
7337 % If we want to allow any <char> as delimiter,
7338 % we need the curly braces so that makeinfo sees the @verb command, eg:
7339 % `@verbx...x' would look like the '@verbx' command.  --janneke@gnu.org
7340 %
7341 % [Knuth]: Donald Ervin Knuth, 1996.  The TeXbook.
7342 %
7343 % [Knuth] p.344; only we need to do the other characters Texinfo sets
7344 % active too.  Otherwise, they get lost as the first character on a
7345 % verbatim line.
7346 \def\dospecials{%
7347   \do\ \do\\\do\{\do\}\do\$\do\&%
7348   \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~%
7349   \do\<\do\>\do\|\do\@\do+\do\"%
7350   % Don't do the quotes -- if we do, @set txicodequoteundirected and
7351   % @set txicodequotebacktick will not have effect on @verb and
7352   % @verbatim, and ?` and !` ligatures won't get disabled.
7353   %\do\`\do\'%
7354 }
7355 %
7356 % [Knuth] p. 380
7357 \def\uncatcodespecials{%
7358   \def\do##1{\catcode`##1=\other}\dospecials}
7359 %
7360 % Setup for the @verb command.
7361 %
7362 % Eight spaces for a tab
7363 \begingroup
7364   \catcode`\^^I=\active
7365   \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }}
7366 \endgroup
7367 %
7368 \def\setupverb{%
7369   \tt  % easiest (and conventionally used) font for verbatim
7370   \def\par{\leavevmode\endgraf}%
7371   \setupmarkupstyle{verb}%
7372   \tabeightspaces
7373   % Respect line breaks,
7374   % print special symbols as themselves, and
7375   % make each space count
7376   % must do in this order:
7377   \obeylines \uncatcodespecials \sepspaces
7378 }
7379
7380 % Setup for the @verbatim environment
7381 %
7382 % Real tab expansion.
7383 \newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
7384 %
7385 % We typeset each line of the verbatim in an \hbox, so we can handle
7386 % tabs.  The \global is in case the verbatim line starts with an accent,
7387 % or some other command that starts with a begin-group.  Otherwise, the
7388 % entire \verbbox would disappear at the corresponding end-group, before
7389 % it is typeset.  Meanwhile, we can't have nested verbatim commands
7390 % (can we?), so the \global won't be overwriting itself.
7391 \newbox\verbbox
7392 \def\starttabbox{\global\setbox\verbbox=\hbox\bgroup}
7393 %
7394 \begingroup
7395   \catcode`\^^I=\active
7396   \gdef\tabexpand{%
7397     \catcode`\^^I=\active
7398     \def^^I{\leavevmode\egroup
7399       \dimen\verbbox=\wd\verbbox % the width so far, or since the previous tab
7400       \divide\dimen\verbbox by\tabw
7401       \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw
7402       \advance\dimen\verbbox by\tabw  % advance to next multiple of \tabw
7403       \wd\verbbox=\dimen\verbbox \box\verbbox \starttabbox
7404     }%
7405   }
7406 \endgroup
7407
7408 % start the verbatim environment.
7409 \def\setupverbatim{%
7410   \let\nonarrowing = t%
7411   \nonfillstart
7412   \tt % easiest (and conventionally used) font for verbatim
7413   % The \leavevmode here is for blank lines.  Otherwise, we would
7414   % never \starttabox and the \egroup would end verbatim mode.
7415   \def\par{\leavevmode\egroup\box\verbbox\endgraf}%
7416   \tabexpand
7417   \setupmarkupstyle{verbatim}%
7418   % Respect line breaks,
7419   % print special symbols as themselves, and
7420   % make each space count.
7421   % Must do in this order:
7422   \obeylines \uncatcodespecials \sepspaces
7423   \everypar{\starttabbox}%
7424 }
7425
7426 % Do the @verb magic: verbatim text is quoted by unique
7427 % delimiter characters.  Before first delimiter expect a
7428 % right brace, after last delimiter expect closing brace:
7429 %
7430 %    \def\doverb'{'<char>#1<char>'}'{#1}
7431 %
7432 % [Knuth] p. 382; only eat outer {}
7433 \begingroup
7434   \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other
7435   \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next]
7436 \endgroup
7437 %
7438 \def\verb{\begingroup\setupverb\doverb}
7439 %
7440 %
7441 % Do the @verbatim magic: define the macro \doverbatim so that
7442 % the (first) argument ends when '@end verbatim' is reached, ie:
7443 %
7444 %     \def\doverbatim#1@end verbatim{#1}
7445 %
7446 % For Texinfo it's a lot easier than for LaTeX,
7447 % because texinfo's \verbatim doesn't stop at '\end{verbatim}':
7448 % we need not redefine '\', '{' and '}'.
7449 %
7450 % Inspired by LaTeX's verbatim command set [latex.ltx]
7451 %
7452 \begingroup
7453   \catcode`\ =\active
7454   \obeylines %
7455   % ignore everything up to the first ^^M, that's the newline at the end
7456   % of the @verbatim input line itself.  Otherwise we get an extra blank
7457   % line in the output.
7458   \xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}%
7459   % We really want {...\end verbatim} in the body of the macro, but
7460   % without the active space; thus we have to use \xdef and \gobble.
7461 \endgroup
7462 %
7463 \envdef\verbatim{%
7464     \setupverbatim\doverbatim
7465 }
7466 \let\Everbatim = \afterenvbreak
7467
7468
7469 % @verbatiminclude FILE - insert text of file in verbatim environment.
7470 %
7471 \def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude}
7472 %
7473 \def\doverbatiminclude#1{%
7474   {%
7475     \makevalueexpandable
7476     \setupverbatim
7477     \indexnofonts       % Allow `@@' and other weird things in file names.
7478     \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}%
7479     \input #1
7480     \afterenvbreak
7481   }%
7482 }
7483
7484 % @copying ... @end copying.
7485 % Save the text away for @insertcopying later.
7486 %
7487 % We save the uninterpreted tokens, rather than creating a box.
7488 % Saving the text in a box would be much easier, but then all the
7489 % typesetting commands (@smallbook, font changes, etc.) have to be done
7490 % beforehand -- and a) we want @copying to be done first in the source
7491 % file; b) letting users define the frontmatter in as flexible order as
7492 % possible is desirable.
7493 %
7494 \def\copying{\checkenv{}\begingroup\scanargctxt\docopying}
7495 \def\docopying#1@end copying{\endgroup\def\copyingtext{#1}}
7496 %
7497 \def\insertcopying{%
7498   \begingroup
7499     \parindent = 0pt  % paragraph indentation looks wrong on title page
7500     \scanexp\copyingtext
7501   \endgroup
7502 }
7503
7504
7505 \message{defuns,}
7506 % @defun etc.
7507
7508 \newskip\defbodyindent \defbodyindent=.4in
7509 \newskip\defargsindent \defargsindent=50pt
7510 \newskip\deflastargmargin \deflastargmargin=18pt
7511 \newcount\defunpenalty
7512
7513 % Start the processing of @deffn:
7514 \def\startdefun{%
7515   \ifnum\lastpenalty<10000
7516     \medbreak
7517     \defunpenalty=10003 % Will keep this @deffn together with the
7518                         % following @def command, see below.
7519   \else
7520     % If there are two @def commands in a row, we'll have a \nobreak,
7521     % which is there to keep the function description together with its
7522     % header.  But if there's nothing but headers, we need to allow a
7523     % break somewhere.  Check specifically for penalty 10002, inserted
7524     % by \printdefunline, instead of 10000, since the sectioning
7525     % commands also insert a nobreak penalty, and we don't want to allow
7526     % a break between a section heading and a defun.
7527     %
7528     % As a further refinement, we avoid "club" headers by signalling
7529     % with penalty of 10003 after the very first @deffn in the
7530     % sequence (see above), and penalty of 10002 after any following
7531     % @def command.
7532     \ifnum\lastpenalty=10002 \penalty2000 \else \defunpenalty=10002 \fi
7533     %
7534     % Similarly, after a section heading, do not allow a break.
7535     % But do insert the glue.
7536     \medskip  % preceded by discardable penalty, so not a breakpoint
7537   \fi
7538   %
7539   \parindent=0in
7540   \advance\leftskip by \defbodyindent
7541   \exdentamount=\defbodyindent
7542 }
7543
7544 \def\dodefunx#1{%
7545   % First, check whether we are in the right environment:
7546   \checkenv#1%
7547   %
7548   % As above, allow line break if we have multiple x headers in a row.
7549   % It's not a great place, though.
7550   \ifnum\lastpenalty=10002 \penalty3000 \else \defunpenalty=10002 \fi
7551   %
7552   % And now, it's time to reuse the body of the original defun:
7553   \expandafter\gobbledefun#1%
7554 }
7555 \def\gobbledefun#1\startdefun{}
7556
7557 % \printdefunline \deffnheader{text}
7558 %
7559 \def\printdefunline#1#2{%
7560   \begingroup
7561     % call \deffnheader:
7562     #1#2 \endheader
7563     % common ending:
7564     \interlinepenalty = 10000
7565     \advance\rightskip by 0pt plus 1fil\relax
7566     \endgraf
7567     \nobreak\vskip -\parskip
7568     \penalty\defunpenalty  % signal to \startdefun and \dodefunx
7569     % Some of the @defun-type tags do not enable magic parentheses,
7570     % rendering the following check redundant.  But we don't optimize.
7571     \checkparencounts
7572   \endgroup
7573 }
7574
7575 \def\Edefun{\endgraf\medbreak}
7576
7577 % \makedefun{deffn} creates \deffn, \deffnx and \Edeffn;
7578 % the only thing remaining is to define \deffnheader.
7579 %
7580 \def\makedefun#1{%
7581   \expandafter\let\csname E#1\endcsname = \Edefun
7582   \edef\temp{\noexpand\domakedefun
7583     \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}%
7584   \temp
7585 }
7586
7587 % \domakedefun \deffn \deffnx \deffnheader { (defn. of \deffnheader) }
7588 %
7589 % Define \deffn and \deffnx, without parameters.
7590 % \deffnheader has to be defined explicitly.
7591 %
7592 \def\domakedefun#1#2#3{%
7593   \envdef#1{%
7594     \startdefun
7595     \doingtypefnfalse    % distinguish typed functions from all else
7596     \parseargusing\activeparens{\printdefunline#3}%
7597   }%
7598   \def#2{\dodefunx#1}%
7599   \def#3%
7600 }
7601
7602 \newif\ifdoingtypefn       % doing typed function?
7603 \newif\ifrettypeownline    % typeset return type on its own line?
7604
7605 % @deftypefnnewline on|off says whether the return type of typed functions
7606 % are printed on their own line.  This affects @deftypefn, @deftypefun,
7607 % @deftypeop, and @deftypemethod.
7608
7609 \parseargdef\deftypefnnewline{%
7610   \def\temp{#1}%
7611   \ifx\temp\onword
7612     \expandafter\let\csname SETtxideftypefnnl\endcsname
7613       = \empty
7614   \else\ifx\temp\offword
7615     \expandafter\let\csname SETtxideftypefnnl\endcsname
7616       = \relax
7617   \else
7618     \errhelp = \EMsimple
7619     \errmessage{Unknown @txideftypefnnl value `\temp',
7620                 must be on|off}%
7621   \fi\fi
7622 }
7623
7624 % Untyped functions:
7625
7626 % @deffn category name args
7627 \makedefun{deffn}{\deffngeneral{}}
7628
7629 % @deffn category class name args
7630 \makedefun{defop}#1 {\defopon{#1\ \putwordon}}
7631
7632 % \defopon {category on}class name args
7633 \def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
7634
7635 % \deffngeneral {subind}category name args
7636 %
7637 \def\deffngeneral#1#2 #3 #4\endheader{%
7638   % Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}.
7639   \dosubind{fn}{\code{#3}}{#1}%
7640   \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
7641 }
7642
7643 % Typed functions:
7644
7645 % @deftypefn category type name args
7646 \makedefun{deftypefn}{\deftypefngeneral{}}
7647
7648 % @deftypeop category class type name args
7649 \makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}}
7650
7651 % \deftypeopon {category on}class type name args
7652 \def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
7653
7654 % \deftypefngeneral {subind}category type name args
7655 %
7656 \def\deftypefngeneral#1#2 #3 #4 #5\endheader{%
7657   \dosubind{fn}{\code{#4}}{#1}%
7658   \doingtypefntrue
7659   \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
7660 }
7661
7662 % Typed variables:
7663
7664 % @deftypevr category type var args
7665 \makedefun{deftypevr}{\deftypecvgeneral{}}
7666
7667 % @deftypecv category class type var args
7668 \makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}}
7669
7670 % \deftypecvof {category of}class type var args
7671 \def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} }
7672
7673 % \deftypecvgeneral {subind}category type var args
7674 %
7675 \def\deftypecvgeneral#1#2 #3 #4 #5\endheader{%
7676   \dosubind{vr}{\code{#4}}{#1}%
7677   \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
7678 }
7679
7680 % Untyped variables:
7681
7682 % @defvr category var args
7683 \makedefun{defvr}#1 {\deftypevrheader{#1} {} }
7684
7685 % @defcv category class var args
7686 \makedefun{defcv}#1 {\defcvof{#1\ \putwordof}}
7687
7688 % \defcvof {category of}class var args
7689 \def\defcvof#1#2 {\deftypecvof{#1}#2 {} }
7690
7691 % Types:
7692
7693 % @deftp category name args
7694 \makedefun{deftp}#1 #2 #3\endheader{%
7695   \doind{tp}{\code{#2}}%
7696   \defname{#1}{}{#2}\defunargs{#3\unskip}%
7697 }
7698
7699 % Remaining @defun-like shortcuts:
7700 \makedefun{defun}{\deffnheader{\putwordDeffunc} }
7701 \makedefun{defmac}{\deffnheader{\putwordDefmac} }
7702 \makedefun{defspec}{\deffnheader{\putwordDefspec} }
7703 \makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} }
7704 \makedefun{defvar}{\defvrheader{\putwordDefvar} }
7705 \makedefun{defopt}{\defvrheader{\putwordDefopt} }
7706 \makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} }
7707 \makedefun{defmethod}{\defopon\putwordMethodon}
7708 \makedefun{deftypemethod}{\deftypeopon\putwordMethodon}
7709 \makedefun{defivar}{\defcvof\putwordInstanceVariableof}
7710 \makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof}
7711
7712 % \defname, which formats the name of the @def (not the args).
7713 % #1 is the category, such as "Function".
7714 % #2 is the return type, if any.
7715 % #3 is the function name.
7716 %
7717 % We are followed by (but not passed) the arguments, if any.
7718 %
7719 \def\defname#1#2#3{%
7720   \par
7721   % Get the values of \leftskip and \rightskip as they were outside the @def...
7722   \advance\leftskip by -\defbodyindent
7723   %
7724   % Determine if we are typesetting the return type of a typed function
7725   % on a line by itself.
7726   \rettypeownlinefalse
7727   \ifdoingtypefn  % doing a typed function specifically?
7728     % then check user option for putting return type on its own line:
7729     \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else
7730       \rettypeownlinetrue
7731     \fi
7732   \fi
7733   %
7734   % How we'll format the category name.  Putting it in brackets helps
7735   % distinguish it from the body text that may end up on the next line
7736   % just below it.
7737   \def\temp{#1}%
7738   \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
7739   %
7740   % Figure out line sizes for the paragraph shape.  We'll always have at
7741   % least two.
7742   \tempnum = 2
7743   %
7744   % The first line needs space for \box0; but if \rightskip is nonzero,
7745   % we need only space for the part of \box0 which exceeds it:
7746   \dimen0=\hsize  \advance\dimen0 by -\wd0  \advance\dimen0 by \rightskip
7747   %
7748   % If doing a return type on its own line, we'll have another line.
7749   \ifrettypeownline
7750     \advance\tempnum by 1
7751     \def\maybeshapeline{0in \hsize}%
7752   \else
7753     \def\maybeshapeline{}%
7754   \fi
7755   %
7756   % The continuations:
7757   \dimen2=\hsize  \advance\dimen2 by -\defargsindent
7758   %
7759   % The final paragraph shape:
7760   \parshape \tempnum  0in \dimen0  \maybeshapeline  \defargsindent \dimen2
7761   %
7762   % Put the category name at the right margin.
7763   \noindent
7764   \hbox to 0pt{%
7765     \hfil\box0 \kern-\hsize
7766     % \hsize has to be shortened this way:
7767     \kern\leftskip
7768     % Intentionally do not respect \rightskip, since we need the space.
7769   }%
7770   %
7771   % Allow all lines to be underfull without complaint:
7772   \tolerance=10000 \hbadness=10000
7773   \exdentamount=\defbodyindent
7774   {%
7775     % defun fonts. We use typewriter by default (used to be bold) because:
7776     % . we're printing identifiers, they should be in tt in principle.
7777     % . in languages with many accents, such as Czech or French, it's
7778     %   common to leave accents off identifiers.  The result looks ok in
7779     %   tt, but exceedingly strange in rm.
7780     % . we don't want -- and --- to be treated as ligatures.
7781     % . this still does not fix the ?` and !` ligatures, but so far no
7782     %   one has made identifiers using them :).
7783     \df \tt
7784     \def\temp{#2}% text of the return type
7785     \ifx\temp\empty\else
7786       \tclose{\temp}% typeset the return type
7787       \ifrettypeownline
7788         % put return type on its own line; prohibit line break following:
7789         \hfil\vadjust{\nobreak}\break  
7790       \else
7791         \space  % type on same line, so just followed by a space
7792       \fi
7793     \fi           % no return type
7794     #3% output function name
7795   }%
7796   {\rm\enskip}% hskip 0.5 em of \tenrm
7797   %
7798   \boldbrax
7799   % arguments will be output next, if any.
7800 }
7801
7802 % Print arguments in slanted roman (not ttsl), inconsistently with using
7803 % tt for the name.  This is because literal text is sometimes needed in
7804 % the argument list (groff manual), and ttsl and tt are not very
7805 % distinguishable.  Prevent hyphenation at `-' chars.
7806 %
7807 \def\defunargs#1{%
7808   % use sl by default (not ttsl),
7809   % tt for the names.
7810   \df \sl \hyphenchar\font=0
7811   %
7812   % On the other hand, if an argument has two dashes (for instance), we
7813   % want a way to get ttsl.  We used to recommend @var for that, so
7814   % leave the code in, but it's strange for @var to lead to typewriter.
7815   % Nowadays we recommend @code, since the difference between a ttsl hyphen
7816   % and a tt hyphen is pretty tiny.  @code also disables ?` !`.
7817   \def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}%
7818   #1%
7819   \sl\hyphenchar\font=45
7820 }
7821
7822 % We want ()&[] to print specially on the defun line.
7823 %
7824 \def\activeparens{%
7825   \catcode`\(=\active \catcode`\)=\active
7826   \catcode`\[=\active \catcode`\]=\active
7827   \catcode`\&=\active
7828 }
7829
7830 % Make control sequences which act like normal parenthesis chars.
7831 \let\lparen = ( \let\rparen = )
7832
7833 % Be sure that we always have a definition for `(', etc.  For example,
7834 % if the fn name has parens in it, \boldbrax will not be in effect yet,
7835 % so TeX would otherwise complain about undefined control sequence.
7836 {
7837   \activeparens
7838   \global\let(=\lparen \global\let)=\rparen
7839   \global\let[=\lbrack \global\let]=\rbrack
7840   \global\let& = \&
7841
7842   \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
7843   \gdef\magicamp{\let&=\amprm}
7844 }
7845
7846 \newcount\parencount
7847
7848 % If we encounter &foo, then turn on ()-hacking afterwards
7849 \newif\ifampseen
7850 \def\amprm#1 {\ampseentrue{\bf\&#1 }}
7851
7852 \def\parenfont{%
7853   \ifampseen
7854     % At the first level, print parens in roman,
7855     % otherwise use the default font.
7856     \ifnum \parencount=1 \rm \fi
7857   \else
7858     % The \sf parens (in \boldbrax) actually are a little bolder than
7859     % the contained text.  This is especially needed for [ and ] .
7860     \sf
7861   \fi
7862 }
7863 \def\infirstlevel#1{%
7864   \ifampseen
7865     \ifnum\parencount=1
7866       #1%
7867     \fi
7868   \fi
7869 }
7870 \def\bfafterword#1 {#1 \bf}
7871
7872 \def\opnr{%
7873   \global\advance\parencount by 1
7874   {\parenfont(}%
7875   \infirstlevel \bfafterword
7876 }
7877 \def\clnr{%
7878   {\parenfont)}%
7879   \infirstlevel \sl
7880   \global\advance\parencount by -1
7881 }
7882
7883 \newcount\brackcount
7884 \def\lbrb{%
7885   \global\advance\brackcount by 1
7886   {\bf[}%
7887 }
7888 \def\rbrb{%
7889   {\bf]}%
7890   \global\advance\brackcount by -1
7891 }
7892
7893 \def\checkparencounts{%
7894   \ifnum\parencount=0 \else \badparencount \fi
7895   \ifnum\brackcount=0 \else \badbrackcount \fi
7896 }
7897 % these should not use \errmessage; the glibc manual, at least, actually
7898 % has such constructs (when documenting function pointers).
7899 \def\badparencount{%
7900   \message{Warning: unbalanced parentheses in @def...}%
7901   \global\parencount=0
7902 }
7903 \def\badbrackcount{%
7904   \message{Warning: unbalanced square brackets in @def...}%
7905   \global\brackcount=0
7906 }
7907
7908
7909 \message{macros,}
7910 % @macro.
7911
7912 % To do this right we need a feature of e-TeX, \scantokens,
7913 % which we arrange to emulate with a temporary file in ordinary TeX.
7914 \ifx\eTeXversion\thisisundefined
7915   \newwrite\macscribble
7916   \def\scantokens#1{%
7917     \toks0={#1}%
7918     \immediate\openout\macscribble=\jobname.tmp
7919     \immediate\write\macscribble{\the\toks0}%
7920     \immediate\closeout\macscribble
7921     \input \jobname.tmp
7922   }
7923 \fi
7924
7925 \let\aftermacroxxx\relax
7926 \def\aftermacro{\aftermacroxxx}
7927
7928 % alias because \c means cedilla in @tex or @math
7929 \let\texinfoc=\c
7930
7931 \newcount\savedcatcodeone
7932 \newcount\savedcatcodetwo
7933
7934 % Used at the time of macro expansion.
7935 % Argument is macro body with arguments substituted
7936 \def\scanmacro#1{%
7937   \newlinechar`\^^M
7938   \def\xeatspaces{\eatspaces}%
7939   %
7940   % Temporarily undo catcode changes of \printindex.  Set catcode of @ to
7941   % 0 so that @-commands in macro expansions aren't printed literally when 
7942   % formatting an index file, where \ is used as the escape character.
7943   \savedcatcodeone=\catcode`\@
7944   \savedcatcodetwo=\catcode`\\
7945   \catcode`\@=0
7946   \catcode`\\=\active
7947   %
7948   % Process the macro body under the current catcode regime.
7949   \scantokens{#1@texinfoc}\aftermacro%
7950   %
7951   \catcode`\@=\savedcatcodeone
7952   \catcode`\\=\savedcatcodetwo
7953   %
7954   % The \texinfoc is to remove the \newlinechar added by \scantokens, and
7955   % can be noticed by \parsearg.
7956   %   The \aftermacro allows a \comment at the end of the macro definition
7957   % to duplicate itself past the final \newlinechar added by \scantokens:
7958   % this is used in the definition of \group to comment out a newline.  We
7959   % don't do the same for \c to support Texinfo files with macros that ended
7960   % with a @c, which should no longer be necessary.
7961   %   We avoid surrounding the call to \scantokens with \bgroup and \egroup
7962   % to allow macros to open or close groups themselves.
7963 }
7964
7965 % Used for copying and captions
7966 \def\scanexp#1{%
7967   \expandafter\scanmacro\expandafter{#1}%
7968 }
7969
7970 \newcount\paramno   % Count of parameters
7971 \newtoks\macname    % Macro name
7972 \newif\ifrecursive  % Is it recursive?
7973
7974 % List of all defined macros in the form
7975 %    \definedummyword\macro1\definedummyword\macro2...
7976 % Currently is also contains all @aliases; the list can be split
7977 % if there is a need.
7978 \def\macrolist{}
7979
7980 % Add the macro to \macrolist
7981 \def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname}
7982 \def\addtomacrolistxxx#1{%
7983      \toks0 = \expandafter{\macrolist\definedummyword#1}%
7984      \xdef\macrolist{\the\toks0}%
7985 }
7986
7987 % Utility routines.
7988 % This does \let #1 = #2, with \csnames; that is,
7989 %   \let \csname#1\endcsname = \csname#2\endcsname
7990 % (except of course we have to play expansion games).
7991 %
7992 \def\cslet#1#2{%
7993   \expandafter\let
7994   \csname#1\expandafter\endcsname
7995   \csname#2\endcsname
7996 }
7997
7998 % Trim leading and trailing spaces off a string.
7999 % Concepts from aro-bend problem 15 (see CTAN).
8000 {\catcode`\@=11
8001 \gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }}
8002 \gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@}
8003 \gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @}
8004 \def\unbrace#1{#1}
8005 \unbrace{\gdef\trim@@@ #1 } #2@{#1}
8006 }
8007
8008 % Trim a single trailing ^^M off a string.
8009 {\catcode`\^^M=\other \catcode`\Q=3%
8010 \gdef\eatcr #1{\eatcra #1Q^^MQ}%
8011 \gdef\eatcra#1^^MQ{\eatcrb#1Q}%
8012 \gdef\eatcrb#1Q#2Q{#1}%
8013 }
8014
8015 % Macro bodies are absorbed as an argument in a context where
8016 % all characters are catcode 10, 11 or 12, except \ which is active
8017 % (as in normal texinfo). It is necessary to change the definition of \
8018 % to recognize macro arguments; this is the job of \mbodybackslash.
8019 %
8020 % Non-ASCII encodings make 8-bit characters active, so un-activate
8021 % them to avoid their expansion.  Must do this non-globally, to
8022 % confine the change to the current group.
8023 %
8024 % It's necessary to have hard CRs when the macro is executed. This is
8025 % done by making ^^M (\endlinechar) catcode 12 when reading the macro
8026 % body, and then making it the \newlinechar in \scanmacro.
8027 %
8028 \def\scanctxt{% used as subroutine
8029   \catcode`\"=\other
8030   \catcode`\+=\other
8031   \catcode`\<=\other
8032   \catcode`\>=\other
8033   \catcode`\^=\other
8034   \catcode`\_=\other
8035   \catcode`\|=\other
8036   \catcode`\~=\other
8037   \passthroughcharstrue
8038 }
8039
8040 \def\scanargctxt{% used for copying and captions, not macros.
8041   \scanctxt
8042   \catcode`\@=\other
8043   \catcode`\\=\other
8044   \catcode`\^^M=\other
8045 }
8046
8047 \def\macrobodyctxt{% used for @macro definitions
8048   \scanctxt
8049   \catcode`\ =\other
8050   \catcode`\@=\other
8051   \catcode`\{=\other
8052   \catcode`\}=\other
8053   \catcode`\^^M=\other
8054   \usembodybackslash
8055 }
8056
8057 % Used when scanning braced macro arguments.  Note, however, that catcode
8058 % changes here are ineffectual if the macro invocation was nested inside
8059 % an argument to another Texinfo command.
8060 \def\macroargctxt{%
8061   \scanctxt
8062   \catcode`\ =\active
8063   \catcode`\^^M=\other
8064   \catcode`\\=\active
8065 }
8066
8067 \def\macrolineargctxt{% used for whole-line arguments without braces
8068   \scanctxt
8069   \catcode`\{=\other
8070   \catcode`\}=\other
8071 }
8072
8073 % \mbodybackslash is the definition of \ in @macro bodies.
8074 % It maps \foo\ => \csname macarg.foo\endcsname => #N
8075 % where N is the macro parameter number.
8076 % We define \csname macarg.\endcsname to be \realbackslash, so
8077 % \\ in macro replacement text gets you a backslash.
8078 %
8079 {\catcode`@=0 @catcode`@\=@active
8080  @gdef@usembodybackslash{@let\=@mbodybackslash}
8081  @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname}
8082 }
8083 \expandafter\def\csname macarg.\endcsname{\realbackslash}
8084
8085 \def\margbackslash#1{\char`\#1 }
8086
8087 \def\macro{\recursivefalse\parsearg\macroxxx}
8088 \def\rmacro{\recursivetrue\parsearg\macroxxx}
8089
8090 \def\macroxxx#1{%
8091   \getargs{#1}% now \macname is the macname and \argl the arglist
8092   \ifx\argl\empty       % no arguments
8093      \paramno=0\relax
8094   \else
8095      \expandafter\parsemargdef \argl;%
8096      \if\paramno>256\relax
8097        \ifx\eTeXversion\thisisundefined
8098          \errhelp = \EMsimple
8099          \errmessage{You need eTeX to compile a file with macros with more than 256 arguments}
8100        \fi
8101      \fi
8102   \fi
8103   \if1\csname ismacro.\the\macname\endcsname
8104      \message{Warning: redefining \the\macname}%
8105   \else
8106      \expandafter\ifx\csname \the\macname\endcsname \relax
8107      \else \errmessage{Macro name \the\macname\space already defined}\fi
8108      \global\cslet{macsave.\the\macname}{\the\macname}%
8109      \global\expandafter\let\csname ismacro.\the\macname\endcsname=1%
8110      \addtomacrolist{\the\macname}%
8111   \fi
8112   \begingroup \macrobodyctxt
8113   \ifrecursive \expandafter\parsermacbody
8114   \else \expandafter\parsemacbody
8115   \fi}
8116
8117 \parseargdef\unmacro{%
8118   \if1\csname ismacro.#1\endcsname
8119     \global\cslet{#1}{macsave.#1}%
8120     \global\expandafter\let \csname ismacro.#1\endcsname=0%
8121     % Remove the macro name from \macrolist:
8122     \begingroup
8123       \expandafter\let\csname#1\endcsname \relax
8124       \let\definedummyword\unmacrodo
8125       \xdef\macrolist{\macrolist}%
8126     \endgroup
8127   \else
8128     \errmessage{Macro #1 not defined}%
8129   \fi
8130 }
8131
8132 % Called by \do from \dounmacro on each macro.  The idea is to omit any
8133 % macro definitions that have been changed to \relax.
8134 %
8135 \def\unmacrodo#1{%
8136   \ifx #1\relax
8137     % remove this
8138   \else
8139     \noexpand\definedummyword \noexpand#1%
8140   \fi
8141 }
8142
8143 % \getargs -- Parse the arguments to a @macro line.  Set \macname to
8144 % the name of the macro, and \argl to the braced argument list.
8145 \def\getargs#1{\getargsxxx#1{}}
8146 \def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
8147 \def\getmacname#1 #2\relax{\macname={#1}}
8148 \def\getmacargs#1{\def\argl{#1}}
8149 % This made use of the feature that if the last token of a
8150 % <parameter list> is #, then the preceding argument is delimited by
8151 % an opening brace, and that opening brace is not consumed.
8152
8153 % Parse the optional {params} list to @macro or @rmacro.
8154 % Set \paramno to the number of arguments,
8155 % and \paramlist to a parameter text for the macro (e.g. #1,#2,#3 for a
8156 % three-param macro.)  Define \macarg.BLAH for each BLAH in the params
8157 % list to some hook where the argument is to be expanded.  If there are
8158 % less than 10 arguments that hook is to be replaced by ##N where N
8159 % is the position in that list, that is to say the macro arguments are to be
8160 % defined `a la TeX in the macro body.  
8161 %
8162 % That gets used by \mbodybackslash (above).
8163 %
8164 % If there are 10 or more arguments, a different technique is used: see
8165 % \parsemmanyargdef.
8166 %
8167 \def\parsemargdef#1;{%
8168   \paramno=0\def\paramlist{}%
8169   \let\hash\relax
8170   % \hash is redefined to `#' later to get it into definitions
8171   \let\xeatspaces\relax
8172   \parsemargdefxxx#1,;,%
8173   \ifnum\paramno<10\relax\else
8174     \paramno0\relax
8175     \parsemmanyargdef@@#1,;,% 10 or more arguments
8176   \fi
8177 }
8178 \def\parsemargdefxxx#1,{%
8179   \if#1;\let\next=\relax
8180   \else \let\next=\parsemargdefxxx
8181     \advance\paramno by 1
8182     \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
8183         {\xeatspaces{\hash\the\paramno}}%
8184     \edef\paramlist{\paramlist\hash\the\paramno,}%
8185   \fi\next}
8186
8187 % \parsemacbody, \parsermacbody
8188 %
8189 % Read recursive and nonrecursive macro bodies. (They're different since
8190 % rec and nonrec macros end differently.)
8191
8192 % We are in \macrobodyctxt, and the \xdef causes backslashshes in the macro 
8193 % body to be transformed.
8194 % Set \macrobody to the body of the macro, and call \defmacro.
8195 %
8196 {\catcode`\ =\other\long\gdef\parsemacbody#1@end macro{%
8197 \xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}%
8198 {\catcode`\ =\other\long\gdef\parsermacbody#1@end rmacro{%
8199 \xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}%
8200
8201 % Make @ a letter, so that we can make private-to-Texinfo macro names.
8202 \edef\texiatcatcode{\the\catcode`\@}
8203 \catcode `@=11\relax
8204
8205 %%%%%%%%%%%%%% Code for > 10 arguments only   %%%%%%%%%%%%%%%%%%
8206
8207 % If there are 10 or more arguments, a different technique is used, where the
8208 % hook remains in the body, and when macro is to be expanded the body is
8209 % processed again to replace the arguments.
8210 %
8211 % In that case, the hook is \the\toks N-1, and we simply set \toks N-1 to the
8212 % argument N value and then \edef the body (nothing else will expand because of
8213 % the catcode regime under which the body was input).
8214 %
8215 % If you compile with TeX (not eTeX), and you have macros with 10 or more
8216 % arguments, no macro can have more than 256 arguments (else error).
8217 %
8218 % In case that there are 10 or more arguments we parse again the arguments
8219 % list to set new definitions for the \macarg.BLAH macros corresponding to
8220 % each BLAH argument. It was anyhow needed to parse already once this list
8221 % in order to count the arguments, and as macros with at most 9 arguments
8222 % are by far more frequent than macro with 10 or more arguments, defining
8223 % twice the \macarg.BLAH macros does not cost too much processing power.
8224 \def\parsemmanyargdef@@#1,{%
8225   \if#1;\let\next=\relax
8226   \else 
8227     \let\next=\parsemmanyargdef@@
8228     \edef\tempb{\eatspaces{#1}}%
8229     \expandafter\def\expandafter\tempa
8230        \expandafter{\csname macarg.\tempb\endcsname}%
8231     % Note that we need some extra \noexpand\noexpand, this is because we
8232     % don't want \the  to be expanded in the \parsermacbody  as it uses an
8233     % \xdef .
8234     \expandafter\edef\tempa
8235       {\noexpand\noexpand\noexpand\the\toks\the\paramno}%
8236     \advance\paramno by 1\relax
8237   \fi\next}
8238
8239
8240 \let\endargs@\relax
8241 \let\nil@\relax
8242 \def\nilm@{\nil@}%
8243 \long\def\nillm@{\nil@}%
8244
8245 % This macro is expanded during the Texinfo macro expansion, not during its
8246 % definition.  It gets all the arguments' values and assigns them to macros
8247 % macarg.ARGNAME
8248 %
8249 % #1 is the macro name
8250 % #2 is the list of argument names
8251 % #3 is the list of argument values
8252 \def\getargvals@#1#2#3{%
8253   \def\macargdeflist@{}%
8254   \def\saveparamlist@{#2}% Need to keep a copy for parameter expansion.
8255   \def\paramlist{#2,\nil@}%
8256   \def\macroname{#1}%
8257   \begingroup
8258   \macroargctxt
8259   \def\argvaluelist{#3,\nil@}%
8260   \def\@tempa{#3}%
8261   \ifx\@tempa\empty
8262     \setemptyargvalues@
8263   \else
8264     \getargvals@@
8265   \fi
8266 }
8267 \def\getargvals@@{%
8268   \ifx\paramlist\nilm@
8269       % Some sanity check needed here that \argvaluelist is also empty.
8270       \ifx\argvaluelist\nillm@
8271       \else
8272         \errhelp = \EMsimple
8273         \errmessage{Too many arguments in macro `\macroname'!}%
8274       \fi
8275       \let\next\macargexpandinbody@
8276   \else
8277     \ifx\argvaluelist\nillm@
8278        % No more arguments values passed to macro.  Set remaining named-arg
8279        % macros to empty.
8280        \let\next\setemptyargvalues@
8281     \else
8282       % pop current arg name into \@tempb
8283       \def\@tempa##1{\pop@{\@tempb}{\paramlist}##1\endargs@}%
8284       \expandafter\@tempa\expandafter{\paramlist}%
8285        % pop current argument value into \@tempc
8286       \def\@tempa##1{\longpop@{\@tempc}{\argvaluelist}##1\endargs@}%
8287       \expandafter\@tempa\expandafter{\argvaluelist}%
8288        % Here \@tempb is the current arg name and \@tempc is the current arg value.
8289        % First place the new argument macro definition into \@tempd
8290        \expandafter\macname\expandafter{\@tempc}%
8291        \expandafter\let\csname macarg.\@tempb\endcsname\relax
8292        \expandafter\def\expandafter\@tempe\expandafter{%
8293          \csname macarg.\@tempb\endcsname}%
8294        \edef\@tempd{\long\def\@tempe{\the\macname}}%
8295        \push@\@tempd\macargdeflist@
8296        \let\next\getargvals@@
8297     \fi
8298   \fi
8299   \next
8300 }
8301
8302 \def\push@#1#2{%
8303   \expandafter\expandafter\expandafter\def
8304   \expandafter\expandafter\expandafter#2%
8305   \expandafter\expandafter\expandafter{%
8306   \expandafter#1#2}%
8307 }
8308
8309 % Replace arguments by their values in the macro body, and place the result
8310 % in macro \@tempa.
8311
8312 \def\macvalstoargs@{%
8313   %  To do this we use the property that token registers that are \the'ed
8314   % within an \edef  expand only once. So we are going to place all argument
8315   % values into respective token registers.
8316   %
8317   % First we save the token context, and initialize argument numbering.
8318   \begingroup
8319     \paramno0\relax
8320     % Then, for each argument number #N, we place the corresponding argument
8321     % value into a new token list register \toks#N
8322     \expandafter\putargsintokens@\saveparamlist@,;,%
8323     % Then, we expand the body so that argument are replaced by their
8324     % values. The trick for values not to be expanded themselves is that they
8325     % are within tokens and that tokens expand only once in an \edef .
8326     \edef\@tempc{\csname mac.\macroname .body\endcsname}%
8327     % Now we restore the token stack pointer to free the token list registers
8328     % which we have used, but we make sure that expanded body is saved after
8329     % group.
8330     \expandafter
8331   \endgroup
8332   \expandafter\def\expandafter\@tempa\expandafter{\@tempc}%
8333   }
8334
8335 % Define the named-macro outside of this group and then close this group. 
8336
8337 \def\macargexpandinbody@{% 
8338   \expandafter
8339   \endgroup
8340   \macargdeflist@
8341   % First the replace in body the macro arguments by their values, the result
8342   % is in \@tempa .
8343   \macvalstoargs@
8344   % Then we point at the \norecurse or \gobble (for recursive) macro value
8345   % with \@tempb .
8346   \expandafter\let\expandafter\@tempb\csname mac.\macroname .recurse\endcsname
8347   % Depending on whether it is recursive or not, we need some tailing
8348   % \egroup .
8349   \ifx\@tempb\gobble
8350      \let\@tempc\relax
8351   \else
8352      \let\@tempc\egroup
8353   \fi
8354   % And now we do the real job:
8355   \edef\@tempd{\noexpand\@tempb{\macroname}\noexpand\scanmacro{\@tempa}\@tempc}%
8356   \@tempd
8357 }
8358
8359 \def\putargsintokens@#1,{%
8360   \if#1;\let\next\relax
8361   \else
8362     \let\next\putargsintokens@
8363     % First we allocate the new token list register, and give it a temporary
8364     % alias \@tempb .
8365     \toksdef\@tempb\the\paramno
8366     % Then we place the argument value into that token list register.
8367     \expandafter\let\expandafter\@tempa\csname macarg.#1\endcsname
8368     \expandafter\@tempb\expandafter{\@tempa}%
8369     \advance\paramno by 1\relax
8370   \fi
8371   \next
8372 }
8373
8374 % Trailing missing arguments are set to empty.
8375
8376 \def\setemptyargvalues@{%
8377   \ifx\paramlist\nilm@
8378     \let\next\macargexpandinbody@
8379   \else
8380     \expandafter\setemptyargvaluesparser@\paramlist\endargs@
8381     \let\next\setemptyargvalues@
8382   \fi
8383   \next
8384 }
8385
8386 \def\setemptyargvaluesparser@#1,#2\endargs@{%
8387   \expandafter\def\expandafter\@tempa\expandafter{%
8388     \expandafter\def\csname macarg.#1\endcsname{}}%
8389   \push@\@tempa\macargdeflist@
8390   \def\paramlist{#2}%
8391 }
8392
8393 % #1 is the element target macro
8394 % #2 is the list macro
8395 % #3,#4\endargs@ is the list value
8396 \def\pop@#1#2#3,#4\endargs@{%
8397    \def#1{#3}%
8398    \def#2{#4}%
8399 }
8400 \long\def\longpop@#1#2#3,#4\endargs@{%
8401    \long\def#1{#3}%
8402    \long\def#2{#4}%
8403 }
8404
8405
8406 %%%%%%%%%%%%%% End of code for > 10 arguments %%%%%%%%%%%%%%%%%%
8407
8408
8409 % This defines a Texinfo @macro or @rmacro, called by \parsemacbody.
8410 %    \macrobody has the body of the macro in it, with placeholders for
8411 % its parameters, looking like "\xeatspaces{\hash 1}".
8412 %    \paramno is the number of parameters
8413 %    \paramlist is a TeX parameter text, e.g. "#1,#2,#3,"
8414 % There are eight cases: recursive and nonrecursive macros of zero, one,
8415 % up to nine, and many arguments.
8416 % \xdef is used so that macro definitions will survive the file
8417 % they're defined in: @include reads the file inside a group.
8418 %
8419 \def\defmacro{%
8420   \let\hash=##% convert placeholders to macro parameter chars
8421   \ifnum\paramno=1
8422     \def\xeatspaces##1{##1}%
8423     % This removes the pair of braces around the argument.  We don't
8424     % use \eatspaces, because this can cause ends of lines to be lost
8425     % when the argument to \eatspaces is read, leading to line-based
8426     % commands like "@itemize" not being read correctly.
8427   \else
8428     \let\xeatspaces\relax % suppress expansion
8429   \fi
8430   \ifrecursive   %%%%%%%%%%%%%% Recursive %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8431     \ifcase\paramno
8432     % 0
8433       \expandafter\xdef\csname\the\macname\endcsname{%
8434         \noexpand\scanmacro{\macrobody}}%
8435     \or % 1
8436       \expandafter\xdef\csname\the\macname\endcsname{%
8437          \bgroup
8438          \noexpand\braceorline
8439          \expandafter\noexpand\csname\the\macname @@@\endcsname}%
8440       \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8441         \egroup
8442         \noexpand\scanmacro{\macrobody}%
8443         }%
8444     \else
8445       \ifnum\paramno<10\relax % at most 9
8446         % See non-recursive section below for comments
8447         \expandafter\xdef\csname\the\macname\endcsname{%
8448           \bgroup
8449           \noexpand\expandafter
8450           \noexpand\macroargctxt
8451           \noexpand\expandafter
8452           \expandafter\noexpand\csname\the\macname @@\endcsname}%
8453         \expandafter\xdef\csname\the\macname @@\endcsname##1{%
8454             \noexpand\passargtomacro
8455             \expandafter\noexpand\csname\the\macname @@@\endcsname{##1,}}%
8456         \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8457             \expandafter\noexpand\csname\the\macname @@@@\endcsname ##1}%
8458         \expandafter\expandafter
8459         \expandafter\xdef
8460         \expandafter\expandafter
8461           \csname\the\macname @@@@\endcsname\paramlist{%
8462             \egroup\noexpand\scanmacro{\macrobody}}%
8463       \else % 10 or more
8464         \expandafter\xdef\csname\the\macname\endcsname{%
8465           \noexpand\getargvals@{\the\macname}{\argl}%
8466         }%    
8467         \global\expandafter\let\csname mac.\the\macname .body\endcsname\macrobody
8468         \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\gobble
8469       \fi
8470     \fi
8471   \else  %%%%%%%%%%%%%%%%%%%%%% Non-recursive %%%%%%%%%%%%%%%%%%%%%%%%%%
8472     \ifcase\paramno
8473     % 0
8474       \expandafter\xdef\csname\the\macname\endcsname{%
8475         \noexpand\scanmacro{\macrobody}}%
8476     \or % 1
8477       \expandafter\xdef\csname\the\macname\endcsname{%
8478          \bgroup
8479          \noexpand\braceorline
8480          \expandafter\noexpand\csname\the\macname @@@\endcsname}%
8481       \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8482         \egroup
8483         \noexpand\scanmacro{\macrobody}%
8484         }%
8485     \else % at most 9
8486       \ifnum\paramno<10\relax
8487         % @MACNAME sets the context for reading the macro argument
8488         % @MACNAME@@ gets the argument, processes backslashes and appends a 
8489         % comma.
8490         % @MACNAME@@@ removes braces surrounding the argument list.
8491         % @MACNAME@@@@ scans the macro body with arguments substituted.
8492         \expandafter\xdef\csname\the\macname\endcsname{%
8493           \bgroup
8494           \noexpand\expandafter  % This \expandafter skip any spaces after the
8495           \noexpand\macroargctxt % macro before we change the catcode of space.
8496           \noexpand\expandafter
8497           \expandafter\noexpand\csname\the\macname @@\endcsname}%
8498         \expandafter\xdef\csname\the\macname @@\endcsname##1{%
8499             \noexpand\passargtomacro
8500             \expandafter\noexpand\csname\the\macname @@@\endcsname{##1,}}%
8501         \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8502             \expandafter\noexpand\csname\the\macname @@@@\endcsname ##1}%
8503         \expandafter\expandafter
8504         \expandafter\xdef
8505         \expandafter\expandafter
8506           \csname\the\macname @@@@\endcsname\paramlist{%
8507             \egroup\noexpand\scanmacro{\macrobody}}%
8508       \else % 10 or more:
8509         \expandafter\xdef\csname\the\macname\endcsname{%
8510           \noexpand\getargvals@{\the\macname}{\argl}%
8511         }%
8512         \global\expandafter\let\csname mac.\the\macname .body\endcsname\macrobody
8513         \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\norecurse
8514       \fi
8515     \fi
8516   \fi}
8517
8518 \catcode `\@\texiatcatcode\relax % end private-to-Texinfo catcodes
8519
8520 \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
8521
8522
8523 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8524 %
8525 {\catcode`\@=0 \catcode`\\=13  % We need to manipulate \ so use @ as escape
8526 @catcode`@_=11  % private names
8527 @catcode`@!=11  % used as argument separator
8528
8529 % \passargtomacro#1#2 -
8530 % Call #1 with a list of tokens #2, with any doubled backslashes in #2
8531 % compressed to one.
8532 %
8533 % This implementation works by expansion, and not execution (so we cannot use 
8534 % \def or similar).  This reduces the risk of this failing in contexts where 
8535 % complete expansion is done with no execution (for example, in writing out to 
8536 % an auxiliary file for an index entry).
8537
8538 % State is kept in the input stream: the argument passed to
8539 % @look_ahead, @gobble_and_check_finish and @add_segment is
8540 %
8541 % THE_MACRO ARG_RESULT ! {PENDING_BS} NEXT_TOKEN  (... rest of input)
8542 %
8543 % where:
8544 % THE_MACRO - name of the macro we want to call
8545 % ARG_RESULT - argument list we build to pass to that macro
8546 % PENDING_BS - either a backslash or nothing
8547 % NEXT_TOKEN - used to look ahead in the input stream to see what's coming next
8548
8549 @gdef@passargtomacro#1#2{%
8550   @add_segment #1!{}@relax#2\@_finish\%
8551 }
8552 @gdef@_finish{@_finishx} @global@let@_finishx@relax
8553
8554 % #1 - THE_MACRO ARG_RESULT
8555 % #2 - PENDING_BS
8556 % #3 - NEXT_TOKEN
8557 % #4 used to look ahead
8558 %
8559 % If the next token is not a backslash, process the rest of the argument; 
8560 % otherwise, remove the next token.
8561 @gdef@look_ahead#1!#2#3#4{%
8562   @ifx#4\%
8563    @expandafter@gobble_and_check_finish 
8564   @else
8565    @expandafter@add_segment
8566   @fi#1!{#2}#4#4%
8567 }
8568
8569 % #1 - THE_MACRO ARG_RESULT
8570 % #2 - PENDING_BS
8571 % #3 - NEXT_TOKEN
8572 % #4 should be a backslash, which is gobbled.
8573 % #5 looks ahead
8574 %
8575 % Double backslash found.  Add a single backslash, and look ahead.
8576 @gdef@gobble_and_check_finish#1!#2#3#4#5{%
8577   @add_segment#1\!{}#5#5%
8578 }
8579
8580 @gdef@is_fi{@fi}
8581
8582 % #1 - THE_MACRO ARG_RESULT
8583 % #2 - PENDING_BS
8584 % #3 - NEXT_TOKEN
8585 % #4 is input stream until next backslash
8586 %
8587 % Input stream is either at the start of the argument, or just after a 
8588 % backslash sequence, either a lone backslash, or a doubled backslash.  
8589 % NEXT_TOKEN contains the first token in the input stream: if it is \finish, 
8590 % finish; otherwise, append to ARG_RESULT the segment of the argument up until
8591 % the next backslash.  PENDING_BACKSLASH contains a backslash to represent
8592 % a backslash just before the start of the input stream that has not been
8593 % added to ARG_RESULT.
8594 @gdef@add_segment#1!#2#3#4\{%
8595 @ifx#3@_finish
8596   @call_the_macro#1!%
8597 @else
8598   % append the pending backslash to the result, followed by the next segment
8599   @expandafter@is_fi@look_ahead#1#2#4!{\}@fi
8600   % this @fi is discarded by @look_ahead.
8601   % we can't get rid of it with \expandafter because we don't know how 
8602   % long #4 is.
8603 }
8604
8605 % #1 - THE_MACRO
8606 % #2 - ARG_RESULT
8607 % #3 discards the res of the conditional in @add_segment, and @is_fi ends the 
8608 % conditional.
8609 @gdef@call_the_macro#1#2!#3@fi{@is_fi #1{#2}}
8610
8611 }
8612 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8613
8614 % \braceorline MAC is used for a one-argument macro MAC.  It checks
8615 % whether the next non-whitespace character is a {.  It sets the context
8616 % for reading the argument (slightly different in the two cases).  Then,
8617 % to read the argument, in the whole-line case, it then calls the regular
8618 % \parsearg MAC; in the lbrace case, it calls \passargtomacro MAC.
8619
8620 \def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx}
8621 \def\braceorlinexxx{%
8622   \ifx\nchar\bgroup
8623     \macroargctxt
8624     \expandafter\passargtomacro
8625   \else
8626     \macrolineargctxt\expandafter\parsearg
8627   \fi \macnamexxx}
8628
8629
8630 % @alias.
8631 % We need some trickery to remove the optional spaces around the equal
8632 % sign.  Make them active and then expand them all to nothing.
8633 %
8634 \def\alias{\parseargusing\obeyspaces\aliasxxx}
8635 \def\aliasxxx #1{\aliasyyy#1\relax}
8636 \def\aliasyyy #1=#2\relax{%
8637   {%
8638     \expandafter\let\obeyedspace=\empty
8639     \addtomacrolist{#1}%
8640     \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}%
8641   }%
8642   \next
8643 }
8644
8645
8646 \message{cross references,}
8647
8648 \newwrite\auxfile
8649 \newif\ifhavexrefs    % True if xref values are known.
8650 \newif\ifwarnedxrefs  % True if we warned once that they aren't known.
8651
8652 % @inforef is relatively simple.
8653 \def\inforef #1{\inforefzzz #1,,,,**}
8654 \def\inforefzzz #1,#2,#3,#4**{%
8655   \putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
8656   node \samp{\ignorespaces#1{}}}
8657
8658 % @node's only job in TeX is to define \lastnode, which is used in
8659 % cross-references.  The @node line might or might not have commas, and
8660 % might or might not have spaces before the first comma, like:
8661 % @node foo , bar , ...
8662 % We don't want such trailing spaces in the node name.
8663 %
8664 \parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse}
8665 %
8666 % also remove a trailing comma, in case of something like this:
8667 % @node Help-Cross,  ,  , Cross-refs
8668 \def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse}
8669 \def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}}
8670
8671 \let\nwnode=\node
8672 \let\lastnode=\empty
8673
8674 % Write a cross-reference definition for the current node.  #1 is the
8675 % type (Ynumbered, Yappendix, Ynothing).
8676 %
8677 \def\donoderef#1{%
8678   \ifx\lastnode\empty\else
8679     \setref{\lastnode}{#1}%
8680     \global\let\lastnode=\empty
8681   \fi
8682 }
8683
8684 % @anchor{NAME} -- define xref target at arbitrary point.
8685 %
8686 \newcount\savesfregister
8687 %
8688 \def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi}
8689 \def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi}
8690 \def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces}
8691
8692 % \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an
8693 % anchor), which consists of three parts:
8694 % 1) NAME-title - the current sectioning name taken from \lastsection,
8695 %                 or the anchor name.
8696 % 2) NAME-snt   - section number and type, passed as the SNT arg, or
8697 %                 empty for anchors.
8698 % 3) NAME-pg    - the page number.
8699 %
8700 % This is called from \donoderef, \anchor, and \dofloat.  In the case of
8701 % floats, there is an additional part, which is not written here:
8702 % 4) NAME-lof   - the text as it should appear in a @listoffloats.
8703 %
8704 \def\setref#1#2{%
8705   \pdfmkdest{#1}%
8706   \iflinks
8707     {%
8708       \requireauxfile
8709       \atdummies  % preserve commands, but don't expand them
8710       \edef\writexrdef##1##2{%
8711         \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef
8712           ##1}{##2}}% these are parameters of \writexrdef
8713       }%
8714       \toks0 = \expandafter{\lastsection}%
8715       \immediate \writexrdef{title}{\the\toks0 }%
8716       \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc.
8717       \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout
8718     }%
8719   \fi
8720 }
8721
8722 % @xrefautosectiontitle on|off says whether @section(ing) names are used
8723 % automatically in xrefs, if the third arg is not explicitly specified.
8724 % This was provided as a "secret" @set xref-automatic-section-title
8725 % variable, now it's official.
8726
8727 \parseargdef\xrefautomaticsectiontitle{%
8728   \def\temp{#1}%
8729   \ifx\temp\onword
8730     \expandafter\let\csname SETxref-automatic-section-title\endcsname
8731       = \empty
8732   \else\ifx\temp\offword
8733     \expandafter\let\csname SETxref-automatic-section-title\endcsname
8734       = \relax
8735   \else
8736     \errhelp = \EMsimple
8737     \errmessage{Unknown @xrefautomaticsectiontitle value `\temp',
8738                 must be on|off}%
8739   \fi\fi
8740 }
8741
8742\f
8743 % @xref, @pxref, and @ref generate cross-references.  For \xrefX, #1 is
8744 % the node name, #2 the name of the Info cross-reference, #3 the printed
8745 % node name, #4 the name of the Info file, #5 the name of the printed
8746 % manual.  All but the node name can be omitted.
8747 %
8748 \def\pxref{\putwordsee{} \xrefXX}
8749 \def\xref{\putwordSee{} \xrefXX}
8750 \def\ref{\xrefXX}
8751
8752 \def\xrefXX#1{\def\xrefXXarg{#1}\futurelet\tokenafterxref\xrefXXX}
8753 \def\xrefXXX{\expandafter\xrefX\expandafter[\xrefXXarg,,,,,,,]}
8754 %
8755 \newbox\toprefbox
8756 \newbox\printedrefnamebox
8757 \newbox\infofilenamebox
8758 \newbox\printedmanualbox
8759 %
8760 \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
8761   \unsepspaces
8762   %
8763   % Get args without leading/trailing spaces.
8764   \def\printedrefname{\ignorespaces #3}%
8765   \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}%
8766   %
8767   \def\infofilename{\ignorespaces #4}%
8768   \setbox\infofilenamebox = \hbox{\infofilename\unskip}%
8769   %
8770   \def\printedmanual{\ignorespaces #5}%
8771   \setbox\printedmanualbox  = \hbox{\printedmanual\unskip}%
8772   %
8773   % If the printed reference name (arg #3) was not explicitly given in
8774   % the @xref, figure out what we want to use.
8775   \ifdim \wd\printedrefnamebox = 0pt
8776     % No printed node name was explicitly given.
8777     \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax
8778       % Not auto section-title: use node name inside the square brackets.
8779       \def\printedrefname{\ignorespaces #1}%
8780     \else
8781       % Auto section-title: use chapter/section title inside
8782       % the square brackets if we have it.
8783       \ifdim \wd\printedmanualbox > 0pt
8784         % It is in another manual, so we don't have it; use node name.
8785         \def\printedrefname{\ignorespaces #1}%
8786       \else
8787         \ifhavexrefs
8788           % We (should) know the real title if we have the xref values.
8789           \def\printedrefname{\refx{#1-title}{}}%
8790         \else
8791           % Otherwise just copy the Info node name.
8792           \def\printedrefname{\ignorespaces #1}%
8793         \fi%
8794       \fi
8795     \fi
8796   \fi
8797   %
8798   % Make link in pdf output.
8799   \ifpdf
8800     % For pdfTeX and LuaTeX
8801     {\indexnofonts
8802      \turnoffactive
8803      \makevalueexpandable
8804      % This expands tokens, so do it after making catcode changes, so _
8805      % etc. don't get their TeX definitions.  This ignores all spaces in
8806      % #4, including (wrongly) those in the middle of the filename.
8807      \getfilename{#4}%
8808      %
8809      % This (wrongly) does not take account of leading or trailing
8810      % spaces in #1, which should be ignored.
8811      \edef\pdfxrefdest{#1}%
8812      \ifx\pdfxrefdest\empty
8813        \def\pdfxrefdest{Top}% no empty targets
8814      \else
8815        \txiescapepdf\pdfxrefdest  % escape PDF special chars
8816      \fi
8817      %
8818      \leavevmode
8819      \startlink attr{/Border [0 0 0]}%
8820      \ifnum\filenamelength>0
8821        goto file{\the\filename.pdf} name{\pdfxrefdest}%
8822      \else
8823        goto name{\pdfmkpgn{\pdfxrefdest}}%
8824      \fi
8825     }%
8826     \setcolor{\linkcolor}%
8827   \else
8828     \ifx\XeTeXrevision\thisisundefined
8829     \else
8830       % For XeTeX
8831       {\indexnofonts
8832        \turnoffactive
8833        \makevalueexpandable
8834        % This expands tokens, so do it after making catcode changes, so _
8835        % etc. don't get their TeX definitions.  This ignores all spaces in
8836        % #4, including (wrongly) those in the middle of the filename.
8837        \getfilename{#4}%
8838        %
8839        % This (wrongly) does not take account of leading or trailing
8840        % spaces in #1, which should be ignored.
8841        \iftxiuseunicodedestname
8842          \def\pdfxrefdest{#1}% Pass through Unicode characters.
8843        \else
8844          \edef\pdfxrefdest{#1}% Replace Unicode characters to ASCII.
8845        \fi
8846        \ifx\pdfxrefdest\empty
8847          \def\pdfxrefdest{Top}% no empty targets
8848        \else
8849          \txiescapepdf\pdfxrefdest  % escape PDF special chars
8850        \fi
8851        %
8852        \leavevmode
8853        \ifnum\filenamelength>0
8854          % By the default settings,
8855          % XeTeX (xdvipdfmx) replaces link destination names with integers.
8856          % In this case, the replaced destination names of
8857          % remote PDF cannot be known. In order to avoid replacement,
8858          % you can use commandline option `-C 0x0010' for xdvipdfmx.
8859          \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A
8860            << /S /GoToR /F (\the\filename.pdf) /D (name\pdfxrefdest) >> >>}%
8861        \else
8862          \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A
8863            << /S /GoTo /D (name\pdfxrefdest) >> >>}%
8864        \fi
8865       }%
8866       \setcolor{\linkcolor}%
8867     \fi
8868   \fi
8869   {%
8870     % Have to otherify everything special to allow the \csname to
8871     % include an _ in the xref name, etc.
8872     \indexnofonts
8873     \turnoffactive
8874     \def\value##1{##1}%
8875     \expandafter\global\expandafter\let\expandafter\Xthisreftitle
8876       \csname XR#1-title\endcsname
8877   }%
8878   %
8879   % Float references are printed completely differently: "Figure 1.2"
8880   % instead of "[somenode], p.3".  \iffloat distinguishes them by
8881   % \Xthisreftitle being set to a magic string.
8882   \iffloat\Xthisreftitle
8883     % If the user specified the print name (third arg) to the ref,
8884     % print it instead of our usual "Figure 1.2".
8885     \ifdim\wd\printedrefnamebox = 0pt
8886       \refx{#1-snt}{}%
8887     \else
8888       \printedrefname
8889     \fi
8890     %
8891     % If the user also gave the printed manual name (fifth arg), append
8892     % "in MANUALNAME".
8893     \ifdim \wd\printedmanualbox > 0pt
8894       \space \putwordin{} \cite{\printedmanual}%
8895     \fi
8896   \else
8897     % node/anchor (non-float) references.
8898     % 
8899     % If we use \unhbox to print the node names, TeX does not insert
8900     % empty discretionaries after hyphens, which means that it will not
8901     % find a line break at a hyphen in a node names.  Since some manuals
8902     % are best written with fairly long node names, containing hyphens,
8903     % this is a loss.  Therefore, we give the text of the node name
8904     % again, so it is as if TeX is seeing it for the first time.
8905     % 
8906     \ifdim \wd\printedmanualbox > 0pt
8907       % Cross-manual reference with a printed manual name.
8908       % 
8909       \crossmanualxref{\cite{\printedmanual\unskip}}%
8910     %
8911     \else\ifdim \wd\infofilenamebox > 0pt
8912       % Cross-manual reference with only an info filename (arg 4), no
8913       % printed manual name (arg 5).  This is essentially the same as
8914       % the case above; we output the filename, since we have nothing else.
8915       % 
8916       \crossmanualxref{\code{\infofilename\unskip}}%
8917     %
8918     \else
8919       % Reference within this manual.
8920       %
8921       % _ (for example) has to be the character _ for the purposes of the
8922       % control sequence corresponding to the node, but it has to expand
8923       % into the usual \leavevmode...\vrule stuff for purposes of
8924       % printing. So we \turnoffactive for the \refx-snt, back on for the
8925       % printing, back off for the \refx-pg.
8926       {\turnoffactive
8927        % Only output a following space if the -snt ref is nonempty; for
8928        % @unnumbered and @anchor, it won't be.
8929        \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
8930        \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
8931       }%
8932       % output the `[mynode]' via the macro below so it can be overridden.
8933       \xrefprintnodename\printedrefname
8934       %
8935       % But we always want a comma and a space:
8936       ,\space
8937       %
8938       % output the `page 3'.
8939       \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
8940       % Add a , if xref followed by a space
8941       \if\space\noexpand\tokenafterxref ,%
8942       \else\ifx\        \tokenafterxref ,% @TAB
8943       \else\ifx\*\tokenafterxref ,%   @*
8944       \else\ifx\ \tokenafterxref ,%   @SPACE
8945       \else\ifx\
8946                 \tokenafterxref ,%    @NL
8947       \else\ifx\tie\tokenafterxref ,% @tie
8948       \fi\fi\fi\fi\fi\fi
8949     \fi\fi
8950   \fi
8951   \endlink
8952 \endgroup}
8953
8954 % Output a cross-manual xref to #1.  Used just above (twice).
8955
8956 % Only include the text "Section ``foo'' in" if the foo is neither
8957 % missing or Top.  Thus, @xref{,,,foo,The Foo Manual} outputs simply
8958 % "see The Foo Manual", the idea being to refer to the whole manual.
8959
8960 % But, this being TeX, we can't easily compare our node name against the
8961 % string "Top" while ignoring the possible spaces before and after in
8962 % the input.  By adding the arbitrary 7sp below, we make it much less
8963 % likely that a real node name would have the same width as "Top" (e.g.,
8964 % in a monospaced font).  Hopefully it will never happen in practice.
8965
8966 % For the same basic reason, we retypeset the "Top" at every
8967 % reference, since the current font is indeterminate.
8968
8969 \def\crossmanualxref#1{%
8970   \setbox\toprefbox = \hbox{Top\kern7sp}%
8971   \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}%
8972   \ifdim \wd2 > 7sp  % nonempty?
8973     \ifdim \wd2 = \wd\toprefbox \else  % same as Top?
8974       \putwordSection{} ``\printedrefname'' \putwordin{}\space
8975     \fi
8976   \fi
8977   #1%
8978 }
8979
8980 % This macro is called from \xrefX for the `[nodename]' part of xref
8981 % output.  It's a separate macro only so it can be changed more easily,
8982 % since square brackets don't work well in some documents.  Particularly
8983 % one that Bob is working on :).
8984 %
8985 \def\xrefprintnodename#1{[#1]}
8986
8987 % Things referred to by \setref.
8988 %
8989 \def\Ynothing{}
8990 \def\Yomitfromtoc{}
8991 \def\Ynumbered{%
8992   \ifnum\secno=0
8993     \putwordChapter@tie \the\chapno
8994   \else \ifnum\subsecno=0
8995     \putwordSection@tie \the\chapno.\the\secno
8996   \else \ifnum\subsubsecno=0
8997     \putwordSection@tie \the\chapno.\the\secno.\the\subsecno
8998   \else
8999     \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno
9000   \fi\fi\fi
9001 }
9002 \def\Yappendix{%
9003   \ifnum\secno=0
9004      \putwordAppendix@tie @char\the\appendixno{}%
9005   \else \ifnum\subsecno=0
9006      \putwordSection@tie @char\the\appendixno.\the\secno
9007   \else \ifnum\subsubsecno=0
9008     \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno
9009   \else
9010     \putwordSection@tie
9011       @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno
9012   \fi\fi\fi
9013 }
9014
9015 % \refx{NAME}{SUFFIX} - reference a cross-reference string named NAME.  SUFFIX 
9016 % is output afterwards if non-empty.
9017 \def\refx#1#2{%
9018   \requireauxfile
9019   {%
9020     \indexnofonts
9021     \otherbackslash
9022     \def\value##1{##1}%
9023     \expandafter\global\expandafter\let\expandafter\thisrefX
9024       \csname XR#1\endcsname
9025   }%
9026   \ifx\thisrefX\relax
9027     % If not defined, say something at least.
9028     \angleleft un\-de\-fined\angleright
9029     \iflinks
9030       \ifhavexrefs
9031         {\toks0 = {#1}% avoid expansion of possibly-complex value
9032          \message{\linenumber Undefined cross reference `\the\toks0'.}}%
9033       \else
9034         \ifwarnedxrefs\else
9035           \global\warnedxrefstrue
9036           \message{Cross reference values unknown; you must run TeX again.}%
9037         \fi
9038       \fi
9039     \fi
9040   \else
9041     % It's defined, so just use it.
9042     \thisrefX
9043   \fi
9044   #2% Output the suffix in any case.
9045 }
9046
9047 % This is the macro invoked by entries in the aux file.  Define a control 
9048 % sequence for a cross-reference target (we prepend XR to the control sequence 
9049 % name to avoid collisions).  The value is the page number.  If this is a float 
9050 % type, we have more work to do.
9051 %
9052 \def\xrdef#1#2{%
9053   {% Expand the node or anchor name to remove control sequences.
9054    % \turnoffactive stops 8-bit characters being changed to commands
9055    % like @'e.  \refx does the same to retrieve the value in the definition.
9056     \indexnofonts
9057     \turnoffactive
9058     \def\value##1{##1}%
9059     \xdef\safexrefname{#1}%
9060   }%
9061   %
9062   \expandafter\gdef\csname XR\safexrefname\endcsname{#2}% remember this xref
9063   %
9064   % Was that xref control sequence that we just defined for a float?
9065   \expandafter\iffloat\csname XR\safexrefname\endcsname
9066     % it was a float, and we have the (safe) float type in \iffloattype.
9067     \expandafter\let\expandafter\floatlist
9068       \csname floatlist\iffloattype\endcsname
9069     %
9070     % Is this the first time we've seen this float type?
9071     \expandafter\ifx\floatlist\relax
9072       \toks0 = {\do}% yes, so just \do
9073     \else
9074       % had it before, so preserve previous elements in list.
9075       \toks0 = \expandafter{\floatlist\do}%
9076     \fi
9077     %
9078     % Remember this xref in the control sequence \floatlistFLOATTYPE,
9079     % for later use in \listoffloats.
9080     \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0
9081       {\safexrefname}}%
9082   \fi
9083 }
9084
9085 % If working on a large document in chapters, it is convenient to
9086 % be able to disable indexing, cross-referencing, and contents, for test runs.
9087 % This is done with @novalidate at the beginning of the file.
9088 %
9089 \newif\iflinks \linkstrue % by default we want the aux files.
9090 \let\novalidate = \linksfalse
9091
9092 % Used when writing to the aux file, or when using data from it.
9093 \def\requireauxfile{%
9094   \iflinks
9095     \tryauxfile
9096     % Open the new aux file.  TeX will close it automatically at exit.
9097     \immediate\openout\auxfile=\jobname.aux
9098   \fi
9099   \global\let\requireauxfile=\relax   % Only do this once.
9100 }
9101
9102 % Read the last existing aux file, if any.  No error if none exists.
9103 %
9104 \def\tryauxfile{%
9105   \openin 1 \jobname.aux
9106   \ifeof 1 \else
9107     \readdatafile{aux}%
9108     \global\havexrefstrue
9109   \fi
9110   \closein 1
9111 }
9112
9113 \def\setupdatafile{%
9114   \catcode`\^^@=\other
9115   \catcode`\^^A=\other
9116   \catcode`\^^B=\other
9117   \catcode`\^^C=\other
9118   \catcode`\^^D=\other
9119   \catcode`\^^E=\other
9120   \catcode`\^^F=\other
9121   \catcode`\^^G=\other
9122   \catcode`\^^H=\other
9123   \catcode`\^^K=\other
9124   \catcode`\^^L=\other
9125   \catcode`\^^N=\other
9126   \catcode`\^^P=\other
9127   \catcode`\^^Q=\other
9128   \catcode`\^^R=\other
9129   \catcode`\^^S=\other
9130   \catcode`\^^T=\other
9131   \catcode`\^^U=\other
9132   \catcode`\^^V=\other
9133   \catcode`\^^W=\other
9134   \catcode`\^^X=\other
9135   \catcode`\^^Z=\other
9136   \catcode`\^^[=\other
9137   \catcode`\^^\=\other
9138   \catcode`\^^]=\other
9139   \catcode`\^^^=\other
9140   \catcode`\^^_=\other
9141   % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc.
9142   % in xref tags, i.e., node names.  But since ^^e4 notation isn't
9143   % supported in the main text, it doesn't seem desirable.  Furthermore,
9144   % that is not enough: for node names that actually contain a ^
9145   % character, we would end up writing a line like this: 'xrdef {'hat
9146   % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first
9147   % argument, and \hat is not an expandable control sequence.  It could
9148   % all be worked out, but why?  Either we support ^^ or we don't.
9149   %
9150   % The other change necessary for this was to define \auxhat:
9151   % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter
9152   % and then to call \auxhat in \setq.
9153   %
9154   \catcode`\^=\other
9155   %
9156   % Special characters.  Should be turned off anyway, but...
9157   \catcode`\~=\other
9158   \catcode`\[=\other
9159   \catcode`\]=\other
9160   \catcode`\"=\other
9161   \catcode`\_=\other
9162   \catcode`\|=\other
9163   \catcode`\<=\other
9164   \catcode`\>=\other
9165   \catcode`\$=\other
9166   \catcode`\#=\other
9167   \catcode`\&=\other
9168   \catcode`\%=\other
9169   \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
9170   %
9171   % This is to support \ in node names and titles, since the \
9172   % characters end up in a \csname.  It's easier than
9173   % leaving it active and making its active definition an actual \
9174   % character.  What I don't understand is why it works in the *value*
9175   % of the xrdef.  Seems like it should be a catcode12 \, and that
9176   % should not typeset properly.  But it works, so I'm moving on for
9177   % now.  --karl, 15jan04.
9178   \catcode`\\=\other
9179   %
9180   % @ is our escape character in .aux files, and we need braces.
9181   \catcode`\{=1
9182   \catcode`\}=2
9183   \catcode`\@=0
9184 }
9185
9186 \def\readdatafile#1{%
9187 \begingroup
9188   \setupdatafile
9189   \input\jobname.#1
9190 \endgroup}
9191
9192
9193 \message{insertions,}
9194 % including footnotes.
9195
9196 \newcount \footnoteno
9197
9198 % The trailing space in the following definition for supereject is
9199 % vital for proper filling; pages come out unaligned when you do a
9200 % pagealignmacro call if that space before the closing brace is
9201 % removed. (Generally, numeric constants should always be followed by a
9202 % space to prevent strange expansion errors.)
9203 \def\supereject{\par\penalty -20000\footnoteno =0 }
9204
9205 % @footnotestyle is meaningful for Info output only.
9206 \let\footnotestyle=\comment
9207
9208 {\catcode `\@=11
9209 %
9210 % Auto-number footnotes.  Otherwise like plain.
9211 \gdef\footnote{%
9212   \global\advance\footnoteno by \@ne
9213   \edef\thisfootno{$^{\the\footnoteno}$}%
9214   %
9215   % In case the footnote comes at the end of a sentence, preserve the
9216   % extra spacing after we do the footnote number.
9217   \let\@sf\empty
9218   \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi
9219   %
9220   % Remove inadvertent blank space before typesetting the footnote number.
9221   \unskip
9222   \thisfootno\@sf
9223   \dofootnote
9224 }%
9225
9226 % Don't bother with the trickery in plain.tex to not require the
9227 % footnote text as a parameter.  Our footnotes don't need to be so general.
9228 %
9229 % Oh yes, they do; otherwise, @ifset (and anything else that uses
9230 % \parseargline) fails inside footnotes because the tokens are fixed when
9231 % the footnote is read.  --karl, 16nov96.
9232 %
9233 \gdef\dofootnote{%
9234   \insert\footins\bgroup
9235   %
9236   % Nested footnotes are not supported in TeX, that would take a lot
9237   % more work.  (\startsavinginserts does not suffice.)
9238   \let\footnote=\errfootnotenest
9239   %
9240   % We want to typeset this text as a normal paragraph, even if the
9241   % footnote reference occurs in (for example) a display environment.
9242   % So reset some parameters.
9243   \hsize=\txipagewidth
9244   \interlinepenalty\interfootnotelinepenalty
9245   \splittopskip\ht\strutbox % top baseline for broken footnotes
9246   \splitmaxdepth\dp\strutbox
9247   \floatingpenalty\@MM
9248   \leftskip\z@skip
9249   \rightskip\z@skip
9250   \spaceskip\z@skip
9251   \xspaceskip\z@skip
9252   \parindent\defaultparindent
9253   %
9254   \smallfonts \rm
9255   %
9256   % Because we use hanging indentation in footnotes, a @noindent appears
9257   % to exdent this text, so make it be a no-op.  makeinfo does not use
9258   % hanging indentation so @noindent can still be needed within footnote
9259   % text after an @example or the like (not that this is good style).
9260   \let\noindent = \relax
9261   %
9262   % Hang the footnote text off the number.  Use \everypar in case the
9263   % footnote extends for more than one paragraph.
9264   \everypar = {\hang}%
9265   \textindent{\thisfootno}%
9266   %
9267   % Don't crash into the line above the footnote text.  Since this
9268   % expands into a box, it must come within the paragraph, lest it
9269   % provide a place where TeX can split the footnote.
9270   \footstrut
9271   %
9272   % Invoke rest of plain TeX footnote routine.
9273   \futurelet\next\fo@t
9274 }
9275 }%end \catcode `\@=11
9276
9277 \def\errfootnotenest{%
9278   \errhelp=\EMsimple
9279   \errmessage{Nested footnotes not supported in texinfo.tex,
9280     even though they work in makeinfo; sorry}
9281 }
9282
9283 \def\errfootnoteheading{%
9284   \errhelp=\EMsimple
9285   \errmessage{Footnotes in chapters, sections, etc., are not supported}
9286 }
9287
9288 % In case a @footnote appears in a vbox, save the footnote text and create
9289 % the real \insert just after the vbox finished.  Otherwise, the insertion
9290 % would be lost.
9291 % Similarly, if a @footnote appears inside an alignment, save the footnote
9292 % text to a box and make the \insert when a row of the table is finished.
9293 % And the same can be done for other insert classes.  --kasal, 16nov03.
9294 %
9295 % Replace the \insert primitive by a cheating macro.
9296 % Deeper inside, just make sure that the saved insertions are not spilled
9297 % out prematurely.
9298 %
9299 \def\startsavinginserts{%
9300   \ifx \insert\ptexinsert
9301     \let\insert\saveinsert
9302   \else
9303     \let\checkinserts\relax
9304   \fi
9305 }
9306
9307 % This \insert replacement works for both \insert\footins{foo} and
9308 % \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}.
9309 %
9310 \def\saveinsert#1{%
9311   \edef\next{\noexpand\savetobox \makeSAVEname#1}%
9312   \afterassignment\next
9313   % swallow the left brace
9314   \let\temp =
9315 }
9316 \def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}}
9317 \def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1}
9318
9319 \def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi}
9320
9321 \def\placesaveins#1{%
9322   \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname
9323     {\box#1}%
9324 }
9325
9326 % eat @SAVE -- beware, all of them have catcode \other:
9327 {
9328   \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials  %  ;-)
9329   \gdef\gobblesave @SAVE{}
9330 }
9331
9332 % initialization:
9333 \def\newsaveins #1{%
9334   \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}%
9335   \next
9336 }
9337 \def\newsaveinsX #1{%
9338   \csname newbox\endcsname #1%
9339   \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts
9340     \checksaveins #1}%
9341 }
9342
9343 % initialize:
9344 \let\checkinserts\empty
9345 \newsaveins\footins
9346 \newsaveins\margin
9347
9348
9349 % @image.  We use the macros from epsf.tex to support this.
9350 % If epsf.tex is not installed and @image is used, we complain.
9351 %
9352 % Check for and read epsf.tex up front.  If we read it only at @image
9353 % time, we might be inside a group, and then its definitions would get
9354 % undone and the next image would fail.
9355 \openin 1 = epsf.tex
9356 \ifeof 1 \else
9357   % Do not bother showing banner with epsf.tex v2.7k (available in
9358   % doc/epsf.tex and on ctan).
9359   \def\epsfannounce{\toks0 = }%
9360   \input epsf.tex
9361 \fi
9362 \closein 1
9363 %
9364 % We will only complain once about lack of epsf.tex.
9365 \newif\ifwarnednoepsf
9366 \newhelp\noepsfhelp{epsf.tex must be installed for images to
9367   work.  It is also included in the Texinfo distribution, or you can get
9368   it from ftp://tug.org/tex/epsf.tex.}
9369 %
9370 \def\image#1{%
9371   \ifx\epsfbox\thisisundefined
9372     \ifwarnednoepsf \else
9373       \errhelp = \noepsfhelp
9374       \errmessage{epsf.tex not found, images will be ignored}%
9375       \global\warnednoepsftrue
9376     \fi
9377   \else
9378     \imagexxx #1,,,,,\finish
9379   \fi
9380 }
9381 %
9382 % Arguments to @image:
9383 % #1 is (mandatory) image filename; we tack on .eps extension.
9384 % #2 is (optional) width, #3 is (optional) height.
9385 % #4 is (ignored optional) html alt text.
9386 % #5 is (ignored optional) extension.
9387 % #6 is just the usual extra ignored arg for parsing stuff.
9388 \newif\ifimagevmode
9389 \def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup
9390   \catcode`\^^M = 5     % in case we're inside an example
9391   \normalturnoffactive  % allow _ et al. in names
9392   \def\xprocessmacroarg{\eatspaces}% in case we are being used via a macro
9393   % If the image is by itself, center it.
9394   \ifvmode
9395     \imagevmodetrue
9396   \else \ifx\centersub\centerV
9397     % for @center @image, we need a vbox so we can have our vertical space
9398     \imagevmodetrue
9399     \vbox\bgroup % vbox has better behavior than vtop herev
9400   \fi\fi
9401   %
9402   \ifimagevmode
9403     \nobreak\medskip
9404     % Usually we'll have text after the image which will insert
9405     % \parskip glue, so insert it here too to equalize the space
9406     % above and below.
9407     \nobreak\vskip\parskip
9408     \nobreak
9409   \fi
9410   %
9411   % Leave vertical mode so that indentation from an enclosing
9412   %  environment such as @quotation is respected.
9413   % However, if we're at the top level, we don't want the
9414   %  normal paragraph indentation.
9415   % On the other hand, if we are in the case of @center @image, we don't
9416   %  want to start a paragraph, which will create a hsize-width box and
9417   %  eradicate the centering.
9418   \ifx\centersub\centerV\else \noindent \fi
9419   %
9420   % Output the image.
9421   \ifpdf
9422     % For pdfTeX and LuaTeX <= 0.80
9423     \dopdfimage{#1}{#2}{#3}%
9424   \else
9425     \ifx\XeTeXrevision\thisisundefined
9426       % For epsf.tex
9427       % \epsfbox itself resets \epsf?size at each figure.
9428       \setbox0 = \hbox{\ignorespaces #2}%
9429         \ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
9430       \setbox0 = \hbox{\ignorespaces #3}%
9431         \ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
9432       \epsfbox{#1.eps}%
9433     \else
9434       % For XeTeX
9435       \doxeteximage{#1}{#2}{#3}%
9436     \fi
9437   \fi
9438   %
9439   \ifimagevmode
9440     \medskip  % space after a standalone image
9441   \fi  
9442   \ifx\centersub\centerV \egroup \fi
9443 \endgroup}
9444
9445
9446 % @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables,
9447 % etc.  We don't actually implement floating yet, we always include the
9448 % float "here".  But it seemed the best name for the future.
9449 %
9450 \envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish}
9451
9452 % There may be a space before second and/or third parameter; delete it.
9453 \def\eatcommaspace#1, {#1,}
9454
9455 % #1 is the optional FLOATTYPE, the text label for this float, typically
9456 % "Figure", "Table", "Example", etc.  Can't contain commas.  If omitted,
9457 % this float will not be numbered and cannot be referred to.
9458 %
9459 % #2 is the optional xref label.  Also must be present for the float to
9460 % be referable.
9461 %
9462 % #3 is the optional positioning argument; for now, it is ignored.  It
9463 % will somehow specify the positions allowed to float to (here, top, bottom).
9464 %
9465 % We keep a separate counter for each FLOATTYPE, which we reset at each
9466 % chapter-level command.
9467 \let\resetallfloatnos=\empty
9468 %
9469 \def\dofloat#1,#2,#3,#4\finish{%
9470   \let\thiscaption=\empty
9471   \let\thisshortcaption=\empty
9472   %
9473   % don't lose footnotes inside @float.
9474   %
9475   % BEWARE: when the floats start float, we have to issue warning whenever an
9476   % insert appears inside a float which could possibly float. --kasal, 26may04
9477   %
9478   \startsavinginserts
9479   %
9480   % We can't be used inside a paragraph.
9481   \par
9482   %
9483   \vtop\bgroup
9484     \def\floattype{#1}%
9485     \def\floatlabel{#2}%
9486     \def\floatloc{#3}% we do nothing with this yet.
9487     %
9488     \ifx\floattype\empty
9489       \let\safefloattype=\empty
9490     \else
9491       {%
9492         % the floattype might have accents or other special characters,
9493         % but we need to use it in a control sequence name.
9494         \indexnofonts
9495         \turnoffactive
9496         \xdef\safefloattype{\floattype}%
9497       }%
9498     \fi
9499     %
9500     % If label is given but no type, we handle that as the empty type.
9501     \ifx\floatlabel\empty \else
9502       % We want each FLOATTYPE to be numbered separately (Figure 1,
9503       % Table 1, Figure 2, ...).  (And if no label, no number.)
9504       %
9505       \expandafter\getfloatno\csname\safefloattype floatno\endcsname
9506       \global\advance\floatno by 1
9507       %
9508       {%
9509         % This magic value for \lastsection is output by \setref as the
9510         % XREFLABEL-title value.  \xrefX uses it to distinguish float
9511         % labels (which have a completely different output format) from
9512         % node and anchor labels.  And \xrdef uses it to construct the
9513         % lists of floats.
9514         %
9515         \edef\lastsection{\floatmagic=\safefloattype}%
9516         \setref{\floatlabel}{Yfloat}%
9517       }%
9518     \fi
9519     %
9520     % start with \parskip glue, I guess.
9521     \vskip\parskip
9522     %
9523     % Don't suppress indentation if a float happens to start a section.
9524     \restorefirstparagraphindent
9525 }
9526
9527 % we have these possibilities:
9528 % @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap
9529 % @float Foo,lbl & no caption:    Foo 1.1
9530 % @float Foo & @caption{Cap}:     Foo: Cap
9531 % @float Foo & no caption:        Foo
9532 % @float ,lbl & Caption{Cap}:     1.1: Cap
9533 % @float ,lbl & no caption:       1.1
9534 % @float & @caption{Cap}:         Cap
9535 % @float & no caption:
9536 %
9537 \def\Efloat{%
9538     \let\floatident = \empty
9539     %
9540     % In all cases, if we have a float type, it comes first.
9541     \ifx\floattype\empty \else \def\floatident{\floattype}\fi
9542     %
9543     % If we have an xref label, the number comes next.
9544     \ifx\floatlabel\empty \else
9545       \ifx\floattype\empty \else % if also had float type, need tie first.
9546         \appendtomacro\floatident{\tie}%
9547       \fi
9548       % the number.
9549       \appendtomacro\floatident{\chaplevelprefix\the\floatno}%
9550     \fi
9551     %
9552     % Start the printed caption with what we've constructed in
9553     % \floatident, but keep it separate; we need \floatident again.
9554     \let\captionline = \floatident
9555     %
9556     \ifx\thiscaption\empty \else
9557       \ifx\floatident\empty \else
9558         \appendtomacro\captionline{: }% had ident, so need a colon between
9559       \fi
9560       %
9561       % caption text.
9562       \appendtomacro\captionline{\scanexp\thiscaption}%
9563     \fi
9564     %
9565     % If we have anything to print, print it, with space before.
9566     % Eventually this needs to become an \insert.
9567     \ifx\captionline\empty \else
9568       \vskip.5\parskip
9569       \captionline
9570       %
9571       % Space below caption.
9572       \vskip\parskip
9573     \fi
9574     %
9575     % If have an xref label, write the list of floats info.  Do this
9576     % after the caption, to avoid chance of it being a breakpoint.
9577     \ifx\floatlabel\empty \else
9578       % Write the text that goes in the lof to the aux file as
9579       % \floatlabel-lof.  Besides \floatident, we include the short
9580       % caption if specified, else the full caption if specified, else nothing.
9581       {%
9582         \requireauxfile
9583         \atdummies
9584         %
9585         \ifx\thisshortcaption\empty
9586           \def\gtemp{\thiscaption}%
9587         \else
9588           \def\gtemp{\thisshortcaption}%
9589         \fi
9590         \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident
9591           \ifx\gtemp\empty \else : \gtemp \fi}}%
9592       }%
9593     \fi
9594   \egroup  % end of \vtop
9595   %
9596   \checkinserts
9597 }
9598
9599 % Append the tokens #2 to the definition of macro #1, not expanding either.
9600 %
9601 \def\appendtomacro#1#2{%
9602   \expandafter\def\expandafter#1\expandafter{#1#2}%
9603 }
9604
9605 % @caption, @shortcaption
9606 %
9607 \def\caption{\docaption\thiscaption}
9608 \def\shortcaption{\docaption\thisshortcaption}
9609 \def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption}
9610 \def\defcaption#1#2{\egroup \def#1{#2}}
9611
9612 % The parameter is the control sequence identifying the counter we are
9613 % going to use.  Create it if it doesn't exist and assign it to \floatno.
9614 \def\getfloatno#1{%
9615   \ifx#1\relax
9616       % Haven't seen this figure type before.
9617       \csname newcount\endcsname #1%
9618       %
9619       % Remember to reset this floatno at the next chap.
9620       \expandafter\gdef\expandafter\resetallfloatnos
9621         \expandafter{\resetallfloatnos #1=0 }%
9622   \fi
9623   \let\floatno#1%
9624 }
9625
9626 % \setref calls this to get the XREFLABEL-snt value.  We want an @xref
9627 % to the FLOATLABEL to expand to "Figure 3.1".  We call \setref when we
9628 % first read the @float command.
9629 %
9630 \def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}%
9631
9632 % Magic string used for the XREFLABEL-title value, so \xrefX can
9633 % distinguish floats from other xref types.
9634 \def\floatmagic{!!float!!}
9635
9636 % #1 is the control sequence we are passed; we expand into a conditional
9637 % which is true if #1 represents a float ref.  That is, the magic
9638 % \lastsection value which we \setref above.
9639 %
9640 \def\iffloat#1{\expandafter\doiffloat#1==\finish}
9641 %
9642 % #1 is (maybe) the \floatmagic string.  If so, #2 will be the
9643 % (safe) float type for this float.  We set \iffloattype to #2.
9644 %
9645 \def\doiffloat#1=#2=#3\finish{%
9646   \def\temp{#1}%
9647   \def\iffloattype{#2}%
9648   \ifx\temp\floatmagic
9649 }
9650
9651 % @listoffloats FLOATTYPE - print a list of floats like a table of contents.
9652 %
9653 \parseargdef\listoffloats{%
9654   \def\floattype{#1}% floattype
9655   {%
9656     % the floattype might have accents or other special characters,
9657     % but we need to use it in a control sequence name.
9658     \indexnofonts
9659     \turnoffactive
9660     \xdef\safefloattype{\floattype}%
9661   }%
9662   %
9663   % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE.
9664   \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax
9665     \ifhavexrefs
9666       % if the user said @listoffloats foo but never @float foo.
9667       \message{\linenumber No `\safefloattype' floats to list.}%
9668     \fi
9669   \else
9670     \begingroup
9671       \leftskip=\tocindent  % indent these entries like a toc
9672       \let\do=\listoffloatsdo
9673       \csname floatlist\safefloattype\endcsname
9674     \endgroup
9675   \fi
9676 }
9677
9678 % This is called on each entry in a list of floats.  We're passed the
9679 % xref label, in the form LABEL-title, which is how we save it in the
9680 % aux file.  We strip off the -title and look up \XRLABEL-lof, which
9681 % has the text we're supposed to typeset here.
9682 %
9683 % Figures without xref labels will not be included in the list (since
9684 % they won't appear in the aux file).
9685 %
9686 \def\listoffloatsdo#1{\listoffloatsdoentry#1\finish}
9687 \def\listoffloatsdoentry#1-title\finish{{%
9688   % Can't fully expand XR#1-lof because it can contain anything.  Just
9689   % pass the control sequence.  On the other hand, XR#1-pg is just the
9690   % page number, and we want to fully expand that so we can get a link
9691   % in pdf output.
9692   \toksA = \expandafter{\csname XR#1-lof\endcsname}%
9693   %
9694   % use the same \entry macro we use to generate the TOC and index.
9695   \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}%
9696   \writeentry
9697 }}
9698
9699
9700 \message{localization,}
9701
9702 % For single-language documents, @documentlanguage is usually given very
9703 % early, just after @documentencoding.  Single argument is the language
9704 % (de) or locale (de_DE) abbreviation.
9705 %
9706 {
9707   \catcode`\_ = \active
9708   \globaldefs=1
9709 \parseargdef\documentlanguage{%
9710   \tex % read txi-??.tex file in plain TeX.
9711     % Read the file by the name they passed if it exists.
9712     \let_ = \normalunderscore  % normal _ character for filename test
9713     \openin 1 txi-#1.tex
9714     \ifeof 1
9715       \documentlanguagetrywithoutunderscore #1_\finish
9716     \else
9717       \globaldefs = 1  % everything in the txi-LL files needs to persist
9718       \input txi-#1.tex
9719     \fi
9720     \closein 1
9721   \endgroup % end raw TeX
9722 }
9723 %
9724 % If they passed de_DE, and txi-de_DE.tex doesn't exist,
9725 % try txi-de.tex.
9726 %
9727 \gdef\documentlanguagetrywithoutunderscore#1_#2\finish{%
9728   \openin 1 txi-#1.tex
9729   \ifeof 1
9730     \errhelp = \nolanghelp
9731     \errmessage{Cannot read language file txi-#1.tex}%
9732   \else
9733     \globaldefs = 1  % everything in the txi-LL files needs to persist
9734     \input txi-#1.tex
9735   \fi
9736   \closein 1
9737 }
9738 }% end of special _ catcode
9739 %
9740 \newhelp\nolanghelp{The given language definition file cannot be found or
9741 is empty.  Maybe you need to install it?  Putting it in the current
9742 directory should work if nowhere else does.}
9743
9744 % This macro is called from txi-??.tex files; the first argument is the
9745 % \language name to set (without the "\lang@" prefix), the second and
9746 % third args are \{left,right}hyphenmin.
9747 %
9748 % The language names to pass are determined when the format is built.
9749 % See the etex.log file created at that time, e.g.,
9750 % /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log.
9751 %
9752 % With TeX Live 2008, etex now includes hyphenation patterns for all
9753 % available languages.  This means we can support hyphenation in
9754 % Texinfo, at least to some extent.  (This still doesn't solve the
9755 % accented characters problem.)
9756 %
9757 \catcode`@=11
9758 \def\txisetlanguage#1#2#3{%
9759   % do not set the language if the name is undefined in the current TeX.
9760   \expandafter\ifx\csname lang@#1\endcsname \relax
9761     \message{no patterns for #1}%
9762   \else
9763     \global\language = \csname lang@#1\endcsname
9764   \fi
9765   % but there is no harm in adjusting the hyphenmin values regardless.
9766   \global\lefthyphenmin = #2\relax
9767   \global\righthyphenmin = #3\relax
9768 }
9769
9770 % XeTeX and LuaTeX can handle native Unicode.
9771 % Their default I/O is UTF-8 sequence instead of byte-wise.
9772 % Other TeX engine (pdfTeX etc.) I/O is byte-wise.
9773 %
9774 \newif\iftxinativeunicodecapable
9775 \newif\iftxiusebytewiseio
9776
9777 \ifx\XeTeXrevision\thisisundefined
9778   \ifx\luatexversion\thisisundefined
9779     \txinativeunicodecapablefalse
9780     \txiusebytewiseiotrue
9781   \else
9782     \txinativeunicodecapabletrue
9783     \txiusebytewiseiofalse
9784   \fi
9785 \else
9786   \txinativeunicodecapabletrue
9787   \txiusebytewiseiofalse
9788 \fi
9789
9790 % Set I/O by bytes instead of UTF-8 sequence for XeTeX and LuaTex
9791 % for non-UTF-8 (byte-wise) encodings.
9792 %
9793 \def\setbytewiseio{%
9794   \ifx\XeTeXrevision\thisisundefined
9795   \else
9796     \XeTeXdefaultencoding "bytes"  % For subsequent files to be read
9797     \XeTeXinputencoding "bytes"  % For document root file
9798     % Unfortunately, there seems to be no corresponding XeTeX command for
9799     % output encoding.  This is a problem for auxiliary index and TOC files.
9800     % The only solution would be perhaps to write out @U{...} sequences in
9801     % place of non-ASCII characters.
9802   \fi
9803
9804   \ifx\luatexversion\thisisundefined
9805   \else
9806     \directlua{
9807     local utf8_char, byte, gsub = unicode.utf8.char, string.byte, string.gsub
9808     local function convert_char (char)
9809       return utf8_char(byte(char))
9810     end
9811
9812     local function convert_line (line)
9813       return gsub(line, ".", convert_char)
9814     end
9815
9816     callback.register("process_input_buffer", convert_line)
9817
9818     local function convert_line_out (line)
9819       local line_out = ""
9820       for c in string.utfvalues(line) do
9821          line_out = line_out .. string.char(c)
9822       end
9823       return line_out
9824     end
9825
9826     callback.register("process_output_buffer", convert_line_out)
9827     }
9828   \fi
9829
9830   \txiusebytewiseiotrue
9831 }
9832
9833
9834 % Helpers for encodings.
9835 % Set the catcode of characters 128 through 255 to the specified number.
9836 %
9837 \def\setnonasciicharscatcode#1{%
9838    \count255=128
9839    \loop\ifnum\count255<256
9840       \global\catcode\count255=#1\relax
9841       \advance\count255 by 1
9842    \repeat
9843 }
9844
9845 \def\setnonasciicharscatcodenonglobal#1{%
9846    \count255=128
9847    \loop\ifnum\count255<256
9848       \catcode\count255=#1\relax
9849       \advance\count255 by 1
9850    \repeat
9851 }
9852
9853 % @documentencoding sets the definition of non-ASCII characters
9854 % according to the specified encoding.
9855 %
9856 \def\documentencoding{\parseargusing\filenamecatcodes\documentencodingzzz}
9857 \def\documentencodingzzz#1{%
9858   %
9859   % Encoding being declared for the document.
9860   \def\declaredencoding{\csname #1.enc\endcsname}%
9861   %
9862   % Supported encodings: names converted to tokens in order to be able
9863   % to compare them with \ifx.
9864   \def\ascii{\csname US-ASCII.enc\endcsname}%
9865   \def\latnine{\csname ISO-8859-15.enc\endcsname}%
9866   \def\latone{\csname ISO-8859-1.enc\endcsname}%
9867   \def\lattwo{\csname ISO-8859-2.enc\endcsname}%
9868   \def\utfeight{\csname UTF-8.enc\endcsname}%
9869   %
9870   \ifx \declaredencoding \ascii
9871      \asciichardefs
9872   %
9873   \else \ifx \declaredencoding \lattwo
9874      \iftxinativeunicodecapable
9875        \setbytewiseio
9876      \fi
9877      \setnonasciicharscatcode\active
9878      \lattwochardefs
9879   %
9880   \else \ifx \declaredencoding \latone
9881      \iftxinativeunicodecapable
9882        \setbytewiseio
9883      \fi
9884      \setnonasciicharscatcode\active
9885      \latonechardefs
9886   %
9887   \else \ifx \declaredencoding \latnine
9888      \iftxinativeunicodecapable
9889        \setbytewiseio
9890      \fi
9891      \setnonasciicharscatcode\active
9892      \latninechardefs
9893   %
9894   \else \ifx \declaredencoding \utfeight
9895      \iftxinativeunicodecapable
9896        % For native Unicode (XeTeX and LuaTeX)
9897        \nativeunicodechardefs
9898      \else
9899        % For UTF-8 byte sequence (TeX, eTeX and pdfTeX)
9900        \setnonasciicharscatcode\active
9901        % since we already invoked \utfeightchardefs at the top level
9902        % (below), do not re-invoke it, then our check for duplicated
9903        % definitions triggers.  Making non-ascii chars active is enough.
9904      \fi
9905   %
9906   \else
9907     \message{Ignoring unknown document encoding: #1.}%
9908   %
9909   \fi % utfeight
9910   \fi % latnine
9911   \fi % latone
9912   \fi % lattwo
9913   \fi % ascii
9914 }
9915
9916 % emacs-page
9917 % A message to be logged when using a character that isn't available
9918 % the default font encoding (OT1).
9919 %
9920 \def\missingcharmsg#1{\message{Character missing, sorry: #1.}}
9921
9922 % Take account of \c (plain) vs. \, (Texinfo) difference.
9923 \def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi}
9924
9925 % First, make active non-ASCII characters in order for them to be
9926 % correctly categorized when TeX reads the replacement text of
9927 % macros containing the character definitions.
9928 \setnonasciicharscatcode\active
9929 %
9930
9931 \def\gdefchar#1#2{%
9932 \gdef#1{%
9933    \ifpassthroughchars
9934      \string#1%
9935    \else
9936      #2%
9937    \fi
9938 }}
9939
9940 % Latin1 (ISO-8859-1) character definitions.
9941 \def\latonechardefs{%
9942   \gdefchar^^a0{\tie}
9943   \gdefchar^^a1{\exclamdown}
9944   \gdefchar^^a2{{\tcfont \char162}} % cent
9945   \gdefchar^^a3{\pounds}
9946   \gdefchar^^a4{{\tcfont \char164}} % currency
9947   \gdefchar^^a5{{\tcfont \char165}} % yen
9948   \gdefchar^^a6{{\tcfont \char166}} % broken bar
9949   \gdefchar^^a7{\S}
9950   \gdefchar^^a8{\"{}}
9951   \gdefchar^^a9{\copyright}
9952   \gdefchar^^aa{\ordf}
9953   \gdefchar^^ab{\guillemetleft}
9954   \gdefchar^^ac{\ensuremath\lnot}
9955   \gdefchar^^ad{\-}
9956   \gdefchar^^ae{\registeredsymbol}
9957   \gdefchar^^af{\={}}
9958   %
9959   \gdefchar^^b0{\textdegree}
9960   \gdefchar^^b1{$\pm$}
9961   \gdefchar^^b2{$^2$}
9962   \gdefchar^^b3{$^3$}
9963   \gdefchar^^b4{\'{}}
9964   \gdefchar^^b5{$\mu$}
9965   \gdefchar^^b6{\P}
9966   \gdefchar^^b7{\ensuremath\cdot}
9967   \gdefchar^^b8{\cedilla\ }
9968   \gdefchar^^b9{$^1$}
9969   \gdefchar^^ba{\ordm}
9970   \gdefchar^^bb{\guillemetright}
9971   \gdefchar^^bc{$1\over4$}
9972   \gdefchar^^bd{$1\over2$}
9973   \gdefchar^^be{$3\over4$}
9974   \gdefchar^^bf{\questiondown}
9975   %
9976   \gdefchar^^c0{\`A}
9977   \gdefchar^^c1{\'A}
9978   \gdefchar^^c2{\^A}
9979   \gdefchar^^c3{\~A}
9980   \gdefchar^^c4{\"A}
9981   \gdefchar^^c5{\ringaccent A}
9982   \gdefchar^^c6{\AE}
9983   \gdefchar^^c7{\cedilla C}
9984   \gdefchar^^c8{\`E}
9985   \gdefchar^^c9{\'E}
9986   \gdefchar^^ca{\^E}
9987   \gdefchar^^cb{\"E}
9988   \gdefchar^^cc{\`I}
9989   \gdefchar^^cd{\'I}
9990   \gdefchar^^ce{\^I}
9991   \gdefchar^^cf{\"I}
9992   %
9993   \gdefchar^^d0{\DH}
9994   \gdefchar^^d1{\~N}
9995   \gdefchar^^d2{\`O}
9996   \gdefchar^^d3{\'O}
9997   \gdefchar^^d4{\^O}
9998   \gdefchar^^d5{\~O}
9999   \gdefchar^^d6{\"O}
10000   \gdefchar^^d7{$\times$}
10001   \gdefchar^^d8{\O}
10002   \gdefchar^^d9{\`U}
10003   \gdefchar^^da{\'U}
10004   \gdefchar^^db{\^U}
10005   \gdefchar^^dc{\"U}
10006   \gdefchar^^dd{\'Y}
10007   \gdefchar^^de{\TH}
10008   \gdefchar^^df{\ss}
10009   %
10010   \gdefchar^^e0{\`a}
10011   \gdefchar^^e1{\'a}
10012   \gdefchar^^e2{\^a}
10013   \gdefchar^^e3{\~a}
10014   \gdefchar^^e4{\"a}
10015   \gdefchar^^e5{\ringaccent a}
10016   \gdefchar^^e6{\ae}
10017   \gdefchar^^e7{\cedilla c}
10018   \gdefchar^^e8{\`e}
10019   \gdefchar^^e9{\'e}
10020   \gdefchar^^ea{\^e}
10021   \gdefchar^^eb{\"e}
10022   \gdefchar^^ec{\`{\dotless i}}
10023   \gdefchar^^ed{\'{\dotless i}}
10024   \gdefchar^^ee{\^{\dotless i}}
10025   \gdefchar^^ef{\"{\dotless i}}
10026   %
10027   \gdefchar^^f0{\dh}
10028   \gdefchar^^f1{\~n}
10029   \gdefchar^^f2{\`o}
10030   \gdefchar^^f3{\'o}
10031   \gdefchar^^f4{\^o}
10032   \gdefchar^^f5{\~o}
10033   \gdefchar^^f6{\"o}
10034   \gdefchar^^f7{$\div$}
10035   \gdefchar^^f8{\o}
10036   \gdefchar^^f9{\`u}
10037   \gdefchar^^fa{\'u}
10038   \gdefchar^^fb{\^u}
10039   \gdefchar^^fc{\"u}
10040   \gdefchar^^fd{\'y}
10041   \gdefchar^^fe{\th}
10042   \gdefchar^^ff{\"y}
10043 }
10044
10045 % Latin9 (ISO-8859-15) encoding character definitions.
10046 \def\latninechardefs{%
10047   % Encoding is almost identical to Latin1.
10048   \latonechardefs
10049   %
10050   \gdefchar^^a4{\euro}
10051   \gdefchar^^a6{\v S}
10052   \gdefchar^^a8{\v s}
10053   \gdefchar^^b4{\v Z}
10054   \gdefchar^^b8{\v z}
10055   \gdefchar^^bc{\OE}
10056   \gdefchar^^bd{\oe}
10057   \gdefchar^^be{\"Y}
10058 }
10059
10060 % Latin2 (ISO-8859-2) character definitions.
10061 \def\lattwochardefs{%
10062   \gdefchar^^a0{\tie}
10063   \gdefchar^^a1{\ogonek{A}}
10064   \gdefchar^^a2{\u{}}
10065   \gdefchar^^a3{\L}
10066   \gdefchar^^a4{\missingcharmsg{CURRENCY SIGN}}
10067   \gdefchar^^a5{\v L}
10068   \gdefchar^^a6{\'S}
10069   \gdefchar^^a7{\S}
10070   \gdefchar^^a8{\"{}}
10071   \gdefchar^^a9{\v S}
10072   \gdefchar^^aa{\cedilla S}
10073   \gdefchar^^ab{\v T}
10074   \gdefchar^^ac{\'Z}
10075   \gdefchar^^ad{\-}
10076   \gdefchar^^ae{\v Z}
10077   \gdefchar^^af{\dotaccent Z}
10078   %
10079   \gdefchar^^b0{\textdegree}
10080   \gdefchar^^b1{\ogonek{a}}
10081   \gdefchar^^b2{\ogonek{ }}
10082   \gdefchar^^b3{\l}
10083   \gdefchar^^b4{\'{}}
10084   \gdefchar^^b5{\v l}
10085   \gdefchar^^b6{\'s}
10086   \gdefchar^^b7{\v{}}
10087   \gdefchar^^b8{\cedilla\ }
10088   \gdefchar^^b9{\v s}
10089   \gdefchar^^ba{\cedilla s}
10090   \gdefchar^^bb{\v t}
10091   \gdefchar^^bc{\'z}
10092   \gdefchar^^bd{\H{}}
10093   \gdefchar^^be{\v z}
10094   \gdefchar^^bf{\dotaccent z}
10095   %
10096   \gdefchar^^c0{\'R}
10097   \gdefchar^^c1{\'A}
10098   \gdefchar^^c2{\^A}
10099   \gdefchar^^c3{\u A}
10100   \gdefchar^^c4{\"A}
10101   \gdefchar^^c5{\'L}
10102   \gdefchar^^c6{\'C}
10103   \gdefchar^^c7{\cedilla C}
10104   \gdefchar^^c8{\v C}
10105   \gdefchar^^c9{\'E}
10106   \gdefchar^^ca{\ogonek{E}}
10107   \gdefchar^^cb{\"E}
10108   \gdefchar^^cc{\v E}
10109   \gdefchar^^cd{\'I}
10110   \gdefchar^^ce{\^I}
10111   \gdefchar^^cf{\v D}
10112   %
10113   \gdefchar^^d0{\DH}
10114   \gdefchar^^d1{\'N}
10115   \gdefchar^^d2{\v N}
10116   \gdefchar^^d3{\'O}
10117   \gdefchar^^d4{\^O}
10118   \gdefchar^^d5{\H O}
10119   \gdefchar^^d6{\"O}
10120   \gdefchar^^d7{$\times$}
10121   \gdefchar^^d8{\v R}
10122   \gdefchar^^d9{\ringaccent U}
10123   \gdefchar^^da{\'U}
10124   \gdefchar^^db{\H U}
10125   \gdefchar^^dc{\"U}
10126   \gdefchar^^dd{\'Y}
10127   \gdefchar^^de{\cedilla T}
10128   \gdefchar^^df{\ss}
10129   %
10130   \gdefchar^^e0{\'r}
10131   \gdefchar^^e1{\'a}
10132   \gdefchar^^e2{\^a}
10133   \gdefchar^^e3{\u a}
10134   \gdefchar^^e4{\"a}
10135   \gdefchar^^e5{\'l}
10136   \gdefchar^^e6{\'c}
10137   \gdefchar^^e7{\cedilla c}
10138   \gdefchar^^e8{\v c}
10139   \gdefchar^^e9{\'e}
10140   \gdefchar^^ea{\ogonek{e}}
10141   \gdefchar^^eb{\"e}
10142   \gdefchar^^ec{\v e}
10143   \gdefchar^^ed{\'{\dotless{i}}}
10144   \gdefchar^^ee{\^{\dotless{i}}}
10145   \gdefchar^^ef{\v d}
10146   %
10147   \gdefchar^^f0{\dh}
10148   \gdefchar^^f1{\'n}
10149   \gdefchar^^f2{\v n}
10150   \gdefchar^^f3{\'o}
10151   \gdefchar^^f4{\^o}
10152   \gdefchar^^f5{\H o}
10153   \gdefchar^^f6{\"o}
10154   \gdefchar^^f7{$\div$}
10155   \gdefchar^^f8{\v r}
10156   \gdefchar^^f9{\ringaccent u}
10157   \gdefchar^^fa{\'u}
10158   \gdefchar^^fb{\H u}
10159   \gdefchar^^fc{\"u}
10160   \gdefchar^^fd{\'y}
10161   \gdefchar^^fe{\cedilla t}
10162   \gdefchar^^ff{\dotaccent{}}
10163 }
10164
10165 % UTF-8 character definitions.
10166 %
10167 % This code to support UTF-8 is based on LaTeX's utf8.def, with some
10168 % changes for Texinfo conventions.  It is included here under the GPL by
10169 % permission from Frank Mittelbach and the LaTeX team.
10170 %
10171 \newcount\countUTFx
10172 \newcount\countUTFy
10173 \newcount\countUTFz
10174
10175 \gdef\UTFviiiTwoOctets#1#2{\expandafter
10176    \UTFviiiDefined\csname u8:#1\string #2\endcsname}
10177 %
10178 \gdef\UTFviiiThreeOctets#1#2#3{\expandafter
10179    \UTFviiiDefined\csname u8:#1\string #2\string #3\endcsname}
10180 %
10181 \gdef\UTFviiiFourOctets#1#2#3#4{\expandafter
10182    \UTFviiiDefined\csname u8:#1\string #2\string #3\string #4\endcsname}
10183
10184 \gdef\UTFviiiDefined#1{%
10185   \ifx #1\relax
10186     \message{\linenumber Unicode char \string #1 not defined for Texinfo}%
10187   \else
10188     \expandafter #1%
10189   \fi
10190 }
10191
10192 % Give non-ASCII bytes the active definitions for processing UTF-8 sequences
10193 \begingroup
10194   \catcode`\~13
10195   \catcode`\$12
10196   \catcode`\"12
10197
10198   % Loop from \countUTFx to \countUTFy, performing \UTFviiiTmp
10199   % substituting ~ and $ with a character token of that value.
10200   \def\UTFviiiLoop{%
10201     \global\catcode\countUTFx\active
10202     \uccode`\~\countUTFx
10203     \uccode`\$\countUTFx
10204     \uppercase\expandafter{\UTFviiiTmp}%
10205     \advance\countUTFx by 1
10206     \ifnum\countUTFx < \countUTFy
10207       \expandafter\UTFviiiLoop
10208     \fi}
10209
10210   % For bytes other than the first in a UTF-8 sequence.  Not expected to
10211   % be expanded except when writing to auxiliary files.
10212   \countUTFx = "80
10213   \countUTFy = "C2
10214   \def\UTFviiiTmp{%
10215     \gdef~{
10216         \ifpassthroughchars $\fi}}%
10217   \UTFviiiLoop
10218
10219   \countUTFx = "C2
10220   \countUTFy = "E0
10221   \def\UTFviiiTmp{%
10222     \gdef~{%
10223         \ifpassthroughchars $%
10224         \else\expandafter\UTFviiiTwoOctets\expandafter$\fi}}%
10225   \UTFviiiLoop
10226
10227   \countUTFx = "E0
10228   \countUTFy = "F0
10229   \def\UTFviiiTmp{%
10230     \gdef~{%
10231         \ifpassthroughchars $%
10232         \else\expandafter\UTFviiiThreeOctets\expandafter$\fi}}%
10233   \UTFviiiLoop
10234
10235   \countUTFx = "F0
10236   \countUTFy = "F4
10237   \def\UTFviiiTmp{%
10238     \gdef~{%
10239         \ifpassthroughchars $%
10240         \else\expandafter\UTFviiiFourOctets\expandafter$\fi
10241         }}%
10242   \UTFviiiLoop
10243 \endgroup
10244
10245 \def\globallet{\global\let} % save some \expandafter's below
10246
10247 % @U{xxxx} to produce U+xxxx, if we support it.
10248 \def\U#1{%
10249   \expandafter\ifx\csname uni:#1\endcsname \relax
10250     \iftxinativeunicodecapable
10251       % Any Unicode characters can be used by native Unicode.
10252       % However, if the font does not have the glyph, the letter will miss.
10253       \begingroup
10254         \uccode`\.="#1\relax
10255         \uppercase{.}
10256       \endgroup
10257     \else
10258       \errhelp = \EMsimple      
10259       \errmessage{Unicode character U+#1 not supported, sorry}%
10260     \fi
10261   \else
10262     \csname uni:#1\endcsname
10263   \fi
10264 }
10265
10266 % For UTF-8 byte sequence (TeX, e-TeX and pdfTeX)
10267 % Definition macro to replace the Unicode character
10268 % Definition macro that is used by @U command
10269 %
10270 \begingroup
10271   \catcode`\"=12
10272   \catcode`\<=12
10273   \catcode`\.=12
10274   \catcode`\,=12
10275   \catcode`\;=12
10276   \catcode`\!=12
10277   \catcode`\~=13
10278   \gdef\DeclareUnicodeCharacterUTFviii#1#2{%
10279     \countUTFz = "#1\relax
10280     \begingroup
10281       \parseXMLCharref
10282       %
10283       % Access definitions of characters given UTF-8 sequences
10284       \def\UTFviiiTwoOctets##1##2{%
10285         \csname u8:##1\string ##2\endcsname}%
10286       \def\UTFviiiThreeOctets##1##2##3{%
10287         \csname u8:##1\string ##2\string ##3\endcsname}%
10288       \def\UTFviiiFourOctets##1##2##3##4{%
10289         \csname u8:##1\string ##2\string ##3\string ##4\endcsname}%
10290       \expandafter\expandafter\expandafter\expandafter
10291        \expandafter\expandafter\expandafter
10292        \gdef\UTFviiiTmp{#2}%
10293       % 
10294       \expandafter\ifx\csname uni:#1\endcsname \relax \else
10295        \message{Internal error, already defined: #1}%
10296       \fi
10297       %
10298       % define an additional control sequence for this code point.
10299       \expandafter\globallet\csname uni:#1\endcsname \UTFviiiTmp
10300     \endgroup}
10301   %
10302   % Given the value in \countUTFz as a Unicode code point, set \UTFviiiTmp.
10303   \gdef\parseXMLCharref{%
10304     \ifnum\countUTFz < "A0\relax
10305       \errhelp = \EMsimple
10306       \errmessage{Cannot define Unicode char value < 00A0}%
10307     \else\ifnum\countUTFz < "800\relax
10308       \parseUTFviiiA,%
10309       \parseUTFviiiB C\UTFviiiTwoOctets.,%
10310     \else\ifnum\countUTFz < "10000\relax
10311       \parseUTFviiiA;%
10312       \parseUTFviiiA,%
10313       \parseUTFviiiB E\UTFviiiThreeOctets.{,;}%
10314     \else
10315       \parseUTFviiiA;%
10316       \parseUTFviiiA,%
10317       \parseUTFviiiA!%
10318       \parseUTFviiiB F\UTFviiiFourOctets.{!,;}%
10319     \fi\fi\fi
10320   }
10321
10322   \gdef\parseUTFviiiA#1{%
10323     \countUTFx = \countUTFz
10324     \divide\countUTFz by 64
10325     \countUTFy = \countUTFz
10326     \multiply\countUTFz by 64
10327     \advance\countUTFx by -\countUTFz
10328     \advance\countUTFx by 128
10329     \uccode `#1\countUTFx
10330     \countUTFz = \countUTFy}
10331
10332   % Used to set \UTFviiiTmp to a UTF-8 byte sequence
10333   \gdef\parseUTFviiiB#1#2#3#4{%
10334     \advance\countUTFz by "#10\relax
10335     \uccode `#3\countUTFz
10336     \uppercase{\gdef\UTFviiiTmp{#2#3#4}}}
10337 \endgroup
10338
10339 % For native Unicode (XeTeX and LuaTeX)
10340 % Definition macro that is set catcode other non global
10341 %
10342 \def\DeclareUnicodeCharacterNativeOther#1#2{%
10343   \catcode"#1=\other
10344 }
10345
10346 % https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_M
10347 % U+0000..U+007F = https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block)
10348 % U+0080..U+00FF = https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)
10349 % U+0100..U+017F = https://en.wikipedia.org/wiki/Latin_Extended-A
10350 % U+0180..U+024F = https://en.wikipedia.org/wiki/Latin_Extended-B
10351
10352 % Many of our renditions are less than wonderful, and all the missing
10353 % characters are available somewhere.  Loading the necessary fonts
10354 % awaits user request.  We can't truly support Unicode without
10355 % reimplementing everything that's been done in LaTeX for many years,
10356 % plus probably using luatex or xetex, and who knows what else.
10357 % We won't be doing that here in this simple file.  But we can try to at
10358 % least make most of the characters not bomb out.
10359 %
10360 \def\unicodechardefs{%
10361   \DeclareUnicodeCharacter{00A0}{\tie}%
10362   \DeclareUnicodeCharacter{00A1}{\exclamdown}%
10363   \DeclareUnicodeCharacter{00A2}{{\tcfont \char162}}% 0242=cent
10364   \DeclareUnicodeCharacter{00A3}{\pounds}%
10365   \DeclareUnicodeCharacter{00A4}{{\tcfont \char164}}% 0244=currency
10366   \DeclareUnicodeCharacter{00A5}{{\tcfont \char165}}% 0245=yen
10367   \DeclareUnicodeCharacter{00A6}{{\tcfont \char166}}% 0246=brokenbar
10368   \DeclareUnicodeCharacter{00A7}{\S}%
10369   \DeclareUnicodeCharacter{00A8}{\"{ }}%
10370   \DeclareUnicodeCharacter{00A9}{\copyright}%
10371   \DeclareUnicodeCharacter{00AA}{\ordf}%
10372   \DeclareUnicodeCharacter{00AB}{\guillemetleft}%
10373   \DeclareUnicodeCharacter{00AC}{\ensuremath\lnot}%
10374   \DeclareUnicodeCharacter{00AD}{\-}%
10375   \DeclareUnicodeCharacter{00AE}{\registeredsymbol}%
10376   \DeclareUnicodeCharacter{00AF}{\={ }}%
10377   %
10378   \DeclareUnicodeCharacter{00B0}{\ringaccent{ }}%
10379   \DeclareUnicodeCharacter{00B1}{\ensuremath\pm}%
10380   \DeclareUnicodeCharacter{00B2}{$^2$}%
10381   \DeclareUnicodeCharacter{00B3}{$^3$}%
10382   \DeclareUnicodeCharacter{00B4}{\'{ }}%
10383   \DeclareUnicodeCharacter{00B5}{$\mu$}%
10384   \DeclareUnicodeCharacter{00B6}{\P}%
10385   \DeclareUnicodeCharacter{00B7}{\ensuremath\cdot}%
10386   \DeclareUnicodeCharacter{00B8}{\cedilla{ }}%
10387   \DeclareUnicodeCharacter{00B9}{$^1$}%
10388   \DeclareUnicodeCharacter{00BA}{\ordm}%
10389   \DeclareUnicodeCharacter{00BB}{\guillemetright}%
10390   \DeclareUnicodeCharacter{00BC}{$1\over4$}%
10391   \DeclareUnicodeCharacter{00BD}{$1\over2$}%
10392   \DeclareUnicodeCharacter{00BE}{$3\over4$}%
10393   \DeclareUnicodeCharacter{00BF}{\questiondown}%
10394   %
10395   \DeclareUnicodeCharacter{00C0}{\`A}%
10396   \DeclareUnicodeCharacter{00C1}{\'A}%
10397   \DeclareUnicodeCharacter{00C2}{\^A}%
10398   \DeclareUnicodeCharacter{00C3}{\~A}%
10399   \DeclareUnicodeCharacter{00C4}{\"A}%
10400   \DeclareUnicodeCharacter{00C5}{\AA}%
10401   \DeclareUnicodeCharacter{00C6}{\AE}%
10402   \DeclareUnicodeCharacter{00C7}{\cedilla{C}}%
10403   \DeclareUnicodeCharacter{00C8}{\`E}%
10404   \DeclareUnicodeCharacter{00C9}{\'E}%
10405   \DeclareUnicodeCharacter{00CA}{\^E}%
10406   \DeclareUnicodeCharacter{00CB}{\"E}%
10407   \DeclareUnicodeCharacter{00CC}{\`I}%
10408   \DeclareUnicodeCharacter{00CD}{\'I}%
10409   \DeclareUnicodeCharacter{00CE}{\^I}%
10410   \DeclareUnicodeCharacter{00CF}{\"I}%
10411   %
10412   \DeclareUnicodeCharacter{00D0}{\DH}%
10413   \DeclareUnicodeCharacter{00D1}{\~N}%
10414   \DeclareUnicodeCharacter{00D2}{\`O}%
10415   \DeclareUnicodeCharacter{00D3}{\'O}%
10416   \DeclareUnicodeCharacter{00D4}{\^O}%
10417   \DeclareUnicodeCharacter{00D5}{\~O}%
10418   \DeclareUnicodeCharacter{00D6}{\"O}%
10419   \DeclareUnicodeCharacter{00D7}{\ensuremath\times}%
10420   \DeclareUnicodeCharacter{00D8}{\O}%
10421   \DeclareUnicodeCharacter{00D9}{\`U}%
10422   \DeclareUnicodeCharacter{00DA}{\'U}%
10423   \DeclareUnicodeCharacter{00DB}{\^U}%
10424   \DeclareUnicodeCharacter{00DC}{\"U}%
10425   \DeclareUnicodeCharacter{00DD}{\'Y}%
10426   \DeclareUnicodeCharacter{00DE}{\TH}%
10427   \DeclareUnicodeCharacter{00DF}{\ss}%
10428   %
10429   \DeclareUnicodeCharacter{00E0}{\`a}%
10430   \DeclareUnicodeCharacter{00E1}{\'a}%
10431   \DeclareUnicodeCharacter{00E2}{\^a}%
10432   \DeclareUnicodeCharacter{00E3}{\~a}%
10433   \DeclareUnicodeCharacter{00E4}{\"a}%
10434   \DeclareUnicodeCharacter{00E5}{\aa}%
10435   \DeclareUnicodeCharacter{00E6}{\ae}%
10436   \DeclareUnicodeCharacter{00E7}{\cedilla{c}}%
10437   \DeclareUnicodeCharacter{00E8}{\`e}%
10438   \DeclareUnicodeCharacter{00E9}{\'e}%
10439   \DeclareUnicodeCharacter{00EA}{\^e}%
10440   \DeclareUnicodeCharacter{00EB}{\"e}%
10441   \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}}%
10442   \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}}%
10443   \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}}%
10444   \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}}%
10445   %
10446   \DeclareUnicodeCharacter{00F0}{\dh}%
10447   \DeclareUnicodeCharacter{00F1}{\~n}%
10448   \DeclareUnicodeCharacter{00F2}{\`o}%
10449   \DeclareUnicodeCharacter{00F3}{\'o}%
10450   \DeclareUnicodeCharacter{00F4}{\^o}%
10451   \DeclareUnicodeCharacter{00F5}{\~o}%
10452   \DeclareUnicodeCharacter{00F6}{\"o}%
10453   \DeclareUnicodeCharacter{00F7}{\ensuremath\div}%
10454   \DeclareUnicodeCharacter{00F8}{\o}%
10455   \DeclareUnicodeCharacter{00F9}{\`u}%
10456   \DeclareUnicodeCharacter{00FA}{\'u}%
10457   \DeclareUnicodeCharacter{00FB}{\^u}%
10458   \DeclareUnicodeCharacter{00FC}{\"u}%
10459   \DeclareUnicodeCharacter{00FD}{\'y}%
10460   \DeclareUnicodeCharacter{00FE}{\th}%
10461   \DeclareUnicodeCharacter{00FF}{\"y}%
10462   %
10463   \DeclareUnicodeCharacter{0100}{\=A}%
10464   \DeclareUnicodeCharacter{0101}{\=a}%
10465   \DeclareUnicodeCharacter{0102}{\u{A}}%
10466   \DeclareUnicodeCharacter{0103}{\u{a}}%
10467   \DeclareUnicodeCharacter{0104}{\ogonek{A}}%
10468   \DeclareUnicodeCharacter{0105}{\ogonek{a}}%
10469   \DeclareUnicodeCharacter{0106}{\'C}%
10470   \DeclareUnicodeCharacter{0107}{\'c}%
10471   \DeclareUnicodeCharacter{0108}{\^C}%
10472   \DeclareUnicodeCharacter{0109}{\^c}%
10473   \DeclareUnicodeCharacter{010A}{\dotaccent{C}}%
10474   \DeclareUnicodeCharacter{010B}{\dotaccent{c}}%
10475   \DeclareUnicodeCharacter{010C}{\v{C}}%
10476   \DeclareUnicodeCharacter{010D}{\v{c}}%
10477   \DeclareUnicodeCharacter{010E}{\v{D}}%
10478   \DeclareUnicodeCharacter{010F}{d'}%
10479   %
10480   \DeclareUnicodeCharacter{0110}{\DH}%
10481   \DeclareUnicodeCharacter{0111}{\dh}%
10482   \DeclareUnicodeCharacter{0112}{\=E}%
10483   \DeclareUnicodeCharacter{0113}{\=e}%
10484   \DeclareUnicodeCharacter{0114}{\u{E}}%
10485   \DeclareUnicodeCharacter{0115}{\u{e}}%
10486   \DeclareUnicodeCharacter{0116}{\dotaccent{E}}%
10487   \DeclareUnicodeCharacter{0117}{\dotaccent{e}}%
10488   \DeclareUnicodeCharacter{0118}{\ogonek{E}}%
10489   \DeclareUnicodeCharacter{0119}{\ogonek{e}}%
10490   \DeclareUnicodeCharacter{011A}{\v{E}}%
10491   \DeclareUnicodeCharacter{011B}{\v{e}}%
10492   \DeclareUnicodeCharacter{011C}{\^G}%
10493   \DeclareUnicodeCharacter{011D}{\^g}%
10494   \DeclareUnicodeCharacter{011E}{\u{G}}%
10495   \DeclareUnicodeCharacter{011F}{\u{g}}%
10496   %
10497   \DeclareUnicodeCharacter{0120}{\dotaccent{G}}%
10498   \DeclareUnicodeCharacter{0121}{\dotaccent{g}}%
10499   \DeclareUnicodeCharacter{0122}{\cedilla{G}}%
10500   \DeclareUnicodeCharacter{0123}{\cedilla{g}}%
10501   \DeclareUnicodeCharacter{0124}{\^H}%
10502   \DeclareUnicodeCharacter{0125}{\^h}%
10503   \DeclareUnicodeCharacter{0126}{\missingcharmsg{H WITH STROKE}}%
10504   \DeclareUnicodeCharacter{0127}{\missingcharmsg{h WITH STROKE}}%
10505   \DeclareUnicodeCharacter{0128}{\~I}%
10506   \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}}%
10507   \DeclareUnicodeCharacter{012A}{\=I}%
10508   \DeclareUnicodeCharacter{012B}{\={\dotless{i}}}%
10509   \DeclareUnicodeCharacter{012C}{\u{I}}%
10510   \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}}%
10511   \DeclareUnicodeCharacter{012E}{\ogonek{I}}%
10512   \DeclareUnicodeCharacter{012F}{\ogonek{i}}%
10513   %
10514   \DeclareUnicodeCharacter{0130}{\dotaccent{I}}%
10515   \DeclareUnicodeCharacter{0131}{\dotless{i}}%
10516   \DeclareUnicodeCharacter{0132}{IJ}%
10517   \DeclareUnicodeCharacter{0133}{ij}%
10518   \DeclareUnicodeCharacter{0134}{\^J}%
10519   \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}}%
10520   \DeclareUnicodeCharacter{0136}{\cedilla{K}}%
10521   \DeclareUnicodeCharacter{0137}{\cedilla{k}}%
10522   \DeclareUnicodeCharacter{0138}{\ensuremath\kappa}%
10523   \DeclareUnicodeCharacter{0139}{\'L}%
10524   \DeclareUnicodeCharacter{013A}{\'l}%
10525   \DeclareUnicodeCharacter{013B}{\cedilla{L}}%
10526   \DeclareUnicodeCharacter{013C}{\cedilla{l}}%
10527   \DeclareUnicodeCharacter{013D}{L'}% should kern
10528   \DeclareUnicodeCharacter{013E}{l'}% should kern
10529   \DeclareUnicodeCharacter{013F}{L\U{00B7}}%
10530   %
10531   \DeclareUnicodeCharacter{0140}{l\U{00B7}}%
10532   \DeclareUnicodeCharacter{0141}{\L}%
10533   \DeclareUnicodeCharacter{0142}{\l}%
10534   \DeclareUnicodeCharacter{0143}{\'N}%
10535   \DeclareUnicodeCharacter{0144}{\'n}%
10536   \DeclareUnicodeCharacter{0145}{\cedilla{N}}%
10537   \DeclareUnicodeCharacter{0146}{\cedilla{n}}%
10538   \DeclareUnicodeCharacter{0147}{\v{N}}%
10539   \DeclareUnicodeCharacter{0148}{\v{n}}%
10540   \DeclareUnicodeCharacter{0149}{'n}%
10541   \DeclareUnicodeCharacter{014A}{\missingcharmsg{ENG}}%
10542   \DeclareUnicodeCharacter{014B}{\missingcharmsg{eng}}%
10543   \DeclareUnicodeCharacter{014C}{\=O}%
10544   \DeclareUnicodeCharacter{014D}{\=o}%
10545   \DeclareUnicodeCharacter{014E}{\u{O}}%
10546   \DeclareUnicodeCharacter{014F}{\u{o}}%
10547   %
10548   \DeclareUnicodeCharacter{0150}{\H{O}}%
10549   \DeclareUnicodeCharacter{0151}{\H{o}}%
10550   \DeclareUnicodeCharacter{0152}{\OE}%
10551   \DeclareUnicodeCharacter{0153}{\oe}%
10552   \DeclareUnicodeCharacter{0154}{\'R}%
10553   \DeclareUnicodeCharacter{0155}{\'r}%
10554   \DeclareUnicodeCharacter{0156}{\cedilla{R}}%
10555   \DeclareUnicodeCharacter{0157}{\cedilla{r}}%
10556   \DeclareUnicodeCharacter{0158}{\v{R}}%
10557   \DeclareUnicodeCharacter{0159}{\v{r}}%
10558   \DeclareUnicodeCharacter{015A}{\'S}%
10559   \DeclareUnicodeCharacter{015B}{\'s}%
10560   \DeclareUnicodeCharacter{015C}{\^S}%
10561   \DeclareUnicodeCharacter{015D}{\^s}%
10562   \DeclareUnicodeCharacter{015E}{\cedilla{S}}%
10563   \DeclareUnicodeCharacter{015F}{\cedilla{s}}%
10564   %
10565   \DeclareUnicodeCharacter{0160}{\v{S}}%
10566   \DeclareUnicodeCharacter{0161}{\v{s}}%
10567   \DeclareUnicodeCharacter{0162}{\cedilla{T}}%
10568   \DeclareUnicodeCharacter{0163}{\cedilla{t}}%
10569   \DeclareUnicodeCharacter{0164}{\v{T}}%
10570   \DeclareUnicodeCharacter{0165}{\v{t}}%
10571   \DeclareUnicodeCharacter{0166}{\missingcharmsg{H WITH STROKE}}%
10572   \DeclareUnicodeCharacter{0167}{\missingcharmsg{h WITH STROKE}}%
10573   \DeclareUnicodeCharacter{0168}{\~U}%
10574   \DeclareUnicodeCharacter{0169}{\~u}%
10575   \DeclareUnicodeCharacter{016A}{\=U}%
10576   \DeclareUnicodeCharacter{016B}{\=u}%
10577   \DeclareUnicodeCharacter{016C}{\u{U}}%
10578   \DeclareUnicodeCharacter{016D}{\u{u}}%
10579   \DeclareUnicodeCharacter{016E}{\ringaccent{U}}%
10580   \DeclareUnicodeCharacter{016F}{\ringaccent{u}}%
10581   %
10582   \DeclareUnicodeCharacter{0170}{\H{U}}%
10583   \DeclareUnicodeCharacter{0171}{\H{u}}%
10584   \DeclareUnicodeCharacter{0172}{\ogonek{U}}%
10585   \DeclareUnicodeCharacter{0173}{\ogonek{u}}%
10586   \DeclareUnicodeCharacter{0174}{\^W}%
10587   \DeclareUnicodeCharacter{0175}{\^w}%
10588   \DeclareUnicodeCharacter{0176}{\^Y}%
10589   \DeclareUnicodeCharacter{0177}{\^y}%
10590   \DeclareUnicodeCharacter{0178}{\"Y}%
10591   \DeclareUnicodeCharacter{0179}{\'Z}%
10592   \DeclareUnicodeCharacter{017A}{\'z}%
10593   \DeclareUnicodeCharacter{017B}{\dotaccent{Z}}%
10594   \DeclareUnicodeCharacter{017C}{\dotaccent{z}}%
10595   \DeclareUnicodeCharacter{017D}{\v{Z}}%
10596   \DeclareUnicodeCharacter{017E}{\v{z}}%
10597   \DeclareUnicodeCharacter{017F}{\missingcharmsg{LONG S}}%
10598   %
10599   \DeclareUnicodeCharacter{01C4}{D\v{Z}}%
10600   \DeclareUnicodeCharacter{01C5}{D\v{z}}%
10601   \DeclareUnicodeCharacter{01C6}{d\v{z}}%
10602   \DeclareUnicodeCharacter{01C7}{LJ}%
10603   \DeclareUnicodeCharacter{01C8}{Lj}%
10604   \DeclareUnicodeCharacter{01C9}{lj}%
10605   \DeclareUnicodeCharacter{01CA}{NJ}%
10606   \DeclareUnicodeCharacter{01CB}{Nj}%
10607   \DeclareUnicodeCharacter{01CC}{nj}%
10608   \DeclareUnicodeCharacter{01CD}{\v{A}}%
10609   \DeclareUnicodeCharacter{01CE}{\v{a}}%
10610   \DeclareUnicodeCharacter{01CF}{\v{I}}%
10611   %
10612   \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}}%
10613   \DeclareUnicodeCharacter{01D1}{\v{O}}%
10614   \DeclareUnicodeCharacter{01D2}{\v{o}}%
10615   \DeclareUnicodeCharacter{01D3}{\v{U}}%
10616   \DeclareUnicodeCharacter{01D4}{\v{u}}%
10617   %
10618   \DeclareUnicodeCharacter{01E2}{\={\AE}}%
10619   \DeclareUnicodeCharacter{01E3}{\={\ae}}%
10620   \DeclareUnicodeCharacter{01E6}{\v{G}}%
10621   \DeclareUnicodeCharacter{01E7}{\v{g}}%
10622   \DeclareUnicodeCharacter{01E8}{\v{K}}%
10623   \DeclareUnicodeCharacter{01E9}{\v{k}}%
10624   %
10625   \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}}%
10626   \DeclareUnicodeCharacter{01F1}{DZ}%
10627   \DeclareUnicodeCharacter{01F2}{Dz}%
10628   \DeclareUnicodeCharacter{01F3}{dz}%
10629   \DeclareUnicodeCharacter{01F4}{\'G}%
10630   \DeclareUnicodeCharacter{01F5}{\'g}%
10631   \DeclareUnicodeCharacter{01F8}{\`N}%
10632   \DeclareUnicodeCharacter{01F9}{\`n}%
10633   \DeclareUnicodeCharacter{01FC}{\'{\AE}}%
10634   \DeclareUnicodeCharacter{01FD}{\'{\ae}}%
10635   \DeclareUnicodeCharacter{01FE}{\'{\O}}%
10636   \DeclareUnicodeCharacter{01FF}{\'{\o}}%
10637   %
10638   \DeclareUnicodeCharacter{021E}{\v{H}}%
10639   \DeclareUnicodeCharacter{021F}{\v{h}}%
10640   %
10641   \DeclareUnicodeCharacter{0226}{\dotaccent{A}}%
10642   \DeclareUnicodeCharacter{0227}{\dotaccent{a}}%
10643   \DeclareUnicodeCharacter{0228}{\cedilla{E}}%
10644   \DeclareUnicodeCharacter{0229}{\cedilla{e}}%
10645   \DeclareUnicodeCharacter{022E}{\dotaccent{O}}%
10646   \DeclareUnicodeCharacter{022F}{\dotaccent{o}}%
10647   %
10648   \DeclareUnicodeCharacter{0232}{\=Y}%
10649   \DeclareUnicodeCharacter{0233}{\=y}%
10650   \DeclareUnicodeCharacter{0237}{\dotless{j}}%
10651   %
10652   \DeclareUnicodeCharacter{02DB}{\ogonek{ }}%
10653   %
10654   % Greek letters upper case
10655   \DeclareUnicodeCharacter{0391}{{\it A}}%
10656   \DeclareUnicodeCharacter{0392}{{\it B}}%
10657   \DeclareUnicodeCharacter{0393}{\ensuremath{\mit\Gamma}}%
10658   \DeclareUnicodeCharacter{0394}{\ensuremath{\mit\Delta}}%
10659   \DeclareUnicodeCharacter{0395}{{\it E}}%
10660   \DeclareUnicodeCharacter{0396}{{\it Z}}%
10661   \DeclareUnicodeCharacter{0397}{{\it H}}%
10662   \DeclareUnicodeCharacter{0398}{\ensuremath{\mit\Theta}}%
10663   \DeclareUnicodeCharacter{0399}{{\it I}}%
10664   \DeclareUnicodeCharacter{039A}{{\it K}}%
10665   \DeclareUnicodeCharacter{039B}{\ensuremath{\mit\Lambda}}%
10666   \DeclareUnicodeCharacter{039C}{{\it M}}%
10667   \DeclareUnicodeCharacter{039D}{{\it N}}%
10668   \DeclareUnicodeCharacter{039E}{\ensuremath{\mit\Xi}}%
10669   \DeclareUnicodeCharacter{039F}{{\it O}}%
10670   \DeclareUnicodeCharacter{03A0}{\ensuremath{\mit\Pi}}%
10671   \DeclareUnicodeCharacter{03A1}{{\it P}}%
10672   %\DeclareUnicodeCharacter{03A2}{} % none - corresponds to final sigma
10673   \DeclareUnicodeCharacter{03A3}{\ensuremath{\mit\Sigma}}%
10674   \DeclareUnicodeCharacter{03A4}{{\it T}}%
10675   \DeclareUnicodeCharacter{03A5}{\ensuremath{\mit\Upsilon}}%
10676   \DeclareUnicodeCharacter{03A6}{\ensuremath{\mit\Phi}}%
10677   \DeclareUnicodeCharacter{03A7}{{\it X}}%
10678   \DeclareUnicodeCharacter{03A8}{\ensuremath{\mit\Psi}}%
10679   \DeclareUnicodeCharacter{03A9}{\ensuremath{\mit\Omega}}%
10680   %
10681   % Vowels with accents
10682   \DeclareUnicodeCharacter{0390}{\ensuremath{\ddot{\acute\iota}}}%
10683   \DeclareUnicodeCharacter{03AC}{\ensuremath{\acute\alpha}}%
10684   \DeclareUnicodeCharacter{03AD}{\ensuremath{\acute\epsilon}}%
10685   \DeclareUnicodeCharacter{03AE}{\ensuremath{\acute\eta}}%
10686   \DeclareUnicodeCharacter{03AF}{\ensuremath{\acute\iota}}%
10687   \DeclareUnicodeCharacter{03B0}{\ensuremath{\acute{\ddot\upsilon}}}%
10688   %
10689   % Standalone accent
10690   \DeclareUnicodeCharacter{0384}{\ensuremath{\acute{\ }}}%
10691   %
10692   % Greek letters lower case
10693   \DeclareUnicodeCharacter{03B1}{\ensuremath\alpha}%
10694   \DeclareUnicodeCharacter{03B2}{\ensuremath\beta}%
10695   \DeclareUnicodeCharacter{03B3}{\ensuremath\gamma}%
10696   \DeclareUnicodeCharacter{03B4}{\ensuremath\delta}%
10697   \DeclareUnicodeCharacter{03B5}{\ensuremath\epsilon}%
10698   \DeclareUnicodeCharacter{03B6}{\ensuremath\zeta}%
10699   \DeclareUnicodeCharacter{03B7}{\ensuremath\eta}%
10700   \DeclareUnicodeCharacter{03B8}{\ensuremath\theta}%
10701   \DeclareUnicodeCharacter{03B9}{\ensuremath\iota}%
10702   \DeclareUnicodeCharacter{03BA}{\ensuremath\kappa}%
10703   \DeclareUnicodeCharacter{03BB}{\ensuremath\lambda}%
10704   \DeclareUnicodeCharacter{03BC}{\ensuremath\mu}%
10705   \DeclareUnicodeCharacter{03BD}{\ensuremath\nu}%
10706   \DeclareUnicodeCharacter{03BE}{\ensuremath\xi}%
10707   \DeclareUnicodeCharacter{03BF}{{\it o}}% omicron
10708   \DeclareUnicodeCharacter{03C0}{\ensuremath\pi}%
10709   \DeclareUnicodeCharacter{03C1}{\ensuremath\rho}%
10710   \DeclareUnicodeCharacter{03C2}{\ensuremath\varsigma}%
10711   \DeclareUnicodeCharacter{03C3}{\ensuremath\sigma}%
10712   \DeclareUnicodeCharacter{03C4}{\ensuremath\tau}%
10713   \DeclareUnicodeCharacter{03C5}{\ensuremath\upsilon}%
10714   \DeclareUnicodeCharacter{03C6}{\ensuremath\phi}%
10715   \DeclareUnicodeCharacter{03C7}{\ensuremath\chi}%
10716   \DeclareUnicodeCharacter{03C8}{\ensuremath\psi}%
10717   \DeclareUnicodeCharacter{03C9}{\ensuremath\omega}%
10718   %
10719   % More Greek vowels with accents
10720   \DeclareUnicodeCharacter{03CA}{\ensuremath{\ddot\iota}}%
10721   \DeclareUnicodeCharacter{03CB}{\ensuremath{\ddot\upsilon}}%
10722   \DeclareUnicodeCharacter{03CC}{\ensuremath{\acute o}}%
10723   \DeclareUnicodeCharacter{03CD}{\ensuremath{\acute\upsilon}}%
10724   \DeclareUnicodeCharacter{03CE}{\ensuremath{\acute\omega}}%
10725   %
10726   % Variant Greek letters
10727   \DeclareUnicodeCharacter{03D1}{\ensuremath\vartheta}%
10728   \DeclareUnicodeCharacter{03D6}{\ensuremath\varpi}%
10729   \DeclareUnicodeCharacter{03F1}{\ensuremath\varrho}%
10730   %
10731   \DeclareUnicodeCharacter{1E02}{\dotaccent{B}}%
10732   \DeclareUnicodeCharacter{1E03}{\dotaccent{b}}%
10733   \DeclareUnicodeCharacter{1E04}{\udotaccent{B}}%
10734   \DeclareUnicodeCharacter{1E05}{\udotaccent{b}}%
10735   \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}}%
10736   \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}}%
10737   \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}}%
10738   \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}}%
10739   \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}}%
10740   \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}}%
10741   \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}}%
10742   \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}}%
10743   %
10744   \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}}%
10745   \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}}%
10746   %
10747   \DeclareUnicodeCharacter{1E20}{\=G}%
10748   \DeclareUnicodeCharacter{1E21}{\=g}%
10749   \DeclareUnicodeCharacter{1E22}{\dotaccent{H}}%
10750   \DeclareUnicodeCharacter{1E23}{\dotaccent{h}}%
10751   \DeclareUnicodeCharacter{1E24}{\udotaccent{H}}%
10752   \DeclareUnicodeCharacter{1E25}{\udotaccent{h}}%
10753   \DeclareUnicodeCharacter{1E26}{\"H}%
10754   \DeclareUnicodeCharacter{1E27}{\"h}%
10755   %
10756   \DeclareUnicodeCharacter{1E30}{\'K}%
10757   \DeclareUnicodeCharacter{1E31}{\'k}%
10758   \DeclareUnicodeCharacter{1E32}{\udotaccent{K}}%
10759   \DeclareUnicodeCharacter{1E33}{\udotaccent{k}}%
10760   \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}}%
10761   \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}}%
10762   \DeclareUnicodeCharacter{1E36}{\udotaccent{L}}%
10763   \DeclareUnicodeCharacter{1E37}{\udotaccent{l}}%
10764   \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}}%
10765   \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}}%
10766   \DeclareUnicodeCharacter{1E3E}{\'M}%
10767   \DeclareUnicodeCharacter{1E3F}{\'m}%
10768   %
10769   \DeclareUnicodeCharacter{1E40}{\dotaccent{M}}%
10770   \DeclareUnicodeCharacter{1E41}{\dotaccent{m}}%
10771   \DeclareUnicodeCharacter{1E42}{\udotaccent{M}}%
10772   \DeclareUnicodeCharacter{1E43}{\udotaccent{m}}%
10773   \DeclareUnicodeCharacter{1E44}{\dotaccent{N}}%
10774   \DeclareUnicodeCharacter{1E45}{\dotaccent{n}}%
10775   \DeclareUnicodeCharacter{1E46}{\udotaccent{N}}%
10776   \DeclareUnicodeCharacter{1E47}{\udotaccent{n}}%
10777   \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}}%
10778   \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}}%
10779   %
10780   \DeclareUnicodeCharacter{1E54}{\'P}%
10781   \DeclareUnicodeCharacter{1E55}{\'p}%
10782   \DeclareUnicodeCharacter{1E56}{\dotaccent{P}}%
10783   \DeclareUnicodeCharacter{1E57}{\dotaccent{p}}%
10784   \DeclareUnicodeCharacter{1E58}{\dotaccent{R}}%
10785   \DeclareUnicodeCharacter{1E59}{\dotaccent{r}}%
10786   \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}}%
10787   \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}}%
10788   \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}}%
10789   \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}}%
10790   %
10791   \DeclareUnicodeCharacter{1E60}{\dotaccent{S}}%
10792   \DeclareUnicodeCharacter{1E61}{\dotaccent{s}}%
10793   \DeclareUnicodeCharacter{1E62}{\udotaccent{S}}%
10794   \DeclareUnicodeCharacter{1E63}{\udotaccent{s}}%
10795   \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}}%
10796   \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}}%
10797   \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}}%
10798   \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}}%
10799   \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}}%
10800   \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}}%
10801   %
10802   \DeclareUnicodeCharacter{1E7C}{\~V}%
10803   \DeclareUnicodeCharacter{1E7D}{\~v}%
10804   \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}}%
10805   \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}}%
10806   %
10807   \DeclareUnicodeCharacter{1E80}{\`W}%
10808   \DeclareUnicodeCharacter{1E81}{\`w}%
10809   \DeclareUnicodeCharacter{1E82}{\'W}%
10810   \DeclareUnicodeCharacter{1E83}{\'w}%
10811   \DeclareUnicodeCharacter{1E84}{\"W}%
10812   \DeclareUnicodeCharacter{1E85}{\"w}%
10813   \DeclareUnicodeCharacter{1E86}{\dotaccent{W}}%
10814   \DeclareUnicodeCharacter{1E87}{\dotaccent{w}}%
10815   \DeclareUnicodeCharacter{1E88}{\udotaccent{W}}%
10816   \DeclareUnicodeCharacter{1E89}{\udotaccent{w}}%
10817   \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}}%
10818   \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}}%
10819   \DeclareUnicodeCharacter{1E8C}{\"X}%
10820   \DeclareUnicodeCharacter{1E8D}{\"x}%
10821   \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}}%
10822   \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}}%
10823   %
10824   \DeclareUnicodeCharacter{1E90}{\^Z}%
10825   \DeclareUnicodeCharacter{1E91}{\^z}%
10826   \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}}%
10827   \DeclareUnicodeCharacter{1E93}{\udotaccent{z}}%
10828   \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}}%
10829   \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}}%
10830   \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}}%
10831   \DeclareUnicodeCharacter{1E97}{\"t}%
10832   \DeclareUnicodeCharacter{1E98}{\ringaccent{w}}%
10833   \DeclareUnicodeCharacter{1E99}{\ringaccent{y}}%
10834   %
10835   \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}}%
10836   \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}}%
10837   %
10838   \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}}%
10839   \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}}%
10840   \DeclareUnicodeCharacter{1EBC}{\~E}%
10841   \DeclareUnicodeCharacter{1EBD}{\~e}%
10842   %
10843   \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}}%
10844   \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}}%
10845   \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}}%
10846   \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}}%
10847   %
10848   \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}}%
10849   \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}}%
10850   %
10851   \DeclareUnicodeCharacter{1EF2}{\`Y}%
10852   \DeclareUnicodeCharacter{1EF3}{\`y}%
10853   \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}}%
10854   %
10855   \DeclareUnicodeCharacter{1EF8}{\~Y}%
10856   \DeclareUnicodeCharacter{1EF9}{\~y}%
10857   %
10858   % Punctuation
10859   \DeclareUnicodeCharacter{2013}{--}%
10860   \DeclareUnicodeCharacter{2014}{---}%
10861   \DeclareUnicodeCharacter{2018}{\quoteleft}%
10862   \DeclareUnicodeCharacter{2019}{\quoteright}%
10863   \DeclareUnicodeCharacter{201A}{\quotesinglbase}%
10864   \DeclareUnicodeCharacter{201C}{\quotedblleft}%
10865   \DeclareUnicodeCharacter{201D}{\quotedblright}%
10866   \DeclareUnicodeCharacter{201E}{\quotedblbase}%
10867   \DeclareUnicodeCharacter{2020}{\ensuremath\dagger}%
10868   \DeclareUnicodeCharacter{2021}{\ensuremath\ddagger}%
10869   \DeclareUnicodeCharacter{2022}{\bullet}%
10870   \DeclareUnicodeCharacter{202F}{\thinspace}%
10871   \DeclareUnicodeCharacter{2026}{\dots}%
10872   \DeclareUnicodeCharacter{2039}{\guilsinglleft}%
10873   \DeclareUnicodeCharacter{203A}{\guilsinglright}%
10874   %
10875   \DeclareUnicodeCharacter{20AC}{\euro}%
10876   %
10877   \DeclareUnicodeCharacter{2192}{\expansion}%
10878   \DeclareUnicodeCharacter{21D2}{\result}%
10879   %
10880   % Mathematical symbols
10881   \DeclareUnicodeCharacter{2200}{\ensuremath\forall}%
10882   \DeclareUnicodeCharacter{2203}{\ensuremath\exists}%
10883   \DeclareUnicodeCharacter{2208}{\ensuremath\in}%
10884   \DeclareUnicodeCharacter{2212}{\minus}%
10885   \DeclareUnicodeCharacter{2217}{\ast}%
10886   \DeclareUnicodeCharacter{221E}{\ensuremath\infty}%
10887   \DeclareUnicodeCharacter{2225}{\ensuremath\parallel}%
10888   \DeclareUnicodeCharacter{2227}{\ensuremath\wedge}%
10889   \DeclareUnicodeCharacter{2229}{\ensuremath\cap}%
10890   \DeclareUnicodeCharacter{2261}{\equiv}%
10891   \DeclareUnicodeCharacter{2264}{\ensuremath\leq}%
10892   \DeclareUnicodeCharacter{2265}{\ensuremath\geq}%
10893   \DeclareUnicodeCharacter{2282}{\ensuremath\subset}%
10894   \DeclareUnicodeCharacter{2287}{\ensuremath\supseteq}%
10895   %
10896   \DeclareUnicodeCharacter{2016}{\ensuremath\Vert}%
10897   \DeclareUnicodeCharacter{2032}{\ensuremath\prime}%
10898   \DeclareUnicodeCharacter{210F}{\ensuremath\hbar}%
10899   \DeclareUnicodeCharacter{2111}{\ensuremath\Im}%
10900   \DeclareUnicodeCharacter{2113}{\ensuremath\ell}%
10901   \DeclareUnicodeCharacter{2118}{\ensuremath\wp}%
10902   \DeclareUnicodeCharacter{211C}{\ensuremath\Re}%
10903   \DeclareUnicodeCharacter{2127}{\ensuremath\mho}%
10904   \DeclareUnicodeCharacter{2135}{\ensuremath\aleph}%
10905   \DeclareUnicodeCharacter{2190}{\ensuremath\leftarrow}%
10906   \DeclareUnicodeCharacter{2191}{\ensuremath\uparrow}%
10907   \DeclareUnicodeCharacter{2193}{\ensuremath\downarrow}%
10908   \DeclareUnicodeCharacter{2194}{\ensuremath\leftrightarrow}%
10909   \DeclareUnicodeCharacter{2195}{\ensuremath\updownarrow}%
10910   \DeclareUnicodeCharacter{2196}{\ensuremath\nwarrow}%
10911   \DeclareUnicodeCharacter{2197}{\ensuremath\nearrow}%
10912   \DeclareUnicodeCharacter{2198}{\ensuremath\searrow}%
10913   \DeclareUnicodeCharacter{2199}{\ensuremath\swarrow}%
10914   \DeclareUnicodeCharacter{21A6}{\ensuremath\mapsto}%
10915   \DeclareUnicodeCharacter{21A9}{\ensuremath\hookleftarrow}%
10916   \DeclareUnicodeCharacter{21AA}{\ensuremath\hookrightarrow}%
10917   \DeclareUnicodeCharacter{21BC}{\ensuremath\leftharpoonup}%
10918   \DeclareUnicodeCharacter{21BD}{\ensuremath\leftharpoondown}%
10919   \DeclareUnicodeCharacter{21BE}{\ensuremath\upharpoonright}%
10920   \DeclareUnicodeCharacter{21C0}{\ensuremath\rightharpoonup}%
10921   \DeclareUnicodeCharacter{21C1}{\ensuremath\rightharpoondown}%
10922   \DeclareUnicodeCharacter{21CC}{\ensuremath\rightleftharpoons}%
10923   \DeclareUnicodeCharacter{21D0}{\ensuremath\Leftarrow}%
10924   \DeclareUnicodeCharacter{21D1}{\ensuremath\Uparrow}%
10925   \DeclareUnicodeCharacter{21D3}{\ensuremath\Downarrow}%
10926   \DeclareUnicodeCharacter{21D4}{\ensuremath\Leftrightarrow}%
10927   \DeclareUnicodeCharacter{21D5}{\ensuremath\Updownarrow}%
10928   \DeclareUnicodeCharacter{21DD}{\ensuremath\leadsto}%
10929   \DeclareUnicodeCharacter{2201}{\ensuremath\complement}%
10930   \DeclareUnicodeCharacter{2202}{\ensuremath\partial}%
10931   \DeclareUnicodeCharacter{2205}{\ensuremath\emptyset}%
10932   \DeclareUnicodeCharacter{2207}{\ensuremath\nabla}%
10933   \DeclareUnicodeCharacter{2209}{\ensuremath\notin}%
10934   \DeclareUnicodeCharacter{220B}{\ensuremath\owns}%
10935   \DeclareUnicodeCharacter{220F}{\ensuremath\prod}%
10936   \DeclareUnicodeCharacter{2210}{\ensuremath\coprod}%
10937   \DeclareUnicodeCharacter{2211}{\ensuremath\sum}%
10938   \DeclareUnicodeCharacter{2213}{\ensuremath\mp}%
10939   \DeclareUnicodeCharacter{2218}{\ensuremath\circ}%
10940   \DeclareUnicodeCharacter{221A}{\ensuremath\surd}%
10941   \DeclareUnicodeCharacter{221D}{\ensuremath\propto}%
10942   \DeclareUnicodeCharacter{2220}{\ensuremath\angle}%
10943   \DeclareUnicodeCharacter{2223}{\ensuremath\mid}%
10944   \DeclareUnicodeCharacter{2228}{\ensuremath\vee}%
10945   \DeclareUnicodeCharacter{222A}{\ensuremath\cup}%
10946   \DeclareUnicodeCharacter{222B}{\ensuremath\smallint}%
10947   \DeclareUnicodeCharacter{222E}{\ensuremath\oint}%
10948   \DeclareUnicodeCharacter{223C}{\ensuremath\sim}%
10949   \DeclareUnicodeCharacter{2240}{\ensuremath\wr}%
10950   \DeclareUnicodeCharacter{2243}{\ensuremath\simeq}%
10951   \DeclareUnicodeCharacter{2245}{\ensuremath\cong}%
10952   \DeclareUnicodeCharacter{2248}{\ensuremath\approx}%
10953   \DeclareUnicodeCharacter{224D}{\ensuremath\asymp}%
10954   \DeclareUnicodeCharacter{2250}{\ensuremath\doteq}%
10955   \DeclareUnicodeCharacter{2260}{\ensuremath\neq}%
10956   \DeclareUnicodeCharacter{226A}{\ensuremath\ll}%
10957   \DeclareUnicodeCharacter{226B}{\ensuremath\gg}%
10958   \DeclareUnicodeCharacter{227A}{\ensuremath\prec}%
10959   \DeclareUnicodeCharacter{227B}{\ensuremath\succ}%
10960   \DeclareUnicodeCharacter{2283}{\ensuremath\supset}%
10961   \DeclareUnicodeCharacter{2286}{\ensuremath\subseteq}%
10962   \DeclareUnicodeCharacter{228E}{\ensuremath\uplus}%
10963   \DeclareUnicodeCharacter{228F}{\ensuremath\sqsubset}%
10964   \DeclareUnicodeCharacter{2290}{\ensuremath\sqsupset}%
10965   \DeclareUnicodeCharacter{2291}{\ensuremath\sqsubseteq}%
10966   \DeclareUnicodeCharacter{2292}{\ensuremath\sqsupseteq}%
10967   \DeclareUnicodeCharacter{2293}{\ensuremath\sqcap}%
10968   \DeclareUnicodeCharacter{2294}{\ensuremath\sqcup}%
10969   \DeclareUnicodeCharacter{2295}{\ensuremath\oplus}%
10970   \DeclareUnicodeCharacter{2296}{\ensuremath\ominus}%
10971   \DeclareUnicodeCharacter{2297}{\ensuremath\otimes}%
10972   \DeclareUnicodeCharacter{2298}{\ensuremath\oslash}%
10973   \DeclareUnicodeCharacter{2299}{\ensuremath\odot}%
10974   \DeclareUnicodeCharacter{22A2}{\ensuremath\vdash}%
10975   \DeclareUnicodeCharacter{22A3}{\ensuremath\dashv}%
10976   \DeclareUnicodeCharacter{22A4}{\ensuremath\ptextop}%
10977   \DeclareUnicodeCharacter{22A5}{\ensuremath\bot}%
10978   \DeclareUnicodeCharacter{22A8}{\ensuremath\models}%
10979   \DeclareUnicodeCharacter{22B4}{\ensuremath\unlhd}%
10980   \DeclareUnicodeCharacter{22B5}{\ensuremath\unrhd}%
10981   \DeclareUnicodeCharacter{22C0}{\ensuremath\bigwedge}%
10982   \DeclareUnicodeCharacter{22C1}{\ensuremath\bigvee}%
10983   \DeclareUnicodeCharacter{22C2}{\ensuremath\bigcap}%
10984   \DeclareUnicodeCharacter{22C3}{\ensuremath\bigcup}%
10985   \DeclareUnicodeCharacter{22C4}{\ensuremath\diamond}%
10986   \DeclareUnicodeCharacter{22C5}{\ensuremath\cdot}%
10987   \DeclareUnicodeCharacter{22C6}{\ensuremath\star}%
10988   \DeclareUnicodeCharacter{22C8}{\ensuremath\bowtie}%
10989   \DeclareUnicodeCharacter{2308}{\ensuremath\lceil}%
10990   \DeclareUnicodeCharacter{2309}{\ensuremath\rceil}%
10991   \DeclareUnicodeCharacter{230A}{\ensuremath\lfloor}%
10992   \DeclareUnicodeCharacter{230B}{\ensuremath\rfloor}%
10993   \DeclareUnicodeCharacter{2322}{\ensuremath\frown}%
10994   \DeclareUnicodeCharacter{2323}{\ensuremath\smile}%
10995   %
10996   \DeclareUnicodeCharacter{25A1}{\ensuremath\Box}%
10997   \DeclareUnicodeCharacter{25B3}{\ensuremath\triangle}%
10998   \DeclareUnicodeCharacter{25B7}{\ensuremath\triangleright}%
10999   \DeclareUnicodeCharacter{25BD}{\ensuremath\bigtriangledown}%
11000   \DeclareUnicodeCharacter{25C1}{\ensuremath\triangleleft}%
11001   \DeclareUnicodeCharacter{25C7}{\ensuremath\Diamond}%
11002   \DeclareUnicodeCharacter{2660}{\ensuremath\spadesuit}%
11003   \DeclareUnicodeCharacter{2661}{\ensuremath\heartsuit}%
11004   \DeclareUnicodeCharacter{2662}{\ensuremath\diamondsuit}%
11005   \DeclareUnicodeCharacter{2663}{\ensuremath\clubsuit}%
11006   \DeclareUnicodeCharacter{266D}{\ensuremath\flat}%
11007   \DeclareUnicodeCharacter{266E}{\ensuremath\natural}%
11008   \DeclareUnicodeCharacter{266F}{\ensuremath\sharp}%
11009   \DeclareUnicodeCharacter{26AA}{\ensuremath\bigcirc}%
11010   \DeclareUnicodeCharacter{27B9}{\ensuremath\rangle}%
11011   \DeclareUnicodeCharacter{27C2}{\ensuremath\perp}%
11012   \DeclareUnicodeCharacter{27E8}{\ensuremath\langle}%
11013   \DeclareUnicodeCharacter{27F5}{\ensuremath\longleftarrow}%
11014   \DeclareUnicodeCharacter{27F6}{\ensuremath\longrightarrow}%
11015   \DeclareUnicodeCharacter{27F7}{\ensuremath\longleftrightarrow}%
11016   \DeclareUnicodeCharacter{27FC}{\ensuremath\longmapsto}%
11017   \DeclareUnicodeCharacter{29F5}{\ensuremath\setminus}%
11018   \DeclareUnicodeCharacter{2A00}{\ensuremath\bigodot}%
11019   \DeclareUnicodeCharacter{2A01}{\ensuremath\bigoplus}%
11020   \DeclareUnicodeCharacter{2A02}{\ensuremath\bigotimes}%
11021   \DeclareUnicodeCharacter{2A04}{\ensuremath\biguplus}%
11022   \DeclareUnicodeCharacter{2A06}{\ensuremath\bigsqcup}%
11023   \DeclareUnicodeCharacter{2A1D}{\ensuremath\Join}%
11024   \DeclareUnicodeCharacter{2A3F}{\ensuremath\amalg}%
11025   \DeclareUnicodeCharacter{2AAF}{\ensuremath\preceq}%
11026   \DeclareUnicodeCharacter{2AB0}{\ensuremath\succeq}%
11027   %
11028   \global\mathchardef\checkmark="1370% actually the square root sign
11029   \DeclareUnicodeCharacter{2713}{\ensuremath\checkmark}%
11030 }% end of \unicodechardefs
11031
11032 % UTF-8 byte sequence (pdfTeX) definitions (replacing and @U command)
11033 % It makes the setting that replace UTF-8 byte sequence.
11034 \def\utfeightchardefs{%
11035   \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterUTFviii
11036   \unicodechardefs
11037 }
11038
11039 % Whether the active definitions of non-ASCII characters expand to
11040 % non-active tokens with the same character code.  This is used to
11041 % write characters literally, instead of using active definitions for
11042 % printing the correct glyphs.
11043 \newif\ifpassthroughchars
11044 \passthroughcharsfalse
11045
11046 % For native Unicode (XeTeX and LuaTeX)
11047 % Definition macro to replace / pass-through the Unicode character
11048 %
11049 \def\DeclareUnicodeCharacterNative#1#2{%
11050   \catcode"#1=\active
11051   \def\dodeclareunicodecharacternative##1##2##3{%
11052     \begingroup
11053       \uccode`\~="##2\relax
11054       \uppercase{\gdef~}{%
11055         \ifpassthroughchars
11056           ##1%
11057         \else
11058           ##3%
11059         \fi
11060       }
11061     \endgroup
11062   }
11063   \begingroup
11064     \uccode`\.="#1\relax
11065     \uppercase{\def\UTFNativeTmp{.}}%
11066     \expandafter\dodeclareunicodecharacternative\UTFNativeTmp{#1}{#2}%
11067   \endgroup
11068 }
11069
11070 % Native Unicode (XeTeX and LuaTeX) character replacing definitions
11071 % It makes the setting that replace the Unicode characters.
11072 \def\nativeunicodechardefs{%
11073   \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNative
11074   \unicodechardefs
11075 }
11076
11077 % For native Unicode (XeTeX and LuaTeX).  Make the character token expand
11078 % to the sequences given in \unicodechardefs for printing.
11079 \def\DeclareUnicodeCharacterNativeAtU#1#2{%
11080   \def\UTFAtUTmp{#2}
11081   \expandafter\globallet\csname uni:#1\endcsname \UTFAtUTmp
11082 }
11083
11084 % Native Unicode (XeTeX and LuaTeX) @U command definitions
11085 \def\nativeunicodechardefsatu{%
11086   \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNativeAtU
11087   \unicodechardefs
11088 }
11089
11090 % US-ASCII character definitions.
11091 \def\asciichardefs{% nothing need be done
11092    \relax
11093 }
11094
11095 % define all the unicode characters we know about, for the sake of @U.
11096 \iftxinativeunicodecapable
11097   \nativeunicodechardefsatu
11098 \else
11099   \utfeightchardefs
11100 \fi
11101
11102
11103 % Make non-ASCII characters printable again for compatibility with
11104 % existing Texinfo documents that may use them, even without declaring a
11105 % document encoding.
11106 %
11107 \setnonasciicharscatcode \other
11108
11109
11110 \message{formatting,}
11111
11112 \newdimen\defaultparindent \defaultparindent = 15pt
11113
11114 \chapheadingskip = 15pt plus 4pt minus 2pt
11115 \secheadingskip = 12pt plus 3pt minus 2pt
11116 \subsecheadingskip = 9pt plus 2pt minus 2pt
11117
11118 % Prevent underfull vbox error messages.
11119 \vbadness = 10000
11120
11121 % Don't be very finicky about underfull hboxes, either.
11122 \hbadness = 6666
11123
11124 % Following George Bush, get rid of widows and orphans.
11125 \widowpenalty=10000
11126 \clubpenalty=10000
11127
11128 % Use TeX 3.0's \emergencystretch to help line breaking, but if we're
11129 % using an old version of TeX, don't do anything.  We want the amount of
11130 % stretch added to depend on the line length, hence the dependence on
11131 % \hsize.  We call this whenever the paper size is set.
11132 %
11133 \def\setemergencystretch{%
11134   \ifx\emergencystretch\thisisundefined
11135     % Allow us to assign to \emergencystretch anyway.
11136     \def\emergencystretch{\dimen0}%
11137   \else
11138     \emergencystretch = .15\hsize
11139   \fi
11140 }
11141
11142 % Parameters in order: 1) textheight; 2) textwidth;
11143 % 3) voffset; 4) hoffset; 5) binding offset; 6) topskip;
11144 % 7) physical page height; 8) physical page width.
11145 %
11146 % We also call \setleading{\textleading}, so the caller should define
11147 % \textleading.  The caller should also set \parskip.
11148 %
11149 \def\internalpagesizes#1#2#3#4#5#6#7#8{%
11150   \voffset = #3\relax
11151   \topskip = #6\relax
11152   \splittopskip = \topskip
11153   %
11154   \vsize = #1\relax
11155   \advance\vsize by \topskip
11156   \outervsize = \vsize
11157   \advance\outervsize by 2\topandbottommargin
11158   \txipageheight = \vsize
11159   %
11160   \hsize = #2\relax
11161   \outerhsize = \hsize
11162   \advance\outerhsize by 0.5in
11163   \txipagewidth = \hsize
11164   %
11165   \normaloffset = #4\relax
11166   \bindingoffset = #5\relax
11167   %
11168   \ifpdf
11169     \pdfpageheight #7\relax
11170     \pdfpagewidth #8\relax
11171     % if we don't reset these, they will remain at "1 true in" of
11172     % whatever layout pdftex was dumped with.
11173     \pdfhorigin = 1 true in
11174     \pdfvorigin = 1 true in
11175   \else
11176     \ifx\XeTeXrevision\thisisundefined
11177     \else
11178       \pdfpageheight #7\relax
11179       \pdfpagewidth #8\relax
11180       % XeTeX does not have \pdfhorigin and \pdfvorigin.
11181     \fi
11182   \fi
11183   %
11184   \setleading{\textleading}
11185   %
11186   \parindent = \defaultparindent
11187   \setemergencystretch
11188 }
11189
11190 % @letterpaper (the default).
11191 \def\letterpaper{{\globaldefs = 1
11192   \parskip = 3pt plus 2pt minus 1pt
11193   \textleading = 13.2pt
11194   %
11195   % If page is nothing but text, make it come out even.
11196   \internalpagesizes{607.2pt}{6in}% that's 46 lines
11197                     {\voffset}{.25in}%
11198                     {\bindingoffset}{36pt}%
11199                     {11in}{8.5in}%
11200 }}
11201
11202 % Use @smallbook to reset parameters for 7x9.25 trim size.
11203 \def\smallbook{{\globaldefs = 1
11204   \parskip = 2pt plus 1pt
11205   \textleading = 12pt
11206   %
11207   \internalpagesizes{7.5in}{5in}%
11208                     {-.2in}{0in}%
11209                     {\bindingoffset}{16pt}%
11210                     {9.25in}{7in}%
11211   %
11212   \lispnarrowing = 0.3in
11213   \tolerance = 700
11214   \hfuzz = 1pt
11215   \contentsrightmargin = 0pt
11216   \defbodyindent = .5cm
11217 }}
11218
11219 % Use @smallerbook to reset parameters for 6x9 trim size.
11220 % (Just testing, parameters still in flux.)
11221 \def\smallerbook{{\globaldefs = 1
11222   \parskip = 1.5pt plus 1pt
11223   \textleading = 12pt
11224   %
11225   \internalpagesizes{7.4in}{4.8in}%
11226                     {-.2in}{-.4in}%
11227                     {0pt}{14pt}%
11228                     {9in}{6in}%
11229   %
11230   \lispnarrowing = 0.25in
11231   \tolerance = 700
11232   \hfuzz = 1pt
11233   \contentsrightmargin = 0pt
11234   \defbodyindent = .4cm
11235 }}
11236
11237 % Use @afourpaper to print on European A4 paper.
11238 \def\afourpaper{{\globaldefs = 1
11239   \parskip = 3pt plus 2pt minus 1pt
11240   \textleading = 13.2pt
11241   %
11242   % Double-side printing via postscript on Laserjet 4050
11243   % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm.
11244   % To change the settings for a different printer or situation, adjust
11245   % \normaloffset until the front-side and back-side texts align.  Then
11246   % do the same for \bindingoffset.  You can set these for testing in
11247   % your texinfo source file like this:
11248   % @tex
11249   % \global\normaloffset = -6mm
11250   % \global\bindingoffset = 10mm
11251   % @end tex
11252   \internalpagesizes{673.2pt}{160mm}% that's 51 lines
11253                     {\voffset}{\hoffset}%
11254                     {\bindingoffset}{44pt}%
11255                     {297mm}{210mm}%
11256   %
11257   \tolerance = 700
11258   \hfuzz = 1pt
11259   \contentsrightmargin = 0pt
11260   \defbodyindent = 5mm
11261 }}
11262
11263 % Use @afivepaper to print on European A5 paper.
11264 % From romildo@urano.iceb.ufop.br, 2 July 2000.
11265 % He also recommends making @example and @lisp be small.
11266 \def\afivepaper{{\globaldefs = 1
11267   \parskip = 2pt plus 1pt minus 0.1pt
11268   \textleading = 12.5pt
11269   %
11270   \internalpagesizes{160mm}{120mm}%
11271                     {\voffset}{\hoffset}%
11272                     {\bindingoffset}{8pt}%
11273                     {210mm}{148mm}%
11274   %
11275   \lispnarrowing = 0.2in
11276   \tolerance = 800
11277   \hfuzz = 1.2pt
11278   \contentsrightmargin = 0pt
11279   \defbodyindent = 2mm
11280   \tableindent = 12mm
11281 }}
11282
11283 % A specific text layout, 24x15cm overall, intended for A4 paper.
11284 \def\afourlatex{{\globaldefs = 1
11285   \afourpaper
11286   \internalpagesizes{237mm}{150mm}%
11287                     {\voffset}{4.6mm}%
11288                     {\bindingoffset}{7mm}%
11289                     {297mm}{210mm}%
11290   %
11291   % Must explicitly reset to 0 because we call \afourpaper.
11292   \globaldefs = 0
11293 }}
11294
11295 % Use @afourwide to print on A4 paper in landscape format.
11296 \def\afourwide{{\globaldefs = 1
11297   \afourpaper
11298   \internalpagesizes{241mm}{165mm}%
11299                     {\voffset}{-2.95mm}%
11300                     {\bindingoffset}{7mm}%
11301                     {297mm}{210mm}%
11302   \globaldefs = 0
11303 }}
11304
11305 % @pagesizes TEXTHEIGHT[,TEXTWIDTH]
11306 % Perhaps we should allow setting the margins, \topskip, \parskip,
11307 % and/or leading, also. Or perhaps we should compute them somehow.
11308 %
11309 \parseargdef\pagesizes{\pagesizesyyy #1,,\finish}
11310 \def\pagesizesyyy#1,#2,#3\finish{{%
11311   \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi
11312   \globaldefs = 1
11313   %
11314   \parskip = 3pt plus 2pt minus 1pt
11315   \setleading{\textleading}%
11316   %
11317   \dimen0 = #1\relax
11318   \advance\dimen0 by \voffset
11319   %
11320   \dimen2 = \hsize
11321   \advance\dimen2 by \normaloffset
11322   %
11323   \internalpagesizes{#1}{\hsize}%
11324                     {\voffset}{\normaloffset}%
11325                     {\bindingoffset}{44pt}%
11326                     {\dimen0}{\dimen2}%
11327 }}
11328
11329 % Set default to letter.
11330 %
11331 \letterpaper
11332
11333
11334 \message{and turning on texinfo input format.}
11335
11336 \def^^L{\par} % remove \outer, so ^L can appear in an @comment
11337
11338 % DEL is a comment character, in case @c does not suffice.
11339 \catcode`\^^? = 14
11340
11341 % Define macros to output various characters with catcode for normal text.
11342 \catcode`\"=\other \def\normaldoublequote{"}
11343 \catcode`\$=\other \def\normaldollar{$}%$ font-lock fix
11344 \catcode`\+=\other \def\normalplus{+}
11345 \catcode`\<=\other \def\normalless{<}
11346 \catcode`\>=\other \def\normalgreater{>}
11347 \catcode`\^=\other \def\normalcaret{^}
11348 \catcode`\_=\other \def\normalunderscore{_}
11349 \catcode`\|=\other \def\normalverticalbar{|}
11350 \catcode`\~=\other \def\normaltilde{~}
11351
11352 % This macro is used to make a character print one way in \tt
11353 % (where it can probably be output as-is), and another way in other fonts,
11354 % where something hairier probably needs to be done.
11355 %
11356 % #1 is what to print if we are indeed using \tt; #2 is what to print
11357 % otherwise.  Since all the Computer Modern typewriter fonts have zero
11358 % interword stretch (and shrink), and it is reasonable to expect all
11359 % typewriter fonts to have this, we can check that font parameter.
11360 %
11361 \def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi}
11362
11363 % Same as above, but check for italic font.  Actually this also catches
11364 % non-italic slanted fonts since it is impossible to distinguish them from
11365 % italic fonts.  But since this is only used by $ and it uses \sl anyway
11366 % this is not a problem.
11367 \def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi}
11368
11369 % Set catcodes for Texinfo file
11370
11371 % Active characters for printing the wanted glyph.
11372 % Most of these we simply print from the \tt font, but for some, we can
11373 % use math or other variants that look better in normal text.
11374 %
11375 \catcode`\"=\active
11376 \def\activedoublequote{{\tt\char34}}
11377 \let"=\activedoublequote
11378 \catcode`\~=\active \def\activetilde{{\tt\char126}} \let~ = \activetilde
11379 \chardef\hatchar=`\^
11380 \catcode`\^=\active \def\activehat{{\tt \hatchar}} \let^ = \activehat
11381
11382 \catcode`\_=\active
11383 \def_{\ifusingtt\normalunderscore\_}
11384 \def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }
11385 \let\realunder=_
11386
11387 \catcode`\|=\active \def|{{\tt\char124}}
11388
11389 \chardef \less=`\<
11390 \catcode`\<=\active \def\activeless{{\tt \less}}\let< = \activeless
11391 \chardef \gtr=`\>
11392 \catcode`\>=\active \def\activegtr{{\tt \gtr}}\let> = \activegtr
11393 \catcode`\+=\active \def+{{\tt \char 43}}
11394 \catcode`\$=\active \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix
11395 \catcode`\-=\active \let-=\normaldash
11396
11397
11398 % used for headline/footline in the output routine, in case the page
11399 % breaks in the middle of an @tex block.
11400 \def\texinfochars{%
11401   \let< = \activeless
11402   \let> = \activegtr
11403   \let~ = \activetilde 
11404   \let^ = \activehat
11405   \markupsetuplqdefault \markupsetuprqdefault 
11406   \let\b = \strong
11407   \let\i = \smartitalic
11408   % in principle, all other definitions in \tex have to be undone too.
11409 }
11410
11411 % Used sometimes to turn off (effectively) the active characters even after
11412 % parsing them.
11413 \def\turnoffactive{%
11414   \normalturnoffactive
11415   \otherbackslash
11416 }
11417
11418 \catcode`\@=0
11419
11420 % \backslashcurfont outputs one backslash character in current font,
11421 % as in \char`\\.
11422 \global\chardef\backslashcurfont=`\\
11423 \global\let\rawbackslashxx=\backslashcurfont  % let existing .??s files work
11424
11425 % \realbackslash is an actual character `\' with catcode other, and
11426 % \doublebackslash is two of them (for the pdf outlines).
11427 {\catcode`\\=\other @gdef@realbackslash{\} @gdef@doublebackslash{\\}}
11428
11429 % In Texinfo, backslash is an active character; it prints the backslash
11430 % in fixed width font.
11431 \catcode`\\=\active  % @ for escape char from now on.
11432
11433 % Print a typewriter backslash.  For math mode, we can't simply use
11434 % \backslashcurfont: the story here is that in math mode, the \char
11435 % of \backslashcurfont ends up printing the roman \ from the math symbol
11436 % font (because \char in math mode uses the \mathcode, and plain.tex
11437 % sets \mathcode`\\="026E).  Hence we use an explicit \mathchar,
11438 % which is the decimal equivalent of "715c (class 7, e.g., use \fam;
11439 % ignored family value; char position "5C).  We can't use " for the
11440 % usual hex value because it has already been made active.
11441
11442 @def@ttbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}}
11443 @let@backslashchar = @ttbackslash % @backslashchar{} is for user documents.
11444
11445 % \rawbackslash defines an active \ to do \backslashcurfont.
11446 % \otherbackslash defines an active \ to be a literal `\' character with
11447 % catcode other.  We switch back and forth between these.
11448 @gdef@rawbackslash{@let\=@backslashcurfont}
11449 @gdef@otherbackslash{@let\=@realbackslash}
11450
11451 % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
11452 % the literal character `\'.
11453 %
11454 {@catcode`- = @active
11455  @gdef@normalturnoffactive{%
11456    @passthroughcharstrue
11457    @let-=@normaldash
11458    @let"=@normaldoublequote
11459    @let$=@normaldollar %$ font-lock fix
11460    @let+=@normalplus
11461    @let<=@normalless
11462    @let>=@normalgreater
11463    @let^=@normalcaret
11464    @let_=@normalunderscore
11465    @let|=@normalverticalbar
11466    @let~=@normaltilde
11467    @let\=@ttbackslash
11468    @markupsetuplqdefault
11469    @markupsetuprqdefault
11470    @unsepspaces
11471  }
11472 }
11473
11474 % If a .fmt file is being used, characters that might appear in a file
11475 % name cannot be active until we have parsed the command line.
11476 % So turn them off again, and have @fixbackslash turn them back on.
11477 @catcode`+=@other @catcode`@_=@other
11478
11479 % \enablebackslashhack - allow file to begin `\input texinfo'
11480 %
11481 % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
11482 % That is what \eatinput is for; after that, the `\' should revert to printing
11483 % a backslash.
11484 % If the file did not have a `\input texinfo', then it is turned off after
11485 % the first line; otherwise the first `\' in the file would cause an error.
11486 % This is used on the very last line of this file, texinfo.tex.
11487 % We also use @c to call @fixbackslash, in case ends of lines are hidden.
11488 {
11489 @catcode`@^=7
11490 @catcode`@^^M=13@gdef@enablebackslashhack{%
11491   @global@let\ = @eatinput%
11492   @catcode`@^^M=13%
11493   @def@c{@fixbackslash@c}%
11494   % Definition for the newline at the end of this file.
11495   @def ^^M{@let^^M@secondlinenl}%
11496   % Definition for a newline in the main Texinfo file.
11497   @gdef @secondlinenl{@fixbackslash}%
11498 }}
11499
11500 {@catcode`@^=7 @catcode`@^^M=13%
11501 @gdef@eatinput input texinfo#1^^M{@fixbackslash}}
11502
11503 % Emergency active definition of newline, in case an active newline token
11504 % appears by mistake.
11505 {@catcode`@^=7 @catcode13=13%
11506 @gdef@enableemergencynewline{%
11507   @gdef^^M{%
11508     @par%
11509     %<warning: active newline>@par%
11510 }}}
11511
11512
11513 @gdef@fixbackslash{%
11514   @ifx\@eatinput @let\ = @ttbackslash @fi
11515   @catcode13=5 % regular end of line
11516   @enableemergencynewline
11517   @let@c=@texinfoc
11518   % Also turn back on active characters that might appear in the input
11519   % file name, in case not using a pre-dumped format.
11520   @catcode`+=@active
11521   @catcode`@_=@active
11522   %
11523   % If texinfo.cnf is present on the system, read it.
11524   % Useful for site-wide @afourpaper, etc.  This macro, @fixbackslash, gets
11525   % called at the beginning of every Texinfo file.  Not opening texinfo.cnf
11526   % directly in this file, texinfo.tex, makes it possible to make a format
11527   % file for Texinfo.
11528   %
11529   @openin 1 texinfo.cnf
11530   @ifeof 1 @else @input texinfo.cnf @fi
11531   @closein 1
11532 }
11533
11534
11535 % Say @foo, not \foo, in error messages.
11536 @escapechar = `@@
11537
11538 % These (along with & and #) are made active for url-breaking, so need
11539 % active definitions as the normal characters.
11540 @def@normaldot{.}
11541 @def@normalquest{?}
11542 @def@normalslash{/}
11543
11544 % These look ok in all fonts, so just make them not special.
11545 % @hashchar{} gets its own user-level command, because of #line.
11546 @catcode`@& = @other @def@normalamp{&}
11547 @catcode`@# = @other @def@normalhash{#}
11548 @catcode`@% = @other @def@normalpercent{%}
11549
11550 @let @hashchar = @normalhash
11551
11552 @c Finally, make ` and ' active, so that txicodequoteundirected and
11553 @c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}.  If we
11554 @c don't make ` and ' active, @code will not get them as active chars.
11555 @c Do this last of all since we use ` in the previous @catcode assignments.
11556 @catcode`@'=@active
11557 @catcode`@`=@active
11558 @markupsetuplqdefault
11559 @markupsetuprqdefault
11560
11561 @c Local variables:
11562 @c eval: (add-hook 'write-file-hooks 'time-stamp)
11563 @c page-delimiter: "^\\\\message\\|emacs-page"
11564 @c time-stamp-start: "def\\\\texinfoversion{"
11565 @c time-stamp-format: "%:y-%02m-%02d.%02H"
11566 @c time-stamp-end: "}"
11567 @c End:
11568
11569 @c vim:sw=2:
11570
11571 @ignore
11572    arch-tag: e1b36e32-c96e-4135-a41a-0b2efa2ea115
11573 @end ignore
11574 @enablebackslashhack