autoupdate
[gnulib.git] / build-aux / texinfo.tex
1 % texinfo.tex -- TeX macros to handle Texinfo files.
2
3 % Load plain if necessary, i.e., if running under initex.
4 \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
5 %
6 \def\texinfoversion{2011-08-14.17}
7 %
8 % Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
9 % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
10 % 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
11 %
12 % This texinfo.tex file is free software: you can redistribute it and/or
13 % modify it under the terms of the GNU General Public License as
14 % published by the Free Software Foundation, either version 3 of the
15 % License, or (at your option) any later version.
16 %
17 % This texinfo.tex file is distributed in the hope that it will be
18 % useful, but WITHOUT ANY WARRANTY; without even the implied warranty
19 % of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20 % General Public License for more details.
21 %
22 % You should have received a copy of the GNU General Public License
23 % along with this program.  If not, see <http://www.gnu.org/licenses/>.
24 %
25 % As a special exception, when this file is read by TeX when processing
26 % a Texinfo source document, you may use the result without
27 % restriction.  (This has been our intent since Texinfo was invented.)
28 %
29 % Please try the latest version of texinfo.tex before submitting bug
30 % reports; you can get the latest version from:
31 %   http://www.gnu.org/software/texinfo/ (the Texinfo home page), or
32 %   ftp://tug.org/tex/texinfo.tex
33 %     (and all CTAN mirrors, see http://www.ctan.org).
34 % The texinfo.tex in any given distribution could well be out
35 % of date, so if that's what you're using, please check.
36 %
37 % Send bug reports to bug-texinfo@gnu.org.  Please include including a
38 % complete document in each bug report with which we can reproduce the
39 % problem.  Patches are, of course, greatly appreciated.
40 %
41 % To process a Texinfo manual with TeX, it's most reliable to use the
42 % texi2dvi shell script that comes with the distribution.  For a simple
43 % manual foo.texi, however, you can get away with this:
44 %   tex foo.texi
45 %   texindex foo.??
46 %   tex foo.texi
47 %   tex foo.texi
48 %   dvips foo.dvi -o  # or whatever; this makes foo.ps.
49 % The extra TeX runs get the cross-reference information correct.
50 % Sometimes one run after texindex suffices, and sometimes you need more
51 % than two; texi2dvi does it as many times as necessary.
52 %
53 % It is possible to adapt texinfo.tex for other languages, to some
54 % extent.  You can get the existing language-specific files from the
55 % full Texinfo distribution.
56 %
57 % The GNU Texinfo home page is http://www.gnu.org/software/texinfo.
58
59
60 \message{Loading texinfo [version \texinfoversion]:}
61
62 % If in a .fmt file, print the version number
63 % and turn on active characters that we couldn't do earlier because
64 % they might have appeared in the input file name.
65 \everyjob{\message{[Texinfo version \texinfoversion]}%
66   \catcode`+=\active \catcode`\_=\active}
67
68 \chardef\other=12
69
70 % We never want plain's \outer definition of \+ in Texinfo.
71 % For @tex, we can use \tabalign.
72 \let\+ = \relax
73
74 % Save some plain tex macros whose names we will redefine.
75 \let\ptexb=\b
76 \let\ptexbullet=\bullet
77 \let\ptexc=\c
78 \let\ptexcomma=\,
79 \let\ptexdot=\.
80 \let\ptexdots=\dots
81 \let\ptexend=\end
82 \let\ptexequiv=\equiv
83 \let\ptexexclam=\!
84 \let\ptexfootnote=\footnote
85 \let\ptexgtr=>
86 \let\ptexhat=^
87 \let\ptexi=\i
88 \let\ptexindent=\indent
89 \let\ptexinsert=\insert
90 \let\ptexlbrace=\{
91 \let\ptexless=<
92 \let\ptexnewwrite\newwrite
93 \let\ptexnoindent=\noindent
94 \let\ptexplus=+
95 \let\ptexraggedright=\raggedright
96 \let\ptexrbrace=\}
97 \let\ptexslash=\/
98 \let\ptexstar=\*
99 \let\ptext=\t
100 \let\ptextop=\top
101 {\catcode`\'=\active \global\let\ptexquoteright'}% active in plain's math mode
102
103 % If this character appears in an error message or help string, it
104 % starts a new line in the output.
105 \newlinechar = `^^J
106
107 % Use TeX 3.0's \inputlineno to get the line number, for better error
108 % messages, but if we're using an old version of TeX, don't do anything.
109 %
110 \ifx\inputlineno\thisisundefined
111   \let\linenumber = \empty % Pre-3.0.
112 \else
113   \def\linenumber{l.\the\inputlineno:\space}
114 \fi
115
116 % Set up fixed words for English if not already set.
117 \ifx\putwordAppendix\undefined  \gdef\putwordAppendix{Appendix}\fi
118 \ifx\putwordChapter\undefined   \gdef\putwordChapter{Chapter}\fi
119 \ifx\putwordfile\undefined      \gdef\putwordfile{file}\fi
120 \ifx\putwordin\undefined        \gdef\putwordin{in}\fi
121 \ifx\putwordIndexIsEmpty\undefined       \gdef\putwordIndexIsEmpty{(Index is empty)}\fi
122 \ifx\putwordIndexNonexistent\undefined   \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi
123 \ifx\putwordInfo\undefined      \gdef\putwordInfo{Info}\fi
124 \ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi
125 \ifx\putwordMethodon\undefined  \gdef\putwordMethodon{Method on}\fi
126 \ifx\putwordNoTitle\undefined   \gdef\putwordNoTitle{No Title}\fi
127 \ifx\putwordof\undefined        \gdef\putwordof{of}\fi
128 \ifx\putwordon\undefined        \gdef\putwordon{on}\fi
129 \ifx\putwordpage\undefined      \gdef\putwordpage{page}\fi
130 \ifx\putwordsection\undefined   \gdef\putwordsection{section}\fi
131 \ifx\putwordSection\undefined   \gdef\putwordSection{Section}\fi
132 \ifx\putwordsee\undefined       \gdef\putwordsee{see}\fi
133 \ifx\putwordSee\undefined       \gdef\putwordSee{See}\fi
134 \ifx\putwordShortTOC\undefined  \gdef\putwordShortTOC{Short Contents}\fi
135 \ifx\putwordTOC\undefined       \gdef\putwordTOC{Table of Contents}\fi
136 %
137 \ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi
138 \ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi
139 \ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi
140 \ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi
141 \ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi
142 \ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi
143 \ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi
144 \ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi
145 \ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi
146 \ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi
147 \ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi
148 \ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi
149 %
150 \ifx\putwordDefmac\undefined    \gdef\putwordDefmac{Macro}\fi
151 \ifx\putwordDefspec\undefined   \gdef\putwordDefspec{Special Form}\fi
152 \ifx\putwordDefvar\undefined    \gdef\putwordDefvar{Variable}\fi
153 \ifx\putwordDefopt\undefined    \gdef\putwordDefopt{User Option}\fi
154 \ifx\putwordDeffunc\undefined   \gdef\putwordDeffunc{Function}\fi
155
156 % Since the category of space is not known, we have to be careful.
157 \chardef\spacecat = 10
158 \def\spaceisspace{\catcode`\ =\spacecat}
159
160 % sometimes characters are active, so we need control sequences.
161 \chardef\ampChar   = `\&
162 \chardef\colonChar = `\:
163 \chardef\commaChar = `\,
164 \chardef\dashChar  = `\-
165 \chardef\dotChar   = `\.
166 \chardef\exclamChar= `\!
167 \chardef\hashChar  = `\#
168 \chardef\lquoteChar= `\`
169 \chardef\questChar = `\?
170 \chardef\rquoteChar= `\'
171 \chardef\semiChar  = `\;
172 \chardef\slashChar = `\/
173 \chardef\underChar = `\_
174
175 % Ignore a token.
176 %
177 \def\gobble#1{}
178
179 % The following is used inside several \edef's.
180 \def\makecsname#1{\expandafter\noexpand\csname#1\endcsname}
181
182 % Hyphenation fixes.
183 \hyphenation{
184   Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script
185   ap-pen-dix bit-map bit-maps
186   data-base data-bases eshell fall-ing half-way long-est man-u-script
187   man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm
188   par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces
189   spell-ing spell-ings
190   stand-alone strong-est time-stamp time-stamps which-ever white-space
191   wide-spread wrap-around
192 }
193
194 % Margin to add to right of even pages, to left of odd pages.
195 \newdimen\bindingoffset
196 \newdimen\normaloffset
197 \newdimen\pagewidth \newdimen\pageheight
198
199 % For a final copy, take out the rectangles
200 % that mark overfull boxes (in case you have decided
201 % that the text looks ok even though it passes the margin).
202 %
203 \def\finalout{\overfullrule=0pt }
204
205 % Sometimes it is convenient to have everything in the transcript file
206 % and nothing on the terminal.  We don't just call \tracingall here,
207 % since that produces some useless output on the terminal.  We also make
208 % some effort to order the tracing commands to reduce output in the log
209 % file; cf. trace.sty in LaTeX.
210 %
211 \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
212 \def\loggingall{%
213   \tracingstats2
214   \tracingpages1
215   \tracinglostchars2  % 2 gives us more in etex
216   \tracingparagraphs1
217   \tracingoutput1
218   \tracingmacros2
219   \tracingrestores1
220   \showboxbreadth\maxdimen \showboxdepth\maxdimen
221   \ifx\eTeXversion\thisisundefined\else % etex gives us more logging
222     \tracingscantokens1
223     \tracingifs1
224     \tracinggroups1
225     \tracingnesting2
226     \tracingassigns1
227   \fi
228   \tracingcommands3  % 3 gives us more in etex
229   \errorcontextlines16
230 }%
231
232 % add check for \lastpenalty to plain's definitions.  If the last thing
233 % we did was a \nobreak, we don't want to insert more space.
234 %
235 \def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount
236   \removelastskip\penalty-50\smallskip\fi\fi}
237 \def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount
238   \removelastskip\penalty-100\medskip\fi\fi}
239 \def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount
240   \removelastskip\penalty-200\bigskip\fi\fi}
241
242 % Do @cropmarks to get crop marks.
243 %
244 \newif\ifcropmarks
245 \let\cropmarks = \cropmarkstrue
246 %
247 % Dimensions to add cropmarks at corners.
248 % Added by P. A. MacKay, 12 Nov. 1986
249 %
250 \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines
251 \newdimen\cornerlong  \cornerlong=1pc
252 \newdimen\cornerthick \cornerthick=.3pt
253 \newdimen\topandbottommargin \topandbottommargin=.75in
254
255 % Output a mark which sets \thischapter, \thissection and \thiscolor.
256 % We dump everything together because we only have one kind of mark.
257 % This works because we only use \botmark / \topmark, not \firstmark.
258 %
259 % A mark contains a subexpression of the \ifcase ... \fi construct.
260 % \get*marks macros below extract the needed part using \ifcase.
261 %
262 % Another complication is to let the user choose whether \thischapter
263 % (\thissection) refers to the chapter (section) in effect at the top
264 % of a page, or that at the bottom of a page.  The solution is
265 % described on page 260 of The TeXbook.  It involves outputting two
266 % marks for the sectioning macros, one before the section break, and
267 % one after.  I won't pretend I can describe this better than DEK...
268 \def\domark{%
269   \toks0=\expandafter{\lastchapterdefs}%
270   \toks2=\expandafter{\lastsectiondefs}%
271   \toks4=\expandafter{\prevchapterdefs}%
272   \toks6=\expandafter{\prevsectiondefs}%
273   \toks8=\expandafter{\lastcolordefs}%
274   \mark{%
275                    \the\toks0 \the\toks2
276       \noexpand\or \the\toks4 \the\toks6
277     \noexpand\else \the\toks8
278   }%
279 }
280 % \topmark doesn't work for the very first chapter (after the title
281 % page or the contents), so we use \firstmark there -- this gets us
282 % the mark with the chapter defs, unless the user sneaks in, e.g.,
283 % @setcolor (or @url, or @link, etc.) between @contents and the very
284 % first @chapter.
285 \def\gettopheadingmarks{%
286   \ifcase0\topmark\fi
287   \ifx\thischapter\empty \ifcase0\firstmark\fi \fi
288 }
289 \def\getbottomheadingmarks{\ifcase1\botmark\fi}
290 \def\getcolormarks{\ifcase2\topmark\fi}
291
292 % Avoid "undefined control sequence" errors.
293 \def\lastchapterdefs{}
294 \def\lastsectiondefs{}
295 \def\prevchapterdefs{}
296 \def\prevsectiondefs{}
297 \def\lastcolordefs{}
298
299 % Main output routine.
300 \chardef\PAGE = 255
301 \output = {\onepageout{\pagecontents\PAGE}}
302
303 \newbox\headlinebox
304 \newbox\footlinebox
305
306 % \onepageout takes a vbox as an argument.  Note that \pagecontents
307 % does insertions, but you have to call it yourself.
308 \def\onepageout#1{%
309   \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi
310   %
311   \ifodd\pageno  \advance\hoffset by \bindingoffset
312   \else \advance\hoffset by -\bindingoffset\fi
313   %
314   % Do this outside of the \shipout so @code etc. will be expanded in
315   % the headline as they should be, not taken literally (outputting ''code).
316   \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi
317   \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}%
318   \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi
319   \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}%
320   %
321   {%
322     % Have to do this stuff outside the \shipout because we want it to
323     % take effect in \write's, yet the group defined by the \vbox ends
324     % before the \shipout runs.
325     %
326     \indexdummies         % don't expand commands in the output.
327     \normalturnoffactive  % \ in index entries must not stay \, e.g., if
328                % the page break happens to be in the middle of an example.
329                % We don't want .vr (or whatever) entries like this:
330                % \entry{{\tt \indexbackslash }acronym}{32}{\code {\acronym}}
331                % "\acronym" won't work when it's read back in;
332                % it needs to be
333                % {\code {{\tt \backslashcurfont }acronym}
334     \shipout\vbox{%
335       % Do this early so pdf references go to the beginning of the page.
336       \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi
337       %
338       \ifcropmarks \vbox to \outervsize\bgroup
339         \hsize = \outerhsize
340         \vskip-\topandbottommargin
341         \vtop to0pt{%
342           \line{\ewtop\hfil\ewtop}%
343           \nointerlineskip
344           \line{%
345             \vbox{\moveleft\cornerthick\nstop}%
346             \hfill
347             \vbox{\moveright\cornerthick\nstop}%
348           }%
349           \vss}%
350         \vskip\topandbottommargin
351         \line\bgroup
352           \hfil % center the page within the outer (page) hsize.
353           \ifodd\pageno\hskip\bindingoffset\fi
354           \vbox\bgroup
355       \fi
356       %
357       \unvbox\headlinebox
358       \pagebody{#1}%
359       \ifdim\ht\footlinebox > 0pt
360         % Only leave this space if the footline is nonempty.
361         % (We lessened \vsize for it in \oddfootingyyy.)
362         % The \baselineskip=24pt in plain's \makefootline has no effect.
363         \vskip 24pt
364         \unvbox\footlinebox
365       \fi
366       %
367       \ifcropmarks
368           \egroup % end of \vbox\bgroup
369         \hfil\egroup % end of (centering) \line\bgroup
370         \vskip\topandbottommargin plus1fill minus1fill
371         \boxmaxdepth = \cornerthick
372         \vbox to0pt{\vss
373           \line{%
374             \vbox{\moveleft\cornerthick\nsbot}%
375             \hfill
376             \vbox{\moveright\cornerthick\nsbot}%
377           }%
378           \nointerlineskip
379           \line{\ewbot\hfil\ewbot}%
380         }%
381       \egroup % \vbox from first cropmarks clause
382       \fi
383     }% end of \shipout\vbox
384   }% end of group with \indexdummies
385   \advancepageno
386   \ifnum\outputpenalty>-20000 \else\dosupereject\fi
387 }
388
389 \newinsert\margin \dimen\margin=\maxdimen
390
391 \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
392 {\catcode`\@ =11
393 \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
394 % marginal hacks, juha@viisa.uucp (Juha Takala)
395 \ifvoid\margin\else % marginal info is present
396   \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi
397 \dimen@=\dp#1\relax \unvbox#1\relax
398 \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
399 \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
400 }
401
402 % Here are the rules for the cropmarks.  Note that they are
403 % offset so that the space between them is truly \outerhsize or \outervsize
404 % (P. A. MacKay, 12 November, 1986)
405 %
406 \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
407 \def\nstop{\vbox
408   {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
409 \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
410 \def\nsbot{\vbox
411   {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
412
413 % Parse an argument, then pass it to #1.  The argument is the rest of
414 % the input line (except we remove a trailing comment).  #1 should be a
415 % macro which expects an ordinary undelimited TeX argument.
416 %
417 \def\parsearg{\parseargusing{}}
418 \def\parseargusing#1#2{%
419   \def\argtorun{#2}%
420   \begingroup
421     \obeylines
422     \spaceisspace
423     #1%
424     \parseargline\empty% Insert the \empty token, see \finishparsearg below.
425 }
426
427 {\obeylines %
428   \gdef\parseargline#1^^M{%
429     \endgroup % End of the group started in \parsearg.
430     \argremovecomment #1\comment\ArgTerm%
431   }%
432 }
433
434 % First remove any @comment, then any @c comment.
435 \def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm}
436 \def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
437
438 % Each occurrence of `\^^M' or `<space>\^^M' is replaced by a single space.
439 %
440 % \argremovec might leave us with trailing space, e.g.,
441 %    @end itemize  @c foo
442 % This space token undergoes the same procedure and is eventually removed
443 % by \finishparsearg.
444 %
445 \def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M}
446 \def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M}
447 \def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{%
448   \def\temp{#3}%
449   \ifx\temp\empty
450     % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp:
451     \let\temp\finishparsearg
452   \else
453     \let\temp\argcheckspaces
454   \fi
455   % Put the space token in:
456   \temp#1 #3\ArgTerm
457 }
458
459 % If a _delimited_ argument is enclosed in braces, they get stripped; so
460 % to get _exactly_ the rest of the line, we had to prevent such situation.
461 % We prepended an \empty token at the very beginning and we expand it now,
462 % just before passing the control to \argtorun.
463 % (Similarly, we have to think about #3 of \argcheckspacesY above: it is
464 % either the null string, or it ends with \^^M---thus there is no danger
465 % that a pair of braces would be stripped.
466 %
467 % But first, we have to remove the trailing space token.
468 %
469 \def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}}
470
471 % \parseargdef\foo{...}
472 %       is roughly equivalent to
473 % \def\foo{\parsearg\Xfoo}
474 % \def\Xfoo#1{...}
475 %
476 % Actually, I use \csname\string\foo\endcsname, ie. \\foo, as it is my
477 % favourite TeX trick.  --kasal, 16nov03
478
479 \def\parseargdef#1{%
480   \expandafter \doparseargdef \csname\string#1\endcsname #1%
481 }
482 \def\doparseargdef#1#2{%
483   \def#2{\parsearg#1}%
484   \def#1##1%
485 }
486
487 % Several utility definitions with active space:
488 {
489   \obeyspaces
490   \gdef\obeyedspace{ }
491
492   % Make each space character in the input produce a normal interword
493   % space in the output.  Don't allow a line break at this space, as this
494   % is used only in environments like @example, where each line of input
495   % should produce a line of output anyway.
496   %
497   \gdef\sepspaces{\obeyspaces\let =\tie}
498
499   % If an index command is used in an @example environment, any spaces
500   % therein should become regular spaces in the raw index file, not the
501   % expansion of \tie (\leavevmode \penalty \@M \ ).
502   \gdef\unsepspaces{\let =\space}
503 }
504
505
506 \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
507
508 % Define the framework for environments in texinfo.tex.  It's used like this:
509 %
510 %   \envdef\foo{...}
511 %   \def\Efoo{...}
512 %
513 % It's the responsibility of \envdef to insert \begingroup before the
514 % actual body; @end closes the group after calling \Efoo.  \envdef also
515 % defines \thisenv, so the current environment is known; @end checks
516 % whether the environment name matches.  The \checkenv macro can also be
517 % used to check whether the current environment is the one expected.
518 %
519 % Non-false conditionals (@iftex, @ifset) don't fit into this, so they
520 % are not treated as environments; they don't open a group.  (The
521 % implementation of @end takes care not to call \endgroup in this
522 % special case.)
523
524
525 % At run-time, environments start with this:
526 \def\startenvironment#1{\begingroup\def\thisenv{#1}}
527 % initialize
528 \let\thisenv\empty
529
530 % ... but they get defined via ``\envdef\foo{...}'':
531 \long\def\envdef#1#2{\def#1{\startenvironment#1#2}}
532 \def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}}
533
534 % Check whether we're in the right environment:
535 \def\checkenv#1{%
536   \def\temp{#1}%
537   \ifx\thisenv\temp
538   \else
539     \badenverr
540   \fi
541 }
542
543 % Environment mismatch, #1 expected:
544 \def\badenverr{%
545   \errhelp = \EMsimple
546   \errmessage{This command can appear only \inenvironment\temp,
547     not \inenvironment\thisenv}%
548 }
549 \def\inenvironment#1{%
550   \ifx#1\empty
551     outside of any environment%
552   \else
553     in environment \expandafter\string#1%
554   \fi
555 }
556
557 % @end foo executes the definition of \Efoo.
558 % But first, it executes a specialized version of \checkenv
559 %
560 \parseargdef\end{%
561   \if 1\csname iscond.#1\endcsname
562   \else
563     % The general wording of \badenverr may not be ideal.
564     \expandafter\checkenv\csname#1\endcsname
565     \csname E#1\endcsname
566     \endgroup
567   \fi
568 }
569
570 \newhelp\EMsimple{Press RETURN to continue.}
571
572
573 % Be sure we're in horizontal mode when doing a tie, since we make space
574 % equivalent to this in @example-like environments. Otherwise, a space
575 % at the beginning of a line will start with \penalty -- and
576 % since \penalty is valid in vertical mode, we'd end up putting the
577 % penalty on the vertical list instead of in the new paragraph.
578 {\catcode`@ = 11
579  % Avoid using \@M directly, because that causes trouble
580  % if the definition is written into an index file.
581  \global\let\tiepenalty = \@M
582  \gdef\tie{\leavevmode\penalty\tiepenalty\ }
583 }
584
585 % @: forces normal size whitespace following.
586 \def\:{\spacefactor=1000 }
587
588 % @* forces a line break.
589 \def\*{\hfil\break\hbox{}\ignorespaces}
590
591 % @/ allows a line break.
592 \let\/=\allowbreak
593
594 % @. is an end-of-sentence period.
595 \def\.{.\spacefactor=\endofsentencespacefactor\space}
596
597 % @! is an end-of-sentence bang.
598 \def\!{!\spacefactor=\endofsentencespacefactor\space}
599
600 % @? is an end-of-sentence query.
601 \def\?{?\spacefactor=\endofsentencespacefactor\space}
602
603 % @frenchspacing on|off  says whether to put extra space after punctuation.
604 %
605 \def\onword{on}
606 \def\offword{off}
607 %
608 \parseargdef\frenchspacing{%
609   \def\temp{#1}%
610   \ifx\temp\onword \plainfrenchspacing
611   \else\ifx\temp\offword \plainnonfrenchspacing
612   \else
613     \errhelp = \EMsimple
614     \errmessage{Unknown @frenchspacing option `\temp', must be on|off}%
615   \fi\fi
616 }
617
618 % @w prevents a word break.  Without the \leavevmode, @w at the
619 % beginning of a paragraph, when TeX is still in vertical mode, would
620 % produce a whole line of output instead of starting the paragraph.
621 \def\w#1{\leavevmode\hbox{#1}}
622
623 % @group ... @end group forces ... to be all on one page, by enclosing
624 % it in a TeX vbox.  We use \vtop instead of \vbox to construct the box
625 % to keep its height that of a normal line.  According to the rules for
626 % \topskip (p.114 of the TeXbook), the glue inserted is
627 % max (\topskip - \ht (first item), 0).  If that height is large,
628 % therefore, no glue is inserted, and the space between the headline and
629 % the text is small, which looks bad.
630 %
631 % Another complication is that the group might be very large.  This can
632 % cause the glue on the previous page to be unduly stretched, because it
633 % does not have much material.  In this case, it's better to add an
634 % explicit \vfill so that the extra space is at the bottom.  The
635 % threshold for doing this is if the group is more than \vfilllimit
636 % percent of a page (\vfilllimit can be changed inside of @tex).
637 %
638 \newbox\groupbox
639 \def\vfilllimit{0.7}
640 %
641 \envdef\group{%
642   \ifnum\catcode`\^^M=\active \else
643     \errhelp = \groupinvalidhelp
644     \errmessage{@group invalid in context where filling is enabled}%
645   \fi
646   \startsavinginserts
647   %
648   \setbox\groupbox = \vtop\bgroup
649     % Do @comment since we are called inside an environment such as
650     % @example, where each end-of-line in the input causes an
651     % end-of-line in the output.  We don't want the end-of-line after
652     % the `@group' to put extra space in the output.  Since @group
653     % should appear on a line by itself (according to the Texinfo
654     % manual), we don't worry about eating any user text.
655     \comment
656 }
657 %
658 % The \vtop produces a box with normal height and large depth; thus, TeX puts
659 % \baselineskip glue before it, and (when the next line of text is done)
660 % \lineskip glue after it.  Thus, space below is not quite equal to space
661 % above.  But it's pretty close.
662 \def\Egroup{%
663     % To get correct interline space between the last line of the group
664     % and the first line afterwards, we have to propagate \prevdepth.
665     \endgraf % Not \par, as it may have been set to \lisppar.
666     \global\dimen1 = \prevdepth
667   \egroup           % End the \vtop.
668   % \dimen0 is the vertical size of the group's box.
669   \dimen0 = \ht\groupbox  \advance\dimen0 by \dp\groupbox
670   % \dimen2 is how much space is left on the page (more or less).
671   \dimen2 = \pageheight   \advance\dimen2 by -\pagetotal
672   % if the group doesn't fit on the current page, and it's a big big
673   % group, force a page break.
674   \ifdim \dimen0 > \dimen2
675     \ifdim \pagetotal < \vfilllimit\pageheight
676       \page
677     \fi
678   \fi
679   \box\groupbox
680   \prevdepth = \dimen1
681   \checkinserts
682 }
683 %
684 % TeX puts in an \escapechar (i.e., `@') at the beginning of the help
685 % message, so this ends up printing `@group can only ...'.
686 %
687 \newhelp\groupinvalidhelp{%
688 group can only be used in environments such as @example,^^J%
689 where each line of input produces a line of output.}
690
691 % @need space-in-mils
692 % forces a page break if there is not space-in-mils remaining.
693
694 \newdimen\mil  \mil=0.001in
695
696 \parseargdef\need{%
697   % Ensure vertical mode, so we don't make a big box in the middle of a
698   % paragraph.
699   \par
700   %
701   % If the @need value is less than one line space, it's useless.
702   \dimen0 = #1\mil
703   \dimen2 = \ht\strutbox
704   \advance\dimen2 by \dp\strutbox
705   \ifdim\dimen0 > \dimen2
706     %
707     % Do a \strut just to make the height of this box be normal, so the
708     % normal leading is inserted relative to the preceding line.
709     % And a page break here is fine.
710     \vtop to #1\mil{\strut\vfil}%
711     %
712     % TeX does not even consider page breaks if a penalty added to the
713     % main vertical list is 10000 or more.  But in order to see if the
714     % empty box we just added fits on the page, we must make it consider
715     % page breaks.  On the other hand, we don't want to actually break the
716     % page after the empty box.  So we use a penalty of 9999.
717     %
718     % There is an extremely small chance that TeX will actually break the
719     % page at this \penalty, if there are no other feasible breakpoints in
720     % sight.  (If the user is using lots of big @group commands, which
721     % almost-but-not-quite fill up a page, TeX will have a hard time doing
722     % good page breaking, for example.)  However, I could not construct an
723     % example where a page broke at this \penalty; if it happens in a real
724     % document, then we can reconsider our strategy.
725     \penalty9999
726     %
727     % Back up by the size of the box, whether we did a page break or not.
728     \kern -#1\mil
729     %
730     % Do not allow a page break right after this kern.
731     \nobreak
732   \fi
733 }
734
735 % @br   forces paragraph break (and is undocumented).
736
737 \let\br = \par
738
739 % @page forces the start of a new page.
740 %
741 \def\page{\par\vfill\supereject}
742
743 % @exdent text....
744 % outputs text on separate line in roman font, starting at standard page margin
745
746 % This records the amount of indent in the innermost environment.
747 % That's how much \exdent should take out.
748 \newskip\exdentamount
749
750 % This defn is used inside fill environments such as @defun.
751 \parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}
752
753 % This defn is used inside nofill environments such as @example.
754 \parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount
755   \leftline{\hskip\leftskip{\rm#1}}}}
756
757 % @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current
758 % paragraph.  For more general purposes, use the \margin insertion
759 % class.  WHICH is `l' or `r'.  Not documented, written for gawk manual.
760 %
761 \newskip\inmarginspacing \inmarginspacing=1cm
762 \def\strutdepth{\dp\strutbox}
763 %
764 \def\doinmargin#1#2{\strut\vadjust{%
765   \nobreak
766   \kern-\strutdepth
767   \vtop to \strutdepth{%
768     \baselineskip=\strutdepth
769     \vss
770     % if you have multiple lines of stuff to put here, you'll need to
771     % make the vbox yourself of the appropriate size.
772     \ifx#1l%
773       \llap{\ignorespaces #2\hskip\inmarginspacing}%
774     \else
775       \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}%
776     \fi
777     \null
778   }%
779 }}
780 \def\inleftmargin{\doinmargin l}
781 \def\inrightmargin{\doinmargin r}
782 %
783 % @inmargin{TEXT [, RIGHT-TEXT]}
784 % (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right;
785 % else use TEXT for both).
786 %
787 \def\inmargin#1{\parseinmargin #1,,\finish}
788 \def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing.
789   \setbox0 = \hbox{\ignorespaces #2}%
790   \ifdim\wd0 > 0pt
791     \def\lefttext{#1}%  have both texts
792     \def\righttext{#2}%
793   \else
794     \def\lefttext{#1}%  have only one text
795     \def\righttext{#1}%
796   \fi
797   %
798   \ifodd\pageno
799     \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin
800   \else
801     \def\temp{\inleftmargin\lefttext}%
802   \fi
803   \temp
804 }
805
806 % @| inserts a changebar to the left of the current line.  It should
807 % surround any changed text.  This approach does *not* work if the
808 % change spans more than two lines of output.  To handle that, we would
809 % have adopt a much more difficult approach (putting marks into the main
810 % vertical list for the beginning and end of each change).  This command
811 % is not documented, not supported, and doesn't work.
812 %
813 \def\|{%
814   % \vadjust can only be used in horizontal mode.
815   \leavevmode
816   %
817   % Append this vertical mode material after the current line in the output.
818   \vadjust{%
819     % We want to insert a rule with the height and depth of the current
820     % leading; that is exactly what \strutbox is supposed to record.
821     \vskip-\baselineskip
822     %
823     % \vadjust-items are inserted at the left edge of the type.  So
824     % the \llap here moves out into the left-hand margin.
825     \llap{%
826       %
827       % For a thicker or thinner bar, change the `1pt'.
828       \vrule height\baselineskip width1pt
829       %
830       % This is the space between the bar and the text.
831       \hskip 12pt
832     }%
833   }%
834 }
835
836 % @include FILE -- \input text of FILE.
837 %
838 \def\include{\parseargusing\filenamecatcodes\includezzz}
839 \def\includezzz#1{%
840   \pushthisfilestack
841   \def\thisfile{#1}%
842   {%
843     \makevalueexpandable  % we want to expand any @value in FILE.
844     \turnoffactive        % and allow special characters in the expansion
845     \indexnofonts         % Allow `@@' and other weird things in file names.
846     \wlog{texinfo.tex: doing @include of #1^^J}%
847     \edef\temp{\noexpand\input #1 }%
848     %
849     % This trickery is to read FILE outside of a group, in case it makes
850     % definitions, etc.
851     \expandafter
852   }\temp
853   \popthisfilestack
854 }
855 \def\filenamecatcodes{%
856   \catcode`\\=\other
857   \catcode`~=\other
858   \catcode`^=\other
859   \catcode`_=\other
860   \catcode`|=\other
861   \catcode`<=\other
862   \catcode`>=\other
863   \catcode`+=\other
864   \catcode`-=\other
865   \catcode`\`=\other
866   \catcode`\'=\other
867 }
868
869 \def\pushthisfilestack{%
870   \expandafter\pushthisfilestackX\popthisfilestack\StackTerm
871 }
872 \def\pushthisfilestackX{%
873   \expandafter\pushthisfilestackY\thisfile\StackTerm
874 }
875 \def\pushthisfilestackY #1\StackTerm #2\StackTerm {%
876   \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}%
877 }
878
879 \def\popthisfilestack{\errthisfilestackempty}
880 \def\errthisfilestackempty{\errmessage{Internal error:
881   the stack of filenames is empty.}}
882
883 \def\thisfile{}
884
885 % @center line
886 % outputs that line, centered.
887 %
888 \parseargdef\center{%
889   \ifhmode
890     \let\next\centerH
891   \else
892     \let\next\centerV
893   \fi
894   \next{\hfil \ignorespaces#1\unskip \hfil}%
895 }
896 \def\centerH#1{%
897   {%
898     \hfil\break
899     \advance\hsize by -\leftskip
900     \advance\hsize by -\rightskip
901     \line{#1}%
902     \break
903   }%
904 }
905 \def\centerV#1{\line{\kern\leftskip #1\kern\rightskip}}
906
907 % @sp n   outputs n lines of vertical space
908
909 \parseargdef\sp{\vskip #1\baselineskip}
910
911 % @comment ...line which is ignored...
912 % @c is the same as @comment
913 % @ignore ... @end ignore  is another way to write a comment
914
915 \def\comment{\begingroup \catcode`\^^M=\other%
916 \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
917 \commentxxx}
918 {\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}}
919
920 \let\c=\comment
921
922 % @paragraphindent NCHARS
923 % We'll use ems for NCHARS, close enough.
924 % NCHARS can also be the word `asis' or `none'.
925 % We cannot feasibly implement @paragraphindent asis, though.
926 %
927 \def\asisword{asis} % no translation, these are keywords
928 \def\noneword{none}
929 %
930 \parseargdef\paragraphindent{%
931   \def\temp{#1}%
932   \ifx\temp\asisword
933   \else
934     \ifx\temp\noneword
935       \defaultparindent = 0pt
936     \else
937       \defaultparindent = #1em
938     \fi
939   \fi
940   \parindent = \defaultparindent
941 }
942
943 % @exampleindent NCHARS
944 % We'll use ems for NCHARS like @paragraphindent.
945 % It seems @exampleindent asis isn't necessary, but
946 % I preserve it to make it similar to @paragraphindent.
947 \parseargdef\exampleindent{%
948   \def\temp{#1}%
949   \ifx\temp\asisword
950   \else
951     \ifx\temp\noneword
952       \lispnarrowing = 0pt
953     \else
954       \lispnarrowing = #1em
955     \fi
956   \fi
957 }
958
959 % @firstparagraphindent WORD
960 % If WORD is `none', then suppress indentation of the first paragraph
961 % after a section heading.  If WORD is `insert', then do indent at such
962 % paragraphs.
963 %
964 % The paragraph indentation is suppressed or not by calling
965 % \suppressfirstparagraphindent, which the sectioning commands do.
966 % We switch the definition of this back and forth according to WORD.
967 % By default, we suppress indentation.
968 %
969 \def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent}
970 \def\insertword{insert}
971 %
972 \parseargdef\firstparagraphindent{%
973   \def\temp{#1}%
974   \ifx\temp\noneword
975     \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent
976   \else\ifx\temp\insertword
977     \let\suppressfirstparagraphindent = \relax
978   \else
979     \errhelp = \EMsimple
980     \errmessage{Unknown @firstparagraphindent option `\temp'}%
981   \fi\fi
982 }
983
984 % Here is how we actually suppress indentation.  Redefine \everypar to
985 % \kern backwards by \parindent, and then reset itself to empty.
986 %
987 % We also make \indent itself not actually do anything until the next
988 % paragraph.
989 %
990 \gdef\dosuppressfirstparagraphindent{%
991   \gdef\indent{%
992     \restorefirstparagraphindent
993     \indent
994   }%
995   \gdef\noindent{%
996     \restorefirstparagraphindent
997     \noindent
998   }%
999   \global\everypar = {%
1000     \kern -\parindent
1001     \restorefirstparagraphindent
1002   }%
1003 }
1004
1005 \gdef\restorefirstparagraphindent{%
1006   \global \let \indent = \ptexindent
1007   \global \let \noindent = \ptexnoindent
1008   \global \everypar = {}%
1009 }
1010
1011
1012 % @refill is a no-op.
1013 \let\refill=\relax
1014
1015 % If working on a large document in chapters, it is convenient to
1016 % be able to disable indexing, cross-referencing, and contents, for test runs.
1017 % This is done with @novalidate (before @setfilename).
1018 %
1019 \newif\iflinks \linkstrue % by default we want the aux files.
1020 \let\novalidate = \linksfalse
1021
1022 % @setfilename is done at the beginning of every texinfo file.
1023 % So open here the files we need to have open while reading the input.
1024 % This makes it possible to make a .fmt file for texinfo.
1025 \def\setfilename{%
1026    \fixbackslash  % Turn off hack to swallow `\input texinfo'.
1027    \iflinks
1028      \tryauxfile
1029      % Open the new aux file.  TeX will close it automatically at exit.
1030      \immediate\openout\auxfile=\jobname.aux
1031    \fi % \openindices needs to do some work in any case.
1032    \openindices
1033    \let\setfilename=\comment % Ignore extra @setfilename cmds.
1034    %
1035    % If texinfo.cnf is present on the system, read it.
1036    % Useful for site-wide @afourpaper, etc.
1037    \openin 1 texinfo.cnf
1038    \ifeof 1 \else \input texinfo.cnf \fi
1039    \closein 1
1040    %
1041    \comment % Ignore the actual filename.
1042 }
1043
1044 % Called from \setfilename.
1045 %
1046 \def\openindices{%
1047   \newindex{cp}%
1048   \newcodeindex{fn}%
1049   \newcodeindex{vr}%
1050   \newcodeindex{tp}%
1051   \newcodeindex{ky}%
1052   \newcodeindex{pg}%
1053 }
1054
1055 % @bye.
1056 \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
1057
1058
1059 \message{pdf,}
1060 % adobe `portable' document format
1061 \newcount\tempnum
1062 \newcount\lnkcount
1063 \newtoks\filename
1064 \newcount\filenamelength
1065 \newcount\pgn
1066 \newtoks\toksA
1067 \newtoks\toksB
1068 \newtoks\toksC
1069 \newtoks\toksD
1070 \newbox\boxA
1071 \newcount\countA
1072 \newif\ifpdf
1073 \newif\ifpdfmakepagedest
1074
1075 % when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1
1076 % can be set).  So we test for \relax and 0 as well as being undefined.
1077 \ifx\pdfoutput\thisisundefined
1078 \else
1079   \ifx\pdfoutput\relax
1080   \else
1081     \ifcase\pdfoutput
1082     \else
1083       \pdftrue
1084     \fi
1085   \fi
1086 \fi
1087
1088 % PDF uses PostScript string constants for the names of xref targets,
1089 % for display in the outlines, and in other places.  Thus, we have to
1090 % double any backslashes.  Otherwise, a name like "\node" will be
1091 % interpreted as a newline (\n), followed by o, d, e.  Not good.
1092 % http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html
1093 % (and related messages, the final outcome is that it is up to the TeX
1094 % user to double the backslashes and otherwise make the string valid, so
1095 % that's what we do).
1096
1097 % double active backslashes.
1098 %
1099 {\catcode`\@=0 \catcode`\\=\active
1100  @gdef@activebackslashdouble{%
1101    @catcode`@\=@active
1102    @let\=@doublebackslash}
1103 }
1104
1105 % To handle parens, we must adopt a different approach, since parens are
1106 % not active characters.  hyperref.dtx (which has the same problem as
1107 % us) handles it with this amazing macro to replace tokens, with minor
1108 % changes for Texinfo.  It is included here under the GPL by permission
1109 % from the author, Heiko Oberdiek.
1110 %
1111 % #1 is the tokens to replace.
1112 % #2 is the replacement.
1113 % #3 is the control sequence with the string.
1114 %
1115 \def\HyPsdSubst#1#2#3{%
1116   \def\HyPsdReplace##1#1##2\END{%
1117     ##1%
1118     \ifx\\##2\\%
1119     \else
1120       #2%
1121       \HyReturnAfterFi{%
1122         \HyPsdReplace##2\END
1123       }%
1124     \fi
1125   }%
1126   \xdef#3{\expandafter\HyPsdReplace#3#1\END}%
1127 }
1128 \long\def\HyReturnAfterFi#1\fi{\fi#1}
1129
1130 % #1 is a control sequence in which to do the replacements.
1131 \def\backslashparens#1{%
1132   \xdef#1{#1}% redefine it as its expansion; the definition is simply
1133              % \lastnode when called from \setref -> \pdfmkdest.
1134   \HyPsdSubst{(}{\realbackslash(}{#1}%
1135   \HyPsdSubst{)}{\realbackslash)}{#1}%
1136 }
1137
1138 \newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images
1139 with PDF output, and none of those formats could be found.  (.eps cannot
1140 be supported due to the design of the PDF format; use regular TeX (DVI
1141 output) for that.)}
1142
1143 \ifpdf
1144   %
1145   % Color manipulation macros based on pdfcolor.tex,
1146   % except using rgb instead of cmyk; the latter is said to render as a
1147   % very dark gray on-screen and a very dark halftone in print, instead
1148   % of actual black.
1149   \def\rgbDarkRed{0.50 0.09 0.12}
1150   \def\rgbBlack{0 0 0}
1151   %
1152   % k sets the color for filling (usual text, etc.);
1153   % K sets the color for stroking (thin rules, e.g., normal _'s).
1154   \def\pdfsetcolor#1{\pdfliteral{#1 rg  #1 RG}}
1155   %
1156   % Set color, and create a mark which defines \thiscolor accordingly,
1157   % so that \makeheadline knows which color to restore.
1158   \def\setcolor#1{%
1159     \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}%
1160     \domark
1161     \pdfsetcolor{#1}%
1162   }
1163   %
1164   \def\maincolor{\rgbBlack}
1165   \pdfsetcolor{\maincolor}
1166   \edef\thiscolor{\maincolor}
1167   \def\lastcolordefs{}
1168   %
1169   \def\makefootline{%
1170     \baselineskip24pt
1171     \line{\pdfsetcolor{\maincolor}\the\footline}%
1172   }
1173   %
1174   \def\makeheadline{%
1175     \vbox to 0pt{%
1176       \vskip-22.5pt
1177       \line{%
1178         \vbox to8.5pt{}%
1179         % Extract \thiscolor definition from the marks.
1180         \getcolormarks
1181         % Typeset the headline with \maincolor, then restore the color.
1182         \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
1183       }%
1184       \vss
1185     }%
1186     \nointerlineskip
1187   }
1188   %
1189   %
1190   \pdfcatalog{/PageMode /UseOutlines}
1191   %
1192   % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
1193   \def\dopdfimage#1#2#3{%
1194     \def\imagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
1195     \def\imageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
1196     %
1197     % pdftex (and the PDF format) support .png, .jpg, .pdf (among
1198     % others).  Let's try in that order.
1199     \let\pdfimgext=\empty
1200     \begingroup
1201       \openin 1 #1.png \ifeof 1
1202         \openin 1 #1.jpg \ifeof 1
1203           \openin 1 #1.jpeg \ifeof 1
1204             \openin 1 #1.JPG \ifeof 1
1205               \openin 1 #1.pdf \ifeof 1
1206                 \openin 1 #1.PDF \ifeof 1
1207                   \errhelp = \nopdfimagehelp
1208                   \errmessage{Could not find image file #1 for pdf}%
1209                 \else \gdef\pdfimgext{PDF}%
1210                 \fi
1211               \else \gdef\pdfimgext{pdf}%
1212               \fi
1213             \else \gdef\pdfimgext{JPG}%
1214             \fi
1215           \else \gdef\pdfimgext{jpeg}%
1216           \fi
1217         \else \gdef\pdfimgext{jpg}%
1218         \fi
1219       \else \gdef\pdfimgext{png}%
1220       \fi
1221       \closein 1
1222     \endgroup
1223     %
1224     % without \immediate, ancient pdftex seg faults when the same image is
1225     % included twice.  (Version 3.14159-pre-1.0-unofficial-20010704.)
1226     \ifnum\pdftexversion < 14
1227       \immediate\pdfimage
1228     \else
1229       \immediate\pdfximage
1230     \fi
1231       \ifdim \wd0 >0pt width \imagewidth \fi
1232       \ifdim \wd2 >0pt height \imageheight \fi
1233       \ifnum\pdftexversion<13
1234          #1.\pdfimgext
1235        \else
1236          {#1.\pdfimgext}%
1237        \fi
1238     \ifnum\pdftexversion < 14 \else
1239       \pdfrefximage \pdflastximage
1240     \fi}
1241   %
1242   \def\pdfmkdest#1{{%
1243     % We have to set dummies so commands such as @code, and characters
1244     % such as \, aren't expanded when present in a section title.
1245     \indexnofonts
1246     \turnoffactive
1247     \activebackslashdouble
1248     \makevalueexpandable
1249     \def\pdfdestname{#1}%
1250     \backslashparens\pdfdestname
1251     \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
1252   }}
1253   %
1254   % used to mark target names; must be expandable.
1255   \def\pdfmkpgn#1{#1}
1256   %
1257   % by default, use a color that is dark enough to print on paper as
1258   % nearly black, but still distinguishable for online viewing.
1259   \def\urlcolor{\rgbDarkRed}
1260   \def\linkcolor{\rgbDarkRed}
1261   \def\endlink{\setcolor{\maincolor}\pdfendlink}
1262   %
1263   % Adding outlines to PDF; macros for calculating structure of outlines
1264   % come from Petr Olsak
1265   \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
1266     \else \csname#1\endcsname \fi}
1267   \def\advancenumber#1{\tempnum=\expnumber{#1}\relax
1268     \advance\tempnum by 1
1269     \expandafter\xdef\csname#1\endcsname{\the\tempnum}}
1270   %
1271   % #1 is the section text, which is what will be displayed in the
1272   % outline by the pdf viewer.  #2 is the pdf expression for the number
1273   % of subentries (or empty, for subsubsections).  #3 is the node text,
1274   % which might be empty if this toc entry had no corresponding node.
1275   % #4 is the page number
1276   %
1277   \def\dopdfoutline#1#2#3#4{%
1278     % Generate a link to the node text if that exists; else, use the
1279     % page number.  We could generate a destination for the section
1280     % text in the case where a section has no node, but it doesn't
1281     % seem worth the trouble, since most documents are normally structured.
1282     \def\pdfoutlinedest{#3}%
1283     \ifx\pdfoutlinedest\empty
1284       \def\pdfoutlinedest{#4}%
1285     \else
1286       % Doubled backslashes in the name.
1287       {\activebackslashdouble \xdef\pdfoutlinedest{#3}%
1288        \backslashparens\pdfoutlinedest}%
1289     \fi
1290     %
1291     % Also double the backslashes in the display string.
1292     {\activebackslashdouble \xdef\pdfoutlinetext{#1}%
1293      \backslashparens\pdfoutlinetext}%
1294     %
1295     \pdfoutline goto name{\pdfmkpgn{\pdfoutlinedest}}#2{\pdfoutlinetext}%
1296   }
1297   %
1298   \def\pdfmakeoutlines{%
1299     \begingroup
1300       % Thanh's hack / proper braces in bookmarks
1301       \edef\mylbrace{\iftrue \string{\else}\fi}\let\{=\mylbrace
1302       \edef\myrbrace{\iffalse{\else\string}\fi}\let\}=\myrbrace
1303       %
1304       % Read toc silently, to get counts of subentries for \pdfoutline.
1305       \def\partentry##1##2##3##4{}% ignore parts in the outlines
1306       \def\numchapentry##1##2##3##4{%
1307         \def\thischapnum{##2}%
1308         \def\thissecnum{0}%
1309         \def\thissubsecnum{0}%
1310       }%
1311       \def\numsecentry##1##2##3##4{%
1312         \advancenumber{chap\thischapnum}%
1313         \def\thissecnum{##2}%
1314         \def\thissubsecnum{0}%
1315       }%
1316       \def\numsubsecentry##1##2##3##4{%
1317         \advancenumber{sec\thissecnum}%
1318         \def\thissubsecnum{##2}%
1319       }%
1320       \def\numsubsubsecentry##1##2##3##4{%
1321         \advancenumber{subsec\thissubsecnum}%
1322       }%
1323       \def\thischapnum{0}%
1324       \def\thissecnum{0}%
1325       \def\thissubsecnum{0}%
1326       %
1327       % use \def rather than \let here because we redefine \chapentry et
1328       % al. a second time, below.
1329       \def\appentry{\numchapentry}%
1330       \def\appsecentry{\numsecentry}%
1331       \def\appsubsecentry{\numsubsecentry}%
1332       \def\appsubsubsecentry{\numsubsubsecentry}%
1333       \def\unnchapentry{\numchapentry}%
1334       \def\unnsecentry{\numsecentry}%
1335       \def\unnsubsecentry{\numsubsecentry}%
1336       \def\unnsubsubsecentry{\numsubsubsecentry}%
1337       \readdatafile{toc}%
1338       %
1339       % Read toc second time, this time actually producing the outlines.
1340       % The `-' means take the \expnumber as the absolute number of
1341       % subentries, which we calculated on our first read of the .toc above.
1342       %
1343       % We use the node names as the destinations.
1344       \def\numchapentry##1##2##3##4{%
1345         \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}%
1346       \def\numsecentry##1##2##3##4{%
1347         \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}%
1348       \def\numsubsecentry##1##2##3##4{%
1349         \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}%
1350       \def\numsubsubsecentry##1##2##3##4{% count is always zero
1351         \dopdfoutline{##1}{}{##3}{##4}}%
1352       %
1353       % PDF outlines are displayed using system fonts, instead of
1354       % document fonts.  Therefore we cannot use special characters,
1355       % since the encoding is unknown.  For example, the eogonek from
1356       % Latin 2 (0xea) gets translated to a | character.  Info from
1357       % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100.
1358       %
1359       % xx to do this right, we have to translate 8-bit characters to
1360       % their "best" equivalent, based on the @documentencoding.  Right
1361       % now, I guess we'll just let the pdf reader have its way.
1362       \indexnofonts
1363       \setupdatafile
1364       \catcode`\\=\active \otherbackslash
1365       \input \tocreadfilename
1366     \endgroup
1367   }
1368   %
1369   \def\skipspaces#1{\def\PP{#1}\def\D{|}%
1370     \ifx\PP\D\let\nextsp\relax
1371     \else\let\nextsp\skipspaces
1372       \ifx\p\space\else\addtokens{\filename}{\PP}%
1373         \advance\filenamelength by 1
1374       \fi
1375     \fi
1376     \nextsp}
1377   \def\getfilename#1{\filenamelength=0\expandafter\skipspaces#1|\relax}
1378   \ifnum\pdftexversion < 14
1379     \let \startlink \pdfannotlink
1380   \else
1381     \let \startlink \pdfstartlink
1382   \fi
1383   % make a live url in pdf output.
1384   \def\pdfurl#1{%
1385     \begingroup
1386       % it seems we really need yet another set of dummies; have not
1387       % tried to figure out what each command should do in the context
1388       % of @url.  for now, just make @/ a no-op, that's the only one
1389       % people have actually reported a problem with.
1390       %
1391       \normalturnoffactive
1392       \def\@{@}%
1393       \let\/=\empty
1394       \makevalueexpandable
1395       % do we want to go so far as to use \indexnofonts instead of just
1396       % special-casing \var here?
1397       \def\var##1{##1}%
1398       %
1399       \leavevmode\setcolor{\urlcolor}%
1400       \startlink attr{/Border [0 0 0]}%
1401         user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
1402     \endgroup}
1403   \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1404   \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1405   \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1406   \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1407   \def\maketoks{%
1408     \expandafter\poptoks\the\toksA|ENDTOKS|\relax
1409     \ifx\first0\adn0
1410     \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1411     \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
1412     \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
1413     \else
1414       \ifnum0=\countA\else\makelink\fi
1415       \ifx\first.\let\next=\done\else
1416         \let\next=\maketoks
1417         \addtokens{\toksB}{\the\toksD}
1418         \ifx\first,\addtokens{\toksB}{\space}\fi
1419       \fi
1420     \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1421     \next}
1422   \def\makelink{\addtokens{\toksB}%
1423     {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1424   \def\pdflink#1{%
1425     \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}}
1426     \setcolor{\linkcolor}#1\endlink}
1427   \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1428 \else
1429   % non-pdf mode
1430   \let\pdfmkdest = \gobble
1431   \let\pdfurl = \gobble
1432   \let\endlink = \relax
1433   \let\setcolor = \gobble
1434   \let\pdfsetcolor = \gobble
1435   \let\pdfmakeoutlines = \relax
1436 \fi  % \ifx\pdfoutput
1437
1438
1439 \message{fonts,}
1440
1441 % Change the current font style to #1, remembering it in \curfontstyle.
1442 % For now, we do not accumulate font styles: @b{@i{foo}} prints foo in
1443 % italics, not bold italics.
1444 %
1445 \def\setfontstyle#1{%
1446   \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd.
1447   \csname ten#1\endcsname  % change the current font
1448 }
1449
1450 % Select #1 fonts with the current style.
1451 %
1452 \def\selectfonts#1{\csname #1fonts\endcsname \csname\curfontstyle\endcsname}
1453
1454 \def\rm{\fam=0 \setfontstyle{rm}}
1455 \def\it{\fam=\itfam \setfontstyle{it}}
1456 \def\sl{\fam=\slfam \setfontstyle{sl}}
1457 \def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf}
1458 \def\tt{\fam=\ttfam \setfontstyle{tt}}
1459
1460 % Unfortunately, we have to override this for titles and the like, since
1461 % in those cases "rm" is bold.  Sigh.
1462 \def\rmisbold{\rm\def\curfontstyle{bf}}
1463
1464 % Texinfo sort of supports the sans serif font style, which plain TeX does not.
1465 % So we set up a \sf.
1466 \newfam\sffam
1467 \def\sf{\fam=\sffam \setfontstyle{sf}}
1468 \let\li = \sf % Sometimes we call it \li, not \sf.
1469
1470 % We don't need math for this font style.
1471 \def\ttsl{\setfontstyle{ttsl}}
1472
1473
1474 % Default leading.
1475 \newdimen\textleading  \textleading = 13.2pt
1476
1477 % Set the baselineskip to #1, and the lineskip and strut size
1478 % correspondingly.  There is no deep meaning behind these magic numbers
1479 % used as factors; they just match (closely enough) what Knuth defined.
1480 %
1481 \def\lineskipfactor{.08333}
1482 \def\strutheightpercent{.70833}
1483 \def\strutdepthpercent {.29167}
1484 %
1485 % can get a sort of poor man's double spacing by redefining this.
1486 \def\baselinefactor{1}
1487 %
1488 \def\setleading#1{%
1489   \dimen0 = #1\relax
1490   \normalbaselineskip = \baselinefactor\dimen0
1491   \normallineskip = \lineskipfactor\normalbaselineskip
1492   \normalbaselines
1493   \setbox\strutbox =\hbox{%
1494     \vrule width0pt height\strutheightpercent\baselineskip
1495                     depth \strutdepthpercent \baselineskip
1496   }%
1497 }
1498
1499 % PDF CMaps.  See also LaTeX's t1.cmap.
1500 %
1501 % do nothing with this by default.
1502 \expandafter\let\csname cmapOT1\endcsname\gobble
1503 \expandafter\let\csname cmapOT1IT\endcsname\gobble
1504 \expandafter\let\csname cmapOT1TT\endcsname\gobble
1505
1506 % if we are producing pdf, and we have \pdffontattr, then define cmaps.
1507 % (\pdffontattr was introduced many years ago, but people still run
1508 % older pdftex's; it's easy to conditionalize, so we do.)
1509 \ifpdf \ifx\pdffontattr\thisisundefined \else
1510   \begingroup
1511     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
1512     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
1513 %%DocumentNeededResources: ProcSet (CIDInit)
1514 %%IncludeResource: ProcSet (CIDInit)
1515 %%BeginResource: CMap (TeX-OT1-0)
1516 %%Title: (TeX-OT1-0 TeX OT1 0)
1517 %%Version: 1.000
1518 %%EndComments
1519 /CIDInit /ProcSet findresource begin
1520 12 dict begin
1521 begincmap
1522 /CIDSystemInfo
1523 << /Registry (TeX)
1524 /Ordering (OT1)
1525 /Supplement 0
1526 >> def
1527 /CMapName /TeX-OT1-0 def
1528 /CMapType 2 def
1529 1 begincodespacerange
1530 <00> <7F>
1531 endcodespacerange
1532 8 beginbfrange
1533 <00> <01> <0393>
1534 <09> <0A> <03A8>
1535 <23> <26> <0023>
1536 <28> <3B> <0028>
1537 <3F> <5B> <003F>
1538 <5D> <5E> <005D>
1539 <61> <7A> <0061>
1540 <7B> <7C> <2013>
1541 endbfrange
1542 40 beginbfchar
1543 <02> <0398>
1544 <03> <039B>
1545 <04> <039E>
1546 <05> <03A0>
1547 <06> <03A3>
1548 <07> <03D2>
1549 <08> <03A6>
1550 <0B> <00660066>
1551 <0C> <00660069>
1552 <0D> <0066006C>
1553 <0E> <006600660069>
1554 <0F> <00660066006C>
1555 <10> <0131>
1556 <11> <0237>
1557 <12> <0060>
1558 <13> <00B4>
1559 <14> <02C7>
1560 <15> <02D8>
1561 <16> <00AF>
1562 <17> <02DA>
1563 <18> <00B8>
1564 <19> <00DF>
1565 <1A> <00E6>
1566 <1B> <0153>
1567 <1C> <00F8>
1568 <1D> <00C6>
1569 <1E> <0152>
1570 <1F> <00D8>
1571 <21> <0021>
1572 <22> <201D>
1573 <27> <2019>
1574 <3C> <00A1>
1575 <3D> <003D>
1576 <3E> <00BF>
1577 <5C> <201C>
1578 <5F> <02D9>
1579 <60> <2018>
1580 <7D> <02DD>
1581 <7E> <007E>
1582 <7F> <00A8>
1583 endbfchar
1584 endcmap
1585 CMapName currentdict /CMap defineresource pop
1586 end
1587 end
1588 %%EndResource
1589 %%EOF
1590     }\endgroup
1591   \expandafter\edef\csname cmapOT1\endcsname#1{%
1592     \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
1593   }%
1594 %
1595 % \cmapOT1IT
1596   \begingroup
1597     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
1598     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
1599 %%DocumentNeededResources: ProcSet (CIDInit)
1600 %%IncludeResource: ProcSet (CIDInit)
1601 %%BeginResource: CMap (TeX-OT1IT-0)
1602 %%Title: (TeX-OT1IT-0 TeX OT1IT 0)
1603 %%Version: 1.000
1604 %%EndComments
1605 /CIDInit /ProcSet findresource begin
1606 12 dict begin
1607 begincmap
1608 /CIDSystemInfo
1609 << /Registry (TeX)
1610 /Ordering (OT1IT)
1611 /Supplement 0
1612 >> def
1613 /CMapName /TeX-OT1IT-0 def
1614 /CMapType 2 def
1615 1 begincodespacerange
1616 <00> <7F>
1617 endcodespacerange
1618 8 beginbfrange
1619 <00> <01> <0393>
1620 <09> <0A> <03A8>
1621 <25> <26> <0025>
1622 <28> <3B> <0028>
1623 <3F> <5B> <003F>
1624 <5D> <5E> <005D>
1625 <61> <7A> <0061>
1626 <7B> <7C> <2013>
1627 endbfrange
1628 42 beginbfchar
1629 <02> <0398>
1630 <03> <039B>
1631 <04> <039E>
1632 <05> <03A0>
1633 <06> <03A3>
1634 <07> <03D2>
1635 <08> <03A6>
1636 <0B> <00660066>
1637 <0C> <00660069>
1638 <0D> <0066006C>
1639 <0E> <006600660069>
1640 <0F> <00660066006C>
1641 <10> <0131>
1642 <11> <0237>
1643 <12> <0060>
1644 <13> <00B4>
1645 <14> <02C7>
1646 <15> <02D8>
1647 <16> <00AF>
1648 <17> <02DA>
1649 <18> <00B8>
1650 <19> <00DF>
1651 <1A> <00E6>
1652 <1B> <0153>
1653 <1C> <00F8>
1654 <1D> <00C6>
1655 <1E> <0152>
1656 <1F> <00D8>
1657 <21> <0021>
1658 <22> <201D>
1659 <23> <0023>
1660 <24> <00A3>
1661 <27> <2019>
1662 <3C> <00A1>
1663 <3D> <003D>
1664 <3E> <00BF>
1665 <5C> <201C>
1666 <5F> <02D9>
1667 <60> <2018>
1668 <7D> <02DD>
1669 <7E> <007E>
1670 <7F> <00A8>
1671 endbfchar
1672 endcmap
1673 CMapName currentdict /CMap defineresource pop
1674 end
1675 end
1676 %%EndResource
1677 %%EOF
1678     }\endgroup
1679   \expandafter\edef\csname cmapOT1IT\endcsname#1{%
1680     \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
1681   }%
1682 %
1683 % \cmapOT1TT
1684   \begingroup
1685     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
1686     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
1687 %%DocumentNeededResources: ProcSet (CIDInit)
1688 %%IncludeResource: ProcSet (CIDInit)
1689 %%BeginResource: CMap (TeX-OT1TT-0)
1690 %%Title: (TeX-OT1TT-0 TeX OT1TT 0)
1691 %%Version: 1.000
1692 %%EndComments
1693 /CIDInit /ProcSet findresource begin
1694 12 dict begin
1695 begincmap
1696 /CIDSystemInfo
1697 << /Registry (TeX)
1698 /Ordering (OT1TT)
1699 /Supplement 0
1700 >> def
1701 /CMapName /TeX-OT1TT-0 def
1702 /CMapType 2 def
1703 1 begincodespacerange
1704 <00> <7F>
1705 endcodespacerange
1706 5 beginbfrange
1707 <00> <01> <0393>
1708 <09> <0A> <03A8>
1709 <21> <26> <0021>
1710 <28> <5F> <0028>
1711 <61> <7E> <0061>
1712 endbfrange
1713 32 beginbfchar
1714 <02> <0398>
1715 <03> <039B>
1716 <04> <039E>
1717 <05> <03A0>
1718 <06> <03A3>
1719 <07> <03D2>
1720 <08> <03A6>
1721 <0B> <2191>
1722 <0C> <2193>
1723 <0D> <0027>
1724 <0E> <00A1>
1725 <0F> <00BF>
1726 <10> <0131>
1727 <11> <0237>
1728 <12> <0060>
1729 <13> <00B4>
1730 <14> <02C7>
1731 <15> <02D8>
1732 <16> <00AF>
1733 <17> <02DA>
1734 <18> <00B8>
1735 <19> <00DF>
1736 <1A> <00E6>
1737 <1B> <0153>
1738 <1C> <00F8>
1739 <1D> <00C6>
1740 <1E> <0152>
1741 <1F> <00D8>
1742 <20> <2423>
1743 <27> <2019>
1744 <60> <2018>
1745 <7F> <00A8>
1746 endbfchar
1747 endcmap
1748 CMapName currentdict /CMap defineresource pop
1749 end
1750 end
1751 %%EndResource
1752 %%EOF
1753     }\endgroup
1754   \expandafter\edef\csname cmapOT1TT\endcsname#1{%
1755     \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
1756   }%
1757 \fi\fi
1758
1759
1760 % Set the font macro #1 to the font named #2, adding on the
1761 % specified font prefix (normally `cm').
1762 % #3 is the font's design size, #4 is a scale factor, #5 is the CMap
1763 % encoding (currently only OT1, OT1IT and OT1TT are allowed, pass
1764 % empty to omit).
1765 \def\setfont#1#2#3#4#5{%
1766   \font#1=\fontprefix#2#3 scaled #4
1767   \csname cmap#5\endcsname#1%
1768 }
1769 % This is what gets called when #5 of \setfont is empty.
1770 \let\cmap\gobble
1771 % emacs-page end of cmaps
1772
1773 % Use cm as the default font prefix.
1774 % To specify the font prefix, you must define \fontprefix
1775 % before you read in texinfo.tex.
1776 \ifx\fontprefix\thisisundefined
1777 \def\fontprefix{cm}
1778 \fi
1779 % Support font families that don't use the same naming scheme as CM.
1780 \def\rmshape{r}
1781 \def\rmbshape{bx}               %where the normal face is bold
1782 \def\bfshape{b}
1783 \def\bxshape{bx}
1784 \def\ttshape{tt}
1785 \def\ttbshape{tt}
1786 \def\ttslshape{sltt}
1787 \def\itshape{ti}
1788 \def\itbshape{bxti}
1789 \def\slshape{sl}
1790 \def\slbshape{bxsl}
1791 \def\sfshape{ss}
1792 \def\sfbshape{ss}
1793 \def\scshape{csc}
1794 \def\scbshape{csc}
1795
1796 % Definitions for a main text size of 11pt.  This is the default in
1797 % Texinfo.
1798 %
1799 \def\definetextfontsizexi{%
1800 % Text fonts (11.2pt, magstep1).
1801 \def\textnominalsize{11pt}
1802 \edef\mainmagstep{\magstephalf}
1803 \setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
1804 \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
1805 \setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
1806 \setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
1807 \setfont\textsl\slshape{10}{\mainmagstep}{OT1}
1808 \setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
1809 \setfont\textsc\scshape{10}{\mainmagstep}{OT1}
1810 \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
1811 \font\texti=cmmi10 scaled \mainmagstep
1812 \font\textsy=cmsy10 scaled \mainmagstep
1813 \def\textecsize{1095}
1814
1815 % A few fonts for @defun names and args.
1816 \setfont\defbf\bfshape{10}{\magstep1}{OT1}
1817 \setfont\deftt\ttshape{10}{\magstep1}{OT1TT}
1818 \setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT}
1819 \def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf}
1820
1821 % Fonts for indices, footnotes, small examples (9pt).
1822 \def\smallnominalsize{9pt}
1823 \setfont\smallrm\rmshape{9}{1000}{OT1}
1824 \setfont\smalltt\ttshape{9}{1000}{OT1TT}
1825 \setfont\smallbf\bfshape{10}{900}{OT1}
1826 \setfont\smallit\itshape{9}{1000}{OT1IT}
1827 \setfont\smallsl\slshape{9}{1000}{OT1}
1828 \setfont\smallsf\sfshape{9}{1000}{OT1}
1829 \setfont\smallsc\scshape{10}{900}{OT1}
1830 \setfont\smallttsl\ttslshape{10}{900}{OT1TT}
1831 \font\smalli=cmmi9
1832 \font\smallsy=cmsy9
1833 \def\smallecsize{0900}
1834
1835 % Fonts for small examples (8pt).
1836 \def\smallernominalsize{8pt}
1837 \setfont\smallerrm\rmshape{8}{1000}{OT1}
1838 \setfont\smallertt\ttshape{8}{1000}{OT1TT}
1839 \setfont\smallerbf\bfshape{10}{800}{OT1}
1840 \setfont\smallerit\itshape{8}{1000}{OT1IT}
1841 \setfont\smallersl\slshape{8}{1000}{OT1}
1842 \setfont\smallersf\sfshape{8}{1000}{OT1}
1843 \setfont\smallersc\scshape{10}{800}{OT1}
1844 \setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
1845 \font\smalleri=cmmi8
1846 \font\smallersy=cmsy8
1847 \def\smallerecsize{0800}
1848
1849 % Fonts for title page (20.4pt):
1850 \def\titlenominalsize{20pt}
1851 \setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
1852 \setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
1853 \setfont\titlesl\slbshape{10}{\magstep4}{OT1}
1854 \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
1855 \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
1856 \setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
1857 \let\titlebf=\titlerm
1858 \setfont\titlesc\scbshape{10}{\magstep4}{OT1}
1859 \font\titlei=cmmi12 scaled \magstep3
1860 \font\titlesy=cmsy10 scaled \magstep4
1861 \def\titleecsize{2074}
1862
1863 % Chapter (and unnumbered) fonts (17.28pt).
1864 \def\chapnominalsize{17pt}
1865 \setfont\chaprm\rmbshape{12}{\magstep2}{OT1}
1866 \setfont\chapit\itbshape{10}{\magstep3}{OT1IT}
1867 \setfont\chapsl\slbshape{10}{\magstep3}{OT1}
1868 \setfont\chaptt\ttbshape{12}{\magstep2}{OT1TT}
1869 \setfont\chapttsl\ttslshape{10}{\magstep3}{OT1TT}
1870 \setfont\chapsf\sfbshape{17}{1000}{OT1}
1871 \let\chapbf=\chaprm
1872 \setfont\chapsc\scbshape{10}{\magstep3}{OT1}
1873 \font\chapi=cmmi12 scaled \magstep2
1874 \font\chapsy=cmsy10 scaled \magstep3
1875 \def\chapecsize{1728}
1876
1877 % Section fonts (14.4pt).
1878 \def\secnominalsize{14pt}
1879 \setfont\secrm\rmbshape{12}{\magstep1}{OT1}
1880 \setfont\secit\itbshape{10}{\magstep2}{OT1IT}
1881 \setfont\secsl\slbshape{10}{\magstep2}{OT1}
1882 \setfont\sectt\ttbshape{12}{\magstep1}{OT1TT}
1883 \setfont\secttsl\ttslshape{10}{\magstep2}{OT1TT}
1884 \setfont\secsf\sfbshape{12}{\magstep1}{OT1}
1885 \let\secbf\secrm
1886 \setfont\secsc\scbshape{10}{\magstep2}{OT1}
1887 \font\seci=cmmi12 scaled \magstep1
1888 \font\secsy=cmsy10 scaled \magstep2
1889 \def\sececsize{1440}
1890
1891 % Subsection fonts (13.15pt).
1892 \def\ssecnominalsize{13pt}
1893 \setfont\ssecrm\rmbshape{12}{\magstephalf}{OT1}
1894 \setfont\ssecit\itbshape{10}{1315}{OT1IT}
1895 \setfont\ssecsl\slbshape{10}{1315}{OT1}
1896 \setfont\ssectt\ttbshape{12}{\magstephalf}{OT1TT}
1897 \setfont\ssecttsl\ttslshape{10}{1315}{OT1TT}
1898 \setfont\ssecsf\sfbshape{12}{\magstephalf}{OT1}
1899 \let\ssecbf\ssecrm
1900 \setfont\ssecsc\scbshape{10}{1315}{OT1}
1901 \font\sseci=cmmi12 scaled \magstephalf
1902 \font\ssecsy=cmsy10 scaled 1315
1903 \def\ssececsize{1200}
1904
1905 % Reduced fonts for @acro in text (10pt).
1906 \def\reducednominalsize{10pt}
1907 \setfont\reducedrm\rmshape{10}{1000}{OT1}
1908 \setfont\reducedtt\ttshape{10}{1000}{OT1TT}
1909 \setfont\reducedbf\bfshape{10}{1000}{OT1}
1910 \setfont\reducedit\itshape{10}{1000}{OT1IT}
1911 \setfont\reducedsl\slshape{10}{1000}{OT1}
1912 \setfont\reducedsf\sfshape{10}{1000}{OT1}
1913 \setfont\reducedsc\scshape{10}{1000}{OT1}
1914 \setfont\reducedttsl\ttslshape{10}{1000}{OT1TT}
1915 \font\reducedi=cmmi10
1916 \font\reducedsy=cmsy10
1917 \def\reducedecsize{1000}
1918
1919 \textleading = 13.2pt % line spacing for 11pt CM
1920 \textfonts            % reset the current fonts
1921 \rm
1922 } % end of 11pt text font size definitions
1923
1924
1925 % Definitions to make the main text be 10pt Computer Modern, with
1926 % section, chapter, etc., sizes following suit.  This is for the GNU
1927 % Press printing of the Emacs 22 manual.  Maybe other manuals in the
1928 % future.  Used with @smallbook, which sets the leading to 12pt.
1929 %
1930 \def\definetextfontsizex{%
1931 % Text fonts (10pt).
1932 \def\textnominalsize{10pt}
1933 \edef\mainmagstep{1000}
1934 \setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
1935 \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
1936 \setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
1937 \setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
1938 \setfont\textsl\slshape{10}{\mainmagstep}{OT1}
1939 \setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
1940 \setfont\textsc\scshape{10}{\mainmagstep}{OT1}
1941 \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
1942 \font\texti=cmmi10 scaled \mainmagstep
1943 \font\textsy=cmsy10 scaled \mainmagstep
1944 \def\textecsize{1000}
1945
1946 % A few fonts for @defun names and args.
1947 \setfont\defbf\bfshape{10}{\magstephalf}{OT1}
1948 \setfont\deftt\ttshape{10}{\magstephalf}{OT1TT}
1949 \setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT}
1950 \def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf}
1951
1952 % Fonts for indices, footnotes, small examples (9pt).
1953 \def\smallnominalsize{9pt}
1954 \setfont\smallrm\rmshape{9}{1000}{OT1}
1955 \setfont\smalltt\ttshape{9}{1000}{OT1TT}
1956 \setfont\smallbf\bfshape{10}{900}{OT1}
1957 \setfont\smallit\itshape{9}{1000}{OT1IT}
1958 \setfont\smallsl\slshape{9}{1000}{OT1}
1959 \setfont\smallsf\sfshape{9}{1000}{OT1}
1960 \setfont\smallsc\scshape{10}{900}{OT1}
1961 \setfont\smallttsl\ttslshape{10}{900}{OT1TT}
1962 \font\smalli=cmmi9
1963 \font\smallsy=cmsy9
1964 \def\smallecsize{0900}
1965
1966 % Fonts for small examples (8pt).
1967 \def\smallernominalsize{8pt}
1968 \setfont\smallerrm\rmshape{8}{1000}{OT1}
1969 \setfont\smallertt\ttshape{8}{1000}{OT1TT}
1970 \setfont\smallerbf\bfshape{10}{800}{OT1}
1971 \setfont\smallerit\itshape{8}{1000}{OT1IT}
1972 \setfont\smallersl\slshape{8}{1000}{OT1}
1973 \setfont\smallersf\sfshape{8}{1000}{OT1}
1974 \setfont\smallersc\scshape{10}{800}{OT1}
1975 \setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
1976 \font\smalleri=cmmi8
1977 \font\smallersy=cmsy8
1978 \def\smallerecsize{0800}
1979
1980 % Fonts for title page (20.4pt):
1981 \def\titlenominalsize{20pt}
1982 \setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
1983 \setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
1984 \setfont\titlesl\slbshape{10}{\magstep4}{OT1}
1985 \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
1986 \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
1987 \setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
1988 \let\titlebf=\titlerm
1989 \setfont\titlesc\scbshape{10}{\magstep4}{OT1}
1990 \font\titlei=cmmi12 scaled \magstep3
1991 \font\titlesy=cmsy10 scaled \magstep4
1992 \def\titleecsize{2074}
1993
1994 % Chapter fonts (14.4pt).
1995 \def\chapnominalsize{14pt}
1996 \setfont\chaprm\rmbshape{12}{\magstep1}{OT1}
1997 \setfont\chapit\itbshape{10}{\magstep2}{OT1IT}
1998 \setfont\chapsl\slbshape{10}{\magstep2}{OT1}
1999 \setfont\chaptt\ttbshape{12}{\magstep1}{OT1TT}
2000 \setfont\chapttsl\ttslshape{10}{\magstep2}{OT1TT}
2001 \setfont\chapsf\sfbshape{12}{\magstep1}{OT1}
2002 \let\chapbf\chaprm
2003 \setfont\chapsc\scbshape{10}{\magstep2}{OT1}
2004 \font\chapi=cmmi12 scaled \magstep1
2005 \font\chapsy=cmsy10 scaled \magstep2
2006 \def\chapecsize{1440}
2007
2008 % Section fonts (12pt).
2009 \def\secnominalsize{12pt}
2010 \setfont\secrm\rmbshape{12}{1000}{OT1}
2011 \setfont\secit\itbshape{10}{\magstep1}{OT1IT}
2012 \setfont\secsl\slbshape{10}{\magstep1}{OT1}
2013 \setfont\sectt\ttbshape{12}{1000}{OT1TT}
2014 \setfont\secttsl\ttslshape{10}{\magstep1}{OT1TT}
2015 \setfont\secsf\sfbshape{12}{1000}{OT1}
2016 \let\secbf\secrm
2017 \setfont\secsc\scbshape{10}{\magstep1}{OT1}
2018 \font\seci=cmmi12
2019 \font\secsy=cmsy10 scaled \magstep1
2020 \def\sececsize{1200}
2021
2022 % Subsection fonts (10pt).
2023 \def\ssecnominalsize{10pt}
2024 \setfont\ssecrm\rmbshape{10}{1000}{OT1}
2025 \setfont\ssecit\itbshape{10}{1000}{OT1IT}
2026 \setfont\ssecsl\slbshape{10}{1000}{OT1}
2027 \setfont\ssectt\ttbshape{10}{1000}{OT1TT}
2028 \setfont\ssecttsl\ttslshape{10}{1000}{OT1TT}
2029 \setfont\ssecsf\sfbshape{10}{1000}{OT1}
2030 \let\ssecbf\ssecrm
2031 \setfont\ssecsc\scbshape{10}{1000}{OT1}
2032 \font\sseci=cmmi10
2033 \font\ssecsy=cmsy10
2034 \def\ssececsize{1000}
2035
2036 % Reduced fonts for @acro in text (9pt).
2037 \def\reducednominalsize{9pt}
2038 \setfont\reducedrm\rmshape{9}{1000}{OT1}
2039 \setfont\reducedtt\ttshape{9}{1000}{OT1TT}
2040 \setfont\reducedbf\bfshape{10}{900}{OT1}
2041 \setfont\reducedit\itshape{9}{1000}{OT1IT}
2042 \setfont\reducedsl\slshape{9}{1000}{OT1}
2043 \setfont\reducedsf\sfshape{9}{1000}{OT1}
2044 \setfont\reducedsc\scshape{10}{900}{OT1}
2045 \setfont\reducedttsl\ttslshape{10}{900}{OT1TT}
2046 \font\reducedi=cmmi9
2047 \font\reducedsy=cmsy9
2048 \def\reducedecsize{0900}
2049
2050 \divide\parskip by 2  % reduce space between paragraphs
2051 \textleading = 12pt   % line spacing for 10pt CM
2052 \textfonts            % reset the current fonts
2053 \rm
2054 } % end of 10pt text font size definitions
2055
2056
2057 % We provide the user-level command
2058 %   @fonttextsize 10
2059 % (or 11) to redefine the text font size.  pt is assumed.
2060 %
2061 \def\xiword{11}
2062 \def\xword{10}
2063 \def\xwordpt{10pt}
2064 %
2065 \parseargdef\fonttextsize{%
2066   \def\textsizearg{#1}%
2067   %\wlog{doing @fonttextsize \textsizearg}%
2068   %
2069   % Set \globaldefs so that documents can use this inside @tex, since
2070   % makeinfo 4.8 does not support it, but we need it nonetheless.
2071   %
2072  \begingroup \globaldefs=1
2073   \ifx\textsizearg\xword \definetextfontsizex
2074   \else \ifx\textsizearg\xiword \definetextfontsizexi
2075   \else
2076     \errhelp=\EMsimple
2077     \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'}
2078   \fi\fi
2079  \endgroup
2080 }
2081
2082
2083 % In order for the font changes to affect most math symbols and letters,
2084 % we have to define the \textfont of the standard families.  Since
2085 % texinfo doesn't allow for producing subscripts and superscripts except
2086 % in the main text, we don't bother to reset \scriptfont and
2087 % \scriptscriptfont (which would also require loading a lot more fonts).
2088 %
2089 \def\resetmathfonts{%
2090   \textfont0=\tenrm \textfont1=\teni \textfont2=\tensy
2091   \textfont\itfam=\tenit \textfont\slfam=\tensl \textfont\bffam=\tenbf
2092   \textfont\ttfam=\tentt \textfont\sffam=\tensf
2093 }
2094
2095 % The font-changing commands redefine the meanings of \tenSTYLE, instead
2096 % of just \STYLE.  We do this because \STYLE needs to also set the
2097 % current \fam for math mode.  Our \STYLE (e.g., \rm) commands hardwire
2098 % \tenSTYLE to set the current font.
2099 %
2100 % Each font-changing command also sets the names \lsize (one size lower)
2101 % and \lllsize (three sizes lower).  These relative commands are used in
2102 % the LaTeX logo and acronyms.
2103 %
2104 % This all needs generalizing, badly.
2105 %
2106 \def\textfonts{%
2107   \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
2108   \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
2109   \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy
2110   \let\tenttsl=\textttsl
2111   \def\curfontsize{text}%
2112   \def\lsize{reduced}\def\lllsize{smaller}%
2113   \resetmathfonts \setleading{\textleading}}
2114 \def\titlefonts{%
2115   \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl
2116   \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc
2117   \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy
2118   \let\tenttsl=\titlettsl
2119   \def\curfontsize{title}%
2120   \def\lsize{chap}\def\lllsize{subsec}%
2121   \resetmathfonts \setleading{27pt}}
2122 \def\titlefont#1{{\titlefonts\rmisbold #1}}
2123 \def\chapfonts{%
2124   \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl
2125   \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
2126   \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy
2127   \let\tenttsl=\chapttsl
2128   \def\curfontsize{chap}%
2129   \def\lsize{sec}\def\lllsize{text}%
2130   \resetmathfonts \setleading{19pt}}
2131 \def\secfonts{%
2132   \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl
2133   \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc
2134   \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy
2135   \let\tenttsl=\secttsl
2136   \def\curfontsize{sec}%
2137   \def\lsize{subsec}\def\lllsize{reduced}%
2138   \resetmathfonts \setleading{16pt}}
2139 \def\subsecfonts{%
2140   \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl
2141   \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc
2142   \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy
2143   \let\tenttsl=\ssecttsl
2144   \def\curfontsize{ssec}%
2145   \def\lsize{text}\def\lllsize{small}%
2146   \resetmathfonts \setleading{15pt}}
2147 \let\subsubsecfonts = \subsecfonts
2148 \def\reducedfonts{%
2149   \let\tenrm=\reducedrm \let\tenit=\reducedit \let\tensl=\reducedsl
2150   \let\tenbf=\reducedbf \let\tentt=\reducedtt \let\reducedcaps=\reducedsc
2151   \let\tensf=\reducedsf \let\teni=\reducedi \let\tensy=\reducedsy
2152   \let\tenttsl=\reducedttsl
2153   \def\curfontsize{reduced}%
2154   \def\lsize{small}\def\lllsize{smaller}%
2155   \resetmathfonts \setleading{10.5pt}}
2156 \def\smallfonts{%
2157   \let\tenrm=\smallrm \let\tenit=\smallit \let\tensl=\smallsl
2158   \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc
2159   \let\tensf=\smallsf \let\teni=\smalli \let\tensy=\smallsy
2160   \let\tenttsl=\smallttsl
2161   \def\curfontsize{small}%
2162   \def\lsize{smaller}\def\lllsize{smaller}%
2163   \resetmathfonts \setleading{10.5pt}}
2164 \def\smallerfonts{%
2165   \let\tenrm=\smallerrm \let\tenit=\smallerit \let\tensl=\smallersl
2166   \let\tenbf=\smallerbf \let\tentt=\smallertt \let\smallcaps=\smallersc
2167   \let\tensf=\smallersf \let\teni=\smalleri \let\tensy=\smallersy
2168   \let\tenttsl=\smallerttsl
2169   \def\curfontsize{smaller}%
2170   \def\lsize{smaller}\def\lllsize{smaller}%
2171   \resetmathfonts \setleading{9.5pt}}
2172
2173 % Fonts for short table of contents.
2174 \setfont\shortcontrm\rmshape{12}{1000}{OT1}
2175 \setfont\shortcontbf\bfshape{10}{\magstep1}{OT1}  % no cmb12
2176 \setfont\shortcontsl\slshape{12}{1000}{OT1}
2177 \setfont\shortconttt\ttshape{12}{1000}{OT1TT}
2178
2179 % Define these just so they can be easily changed for other fonts.
2180 \def\angleleft{$\langle$}
2181 \def\angleright{$\rangle$}
2182
2183 % Set the fonts to use with the @small... environments.
2184 \let\smallexamplefonts = \smallfonts
2185
2186 % About \smallexamplefonts.  If we use \smallfonts (9pt), @smallexample
2187 % can fit this many characters:
2188 %   8.5x11=86   smallbook=72  a4=90  a5=69
2189 % If we use \scriptfonts (8pt), then we can fit this many characters:
2190 %   8.5x11=90+  smallbook=80  a4=90+  a5=77
2191 % For me, subjectively, the few extra characters that fit aren't worth
2192 % the additional smallness of 8pt.  So I'm making the default 9pt.
2193 %
2194 % By the way, for comparison, here's what fits with @example (10pt):
2195 %   8.5x11=71  smallbook=60  a4=75  a5=58
2196 % --karl, 24jan03.
2197
2198 % Set up the default fonts, so we can use them for creating boxes.
2199 %
2200 \definetextfontsizexi
2201
2202
2203 \message{markup,}
2204
2205 % Check if we are currently using a typewriter font.  Since all the
2206 % Computer Modern typewriter fonts have zero interword stretch (and
2207 % shrink), and it is reasonable to expect all typewriter fonts to have
2208 % this property, we can check that font parameter.
2209 %
2210 \def\ifmonospace{\ifdim\fontdimen3\font=0pt }
2211
2212 % Markup style infrastructure.  \defmarkupstylesetup\INITMACRO will
2213 % define and register \INITMACRO to be called on markup style changes.
2214 % \INITMACRO can check \currentmarkupstyle for the innermost
2215 % style and the set of \ifmarkupSTYLE switches for all styles
2216 % currently in effect.
2217 \newif\ifmarkupvar
2218 \newif\ifmarkupsamp
2219 \newif\ifmarkupkey
2220 %\newif\ifmarkupfile % @file == @samp.
2221 %\newif\ifmarkupoption % @option == @samp.
2222 \newif\ifmarkupcode
2223 \newif\ifmarkupkbd
2224 %\newif\ifmarkupenv % @env == @code.
2225 %\newif\ifmarkupcommand % @command == @code.
2226 \newif\ifmarkuptex % @tex (and part of @math, for now).
2227 \newif\ifmarkupexample
2228 \newif\ifmarkupverb
2229 \newif\ifmarkupverbatim
2230
2231 \let\currentmarkupstyle\empty
2232
2233 \def\setupmarkupstyle#1{%
2234   \csname markup#1true\endcsname
2235   \def\currentmarkupstyle{#1}%
2236   \markupstylesetup
2237 }
2238
2239 \let\markupstylesetup\empty
2240
2241 \def\defmarkupstylesetup#1{%
2242   \expandafter\def\expandafter\markupstylesetup
2243     \expandafter{\markupstylesetup #1}%
2244   \def#1%
2245 }
2246
2247 % Markup style setup for left and right quotes.
2248 \defmarkupstylesetup\markupsetuplq{%
2249   \expandafter\let\expandafter \temp
2250     \csname markupsetuplq\currentmarkupstyle\endcsname
2251   \ifx\temp\relax \markupsetuplqdefault \else \temp \fi
2252 }
2253
2254 \defmarkupstylesetup\markupsetuprq{%
2255   \expandafter\let\expandafter \temp
2256     \csname markupsetuprq\currentmarkupstyle\endcsname
2257   \ifx\temp\relax \markupsetuprqdefault \else \temp \fi
2258 }
2259
2260 {
2261 \catcode`\'=\active
2262 \catcode`\`=\active
2263
2264 \gdef\markupsetuplqdefault{\let`\lq}
2265 \gdef\markupsetuprqdefault{\let'\rq}
2266
2267 \gdef\markupsetcodequoteleft{\let`\codequoteleft}
2268 \gdef\markupsetcodequoteright{\let'\codequoteright}
2269
2270 \gdef\markupsetnoligaturesquoteleft{\let`\noligaturesquoteleft}
2271 }
2272
2273 \let\markupsetuplqcode \markupsetcodequoteleft
2274 \let\markupsetuprqcode \markupsetcodequoteright
2275 %
2276 \let\markupsetuplqexample \markupsetcodequoteleft
2277 \let\markupsetuprqexample \markupsetcodequoteright
2278 %
2279 \let\markupsetuplqsamp \markupsetcodequoteleft
2280 \let\markupsetuprqsamp \markupsetcodequoteright
2281 %
2282 \let\markupsetuplqverb \markupsetcodequoteleft
2283 \let\markupsetuprqverb \markupsetcodequoteright
2284 %
2285 \let\markupsetuplqverbatim \markupsetcodequoteleft
2286 \let\markupsetuprqverbatim \markupsetcodequoteright
2287
2288 \let\markupsetuplqkbd \markupsetnoligaturesquoteleft
2289
2290 % Allow an option to not use regular directed right quote/apostrophe
2291 % (char 0x27), but instead the undirected quote from cmtt (char 0x0d).
2292 % The undirected quote is ugly, so don't make it the default, but it
2293 % works for pasting with more pdf viewers (at least evince), the
2294 % lilypond developers report.  xpdf does work with the regular 0x27.
2295 %
2296 \def\codequoteright{%
2297   \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax
2298     \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax
2299       '%
2300     \else \char'15 \fi
2301   \else \char'15 \fi
2302 }
2303 %
2304 % and a similar option for the left quote char vs. a grave accent.
2305 % Modern fonts display ASCII 0x60 as a grave accent, so some people like
2306 % the code environments to do likewise.
2307 %
2308 \def\codequoteleft{%
2309   \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax
2310     \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax
2311       % [Knuth] pp. 380,381,391
2312       % \relax disables Spanish ligatures ?` and !` of \tt font.
2313       \relax`%
2314     \else \char'22 \fi
2315   \else \char'22 \fi
2316 }
2317
2318 % Commands to set the quote options.
2319
2320 \parseargdef\codequoteundirected{%
2321   \def\temp{#1}%
2322   \ifx\temp\onword
2323     \expandafter\let\csname SETtxicodequoteundirected\endcsname
2324       = t%
2325   \else\ifx\temp\offword
2326     \expandafter\let\csname SETtxicodequoteundirected\endcsname
2327       = \relax
2328   \else
2329     \errhelp = \EMsimple
2330     \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}%
2331   \fi\fi
2332 }
2333 %
2334 \parseargdef\codequotebacktick{%
2335   \def\temp{#1}%
2336   \ifx\temp\onword
2337     \expandafter\let\csname SETtxicodequotebacktick\endcsname
2338       = t%
2339   \else\ifx\temp\offword
2340     \expandafter\let\csname SETtxicodequotebacktick\endcsname
2341       = \relax
2342   \else
2343     \errhelp = \EMsimple
2344     \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}%
2345   \fi\fi
2346 }
2347
2348 % [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font.
2349 \def\noligaturesquoteleft{\relax\lq}
2350
2351 % Count depth in font-changes, for error checks
2352 \newcount\fontdepth \fontdepth=0
2353
2354 % Font commands.
2355
2356 % #1 is the font command (\sl or \it), #2 is the text to slant.
2357 % If we are in a monospaced environment, however, 1) always use \ttsl,
2358 % and 2) do not add an italic correction.
2359 \def\dosmartslant#1#2{%
2360   \ifusingtt 
2361     {{\ttsl #2}\let\next=\relax}%
2362     {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}%
2363   \next
2364 }
2365 \def\smartslanted{\dosmartslant\sl}
2366 \def\smartitalic{\dosmartslant\it}
2367
2368 % Output an italic correction unless \next (presumed to be the following
2369 % character) is such as not to need one.
2370 \def\smartitaliccorrection{%
2371   \ifx\next,%
2372   \else\ifx\next-%
2373   \else\ifx\next.%
2374   \else\ptexslash
2375   \fi\fi\fi}
2376
2377 % like \smartslanted except unconditionally uses \ttsl, and no ic.
2378 % @var is set to this for defun arguments.
2379 \def\ttslanted#1{{\ttsl #1}}
2380
2381 % @cite is like \smartslanted except unconditionally use \sl.  We never want
2382 % ttsl for book titles, do we?
2383 \def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection}
2384
2385 \let\i=\smartitalic
2386 \let\slanted=\smartslanted
2387 \def\var#1{\smartslanted{#1}}
2388 \let\dfn=\smartslanted
2389 \let\emph=\smartitalic
2390
2391 % Explicit font changes: @r, @sc, undocumented @ii.
2392 \def\r#1{{\rm #1}}              % roman font
2393 \def\sc#1{{\smallcaps#1}}       % smallcaps font
2394 \def\ii#1{{\it #1}}             % italic font
2395
2396 % @b, explicit bold.  Also @strong.
2397 \def\b#1{{\bf #1}}
2398 \let\strong=\b
2399
2400 % @sansserif, explicit sans.
2401 \def\sansserif#1{{\sf #1}}
2402
2403 % We can't just use \exhyphenpenalty, because that only has effect at
2404 % the end of a paragraph.  Restore normal hyphenation at the end of the
2405 % group within which \nohyphenation is presumably called.
2406 %
2407 \def\nohyphenation{\hyphenchar\font = -1  \aftergroup\restorehyphenation}
2408 \def\restorehyphenation{\hyphenchar\font = `- }
2409
2410 % Set sfcode to normal for the chars that usually have another value.
2411 % Can't use plain's \frenchspacing because it uses the `\x notation, and
2412 % sometimes \x has an active definition that messes things up.
2413 %
2414 \catcode`@=11
2415   \def\plainfrenchspacing{%
2416     \sfcode\dotChar  =\@m \sfcode\questChar=\@m \sfcode\exclamChar=\@m
2417     \sfcode\colonChar=\@m \sfcode\semiChar =\@m \sfcode\commaChar =\@m
2418     \def\endofsentencespacefactor{1000}% for @. and friends
2419   }
2420   \def\plainnonfrenchspacing{%
2421     \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000
2422     \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250
2423     \def\endofsentencespacefactor{3000}% for @. and friends
2424   }
2425 \catcode`@=\other
2426 \def\endofsentencespacefactor{3000}% default
2427
2428 % @t, explicit typewriter.
2429 \def\t#1{%
2430   {\tt \rawbackslash \plainfrenchspacing #1}%
2431   \null
2432 }
2433
2434 % @samp.
2435 \def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}}
2436
2437 % definition of @key that produces a lozenge.  Doesn't adjust to text size.
2438 %\setfont\keyrm\rmshape{8}{1000}{OT1}
2439 %\font\keysy=cmsy9
2440 %\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
2441 %  \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
2442 %    \vbox{\hrule\kern-0.4pt
2443 %     \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
2444 %    \kern-0.4pt\hrule}%
2445 %  \kern-.06em\raise0.4pt\hbox{\angleright}}}}
2446
2447 % definition of @key with no lozenge.  If the current font is already
2448 % monospace, don't change it; that way, we respect @kbdinputstyle.  But
2449 % if it isn't monospace, then use \tt.
2450 %
2451 \def\key#1{{\setupmarkupstyle{key}%
2452   \nohyphenation
2453   \ifmonospace\else\tt\fi
2454   #1}\null}
2455
2456 % ctrl is no longer a Texinfo command.
2457 \def\ctrl #1{{\tt \rawbackslash \hat}#1}
2458
2459 % @file, @option are the same as @samp.
2460 \let\file=\samp
2461 \let\option=\samp
2462
2463 % @code is a modification of @t,
2464 % which makes spaces the same size as normal in the surrounding text.
2465 \def\tclose#1{%
2466   {%
2467     % Change normal interword space to be same as for the current font.
2468     \spaceskip = \fontdimen2\font
2469     %
2470     % Switch to typewriter.
2471     \tt
2472     %
2473     % But `\ ' produces the large typewriter interword space.
2474     \def\ {{\spaceskip = 0pt{} }}%
2475     %
2476     % Turn off hyphenation.
2477     \nohyphenation
2478     %
2479     \rawbackslash
2480     \plainfrenchspacing
2481     #1%
2482   }%
2483   \null
2484 }
2485
2486 % We *must* turn on hyphenation at `-' and `_' in @code.
2487 % Otherwise, it is too hard to avoid overfull hboxes
2488 % in the Emacs manual, the Library manual, etc.
2489
2490 % Unfortunately, TeX uses one parameter (\hyphenchar) to control
2491 % both hyphenation at - and hyphenation within words.
2492 % We must therefore turn them both off (\tclose does that)
2493 % and arrange explicitly to hyphenate at a dash.
2494 %  -- rms.
2495 {
2496   \catcode`\-=\active \catcode`\_=\active
2497   \catcode`\'=\active \catcode`\`=\active
2498   \global\let'=\rq \global\let`=\lq  % default definitions
2499   %
2500   \global\def\code{\begingroup
2501     \setupmarkupstyle{code}%
2502     % The following should really be moved into \setupmarkupstyle handlers.
2503     \catcode\dashChar=\active  \catcode\underChar=\active
2504     \ifallowcodebreaks
2505      \let-\codedash
2506      \let_\codeunder
2507     \else
2508      \let-\realdash
2509      \let_\realunder
2510     \fi
2511     \codex
2512   }
2513 }
2514
2515 \def\codex #1{\tclose{#1}\endgroup}
2516
2517 \def\realdash{-}
2518 \def\codedash{-\discretionary{}{}{}}
2519 \def\codeunder{%
2520   % this is all so @math{@code{var_name}+1} can work.  In math mode, _
2521   % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.)
2522   % will therefore expand the active definition of _, which is us
2523   % (inside @code that is), therefore an endless loop.
2524   \ifusingtt{\ifmmode
2525                \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_.
2526              \else\normalunderscore \fi
2527              \discretionary{}{}{}}%
2528             {\_}%
2529 }
2530
2531 % An additional complication: the above will allow breaks after, e.g.,
2532 % each of the four underscores in __typeof__.  This is undesirable in
2533 % some manuals, especially if they don't have long identifiers in
2534 % general.  @allowcodebreaks provides a way to control this.
2535 %
2536 \newif\ifallowcodebreaks  \allowcodebreakstrue
2537
2538 \def\keywordtrue{true}
2539 \def\keywordfalse{false}
2540
2541 \parseargdef\allowcodebreaks{%
2542   \def\txiarg{#1}%
2543   \ifx\txiarg\keywordtrue
2544     \allowcodebreakstrue
2545   \else\ifx\txiarg\keywordfalse
2546     \allowcodebreaksfalse
2547   \else
2548     \errhelp = \EMsimple
2549     \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}%
2550   \fi\fi
2551 }
2552
2553 % @uref (abbreviation for `urlref') takes an optional (comma-separated)
2554 % second argument specifying the text to display and an optional third
2555 % arg as text to display instead of (rather than in addition to) the url
2556 % itself.  First (mandatory) arg is the url.
2557 % (This \urefnobreak definition isn't used now, leaving it for a while
2558 % for comparison.)
2559 \def\urefnobreak#1{\dourefnobreak #1,,,\finish}
2560 \def\dourefnobreak#1,#2,#3,#4\finish{\begingroup
2561   \unsepspaces
2562   \pdfurl{#1}%
2563   \setbox0 = \hbox{\ignorespaces #3}%
2564   \ifdim\wd0 > 0pt
2565     \unhbox0 % third arg given, show only that
2566   \else
2567     \setbox0 = \hbox{\ignorespaces #2}%
2568     \ifdim\wd0 > 0pt
2569       \ifpdf
2570         \unhbox0             % PDF: 2nd arg given, show only it
2571       \else
2572         \unhbox0\ (\code{#1})% DVI: 2nd arg given, show both it and url
2573       \fi
2574     \else
2575       \code{#1}% only url given, so show it
2576     \fi
2577   \fi
2578   \endlink
2579 \endgroup}
2580
2581 % This \urefbreak definition is the active one.
2582 \def\urefbreak{\begingroup \urefcatcodes \dourefbreak}
2583 \let\uref=\urefbreak
2584 \def\dourefbreak#1{\urefbreakfinish #1,,,\finish}
2585 \def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example
2586   \unsepspaces
2587   \pdfurl{#1}%
2588   \setbox0 = \hbox{\ignorespaces #3}%
2589   \ifdim\wd0 > 0pt
2590     \unhbox0 % third arg given, show only that
2591   \else
2592     \setbox0 = \hbox{\ignorespaces #2}%
2593     \ifdim\wd0 > 0pt
2594       \ifpdf
2595         \unhbox0             % PDF: 2nd arg given, show only it
2596       \else
2597         \unhbox0\ (\urefcode{#1})% DVI: 2nd arg given, show both it and url
2598       \fi
2599     \else
2600       \urefcode{#1}% only url given, so show it
2601     \fi
2602   \fi
2603   \endlink
2604 \endgroup}
2605
2606 % Allow line breaks around only a few characters (only).
2607 \def\urefcatcodes{%
2608   \catcode\ampChar=\active   \catcode\dotChar=\active
2609   \catcode\hashChar=\active  \catcode\questChar=\active
2610   \catcode\slashChar=\active
2611 }
2612 {
2613   \urefcatcodes
2614   %
2615   \global\def\urefcode{\begingroup
2616     \setupmarkupstyle{code}%
2617     \urefcatcodes
2618     \let&\urefcodeamp
2619     \let.\urefcodedot
2620     \let#\urefcodehash
2621     \let?\urefcodequest
2622     \let/\urefcodeslash
2623     \codex
2624   }
2625   %
2626   % By default, they are just regular characters.
2627   \global\def&{\normalamp}
2628   \global\def.{\normaldot}
2629   \global\def#{\normalhash}
2630   \global\def?{\normalquest}
2631   \global\def/{\normalslash}
2632 }
2633
2634 % we put a little stretch before and after the breakable chars, to help
2635 % line breaking of long url's.  The unequal skips make look better in
2636 % cmtt at least, especially for dots.
2637 \def\urefprestretch{\urefprebreak \hskip0pt plus.13em }
2638 \def\urefpoststretch{\urefpostbreak \hskip0pt plus.1em }
2639 %
2640 \def\urefcodeamp{\urefprestretch \&\urefpoststretch}
2641 \def\urefcodedot{\urefprestretch .\urefpoststretch}
2642 \def\urefcodehash{\urefprestretch \#\urefpoststretch}
2643 \def\urefcodequest{\urefprestretch ?\urefpoststretch}
2644 \def\urefcodeslash{\futurelet\next\urefcodeslashfinish}
2645 {
2646   \catcode`\/=\active
2647   \global\def\urefcodeslashfinish{%
2648     \urefprestretch \slashChar
2649     % Allow line break only after the final / in a sequence of
2650     % slashes, to avoid line break between the slashes in http://.
2651     \ifx\next/\else \urefpoststretch \fi
2652   }
2653 }
2654
2655 % One more complication: by default we'll break after the special
2656 % characters, but some people like to break before the special chars, so
2657 % allow that.  Also allow no breaking at all, for manual control.
2658
2659 \parseargdef\urefbreakstyle{%
2660   \def\txiarg{#1}%
2661   \ifx\txiarg\wordnone
2662     \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak}
2663   \else\ifx\txiarg\wordbefore
2664     \def\urefprebreak{\allowbreak}\def\urefpostbreak{\nobreak}
2665   \else\ifx\txiarg\wordafter
2666     \def\urefprebreak{\nobreak}\def\urefpostbreak{\allowbreak}
2667   \else
2668     \errhelp = \EMsimple
2669     \errmessage{Unknown @urefbreakstyle setting `\txiarg'}%
2670   \fi\fi\fi
2671 }
2672 \def\wordafter{after}
2673 \def\wordbefore{before}
2674 \def\wordnone{none}
2675
2676 \urefbreakstyle after
2677
2678 % @url synonym for @uref, since that's how everyone uses it.
2679 %
2680 \let\url=\uref
2681
2682 % rms does not like angle brackets --karl, 17may97.
2683 % So now @email is just like @uref, unless we are pdf.
2684 %
2685 %\def\email#1{\angleleft{\tt #1}\angleright}
2686 \ifpdf
2687   \def\email#1{\doemail#1,,\finish}
2688   \def\doemail#1,#2,#3\finish{\begingroup
2689     \unsepspaces
2690     \pdfurl{mailto:#1}%
2691     \setbox0 = \hbox{\ignorespaces #2}%
2692     \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
2693     \endlink
2694   \endgroup}
2695 \else
2696   \let\email=\uref
2697 \fi
2698
2699 % @kbd is like @code, except that if the argument is just one @key command,
2700 % then @kbd has no effect.
2701 \def\kbd#1{{\setupmarkupstyle{kbd}\def\look{#1}\expandafter\kbdfoo\look??\par}}
2702
2703 % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
2704 %   `example' (@kbd uses ttsl only inside of @example and friends),
2705 %   or `code' (@kbd uses normal tty font always).
2706 \parseargdef\kbdinputstyle{%
2707   \def\txiarg{#1}%
2708   \ifx\txiarg\worddistinct
2709     \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
2710   \else\ifx\txiarg\wordexample
2711     \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
2712   \else\ifx\txiarg\wordcode
2713     \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
2714   \else
2715     \errhelp = \EMsimple
2716     \errmessage{Unknown @kbdinputstyle setting `\txiarg'}%
2717   \fi\fi\fi
2718 }
2719 \def\worddistinct{distinct}
2720 \def\wordexample{example}
2721 \def\wordcode{code}
2722
2723 % Default is `distinct'.
2724 \kbdinputstyle distinct
2725
2726 \def\xkey{\key}
2727 \def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}%
2728 \ifx\one\xkey\ifx\threex\three \key{#2}%
2729 \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
2730 \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi}
2731
2732 % For @indicateurl, @env, @command quotes seem unnecessary, so use \code.
2733 \let\indicateurl=\code
2734 \let\env=\code
2735 \let\command=\code
2736
2737 % @clicksequence{File @click{} Open ...}
2738 \def\clicksequence#1{\begingroup #1\endgroup}
2739
2740 % @clickstyle @arrow   (by default)
2741 \parseargdef\clickstyle{\def\click{#1}}
2742 \def\click{\arrow}
2743
2744 % Typeset a dimension, e.g., `in' or `pt'.  The only reason for the
2745 % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
2746 %
2747 \def\dmn#1{\thinspace #1}
2748
2749 % @l was never documented to mean ``switch to the Lisp font'',
2750 % and it is not used as such in any manual I can find.  We need it for
2751 % Polish suppressed-l.  --karl, 22sep96.
2752 %\def\l#1{{\li #1}\null}
2753
2754 % @acronym for "FBI", "NATO", and the like.
2755 % We print this one point size smaller, since it's intended for
2756 % all-uppercase.
2757 %
2758 \def\acronym#1{\doacronym #1,,\finish}
2759 \def\doacronym#1,#2,#3\finish{%
2760   {\selectfonts\lsize #1}%
2761   \def\temp{#2}%
2762   \ifx\temp\empty \else
2763     \space ({\unsepspaces \ignorespaces \temp \unskip})%
2764   \fi
2765 }
2766
2767 % @abbr for "Comput. J." and the like.
2768 % No font change, but don't do end-of-sentence spacing.
2769 %
2770 \def\abbr#1{\doabbr #1,,\finish}
2771 \def\doabbr#1,#2,#3\finish{%
2772   {\plainfrenchspacing #1}%
2773   \def\temp{#2}%
2774   \ifx\temp\empty \else
2775     \space ({\unsepspaces \ignorespaces \temp \unskip})%
2776   \fi
2777 }
2778
2779 % @asis just yields its argument.  Used with @table, for example.
2780 %
2781 \def\asis#1{#1}
2782
2783 % @math outputs its argument in math mode.
2784 %
2785 % One complication: _ usually means subscripts, but it could also mean
2786 % an actual _ character, as in @math{@var{some_variable} + 1}.  So make
2787 % _ active, and distinguish by seeing if the current family is \slfam,
2788 % which is what @var uses.
2789 {
2790   \catcode`\_ = \active
2791   \gdef\mathunderscore{%
2792     \catcode`\_=\active
2793     \def_{\ifnum\fam=\slfam \_\else\sb\fi}%
2794   }
2795 }
2796 % Another complication: we want \\ (and @\) to output a math (or tt) \.
2797 % FYI, plain.tex uses \\ as a temporary control sequence (for no
2798 % particular reason), but this is not advertised and we don't care.
2799 %
2800 % The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\.
2801 \def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi}
2802 %
2803 \def\math{%
2804   \tex
2805   \mathunderscore
2806   \let\\ = \mathbackslash
2807   \mathactive
2808   % make the texinfo accent commands work in math mode
2809   \let\"=\ddot
2810   \let\'=\acute
2811   \let\==\bar
2812   \let\^=\hat
2813   \let\`=\grave
2814   \let\u=\breve
2815   \let\v=\check
2816   \let\~=\tilde
2817   \let\dotaccent=\dot
2818   $\finishmath
2819 }
2820 \def\finishmath#1{#1$\endgroup}  % Close the group opened by \tex.
2821
2822 % Some active characters (such as <) are spaced differently in math.
2823 % We have to reset their definitions in case the @math was an argument
2824 % to a command which sets the catcodes (such as @item or @section).
2825 %
2826 {
2827   \catcode`^ = \active
2828   \catcode`< = \active
2829   \catcode`> = \active
2830   \catcode`+ = \active
2831   \catcode`' = \active
2832   \gdef\mathactive{%
2833     \let^ = \ptexhat
2834     \let< = \ptexless
2835     \let> = \ptexgtr
2836     \let+ = \ptexplus
2837     \let' = \ptexquoteright
2838   }
2839 }
2840
2841
2842 \message{glyphs,}
2843 % and logos.
2844
2845 % @@ prints an @.
2846 \def\@{\char64 }
2847
2848 % Used to generate quoted braces.  Unless we're in typewriter, use
2849 % \ecfont because the CM text fonts do not have braces, and we don't
2850 % want to switch into math.
2851 \def\mylbrace{{\ifmonospace\else\ecfont\fi \char123}}
2852 \def\myrbrace{{\ifmonospace\else\ecfont\fi \char125}}
2853 \let\{=\mylbrace
2854 \let\}=\myrbrace
2855 \begingroup
2856   % Definitions to produce \{ and \} commands for indices,
2857   % and @{ and @} for the aux/toc files.
2858   \catcode`\{ = \other \catcode`\} = \other
2859   \catcode`\[ = 1 \catcode`\] = 2
2860   \catcode`\! = 0 \catcode`\\ = \other
2861   !gdef!lbracecmd[\{]%
2862   !gdef!rbracecmd[\}]%
2863   !gdef!lbraceatcmd[@{]%
2864   !gdef!rbraceatcmd[@}]%
2865 !endgroup
2866
2867 % @comma{} to avoid , parsing problems.
2868 \let\comma = ,
2869
2870 % Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
2871 % Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H.
2872 \let\, = \ptexc
2873 \let\dotaccent = \ptexdot
2874 \def\ringaccent#1{{\accent23 #1}}
2875 \let\tieaccent = \ptext
2876 \let\ubaraccent = \ptexb
2877 \let\udotaccent = \d
2878
2879 % Other special characters: @questiondown @exclamdown @ordf @ordm
2880 % Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss.
2881 \def\questiondown{?`}
2882 \def\exclamdown{!`}
2883 \def\ordf{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{a}}}
2884 \def\ordm{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{o}}}
2885
2886 % Dotless i and dotless j, used for accents.
2887 \def\imacro{i}
2888 \def\jmacro{j}
2889 \def\dotless#1{%
2890   \def\temp{#1}%
2891   \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi
2892   \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi
2893   \else \errmessage{@dotless can be used only with i or j}%
2894   \fi\fi
2895 }
2896
2897 % The \TeX{} logo, as in plain, but resetting the spacing so that a
2898 % period following counts as ending a sentence.  (Idea found in latex.)
2899 %
2900 \edef\TeX{\TeX \spacefactor=1000 }
2901
2902 % @LaTeX{} logo.  Not quite the same results as the definition in
2903 % latex.ltx, since we use a different font for the raised A; it's most
2904 % convenient for us to use an explicitly smaller font, rather than using
2905 % the \scriptstyle font (since we don't reset \scriptstyle and
2906 % \scriptscriptstyle).
2907 %
2908 \def\LaTeX{%
2909   L\kern-.36em
2910   {\setbox0=\hbox{T}%
2911    \vbox to \ht0{\hbox{%
2912      \ifx\textnominalsize\xwordpt
2913        % for 10pt running text, \lllsize (8pt) is too small for the A in LaTeX.
2914        % Revert to plain's \scriptsize, which is 7pt.
2915        \count255=\the\fam $\fam\count255 \scriptstyle A$%
2916      \else
2917        % For 11pt, we can use our lllsize.
2918        \selectfonts\lllsize A%
2919      \fi
2920      }%
2921      \vss
2922   }}%
2923   \kern-.15em
2924   \TeX
2925 }
2926
2927 % Some math mode symbols.
2928 \def\bullet{$\ptexbullet$}
2929 \def\geq{\ifmmode \ge\else $\ge$\fi}
2930 \def\leq{\ifmmode \le\else $\le$\fi}
2931 \def\minus{\ifmmode -\else $-$\fi}
2932
2933 % @dots{} outputs an ellipsis using the current font.
2934 % We do .5em per period so that it has the same spacing in the cm
2935 % typewriter fonts as three actual period characters; on the other hand,
2936 % in other typewriter fonts three periods are wider than 1.5em.  So do
2937 % whichever is larger.
2938 %
2939 \def\dots{%
2940   \leavevmode
2941   \setbox0=\hbox{...}% get width of three periods
2942   \ifdim\wd0 > 1.5em
2943     \dimen0 = \wd0
2944   \else
2945     \dimen0 = 1.5em
2946   \fi
2947   \hbox to \dimen0{%
2948     \hskip 0pt plus.25fil
2949     .\hskip 0pt plus1fil
2950     .\hskip 0pt plus1fil
2951     .\hskip 0pt plus.5fil
2952   }%
2953 }
2954
2955 % @enddots{} is an end-of-sentence ellipsis.
2956 %
2957 \def\enddots{%
2958   \dots
2959   \spacefactor=\endofsentencespacefactor
2960 }
2961
2962 % @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
2963 %
2964 % Since these characters are used in examples, they should be an even number of
2965 % \tt widths. Each \tt character is 1en, so two makes it 1em.
2966 %
2967 \def\point{$\star$}
2968 \def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}}
2969 \def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
2970 \def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}}
2971 \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
2972 \def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}}
2973
2974 % The @error{} command.
2975 % Adapted from the TeXbook's \boxit.
2976 %
2977 \newbox\errorbox
2978 %
2979 {\tentt \global\dimen0 = 3em}% Width of the box.
2980 \dimen2 = .55pt % Thickness of rules
2981 % The text. (`r' is open on the right, `e' somewhat less so on the left.)
2982 \setbox0 = \hbox{\kern-.75pt \reducedsf error\kern-1.5pt}
2983 %
2984 \setbox\errorbox=\hbox to \dimen0{\hfil
2985    \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
2986    \advance\hsize by -2\dimen2 % Rules.
2987    \vbox{%
2988       \hrule height\dimen2
2989       \hbox{\vrule width\dimen2 \kern3pt          % Space to left of text.
2990          \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
2991          \kern3pt\vrule width\dimen2}% Space to right.
2992       \hrule height\dimen2}
2993     \hfil}
2994 %
2995 \def\error{\leavevmode\lower.7ex\copy\errorbox}
2996
2997 % @pounds{} is a sterling sign, which Knuth put in the CM italic font.
2998 %
2999 \def\pounds{{\it\$}}
3000
3001 % @euro{} comes from a separate font, depending on the current style.
3002 % We use the free feym* fonts from the eurosym package by Henrik
3003 % Theiling, which support regular, slanted, bold and bold slanted (and
3004 % "outlined" (blackboard board, sort of) versions, which we don't need).
3005 % It is available from http://www.ctan.org/tex-archive/fonts/eurosym.
3006 %
3007 % Although only regular is the truly official Euro symbol, we ignore
3008 % that.  The Euro is designed to be slightly taller than the regular
3009 % font height.
3010 %
3011 % feymr - regular
3012 % feymo - slanted
3013 % feybr - bold
3014 % feybo - bold slanted
3015 %
3016 % There is no good (free) typewriter version, to my knowledge.
3017 % A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide.
3018 % Hmm.
3019 %
3020 % Also doesn't work in math.  Do we need to do math with euro symbols?
3021 % Hope not.
3022 %
3023 %
3024 \def\euro{{\eurofont e}}
3025 \def\eurofont{%
3026   % We set the font at each command, rather than predefining it in
3027   % \textfonts and the other font-switching commands, so that
3028   % installations which never need the symbol don't have to have the
3029   % font installed.
3030   %
3031   % There is only one designed size (nominal 10pt), so we always scale
3032   % that to the current nominal size.
3033   %
3034   % By the way, simply using "at 1em" works for cmr10 and the like, but
3035   % does not work for cmbx10 and other extended/shrunken fonts.
3036   %
3037   \def\eurosize{\csname\curfontsize nominalsize\endcsname}%
3038   %
3039   \ifx\curfontstyle\bfstylename
3040     % bold:
3041     \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize
3042   \else
3043     % regular:
3044     \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize
3045   \fi
3046   \thiseurofont
3047 }
3048
3049 % Glyphs from the EC fonts.  We don't use \let for the aliases, because
3050 % sometimes we redefine the original macro, and the alias should reflect
3051 % the redefinition.
3052 %
3053 % Use LaTeX names for the Icelandic letters.
3054 \def\DH{{\ecfont \char"D0}} % Eth
3055 \def\dh{{\ecfont \char"F0}} % eth
3056 \def\TH{{\ecfont \char"DE}} % Thorn
3057 \def\th{{\ecfont \char"FE}} % thorn
3058 %
3059 \def\guillemetleft{{\ecfont \char"13}}
3060 \def\guillemotleft{\guillemetleft}
3061 \def\guillemetright{{\ecfont \char"14}}
3062 \def\guillemotright{\guillemetright}
3063 \def\guilsinglleft{{\ecfont \char"0E}}
3064 \def\guilsinglright{{\ecfont \char"0F}}
3065 \def\quotedblbase{{\ecfont \char"12}}
3066 \def\quotesinglbase{{\ecfont \char"0D}}
3067 %
3068 % This positioning is not perfect (see the ogonek LaTeX package), but
3069 % we have the precomposed glyphs for the most common cases.  We put the
3070 % tests to use those glyphs in the single \ogonek macro so we have fewer
3071 % dummy definitions to worry about for index entries, etc.
3072 %
3073 % ogonek is also used with other letters in Lithuanian (IOU), but using
3074 % the precomposed glyphs for those is not so easy since they aren't in
3075 % the same EC font.
3076 \def\ogonek#1{{%
3077   \def\temp{#1}%
3078   \ifx\temp\macrocharA\Aogonek
3079   \else\ifx\temp\macrochara\aogonek
3080   \else\ifx\temp\macrocharE\Eogonek
3081   \else\ifx\temp\macrochare\eogonek
3082   \else
3083     \ecfont \setbox0=\hbox{#1}%
3084     \ifdim\ht0=1ex\accent"0C #1%
3085     \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}%
3086     \fi
3087   \fi\fi\fi\fi
3088   }%
3089 }
3090 \def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A}
3091 \def\aogonek{{\ecfont \char"A1}}\def\macrochara{a}
3092 \def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E}
3093 \def\eogonek{{\ecfont \char"A6}}\def\macrochare{e}
3094 %
3095 % Use the ec* fonts (cm-super in outline format) for non-CM glyphs.
3096 \def\ecfont{%
3097   % We can't distinguish serif/sans and italic/slanted, but this
3098   % is used for crude hacks anyway (like adding French and German
3099   % quotes to documents typeset with CM, where we lose kerning), so
3100   % hopefully nobody will notice/care.
3101   \edef\ecsize{\csname\curfontsize ecsize\endcsname}%
3102   \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}%
3103   \ifx\curfontstyle\bfstylename
3104     % bold:
3105     \font\thisecfont = ecb\ifusingit{i}{x}\ecsize \space at \nominalsize
3106   \else
3107     % regular:
3108     \font\thisecfont = ec\ifusingit{ti}{rm}\ecsize \space at \nominalsize
3109   \fi
3110   \thisecfont
3111 }
3112
3113 % @registeredsymbol - R in a circle.  The font for the R should really
3114 % be smaller yet, but lllsize is the best we can do for now.
3115 % Adapted from the plain.tex definition of \copyright.
3116 %
3117 \def\registeredsymbol{%
3118   $^{{\ooalign{\hfil\raise.07ex\hbox{\selectfonts\lllsize R}%
3119                \hfil\crcr\Orb}}%
3120     }$%
3121 }
3122
3123 % @textdegree - the normal degrees sign.
3124 %
3125 \def\textdegree{$^\circ$}
3126
3127 % Laurent Siebenmann reports \Orb undefined with:
3128 %  Textures 1.7.7 (preloaded format=plain 93.10.14)  (68K)  16 APR 2004 02:38
3129 % so we'll define it if necessary.
3130 %
3131 \ifx\Orb\thisisundefined
3132 \def\Orb{\mathhexbox20D}
3133 \fi
3134
3135 % Quotes.
3136 \chardef\quotedblleft="5C
3137 \chardef\quotedblright=`\"
3138 \chardef\quoteleft=`\`
3139 \chardef\quoteright=`\'
3140
3141
3142 \message{page headings,}
3143
3144 \newskip\titlepagetopglue \titlepagetopglue = 1.5in
3145 \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
3146
3147 % First the title page.  Must do @settitle before @titlepage.
3148 \newif\ifseenauthor
3149 \newif\iffinishedtitlepage
3150
3151 % Do an implicit @contents or @shortcontents after @end titlepage if the
3152 % user says @setcontentsaftertitlepage or @setshortcontentsaftertitlepage.
3153 %
3154 \newif\ifsetcontentsaftertitlepage
3155  \let\setcontentsaftertitlepage = \setcontentsaftertitlepagetrue
3156 \newif\ifsetshortcontentsaftertitlepage
3157  \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue
3158
3159 \parseargdef\shorttitlepage{%
3160   \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}%
3161   \endgroup\page\hbox{}\page}
3162
3163 \envdef\titlepage{%
3164   % Open one extra group, as we want to close it in the middle of \Etitlepage.
3165   \begingroup
3166     \parindent=0pt \textfonts
3167     % Leave some space at the very top of the page.
3168     \vglue\titlepagetopglue
3169     % No rule at page bottom unless we print one at the top with @title.
3170     \finishedtitlepagetrue
3171     %
3172     % Most title ``pages'' are actually two pages long, with space
3173     % at the top of the second.  We don't want the ragged left on the second.
3174     \let\oldpage = \page
3175     \def\page{%
3176       \iffinishedtitlepage\else
3177          \finishtitlepage
3178       \fi
3179       \let\page = \oldpage
3180       \page
3181       \null
3182     }%
3183 }
3184
3185 \def\Etitlepage{%
3186     \iffinishedtitlepage\else
3187         \finishtitlepage
3188     \fi
3189     % It is important to do the page break before ending the group,
3190     % because the headline and footline are only empty inside the group.
3191     % If we use the new definition of \page, we always get a blank page
3192     % after the title page, which we certainly don't want.
3193     \oldpage
3194   \endgroup
3195   %
3196   % Need this before the \...aftertitlepage checks so that if they are
3197   % in effect the toc pages will come out with page numbers.
3198   \HEADINGSon
3199   %
3200   % If they want short, they certainly want long too.
3201   \ifsetshortcontentsaftertitlepage
3202     \shortcontents
3203     \contents
3204     \global\let\shortcontents = \relax
3205     \global\let\contents = \relax
3206   \fi
3207   %
3208   \ifsetcontentsaftertitlepage
3209     \contents
3210     \global\let\contents = \relax
3211     \global\let\shortcontents = \relax
3212   \fi
3213 }
3214
3215 \def\finishtitlepage{%
3216   \vskip4pt \hrule height 2pt width \hsize
3217   \vskip\titlepagebottomglue
3218   \finishedtitlepagetrue
3219 }
3220
3221 % Macros to be used within @titlepage:
3222
3223 \let\subtitlerm=\tenrm
3224 \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}
3225
3226 \parseargdef\title{%
3227   \checkenv\titlepage
3228   \leftline{\titlefonts\rmisbold #1}
3229   % print a rule at the page bottom also.
3230   \finishedtitlepagefalse
3231   \vskip4pt \hrule height 4pt width \hsize \vskip4pt
3232 }
3233
3234 \parseargdef\subtitle{%
3235   \checkenv\titlepage
3236   {\subtitlefont \rightline{#1}}%
3237 }
3238
3239 % @author should come last, but may come many times.
3240 % It can also be used inside @quotation.
3241 %
3242 \parseargdef\author{%
3243   \def\temp{\quotation}%
3244   \ifx\thisenv\temp
3245     \def\quotationauthor{#1}% printed in \Equotation.
3246   \else
3247     \checkenv\titlepage
3248     \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi
3249     {\secfonts\rmisbold \leftline{#1}}%
3250   \fi
3251 }
3252
3253
3254 % Set up page headings and footings.
3255
3256 \let\thispage=\folio
3257
3258 \newtoks\evenheadline    % headline on even pages
3259 \newtoks\oddheadline     % headline on odd pages
3260 \newtoks\evenfootline    % footline on even pages
3261 \newtoks\oddfootline     % footline on odd pages
3262
3263 % Now make TeX use those variables
3264 \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
3265                             \else \the\evenheadline \fi}}
3266 \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
3267                             \else \the\evenfootline \fi}\HEADINGShook}
3268 \let\HEADINGShook=\relax
3269
3270 % Commands to set those variables.
3271 % For example, this is what  @headings on  does
3272 % @evenheading @thistitle|@thispage|@thischapter
3273 % @oddheading @thischapter|@thispage|@thistitle
3274 % @evenfooting @thisfile||
3275 % @oddfooting ||@thisfile
3276
3277
3278 \def\evenheading{\parsearg\evenheadingxxx}
3279 \def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish}
3280 \def\evenheadingyyy #1\|#2\|#3\|#4\finish{%
3281 \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3282
3283 \def\oddheading{\parsearg\oddheadingxxx}
3284 \def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish}
3285 \def\oddheadingyyy #1\|#2\|#3\|#4\finish{%
3286 \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3287
3288 \parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
3289
3290 \def\evenfooting{\parsearg\evenfootingxxx}
3291 \def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish}
3292 \def\evenfootingyyy #1\|#2\|#3\|#4\finish{%
3293 \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3294
3295 \def\oddfooting{\parsearg\oddfootingxxx}
3296 \def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish}
3297 \def\oddfootingyyy #1\|#2\|#3\|#4\finish{%
3298   \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}%
3299   %
3300   % Leave some space for the footline.  Hopefully ok to assume
3301   % @evenfooting will not be used by itself.
3302   \global\advance\pageheight by -12pt
3303   \global\advance\vsize by -12pt
3304 }
3305
3306 \parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}}
3307
3308 % @evenheadingmarks top     \thischapter <- chapter at the top of a page
3309 % @evenheadingmarks bottom  \thischapter <- chapter at the bottom of a page
3310 %
3311 % The same set of arguments for:
3312 %
3313 % @oddheadingmarks
3314 % @evenfootingmarks
3315 % @oddfootingmarks
3316 % @everyheadingmarks
3317 % @everyfootingmarks
3318
3319 \def\evenheadingmarks{\headingmarks{even}{heading}}
3320 \def\oddheadingmarks{\headingmarks{odd}{heading}}
3321 \def\evenfootingmarks{\headingmarks{even}{footing}}
3322 \def\oddfootingmarks{\headingmarks{odd}{footing}}
3323 \def\everyheadingmarks#1 {\headingmarks{even}{heading}{#1}
3324                           \headingmarks{odd}{heading}{#1} }
3325 \def\everyfootingmarks#1 {\headingmarks{even}{footing}{#1}
3326                           \headingmarks{odd}{footing}{#1} }
3327 % #1 = even/odd, #2 = heading/footing, #3 = top/bottom.
3328 \def\headingmarks#1#2#3 {%
3329   \expandafter\let\expandafter\temp \csname get#3headingmarks\endcsname
3330   \global\expandafter\let\csname get#1#2marks\endcsname \temp
3331 }
3332
3333 \everyheadingmarks bottom
3334 \everyfootingmarks bottom
3335
3336 % @headings double      turns headings on for double-sided printing.
3337 % @headings single      turns headings on for single-sided printing.
3338 % @headings off         turns them off.
3339 % @headings on          same as @headings double, retained for compatibility.
3340 % @headings after       turns on double-sided headings after this page.
3341 % @headings doubleafter turns on double-sided headings after this page.
3342 % @headings singleafter turns on single-sided headings after this page.
3343 % By default, they are off at the start of a document,
3344 % and turned `on' after @end titlepage.
3345
3346 \def\headings #1 {\csname HEADINGS#1\endcsname}
3347
3348 \def\headingsoff{% non-global headings elimination
3349   \evenheadline={\hfil}\evenfootline={\hfil}%
3350    \oddheadline={\hfil}\oddfootline={\hfil}%
3351 }
3352
3353 \def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting
3354 \HEADINGSoff  % it's the default
3355
3356 % When we turn headings on, set the page number to 1.
3357 % For double-sided printing, put current file name in lower left corner,
3358 % chapter name on inside top of right hand pages, document
3359 % title on inside top of left hand pages, and page numbers on outside top
3360 % edge of all pages.
3361 \def\HEADINGSdouble{%
3362 \global\pageno=1
3363 \global\evenfootline={\hfil}
3364 \global\oddfootline={\hfil}
3365 \global\evenheadline={\line{\folio\hfil\thistitle}}
3366 \global\oddheadline={\line{\thischapter\hfil\folio}}
3367 \global\let\contentsalignmacro = \chapoddpage
3368 }
3369 \let\contentsalignmacro = \chappager
3370
3371 % For single-sided printing, chapter title goes across top left of page,
3372 % page number on top right.
3373 \def\HEADINGSsingle{%
3374 \global\pageno=1
3375 \global\evenfootline={\hfil}
3376 \global\oddfootline={\hfil}
3377 \global\evenheadline={\line{\thischapter\hfil\folio}}
3378 \global\oddheadline={\line{\thischapter\hfil\folio}}
3379 \global\let\contentsalignmacro = \chappager
3380 }
3381 \def\HEADINGSon{\HEADINGSdouble}
3382
3383 \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
3384 \let\HEADINGSdoubleafter=\HEADINGSafter
3385 \def\HEADINGSdoublex{%
3386 \global\evenfootline={\hfil}
3387 \global\oddfootline={\hfil}
3388 \global\evenheadline={\line{\folio\hfil\thistitle}}
3389 \global\oddheadline={\line{\thischapter\hfil\folio}}
3390 \global\let\contentsalignmacro = \chapoddpage
3391 }
3392
3393 \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
3394 \def\HEADINGSsinglex{%
3395 \global\evenfootline={\hfil}
3396 \global\oddfootline={\hfil}
3397 \global\evenheadline={\line{\thischapter\hfil\folio}}
3398 \global\oddheadline={\line{\thischapter\hfil\folio}}
3399 \global\let\contentsalignmacro = \chappager
3400 }
3401
3402 % Subroutines used in generating headings
3403 % This produces Day Month Year style of output.
3404 % Only define if not already defined, in case a txi-??.tex file has set
3405 % up a different format (e.g., txi-cs.tex does this).
3406 \ifx\today\thisisundefined
3407 \def\today{%
3408   \number\day\space
3409   \ifcase\month
3410   \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr
3411   \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug
3412   \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec
3413   \fi
3414   \space\number\year}
3415 \fi
3416
3417 % @settitle line...  specifies the title of the document, for headings.
3418 % It generates no output of its own.
3419 \def\thistitle{\putwordNoTitle}
3420 \def\settitle{\parsearg{\gdef\thistitle}}
3421
3422
3423 \message{tables,}
3424 % Tables -- @table, @ftable, @vtable, @item(x).
3425
3426 % default indentation of table text
3427 \newdimen\tableindent \tableindent=.8in
3428 % default indentation of @itemize and @enumerate text
3429 \newdimen\itemindent  \itemindent=.3in
3430 % margin between end of table item and start of table text.
3431 \newdimen\itemmargin  \itemmargin=.1in
3432
3433 % used internally for \itemindent minus \itemmargin
3434 \newdimen\itemmax
3435
3436 % Note @table, @ftable, and @vtable define @item, @itemx, etc., with
3437 % these defs.
3438 % They also define \itemindex
3439 % to index the item name in whatever manner is desired (perhaps none).
3440
3441 \newif\ifitemxneedsnegativevskip
3442
3443 \def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
3444
3445 \def\internalBitem{\smallbreak \parsearg\itemzzz}
3446 \def\internalBitemx{\itemxpar \parsearg\itemzzz}
3447
3448 \def\itemzzz #1{\begingroup %
3449   \advance\hsize by -\rightskip
3450   \advance\hsize by -\tableindent
3451   \setbox0=\hbox{\itemindicate{#1}}%
3452   \itemindex{#1}%
3453   \nobreak % This prevents a break before @itemx.
3454   %
3455   % If the item text does not fit in the space we have, put it on a line
3456   % by itself, and do not allow a page break either before or after that
3457   % line.  We do not start a paragraph here because then if the next
3458   % command is, e.g., @kindex, the whatsit would get put into the
3459   % horizontal list on a line by itself, resulting in extra blank space.
3460   \ifdim \wd0>\itemmax
3461     %
3462     % Make this a paragraph so we get the \parskip glue and wrapping,
3463     % but leave it ragged-right.
3464     \begingroup
3465       \advance\leftskip by-\tableindent
3466       \advance\hsize by\tableindent
3467       \advance\rightskip by0pt plus1fil\relax
3468       \leavevmode\unhbox0\par
3469     \endgroup
3470     %
3471     % We're going to be starting a paragraph, but we don't want the
3472     % \parskip glue -- logically it's part of the @item we just started.
3473     \nobreak \vskip-\parskip
3474     %
3475     % Stop a page break at the \parskip glue coming up.  However, if
3476     % what follows is an environment such as @example, there will be no
3477     % \parskip glue; then the negative vskip we just inserted would
3478     % cause the example and the item to crash together.  So we use this
3479     % bizarre value of 10001 as a signal to \aboveenvbreak to insert
3480     % \parskip glue after all.  Section titles are handled this way also.
3481     %
3482     \penalty 10001
3483     \endgroup
3484     \itemxneedsnegativevskipfalse
3485   \else
3486     % The item text fits into the space.  Start a paragraph, so that the
3487     % following text (if any) will end up on the same line.
3488     \noindent
3489     % Do this with kerns and \unhbox so that if there is a footnote in
3490     % the item text, it can migrate to the main vertical list and
3491     % eventually be printed.
3492     \nobreak\kern-\tableindent
3493     \dimen0 = \itemmax  \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0
3494     \unhbox0
3495     \nobreak\kern\dimen0
3496     \endgroup
3497     \itemxneedsnegativevskiptrue
3498   \fi
3499 }
3500
3501 \def\item{\errmessage{@item while not in a list environment}}
3502 \def\itemx{\errmessage{@itemx while not in a list environment}}
3503
3504 % @table, @ftable, @vtable.
3505 \envdef\table{%
3506   \let\itemindex\gobble
3507   \tablecheck{table}%
3508 }
3509 \envdef\ftable{%
3510   \def\itemindex ##1{\doind {fn}{\code{##1}}}%
3511   \tablecheck{ftable}%
3512 }
3513 \envdef\vtable{%
3514   \def\itemindex ##1{\doind {vr}{\code{##1}}}%
3515   \tablecheck{vtable}%
3516 }
3517 \def\tablecheck#1{%
3518   \ifnum \the\catcode`\^^M=\active
3519     \endgroup
3520     \errmessage{This command won't work in this context; perhaps the problem is
3521       that we are \inenvironment\thisenv}%
3522     \def\next{\doignore{#1}}%
3523   \else
3524     \let\next\tablex
3525   \fi
3526   \next
3527 }
3528 \def\tablex#1{%
3529   \def\itemindicate{#1}%
3530   \parsearg\tabley
3531 }
3532 \def\tabley#1{%
3533   {%
3534     \makevalueexpandable
3535     \edef\temp{\noexpand\tablez #1\space\space\space}%
3536     \expandafter
3537   }\temp \endtablez
3538 }
3539 \def\tablez #1 #2 #3 #4\endtablez{%
3540   \aboveenvbreak
3541   \ifnum 0#1>0 \advance \leftskip by #1\mil \fi
3542   \ifnum 0#2>0 \tableindent=#2\mil \fi
3543   \ifnum 0#3>0 \advance \rightskip by #3\mil \fi
3544   \itemmax=\tableindent
3545   \advance \itemmax by -\itemmargin
3546   \advance \leftskip by \tableindent
3547   \exdentamount=\tableindent
3548   \parindent = 0pt
3549   \parskip = \smallskipamount
3550   \ifdim \parskip=0pt \parskip=2pt \fi
3551   \let\item = \internalBitem
3552   \let\itemx = \internalBitemx
3553 }
3554 \def\Etable{\endgraf\afterenvbreak}
3555 \let\Eftable\Etable
3556 \let\Evtable\Etable
3557 \let\Eitemize\Etable
3558 \let\Eenumerate\Etable
3559
3560 % This is the counter used by @enumerate, which is really @itemize
3561
3562 \newcount \itemno
3563
3564 \envdef\itemize{\parsearg\doitemize}
3565
3566 \def\doitemize#1{%
3567   \aboveenvbreak
3568   \itemmax=\itemindent
3569   \advance\itemmax by -\itemmargin
3570   \advance\leftskip by \itemindent
3571   \exdentamount=\itemindent
3572   \parindent=0pt
3573   \parskip=\smallskipamount
3574   \ifdim\parskip=0pt \parskip=2pt \fi
3575   %
3576   % Try typesetting the item mark that if the document erroneously says
3577   % something like @itemize @samp (intending @table), there's an error
3578   % right away at the @itemize.  It's not the best error message in the
3579   % world, but it's better than leaving it to the @item.  This means if
3580   % the user wants an empty mark, they have to say @w{} not just @w.
3581   \def\itemcontents{#1}%
3582   \setbox0 = \hbox{\itemcontents}%
3583   %
3584   % @itemize with no arg is equivalent to @itemize @bullet.
3585   \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi
3586   %
3587   \let\item=\itemizeitem
3588 }
3589
3590 % Definition of @item while inside @itemize and @enumerate.
3591 %
3592 \def\itemizeitem{%
3593   \advance\itemno by 1  % for enumerations
3594   {\let\par=\endgraf \smallbreak}% reasonable place to break
3595   {%
3596    % If the document has an @itemize directly after a section title, a
3597    % \nobreak will be last on the list, and \sectionheading will have
3598    % done a \vskip-\parskip.  In that case, we don't want to zero
3599    % parskip, or the item text will crash with the heading.  On the
3600    % other hand, when there is normal text preceding the item (as there
3601    % usually is), we do want to zero parskip, or there would be too much
3602    % space.  In that case, we won't have a \nobreak before.  At least
3603    % that's the theory.
3604    \ifnum\lastpenalty<10000 \parskip=0in \fi
3605    \noindent
3606    \hbox to 0pt{\hss \itemcontents \kern\itemmargin}%
3607    %
3608    \vadjust{\penalty 1200}}% not good to break after first line of item.
3609   \flushcr
3610 }
3611
3612 % \splitoff TOKENS\endmark defines \first to be the first token in
3613 % TOKENS, and \rest to be the remainder.
3614 %
3615 \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
3616
3617 % Allow an optional argument of an uppercase letter, lowercase letter,
3618 % or number, to specify the first label in the enumerated list.  No
3619 % argument is the same as `1'.
3620 %
3621 \envparseargdef\enumerate{\enumeratey #1  \endenumeratey}
3622 \def\enumeratey #1 #2\endenumeratey{%
3623   % If we were given no argument, pretend we were given `1'.
3624   \def\thearg{#1}%
3625   \ifx\thearg\empty \def\thearg{1}\fi
3626   %
3627   % Detect if the argument is a single token.  If so, it might be a
3628   % letter.  Otherwise, the only valid thing it can be is a number.
3629   % (We will always have one token, because of the test we just made.
3630   % This is a good thing, since \splitoff doesn't work given nothing at
3631   % all -- the first parameter is undelimited.)
3632   \expandafter\splitoff\thearg\endmark
3633   \ifx\rest\empty
3634     % Only one token in the argument.  It could still be anything.
3635     % A ``lowercase letter'' is one whose \lccode is nonzero.
3636     % An ``uppercase letter'' is one whose \lccode is both nonzero, and
3637     %   not equal to itself.
3638     % Otherwise, we assume it's a number.
3639     %
3640     % We need the \relax at the end of the \ifnum lines to stop TeX from
3641     % continuing to look for a <number>.
3642     %
3643     \ifnum\lccode\expandafter`\thearg=0\relax
3644       \numericenumerate % a number (we hope)
3645     \else
3646       % It's a letter.
3647       \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
3648         \lowercaseenumerate % lowercase letter
3649       \else
3650         \uppercaseenumerate % uppercase letter
3651       \fi
3652     \fi
3653   \else
3654     % Multiple tokens in the argument.  We hope it's a number.
3655     \numericenumerate
3656   \fi
3657 }
3658
3659 % An @enumerate whose labels are integers.  The starting integer is
3660 % given in \thearg.
3661 %
3662 \def\numericenumerate{%
3663   \itemno = \thearg
3664   \startenumeration{\the\itemno}%
3665 }
3666
3667 % The starting (lowercase) letter is in \thearg.
3668 \def\lowercaseenumerate{%
3669   \itemno = \expandafter`\thearg
3670   \startenumeration{%
3671     % Be sure we're not beyond the end of the alphabet.
3672     \ifnum\itemno=0
3673       \errmessage{No more lowercase letters in @enumerate; get a bigger
3674                   alphabet}%
3675     \fi
3676     \char\lccode\itemno
3677   }%
3678 }
3679
3680 % The starting (uppercase) letter is in \thearg.
3681 \def\uppercaseenumerate{%
3682   \itemno = \expandafter`\thearg
3683   \startenumeration{%
3684     % Be sure we're not beyond the end of the alphabet.
3685     \ifnum\itemno=0
3686       \errmessage{No more uppercase letters in @enumerate; get a bigger
3687                   alphabet}
3688     \fi
3689     \char\uccode\itemno
3690   }%
3691 }
3692
3693 % Call \doitemize, adding a period to the first argument and supplying the
3694 % common last two arguments.  Also subtract one from the initial value in
3695 % \itemno, since @item increments \itemno.
3696 %
3697 \def\startenumeration#1{%
3698   \advance\itemno by -1
3699   \doitemize{#1.}\flushcr
3700 }
3701
3702 % @alphaenumerate and @capsenumerate are abbreviations for giving an arg
3703 % to @enumerate.
3704 %
3705 \def\alphaenumerate{\enumerate{a}}
3706 \def\capsenumerate{\enumerate{A}}
3707 \def\Ealphaenumerate{\Eenumerate}
3708 \def\Ecapsenumerate{\Eenumerate}
3709
3710
3711 % @multitable macros
3712 % Amy Hendrickson, 8/18/94, 3/6/96
3713 %
3714 % @multitable ... @end multitable will make as many columns as desired.
3715 % Contents of each column will wrap at width given in preamble.  Width
3716 % can be specified either with sample text given in a template line,
3717 % or in percent of \hsize, the current width of text on page.
3718
3719 % Table can continue over pages but will only break between lines.
3720
3721 % To make preamble:
3722 %
3723 % Either define widths of columns in terms of percent of \hsize:
3724 %   @multitable @columnfractions .25 .3 .45
3725 %   @item ...
3726 %
3727 %   Numbers following @columnfractions are the percent of the total
3728 %   current hsize to be used for each column. You may use as many
3729 %   columns as desired.
3730
3731
3732 % Or use a template:
3733 %   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
3734 %   @item ...
3735 %   using the widest term desired in each column.
3736
3737 % Each new table line starts with @item, each subsequent new column
3738 % starts with @tab. Empty columns may be produced by supplying @tab's
3739 % with nothing between them for as many times as empty columns are needed,
3740 % ie, @tab@tab@tab will produce two empty columns.
3741
3742 % @item, @tab do not need to be on their own lines, but it will not hurt
3743 % if they are.
3744
3745 % Sample multitable:
3746
3747 %   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
3748 %   @item first col stuff @tab second col stuff @tab third col
3749 %   @item
3750 %   first col stuff
3751 %   @tab
3752 %   second col stuff
3753 %   @tab
3754 %   third col
3755 %   @item first col stuff @tab second col stuff
3756 %   @tab Many paragraphs of text may be used in any column.
3757 %
3758 %         They will wrap at the width determined by the template.
3759 %   @item@tab@tab This will be in third column.
3760 %   @end multitable
3761
3762 % Default dimensions may be reset by user.
3763 % @multitableparskip is vertical space between paragraphs in table.
3764 % @multitableparindent is paragraph indent in table.
3765 % @multitablecolmargin is horizontal space to be left between columns.
3766 % @multitablelinespace is space to leave between table items, baseline
3767 %                                                            to baseline.
3768 %   0pt means it depends on current normal line spacing.
3769 %
3770 \newskip\multitableparskip
3771 \newskip\multitableparindent
3772 \newdimen\multitablecolspace
3773 \newskip\multitablelinespace
3774 \multitableparskip=0pt
3775 \multitableparindent=6pt
3776 \multitablecolspace=12pt
3777 \multitablelinespace=0pt
3778
3779 % Macros used to set up halign preamble:
3780 %
3781 \let\endsetuptable\relax
3782 \def\xendsetuptable{\endsetuptable}
3783 \let\columnfractions\relax
3784 \def\xcolumnfractions{\columnfractions}
3785 \newif\ifsetpercent
3786
3787 % #1 is the @columnfraction, usually a decimal number like .5, but might
3788 % be just 1.  We just use it, whatever it is.
3789 %
3790 \def\pickupwholefraction#1 {%
3791   \global\advance\colcount by 1
3792   \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}%
3793   \setuptable
3794 }
3795
3796 \newcount\colcount
3797 \def\setuptable#1{%
3798   \def\firstarg{#1}%
3799   \ifx\firstarg\xendsetuptable
3800     \let\go = \relax
3801   \else
3802     \ifx\firstarg\xcolumnfractions
3803       \global\setpercenttrue
3804     \else
3805       \ifsetpercent
3806          \let\go\pickupwholefraction
3807       \else
3808          \global\advance\colcount by 1
3809          \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a
3810                    % separator; typically that is always in the input, anyway.
3811          \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
3812       \fi
3813     \fi
3814     \ifx\go\pickupwholefraction
3815       % Put the argument back for the \pickupwholefraction call, so
3816       % we'll always have a period there to be parsed.
3817       \def\go{\pickupwholefraction#1}%
3818     \else
3819       \let\go = \setuptable
3820     \fi%
3821   \fi
3822   \go
3823 }
3824
3825 % multitable-only commands.
3826 %
3827 % @headitem starts a heading row, which we typeset in bold.
3828 % Assignments have to be global since we are inside the implicit group
3829 % of an alignment entry.  \everycr resets \everytab so we don't have to
3830 % undo it ourselves.
3831 \def\headitemfont{\b}% for people to use in the template row; not changeable
3832 \def\headitem{%
3833   \checkenv\multitable
3834   \crcr
3835   \global\everytab={\bf}% can't use \headitemfont since the parsing differs
3836   \the\everytab % for the first item
3837 }%
3838 %
3839 % A \tab used to include \hskip1sp.  But then the space in a template
3840 % line is not enough.  That is bad.  So let's go back to just `&' until
3841 % we again encounter the problem the 1sp was intended to solve.
3842 %                                       --karl, nathan@acm.org, 20apr99.
3843 \def\tab{\checkenv\multitable &\the\everytab}%
3844
3845 % @multitable ... @end multitable definitions:
3846 %
3847 \newtoks\everytab  % insert after every tab.
3848 %
3849 \envdef\multitable{%
3850   \vskip\parskip
3851   \startsavinginserts
3852   %
3853   % @item within a multitable starts a normal row.
3854   % We use \def instead of \let so that if one of the multitable entries
3855   % contains an @itemize, we don't choke on the \item (seen as \crcr aka
3856   % \endtemplate) expanding \doitemize.
3857   \def\item{\crcr}%
3858   %
3859   \tolerance=9500
3860   \hbadness=9500
3861   \setmultitablespacing
3862   \parskip=\multitableparskip
3863   \parindent=\multitableparindent
3864   \overfullrule=0pt
3865   \global\colcount=0
3866   %
3867   \everycr = {%
3868     \noalign{%
3869       \global\everytab={}%
3870       \global\colcount=0 % Reset the column counter.
3871       % Check for saved footnotes, etc.
3872       \checkinserts
3873       % Keeps underfull box messages off when table breaks over pages.
3874       %\filbreak
3875         % Maybe so, but it also creates really weird page breaks when the
3876         % table breaks over pages. Wouldn't \vfil be better?  Wait until the
3877         % problem manifests itself, so it can be fixed for real --karl.
3878     }%
3879   }%
3880   %
3881   \parsearg\domultitable
3882 }
3883 \def\domultitable#1{%
3884   % To parse everything between @multitable and @item:
3885   \setuptable#1 \endsetuptable
3886   %
3887   % This preamble sets up a generic column definition, which will
3888   % be used as many times as user calls for columns.
3889   % \vtop will set a single line and will also let text wrap and
3890   % continue for many paragraphs if desired.
3891   \halign\bgroup &%
3892     \global\advance\colcount by 1
3893     \multistrut
3894     \vtop{%
3895       % Use the current \colcount to find the correct column width:
3896       \hsize=\expandafter\csname col\the\colcount\endcsname
3897       %
3898       % In order to keep entries from bumping into each other
3899       % we will add a \leftskip of \multitablecolspace to all columns after
3900       % the first one.
3901       %
3902       % If a template has been used, we will add \multitablecolspace
3903       % to the width of each template entry.
3904       %
3905       % If the user has set preamble in terms of percent of \hsize we will
3906       % use that dimension as the width of the column, and the \leftskip
3907       % will keep entries from bumping into each other.  Table will start at
3908       % left margin and final column will justify at right margin.
3909       %
3910       % Make sure we don't inherit \rightskip from the outer environment.
3911       \rightskip=0pt
3912       \ifnum\colcount=1
3913         % The first column will be indented with the surrounding text.
3914         \advance\hsize by\leftskip
3915       \else
3916         \ifsetpercent \else
3917           % If user has not set preamble in terms of percent of \hsize
3918           % we will advance \hsize by \multitablecolspace.
3919           \advance\hsize by \multitablecolspace
3920         \fi
3921        % In either case we will make \leftskip=\multitablecolspace:
3922       \leftskip=\multitablecolspace
3923       \fi
3924       % Ignoring space at the beginning and end avoids an occasional spurious
3925       % blank line, when TeX decides to break the line at the space before the
3926       % box from the multistrut, so the strut ends up on a line by itself.
3927       % For example:
3928       % @multitable @columnfractions .11 .89
3929       % @item @code{#}
3930       % @tab Legal holiday which is valid in major parts of the whole country.
3931       % Is automatically provided with highlighting sequences respectively
3932       % marking characters.
3933       \noindent\ignorespaces##\unskip\multistrut
3934     }\cr
3935 }
3936 \def\Emultitable{%
3937   \crcr
3938   \egroup % end the \halign
3939   \global\setpercentfalse
3940 }
3941
3942 \def\setmultitablespacing{%
3943   \def\multistrut{\strut}% just use the standard line spacing
3944   %
3945   % Compute \multitablelinespace (if not defined by user) for use in
3946   % \multitableparskip calculation.  We used define \multistrut based on
3947   % this, but (ironically) that caused the spacing to be off.
3948   % See bug-texinfo report from Werner Lemberg, 31 Oct 2004 12:52:20 +0100.
3949 \ifdim\multitablelinespace=0pt
3950 \setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip
3951 \global\advance\multitablelinespace by-\ht0
3952 \fi
3953 % Test to see if parskip is larger than space between lines of
3954 % table. If not, do nothing.
3955 %        If so, set to same dimension as multitablelinespace.
3956 \ifdim\multitableparskip>\multitablelinespace
3957 \global\multitableparskip=\multitablelinespace
3958 \global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller
3959                                       %% than skip between lines in the table.
3960 \fi%
3961 \ifdim\multitableparskip=0pt
3962 \global\multitableparskip=\multitablelinespace
3963 \global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller
3964                                       %% than skip between lines in the table.
3965 \fi}
3966
3967
3968 \message{conditionals,}
3969
3970 % @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext,
3971 % @ifnotxml always succeed.  They currently do nothing; we don't
3972 % attempt to check whether the conditionals are properly nested.  But we
3973 % have to remember that they are conditionals, so that @end doesn't
3974 % attempt to close an environment group.
3975 %
3976 \def\makecond#1{%
3977   \expandafter\let\csname #1\endcsname = \relax
3978   \expandafter\let\csname iscond.#1\endcsname = 1
3979 }
3980 \makecond{iftex}
3981 \makecond{ifnotdocbook}
3982 \makecond{ifnothtml}
3983 \makecond{ifnotinfo}
3984 \makecond{ifnotplaintext}
3985 \makecond{ifnotxml}
3986
3987 % Ignore @ignore, @ifhtml, @ifinfo, and the like.
3988 %
3989 \def\direntry{\doignore{direntry}}
3990 \def\documentdescription{\doignore{documentdescription}}
3991 \def\docbook{\doignore{docbook}}
3992 \def\html{\doignore{html}}
3993 \def\ifdocbook{\doignore{ifdocbook}}
3994 \def\ifhtml{\doignore{ifhtml}}
3995 \def\ifinfo{\doignore{ifinfo}}
3996 \def\ifnottex{\doignore{ifnottex}}
3997 \def\ifplaintext{\doignore{ifplaintext}}
3998 \def\ifxml{\doignore{ifxml}}
3999 \def\ignore{\doignore{ignore}}
4000 \def\menu{\doignore{menu}}
4001 \def\xml{\doignore{xml}}
4002
4003 % Ignore text until a line `@end #1', keeping track of nested conditionals.
4004 %
4005 % A count to remember the depth of nesting.
4006 \newcount\doignorecount
4007
4008 \def\doignore#1{\begingroup
4009   % Scan in ``verbatim'' mode:
4010   \obeylines
4011   \catcode`\@ = \other
4012   \catcode`\{ = \other
4013   \catcode`\} = \other
4014   %
4015   % Make sure that spaces turn into tokens that match what \doignoretext wants.
4016   \spaceisspace
4017   %
4018   % Count number of #1's that we've seen.
4019   \doignorecount = 0
4020   %
4021   % Swallow text until we reach the matching `@end #1'.
4022   \dodoignore{#1}%
4023 }
4024
4025 { \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source.
4026   \obeylines %
4027   %
4028   \gdef\dodoignore#1{%
4029     % #1 contains the command name as a string, e.g., `ifinfo'.
4030     %
4031     % Define a command to find the next `@end #1'.
4032     \long\def\doignoretext##1^^M@end #1{%
4033       \doignoretextyyy##1^^M@#1\_STOP_}%
4034     %
4035     % And this command to find another #1 command, at the beginning of a
4036     % line.  (Otherwise, we would consider a line `@c @ifset', for
4037     % example, to count as an @ifset for nesting.)
4038     \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}%
4039     %
4040     % And now expand that command.
4041     \doignoretext ^^M%
4042   }%
4043 }
4044
4045 \def\doignoreyyy#1{%
4046   \def\temp{#1}%
4047   \ifx\temp\empty                       % Nothing found.
4048     \let\next\doignoretextzzz
4049   \else                                 % Found a nested condition, ...
4050     \advance\doignorecount by 1
4051     \let\next\doignoretextyyy           % ..., look for another.
4052     % If we're here, #1 ends with ^^M\ifinfo (for example).
4053   \fi
4054   \next #1% the token \_STOP_ is present just after this macro.
4055 }
4056
4057 % We have to swallow the remaining "\_STOP_".
4058 %
4059 \def\doignoretextzzz#1{%
4060   \ifnum\doignorecount = 0      % We have just found the outermost @end.
4061     \let\next\enddoignore
4062   \else                         % Still inside a nested condition.
4063     \advance\doignorecount by -1
4064     \let\next\doignoretext      % Look for the next @end.
4065   \fi
4066   \next
4067 }
4068
4069 % Finish off ignored text.
4070 { \obeylines%
4071   % Ignore anything after the last `@end #1'; this matters in verbatim
4072   % environments, where otherwise the newline after an ignored conditional
4073   % would result in a blank line in the output.
4074   \gdef\enddoignore#1^^M{\endgroup\ignorespaces}%
4075 }
4076
4077
4078 % @set VAR sets the variable VAR to an empty value.
4079 % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
4080 %
4081 % Since we want to separate VAR from REST-OF-LINE (which might be
4082 % empty), we can't just use \parsearg; we have to insert a space of our
4083 % own to delimit the rest of the line, and then take it out again if we
4084 % didn't need it.
4085 % We rely on the fact that \parsearg sets \catcode`\ =10.
4086 %
4087 \parseargdef\set{\setyyy#1 \endsetyyy}
4088 \def\setyyy#1 #2\endsetyyy{%
4089   {%
4090     \makevalueexpandable
4091     \def\temp{#2}%
4092     \edef\next{\gdef\makecsname{SET#1}}%
4093     \ifx\temp\empty
4094       \next{}%
4095     \else
4096       \setzzz#2\endsetzzz
4097     \fi
4098   }%
4099 }
4100 % Remove the trailing space \setxxx inserted.
4101 \def\setzzz#1 \endsetzzz{\next{#1}}
4102
4103 % @clear VAR clears (i.e., unsets) the variable VAR.
4104 %
4105 \parseargdef\clear{%
4106   {%
4107     \makevalueexpandable
4108     \global\expandafter\let\csname SET#1\endcsname=\relax
4109   }%
4110 }
4111
4112 % @value{foo} gets the text saved in variable foo.
4113 \def\value{\begingroup\makevalueexpandable\valuexxx}
4114 \def\valuexxx#1{\expandablevalue{#1}\endgroup}
4115 {
4116   \catcode`\- = \active \catcode`\_ = \active
4117   %
4118   \gdef\makevalueexpandable{%
4119     \let\value = \expandablevalue
4120     % We don't want these characters active, ...
4121     \catcode`\-=\other \catcode`\_=\other
4122     % ..., but we might end up with active ones in the argument if
4123     % we're called from @code, as @code{@value{foo-bar_}}, though.
4124     % So \let them to their normal equivalents.
4125     \let-\realdash \let_\normalunderscore
4126   }
4127 }
4128
4129 % We have this subroutine so that we can handle at least some @value's
4130 % properly in indexes (we call \makevalueexpandable in \indexdummies).
4131 % The command has to be fully expandable (if the variable is set), since
4132 % the result winds up in the index file.  This means that if the
4133 % variable's value contains other Texinfo commands, it's almost certain
4134 % it will fail (although perhaps we could fix that with sufficient work
4135 % to do a one-level expansion on the result, instead of complete).
4136 %
4137 \def\expandablevalue#1{%
4138   \expandafter\ifx\csname SET#1\endcsname\relax
4139     {[No value for ``#1'']}%
4140     \message{Variable `#1', used in @value, is not set.}%
4141   \else
4142     \csname SET#1\endcsname
4143   \fi
4144 }
4145
4146 % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
4147 % with @set.
4148 %
4149 % To get special treatment of `@end ifset,' call \makeond and the redefine.
4150 %
4151 \makecond{ifset}
4152 \def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}}
4153 \def\doifset#1#2{%
4154   {%
4155     \makevalueexpandable
4156     \let\next=\empty
4157     \expandafter\ifx\csname SET#2\endcsname\relax
4158       #1% If not set, redefine \next.
4159     \fi
4160     \expandafter
4161   }\next
4162 }
4163 \def\ifsetfail{\doignore{ifset}}
4164
4165 % @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been
4166 % defined with @set, or has been undefined with @clear.
4167 %
4168 % The `\else' inside the `\doifset' parameter is a trick to reuse the
4169 % above code: if the variable is not set, do nothing, if it is set,
4170 % then redefine \next to \ifclearfail.
4171 %
4172 \makecond{ifclear}
4173 \def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}}
4174 \def\ifclearfail{\doignore{ifclear}}
4175
4176 % @dircategory CATEGORY  -- specify a category of the dir file
4177 % which this file should belong to.  Ignore this in TeX.
4178 \let\dircategory=\comment
4179
4180 % @defininfoenclose.
4181 \let\definfoenclose=\comment
4182
4183
4184 \message{indexing,}
4185 % Index generation facilities
4186
4187 % Define \newwrite to be identical to plain tex's \newwrite
4188 % except not \outer, so it can be used within macros and \if's.
4189 \edef\newwrite{\makecsname{ptexnewwrite}}
4190
4191 % \newindex {foo} defines an index named foo.
4192 % It automatically defines \fooindex such that
4193 % \fooindex ...rest of line... puts an entry in the index foo.
4194 % It also defines \fooindfile to be the number of the output channel for
4195 % the file that accumulates this index.  The file's extension is foo.
4196 % The name of an index should be no more than 2 characters long
4197 % for the sake of vms.
4198 %
4199 \def\newindex#1{%
4200   \iflinks
4201     \expandafter\newwrite \csname#1indfile\endcsname
4202     \openout \csname#1indfile\endcsname \jobname.#1 % Open the file
4203   \fi
4204   \expandafter\xdef\csname#1index\endcsname{%     % Define @#1index
4205     \noexpand\doindex{#1}}
4206 }
4207
4208 % @defindex foo  ==  \newindex{foo}
4209 %
4210 \def\defindex{\parsearg\newindex}
4211
4212 % Define @defcodeindex, like @defindex except put all entries in @code.
4213 %
4214 \def\defcodeindex{\parsearg\newcodeindex}
4215 %
4216 \def\newcodeindex#1{%
4217   \iflinks
4218     \expandafter\newwrite \csname#1indfile\endcsname
4219     \openout \csname#1indfile\endcsname \jobname.#1
4220   \fi
4221   \expandafter\xdef\csname#1index\endcsname{%
4222     \noexpand\docodeindex{#1}}%
4223 }
4224
4225
4226 % @synindex foo bar    makes index foo feed into index bar.
4227 % Do this instead of @defindex foo if you don't want it as a separate index.
4228 %
4229 % @syncodeindex foo bar   similar, but put all entries made for index foo
4230 % inside @code.
4231 %
4232 \def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}}
4233 \def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}}
4234
4235 % #1 is \doindex or \docodeindex, #2 the index getting redefined (foo),
4236 % #3 the target index (bar).
4237 \def\dosynindex#1#2#3{%
4238   % Only do \closeout if we haven't already done it, else we'll end up
4239   % closing the target index.
4240   \expandafter \ifx\csname donesynindex#2\endcsname \relax
4241     % The \closeout helps reduce unnecessary open files; the limit on the
4242     % Acorn RISC OS is a mere 16 files.
4243     \expandafter\closeout\csname#2indfile\endcsname
4244     \expandafter\let\csname donesynindex#2\endcsname = 1
4245   \fi
4246   % redefine \fooindfile:
4247   \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname
4248   \expandafter\let\csname#2indfile\endcsname=\temp
4249   % redefine \fooindex:
4250   \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}%
4251 }
4252
4253 % Define \doindex, the driver for all \fooindex macros.
4254 % Argument #1 is generated by the calling \fooindex macro,
4255 %  and it is "foo", the name of the index.
4256
4257 % \doindex just uses \parsearg; it calls \doind for the actual work.
4258 % This is because \doind is more useful to call from other macros.
4259
4260 % There is also \dosubind {index}{topic}{subtopic}
4261 % which makes an entry in a two-level index such as the operation index.
4262
4263 \def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer}
4264 \def\singleindexer #1{\doind{\indexname}{#1}}
4265
4266 % like the previous two, but they put @code around the argument.
4267 \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
4268 \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
4269
4270 % Take care of Texinfo commands that can appear in an index entry.
4271 % Since there are some commands we want to expand, and others we don't,
4272 % we have to laboriously prevent expansion for those that we don't.
4273 %
4274 \def\indexdummies{%
4275   \escapechar = `\\     % use backslash in output files.
4276   \def\@{@}% change to @@ when we switch to @ as escape char in index files.
4277   \def\ {\realbackslash\space }%
4278   %
4279   % Need these unexpandable (because we define \tt as a dummy)
4280   % definitions when @{ or @} appear in index entry text.  Also, more
4281   % complicated, when \tex is in effect and \{ is a \delimiter again.
4282   % We can't use \lbracecmd and \rbracecmd because texindex assumes
4283   % braces and backslashes are used only as delimiters.  Perhaps we
4284   % should define @lbrace and @rbrace commands a la @comma.
4285   \def\{{{\tt\char123}}%
4286   \def\}{{\tt\char125}}%
4287   %
4288   % I don't entirely understand this, but when an index entry is
4289   % generated from a macro call, the \endinput which \scanmacro inserts
4290   % causes processing to be prematurely terminated.  This is,
4291   % apparently, because \indexsorttmp is fully expanded, and \endinput
4292   % is an expandable command.  The redefinition below makes \endinput
4293   % disappear altogether for that purpose -- although logging shows that
4294   % processing continues to some further point.  On the other hand, it
4295   % seems \endinput does not hurt in the printed index arg, since that
4296   % is still getting written without apparent harm.
4297   %
4298   % Sample source (mac-idx3.tex, reported by Graham Percival to
4299   % help-texinfo, 22may06):
4300   % @macro funindex {WORD}
4301   % @findex xyz
4302   % @end macro
4303   % ...
4304   % @funindex commtest
4305   %
4306   % The above is not enough to reproduce the bug, but it gives the flavor.
4307   %
4308   % Sample whatsit resulting:
4309   % .@write3{\entry{xyz}{@folio }{@code {xyz@endinput }}}
4310   %
4311   % So:
4312   \let\endinput = \empty
4313   %
4314   % Do the redefinitions.
4315   \commondummies
4316 }
4317
4318 % For the aux and toc files, @ is the escape character.  So we want to
4319 % redefine everything using @ as the escape character (instead of
4320 % \realbackslash, still used for index files).  When everything uses @,
4321 % this will be simpler.
4322 %
4323 \def\atdummies{%
4324   \def\@{@@}%
4325   \def\ {@ }%
4326   \let\{ = \lbraceatcmd
4327   \let\} = \rbraceatcmd
4328   %
4329   % Do the redefinitions.
4330   \commondummies
4331   \otherbackslash
4332 }
4333
4334 % Called from \indexdummies and \atdummies.
4335 %
4336 \def\commondummies{%
4337   %
4338   % \definedummyword defines \#1 as \string\#1\space, thus effectively
4339   % preventing its expansion.  This is used only for control words,
4340   % not control letters, because the \space would be incorrect for
4341   % control characters, but is needed to separate the control word
4342   % from whatever follows.
4343   %
4344   % For control letters, we have \definedummyletter, which omits the
4345   % space.
4346   %
4347   % These can be used both for control words that take an argument and
4348   % those that do not.  If it is followed by {arg} in the input, then
4349   % that will dutifully get written to the index (or wherever).
4350   %
4351   \def\definedummyword  ##1{\def##1{\string##1\space}}%
4352   \def\definedummyletter##1{\def##1{\string##1}}%
4353   \let\definedummyaccent\definedummyletter
4354   %
4355   \commondummiesnofonts
4356   %
4357   \definedummyletter\_%
4358   \definedummyletter\-%
4359   %
4360   % Non-English letters.
4361   \definedummyword\AA
4362   \definedummyword\AE
4363   \definedummyword\DH
4364   \definedummyword\L
4365   \definedummyword\O
4366   \definedummyword\OE
4367   \definedummyword\TH
4368   \definedummyword\aa
4369   \definedummyword\ae
4370   \definedummyword\dh
4371   \definedummyword\exclamdown
4372   \definedummyword\l
4373   \definedummyword\o
4374   \definedummyword\oe
4375   \definedummyword\ordf
4376   \definedummyword\ordm
4377   \definedummyword\questiondown
4378   \definedummyword\ss
4379   \definedummyword\th
4380   %
4381   % Although these internal commands shouldn't show up, sometimes they do.
4382   \definedummyword\bf
4383   \definedummyword\gtr
4384   \definedummyword\hat
4385   \definedummyword\less
4386   \definedummyword\sf
4387   \definedummyword\sl
4388   \definedummyword\tclose
4389   \definedummyword\tt
4390   %
4391   \definedummyword\LaTeX
4392   \definedummyword\TeX
4393   %
4394   % Assorted special characters.
4395   \definedummyword\arrow
4396   \definedummyword\bullet
4397   \definedummyword\comma
4398   \definedummyword\copyright
4399   \definedummyword\registeredsymbol
4400   \definedummyword\dots
4401   \definedummyword\enddots
4402   \definedummyword\entrybreak
4403   \definedummyword\equiv
4404   \definedummyword\error
4405   \definedummyword\euro
4406   \definedummyword\expansion
4407   \definedummyword\geq
4408   \definedummyword\guillemetleft
4409   \definedummyword\guillemetright
4410   \definedummyword\guilsinglleft
4411   \definedummyword\guilsinglright
4412   \definedummyword\leq
4413   \definedummyword\minus
4414   \definedummyword\ogonek
4415   \definedummyword\pounds
4416   \definedummyword\point
4417   \definedummyword\print
4418   \definedummyword\quotedblbase
4419   \definedummyword\quotedblleft
4420   \definedummyword\quotedblright
4421   \definedummyword\quoteleft
4422   \definedummyword\quoteright
4423   \definedummyword\quotesinglbase
4424   \definedummyword\result
4425   \definedummyword\textdegree
4426   %
4427   % We want to disable all macros so that they are not expanded by \write.
4428   \macrolist
4429   %
4430   \normalturnoffactive
4431   %
4432   % Handle some cases of @value -- where it does not contain any
4433   % (non-fully-expandable) commands.
4434   \makevalueexpandable
4435 }
4436
4437 % \commondummiesnofonts: common to \commondummies and \indexnofonts.
4438 %
4439 \def\commondummiesnofonts{%
4440   % Control letters and accents.
4441   \definedummyletter\!%
4442   \definedummyaccent\"%
4443   \definedummyaccent\'%
4444   \definedummyletter\*%
4445   \definedummyaccent\,%
4446   \definedummyletter\.%
4447   \definedummyletter\/%
4448   \definedummyletter\:%
4449   \definedummyaccent\=%
4450   \definedummyletter\?%
4451   \definedummyaccent\^%
4452   \definedummyaccent\`%
4453   \definedummyaccent\~%
4454   \definedummyword\u
4455   \definedummyword\v
4456   \definedummyword\H
4457   \definedummyword\dotaccent
4458   \definedummyword\ogonek
4459   \definedummyword\ringaccent
4460   \definedummyword\tieaccent
4461   \definedummyword\ubaraccent
4462   \definedummyword\udotaccent
4463   \definedummyword\dotless
4464   %
4465   % Texinfo font commands.
4466   \definedummyword\b
4467   \definedummyword\i
4468   \definedummyword\r
4469   \definedummyword\sansserif
4470   \definedummyword\sc
4471   \definedummyword\slanted
4472   \definedummyword\t
4473   %
4474   % Commands that take arguments.
4475   \definedummyword\acronym
4476   \definedummyword\cite
4477   \definedummyword\code
4478   \definedummyword\command
4479   \definedummyword\dfn
4480   \definedummyword\dmn
4481   \definedummyword\email
4482   \definedummyword\emph
4483   \definedummyword\env
4484   \definedummyword\file
4485   \definedummyword\indicateurl
4486   \definedummyword\kbd
4487   \definedummyword\key
4488   \definedummyword\math
4489   \definedummyword\option
4490   \definedummyword\pxref
4491   \definedummyword\ref
4492   \definedummyword\samp
4493   \definedummyword\strong
4494   \definedummyword\tie
4495   \definedummyword\uref
4496   \definedummyword\url
4497   \definedummyword\var
4498   \definedummyword\verb
4499   \definedummyword\w
4500   \definedummyword\xref
4501 }
4502
4503 % \indexnofonts is used when outputting the strings to sort the index
4504 % by, and when constructing control sequence names.  It eliminates all
4505 % control sequences and just writes whatever the best ASCII sort string
4506 % would be for a given command (usually its argument).
4507 %
4508 \def\indexnofonts{%
4509   % Accent commands should become @asis.
4510   \def\definedummyaccent##1{\let##1\asis}%
4511   % We can just ignore other control letters.
4512   \def\definedummyletter##1{\let##1\empty}%
4513   % All control words become @asis by default; overrides below.
4514   \let\definedummyword\definedummyaccent
4515   %
4516   \commondummiesnofonts
4517   %
4518   % Don't no-op \tt, since it isn't a user-level command
4519   % and is used in the definitions of the active chars like <, >, |, etc.
4520   % Likewise with the other plain tex font commands.
4521   %\let\tt=\asis
4522   %
4523   \def\ { }%
4524   \def\@{@}%
4525   \def\_{\normalunderscore}%
4526   \def\-{}% @- shouldn't affect sorting
4527   %
4528   % Unfortunately, texindex is not prepared to handle braces in the
4529   % content at all.  So for index sorting, we map @{ and @} to strings
4530   % starting with |, since that ASCII character is between ASCII { and }.
4531   \def\{{|a}%
4532   \def\}{|b}%
4533   %
4534   % Non-English letters.
4535   \def\AA{AA}%
4536   \def\AE{AE}%
4537   \def\DH{DZZ}%
4538   \def\L{L}%
4539   \def\OE{OE}%
4540   \def\O{O}%
4541   \def\TH{ZZZ}%
4542   \def\aa{aa}%
4543   \def\ae{ae}%
4544   \def\dh{dzz}%
4545   \def\exclamdown{!}%
4546   \def\l{l}%
4547   \def\oe{oe}%
4548   \def\ordf{a}%
4549   \def\ordm{o}%
4550   \def\o{o}%
4551   \def\questiondown{?}%
4552   \def\ss{ss}%
4553   \def\th{zzz}%
4554   %
4555   \def\LaTeX{LaTeX}%
4556   \def\TeX{TeX}%
4557   %
4558   % Assorted special characters.
4559   % (The following {} will end up in the sort string, but that's ok.)
4560   \def\arrow{->}%
4561   \def\bullet{bullet}%
4562   \def\comma{,}%
4563   \def\copyright{copyright}%
4564   \def\dots{...}%
4565   \def\enddots{...}%
4566   \def\equiv{==}%
4567   \def\error{error}%
4568   \def\euro{euro}%
4569   \def\expansion{==>}%
4570   \def\geq{>=}%
4571   \def\guillemetleft{<<}%
4572   \def\guillemetright{>>}%
4573   \def\guilsinglleft{<}%
4574   \def\guilsinglright{>}%
4575   \def\leq{<=}%
4576   \def\minus{-}%
4577   \def\point{.}%
4578   \def\pounds{pounds}%
4579   \def\print{-|}%
4580   \def\quotedblbase{"}%
4581   \def\quotedblleft{"}%
4582   \def\quotedblright{"}%
4583   \def\quoteleft{`}%
4584   \def\quoteright{'}%
4585   \def\quotesinglbase{,}%
4586   \def\registeredsymbol{R}%
4587   \def\result{=>}%
4588   \def\textdegree{o}%
4589   %
4590   \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax
4591   \else \indexlquoteignore \fi
4592   %
4593   % We need to get rid of all macros, leaving only the arguments (if present).
4594   % Of course this is not nearly correct, but it is the best we can do for now.
4595   % makeinfo does not expand macros in the argument to @deffn, which ends up
4596   % writing an index entry, and texindex isn't prepared for an index sort entry
4597   % that starts with \.
4598   %
4599   % Since macro invocations are followed by braces, we can just redefine them
4600   % to take a single TeX argument.  The case of a macro invocation that
4601   % goes to end-of-line is not handled.
4602   %
4603   \macrolist
4604 }
4605
4606 % Undocumented (for FSFS 2nd ed.): @set txiindexlquoteignore makes us
4607 % ignore left quotes in the sort term.
4608 {\catcode`\`=\active
4609  \gdef\indexlquoteignore{\let`=\empty}}
4610
4611 \let\indexbackslash=0  %overridden during \printindex.
4612 \let\SETmarginindex=\relax % put index entries in margin (undocumented)?
4613
4614 % Most index entries go through here, but \dosubind is the general case.
4615 % #1 is the index name, #2 is the entry text.
4616 \def\doind#1#2{\dosubind{#1}{#2}{}}
4617
4618 % Workhorse for all \fooindexes.
4619 % #1 is name of index, #2 is stuff to put there, #3 is subentry --
4620 % empty if called from \doind, as we usually are (the main exception
4621 % is with most defuns, which call us directly).
4622 %
4623 \def\dosubind#1#2#3{%
4624   \iflinks
4625   {%
4626     % Store the main index entry text (including the third arg).
4627     \toks0 = {#2}%
4628     % If third arg is present, precede it with a space.
4629     \def\thirdarg{#3}%
4630     \ifx\thirdarg\empty \else
4631       \toks0 = \expandafter{\the\toks0 \space #3}%
4632     \fi
4633     %
4634     \edef\writeto{\csname#1indfile\endcsname}%
4635     %
4636     \safewhatsit\dosubindwrite
4637   }%
4638   \fi
4639 }
4640
4641 % Write the entry in \toks0 to the index file:
4642 %
4643 \def\dosubindwrite{%
4644   % Put the index entry in the margin if desired.
4645   \ifx\SETmarginindex\relax\else
4646     \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}%
4647   \fi
4648   %
4649   % Remember, we are within a group.
4650   \indexdummies % Must do this here, since \bf, etc expand at this stage
4651   \def\backslashcurfont{\indexbackslash}% \indexbackslash isn't defined now
4652       % so it will be output as is; and it will print as backslash.
4653   %
4654   % Process the index entry with all font commands turned off, to
4655   % get the string to sort by.
4656   {\indexnofonts
4657    \edef\temp{\the\toks0}% need full expansion
4658    \xdef\indexsorttmp{\temp}%
4659   }%
4660   %
4661   % Set up the complete index entry, with both the sort key and
4662   % the original text, including any font commands.  We write
4663   % three arguments to \entry to the .?? file (four in the
4664   % subentry case), texindex reduces to two when writing the .??s
4665   % sorted result.
4666   \edef\temp{%
4667     \write\writeto{%
4668       \string\entry{\indexsorttmp}{\noexpand\folio}{\the\toks0}}%
4669   }%
4670   \temp
4671 }
4672
4673 % Take care of unwanted page breaks/skips around a whatsit:
4674 %
4675 % If a skip is the last thing on the list now, preserve it
4676 % by backing up by \lastskip, doing the \write, then inserting
4677 % the skip again.  Otherwise, the whatsit generated by the
4678 % \write or \pdfdest will make \lastskip zero.  The result is that
4679 % sequences like this:
4680 % @end defun
4681 % @tindex whatever
4682 % @defun ...
4683 % will have extra space inserted, because the \medbreak in the
4684 % start of the @defun won't see the skip inserted by the @end of
4685 % the previous defun.
4686 %
4687 % But don't do any of this if we're not in vertical mode.  We
4688 % don't want to do a \vskip and prematurely end a paragraph.
4689 %
4690 % Avoid page breaks due to these extra skips, too.
4691 %
4692 % But wait, there is a catch there:
4693 % We'll have to check whether \lastskip is zero skip.  \ifdim is not
4694 % sufficient for this purpose, as it ignores stretch and shrink parts
4695 % of the skip.  The only way seems to be to check the textual
4696 % representation of the skip.
4697 %
4698 % The following is almost like \def\zeroskipmacro{0.0pt} except that
4699 % the ``p'' and ``t'' characters have catcode \other, not 11 (letter).
4700 %
4701 \edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname}
4702 %
4703 \newskip\whatsitskip
4704 \newcount\whatsitpenalty
4705 %
4706 % ..., ready, GO:
4707 %
4708 \def\safewhatsit#1{%
4709 \ifhmode
4710   #1%
4711 \else
4712   % \lastskip and \lastpenalty cannot both be nonzero simultaneously.
4713   \whatsitskip = \lastskip
4714   \edef\lastskipmacro{\the\lastskip}%
4715   \whatsitpenalty = \lastpenalty
4716   %
4717   % If \lastskip is nonzero, that means the last item was a
4718   % skip.  And since a skip is discardable, that means this
4719   % -\whatsitskip glue we're inserting is preceded by a
4720   % non-discardable item, therefore it is not a potential
4721   % breakpoint, therefore no \nobreak needed.
4722   \ifx\lastskipmacro\zeroskipmacro
4723   \else
4724     \vskip-\whatsitskip
4725   \fi
4726   %
4727   #1%
4728   %
4729   \ifx\lastskipmacro\zeroskipmacro
4730     % If \lastskip was zero, perhaps the last item was a penalty, and
4731     % perhaps it was >=10000, e.g., a \nobreak.  In that case, we want
4732     % to re-insert the same penalty (values >10000 are used for various
4733     % signals); since we just inserted a non-discardable item, any
4734     % following glue (such as a \parskip) would be a breakpoint.  For example:
4735     %
4736     %   @deffn deffn-whatever
4737     %   @vindex index-whatever
4738     %   Description.
4739     % would allow a break between the index-whatever whatsit
4740     % and the "Description." paragraph.
4741     \ifnum\whatsitpenalty>9999 \penalty\whatsitpenalty \fi
4742   \else
4743     % On the other hand, if we had a nonzero \lastskip,
4744     % this make-up glue would be preceded by a non-discardable item
4745     % (the whatsit from the \write), so we must insert a \nobreak.
4746     \nobreak\vskip\whatsitskip
4747   \fi
4748 \fi
4749 }
4750
4751 % The index entry written in the file actually looks like
4752 %  \entry {sortstring}{page}{topic}
4753 % or
4754 %  \entry {sortstring}{page}{topic}{subtopic}
4755 % The texindex program reads in these files and writes files
4756 % containing these kinds of lines:
4757 %  \initial {c}
4758 %     before the first topic whose initial is c
4759 %  \entry {topic}{pagelist}
4760 %     for a topic that is used without subtopics
4761 %  \primary {topic}
4762 %     for the beginning of a topic that is used with subtopics
4763 %  \secondary {subtopic}{pagelist}
4764 %     for each subtopic.
4765
4766 % Define the user-accessible indexing commands
4767 % @findex, @vindex, @kindex, @cindex.
4768
4769 \def\findex {\fnindex}
4770 \def\kindex {\kyindex}
4771 \def\cindex {\cpindex}
4772 \def\vindex {\vrindex}
4773 \def\tindex {\tpindex}
4774 \def\pindex {\pgindex}
4775
4776 \def\cindexsub {\begingroup\obeylines\cindexsub}
4777 {\obeylines %
4778 \gdef\cindexsub "#1" #2^^M{\endgroup %
4779 \dosubind{cp}{#2}{#1}}}
4780
4781 % Define the macros used in formatting output of the sorted index material.
4782
4783 % @printindex causes a particular index (the ??s file) to get printed.
4784 % It does not print any chapter heading (usually an @unnumbered).
4785 %
4786 \parseargdef\printindex{\begingroup
4787   \dobreak \chapheadingskip{10000}%
4788   %
4789   \smallfonts \rm
4790   \tolerance = 9500
4791   \plainfrenchspacing
4792   \everypar = {}% don't want the \kern\-parindent from indentation suppression.
4793   %
4794   % See if the index file exists and is nonempty.
4795   % Change catcode of @ here so that if the index file contains
4796   % \initial {@}
4797   % as its first line, TeX doesn't complain about mismatched braces
4798   % (because it thinks @} is a control sequence).
4799   \catcode`\@ = 11
4800   \openin 1 \jobname.#1s
4801   \ifeof 1
4802     % \enddoublecolumns gets confused if there is no text in the index,
4803     % and it loses the chapter title and the aux file entries for the
4804     % index.  The easiest way to prevent this problem is to make sure
4805     % there is some text.
4806     \putwordIndexNonexistent
4807   \else
4808     %
4809     % If the index file exists but is empty, then \openin leaves \ifeof
4810     % false.  We have to make TeX try to read something from the file, so
4811     % it can discover if there is anything in it.
4812     \read 1 to \temp
4813     \ifeof 1
4814       \putwordIndexIsEmpty
4815     \else
4816       % Index files are almost Texinfo source, but we use \ as the escape
4817       % character.  It would be better to use @, but that's too big a change
4818       % to make right now.
4819       \def\indexbackslash{\backslashcurfont}%
4820       \catcode`\\ = 0
4821       \escapechar = `\\
4822       \begindoublecolumns
4823       \input \jobname.#1s
4824       \enddoublecolumns
4825     \fi
4826   \fi
4827   \closein 1
4828 \endgroup}
4829
4830 % These macros are used by the sorted index file itself.
4831 % Change them to control the appearance of the index.
4832
4833 \def\initial#1{{%
4834   % Some minor font changes for the special characters.
4835   \let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt
4836   %
4837   % Remove any glue we may have, we'll be inserting our own.
4838   \removelastskip
4839   %
4840   % We like breaks before the index initials, so insert a bonus.
4841   \nobreak
4842   \vskip 0pt plus 3\baselineskip
4843   \penalty 0
4844   \vskip 0pt plus -3\baselineskip
4845   %
4846   % Typeset the initial.  Making this add up to a whole number of
4847   % baselineskips increases the chance of the dots lining up from column
4848   % to column.  It still won't often be perfect, because of the stretch
4849   % we need before each entry, but it's better.
4850   %
4851   % No shrink because it confuses \balancecolumns.
4852   \vskip 1.67\baselineskip plus .5\baselineskip
4853   \leftline{\secbf #1}%
4854   % Do our best not to break after the initial.
4855   \nobreak
4856   \vskip .33\baselineskip plus .1\baselineskip
4857 }}
4858
4859 % \entry typesets a paragraph consisting of the text (#1), dot leaders, and
4860 % then page number (#2) flushed to the right margin.  It is used for index
4861 % and table of contents entries.  The paragraph is indented by \leftskip.
4862 %
4863 % A straightforward implementation would start like this:
4864 %       \def\entry#1#2{...
4865 % But this freezes the catcodes in the argument, and can cause problems to
4866 % @code, which sets - active.  This problem was fixed by a kludge---
4867 % ``-'' was active throughout whole index, but this isn't really right.
4868 % The right solution is to prevent \entry from swallowing the whole text.
4869 %                                 --kasal, 21nov03
4870 \def\entry{%
4871   \begingroup
4872     %
4873     % Start a new paragraph if necessary, so our assignments below can't
4874     % affect previous text.
4875     \par
4876     %
4877     % Do not fill out the last line with white space.
4878     \parfillskip = 0in
4879     %
4880     % No extra space above this paragraph.
4881     \parskip = 0in
4882     %
4883     % Do not prefer a separate line ending with a hyphen to fewer lines.
4884     \finalhyphendemerits = 0
4885     %
4886     % \hangindent is only relevant when the entry text and page number
4887     % don't both fit on one line.  In that case, bob suggests starting the
4888     % dots pretty far over on the line.  Unfortunately, a large
4889     % indentation looks wrong when the entry text itself is broken across
4890     % lines.  So we use a small indentation and put up with long leaders.
4891     %
4892     % \hangafter is reset to 1 (which is the value we want) at the start
4893     % of each paragraph, so we need not do anything with that.
4894     \hangindent = 2em
4895     %
4896     % When the entry text needs to be broken, just fill out the first line
4897     % with blank space.
4898     \rightskip = 0pt plus1fil
4899     %
4900     % A bit of stretch before each entry for the benefit of balancing
4901     % columns.
4902     \vskip 0pt plus1pt
4903     %
4904     % When reading the text of entry, convert explicit line breaks
4905     % from @* into spaces.  The user might give these in long section
4906     % titles, for instance.
4907     \def\*{\unskip\space\ignorespaces}%
4908     \def\entrybreak{\hfil\break}%
4909     %
4910     % Swallow the left brace of the text (first parameter):
4911     \afterassignment\doentry
4912     \let\temp =
4913 }
4914 \def\entrybreak{\unskip\space\ignorespaces}%
4915 \def\doentry{%
4916     \bgroup % Instead of the swallowed brace.
4917       \noindent
4918       \aftergroup\finishentry
4919       % And now comes the text of the entry.
4920 }
4921 \def\finishentry#1{%
4922     % #1 is the page number.
4923     %
4924     % The following is kludged to not output a line of dots in the index if
4925     % there are no page numbers.  The next person who breaks this will be
4926     % cursed by a Unix daemon.
4927     \setbox\boxA = \hbox{#1}%
4928     \ifdim\wd\boxA = 0pt
4929       \ %
4930     \else
4931       %
4932       % If we must, put the page number on a line of its own, and fill out
4933       % this line with blank space.  (The \hfil is overwhelmed with the
4934       % fill leaders glue in \indexdotfill if the page number does fit.)
4935       \hfil\penalty50
4936       \null\nobreak\indexdotfill % Have leaders before the page number.
4937       %
4938       % The `\ ' here is removed by the implicit \unskip that TeX does as
4939       % part of (the primitive) \par.  Without it, a spurious underfull
4940       % \hbox ensues.
4941       \ifpdf
4942         \pdfgettoks#1.%
4943         \ \the\toksA
4944       \else
4945         \ #1%
4946       \fi
4947     \fi
4948     \par
4949   \endgroup
4950 }
4951
4952 % Like plain.tex's \dotfill, except uses up at least 1 em.
4953 \def\indexdotfill{\cleaders
4954   \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1fill}
4955
4956 \def\primary #1{\line{#1\hfil}}
4957
4958 \newskip\secondaryindent \secondaryindent=0.5cm
4959 \def\secondary#1#2{{%
4960   \parfillskip=0in
4961   \parskip=0in
4962   \hangindent=1in
4963   \hangafter=1
4964   \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill
4965   \ifpdf
4966     \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
4967   \else
4968     #2
4969   \fi
4970   \par
4971 }}
4972
4973 % Define two-column mode, which we use to typeset indexes.
4974 % Adapted from the TeXbook, page 416, which is to say,
4975 % the manmac.tex format used to print the TeXbook itself.
4976 \catcode`\@=11
4977
4978 \newbox\partialpage
4979 \newdimen\doublecolumnhsize
4980
4981 \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
4982   % Grab any single-column material above us.
4983   \output = {%
4984     %
4985     % Here is a possibility not foreseen in manmac: if we accumulate a
4986     % whole lot of material, we might end up calling this \output
4987     % routine twice in a row (see the doublecol-lose test, which is
4988     % essentially a couple of indexes with @setchapternewpage off).  In
4989     % that case we just ship out what is in \partialpage with the normal
4990     % output routine.  Generally, \partialpage will be empty when this
4991     % runs and this will be a no-op.  See the indexspread.tex test case.
4992     \ifvoid\partialpage \else
4993       \onepageout{\pagecontents\partialpage}%
4994     \fi
4995     %
4996     \global\setbox\partialpage = \vbox{%
4997       % Unvbox the main output page.
4998       \unvbox\PAGE
4999       \kern-\topskip \kern\baselineskip
5000     }%
5001   }%
5002   \eject % run that output routine to set \partialpage
5003   %
5004   % Use the double-column output routine for subsequent pages.
5005   \output = {\doublecolumnout}%
5006   %
5007   % Change the page size parameters.  We could do this once outside this
5008   % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
5009   % format, but then we repeat the same computation.  Repeating a couple
5010   % of assignments once per index is clearly meaningless for the
5011   % execution time, so we may as well do it in one place.
5012   %
5013   % First we halve the line length, less a little for the gutter between
5014   % the columns.  We compute the gutter based on the line length, so it
5015   % changes automatically with the paper format.  The magic constant
5016   % below is chosen so that the gutter has the same value (well, +-<1pt)
5017   % as it did when we hard-coded it.
5018   %
5019   % We put the result in a separate register, \doublecolumhsize, so we
5020   % can restore it in \pagesofar, after \hsize itself has (potentially)
5021   % been clobbered.
5022   %
5023   \doublecolumnhsize = \hsize
5024     \advance\doublecolumnhsize by -.04154\hsize
5025     \divide\doublecolumnhsize by 2
5026   \hsize = \doublecolumnhsize
5027   %
5028   % Double the \vsize as well.  (We don't need a separate register here,
5029   % since nobody clobbers \vsize.)
5030   \vsize = 2\vsize
5031 }
5032
5033 % The double-column output routine for all double-column pages except
5034 % the last.
5035 %
5036 \def\doublecolumnout{%
5037   \splittopskip=\topskip \splitmaxdepth=\maxdepth
5038   % Get the available space for the double columns -- the normal
5039   % (undoubled) page height minus any material left over from the
5040   % previous page.
5041   \dimen@ = \vsize
5042   \divide\dimen@ by 2
5043   \advance\dimen@ by -\ht\partialpage
5044   %
5045   % box0 will be the left-hand column, box2 the right.
5046   \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
5047   \onepageout\pagesofar
5048   \unvbox255
5049   \penalty\outputpenalty
5050 }
5051 %
5052 % Re-output the contents of the output page -- any previous material,
5053 % followed by the two boxes we just split, in box0 and box2.
5054 \def\pagesofar{%
5055   \unvbox\partialpage
5056   %
5057   \hsize = \doublecolumnhsize
5058   \wd0=\hsize \wd2=\hsize
5059   \hbox to\pagewidth{\box0\hfil\box2}%
5060 }
5061 %
5062 % All done with double columns.
5063 \def\enddoublecolumns{%
5064   % The following penalty ensures that the page builder is exercised
5065   % _before_ we change the output routine.  This is necessary in the
5066   % following situation:
5067   %
5068   % The last section of the index consists only of a single entry.
5069   % Before this section, \pagetotal is less than \pagegoal, so no
5070   % break occurs before the last section starts.  However, the last
5071   % section, consisting of \initial and the single \entry, does not
5072   % fit on the page and has to be broken off.  Without the following
5073   % penalty the page builder will not be exercised until \eject
5074   % below, and by that time we'll already have changed the output
5075   % routine to the \balancecolumns version, so the next-to-last
5076   % double-column page will be processed with \balancecolumns, which
5077   % is wrong:  The two columns will go to the main vertical list, with
5078   % the broken-off section in the recent contributions.  As soon as
5079   % the output routine finishes, TeX starts reconsidering the page
5080   % break.  The two columns and the broken-off section both fit on the
5081   % page, because the two columns now take up only half of the page
5082   % goal.  When TeX sees \eject from below which follows the final
5083   % section, it invokes the new output routine that we've set after
5084   % \balancecolumns below; \onepageout will try to fit the two columns
5085   % and the final section into the vbox of \pageheight (see
5086   % \pagebody), causing an overfull box.
5087   %
5088   % Note that glue won't work here, because glue does not exercise the
5089   % page builder, unlike penalties (see The TeXbook, pp. 280-281).
5090   \penalty0
5091   %
5092   \output = {%
5093     % Split the last of the double-column material.  Leave it on the
5094     % current page, no automatic page break.
5095     \balancecolumns
5096     %
5097     % If we end up splitting too much material for the current page,
5098     % though, there will be another page break right after this \output
5099     % invocation ends.  Having called \balancecolumns once, we do not
5100     % want to call it again.  Therefore, reset \output to its normal
5101     % definition right away.  (We hope \balancecolumns will never be
5102     % called on to balance too much material, but if it is, this makes
5103     % the output somewhat more palatable.)
5104     \global\output = {\onepageout{\pagecontents\PAGE}}%
5105   }%
5106   \eject
5107   \endgroup % started in \begindoublecolumns
5108   %
5109   % \pagegoal was set to the doubled \vsize above, since we restarted
5110   % the current page.  We're now back to normal single-column
5111   % typesetting, so reset \pagegoal to the normal \vsize (after the
5112   % \endgroup where \vsize got restored).
5113   \pagegoal = \vsize
5114 }
5115 %
5116 % Called at the end of the double column material.
5117 \def\balancecolumns{%
5118   \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120.
5119   \dimen@ = \ht0
5120   \advance\dimen@ by \topskip
5121   \advance\dimen@ by-\baselineskip
5122   \divide\dimen@ by 2 % target to split to
5123   %debug\message{final 2-column material height=\the\ht0, target=\the\dimen@.}%
5124   \splittopskip = \topskip
5125   % Loop until we get a decent breakpoint.
5126   {%
5127     \vbadness = 10000
5128     \loop
5129       \global\setbox3 = \copy0
5130       \global\setbox1 = \vsplit3 to \dimen@
5131     \ifdim\ht3>\dimen@
5132       \global\advance\dimen@ by 1pt
5133     \repeat
5134   }%
5135   %debug\message{split to \the\dimen@, column heights: \the\ht1, \the\ht3.}%
5136   \setbox0=\vbox to\dimen@{\unvbox1}%
5137   \setbox2=\vbox to\dimen@{\unvbox3}%
5138   %
5139   \pagesofar
5140 }
5141 \catcode`\@ = \other
5142
5143
5144 \message{sectioning,}
5145 % Chapters, sections, etc.
5146
5147 % Let's start with @part.
5148 \outer\parseargdef\part{\partzzz{#1}}
5149 \def\partzzz#1{%
5150   \chapoddpage
5151   \null
5152   \vskip.3\vsize  % move it down on the page a bit
5153   \begingroup
5154     \noindent \titlefonts\rmisbold #1\par % the text
5155     \let\lastnode=\empty      % no node to associate with
5156     \writetocentry{part}{#1}{}% but put it in the toc
5157     \headingsoff              % no headline or footline on the part page
5158     \chapoddpage
5159   \endgroup
5160 }
5161
5162 % \unnumberedno is an oxymoron.  But we count the unnumbered
5163 % sections so that we can refer to them unambiguously in the pdf
5164 % outlines by their "section number".  We avoid collisions with chapter
5165 % numbers by starting them at 10000.  (If a document ever has 10000
5166 % chapters, we're in trouble anyway, I'm sure.)
5167 \newcount\unnumberedno \unnumberedno = 10000
5168 \newcount\chapno
5169 \newcount\secno        \secno=0
5170 \newcount\subsecno     \subsecno=0
5171 \newcount\subsubsecno  \subsubsecno=0
5172
5173 % This counter is funny since it counts through charcodes of letters A, B, ...
5174 \newcount\appendixno  \appendixno = `\@
5175 %
5176 % \def\appendixletter{\char\the\appendixno}
5177 % We do the following ugly conditional instead of the above simple
5178 % construct for the sake of pdftex, which needs the actual
5179 % letter in the expansion, not just typeset.
5180 %
5181 \def\appendixletter{%
5182   \ifnum\appendixno=`A A%
5183   \else\ifnum\appendixno=`B B%
5184   \else\ifnum\appendixno=`C C%
5185   \else\ifnum\appendixno=`D D%
5186   \else\ifnum\appendixno=`E E%
5187   \else\ifnum\appendixno=`F F%
5188   \else\ifnum\appendixno=`G G%
5189   \else\ifnum\appendixno=`H H%
5190   \else\ifnum\appendixno=`I I%
5191   \else\ifnum\appendixno=`J J%
5192   \else\ifnum\appendixno=`K K%
5193   \else\ifnum\appendixno=`L L%
5194   \else\ifnum\appendixno=`M M%
5195   \else\ifnum\appendixno=`N N%
5196   \else\ifnum\appendixno=`O O%
5197   \else\ifnum\appendixno=`P P%
5198   \else\ifnum\appendixno=`Q Q%
5199   \else\ifnum\appendixno=`R R%
5200   \else\ifnum\appendixno=`S S%
5201   \else\ifnum\appendixno=`T T%
5202   \else\ifnum\appendixno=`U U%
5203   \else\ifnum\appendixno=`V V%
5204   \else\ifnum\appendixno=`W W%
5205   \else\ifnum\appendixno=`X X%
5206   \else\ifnum\appendixno=`Y Y%
5207   \else\ifnum\appendixno=`Z Z%
5208   % The \the is necessary, despite appearances, because \appendixletter is
5209   % expanded while writing the .toc file.  \char\appendixno is not
5210   % expandable, thus it is written literally, thus all appendixes come out
5211   % with the same letter (or @) in the toc without it.
5212   \else\char\the\appendixno
5213   \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
5214   \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
5215
5216 % Each @chapter defines these (using marks) as the number+name, number
5217 % and name of the chapter.  Page headings and footings can use
5218 % these.  @section does likewise.
5219 \def\thischapter{}
5220 \def\thischapternum{}
5221 \def\thischaptername{}
5222 \def\thissection{}
5223 \def\thissectionnum{}
5224 \def\thissectionname{}
5225
5226 \newcount\absseclevel % used to calculate proper heading level
5227 \newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count
5228
5229 % @raisesections: treat @section as chapter, @subsection as section, etc.
5230 \def\raisesections{\global\advance\secbase by -1}
5231 \let\up=\raisesections % original BFox name
5232
5233 % @lowersections: treat @chapter as section, @section as subsection, etc.
5234 \def\lowersections{\global\advance\secbase by 1}
5235 \let\down=\lowersections % original BFox name
5236
5237 % we only have subsub.
5238 \chardef\maxseclevel = 3
5239 %
5240 % A numbered section within an unnumbered changes to unnumbered too.
5241 % To achieve this, remember the "biggest" unnum. sec. we are currently in:
5242 \chardef\unnlevel = \maxseclevel
5243 %
5244 % Trace whether the current chapter is an appendix or not:
5245 % \chapheadtype is "N" or "A", unnumbered chapters are ignored.
5246 \def\chapheadtype{N}
5247
5248 % Choose a heading macro
5249 % #1 is heading type
5250 % #2 is heading level
5251 % #3 is text for heading
5252 \def\genhead#1#2#3{%
5253   % Compute the abs. sec. level:
5254   \absseclevel=#2
5255   \advance\absseclevel by \secbase
5256   % Make sure \absseclevel doesn't fall outside the range:
5257   \ifnum \absseclevel < 0
5258     \absseclevel = 0
5259   \else
5260     \ifnum \absseclevel > 3
5261       \absseclevel = 3
5262     \fi
5263   \fi
5264   % The heading type:
5265   \def\headtype{#1}%
5266   \if \headtype U%
5267     \ifnum \absseclevel < \unnlevel
5268       \chardef\unnlevel = \absseclevel
5269     \fi
5270   \else
5271     % Check for appendix sections:
5272     \ifnum \absseclevel = 0
5273       \edef\chapheadtype{\headtype}%
5274     \else
5275       \if \headtype A\if \chapheadtype N%
5276         \errmessage{@appendix... within a non-appendix chapter}%
5277       \fi\fi
5278     \fi
5279     % Check for numbered within unnumbered:
5280     \ifnum \absseclevel > \unnlevel
5281       \def\headtype{U}%
5282     \else
5283       \chardef\unnlevel = 3
5284     \fi
5285   \fi
5286   % Now print the heading:
5287   \if \headtype U%
5288     \ifcase\absseclevel
5289         \unnumberedzzz{#3}%
5290     \or \unnumberedseczzz{#3}%
5291     \or \unnumberedsubseczzz{#3}%
5292     \or \unnumberedsubsubseczzz{#3}%
5293     \fi
5294   \else
5295     \if \headtype A%
5296       \ifcase\absseclevel
5297           \appendixzzz{#3}%
5298       \or \appendixsectionzzz{#3}%
5299       \or \appendixsubseczzz{#3}%
5300       \or \appendixsubsubseczzz{#3}%
5301       \fi
5302     \else
5303       \ifcase\absseclevel
5304           \chapterzzz{#3}%
5305       \or \seczzz{#3}%
5306       \or \numberedsubseczzz{#3}%
5307       \or \numberedsubsubseczzz{#3}%
5308       \fi
5309     \fi
5310   \fi
5311   \suppressfirstparagraphindent
5312 }
5313
5314 % an interface:
5315 \def\numhead{\genhead N}
5316 \def\apphead{\genhead A}
5317 \def\unnmhead{\genhead U}
5318
5319 % @chapter, @appendix, @unnumbered.  Increment top-level counter, reset
5320 % all lower-level sectioning counters to zero.
5321 %
5322 % Also set \chaplevelprefix, which we prepend to @float sequence numbers
5323 % (e.g., figures), q.v.  By default (before any chapter), that is empty.
5324 \let\chaplevelprefix = \empty
5325 %
5326 \outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz
5327 \def\chapterzzz#1{%
5328   % section resetting is \global in case the chapter is in a group, such
5329   % as an @include file.
5330   \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
5331     \global\advance\chapno by 1
5332   %
5333   % Used for \float.
5334   \gdef\chaplevelprefix{\the\chapno.}%
5335   \resetallfloatnos
5336   %
5337   % \putwordChapter can contain complex things in translations.
5338   \toks0=\expandafter{\putwordChapter}%
5339   \message{\the\toks0 \space \the\chapno}%
5340   %
5341   % Write the actual heading.
5342   \chapmacro{#1}{Ynumbered}{\the\chapno}%
5343   %
5344   % So @section and the like are numbered underneath this chapter.
5345   \global\let\section = \numberedsec
5346   \global\let\subsection = \numberedsubsec
5347   \global\let\subsubsection = \numberedsubsubsec
5348 }
5349
5350 \outer\parseargdef\appendix{\apphead0{#1}} % normally calls appendixzzz
5351 %
5352 \def\appendixzzz#1{%
5353   \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
5354     \global\advance\appendixno by 1
5355   \gdef\chaplevelprefix{\appendixletter.}%
5356   \resetallfloatnos
5357   %
5358   % \putwordAppendix can contain complex things in translations.
5359   \toks0=\expandafter{\putwordAppendix}%
5360   \message{\the\toks0 \space \appendixletter}%
5361   %
5362   \chapmacro{#1}{Yappendix}{\appendixletter}%
5363   %
5364   \global\let\section = \appendixsec
5365   \global\let\subsection = \appendixsubsec
5366   \global\let\subsubsection = \appendixsubsubsec
5367 }
5368
5369 % normally unnmhead0 calls unnumberedzzz:
5370 \outer\parseargdef\unnumbered{\unnmhead0{#1}}
5371 \def\unnumberedzzz#1{%
5372   \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
5373     \global\advance\unnumberedno by 1
5374   %
5375   % Since an unnumbered has no number, no prefix for figures.
5376   \global\let\chaplevelprefix = \empty
5377   \resetallfloatnos
5378   %
5379   % This used to be simply \message{#1}, but TeX fully expands the
5380   % argument to \message.  Therefore, if #1 contained @-commands, TeX
5381   % expanded them.  For example, in `@unnumbered The @cite{Book}', TeX
5382   % expanded @cite (which turns out to cause errors because \cite is meant
5383   % to be executed, not expanded).
5384   %
5385   % Anyway, we don't want the fully-expanded definition of @cite to appear
5386   % as a result of the \message, we just want `@cite' itself.  We use
5387   % \the<toks register> to achieve this: TeX expands \the<toks> only once,
5388   % simply yielding the contents of <toks register>.  (We also do this for
5389   % the toc entries.)
5390   \toks0 = {#1}%
5391   \message{(\the\toks0)}%
5392   %
5393   \chapmacro{#1}{Ynothing}{\the\unnumberedno}%
5394   %
5395   \global\let\section = \unnumberedsec
5396   \global\let\subsection = \unnumberedsubsec
5397   \global\let\subsubsection = \unnumberedsubsubsec
5398 }
5399
5400 % @centerchap is like @unnumbered, but the heading is centered.
5401 \outer\parseargdef\centerchap{%
5402   % Well, we could do the following in a group, but that would break
5403   % an assumption that \chapmacro is called at the outermost level.
5404   % Thus we are safer this way:         --kasal, 24feb04
5405   \let\centerparametersmaybe = \centerparameters
5406   \unnmhead0{#1}%
5407   \let\centerparametersmaybe = \relax
5408 }
5409
5410 % @top is like @unnumbered.
5411 \let\top\unnumbered
5412
5413 % Sections.
5414
5415 \outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
5416 \def\seczzz#1{%
5417   \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
5418   \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}%
5419 }
5420
5421 % normally calls appendixsectionzzz:
5422 \outer\parseargdef\appendixsection{\apphead1{#1}}
5423 \def\appendixsectionzzz#1{%
5424   \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
5425   \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}%
5426 }
5427 \let\appendixsec\appendixsection
5428
5429 % normally calls unnumberedseczzz:
5430 \outer\parseargdef\unnumberedsec{\unnmhead1{#1}}
5431 \def\unnumberedseczzz#1{%
5432   \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
5433   \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%
5434 }
5435
5436 % Subsections.
5437
5438 % normally calls numberedsubseczzz:
5439 \outer\parseargdef\numberedsubsec{\numhead2{#1}}
5440 \def\numberedsubseczzz#1{%
5441   \global\subsubsecno=0  \global\advance\subsecno by 1
5442   \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}%
5443 }
5444
5445 % normally calls appendixsubseczzz:
5446 \outer\parseargdef\appendixsubsec{\apphead2{#1}}
5447 \def\appendixsubseczzz#1{%
5448   \global\subsubsecno=0  \global\advance\subsecno by 1
5449   \sectionheading{#1}{subsec}{Yappendix}%
5450                  {\appendixletter.\the\secno.\the\subsecno}%
5451 }
5452
5453 % normally calls unnumberedsubseczzz:
5454 \outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}}
5455 \def\unnumberedsubseczzz#1{%
5456   \global\subsubsecno=0  \global\advance\subsecno by 1
5457   \sectionheading{#1}{subsec}{Ynothing}%
5458                  {\the\unnumberedno.\the\secno.\the\subsecno}%
5459 }
5460
5461 % Subsubsections.
5462
5463 % normally numberedsubsubseczzz:
5464 \outer\parseargdef\numberedsubsubsec{\numhead3{#1}}
5465 \def\numberedsubsubseczzz#1{%
5466   \global\advance\subsubsecno by 1
5467   \sectionheading{#1}{subsubsec}{Ynumbered}%
5468                  {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}%
5469 }
5470
5471 % normally appendixsubsubseczzz:
5472 \outer\parseargdef\appendixsubsubsec{\apphead3{#1}}
5473 \def\appendixsubsubseczzz#1{%
5474   \global\advance\subsubsecno by 1
5475   \sectionheading{#1}{subsubsec}{Yappendix}%
5476                  {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}%
5477 }
5478
5479 % normally unnumberedsubsubseczzz:
5480 \outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}}
5481 \def\unnumberedsubsubseczzz#1{%
5482   \global\advance\subsubsecno by 1
5483   \sectionheading{#1}{subsubsec}{Ynothing}%
5484                  {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}%
5485 }
5486
5487 % These macros control what the section commands do, according
5488 % to what kind of chapter we are in (ordinary, appendix, or unnumbered).
5489 % Define them by default for a numbered chapter.
5490 \let\section = \numberedsec
5491 \let\subsection = \numberedsubsec
5492 \let\subsubsection = \numberedsubsubsec
5493
5494 % Define @majorheading, @heading and @subheading
5495
5496 % NOTE on use of \vbox for chapter headings, section headings, and such:
5497 %       1) We use \vbox rather than the earlier \line to permit
5498 %          overlong headings to fold.
5499 %       2) \hyphenpenalty is set to 10000 because hyphenation in a
5500 %          heading is obnoxious; this forbids it.
5501 %       3) Likewise, headings look best if no \parindent is used, and
5502 %          if justification is not attempted.  Hence \raggedright.
5503
5504 \def\majorheading{%
5505   {\advance\chapheadingskip by 10pt \chapbreak }%
5506   \parsearg\chapheadingzzz
5507 }
5508
5509 \def\chapheading{\chapbreak \parsearg\chapheadingzzz}
5510 \def\chapheadingzzz#1{%
5511   {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
5512                     \parindent=0pt\ptexraggedright
5513                     \rmisbold #1\hfill}}%
5514   \bigskip \par\penalty 200\relax
5515   \suppressfirstparagraphindent
5516 }
5517
5518 % @heading, @subheading, @subsubheading.
5519 \parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{}
5520   \suppressfirstparagraphindent}
5521 \parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{}
5522   \suppressfirstparagraphindent}
5523 \parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{}
5524   \suppressfirstparagraphindent}
5525
5526 % These macros generate a chapter, section, etc. heading only
5527 % (including whitespace, linebreaking, etc. around it),
5528 % given all the information in convenient, parsed form.
5529
5530 % Args are the skip and penalty (usually negative)
5531 \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
5532
5533 % Parameter controlling skip before chapter headings (if needed)
5534 \newskip\chapheadingskip
5535
5536 % Define plain chapter starts, and page on/off switching for it.
5537 \def\chapbreak{\dobreak \chapheadingskip {-4000}}
5538 \def\chappager{\par\vfill\supereject}
5539 % Because \domark is called before \chapoddpage, the filler page will
5540 % get the headings for the next chapter, which is wrong.  But we don't
5541 % care -- we just disable all headings on the filler page.
5542 \def\chapoddpage{%
5543   \chappager
5544   \ifodd\pageno \else
5545     \begingroup
5546       \headingsoff
5547       \null
5548       \chappager
5549     \endgroup
5550   \fi
5551 }
5552
5553 \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
5554
5555 \def\CHAPPAGoff{%
5556 \global\let\contentsalignmacro = \chappager
5557 \global\let\pchapsepmacro=\chapbreak
5558 \global\let\pagealignmacro=\chappager}
5559
5560 \def\CHAPPAGon{%
5561 \global\let\contentsalignmacro = \chappager
5562 \global\let\pchapsepmacro=\chappager
5563 \global\let\pagealignmacro=\chappager
5564 \global\def\HEADINGSon{\HEADINGSsingle}}
5565
5566 \def\CHAPPAGodd{%
5567 \global\let\contentsalignmacro = \chapoddpage
5568 \global\let\pchapsepmacro=\chapoddpage
5569 \global\let\pagealignmacro=\chapoddpage
5570 \global\def\HEADINGSon{\HEADINGSdouble}}
5571
5572 \CHAPPAGon
5573
5574 % Chapter opening.
5575 %
5576 % #1 is the text, #2 is the section type (Ynumbered, Ynothing,
5577 % Yappendix, Yomitfromtoc), #3 the chapter number.
5578 %
5579 % To test against our argument.
5580 \def\Ynothingkeyword{Ynothing}
5581 \def\Yomitfromtockeyword{Yomitfromtoc}
5582 \def\Yappendixkeyword{Yappendix}
5583 %
5584 \def\chapmacro#1#2#3{%
5585   % Insert the first mark before the heading break (see notes for \domark).
5586   \let\prevchapterdefs=\lastchapterdefs
5587   \let\prevsectiondefs=\lastsectiondefs
5588   \gdef\lastsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}%
5589                         \gdef\thissection{}}%
5590   %
5591   \def\temptype{#2}%
5592   \ifx\temptype\Ynothingkeyword
5593     \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
5594                           \gdef\thischapter{\thischaptername}}%
5595   \else\ifx\temptype\Yomitfromtockeyword
5596     \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
5597                           \gdef\thischapter{}}%
5598   \else\ifx\temptype\Yappendixkeyword
5599     \toks0={#1}%
5600     \xdef\lastchapterdefs{%
5601       \gdef\noexpand\thischaptername{\the\toks0}%
5602       \gdef\noexpand\thischapternum{\appendixletter}%
5603       % \noexpand\putwordAppendix avoids expanding indigestible
5604       % commands in some of the translations.
5605       \gdef\noexpand\thischapter{\noexpand\putwordAppendix{}
5606                                  \noexpand\thischapternum:
5607                                  \noexpand\thischaptername}%
5608     }%
5609   \else
5610     \toks0={#1}%
5611     \xdef\lastchapterdefs{%
5612       \gdef\noexpand\thischaptername{\the\toks0}%
5613       \gdef\noexpand\thischapternum{\the\chapno}%
5614       % \noexpand\putwordChapter avoids expanding indigestible
5615       % commands in some of the translations.
5616       \gdef\noexpand\thischapter{\noexpand\putwordChapter{}
5617                                  \noexpand\thischapternum:
5618                                  \noexpand\thischaptername}%
5619     }%
5620   \fi\fi\fi
5621   %
5622   % Output the mark.  Pass it through \safewhatsit, to take care of
5623   % the preceding space.
5624   \safewhatsit\domark
5625   %
5626   % Insert the chapter heading break.
5627   \pchapsepmacro
5628   %
5629   % Now the second mark, after the heading break.  No break points
5630   % between here and the heading.
5631   \let\prevchapterdefs=\lastchapterdefs
5632   \let\prevsectiondefs=\lastsectiondefs
5633   \domark
5634   %
5635   {%
5636     \chapfonts \rmisbold
5637     %
5638     % Have to define \lastsection before calling \donoderef, because the
5639     % xref code eventually uses it.  On the other hand, it has to be called
5640     % after \pchapsepmacro, or the headline will change too soon.
5641     \gdef\lastsection{#1}%
5642     %
5643     % Only insert the separating space if we have a chapter/appendix
5644     % number, and don't print the unnumbered ``number''.
5645     \ifx\temptype\Ynothingkeyword
5646       \setbox0 = \hbox{}%
5647       \def\toctype{unnchap}%
5648     \else\ifx\temptype\Yomitfromtockeyword
5649       \setbox0 = \hbox{}% contents like unnumbered, but no toc entry
5650       \def\toctype{omit}%
5651     \else\ifx\temptype\Yappendixkeyword
5652       \setbox0 = \hbox{\putwordAppendix{} #3\enspace}%
5653       \def\toctype{app}%
5654     \else
5655       \setbox0 = \hbox{#3\enspace}%
5656       \def\toctype{numchap}%
5657     \fi\fi\fi
5658     %
5659     % Write the toc entry for this chapter.  Must come before the
5660     % \donoderef, because we include the current node name in the toc
5661     % entry, and \donoderef resets it to empty.
5662     \writetocentry{\toctype}{#1}{#3}%
5663     %
5664     % For pdftex, we have to write out the node definition (aka, make
5665     % the pdfdest) after any page break, but before the actual text has
5666     % been typeset.  If the destination for the pdf outline is after the
5667     % text, then jumping from the outline may wind up with the text not
5668     % being visible, for instance under high magnification.
5669     \donoderef{#2}%
5670     %
5671     % Typeset the actual heading.
5672     \nobreak % Avoid page breaks at the interline glue.
5673     \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright
5674           \hangindent=\wd0 \centerparametersmaybe
5675           \unhbox0 #1\par}%
5676   }%
5677   \nobreak\bigskip % no page break after a chapter title
5678   \nobreak
5679 }
5680
5681 % @centerchap -- centered and unnumbered.
5682 \let\centerparametersmaybe = \relax
5683 \def\centerparameters{%
5684   \advance\rightskip by 3\rightskip
5685   \leftskip = \rightskip
5686   \parfillskip = 0pt
5687 }
5688
5689
5690 % I don't think this chapter style is supported any more, so I'm not
5691 % updating it with the new noderef stuff.  We'll see.  --karl, 11aug03.
5692 %
5693 \def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
5694 %
5695 \def\unnchfopen #1{%
5696 \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
5697                        \parindent=0pt\ptexraggedright
5698                        \rmisbold #1\hfill}}\bigskip \par\nobreak
5699 }
5700 \def\chfopen #1#2{\chapoddpage {\chapfonts
5701 \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
5702 \par\penalty 5000 %
5703 }
5704 \def\centerchfopen #1{%
5705 \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
5706                        \parindent=0pt
5707                        \hfill {\rmisbold #1}\hfill}}\bigskip \par\nobreak
5708 }
5709 \def\CHAPFopen{%
5710   \global\let\chapmacro=\chfopen
5711   \global\let\centerchapmacro=\centerchfopen}
5712
5713
5714 % Section titles.  These macros combine the section number parts and
5715 % call the generic \sectionheading to do the printing.
5716 %
5717 \newskip\secheadingskip
5718 \def\secheadingbreak{\dobreak \secheadingskip{-1000}}
5719
5720 % Subsection titles.
5721 \newskip\subsecheadingskip
5722 \def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}}
5723
5724 % Subsubsection titles.
5725 \def\subsubsecheadingskip{\subsecheadingskip}
5726 \def\subsubsecheadingbreak{\subsecheadingbreak}
5727
5728
5729 % Print any size, any type, section title.
5730 %
5731 % #1 is the text, #2 is the section level (sec/subsec/subsubsec), #3 is
5732 % the section type for xrefs (Ynumbered, Ynothing, Yappendix), #4 is the
5733 % section number.
5734 %
5735 \def\seckeyword{sec}
5736 %
5737 \def\sectionheading#1#2#3#4{%
5738   {%
5739     \checkenv{}% should not be in an environment.
5740     %
5741     % Switch to the right set of fonts.
5742     \csname #2fonts\endcsname \rmisbold
5743     %
5744     \def\sectionlevel{#2}%
5745     \def\temptype{#3}%
5746     %
5747     % Insert first mark before the heading break (see notes for \domark).
5748     \let\prevsectiondefs=\lastsectiondefs
5749     \ifx\temptype\Ynothingkeyword
5750       \ifx\sectionlevel\seckeyword
5751         \gdef\lastsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}%
5752                               \gdef\thissection{\thissectionname}}%
5753       \fi
5754     \else\ifx\temptype\Yomitfromtockeyword
5755       % Don't redefine \thissection.
5756     \else\ifx\temptype\Yappendixkeyword
5757       \ifx\sectionlevel\seckeyword
5758         \toks0={#1}%
5759         \xdef\lastsectiondefs{%
5760           \gdef\noexpand\thissectionname{\the\toks0}%
5761           \gdef\noexpand\thissectionnum{#4}%
5762           % \noexpand\putwordSection avoids expanding indigestible
5763           % commands in some of the translations.
5764           \gdef\noexpand\thissection{\noexpand\putwordSection{}
5765                                      \noexpand\thissectionnum:
5766                                      \noexpand\thissectionname}%
5767         }%
5768       \fi
5769     \else
5770       \ifx\sectionlevel\seckeyword
5771         \toks0={#1}%
5772         \xdef\lastsectiondefs{%
5773           \gdef\noexpand\thissectionname{\the\toks0}%
5774           \gdef\noexpand\thissectionnum{#4}%
5775           % \noexpand\putwordSection avoids expanding indigestible
5776           % commands in some of the translations.
5777           \gdef\noexpand\thissection{\noexpand\putwordSection{}
5778                                      \noexpand\thissectionnum:
5779                                      \noexpand\thissectionname}%
5780         }%
5781       \fi
5782     \fi\fi\fi
5783     %
5784     % Go into vertical mode.  Usually we'll already be there, but we
5785     % don't want the following whatsit to end up in a preceding paragraph
5786     % if the document didn't happen to have a blank line.
5787     \par
5788     %
5789     % Output the mark.  Pass it through \safewhatsit, to take care of
5790     % the preceding space.
5791     \safewhatsit\domark
5792     %
5793     % Insert space above the heading.
5794     \csname #2headingbreak\endcsname
5795     %
5796     % Now the second mark, after the heading break.  No break points
5797     % between here and the heading.
5798     \let\prevsectiondefs=\lastsectiondefs
5799     \domark
5800     %
5801     % Only insert the space after the number if we have a section number.
5802     \ifx\temptype\Ynothingkeyword
5803       \setbox0 = \hbox{}%
5804       \def\toctype{unn}%
5805       \gdef\lastsection{#1}%
5806     \else\ifx\temptype\Yomitfromtockeyword
5807       % for @headings -- no section number, don't include in toc,
5808       % and don't redefine \lastsection.
5809       \setbox0 = \hbox{}%
5810       \def\toctype{omit}%
5811       \let\sectionlevel=\empty
5812     \else\ifx\temptype\Yappendixkeyword
5813       \setbox0 = \hbox{#4\enspace}%
5814       \def\toctype{app}%
5815       \gdef\lastsection{#1}%
5816     \else
5817       \setbox0 = \hbox{#4\enspace}%
5818       \def\toctype{num}%
5819       \gdef\lastsection{#1}%
5820     \fi\fi\fi
5821     %
5822     % Write the toc entry (before \donoderef).  See comments in \chapmacro.
5823     \writetocentry{\toctype\sectionlevel}{#1}{#4}%
5824     %
5825     % Write the node reference (= pdf destination for pdftex).
5826     % Again, see comments in \chapmacro.
5827     \donoderef{#3}%
5828     %
5829     % Interline glue will be inserted when the vbox is completed.
5830     % That glue will be a valid breakpoint for the page, since it'll be
5831     % preceded by a whatsit (usually from the \donoderef, or from the
5832     % \writetocentry if there was no node).  We don't want to allow that
5833     % break, since then the whatsits could end up on page n while the
5834     % section is on page n+1, thus toc/etc. are wrong.  Debian bug 276000.
5835     \nobreak
5836     %
5837     % Output the actual section heading.
5838     \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright
5839           \hangindent=\wd0  % zero if no section number
5840           \unhbox0 #1}%
5841   }%
5842   % Add extra space after the heading -- half of whatever came above it.
5843   % Don't allow stretch, though.
5844   \kern .5 \csname #2headingskip\endcsname
5845   %
5846   % Do not let the kern be a potential breakpoint, as it would be if it
5847   % was followed by glue.
5848   \nobreak
5849   %
5850   % We'll almost certainly start a paragraph next, so don't let that
5851   % glue accumulate.  (Not a breakpoint because it's preceded by a
5852   % discardable item.)
5853   \vskip-\parskip
5854   %
5855   % This is purely so the last item on the list is a known \penalty >
5856   % 10000.  This is so \startdefun can avoid allowing breakpoints after
5857   % section headings.  Otherwise, it would insert a valid breakpoint between:
5858   %   @section sec-whatever
5859   %   @deffn def-whatever
5860   \penalty 10001
5861 }
5862
5863
5864 \message{toc,}
5865 % Table of contents.
5866 \newwrite\tocfile
5867
5868 % Write an entry to the toc file, opening it if necessary.
5869 % Called from @chapter, etc.
5870 %
5871 % Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno}
5872 % We append the current node name (if any) and page number as additional
5873 % arguments for the \{chap,sec,...}entry macros which will eventually
5874 % read this.  The node name is used in the pdf outlines as the
5875 % destination to jump to.
5876 %
5877 % We open the .toc file for writing here instead of at @setfilename (or
5878 % any other fixed time) so that @contents can be anywhere in the document.
5879 % But if #1 is `omit', then we don't do anything.  This is used for the
5880 % table of contents chapter openings themselves.
5881 %
5882 \newif\iftocfileopened
5883 \def\omitkeyword{omit}%
5884 %
5885 \def\writetocentry#1#2#3{%
5886   \edef\writetoctype{#1}%
5887   \ifx\writetoctype\omitkeyword \else
5888     \iftocfileopened\else
5889       \immediate\openout\tocfile = \jobname.toc
5890       \global\tocfileopenedtrue
5891     \fi
5892     %
5893     \iflinks
5894       {\atdummies
5895        \edef\temp{%
5896          \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}%
5897        \temp
5898       }%
5899     \fi
5900   \fi
5901   %
5902   % Tell \shipout to create a pdf destination on each page, if we're
5903   % writing pdf.  These are used in the table of contents.  We can't
5904   % just write one on every page because the title pages are numbered
5905   % 1 and 2 (the page numbers aren't printed), and so are the first
5906   % two pages of the document.  Thus, we'd have two destinations named
5907   % `1', and two named `2'.
5908   \ifpdf \global\pdfmakepagedesttrue \fi
5909 }
5910
5911
5912 % These characters do not print properly in the Computer Modern roman
5913 % fonts, so we must take special care.  This is more or less redundant
5914 % with the Texinfo input format setup at the end of this file.
5915 %
5916 \def\activecatcodes{%
5917   \catcode`\"=\active
5918   \catcode`\$=\active
5919   \catcode`\<=\active
5920   \catcode`\>=\active
5921   \catcode`\\=\active
5922   \catcode`\^=\active
5923   \catcode`\_=\active
5924   \catcode`\|=\active
5925   \catcode`\~=\active
5926 }
5927
5928
5929 % Read the toc file, which is essentially Texinfo input.
5930 \def\readtocfile{%
5931   \setupdatafile
5932   \activecatcodes
5933   \input \tocreadfilename
5934 }
5935
5936 \newskip\contentsrightmargin \contentsrightmargin=1in
5937 \newcount\savepageno
5938 \newcount\lastnegativepageno \lastnegativepageno = -1
5939
5940 % Prepare to read what we've written to \tocfile.
5941 %
5942 \def\startcontents#1{%
5943   % If @setchapternewpage on, and @headings double, the contents should
5944   % start on an odd page, unlike chapters.  Thus, we maintain
5945   % \contentsalignmacro in parallel with \pagealignmacro.
5946   % From: Torbjorn Granlund <tege@matematik.su.se>
5947   \contentsalignmacro
5948   \immediate\closeout\tocfile
5949   %
5950   % Don't need to put `Contents' or `Short Contents' in the headline.
5951   % It is abundantly clear what they are.
5952   \chapmacro{#1}{Yomitfromtoc}{}%
5953   %
5954   \savepageno = \pageno
5955   \begingroup                  % Set up to handle contents files properly.
5956     \raggedbottom              % Worry more about breakpoints than the bottom.
5957     \advance\hsize by -\contentsrightmargin % Don't use the full line length.
5958     %
5959     % Roman numerals for page numbers.
5960     \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
5961 }
5962
5963 % redefined for the two-volume lispref.  We always output on
5964 % \jobname.toc even if this is redefined.
5965 %
5966 \def\tocreadfilename{\jobname.toc}
5967
5968 % Normal (long) toc.
5969 %
5970 \def\contents{%
5971   \startcontents{\putwordTOC}%
5972     \openin 1 \tocreadfilename\space
5973     \ifeof 1 \else
5974       \readtocfile
5975     \fi
5976     \vfill \eject
5977     \contentsalignmacro % in case @setchapternewpage odd is in effect
5978     \ifeof 1 \else
5979       \pdfmakeoutlines
5980     \fi
5981     \closein 1
5982   \endgroup
5983   \lastnegativepageno = \pageno
5984   \global\pageno = \savepageno
5985 }
5986
5987 % And just the chapters.
5988 \def\summarycontents{%
5989   \startcontents{\putwordShortTOC}%
5990     %
5991     \let\partentry = \shortpartentry
5992     \let\numchapentry = \shortchapentry
5993     \let\appentry = \shortchapentry
5994     \let\unnchapentry = \shortunnchapentry
5995     % We want a true roman here for the page numbers.
5996     \secfonts
5997     \let\rm=\shortcontrm \let\bf=\shortcontbf
5998     \let\sl=\shortcontsl \let\tt=\shortconttt
5999     \rm
6000     \hyphenpenalty = 10000
6001     \advance\baselineskip by 1pt % Open it up a little.
6002     \def\numsecentry##1##2##3##4{}
6003     \let\appsecentry = \numsecentry
6004     \let\unnsecentry = \numsecentry
6005     \let\numsubsecentry = \numsecentry
6006     \let\appsubsecentry = \numsecentry
6007     \let\unnsubsecentry = \numsecentry
6008     \let\numsubsubsecentry = \numsecentry
6009     \let\appsubsubsecentry = \numsecentry
6010     \let\unnsubsubsecentry = \numsecentry
6011     \openin 1 \tocreadfilename\space
6012     \ifeof 1 \else
6013       \readtocfile
6014     \fi
6015     \closein 1
6016     \vfill \eject
6017     \contentsalignmacro % in case @setchapternewpage odd is in effect
6018   \endgroup
6019   \lastnegativepageno = \pageno
6020   \global\pageno = \savepageno
6021 }
6022 \let\shortcontents = \summarycontents
6023
6024 % Typeset the label for a chapter or appendix for the short contents.
6025 % The arg is, e.g., `A' for an appendix, or `3' for a chapter.
6026 %
6027 \def\shortchaplabel#1{%
6028   % This space should be enough, since a single number is .5em, and the
6029   % widest letter (M) is 1em, at least in the Computer Modern fonts.
6030   % But use \hss just in case.
6031   % (This space doesn't include the extra space that gets added after
6032   % the label; that gets put in by \shortchapentry above.)
6033   %
6034   % We'd like to right-justify chapter numbers, but that looks strange
6035   % with appendix letters.  And right-justifying numbers and
6036   % left-justifying letters looks strange when there is less than 10
6037   % chapters.  Have to read the whole toc once to know how many chapters
6038   % there are before deciding ...
6039   \hbox to 1em{#1\hss}%
6040 }
6041
6042 % These macros generate individual entries in the table of contents.
6043 % The first argument is the chapter or section name.
6044 % The last argument is the page number.
6045 % The arguments in between are the chapter number, section number, ...
6046
6047 % Parts, in the main contents.  Replace the part number, which doesn't
6048 % exist, with an empty box.  Let's hope all the numbers have the same width.
6049 % Also ignore the page number, which is conventionally not printed.
6050 \def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}}
6051 \def\partentry#1#2#3#4{\dochapentry{\numeralbox\labelspace#1}{}}
6052 %
6053 % Parts, in the short toc.
6054 \def\shortpartentry#1#2#3#4{%
6055   \penalty-300
6056   \vskip.5\baselineskip plus.15\baselineskip minus.1\baselineskip
6057   \shortchapentry{{\bf #1}}{\numeralbox}{}{}%
6058 }
6059
6060 % Chapters, in the main contents.
6061 \def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}}
6062 %
6063 % Chapters, in the short toc.
6064 % See comments in \dochapentry re vbox and related settings.
6065 \def\shortchapentry#1#2#3#4{%
6066   \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}%
6067 }
6068
6069 % Appendices, in the main contents.
6070 % Need the word Appendix, and a fixed-size box.
6071 %
6072 \def\appendixbox#1{%
6073   % We use M since it's probably the widest letter.
6074   \setbox0 = \hbox{\putwordAppendix{} M}%
6075   \hbox to \wd0{\putwordAppendix{} #1\hss}}
6076 %
6077 \def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\labelspace#1}{#4}}
6078
6079 % Unnumbered chapters.
6080 \def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}}
6081 \def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}}
6082
6083 % Sections.
6084 \def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}}
6085 \let\appsecentry=\numsecentry
6086 \def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}}
6087
6088 % Subsections.
6089 \def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}}
6090 \let\appsubsecentry=\numsubsecentry
6091 \def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}}
6092
6093 % And subsubsections.
6094 \def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}}
6095 \let\appsubsubsecentry=\numsubsubsecentry
6096 \def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}}
6097
6098 % This parameter controls the indentation of the various levels.
6099 % Same as \defaultparindent.
6100 \newdimen\tocindent \tocindent = 15pt
6101
6102 % Now for the actual typesetting. In all these, #1 is the text and #2 is the
6103 % page number.
6104 %
6105 % If the toc has to be broken over pages, we want it to be at chapters
6106 % if at all possible; hence the \penalty.
6107 \def\dochapentry#1#2{%
6108    \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
6109    \begingroup
6110      \chapentryfonts
6111      \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6112    \endgroup
6113    \nobreak\vskip .25\baselineskip plus.1\baselineskip
6114 }
6115
6116 \def\dosecentry#1#2{\begingroup
6117   \secentryfonts \leftskip=\tocindent
6118   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6119 \endgroup}
6120
6121 \def\dosubsecentry#1#2{\begingroup
6122   \subsecentryfonts \leftskip=2\tocindent
6123   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6124 \endgroup}
6125
6126 \def\dosubsubsecentry#1#2{\begingroup
6127   \subsubsecentryfonts \leftskip=3\tocindent
6128   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6129 \endgroup}
6130
6131 % We use the same \entry macro as for the index entries.
6132 \let\tocentry = \entry
6133
6134 % Space between chapter (or whatever) number and the title.
6135 \def\labelspace{\hskip1em \relax}
6136
6137 \def\dopageno#1{{\rm #1}}
6138 \def\doshortpageno#1{{\rm #1}}
6139
6140 \def\chapentryfonts{\secfonts \rm}
6141 \def\secentryfonts{\textfonts}
6142 \def\subsecentryfonts{\textfonts}
6143 \def\subsubsecentryfonts{\textfonts}
6144
6145
6146 \message{environments,}
6147 % @foo ... @end foo.
6148
6149 % @tex ... @end tex    escapes into raw TeX temporarily.
6150 % One exception: @ is still an escape character, so that @end tex works.
6151 % But \@ or @@ will get a plain @ character.
6152
6153 \envdef\tex{%
6154   \setupmarkupstyle{tex}%
6155   \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
6156   \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
6157   \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
6158   \catcode `\%=14
6159   \catcode `\+=\other
6160   \catcode `\"=\other
6161   \catcode `\|=\other
6162   \catcode `\<=\other
6163   \catcode `\>=\other
6164   \catcode`\`=\other
6165   \catcode`\'=\other
6166   \escapechar=`\\
6167   %
6168   % ' is active in math mode (mathcode"8000).  So reset it, and all our
6169   % other math active characters (just in case), to plain's definitions.
6170   \mathactive
6171   %
6172   \let\b=\ptexb
6173   \let\bullet=\ptexbullet
6174   \let\c=\ptexc
6175   \let\,=\ptexcomma
6176   \let\.=\ptexdot
6177   \let\dots=\ptexdots
6178   \let\equiv=\ptexequiv
6179   \let\!=\ptexexclam
6180   \let\i=\ptexi
6181   \let\indent=\ptexindent
6182   \let\noindent=\ptexnoindent
6183   \let\{=\ptexlbrace
6184   \let\+=\tabalign
6185   \let\}=\ptexrbrace
6186   \let\/=\ptexslash
6187   \let\*=\ptexstar
6188   \let\t=\ptext
6189   \expandafter \let\csname top\endcsname=\ptextop  % outer
6190   \let\frenchspacing=\plainfrenchspacing
6191   %
6192   \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
6193   \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
6194   \def\@{@}%
6195 }
6196 % There is no need to define \Etex.
6197
6198 % Define @lisp ... @end lisp.
6199 % @lisp environment forms a group so it can rebind things,
6200 % including the definition of @end lisp (which normally is erroneous).
6201
6202 % Amount to narrow the margins by for @lisp.
6203 \newskip\lispnarrowing \lispnarrowing=0.4in
6204
6205 % This is the definition that ^^M gets inside @lisp, @example, and other
6206 % such environments.  \null is better than a space, since it doesn't
6207 % have any width.
6208 \def\lisppar{\null\endgraf}
6209
6210 % This space is always present above and below environments.
6211 \newskip\envskipamount \envskipamount = 0pt
6212
6213 % Make spacing and below environment symmetrical.  We use \parskip here
6214 % to help in doing that, since in @example-like environments \parskip
6215 % is reset to zero; thus the \afterenvbreak inserts no space -- but the
6216 % start of the next paragraph will insert \parskip.
6217 %
6218 \def\aboveenvbreak{{%
6219   % =10000 instead of <10000 because of a special case in \itemzzz and
6220   % \sectionheading, q.v.
6221   \ifnum \lastpenalty=10000 \else
6222     \advance\envskipamount by \parskip
6223     \endgraf
6224     \ifdim\lastskip<\envskipamount
6225       \removelastskip
6226       % it's not a good place to break if the last penalty was \nobreak
6227       % or better ...
6228       \ifnum\lastpenalty<10000 \penalty-50 \fi
6229       \vskip\envskipamount
6230     \fi
6231   \fi
6232 }}
6233
6234 \let\afterenvbreak = \aboveenvbreak
6235
6236 % \nonarrowing is a flag.  If "set", @lisp etc don't narrow margins; it will
6237 % also clear it, so that its embedded environments do the narrowing again.
6238 \let\nonarrowing=\relax
6239
6240 % @cartouche ... @end cartouche: draw rectangle w/rounded corners around
6241 % environment contents.
6242 \font\circle=lcircle10
6243 \newdimen\circthick
6244 \newdimen\cartouter\newdimen\cartinner
6245 \newskip\normbskip\newskip\normpskip\newskip\normlskip
6246 \circthick=\fontdimen8\circle
6247 %
6248 \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
6249 \def\ctr{{\hskip 6pt\circle\char'010}}
6250 \def\cbl{{\circle\char'012\hskip -6pt}}
6251 \def\cbr{{\hskip 6pt\circle\char'011}}
6252 \def\carttop{\hbox to \cartouter{\hskip\lskip
6253         \ctl\leaders\hrule height\circthick\hfil\ctr
6254         \hskip\rskip}}
6255 \def\cartbot{\hbox to \cartouter{\hskip\lskip
6256         \cbl\leaders\hrule height\circthick\hfil\cbr
6257         \hskip\rskip}}
6258 %
6259 \newskip\lskip\newskip\rskip
6260
6261 \envdef\cartouche{%
6262   \ifhmode\par\fi  % can't be in the midst of a paragraph.
6263   \startsavinginserts
6264   \lskip=\leftskip \rskip=\rightskip
6265   \leftskip=0pt\rightskip=0pt % we want these *outside*.
6266   \cartinner=\hsize \advance\cartinner by-\lskip
6267   \advance\cartinner by-\rskip
6268   \cartouter=\hsize
6269   \advance\cartouter by 18.4pt  % allow for 3pt kerns on either
6270                                 % side, and for 6pt waste from
6271                                 % each corner char, and rule thickness
6272   \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
6273   % Flag to tell @lisp, etc., not to narrow margin.
6274   \let\nonarrowing = t%
6275   %
6276   % If this cartouche directly follows a sectioning command, we need the
6277   % \parskip glue (backspaced over by default) or the cartouche can
6278   % collide with the section heading.
6279   \ifnum\lastpenalty>10000 \vskip\parskip \fi
6280   %
6281   \vbox\bgroup
6282       \baselineskip=0pt\parskip=0pt\lineskip=0pt
6283       \carttop
6284       \hbox\bgroup
6285           \hskip\lskip
6286           \vrule\kern3pt
6287           \vbox\bgroup
6288               \kern3pt
6289               \hsize=\cartinner
6290               \baselineskip=\normbskip
6291               \lineskip=\normlskip
6292               \parskip=\normpskip
6293               \vskip -\parskip
6294               \comment % For explanation, see the end of def\group.
6295 }
6296 \def\Ecartouche{%
6297               \ifhmode\par\fi
6298               \kern3pt
6299           \egroup
6300           \kern3pt\vrule
6301           \hskip\rskip
6302       \egroup
6303       \cartbot
6304   \egroup
6305   \checkinserts
6306 }
6307
6308
6309 % This macro is called at the beginning of all the @example variants,
6310 % inside a group.
6311 \newdimen\nonfillparindent
6312 \def\nonfillstart{%
6313   \aboveenvbreak
6314   \hfuzz = 12pt % Don't be fussy
6315   \sepspaces % Make spaces be word-separators rather than space tokens.
6316   \let\par = \lisppar % don't ignore blank lines
6317   \obeylines % each line of input is a line of output
6318   \parskip = 0pt
6319   % Turn off paragraph indentation but redefine \indent to emulate
6320   % the normal \indent.
6321   \nonfillparindent=\parindent
6322   \parindent = 0pt
6323   \let\indent\nonfillindent
6324   %
6325   \emergencystretch = 0pt % don't try to avoid overfull boxes
6326   \ifx\nonarrowing\relax
6327     \advance \leftskip by \lispnarrowing
6328     \exdentamount=\lispnarrowing
6329   \else
6330     \let\nonarrowing = \relax
6331   \fi
6332   \let\exdent=\nofillexdent
6333 }
6334
6335 \begingroup
6336 \obeyspaces
6337 % We want to swallow spaces (but not other tokens) after the fake
6338 % @indent in our nonfill-environments, where spaces are normally
6339 % active and set to @tie, resulting in them not being ignored after
6340 % @indent.
6341 \gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}%
6342 \gdef\nonfillindentcheck{%
6343 \ifx\temp %
6344 \expandafter\nonfillindentgobble%
6345 \else%
6346 \leavevmode\nonfillindentbox%
6347 \fi%
6348 }%
6349 \endgroup
6350 \def\nonfillindentgobble#1{\nonfillindent}
6351 \def\nonfillindentbox{\hbox to \nonfillparindent{\hss}}
6352
6353 % If you want all examples etc. small: @set dispenvsize small.
6354 % If you want even small examples the full size: @set dispenvsize nosmall.
6355 % This affects the following displayed environments:
6356 %    @example, @display, @format, @lisp
6357 %
6358 \def\smallword{small}
6359 \def\nosmallword{nosmall}
6360 \let\SETdispenvsize\relax
6361 \def\setnormaldispenv{%
6362   \ifx\SETdispenvsize\smallword
6363     % end paragraph for sake of leading, in case document has no blank
6364     % line.  This is redundant with what happens in \aboveenvbreak, but
6365     % we need to do it before changing the fonts, and it's inconvenient
6366     % to change the fonts afterward.
6367     \ifnum \lastpenalty=10000 \else \endgraf \fi
6368     \smallexamplefonts \rm
6369   \fi
6370 }
6371 \def\setsmalldispenv{%
6372   \ifx\SETdispenvsize\nosmallword
6373   \else
6374     \ifnum \lastpenalty=10000 \else \endgraf \fi
6375     \smallexamplefonts \rm
6376   \fi
6377 }
6378
6379 % We often define two environments, @foo and @smallfoo.
6380 % Let's do it in one command.  #1 is the env name, #2 the definition.
6381 \def\makedispenvdef#1#2{%
6382   \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}%
6383   \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}%
6384   \expandafter\let\csname E#1\endcsname \afterenvbreak
6385   \expandafter\let\csname Esmall#1\endcsname \afterenvbreak
6386 }
6387
6388 % Define two environment synonyms (#1 and #2) for an environment.
6389 \def\maketwodispenvdef#1#2#3{%
6390   \makedispenvdef{#1}{#3}%
6391   \makedispenvdef{#2}{#3}%
6392 }
6393 %
6394 % @lisp: indented, narrowed, typewriter font;
6395 % @example: same as @lisp.
6396 %
6397 % @smallexample and @smalllisp: use smaller fonts.
6398 % Originally contributed by Pavel@xerox.
6399 %
6400 \maketwodispenvdef{lisp}{example}{%
6401   \nonfillstart
6402   \tt\setupmarkupstyle{example}%
6403   \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
6404   \gobble % eat return
6405 }
6406 % @display/@smalldisplay: same as @lisp except keep current font.
6407 %
6408 \makedispenvdef{display}{%
6409   \nonfillstart
6410   \gobble
6411 }
6412
6413 % @format/@smallformat: same as @display except don't narrow margins.
6414 %
6415 \makedispenvdef{format}{%
6416   \let\nonarrowing = t%
6417   \nonfillstart
6418   \gobble
6419 }
6420
6421 % @flushleft: same as @format, but doesn't obey \SETdispenvsize.
6422 \envdef\flushleft{%
6423   \let\nonarrowing = t%
6424   \nonfillstart
6425   \gobble
6426 }
6427 \let\Eflushleft = \afterenvbreak
6428
6429 % @flushright.
6430 %
6431 \envdef\flushright{%
6432   \let\nonarrowing = t%
6433   \nonfillstart
6434   \advance\leftskip by 0pt plus 1fill\relax
6435   \gobble
6436 }
6437 \let\Eflushright = \afterenvbreak
6438
6439
6440 % @raggedright does more-or-less normal line breaking but no right
6441 % justification.  From plain.tex.
6442 \envdef\raggedright{%
6443   \rightskip0pt plus2em \spaceskip.3333em \xspaceskip.5em\relax
6444 }
6445 \let\Eraggedright\par
6446
6447 \envdef\raggedleft{%
6448   \parindent=0pt \leftskip0pt plus2em
6449   \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
6450   \hbadness=10000 % Last line will usually be underfull, so turn off
6451                   % badness reporting.
6452 }
6453 \let\Eraggedleft\par
6454
6455 \envdef\raggedcenter{%
6456   \parindent=0pt \rightskip0pt plus1em \leftskip0pt plus1em
6457   \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
6458   \hbadness=10000 % Last line will usually be underfull, so turn off
6459                   % badness reporting.
6460 }
6461 \let\Eraggedcenter\par
6462
6463
6464 % @quotation does normal linebreaking (hence we can't use \nonfillstart)
6465 % and narrows the margins.  We keep \parskip nonzero in general, since
6466 % we're doing normal filling.  So, when using \aboveenvbreak and
6467 % \afterenvbreak, temporarily make \parskip 0.
6468 %
6469 \makedispenvdef{quotation}{\quotationstart}
6470 %
6471 \def\quotationstart{%
6472   {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
6473   \parindent=0pt
6474   %
6475   % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
6476   \ifx\nonarrowing\relax
6477     \advance\leftskip by \lispnarrowing
6478     \advance\rightskip by \lispnarrowing
6479     \exdentamount = \lispnarrowing
6480   \else
6481     \let\nonarrowing = \relax
6482   \fi
6483   \parsearg\quotationlabel
6484 }
6485
6486 % We have retained a nonzero parskip for the environment, since we're
6487 % doing normal filling.
6488 %
6489 \def\Equotation{%
6490   \par
6491   \ifx\quotationauthor\thisisundefined\else
6492     % indent a bit.
6493     \leftline{\kern 2\leftskip \sl ---\quotationauthor}%
6494   \fi
6495   {\parskip=0pt \afterenvbreak}%
6496 }
6497 \def\Esmallquotation{\Equotation}
6498
6499 % If we're given an argument, typeset it in bold with a colon after.
6500 \def\quotationlabel#1{%
6501   \def\temp{#1}%
6502   \ifx\temp\empty \else
6503     {\bf #1: }%
6504   \fi
6505 }
6506
6507
6508 % LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>}
6509 % If we want to allow any <char> as delimiter,
6510 % we need the curly braces so that makeinfo sees the @verb command, eg:
6511 % `@verbx...x' would look like the '@verbx' command.  --janneke@gnu.org
6512 %
6513 % [Knuth]: Donald Ervin Knuth, 1996.  The TeXbook.
6514 %
6515 % [Knuth] p.344; only we need to do the other characters Texinfo sets
6516 % active too.  Otherwise, they get lost as the first character on a
6517 % verbatim line.
6518 \def\dospecials{%
6519   \do\ \do\\\do\{\do\}\do\$\do\&%
6520   \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~%
6521   \do\<\do\>\do\|\do\@\do+\do\"%
6522   % Don't do the quotes -- if we do, @set txicodequoteundirected and
6523   % @set txicodequotebacktick will not have effect on @verb and
6524   % @verbatim, and ?` and !` ligatures won't get disabled.
6525   %\do\`\do\'%
6526 }
6527 %
6528 % [Knuth] p. 380
6529 \def\uncatcodespecials{%
6530   \def\do##1{\catcode`##1=\other}\dospecials}
6531 %
6532 % Setup for the @verb command.
6533 %
6534 % Eight spaces for a tab
6535 \begingroup
6536   \catcode`\^^I=\active
6537   \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }}
6538 \endgroup
6539 %
6540 \def\setupverb{%
6541   \tt  % easiest (and conventionally used) font for verbatim
6542   \def\par{\leavevmode\endgraf}%
6543   \setupmarkupstyle{verb}%
6544   \tabeightspaces
6545   % Respect line breaks,
6546   % print special symbols as themselves, and
6547   % make each space count
6548   % must do in this order:
6549   \obeylines \uncatcodespecials \sepspaces
6550 }
6551
6552 % Setup for the @verbatim environment
6553 %
6554 % Real tab expansion.
6555 \newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
6556 %
6557 % We typeset each line of the verbatim in an \hbox, so we can handle
6558 % tabs.  The \global is in case the verbatim line starts with an accent,
6559 % or some other command that starts with a begin-group.  Otherwise, the
6560 % entire \verbbox would disappear at the corresponding end-group, before
6561 % it is typeset.  Meanwhile, we can't have nested verbatim commands
6562 % (can we?), so the \global won't be overwriting itself.
6563 \newbox\verbbox
6564 \def\starttabbox{\global\setbox\verbbox=\hbox\bgroup}
6565 %
6566 \begingroup
6567   \catcode`\^^I=\active
6568   \gdef\tabexpand{%
6569     \catcode`\^^I=\active
6570     \def^^I{\leavevmode\egroup
6571       \dimen\verbbox=\wd\verbbox % the width so far, or since the previous tab
6572       \divide\dimen\verbbox by\tabw
6573       \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw
6574       \advance\dimen\verbbox by\tabw  % advance to next multiple of \tabw
6575       \wd\verbbox=\dimen\verbbox \box\verbbox \starttabbox
6576     }%
6577   }
6578 \endgroup
6579
6580 % start the verbatim environment.
6581 \def\setupverbatim{%
6582   \let\nonarrowing = t%
6583   \nonfillstart
6584   \tt % easiest (and conventionally used) font for verbatim
6585   % The \leavevmode here is for blank lines.  Otherwise, we would
6586   % never \starttabox and the \egroup would end verbatim mode.
6587   \def\par{\leavevmode\egroup\box\verbbox\endgraf}%
6588   \tabexpand
6589   \setupmarkupstyle{verbatim}%
6590   % Respect line breaks,
6591   % print special symbols as themselves, and
6592   % make each space count.
6593   % Must do in this order:
6594   \obeylines \uncatcodespecials \sepspaces
6595   \everypar{\starttabbox}%
6596 }
6597
6598 % Do the @verb magic: verbatim text is quoted by unique
6599 % delimiter characters.  Before first delimiter expect a
6600 % right brace, after last delimiter expect closing brace:
6601 %
6602 %    \def\doverb'{'<char>#1<char>'}'{#1}
6603 %
6604 % [Knuth] p. 382; only eat outer {}
6605 \begingroup
6606   \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other
6607   \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next]
6608 \endgroup
6609 %
6610 \def\verb{\begingroup\setupverb\doverb}
6611 %
6612 %
6613 % Do the @verbatim magic: define the macro \doverbatim so that
6614 % the (first) argument ends when '@end verbatim' is reached, ie:
6615 %
6616 %     \def\doverbatim#1@end verbatim{#1}
6617 %
6618 % For Texinfo it's a lot easier than for LaTeX,
6619 % because texinfo's \verbatim doesn't stop at '\end{verbatim}':
6620 % we need not redefine '\', '{' and '}'.
6621 %
6622 % Inspired by LaTeX's verbatim command set [latex.ltx]
6623 %
6624 \begingroup
6625   \catcode`\ =\active
6626   \obeylines %
6627   % ignore everything up to the first ^^M, that's the newline at the end
6628   % of the @verbatim input line itself.  Otherwise we get an extra blank
6629   % line in the output.
6630   \xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}%
6631   % We really want {...\end verbatim} in the body of the macro, but
6632   % without the active space; thus we have to use \xdef and \gobble.
6633 \endgroup
6634 %
6635 \envdef\verbatim{%
6636     \setupverbatim\doverbatim
6637 }
6638 \let\Everbatim = \afterenvbreak
6639
6640
6641 % @verbatiminclude FILE - insert text of file in verbatim environment.
6642 %
6643 \def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude}
6644 %
6645 \def\doverbatiminclude#1{%
6646   {%
6647     \makevalueexpandable
6648     \setupverbatim
6649     \indexnofonts       % Allow `@@' and other weird things in file names.
6650     \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}%
6651     \input #1
6652     \afterenvbreak
6653   }%
6654 }
6655
6656 % @copying ... @end copying.
6657 % Save the text away for @insertcopying later.
6658 %
6659 % We save the uninterpreted tokens, rather than creating a box.
6660 % Saving the text in a box would be much easier, but then all the
6661 % typesetting commands (@smallbook, font changes, etc.) have to be done
6662 % beforehand -- and a) we want @copying to be done first in the source
6663 % file; b) letting users define the frontmatter in as flexible order as
6664 % possible is very desirable.
6665 %
6666 \def\copying{\checkenv{}\begingroup\scanargctxt\docopying}
6667 \def\docopying#1@end copying{\endgroup\def\copyingtext{#1}}
6668 %
6669 \def\insertcopying{%
6670   \begingroup
6671     \parindent = 0pt  % paragraph indentation looks wrong on title page
6672     \scanexp\copyingtext
6673   \endgroup
6674 }
6675
6676
6677 \message{defuns,}
6678 % @defun etc.
6679
6680 \newskip\defbodyindent \defbodyindent=.4in
6681 \newskip\defargsindent \defargsindent=50pt
6682 \newskip\deflastargmargin \deflastargmargin=18pt
6683 \newcount\defunpenalty
6684
6685 % Start the processing of @deffn:
6686 \def\startdefun{%
6687   \ifnum\lastpenalty<10000
6688     \medbreak
6689     \defunpenalty=10003 % Will keep this @deffn together with the
6690                         % following @def command, see below.
6691   \else
6692     % If there are two @def commands in a row, we'll have a \nobreak,
6693     % which is there to keep the function description together with its
6694     % header.  But if there's nothing but headers, we need to allow a
6695     % break somewhere.  Check specifically for penalty 10002, inserted
6696     % by \printdefunline, instead of 10000, since the sectioning
6697     % commands also insert a nobreak penalty, and we don't want to allow
6698     % a break between a section heading and a defun.
6699     %
6700     % As a further refinement, we avoid "club" headers by signalling
6701     % with penalty of 10003 after the very first @deffn in the
6702     % sequence (see above), and penalty of 10002 after any following
6703     % @def command.
6704     \ifnum\lastpenalty=10002 \penalty2000 \else \defunpenalty=10002 \fi
6705     %
6706     % Similarly, after a section heading, do not allow a break.
6707     % But do insert the glue.
6708     \medskip  % preceded by discardable penalty, so not a breakpoint
6709   \fi
6710   %
6711   \parindent=0in
6712   \advance\leftskip by \defbodyindent
6713   \exdentamount=\defbodyindent
6714 }
6715
6716 \def\dodefunx#1{%
6717   % First, check whether we are in the right environment:
6718   \checkenv#1%
6719   %
6720   % As above, allow line break if we have multiple x headers in a row.
6721   % It's not a great place, though.
6722   \ifnum\lastpenalty=10002 \penalty3000 \else \defunpenalty=10002 \fi
6723   %
6724   % And now, it's time to reuse the body of the original defun:
6725   \expandafter\gobbledefun#1%
6726 }
6727 \def\gobbledefun#1\startdefun{}
6728
6729 % \printdefunline \deffnheader{text}
6730 %
6731 \def\printdefunline#1#2{%
6732   \begingroup
6733     % call \deffnheader:
6734     #1#2 \endheader
6735     % common ending:
6736     \interlinepenalty = 10000
6737     \advance\rightskip by 0pt plus 1fil\relax
6738     \endgraf
6739     \nobreak\vskip -\parskip
6740     \penalty\defunpenalty  % signal to \startdefun and \dodefunx
6741     % Some of the @defun-type tags do not enable magic parentheses,
6742     % rendering the following check redundant.  But we don't optimize.
6743     \checkparencounts
6744   \endgroup
6745 }
6746
6747 \def\Edefun{\endgraf\medbreak}
6748
6749 % \makedefun{deffn} creates \deffn, \deffnx and \Edeffn;
6750 % the only thing remaining is to define \deffnheader.
6751 %
6752 \def\makedefun#1{%
6753   \expandafter\let\csname E#1\endcsname = \Edefun
6754   \edef\temp{\noexpand\domakedefun
6755     \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}%
6756   \temp
6757 }
6758
6759 % \domakedefun \deffn \deffnx \deffnheader
6760 %
6761 % Define \deffn and \deffnx, without parameters.
6762 % \deffnheader has to be defined explicitly.
6763 %
6764 \def\domakedefun#1#2#3{%
6765   \envdef#1{%
6766     \startdefun
6767     \doingtypefnfalse    % distinguish typed functions from all else
6768     \parseargusing\activeparens{\printdefunline#3}%
6769   }%
6770   \def#2{\dodefunx#1}%
6771   \def#3%
6772 }
6773
6774 \newif\ifdoingtypefn       % doing typed function?
6775 \newif\ifrettypeownline    % typeset return type on its own line?
6776
6777 % @deftypefnnewline on|off says whether the return type of typed functions
6778 % are printed on their own line.  This affects @deftypefn, @deftypefun,
6779 % @deftypeop, and @deftypemethod.
6780
6781 \parseargdef\deftypefnnewline{%
6782   \def\temp{#1}%
6783   \ifx\temp\onword
6784     \expandafter\let\csname SETtxideftypefnnl\endcsname
6785       = \empty
6786   \else\ifx\temp\offword
6787     \expandafter\let\csname SETtxideftypefnnl\endcsname
6788       = \relax
6789   \else
6790     \errhelp = \EMsimple
6791     \errmessage{Unknown @txideftypefnnl value `\temp',
6792                 must be on|off}%
6793   \fi\fi
6794 }
6795
6796 % Untyped functions:
6797
6798 % @deffn category name args
6799 \makedefun{deffn}{\deffngeneral{}}
6800
6801 % @deffn category class name args
6802 \makedefun{defop}#1 {\defopon{#1\ \putwordon}}
6803
6804 % \defopon {category on}class name args
6805 \def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
6806
6807 % \deffngeneral {subind}category name args
6808 %
6809 \def\deffngeneral#1#2 #3 #4\endheader{%
6810   % Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}.
6811   \dosubind{fn}{\code{#3}}{#1}%
6812   \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
6813 }
6814
6815 % Typed functions:
6816
6817 % @deftypefn category type name args
6818 \makedefun{deftypefn}{\deftypefngeneral{}}
6819
6820 % @deftypeop category class type name args
6821 \makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}}
6822
6823 % \deftypeopon {category on}class type name args
6824 \def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
6825
6826 % \deftypefngeneral {subind}category type name args
6827 %
6828 \def\deftypefngeneral#1#2 #3 #4 #5\endheader{%
6829   \dosubind{fn}{\code{#4}}{#1}%
6830   \doingtypefntrue
6831   \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
6832 }
6833
6834 % Typed variables:
6835
6836 % @deftypevr category type var args
6837 \makedefun{deftypevr}{\deftypecvgeneral{}}
6838
6839 % @deftypecv category class type var args
6840 \makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}}
6841
6842 % \deftypecvof {category of}class type var args
6843 \def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} }
6844
6845 % \deftypecvgeneral {subind}category type var args
6846 %
6847 \def\deftypecvgeneral#1#2 #3 #4 #5\endheader{%
6848   \dosubind{vr}{\code{#4}}{#1}%
6849   \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
6850 }
6851
6852 % Untyped variables:
6853
6854 % @defvr category var args
6855 \makedefun{defvr}#1 {\deftypevrheader{#1} {} }
6856
6857 % @defcv category class var args
6858 \makedefun{defcv}#1 {\defcvof{#1\ \putwordof}}
6859
6860 % \defcvof {category of}class var args
6861 \def\defcvof#1#2 {\deftypecvof{#1}#2 {} }
6862
6863 % Types:
6864
6865 % @deftp category name args
6866 \makedefun{deftp}#1 #2 #3\endheader{%
6867   \doind{tp}{\code{#2}}%
6868   \defname{#1}{}{#2}\defunargs{#3\unskip}%
6869 }
6870
6871 % Remaining @defun-like shortcuts:
6872 \makedefun{defun}{\deffnheader{\putwordDeffunc} }
6873 \makedefun{defmac}{\deffnheader{\putwordDefmac} }
6874 \makedefun{defspec}{\deffnheader{\putwordDefspec} }
6875 \makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} }
6876 \makedefun{defvar}{\defvrheader{\putwordDefvar} }
6877 \makedefun{defopt}{\defvrheader{\putwordDefopt} }
6878 \makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} }
6879 \makedefun{defmethod}{\defopon\putwordMethodon}
6880 \makedefun{deftypemethod}{\deftypeopon\putwordMethodon}
6881 \makedefun{defivar}{\defcvof\putwordInstanceVariableof}
6882 \makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof}
6883
6884 % \defname, which formats the name of the @def (not the args).
6885 % #1 is the category, such as "Function".
6886 % #2 is the return type, if any.
6887 % #3 is the function name.
6888 %
6889 % We are followed by (but not passed) the arguments, if any.
6890 %
6891 \def\defname#1#2#3{%
6892   \par
6893   % Get the values of \leftskip and \rightskip as they were outside the @def...
6894   \advance\leftskip by -\defbodyindent
6895   %
6896   % Determine if we are typesetting the return type of a typed function
6897   % on a line by itself.
6898   \rettypeownlinefalse
6899   \ifdoingtypefn  % doing a typed function specifically?
6900     % then check user option for putting return type on its own line:
6901     \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else
6902       \rettypeownlinetrue
6903     \fi
6904   \fi
6905   %
6906   % How we'll format the category name.  Putting it in brackets helps
6907   % distinguish it from the body text that may end up on the next line
6908   % just below it.
6909   \def\temp{#1}%
6910   \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
6911   %
6912   % Figure out line sizes for the paragraph shape.  We'll always have at
6913   % least two.
6914   \tempnum = 2
6915   %
6916   % The first line needs space for \box0; but if \rightskip is nonzero,
6917   % we need only space for the part of \box0 which exceeds it:
6918   \dimen0=\hsize  \advance\dimen0 by -\wd0  \advance\dimen0 by \rightskip
6919   %
6920   % If doing a return type on its own line, we'll have another line.
6921   \ifrettypeownline
6922     \advance\tempnum by 1
6923     \def\maybeshapeline{0in \hsize}%
6924   \else
6925     \def\maybeshapeline{}%
6926   \fi
6927   %
6928   % The continuations:
6929   \dimen2=\hsize  \advance\dimen2 by -\defargsindent
6930   %
6931   % The final paragraph shape:
6932   \parshape \tempnum  0in \dimen0  \maybeshapeline  \defargsindent \dimen2
6933   %
6934   % Put the category name at the right margin.
6935   \noindent
6936   \hbox to 0pt{%
6937     \hfil\box0 \kern-\hsize
6938     % \hsize has to be shortened this way:
6939     \kern\leftskip
6940     % Intentionally do not respect \rightskip, since we need the space.
6941   }%
6942   %
6943   % Allow all lines to be underfull without complaint:
6944   \tolerance=10000 \hbadness=10000
6945   \exdentamount=\defbodyindent
6946   {%
6947     % defun fonts. We use typewriter by default (used to be bold) because:
6948     % . we're printing identifiers, they should be in tt in principle.
6949     % . in languages with many accents, such as Czech or French, it's
6950     %   common to leave accents off identifiers.  The result looks ok in
6951     %   tt, but exceedingly strange in rm.
6952     % . we don't want -- and --- to be treated as ligatures.
6953     % . this still does not fix the ?` and !` ligatures, but so far no
6954     %   one has made identifiers using them :).
6955     \df \tt
6956     \def\temp{#2}% text of the return type
6957     \ifx\temp\empty\else
6958       \tclose{\temp}% typeset the return type
6959       \ifrettypeownline
6960         % put return type on its own line; prohibit line break following:
6961         \hfil\vadjust{\nobreak}\break  
6962       \else
6963         \space  % type on same line, so just followed by a space
6964       \fi
6965     \fi           % no return type
6966     #3% output function name
6967   }%
6968   {\rm\enskip}% hskip 0.5 em of \tenrm
6969   %
6970   \boldbrax
6971   % arguments will be output next, if any.
6972 }
6973
6974 % Print arguments in slanted roman (not ttsl), inconsistently with using
6975 % tt for the name.  This is because literal text is sometimes needed in
6976 % the argument list (groff manual), and ttsl and tt are not very
6977 % distinguishable.  Prevent hyphenation at `-' chars.
6978 %
6979 \def\defunargs#1{%
6980   % use sl by default (not ttsl),
6981   % tt for the names.
6982   \df \sl \hyphenchar\font=0
6983   %
6984   % On the other hand, if an argument has two dashes (for instance), we
6985   % want a way to get ttsl.  Let's try @var for that.
6986   \def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}%
6987   #1%
6988   \sl\hyphenchar\font=45
6989 }
6990
6991 % We want ()&[] to print specially on the defun line.
6992 %
6993 \def\activeparens{%
6994   \catcode`\(=\active \catcode`\)=\active
6995   \catcode`\[=\active \catcode`\]=\active
6996   \catcode`\&=\active
6997 }
6998
6999 % Make control sequences which act like normal parenthesis chars.
7000 \let\lparen = ( \let\rparen = )
7001
7002 % Be sure that we always have a definition for `(', etc.  For example,
7003 % if the fn name has parens in it, \boldbrax will not be in effect yet,
7004 % so TeX would otherwise complain about undefined control sequence.
7005 {
7006   \activeparens
7007   \global\let(=\lparen \global\let)=\rparen
7008   \global\let[=\lbrack \global\let]=\rbrack
7009   \global\let& = \&
7010
7011   \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
7012   \gdef\magicamp{\let&=\amprm}
7013 }
7014
7015 \newcount\parencount
7016
7017 % If we encounter &foo, then turn on ()-hacking afterwards
7018 \newif\ifampseen
7019 \def\amprm#1 {\ampseentrue{\bf\&#1 }}
7020
7021 \def\parenfont{%
7022   \ifampseen
7023     % At the first level, print parens in roman,
7024     % otherwise use the default font.
7025     \ifnum \parencount=1 \rm \fi
7026   \else
7027     % The \sf parens (in \boldbrax) actually are a little bolder than
7028     % the contained text.  This is especially needed for [ and ] .
7029     \sf
7030   \fi
7031 }
7032 \def\infirstlevel#1{%
7033   \ifampseen
7034     \ifnum\parencount=1
7035       #1%
7036     \fi
7037   \fi
7038 }
7039 \def\bfafterword#1 {#1 \bf}
7040
7041 \def\opnr{%
7042   \global\advance\parencount by 1
7043   {\parenfont(}%
7044   \infirstlevel \bfafterword
7045 }
7046 \def\clnr{%
7047   {\parenfont)}%
7048   \infirstlevel \sl
7049   \global\advance\parencount by -1
7050 }
7051
7052 \newcount\brackcount
7053 \def\lbrb{%
7054   \global\advance\brackcount by 1
7055   {\bf[}%
7056 }
7057 \def\rbrb{%
7058   {\bf]}%
7059   \global\advance\brackcount by -1
7060 }
7061
7062 \def\checkparencounts{%
7063   \ifnum\parencount=0 \else \badparencount \fi
7064   \ifnum\brackcount=0 \else \badbrackcount \fi
7065 }
7066 % these should not use \errmessage; the glibc manual, at least, actually
7067 % has such constructs (when documenting function pointers).
7068 \def\badparencount{%
7069   \message{Warning: unbalanced parentheses in @def...}%
7070   \global\parencount=0
7071 }
7072 \def\badbrackcount{%
7073   \message{Warning: unbalanced square brackets in @def...}%
7074   \global\brackcount=0
7075 }
7076
7077
7078 \message{macros,}
7079 % @macro.
7080
7081 % To do this right we need a feature of e-TeX, \scantokens,
7082 % which we arrange to emulate with a temporary file in ordinary TeX.
7083 \ifx\eTeXversion\thisisundefined
7084   \newwrite\macscribble
7085   \def\scantokens#1{%
7086     \toks0={#1}%
7087     \immediate\openout\macscribble=\jobname.tmp
7088     \immediate\write\macscribble{\the\toks0}%
7089     \immediate\closeout\macscribble
7090     \input \jobname.tmp
7091   }
7092 \fi
7093
7094 \def\scanmacro#1{\begingroup
7095   \newlinechar`\^^M
7096   \let\xeatspaces\eatspaces
7097   %
7098   % Undo catcode changes of \startcontents and \doprintindex
7099   % When called from @insertcopying or (short)caption, we need active
7100   % backslash to get it printed correctly.  Previously, we had
7101   % \catcode`\\=\other instead.  We'll see whether a problem appears
7102   % with macro expansion.                               --kasal, 19aug04
7103   \catcode`\@=0 \catcode`\\=\active \escapechar=`\@
7104   %
7105   % ... and for \example:
7106   \spaceisspace
7107   %
7108   % The \empty here causes a following catcode 5 newline to be eaten as
7109   % part of reading whitespace after a control sequence.  It does not
7110   % eat a catcode 13 newline.  There's no good way to handle the two
7111   % cases (untried: maybe e-TeX's \everyeof could help, though plain TeX
7112   % would then have different behavior).  See the Macro Details node in
7113   % the manual for the workaround we recommend for macros and
7114   % line-oriented commands.
7115   % 
7116   \scantokens{#1\empty}%
7117 \endgroup}
7118
7119 \def\scanexp#1{%
7120   \edef\temp{\noexpand\scanmacro{#1}}%
7121   \temp
7122 }
7123
7124 \newcount\paramno   % Count of parameters
7125 \newtoks\macname    % Macro name
7126 \newif\ifrecursive  % Is it recursive?
7127
7128 % List of all defined macros in the form
7129 %    \definedummyword\macro1\definedummyword\macro2...
7130 % Currently is also contains all @aliases; the list can be split
7131 % if there is a need.
7132 \def\macrolist{}
7133
7134 % Add the macro to \macrolist
7135 \def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname}
7136 \def\addtomacrolistxxx#1{%
7137      \toks0 = \expandafter{\macrolist\definedummyword#1}%
7138      \xdef\macrolist{\the\toks0}%
7139 }
7140
7141 % Utility routines.
7142 % This does \let #1 = #2, with \csnames; that is,
7143 %   \let \csname#1\endcsname = \csname#2\endcsname
7144 % (except of course we have to play expansion games).
7145 %
7146 \def\cslet#1#2{%
7147   \expandafter\let
7148   \csname#1\expandafter\endcsname
7149   \csname#2\endcsname
7150 }
7151
7152 % Trim leading and trailing spaces off a string.
7153 % Concepts from aro-bend problem 15 (see CTAN).
7154 {\catcode`\@=11
7155 \gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }}
7156 \gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@}
7157 \gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @}
7158 \def\unbrace#1{#1}
7159 \unbrace{\gdef\trim@@@ #1 } #2@{#1}
7160 }
7161
7162 % Trim a single trailing ^^M off a string.
7163 {\catcode`\^^M=\other \catcode`\Q=3%
7164 \gdef\eatcr #1{\eatcra #1Q^^MQ}%
7165 \gdef\eatcra#1^^MQ{\eatcrb#1Q}%
7166 \gdef\eatcrb#1Q#2Q{#1}%
7167 }
7168
7169 % Macro bodies are absorbed as an argument in a context where
7170 % all characters are catcode 10, 11 or 12, except \ which is active
7171 % (as in normal texinfo). It is necessary to change the definition of \
7172 % to recognize macro arguments; this is the job of \mbodybackslash.
7173 %
7174 % Non-ASCII encodings make 8-bit characters active, so un-activate
7175 % them to avoid their expansion.  Must do this non-globally, to
7176 % confine the change to the current group.
7177 %
7178 % It's necessary to have hard CRs when the macro is executed. This is
7179 % done by making ^^M (\endlinechar) catcode 12 when reading the macro
7180 % body, and then making it the \newlinechar in \scanmacro.
7181 %
7182 \def\scanctxt{% used as subroutine
7183   \catcode`\"=\other
7184   \catcode`\+=\other
7185   \catcode`\<=\other
7186   \catcode`\>=\other
7187   \catcode`\@=\other
7188   \catcode`\^=\other
7189   \catcode`\_=\other
7190   \catcode`\|=\other
7191   \catcode`\~=\other
7192   \ifx\declaredencoding\ascii \else \setnonasciicharscatcodenonglobal\other \fi
7193 }
7194
7195 \def\scanargctxt{% used for copying and captions, not macros.
7196   \scanctxt
7197   \catcode`\\=\other
7198   \catcode`\^^M=\other
7199 }
7200
7201 \def\macrobodyctxt{% used for @macro definitions
7202   \scanctxt
7203   \catcode`\{=\other
7204   \catcode`\}=\other
7205   \catcode`\^^M=\other
7206   \usembodybackslash
7207 }
7208
7209 \def\macroargctxt{% used when scanning invocations
7210   \scanctxt
7211   \catcode`\\=0
7212 }
7213 % why catcode 0 for \ in the above?  To recognize \\ \{ \} as "escapes"
7214 % for the single characters \ { }.  Thus, we end up with the "commands"
7215 % that would be written @\ @{ @} in a Texinfo document.
7216
7217 % We already have @{ and @}.  For @\, we define it here, and only for
7218 % this purpose, to produce a typewriter backslash (so, the @\ that we
7219 % define for @math can't be used with @macro calls):
7220 %
7221 \def\\{\normalbackslash}%
7222
7223 % We would like to do this for \, too, since that is what makeinfo does.
7224 % But it is not possible, because Texinfo already has a command @, for a
7225 % cedilla accent.  Documents must use @comma{} instead.
7226 %
7227 % \anythingelse will almost certainly be an error of some kind.
7228
7229
7230 % \mbodybackslash is the definition of \ in @macro bodies.
7231 % It maps \foo\ => \csname macarg.foo\endcsname => #N
7232 % where N is the macro parameter number.
7233 % We define \csname macarg.\endcsname to be \realbackslash, so
7234 % \\ in macro replacement text gets you a backslash.
7235 %
7236 {\catcode`@=0 @catcode`@\=@active
7237  @gdef@usembodybackslash{@let\=@mbodybackslash}
7238  @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname}
7239 }
7240 \expandafter\def\csname macarg.\endcsname{\realbackslash}
7241
7242 \def\margbackslash#1{\char`\#1 }
7243
7244 \def\macro{\recursivefalse\parsearg\macroxxx}
7245 \def\rmacro{\recursivetrue\parsearg\macroxxx}
7246
7247 \def\macroxxx#1{%
7248   \getargs{#1}% now \macname is the macname and \argl the arglist
7249   \ifx\argl\empty       % no arguments
7250      \paramno=0
7251   \else
7252      \expandafter\parsemargdef \argl;%
7253   \fi
7254   \if1\csname ismacro.\the\macname\endcsname
7255      \message{Warning: redefining \the\macname}%
7256   \else
7257      \expandafter\ifx\csname \the\macname\endcsname \relax
7258      \else \errmessage{Macro name \the\macname\space already defined}\fi
7259      \global\cslet{macsave.\the\macname}{\the\macname}%
7260      \global\expandafter\let\csname ismacro.\the\macname\endcsname=1%
7261      \addtomacrolist{\the\macname}%
7262   \fi
7263   \begingroup \macrobodyctxt
7264   \ifrecursive \expandafter\parsermacbody
7265   \else \expandafter\parsemacbody
7266   \fi}
7267
7268 \parseargdef\unmacro{%
7269   \if1\csname ismacro.#1\endcsname
7270     \global\cslet{#1}{macsave.#1}%
7271     \global\expandafter\let \csname ismacro.#1\endcsname=0%
7272     % Remove the macro name from \macrolist:
7273     \begingroup
7274       \expandafter\let\csname#1\endcsname \relax
7275       \let\definedummyword\unmacrodo
7276       \xdef\macrolist{\macrolist}%
7277     \endgroup
7278   \else
7279     \errmessage{Macro #1 not defined}%
7280   \fi
7281 }
7282
7283 % Called by \do from \dounmacro on each macro.  The idea is to omit any
7284 % macro definitions that have been changed to \relax.
7285 %
7286 \def\unmacrodo#1{%
7287   \ifx #1\relax
7288     % remove this
7289   \else
7290     \noexpand\definedummyword \noexpand#1%
7291   \fi
7292 }
7293
7294 % This makes use of the obscure feature that if the last token of a
7295 % <parameter list> is #, then the preceding argument is delimited by
7296 % an opening brace, and that opening brace is not consumed.
7297 \def\getargs#1{\getargsxxx#1{}}
7298 \def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
7299 \def\getmacname#1 #2\relax{\macname={#1}}
7300 \def\getmacargs#1{\def\argl{#1}}
7301
7302 % Parse the optional {params} list.  Set up \paramno and \paramlist
7303 % so \defmacro knows what to do.  Define \macarg.blah for each blah
7304 % in the params list to be ##N where N is the position in that list.
7305 % That gets used by \mbodybackslash (above).
7306 %
7307 % We need to get `macro parameter char #' into several definitions.
7308 % The technique used is stolen from LaTeX: let \hash be something
7309 % unexpandable, insert that wherever you need a #, and then redefine
7310 % it to # just before using the token list produced.
7311 %
7312 % The same technique is used to protect \eatspaces till just before
7313 % the macro is used.
7314
7315 \def\parsemargdef#1;{%
7316   \paramno=0\def\paramlist{}%
7317   \let\hash\relax
7318   \let\xeatspaces\relax
7319   \parsemargdefxxx#1,;,%
7320 }
7321 \def\parsemargdefxxx#1,{%
7322   \if#1;\let\next=\relax
7323   \else \let\next=\parsemargdefxxx
7324     \advance\paramno by 1
7325     \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
7326         {\xeatspaces{\hash\the\paramno}}%
7327     \edef\paramlist{\paramlist\hash\the\paramno,}%
7328   \fi\next}
7329
7330 % These two commands read recursive and nonrecursive macro bodies.
7331 % (They're different since rec and nonrec macros end differently.)
7332 %
7333 \long\def\parsemacbody#1@end macro%
7334 {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
7335 \long\def\parsermacbody#1@end rmacro%
7336 {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
7337
7338 % This defines the macro itself. There are six cases: recursive and
7339 % nonrecursive macros of zero, one, and many arguments.
7340 % Much magic with \expandafter here.
7341 % \xdef is used so that macro definitions will survive the file
7342 % they're defined in; @include reads the file inside a group.
7343 %
7344 \def\defmacro{%
7345   \let\hash=##% convert placeholders to macro parameter chars
7346   \ifrecursive
7347     \ifcase\paramno
7348     % 0
7349       \expandafter\xdef\csname\the\macname\endcsname{%
7350         \noexpand\scanmacro{\temp}}%
7351     \or % 1
7352       \expandafter\xdef\csname\the\macname\endcsname{%
7353          \bgroup\noexpand\macroargctxt
7354          \noexpand\braceorline
7355          \expandafter\noexpand\csname\the\macname xxx\endcsname}%
7356       \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
7357          \egroup\noexpand\scanmacro{\temp}}%
7358     \else % many
7359       \expandafter\xdef\csname\the\macname\endcsname{%
7360          \bgroup\noexpand\macroargctxt
7361          \noexpand\csname\the\macname xx\endcsname}%
7362       \expandafter\xdef\csname\the\macname xx\endcsname##1{%
7363           \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
7364       \expandafter\expandafter
7365       \expandafter\xdef
7366       \expandafter\expandafter
7367         \csname\the\macname xxx\endcsname
7368           \paramlist{\egroup\noexpand\scanmacro{\temp}}%
7369     \fi
7370   \else
7371     \ifcase\paramno
7372     % 0
7373       \expandafter\xdef\csname\the\macname\endcsname{%
7374         \noexpand\norecurse{\the\macname}%
7375         \noexpand\scanmacro{\temp}\egroup}%
7376     \or % 1
7377       \expandafter\xdef\csname\the\macname\endcsname{%
7378          \bgroup\noexpand\macroargctxt
7379          \noexpand\braceorline
7380          \expandafter\noexpand\csname\the\macname xxx\endcsname}%
7381       \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
7382         \egroup
7383         \noexpand\norecurse{\the\macname}%
7384         \noexpand\scanmacro{\temp}\egroup}%
7385     \else % many
7386       \expandafter\xdef\csname\the\macname\endcsname{%
7387          \bgroup\noexpand\macroargctxt
7388          \expandafter\noexpand\csname\the\macname xx\endcsname}%
7389       \expandafter\xdef\csname\the\macname xx\endcsname##1{%
7390           \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
7391       \expandafter\expandafter
7392       \expandafter\xdef
7393       \expandafter\expandafter
7394       \csname\the\macname xxx\endcsname
7395       \paramlist{%
7396           \egroup
7397           \noexpand\norecurse{\the\macname}%
7398           \noexpand\scanmacro{\temp}\egroup}%
7399     \fi
7400   \fi}
7401
7402 \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
7403
7404 % \braceorline decides whether the next nonwhitespace character is a
7405 % {.  If so it reads up to the closing }, if not, it reads the whole
7406 % line.  Whatever was read is then fed to the next control sequence
7407 % as an argument (by \parsebrace or \parsearg).
7408
7409 \def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx}
7410 \def\braceorlinexxx{%
7411   \ifx\nchar\bgroup\else
7412     \expandafter\parsearg
7413   \fi \macnamexxx}
7414
7415
7416 % @alias.
7417 % We need some trickery to remove the optional spaces around the equal
7418 % sign.  Make them active and then expand them all to nothing.
7419 %
7420 \def\alias{\parseargusing\obeyspaces\aliasxxx}
7421 \def\aliasxxx #1{\aliasyyy#1\relax}
7422 \def\aliasyyy #1=#2\relax{%
7423   {%
7424     \expandafter\let\obeyedspace=\empty
7425     \addtomacrolist{#1}%
7426     \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}%
7427   }%
7428   \next
7429 }
7430
7431
7432 \message{cross references,}
7433
7434 \newwrite\auxfile
7435 \newif\ifhavexrefs    % True if xref values are known.
7436 \newif\ifwarnedxrefs  % True if we warned once that they aren't known.
7437
7438 % @inforef is relatively simple.
7439 \def\inforef #1{\inforefzzz #1,,,,**}
7440 \def\inforefzzz #1,#2,#3,#4**{%
7441   \putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
7442   node \samp{\ignorespaces#1{}}}
7443
7444 % @node's only job in TeX is to define \lastnode, which is used in
7445 % cross-references.  The @node line might or might not have commas, and
7446 % might or might not have spaces before the first comma, like:
7447 % @node foo , bar , ...
7448 % We don't want such trailing spaces in the node name.
7449 %
7450 \parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse}
7451 %
7452 % also remove a trailing comma, in case of something like this:
7453 % @node Help-Cross,  ,  , Cross-refs
7454 \def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse}
7455 \def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}}
7456
7457 \let\nwnode=\node
7458 \let\lastnode=\empty
7459
7460 % Write a cross-reference definition for the current node.  #1 is the
7461 % type (Ynumbered, Yappendix, Ynothing).
7462 %
7463 \def\donoderef#1{%
7464   \ifx\lastnode\empty\else
7465     \setref{\lastnode}{#1}%
7466     \global\let\lastnode=\empty
7467   \fi
7468 }
7469
7470 % @anchor{NAME} -- define xref target at arbitrary point.
7471 %
7472 \newcount\savesfregister
7473 %
7474 \def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi}
7475 \def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi}
7476 \def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces}
7477
7478 % \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an
7479 % anchor), which consists of three parts:
7480 % 1) NAME-title - the current sectioning name taken from \lastsection,
7481 %                 or the anchor name.
7482 % 2) NAME-snt   - section number and type, passed as the SNT arg, or
7483 %                 empty for anchors.
7484 % 3) NAME-pg    - the page number.
7485 %
7486 % This is called from \donoderef, \anchor, and \dofloat.  In the case of
7487 % floats, there is an additional part, which is not written here:
7488 % 4) NAME-lof   - the text as it should appear in a @listoffloats.
7489 %
7490 \def\setref#1#2{%
7491   \pdfmkdest{#1}%
7492   \iflinks
7493     {%
7494       \atdummies  % preserve commands, but don't expand them
7495       \edef\writexrdef##1##2{%
7496         \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef
7497           ##1}{##2}}% these are parameters of \writexrdef
7498       }%
7499       \toks0 = \expandafter{\lastsection}%
7500       \immediate \writexrdef{title}{\the\toks0 }%
7501       \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc.
7502       \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout
7503     }%
7504   \fi
7505 }
7506
7507 % @xrefautosectiontitle on|off says whether @section(ing) names are used
7508 % automatically in xrefs, if the third arg is not explicitly specified.
7509 % This was provided as a "secret" @set xref-automatic-section-title
7510 % variable, now it's official.
7511
7512 \parseargdef\xrefautomaticsectiontitle{%
7513   \def\temp{#1}%
7514   \ifx\temp\onword
7515     \expandafter\let\csname SETxref-automatic-section-title\endcsname
7516       = \empty
7517   \else\ifx\temp\offword
7518     \expandafter\let\csname SETxref-automatic-section-title\endcsname
7519       = \relax
7520   \else
7521     \errhelp = \EMsimple
7522     \errmessage{Unknown @xrefautomaticsectiontitle value `\temp',
7523                 must be on|off}%
7524   \fi\fi
7525 }
7526
7527
7528 % @xref, @pxref, and @ref generate cross-references.  For \xrefX, #1 is
7529 % the node name, #2 the name of the Info cross-reference, #3 the printed
7530 % node name, #4 the name of the Info file, #5 the name of the printed
7531 % manual.  All but the node name can be omitted.
7532 %
7533 \def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]}
7534 \def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]}
7535 \def\ref#1{\xrefX[#1,,,,,,,]}
7536 \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
7537   \unsepspaces
7538   \def\printedmanual{\ignorespaces #5}%
7539   \def\printedrefname{\ignorespaces #3}%
7540   \setbox1=\hbox{\printedmanual\unskip}%
7541   \setbox0=\hbox{\printedrefname\unskip}%
7542   \ifdim \wd0 = 0pt
7543     % No printed node name was explicitly given.
7544     \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax
7545       % Use the node name inside the square brackets.
7546       \def\printedrefname{\ignorespaces #1}%
7547     \else
7548       % Use the actual chapter/section title appear inside
7549       % the square brackets.  Use the real section title if we have it.
7550       \ifdim \wd1 > 0pt
7551         % It is in another manual, so we don't have it.
7552         \def\printedrefname{\ignorespaces #1}%
7553       \else
7554         \ifhavexrefs
7555           % We know the real title if we have the xref values.
7556           \def\printedrefname{\refx{#1-title}{}}%
7557         \else
7558           % Otherwise just copy the Info node name.
7559           \def\printedrefname{\ignorespaces #1}%
7560         \fi%
7561       \fi
7562     \fi
7563   \fi
7564   %
7565   % Make link in pdf output.
7566   \ifpdf
7567     {\indexnofonts
7568      \turnoffactive
7569      % This expands tokens, so do it after making catcode changes, so _
7570      % etc. don't get their TeX definitions.
7571      \getfilename{#4}%
7572      %
7573      % See comments at \activebackslashdouble.
7574      {\activebackslashdouble \xdef\pdfxrefdest{#1}%
7575       \backslashparens\pdfxrefdest}%
7576      %
7577      \leavevmode
7578      \startlink attr{/Border [0 0 0]}%
7579      \ifnum\filenamelength>0
7580        goto file{\the\filename.pdf} name{\pdfxrefdest}%
7581      \else
7582        goto name{\pdfmkpgn{\pdfxrefdest}}%
7583      \fi
7584     }%
7585     \setcolor{\linkcolor}%
7586   \fi
7587   %
7588   % Float references are printed completely differently: "Figure 1.2"
7589   % instead of "[somenode], p.3".  We distinguish them by the
7590   % LABEL-title being set to a magic string.
7591   {%
7592     % Have to otherify everything special to allow the \csname to
7593     % include an _ in the xref name, etc.
7594     \indexnofonts
7595     \turnoffactive
7596     \expandafter\global\expandafter\let\expandafter\Xthisreftitle
7597       \csname XR#1-title\endcsname
7598   }%
7599   \iffloat\Xthisreftitle
7600     % If the user specified the print name (third arg) to the ref,
7601     % print it instead of our usual "Figure 1.2".
7602     \ifdim\wd0 = 0pt
7603       \refx{#1-snt}{}%
7604     \else
7605       \printedrefname
7606     \fi
7607     %
7608     % if the user also gave the printed manual name (fifth arg), append
7609     % "in MANUALNAME".
7610     \ifdim \wd1 > 0pt
7611       \space \putwordin{} \cite{\printedmanual}%
7612     \fi
7613   \else
7614     % node/anchor (non-float) references.
7615     %
7616     % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not
7617     % insert empty discretionaries after hyphens, which means that it will
7618     % not find a line break at a hyphen in a node names.  Since some manuals
7619     % are best written with fairly long node names, containing hyphens, this
7620     % is a loss.  Therefore, we give the text of the node name again, so it
7621     % is as if TeX is seeing it for the first time.
7622     \ifdim \wd1 > 0pt
7623       \putwordSection{} ``\printedrefname'' \putwordin{} \cite{\printedmanual}%
7624     \else
7625       % _ (for example) has to be the character _ for the purposes of the
7626       % control sequence corresponding to the node, but it has to expand
7627       % into the usual \leavevmode...\vrule stuff for purposes of
7628       % printing. So we \turnoffactive for the \refx-snt, back on for the
7629       % printing, back off for the \refx-pg.
7630       {\turnoffactive
7631        % Only output a following space if the -snt ref is nonempty; for
7632        % @unnumbered and @anchor, it won't be.
7633        \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
7634        \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
7635       }%
7636       % output the `[mynode]' via a macro so it can be overridden.
7637       \xrefprintnodename\printedrefname
7638       %
7639       % But we always want a comma and a space:
7640       ,\space
7641       %
7642       % output the `page 3'.
7643       \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
7644     \fi
7645   \fi
7646   \endlink
7647 \endgroup}
7648
7649 % This macro is called from \xrefX for the `[nodename]' part of xref
7650 % output.  It's a separate macro only so it can be changed more easily,
7651 % since square brackets don't work well in some documents.  Particularly
7652 % one that Bob is working on :).
7653 %
7654 \def\xrefprintnodename#1{[#1]}
7655
7656 % Things referred to by \setref.
7657 %
7658 \def\Ynothing{}
7659 \def\Yomitfromtoc{}
7660 \def\Ynumbered{%
7661   \ifnum\secno=0
7662     \putwordChapter@tie \the\chapno
7663   \else \ifnum\subsecno=0
7664     \putwordSection@tie \the\chapno.\the\secno
7665   \else \ifnum\subsubsecno=0
7666     \putwordSection@tie \the\chapno.\the\secno.\the\subsecno
7667   \else
7668     \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno
7669   \fi\fi\fi
7670 }
7671 \def\Yappendix{%
7672   \ifnum\secno=0
7673      \putwordAppendix@tie @char\the\appendixno{}%
7674   \else \ifnum\subsecno=0
7675      \putwordSection@tie @char\the\appendixno.\the\secno
7676   \else \ifnum\subsubsecno=0
7677     \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno
7678   \else
7679     \putwordSection@tie
7680       @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno
7681   \fi\fi\fi
7682 }
7683
7684 % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
7685 % If its value is nonempty, SUFFIX is output afterward.
7686 %
7687 \def\refx#1#2{%
7688   {%
7689     \indexnofonts
7690     \otherbackslash
7691     \expandafter\global\expandafter\let\expandafter\thisrefX
7692       \csname XR#1\endcsname
7693   }%
7694   \ifx\thisrefX\relax
7695     % If not defined, say something at least.
7696     \angleleft un\-de\-fined\angleright
7697     \iflinks
7698       \ifhavexrefs
7699         {\toks0 = {#1}% avoid expansion of possibly-complex value
7700          \message{\linenumber Undefined cross reference `\the\toks0'.}}%
7701       \else
7702         \ifwarnedxrefs\else
7703           \global\warnedxrefstrue
7704           \message{Cross reference values unknown; you must run TeX again.}%
7705         \fi
7706       \fi
7707     \fi
7708   \else
7709     % It's defined, so just use it.
7710     \thisrefX
7711   \fi
7712   #2% Output the suffix in any case.
7713 }
7714
7715 % This is the macro invoked by entries in the aux file.  Usually it's
7716 % just a \def (we prepend XR to the control sequence name to avoid
7717 % collisions).  But if this is a float type, we have more work to do.
7718 %
7719 \def\xrdef#1#2{%
7720   {% The node name might contain 8-bit characters, which in our current
7721    % implementation are changed to commands like @'e.  Don't let these
7722    % mess up the control sequence name.
7723     \indexnofonts
7724     \turnoffactive
7725     \xdef\safexrefname{#1}%
7726   }%
7727   %
7728   \expandafter\gdef\csname XR\safexrefname\endcsname{#2}% remember this xref
7729   %
7730   % Was that xref control sequence that we just defined for a float?
7731   \expandafter\iffloat\csname XR\safexrefname\endcsname
7732     % it was a float, and we have the (safe) float type in \iffloattype.
7733     \expandafter\let\expandafter\floatlist
7734       \csname floatlist\iffloattype\endcsname
7735     %
7736     % Is this the first time we've seen this float type?
7737     \expandafter\ifx\floatlist\relax
7738       \toks0 = {\do}% yes, so just \do
7739     \else
7740       % had it before, so preserve previous elements in list.
7741       \toks0 = \expandafter{\floatlist\do}%
7742     \fi
7743     %
7744     % Remember this xref in the control sequence \floatlistFLOATTYPE,
7745     % for later use in \listoffloats.
7746     \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0
7747       {\safexrefname}}%
7748   \fi
7749 }
7750
7751 % Read the last existing aux file, if any.  No error if none exists.
7752 %
7753 \def\tryauxfile{%
7754   \openin 1 \jobname.aux
7755   \ifeof 1 \else
7756     \readdatafile{aux}%
7757     \global\havexrefstrue
7758   \fi
7759   \closein 1
7760 }
7761
7762 \def\setupdatafile{%
7763   \catcode`\^^@=\other
7764   \catcode`\^^A=\other
7765   \catcode`\^^B=\other
7766   \catcode`\^^C=\other
7767   \catcode`\^^D=\other
7768   \catcode`\^^E=\other
7769   \catcode`\^^F=\other
7770   \catcode`\^^G=\other
7771   \catcode`\^^H=\other
7772   \catcode`\^^K=\other
7773   \catcode`\^^L=\other
7774   \catcode`\^^N=\other
7775   \catcode`\^^P=\other
7776   \catcode`\^^Q=\other
7777   \catcode`\^^R=\other
7778   \catcode`\^^S=\other
7779   \catcode`\^^T=\other
7780   \catcode`\^^U=\other
7781   \catcode`\^^V=\other
7782   \catcode`\^^W=\other
7783   \catcode`\^^X=\other
7784   \catcode`\^^Z=\other
7785   \catcode`\^^[=\other
7786   \catcode`\^^\=\other
7787   \catcode`\^^]=\other
7788   \catcode`\^^^=\other
7789   \catcode`\^^_=\other
7790   % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc.
7791   % in xref tags, i.e., node names.  But since ^^e4 notation isn't
7792   % supported in the main text, it doesn't seem desirable.  Furthermore,
7793   % that is not enough: for node names that actually contain a ^
7794   % character, we would end up writing a line like this: 'xrdef {'hat
7795   % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first
7796   % argument, and \hat is not an expandable control sequence.  It could
7797   % all be worked out, but why?  Either we support ^^ or we don't.
7798   %
7799   % The other change necessary for this was to define \auxhat:
7800   % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter
7801   % and then to call \auxhat in \setq.
7802   %
7803   \catcode`\^=\other
7804   %
7805   % Special characters.  Should be turned off anyway, but...
7806   \catcode`\~=\other
7807   \catcode`\[=\other
7808   \catcode`\]=\other
7809   \catcode`\"=\other
7810   \catcode`\_=\other
7811   \catcode`\|=\other
7812   \catcode`\<=\other
7813   \catcode`\>=\other
7814   \catcode`\$=\other
7815   \catcode`\#=\other
7816   \catcode`\&=\other
7817   \catcode`\%=\other
7818   \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
7819   %
7820   % This is to support \ in node names and titles, since the \
7821   % characters end up in a \csname.  It's easier than
7822   % leaving it active and making its active definition an actual \
7823   % character.  What I don't understand is why it works in the *value*
7824   % of the xrdef.  Seems like it should be a catcode12 \, and that
7825   % should not typeset properly.  But it works, so I'm moving on for
7826   % now.  --karl, 15jan04.
7827   \catcode`\\=\other
7828   %
7829   % Make the characters 128-255 be printing characters.
7830   {%
7831     \count1=128
7832     \def\loop{%
7833       \catcode\count1=\other
7834       \advance\count1 by 1
7835       \ifnum \count1<256 \loop \fi
7836     }%
7837   }%
7838   %
7839   % @ is our escape character in .aux files, and we need braces.
7840   \catcode`\{=1
7841   \catcode`\}=2
7842   \catcode`\@=0
7843 }
7844
7845 \def\readdatafile#1{%
7846 \begingroup
7847   \setupdatafile
7848   \input\jobname.#1
7849 \endgroup}
7850
7851
7852 \message{insertions,}
7853 % including footnotes.
7854
7855 \newcount \footnoteno
7856
7857 % The trailing space in the following definition for supereject is
7858 % vital for proper filling; pages come out unaligned when you do a
7859 % pagealignmacro call if that space before the closing brace is
7860 % removed. (Generally, numeric constants should always be followed by a
7861 % space to prevent strange expansion errors.)
7862 \def\supereject{\par\penalty -20000\footnoteno =0 }
7863
7864 % @footnotestyle is meaningful for info output only.
7865 \let\footnotestyle=\comment
7866
7867 {\catcode `\@=11
7868 %
7869 % Auto-number footnotes.  Otherwise like plain.
7870 \gdef\footnote{%
7871   \let\indent=\ptexindent
7872   \let\noindent=\ptexnoindent
7873   \global\advance\footnoteno by \@ne
7874   \edef\thisfootno{$^{\the\footnoteno}$}%
7875   %
7876   % In case the footnote comes at the end of a sentence, preserve the
7877   % extra spacing after we do the footnote number.
7878   \let\@sf\empty
7879   \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi
7880   %
7881   % Remove inadvertent blank space before typesetting the footnote number.
7882   \unskip
7883   \thisfootno\@sf
7884   \dofootnote
7885 }%
7886
7887 % Don't bother with the trickery in plain.tex to not require the
7888 % footnote text as a parameter.  Our footnotes don't need to be so general.
7889 %
7890 % Oh yes, they do; otherwise, @ifset (and anything else that uses
7891 % \parseargline) fails inside footnotes because the tokens are fixed when
7892 % the footnote is read.  --karl, 16nov96.
7893 %
7894 \gdef\dofootnote{%
7895   \insert\footins\bgroup
7896   % We want to typeset this text as a normal paragraph, even if the
7897   % footnote reference occurs in (for example) a display environment.
7898   % So reset some parameters.
7899   \hsize=\pagewidth
7900   \interlinepenalty\interfootnotelinepenalty
7901   \splittopskip\ht\strutbox % top baseline for broken footnotes
7902   \splitmaxdepth\dp\strutbox
7903   \floatingpenalty\@MM
7904   \leftskip\z@skip
7905   \rightskip\z@skip
7906   \spaceskip\z@skip
7907   \xspaceskip\z@skip
7908   \parindent\defaultparindent
7909   %
7910   \smallfonts \rm
7911   %
7912   % Because we use hanging indentation in footnotes, a @noindent appears
7913   % to exdent this text, so make it be a no-op.  makeinfo does not use
7914   % hanging indentation so @noindent can still be needed within footnote
7915   % text after an @example or the like (not that this is good style).
7916   \let\noindent = \relax
7917   %
7918   % Hang the footnote text off the number.  Use \everypar in case the
7919   % footnote extends for more than one paragraph.
7920   \everypar = {\hang}%
7921   \textindent{\thisfootno}%
7922   %
7923   % Don't crash into the line above the footnote text.  Since this
7924   % expands into a box, it must come within the paragraph, lest it
7925   % provide a place where TeX can split the footnote.
7926   \footstrut
7927   \futurelet\next\fo@t
7928 }
7929 }%end \catcode `\@=11
7930
7931 % In case a @footnote appears in a vbox, save the footnote text and create
7932 % the real \insert just after the vbox finished.  Otherwise, the insertion
7933 % would be lost.
7934 % Similarly, if a @footnote appears inside an alignment, save the footnote
7935 % text to a box and make the \insert when a row of the table is finished.
7936 % And the same can be done for other insert classes.  --kasal, 16nov03.
7937
7938 % Replace the \insert primitive by a cheating macro.
7939 % Deeper inside, just make sure that the saved insertions are not spilled
7940 % out prematurely.
7941 %
7942 \def\startsavinginserts{%
7943   \ifx \insert\ptexinsert
7944     \let\insert\saveinsert
7945   \else
7946     \let\checkinserts\relax
7947   \fi
7948 }
7949
7950 % This \insert replacement works for both \insert\footins{foo} and
7951 % \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}.
7952 %
7953 \def\saveinsert#1{%
7954   \edef\next{\noexpand\savetobox \makeSAVEname#1}%
7955   \afterassignment\next
7956   % swallow the left brace
7957   \let\temp =
7958 }
7959 \def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}}
7960 \def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1}
7961
7962 \def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi}
7963
7964 \def\placesaveins#1{%
7965   \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname
7966     {\box#1}%
7967 }
7968
7969 % eat @SAVE -- beware, all of them have catcode \other:
7970 {
7971   \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials  %  ;-)
7972   \gdef\gobblesave @SAVE{}
7973 }
7974
7975 % initialization:
7976 \def\newsaveins #1{%
7977   \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}%
7978   \next
7979 }
7980 \def\newsaveinsX #1{%
7981   \csname newbox\endcsname #1%
7982   \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts
7983     \checksaveins #1}%
7984 }
7985
7986 % initialize:
7987 \let\checkinserts\empty
7988 \newsaveins\footins
7989 \newsaveins\margin
7990
7991
7992 % @image.  We use the macros from epsf.tex to support this.
7993 % If epsf.tex is not installed and @image is used, we complain.
7994 %
7995 % Check for and read epsf.tex up front.  If we read it only at @image
7996 % time, we might be inside a group, and then its definitions would get
7997 % undone and the next image would fail.
7998 \openin 1 = epsf.tex
7999 \ifeof 1 \else
8000   % Do not bother showing banner with epsf.tex v2.7k (available in
8001   % doc/epsf.tex and on ctan).
8002   \def\epsfannounce{\toks0 = }%
8003   \input epsf.tex
8004 \fi
8005 \closein 1
8006 %
8007 % We will only complain once about lack of epsf.tex.
8008 \newif\ifwarnednoepsf
8009 \newhelp\noepsfhelp{epsf.tex must be installed for images to
8010   work.  It is also included in the Texinfo distribution, or you can get
8011   it from ftp://tug.org/tex/epsf.tex.}
8012 %
8013 \def\image#1{%
8014   \ifx\epsfbox\thisiundefined
8015     \ifwarnednoepsf \else
8016       \errhelp = \noepsfhelp
8017       \errmessage{epsf.tex not found, images will be ignored}%
8018       \global\warnednoepsftrue
8019     \fi
8020   \else
8021     \imagexxx #1,,,,,\finish
8022   \fi
8023 }
8024 %
8025 % Arguments to @image:
8026 % #1 is (mandatory) image filename; we tack on .eps extension.
8027 % #2 is (optional) width, #3 is (optional) height.
8028 % #4 is (ignored optional) html alt text.
8029 % #5 is (ignored optional) extension.
8030 % #6 is just the usual extra ignored arg for parsing stuff.
8031 \newif\ifimagevmode
8032 \def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup
8033   \catcode`\^^M = 5     % in case we're inside an example
8034   \normalturnoffactive  % allow _ et al. in names
8035   % If the image is by itself, center it.
8036   \ifvmode
8037     \imagevmodetrue
8038     \nobreak\medskip
8039     % Usually we'll have text after the image which will insert
8040     % \parskip glue, so insert it here too to equalize the space
8041     % above and below.
8042     \nobreak\vskip\parskip
8043     \nobreak
8044   \fi
8045   %
8046   % Leave vertical mode so that indentation from an enclosing
8047   % environment such as @quotation is respected.  On the other hand, if
8048   % it's at the top level, we don't want the normal paragraph indentation.
8049   \noindent
8050   %
8051   % Output the image.
8052   \ifpdf
8053     \dopdfimage{#1}{#2}{#3}%
8054   \else
8055     % \epsfbox itself resets \epsf?size at each figure.
8056     \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
8057     \setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
8058     \epsfbox{#1.eps}%
8059   \fi
8060   %
8061   \ifimagevmode \medskip \fi  % space after the standalone image
8062 \endgroup}
8063
8064
8065 % @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables,
8066 % etc.  We don't actually implement floating yet, we always include the
8067 % float "here".  But it seemed the best name for the future.
8068 %
8069 \envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish}
8070
8071 % There may be a space before second and/or third parameter; delete it.
8072 \def\eatcommaspace#1, {#1,}
8073
8074 % #1 is the optional FLOATTYPE, the text label for this float, typically
8075 % "Figure", "Table", "Example", etc.  Can't contain commas.  If omitted,
8076 % this float will not be numbered and cannot be referred to.
8077 %
8078 % #2 is the optional xref label.  Also must be present for the float to
8079 % be referable.
8080 %
8081 % #3 is the optional positioning argument; for now, it is ignored.  It
8082 % will somehow specify the positions allowed to float to (here, top, bottom).
8083 %
8084 % We keep a separate counter for each FLOATTYPE, which we reset at each
8085 % chapter-level command.
8086 \let\resetallfloatnos=\empty
8087 %
8088 \def\dofloat#1,#2,#3,#4\finish{%
8089   \let\thiscaption=\empty
8090   \let\thisshortcaption=\empty
8091   %
8092   % don't lose footnotes inside @float.
8093   %
8094   % BEWARE: when the floats start float, we have to issue warning whenever an
8095   % insert appears inside a float which could possibly float. --kasal, 26may04
8096   %
8097   \startsavinginserts
8098   %
8099   % We can't be used inside a paragraph.
8100   \par
8101   %
8102   \vtop\bgroup
8103     \def\floattype{#1}%
8104     \def\floatlabel{#2}%
8105     \def\floatloc{#3}% we do nothing with this yet.
8106     %
8107     \ifx\floattype\empty
8108       \let\safefloattype=\empty
8109     \else
8110       {%
8111         % the floattype might have accents or other special characters,
8112         % but we need to use it in a control sequence name.
8113         \indexnofonts
8114         \turnoffactive
8115         \xdef\safefloattype{\floattype}%
8116       }%
8117     \fi
8118     %
8119     % If label is given but no type, we handle that as the empty type.
8120     \ifx\floatlabel\empty \else
8121       % We want each FLOATTYPE to be numbered separately (Figure 1,
8122       % Table 1, Figure 2, ...).  (And if no label, no number.)
8123       %
8124       \expandafter\getfloatno\csname\safefloattype floatno\endcsname
8125       \global\advance\floatno by 1
8126       %
8127       {%
8128         % This magic value for \lastsection is output by \setref as the
8129         % XREFLABEL-title value.  \xrefX uses it to distinguish float
8130         % labels (which have a completely different output format) from
8131         % node and anchor labels.  And \xrdef uses it to construct the
8132         % lists of floats.
8133         %
8134         \edef\lastsection{\floatmagic=\safefloattype}%
8135         \setref{\floatlabel}{Yfloat}%
8136       }%
8137     \fi
8138     %
8139     % start with \parskip glue, I guess.
8140     \vskip\parskip
8141     %
8142     % Don't suppress indentation if a float happens to start a section.
8143     \restorefirstparagraphindent
8144 }
8145
8146 % we have these possibilities:
8147 % @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap
8148 % @float Foo,lbl & no caption:    Foo 1.1
8149 % @float Foo & @caption{Cap}:     Foo: Cap
8150 % @float Foo & no caption:        Foo
8151 % @float ,lbl & Caption{Cap}:     1.1: Cap
8152 % @float ,lbl & no caption:       1.1
8153 % @float & @caption{Cap}:         Cap
8154 % @float & no caption:
8155 %
8156 \def\Efloat{%
8157     \let\floatident = \empty
8158     %
8159     % In all cases, if we have a float type, it comes first.
8160     \ifx\floattype\empty \else \def\floatident{\floattype}\fi
8161     %
8162     % If we have an xref label, the number comes next.
8163     \ifx\floatlabel\empty \else
8164       \ifx\floattype\empty \else % if also had float type, need tie first.
8165         \appendtomacro\floatident{\tie}%
8166       \fi
8167       % the number.
8168       \appendtomacro\floatident{\chaplevelprefix\the\floatno}%
8169     \fi
8170     %
8171     % Start the printed caption with what we've constructed in
8172     % \floatident, but keep it separate; we need \floatident again.
8173     \let\captionline = \floatident
8174     %
8175     \ifx\thiscaption\empty \else
8176       \ifx\floatident\empty \else
8177         \appendtomacro\captionline{: }% had ident, so need a colon between
8178       \fi
8179       %
8180       % caption text.
8181       \appendtomacro\captionline{\scanexp\thiscaption}%
8182     \fi
8183     %
8184     % If we have anything to print, print it, with space before.
8185     % Eventually this needs to become an \insert.
8186     \ifx\captionline\empty \else
8187       \vskip.5\parskip
8188       \captionline
8189       %
8190       % Space below caption.
8191       \vskip\parskip
8192     \fi
8193     %
8194     % If have an xref label, write the list of floats info.  Do this
8195     % after the caption, to avoid chance of it being a breakpoint.
8196     \ifx\floatlabel\empty \else
8197       % Write the text that goes in the lof to the aux file as
8198       % \floatlabel-lof.  Besides \floatident, we include the short
8199       % caption if specified, else the full caption if specified, else nothing.
8200       {%
8201         \atdummies
8202         %
8203         % since we read the caption text in the macro world, where ^^M
8204         % is turned into a normal character, we have to scan it back, so
8205         % we don't write the literal three characters "^^M" into the aux file.
8206         \scanexp{%
8207           \xdef\noexpand\gtemp{%
8208             \ifx\thisshortcaption\empty
8209               \thiscaption
8210             \else
8211               \thisshortcaption
8212             \fi
8213           }%
8214         }%
8215         \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident
8216           \ifx\gtemp\empty \else : \gtemp \fi}}%
8217       }%
8218     \fi
8219   \egroup  % end of \vtop
8220   %
8221   % place the captured inserts
8222   %
8223   % BEWARE: when the floats start floating, we have to issue warning
8224   % whenever an insert appears inside a float which could possibly
8225   % float. --kasal, 26may04
8226   %
8227   \checkinserts
8228 }
8229
8230 % Append the tokens #2 to the definition of macro #1, not expanding either.
8231 %
8232 \def\appendtomacro#1#2{%
8233   \expandafter\def\expandafter#1\expandafter{#1#2}%
8234 }
8235
8236 % @caption, @shortcaption
8237 %
8238 \def\caption{\docaption\thiscaption}
8239 \def\shortcaption{\docaption\thisshortcaption}
8240 \def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption}
8241 \def\defcaption#1#2{\egroup \def#1{#2}}
8242
8243 % The parameter is the control sequence identifying the counter we are
8244 % going to use.  Create it if it doesn't exist and assign it to \floatno.
8245 \def\getfloatno#1{%
8246   \ifx#1\relax
8247       % Haven't seen this figure type before.
8248       \csname newcount\endcsname #1%
8249       %
8250       % Remember to reset this floatno at the next chap.
8251       \expandafter\gdef\expandafter\resetallfloatnos
8252         \expandafter{\resetallfloatnos #1=0 }%
8253   \fi
8254   \let\floatno#1%
8255 }
8256
8257 % \setref calls this to get the XREFLABEL-snt value.  We want an @xref
8258 % to the FLOATLABEL to expand to "Figure 3.1".  We call \setref when we
8259 % first read the @float command.
8260 %
8261 \def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}%
8262
8263 % Magic string used for the XREFLABEL-title value, so \xrefX can
8264 % distinguish floats from other xref types.
8265 \def\floatmagic{!!float!!}
8266
8267 % #1 is the control sequence we are passed; we expand into a conditional
8268 % which is true if #1 represents a float ref.  That is, the magic
8269 % \lastsection value which we \setref above.
8270 %
8271 \def\iffloat#1{\expandafter\doiffloat#1==\finish}
8272 %
8273 % #1 is (maybe) the \floatmagic string.  If so, #2 will be the
8274 % (safe) float type for this float.  We set \iffloattype to #2.
8275 %
8276 \def\doiffloat#1=#2=#3\finish{%
8277   \def\temp{#1}%
8278   \def\iffloattype{#2}%
8279   \ifx\temp\floatmagic
8280 }
8281
8282 % @listoffloats FLOATTYPE - print a list of floats like a table of contents.
8283 %
8284 \parseargdef\listoffloats{%
8285   \def\floattype{#1}% floattype
8286   {%
8287     % the floattype might have accents or other special characters,
8288     % but we need to use it in a control sequence name.
8289     \indexnofonts
8290     \turnoffactive
8291     \xdef\safefloattype{\floattype}%
8292   }%
8293   %
8294   % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE.
8295   \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax
8296     \ifhavexrefs
8297       % if the user said @listoffloats foo but never @float foo.
8298       \message{\linenumber No `\safefloattype' floats to list.}%
8299     \fi
8300   \else
8301     \begingroup
8302       \leftskip=\tocindent  % indent these entries like a toc
8303       \let\do=\listoffloatsdo
8304       \csname floatlist\safefloattype\endcsname
8305     \endgroup
8306   \fi
8307 }
8308
8309 % This is called on each entry in a list of floats.  We're passed the
8310 % xref label, in the form LABEL-title, which is how we save it in the
8311 % aux file.  We strip off the -title and look up \XRLABEL-lof, which
8312 % has the text we're supposed to typeset here.
8313 %
8314 % Figures without xref labels will not be included in the list (since
8315 % they won't appear in the aux file).
8316 %
8317 \def\listoffloatsdo#1{\listoffloatsdoentry#1\finish}
8318 \def\listoffloatsdoentry#1-title\finish{{%
8319   % Can't fully expand XR#1-lof because it can contain anything.  Just
8320   % pass the control sequence.  On the other hand, XR#1-pg is just the
8321   % page number, and we want to fully expand that so we can get a link
8322   % in pdf output.
8323   \toksA = \expandafter{\csname XR#1-lof\endcsname}%
8324   %
8325   % use the same \entry macro we use to generate the TOC and index.
8326   \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}%
8327   \writeentry
8328 }}
8329
8330
8331 \message{localization,}
8332
8333 % For single-language documents, @documentlanguage is usually given very
8334 % early, just after @documentencoding.  Single argument is the language
8335 % (de) or locale (de_DE) abbreviation.
8336 %
8337 {
8338   \catcode`\_ = \active
8339   \globaldefs=1
8340 \parseargdef\documentlanguage{\begingroup
8341   \let_=\normalunderscore  % normal _ character for filenames
8342   \tex % read txi-??.tex file in plain TeX.
8343     % Read the file by the name they passed if it exists.
8344     \openin 1 txi-#1.tex
8345     \ifeof 1
8346       \documentlanguagetrywithoutunderscore{#1_\finish}%
8347     \else
8348       \globaldefs = 1  % everything in the txi-LL files needs to persist
8349       \input txi-#1.tex
8350     \fi
8351     \closein 1
8352   \endgroup % end raw TeX
8353 \endgroup}
8354 %
8355 % If they passed de_DE, and txi-de_DE.tex doesn't exist,
8356 % try txi-de.tex.
8357 %
8358 \gdef\documentlanguagetrywithoutunderscore#1_#2\finish{%
8359   \openin 1 txi-#1.tex
8360   \ifeof 1
8361     \errhelp = \nolanghelp
8362     \errmessage{Cannot read language file txi-#1.tex}%
8363   \else
8364     \globaldefs = 1  % everything in the txi-LL files needs to persist
8365     \input txi-#1.tex
8366   \fi
8367   \closein 1
8368 }
8369 }% end of special _ catcode
8370 %
8371 \newhelp\nolanghelp{The given language definition file cannot be found or
8372 is empty.  Maybe you need to install it?  Putting it in the current
8373 directory should work if nowhere else does.}
8374
8375 % This macro is called from txi-??.tex files; the first argument is the
8376 % \language name to set (without the "\lang@" prefix), the second and
8377 % third args are \{left,right}hyphenmin.
8378 %
8379 % The language names to pass are determined when the format is built.
8380 % See the etex.log file created at that time, e.g.,
8381 % /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log.
8382 %
8383 % With TeX Live 2008, etex now includes hyphenation patterns for all
8384 % available languages.  This means we can support hyphenation in
8385 % Texinfo, at least to some extent.  (This still doesn't solve the
8386 % accented characters problem.)
8387 %
8388 \catcode`@=11
8389 \def\txisetlanguage#1#2#3{%
8390   % do not set the language if the name is undefined in the current TeX.
8391   \expandafter\ifx\csname lang@#1\endcsname \relax
8392     \message{no patterns for #1}%
8393   \else
8394     \global\language = \csname lang@#1\endcsname
8395   \fi
8396   % but there is no harm in adjusting the hyphenmin values regardless.
8397   \global\lefthyphenmin = #2\relax
8398   \global\righthyphenmin = #3\relax
8399 }
8400
8401 % Helpers for encodings.
8402 % Set the catcode of characters 128 through 255 to the specified number.
8403 %
8404 \def\setnonasciicharscatcode#1{%
8405    \count255=128
8406    \loop\ifnum\count255<256
8407       \global\catcode\count255=#1\relax
8408       \advance\count255 by 1
8409    \repeat
8410 }
8411
8412 \def\setnonasciicharscatcodenonglobal#1{%
8413    \count255=128
8414    \loop\ifnum\count255<256
8415       \catcode\count255=#1\relax
8416       \advance\count255 by 1
8417    \repeat
8418 }
8419
8420 % @documentencoding sets the definition of non-ASCII characters
8421 % according to the specified encoding.
8422 %
8423 \parseargdef\documentencoding{%
8424   % Encoding being declared for the document.
8425   \def\declaredencoding{\csname #1.enc\endcsname}%
8426   %
8427   % Supported encodings: names converted to tokens in order to be able
8428   % to compare them with \ifx.
8429   \def\ascii{\csname US-ASCII.enc\endcsname}%
8430   \def\latnine{\csname ISO-8859-15.enc\endcsname}%
8431   \def\latone{\csname ISO-8859-1.enc\endcsname}%
8432   \def\lattwo{\csname ISO-8859-2.enc\endcsname}%
8433   \def\utfeight{\csname UTF-8.enc\endcsname}%
8434   %
8435   \ifx \declaredencoding \ascii
8436      \asciichardefs
8437   %
8438   \else \ifx \declaredencoding \lattwo
8439      \setnonasciicharscatcode\active
8440      \lattwochardefs
8441   %
8442   \else \ifx \declaredencoding \latone
8443      \setnonasciicharscatcode\active
8444      \latonechardefs
8445   %
8446   \else \ifx \declaredencoding \latnine
8447      \setnonasciicharscatcode\active
8448      \latninechardefs
8449   %
8450   \else \ifx \declaredencoding \utfeight
8451      \setnonasciicharscatcode\active
8452      \utfeightchardefs
8453   %
8454   \else
8455     \message{Unknown document encoding #1, ignoring.}%
8456   %
8457   \fi % utfeight
8458   \fi % latnine
8459   \fi % latone
8460   \fi % lattwo
8461   \fi % ascii
8462 }
8463
8464 % A message to be logged when using a character that isn't available
8465 % the default font encoding (OT1).
8466 %
8467 \def\missingcharmsg#1{\message{Character missing in OT1 encoding: #1.}}
8468
8469 % Take account of \c (plain) vs. \, (Texinfo) difference.
8470 \def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi}
8471
8472 % First, make active non-ASCII characters in order for them to be
8473 % correctly categorized when TeX reads the replacement text of
8474 % macros containing the character definitions.
8475 \setnonasciicharscatcode\active
8476 %
8477 % Latin1 (ISO-8859-1) character definitions.
8478 \def\latonechardefs{%
8479   \gdef^^a0{\tie}
8480   \gdef^^a1{\exclamdown}
8481   \gdef^^a2{\missingcharmsg{CENT SIGN}}
8482   \gdef^^a3{{\pounds}}
8483   \gdef^^a4{\missingcharmsg{CURRENCY SIGN}}
8484   \gdef^^a5{\missingcharmsg{YEN SIGN}}
8485   \gdef^^a6{\missingcharmsg{BROKEN BAR}}
8486   \gdef^^a7{\S}
8487   \gdef^^a8{\"{}}
8488   \gdef^^a9{\copyright}
8489   \gdef^^aa{\ordf}
8490   \gdef^^ab{\guillemetleft}
8491   \gdef^^ac{$\lnot$}
8492   \gdef^^ad{\-}
8493   \gdef^^ae{\registeredsymbol}
8494   \gdef^^af{\={}}
8495   %
8496   \gdef^^b0{\textdegree}
8497   \gdef^^b1{$\pm$}
8498   \gdef^^b2{$^2$}
8499   \gdef^^b3{$^3$}
8500   \gdef^^b4{\'{}}
8501   \gdef^^b5{$\mu$}
8502   \gdef^^b6{\P}
8503   %
8504   \gdef^^b7{$^.$}
8505   \gdef^^b8{\cedilla\ }
8506   \gdef^^b9{$^1$}
8507   \gdef^^ba{\ordm}
8508   %
8509   \gdef^^bb{\guillemetright}
8510   \gdef^^bc{$1\over4$}
8511   \gdef^^bd{$1\over2$}
8512   \gdef^^be{$3\over4$}
8513   \gdef^^bf{\questiondown}
8514   %
8515   \gdef^^c0{\`A}
8516   \gdef^^c1{\'A}
8517   \gdef^^c2{\^A}
8518   \gdef^^c3{\~A}
8519   \gdef^^c4{\"A}
8520   \gdef^^c5{\ringaccent A}
8521   \gdef^^c6{\AE}
8522   \gdef^^c7{\cedilla C}
8523   \gdef^^c8{\`E}
8524   \gdef^^c9{\'E}
8525   \gdef^^ca{\^E}
8526   \gdef^^cb{\"E}
8527   \gdef^^cc{\`I}
8528   \gdef^^cd{\'I}
8529   \gdef^^ce{\^I}
8530   \gdef^^cf{\"I}
8531   %
8532   \gdef^^d0{\DH}
8533   \gdef^^d1{\~N}
8534   \gdef^^d2{\`O}
8535   \gdef^^d3{\'O}
8536   \gdef^^d4{\^O}
8537   \gdef^^d5{\~O}
8538   \gdef^^d6{\"O}
8539   \gdef^^d7{$\times$}
8540   \gdef^^d8{\O}
8541   \gdef^^d9{\`U}
8542   \gdef^^da{\'U}
8543   \gdef^^db{\^U}
8544   \gdef^^dc{\"U}
8545   \gdef^^dd{\'Y}
8546   \gdef^^de{\TH}
8547   \gdef^^df{\ss}
8548   %
8549   \gdef^^e0{\`a}
8550   \gdef^^e1{\'a}
8551   \gdef^^e2{\^a}
8552   \gdef^^e3{\~a}
8553   \gdef^^e4{\"a}
8554   \gdef^^e5{\ringaccent a}
8555   \gdef^^e6{\ae}
8556   \gdef^^e7{\cedilla c}
8557   \gdef^^e8{\`e}
8558   \gdef^^e9{\'e}
8559   \gdef^^ea{\^e}
8560   \gdef^^eb{\"e}
8561   \gdef^^ec{\`{\dotless i}}
8562   \gdef^^ed{\'{\dotless i}}
8563   \gdef^^ee{\^{\dotless i}}
8564   \gdef^^ef{\"{\dotless i}}
8565   %
8566   \gdef^^f0{\dh}
8567   \gdef^^f1{\~n}
8568   \gdef^^f2{\`o}
8569   \gdef^^f3{\'o}
8570   \gdef^^f4{\^o}
8571   \gdef^^f5{\~o}
8572   \gdef^^f6{\"o}
8573   \gdef^^f7{$\div$}
8574   \gdef^^f8{\o}
8575   \gdef^^f9{\`u}
8576   \gdef^^fa{\'u}
8577   \gdef^^fb{\^u}
8578   \gdef^^fc{\"u}
8579   \gdef^^fd{\'y}
8580   \gdef^^fe{\th}
8581   \gdef^^ff{\"y}
8582 }
8583
8584 % Latin9 (ISO-8859-15) encoding character definitions.
8585 \def\latninechardefs{%
8586   % Encoding is almost identical to Latin1.
8587   \latonechardefs
8588   %
8589   \gdef^^a4{\euro}
8590   \gdef^^a6{\v S}
8591   \gdef^^a8{\v s}
8592   \gdef^^b4{\v Z}
8593   \gdef^^b8{\v z}
8594   \gdef^^bc{\OE}
8595   \gdef^^bd{\oe}
8596   \gdef^^be{\"Y}
8597 }
8598
8599 % Latin2 (ISO-8859-2) character definitions.
8600 \def\lattwochardefs{%
8601   \gdef^^a0{\tie}
8602   \gdef^^a1{\ogonek{A}}
8603   \gdef^^a2{\u{}}
8604   \gdef^^a3{\L}
8605   \gdef^^a4{\missingcharmsg{CURRENCY SIGN}}
8606   \gdef^^a5{\v L}
8607   \gdef^^a6{\'S}
8608   \gdef^^a7{\S}
8609   \gdef^^a8{\"{}}
8610   \gdef^^a9{\v S}
8611   \gdef^^aa{\cedilla S}
8612   \gdef^^ab{\v T}
8613   \gdef^^ac{\'Z}
8614   \gdef^^ad{\-}
8615   \gdef^^ae{\v Z}
8616   \gdef^^af{\dotaccent Z}
8617   %
8618   \gdef^^b0{\textdegree}
8619   \gdef^^b1{\ogonek{a}}
8620   \gdef^^b2{\ogonek{ }}
8621   \gdef^^b3{\l}
8622   \gdef^^b4{\'{}}
8623   \gdef^^b5{\v l}
8624   \gdef^^b6{\'s}
8625   \gdef^^b7{\v{}}
8626   \gdef^^b8{\cedilla\ }
8627   \gdef^^b9{\v s}
8628   \gdef^^ba{\cedilla s}
8629   \gdef^^bb{\v t}
8630   \gdef^^bc{\'z}
8631   \gdef^^bd{\H{}}
8632   \gdef^^be{\v z}
8633   \gdef^^bf{\dotaccent z}
8634   %
8635   \gdef^^c0{\'R}
8636   \gdef^^c1{\'A}
8637   \gdef^^c2{\^A}
8638   \gdef^^c3{\u A}
8639   \gdef^^c4{\"A}
8640   \gdef^^c5{\'L}
8641   \gdef^^c6{\'C}
8642   \gdef^^c7{\cedilla C}
8643   \gdef^^c8{\v C}
8644   \gdef^^c9{\'E}
8645   \gdef^^ca{\ogonek{E}}
8646   \gdef^^cb{\"E}
8647   \gdef^^cc{\v E}
8648   \gdef^^cd{\'I}
8649   \gdef^^ce{\^I}
8650   \gdef^^cf{\v D}
8651   %
8652   \gdef^^d0{\DH}
8653   \gdef^^d1{\'N}
8654   \gdef^^d2{\v N}
8655   \gdef^^d3{\'O}
8656   \gdef^^d4{\^O}
8657   \gdef^^d5{\H O}
8658   \gdef^^d6{\"O}
8659   \gdef^^d7{$\times$}
8660   \gdef^^d8{\v R}
8661   \gdef^^d9{\ringaccent U}
8662   \gdef^^da{\'U}
8663   \gdef^^db{\H U}
8664   \gdef^^dc{\"U}
8665   \gdef^^dd{\'Y}
8666   \gdef^^de{\cedilla T}
8667   \gdef^^df{\ss}
8668   %
8669   \gdef^^e0{\'r}
8670   \gdef^^e1{\'a}
8671   \gdef^^e2{\^a}
8672   \gdef^^e3{\u a}
8673   \gdef^^e4{\"a}
8674   \gdef^^e5{\'l}
8675   \gdef^^e6{\'c}
8676   \gdef^^e7{\cedilla c}
8677   \gdef^^e8{\v c}
8678   \gdef^^e9{\'e}
8679   \gdef^^ea{\ogonek{e}}
8680   \gdef^^eb{\"e}
8681   \gdef^^ec{\v e}
8682   \gdef^^ed{\'{\dotless{i}}}
8683   \gdef^^ee{\^{\dotless{i}}}
8684   \gdef^^ef{\v d}
8685   %
8686   \gdef^^f0{\dh}
8687   \gdef^^f1{\'n}
8688   \gdef^^f2{\v n}
8689   \gdef^^f3{\'o}
8690   \gdef^^f4{\^o}
8691   \gdef^^f5{\H o}
8692   \gdef^^f6{\"o}
8693   \gdef^^f7{$\div$}
8694   \gdef^^f8{\v r}
8695   \gdef^^f9{\ringaccent u}
8696   \gdef^^fa{\'u}
8697   \gdef^^fb{\H u}
8698   \gdef^^fc{\"u}
8699   \gdef^^fd{\'y}
8700   \gdef^^fe{\cedilla t}
8701   \gdef^^ff{\dotaccent{}}
8702 }
8703
8704 % UTF-8 character definitions.
8705 %
8706 % This code to support UTF-8 is based on LaTeX's utf8.def, with some
8707 % changes for Texinfo conventions.  It is included here under the GPL by
8708 % permission from Frank Mittelbach and the LaTeX team.
8709 %
8710 \newcount\countUTFx
8711 \newcount\countUTFy
8712 \newcount\countUTFz
8713
8714 \gdef\UTFviiiTwoOctets#1#2{\expandafter
8715    \UTFviiiDefined\csname u8:#1\string #2\endcsname}
8716 %
8717 \gdef\UTFviiiThreeOctets#1#2#3{\expandafter
8718    \UTFviiiDefined\csname u8:#1\string #2\string #3\endcsname}
8719 %
8720 \gdef\UTFviiiFourOctets#1#2#3#4{\expandafter
8721    \UTFviiiDefined\csname u8:#1\string #2\string #3\string #4\endcsname}
8722
8723 \gdef\UTFviiiDefined#1{%
8724   \ifx #1\relax
8725     \message{\linenumber Unicode char \string #1 not defined for Texinfo}%
8726   \else
8727     \expandafter #1%
8728   \fi
8729 }
8730
8731 \begingroup
8732   \catcode`\~13
8733   \catcode`\"12
8734
8735   \def\UTFviiiLoop{%
8736     \global\catcode\countUTFx\active
8737     \uccode`\~\countUTFx
8738     \uppercase\expandafter{\UTFviiiTmp}%
8739     \advance\countUTFx by 1
8740     \ifnum\countUTFx < \countUTFy
8741       \expandafter\UTFviiiLoop
8742     \fi}
8743
8744   \countUTFx = "C2
8745   \countUTFy = "E0
8746   \def\UTFviiiTmp{%
8747     \xdef~{\noexpand\UTFviiiTwoOctets\string~}}
8748   \UTFviiiLoop
8749
8750   \countUTFx = "E0
8751   \countUTFy = "F0
8752   \def\UTFviiiTmp{%
8753     \xdef~{\noexpand\UTFviiiThreeOctets\string~}}
8754   \UTFviiiLoop
8755
8756   \countUTFx = "F0
8757   \countUTFy = "F4
8758   \def\UTFviiiTmp{%
8759     \xdef~{\noexpand\UTFviiiFourOctets\string~}}
8760   \UTFviiiLoop
8761 \endgroup
8762
8763 \begingroup
8764   \catcode`\"=12
8765   \catcode`\<=12
8766   \catcode`\.=12
8767   \catcode`\,=12
8768   \catcode`\;=12
8769   \catcode`\!=12
8770   \catcode`\~=13
8771
8772   \gdef\DeclareUnicodeCharacter#1#2{%
8773     \countUTFz = "#1\relax
8774     %\wlog{\space\space defining Unicode char U+#1 (decimal \the\countUTFz)}%
8775     \begingroup
8776       \parseXMLCharref
8777       \def\UTFviiiTwoOctets##1##2{%
8778         \csname u8:##1\string ##2\endcsname}%
8779       \def\UTFviiiThreeOctets##1##2##3{%
8780         \csname u8:##1\string ##2\string ##3\endcsname}%
8781       \def\UTFviiiFourOctets##1##2##3##4{%
8782         \csname u8:##1\string ##2\string ##3\string ##4\endcsname}%
8783       \expandafter\expandafter\expandafter\expandafter
8784        \expandafter\expandafter\expandafter
8785        \gdef\UTFviiiTmp{#2}%
8786     \endgroup}
8787
8788   \gdef\parseXMLCharref{%
8789     \ifnum\countUTFz < "A0\relax
8790       \errhelp = \EMsimple
8791       \errmessage{Cannot define Unicode char value < 00A0}%
8792     \else\ifnum\countUTFz < "800\relax
8793       \parseUTFviiiA,%
8794       \parseUTFviiiB C\UTFviiiTwoOctets.,%
8795     \else\ifnum\countUTFz < "10000\relax
8796       \parseUTFviiiA;%
8797       \parseUTFviiiA,%
8798       \parseUTFviiiB E\UTFviiiThreeOctets.{,;}%
8799     \else
8800       \parseUTFviiiA;%
8801       \parseUTFviiiA,%
8802       \parseUTFviiiA!%
8803       \parseUTFviiiB F\UTFviiiFourOctets.{!,;}%
8804     \fi\fi\fi
8805   }
8806
8807   \gdef\parseUTFviiiA#1{%
8808     \countUTFx = \countUTFz
8809     \divide\countUTFz by 64
8810     \countUTFy = \countUTFz
8811     \multiply\countUTFz by 64
8812     \advance\countUTFx by -\countUTFz
8813     \advance\countUTFx by 128
8814     \uccode `#1\countUTFx
8815     \countUTFz = \countUTFy}
8816
8817   \gdef\parseUTFviiiB#1#2#3#4{%
8818     \advance\countUTFz by "#10\relax
8819     \uccode `#3\countUTFz
8820     \uppercase{\gdef\UTFviiiTmp{#2#3#4}}}
8821 \endgroup
8822
8823 \def\utfeightchardefs{%
8824   \DeclareUnicodeCharacter{00A0}{\tie}
8825   \DeclareUnicodeCharacter{00A1}{\exclamdown}
8826   \DeclareUnicodeCharacter{00A3}{\pounds}
8827   \DeclareUnicodeCharacter{00A8}{\"{ }}
8828   \DeclareUnicodeCharacter{00A9}{\copyright}
8829   \DeclareUnicodeCharacter{00AA}{\ordf}
8830   \DeclareUnicodeCharacter{00AB}{\guillemetleft}
8831   \DeclareUnicodeCharacter{00AD}{\-}
8832   \DeclareUnicodeCharacter{00AE}{\registeredsymbol}
8833   \DeclareUnicodeCharacter{00AF}{\={ }}
8834
8835   \DeclareUnicodeCharacter{00B0}{\ringaccent{ }}
8836   \DeclareUnicodeCharacter{00B4}{\'{ }}
8837   \DeclareUnicodeCharacter{00B8}{\cedilla{ }}
8838   \DeclareUnicodeCharacter{00BA}{\ordm}
8839   \DeclareUnicodeCharacter{00BB}{\guillemetright}
8840   \DeclareUnicodeCharacter{00BF}{\questiondown}
8841
8842   \DeclareUnicodeCharacter{00C0}{\`A}
8843   \DeclareUnicodeCharacter{00C1}{\'A}
8844   \DeclareUnicodeCharacter{00C2}{\^A}
8845   \DeclareUnicodeCharacter{00C3}{\~A}
8846   \DeclareUnicodeCharacter{00C4}{\"A}
8847   \DeclareUnicodeCharacter{00C5}{\AA}
8848   \DeclareUnicodeCharacter{00C6}{\AE}
8849   \DeclareUnicodeCharacter{00C7}{\cedilla{C}}
8850   \DeclareUnicodeCharacter{00C8}{\`E}
8851   \DeclareUnicodeCharacter{00C9}{\'E}
8852   \DeclareUnicodeCharacter{00CA}{\^E}
8853   \DeclareUnicodeCharacter{00CB}{\"E}
8854   \DeclareUnicodeCharacter{00CC}{\`I}
8855   \DeclareUnicodeCharacter{00CD}{\'I}
8856   \DeclareUnicodeCharacter{00CE}{\^I}
8857   \DeclareUnicodeCharacter{00CF}{\"I}
8858
8859   \DeclareUnicodeCharacter{00D0}{\DH}
8860   \DeclareUnicodeCharacter{00D1}{\~N}
8861   \DeclareUnicodeCharacter{00D2}{\`O}
8862   \DeclareUnicodeCharacter{00D3}{\'O}
8863   \DeclareUnicodeCharacter{00D4}{\^O}
8864   \DeclareUnicodeCharacter{00D5}{\~O}
8865   \DeclareUnicodeCharacter{00D6}{\"O}
8866   \DeclareUnicodeCharacter{00D8}{\O}
8867   \DeclareUnicodeCharacter{00D9}{\`U}
8868   \DeclareUnicodeCharacter{00DA}{\'U}
8869   \DeclareUnicodeCharacter{00DB}{\^U}
8870   \DeclareUnicodeCharacter{00DC}{\"U}
8871   \DeclareUnicodeCharacter{00DD}{\'Y}
8872   \DeclareUnicodeCharacter{00DE}{\TH}
8873   \DeclareUnicodeCharacter{00DF}{\ss}
8874
8875   \DeclareUnicodeCharacter{00E0}{\`a}
8876   \DeclareUnicodeCharacter{00E1}{\'a}
8877   \DeclareUnicodeCharacter{00E2}{\^a}
8878   \DeclareUnicodeCharacter{00E3}{\~a}
8879   \DeclareUnicodeCharacter{00E4}{\"a}
8880   \DeclareUnicodeCharacter{00E5}{\aa}
8881   \DeclareUnicodeCharacter{00E6}{\ae}
8882   \DeclareUnicodeCharacter{00E7}{\cedilla{c}}
8883   \DeclareUnicodeCharacter{00E8}{\`e}
8884   \DeclareUnicodeCharacter{00E9}{\'e}
8885   \DeclareUnicodeCharacter{00EA}{\^e}
8886   \DeclareUnicodeCharacter{00EB}{\"e}
8887   \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}}
8888   \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}}
8889   \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}}
8890   \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}}
8891
8892   \DeclareUnicodeCharacter{00F0}{\dh}
8893   \DeclareUnicodeCharacter{00F1}{\~n}
8894   \DeclareUnicodeCharacter{00F2}{\`o}
8895   \DeclareUnicodeCharacter{00F3}{\'o}
8896   \DeclareUnicodeCharacter{00F4}{\^o}
8897   \DeclareUnicodeCharacter{00F5}{\~o}
8898   \DeclareUnicodeCharacter{00F6}{\"o}
8899   \DeclareUnicodeCharacter{00F8}{\o}
8900   \DeclareUnicodeCharacter{00F9}{\`u}
8901   \DeclareUnicodeCharacter{00FA}{\'u}
8902   \DeclareUnicodeCharacter{00FB}{\^u}
8903   \DeclareUnicodeCharacter{00FC}{\"u}
8904   \DeclareUnicodeCharacter{00FD}{\'y}
8905   \DeclareUnicodeCharacter{00FE}{\th}
8906   \DeclareUnicodeCharacter{00FF}{\"y}
8907
8908   \DeclareUnicodeCharacter{0100}{\=A}
8909   \DeclareUnicodeCharacter{0101}{\=a}
8910   \DeclareUnicodeCharacter{0102}{\u{A}}
8911   \DeclareUnicodeCharacter{0103}{\u{a}}
8912   \DeclareUnicodeCharacter{0104}{\ogonek{A}}
8913   \DeclareUnicodeCharacter{0105}{\ogonek{a}}
8914   \DeclareUnicodeCharacter{0106}{\'C}
8915   \DeclareUnicodeCharacter{0107}{\'c}
8916   \DeclareUnicodeCharacter{0108}{\^C}
8917   \DeclareUnicodeCharacter{0109}{\^c}
8918   \DeclareUnicodeCharacter{0118}{\ogonek{E}}
8919   \DeclareUnicodeCharacter{0119}{\ogonek{e}}
8920   \DeclareUnicodeCharacter{010A}{\dotaccent{C}}
8921   \DeclareUnicodeCharacter{010B}{\dotaccent{c}}
8922   \DeclareUnicodeCharacter{010C}{\v{C}}
8923   \DeclareUnicodeCharacter{010D}{\v{c}}
8924   \DeclareUnicodeCharacter{010E}{\v{D}}
8925
8926   \DeclareUnicodeCharacter{0112}{\=E}
8927   \DeclareUnicodeCharacter{0113}{\=e}
8928   \DeclareUnicodeCharacter{0114}{\u{E}}
8929   \DeclareUnicodeCharacter{0115}{\u{e}}
8930   \DeclareUnicodeCharacter{0116}{\dotaccent{E}}
8931   \DeclareUnicodeCharacter{0117}{\dotaccent{e}}
8932   \DeclareUnicodeCharacter{011A}{\v{E}}
8933   \DeclareUnicodeCharacter{011B}{\v{e}}
8934   \DeclareUnicodeCharacter{011C}{\^G}
8935   \DeclareUnicodeCharacter{011D}{\^g}
8936   \DeclareUnicodeCharacter{011E}{\u{G}}
8937   \DeclareUnicodeCharacter{011F}{\u{g}}
8938
8939   \DeclareUnicodeCharacter{0120}{\dotaccent{G}}
8940   \DeclareUnicodeCharacter{0121}{\dotaccent{g}}
8941   \DeclareUnicodeCharacter{0124}{\^H}
8942   \DeclareUnicodeCharacter{0125}{\^h}
8943   \DeclareUnicodeCharacter{0128}{\~I}
8944   \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}}
8945   \DeclareUnicodeCharacter{012A}{\=I}
8946   \DeclareUnicodeCharacter{012B}{\={\dotless{i}}}
8947   \DeclareUnicodeCharacter{012C}{\u{I}}
8948   \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}}
8949
8950   \DeclareUnicodeCharacter{0130}{\dotaccent{I}}
8951   \DeclareUnicodeCharacter{0131}{\dotless{i}}
8952   \DeclareUnicodeCharacter{0132}{IJ}
8953   \DeclareUnicodeCharacter{0133}{ij}
8954   \DeclareUnicodeCharacter{0134}{\^J}
8955   \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}}
8956   \DeclareUnicodeCharacter{0139}{\'L}
8957   \DeclareUnicodeCharacter{013A}{\'l}
8958
8959   \DeclareUnicodeCharacter{0141}{\L}
8960   \DeclareUnicodeCharacter{0142}{\l}
8961   \DeclareUnicodeCharacter{0143}{\'N}
8962   \DeclareUnicodeCharacter{0144}{\'n}
8963   \DeclareUnicodeCharacter{0147}{\v{N}}
8964   \DeclareUnicodeCharacter{0148}{\v{n}}
8965   \DeclareUnicodeCharacter{014C}{\=O}
8966   \DeclareUnicodeCharacter{014D}{\=o}
8967   \DeclareUnicodeCharacter{014E}{\u{O}}
8968   \DeclareUnicodeCharacter{014F}{\u{o}}
8969
8970   \DeclareUnicodeCharacter{0150}{\H{O}}
8971   \DeclareUnicodeCharacter{0151}{\H{o}}
8972   \DeclareUnicodeCharacter{0152}{\OE}
8973   \DeclareUnicodeCharacter{0153}{\oe}
8974   \DeclareUnicodeCharacter{0154}{\'R}
8975   \DeclareUnicodeCharacter{0155}{\'r}
8976   \DeclareUnicodeCharacter{0158}{\v{R}}
8977   \DeclareUnicodeCharacter{0159}{\v{r}}
8978   \DeclareUnicodeCharacter{015A}{\'S}
8979   \DeclareUnicodeCharacter{015B}{\'s}
8980   \DeclareUnicodeCharacter{015C}{\^S}
8981   \DeclareUnicodeCharacter{015D}{\^s}
8982   \DeclareUnicodeCharacter{015E}{\cedilla{S}}
8983   \DeclareUnicodeCharacter{015F}{\cedilla{s}}
8984
8985   \DeclareUnicodeCharacter{0160}{\v{S}}
8986   \DeclareUnicodeCharacter{0161}{\v{s}}
8987   \DeclareUnicodeCharacter{0162}{\cedilla{t}}
8988   \DeclareUnicodeCharacter{0163}{\cedilla{T}}
8989   \DeclareUnicodeCharacter{0164}{\v{T}}
8990
8991   \DeclareUnicodeCharacter{0168}{\~U}
8992   \DeclareUnicodeCharacter{0169}{\~u}
8993   \DeclareUnicodeCharacter{016A}{\=U}
8994   \DeclareUnicodeCharacter{016B}{\=u}
8995   \DeclareUnicodeCharacter{016C}{\u{U}}
8996   \DeclareUnicodeCharacter{016D}{\u{u}}
8997   \DeclareUnicodeCharacter{016E}{\ringaccent{U}}
8998   \DeclareUnicodeCharacter{016F}{\ringaccent{u}}
8999
9000   \DeclareUnicodeCharacter{0170}{\H{U}}
9001   \DeclareUnicodeCharacter{0171}{\H{u}}
9002   \DeclareUnicodeCharacter{0174}{\^W}
9003   \DeclareUnicodeCharacter{0175}{\^w}
9004   \DeclareUnicodeCharacter{0176}{\^Y}
9005   \DeclareUnicodeCharacter{0177}{\^y}
9006   \DeclareUnicodeCharacter{0178}{\"Y}
9007   \DeclareUnicodeCharacter{0179}{\'Z}
9008   \DeclareUnicodeCharacter{017A}{\'z}
9009   \DeclareUnicodeCharacter{017B}{\dotaccent{Z}}
9010   \DeclareUnicodeCharacter{017C}{\dotaccent{z}}
9011   \DeclareUnicodeCharacter{017D}{\v{Z}}
9012   \DeclareUnicodeCharacter{017E}{\v{z}}
9013
9014   \DeclareUnicodeCharacter{01C4}{D\v{Z}}
9015   \DeclareUnicodeCharacter{01C5}{D\v{z}}
9016   \DeclareUnicodeCharacter{01C6}{d\v{z}}
9017   \DeclareUnicodeCharacter{01C7}{LJ}
9018   \DeclareUnicodeCharacter{01C8}{Lj}
9019   \DeclareUnicodeCharacter{01C9}{lj}
9020   \DeclareUnicodeCharacter{01CA}{NJ}
9021   \DeclareUnicodeCharacter{01CB}{Nj}
9022   \DeclareUnicodeCharacter{01CC}{nj}
9023   \DeclareUnicodeCharacter{01CD}{\v{A}}
9024   \DeclareUnicodeCharacter{01CE}{\v{a}}
9025   \DeclareUnicodeCharacter{01CF}{\v{I}}
9026
9027   \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}}
9028   \DeclareUnicodeCharacter{01D1}{\v{O}}
9029   \DeclareUnicodeCharacter{01D2}{\v{o}}
9030   \DeclareUnicodeCharacter{01D3}{\v{U}}
9031   \DeclareUnicodeCharacter{01D4}{\v{u}}
9032
9033   \DeclareUnicodeCharacter{01E2}{\={\AE}}
9034   \DeclareUnicodeCharacter{01E3}{\={\ae}}
9035   \DeclareUnicodeCharacter{01E6}{\v{G}}
9036   \DeclareUnicodeCharacter{01E7}{\v{g}}
9037   \DeclareUnicodeCharacter{01E8}{\v{K}}
9038   \DeclareUnicodeCharacter{01E9}{\v{k}}
9039
9040   \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}}
9041   \DeclareUnicodeCharacter{01F1}{DZ}
9042   \DeclareUnicodeCharacter{01F2}{Dz}
9043   \DeclareUnicodeCharacter{01F3}{dz}
9044   \DeclareUnicodeCharacter{01F4}{\'G}
9045   \DeclareUnicodeCharacter{01F5}{\'g}
9046   \DeclareUnicodeCharacter{01F8}{\`N}
9047   \DeclareUnicodeCharacter{01F9}{\`n}
9048   \DeclareUnicodeCharacter{01FC}{\'{\AE}}
9049   \DeclareUnicodeCharacter{01FD}{\'{\ae}}
9050   \DeclareUnicodeCharacter{01FE}{\'{\O}}
9051   \DeclareUnicodeCharacter{01FF}{\'{\o}}
9052
9053   \DeclareUnicodeCharacter{021E}{\v{H}}
9054   \DeclareUnicodeCharacter{021F}{\v{h}}
9055
9056   \DeclareUnicodeCharacter{0226}{\dotaccent{A}}
9057   \DeclareUnicodeCharacter{0227}{\dotaccent{a}}
9058   \DeclareUnicodeCharacter{0228}{\cedilla{E}}
9059   \DeclareUnicodeCharacter{0229}{\cedilla{e}}
9060   \DeclareUnicodeCharacter{022E}{\dotaccent{O}}
9061   \DeclareUnicodeCharacter{022F}{\dotaccent{o}}
9062
9063   \DeclareUnicodeCharacter{0232}{\=Y}
9064   \DeclareUnicodeCharacter{0233}{\=y}
9065   \DeclareUnicodeCharacter{0237}{\dotless{j}}
9066
9067   \DeclareUnicodeCharacter{02DB}{\ogonek{ }}
9068
9069   \DeclareUnicodeCharacter{1E02}{\dotaccent{B}}
9070   \DeclareUnicodeCharacter{1E03}{\dotaccent{b}}
9071   \DeclareUnicodeCharacter{1E04}{\udotaccent{B}}
9072   \DeclareUnicodeCharacter{1E05}{\udotaccent{b}}
9073   \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}}
9074   \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}}
9075   \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}}
9076   \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}}
9077   \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}}
9078   \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}}
9079   \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}}
9080   \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}}
9081
9082   \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}}
9083   \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}}
9084
9085   \DeclareUnicodeCharacter{1E20}{\=G}
9086   \DeclareUnicodeCharacter{1E21}{\=g}
9087   \DeclareUnicodeCharacter{1E22}{\dotaccent{H}}
9088   \DeclareUnicodeCharacter{1E23}{\dotaccent{h}}
9089   \DeclareUnicodeCharacter{1E24}{\udotaccent{H}}
9090   \DeclareUnicodeCharacter{1E25}{\udotaccent{h}}
9091   \DeclareUnicodeCharacter{1E26}{\"H}
9092   \DeclareUnicodeCharacter{1E27}{\"h}
9093
9094   \DeclareUnicodeCharacter{1E30}{\'K}
9095   \DeclareUnicodeCharacter{1E31}{\'k}
9096   \DeclareUnicodeCharacter{1E32}{\udotaccent{K}}
9097   \DeclareUnicodeCharacter{1E33}{\udotaccent{k}}
9098   \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}}
9099   \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}}
9100   \DeclareUnicodeCharacter{1E36}{\udotaccent{L}}
9101   \DeclareUnicodeCharacter{1E37}{\udotaccent{l}}
9102   \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}}
9103   \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}}
9104   \DeclareUnicodeCharacter{1E3E}{\'M}
9105   \DeclareUnicodeCharacter{1E3F}{\'m}
9106
9107   \DeclareUnicodeCharacter{1E40}{\dotaccent{M}}
9108   \DeclareUnicodeCharacter{1E41}{\dotaccent{m}}
9109   \DeclareUnicodeCharacter{1E42}{\udotaccent{M}}
9110   \DeclareUnicodeCharacter{1E43}{\udotaccent{m}}
9111   \DeclareUnicodeCharacter{1E44}{\dotaccent{N}}
9112   \DeclareUnicodeCharacter{1E45}{\dotaccent{n}}
9113   \DeclareUnicodeCharacter{1E46}{\udotaccent{N}}
9114   \DeclareUnicodeCharacter{1E47}{\udotaccent{n}}
9115   \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}}
9116   \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}}
9117
9118   \DeclareUnicodeCharacter{1E54}{\'P}
9119   \DeclareUnicodeCharacter{1E55}{\'p}
9120   \DeclareUnicodeCharacter{1E56}{\dotaccent{P}}
9121   \DeclareUnicodeCharacter{1E57}{\dotaccent{p}}
9122   \DeclareUnicodeCharacter{1E58}{\dotaccent{R}}
9123   \DeclareUnicodeCharacter{1E59}{\dotaccent{r}}
9124   \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}}
9125   \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}}
9126   \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}}
9127   \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}}
9128
9129   \DeclareUnicodeCharacter{1E60}{\dotaccent{S}}
9130   \DeclareUnicodeCharacter{1E61}{\dotaccent{s}}
9131   \DeclareUnicodeCharacter{1E62}{\udotaccent{S}}
9132   \DeclareUnicodeCharacter{1E63}{\udotaccent{s}}
9133   \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}}
9134   \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}}
9135   \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}}
9136   \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}}
9137   \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}}
9138   \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}}
9139
9140   \DeclareUnicodeCharacter{1E7C}{\~V}
9141   \DeclareUnicodeCharacter{1E7D}{\~v}
9142   \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}}
9143   \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}}
9144
9145   \DeclareUnicodeCharacter{1E80}{\`W}
9146   \DeclareUnicodeCharacter{1E81}{\`w}
9147   \DeclareUnicodeCharacter{1E82}{\'W}
9148   \DeclareUnicodeCharacter{1E83}{\'w}
9149   \DeclareUnicodeCharacter{1E84}{\"W}
9150   \DeclareUnicodeCharacter{1E85}{\"w}
9151   \DeclareUnicodeCharacter{1E86}{\dotaccent{W}}
9152   \DeclareUnicodeCharacter{1E87}{\dotaccent{w}}
9153   \DeclareUnicodeCharacter{1E88}{\udotaccent{W}}
9154   \DeclareUnicodeCharacter{1E89}{\udotaccent{w}}
9155   \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}}
9156   \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}}
9157   \DeclareUnicodeCharacter{1E8C}{\"X}
9158   \DeclareUnicodeCharacter{1E8D}{\"x}
9159   \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}}
9160   \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}}
9161
9162   \DeclareUnicodeCharacter{1E90}{\^Z}
9163   \DeclareUnicodeCharacter{1E91}{\^z}
9164   \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}}
9165   \DeclareUnicodeCharacter{1E93}{\udotaccent{z}}
9166   \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}}
9167   \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}}
9168   \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}}
9169   \DeclareUnicodeCharacter{1E97}{\"t}
9170   \DeclareUnicodeCharacter{1E98}{\ringaccent{w}}
9171   \DeclareUnicodeCharacter{1E99}{\ringaccent{y}}
9172
9173   \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}}
9174   \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}}
9175
9176   \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}}
9177   \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}}
9178   \DeclareUnicodeCharacter{1EBC}{\~E}
9179   \DeclareUnicodeCharacter{1EBD}{\~e}
9180
9181   \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}}
9182   \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}}
9183   \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}}
9184   \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}}
9185
9186   \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}}
9187   \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}}
9188
9189   \DeclareUnicodeCharacter{1EF2}{\`Y}
9190   \DeclareUnicodeCharacter{1EF3}{\`y}
9191   \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}}
9192
9193   \DeclareUnicodeCharacter{1EF8}{\~Y}
9194   \DeclareUnicodeCharacter{1EF9}{\~y}
9195
9196   \DeclareUnicodeCharacter{2013}{--}
9197   \DeclareUnicodeCharacter{2014}{---}
9198   \DeclareUnicodeCharacter{2018}{\quoteleft}
9199   \DeclareUnicodeCharacter{2019}{\quoteright}
9200   \DeclareUnicodeCharacter{201A}{\quotesinglbase}
9201   \DeclareUnicodeCharacter{201C}{\quotedblleft}
9202   \DeclareUnicodeCharacter{201D}{\quotedblright}
9203   \DeclareUnicodeCharacter{201E}{\quotedblbase}
9204   \DeclareUnicodeCharacter{2022}{\bullet}
9205   \DeclareUnicodeCharacter{2026}{\dots}
9206   \DeclareUnicodeCharacter{2039}{\guilsinglleft}
9207   \DeclareUnicodeCharacter{203A}{\guilsinglright}
9208   \DeclareUnicodeCharacter{20AC}{\euro}
9209
9210   \DeclareUnicodeCharacter{2192}{\expansion}
9211   \DeclareUnicodeCharacter{21D2}{\result}
9212
9213   \DeclareUnicodeCharacter{2212}{\minus}
9214   \DeclareUnicodeCharacter{2217}{\point}
9215   \DeclareUnicodeCharacter{2261}{\equiv}
9216 }% end of \utfeightchardefs
9217
9218
9219 % US-ASCII character definitions.
9220 \def\asciichardefs{% nothing need be done
9221    \relax
9222 }
9223
9224 % Make non-ASCII characters printable again for compatibility with
9225 % existing Texinfo documents that may use them, even without declaring a
9226 % document encoding.
9227 %
9228 \setnonasciicharscatcode \other
9229
9230
9231 \message{formatting,}
9232
9233 \newdimen\defaultparindent \defaultparindent = 15pt
9234
9235 \chapheadingskip = 15pt plus 4pt minus 2pt
9236 \secheadingskip = 12pt plus 3pt minus 2pt
9237 \subsecheadingskip = 9pt plus 2pt minus 2pt
9238
9239 % Prevent underfull vbox error messages.
9240 \vbadness = 10000
9241
9242 % Don't be very finicky about underfull hboxes, either.
9243 \hbadness = 6666
9244
9245 % Following George Bush, get rid of widows and orphans.
9246 \widowpenalty=10000
9247 \clubpenalty=10000
9248
9249 % Use TeX 3.0's \emergencystretch to help line breaking, but if we're
9250 % using an old version of TeX, don't do anything.  We want the amount of
9251 % stretch added to depend on the line length, hence the dependence on
9252 % \hsize.  We call this whenever the paper size is set.
9253 %
9254 \def\setemergencystretch{%
9255   \ifx\emergencystretch\thisisundefined
9256     % Allow us to assign to \emergencystretch anyway.
9257     \def\emergencystretch{\dimen0}%
9258   \else
9259     \emergencystretch = .15\hsize
9260   \fi
9261 }
9262
9263 % Parameters in order: 1) textheight; 2) textwidth;
9264 % 3) voffset; 4) hoffset; 5) binding offset; 6) topskip;
9265 % 7) physical page height; 8) physical page width.
9266 %
9267 % We also call \setleading{\textleading}, so the caller should define
9268 % \textleading.  The caller should also set \parskip.
9269 %
9270 \def\internalpagesizes#1#2#3#4#5#6#7#8{%
9271   \voffset = #3\relax
9272   \topskip = #6\relax
9273   \splittopskip = \topskip
9274   %
9275   \vsize = #1\relax
9276   \advance\vsize by \topskip
9277   \outervsize = \vsize
9278   \advance\outervsize by 2\topandbottommargin
9279   \pageheight = \vsize
9280   %
9281   \hsize = #2\relax
9282   \outerhsize = \hsize
9283   \advance\outerhsize by 0.5in
9284   \pagewidth = \hsize
9285   %
9286   \normaloffset = #4\relax
9287   \bindingoffset = #5\relax
9288   %
9289   \ifpdf
9290     \pdfpageheight #7\relax
9291     \pdfpagewidth #8\relax
9292     % if we don't reset these, they will remain at "1 true in" of
9293     % whatever layout pdftex was dumped with.
9294     \pdfhorigin = 1 true in
9295     \pdfvorigin = 1 true in
9296   \fi
9297   %
9298   \setleading{\textleading}
9299   %
9300   \parindent = \defaultparindent
9301   \setemergencystretch
9302 }
9303
9304 % @letterpaper (the default).
9305 \def\letterpaper{{\globaldefs = 1
9306   \parskip = 3pt plus 2pt minus 1pt
9307   \textleading = 13.2pt
9308   %
9309   % If page is nothing but text, make it come out even.
9310   \internalpagesizes{607.2pt}{6in}% that's 46 lines
9311                     {\voffset}{.25in}%
9312                     {\bindingoffset}{36pt}%
9313                     {11in}{8.5in}%
9314 }}
9315
9316 % Use @smallbook to reset parameters for 7x9.25 trim size.
9317 \def\smallbook{{\globaldefs = 1
9318   \parskip = 2pt plus 1pt
9319   \textleading = 12pt
9320   %
9321   \internalpagesizes{7.5in}{5in}%
9322                     {-.2in}{0in}%
9323                     {\bindingoffset}{16pt}%
9324                     {9.25in}{7in}%
9325   %
9326   \lispnarrowing = 0.3in
9327   \tolerance = 700
9328   \hfuzz = 1pt
9329   \contentsrightmargin = 0pt
9330   \defbodyindent = .5cm
9331 }}
9332
9333 % Use @smallerbook to reset parameters for 6x9 trim size.
9334 % (Just testing, parameters still in flux.)
9335 \def\smallerbook{{\globaldefs = 1
9336   \parskip = 1.5pt plus 1pt
9337   \textleading = 12pt
9338   %
9339   \internalpagesizes{7.4in}{4.8in}%
9340                     {-.2in}{-.4in}%
9341                     {0pt}{14pt}%
9342                     {9in}{6in}%
9343   %
9344   \lispnarrowing = 0.25in
9345   \tolerance = 700
9346   \hfuzz = 1pt
9347   \contentsrightmargin = 0pt
9348   \defbodyindent = .4cm
9349 }}
9350
9351 % Use @afourpaper to print on European A4 paper.
9352 \def\afourpaper{{\globaldefs = 1
9353   \parskip = 3pt plus 2pt minus 1pt
9354   \textleading = 13.2pt
9355   %
9356   % Double-side printing via postscript on Laserjet 4050
9357   % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm.
9358   % To change the settings for a different printer or situation, adjust
9359   % \normaloffset until the front-side and back-side texts align.  Then
9360   % do the same for \bindingoffset.  You can set these for testing in
9361   % your texinfo source file like this:
9362   % @tex
9363   % \global\normaloffset = -6mm
9364   % \global\bindingoffset = 10mm
9365   % @end tex
9366   \internalpagesizes{673.2pt}{160mm}% that's 51 lines
9367                     {\voffset}{\hoffset}%
9368                     {\bindingoffset}{44pt}%
9369                     {297mm}{210mm}%
9370   %
9371   \tolerance = 700
9372   \hfuzz = 1pt
9373   \contentsrightmargin = 0pt
9374   \defbodyindent = 5mm
9375 }}
9376
9377 % Use @afivepaper to print on European A5 paper.
9378 % From romildo@urano.iceb.ufop.br, 2 July 2000.
9379 % He also recommends making @example and @lisp be small.
9380 \def\afivepaper{{\globaldefs = 1
9381   \parskip = 2pt plus 1pt minus 0.1pt
9382   \textleading = 12.5pt
9383   %
9384   \internalpagesizes{160mm}{120mm}%
9385                     {\voffset}{\hoffset}%
9386                     {\bindingoffset}{8pt}%
9387                     {210mm}{148mm}%
9388   %
9389   \lispnarrowing = 0.2in
9390   \tolerance = 800
9391   \hfuzz = 1.2pt
9392   \contentsrightmargin = 0pt
9393   \defbodyindent = 2mm
9394   \tableindent = 12mm
9395 }}
9396
9397 % A specific text layout, 24x15cm overall, intended for A4 paper.
9398 \def\afourlatex{{\globaldefs = 1
9399   \afourpaper
9400   \internalpagesizes{237mm}{150mm}%
9401                     {\voffset}{4.6mm}%
9402                     {\bindingoffset}{7mm}%
9403                     {297mm}{210mm}%
9404   %
9405   % Must explicitly reset to 0 because we call \afourpaper.
9406   \globaldefs = 0
9407 }}
9408
9409 % Use @afourwide to print on A4 paper in landscape format.
9410 \def\afourwide{{\globaldefs = 1
9411   \afourpaper
9412   \internalpagesizes{241mm}{165mm}%
9413                     {\voffset}{-2.95mm}%
9414                     {\bindingoffset}{7mm}%
9415                     {297mm}{210mm}%
9416   \globaldefs = 0
9417 }}
9418
9419 % @pagesizes TEXTHEIGHT[,TEXTWIDTH]
9420 % Perhaps we should allow setting the margins, \topskip, \parskip,
9421 % and/or leading, also. Or perhaps we should compute them somehow.
9422 %
9423 \parseargdef\pagesizes{\pagesizesyyy #1,,\finish}
9424 \def\pagesizesyyy#1,#2,#3\finish{{%
9425   \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi
9426   \globaldefs = 1
9427   %
9428   \parskip = 3pt plus 2pt minus 1pt
9429   \setleading{\textleading}%
9430   %
9431   \dimen0 = #1\relax
9432   \advance\dimen0 by \voffset
9433   %
9434   \dimen2 = \hsize
9435   \advance\dimen2 by \normaloffset
9436   %
9437   \internalpagesizes{#1}{\hsize}%
9438                     {\voffset}{\normaloffset}%
9439                     {\bindingoffset}{44pt}%
9440                     {\dimen0}{\dimen2}%
9441 }}
9442
9443 % Set default to letter.
9444 %
9445 \letterpaper
9446
9447
9448 \message{and turning on texinfo input format.}
9449
9450 \def^^L{\par} % remove \outer, so ^L can appear in an @comment
9451
9452 % DEL is a comment character, in case @c does not suffice.
9453 \catcode`\^^? = 14
9454
9455 % Define macros to output various characters with catcode for normal text.
9456 \catcode`\"=\other \def\normaldoublequote{"}
9457 \catcode`\$=\other \def\normaldollar{$}%$ font-lock fix
9458 \catcode`\+=\other \def\normalplus{+}
9459 \catcode`\<=\other \def\normalless{<}
9460 \catcode`\>=\other \def\normalgreater{>}
9461 \catcode`\^=\other \def\normalcaret{^}
9462 \catcode`\_=\other \def\normalunderscore{_}
9463 \catcode`\|=\other \def\normalverticalbar{|}
9464 \catcode`\~=\other \def\normaltilde{~}
9465
9466 % This macro is used to make a character print one way in \tt
9467 % (where it can probably be output as-is), and another way in other fonts,
9468 % where something hairier probably needs to be done.
9469 %
9470 % #1 is what to print if we are indeed using \tt; #2 is what to print
9471 % otherwise.  Since all the Computer Modern typewriter fonts have zero
9472 % interword stretch (and shrink), and it is reasonable to expect all
9473 % typewriter fonts to have this, we can check that font parameter.
9474 %
9475 \def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi}
9476
9477 % Same as above, but check for italic font.  Actually this also catches
9478 % non-italic slanted fonts since it is impossible to distinguish them from
9479 % italic fonts.  But since this is only used by $ and it uses \sl anyway
9480 % this is not a problem.
9481 \def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi}
9482
9483 % Turn off all special characters except @
9484 % (and those which the user can use as if they were ordinary).
9485 % Most of these we simply print from the \tt font, but for some, we can
9486 % use math or other variants that look better in normal text.
9487
9488 \catcode`\"=\active
9489 \def\activedoublequote{{\tt\char34}}
9490 \let"=\activedoublequote
9491 \catcode`\~=\active
9492 \def~{{\tt\char126}}
9493 \chardef\hat=`\^
9494 \catcode`\^=\active
9495 \def^{{\tt \hat}}
9496
9497 \catcode`\_=\active
9498 \def_{\ifusingtt\normalunderscore\_}
9499 \let\realunder=_
9500 % Subroutine for the previous macro.
9501 \def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }
9502
9503 \catcode`\|=\active
9504 \def|{{\tt\char124}}
9505 \chardef \less=`\<
9506 \catcode`\<=\active
9507 \def<{{\tt \less}}
9508 \chardef \gtr=`\>
9509 \catcode`\>=\active
9510 \def>{{\tt \gtr}}
9511 \catcode`\+=\active
9512 \def+{{\tt \char 43}}
9513 \catcode`\$=\active
9514 \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix
9515
9516 % If a .fmt file is being used, characters that might appear in a file
9517 % name cannot be active until we have parsed the command line.
9518 % So turn them off again, and have \everyjob (or @setfilename) turn them on.
9519 % \otherifyactive is called near the end of this file.
9520 \def\otherifyactive{\catcode`+=\other \catcode`\_=\other}
9521
9522 % Used sometimes to turn off (effectively) the active characters even after
9523 % parsing them.
9524 \def\turnoffactive{%
9525   \normalturnoffactive
9526   \otherbackslash
9527 }
9528
9529 \catcode`\@=0
9530
9531 % \backslashcurfont outputs one backslash character in current font,
9532 % as in \char`\\.
9533 \global\chardef\backslashcurfont=`\\
9534 \global\let\rawbackslashxx=\backslashcurfont  % let existing .??s files work
9535
9536 % \realbackslash is an actual character `\' with catcode other, and
9537 % \doublebackslash is two of them (for the pdf outlines).
9538 {\catcode`\\=\other @gdef@realbackslash{\} @gdef@doublebackslash{\\}}
9539
9540 % In texinfo, backslash is an active character; it prints the backslash
9541 % in fixed width font.
9542 \catcode`\\=\active
9543 @def@normalbackslash{{@tt@backslashcurfont}}
9544 % On startup, @fixbackslash assigns:
9545 %  @let \ = @normalbackslash
9546
9547 % \rawbackslash defines an active \ to do \backslashcurfont.
9548 % \otherbackslash defines an active \ to be a literal `\' character with
9549 % catcode other.
9550 @gdef@rawbackslash{@let\=@backslashcurfont}
9551 @gdef@otherbackslash{@let\=@realbackslash}
9552
9553 % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
9554 % the literal character `\'.
9555 %
9556 @def@normalturnoffactive{%
9557   @let"=@normaldoublequote
9558   @let$=@normaldollar %$ font-lock fix
9559   @let+=@normalplus
9560   @let<=@normalless
9561   @let>=@normalgreater
9562   @let\=@normalbackslash
9563   @let^=@normalcaret
9564   @let_=@normalunderscore
9565   @let|=@normalverticalbar
9566   @let~=@normaltilde
9567   @markupsetuplqdefault
9568   @markupsetuprqdefault
9569   @unsepspaces
9570 }
9571
9572 % Make _ and + \other characters, temporarily.
9573 % This is canceled by @fixbackslash.
9574 @otherifyactive
9575
9576 % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
9577 % That is what \eatinput is for; after that, the `\' should revert to printing
9578 % a backslash.
9579 %
9580 @gdef@eatinput input texinfo{@fixbackslash}
9581 @global@let\ = @eatinput
9582
9583 % On the other hand, perhaps the file did not have a `\input texinfo'. Then
9584 % the first `\' in the file would cause an error. This macro tries to fix
9585 % that, assuming it is called before the first `\' could plausibly occur.
9586 % Also turn back on active characters that might appear in the input
9587 % file name, in case not using a pre-dumped format.
9588 %
9589 @gdef@fixbackslash{%
9590   @ifx\@eatinput @let\ = @normalbackslash @fi
9591   @catcode`+=@active
9592   @catcode`@_=@active
9593 }
9594
9595 % Say @foo, not \foo, in error messages.
9596 @escapechar = `@@
9597
9598 % These (along with & and #) are made active for url-breaking, so need
9599 % active definitions as the normal characters.
9600 @def@normaldot{.}
9601 @def@normalquest{?}
9602 @def@normalslash{/}
9603
9604 % These look ok in all fonts, so just make them not special.
9605 @catcode`@& = @other @def@normalamp{&}
9606 @catcode`@# = @other @def@normalhash{#}
9607 @catcode`@% = @other @def@normalpercent{%}
9608
9609 @c Finally, make ` and ' active, so that txicodequoteundirected and
9610 @c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}.  If we
9611 @c don't make ` and ' active, @code will not get them as active chars.
9612 @c Do this last of all since we use ` in the previous @catcode assignments.
9613 @catcode`@'=@active
9614 @catcode`@`=@active
9615 @markupsetuplqdefault
9616 @markupsetuprqdefault
9617
9618 @c Local variables:
9619 @c eval: (add-hook 'write-file-hooks 'time-stamp)
9620 @c page-delimiter: "^\\\\message"
9621 @c time-stamp-start: "def\\\\texinfoversion{"
9622 @c time-stamp-format: "%:y-%02m-%02d.%02H"
9623 @c time-stamp-end: "}"
9624 @c End:
9625
9626 @c vim:sw=2:
9627
9628 @ignore
9629    arch-tag: e1b36e32-c96e-4135-a41a-0b2efa2ea115
9630 @end ignore