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