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