maint.mk: relax the default _gl_TS_function_match regexp
[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-05-23.16}
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   %
5859   %   @section sec-whatever
5860   %   @deffn def-whatever
5861   \penalty 10001
5862 }
5863
5864
5865 \message{toc,}
5866 % Table of contents.
5867 \newwrite\tocfile
5868
5869 % Write an entry to the toc file, opening it if necessary.
5870 % Called from @chapter, etc.
5871 %
5872 % Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno}
5873 % We append the current node name (if any) and page number as additional
5874 % arguments for the \{chap,sec,...}entry macros which will eventually
5875 % read this.  The node name is used in the pdf outlines as the
5876 % destination to jump to.
5877 %
5878 % We open the .toc file for writing here instead of at @setfilename (or
5879 % any other fixed time) so that @contents can be anywhere in the document.
5880 % But if #1 is `omit', then we don't do anything.  This is used for the
5881 % table of contents chapter openings themselves.
5882 %
5883 \newif\iftocfileopened
5884 \def\omitkeyword{omit}%
5885 %
5886 \def\writetocentry#1#2#3{%
5887   \edef\writetoctype{#1}%
5888   \ifx\writetoctype\omitkeyword \else
5889     \iftocfileopened\else
5890       \immediate\openout\tocfile = \jobname.toc
5891       \global\tocfileopenedtrue
5892     \fi
5893     %
5894     \iflinks
5895       {\atdummies
5896        \edef\temp{%
5897          \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}%
5898        \temp
5899       }%
5900     \fi
5901   \fi
5902   %
5903   % Tell \shipout to create a pdf destination on each page, if we're
5904   % writing pdf.  These are used in the table of contents.  We can't
5905   % just write one on every page because the title pages are numbered
5906   % 1 and 2 (the page numbers aren't printed), and so are the first
5907   % two pages of the document.  Thus, we'd have two destinations named
5908   % `1', and two named `2'.
5909   \ifpdf \global\pdfmakepagedesttrue \fi
5910 }
5911
5912
5913 % These characters do not print properly in the Computer Modern roman
5914 % fonts, so we must take special care.  This is more or less redundant
5915 % with the Texinfo input format setup at the end of this file.
5916 %
5917 \def\activecatcodes{%
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   \catcode`\~=\active
5927 }
5928
5929
5930 % Read the toc file, which is essentially Texinfo input.
5931 \def\readtocfile{%
5932   \setupdatafile
5933   \activecatcodes
5934   \input \tocreadfilename
5935 }
5936
5937 \newskip\contentsrightmargin \contentsrightmargin=1in
5938 \newcount\savepageno
5939 \newcount\lastnegativepageno \lastnegativepageno = -1
5940
5941 % Prepare to read what we've written to \tocfile.
5942 %
5943 \def\startcontents#1{%
5944   % If @setchapternewpage on, and @headings double, the contents should
5945   % start on an odd page, unlike chapters.  Thus, we maintain
5946   % \contentsalignmacro in parallel with \pagealignmacro.
5947   % From: Torbjorn Granlund <tege@matematik.su.se>
5948   \contentsalignmacro
5949   \immediate\closeout\tocfile
5950   %
5951   % Don't need to put `Contents' or `Short Contents' in the headline.
5952   % It is abundantly clear what they are.
5953   \chapmacro{#1}{Yomitfromtoc}{}%
5954   %
5955   \savepageno = \pageno
5956   \begingroup                  % Set up to handle contents files properly.
5957     \raggedbottom              % Worry more about breakpoints than the bottom.
5958     \advance\hsize by -\contentsrightmargin % Don't use the full line length.
5959     %
5960     % Roman numerals for page numbers.
5961     \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
5962 }
5963
5964 % redefined for the two-volume lispref.  We always output on
5965 % \jobname.toc even if this is redefined.
5966 %
5967 \def\tocreadfilename{\jobname.toc}
5968
5969 % Normal (long) toc.
5970 %
5971 \def\contents{%
5972   \startcontents{\putwordTOC}%
5973     \openin 1 \tocreadfilename\space
5974     \ifeof 1 \else
5975       \readtocfile
5976     \fi
5977     \vfill \eject
5978     \contentsalignmacro % in case @setchapternewpage odd is in effect
5979     \ifeof 1 \else
5980       \pdfmakeoutlines
5981     \fi
5982     \closein 1
5983   \endgroup
5984   \lastnegativepageno = \pageno
5985   \global\pageno = \savepageno
5986 }
5987
5988 % And just the chapters.
5989 \def\summarycontents{%
5990   \startcontents{\putwordShortTOC}%
5991     %
5992     \let\partentry = \shortpartentry
5993     \let\numchapentry = \shortchapentry
5994     \let\appentry = \shortchapentry
5995     \let\unnchapentry = \shortunnchapentry
5996     % We want a true roman here for the page numbers.
5997     \secfonts
5998     \let\rm=\shortcontrm \let\bf=\shortcontbf
5999     \let\sl=\shortcontsl \let\tt=\shortconttt
6000     \rm
6001     \hyphenpenalty = 10000
6002     \advance\baselineskip by 1pt % Open it up a little.
6003     \def\numsecentry##1##2##3##4{}
6004     \let\appsecentry = \numsecentry
6005     \let\unnsecentry = \numsecentry
6006     \let\numsubsecentry = \numsecentry
6007     \let\appsubsecentry = \numsecentry
6008     \let\unnsubsecentry = \numsecentry
6009     \let\numsubsubsecentry = \numsecentry
6010     \let\appsubsubsecentry = \numsecentry
6011     \let\unnsubsubsecentry = \numsecentry
6012     \openin 1 \tocreadfilename\space
6013     \ifeof 1 \else
6014       \readtocfile
6015     \fi
6016     \closein 1
6017     \vfill \eject
6018     \contentsalignmacro % in case @setchapternewpage odd is in effect
6019   \endgroup
6020   \lastnegativepageno = \pageno
6021   \global\pageno = \savepageno
6022 }
6023 \let\shortcontents = \summarycontents
6024
6025 % Typeset the label for a chapter or appendix for the short contents.
6026 % The arg is, e.g., `A' for an appendix, or `3' for a chapter.
6027 %
6028 \def\shortchaplabel#1{%
6029   % This space should be enough, since a single number is .5em, and the
6030   % widest letter (M) is 1em, at least in the Computer Modern fonts.
6031   % But use \hss just in case.
6032   % (This space doesn't include the extra space that gets added after
6033   % the label; that gets put in by \shortchapentry above.)
6034   %
6035   % We'd like to right-justify chapter numbers, but that looks strange
6036   % with appendix letters.  And right-justifying numbers and
6037   % left-justifying letters looks strange when there is less than 10
6038   % chapters.  Have to read the whole toc once to know how many chapters
6039   % there are before deciding ...
6040   \hbox to 1em{#1\hss}%
6041 }
6042
6043 % These macros generate individual entries in the table of contents.
6044 % The first argument is the chapter or section name.
6045 % The last argument is the page number.
6046 % The arguments in between are the chapter number, section number, ...
6047
6048 % Parts, in the main contents.  Replace the part number, which doesn't
6049 % exist, with an empty box.  Let's hope all the numbers have the same width.
6050 % Also ignore the page number, which is conventionally not printed.
6051 \def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}}
6052 \def\partentry#1#2#3#4{\dochapentry{\numeralbox\labelspace#1}{}}
6053 %
6054 % Parts, in the short toc.
6055 \def\shortpartentry#1#2#3#4{%
6056   \penalty-300
6057   \vskip.5\baselineskip plus.15\baselineskip minus.1\baselineskip
6058   \shortchapentry{{\bf #1}}{\numeralbox}{}{}%
6059 }
6060
6061 % Chapters, in the main contents.
6062 \def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}}
6063 %
6064 % Chapters, in the short toc.
6065 % See comments in \dochapentry re vbox and related settings.
6066 \def\shortchapentry#1#2#3#4{%
6067   \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}%
6068 }
6069
6070 % Appendices, in the main contents.
6071 % Need the word Appendix, and a fixed-size box.
6072 %
6073 \def\appendixbox#1{%
6074   % We use M since it's probably the widest letter.
6075   \setbox0 = \hbox{\putwordAppendix{} M}%
6076   \hbox to \wd0{\putwordAppendix{} #1\hss}}
6077 %
6078 \def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\labelspace#1}{#4}}
6079
6080 % Unnumbered chapters.
6081 \def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}}
6082 \def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}}
6083
6084 % Sections.
6085 \def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}}
6086 \let\appsecentry=\numsecentry
6087 \def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}}
6088
6089 % Subsections.
6090 \def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}}
6091 \let\appsubsecentry=\numsubsecentry
6092 \def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}}
6093
6094 % And subsubsections.
6095 \def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}}
6096 \let\appsubsubsecentry=\numsubsubsecentry
6097 \def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}}
6098
6099 % This parameter controls the indentation of the various levels.
6100 % Same as \defaultparindent.
6101 \newdimen\tocindent \tocindent = 15pt
6102
6103 % Now for the actual typesetting. In all these, #1 is the text and #2 is the
6104 % page number.
6105 %
6106 % If the toc has to be broken over pages, we want it to be at chapters
6107 % if at all possible; hence the \penalty.
6108 \def\dochapentry#1#2{%
6109    \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
6110    \begingroup
6111      \chapentryfonts
6112      \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6113    \endgroup
6114    \nobreak\vskip .25\baselineskip plus.1\baselineskip
6115 }
6116
6117 \def\dosecentry#1#2{\begingroup
6118   \secentryfonts \leftskip=\tocindent
6119   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6120 \endgroup}
6121
6122 \def\dosubsecentry#1#2{\begingroup
6123   \subsecentryfonts \leftskip=2\tocindent
6124   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6125 \endgroup}
6126
6127 \def\dosubsubsecentry#1#2{\begingroup
6128   \subsubsecentryfonts \leftskip=3\tocindent
6129   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6130 \endgroup}
6131
6132 % We use the same \entry macro as for the index entries.
6133 \let\tocentry = \entry
6134
6135 % Space between chapter (or whatever) number and the title.
6136 \def\labelspace{\hskip1em \relax}
6137
6138 \def\dopageno#1{{\rm #1}}
6139 \def\doshortpageno#1{{\rm #1}}
6140
6141 \def\chapentryfonts{\secfonts \rm}
6142 \def\secentryfonts{\textfonts}
6143 \def\subsecentryfonts{\textfonts}
6144 \def\subsubsecentryfonts{\textfonts}
6145
6146
6147 \message{environments,}
6148 % @foo ... @end foo.
6149
6150 % @tex ... @end tex    escapes into raw TeX temporarily.
6151 % One exception: @ is still an escape character, so that @end tex works.
6152 % But \@ or @@ will get a plain @ character.
6153
6154 \envdef\tex{%
6155   \setupmarkupstyle{tex}%
6156   \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
6157   \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
6158   \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
6159   \catcode `\%=14
6160   \catcode `\+=\other
6161   \catcode `\"=\other
6162   \catcode `\|=\other
6163   \catcode `\<=\other
6164   \catcode `\>=\other
6165   \catcode`\`=\other
6166   \catcode`\'=\other
6167   \escapechar=`\\
6168   %
6169   % ' is active in math mode (mathcode"8000).  So reset it, and all our
6170   % other math active characters (just in case), to plain's definitions.
6171   \mathactive
6172   %
6173   \let\b=\ptexb
6174   \let\bullet=\ptexbullet
6175   \let\c=\ptexc
6176   \let\,=\ptexcomma
6177   \let\.=\ptexdot
6178   \let\dots=\ptexdots
6179   \let\equiv=\ptexequiv
6180   \let\!=\ptexexclam
6181   \let\i=\ptexi
6182   \let\indent=\ptexindent
6183   \let\noindent=\ptexnoindent
6184   \let\{=\ptexlbrace
6185   \let\+=\tabalign
6186   \let\}=\ptexrbrace
6187   \let\/=\ptexslash
6188   \let\*=\ptexstar
6189   \let\t=\ptext
6190   \expandafter \let\csname top\endcsname=\ptextop  % outer
6191   \let\frenchspacing=\plainfrenchspacing
6192   %
6193   \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
6194   \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
6195   \def\@{@}%
6196 }
6197 % There is no need to define \Etex.
6198
6199 % Define @lisp ... @end lisp.
6200 % @lisp environment forms a group so it can rebind things,
6201 % including the definition of @end lisp (which normally is erroneous).
6202
6203 % Amount to narrow the margins by for @lisp.
6204 \newskip\lispnarrowing \lispnarrowing=0.4in
6205
6206 % This is the definition that ^^M gets inside @lisp, @example, and other
6207 % such environments.  \null is better than a space, since it doesn't
6208 % have any width.
6209 \def\lisppar{\null\endgraf}
6210
6211 % This space is always present above and below environments.
6212 \newskip\envskipamount \envskipamount = 0pt
6213
6214 % Make spacing and below environment symmetrical.  We use \parskip here
6215 % to help in doing that, since in @example-like environments \parskip
6216 % is reset to zero; thus the \afterenvbreak inserts no space -- but the
6217 % start of the next paragraph will insert \parskip.
6218 %
6219 \def\aboveenvbreak{{%
6220   % =10000 instead of <10000 because of a special case in \itemzzz and
6221   % \sectionheading, q.v.
6222   \ifnum \lastpenalty=10000 \else
6223     \advance\envskipamount by \parskip
6224     \endgraf
6225     \ifdim\lastskip<\envskipamount
6226       \removelastskip
6227       % it's not a good place to break if the last penalty was \nobreak
6228       % or better ...
6229       \ifnum\lastpenalty<10000 \penalty-50 \fi
6230       \vskip\envskipamount
6231     \fi
6232   \fi
6233 }}
6234
6235 \let\afterenvbreak = \aboveenvbreak
6236
6237 % \nonarrowing is a flag.  If "set", @lisp etc don't narrow margins; it will
6238 % also clear it, so that its embedded environments do the narrowing again.
6239 \let\nonarrowing=\relax
6240
6241 % @cartouche ... @end cartouche: draw rectangle w/rounded corners around
6242 % environment contents.
6243 \font\circle=lcircle10
6244 \newdimen\circthick
6245 \newdimen\cartouter\newdimen\cartinner
6246 \newskip\normbskip\newskip\normpskip\newskip\normlskip
6247 \circthick=\fontdimen8\circle
6248 %
6249 \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
6250 \def\ctr{{\hskip 6pt\circle\char'010}}
6251 \def\cbl{{\circle\char'012\hskip -6pt}}
6252 \def\cbr{{\hskip 6pt\circle\char'011}}
6253 \def\carttop{\hbox to \cartouter{\hskip\lskip
6254         \ctl\leaders\hrule height\circthick\hfil\ctr
6255         \hskip\rskip}}
6256 \def\cartbot{\hbox to \cartouter{\hskip\lskip
6257         \cbl\leaders\hrule height\circthick\hfil\cbr
6258         \hskip\rskip}}
6259 %
6260 \newskip\lskip\newskip\rskip
6261
6262 \envdef\cartouche{%
6263   \ifhmode\par\fi  % can't be in the midst of a paragraph.
6264   \startsavinginserts
6265   \lskip=\leftskip \rskip=\rightskip
6266   \leftskip=0pt\rightskip=0pt % we want these *outside*.
6267   \cartinner=\hsize \advance\cartinner by-\lskip
6268   \advance\cartinner by-\rskip
6269   \cartouter=\hsize
6270   \advance\cartouter by 18.4pt  % allow for 3pt kerns on either
6271                                 % side, and for 6pt waste from
6272                                 % each corner char, and rule thickness
6273   \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
6274   % Flag to tell @lisp, etc., not to narrow margin.
6275   \let\nonarrowing = t%
6276   \vbox\bgroup
6277       \baselineskip=0pt\parskip=0pt\lineskip=0pt
6278       \carttop
6279       \hbox\bgroup
6280           \hskip\lskip
6281           \vrule\kern3pt
6282           \vbox\bgroup
6283               \kern3pt
6284               \hsize=\cartinner
6285               \baselineskip=\normbskip
6286               \lineskip=\normlskip
6287               \parskip=\normpskip
6288               \vskip -\parskip
6289               \comment % For explanation, see the end of \def\group.
6290 }
6291 \def\Ecartouche{%
6292               \ifhmode\par\fi
6293               \kern3pt
6294           \egroup
6295           \kern3pt\vrule
6296           \hskip\rskip
6297       \egroup
6298       \cartbot
6299   \egroup
6300   \checkinserts
6301 }
6302
6303
6304 % This macro is called at the beginning of all the @example variants,
6305 % inside a group.
6306 \newdimen\nonfillparindent
6307 \def\nonfillstart{%
6308   \aboveenvbreak
6309   \hfuzz = 12pt % Don't be fussy
6310   \sepspaces % Make spaces be word-separators rather than space tokens.
6311   \let\par = \lisppar % don't ignore blank lines
6312   \obeylines % each line of input is a line of output
6313   \parskip = 0pt
6314   % Turn off paragraph indentation but redefine \indent to emulate
6315   % the normal \indent.
6316   \nonfillparindent=\parindent
6317   \parindent = 0pt
6318   \let\indent\nonfillindent
6319   %
6320   \emergencystretch = 0pt % don't try to avoid overfull boxes
6321   \ifx\nonarrowing\relax
6322     \advance \leftskip by \lispnarrowing
6323     \exdentamount=\lispnarrowing
6324   \else
6325     \let\nonarrowing = \relax
6326   \fi
6327   \let\exdent=\nofillexdent
6328 }
6329
6330 \begingroup
6331 \obeyspaces
6332 % We want to swallow spaces (but not other tokens) after the fake
6333 % @indent in our nonfill-environments, where spaces are normally
6334 % active and set to @tie, resulting in them not being ignored after
6335 % @indent.
6336 \gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}%
6337 \gdef\nonfillindentcheck{%
6338 \ifx\temp %
6339 \expandafter\nonfillindentgobble%
6340 \else%
6341 \leavevmode\nonfillindentbox%
6342 \fi%
6343 }%
6344 \endgroup
6345 \def\nonfillindentgobble#1{\nonfillindent}
6346 \def\nonfillindentbox{\hbox to \nonfillparindent{\hss}}
6347
6348 % If you want all examples etc. small: @set dispenvsize small.
6349 % If you want even small examples the full size: @set dispenvsize nosmall.
6350 % This affects the following displayed environments:
6351 %    @example, @display, @format, @lisp
6352 %
6353 \def\smallword{small}
6354 \def\nosmallword{nosmall}
6355 \let\SETdispenvsize\relax
6356 \def\setnormaldispenv{%
6357   \ifx\SETdispenvsize\smallword
6358     % end paragraph for sake of leading, in case document has no blank
6359     % line.  This is redundant with what happens in \aboveenvbreak, but
6360     % we need to do it before changing the fonts, and it's inconvenient
6361     % to change the fonts afterward.
6362     \ifnum \lastpenalty=10000 \else \endgraf \fi
6363     \smallexamplefonts \rm
6364   \fi
6365 }
6366 \def\setsmalldispenv{%
6367   \ifx\SETdispenvsize\nosmallword
6368   \else
6369     \ifnum \lastpenalty=10000 \else \endgraf \fi
6370     \smallexamplefonts \rm
6371   \fi
6372 }
6373
6374 % We often define two environments, @foo and @smallfoo.
6375 % Let's do it in one command.  #1 is the env name, #2 the definition.
6376 \def\makedispenvdef#1#2{%
6377   \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}%
6378   \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}%
6379   \expandafter\let\csname E#1\endcsname \afterenvbreak
6380   \expandafter\let\csname Esmall#1\endcsname \afterenvbreak
6381 }
6382
6383 % Define two environment synonyms (#1 and #2) for an environment.
6384 \def\maketwodispenvdef#1#2#3{%
6385   \makedispenvdef{#1}{#3}%
6386   \makedispenvdef{#2}{#3}%
6387 }
6388 %
6389 % @lisp: indented, narrowed, typewriter font;
6390 % @example: same as @lisp.
6391 %
6392 % @smallexample and @smalllisp: use smaller fonts.
6393 % Originally contributed by Pavel@xerox.
6394 %
6395 \maketwodispenvdef{lisp}{example}{%
6396   \nonfillstart
6397   \tt\setupmarkupstyle{example}%
6398   \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
6399   \gobble % eat return
6400 }
6401 % @display/@smalldisplay: same as @lisp except keep current font.
6402 %
6403 \makedispenvdef{display}{%
6404   \nonfillstart
6405   \gobble
6406 }
6407
6408 % @format/@smallformat: same as @display except don't narrow margins.
6409 %
6410 \makedispenvdef{format}{%
6411   \let\nonarrowing = t%
6412   \nonfillstart
6413   \gobble
6414 }
6415
6416 % @flushleft: same as @format, but doesn't obey \SETdispenvsize.
6417 \envdef\flushleft{%
6418   \let\nonarrowing = t%
6419   \nonfillstart
6420   \gobble
6421 }
6422 \let\Eflushleft = \afterenvbreak
6423
6424 % @flushright.
6425 %
6426 \envdef\flushright{%
6427   \let\nonarrowing = t%
6428   \nonfillstart
6429   \advance\leftskip by 0pt plus 1fill\relax
6430   \gobble
6431 }
6432 \let\Eflushright = \afterenvbreak
6433
6434
6435 % @raggedright does more-or-less normal line breaking but no right
6436 % justification.  From plain.tex.
6437 \envdef\raggedright{%
6438   \rightskip0pt plus2em \spaceskip.3333em \xspaceskip.5em\relax
6439 }
6440 \let\Eraggedright\par
6441
6442 \envdef\raggedleft{%
6443   \parindent=0pt \leftskip0pt plus2em
6444   \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
6445   \hbadness=10000 % Last line will usually be underfull, so turn off
6446                   % badness reporting.
6447 }
6448 \let\Eraggedleft\par
6449
6450 \envdef\raggedcenter{%
6451   \parindent=0pt \rightskip0pt plus1em \leftskip0pt plus1em
6452   \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
6453   \hbadness=10000 % Last line will usually be underfull, so turn off
6454                   % badness reporting.
6455 }
6456 \let\Eraggedcenter\par
6457
6458
6459 % @quotation does normal linebreaking (hence we can't use \nonfillstart)
6460 % and narrows the margins.  We keep \parskip nonzero in general, since
6461 % we're doing normal filling.  So, when using \aboveenvbreak and
6462 % \afterenvbreak, temporarily make \parskip 0.
6463 %
6464 \makedispenvdef{quotation}{\quotationstart}
6465 %
6466 \def\quotationstart{%
6467   {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
6468   \parindent=0pt
6469   %
6470   % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
6471   \ifx\nonarrowing\relax
6472     \advance\leftskip by \lispnarrowing
6473     \advance\rightskip by \lispnarrowing
6474     \exdentamount = \lispnarrowing
6475   \else
6476     \let\nonarrowing = \relax
6477   \fi
6478   \parsearg\quotationlabel
6479 }
6480
6481 % We have retained a nonzero parskip for the environment, since we're
6482 % doing normal filling.
6483 %
6484 \def\Equotation{%
6485   \par
6486   \ifx\quotationauthor\thisisundefined\else
6487     % indent a bit.
6488     \leftline{\kern 2\leftskip \sl ---\quotationauthor}%
6489   \fi
6490   {\parskip=0pt \afterenvbreak}%
6491 }
6492 \def\Esmallquotation{\Equotation}
6493
6494 % If we're given an argument, typeset it in bold with a colon after.
6495 \def\quotationlabel#1{%
6496   \def\temp{#1}%
6497   \ifx\temp\empty \else
6498     {\bf #1: }%
6499   \fi
6500 }
6501
6502
6503 % LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>}
6504 % If we want to allow any <char> as delimiter,
6505 % we need the curly braces so that makeinfo sees the @verb command, eg:
6506 % `@verbx...x' would look like the '@verbx' command.  --janneke@gnu.org
6507 %
6508 % [Knuth]: Donald Ervin Knuth, 1996.  The TeXbook.
6509 %
6510 % [Knuth] p.344; only we need to do the other characters Texinfo sets
6511 % active too.  Otherwise, they get lost as the first character on a
6512 % verbatim line.
6513 \def\dospecials{%
6514   \do\ \do\\\do\{\do\}\do\$\do\&%
6515   \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~%
6516   \do\<\do\>\do\|\do\@\do+\do\"%
6517   % Don't do the quotes -- if we do, @set txicodequoteundirected and
6518   % @set txicodequotebacktick will not have effect on @verb and
6519   % @verbatim, and ?` and !` ligatures won't get disabled.
6520   %\do\`\do\'%
6521 }
6522 %
6523 % [Knuth] p. 380
6524 \def\uncatcodespecials{%
6525   \def\do##1{\catcode`##1=\other}\dospecials}
6526 %
6527 % Setup for the @verb command.
6528 %
6529 % Eight spaces for a tab
6530 \begingroup
6531   \catcode`\^^I=\active
6532   \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }}
6533 \endgroup
6534 %
6535 \def\setupverb{%
6536   \tt  % easiest (and conventionally used) font for verbatim
6537   \def\par{\leavevmode\endgraf}%
6538   \setupmarkupstyle{verb}%
6539   \tabeightspaces
6540   % Respect line breaks,
6541   % print special symbols as themselves, and
6542   % make each space count
6543   % must do in this order:
6544   \obeylines \uncatcodespecials \sepspaces
6545 }
6546
6547 % Setup for the @verbatim environment
6548 %
6549 % Real tab expansion.
6550 \newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
6551 %
6552 % We typeset each line of the verbatim in an \hbox, so we can handle
6553 % tabs.  The \global is in case the verbatim line starts with an accent,
6554 % or some other command that starts with a begin-group.  Otherwise, the
6555 % entire \verbbox would disappear at the corresponding end-group, before
6556 % it is typeset.  Meanwhile, we can't have nested verbatim commands
6557 % (can we?), so the \global won't be overwriting itself.
6558 \newbox\verbbox
6559 \def\starttabbox{\global\setbox\verbbox=\hbox\bgroup}
6560 %
6561 \begingroup
6562   \catcode`\^^I=\active
6563   \gdef\tabexpand{%
6564     \catcode`\^^I=\active
6565     \def^^I{\leavevmode\egroup
6566       \dimen\verbbox=\wd\verbbox % the width so far, or since the previous tab
6567       \divide\dimen\verbbox by\tabw
6568       \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw
6569       \advance\dimen\verbbox by\tabw  % advance to next multiple of \tabw
6570       \wd\verbbox=\dimen\verbbox \box\verbbox \starttabbox
6571     }%
6572   }
6573 \endgroup
6574
6575 % start the verbatim environment.
6576 \def\setupverbatim{%
6577   \let\nonarrowing = t%
6578   \nonfillstart
6579   \tt % easiest (and conventionally used) font for verbatim
6580   % The \leavevmode here is for blank lines.  Otherwise, we would
6581   % never \starttabox and the \egroup would end verbatim mode.
6582   \def\par{\leavevmode\egroup\box\verbbox\endgraf}%
6583   \tabexpand
6584   \setupmarkupstyle{verbatim}%
6585   % Respect line breaks,
6586   % print special symbols as themselves, and
6587   % make each space count.
6588   % Must do in this order:
6589   \obeylines \uncatcodespecials \sepspaces
6590   \everypar{\starttabbox}%
6591 }
6592
6593 % Do the @verb magic: verbatim text is quoted by unique
6594 % delimiter characters.  Before first delimiter expect a
6595 % right brace, after last delimiter expect closing brace:
6596 %
6597 %    \def\doverb'{'<char>#1<char>'}'{#1}
6598 %
6599 % [Knuth] p. 382; only eat outer {}
6600 \begingroup
6601   \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other
6602   \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next]
6603 \endgroup
6604 %
6605 \def\verb{\begingroup\setupverb\doverb}
6606 %
6607 %
6608 % Do the @verbatim magic: define the macro \doverbatim so that
6609 % the (first) argument ends when '@end verbatim' is reached, ie:
6610 %
6611 %     \def\doverbatim#1@end verbatim{#1}
6612 %
6613 % For Texinfo it's a lot easier than for LaTeX,
6614 % because texinfo's \verbatim doesn't stop at '\end{verbatim}':
6615 % we need not redefine '\', '{' and '}'.
6616 %
6617 % Inspired by LaTeX's verbatim command set [latex.ltx]
6618 %
6619 \begingroup
6620   \catcode`\ =\active
6621   \obeylines %
6622   % ignore everything up to the first ^^M, that's the newline at the end
6623   % of the @verbatim input line itself.  Otherwise we get an extra blank
6624   % line in the output.
6625   \xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}%
6626   % We really want {...\end verbatim} in the body of the macro, but
6627   % without the active space; thus we have to use \xdef and \gobble.
6628 \endgroup
6629 %
6630 \envdef\verbatim{%
6631     \setupverbatim\doverbatim
6632 }
6633 \let\Everbatim = \afterenvbreak
6634
6635
6636 % @verbatiminclude FILE - insert text of file in verbatim environment.
6637 %
6638 \def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude}
6639 %
6640 \def\doverbatiminclude#1{%
6641   {%
6642     \makevalueexpandable
6643     \setupverbatim
6644     \indexnofonts       % Allow `@@' and other weird things in file names.
6645     \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}%
6646     \input #1
6647     \afterenvbreak
6648   }%
6649 }
6650
6651 % @copying ... @end copying.
6652 % Save the text away for @insertcopying later.
6653 %
6654 % We save the uninterpreted tokens, rather than creating a box.
6655 % Saving the text in a box would be much easier, but then all the
6656 % typesetting commands (@smallbook, font changes, etc.) have to be done
6657 % beforehand -- and a) we want @copying to be done first in the source
6658 % file; b) letting users define the frontmatter in as flexible order as
6659 % possible is very desirable.
6660 %
6661 \def\copying{\checkenv{}\begingroup\scanargctxt\docopying}
6662 \def\docopying#1@end copying{\endgroup\def\copyingtext{#1}}
6663 %
6664 \def\insertcopying{%
6665   \begingroup
6666     \parindent = 0pt  % paragraph indentation looks wrong on title page
6667     \scanexp\copyingtext
6668   \endgroup
6669 }
6670
6671
6672 \message{defuns,}
6673 % @defun etc.
6674
6675 \newskip\defbodyindent \defbodyindent=.4in
6676 \newskip\defargsindent \defargsindent=50pt
6677 \newskip\deflastargmargin \deflastargmargin=18pt
6678 \newcount\defunpenalty
6679
6680 % Start the processing of @deffn:
6681 \def\startdefun{%
6682   \ifnum\lastpenalty<10000
6683     \medbreak
6684     \defunpenalty=10003 % Will keep this @deffn together with the
6685                         % following @def command, see below.
6686   \else
6687     % If there are two @def commands in a row, we'll have a \nobreak,
6688     % which is there to keep the function description together with its
6689     % header.  But if there's nothing but headers, we need to allow a
6690     % break somewhere.  Check specifically for penalty 10002, inserted
6691     % by \printdefunline, instead of 10000, since the sectioning
6692     % commands also insert a nobreak penalty, and we don't want to allow
6693     % a break between a section heading and a defun.
6694     %
6695     % As a further refinement, we avoid "club" headers by signalling
6696     % with penalty of 10003 after the very first @deffn in the
6697     % sequence (see above), and penalty of 10002 after any following
6698     % @def command.
6699     \ifnum\lastpenalty=10002 \penalty2000 \else \defunpenalty=10002 \fi
6700     %
6701     % Similarly, after a section heading, do not allow a break.
6702     % But do insert the glue.
6703     \medskip  % preceded by discardable penalty, so not a breakpoint
6704   \fi
6705   %
6706   \parindent=0in
6707   \advance\leftskip by \defbodyindent
6708   \exdentamount=\defbodyindent
6709 }
6710
6711 \def\dodefunx#1{%
6712   % First, check whether we are in the right environment:
6713   \checkenv#1%
6714   %
6715   % As above, allow line break if we have multiple x headers in a row.
6716   % It's not a great place, though.
6717   \ifnum\lastpenalty=10002 \penalty3000 \else \defunpenalty=10002 \fi
6718   %
6719   % And now, it's time to reuse the body of the original defun:
6720   \expandafter\gobbledefun#1%
6721 }
6722 \def\gobbledefun#1\startdefun{}
6723
6724 % \printdefunline \deffnheader{text}
6725 %
6726 \def\printdefunline#1#2{%
6727   \begingroup
6728     % call \deffnheader:
6729     #1#2 \endheader
6730     % common ending:
6731     \interlinepenalty = 10000
6732     \advance\rightskip by 0pt plus 1fil\relax
6733     \endgraf
6734     \nobreak\vskip -\parskip
6735     \penalty\defunpenalty  % signal to \startdefun and \dodefunx
6736     % Some of the @defun-type tags do not enable magic parentheses,
6737     % rendering the following check redundant.  But we don't optimize.
6738     \checkparencounts
6739   \endgroup
6740 }
6741
6742 \def\Edefun{\endgraf\medbreak}
6743
6744 % \makedefun{deffn} creates \deffn, \deffnx and \Edeffn;
6745 % the only thing remaining is to define \deffnheader.
6746 %
6747 \def\makedefun#1{%
6748   \expandafter\let\csname E#1\endcsname = \Edefun
6749   \edef\temp{\noexpand\domakedefun
6750     \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}%
6751   \temp
6752 }
6753
6754 % \domakedefun \deffn \deffnx \deffnheader
6755 %
6756 % Define \deffn and \deffnx, without parameters.
6757 % \deffnheader has to be defined explicitly.
6758 %
6759 \def\domakedefun#1#2#3{%
6760   \envdef#1{%
6761     \startdefun
6762     \doingtypefnfalse    % distinguish typed functions from all else
6763     \parseargusing\activeparens{\printdefunline#3}%
6764   }%
6765   \def#2{\dodefunx#1}%
6766   \def#3%
6767 }
6768
6769 \newif\ifdoingtypefn       % doing typed function?
6770 \newif\ifrettypeownline    % typeset return type on its own line?
6771
6772 % @deftypefnnewline on|off says whether the return type of typed functions
6773 % are printed on their own line.  This affects @deftypefn, @deftypefun,
6774 % @deftypeop, and @deftypemethod.
6775
6776 \parseargdef\deftypefnnewline{%
6777   \def\temp{#1}%
6778   \ifx\temp\onword
6779     \expandafter\let\csname SETtxideftypefnnl\endcsname
6780       = \empty
6781   \else\ifx\temp\offword
6782     \expandafter\let\csname SETtxideftypefnnl\endcsname
6783       = \relax
6784   \else
6785     \errhelp = \EMsimple
6786     \errmessage{Unknown @txideftypefnnl value `\temp',
6787                 must be on|off}%
6788   \fi\fi
6789 }
6790
6791 % Untyped functions:
6792
6793 % @deffn category name args
6794 \makedefun{deffn}{\deffngeneral{}}
6795
6796 % @deffn category class name args
6797 \makedefun{defop}#1 {\defopon{#1\ \putwordon}}
6798
6799 % \defopon {category on}class name args
6800 \def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
6801
6802 % \deffngeneral {subind}category name args
6803 %
6804 \def\deffngeneral#1#2 #3 #4\endheader{%
6805   % Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}.
6806   \dosubind{fn}{\code{#3}}{#1}%
6807   \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
6808 }
6809
6810 % Typed functions:
6811
6812 % @deftypefn category type name args
6813 \makedefun{deftypefn}{\deftypefngeneral{}}
6814
6815 % @deftypeop category class type name args
6816 \makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}}
6817
6818 % \deftypeopon {category on}class type name args
6819 \def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
6820
6821 % \deftypefngeneral {subind}category type name args
6822 %
6823 \def\deftypefngeneral#1#2 #3 #4 #5\endheader{%
6824   \dosubind{fn}{\code{#4}}{#1}%
6825   \doingtypefntrue
6826   \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
6827 }
6828
6829 % Typed variables:
6830
6831 % @deftypevr category type var args
6832 \makedefun{deftypevr}{\deftypecvgeneral{}}
6833
6834 % @deftypecv category class type var args
6835 \makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}}
6836
6837 % \deftypecvof {category of}class type var args
6838 \def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} }
6839
6840 % \deftypecvgeneral {subind}category type var args
6841 %
6842 \def\deftypecvgeneral#1#2 #3 #4 #5\endheader{%
6843   \dosubind{vr}{\code{#4}}{#1}%
6844   \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
6845 }
6846
6847 % Untyped variables:
6848
6849 % @defvr category var args
6850 \makedefun{defvr}#1 {\deftypevrheader{#1} {} }
6851
6852 % @defcv category class var args
6853 \makedefun{defcv}#1 {\defcvof{#1\ \putwordof}}
6854
6855 % \defcvof {category of}class var args
6856 \def\defcvof#1#2 {\deftypecvof{#1}#2 {} }
6857
6858 % Types:
6859
6860 % @deftp category name args
6861 \makedefun{deftp}#1 #2 #3\endheader{%
6862   \doind{tp}{\code{#2}}%
6863   \defname{#1}{}{#2}\defunargs{#3\unskip}%
6864 }
6865
6866 % Remaining @defun-like shortcuts:
6867 \makedefun{defun}{\deffnheader{\putwordDeffunc} }
6868 \makedefun{defmac}{\deffnheader{\putwordDefmac} }
6869 \makedefun{defspec}{\deffnheader{\putwordDefspec} }
6870 \makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} }
6871 \makedefun{defvar}{\defvrheader{\putwordDefvar} }
6872 \makedefun{defopt}{\defvrheader{\putwordDefopt} }
6873 \makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} }
6874 \makedefun{defmethod}{\defopon\putwordMethodon}
6875 \makedefun{deftypemethod}{\deftypeopon\putwordMethodon}
6876 \makedefun{defivar}{\defcvof\putwordInstanceVariableof}
6877 \makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof}
6878
6879 % \defname, which formats the name of the @def (not the args).
6880 % #1 is the category, such as "Function".
6881 % #2 is the return type, if any.
6882 % #3 is the function name.
6883 %
6884 % We are followed by (but not passed) the arguments, if any.
6885 %
6886 \def\defname#1#2#3{%
6887   \par
6888   % Get the values of \leftskip and \rightskip as they were outside the @def...
6889   \advance\leftskip by -\defbodyindent
6890   %
6891   % Determine if we are typesetting the return type of a typed function
6892   % on a line by itself.
6893   \rettypeownlinefalse
6894   \ifdoingtypefn  % doing a typed function specifically?
6895     % then check user option for putting return type on its own line:
6896     \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else
6897       \rettypeownlinetrue
6898     \fi
6899   \fi
6900   %
6901   % How we'll format the category name.  Putting it in brackets helps
6902   % distinguish it from the body text that may end up on the next line
6903   % just below it.
6904   \def\temp{#1}%
6905   \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
6906   %
6907   % Figure out line sizes for the paragraph shape.  We'll always have at
6908   % least two.
6909   \tempnum = 2
6910   %
6911   % The first line needs space for \box0; but if \rightskip is nonzero,
6912   % we need only space for the part of \box0 which exceeds it:
6913   \dimen0=\hsize  \advance\dimen0 by -\wd0  \advance\dimen0 by \rightskip
6914   %
6915   % If doing a return type on its own line, we'll have another line.
6916   \ifrettypeownline
6917     \advance\tempnum by 1
6918     \def\maybeshapeline{0in \hsize}%
6919   \else
6920     \def\maybeshapeline{}%
6921   \fi
6922   %
6923   % The continuations:
6924   \dimen2=\hsize  \advance\dimen2 by -\defargsindent
6925   %
6926   % The final paragraph shape:
6927   \parshape \tempnum  0in \dimen0  \maybeshapeline  \defargsindent \dimen2
6928   %
6929   % Put the category name at the right margin.
6930   \noindent
6931   \hbox to 0pt{%
6932     \hfil\box0 \kern-\hsize
6933     % \hsize has to be shortened this way:
6934     \kern\leftskip
6935     % Intentionally do not respect \rightskip, since we need the space.
6936   }%
6937   %
6938   % Allow all lines to be underfull without complaint:
6939   \tolerance=10000 \hbadness=10000
6940   \exdentamount=\defbodyindent
6941   {%
6942     % defun fonts. We use typewriter by default (used to be bold) because:
6943     % . we're printing identifiers, they should be in tt in principle.
6944     % . in languages with many accents, such as Czech or French, it's
6945     %   common to leave accents off identifiers.  The result looks ok in
6946     %   tt, but exceedingly strange in rm.
6947     % . we don't want -- and --- to be treated as ligatures.
6948     % . this still does not fix the ?` and !` ligatures, but so far no
6949     %   one has made identifiers using them :).
6950     \df \tt
6951     \def\temp{#2}% text of the return type
6952     \ifx\temp\empty\else
6953       \tclose{\temp}% typeset the return type
6954       \ifrettypeownline
6955         % put return type on its own line; prohibit line break following:
6956         \hfil\vadjust{\nobreak}\break  
6957       \else
6958         \space  % type on same line, so just followed by a space
6959       \fi
6960     \fi           % no return type
6961     #3% output function name
6962   }%
6963   {\rm\enskip}% hskip 0.5 em of \tenrm
6964   %
6965   \boldbrax
6966   % arguments will be output next, if any.
6967 }
6968
6969 % Print arguments in slanted roman (not ttsl), inconsistently with using
6970 % tt for the name.  This is because literal text is sometimes needed in
6971 % the argument list (groff manual), and ttsl and tt are not very
6972 % distinguishable.  Prevent hyphenation at `-' chars.
6973 %
6974 \def\defunargs#1{%
6975   % use sl by default (not ttsl),
6976   % tt for the names.
6977   \df \sl \hyphenchar\font=0
6978   %
6979   % On the other hand, if an argument has two dashes (for instance), we
6980   % want a way to get ttsl.  Let's try @var for that.
6981   \def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}%
6982   #1%
6983   \sl\hyphenchar\font=45
6984 }
6985
6986 % We want ()&[] to print specially on the defun line.
6987 %
6988 \def\activeparens{%
6989   \catcode`\(=\active \catcode`\)=\active
6990   \catcode`\[=\active \catcode`\]=\active
6991   \catcode`\&=\active
6992 }
6993
6994 % Make control sequences which act like normal parenthesis chars.
6995 \let\lparen = ( \let\rparen = )
6996
6997 % Be sure that we always have a definition for `(', etc.  For example,
6998 % if the fn name has parens in it, \boldbrax will not be in effect yet,
6999 % so TeX would otherwise complain about undefined control sequence.
7000 {
7001   \activeparens
7002   \global\let(=\lparen \global\let)=\rparen
7003   \global\let[=\lbrack \global\let]=\rbrack
7004   \global\let& = \&
7005
7006   \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
7007   \gdef\magicamp{\let&=\amprm}
7008 }
7009
7010 \newcount\parencount
7011
7012 % If we encounter &foo, then turn on ()-hacking afterwards
7013 \newif\ifampseen
7014 \def\amprm#1 {\ampseentrue{\bf\&#1 }}
7015
7016 \def\parenfont{%
7017   \ifampseen
7018     % At the first level, print parens in roman,
7019     % otherwise use the default font.
7020     \ifnum \parencount=1 \rm \fi
7021   \else
7022     % The \sf parens (in \boldbrax) actually are a little bolder than
7023     % the contained text.  This is especially needed for [ and ] .
7024     \sf
7025   \fi
7026 }
7027 \def\infirstlevel#1{%
7028   \ifampseen
7029     \ifnum\parencount=1
7030       #1%
7031     \fi
7032   \fi
7033 }
7034 \def\bfafterword#1 {#1 \bf}
7035
7036 \def\opnr{%
7037   \global\advance\parencount by 1
7038   {\parenfont(}%
7039   \infirstlevel \bfafterword
7040 }
7041 \def\clnr{%
7042   {\parenfont)}%
7043   \infirstlevel \sl
7044   \global\advance\parencount by -1
7045 }
7046
7047 \newcount\brackcount
7048 \def\lbrb{%
7049   \global\advance\brackcount by 1
7050   {\bf[}%
7051 }
7052 \def\rbrb{%
7053   {\bf]}%
7054   \global\advance\brackcount by -1
7055 }
7056
7057 \def\checkparencounts{%
7058   \ifnum\parencount=0 \else \badparencount \fi
7059   \ifnum\brackcount=0 \else \badbrackcount \fi
7060 }
7061 % these should not use \errmessage; the glibc manual, at least, actually
7062 % has such constructs (when documenting function pointers).
7063 \def\badparencount{%
7064   \message{Warning: unbalanced parentheses in @def...}%
7065   \global\parencount=0
7066 }
7067 \def\badbrackcount{%
7068   \message{Warning: unbalanced square brackets in @def...}%
7069   \global\brackcount=0
7070 }
7071
7072
7073 \message{macros,}
7074 % @macro.
7075
7076 % To do this right we need a feature of e-TeX, \scantokens,
7077 % which we arrange to emulate with a temporary file in ordinary TeX.
7078 \ifx\eTeXversion\thisisundefined
7079   \newwrite\macscribble
7080   \def\scantokens#1{%
7081     \toks0={#1}%
7082     \immediate\openout\macscribble=\jobname.tmp
7083     \immediate\write\macscribble{\the\toks0}%
7084     \immediate\closeout\macscribble
7085     \input \jobname.tmp
7086   }
7087 \fi
7088
7089 \def\scanmacro#1{\begingroup
7090   \newlinechar`\^^M
7091   \let\xeatspaces\eatspaces
7092   %
7093   % Undo catcode changes of \startcontents and \doprintindex
7094   % When called from @insertcopying or (short)caption, we need active
7095   % backslash to get it printed correctly.  Previously, we had
7096   % \catcode`\\=\other instead.  We'll see whether a problem appears
7097   % with macro expansion.                               --kasal, 19aug04
7098   \catcode`\@=0 \catcode`\\=\active \escapechar=`\@
7099   %
7100   % ... and for \example:
7101   \spaceisspace
7102   %
7103   % The \empty here causes a following catcode 5 newline to be eaten as
7104   % part of reading whitespace after a control sequence.  It does not
7105   % eat a catcode 13 newline.  There's no good way to handle the two
7106   % cases (untried: maybe e-TeX's \everyeof could help, though plain TeX
7107   % would then have different behavior).  See the Macro Details node in
7108   % the manual for the workaround we recommend for macros and
7109   % line-oriented commands.
7110   % 
7111   \scantokens{#1\empty}%
7112 \endgroup}
7113
7114 \def\scanexp#1{%
7115   \edef\temp{\noexpand\scanmacro{#1}}%
7116   \temp
7117 }
7118
7119 \newcount\paramno   % Count of parameters
7120 \newtoks\macname    % Macro name
7121 \newif\ifrecursive  % Is it recursive?
7122
7123 % List of all defined macros in the form
7124 %    \definedummyword\macro1\definedummyword\macro2...
7125 % Currently is also contains all @aliases; the list can be split
7126 % if there is a need.
7127 \def\macrolist{}
7128
7129 % Add the macro to \macrolist
7130 \def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname}
7131 \def\addtomacrolistxxx#1{%
7132      \toks0 = \expandafter{\macrolist\definedummyword#1}%
7133      \xdef\macrolist{\the\toks0}%
7134 }
7135
7136 % Utility routines.
7137 % This does \let #1 = #2, with \csnames; that is,
7138 %   \let \csname#1\endcsname = \csname#2\endcsname
7139 % (except of course we have to play expansion games).
7140 %
7141 \def\cslet#1#2{%
7142   \expandafter\let
7143   \csname#1\expandafter\endcsname
7144   \csname#2\endcsname
7145 }
7146
7147 % Trim leading and trailing spaces off a string.
7148 % Concepts from aro-bend problem 15 (see CTAN).
7149 {\catcode`\@=11
7150 \gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }}
7151 \gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@}
7152 \gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @}
7153 \def\unbrace#1{#1}
7154 \unbrace{\gdef\trim@@@ #1 } #2@{#1}
7155 }
7156
7157 % Trim a single trailing ^^M off a string.
7158 {\catcode`\^^M=\other \catcode`\Q=3%
7159 \gdef\eatcr #1{\eatcra #1Q^^MQ}%
7160 \gdef\eatcra#1^^MQ{\eatcrb#1Q}%
7161 \gdef\eatcrb#1Q#2Q{#1}%
7162 }
7163
7164 % Macro bodies are absorbed as an argument in a context where
7165 % all characters are catcode 10, 11 or 12, except \ which is active
7166 % (as in normal texinfo). It is necessary to change the definition of \
7167 % to recognize macro arguments; this is the job of \mbodybackslash.
7168 %
7169 % Non-ASCII encodings make 8-bit characters active, so un-activate
7170 % them to avoid their expansion.  Must do this non-globally, to
7171 % confine the change to the current group.
7172 %
7173 % It's necessary to have hard CRs when the macro is executed. This is
7174 % done by making ^^M (\endlinechar) catcode 12 when reading the macro
7175 % body, and then making it the \newlinechar in \scanmacro.
7176 %
7177 \def\scanctxt{% used as subroutine
7178   \catcode`\"=\other
7179   \catcode`\+=\other
7180   \catcode`\<=\other
7181   \catcode`\>=\other
7182   \catcode`\@=\other
7183   \catcode`\^=\other
7184   \catcode`\_=\other
7185   \catcode`\|=\other
7186   \catcode`\~=\other
7187   \ifx\declaredencoding\ascii \else \setnonasciicharscatcodenonglobal\other \fi
7188 }
7189
7190 \def\scanargctxt{% used for copying and captions, not macros.
7191   \scanctxt
7192   \catcode`\\=\other
7193   \catcode`\^^M=\other
7194 }
7195
7196 \def\macrobodyctxt{% used for @macro definitions
7197   \scanctxt
7198   \catcode`\{=\other
7199   \catcode`\}=\other
7200   \catcode`\^^M=\other
7201   \usembodybackslash
7202 }
7203
7204 \def\macroargctxt{% used when scanning invocations
7205   \scanctxt
7206   \catcode`\\=0
7207 }
7208 % why catcode 0 for \ in the above?  To recognize \\ \{ \} as "escapes"
7209 % for the single characters \ { }.  Thus, we end up with the "commands"
7210 % that would be written @\ @{ @} in a Texinfo document.
7211
7212 % We already have @{ and @}.  For @\, we define it here, and only for
7213 % this purpose, to produce a typewriter backslash (so, the @\ that we
7214 % define for @math can't be used with @macro calls):
7215 %
7216 \def\\{\normalbackslash}%
7217
7218 % We would like to do this for \, too, since that is what makeinfo does.
7219 % But it is not possible, because Texinfo already has a command @, for a
7220 % cedilla accent.  Documents must use @comma{} instead.
7221 %
7222 % \anythingelse will almost certainly be an error of some kind.
7223
7224
7225 % \mbodybackslash is the definition of \ in @macro bodies.
7226 % It maps \foo\ => \csname macarg.foo\endcsname => #N
7227 % where N is the macro parameter number.
7228 % We define \csname macarg.\endcsname to be \realbackslash, so
7229 % \\ in macro replacement text gets you a backslash.
7230 %
7231 {\catcode`@=0 @catcode`@\=@active
7232  @gdef@usembodybackslash{@let\=@mbodybackslash}
7233  @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname}
7234 }
7235 \expandafter\def\csname macarg.\endcsname{\realbackslash}
7236
7237 \def\margbackslash#1{\char`\#1 }
7238
7239 \def\macro{\recursivefalse\parsearg\macroxxx}
7240 \def\rmacro{\recursivetrue\parsearg\macroxxx}
7241
7242 \def\macroxxx#1{%
7243   \getargs{#1}% now \macname is the macname and \argl the arglist
7244   \ifx\argl\empty       % no arguments
7245      \paramno=0
7246   \else
7247      \expandafter\parsemargdef \argl;%
7248   \fi
7249   \if1\csname ismacro.\the\macname\endcsname
7250      \message{Warning: redefining \the\macname}%
7251   \else
7252      \expandafter\ifx\csname \the\macname\endcsname \relax
7253      \else \errmessage{Macro name \the\macname\space already defined}\fi
7254      \global\cslet{macsave.\the\macname}{\the\macname}%
7255      \global\expandafter\let\csname ismacro.\the\macname\endcsname=1%
7256      \addtomacrolist{\the\macname}%
7257   \fi
7258   \begingroup \macrobodyctxt
7259   \ifrecursive \expandafter\parsermacbody
7260   \else \expandafter\parsemacbody
7261   \fi}
7262
7263 \parseargdef\unmacro{%
7264   \if1\csname ismacro.#1\endcsname
7265     \global\cslet{#1}{macsave.#1}%
7266     \global\expandafter\let \csname ismacro.#1\endcsname=0%
7267     % Remove the macro name from \macrolist:
7268     \begingroup
7269       \expandafter\let\csname#1\endcsname \relax
7270       \let\definedummyword\unmacrodo
7271       \xdef\macrolist{\macrolist}%
7272     \endgroup
7273   \else
7274     \errmessage{Macro #1 not defined}%
7275   \fi
7276 }
7277
7278 % Called by \do from \dounmacro on each macro.  The idea is to omit any
7279 % macro definitions that have been changed to \relax.
7280 %
7281 \def\unmacrodo#1{%
7282   \ifx #1\relax
7283     % remove this
7284   \else
7285     \noexpand\definedummyword \noexpand#1%
7286   \fi
7287 }
7288
7289 % This makes use of the obscure feature that if the last token of a
7290 % <parameter list> is #, then the preceding argument is delimited by
7291 % an opening brace, and that opening brace is not consumed.
7292 \def\getargs#1{\getargsxxx#1{}}
7293 \def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
7294 \def\getmacname#1 #2\relax{\macname={#1}}
7295 \def\getmacargs#1{\def\argl{#1}}
7296
7297 % Parse the optional {params} list.  Set up \paramno and \paramlist
7298 % so \defmacro knows what to do.  Define \macarg.blah for each blah
7299 % in the params list to be ##N where N is the position in that list.
7300 % That gets used by \mbodybackslash (above).
7301 %
7302 % We need to get `macro parameter char #' into several definitions.
7303 % The technique used is stolen from LaTeX: let \hash be something
7304 % unexpandable, insert that wherever you need a #, and then redefine
7305 % it to # just before using the token list produced.
7306 %
7307 % The same technique is used to protect \eatspaces till just before
7308 % the macro is used.
7309
7310 \def\parsemargdef#1;{%
7311   \paramno=0\def\paramlist{}%
7312   \let\hash\relax
7313   \let\xeatspaces\relax
7314   \parsemargdefxxx#1,;,%
7315 }
7316 \def\parsemargdefxxx#1,{%
7317   \if#1;\let\next=\relax
7318   \else \let\next=\parsemargdefxxx
7319     \advance\paramno by 1
7320     \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
7321         {\xeatspaces{\hash\the\paramno}}%
7322     \edef\paramlist{\paramlist\hash\the\paramno,}%
7323   \fi\next}
7324
7325 % These two commands read recursive and nonrecursive macro bodies.
7326 % (They're different since rec and nonrec macros end differently.)
7327 %
7328 \long\def\parsemacbody#1@end macro%
7329 {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
7330 \long\def\parsermacbody#1@end rmacro%
7331 {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
7332
7333 % This defines the macro itself. There are six cases: recursive and
7334 % nonrecursive macros of zero, one, and many arguments.
7335 % Much magic with \expandafter here.
7336 % \xdef is used so that macro definitions will survive the file
7337 % they're defined in; @include reads the file inside a group.
7338 %
7339 \def\defmacro{%
7340   \let\hash=##% convert placeholders to macro parameter chars
7341   \ifrecursive
7342     \ifcase\paramno
7343     % 0
7344       \expandafter\xdef\csname\the\macname\endcsname{%
7345         \noexpand\scanmacro{\temp}}%
7346     \or % 1
7347       \expandafter\xdef\csname\the\macname\endcsname{%
7348          \bgroup\noexpand\macroargctxt
7349          \noexpand\braceorline
7350          \expandafter\noexpand\csname\the\macname xxx\endcsname}%
7351       \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
7352          \egroup\noexpand\scanmacro{\temp}}%
7353     \else % many
7354       \expandafter\xdef\csname\the\macname\endcsname{%
7355          \bgroup\noexpand\macroargctxt
7356          \noexpand\csname\the\macname xx\endcsname}%
7357       \expandafter\xdef\csname\the\macname xx\endcsname##1{%
7358           \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
7359       \expandafter\expandafter
7360       \expandafter\xdef
7361       \expandafter\expandafter
7362         \csname\the\macname xxx\endcsname
7363           \paramlist{\egroup\noexpand\scanmacro{\temp}}%
7364     \fi
7365   \else
7366     \ifcase\paramno
7367     % 0
7368       \expandafter\xdef\csname\the\macname\endcsname{%
7369         \noexpand\norecurse{\the\macname}%
7370         \noexpand\scanmacro{\temp}\egroup}%
7371     \or % 1
7372       \expandafter\xdef\csname\the\macname\endcsname{%
7373          \bgroup\noexpand\macroargctxt
7374          \noexpand\braceorline
7375          \expandafter\noexpand\csname\the\macname xxx\endcsname}%
7376       \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
7377         \egroup
7378         \noexpand\norecurse{\the\macname}%
7379         \noexpand\scanmacro{\temp}\egroup}%
7380     \else % many
7381       \expandafter\xdef\csname\the\macname\endcsname{%
7382          \bgroup\noexpand\macroargctxt
7383          \expandafter\noexpand\csname\the\macname xx\endcsname}%
7384       \expandafter\xdef\csname\the\macname xx\endcsname##1{%
7385           \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
7386       \expandafter\expandafter
7387       \expandafter\xdef
7388       \expandafter\expandafter
7389       \csname\the\macname xxx\endcsname
7390       \paramlist{%
7391           \egroup
7392           \noexpand\norecurse{\the\macname}%
7393           \noexpand\scanmacro{\temp}\egroup}%
7394     \fi
7395   \fi}
7396
7397 \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
7398
7399 % \braceorline decides whether the next nonwhitespace character is a
7400 % {.  If so it reads up to the closing }, if not, it reads the whole
7401 % line.  Whatever was read is then fed to the next control sequence
7402 % as an argument (by \parsebrace or \parsearg).
7403
7404 \def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx}
7405 \def\braceorlinexxx{%
7406   \ifx\nchar\bgroup\else
7407     \expandafter\parsearg
7408   \fi \macnamexxx}
7409
7410
7411 % @alias.
7412 % We need some trickery to remove the optional spaces around the equal
7413 % sign.  Make them active and then expand them all to nothing.
7414 %
7415 \def\alias{\parseargusing\obeyspaces\aliasxxx}
7416 \def\aliasxxx #1{\aliasyyy#1\relax}
7417 \def\aliasyyy #1=#2\relax{%
7418   {%
7419     \expandafter\let\obeyedspace=\empty
7420     \addtomacrolist{#1}%
7421     \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}%
7422   }%
7423   \next
7424 }
7425
7426
7427 \message{cross references,}
7428
7429 \newwrite\auxfile
7430 \newif\ifhavexrefs    % True if xref values are known.
7431 \newif\ifwarnedxrefs  % True if we warned once that they aren't known.
7432
7433 % @inforef is relatively simple.
7434 \def\inforef #1{\inforefzzz #1,,,,**}
7435 \def\inforefzzz #1,#2,#3,#4**{%
7436   \putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
7437   node \samp{\ignorespaces#1{}}}
7438
7439 % @node's only job in TeX is to define \lastnode, which is used in
7440 % cross-references.  The @node line might or might not have commas, and
7441 % might or might not have spaces before the first comma, like:
7442 % @node foo , bar , ...
7443 % We don't want such trailing spaces in the node name.
7444 %
7445 \parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse}
7446 %
7447 % also remove a trailing comma, in case of something like this:
7448 % @node Help-Cross,  ,  , Cross-refs
7449 \def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse}
7450 \def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}}
7451
7452 \let\nwnode=\node
7453 \let\lastnode=\empty
7454
7455 % Write a cross-reference definition for the current node.  #1 is the
7456 % type (Ynumbered, Yappendix, Ynothing).
7457 %
7458 \def\donoderef#1{%
7459   \ifx\lastnode\empty\else
7460     \setref{\lastnode}{#1}%
7461     \global\let\lastnode=\empty
7462   \fi
7463 }
7464
7465 % @anchor{NAME} -- define xref target at arbitrary point.
7466 %
7467 \newcount\savesfregister
7468 %
7469 \def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi}
7470 \def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi}
7471 \def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces}
7472
7473 % \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an
7474 % anchor), which consists of three parts:
7475 % 1) NAME-title - the current sectioning name taken from \lastsection,
7476 %                 or the anchor name.
7477 % 2) NAME-snt   - section number and type, passed as the SNT arg, or
7478 %                 empty for anchors.
7479 % 3) NAME-pg    - the page number.
7480 %
7481 % This is called from \donoderef, \anchor, and \dofloat.  In the case of
7482 % floats, there is an additional part, which is not written here:
7483 % 4) NAME-lof   - the text as it should appear in a @listoffloats.
7484 %
7485 \def\setref#1#2{%
7486   \pdfmkdest{#1}%
7487   \iflinks
7488     {%
7489       \atdummies  % preserve commands, but don't expand them
7490       \edef\writexrdef##1##2{%
7491         \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef
7492           ##1}{##2}}% these are parameters of \writexrdef
7493       }%
7494       \toks0 = \expandafter{\lastsection}%
7495       \immediate \writexrdef{title}{\the\toks0 }%
7496       \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc.
7497       \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout
7498     }%
7499   \fi
7500 }
7501
7502 % @xrefautosectiontitle on|off says whether @section(ing) names are used
7503 % automatically in xrefs, if the third arg is not explicitly specified.
7504 % This was provided as a "secret" @set xref-automatic-section-title
7505 % variable, now it's official.
7506
7507 \parseargdef\xrefautomaticsectiontitle{%
7508   \def\temp{#1}%
7509   \ifx\temp\onword
7510     \expandafter\let\csname SETxref-automatic-section-title\endcsname
7511       = \empty
7512   \else\ifx\temp\offword
7513     \expandafter\let\csname SETxref-automatic-section-title\endcsname
7514       = \relax
7515   \else
7516     \errhelp = \EMsimple
7517     \errmessage{Unknown @xrefautomaticsectiontitle value `\temp',
7518                 must be on|off}%
7519   \fi\fi
7520 }
7521
7522
7523 % @xref, @pxref, and @ref generate cross-references.  For \xrefX, #1 is
7524 % the node name, #2 the name of the Info cross-reference, #3 the printed
7525 % node name, #4 the name of the Info file, #5 the name of the printed
7526 % manual.  All but the node name can be omitted.
7527 %
7528 \def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]}
7529 \def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]}
7530 \def\ref#1{\xrefX[#1,,,,,,,]}
7531 \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
7532   \unsepspaces
7533   \def\printedmanual{\ignorespaces #5}%
7534   \def\printedrefname{\ignorespaces #3}%
7535   \setbox1=\hbox{\printedmanual\unskip}%
7536   \setbox0=\hbox{\printedrefname\unskip}%
7537   \ifdim \wd0 = 0pt
7538     % No printed node name was explicitly given.
7539     \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax
7540       % Use the node name inside the square brackets.
7541       \def\printedrefname{\ignorespaces #1}%
7542     \else
7543       % Use the actual chapter/section title appear inside
7544       % the square brackets.  Use the real section title if we have it.
7545       \ifdim \wd1 > 0pt
7546         % It is in another manual, so we don't have it.
7547         \def\printedrefname{\ignorespaces #1}%
7548       \else
7549         \ifhavexrefs
7550           % We know the real title if we have the xref values.
7551           \def\printedrefname{\refx{#1-title}{}}%
7552         \else
7553           % Otherwise just copy the Info node name.
7554           \def\printedrefname{\ignorespaces #1}%
7555         \fi%
7556       \fi
7557     \fi
7558   \fi
7559   %
7560   % Make link in pdf output.
7561   \ifpdf
7562     {\indexnofonts
7563      \turnoffactive
7564      % This expands tokens, so do it after making catcode changes, so _
7565      % etc. don't get their TeX definitions.
7566      \getfilename{#4}%
7567      %
7568      % See comments at \activebackslashdouble.
7569      {\activebackslashdouble \xdef\pdfxrefdest{#1}%
7570       \backslashparens\pdfxrefdest}%
7571      %
7572      \leavevmode
7573      \startlink attr{/Border [0 0 0]}%
7574      \ifnum\filenamelength>0
7575        goto file{\the\filename.pdf} name{\pdfxrefdest}%
7576      \else
7577        goto name{\pdfmkpgn{\pdfxrefdest}}%
7578      \fi
7579     }%
7580     \setcolor{\linkcolor}%
7581   \fi
7582   %
7583   % Float references are printed completely differently: "Figure 1.2"
7584   % instead of "[somenode], p.3".  We distinguish them by the
7585   % LABEL-title being set to a magic string.
7586   {%
7587     % Have to otherify everything special to allow the \csname to
7588     % include an _ in the xref name, etc.
7589     \indexnofonts
7590     \turnoffactive
7591     \expandafter\global\expandafter\let\expandafter\Xthisreftitle
7592       \csname XR#1-title\endcsname
7593   }%
7594   \iffloat\Xthisreftitle
7595     % If the user specified the print name (third arg) to the ref,
7596     % print it instead of our usual "Figure 1.2".
7597     \ifdim\wd0 = 0pt
7598       \refx{#1-snt}{}%
7599     \else
7600       \printedrefname
7601     \fi
7602     %
7603     % if the user also gave the printed manual name (fifth arg), append
7604     % "in MANUALNAME".
7605     \ifdim \wd1 > 0pt
7606       \space \putwordin{} \cite{\printedmanual}%
7607     \fi
7608   \else
7609     % node/anchor (non-float) references.
7610     %
7611     % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not
7612     % insert empty discretionaries after hyphens, which means that it will
7613     % not find a line break at a hyphen in a node names.  Since some manuals
7614     % are best written with fairly long node names, containing hyphens, this
7615     % is a loss.  Therefore, we give the text of the node name again, so it
7616     % is as if TeX is seeing it for the first time.
7617     \ifdim \wd1 > 0pt
7618       \putwordSection{} ``\printedrefname'' \putwordin{} \cite{\printedmanual}%
7619     \else
7620       % _ (for example) has to be the character _ for the purposes of the
7621       % control sequence corresponding to the node, but it has to expand
7622       % into the usual \leavevmode...\vrule stuff for purposes of
7623       % printing. So we \turnoffactive for the \refx-snt, back on for the
7624       % printing, back off for the \refx-pg.
7625       {\turnoffactive
7626        % Only output a following space if the -snt ref is nonempty; for
7627        % @unnumbered and @anchor, it won't be.
7628        \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
7629        \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
7630       }%
7631       % output the `[mynode]' via a macro so it can be overridden.
7632       \xrefprintnodename\printedrefname
7633       %
7634       % But we always want a comma and a space:
7635       ,\space
7636       %
7637       % output the `page 3'.
7638       \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
7639     \fi
7640   \fi
7641   \endlink
7642 \endgroup}
7643
7644 % This macro is called from \xrefX for the `[nodename]' part of xref
7645 % output.  It's a separate macro only so it can be changed more easily,
7646 % since square brackets don't work well in some documents.  Particularly
7647 % one that Bob is working on :).
7648 %
7649 \def\xrefprintnodename#1{[#1]}
7650
7651 % Things referred to by \setref.
7652 %
7653 \def\Ynothing{}
7654 \def\Yomitfromtoc{}
7655 \def\Ynumbered{%
7656   \ifnum\secno=0
7657     \putwordChapter@tie \the\chapno
7658   \else \ifnum\subsecno=0
7659     \putwordSection@tie \the\chapno.\the\secno
7660   \else \ifnum\subsubsecno=0
7661     \putwordSection@tie \the\chapno.\the\secno.\the\subsecno
7662   \else
7663     \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno
7664   \fi\fi\fi
7665 }
7666 \def\Yappendix{%
7667   \ifnum\secno=0
7668      \putwordAppendix@tie @char\the\appendixno{}%
7669   \else \ifnum\subsecno=0
7670      \putwordSection@tie @char\the\appendixno.\the\secno
7671   \else \ifnum\subsubsecno=0
7672     \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno
7673   \else
7674     \putwordSection@tie
7675       @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno
7676   \fi\fi\fi
7677 }
7678
7679 % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
7680 % If its value is nonempty, SUFFIX is output afterward.
7681 %
7682 \def\refx#1#2{%
7683   {%
7684     \indexnofonts
7685     \otherbackslash
7686     \expandafter\global\expandafter\let\expandafter\thisrefX
7687       \csname XR#1\endcsname
7688   }%
7689   \ifx\thisrefX\relax
7690     % If not defined, say something at least.
7691     \angleleft un\-de\-fined\angleright
7692     \iflinks
7693       \ifhavexrefs
7694         {\toks0 = {#1}% avoid expansion of possibly-complex value
7695          \message{\linenumber Undefined cross reference `\the\toks0'.}}%
7696       \else
7697         \ifwarnedxrefs\else
7698           \global\warnedxrefstrue
7699           \message{Cross reference values unknown; you must run TeX again.}%
7700         \fi
7701       \fi
7702     \fi
7703   \else
7704     % It's defined, so just use it.
7705     \thisrefX
7706   \fi
7707   #2% Output the suffix in any case.
7708 }
7709
7710 % This is the macro invoked by entries in the aux file.  Usually it's
7711 % just a \def (we prepend XR to the control sequence name to avoid
7712 % collisions).  But if this is a float type, we have more work to do.
7713 %
7714 \def\xrdef#1#2{%
7715   {% The node name might contain 8-bit characters, which in our current
7716    % implementation are changed to commands like @'e.  Don't let these
7717    % mess up the control sequence name.
7718     \indexnofonts
7719     \turnoffactive
7720     \xdef\safexrefname{#1}%
7721   }%
7722   %
7723   \expandafter\gdef\csname XR\safexrefname\endcsname{#2}% remember this xref
7724   %
7725   % Was that xref control sequence that we just defined for a float?
7726   \expandafter\iffloat\csname XR\safexrefname\endcsname
7727     % it was a float, and we have the (safe) float type in \iffloattype.
7728     \expandafter\let\expandafter\floatlist
7729       \csname floatlist\iffloattype\endcsname
7730     %
7731     % Is this the first time we've seen this float type?
7732     \expandafter\ifx\floatlist\relax
7733       \toks0 = {\do}% yes, so just \do
7734     \else
7735       % had it before, so preserve previous elements in list.
7736       \toks0 = \expandafter{\floatlist\do}%
7737     \fi
7738     %
7739     % Remember this xref in the control sequence \floatlistFLOATTYPE,
7740     % for later use in \listoffloats.
7741     \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0
7742       {\safexrefname}}%
7743   \fi
7744 }
7745
7746 % Read the last existing aux file, if any.  No error if none exists.
7747 %
7748 \def\tryauxfile{%
7749   \openin 1 \jobname.aux
7750   \ifeof 1 \else
7751     \readdatafile{aux}%
7752     \global\havexrefstrue
7753   \fi
7754   \closein 1
7755 }
7756
7757 \def\setupdatafile{%
7758   \catcode`\^^@=\other
7759   \catcode`\^^A=\other
7760   \catcode`\^^B=\other
7761   \catcode`\^^C=\other
7762   \catcode`\^^D=\other
7763   \catcode`\^^E=\other
7764   \catcode`\^^F=\other
7765   \catcode`\^^G=\other
7766   \catcode`\^^H=\other
7767   \catcode`\^^K=\other
7768   \catcode`\^^L=\other
7769   \catcode`\^^N=\other
7770   \catcode`\^^P=\other
7771   \catcode`\^^Q=\other
7772   \catcode`\^^R=\other
7773   \catcode`\^^S=\other
7774   \catcode`\^^T=\other
7775   \catcode`\^^U=\other
7776   \catcode`\^^V=\other
7777   \catcode`\^^W=\other
7778   \catcode`\^^X=\other
7779   \catcode`\^^Z=\other
7780   \catcode`\^^[=\other
7781   \catcode`\^^\=\other
7782   \catcode`\^^]=\other
7783   \catcode`\^^^=\other
7784   \catcode`\^^_=\other
7785   % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc.
7786   % in xref tags, i.e., node names.  But since ^^e4 notation isn't
7787   % supported in the main text, it doesn't seem desirable.  Furthermore,
7788   % that is not enough: for node names that actually contain a ^
7789   % character, we would end up writing a line like this: 'xrdef {'hat
7790   % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first
7791   % argument, and \hat is not an expandable control sequence.  It could
7792   % all be worked out, but why?  Either we support ^^ or we don't.
7793   %
7794   % The other change necessary for this was to define \auxhat:
7795   % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter
7796   % and then to call \auxhat in \setq.
7797   %
7798   \catcode`\^=\other
7799   %
7800   % Special characters.  Should be turned off anyway, but...
7801   \catcode`\~=\other
7802   \catcode`\[=\other
7803   \catcode`\]=\other
7804   \catcode`\"=\other
7805   \catcode`\_=\other
7806   \catcode`\|=\other
7807   \catcode`\<=\other
7808   \catcode`\>=\other
7809   \catcode`\$=\other
7810   \catcode`\#=\other
7811   \catcode`\&=\other
7812   \catcode`\%=\other
7813   \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
7814   %
7815   % This is to support \ in node names and titles, since the \
7816   % characters end up in a \csname.  It's easier than
7817   % leaving it active and making its active definition an actual \
7818   % character.  What I don't understand is why it works in the *value*
7819   % of the xrdef.  Seems like it should be a catcode12 \, and that
7820   % should not typeset properly.  But it works, so I'm moving on for
7821   % now.  --karl, 15jan04.
7822   \catcode`\\=\other
7823   %
7824   % Make the characters 128-255 be printing characters.
7825   {%
7826     \count1=128
7827     \def\loop{%
7828       \catcode\count1=\other
7829       \advance\count1 by 1
7830       \ifnum \count1<256 \loop \fi
7831     }%
7832   }%
7833   %
7834   % @ is our escape character in .aux files, and we need braces.
7835   \catcode`\{=1
7836   \catcode`\}=2
7837   \catcode`\@=0
7838 }
7839
7840 \def\readdatafile#1{%
7841 \begingroup
7842   \setupdatafile
7843   \input\jobname.#1
7844 \endgroup}
7845
7846
7847 \message{insertions,}
7848 % including footnotes.
7849
7850 \newcount \footnoteno
7851
7852 % The trailing space in the following definition for supereject is
7853 % vital for proper filling; pages come out unaligned when you do a
7854 % pagealignmacro call if that space before the closing brace is
7855 % removed. (Generally, numeric constants should always be followed by a
7856 % space to prevent strange expansion errors.)
7857 \def\supereject{\par\penalty -20000\footnoteno =0 }
7858
7859 % @footnotestyle is meaningful for info output only.
7860 \let\footnotestyle=\comment
7861
7862 {\catcode `\@=11
7863 %
7864 % Auto-number footnotes.  Otherwise like plain.
7865 \gdef\footnote{%
7866   \let\indent=\ptexindent
7867   \let\noindent=\ptexnoindent
7868   \global\advance\footnoteno by \@ne
7869   \edef\thisfootno{$^{\the\footnoteno}$}%
7870   %
7871   % In case the footnote comes at the end of a sentence, preserve the
7872   % extra spacing after we do the footnote number.
7873   \let\@sf\empty
7874   \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi
7875   %
7876   % Remove inadvertent blank space before typesetting the footnote number.
7877   \unskip
7878   \thisfootno\@sf
7879   \dofootnote
7880 }%
7881
7882 % Don't bother with the trickery in plain.tex to not require the
7883 % footnote text as a parameter.  Our footnotes don't need to be so general.
7884 %
7885 % Oh yes, they do; otherwise, @ifset (and anything else that uses
7886 % \parseargline) fails inside footnotes because the tokens are fixed when
7887 % the footnote is read.  --karl, 16nov96.
7888 %
7889 \gdef\dofootnote{%
7890   \insert\footins\bgroup
7891   % We want to typeset this text as a normal paragraph, even if the
7892   % footnote reference occurs in (for example) a display environment.
7893   % So reset some parameters.
7894   \hsize=\pagewidth
7895   \interlinepenalty\interfootnotelinepenalty
7896   \splittopskip\ht\strutbox % top baseline for broken footnotes
7897   \splitmaxdepth\dp\strutbox
7898   \floatingpenalty\@MM
7899   \leftskip\z@skip
7900   \rightskip\z@skip
7901   \spaceskip\z@skip
7902   \xspaceskip\z@skip
7903   \parindent\defaultparindent
7904   %
7905   \smallfonts \rm
7906   %
7907   % Because we use hanging indentation in footnotes, a @noindent appears
7908   % to exdent this text, so make it be a no-op.  makeinfo does not use
7909   % hanging indentation so @noindent can still be needed within footnote
7910   % text after an @example or the like (not that this is good style).
7911   \let\noindent = \relax
7912   %
7913   % Hang the footnote text off the number.  Use \everypar in case the
7914   % footnote extends for more than one paragraph.
7915   \everypar = {\hang}%
7916   \textindent{\thisfootno}%
7917   %
7918   % Don't crash into the line above the footnote text.  Since this
7919   % expands into a box, it must come within the paragraph, lest it
7920   % provide a place where TeX can split the footnote.
7921   \footstrut
7922   \futurelet\next\fo@t
7923 }
7924 }%end \catcode `\@=11
7925
7926 % In case a @footnote appears in a vbox, save the footnote text and create
7927 % the real \insert just after the vbox finished.  Otherwise, the insertion
7928 % would be lost.
7929 % Similarly, if a @footnote appears inside an alignment, save the footnote
7930 % text to a box and make the \insert when a row of the table is finished.
7931 % And the same can be done for other insert classes.  --kasal, 16nov03.
7932
7933 % Replace the \insert primitive by a cheating macro.
7934 % Deeper inside, just make sure that the saved insertions are not spilled
7935 % out prematurely.
7936 %
7937 \def\startsavinginserts{%
7938   \ifx \insert\ptexinsert
7939     \let\insert\saveinsert
7940   \else
7941     \let\checkinserts\relax
7942   \fi
7943 }
7944
7945 % This \insert replacement works for both \insert\footins{foo} and
7946 % \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}.
7947 %
7948 \def\saveinsert#1{%
7949   \edef\next{\noexpand\savetobox \makeSAVEname#1}%
7950   \afterassignment\next
7951   % swallow the left brace
7952   \let\temp =
7953 }
7954 \def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}}
7955 \def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1}
7956
7957 \def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi}
7958
7959 \def\placesaveins#1{%
7960   \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname
7961     {\box#1}%
7962 }
7963
7964 % eat @SAVE -- beware, all of them have catcode \other:
7965 {
7966   \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials  %  ;-)
7967   \gdef\gobblesave @SAVE{}
7968 }
7969
7970 % initialization:
7971 \def\newsaveins #1{%
7972   \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}%
7973   \next
7974 }
7975 \def\newsaveinsX #1{%
7976   \csname newbox\endcsname #1%
7977   \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts
7978     \checksaveins #1}%
7979 }
7980
7981 % initialize:
7982 \let\checkinserts\empty
7983 \newsaveins\footins
7984 \newsaveins\margin
7985
7986
7987 % @image.  We use the macros from epsf.tex to support this.
7988 % If epsf.tex is not installed and @image is used, we complain.
7989 %
7990 % Check for and read epsf.tex up front.  If we read it only at @image
7991 % time, we might be inside a group, and then its definitions would get
7992 % undone and the next image would fail.
7993 \openin 1 = epsf.tex
7994 \ifeof 1 \else
7995   % Do not bother showing banner with epsf.tex v2.7k (available in
7996   % doc/epsf.tex and on ctan).
7997   \def\epsfannounce{\toks0 = }%
7998   \input epsf.tex
7999 \fi
8000 \closein 1
8001 %
8002 % We will only complain once about lack of epsf.tex.
8003 \newif\ifwarnednoepsf
8004 \newhelp\noepsfhelp{epsf.tex must be installed for images to
8005   work.  It is also included in the Texinfo distribution, or you can get
8006   it from ftp://tug.org/tex/epsf.tex.}
8007 %
8008 \def\image#1{%
8009   \ifx\epsfbox\thisiundefined
8010     \ifwarnednoepsf \else
8011       \errhelp = \noepsfhelp
8012       \errmessage{epsf.tex not found, images will be ignored}%
8013       \global\warnednoepsftrue
8014     \fi
8015   \else
8016     \imagexxx #1,,,,,\finish
8017   \fi
8018 }
8019 %
8020 % Arguments to @image:
8021 % #1 is (mandatory) image filename; we tack on .eps extension.
8022 % #2 is (optional) width, #3 is (optional) height.
8023 % #4 is (ignored optional) html alt text.
8024 % #5 is (ignored optional) extension.
8025 % #6 is just the usual extra ignored arg for parsing stuff.
8026 \newif\ifimagevmode
8027 \def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup
8028   \catcode`\^^M = 5     % in case we're inside an example
8029   \normalturnoffactive  % allow _ et al. in names
8030   % If the image is by itself, center it.
8031   \ifvmode
8032     \imagevmodetrue
8033     \nobreak\medskip
8034     % Usually we'll have text after the image which will insert
8035     % \parskip glue, so insert it here too to equalize the space
8036     % above and below.
8037     \nobreak\vskip\parskip
8038     \nobreak
8039   \fi
8040   %
8041   % Leave vertical mode so that indentation from an enclosing
8042   % environment such as @quotation is respected.  On the other hand, if
8043   % it's at the top level, we don't want the normal paragraph indentation.
8044   \noindent
8045   %
8046   % Output the image.
8047   \ifpdf
8048     \dopdfimage{#1}{#2}{#3}%
8049   \else
8050     % \epsfbox itself resets \epsf?size at each figure.
8051     \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
8052     \setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
8053     \epsfbox{#1.eps}%
8054   \fi
8055   %
8056   \ifimagevmode \medskip \fi  % space after the standalone image
8057 \endgroup}
8058
8059
8060 % @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables,
8061 % etc.  We don't actually implement floating yet, we always include the
8062 % float "here".  But it seemed the best name for the future.
8063 %
8064 \envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish}
8065
8066 % There may be a space before second and/or third parameter; delete it.
8067 \def\eatcommaspace#1, {#1,}
8068
8069 % #1 is the optional FLOATTYPE, the text label for this float, typically
8070 % "Figure", "Table", "Example", etc.  Can't contain commas.  If omitted,
8071 % this float will not be numbered and cannot be referred to.
8072 %
8073 % #2 is the optional xref label.  Also must be present for the float to
8074 % be referable.
8075 %
8076 % #3 is the optional positioning argument; for now, it is ignored.  It
8077 % will somehow specify the positions allowed to float to (here, top, bottom).
8078 %
8079 % We keep a separate counter for each FLOATTYPE, which we reset at each
8080 % chapter-level command.
8081 \let\resetallfloatnos=\empty
8082 %
8083 \def\dofloat#1,#2,#3,#4\finish{%
8084   \let\thiscaption=\empty
8085   \let\thisshortcaption=\empty
8086   %
8087   % don't lose footnotes inside @float.
8088   %
8089   % BEWARE: when the floats start float, we have to issue warning whenever an
8090   % insert appears inside a float which could possibly float. --kasal, 26may04
8091   %
8092   \startsavinginserts
8093   %
8094   % We can't be used inside a paragraph.
8095   \par
8096   %
8097   \vtop\bgroup
8098     \def\floattype{#1}%
8099     \def\floatlabel{#2}%
8100     \def\floatloc{#3}% we do nothing with this yet.
8101     %
8102     \ifx\floattype\empty
8103       \let\safefloattype=\empty
8104     \else
8105       {%
8106         % the floattype might have accents or other special characters,
8107         % but we need to use it in a control sequence name.
8108         \indexnofonts
8109         \turnoffactive
8110         \xdef\safefloattype{\floattype}%
8111       }%
8112     \fi
8113     %
8114     % If label is given but no type, we handle that as the empty type.
8115     \ifx\floatlabel\empty \else
8116       % We want each FLOATTYPE to be numbered separately (Figure 1,
8117       % Table 1, Figure 2, ...).  (And if no label, no number.)
8118       %
8119       \expandafter\getfloatno\csname\safefloattype floatno\endcsname
8120       \global\advance\floatno by 1
8121       %
8122       {%
8123         % This magic value for \lastsection is output by \setref as the
8124         % XREFLABEL-title value.  \xrefX uses it to distinguish float
8125         % labels (which have a completely different output format) from
8126         % node and anchor labels.  And \xrdef uses it to construct the
8127         % lists of floats.
8128         %
8129         \edef\lastsection{\floatmagic=\safefloattype}%
8130         \setref{\floatlabel}{Yfloat}%
8131       }%
8132     \fi
8133     %
8134     % start with \parskip glue, I guess.
8135     \vskip\parskip
8136     %
8137     % Don't suppress indentation if a float happens to start a section.
8138     \restorefirstparagraphindent
8139 }
8140
8141 % we have these possibilities:
8142 % @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap
8143 % @float Foo,lbl & no caption:    Foo 1.1
8144 % @float Foo & @caption{Cap}:     Foo: Cap
8145 % @float Foo & no caption:        Foo
8146 % @float ,lbl & Caption{Cap}:     1.1: Cap
8147 % @float ,lbl & no caption:       1.1
8148 % @float & @caption{Cap}:         Cap
8149 % @float & no caption:
8150 %
8151 \def\Efloat{%
8152     \let\floatident = \empty
8153     %
8154     % In all cases, if we have a float type, it comes first.
8155     \ifx\floattype\empty \else \def\floatident{\floattype}\fi
8156     %
8157     % If we have an xref label, the number comes next.
8158     \ifx\floatlabel\empty \else
8159       \ifx\floattype\empty \else % if also had float type, need tie first.
8160         \appendtomacro\floatident{\tie}%
8161       \fi
8162       % the number.
8163       \appendtomacro\floatident{\chaplevelprefix\the\floatno}%
8164     \fi
8165     %
8166     % Start the printed caption with what we've constructed in
8167     % \floatident, but keep it separate; we need \floatident again.
8168     \let\captionline = \floatident
8169     %
8170     \ifx\thiscaption\empty \else
8171       \ifx\floatident\empty \else
8172         \appendtomacro\captionline{: }% had ident, so need a colon between
8173       \fi
8174       %
8175       % caption text.
8176       \appendtomacro\captionline{\scanexp\thiscaption}%
8177     \fi
8178     %
8179     % If we have anything to print, print it, with space before.
8180     % Eventually this needs to become an \insert.
8181     \ifx\captionline\empty \else
8182       \vskip.5\parskip
8183       \captionline
8184       %
8185       % Space below caption.
8186       \vskip\parskip
8187     \fi
8188     %
8189     % If have an xref label, write the list of floats info.  Do this
8190     % after the caption, to avoid chance of it being a breakpoint.
8191     \ifx\floatlabel\empty \else
8192       % Write the text that goes in the lof to the aux file as
8193       % \floatlabel-lof.  Besides \floatident, we include the short
8194       % caption if specified, else the full caption if specified, else nothing.
8195       {%
8196         \atdummies
8197         %
8198         % since we read the caption text in the macro world, where ^^M
8199         % is turned into a normal character, we have to scan it back, so
8200         % we don't write the literal three characters "^^M" into the aux file.
8201         \scanexp{%
8202           \xdef\noexpand\gtemp{%
8203             \ifx\thisshortcaption\empty
8204               \thiscaption
8205             \else
8206               \thisshortcaption
8207             \fi
8208           }%
8209         }%
8210         \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident
8211           \ifx\gtemp\empty \else : \gtemp \fi}}%
8212       }%
8213     \fi
8214   \egroup  % end of \vtop
8215   %
8216   % place the captured inserts
8217   %
8218   % BEWARE: when the floats start floating, we have to issue warning
8219   % whenever an insert appears inside a float which could possibly
8220   % float. --kasal, 26may04
8221   %
8222   \checkinserts
8223 }
8224
8225 % Append the tokens #2 to the definition of macro #1, not expanding either.
8226 %
8227 \def\appendtomacro#1#2{%
8228   \expandafter\def\expandafter#1\expandafter{#1#2}%
8229 }
8230
8231 % @caption, @shortcaption
8232 %
8233 \def\caption{\docaption\thiscaption}
8234 \def\shortcaption{\docaption\thisshortcaption}
8235 \def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption}
8236 \def\defcaption#1#2{\egroup \def#1{#2}}
8237
8238 % The parameter is the control sequence identifying the counter we are
8239 % going to use.  Create it if it doesn't exist and assign it to \floatno.
8240 \def\getfloatno#1{%
8241   \ifx#1\relax
8242       % Haven't seen this figure type before.
8243       \csname newcount\endcsname #1%
8244       %
8245       % Remember to reset this floatno at the next chap.
8246       \expandafter\gdef\expandafter\resetallfloatnos
8247         \expandafter{\resetallfloatnos #1=0 }%
8248   \fi
8249   \let\floatno#1%
8250 }
8251
8252 % \setref calls this to get the XREFLABEL-snt value.  We want an @xref
8253 % to the FLOATLABEL to expand to "Figure 3.1".  We call \setref when we
8254 % first read the @float command.
8255 %
8256 \def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}%
8257
8258 % Magic string used for the XREFLABEL-title value, so \xrefX can
8259 % distinguish floats from other xref types.
8260 \def\floatmagic{!!float!!}
8261
8262 % #1 is the control sequence we are passed; we expand into a conditional
8263 % which is true if #1 represents a float ref.  That is, the magic
8264 % \lastsection value which we \setref above.
8265 %
8266 \def\iffloat#1{\expandafter\doiffloat#1==\finish}
8267 %
8268 % #1 is (maybe) the \floatmagic string.  If so, #2 will be the
8269 % (safe) float type for this float.  We set \iffloattype to #2.
8270 %
8271 \def\doiffloat#1=#2=#3\finish{%
8272   \def\temp{#1}%
8273   \def\iffloattype{#2}%
8274   \ifx\temp\floatmagic
8275 }
8276
8277 % @listoffloats FLOATTYPE - print a list of floats like a table of contents.
8278 %
8279 \parseargdef\listoffloats{%
8280   \def\floattype{#1}% floattype
8281   {%
8282     % the floattype might have accents or other special characters,
8283     % but we need to use it in a control sequence name.
8284     \indexnofonts
8285     \turnoffactive
8286     \xdef\safefloattype{\floattype}%
8287   }%
8288   %
8289   % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE.
8290   \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax
8291     \ifhavexrefs
8292       % if the user said @listoffloats foo but never @float foo.
8293       \message{\linenumber No `\safefloattype' floats to list.}%
8294     \fi
8295   \else
8296     \begingroup
8297       \leftskip=\tocindent  % indent these entries like a toc
8298       \let\do=\listoffloatsdo
8299       \csname floatlist\safefloattype\endcsname
8300     \endgroup
8301   \fi
8302 }
8303
8304 % This is called on each entry in a list of floats.  We're passed the
8305 % xref label, in the form LABEL-title, which is how we save it in the
8306 % aux file.  We strip off the -title and look up \XRLABEL-lof, which
8307 % has the text we're supposed to typeset here.
8308 %
8309 % Figures without xref labels will not be included in the list (since
8310 % they won't appear in the aux file).
8311 %
8312 \def\listoffloatsdo#1{\listoffloatsdoentry#1\finish}
8313 \def\listoffloatsdoentry#1-title\finish{{%
8314   % Can't fully expand XR#1-lof because it can contain anything.  Just
8315   % pass the control sequence.  On the other hand, XR#1-pg is just the
8316   % page number, and we want to fully expand that so we can get a link
8317   % in pdf output.
8318   \toksA = \expandafter{\csname XR#1-lof\endcsname}%
8319   %
8320   % use the same \entry macro we use to generate the TOC and index.
8321   \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}%
8322   \writeentry
8323 }}
8324
8325
8326 \message{localization,}
8327
8328 % For single-language documents, @documentlanguage is usually given very
8329 % early, just after @documentencoding.  Single argument is the language
8330 % (de) or locale (de_DE) abbreviation.
8331 %
8332 {
8333   \catcode`\_ = \active
8334   \globaldefs=1
8335 \parseargdef\documentlanguage{\begingroup
8336   \let_=\normalunderscore  % normal _ character for filenames
8337   \tex % read txi-??.tex file in plain TeX.
8338     % Read the file by the name they passed if it exists.
8339     \openin 1 txi-#1.tex
8340     \ifeof 1
8341       \documentlanguagetrywithoutunderscore{#1_\finish}%
8342     \else
8343       \globaldefs = 1  % everything in the txi-LL files needs to persist
8344       \input txi-#1.tex
8345     \fi
8346     \closein 1
8347   \endgroup % end raw TeX
8348 \endgroup}
8349 %
8350 % If they passed de_DE, and txi-de_DE.tex doesn't exist,
8351 % try txi-de.tex.
8352 %
8353 \gdef\documentlanguagetrywithoutunderscore#1_#2\finish{%
8354   \openin 1 txi-#1.tex
8355   \ifeof 1
8356     \errhelp = \nolanghelp
8357     \errmessage{Cannot read language file txi-#1.tex}%
8358   \else
8359     \globaldefs = 1  % everything in the txi-LL files needs to persist
8360     \input txi-#1.tex
8361   \fi
8362   \closein 1
8363 }
8364 }% end of special _ catcode
8365 %
8366 \newhelp\nolanghelp{The given language definition file cannot be found or
8367 is empty.  Maybe you need to install it?  Putting it in the current
8368 directory should work if nowhere else does.}
8369
8370 % This macro is called from txi-??.tex files; the first argument is the
8371 % \language name to set (without the "\lang@" prefix), the second and
8372 % third args are \{left,right}hyphenmin.
8373 %
8374 % The language names to pass are determined when the format is built.
8375 % See the etex.log file created at that time, e.g.,
8376 % /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log.
8377 %
8378 % With TeX Live 2008, etex now includes hyphenation patterns for all
8379 % available languages.  This means we can support hyphenation in
8380 % Texinfo, at least to some extent.  (This still doesn't solve the
8381 % accented characters problem.)
8382 %
8383 \catcode`@=11
8384 \def\txisetlanguage#1#2#3{%
8385   % do not set the language if the name is undefined in the current TeX.
8386   \expandafter\ifx\csname lang@#1\endcsname \relax
8387     \message{no patterns for #1}%
8388   \else
8389     \global\language = \csname lang@#1\endcsname
8390   \fi
8391   % but there is no harm in adjusting the hyphenmin values regardless.
8392   \global\lefthyphenmin = #2\relax
8393   \global\righthyphenmin = #3\relax
8394 }
8395
8396 % Helpers for encodings.
8397 % Set the catcode of characters 128 through 255 to the specified number.
8398 %
8399 \def\setnonasciicharscatcode#1{%
8400    \count255=128
8401    \loop\ifnum\count255<256
8402       \global\catcode\count255=#1\relax
8403       \advance\count255 by 1
8404    \repeat
8405 }
8406
8407 \def\setnonasciicharscatcodenonglobal#1{%
8408    \count255=128
8409    \loop\ifnum\count255<256
8410       \catcode\count255=#1\relax
8411       \advance\count255 by 1
8412    \repeat
8413 }
8414
8415 % @documentencoding sets the definition of non-ASCII characters
8416 % according to the specified encoding.
8417 %
8418 \parseargdef\documentencoding{%
8419   % Encoding being declared for the document.
8420   \def\declaredencoding{\csname #1.enc\endcsname}%
8421   %
8422   % Supported encodings: names converted to tokens in order to be able
8423   % to compare them with \ifx.
8424   \def\ascii{\csname US-ASCII.enc\endcsname}%
8425   \def\latnine{\csname ISO-8859-15.enc\endcsname}%
8426   \def\latone{\csname ISO-8859-1.enc\endcsname}%
8427   \def\lattwo{\csname ISO-8859-2.enc\endcsname}%
8428   \def\utfeight{\csname UTF-8.enc\endcsname}%
8429   %
8430   \ifx \declaredencoding \ascii
8431      \asciichardefs
8432   %
8433   \else \ifx \declaredencoding \lattwo
8434      \setnonasciicharscatcode\active
8435      \lattwochardefs
8436   %
8437   \else \ifx \declaredencoding \latone
8438      \setnonasciicharscatcode\active
8439      \latonechardefs
8440   %
8441   \else \ifx \declaredencoding \latnine
8442      \setnonasciicharscatcode\active
8443      \latninechardefs
8444   %
8445   \else \ifx \declaredencoding \utfeight
8446      \setnonasciicharscatcode\active
8447      \utfeightchardefs
8448   %
8449   \else
8450     \message{Unknown document encoding #1, ignoring.}%
8451   %
8452   \fi % utfeight
8453   \fi % latnine
8454   \fi % latone
8455   \fi % lattwo
8456   \fi % ascii
8457 }
8458
8459 % A message to be logged when using a character that isn't available
8460 % the default font encoding (OT1).
8461 %
8462 \def\missingcharmsg#1{\message{Character missing in OT1 encoding: #1.}}
8463
8464 % Take account of \c (plain) vs. \, (Texinfo) difference.
8465 \def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi}
8466
8467 % First, make active non-ASCII characters in order for them to be
8468 % correctly categorized when TeX reads the replacement text of
8469 % macros containing the character definitions.
8470 \setnonasciicharscatcode\active
8471 %
8472 % Latin1 (ISO-8859-1) character definitions.
8473 \def\latonechardefs{%
8474   \gdef^^a0{\tie}
8475   \gdef^^a1{\exclamdown}
8476   \gdef^^a2{\missingcharmsg{CENT SIGN}}
8477   \gdef^^a3{{\pounds}}
8478   \gdef^^a4{\missingcharmsg{CURRENCY SIGN}}
8479   \gdef^^a5{\missingcharmsg{YEN SIGN}}
8480   \gdef^^a6{\missingcharmsg{BROKEN BAR}}
8481   \gdef^^a7{\S}
8482   \gdef^^a8{\"{}}
8483   \gdef^^a9{\copyright}
8484   \gdef^^aa{\ordf}
8485   \gdef^^ab{\guillemetleft}
8486   \gdef^^ac{$\lnot$}
8487   \gdef^^ad{\-}
8488   \gdef^^ae{\registeredsymbol}
8489   \gdef^^af{\={}}
8490   %
8491   \gdef^^b0{\textdegree}
8492   \gdef^^b1{$\pm$}
8493   \gdef^^b2{$^2$}
8494   \gdef^^b3{$^3$}
8495   \gdef^^b4{\'{}}
8496   \gdef^^b5{$\mu$}
8497   \gdef^^b6{\P}
8498   %
8499   \gdef^^b7{$^.$}
8500   \gdef^^b8{\cedilla\ }
8501   \gdef^^b9{$^1$}
8502   \gdef^^ba{\ordm}
8503   %
8504   \gdef^^bb{\guillemetright}
8505   \gdef^^bc{$1\over4$}
8506   \gdef^^bd{$1\over2$}
8507   \gdef^^be{$3\over4$}
8508   \gdef^^bf{\questiondown}
8509   %
8510   \gdef^^c0{\`A}
8511   \gdef^^c1{\'A}
8512   \gdef^^c2{\^A}
8513   \gdef^^c3{\~A}
8514   \gdef^^c4{\"A}
8515   \gdef^^c5{\ringaccent A}
8516   \gdef^^c6{\AE}
8517   \gdef^^c7{\cedilla C}
8518   \gdef^^c8{\`E}
8519   \gdef^^c9{\'E}
8520   \gdef^^ca{\^E}
8521   \gdef^^cb{\"E}
8522   \gdef^^cc{\`I}
8523   \gdef^^cd{\'I}
8524   \gdef^^ce{\^I}
8525   \gdef^^cf{\"I}
8526   %
8527   \gdef^^d0{\DH}
8528   \gdef^^d1{\~N}
8529   \gdef^^d2{\`O}
8530   \gdef^^d3{\'O}
8531   \gdef^^d4{\^O}
8532   \gdef^^d5{\~O}
8533   \gdef^^d6{\"O}
8534   \gdef^^d7{$\times$}
8535   \gdef^^d8{\O}
8536   \gdef^^d9{\`U}
8537   \gdef^^da{\'U}
8538   \gdef^^db{\^U}
8539   \gdef^^dc{\"U}
8540   \gdef^^dd{\'Y}
8541   \gdef^^de{\TH}
8542   \gdef^^df{\ss}
8543   %
8544   \gdef^^e0{\`a}
8545   \gdef^^e1{\'a}
8546   \gdef^^e2{\^a}
8547   \gdef^^e3{\~a}
8548   \gdef^^e4{\"a}
8549   \gdef^^e5{\ringaccent a}
8550   \gdef^^e6{\ae}
8551   \gdef^^e7{\cedilla c}
8552   \gdef^^e8{\`e}
8553   \gdef^^e9{\'e}
8554   \gdef^^ea{\^e}
8555   \gdef^^eb{\"e}
8556   \gdef^^ec{\`{\dotless i}}
8557   \gdef^^ed{\'{\dotless i}}
8558   \gdef^^ee{\^{\dotless i}}
8559   \gdef^^ef{\"{\dotless i}}
8560   %
8561   \gdef^^f0{\dh}
8562   \gdef^^f1{\~n}
8563   \gdef^^f2{\`o}
8564   \gdef^^f3{\'o}
8565   \gdef^^f4{\^o}
8566   \gdef^^f5{\~o}
8567   \gdef^^f6{\"o}
8568   \gdef^^f7{$\div$}
8569   \gdef^^f8{\o}
8570   \gdef^^f9{\`u}
8571   \gdef^^fa{\'u}
8572   \gdef^^fb{\^u}
8573   \gdef^^fc{\"u}
8574   \gdef^^fd{\'y}
8575   \gdef^^fe{\th}
8576   \gdef^^ff{\"y}
8577 }
8578
8579 % Latin9 (ISO-8859-15) encoding character definitions.
8580 \def\latninechardefs{%
8581   % Encoding is almost identical to Latin1.
8582   \latonechardefs
8583   %
8584   \gdef^^a4{\euro}
8585   \gdef^^a6{\v S}
8586   \gdef^^a8{\v s}
8587   \gdef^^b4{\v Z}
8588   \gdef^^b8{\v z}
8589   \gdef^^bc{\OE}
8590   \gdef^^bd{\oe}
8591   \gdef^^be{\"Y}
8592 }
8593
8594 % Latin2 (ISO-8859-2) character definitions.
8595 \def\lattwochardefs{%
8596   \gdef^^a0{\tie}
8597   \gdef^^a1{\ogonek{A}}
8598   \gdef^^a2{\u{}}
8599   \gdef^^a3{\L}
8600   \gdef^^a4{\missingcharmsg{CURRENCY SIGN}}
8601   \gdef^^a5{\v L}
8602   \gdef^^a6{\'S}
8603   \gdef^^a7{\S}
8604   \gdef^^a8{\"{}}
8605   \gdef^^a9{\v S}
8606   \gdef^^aa{\cedilla S}
8607   \gdef^^ab{\v T}
8608   \gdef^^ac{\'Z}
8609   \gdef^^ad{\-}
8610   \gdef^^ae{\v Z}
8611   \gdef^^af{\dotaccent Z}
8612   %
8613   \gdef^^b0{\textdegree}
8614   \gdef^^b1{\ogonek{a}}
8615   \gdef^^b2{\ogonek{ }}
8616   \gdef^^b3{\l}
8617   \gdef^^b4{\'{}}
8618   \gdef^^b5{\v l}
8619   \gdef^^b6{\'s}
8620   \gdef^^b7{\v{}}
8621   \gdef^^b8{\cedilla\ }
8622   \gdef^^b9{\v s}
8623   \gdef^^ba{\cedilla s}
8624   \gdef^^bb{\v t}
8625   \gdef^^bc{\'z}
8626   \gdef^^bd{\H{}}
8627   \gdef^^be{\v z}
8628   \gdef^^bf{\dotaccent z}
8629   %
8630   \gdef^^c0{\'R}
8631   \gdef^^c1{\'A}
8632   \gdef^^c2{\^A}
8633   \gdef^^c3{\u A}
8634   \gdef^^c4{\"A}
8635   \gdef^^c5{\'L}
8636   \gdef^^c6{\'C}
8637   \gdef^^c7{\cedilla C}
8638   \gdef^^c8{\v C}
8639   \gdef^^c9{\'E}
8640   \gdef^^ca{\ogonek{E}}
8641   \gdef^^cb{\"E}
8642   \gdef^^cc{\v E}
8643   \gdef^^cd{\'I}
8644   \gdef^^ce{\^I}
8645   \gdef^^cf{\v D}
8646   %
8647   \gdef^^d0{\DH}
8648   \gdef^^d1{\'N}
8649   \gdef^^d2{\v N}
8650   \gdef^^d3{\'O}
8651   \gdef^^d4{\^O}
8652   \gdef^^d5{\H O}
8653   \gdef^^d6{\"O}
8654   \gdef^^d7{$\times$}
8655   \gdef^^d8{\v R}
8656   \gdef^^d9{\ringaccent U}
8657   \gdef^^da{\'U}
8658   \gdef^^db{\H U}
8659   \gdef^^dc{\"U}
8660   \gdef^^dd{\'Y}
8661   \gdef^^de{\cedilla T}
8662   \gdef^^df{\ss}
8663   %
8664   \gdef^^e0{\'r}
8665   \gdef^^e1{\'a}
8666   \gdef^^e2{\^a}
8667   \gdef^^e3{\u a}
8668   \gdef^^e4{\"a}
8669   \gdef^^e5{\'l}
8670   \gdef^^e6{\'c}
8671   \gdef^^e7{\cedilla c}
8672   \gdef^^e8{\v c}
8673   \gdef^^e9{\'e}
8674   \gdef^^ea{\ogonek{e}}
8675   \gdef^^eb{\"e}
8676   \gdef^^ec{\v e}
8677   \gdef^^ed{\'{\dotless{i}}}
8678   \gdef^^ee{\^{\dotless{i}}}
8679   \gdef^^ef{\v d}
8680   %
8681   \gdef^^f0{\dh}
8682   \gdef^^f1{\'n}
8683   \gdef^^f2{\v n}
8684   \gdef^^f3{\'o}
8685   \gdef^^f4{\^o}
8686   \gdef^^f5{\H o}
8687   \gdef^^f6{\"o}
8688   \gdef^^f7{$\div$}
8689   \gdef^^f8{\v r}
8690   \gdef^^f9{\ringaccent u}
8691   \gdef^^fa{\'u}
8692   \gdef^^fb{\H u}
8693   \gdef^^fc{\"u}
8694   \gdef^^fd{\'y}
8695   \gdef^^fe{\cedilla t}
8696   \gdef^^ff{\dotaccent{}}
8697 }
8698
8699 % UTF-8 character definitions.
8700 %
8701 % This code to support UTF-8 is based on LaTeX's utf8.def, with some
8702 % changes for Texinfo conventions.  It is included here under the GPL by
8703 % permission from Frank Mittelbach and the LaTeX team.
8704 %
8705 \newcount\countUTFx
8706 \newcount\countUTFy
8707 \newcount\countUTFz
8708
8709 \gdef\UTFviiiTwoOctets#1#2{\expandafter
8710    \UTFviiiDefined\csname u8:#1\string #2\endcsname}
8711 %
8712 \gdef\UTFviiiThreeOctets#1#2#3{\expandafter
8713    \UTFviiiDefined\csname u8:#1\string #2\string #3\endcsname}
8714 %
8715 \gdef\UTFviiiFourOctets#1#2#3#4{\expandafter
8716    \UTFviiiDefined\csname u8:#1\string #2\string #3\string #4\endcsname}
8717
8718 \gdef\UTFviiiDefined#1{%
8719   \ifx #1\relax
8720     \message{\linenumber Unicode char \string #1 not defined for Texinfo}%
8721   \else
8722     \expandafter #1%
8723   \fi
8724 }
8725
8726 \begingroup
8727   \catcode`\~13
8728   \catcode`\"12
8729
8730   \def\UTFviiiLoop{%
8731     \global\catcode\countUTFx\active
8732     \uccode`\~\countUTFx
8733     \uppercase\expandafter{\UTFviiiTmp}%
8734     \advance\countUTFx by 1
8735     \ifnum\countUTFx < \countUTFy
8736       \expandafter\UTFviiiLoop
8737     \fi}
8738
8739   \countUTFx = "C2
8740   \countUTFy = "E0
8741   \def\UTFviiiTmp{%
8742     \xdef~{\noexpand\UTFviiiTwoOctets\string~}}
8743   \UTFviiiLoop
8744
8745   \countUTFx = "E0
8746   \countUTFy = "F0
8747   \def\UTFviiiTmp{%
8748     \xdef~{\noexpand\UTFviiiThreeOctets\string~}}
8749   \UTFviiiLoop
8750
8751   \countUTFx = "F0
8752   \countUTFy = "F4
8753   \def\UTFviiiTmp{%
8754     \xdef~{\noexpand\UTFviiiFourOctets\string~}}
8755   \UTFviiiLoop
8756 \endgroup
8757
8758 \begingroup
8759   \catcode`\"=12
8760   \catcode`\<=12
8761   \catcode`\.=12
8762   \catcode`\,=12
8763   \catcode`\;=12
8764   \catcode`\!=12
8765   \catcode`\~=13
8766
8767   \gdef\DeclareUnicodeCharacter#1#2{%
8768     \countUTFz = "#1\relax
8769     %\wlog{\space\space defining Unicode char U+#1 (decimal \the\countUTFz)}%
8770     \begingroup
8771       \parseXMLCharref
8772       \def\UTFviiiTwoOctets##1##2{%
8773         \csname u8:##1\string ##2\endcsname}%
8774       \def\UTFviiiThreeOctets##1##2##3{%
8775         \csname u8:##1\string ##2\string ##3\endcsname}%
8776       \def\UTFviiiFourOctets##1##2##3##4{%
8777         \csname u8:##1\string ##2\string ##3\string ##4\endcsname}%
8778       \expandafter\expandafter\expandafter\expandafter
8779        \expandafter\expandafter\expandafter
8780        \gdef\UTFviiiTmp{#2}%
8781     \endgroup}
8782
8783   \gdef\parseXMLCharref{%
8784     \ifnum\countUTFz < "A0\relax
8785       \errhelp = \EMsimple
8786       \errmessage{Cannot define Unicode char value < 00A0}%
8787     \else\ifnum\countUTFz < "800\relax
8788       \parseUTFviiiA,%
8789       \parseUTFviiiB C\UTFviiiTwoOctets.,%
8790     \else\ifnum\countUTFz < "10000\relax
8791       \parseUTFviiiA;%
8792       \parseUTFviiiA,%
8793       \parseUTFviiiB E\UTFviiiThreeOctets.{,;}%
8794     \else
8795       \parseUTFviiiA;%
8796       \parseUTFviiiA,%
8797       \parseUTFviiiA!%
8798       \parseUTFviiiB F\UTFviiiFourOctets.{!,;}%
8799     \fi\fi\fi
8800   }
8801
8802   \gdef\parseUTFviiiA#1{%
8803     \countUTFx = \countUTFz
8804     \divide\countUTFz by 64
8805     \countUTFy = \countUTFz
8806     \multiply\countUTFz by 64
8807     \advance\countUTFx by -\countUTFz
8808     \advance\countUTFx by 128
8809     \uccode `#1\countUTFx
8810     \countUTFz = \countUTFy}
8811
8812   \gdef\parseUTFviiiB#1#2#3#4{%
8813     \advance\countUTFz by "#10\relax
8814     \uccode `#3\countUTFz
8815     \uppercase{\gdef\UTFviiiTmp{#2#3#4}}}
8816 \endgroup
8817
8818 \def\utfeightchardefs{%
8819   \DeclareUnicodeCharacter{00A0}{\tie}
8820   \DeclareUnicodeCharacter{00A1}{\exclamdown}
8821   \DeclareUnicodeCharacter{00A3}{\pounds}
8822   \DeclareUnicodeCharacter{00A8}{\"{ }}
8823   \DeclareUnicodeCharacter{00A9}{\copyright}
8824   \DeclareUnicodeCharacter{00AA}{\ordf}
8825   \DeclareUnicodeCharacter{00AB}{\guillemetleft}
8826   \DeclareUnicodeCharacter{00AD}{\-}
8827   \DeclareUnicodeCharacter{00AE}{\registeredsymbol}
8828   \DeclareUnicodeCharacter{00AF}{\={ }}
8829
8830   \DeclareUnicodeCharacter{00B0}{\ringaccent{ }}
8831   \DeclareUnicodeCharacter{00B4}{\'{ }}
8832   \DeclareUnicodeCharacter{00B8}{\cedilla{ }}
8833   \DeclareUnicodeCharacter{00BA}{\ordm}
8834   \DeclareUnicodeCharacter{00BB}{\guillemetright}
8835   \DeclareUnicodeCharacter{00BF}{\questiondown}
8836
8837   \DeclareUnicodeCharacter{00C0}{\`A}
8838   \DeclareUnicodeCharacter{00C1}{\'A}
8839   \DeclareUnicodeCharacter{00C2}{\^A}
8840   \DeclareUnicodeCharacter{00C3}{\~A}
8841   \DeclareUnicodeCharacter{00C4}{\"A}
8842   \DeclareUnicodeCharacter{00C5}{\AA}
8843   \DeclareUnicodeCharacter{00C6}{\AE}
8844   \DeclareUnicodeCharacter{00C7}{\cedilla{C}}
8845   \DeclareUnicodeCharacter{00C8}{\`E}
8846   \DeclareUnicodeCharacter{00C9}{\'E}
8847   \DeclareUnicodeCharacter{00CA}{\^E}
8848   \DeclareUnicodeCharacter{00CB}{\"E}
8849   \DeclareUnicodeCharacter{00CC}{\`I}
8850   \DeclareUnicodeCharacter{00CD}{\'I}
8851   \DeclareUnicodeCharacter{00CE}{\^I}
8852   \DeclareUnicodeCharacter{00CF}{\"I}
8853
8854   \DeclareUnicodeCharacter{00D0}{\DH}
8855   \DeclareUnicodeCharacter{00D1}{\~N}
8856   \DeclareUnicodeCharacter{00D2}{\`O}
8857   \DeclareUnicodeCharacter{00D3}{\'O}
8858   \DeclareUnicodeCharacter{00D4}{\^O}
8859   \DeclareUnicodeCharacter{00D5}{\~O}
8860   \DeclareUnicodeCharacter{00D6}{\"O}
8861   \DeclareUnicodeCharacter{00D8}{\O}
8862   \DeclareUnicodeCharacter{00D9}{\`U}
8863   \DeclareUnicodeCharacter{00DA}{\'U}
8864   \DeclareUnicodeCharacter{00DB}{\^U}
8865   \DeclareUnicodeCharacter{00DC}{\"U}
8866   \DeclareUnicodeCharacter{00DD}{\'Y}
8867   \DeclareUnicodeCharacter{00DE}{\TH}
8868   \DeclareUnicodeCharacter{00DF}{\ss}
8869
8870   \DeclareUnicodeCharacter{00E0}{\`a}
8871   \DeclareUnicodeCharacter{00E1}{\'a}
8872   \DeclareUnicodeCharacter{00E2}{\^a}
8873   \DeclareUnicodeCharacter{00E3}{\~a}
8874   \DeclareUnicodeCharacter{00E4}{\"a}
8875   \DeclareUnicodeCharacter{00E5}{\aa}
8876   \DeclareUnicodeCharacter{00E6}{\ae}
8877   \DeclareUnicodeCharacter{00E7}{\cedilla{c}}
8878   \DeclareUnicodeCharacter{00E8}{\`e}
8879   \DeclareUnicodeCharacter{00E9}{\'e}
8880   \DeclareUnicodeCharacter{00EA}{\^e}
8881   \DeclareUnicodeCharacter{00EB}{\"e}
8882   \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}}
8883   \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}}
8884   \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}}
8885   \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}}
8886
8887   \DeclareUnicodeCharacter{00F0}{\dh}
8888   \DeclareUnicodeCharacter{00F1}{\~n}
8889   \DeclareUnicodeCharacter{00F2}{\`o}
8890   \DeclareUnicodeCharacter{00F3}{\'o}
8891   \DeclareUnicodeCharacter{00F4}{\^o}
8892   \DeclareUnicodeCharacter{00F5}{\~o}
8893   \DeclareUnicodeCharacter{00F6}{\"o}
8894   \DeclareUnicodeCharacter{00F8}{\o}
8895   \DeclareUnicodeCharacter{00F9}{\`u}
8896   \DeclareUnicodeCharacter{00FA}{\'u}
8897   \DeclareUnicodeCharacter{00FB}{\^u}
8898   \DeclareUnicodeCharacter{00FC}{\"u}
8899   \DeclareUnicodeCharacter{00FD}{\'y}
8900   \DeclareUnicodeCharacter{00FE}{\th}
8901   \DeclareUnicodeCharacter{00FF}{\"y}
8902
8903   \DeclareUnicodeCharacter{0100}{\=A}
8904   \DeclareUnicodeCharacter{0101}{\=a}
8905   \DeclareUnicodeCharacter{0102}{\u{A}}
8906   \DeclareUnicodeCharacter{0103}{\u{a}}
8907   \DeclareUnicodeCharacter{0104}{\ogonek{A}}
8908   \DeclareUnicodeCharacter{0105}{\ogonek{a}}
8909   \DeclareUnicodeCharacter{0106}{\'C}
8910   \DeclareUnicodeCharacter{0107}{\'c}
8911   \DeclareUnicodeCharacter{0108}{\^C}
8912   \DeclareUnicodeCharacter{0109}{\^c}
8913   \DeclareUnicodeCharacter{0118}{\ogonek{E}}
8914   \DeclareUnicodeCharacter{0119}{\ogonek{e}}
8915   \DeclareUnicodeCharacter{010A}{\dotaccent{C}}
8916   \DeclareUnicodeCharacter{010B}{\dotaccent{c}}
8917   \DeclareUnicodeCharacter{010C}{\v{C}}
8918   \DeclareUnicodeCharacter{010D}{\v{c}}
8919   \DeclareUnicodeCharacter{010E}{\v{D}}
8920
8921   \DeclareUnicodeCharacter{0112}{\=E}
8922   \DeclareUnicodeCharacter{0113}{\=e}
8923   \DeclareUnicodeCharacter{0114}{\u{E}}
8924   \DeclareUnicodeCharacter{0115}{\u{e}}
8925   \DeclareUnicodeCharacter{0116}{\dotaccent{E}}
8926   \DeclareUnicodeCharacter{0117}{\dotaccent{e}}
8927   \DeclareUnicodeCharacter{011A}{\v{E}}
8928   \DeclareUnicodeCharacter{011B}{\v{e}}
8929   \DeclareUnicodeCharacter{011C}{\^G}
8930   \DeclareUnicodeCharacter{011D}{\^g}
8931   \DeclareUnicodeCharacter{011E}{\u{G}}
8932   \DeclareUnicodeCharacter{011F}{\u{g}}
8933
8934   \DeclareUnicodeCharacter{0120}{\dotaccent{G}}
8935   \DeclareUnicodeCharacter{0121}{\dotaccent{g}}
8936   \DeclareUnicodeCharacter{0124}{\^H}
8937   \DeclareUnicodeCharacter{0125}{\^h}
8938   \DeclareUnicodeCharacter{0128}{\~I}
8939   \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}}
8940   \DeclareUnicodeCharacter{012A}{\=I}
8941   \DeclareUnicodeCharacter{012B}{\={\dotless{i}}}
8942   \DeclareUnicodeCharacter{012C}{\u{I}}
8943   \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}}
8944
8945   \DeclareUnicodeCharacter{0130}{\dotaccent{I}}
8946   \DeclareUnicodeCharacter{0131}{\dotless{i}}
8947   \DeclareUnicodeCharacter{0132}{IJ}
8948   \DeclareUnicodeCharacter{0133}{ij}
8949   \DeclareUnicodeCharacter{0134}{\^J}
8950   \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}}
8951   \DeclareUnicodeCharacter{0139}{\'L}
8952   \DeclareUnicodeCharacter{013A}{\'l}
8953
8954   \DeclareUnicodeCharacter{0141}{\L}
8955   \DeclareUnicodeCharacter{0142}{\l}
8956   \DeclareUnicodeCharacter{0143}{\'N}
8957   \DeclareUnicodeCharacter{0144}{\'n}
8958   \DeclareUnicodeCharacter{0147}{\v{N}}
8959   \DeclareUnicodeCharacter{0148}{\v{n}}
8960   \DeclareUnicodeCharacter{014C}{\=O}
8961   \DeclareUnicodeCharacter{014D}{\=o}
8962   \DeclareUnicodeCharacter{014E}{\u{O}}
8963   \DeclareUnicodeCharacter{014F}{\u{o}}
8964
8965   \DeclareUnicodeCharacter{0150}{\H{O}}
8966   \DeclareUnicodeCharacter{0151}{\H{o}}
8967   \DeclareUnicodeCharacter{0152}{\OE}
8968   \DeclareUnicodeCharacter{0153}{\oe}
8969   \DeclareUnicodeCharacter{0154}{\'R}
8970   \DeclareUnicodeCharacter{0155}{\'r}
8971   \DeclareUnicodeCharacter{0158}{\v{R}}
8972   \DeclareUnicodeCharacter{0159}{\v{r}}
8973   \DeclareUnicodeCharacter{015A}{\'S}
8974   \DeclareUnicodeCharacter{015B}{\'s}
8975   \DeclareUnicodeCharacter{015C}{\^S}
8976   \DeclareUnicodeCharacter{015D}{\^s}
8977   \DeclareUnicodeCharacter{015E}{\cedilla{S}}
8978   \DeclareUnicodeCharacter{015F}{\cedilla{s}}
8979
8980   \DeclareUnicodeCharacter{0160}{\v{S}}
8981   \DeclareUnicodeCharacter{0161}{\v{s}}
8982   \DeclareUnicodeCharacter{0162}{\cedilla{t}}
8983   \DeclareUnicodeCharacter{0163}{\cedilla{T}}
8984   \DeclareUnicodeCharacter{0164}{\v{T}}
8985
8986   \DeclareUnicodeCharacter{0168}{\~U}
8987   \DeclareUnicodeCharacter{0169}{\~u}
8988   \DeclareUnicodeCharacter{016A}{\=U}
8989   \DeclareUnicodeCharacter{016B}{\=u}
8990   \DeclareUnicodeCharacter{016C}{\u{U}}
8991   \DeclareUnicodeCharacter{016D}{\u{u}}
8992   \DeclareUnicodeCharacter{016E}{\ringaccent{U}}
8993   \DeclareUnicodeCharacter{016F}{\ringaccent{u}}
8994
8995   \DeclareUnicodeCharacter{0170}{\H{U}}
8996   \DeclareUnicodeCharacter{0171}{\H{u}}
8997   \DeclareUnicodeCharacter{0174}{\^W}
8998   \DeclareUnicodeCharacter{0175}{\^w}
8999   \DeclareUnicodeCharacter{0176}{\^Y}
9000   \DeclareUnicodeCharacter{0177}{\^y}
9001   \DeclareUnicodeCharacter{0178}{\"Y}
9002   \DeclareUnicodeCharacter{0179}{\'Z}
9003   \DeclareUnicodeCharacter{017A}{\'z}
9004   \DeclareUnicodeCharacter{017B}{\dotaccent{Z}}
9005   \DeclareUnicodeCharacter{017C}{\dotaccent{z}}
9006   \DeclareUnicodeCharacter{017D}{\v{Z}}
9007   \DeclareUnicodeCharacter{017E}{\v{z}}
9008
9009   \DeclareUnicodeCharacter{01C4}{D\v{Z}}
9010   \DeclareUnicodeCharacter{01C5}{D\v{z}}
9011   \DeclareUnicodeCharacter{01C6}{d\v{z}}
9012   \DeclareUnicodeCharacter{01C7}{LJ}
9013   \DeclareUnicodeCharacter{01C8}{Lj}
9014   \DeclareUnicodeCharacter{01C9}{lj}
9015   \DeclareUnicodeCharacter{01CA}{NJ}
9016   \DeclareUnicodeCharacter{01CB}{Nj}
9017   \DeclareUnicodeCharacter{01CC}{nj}
9018   \DeclareUnicodeCharacter{01CD}{\v{A}}
9019   \DeclareUnicodeCharacter{01CE}{\v{a}}
9020   \DeclareUnicodeCharacter{01CF}{\v{I}}
9021
9022   \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}}
9023   \DeclareUnicodeCharacter{01D1}{\v{O}}
9024   \DeclareUnicodeCharacter{01D2}{\v{o}}
9025   \DeclareUnicodeCharacter{01D3}{\v{U}}
9026   \DeclareUnicodeCharacter{01D4}{\v{u}}
9027
9028   \DeclareUnicodeCharacter{01E2}{\={\AE}}
9029   \DeclareUnicodeCharacter{01E3}{\={\ae}}
9030   \DeclareUnicodeCharacter{01E6}{\v{G}}
9031   \DeclareUnicodeCharacter{01E7}{\v{g}}
9032   \DeclareUnicodeCharacter{01E8}{\v{K}}
9033   \DeclareUnicodeCharacter{01E9}{\v{k}}
9034
9035   \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}}
9036   \DeclareUnicodeCharacter{01F1}{DZ}
9037   \DeclareUnicodeCharacter{01F2}{Dz}
9038   \DeclareUnicodeCharacter{01F3}{dz}
9039   \DeclareUnicodeCharacter{01F4}{\'G}
9040   \DeclareUnicodeCharacter{01F5}{\'g}
9041   \DeclareUnicodeCharacter{01F8}{\`N}
9042   \DeclareUnicodeCharacter{01F9}{\`n}
9043   \DeclareUnicodeCharacter{01FC}{\'{\AE}}
9044   \DeclareUnicodeCharacter{01FD}{\'{\ae}}
9045   \DeclareUnicodeCharacter{01FE}{\'{\O}}
9046   \DeclareUnicodeCharacter{01FF}{\'{\o}}
9047
9048   \DeclareUnicodeCharacter{021E}{\v{H}}
9049   \DeclareUnicodeCharacter{021F}{\v{h}}
9050
9051   \DeclareUnicodeCharacter{0226}{\dotaccent{A}}
9052   \DeclareUnicodeCharacter{0227}{\dotaccent{a}}
9053   \DeclareUnicodeCharacter{0228}{\cedilla{E}}
9054   \DeclareUnicodeCharacter{0229}{\cedilla{e}}
9055   \DeclareUnicodeCharacter{022E}{\dotaccent{O}}
9056   \DeclareUnicodeCharacter{022F}{\dotaccent{o}}
9057
9058   \DeclareUnicodeCharacter{0232}{\=Y}
9059   \DeclareUnicodeCharacter{0233}{\=y}
9060   \DeclareUnicodeCharacter{0237}{\dotless{j}}
9061
9062   \DeclareUnicodeCharacter{02DB}{\ogonek{ }}
9063
9064   \DeclareUnicodeCharacter{1E02}{\dotaccent{B}}
9065   \DeclareUnicodeCharacter{1E03}{\dotaccent{b}}
9066   \DeclareUnicodeCharacter{1E04}{\udotaccent{B}}
9067   \DeclareUnicodeCharacter{1E05}{\udotaccent{b}}
9068   \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}}
9069   \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}}
9070   \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}}
9071   \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}}
9072   \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}}
9073   \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}}
9074   \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}}
9075   \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}}
9076
9077   \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}}
9078   \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}}
9079
9080   \DeclareUnicodeCharacter{1E20}{\=G}
9081   \DeclareUnicodeCharacter{1E21}{\=g}
9082   \DeclareUnicodeCharacter{1E22}{\dotaccent{H}}
9083   \DeclareUnicodeCharacter{1E23}{\dotaccent{h}}
9084   \DeclareUnicodeCharacter{1E24}{\udotaccent{H}}
9085   \DeclareUnicodeCharacter{1E25}{\udotaccent{h}}
9086   \DeclareUnicodeCharacter{1E26}{\"H}
9087   \DeclareUnicodeCharacter{1E27}{\"h}
9088
9089   \DeclareUnicodeCharacter{1E30}{\'K}
9090   \DeclareUnicodeCharacter{1E31}{\'k}
9091   \DeclareUnicodeCharacter{1E32}{\udotaccent{K}}
9092   \DeclareUnicodeCharacter{1E33}{\udotaccent{k}}
9093   \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}}
9094   \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}}
9095   \DeclareUnicodeCharacter{1E36}{\udotaccent{L}}
9096   \DeclareUnicodeCharacter{1E37}{\udotaccent{l}}
9097   \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}}
9098   \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}}
9099   \DeclareUnicodeCharacter{1E3E}{\'M}
9100   \DeclareUnicodeCharacter{1E3F}{\'m}
9101
9102   \DeclareUnicodeCharacter{1E40}{\dotaccent{M}}
9103   \DeclareUnicodeCharacter{1E41}{\dotaccent{m}}
9104   \DeclareUnicodeCharacter{1E42}{\udotaccent{M}}
9105   \DeclareUnicodeCharacter{1E43}{\udotaccent{m}}
9106   \DeclareUnicodeCharacter{1E44}{\dotaccent{N}}
9107   \DeclareUnicodeCharacter{1E45}{\dotaccent{n}}
9108   \DeclareUnicodeCharacter{1E46}{\udotaccent{N}}
9109   \DeclareUnicodeCharacter{1E47}{\udotaccent{n}}
9110   \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}}
9111   \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}}
9112
9113   \DeclareUnicodeCharacter{1E54}{\'P}
9114   \DeclareUnicodeCharacter{1E55}{\'p}
9115   \DeclareUnicodeCharacter{1E56}{\dotaccent{P}}
9116   \DeclareUnicodeCharacter{1E57}{\dotaccent{p}}
9117   \DeclareUnicodeCharacter{1E58}{\dotaccent{R}}
9118   \DeclareUnicodeCharacter{1E59}{\dotaccent{r}}
9119   \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}}
9120   \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}}
9121   \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}}
9122   \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}}
9123
9124   \DeclareUnicodeCharacter{1E60}{\dotaccent{S}}
9125   \DeclareUnicodeCharacter{1E61}{\dotaccent{s}}
9126   \DeclareUnicodeCharacter{1E62}{\udotaccent{S}}
9127   \DeclareUnicodeCharacter{1E63}{\udotaccent{s}}
9128   \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}}
9129   \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}}
9130   \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}}
9131   \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}}
9132   \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}}
9133   \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}}
9134
9135   \DeclareUnicodeCharacter{1E7C}{\~V}
9136   \DeclareUnicodeCharacter{1E7D}{\~v}
9137   \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}}
9138   \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}}
9139
9140   \DeclareUnicodeCharacter{1E80}{\`W}
9141   \DeclareUnicodeCharacter{1E81}{\`w}
9142   \DeclareUnicodeCharacter{1E82}{\'W}
9143   \DeclareUnicodeCharacter{1E83}{\'w}
9144   \DeclareUnicodeCharacter{1E84}{\"W}
9145   \DeclareUnicodeCharacter{1E85}{\"w}
9146   \DeclareUnicodeCharacter{1E86}{\dotaccent{W}}
9147   \DeclareUnicodeCharacter{1E87}{\dotaccent{w}}
9148   \DeclareUnicodeCharacter{1E88}{\udotaccent{W}}
9149   \DeclareUnicodeCharacter{1E89}{\udotaccent{w}}
9150   \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}}
9151   \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}}
9152   \DeclareUnicodeCharacter{1E8C}{\"X}
9153   \DeclareUnicodeCharacter{1E8D}{\"x}
9154   \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}}
9155   \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}}
9156
9157   \DeclareUnicodeCharacter{1E90}{\^Z}
9158   \DeclareUnicodeCharacter{1E91}{\^z}
9159   \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}}
9160   \DeclareUnicodeCharacter{1E93}{\udotaccent{z}}
9161   \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}}
9162   \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}}
9163   \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}}
9164   \DeclareUnicodeCharacter{1E97}{\"t}
9165   \DeclareUnicodeCharacter{1E98}{\ringaccent{w}}
9166   \DeclareUnicodeCharacter{1E99}{\ringaccent{y}}
9167
9168   \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}}
9169   \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}}
9170
9171   \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}}
9172   \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}}
9173   \DeclareUnicodeCharacter{1EBC}{\~E}
9174   \DeclareUnicodeCharacter{1EBD}{\~e}
9175
9176   \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}}
9177   \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}}
9178   \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}}
9179   \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}}
9180
9181   \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}}
9182   \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}}
9183
9184   \DeclareUnicodeCharacter{1EF2}{\`Y}
9185   \DeclareUnicodeCharacter{1EF3}{\`y}
9186   \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}}
9187
9188   \DeclareUnicodeCharacter{1EF8}{\~Y}
9189   \DeclareUnicodeCharacter{1EF9}{\~y}
9190
9191   \DeclareUnicodeCharacter{2013}{--}
9192   \DeclareUnicodeCharacter{2014}{---}
9193   \DeclareUnicodeCharacter{2018}{\quoteleft}
9194   \DeclareUnicodeCharacter{2019}{\quoteright}
9195   \DeclareUnicodeCharacter{201A}{\quotesinglbase}
9196   \DeclareUnicodeCharacter{201C}{\quotedblleft}
9197   \DeclareUnicodeCharacter{201D}{\quotedblright}
9198   \DeclareUnicodeCharacter{201E}{\quotedblbase}
9199   \DeclareUnicodeCharacter{2022}{\bullet}
9200   \DeclareUnicodeCharacter{2026}{\dots}
9201   \DeclareUnicodeCharacter{2039}{\guilsinglleft}
9202   \DeclareUnicodeCharacter{203A}{\guilsinglright}
9203   \DeclareUnicodeCharacter{20AC}{\euro}
9204
9205   \DeclareUnicodeCharacter{2192}{\expansion}
9206   \DeclareUnicodeCharacter{21D2}{\result}
9207
9208   \DeclareUnicodeCharacter{2212}{\minus}
9209   \DeclareUnicodeCharacter{2217}{\point}
9210   \DeclareUnicodeCharacter{2261}{\equiv}
9211 }% end of \utfeightchardefs
9212
9213
9214 % US-ASCII character definitions.
9215 \def\asciichardefs{% nothing need be done
9216    \relax
9217 }
9218
9219 % Make non-ASCII characters printable again for compatibility with
9220 % existing Texinfo documents that may use them, even without declaring a
9221 % document encoding.
9222 %
9223 \setnonasciicharscatcode \other
9224
9225
9226 \message{formatting,}
9227
9228 \newdimen\defaultparindent \defaultparindent = 15pt
9229
9230 \chapheadingskip = 15pt plus 4pt minus 2pt
9231 \secheadingskip = 12pt plus 3pt minus 2pt
9232 \subsecheadingskip = 9pt plus 2pt minus 2pt
9233
9234 % Prevent underfull vbox error messages.
9235 \vbadness = 10000
9236
9237 % Don't be very finicky about underfull hboxes, either.
9238 \hbadness = 6666
9239
9240 % Following George Bush, get rid of widows and orphans.
9241 \widowpenalty=10000
9242 \clubpenalty=10000
9243
9244 % Use TeX 3.0's \emergencystretch to help line breaking, but if we're
9245 % using an old version of TeX, don't do anything.  We want the amount of
9246 % stretch added to depend on the line length, hence the dependence on
9247 % \hsize.  We call this whenever the paper size is set.
9248 %
9249 \def\setemergencystretch{%
9250   \ifx\emergencystretch\thisisundefined
9251     % Allow us to assign to \emergencystretch anyway.
9252     \def\emergencystretch{\dimen0}%
9253   \else
9254     \emergencystretch = .15\hsize
9255   \fi
9256 }
9257
9258 % Parameters in order: 1) textheight; 2) textwidth;
9259 % 3) voffset; 4) hoffset; 5) binding offset; 6) topskip;
9260 % 7) physical page height; 8) physical page width.
9261 %
9262 % We also call \setleading{\textleading}, so the caller should define
9263 % \textleading.  The caller should also set \parskip.
9264 %
9265 \def\internalpagesizes#1#2#3#4#5#6#7#8{%
9266   \voffset = #3\relax
9267   \topskip = #6\relax
9268   \splittopskip = \topskip
9269   %
9270   \vsize = #1\relax
9271   \advance\vsize by \topskip
9272   \outervsize = \vsize
9273   \advance\outervsize by 2\topandbottommargin
9274   \pageheight = \vsize
9275   %
9276   \hsize = #2\relax
9277   \outerhsize = \hsize
9278   \advance\outerhsize by 0.5in
9279   \pagewidth = \hsize
9280   %
9281   \normaloffset = #4\relax
9282   \bindingoffset = #5\relax
9283   %
9284   \ifpdf
9285     \pdfpageheight #7\relax
9286     \pdfpagewidth #8\relax
9287     % if we don't reset these, they will remain at "1 true in" of
9288     % whatever layout pdftex was dumped with.
9289     \pdfhorigin = 1 true in
9290     \pdfvorigin = 1 true in
9291   \fi
9292   %
9293   \setleading{\textleading}
9294   %
9295   \parindent = \defaultparindent
9296   \setemergencystretch
9297 }
9298
9299 % @letterpaper (the default).
9300 \def\letterpaper{{\globaldefs = 1
9301   \parskip = 3pt plus 2pt minus 1pt
9302   \textleading = 13.2pt
9303   %
9304   % If page is nothing but text, make it come out even.
9305   \internalpagesizes{607.2pt}{6in}% that's 46 lines
9306                     {\voffset}{.25in}%
9307                     {\bindingoffset}{36pt}%
9308                     {11in}{8.5in}%
9309 }}
9310
9311 % Use @smallbook to reset parameters for 7x9.25 trim size.
9312 \def\smallbook{{\globaldefs = 1
9313   \parskip = 2pt plus 1pt
9314   \textleading = 12pt
9315   %
9316   \internalpagesizes{7.5in}{5in}%
9317                     {-.2in}{0in}%
9318                     {\bindingoffset}{16pt}%
9319                     {9.25in}{7in}%
9320   %
9321   \lispnarrowing = 0.3in
9322   \tolerance = 700
9323   \hfuzz = 1pt
9324   \contentsrightmargin = 0pt
9325   \defbodyindent = .5cm
9326 }}
9327
9328 % Use @smallerbook to reset parameters for 6x9 trim size.
9329 % (Just testing, parameters still in flux.)
9330 \def\smallerbook{{\globaldefs = 1
9331   \parskip = 1.5pt plus 1pt
9332   \textleading = 12pt
9333   %
9334   \internalpagesizes{7.4in}{4.8in}%
9335                     {-.2in}{-.4in}%
9336                     {0pt}{14pt}%
9337                     {9in}{6in}%
9338   %
9339   \lispnarrowing = 0.25in
9340   \tolerance = 700
9341   \hfuzz = 1pt
9342   \contentsrightmargin = 0pt
9343   \defbodyindent = .4cm
9344 }}
9345
9346 % Use @afourpaper to print on European A4 paper.
9347 \def\afourpaper{{\globaldefs = 1
9348   \parskip = 3pt plus 2pt minus 1pt
9349   \textleading = 13.2pt
9350   %
9351   % Double-side printing via postscript on Laserjet 4050
9352   % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm.
9353   % To change the settings for a different printer or situation, adjust
9354   % \normaloffset until the front-side and back-side texts align.  Then
9355   % do the same for \bindingoffset.  You can set these for testing in
9356   % your texinfo source file like this:
9357   % @tex
9358   % \global\normaloffset = -6mm
9359   % \global\bindingoffset = 10mm
9360   % @end tex
9361   \internalpagesizes{673.2pt}{160mm}% that's 51 lines
9362                     {\voffset}{\hoffset}%
9363                     {\bindingoffset}{44pt}%
9364                     {297mm}{210mm}%
9365   %
9366   \tolerance = 700
9367   \hfuzz = 1pt
9368   \contentsrightmargin = 0pt
9369   \defbodyindent = 5mm
9370 }}
9371
9372 % Use @afivepaper to print on European A5 paper.
9373 % From romildo@urano.iceb.ufop.br, 2 July 2000.
9374 % He also recommends making @example and @lisp be small.
9375 \def\afivepaper{{\globaldefs = 1
9376   \parskip = 2pt plus 1pt minus 0.1pt
9377   \textleading = 12.5pt
9378   %
9379   \internalpagesizes{160mm}{120mm}%
9380                     {\voffset}{\hoffset}%
9381                     {\bindingoffset}{8pt}%
9382                     {210mm}{148mm}%
9383   %
9384   \lispnarrowing = 0.2in
9385   \tolerance = 800
9386   \hfuzz = 1.2pt
9387   \contentsrightmargin = 0pt
9388   \defbodyindent = 2mm
9389   \tableindent = 12mm
9390 }}
9391
9392 % A specific text layout, 24x15cm overall, intended for A4 paper.
9393 \def\afourlatex{{\globaldefs = 1
9394   \afourpaper
9395   \internalpagesizes{237mm}{150mm}%
9396                     {\voffset}{4.6mm}%
9397                     {\bindingoffset}{7mm}%
9398                     {297mm}{210mm}%
9399   %
9400   % Must explicitly reset to 0 because we call \afourpaper.
9401   \globaldefs = 0
9402 }}
9403
9404 % Use @afourwide to print on A4 paper in landscape format.
9405 \def\afourwide{{\globaldefs = 1
9406   \afourpaper
9407   \internalpagesizes{241mm}{165mm}%
9408                     {\voffset}{-2.95mm}%
9409                     {\bindingoffset}{7mm}%
9410                     {297mm}{210mm}%
9411   \globaldefs = 0
9412 }}
9413
9414 % @pagesizes TEXTHEIGHT[,TEXTWIDTH]
9415 % Perhaps we should allow setting the margins, \topskip, \parskip,
9416 % and/or leading, also. Or perhaps we should compute them somehow.
9417 %
9418 \parseargdef\pagesizes{\pagesizesyyy #1,,\finish}
9419 \def\pagesizesyyy#1,#2,#3\finish{{%
9420   \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi
9421   \globaldefs = 1
9422   %
9423   \parskip = 3pt plus 2pt minus 1pt
9424   \setleading{\textleading}%
9425   %
9426   \dimen0 = #1\relax
9427   \advance\dimen0 by \voffset
9428   %
9429   \dimen2 = \hsize
9430   \advance\dimen2 by \normaloffset
9431   %
9432   \internalpagesizes{#1}{\hsize}%
9433                     {\voffset}{\normaloffset}%
9434                     {\bindingoffset}{44pt}%
9435                     {\dimen0}{\dimen2}%
9436 }}
9437
9438 % Set default to letter.
9439 %
9440 \letterpaper
9441
9442
9443 \message{and turning on texinfo input format.}
9444
9445 \def^^L{\par} % remove \outer, so ^L can appear in an @comment
9446
9447 % DEL is a comment character, in case @c does not suffice.
9448 \catcode`\^^? = 14
9449
9450 % Define macros to output various characters with catcode for normal text.
9451 \catcode`\"=\other \def\normaldoublequote{"}
9452 \catcode`\$=\other \def\normaldollar{$}%$ font-lock fix
9453 \catcode`\+=\other \def\normalplus{+}
9454 \catcode`\<=\other \def\normalless{<}
9455 \catcode`\>=\other \def\normalgreater{>}
9456 \catcode`\^=\other \def\normalcaret{^}
9457 \catcode`\_=\other \def\normalunderscore{_}
9458 \catcode`\|=\other \def\normalverticalbar{|}
9459 \catcode`\~=\other \def\normaltilde{~}
9460
9461 % This macro is used to make a character print one way in \tt
9462 % (where it can probably be output as-is), and another way in other fonts,
9463 % where something hairier probably needs to be done.
9464 %
9465 % #1 is what to print if we are indeed using \tt; #2 is what to print
9466 % otherwise.  Since all the Computer Modern typewriter fonts have zero
9467 % interword stretch (and shrink), and it is reasonable to expect all
9468 % typewriter fonts to have this, we can check that font parameter.
9469 %
9470 \def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi}
9471
9472 % Same as above, but check for italic font.  Actually this also catches
9473 % non-italic slanted fonts since it is impossible to distinguish them from
9474 % italic fonts.  But since this is only used by $ and it uses \sl anyway
9475 % this is not a problem.
9476 \def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi}
9477
9478 % Turn off all special characters except @
9479 % (and those which the user can use as if they were ordinary).
9480 % Most of these we simply print from the \tt font, but for some, we can
9481 % use math or other variants that look better in normal text.
9482
9483 \catcode`\"=\active
9484 \def\activedoublequote{{\tt\char34}}
9485 \let"=\activedoublequote
9486 \catcode`\~=\active
9487 \def~{{\tt\char126}}
9488 \chardef\hat=`\^
9489 \catcode`\^=\active
9490 \def^{{\tt \hat}}
9491
9492 \catcode`\_=\active
9493 \def_{\ifusingtt\normalunderscore\_}
9494 \let\realunder=_
9495 % Subroutine for the previous macro.
9496 \def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }
9497
9498 \catcode`\|=\active
9499 \def|{{\tt\char124}}
9500 \chardef \less=`\<
9501 \catcode`\<=\active
9502 \def<{{\tt \less}}
9503 \chardef \gtr=`\>
9504 \catcode`\>=\active
9505 \def>{{\tt \gtr}}
9506 \catcode`\+=\active
9507 \def+{{\tt \char 43}}
9508 \catcode`\$=\active
9509 \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix
9510
9511 % If a .fmt file is being used, characters that might appear in a file
9512 % name cannot be active until we have parsed the command line.
9513 % So turn them off again, and have \everyjob (or @setfilename) turn them on.
9514 % \otherifyactive is called near the end of this file.
9515 \def\otherifyactive{\catcode`+=\other \catcode`\_=\other}
9516
9517 % Used sometimes to turn off (effectively) the active characters even after
9518 % parsing them.
9519 \def\turnoffactive{%
9520   \normalturnoffactive
9521   \otherbackslash
9522 }
9523
9524 \catcode`\@=0
9525
9526 % \backslashcurfont outputs one backslash character in current font,
9527 % as in \char`\\.
9528 \global\chardef\backslashcurfont=`\\
9529 \global\let\rawbackslashxx=\backslashcurfont  % let existing .??s files work
9530
9531 % \realbackslash is an actual character `\' with catcode other, and
9532 % \doublebackslash is two of them (for the pdf outlines).
9533 {\catcode`\\=\other @gdef@realbackslash{\} @gdef@doublebackslash{\\}}
9534
9535 % In texinfo, backslash is an active character; it prints the backslash
9536 % in fixed width font.
9537 \catcode`\\=\active
9538 @def@normalbackslash{{@tt@backslashcurfont}}
9539 % On startup, @fixbackslash assigns:
9540 %  @let \ = @normalbackslash
9541
9542 % \rawbackslash defines an active \ to do \backslashcurfont.
9543 % \otherbackslash defines an active \ to be a literal `\' character with
9544 % catcode other.
9545 @gdef@rawbackslash{@let\=@backslashcurfont}
9546 @gdef@otherbackslash{@let\=@realbackslash}
9547
9548 % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
9549 % the literal character `\'.
9550 %
9551 @def@normalturnoffactive{%
9552   @let"=@normaldoublequote
9553   @let$=@normaldollar %$ font-lock fix
9554   @let+=@normalplus
9555   @let<=@normalless
9556   @let>=@normalgreater
9557   @let\=@normalbackslash
9558   @let^=@normalcaret
9559   @let_=@normalunderscore
9560   @let|=@normalverticalbar
9561   @let~=@normaltilde
9562   @markupsetuplqdefault
9563   @markupsetuprqdefault
9564   @unsepspaces
9565 }
9566
9567 % Make _ and + \other characters, temporarily.
9568 % This is canceled by @fixbackslash.
9569 @otherifyactive
9570
9571 % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
9572 % That is what \eatinput is for; after that, the `\' should revert to printing
9573 % a backslash.
9574 %
9575 @gdef@eatinput input texinfo{@fixbackslash}
9576 @global@let\ = @eatinput
9577
9578 % On the other hand, perhaps the file did not have a `\input texinfo'. Then
9579 % the first `\' in the file would cause an error. This macro tries to fix
9580 % that, assuming it is called before the first `\' could plausibly occur.
9581 % Also turn back on active characters that might appear in the input
9582 % file name, in case not using a pre-dumped format.
9583 %
9584 @gdef@fixbackslash{%
9585   @ifx\@eatinput @let\ = @normalbackslash @fi
9586   @catcode`+=@active
9587   @catcode`@_=@active
9588 }
9589
9590 % Say @foo, not \foo, in error messages.
9591 @escapechar = `@@
9592
9593 % These (along with & and #) are made active for url-breaking, so need
9594 % active definitions as the normal characters.
9595 @def@normaldot{.}
9596 @def@normalquest{?}
9597 @def@normalslash{/}
9598
9599 % These look ok in all fonts, so just make them not special.
9600 @catcode`@& = @other @def@normalamp{&}
9601 @catcode`@# = @other @def@normalhash{#}
9602 @catcode`@% = @other @def@normalpercent{%}
9603
9604 @c Finally, make ` and ' active, so that txicodequoteundirected and
9605 @c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}.  If we
9606 @c don't make ` and ' active, @code will not get them as active chars.
9607 @c Do this last of all since we use ` in the previous @catcode assignments.
9608 @catcode`@'=@active
9609 @catcode`@`=@active
9610 @markupsetuplqdefault
9611 @markupsetuprqdefault
9612
9613 @c Local variables:
9614 @c eval: (add-hook 'write-file-hooks 'time-stamp)
9615 @c page-delimiter: "^\\\\message"
9616 @c time-stamp-start: "def\\\\texinfoversion{"
9617 @c time-stamp-format: "%:y-%02m-%02d.%02H"
9618 @c time-stamp-end: "}"
9619 @c End:
9620
9621 @c vim:sw=2:
9622
9623 @ignore
9624    arch-tag: e1b36e32-c96e-4135-a41a-0b2efa2ea115
9625 @end ignore