]> git.donarmstrong.com Git - lilypond.git/blob - tex/texinfo.tex
Merge branch 'master' into translation
[lilypond.git] / tex / texinfo.tex
1 % texinfo.tex -- TeX macros to handle Texinfo files.
2
3 % Load plain if necessary, i.e., if running under initex.
4 \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
5 %
6 \def\texinfoversion{2016-02-15.14}
7 %
8 % Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
9 % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
10 % 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016
11 % Free Software Foundation, Inc.
12 %
13 % This texinfo.tex file is free software: you can redistribute it and/or
14 % modify it under the terms of the GNU General Public License as
15 % published by the Free Software Foundation, either version 3 of the
16 % License, or (at your option) any later version.
17 %
18 % This texinfo.tex file is distributed in the hope that it will be
19 % useful, but WITHOUT ANY WARRANTY; without even the implied warranty
20 % of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21 % General Public License for more details.
22 %
23 % You should have received a copy of the GNU General Public License
24 % along with this program.  If not, see <http://www.gnu.org/licenses/>.
25 %
26 % As a special exception, when this file is read by TeX when processing
27 % a Texinfo source document, you may use the result without
28 % restriction. This Exception is an additional permission under section 7
29 % of the GNU General Public License, version 3 ("GPLv3").
30 %
31 % Please try the latest version of texinfo.tex before submitting bug
32 % reports; you can get the latest version from:
33 %   http://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or
34 %   http://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or
35 %   http://www.gnu.org/software/texinfo/ (the Texinfo home page)
36 % The texinfo.tex in any given distribution could well be out
37 % of date, so if that's what you're using, please check.
38 %
39 % Send bug reports to bug-texinfo@gnu.org.  Please include including a
40 % complete document in each bug report with which we can reproduce the
41 % problem.  Patches are, of course, greatly appreciated.
42 %
43 % To process a Texinfo manual with TeX, it's most reliable to use the
44 % texi2dvi shell script that comes with the distribution.  For a simple
45 % manual foo.texi, however, you can get away with this:
46 %   tex foo.texi
47 %   texindex foo.??
48 %   tex foo.texi
49 %   tex foo.texi
50 %   dvips foo.dvi -o  # or whatever; this makes foo.ps.
51 % The extra TeX runs get the cross-reference information correct.
52 % Sometimes one run after texindex suffices, and sometimes you need more
53 % than two; texi2dvi does it as many times as necessary.
54 %
55 % It is possible to adapt texinfo.tex for other languages, to some
56 % extent.  You can get the existing language-specific files from the
57 % full Texinfo distribution.
58 %
59 % The GNU Texinfo home page is http://www.gnu.org/software/texinfo.
60
61
62 \message{Loading texinfo [version \texinfoversion]:}
63
64 % If in a .fmt file, print the version number
65 % and turn on active characters that we couldn't do earlier because
66 % they might have appeared in the input file name.
67 \everyjob{\message{[Texinfo version \texinfoversion]}%
68   \catcode`+=\active \catcode`\_=\active}
69
70 \chardef\other=12
71
72 % We never want plain's \outer definition of \+ in Texinfo.
73 % For @tex, we can use \tabalign.
74 \let\+ = \relax
75
76 % Save some plain tex macros whose names we will redefine.
77 \let\ptexb=\b
78 \let\ptexbullet=\bullet
79 \let\ptexc=\c
80 \let\ptexcomma=\,
81 \let\ptexdot=\.
82 \let\ptexdots=\dots
83 \let\ptexend=\end
84 \let\ptexequiv=\equiv
85 \let\ptexexclam=\!
86 \let\ptexfootnote=\footnote
87 \let\ptexgtr=>
88 \let\ptexhat=^
89 \let\ptexi=\i
90 \let\ptexindent=\indent
91 \let\ptexinsert=\insert
92 \let\ptexlbrace=\{
93 \let\ptexless=<
94 \let\ptexnewwrite\newwrite
95 \let\ptexnoindent=\noindent
96 \let\ptexplus=+
97 \let\ptexraggedright=\raggedright
98 \let\ptexrbrace=\}
99 \let\ptexslash=\/
100 \let\ptexsp=\sp
101 \let\ptexstar=\*
102 \let\ptexsup=\sup
103 \let\ptext=\t
104 \let\ptextop=\top
105 {\catcode`\'=\active \global\let\ptexquoteright'}% active in plain's math mode
106
107 % If this character appears in an error message or help string, it
108 % starts a new line in the output.
109 \newlinechar = `^^J
110
111 % Use TeX 3.0's \inputlineno to get the line number, for better error
112 % messages, but if we're using an old version of TeX, don't do anything.
113 %
114 \ifx\inputlineno\thisisundefined
115   \let\linenumber = \empty % Pre-3.0.
116 \else
117   \def\linenumber{l.\the\inputlineno:\space}
118 \fi
119
120 % Set up fixed words for English if not already set.
121 \ifx\putwordAppendix\undefined  \gdef\putwordAppendix{Appendix}\fi
122 \ifx\putwordChapter\undefined   \gdef\putwordChapter{Chapter}\fi
123 \ifx\putworderror\undefined     \gdef\putworderror{error}\fi
124 \ifx\putwordfile\undefined      \gdef\putwordfile{file}\fi
125 \ifx\putwordin\undefined        \gdef\putwordin{in}\fi
126 \ifx\putwordIndexIsEmpty\undefined       \gdef\putwordIndexIsEmpty{(Index is empty)}\fi
127 \ifx\putwordIndexNonexistent\undefined   \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi
128 \ifx\putwordInfo\undefined      \gdef\putwordInfo{Info}\fi
129 \ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi
130 \ifx\putwordMethodon\undefined  \gdef\putwordMethodon{Method on}\fi
131 \ifx\putwordNoTitle\undefined   \gdef\putwordNoTitle{No Title}\fi
132 \ifx\putwordof\undefined        \gdef\putwordof{of}\fi
133 \ifx\putwordon\undefined        \gdef\putwordon{on}\fi
134 \ifx\putwordpage\undefined      \gdef\putwordpage{page}\fi
135 \ifx\putwordsection\undefined   \gdef\putwordsection{section}\fi
136 \ifx\putwordSection\undefined   \gdef\putwordSection{Section}\fi
137 \ifx\putwordsee\undefined       \gdef\putwordsee{see}\fi
138 \ifx\putwordSee\undefined       \gdef\putwordSee{See}\fi
139 \ifx\putwordShortTOC\undefined  \gdef\putwordShortTOC{Short Contents}\fi
140 \ifx\putwordTOC\undefined       \gdef\putwordTOC{Table of Contents}\fi
141 %
142 \ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi
143 \ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi
144 \ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi
145 \ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi
146 \ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi
147 \ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi
148 \ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi
149 \ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi
150 \ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi
151 \ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi
152 \ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi
153 \ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi
154 %
155 \ifx\putwordDefmac\undefined    \gdef\putwordDefmac{Macro}\fi
156 \ifx\putwordDefspec\undefined   \gdef\putwordDefspec{Special Form}\fi
157 \ifx\putwordDefvar\undefined    \gdef\putwordDefvar{Variable}\fi
158 \ifx\putwordDefopt\undefined    \gdef\putwordDefopt{User Option}\fi
159 \ifx\putwordDeffunc\undefined   \gdef\putwordDeffunc{Function}\fi
160
161 % Give the space character the catcode for a space.
162 \def\spaceisspace{\catcode`\ =10\relax}
163
164 \chardef\dashChar  = `\-
165 \chardef\slashChar = `\/
166 \chardef\underChar = `\_
167
168 % Ignore a token.
169 %
170 \def\gobble#1{}
171
172 % The following is used inside several \edef's.
173 \def\makecsname#1{\expandafter\noexpand\csname#1\endcsname}
174
175 % Hyphenation fixes.
176 \hyphenation{
177   Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script
178   ap-pen-dix bit-map bit-maps
179   data-base data-bases eshell fall-ing half-way long-est man-u-script
180   man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm
181   par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces
182   spell-ing spell-ings
183   stand-alone strong-est time-stamp time-stamps which-ever white-space
184   wide-spread wrap-around
185 }
186
187 % Sometimes it is convenient to have everything in the transcript file
188 % and nothing on the terminal.  We don't just call \tracingall here,
189 % since that produces some useless output on the terminal.  We also make
190 % some effort to order the tracing commands to reduce output in the log
191 % file; cf. trace.sty in LaTeX.
192 %
193 \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
194 \def\loggingall{%
195   \tracingstats2
196   \tracingpages1
197   \tracinglostchars2  % 2 gives us more in etex
198   \tracingparagraphs1
199   \tracingoutput1
200   \tracingmacros2
201   \tracingrestores1
202   \showboxbreadth\maxdimen \showboxdepth\maxdimen
203   \ifx\eTeXversion\thisisundefined\else % etex gives us more logging
204     \tracingscantokens1
205     \tracingifs1
206     \tracinggroups1
207     \tracingnesting2
208     \tracingassigns1
209   \fi
210   \tracingcommands3  % 3 gives us more in etex
211   \errorcontextlines16
212 }%
213
214 % @errormsg{MSG}.  Do the index-like expansions on MSG, but if things
215 % aren't perfect, it's not the end of the world, being an error message,
216 % after all.
217
218 \def\errormsg{\begingroup \indexnofonts \doerrormsg}
219 \def\doerrormsg#1{\errmessage{#1}}
220
221 % add check for \lastpenalty to plain's definitions.  If the last thing
222 % we did was a \nobreak, we don't want to insert more space.
223 %
224 \def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount
225   \removelastskip\penalty-50\smallskip\fi\fi}
226 \def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount
227   \removelastskip\penalty-100\medskip\fi\fi}
228 \def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount
229   \removelastskip\penalty-200\bigskip\fi\fi}
230
231 %\f Output routine
232 %
233
234 % For a final copy, take out the rectangles
235 % that mark overfull boxes (in case you have decided
236 % that the text looks ok even though it passes the margin).
237 %
238 \def\finalout{\overfullrule=0pt }
239
240 % Do @cropmarks to get crop marks.
241 %
242 \newif\ifcropmarks
243 \let\cropmarks = \cropmarkstrue
244 %
245 % Dimensions to add cropmarks at corners.
246 % Added by P. A. MacKay, 12 Nov. 1986
247 %
248 \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines
249 \newdimen\cornerlong  \cornerlong=1pc
250 \newdimen\cornerthick \cornerthick=.3pt
251 \newdimen\topandbottommargin \topandbottommargin=.75in
252
253 % Output a mark which sets \thischapter, \thissection and \thiscolor.
254 % We dump everything together because we only have one kind of mark.
255 % This works because we only use \botmark / \topmark, not \firstmark.
256 %
257 % A mark contains a subexpression of the \ifcase ... \fi construct.
258 % \get*marks macros below extract the needed part using \ifcase.
259 %
260 % Another complication is to let the user choose whether \thischapter
261 % (\thissection) refers to the chapter (section) in effect at the top
262 % of a page, or that at the bottom of a page.
263
264 % \domark is called twice inside \chapmacro, to add one
265 % mark before the section break, and one after.
266 %   In the second call \prevchapterdefs is the same as \lastchapterdefs,
267 % and \prevsectiondefs is the same as \lastsectiondefs.
268 %   Then if the page is not broken at the mark, some of the previous
269 % section appears on the page, and we can get the name of this section
270 % from \firstmark for @everyheadingmarks top.
271 %   @everyheadingmarks bottom uses \botmark.
272 %
273 % See page 260 of The TeXbook.
274 \def\domark{%
275   \toks0=\expandafter{\lastchapterdefs}%
276   \toks2=\expandafter{\lastsectiondefs}%
277   \toks4=\expandafter{\prevchapterdefs}%
278   \toks6=\expandafter{\prevsectiondefs}%
279   \toks8=\expandafter{\lastcolordefs}%
280   \mark{%
281                    \the\toks0 \the\toks2  % 0: marks for @everyheadingmarks top
282       \noexpand\or \the\toks4 \the\toks6  % 1: for @everyheadingmarks bottom
283     \noexpand\else \the\toks8             % 2: color marks
284   }%
285 }
286
287 % \gettopheadingmarks, \getbottomheadingmarks,
288 % \getcolormarks - extract needed part of mark.
289 %
290 % \topmark doesn't work for the very first chapter (after the title
291 % page or the contents), so we use \firstmark there -- this gets us
292 % the mark with the chapter defs, unless the user sneaks in, e.g.,
293 % @setcolor (or @url, or @link, etc.) between @contents and the very
294 % first @chapter.
295 \def\gettopheadingmarks{%
296   \ifcase0\topmark\fi
297   \ifx\thischapter\empty \ifcase0\firstmark\fi \fi
298 }
299 \def\getbottomheadingmarks{\ifcase1\botmark\fi}
300 \def\getcolormarks{\ifcase2\topmark\fi}
301
302 % Avoid "undefined control sequence" errors.
303 \def\lastchapterdefs{}
304 \def\lastsectiondefs{}
305 \def\lastsection{}
306 \def\prevchapterdefs{}
307 \def\prevsectiondefs{}
308 \def\lastcolordefs{}
309
310 % Margin to add to right of even pages, to left of odd pages.
311 \newdimen\bindingoffset
312 \newdimen\normaloffset
313 \newdimen\pagewidth \newdimen\pageheight
314
315 % Main output routine.
316 %
317 \chardef\PAGE = 255
318 \output = {\onepageout{\pagecontents\PAGE}}
319
320 \newbox\headlinebox
321 \newbox\footlinebox
322
323 % \onepageout takes a vbox as an argument.
324 % \shipout a vbox for a single page, adding an optional header, footer,
325 % cropmarks, and footnote.  This also causes index entries for this page
326 % to be written to the auxiliary files.
327 %
328 \def\onepageout#1{%
329   \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi
330   %
331   \ifodd\pageno  \advance\hoffset by \bindingoffset
332   \else \advance\hoffset by -\bindingoffset\fi
333   %
334   % Common context changes for both heading and footing.
335   % Do this outside of the \shipout so @code etc. will be expanded in
336   % the headline as they should be, not taken literally (outputting ''code).
337   \def\commmonheadfootline{\let\hsize=\pagewidth \texinfochars}
338   %
339   % Retrieve the information for the headings from the marks in the page,
340   % and call Plain TeX's \makeheadline and \makefootline, which use the
341   % values in \headline and \footline.
342   %
343   % This is used to check if we are on the first page of a chapter.
344   \ifcase1\topmark\fi
345   \let\prevchaptername\thischaptername
346   \ifcase0\firstmark\fi
347   \let\curchaptername\thischaptername
348   %
349   \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi
350   \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi
351   %
352   \ifx\curchaptername\prevchaptername
353     \let\thischapterheading\thischapter
354   \else
355     % \thischapterheading is the same as \thischapter except it is blank
356     % for the first page of a chapter.  This is to prevent the chapter name 
357     % being shown twice.
358     \def\thischapterheading{}%
359   \fi
360   %
361   \global\setbox\headlinebox = \vbox{\commmonheadfootline \makeheadline}%
362   \global\setbox\footlinebox = \vbox{\commmonheadfootline \makefootline}%
363   %
364   {%
365     % Set context for writing to auxiliary files like index files.
366     % Have to do this stuff outside the \shipout because we want it to
367     % take effect in \write's, yet the group defined by the \vbox ends
368     % before the \shipout runs.
369     %
370     \indexdummies         % don't expand commands in the output.
371     \normalturnoffactive  % \ in index entries must not stay \, e.g., if
372                % the page break happens to be in the middle of an example.
373                % We don't want .vr (or whatever) entries like this:
374                % \entry{{\indexbackslash }acronym}{32}{\code {\acronym}}
375                % "\acronym" won't work when it's read back in;
376                % it needs to be
377                % {\code {{\backslashcurfont }acronym}
378     \shipout\vbox{%
379       % Do this early so pdf references go to the beginning of the page.
380       \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi
381       %
382       \ifcropmarks \vbox to \outervsize\bgroup
383         \hsize = \outerhsize
384         \vskip-\topandbottommargin
385         \vtop to0pt{%
386           \line{\ewtop\hfil\ewtop}%
387           \nointerlineskip
388           \line{%
389             \vbox{\moveleft\cornerthick\nstop}%
390             \hfill
391             \vbox{\moveright\cornerthick\nstop}%
392           }%
393           \vss}%
394         \vskip\topandbottommargin
395         \line\bgroup
396           \hfil % center the page within the outer (page) hsize.
397           \ifodd\pageno\hskip\bindingoffset\fi
398           \vbox\bgroup
399       \fi
400       %
401       \unvbox\headlinebox
402       \pagebody{#1}%
403       \ifdim\ht\footlinebox > 0pt
404         % Only leave this space if the footline is nonempty.
405         % (We lessened \vsize for it in \oddfootingyyy.)
406         % The \baselineskip=24pt in plain's \makefootline has no effect.
407         \vskip 24pt
408         \unvbox\footlinebox
409       \fi
410       %
411       \ifcropmarks
412           \egroup % end of \vbox\bgroup
413         \hfil\egroup % end of (centering) \line\bgroup
414         \vskip\topandbottommargin plus1fill minus1fill
415         \boxmaxdepth = \cornerthick
416         \vbox to0pt{\vss
417           \line{%
418             \vbox{\moveleft\cornerthick\nsbot}%
419             \hfill
420             \vbox{\moveright\cornerthick\nsbot}%
421           }%
422           \nointerlineskip
423           \line{\ewbot\hfil\ewbot}%
424         }%
425       \egroup % \vbox from first cropmarks clause
426       \fi
427     }% end of \shipout\vbox
428   }% end of group with \indexdummies
429   \advancepageno
430   \ifnum\outputpenalty>-20000 \else\dosupereject\fi
431 }
432
433 \newinsert\margin \dimen\margin=\maxdimen
434
435 % Main part of page, including any footnotes
436 \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
437 {\catcode`\@ =11
438 \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
439 % marginal hacks, juha@viisa.uucp (Juha Takala)
440 \ifvoid\margin\else % marginal info is present
441   \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi
442 \dimen@=\dp#1\relax \unvbox#1\relax
443 \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
444 \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
445 }
446
447 % Here are the rules for the cropmarks.  Note that they are
448 % offset so that the space between them is truly \outerhsize or \outervsize
449 % (P. A. MacKay, 12 November, 1986)
450 %
451 \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
452 \def\nstop{\vbox
453   {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
454 \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
455 \def\nsbot{\vbox
456   {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
457
458
459 % Argument parsing
460
461 % Parse an argument, then pass it to #1.  The argument is the rest of
462 % the input line (except we remove a trailing comment).  #1 should be a
463 % macro which expects an ordinary undelimited TeX argument.
464 % For example, \def\foo{\parsearg\fooxxx}.
465 %
466 \def\parsearg{\parseargusing{}}
467 \def\parseargusing#1#2{%
468   \def\argtorun{#2}%
469   \begingroup
470     \obeylines
471     \spaceisspace
472     #1%
473     \parseargline\empty% Insert the \empty token, see \finishparsearg below.
474 }
475
476 {\obeylines %
477   \gdef\parseargline#1^^M{%
478     \endgroup % End of the group started in \parsearg.
479     \argremovecomment #1\comment\ArgTerm%
480   }%
481 }
482
483 % First remove any @comment, then any @c comment.  Also remove a @texinfoc
484 % comment (see \scanmacro for details).  Pass the result on to \argcheckspaces.
485 \def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm}
486 \def\argremovec#1\c#2\ArgTerm{\argremovetexinfoc #1\texinfoc\ArgTerm}
487 \def\argremovetexinfoc#1\texinfoc#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
488
489 % Each occurrence of `\^^M' or `<space>\^^M' is replaced by a single space.
490 %
491 % \argremovec might leave us with trailing space, e.g.,
492 %    @end itemize  @c foo
493 % This space token undergoes the same procedure and is eventually removed
494 % by \finishparsearg.
495 %
496 \def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M}
497 \def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M}
498 \def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{%
499   \def\temp{#3}%
500   \ifx\temp\empty
501     % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp:
502     \let\temp\finishparsearg
503   \else
504     \let\temp\argcheckspaces
505   \fi
506   % Put the space token in:
507   \temp#1 #3\ArgTerm
508 }
509
510 % If a _delimited_ argument is enclosed in braces, they get stripped; so
511 % to get _exactly_ the rest of the line, we had to prevent such situation.
512 % We prepended an \empty token at the very beginning and we expand it now,
513 % just before passing the control to \argtorun.
514 % (Similarly, we have to think about #3 of \argcheckspacesY above: it is
515 % either the null string, or it ends with \^^M---thus there is no danger
516 % that a pair of braces would be stripped.
517 %
518 % But first, we have to remove the trailing space token.
519 %
520 \def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}}
521
522
523 % \parseargdef - define a command taking an argument on the line
524 %
525 % \parseargdef\foo{...}
526 %       is roughly equivalent to
527 % \def\foo{\parsearg\Xfoo}
528 % \def\Xfoo#1{...}
529 \def\parseargdef#1{%
530   \expandafter \doparseargdef \csname\string#1\endcsname #1%
531 }
532 \def\doparseargdef#1#2{%
533   \def#2{\parsearg#1}%
534   \def#1##1%
535 }
536
537 % Several utility definitions with active space:
538 {
539   \obeyspaces
540   \gdef\obeyedspace{ }
541
542   % Make each space character in the input produce a normal interword
543   % space in the output.  Don't allow a line break at this space, as this
544   % is used only in environments like @example, where each line of input
545   % should produce a line of output anyway.
546   %
547   \gdef\sepspaces{\obeyspaces\let =\tie}
548
549   % If an index command is used in an @example environment, any spaces
550   % therein should become regular spaces in the raw index file, not the
551   % expansion of \tie (\leavevmode \penalty \@M \ ).
552   \gdef\unsepspaces{\let =\space}
553 }
554
555
556 \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
557
558 % Define the framework for environments in texinfo.tex.  It's used like this:
559 %
560 %   \envdef\foo{...}
561 %   \def\Efoo{...}
562 %
563 % It's the responsibility of \envdef to insert \begingroup before the
564 % actual body; @end closes the group after calling \Efoo.  \envdef also
565 % defines \thisenv, so the current environment is known; @end checks
566 % whether the environment name matches.  The \checkenv macro can also be
567 % used to check whether the current environment is the one expected.
568 %
569 % Non-false conditionals (@iftex, @ifset) don't fit into this, so they
570 % are not treated as environments; they don't open a group.  (The
571 % implementation of @end takes care not to call \endgroup in this
572 % special case.)
573
574
575 % At run-time, environments start with this:
576 \def\startenvironment#1{\begingroup\def\thisenv{#1}}
577 % initialize
578 \let\thisenv\empty
579
580 % ... but they get defined via ``\envdef\foo{...}'':
581 \long\def\envdef#1#2{\def#1{\startenvironment#1#2}}
582 \def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}}
583
584 % Check whether we're in the right environment:
585 \def\checkenv#1{%
586   \def\temp{#1}%
587   \ifx\thisenv\temp
588   \else
589     \badenverr
590   \fi
591 }
592
593 % Environment mismatch, #1 expected:
594 \def\badenverr{%
595   \errhelp = \EMsimple
596   \errmessage{This command can appear only \inenvironment\temp,
597     not \inenvironment\thisenv}%
598 }
599 \def\inenvironment#1{%
600   \ifx#1\empty
601     outside of any environment%
602   \else
603     in environment \expandafter\string#1%
604   \fi
605 }
606
607 % @end foo executes the definition of \Efoo.
608 % But first, it executes a specialized version of \checkenv
609 %
610 \parseargdef\end{%
611   \if 1\csname iscond.#1\endcsname
612   \else
613     % The general wording of \badenverr may not be ideal.
614     \expandafter\checkenv\csname#1\endcsname
615     \csname E#1\endcsname
616     \endgroup
617   \fi
618 }
619
620 \newhelp\EMsimple{Press RETURN to continue.}
621
622
623 % Be sure we're in horizontal mode when doing a tie, since we make space
624 % equivalent to this in @example-like environments. Otherwise, a space
625 % at the beginning of a line will start with \penalty -- and
626 % since \penalty is valid in vertical mode, we'd end up putting the
627 % penalty on the vertical list instead of in the new paragraph.
628 {\catcode`@ = 11
629  % Avoid using \@M directly, because that causes trouble
630  % if the definition is written into an index file.
631  \global\let\tiepenalty = \@M
632  \gdef\tie{\leavevmode\penalty\tiepenalty\ }
633 }
634
635 % @: forces normal size whitespace following.
636 \def\:{\spacefactor=1000 }
637
638 % @* forces a line break.
639 \def\*{\unskip\hfil\break\hbox{}\ignorespaces}
640
641 % @/ allows a line break.
642 \let\/=\allowbreak
643
644 % @. is an end-of-sentence period.
645 \def\.{.\spacefactor=\endofsentencespacefactor\space}
646
647 % @! is an end-of-sentence bang.
648 \def\!{!\spacefactor=\endofsentencespacefactor\space}
649
650 % @? is an end-of-sentence query.
651 \def\?{?\spacefactor=\endofsentencespacefactor\space}
652
653 % @frenchspacing on|off  says whether to put extra space after punctuation.
654 %
655 \def\onword{on}
656 \def\offword{off}
657 %
658 \parseargdef\frenchspacing{%
659   \def\temp{#1}%
660   \ifx\temp\onword \plainfrenchspacing
661   \else\ifx\temp\offword \plainnonfrenchspacing
662   \else
663     \errhelp = \EMsimple
664     \errmessage{Unknown @frenchspacing option `\temp', must be on|off}%
665   \fi\fi
666 }
667
668 % @w prevents a word break.  Without the \leavevmode, @w at the
669 % beginning of a paragraph, when TeX is still in vertical mode, would
670 % produce a whole line of output instead of starting the paragraph.
671 \def\w#1{\leavevmode\hbox{#1}}
672
673 % @group ... @end group forces ... to be all on one page, by enclosing
674 % it in a TeX vbox.  We use \vtop instead of \vbox to construct the box
675 % to keep its height that of a normal line.  According to the rules for
676 % \topskip (p.114 of the TeXbook), the glue inserted is
677 % max (\topskip - \ht (first item), 0).  If that height is large,
678 % therefore, no glue is inserted, and the space between the headline and
679 % the text is small, which looks bad.
680 %
681 % Another complication is that the group might be very large.  This can
682 % cause the glue on the previous page to be unduly stretched, because it
683 % does not have much material.  In this case, it's better to add an
684 % explicit \vfill so that the extra space is at the bottom.  The
685 % threshold for doing this is if the group is more than \vfilllimit
686 % percent of a page (\vfilllimit can be changed inside of @tex).
687 %
688 \newbox\groupbox
689 \def\vfilllimit{0.7}
690 %
691 \envdef\group{%
692   \ifnum\catcode`\^^M=\active \else
693     \errhelp = \groupinvalidhelp
694     \errmessage{@group invalid in context where filling is enabled}%
695   \fi
696   \startsavinginserts
697   %
698   \setbox\groupbox = \vtop\bgroup
699     % Do @comment since we are called inside an environment such as
700     % @example, where each end-of-line in the input causes an
701     % end-of-line in the output.  We don't want the end-of-line after
702     % the `@group' to put extra space in the output.  Since @group
703     % should appear on a line by itself (according to the Texinfo
704     % manual), we don't worry about eating any user text.
705     \comment
706 }
707 %
708 % The \vtop produces a box with normal height and large depth; thus, TeX puts
709 % \baselineskip glue before it, and (when the next line of text is done)
710 % \lineskip glue after it.  Thus, space below is not quite equal to space
711 % above.  But it's pretty close.
712 \def\Egroup{%
713     % To get correct interline space between the last line of the group
714     % and the first line afterwards, we have to propagate \prevdepth.
715     \endgraf % Not \par, as it may have been set to \lisppar.
716     \global\dimen1 = \prevdepth
717   \egroup           % End the \vtop.
718   \addgroupbox
719   \prevdepth = \dimen1
720   \checkinserts
721 }
722
723 \def\addgroupbox{
724   % \dimen0 is the vertical size of the group's box.
725   \dimen0 = \ht\groupbox  \advance\dimen0 by \dp\groupbox
726   % \dimen2 is how much space is left on the page (more or less).
727   \dimen2 = \pageheight   \advance\dimen2 by -\pagetotal
728   % if the group doesn't fit on the current page, and it's a big big
729   % group, force a page break.
730   \ifdim \dimen0 > \dimen2
731     \ifdim \pagetotal < \vfilllimit\pageheight
732       \page
733     \fi
734   \fi
735   \box\groupbox
736 }
737
738 %
739 % TeX puts in an \escapechar (i.e., `@') at the beginning of the help
740 % message, so this ends up printing `@group can only ...'.
741 %
742 \newhelp\groupinvalidhelp{%
743 group can only be used in environments such as @example,^^J%
744 where each line of input produces a line of output.}
745
746 % @need space-in-mils
747 % forces a page break if there is not space-in-mils remaining.
748
749 \newdimen\mil  \mil=0.001in
750
751 \parseargdef\need{%
752   % Ensure vertical mode, so we don't make a big box in the middle of a
753   % paragraph.
754   \par
755   %
756   % If the @need value is less than one line space, it's useless.
757   \dimen0 = #1\mil
758   \dimen2 = \ht\strutbox
759   \advance\dimen2 by \dp\strutbox
760   \ifdim\dimen0 > \dimen2
761     %
762     % Do a \strut just to make the height of this box be normal, so the
763     % normal leading is inserted relative to the preceding line.
764     % And a page break here is fine.
765     \vtop to #1\mil{\strut\vfil}%
766     %
767     % TeX does not even consider page breaks if a penalty added to the
768     % main vertical list is 10000 or more.  But in order to see if the
769     % empty box we just added fits on the page, we must make it consider
770     % page breaks.  On the other hand, we don't want to actually break the
771     % page after the empty box.  So we use a penalty of 9999.
772     %
773     % There is an extremely small chance that TeX will actually break the
774     % page at this \penalty, if there are no other feasible breakpoints in
775     % sight.  (If the user is using lots of big @group commands, which
776     % almost-but-not-quite fill up a page, TeX will have a hard time doing
777     % good page breaking, for example.)  However, I could not construct an
778     % example where a page broke at this \penalty; if it happens in a real
779     % document, then we can reconsider our strategy.
780     \penalty9999
781     %
782     % Back up by the size of the box, whether we did a page break or not.
783     \kern -#1\mil
784     %
785     % Do not allow a page break right after this kern.
786     \nobreak
787   \fi
788 }
789
790 % @br   forces paragraph break (and is undocumented).
791
792 \let\br = \par
793
794 % @page forces the start of a new page.
795 %
796 \def\page{\par\vfill\supereject}
797
798 % @exdent text....
799 % outputs text on separate line in roman font, starting at standard page margin
800
801 % This records the amount of indent in the innermost environment.
802 % That's how much \exdent should take out.
803 \newskip\exdentamount
804
805 % This defn is used inside fill environments such as @defun.
806 \parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}
807
808 % This defn is used inside nofill environments such as @example.
809 \parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount
810   \leftline{\hskip\leftskip{\rm#1}}}}
811
812 % @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current
813 % paragraph.  For more general purposes, use the \margin insertion
814 % class.  WHICH is `l' or `r'.  Not documented, written for gawk manual.
815 %
816 \newskip\inmarginspacing \inmarginspacing=1cm
817 \def\strutdepth{\dp\strutbox}
818 %
819 \def\doinmargin#1#2{\strut\vadjust{%
820   \nobreak
821   \kern-\strutdepth
822   \vtop to \strutdepth{%
823     \baselineskip=\strutdepth
824     \vss
825     % if you have multiple lines of stuff to put here, you'll need to
826     % make the vbox yourself of the appropriate size.
827     \ifx#1l%
828       \llap{\ignorespaces #2\hskip\inmarginspacing}%
829     \else
830       \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}%
831     \fi
832     \null
833   }%
834 }}
835 \def\inleftmargin{\doinmargin l}
836 \def\inrightmargin{\doinmargin r}
837 %
838 % @inmargin{TEXT [, RIGHT-TEXT]}
839 % (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right;
840 % else use TEXT for both).
841 %
842 \def\inmargin#1{\parseinmargin #1,,\finish}
843 \def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing.
844   \setbox0 = \hbox{\ignorespaces #2}%
845   \ifdim\wd0 > 0pt
846     \def\lefttext{#1}%  have both texts
847     \def\righttext{#2}%
848   \else
849     \def\lefttext{#1}%  have only one text
850     \def\righttext{#1}%
851   \fi
852   %
853   \ifodd\pageno
854     \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin
855   \else
856     \def\temp{\inleftmargin\lefttext}%
857   \fi
858   \temp
859 }
860
861 % @| inserts a changebar to the left of the current line.  It should
862 % surround any changed text.  This approach does *not* work if the
863 % change spans more than two lines of output.  To handle that, we would
864 % have adopt a much more difficult approach (putting marks into the main
865 % vertical list for the beginning and end of each change).  This command
866 % is not documented, not supported, and doesn't work.
867 %
868 \def\|{%
869   % \vadjust can only be used in horizontal mode.
870   \leavevmode
871   %
872   % Append this vertical mode material after the current line in the output.
873   \vadjust{%
874     % We want to insert a rule with the height and depth of the current
875     % leading; that is exactly what \strutbox is supposed to record.
876     \vskip-\baselineskip
877     %
878     % \vadjust-items are inserted at the left edge of the type.  So
879     % the \llap here moves out into the left-hand margin.
880     \llap{%
881       %
882       % For a thicker or thinner bar, change the `1pt'.
883       \vrule height\baselineskip width1pt
884       %
885       % This is the space between the bar and the text.
886       \hskip 12pt
887     }%
888   }%
889 }
890
891 % @include FILE -- \input text of FILE.
892 %
893 \def\include{\parseargusing\filenamecatcodes\includezzz}
894 \def\includezzz#1{%
895   \pushthisfilestack
896   \def\thisfile{#1}%
897   {%
898     \makevalueexpandable  % we want to expand any @value in FILE.
899     \turnoffactive        % and allow special characters in the expansion
900     \indexnofonts         % Allow `@@' and other weird things in file names.
901     \wlog{texinfo.tex: doing @include of #1^^J}%
902     \edef\temp{\noexpand\input #1 }%
903     %
904     % This trickery is to read FILE outside of a group, in case it makes
905     % definitions, etc.
906     \expandafter
907   }\temp
908   \popthisfilestack
909 }
910 \def\filenamecatcodes{%
911   \catcode`\\=\other
912   \catcode`~=\other
913   \catcode`^=\other
914   \catcode`_=\other
915   \catcode`|=\other
916   \catcode`<=\other
917   \catcode`>=\other
918   \catcode`+=\other
919   \catcode`-=\other
920   \catcode`\`=\other
921   \catcode`\'=\other
922 }
923
924 \def\pushthisfilestack{%
925   \expandafter\pushthisfilestackX\popthisfilestack\StackTerm
926 }
927 \def\pushthisfilestackX{%
928   \expandafter\pushthisfilestackY\thisfile\StackTerm
929 }
930 \def\pushthisfilestackY #1\StackTerm #2\StackTerm {%
931   \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}%
932 }
933
934 \def\popthisfilestack{\errthisfilestackempty}
935 \def\errthisfilestackempty{\errmessage{Internal error:
936   the stack of filenames is empty.}}
937 %
938 \def\thisfile{}
939
940 % @center line
941 % outputs that line, centered.
942 %
943 \parseargdef\center{%
944   \ifhmode
945     \let\centersub\centerH
946   \else
947     \let\centersub\centerV
948   \fi
949   \centersub{\hfil \ignorespaces#1\unskip \hfil}%
950   \let\centersub\relax % don't let the definition persist, just in case
951 }
952 \def\centerH#1{{%
953   \hfil\break
954   \advance\hsize by -\leftskip
955   \advance\hsize by -\rightskip
956   \line{#1}%
957   \break
958 }}
959 %
960 \newcount\centerpenalty
961 \def\centerV#1{%
962   % The idea here is the same as in \startdefun, \cartouche, etc.: if
963   % @center is the first thing after a section heading, we need to wipe
964   % out the negative parskip inserted by \sectionheading, but still
965   % prevent a page break here.
966   \centerpenalty = \lastpenalty
967   \ifnum\centerpenalty>10000 \vskip\parskip \fi
968   \ifnum\centerpenalty>9999 \penalty\centerpenalty \fi
969   \line{\kern\leftskip #1\kern\rightskip}%
970 }
971
972 % @sp n   outputs n lines of vertical space
973 %
974 \parseargdef\sp{\vskip #1\baselineskip}
975
976 % @comment ...line which is ignored...
977 % @c is the same as @comment
978 % @ignore ... @end ignore  is another way to write a comment
979 %
980 \def\comment{\begingroup \catcode`\^^M=\active%
981 \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other\commentxxx}%
982
983 {\catcode`\^^M=\active%
984 \gdef\commentxxx#1^^M{\endgroup%
985 \futurelet\nexttoken\commentxxxx}%
986 \gdef\commentxxxx{\ifx\nexttoken\aftermacro\expandafter\comment\fi}%
987 }
988
989 \def\c{\begingroup \catcode`\^^M=\active%
990 \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
991 \cxxx}
992 {\catcode`\^^M=\active \gdef\cxxx#1^^M{\endgroup}}
993 % See comment in \scanmacro about why the definitions of @c and @comment differ
994
995 % @paragraphindent NCHARS
996 % We'll use ems for NCHARS, close enough.
997 % NCHARS can also be the word `asis' or `none'.
998 % We cannot feasibly implement @paragraphindent asis, though.
999 %
1000 \def\asisword{asis} % no translation, these are keywords
1001 \def\noneword{none}
1002 %
1003 \parseargdef\paragraphindent{%
1004   \def\temp{#1}%
1005   \ifx\temp\asisword
1006   \else
1007     \ifx\temp\noneword
1008       \defaultparindent = 0pt
1009     \else
1010       \defaultparindent = #1em
1011     \fi
1012   \fi
1013   \parindent = \defaultparindent
1014 }
1015
1016 % @exampleindent NCHARS
1017 % We'll use ems for NCHARS like @paragraphindent.
1018 % It seems @exampleindent asis isn't necessary, but
1019 % I preserve it to make it similar to @paragraphindent.
1020 \parseargdef\exampleindent{%
1021   \def\temp{#1}%
1022   \ifx\temp\asisword
1023   \else
1024     \ifx\temp\noneword
1025       \lispnarrowing = 0pt
1026     \else
1027       \lispnarrowing = #1em
1028     \fi
1029   \fi
1030 }
1031
1032 % @firstparagraphindent WORD
1033 % If WORD is `none', then suppress indentation of the first paragraph
1034 % after a section heading.  If WORD is `insert', then do indent at such
1035 % paragraphs.
1036 %
1037 % The paragraph indentation is suppressed or not by calling
1038 % \suppressfirstparagraphindent, which the sectioning commands do.
1039 % We switch the definition of this back and forth according to WORD.
1040 % By default, we suppress indentation.
1041 %
1042 \def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent}
1043 \def\insertword{insert}
1044 %
1045 \parseargdef\firstparagraphindent{%
1046   \def\temp{#1}%
1047   \ifx\temp\noneword
1048     \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent
1049   \else\ifx\temp\insertword
1050     \let\suppressfirstparagraphindent = \relax
1051   \else
1052     \errhelp = \EMsimple
1053     \errmessage{Unknown @firstparagraphindent option `\temp'}%
1054   \fi\fi
1055 }
1056
1057 % Here is how we actually suppress indentation.  Redefine \everypar to
1058 % \kern backwards by \parindent, and then reset itself to empty.
1059 %
1060 % We also make \indent itself not actually do anything until the next
1061 % paragraph.
1062 %
1063 \gdef\dosuppressfirstparagraphindent{%
1064   \gdef\indent  {\restorefirstparagraphindent \indent}%
1065   \gdef\noindent{\restorefirstparagraphindent \noindent}%
1066   \global\everypar = {\kern -\parindent \restorefirstparagraphindent}%
1067 }
1068 %
1069 \gdef\restorefirstparagraphindent{%
1070   \global\let\indent = \ptexindent
1071   \global\let\noindent = \ptexnoindent
1072   \global\everypar = {}%
1073 }
1074
1075
1076 % @refill is a no-op.
1077 \let\refill=\relax
1078
1079 % @setfilename INFO-FILENAME - ignored
1080 \let\setfilename=\comment
1081
1082 % @bye.
1083 \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
1084
1085
1086 \message{pdf,}
1087 % adobe `portable' document format
1088 \newcount\tempnum
1089 \newcount\lnkcount
1090 \newtoks\filename
1091 \newcount\filenamelength
1092 \newcount\pgn
1093 \newtoks\toksA
1094 \newtoks\toksB
1095 \newtoks\toksC
1096 \newtoks\toksD
1097 \newbox\boxA
1098 \newbox\boxB
1099 \newcount\countA
1100 \newif\ifpdf
1101 \newif\ifpdfmakepagedest
1102
1103 % when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1
1104 % can be set).  So we test for \relax and 0 as well as being undefined.
1105 \ifx\pdfoutput\thisisundefined
1106 \else
1107   \ifx\pdfoutput\relax
1108   \else
1109     \ifcase\pdfoutput
1110     \else
1111       \pdftrue
1112     \fi
1113   \fi
1114 \fi
1115
1116 % PDF uses PostScript string constants for the names of xref targets,
1117 % for display in the outlines, and in other places.  Thus, we have to
1118 % double any backslashes.  Otherwise, a name like "\node" will be
1119 % interpreted as a newline (\n), followed by o, d, e.  Not good.
1120
1121 % See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and
1122 % related messages.  The final outcome is that it is up to the TeX user
1123 % to double the backslashes and otherwise make the string valid, so
1124 % that's what we do.  pdftex 1.30.0 (ca.2005) introduced a primitive to
1125 % do this reliably, so we use it.
1126
1127 % #1 is a control sequence in which to do the replacements,
1128 % which we \xdef.
1129 \def\txiescapepdf#1{%
1130   \ifx\pdfescapestring\thisisundefined
1131     % No primitive available; should we give a warning or log?
1132     % Many times it won't matter.
1133   \else
1134     % The expandable \pdfescapestring primitive escapes parentheses,
1135     % backslashes, and other special chars.
1136     \xdef#1{\pdfescapestring{#1}}%
1137   \fi
1138 }
1139
1140 \newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images
1141 with PDF output, and none of those formats could be found.  (.eps cannot
1142 be supported due to the design of the PDF format; use regular TeX (DVI
1143 output) for that.)}
1144
1145 \ifpdf
1146   %
1147   % Color manipulation macros using ideas from pdfcolor.tex,
1148   % except using rgb instead of cmyk; the latter is said to render as a
1149   % very dark gray on-screen and a very dark halftone in print, instead
1150   % of actual black. The dark red here is dark enough to print on paper as
1151   % nearly black, but still distinguishable for online viewing.  We use
1152   % black by default, though.
1153   \def\rgbDarkRed{0.50 0.09 0.12}
1154   \def\rgbBlack{0 0 0}
1155   %
1156   % rg sets the color for filling (usual text, etc.);
1157   % RG sets the color for stroking (thin rules, e.g., normal _'s).
1158   \def\pdfsetcolor#1{\pdfliteral{#1 rg  #1 RG}}
1159   %
1160   % Set color, and create a mark which defines \thiscolor accordingly,
1161   % so that \makeheadline knows which color to restore.
1162   \def\setcolor#1{%
1163     \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}%
1164     \domark
1165     \pdfsetcolor{#1}%
1166   }
1167   %
1168   \def\maincolor{\rgbBlack}
1169   \pdfsetcolor{\maincolor}
1170   \edef\thiscolor{\maincolor}
1171   \def\lastcolordefs{}
1172   %
1173   \def\makefootline{%
1174     \baselineskip24pt
1175     \line{\pdfsetcolor{\maincolor}\the\footline}%
1176   }
1177   %
1178   \def\makeheadline{%
1179     \vbox to 0pt{%
1180       \vskip-22.5pt
1181       \line{%
1182         \vbox to8.5pt{}%
1183         % Extract \thiscolor definition from the marks.
1184         \getcolormarks
1185         % Typeset the headline with \maincolor, then restore the color.
1186         \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
1187       }%
1188       \vss
1189     }%
1190     \nointerlineskip
1191   }
1192   %
1193   %
1194   \pdfcatalog{/PageMode /UseOutlines}
1195   %
1196   % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
1197   \def\dopdfimage#1#2#3{%
1198     \def\pdfimagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
1199     \def\pdfimageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
1200     %
1201     % pdftex (and the PDF format) support .pdf, .png, .jpg (among
1202     % others).  Let's try in that order, PDF first since if
1203     % someone has a scalable image, presumably better to use that than a
1204     % bitmap.
1205     \let\pdfimgext=\empty
1206     \begingroup
1207       \openin 1 #1.pdf \ifeof 1
1208         \openin 1 #1.PDF \ifeof 1
1209           \openin 1 #1.png \ifeof 1
1210             \openin 1 #1.jpg \ifeof 1
1211               \openin 1 #1.jpeg \ifeof 1
1212                 \openin 1 #1.JPG \ifeof 1
1213                   \errhelp = \nopdfimagehelp
1214                   \errmessage{Could not find image file #1 for pdf}%
1215                 \else \gdef\pdfimgext{JPG}%
1216                 \fi
1217               \else \gdef\pdfimgext{jpeg}%
1218               \fi
1219             \else \gdef\pdfimgext{jpg}%
1220             \fi
1221           \else \gdef\pdfimgext{png}%
1222           \fi
1223         \else \gdef\pdfimgext{PDF}%
1224         \fi
1225       \else \gdef\pdfimgext{pdf}%
1226       \fi
1227       \closein 1
1228     \endgroup
1229     %
1230     % without \immediate, ancient pdftex seg faults when the same image is
1231     % included twice.  (Version 3.14159-pre-1.0-unofficial-20010704.)
1232     \ifnum\pdftexversion < 14
1233       \immediate\pdfimage
1234     \else
1235       \immediate\pdfximage
1236     \fi
1237       \ifdim \wd0 >0pt width \pdfimagewidth \fi
1238       \ifdim \wd2 >0pt height \pdfimageheight \fi
1239       \ifnum\pdftexversion<13
1240          #1.\pdfimgext
1241        \else
1242          {#1.\pdfimgext}%
1243        \fi
1244     \ifnum\pdftexversion < 14 \else
1245       \pdfrefximage \pdflastximage
1246     \fi}
1247   %
1248   \def\pdfmkdest#1{{%
1249     % We have to set dummies so commands such as @code, and characters
1250     % such as \, aren't expanded when present in a section title.
1251     \indexnofonts
1252     \turnoffactive
1253     \makevalueexpandable
1254     \def\pdfdestname{#1}%
1255     \txiescapepdf\pdfdestname
1256     \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
1257   }}
1258   %
1259   % used to mark target names; must be expandable.
1260   \def\pdfmkpgn#1{#1}
1261   %
1262   % by default, use black for everything.
1263   \def\urlcolor{\rgbBlack}
1264   \def\linkcolor{\rgbBlack}
1265   \def\endlink{\setcolor{\maincolor}\pdfendlink}
1266   %
1267   % Adding outlines to PDF; macros for calculating structure of outlines
1268   % come from Petr Olsak
1269   \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
1270     \else \csname#1\endcsname \fi}
1271   \def\advancenumber#1{\tempnum=\expnumber{#1}\relax
1272     \advance\tempnum by 1
1273     \expandafter\xdef\csname#1\endcsname{\the\tempnum}}
1274   %
1275   % #1 is the section text, which is what will be displayed in the
1276   % outline by the pdf viewer.  #2 is the pdf expression for the number
1277   % of subentries (or empty, for subsubsections).  #3 is the node text,
1278   % which might be empty if this toc entry had no corresponding node.
1279   % #4 is the page number
1280   %
1281   \def\dopdfoutline#1#2#3#4{%
1282     % Generate a link to the node text if that exists; else, use the
1283     % page number.  We could generate a destination for the section
1284     % text in the case where a section has no node, but it doesn't
1285     % seem worth the trouble, since most documents are normally structured.
1286     \edef\pdfoutlinedest{#3}%
1287     \ifx\pdfoutlinedest\empty
1288       \def\pdfoutlinedest{#4}%
1289     \else
1290       \txiescapepdf\pdfoutlinedest
1291     \fi
1292     %
1293     % Also escape PDF chars in the display string.
1294     \edef\pdfoutlinetext{#1}%
1295     \txiescapepdf\pdfoutlinetext
1296     %
1297     \pdfoutline goto name{\pdfmkpgn{\pdfoutlinedest}}#2{\pdfoutlinetext}%
1298   }
1299   %
1300   \def\pdfmakeoutlines{%
1301     \begingroup
1302       % Read toc silently, to get counts of subentries for \pdfoutline.
1303       \def\partentry##1##2##3##4{}% ignore parts in the outlines
1304       \def\numchapentry##1##2##3##4{%
1305         \def\thischapnum{##2}%
1306         \def\thissecnum{0}%
1307         \def\thissubsecnum{0}%
1308       }%
1309       \def\numsecentry##1##2##3##4{%
1310         \advancenumber{chap\thischapnum}%
1311         \def\thissecnum{##2}%
1312         \def\thissubsecnum{0}%
1313       }%
1314       \def\numsubsecentry##1##2##3##4{%
1315         \advancenumber{sec\thissecnum}%
1316         \def\thissubsecnum{##2}%
1317       }%
1318       \def\numsubsubsecentry##1##2##3##4{%
1319         \advancenumber{subsec\thissubsecnum}%
1320       }%
1321       \def\thischapnum{0}%
1322       \def\thissecnum{0}%
1323       \def\thissubsecnum{0}%
1324       %
1325       % use \def rather than \let here because we redefine \chapentry et
1326       % al. a second time, below.
1327       \def\appentry{\numchapentry}%
1328       \def\appsecentry{\numsecentry}%
1329       \def\appsubsecentry{\numsubsecentry}%
1330       \def\appsubsubsecentry{\numsubsubsecentry}%
1331       \def\unnchapentry{\numchapentry}%
1332       \def\unnsecentry{\numsecentry}%
1333       \def\unnsubsecentry{\numsubsecentry}%
1334       \def\unnsubsubsecentry{\numsubsubsecentry}%
1335       \readdatafile{toc}%
1336       %
1337       % Read toc second time, this time actually producing the outlines.
1338       % The `-' means take the \expnumber as the absolute number of
1339       % subentries, which we calculated on our first read of the .toc above.
1340       %
1341       % We use the node names as the destinations.
1342       \def\numchapentry##1##2##3##4{%
1343         \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}%
1344       \def\numsecentry##1##2##3##4{%
1345         \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}%
1346       \def\numsubsecentry##1##2##3##4{%
1347         \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}%
1348       \def\numsubsubsecentry##1##2##3##4{% count is always zero
1349         \dopdfoutline{##1}{}{##3}{##4}}%
1350       %
1351       % PDF outlines are displayed using system fonts, instead of
1352       % document fonts.  Therefore we cannot use special characters,
1353       % since the encoding is unknown.  For example, the eogonek from
1354       % Latin 2 (0xea) gets translated to a | character.  Info from
1355       % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100.
1356       %
1357       % TODO this right, we have to translate 8-bit characters to
1358       % their "best" equivalent, based on the @documentencoding.  Too
1359       % much work for too little return.  Just use the ASCII equivalents
1360       % we use for the index sort strings.
1361       % 
1362       \indexnofonts
1363       \setupdatafile
1364       % We can have normal brace characters in the PDF outlines, unlike
1365       % Texinfo index files.  So set that up.
1366       \def\{{\lbracecharliteral}%
1367       \def\}{\rbracecharliteral}%
1368       \catcode`\\=\active \otherbackslash
1369       \input \tocreadfilename
1370     \endgroup
1371   }
1372   {\catcode`[=1 \catcode`]=2
1373    \catcode`{=\other \catcode`}=\other
1374    \gdef\lbracecharliteral[{]%
1375    \gdef\rbracecharliteral[}]%
1376   ]
1377   %
1378   \def\skipspaces#1{\def\PP{#1}\def\D{|}%
1379     \ifx\PP\D\let\nextsp\relax
1380     \else\let\nextsp\skipspaces
1381       \addtokens{\filename}{\PP}%
1382       \advance\filenamelength by 1
1383     \fi
1384     \nextsp}
1385   \def\getfilename#1{%
1386     \filenamelength=0
1387     % If we don't expand the argument now, \skipspaces will get
1388     % snagged on things like "@value{foo}".
1389     \edef\temp{#1}%
1390     \expandafter\skipspaces\temp|\relax
1391   }
1392   \ifnum\pdftexversion < 14
1393     \let \startlink \pdfannotlink
1394   \else
1395     \let \startlink \pdfstartlink
1396   \fi
1397   % make a live url in pdf output.
1398   \def\pdfurl#1{%
1399     \begingroup
1400       % it seems we really need yet another set of dummies; have not
1401       % tried to figure out what each command should do in the context
1402       % of @url.  for now, just make @/ a no-op, that's the only one
1403       % people have actually reported a problem with.
1404       %
1405       \normalturnoffactive
1406       \def\@{@}%
1407       \let\/=\empty
1408       \makevalueexpandable
1409       % do we want to go so far as to use \indexnofonts instead of just
1410       % special-casing \var here?
1411       \def\var##1{##1}%
1412       %
1413       \leavevmode\setcolor{\urlcolor}%
1414       \startlink attr{/Border [0 0 0]}%
1415         user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
1416     \endgroup}
1417   \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1418   \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1419   \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1420   \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1421   \def\maketoks{%
1422     \expandafter\poptoks\the\toksA|ENDTOKS|\relax
1423     \ifx\first0\adn0
1424     \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1425     \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
1426     \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
1427     \else
1428       \ifnum0=\countA\else\makelink\fi
1429       \ifx\first.\let\next=\done\else
1430         \let\next=\maketoks
1431         \addtokens{\toksB}{\the\toksD}
1432         \ifx\first,\addtokens{\toksB}{\space}\fi
1433       \fi
1434     \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1435     \next}
1436   \def\makelink{\addtokens{\toksB}%
1437     {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1438   \def\pdflink#1{%
1439     \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}}
1440     \setcolor{\linkcolor}#1\endlink}
1441   \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1442 \else
1443   % non-pdf mode
1444   \let\pdfmkdest = \gobble
1445   \let\pdfurl = \gobble
1446   \let\endlink = \relax
1447   \let\setcolor = \gobble
1448   \let\pdfsetcolor = \gobble
1449   \let\pdfmakeoutlines = \relax
1450 \fi  % \ifx\pdfoutput
1451
1452 %
1453 % PDF outline support for XeTeX
1454 %
1455 \ifx\XeTeXrevision\thisisundefined
1456 \else
1457   \pdfmakepagedesttrue \relax
1458   % Emulate the primitive of pdfTeX
1459   \def\pdfdest name#1 xyz{%
1460     \special{pdf:dest (name#1) [@thispage /XYZ @xpos @ypos]}%
1461   }
1462   \def\pdfmkdest#1{{%
1463     % We have to set dummies so commands such as @code, and characters
1464     % such as \, aren't expanded when present in a section title.
1465     \indexnofonts
1466     \makevalueexpandable
1467     % In the case of XeTeX, xdvipdfmx converts strings to UTF-16.
1468     % Therefore \txiescapepdf is not necessary.
1469     \safewhatsit{\pdfdest name{#1} xyz}%
1470   }}
1471   %
1472   \def\dopdfoutline#1#2#3#4{%
1473     \edef\pdfoutlinedest{#3}%
1474     \ifx\pdfoutlinedest\empty
1475       \def\pdfoutlinedest{#4}%
1476     \fi
1477     {
1478       \turnoffactive
1479       % In the case of XeTeX, xdvipdfmx converts strings to UTF-16.
1480       % Therefore \txiescapepdf is not necessary.
1481       \special{pdf:out [-] #2 << /Title (#1) /A << /S /GoTo /D (name\pdfoutlinedest) >> >> }%
1482     }
1483   }
1484   %
1485   \def\pdfmakeoutlines{%
1486     \begingroup
1487       %
1488       % In the case of XeTeX, counts of subentries is not necesary.
1489       % Therefore, read toc only once.
1490       %
1491       % We use the node names as the destinations.
1492       \def\partentry##1##2##3##4{}% ignore parts in the outlines
1493       \def\numchapentry##1##2##3##4{%
1494         \dopdfoutline{##1}{1}{##3}{##4}}%
1495       \def\numsecentry##1##2##3##4{%
1496         \dopdfoutline{##1}{2}{##3}{##4}}%
1497       \def\numsubsecentry##1##2##3##4{%
1498         \dopdfoutline{##1}{3}{##3}{##4}}%
1499       \def\numsubsubsecentry##1##2##3##4{%
1500         \dopdfoutline{##1}{4}{##3}{##4}}%
1501       %
1502       \let\appentry\numchapentry%
1503       \let\appsecentry\numsecentry%
1504       \let\appsubsecentry\numsubsecentry%
1505       \let\appsubsubsecentry\numsubsubsecentry%
1506       \let\unnchapentry\numchapentry%
1507       \let\unnsecentry\numsecentry%
1508       \let\unnsubsecentry\numsubsecentry%
1509       \let\unnsubsubsecentry\numsubsubsecentry%
1510       %
1511       % In the case of XeTeX, xdvipdfmx converts strings to UTF-16.
1512       % Therefore, the encoding and the language may not be considered.
1513       %
1514       \indexnofonts
1515       \setupdatafile
1516       % We can have normal brace characters in the PDF outlines, unlike
1517       % Texinfo index files.  So set that up.
1518       \def\{{\lbracecharliteral}%
1519       \def\}{\rbracecharliteral}%
1520       \catcode`\\=\active \otherbackslash
1521       \input \tocreadfilename
1522     \endgroup
1523   }
1524   {\catcode`[=1 \catcode`]=2
1525    \catcode`{=\other \catcode`}=\other
1526    \gdef\lbracecharliteral[{]%
1527    \gdef\rbracecharliteral[}]%
1528   ]
1529
1530   \special{pdf:docview << /PageMode /UseOutlines >> }
1531   \openin 1 uptex.tex % upTeX has UTF8-UTF16 cmap
1532   \ifeof 1
1533     % upTeX does not exist. To use UTF8-UCS2 cmap.
1534     % In this case, non-BMP characters (over U+FFFF) can not be used.
1535     \special{pdf:tounicode UTF8-UCS2}
1536   \else
1537     % upTeX exists. To use UTF8-UTF16 cmap.
1538     % Non-BMP characters (over U+FFFF) can be used.
1539     \special{pdf:tounicode UTF8-UTF16}
1540   \fi
1541 \fi
1542
1543 %
1544 % @image support for XeTeX
1545 %
1546 \newif\ifxeteximgpdf
1547 \ifx\XeTeXrevision\thisisundefined
1548 \else
1549   %
1550   % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
1551   \def\doxeteximage#1#2#3{%
1552     \def\xeteximagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
1553     \def\xeteximageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
1554     %
1555     % XeTeX (and the PDF format) support .pdf, .png, .jpg (among
1556     % others).  Let's try in that order, PDF first since if
1557     % someone has a scalable image, presumably better to use that than a
1558     % bitmap.
1559     \let\xeteximgext=\empty
1560     \xeteximgpdffalse
1561     \begingroup
1562       \openin 1 #1.pdf \ifeof 1
1563         \openin 1 #1.PDF \ifeof 1
1564           \openin 1 #1.png \ifeof 1
1565             \openin 1 #1.jpg \ifeof 1
1566               \openin 1 #1.jpeg \ifeof 1
1567                 \openin 1 #1.JPG \ifeof 1
1568                   \errmessage{Could not find image file #1 for XeTeX}%
1569                 \else \gdef\xeteximgext{JPG}%
1570                 \fi
1571               \else \gdef\xeteximgext{jpeg}%
1572               \fi
1573             \else \gdef\xeteximgext{jpg}%
1574             \fi
1575           \else \gdef\xeteximgext{png}%
1576           \fi
1577         \else \gdef\xeteximgext{PDF} \global\xeteximgpdftrue%
1578         \fi
1579       \else \gdef\xeteximgext{pdf} \global\xeteximgpdftrue%
1580       \fi
1581       \closein 1
1582     \endgroup
1583     %
1584     \ifxeteximgpdf
1585       \XeTeXpdffile "#1".\xeteximgext ""
1586     \else
1587       \XeTeXpicfile "#1".\xeteximgext ""
1588     \fi
1589     \ifdim \wd0 >0pt width \xeteximagewidth \fi
1590     \ifdim \wd2 >0pt height \xeteximageheight \fi \relax
1591   }
1592 \fi
1593
1594 \message{fonts,}
1595
1596 % Change the current font style to #1, remembering it in \curfontstyle.
1597 % For now, we do not accumulate font styles: @b{@i{foo}} prints foo in
1598 % italics, not bold italics.
1599 %
1600 \def\setfontstyle#1{%
1601   \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd.
1602   \csname ten#1\endcsname  % change the current font
1603 }
1604
1605 % Select #1 fonts with the current style.
1606 %
1607 \def\selectfonts#1{\csname #1fonts\endcsname \csname\curfontstyle\endcsname}
1608
1609 \def\rm{\fam=0 \setfontstyle{rm}}
1610 \def\it{\fam=\itfam \setfontstyle{it}}
1611 \def\sl{\fam=\slfam \setfontstyle{sl}}
1612 \def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf}
1613 \def\tt{\fam=\ttfam \setfontstyle{tt}}
1614
1615 % Unfortunately, we have to override this for titles and the like, since
1616 % in those cases "rm" is bold.  Sigh.
1617 \def\rmisbold{\rm\def\curfontstyle{bf}}
1618
1619 % Texinfo sort of supports the sans serif font style, which plain TeX does not.
1620 % So we set up a \sf.
1621 \newfam\sffam
1622 \def\sf{\fam=\sffam \setfontstyle{sf}}
1623 \let\li = \sf % Sometimes we call it \li, not \sf.
1624
1625 % We don't need math for this font style.
1626 \def\ttsl{\setfontstyle{ttsl}}
1627
1628
1629 % Set the baselineskip to #1, and the lineskip and strut size
1630 % correspondingly.  There is no deep meaning behind these magic numbers
1631 % used as factors; they just match (closely enough) what Knuth defined.
1632 %
1633 \def\lineskipfactor{.08333}
1634 \def\strutheightpercent{.70833}
1635 \def\strutdepthpercent {.29167}
1636 %
1637 % can get a sort of poor man's double spacing by redefining this.
1638 \def\baselinefactor{1}
1639 %
1640 \newdimen\textleading
1641 \def\setleading#1{%
1642   \dimen0 = #1\relax
1643   \normalbaselineskip = \baselinefactor\dimen0
1644   \normallineskip = \lineskipfactor\normalbaselineskip
1645   \normalbaselines
1646   \setbox\strutbox =\hbox{%
1647     \vrule width0pt height\strutheightpercent\baselineskip
1648                     depth \strutdepthpercent \baselineskip
1649   }%
1650 }
1651
1652 % PDF CMaps.  See also LaTeX's t1.cmap.
1653 %
1654 % do nothing with this by default.
1655 \expandafter\let\csname cmapOT1\endcsname\gobble
1656 \expandafter\let\csname cmapOT1IT\endcsname\gobble
1657 \expandafter\let\csname cmapOT1TT\endcsname\gobble
1658
1659 % if we are producing pdf, and we have \pdffontattr, then define cmaps.
1660 % (\pdffontattr was introduced many years ago, but people still run
1661 % older pdftex's; it's easy to conditionalize, so we do.)
1662 \ifpdf \ifx\pdffontattr\thisisundefined \else
1663   \begingroup
1664     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
1665     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
1666 %%DocumentNeededResources: ProcSet (CIDInit)
1667 %%IncludeResource: ProcSet (CIDInit)
1668 %%BeginResource: CMap (TeX-OT1-0)
1669 %%Title: (TeX-OT1-0 TeX OT1 0)
1670 %%Version: 1.000
1671 %%EndComments
1672 /CIDInit /ProcSet findresource begin
1673 12 dict begin
1674 begincmap
1675 /CIDSystemInfo
1676 << /Registry (TeX)
1677 /Ordering (OT1)
1678 /Supplement 0
1679 >> def
1680 /CMapName /TeX-OT1-0 def
1681 /CMapType 2 def
1682 1 begincodespacerange
1683 <00> <7F>
1684 endcodespacerange
1685 8 beginbfrange
1686 <00> <01> <0393>
1687 <09> <0A> <03A8>
1688 <23> <26> <0023>
1689 <28> <3B> <0028>
1690 <3F> <5B> <003F>
1691 <5D> <5E> <005D>
1692 <61> <7A> <0061>
1693 <7B> <7C> <2013>
1694 endbfrange
1695 40 beginbfchar
1696 <02> <0398>
1697 <03> <039B>
1698 <04> <039E>
1699 <05> <03A0>
1700 <06> <03A3>
1701 <07> <03D2>
1702 <08> <03A6>
1703 <0B> <00660066>
1704 <0C> <00660069>
1705 <0D> <0066006C>
1706 <0E> <006600660069>
1707 <0F> <00660066006C>
1708 <10> <0131>
1709 <11> <0237>
1710 <12> <0060>
1711 <13> <00B4>
1712 <14> <02C7>
1713 <15> <02D8>
1714 <16> <00AF>
1715 <17> <02DA>
1716 <18> <00B8>
1717 <19> <00DF>
1718 <1A> <00E6>
1719 <1B> <0153>
1720 <1C> <00F8>
1721 <1D> <00C6>
1722 <1E> <0152>
1723 <1F> <00D8>
1724 <21> <0021>
1725 <22> <201D>
1726 <27> <2019>
1727 <3C> <00A1>
1728 <3D> <003D>
1729 <3E> <00BF>
1730 <5C> <201C>
1731 <5F> <02D9>
1732 <60> <2018>
1733 <7D> <02DD>
1734 <7E> <007E>
1735 <7F> <00A8>
1736 endbfchar
1737 endcmap
1738 CMapName currentdict /CMap defineresource pop
1739 end
1740 end
1741 %%EndResource
1742 %%EOF
1743     }\endgroup
1744   \expandafter\edef\csname cmapOT1\endcsname#1{%
1745     \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
1746   }%
1747 %
1748 % \cmapOT1IT
1749   \begingroup
1750     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
1751     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
1752 %%DocumentNeededResources: ProcSet (CIDInit)
1753 %%IncludeResource: ProcSet (CIDInit)
1754 %%BeginResource: CMap (TeX-OT1IT-0)
1755 %%Title: (TeX-OT1IT-0 TeX OT1IT 0)
1756 %%Version: 1.000
1757 %%EndComments
1758 /CIDInit /ProcSet findresource begin
1759 12 dict begin
1760 begincmap
1761 /CIDSystemInfo
1762 << /Registry (TeX)
1763 /Ordering (OT1IT)
1764 /Supplement 0
1765 >> def
1766 /CMapName /TeX-OT1IT-0 def
1767 /CMapType 2 def
1768 1 begincodespacerange
1769 <00> <7F>
1770 endcodespacerange
1771 8 beginbfrange
1772 <00> <01> <0393>
1773 <09> <0A> <03A8>
1774 <25> <26> <0025>
1775 <28> <3B> <0028>
1776 <3F> <5B> <003F>
1777 <5D> <5E> <005D>
1778 <61> <7A> <0061>
1779 <7B> <7C> <2013>
1780 endbfrange
1781 42 beginbfchar
1782 <02> <0398>
1783 <03> <039B>
1784 <04> <039E>
1785 <05> <03A0>
1786 <06> <03A3>
1787 <07> <03D2>
1788 <08> <03A6>
1789 <0B> <00660066>
1790 <0C> <00660069>
1791 <0D> <0066006C>
1792 <0E> <006600660069>
1793 <0F> <00660066006C>
1794 <10> <0131>
1795 <11> <0237>
1796 <12> <0060>
1797 <13> <00B4>
1798 <14> <02C7>
1799 <15> <02D8>
1800 <16> <00AF>
1801 <17> <02DA>
1802 <18> <00B8>
1803 <19> <00DF>
1804 <1A> <00E6>
1805 <1B> <0153>
1806 <1C> <00F8>
1807 <1D> <00C6>
1808 <1E> <0152>
1809 <1F> <00D8>
1810 <21> <0021>
1811 <22> <201D>
1812 <23> <0023>
1813 <24> <00A3>
1814 <27> <2019>
1815 <3C> <00A1>
1816 <3D> <003D>
1817 <3E> <00BF>
1818 <5C> <201C>
1819 <5F> <02D9>
1820 <60> <2018>
1821 <7D> <02DD>
1822 <7E> <007E>
1823 <7F> <00A8>
1824 endbfchar
1825 endcmap
1826 CMapName currentdict /CMap defineresource pop
1827 end
1828 end
1829 %%EndResource
1830 %%EOF
1831     }\endgroup
1832   \expandafter\edef\csname cmapOT1IT\endcsname#1{%
1833     \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
1834   }%
1835 %
1836 % \cmapOT1TT
1837   \begingroup
1838     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
1839     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
1840 %%DocumentNeededResources: ProcSet (CIDInit)
1841 %%IncludeResource: ProcSet (CIDInit)
1842 %%BeginResource: CMap (TeX-OT1TT-0)
1843 %%Title: (TeX-OT1TT-0 TeX OT1TT 0)
1844 %%Version: 1.000
1845 %%EndComments
1846 /CIDInit /ProcSet findresource begin
1847 12 dict begin
1848 begincmap
1849 /CIDSystemInfo
1850 << /Registry (TeX)
1851 /Ordering (OT1TT)
1852 /Supplement 0
1853 >> def
1854 /CMapName /TeX-OT1TT-0 def
1855 /CMapType 2 def
1856 1 begincodespacerange
1857 <00> <7F>
1858 endcodespacerange
1859 5 beginbfrange
1860 <00> <01> <0393>
1861 <09> <0A> <03A8>
1862 <21> <26> <0021>
1863 <28> <5F> <0028>
1864 <61> <7E> <0061>
1865 endbfrange
1866 32 beginbfchar
1867 <02> <0398>
1868 <03> <039B>
1869 <04> <039E>
1870 <05> <03A0>
1871 <06> <03A3>
1872 <07> <03D2>
1873 <08> <03A6>
1874 <0B> <2191>
1875 <0C> <2193>
1876 <0D> <0027>
1877 <0E> <00A1>
1878 <0F> <00BF>
1879 <10> <0131>
1880 <11> <0237>
1881 <12> <0060>
1882 <13> <00B4>
1883 <14> <02C7>
1884 <15> <02D8>
1885 <16> <00AF>
1886 <17> <02DA>
1887 <18> <00B8>
1888 <19> <00DF>
1889 <1A> <00E6>
1890 <1B> <0153>
1891 <1C> <00F8>
1892 <1D> <00C6>
1893 <1E> <0152>
1894 <1F> <00D8>
1895 <20> <2423>
1896 <27> <2019>
1897 <60> <2018>
1898 <7F> <00A8>
1899 endbfchar
1900 endcmap
1901 CMapName currentdict /CMap defineresource pop
1902 end
1903 end
1904 %%EndResource
1905 %%EOF
1906     }\endgroup
1907   \expandafter\edef\csname cmapOT1TT\endcsname#1{%
1908     \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
1909   }%
1910 \fi\fi
1911
1912
1913 % Set the font macro #1 to the font named \fontprefix#2.
1914 % #3 is the font's design size, #4 is a scale factor, #5 is the CMap
1915 % encoding (only OT1, OT1IT and OT1TT are allowed, or empty to omit).
1916 % Example:
1917 % #1 = \textrm
1918 % #2 = \rmshape
1919 % #3 = 10
1920 % #4 = \mainmagstep
1921 % #5 = OT1
1922 %
1923 \def\setfont#1#2#3#4#5{%
1924   \font#1=\fontprefix#2#3 scaled #4
1925   \csname cmap#5\endcsname#1%
1926 }
1927 % This is what gets called when #5 of \setfont is empty.
1928 \let\cmap\gobble
1929 %
1930 % (end of cmaps)
1931
1932 % Use cm as the default font prefix.
1933 % To specify the font prefix, you must define \fontprefix
1934 % before you read in texinfo.tex.
1935 \ifx\fontprefix\thisisundefined
1936 \def\fontprefix{cm}
1937 \fi
1938 % Support font families that don't use the same naming scheme as CM.
1939 \def\rmshape{r}
1940 \def\rmbshape{bx}               % where the normal face is bold
1941 \def\bfshape{b}
1942 \def\bxshape{bx}
1943 \def\ttshape{tt}
1944 \def\ttbshape{tt}
1945 \def\ttslshape{sltt}
1946 \def\itshape{ti}
1947 \def\itbshape{bxti}
1948 \def\slshape{sl}
1949 \def\slbshape{bxsl}
1950 \def\sfshape{ss}
1951 \def\sfbshape{ss}
1952 \def\scshape{csc}
1953 \def\scbshape{csc}
1954
1955 % Definitions for a main text size of 11pt.  (The default in Texinfo.)
1956 %
1957 \def\definetextfontsizexi{%
1958 % Text fonts (11.2pt, magstep1).
1959 \def\textnominalsize{11pt}
1960 \edef\mainmagstep{\magstephalf}
1961 \setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
1962 \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
1963 \setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
1964 \setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
1965 \setfont\textsl\slshape{10}{\mainmagstep}{OT1}
1966 \setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
1967 \setfont\textsc\scshape{10}{\mainmagstep}{OT1}
1968 \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
1969 \font\texti=cmmi10 scaled \mainmagstep
1970 \font\textsy=cmsy10 scaled \mainmagstep
1971 \def\textecsize{1095}
1972
1973 % A few fonts for @defun names and args.
1974 \setfont\defbf\bfshape{10}{\magstep1}{OT1}
1975 \setfont\deftt\ttshape{10}{\magstep1}{OT1TT}
1976 \setfont\defsl\slshape{10}{\magstep1}{OT1TT}
1977 \setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT}
1978 \def\df{\let\tentt=\deftt \let\tenbf = \defbf
1979 \let\tenttsl=\defttsl \let\tensl=\defsl \bf}
1980
1981 % Fonts for indices, footnotes, small examples (9pt).
1982 \def\smallnominalsize{9pt}
1983 \setfont\smallrm\rmshape{9}{1000}{OT1}
1984 \setfont\smalltt\ttshape{9}{1000}{OT1TT}
1985 \setfont\smallbf\bfshape{10}{900}{OT1}
1986 \setfont\smallit\itshape{9}{1000}{OT1IT}
1987 \setfont\smallsl\slshape{9}{1000}{OT1}
1988 \setfont\smallsf\sfshape{9}{1000}{OT1}
1989 \setfont\smallsc\scshape{10}{900}{OT1}
1990 \setfont\smallttsl\ttslshape{10}{900}{OT1TT}
1991 \font\smalli=cmmi9
1992 \font\smallsy=cmsy9
1993 \def\smallecsize{0900}
1994
1995 % Fonts for small examples (8pt).
1996 \def\smallernominalsize{8pt}
1997 \setfont\smallerrm\rmshape{8}{1000}{OT1}
1998 \setfont\smallertt\ttshape{8}{1000}{OT1TT}
1999 \setfont\smallerbf\bfshape{10}{800}{OT1}
2000 \setfont\smallerit\itshape{8}{1000}{OT1IT}
2001 \setfont\smallersl\slshape{8}{1000}{OT1}
2002 \setfont\smallersf\sfshape{8}{1000}{OT1}
2003 \setfont\smallersc\scshape{10}{800}{OT1}
2004 \setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
2005 \font\smalleri=cmmi8
2006 \font\smallersy=cmsy8
2007 \def\smallerecsize{0800}
2008
2009 % Fonts for title page (20.4pt):
2010 \def\titlenominalsize{20pt}
2011 \setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
2012 \setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
2013 \setfont\titlesl\slbshape{10}{\magstep4}{OT1}
2014 \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
2015 \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
2016 \setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
2017 \let\titlebf=\titlerm
2018 \setfont\titlesc\scbshape{10}{\magstep4}{OT1}
2019 \font\titlei=cmmi12 scaled \magstep3
2020 \font\titlesy=cmsy10 scaled \magstep4
2021 \def\titleecsize{2074}
2022
2023 % Chapter (and unnumbered) fonts (17.28pt).
2024 \def\chapnominalsize{17pt}
2025 \setfont\chaprm\rmbshape{12}{\magstep2}{OT1}
2026 \setfont\chapit\itbshape{10}{\magstep3}{OT1IT}
2027 \setfont\chapsl\slbshape{10}{\magstep3}{OT1}
2028 \setfont\chaptt\ttbshape{12}{\magstep2}{OT1TT}
2029 \setfont\chapttsl\ttslshape{10}{\magstep3}{OT1TT}
2030 \setfont\chapsf\sfbshape{17}{1000}{OT1}
2031 \let\chapbf=\chaprm
2032 \setfont\chapsc\scbshape{10}{\magstep3}{OT1}
2033 \font\chapi=cmmi12 scaled \magstep2
2034 \font\chapsy=cmsy10 scaled \magstep3
2035 \def\chapecsize{1728}
2036
2037 % Section fonts (14.4pt).
2038 \def\secnominalsize{14pt}
2039 \setfont\secrm\rmbshape{12}{\magstep1}{OT1}
2040 \setfont\secrmnotbold\rmshape{12}{\magstep1}{OT1}
2041 \setfont\secit\itbshape{10}{\magstep2}{OT1IT}
2042 \setfont\secsl\slbshape{10}{\magstep2}{OT1}
2043 \setfont\sectt\ttbshape{12}{\magstep1}{OT1TT}
2044 \setfont\secttsl\ttslshape{10}{\magstep2}{OT1TT}
2045 \setfont\secsf\sfbshape{12}{\magstep1}{OT1}
2046 \let\secbf\secrm
2047 \setfont\secsc\scbshape{10}{\magstep2}{OT1}
2048 \font\seci=cmmi12 scaled \magstep1
2049 \font\secsy=cmsy10 scaled \magstep2
2050 \def\sececsize{1440}
2051
2052 % Subsection fonts (13.15pt).
2053 \def\ssecnominalsize{13pt}
2054 \setfont\ssecrm\rmbshape{12}{\magstephalf}{OT1}
2055 \setfont\ssecit\itbshape{10}{1315}{OT1IT}
2056 \setfont\ssecsl\slbshape{10}{1315}{OT1}
2057 \setfont\ssectt\ttbshape{12}{\magstephalf}{OT1TT}
2058 \setfont\ssecttsl\ttslshape{10}{1315}{OT1TT}
2059 \setfont\ssecsf\sfbshape{12}{\magstephalf}{OT1}
2060 \let\ssecbf\ssecrm
2061 \setfont\ssecsc\scbshape{10}{1315}{OT1}
2062 \font\sseci=cmmi12 scaled \magstephalf
2063 \font\ssecsy=cmsy10 scaled 1315
2064 \def\ssececsize{1200}
2065
2066 % Reduced fonts for @acro in text (10pt).
2067 \def\reducednominalsize{10pt}
2068 \setfont\reducedrm\rmshape{10}{1000}{OT1}
2069 \setfont\reducedtt\ttshape{10}{1000}{OT1TT}
2070 \setfont\reducedbf\bfshape{10}{1000}{OT1}
2071 \setfont\reducedit\itshape{10}{1000}{OT1IT}
2072 \setfont\reducedsl\slshape{10}{1000}{OT1}
2073 \setfont\reducedsf\sfshape{10}{1000}{OT1}
2074 \setfont\reducedsc\scshape{10}{1000}{OT1}
2075 \setfont\reducedttsl\ttslshape{10}{1000}{OT1TT}
2076 \font\reducedi=cmmi10
2077 \font\reducedsy=cmsy10
2078 \def\reducedecsize{1000}
2079
2080 \textleading = 13.2pt % line spacing for 11pt CM
2081 \textfonts            % reset the current fonts
2082 \rm
2083 } % end of 11pt text font size definitions, \definetextfontsizexi
2084
2085
2086 % Definitions to make the main text be 10pt Computer Modern, with
2087 % section, chapter, etc., sizes following suit.  This is for the GNU
2088 % Press printing of the Emacs 22 manual.  Maybe other manuals in the
2089 % future.  Used with @smallbook, which sets the leading to 12pt.
2090 %
2091 \def\definetextfontsizex{%
2092 % Text fonts (10pt).
2093 \def\textnominalsize{10pt}
2094 \edef\mainmagstep{1000}
2095 \setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
2096 \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
2097 \setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
2098 \setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
2099 \setfont\textsl\slshape{10}{\mainmagstep}{OT1}
2100 \setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
2101 \setfont\textsc\scshape{10}{\mainmagstep}{OT1}
2102 \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
2103 \font\texti=cmmi10 scaled \mainmagstep
2104 \font\textsy=cmsy10 scaled \mainmagstep
2105 \def\textecsize{1000}
2106
2107 % A few fonts for @defun names and args.
2108 \setfont\defbf\bfshape{10}{\magstephalf}{OT1}
2109 \setfont\deftt\ttshape{10}{\magstephalf}{OT1TT}
2110 \setfont\defsl\slshape{10}{\magstephalf}{OT1TT}
2111 \setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT}
2112 \def\df{\let\tentt=\deftt \let\tenbf = \defbf
2113 \let\tensl=\defsl \let\tenttsl=\defttsl \bf}
2114
2115 % Fonts for indices, footnotes, small examples (9pt).
2116 \def\smallnominalsize{9pt}
2117 \setfont\smallrm\rmshape{9}{1000}{OT1}
2118 \setfont\smalltt\ttshape{9}{1000}{OT1TT}
2119 \setfont\smallbf\bfshape{10}{900}{OT1}
2120 \setfont\smallit\itshape{9}{1000}{OT1IT}
2121 \setfont\smallsl\slshape{9}{1000}{OT1}
2122 \setfont\smallsf\sfshape{9}{1000}{OT1}
2123 \setfont\smallsc\scshape{10}{900}{OT1}
2124 \setfont\smallttsl\ttslshape{10}{900}{OT1TT}
2125 \font\smalli=cmmi9
2126 \font\smallsy=cmsy9
2127 \def\smallecsize{0900}
2128
2129 % Fonts for small examples (8pt).
2130 \def\smallernominalsize{8pt}
2131 \setfont\smallerrm\rmshape{8}{1000}{OT1}
2132 \setfont\smallertt\ttshape{8}{1000}{OT1TT}
2133 \setfont\smallerbf\bfshape{10}{800}{OT1}
2134 \setfont\smallerit\itshape{8}{1000}{OT1IT}
2135 \setfont\smallersl\slshape{8}{1000}{OT1}
2136 \setfont\smallersf\sfshape{8}{1000}{OT1}
2137 \setfont\smallersc\scshape{10}{800}{OT1}
2138 \setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
2139 \font\smalleri=cmmi8
2140 \font\smallersy=cmsy8
2141 \def\smallerecsize{0800}
2142
2143 % Fonts for title page (20.4pt):
2144 \def\titlenominalsize{20pt}
2145 \setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
2146 \setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
2147 \setfont\titlesl\slbshape{10}{\magstep4}{OT1}
2148 \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
2149 \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
2150 \setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
2151 \let\titlebf=\titlerm
2152 \setfont\titlesc\scbshape{10}{\magstep4}{OT1}
2153 \font\titlei=cmmi12 scaled \magstep3
2154 \font\titlesy=cmsy10 scaled \magstep4
2155 \def\titleecsize{2074}
2156
2157 % Chapter fonts (14.4pt).
2158 \def\chapnominalsize{14pt}
2159 \setfont\chaprm\rmbshape{12}{\magstep1}{OT1}
2160 \setfont\chapit\itbshape{10}{\magstep2}{OT1IT}
2161 \setfont\chapsl\slbshape{10}{\magstep2}{OT1}
2162 \setfont\chaptt\ttbshape{12}{\magstep1}{OT1TT}
2163 \setfont\chapttsl\ttslshape{10}{\magstep2}{OT1TT}
2164 \setfont\chapsf\sfbshape{12}{\magstep1}{OT1}
2165 \let\chapbf\chaprm
2166 \setfont\chapsc\scbshape{10}{\magstep2}{OT1}
2167 \font\chapi=cmmi12 scaled \magstep1
2168 \font\chapsy=cmsy10 scaled \magstep2
2169 \def\chapecsize{1440}
2170
2171 % Section fonts (12pt).
2172 \def\secnominalsize{12pt}
2173 \setfont\secrm\rmbshape{12}{1000}{OT1}
2174 \setfont\secit\itbshape{10}{\magstep1}{OT1IT}
2175 \setfont\secsl\slbshape{10}{\magstep1}{OT1}
2176 \setfont\sectt\ttbshape{12}{1000}{OT1TT}
2177 \setfont\secttsl\ttslshape{10}{\magstep1}{OT1TT}
2178 \setfont\secsf\sfbshape{12}{1000}{OT1}
2179 \let\secbf\secrm
2180 \setfont\secsc\scbshape{10}{\magstep1}{OT1}
2181 \font\seci=cmmi12
2182 \font\secsy=cmsy10 scaled \magstep1
2183 \def\sececsize{1200}
2184
2185 % Subsection fonts (10pt).
2186 \def\ssecnominalsize{10pt}
2187 \setfont\ssecrm\rmbshape{10}{1000}{OT1}
2188 \setfont\ssecit\itbshape{10}{1000}{OT1IT}
2189 \setfont\ssecsl\slbshape{10}{1000}{OT1}
2190 \setfont\ssectt\ttbshape{10}{1000}{OT1TT}
2191 \setfont\ssecttsl\ttslshape{10}{1000}{OT1TT}
2192 \setfont\ssecsf\sfbshape{10}{1000}{OT1}
2193 \let\ssecbf\ssecrm
2194 \setfont\ssecsc\scbshape{10}{1000}{OT1}
2195 \font\sseci=cmmi10
2196 \font\ssecsy=cmsy10
2197 \def\ssececsize{1000}
2198
2199 % Reduced fonts for @acro in text (9pt).
2200 \def\reducednominalsize{9pt}
2201 \setfont\reducedrm\rmshape{9}{1000}{OT1}
2202 \setfont\reducedtt\ttshape{9}{1000}{OT1TT}
2203 \setfont\reducedbf\bfshape{10}{900}{OT1}
2204 \setfont\reducedit\itshape{9}{1000}{OT1IT}
2205 \setfont\reducedsl\slshape{9}{1000}{OT1}
2206 \setfont\reducedsf\sfshape{9}{1000}{OT1}
2207 \setfont\reducedsc\scshape{10}{900}{OT1}
2208 \setfont\reducedttsl\ttslshape{10}{900}{OT1TT}
2209 \font\reducedi=cmmi9
2210 \font\reducedsy=cmsy9
2211 \def\reducedecsize{0900}
2212
2213 \divide\parskip by 2  % reduce space between paragraphs
2214 \textleading = 12pt   % line spacing for 10pt CM
2215 \textfonts            % reset the current fonts
2216 \rm
2217 } % end of 10pt text font size definitions, \definetextfontsizex
2218
2219
2220 % We provide the user-level command
2221 %   @fonttextsize 10
2222 % (or 11) to redefine the text font size.  pt is assumed.
2223 %
2224 \def\xiword{11}
2225 \def\xword{10}
2226 \def\xwordpt{10pt}
2227 %
2228 \parseargdef\fonttextsize{%
2229   \def\textsizearg{#1}%
2230   %\wlog{doing @fonttextsize \textsizearg}%
2231   %
2232   % Set \globaldefs so that documents can use this inside @tex, since
2233   % makeinfo 4.8 does not support it, but we need it nonetheless.
2234   %
2235  \begingroup \globaldefs=1
2236   \ifx\textsizearg\xword \definetextfontsizex
2237   \else \ifx\textsizearg\xiword \definetextfontsizexi
2238   \else
2239     \errhelp=\EMsimple
2240     \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'}
2241   \fi\fi
2242  \endgroup
2243 }
2244
2245 % In order for the font changes to affect most math symbols and letters,
2246 % we have to define the \textfont of the standard families.  We don't
2247 % bother to reset \scriptfont and \scriptscriptfont; awaiting user need.
2248 %
2249 \def\resetmathfonts{%
2250   \textfont0=\tenrm \textfont1=\teni \textfont2=\tensy
2251   \textfont\itfam=\tenit \textfont\slfam=\tensl \textfont\bffam=\tenbf
2252   \textfont\ttfam=\tentt \textfont\sffam=\tensf
2253 }
2254
2255 % The font-changing commands redefine the meanings of \tenSTYLE, instead
2256 % of just \STYLE.  We do this because \STYLE needs to also set the
2257 % current \fam for math mode.  Our \STYLE (e.g., \rm) commands hardwire
2258 % \tenSTYLE to set the current font.
2259 %
2260 % Each font-changing command also sets the names \lsize (one size lower)
2261 % and \lllsize (three sizes lower).  These relative commands are used
2262 % in, e.g., the LaTeX logo and acronyms.
2263 %
2264 % This all needs generalizing, badly.
2265 %
2266 \def\textfonts{%
2267   \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
2268   \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
2269   \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy
2270   \let\tenttsl=\textttsl
2271   \def\curfontsize{text}%
2272   \def\lsize{reduced}\def\lllsize{smaller}%
2273   \resetmathfonts \setleading{\textleading}}
2274 \def\titlefonts{%
2275   \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl
2276   \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc
2277   \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy
2278   \let\tenttsl=\titlettsl
2279   \def\curfontsize{title}%
2280   \def\lsize{chap}\def\lllsize{subsec}%
2281   \resetmathfonts \setleading{27pt}}
2282 \def\titlefont#1{{\titlefonts\rmisbold #1}}
2283 \def\chapfonts{%
2284   \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl
2285   \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
2286   \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy
2287   \let\tenttsl=\chapttsl
2288   \def\curfontsize{chap}%
2289   \def\lsize{sec}\def\lllsize{text}%
2290   \resetmathfonts \setleading{19pt}}
2291 \def\secfonts{%
2292   \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl
2293   \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc
2294   \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy
2295   \let\tenttsl=\secttsl
2296   \def\curfontsize{sec}%
2297   \def\lsize{subsec}\def\lllsize{reduced}%
2298   \resetmathfonts \setleading{17pt}}
2299 \def\subsecfonts{%
2300   \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl
2301   \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc
2302   \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy
2303   \let\tenttsl=\ssecttsl
2304   \def\curfontsize{ssec}%
2305   \def\lsize{text}\def\lllsize{small}%
2306   \resetmathfonts \setleading{15pt}}
2307 \let\subsubsecfonts = \subsecfonts
2308 \def\reducedfonts{%
2309   \let\tenrm=\reducedrm \let\tenit=\reducedit \let\tensl=\reducedsl
2310   \let\tenbf=\reducedbf \let\tentt=\reducedtt \let\reducedcaps=\reducedsc
2311   \let\tensf=\reducedsf \let\teni=\reducedi \let\tensy=\reducedsy
2312   \let\tenttsl=\reducedttsl
2313   \def\curfontsize{reduced}%
2314   \def\lsize{small}\def\lllsize{smaller}%
2315   \resetmathfonts \setleading{10.5pt}}
2316 \def\smallfonts{%
2317   \let\tenrm=\smallrm \let\tenit=\smallit \let\tensl=\smallsl
2318   \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc
2319   \let\tensf=\smallsf \let\teni=\smalli \let\tensy=\smallsy
2320   \let\tenttsl=\smallttsl
2321   \def\curfontsize{small}%
2322   \def\lsize{smaller}\def\lllsize{smaller}%
2323   \resetmathfonts \setleading{10.5pt}}
2324 \def\smallerfonts{%
2325   \let\tenrm=\smallerrm \let\tenit=\smallerit \let\tensl=\smallersl
2326   \let\tenbf=\smallerbf \let\tentt=\smallertt \let\smallcaps=\smallersc
2327   \let\tensf=\smallersf \let\teni=\smalleri \let\tensy=\smallersy
2328   \let\tenttsl=\smallerttsl
2329   \def\curfontsize{smaller}%
2330   \def\lsize{smaller}\def\lllsize{smaller}%
2331   \resetmathfonts \setleading{9.5pt}}
2332
2333 % Fonts for short table of contents.
2334 \setfont\shortcontrm\rmshape{12}{1000}{OT1}
2335 \setfont\shortcontbf\bfshape{10}{\magstep1}{OT1}  % no cmb12
2336 \setfont\shortcontsl\slshape{12}{1000}{OT1}
2337 \setfont\shortconttt\ttshape{12}{1000}{OT1TT}
2338
2339 % Define these just so they can be easily changed for other fonts.
2340 \def\angleleft{$\langle$}
2341 \def\angleright{$\rangle$}
2342
2343 % Set the fonts to use with the @small... environments.
2344 \let\smallexamplefonts = \smallfonts
2345
2346 % About \smallexamplefonts.  If we use \smallfonts (9pt), @smallexample
2347 % can fit this many characters:
2348 %   8.5x11=86   smallbook=72  a4=90  a5=69
2349 % If we use \scriptfonts (8pt), then we can fit this many characters:
2350 %   8.5x11=90+  smallbook=80  a4=90+  a5=77
2351 % For me, subjectively, the few extra characters that fit aren't worth
2352 % the additional smallness of 8pt.  So I'm making the default 9pt.
2353 %
2354 % By the way, for comparison, here's what fits with @example (10pt):
2355 %   8.5x11=71  smallbook=60  a4=75  a5=58
2356 % --karl, 24jan03.
2357
2358 % Set up the default fonts, so we can use them for creating boxes.
2359 %
2360 \definetextfontsizexi
2361
2362
2363 \message{markup,}
2364
2365 % Check if we are currently using a typewriter font.  Since all the
2366 % Computer Modern typewriter fonts have zero interword stretch (and
2367 % shrink), and it is reasonable to expect all typewriter fonts to have
2368 % this property, we can check that font parameter.
2369 %
2370 \def\ifmonospace{\ifdim\fontdimen3\font=0pt }
2371
2372 % Markup style infrastructure.  \defmarkupstylesetup\INITMACRO will
2373 % define and register \INITMACRO to be called on markup style changes.
2374 % \INITMACRO can check \currentmarkupstyle for the innermost
2375 % style and the set of \ifmarkupSTYLE switches for all styles
2376 % currently in effect.
2377 \newif\ifmarkupvar
2378 \newif\ifmarkupsamp
2379 \newif\ifmarkupkey
2380 %\newif\ifmarkupfile % @file == @samp.
2381 %\newif\ifmarkupoption % @option == @samp.
2382 \newif\ifmarkupcode
2383 \newif\ifmarkupkbd
2384 %\newif\ifmarkupenv % @env == @code.
2385 %\newif\ifmarkupcommand % @command == @code.
2386 \newif\ifmarkuptex % @tex (and part of @math, for now).
2387 \newif\ifmarkupexample
2388 \newif\ifmarkupverb
2389 \newif\ifmarkupverbatim
2390
2391 \let\currentmarkupstyle\empty
2392
2393 \def\setupmarkupstyle#1{%
2394   \csname markup#1true\endcsname
2395   \def\currentmarkupstyle{#1}%
2396   \markupstylesetup
2397 }
2398
2399 \let\markupstylesetup\empty
2400
2401 \def\defmarkupstylesetup#1{%
2402   \expandafter\def\expandafter\markupstylesetup
2403     \expandafter{\markupstylesetup #1}%
2404   \def#1%
2405 }
2406
2407 % Markup style setup for left and right quotes.
2408 \defmarkupstylesetup\markupsetuplq{%
2409   \expandafter\let\expandafter \temp
2410     \csname markupsetuplq\currentmarkupstyle\endcsname
2411   \ifx\temp\relax \markupsetuplqdefault \else \temp \fi
2412 }
2413
2414 \defmarkupstylesetup\markupsetuprq{%
2415   \expandafter\let\expandafter \temp
2416     \csname markupsetuprq\currentmarkupstyle\endcsname
2417   \ifx\temp\relax \markupsetuprqdefault \else \temp \fi
2418 }
2419
2420 {
2421 \catcode`\'=\active
2422 \catcode`\`=\active
2423
2424 \gdef\markupsetuplqdefault{\let`\lq}
2425 \gdef\markupsetuprqdefault{\let'\rq}
2426
2427 \gdef\markupsetcodequoteleft{\let`\codequoteleft}
2428 \gdef\markupsetcodequoteright{\let'\codequoteright}
2429 }
2430
2431 \let\markupsetuplqcode \markupsetcodequoteleft
2432 \let\markupsetuprqcode \markupsetcodequoteright
2433 %
2434 \let\markupsetuplqexample \markupsetcodequoteleft
2435 \let\markupsetuprqexample \markupsetcodequoteright
2436 %
2437 \let\markupsetuplqkbd     \markupsetcodequoteleft
2438 \let\markupsetuprqkbd     \markupsetcodequoteright
2439 %
2440 \let\markupsetuplqsamp \markupsetcodequoteleft
2441 \let\markupsetuprqsamp \markupsetcodequoteright
2442 %
2443 \let\markupsetuplqverb \markupsetcodequoteleft
2444 \let\markupsetuprqverb \markupsetcodequoteright
2445 %
2446 \let\markupsetuplqverbatim \markupsetcodequoteleft
2447 \let\markupsetuprqverbatim \markupsetcodequoteright
2448
2449 % Allow an option to not use regular directed right quote/apostrophe
2450 % (char 0x27), but instead the undirected quote from cmtt (char 0x0d).
2451 % The undirected quote is ugly, so don't make it the default, but it
2452 % works for pasting with more pdf viewers (at least evince), the
2453 % lilypond developers report.  xpdf does work with the regular 0x27.
2454 %
2455 \def\codequoteright{%
2456   \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax
2457     \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax
2458       '%
2459     \else \char'15 \fi
2460   \else \char'15 \fi
2461 }
2462 %
2463 % and a similar option for the left quote char vs. a grave accent.
2464 % Modern fonts display ASCII 0x60 as a grave accent, so some people like
2465 % the code environments to do likewise.
2466 %
2467 \def\codequoteleft{%
2468   \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax
2469     \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax
2470       % [Knuth] pp. 380,381,391
2471       % \relax disables Spanish ligatures ?` and !` of \tt font.
2472       \relax`%
2473     \else \char'22 \fi
2474   \else \char'22 \fi
2475 }
2476
2477 % Commands to set the quote options.
2478
2479 \parseargdef\codequoteundirected{%
2480   \def\temp{#1}%
2481   \ifx\temp\onword
2482     \expandafter\let\csname SETtxicodequoteundirected\endcsname
2483       = t%
2484   \else\ifx\temp\offword
2485     \expandafter\let\csname SETtxicodequoteundirected\endcsname
2486       = \relax
2487   \else
2488     \errhelp = \EMsimple
2489     \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}%
2490   \fi\fi
2491 }
2492 %
2493 \parseargdef\codequotebacktick{%
2494   \def\temp{#1}%
2495   \ifx\temp\onword
2496     \expandafter\let\csname SETtxicodequotebacktick\endcsname
2497       = t%
2498   \else\ifx\temp\offword
2499     \expandafter\let\csname SETtxicodequotebacktick\endcsname
2500       = \relax
2501   \else
2502     \errhelp = \EMsimple
2503     \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}%
2504   \fi\fi
2505 }
2506
2507 % [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font.
2508 \def\noligaturesquoteleft{\relax\lq}
2509
2510 % Count depth in font-changes, for error checks
2511 \newcount\fontdepth \fontdepth=0
2512
2513 % Font commands.
2514
2515 % #1 is the font command (\sl or \it), #2 is the text to slant.
2516 % If we are in a monospaced environment, however, 1) always use \ttsl,
2517 % and 2) do not add an italic correction.
2518 \def\dosmartslant#1#2{%
2519   \ifusingtt 
2520     {{\ttsl #2}\let\next=\relax}%
2521     {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}%
2522   \next
2523 }
2524 \def\smartslanted{\dosmartslant\sl}
2525 \def\smartitalic{\dosmartslant\it}
2526
2527 % Output an italic correction unless \next (presumed to be the following
2528 % character) is such as not to need one.
2529 \def\smartitaliccorrection{%
2530   \ifx\next,%
2531   \else\ifx\next-%
2532   \else\ifx\next.%
2533   \else\ifx\next\.%
2534   \else\ifx\next\comma%
2535   \else\ptexslash
2536   \fi\fi\fi\fi\fi
2537   \aftersmartic
2538 }
2539
2540 % Unconditional use \ttsl, and no ic.  @var is set to this for defuns.
2541 \def\ttslanted#1{{\ttsl #1}}
2542
2543 % @cite is like \smartslanted except unconditionally use \sl.  We never want
2544 % ttsl for book titles, do we?
2545 \def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection}
2546
2547 \def\aftersmartic{}
2548 \def\var#1{%
2549   \let\saveaftersmartic = \aftersmartic
2550   \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}%
2551   \smartslanted{#1}%
2552 }
2553
2554 \let\i=\smartitalic
2555 \let\slanted=\smartslanted
2556 \let\dfn=\smartslanted
2557 \let\emph=\smartitalic
2558
2559 % Explicit font changes: @r, @sc, undocumented @ii.
2560 \def\r#1{{\rm #1}}              % roman font
2561 \def\sc#1{{\smallcaps#1}}       % smallcaps font
2562 \def\ii#1{{\it #1}}             % italic font
2563
2564 % @b, explicit bold.  Also @strong.
2565 \def\b#1{{\bf #1}}
2566 \let\strong=\b
2567
2568 % @sansserif, explicit sans.
2569 \def\sansserif#1{{\sf #1}}
2570
2571 % We can't just use \exhyphenpenalty, because that only has effect at
2572 % the end of a paragraph.  Restore normal hyphenation at the end of the
2573 % group within which \nohyphenation is presumably called.
2574 %
2575 \def\nohyphenation{\hyphenchar\font = -1  \aftergroup\restorehyphenation}
2576 \def\restorehyphenation{\hyphenchar\font = `- }
2577
2578 % Set sfcode to normal for the chars that usually have another value.
2579 % Can't use plain's \frenchspacing because it uses the `\x notation, and
2580 % sometimes \x has an active definition that messes things up.
2581 %
2582 \catcode`@=11
2583   \def\plainfrenchspacing{%
2584     \sfcode`\.=\@m \sfcode`\?=\@m \sfcode`\!=\@m
2585     \sfcode`\:=\@m \sfcode`\;=\@m \sfcode`\,=\@m
2586     \def\endofsentencespacefactor{1000}% for @. and friends
2587   }
2588   \def\plainnonfrenchspacing{%
2589     \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000
2590     \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250
2591     \def\endofsentencespacefactor{3000}% for @. and friends
2592   }
2593 \catcode`@=\other
2594 \def\endofsentencespacefactor{3000}% default
2595
2596 % @t, explicit typewriter.
2597 \def\t#1{%
2598   {\tt \rawbackslash \plainfrenchspacing #1}%
2599   \null
2600 }
2601
2602 % @samp.
2603 \def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}}
2604
2605 % @indicateurl is \samp, that is, with quotes.
2606 \let\indicateurl=\samp
2607
2608 % @code (and similar) prints in typewriter, but with spaces the same
2609 % size as normal in the surrounding text, without hyphenation, etc.
2610 % This is a subroutine for that.
2611 \def\tclose#1{%
2612   {%
2613     % Change normal interword space to be same as for the current font.
2614     \spaceskip = \fontdimen2\font
2615     %
2616     % Switch to typewriter.
2617     \tt
2618     %
2619     % But `\ ' produces the large typewriter interword space.
2620     \def\ {{\spaceskip = 0pt{} }}%
2621     %
2622     % Turn off hyphenation.
2623     \nohyphenation
2624     %
2625     \rawbackslash
2626     \plainfrenchspacing
2627     #1%
2628   }%
2629   \null % reset spacefactor to 1000
2630 }
2631
2632 % We *must* turn on hyphenation at `-' and `_' in @code.
2633 % (But see \codedashfinish below.)
2634 % Otherwise, it is too hard to avoid overfull hboxes
2635 % in the Emacs manual, the Library manual, etc.
2636 %
2637 % Unfortunately, TeX uses one parameter (\hyphenchar) to control
2638 % both hyphenation at - and hyphenation within words.
2639 % We must therefore turn them both off (\tclose does that)
2640 % and arrange explicitly to hyphenate at a dash. -- rms.
2641 {
2642   \catcode`\-=\active \catcode`\_=\active
2643   \catcode`\'=\active \catcode`\`=\active
2644   \global\let'=\rq \global\let`=\lq  % default definitions
2645   %
2646   \global\def\code{\begingroup
2647     \setupmarkupstyle{code}%
2648     % The following should really be moved into \setupmarkupstyle handlers.
2649     \catcode\dashChar=\active  \catcode\underChar=\active
2650     \ifallowcodebreaks
2651      \let-\codedash
2652      \let_\codeunder
2653     \else
2654      \let-\normaldash
2655      \let_\realunder
2656     \fi
2657     % Given -foo (with a single dash), we do not want to allow a break
2658     % after the hyphen.
2659     \global\let\codedashprev=\codedash
2660     %
2661     \codex
2662   }
2663   %
2664   \gdef\codedash{\futurelet\next\codedashfinish}
2665   \gdef\codedashfinish{%
2666     \normaldash % always output the dash character itself.
2667     % 
2668     % Now, output a discretionary to allow a line break, unless
2669     % (a) the next character is a -, or
2670     % (b) the preceding character is a -.
2671     % E.g., given --posix, we do not want to allow a break after either -.
2672     % Given --foo-bar, we do want to allow a break between the - and the b.
2673     \ifx\next\codedash \else
2674       \ifx\codedashprev\codedash 
2675       \else \discretionary{}{}{}\fi
2676     \fi
2677     % we need the space after the = for the case when \next itself is a
2678     % space token; it would get swallowed otherwise.  As in @code{- a}.
2679     \global\let\codedashprev= \next
2680   }
2681 }
2682 \def\normaldash{-}
2683 %
2684 \def\codex #1{\tclose{#1}\endgroup}
2685
2686 \def\codeunder{%
2687   % this is all so @math{@code{var_name}+1} can work.  In math mode, _
2688   % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.)
2689   % will therefore expand the active definition of _, which is us
2690   % (inside @code that is), therefore an endless loop.
2691   \ifusingtt{\ifmmode
2692                \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_.
2693              \else\normalunderscore \fi
2694              \discretionary{}{}{}}%
2695             {\_}%
2696 }
2697
2698 % An additional complication: the above will allow breaks after, e.g.,
2699 % each of the four underscores in __typeof__.  This is bad.
2700 % @allowcodebreaks provides a document-level way to turn breaking at -
2701 % and _ on and off.
2702 %
2703 \newif\ifallowcodebreaks  \allowcodebreakstrue
2704
2705 \def\keywordtrue{true}
2706 \def\keywordfalse{false}
2707
2708 \parseargdef\allowcodebreaks{%
2709   \def\txiarg{#1}%
2710   \ifx\txiarg\keywordtrue
2711     \allowcodebreakstrue
2712   \else\ifx\txiarg\keywordfalse
2713     \allowcodebreaksfalse
2714   \else
2715     \errhelp = \EMsimple
2716     \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}%
2717   \fi\fi
2718 }
2719
2720 % For @command, @env, @file, @option quotes seem unnecessary,
2721 % so use \code rather than \samp.
2722 \let\command=\code
2723 \let\env=\code
2724 \let\file=\code
2725 \let\option=\code
2726
2727 % @uref (abbreviation for `urlref') aka @url takes an optional
2728 % (comma-separated) second argument specifying the text to display and
2729 % an optional third arg as text to display instead of (rather than in
2730 % addition to) the url itself.  First (mandatory) arg is the url.
2731
2732 % TeX-only option to allow changing PDF output to show only the second
2733 % arg (if given), and not the url (which is then just the link target).
2734 \newif\ifurefurlonlylink
2735
2736 % The main macro is \urefbreak, which allows breaking at expected
2737 % places within the url.  (There used to be another version, which
2738 % didn't support automatic breaking.)
2739 \def\urefbreak{\begingroup \urefcatcodes \dourefbreak}
2740 \let\uref=\urefbreak
2741 %
2742 \def\dourefbreak#1{\urefbreakfinish #1,,,\finish}
2743 \def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example
2744   \unsepspaces
2745   \pdfurl{#1}%
2746   \setbox0 = \hbox{\ignorespaces #3}%
2747   \ifdim\wd0 > 0pt
2748     \unhbox0 % third arg given, show only that
2749   \else
2750     \setbox0 = \hbox{\ignorespaces #2}% look for second arg
2751     \ifdim\wd0 > 0pt
2752       \ifpdf
2753         \ifurefurlonlylink
2754           % PDF plus option to not display url, show just arg
2755           \unhbox0             
2756         \else
2757           % PDF, normally display both arg and url for consistency,
2758           % visibility, if the pdf is eventually used to print, etc.
2759           \unhbox0\ (\urefcode{#1})%
2760         \fi
2761       \else
2762         \unhbox0\ (\urefcode{#1})% DVI, always show arg and url
2763       \fi
2764     \else
2765       \urefcode{#1}% only url given, so show it
2766     \fi
2767   \fi
2768   \endlink
2769 \endgroup}
2770
2771 % Allow line breaks around only a few characters (only).
2772 \def\urefcatcodes{%
2773   \catcode`\&=\active \catcode`\.=\active
2774   \catcode`\#=\active \catcode`\?=\active
2775   \catcode`\/=\active
2776 }
2777 {
2778   \urefcatcodes
2779   %
2780   \global\def\urefcode{\begingroup
2781     \setupmarkupstyle{code}%
2782     \urefcatcodes
2783     \let&\urefcodeamp
2784     \let.\urefcodedot
2785     \let#\urefcodehash
2786     \let?\urefcodequest
2787     \let/\urefcodeslash
2788     \codex
2789   }
2790   %
2791   % By default, they are just regular characters.
2792   \global\def&{\normalamp}
2793   \global\def.{\normaldot}
2794   \global\def#{\normalhash}
2795   \global\def?{\normalquest}
2796   \global\def/{\normalslash}
2797 }
2798
2799 % we put a little stretch before and after the breakable chars, to help
2800 % line breaking of long url's.  The unequal skips make look better in
2801 % cmtt at least, especially for dots.
2802 \def\urefprestretchamount{.13em}
2803 \def\urefpoststretchamount{.1em}
2804 \def\urefprestretch{\urefprebreak \hskip0pt plus\urefprestretchamount\relax}
2805 \def\urefpoststretch{\urefpostbreak \hskip0pt plus\urefprestretchamount\relax}
2806 %
2807 \def\urefcodeamp{\urefprestretch \&\urefpoststretch}
2808 \def\urefcodedot{\urefprestretch .\urefpoststretch}
2809 \def\urefcodehash{\urefprestretch \#\urefpoststretch}
2810 \def\urefcodequest{\urefprestretch ?\urefpoststretch}
2811 \def\urefcodeslash{\futurelet\next\urefcodeslashfinish}
2812 {
2813   \catcode`\/=\active
2814   \global\def\urefcodeslashfinish{%
2815     \urefprestretch \slashChar
2816     % Allow line break only after the final / in a sequence of
2817     % slashes, to avoid line break between the slashes in http://.
2818     \ifx\next/\else \urefpoststretch \fi
2819   }
2820 }
2821
2822 % One more complication: by default we'll break after the special
2823 % characters, but some people like to break before the special chars, so
2824 % allow that.  Also allow no breaking at all, for manual control.
2825
2826 \parseargdef\urefbreakstyle{%
2827   \def\txiarg{#1}%
2828   \ifx\txiarg\wordnone
2829     \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak}
2830   \else\ifx\txiarg\wordbefore
2831     \def\urefprebreak{\allowbreak}\def\urefpostbreak{\nobreak}
2832   \else\ifx\txiarg\wordafter
2833     \def\urefprebreak{\nobreak}\def\urefpostbreak{\allowbreak}
2834   \else
2835     \errhelp = \EMsimple
2836     \errmessage{Unknown @urefbreakstyle setting `\txiarg'}%
2837   \fi\fi\fi
2838 }
2839 \def\wordafter{after}
2840 \def\wordbefore{before}
2841 \def\wordnone{none}
2842
2843 \urefbreakstyle after
2844
2845 % @url synonym for @uref, since that's how everyone uses it.
2846 %
2847 \let\url=\uref
2848
2849 % rms does not like angle brackets --karl, 17may97.
2850 % So now @email is just like @uref, unless we are pdf.
2851 %
2852 %\def\email#1{\angleleft{\tt #1}\angleright}
2853 \ifpdf
2854   \def\email#1{\doemail#1,,\finish}
2855   \def\doemail#1,#2,#3\finish{\begingroup
2856     \unsepspaces
2857     \pdfurl{mailto:#1}%
2858     \setbox0 = \hbox{\ignorespaces #2}%
2859     \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
2860     \endlink
2861   \endgroup}
2862 \else
2863   \let\email=\uref
2864 \fi
2865
2866 % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
2867 %   `example' (@kbd uses ttsl only inside of @example and friends),
2868 %   or `code' (@kbd uses normal tty font always).
2869 \parseargdef\kbdinputstyle{%
2870   \def\txiarg{#1}%
2871   \ifx\txiarg\worddistinct
2872     \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
2873   \else\ifx\txiarg\wordexample
2874     \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
2875   \else\ifx\txiarg\wordcode
2876     \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
2877   \else
2878     \errhelp = \EMsimple
2879     \errmessage{Unknown @kbdinputstyle setting `\txiarg'}%
2880   \fi\fi\fi
2881 }
2882 \def\worddistinct{distinct}
2883 \def\wordexample{example}
2884 \def\wordcode{code}
2885
2886 % Default is `distinct'.
2887 \kbdinputstyle distinct
2888
2889 % @kbd is like @code, except that if the argument is just one @key command,
2890 % then @kbd has no effect.
2891 \def\kbd#1{{\def\look{#1}\expandafter\kbdsub\look??\par}}
2892
2893 \def\xkey{\key}
2894 \def\kbdsub#1#2#3\par{%
2895   \def\one{#1}\def\three{#3}\def\threex{??}%
2896   \ifx\one\xkey\ifx\threex\three \key{#2}%
2897   \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
2898   \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
2899 }
2900
2901 % definition of @key that produces a lozenge.  Doesn't adjust to text size.
2902 %\setfont\keyrm\rmshape{8}{1000}{OT1}
2903 %\font\keysy=cmsy9
2904 %\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
2905 %  \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
2906 %    \vbox{\hrule\kern-0.4pt
2907 %     \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
2908 %    \kern-0.4pt\hrule}%
2909 %  \kern-.06em\raise0.4pt\hbox{\angleright}}}}
2910
2911 % definition of @key with no lozenge.  If the current font is already
2912 % monospace, don't change it; that way, we respect @kbdinputstyle.  But
2913 % if it isn't monospace, then use \tt.
2914 %
2915 \def\key#1{{\setupmarkupstyle{key}%
2916   \nohyphenation
2917   \ifmonospace\else\tt\fi
2918   #1}\null}
2919
2920 % @clicksequence{File @click{} Open ...}
2921 \def\clicksequence#1{\begingroup #1\endgroup}
2922
2923 % @clickstyle @arrow   (by default)
2924 \parseargdef\clickstyle{\def\click{#1}}
2925 \def\click{\arrow}
2926
2927 % Typeset a dimension, e.g., `in' or `pt'.  The only reason for the
2928 % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
2929 %
2930 \def\dmn#1{\thinspace #1}
2931
2932 % @acronym for "FBI", "NATO", and the like.
2933 % We print this one point size smaller, since it's intended for
2934 % all-uppercase.
2935 %
2936 \def\acronym#1{\doacronym #1,,\finish}
2937 \def\doacronym#1,#2,#3\finish{%
2938   {\selectfonts\lsize #1}%
2939   \def\temp{#2}%
2940   \ifx\temp\empty \else
2941     \space ({\unsepspaces \ignorespaces \temp \unskip})%
2942   \fi
2943   \null % reset \spacefactor=1000
2944 }
2945
2946 % @abbr for "Comput. J." and the like.
2947 % No font change, but don't do end-of-sentence spacing.
2948 %
2949 \def\abbr#1{\doabbr #1,,\finish}
2950 \def\doabbr#1,#2,#3\finish{%
2951   {\plainfrenchspacing #1}%
2952   \def\temp{#2}%
2953   \ifx\temp\empty \else
2954     \space ({\unsepspaces \ignorespaces \temp \unskip})%
2955   \fi
2956   \null % reset \spacefactor=1000
2957 }
2958
2959 % @asis just yields its argument.  Used with @table, for example.
2960 %
2961 \def\asis#1{#1}
2962
2963 % @math outputs its argument in math mode.
2964 %
2965 % One complication: _ usually means subscripts, but it could also mean
2966 % an actual _ character, as in @math{@var{some_variable} + 1}.  So make
2967 % _ active, and distinguish by seeing if the current family is \slfam,
2968 % which is what @var uses.
2969 {
2970   \catcode`\_ = \active
2971   \gdef\mathunderscore{%
2972     \catcode`\_=\active
2973     \def_{\ifnum\fam=\slfam \_\else\sb\fi}%
2974   }
2975 }
2976 % Another complication: we want \\ (and @\) to output a math (or tt) \.
2977 % FYI, plain.tex uses \\ as a temporary control sequence (for no
2978 % particular reason), but this is not advertised and we don't care.
2979 %
2980 % The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\.
2981 \def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi}
2982 %
2983 \def\math{%
2984   \ifmmode\else % only go into math if not in math mode already
2985     \tex
2986     \mathunderscore
2987     \let\\ = \mathbackslash
2988     \mathactive
2989     % make the texinfo accent commands work in math mode
2990     \let\"=\ddot
2991     \let\'=\acute
2992     \let\==\bar
2993     \let\^=\hat
2994     \let\`=\grave
2995     \let\u=\breve
2996     \let\v=\check
2997     \let\~=\tilde
2998     \let\dotaccent=\dot
2999     % have to provide another name for sup operator
3000     \let\mathopsup=\sup
3001   $\expandafter\finishmath\fi
3002 }
3003 \def\finishmath#1{#1$\endgroup}  % Close the group opened by \tex.
3004
3005 % Some active characters (such as <) are spaced differently in math.
3006 % We have to reset their definitions in case the @math was an argument
3007 % to a command which sets the catcodes (such as @item or @section).
3008 %
3009 {
3010   \catcode`^ = \active
3011   \catcode`< = \active
3012   \catcode`> = \active
3013   \catcode`+ = \active
3014   \catcode`' = \active
3015   \gdef\mathactive{%
3016     \let^ = \ptexhat
3017     \let< = \ptexless
3018     \let> = \ptexgtr
3019     \let+ = \ptexplus
3020     \let' = \ptexquoteright
3021   }
3022 }
3023
3024 % for @sub and @sup, if in math mode, just do a normal sub/superscript.
3025 % If in text, use math to place as sub/superscript, but switch
3026 % into text mode, with smaller fonts.  This is a different font than the
3027 % one used for real math sub/superscripts (8pt vs. 7pt), but let's not
3028 % fix it (significant additions to font machinery) until someone notices.
3029 %
3030 \def\sub{\ifmmode \expandafter\sb \else \expandafter\finishsub\fi}
3031 \def\finishsub#1{$\sb{\hbox{\selectfonts\lllsize #1}}$}%
3032 %
3033 \def\sup{\ifmmode \expandafter\ptexsp \else \expandafter\finishsup\fi}
3034 \def\finishsup#1{$\ptexsp{\hbox{\selectfonts\lllsize #1}}$}%
3035
3036 % @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}.
3037 % Ignore unless FMTNAME == tex; then it is like @iftex and @tex,
3038 % except specified as a normal braced arg, so no newlines to worry about.
3039
3040 \def\outfmtnametex{tex}
3041 %
3042 \long\def\inlinefmt#1{\doinlinefmt #1,\finish}
3043 \long\def\doinlinefmt#1,#2,\finish{%
3044   \def\inlinefmtname{#1}%
3045   \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi
3046 }
3047
3048 % @inlinefmtifelse{FMTNAME,THEN-TEXT,ELSE-TEXT} expands THEN-TEXT if
3049 % FMTNAME is tex, else ELSE-TEXT.
3050 \long\def\inlinefmtifelse#1{\doinlinefmtifelse #1,,,\finish}
3051 \long\def\doinlinefmtifelse#1,#2,#3,#4,\finish{%
3052   \def\inlinefmtname{#1}%
3053   \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\else \ignorespaces #3\fi
3054 }
3055 %
3056 % For raw, must switch into @tex before parsing the argument, to avoid
3057 % setting catcodes prematurely.  Doing it this way means that, for
3058 % example, @inlineraw{html, foo{bar} gets a parse error instead of being
3059 % ignored.  But this isn't important because if people want a literal
3060 % *right* brace they would have to use a command anyway, so they may as
3061 % well use a command to get a left brace too.  We could re-use the
3062 % delimiter character idea from \verb, but it seems like overkill.
3063
3064 \long\def\inlineraw{\tex \doinlineraw}
3065 \long\def\doinlineraw#1{\doinlinerawtwo #1,\finish}
3066 \def\doinlinerawtwo#1,#2,\finish{%
3067   \def\inlinerawname{#1}%
3068   \ifx\inlinerawname\outfmtnametex \ignorespaces #2\fi
3069   \endgroup % close group opened by \tex.
3070 }
3071
3072 % @inlineifset{VAR, TEXT} expands TEXT if VAR is @set.
3073 %
3074 \long\def\inlineifset#1{\doinlineifset #1,\finish}
3075 \long\def\doinlineifset#1,#2,\finish{%
3076   \def\inlinevarname{#1}%
3077   \expandafter\ifx\csname SET\inlinevarname\endcsname\relax
3078   \else\ignorespaces#2\fi
3079 }
3080
3081 % @inlineifclear{VAR, TEXT} expands TEXT if VAR is not @set.
3082 %
3083 \long\def\inlineifclear#1{\doinlineifclear #1,\finish}
3084 \long\def\doinlineifclear#1,#2,\finish{%
3085   \def\inlinevarname{#1}%
3086   \expandafter\ifx\csname SET\inlinevarname\endcsname\relax \ignorespaces#2\fi
3087 }
3088
3089
3090 \message{glyphs,}
3091 % and logos.
3092
3093 % @@ prints an @, as does @atchar{}.
3094 \def\@{\char64 }
3095 \let\atchar=\@
3096
3097 % @{ @} @lbracechar{} @rbracechar{} all generate brace characters.
3098 % Unless we're in typewriter, use \ecfont because the CM text fonts do
3099 % not have braces, and we don't want to switch into math.
3100 \def\mylbrace{{\ifmonospace\else\ecfont\fi \char123}}
3101 \def\myrbrace{{\ifmonospace\else\ecfont\fi \char125}}
3102 \let\{=\mylbrace \let\lbracechar=\{
3103 \let\}=\myrbrace \let\rbracechar=\}
3104 \begingroup
3105   % Definitions to produce \{ and \} commands for indices,
3106   % and @{ and @} for the aux/toc files.
3107   \catcode`\{ = \other \catcode`\} = \other
3108   \catcode`\[ = 1 \catcode`\] = 2
3109   \catcode`\! = 0 \catcode`\\ = \other
3110   !gdef!lbracecmd[\{]%
3111   !gdef!rbracecmd[\}]%
3112   !gdef!lbraceatcmd[@{]%
3113   !gdef!rbraceatcmd[@}]%
3114 !endgroup
3115
3116 % @comma{} to avoid , parsing problems.
3117 \let\comma = ,
3118
3119 % Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
3120 % Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H.
3121 \let\, = \ptexc
3122 \let\dotaccent = \ptexdot
3123 \def\ringaccent#1{{\accent23 #1}}
3124 \let\tieaccent = \ptext
3125 \let\ubaraccent = \ptexb
3126 \let\udotaccent = \d
3127
3128 % Other special characters: @questiondown @exclamdown @ordf @ordm
3129 % Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss.
3130 \def\questiondown{?`}
3131 \def\exclamdown{!`}
3132 \def\ordf{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{a}}}
3133 \def\ordm{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{o}}}
3134
3135 % Dotless i and dotless j, used for accents.
3136 \def\imacro{i}
3137 \def\jmacro{j}
3138 \def\dotless#1{%
3139   \def\temp{#1}%
3140   \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi
3141   \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi
3142   \else \errmessage{@dotless can be used only with i or j}%
3143   \fi\fi
3144 }
3145
3146 % The \TeX{} logo, as in plain, but resetting the spacing so that a
3147 % period following counts as ending a sentence.  (Idea found in latex.)
3148 %
3149 \edef\TeX{\TeX \spacefactor=1000 }
3150
3151 % @LaTeX{} logo.  Not quite the same results as the definition in
3152 % latex.ltx, since we use a different font for the raised A; it's most
3153 % convenient for us to use an explicitly smaller font, rather than using
3154 % the \scriptstyle font (since we don't reset \scriptstyle and
3155 % \scriptscriptstyle).
3156 %
3157 \def\LaTeX{%
3158   L\kern-.36em
3159   {\setbox0=\hbox{T}%
3160    \vbox to \ht0{\hbox{%
3161      \ifx\textnominalsize\xwordpt
3162        % for 10pt running text, \lllsize (8pt) is too small for the A in LaTeX.
3163        % Revert to plain's \scriptsize, which is 7pt.
3164        \count255=\the\fam $\fam\count255 \scriptstyle A$%
3165      \else
3166        % For 11pt, we can use our lllsize.
3167        \selectfonts\lllsize A%
3168      \fi
3169      }%
3170      \vss
3171   }}%
3172   \kern-.15em
3173   \TeX
3174 }
3175
3176 % Some math mode symbols.  Define \ensuremath to switch into math mode
3177 % unless we are already there.  Expansion tricks may not be needed here,
3178 % but safer, and can't hurt.
3179 \def\ensuremath{\ifmmode \expandafter\asis \else\expandafter\ensuredmath \fi}
3180 \def\ensuredmath#1{$\relax#1$}
3181 %
3182 \def\bullet{\ensuremath\ptexbullet}
3183 \def\geq{\ensuremath\ge}
3184 \def\leq{\ensuremath\le}
3185 \def\minus{\ensuremath-}
3186
3187 % @dots{} outputs an ellipsis using the current font.
3188 % We do .5em per period so that it has the same spacing in the cm
3189 % typewriter fonts as three actual period characters; on the other hand,
3190 % in other typewriter fonts three periods are wider than 1.5em.  So do
3191 % whichever is larger.
3192 %
3193 \def\dots{%
3194   \leavevmode
3195   \setbox0=\hbox{...}% get width of three periods
3196   \ifdim\wd0 > 1.5em
3197     \dimen0 = \wd0
3198   \else
3199     \dimen0 = 1.5em
3200   \fi
3201   \hbox to \dimen0{%
3202     \hskip 0pt plus.25fil
3203     .\hskip 0pt plus1fil
3204     .\hskip 0pt plus1fil
3205     .\hskip 0pt plus.5fil
3206   }%
3207 }
3208
3209 % @enddots{} is an end-of-sentence ellipsis.
3210 %
3211 \def\enddots{%
3212   \dots
3213   \spacefactor=\endofsentencespacefactor
3214 }
3215
3216 % @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
3217 %
3218 % Since these characters are used in examples, they should be an even number of
3219 % \tt widths. Each \tt character is 1en, so two makes it 1em.
3220 %
3221 \def\point{$\star$}
3222 \def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}}
3223 \def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
3224 \def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}}
3225 \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
3226 \def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}}
3227
3228 % The @error{} command.
3229 % Adapted from the TeXbook's \boxit.
3230 %
3231 \newbox\errorbox
3232 %
3233 {\tentt \global\dimen0 = 3em}% Width of the box.
3234 \dimen2 = .55pt % Thickness of rules
3235 % The text. (`r' is open on the right, `e' somewhat less so on the left.)
3236 \setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt}
3237 %
3238 \setbox\errorbox=\hbox to \dimen0{\hfil
3239    \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
3240    \advance\hsize by -2\dimen2 % Rules.
3241    \vbox{%
3242       \hrule height\dimen2
3243       \hbox{\vrule width\dimen2 \kern3pt          % Space to left of text.
3244          \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
3245          \kern3pt\vrule width\dimen2}% Space to right.
3246       \hrule height\dimen2}
3247     \hfil}
3248 %
3249 \def\error{\leavevmode\lower.7ex\copy\errorbox}
3250
3251 % @pounds{} is a sterling sign, which Knuth put in the CM italic font.
3252 %
3253 \def\pounds{{\it\$}}
3254
3255 % @euro{} comes from a separate font, depending on the current style.
3256 % We use the free feym* fonts from the eurosym package by Henrik
3257 % Theiling, which support regular, slanted, bold and bold slanted (and
3258 % "outlined" (blackboard board, sort of) versions, which we don't need).
3259 % It is available from http://www.ctan.org/tex-archive/fonts/eurosym.
3260 %
3261 % Although only regular is the truly official Euro symbol, we ignore
3262 % that.  The Euro is designed to be slightly taller than the regular
3263 % font height.
3264 %
3265 % feymr - regular
3266 % feymo - slanted
3267 % feybr - bold
3268 % feybo - bold slanted
3269 %
3270 % There is no good (free) typewriter version, to my knowledge.
3271 % A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide.
3272 % Hmm.
3273 %
3274 % Also doesn't work in math.  Do we need to do math with euro symbols?
3275 % Hope not.
3276 %
3277 %
3278 \def\euro{{\eurofont e}}
3279 \def\eurofont{%
3280   % We set the font at each command, rather than predefining it in
3281   % \textfonts and the other font-switching commands, so that
3282   % installations which never need the symbol don't have to have the
3283   % font installed.
3284   %
3285   % There is only one designed size (nominal 10pt), so we always scale
3286   % that to the current nominal size.
3287   %
3288   % By the way, simply using "at 1em" works for cmr10 and the like, but
3289   % does not work for cmbx10 and other extended/shrunken fonts.
3290   %
3291   \def\eurosize{\csname\curfontsize nominalsize\endcsname}%
3292   %
3293   \ifx\curfontstyle\bfstylename
3294     % bold:
3295     \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize
3296   \else
3297     % regular:
3298     \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize
3299   \fi
3300   \thiseurofont
3301 }
3302
3303 % Glyphs from the EC fonts.  We don't use \let for the aliases, because
3304 % sometimes we redefine the original macro, and the alias should reflect
3305 % the redefinition.
3306 %
3307 % Use LaTeX names for the Icelandic letters.
3308 \def\DH{{\ecfont \char"D0}} % Eth
3309 \def\dh{{\ecfont \char"F0}} % eth
3310 \def\TH{{\ecfont \char"DE}} % Thorn
3311 \def\th{{\ecfont \char"FE}} % thorn
3312 %
3313 \def\guillemetleft{{\ecfont \char"13}}
3314 \def\guillemotleft{\guillemetleft}
3315 \def\guillemetright{{\ecfont \char"14}}
3316 \def\guillemotright{\guillemetright}
3317 \def\guilsinglleft{{\ecfont \char"0E}}
3318 \def\guilsinglright{{\ecfont \char"0F}}
3319 \def\quotedblbase{{\ecfont \char"12}}
3320 \def\quotesinglbase{{\ecfont \char"0D}}
3321 %
3322 % This positioning is not perfect (see the ogonek LaTeX package), but
3323 % we have the precomposed glyphs for the most common cases.  We put the
3324 % tests to use those glyphs in the single \ogonek macro so we have fewer
3325 % dummy definitions to worry about for index entries, etc.
3326 %
3327 % ogonek is also used with other letters in Lithuanian (IOU), but using
3328 % the precomposed glyphs for those is not so easy since they aren't in
3329 % the same EC font.
3330 \def\ogonek#1{{%
3331   \def\temp{#1}%
3332   \ifx\temp\macrocharA\Aogonek
3333   \else\ifx\temp\macrochara\aogonek
3334   \else\ifx\temp\macrocharE\Eogonek
3335   \else\ifx\temp\macrochare\eogonek
3336   \else
3337     \ecfont \setbox0=\hbox{#1}%
3338     \ifdim\ht0=1ex\accent"0C #1%
3339     \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}%
3340     \fi
3341   \fi\fi\fi\fi
3342   }%
3343 }
3344 \def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A}
3345 \def\aogonek{{\ecfont \char"A1}}\def\macrochara{a}
3346 \def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E}
3347 \def\eogonek{{\ecfont \char"A6}}\def\macrochare{e}
3348 %
3349 % Use the European Computer Modern fonts (cm-super in outline format)
3350 % for non-CM glyphs.  That is ec* for regular text and tc* for the text
3351 % companion symbols (LaTeX TS1 encoding).  Both are part of the ec
3352 % package and follow the same conventions.
3353
3354 \def\ecfont{\etcfont{e}}
3355 \def\tcfont{\etcfont{t}}
3356 %
3357 \def\etcfont#1{%
3358   % We can't distinguish serif/sans and italic/slanted, but this
3359   % is used for crude hacks anyway (like adding French and German
3360   % quotes to documents typeset with CM, where we lose kerning), so
3361   % hopefully nobody will notice/care.
3362   \edef\ecsize{\csname\curfontsize ecsize\endcsname}%
3363   \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}%
3364   \ifmonospace
3365     % typewriter:
3366     \font\thisecfont = #1ctt\ecsize \space at \nominalsize
3367   \else
3368     \ifx\curfontstyle\bfstylename
3369       % bold:
3370       \font\thisecfont = #1cb\ifusingit{i}{x}\ecsize \space at \nominalsize
3371     \else
3372       % regular:
3373       \font\thisecfont = #1c\ifusingit{ti}{rm}\ecsize \space at \nominalsize
3374     \fi
3375   \fi
3376   \thisecfont
3377 }
3378
3379 % @registeredsymbol - R in a circle.  The font for the R should really
3380 % be smaller yet, but lllsize is the best we can do for now.
3381 % Adapted from the plain.tex definition of \copyright.
3382 %
3383 \def\registeredsymbol{%
3384   $^{{\ooalign{\hfil\raise.07ex\hbox{\selectfonts\lllsize R}%
3385                \hfil\crcr\Orb}}%
3386     }$%
3387 }
3388
3389 % @textdegree - the normal degrees sign.
3390 %
3391 \def\textdegree{$^\circ$}
3392
3393 % Laurent Siebenmann reports \Orb undefined with:
3394 %  Textures 1.7.7 (preloaded format=plain 93.10.14)  (68K)  16 APR 2004 02:38
3395 % so we'll define it if necessary.
3396 %
3397 \ifx\Orb\thisisundefined
3398 \def\Orb{\mathhexbox20D}
3399 \fi
3400
3401 % Quotes.
3402 \chardef\quotedblleft="5C
3403 \chardef\quotedblright=`\"
3404 \chardef\quoteleft=`\`
3405 \chardef\quoteright=`\'
3406
3407
3408 \message{page headings,}
3409
3410 \newskip\titlepagetopglue \titlepagetopglue = 1.5in
3411 \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
3412
3413 % First the title page.  Must do @settitle before @titlepage.
3414 \newif\ifseenauthor
3415 \newif\iffinishedtitlepage
3416
3417 % Do an implicit @contents or @shortcontents after @end titlepage if the
3418 % user says @setcontentsaftertitlepage or @setshortcontentsaftertitlepage.
3419 %
3420 \newif\ifsetcontentsaftertitlepage
3421  \let\setcontentsaftertitlepage = \setcontentsaftertitlepagetrue
3422 \newif\ifsetshortcontentsaftertitlepage
3423  \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue
3424
3425 \parseargdef\shorttitlepage{%
3426   \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}%
3427   \endgroup\page\hbox{}\page}
3428
3429 \envdef\titlepage{%
3430   % Open one extra group, as we want to close it in the middle of \Etitlepage.
3431   \begingroup
3432     \parindent=0pt \textfonts
3433     % Leave some space at the very top of the page.
3434     \vglue\titlepagetopglue
3435     % No rule at page bottom unless we print one at the top with @title.
3436     \finishedtitlepagetrue
3437     %
3438     % Most title ``pages'' are actually two pages long, with space
3439     % at the top of the second.  We don't want the ragged left on the second.
3440     \let\oldpage = \page
3441     \def\page{%
3442       \iffinishedtitlepage\else
3443          \finishtitlepage
3444       \fi
3445       \let\page = \oldpage
3446       \page
3447       \null
3448     }%
3449 }
3450
3451 \def\Etitlepage{%
3452     \iffinishedtitlepage\else
3453         \finishtitlepage
3454     \fi
3455     % It is important to do the page break before ending the group,
3456     % because the headline and footline are only empty inside the group.
3457     % If we use the new definition of \page, we always get a blank page
3458     % after the title page, which we certainly don't want.
3459     \oldpage
3460   \endgroup
3461   %
3462   % Need this before the \...aftertitlepage checks so that if they are
3463   % in effect the toc pages will come out with page numbers.
3464   \HEADINGSon
3465   %
3466   % If they want short, they certainly want long too.
3467   \ifsetshortcontentsaftertitlepage
3468     \shortcontents
3469     \contents
3470     \global\let\shortcontents = \relax
3471     \global\let\contents = \relax
3472   \fi
3473   %
3474   \ifsetcontentsaftertitlepage
3475     \contents
3476     \global\let\contents = \relax
3477     \global\let\shortcontents = \relax
3478   \fi
3479 }
3480
3481 \def\finishtitlepage{%
3482   \vskip4pt \hrule height 2pt width \hsize
3483   \vskip\titlepagebottomglue
3484   \finishedtitlepagetrue
3485 }
3486
3487 % Settings used for typesetting titles: no hyphenation, no indentation,
3488 % don't worry much about spacing, ragged right.  This should be used
3489 % inside a \vbox, and fonts need to be set appropriately first.  Because
3490 % it is always used for titles, nothing else, we call \rmisbold.  \par
3491 % should be specified before the end of the \vbox, since a vbox is a group.
3492
3493 \def\raggedtitlesettings{%
3494   \rmisbold
3495   \hyphenpenalty=10000
3496   \parindent=0pt
3497   \tolerance=5000
3498   \ptexraggedright
3499 }
3500
3501 % Macros to be used within @titlepage:
3502
3503 \let\subtitlerm=\tenrm
3504 \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}
3505
3506 \parseargdef\title{%
3507   \checkenv\titlepage
3508   \vbox{\titlefonts \raggedtitlesettings #1\par}%
3509   % print a rule at the page bottom also.
3510   \finishedtitlepagefalse
3511   \vskip4pt \hrule height 4pt width \hsize \vskip4pt
3512 }
3513
3514 \parseargdef\subtitle{%
3515   \checkenv\titlepage
3516   {\subtitlefont \rightline{#1}}%
3517 }
3518
3519 % @author should come last, but may come many times.
3520 % It can also be used inside @quotation.
3521 %
3522 \parseargdef\author{%
3523   \def\temp{\quotation}%
3524   \ifx\thisenv\temp
3525     \def\quotationauthor{#1}% printed in \Equotation.
3526   \else
3527     \checkenv\titlepage
3528     \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi
3529     {\secfonts\rmisbold \leftline{#1}}%
3530   \fi
3531 }
3532
3533
3534 % Set up page headings and footings.
3535
3536 \let\thispage=\folio
3537
3538 \newtoks\evenheadline    % headline on even pages
3539 \newtoks\oddheadline     % headline on odd pages
3540 \newtoks\evenfootline    % footline on even pages
3541 \newtoks\oddfootline     % footline on odd pages
3542
3543 % Now make \makeheadline and \makefootline in Plain TeX use those variables
3544 \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
3545                             \else \the\evenheadline \fi}}
3546 \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
3547                             \else \the\evenfootline \fi}\HEADINGShook}
3548 \let\HEADINGShook=\relax
3549
3550 % Commands to set those variables.
3551 % For example, this is what  @headings on  does
3552 % @evenheading @thistitle|@thispage|@thischapter
3553 % @oddheading @thischapter|@thispage|@thistitle
3554 % @evenfooting @thisfile||
3555 % @oddfooting ||@thisfile
3556
3557
3558 \def\evenheading{\parsearg\evenheadingxxx}
3559 \def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish}
3560 \def\evenheadingyyy #1\|#2\|#3\|#4\finish{%
3561 \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3562
3563 \def\oddheading{\parsearg\oddheadingxxx}
3564 \def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish}
3565 \def\oddheadingyyy #1\|#2\|#3\|#4\finish{%
3566 \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3567
3568 \parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
3569
3570 \def\evenfooting{\parsearg\evenfootingxxx}
3571 \def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish}
3572 \def\evenfootingyyy #1\|#2\|#3\|#4\finish{%
3573 \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3574
3575 \def\oddfooting{\parsearg\oddfootingxxx}
3576 \def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish}
3577 \def\oddfootingyyy #1\|#2\|#3\|#4\finish{%
3578   \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}%
3579   %
3580   % Leave some space for the footline.  Hopefully ok to assume
3581   % @evenfooting will not be used by itself.
3582   \global\advance\pageheight by -12pt
3583   \global\advance\vsize by -12pt
3584 }
3585
3586 \parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}}
3587
3588 % @evenheadingmarks top     \thischapter <- chapter at the top of a page
3589 % @evenheadingmarks bottom  \thischapter <- chapter at the bottom of a page
3590 %
3591 % The same set of arguments for:
3592 %
3593 % @oddheadingmarks
3594 % @evenfootingmarks
3595 % @oddfootingmarks
3596 % @everyheadingmarks
3597 % @everyfootingmarks
3598
3599 % These define \getoddheadingmarks, \getevenheadingmarks,
3600 % \getoddfootingmarks, and \getevenfootingmarks, each to one of
3601 % \gettopheadingmarks, \getbottomheadingmarks.
3602 %
3603 \def\evenheadingmarks{\headingmarks{even}{heading}}
3604 \def\oddheadingmarks{\headingmarks{odd}{heading}}
3605 \def\evenfootingmarks{\headingmarks{even}{footing}}
3606 \def\oddfootingmarks{\headingmarks{odd}{footing}}
3607 \def\everyheadingmarks#1 {\headingmarks{even}{heading}{#1}
3608                           \headingmarks{odd}{heading}{#1} }
3609 \def\everyfootingmarks#1 {\headingmarks{even}{footing}{#1}
3610                           \headingmarks{odd}{footing}{#1} }
3611 % #1 = even/odd, #2 = heading/footing, #3 = top/bottom.
3612 \def\headingmarks#1#2#3 {%
3613   \expandafter\let\expandafter\temp \csname get#3headingmarks\endcsname
3614   \global\expandafter\let\csname get#1#2marks\endcsname \temp
3615 }
3616
3617 \everyheadingmarks bottom
3618 \everyfootingmarks bottom
3619
3620 % @headings double      turns headings on for double-sided printing.
3621 % @headings single      turns headings on for single-sided printing.
3622 % @headings off         turns them off.
3623 % @headings on          same as @headings double, retained for compatibility.
3624 % @headings after       turns on double-sided headings after this page.
3625 % @headings doubleafter turns on double-sided headings after this page.
3626 % @headings singleafter turns on single-sided headings after this page.
3627 % By default, they are off at the start of a document,
3628 % and turned `on' after @end titlepage.
3629
3630 \def\headings #1 {\csname HEADINGS#1\endcsname}
3631
3632 \def\headingsoff{% non-global headings elimination
3633   \evenheadline={\hfil}\evenfootline={\hfil}%
3634    \oddheadline={\hfil}\oddfootline={\hfil}%
3635 }
3636
3637 \def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting
3638 \HEADINGSoff  % it's the default
3639
3640 % When we turn headings on, set the page number to 1.
3641 % For double-sided printing, put current file name in lower left corner,
3642 % chapter name on inside top of right hand pages, document
3643 % title on inside top of left hand pages, and page numbers on outside top
3644 % edge of all pages.
3645 \def\HEADINGSdouble{%
3646 \global\pageno=1
3647 \global\evenfootline={\hfil}
3648 \global\oddfootline={\hfil}
3649 \global\evenheadline={\line{\folio\hfil\thistitle}}
3650 \global\oddheadline={\line{\thischapterheading\hfil\folio}}
3651 \global\let\contentsalignmacro = \chapoddpage
3652 }
3653 \let\contentsalignmacro = \chappager
3654
3655 % For single-sided printing, chapter title goes across top left of page,
3656 % page number on top right.
3657 \def\HEADINGSsingle{%
3658 \global\pageno=1
3659 \global\evenfootline={\hfil}
3660 \global\oddfootline={\hfil}
3661 \global\evenheadline={\line{\thischapterheading\hfil\folio}}
3662 \global\oddheadline={\line{\thischapterheading\hfil\folio}}
3663 \global\let\contentsalignmacro = \chappager
3664 }
3665 \def\HEADINGSon{\HEADINGSdouble}
3666
3667 \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
3668 \let\HEADINGSdoubleafter=\HEADINGSafter
3669 \def\HEADINGSdoublex{%
3670 \global\evenfootline={\hfil}
3671 \global\oddfootline={\hfil}
3672 \global\evenheadline={\line{\folio\hfil\thistitle}}
3673 \global\oddheadline={\line{\thischapterheading\hfil\folio}}
3674 \global\let\contentsalignmacro = \chapoddpage
3675 }
3676
3677 \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
3678 \def\HEADINGSsinglex{%
3679 \global\evenfootline={\hfil}
3680 \global\oddfootline={\hfil}
3681 \global\evenheadline={\line{\thischapterheading\hfil\folio}}
3682 \global\oddheadline={\line{\thischapterheading\hfil\folio}}
3683 \global\let\contentsalignmacro = \chappager
3684 }
3685
3686 % Subroutines used in generating headings
3687 % This produces Day Month Year style of output.
3688 % Only define if not already defined, in case a txi-??.tex file has set
3689 % up a different format (e.g., txi-cs.tex does this).
3690 \ifx\today\thisisundefined
3691 \def\today{%
3692   \number\day\space
3693   \ifcase\month
3694   \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr
3695   \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug
3696   \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec
3697   \fi
3698   \space\number\year}
3699 \fi
3700
3701 % @settitle line...  specifies the title of the document, for headings.
3702 % It generates no output of its own.
3703 \def\thistitle{\putwordNoTitle}
3704 \def\settitle{\parsearg{\gdef\thistitle}}
3705
3706
3707 \message{tables,}
3708 % Tables -- @table, @ftable, @vtable, @item(x).
3709
3710 % default indentation of table text
3711 \newdimen\tableindent \tableindent=.8in
3712 % default indentation of @itemize and @enumerate text
3713 \newdimen\itemindent  \itemindent=.3in
3714 % margin between end of table item and start of table text.
3715 \newdimen\itemmargin  \itemmargin=.1in
3716
3717 % used internally for \itemindent minus \itemmargin
3718 \newdimen\itemmax
3719
3720 % Note @table, @ftable, and @vtable define @item, @itemx, etc., with
3721 % these defs.
3722 % They also define \itemindex
3723 % to index the item name in whatever manner is desired (perhaps none).
3724
3725 \newif\ifitemxneedsnegativevskip
3726
3727 \def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
3728
3729 \def\internalBitem{\smallbreak \parsearg\itemzzz}
3730 \def\internalBitemx{\itemxpar \parsearg\itemzzz}
3731
3732 \def\itemzzz #1{\begingroup %
3733   \advance\hsize by -\rightskip
3734   \advance\hsize by -\tableindent
3735   \setbox0=\hbox{\itemindicate{#1}}%
3736   \itemindex{#1}%
3737   \nobreak % This prevents a break before @itemx.
3738   %
3739   % If the item text does not fit in the space we have, put it on a line
3740   % by itself, and do not allow a page break either before or after that
3741   % line.  We do not start a paragraph here because then if the next
3742   % command is, e.g., @kindex, the whatsit would get put into the
3743   % horizontal list on a line by itself, resulting in extra blank space.
3744   \ifdim \wd0>\itemmax
3745     %
3746     % Make this a paragraph so we get the \parskip glue and wrapping,
3747     % but leave it ragged-right.
3748     \begingroup
3749       \advance\leftskip by-\tableindent
3750       \advance\hsize by\tableindent
3751       \advance\rightskip by0pt plus1fil\relax
3752       \leavevmode\unhbox0\par
3753     \endgroup
3754     %
3755     % We're going to be starting a paragraph, but we don't want the
3756     % \parskip glue -- logically it's part of the @item we just started.
3757     \nobreak \vskip-\parskip
3758     %
3759     % Stop a page break at the \parskip glue coming up.  However, if
3760     % what follows is an environment such as @example, there will be no
3761     % \parskip glue; then the negative vskip we just inserted would
3762     % cause the example and the item to crash together.  So we use this
3763     % bizarre value of 10001 as a signal to \aboveenvbreak to insert
3764     % \parskip glue after all.  Section titles are handled this way also.
3765     %
3766     \penalty 10001
3767     \endgroup
3768     \itemxneedsnegativevskipfalse
3769   \else
3770     % The item text fits into the space.  Start a paragraph, so that the
3771     % following text (if any) will end up on the same line.
3772     \noindent
3773     % Do this with kerns and \unhbox so that if there is a footnote in
3774     % the item text, it can migrate to the main vertical list and
3775     % eventually be printed.
3776     \nobreak\kern-\tableindent
3777     \dimen0 = \itemmax  \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0
3778     \unhbox0
3779     \nobreak\kern\dimen0
3780     \endgroup
3781     \itemxneedsnegativevskiptrue
3782   \fi
3783 }
3784
3785 \def\item{\errmessage{@item while not in a list environment}}
3786 \def\itemx{\errmessage{@itemx while not in a list environment}}
3787
3788 % @table, @ftable, @vtable.
3789 \envdef\table{%
3790   \let\itemindex\gobble
3791   \tablecheck{table}%
3792 }
3793 \envdef\ftable{%
3794   \def\itemindex ##1{\doind {fn}{\code{##1}}}%
3795   \tablecheck{ftable}%
3796 }
3797 \envdef\vtable{%
3798   \def\itemindex ##1{\doind {vr}{\code{##1}}}%
3799   \tablecheck{vtable}%
3800 }
3801 \def\tablecheck#1{%
3802   \ifnum \the\catcode`\^^M=\active
3803     \endgroup
3804     \errmessage{This command won't work in this context; perhaps the problem is
3805       that we are \inenvironment\thisenv}%
3806     \def\next{\doignore{#1}}%
3807   \else
3808     \let\next\tablex
3809   \fi
3810   \next
3811 }
3812 \def\tablex#1{%
3813   \def\itemindicate{#1}%
3814   \parsearg\tabley
3815 }
3816 \def\tabley#1{%
3817   {%
3818     \makevalueexpandable
3819     \edef\temp{\noexpand\tablez #1\space\space\space}%
3820     \expandafter
3821   }\temp \endtablez
3822 }
3823 \def\tablez #1 #2 #3 #4\endtablez{%
3824   \aboveenvbreak
3825   \ifnum 0#1>0 \advance \leftskip by #1\mil \fi
3826   \ifnum 0#2>0 \tableindent=#2\mil \fi
3827   \ifnum 0#3>0 \advance \rightskip by #3\mil \fi
3828   \itemmax=\tableindent
3829   \advance \itemmax by -\itemmargin
3830   \advance \leftskip by \tableindent
3831   \exdentamount=\tableindent
3832   \parindent = 0pt
3833   \parskip = \smallskipamount
3834   \ifdim \parskip=0pt \parskip=2pt \fi
3835   \let\item = \internalBitem
3836   \let\itemx = \internalBitemx
3837 }
3838 \def\Etable{\endgraf\afterenvbreak}
3839 \let\Eftable\Etable
3840 \let\Evtable\Etable
3841 \let\Eitemize\Etable
3842 \let\Eenumerate\Etable
3843
3844 % This is the counter used by @enumerate, which is really @itemize
3845
3846 \newcount \itemno
3847
3848 \envdef\itemize{\parsearg\doitemize}
3849
3850 \def\doitemize#1{%
3851   \aboveenvbreak
3852   \itemmax=\itemindent
3853   \advance\itemmax by -\itemmargin
3854   \advance\leftskip by \itemindent
3855   \exdentamount=\itemindent
3856   \parindent=0pt
3857   \parskip=\smallskipamount
3858   \ifdim\parskip=0pt \parskip=2pt \fi
3859   %
3860   % Try typesetting the item mark so that if the document erroneously says
3861   % something like @itemize @samp (intending @table), there's an error
3862   % right away at the @itemize.  It's not the best error message in the
3863   % world, but it's better than leaving it to the @item.  This means if
3864   % the user wants an empty mark, they have to say @w{} not just @w.
3865   \def\itemcontents{#1}%
3866   \setbox0 = \hbox{\itemcontents}%
3867   %
3868   % @itemize with no arg is equivalent to @itemize @bullet.
3869   \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi
3870   %
3871   \let\item=\itemizeitem
3872 }
3873
3874 % Definition of @item while inside @itemize and @enumerate.
3875 %
3876 \def\itemizeitem{%
3877   \advance\itemno by 1  % for enumerations
3878   {\let\par=\endgraf \smallbreak}% reasonable place to break
3879   {%
3880    % If the document has an @itemize directly after a section title, a
3881    % \nobreak will be last on the list, and \sectionheading will have
3882    % done a \vskip-\parskip.  In that case, we don't want to zero
3883    % parskip, or the item text will crash with the heading.  On the
3884    % other hand, when there is normal text preceding the item (as there
3885    % usually is), we do want to zero parskip, or there would be too much
3886    % space.  In that case, we won't have a \nobreak before.  At least
3887    % that's the theory.
3888    \ifnum\lastpenalty<10000 \parskip=0in \fi
3889    \noindent
3890    \hbox to 0pt{\hss \itemcontents \kern\itemmargin}%
3891    %
3892    \ifinner\else
3893      \vadjust{\penalty 1200}% not good to break after first line of item.
3894    \fi
3895    % We can be in inner vertical mode in a footnote, although an
3896    % @itemize looks awful there.
3897   }%
3898   \flushcr
3899 }
3900
3901 % \splitoff TOKENS\endmark defines \first to be the first token in
3902 % TOKENS, and \rest to be the remainder.
3903 %
3904 \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
3905
3906 % Allow an optional argument of an uppercase letter, lowercase letter,
3907 % or number, to specify the first label in the enumerated list.  No
3908 % argument is the same as `1'.
3909 %
3910 \envparseargdef\enumerate{\enumeratey #1  \endenumeratey}
3911 \def\enumeratey #1 #2\endenumeratey{%
3912   % If we were given no argument, pretend we were given `1'.
3913   \def\thearg{#1}%
3914   \ifx\thearg\empty \def\thearg{1}\fi
3915   %
3916   % Detect if the argument is a single token.  If so, it might be a
3917   % letter.  Otherwise, the only valid thing it can be is a number.
3918   % (We will always have one token, because of the test we just made.
3919   % This is a good thing, since \splitoff doesn't work given nothing at
3920   % all -- the first parameter is undelimited.)
3921   \expandafter\splitoff\thearg\endmark
3922   \ifx\rest\empty
3923     % Only one token in the argument.  It could still be anything.
3924     % A ``lowercase letter'' is one whose \lccode is nonzero.
3925     % An ``uppercase letter'' is one whose \lccode is both nonzero, and
3926     %   not equal to itself.
3927     % Otherwise, we assume it's a number.
3928     %
3929     % We need the \relax at the end of the \ifnum lines to stop TeX from
3930     % continuing to look for a <number>.
3931     %
3932     \ifnum\lccode\expandafter`\thearg=0\relax
3933       \numericenumerate % a number (we hope)
3934     \else
3935       % It's a letter.
3936       \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
3937         \lowercaseenumerate % lowercase letter
3938       \else
3939         \uppercaseenumerate % uppercase letter
3940       \fi
3941     \fi
3942   \else
3943     % Multiple tokens in the argument.  We hope it's a number.
3944     \numericenumerate
3945   \fi
3946 }
3947
3948 % An @enumerate whose labels are integers.  The starting integer is
3949 % given in \thearg.
3950 %
3951 \def\numericenumerate{%
3952   \itemno = \thearg
3953   \startenumeration{\the\itemno}%
3954 }
3955
3956 % The starting (lowercase) letter is in \thearg.
3957 \def\lowercaseenumerate{%
3958   \itemno = \expandafter`\thearg
3959   \startenumeration{%
3960     % Be sure we're not beyond the end of the alphabet.
3961     \ifnum\itemno=0
3962       \errmessage{No more lowercase letters in @enumerate; get a bigger
3963                   alphabet}%
3964     \fi
3965     \char\lccode\itemno
3966   }%
3967 }
3968
3969 % The starting (uppercase) letter is in \thearg.
3970 \def\uppercaseenumerate{%
3971   \itemno = \expandafter`\thearg
3972   \startenumeration{%
3973     % Be sure we're not beyond the end of the alphabet.
3974     \ifnum\itemno=0
3975       \errmessage{No more uppercase letters in @enumerate; get a bigger
3976                   alphabet}
3977     \fi
3978     \char\uccode\itemno
3979   }%
3980 }
3981
3982 % Call \doitemize, adding a period to the first argument and supplying the
3983 % common last two arguments.  Also subtract one from the initial value in
3984 % \itemno, since @item increments \itemno.
3985 %
3986 \def\startenumeration#1{%
3987   \advance\itemno by -1
3988   \doitemize{#1.}\flushcr
3989 }
3990
3991 % @alphaenumerate and @capsenumerate are abbreviations for giving an arg
3992 % to @enumerate.
3993 %
3994 \def\alphaenumerate{\enumerate{a}}
3995 \def\capsenumerate{\enumerate{A}}
3996 \def\Ealphaenumerate{\Eenumerate}
3997 \def\Ecapsenumerate{\Eenumerate}
3998
3999
4000 % @multitable macros
4001 % Amy Hendrickson, 8/18/94, 3/6/96
4002 %
4003 % @multitable ... @end multitable will make as many columns as desired.
4004 % Contents of each column will wrap at width given in preamble.  Width
4005 % can be specified either with sample text given in a template line,
4006 % or in percent of \hsize, the current width of text on page.
4007
4008 % Table can continue over pages but will only break between lines.
4009
4010 % To make preamble:
4011 %
4012 % Either define widths of columns in terms of percent of \hsize:
4013 %   @multitable @columnfractions .25 .3 .45
4014 %   @item ...
4015 %
4016 %   Numbers following @columnfractions are the percent of the total
4017 %   current hsize to be used for each column. You may use as many
4018 %   columns as desired.
4019
4020
4021 % Or use a template:
4022 %   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
4023 %   @item ...
4024 %   using the widest term desired in each column.
4025
4026 % Each new table line starts with @item, each subsequent new column
4027 % starts with @tab. Empty columns may be produced by supplying @tab's
4028 % with nothing between them for as many times as empty columns are needed,
4029 % ie, @tab@tab@tab will produce two empty columns.
4030
4031 % @item, @tab do not need to be on their own lines, but it will not hurt
4032 % if they are.
4033
4034 % Sample multitable:
4035
4036 %   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
4037 %   @item first col stuff @tab second col stuff @tab third col
4038 %   @item
4039 %   first col stuff
4040 %   @tab
4041 %   second col stuff
4042 %   @tab
4043 %   third col
4044 %   @item first col stuff @tab second col stuff
4045 %   @tab Many paragraphs of text may be used in any column.
4046 %
4047 %         They will wrap at the width determined by the template.
4048 %   @item@tab@tab This will be in third column.
4049 %   @end multitable
4050
4051 % Default dimensions may be reset by user.
4052 % @multitableparskip is vertical space between paragraphs in table.
4053 % @multitableparindent is paragraph indent in table.
4054 % @multitablecolmargin is horizontal space to be left between columns.
4055 % @multitablelinespace is space to leave between table items, baseline
4056 %                                                            to baseline.
4057 %   0pt means it depends on current normal line spacing.
4058 %
4059 \newskip\multitableparskip
4060 \newskip\multitableparindent
4061 \newdimen\multitablecolspace
4062 \newskip\multitablelinespace
4063 \multitableparskip=0pt
4064 \multitableparindent=6pt
4065 \multitablecolspace=12pt
4066 \multitablelinespace=0pt
4067
4068 % Macros used to set up halign preamble:
4069 %
4070 \let\endsetuptable\relax
4071 \def\xendsetuptable{\endsetuptable}
4072 \let\columnfractions\relax
4073 \def\xcolumnfractions{\columnfractions}
4074 \newif\ifsetpercent
4075
4076 % #1 is the @columnfraction, usually a decimal number like .5, but might
4077 % be just 1.  We just use it, whatever it is.
4078 %
4079 \def\pickupwholefraction#1 {%
4080   \global\advance\colcount by 1
4081   \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}%
4082   \setuptable
4083 }
4084
4085 \newcount\colcount
4086 \def\setuptable#1{%
4087   \def\firstarg{#1}%
4088   \ifx\firstarg\xendsetuptable
4089     \let\go = \relax
4090   \else
4091     \ifx\firstarg\xcolumnfractions
4092       \global\setpercenttrue
4093     \else
4094       \ifsetpercent
4095          \let\go\pickupwholefraction
4096       \else
4097          \global\advance\colcount by 1
4098          \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a
4099                    % separator; typically that is always in the input, anyway.
4100          \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
4101       \fi
4102     \fi
4103     \ifx\go\pickupwholefraction
4104       % Put the argument back for the \pickupwholefraction call, so
4105       % we'll always have a period there to be parsed.
4106       \def\go{\pickupwholefraction#1}%
4107     \else
4108       \let\go = \setuptable
4109     \fi%
4110   \fi
4111   \go
4112 }
4113
4114 % multitable-only commands.
4115
4116 % @headitem starts a heading row, which we typeset in bold.  Assignments
4117 % have to be global since we are inside the implicit group of an
4118 % alignment entry.  \everycr below resets \everytab so we don't have to
4119 % undo it ourselves.
4120 \def\headitemfont{\b}% for people to use in the template row; not changeable
4121 \def\headitem{%
4122   \checkenv\multitable
4123   \crcr
4124   \gdef\headitemcrhook{\nobreak}% attempt to avoid page break after headings
4125   \global\everytab={\bf}% can't use \headitemfont since the parsing differs
4126   \the\everytab % for the first item
4127 }%
4128 %
4129 % default for tables with no headings.
4130 \let\headitemcrhook=\relax
4131 %
4132 % A \tab used to include \hskip1sp.  But then the space in a template
4133 % line is not enough.  That is bad.  So let's go back to just `&' until
4134 % we again encounter the problem the 1sp was intended to solve.
4135 %                                       --karl, nathan@acm.org, 20apr99.
4136 \def\tab{\checkenv\multitable &\the\everytab}%
4137
4138 % @multitable ... @end multitable definitions:
4139 %
4140 \newtoks\everytab  % insert after every tab.
4141 %
4142 \envdef\multitable{%
4143   \vskip\parskip
4144   \startsavinginserts
4145   %
4146   % @item within a multitable starts a normal row.
4147   % We use \def instead of \let so that if one of the multitable entries
4148   % contains an @itemize, we don't choke on the \item (seen as \crcr aka
4149   % \endtemplate) expanding \doitemize.
4150   \def\item{\crcr}%
4151   %
4152   \tolerance=9500
4153   \hbadness=9500
4154   \setmultitablespacing
4155   \parskip=\multitableparskip
4156   \parindent=\multitableparindent
4157   \overfullrule=0pt
4158   \global\colcount=0
4159   %
4160   \everycr = {%
4161     \noalign{%
4162       \global\everytab={}% Reset from possible headitem.
4163       \global\colcount=0 % Reset the column counter.
4164       %
4165       % Check for saved footnotes, etc.:
4166       \checkinserts
4167       %
4168       % Perhaps a \nobreak, then reset:
4169       \headitemcrhook
4170       \global\let\headitemcrhook=\relax
4171     }%
4172   }%
4173   %
4174   \parsearg\domultitable
4175 }
4176 \def\domultitable#1{%
4177   % To parse everything between @multitable and @item:
4178   \setuptable#1 \endsetuptable
4179   %
4180   % This preamble sets up a generic column definition, which will
4181   % be used as many times as user calls for columns.
4182   % \vtop will set a single line and will also let text wrap and
4183   % continue for many paragraphs if desired.
4184   \halign\bgroup &%
4185     \global\advance\colcount by 1
4186     \multistrut
4187     \vtop{%
4188       % Use the current \colcount to find the correct column width:
4189       \hsize=\expandafter\csname col\the\colcount\endcsname
4190       %
4191       % In order to keep entries from bumping into each other
4192       % we will add a \leftskip of \multitablecolspace to all columns after
4193       % the first one.
4194       %
4195       % If a template has been used, we will add \multitablecolspace
4196       % to the width of each template entry.
4197       %
4198       % If the user has set preamble in terms of percent of \hsize we will
4199       % use that dimension as the width of the column, and the \leftskip
4200       % will keep entries from bumping into each other.  Table will start at
4201       % left margin and final column will justify at right margin.
4202       %
4203       % Make sure we don't inherit \rightskip from the outer environment.
4204       \rightskip=0pt
4205       \ifnum\colcount=1
4206         % The first column will be indented with the surrounding text.
4207         \advance\hsize by\leftskip
4208       \else
4209         \ifsetpercent \else
4210           % If user has not set preamble in terms of percent of \hsize
4211           % we will advance \hsize by \multitablecolspace.
4212           \advance\hsize by \multitablecolspace
4213         \fi
4214        % In either case we will make \leftskip=\multitablecolspace:
4215       \leftskip=\multitablecolspace
4216       \fi
4217       % Ignoring space at the beginning and end avoids an occasional spurious
4218       % blank line, when TeX decides to break the line at the space before the
4219       % box from the multistrut, so the strut ends up on a line by itself.
4220       % For example:
4221       % @multitable @columnfractions .11 .89
4222       % @item @code{#}
4223       % @tab Legal holiday which is valid in major parts of the whole country.
4224       % Is automatically provided with highlighting sequences respectively
4225       % marking characters.
4226       \noindent\ignorespaces##\unskip\multistrut
4227     }\cr
4228 }
4229 \def\Emultitable{%
4230   \crcr
4231   \egroup % end the \halign
4232   \global\setpercentfalse
4233 }
4234
4235 \def\setmultitablespacing{%
4236   \def\multistrut{\strut}% just use the standard line spacing
4237   %
4238   % Compute \multitablelinespace (if not defined by user) for use in
4239   % \multitableparskip calculation.  We used define \multistrut based on
4240   % this, but (ironically) that caused the spacing to be off.
4241   % See bug-texinfo report from Werner Lemberg, 31 Oct 2004 12:52:20 +0100.
4242 \ifdim\multitablelinespace=0pt
4243 \setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip
4244 \global\advance\multitablelinespace by-\ht0
4245 \fi
4246 % Test to see if parskip is larger than space between lines of
4247 % table. If not, do nothing.
4248 %        If so, set to same dimension as multitablelinespace.
4249 \ifdim\multitableparskip>\multitablelinespace
4250 \global\multitableparskip=\multitablelinespace
4251 \global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
4252                                       % than skip between lines in the table.
4253 \fi%
4254 \ifdim\multitableparskip=0pt
4255 \global\multitableparskip=\multitablelinespace
4256 \global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
4257                                       % than skip between lines in the table.
4258 \fi}
4259
4260
4261 \message{conditionals,}
4262
4263 % @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext,
4264 % @ifnotxml always succeed.  They currently do nothing; we don't
4265 % attempt to check whether the conditionals are properly nested.  But we
4266 % have to remember that they are conditionals, so that @end doesn't
4267 % attempt to close an environment group.
4268 %
4269 \def\makecond#1{%
4270   \expandafter\let\csname #1\endcsname = \relax
4271   \expandafter\let\csname iscond.#1\endcsname = 1
4272 }
4273 \makecond{iftex}
4274 \makecond{ifnotdocbook}
4275 \makecond{ifnothtml}
4276 \makecond{ifnotinfo}
4277 \makecond{ifnotplaintext}
4278 \makecond{ifnotxml}
4279
4280 % Ignore @ignore, @ifhtml, @ifinfo, and the like.
4281 %
4282 \def\direntry{\doignore{direntry}}
4283 \def\documentdescription{\doignore{documentdescription}}
4284 \def\docbook{\doignore{docbook}}
4285 \def\html{\doignore{html}}
4286 \def\ifdocbook{\doignore{ifdocbook}}
4287 \def\ifhtml{\doignore{ifhtml}}
4288 \def\ifinfo{\doignore{ifinfo}}
4289 \def\ifnottex{\doignore{ifnottex}}
4290 \def\ifplaintext{\doignore{ifplaintext}}
4291 \def\ifxml{\doignore{ifxml}}
4292 \def\ignore{\doignore{ignore}}
4293 \def\menu{\doignore{menu}}
4294 \def\xml{\doignore{xml}}
4295
4296 % Ignore text until a line `@end #1', keeping track of nested conditionals.
4297 %
4298 % A count to remember the depth of nesting.
4299 \newcount\doignorecount
4300
4301 \def\doignore#1{\begingroup
4302   % Scan in ``verbatim'' mode:
4303   \obeylines
4304   \catcode`\@ = \other
4305   \catcode`\{ = \other
4306   \catcode`\} = \other
4307   %
4308   % Make sure that spaces turn into tokens that match what \doignoretext wants.
4309   \spaceisspace
4310   %
4311   % Count number of #1's that we've seen.
4312   \doignorecount = 0
4313   %
4314   % Swallow text until we reach the matching `@end #1'.
4315   \dodoignore{#1}%
4316 }
4317
4318 { \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source.
4319   \obeylines %
4320   %
4321   \gdef\dodoignore#1{%
4322     % #1 contains the command name as a string, e.g., `ifinfo'.
4323     %
4324     % Define a command to find the next `@end #1'.
4325     \long\def\doignoretext##1^^M@end #1{%
4326       \doignoretextyyy##1^^M@#1\_STOP_}%
4327     %
4328     % And this command to find another #1 command, at the beginning of a
4329     % line.  (Otherwise, we would consider a line `@c @ifset', for
4330     % example, to count as an @ifset for nesting.)
4331     \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}%
4332     %
4333     % And now expand that command.
4334     \doignoretext ^^M%
4335   }%
4336 }
4337
4338 \def\doignoreyyy#1{%
4339   \def\temp{#1}%
4340   \ifx\temp\empty                       % Nothing found.
4341     \let\next\doignoretextzzz
4342   \else                                 % Found a nested condition, ...
4343     \advance\doignorecount by 1
4344     \let\next\doignoretextyyy           % ..., look for another.
4345     % If we're here, #1 ends with ^^M\ifinfo (for example).
4346   \fi
4347   \next #1% the token \_STOP_ is present just after this macro.
4348 }
4349
4350 % We have to swallow the remaining "\_STOP_".
4351 %
4352 \def\doignoretextzzz#1{%
4353   \ifnum\doignorecount = 0      % We have just found the outermost @end.
4354     \let\next\enddoignore
4355   \else                         % Still inside a nested condition.
4356     \advance\doignorecount by -1
4357     \let\next\doignoretext      % Look for the next @end.
4358   \fi
4359   \next
4360 }
4361
4362 % Finish off ignored text.
4363 { \obeylines%
4364   % Ignore anything after the last `@end #1'; this matters in verbatim
4365   % environments, where otherwise the newline after an ignored conditional
4366   % would result in a blank line in the output.
4367   \gdef\enddoignore#1^^M{\endgroup\ignorespaces}%
4368 }
4369
4370
4371 % @set VAR sets the variable VAR to an empty value.
4372 % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
4373 %
4374 % Since we want to separate VAR from REST-OF-LINE (which might be
4375 % empty), we can't just use \parsearg; we have to insert a space of our
4376 % own to delimit the rest of the line, and then take it out again if we
4377 % didn't need it.
4378 % We rely on the fact that \parsearg sets \catcode`\ =10.
4379 %
4380 \parseargdef\set{\setyyy#1 \endsetyyy}
4381 \def\setyyy#1 #2\endsetyyy{%
4382   {%
4383     \makevalueexpandable
4384     \def\temp{#2}%
4385     \edef\next{\gdef\makecsname{SET#1}}%
4386     \ifx\temp\empty
4387       \next{}%
4388     \else
4389       \setzzz#2\endsetzzz
4390     \fi
4391   }%
4392 }
4393 % Remove the trailing space \setxxx inserted.
4394 \def\setzzz#1 \endsetzzz{\next{#1}}
4395
4396 % @clear VAR clears (i.e., unsets) the variable VAR.
4397 %
4398 \parseargdef\clear{%
4399   {%
4400     \makevalueexpandable
4401     \global\expandafter\let\csname SET#1\endcsname=\relax
4402   }%
4403 }
4404
4405 % @value{foo} gets the text saved in variable foo.
4406 \def\value{\begingroup\makevalueexpandable\valuexxx}
4407 \def\valuexxx#1{\expandablevalue{#1}\endgroup}
4408 {
4409   \catcode`\-=\active \catcode`\_=\active
4410   %
4411   \gdef\makevalueexpandable{%
4412     \let\value = \expandablevalue
4413     % We don't want these characters active, ...
4414     \catcode`\-=\other \catcode`\_=\other
4415     % ..., but we might end up with active ones in the argument if
4416     % we're called from @code, as @code{@value{foo-bar_}}, though.
4417     % So \let them to their normal equivalents.
4418     \let-\normaldash \let_\normalunderscore
4419   }
4420 }
4421
4422 % We have this subroutine so that we can handle at least some @value's
4423 % properly in indexes (we call \makevalueexpandable in \indexdummies).
4424 % The command has to be fully expandable (if the variable is set), since
4425 % the result winds up in the index file.  This means that if the
4426 % variable's value contains other Texinfo commands, it's almost certain
4427 % it will fail (although perhaps we could fix that with sufficient work
4428 % to do a one-level expansion on the result, instead of complete).
4429
4430 % Unfortunately, this has the consequence that when _ is in the *value*
4431 % of an @set, it does not print properly in the roman fonts (get the cmr
4432 % dot accent at position 126 instead).  No fix comes to mind, and it's
4433 % been this way since 2003 or earlier, so just ignore it.
4434
4435 \def\expandablevalue#1{%
4436   \expandafter\ifx\csname SET#1\endcsname\relax
4437     {[No value for ``#1'']}%
4438     \message{Variable `#1', used in @value, is not set.}%
4439   \else
4440     \csname SET#1\endcsname
4441   \fi
4442 }
4443
4444 % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
4445 % with @set.
4446
4447 % To get the special treatment we need for `@end ifset,' we call
4448 % \makecond and then redefine.
4449 %
4450 \makecond{ifset}
4451 \def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}}
4452 \def\doifset#1#2{%
4453   {%
4454     \makevalueexpandable
4455     \let\next=\empty
4456     \expandafter\ifx\csname SET#2\endcsname\relax
4457       #1% If not set, redefine \next.
4458     \fi
4459     \expandafter
4460   }\next
4461 }
4462 \def\ifsetfail{\doignore{ifset}}
4463
4464 % @ifclear VAR ... @end executes the `...' iff VAR has never been
4465 % defined with @set, or has been undefined with @clear.
4466 %
4467 % The `\else' inside the `\doifset' parameter is a trick to reuse the
4468 % above code: if the variable is not set, do nothing, if it is set,
4469 % then redefine \next to \ifclearfail.
4470 %
4471 \makecond{ifclear}
4472 \def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}}
4473 \def\ifclearfail{\doignore{ifclear}}
4474
4475 % @ifcommandisdefined CMD ... @end executes the `...' if CMD (written
4476 % without the @) is in fact defined.  We can only feasibly check at the
4477 % TeX level, so something like `mathcode' is going to considered
4478 % defined even though it is not a Texinfo command.
4479
4480 \makecond{ifcommanddefined}
4481 \def\ifcommanddefined{\parsearg{\doifcmddefined{\let\next=\ifcmddefinedfail}}}
4482 %
4483 \def\doifcmddefined#1#2{{%
4484     \makevalueexpandable
4485     \let\next=\empty
4486     \expandafter\ifx\csname #2\endcsname\relax
4487       #1% If not defined, \let\next as above.
4488     \fi
4489     \expandafter
4490   }\next
4491 }
4492 \def\ifcmddefinedfail{\doignore{ifcommanddefined}}
4493
4494 % @ifcommandnotdefined CMD ... handled similar to @ifclear above.
4495 \makecond{ifcommandnotdefined}
4496 \def\ifcommandnotdefined{%
4497   \parsearg{\doifcmddefined{\else \let\next=\ifcmdnotdefinedfail}}}
4498 \def\ifcmdnotdefinedfail{\doignore{ifcommandnotdefined}}
4499
4500 % Set the `txicommandconditionals' variable, so documents have a way to
4501 % test if the @ifcommand...defined conditionals are available.
4502 \set txicommandconditionals
4503
4504 % @dircategory CATEGORY  -- specify a category of the dir file
4505 % which this file should belong to.  Ignore this in TeX.
4506 \let\dircategory=\comment
4507
4508 % @defininfoenclose.
4509 \let\definfoenclose=\comment
4510
4511
4512 \message{indexing,}
4513 % Index generation facilities
4514
4515 % Define \newwrite to be identical to plain tex's \newwrite
4516 % except not \outer, so it can be used within macros and \if's.
4517 \edef\newwrite{\makecsname{ptexnewwrite}}
4518
4519 % \newindex {foo} defines an index named IX.
4520 % It automatically defines \IXindex such that
4521 % \IXindex ...rest of line... puts an entry in the index IX.
4522 % It also defines \IXindfile to be the number of the output channel for
4523 % the file that accumulates this index.  The file's extension is IX.
4524 % The name of an index should be no more than 2 characters long
4525 % for the sake of vms.
4526 %
4527 \def\newindex#1{%
4528   \expandafter\chardef\csname#1indfile\endcsname=0
4529   \expandafter\xdef\csname#1index\endcsname{%     % Define @#1index
4530     \noexpand\doindex{#1}}
4531 }
4532
4533 % @defindex foo  ==  \newindex{foo}
4534 %
4535 \def\defindex{\parsearg\newindex}
4536
4537 % Define @defcodeindex, like @defindex except put all entries in @code.
4538 %
4539 \def\defcodeindex{\parsearg\newcodeindex}
4540 %
4541 \def\newcodeindex#1{%
4542   \expandafter\chardef\csname#1indfile\endcsname=0
4543   \expandafter\xdef\csname#1index\endcsname{%
4544     \noexpand\docodeindex{#1}}%
4545 }
4546
4547 % The default indices:
4548 \newindex{cp}%      concepts,
4549 \newcodeindex{fn}%  functions,
4550 \newcodeindex{vr}%  variables,
4551 \newcodeindex{tp}%  types,
4552 \newcodeindex{ky}%  keys
4553 \newcodeindex{pg}%  and programs.
4554
4555
4556 % @synindex foo bar    makes index foo feed into index bar.
4557 % Do this instead of @defindex foo if you don't want it as a separate index.
4558 %
4559 % @syncodeindex foo bar   similar, but put all entries made for index foo
4560 % inside @code.
4561 %
4562 \def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}}
4563 \def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}}
4564
4565 % #1 is \doindex or \docodeindex, #2 the index getting redefined (foo),
4566 % #3 the target index (bar).
4567 \def\dosynindex#1#2#3{%
4568   % Only do \closeout if we haven't already done it, else we'll end up
4569   % closing the target index.
4570   \expandafter \ifx\csname donesynindex#2\endcsname \relax
4571     % The \closeout helps reduce unnecessary open files; the limit on the
4572     % Acorn RISC OS is a mere 16 files.
4573     \expandafter\closeout\csname#2indfile\endcsname
4574     \expandafter\let\csname donesynindex#2\endcsname = 1
4575   \fi
4576   % redefine \fooindfile:
4577   \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname
4578   \expandafter\let\csname#2indfile\endcsname=\temp
4579   % redefine \fooindex:
4580   \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}%
4581 }
4582
4583 % Define \doindex, the driver for all index macros.
4584 % Argument #1 is generated by the calling \fooindex macro,
4585 % and it the two-letter name of the index.
4586
4587 \def\doindex#1{\edef\indexname{#1}\parsearg\doindexxxx}
4588 \def\doindexxxx #1{\doind{\indexname}{#1}}
4589
4590 % like the previous two, but they put @code around the argument.
4591 \def\docodeindex#1{\edef\indexname{#1}\parsearg\docodeindexxxx}
4592 \def\docodeindexxxx #1{\doind{\indexname}{\code{#1}}}
4593
4594 % Used when writing an index entry out to an index file, to prevent
4595 % expansion of Texinfo commands that can appear in an index entry.
4596 %
4597 \def\indexdummies{%
4598   \escapechar = `\\     % use backslash in output files.
4599   \def\@{@}% change to @@ when we switch to @ as escape char in index files.
4600   \def\ {\realbackslash\space }%
4601   %
4602   % Need these unexpandable (because we define \tt as a dummy)
4603   % definitions when @{ or @} appear in index entry text.  Also, more
4604   % complicated, when \tex is in effect and \{ is a \delimiter again.
4605   % We can't use \lbracecmd and \rbracecmd because texindex assumes
4606   % braces and backslashes are used only as delimiters.  Perhaps we
4607   % should use @lbracechar and @rbracechar?
4608   \def\{{{\tt\char123}}%
4609   \def\}{{\tt\char125}}%
4610   %
4611   % Do the redefinitions.
4612   \commondummies
4613 }
4614
4615 % For the aux and toc files, @ is the escape character.  So we want to
4616 % redefine everything using @ as the escape character (instead of
4617 % \realbackslash, still used for index files).  When everything uses @,
4618 % this will be simpler.
4619 %
4620 \def\atdummies{%
4621   \def\@{@@}%
4622   \def\ {@ }%
4623   \let\{ = \lbraceatcmd
4624   \let\} = \rbraceatcmd
4625   %
4626   % Do the redefinitions.
4627   \commondummies
4628   \otherbackslash
4629 }
4630
4631 % Called from \indexdummies and \atdummies.
4632 %
4633 \def\commondummies{%
4634   % \definedummyword defines \#1 as \string\#1\space, thus effectively
4635   % preventing its expansion.  This is used only for control words,
4636   % not control letters, because the \space would be incorrect for
4637   % control characters, but is needed to separate the control word
4638   % from whatever follows.
4639   %
4640   % For control letters, we have \definedummyletter, which omits the
4641   % space.
4642   %
4643   % These can be used both for control words that take an argument and
4644   % those that do not.  If it is followed by {arg} in the input, then
4645   % that will dutifully get written to the index (or wherever).
4646   %
4647   \def\definedummyword  ##1{\def##1{\string##1\space}}%
4648   \def\definedummyletter##1{\def##1{\string##1}}%
4649   \let\definedummyaccent\definedummyletter
4650   %
4651   \commondummiesnofonts
4652   %
4653   \definedummyletter\_%
4654   \definedummyletter\-%
4655   %
4656   % Non-English letters.
4657   \definedummyword\AA
4658   \definedummyword\AE
4659   \definedummyword\DH
4660   \definedummyword\L
4661   \definedummyword\O
4662   \definedummyword\OE
4663   \definedummyword\TH
4664   \definedummyword\aa
4665   \definedummyword\ae
4666   \definedummyword\dh
4667   \definedummyword\exclamdown
4668   \definedummyword\l
4669   \definedummyword\o
4670   \definedummyword\oe
4671   \definedummyword\ordf
4672   \definedummyword\ordm
4673   \definedummyword\questiondown
4674   \definedummyword\ss
4675   \definedummyword\th
4676   %
4677   % Although these internal commands shouldn't show up, sometimes they do.
4678   \definedummyword\bf
4679   \definedummyword\gtr
4680   \definedummyword\hat
4681   \definedummyword\less
4682   \definedummyword\sf
4683   \definedummyword\sl
4684   \definedummyword\tclose
4685   \definedummyword\tt
4686   %
4687   \definedummyword\LaTeX
4688   \definedummyword\TeX
4689   %
4690   % Assorted special characters.
4691   \definedummyword\arrow
4692   \definedummyword\bullet
4693   \definedummyword\comma
4694   \definedummyword\copyright
4695   \definedummyword\registeredsymbol
4696   \definedummyword\dots
4697   \definedummyword\enddots
4698   \definedummyword\entrybreak
4699   \definedummyword\equiv
4700   \definedummyword\error
4701   \definedummyword\euro
4702   \definedummyword\expansion
4703   \definedummyword\geq
4704   \definedummyword\guillemetleft
4705   \definedummyword\guillemetright
4706   \definedummyword\guilsinglleft
4707   \definedummyword\guilsinglright
4708   \definedummyword\lbracechar
4709   \definedummyword\leq
4710   \definedummyword\mathopsup
4711   \definedummyword\minus
4712   \definedummyword\ogonek
4713   \definedummyword\pounds
4714   \definedummyword\point
4715   \definedummyword\print
4716   \definedummyword\quotedblbase
4717   \definedummyword\quotedblleft
4718   \definedummyword\quotedblright
4719   \definedummyword\quoteleft
4720   \definedummyword\quoteright
4721   \definedummyword\quotesinglbase
4722   \definedummyword\rbracechar
4723   \definedummyword\result
4724   \definedummyword\sub
4725   \definedummyword\sup
4726   \definedummyword\textdegree
4727   %
4728   % We want to disable all macros so that they are not expanded by \write.
4729   \macrolist
4730   %
4731   \normalturnoffactive
4732   %
4733   % Handle some cases of @value -- where it does not contain any
4734   % (non-fully-expandable) commands.
4735   \makevalueexpandable
4736 }
4737
4738 % \commondummiesnofonts: common to \commondummies and \indexnofonts.
4739 % Define \definedumyletter, \definedummyaccent and \definedummyword before
4740 % using.
4741 %
4742 \def\commondummiesnofonts{%
4743   % Control letters and accents.
4744   \definedummyletter\!%
4745   \definedummyaccent\"%
4746   \definedummyaccent\'%
4747   \definedummyletter\*%
4748   \definedummyaccent\,%
4749   \definedummyletter\.%
4750   \definedummyletter\/%
4751   \definedummyletter\:%
4752   \definedummyaccent\=%
4753   \definedummyletter\?%
4754   \definedummyaccent\^%
4755   \definedummyaccent\`%
4756   \definedummyaccent\~%
4757   \definedummyword\u
4758   \definedummyword\v
4759   \definedummyword\H
4760   \definedummyword\dotaccent
4761   \definedummyword\ogonek
4762   \definedummyword\ringaccent
4763   \definedummyword\tieaccent
4764   \definedummyword\ubaraccent
4765   \definedummyword\udotaccent
4766   \definedummyword\dotless
4767   %
4768   % Texinfo font commands.
4769   \definedummyword\b
4770   \definedummyword\i
4771   \definedummyword\r
4772   \definedummyword\sansserif
4773   \definedummyword\sc
4774   \definedummyword\slanted
4775   \definedummyword\t
4776   %
4777   % Commands that take arguments.
4778   \definedummyword\abbr
4779   \definedummyword\acronym
4780   \definedummyword\anchor
4781   \definedummyword\cite
4782   \definedummyword\code
4783   \definedummyword\command
4784   \definedummyword\dfn
4785   \definedummyword\dmn
4786   \definedummyword\email
4787   \definedummyword\emph
4788   \definedummyword\env
4789   \definedummyword\file
4790   \definedummyword\image
4791   \definedummyword\indicateurl
4792   \definedummyword\inforef
4793   \definedummyword\kbd
4794   \definedummyword\key
4795   \definedummyword\math
4796   \definedummyword\option
4797   \definedummyword\pxref
4798   \definedummyword\ref
4799   \definedummyword\samp
4800   \definedummyword\strong
4801   \definedummyword\tie
4802   \definedummyword\U
4803   \definedummyword\uref
4804   \definedummyword\url
4805   \definedummyword\var
4806   \definedummyword\verb
4807   \definedummyword\w
4808   \definedummyword\xref
4809 }
4810
4811 % For testing: output @{ and @} in index sort strings as \{ and \}.
4812 \newif\ifusebracesinindexes
4813
4814 \let\indexlbrace\relax
4815 \let\indexrbrace\relax
4816
4817 {\catcode`\@=0
4818 \catcode`\\=13
4819   @gdef@backslashdisappear{@def\{}}
4820 }
4821
4822 {
4823 \catcode`\<=13
4824 \catcode`\-=13
4825 \catcode`\`=13
4826   \gdef\indexnonalnumdisappear{%
4827     \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax\else
4828       % @set txiindexlquoteignore makes us ignore left quotes in the sort term.
4829       % (Introduced for FSFS 2nd ed.)
4830       \let`=\empty
4831     \fi
4832     %
4833     \expandafter\ifx\csname SETtxiindexbackslashignore\endcsname\relax\else
4834       \backslashdisappear
4835     \fi
4836     %
4837     \expandafter\ifx\csname SETtxiindexhyphenignore\endcsname\relax\else
4838       \def-{}%
4839     \fi
4840     \expandafter\ifx\csname SETtxiindexlessthanignore\endcsname\relax\else
4841       \def<{}%
4842     \fi
4843     \expandafter\ifx\csname SETtxiindexatsignignore\endcsname\relax\else
4844       \def\@{}%
4845     \fi
4846   }
4847
4848   \gdef\indexnonalnumreappear{%
4849     \useindexbackslash
4850     \let-\normaldash
4851     \let<\normalless
4852     \def\@{@}%
4853   }
4854 }
4855
4856
4857 % \indexnofonts is used when outputting the strings to sort the index
4858 % by, and when constructing control sequence names.  It eliminates all
4859 % control sequences and just writes whatever the best ASCII sort string
4860 % would be for a given command (usually its argument).
4861 %
4862 \def\indexnofonts{%
4863   % Accent commands should become @asis.
4864   \def\definedummyaccent##1{\let##1\asis}%
4865   % We can just ignore other control letters.
4866   \def\definedummyletter##1{\let##1\empty}%
4867   % All control words become @asis by default; overrides below.
4868   \let\definedummyword\definedummyaccent
4869   \commondummiesnofonts
4870   %
4871   % Don't no-op \tt, since it isn't a user-level command
4872   % and is used in the definitions of the active chars like <, >, |, etc.
4873   % Likewise with the other plain tex font commands.
4874   %\let\tt=\asis
4875   %
4876   \def\ { }%
4877   \def\@{@}%
4878   \def\_{\normalunderscore}%
4879   \def\-{}% @- shouldn't affect sorting
4880   %
4881   \uccode`\1=`\{ \uppercase{\def\{{1}}%
4882   \uccode`\1=`\} \uppercase{\def\}{1}}%
4883   \let\lbracechar\{%
4884   \let\rbracechar\}%
4885   %
4886   % Non-English letters.
4887   \def\AA{AA}%
4888   \def\AE{AE}%
4889   \def\DH{DZZ}%
4890   \def\L{L}%
4891   \def\OE{OE}%
4892   \def\O{O}%
4893   \def\TH{TH}%
4894   \def\aa{aa}%
4895   \def\ae{ae}%
4896   \def\dh{dzz}%
4897   \def\exclamdown{!}%
4898   \def\l{l}%
4899   \def\oe{oe}%
4900   \def\ordf{a}%
4901   \def\ordm{o}%
4902   \def\o{o}%
4903   \def\questiondown{?}%
4904   \def\ss{ss}%
4905   \def\th{th}%
4906   %
4907   \def\LaTeX{LaTeX}%
4908   \def\TeX{TeX}%
4909   %
4910   % Assorted special characters.
4911   % (The following {} will end up in the sort string, but that's ok.)
4912   \def\arrow{->}%
4913   \def\bullet{bullet}%
4914   \def\comma{,}%
4915   \def\copyright{copyright}%
4916   \def\dots{...}%
4917   \def\enddots{...}%
4918   \def\equiv{==}%
4919   \def\error{error}%
4920   \def\euro{euro}%
4921   \def\expansion{==>}%
4922   \def\geq{>=}%
4923   \def\guillemetleft{<<}%
4924   \def\guillemetright{>>}%
4925   \def\guilsinglleft{<}%
4926   \def\guilsinglright{>}%
4927   \def\leq{<=}%
4928   \def\minus{-}%
4929   \def\point{.}%
4930   \def\pounds{pounds}%
4931   \def\print{-|}%
4932   \def\quotedblbase{"}%
4933   \def\quotedblleft{"}%
4934   \def\quotedblright{"}%
4935   \def\quoteleft{`}%
4936   \def\quoteright{'}%
4937   \def\quotesinglbase{,}%
4938   \def\registeredsymbol{R}%
4939   \def\result{=>}%
4940   \def\textdegree{o}%
4941   %
4942   % We need to get rid of all macros, leaving only the arguments (if present).
4943   % Of course this is not nearly correct, but it is the best we can do for now.
4944   % makeinfo does not expand macros in the argument to @deffn, which ends up
4945   % writing an index entry, and texindex isn't prepared for an index sort entry
4946   % that starts with \.
4947   %
4948   % Since macro invocations are followed by braces, we can just redefine them
4949   % to take a single TeX argument.  The case of a macro invocation that
4950   % goes to end-of-line is not handled.
4951   %
4952   \macrolist
4953 }
4954
4955
4956 \let\SETmarginindex=\relax % put index entries in margin (undocumented)?
4957
4958 % Most index entries go through here, but \dosubind is the general case.
4959 % #1 is the index name, #2 is the entry text.
4960 \def\doind#1#2{\dosubind{#1}{#2}{}}
4961
4962 % There is also \dosubind {index}{topic}{subtopic}
4963 % which makes an entry in a two-level index such as the operation index.
4964 % TODO: Two-level index?  Operation index?
4965
4966 % Workhorse for all indexes.
4967 % #1 is name of index, #2 is stuff to put there, #3 is subentry --
4968 % empty if called from \doind, as we usually are (the main exception
4969 % is with most defuns, which call us directly).
4970 %
4971 \def\dosubind#1#2#3{%
4972   \iflinks
4973   {%
4974     \requireopenindexfile{#1}%
4975     % Store the main index entry text (including the third arg).
4976     \toks0 = {#2}%
4977     % If third arg is present, precede it with a space.
4978     \def\thirdarg{#3}%
4979     \ifx\thirdarg\empty \else
4980       \toks0 = \expandafter{\the\toks0 \space #3}%
4981     \fi
4982     %
4983     \edef\writeto{\csname#1indfile\endcsname}%
4984     %
4985     \safewhatsit\dosubindwrite
4986   }%
4987   \fi
4988 }
4989
4990 % Check if an index file has been opened, and if not, open it.
4991 \def\requireopenindexfile#1{%
4992 \ifnum\csname #1indfile\endcsname=0
4993   \expandafter\newwrite \csname#1indfile\endcsname
4994   \edef\suffix{#1}%
4995   % A .fls suffix would conflict with the file extension for the output
4996   % of -recorder, so use .f1s instead.
4997   \ifx\suffix\indexisfl\def\suffix{f1}\fi
4998   % Open the file
4999   \immediate\openout\csname#1indfile\endcsname \jobname.\suffix
5000   % Using \immediate here prevents an object entering into the current box,
5001   % which could confound checks such as those in \safewhatsit for preceding
5002   % skips.
5003 \fi}
5004 \def\indexisfl{fl}
5005
5006 % Output \ as {\indexbackslash}, because \ is an escape character in
5007 % the index files.
5008 \let\indexbackslash=\relax
5009 {\catcode`\@=0 \catcode`\\=\active
5010   @gdef@useindexbackslash{@def\{{@indexbackslash}}}
5011 }
5012
5013 % Definition for writing index entry text.
5014 \def\sortas#1{\ignorespaces}%
5015
5016 % Definition for writing index entry sort key.  Should occur at the at
5017 % the beginning of the index entry, like
5018 %     @cindex @sortas{september} \september
5019 % The \ignorespaces takes care of following space, but there's no way
5020 % to remove space before it.
5021 {
5022 \catcode`\-=13
5023 \gdef\indexwritesortas{%
5024   \begingroup
5025   \indexnonalnumreappear
5026   \indexwritesortasxxx}
5027 \gdef\indexwritesortasxxx#1{%
5028   \xdef\indexsortkey{#1}\endgroup}
5029 }
5030
5031
5032 % Write the entry in \toks0 to the index file.
5033 %
5034 \def\dosubindwrite{%
5035   % Put the index entry in the margin if desired.
5036   \ifx\SETmarginindex\relax\else
5037     \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}%
5038   \fi
5039   %
5040   % Remember, we are within a group.
5041   \indexdummies % Must do this here, since \bf, etc expand at this stage
5042   \useindexbackslash % \indexbackslash isn't defined now so it will be output 
5043                      % as is; and it will print as backslash.
5044   % The braces around \indexbrace are recognized by texindex.
5045   %
5046   % Get the string to sort by, by processing the index entry with all
5047   % font commands turned off.
5048   {\indexnofonts
5049    \def\lbracechar{{\indexlbrace}}%
5050    \def\rbracechar{{\indexrbrace}}%
5051    \let\{=\lbracechar
5052    \let\}=\rbracechar
5053    \indexnonalnumdisappear
5054    \xdef\indexsortkey{}%
5055    \let\sortas=\indexwritesortas
5056    \edef\temp{\the\toks0}%
5057    \setbox\dummybox = \hbox{\temp}% Make sure to execute any \sortas
5058    \ifx\indexsortkey\empty
5059      \xdef\indexsortkey{\temp}%
5060      \ifx\indexsortkey\empty\xdef\indexsortkey{ }\fi
5061    \fi
5062   }%
5063   %
5064   % Set up the complete index entry, with both the sort key and
5065   % the original text, including any font commands.  We write
5066   % three arguments to \entry to the .?? file (four in the
5067   % subentry case), texindex reduces to two when writing the .??s
5068   % sorted result.
5069   \edef\temp{%
5070     \write\writeto{%
5071       \string\entry{\indexsortkey}{\noexpand\folio}{\the\toks0}}%
5072   }%
5073   \temp
5074 }
5075 \newbox\dummybox % used above
5076
5077 % Take care of unwanted page breaks/skips around a whatsit:
5078 %
5079 % If a skip is the last thing on the list now, preserve it
5080 % by backing up by \lastskip, doing the \write, then inserting
5081 % the skip again.  Otherwise, the whatsit generated by the
5082 % \write or \pdfdest will make \lastskip zero.  The result is that
5083 % sequences like this:
5084 % @end defun
5085 % @tindex whatever
5086 % @defun ...
5087 % will have extra space inserted, because the \medbreak in the
5088 % start of the @defun won't see the skip inserted by the @end of
5089 % the previous defun.
5090 %
5091 % But don't do any of this if we're not in vertical mode.  We
5092 % don't want to do a \vskip and prematurely end a paragraph.
5093 %
5094 % Avoid page breaks due to these extra skips, too.
5095 %
5096 % But wait, there is a catch there:
5097 % We'll have to check whether \lastskip is zero skip.  \ifdim is not
5098 % sufficient for this purpose, as it ignores stretch and shrink parts
5099 % of the skip.  The only way seems to be to check the textual
5100 % representation of the skip.
5101 %
5102 % The following is almost like \def\zeroskipmacro{0.0pt} except that
5103 % the ``p'' and ``t'' characters have catcode \other, not 11 (letter).
5104 %
5105 \edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname}
5106 %
5107 \newskip\whatsitskip
5108 \newcount\whatsitpenalty
5109 %
5110 % ..., ready, GO:
5111 %
5112 \def\safewhatsit#1{\ifhmode
5113   #1%
5114  \else
5115   % \lastskip and \lastpenalty cannot both be nonzero simultaneously.
5116   \whatsitskip = \lastskip
5117   \edef\lastskipmacro{\the\lastskip}%
5118   \whatsitpenalty = \lastpenalty
5119   %
5120   % If \lastskip is nonzero, that means the last item was a
5121   % skip.  And since a skip is discardable, that means this
5122   % -\whatsitskip glue we're inserting is preceded by a
5123   % non-discardable item, therefore it is not a potential
5124   % breakpoint, therefore no \nobreak needed.
5125   \ifx\lastskipmacro\zeroskipmacro
5126   \else
5127     \vskip-\whatsitskip
5128   \fi
5129   %
5130   #1%
5131   %
5132   \ifx\lastskipmacro\zeroskipmacro
5133     % If \lastskip was zero, perhaps the last item was a penalty, and
5134     % perhaps it was >=10000, e.g., a \nobreak.  In that case, we want
5135     % to re-insert the same penalty (values >10000 are used for various
5136     % signals); since we just inserted a non-discardable item, any
5137     % following glue (such as a \parskip) would be a breakpoint.  For example:
5138     %   @deffn deffn-whatever
5139     %   @vindex index-whatever
5140     %   Description.
5141     % would allow a break between the index-whatever whatsit
5142     % and the "Description." paragraph.
5143     \ifnum\whatsitpenalty>9999 \penalty\whatsitpenalty \fi
5144   \else
5145     % On the other hand, if we had a nonzero \lastskip,
5146     % this make-up glue would be preceded by a non-discardable item
5147     % (the whatsit from the \write), so we must insert a \nobreak.
5148     \nobreak\vskip\whatsitskip
5149   \fi
5150 \fi}
5151
5152 % The index entry written in the file actually looks like
5153 %  \entry {sortstring}{page}{topic}
5154 % or
5155 %  \entry {sortstring}{page}{topic}{subtopic}
5156 % The texindex program reads in these files and writes files
5157 % containing these kinds of lines:
5158 %  \initial {c}
5159 %     before the first topic whose initial is c
5160 %  \entry {topic}{pagelist}
5161 %     for a topic that is used without subtopics
5162 %  \primary {topic}
5163 %     for the beginning of a topic that is used with subtopics
5164 %  \secondary {subtopic}{pagelist}
5165 %     for each subtopic.
5166
5167 % Define the user-accessible indexing commands
5168 % @findex, @vindex, @kindex, @cindex.
5169
5170 \def\findex {\fnindex}
5171 \def\kindex {\kyindex}
5172 \def\cindex {\cpindex}
5173 \def\vindex {\vrindex}
5174 \def\tindex {\tpindex}
5175 \def\pindex {\pgindex}
5176
5177 \def\cindexsub {\begingroup\obeylines\cindexsub}
5178 {\obeylines %
5179 \gdef\cindexsub "#1" #2^^M{\endgroup %
5180 \dosubind{cp}{#2}{#1}}}
5181
5182 % Define the macros used in formatting output of the sorted index material.
5183
5184 % @printindex causes a particular index (the ??s file) to get printed.
5185 % It does not print any chapter heading (usually an @unnumbered).
5186 %
5187 \parseargdef\printindex{\begingroup
5188   \dobreak \chapheadingskip{10000}%
5189   %
5190   \smallfonts \rm
5191   \tolerance = 9500
5192   \plainfrenchspacing
5193   \everypar = {}% don't want the \kern\-parindent from indentation suppression.
5194   %
5195   % See if the index file exists and is nonempty.
5196   % Change catcode of @ here so that if the index file contains
5197   % \initial {@}
5198   % as its first line, TeX doesn't complain about mismatched braces
5199   % (because it thinks @} is a control sequence).
5200   \catcode`\@ = 11
5201   % See comment in \requireopenindexfile.
5202   \def\indexname{#1}\ifx\indexname\indexisfl\def\indexname{f1}\fi
5203   \openin 1 \jobname.\indexname s
5204   \ifeof 1
5205     % \enddoublecolumns gets confused if there is no text in the index,
5206     % and it loses the chapter title and the aux file entries for the
5207     % index.  The easiest way to prevent this problem is to make sure
5208     % there is some text.
5209     \putwordIndexNonexistent
5210   \else
5211     \catcode`\\ = 0
5212     \escapechar = `\\
5213     %
5214     % If the index file exists but is empty, then \openin leaves \ifeof
5215     % false.  We have to make TeX try to read something from the file, so
5216     % it can discover if there is anything in it.
5217     \read 1 to \thisline
5218     \ifeof 1
5219       \putwordIndexIsEmpty
5220     \else
5221       % Index files are almost Texinfo source, but we use \ as the escape
5222       % character.  It would be better to use @, but that's too big a change
5223       % to make right now.
5224       \def\indexbackslash{\ttbackslash}%
5225       \let\indexlbrace\{   % Likewise, set these sequences for braces
5226       \let\indexrbrace\}   % used in the sort key.
5227       \begindoublecolumns
5228       \let\entryorphanpenalty=\indexorphanpenalty
5229       %
5230       % Read input from the index file line by line.
5231       \loopdo
5232         \ifeof1
5233           \let\firsttoken\relax
5234         \else
5235           \read 1 to \nextline
5236           \edef\act{\gdef\noexpand\firsttoken{\getfirsttoken\nextline}}%
5237           \act
5238         \fi
5239         \thisline
5240         %
5241         \ifeof1\else
5242         \let\thisline\nextline
5243       \repeat
5244       %%
5245       \enddoublecolumns
5246     \fi
5247   \fi
5248   \closein 1
5249 \endgroup}
5250
5251 \def\getfirsttoken#1{\expandafter\getfirsttokenx#1\endfirsttoken}
5252 \long\def\getfirsttokenx#1#2\endfirsttoken{\noexpand#1}
5253
5254 \def\loopdo#1\repeat{\def\body{#1}\loopdoxxx}
5255 \def\loopdoxxx{\let\next=\relax\body\let\next=\loopdoxxx\fi\next}
5256
5257 % These macros are used by the sorted index file itself.
5258 % Change them to control the appearance of the index.
5259
5260 {\catcode`\/=13 \catcode`\-=13 \catcode`\^=13 \catcode`\~=13 \catcode`\_=13
5261 \catcode`\|=13 \catcode`\<=13 \catcode`\>=13 \catcode`\+=13 \catcode`\"=13
5262 \catcode`\$=3
5263 \gdef\initialglyphs{%
5264   % Some changes for non-alphabetic characters.  Using the glyphs from the
5265   % math fonts looks more consistent than the typewriter font used elsewhere
5266   % for these characters.
5267   \def\indexbackslash{\math{\backslash}}%
5268   \let\\=\indexbackslash
5269   %
5270   % Can't get bold backslash so don't use bold forward slash
5271   \catcode`\/=13
5272   \def/{{\secrmnotbold \normalslash}}%
5273   \def-{{\normaldash\normaldash}}% en dash `--'
5274   \def^{{\chapbf \normalcaret}}%
5275   \def~{{\chapbf \normaltilde}}%
5276   \def\_{%
5277      \leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }%
5278   \def|{$\vert$}%
5279   \def<{$\less$}%
5280   \def>{$\gtr$}%
5281   \def+{$\normalplus$}%
5282 }}
5283
5284 \def\initial{%
5285   \bgroup
5286   \initialglyphs
5287   \initialx
5288 }
5289
5290 \def\initialx#1{%
5291   % Remove any glue we may have, we'll be inserting our own.
5292   \removelastskip
5293   %
5294   % We like breaks before the index initials, so insert a bonus.
5295   % The glue before the bonus allows a little bit of space at the
5296   % bottom of a column to reduce an increase in inter-line spacing.
5297   \nobreak
5298   \vskip 0pt plus 5\baselineskip
5299   \penalty -300 
5300   \vskip 0pt plus -5\baselineskip
5301   %
5302   % Typeset the initial.  Making this add up to a whole number of
5303   % baselineskips increases the chance of the dots lining up from column
5304   % to column.  It still won't often be perfect, because of the stretch
5305   % we need before each entry, but it's better.
5306   %
5307   % No shrink because it confuses \balancecolumns.
5308   \vskip 1.67\baselineskip plus 1\baselineskip
5309   \leftline{\secfonts \kern-0.05em \secbf #1}%
5310   % \secfonts is inside the argument of \leftline so that the change of
5311   % \baselineskip will not affect any glue inserted before the vbox that
5312   % \leftline creates.
5313   % Do our best not to break after the initial.
5314   \nobreak
5315   \vskip .33\baselineskip plus .1\baselineskip
5316   \egroup % \initialglyphs
5317 }
5318
5319 \newdimen\entryrightmargin
5320 \entryrightmargin=0pt
5321
5322 % \entry typesets a paragraph consisting of the text (#1), dot leaders, and
5323 % then page number (#2) flushed to the right margin.  It is used for index
5324 % and table of contents entries.  The paragraph is indented by \leftskip.
5325 %
5326 \def\entry{%
5327   \begingroup
5328     %
5329     % Start a new paragraph if necessary, so our assignments below can't
5330     % affect previous text.
5331     \par
5332     %
5333     % No extra space above this paragraph.
5334     \parskip = 0in
5335     %
5336     % When reading the text of entry, convert explicit line breaks
5337     % from @* into spaces.  The user might give these in long section
5338     % titles, for instance.
5339     \def\*{\unskip\space\ignorespaces}%
5340     \def\entrybreak{\hfil\break}% An undocumented command
5341     %
5342     % A bit of stretch before each entry for the benefit of balancing
5343     % columns.
5344     \vskip 0pt plus0.5pt
5345     %
5346     % Swallow the left brace of the text (first parameter):
5347     \afterassignment\doentry
5348     \let\temp =
5349 }
5350 \def\entrybreak{\unskip\space\ignorespaces}%
5351 \def\doentry{%
5352     % Save the text of the entry
5353     \global\setbox\boxA=\hbox\bgroup
5354     \bgroup % Instead of the swallowed brace.
5355       \noindent
5356       \aftergroup\finishentry
5357       % And now comes the text of the entry.
5358       % Not absorbing as a macro argument reduces the chance of problems
5359       % with catcodes occurring.
5360 }
5361 {\catcode`\@=11
5362 \gdef\finishentry#1{%
5363     \egroup % end box A
5364     \dimen@ = \wd\boxA % Length of text of entry
5365     \global\setbox\boxA=\hbox\bgroup\unhbox\boxA
5366     % #1 is the page number.
5367     %
5368     % Get the width of the page numbers, and only use
5369     % leaders if they are present.
5370     \global\setbox\boxB = \hbox{#1}%
5371     \ifdim\wd\boxB = 0pt
5372       \null\nobreak\hfill\ %
5373     \else
5374       %
5375       \null\nobreak\indexdotfill % Have leaders before the page number.
5376       %
5377       \ifpdf
5378         \pdfgettoks#1.%
5379         \bgroup\let\domark\relax
5380           \hskip\skip\thinshrinkable\the\toksA
5381         \egroup
5382         % The redefinion of \domark stops marks being added in \pdflink to 
5383         % preserve coloured links across page boundaries.  Otherwise the marks
5384         % would get in the way of \lastbox in \insertindexentrybox.
5385       \else
5386         \hskip\skip\thinshrinkable #1%
5387       \fi
5388     \fi
5389     \egroup % end \boxA
5390     \ifdim\wd\boxB = 0pt
5391       \global\setbox\entryindexbox=\vbox{\unhbox\boxA}%
5392     \else
5393     \global\setbox\entryindexbox=\vbox\bgroup
5394       \prevdepth=\entrylinedepth
5395       \noindent
5396       % We want the text of the entries to be aligned to the left, and the
5397       % page numbers to be aligned to the right.
5398       %
5399       \advance\leftskip by 0pt plus 1fil
5400       \advance\leftskip by 0pt plus -1fill
5401       \rightskip = 0pt plus -1fil
5402       \advance\rightskip by 0pt plus 1fill
5403       % Cause last line, which could consist of page numbers on their own
5404       % if the list of page numbers is long, to be aligned to the right.
5405       \parfillskip=0pt plus -1fill
5406       %
5407       \hangindent=1em
5408       %
5409       \advance\rightskip by \entryrightmargin
5410       % Determine how far we can stretch into the margin.
5411       % This allows, e.g., "Appendix H  GNU Free Documentation License" to
5412       % fit on one line in @letterpaper format.
5413       \ifdim\entryrightmargin>2.1em
5414         \dimen@i=2.1em
5415       \else
5416         \dimen@i=0em
5417       \fi
5418       \advance \parfillskip by 0pt minus 1\dimen@i
5419       %
5420       \dimen@ii = \hsize
5421       \advance\dimen@ii by -1\leftskip
5422       \advance\dimen@ii by -1\entryrightmargin
5423       \advance\dimen@ii by 1\dimen@i
5424       \ifdim\wd\boxA > \dimen@ii % If the entry doesn't fit in one line
5425       \ifdim\dimen@ > 0.8\dimen@ii   % due to long index text
5426         \dimen@ = 0.7\dimen@ % Try to split the text roughly evenly
5427         \dimen@ii = \hsize
5428         \advance \dimen@ii by -1em
5429         \ifnum\dimen@>\dimen@ii
5430           % If the entry is too long, use the whole line
5431           \dimen@ = \dimen@ii
5432         \fi
5433         \advance\leftskip by 0pt plus 1fill % ragged right
5434         \advance \dimen@ by 1\rightskip
5435         \parshape = 2 0pt \dimen@ 1em \dimen@ii
5436         % Ideally we'd add a finite glue at the end of the first line only, but
5437         % TeX doesn't seem to provide a way to do such a thing.
5438       \fi\fi
5439       \unhbox\boxA
5440       %
5441       % Do not prefer a separate line ending with a hyphen to fewer lines.
5442       \finalhyphendemerits = 0
5443       %
5444       % Word spacing - no stretch
5445       \spaceskip=\fontdimen2\font minus \fontdimen4\font
5446       %
5447       \linepenalty=1000  % Discourage line breaks.
5448       \hyphenpenalty=5000  % Discourage hyphenation.
5449       %
5450       \par % format the paragraph
5451     \egroup % The \vbox
5452     \fi
5453   \endgroup
5454   % delay text of entry until after penalty
5455   \bgroup\aftergroup\insertindexentrybox
5456   \entryorphanpenalty
5457 }}
5458
5459 \newskip\thinshrinkable
5460 \skip\thinshrinkable=.15em minus .15em
5461
5462 \newbox\entryindexbox
5463 \def\insertindexentrybox{%
5464   \copy\entryindexbox
5465   % The following gets the depth of the last box.  This is for even
5466   % line spacing when entries span several lines.
5467   \setbox\dummybox\vbox{%
5468     \unvbox\entryindexbox
5469     \nointerlineskip
5470     \lastbox
5471     \global\entrylinedepth=\prevdepth
5472   }%
5473   % Note that we couldn't simply \unvbox\entryindexbox followed by 
5474   % \nointerlineskip\lastbox to remove the last box and then reinstate it, 
5475   % because this resets how far the box has been \moveleft'ed to 0.  \unvbox
5476   % doesn't affect \prevdepth either.
5477 }
5478 \newdimen\entrylinedepth
5479
5480 % Default is no penalty
5481 \let\entryorphanpenalty\egroup
5482
5483 % Used from \printindex.  \firsttoken should be the first token
5484 % after the \entry.  If it's not another \entry, we are at the last
5485 % line of a group of index entries, so insert a penalty to discourage
5486 % orphaned index entries.
5487 \long\def\indexorphanpenalty{%
5488   \def\isentry{\entry}%
5489   \ifx\firsttoken\isentry
5490   \else
5491     \unskip\penalty 9000
5492     % The \unskip here stops breaking before the glue.  It relies on the
5493     % \vskip above being there, otherwise there is an error
5494     % "You can't use `\unskip' in vertical mode".  There has to be glue
5495     % in the current vertical list that hasn't been added to the
5496     % "current page".  See Chapter 24 of the TeXbook.  This contradicts
5497     % Section 8.3.7 in "TeX by Topic," though.
5498   \fi
5499   \egroup % now comes the box added with \aftergroup
5500 }
5501
5502 % Like plain.tex's \dotfill, except uses up at least 1 em.
5503 % The filll stretch here overpowers both the fil and fill stretch to push
5504 % the page number to the right.
5505 \def\indexdotfill{\cleaders
5506   \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1filll}
5507
5508
5509 \def\primary #1{\line{#1\hfil}}
5510
5511 \newskip\secondaryindent \secondaryindent=0.5cm
5512 \def\secondary#1#2{{%
5513   \parfillskip=0in
5514   \parskip=0in
5515   \hangindent=1in
5516   \hangafter=1
5517   \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill
5518   \ifpdf
5519     \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
5520   \else
5521     #2
5522   \fi
5523   \par
5524 }}
5525
5526 % Define two-column mode, which we use to typeset indexes.
5527 % Adapted from the TeXbook, page 416, which is to say,
5528 % the manmac.tex format used to print the TeXbook itself.
5529 \catcode`\@=11  % private names
5530
5531 \newbox\partialpage
5532 \newdimen\doublecolumnhsize
5533 \newdimen\doublecolumntopgap
5534 \doublecolumntopgap = 0pt
5535
5536 % Use inside an output routine to save \topmark and \firstmark
5537 \def\savemarks{%
5538   \global\savedtopmark=\expandafter{\topmark }%
5539   \global\savedfirstmark=\expandafter{\firstmark }%
5540 }
5541 \newtoks\savedtopmark
5542 \newtoks\savedfirstmark
5543
5544 % Set \topmark and \firstmark for next time \output runs.
5545 % Can't be run from withinside \output (because any material
5546 % added while an output routine is active, including 
5547 % penalties, is saved for after it finishes).  The page so far
5548 % should be empty, otherwise what's on it will be thrown away.
5549 \def\restoremarks{%
5550   \mark{\the\savedtopmark}%
5551   \bgroup\output = {%
5552     \setbox\dummybox=\box\PAGE
5553   }abc\eject\egroup
5554   % "abc" because output routine doesn't fire for a completely empty page.
5555   \mark{\the\savedfirstmark}%
5556 }
5557
5558 \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
5559   % If not much space left on page, start a new page.
5560   \ifdim\pagetotal>0.8\vsize\vfill\eject\fi
5561   %
5562   % Grab any single-column material above us.
5563   \output = {%
5564     %
5565     % Here is a possibility not foreseen in manmac: if we accumulate a
5566     % whole lot of material, we might end up calling this \output
5567     % routine twice in a row (see the doublecol-lose test, which is
5568     % essentially a couple of indexes with @setchapternewpage off).  In
5569     % that case we just ship out what is in \partialpage with the normal
5570     % output routine.  Generally, \partialpage will be empty when this
5571     % runs and this will be a no-op.  See the indexspread.tex test case.
5572     \ifvoid\partialpage \else
5573       \onepageout{\pagecontents\partialpage}%
5574     \fi
5575     %
5576     \global\setbox\partialpage = \vbox{%
5577       % Unvbox the main output page.
5578       \unvbox\PAGE
5579       \kern-\topskip \kern\baselineskip
5580     }%
5581     \savemarks
5582   }%
5583   \eject % run that output routine to set \partialpage
5584   \restoremarks
5585   %
5586   % We recover the two marks that the last output routine saved in order
5587   % to propagate the information in marks added around a chapter heading,
5588   % which could be otherwise be lost by the time the final page is output.
5589   %
5590   %
5591   % Use the double-column output routine for subsequent pages.
5592   \output = {\doublecolumnout}%
5593   %
5594   % Change the page size parameters.  We could do this once outside this
5595   % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
5596   % format, but then we repeat the same computation.  Repeating a couple
5597   % of assignments once per index is clearly meaningless for the
5598   % execution time, so we may as well do it in one place.
5599   %
5600   % First we halve the line length, less a little for the gutter between
5601   % the columns.  We compute the gutter based on the line length, so it
5602   % changes automatically with the paper format.  The magic constant
5603   % below is chosen so that the gutter has the same value (well, +-<1pt)
5604   % as it did when we hard-coded it.
5605   %
5606   % We put the result in a separate register, \doublecolumhsize, so we
5607   % can restore it in \pagesofar, after \hsize itself has (potentially)
5608   % been clobbered.
5609   %
5610   \doublecolumnhsize = \hsize
5611     \advance\doublecolumnhsize by -.04154\hsize
5612     \divide\doublecolumnhsize by 2
5613   \hsize = \doublecolumnhsize
5614   %
5615   % Double the \vsize as well.  (We don't need a separate register here,
5616   % since nobody clobbers \vsize.)
5617   \global\doublecolumntopgap = \topskip
5618   \global\advance\doublecolumntopgap by -1\baselineskip
5619   \advance\vsize by -1\doublecolumntopgap
5620   \vsize = 2\vsize
5621   \topskip=0pt
5622   \global\entrylinedepth=0pt\relax
5623 }
5624
5625 % The double-column output routine for all double-column pages except
5626 % the last, which is done by \balancecolumns.
5627 %
5628 \def\doublecolumnout{%
5629   %
5630   \splittopskip=\topskip \splitmaxdepth=\maxdepth
5631   % Get the available space for the double columns -- the normal
5632   % (undoubled) page height minus any material left over from the
5633   % previous page.
5634   \dimen@ = \vsize
5635   \divide\dimen@ by 2
5636   \advance\dimen@ by -\ht\partialpage
5637   %
5638   % box0 will be the left-hand column, box2 the right.
5639   \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
5640   \onepageout\pagesofar
5641   \unvbox255
5642   \penalty\outputpenalty
5643 }
5644 %
5645 % Re-output the contents of the output page -- any previous material,
5646 % followed by the two boxes we just split, in box0 and box2.
5647 \def\pagesofar{%
5648   \unvbox\partialpage
5649   %
5650   \hsize = \doublecolumnhsize
5651   \wd0=\hsize \wd2=\hsize
5652   \vbox{%
5653     \vskip\doublecolumntopgap
5654     \hbox to\pagewidth{\box0\hfil\box2}}%
5655 }
5656
5657
5658 % Finished with with double columns.
5659 \def\enddoublecolumns{%
5660   % The following penalty ensures that the page builder is exercised
5661   % _before_ we change the output routine.  This is necessary in the
5662   % following situation:
5663   %
5664   % The last section of the index consists only of a single entry.
5665   % Before this section, \pagetotal is less than \pagegoal, so no
5666   % break occurs before the last section starts.  However, the last
5667   % section, consisting of \initial and the single \entry, does not
5668   % fit on the page and has to be broken off.  Without the following
5669   % penalty the page builder will not be exercised until \eject
5670   % below, and by that time we'll already have changed the output
5671   % routine to the \balancecolumns version, so the next-to-last
5672   % double-column page will be processed with \balancecolumns, which
5673   % is wrong:  The two columns will go to the main vertical list, with
5674   % the broken-off section in the recent contributions.  As soon as
5675   % the output routine finishes, TeX starts reconsidering the page
5676   % break.  The two columns and the broken-off section both fit on the
5677   % page, because the two columns now take up only half of the page
5678   % goal.  When TeX sees \eject from below which follows the final
5679   % section, it invokes the new output routine that we've set after
5680   % \balancecolumns below; \onepageout will try to fit the two columns
5681   % and the final section into the vbox of \pageheight (see
5682   % \pagebody), causing an overfull box.
5683   %
5684   % Note that glue won't work here, because glue does not exercise the
5685   % page builder, unlike penalties (see The TeXbook, pp. 280-281).
5686   \penalty0
5687   %
5688   \output = {%
5689     % Split the last of the double-column material.
5690     \savemarks
5691     \balancecolumns
5692     %
5693     % Having called \balancecolumns once, we do not
5694     % want to call it again.  Therefore, reset \output to its normal
5695     % definition right away.
5696     \global\output = {\onepageout{\pagecontents\PAGE}}%
5697   }%
5698   \eject
5699   \endgroup % started in \begindoublecolumns
5700   \restoremarks
5701   % Leave the double-column material on the current page, no automatic
5702   % page break.
5703   \box\balancedcolumns
5704   %
5705   % \pagegoal was set to the doubled \vsize above, since we restarted
5706   % the current page.  We're now back to normal single-column
5707   % typesetting, so reset \pagegoal to the normal \vsize (after the
5708   % \endgroup where \vsize got restored).
5709   \pagegoal = \vsize
5710 }
5711 \newbox\balancedcolumns
5712 \setbox\balancedcolumns=\vbox{shouldnt see this}%
5713 %
5714 % Only called for the last of the double column material.  \doublecolumnout 
5715 % does the others.
5716 \def\balancecolumns{%
5717   \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120.
5718   \dimen@ = \ht0
5719   \advance\dimen@ by \topskip
5720   \advance\dimen@ by-\baselineskip
5721   \ifdim\dimen@<14\baselineskip
5722     % Don't split a short final column in two.
5723     \setbox2=\vbox{}%
5724   \else
5725     \divide\dimen@ by 2 % target to split to
5726     \dimen@ii = \dimen@
5727     \splittopskip = \topskip
5728     % Loop until the second column is no higher than the first
5729     {%
5730       \vbadness = 10000
5731       \loop
5732         \global\setbox3 = \copy0
5733         \global\setbox1 = \vsplit3 to \dimen@
5734         % Remove glue from bottom of first column to
5735         % make sure it is higher than the second.
5736         \global\setbox1 = \vbox{\unvbox1\unpenalty\unskip}%
5737       \ifdim\ht3>\ht1
5738         \global\advance\dimen@ by 1pt
5739       \repeat
5740     }%
5741     \multiply\dimen@ii by 4
5742     \divide\dimen@ii by 5
5743     \ifdim\ht3<\dimen@ii
5744       % Column heights are too different, so don't make their bottoms
5745       % flush with each other.  The glue at the end of the second column
5746       % allows a second column to stretch, reducing the difference in
5747       % height between the two.
5748       \setbox0=\vbox to\dimen@{\unvbox1\vfill}%
5749       \setbox2=\vbox to\dimen@{\unvbox3\vskip 0pt plus 0.3\ht0}%
5750     \else
5751       \setbox0=\vbox to\dimen@{\unvbox1}%
5752       \setbox2=\vbox to\dimen@{\unvbox3}%
5753     \fi
5754   \fi
5755   %
5756   \global\setbox\balancedcolumns=\vbox{\pagesofar}%
5757 }
5758 \catcode`\@ = \other
5759
5760
5761 \message{sectioning,}
5762 % Chapters, sections, etc.
5763
5764 % Let's start with @part.
5765 \outer\parseargdef\part{\partzzz{#1}}
5766 \def\partzzz#1{%
5767   \chapoddpage
5768   \null
5769   \vskip.3\vsize  % move it down on the page a bit
5770   \begingroup
5771     \noindent \titlefonts\rmisbold #1\par % the text
5772     \let\lastnode=\empty      % no node to associate with
5773     \writetocentry{part}{#1}{}% but put it in the toc
5774     \headingsoff              % no headline or footline on the part page
5775     % This outputs a mark at the end of the page that clears \thischapter
5776     % and \thissection, as is done in \startcontents.
5777     \let\pchapsepmacro\relax
5778     \chapmacro{}{Yomitfromtoc}{}%
5779     \chapoddpage
5780   \endgroup
5781 }
5782
5783 % \unnumberedno is an oxymoron.  But we count the unnumbered
5784 % sections so that we can refer to them unambiguously in the pdf
5785 % outlines by their "section number".  We avoid collisions with chapter
5786 % numbers by starting them at 10000.  (If a document ever has 10000
5787 % chapters, we're in trouble anyway, I'm sure.)
5788 \newcount\unnumberedno \unnumberedno = 10000
5789 \newcount\chapno
5790 \newcount\secno        \secno=0
5791 \newcount\subsecno     \subsecno=0
5792 \newcount\subsubsecno  \subsubsecno=0
5793
5794 % This counter is funny since it counts through charcodes of letters A, B, ...
5795 \newcount\appendixno  \appendixno = `\@
5796 %
5797 % \def\appendixletter{\char\the\appendixno}
5798 % We do the following ugly conditional instead of the above simple
5799 % construct for the sake of pdftex, which needs the actual
5800 % letter in the expansion, not just typeset.
5801 %
5802 \def\appendixletter{%
5803   \ifnum\appendixno=`A A%
5804   \else\ifnum\appendixno=`B B%
5805   \else\ifnum\appendixno=`C C%
5806   \else\ifnum\appendixno=`D D%
5807   \else\ifnum\appendixno=`E E%
5808   \else\ifnum\appendixno=`F F%
5809   \else\ifnum\appendixno=`G G%
5810   \else\ifnum\appendixno=`H H%
5811   \else\ifnum\appendixno=`I I%
5812   \else\ifnum\appendixno=`J J%
5813   \else\ifnum\appendixno=`K K%
5814   \else\ifnum\appendixno=`L L%
5815   \else\ifnum\appendixno=`M M%
5816   \else\ifnum\appendixno=`N N%
5817   \else\ifnum\appendixno=`O O%
5818   \else\ifnum\appendixno=`P P%
5819   \else\ifnum\appendixno=`Q Q%
5820   \else\ifnum\appendixno=`R R%
5821   \else\ifnum\appendixno=`S S%
5822   \else\ifnum\appendixno=`T T%
5823   \else\ifnum\appendixno=`U U%
5824   \else\ifnum\appendixno=`V V%
5825   \else\ifnum\appendixno=`W W%
5826   \else\ifnum\appendixno=`X X%
5827   \else\ifnum\appendixno=`Y Y%
5828   \else\ifnum\appendixno=`Z Z%
5829   % The \the is necessary, despite appearances, because \appendixletter is
5830   % expanded while writing the .toc file.  \char\appendixno is not
5831   % expandable, thus it is written literally, thus all appendixes come out
5832   % with the same letter (or @) in the toc without it.
5833   \else\char\the\appendixno
5834   \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
5835   \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
5836
5837 % Each @chapter defines these (using marks) as the number+name, number
5838 % and name of the chapter.  Page headings and footings can use
5839 % these.  @section does likewise.
5840 \def\thischapter{}
5841 \def\thischapternum{}
5842 \def\thischaptername{}
5843 \def\thissection{}
5844 \def\thissectionnum{}
5845 \def\thissectionname{}
5846
5847 \newcount\absseclevel % used to calculate proper heading level
5848 \newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count
5849
5850 % @raisesections: treat @section as chapter, @subsection as section, etc.
5851 \def\raisesections{\global\advance\secbase by -1}
5852 \let\up=\raisesections % original BFox name
5853
5854 % @lowersections: treat @chapter as section, @section as subsection, etc.
5855 \def\lowersections{\global\advance\secbase by 1}
5856 \let\down=\lowersections % original BFox name
5857
5858 % we only have subsub.
5859 \chardef\maxseclevel = 3
5860 %
5861 % A numbered section within an unnumbered changes to unnumbered too.
5862 % To achieve this, remember the "biggest" unnum. sec. we are currently in:
5863 \chardef\unnlevel = \maxseclevel
5864 %
5865 % Trace whether the current chapter is an appendix or not:
5866 % \chapheadtype is "N" or "A", unnumbered chapters are ignored.
5867 \def\chapheadtype{N}
5868
5869 % Choose a heading macro
5870 % #1 is heading type
5871 % #2 is heading level
5872 % #3 is text for heading
5873 \def\genhead#1#2#3{%
5874   % Compute the abs. sec. level:
5875   \absseclevel=#2
5876   \advance\absseclevel by \secbase
5877   % Make sure \absseclevel doesn't fall outside the range:
5878   \ifnum \absseclevel < 0
5879     \absseclevel = 0
5880   \else
5881     \ifnum \absseclevel > 3
5882       \absseclevel = 3
5883     \fi
5884   \fi
5885   % The heading type:
5886   \def\headtype{#1}%
5887   \if \headtype U%
5888     \ifnum \absseclevel < \unnlevel
5889       \chardef\unnlevel = \absseclevel
5890     \fi
5891   \else
5892     % Check for appendix sections:
5893     \ifnum \absseclevel = 0
5894       \edef\chapheadtype{\headtype}%
5895     \else
5896       \if \headtype A\if \chapheadtype N%
5897         \errmessage{@appendix... within a non-appendix chapter}%
5898       \fi\fi
5899     \fi
5900     % Check for numbered within unnumbered:
5901     \ifnum \absseclevel > \unnlevel
5902       \def\headtype{U}%
5903     \else
5904       \chardef\unnlevel = 3
5905     \fi
5906   \fi
5907   % Now print the heading:
5908   \if \headtype U%
5909     \ifcase\absseclevel
5910         \unnumberedzzz{#3}%
5911     \or \unnumberedseczzz{#3}%
5912     \or \unnumberedsubseczzz{#3}%
5913     \or \unnumberedsubsubseczzz{#3}%
5914     \fi
5915   \else
5916     \if \headtype A%
5917       \ifcase\absseclevel
5918           \appendixzzz{#3}%
5919       \or \appendixsectionzzz{#3}%
5920       \or \appendixsubseczzz{#3}%
5921       \or \appendixsubsubseczzz{#3}%
5922       \fi
5923     \else
5924       \ifcase\absseclevel
5925           \chapterzzz{#3}%
5926       \or \seczzz{#3}%
5927       \or \numberedsubseczzz{#3}%
5928       \or \numberedsubsubseczzz{#3}%
5929       \fi
5930     \fi
5931   \fi
5932   \suppressfirstparagraphindent
5933 }
5934
5935 % an interface:
5936 \def\numhead{\genhead N}
5937 \def\apphead{\genhead A}
5938 \def\unnmhead{\genhead U}
5939
5940 % @chapter, @appendix, @unnumbered.  Increment top-level counter, reset
5941 % all lower-level sectioning counters to zero.
5942 %
5943 % Also set \chaplevelprefix, which we prepend to @float sequence numbers
5944 % (e.g., figures), q.v.  By default (before any chapter), that is empty.
5945 \let\chaplevelprefix = \empty
5946 %
5947 \outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz
5948 \def\chapterzzz#1{%
5949   % section resetting is \global in case the chapter is in a group, such
5950   % as an @include file.
5951   \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
5952     \global\advance\chapno by 1
5953   %
5954   % Used for \float.
5955   \gdef\chaplevelprefix{\the\chapno.}%
5956   \resetallfloatnos
5957   %
5958   % \putwordChapter can contain complex things in translations.
5959   \toks0=\expandafter{\putwordChapter}%
5960   \message{\the\toks0 \space \the\chapno}%
5961   %
5962   % Write the actual heading.
5963   \chapmacro{#1}{Ynumbered}{\the\chapno}%
5964   %
5965   % So @section and the like are numbered underneath this chapter.
5966   \global\let\section = \numberedsec
5967   \global\let\subsection = \numberedsubsec
5968   \global\let\subsubsection = \numberedsubsubsec
5969 }
5970
5971 \outer\parseargdef\appendix{\apphead0{#1}} % normally calls appendixzzz
5972 %
5973 \def\appendixzzz#1{%
5974   \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
5975     \global\advance\appendixno by 1
5976   \gdef\chaplevelprefix{\appendixletter.}%
5977   \resetallfloatnos
5978   %
5979   % \putwordAppendix can contain complex things in translations.
5980   \toks0=\expandafter{\putwordAppendix}%
5981   \message{\the\toks0 \space \appendixletter}%
5982   %
5983   \chapmacro{#1}{Yappendix}{\appendixletter}%
5984   %
5985   \global\let\section = \appendixsec
5986   \global\let\subsection = \appendixsubsec
5987   \global\let\subsubsection = \appendixsubsubsec
5988 }
5989
5990 % normally unnmhead0 calls unnumberedzzz:
5991 \outer\parseargdef\unnumbered{\unnmhead0{#1}}
5992 \def\unnumberedzzz#1{%
5993   \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
5994     \global\advance\unnumberedno by 1
5995   %
5996   % Since an unnumbered has no number, no prefix for figures.
5997   \global\let\chaplevelprefix = \empty
5998   \resetallfloatnos
5999   %
6000   % This used to be simply \message{#1}, but TeX fully expands the
6001   % argument to \message.  Therefore, if #1 contained @-commands, TeX
6002   % expanded them.  For example, in `@unnumbered The @cite{Book}', TeX
6003   % expanded @cite (which turns out to cause errors because \cite is meant
6004   % to be executed, not expanded).
6005   %
6006   % Anyway, we don't want the fully-expanded definition of @cite to appear
6007   % as a result of the \message, we just want `@cite' itself.  We use
6008   % \the<toks register> to achieve this: TeX expands \the<toks> only once,
6009   % simply yielding the contents of <toks register>.  (We also do this for
6010   % the toc entries.)
6011   \toks0 = {#1}%
6012   \message{(\the\toks0)}%
6013   %
6014   \chapmacro{#1}{Ynothing}{\the\unnumberedno}%
6015   %
6016   \global\let\section = \unnumberedsec
6017   \global\let\subsection = \unnumberedsubsec
6018   \global\let\subsubsection = \unnumberedsubsubsec
6019 }
6020
6021 % @centerchap is like @unnumbered, but the heading is centered.
6022 \outer\parseargdef\centerchap{%
6023   \let\centerparametersmaybe = \centerparameters
6024   \unnmhead0{#1}%
6025   \let\centerparametersmaybe = \relax
6026 }
6027
6028 % @top is like @unnumbered.
6029 \let\top\unnumbered
6030
6031 % Sections.
6032
6033 \outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
6034 \def\seczzz#1{%
6035   \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
6036   \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}%
6037 }
6038
6039 % normally calls appendixsectionzzz:
6040 \outer\parseargdef\appendixsection{\apphead1{#1}}
6041 \def\appendixsectionzzz#1{%
6042   \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
6043   \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}%
6044 }
6045 \let\appendixsec\appendixsection
6046
6047 % normally calls unnumberedseczzz:
6048 \outer\parseargdef\unnumberedsec{\unnmhead1{#1}}
6049 \def\unnumberedseczzz#1{%
6050   \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
6051   \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%
6052 }
6053
6054 % Subsections.
6055
6056 % normally calls numberedsubseczzz:
6057 \outer\parseargdef\numberedsubsec{\numhead2{#1}}
6058 \def\numberedsubseczzz#1{%
6059   \global\subsubsecno=0  \global\advance\subsecno by 1
6060   \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}%
6061 }
6062
6063 % normally calls appendixsubseczzz:
6064 \outer\parseargdef\appendixsubsec{\apphead2{#1}}
6065 \def\appendixsubseczzz#1{%
6066   \global\subsubsecno=0  \global\advance\subsecno by 1
6067   \sectionheading{#1}{subsec}{Yappendix}%
6068                  {\appendixletter.\the\secno.\the\subsecno}%
6069 }
6070
6071 % normally calls unnumberedsubseczzz:
6072 \outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}}
6073 \def\unnumberedsubseczzz#1{%
6074   \global\subsubsecno=0  \global\advance\subsecno by 1
6075   \sectionheading{#1}{subsec}{Ynothing}%
6076                  {\the\unnumberedno.\the\secno.\the\subsecno}%
6077 }
6078
6079 % Subsubsections.
6080
6081 % normally numberedsubsubseczzz:
6082 \outer\parseargdef\numberedsubsubsec{\numhead3{#1}}
6083 \def\numberedsubsubseczzz#1{%
6084   \global\advance\subsubsecno by 1
6085   \sectionheading{#1}{subsubsec}{Ynumbered}%
6086                  {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}%
6087 }
6088
6089 % normally appendixsubsubseczzz:
6090 \outer\parseargdef\appendixsubsubsec{\apphead3{#1}}
6091 \def\appendixsubsubseczzz#1{%
6092   \global\advance\subsubsecno by 1
6093   \sectionheading{#1}{subsubsec}{Yappendix}%
6094                  {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}%
6095 }
6096
6097 % normally unnumberedsubsubseczzz:
6098 \outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}}
6099 \def\unnumberedsubsubseczzz#1{%
6100   \global\advance\subsubsecno by 1
6101   \sectionheading{#1}{subsubsec}{Ynothing}%
6102                  {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}%
6103 }
6104
6105 % These macros control what the section commands do, according
6106 % to what kind of chapter we are in (ordinary, appendix, or unnumbered).
6107 % Define them by default for a numbered chapter.
6108 \let\section = \numberedsec
6109 \let\subsection = \numberedsubsec
6110 \let\subsubsection = \numberedsubsubsec
6111
6112 % Define @majorheading, @heading and @subheading
6113
6114 \def\majorheading{%
6115   {\advance\chapheadingskip by 10pt \chapbreak }%
6116   \parsearg\chapheadingzzz
6117 }
6118
6119 \def\chapheading{\chapbreak \parsearg\chapheadingzzz}
6120 \def\chapheadingzzz#1{%
6121   \vbox{\chapfonts \raggedtitlesettings #1\par}%
6122   \nobreak\bigskip \nobreak
6123   \suppressfirstparagraphindent
6124 }
6125
6126 % @heading, @subheading, @subsubheading.
6127 \parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{}
6128   \suppressfirstparagraphindent}
6129 \parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{}
6130   \suppressfirstparagraphindent}
6131 \parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{}
6132   \suppressfirstparagraphindent}
6133
6134 % These macros generate a chapter, section, etc. heading only
6135 % (including whitespace, linebreaking, etc. around it),
6136 % given all the information in convenient, parsed form.
6137
6138 % Args are the skip and penalty (usually negative)
6139 \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
6140
6141 % Parameter controlling skip before chapter headings (if needed)
6142 \newskip\chapheadingskip
6143
6144 % Define plain chapter starts, and page on/off switching for it.
6145 \def\chapbreak{\dobreak \chapheadingskip {-4000}}
6146
6147 % Start a new page
6148 \def\chappager{\par\vfill\supereject}
6149
6150 % \chapoddpage - start on an odd page for a new chapter
6151 % Because \domark is called before \chapoddpage, the filler page will
6152 % get the headings for the next chapter, which is wrong.  But we don't
6153 % care -- we just disable all headings on the filler page.
6154 \def\chapoddpage{%
6155   \chappager
6156   \ifodd\pageno \else
6157     \begingroup
6158       \headingsoff
6159       \null
6160       \chappager
6161     \endgroup
6162   \fi
6163 }
6164
6165 \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
6166
6167 \def\CHAPPAGoff{%
6168 \global\let\contentsalignmacro = \chappager
6169 \global\let\pchapsepmacro=\chapbreak
6170 \global\let\pagealignmacro=\chappager}
6171
6172 \def\CHAPPAGon{%
6173 \global\let\contentsalignmacro = \chappager
6174 \global\let\pchapsepmacro=\chappager
6175 \global\let\pagealignmacro=\chappager
6176 \global\def\HEADINGSon{\HEADINGSsingle}}
6177
6178 \def\CHAPPAGodd{%
6179 \global\let\contentsalignmacro = \chapoddpage
6180 \global\let\pchapsepmacro=\chapoddpage
6181 \global\let\pagealignmacro=\chapoddpage
6182 \global\def\HEADINGSon{\HEADINGSdouble}}
6183
6184 \CHAPPAGon
6185
6186 % \chapmacro - Chapter opening.
6187 %
6188 % #1 is the text, #2 is the section type (Ynumbered, Ynothing,
6189 % Yappendix, Yomitfromtoc), #3 the chapter number.
6190 % Not used for @heading series.
6191 %
6192 % To test against our argument.
6193 \def\Ynothingkeyword{Ynothing}
6194 \def\Yappendixkeyword{Yappendix}
6195 \def\Yomitfromtockeyword{Yomitfromtoc}
6196 %
6197 \def\chapmacro#1#2#3{%
6198   \expandafter\ifx\thisenv\titlepage\else
6199     \checkenv{}% chapters, etc., should not start inside an environment.
6200   \fi
6201   % FIXME: \chapmacro is currently called from inside \titlepage when
6202   % \setcontentsaftertitlepage to print the "Table of Contents" heading, but
6203   % this should probably be done by \sectionheading with an option to print
6204   % in chapter size.
6205   %
6206   % Insert the first mark before the heading break (see notes for \domark).
6207   \let\prevchapterdefs=\lastchapterdefs
6208   \let\prevsectiondefs=\lastsectiondefs
6209   \gdef\lastsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}%
6210                         \gdef\thissection{}}%
6211   %
6212   \def\temptype{#2}%
6213   \ifx\temptype\Ynothingkeyword
6214     \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
6215                           \gdef\thischapter{\thischaptername}}%
6216   \else\ifx\temptype\Yomitfromtockeyword
6217     \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
6218                           \gdef\thischapter{}}%
6219   \else\ifx\temptype\Yappendixkeyword
6220     \toks0={#1}%
6221     \xdef\lastchapterdefs{%
6222       \gdef\noexpand\thischaptername{\the\toks0}%
6223       \gdef\noexpand\thischapternum{\appendixletter}%
6224       % \noexpand\putwordAppendix avoids expanding indigestible
6225       % commands in some of the translations.
6226       \gdef\noexpand\thischapter{\noexpand\putwordAppendix{}
6227                                  \noexpand\thischapternum:
6228                                  \noexpand\thischaptername}%
6229     }%
6230   \else
6231     \toks0={#1}%
6232     \xdef\lastchapterdefs{%
6233       \gdef\noexpand\thischaptername{\the\toks0}%
6234       \gdef\noexpand\thischapternum{\the\chapno}%
6235       % \noexpand\putwordChapter avoids expanding indigestible
6236       % commands in some of the translations.
6237       \gdef\noexpand\thischapter{\noexpand\putwordChapter{}
6238                                  \noexpand\thischapternum:
6239                                  \noexpand\thischaptername}%
6240     }%
6241   \fi\fi\fi
6242   %
6243   % Output the mark.  Pass it through \safewhatsit, to take care of
6244   % the preceding space.
6245   \safewhatsit\domark
6246   %
6247   % Insert the chapter heading break.
6248   \pchapsepmacro
6249   %
6250   % Now the second mark, after the heading break.  No break points
6251   % between here and the heading.
6252   \let\prevchapterdefs=\lastchapterdefs
6253   \let\prevsectiondefs=\lastsectiondefs
6254   \domark
6255   %
6256   {%
6257     \chapfonts \rmisbold
6258     \let\footnote=\errfootnoteheading % give better error message
6259     %
6260     % Have to define \lastsection before calling \donoderef, because the
6261     % xref code eventually uses it.  On the other hand, it has to be called
6262     % after \pchapsepmacro, or the headline will change too soon.
6263     \gdef\lastsection{#1}%
6264     %
6265     % Only insert the separating space if we have a chapter/appendix
6266     % number, and don't print the unnumbered ``number''.
6267     \ifx\temptype\Ynothingkeyword
6268       \setbox0 = \hbox{}%
6269       \def\toctype{unnchap}%
6270     \else\ifx\temptype\Yomitfromtockeyword
6271       \setbox0 = \hbox{}% contents like unnumbered, but no toc entry
6272       \def\toctype{omit}%
6273     \else\ifx\temptype\Yappendixkeyword
6274       \setbox0 = \hbox{\putwordAppendix{} #3\enspace}%
6275       \def\toctype{app}%
6276     \else
6277       \setbox0 = \hbox{#3\enspace}%
6278       \def\toctype{numchap}%
6279     \fi\fi\fi
6280     %
6281     % Write the toc entry for this chapter.  Must come before the
6282     % \donoderef, because we include the current node name in the toc
6283     % entry, and \donoderef resets it to empty.
6284     \writetocentry{\toctype}{#1}{#3}%
6285     %
6286     % For pdftex, we have to write out the node definition (aka, make
6287     % the pdfdest) after any page break, but before the actual text has
6288     % been typeset.  If the destination for the pdf outline is after the
6289     % text, then jumping from the outline may wind up with the text not
6290     % being visible, for instance under high magnification.
6291     \donoderef{#2}%
6292     %
6293     % Typeset the actual heading.
6294     \nobreak % Avoid page breaks at the interline glue.
6295     \vbox{\raggedtitlesettings \hangindent=\wd0 \centerparametersmaybe
6296           \unhbox0 #1\par}%
6297   }%
6298   \nobreak\bigskip % no page break after a chapter title
6299   \nobreak
6300 }
6301
6302 % @centerchap -- centered and unnumbered.
6303 \let\centerparametersmaybe = \relax
6304 \def\centerparameters{%
6305   \advance\rightskip by 3\rightskip
6306   \leftskip = \rightskip
6307   \parfillskip = 0pt
6308 }
6309
6310
6311 % I don't think this chapter style is supported any more, so I'm not
6312 % updating it with the new noderef stuff.  We'll see.  --karl, 11aug03.
6313 %
6314 \def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
6315 %
6316 \def\unnchfopen #1{%
6317   \chapoddpage
6318   \vbox{\chapfonts \raggedtitlesettings #1\par}%
6319   \nobreak\bigskip\nobreak
6320 }
6321 \def\chfopen #1#2{\chapoddpage {\chapfonts
6322 \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
6323 \par\penalty 5000 %
6324 }
6325 \def\centerchfopen #1{%
6326   \chapoddpage
6327   \vbox{\chapfonts \raggedtitlesettings \hfill #1\hfill}%
6328   \nobreak\bigskip \nobreak
6329 }
6330 \def\CHAPFopen{%
6331   \global\let\chapmacro=\chfopen
6332   \global\let\centerchapmacro=\centerchfopen}
6333
6334
6335 % Section titles.  These macros combine the section number parts and
6336 % call the generic \sectionheading to do the printing.
6337 %
6338 \newskip\secheadingskip
6339 \def\secheadingbreak{\dobreak \secheadingskip{-1000}}
6340
6341 % Subsection titles.
6342 \newskip\subsecheadingskip
6343 \def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}}
6344
6345 % Subsubsection titles.
6346 \def\subsubsecheadingskip{\subsecheadingskip}
6347 \def\subsubsecheadingbreak{\subsecheadingbreak}
6348
6349
6350 % Print any size, any type, section title.
6351 %
6352 % #1 is the text of the title,
6353 % #2 is the section level (sec/subsec/subsubsec),
6354 % #3 is the section type (Ynumbered, Ynothing, Yappendix, Yomitfromtoc),
6355 % #4 is the section number.
6356 %
6357 \def\seckeyword{sec}
6358 %
6359 \def\sectionheading#1#2#3#4{%
6360   {%
6361     \def\sectionlevel{#2}%
6362     \def\temptype{#3}%
6363     %
6364     % It is ok for the @heading series commands to appear inside an
6365     % environment (it's been historically allowed, though the logic is
6366     % dubious), but not the others.
6367     \ifx\temptype\Yomitfromtockeyword\else
6368       \checkenv{}% non-@*heading should not be in an environment.
6369     \fi
6370     \let\footnote=\errfootnoteheading
6371     %
6372     % Switch to the right set of fonts.
6373     \csname #2fonts\endcsname \rmisbold
6374     %
6375     % Insert first mark before the heading break (see notes for \domark).
6376     \let\prevsectiondefs=\lastsectiondefs
6377     \ifx\temptype\Ynothingkeyword
6378       \ifx\sectionlevel\seckeyword
6379         \gdef\lastsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}%
6380                               \gdef\thissection{\thissectionname}}%
6381       \fi
6382     \else\ifx\temptype\Yomitfromtockeyword
6383       % Don't redefine \thissection.
6384     \else\ifx\temptype\Yappendixkeyword
6385       \ifx\sectionlevel\seckeyword
6386         \toks0={#1}%
6387         \xdef\lastsectiondefs{%
6388           \gdef\noexpand\thissectionname{\the\toks0}%
6389           \gdef\noexpand\thissectionnum{#4}%
6390           % \noexpand\putwordSection avoids expanding indigestible
6391           % commands in some of the translations.
6392           \gdef\noexpand\thissection{\noexpand\putwordSection{}
6393                                      \noexpand\thissectionnum:
6394                                      \noexpand\thissectionname}%
6395         }%
6396       \fi
6397     \else
6398       \ifx\sectionlevel\seckeyword
6399         \toks0={#1}%
6400         \xdef\lastsectiondefs{%
6401           \gdef\noexpand\thissectionname{\the\toks0}%
6402           \gdef\noexpand\thissectionnum{#4}%
6403           % \noexpand\putwordSection avoids expanding indigestible
6404           % commands in some of the translations.
6405           \gdef\noexpand\thissection{\noexpand\putwordSection{}
6406                                      \noexpand\thissectionnum:
6407                                      \noexpand\thissectionname}%
6408         }%
6409       \fi
6410     \fi\fi\fi
6411     %
6412     % Go into vertical mode.  Usually we'll already be there, but we
6413     % don't want the following whatsit to end up in a preceding paragraph
6414     % if the document didn't happen to have a blank line.
6415     \par
6416     %
6417     % Output the mark.  Pass it through \safewhatsit, to take care of
6418     % the preceding space.
6419     \safewhatsit\domark
6420     %
6421     % Insert space above the heading.
6422     \csname #2headingbreak\endcsname
6423     %
6424     % Now the second mark, after the heading break.  No break points
6425     % between here and the heading.
6426     \global\let\prevsectiondefs=\lastsectiondefs
6427     \domark
6428     %
6429     % Only insert the space after the number if we have a section number.
6430     \ifx\temptype\Ynothingkeyword
6431       \setbox0 = \hbox{}%
6432       \def\toctype{unn}%
6433       \gdef\lastsection{#1}%
6434     \else\ifx\temptype\Yomitfromtockeyword
6435       % for @headings -- no section number, don't include in toc,
6436       % and don't redefine \lastsection.
6437       \setbox0 = \hbox{}%
6438       \def\toctype{omit}%
6439       \let\sectionlevel=\empty
6440     \else\ifx\temptype\Yappendixkeyword
6441       \setbox0 = \hbox{#4\enspace}%
6442       \def\toctype{app}%
6443       \gdef\lastsection{#1}%
6444     \else
6445       \setbox0 = \hbox{#4\enspace}%
6446       \def\toctype{num}%
6447       \gdef\lastsection{#1}%
6448     \fi\fi\fi
6449     %
6450     % Write the toc entry (before \donoderef).  See comments in \chapmacro.
6451     \writetocentry{\toctype\sectionlevel}{#1}{#4}%
6452     %
6453     % Write the node reference (= pdf destination for pdftex).
6454     % Again, see comments in \chapmacro.
6455     \donoderef{#3}%
6456     %
6457     % Interline glue will be inserted when the vbox is completed.
6458     % That glue will be a valid breakpoint for the page, since it'll be
6459     % preceded by a whatsit (usually from the \donoderef, or from the
6460     % \writetocentry if there was no node).  We don't want to allow that
6461     % break, since then the whatsits could end up on page n while the
6462     % section is on page n+1, thus toc/etc. are wrong.  Debian bug 276000.
6463     \nobreak
6464     %
6465     % Output the actual section heading.
6466     \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright
6467           \hangindent=\wd0  % zero if no section number
6468           \unhbox0 #1}%
6469   }%
6470   % Add extra space after the heading -- half of whatever came above it.
6471   % Don't allow stretch, though.
6472   \kern .5 \csname #2headingskip\endcsname
6473   %
6474   % Do not let the kern be a potential breakpoint, as it would be if it
6475   % was followed by glue.
6476   \nobreak
6477   %
6478   % We'll almost certainly start a paragraph next, so don't let that
6479   % glue accumulate.  (Not a breakpoint because it's preceded by a
6480   % discardable item.)  However, when a paragraph is not started next
6481   % (\startdefun, \cartouche, \center, etc.), this needs to be wiped out
6482   % or the negative glue will cause weirdly wrong output, typically
6483   % obscuring the section heading with something else.
6484   \vskip-\parskip
6485   %
6486   % This is so the last item on the main vertical list is a known
6487   % \penalty > 10000, so \startdefun, etc., can recognize the situation
6488   % and do the needful.
6489   \penalty 10001
6490 }
6491
6492
6493 \message{toc,}
6494 % Table of contents.
6495 \newwrite\tocfile
6496
6497 % Write an entry to the toc file, opening it if necessary.
6498 % Called from @chapter, etc.
6499 %
6500 % Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno}
6501 % We append the current node name (if any) and page number as additional
6502 % arguments for the \{chap,sec,...}entry macros which will eventually
6503 % read this.  The node name is used in the pdf outlines as the
6504 % destination to jump to.
6505 %
6506 % We open the .toc file for writing here instead of at @setfilename (or
6507 % any other fixed time) so that @contents can be anywhere in the document.
6508 % But if #1 is `omit', then we don't do anything.  This is used for the
6509 % table of contents chapter openings themselves.
6510 %
6511 \newif\iftocfileopened
6512 \def\omitkeyword{omit}%
6513 %
6514 \def\writetocentry#1#2#3{%
6515   \edef\writetoctype{#1}%
6516   \ifx\writetoctype\omitkeyword \else
6517     \iftocfileopened\else
6518       \immediate\openout\tocfile = \jobname.toc
6519       \global\tocfileopenedtrue
6520     \fi
6521     %
6522     \iflinks
6523       {\atdummies
6524        \edef\temp{%
6525          \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}%
6526        \temp
6527       }%
6528     \fi
6529   \fi
6530   %
6531   % Tell \shipout to create a pdf destination on each page, if we're
6532   % writing pdf.  These are used in the table of contents.  We can't
6533   % just write one on every page because the title pages are numbered
6534   % 1 and 2 (the page numbers aren't printed), and so are the first
6535   % two pages of the document.  Thus, we'd have two destinations named
6536   % `1', and two named `2'.
6537   \ifpdf \global\pdfmakepagedesttrue \fi
6538 }
6539
6540
6541 % These characters do not print properly in the Computer Modern roman
6542 % fonts, so we must take special care.  This is more or less redundant
6543 % with the Texinfo input format setup at the end of this file.
6544 %
6545 \def\activecatcodes{%
6546   \catcode`\"=\active
6547   \catcode`\$=\active
6548   \catcode`\<=\active
6549   \catcode`\>=\active
6550   \catcode`\\=\active
6551   \catcode`\^=\active
6552   \catcode`\_=\active
6553   \catcode`\|=\active
6554   \catcode`\~=\active
6555 }
6556
6557
6558 % Read the toc file, which is essentially Texinfo input.
6559 \def\readtocfile{%
6560   \setupdatafile
6561   \activecatcodes
6562   \input \tocreadfilename
6563 }
6564
6565 \newskip\contentsrightmargin \contentsrightmargin=1in
6566 \newcount\savepageno
6567 \newcount\lastnegativepageno \lastnegativepageno = -1
6568
6569 % Prepare to read what we've written to \tocfile.
6570 %
6571 \def\startcontents#1{%
6572   % If @setchapternewpage on, and @headings double, the contents should
6573   % start on an odd page, unlike chapters.  Thus, we maintain
6574   % \contentsalignmacro in parallel with \pagealignmacro.
6575   % From: Torbjorn Granlund <tege@matematik.su.se>
6576   \contentsalignmacro
6577   \immediate\closeout\tocfile
6578   %
6579   % Don't need to put `Contents' or `Short Contents' in the headline.
6580   % It is abundantly clear what they are.
6581   \chapmacro{#1}{Yomitfromtoc}{}%
6582   %
6583   \savepageno = \pageno
6584   \begingroup                  % Set up to handle contents files properly.
6585     \raggedbottom              % Worry more about breakpoints than the bottom.
6586     \entryrightmargin=\contentsrightmargin % Don't use the full line length.
6587     %
6588     % Roman numerals for page numbers.
6589     \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
6590 }
6591
6592 % redefined for the two-volume lispref.  We always output on
6593 % \jobname.toc even if this is redefined.
6594 %
6595 \def\tocreadfilename{\jobname.toc}
6596
6597 % Normal (long) toc.
6598 %
6599 \def\contents{%
6600   \startcontents{\putwordTOC}%
6601     \openin 1 \tocreadfilename\space
6602     \ifeof 1 \else
6603       \readtocfile
6604     \fi
6605     \vfill \eject
6606     \contentsalignmacro % in case @setchapternewpage odd is in effect
6607     \ifeof 1 \else
6608       \pdfmakeoutlines
6609     \fi
6610     \closein 1
6611   \endgroup
6612   \lastnegativepageno = \pageno
6613   \global\pageno = \savepageno
6614 }
6615
6616 % And just the chapters.
6617 \def\summarycontents{%
6618   \startcontents{\putwordShortTOC}%
6619     %
6620     \let\partentry = \shortpartentry
6621     \let\numchapentry = \shortchapentry
6622     \let\appentry = \shortchapentry
6623     \let\unnchapentry = \shortunnchapentry
6624     % We want a true roman here for the page numbers.
6625     \secfonts
6626     \let\rm=\shortcontrm \let\bf=\shortcontbf
6627     \let\sl=\shortcontsl \let\tt=\shortconttt
6628     \rm
6629     \hyphenpenalty = 10000
6630     \advance\baselineskip by 1pt % Open it up a little.
6631     \def\numsecentry##1##2##3##4{}
6632     \let\appsecentry = \numsecentry
6633     \let\unnsecentry = \numsecentry
6634     \let\numsubsecentry = \numsecentry
6635     \let\appsubsecentry = \numsecentry
6636     \let\unnsubsecentry = \numsecentry
6637     \let\numsubsubsecentry = \numsecentry
6638     \let\appsubsubsecentry = \numsecentry
6639     \let\unnsubsubsecentry = \numsecentry
6640     \openin 1 \tocreadfilename\space
6641     \ifeof 1 \else
6642       \readtocfile
6643     \fi
6644     \closein 1
6645     \vfill \eject
6646     \contentsalignmacro % in case @setchapternewpage odd is in effect
6647   \endgroup
6648   \lastnegativepageno = \pageno
6649   \global\pageno = \savepageno
6650 }
6651 \let\shortcontents = \summarycontents
6652
6653 % Typeset the label for a chapter or appendix for the short contents.
6654 % The arg is, e.g., `A' for an appendix, or `3' for a chapter.
6655 %
6656 \def\shortchaplabel#1{%
6657   % This space should be enough, since a single number is .5em, and the
6658   % widest letter (M) is 1em, at least in the Computer Modern fonts.
6659   % But use \hss just in case.
6660   % (This space doesn't include the extra space that gets added after
6661   % the label; that gets put in by \shortchapentry above.)
6662   %
6663   % We'd like to right-justify chapter numbers, but that looks strange
6664   % with appendix letters.  And right-justifying numbers and
6665   % left-justifying letters looks strange when there is less than 10
6666   % chapters.  Have to read the whole toc once to know how many chapters
6667   % there are before deciding ...
6668   \hbox to 1em{#1\hss}%
6669 }
6670
6671 % These macros generate individual entries in the table of contents.
6672 % The first argument is the chapter or section name.
6673 % The last argument is the page number.
6674 % The arguments in between are the chapter number, section number, ...
6675
6676 % Parts, in the main contents.  Replace the part number, which doesn't
6677 % exist, with an empty box.  Let's hope all the numbers have the same width.
6678 % Also ignore the page number, which is conventionally not printed.
6679 \def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}}
6680 \def\partentry#1#2#3#4{\dochapentry{\numeralbox\labelspace#1}{}}
6681 %
6682 % Parts, in the short toc.
6683 \def\shortpartentry#1#2#3#4{%
6684   \penalty-300
6685   \vskip.5\baselineskip plus.15\baselineskip minus.1\baselineskip
6686   \shortchapentry{{\bf #1}}{\numeralbox}{}{}%
6687 }
6688
6689 % Chapters, in the main contents.
6690 \def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}}
6691
6692 % Chapters, in the short toc.
6693 % See comments in \dochapentry re vbox and related settings.
6694 \def\shortchapentry#1#2#3#4{%
6695   \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}%
6696 }
6697
6698 % Appendices, in the main contents.
6699 % Need the word Appendix, and a fixed-size box.
6700 %
6701 \def\appendixbox#1{%
6702   % We use M since it's probably the widest letter.
6703   \setbox0 = \hbox{\putwordAppendix{} M}%
6704   \hbox to \wd0{\putwordAppendix{} #1\hss}}
6705 %
6706 \def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\hskip.7em#1}{#4}}
6707
6708 % Unnumbered chapters.
6709 \def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}}
6710 \def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}}
6711
6712 % Sections.
6713 \def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}}
6714 \let\appsecentry=\numsecentry
6715 \def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}}
6716
6717 % Subsections.
6718 \def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}}
6719 \let\appsubsecentry=\numsubsecentry
6720 \def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}}
6721
6722 % And subsubsections.
6723 \def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}}
6724 \let\appsubsubsecentry=\numsubsubsecentry
6725 \def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}}
6726
6727 % This parameter controls the indentation of the various levels.
6728 % Same as \defaultparindent.
6729 \newdimen\tocindent \tocindent = 15pt
6730
6731 % Now for the actual typesetting. In all these, #1 is the text and #2 is the
6732 % page number.
6733 %
6734 % If the toc has to be broken over pages, we want it to be at chapters
6735 % if at all possible; hence the \penalty.
6736 \def\dochapentry#1#2{%
6737    \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
6738    \begingroup
6739      % Move the page numbers slightly to the right
6740      \advance\entryrightmargin by -0.05em
6741      \chapentryfonts
6742      \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6743    \endgroup
6744    \nobreak\vskip .25\baselineskip plus.1\baselineskip
6745 }
6746
6747 \def\dosecentry#1#2{\begingroup
6748   \secentryfonts \leftskip=\tocindent
6749   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6750 \endgroup}
6751
6752 \def\dosubsecentry#1#2{\begingroup
6753   \subsecentryfonts \leftskip=2\tocindent
6754   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6755 \endgroup}
6756
6757 \def\dosubsubsecentry#1#2{\begingroup
6758   \subsubsecentryfonts \leftskip=3\tocindent
6759   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6760 \endgroup}
6761
6762 % We use the same \entry macro as for the index entries.
6763 \let\tocentry = \entry
6764
6765 % Space between chapter (or whatever) number and the title.
6766 \def\labelspace{\hskip1em \relax}
6767
6768 \def\dopageno#1{{\rm #1}}
6769 \def\doshortpageno#1{{\rm #1}}
6770
6771 \def\chapentryfonts{\secfonts \rm}
6772 \def\secentryfonts{\textfonts}
6773 \def\subsecentryfonts{\textfonts}
6774 \def\subsubsecentryfonts{\textfonts}
6775
6776
6777 \message{environments,}
6778 % @foo ... @end foo.
6779
6780 % @tex ... @end tex    escapes into raw TeX temporarily.
6781 % One exception: @ is still an escape character, so that @end tex works.
6782 % But \@ or @@ will get a plain @ character.
6783
6784 \envdef\tex{%
6785   \setupmarkupstyle{tex}%
6786   \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
6787   \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
6788   \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
6789   \catcode `\%=14
6790   \catcode `\+=\other
6791   \catcode `\"=\other
6792   \catcode `\|=\other
6793   \catcode `\<=\other
6794   \catcode `\>=\other
6795   \catcode `\`=\other
6796   \catcode `\'=\other
6797   \escapechar=`\\
6798   %
6799   % ' is active in math mode (mathcode"8000).  So reset it, and all our
6800   % other math active characters (just in case), to plain's definitions.
6801   \mathactive
6802   %
6803   % Inverse of the list at the beginning of the file.
6804   \let\b=\ptexb
6805   \let\bullet=\ptexbullet
6806   \let\c=\ptexc
6807   \let\,=\ptexcomma
6808   \let\.=\ptexdot
6809   \let\dots=\ptexdots
6810   \let\equiv=\ptexequiv
6811   \let\!=\ptexexclam
6812   \let\i=\ptexi
6813   \let\indent=\ptexindent
6814   \let\noindent=\ptexnoindent
6815   \let\{=\ptexlbrace
6816   \let\+=\tabalign
6817   \let\}=\ptexrbrace
6818   \let\/=\ptexslash
6819   \let\sp=\ptexsp
6820   \let\*=\ptexstar
6821   %\let\sup=\ptexsup % do not redefine, we want @sup to work in math mode
6822   \let\t=\ptext
6823   \expandafter \let\csname top\endcsname=\ptextop  % we've made it outer
6824   \let\frenchspacing=\plainfrenchspacing
6825   %
6826   \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
6827   \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
6828   \def\@{@}%
6829 }
6830 % There is no need to define \Etex.
6831
6832 % Define @lisp ... @end lisp.
6833 % @lisp environment forms a group so it can rebind things,
6834 % including the definition of @end lisp (which normally is erroneous).
6835
6836 % Amount to narrow the margins by for @lisp.
6837 \newskip\lispnarrowing \lispnarrowing=0.4in
6838
6839 % This is the definition that ^^M gets inside @lisp, @example, and other
6840 % such environments.  \null is better than a space, since it doesn't
6841 % have any width.
6842 \def\lisppar{\null\endgraf}
6843
6844 % This space is always present above and below environments.
6845 \newskip\envskipamount \envskipamount = 0pt
6846
6847 % Make spacing and below environment symmetrical.  We use \parskip here
6848 % to help in doing that, since in @example-like environments \parskip
6849 % is reset to zero; thus the \afterenvbreak inserts no space -- but the
6850 % start of the next paragraph will insert \parskip.
6851 %
6852 \def\aboveenvbreak{{%
6853   % =10000 instead of <10000 because of a special case in \itemzzz and
6854   % \sectionheading, q.v.
6855   \ifnum \lastpenalty=10000 \else
6856     \advance\envskipamount by \parskip
6857     \endgraf
6858     \ifdim\lastskip<\envskipamount
6859       \removelastskip
6860       \ifnum\lastpenalty<10000
6861         % Penalize breaking before the environment, because preceding text
6862         % often leads into it.
6863         \penalty100
6864       \fi
6865       \vskip\envskipamount
6866     \fi
6867   \fi
6868 }}
6869
6870 \def\afterenvbreak{{%
6871   % =10000 instead of <10000 because of a special case in \itemzzz and
6872   % \sectionheading, q.v.
6873   \ifnum \lastpenalty=10000 \else
6874     \advance\envskipamount by \parskip
6875     \endgraf
6876     \ifdim\lastskip<\envskipamount
6877       \removelastskip
6878       % it's not a good place to break if the last penalty was \nobreak
6879       % or better ...
6880       \ifnum\lastpenalty<10000 \penalty-50 \fi
6881       \vskip\envskipamount
6882     \fi
6883   \fi
6884 }}
6885
6886 % \nonarrowing is a flag.  If "set", @lisp etc don't narrow margins; it will
6887 % also clear it, so that its embedded environments do the narrowing again.
6888 \let\nonarrowing=\relax
6889
6890 % @cartouche ... @end cartouche: draw rectangle w/rounded corners around
6891 % environment contents.
6892 \font\circle=lcircle10
6893 \newdimen\circthick
6894 \newdimen\cartouter\newdimen\cartinner
6895 \newskip\normbskip\newskip\normpskip\newskip\normlskip
6896 \circthick=\fontdimen8\circle
6897 %
6898 \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
6899 \def\ctr{{\hskip 6pt\circle\char'010}}
6900 \def\cbl{{\circle\char'012\hskip -6pt}}
6901 \def\cbr{{\hskip 6pt\circle\char'011}}
6902 \def\carttop{\hbox to \cartouter{\hskip\lskip
6903         \ctl\leaders\hrule height\circthick\hfil\ctr
6904         \hskip\rskip}}
6905 \def\cartbot{\hbox to \cartouter{\hskip\lskip
6906         \cbl\leaders\hrule height\circthick\hfil\cbr
6907         \hskip\rskip}}
6908 %
6909 \newskip\lskip\newskip\rskip
6910
6911 \envdef\cartouche{%
6912   \ifhmode\par\fi  % can't be in the midst of a paragraph.
6913   \startsavinginserts
6914   \lskip=\leftskip \rskip=\rightskip
6915   \leftskip=0pt\rightskip=0pt % we want these *outside*.
6916   \cartinner=\hsize \advance\cartinner by-\lskip
6917   \advance\cartinner by-\rskip
6918   \cartouter=\hsize
6919   \advance\cartouter by 18.4pt  % allow for 3pt kerns on either
6920                                 % side, and for 6pt waste from
6921                                 % each corner char, and rule thickness
6922   \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
6923   %
6924   % If this cartouche directly follows a sectioning command, we need the
6925   % \parskip glue (backspaced over by default) or the cartouche can
6926   % collide with the section heading.
6927   \ifnum\lastpenalty>10000 \vskip\parskip \penalty\lastpenalty \fi
6928   %
6929   \setbox\groupbox=\vbox\bgroup
6930       \baselineskip=0pt\parskip=0pt\lineskip=0pt
6931       \carttop
6932       \hbox\bgroup
6933           \hskip\lskip
6934           \vrule\kern3pt
6935           \vbox\bgroup
6936               \kern3pt
6937               \hsize=\cartinner
6938               \baselineskip=\normbskip
6939               \lineskip=\normlskip
6940               \parskip=\normpskip
6941               \vskip -\parskip
6942               \comment % For explanation, see the end of def\group.
6943 }
6944 \def\Ecartouche{%
6945               \ifhmode\par\fi
6946               \kern3pt
6947           \egroup
6948           \kern3pt\vrule
6949           \hskip\rskip
6950       \egroup
6951       \cartbot
6952   \egroup
6953   \addgroupbox
6954   \checkinserts
6955 }
6956
6957
6958 % This macro is called at the beginning of all the @example variants,
6959 % inside a group.
6960 \newdimen\nonfillparindent
6961 \def\nonfillstart{%
6962   \aboveenvbreak
6963   \ifdim\hfuzz < 12pt \hfuzz = 12pt \fi % Don't be fussy
6964   \sepspaces % Make spaces be word-separators rather than space tokens.
6965   \let\par = \lisppar % don't ignore blank lines
6966   \obeylines % each line of input is a line of output
6967   \parskip = 0pt
6968   % Turn off paragraph indentation but redefine \indent to emulate
6969   % the normal \indent.
6970   \nonfillparindent=\parindent
6971   \parindent = 0pt
6972   \let\indent\nonfillindent
6973   %
6974   \emergencystretch = 0pt % don't try to avoid overfull boxes
6975   \ifx\nonarrowing\relax
6976     \advance \leftskip by \lispnarrowing
6977     \exdentamount=\lispnarrowing
6978   \else
6979     \let\nonarrowing = \relax
6980   \fi
6981   \let\exdent=\nofillexdent
6982 }
6983
6984 \begingroup
6985 \obeyspaces
6986 % We want to swallow spaces (but not other tokens) after the fake
6987 % @indent in our nonfill-environments, where spaces are normally
6988 % active and set to @tie, resulting in them not being ignored after
6989 % @indent.
6990 \gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}%
6991 \gdef\nonfillindentcheck{%
6992 \ifx\temp %
6993 \expandafter\nonfillindentgobble%
6994 \else%
6995 \leavevmode\nonfillindentbox%
6996 \fi%
6997 }%
6998 \endgroup
6999 \def\nonfillindentgobble#1{\nonfillindent}
7000 \def\nonfillindentbox{\hbox to \nonfillparindent{\hss}}
7001
7002 % If you want all examples etc. small: @set dispenvsize small.
7003 % If you want even small examples the full size: @set dispenvsize nosmall.
7004 % This affects the following displayed environments:
7005 %    @example, @display, @format, @lisp
7006 %
7007 \def\smallword{small}
7008 \def\nosmallword{nosmall}
7009 \let\SETdispenvsize\relax
7010 \def\setnormaldispenv{%
7011   \ifx\SETdispenvsize\smallword
7012     % end paragraph for sake of leading, in case document has no blank
7013     % line.  This is redundant with what happens in \aboveenvbreak, but
7014     % we need to do it before changing the fonts, and it's inconvenient
7015     % to change the fonts afterward.
7016     \ifnum \lastpenalty=10000 \else \endgraf \fi
7017     \smallexamplefonts \rm
7018   \fi
7019 }
7020 \def\setsmalldispenv{%
7021   \ifx\SETdispenvsize\nosmallword
7022   \else
7023     \ifnum \lastpenalty=10000 \else \endgraf \fi
7024     \smallexamplefonts \rm
7025   \fi
7026 }
7027
7028 % We often define two environments, @foo and @smallfoo.
7029 % Let's do it in one command.  #1 is the env name, #2 the definition.
7030 \def\makedispenvdef#1#2{%
7031   \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}%
7032   \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}%
7033   \expandafter\let\csname E#1\endcsname \afterenvbreak
7034   \expandafter\let\csname Esmall#1\endcsname \afterenvbreak
7035 }
7036
7037 % Define two environment synonyms (#1 and #2) for an environment.
7038 \def\maketwodispenvdef#1#2#3{%
7039   \makedispenvdef{#1}{#3}%
7040   \makedispenvdef{#2}{#3}%
7041 }
7042 %
7043 % @lisp: indented, narrowed, typewriter font;
7044 % @example: same as @lisp.
7045 %
7046 % @smallexample and @smalllisp: use smaller fonts.
7047 % Originally contributed by Pavel@xerox.
7048 %
7049 \maketwodispenvdef{lisp}{example}{%
7050   \nonfillstart
7051   \tt\setupmarkupstyle{example}%
7052   \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
7053   \gobble % eat return
7054 }
7055 % @display/@smalldisplay: same as @lisp except keep current font.
7056 %
7057 \makedispenvdef{display}{%
7058   \nonfillstart
7059   \gobble
7060 }
7061
7062 % @format/@smallformat: same as @display except don't narrow margins.
7063 %
7064 \makedispenvdef{format}{%
7065   \let\nonarrowing = t%
7066   \nonfillstart
7067   \gobble
7068 }
7069
7070 % @flushleft: same as @format, but doesn't obey \SETdispenvsize.
7071 \envdef\flushleft{%
7072   \let\nonarrowing = t%
7073   \nonfillstart
7074   \gobble
7075 }
7076 \let\Eflushleft = \afterenvbreak
7077
7078 % @flushright.
7079 %
7080 \envdef\flushright{%
7081   \let\nonarrowing = t%
7082   \nonfillstart
7083   \advance\leftskip by 0pt plus 1fill\relax
7084   \gobble
7085 }
7086 \let\Eflushright = \afterenvbreak
7087
7088
7089 % @raggedright does more-or-less normal line breaking but no right
7090 % justification.  From plain.tex.  Don't stretch around special
7091 % characters in urls in this environment, since the stretch at the right
7092 % should be enough.
7093 \envdef\raggedright{%
7094   \rightskip0pt plus2.4em \spaceskip.3333em \xspaceskip.5em\relax
7095   \def\urefprestretchamount{0pt}%
7096   \def\urefpoststretchamount{0pt}%
7097 }
7098 \let\Eraggedright\par
7099
7100 \envdef\raggedleft{%
7101   \parindent=0pt \leftskip0pt plus2em
7102   \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
7103   \hbadness=10000 % Last line will usually be underfull, so turn off
7104                   % badness reporting.
7105 }
7106 \let\Eraggedleft\par
7107
7108 \envdef\raggedcenter{%
7109   \parindent=0pt \rightskip0pt plus1em \leftskip0pt plus1em
7110   \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
7111   \hbadness=10000 % Last line will usually be underfull, so turn off
7112                   % badness reporting.
7113 }
7114 \let\Eraggedcenter\par
7115
7116
7117 % @quotation does normal linebreaking (hence we can't use \nonfillstart)
7118 % and narrows the margins.  We keep \parskip nonzero in general, since
7119 % we're doing normal filling.  So, when using \aboveenvbreak and
7120 % \afterenvbreak, temporarily make \parskip 0.
7121 %
7122 \makedispenvdef{quotation}{\quotationstart}
7123 %
7124 \def\quotationstart{%
7125   \indentedblockstart % same as \indentedblock, but increase right margin too.
7126   \ifx\nonarrowing\relax
7127     \advance\rightskip by \lispnarrowing
7128   \fi
7129   \parsearg\quotationlabel
7130 }
7131
7132 % We have retained a nonzero parskip for the environment, since we're
7133 % doing normal filling.
7134 %
7135 \def\Equotation{%
7136   \par
7137   \ifx\quotationauthor\thisisundefined\else
7138     % indent a bit.
7139     \leftline{\kern 2\leftskip \sl ---\quotationauthor}%
7140   \fi
7141   {\parskip=0pt \afterenvbreak}%
7142 }
7143 \def\Esmallquotation{\Equotation}
7144
7145 % If we're given an argument, typeset it in bold with a colon after.
7146 \def\quotationlabel#1{%
7147   \def\temp{#1}%
7148   \ifx\temp\empty \else
7149     {\bf #1: }%
7150   \fi
7151 }
7152
7153 % @indentedblock is like @quotation, but indents only on the left and
7154 % has no optional argument.
7155
7156 \makedispenvdef{indentedblock}{\indentedblockstart}
7157 %
7158 \def\indentedblockstart{%
7159   {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
7160   \parindent=0pt
7161   %
7162   % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
7163   \ifx\nonarrowing\relax
7164     \advance\leftskip by \lispnarrowing
7165     \exdentamount = \lispnarrowing
7166   \else
7167     \let\nonarrowing = \relax
7168   \fi
7169 }
7170
7171 % Keep a nonzero parskip for the environment, since we're doing normal filling.
7172 %
7173 \def\Eindentedblock{%
7174   \par
7175   {\parskip=0pt \afterenvbreak}%
7176 }
7177 \def\Esmallindentedblock{\Eindentedblock}
7178
7179
7180 % LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>}
7181 % If we want to allow any <char> as delimiter,
7182 % we need the curly braces so that makeinfo sees the @verb command, eg:
7183 % `@verbx...x' would look like the '@verbx' command.  --janneke@gnu.org
7184 %
7185 % [Knuth]: Donald Ervin Knuth, 1996.  The TeXbook.
7186 %
7187 % [Knuth] p.344; only we need to do the other characters Texinfo sets
7188 % active too.  Otherwise, they get lost as the first character on a
7189 % verbatim line.
7190 \def\dospecials{%
7191   \do\ \do\\\do\{\do\}\do\$\do\&%
7192   \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~%
7193   \do\<\do\>\do\|\do\@\do+\do\"%
7194   % Don't do the quotes -- if we do, @set txicodequoteundirected and
7195   % @set txicodequotebacktick will not have effect on @verb and
7196   % @verbatim, and ?` and !` ligatures won't get disabled.
7197   %\do\`\do\'%
7198 }
7199 %
7200 % [Knuth] p. 380
7201 \def\uncatcodespecials{%
7202   \def\do##1{\catcode`##1=\other}\dospecials}
7203 %
7204 % Setup for the @verb command.
7205 %
7206 % Eight spaces for a tab
7207 \begingroup
7208   \catcode`\^^I=\active
7209   \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }}
7210 \endgroup
7211 %
7212 \def\setupverb{%
7213   \tt  % easiest (and conventionally used) font for verbatim
7214   \def\par{\leavevmode\endgraf}%
7215   \setupmarkupstyle{verb}%
7216   \tabeightspaces
7217   % Respect line breaks,
7218   % print special symbols as themselves, and
7219   % make each space count
7220   % must do in this order:
7221   \obeylines \uncatcodespecials \sepspaces
7222 }
7223
7224 % Setup for the @verbatim environment
7225 %
7226 % Real tab expansion.
7227 \newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
7228 %
7229 % We typeset each line of the verbatim in an \hbox, so we can handle
7230 % tabs.  The \global is in case the verbatim line starts with an accent,
7231 % or some other command that starts with a begin-group.  Otherwise, the
7232 % entire \verbbox would disappear at the corresponding end-group, before
7233 % it is typeset.  Meanwhile, we can't have nested verbatim commands
7234 % (can we?), so the \global won't be overwriting itself.
7235 \newbox\verbbox
7236 \def\starttabbox{\global\setbox\verbbox=\hbox\bgroup}
7237 %
7238 \begingroup
7239   \catcode`\^^I=\active
7240   \gdef\tabexpand{%
7241     \catcode`\^^I=\active
7242     \def^^I{\leavevmode\egroup
7243       \dimen\verbbox=\wd\verbbox % the width so far, or since the previous tab
7244       \divide\dimen\verbbox by\tabw
7245       \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw
7246       \advance\dimen\verbbox by\tabw  % advance to next multiple of \tabw
7247       \wd\verbbox=\dimen\verbbox \box\verbbox \starttabbox
7248     }%
7249   }
7250 \endgroup
7251
7252 % start the verbatim environment.
7253 \def\setupverbatim{%
7254   \let\nonarrowing = t%
7255   \nonfillstart
7256   \tt % easiest (and conventionally used) font for verbatim
7257   % The \leavevmode here is for blank lines.  Otherwise, we would
7258   % never \starttabox and the \egroup would end verbatim mode.
7259   \def\par{\leavevmode\egroup\box\verbbox\endgraf}%
7260   \tabexpand
7261   \setupmarkupstyle{verbatim}%
7262   % Respect line breaks,
7263   % print special symbols as themselves, and
7264   % make each space count.
7265   % Must do in this order:
7266   \obeylines \uncatcodespecials \sepspaces
7267   \everypar{\starttabbox}%
7268 }
7269
7270 % Do the @verb magic: verbatim text is quoted by unique
7271 % delimiter characters.  Before first delimiter expect a
7272 % right brace, after last delimiter expect closing brace:
7273 %
7274 %    \def\doverb'{'<char>#1<char>'}'{#1}
7275 %
7276 % [Knuth] p. 382; only eat outer {}
7277 \begingroup
7278   \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other
7279   \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next]
7280 \endgroup
7281 %
7282 \def\verb{\begingroup\setupverb\doverb}
7283 %
7284 %
7285 % Do the @verbatim magic: define the macro \doverbatim so that
7286 % the (first) argument ends when '@end verbatim' is reached, ie:
7287 %
7288 %     \def\doverbatim#1@end verbatim{#1}
7289 %
7290 % For Texinfo it's a lot easier than for LaTeX,
7291 % because texinfo's \verbatim doesn't stop at '\end{verbatim}':
7292 % we need not redefine '\', '{' and '}'.
7293 %
7294 % Inspired by LaTeX's verbatim command set [latex.ltx]
7295 %
7296 \begingroup
7297   \catcode`\ =\active
7298   \obeylines %
7299   % ignore everything up to the first ^^M, that's the newline at the end
7300   % of the @verbatim input line itself.  Otherwise we get an extra blank
7301   % line in the output.
7302   \xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}%
7303   % We really want {...\end verbatim} in the body of the macro, but
7304   % without the active space; thus we have to use \xdef and \gobble.
7305 \endgroup
7306 %
7307 \envdef\verbatim{%
7308     \setupverbatim\doverbatim
7309 }
7310 \let\Everbatim = \afterenvbreak
7311
7312
7313 % @verbatiminclude FILE - insert text of file in verbatim environment.
7314 %
7315 \def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude}
7316 %
7317 \def\doverbatiminclude#1{%
7318   {%
7319     \makevalueexpandable
7320     \setupverbatim
7321     \indexnofonts       % Allow `@@' and other weird things in file names.
7322     \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}%
7323     \input #1
7324     \afterenvbreak
7325   }%
7326 }
7327
7328 % @copying ... @end copying.
7329 % Save the text away for @insertcopying later.
7330 %
7331 % We save the uninterpreted tokens, rather than creating a box.
7332 % Saving the text in a box would be much easier, but then all the
7333 % typesetting commands (@smallbook, font changes, etc.) have to be done
7334 % beforehand -- and a) we want @copying to be done first in the source
7335 % file; b) letting users define the frontmatter in as flexible order as
7336 % possible is desirable.
7337 %
7338 \def\copying{\checkenv{}\begingroup\scanargctxt\docopying}
7339 \def\docopying#1@end copying{\endgroup\def\copyingtext{#1}}
7340 %
7341 \def\insertcopying{%
7342   \begingroup
7343     \parindent = 0pt  % paragraph indentation looks wrong on title page
7344     \scanexp\copyingtext
7345   \endgroup
7346 }
7347
7348
7349 \message{defuns,}
7350 % @defun etc.
7351
7352 \newskip\defbodyindent \defbodyindent=.4in
7353 \newskip\defargsindent \defargsindent=50pt
7354 \newskip\deflastargmargin \deflastargmargin=18pt
7355 \newcount\defunpenalty
7356
7357 % Start the processing of @deffn:
7358 \def\startdefun{%
7359   \ifnum\lastpenalty<10000
7360     \medbreak
7361     \defunpenalty=10003 % Will keep this @deffn together with the
7362                         % following @def command, see below.
7363   \else
7364     % If there are two @def commands in a row, we'll have a \nobreak,
7365     % which is there to keep the function description together with its
7366     % header.  But if there's nothing but headers, we need to allow a
7367     % break somewhere.  Check specifically for penalty 10002, inserted
7368     % by \printdefunline, instead of 10000, since the sectioning
7369     % commands also insert a nobreak penalty, and we don't want to allow
7370     % a break between a section heading and a defun.
7371     %
7372     % As a further refinement, we avoid "club" headers by signalling
7373     % with penalty of 10003 after the very first @deffn in the
7374     % sequence (see above), and penalty of 10002 after any following
7375     % @def command.
7376     \ifnum\lastpenalty=10002 \penalty2000 \else \defunpenalty=10002 \fi
7377     %
7378     % Similarly, after a section heading, do not allow a break.
7379     % But do insert the glue.
7380     \medskip  % preceded by discardable penalty, so not a breakpoint
7381   \fi
7382   %
7383   \parindent=0in
7384   \advance\leftskip by \defbodyindent
7385   \exdentamount=\defbodyindent
7386 }
7387
7388 \def\dodefunx#1{%
7389   % First, check whether we are in the right environment:
7390   \checkenv#1%
7391   %
7392   % As above, allow line break if we have multiple x headers in a row.
7393   % It's not a great place, though.
7394   \ifnum\lastpenalty=10002 \penalty3000 \else \defunpenalty=10002 \fi
7395   %
7396   % And now, it's time to reuse the body of the original defun:
7397   \expandafter\gobbledefun#1%
7398 }
7399 \def\gobbledefun#1\startdefun{}
7400
7401 % \printdefunline \deffnheader{text}
7402 %
7403 \def\printdefunline#1#2{%
7404   \begingroup
7405     % call \deffnheader:
7406     #1#2 \endheader
7407     % common ending:
7408     \interlinepenalty = 10000
7409     \advance\rightskip by 0pt plus 1fil\relax
7410     \endgraf
7411     \nobreak\vskip -\parskip
7412     \penalty\defunpenalty  % signal to \startdefun and \dodefunx
7413     % Some of the @defun-type tags do not enable magic parentheses,
7414     % rendering the following check redundant.  But we don't optimize.
7415     \checkparencounts
7416   \endgroup
7417 }
7418
7419 \def\Edefun{\endgraf\medbreak}
7420
7421 % \makedefun{deffn} creates \deffn, \deffnx and \Edeffn;
7422 % the only thing remaining is to define \deffnheader.
7423 %
7424 \def\makedefun#1{%
7425   \expandafter\let\csname E#1\endcsname = \Edefun
7426   \edef\temp{\noexpand\domakedefun
7427     \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}%
7428   \temp
7429 }
7430
7431 % \domakedefun \deffn \deffnx \deffnheader { (defn. of \deffnheader) }
7432 %
7433 % Define \deffn and \deffnx, without parameters.
7434 % \deffnheader has to be defined explicitly.
7435 %
7436 \def\domakedefun#1#2#3{%
7437   \envdef#1{%
7438     \startdefun
7439     \doingtypefnfalse    % distinguish typed functions from all else
7440     \parseargusing\activeparens{\printdefunline#3}%
7441   }%
7442   \def#2{\dodefunx#1}%
7443   \def#3%
7444 }
7445
7446 \newif\ifdoingtypefn       % doing typed function?
7447 \newif\ifrettypeownline    % typeset return type on its own line?
7448
7449 % @deftypefnnewline on|off says whether the return type of typed functions
7450 % are printed on their own line.  This affects @deftypefn, @deftypefun,
7451 % @deftypeop, and @deftypemethod.
7452
7453 \parseargdef\deftypefnnewline{%
7454   \def\temp{#1}%
7455   \ifx\temp\onword
7456     \expandafter\let\csname SETtxideftypefnnl\endcsname
7457       = \empty
7458   \else\ifx\temp\offword
7459     \expandafter\let\csname SETtxideftypefnnl\endcsname
7460       = \relax
7461   \else
7462     \errhelp = \EMsimple
7463     \errmessage{Unknown @txideftypefnnl value `\temp',
7464                 must be on|off}%
7465   \fi\fi
7466 }
7467
7468 % Untyped functions:
7469
7470 % @deffn category name args
7471 \makedefun{deffn}{\deffngeneral{}}
7472
7473 % @deffn category class name args
7474 \makedefun{defop}#1 {\defopon{#1\ \putwordon}}
7475
7476 % \defopon {category on}class name args
7477 \def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
7478
7479 % \deffngeneral {subind}category name args
7480 %
7481 \def\deffngeneral#1#2 #3 #4\endheader{%
7482   % Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}.
7483   \dosubind{fn}{\code{#3}}{#1}%
7484   \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
7485 }
7486
7487 % Typed functions:
7488
7489 % @deftypefn category type name args
7490 \makedefun{deftypefn}{\deftypefngeneral{}}
7491
7492 % @deftypeop category class type name args
7493 \makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}}
7494
7495 % \deftypeopon {category on}class type name args
7496 \def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
7497
7498 % \deftypefngeneral {subind}category type name args
7499 %
7500 \def\deftypefngeneral#1#2 #3 #4 #5\endheader{%
7501   \dosubind{fn}{\code{#4}}{#1}%
7502   \doingtypefntrue
7503   \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
7504 }
7505
7506 % Typed variables:
7507
7508 % @deftypevr category type var args
7509 \makedefun{deftypevr}{\deftypecvgeneral{}}
7510
7511 % @deftypecv category class type var args
7512 \makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}}
7513
7514 % \deftypecvof {category of}class type var args
7515 \def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} }
7516
7517 % \deftypecvgeneral {subind}category type var args
7518 %
7519 \def\deftypecvgeneral#1#2 #3 #4 #5\endheader{%
7520   \dosubind{vr}{\code{#4}}{#1}%
7521   \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
7522 }
7523
7524 % Untyped variables:
7525
7526 % @defvr category var args
7527 \makedefun{defvr}#1 {\deftypevrheader{#1} {} }
7528
7529 % @defcv category class var args
7530 \makedefun{defcv}#1 {\defcvof{#1\ \putwordof}}
7531
7532 % \defcvof {category of}class var args
7533 \def\defcvof#1#2 {\deftypecvof{#1}#2 {} }
7534
7535 % Types:
7536
7537 % @deftp category name args
7538 \makedefun{deftp}#1 #2 #3\endheader{%
7539   \doind{tp}{\code{#2}}%
7540   \defname{#1}{}{#2}\defunargs{#3\unskip}%
7541 }
7542
7543 % Remaining @defun-like shortcuts:
7544 \makedefun{defun}{\deffnheader{\putwordDeffunc} }
7545 \makedefun{defmac}{\deffnheader{\putwordDefmac} }
7546 \makedefun{defspec}{\deffnheader{\putwordDefspec} }
7547 \makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} }
7548 \makedefun{defvar}{\defvrheader{\putwordDefvar} }
7549 \makedefun{defopt}{\defvrheader{\putwordDefopt} }
7550 \makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} }
7551 \makedefun{defmethod}{\defopon\putwordMethodon}
7552 \makedefun{deftypemethod}{\deftypeopon\putwordMethodon}
7553 \makedefun{defivar}{\defcvof\putwordInstanceVariableof}
7554 \makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof}
7555
7556 % \defname, which formats the name of the @def (not the args).
7557 % #1 is the category, such as "Function".
7558 % #2 is the return type, if any.
7559 % #3 is the function name.
7560 %
7561 % We are followed by (but not passed) the arguments, if any.
7562 %
7563 \def\defname#1#2#3{%
7564   \par
7565   % Get the values of \leftskip and \rightskip as they were outside the @def...
7566   \advance\leftskip by -\defbodyindent
7567   %
7568   % Determine if we are typesetting the return type of a typed function
7569   % on a line by itself.
7570   \rettypeownlinefalse
7571   \ifdoingtypefn  % doing a typed function specifically?
7572     % then check user option for putting return type on its own line:
7573     \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else
7574       \rettypeownlinetrue
7575     \fi
7576   \fi
7577   %
7578   % How we'll format the category name.  Putting it in brackets helps
7579   % distinguish it from the body text that may end up on the next line
7580   % just below it.
7581   \def\temp{#1}%
7582   \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
7583   %
7584   % Figure out line sizes for the paragraph shape.  We'll always have at
7585   % least two.
7586   \tempnum = 2
7587   %
7588   % The first line needs space for \box0; but if \rightskip is nonzero,
7589   % we need only space for the part of \box0 which exceeds it:
7590   \dimen0=\hsize  \advance\dimen0 by -\wd0  \advance\dimen0 by \rightskip
7591   %
7592   % If doing a return type on its own line, we'll have another line.
7593   \ifrettypeownline
7594     \advance\tempnum by 1
7595     \def\maybeshapeline{0in \hsize}%
7596   \else
7597     \def\maybeshapeline{}%
7598   \fi
7599   %
7600   % The continuations:
7601   \dimen2=\hsize  \advance\dimen2 by -\defargsindent
7602   %
7603   % The final paragraph shape:
7604   \parshape \tempnum  0in \dimen0  \maybeshapeline  \defargsindent \dimen2
7605   %
7606   % Put the category name at the right margin.
7607   \noindent
7608   \hbox to 0pt{%
7609     \hfil\box0 \kern-\hsize
7610     % \hsize has to be shortened this way:
7611     \kern\leftskip
7612     % Intentionally do not respect \rightskip, since we need the space.
7613   }%
7614   %
7615   % Allow all lines to be underfull without complaint:
7616   \tolerance=10000 \hbadness=10000
7617   \exdentamount=\defbodyindent
7618   {%
7619     % defun fonts. We use typewriter by default (used to be bold) because:
7620     % . we're printing identifiers, they should be in tt in principle.
7621     % . in languages with many accents, such as Czech or French, it's
7622     %   common to leave accents off identifiers.  The result looks ok in
7623     %   tt, but exceedingly strange in rm.
7624     % . we don't want -- and --- to be treated as ligatures.
7625     % . this still does not fix the ?` and !` ligatures, but so far no
7626     %   one has made identifiers using them :).
7627     \df \tt
7628     \def\temp{#2}% text of the return type
7629     \ifx\temp\empty\else
7630       \tclose{\temp}% typeset the return type
7631       \ifrettypeownline
7632         % put return type on its own line; prohibit line break following:
7633         \hfil\vadjust{\nobreak}\break  
7634       \else
7635         \space  % type on same line, so just followed by a space
7636       \fi
7637     \fi           % no return type
7638     #3% output function name
7639   }%
7640   {\rm\enskip}% hskip 0.5 em of \tenrm
7641   %
7642   \boldbrax
7643   % arguments will be output next, if any.
7644 }
7645
7646 % Print arguments in slanted roman (not ttsl), inconsistently with using
7647 % tt for the name.  This is because literal text is sometimes needed in
7648 % the argument list (groff manual), and ttsl and tt are not very
7649 % distinguishable.  Prevent hyphenation at `-' chars.
7650 %
7651 \def\defunargs#1{%
7652   % use sl by default (not ttsl),
7653   % tt for the names.
7654   \df \sl \hyphenchar\font=0
7655   %
7656   % On the other hand, if an argument has two dashes (for instance), we
7657   % want a way to get ttsl.  We used to recommend @var for that, so
7658   % leave the code in, but it's strange for @var to lead to typewriter.
7659   % Nowadays we recommend @code, since the difference between a ttsl hyphen
7660   % and a tt hyphen is pretty tiny.  @code also disables ?` !`.
7661   \def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}%
7662   #1%
7663   \sl\hyphenchar\font=45
7664 }
7665
7666 % We want ()&[] to print specially on the defun line.
7667 %
7668 \def\activeparens{%
7669   \catcode`\(=\active \catcode`\)=\active
7670   \catcode`\[=\active \catcode`\]=\active
7671   \catcode`\&=\active
7672 }
7673
7674 % Make control sequences which act like normal parenthesis chars.
7675 \let\lparen = ( \let\rparen = )
7676
7677 % Be sure that we always have a definition for `(', etc.  For example,
7678 % if the fn name has parens in it, \boldbrax will not be in effect yet,
7679 % so TeX would otherwise complain about undefined control sequence.
7680 {
7681   \activeparens
7682   \global\let(=\lparen \global\let)=\rparen
7683   \global\let[=\lbrack \global\let]=\rbrack
7684   \global\let& = \&
7685
7686   \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
7687   \gdef\magicamp{\let&=\amprm}
7688 }
7689
7690 \newcount\parencount
7691
7692 % If we encounter &foo, then turn on ()-hacking afterwards
7693 \newif\ifampseen
7694 \def\amprm#1 {\ampseentrue{\bf\&#1 }}
7695
7696 \def\parenfont{%
7697   \ifampseen
7698     % At the first level, print parens in roman,
7699     % otherwise use the default font.
7700     \ifnum \parencount=1 \rm \fi
7701   \else
7702     % The \sf parens (in \boldbrax) actually are a little bolder than
7703     % the contained text.  This is especially needed for [ and ] .
7704     \sf
7705   \fi
7706 }
7707 \def\infirstlevel#1{%
7708   \ifampseen
7709     \ifnum\parencount=1
7710       #1%
7711     \fi
7712   \fi
7713 }
7714 \def\bfafterword#1 {#1 \bf}
7715
7716 \def\opnr{%
7717   \global\advance\parencount by 1
7718   {\parenfont(}%
7719   \infirstlevel \bfafterword
7720 }
7721 \def\clnr{%
7722   {\parenfont)}%
7723   \infirstlevel \sl
7724   \global\advance\parencount by -1
7725 }
7726
7727 \newcount\brackcount
7728 \def\lbrb{%
7729   \global\advance\brackcount by 1
7730   {\bf[}%
7731 }
7732 \def\rbrb{%
7733   {\bf]}%
7734   \global\advance\brackcount by -1
7735 }
7736
7737 \def\checkparencounts{%
7738   \ifnum\parencount=0 \else \badparencount \fi
7739   \ifnum\brackcount=0 \else \badbrackcount \fi
7740 }
7741 % these should not use \errmessage; the glibc manual, at least, actually
7742 % has such constructs (when documenting function pointers).
7743 \def\badparencount{%
7744   \message{Warning: unbalanced parentheses in @def...}%
7745   \global\parencount=0
7746 }
7747 \def\badbrackcount{%
7748   \message{Warning: unbalanced square brackets in @def...}%
7749   \global\brackcount=0
7750 }
7751
7752
7753 \message{macros,}
7754 % @macro.
7755
7756 % To do this right we need a feature of e-TeX, \scantokens,
7757 % which we arrange to emulate with a temporary file in ordinary TeX.
7758 \ifx\eTeXversion\thisisundefined
7759   \newwrite\macscribble
7760   \def\scantokens#1{%
7761     \toks0={#1}%
7762     \immediate\openout\macscribble=\jobname.tmp
7763     \immediate\write\macscribble{\the\toks0}%
7764     \immediate\closeout\macscribble
7765     \input \jobname.tmp
7766   }
7767 \fi
7768
7769 \let\aftermacroxxx\relax
7770 \def\aftermacro{\aftermacroxxx}
7771
7772 % alias because \c means cedilla in @tex or @math
7773 \let\texinfoc=\c
7774
7775 % Used at the time of macro expansion.
7776 % Argument is macro body with arguments substituted
7777 \def\scanmacro#1{%
7778   \newlinechar`\^^M
7779   \def\xprocessmacroarg{\eatspaces}%
7780   %
7781   % Process the macro body under the current catcode regime.
7782   \scantokens{#1\texinfoc}\aftermacro%
7783   %
7784   % The \c is to remove the \newlinechar added by \scantokens, and
7785   % can be noticed by \parsearg.
7786   %   The \aftermacro allows a \comment at the end of the macro definition
7787   % to duplicate itself past the final \newlinechar added by \scantokens:
7788   % this is used in the definition of \group to comment out a newline.  We
7789   % don't do the same for \c to support Texinfo files with macros that ended
7790   % with a @c, which should no longer be necessary.
7791   %   We avoid surrounding the call to \scantokens with \bgroup and \egroup
7792   % to allow macros to open or close groups themselves.
7793 }
7794
7795 % Used for copying and captions
7796 \def\scanexp#1{%
7797   \bgroup
7798   % Undo catcode changes of \startcontents and \printindex
7799   % When called from @insertcopying or (short)caption, we need active
7800   % backslash to get it printed correctly.
7801   % FIXME: This may not be needed.
7802   %\catcode`\@=0 \catcode`\\=\active \escapechar=`\@
7803   \edef\temp{\noexpand\scanmacro{#1}}%
7804   \temp
7805   \egroup
7806 }
7807
7808 \newcount\paramno   % Count of parameters
7809 \newtoks\macname    % Macro name
7810 \newif\ifrecursive  % Is it recursive?
7811
7812 % List of all defined macros in the form
7813 %    \definedummyword\macro1\definedummyword\macro2...
7814 % Currently is also contains all @aliases; the list can be split
7815 % if there is a need.
7816 \def\macrolist{}
7817
7818 % Add the macro to \macrolist
7819 \def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname}
7820 \def\addtomacrolistxxx#1{%
7821      \toks0 = \expandafter{\macrolist\definedummyword#1}%
7822      \xdef\macrolist{\the\toks0}%
7823 }
7824
7825 % Utility routines.
7826 % This does \let #1 = #2, with \csnames; that is,
7827 %   \let \csname#1\endcsname = \csname#2\endcsname
7828 % (except of course we have to play expansion games).
7829 %
7830 \def\cslet#1#2{%
7831   \expandafter\let
7832   \csname#1\expandafter\endcsname
7833   \csname#2\endcsname
7834 }
7835
7836 % Trim leading and trailing spaces off a string.
7837 % Concepts from aro-bend problem 15 (see CTAN).
7838 {\catcode`\@=11
7839 \gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }}
7840 \gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@}
7841 \gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @}
7842 \def\unbrace#1{#1}
7843 \unbrace{\gdef\trim@@@ #1 } #2@{#1}
7844 }
7845
7846 % Trim a single trailing ^^M off a string.
7847 {\catcode`\^^M=\other \catcode`\Q=3%
7848 \gdef\eatcr #1{\eatcra #1Q^^MQ}%
7849 \gdef\eatcra#1^^MQ{\eatcrb#1Q}%
7850 \gdef\eatcrb#1Q#2Q{#1}%
7851 }
7852
7853 % Macro bodies are absorbed as an argument in a context where
7854 % all characters are catcode 10, 11 or 12, except \ which is active
7855 % (as in normal texinfo). It is necessary to change the definition of \
7856 % to recognize macro arguments; this is the job of \mbodybackslash.
7857 %
7858 % Non-ASCII encodings make 8-bit characters active, so un-activate
7859 % them to avoid their expansion.  Must do this non-globally, to
7860 % confine the change to the current group.
7861 %
7862 % It's necessary to have hard CRs when the macro is executed. This is
7863 % done by making ^^M (\endlinechar) catcode 12 when reading the macro
7864 % body, and then making it the \newlinechar in \scanmacro.
7865 %
7866 \def\scanctxt{% used as subroutine
7867   \catcode`\"=\other
7868   \catcode`\+=\other
7869   \catcode`\<=\other
7870   \catcode`\>=\other
7871   \catcode`\^=\other
7872   \catcode`\_=\other
7873   \catcode`\|=\other
7874   \catcode`\~=\other
7875   \ifx\declaredencoding\ascii \else \setcharscatcodeothernonglobal \fi
7876 }
7877
7878 \def\scanargctxt{% used for copying and captions, not macros.
7879   \scanctxt
7880   \catcode`\@=\other
7881   \catcode`\\=\other
7882   \catcode`\^^M=\other
7883 }
7884
7885 \def\macrobodyctxt{% used for @macro definitions
7886   \scanctxt
7887   \catcode`\ =\other
7888   \catcode`\@=\other
7889   \catcode`\{=\other
7890   \catcode`\}=\other
7891   \catcode`\^^M=\other
7892   \usembodybackslash
7893 }
7894
7895 % Used when scanning braced macro arguments.  Note, however, that catcode
7896 % changes here are ineffectual if the macro invocation was nested inside
7897 % an argument to another Texinfo command.
7898 \def\macroargctxt{%
7899   \scanctxt
7900   \catcode`\ =\active
7901   \catcode`\^^M=\other
7902   \catcode`\\=\active
7903 }
7904
7905 \def\macrolineargctxt{% used for whole-line arguments without braces
7906   \scanctxt
7907   \catcode`\{=\other
7908   \catcode`\}=\other
7909 }
7910
7911 % \mbodybackslash is the definition of \ in @macro bodies.
7912 % It maps \foo\ => \csname macarg.foo\endcsname => #N
7913 % where N is the macro parameter number.
7914 % We define \csname macarg.\endcsname to be \realbackslash, so
7915 % \\ in macro replacement text gets you a backslash.
7916 %
7917 {\catcode`@=0 @catcode`@\=@active
7918  @gdef@usembodybackslash{@let\=@mbodybackslash}
7919  @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname}
7920 }
7921 \expandafter\def\csname macarg.\endcsname{\realbackslash}
7922
7923 \def\margbackslash#1{\char`\#1 }
7924
7925 \def\macro{\recursivefalse\parsearg\macroxxx}
7926 \def\rmacro{\recursivetrue\parsearg\macroxxx}
7927
7928 \def\macroxxx#1{%
7929   \getargs{#1}% now \macname is the macname and \argl the arglist
7930   \ifx\argl\empty       % no arguments
7931      \paramno=0\relax
7932   \else
7933      \expandafter\parsemargdef \argl;%
7934      \if\paramno>256\relax
7935        \ifx\eTeXversion\thisisundefined
7936          \errhelp = \EMsimple
7937          \errmessage{You need eTeX to compile a file with macros with more than 256 arguments}
7938        \fi
7939      \fi
7940   \fi
7941   \if1\csname ismacro.\the\macname\endcsname
7942      \message{Warning: redefining \the\macname}%
7943   \else
7944      \expandafter\ifx\csname \the\macname\endcsname \relax
7945      \else \errmessage{Macro name \the\macname\space already defined}\fi
7946      \global\cslet{macsave.\the\macname}{\the\macname}%
7947      \global\expandafter\let\csname ismacro.\the\macname\endcsname=1%
7948      \addtomacrolist{\the\macname}%
7949   \fi
7950   \begingroup \macrobodyctxt
7951   \ifrecursive \expandafter\parsermacbody
7952   \else \expandafter\parsemacbody
7953   \fi}
7954
7955 \parseargdef\unmacro{%
7956   \if1\csname ismacro.#1\endcsname
7957     \global\cslet{#1}{macsave.#1}%
7958     \global\expandafter\let \csname ismacro.#1\endcsname=0%
7959     % Remove the macro name from \macrolist:
7960     \begingroup
7961       \expandafter\let\csname#1\endcsname \relax
7962       \let\definedummyword\unmacrodo
7963       \xdef\macrolist{\macrolist}%
7964     \endgroup
7965   \else
7966     \errmessage{Macro #1 not defined}%
7967   \fi
7968 }
7969
7970 % Called by \do from \dounmacro on each macro.  The idea is to omit any
7971 % macro definitions that have been changed to \relax.
7972 %
7973 \def\unmacrodo#1{%
7974   \ifx #1\relax
7975     % remove this
7976   \else
7977     \noexpand\definedummyword \noexpand#1%
7978   \fi
7979 }
7980
7981 % \getargs -- Parse the arguments to a @macro line.  Set \macname to
7982 % the name of the macro, and \argl to the braced argument list.
7983 \def\getargs#1{\getargsxxx#1{}}
7984 \def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
7985 \def\getmacname#1 #2\relax{\macname={#1}}
7986 \def\getmacargs#1{\def\argl{#1}}
7987 % This made use of the feature that if the last token of a
7988 % <parameter list> is #, then the preceding argument is delimited by
7989 % an opening brace, and that opening brace is not consumed.
7990
7991 % Parse the optional {params} list to @macro or @rmacro.
7992 % Set \paramno to the number of arguments,
7993 % and \paramlist to a parameter text for the macro (e.g. #1,#2,#3 for a
7994 % three-param macro.)  Define \macarg.BLAH for each BLAH in the params
7995 % list to some hook where the argument is to be expanded.  If there are
7996 % less than 10 arguments that hook is to be replaced by ##N where N
7997 % is the position in that list, that is to say the macro arguments are to be
7998 % defined `a la TeX in the macro body.  
7999 %
8000 % That gets used by \mbodybackslash (above).
8001 %
8002 % If there are 10 or more arguments, a different technique is used: see
8003 % \parsemmanyargdef.
8004 %
8005 \def\parsemargdef#1;{%
8006   \paramno=0\def\paramlist{}%
8007   \let\hash\relax
8008   % \hash is redefined to `#' later to get it into definitions
8009   \let\processmacroarg\relax
8010   \parsemargdefxxx#1,;,%
8011   \ifnum\paramno<10\relax\else
8012     \paramno0\relax
8013     \parsemmanyargdef@@#1,;,% 10 or more arguments
8014   \fi
8015 }
8016 \def\parsemargdefxxx#1,{%
8017   \if#1;\let\next=\relax
8018   \else \let\next=\parsemargdefxxx
8019     \advance\paramno by 1
8020     \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
8021         {\processmacroarg{\hash\the\paramno}}%
8022     \edef\paramlist{\paramlist\hash\the\paramno,}%
8023   \fi\next}
8024
8025 % \parsemacbody, \parsermacbody
8026 %
8027 % Read recursive and nonrecursive macro bodies. (They're different since
8028 % rec and nonrec macros end differently.)
8029
8030 % We are in \macrobodyctxt, and the \xdef causes backslashshes in the macro 
8031 % body to be transformed.
8032 % Set \macrobody to the body of the macro, and call \defmacro.
8033 %
8034 {\catcode`\ =\other\long\gdef\parsemacbody#1@end macro{%
8035 \xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}%
8036 {\catcode`\ =\other\long\gdef\parsermacbody#1@end rmacro{%
8037 \xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}%
8038
8039 % Make @ a letter, so that we can make private-to-Texinfo macro names.
8040 \edef\texiatcatcode{\the\catcode`\@}
8041 \catcode `@=11\relax
8042
8043 %%%%%%%%%%%%%% Code for > 10 arguments only   %%%%%%%%%%%%%%%%%%
8044
8045 % If there are 10 or more arguments, a different technique is used, where the
8046 % hook remains in the body, and when macro is to be expanded the body is
8047 % processed again to replace the arguments.
8048 %
8049 % In that case, the hook is \the\toks N-1, and we simply set \toks N-1 to the
8050 % argument N value and then \edef the body (nothing else will expand because of
8051 % the catcode regime under which the body was input).
8052 %
8053 % If you compile with TeX (not eTeX), and you have macros with 10 or more
8054 % arguments, no macro can have more than 256 arguments (else error).
8055 %
8056 % In case that there are 10 or more arguments we parse again the arguments
8057 % list to set new definitions for the \macarg.BLAH macros corresponding to
8058 % each BLAH argument. It was anyhow needed to parse already once this list
8059 % in order to count the arguments, and as macros with at most 9 arguments
8060 % are by far more frequent than macro with 10 or more arguments, defining
8061 % twice the \macarg.BLAH macros does not cost too much processing power.
8062 \def\parsemmanyargdef@@#1,{%
8063   \if#1;\let\next=\relax
8064   \else 
8065     \let\next=\parsemmanyargdef@@
8066     \edef\tempb{\eatspaces{#1}}%
8067     \expandafter\def\expandafter\tempa
8068        \expandafter{\csname macarg.\tempb\endcsname}%
8069     % Note that we need some extra \noexpand\noexpand, this is because we
8070     % don't want \the  to be expanded in the \parsermacbody  as it uses an
8071     % \xdef .
8072     \expandafter\edef\tempa
8073       {\noexpand\noexpand\noexpand\the\toks\the\paramno}%
8074     \advance\paramno by 1\relax
8075   \fi\next}
8076
8077
8078 \let\endargs@\relax
8079 \let\nil@\relax
8080 \def\nilm@{\nil@}%
8081 \long\def\nillm@{\nil@}%
8082
8083 % This macro is expanded during the Texinfo macro expansion, not during its
8084 % definition.  It gets all the arguments' values and assigns them to macros
8085 % macarg.ARGNAME
8086 %
8087 % #1 is the macro name
8088 % #2 is the list of argument names
8089 % #3 is the list of argument values
8090 \def\getargvals@#1#2#3{%
8091   \def\macargdeflist@{}%
8092   \def\saveparamlist@{#2}% Need to keep a copy for parameter expansion.
8093   \def\paramlist{#2,\nil@}%
8094   \def\macroname{#1}%
8095   \begingroup
8096   \macroargctxt
8097   \def\argvaluelist{#3,\nil@}%
8098   \def\@tempa{#3}%
8099   \ifx\@tempa\empty
8100     \setemptyargvalues@
8101   \else
8102     \getargvals@@
8103   \fi
8104 }
8105 \def\getargvals@@{%
8106   \ifx\paramlist\nilm@
8107       % Some sanity check needed here that \argvaluelist is also empty.
8108       \ifx\argvaluelist\nillm@
8109       \else
8110         \errhelp = \EMsimple
8111         \errmessage{Too many arguments in macro `\macroname'!}%
8112       \fi
8113       \let\next\macargexpandinbody@
8114   \else
8115     \ifx\argvaluelist\nillm@
8116        % No more arguments values passed to macro.  Set remaining named-arg
8117        % macros to empty.
8118        \let\next\setemptyargvalues@
8119     \else
8120       % pop current arg name into \@tempb
8121       \def\@tempa##1{\pop@{\@tempb}{\paramlist}##1\endargs@}%
8122       \expandafter\@tempa\expandafter{\paramlist}%
8123        % pop current argument value into \@tempc
8124       \def\@tempa##1{\longpop@{\@tempc}{\argvaluelist}##1\endargs@}%
8125       \expandafter\@tempa\expandafter{\argvaluelist}%
8126        % Here \@tempb is the current arg name and \@tempc is the current arg value.
8127        % First place the new argument macro definition into \@tempd
8128        \expandafter\macname\expandafter{\@tempc}%
8129        \expandafter\let\csname macarg.\@tempb\endcsname\relax
8130        \expandafter\def\expandafter\@tempe\expandafter{%
8131          \csname macarg.\@tempb\endcsname}%
8132        \edef\@tempd{\long\def\@tempe{\the\macname}}%
8133        \push@\@tempd\macargdeflist@
8134        \let\next\getargvals@@
8135     \fi
8136   \fi
8137   \next
8138 }
8139
8140 \def\push@#1#2{%
8141   \expandafter\expandafter\expandafter\def
8142   \expandafter\expandafter\expandafter#2%
8143   \expandafter\expandafter\expandafter{%
8144   \expandafter#1#2}%
8145 }
8146
8147 % Replace arguments by their values in the macro body, and place the result
8148 % in macro \@tempa.
8149
8150 \def\macvalstoargs@{%
8151   %  To do this we use the property that token registers that are \the'ed
8152   % within an \edef  expand only once. So we are going to place all argument
8153   % values into respective token registers.
8154   %
8155   % First we save the token context, and initialize argument numbering.
8156   \begingroup
8157     \paramno0\relax
8158     % Then, for each argument number #N, we place the corresponding argument
8159     % value into a new token list register \toks#N
8160     \expandafter\putargsintokens@\saveparamlist@,;,%
8161     % Then, we expand the body so that argument are replaced by their
8162     % values. The trick for values not to be expanded themselves is that they
8163     % are within tokens and that tokens expand only once in an \edef .
8164     \edef\@tempc{\csname mac.\macroname .body\endcsname}%
8165     % Now we restore the token stack pointer to free the token list registers
8166     % which we have used, but we make sure that expanded body is saved after
8167     % group.
8168     \expandafter
8169   \endgroup
8170   \expandafter\def\expandafter\@tempa\expandafter{\@tempc}%
8171   }
8172
8173 % Define the named-macro outside of this group and then close this group. 
8174
8175 \def\macargexpandinbody@{% 
8176   \expandafter
8177   \endgroup
8178   \macargdeflist@
8179   % First the replace in body the macro arguments by their values, the result
8180   % is in \@tempa .
8181   \macvalstoargs@
8182   % Then we point at the \norecurse or \gobble (for recursive) macro value
8183   % with \@tempb .
8184   \expandafter\let\expandafter\@tempb\csname mac.\macroname .recurse\endcsname
8185   % Depending on whether it is recursive or not, we need some tailing
8186   % \egroup .
8187   \ifx\@tempb\gobble
8188      \let\@tempc\relax
8189   \else
8190      \let\@tempc\egroup
8191   \fi
8192   % And now we do the real job:
8193   \edef\@tempd{\noexpand\@tempb{\macroname}\noexpand\scanmacro{\@tempa}\@tempc}%
8194   \@tempd
8195 }
8196
8197 \def\putargsintokens@#1,{%
8198   \if#1;\let\next\relax
8199   \else
8200     \let\next\putargsintokens@
8201     % First we allocate the new token list register, and give it a temporary
8202     % alias \@tempb .
8203     \toksdef\@tempb\the\paramno
8204     % Then we place the argument value into that token list register.
8205     \expandafter\let\expandafter\@tempa\csname macarg.#1\endcsname
8206     \expandafter\@tempb\expandafter{\@tempa}%
8207     \advance\paramno by 1\relax
8208   \fi
8209   \next
8210 }
8211
8212 % Trailing missing arguments are set to empty.
8213
8214 \def\setemptyargvalues@{%
8215   \ifx\paramlist\nilm@
8216     \let\next\macargexpandinbody@
8217   \else
8218     \expandafter\setemptyargvaluesparser@\paramlist\endargs@
8219     \let\next\setemptyargvalues@
8220   \fi
8221   \next
8222 }
8223
8224 \def\setemptyargvaluesparser@#1,#2\endargs@{%
8225   \expandafter\def\expandafter\@tempa\expandafter{%
8226     \expandafter\def\csname macarg.#1\endcsname{}}%
8227   \push@\@tempa\macargdeflist@
8228   \def\paramlist{#2}%
8229 }
8230
8231 % #1 is the element target macro
8232 % #2 is the list macro
8233 % #3,#4\endargs@ is the list value
8234 \def\pop@#1#2#3,#4\endargs@{%
8235    \def#1{#3}%
8236    \def#2{#4}%
8237 }
8238 \long\def\longpop@#1#2#3,#4\endargs@{%
8239    \long\def#1{#3}%
8240    \long\def#2{#4}%
8241 }
8242
8243
8244 %%%%%%%%%%%%%% End of code for > 10 arguments %%%%%%%%%%%%%%%%%%
8245
8246
8247
8248 % Remove following spaces at the expansion stage.
8249 % This works because spaces are discarded before each argument when TeX is 
8250 % getting the arguments for a macro.
8251 % This must not be immediately followed by a }.
8252 \long\def\gobblespaces#1{#1}
8253
8254 % This defines a Texinfo @macro or @rmacro, called by \parsemacbody.
8255 %    \macrobody has the body of the macro in it, with placeholders for
8256 % its parameters, looking like "\processmacroarg{\hash 1}".
8257 %    \paramno is the number of parameters
8258 %    \paramlist is a TeX parameter text, e.g. "#1,#2,#3,"
8259 % There are eight cases: recursive and nonrecursive macros of zero, one,
8260 % up to nine, and many arguments.
8261 % \xdef is used so that macro definitions will survive the file
8262 % they're defined in: @include reads the file inside a group.
8263 %
8264 \def\defmacro{%
8265   \let\hash=##% convert placeholders to macro parameter chars
8266   \ifnum\paramno=1
8267     \def\processmacroarg{\gobblespaces}%
8268     % This removes the pair of braces around the argument.  We don't
8269     % use \eatspaces, because this can cause ends of lines to be lost
8270     % when the argument to \eatspaces is read, leading to line-based
8271     % commands like "@itemize" not being read correctly.
8272   \else
8273     \def\processmacroarg{\xprocessmacroarg}%
8274     \let\xprocessmacroarg\relax
8275   \fi
8276   \ifrecursive   %%%%%%%%%%%%%% Recursive %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8277     \ifcase\paramno
8278     % 0
8279       \expandafter\xdef\csname\the\macname\endcsname{%
8280         \noexpand\scanmacro{\macrobody}}%
8281     \or % 1
8282       \expandafter\xdef\csname\the\macname\endcsname{%
8283          \bgroup
8284          \noexpand\braceorline
8285          \expandafter\noexpand\csname\the\macname @@@\endcsname}%
8286       \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8287          \expandafter\noexpand\csname\the\macname @@@@\endcsname{%
8288            \noexpand\gobblespaces##1\empty}%
8289            % The \empty is for \gobblespaces in case #1 is empty
8290          }%
8291       \expandafter\xdef\csname\the\macname @@@@\endcsname##1{%
8292          \egroup\noexpand\scanmacro{\macrobody}}%
8293     \else
8294       \ifnum\paramno<10\relax % at most 9
8295         % See non-recursive section below for comments
8296         \expandafter\xdef\csname\the\macname\endcsname{%
8297           \bgroup
8298           \noexpand\expandafter
8299           \noexpand\macroargctxt
8300           \noexpand\expandafter
8301           \expandafter\noexpand\csname\the\macname @@\endcsname}%
8302         \expandafter\xdef\csname\the\macname @@\endcsname##1{%
8303             \noexpand\passargtomacro
8304             \expandafter\noexpand\csname\the\macname @@@\endcsname{##1,}}%
8305         \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8306             \expandafter\noexpand\csname\the\macname @@@@\endcsname ##1}%
8307         \expandafter\expandafter
8308         \expandafter\xdef
8309         \expandafter\expandafter
8310           \csname\the\macname @@@@\endcsname\paramlist{%
8311             \egroup\noexpand\scanmacro{\macrobody}}%
8312       \else % 10 or more
8313         \expandafter\xdef\csname\the\macname\endcsname{%
8314           \noexpand\getargvals@{\the\macname}{\argl}%
8315         }%    
8316         \global\expandafter\let\csname mac.\the\macname .body\endcsname\macrobody
8317         \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\gobble
8318       \fi
8319     \fi
8320   \else  %%%%%%%%%%%%%%%%%%%%%% Non-recursive %%%%%%%%%%%%%%%%%%%%%%%%%%
8321     \ifcase\paramno
8322     % 0
8323       \expandafter\xdef\csname\the\macname\endcsname{%
8324         \noexpand\scanmacro{\macrobody}}%
8325     \or % 1
8326       \expandafter\xdef\csname\the\macname\endcsname{%
8327          \bgroup
8328          \noexpand\braceorline
8329          \expandafter\noexpand\csname\the\macname @@@\endcsname}%
8330       \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8331          \expandafter\noexpand\csname\the\macname @@@@\endcsname{%
8332            \noexpand\gobblespaces##1\empty}%
8333            % The \empty is for \gobblespaces in case #1 is empty
8334          }%
8335       \expandafter\xdef\csname\the\macname @@@@\endcsname##1{%
8336         \egroup
8337         \noexpand\scanmacro{\macrobody}%
8338         }%
8339     \else % at most 9
8340       \ifnum\paramno<10\relax
8341         % @MACNAME sets the context for reading the macro argument
8342         % @MACNAME@@ gets the argument, processes backslashes and appends a 
8343         % comma.
8344         % @MACNAME@@@ removes braces surrounding the argument list.
8345         % @MACNAME@@@@ scans the macro body with arguments substituted.
8346         \expandafter\xdef\csname\the\macname\endcsname{%
8347           \bgroup
8348           \noexpand\expandafter  % This \expandafter skip any spaces after the
8349           \noexpand\macroargctxt % macro before we change the catcode of space.
8350           \noexpand\expandafter
8351           \expandafter\noexpand\csname\the\macname @@\endcsname}%
8352         \expandafter\xdef\csname\the\macname @@\endcsname##1{%
8353             \noexpand\passargtomacro
8354             \expandafter\noexpand\csname\the\macname @@@\endcsname{##1,}}%
8355         \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8356             \expandafter\noexpand\csname\the\macname @@@@\endcsname ##1}%
8357         \expandafter\expandafter
8358         \expandafter\xdef
8359         \expandafter\expandafter
8360           \csname\the\macname @@@@\endcsname\paramlist{%
8361             \egroup\noexpand\scanmacro{\macrobody}}%
8362       \else % 10 or more:
8363         \expandafter\xdef\csname\the\macname\endcsname{%
8364           \noexpand\getargvals@{\the\macname}{\argl}%
8365         }%
8366         \global\expandafter\let\csname mac.\the\macname .body\endcsname\macrobody
8367         \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\norecurse
8368       \fi
8369     \fi
8370   \fi}
8371
8372 \catcode `\@\texiatcatcode\relax % end private-to-Texinfo catcodes
8373
8374 \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
8375
8376
8377 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8378 %
8379 {\catcode`\@=0 \catcode`\\=13  % We need to manipulate \ so use @ as escape
8380 @catcode`@_=11  % private names
8381 @catcode`@!=11  % used as argument separator
8382
8383 % \passargtomacro#1#2 -
8384 % Call #1 with a list of tokens #2, with any doubled backslashes in #2
8385 % compressed to one.
8386 %
8387 % This implementation works by expansion, and not execution (so we cannot use 
8388 % \def or similar).  This reduces the risk of this failing in contexts where 
8389 % complete expansion is done with no execution (for example, in writing out to 
8390 % an auxiliary file for an index entry).
8391
8392 % State is kept in the input stream: the argument passed to
8393 % @look_ahead, @gobble_and_check_finish and @add_segment is
8394 %
8395 % THE_MACRO ARG_RESULT ! {PENDING_BS} NEXT_TOKEN  (... rest of input)
8396 %
8397 % where:
8398 % THE_MACRO - name of the macro we want to call
8399 % ARG_RESULT - argument list we build to pass to that macro
8400 % PENDING_BS - either a backslash or nothing
8401 % NEXT_TOKEN - used to look ahead in the input stream to see what's coming next
8402
8403 @gdef@passargtomacro#1#2{%
8404   @add_segment #1!{}@relax#2\@_finish\%
8405 }
8406 @gdef@_finish{@_finishx} @global@let@_finishx@relax
8407
8408 % #1 - THE_MACRO ARG_RESULT
8409 % #2 - PENDING_BS
8410 % #3 - NEXT_TOKEN
8411 % #4 used to look ahead
8412 %
8413 % If the next token is not a backslash, process the rest of the argument; 
8414 % otherwise, remove the next token.
8415 @gdef@look_ahead#1!#2#3#4{%
8416   @ifx#4\%
8417    @expandafter@gobble_and_check_finish 
8418   @else
8419    @expandafter@add_segment
8420   @fi#1!{#2}#4#4%
8421 }
8422
8423 % #1 - THE_MACRO ARG_RESULT
8424 % #2 - PENDING_BS
8425 % #3 - NEXT_TOKEN
8426 % #4 should be a backslash, which is gobbled.
8427 % #5 looks ahead
8428 %
8429 % Double backslash found.  Add a single backslash, and look ahead.
8430 @gdef@gobble_and_check_finish#1!#2#3#4#5{%
8431   @add_segment#1\!{}#5#5%
8432 }
8433
8434 @gdef@is_fi{@fi}
8435
8436 % #1 - THE_MACRO ARG_RESULT
8437 % #2 - PENDING_BS
8438 % #3 - NEXT_TOKEN
8439 % #4 is input stream until next backslash
8440 %
8441 % Input stream is either at the start of the argument, or just after a 
8442 % backslash sequence, either a lone backslash, or a doubled backslash.  
8443 % NEXT_TOKEN contains the first token in the input stream: if it is \finish, 
8444 % finish; otherwise, append to ARG_RESULT the segment of the argument up until
8445 % the next backslash.  PENDING_BACKSLASH contains a backslash to represent
8446 % a backslash just before the start of the input stream that has not been
8447 % added to ARG_RESULT.
8448 @gdef@add_segment#1!#2#3#4\{%
8449 @ifx#3@_finish
8450   @call_the_macro#1!%
8451 @else
8452   % append the pending backslash to the result, followed by the next segment
8453   @expandafter@is_fi@look_ahead#1#2#4!{\}@fi
8454   % this @fi is discarded by @look_ahead.
8455   % we can't get rid of it with \expandafter because we don't know how 
8456   % long #4 is.
8457 }
8458
8459 % #1 - THE_MACRO
8460 % #2 - ARG_RESULT
8461 % #3 discards the res of the conditional in @add_segment, and @is_fi ends the 
8462 % conditional.
8463 @gdef@call_the_macro#1#2!#3@fi{@is_fi #1{#2}}
8464
8465 }
8466 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8467
8468 % \braceorline MAC is used for a one-argument macro MAC.  It checks
8469 % whether the next non-whitespace character is a {.  It sets the context
8470 % for reading the argument (slightly different in the two cases).  Then,
8471 % to read the argument, in the whole-line case, it then calls the regular
8472 % \parsearg MAC; in the lbrace case, it calls \passargtomacro MAC.
8473
8474 \def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx}
8475 \def\braceorlinexxx{%
8476   \ifx\nchar\bgroup
8477     \macroargctxt
8478     \expandafter\passargtomacro
8479   \else
8480     \macrolineargctxt\expandafter\parsearg
8481   \fi \macnamexxx}
8482
8483
8484 % @alias.
8485 % We need some trickery to remove the optional spaces around the equal
8486 % sign.  Make them active and then expand them all to nothing.
8487 %
8488 \def\alias{\parseargusing\obeyspaces\aliasxxx}
8489 \def\aliasxxx #1{\aliasyyy#1\relax}
8490 \def\aliasyyy #1=#2\relax{%
8491   {%
8492     \expandafter\let\obeyedspace=\empty
8493     \addtomacrolist{#1}%
8494     \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}%
8495   }%
8496   \next
8497 }
8498
8499
8500 \message{cross references,}
8501
8502 \newwrite\auxfile
8503 \newif\ifhavexrefs    % True if xref values are known.
8504 \newif\ifwarnedxrefs  % True if we warned once that they aren't known.
8505
8506 % @inforef is relatively simple.
8507 \def\inforef #1{\inforefzzz #1,,,,**}
8508 \def\inforefzzz #1,#2,#3,#4**{%
8509   \putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
8510   node \samp{\ignorespaces#1{}}}
8511
8512 % @node's only job in TeX is to define \lastnode, which is used in
8513 % cross-references.  The @node line might or might not have commas, and
8514 % might or might not have spaces before the first comma, like:
8515 % @node foo , bar , ...
8516 % We don't want such trailing spaces in the node name.
8517 %
8518 \parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse}
8519 %
8520 % also remove a trailing comma, in case of something like this:
8521 % @node Help-Cross,  ,  , Cross-refs
8522 \def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse}
8523 \def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}}
8524
8525 \let\nwnode=\node
8526 \let\lastnode=\empty
8527
8528 % Write a cross-reference definition for the current node.  #1 is the
8529 % type (Ynumbered, Yappendix, Ynothing).
8530 %
8531 \def\donoderef#1{%
8532   \ifx\lastnode\empty\else
8533     \setref{\lastnode}{#1}%
8534     \global\let\lastnode=\empty
8535   \fi
8536 }
8537
8538 % @anchor{NAME} -- define xref target at arbitrary point.
8539 %
8540 \newcount\savesfregister
8541 %
8542 \def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi}
8543 \def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi}
8544 \def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces}
8545
8546 % \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an
8547 % anchor), which consists of three parts:
8548 % 1) NAME-title - the current sectioning name taken from \lastsection,
8549 %                 or the anchor name.
8550 % 2) NAME-snt   - section number and type, passed as the SNT arg, or
8551 %                 empty for anchors.
8552 % 3) NAME-pg    - the page number.
8553 %
8554 % This is called from \donoderef, \anchor, and \dofloat.  In the case of
8555 % floats, there is an additional part, which is not written here:
8556 % 4) NAME-lof   - the text as it should appear in a @listoffloats.
8557 %
8558 \def\setref#1#2{%
8559   \pdfmkdest{#1}%
8560   \iflinks
8561     {%
8562       \requireauxfile
8563       \atdummies  % preserve commands, but don't expand them
8564       \edef\writexrdef##1##2{%
8565         \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef
8566           ##1}{##2}}% these are parameters of \writexrdef
8567       }%
8568       \toks0 = \expandafter{\lastsection}%
8569       \immediate \writexrdef{title}{\the\toks0 }%
8570       \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc.
8571       \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout
8572     }%
8573   \fi
8574 }
8575
8576 % @xrefautosectiontitle on|off says whether @section(ing) names are used
8577 % automatically in xrefs, if the third arg is not explicitly specified.
8578 % This was provided as a "secret" @set xref-automatic-section-title
8579 % variable, now it's official.
8580
8581 \parseargdef\xrefautomaticsectiontitle{%
8582   \def\temp{#1}%
8583   \ifx\temp\onword
8584     \expandafter\let\csname SETxref-automatic-section-title\endcsname
8585       = \empty
8586   \else\ifx\temp\offword
8587     \expandafter\let\csname SETxref-automatic-section-title\endcsname
8588       = \relax
8589   \else
8590     \errhelp = \EMsimple
8591     \errmessage{Unknown @xrefautomaticsectiontitle value `\temp',
8592                 must be on|off}%
8593   \fi\fi
8594 }
8595
8596\f
8597 % @xref, @pxref, and @ref generate cross-references.  For \xrefX, #1 is
8598 % the node name, #2 the name of the Info cross-reference, #3 the printed
8599 % node name, #4 the name of the Info file, #5 the name of the printed
8600 % manual.  All but the node name can be omitted.
8601 %
8602 \def\pxref{\putwordsee{} \xrefXX}
8603 \def\xref{\putwordSee{} \xrefXX}
8604 \def\ref{\xrefXX}
8605
8606 \def\xrefXX#1{\def\xrefXXarg{#1}\futurelet\tokenafterxref\xrefXXX}
8607 \def\xrefXXX{\expandafter\xrefX\expandafter[\xrefXXarg,,,,,,,]}
8608 %
8609 \newbox\toprefbox
8610 \newbox\printedrefnamebox
8611 \newbox\infofilenamebox
8612 \newbox\printedmanualbox
8613 %
8614 \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
8615   \unsepspaces
8616   %
8617   % Get args without leading/trailing spaces.
8618   \def\printedrefname{\ignorespaces #3}%
8619   \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}%
8620   %
8621   \def\infofilename{\ignorespaces #4}%
8622   \setbox\infofilenamebox = \hbox{\infofilename\unskip}%
8623   %
8624   \def\printedmanual{\ignorespaces #5}%
8625   \setbox\printedmanualbox  = \hbox{\printedmanual\unskip}%
8626   %
8627   % If the printed reference name (arg #3) was not explicitly given in
8628   % the @xref, figure out what we want to use.
8629   \ifdim \wd\printedrefnamebox = 0pt
8630     % No printed node name was explicitly given.
8631     \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax
8632       % Not auto section-title: use node name inside the square brackets.
8633       \def\printedrefname{\ignorespaces #1}%
8634     \else
8635       % Auto section-title: use chapter/section title inside
8636       % the square brackets if we have it.
8637       \ifdim \wd\printedmanualbox > 0pt
8638         % It is in another manual, so we don't have it; use node name.
8639         \def\printedrefname{\ignorespaces #1}%
8640       \else
8641         \ifhavexrefs
8642           % We (should) know the real title if we have the xref values.
8643           \def\printedrefname{\refx{#1-title}{}}%
8644         \else
8645           % Otherwise just copy the Info node name.
8646           \def\printedrefname{\ignorespaces #1}%
8647         \fi%
8648       \fi
8649     \fi
8650   \fi
8651   %
8652   % Make link in pdf output.
8653   \ifpdf
8654     {\indexnofonts
8655      \turnoffactive
8656      \makevalueexpandable
8657      % This expands tokens, so do it after making catcode changes, so _
8658      % etc. don't get their TeX definitions.  This ignores all spaces in
8659      % #4, including (wrongly) those in the middle of the filename.
8660      \getfilename{#4}%
8661      %
8662      % This (wrongly) does not take account of leading or trailing
8663      % spaces in #1, which should be ignored.
8664      \edef\pdfxrefdest{#1}%
8665      \ifx\pdfxrefdest\empty
8666        \def\pdfxrefdest{Top}% no empty targets
8667      \else
8668        \txiescapepdf\pdfxrefdest  % escape PDF special chars
8669      \fi
8670      %
8671      \leavevmode
8672      \startlink attr{/Border [0 0 0]}%
8673      \ifnum\filenamelength>0
8674        goto file{\the\filename.pdf} name{\pdfxrefdest}%
8675      \else
8676        goto name{\pdfmkpgn{\pdfxrefdest}}%
8677      \fi
8678     }%
8679     \setcolor{\linkcolor}%
8680   \fi
8681   {%
8682     % Have to otherify everything special to allow the \csname to
8683     % include an _ in the xref name, etc.
8684     \indexnofonts
8685     \turnoffactive
8686     \expandafter\global\expandafter\let\expandafter\Xthisreftitle
8687       \csname XR#1-title\endcsname
8688   }%
8689   %
8690   % Float references are printed completely differently: "Figure 1.2"
8691   % instead of "[somenode], p.3".  \iffloat distinguishes them by
8692   % \Xthisreftitle being set to a magic string.
8693   \iffloat\Xthisreftitle
8694     % If the user specified the print name (third arg) to the ref,
8695     % print it instead of our usual "Figure 1.2".
8696     \ifdim\wd\printedrefnamebox = 0pt
8697       \refx{#1-snt}{}%
8698     \else
8699       \printedrefname
8700     \fi
8701     %
8702     % If the user also gave the printed manual name (fifth arg), append
8703     % "in MANUALNAME".
8704     \ifdim \wd\printedmanualbox > 0pt
8705       \space \putwordin{} \cite{\printedmanual}%
8706     \fi
8707   \else
8708     % node/anchor (non-float) references.
8709     % 
8710     % If we use \unhbox to print the node names, TeX does not insert
8711     % empty discretionaries after hyphens, which means that it will not
8712     % find a line break at a hyphen in a node names.  Since some manuals
8713     % are best written with fairly long node names, containing hyphens,
8714     % this is a loss.  Therefore, we give the text of the node name
8715     % again, so it is as if TeX is seeing it for the first time.
8716     % 
8717     \ifdim \wd\printedmanualbox > 0pt
8718       % Cross-manual reference with a printed manual name.
8719       % 
8720       \crossmanualxref{\cite{\printedmanual\unskip}}%
8721     %
8722     \else\ifdim \wd\infofilenamebox > 0pt
8723       % Cross-manual reference with only an info filename (arg 4), no
8724       % printed manual name (arg 5).  This is essentially the same as
8725       % the case above; we output the filename, since we have nothing else.
8726       % 
8727       \crossmanualxref{\code{\infofilename\unskip}}%
8728     %
8729     \else
8730       % Reference within this manual.
8731       %
8732       % _ (for example) has to be the character _ for the purposes of the
8733       % control sequence corresponding to the node, but it has to expand
8734       % into the usual \leavevmode...\vrule stuff for purposes of
8735       % printing. So we \turnoffactive for the \refx-snt, back on for the
8736       % printing, back off for the \refx-pg.
8737       {\turnoffactive
8738        % Only output a following space if the -snt ref is nonempty; for
8739        % @unnumbered and @anchor, it won't be.
8740        \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
8741        \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
8742       }%
8743       % output the `[mynode]' via the macro below so it can be overridden.
8744       \xrefprintnodename\printedrefname
8745       %
8746       % But we always want a comma and a space:
8747       ,\space
8748       %
8749       % output the `page 3'.
8750       \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
8751       % Add a , if xref followed by a space
8752       \if\space\noexpand\tokenafterxref ,%
8753       \else\ifx\        \tokenafterxref ,% @TAB
8754       \else\ifx\*\tokenafterxref ,%   @*
8755       \else\ifx\ \tokenafterxref ,%   @SPACE
8756       \else\ifx\
8757                 \tokenafterxref ,%    @NL
8758       \else\ifx\tie\tokenafterxref ,% @tie
8759       \fi\fi\fi\fi\fi\fi
8760     \fi\fi
8761   \fi
8762   \endlink
8763 \endgroup}
8764
8765 % Output a cross-manual xref to #1.  Used just above (twice).
8766
8767 % Only include the text "Section ``foo'' in" if the foo is neither
8768 % missing or Top.  Thus, @xref{,,,foo,The Foo Manual} outputs simply
8769 % "see The Foo Manual", the idea being to refer to the whole manual.
8770
8771 % But, this being TeX, we can't easily compare our node name against the
8772 % string "Top" while ignoring the possible spaces before and after in
8773 % the input.  By adding the arbitrary 7sp below, we make it much less
8774 % likely that a real node name would have the same width as "Top" (e.g.,
8775 % in a monospaced font).  Hopefully it will never happen in practice.
8776
8777 % For the same basic reason, we retypeset the "Top" at every
8778 % reference, since the current font is indeterminate.
8779
8780 \def\crossmanualxref#1{%
8781   \setbox\toprefbox = \hbox{Top\kern7sp}%
8782   \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}%
8783   \ifdim \wd2 > 7sp  % nonempty?
8784     \ifdim \wd2 = \wd\toprefbox \else  % same as Top?
8785       \putwordSection{} ``\printedrefname'' \putwordin{}\space
8786     \fi
8787   \fi
8788   #1%
8789 }
8790
8791 % This macro is called from \xrefX for the `[nodename]' part of xref
8792 % output.  It's a separate macro only so it can be changed more easily,
8793 % since square brackets don't work well in some documents.  Particularly
8794 % one that Bob is working on :).
8795 %
8796 \def\xrefprintnodename#1{[#1]}
8797
8798 % Things referred to by \setref.
8799 %
8800 \def\Ynothing{}
8801 \def\Yomitfromtoc{}
8802 \def\Ynumbered{%
8803   \ifnum\secno=0
8804     \putwordChapter@tie \the\chapno
8805   \else \ifnum\subsecno=0
8806     \putwordSection@tie \the\chapno.\the\secno
8807   \else \ifnum\subsubsecno=0
8808     \putwordSection@tie \the\chapno.\the\secno.\the\subsecno
8809   \else
8810     \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno
8811   \fi\fi\fi
8812 }
8813 \def\Yappendix{%
8814   \ifnum\secno=0
8815      \putwordAppendix@tie @char\the\appendixno{}%
8816   \else \ifnum\subsecno=0
8817      \putwordSection@tie @char\the\appendixno.\the\secno
8818   \else \ifnum\subsubsecno=0
8819     \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno
8820   \else
8821     \putwordSection@tie
8822       @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno
8823   \fi\fi\fi
8824 }
8825
8826 % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
8827 % If its value is nonempty, SUFFIX is output afterward.
8828 %
8829 \def\refx#1#2{%
8830   \requireauxfile
8831   {%
8832     \indexnofonts
8833     \otherbackslash
8834     \expandafter\global\expandafter\let\expandafter\thisrefX
8835       \csname XR#1\endcsname
8836   }%
8837   \ifx\thisrefX\relax
8838     % If not defined, say something at least.
8839     \angleleft un\-de\-fined\angleright
8840     \iflinks
8841       \ifhavexrefs
8842         {\toks0 = {#1}% avoid expansion of possibly-complex value
8843          \message{\linenumber Undefined cross reference `\the\toks0'.}}%
8844       \else
8845         \ifwarnedxrefs\else
8846           \global\warnedxrefstrue
8847           \message{Cross reference values unknown; you must run TeX again.}%
8848         \fi
8849       \fi
8850     \fi
8851   \else
8852     % It's defined, so just use it.
8853     \thisrefX
8854   \fi
8855   #2% Output the suffix in any case.
8856 }
8857
8858 % This is the macro invoked by entries in the aux file.  Usually it's
8859 % just a \def (we prepend XR to the control sequence name to avoid
8860 % collisions).  But if this is a float type, we have more work to do.
8861 %
8862 \def\xrdef#1#2{%
8863   {% The node name might contain 8-bit characters, which in our current
8864    % implementation are changed to commands like @'e.  Don't let these
8865    % mess up the control sequence name.
8866     \indexnofonts
8867     \turnoffactive
8868     \xdef\safexrefname{#1}%
8869   }%
8870   %
8871   \expandafter\gdef\csname XR\safexrefname\endcsname{#2}% remember this xref
8872   %
8873   % Was that xref control sequence that we just defined for a float?
8874   \expandafter\iffloat\csname XR\safexrefname\endcsname
8875     % it was a float, and we have the (safe) float type in \iffloattype.
8876     \expandafter\let\expandafter\floatlist
8877       \csname floatlist\iffloattype\endcsname
8878     %
8879     % Is this the first time we've seen this float type?
8880     \expandafter\ifx\floatlist\relax
8881       \toks0 = {\do}% yes, so just \do
8882     \else
8883       % had it before, so preserve previous elements in list.
8884       \toks0 = \expandafter{\floatlist\do}%
8885     \fi
8886     %
8887     % Remember this xref in the control sequence \floatlistFLOATTYPE,
8888     % for later use in \listoffloats.
8889     \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0
8890       {\safexrefname}}%
8891   \fi
8892 }
8893
8894 % If working on a large document in chapters, it is convenient to
8895 % be able to disable indexing, cross-referencing, and contents, for test runs.
8896 % This is done with @novalidate at the beginning of the file.
8897 %
8898 \newif\iflinks \linkstrue % by default we want the aux files.
8899 \let\novalidate = \linksfalse
8900
8901 % Used when writing to the aux file, or when using data from it.
8902 \def\requireauxfile{%
8903   \iflinks
8904     \tryauxfile
8905     % Open the new aux file.  TeX will close it automatically at exit.
8906     \immediate\openout\auxfile=\jobname.aux
8907   \fi
8908   \global\let\requireauxfile=\relax   % Only do this once.
8909 }
8910
8911 % Read the last existing aux file, if any.  No error if none exists.
8912 %
8913 \def\tryauxfile{%
8914   \openin 1 \jobname.aux
8915   \ifeof 1 \else
8916     \readdatafile{aux}%
8917     \global\havexrefstrue
8918   \fi
8919   \closein 1
8920 }
8921
8922 \def\setupdatafile{%
8923   \catcode`\^^@=\other
8924   \catcode`\^^A=\other
8925   \catcode`\^^B=\other
8926   \catcode`\^^C=\other
8927   \catcode`\^^D=\other
8928   \catcode`\^^E=\other
8929   \catcode`\^^F=\other
8930   \catcode`\^^G=\other
8931   \catcode`\^^H=\other
8932   \catcode`\^^K=\other
8933   \catcode`\^^L=\other
8934   \catcode`\^^N=\other
8935   \catcode`\^^P=\other
8936   \catcode`\^^Q=\other
8937   \catcode`\^^R=\other
8938   \catcode`\^^S=\other
8939   \catcode`\^^T=\other
8940   \catcode`\^^U=\other
8941   \catcode`\^^V=\other
8942   \catcode`\^^W=\other
8943   \catcode`\^^X=\other
8944   \catcode`\^^Z=\other
8945   \catcode`\^^[=\other
8946   \catcode`\^^\=\other
8947   \catcode`\^^]=\other
8948   \catcode`\^^^=\other
8949   \catcode`\^^_=\other
8950   % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc.
8951   % in xref tags, i.e., node names.  But since ^^e4 notation isn't
8952   % supported in the main text, it doesn't seem desirable.  Furthermore,
8953   % that is not enough: for node names that actually contain a ^
8954   % character, we would end up writing a line like this: 'xrdef {'hat
8955   % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first
8956   % argument, and \hat is not an expandable control sequence.  It could
8957   % all be worked out, but why?  Either we support ^^ or we don't.
8958   %
8959   % The other change necessary for this was to define \auxhat:
8960   % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter
8961   % and then to call \auxhat in \setq.
8962   %
8963   \catcode`\^=\other
8964   %
8965   % Special characters.  Should be turned off anyway, but...
8966   \catcode`\~=\other
8967   \catcode`\[=\other
8968   \catcode`\]=\other
8969   \catcode`\"=\other
8970   \catcode`\_=\other
8971   \catcode`\|=\other
8972   \catcode`\<=\other
8973   \catcode`\>=\other
8974   \catcode`\$=\other
8975   \catcode`\#=\other
8976   \catcode`\&=\other
8977   \catcode`\%=\other
8978   \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
8979   %
8980   % This is to support \ in node names and titles, since the \
8981   % characters end up in a \csname.  It's easier than
8982   % leaving it active and making its active definition an actual \
8983   % character.  What I don't understand is why it works in the *value*
8984   % of the xrdef.  Seems like it should be a catcode12 \, and that
8985   % should not typeset properly.  But it works, so I'm moving on for
8986   % now.  --karl, 15jan04.
8987   \catcode`\\=\other
8988   %
8989   % Make the characters 128-255 be printing characters.
8990   {\setcharscatcodeothernonglobal}%
8991   %
8992   % @ is our escape character in .aux files, and we need braces.
8993   \catcode`\{=1
8994   \catcode`\}=2
8995   \catcode`\@=0
8996 }
8997
8998 \def\readdatafile#1{%
8999 \begingroup
9000   \setupdatafile
9001   \input\jobname.#1
9002 \endgroup}
9003
9004
9005 \message{insertions,}
9006 % including footnotes.
9007
9008 \newcount \footnoteno
9009
9010 % The trailing space in the following definition for supereject is
9011 % vital for proper filling; pages come out unaligned when you do a
9012 % pagealignmacro call if that space before the closing brace is
9013 % removed. (Generally, numeric constants should always be followed by a
9014 % space to prevent strange expansion errors.)
9015 \def\supereject{\par\penalty -20000\footnoteno =0 }
9016
9017 % @footnotestyle is meaningful for Info output only.
9018 \let\footnotestyle=\comment
9019
9020 {\catcode `\@=11
9021 %
9022 % Auto-number footnotes.  Otherwise like plain.
9023 \gdef\footnote{%
9024   \global\advance\footnoteno by \@ne
9025   \edef\thisfootno{$^{\the\footnoteno}$}%
9026   %
9027   % In case the footnote comes at the end of a sentence, preserve the
9028   % extra spacing after we do the footnote number.
9029   \let\@sf\empty
9030   \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi
9031   %
9032   % Remove inadvertent blank space before typesetting the footnote number.
9033   \unskip
9034   \thisfootno\@sf
9035   \dofootnote
9036 }%
9037
9038 % Don't bother with the trickery in plain.tex to not require the
9039 % footnote text as a parameter.  Our footnotes don't need to be so general.
9040 %
9041 % Oh yes, they do; otherwise, @ifset (and anything else that uses
9042 % \parseargline) fails inside footnotes because the tokens are fixed when
9043 % the footnote is read.  --karl, 16nov96.
9044 %
9045 \gdef\dofootnote{%
9046   \insert\footins\bgroup
9047   %
9048   % Nested footnotes are not supported in TeX, that would take a lot
9049   % more work.  (\startsavinginserts does not suffice.)
9050   \let\footnote=\errfootnotenest
9051   %
9052   % We want to typeset this text as a normal paragraph, even if the
9053   % footnote reference occurs in (for example) a display environment.
9054   % So reset some parameters.
9055   \hsize=\pagewidth
9056   \interlinepenalty\interfootnotelinepenalty
9057   \splittopskip\ht\strutbox % top baseline for broken footnotes
9058   \splitmaxdepth\dp\strutbox
9059   \floatingpenalty\@MM
9060   \leftskip\z@skip
9061   \rightskip\z@skip
9062   \spaceskip\z@skip
9063   \xspaceskip\z@skip
9064   \parindent\defaultparindent
9065   %
9066   \smallfonts \rm
9067   %
9068   % Because we use hanging indentation in footnotes, a @noindent appears
9069   % to exdent this text, so make it be a no-op.  makeinfo does not use
9070   % hanging indentation so @noindent can still be needed within footnote
9071   % text after an @example or the like (not that this is good style).
9072   \let\noindent = \relax
9073   %
9074   % Hang the footnote text off the number.  Use \everypar in case the
9075   % footnote extends for more than one paragraph.
9076   \everypar = {\hang}%
9077   \textindent{\thisfootno}%
9078   %
9079   % Don't crash into the line above the footnote text.  Since this
9080   % expands into a box, it must come within the paragraph, lest it
9081   % provide a place where TeX can split the footnote.
9082   \footstrut
9083   %
9084   % Invoke rest of plain TeX footnote routine.
9085   \futurelet\next\fo@t
9086 }
9087 }%end \catcode `\@=11
9088
9089 \def\errfootnotenest{%
9090   \errhelp=\EMsimple
9091   \errmessage{Nested footnotes not supported in texinfo.tex,
9092     even though they work in makeinfo; sorry}
9093 }
9094
9095 \def\errfootnoteheading{%
9096   \errhelp=\EMsimple
9097   \errmessage{Footnotes in chapters, sections, etc., are not supported}
9098 }
9099
9100 % In case a @footnote appears in a vbox, save the footnote text and create
9101 % the real \insert just after the vbox finished.  Otherwise, the insertion
9102 % would be lost.
9103 % Similarly, if a @footnote appears inside an alignment, save the footnote
9104 % text to a box and make the \insert when a row of the table is finished.
9105 % And the same can be done for other insert classes.  --kasal, 16nov03.
9106 %
9107 % Replace the \insert primitive by a cheating macro.
9108 % Deeper inside, just make sure that the saved insertions are not spilled
9109 % out prematurely.
9110 %
9111 \def\startsavinginserts{%
9112   \ifx \insert\ptexinsert
9113     \let\insert\saveinsert
9114   \else
9115     \let\checkinserts\relax
9116   \fi
9117 }
9118
9119 % This \insert replacement works for both \insert\footins{foo} and
9120 % \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}.
9121 %
9122 \def\saveinsert#1{%
9123   \edef\next{\noexpand\savetobox \makeSAVEname#1}%
9124   \afterassignment\next
9125   % swallow the left brace
9126   \let\temp =
9127 }
9128 \def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}}
9129 \def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1}
9130
9131 \def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi}
9132
9133 \def\placesaveins#1{%
9134   \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname
9135     {\box#1}%
9136 }
9137
9138 % eat @SAVE -- beware, all of them have catcode \other:
9139 {
9140   \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials  %  ;-)
9141   \gdef\gobblesave @SAVE{}
9142 }
9143
9144 % initialization:
9145 \def\newsaveins #1{%
9146   \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}%
9147   \next
9148 }
9149 \def\newsaveinsX #1{%
9150   \csname newbox\endcsname #1%
9151   \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts
9152     \checksaveins #1}%
9153 }
9154
9155 % initialize:
9156 \let\checkinserts\empty
9157 \newsaveins\footins
9158 \newsaveins\margin
9159
9160
9161 % @image.  We use the macros from epsf.tex to support this.
9162 % If epsf.tex is not installed and @image is used, we complain.
9163 %
9164 % Check for and read epsf.tex up front.  If we read it only at @image
9165 % time, we might be inside a group, and then its definitions would get
9166 % undone and the next image would fail.
9167 \openin 1 = epsf.tex
9168 \ifeof 1 \else
9169   % Do not bother showing banner with epsf.tex v2.7k (available in
9170   % doc/epsf.tex and on ctan).
9171   \def\epsfannounce{\toks0 = }%
9172   \input epsf.tex
9173 \fi
9174 \closein 1
9175 %
9176 % We will only complain once about lack of epsf.tex.
9177 \newif\ifwarnednoepsf
9178 \newhelp\noepsfhelp{epsf.tex must be installed for images to
9179   work.  It is also included in the Texinfo distribution, or you can get
9180   it from ftp://tug.org/tex/epsf.tex.}
9181 %
9182 \def\image#1{%
9183   \ifx\epsfbox\thisisundefined
9184     \ifwarnednoepsf \else
9185       \errhelp = \noepsfhelp
9186       \errmessage{epsf.tex not found, images will be ignored}%
9187       \global\warnednoepsftrue
9188     \fi
9189   \else
9190     \imagexxx #1,,,,,\finish
9191   \fi
9192 }
9193 %
9194 % Arguments to @image:
9195 % #1 is (mandatory) image filename; we tack on .eps extension.
9196 % #2 is (optional) width, #3 is (optional) height.
9197 % #4 is (ignored optional) html alt text.
9198 % #5 is (ignored optional) extension.
9199 % #6 is just the usual extra ignored arg for parsing stuff.
9200 \newif\ifimagevmode
9201 \def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup
9202   \catcode`\^^M = 5     % in case we're inside an example
9203   \normalturnoffactive  % allow _ et al. in names
9204   \def\xprocessmacroarg{\eatspaces}% in case we are being used via a macro
9205   % If the image is by itself, center it.
9206   \ifvmode
9207     \imagevmodetrue
9208   \else \ifx\centersub\centerV
9209     % for @center @image, we need a vbox so we can have our vertical space
9210     \imagevmodetrue
9211     \vbox\bgroup % vbox has better behavior than vtop herev
9212   \fi\fi
9213   %
9214   \ifimagevmode
9215     \nobreak\medskip
9216     % Usually we'll have text after the image which will insert
9217     % \parskip glue, so insert it here too to equalize the space
9218     % above and below.
9219     \nobreak\vskip\parskip
9220     \nobreak
9221   \fi
9222   %
9223   % Leave vertical mode so that indentation from an enclosing
9224   %  environment such as @quotation is respected.
9225   % However, if we're at the top level, we don't want the
9226   %  normal paragraph indentation.
9227   % On the other hand, if we are in the case of @center @image, we don't
9228   %  want to start a paragraph, which will create a hsize-width box and
9229   %  eradicate the centering.
9230   \ifx\centersub\centerV\else \noindent \fi
9231   %
9232   % Output the image.
9233   \ifpdf
9234     % For pdfTeX and LuaTeX <= 0.80
9235     \dopdfimage{#1}{#2}{#3}%
9236   \else
9237     \ifx\XeTeXrevision\thisisundefined
9238       % For epsf.tex
9239       % \epsfbox itself resets \epsf?size at each figure.
9240       \setbox0 = \hbox{\ignorespaces #2}%
9241         \ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
9242       \setbox0 = \hbox{\ignorespaces #3}%
9243         \ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
9244       \epsfbox{#1.eps}%
9245     \else
9246       % For XeTeX
9247       \doxeteximage{#1}{#2}{#3}%
9248     \fi
9249   \fi
9250   %
9251   \ifimagevmode
9252     \medskip  % space after a standalone image
9253   \fi  
9254   \ifx\centersub\centerV \egroup \fi
9255 \endgroup}
9256
9257
9258 % @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables,
9259 % etc.  We don't actually implement floating yet, we always include the
9260 % float "here".  But it seemed the best name for the future.
9261 %
9262 \envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish}
9263
9264 % There may be a space before second and/or third parameter; delete it.
9265 \def\eatcommaspace#1, {#1,}
9266
9267 % #1 is the optional FLOATTYPE, the text label for this float, typically
9268 % "Figure", "Table", "Example", etc.  Can't contain commas.  If omitted,
9269 % this float will not be numbered and cannot be referred to.
9270 %
9271 % #2 is the optional xref label.  Also must be present for the float to
9272 % be referable.
9273 %
9274 % #3 is the optional positioning argument; for now, it is ignored.  It
9275 % will somehow specify the positions allowed to float to (here, top, bottom).
9276 %
9277 % We keep a separate counter for each FLOATTYPE, which we reset at each
9278 % chapter-level command.
9279 \let\resetallfloatnos=\empty
9280 %
9281 \def\dofloat#1,#2,#3,#4\finish{%
9282   \let\thiscaption=\empty
9283   \let\thisshortcaption=\empty
9284   %
9285   % don't lose footnotes inside @float.
9286   %
9287   % BEWARE: when the floats start float, we have to issue warning whenever an
9288   % insert appears inside a float which could possibly float. --kasal, 26may04
9289   %
9290   \startsavinginserts
9291   %
9292   % We can't be used inside a paragraph.
9293   \par
9294   %
9295   \vtop\bgroup
9296     \def\floattype{#1}%
9297     \def\floatlabel{#2}%
9298     \def\floatloc{#3}% we do nothing with this yet.
9299     %
9300     \ifx\floattype\empty
9301       \let\safefloattype=\empty
9302     \else
9303       {%
9304         % the floattype might have accents or other special characters,
9305         % but we need to use it in a control sequence name.
9306         \indexnofonts
9307         \turnoffactive
9308         \xdef\safefloattype{\floattype}%
9309       }%
9310     \fi
9311     %
9312     % If label is given but no type, we handle that as the empty type.
9313     \ifx\floatlabel\empty \else
9314       % We want each FLOATTYPE to be numbered separately (Figure 1,
9315       % Table 1, Figure 2, ...).  (And if no label, no number.)
9316       %
9317       \expandafter\getfloatno\csname\safefloattype floatno\endcsname
9318       \global\advance\floatno by 1
9319       %
9320       {%
9321         % This magic value for \lastsection is output by \setref as the
9322         % XREFLABEL-title value.  \xrefX uses it to distinguish float
9323         % labels (which have a completely different output format) from
9324         % node and anchor labels.  And \xrdef uses it to construct the
9325         % lists of floats.
9326         %
9327         \edef\lastsection{\floatmagic=\safefloattype}%
9328         \setref{\floatlabel}{Yfloat}%
9329       }%
9330     \fi
9331     %
9332     % start with \parskip glue, I guess.
9333     \vskip\parskip
9334     %
9335     % Don't suppress indentation if a float happens to start a section.
9336     \restorefirstparagraphindent
9337 }
9338
9339 % we have these possibilities:
9340 % @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap
9341 % @float Foo,lbl & no caption:    Foo 1.1
9342 % @float Foo & @caption{Cap}:     Foo: Cap
9343 % @float Foo & no caption:        Foo
9344 % @float ,lbl & Caption{Cap}:     1.1: Cap
9345 % @float ,lbl & no caption:       1.1
9346 % @float & @caption{Cap}:         Cap
9347 % @float & no caption:
9348 %
9349 \def\Efloat{%
9350     \let\floatident = \empty
9351     %
9352     % In all cases, if we have a float type, it comes first.
9353     \ifx\floattype\empty \else \def\floatident{\floattype}\fi
9354     %
9355     % If we have an xref label, the number comes next.
9356     \ifx\floatlabel\empty \else
9357       \ifx\floattype\empty \else % if also had float type, need tie first.
9358         \appendtomacro\floatident{\tie}%
9359       \fi
9360       % the number.
9361       \appendtomacro\floatident{\chaplevelprefix\the\floatno}%
9362     \fi
9363     %
9364     % Start the printed caption with what we've constructed in
9365     % \floatident, but keep it separate; we need \floatident again.
9366     \let\captionline = \floatident
9367     %
9368     \ifx\thiscaption\empty \else
9369       \ifx\floatident\empty \else
9370         \appendtomacro\captionline{: }% had ident, so need a colon between
9371       \fi
9372       %
9373       % caption text.
9374       \appendtomacro\captionline{\scanexp\thiscaption}%
9375     \fi
9376     %
9377     % If we have anything to print, print it, with space before.
9378     % Eventually this needs to become an \insert.
9379     \ifx\captionline\empty \else
9380       \vskip.5\parskip
9381       \captionline
9382       %
9383       % Space below caption.
9384       \vskip\parskip
9385     \fi
9386     %
9387     % If have an xref label, write the list of floats info.  Do this
9388     % after the caption, to avoid chance of it being a breakpoint.
9389     \ifx\floatlabel\empty \else
9390       % Write the text that goes in the lof to the aux file as
9391       % \floatlabel-lof.  Besides \floatident, we include the short
9392       % caption if specified, else the full caption if specified, else nothing.
9393       {%
9394         \requireauxfile
9395         \atdummies
9396         %
9397         % since we read the caption text in the macro world, where ^^M
9398         % is turned into a normal character, we have to scan it back, so
9399         % we don't write the literal three characters "^^M" into the aux file.
9400         \scanexp{%
9401           \xdef\noexpand\gtemp{%
9402             \ifx\thisshortcaption\empty
9403               \thiscaption
9404             \else
9405               \thisshortcaption
9406             \fi
9407           }%
9408         }%
9409         \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident
9410           \ifx\gtemp\empty \else : \gtemp \fi}}%
9411       }%
9412     \fi
9413   \egroup  % end of \vtop
9414   %
9415   % place the captured inserts
9416   %
9417   % BEWARE: when the floats start floating, we have to issue warning
9418   % whenever an insert appears inside a float which could possibly
9419   % float. --kasal, 26may04
9420   %
9421   \checkinserts
9422 }
9423
9424 % Append the tokens #2 to the definition of macro #1, not expanding either.
9425 %
9426 \def\appendtomacro#1#2{%
9427   \expandafter\def\expandafter#1\expandafter{#1#2}%
9428 }
9429
9430 % @caption, @shortcaption
9431 %
9432 \def\caption{\docaption\thiscaption}
9433 \def\shortcaption{\docaption\thisshortcaption}
9434 \def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption}
9435 \def\defcaption#1#2{\egroup \def#1{#2}}
9436
9437 % The parameter is the control sequence identifying the counter we are
9438 % going to use.  Create it if it doesn't exist and assign it to \floatno.
9439 \def\getfloatno#1{%
9440   \ifx#1\relax
9441       % Haven't seen this figure type before.
9442       \csname newcount\endcsname #1%
9443       %
9444       % Remember to reset this floatno at the next chap.
9445       \expandafter\gdef\expandafter\resetallfloatnos
9446         \expandafter{\resetallfloatnos #1=0 }%
9447   \fi
9448   \let\floatno#1%
9449 }
9450
9451 % \setref calls this to get the XREFLABEL-snt value.  We want an @xref
9452 % to the FLOATLABEL to expand to "Figure 3.1".  We call \setref when we
9453 % first read the @float command.
9454 %
9455 \def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}%
9456
9457 % Magic string used for the XREFLABEL-title value, so \xrefX can
9458 % distinguish floats from other xref types.
9459 \def\floatmagic{!!float!!}
9460
9461 % #1 is the control sequence we are passed; we expand into a conditional
9462 % which is true if #1 represents a float ref.  That is, the magic
9463 % \lastsection value which we \setref above.
9464 %
9465 \def\iffloat#1{\expandafter\doiffloat#1==\finish}
9466 %
9467 % #1 is (maybe) the \floatmagic string.  If so, #2 will be the
9468 % (safe) float type for this float.  We set \iffloattype to #2.
9469 %
9470 \def\doiffloat#1=#2=#3\finish{%
9471   \def\temp{#1}%
9472   \def\iffloattype{#2}%
9473   \ifx\temp\floatmagic
9474 }
9475
9476 % @listoffloats FLOATTYPE - print a list of floats like a table of contents.
9477 %
9478 \parseargdef\listoffloats{%
9479   \def\floattype{#1}% floattype
9480   {%
9481     % the floattype might have accents or other special characters,
9482     % but we need to use it in a control sequence name.
9483     \indexnofonts
9484     \turnoffactive
9485     \xdef\safefloattype{\floattype}%
9486   }%
9487   %
9488   % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE.
9489   \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax
9490     \ifhavexrefs
9491       % if the user said @listoffloats foo but never @float foo.
9492       \message{\linenumber No `\safefloattype' floats to list.}%
9493     \fi
9494   \else
9495     \begingroup
9496       \leftskip=\tocindent  % indent these entries like a toc
9497       \let\do=\listoffloatsdo
9498       \csname floatlist\safefloattype\endcsname
9499     \endgroup
9500   \fi
9501 }
9502
9503 % This is called on each entry in a list of floats.  We're passed the
9504 % xref label, in the form LABEL-title, which is how we save it in the
9505 % aux file.  We strip off the -title and look up \XRLABEL-lof, which
9506 % has the text we're supposed to typeset here.
9507 %
9508 % Figures without xref labels will not be included in the list (since
9509 % they won't appear in the aux file).
9510 %
9511 \def\listoffloatsdo#1{\listoffloatsdoentry#1\finish}
9512 \def\listoffloatsdoentry#1-title\finish{{%
9513   % Can't fully expand XR#1-lof because it can contain anything.  Just
9514   % pass the control sequence.  On the other hand, XR#1-pg is just the
9515   % page number, and we want to fully expand that so we can get a link
9516   % in pdf output.
9517   \toksA = \expandafter{\csname XR#1-lof\endcsname}%
9518   %
9519   % use the same \entry macro we use to generate the TOC and index.
9520   \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}%
9521   \writeentry
9522 }}
9523
9524
9525 \message{localization,}
9526
9527 % For single-language documents, @documentlanguage is usually given very
9528 % early, just after @documentencoding.  Single argument is the language
9529 % (de) or locale (de_DE) abbreviation.
9530 %
9531 {
9532   \catcode`\_ = \active
9533   \globaldefs=1
9534 \parseargdef\documentlanguage{%
9535   \tex % read txi-??.tex file in plain TeX.
9536     % Read the file by the name they passed if it exists.
9537     \let_ = \normalunderscore  % normal _ character for filename test
9538     \openin 1 txi-#1.tex
9539     \ifeof 1
9540       \documentlanguagetrywithoutunderscore #1_\finish
9541     \else
9542       \globaldefs = 1  % everything in the txi-LL files needs to persist
9543       \input txi-#1.tex
9544     \fi
9545     \closein 1
9546   \endgroup % end raw TeX
9547 }
9548 %
9549 % If they passed de_DE, and txi-de_DE.tex doesn't exist,
9550 % try txi-de.tex.
9551 %
9552 \gdef\documentlanguagetrywithoutunderscore#1_#2\finish{%
9553   \openin 1 txi-#1.tex
9554   \ifeof 1
9555     \errhelp = \nolanghelp
9556     \errmessage{Cannot read language file txi-#1.tex}%
9557   \else
9558     \globaldefs = 1  % everything in the txi-LL files needs to persist
9559     \input txi-#1.tex
9560   \fi
9561   \closein 1
9562 }
9563 }% end of special _ catcode
9564 %
9565 \newhelp\nolanghelp{The given language definition file cannot be found or
9566 is empty.  Maybe you need to install it?  Putting it in the current
9567 directory should work if nowhere else does.}
9568
9569 % This macro is called from txi-??.tex files; the first argument is the
9570 % \language name to set (without the "\lang@" prefix), the second and
9571 % third args are \{left,right}hyphenmin.
9572 %
9573 % The language names to pass are determined when the format is built.
9574 % See the etex.log file created at that time, e.g.,
9575 % /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log.
9576 %
9577 % With TeX Live 2008, etex now includes hyphenation patterns for all
9578 % available languages.  This means we can support hyphenation in
9579 % Texinfo, at least to some extent.  (This still doesn't solve the
9580 % accented characters problem.)
9581 %
9582 \catcode`@=11
9583 \def\txisetlanguage#1#2#3{%
9584   % do not set the language if the name is undefined in the current TeX.
9585   \expandafter\ifx\csname lang@#1\endcsname \relax
9586     \message{no patterns for #1}%
9587   \else
9588     \global\language = \csname lang@#1\endcsname
9589   \fi
9590   % but there is no harm in adjusting the hyphenmin values regardless.
9591   \global\lefthyphenmin = #2\relax
9592   \global\righthyphenmin = #3\relax
9593 }
9594
9595 % XeTeX and LuaTeX can handle native Unicode.
9596 % Their default I/O is UTF-8 sequence instead of byte-wise.
9597 % Other TeX engine (pdfTeX etc.) I/O is byte-wise.
9598 %
9599 \newif\iftxinativeunicodecapable
9600 \newif\iftxiusebytewiseio
9601
9602 \ifx\XeTeXrevision\thisisundefined
9603   \ifx\luatexversion\thisisundefined
9604     \txinativeunicodecapablefalse
9605     \txiusebytewiseiotrue
9606   \else
9607     \txinativeunicodecapabletrue
9608     \txiusebytewiseiofalse
9609   \fi
9610 \else
9611   \txinativeunicodecapabletrue
9612   \txiusebytewiseiofalse
9613 \fi
9614
9615 % Set I/O by bytes instead of UTF-8 sequence for XeTeX and LuaTex
9616 % for non-UTF-8 (byte-wise) encodings.
9617 %
9618 \def\setbytewiseio{%
9619   \ifx\XeTeXrevision\thisisundefined
9620   \else
9621     \XeTeXdefaultencoding "bytes"  % For subsequent files to be read
9622     \XeTeXinputencoding "bytes"  % For document root file
9623     % Unfortunately, there seems to be no corresponding XeTeX command for
9624     % output encoding.  This is a problem for auxiliary index and TOC files.
9625     % The only solution would be perhaps to write out @U{...} sequences in
9626     % place of non-ASCII characters.
9627   \fi
9628
9629   \ifx\luatexversion\thisisundefined
9630   \else
9631     \directlua{
9632     local utf8_char, byte, gsub = unicode.utf8.char, string.byte, string.gsub
9633     local function convert_char (char)
9634       return utf8_char(byte(char))
9635     end
9636
9637     local function convert_line (line)
9638       return gsub(line, ".", convert_char)
9639     end
9640
9641     callback.register("process_input_buffer", convert_line)
9642
9643     local function convert_line_out (line)
9644       local line_out = ""
9645       for c in string.utfvalues(line) do
9646          line_out = line_out .. string.char(c)
9647       end
9648       return line_out
9649     end
9650
9651     callback.register("process_output_buffer", convert_line_out)
9652     }
9653   \fi
9654
9655   \txiusebytewiseiotrue
9656 }
9657
9658
9659 % Helpers for encodings.
9660 % Set the catcode of characters 128 through 255 to the specified number.
9661 %
9662 \def\setnonasciicharscatcode#1{%
9663    \count255=128
9664    \loop\ifnum\count255<256
9665       \global\catcode\count255=#1\relax
9666       \advance\count255 by 1
9667    \repeat
9668 }
9669
9670 \def\setnonasciicharscatcodenonglobal#1{%
9671    \count255=128
9672    \loop\ifnum\count255<256
9673       \catcode\count255=#1\relax
9674       \advance\count255 by 1
9675    \repeat
9676 }
9677
9678 % @documentencoding sets the definition of non-ASCII characters
9679 % according to the specified encoding.
9680 %
9681 \def\documentencoding{\parseargusing\filenamecatcodes\documentencodingzzz}
9682 \def\documentencodingzzz#1{%
9683   %
9684   % Encoding being declared for the document.
9685   \def\declaredencoding{\csname #1.enc\endcsname}%
9686   %
9687   % Supported encodings: names converted to tokens in order to be able
9688   % to compare them with \ifx.
9689   \def\ascii{\csname US-ASCII.enc\endcsname}%
9690   \def\latnine{\csname ISO-8859-15.enc\endcsname}%
9691   \def\latone{\csname ISO-8859-1.enc\endcsname}%
9692   \def\lattwo{\csname ISO-8859-2.enc\endcsname}%
9693   \def\utfeight{\csname UTF-8.enc\endcsname}%
9694   %
9695   \ifx \declaredencoding \ascii
9696      \asciichardefs
9697   %
9698   \else \ifx \declaredencoding \lattwo
9699      \iftxinativeunicodecapable
9700        \setbytewiseio
9701      \fi
9702      \setnonasciicharscatcode\active
9703      \lattwochardefs
9704   %
9705   \else \ifx \declaredencoding \latone
9706      \iftxinativeunicodecapable
9707        \setbytewiseio
9708      \fi
9709      \setnonasciicharscatcode\active
9710      \latonechardefs
9711   %
9712   \else \ifx \declaredencoding \latnine
9713      \iftxinativeunicodecapable
9714        \setbytewiseio
9715      \fi
9716      \setnonasciicharscatcode\active
9717      \latninechardefs
9718   %
9719   \else \ifx \declaredencoding \utfeight
9720      \iftxinativeunicodecapable
9721        % For native Unicode (XeTeX and LuaTeX)
9722        \nativeunicodechardefs
9723      \else
9724        % For UTF-8 byte sequence (TeX, eTeX and pdfTeX)
9725        \setnonasciicharscatcode\active
9726        % since we already invoked \utfeightchardefs at the top level
9727        % (below), do not re-invoke it, then our check for duplicated
9728        % definitions triggers.  Making non-ascii chars active is enough.
9729      \fi
9730   %
9731   \else
9732     \message{Ignoring unknown document encoding: #1.}%
9733   %
9734   \fi % utfeight
9735   \fi % latnine
9736   \fi % latone
9737   \fi % lattwo
9738   \fi % ascii
9739 }
9740
9741 % emacs-page
9742 % A message to be logged when using a character that isn't available
9743 % the default font encoding (OT1).
9744 %
9745 \def\missingcharmsg#1{\message{Character missing, sorry: #1.}}
9746
9747 % Take account of \c (plain) vs. \, (Texinfo) difference.
9748 \def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi}
9749
9750 % First, make active non-ASCII characters in order for them to be
9751 % correctly categorized when TeX reads the replacement text of
9752 % macros containing the character definitions.
9753 \setnonasciicharscatcode\active
9754 %
9755 % Latin1 (ISO-8859-1) character definitions.
9756 \def\latonechardefs{%
9757   \gdef^^a0{\tie}
9758   \gdef^^a1{\exclamdown}
9759   \gdef^^a2{{\tcfont \char162}} % cent
9760   \gdef^^a3{\pounds}
9761   \gdef^^a4{{\tcfont \char164}} % currency
9762   \gdef^^a5{{\tcfont \char165}} % yen
9763   \gdef^^a6{{\tcfont \char166}} % broken bar
9764   \gdef^^a7{\S}
9765   \gdef^^a8{\"{}}
9766   \gdef^^a9{\copyright}
9767   \gdef^^aa{\ordf}
9768   \gdef^^ab{\guillemetleft}
9769   \gdef^^ac{\ensuremath\lnot}
9770   \gdef^^ad{\-}
9771   \gdef^^ae{\registeredsymbol}
9772   \gdef^^af{\={}}
9773   %
9774   \gdef^^b0{\textdegree}
9775   \gdef^^b1{$\pm$}
9776   \gdef^^b2{$^2$}
9777   \gdef^^b3{$^3$}
9778   \gdef^^b4{\'{}}
9779   \gdef^^b5{$\mu$}
9780   \gdef^^b6{\P}
9781   \gdef^^b7{\ensuremath\cdot}
9782   \gdef^^b8{\cedilla\ }
9783   \gdef^^b9{$^1$}
9784   \gdef^^ba{\ordm}
9785   \gdef^^bb{\guillemetright}
9786   \gdef^^bc{$1\over4$}
9787   \gdef^^bd{$1\over2$}
9788   \gdef^^be{$3\over4$}
9789   \gdef^^bf{\questiondown}
9790   %
9791   \gdef^^c0{\`A}
9792   \gdef^^c1{\'A}
9793   \gdef^^c2{\^A}
9794   \gdef^^c3{\~A}
9795   \gdef^^c4{\"A}
9796   \gdef^^c5{\ringaccent A}
9797   \gdef^^c6{\AE}
9798   \gdef^^c7{\cedilla C}
9799   \gdef^^c8{\`E}
9800   \gdef^^c9{\'E}
9801   \gdef^^ca{\^E}
9802   \gdef^^cb{\"E}
9803   \gdef^^cc{\`I}
9804   \gdef^^cd{\'I}
9805   \gdef^^ce{\^I}
9806   \gdef^^cf{\"I}
9807   %
9808   \gdef^^d0{\DH}
9809   \gdef^^d1{\~N}
9810   \gdef^^d2{\`O}
9811   \gdef^^d3{\'O}
9812   \gdef^^d4{\^O}
9813   \gdef^^d5{\~O}
9814   \gdef^^d6{\"O}
9815   \gdef^^d7{$\times$}
9816   \gdef^^d8{\O}
9817   \gdef^^d9{\`U}
9818   \gdef^^da{\'U}
9819   \gdef^^db{\^U}
9820   \gdef^^dc{\"U}
9821   \gdef^^dd{\'Y}
9822   \gdef^^de{\TH}
9823   \gdef^^df{\ss}
9824   %
9825   \gdef^^e0{\`a}
9826   \gdef^^e1{\'a}
9827   \gdef^^e2{\^a}
9828   \gdef^^e3{\~a}
9829   \gdef^^e4{\"a}
9830   \gdef^^e5{\ringaccent a}
9831   \gdef^^e6{\ae}
9832   \gdef^^e7{\cedilla c}
9833   \gdef^^e8{\`e}
9834   \gdef^^e9{\'e}
9835   \gdef^^ea{\^e}
9836   \gdef^^eb{\"e}
9837   \gdef^^ec{\`{\dotless i}}
9838   \gdef^^ed{\'{\dotless i}}
9839   \gdef^^ee{\^{\dotless i}}
9840   \gdef^^ef{\"{\dotless i}}
9841   %
9842   \gdef^^f0{\dh}
9843   \gdef^^f1{\~n}
9844   \gdef^^f2{\`o}
9845   \gdef^^f3{\'o}
9846   \gdef^^f4{\^o}
9847   \gdef^^f5{\~o}
9848   \gdef^^f6{\"o}
9849   \gdef^^f7{$\div$}
9850   \gdef^^f8{\o}
9851   \gdef^^f9{\`u}
9852   \gdef^^fa{\'u}
9853   \gdef^^fb{\^u}
9854   \gdef^^fc{\"u}
9855   \gdef^^fd{\'y}
9856   \gdef^^fe{\th}
9857   \gdef^^ff{\"y}
9858 }
9859
9860 % Latin9 (ISO-8859-15) encoding character definitions.
9861 \def\latninechardefs{%
9862   % Encoding is almost identical to Latin1.
9863   \latonechardefs
9864   %
9865   \gdef^^a4{\euro}
9866   \gdef^^a6{\v S}
9867   \gdef^^a8{\v s}
9868   \gdef^^b4{\v Z}
9869   \gdef^^b8{\v z}
9870   \gdef^^bc{\OE}
9871   \gdef^^bd{\oe}
9872   \gdef^^be{\"Y}
9873 }
9874
9875 % Latin2 (ISO-8859-2) character definitions.
9876 \def\lattwochardefs{%
9877   \gdef^^a0{\tie}
9878   \gdef^^a1{\ogonek{A}}
9879   \gdef^^a2{\u{}}
9880   \gdef^^a3{\L}
9881   \gdef^^a4{\missingcharmsg{CURRENCY SIGN}}
9882   \gdef^^a5{\v L}
9883   \gdef^^a6{\'S}
9884   \gdef^^a7{\S}
9885   \gdef^^a8{\"{}}
9886   \gdef^^a9{\v S}
9887   \gdef^^aa{\cedilla S}
9888   \gdef^^ab{\v T}
9889   \gdef^^ac{\'Z}
9890   \gdef^^ad{\-}
9891   \gdef^^ae{\v Z}
9892   \gdef^^af{\dotaccent Z}
9893   %
9894   \gdef^^b0{\textdegree}
9895   \gdef^^b1{\ogonek{a}}
9896   \gdef^^b2{\ogonek{ }}
9897   \gdef^^b3{\l}
9898   \gdef^^b4{\'{}}
9899   \gdef^^b5{\v l}
9900   \gdef^^b6{\'s}
9901   \gdef^^b7{\v{}}
9902   \gdef^^b8{\cedilla\ }
9903   \gdef^^b9{\v s}
9904   \gdef^^ba{\cedilla s}
9905   \gdef^^bb{\v t}
9906   \gdef^^bc{\'z}
9907   \gdef^^bd{\H{}}
9908   \gdef^^be{\v z}
9909   \gdef^^bf{\dotaccent z}
9910   %
9911   \gdef^^c0{\'R}
9912   \gdef^^c1{\'A}
9913   \gdef^^c2{\^A}
9914   \gdef^^c3{\u A}
9915   \gdef^^c4{\"A}
9916   \gdef^^c5{\'L}
9917   \gdef^^c6{\'C}
9918   \gdef^^c7{\cedilla C}
9919   \gdef^^c8{\v C}
9920   \gdef^^c9{\'E}
9921   \gdef^^ca{\ogonek{E}}
9922   \gdef^^cb{\"E}
9923   \gdef^^cc{\v E}
9924   \gdef^^cd{\'I}
9925   \gdef^^ce{\^I}
9926   \gdef^^cf{\v D}
9927   %
9928   \gdef^^d0{\DH}
9929   \gdef^^d1{\'N}
9930   \gdef^^d2{\v N}
9931   \gdef^^d3{\'O}
9932   \gdef^^d4{\^O}
9933   \gdef^^d5{\H O}
9934   \gdef^^d6{\"O}
9935   \gdef^^d7{$\times$}
9936   \gdef^^d8{\v R}
9937   \gdef^^d9{\ringaccent U}
9938   \gdef^^da{\'U}
9939   \gdef^^db{\H U}
9940   \gdef^^dc{\"U}
9941   \gdef^^dd{\'Y}
9942   \gdef^^de{\cedilla T}
9943   \gdef^^df{\ss}
9944   %
9945   \gdef^^e0{\'r}
9946   \gdef^^e1{\'a}
9947   \gdef^^e2{\^a}
9948   \gdef^^e3{\u a}
9949   \gdef^^e4{\"a}
9950   \gdef^^e5{\'l}
9951   \gdef^^e6{\'c}
9952   \gdef^^e7{\cedilla c}
9953   \gdef^^e8{\v c}
9954   \gdef^^e9{\'e}
9955   \gdef^^ea{\ogonek{e}}
9956   \gdef^^eb{\"e}
9957   \gdef^^ec{\v e}
9958   \gdef^^ed{\'{\dotless{i}}}
9959   \gdef^^ee{\^{\dotless{i}}}
9960   \gdef^^ef{\v d}
9961   %
9962   \gdef^^f0{\dh}
9963   \gdef^^f1{\'n}
9964   \gdef^^f2{\v n}
9965   \gdef^^f3{\'o}
9966   \gdef^^f4{\^o}
9967   \gdef^^f5{\H o}
9968   \gdef^^f6{\"o}
9969   \gdef^^f7{$\div$}
9970   \gdef^^f8{\v r}
9971   \gdef^^f9{\ringaccent u}
9972   \gdef^^fa{\'u}
9973   \gdef^^fb{\H u}
9974   \gdef^^fc{\"u}
9975   \gdef^^fd{\'y}
9976   \gdef^^fe{\cedilla t}
9977   \gdef^^ff{\dotaccent{}}
9978 }
9979
9980 % UTF-8 character definitions.
9981 %
9982 % This code to support UTF-8 is based on LaTeX's utf8.def, with some
9983 % changes for Texinfo conventions.  It is included here under the GPL by
9984 % permission from Frank Mittelbach and the LaTeX team.
9985 %
9986 \newcount\countUTFx
9987 \newcount\countUTFy
9988 \newcount\countUTFz
9989
9990 \gdef\UTFviiiTwoOctets#1#2{\expandafter
9991    \UTFviiiDefined\csname u8:#1\string #2\endcsname}
9992 %
9993 \gdef\UTFviiiThreeOctets#1#2#3{\expandafter
9994    \UTFviiiDefined\csname u8:#1\string #2\string #3\endcsname}
9995 %
9996 \gdef\UTFviiiFourOctets#1#2#3#4{\expandafter
9997    \UTFviiiDefined\csname u8:#1\string #2\string #3\string #4\endcsname}
9998
9999 \gdef\UTFviiiDefined#1{%
10000   \ifx #1\relax
10001     \message{\linenumber Unicode char \string #1 not defined for Texinfo}%
10002   \else
10003     \expandafter #1%
10004   \fi
10005 }
10006
10007 \begingroup
10008   \catcode`\~13
10009   \catcode`\"12
10010
10011   \def\UTFviiiLoop{%
10012     \global\catcode\countUTFx\active
10013     \uccode`\~\countUTFx
10014     \uppercase\expandafter{\UTFviiiTmp}%
10015     \advance\countUTFx by 1
10016     \ifnum\countUTFx < \countUTFy
10017       \expandafter\UTFviiiLoop
10018     \fi}
10019
10020   \countUTFx = "C2
10021   \countUTFy = "E0
10022   \def\UTFviiiTmp{%
10023     \xdef~{\noexpand\UTFviiiTwoOctets\string~}}
10024   \UTFviiiLoop
10025
10026   \countUTFx = "E0
10027   \countUTFy = "F0
10028   \def\UTFviiiTmp{%
10029     \xdef~{\noexpand\UTFviiiThreeOctets\string~}}
10030   \UTFviiiLoop
10031
10032   \countUTFx = "F0
10033   \countUTFy = "F4
10034   \def\UTFviiiTmp{%
10035     \xdef~{\noexpand\UTFviiiFourOctets\string~}}
10036   \UTFviiiLoop
10037 \endgroup
10038
10039 \def\globallet{\global\let} % save some \expandafter's below
10040
10041 % @U{xxxx} to produce U+xxxx, if we support it.
10042 \def\U#1{%
10043   \expandafter\ifx\csname uni:#1\endcsname \relax
10044     \iftxinativeunicodecapable
10045       % Any Unicode characters can be used by native Unicode.
10046       % However, if the font does not have the glyph, the letter will miss.
10047       \begingroup
10048         \uccode`\.="#1\relax
10049         \uppercase{.}
10050       \endgroup
10051     \else
10052       \errhelp = \EMsimple      
10053       \errmessage{Unicode character U+#1 not supported, sorry}%
10054     \fi
10055   \else
10056     \csname uni:#1\endcsname
10057   \fi
10058 }
10059
10060 % For UTF-8 byte sequence (TeX, e-TeX and pdfTeX)
10061 % Definition macro to replace the Unicode character
10062 % Definition macro that is used by @U command
10063 %
10064 \begingroup
10065   \catcode`\"=12
10066   \catcode`\<=12
10067   \catcode`\.=12
10068   \catcode`\,=12
10069   \catcode`\;=12
10070   \catcode`\!=12
10071   \catcode`\~=13
10072   \gdef\DeclareUnicodeCharacterUTFviii#1#2{%
10073     \countUTFz = "#1\relax
10074     %\wlog{\space\space defining Unicode char U+#1 (decimal \the\countUTFz)}%
10075     \begingroup
10076       \parseXMLCharref
10077       \def\UTFviiiTwoOctets##1##2{%
10078         \csname u8:##1\string ##2\endcsname}%
10079       \def\UTFviiiThreeOctets##1##2##3{%
10080         \csname u8:##1\string ##2\string ##3\endcsname}%
10081       \def\UTFviiiFourOctets##1##2##3##4{%
10082         \csname u8:##1\string ##2\string ##3\string ##4\endcsname}%
10083       \expandafter\expandafter\expandafter\expandafter
10084        \expandafter\expandafter\expandafter
10085        \gdef\UTFviiiTmp{#2}%
10086       % 
10087       \expandafter\ifx\csname uni:#1\endcsname \relax \else
10088        \message{Internal error, already defined: #1}%
10089       \fi
10090       %
10091       % define an additional control sequence for this code point.
10092       \expandafter\globallet\csname uni:#1\endcsname \UTFviiiTmp
10093     \endgroup}
10094
10095   \gdef\parseXMLCharref{%
10096     \ifnum\countUTFz < "A0\relax
10097       \errhelp = \EMsimple
10098       \errmessage{Cannot define Unicode char value < 00A0}%
10099     \else\ifnum\countUTFz < "800\relax
10100       \parseUTFviiiA,%
10101       \parseUTFviiiB C\UTFviiiTwoOctets.,%
10102     \else\ifnum\countUTFz < "10000\relax
10103       \parseUTFviiiA;%
10104       \parseUTFviiiA,%
10105       \parseUTFviiiB E\UTFviiiThreeOctets.{,;}%
10106     \else
10107       \parseUTFviiiA;%
10108       \parseUTFviiiA,%
10109       \parseUTFviiiA!%
10110       \parseUTFviiiB F\UTFviiiFourOctets.{!,;}%
10111     \fi\fi\fi
10112   }
10113
10114   \gdef\parseUTFviiiA#1{%
10115     \countUTFx = \countUTFz
10116     \divide\countUTFz by 64
10117     \countUTFy = \countUTFz
10118     \multiply\countUTFz by 64
10119     \advance\countUTFx by -\countUTFz
10120     \advance\countUTFx by 128
10121     \uccode `#1\countUTFx
10122     \countUTFz = \countUTFy}
10123
10124   \gdef\parseUTFviiiB#1#2#3#4{%
10125     \advance\countUTFz by "#10\relax
10126     \uccode `#3\countUTFz
10127     \uppercase{\gdef\UTFviiiTmp{#2#3#4}}}
10128 \endgroup
10129
10130 % For native Unicode (XeTeX and LuaTeX)
10131 % Definition macro that is set catcode other non global
10132 %
10133 \def\DeclareUnicodeCharacterNativeOther#1#2{%
10134   \catcode"#1=\other
10135 }
10136
10137 % https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_M
10138 % U+0000..U+007F = https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block)
10139 % U+0080..U+00FF = https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)
10140 % U+0100..U+017F = https://en.wikipedia.org/wiki/Latin_Extended-A
10141 % U+0180..U+024F = https://en.wikipedia.org/wiki/Latin_Extended-B
10142
10143 % Many of our renditions are less than wonderful, and all the missing
10144 % characters are available somewhere.  Loading the necessary fonts
10145 % awaits user request.  We can't truly support Unicode without
10146 % reimplementing everything that's been done in LaTeX for many years,
10147 % plus probably using luatex or xetex, and who knows what else.
10148 % We won't be doing that here in this simple file.  But we can try to at
10149 % least make most of the characters not bomb out.
10150 %
10151 \def\unicodechardefs{%
10152   \DeclareUnicodeCharacter{00A0}{\tie}%
10153   \DeclareUnicodeCharacter{00A1}{\exclamdown}%
10154   \DeclareUnicodeCharacter{00A2}{{\tcfont \char162}}% 0242=cent
10155   \DeclareUnicodeCharacter{00A3}{\pounds}%
10156   \DeclareUnicodeCharacter{00A4}{{\tcfont \char164}}% 0244=currency
10157   \DeclareUnicodeCharacter{00A5}{{\tcfont \char165}}% 0245=yen
10158   \DeclareUnicodeCharacter{00A6}{{\tcfont \char166}}% 0246=brokenbar
10159   \DeclareUnicodeCharacter{00A7}{\S}%
10160   \DeclareUnicodeCharacter{00A8}{\"{ }}%
10161   \DeclareUnicodeCharacter{00A9}{\copyright}%
10162   \DeclareUnicodeCharacter{00AA}{\ordf}%
10163   \DeclareUnicodeCharacter{00AB}{\guillemetleft}%
10164   \DeclareUnicodeCharacter{00AC}{\ensuremath\lnot}%
10165   \DeclareUnicodeCharacter{00AD}{\-}%
10166   \DeclareUnicodeCharacter{00AE}{\registeredsymbol}%
10167   \DeclareUnicodeCharacter{00AF}{\={ }}%
10168   %
10169   \DeclareUnicodeCharacter{00B0}{\ringaccent{ }}%
10170   \DeclareUnicodeCharacter{00B1}{\ensuremath\pm}%
10171   \DeclareUnicodeCharacter{00B2}{$^2$}%
10172   \DeclareUnicodeCharacter{00B3}{$^3$}%
10173   \DeclareUnicodeCharacter{00B4}{\'{ }}%
10174   \DeclareUnicodeCharacter{00B5}{$\mu$}%
10175   \DeclareUnicodeCharacter{00B6}{\P}%
10176   \DeclareUnicodeCharacter{00B7}{\ensuremath\cdot}%
10177   \DeclareUnicodeCharacter{00B8}{\cedilla{ }}%
10178   \DeclareUnicodeCharacter{00B9}{$^1$}%
10179   \DeclareUnicodeCharacter{00BA}{\ordm}%
10180   \DeclareUnicodeCharacter{00BB}{\guillemetright}%
10181   \DeclareUnicodeCharacter{00BC}{$1\over4$}%
10182   \DeclareUnicodeCharacter{00BD}{$1\over2$}%
10183   \DeclareUnicodeCharacter{00BE}{$3\over4$}%
10184   \DeclareUnicodeCharacter{00BF}{\questiondown}%
10185   %
10186   \DeclareUnicodeCharacter{00C0}{\`A}%
10187   \DeclareUnicodeCharacter{00C1}{\'A}%
10188   \DeclareUnicodeCharacter{00C2}{\^A}%
10189   \DeclareUnicodeCharacter{00C3}{\~A}%
10190   \DeclareUnicodeCharacter{00C4}{\"A}%
10191   \DeclareUnicodeCharacter{00C5}{\AA}%
10192   \DeclareUnicodeCharacter{00C6}{\AE}%
10193   \DeclareUnicodeCharacter{00C7}{\cedilla{C}}%
10194   \DeclareUnicodeCharacter{00C8}{\`E}%
10195   \DeclareUnicodeCharacter{00C9}{\'E}%
10196   \DeclareUnicodeCharacter{00CA}{\^E}%
10197   \DeclareUnicodeCharacter{00CB}{\"E}%
10198   \DeclareUnicodeCharacter{00CC}{\`I}%
10199   \DeclareUnicodeCharacter{00CD}{\'I}%
10200   \DeclareUnicodeCharacter{00CE}{\^I}%
10201   \DeclareUnicodeCharacter{00CF}{\"I}%
10202   %
10203   \DeclareUnicodeCharacter{00D0}{\DH}%
10204   \DeclareUnicodeCharacter{00D1}{\~N}%
10205   \DeclareUnicodeCharacter{00D2}{\`O}%
10206   \DeclareUnicodeCharacter{00D3}{\'O}%
10207   \DeclareUnicodeCharacter{00D4}{\^O}%
10208   \DeclareUnicodeCharacter{00D5}{\~O}%
10209   \DeclareUnicodeCharacter{00D6}{\"O}%
10210   \DeclareUnicodeCharacter{00D7}{\ensuremath\times}%
10211   \DeclareUnicodeCharacter{00D8}{\O}%
10212   \DeclareUnicodeCharacter{00D9}{\`U}%
10213   \DeclareUnicodeCharacter{00DA}{\'U}%
10214   \DeclareUnicodeCharacter{00DB}{\^U}%
10215   \DeclareUnicodeCharacter{00DC}{\"U}%
10216   \DeclareUnicodeCharacter{00DD}{\'Y}%
10217   \DeclareUnicodeCharacter{00DE}{\TH}%
10218   \DeclareUnicodeCharacter{00DF}{\ss}%
10219   %
10220   \DeclareUnicodeCharacter{00E0}{\`a}%
10221   \DeclareUnicodeCharacter{00E1}{\'a}%
10222   \DeclareUnicodeCharacter{00E2}{\^a}%
10223   \DeclareUnicodeCharacter{00E3}{\~a}%
10224   \DeclareUnicodeCharacter{00E4}{\"a}%
10225   \DeclareUnicodeCharacter{00E5}{\aa}%
10226   \DeclareUnicodeCharacter{00E6}{\ae}%
10227   \DeclareUnicodeCharacter{00E7}{\cedilla{c}}%
10228   \DeclareUnicodeCharacter{00E8}{\`e}%
10229   \DeclareUnicodeCharacter{00E9}{\'e}%
10230   \DeclareUnicodeCharacter{00EA}{\^e}%
10231   \DeclareUnicodeCharacter{00EB}{\"e}%
10232   \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}}%
10233   \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}}%
10234   \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}}%
10235   \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}}%
10236   %
10237   \DeclareUnicodeCharacter{00F0}{\dh}%
10238   \DeclareUnicodeCharacter{00F1}{\~n}%
10239   \DeclareUnicodeCharacter{00F2}{\`o}%
10240   \DeclareUnicodeCharacter{00F3}{\'o}%
10241   \DeclareUnicodeCharacter{00F4}{\^o}%
10242   \DeclareUnicodeCharacter{00F5}{\~o}%
10243   \DeclareUnicodeCharacter{00F6}{\"o}%
10244   \DeclareUnicodeCharacter{00F7}{\ensuremath\div}%
10245   \DeclareUnicodeCharacter{00F8}{\o}%
10246   \DeclareUnicodeCharacter{00F9}{\`u}%
10247   \DeclareUnicodeCharacter{00FA}{\'u}%
10248   \DeclareUnicodeCharacter{00FB}{\^u}%
10249   \DeclareUnicodeCharacter{00FC}{\"u}%
10250   \DeclareUnicodeCharacter{00FD}{\'y}%
10251   \DeclareUnicodeCharacter{00FE}{\th}%
10252   \DeclareUnicodeCharacter{00FF}{\"y}%
10253   %
10254   \DeclareUnicodeCharacter{0100}{\=A}%
10255   \DeclareUnicodeCharacter{0101}{\=a}%
10256   \DeclareUnicodeCharacter{0102}{\u{A}}%
10257   \DeclareUnicodeCharacter{0103}{\u{a}}%
10258   \DeclareUnicodeCharacter{0104}{\ogonek{A}}%
10259   \DeclareUnicodeCharacter{0105}{\ogonek{a}}%
10260   \DeclareUnicodeCharacter{0106}{\'C}%
10261   \DeclareUnicodeCharacter{0107}{\'c}%
10262   \DeclareUnicodeCharacter{0108}{\^C}%
10263   \DeclareUnicodeCharacter{0109}{\^c}%
10264   \DeclareUnicodeCharacter{010A}{\dotaccent{C}}%
10265   \DeclareUnicodeCharacter{010B}{\dotaccent{c}}%
10266   \DeclareUnicodeCharacter{010C}{\v{C}}%
10267   \DeclareUnicodeCharacter{010D}{\v{c}}%
10268   \DeclareUnicodeCharacter{010E}{\v{D}}%
10269   \DeclareUnicodeCharacter{010F}{d'}%
10270   %
10271   \DeclareUnicodeCharacter{0110}{\DH}%
10272   \DeclareUnicodeCharacter{0111}{\dh}%
10273   \DeclareUnicodeCharacter{0112}{\=E}%
10274   \DeclareUnicodeCharacter{0113}{\=e}%
10275   \DeclareUnicodeCharacter{0114}{\u{E}}%
10276   \DeclareUnicodeCharacter{0115}{\u{e}}%
10277   \DeclareUnicodeCharacter{0116}{\dotaccent{E}}%
10278   \DeclareUnicodeCharacter{0117}{\dotaccent{e}}%
10279   \DeclareUnicodeCharacter{0118}{\ogonek{E}}%
10280   \DeclareUnicodeCharacter{0119}{\ogonek{e}}%
10281   \DeclareUnicodeCharacter{011A}{\v{E}}%
10282   \DeclareUnicodeCharacter{011B}{\v{e}}%
10283   \DeclareUnicodeCharacter{011C}{\^G}%
10284   \DeclareUnicodeCharacter{011D}{\^g}%
10285   \DeclareUnicodeCharacter{011E}{\u{G}}%
10286   \DeclareUnicodeCharacter{011F}{\u{g}}%
10287   %
10288   \DeclareUnicodeCharacter{0120}{\dotaccent{G}}%
10289   \DeclareUnicodeCharacter{0121}{\dotaccent{g}}%
10290   \DeclareUnicodeCharacter{0122}{\cedilla{G}}%
10291   \DeclareUnicodeCharacter{0123}{\cedilla{g}}%
10292   \DeclareUnicodeCharacter{0124}{\^H}%
10293   \DeclareUnicodeCharacter{0125}{\^h}%
10294   \DeclareUnicodeCharacter{0126}{\missingcharmsg{H WITH STROKE}}%
10295   \DeclareUnicodeCharacter{0127}{\missingcharmsg{h WITH STROKE}}%
10296   \DeclareUnicodeCharacter{0128}{\~I}%
10297   \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}}%
10298   \DeclareUnicodeCharacter{012A}{\=I}%
10299   \DeclareUnicodeCharacter{012B}{\={\dotless{i}}}%
10300   \DeclareUnicodeCharacter{012C}{\u{I}}%
10301   \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}}%
10302   \DeclareUnicodeCharacter{012E}{\ogonek{I}}%
10303   \DeclareUnicodeCharacter{012F}{\ogonek{i}}%
10304   %
10305   \DeclareUnicodeCharacter{0130}{\dotaccent{I}}%
10306   \DeclareUnicodeCharacter{0131}{\dotless{i}}%
10307   \DeclareUnicodeCharacter{0132}{IJ}%
10308   \DeclareUnicodeCharacter{0133}{ij}%
10309   \DeclareUnicodeCharacter{0134}{\^J}%
10310   \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}}%
10311   \DeclareUnicodeCharacter{0136}{\cedilla{K}}%
10312   \DeclareUnicodeCharacter{0137}{\cedilla{k}}%
10313   \DeclareUnicodeCharacter{0138}{\ensuremath\kappa}%
10314   \DeclareUnicodeCharacter{0139}{\'L}%
10315   \DeclareUnicodeCharacter{013A}{\'l}%
10316   \DeclareUnicodeCharacter{013B}{\cedilla{L}}%
10317   \DeclareUnicodeCharacter{013C}{\cedilla{l}}%
10318   \DeclareUnicodeCharacter{013D}{L'}% should kern
10319   \DeclareUnicodeCharacter{013E}{l'}% should kern
10320   \DeclareUnicodeCharacter{013F}{L\U{00B7}}%
10321   %
10322   \DeclareUnicodeCharacter{0140}{l\U{00B7}}%
10323   \DeclareUnicodeCharacter{0141}{\L}%
10324   \DeclareUnicodeCharacter{0142}{\l}%
10325   \DeclareUnicodeCharacter{0143}{\'N}%
10326   \DeclareUnicodeCharacter{0144}{\'n}%
10327   \DeclareUnicodeCharacter{0145}{\cedilla{N}}%
10328   \DeclareUnicodeCharacter{0146}{\cedilla{n}}%
10329   \DeclareUnicodeCharacter{0147}{\v{N}}%
10330   \DeclareUnicodeCharacter{0148}{\v{n}}%
10331   \DeclareUnicodeCharacter{0149}{'n}%
10332   \DeclareUnicodeCharacter{014A}{\missingcharmsg{ENG}}%
10333   \DeclareUnicodeCharacter{014B}{\missingcharmsg{eng}}%
10334   \DeclareUnicodeCharacter{014C}{\=O}%
10335   \DeclareUnicodeCharacter{014D}{\=o}%
10336   \DeclareUnicodeCharacter{014E}{\u{O}}%
10337   \DeclareUnicodeCharacter{014F}{\u{o}}%
10338   %
10339   \DeclareUnicodeCharacter{0150}{\H{O}}%
10340   \DeclareUnicodeCharacter{0151}{\H{o}}%
10341   \DeclareUnicodeCharacter{0152}{\OE}%
10342   \DeclareUnicodeCharacter{0153}{\oe}%
10343   \DeclareUnicodeCharacter{0154}{\'R}%
10344   \DeclareUnicodeCharacter{0155}{\'r}%
10345   \DeclareUnicodeCharacter{0156}{\cedilla{R}}%
10346   \DeclareUnicodeCharacter{0157}{\cedilla{r}}%
10347   \DeclareUnicodeCharacter{0158}{\v{R}}%
10348   \DeclareUnicodeCharacter{0159}{\v{r}}%
10349   \DeclareUnicodeCharacter{015A}{\'S}%
10350   \DeclareUnicodeCharacter{015B}{\'s}%
10351   \DeclareUnicodeCharacter{015C}{\^S}%
10352   \DeclareUnicodeCharacter{015D}{\^s}%
10353   \DeclareUnicodeCharacter{015E}{\cedilla{S}}%
10354   \DeclareUnicodeCharacter{015F}{\cedilla{s}}%
10355   %
10356   \DeclareUnicodeCharacter{0160}{\v{S}}%
10357   \DeclareUnicodeCharacter{0161}{\v{s}}%
10358   \DeclareUnicodeCharacter{0162}{\cedilla{T}}%
10359   \DeclareUnicodeCharacter{0163}{\cedilla{t}}%
10360   \DeclareUnicodeCharacter{0164}{\v{T}}%
10361   \DeclareUnicodeCharacter{0165}{\v{t}}%
10362   \DeclareUnicodeCharacter{0166}{\missingcharmsg{H WITH STROKE}}%
10363   \DeclareUnicodeCharacter{0167}{\missingcharmsg{h WITH STROKE}}%
10364   \DeclareUnicodeCharacter{0168}{\~U}%
10365   \DeclareUnicodeCharacter{0169}{\~u}%
10366   \DeclareUnicodeCharacter{016A}{\=U}%
10367   \DeclareUnicodeCharacter{016B}{\=u}%
10368   \DeclareUnicodeCharacter{016C}{\u{U}}%
10369   \DeclareUnicodeCharacter{016D}{\u{u}}%
10370   \DeclareUnicodeCharacter{016E}{\ringaccent{U}}%
10371   \DeclareUnicodeCharacter{016F}{\ringaccent{u}}%
10372   %
10373   \DeclareUnicodeCharacter{0170}{\H{U}}%
10374   \DeclareUnicodeCharacter{0171}{\H{u}}%
10375   \DeclareUnicodeCharacter{0172}{\ogonek{U}}%
10376   \DeclareUnicodeCharacter{0173}{\ogonek{u}}%
10377   \DeclareUnicodeCharacter{0174}{\^W}%
10378   \DeclareUnicodeCharacter{0175}{\^w}%
10379   \DeclareUnicodeCharacter{0176}{\^Y}%
10380   \DeclareUnicodeCharacter{0177}{\^y}%
10381   \DeclareUnicodeCharacter{0178}{\"Y}%
10382   \DeclareUnicodeCharacter{0179}{\'Z}%
10383   \DeclareUnicodeCharacter{017A}{\'z}%
10384   \DeclareUnicodeCharacter{017B}{\dotaccent{Z}}%
10385   \DeclareUnicodeCharacter{017C}{\dotaccent{z}}%
10386   \DeclareUnicodeCharacter{017D}{\v{Z}}%
10387   \DeclareUnicodeCharacter{017E}{\v{z}}%
10388   \DeclareUnicodeCharacter{017F}{\missingcharmsg{LONG S}}%
10389   %
10390   \DeclareUnicodeCharacter{01C4}{D\v{Z}}%
10391   \DeclareUnicodeCharacter{01C5}{D\v{z}}%
10392   \DeclareUnicodeCharacter{01C6}{d\v{z}}%
10393   \DeclareUnicodeCharacter{01C7}{LJ}%
10394   \DeclareUnicodeCharacter{01C8}{Lj}%
10395   \DeclareUnicodeCharacter{01C9}{lj}%
10396   \DeclareUnicodeCharacter{01CA}{NJ}%
10397   \DeclareUnicodeCharacter{01CB}{Nj}%
10398   \DeclareUnicodeCharacter{01CC}{nj}%
10399   \DeclareUnicodeCharacter{01CD}{\v{A}}%
10400   \DeclareUnicodeCharacter{01CE}{\v{a}}%
10401   \DeclareUnicodeCharacter{01CF}{\v{I}}%
10402   %
10403   \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}}%
10404   \DeclareUnicodeCharacter{01D1}{\v{O}}%
10405   \DeclareUnicodeCharacter{01D2}{\v{o}}%
10406   \DeclareUnicodeCharacter{01D3}{\v{U}}%
10407   \DeclareUnicodeCharacter{01D4}{\v{u}}%
10408   %
10409   \DeclareUnicodeCharacter{01E2}{\={\AE}}%
10410   \DeclareUnicodeCharacter{01E3}{\={\ae}}%
10411   \DeclareUnicodeCharacter{01E6}{\v{G}}%
10412   \DeclareUnicodeCharacter{01E7}{\v{g}}%
10413   \DeclareUnicodeCharacter{01E8}{\v{K}}%
10414   \DeclareUnicodeCharacter{01E9}{\v{k}}%
10415   %
10416   \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}}%
10417   \DeclareUnicodeCharacter{01F1}{DZ}%
10418   \DeclareUnicodeCharacter{01F2}{Dz}%
10419   \DeclareUnicodeCharacter{01F3}{dz}%
10420   \DeclareUnicodeCharacter{01F4}{\'G}%
10421   \DeclareUnicodeCharacter{01F5}{\'g}%
10422   \DeclareUnicodeCharacter{01F8}{\`N}%
10423   \DeclareUnicodeCharacter{01F9}{\`n}%
10424   \DeclareUnicodeCharacter{01FC}{\'{\AE}}%
10425   \DeclareUnicodeCharacter{01FD}{\'{\ae}}%
10426   \DeclareUnicodeCharacter{01FE}{\'{\O}}%
10427   \DeclareUnicodeCharacter{01FF}{\'{\o}}%
10428   %
10429   \DeclareUnicodeCharacter{021E}{\v{H}}%
10430   \DeclareUnicodeCharacter{021F}{\v{h}}%
10431   %
10432   \DeclareUnicodeCharacter{0226}{\dotaccent{A}}%
10433   \DeclareUnicodeCharacter{0227}{\dotaccent{a}}%
10434   \DeclareUnicodeCharacter{0228}{\cedilla{E}}%
10435   \DeclareUnicodeCharacter{0229}{\cedilla{e}}%
10436   \DeclareUnicodeCharacter{022E}{\dotaccent{O}}%
10437   \DeclareUnicodeCharacter{022F}{\dotaccent{o}}%
10438   %
10439   \DeclareUnicodeCharacter{0232}{\=Y}%
10440   \DeclareUnicodeCharacter{0233}{\=y}%
10441   \DeclareUnicodeCharacter{0237}{\dotless{j}}%
10442   %
10443   \DeclareUnicodeCharacter{02DB}{\ogonek{ }}%
10444   %
10445   % Greek letters upper case
10446   \DeclareUnicodeCharacter{0391}{{\it A}}%
10447   \DeclareUnicodeCharacter{0392}{{\it B}}%
10448   \DeclareUnicodeCharacter{0393}{\ensuremath{\mit\Gamma}}%
10449   \DeclareUnicodeCharacter{0394}{\ensuremath{\mit\Delta}}%
10450   \DeclareUnicodeCharacter{0395}{{\it E}}%
10451   \DeclareUnicodeCharacter{0396}{{\it Z}}%
10452   \DeclareUnicodeCharacter{0397}{{\it H}}%
10453   \DeclareUnicodeCharacter{0398}{\ensuremath{\mit\Theta}}%
10454   \DeclareUnicodeCharacter{0399}{{\it I}}%
10455   \DeclareUnicodeCharacter{039A}{{\it K}}%
10456   \DeclareUnicodeCharacter{039B}{\ensuremath{\mit\Lambda}}%
10457   \DeclareUnicodeCharacter{039C}{{\it M}}%
10458   \DeclareUnicodeCharacter{039D}{{\it N}}%
10459   \DeclareUnicodeCharacter{039E}{\ensuremath{\mit\Xi}}%
10460   \DeclareUnicodeCharacter{039F}{{\it O}}%
10461   \DeclareUnicodeCharacter{03A0}{\ensuremath{\mit\Pi}}%
10462   \DeclareUnicodeCharacter{03A1}{{\it P}}%
10463   %\DeclareUnicodeCharacter{03A2}{} % none - corresponds to final sigma
10464   \DeclareUnicodeCharacter{03A3}{\ensuremath{\mit\Sigma}}%
10465   \DeclareUnicodeCharacter{03A4}{{\it T}}%
10466   \DeclareUnicodeCharacter{03A5}{\ensuremath{\mit\Upsilon}}%
10467   \DeclareUnicodeCharacter{03A6}{\ensuremath{\mit\Phi}}%
10468   \DeclareUnicodeCharacter{03A7}{{\it X}}%
10469   \DeclareUnicodeCharacter{03A8}{\ensuremath{\mit\Psi}}%
10470   \DeclareUnicodeCharacter{03A9}{\ensuremath{\mit\Omega}}%
10471   %
10472   % Vowels with accents
10473   \DeclareUnicodeCharacter{0390}{\ensuremath{\ddot{\acute\iota}}}%
10474   \DeclareUnicodeCharacter{03AC}{\ensuremath{\acute\alpha}}%
10475   \DeclareUnicodeCharacter{03AD}{\ensuremath{\acute\epsilon}}%
10476   \DeclareUnicodeCharacter{03AE}{\ensuremath{\acute\eta}}%
10477   \DeclareUnicodeCharacter{03AF}{\ensuremath{\acute\iota}}%
10478   \DeclareUnicodeCharacter{03B0}{\ensuremath{\acute{\ddot\upsilon}}}%
10479   %
10480   % Standalone accent
10481   \DeclareUnicodeCharacter{0384}{\ensuremath{\acute{\ }}}%
10482   %
10483   % Greek letters lower case
10484   \DeclareUnicodeCharacter{03B1}{\ensuremath\alpha}%
10485   \DeclareUnicodeCharacter{03B2}{\ensuremath\beta}%
10486   \DeclareUnicodeCharacter{03B3}{\ensuremath\gamma}%
10487   \DeclareUnicodeCharacter{03B4}{\ensuremath\delta}%
10488   \DeclareUnicodeCharacter{03B5}{\ensuremath\epsilon}%
10489   \DeclareUnicodeCharacter{03B6}{\ensuremath\zeta}%
10490   \DeclareUnicodeCharacter{03B7}{\ensuremath\eta}%
10491   \DeclareUnicodeCharacter{03B8}{\ensuremath\theta}%
10492   \DeclareUnicodeCharacter{03B9}{\ensuremath\iota}%
10493   \DeclareUnicodeCharacter{03BA}{\ensuremath\kappa}%
10494   \DeclareUnicodeCharacter{03BB}{\ensuremath\lambda}%
10495   \DeclareUnicodeCharacter{03BC}{\ensuremath\mu}%
10496   \DeclareUnicodeCharacter{03BD}{\ensuremath\nu}%
10497   \DeclareUnicodeCharacter{03BE}{\ensuremath\xi}%
10498   \DeclareUnicodeCharacter{03BF}{{\it o}}% omicron
10499   \DeclareUnicodeCharacter{03C0}{\ensuremath\pi}%
10500   \DeclareUnicodeCharacter{03C1}{\ensuremath\rho}%
10501   \DeclareUnicodeCharacter{03C2}{\ensuremath\varsigma}%
10502   \DeclareUnicodeCharacter{03C3}{\ensuremath\sigma}%
10503   \DeclareUnicodeCharacter{03C4}{\ensuremath\tau}%
10504   \DeclareUnicodeCharacter{03C5}{\ensuremath\upsilon}%
10505   \DeclareUnicodeCharacter{03C6}{\ensuremath\phi}%
10506   \DeclareUnicodeCharacter{03C7}{\ensuremath\chi}%
10507   \DeclareUnicodeCharacter{03C8}{\ensuremath\psi}%
10508   \DeclareUnicodeCharacter{03C9}{\ensuremath\omega}%
10509   %
10510   % More Greek vowels with accents
10511   \DeclareUnicodeCharacter{03CA}{\ensuremath{\ddot\iota}}%
10512   \DeclareUnicodeCharacter{03CB}{\ensuremath{\ddot\upsilon}}%
10513   \DeclareUnicodeCharacter{03CC}{\ensuremath{\acute o}}%
10514   \DeclareUnicodeCharacter{03CD}{\ensuremath{\acute\upsilon}}%
10515   \DeclareUnicodeCharacter{03CE}{\ensuremath{\acute\omega}}%
10516   %
10517   % Variant Greek letters
10518   \DeclareUnicodeCharacter{03D1}{\ensuremath\vartheta}%
10519   \DeclareUnicodeCharacter{03D6}{\ensuremath\varpi}%
10520   \DeclareUnicodeCharacter{03F1}{\ensuremath\varrho}%
10521   %
10522   \DeclareUnicodeCharacter{1E02}{\dotaccent{B}}%
10523   \DeclareUnicodeCharacter{1E03}{\dotaccent{b}}%
10524   \DeclareUnicodeCharacter{1E04}{\udotaccent{B}}%
10525   \DeclareUnicodeCharacter{1E05}{\udotaccent{b}}%
10526   \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}}%
10527   \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}}%
10528   \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}}%
10529   \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}}%
10530   \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}}%
10531   \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}}%
10532   \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}}%
10533   \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}}%
10534   %
10535   \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}}%
10536   \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}}%
10537   %
10538   \DeclareUnicodeCharacter{1E20}{\=G}%
10539   \DeclareUnicodeCharacter{1E21}{\=g}%
10540   \DeclareUnicodeCharacter{1E22}{\dotaccent{H}}%
10541   \DeclareUnicodeCharacter{1E23}{\dotaccent{h}}%
10542   \DeclareUnicodeCharacter{1E24}{\udotaccent{H}}%
10543   \DeclareUnicodeCharacter{1E25}{\udotaccent{h}}%
10544   \DeclareUnicodeCharacter{1E26}{\"H}%
10545   \DeclareUnicodeCharacter{1E27}{\"h}%
10546   %
10547   \DeclareUnicodeCharacter{1E30}{\'K}%
10548   \DeclareUnicodeCharacter{1E31}{\'k}%
10549   \DeclareUnicodeCharacter{1E32}{\udotaccent{K}}%
10550   \DeclareUnicodeCharacter{1E33}{\udotaccent{k}}%
10551   \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}}%
10552   \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}}%
10553   \DeclareUnicodeCharacter{1E36}{\udotaccent{L}}%
10554   \DeclareUnicodeCharacter{1E37}{\udotaccent{l}}%
10555   \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}}%
10556   \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}}%
10557   \DeclareUnicodeCharacter{1E3E}{\'M}%
10558   \DeclareUnicodeCharacter{1E3F}{\'m}%
10559   %
10560   \DeclareUnicodeCharacter{1E40}{\dotaccent{M}}%
10561   \DeclareUnicodeCharacter{1E41}{\dotaccent{m}}%
10562   \DeclareUnicodeCharacter{1E42}{\udotaccent{M}}%
10563   \DeclareUnicodeCharacter{1E43}{\udotaccent{m}}%
10564   \DeclareUnicodeCharacter{1E44}{\dotaccent{N}}%
10565   \DeclareUnicodeCharacter{1E45}{\dotaccent{n}}%
10566   \DeclareUnicodeCharacter{1E46}{\udotaccent{N}}%
10567   \DeclareUnicodeCharacter{1E47}{\udotaccent{n}}%
10568   \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}}%
10569   \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}}%
10570   %
10571   \DeclareUnicodeCharacter{1E54}{\'P}%
10572   \DeclareUnicodeCharacter{1E55}{\'p}%
10573   \DeclareUnicodeCharacter{1E56}{\dotaccent{P}}%
10574   \DeclareUnicodeCharacter{1E57}{\dotaccent{p}}%
10575   \DeclareUnicodeCharacter{1E58}{\dotaccent{R}}%
10576   \DeclareUnicodeCharacter{1E59}{\dotaccent{r}}%
10577   \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}}%
10578   \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}}%
10579   \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}}%
10580   \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}}%
10581   %
10582   \DeclareUnicodeCharacter{1E60}{\dotaccent{S}}%
10583   \DeclareUnicodeCharacter{1E61}{\dotaccent{s}}%
10584   \DeclareUnicodeCharacter{1E62}{\udotaccent{S}}%
10585   \DeclareUnicodeCharacter{1E63}{\udotaccent{s}}%
10586   \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}}%
10587   \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}}%
10588   \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}}%
10589   \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}}%
10590   \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}}%
10591   \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}}%
10592   %
10593   \DeclareUnicodeCharacter{1E7C}{\~V}%
10594   \DeclareUnicodeCharacter{1E7D}{\~v}%
10595   \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}}%
10596   \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}}%
10597   %
10598   \DeclareUnicodeCharacter{1E80}{\`W}%
10599   \DeclareUnicodeCharacter{1E81}{\`w}%
10600   \DeclareUnicodeCharacter{1E82}{\'W}%
10601   \DeclareUnicodeCharacter{1E83}{\'w}%
10602   \DeclareUnicodeCharacter{1E84}{\"W}%
10603   \DeclareUnicodeCharacter{1E85}{\"w}%
10604   \DeclareUnicodeCharacter{1E86}{\dotaccent{W}}%
10605   \DeclareUnicodeCharacter{1E87}{\dotaccent{w}}%
10606   \DeclareUnicodeCharacter{1E88}{\udotaccent{W}}%
10607   \DeclareUnicodeCharacter{1E89}{\udotaccent{w}}%
10608   \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}}%
10609   \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}}%
10610   \DeclareUnicodeCharacter{1E8C}{\"X}%
10611   \DeclareUnicodeCharacter{1E8D}{\"x}%
10612   \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}}%
10613   \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}}%
10614   %
10615   \DeclareUnicodeCharacter{1E90}{\^Z}%
10616   \DeclareUnicodeCharacter{1E91}{\^z}%
10617   \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}}%
10618   \DeclareUnicodeCharacter{1E93}{\udotaccent{z}}%
10619   \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}}%
10620   \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}}%
10621   \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}}%
10622   \DeclareUnicodeCharacter{1E97}{\"t}%
10623   \DeclareUnicodeCharacter{1E98}{\ringaccent{w}}%
10624   \DeclareUnicodeCharacter{1E99}{\ringaccent{y}}%
10625   %
10626   \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}}%
10627   \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}}%
10628   %
10629   \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}}%
10630   \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}}%
10631   \DeclareUnicodeCharacter{1EBC}{\~E}%
10632   \DeclareUnicodeCharacter{1EBD}{\~e}%
10633   %
10634   \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}}%
10635   \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}}%
10636   \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}}%
10637   \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}}%
10638   %
10639   \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}}%
10640   \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}}%
10641   %
10642   \DeclareUnicodeCharacter{1EF2}{\`Y}%
10643   \DeclareUnicodeCharacter{1EF3}{\`y}%
10644   \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}}%
10645   %
10646   \DeclareUnicodeCharacter{1EF8}{\~Y}%
10647   \DeclareUnicodeCharacter{1EF9}{\~y}%
10648   %
10649   % Punctuation
10650   \DeclareUnicodeCharacter{2013}{--}%
10651   \DeclareUnicodeCharacter{2014}{---}%
10652   \DeclareUnicodeCharacter{2018}{\quoteleft}%
10653   \DeclareUnicodeCharacter{2019}{\quoteright}%
10654   \DeclareUnicodeCharacter{201A}{\quotesinglbase}%
10655   \DeclareUnicodeCharacter{201C}{\quotedblleft}%
10656   \DeclareUnicodeCharacter{201D}{\quotedblright}%
10657   \DeclareUnicodeCharacter{201E}{\quotedblbase}%
10658   \DeclareUnicodeCharacter{2020}{\ensuremath\dagger}%
10659   \DeclareUnicodeCharacter{2021}{\ensuremath\ddagger}%
10660   \DeclareUnicodeCharacter{2022}{\bullet}%
10661   \DeclareUnicodeCharacter{202F}{\thinspace}%
10662   \DeclareUnicodeCharacter{2026}{\dots}%
10663   \DeclareUnicodeCharacter{2039}{\guilsinglleft}%
10664   \DeclareUnicodeCharacter{203A}{\guilsinglright}%
10665   %
10666   \DeclareUnicodeCharacter{20AC}{\euro}%
10667   %
10668   \DeclareUnicodeCharacter{2192}{\expansion}%
10669   \DeclareUnicodeCharacter{21D2}{\result}%
10670   %
10671   % Mathematical symbols
10672   \DeclareUnicodeCharacter{2200}{\ensuremath\forall}%
10673   \DeclareUnicodeCharacter{2203}{\ensuremath\exists}%
10674   \DeclareUnicodeCharacter{2208}{\ensuremath\in}%
10675   \DeclareUnicodeCharacter{2212}{\minus}%
10676   \DeclareUnicodeCharacter{2217}{\ast}%
10677   \DeclareUnicodeCharacter{221E}{\ensuremath\infty}%
10678   \DeclareUnicodeCharacter{2225}{\ensuremath\parallel}%
10679   \DeclareUnicodeCharacter{2227}{\ensuremath\wedge}%
10680   \DeclareUnicodeCharacter{2229}{\ensuremath\cap}%
10681   \DeclareUnicodeCharacter{2261}{\equiv}%
10682   \DeclareUnicodeCharacter{2264}{\ensuremath\leq}%
10683   \DeclareUnicodeCharacter{2265}{\ensuremath\geq}%
10684   \DeclareUnicodeCharacter{2282}{\ensuremath\subset}%
10685   \DeclareUnicodeCharacter{2287}{\ensuremath\supseteq}%
10686   %
10687   \DeclareUnicodeCharacter{2016}{\ensuremath\Vert}%
10688   \DeclareUnicodeCharacter{2032}{\ensuremath\prime}%
10689   \DeclareUnicodeCharacter{210F}{\ensuremath\hbar}%
10690   \DeclareUnicodeCharacter{2111}{\ensuremath\Im}%
10691   \DeclareUnicodeCharacter{2113}{\ensuremath\ell}%
10692   \DeclareUnicodeCharacter{2118}{\ensuremath\wp}%
10693   \DeclareUnicodeCharacter{211C}{\ensuremath\Re}%
10694   \DeclareUnicodeCharacter{2127}{\ensuremath\mho}%
10695   \DeclareUnicodeCharacter{2135}{\ensuremath\aleph}%
10696   \DeclareUnicodeCharacter{2190}{\ensuremath\leftarrow}%
10697   \DeclareUnicodeCharacter{2191}{\ensuremath\uparrow}%
10698   \DeclareUnicodeCharacter{2193}{\ensuremath\downarrow}%
10699   \DeclareUnicodeCharacter{2194}{\ensuremath\leftrightarrow}%
10700   \DeclareUnicodeCharacter{2195}{\ensuremath\updownarrow}%
10701   \DeclareUnicodeCharacter{2196}{\ensuremath\nwarrow}%
10702   \DeclareUnicodeCharacter{2197}{\ensuremath\nearrow}%
10703   \DeclareUnicodeCharacter{2198}{\ensuremath\searrow}%
10704   \DeclareUnicodeCharacter{2199}{\ensuremath\swarrow}%
10705   \DeclareUnicodeCharacter{21A6}{\ensuremath\mapsto}%
10706   \DeclareUnicodeCharacter{21A9}{\ensuremath\hookleftarrow}%
10707   \DeclareUnicodeCharacter{21AA}{\ensuremath\hookrightarrow}%
10708   \DeclareUnicodeCharacter{21BC}{\ensuremath\leftharpoonup}%
10709   \DeclareUnicodeCharacter{21BD}{\ensuremath\leftharpoondown}%
10710   \DeclareUnicodeCharacter{21BE}{\ensuremath\upharpoonright}%
10711   \DeclareUnicodeCharacter{21C0}{\ensuremath\rightharpoonup}%
10712   \DeclareUnicodeCharacter{21C1}{\ensuremath\rightharpoondown}%
10713   \DeclareUnicodeCharacter{21CC}{\ensuremath\rightleftharpoons}%
10714   \DeclareUnicodeCharacter{21D0}{\ensuremath\Leftarrow}%
10715   \DeclareUnicodeCharacter{21D1}{\ensuremath\Uparrow}%
10716   \DeclareUnicodeCharacter{21D3}{\ensuremath\Downarrow}%
10717   \DeclareUnicodeCharacter{21D4}{\ensuremath\Leftrightarrow}%
10718   \DeclareUnicodeCharacter{21D5}{\ensuremath\Updownarrow}%
10719   \DeclareUnicodeCharacter{21DD}{\ensuremath\leadsto}%
10720   \DeclareUnicodeCharacter{2201}{\ensuremath\complement}%
10721   \DeclareUnicodeCharacter{2202}{\ensuremath\partial}%
10722   \DeclareUnicodeCharacter{2205}{\ensuremath\emptyset}%
10723   \DeclareUnicodeCharacter{2207}{\ensuremath\nabla}%
10724   \DeclareUnicodeCharacter{2209}{\ensuremath\notin}%
10725   \DeclareUnicodeCharacter{220B}{\ensuremath\owns}%
10726   \DeclareUnicodeCharacter{220F}{\ensuremath\prod}%
10727   \DeclareUnicodeCharacter{2210}{\ensuremath\coprod}%
10728   \DeclareUnicodeCharacter{2211}{\ensuremath\sum}%
10729   \DeclareUnicodeCharacter{2213}{\ensuremath\mp}%
10730   \DeclareUnicodeCharacter{2218}{\ensuremath\circ}%
10731   \DeclareUnicodeCharacter{221A}{\ensuremath\surd}%
10732   \DeclareUnicodeCharacter{221D}{\ensuremath\propto}%
10733   \DeclareUnicodeCharacter{2220}{\ensuremath\angle}%
10734   \DeclareUnicodeCharacter{2223}{\ensuremath\mid}%
10735   \DeclareUnicodeCharacter{2228}{\ensuremath\vee}%
10736   \DeclareUnicodeCharacter{222A}{\ensuremath\cup}%
10737   \DeclareUnicodeCharacter{222B}{\ensuremath\smallint}%
10738   \DeclareUnicodeCharacter{222E}{\ensuremath\oint}%
10739   \DeclareUnicodeCharacter{223C}{\ensuremath\sim}%
10740   \DeclareUnicodeCharacter{2240}{\ensuremath\wr}%
10741   \DeclareUnicodeCharacter{2243}{\ensuremath\simeq}%
10742   \DeclareUnicodeCharacter{2245}{\ensuremath\cong}%
10743   \DeclareUnicodeCharacter{2248}{\ensuremath\approx}%
10744   \DeclareUnicodeCharacter{224D}{\ensuremath\asymp}%
10745   \DeclareUnicodeCharacter{2250}{\ensuremath\doteq}%
10746   \DeclareUnicodeCharacter{2260}{\ensuremath\neq}%
10747   \DeclareUnicodeCharacter{226A}{\ensuremath\ll}%
10748   \DeclareUnicodeCharacter{226B}{\ensuremath\gg}%
10749   \DeclareUnicodeCharacter{227A}{\ensuremath\prec}%
10750   \DeclareUnicodeCharacter{227B}{\ensuremath\succ}%
10751   \DeclareUnicodeCharacter{2283}{\ensuremath\supset}%
10752   \DeclareUnicodeCharacter{2286}{\ensuremath\subseteq}%
10753   \DeclareUnicodeCharacter{228E}{\ensuremath\uplus}%
10754   \DeclareUnicodeCharacter{228F}{\ensuremath\sqsubset}%
10755   \DeclareUnicodeCharacter{2290}{\ensuremath\sqsupset}%
10756   \DeclareUnicodeCharacter{2291}{\ensuremath\sqsubseteq}%
10757   \DeclareUnicodeCharacter{2292}{\ensuremath\sqsupseteq}%
10758   \DeclareUnicodeCharacter{2293}{\ensuremath\sqcap}%
10759   \DeclareUnicodeCharacter{2294}{\ensuremath\sqcup}%
10760   \DeclareUnicodeCharacter{2295}{\ensuremath\oplus}%
10761   \DeclareUnicodeCharacter{2296}{\ensuremath\ominus}%
10762   \DeclareUnicodeCharacter{2297}{\ensuremath\otimes}%
10763   \DeclareUnicodeCharacter{2298}{\ensuremath\oslash}%
10764   \DeclareUnicodeCharacter{2299}{\ensuremath\odot}%
10765   \DeclareUnicodeCharacter{22A2}{\ensuremath\vdash}%
10766   \DeclareUnicodeCharacter{22A3}{\ensuremath\dashv}%
10767   \DeclareUnicodeCharacter{22A4}{\ensuremath\ptextop}%
10768   \DeclareUnicodeCharacter{22A5}{\ensuremath\bot}%
10769   \DeclareUnicodeCharacter{22A8}{\ensuremath\models}%
10770   \DeclareUnicodeCharacter{22B4}{\ensuremath\unlhd}%
10771   \DeclareUnicodeCharacter{22B5}{\ensuremath\unrhd}%
10772   \DeclareUnicodeCharacter{22C0}{\ensuremath\bigwedge}%
10773   \DeclareUnicodeCharacter{22C1}{\ensuremath\bigvee}%
10774   \DeclareUnicodeCharacter{22C2}{\ensuremath\bigcap}%
10775   \DeclareUnicodeCharacter{22C3}{\ensuremath\bigcup}%
10776   \DeclareUnicodeCharacter{22C4}{\ensuremath\diamond}%
10777   \DeclareUnicodeCharacter{22C5}{\ensuremath\cdot}%
10778   \DeclareUnicodeCharacter{22C6}{\ensuremath\star}%
10779   \DeclareUnicodeCharacter{22C8}{\ensuremath\bowtie}%
10780   \DeclareUnicodeCharacter{2308}{\ensuremath\lceil}%
10781   \DeclareUnicodeCharacter{2309}{\ensuremath\rceil}%
10782   \DeclareUnicodeCharacter{230A}{\ensuremath\lfloor}%
10783   \DeclareUnicodeCharacter{230B}{\ensuremath\rfloor}%
10784   \DeclareUnicodeCharacter{2322}{\ensuremath\frown}%
10785   \DeclareUnicodeCharacter{2323}{\ensuremath\smile}%
10786   %
10787   \DeclareUnicodeCharacter{25A1}{\ensuremath\Box}%
10788   \DeclareUnicodeCharacter{25B3}{\ensuremath\triangle}%
10789   \DeclareUnicodeCharacter{25B7}{\ensuremath\triangleright}%
10790   \DeclareUnicodeCharacter{25BD}{\ensuremath\bigtriangledown}%
10791   \DeclareUnicodeCharacter{25C1}{\ensuremath\triangleleft}%
10792   \DeclareUnicodeCharacter{25C7}{\ensuremath\Diamond}%
10793   \DeclareUnicodeCharacter{2660}{\ensuremath\spadesuit}%
10794   \DeclareUnicodeCharacter{2661}{\ensuremath\heartsuit}%
10795   \DeclareUnicodeCharacter{2662}{\ensuremath\diamondsuit}%
10796   \DeclareUnicodeCharacter{2663}{\ensuremath\clubsuit}%
10797   \DeclareUnicodeCharacter{266D}{\ensuremath\flat}%
10798   \DeclareUnicodeCharacter{266E}{\ensuremath\natural}%
10799   \DeclareUnicodeCharacter{266F}{\ensuremath\sharp}%
10800   \DeclareUnicodeCharacter{26AA}{\ensuremath\bigcirc}%
10801   \DeclareUnicodeCharacter{27B9}{\ensuremath\rangle}%
10802   \DeclareUnicodeCharacter{27C2}{\ensuremath\perp}%
10803   \DeclareUnicodeCharacter{27E8}{\ensuremath\langle}%
10804   \DeclareUnicodeCharacter{27F5}{\ensuremath\longleftarrow}%
10805   \DeclareUnicodeCharacter{27F6}{\ensuremath\longrightarrow}%
10806   \DeclareUnicodeCharacter{27F7}{\ensuremath\longleftrightarrow}%
10807   \DeclareUnicodeCharacter{27FC}{\ensuremath\longmapsto}%
10808   \DeclareUnicodeCharacter{29F5}{\ensuremath\setminus}%
10809   \DeclareUnicodeCharacter{2A00}{\ensuremath\bigodot}%
10810   \DeclareUnicodeCharacter{2A01}{\ensuremath\bigoplus}%
10811   \DeclareUnicodeCharacter{2A02}{\ensuremath\bigotimes}%
10812   \DeclareUnicodeCharacter{2A04}{\ensuremath\biguplus}%
10813   \DeclareUnicodeCharacter{2A06}{\ensuremath\bigsqcup}%
10814   \DeclareUnicodeCharacter{2A1D}{\ensuremath\Join}%
10815   \DeclareUnicodeCharacter{2A3F}{\ensuremath\amalg}%
10816   \DeclareUnicodeCharacter{2AAF}{\ensuremath\preceq}%
10817   \DeclareUnicodeCharacter{2AB0}{\ensuremath\succeq}%
10818   %
10819   \global\mathchardef\checkmark="1370% actually the square root sign
10820   \DeclareUnicodeCharacter{2713}{\ensuremath\checkmark}%
10821 }% end of \unicodechardefs
10822
10823 % UTF-8 byte sequence (pdfTeX) definitions (replacing and @U command)
10824 % It makes the setting that replace UTF-8 byte sequence.
10825 \def\utfeightchardefs{%
10826   \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterUTFviii
10827   \unicodechardefs
10828 }
10829
10830 \newif\ifpassthroughchars
10831 \passthroughcharsfalse
10832
10833 % For native Unicode (XeTeX and LuaTeX)
10834 % Definition macro to replace / pass-through the Unicode character
10835 %
10836 \def\DeclareUnicodeCharacterNative#1#2{%
10837   \catcode"#1=\active
10838   \def\dodeclareunicodecharacternative##1##2##3{%
10839     \begingroup
10840       \uccode`\~="##2\relax
10841       \uppercase{\gdef~}{%
10842         \ifpassthroughchars
10843           ##1%
10844         \else
10845           ##3%
10846         \fi
10847       }
10848     \endgroup
10849   }
10850   \begingroup
10851     \uccode`\.="#1\relax
10852     \uppercase{\def\UTFNativeTmp{.}}%
10853     \expandafter\dodeclareunicodecharacternative\UTFNativeTmp{#1}{#2}%
10854   \endgroup
10855 }
10856
10857 % Native Unicode (XeTeX and LuaTeX) character replacing definitions
10858 % It makes the setting that replace the Unicode characters.
10859 \def\nativeunicodechardefs{%
10860   \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNative
10861   \unicodechardefs
10862 }
10863
10864 % For native Unicode (XeTeX and LuaTeX).  Make the character token expand
10865 % to the sequences given in \unicodechardefs for printing.
10866 \def\DeclareUnicodeCharacterNativeAtU#1#2{%
10867   \def\UTFAtUTmp{#2}
10868   \expandafter\globallet\csname uni:#1\endcsname \UTFAtUTmp
10869 }
10870
10871 % Native Unicode (XeTeX and LuaTeX) @U command definitions
10872 \def\nativeunicodechardefsatu{%
10873   \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNativeAtU
10874   \unicodechardefs
10875 }
10876
10877 % Native Unicode (XeTeX and LuaTeX) catcode other non global definitions
10878 \def\nativeunicodecharscatcodeothernonglobal{%
10879   \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNativeOther
10880   \unicodechardefs
10881 }
10882
10883 % Catcode (non-ASCII or native Unicode) are set to \other (non-global
10884 % assignments).
10885 \def\setcharscatcodeothernonglobal{%
10886   \iftxiusebytewiseio
10887     \setnonasciicharscatcodenonglobal\other
10888   \else
10889     \nativeunicodecharscatcodeothernonglobal
10890   \fi
10891 }
10892
10893 % US-ASCII character definitions.
10894 \def\asciichardefs{% nothing need be done
10895    \relax
10896 }
10897
10898 % Redefine the active definitions of non-ASCII characters to expand to
10899 % non-active tokens with the same character code.
10900 \def\nonasciistringdefs{%
10901   \setnonasciicharscatcode\active
10902   \def\defstringchar##1{\def##1{\string##1}}%
10903   %
10904   \defstringchar^^80\defstringchar^^81\defstringchar^^82\defstringchar^^83%
10905   \defstringchar^^84\defstringchar^^85\defstringchar^^86\defstringchar^^87%
10906   \defstringchar^^88\defstringchar^^89\defstringchar^^8a\defstringchar^^8b%
10907   \defstringchar^^8c\defstringchar^^8d\defstringchar^^8e\defstringchar^^8f%
10908   %
10909   \defstringchar^^90\defstringchar^^91\defstringchar^^92\defstringchar^^93%
10910   \defstringchar^^94\defstringchar^^95\defstringchar^^96\defstringchar^^97%
10911   \defstringchar^^98\defstringchar^^99\defstringchar^^9a\defstringchar^^9b%
10912   \defstringchar^^9c\defstringchar^^9d\defstringchar^^9e\defstringchar^^9f%
10913   %
10914   \defstringchar^^a0\defstringchar^^a1\defstringchar^^a2\defstringchar^^a3%
10915   \defstringchar^^a4\defstringchar^^a5\defstringchar^^a6\defstringchar^^a7%
10916   \defstringchar^^a8\defstringchar^^a9\defstringchar^^aa\defstringchar^^ab%
10917   \defstringchar^^ac\defstringchar^^ad\defstringchar^^ae\defstringchar^^af%
10918   %
10919   \defstringchar^^b0\defstringchar^^b1\defstringchar^^b2\defstringchar^^b3%
10920   \defstringchar^^b4\defstringchar^^b5\defstringchar^^b6\defstringchar^^b7%
10921   \defstringchar^^b8\defstringchar^^b9\defstringchar^^ba\defstringchar^^bb%
10922   \defstringchar^^bc\defstringchar^^bd\defstringchar^^be\defstringchar^^bf%
10923   %
10924   \defstringchar^^c0\defstringchar^^c1\defstringchar^^c2\defstringchar^^c3%
10925   \defstringchar^^c4\defstringchar^^c5\defstringchar^^c6\defstringchar^^c7%
10926   \defstringchar^^c8\defstringchar^^c9\defstringchar^^ca\defstringchar^^cb%
10927   \defstringchar^^cc\defstringchar^^cd\defstringchar^^ce\defstringchar^^cf%
10928   %
10929   \defstringchar^^d0\defstringchar^^d1\defstringchar^^d2\defstringchar^^d3%
10930   \defstringchar^^d4\defstringchar^^d5\defstringchar^^d6\defstringchar^^d7%
10931   \defstringchar^^d8\defstringchar^^d9\defstringchar^^da\defstringchar^^db%
10932   \defstringchar^^dc\defstringchar^^dd\defstringchar^^de\defstringchar^^df%
10933   %
10934   \defstringchar^^e0\defstringchar^^e1\defstringchar^^e2\defstringchar^^e3%
10935   \defstringchar^^e4\defstringchar^^e5\defstringchar^^e6\defstringchar^^e7%
10936   \defstringchar^^e8\defstringchar^^e9\defstringchar^^ea\defstringchar^^eb%
10937   \defstringchar^^ec\defstringchar^^ed\defstringchar^^ee\defstringchar^^ef%
10938   %
10939   \defstringchar^^f0\defstringchar^^f1\defstringchar^^f2\defstringchar^^f3%
10940   \defstringchar^^f4\defstringchar^^f5\defstringchar^^f6\defstringchar^^f7%
10941   \defstringchar^^f8\defstringchar^^f9\defstringchar^^fa\defstringchar^^fb%
10942   \defstringchar^^fc\defstringchar^^fd\defstringchar^^fe\defstringchar^^ff%
10943 }
10944
10945 % Write characters literally, instead of using active definitions for
10946 % printing the correct glyphs.
10947 \def\passthroughcharacters{%
10948   \iftxiusebytewiseio
10949     \nonasciistringdefs
10950   \else
10951     \passthroughcharstrue
10952   \fi
10953 }
10954
10955
10956 % define all the unicode characters we know about, for the sake of @U.
10957 \iftxinativeunicodecapable
10958   \nativeunicodechardefsatu
10959 \else
10960   \utfeightchardefs
10961 \fi
10962
10963
10964 % Make non-ASCII characters printable again for compatibility with
10965 % existing Texinfo documents that may use them, even without declaring a
10966 % document encoding.
10967 %
10968 \setnonasciicharscatcode \other
10969
10970
10971 \message{formatting,}
10972
10973 \newdimen\defaultparindent \defaultparindent = 15pt
10974
10975 \chapheadingskip = 15pt plus 4pt minus 2pt
10976 \secheadingskip = 12pt plus 3pt minus 2pt
10977 \subsecheadingskip = 9pt plus 2pt minus 2pt
10978
10979 % Prevent underfull vbox error messages.
10980 \vbadness = 10000
10981
10982 % Don't be very finicky about underfull hboxes, either.
10983 \hbadness = 6666
10984
10985 % Following George Bush, get rid of widows and orphans.
10986 \widowpenalty=10000
10987 \clubpenalty=10000
10988
10989 % Use TeX 3.0's \emergencystretch to help line breaking, but if we're
10990 % using an old version of TeX, don't do anything.  We want the amount of
10991 % stretch added to depend on the line length, hence the dependence on
10992 % \hsize.  We call this whenever the paper size is set.
10993 %
10994 \def\setemergencystretch{%
10995   \ifx\emergencystretch\thisisundefined
10996     % Allow us to assign to \emergencystretch anyway.
10997     \def\emergencystretch{\dimen0}%
10998   \else
10999     \emergencystretch = .15\hsize
11000   \fi
11001 }
11002
11003 % Parameters in order: 1) textheight; 2) textwidth;
11004 % 3) voffset; 4) hoffset; 5) binding offset; 6) topskip;
11005 % 7) physical page height; 8) physical page width.
11006 %
11007 % We also call \setleading{\textleading}, so the caller should define
11008 % \textleading.  The caller should also set \parskip.
11009 %
11010 \def\internalpagesizes#1#2#3#4#5#6#7#8{%
11011   \voffset = #3\relax
11012   \topskip = #6\relax
11013   \splittopskip = \topskip
11014   %
11015   \vsize = #1\relax
11016   \advance\vsize by \topskip
11017   \outervsize = \vsize
11018   \advance\outervsize by 2\topandbottommargin
11019   \pageheight = \vsize
11020   %
11021   \hsize = #2\relax
11022   \outerhsize = \hsize
11023   \advance\outerhsize by 0.5in
11024   \pagewidth = \hsize
11025   %
11026   \normaloffset = #4\relax
11027   \bindingoffset = #5\relax
11028   %
11029   \ifpdf
11030     \pdfpageheight #7\relax
11031     \pdfpagewidth #8\relax
11032     % if we don't reset these, they will remain at "1 true in" of
11033     % whatever layout pdftex was dumped with.
11034     \pdfhorigin = 1 true in
11035     \pdfvorigin = 1 true in
11036   \fi
11037   %
11038   \setleading{\textleading}
11039   %
11040   \parindent = \defaultparindent
11041   \setemergencystretch
11042 }
11043
11044 % @letterpaper (the default).
11045 \def\letterpaper{{\globaldefs = 1
11046   \parskip = 3pt plus 2pt minus 1pt
11047   \textleading = 13.2pt
11048   %
11049   % If page is nothing but text, make it come out even.
11050   \internalpagesizes{607.2pt}{6in}% that's 46 lines
11051                     {\voffset}{.25in}%
11052                     {\bindingoffset}{36pt}%
11053                     {11in}{8.5in}%
11054 }}
11055
11056 % Use @smallbook to reset parameters for 7x9.25 trim size.
11057 \def\smallbook{{\globaldefs = 1
11058   \parskip = 2pt plus 1pt
11059   \textleading = 12pt
11060   %
11061   \internalpagesizes{7.5in}{5in}%
11062                     {-.2in}{0in}%
11063                     {\bindingoffset}{16pt}%
11064                     {9.25in}{7in}%
11065   %
11066   \lispnarrowing = 0.3in
11067   \tolerance = 700
11068   \hfuzz = 1pt
11069   \contentsrightmargin = 0pt
11070   \defbodyindent = .5cm
11071 }}
11072
11073 % Use @smallerbook to reset parameters for 6x9 trim size.
11074 % (Just testing, parameters still in flux.)
11075 \def\smallerbook{{\globaldefs = 1
11076   \parskip = 1.5pt plus 1pt
11077   \textleading = 12pt
11078   %
11079   \internalpagesizes{7.4in}{4.8in}%
11080                     {-.2in}{-.4in}%
11081                     {0pt}{14pt}%
11082                     {9in}{6in}%
11083   %
11084   \lispnarrowing = 0.25in
11085   \tolerance = 700
11086   \hfuzz = 1pt
11087   \contentsrightmargin = 0pt
11088   \defbodyindent = .4cm
11089 }}
11090
11091 % Use @afourpaper to print on European A4 paper.
11092 \def\afourpaper{{\globaldefs = 1
11093   \parskip = 3pt plus 2pt minus 1pt
11094   \textleading = 13.2pt
11095   %
11096   % Double-side printing via postscript on Laserjet 4050
11097   % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm.
11098   % To change the settings for a different printer or situation, adjust
11099   % \normaloffset until the front-side and back-side texts align.  Then
11100   % do the same for \bindingoffset.  You can set these for testing in
11101   % your texinfo source file like this:
11102   % @tex
11103   % \global\normaloffset = -6mm
11104   % \global\bindingoffset = 10mm
11105   % @end tex
11106   \internalpagesizes{673.2pt}{160mm}% that's 51 lines
11107                     {\voffset}{\hoffset}%
11108                     {\bindingoffset}{44pt}%
11109                     {297mm}{210mm}%
11110   %
11111   \tolerance = 700
11112   \hfuzz = 1pt
11113   \contentsrightmargin = 0pt
11114   \defbodyindent = 5mm
11115 }}
11116
11117 % Use @afivepaper to print on European A5 paper.
11118 % From romildo@urano.iceb.ufop.br, 2 July 2000.
11119 % He also recommends making @example and @lisp be small.
11120 \def\afivepaper{{\globaldefs = 1
11121   \parskip = 2pt plus 1pt minus 0.1pt
11122   \textleading = 12.5pt
11123   %
11124   \internalpagesizes{160mm}{120mm}%
11125                     {\voffset}{\hoffset}%
11126                     {\bindingoffset}{8pt}%
11127                     {210mm}{148mm}%
11128   %
11129   \lispnarrowing = 0.2in
11130   \tolerance = 800
11131   \hfuzz = 1.2pt
11132   \contentsrightmargin = 0pt
11133   \defbodyindent = 2mm
11134   \tableindent = 12mm
11135 }}
11136
11137 % A specific text layout, 24x15cm overall, intended for A4 paper.
11138 \def\afourlatex{{\globaldefs = 1
11139   \afourpaper
11140   \internalpagesizes{237mm}{150mm}%
11141                     {\voffset}{4.6mm}%
11142                     {\bindingoffset}{7mm}%
11143                     {297mm}{210mm}%
11144   %
11145   % Must explicitly reset to 0 because we call \afourpaper.
11146   \globaldefs = 0
11147 }}
11148
11149 % Use @afourwide to print on A4 paper in landscape format.
11150 \def\afourwide{{\globaldefs = 1
11151   \afourpaper
11152   \internalpagesizes{241mm}{165mm}%
11153                     {\voffset}{-2.95mm}%
11154                     {\bindingoffset}{7mm}%
11155                     {297mm}{210mm}%
11156   \globaldefs = 0
11157 }}
11158
11159 % @pagesizes TEXTHEIGHT[,TEXTWIDTH]
11160 % Perhaps we should allow setting the margins, \topskip, \parskip,
11161 % and/or leading, also. Or perhaps we should compute them somehow.
11162 %
11163 \parseargdef\pagesizes{\pagesizesyyy #1,,\finish}
11164 \def\pagesizesyyy#1,#2,#3\finish{{%
11165   \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi
11166   \globaldefs = 1
11167   %
11168   \parskip = 3pt plus 2pt minus 1pt
11169   \setleading{\textleading}%
11170   %
11171   \dimen0 = #1\relax
11172   \advance\dimen0 by \voffset
11173   %
11174   \dimen2 = \hsize
11175   \advance\dimen2 by \normaloffset
11176   %
11177   \internalpagesizes{#1}{\hsize}%
11178                     {\voffset}{\normaloffset}%
11179                     {\bindingoffset}{44pt}%
11180                     {\dimen0}{\dimen2}%
11181 }}
11182
11183 % Set default to letter.
11184 %
11185 \letterpaper
11186
11187
11188 \message{and turning on texinfo input format.}
11189
11190 \def^^L{\par} % remove \outer, so ^L can appear in an @comment
11191
11192 % DEL is a comment character, in case @c does not suffice.
11193 \catcode`\^^? = 14
11194
11195 % Define macros to output various characters with catcode for normal text.
11196 \catcode`\"=\other \def\normaldoublequote{"}
11197 \catcode`\$=\other \def\normaldollar{$}%$ font-lock fix
11198 \catcode`\+=\other \def\normalplus{+}
11199 \catcode`\<=\other \def\normalless{<}
11200 \catcode`\>=\other \def\normalgreater{>}
11201 \catcode`\^=\other \def\normalcaret{^}
11202 \catcode`\_=\other \def\normalunderscore{_}
11203 \catcode`\|=\other \def\normalverticalbar{|}
11204 \catcode`\~=\other \def\normaltilde{~}
11205
11206 % This macro is used to make a character print one way in \tt
11207 % (where it can probably be output as-is), and another way in other fonts,
11208 % where something hairier probably needs to be done.
11209 %
11210 % #1 is what to print if we are indeed using \tt; #2 is what to print
11211 % otherwise.  Since all the Computer Modern typewriter fonts have zero
11212 % interword stretch (and shrink), and it is reasonable to expect all
11213 % typewriter fonts to have this, we can check that font parameter.
11214 %
11215 \def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi}
11216
11217 % Same as above, but check for italic font.  Actually this also catches
11218 % non-italic slanted fonts since it is impossible to distinguish them from
11219 % italic fonts.  But since this is only used by $ and it uses \sl anyway
11220 % this is not a problem.
11221 \def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi}
11222
11223 % Set catcodes for Texinfo file
11224
11225 % Active characters for printing the wanted glyph.
11226 % Most of these we simply print from the \tt font, but for some, we can
11227 % use math or other variants that look better in normal text.
11228 %
11229 \catcode`\"=\active
11230 \def\activedoublequote{{\tt\char34}}
11231 \let"=\activedoublequote
11232 \catcode`\~=\active \def\activetilde{{\tt\char126}} \let~ = \activetilde
11233 \chardef\hatchar=`\^
11234 \catcode`\^=\active \def\activehat{{\tt \hatchar}} \let^ = \activehat
11235
11236 \catcode`\_=\active
11237 \def_{\ifusingtt\normalunderscore\_}
11238 \def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }
11239 \let\realunder=_
11240
11241 \catcode`\|=\active \def|{{\tt\char124}}
11242
11243 \chardef \less=`\<
11244 \catcode`\<=\active \def\activeless{{\tt \less}}\let< = \activeless
11245 \chardef \gtr=`\>
11246 \catcode`\>=\active \def\activegtr{{\tt \gtr}}\let> = \activegtr
11247 \catcode`\+=\active \def+{{\tt \char 43}}
11248 \catcode`\$=\active \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix
11249 \catcode`\-=\active \let-=\normaldash
11250
11251
11252 % used for headline/footline in the output routine, in case the page
11253 % breaks in the middle of an @tex block.
11254 \def\texinfochars{%
11255   \let< = \activeless
11256   \let> = \activegtr
11257   \let~ = \activetilde 
11258   \let^ = \activehat
11259   \markupsetuplqdefault \markupsetuprqdefault 
11260   \let\b = \strong
11261   \let\i = \smartitalic
11262   % in principle, all other definitions in \tex have to be undone too.
11263 }
11264
11265 % Used sometimes to turn off (effectively) the active characters even after
11266 % parsing them.
11267 \def\turnoffactive{%
11268   \normalturnoffactive
11269   \otherbackslash
11270 }
11271
11272 \catcode`\@=0
11273
11274 % \backslashcurfont outputs one backslash character in current font,
11275 % as in \char`\\.
11276 \global\chardef\backslashcurfont=`\\
11277 \global\let\rawbackslashxx=\backslashcurfont  % let existing .??s files work
11278
11279 % \realbackslash is an actual character `\' with catcode other, and
11280 % \doublebackslash is two of them (for the pdf outlines).
11281 {\catcode`\\=\other @gdef@realbackslash{\} @gdef@doublebackslash{\\}}
11282
11283 % In Texinfo, backslash is an active character; it prints the backslash
11284 % in fixed width font.
11285 \catcode`\\=\active  % @ for escape char from now on.
11286
11287 % Print a typewriter backslash.  For math mode, we can't simply use
11288 % \backslashcurfont: the story here is that in math mode, the \char
11289 % of \backslashcurfont ends up printing the roman \ from the math symbol
11290 % font (because \char in math mode uses the \mathcode, and plain.tex
11291 % sets \mathcode`\\="026E).  Hence we use an explicit \mathchar,
11292 % which is the decimal equivalent of "715c (class 7, e.g., use \fam;
11293 % ignored family value; char position "5C).  We can't use " for the
11294 % usual hex value because it has already been made active.
11295
11296 @def@ttbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}}
11297 @let@backslashchar = @ttbackslash % @backslashchar{} is for user documents.
11298
11299 % \rawbackslash defines an active \ to do \backslashcurfont.
11300 % \otherbackslash defines an active \ to be a literal `\' character with
11301 % catcode other.  We switch back and forth between these.
11302 @gdef@rawbackslash{@let\=@backslashcurfont}
11303 @gdef@otherbackslash{@let\=@realbackslash}
11304
11305 % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
11306 % the literal character `\'.
11307 %
11308 {@catcode`- = @active
11309  @gdef@normalturnoffactive{%
11310    @passthroughcharacters
11311    @let-=@normaldash
11312    @let"=@normaldoublequote
11313    @let$=@normaldollar %$ font-lock fix
11314    @let+=@normalplus
11315    @let<=@normalless
11316    @let>=@normalgreater
11317    @let^=@normalcaret
11318    @let_=@normalunderscore
11319    @let|=@normalverticalbar
11320    @let~=@normaltilde
11321    @let\=@ttbackslash
11322    @markupsetuplqdefault
11323    @markupsetuprqdefault
11324    @unsepspaces
11325  }
11326 }
11327
11328 % If a .fmt file is being used, characters that might appear in a file
11329 % name cannot be active until we have parsed the command line.
11330 % So turn them off again, and have @fixbackslash turn them back on.
11331 @catcode`+=@other @catcode`@_=@other
11332
11333 % \enablebackslashhack - allow file to begin `\input texinfo'
11334 %
11335 % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
11336 % That is what \eatinput is for; after that, the `\' should revert to printing
11337 % a backslash.
11338 % If the file did not have a `\input texinfo', then it is turned off after
11339 % the first line; otherwise the first `\' in the file would cause an error.
11340 % This is used on the very last line of this file, texinfo.tex.
11341 % We also use @c to call @fixbackslash, in case ends of lines are hidden.
11342 {
11343 @catcode`@^=7
11344 @catcode`@^^M=13@gdef@enablebackslashhack{%
11345   @global@let\ = @eatinput%
11346   @catcode`@^^M=13%
11347   @def@c{@fixbackslash@c}%
11348   @def ^^M{@let^^M@secondlinenl}%
11349   @gdef @secondlinenl{@let^^M@thirdlinenl}%
11350   @gdef @thirdlinenl{@fixbackslash}%
11351 }}
11352
11353 {@catcode`@^=7 @catcode`@^^M=13%
11354 @gdef@eatinput input texinfo#1^^M{@fixbackslash}}
11355
11356 % Emergency active definition of newline, in case an active newline token
11357 % appears by mistake.
11358 {@catcode`@^=7 @catcode13=13%
11359 @gdef@enableemergencynewline{%
11360   @gdef^^M{%
11361     @par%
11362     %<warning: active newline>@par%
11363 }}}
11364
11365
11366 @gdef@fixbackslash{%
11367   @ifx\@eatinput @let\ = @ttbackslash @fi
11368   @catcode13=5 % regular end of line
11369   @enableemergencynewline
11370   @let@c=@texinfoc
11371   % Also turn back on active characters that might appear in the input
11372   % file name, in case not using a pre-dumped format.
11373   @catcode`+=@active
11374   @catcode`@_=@active
11375   %
11376   % If texinfo.cnf is present on the system, read it.
11377   % Useful for site-wide @afourpaper, etc.  This macro, @fixbackslash, gets
11378   % called at the beginning of every Texinfo file.  Not opening texinfo.cnf
11379   % directly in this file, texinfo.tex, makes it possible to make a format
11380   % file for Texinfo.
11381   %
11382   @openin 1 texinfo.cnf
11383   @ifeof 1 @else @input texinfo.cnf @fi
11384   @closein 1
11385 }
11386
11387
11388 % Say @foo, not \foo, in error messages.
11389 @escapechar = `@@
11390
11391 % These (along with & and #) are made active for url-breaking, so need
11392 % active definitions as the normal characters.
11393 @def@normaldot{.}
11394 @def@normalquest{?}
11395 @def@normalslash{/}
11396
11397 % These look ok in all fonts, so just make them not special.
11398 % @hashchar{} gets its own user-level command, because of #line.
11399 @catcode`@& = @other @def@normalamp{&}
11400 @catcode`@# = @other @def@normalhash{#}
11401 @catcode`@% = @other @def@normalpercent{%}
11402
11403 @let @hashchar = @normalhash
11404
11405 @c Finally, make ` and ' active, so that txicodequoteundirected and
11406 @c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}.  If we
11407 @c don't make ` and ' active, @code will not get them as active chars.
11408 @c Do this last of all since we use ` in the previous @catcode assignments.
11409 @catcode`@'=@active
11410 @catcode`@`=@active
11411 @markupsetuplqdefault
11412 @markupsetuprqdefault
11413
11414 @c Local variables:
11415 @c eval: (add-hook 'write-file-hooks 'time-stamp)
11416 @c page-delimiter: "^\\\\message\\|emacs-page"
11417 @c time-stamp-start: "def\\\\texinfoversion{"
11418 @c time-stamp-format: "%:y-%02m-%02d.%02H"
11419 @c time-stamp-end: "}"
11420 @c End:
11421
11422 @c vim:sw=2:
11423
11424 @ignore
11425    arch-tag: e1b36e32-c96e-4135-a41a-0b2efa2ea115
11426 @end ignore
11427 @enablebackslashhack