VirtualBox

source: kBuild/trunk/src/sed/build-aux/texinfo.tex@ 3613

Last change on this file since 3613 was 3611, checked in by bird, 7 months ago

vendor/sed/current: GNU sed 4.9 (sed-4.9.tar.xz sha256:6e226b732e1cd739464ad6862bd1a1aba42d7982922da7a53519631d24975181)

File size: 368.6 KB
Line 
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{2022-10-01.15}
7%
8% Copyright 1985, 1986, 1988, 1990-2022 Free Software Foundation, Inc.
9%
10% This texinfo.tex file is free software: you can redistribute it and/or
11% modify it under the terms of the GNU General Public License as
12% published by the Free Software Foundation, either version 3 of the
13% License, or (at your option) any later version.
14%
15% This texinfo.tex file is distributed in the hope that it will be
16% useful, but WITHOUT ANY WARRANTY; without even the implied warranty
17% of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18% General Public License for more details.
19%
20% You should have received a copy of the GNU General Public License
21% along with this program. If not, see <https://www.gnu.org/licenses/>.
22%
23% As a special exception, when this file is read by TeX when processing
24% a Texinfo source document, you may use the result without
25% restriction. This Exception is an additional permission under section 7
26% of the GNU General Public License, version 3 ("GPLv3").
27%
28% Please try the latest version of texinfo.tex before submitting bug
29% reports; you can get the latest version from:
30% https://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or
31% https://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or
32% https://www.gnu.org/software/texinfo/ (the Texinfo home page)
33% The texinfo.tex in any given distribution could well be out
34% of date, so if that's what you're using, please check.
35%
36% Send bug reports to [email protected]. Please include a
37% complete document in each bug report with which we can reproduce the
38% problem. Patches are, of course, greatly appreciated.
39%
40% To process a Texinfo manual with TeX, it's most reliable to use the
41% texi2dvi shell script that comes with the distribution. For a simple
42% manual foo.texi, however, you can get away with this:
43% tex foo.texi
44% texindex foo.??
45% tex foo.texi
46% tex foo.texi
47% dvips foo.dvi -o # or whatever; this makes foo.ps.
48% The extra TeX runs get the cross-reference information correct.
49% Sometimes one run after texindex suffices, and sometimes you need more
50% than two; texi2dvi does it as many times as necessary.
51%
52% It is possible to adapt texinfo.tex for other languages, to some
53% extent. You can get the existing language-specific files from the
54% full Texinfo distribution.
55%
56% The GNU Texinfo home page is https://www.gnu.org/software/texinfo.
57
58
59\message{Loading texinfo [version \texinfoversion]:}
60
61% If in a .fmt file, print the version number
62% and turn on active characters that we couldn't do earlier because
63% they might have appeared in the input file name.
64\everyjob{\message{[Texinfo version \texinfoversion]}%
65 \catcode`+=\active \catcode`\_=\active}
66
67% LaTeX's \typeout. This ensures that the messages it is used for
68% are identical in format to the corresponding ones from latex/pdflatex.
69\def\typeout{\immediate\write17}%
70
71\chardef\other=12
72
73% We never want plain's \outer definition of \+ in Texinfo.
74% For @tex, we can use \tabalign.
75\let\+ = \relax
76
77% Save some plain tex macros whose names we will redefine.
78\let\ptexb=\b
79\let\ptexbullet=\bullet
80\let\ptexc=\c
81\let\ptexcomma=\,
82\let\ptexdot=\.
83\let\ptexdots=\dots
84\let\ptexend=\end
85\let\ptexequiv=\equiv
86\let\ptexexclam=\!
87\let\ptexfootnote=\footnote
88\let\ptexgtr=>
89\let\ptexhat=^
90\let\ptexi=\i
91\let\ptexindent=\indent
92\let\ptexinsert=\insert
93\let\ptexlbrace=\{
94\let\ptexless=<
95\let\ptexnewwrite\newwrite
96\let\ptexnoindent=\noindent
97\let\ptexplus=+
98\let\ptexraggedright=\raggedright
99\let\ptexrbrace=\}
100\let\ptexslash=\/
101\let\ptexsp=\sp
102\let\ptexstar=\*
103\let\ptexsup=\sup
104\let\ptext=\t
105\let\ptextop=\top
106{\catcode`\'=\active \global\let\ptexquoteright'}% active in plain's math mode
107
108% If this character appears in an error message or help string, it
109% starts a new line in the output.
110\newlinechar = `^^J
111
112% Use TeX 3.0's \inputlineno to get the line number, for better error
113% messages, but if we're using an old version of TeX, don't do anything.
114%
115\ifx\inputlineno\thisisundefined
116 \let\linenumber = \empty % Pre-3.0.
117\else
118 \def\linenumber{l.\the\inputlineno:\space}
119\fi
120
121% Set up fixed words for English if not already set.
122\ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi
123\ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi
124\ifx\putworderror\undefined \gdef\putworderror{error}\fi
125\ifx\putwordfile\undefined \gdef\putwordfile{file}\fi
126\ifx\putwordin\undefined \gdef\putwordin{in}\fi
127\ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi
128\ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi
129\ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi
130\ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi
131\ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi
132\ifx\putwordNoTitle\undefined \gdef\putwordNoTitle{No Title}\fi
133\ifx\putwordof\undefined \gdef\putwordof{of}\fi
134\ifx\putwordon\undefined \gdef\putwordon{on}\fi
135\ifx\putwordpage\undefined \gdef\putwordpage{page}\fi
136\ifx\putwordsection\undefined \gdef\putwordsection{section}\fi
137\ifx\putwordSection\undefined \gdef\putwordSection{Section}\fi
138\ifx\putwordsee\undefined \gdef\putwordsee{see}\fi
139\ifx\putwordSee\undefined \gdef\putwordSee{See}\fi
140\ifx\putwordShortTOC\undefined \gdef\putwordShortTOC{Short Contents}\fi
141\ifx\putwordTOC\undefined \gdef\putwordTOC{Table of Contents}\fi
142%
143\ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi
144\ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi
145\ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi
146\ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi
147\ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi
148\ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi
149\ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi
150\ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi
151\ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi
152\ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi
153\ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi
154\ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi
155%
156\ifx\putwordDefmac\undefined \gdef\putwordDefmac{Macro}\fi
157\ifx\putwordDefspec\undefined \gdef\putwordDefspec{Special Form}\fi
158\ifx\putwordDefvar\undefined \gdef\putwordDefvar{Variable}\fi
159\ifx\putwordDefopt\undefined \gdef\putwordDefopt{User Option}\fi
160\ifx\putwordDeffunc\undefined \gdef\putwordDeffunc{Function}\fi
161
162% Give the space character the catcode for a space.
163\def\spaceisspace{\catcode`\ =10\relax}
164
165% Likewise for ^^M, the end of line character.
166\def\endlineisspace{\catcode13=10\relax}
167
168\chardef\dashChar = `\-
169\chardef\slashChar = `\/
170\chardef\underChar = `\_
171
172% Ignore a token.
173%
174\def\gobble#1{}
175
176% The following is used inside several \edef's.
177\def\makecsname#1{\expandafter\noexpand\csname#1\endcsname}
178
179% Hyphenation fixes.
180\hyphenation{
181 Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script
182 ap-pen-dix bit-map bit-maps
183 data-base data-bases eshell fall-ing half-way long-est man-u-script
184 man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm
185 par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces
186 spell-ing spell-ings
187 stand-alone strong-est time-stamp time-stamps which-ever white-space
188 wide-spread wrap-around
189}
190
191% Sometimes it is convenient to have everything in the transcript file
192% and nothing on the terminal. We don't just call \tracingall here,
193% since that produces some useless output on the terminal. We also make
194% some effort to order the tracing commands to reduce output in the log
195% file; cf. trace.sty in LaTeX.
196%
197\def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
198\def\loggingall{%
199 \tracingstats2
200 \tracingpages1
201 \tracinglostchars2 % 2 gives us more in etex
202 \tracingparagraphs1
203 \tracingoutput1
204 \tracingmacros2
205 \tracingrestores1
206 \showboxbreadth\maxdimen \showboxdepth\maxdimen
207 \ifx\eTeXversion\thisisundefined\else % etex gives us more logging
208 \tracingscantokens1
209 \tracingifs1
210 \tracinggroups1
211 \tracingnesting2
212 \tracingassigns1
213 \fi
214 \tracingcommands3 % 3 gives us more in etex
215 \errorcontextlines16
216}%
217
218% @errormsg{MSG}. Do the index-like expansions on MSG, but if things
219% aren't perfect, it's not the end of the world, being an error message,
220% after all.
221%
222\def\errormsg{\begingroup \indexnofonts \doerrormsg}
223\def\doerrormsg#1{\errmessage{#1}}
224
225% add check for \lastpenalty to plain's definitions. If the last thing
226% we did was a \nobreak, we don't want to insert more space.
227%
228\def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount
229 \removelastskip\penalty-50\smallskip\fi\fi}
230\def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount
231 \removelastskip\penalty-100\medskip\fi\fi}
232\def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount
233 \removelastskip\penalty-200\bigskip\fi\fi}
234
235%
236 Output routine
237%
238
239% For a final copy, take out the rectangles
240% that mark overfull boxes (in case you have decided
241% that the text looks ok even though it passes the margin).
242%
243\def\finalout{\overfullrule=0pt }
244
245% Output a mark which sets \thischapter, \thissection and \thiscolor.
246% We dump everything together because we only have one kind of mark.
247% This works because we only use \botmark / \topmark, not \firstmark.
248%
249% A mark contains a subexpression of the \ifcase ... \fi construct.
250% \get*marks macros below extract the needed part using \ifcase.
251%
252% Another complication is to let the user choose whether \thischapter
253% (\thissection) refers to the chapter (section) in effect at the top
254% of a page, or that at the bottom of a page.
255
256% \domark is called twice inside \chapmacro, to add one
257% mark before the section break, and one after.
258% In the second call \prevchapterdefs is the same as \currentchapterdefs,
259% and \prevsectiondefs is the same as \currentsectiondefs.
260% Then if the page is not broken at the mark, some of the previous
261% section appears on the page, and we can get the name of this section
262% from \firstmark for @everyheadingmarks top.
263% @everyheadingmarks bottom uses \botmark.
264%
265% See page 260 of The TeXbook.
266\def\domark{%
267 \toks0=\expandafter{\currentchapterdefs}%
268 \toks2=\expandafter{\currentsectiondefs}%
269 \toks4=\expandafter{\prevchapterdefs}%
270 \toks6=\expandafter{\prevsectiondefs}%
271 \toks8=\expandafter{\currentcolordefs}%
272 \mark{%
273 \the\toks0 \the\toks2 % 0: marks for @everyheadingmarks top
274 \noexpand\or \the\toks4 \the\toks6 % 1: for @everyheadingmarks bottom
275 \noexpand\else \the\toks8 % 2: color marks
276 }%
277}
278
279% \gettopheadingmarks, \getbottomheadingmarks,
280% \getcolormarks - extract needed part of mark.
281%
282% \topmark doesn't work for the very first chapter (after the title
283% page or the contents), so we use \firstmark there -- this gets us
284% the mark with the chapter defs, unless the user sneaks in, e.g.,
285% @setcolor (or @url, or @link, etc.) between @contents and the very
286% first @chapter.
287\def\gettopheadingmarks{%
288 \ifcase0\the\savedtopmark\fi
289 \ifx\thischapter\empty \ifcase0\firstmark\fi \fi
290}
291\def\getbottomheadingmarks{\ifcase1\botmark\fi}
292\def\getcolormarks{\ifcase2\the\savedtopmark\fi}
293
294% Avoid "undefined control sequence" errors.
295\def\currentchapterdefs{}
296\def\currentsectiondefs{}
297\def\currentsection{}
298\def\prevchapterdefs{}
299\def\prevsectiondefs{}
300\def\currentcolordefs{}
301
302% Margin to add to right of even pages, to left of odd pages.
303\newdimen\bindingoffset
304\newdimen\normaloffset
305\newdimen\txipagewidth \newdimen\txipageheight
306
307% Main output routine.
308%
309\chardef\PAGE = 255
310\newtoks\defaultoutput
311\defaultoutput = {\savetopmark\onepageout{\pagecontents\PAGE}}
312\output=\expandafter{\the\defaultoutput}
313
314\newbox\headlinebox
315\newbox\footlinebox
316
317% When outputting the double column layout for indices, an output routine
318% is run several times, hiding the original value of \topmark. Hence, save
319% \topmark at the beginning.
320%
321\newtoks\savedtopmark
322\newif\iftopmarksaved
323\topmarksavedtrue
324\def\savetopmark{%
325 \iftopmarksaved\else
326 \global\savedtopmark=\expandafter{\topmark}%
327 \global\topmarksavedtrue
328 \fi
329}
330
331% \onepageout takes a vbox as an argument.
332% \shipout a vbox for a single page, adding an optional header, footer
333% and footnote. This also causes index entries for this page to be written
334% to the auxiliary files.
335%
336\def\onepageout#1{%
337 \hoffset=\normaloffset
338 %
339 \ifodd\pageno \advance\hoffset by \bindingoffset
340 \else \advance\hoffset by -\bindingoffset\fi
341 %
342 \checkchapterpage
343 %
344 % Make the heading and footing. \makeheadline and \makefootline
345 % use the contents of \headline and \footline.
346 \def\commonheadfootline{\let\hsize=\txipagewidth \texinfochars}
347 \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi
348 \global\setbox\headlinebox = \vbox{\commonheadfootline \makeheadline}%
349 \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi
350 \global\setbox\footlinebox = \vbox{\commonheadfootline \makefootline}%
351 %
352 {%
353 % Set context for writing to auxiliary files like index files.
354 % Have to do this stuff outside the \shipout because we want it to
355 % take effect in \write's, yet the group defined by the \vbox ends
356 % before the \shipout runs.
357 %
358 \atdummies % don't expand commands in the output.
359 \turnoffactive
360 \shipout\vbox{%
361 % Do this early so pdf references go to the beginning of the page.
362 \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi
363 %
364 \unvbox\headlinebox
365 \pagebody{#1}%
366 \ifdim\ht\footlinebox > 0pt
367 % Only leave this space if the footline is nonempty.
368 % (We lessened \vsize for it in \oddfootingyyy.)
369 % The \baselineskip=24pt in plain's \makefootline has no effect.
370 \vskip 24pt
371 \unvbox\footlinebox
372 \fi
373 %
374 }%
375 }%
376 \global\topmarksavedfalse
377 \advancepageno
378 \ifnum\outputpenalty>-20000 \else\dosupereject\fi
379}
380
381\newinsert\margin \dimen\margin=\maxdimen
382
383% Main part of page, including any footnotes
384\def\pagebody#1{\vbox to\txipageheight{\boxmaxdepth=\maxdepth #1}}
385{\catcode`\@ =11
386\gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
387% marginal hacks, [email protected] (Juha Takala)
388\ifvoid\margin\else % marginal info is present
389 \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi
390\dimen@=\dp#1\relax \unvbox#1\relax
391\ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
392\ifr@ggedbottom \kern-\dimen@ \vfil \fi}
393}
394
395% Check if we are on the first page of a chapter. Used for printing headings.
396\newif\ifchapterpage
397\def\checkchapterpage{%
398 % Get the chapter that was current at the end of the last page
399 \ifcase1\the\savedtopmark\fi
400 \let\prevchaptername\thischaptername
401 %
402 \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi
403 \let\curchaptername\thischaptername
404 %
405 \ifx\curchaptername\prevchaptername
406 \chapterpagefalse
407 \else
408 \chapterpagetrue
409 \fi
410}
411
412% Argument parsing
413
414% Parse an argument, then pass it to #1. The argument is the rest of
415% the input line (except we remove a trailing comment). #1 should be a
416% macro which expects an ordinary undelimited TeX argument.
417% For example, \def\foo{\parsearg\fooxxx}.
418%
419\def\parsearg{\parseargusing{}}
420\def\parseargusing#1#2{%
421 \def\argtorun{#2}%
422 \begingroup
423 \obeylines
424 \spaceisspace
425 #1%
426 \parseargline\empty% Insert the \empty token, see \finishparsearg below.
427}
428
429{\obeylines %
430 \gdef\parseargline#1^^M{%
431 \endgroup % End of the group started in \parsearg.
432 \argremovecomment #1\comment\ArgTerm%
433 }%
434}
435
436% First remove any @comment, then any @c comment. Pass the result on to
437% \argcheckspaces.
438\def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm}
439\def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
440
441% Each occurrence of `\^^M' or `<space>\^^M' is replaced by a single space.
442%
443% \argremovec might leave us with trailing space, e.g.,
444% @end itemize @c foo
445% This space token undergoes the same procedure and is eventually removed
446% by \finishparsearg.
447%
448\def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M}
449\def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M}
450\def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{%
451 \def\temp{#3}%
452 \ifx\temp\empty
453 % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp:
454 \let\temp\finishparsearg
455 \else
456 \let\temp\argcheckspaces
457 \fi
458 % Put the space token in:
459 \temp#1 #3\ArgTerm
460}
461
462% If a _delimited_ argument is enclosed in braces, they get stripped; so
463% to get _exactly_ the rest of the line, we had to prevent such situation.
464% We prepended an \empty token at the very beginning and we expand it now,
465% just before passing the control to \argtorun.
466% (Similarly, we have to think about #3 of \argcheckspacesY above: it is
467% either the null string, or it ends with \^^M---thus there is no danger
468% that a pair of braces would be stripped.
469%
470% But first, we have to remove the trailing space token.
471%
472\def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}}
473
474
475% \parseargdef - define a command taking an argument on the line
476%
477% \parseargdef\foo{...}
478% is roughly equivalent to
479% \def\foo{\parsearg\Xfoo}
480% \def\Xfoo#1{...}
481\def\parseargdef#1{%
482 \expandafter \doparseargdef \csname\string#1\endcsname #1%
483}
484\def\doparseargdef#1#2{%
485 \def#2{\parsearg#1}%
486 \def#1##1%
487}
488
489% Several utility definitions with active space:
490{
491 \obeyspaces
492 \gdef\obeyedspace{ }
493
494 % Make each space character in the input produce a normal interword
495 % space in the output. Don't allow a line break at this space, as this
496 % is used only in environments like @example, where each line of input
497 % should produce a line of output anyway.
498 %
499 \gdef\sepspaces{\obeyspaces\let =\tie}
500
501 % If an index command is used in an @example environment, any spaces
502 % therein should become regular spaces in the raw index file, not the
503 % expansion of \tie (\leavevmode \penalty \@M \ ).
504 \gdef\unsepspaces{\let =\space}
505}
506
507
508\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
509
510% Define the framework for environments in texinfo.tex. It's used like this:
511%
512% \envdef\foo{...}
513% \def\Efoo{...}
514%
515% It's the responsibility of \envdef to insert \begingroup before the
516% actual body; @end closes the group after calling \Efoo. \envdef also
517% defines \thisenv, so the current environment is known; @end checks
518% whether the environment name matches. The \checkenv macro can also be
519% used to check whether the current environment is the one expected.
520%
521% Non-false conditionals (@iftex, @ifset) don't fit into this, so they
522% are not treated as environments; they don't open a group. (The
523% implementation of @end takes care not to call \endgroup in this
524% special case.)
525
526
527% At run-time, environments start with this:
528\def\startenvironment#1{\begingroup\def\thisenv{#1}}
529% initialize
530\let\thisenv\empty
531
532% ... but they get defined via ``\envdef\foo{...}'':
533\long\def\envdef#1#2{\def#1{\startenvironment#1#2}}
534\def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}}
535
536% Check whether we're in the right environment:
537\def\checkenv#1{%
538 \def\temp{#1}%
539 \ifx\thisenv\temp
540 \else
541 \badenverr
542 \fi
543}
544
545% Environment mismatch, #1 expected:
546\def\badenverr{%
547 \errhelp = \EMsimple
548 \errmessage{This command can appear only \inenvironment\temp,
549 not \inenvironment\thisenv}%
550}
551\def\inenvironment#1{%
552 \ifx#1\empty
553 outside of any environment%
554 \else
555 in environment \expandafter\string#1%
556 \fi
557}
558
559
560% @end foo calls \checkenv and executes the definition of \Efoo.
561\parseargdef\end{%
562 \if 1\csname iscond.#1\endcsname
563 \else
564 % The general wording of \badenverr may not be ideal.
565 \expandafter\checkenv\csname#1\endcsname
566 \csname E#1\endcsname
567 \endgroup
568 \fi
569}
570
571\newhelp\EMsimple{Press RETURN to continue.}
572
573
574% Be sure we're in horizontal mode when doing a tie, since we make space
575% equivalent to this in @example-like environments. Otherwise, a space
576% at the beginning of a line will start with \penalty -- and
577% since \penalty is valid in vertical mode, we'd end up putting the
578% penalty on the vertical list instead of in the new paragraph.
579{\catcode`@ = 11
580 % Avoid using \@M directly, because that causes trouble
581 % if the definition is written into an index file.
582 \global\let\tiepenalty = \@M
583 \gdef\tie{\leavevmode\penalty\tiepenalty\ }
584}
585
586% @: forces normal size whitespace following.
587\def\:{\spacefactor=1000 }
588
589% @* forces a line break.
590\def\*{\unskip\hfil\break\hbox{}\ignorespaces}
591
592% @/ allows a line break.
593\let\/=\allowbreak
594
595% @. is an end-of-sentence period.
596\def\.{.\spacefactor=\endofsentencespacefactor\space}
597
598% @! is an end-of-sentence bang.
599\def\!{!\spacefactor=\endofsentencespacefactor\space}
600
601% @? is an end-of-sentence query.
602\def\?{?\spacefactor=\endofsentencespacefactor\space}
603
604% @w prevents a word break. Without the \leavevmode, @w at the
605% beginning of a paragraph, when TeX is still in vertical mode, would
606% produce a whole line of output instead of starting the paragraph.
607\def\w#1{\leavevmode\hbox{#1}}
608
609% @group ... @end group forces ... to be all on one page, by enclosing
610% it in a TeX vbox. We use \vtop instead of \vbox to construct the box
611% to keep its height that of a normal line. According to the rules for
612% \topskip (p.114 of the TeXbook), the glue inserted is
613% max (\topskip - \ht (first item), 0). If that height is large,
614% therefore, no glue is inserted, and the space between the headline and
615% the text is small, which looks bad.
616%
617% Another complication is that the group might be very large. This can
618% cause the glue on the previous page to be unduly stretched, because it
619% does not have much material. In this case, it's better to add an
620% explicit \vfill so that the extra space is at the bottom. The
621% threshold for doing this is if the group is more than \vfilllimit
622% percent of a page (\vfilllimit can be changed inside of @tex).
623%
624\newbox\groupbox
625\def\vfilllimit{0.7}
626%
627\envdef\group{%
628 \ifnum\catcode`\^^M=\active \else
629 \errhelp = \groupinvalidhelp
630 \errmessage{@group invalid in context where filling is enabled}%
631 \fi
632 \startsavinginserts
633 %
634 \setbox\groupbox = \vtop\bgroup
635 % Do @comment since we are called inside an environment such as
636 % @example, where each end-of-line in the input causes an
637 % end-of-line in the output. We don't want the end-of-line after
638 % the `@group' to put extra space in the output. Since @group
639 % should appear on a line by itself (according to the Texinfo
640 % manual), we don't worry about eating any user text.
641 \comment
642}
643%
644% The \vtop produces a box with normal height and large depth; thus, TeX puts
645% \baselineskip glue before it, and (when the next line of text is done)
646% \lineskip glue after it. Thus, space below is not quite equal to space
647% above. But it's pretty close.
648\def\Egroup{%
649 % To get correct interline space between the last line of the group
650 % and the first line afterwards, we have to propagate \prevdepth.
651 \endgraf % Not \par, as it may have been set to \lisppar.
652 \global\dimen1 = \prevdepth
653 \egroup % End the \vtop.
654 \addgroupbox
655 \prevdepth = \dimen1
656 \checkinserts
657}
658
659\def\addgroupbox{
660 % \dimen0 is the vertical size of the group's box.
661 \dimen0 = \ht\groupbox \advance\dimen0 by \dp\groupbox
662 % \dimen2 is how much space is left on the page (more or less).
663 \dimen2 = \txipageheight \advance\dimen2 by -\pagetotal
664 % if the group doesn't fit on the current page, and it's a big big
665 % group, force a page break.
666 \ifdim \dimen0 > \dimen2
667 \ifdim \pagetotal < \vfilllimit\txipageheight
668 \page
669 \fi
670 \fi
671 \box\groupbox
672}
673
674%
675% TeX puts in an \escapechar (i.e., `@') at the beginning of the help
676% message, so this ends up printing `@group can only ...'.
677%
678\newhelp\groupinvalidhelp{%
679group can only be used in environments such as @example,^^J%
680where each line of input produces a line of output.}
681
682% @need space-in-mils
683% forces a page break if there is not space-in-mils remaining.
684
685\newdimen\mil \mil=0.001in
686
687\parseargdef\need{%
688 % Ensure vertical mode, so we don't make a big box in the middle of a
689 % paragraph.
690 \par
691 %
692 % If the @need value is less than one line space, it's useless.
693 \dimen0 = #1\mil
694 \dimen2 = \ht\strutbox
695 \advance\dimen2 by \dp\strutbox
696 \ifdim\dimen0 > \dimen2
697 % This is similar to the 'needspace' module in LaTeX.
698 % The first penalty allows a break if the end of the page is
699 % not too far away. Following penalties and skips are discarded.
700 % Otherwise, require at least \dimen0 of vertical space.
701 %
702 % (We used to use a \vtop to reserve space, but this had spacing issues
703 % when followed by a section heading, as it was not a "discardable item".
704 % This also has the benefit of providing glue before the page break if
705 % there isn't enough space.)
706 \vskip0pt plus \dimen0
707 \penalty-100
708 \vskip0pt plus -\dimen0
709 \vskip \dimen0
710 \penalty9999
711 \vskip -\dimen0
712 \penalty0\relax % this hides the above glue from \safewhatsit and \dobreak
713 \fi
714}
715
716% @br forces paragraph break (and is undocumented).
717
718\let\br = \par
719
720% @page forces the start of a new page.
721%
722\def\page{\par\vfill\supereject}
723
724% @exdent text....
725% outputs text on separate line in roman font, starting at standard page margin
726
727% This records the amount of indent in the innermost environment.
728% That's how much \exdent should take out.
729\newskip\exdentamount
730
731% This defn is used inside fill environments such as @defun.
732\parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}
733
734% This defn is used inside nofill environments such as @example.
735\parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount
736 \leftline{\hskip\leftskip{\rm#1}}}}
737
738% @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current
739% paragraph. For more general purposes, use the \margin insertion
740% class. WHICH is `l' or `r'. Not documented, written for gawk manual.
741%
742\newskip\inmarginspacing \inmarginspacing=1cm
743\def\strutdepth{\dp\strutbox}
744%
745\def\doinmargin#1#2{\strut\vadjust{%
746 \nobreak
747 \kern-\strutdepth
748 \vtop to \strutdepth{%
749 \baselineskip=\strutdepth
750 \vss
751 % if you have multiple lines of stuff to put here, you'll need to
752 % make the vbox yourself of the appropriate size.
753 \ifx#1l%
754 \llap{\ignorespaces #2\hskip\inmarginspacing}%
755 \else
756 \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}%
757 \fi
758 \null
759 }%
760}}
761\def\inleftmargin{\doinmargin l}
762\def\inrightmargin{\doinmargin r}
763%
764% @inmargin{TEXT [, RIGHT-TEXT]}
765% (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right;
766% else use TEXT for both).
767%
768\def\inmargin#1{\parseinmargin #1,,\finish}
769\def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing.
770 \setbox0 = \hbox{\ignorespaces #2}%
771 \ifdim\wd0 > 0pt
772 \def\lefttext{#1}% have both texts
773 \def\righttext{#2}%
774 \else
775 \def\lefttext{#1}% have only one text
776 \def\righttext{#1}%
777 \fi
778 %
779 \ifodd\pageno
780 \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin
781 \else
782 \def\temp{\inleftmargin\lefttext}%
783 \fi
784 \temp
785}
786
787% @include FILE -- \input text of FILE.
788%
789\def\include{\parseargusing\filenamecatcodes\includezzz}
790\def\includezzz#1{%
791 \pushthisfilestack
792 \def\thisfile{#1}%
793 {%
794 \makevalueexpandable % we want to expand any @value in FILE.
795 \turnoffactive % and allow special characters in the expansion
796 \indexnofonts % Allow `@@' and other weird things in file names.
797 \wlog{texinfo.tex: doing @include of #1^^J}%
798 \edef\temp{\noexpand\input #1 }%
799 %
800 % This trickery is to read FILE outside of a group, in case it makes
801 % definitions, etc.
802 \expandafter
803 }\temp
804 \popthisfilestack
805}
806\def\filenamecatcodes{%
807 \catcode`\\=\other
808 \catcode`~=\other
809 \catcode`^=\other
810 \catcode`_=\other
811 \catcode`|=\other
812 \catcode`<=\other
813 \catcode`>=\other
814 \catcode`+=\other
815 \catcode`-=\other
816 \catcode`\`=\other
817 \catcode`\'=\other
818}
819
820\def\pushthisfilestack{%
821 \expandafter\pushthisfilestackX\popthisfilestack\StackTerm
822}
823\def\pushthisfilestackX{%
824 \expandafter\pushthisfilestackY\thisfile\StackTerm
825}
826\def\pushthisfilestackY #1\StackTerm #2\StackTerm {%
827 \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}%
828}
829
830\def\popthisfilestack{\errthisfilestackempty}
831\def\errthisfilestackempty{\errmessage{Internal error:
832 the stack of filenames is empty.}}
833%
834\def\thisfile{}
835
836% @center line
837% outputs that line, centered.
838%
839\parseargdef\center{%
840 \ifhmode
841 \let\centersub\centerH
842 \else
843 \let\centersub\centerV
844 \fi
845 \centersub{\hfil \ignorespaces#1\unskip \hfil}%
846 \let\centersub\relax % don't let the definition persist, just in case
847}
848\def\centerH#1{{%
849 \hfil\break
850 \advance\hsize by -\leftskip
851 \advance\hsize by -\rightskip
852 \line{#1}%
853 \break
854}}
855%
856\newcount\centerpenalty
857\def\centerV#1{%
858 % The idea here is the same as in \startdefun, \cartouche, etc.: if
859 % @center is the first thing after a section heading, we need to wipe
860 % out the negative parskip inserted by \sectionheading, but still
861 % prevent a page break here.
862 \centerpenalty = \lastpenalty
863 \ifnum\centerpenalty>10000 \vskip\parskip \fi
864 \ifnum\centerpenalty>9999 \penalty\centerpenalty \fi
865 \line{\kern\leftskip #1\kern\rightskip}%
866}
867
868% @sp n outputs n lines of vertical space
869%
870\parseargdef\sp{\vskip #1\baselineskip}
871
872% @comment ...line which is ignored...
873% @c is the same as @comment
874% @ignore ... @end ignore is another way to write a comment
875
876
877\def\c{\begingroup \catcode`\^^M=\active%
878\catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
879\cxxx}
880{\catcode`\^^M=\active \gdef\cxxx#1^^M{\endgroup}}
881%
882\let\comment\c
883
884% @paragraphindent NCHARS
885% We'll use ems for NCHARS, close enough.
886% NCHARS can also be the word `asis' or `none'.
887% We cannot feasibly implement @paragraphindent asis, though.
888%
889\def\asisword{asis} % no translation, these are keywords
890\def\noneword{none}
891%
892\parseargdef\paragraphindent{%
893 \def\temp{#1}%
894 \ifx\temp\asisword
895 \else
896 \ifx\temp\noneword
897 \defaultparindent = 0pt
898 \else
899 \defaultparindent = #1em
900 \fi
901 \fi
902 \parindent = \defaultparindent
903}
904
905% @exampleindent NCHARS
906% We'll use ems for NCHARS like @paragraphindent.
907% It seems @exampleindent asis isn't necessary, but
908% I preserve it to make it similar to @paragraphindent.
909\parseargdef\exampleindent{%
910 \def\temp{#1}%
911 \ifx\temp\asisword
912 \else
913 \ifx\temp\noneword
914 \lispnarrowing = 0pt
915 \else
916 \lispnarrowing = #1em
917 \fi
918 \fi
919}
920
921% @firstparagraphindent WORD
922% If WORD is `none', then suppress indentation of the first paragraph
923% after a section heading. If WORD is `insert', then do indent at such
924% paragraphs.
925%
926% The paragraph indentation is suppressed or not by calling
927% \suppressfirstparagraphindent, which the sectioning commands do.
928% We switch the definition of this back and forth according to WORD.
929% By default, we suppress indentation.
930%
931\def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent}
932\def\insertword{insert}
933%
934\parseargdef\firstparagraphindent{%
935 \def\temp{#1}%
936 \ifx\temp\noneword
937 \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent
938 \else\ifx\temp\insertword
939 \let\suppressfirstparagraphindent = \relax
940 \else
941 \errhelp = \EMsimple
942 \errmessage{Unknown @firstparagraphindent option `\temp'}%
943 \fi\fi
944}
945
946% Here is how we actually suppress indentation. Redefine \everypar to
947% \kern backwards by \parindent, and then reset itself to empty.
948%
949% We also make \indent itself not actually do anything until the next
950% paragraph.
951%
952\gdef\dosuppressfirstparagraphindent{%
953 \gdef\indent {\restorefirstparagraphindent \indent}%
954 \gdef\noindent{\restorefirstparagraphindent \noindent}%
955 \global\everypar = {\kern -\parindent \restorefirstparagraphindent}%
956}
957%
958\gdef\restorefirstparagraphindent{%
959 \global\let\indent = \ptexindent
960 \global\let\noindent = \ptexnoindent
961 \global\everypar = {}%
962}
963
964% leave vertical mode without cancelling any first paragraph indent
965\gdef\imageindent{%
966 \toks0=\everypar
967 \everypar={}%
968 \ptexnoindent
969 \global\everypar=\toks0
970}
971
972
973% @refill is a no-op.
974\let\refill=\relax
975
976% @setfilename INFO-FILENAME - ignored
977\let\setfilename=\comment
978
979% @bye.
980\outer\def\bye{\chappager\pagelabels\tracingstats=1\ptexend}
981
982
983\message{pdf,}
984% adobe `portable' document format
985\newcount\tempnum
986\newcount\lnkcount
987\newtoks\filename
988\newcount\filenamelength
989\newcount\pgn
990\newtoks\toksA
991\newtoks\toksB
992\newtoks\toksC
993\newtoks\toksD
994\newbox\boxA
995\newbox\boxB
996\newcount\countA
997\newif\ifpdf
998\newif\ifpdfmakepagedest
999
1000%
1001% For LuaTeX
1002%
1003
1004\newif\iftxiuseunicodedestname
1005\txiuseunicodedestnamefalse % For pdfTeX etc.
1006
1007\ifx\luatexversion\thisisundefined
1008\else
1009 % Use Unicode destination names
1010 \txiuseunicodedestnametrue
1011 % Escape PDF strings with converting UTF-16 from UTF-8
1012 \begingroup
1013 \catcode`\%=12
1014 \directlua{
1015 function UTF16oct(str)
1016 tex.sprint(string.char(0x5c) .. '376' .. string.char(0x5c) .. '377')
1017 for c in string.utfvalues(str) do
1018 if c < 0x10000 then
1019 tex.sprint(
1020 string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
1021 string.char(0x5c) .. string.char(0x25) .. '03o',
1022 math.floor(c / 256), math.floor(c % 256)))
1023 else
1024 c = c - 0x10000
1025 local c_hi = c / 1024 + 0xd800
1026 local c_lo = c % 1024 + 0xdc00
1027 tex.sprint(
1028 string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
1029 string.char(0x5c) .. string.char(0x25) .. '03o' ..
1030 string.char(0x5c) .. string.char(0x25) .. '03o' ..
1031 string.char(0x5c) .. string.char(0x25) .. '03o',
1032 math.floor(c_hi / 256), math.floor(c_hi % 256),
1033 math.floor(c_lo / 256), math.floor(c_lo % 256)))
1034 end
1035 end
1036 end
1037 }
1038 \endgroup
1039 \def\pdfescapestrutfsixteen#1{\directlua{UTF16oct('\luaescapestring{#1}')}}
1040 % Escape PDF strings without converting
1041 \begingroup
1042 \directlua{
1043 function PDFescstr(str)
1044 for c in string.bytes(str) do
1045 if c <= 0x20 or c >= 0x80 or c == 0x28 or c == 0x29 or c == 0x5c then
1046 tex.sprint(-2,
1047 string.format(string.char(0x5c) .. string.char(0x25) .. '03o',
1048 c))
1049 else
1050 tex.sprint(-2, string.char(c))
1051 end
1052 end
1053 end
1054 }
1055 % The -2 in the arguments here gives all the input to TeX catcode 12
1056 % (other) or 10 (space), preventing undefined control sequence errors. See
1057 % https://lists.gnu.org/archive/html/bug-texinfo/2019-08/msg00031.html
1058 %
1059 \endgroup
1060 \def\pdfescapestring#1{\directlua{PDFescstr('\luaescapestring{#1}')}}
1061 \ifnum\luatexversion>84
1062 % For LuaTeX >= 0.85
1063 \def\pdfdest{\pdfextension dest}
1064 \let\pdfoutput\outputmode
1065 \def\pdfliteral{\pdfextension literal}
1066 \def\pdfcatalog{\pdfextension catalog}
1067 \def\pdftexversion{\numexpr\pdffeedback version\relax}
1068 \let\pdfximage\saveimageresource
1069 \let\pdfrefximage\useimageresource
1070 \let\pdflastximage\lastsavedimageresourceindex
1071 \def\pdfendlink{\pdfextension endlink\relax}
1072 \def\pdfoutline{\pdfextension outline}
1073 \def\pdfstartlink{\pdfextension startlink}
1074 \def\pdffontattr{\pdfextension fontattr}
1075 \def\pdfobj{\pdfextension obj}
1076 \def\pdflastobj{\numexpr\pdffeedback lastobj\relax}
1077 \let\pdfpagewidth\pagewidth
1078 \let\pdfpageheight\pageheight
1079 \edef\pdfhorigin{\pdfvariable horigin}
1080 \edef\pdfvorigin{\pdfvariable vorigin}
1081 \fi
1082\fi
1083
1084% when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1
1085% can be set). So we test for \relax and 0 as well as being undefined.
1086\ifx\pdfoutput\thisisundefined
1087\else
1088 \ifx\pdfoutput\relax
1089 \else
1090 \ifcase\pdfoutput
1091 \else
1092 \pdftrue
1093 \fi
1094 \fi
1095\fi
1096
1097\newif\ifpdforxetex
1098\pdforxetexfalse
1099\ifpdf
1100 \pdforxetextrue
1101\fi
1102\ifx\XeTeXrevision\thisisundefined\else
1103 \pdforxetextrue
1104\fi
1105
1106
1107% Output page labels information.
1108% See PDF reference v.1.7 p.594, section 8.3.1.
1109\ifpdf
1110\def\pagelabels{%
1111 \def\title{0 << /P (T-) /S /D >>}%
1112 \edef\roman{\the\romancount << /S /r >>}%
1113 \edef\arabic{\the\arabiccount << /S /D >>}%
1114 %
1115 % Page label ranges must be increasing. Remove any duplicates.
1116 % (There is a slight chance of this being wrong if e.g. there is
1117 % a @contents but no @titlepage, etc.)
1118 %
1119 \ifnum\romancount=0 \def\roman{}\fi
1120 \ifnum\arabiccount=0 \def\title{}%
1121 \else
1122 \ifnum\romancount=\arabiccount \def\roman{}\fi
1123 \fi
1124 %
1125 \ifnum\romancount<\arabiccount
1126 \pdfcatalog{/PageLabels << /Nums [\title \roman \arabic ] >> }\relax
1127 \else
1128 \pdfcatalog{/PageLabels << /Nums [\title \arabic \roman ] >> }\relax
1129 \fi
1130}
1131\else
1132 \let\pagelabels\relax
1133\fi
1134
1135\newcount\pagecount \pagecount=0
1136\newcount\romancount \romancount=0
1137\newcount\arabiccount \arabiccount=0
1138\ifpdf
1139 \let\ptxadvancepageno\advancepageno
1140 \def\advancepageno{%
1141 \ptxadvancepageno\global\advance\pagecount by 1
1142 }
1143\fi
1144
1145
1146% PDF uses PostScript string constants for the names of xref targets,
1147% for display in the outlines, and in other places. Thus, we have to
1148% double any backslashes. Otherwise, a name like "\node" will be
1149% interpreted as a newline (\n), followed by o, d, e. Not good.
1150%
1151% See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and
1152% related messages. The final outcome is that it is up to the TeX user
1153% to double the backslashes and otherwise make the string valid, so
1154% that's what we do. pdftex 1.30.0 (ca.2005) introduced a primitive to
1155% do this reliably, so we use it.
1156
1157% #1 is a control sequence in which to do the replacements,
1158% which we \xdef.
1159\def\txiescapepdf#1{%
1160 \ifx\pdfescapestring\thisisundefined
1161 % No primitive available; should we give a warning or log?
1162 % Many times it won't matter.
1163 \xdef#1{#1}%
1164 \else
1165 % The expandable \pdfescapestring primitive escapes parentheses,
1166 % backslashes, and other special chars.
1167 \xdef#1{\pdfescapestring{#1}}%
1168 \fi
1169}
1170\def\txiescapepdfutfsixteen#1{%
1171 \ifx\pdfescapestrutfsixteen\thisisundefined
1172 % No UTF-16 converting macro available.
1173 \txiescapepdf{#1}%
1174 \else
1175 \xdef#1{\pdfescapestrutfsixteen{#1}}%
1176 \fi
1177}
1178
1179\newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images
1180with PDF output, and none of those formats could be found. (.eps cannot
1181be supported due to the design of the PDF format; use regular TeX (DVI
1182output) for that.)}
1183
1184\ifpdf
1185 %
1186 % Color manipulation macros using ideas from pdfcolor.tex,
1187 % except using rgb instead of cmyk; the latter is said to render as a
1188 % very dark gray on-screen and a very dark halftone in print, instead
1189 % of actual black. The dark red here is dark enough to print on paper as
1190 % nearly black, but still distinguishable for online viewing. We use
1191 % black by default, though.
1192 \def\rgbDarkRed{0.50 0.09 0.12}
1193 \def\rgbBlack{0 0 0}
1194 %
1195 % rg sets the color for filling (usual text, etc.);
1196 % RG sets the color for stroking (thin rules, e.g., normal _'s).
1197 \def\pdfsetcolor#1{\pdfliteral{#1 rg #1 RG}}
1198 %
1199 % Set color, and create a mark which defines \thiscolor accordingly,
1200 % so that \makeheadline knows which color to restore.
1201 \def\setcolor#1{%
1202 \xdef\currentcolordefs{\gdef\noexpand\thiscolor{#1}}%
1203 \domark
1204 \pdfsetcolor{#1}%
1205 }
1206 %
1207 \def\maincolor{\rgbBlack}
1208 \pdfsetcolor{\maincolor}
1209 \edef\thiscolor{\maincolor}
1210 \def\currentcolordefs{}
1211 %
1212 \def\makefootline{%
1213 \baselineskip24pt
1214 \line{\pdfsetcolor{\maincolor}\the\footline}%
1215 }
1216 %
1217 \def\makeheadline{%
1218 \vbox to 0pt{%
1219 \vskip-22.5pt
1220 \line{%
1221 \vbox to8.5pt{}%
1222 % Extract \thiscolor definition from the marks.
1223 \getcolormarks
1224 % Typeset the headline with \maincolor, then restore the color.
1225 \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
1226 }%
1227 \vss
1228 }%
1229 \nointerlineskip
1230 }
1231 %
1232 %
1233 \pdfcatalog{/PageMode /UseOutlines}
1234 %
1235 % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
1236 \def\dopdfimage#1#2#3{%
1237 \def\pdfimagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
1238 \def\pdfimageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
1239 %
1240 % pdftex (and the PDF format) support .pdf, .png, .jpg (among
1241 % others). Let's try in that order, PDF first since if
1242 % someone has a scalable image, presumably better to use that than a
1243 % bitmap.
1244 \let\pdfimgext=\empty
1245 \begingroup
1246 \openin 1 #1.pdf \ifeof 1
1247 \openin 1 #1.PDF \ifeof 1
1248 \openin 1 #1.png \ifeof 1
1249 \openin 1 #1.jpg \ifeof 1
1250 \openin 1 #1.jpeg \ifeof 1
1251 \openin 1 #1.JPG \ifeof 1
1252 \errhelp = \nopdfimagehelp
1253 \errmessage{Could not find image file #1 for pdf}%
1254 \else \gdef\pdfimgext{JPG}%
1255 \fi
1256 \else \gdef\pdfimgext{jpeg}%
1257 \fi
1258 \else \gdef\pdfimgext{jpg}%
1259 \fi
1260 \else \gdef\pdfimgext{png}%
1261 \fi
1262 \else \gdef\pdfimgext{PDF}%
1263 \fi
1264 \else \gdef\pdfimgext{pdf}%
1265 \fi
1266 \closein 1
1267 \endgroup
1268 %
1269 % without \immediate, ancient pdftex seg faults when the same image is
1270 % included twice. (Version 3.14159-pre-1.0-unofficial-20010704.)
1271 \ifnum\pdftexversion < 14
1272 \immediate\pdfimage
1273 \else
1274 \immediate\pdfximage
1275 \fi
1276 \ifdim \wd0 >0pt width \pdfimagewidth \fi
1277 \ifdim \wd2 >0pt height \pdfimageheight \fi
1278 \ifnum\pdftexversion<13
1279 #1.\pdfimgext
1280 \else
1281 {#1.\pdfimgext}%
1282 \fi
1283 \ifnum\pdftexversion < 14 \else
1284 \pdfrefximage \pdflastximage
1285 \fi}
1286 %
1287 \def\setpdfdestname#1{{%
1288 % We have to set dummies so commands such as @code, and characters
1289 % such as \, aren't expanded when present in a section title.
1290 \indexnofonts
1291 \makevalueexpandable
1292 \turnoffactive
1293 \iftxiuseunicodedestname
1294 \ifx \declaredencoding \latone
1295 % Pass through Latin-1 characters.
1296 % LuaTeX with byte wise I/O converts Latin-1 characters to Unicode.
1297 \else
1298 \ifx \declaredencoding \utfeight
1299 % Pass through Unicode characters.
1300 \else
1301 % Use ASCII approximations in destination names.
1302 \passthroughcharsfalse
1303 \fi
1304 \fi
1305 \else
1306 % Use ASCII approximations in destination names.
1307 \passthroughcharsfalse
1308 \fi
1309 \def\pdfdestname{#1}%
1310 \txiescapepdf\pdfdestname
1311 }}
1312 %
1313 \def\setpdfoutlinetext#1{{%
1314 \indexnofonts
1315 \makevalueexpandable
1316 \turnoffactive
1317 \ifx \declaredencoding \latone
1318 % The PDF format can use an extended form of Latin-1 in bookmark
1319 % strings. See Appendix D of the PDF Reference, Sixth Edition, for
1320 % the "PDFDocEncoding".
1321 \passthroughcharstrue
1322 % Pass through Latin-1 characters.
1323 % LuaTeX: Convert to Unicode
1324 % pdfTeX: Use Latin-1 as PDFDocEncoding
1325 \def\pdfoutlinetext{#1}%
1326 \else
1327 \ifx \declaredencoding \utfeight
1328 \ifx\luatexversion\thisisundefined
1329 % For pdfTeX with UTF-8.
1330 % TODO: the PDF format can use UTF-16 in bookmark strings,
1331 % but the code for this isn't done yet.
1332 % Use ASCII approximations.
1333 \passthroughcharsfalse
1334 \def\pdfoutlinetext{#1}%
1335 \else
1336 % For LuaTeX with UTF-8.
1337 % Pass through Unicode characters for title texts.
1338 \passthroughcharstrue
1339 \def\pdfoutlinetext{#1}%
1340 \fi
1341 \else
1342 % For non-Latin-1 or non-UTF-8 encodings.
1343 % Use ASCII approximations.
1344 \passthroughcharsfalse
1345 \def\pdfoutlinetext{#1}%
1346 \fi
1347 \fi
1348 % LuaTeX: Convert to UTF-16
1349 % pdfTeX: Use Latin-1 as PDFDocEncoding
1350 \txiescapepdfutfsixteen\pdfoutlinetext
1351 }}
1352 %
1353 \def\pdfmkdest#1{%
1354 \setpdfdestname{#1}%
1355 \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
1356 }
1357 %
1358 % used to mark target names; must be expandable.
1359 \def\pdfmkpgn#1{#1}
1360 %
1361 % by default, use black for everything.
1362 \def\urlcolor{\rgbBlack}
1363 \def\linkcolor{\rgbBlack}
1364 \def\endlink{\setcolor{\maincolor}\pdfendlink}
1365 %
1366 % Adding outlines to PDF; macros for calculating structure of outlines
1367 % come from Petr Olsak
1368 \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
1369 \else \csname#1\endcsname \fi}
1370 \def\advancenumber#1{\tempnum=\expnumber{#1}\relax
1371 \advance\tempnum by 1
1372 \expandafter\xdef\csname#1\endcsname{\the\tempnum}}
1373 %
1374 % #1 is the section text, which is what will be displayed in the
1375 % outline by the pdf viewer. #2 is the pdf expression for the number
1376 % of subentries (or empty, for subsubsections). #3 is the node text,
1377 % which might be empty if this toc entry had no corresponding node.
1378 % #4 is the page number
1379 %
1380 \def\dopdfoutline#1#2#3#4{%
1381 % Generate a link to the node text if that exists; else, use the
1382 % page number. We could generate a destination for the section
1383 % text in the case where a section has no node, but it doesn't
1384 % seem worth the trouble, since most documents are normally structured.
1385 \setpdfoutlinetext{#1}
1386 \setpdfdestname{#3}
1387 \ifx\pdfdestname\empty
1388 \def\pdfdestname{#4}%
1389 \fi
1390 %
1391 \pdfoutline goto name{\pdfmkpgn{\pdfdestname}}#2{\pdfoutlinetext}%
1392 }
1393 %
1394 \def\pdfmakeoutlines{%
1395 \begingroup
1396 % Read toc silently, to get counts of subentries for \pdfoutline.
1397 \def\partentry##1##2##3##4{}% ignore parts in the outlines
1398 \def\numchapentry##1##2##3##4{%
1399 \def\thischapnum{##2}%
1400 \def\thissecnum{0}%
1401 \def\thissubsecnum{0}%
1402 }%
1403 \def\numsecentry##1##2##3##4{%
1404 \advancenumber{chap\thischapnum}%
1405 \def\thissecnum{##2}%
1406 \def\thissubsecnum{0}%
1407 }%
1408 \def\numsubsecentry##1##2##3##4{%
1409 \advancenumber{sec\thissecnum}%
1410 \def\thissubsecnum{##2}%
1411 }%
1412 \def\numsubsubsecentry##1##2##3##4{%
1413 \advancenumber{subsec\thissubsecnum}%
1414 }%
1415 \def\thischapnum{0}%
1416 \def\thissecnum{0}%
1417 \def\thissubsecnum{0}%
1418 %
1419 % use \def rather than \let here because we redefine \chapentry et
1420 % al. a second time, below.
1421 \def\appentry{\numchapentry}%
1422 \def\appsecentry{\numsecentry}%
1423 \def\appsubsecentry{\numsubsecentry}%
1424 \def\appsubsubsecentry{\numsubsubsecentry}%
1425 \def\unnchapentry{\numchapentry}%
1426 \def\unnsecentry{\numsecentry}%
1427 \def\unnsubsecentry{\numsubsecentry}%
1428 \def\unnsubsubsecentry{\numsubsubsecentry}%
1429 \readdatafile{toc}%
1430 %
1431 % Read toc second time, this time actually producing the outlines.
1432 % The `-' means take the \expnumber as the absolute number of
1433 % subentries, which we calculated on our first read of the .toc above.
1434 %
1435 % We use the node names as the destinations.
1436 %
1437 % Currently we prefix the section name with the section number
1438 % for chapter and appendix headings only in order to avoid too much
1439 % horizontal space being required in the PDF viewer.
1440 \def\numchapentry##1##2##3##4{%
1441 \dopdfoutline{##2 ##1}{count-\expnumber{chap##2}}{##3}{##4}}%
1442 \def\unnchapentry##1##2##3##4{%
1443 \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}%
1444 \def\numsecentry##1##2##3##4{%
1445 \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}%
1446 \def\numsubsecentry##1##2##3##4{%
1447 \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}%
1448 \def\numsubsubsecentry##1##2##3##4{% count is always zero
1449 \dopdfoutline{##1}{}{##3}{##4}}%
1450 %
1451 % PDF outlines are displayed using system fonts, instead of
1452 % document fonts. Therefore we cannot use special characters,
1453 % since the encoding is unknown. For example, the eogonek from
1454 % Latin 2 (0xea) gets translated to a | character. Info from
1455 % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100.
1456 %
1457 % TODO this right, we have to translate 8-bit characters to
1458 % their "best" equivalent, based on the @documentencoding. Too
1459 % much work for too little return. Just use the ASCII equivalents
1460 % we use for the index sort strings.
1461 %
1462 \indexnofonts
1463 \setupdatafile
1464 % We can have normal brace characters in the PDF outlines, unlike
1465 % Texinfo index files. So set that up.
1466 \def\{{\lbracecharliteral}%
1467 \def\}{\rbracecharliteral}%
1468 \catcode`\\=\active \otherbackslash
1469 \input \tocreadfilename
1470 \endgroup
1471 }
1472 {\catcode`[=1 \catcode`]=2
1473 \catcode`{=\other \catcode`}=\other
1474 \gdef\lbracecharliteral[{]%
1475 \gdef\rbracecharliteral[}]%
1476 ]
1477 %
1478 \def\skipspaces#1{\def\PP{#1}\def\D{|}%
1479 \ifx\PP\D\let\nextsp\relax
1480 \else\let\nextsp\skipspaces
1481 \addtokens{\filename}{\PP}%
1482 \advance\filenamelength by 1
1483 \fi
1484 \nextsp}
1485 \def\getfilename#1{%
1486 \filenamelength=0
1487 % If we don't expand the argument now, \skipspaces will get
1488 % snagged on things like "@value{foo}".
1489 \edef\temp{#1}%
1490 \expandafter\skipspaces\temp|\relax
1491 }
1492 \ifnum\pdftexversion < 14
1493 \let \startlink \pdfannotlink
1494 \else
1495 \let \startlink \pdfstartlink
1496 \fi
1497 % make a live url in pdf output.
1498 \def\pdfurl#1{%
1499 \begingroup
1500 % it seems we really need yet another set of dummies; have not
1501 % tried to figure out what each command should do in the context
1502 % of @url. for now, just make @/ a no-op, that's the only one
1503 % people have actually reported a problem with.
1504 %
1505 \normalturnoffactive
1506 \def\@{@}%
1507 \let\/=\empty
1508 \makevalueexpandable
1509 % do we want to go so far as to use \indexnofonts instead of just
1510 % special-casing \var here?
1511 \def\var##1{##1}%
1512 %
1513 \leavevmode\setcolor{\urlcolor}%
1514 \startlink attr{/Border [0 0 0]}%
1515 user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
1516 \endgroup}
1517 % \pdfgettoks - Surround page numbers in #1 with @pdflink. #1 may
1518 % be a simple number, or a list of numbers in the case of an index
1519 % entry.
1520 \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1521 \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1522 \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1523 \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1524 \def\maketoks{%
1525 \expandafter\poptoks\the\toksA|ENDTOKS|\relax
1526 \ifx\first0\adn0
1527 \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1528 \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
1529 \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
1530 \else
1531 \ifnum0=\countA\else\makelink\fi
1532 \ifx\first.\let\next=\done\else
1533 \let\next=\maketoks
1534 \addtokens{\toksB}{\the\toksD}
1535 \ifx\first,\addtokens{\toksB}{\space}\fi
1536 \fi
1537 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1538 \next}
1539 \def\makelink{\addtokens{\toksB}%
1540 {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1541 \def\pdflink#1{%
1542 \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}}
1543 \setcolor{\linkcolor}#1\endlink}
1544 \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1545\else
1546 % non-pdf mode
1547 \let\pdfmkdest = \gobble
1548 \let\pdfurl = \gobble
1549 \let\endlink = \relax
1550 \let\setcolor = \gobble
1551 \let\pdfsetcolor = \gobble
1552 \let\pdfmakeoutlines = \relax
1553\fi % \ifx\pdfoutput
1554
1555%
1556% For XeTeX
1557%
1558\ifx\XeTeXrevision\thisisundefined
1559\else
1560 %
1561 % XeTeX version check
1562 %
1563 \ifnum\strcmp{\the\XeTeXversion\XeTeXrevision}{0.99996}>-1
1564 % TeX Live 2016 contains XeTeX 0.99996 and xdvipdfmx 20160307.
1565 % It can use the `dvipdfmx:config' special (from TeX Live SVN r40941).
1566 % For avoiding PDF destination name replacement, we use this special
1567 % instead of xdvipdfmx's command line option `-C 0x0010'.
1568 \special{dvipdfmx:config C 0x0010}
1569 % XeTeX 0.99995+ comes with xdvipdfmx 20160307+.
1570 % It can handle Unicode destination names for PDF.
1571 \txiuseunicodedestnametrue
1572 \else
1573 % XeTeX < 0.99996 (TeX Live < 2016) cannot use the
1574 % `dvipdfmx:config' special.
1575 % So for avoiding PDF destination name replacement,
1576 % xdvipdfmx's command line option `-C 0x0010' is necessary.
1577 %
1578 % XeTeX < 0.99995 can not handle Unicode destination names for PDF
1579 % because xdvipdfmx 20150315 has a UTF-16 conversion issue.
1580 % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753).
1581 \txiuseunicodedestnamefalse
1582 \fi
1583 %
1584 % Color support
1585 %
1586 \def\rgbDarkRed{0.50 0.09 0.12}
1587 \def\rgbBlack{0 0 0}
1588 %
1589 \def\pdfsetcolor#1{\special{pdf:scolor [#1]}}
1590 %
1591 % Set color, and create a mark which defines \thiscolor accordingly,
1592 % so that \makeheadline knows which color to restore.
1593 \def\setcolor#1{%
1594 \xdef\currentcolordefs{\gdef\noexpand\thiscolor{#1}}%
1595 \domark
1596 \pdfsetcolor{#1}%
1597 }
1598 %
1599 \def\maincolor{\rgbBlack}
1600 \pdfsetcolor{\maincolor}
1601 \edef\thiscolor{\maincolor}
1602 \def\currentcolordefs{}
1603 %
1604 \def\makefootline{%
1605 \baselineskip24pt
1606 \line{\pdfsetcolor{\maincolor}\the\footline}%
1607 }
1608 %
1609 \def\makeheadline{%
1610 \vbox to 0pt{%
1611 \vskip-22.5pt
1612 \line{%
1613 \vbox to8.5pt{}%
1614 % Extract \thiscolor definition from the marks.
1615 \getcolormarks
1616 % Typeset the headline with \maincolor, then restore the color.
1617 \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
1618 }%
1619 \vss
1620 }%
1621 \nointerlineskip
1622 }
1623 %
1624 % PDF outline support
1625 %
1626 % Emulate pdfTeX primitive
1627 \def\pdfdest name#1 xyz{%
1628 \special{pdf:dest (#1) [@thispage /XYZ @xpos @ypos null]}%
1629 }
1630 %
1631 \def\setpdfdestname#1{{%
1632 % We have to set dummies so commands such as @code, and characters
1633 % such as \, aren't expanded when present in a section title.
1634 \indexnofonts
1635 \makevalueexpandable
1636 \turnoffactive
1637 \iftxiuseunicodedestname
1638 % Pass through Unicode characters.
1639 \else
1640 % Use ASCII approximations in destination names.
1641 \passthroughcharsfalse
1642 \fi
1643 \def\pdfdestname{#1}%
1644 \txiescapepdf\pdfdestname
1645 }}
1646 %
1647 \def\setpdfoutlinetext#1{{%
1648 \turnoffactive
1649 % Always use Unicode characters in title texts.
1650 \def\pdfoutlinetext{#1}%
1651 % For XeTeX, xdvipdfmx converts to UTF-16.
1652 % So we do not convert.
1653 \txiescapepdf\pdfoutlinetext
1654 }}
1655 %
1656 \def\pdfmkdest#1{%
1657 \setpdfdestname{#1}%
1658 \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
1659 }
1660 %
1661 % by default, use black for everything.
1662 \def\urlcolor{\rgbBlack}
1663 \def\linkcolor{\rgbBlack}
1664 \def\endlink{\setcolor{\maincolor}\pdfendlink}
1665 %
1666 \def\dopdfoutline#1#2#3#4{%
1667 \setpdfoutlinetext{#1}
1668 \setpdfdestname{#3}
1669 \ifx\pdfdestname\empty
1670 \def\pdfdestname{#4}%
1671 \fi
1672 %
1673 \special{pdf:out [-] #2 << /Title (\pdfoutlinetext) /A
1674 << /S /GoTo /D (\pdfdestname) >> >> }%
1675 }
1676 %
1677 \def\pdfmakeoutlines{%
1678 \begingroup
1679 %
1680 % For XeTeX, counts of subentries are not necessary.
1681 % Therefore, we read toc only once.
1682 %
1683 % We use node names as destinations.
1684 %
1685 % Currently we prefix the section name with the section number
1686 % for chapter and appendix headings only in order to avoid too much
1687 % horizontal space being required in the PDF viewer.
1688 \def\partentry##1##2##3##4{}% ignore parts in the outlines
1689 \def\numchapentry##1##2##3##4{%
1690 \dopdfoutline{##2 ##1}{1}{##3}{##4}}%
1691 \def\numsecentry##1##2##3##4{%
1692 \dopdfoutline{##1}{2}{##3}{##4}}%
1693 \def\numsubsecentry##1##2##3##4{%
1694 \dopdfoutline{##1}{3}{##3}{##4}}%
1695 \def\numsubsubsecentry##1##2##3##4{%
1696 \dopdfoutline{##1}{4}{##3}{##4}}%
1697 %
1698 \let\appentry\numchapentry%
1699 \let\appsecentry\numsecentry%
1700 \let\appsubsecentry\numsubsecentry%
1701 \let\appsubsubsecentry\numsubsubsecentry%
1702 \def\unnchapentry##1##2##3##4{%
1703 \dopdfoutline{##1}{1}{##3}{##4}}%
1704 \let\unnsecentry\numsecentry%
1705 \let\unnsubsecentry\numsubsecentry%
1706 \let\unnsubsubsecentry\numsubsubsecentry%
1707 %
1708 % For XeTeX, xdvipdfmx converts strings to UTF-16.
1709 % Therefore, the encoding and the language may not be considered.
1710 %
1711 \indexnofonts
1712 \setupdatafile
1713 % We can have normal brace characters in the PDF outlines, unlike
1714 % Texinfo index files. So set that up.
1715 \def\{{\lbracecharliteral}%
1716 \def\}{\rbracecharliteral}%
1717 \catcode`\\=\active \otherbackslash
1718 \input \tocreadfilename
1719 \endgroup
1720 }
1721 {\catcode`[=1 \catcode`]=2
1722 \catcode`{=\other \catcode`}=\other
1723 \gdef\lbracecharliteral[{]%
1724 \gdef\rbracecharliteral[}]%
1725 ]
1726
1727 \special{pdf:docview << /PageMode /UseOutlines >> }
1728 % ``\special{pdf:tounicode ...}'' is not necessary
1729 % because xdvipdfmx converts strings from UTF-8 to UTF-16 without it.
1730 % However, due to a UTF-16 conversion issue of xdvipdfmx 20150315,
1731 % ``\special{pdf:dest ...}'' cannot handle non-ASCII strings.
1732 % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753).
1733%
1734 \def\skipspaces#1{\def\PP{#1}\def\D{|}%
1735 \ifx\PP\D\let\nextsp\relax
1736 \else\let\nextsp\skipspaces
1737 \addtokens{\filename}{\PP}%
1738 \advance\filenamelength by 1
1739 \fi
1740 \nextsp}
1741 \def\getfilename#1{%
1742 \filenamelength=0
1743 % If we don't expand the argument now, \skipspaces will get
1744 % snagged on things like "@value{foo}".
1745 \edef\temp{#1}%
1746 \expandafter\skipspaces\temp|\relax
1747 }
1748 % make a live url in pdf output.
1749 \def\pdfurl#1{%
1750 \begingroup
1751 % it seems we really need yet another set of dummies; have not
1752 % tried to figure out what each command should do in the context
1753 % of @url. for now, just make @/ a no-op, that's the only one
1754 % people have actually reported a problem with.
1755 %
1756 \normalturnoffactive
1757 \def\@{@}%
1758 \let\/=\empty
1759 \makevalueexpandable
1760 % do we want to go so far as to use \indexnofonts instead of just
1761 % special-casing \var here?
1762 \def\var##1{##1}%
1763 %
1764 \leavevmode\setcolor{\urlcolor}%
1765 \special{pdf:bann << /Border [0 0 0]
1766 /Subtype /Link /A << /S /URI /URI (#1) >> >>}%
1767 \endgroup}
1768 \def\endlink{\setcolor{\maincolor}\special{pdf:eann}}
1769 \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1770 \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1771 \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1772 \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1773 \def\maketoks{%
1774 \expandafter\poptoks\the\toksA|ENDTOKS|\relax
1775 \ifx\first0\adn0
1776 \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1777 \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
1778 \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
1779 \else
1780 \ifnum0=\countA\else\makelink\fi
1781 \ifx\first.\let\next=\done\else
1782 \let\next=\maketoks
1783 \addtokens{\toksB}{\the\toksD}
1784 \ifx\first,\addtokens{\toksB}{\space}\fi
1785 \fi
1786 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1787 \next}
1788 \def\makelink{\addtokens{\toksB}%
1789 {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1790 \def\pdflink#1{%
1791 \special{pdf:bann << /Border [0 0 0]
1792 /Type /Annot /Subtype /Link /A << /S /GoTo /D (#1) >> >>}%
1793 \setcolor{\linkcolor}#1\endlink}
1794 \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1795%
1796 %
1797 % @image support
1798 %
1799 % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
1800 \def\doxeteximage#1#2#3{%
1801 \def\xeteximagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
1802 \def\xeteximageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
1803 %
1804 % XeTeX (and the PDF format) supports .pdf, .png, .jpg (among
1805 % others). Let's try in that order, PDF first since if
1806 % someone has a scalable image, presumably better to use that than a
1807 % bitmap.
1808 \let\xeteximgext=\empty
1809 \begingroup
1810 \openin 1 #1.pdf \ifeof 1
1811 \openin 1 #1.PDF \ifeof 1
1812 \openin 1 #1.png \ifeof 1
1813 \openin 1 #1.jpg \ifeof 1
1814 \openin 1 #1.jpeg \ifeof 1
1815 \openin 1 #1.JPG \ifeof 1
1816 \errmessage{Could not find image file #1 for XeTeX}%
1817 \else \gdef\xeteximgext{JPG}%
1818 \fi
1819 \else \gdef\xeteximgext{jpeg}%
1820 \fi
1821 \else \gdef\xeteximgext{jpg}%
1822 \fi
1823 \else \gdef\xeteximgext{png}%
1824 \fi
1825 \else \gdef\xeteximgext{PDF}%
1826 \fi
1827 \else \gdef\xeteximgext{pdf}%
1828 \fi
1829 \closein 1
1830 \endgroup
1831 %
1832 % Putting an \hbox around the image can prevent an over-long line
1833 % after the image.
1834 \hbox\bgroup
1835 \def\xetexpdfext{pdf}%
1836 \ifx\xeteximgext\xetexpdfext
1837 \XeTeXpdffile "#1".\xeteximgext ""
1838 \else
1839 \def\xetexpdfext{PDF}%
1840 \ifx\xeteximgext\xetexpdfext
1841 \XeTeXpdffile "#1".\xeteximgext ""
1842 \else
1843 \XeTeXpicfile "#1".\xeteximgext ""
1844 \fi
1845 \fi
1846 \ifdim \wd0 >0pt width \xeteximagewidth \fi
1847 \ifdim \wd2 >0pt height \xeteximageheight \fi \relax
1848 \egroup
1849 }
1850\fi
1851
1852
1853%
1854\message{fonts,}
1855
1856% Set the baselineskip to #1, and the lineskip and strut size
1857% correspondingly. There is no deep meaning behind these magic numbers
1858% used as factors; they just match (closely enough) what Knuth defined.
1859%
1860\def\lineskipfactor{.08333}
1861\def\strutheightpercent{.70833}
1862\def\strutdepthpercent {.29167}
1863%
1864% can get a sort of poor man's double spacing by redefining this.
1865\def\baselinefactor{1}
1866%
1867\newdimen\textleading
1868\def\setleading#1{%
1869 \dimen0 = #1\relax
1870 \normalbaselineskip = \baselinefactor\dimen0
1871 \normallineskip = \lineskipfactor\normalbaselineskip
1872 \normalbaselines
1873 \setbox\strutbox =\hbox{%
1874 \vrule width0pt height\strutheightpercent\baselineskip
1875 depth \strutdepthpercent \baselineskip
1876 }%
1877}
1878
1879% PDF CMaps. See also LaTeX's t1.cmap.
1880%
1881% do nothing with this by default.
1882\expandafter\let\csname cmapOT1\endcsname\gobble
1883\expandafter\let\csname cmapOT1IT\endcsname\gobble
1884\expandafter\let\csname cmapOT1TT\endcsname\gobble
1885
1886% if we are producing pdf, and we have \pdffontattr, then define cmaps.
1887% (\pdffontattr was introduced many years ago, but people still run
1888% older pdftex's; it's easy to conditionalize, so we do.)
1889\ifpdf \ifx\pdffontattr\thisisundefined \else
1890 \begingroup
1891 \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
1892 \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
1893%%DocumentNeededResources: ProcSet (CIDInit)
1894%%IncludeResource: ProcSet (CIDInit)
1895%%BeginResource: CMap (TeX-OT1-0)
1896%%Title: (TeX-OT1-0 TeX OT1 0)
1897%%Version: 1.000
1898%%EndComments
1899/CIDInit /ProcSet findresource begin
190012 dict begin
1901begincmap
1902/CIDSystemInfo
1903<< /Registry (TeX)
1904/Ordering (OT1)
1905/Supplement 0
1906>> def
1907/CMapName /TeX-OT1-0 def
1908/CMapType 2 def
19091 begincodespacerange
1910<00> <7F>
1911endcodespacerange
19128 beginbfrange
1913<00> <01> <0393>
1914<09> <0A> <03A8>
1915<23> <26> <0023>
1916<28> <3B> <0028>
1917<3F> <5B> <003F>
1918<5D> <5E> <005D>
1919<61> <7A> <0061>
1920<7B> <7C> <2013>
1921endbfrange
192240 beginbfchar
1923<02> <0398>
1924<03> <039B>
1925<04> <039E>
1926<05> <03A0>
1927<06> <03A3>
1928<07> <03D2>
1929<08> <03A6>
1930<0B> <00660066>
1931<0C> <00660069>
1932<0D> <0066006C>
1933<0E> <006600660069>
1934<0F> <00660066006C>
1935<10> <0131>
1936<11> <0237>
1937<12> <0060>
1938<13> <00B4>
1939<14> <02C7>
1940<15> <02D8>
1941<16> <00AF>
1942<17> <02DA>
1943<18> <00B8>
1944<19> <00DF>
1945<1A> <00E6>
1946<1B> <0153>
1947<1C> <00F8>
1948<1D> <00C6>
1949<1E> <0152>
1950<1F> <00D8>
1951<21> <0021>
1952<22> <201D>
1953<27> <2019>
1954<3C> <00A1>
1955<3D> <003D>
1956<3E> <00BF>
1957<5C> <201C>
1958<5F> <02D9>
1959<60> <2018>
1960<7D> <02DD>
1961<7E> <007E>
1962<7F> <00A8>
1963endbfchar
1964endcmap
1965CMapName currentdict /CMap defineresource pop
1966end
1967end
1968%%EndResource
1969%%EOF
1970 }\endgroup
1971 \expandafter\edef\csname cmapOT1\endcsname#1{%
1972 \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
1973 }%
1974%
1975% \cmapOT1IT
1976 \begingroup
1977 \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
1978 \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
1979%%DocumentNeededResources: ProcSet (CIDInit)
1980%%IncludeResource: ProcSet (CIDInit)
1981%%BeginResource: CMap (TeX-OT1IT-0)
1982%%Title: (TeX-OT1IT-0 TeX OT1IT 0)
1983%%Version: 1.000
1984%%EndComments
1985/CIDInit /ProcSet findresource begin
198612 dict begin
1987begincmap
1988/CIDSystemInfo
1989<< /Registry (TeX)
1990/Ordering (OT1IT)
1991/Supplement 0
1992>> def
1993/CMapName /TeX-OT1IT-0 def
1994/CMapType 2 def
19951 begincodespacerange
1996<00> <7F>
1997endcodespacerange
19988 beginbfrange
1999<00> <01> <0393>
2000<09> <0A> <03A8>
2001<25> <26> <0025>
2002<28> <3B> <0028>
2003<3F> <5B> <003F>
2004<5D> <5E> <005D>
2005<61> <7A> <0061>
2006<7B> <7C> <2013>
2007endbfrange
200842 beginbfchar
2009<02> <0398>
2010<03> <039B>
2011<04> <039E>
2012<05> <03A0>
2013<06> <03A3>
2014<07> <03D2>
2015<08> <03A6>
2016<0B> <00660066>
2017<0C> <00660069>
2018<0D> <0066006C>
2019<0E> <006600660069>
2020<0F> <00660066006C>
2021<10> <0131>
2022<11> <0237>
2023<12> <0060>
2024<13> <00B4>
2025<14> <02C7>
2026<15> <02D8>
2027<16> <00AF>
2028<17> <02DA>
2029<18> <00B8>
2030<19> <00DF>
2031<1A> <00E6>
2032<1B> <0153>
2033<1C> <00F8>
2034<1D> <00C6>
2035<1E> <0152>
2036<1F> <00D8>
2037<21> <0021>
2038<22> <201D>
2039<23> <0023>
2040<24> <00A3>
2041<27> <2019>
2042<3C> <00A1>
2043<3D> <003D>
2044<3E> <00BF>
2045<5C> <201C>
2046<5F> <02D9>
2047<60> <2018>
2048<7D> <02DD>
2049<7E> <007E>
2050<7F> <00A8>
2051endbfchar
2052endcmap
2053CMapName currentdict /CMap defineresource pop
2054end
2055end
2056%%EndResource
2057%%EOF
2058 }\endgroup
2059 \expandafter\edef\csname cmapOT1IT\endcsname#1{%
2060 \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
2061 }%
2062%
2063% \cmapOT1TT
2064 \begingroup
2065 \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
2066 \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
2067%%DocumentNeededResources: ProcSet (CIDInit)
2068%%IncludeResource: ProcSet (CIDInit)
2069%%BeginResource: CMap (TeX-OT1TT-0)
2070%%Title: (TeX-OT1TT-0 TeX OT1TT 0)
2071%%Version: 1.000
2072%%EndComments
2073/CIDInit /ProcSet findresource begin
207412 dict begin
2075begincmap
2076/CIDSystemInfo
2077<< /Registry (TeX)
2078/Ordering (OT1TT)
2079/Supplement 0
2080>> def
2081/CMapName /TeX-OT1TT-0 def
2082/CMapType 2 def
20831 begincodespacerange
2084<00> <7F>
2085endcodespacerange
20865 beginbfrange
2087<00> <01> <0393>
2088<09> <0A> <03A8>
2089<21> <26> <0021>
2090<28> <5F> <0028>
2091<61> <7E> <0061>
2092endbfrange
209332 beginbfchar
2094<02> <0398>
2095<03> <039B>
2096<04> <039E>
2097<05> <03A0>
2098<06> <03A3>
2099<07> <03D2>
2100<08> <03A6>
2101<0B> <2191>
2102<0C> <2193>
2103<0D> <0027>
2104<0E> <00A1>
2105<0F> <00BF>
2106<10> <0131>
2107<11> <0237>
2108<12> <0060>
2109<13> <00B4>
2110<14> <02C7>
2111<15> <02D8>
2112<16> <00AF>
2113<17> <02DA>
2114<18> <00B8>
2115<19> <00DF>
2116<1A> <00E6>
2117<1B> <0153>
2118<1C> <00F8>
2119<1D> <00C6>
2120<1E> <0152>
2121<1F> <00D8>
2122<20> <2423>
2123<27> <2019>
2124<60> <2018>
2125<7F> <00A8>
2126endbfchar
2127endcmap
2128CMapName currentdict /CMap defineresource pop
2129end
2130end
2131%%EndResource
2132%%EOF
2133 }\endgroup
2134 \expandafter\edef\csname cmapOT1TT\endcsname#1{%
2135 \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
2136 }%
2137\fi\fi
2138
2139
2140% Set the font macro #1 to the font named \fontprefix#2.
2141% #3 is the font's design size, #4 is a scale factor, #5 is the CMap
2142% encoding (only OT1, OT1IT and OT1TT are allowed, or empty to omit).
2143% Example:
2144% #1 = \textrm
2145% #2 = \rmshape
2146% #3 = 10
2147% #4 = \mainmagstep
2148% #5 = OT1
2149%
2150\def\setfont#1#2#3#4#5{%
2151 \font#1=\fontprefix#2#3 scaled #4
2152 \csname cmap#5\endcsname#1%
2153}
2154% This is what gets called when #5 of \setfont is empty.
2155\let\cmap\gobble
2156%
2157% (end of cmaps)
2158
2159% Use cm as the default font prefix.
2160% To specify the font prefix, you must define \fontprefix
2161% before you read in texinfo.tex.
2162\ifx\fontprefix\thisisundefined
2163\def\fontprefix{cm}
2164\fi
2165% Support font families that don't use the same naming scheme as CM.
2166\def\rmshape{r}
2167\def\rmbshape{bx} % where the normal face is bold
2168\def\bfshape{b}
2169\def\bxshape{bx}
2170\def\ttshape{tt}
2171\def\ttbshape{tt}
2172\def\ttslshape{sltt}
2173\def\itshape{ti}
2174\def\itbshape{bxti}
2175\def\slshape{sl}
2176\def\slbshape{bxsl}
2177\def\sfshape{ss}
2178\def\sfbshape{ss}
2179\def\scshape{csc}
2180\def\scbshape{csc}
2181
2182% Definitions for a main text size of 11pt. (The default in Texinfo.)
2183%
2184\def\definetextfontsizexi{%
2185% Text fonts (11.2pt, magstep1).
2186\def\textnominalsize{11pt}
2187\edef\mainmagstep{\magstephalf}
2188\setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
2189\setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
2190\setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
2191\setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
2192\setfont\textsl\slshape{10}{\mainmagstep}{OT1}
2193\setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
2194\setfont\textsc\scshape{10}{\mainmagstep}{OT1}
2195\setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
2196\font\texti=cmmi10 scaled \mainmagstep
2197\font\textsy=cmsy10 scaled \mainmagstep
2198\def\textecsize{1095}
2199
2200% A few fonts for @defun names and args.
2201\setfont\defbf\bfshape{10}{\magstep1}{OT1}
2202\setfont\deftt\ttshape{10}{\magstep1}{OT1TT}
2203\setfont\defsl\slshape{10}{\magstep1}{OT1}
2204\setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT}
2205\def\df{\let\ttfont=\deftt \let\bffont = \defbf
2206\let\ttslfont=\defttsl \let\slfont=\defsl \bf}
2207
2208% Fonts for indices, footnotes, small examples (9pt).
2209\def\smallnominalsize{9pt}
2210\setfont\smallrm\rmshape{9}{1000}{OT1}
2211\setfont\smalltt\ttshape{9}{1000}{OT1TT}
2212\setfont\smallbf\bfshape{10}{900}{OT1}
2213\setfont\smallit\itshape{9}{1000}{OT1IT}
2214\setfont\smallsl\slshape{9}{1000}{OT1}
2215\setfont\smallsf\sfshape{9}{1000}{OT1}
2216\setfont\smallsc\scshape{10}{900}{OT1}
2217\setfont\smallttsl\ttslshape{10}{900}{OT1TT}
2218\font\smalli=cmmi9
2219\font\smallsy=cmsy9
2220\def\smallecsize{0900}
2221
2222% Fonts for small examples (8pt).
2223\def\smallernominalsize{8pt}
2224\setfont\smallerrm\rmshape{8}{1000}{OT1}
2225\setfont\smallertt\ttshape{8}{1000}{OT1TT}
2226\setfont\smallerbf\bfshape{10}{800}{OT1}
2227\setfont\smallerit\itshape{8}{1000}{OT1IT}
2228\setfont\smallersl\slshape{8}{1000}{OT1}
2229\setfont\smallersf\sfshape{8}{1000}{OT1}
2230\setfont\smallersc\scshape{10}{800}{OT1}
2231\setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
2232\font\smalleri=cmmi8
2233\font\smallersy=cmsy8
2234\def\smallerecsize{0800}
2235
2236% Fonts for math mode superscripts (7pt).
2237\def\sevennominalsize{7pt}
2238\setfont\sevenrm\rmshape{7}{1000}{OT1}
2239\setfont\seventt\ttshape{10}{700}{OT1TT}
2240\setfont\sevenbf\bfshape{10}{700}{OT1}
2241\setfont\sevenit\itshape{7}{1000}{OT1IT}
2242\setfont\sevensl\slshape{10}{700}{OT1}
2243\setfont\sevensf\sfshape{10}{700}{OT1}
2244\setfont\sevensc\scshape{10}{700}{OT1}
2245\setfont\seventtsl\ttslshape{10}{700}{OT1TT}
2246\font\seveni=cmmi7
2247\font\sevensy=cmsy7
2248\def\sevenecsize{0700}
2249
2250% Fonts for title page (20.4pt):
2251\def\titlenominalsize{20pt}
2252\setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
2253\setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
2254\setfont\titlesl\slbshape{10}{\magstep4}{OT1}
2255\setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
2256\setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
2257\setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
2258\let\titlebf=\titlerm
2259\setfont\titlesc\scbshape{10}{\magstep4}{OT1}
2260\font\titlei=cmmi12 scaled \magstep3
2261\font\titlesy=cmsy10 scaled \magstep4
2262\def\titleecsize{2074}
2263
2264% Chapter (and unnumbered) fonts (17.28pt).
2265\def\chapnominalsize{17pt}
2266\setfont\chaprm\rmbshape{12}{\magstep2}{OT1}
2267\setfont\chapit\itbshape{10}{\magstep3}{OT1IT}
2268\setfont\chapsl\slbshape{10}{\magstep3}{OT1}
2269\setfont\chaptt\ttbshape{12}{\magstep2}{OT1TT}
2270\setfont\chapttsl\ttslshape{10}{\magstep3}{OT1TT}
2271\setfont\chapsf\sfbshape{17}{1000}{OT1}
2272\let\chapbf=\chaprm
2273\setfont\chapsc\scbshape{10}{\magstep3}{OT1}
2274\font\chapi=cmmi12 scaled \magstep2
2275\font\chapsy=cmsy10 scaled \magstep3
2276\def\chapecsize{1728}
2277
2278% Section fonts (14.4pt).
2279\def\secnominalsize{14pt}
2280\setfont\secrm\rmbshape{12}{\magstep1}{OT1}
2281\setfont\secrmnotbold\rmshape{12}{\magstep1}{OT1}
2282\setfont\secit\itbshape{10}{\magstep2}{OT1IT}
2283\setfont\secsl\slbshape{10}{\magstep2}{OT1}
2284\setfont\sectt\ttbshape{12}{\magstep1}{OT1TT}
2285\setfont\secttsl\ttslshape{10}{\magstep2}{OT1TT}
2286\setfont\secsf\sfbshape{12}{\magstep1}{OT1}
2287\let\secbf\secrm
2288\setfont\secsc\scbshape{10}{\magstep2}{OT1}
2289\font\seci=cmmi12 scaled \magstep1
2290\font\secsy=cmsy10 scaled \magstep2
2291\def\sececsize{1440}
2292
2293% Subsection fonts (13.15pt).
2294\def\ssecnominalsize{13pt}
2295\setfont\ssecrm\rmbshape{12}{\magstephalf}{OT1}
2296\setfont\ssecit\itbshape{10}{1315}{OT1IT}
2297\setfont\ssecsl\slbshape{10}{1315}{OT1}
2298\setfont\ssectt\ttbshape{12}{\magstephalf}{OT1TT}
2299\setfont\ssecttsl\ttslshape{10}{1315}{OT1TT}
2300\setfont\ssecsf\sfbshape{12}{\magstephalf}{OT1}
2301\let\ssecbf\ssecrm
2302\setfont\ssecsc\scbshape{10}{1315}{OT1}
2303\font\sseci=cmmi12 scaled \magstephalf
2304\font\ssecsy=cmsy10 scaled 1315
2305\def\ssececsize{1200}
2306
2307% Reduced fonts for @acronym in text (10pt).
2308\def\reducednominalsize{10pt}
2309\setfont\reducedrm\rmshape{10}{1000}{OT1}
2310\setfont\reducedtt\ttshape{10}{1000}{OT1TT}
2311\setfont\reducedbf\bfshape{10}{1000}{OT1}
2312\setfont\reducedit\itshape{10}{1000}{OT1IT}
2313\setfont\reducedsl\slshape{10}{1000}{OT1}
2314\setfont\reducedsf\sfshape{10}{1000}{OT1}
2315\setfont\reducedsc\scshape{10}{1000}{OT1}
2316\setfont\reducedttsl\ttslshape{10}{1000}{OT1TT}
2317\font\reducedi=cmmi10
2318\font\reducedsy=cmsy10
2319\def\reducedecsize{1000}
2320
2321\textleading = 13.2pt % line spacing for 11pt CM
2322\textfonts % reset the current fonts
2323\rm
2324} % end of 11pt text font size definitions, \definetextfontsizexi
2325
2326
2327% Definitions to make the main text be 10pt Computer Modern, with
2328% section, chapter, etc., sizes following suit. This is for the GNU
2329% Press printing of the Emacs 22 manual. Maybe other manuals in the
2330% future. Used with @smallbook, which sets the leading to 12pt.
2331%
2332\def\definetextfontsizex{%
2333% Text fonts (10pt).
2334\def\textnominalsize{10pt}
2335\edef\mainmagstep{1000}
2336\setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
2337\setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
2338\setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
2339\setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
2340\setfont\textsl\slshape{10}{\mainmagstep}{OT1}
2341\setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
2342\setfont\textsc\scshape{10}{\mainmagstep}{OT1}
2343\setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
2344\font\texti=cmmi10 scaled \mainmagstep
2345\font\textsy=cmsy10 scaled \mainmagstep
2346\def\textecsize{1000}
2347
2348% A few fonts for @defun names and args.
2349\setfont\defbf\bfshape{10}{\magstephalf}{OT1}
2350\setfont\deftt\ttshape{10}{\magstephalf}{OT1TT}
2351\setfont\defsl\slshape{10}{\magstephalf}{OT1}
2352\setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT}
2353\def\df{\let\ttfont=\deftt \let\bffont = \defbf
2354\let\slfont=\defsl \let\ttslfont=\defttsl \bf}
2355
2356% Fonts for indices, footnotes, small examples (9pt).
2357\def\smallnominalsize{9pt}
2358\setfont\smallrm\rmshape{9}{1000}{OT1}
2359\setfont\smalltt\ttshape{9}{1000}{OT1TT}
2360\setfont\smallbf\bfshape{10}{900}{OT1}
2361\setfont\smallit\itshape{9}{1000}{OT1IT}
2362\setfont\smallsl\slshape{9}{1000}{OT1}
2363\setfont\smallsf\sfshape{9}{1000}{OT1}
2364\setfont\smallsc\scshape{10}{900}{OT1}
2365\setfont\smallttsl\ttslshape{10}{900}{OT1TT}
2366\font\smalli=cmmi9
2367\font\smallsy=cmsy9
2368\def\smallecsize{0900}
2369
2370% Fonts for small examples (8pt).
2371\def\smallernominalsize{8pt}
2372\setfont\smallerrm\rmshape{8}{1000}{OT1}
2373\setfont\smallertt\ttshape{8}{1000}{OT1TT}
2374\setfont\smallerbf\bfshape{10}{800}{OT1}
2375\setfont\smallerit\itshape{8}{1000}{OT1IT}
2376\setfont\smallersl\slshape{8}{1000}{OT1}
2377\setfont\smallersf\sfshape{8}{1000}{OT1}
2378\setfont\smallersc\scshape{10}{800}{OT1}
2379\setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
2380\font\smalleri=cmmi8
2381\font\smallersy=cmsy8
2382\def\smallerecsize{0800}
2383
2384% Fonts for math mode superscripts (7pt).
2385\def\sevennominalsize{7pt}
2386\setfont\sevenrm\rmshape{7}{1000}{OT1}
2387\setfont\seventt\ttshape{10}{700}{OT1TT}
2388\setfont\sevenbf\bfshape{10}{700}{OT1}
2389\setfont\sevenit\itshape{7}{1000}{OT1IT}
2390\setfont\sevensl\slshape{10}{700}{OT1}
2391\setfont\sevensf\sfshape{10}{700}{OT1}
2392\setfont\sevensc\scshape{10}{700}{OT1}
2393\setfont\seventtsl\ttslshape{10}{700}{OT1TT}
2394\font\seveni=cmmi7
2395\font\sevensy=cmsy7
2396\def\sevenecsize{0700}
2397
2398% Fonts for title page (20.4pt):
2399\def\titlenominalsize{20pt}
2400\setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
2401\setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
2402\setfont\titlesl\slbshape{10}{\magstep4}{OT1}
2403\setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
2404\setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
2405\setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
2406\let\titlebf=\titlerm
2407\setfont\titlesc\scbshape{10}{\magstep4}{OT1}
2408\font\titlei=cmmi12 scaled \magstep3
2409\font\titlesy=cmsy10 scaled \magstep4
2410\def\titleecsize{2074}
2411
2412% Chapter fonts (14.4pt).
2413\def\chapnominalsize{14pt}
2414\setfont\chaprm\rmbshape{12}{\magstep1}{OT1}
2415\setfont\chapit\itbshape{10}{\magstep2}{OT1IT}
2416\setfont\chapsl\slbshape{10}{\magstep2}{OT1}
2417\setfont\chaptt\ttbshape{12}{\magstep1}{OT1TT}
2418\setfont\chapttsl\ttslshape{10}{\magstep2}{OT1TT}
2419\setfont\chapsf\sfbshape{12}{\magstep1}{OT1}
2420\let\chapbf\chaprm
2421\setfont\chapsc\scbshape{10}{\magstep2}{OT1}
2422\font\chapi=cmmi12 scaled \magstep1
2423\font\chapsy=cmsy10 scaled \magstep2
2424\def\chapecsize{1440}
2425
2426% Section fonts (12pt).
2427\def\secnominalsize{12pt}
2428\setfont\secrm\rmbshape{12}{1000}{OT1}
2429\setfont\secit\itbshape{10}{\magstep1}{OT1IT}
2430\setfont\secsl\slbshape{10}{\magstep1}{OT1}
2431\setfont\sectt\ttbshape{12}{1000}{OT1TT}
2432\setfont\secttsl\ttslshape{10}{\magstep1}{OT1TT}
2433\setfont\secsf\sfbshape{12}{1000}{OT1}
2434\let\secbf\secrm
2435\setfont\secsc\scbshape{10}{\magstep1}{OT1}
2436\font\seci=cmmi12
2437\font\secsy=cmsy10 scaled \magstep1
2438\def\sececsize{1200}
2439
2440% Subsection fonts (10pt).
2441\def\ssecnominalsize{10pt}
2442\setfont\ssecrm\rmbshape{10}{1000}{OT1}
2443\setfont\ssecit\itbshape{10}{1000}{OT1IT}
2444\setfont\ssecsl\slbshape{10}{1000}{OT1}
2445\setfont\ssectt\ttbshape{10}{1000}{OT1TT}
2446\setfont\ssecttsl\ttslshape{10}{1000}{OT1TT}
2447\setfont\ssecsf\sfbshape{10}{1000}{OT1}
2448\let\ssecbf\ssecrm
2449\setfont\ssecsc\scbshape{10}{1000}{OT1}
2450\font\sseci=cmmi10
2451\font\ssecsy=cmsy10
2452\def\ssececsize{1000}
2453
2454% Reduced fonts for @acronym in text (9pt).
2455\def\reducednominalsize{9pt}
2456\setfont\reducedrm\rmshape{9}{1000}{OT1}
2457\setfont\reducedtt\ttshape{9}{1000}{OT1TT}
2458\setfont\reducedbf\bfshape{10}{900}{OT1}
2459\setfont\reducedit\itshape{9}{1000}{OT1IT}
2460\setfont\reducedsl\slshape{9}{1000}{OT1}
2461\setfont\reducedsf\sfshape{9}{1000}{OT1}
2462\setfont\reducedsc\scshape{10}{900}{OT1}
2463\setfont\reducedttsl\ttslshape{10}{900}{OT1TT}
2464\font\reducedi=cmmi9
2465\font\reducedsy=cmsy9
2466\def\reducedecsize{0900}
2467
2468\divide\parskip by 2 % reduce space between paragraphs
2469\textleading = 12pt % line spacing for 10pt CM
2470\textfonts % reset the current fonts
2471\rm
2472} % end of 10pt text font size definitions, \definetextfontsizex
2473
2474% Fonts for short table of contents.
2475\setfont\shortcontrm\rmshape{12}{1000}{OT1}
2476\setfont\shortcontbf\bfshape{10}{\magstep1}{OT1} % no cmb12
2477\setfont\shortcontsl\slshape{12}{1000}{OT1}
2478\setfont\shortconttt\ttshape{12}{1000}{OT1TT}
2479
2480
2481% We provide the user-level command
2482% @fonttextsize 10
2483% (or 11) to redefine the text font size. pt is assumed.
2484%
2485\def\xiword{11}
2486\def\xword{10}
2487\def\xwordpt{10pt}
2488%
2489\parseargdef\fonttextsize{%
2490 \def\textsizearg{#1}%
2491 %\wlog{doing @fonttextsize \textsizearg}%
2492 %
2493 % Set \globaldefs so that documents can use this inside @tex, since
2494 % makeinfo 4.8 does not support it, but we need it nonetheless.
2495 %
2496 \begingroup \globaldefs=1
2497 \ifx\textsizearg\xword \definetextfontsizex
2498 \else \ifx\textsizearg\xiword \definetextfontsizexi
2499 \else
2500 \errhelp=\EMsimple
2501 \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'}
2502 \fi\fi
2503 \endgroup
2504}
2505
2506%
2507% Change the current font style to #1, remembering it in \curfontstyle.
2508% For now, we do not accumulate font styles: @b{@i{foo}} prints foo in
2509% italics, not bold italics.
2510%
2511\def\setfontstyle#1{%
2512 \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd.
2513 \csname #1font\endcsname % change the current font
2514}
2515
2516\def\rm{\fam=0 \setfontstyle{rm}}
2517\def\it{\fam=\itfam \setfontstyle{it}}
2518\def\sl{\fam=\slfam \setfontstyle{sl}}
2519\def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf}
2520\def\tt{\fam=\ttfam \setfontstyle{tt}}
2521
2522% Texinfo sort of supports the sans serif font style, which plain TeX does not.
2523% So we set up a \sf.
2524\newfam\sffam
2525\def\sf{\fam=\sffam \setfontstyle{sf}}
2526
2527% We don't need math for this font style.
2528\def\ttsl{\setfontstyle{ttsl}}
2529
2530
2531% In order for the font changes to affect most math symbols and letters,
2532% we have to define the \textfont of the standard families.
2533% We don't bother to reset \scriptscriptfont; awaiting user need.
2534%
2535\def\resetmathfonts{%
2536 \textfont0=\rmfont \textfont1=\ifont \textfont2=\syfont
2537 \textfont\itfam=\itfont \textfont\slfam=\slfont \textfont\bffam=\bffont
2538 \textfont\ttfam=\ttfont \textfont\sffam=\sffont
2539 %
2540 % Fonts for superscript. Note that the 7pt fonts are used regardless
2541 % of the current font size.
2542 \scriptfont0=\sevenrm \scriptfont1=\seveni \scriptfont2=\sevensy
2543 \scriptfont\itfam=\sevenit \scriptfont\slfam=\sevensl
2544 \scriptfont\bffam=\sevenbf \scriptfont\ttfam=\seventt
2545 \scriptfont\sffam=\sevensf
2546}
2547
2548
2549
2550% \defineassignfonts{SIZE} -
2551% Define sequence \assignfontsSIZE, which switches between font sizes
2552% by redefining the meanings of \STYLEfont. (Just \STYLE additionally sets
2553% the current \fam for math mode.)
2554%
2555\def\defineassignfonts#1{%
2556 \expandafter\edef\csname assignfonts#1\endcsname{%
2557 \let\noexpand\rmfont\csname #1rm\endcsname
2558 \let\noexpand\itfont\csname #1it\endcsname
2559 \let\noexpand\slfont\csname #1sl\endcsname
2560 \let\noexpand\bffont\csname #1bf\endcsname
2561 \let\noexpand\ttfont\csname #1tt\endcsname
2562 \let\noexpand\smallcaps\csname #1sc\endcsname
2563 \let\noexpand\sffont \csname #1sf\endcsname
2564 \let\noexpand\ifont \csname #1i\endcsname
2565 \let\noexpand\syfont \csname #1sy\endcsname
2566 \let\noexpand\ttslfont\csname #1ttsl\endcsname
2567 }
2568}
2569
2570\def\assignfonts#1{%
2571 \csname assignfonts#1\endcsname
2572}
2573
2574\newif\ifrmisbold
2575
2576% Select smaller font size with the current style. Used to change font size
2577% in, e.g., the LaTeX logo and acronyms. If we are using bold fonts for
2578% normal roman text, also use bold fonts for roman text in the smaller size.
2579\def\switchtolllsize{%
2580 \expandafter\assignfonts\expandafter{\lllsize}%
2581 \ifrmisbold
2582 \let\rmfont\bffont
2583 \fi
2584 \csname\curfontstyle\endcsname
2585}%
2586
2587\def\switchtolsize{%
2588 \expandafter\assignfonts\expandafter{\lsize}%
2589 \ifrmisbold
2590 \let\rmfont\bffont
2591 \fi
2592 \csname\curfontstyle\endcsname
2593}%
2594
2595% Define the font-changing commands (all called \...fonts).
2596% Each font-changing command also sets the names \lsize (one size lower)
2597% and \lllsize (three sizes lower). These relative commands are used
2598% in, e.g., the LaTeX logo and acronyms.
2599%
2600% Note: The fonts used for \ifont are for "math italics" (\itfont is for
2601% italics in regular text). \syfont is also used in math mode only.
2602%
2603\def\definefontsetatsize#1#2#3#4#5{%
2604 \defineassignfonts{#1}%
2605\expandafter\def\csname #1fonts\endcsname{%
2606 \def\curfontsize{#1}%
2607 \def\lsize{#2}\def\lllsize{#3}%
2608 \csname rmisbold#5\endcsname
2609 \csname assignfonts#1\endcsname
2610 \resetmathfonts
2611 \setleading{#4}%
2612}}
2613
2614\definefontsetatsize{text} {reduced}{smaller}{\textleading}{false}
2615\definefontsetatsize{title} {chap} {subsec} {27pt} {true}
2616\definefontsetatsize{chap} {sec} {text} {19pt} {true}
2617\definefontsetatsize{sec} {subsec} {reduced}{17pt} {true}
2618\definefontsetatsize{ssec} {text} {small} {15pt} {true}
2619\definefontsetatsize{reduced}{small} {smaller}{10.5pt}{false}
2620\definefontsetatsize{small} {smaller}{smaller}{10.5pt}{false}
2621\definefontsetatsize{smaller}{smaller}{smaller}{9.5pt} {false}
2622
2623\def\titlefont#1{{\titlefonts\rm #1}}
2624\let\subsecfonts = \ssecfonts
2625\let\subsubsecfonts = \ssecfonts
2626
2627% Define these just so they can be easily changed for other fonts.
2628\def\angleleft{$\langle$}
2629\def\angleright{$\rangle$}
2630
2631% Set the fonts to use with the @small... environments.
2632\let\smallexamplefonts = \smallfonts
2633
2634% About \smallexamplefonts. If we use \smallfonts (9pt), @smallexample
2635% can fit this many characters:
2636% 8.5x11=86 smallbook=72 a4=90 a5=69
2637% If we use \scriptfonts (8pt), then we can fit this many characters:
2638% 8.5x11=90+ smallbook=80 a4=90+ a5=77
2639% For me, subjectively, the few extra characters that fit aren't worth
2640% the additional smallness of 8pt. So I'm making the default 9pt.
2641%
2642% By the way, for comparison, here's what fits with @example (10pt):
2643% 8.5x11=71 smallbook=60 a4=75 a5=58
2644% --karl, 24jan03.
2645
2646% Set up the default fonts, so we can use them for creating boxes.
2647%
2648\definetextfontsizexi
2649
2650
2651% Check if we are currently using a typewriter font. Since all the
2652% Computer Modern typewriter fonts have zero interword stretch (and
2653% shrink), and it is reasonable to expect all typewriter fonts to have
2654% this property, we can check that font parameter. #1 is what to
2655% print if we are indeed using \tt; #2 is what to print otherwise.
2656\def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi}
2657
2658% Same as above, but check for italic font. Actually this also catches
2659% non-italic slanted fonts since it is impossible to distinguish them from
2660% italic fonts. But since this is only used by $ and it uses \sl anyway
2661% this is not a problem.
2662\def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi}
2663
2664
2665% Check if internal flag is clear, i.e. has not been @set.
2666\def\ifflagclear#1#2#3{%
2667 \expandafter\ifx\csname SET#1\endcsname\relax
2668 #2\else#3\fi
2669}
2670
2671{
2672\catcode`\'=\active
2673\catcode`\`=\active
2674
2675\gdef\setcodequotes{\let`\codequoteleft \let'\codequoteright}
2676\gdef\setregularquotes{\let`\lq \let'\rq}
2677}
2678
2679% Allow an option to not use regular directed right quote/apostrophe
2680% (char 0x27), but instead the undirected quote from cmtt (char 0x0d).
2681% The undirected quote is ugly, so don't make it the default, but it
2682% works for pasting with more pdf viewers (at least evince), the
2683% lilypond developers report. xpdf does work with the regular 0x27.
2684%
2685\def\codequoteright{%
2686 \ifusingtt
2687 {\ifflagclear{txicodequoteundirected}%
2688 {\ifflagclear{codequoteundirected}%
2689 {'}%
2690 {\char'15 }}%
2691 {\char'15 }}%
2692 {'}%
2693}
2694
2695% and a similar option for the left quote char vs. a grave accent.
2696% Modern fonts display ASCII 0x60 as a grave accent, so some people like
2697% the code environments to do likewise.
2698% \relax disables Spanish ligatures ?` and !` of \tt font.
2699%
2700\def\codequoteleft{%
2701 \ifusingtt
2702 {\ifflagclear{txicodequotebacktick}%
2703 {\ifflagclear{codequotebacktick}%
2704 {\relax`}%
2705 {\char'22 }}%
2706 {\char'22 }}%
2707 {\relax`}%
2708}
2709
2710% Commands to set the quote options.
2711%
2712\parseargdef\codequoteundirected{%
2713 \def\temp{#1}%
2714 \ifx\temp\onword
2715 \expandafter\let\csname SETtxicodequoteundirected\endcsname
2716 = t%
2717 \else\ifx\temp\offword
2718 \expandafter\let\csname SETtxicodequoteundirected\endcsname
2719 = \relax
2720 \else
2721 \errhelp = \EMsimple
2722 \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}%
2723 \fi\fi
2724}
2725%
2726\parseargdef\codequotebacktick{%
2727 \def\temp{#1}%
2728 \ifx\temp\onword
2729 \expandafter\let\csname SETtxicodequotebacktick\endcsname
2730 = t%
2731 \else\ifx\temp\offword
2732 \expandafter\let\csname SETtxicodequotebacktick\endcsname
2733 = \relax
2734 \else
2735 \errhelp = \EMsimple
2736 \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}%
2737 \fi\fi
2738}
2739
2740% [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font.
2741\def\noligaturesquoteleft{\relax\lq}
2742
2743% Count depth in font-changes, for error checks
2744\newcount\fontdepth \fontdepth=0
2745
2746% Font commands.
2747
2748% #1 is the font command (\sl or \it), #2 is the text to slant.
2749% If we are in a monospaced environment, however, 1) always use \ttsl,
2750% and 2) do not add an italic correction.
2751\def\dosmartslant#1#2{%
2752 \ifusingtt
2753 {{\ttsl #2}\let\next=\relax}%
2754 {\def\next{{#1#2}\smartitaliccorrection}}%
2755 \next
2756}
2757\def\smartslanted{\dosmartslant\sl}
2758\def\smartitalic{\dosmartslant\it}
2759
2760% Output an italic correction unless the following character is such as
2761% not to need one.
2762\def\smartitaliccorrection{\futurelet\next\smartitaliccorrectionx}
2763\def\smartitaliccorrectionx{%
2764 \ifx\next,%
2765 \else\ifx\next-%
2766 \else\ifx\next.%
2767 \else\ifx\next\.%
2768 \else\ifx\next\comma%
2769 \else\ptexslash
2770 \fi\fi\fi\fi\fi
2771 \aftersmartic
2772}
2773
2774% @cite unconditionally uses \sl with \smartitaliccorrection.
2775\def\cite#1{{\sl #1}\smartitaliccorrection}
2776
2777% @var unconditionally uses \sl. This gives consistency for
2778% parameter names whether they are in @def, @table @code or a
2779% regular paragraph.
2780% To get ttsl font for @var when used in code context, @set txicodevaristt.
2781% The \null is to reset \spacefactor.
2782\def\aftersmartic{}
2783\def\var#1{%
2784 \let\saveaftersmartic = \aftersmartic
2785 \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}%
2786 %
2787 \ifflagclear{txicodevaristt}%
2788 {\def\varnext{{{\sl #1}}\smartitaliccorrection}}%
2789 {\def\varnext{\smartslanted{#1}}}%
2790 \varnext
2791}
2792
2793% To be removed after next release
2794\def\SETtxicodevaristt{}% @set txicodevaristt
2795
2796\let\i=\smartitalic
2797\let\slanted=\smartslanted
2798\let\dfn=\smartslanted
2799\let\emph=\smartitalic
2800
2801% @r for roman font, used for code comment
2802\def\r#1{{%
2803 \usenormaldash % get --, --- ligatures even if in @code
2804 \defcharsdefault % in case on def line
2805 \rm #1}}
2806{\catcode`-=\active \gdef\usenormaldash{\let-\normaldash}}
2807
2808% @sc, undocumented @ii.
2809\def\sc#1{{\smallcaps#1}} % smallcaps font
2810\def\ii#1{{\it #1}} % italic font
2811
2812% @b, explicit bold. Also @strong.
2813\def\b#1{{\bf #1}}
2814\let\strong=\b
2815
2816% @sansserif, explicit sans.
2817\def\sansserif#1{{\sf #1}}
2818
2819% We can't just use \exhyphenpenalty, because that only has effect at
2820% the end of a paragraph. Restore normal hyphenation at the end of the
2821% group within which \nohyphenation is presumably called.
2822%
2823\def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation}
2824\def\restorehyphenation{\hyphenchar\font = `- }
2825
2826\newif\iffrenchspacing
2827\frenchspacingfalse
2828
2829% Set sfcode to normal for the chars that usually have another value.
2830% Can't use plain's \frenchspacing because it uses the `\x notation, and
2831% sometimes \x has an active definition that messes things up.
2832%
2833\catcode`@=11
2834 \def\plainfrenchspacing{%
2835 \iffrenchspacing\else
2836 \frenchspacingtrue
2837 \sfcode`\.=\@m \sfcode`\?=\@m \sfcode`\!=\@m
2838 \sfcode`\:=\@m \sfcode`\;=\@m \sfcode`\,=\@m
2839 \def\endofsentencespacefactor{1000}% for @. and friends
2840 \fi
2841 }
2842 \def\plainnonfrenchspacing{%
2843 \iffrenchspacing
2844 \frenchspacingfalse
2845 \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000
2846 \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250
2847 \def\endofsentencespacefactor{3000}% for @. and friends
2848 \fi
2849 }
2850\catcode`@=\other
2851\def\endofsentencespacefactor{3000}% default
2852
2853% @frenchspacing on|off says whether to put extra space after punctuation.
2854%
2855\def\onword{on}
2856\def\offword{off}
2857%
2858\let\frenchspacingsetting\plainnonfrenchspacing % used in output routine
2859\parseargdef\frenchspacing{%
2860 \def\temp{#1}%
2861 \ifx\temp\onword \let\frenchspacingsetting\plainfrenchspacing
2862 \else\ifx\temp\offword \let\frenchspacingsetting\plainnonfrenchspacing
2863 \else
2864 \errhelp = \EMsimple
2865 \errmessage{Unknown @frenchspacing option `\temp', must be on|off}%
2866 \fi\fi
2867 \frenchspacingsetting
2868}
2869
2870
2871% @t, explicit typewriter.
2872\def\t#1{%
2873 {\tt \defcharsdefault \plainfrenchspacing #1}%
2874 \null
2875}
2876
2877% @samp.
2878\def\samp#1{{\setcodequotes\lq\tclose{#1}\rq\null}}
2879
2880% @indicateurl is \samp, that is, with quotes.
2881\let\indicateurl=\samp
2882
2883% @code (and similar) prints in typewriter, but with spaces the same
2884% size as normal in the surrounding text, without hyphenation, etc.
2885% This is a subroutine for that.
2886\def\tclose#1{%
2887 {%
2888 % Change normal interword space to be same as for the current font.
2889 \spaceskip = \fontdimen2\font
2890 %
2891 % Switch to typewriter.
2892 \tt
2893 %
2894 % But `\ ' produces the large typewriter interword space.
2895 \def\ {{\spaceskip = 0pt{} }}%
2896 %
2897 % Turn off hyphenation.
2898 \nohyphenation
2899 %
2900 \plainfrenchspacing
2901 #1%
2902 }%
2903 \null % reset spacefactor to 1000
2904}
2905
2906% We *must* turn on hyphenation at `-' and `_' in @code.
2907% (But see \codedashfinish below.)
2908% Otherwise, it is too hard to avoid overfull hboxes
2909% in the Emacs manual, the Library manual, etc.
2910%
2911% Unfortunately, TeX uses one parameter (\hyphenchar) to control
2912% both hyphenation at - and hyphenation within words.
2913% We must therefore turn them both off (\tclose does that)
2914% and arrange explicitly to hyphenate at a dash. -- rms.
2915{
2916 \catcode`\-=\active \catcode`\_=\active
2917 \catcode`\'=\active \catcode`\`=\active
2918 \global\let'=\rq \global\let`=\lq % default definitions
2919 %
2920 \global\def\code{\begingroup
2921 \setcodequotes
2922 \catcode\dashChar=\active \catcode\underChar=\active
2923 \ifallowcodebreaks
2924 \let-\codedash
2925 \let_\codeunder
2926 \else
2927 \let-\normaldash
2928 \let_\realunder
2929 \fi
2930 % Given -foo (with a single dash), we do not want to allow a break
2931 % after the hyphen.
2932 \global\let\codedashprev=\codedash
2933 %
2934 \codex
2935 }
2936 %
2937 \gdef\codedash{\futurelet\next\codedashfinish}
2938 \gdef\codedashfinish{%
2939 \normaldash % always output the dash character itself.
2940 %
2941 % Now, output a discretionary to allow a line break, unless
2942 % (a) the next character is a -, or
2943 % (b) the preceding character is a -.
2944 % E.g., given --posix, we do not want to allow a break after either -.
2945 % Given --foo-bar, we do want to allow a break between the - and the b.
2946 \ifx\next\codedash \else
2947 \ifx\codedashprev\codedash
2948 \else \discretionary{}{}{}\fi
2949 \fi
2950 % we need the space after the = for the case when \next itself is a
2951 % space token; it would get swallowed otherwise. As in @code{- a}.
2952 \global\let\codedashprev= \next
2953 }
2954}
2955\def\normaldash{-}
2956%
2957\def\codex #1{\tclose{#1}\endgroup}
2958
2959\def\codeunder{%
2960 % this is all so @math{@code{var_name}+1} can work. In math mode, _
2961 % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.)
2962 % will therefore expand the active definition of _, which is us
2963 % (inside @code that is), therefore an endless loop.
2964 \ifusingtt{\ifmmode
2965 \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_.
2966 \else\normalunderscore \fi
2967 \discretionary{}{}{}}%
2968 {\_}%
2969}
2970
2971% An additional complication: the above will allow breaks after, e.g.,
2972% each of the four underscores in __typeof__. This is bad.
2973% @allowcodebreaks provides a document-level way to turn breaking at -
2974% and _ on and off.
2975%
2976\newif\ifallowcodebreaks \allowcodebreakstrue
2977
2978\def\keywordtrue{true}
2979\def\keywordfalse{false}
2980
2981\parseargdef\allowcodebreaks{%
2982 \def\txiarg{#1}%
2983 \ifx\txiarg\keywordtrue
2984 \allowcodebreakstrue
2985 \else\ifx\txiarg\keywordfalse
2986 \allowcodebreaksfalse
2987 \else
2988 \errhelp = \EMsimple
2989 \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}%
2990 \fi\fi
2991}
2992
2993% For @command, @env, @file, @option quotes seem unnecessary,
2994% so use \code rather than \samp.
2995\let\command=\code
2996\let\env=\code
2997\let\file=\code
2998\let\option=\code
2999
3000% @uref (abbreviation for `urlref') aka @url takes an optional
3001% (comma-separated) second argument specifying the text to display and
3002% an optional third arg as text to display instead of (rather than in
3003% addition to) the url itself. First (mandatory) arg is the url.
3004
3005% TeX-only option to allow changing PDF output to show only the second
3006% arg (if given), and not the url (which is then just the link target).
3007\newif\ifurefurlonlylink
3008
3009% The default \pretolerance setting stops the penalty inserted in
3010% \urefallowbreak being a discouragement to line breaking. Set it to
3011% a negative value for this paragraph only. Hopefully this does not
3012% conflict with redefinitions of \par done elsewhere.
3013\def\nopretolerance{%
3014\pretolerance=-1
3015\def\par{\endgraf\pretolerance=100 \let\par\endgraf}%
3016}
3017
3018% The main macro is \urefbreak, which allows breaking at expected
3019% places within the url.
3020\def\urefbreak{\nopretolerance \begingroup \urefcatcodes \dourefbreak}
3021\let\uref=\urefbreak
3022%
3023\def\dourefbreak#1{\urefbreakfinish #1,,,\finish}
3024\def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example
3025 \unsepspaces
3026 \pdfurl{#1}%
3027 \setbox0 = \hbox{\ignorespaces #3}%
3028 \ifdim\wd0 > 0pt
3029 \unhbox0 % third arg given, show only that
3030 \else
3031 \setbox0 = \hbox{\ignorespaces #2}% look for second arg
3032 \ifdim\wd0 > 0pt
3033 \ifpdf
3034 % For pdfTeX and LuaTeX
3035 \ifurefurlonlylink
3036 % PDF plus option to not display url, show just arg
3037 \unhbox0
3038 \else
3039 % PDF, normally display both arg and url for consistency,
3040 % visibility, if the pdf is eventually used to print, etc.
3041 \unhbox0\ (\urefcode{#1})%
3042 \fi
3043 \else
3044 \ifx\XeTeXrevision\thisisundefined
3045 \unhbox0\ (\urefcode{#1})% DVI, always show arg and url
3046 \else
3047 % For XeTeX
3048 \ifurefurlonlylink
3049 % PDF plus option to not display url, show just arg
3050 \unhbox0
3051 \else
3052 % PDF, normally display both arg and url for consistency,
3053 % visibility, if the pdf is eventually used to print, etc.
3054 \unhbox0\ (\urefcode{#1})%
3055 \fi
3056 \fi
3057 \fi
3058 \else
3059 \urefcode{#1}% only url given, so show it
3060 \fi
3061 \fi
3062 \endlink
3063\endgroup}
3064
3065% Allow line breaks around only a few characters (only).
3066\def\urefcatcodes{%
3067 \catcode`\&=\active \catcode`\.=\active
3068 \catcode`\#=\active \catcode`\?=\active
3069 \catcode`\/=\active
3070}
3071{
3072 \urefcatcodes
3073 %
3074 \global\def\urefcode{\begingroup
3075 \setcodequotes
3076 \urefcatcodes
3077 \let&\urefcodeamp
3078 \let.\urefcodedot
3079 \let#\urefcodehash
3080 \let?\urefcodequest
3081 \let/\urefcodeslash
3082 \codex
3083 }
3084 %
3085 % By default, they are just regular characters.
3086 \global\def&{\normalamp}
3087 \global\def.{\normaldot}
3088 \global\def#{\normalhash}
3089 \global\def?{\normalquest}
3090 \global\def/{\normalslash}
3091}
3092
3093\def\urefcodeamp{\urefprebreak \&\urefpostbreak}
3094\def\urefcodedot{\urefprebreak .\urefpostbreak}
3095\def\urefcodehash{\urefprebreak \#\urefpostbreak}
3096\def\urefcodequest{\urefprebreak ?\urefpostbreak}
3097\def\urefcodeslash{\futurelet\next\urefcodeslashfinish}
3098{
3099 \catcode`\/=\active
3100 \global\def\urefcodeslashfinish{%
3101 \urefprebreak \slashChar
3102 % Allow line break only after the final / in a sequence of
3103 % slashes, to avoid line break between the slashes in http://.
3104 \ifx\next/\else \urefpostbreak \fi
3105 }
3106}
3107
3108% By default we'll break after the special characters, but some people like to
3109% break before the special chars, so allow that. Also allow no breaking at
3110% all, for manual control.
3111%
3112\parseargdef\urefbreakstyle{%
3113 \def\txiarg{#1}%
3114 \ifx\txiarg\wordnone
3115 \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak}
3116 \else\ifx\txiarg\wordbefore
3117 \def\urefprebreak{\urefallowbreak}\def\urefpostbreak{\nobreak}
3118 \else\ifx\txiarg\wordafter
3119 \def\urefprebreak{\nobreak}\def\urefpostbreak{\urefallowbreak}
3120 \else
3121 \errhelp = \EMsimple
3122 \errmessage{Unknown @urefbreakstyle setting `\txiarg'}%
3123 \fi\fi\fi
3124}
3125\def\wordafter{after}
3126\def\wordbefore{before}
3127\def\wordnone{none}
3128
3129% Allow a ragged right output to aid breaking long URL's. There can
3130% be a break at the \allowbreak with no extra glue (if the existing stretch in
3131% the line is sufficient), a break at the \penalty with extra glue added
3132% at the end of the line, or no break at all here.
3133% Changing the value of the penalty and/or the amount of stretch affects how
3134% preferable one choice is over the other.
3135\def\urefallowbreak{%
3136 \penalty0\relax
3137 \hskip 0pt plus 2 em\relax
3138 \penalty1000\relax
3139 \hskip 0pt plus -2 em\relax
3140}
3141
3142\urefbreakstyle after
3143
3144% @url synonym for @uref, since that's how everyone uses it.
3145%
3146\let\url=\uref
3147
3148% rms does not like angle brackets --karl, 17may97.
3149% So now @email is just like @uref, unless we are pdf.
3150%
3151%\def\email#1{\angleleft{\tt #1}\angleright}
3152\ifpdforxetex
3153 \def\email#1{\doemail#1,,\finish}
3154 \def\doemail#1,#2,#3\finish{\begingroup
3155 \unsepspaces
3156 \pdfurl{mailto:#1}%
3157 \setbox0 = \hbox{\ignorespaces #2}%
3158 \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
3159 \endlink
3160 \endgroup}
3161\else
3162 \let\email=\uref
3163\fi
3164
3165% @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
3166% `example' (@kbd uses ttsl only inside of @example and friends),
3167% or `code' (@kbd uses normal tty font always).
3168\parseargdef\kbdinputstyle{%
3169 \def\txiarg{#1}%
3170 \ifx\txiarg\worddistinct
3171 \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
3172 \else\ifx\txiarg\wordexample
3173 \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
3174 \else\ifx\txiarg\wordcode
3175 \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
3176 \else
3177 \errhelp = \EMsimple
3178 \errmessage{Unknown @kbdinputstyle setting `\txiarg'}%
3179 \fi\fi\fi
3180}
3181\def\worddistinct{distinct}
3182\def\wordexample{example}
3183\def\wordcode{code}
3184
3185% Default is `distinct'.
3186\kbdinputstyle distinct
3187
3188\def\kbd#1{%
3189 \tclose{\kbdfont\setcodequotes#1}%
3190}
3191
3192% definition of @key that produces a lozenge. Doesn't adjust to text size.
3193%\setfont\keyrm\rmshape{8}{1000}{OT1}
3194%\font\keysy=cmsy9
3195%\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
3196% \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
3197% \vbox{\hrule\kern-0.4pt
3198% \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
3199% \kern-0.4pt\hrule}%
3200% \kern-.06em\raise0.4pt\hbox{\angleright}}}}
3201
3202% definition of @key with no lozenge.
3203%
3204\def\key#1{{\setregularquotes \nohyphenation \tt #1}\null}
3205
3206% @clicksequence{File @click{} Open ...}
3207\def\clicksequence#1{\begingroup #1\endgroup}
3208
3209% @clickstyle @arrow (by default)
3210\parseargdef\clickstyle{\def\click{#1}}
3211\def\click{\arrow}
3212
3213% Typeset a dimension, e.g., `in' or `pt'. The only reason for the
3214% argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
3215%
3216\def\dmn#1{\thinspace #1}
3217
3218% @acronym for "FBI", "NATO", and the like.
3219% We print this one point size smaller, since it's intended for
3220% all-uppercase.
3221%
3222\def\acronym#1{\doacronym #1,,\finish}
3223\def\doacronym#1,#2,#3\finish{%
3224 {\switchtolsize #1}%
3225 \def\temp{#2}%
3226 \ifx\temp\empty \else
3227 \space ({\unsepspaces \ignorespaces \temp \unskip})%
3228 \fi
3229 \null % reset \spacefactor=1000
3230}
3231
3232% @abbr for "Comput. J." and the like.
3233% No font change, but don't do end-of-sentence spacing.
3234%
3235\def\abbr#1{\doabbr #1,,\finish}
3236\def\doabbr#1,#2,#3\finish{%
3237 {\plainfrenchspacing #1}%
3238 \def\temp{#2}%
3239 \ifx\temp\empty \else
3240 \space ({\unsepspaces \ignorespaces \temp \unskip})%
3241 \fi
3242 \null % reset \spacefactor=1000
3243}
3244
3245% @asis just yields its argument. Used with @table, for example.
3246%
3247\def\asis#1{#1}
3248
3249% @math outputs its argument in math mode.
3250%
3251% One complication: _ usually means subscripts, but it could also mean
3252% an actual _ character, as in @math{@var{some_variable} + 1}. So make
3253% _ active, and distinguish by seeing if the current family is \slfam,
3254% which is what @var uses.
3255{
3256 \catcode`\_ = \active
3257 \gdef\mathunderscore{%
3258 \catcode`\_=\active
3259 \def_{\ifnum\fam=\slfam \_\else\sb\fi}%
3260 }
3261}
3262% Another complication: we want \\ (and @\) to output a math (or tt) \.
3263% FYI, plain.tex uses \\ as a temporary control sequence (for no
3264% particular reason), but this is not advertised and we don't care.
3265%
3266% The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\.
3267\def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi}
3268%
3269\def\math{%
3270 \ifmmode\else % only go into math if not in math mode already
3271 \tex
3272 \mathunderscore
3273 \let\\ = \mathbackslash
3274 \mathactive
3275 % make the texinfo accent commands work in math mode
3276 \let\"=\ddot
3277 \let\'=\acute
3278 \let\==\bar
3279 \let\^=\hat
3280 \let\`=\grave
3281 \let\u=\breve
3282 \let\v=\check
3283 \let\~=\tilde
3284 \let\dotaccent=\dot
3285 % have to provide another name for sup operator
3286 \let\mathopsup=\sup
3287 $\expandafter\finishmath\fi
3288}
3289\def\finishmath#1{#1$\endgroup} % Close the group opened by \tex.
3290
3291% Some active characters (such as <) are spaced differently in math.
3292% We have to reset their definitions in case the @math was an argument
3293% to a command which sets the catcodes (such as @item or @section).
3294%
3295{
3296 \catcode`^ = \active
3297 \catcode`< = \active
3298 \catcode`> = \active
3299 \catcode`+ = \active
3300 \catcode`' = \active
3301 \gdef\mathactive{%
3302 \let^ = \ptexhat
3303 \let< = \ptexless
3304 \let> = \ptexgtr
3305 \let+ = \ptexplus
3306 \let' = \ptexquoteright
3307 }
3308}
3309
3310% for @sub and @sup, if in math mode, just do a normal sub/superscript.
3311% If in text, use math to place as sub/superscript, but switch
3312% into text mode, with smaller fonts. This is a different font than the
3313% one used for real math sub/superscripts (8pt vs. 7pt), but let's not
3314% fix it (significant additions to font machinery) until someone notices.
3315%
3316\def\sub{\ifmmode \expandafter\sb \else \expandafter\finishsub\fi}
3317\def\finishsub#1{$\sb{\hbox{\switchtolllsize #1}}$}%
3318%
3319\def\sup{\ifmmode \expandafter\ptexsp \else \expandafter\finishsup\fi}
3320\def\finishsup#1{$\ptexsp{\hbox{\switchtolllsize #1}}$}%
3321
3322% provide this command from LaTeX as it is very common
3323\def\frac#1#2{{{#1}\over{#2}}}
3324
3325% @displaymath.
3326% \globaldefs is needed to recognize the end lines in \tex and
3327% \end tex. Set \thisenv as @end displaymath is seen before @end tex.
3328{\obeylines
3329\globaldefs=1
3330\envdef\displaymath{%
3331\tex%
3332\def\thisenv{\displaymath}%
3333\begingroup\let\end\displaymathend%
3334$$%
3335}
3336
3337\def\displaymathend{$$\endgroup\end}%
3338
3339\def\Edisplaymath{%
3340\def\thisenv{\tex}%
3341\end tex
3342}}
3343
3344
3345% @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}.
3346% Ignore unless FMTNAME == tex; then it is like @iftex and @tex,
3347% except specified as a normal braced arg, so no newlines to worry about.
3348%
3349\def\outfmtnametex{tex}
3350%
3351\long\def\inlinefmt#1{\doinlinefmt #1,\finish}
3352\long\def\doinlinefmt#1,#2,\finish{%
3353 \def\inlinefmtname{#1}%
3354 \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi
3355}
3356%
3357% @inlinefmtifelse{FMTNAME,THEN-TEXT,ELSE-TEXT} expands THEN-TEXT if
3358% FMTNAME is tex, else ELSE-TEXT.
3359\long\def\inlinefmtifelse#1{\doinlinefmtifelse #1,,,\finish}
3360\long\def\doinlinefmtifelse#1,#2,#3,#4,\finish{%
3361 \def\inlinefmtname{#1}%
3362 \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\else \ignorespaces #3\fi
3363}
3364%
3365% For raw, must switch into @tex before parsing the argument, to avoid
3366% setting catcodes prematurely. Doing it this way means that, for
3367% example, @inlineraw{html, foo{bar} gets a parse error instead of being
3368% ignored. But this isn't important because if people want a literal
3369% *right* brace they would have to use a command anyway, so they may as
3370% well use a command to get a left brace too. We could re-use the
3371% delimiter character idea from \verb, but it seems like overkill.
3372%
3373\long\def\inlineraw{\tex \doinlineraw}
3374\long\def\doinlineraw#1{\doinlinerawtwo #1,\finish}
3375\def\doinlinerawtwo#1,#2,\finish{%
3376 \def\inlinerawname{#1}%
3377 \ifx\inlinerawname\outfmtnametex \ignorespaces #2\fi
3378 \endgroup % close group opened by \tex.
3379}
3380
3381% @inlineifset{VAR, TEXT} expands TEXT if VAR is @set.
3382%
3383\long\def\inlineifset#1{\doinlineifset #1,\finish}
3384\long\def\doinlineifset#1,#2,\finish{%
3385 \def\inlinevarname{#1}%
3386 \expandafter\ifx\csname SET\inlinevarname\endcsname\relax
3387 \else\ignorespaces#2\fi
3388}
3389
3390% @inlineifclear{VAR, TEXT} expands TEXT if VAR is not @set.
3391%
3392\long\def\inlineifclear#1{\doinlineifclear #1,\finish}
3393\long\def\doinlineifclear#1,#2,\finish{%
3394 \def\inlinevarname{#1}%
3395 \expandafter\ifx\csname SET\inlinevarname\endcsname\relax \ignorespaces#2\fi
3396}
3397
3398
3399\message{glyphs,}
3400% and logos.
3401
3402% @@ prints an @, as does @atchar{}.
3403\def\@{\char64 }
3404\let\atchar=\@
3405
3406% @{ @} @lbracechar{} @rbracechar{} all generate brace characters.
3407\def\lbracechar{{\ifusingtt{\char123}{\ensuremath\lbrace}}}
3408\def\rbracechar{{\ifusingtt{\char125}{\ensuremath\rbrace}}}
3409\let\{=\lbracechar
3410\let\}=\rbracechar
3411
3412% @comma{} to avoid , parsing problems.
3413\let\comma = ,
3414
3415% Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
3416% Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H.
3417\let\, = \ptexc
3418\let\dotaccent = \ptexdot
3419\def\ringaccent#1{{\accent23 #1}}
3420\let\tieaccent = \ptext
3421\let\ubaraccent = \ptexb
3422\let\udotaccent = \d
3423
3424% Other special characters: @questiondown @exclamdown @ordf @ordm
3425% Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss.
3426\def\questiondown{?`}
3427\def\exclamdown{!`}
3428\def\ordf{\leavevmode\raise1ex\hbox{\switchtolllsize \underbar{a}}}
3429\def\ordm{\leavevmode\raise1ex\hbox{\switchtolllsize \underbar{o}}}
3430
3431% Dotless i and dotless j, used for accents.
3432\def\imacro{i}
3433\def\jmacro{j}
3434\def\dotless#1{%
3435 \def\temp{#1}%
3436 \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi
3437 \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi
3438 \else \errmessage{@dotless can be used only with i or j}%
3439 \fi\fi
3440}
3441
3442% The \TeX{} logo, as in plain, but resetting the spacing so that a
3443% period following counts as ending a sentence. (Idea found in latex.)
3444%
3445\edef\TeX{\TeX \spacefactor=1000 }
3446
3447% @LaTeX{} logo. Not quite the same results as the definition in
3448% latex.ltx, since we use a different font for the raised A; it's most
3449% convenient for us to use an explicitly smaller font, rather than using
3450% the \scriptstyle font (since we don't reset \scriptstyle and
3451% \scriptscriptstyle).
3452%
3453\def\LaTeX{%
3454 L\kern-.36em
3455 {\setbox0=\hbox{T}%
3456 \vbox to \ht0{\hbox{%
3457 \ifx\textnominalsize\xwordpt
3458 % for 10pt running text, lllsize (8pt) is too small for the A in LaTeX.
3459 % Revert to plain's \scriptsize, which is 7pt.
3460 \count255=\the\fam $\fam\count255 \scriptstyle A$%
3461 \else
3462 \ifx\curfontsize\smallword
3463 % For footnotes and indices
3464 \count255=\the\fam $\fam\count255 \scriptstyle A$%
3465 \else
3466 % For 11pt, we can use our lllsize.
3467 \switchtolllsize A%
3468 \fi
3469 \fi
3470 }%
3471 \vss
3472 }}%
3473 \kern-.15em
3474 \TeX
3475}
3476\def\smallword{small}
3477
3478% Some math mode symbols. Define \ensuremath to switch into math mode
3479% unless we are already there. Expansion tricks may not be needed here,
3480% but safer, and can't hurt.
3481\def\ensuremath{\ifmmode \expandafter\asis \else\expandafter\ensuredmath \fi}
3482\def\ensuredmath#1{$\relax#1$}
3483%
3484\def\bullet{\ensuremath\ptexbullet}
3485\def\geq{\ensuremath\ge}
3486\def\leq{\ensuremath\le}
3487\def\minus{\ensuremath-}
3488
3489% @dots{} outputs an ellipsis using the current font.
3490% We do .5em per period so that it has the same spacing in the cm
3491% typewriter fonts as three actual period characters; on the other hand,
3492% in other typewriter fonts three periods are wider than 1.5em. So do
3493% whichever is larger.
3494%
3495\def\dots{%
3496 \leavevmode
3497 \setbox0=\hbox{...}% get width of three periods
3498 \ifdim\wd0 > 1.5em
3499 \dimen0 = \wd0
3500 \else
3501 \dimen0 = 1.5em
3502 \fi
3503 \hbox to \dimen0{%
3504 \hskip 0pt plus.25fil
3505 .\hskip 0pt plus1fil
3506 .\hskip 0pt plus1fil
3507 .\hskip 0pt plus.5fil
3508 }%
3509}
3510
3511% @enddots{} is an end-of-sentence ellipsis.
3512%
3513\def\enddots{%
3514 \dots
3515 \spacefactor=\endofsentencespacefactor
3516}
3517
3518% @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
3519%
3520% Since these characters are used in examples, they should be an even number of
3521% \tt widths. Each \tt character is 1en, so two makes it 1em.
3522%
3523\def\point{$\star$}
3524\def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}}
3525\def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
3526\def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}}
3527\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
3528\def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}}
3529
3530% The @error{} command.
3531% Adapted from the TeXbook's \boxit.
3532%
3533\newbox\errorbox
3534%
3535{\ttfont \global\dimen0 = 3em}% Width of the box.
3536\dimen2 = .55pt % Thickness of rules
3537% The text. (`r' is open on the right, `e' somewhat less so on the left.)
3538\setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt}
3539%
3540\setbox\errorbox=\hbox to \dimen0{\hfil
3541 \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
3542 \advance\hsize by -2\dimen2 % Rules.
3543 \vbox{%
3544 \hrule height\dimen2
3545 \hbox{\vrule width\dimen2 \kern3pt % Space to left of text.
3546 \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
3547 \kern3pt\vrule width\dimen2}% Space to right.
3548 \hrule height\dimen2}
3549 \hfil}
3550%
3551\def\error{\leavevmode\lower.7ex\copy\errorbox}
3552
3553% @pounds{} is a sterling sign, which Knuth put in the CM italic font.
3554%
3555\def\pounds{{\ifusingtt{\ecfont\char"BF}{\it\$}}}
3556
3557% @euro{} comes from a separate font, depending on the current style.
3558% We use the free feym* fonts from the eurosym package by Henrik
3559% Theiling, which support regular, slanted, bold and bold slanted (and
3560% "outlined" (blackboard board, sort of) versions, which we don't need).
3561% It is available from http://www.ctan.org/tex-archive/fonts/eurosym.
3562%
3563% Although only regular is the truly official Euro symbol, we ignore
3564% that. The Euro is designed to be slightly taller than the regular
3565% font height.
3566%
3567% feymr - regular
3568% feymo - slanted
3569% feybr - bold
3570% feybo - bold slanted
3571%
3572% There is no good (free) typewriter version, to my knowledge.
3573% A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide.
3574% Hmm.
3575%
3576% Also doesn't work in math. Do we need to do math with euro symbols?
3577% Hope not.
3578%
3579%
3580\def\euro{{\eurofont e}}
3581\def\eurofont{%
3582 % We set the font at each command, rather than predefining it in
3583 % \textfonts and the other font-switching commands, so that
3584 % installations which never need the symbol don't have to have the
3585 % font installed.
3586 %
3587 % There is only one designed size (nominal 10pt), so we always scale
3588 % that to the current nominal size.
3589 %
3590 % By the way, simply using "at 1em" works for cmr10 and the like, but
3591 % does not work for cmbx10 and other extended/shrunken fonts.
3592 %
3593 \def\eurosize{\csname\curfontsize nominalsize\endcsname}%
3594 %
3595 \ifx\curfontstyle\bfstylename
3596 % bold:
3597 \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize
3598 \else
3599 % regular:
3600 \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize
3601 \fi
3602 \thiseurofont
3603}
3604
3605% Glyphs from the EC fonts. We don't use \let for the aliases, because
3606% sometimes we redefine the original macro, and the alias should reflect
3607% the redefinition.
3608%
3609% Use LaTeX names for the Icelandic letters.
3610\def\DH{{\ecfont \char"D0}} % Eth
3611\def\dh{{\ecfont \char"F0}} % eth
3612\def\TH{{\ecfont \char"DE}} % Thorn
3613\def\th{{\ecfont \char"FE}} % thorn
3614%
3615\def\guillemetleft{{\ecfont \char"13}}
3616\def\guillemotleft{\guillemetleft}
3617\def\guillemetright{{\ecfont \char"14}}
3618\def\guillemotright{\guillemetright}
3619\def\guilsinglleft{{\ecfont \char"0E}}
3620\def\guilsinglright{{\ecfont \char"0F}}
3621\def\quotedblbase{{\ecfont \char"12}}
3622\def\quotesinglbase{{\ecfont \char"0D}}
3623%
3624\def\L{{\ecfont \char"8A}} % L with stroke
3625\def\l{{\ecfont \char"AA}} % l with stroke
3626%
3627% This positioning is not perfect (see the ogonek LaTeX package), but
3628% we have the precomposed glyphs for the most common cases. We put the
3629% tests to use those glyphs in the single \ogonek macro so we have fewer
3630% dummy definitions to worry about for index entries, etc.
3631%
3632% ogonek is also used with other letters in Lithuanian (IOU), but using
3633% the precomposed glyphs for those is not so easy since they aren't in
3634% the same EC font.
3635\def\ogonek#1{{%
3636 \def\temp{#1}%
3637 \ifx\temp\macrocharA\Aogonek
3638 \else\ifx\temp\macrochara\aogonek
3639 \else\ifx\temp\macrocharE\Eogonek
3640 \else\ifx\temp\macrochare\eogonek
3641 \else
3642 \ecfont \setbox0=\hbox{#1}%
3643 \ifdim\ht0=1ex\accent"0C #1%
3644 \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}%
3645 \fi
3646 \fi\fi\fi\fi
3647 }%
3648}
3649\def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A}
3650\def\aogonek{{\ecfont \char"A1}}\def\macrochara{a}
3651\def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E}
3652\def\eogonek{{\ecfont \char"A6}}\def\macrochare{e}
3653%
3654% Use the European Computer Modern fonts (cm-super in outline format)
3655% for non-CM glyphs. That is ec* for regular text and tc* for the text
3656% companion symbols (LaTeX TS1 encoding). Both are part of the ec
3657% package and follow the same conventions.
3658%
3659\def\ecfont{\etcfont{e}}
3660\def\tcfont{\etcfont{t}}
3661%
3662\def\etcfont#1{%
3663 % We can't distinguish serif/sans and italic/slanted, but this
3664 % is used for crude hacks anyway (like adding French and German
3665 % quotes to documents typeset with CM, where we lose kerning), so
3666 % hopefully nobody will notice/care.
3667 \edef\ecsize{\csname\curfontsize ecsize\endcsname}%
3668 \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}%
3669 \ifusingtt
3670 % typewriter:
3671 {\font\thisecfont = #1ctt\ecsize \space at \nominalsize}%
3672 % else
3673 {\ifx\curfontstyle\bfstylename
3674 % bold:
3675 \font\thisecfont = #1cb\ifusingit{i}{x}\ecsize \space at \nominalsize
3676 \else
3677 % regular:
3678 \font\thisecfont = #1c\ifusingit{ti}{rm}\ecsize \space at \nominalsize
3679 \fi}%
3680 \thisecfont
3681}
3682
3683% @registeredsymbol - R in a circle. The font for the R should really
3684% be smaller yet, but lllsize is the best we can do for now.
3685% Adapted from the plain.tex definition of \copyright.
3686%
3687\def\registeredsymbol{%
3688 $^{{\ooalign{\hfil\raise.07ex\hbox{\switchtolllsize R}%
3689 \hfil\crcr\Orb}}%
3690 }$%
3691}
3692
3693% @textdegree - the normal degrees sign.
3694%
3695\def\textdegree{$^\circ$}
3696
3697% Laurent Siebenmann reports \Orb undefined with:
3698% Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38
3699% so we'll define it if necessary.
3700%
3701\ifx\Orb\thisisundefined
3702\def\Orb{\mathhexbox20D}
3703\fi
3704
3705% Quotes.
3706\chardef\quoteleft=`\`
3707\chardef\quoteright=`\'
3708
3709% only change font for tt for correct kerning and to avoid using
3710% \ecfont unless necessary.
3711\def\quotedblleft{%
3712 \ifusingtt{{\ecfont\char"10}}{{\char"5C}}%
3713}
3714
3715\def\quotedblright{%
3716 \ifusingtt{{\ecfont\char"11}}{{\char`\"}}%
3717}
3718
3719
3720\message{page headings,}
3721
3722\newskip\titlepagetopglue \titlepagetopglue = 1.5in
3723\newskip\titlepagebottomglue \titlepagebottomglue = 2pc
3724
3725% First the title page. Must do @settitle before @titlepage.
3726\newif\ifseenauthor
3727\newif\iffinishedtitlepage
3728
3729% @setcontentsaftertitlepage used to do an implicit @contents or
3730% @shortcontents after @end titlepage, but it is now obsolete.
3731\def\setcontentsaftertitlepage{%
3732 \errmessage{@setcontentsaftertitlepage has been removed as a Texinfo
3733 command; move your @contents command if you want the contents
3734 after the title page.}}%
3735\def\setshortcontentsaftertitlepage{%
3736 \errmessage{@setshortcontentsaftertitlepage has been removed as a Texinfo
3737 command; move your @shortcontents and @contents commands if you
3738 want the contents after the title page.}}%
3739
3740\parseargdef\shorttitlepage{%
3741 \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}%
3742 \endgroup\page\hbox{}\page}
3743
3744\envdef\titlepage{%
3745 % Open one extra group, as we want to close it in the middle of \Etitlepage.
3746 \begingroup
3747 \parindent=0pt \textfonts
3748 % Leave some space at the very top of the page.
3749 \vglue\titlepagetopglue
3750 % No rule at page bottom unless we print one at the top with @title.
3751 \finishedtitlepagetrue
3752 %
3753 % Most title ``pages'' are actually two pages long, with space
3754 % at the top of the second. We don't want the ragged left on the second.
3755 \let\oldpage = \page
3756 \def\page{%
3757 \iffinishedtitlepage\else
3758 \finishtitlepage
3759 \fi
3760 \let\page = \oldpage
3761 \page
3762 \null
3763 }%
3764}
3765
3766\def\Etitlepage{%
3767 \iffinishedtitlepage\else
3768 \finishtitlepage
3769 \fi
3770 % It is important to do the page break before ending the group,
3771 % because the headline and footline are only empty inside the group.
3772 % If we use the new definition of \page, we always get a blank page
3773 % after the title page, which we certainly don't want.
3774 \oldpage
3775 \endgroup
3776 %
3777 % Need this before the \...aftertitlepage checks so that if they are
3778 % in effect the toc pages will come out with page numbers.
3779 \HEADINGSon
3780}
3781
3782\def\finishtitlepage{%
3783 \vskip4pt \hrule height 2pt width \hsize
3784 \vskip\titlepagebottomglue
3785 \finishedtitlepagetrue
3786}
3787
3788% Settings used for typesetting titles: no hyphenation, no indentation,
3789% don't worry much about spacing, ragged right. This should be used
3790% inside a \vbox, and fonts need to be set appropriately first. \par should
3791% be specified before the end of the \vbox, since a vbox is a group.
3792%
3793\def\raggedtitlesettings{%
3794 \rm
3795 \hyphenpenalty=10000
3796 \parindent=0pt
3797 \tolerance=5000
3798 \ptexraggedright
3799}
3800
3801% Macros to be used within @titlepage:
3802
3803\let\subtitlerm=\rmfont
3804\def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}
3805
3806\parseargdef\title{%
3807 \checkenv\titlepage
3808 \vbox{\titlefonts \raggedtitlesettings #1\par}%
3809 % print a rule at the page bottom also.
3810 \finishedtitlepagefalse
3811 \vskip4pt \hrule height 4pt width \hsize \vskip4pt
3812}
3813
3814\parseargdef\subtitle{%
3815 \checkenv\titlepage
3816 {\subtitlefont \rightline{#1}}%
3817}
3818
3819% @author should come last, but may come many times.
3820% It can also be used inside @quotation.
3821%
3822\parseargdef\author{%
3823 \def\temp{\quotation}%
3824 \ifx\thisenv\temp
3825 \def\quotationauthor{#1}% printed in \Equotation.
3826 \else
3827 \checkenv\titlepage
3828 \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi
3829 {\secfonts\rm \leftline{#1}}%
3830 \fi
3831}
3832
3833
3834% Set up page headings and footings.
3835
3836\let\thispage=\folio
3837
3838\newtoks\evenheadline % headline on even pages
3839\newtoks\oddheadline % headline on odd pages
3840\newtoks\evenchapheadline% headline on even pages with a new chapter
3841\newtoks\oddchapheadline % headline on odd pages with a new chapter
3842\newtoks\evenfootline % footline on even pages
3843\newtoks\oddfootline % footline on odd pages
3844
3845% Now make \makeheadline and \makefootline in Plain TeX use those variables
3846\headline={{\textfonts\rm\frenchspacingsetting
3847 \ifchapterpage
3848 \ifodd\pageno\the\oddchapheadline\else\the\evenchapheadline\fi
3849 \else
3850 \ifodd\pageno\the\oddheadline\else\the\evenheadline\fi
3851 \fi}}
3852
3853\footline={{\textfonts\rm\frenchspacingsetting
3854 \ifodd\pageno \the\oddfootline \else \the\evenfootline \fi}%
3855 \HEADINGShook}
3856\let\HEADINGShook=\relax
3857
3858% Commands to set those variables.
3859% For example, this is what @headings on does
3860% @evenheading @thistitle|@thispage|@thischapter
3861% @oddheading @thischapter|@thispage|@thistitle
3862% @evenfooting @thisfile||
3863% @oddfooting ||@thisfile
3864
3865
3866\def\evenheading{\parsearg\evenheadingxxx}
3867\def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish}
3868\def\evenheadingyyy #1\|#2\|#3\|#4\finish{%
3869 \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
3870 \global\evenchapheadline=\evenheadline}
3871
3872\def\oddheading{\parsearg\oddheadingxxx}
3873\def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish}
3874\def\oddheadingyyy #1\|#2\|#3\|#4\finish{%
3875 \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}%
3876 \global\oddchapheadline=\oddheadline}
3877
3878\parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
3879
3880\def\evenfooting{\parsearg\evenfootingxxx}
3881\def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish}
3882\def\evenfootingyyy #1\|#2\|#3\|#4\finish{%
3883\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3884
3885\def\oddfooting{\parsearg\oddfootingxxx}
3886\def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish}
3887\def\oddfootingyyy #1\|#2\|#3\|#4\finish{%
3888 \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}%
3889 %
3890 % Leave some space for the footline. Hopefully ok to assume
3891 % @evenfooting will not be used by itself.
3892 \global\advance\txipageheight by -12pt
3893 \global\advance\vsize by -12pt
3894}
3895
3896\parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}}
3897
3898% @evenheadingmarks top \thischapter <- chapter at the top of a page
3899% @evenheadingmarks bottom \thischapter <- chapter at the bottom of a page
3900%
3901% The same set of arguments for:
3902%
3903% @oddheadingmarks
3904% @evenfootingmarks
3905% @oddfootingmarks
3906% @everyheadingmarks
3907% @everyfootingmarks
3908
3909% These define \getoddheadingmarks, \getevenheadingmarks,
3910% \getoddfootingmarks, and \getevenfootingmarks, each to one of
3911% \gettopheadingmarks, \getbottomheadingmarks.
3912%
3913\def\evenheadingmarks{\headingmarks{even}{heading}}
3914\def\oddheadingmarks{\headingmarks{odd}{heading}}
3915\def\evenfootingmarks{\headingmarks{even}{footing}}
3916\def\oddfootingmarks{\headingmarks{odd}{footing}}
3917\parseargdef\everyheadingmarks{\headingmarks{even}{heading}{#1}
3918 \headingmarks{odd}{heading}{#1} }
3919\parseargdef\everyfootingmarks{\headingmarks{even}{footing}{#1}
3920 \headingmarks{odd}{footing}{#1} }
3921% #1 = even/odd, #2 = heading/footing, #3 = top/bottom.
3922\def\headingmarks#1#2#3 {%
3923 \expandafter\let\expandafter\temp \csname get#3headingmarks\endcsname
3924 \global\expandafter\let\csname get#1#2marks\endcsname \temp
3925}
3926
3927\everyheadingmarks bottom
3928\everyfootingmarks bottom
3929
3930% @headings double turns headings on for double-sided printing.
3931% @headings single turns headings on for single-sided printing.
3932% @headings off turns them off.
3933% @headings on same as @headings double, retained for compatibility.
3934% @headings after turns on double-sided headings after this page.
3935% @headings doubleafter turns on double-sided headings after this page.
3936% @headings singleafter turns on single-sided headings after this page.
3937% By default, they are off at the start of a document,
3938% and turned `on' after @end titlepage.
3939
3940\parseargdef\headings{\csname HEADINGS#1\endcsname}
3941
3942\def\headingsoff{% non-global headings elimination
3943 \evenheadline={\hfil}\evenfootline={\hfil}\evenchapheadline={\hfil}%
3944 \oddheadline={\hfil}\oddfootline={\hfil}\oddchapheadline={\hfil}%
3945}
3946
3947\def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting
3948\HEADINGSoff % it's the default
3949
3950% When we turn headings on, set the page number to 1.
3951\def\pageone{
3952 \global\pageno=1
3953 \global\arabiccount = \pagecount
3954}
3955
3956% For double-sided printing, put current file name in lower left corner,
3957% chapter name on inside top of right hand pages, document
3958% title on inside top of left hand pages, and page numbers on outside top
3959% edge of all pages.
3960\def\HEADINGSdouble{%
3961\pageone
3962\HEADINGSdoublex
3963}
3964\let\contentsalignmacro = \chappager
3965
3966% For single-sided printing, chapter title goes across top left of page,
3967% page number on top right.
3968\def\HEADINGSsingle{%
3969\pageone
3970\HEADINGSsinglex
3971}
3972\def\HEADINGSon{\HEADINGSdouble}
3973
3974\def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
3975\let\HEADINGSdoubleafter=\HEADINGSafter
3976\def\HEADINGSdoublex{%
3977\global\evenfootline={\hfil}
3978\global\oddfootline={\hfil}
3979\global\evenheadline={\line{\folio\hfil\thistitle}}
3980\global\oddheadline={\line{\thischapter\hfil\folio}}
3981\global\evenchapheadline={\line{\folio\hfil\thistitle}}
3982\global\oddchapheadline={\line{\hfil\folio}}
3983\global\let\contentsalignmacro = \chapoddpage
3984}
3985
3986\def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
3987\def\HEADINGSsinglex{%
3988\global\evenfootline={\hfil}
3989\global\oddfootline={\hfil}
3990\global\evenheadline={\line{\thischapter\hfil\folio}}
3991\global\oddheadline={\line{\thischapter\hfil\folio}}
3992\global\evenchapheadline={\line{\hfil\folio}}
3993\global\oddchapheadline={\line{\hfil\folio}}
3994\global\let\contentsalignmacro = \chappager
3995}
3996
3997% for @setchapternewpage off
3998\def\HEADINGSsinglechapoff{%
3999\pageone
4000\global\evenfootline={\hfil}
4001\global\oddfootline={\hfil}
4002\global\evenheadline={\line{\thischapter\hfil\folio}}
4003\global\oddheadline={\line{\thischapter\hfil\folio}}
4004\global\evenchapheadline=\evenheadline
4005\global\oddchapheadline=\oddheadline
4006\global\let\contentsalignmacro = \chappager
4007}
4008
4009% Subroutines used in generating headings
4010% This produces Day Month Year style of output.
4011% Only define if not already defined, in case a txi-??.tex file has set
4012% up a different format (e.g., txi-cs.tex does this).
4013\ifx\today\thisisundefined
4014\def\today{%
4015 \number\day\space
4016 \ifcase\month
4017 \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr
4018 \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug
4019 \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec
4020 \fi
4021 \space\number\year}
4022\fi
4023
4024% @settitle line... specifies the title of the document, for headings.
4025% It generates no output of its own.
4026\def\thistitle{\putwordNoTitle}
4027\def\settitle{\parsearg{\gdef\thistitle}}
4028
4029
4030\message{tables,}
4031% Tables -- @table, @ftable, @vtable, @item(x).
4032
4033% default indentation of table text
4034\newdimen\tableindent \tableindent=.8in
4035% default indentation of @itemize and @enumerate text
4036\newdimen\itemindent \itemindent=.3in
4037% margin between end of table item and start of table text.
4038\newdimen\itemmargin \itemmargin=.1in
4039
4040% used internally for \itemindent minus \itemmargin
4041\newdimen\itemmax
4042
4043% Note @table, @ftable, and @vtable define @item, @itemx, etc., with
4044% these defs.
4045% They also define \itemindex
4046% to index the item name in whatever manner is desired (perhaps none).
4047
4048\newif\ifitemxneedsnegativevskip
4049
4050\def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
4051
4052\def\internalBitem{\smallbreak \parsearg\itemzzz}
4053\def\internalBitemx{\itemxpar \parsearg\itemzzz}
4054
4055\def\itemzzz #1{\begingroup %
4056 \advance\hsize by -\rightskip
4057 \advance\hsize by -\tableindent
4058 \setbox0=\hbox{\itemindicate{#1}}%
4059 \itemindex{#1}%
4060 \nobreak % This prevents a break before @itemx.
4061 %
4062 % If the item text does not fit in the space we have, put it on a line
4063 % by itself, and do not allow a page break either before or after that
4064 % line. We do not start a paragraph here because then if the next
4065 % command is, e.g., @kindex, the whatsit would get put into the
4066 % horizontal list on a line by itself, resulting in extra blank space.
4067 \ifdim \wd0>\itemmax
4068 %
4069 % Make this a paragraph so we get the \parskip glue and wrapping,
4070 % but leave it ragged-right.
4071 \begingroup
4072 \advance\leftskip by-\tableindent
4073 \advance\hsize by\tableindent
4074 \advance\rightskip by0pt plus1fil\relax
4075 \leavevmode\unhbox0\par
4076 \endgroup
4077 %
4078 % We're going to be starting a paragraph, but we don't want the
4079 % \parskip glue -- logically it's part of the @item we just started.
4080 \nobreak \vskip-\parskip
4081 %
4082 % Stop a page break at the \parskip glue coming up. However, if
4083 % what follows is an environment such as @example, there will be no
4084 % \parskip glue; then the negative vskip we just inserted would
4085 % cause the example and the item to crash together. So we use this
4086 % bizarre value of 10001 as a signal to \aboveenvbreak to insert
4087 % \parskip glue after all. Section titles are handled this way also.
4088 %
4089 \penalty 10001
4090 \endgroup
4091 \itemxneedsnegativevskipfalse
4092 \else
4093 % The item text fits into the space. Start a paragraph, so that the
4094 % following text (if any) will end up on the same line.
4095 \noindent
4096 % Do this with kerns and \unhbox so that if there is a footnote in
4097 % the item text, it can migrate to the main vertical list and
4098 % eventually be printed.
4099 \nobreak\kern-\tableindent
4100 \dimen0 = \itemmax \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0
4101 \unhbox0
4102 \nobreak\kern\dimen0
4103 \endgroup
4104 \itemxneedsnegativevskiptrue
4105 \fi
4106}
4107
4108\def\item{\errmessage{@item while not in a list environment}}
4109\def\itemx{\errmessage{@itemx while not in a list environment}}
4110
4111% @table, @ftable, @vtable.
4112\envdef\table{%
4113 \let\itemindex\gobble
4114 \tablecheck{table}%
4115}
4116\envdef\ftable{%
4117 \def\itemindex ##1{\doind {fn}{\code{##1}}}%
4118 \tablecheck{ftable}%
4119}
4120\envdef\vtable{%
4121 \def\itemindex ##1{\doind {vr}{\code{##1}}}%
4122 \tablecheck{vtable}%
4123}
4124\def\tablecheck#1{%
4125 \ifnum \the\catcode`\^^M=\active
4126 \endgroup
4127 \errmessage{This command won't work in this context; perhaps the problem is
4128 that we are \inenvironment\thisenv}%
4129 \def\next{\doignore{#1}}%
4130 \else
4131 \let\next\tablex
4132 \fi
4133 \next
4134}
4135\def\tablex#1{%
4136 \def\itemindicate{#1}%
4137 \parsearg\tabley
4138}
4139\def\tabley#1{%
4140 {%
4141 \makevalueexpandable
4142 \edef\temp{\noexpand\tablez #1\space\space\space}%
4143 \expandafter
4144 }\temp \endtablez
4145}
4146\def\tablez #1 #2 #3 #4\endtablez{%
4147 \aboveenvbreak
4148 \ifnum 0#1>0 \advance \leftskip by #1\mil \fi
4149 \ifnum 0#2>0 \tableindent=#2\mil \fi
4150 \ifnum 0#3>0 \advance \rightskip by #3\mil \fi
4151 \itemmax=\tableindent
4152 \advance \itemmax by -\itemmargin
4153 \advance \leftskip by \tableindent
4154 \exdentamount=\tableindent
4155 \parindent = 0pt
4156 \parskip = \smallskipamount
4157 \ifdim \parskip=0pt \parskip=2pt \fi
4158 \let\item = \internalBitem
4159 \let\itemx = \internalBitemx
4160}
4161\def\Etable{\endgraf\afterenvbreak}
4162\let\Eftable\Etable
4163\let\Evtable\Etable
4164\let\Eitemize\Etable
4165\let\Eenumerate\Etable
4166
4167% This is the counter used by @enumerate, which is really @itemize
4168
4169\newcount \itemno
4170
4171\envdef\itemize{\parsearg\doitemize}
4172
4173\def\doitemize#1{%
4174 \aboveenvbreak
4175 \itemmax=\itemindent
4176 \advance\itemmax by -\itemmargin
4177 \advance\leftskip by \itemindent
4178 \exdentamount=\itemindent
4179 \parindent=0pt
4180 \parskip=\smallskipamount
4181 \ifdim\parskip=0pt \parskip=2pt \fi
4182 %
4183 % Try typesetting the item mark so that if the document erroneously says
4184 % something like @itemize @samp (intending @table), there's an error
4185 % right away at the @itemize. It's not the best error message in the
4186 % world, but it's better than leaving it to the @item. This means if
4187 % the user wants an empty mark, they have to say @w{} not just @w.
4188 \def\itemcontents{#1}%
4189 \setbox0 = \hbox{\itemcontents}%
4190 %
4191 % @itemize with no arg is equivalent to @itemize @bullet.
4192 \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi
4193 %
4194 \let\item=\itemizeitem
4195}
4196
4197% Definition of @item while inside @itemize and @enumerate.
4198%
4199\def\itemizeitem{%
4200 \advance\itemno by 1 % for enumerations
4201 {\let\par=\endgraf \smallbreak}% reasonable place to break
4202 {%
4203 % If the document has an @itemize directly after a section title, a
4204 % \nobreak will be last on the list, and \sectionheading will have
4205 % done a \vskip-\parskip. In that case, we don't want to zero
4206 % parskip, or the item text will crash with the heading. On the
4207 % other hand, when there is normal text preceding the item (as there
4208 % usually is), we do want to zero parskip, or there would be too much
4209 % space. In that case, we won't have a \nobreak before. At least
4210 % that's the theory.
4211 \ifnum\lastpenalty<10000 \parskip=0in \fi
4212 \noindent
4213 \hbox to 0pt{\hss \itemcontents \kern\itemmargin}%
4214 %
4215 \ifinner\else
4216 \vadjust{\penalty 1200}% not good to break after first line of item.
4217 \fi
4218 % We can be in inner vertical mode in a footnote, although an
4219 % @itemize looks awful there.
4220 }%
4221 \flushcr
4222}
4223
4224% \splitoff TOKENS\endmark defines \first to be the first token in
4225% TOKENS, and \rest to be the remainder.
4226%
4227\def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
4228
4229% Allow an optional argument of an uppercase letter, lowercase letter,
4230% or number, to specify the first label in the enumerated list. No
4231% argument is the same as `1'.
4232%
4233\envparseargdef\enumerate{\enumeratey #1 \endenumeratey}
4234\def\enumeratey #1 #2\endenumeratey{%
4235 % If we were given no argument, pretend we were given `1'.
4236 \def\thearg{#1}%
4237 \ifx\thearg\empty \def\thearg{1}\fi
4238 %
4239 % Detect if the argument is a single token. If so, it might be a
4240 % letter. Otherwise, the only valid thing it can be is a number.
4241 % (We will always have one token, because of the test we just made.
4242 % This is a good thing, since \splitoff doesn't work given nothing at
4243 % all -- the first parameter is undelimited.)
4244 \expandafter\splitoff\thearg\endmark
4245 \ifx\rest\empty
4246 % Only one token in the argument. It could still be anything.
4247 % A ``lowercase letter'' is one whose \lccode is nonzero.
4248 % An ``uppercase letter'' is one whose \lccode is both nonzero, and
4249 % not equal to itself.
4250 % Otherwise, we assume it's a number.
4251 %
4252 % We need the \relax at the end of the \ifnum lines to stop TeX from
4253 % continuing to look for a <number>.
4254 %
4255 \ifnum\lccode\expandafter`\thearg=0\relax
4256 \numericenumerate % a number (we hope)
4257 \else
4258 % It's a letter.
4259 \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
4260 \lowercaseenumerate % lowercase letter
4261 \else
4262 \uppercaseenumerate % uppercase letter
4263 \fi
4264 \fi
4265 \else
4266 % Multiple tokens in the argument. We hope it's a number.
4267 \numericenumerate
4268 \fi
4269}
4270
4271% An @enumerate whose labels are integers. The starting integer is
4272% given in \thearg.
4273%
4274\def\numericenumerate{%
4275 \itemno = \thearg
4276 \startenumeration{\the\itemno}%
4277}
4278
4279% The starting (lowercase) letter is in \thearg.
4280\def\lowercaseenumerate{%
4281 \itemno = \expandafter`\thearg
4282 \startenumeration{%
4283 % Be sure we're not beyond the end of the alphabet.
4284 \ifnum\itemno=0
4285 \errmessage{No more lowercase letters in @enumerate; get a bigger
4286 alphabet}%
4287 \fi
4288 \char\lccode\itemno
4289 }%
4290}
4291
4292% The starting (uppercase) letter is in \thearg.
4293\def\uppercaseenumerate{%
4294 \itemno = \expandafter`\thearg
4295 \startenumeration{%
4296 % Be sure we're not beyond the end of the alphabet.
4297 \ifnum\itemno=0
4298 \errmessage{No more uppercase letters in @enumerate; get a bigger
4299 alphabet}
4300 \fi
4301 \char\uccode\itemno
4302 }%
4303}
4304
4305% Call \doitemize, adding a period to the first argument and supplying the
4306% common last two arguments. Also subtract one from the initial value in
4307% \itemno, since @item increments \itemno.
4308%
4309\def\startenumeration#1{%
4310 \advance\itemno by -1
4311 \doitemize{#1.}\flushcr
4312}
4313
4314
4315% @multitable macros
4316
4317% Macros used to set up halign preamble:
4318%
4319\let\endsetuptable\relax
4320\def\xendsetuptable{\endsetuptable}
4321\let\columnfractions\relax
4322\def\xcolumnfractions{\columnfractions}
4323\newif\ifsetpercent
4324
4325% #1 is the @columnfraction, usually a decimal number like .5, but might
4326% be just 1. We just use it, whatever it is.
4327%
4328\def\pickupwholefraction#1 {%
4329 \global\advance\colcount by 1
4330 \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}%
4331 \setuptable
4332}
4333
4334\newcount\colcount
4335\def\setuptable#1{%
4336 \def\firstarg{#1}%
4337 \ifx\firstarg\xendsetuptable
4338 \let\go = \relax
4339 \else
4340 \ifx\firstarg\xcolumnfractions
4341 \global\setpercenttrue
4342 \else
4343 \ifsetpercent
4344 \let\go\pickupwholefraction
4345 \else
4346 \global\advance\colcount by 1
4347 \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a
4348 % separator; typically that is always in the input, anyway.
4349 \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
4350 \fi
4351 \fi
4352 \ifx\go\pickupwholefraction
4353 % Put the argument back for the \pickupwholefraction call, so
4354 % we'll always have a period there to be parsed.
4355 \def\go{\pickupwholefraction#1}%
4356 \else
4357 \let\go = \setuptable
4358 \fi%
4359 \fi
4360 \go
4361}
4362
4363% @headitem starts a heading row, which we typeset in bold. Assignments
4364% have to be global since we are inside the implicit group of an
4365% alignment entry. \everycr below resets \everytab so we don't have to
4366% undo it ourselves.
4367\def\headitemfont{\b}% for people to use in the template row; not changeable
4368\def\headitem{%
4369 \crcr % must appear first
4370 \gdef\headitemcrhook{\nobreak}% attempt to avoid page break after headings
4371 \global\everytab={\bf}% can't use \headitemfont since the parsing differs
4372 \the\everytab % for the first item
4373}%
4374%
4375% default for tables with no headings.
4376\let\headitemcrhook=\relax
4377%
4378\def\tab{\checkenv\multitable &\the\everytab}%
4379
4380\newtoks\everytab % insert after every tab.
4381%
4382\envdef\multitable{%
4383 \vskip\parskip
4384 \startsavinginserts
4385 %
4386 % @item within a multitable starts a normal row.
4387 % We use \def instead of \let so that if one of the multitable entries
4388 % contains an @itemize, we don't choke on the \item (seen as \crcr aka
4389 % \endtemplate) expanding \doitemize.
4390 \def\item{\crcr}%
4391 %
4392 \tolerance=9500
4393 \hbadness=9500
4394 \parskip=0pt
4395 \parindent=6pt
4396 \overfullrule=0pt
4397 \global\colcount=0
4398 %
4399 \everycr = {%
4400 \noalign{%
4401 \global\everytab={}% Reset from possible headitem.
4402 \global\colcount=0 % Reset the column counter.
4403 %
4404 % Check for saved footnotes, etc.:
4405 \checkinserts
4406 %
4407 % Perhaps a \nobreak, then reset:
4408 \headitemcrhook
4409 \global\let\headitemcrhook=\relax
4410 }%
4411 }%
4412 %
4413 \parsearg\domultitable
4414}
4415\def\domultitable#1{%
4416 % To parse everything between @multitable and @item:
4417 \setuptable#1 \endsetuptable
4418 %
4419 % This preamble sets up a generic column definition, which will
4420 % be used as many times as user calls for columns.
4421 % \vtop will set a single line and will also let text wrap and
4422 % continue for many paragraphs if desired.
4423 \halign\bgroup &%
4424 \global\advance\colcount by 1
4425 \strut
4426 \vtop{%
4427 \advance\hsize by -1\leftskip
4428 % Find the correct column width
4429 \hsize=\expandafter\csname col\the\colcount\endcsname
4430 %
4431 \advance\rightskip by -1\rightskip % Zero leaving only any stretch
4432 \ifnum\colcount=1
4433 \advance\hsize by\leftskip % Add indent of surrounding text
4434 \else
4435 % In order to keep entries from bumping into each other.
4436 \leftskip=12pt
4437 \ifsetpercent \else
4438 % If a template has been used
4439 \advance\hsize by \leftskip
4440 \fi
4441 \fi
4442 \noindent\ignorespaces##\unskip\strut
4443 }\cr
4444}
4445\def\Emultitable{%
4446 \crcr
4447 \egroup % end the \halign
4448 \global\setpercentfalse
4449}
4450
4451
4452\message{conditionals,}
4453
4454% @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotlatex, @ifnotplaintext,
4455% @ifnotxml always succeed. They currently do nothing; we don't
4456% attempt to check whether the conditionals are properly nested. But we
4457% have to remember that they are conditionals, so that @end doesn't
4458% attempt to close an environment group.
4459%
4460\def\makecond#1{%
4461 \expandafter\let\csname #1\endcsname = \relax
4462 \expandafter\let\csname iscond.#1\endcsname = 1
4463}
4464\makecond{iftex}
4465\makecond{ifnotdocbook}
4466\makecond{ifnothtml}
4467\makecond{ifnotinfo}
4468\makecond{ifnotlatex}
4469\makecond{ifnotplaintext}
4470\makecond{ifnotxml}
4471
4472% Ignore @ignore, @ifhtml, @ifinfo, and the like.
4473%
4474\def\direntry{\doignore{direntry}}
4475\def\documentdescription{\doignore{documentdescription}}
4476\def\docbook{\doignore{docbook}}
4477\def\html{\doignore{html}}
4478\def\ifdocbook{\doignore{ifdocbook}}
4479\def\ifhtml{\doignore{ifhtml}}
4480\def\ifinfo{\doignore{ifinfo}}
4481\def\iflatex{\doignore{iflatex}}
4482\def\ifnottex{\doignore{ifnottex}}
4483\def\ifplaintext{\doignore{ifplaintext}}
4484\def\ifxml{\doignore{ifxml}}
4485\def\ignore{\doignore{ignore}}
4486\def\latex{\doignore{latex}}
4487\def\menu{\doignore{menu}}
4488\def\xml{\doignore{xml}}
4489
4490% Ignore text until a line `@end #1', keeping track of nested conditionals.
4491%
4492% A count to remember the depth of nesting.
4493\newcount\doignorecount
4494
4495\def\doignore#1{\begingroup
4496 % Scan in ``verbatim'' mode:
4497 \obeylines
4498 \catcode`\@ = \other
4499 \catcode`\{ = \other
4500 \catcode`\} = \other
4501 %
4502 % Make sure that spaces turn into tokens that match what \doignoretext wants.
4503 \spaceisspace
4504 %
4505 % Count number of #1's that we've seen.
4506 \doignorecount = 0
4507 %
4508 % Swallow text until we reach the matching `@end #1'.
4509 \dodoignore{#1}%
4510}
4511
4512{ \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source.
4513 \obeylines %
4514 %
4515 \gdef\dodoignore#1{%
4516 % #1 contains the command name as a string, e.g., `ifinfo'.
4517 %
4518 % Define a command to find the next `@end #1'.
4519 \long\def\doignoretext##1^^M@end #1{%
4520 \doignoretextyyy##1^^M@#1\_STOP_}%
4521 %
4522 % And this command to find another #1 command, at the beginning of a
4523 % line. (Otherwise, we would consider a line `@c @ifset', for
4524 % example, to count as an @ifset for nesting.)
4525 \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}%
4526 %
4527 % And now expand that command.
4528 \doignoretext ^^M%
4529 }%
4530}
4531
4532\def\doignoreyyy#1{%
4533 \def\temp{#1}%
4534 \ifx\temp\empty % Nothing found.
4535 \let\next\doignoretextzzz
4536 \else % Found a nested condition, ...
4537 \advance\doignorecount by 1
4538 \let\next\doignoretextyyy % ..., look for another.
4539 % If we're here, #1 ends with ^^M\ifinfo (for example).
4540 \fi
4541 \next #1% the token \_STOP_ is present just after this macro.
4542}
4543
4544% We have to swallow the remaining "\_STOP_".
4545%
4546\def\doignoretextzzz#1{%
4547 \ifnum\doignorecount = 0 % We have just found the outermost @end.
4548 \let\next\enddoignore
4549 \else % Still inside a nested condition.
4550 \advance\doignorecount by -1
4551 \let\next\doignoretext % Look for the next @end.
4552 \fi
4553 \next
4554}
4555
4556% Finish off ignored text.
4557{ \obeylines%
4558 % Ignore anything after the last `@end #1'; this matters in verbatim
4559 % environments, where otherwise the newline after an ignored conditional
4560 % would result in a blank line in the output.
4561 \gdef\enddoignore#1^^M{\endgroup\ignorespaces}%
4562}
4563
4564
4565% @set VAR sets the variable VAR to an empty value.
4566% @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
4567%
4568% Since we want to separate VAR from REST-OF-LINE (which might be
4569% empty), we can't just use \parsearg; we have to insert a space of our
4570% own to delimit the rest of the line, and then take it out again if we
4571% didn't need it.
4572% We rely on the fact that \parsearg sets \catcode`\ =10.
4573%
4574\parseargdef\set{\setyyy#1 \endsetyyy}
4575\def\setyyy#1 #2\endsetyyy{%
4576 {%
4577 \makevalueexpandable
4578 \def\temp{#2}%
4579 \edef\next{\gdef\makecsname{SET#1}}%
4580 \ifx\temp\empty
4581 \next{}%
4582 \else
4583 \setzzz#2\endsetzzz
4584 \fi
4585 }%
4586}
4587% Remove the trailing space \setxxx inserted.
4588\def\setzzz#1 \endsetzzz{\next{#1}}
4589
4590% @clear VAR clears (i.e., unsets) the variable VAR.
4591%
4592\parseargdef\clear{%
4593 {%
4594 \makevalueexpandable
4595 \global\expandafter\let\csname SET#1\endcsname=\relax
4596 }%
4597}
4598
4599% @value{foo} gets the text saved in variable foo.
4600\def\value{\begingroup\makevalueexpandable\valuexxx}
4601\def\valuexxx#1{\expandablevalue{#1}\endgroup}
4602{
4603 \catcode`\-=\active \catcode`\_=\active
4604 %
4605 \gdef\makevalueexpandable{%
4606 \let\value = \expandablevalue
4607 % We don't want these characters active, ...
4608 \catcode`\-=\other \catcode`\_=\other
4609 % ..., but we might end up with active ones in the argument if
4610 % we're called from @code, as @code{@value{foo-bar_}}, though.
4611 % So \let them to their normal equivalents.
4612 \let-\normaldash \let_\normalunderscore
4613 }
4614}
4615
4616\def\expandablevalue#1{%
4617 \expandafter\ifx\csname SET#1\endcsname\relax
4618 {[No value for ``#1'']}%
4619 \message{Variable `#1', used in @value, is not set.}%
4620 \else
4621 \csname SET#1\endcsname
4622 \fi
4623}
4624
4625% Like \expandablevalue, but completely expandable (the \message in the
4626% definition above operates at the execution level of TeX). Used when
4627% writing to auxiliary files, due to the expansion that \write does.
4628% If flag is undefined, pass through an unexpanded @value command: maybe it
4629% will be set by the time it is read back in.
4630%
4631% NB flag names containing - or _ may not work here.
4632\def\dummyvalue#1{%
4633 \expandafter\ifx\csname SET#1\endcsname\relax
4634 \string\value{#1}%
4635 \else
4636 \csname SET#1\endcsname
4637 \fi
4638}
4639
4640% Used for @value's in index entries to form the sort key: expand the @value
4641% if possible, otherwise sort late.
4642\def\indexnofontsvalue#1{%
4643 \expandafter\ifx\csname SET#1\endcsname\relax
4644 ZZZZZZZ%
4645 \else
4646 \csname SET#1\endcsname
4647 \fi
4648}
4649
4650% @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
4651% with @set.
4652%
4653% To get the special treatment we need for `@end ifset,' we call
4654% \makecond and then redefine.
4655%
4656\makecond{ifset}
4657\def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}}
4658\def\doifset#1#2{%
4659 {%
4660 \makevalueexpandable
4661 \let\next=\empty
4662 \expandafter\ifx\csname SET#2\endcsname\relax
4663 #1% If not set, redefine \next.
4664 \fi
4665 \expandafter
4666 }\next
4667}
4668\def\ifsetfail{\doignore{ifset}}
4669
4670% @ifclear VAR ... @end executes the `...' iff VAR has never been
4671% defined with @set, or has been undefined with @clear.
4672%
4673% The `\else' inside the `\doifset' parameter is a trick to reuse the
4674% above code: if the variable is not set, do nothing, if it is set,
4675% then redefine \next to \ifclearfail.
4676%
4677\makecond{ifclear}
4678\def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}}
4679\def\ifclearfail{\doignore{ifclear}}
4680
4681% @ifcommandisdefined CMD ... @end executes the `...' if CMD (written
4682% without the @) is in fact defined. We can only feasibly check at the
4683% TeX level, so something like `mathcode' is going to considered
4684% defined even though it is not a Texinfo command.
4685%
4686\makecond{ifcommanddefined}
4687\def\ifcommanddefined{\parsearg{\doifcmddefined{\let\next=\ifcmddefinedfail}}}
4688%
4689\def\doifcmddefined#1#2{{%
4690 \makevalueexpandable
4691 \let\next=\empty
4692 \expandafter\ifx\csname #2\endcsname\relax
4693 #1% If not defined, \let\next as above.
4694 \fi
4695 \expandafter
4696 }\next
4697}
4698\def\ifcmddefinedfail{\doignore{ifcommanddefined}}
4699
4700% @ifcommandnotdefined CMD ... handled similar to @ifclear above.
4701\makecond{ifcommandnotdefined}
4702\def\ifcommandnotdefined{%
4703 \parsearg{\doifcmddefined{\else \let\next=\ifcmdnotdefinedfail}}}
4704\def\ifcmdnotdefinedfail{\doignore{ifcommandnotdefined}}
4705
4706% Set the `txicommandconditionals' variable, so documents have a way to
4707% test if the @ifcommand...defined conditionals are available.
4708\set txicommandconditionals
4709
4710% @dircategory CATEGORY -- specify a category of the dir file
4711% which this file should belong to. Ignore this in TeX.
4712\let\dircategory=\comment
4713
4714% @defininfoenclose.
4715\let\definfoenclose=\comment
4716
4717
4718\message{indexing,}
4719% Index generation facilities
4720
4721% Define \newwrite to be identical to plain tex's \newwrite
4722% except not \outer, so it can be used within macros and \if's.
4723\edef\newwrite{\makecsname{ptexnewwrite}}
4724
4725% \newindex {foo} defines an index named IX.
4726% It automatically defines \IXindex such that
4727% \IXindex ...rest of line... puts an entry in the index IX.
4728% It also defines \IXindfile to be the number of the output channel for
4729% the file that accumulates this index. The file's extension is IX.
4730% The name of an index should be no more than 2 characters long
4731% for the sake of vms.
4732%
4733\def\newindex#1{%
4734 \expandafter\chardef\csname#1indfile\endcsname=0
4735 \expandafter\xdef\csname#1index\endcsname{% % Define @#1index
4736 \noexpand\doindex{#1}}
4737}
4738
4739% @defindex foo == \newindex{foo}
4740%
4741\def\defindex{\parsearg\newindex}
4742
4743% Define @defcodeindex, like @defindex except put all entries in @code.
4744%
4745\def\defcodeindex{\parsearg\newcodeindex}
4746%
4747\def\newcodeindex#1{%
4748 \expandafter\chardef\csname#1indfile\endcsname=0
4749 \expandafter\xdef\csname#1index\endcsname{%
4750 \noexpand\docodeindex{#1}}%
4751}
4752
4753% The default indices:
4754\newindex{cp}% concepts,
4755\newcodeindex{fn}% functions,
4756\newcodeindex{vr}% variables,
4757\newcodeindex{tp}% types,
4758\newcodeindex{ky}% keys
4759\newcodeindex{pg}% and programs.
4760
4761
4762% @synindex foo bar makes index foo feed into index bar.
4763% Do this instead of @defindex foo if you don't want it as a separate index.
4764%
4765% @syncodeindex foo bar similar, but put all entries made for index foo
4766% inside @code.
4767%
4768\def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}}
4769\def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}}
4770
4771% #1 is \doindex or \docodeindex, #2 the index getting redefined (foo),
4772% #3 the target index (bar).
4773\def\dosynindex#1#2#3{%
4774 \requireopenindexfile{#3}%
4775 % redefine \fooindfile:
4776 \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname
4777 \expandafter\let\csname#2indfile\endcsname=\temp
4778 % redefine \fooindex:
4779 \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}%
4780}
4781
4782% Define \doindex, the driver for all index macros.
4783% Argument #1 is generated by the calling \fooindex macro,
4784% and it is the two-letter name of the index.
4785
4786\def\doindex#1{\edef\indexname{#1}\parsearg\doindexxxx}
4787\def\doindexxxx #1{\doind{\indexname}{#1}}
4788
4789% like the previous two, but they put @code around the argument.
4790\def\docodeindex#1{\edef\indexname{#1}\parsearg\docodeindexxxx}
4791\def\docodeindexxxx #1{\docind{\indexname}{#1}}
4792
4793
4794% Used for the aux, toc and index files to prevent expansion of Texinfo
4795% commands.
4796%
4797\def\atdummies{%
4798 \definedummyletter\@%
4799 \definedummyletter\ %
4800 \definedummyletter\{%
4801 \definedummyletter\}%
4802 \definedummyletter\&%
4803 %
4804 % Do the redefinitions.
4805 \definedummies
4806 \otherbackslash
4807}
4808
4809% \definedummyword defines \#1 as \string\#1\space, thus effectively
4810% preventing its expansion. This is used only for control words,
4811% not control letters, because the \space would be incorrect for
4812% control characters, but is needed to separate the control word
4813% from whatever follows.
4814%
4815% These can be used both for control words that take an argument and
4816% those that do not. If it is followed by {arg} in the input, then
4817% that will dutifully get written to the index (or wherever).
4818%
4819% For control letters, we have \definedummyletter, which omits the
4820% space.
4821%
4822\def\definedummyword #1{\def#1{\string#1\space}}%
4823\def\definedummyletter#1{\def#1{\string#1}}%
4824\let\definedummyaccent\definedummyletter
4825
4826% Called from \atdummies to prevent the expansion of commands.
4827%
4828\def\definedummies{%
4829 %
4830 \let\commondummyword\definedummyword
4831 \let\commondummyletter\definedummyletter
4832 \let\commondummyaccent\definedummyaccent
4833 \commondummiesnofonts
4834 %
4835 \definedummyletter\_%
4836 \definedummyletter\-%
4837 %
4838 % Non-English letters.
4839 \definedummyword\AA
4840 \definedummyword\AE
4841 \definedummyword\DH
4842 \definedummyword\L
4843 \definedummyword\O
4844 \definedummyword\OE
4845 \definedummyword\TH
4846 \definedummyword\aa
4847 \definedummyword\ae
4848 \definedummyword\dh
4849 \definedummyword\exclamdown
4850 \definedummyword\l
4851 \definedummyword\o
4852 \definedummyword\oe
4853 \definedummyword\ordf
4854 \definedummyword\ordm
4855 \definedummyword\questiondown
4856 \definedummyword\ss
4857 \definedummyword\th
4858 %
4859 % Although these internal commands shouldn't show up, sometimes they do.
4860 \definedummyword\bf
4861 \definedummyword\gtr
4862 \definedummyword\hat
4863 \definedummyword\less
4864 \definedummyword\sf
4865 \definedummyword\sl
4866 \definedummyword\tclose
4867 \definedummyword\tt
4868 %
4869 \definedummyword\LaTeX
4870 \definedummyword\TeX
4871 %
4872 % Assorted special characters.
4873 \definedummyword\ampchar
4874 \definedummyword\atchar
4875 \definedummyword\arrow
4876 \definedummyword\backslashchar
4877 \definedummyword\bullet
4878 \definedummyword\comma
4879 \definedummyword\copyright
4880 \definedummyword\registeredsymbol
4881 \definedummyword\dots
4882 \definedummyword\enddots
4883 \definedummyword\entrybreak
4884 \definedummyword\equiv
4885 \definedummyword\error
4886 \definedummyword\euro
4887 \definedummyword\expansion
4888 \definedummyword\geq
4889 \definedummyword\guillemetleft
4890 \definedummyword\guillemetright
4891 \definedummyword\guilsinglleft
4892 \definedummyword\guilsinglright
4893 \definedummyword\lbracechar
4894 \definedummyword\leq
4895 \definedummyword\mathopsup
4896 \definedummyword\minus
4897 \definedummyword\ogonek
4898 \definedummyword\pounds
4899 \definedummyword\point
4900 \definedummyword\print
4901 \definedummyword\quotedblbase
4902 \definedummyword\quotedblleft
4903 \definedummyword\quotedblright
4904 \definedummyword\quoteleft
4905 \definedummyword\quoteright
4906 \definedummyword\quotesinglbase
4907 \definedummyword\rbracechar
4908 \definedummyword\result
4909 \definedummyword\sub
4910 \definedummyword\sup
4911 \definedummyword\textdegree
4912 %
4913 \definedummyword\subentry
4914 %
4915 % We want to disable all macros so that they are not expanded by \write.
4916 \macrolist
4917 \let\value\dummyvalue
4918 %
4919 \normalturnoffactive
4920}
4921
4922% \commondummiesnofonts: common to \definedummies and \indexnofonts.
4923% Define \commondummyletter, \commondummyaccent and \commondummyword before
4924% using. Used for accents, font commands, and various control letters.
4925%
4926\def\commondummiesnofonts{%
4927 % Control letters and accents.
4928 \commondummyletter\!%
4929 \commondummyaccent\"%
4930 \commondummyaccent\'%
4931 \commondummyletter\*%
4932 \commondummyaccent\,%
4933 \commondummyletter\.%
4934 \commondummyletter\/%
4935 \commondummyletter\:%
4936 \commondummyaccent\=%
4937 \commondummyletter\?%
4938 \commondummyaccent\^%
4939 \commondummyaccent\`%
4940 \commondummyaccent\~%
4941 \commondummyword\u
4942 \commondummyword\v
4943 \commondummyword\H
4944 \commondummyword\dotaccent
4945 \commondummyword\ogonek
4946 \commondummyword\ringaccent
4947 \commondummyword\tieaccent
4948 \commondummyword\ubaraccent
4949 \commondummyword\udotaccent
4950 \commondummyword\dotless
4951 %
4952 % Texinfo font commands.
4953 \commondummyword\b
4954 \commondummyword\i
4955 \commondummyword\r
4956 \commondummyword\sansserif
4957 \commondummyword\sc
4958 \commondummyword\slanted
4959 \commondummyword\t
4960 %
4961 % Commands that take arguments.
4962 \commondummyword\abbr
4963 \commondummyword\acronym
4964 \commondummyword\anchor
4965 \commondummyword\cite
4966 \commondummyword\code
4967 \commondummyword\command
4968 \commondummyword\dfn
4969 \commondummyword\dmn
4970 \commondummyword\email
4971 \commondummyword\emph
4972 \commondummyword\env
4973 \commondummyword\file
4974 \commondummyword\image
4975 \commondummyword\indicateurl
4976 \commondummyword\inforef
4977 \commondummyword\kbd
4978 \commondummyword\key
4979 \commondummyword\math
4980 \commondummyword\option
4981 \commondummyword\pxref
4982 \commondummyword\ref
4983 \commondummyword\samp
4984 \commondummyword\strong
4985 \commondummyword\tie
4986 \commondummyword\U
4987 \commondummyword\uref
4988 \commondummyword\url
4989 \commondummyword\var
4990 \commondummyword\verb
4991 \commondummyword\w
4992 \commondummyword\xref
4993}
4994
4995\let\indexlbrace\relax
4996\let\indexrbrace\relax
4997\let\indexatchar\relax
4998\let\indexbackslash\relax
4999
5000{\catcode`\@=0
5001\catcode`\\=13
5002 @gdef@backslashdisappear{@def\{}}
5003}
5004
5005{
5006\catcode`\<=13
5007\catcode`\-=13
5008\catcode`\`=13
5009 \gdef\indexnonalnumdisappear{%
5010 \ifflagclear{txiindexlquoteignore}{}{%
5011 % @set txiindexlquoteignore makes us ignore left quotes in the sort term.
5012 % (Introduced for FSFS 2nd ed.)
5013 \let`=\empty
5014 }%
5015 %
5016 \ifflagclear{txiindexbackslashignore}{}{%
5017 \backslashdisappear
5018 }%
5019 \ifflagclear{txiindexhyphenignore}{}{%
5020 \def-{}%
5021 }%
5022 \ifflagclear{txiindexlessthanignore}{}{%
5023 \def<{}%
5024 }%
5025 \ifflagclear{txiindexatsignignore}{}{%
5026 \def\@{}%
5027 }%
5028 }
5029
5030 \gdef\indexnonalnumreappear{%
5031 \let-\normaldash
5032 \let<\normalless
5033 }
5034}
5035
5036
5037% \indexnofonts is used when outputting the strings to sort the index
5038% by, and when constructing control sequence names. It eliminates all
5039% control sequences and just writes whatever the best ASCII sort string
5040% would be for a given command (usually its argument).
5041%
5042\def\indexnofonts{%
5043 % Accent commands should become @asis.
5044 \def\commondummyaccent##1{\let##1\asis}%
5045 % We can just ignore other control letters.
5046 \def\commondummyletter##1{\let##1\empty}%
5047 % All control words become @asis by default; overrides below.
5048 \let\commondummyword\commondummyaccent
5049 \commondummiesnofonts
5050 %
5051 % Don't no-op \tt, since it isn't a user-level command
5052 % and is used in the definitions of the active chars like <, >, |, etc.
5053 % Likewise with the other plain tex font commands.
5054 %\let\tt=\asis
5055 %
5056 \def\ { }%
5057 \def\@{@}%
5058 \def\_{\normalunderscore}%
5059 \def\-{}% @- shouldn't affect sorting
5060 %
5061 \uccode`\1=`\{ \uppercase{\def\{{1}}%
5062 \uccode`\1=`\} \uppercase{\def\}{1}}%
5063 \let\lbracechar\{%
5064 \let\rbracechar\}%
5065 %
5066 % Non-English letters.
5067 \def\AA{AA}%
5068 \def\AE{AE}%
5069 \def\DH{DZZ}%
5070 \def\L{L}%
5071 \def\OE{OE}%
5072 \def\O{O}%
5073 \def\TH{TH}%
5074 \def\aa{aa}%
5075 \def\ae{ae}%
5076 \def\dh{dzz}%
5077 \def\exclamdown{!}%
5078 \def\l{l}%
5079 \def\oe{oe}%
5080 \def\ordf{a}%
5081 \def\ordm{o}%
5082 \def\o{o}%
5083 \def\questiondown{?}%
5084 \def\ss{ss}%
5085 \def\th{th}%
5086 %
5087 \let\do\indexnofontsdef
5088 %
5089 \do\LaTeX{LaTeX}%
5090 \do\TeX{TeX}%
5091 %
5092 % Assorted special characters.
5093 \do\atchar{@}%
5094 \do\arrow{->}%
5095 \do\bullet{bullet}%
5096 \do\comma{,}%
5097 \do\copyright{copyright}%
5098 \do\dots{...}%
5099 \do\enddots{...}%
5100 \do\equiv{==}%
5101 \do\error{error}%
5102 \do\euro{euro}%
5103 \do\expansion{==>}%
5104 \do\geq{>=}%
5105 \do\guillemetleft{<<}%
5106 \do\guillemetright{>>}%
5107 \do\guilsinglleft{<}%
5108 \do\guilsinglright{>}%
5109 \do\leq{<=}%
5110 \do\lbracechar{\{}%
5111 \do\minus{-}%
5112 \do\point{.}%
5113 \do\pounds{pounds}%
5114 \do\print{-|}%
5115 \do\quotedblbase{"}%
5116 \do\quotedblleft{"}%
5117 \do\quotedblright{"}%
5118 \do\quoteleft{`}%
5119 \do\quoteright{'}%
5120 \do\quotesinglbase{,}%
5121 \do\rbracechar{\}}%
5122 \do\registeredsymbol{R}%
5123 \do\result{=>}%
5124 \do\textdegree{o}%
5125 %
5126 % We need to get rid of all macros, leaving only the arguments (if present).
5127 % Of course this is not nearly correct, but it is the best we can do for now.
5128 % makeinfo does not expand macros in the argument to @deffn, which ends up
5129 % writing an index entry, and texindex isn't prepared for an index sort entry
5130 % that starts with \.
5131 %
5132 % Since macro invocations are followed by braces, we can just redefine them
5133 % to take a single TeX argument. The case of a macro invocation that
5134 % goes to end-of-line is not handled.
5135 %
5136 \macrolist
5137 \let\value\indexnofontsvalue
5138}
5139
5140% Give the control sequence a definition that removes the {} that follows
5141% its use, e.g. @AA{} -> AA
5142\def\indexnofontsdef#1#2{\def#1##1{#2}}%
5143
5144
5145
5146
5147% #1 is the index name, #2 is the entry text.
5148\def\doind#1#2{%
5149 \iflinks
5150 {%
5151 %
5152 \requireopenindexfile{#1}%
5153 \edef\writeto{\csname#1indfile\endcsname}%
5154 %
5155 \def\indextext{#2}%
5156 \safewhatsit\doindwrite
5157 }%
5158 \fi
5159}
5160
5161% Same as \doind, but for code indices
5162\def\docind#1#2{%
5163 \iflinks
5164 {%
5165 %
5166 \requireopenindexfile{#1}%
5167 \edef\writeto{\csname#1indfile\endcsname}%
5168 %
5169 \def\indextext{#2}%
5170 \safewhatsit\docindwrite
5171 }%
5172 \fi
5173}
5174
5175% Check if an index file has been opened, and if not, open it.
5176\def\requireopenindexfile#1{%
5177\ifnum\csname #1indfile\endcsname=0
5178 \expandafter\newwrite \csname#1indfile\endcsname
5179 \edef\suffix{#1}%
5180 % A .fls suffix would conflict with the file extension for the output
5181 % of -recorder, so use .f1s instead.
5182 \ifx\suffix\indexisfl\def\suffix{f1}\fi
5183 % Open the file
5184 \immediate\openout\csname#1indfile\endcsname \jobname.\suffix
5185 % Using \immediate above here prevents an object entering into the current
5186 % box, which could confound checks such as those in \safewhatsit for
5187 % preceding skips.
5188 \typeout{Writing index file \jobname.\suffix}%
5189\fi}
5190\def\indexisfl{fl}
5191
5192% Definition for writing index entry sort key.
5193{
5194\catcode`\-=13
5195\gdef\indexwritesortas{%
5196 \begingroup
5197 \indexnonalnumreappear
5198 \indexwritesortasxxx}
5199\gdef\indexwritesortasxxx#1{%
5200 \xdef\indexsortkey{#1}\endgroup}
5201}
5202
5203\def\indexwriteseealso#1{
5204 \gdef\pagenumbertext{\string\seealso{#1}}%
5205}
5206\def\indexwriteseeentry#1{
5207 \gdef\pagenumbertext{\string\seeentry{#1}}%
5208}
5209
5210% The default definitions
5211\def\sortas#1{}%
5212\def\seealso#1{\i{\putwordSeeAlso}\ #1}% for sorted index file only
5213\def\putwordSeeAlso{See also}
5214\def\seeentry#1{\i{\putwordSee}\ #1}% for sorted index file only
5215
5216
5217% Given index entry text like "aaa @subentry bbb @sortas{ZZZ}":
5218% * Set \bracedtext to "{aaa}{bbb}"
5219% * Set \fullindexsortkey to "aaa @subentry ZZZ"
5220% * If @seealso occurs, set \pagenumbertext
5221%
5222\def\splitindexentry#1{%
5223 \gdef\fullindexsortkey{}%
5224 \xdef\bracedtext{}%
5225 \def\sep{}%
5226 \def\seealso##1{}%
5227 \def\seeentry##1{}%
5228 \expandafter\doindexsegment#1\subentry\finish\subentry
5229}
5230
5231% append the results from the next segment
5232\def\doindexsegment#1\subentry{%
5233 \def\segment{#1}%
5234 \ifx\segment\isfinish
5235 \else
5236 %
5237 % Fully expand the segment, throwing away any @sortas directives, and
5238 % trim spaces.
5239 \edef\trimmed{\segment}%
5240 \edef\trimmed{\expandafter\eatspaces\expandafter{\trimmed}}%
5241 \ifincodeindex
5242 \edef\trimmed{\noexpand\code{\trimmed}}%
5243 \fi
5244 %
5245 \xdef\bracedtext{\bracedtext{\trimmed}}%
5246 %
5247 % Get the string to sort by. Process the segment with all
5248 % font commands turned off.
5249 \bgroup
5250 \let\sortas\indexwritesortas
5251 \let\seealso\indexwriteseealso
5252 \let\seeentry\indexwriteseeentry
5253 \indexnofonts
5254 % The braces around the commands are recognized by texindex.
5255 \def\lbracechar{{\string\indexlbrace}}%
5256 \def\rbracechar{{\string\indexrbrace}}%
5257 \let\{=\lbracechar
5258 \let\}=\rbracechar
5259 \def\@{{\string\indexatchar}}%
5260 \def\atchar##1{\@}%
5261 \def\backslashchar{{\string\indexbackslash}}%
5262 \uccode`\~=`\\ \uppercase{\let~\backslashchar}%
5263 %
5264 \let\indexsortkey\empty
5265 \global\let\pagenumbertext\empty
5266 % Execute the segment and throw away the typeset output. This executes
5267 % any @sortas or @seealso commands in this segment.
5268 \setbox\dummybox = \hbox{\segment}%
5269 \ifx\indexsortkey\empty{%
5270 \indexnonalnumdisappear
5271 \xdef\trimmed{\segment}%
5272 \xdef\trimmed{\expandafter\eatspaces\expandafter{\trimmed}}%
5273 \xdef\indexsortkey{\trimmed}%
5274 \ifx\indexsortkey\empty\xdef\indexsortkey{ }\fi
5275 }\fi
5276 %
5277 % Append to \fullindexsortkey.
5278 \edef\tmp{\gdef\noexpand\fullindexsortkey{%
5279 \fullindexsortkey\sep\indexsortkey}}%
5280 \tmp
5281 \egroup
5282 \def\sep{\subentry}%
5283 %
5284 \expandafter\doindexsegment
5285 \fi
5286}
5287\def\isfinish{\finish}%
5288\newbox\dummybox % used above
5289
5290\let\subentry\relax
5291
5292% Use \ instead of @ in index files. To support old texi2dvi and texindex.
5293% This works without changing the escape character used in the toc or aux
5294% files because the index entries are fully expanded here, and \string uses
5295% the current value of \escapechar.
5296\def\escapeisbackslash{\escapechar=`\\}
5297
5298% Use \ in index files by default. texi2dvi didn't support @ as the escape
5299% character (as it checked for "\entry" in the files, and not "@entry"). When
5300% the new version of texi2dvi has had a chance to become more prevalent, then
5301% the escape character can change back to @ again. This should be an easy
5302% change to make now because both @ and \ are only used as escape characters in
5303% index files, never standing for themselves.
5304%
5305\set txiindexescapeisbackslash
5306
5307% Write the entry in \indextext to the index file.
5308%
5309
5310\newif\ifincodeindex
5311\def\doindwrite{\incodeindexfalse\doindwritex}
5312\def\docindwrite{\incodeindextrue\doindwritex}
5313
5314\def\doindwritex{%
5315 \maybemarginindex
5316 %
5317 \atdummies
5318 %
5319 \ifflagclear{txiindexescapeisbackslash}{}{\escapeisbackslash}%
5320 %
5321 % For texindex which always views { and } as separators.
5322 \def\{{\lbracechar{}}%
5323 \def\}{\rbracechar{}}%
5324 \uccode`\~=`\\ \uppercase{\def~{\backslashchar{}}}%
5325 %
5326 % Split the entry into primary entry and any subentries, and get the index
5327 % sort key.
5328 \splitindexentry\indextext
5329 %
5330 % Set up the complete index entry, with both the sort key and
5331 % the original text, including any font commands. We write
5332 % three arguments to \entry to the .?? file (four in the
5333 % subentry case), texindex reduces to two when writing the .??s
5334 % sorted result.
5335 %
5336 \edef\temp{%
5337 \write\writeto{%
5338 \string\entry{\fullindexsortkey}%
5339 {\ifx\pagenumbertext\empty\noexpand\folio\else\pagenumbertext\fi}%
5340 \bracedtext}%
5341 }%
5342 \temp
5343}
5344
5345% Put the index entry in the margin if desired (undocumented).
5346\def\maybemarginindex{%
5347 \ifx\SETmarginindex\relax\else
5348 \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \relax\indextext}}%
5349 \fi
5350}
5351\let\SETmarginindex=\relax
5352
5353
5354% Take care of unwanted page breaks/skips around a whatsit:
5355%
5356% If a skip is the last thing on the list now, preserve it
5357% by backing up by \lastskip, doing the \write, then inserting
5358% the skip again. Otherwise, the whatsit generated by the
5359% \write or \pdfdest will make \lastskip zero. The result is that
5360% sequences like this:
5361% @end defun
5362% @tindex whatever
5363% @defun ...
5364% will have extra space inserted, because the \medbreak in the
5365% start of the @defun won't see the skip inserted by the @end of
5366% the previous defun.
5367%
5368% But don't do any of this if we're not in vertical mode. We
5369% don't want to do a \vskip and prematurely end a paragraph.
5370%
5371% Avoid page breaks due to these extra skips, too.
5372%
5373% But wait, there is a catch there:
5374% We'll have to check whether \lastskip is zero skip. \ifdim is not
5375% sufficient for this purpose, as it ignores stretch and shrink parts
5376% of the skip. The only way seems to be to check the textual
5377% representation of the skip.
5378%
5379% The following is almost like \def\zeroskipmacro{0.0pt} except that
5380% the ``p'' and ``t'' characters have catcode \other, not 11 (letter).
5381%
5382\edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname}
5383%
5384\newskip\whatsitskip
5385\newcount\whatsitpenalty
5386%
5387% ..., ready, GO:
5388%
5389\def\safewhatsit#1{\ifhmode
5390 #1%
5391 \else
5392 % \lastskip and \lastpenalty cannot both be nonzero simultaneously.
5393 \whatsitskip = \lastskip
5394 \edef\lastskipmacro{\the\lastskip}%
5395 \whatsitpenalty = \lastpenalty
5396 %
5397 % If \lastskip is nonzero, that means the last item was a
5398 % skip. And since a skip is discardable, that means this
5399 % -\whatsitskip glue we're inserting is preceded by a
5400 % non-discardable item, therefore it is not a potential
5401 % breakpoint, therefore no \nobreak needed.
5402 \ifx\lastskipmacro\zeroskipmacro
5403 \else
5404 \vskip-\whatsitskip
5405 \fi
5406 %
5407 #1%
5408 %
5409 \ifx\lastskipmacro\zeroskipmacro
5410 % If \lastskip was zero, perhaps the last item was a penalty, and
5411 % perhaps it was >=10000, e.g., a \nobreak. In that case, we want
5412 % to re-insert the same penalty (values >10000 are used for various
5413 % signals); since we just inserted a non-discardable item, any
5414 % following glue (such as a \parskip) would be a breakpoint. For example:
5415 % @deffn deffn-whatever
5416 % @vindex index-whatever
5417 % Description.
5418 % would allow a break between the index-whatever whatsit
5419 % and the "Description." paragraph.
5420 \ifnum\whatsitpenalty>9999 \penalty\whatsitpenalty \fi
5421 \else
5422 % On the other hand, if we had a nonzero \lastskip,
5423 % this make-up glue would be preceded by a non-discardable item
5424 % (the whatsit from the \write), so we must insert a \nobreak.
5425 \nobreak\vskip\whatsitskip
5426 \fi
5427\fi}
5428
5429% The index entry written in the file actually looks like
5430% \entry {sortstring}{page}{topic}
5431% or
5432% \entry {sortstring}{page}{topic}{subtopic}
5433% The texindex program reads in these files and writes files
5434% containing these kinds of lines:
5435% \initial {c}
5436% before the first topic whose initial is c
5437% \entry {topic}{pagelist}
5438% for a topic that is used without subtopics
5439% \primary {topic}
5440% \entry {topic}{}
5441% for the beginning of a topic that is used with subtopics
5442% \secondary {subtopic}{pagelist}
5443% for each subtopic.
5444% \secondary {subtopic}{}
5445% for a subtopic with sub-subtopics
5446% \tertiary {subtopic}{subsubtopic}{pagelist}
5447% for each sub-subtopic.
5448
5449% Define the user-accessible indexing commands
5450% @findex, @vindex, @kindex, @cindex.
5451
5452\def\findex {\fnindex}
5453\def\kindex {\kyindex}
5454\def\cindex {\cpindex}
5455\def\vindex {\vrindex}
5456\def\tindex {\tpindex}
5457\def\pindex {\pgindex}
5458
5459% Define the macros used in formatting output of the sorted index material.
5460
5461% @printindex causes a particular index (the ??s file) to get printed.
5462% It does not print any chapter heading (usually an @unnumbered).
5463%
5464\parseargdef\printindex{\begingroup
5465 \dobreak \chapheadingskip{10000}%
5466 %
5467 \smallfonts \rm
5468 \tolerance = 9500
5469 \plainfrenchspacing
5470 \everypar = {}% don't want the \kern\-parindent from indentation suppression.
5471 %
5472 % See comment in \requireopenindexfile.
5473 \def\indexname{#1}\ifx\indexname\indexisfl\def\indexname{f1}\fi
5474 %
5475 % See if the index file exists and is nonempty.
5476 \openin 1 \jobname.\indexname s
5477 \ifeof 1
5478 % \enddoublecolumns gets confused if there is no text in the index,
5479 % and it loses the chapter title and the aux file entries for the
5480 % index. The easiest way to prevent this problem is to make sure
5481 % there is some text.
5482 \putwordIndexNonexistent
5483 \typeout{No file \jobname.\indexname s.}%
5484 \else
5485 % If the index file exists but is empty, then \openin leaves \ifeof
5486 % false. We have to make TeX try to read something from the file, so
5487 % it can discover if there is anything in it.
5488 \read 1 to \thisline
5489 \ifeof 1
5490 \putwordIndexIsEmpty
5491 \else
5492 \expandafter\printindexzz\thisline\relax\relax\finish%
5493 \fi
5494 \fi
5495 \closein 1
5496\endgroup}
5497
5498% If the index file starts with a backslash, forgo reading the index
5499% file altogether. If somebody upgrades texinfo.tex they may still have
5500% old index files using \ as the escape character. Reading this would
5501% at best lead to typesetting garbage, at worst a TeX syntax error.
5502\def\printindexzz#1#2\finish{%
5503 \ifflagclear{txiindexescapeisbackslash}{%
5504 \uccode`\~=`\\ \uppercase{\if\noexpand~}\noexpand#1
5505 \ifflagclear{txiskipindexfileswithbackslash}{%
5506\errmessage{%
5507ERROR: A sorted index file in an obsolete format was skipped.
5508To fix this problem, please upgrade your version of 'texi2dvi'
5509or 'texi2pdf' to that at <https://ftp.gnu.org/gnu/texinfo>.
5510If you are using an old version of 'texindex' (part of the Texinfo
5511distribution), you may also need to upgrade to a newer version (at least 6.0).
5512You may be able to typeset the index if you run
5513'texindex \jobname.\indexname' yourself.
5514You could also try setting the 'txiindexescapeisbackslash' flag by
5515running a command like
5516'texi2dvi -t "@set txiindexescapeisbackslash" \jobname.texi'. If you do
5517this, Texinfo will try to use index files in the old format.
5518If you continue to have problems, deleting the index files and starting again
5519might help (with 'rm \jobname.?? \jobname.??s')%
5520}%
5521 }{%
5522 (Skipped sorted index file in obsolete format)
5523 }%
5524 \else
5525 \begindoublecolumns
5526 \input \jobname.\indexname s
5527 \enddoublecolumns
5528 \fi
5529 }{%
5530 \begindoublecolumns
5531 \catcode`\\=0\relax
5532 %
5533 % Make @ an escape character to give macros a chance to work. This
5534 % should work because we (hopefully) don't otherwise use @ in index files.
5535 %\catcode`\@=12\relax
5536 \catcode`\@=0\relax
5537 \input \jobname.\indexname s
5538 \enddoublecolumns
5539 }%
5540}
5541
5542% These macros are used by the sorted index file itself.
5543% Change them to control the appearance of the index.
5544
5545{\catcode`\/=13 \catcode`\-=13 \catcode`\^=13 \catcode`\~=13 \catcode`\_=13
5546\catcode`\|=13 \catcode`\<=13 \catcode`\>=13 \catcode`\+=13 \catcode`\"=13
5547\catcode`\$=3
5548\gdef\initialglyphs{%
5549 % special control sequences used in the index sort key
5550 \let\indexlbrace\{%
5551 \let\indexrbrace\}%
5552 \let\indexatchar\@%
5553 \def\indexbackslash{\math{\backslash}}%
5554 %
5555 % Some changes for non-alphabetic characters. Using the glyphs from the
5556 % math fonts looks more consistent than the typewriter font used elsewhere
5557 % for these characters.
5558 \uccode`\~=`\\ \uppercase{\def~{\math{\backslash}}}
5559 %
5560 % In case @\ is used for backslash
5561 \uppercase{\let\\=~}
5562 % Can't get bold backslash so don't use bold forward slash
5563 \catcode`\/=13
5564 \def/{{\secrmnotbold \normalslash}}%
5565 \def-{{\normaldash\normaldash}}% en dash `--'
5566 \def^{{\chapbf \normalcaret}}%
5567 \def~{{\chapbf \normaltilde}}%
5568 \def\_{%
5569 \leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }%
5570 \def|{$\vert$}%
5571 \def<{$\less$}%
5572 \def>{$\gtr$}%
5573 \def+{$\normalplus$}%
5574}}
5575
5576\def\initial{%
5577 \bgroup
5578 \initialglyphs
5579 \initialx
5580}
5581
5582\def\initialx#1{%
5583 % Remove any glue we may have, we'll be inserting our own.
5584 \removelastskip
5585 %
5586 % We like breaks before the index initials, so insert a bonus.
5587 % The glue before the bonus allows a little bit of space at the
5588 % bottom of a column to reduce an increase in inter-line spacing.
5589 \nobreak
5590 \vskip 0pt plus 5\baselineskip
5591 \penalty -300
5592 \vskip 0pt plus -5\baselineskip
5593 %
5594 % Typeset the initial. Making this add up to a whole number of
5595 % baselineskips increases the chance of the dots lining up from column
5596 % to column. It still won't often be perfect, because of the stretch
5597 % we need before each entry, but it's better.
5598 %
5599 % No shrink because it confuses \balancecolumns.
5600 \vskip 1.67\baselineskip plus 1\baselineskip
5601 \leftline{\secfonts \kern-0.05em \secbf #1}%
5602 % \secfonts is inside the argument of \leftline so that the change of
5603 % \baselineskip will not affect any glue inserted before the vbox that
5604 % \leftline creates.
5605 % Do our best not to break after the initial.
5606 \nobreak
5607 \vskip .33\baselineskip plus .1\baselineskip
5608 \egroup % \initialglyphs
5609}
5610
5611\newdimen\entryrightmargin
5612\entryrightmargin=0pt
5613
5614% \entry typesets a paragraph consisting of the text (#1), dot leaders, and
5615% then page number (#2) flushed to the right margin. It is used for index
5616% and table of contents entries. The paragraph is indented by \leftskip.
5617%
5618\def\entry{%
5619 \begingroup
5620 %
5621 % Start a new paragraph if necessary, so our assignments below can't
5622 % affect previous text.
5623 \par
5624 %
5625 % No extra space above this paragraph.
5626 \parskip = 0in
5627 %
5628 % When reading the text of entry, convert explicit line breaks
5629 % from @* into spaces. The user might give these in long section
5630 % titles, for instance.
5631 \def\*{\unskip\space\ignorespaces}%
5632 \def\entrybreak{\hfil\break}% An undocumented command
5633 %
5634 % Swallow the left brace of the text (first parameter):
5635 \afterassignment\doentry
5636 \let\temp =
5637}
5638\def\entrybreak{\unskip\space\ignorespaces}%
5639\def\doentry{%
5640 % Save the text of the entry
5641 \global\setbox\boxA=\hbox\bgroup
5642 \bgroup % Instead of the swallowed brace.
5643 \noindent
5644 \aftergroup\finishentry
5645 % And now comes the text of the entry.
5646 % Not absorbing as a macro argument reduces the chance of problems
5647 % with catcodes occurring.
5648}
5649{\catcode`\@=11
5650\gdef\finishentry#1{%
5651 \egroup % end box A
5652 \dimen@ = \wd\boxA % Length of text of entry
5653 \global\setbox\boxA=\hbox\bgroup
5654 \unhbox\boxA
5655 % #1 is the page number.
5656 %
5657 % Get the width of the page numbers, and only use
5658 % leaders if they are present.
5659 \global\setbox\boxB = \hbox{#1}%
5660 \ifdim\wd\boxB = 0pt
5661 \null\nobreak\hfill\ %
5662 \else
5663 %
5664 \null\nobreak\indexdotfill % Have leaders before the page number.
5665 %
5666 \ifpdforxetex
5667 \pdfgettoks#1.%
5668 \hskip\skip\thinshrinkable\the\toksA
5669 \else
5670 \hskip\skip\thinshrinkable #1%
5671 \fi
5672 \fi
5673 \egroup % end \boxA
5674 \ifdim\wd\boxB = 0pt
5675 \noindent\unhbox\boxA\par
5676 \nobreak
5677 \else\bgroup
5678 % We want the text of the entries to be aligned to the left, and the
5679 % page numbers to be aligned to the right.
5680 %
5681 \parindent = 0pt
5682 \advance\leftskip by 0pt plus 1fil
5683 \advance\leftskip by 0pt plus -1fill
5684 \rightskip = 0pt plus -1fil
5685 \advance\rightskip by 0pt plus 1fill
5686 % Cause last line, which could consist of page numbers on their own
5687 % if the list of page numbers is long, to be aligned to the right.
5688 \parfillskip=0pt plus -1fill
5689 %
5690 \advance\rightskip by \entryrightmargin
5691 % Determine how far we can stretch into the margin.
5692 % This allows, e.g., "Appendix H GNU Free Documentation License" to
5693 % fit on one line in @letterpaper format.
5694 \ifdim\entryrightmargin>2.1em
5695 \dimen@i=2.1em
5696 \else
5697 \dimen@i=0em
5698 \fi
5699 \advance \parfillskip by 0pt minus 1\dimen@i
5700 %
5701 \dimen@ii = \hsize
5702 \advance\dimen@ii by -1\leftskip
5703 \advance\dimen@ii by -1\entryrightmargin
5704 \advance\dimen@ii by 1\dimen@i
5705 \ifdim\wd\boxA > \dimen@ii % If the entry doesn't fit in one line
5706 \ifdim\dimen@ > 0.8\dimen@ii % due to long index text
5707 % Try to split the text roughly evenly. \dimen@ will be the length of
5708 % the first line.
5709 \dimen@ = 0.7\dimen@
5710 \dimen@ii = \hsize
5711 \ifnum\dimen@>\dimen@ii
5712 % If the entry is too long (for example, if it needs more than
5713 % two lines), use all the space in the first line.
5714 \dimen@ = \dimen@ii
5715 \fi
5716 \advance\leftskip by 0pt plus 1fill % ragged right
5717 \advance \dimen@ by 1\rightskip
5718 \parshape = 2 0pt \dimen@ 0em \dimen@ii
5719 % Ideally we'd add a finite glue at the end of the first line only,
5720 % instead of using \parshape with explicit line lengths, but TeX
5721 % doesn't seem to provide a way to do such a thing.
5722 %
5723 % Indent all lines but the first one.
5724 \advance\leftskip by 1em
5725 \advance\parindent by -1em
5726 \fi\fi
5727 \indent % start paragraph
5728 \unhbox\boxA
5729 %
5730 % Do not prefer a separate line ending with a hyphen to fewer lines.
5731 \finalhyphendemerits = 0
5732 %
5733 % Word spacing - no stretch
5734 \spaceskip=\fontdimen2\font minus \fontdimen4\font
5735 %
5736 \linepenalty=1000 % Discourage line breaks.
5737 \hyphenpenalty=5000 % Discourage hyphenation.
5738 %
5739 \par % format the paragraph
5740 \egroup % The \vbox
5741 \fi
5742 \endgroup
5743}}
5744
5745\newskip\thinshrinkable
5746\skip\thinshrinkable=.15em minus .15em
5747
5748% Like plain.tex's \dotfill, except uses up at least 1 em.
5749% The filll stretch here overpowers both the fil and fill stretch to push
5750% the page number to the right.
5751\def\indexdotfill{\cleaders
5752 \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1filll}
5753
5754
5755\def\primary #1{\line{#1\hfil}}
5756
5757\def\secondary{\indententry{0.5cm}}
5758\def\tertiary{\indententry{1cm}}
5759
5760\def\indententry#1#2#3{%
5761 \bgroup
5762 \leftskip=#1
5763 \entry{#2}{#3}%
5764 \egroup
5765}
5766
5767% Define two-column mode, which we use to typeset indexes.
5768% Adapted from the TeXbook, page 416, which is to say,
5769% the manmac.tex format used to print the TeXbook itself.
5770\catcode`\@=11 % private names
5771
5772\newbox\partialpage
5773\newdimen\doublecolumnhsize
5774
5775\def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
5776 % If not much space left on page, start a new page.
5777 \ifdim\pagetotal>0.8\vsize\vfill\eject\fi
5778 %
5779 % Grab any single-column material above us.
5780 \output = {%
5781 \savetopmark
5782 %
5783 \global\setbox\partialpage = \vbox{%
5784 % Unvbox the main output page.
5785 \unvbox\PAGE
5786 \kern-\topskip \kern\baselineskip
5787 }%
5788 }%
5789 \eject % run that output routine to set \partialpage
5790 %
5791 % Use the double-column output routine for subsequent pages.
5792 \output = {\doublecolumnout}%
5793 %
5794 % Change the page size parameters. We could do this once outside this
5795 % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
5796 % format, but then we repeat the same computation. Repeating a couple
5797 % of assignments once per index is clearly meaningless for the
5798 % execution time, so we may as well do it in one place.
5799 %
5800 % First we halve the line length, less a little for the gutter between
5801 % the columns. We compute the gutter based on the line length, so it
5802 % changes automatically with the paper format. The magic constant
5803 % below is chosen so that the gutter has the same value (well, +-<1pt)
5804 % as it did when we hard-coded it.
5805 %
5806 % We put the result in a separate register, \doublecolumhsize, so we
5807 % can restore it in \pagesofar, after \hsize itself has (potentially)
5808 % been clobbered.
5809 %
5810 \doublecolumnhsize = \hsize
5811 \advance\doublecolumnhsize by -.04154\hsize
5812 \divide\doublecolumnhsize by 2
5813 \hsize = \doublecolumnhsize
5814 %
5815 % Get the available space for the double columns -- the normal
5816 % (undoubled) page height minus any material left over from the
5817 % previous page.
5818 \advance\vsize by -\ht\partialpage
5819 \vsize = 2\vsize
5820 %
5821 % For the benefit of balancing columns
5822 \advance\baselineskip by 0pt plus 0.5pt
5823}
5824
5825% The double-column output routine for all double-column pages except
5826% the last, which is done by \balancecolumns.
5827%
5828\def\doublecolumnout{%
5829 %
5830 \savetopmark
5831 \splittopskip=\topskip \splitmaxdepth=\maxdepth
5832 \dimen@ = \vsize
5833 \divide\dimen@ by 2
5834 %
5835 % box0 will be the left-hand column, box2 the right.
5836 \setbox0=\vsplit\PAGE to\dimen@ \setbox2=\vsplit\PAGE to\dimen@
5837 \global\advance\vsize by 2\ht\partialpage
5838 \onepageout\pagesofar % empty except for the first time we are called
5839 \unvbox\PAGE
5840 \penalty\outputpenalty
5841}
5842%
5843% Re-output the contents of the output page -- any previous material,
5844% followed by the two boxes we just split, in box0 and box2.
5845\def\pagesofar{%
5846 \unvbox\partialpage
5847 %
5848 \hsize = \doublecolumnhsize
5849 \wd0=\hsize \wd2=\hsize
5850 \hbox to\txipagewidth{\box0\hfil\box2}%
5851}
5852
5853
5854% Finished with double columns.
5855\def\enddoublecolumns{%
5856 % The following penalty ensures that the page builder is exercised
5857 % _before_ we change the output routine. This is necessary in the
5858 % following situation:
5859 %
5860 % The last section of the index consists only of a single entry.
5861 % Before this section, \pagetotal is less than \pagegoal, so no
5862 % break occurs before the last section starts. However, the last
5863 % section, consisting of \initial and the single \entry, does not
5864 % fit on the page and has to be broken off. Without the following
5865 % penalty the page builder will not be exercised until \eject
5866 % below, and by that time we'll already have changed the output
5867 % routine to the \balancecolumns version, so the next-to-last
5868 % double-column page will be processed with \balancecolumns, which
5869 % is wrong: The two columns will go to the main vertical list, with
5870 % the broken-off section in the recent contributions. As soon as
5871 % the output routine finishes, TeX starts reconsidering the page
5872 % break. The two columns and the broken-off section both fit on the
5873 % page, because the two columns now take up only half of the page
5874 % goal. When TeX sees \eject from below which follows the final
5875 % section, it invokes the new output routine that we've set after
5876 % \balancecolumns below; \onepageout will try to fit the two columns
5877 % and the final section into the vbox of \txipageheight (see
5878 % \pagebody), causing an overfull box.
5879 %
5880 % Note that glue won't work here, because glue does not exercise the
5881 % page builder, unlike penalties (see The TeXbook, pp. 280-281).
5882 \penalty0
5883 %
5884 \output = {%
5885 % Split the last of the double-column material.
5886 \savetopmark
5887 \balancecolumns
5888 }%
5889 \eject % call the \output just set
5890 \ifdim\pagetotal=0pt
5891 % Having called \balancecolumns once, we do not
5892 % want to call it again. Therefore, reset \output to its normal
5893 % definition right away.
5894 \global\output=\expandafter{\the\defaultoutput}
5895 %
5896 \endgroup % started in \begindoublecolumns
5897 % Leave the double-column material on the current page, no automatic
5898 % page break.
5899 \box\balancedcolumns
5900 %
5901 % \pagegoal was set to the doubled \vsize above, since we restarted
5902 % the current page. We're now back to normal single-column
5903 % typesetting, so reset \pagegoal to the normal \vsize.
5904 \global\vsize = \txipageheight %
5905 \pagegoal = \txipageheight %
5906 \else
5907 % We had some left-over material. This might happen when \doublecolumnout
5908 % is called in \balancecolumns. Try again.
5909 \expandafter\enddoublecolumns
5910 \fi
5911}
5912\newbox\balancedcolumns
5913\setbox\balancedcolumns=\vbox{shouldnt see this}%
5914%
5915% Only called for the last of the double column material. \doublecolumnout
5916% does the others.
5917\def\balancecolumns{%
5918 \setbox0 = \vbox{\unvbox\PAGE}% like \box255 but more efficient, see p.120.
5919 \dimen@ = \ht0
5920 \ifdim\dimen@<7\baselineskip
5921 % Don't split a short final column in two.
5922 \setbox2=\vbox{}%
5923 \global\setbox\balancedcolumns=\vbox{\pagesofar}%
5924 \else
5925 % double the leading vertical space
5926 \advance\dimen@ by \topskip
5927 \advance\dimen@ by-\baselineskip
5928 \divide\dimen@ by 2 % target to split to
5929 \dimen@ii = \dimen@
5930 \splittopskip = \topskip
5931 % Loop until left column is at least as high as the right column.
5932 {%
5933 \vbadness = 10000
5934 \loop
5935 \global\setbox3 = \copy0
5936 \global\setbox1 = \vsplit3 to \dimen@
5937 \ifdim\ht1<\ht3
5938 \global\advance\dimen@ by 1pt
5939 \repeat
5940 }%
5941 % Now the left column is in box 1, and the right column in box 3.
5942 %
5943 % Check whether the left column has come out higher than the page itself.
5944 % (Note that we have doubled \vsize for the double columns, so
5945 % the actual height of the page is 0.5\vsize).
5946 \ifdim2\ht1>\vsize
5947 % It appears that we have been called upon to balance too much material.
5948 % Output some of it with \doublecolumnout, leaving the rest on the page.
5949 \setbox\PAGE=\box0
5950 \doublecolumnout
5951 \else
5952 % Compare the heights of the two columns.
5953 \ifdim4\ht1>5\ht3
5954 % Column heights are too different, so don't make their bottoms
5955 % flush with each other.
5956 \setbox2=\vbox to \ht1 {\unvbox3\vfill}%
5957 \setbox0=\vbox to \ht1 {\unvbox1\vfill}%
5958 \else
5959 % Make column bottoms flush with each other.
5960 \setbox2=\vbox to\ht1{\unvbox3\unskip}%
5961 \setbox0=\vbox to\ht1{\unvbox1\unskip}%
5962 \fi
5963 \global\setbox\balancedcolumns=\vbox{\pagesofar}%
5964 \fi
5965 \fi
5966 %
5967}
5968\catcode`\@ = \other
5969
5970
5971\message{sectioning,}
5972% Chapters, sections, etc.
5973
5974% Let's start with @part.
5975\parseargdef\part{\partzzz{#1}}
5976\def\partzzz#1{%
5977 \chapoddpage
5978 \null
5979 \vskip.3\vsize % move it down on the page a bit
5980 \begingroup
5981 \noindent \titlefonts\rm #1\par % the text
5982 \let\lastnode=\empty % no node to associate with
5983 \writetocentry{part}{#1}{}% but put it in the toc
5984 \headingsoff % no headline or footline on the part page
5985 % This outputs a mark at the end of the page that clears \thischapter
5986 % and \thissection, as is done in \startcontents.
5987 \let\pchapsepmacro\relax
5988 \chapmacro{}{Yomitfromtoc}{}%
5989 \chapoddpage
5990 \endgroup
5991}
5992
5993% \unnumberedno is an oxymoron. But we count the unnumbered
5994% sections so that we can refer to them unambiguously in the pdf
5995% outlines by their "section number". We avoid collisions with chapter
5996% numbers by starting them at 10000. (If a document ever has 10000
5997% chapters, we're in trouble anyway, I'm sure.)
5998\newcount\unnumberedno \unnumberedno = 10000
5999\newcount\chapno
6000\newcount\secno \secno=0
6001\newcount\subsecno \subsecno=0
6002\newcount\subsubsecno \subsubsecno=0
6003
6004% This counter is funny since it counts through charcodes of letters A, B, ...
6005\newcount\appendixno \appendixno = `\@
6006%
6007% \def\appendixletter{\char\the\appendixno}
6008% We do the following ugly conditional instead of the above simple
6009% construct for the sake of pdftex, which needs the actual
6010% letter in the expansion, not just typeset.
6011%
6012\def\appendixletter{%
6013 \ifnum\appendixno=`A A%
6014 \else\ifnum\appendixno=`B B%
6015 \else\ifnum\appendixno=`C C%
6016 \else\ifnum\appendixno=`D D%
6017 \else\ifnum\appendixno=`E E%
6018 \else\ifnum\appendixno=`F F%
6019 \else\ifnum\appendixno=`G G%
6020 \else\ifnum\appendixno=`H H%
6021 \else\ifnum\appendixno=`I I%
6022 \else\ifnum\appendixno=`J J%
6023 \else\ifnum\appendixno=`K K%
6024 \else\ifnum\appendixno=`L L%
6025 \else\ifnum\appendixno=`M M%
6026 \else\ifnum\appendixno=`N N%
6027 \else\ifnum\appendixno=`O O%
6028 \else\ifnum\appendixno=`P P%
6029 \else\ifnum\appendixno=`Q Q%
6030 \else\ifnum\appendixno=`R R%
6031 \else\ifnum\appendixno=`S S%
6032 \else\ifnum\appendixno=`T T%
6033 \else\ifnum\appendixno=`U U%
6034 \else\ifnum\appendixno=`V V%
6035 \else\ifnum\appendixno=`W W%
6036 \else\ifnum\appendixno=`X X%
6037 \else\ifnum\appendixno=`Y Y%
6038 \else\ifnum\appendixno=`Z Z%
6039 % The \the is necessary, despite appearances, because \appendixletter is
6040 % expanded while writing the .toc file. \char\appendixno is not
6041 % expandable, thus it is written literally, thus all appendixes come out
6042 % with the same letter (or @) in the toc without it.
6043 \else\char\the\appendixno
6044 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
6045 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
6046
6047% Each @chapter defines these (using marks) as the number+name, number
6048% and name of the chapter. Page headings and footings can use
6049% these. @section does likewise.
6050\def\thischapter{}
6051\def\thischapternum{}
6052\def\thischaptername{}
6053\def\thissection{}
6054\def\thissectionnum{}
6055\def\thissectionname{}
6056
6057\newcount\absseclevel % used to calculate proper heading level
6058\newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count
6059
6060% @raisesections: treat @section as chapter, @subsection as section, etc.
6061\def\raisesections{\global\advance\secbase by -1}
6062
6063% @lowersections: treat @chapter as section, @section as subsection, etc.
6064\def\lowersections{\global\advance\secbase by 1}
6065
6066% we only have subsub.
6067\chardef\maxseclevel = 3
6068%
6069% A numbered section within an unnumbered changes to unnumbered too.
6070% To achieve this, remember the "biggest" unnum. sec. we are currently in:
6071\chardef\unnlevel = \maxseclevel
6072%
6073% Trace whether the current chapter is an appendix or not:
6074% \chapheadtype is "N" or "A", unnumbered chapters are ignored.
6075\def\chapheadtype{N}
6076
6077% Choose a heading macro
6078% #1 is heading type
6079% #2 is heading level
6080% #3 is text for heading
6081\def\genhead#1#2#3{%
6082 % Compute the abs. sec. level:
6083 \absseclevel=#2
6084 \advance\absseclevel by \secbase
6085 % Make sure \absseclevel doesn't fall outside the range:
6086 \ifnum \absseclevel < 0
6087 \absseclevel = 0
6088 \else
6089 \ifnum \absseclevel > 3
6090 \absseclevel = 3
6091 \fi
6092 \fi
6093 % The heading type:
6094 \def\headtype{#1}%
6095 \if \headtype U%
6096 \ifnum \absseclevel < \unnlevel
6097 \chardef\unnlevel = \absseclevel
6098 \fi
6099 \else
6100 % Check for appendix sections:
6101 \ifnum \absseclevel = 0
6102 \edef\chapheadtype{\headtype}%
6103 \else
6104 \if \headtype A\if \chapheadtype N%
6105 \errmessage{@appendix... within a non-appendix chapter}%
6106 \fi\fi
6107 \fi
6108 % Check for numbered within unnumbered:
6109 \ifnum \absseclevel > \unnlevel
6110 \def\headtype{U}%
6111 \else
6112 \chardef\unnlevel = 3
6113 \fi
6114 \fi
6115 % Now print the heading:
6116 \if \headtype U%
6117 \ifcase\absseclevel
6118 \unnumberedzzz{#3}%
6119 \or \unnumberedseczzz{#3}%
6120 \or \unnumberedsubseczzz{#3}%
6121 \or \unnumberedsubsubseczzz{#3}%
6122 \fi
6123 \else
6124 \if \headtype A%
6125 \ifcase\absseclevel
6126 \appendixzzz{#3}%
6127 \or \appendixsectionzzz{#3}%
6128 \or \appendixsubseczzz{#3}%
6129 \or \appendixsubsubseczzz{#3}%
6130 \fi
6131 \else
6132 \ifcase\absseclevel
6133 \chapterzzz{#3}%
6134 \or \seczzz{#3}%
6135 \or \numberedsubseczzz{#3}%
6136 \or \numberedsubsubseczzz{#3}%
6137 \fi
6138 \fi
6139 \fi
6140 \suppressfirstparagraphindent
6141}
6142
6143% an interface:
6144\def\numhead{\genhead N}
6145\def\apphead{\genhead A}
6146\def\unnmhead{\genhead U}
6147
6148% @chapter, @appendix, @unnumbered. Increment top-level counter, reset
6149% all lower-level sectioning counters to zero.
6150%
6151% Also set \chaplevelprefix, which we prepend to @float sequence numbers
6152% (e.g., figures), q.v. By default (before any chapter), that is empty.
6153\let\chaplevelprefix = \empty
6154%
6155\outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz
6156\def\chapterzzz#1{%
6157 % section resetting is \global in case the chapter is in a group, such
6158 % as an @include file.
6159 \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6160 \global\advance\chapno by 1
6161 %
6162 % Used for \float.
6163 \gdef\chaplevelprefix{\the\chapno.}%
6164 \resetallfloatnos
6165 %
6166 % \putwordChapter can contain complex things in translations.
6167 \toks0=\expandafter{\putwordChapter}%
6168 \message{\the\toks0 \space \the\chapno}%
6169 %
6170 % Write the actual heading.
6171 \chapmacro{#1}{Ynumbered}{\the\chapno}%
6172 %
6173 % So @section and the like are numbered underneath this chapter.
6174 \global\let\section = \numberedsec
6175 \global\let\subsection = \numberedsubsec
6176 \global\let\subsubsection = \numberedsubsubsec
6177}
6178
6179\outer\parseargdef\appendix{\apphead0{#1}} % normally calls appendixzzz
6180%
6181\def\appendixzzz#1{%
6182 \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6183 \global\advance\appendixno by 1
6184 \gdef\chaplevelprefix{\appendixletter.}%
6185 \resetallfloatnos
6186 %
6187 % \putwordAppendix can contain complex things in translations.
6188 \toks0=\expandafter{\putwordAppendix}%
6189 \message{\the\toks0 \space \appendixletter}%
6190 %
6191 \chapmacro{#1}{Yappendix}{\appendixletter}%
6192 %
6193 \global\let\section = \appendixsec
6194 \global\let\subsection = \appendixsubsec
6195 \global\let\subsubsection = \appendixsubsubsec
6196}
6197
6198% normally unnmhead0 calls unnumberedzzz:
6199\outer\parseargdef\unnumbered{\unnmhead0{#1}}
6200\def\unnumberedzzz#1{%
6201 \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6202 \global\advance\unnumberedno by 1
6203 %
6204 % Since an unnumbered has no number, no prefix for figures.
6205 \global\let\chaplevelprefix = \empty
6206 \resetallfloatnos
6207 %
6208 % This used to be simply \message{#1}, but TeX fully expands the
6209 % argument to \message. Therefore, if #1 contained @-commands, TeX
6210 % expanded them. For example, in `@unnumbered The @cite{Book}', TeX
6211 % expanded @cite (which turns out to cause errors because \cite is meant
6212 % to be executed, not expanded).
6213 %
6214 % Anyway, we don't want the fully-expanded definition of @cite to appear
6215 % as a result of the \message, we just want `@cite' itself. We use
6216 % \the<toks register> to achieve this: TeX expands \the<toks> only once,
6217 % simply yielding the contents of <toks register>. (We also do this for
6218 % the toc entries.)
6219 \toks0 = {#1}%
6220 \message{(\the\toks0)}%
6221 %
6222 \chapmacro{#1}{Ynothing}{\the\unnumberedno}%
6223 %
6224 \global\let\section = \unnumberedsec
6225 \global\let\subsection = \unnumberedsubsec
6226 \global\let\subsubsection = \unnumberedsubsubsec
6227}
6228
6229% @centerchap is like @unnumbered, but the heading is centered.
6230\outer\parseargdef\centerchap{%
6231 \let\centerparametersmaybe = \centerparameters
6232 \unnmhead0{#1}%
6233 \let\centerparametersmaybe = \relax
6234}
6235
6236% @top is like @unnumbered.
6237\let\top\unnumbered
6238
6239% Sections.
6240%
6241\outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
6242\def\seczzz#1{%
6243 \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
6244 \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}%
6245}
6246
6247% normally calls appendixsectionzzz:
6248\outer\parseargdef\appendixsection{\apphead1{#1}}
6249\def\appendixsectionzzz#1{%
6250 \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
6251 \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}%
6252}
6253\let\appendixsec\appendixsection
6254
6255% normally calls unnumberedseczzz:
6256\outer\parseargdef\unnumberedsec{\unnmhead1{#1}}
6257\def\unnumberedseczzz#1{%
6258 \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
6259 \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%
6260}
6261
6262% Subsections.
6263%
6264% normally calls numberedsubseczzz:
6265\outer\parseargdef\numberedsubsec{\numhead2{#1}}
6266\def\numberedsubseczzz#1{%
6267 \global\subsubsecno=0 \global\advance\subsecno by 1
6268 \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}%
6269}
6270
6271% normally calls appendixsubseczzz:
6272\outer\parseargdef\appendixsubsec{\apphead2{#1}}
6273\def\appendixsubseczzz#1{%
6274 \global\subsubsecno=0 \global\advance\subsecno by 1
6275 \sectionheading{#1}{subsec}{Yappendix}%
6276 {\appendixletter.\the\secno.\the\subsecno}%
6277}
6278
6279% normally calls unnumberedsubseczzz:
6280\outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}}
6281\def\unnumberedsubseczzz#1{%
6282 \global\subsubsecno=0 \global\advance\subsecno by 1
6283 \sectionheading{#1}{subsec}{Ynothing}%
6284 {\the\unnumberedno.\the\secno.\the\subsecno}%
6285}
6286
6287% Subsubsections.
6288%
6289% normally numberedsubsubseczzz:
6290\outer\parseargdef\numberedsubsubsec{\numhead3{#1}}
6291\def\numberedsubsubseczzz#1{%
6292 \global\advance\subsubsecno by 1
6293 \sectionheading{#1}{subsubsec}{Ynumbered}%
6294 {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}%
6295}
6296
6297% normally appendixsubsubseczzz:
6298\outer\parseargdef\appendixsubsubsec{\apphead3{#1}}
6299\def\appendixsubsubseczzz#1{%
6300 \global\advance\subsubsecno by 1
6301 \sectionheading{#1}{subsubsec}{Yappendix}%
6302 {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}%
6303}
6304
6305% normally unnumberedsubsubseczzz:
6306\outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}}
6307\def\unnumberedsubsubseczzz#1{%
6308 \global\advance\subsubsecno by 1
6309 \sectionheading{#1}{subsubsec}{Ynothing}%
6310 {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}%
6311}
6312
6313% These macros control what the section commands do, according
6314% to what kind of chapter we are in (ordinary, appendix, or unnumbered).
6315% Define them by default for a numbered chapter.
6316\let\section = \numberedsec
6317\let\subsection = \numberedsubsec
6318\let\subsubsection = \numberedsubsubsec
6319
6320% Define @majorheading, @heading and @subheading
6321
6322\def\majorheading{%
6323 {\advance\chapheadingskip by 10pt \chapbreak }%
6324 \parsearg\chapheadingzzz
6325}
6326
6327\def\chapheading{\chapbreak \parsearg\chapheadingzzz}
6328\def\chapheadingzzz#1{%
6329 \vbox{\chapfonts \raggedtitlesettings #1\par}%
6330 \nobreak\bigskip \nobreak
6331 \suppressfirstparagraphindent
6332}
6333
6334% @heading, @subheading, @subsubheading.
6335\parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{}
6336 \suppressfirstparagraphindent}
6337\parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{}
6338 \suppressfirstparagraphindent}
6339\parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{}
6340 \suppressfirstparagraphindent}
6341
6342% These macros generate a chapter, section, etc. heading only
6343% (including whitespace, linebreaking, etc. around it),
6344% given all the information in convenient, parsed form.
6345
6346% Args are the skip and penalty (usually negative)
6347\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
6348
6349% Parameter controlling skip before chapter headings (if needed)
6350\newskip\chapheadingskip
6351
6352% Define plain chapter starts, and page on/off switching for it.
6353\def\chapbreak{\dobreak \chapheadingskip {-4000}}
6354
6355% Start a new page
6356\def\chappager{\par\vfill\supereject}
6357
6358% \chapoddpage - start on an odd page for a new chapter
6359% Because \domark is called before \chapoddpage, the filler page will
6360% get the headings for the next chapter, which is wrong. But we don't
6361% care -- we just disable all headings on the filler page.
6362\def\chapoddpage{%
6363 \chappager
6364 \ifodd\pageno \else
6365 \begingroup
6366 \headingsoff
6367 \null
6368 \chappager
6369 \endgroup
6370 \fi
6371}
6372
6373\parseargdef\setchapternewpage{\csname CHAPPAG#1\endcsname}
6374
6375\def\CHAPPAGoff{%
6376\global\let\contentsalignmacro = \chappager
6377\global\let\pchapsepmacro=\chapbreak
6378\global\def\HEADINGSon{\HEADINGSsinglechapoff}}
6379
6380\def\CHAPPAGon{%
6381\global\let\contentsalignmacro = \chappager
6382\global\let\pchapsepmacro=\chappager
6383\global\def\HEADINGSon{\HEADINGSsingle}}
6384
6385\def\CHAPPAGodd{%
6386\global\let\contentsalignmacro = \chapoddpage
6387\global\let\pchapsepmacro=\chapoddpage
6388\global\def\HEADINGSon{\HEADINGSdouble}}
6389
6390\CHAPPAGon
6391
6392% \chapmacro - Chapter opening.
6393%
6394% #1 is the text, #2 is the section type (Ynumbered, Ynothing,
6395% Yappendix, Yomitfromtoc), #3 the chapter number.
6396% Not used for @heading series.
6397%
6398% To test against our argument.
6399\def\Ynothingkeyword{Ynothing}
6400\def\Yappendixkeyword{Yappendix}
6401\def\Yomitfromtockeyword{Yomitfromtoc}
6402%
6403\def\chapmacro#1#2#3{%
6404 \expandafter\ifx\thisenv\titlepage\else
6405 \checkenv{}% chapters, etc., should not start inside an environment.
6406 \fi
6407 % Insert the first mark before the heading break (see notes for \domark).
6408 \let\prevchapterdefs=\currentchapterdefs
6409 \let\prevsectiondefs=\currentsectiondefs
6410 \gdef\currentsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}%
6411 \gdef\thissection{}}%
6412 %
6413 \def\temptype{#2}%
6414 \ifx\temptype\Ynothingkeyword
6415 \gdef\currentchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
6416 \gdef\thischapter{\thischaptername}}%
6417 \else\ifx\temptype\Yomitfromtockeyword
6418 \gdef\currentchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
6419 \gdef\thischapter{}}%
6420 \else\ifx\temptype\Yappendixkeyword
6421 \toks0={#1}%
6422 \xdef\currentchapterdefs{%
6423 \gdef\noexpand\thischaptername{\the\toks0}%
6424 \gdef\noexpand\thischapternum{\appendixletter}%
6425 % \noexpand\putwordAppendix avoids expanding indigestible
6426 % commands in some of the translations.
6427 \gdef\noexpand\thischapter{\noexpand\putwordAppendix{}
6428 \noexpand\thischapternum:
6429 \noexpand\thischaptername}%
6430 }%
6431 \else
6432 \toks0={#1}%
6433 \xdef\currentchapterdefs{%
6434 \gdef\noexpand\thischaptername{\the\toks0}%
6435 \gdef\noexpand\thischapternum{\the\chapno}%
6436 % \noexpand\putwordChapter avoids expanding indigestible
6437 % commands in some of the translations.
6438 \gdef\noexpand\thischapter{\noexpand\putwordChapter{}
6439 \noexpand\thischapternum:
6440 \noexpand\thischaptername}%
6441 }%
6442 \fi\fi\fi
6443 %
6444 % Output the mark. Pass it through \safewhatsit, to take care of
6445 % the preceding space.
6446 \safewhatsit\domark
6447 %
6448 % Insert the chapter heading break.
6449 \pchapsepmacro
6450 %
6451 % Now the second mark, after the heading break. No break points
6452 % between here and the heading.
6453 \let\prevchapterdefs=\currentchapterdefs
6454 \let\prevsectiondefs=\currentsectiondefs
6455 \domark
6456 %
6457 {%
6458 \chapfonts \rm
6459 \let\footnote=\errfootnoteheading % give better error message
6460 %
6461 % Have to define \currentsection before calling \donoderef, because the
6462 % xref code eventually uses it. On the other hand, it has to be called
6463 % after \pchapsepmacro, or the headline will change too soon.
6464 \gdef\currentsection{#1}%
6465 %
6466 % Only insert the separating space if we have a chapter/appendix
6467 % number, and don't print the unnumbered ``number''.
6468 \ifx\temptype\Ynothingkeyword
6469 \setbox0 = \hbox{}%
6470 \def\toctype{unnchap}%
6471 \else\ifx\temptype\Yomitfromtockeyword
6472 \setbox0 = \hbox{}% contents like unnumbered, but no toc entry
6473 \def\toctype{omit}%
6474 \else\ifx\temptype\Yappendixkeyword
6475 \setbox0 = \hbox{\putwordAppendix{} #3\enspace}%
6476 \def\toctype{app}%
6477 \else
6478 \setbox0 = \hbox{#3\enspace}%
6479 \def\toctype{numchap}%
6480 \fi\fi\fi
6481 %
6482 % Write the toc entry for this chapter. Must come before the
6483 % \donoderef, because we include the current node name in the toc
6484 % entry, and \donoderef resets it to empty.
6485 \writetocentry{\toctype}{#1}{#3}%
6486 %
6487 % For pdftex, we have to write out the node definition (aka, make
6488 % the pdfdest) after any page break, but before the actual text has
6489 % been typeset. If the destination for the pdf outline is after the
6490 % text, then jumping from the outline may wind up with the text not
6491 % being visible, for instance under high magnification.
6492 \donoderef{#2}%
6493 %
6494 % Typeset the actual heading.
6495 \nobreak % Avoid page breaks at the interline glue.
6496 \vbox{\raggedtitlesettings \hangindent=\wd0 \centerparametersmaybe
6497 \unhbox0 #1\par}%
6498 }%
6499 \nobreak\bigskip % no page break after a chapter title
6500 \nobreak
6501}
6502
6503% @centerchap -- centered and unnumbered.
6504\let\centerparametersmaybe = \relax
6505\def\centerparameters{%
6506 \advance\rightskip by 3\rightskip
6507 \leftskip = \rightskip
6508 \parfillskip = 0pt
6509}
6510
6511
6512% Section titles. These macros combine the section number parts and
6513% call the generic \sectionheading to do the printing.
6514%
6515\newskip\secheadingskip
6516\def\secheadingbreak{\dobreak \secheadingskip{-1000}}
6517
6518% Subsection titles.
6519\newskip\subsecheadingskip
6520\def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}}
6521
6522% Subsubsection titles.
6523\def\subsubsecheadingskip{\subsecheadingskip}
6524\def\subsubsecheadingbreak{\subsecheadingbreak}
6525
6526
6527% Print any size, any type, section title.
6528%
6529% #1 is the text of the title,
6530% #2 is the section level (sec/subsec/subsubsec),
6531% #3 is the section type (Ynumbered, Ynothing, Yappendix, Yomitfromtoc),
6532% #4 is the section number.
6533%
6534\def\seckeyword{sec}
6535%
6536\def\sectionheading#1#2#3#4{%
6537 {%
6538 \def\sectionlevel{#2}%
6539 \def\temptype{#3}%
6540 %
6541 % It is ok for the @heading series commands to appear inside an
6542 % environment (it's been historically allowed, though the logic is
6543 % dubious), but not the others.
6544 \ifx\temptype\Yomitfromtockeyword\else
6545 \checkenv{}% non-@*heading should not be in an environment.
6546 \fi
6547 \let\footnote=\errfootnoteheading
6548 %
6549 % Switch to the right set of fonts.
6550 \csname #2fonts\endcsname \rm
6551 %
6552 % Insert first mark before the heading break (see notes for \domark).
6553 \let\prevsectiondefs=\currentsectiondefs
6554 \ifx\temptype\Ynothingkeyword
6555 \ifx\sectionlevel\seckeyword
6556 \gdef\currentsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}%
6557 \gdef\thissection{\thissectionname}}%
6558 \fi
6559 \else\ifx\temptype\Yomitfromtockeyword
6560 % Don't redefine \thissection.
6561 \else\ifx\temptype\Yappendixkeyword
6562 \ifx\sectionlevel\seckeyword
6563 \toks0={#1}%
6564 \xdef\currentsectiondefs{%
6565 \gdef\noexpand\thissectionname{\the\toks0}%
6566 \gdef\noexpand\thissectionnum{#4}%
6567 % \noexpand\putwordSection avoids expanding indigestible
6568 % commands in some of the translations.
6569 \gdef\noexpand\thissection{\noexpand\putwordSection{}
6570 \noexpand\thissectionnum:
6571 \noexpand\thissectionname}%
6572 }%
6573 \fi
6574 \else
6575 \ifx\sectionlevel\seckeyword
6576 \toks0={#1}%
6577 \xdef\currentsectiondefs{%
6578 \gdef\noexpand\thissectionname{\the\toks0}%
6579 \gdef\noexpand\thissectionnum{#4}%
6580 % \noexpand\putwordSection avoids expanding indigestible
6581 % commands in some of the translations.
6582 \gdef\noexpand\thissection{\noexpand\putwordSection{}
6583 \noexpand\thissectionnum:
6584 \noexpand\thissectionname}%
6585 }%
6586 \fi
6587 \fi\fi\fi
6588 %
6589 % Go into vertical mode. Usually we'll already be there, but we
6590 % don't want the following whatsit to end up in a preceding paragraph
6591 % if the document didn't happen to have a blank line.
6592 \par
6593 %
6594 % Output the mark. Pass it through \safewhatsit, to take care of
6595 % the preceding space.
6596 \safewhatsit\domark
6597 %
6598 % Insert space above the heading.
6599 \csname #2headingbreak\endcsname
6600 %
6601 % Now the second mark, after the heading break. No break points
6602 % between here and the heading.
6603 \global\let\prevsectiondefs=\currentsectiondefs
6604 \domark
6605 %
6606 % Only insert the space after the number if we have a section number.
6607 \ifx\temptype\Ynothingkeyword
6608 \setbox0 = \hbox{}%
6609 \def\toctype{unn}%
6610 \gdef\currentsection{#1}%
6611 \else\ifx\temptype\Yomitfromtockeyword
6612 % for @headings -- no section number, don't include in toc,
6613 % and don't redefine \currentsection.
6614 \setbox0 = \hbox{}%
6615 \def\toctype{omit}%
6616 \let\sectionlevel=\empty
6617 \else\ifx\temptype\Yappendixkeyword
6618 \setbox0 = \hbox{#4\enspace}%
6619 \def\toctype{app}%
6620 \gdef\currentsection{#1}%
6621 \else
6622 \setbox0 = \hbox{#4\enspace}%
6623 \def\toctype{num}%
6624 \gdef\currentsection{#1}%
6625 \fi\fi\fi
6626 %
6627 % Write the toc entry (before \donoderef). See comments in \chapmacro.
6628 \writetocentry{\toctype\sectionlevel}{#1}{#4}%
6629 %
6630 % Write the node reference (= pdf destination for pdftex).
6631 % Again, see comments in \chapmacro.
6632 \donoderef{#3}%
6633 %
6634 % Interline glue will be inserted when the vbox is completed.
6635 % That glue will be a valid breakpoint for the page, since it'll be
6636 % preceded by a whatsit (usually from the \donoderef, or from the
6637 % \writetocentry if there was no node). We don't want to allow that
6638 % break, since then the whatsits could end up on page n while the
6639 % section is on page n+1, thus toc/etc. are wrong. Debian bug 276000.
6640 \nobreak
6641 %
6642 % Output the actual section heading.
6643 \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright
6644 \hangindent=\wd0 % zero if no section number
6645 \unhbox0 #1}%
6646 }%
6647 % Add extra space after the heading -- half of whatever came above it.
6648 % Don't allow stretch, though.
6649 \kern .5 \csname #2headingskip\endcsname
6650 %
6651 % Do not let the kern be a potential breakpoint, as it would be if it
6652 % was followed by glue.
6653 \nobreak
6654 %
6655 % We'll almost certainly start a paragraph next, so don't let that
6656 % glue accumulate. (Not a breakpoint because it's preceded by a
6657 % discardable item.) However, when a paragraph is not started next
6658 % (\startdefun, \cartouche, \center, etc.), this needs to be wiped out
6659 % or the negative glue will cause weirdly wrong output, typically
6660 % obscuring the section heading with something else.
6661 \vskip-\parskip
6662 %
6663 % This is so the last item on the main vertical list is a known
6664 % \penalty > 10000, so \startdefun, etc., can recognize the situation
6665 % and do the needful.
6666 \penalty 10001
6667}
6668
6669
6670\message{toc,}
6671% Table of contents.
6672\newwrite\tocfile
6673
6674% Write an entry to the toc file, opening it if necessary.
6675% Called from @chapter, etc.
6676%
6677% Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno}
6678% We append the current node name (if any) and page number as additional
6679% arguments for the \{chap,sec,...}entry macros which will eventually
6680% read this. The node name is used in the pdf outlines as the
6681% destination to jump to.
6682%
6683% We open the .toc file for writing here instead of at @setfilename (or
6684% any other fixed time) so that @contents can be anywhere in the document.
6685% But if #1 is `omit', then we don't do anything. This is used for the
6686% table of contents chapter openings themselves.
6687%
6688\newif\iftocfileopened
6689\def\omitkeyword{omit}%
6690%
6691\def\writetocentry#1#2#3{%
6692 \edef\writetoctype{#1}%
6693 \ifx\writetoctype\omitkeyword \else
6694 \iftocfileopened\else
6695 \immediate\openout\tocfile = \jobname.toc
6696 \global\tocfileopenedtrue
6697 \fi
6698 %
6699 \iflinks
6700 {\atdummies
6701 \edef\temp{%
6702 \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}%
6703 \temp
6704 }%
6705 \fi
6706 \fi
6707 %
6708 % Tell \shipout to create a pdf destination on each page, if we're
6709 % writing pdf. These are used in the table of contents. We can't
6710 % just write one on every page because the title pages are numbered
6711 % 1 and 2 (the page numbers aren't printed), and so are the first
6712 % two pages of the document. Thus, we'd have two destinations named
6713 % `1', and two named `2'.
6714 \ifpdforxetex
6715 \global\pdfmakepagedesttrue
6716 \fi
6717}
6718
6719
6720% These characters do not print properly in the Computer Modern roman
6721% fonts, so we must take special care. This is more or less redundant
6722% with the Texinfo input format setup at the end of this file.
6723%
6724\def\activecatcodes{%
6725 \catcode`\"=\active
6726 \catcode`\$=\active
6727 \catcode`\<=\active
6728 \catcode`\>=\active
6729 \catcode`\\=\active
6730 \catcode`\^=\active
6731 \catcode`\_=\active
6732 \catcode`\|=\active
6733 \catcode`\~=\active
6734}
6735
6736
6737% Read the toc file, which is essentially Texinfo input.
6738\def\readtocfile{%
6739 \setupdatafile
6740 \activecatcodes
6741 \input \tocreadfilename
6742}
6743
6744\newskip\contentsrightmargin \contentsrightmargin=1in
6745\newcount\savepageno
6746\newcount\lastnegativepageno \lastnegativepageno = -1
6747
6748% Prepare to read what we've written to \tocfile.
6749%
6750\def\startcontents#1{%
6751 % If @setchapternewpage on, and @headings double, the contents should
6752 % start on an odd page, unlike chapters.
6753 \contentsalignmacro
6754 \immediate\closeout\tocfile
6755 %
6756 % Don't need to put `Contents' or `Short Contents' in the headline.
6757 % It is abundantly clear what they are.
6758 \chapmacro{#1}{Yomitfromtoc}{}%
6759 %
6760 \savepageno = \pageno
6761 \begingroup % Set up to handle contents files properly.
6762 \raggedbottom % Worry more about breakpoints than the bottom.
6763 \entryrightmargin=\contentsrightmargin % Don't use the full line length.
6764 %
6765 % Roman numerals for page numbers.
6766 \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
6767 \def\thistitle{}% no title in double-sided headings
6768 % Record where the Roman numerals started.
6769 \ifnum\romancount=0 \global\romancount=\pagecount \fi
6770}
6771
6772% \raggedbottom in plain.tex hardcodes \topskip so override it
6773\catcode`\@=11
6774\def\raggedbottom{\advance\topskip by 0pt plus60pt \r@ggedbottomtrue}
6775\catcode`\@=\other
6776
6777% redefined for the two-volume lispref. We always output on
6778% \jobname.toc even if this is redefined.
6779%
6780\def\tocreadfilename{\jobname.toc}
6781
6782% Normal (long) toc.
6783%
6784\def\contents{%
6785 \startcontents{\putwordTOC}%
6786 \openin 1 \tocreadfilename\space
6787 \ifeof 1 \else
6788 \readtocfile
6789 \fi
6790 \vfill \eject
6791 \contentsalignmacro % in case @setchapternewpage odd is in effect
6792 \ifeof 1 \else
6793 \pdfmakeoutlines
6794 \fi
6795 \closein 1
6796 \endgroup
6797 \contentsendroman
6798}
6799
6800% And just the chapters.
6801\def\summarycontents{%
6802 \startcontents{\putwordShortTOC}%
6803 %
6804 \let\partentry = \shortpartentry
6805 \let\numchapentry = \shortchapentry
6806 \let\appentry = \shortchapentry
6807 \let\unnchapentry = \shortunnchapentry
6808 % We want a true roman here for the page numbers.
6809 \secfonts
6810 \let\rm=\shortcontrm \let\bf=\shortcontbf
6811 \let\sl=\shortcontsl \let\tt=\shortconttt
6812 \rm
6813 \hyphenpenalty = 10000
6814 \advance\baselineskip by 1pt % Open it up a little.
6815 \def\numsecentry##1##2##3##4{}
6816 \let\appsecentry = \numsecentry
6817 \let\unnsecentry = \numsecentry
6818 \let\numsubsecentry = \numsecentry
6819 \let\appsubsecentry = \numsecentry
6820 \let\unnsubsecentry = \numsecentry
6821 \let\numsubsubsecentry = \numsecentry
6822 \let\appsubsubsecentry = \numsecentry
6823 \let\unnsubsubsecentry = \numsecentry
6824 \openin 1 \tocreadfilename\space
6825 \ifeof 1 \else
6826 \readtocfile
6827 \fi
6828 \closein 1
6829 \vfill \eject
6830 \contentsalignmacro % in case @setchapternewpage odd is in effect
6831 \endgroup
6832 \contentsendroman
6833}
6834\let\shortcontents = \summarycontents
6835
6836% Get ready to use Arabic numerals again
6837\def\contentsendroman{%
6838 \lastnegativepageno = \pageno
6839 \global\pageno = \savepageno
6840 %
6841 % If \romancount > \arabiccount, the contents are at the end of the
6842 % document. Otherwise, advance where the Arabic numerals start for
6843 % the page numbers.
6844 \ifnum\romancount>\arabiccount\else\global\arabiccount=\pagecount\fi
6845}
6846
6847% Typeset the label for a chapter or appendix for the short contents.
6848% The arg is, e.g., `A' for an appendix, or `3' for a chapter.
6849%
6850\def\shortchaplabel#1{%
6851 % This space should be enough, since a single number is .5em, and the
6852 % widest letter (M) is 1em, at least in the Computer Modern fonts.
6853 % But use \hss just in case.
6854 % (This space doesn't include the extra space that gets added after
6855 % the label; that gets put in by \shortchapentry above.)
6856 %
6857 % We'd like to right-justify chapter numbers, but that looks strange
6858 % with appendix letters. And right-justifying numbers and
6859 % left-justifying letters looks strange when there is less than 10
6860 % chapters. Have to read the whole toc once to know how many chapters
6861 % there are before deciding ...
6862 \hbox to 1em{#1\hss}%
6863}
6864
6865% These macros generate individual entries in the table of contents.
6866% The first argument is the chapter or section name.
6867% The last argument is the page number.
6868% The arguments in between are the chapter number, section number, ...
6869
6870% Parts, in the main contents. Replace the part number, which doesn't
6871% exist, with an empty box. Let's hope all the numbers have the same width.
6872% Also ignore the page number, which is conventionally not printed.
6873\def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}}
6874\def\partentry#1#2#3#4{%
6875 % Add stretch and a bonus for breaking the page before the part heading.
6876 % This reduces the chance of the page being broken immediately after the
6877 % part heading, before a following chapter heading.
6878 \vskip 0pt plus 5\baselineskip
6879 \penalty-300
6880 \vskip 0pt plus -5\baselineskip
6881 \dochapentry{\numeralbox\labelspace#1}{}%
6882}
6883%
6884% Parts, in the short toc.
6885\def\shortpartentry#1#2#3#4{%
6886 \penalty-300
6887 \vskip.5\baselineskip plus.15\baselineskip minus.1\baselineskip
6888 \shortchapentry{{\bf #1}}{\numeralbox}{}{}%
6889}
6890
6891% Chapters, in the main contents.
6892\def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}}
6893
6894% Chapters, in the short toc.
6895% See comments in \dochapentry re vbox and related settings.
6896\def\shortchapentry#1#2#3#4{%
6897 \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}%
6898}
6899
6900% Appendices, in the main contents.
6901% Need the word Appendix, and a fixed-size box.
6902%
6903\def\appendixbox#1{%
6904 % We use M since it's probably the widest letter.
6905 \setbox0 = \hbox{\putwordAppendix{} M}%
6906 \hbox to \wd0{\putwordAppendix{} #1\hss}}
6907%
6908\def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\hskip.7em#1}{#4}}
6909
6910% Unnumbered chapters.
6911\def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}}
6912\def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}}
6913
6914% Sections.
6915\def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}}
6916\let\appsecentry=\numsecentry
6917\def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}}
6918
6919% Subsections.
6920\def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}}
6921\let\appsubsecentry=\numsubsecentry
6922\def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}}
6923
6924% And subsubsections.
6925\def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}}
6926\let\appsubsubsecentry=\numsubsubsecentry
6927\def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}}
6928
6929% This parameter controls the indentation of the various levels.
6930% Same as \defaultparindent.
6931\newdimen\tocindent \tocindent = 15pt
6932
6933% Now for the actual typesetting. In all these, #1 is the text and #2 is the
6934% page number.
6935%
6936% If the toc has to be broken over pages, we want it to be at chapters
6937% if at all possible; hence the \penalty.
6938\def\dochapentry#1#2{%
6939 \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
6940 \begingroup
6941 % Move the page numbers slightly to the right
6942 \advance\entryrightmargin by -0.05em
6943 \chapentryfonts
6944 \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6945 \endgroup
6946 \nobreak\vskip .25\baselineskip plus.1\baselineskip
6947}
6948
6949\def\dosecentry#1#2{\begingroup
6950 \secentryfonts \leftskip=\tocindent
6951 \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6952\endgroup}
6953
6954\def\dosubsecentry#1#2{\begingroup
6955 \subsecentryfonts \leftskip=2\tocindent
6956 \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6957\endgroup}
6958
6959\def\dosubsubsecentry#1#2{\begingroup
6960 \subsubsecentryfonts \leftskip=3\tocindent
6961 \tocentry{#1}{\dopageno\bgroup#2\egroup}%
6962\endgroup}
6963
6964% We use the same \entry macro as for the index entries.
6965\let\tocentry = \entry
6966
6967% Space between chapter (or whatever) number and the title.
6968\def\labelspace{\hskip1em \relax}
6969
6970\def\dopageno#1{{\rm #1}}
6971\def\doshortpageno#1{{\rm #1}}
6972
6973\def\chapentryfonts{\secfonts \rm}
6974\def\secentryfonts{\textfonts}
6975\def\subsecentryfonts{\textfonts}
6976\def\subsubsecentryfonts{\textfonts}
6977
6978
6979\message{environments,}
6980% @foo ... @end foo.
6981
6982% @tex ... @end tex escapes into raw TeX temporarily.
6983% One exception: @ is still an escape character, so that @end tex works.
6984% But \@ or @@ will get a plain @ character.
6985
6986\envdef\tex{%
6987 \setregularquotes
6988 \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
6989 \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
6990 \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
6991 \catcode `\%=14
6992 \catcode `\+=\other
6993 \catcode `\"=\other
6994 \catcode `\|=\other
6995 \catcode `\<=\other
6996 \catcode `\>=\other
6997 \catcode `\`=\other
6998 \catcode `\'=\other
6999 %
7000 % ' is active in math mode (mathcode"8000). So reset it, and all our
7001 % other math active characters (just in case), to plain's definitions.
7002 \mathactive
7003 %
7004 % Inverse of the list at the beginning of the file.
7005 \let\b=\ptexb
7006 \let\bullet=\ptexbullet
7007 \let\c=\ptexc
7008 \let\,=\ptexcomma
7009 \let\.=\ptexdot
7010 \let\dots=\ptexdots
7011 \let\equiv=\ptexequiv
7012 \let\!=\ptexexclam
7013 \let\i=\ptexi
7014 \let\indent=\ptexindent
7015 \let\noindent=\ptexnoindent
7016 \let\{=\ptexlbrace
7017 \let\+=\tabalign
7018 \let\}=\ptexrbrace
7019 \let\/=\ptexslash
7020 \let\sp=\ptexsp
7021 \let\*=\ptexstar
7022 %\let\sup=\ptexsup % do not redefine, we want @sup to work in math mode
7023 \let\t=\ptext
7024 \expandafter \let\csname top\endcsname=\ptextop % we've made it outer
7025 \let\frenchspacing=\plainfrenchspacing
7026 %
7027 \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
7028 \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
7029 \def\@{@}%
7030}
7031% There is no need to define \Etex.
7032
7033% Define @lisp ... @end lisp.
7034% @lisp environment forms a group so it can rebind things,
7035% including the definition of @end lisp (which normally is erroneous).
7036
7037% Amount to narrow the margins by for @lisp.
7038\newskip\lispnarrowing \lispnarrowing=0.4in
7039
7040% This is the definition that ^^M gets inside @lisp, @example, and other
7041% such environments. \null is better than a space, since it doesn't
7042% have any width.
7043\def\lisppar{\null\endgraf}
7044
7045% This space is always present above and below environments.
7046\newskip\envskipamount \envskipamount = 0pt
7047
7048% Make spacing and below environment symmetrical. We use \parskip here
7049% to help in doing that, since in @example-like environments \parskip
7050% is reset to zero; thus the \afterenvbreak inserts no space -- but the
7051% start of the next paragraph will insert \parskip.
7052%
7053\def\aboveenvbreak{{%
7054 % =10000 instead of <10000 because of a special case in \itemzzz and
7055 % \sectionheading, q.v.
7056 \ifnum \lastpenalty=10000 \else
7057 \advance\envskipamount by \parskip
7058 \endgraf
7059 \ifdim\lastskip<\envskipamount
7060 \removelastskip
7061 \ifnum\lastpenalty<10000
7062 % Penalize breaking before the environment, because preceding text
7063 % often leads into it.
7064 \penalty100
7065 \fi
7066 \vskip\envskipamount
7067 \fi
7068 \fi
7069}}
7070
7071\def\afterenvbreak{{%
7072 % =10000 instead of <10000 because of a special case in \itemzzz and
7073 % \sectionheading, q.v.
7074 \ifnum \lastpenalty=10000 \else
7075 \advance\envskipamount by \parskip
7076 \endgraf
7077 \ifdim\lastskip<\envskipamount
7078 \removelastskip
7079 % it's not a good place to break if the last penalty was \nobreak
7080 % or better ...
7081 \ifnum\lastpenalty<10000 \penalty-50 \fi
7082 \vskip\envskipamount
7083 \fi
7084 \fi
7085}}
7086
7087% \nonarrowing is a flag. If "set", @lisp etc don't narrow margins; it will
7088% also clear it, so that its embedded environments do the narrowing again.
7089\let\nonarrowing=\relax
7090
7091% @cartouche ... @end cartouche: draw rectangle w/rounded corners around
7092% environment contents.
7093
7094%
7095\def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
7096\def\ctr{{\hskip 6pt\circle\char'010}}
7097\def\cbl{{\circle\char'012\hskip -6pt}}
7098\def\cbr{{\hskip 6pt\circle\char'011}}
7099\def\carttop{\hbox to \cartouter{\hskip\lskip
7100 \ctl\leaders\hrule height\circthick\hfil\ctr
7101 \hskip\rskip}}
7102\def\cartbot{\hbox to \cartouter{\hskip\lskip
7103 \cbl\leaders\hrule height\circthick\hfil\cbr
7104 \hskip\rskip}}
7105%
7106\newskip\lskip\newskip\rskip
7107
7108% only require the font if @cartouche is actually used
7109\def\cartouchefontdefs{%
7110 \font\circle=lcircle10\relax
7111 \circthick=\fontdimen8\circle
7112}
7113\newdimen\circthick
7114\newdimen\cartouter\newdimen\cartinner
7115\newskip\normbskip\newskip\normpskip\newskip\normlskip
7116
7117
7118\envdef\cartouche{%
7119 \cartouchefontdefs
7120 \ifhmode\par\fi % can't be in the midst of a paragraph.
7121 \startsavinginserts
7122 \lskip=\leftskip \rskip=\rightskip
7123 \leftskip=0pt\rightskip=0pt % we want these *outside*.
7124 \cartinner=\hsize \advance\cartinner by-\lskip
7125 \advance\cartinner by-\rskip
7126 \cartouter=\hsize
7127 \advance\cartouter by 18.4pt % allow for 3pt kerns on either
7128 % side, and for 6pt waste from
7129 % each corner char, and rule thickness
7130 \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
7131 %
7132 % If this cartouche directly follows a sectioning command, we need the
7133 % \parskip glue (backspaced over by default) or the cartouche can
7134 % collide with the section heading.
7135 \ifnum\lastpenalty>10000 \vskip\parskip \penalty\lastpenalty \fi
7136 %
7137 \setbox\groupbox=\vtop\bgroup
7138 \baselineskip=0pt\parskip=0pt\lineskip=0pt
7139 \carttop
7140 \hbox\bgroup
7141 \hskip\lskip
7142 \vrule\kern3pt
7143 \vbox\bgroup
7144 \kern3pt
7145 \hsize=\cartinner
7146 \baselineskip=\normbskip
7147 \lineskip=\normlskip
7148 \parskip=\normpskip
7149 \vskip -\parskip
7150 \comment % For explanation, see the end of def\group.
7151}
7152\def\Ecartouche{%
7153 \ifhmode\par\fi
7154 \kern3pt
7155 \egroup
7156 \kern3pt\vrule
7157 \hskip\rskip
7158 \egroup
7159 \cartbot
7160 \egroup
7161 \addgroupbox
7162 \checkinserts
7163}
7164
7165
7166% This macro is called at the beginning of all the @example variants,
7167% inside a group.
7168\newdimen\nonfillparindent
7169\def\nonfillstart{%
7170 \aboveenvbreak
7171 \ifdim\hfuzz < 12pt \hfuzz = 12pt \fi % Don't be fussy
7172 \sepspaces % Make spaces be word-separators rather than space tokens.
7173 \let\par = \lisppar % don't ignore blank lines
7174 \obeylines % each line of input is a line of output
7175 \parskip = 0pt
7176 % Turn off paragraph indentation but redefine \indent to emulate
7177 % the normal \indent.
7178 \nonfillparindent=\parindent
7179 \parindent = 0pt
7180 \let\indent\nonfillindent
7181 %
7182 \emergencystretch = 0pt % don't try to avoid overfull boxes
7183 \ifx\nonarrowing\relax
7184 \advance \leftskip by \lispnarrowing
7185 \exdentamount=\lispnarrowing
7186 \else
7187 \let\nonarrowing = \relax
7188 \fi
7189 \let\exdent=\nofillexdent
7190}
7191
7192\begingroup
7193\obeyspaces
7194% We want to swallow spaces (but not other tokens) after the fake
7195% @indent in our nonfill-environments, where spaces are normally
7196% active and set to @tie, resulting in them not being ignored after
7197% @indent.
7198\gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}%
7199\gdef\nonfillindentcheck{%
7200\ifx\temp %
7201\expandafter\nonfillindentgobble%
7202\else%
7203\leavevmode\nonfillindentbox%
7204\fi%
7205}%
7206\endgroup
7207\def\nonfillindentgobble#1{\nonfillindent}
7208\def\nonfillindentbox{\hbox to \nonfillparindent{\hss}}
7209
7210% If you want all examples etc. small: @set dispenvsize small.
7211% If you want even small examples the full size: @set dispenvsize nosmall.
7212% This affects the following displayed environments:
7213% @example, @display, @format, @lisp, @verbatim
7214%
7215\def\smallword{small}
7216\def\nosmallword{nosmall}
7217\let\SETdispenvsize\relax
7218\def\setnormaldispenv{%
7219 \ifx\SETdispenvsize\smallword
7220 % end paragraph for sake of leading, in case document has no blank
7221 % line. This is redundant with what happens in \aboveenvbreak, but
7222 % we need to do it before changing the fonts, and it's inconvenient
7223 % to change the fonts afterward.
7224 \ifnum \lastpenalty=10000 \else \endgraf \fi
7225 \smallexamplefonts \rm
7226 \fi
7227}
7228\def\setsmalldispenv{%
7229 \ifx\SETdispenvsize\nosmallword
7230 \else
7231 \ifnum \lastpenalty=10000 \else \endgraf \fi
7232 \smallexamplefonts \rm
7233 \fi
7234}
7235
7236% We often define two environments, @foo and @smallfoo.
7237% Let's do it in one command. #1 is the env name, #2 the definition.
7238\def\makedispenvdef#1#2{%
7239 \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}%
7240 \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}%
7241 \expandafter\let\csname E#1\endcsname \afterenvbreak
7242 \expandafter\let\csname Esmall#1\endcsname \afterenvbreak
7243}
7244
7245% Define two environment synonyms (#1 and #2) for an environment.
7246\def\maketwodispenvdef#1#2#3{%
7247 \makedispenvdef{#1}{#3}%
7248 \makedispenvdef{#2}{#3}%
7249}
7250%
7251% @lisp: indented, narrowed, typewriter font;
7252% @example: same as @lisp.
7253%
7254% @smallexample and @smalllisp: use smaller fonts.
7255% Originally contributed by Pavel@xerox.
7256%
7257\maketwodispenvdef{lisp}{example}{%
7258 \nonfillstart
7259 \tt\setcodequotes
7260 \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
7261 \parsearg\gobble
7262}
7263% @display/@smalldisplay: same as @lisp except keep current font.
7264%
7265\makedispenvdef{display}{%
7266 \nonfillstart
7267 \gobble
7268}
7269
7270% @format/@smallformat: same as @display except don't narrow margins.
7271%
7272\makedispenvdef{format}{%
7273 \let\nonarrowing = t%
7274 \nonfillstart
7275 \gobble
7276}
7277
7278% @flushleft: same as @format, but doesn't obey \SETdispenvsize.
7279\envdef\flushleft{%
7280 \let\nonarrowing = t%
7281 \nonfillstart
7282 \gobble
7283}
7284\let\Eflushleft = \afterenvbreak
7285
7286% @flushright.
7287%
7288\envdef\flushright{%
7289 \let\nonarrowing = t%
7290 \nonfillstart
7291 \advance\leftskip by 0pt plus 1fill\relax
7292 \gobble
7293}
7294\let\Eflushright = \afterenvbreak
7295
7296
7297% @raggedright does more-or-less normal line breaking but no right
7298% justification. From plain.tex.
7299\envdef\raggedright{%
7300 \rightskip0pt plus2.4em \spaceskip.3333em \xspaceskip.5em\relax
7301}
7302\let\Eraggedright\par
7303
7304
7305% @quotation does normal linebreaking (hence we can't use \nonfillstart)
7306% and narrows the margins. We keep \parskip nonzero in general, since
7307% we're doing normal filling. So, when using \aboveenvbreak and
7308% \afterenvbreak, temporarily make \parskip 0.
7309%
7310\makedispenvdef{quotation}{\quotationstart}
7311%
7312\def\quotationstart{%
7313 \indentedblockstart % same as \indentedblock, but increase right margin too.
7314 \ifx\nonarrowing\relax
7315 \advance\rightskip by \lispnarrowing
7316 \fi
7317 \parsearg\quotationlabel
7318}
7319
7320% We have retained a nonzero parskip for the environment, since we're
7321% doing normal filling.
7322%
7323\def\Equotation{%
7324 \par
7325 \ifx\quotationauthor\thisisundefined\else
7326 % indent a bit.
7327 \leftline{\kern 2\leftskip \sl ---\quotationauthor}%
7328 \fi
7329 {\parskip=0pt \afterenvbreak}%
7330}
7331\def\Esmallquotation{\Equotation}
7332
7333% If we're given an argument, typeset it in bold with a colon after.
7334\def\quotationlabel#1{%
7335 \def\temp{#1}%
7336 \ifx\temp\empty \else
7337 {\bf #1: }%
7338 \fi
7339}
7340
7341% @indentedblock is like @quotation, but indents only on the left and
7342% has no optional argument.
7343%
7344\makedispenvdef{indentedblock}{\indentedblockstart}
7345%
7346\def\indentedblockstart{%
7347 {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
7348 \parindent=0pt
7349 %
7350 % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
7351 \ifx\nonarrowing\relax
7352 \advance\leftskip by \lispnarrowing
7353 \exdentamount = \lispnarrowing
7354 \else
7355 \let\nonarrowing = \relax
7356 \fi
7357}
7358
7359% Keep a nonzero parskip for the environment, since we're doing normal filling.
7360%
7361\def\Eindentedblock{%
7362 \par
7363 {\parskip=0pt \afterenvbreak}%
7364}
7365\def\Esmallindentedblock{\Eindentedblock}
7366
7367
7368% LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>}
7369% If we want to allow any <char> as delimiter,
7370% we need the curly braces so that makeinfo sees the @verb command, eg:
7371% `@verbx...x' would look like the '@verbx' command. [email protected]
7372%
7373% [Knuth]: Donald Ervin Knuth, 1996. The TeXbook.
7374%
7375% [Knuth] p.344; only we need to do the other characters Texinfo sets
7376% active too. Otherwise, they get lost as the first character on a
7377% verbatim line.
7378\def\dospecials{%
7379 \do\ \do\\\do\{\do\}\do\$\do\&%
7380 \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~%
7381 \do\<\do\>\do\|\do\@\do+\do\"%
7382 % Don't do the quotes -- if we do, @set txicodequoteundirected and
7383 % @set txicodequotebacktick will not have effect on @verb and
7384 % @verbatim, and ?` and !` ligatures won't get disabled.
7385 %\do\`\do\'%
7386}
7387%
7388% [Knuth] p. 380
7389\def\uncatcodespecials{%
7390 \def\do##1{\catcode`##1=\other}\dospecials}
7391%
7392% Setup for the @verb command.
7393%
7394% Eight spaces for a tab
7395\begingroup
7396 \catcode`\^^I=\active
7397 \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }}
7398\endgroup
7399%
7400\def\setupverb{%
7401 \tt % easiest (and conventionally used) font for verbatim
7402 \def\par{\leavevmode\endgraf}%
7403 \setcodequotes
7404 \tabeightspaces
7405 % Respect line breaks,
7406 % print special symbols as themselves, and
7407 % make each space count
7408 % must do in this order:
7409 \obeylines \uncatcodespecials \sepspaces
7410}
7411
7412% Setup for the @verbatim environment
7413%
7414% Real tab expansion.
7415\newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
7416%
7417% We typeset each line of the verbatim in an \hbox, so we can handle
7418% tabs.
7419\newbox\verbbox
7420\def\starttabbox{\setbox\verbbox=\hbox\bgroup}
7421%
7422\begingroup
7423 \catcode`\^^I=\active
7424 \gdef\tabexpand{%
7425 \catcode`\^^I=\active
7426 \def^^I{\leavevmode\egroup
7427 \dimen\verbbox=\wd\verbbox % the width so far, or since the previous tab
7428 \divide\dimen\verbbox by\tabw
7429 \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw
7430 \advance\dimen\verbbox by\tabw % advance to next multiple of \tabw
7431 \wd\verbbox=\dimen\verbbox
7432 \leavevmode\box\verbbox \starttabbox
7433 }%
7434 }
7435\endgroup
7436
7437% start the verbatim environment.
7438\def\setupverbatim{%
7439 \let\nonarrowing = t%
7440 \nonfillstart
7441 \tt % easiest (and conventionally used) font for verbatim
7442 \def\par{\egroup\leavevmode\box\verbbox\endgraf\starttabbox}%
7443 \tabexpand
7444 \setcodequotes
7445 % Respect line breaks,
7446 % print special symbols as themselves, and
7447 % make each space count.
7448 % Must do in this order:
7449 \obeylines \uncatcodespecials \sepspaces
7450}
7451
7452% Do the @verb magic: verbatim text is quoted by unique
7453% delimiter characters. Before first delimiter expect a
7454% right brace, after last delimiter expect closing brace:
7455%
7456% \def\doverb'{'<char>#1<char>'}'{#1}
7457%
7458% [Knuth] p. 382; only eat outer {}
7459\begingroup
7460 \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other
7461 \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next]
7462\endgroup
7463%
7464\def\verb{\begingroup\setupverb\doverb}
7465%
7466%
7467% Do the @verbatim magic: define the macro \doverbatim so that
7468% the (first) argument ends when '@end verbatim' is reached, ie:
7469%
7470% \def\doverbatim#1@end verbatim{#1}
7471%
7472% For Texinfo it's a lot easier than for LaTeX,
7473% because texinfo's \verbatim doesn't stop at '\end{verbatim}':
7474% we need not redefine '\', '{' and '}'.
7475%
7476% Inspired by LaTeX's verbatim command set [latex.ltx]
7477%
7478\begingroup
7479 \catcode`\ =\active
7480 \obeylines %
7481 % ignore everything up to the first ^^M, that's the newline at the end
7482 % of the @verbatim input line itself. Otherwise we get an extra blank
7483 % line in the output.
7484 \xdef\doverbatim#1^^M#2@end verbatim{%
7485 \starttabbox#2\egroup\noexpand\end\gobble verbatim}%
7486 % We really want {...\end verbatim} in the body of the macro, but
7487 % without the active space; thus we have to use \xdef and \gobble.
7488 % The \egroup ends the \verbbox started at the end of the last line in
7489 % the block.
7490\endgroup
7491%
7492\envdef\verbatim{%
7493 \setnormaldispenv\setupverbatim\doverbatim
7494}
7495\let\Everbatim = \afterenvbreak
7496
7497
7498% @verbatiminclude FILE - insert text of file in verbatim environment.
7499%
7500\def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude}
7501%
7502\def\doverbatiminclude#1{%
7503 {%
7504 \makevalueexpandable
7505 \setupverbatim
7506 {%
7507 \indexnofonts % Allow `@@' and other weird things in file names.
7508 \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}%
7509 \edef\tmp{\noexpand\input #1 }
7510 \expandafter
7511 }\expandafter\starttabbox\tmp\egroup
7512 \afterenvbreak
7513 }%
7514}
7515
7516% @copying ... @end copying.
7517% Save the text away for @insertcopying later.
7518%
7519% We save the uninterpreted tokens, rather than creating a box.
7520% Saving the text in a box would be much easier, but then all the
7521% typesetting commands (@smallbook, font changes, etc.) have to be done
7522% beforehand -- and a) we want @copying to be done first in the source
7523% file; b) letting users define the frontmatter in as flexible order as
7524% possible is desirable.
7525%
7526\def\copying{\checkenv{}\begingroup\macrobodyctxt\docopying}
7527{\catcode`\ =\other
7528\gdef\docopying#1@end copying{\endgroup\def\copyingtext{#1}}
7529}
7530
7531\def\insertcopying{%
7532 \begingroup
7533 \parindent = 0pt % paragraph indentation looks wrong on title page
7534 \scanexp\copyingtext
7535 \endgroup
7536}
7537
7538
7539\message{defuns,}
7540% @defun etc.
7541
7542\newskip\defbodyindent \defbodyindent=.4in
7543\newskip\defargsindent \defargsindent=50pt
7544\newskip\deflastargmargin \deflastargmargin=18pt
7545\newcount\defunpenalty
7546
7547% Start the processing of @deffn:
7548\def\startdefun{%
7549 \ifnum\lastpenalty<10000
7550 \medbreak
7551 \defunpenalty=10003 % Will keep this @deffn together with the
7552 % following @def command, see below.
7553 \else
7554 % If there are two @def commands in a row, we'll have a \nobreak,
7555 % which is there to keep the function description together with its
7556 % header. But if there's nothing but headers, we need to allow a
7557 % break somewhere. Check specifically for penalty 10002, inserted
7558 % by \printdefunline, instead of 10000, since the sectioning
7559 % commands also insert a nobreak penalty, and we don't want to allow
7560 % a break between a section heading and a defun.
7561 %
7562 % As a further refinement, we avoid "club" headers by signalling
7563 % with penalty of 10003 after the very first @deffn in the
7564 % sequence (see above), and penalty of 10002 after any following
7565 % @def command.
7566 \ifnum\lastpenalty=10002 \penalty2000 \else \defunpenalty=10002 \fi
7567 %
7568 % Similarly, after a section heading, do not allow a break.
7569 % But do insert the glue.
7570 \medskip % preceded by discardable penalty, so not a breakpoint
7571 \fi
7572 %
7573 \parindent=0in
7574 \advance\leftskip by \defbodyindent
7575 \exdentamount=\defbodyindent
7576}
7577
7578\def\dodefunx#1{%
7579 % First, check whether we are in the right environment:
7580 \checkenv#1%
7581 %
7582 % As above, allow line break if we have multiple x headers in a row.
7583 % It's not a great place, though.
7584 \ifnum\lastpenalty=10002 \penalty3000 \else \defunpenalty=10002 \fi
7585 %
7586 % And now, it's time to reuse the body of the original defun:
7587 \expandafter\gobbledefun#1%
7588}
7589\def\gobbledefun#1\startdefun{}
7590
7591% \printdefunline \deffnheader{text}
7592%
7593\def\printdefunline#1#2{%
7594 \begingroup
7595 \plainfrenchspacing
7596 % call \deffnheader:
7597 #1#2 \endheader
7598 % common ending:
7599 \interlinepenalty = 10000
7600 \advance\rightskip by 0pt plus 1fil\relax
7601 \endgraf
7602 \nobreak\vskip -\parskip
7603 \penalty\defunpenalty % signal to \startdefun and \dodefunx
7604 % Some of the @defun-type tags do not enable magic parentheses,
7605 % rendering the following check redundant. But we don't optimize.
7606 \checkparencounts
7607 \endgroup
7608}
7609
7610\def\Edefun{\endgraf\medbreak}
7611
7612% \makedefun{deffoo}{ (definition of \deffooheader) }
7613%
7614% Define \deffoo, \deffoox \Edeffoo and \deffooheader.
7615\def\makedefun#1{%
7616 \expandafter\let\csname E#1\endcsname = \Edefun
7617 \edef\temp{\noexpand\domakedefun
7618 \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}%
7619 \temp
7620}
7621\def\domakedefun#1#2#3{%
7622 \envdef#1{%
7623 \startdefun
7624 \doingtypefnfalse % distinguish typed functions from all else
7625 \parseargusing\activeparens{\printdefunline#3}%
7626 }%
7627 \def#2{\dodefunx#1}%
7628 \def#3%
7629}
7630
7631\newif\ifdoingtypefn % doing typed function?
7632\newif\ifrettypeownline % typeset return type on its own line?
7633
7634% @deftypefnnewline on|off says whether the return type of typed functions
7635% are printed on their own line. This affects @deftypefn, @deftypefun,
7636% @deftypeop, and @deftypemethod.
7637%
7638\parseargdef\deftypefnnewline{%
7639 \def\temp{#1}%
7640 \ifx\temp\onword
7641 \expandafter\let\csname SETtxideftypefnnl\endcsname
7642 = \empty
7643 \else\ifx\temp\offword
7644 \expandafter\let\csname SETtxideftypefnnl\endcsname
7645 = \relax
7646 \else
7647 \errhelp = \EMsimple
7648 \errmessage{Unknown @txideftypefnnl value `\temp',
7649 must be on|off}%
7650 \fi\fi
7651}
7652
7653% Untyped functions:
7654
7655% @deffn category name args
7656\makedefun{deffn}#1 #2 #3\endheader{%
7657 \doind{fn}{\code{#2}}%
7658 \defname{#1}{}{#2}\magicamp\defunargs{#3\unskip}%
7659}
7660
7661% @defop category class name args
7662\makedefun{defop}#1 {\defopheaderx{#1\ \putwordon}}
7663\def\defopheaderx#1#2 #3 #4\endheader{%
7664 \doind{fn}{\code{#3}\space\putwordon\ \code{#2}}%
7665 \defname{#1\ \code{#2}}{}{#3}\magicamp\defunargs{#4\unskip}%
7666}
7667
7668% Typed functions:
7669
7670% @deftypefn category type name args
7671\makedefun{deftypefn}#1 #2 #3 #4\endheader{%
7672 \doind{fn}{\code{#3}}%
7673 \doingtypefntrue
7674 \defname{#1}{#2}{#3}\defunargs{#4\unskip}%
7675}
7676
7677% @deftypeop category class type name args
7678\makedefun{deftypeop}#1 {\deftypeopheaderx{#1\ \putwordon}}
7679\def\deftypeopheaderx#1#2 #3 #4 #5\endheader{%
7680 \doind{fn}{\code{#4}\space\putwordon\ \code{#1\ \code{#2}}}%
7681 \doingtypefntrue
7682 \defname{#1\ \code{#2}}{#3}{#4}\defunargs{#5\unskip}%
7683}
7684
7685% Typed variables:
7686
7687% @deftypevr category type var args
7688\makedefun{deftypevr}#1 #2 #3 #4\endheader{%
7689 \doind{vr}{\code{#3}}%
7690 \defname{#1}{#2}{#3}\defunargs{#4\unskip}%
7691}
7692
7693% @deftypecv category class type var args
7694\makedefun{deftypecv}#1 {\deftypecvheaderx{#1\ \putwordof}}
7695\def\deftypecvheaderx#1#2 #3 #4 #5\endheader{%
7696 \doind{vr}{\code{#4}\space\putwordof\ \code{#2}}%
7697 \defname{#1\ \code{#2}}{#3}{#4}\defunargs{#5\unskip}%
7698}
7699
7700% Untyped variables:
7701
7702% @defvr category var args
7703\makedefun{defvr}#1 {\deftypevrheader{#1} {} }
7704
7705% @defcv category class var args
7706\makedefun{defcv}#1 {\defcvheaderx{#1\ \putwordof}}
7707\def\defcvheaderx#1#2 {\deftypecvheaderx{#1}#2 {} }
7708
7709% Types:
7710
7711% @deftp category name args
7712\makedefun{deftp}#1 #2 #3\endheader{%
7713 \doind{tp}{\code{#2}}%
7714 \defname{#1}{}{#2}\defunargs{#3\unskip}%
7715}
7716
7717% Remaining @defun-like shortcuts:
7718\makedefun{defun}{\deffnheader{\putwordDeffunc} }
7719\makedefun{defmac}{\deffnheader{\putwordDefmac} }
7720\makedefun{defspec}{\deffnheader{\putwordDefspec} }
7721\makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} }
7722\makedefun{defvar}{\defvrheader{\putwordDefvar} }
7723\makedefun{defopt}{\defvrheader{\putwordDefopt} }
7724\makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} }
7725\makedefun{defmethod}{\defopheaderx\putwordMethodon}
7726\makedefun{deftypemethod}{\deftypeopheaderx\putwordMethodon}
7727\makedefun{defivar}{\defcvheaderx\putwordInstanceVariableof}
7728\makedefun{deftypeivar}{\deftypecvheaderx\putwordInstanceVariableof}
7729
7730% \defname, which formats the name of the @def (not the args).
7731% #1 is the category, such as "Function".
7732% #2 is the return type, if any.
7733% #3 is the function name.
7734%
7735% We are followed by (but not passed) the arguments, if any.
7736%
7737\def\defname#1#2#3{%
7738 \par
7739 % Get the values of \leftskip and \rightskip as they were outside the @def...
7740 \advance\leftskip by -\defbodyindent
7741 %
7742 % Determine if we are typesetting the return type of a typed function
7743 % on a line by itself.
7744 \rettypeownlinefalse
7745 \ifdoingtypefn % doing a typed function specifically?
7746 % then check user option for putting return type on its own line:
7747 \ifflagclear{txideftypefnnl}{}{\rettypeownlinetrue}%
7748 \fi
7749 %
7750 % How we'll format the category name. Putting it in brackets helps
7751 % distinguish it from the body text that may end up on the next line
7752 % just below it.
7753 \def\temp{#1}%
7754 \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
7755 %
7756 % Figure out line sizes for the paragraph shape. We'll always have at
7757 % least two.
7758 \tempnum = 2
7759 %
7760 % The first line needs space for \box0; but if \rightskip is nonzero,
7761 % we need only space for the part of \box0 which exceeds it:
7762 \dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip
7763 %
7764 % If doing a return type on its own line, we'll have another line.
7765 \ifrettypeownline
7766 \advance\tempnum by 1
7767 \def\maybeshapeline{0in \hsize}%
7768 \else
7769 \def\maybeshapeline{}%
7770 \fi
7771 %
7772 % The continuations:
7773 \dimen2=\hsize \advance\dimen2 by -\defargsindent
7774 %
7775 % The final paragraph shape:
7776 \parshape \tempnum 0in \dimen0 \maybeshapeline \defargsindent \dimen2
7777 %
7778 % Put the category name at the right margin.
7779 \noindent
7780 \hbox to 0pt{%
7781 \hfil\box0 \kern-\hsize
7782 % \hsize has to be shortened this way:
7783 \kern\leftskip
7784 % Intentionally do not respect \rightskip, since we need the space.
7785 }%
7786 %
7787 % Allow all lines to be underfull without complaint:
7788 \tolerance=10000 \hbadness=10000
7789 \exdentamount=\defbodyindent
7790 {%
7791 % defun fonts. We use typewriter by default (used to be bold) because:
7792 % . we're printing identifiers, they should be in tt in principle.
7793 % . in languages with many accents, such as Czech or French, it's
7794 % common to leave accents off identifiers. The result looks ok in
7795 % tt, but exceedingly strange in rm.
7796 % . we don't want -- and --- to be treated as ligatures.
7797 % . this still does not fix the ?` and !` ligatures, but so far no
7798 % one has made identifiers using them :).
7799 \df \tt
7800 \def\temp{#2}% text of the return type
7801 \ifx\temp\empty\else
7802 \tclose{\temp}% typeset the return type
7803 \ifrettypeownline
7804 % put return type on its own line; prohibit line break following:
7805 \hfil\vadjust{\nobreak}\break
7806 \else
7807 \space % type on same line, so just followed by a space
7808 \fi
7809 \fi % no return type
7810 #3% output function name
7811 }%
7812 \ifflagclear{txidefnamenospace}{%
7813 {\rm\enskip}% hskip 0.5 em of \rmfont
7814 }{}%
7815 %
7816 \boldbrax
7817 % arguments will be output next, if any.
7818}
7819
7820% Print arguments. Use slanted for @def*, typewriter for @deftype*.
7821\def\defunargs#1{%
7822 \df \ifdoingtypefn \tt \else \sl \fi
7823 \ifflagclear{txicodevaristt}{}%
7824 {\def\var##1{{\setregularquotes \ttsl ##1}}}%
7825 #1%
7826}
7827
7828% We want ()&[] to print specially on the defun line.
7829%
7830\def\activeparens{%
7831 \catcode`\(=\active \catcode`\)=\active
7832 \catcode`\[=\active \catcode`\]=\active
7833 \catcode`\&=\active
7834}
7835
7836% Make control sequences which act like normal parenthesis chars.
7837\let\lparen = ( \let\rparen = )
7838
7839% Be sure that we always have a definition for `(', etc. For example,
7840% if the fn name has parens in it, \boldbrax will not be in effect yet,
7841% so TeX would otherwise complain about undefined control sequence.
7842{
7843 \activeparens
7844 \gdef\defcharsdefault{%
7845 \let(=\lparen \let)=\rparen
7846 \let[=\lbrack \let]=\rbrack
7847 \let& = \&%
7848 }
7849 \globaldefs=1 \defcharsdefault
7850
7851 \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
7852 \gdef\magicamp{\let&=\amprm}
7853}
7854\let\ampchar\&
7855
7856\newcount\parencount
7857
7858% If we encounter &foo, then turn on ()-hacking afterwards
7859\newif\ifampseen
7860\def\amprm#1 {\ampseentrue{\bf\&#1 }}
7861
7862\def\parenfont{%
7863 \ifampseen
7864 % At the first level, print parens in roman,
7865 % otherwise use the default font.
7866 \ifnum \parencount=1 \rm \fi
7867 \else
7868 % The \sf parens (in \boldbrax) actually are a little bolder than
7869 % the contained text. This is especially needed for [ and ] .
7870 \sf
7871 \fi
7872}
7873\def\infirstlevel#1{%
7874 \ifampseen
7875 \ifnum\parencount=1
7876 #1%
7877 \fi
7878 \fi
7879}
7880\def\bfafterword#1 {#1 \bf}
7881
7882\def\opnr{%
7883 \global\advance\parencount by 1
7884 {\parenfont(}%
7885 \infirstlevel \bfafterword
7886}
7887\def\clnr{%
7888 {\parenfont)}%
7889 \infirstlevel \sl
7890 \global\advance\parencount by -1
7891}
7892
7893\newcount\brackcount
7894\def\lbrb{%
7895 \global\advance\brackcount by 1
7896 {\bf[}%
7897}
7898\def\rbrb{%
7899 {\bf]}%
7900 \global\advance\brackcount by -1
7901}
7902
7903\def\checkparencounts{%
7904 \ifnum\parencount=0 \else \badparencount \fi
7905 \ifnum\brackcount=0 \else \badbrackcount \fi
7906}
7907% these should not use \errmessage; the glibc manual, at least, actually
7908% has such constructs (when documenting function pointers).
7909\def\badparencount{%
7910 \message{Warning: unbalanced parentheses in @def...}%
7911 \global\parencount=0
7912}
7913\def\badbrackcount{%
7914 \message{Warning: unbalanced square brackets in @def...}%
7915 \global\brackcount=0
7916}
7917
7918
7919\message{macros,}
7920% @macro.
7921
7922% To do this right we need a feature of e-TeX, \scantokens,
7923% which we arrange to emulate with a temporary file in ordinary TeX.
7924\ifx\eTeXversion\thisisundefined
7925 \newwrite\macscribble
7926 \def\scantokens#1{%
7927 \toks0={#1}%
7928 \immediate\openout\macscribble=\jobname.tmp
7929 \immediate\write\macscribble{\the\toks0}%
7930 \immediate\closeout\macscribble
7931 \input \jobname.tmp
7932 }
7933\fi
7934
7935\let\E=\expandafter
7936
7937% Used at the time of macro expansion.
7938% Argument is macro body with arguments substituted
7939\def\scanmacro#1{%
7940 \newlinechar`\^^M
7941 % expand the expansion of \eatleadingcr twice to maybe remove a leading
7942 % newline (and \else and \fi tokens), then call \eatspaces on the result.
7943 \def\xeatspaces##1{%
7944 \E\E\E\E\E\E\E\eatspaces\E\E\E\E\E\E\E{\eatleadingcr##1%
7945 }}%
7946 \def\xempty##1{}%
7947 %
7948 % Process the macro body under the current catcode regime.
7949 \scantokens{#1@comment}%
7950 %
7951 % The \comment is to remove the \newlinechar added by \scantokens, and
7952 % can be noticed by \parsearg. Note \c isn't used because this means cedilla
7953 % in math mode.
7954}
7955
7956% Used for copying and captions
7957\def\scanexp#1{%
7958 \expandafter\scanmacro\expandafter{#1}%
7959}
7960
7961\newcount\paramno % Count of parameters
7962\newtoks\macname % Macro name
7963\newif\ifrecursive % Is it recursive?
7964
7965% List of all defined macros in the form
7966% \commondummyword\macro1\commondummyword\macro2...
7967% Currently is also contains all @aliases; the list can be split
7968% if there is a need.
7969\def\macrolist{}
7970
7971% Add the macro to \macrolist
7972\def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname}
7973\def\addtomacrolistxxx#1{%
7974 \toks0 = \expandafter{\macrolist\commondummyword#1}%
7975 \xdef\macrolist{\the\toks0}%
7976}
7977
7978% Utility routines.
7979% This does \let #1 = #2, with \csnames; that is,
7980% \let \csname#1\endcsname = \csname#2\endcsname
7981% (except of course we have to play expansion games).
7982%
7983\def\cslet#1#2{%
7984 \expandafter\let
7985 \csname#1\expandafter\endcsname
7986 \csname#2\endcsname
7987}
7988
7989% Trim leading and trailing spaces off a string.
7990% Concepts from aro-bend problem 15 (see CTAN).
7991{\catcode`\@=11
7992\gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }}
7993\gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@}
7994\gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @}
7995\def\unbrace#1{#1}
7996\unbrace{\gdef\trim@@@ #1 } #2@{#1}
7997}
7998
7999{\catcode`\^^M=\other%
8000\gdef\eatleadingcr#1{\if\noexpand#1\noexpand^^M\else\E#1\fi}}%
8001% Warning: this won't work for a delimited argument
8002% or for an empty argument
8003
8004% Trim a single trailing ^^M off a string.
8005{\catcode`\^^M=\other \catcode`\Q=3%
8006\gdef\eatcr #1{\eatcra #1Q^^MQ}%
8007\gdef\eatcra#1^^MQ{\eatcrb#1Q}%
8008\gdef\eatcrb#1Q#2Q{#1}%
8009}
8010
8011% Macro bodies are absorbed as an argument in a context where
8012% all characters are catcode 10, 11 or 12, except \ which is active
8013% (as in normal texinfo). It is necessary to change the definition of \
8014% to recognize macro arguments; this is the job of \mbodybackslash.
8015%
8016% Non-ASCII encodings make 8-bit characters active, so un-activate
8017% them to avoid their expansion. Must do this non-globally, to
8018% confine the change to the current group.
8019%
8020% It's necessary to have hard CRs when the macro is executed. This is
8021% done by making ^^M (\endlinechar) catcode 12 when reading the macro
8022% body, and then making it the \newlinechar in \scanmacro.
8023%
8024\def\scanctxt{% used as subroutine
8025 \catcode`\"=\other
8026 \catcode`\+=\other
8027 \catcode`\<=\other
8028 \catcode`\>=\other
8029 \catcode`\^=\other
8030 \catcode`\_=\other
8031 \catcode`\|=\other
8032 \catcode`\~=\other
8033 \catcode`\@=\other
8034 \catcode`\^^M=\other
8035 \catcode`\\=\active
8036 \passthroughcharstrue
8037}
8038
8039\def\macrobodyctxt{% used for @macro definitions and @copying
8040 \scanctxt
8041 \catcode`\ =\other
8042 \catcode`\{=\other
8043 \catcode`\}=\other
8044}
8045
8046% Used when scanning braced macro arguments. Note, however, that catcode
8047% changes here are ineffectual if the macro invocation was nested inside
8048% an argument to another Texinfo command.
8049\def\macroargctxt{%
8050 \scanctxt
8051 \catcode`\ =\active
8052}
8053
8054\def\macrolineargctxt{% used for whole-line arguments without braces
8055 \scanctxt
8056 \catcode`\{=\other
8057 \catcode`\}=\other
8058}
8059
8060% \mbodybackslash is the definition of \ in @macro bodies.
8061% It maps \foo\ => \csname macarg.foo\endcsname => #N
8062% where N is the macro parameter number.
8063% We define \csname macarg.\endcsname to be \realbackslash, so
8064% \\ in macro replacement text gets you a backslash.
8065%
8066{\catcode`@=0 @catcode`@\=@active
8067 @gdef@usembodybackslash{@let\=@mbodybackslash}
8068 @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname}
8069}
8070\expandafter\def\csname macarg.\endcsname{\realbackslash}
8071
8072\def\margbackslash#1{\char`\#1 }
8073
8074\def\macro{\recursivefalse\parsearg\macroxxx}
8075\def\rmacro{\recursivetrue\parsearg\macroxxx}
8076
8077\def\macroxxx#1{%
8078 \getargs{#1}% now \macname is the macname and \argl the arglist
8079 \ifx\argl\empty % no arguments
8080 \paramno=0\relax
8081 \else
8082 \expandafter\parsemargdef \argl;%
8083 \if\paramno>256\relax
8084 \ifx\eTeXversion\thisisundefined
8085 \errhelp = \EMsimple
8086 \errmessage{You need eTeX to compile a file with macros with more than 256 arguments}
8087 \fi
8088 \fi
8089 \fi
8090 \if1\csname ismacro.\the\macname\endcsname
8091 \message{Warning: redefining \the\macname}%
8092 \else
8093 \expandafter\ifx\csname \the\macname\endcsname \relax
8094 \else \errmessage{Macro name \the\macname\space already defined}\fi
8095 \global\cslet{macsave.\the\macname}{\the\macname}%
8096 \global\expandafter\let\csname ismacro.\the\macname\endcsname=1%
8097 \addtomacrolist{\the\macname}%
8098 \fi
8099 \begingroup \macrobodyctxt \usembodybackslash
8100 \ifrecursive \expandafter\parsermacbody
8101 \else \expandafter\parsemacbody
8102 \fi}
8103
8104\parseargdef\unmacro{%
8105 \if1\csname ismacro.#1\endcsname
8106 \global\cslet{#1}{macsave.#1}%
8107 \global\expandafter\let \csname ismacro.#1\endcsname=0%
8108 % Remove the macro name from \macrolist:
8109 \begingroup
8110 \expandafter\let\csname#1\endcsname \relax
8111 \let\commondummyword\unmacrodo
8112 \xdef\macrolist{\macrolist}%
8113 \endgroup
8114 \else
8115 \errmessage{Macro #1 not defined}%
8116 \fi
8117}
8118
8119% Called by \do from \dounmacro on each macro. The idea is to omit any
8120% macro definitions that have been changed to \relax.
8121%
8122\def\unmacrodo#1{%
8123 \ifx #1\relax
8124 % remove this
8125 \else
8126 \noexpand\commondummyword \noexpand#1%
8127 \fi
8128}
8129
8130% \getargs -- Parse the arguments to a @macro line. Set \macname to
8131% the name of the macro, and \argl to the braced argument list.
8132\def\getargs#1{\getargsxxx#1{}}
8133\def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
8134\def\getmacname#1 #2\relax{\macname={#1}}
8135\def\getmacargs#1{\def\argl{#1}}
8136% This made use of the feature that if the last token of a
8137% <parameter list> is #, then the preceding argument is delimited by
8138% an opening brace, and that opening brace is not consumed.
8139
8140% Parse the optional {params} list to @macro or @rmacro.
8141% Set \paramno to the number of arguments,
8142% and \paramlist to a parameter text for the macro (e.g. #1,#2,#3 for a
8143% three-param macro.) Define \macarg.BLAH for each BLAH in the params
8144% list to some hook where the argument is to be expanded. If there are
8145% less than 10 arguments that hook is to be replaced by ##N where N
8146% is the position in that list, that is to say the macro arguments are to be
8147% defined `a la TeX in the macro body.
8148%
8149% That gets used by \mbodybackslash (above).
8150%
8151% If there are 10 or more arguments, a different technique is used: see
8152% \parsemmanyargdef.
8153%
8154\def\parsemargdef#1;{%
8155 \paramno=0\def\paramlist{}%
8156 \let\hash\relax
8157 % \hash is redefined to `#' later to get it into definitions
8158 \let\xeatspaces\relax
8159 \let\xempty\relax
8160 \parsemargdefxxx#1,;,%
8161 \ifnum\paramno<10\relax\else
8162 \paramno0\relax
8163 \parsemmanyargdef@@#1,;,% 10 or more arguments
8164 \fi
8165}
8166\def\parsemargdefxxx#1,{%
8167 \if#1;\let\next=\relax
8168 \else \let\next=\parsemargdefxxx
8169 \advance\paramno by 1
8170 \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
8171 {\xeatspaces{\hash\the\paramno\noexpand\xempty{}}}%
8172 \edef\paramlist{\paramlist\hash\the\paramno,}%
8173 \fi\next}
8174% the \xempty{} is to give \eatleadingcr an argument in the case of an
8175% empty macro argument.
8176
8177% \parsemacbody, \parsermacbody
8178%
8179% Read recursive and nonrecursive macro bodies. (They're different since
8180% rec and nonrec macros end differently.)
8181%
8182% We are in \macrobodyctxt, and the \xdef causes backslashshes in the macro
8183% body to be transformed.
8184% Set \macrobody to the body of the macro, and call \defmacro.
8185%
8186{\catcode`\ =\other\long\gdef\parsemacbody#1@end macro{%
8187\xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}%
8188{\catcode`\ =\other\long\gdef\parsermacbody#1@end rmacro{%
8189\xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}%
8190
8191% Make @ a letter, so that we can make private-to-Texinfo macro names.
8192\edef\texiatcatcode{\the\catcode`\@}
8193\catcode `@=11\relax
8194
8195%%%%%%%%%%%%%% Code for > 10 arguments only %%%%%%%%%%%%%%%%%%
8196
8197% If there are 10 or more arguments, a different technique is used, where the
8198% hook remains in the body, and when macro is to be expanded the body is
8199% processed again to replace the arguments.
8200%
8201% In that case, the hook is \the\toks N-1, and we simply set \toks N-1 to the
8202% argument N value and then \edef the body (nothing else will expand because of
8203% the catcode regime under which the body was input).
8204%
8205% If you compile with TeX (not eTeX), and you have macros with 10 or more
8206% arguments, no macro can have more than 256 arguments (else error).
8207%
8208% In case that there are 10 or more arguments we parse again the arguments
8209% list to set new definitions for the \macarg.BLAH macros corresponding to
8210% each BLAH argument. It was anyhow needed to parse already once this list
8211% in order to count the arguments, and as macros with at most 9 arguments
8212% are by far more frequent than macro with 10 or more arguments, defining
8213% twice the \macarg.BLAH macros does not cost too much processing power.
8214\def\parsemmanyargdef@@#1,{%
8215 \if#1;\let\next=\relax
8216 \else
8217 \let\next=\parsemmanyargdef@@
8218 \edef\tempb{\eatspaces{#1}}%
8219 \expandafter\def\expandafter\tempa
8220 \expandafter{\csname macarg.\tempb\endcsname}%
8221 % Note that we need some extra \noexpand\noexpand, this is because we
8222 % don't want \the to be expanded in the \parsermacbody as it uses an
8223 % \xdef .
8224 \expandafter\edef\tempa
8225 {\noexpand\noexpand\noexpand\the\toks\the\paramno}%
8226 \advance\paramno by 1\relax
8227 \fi\next}
8228
8229
8230\let\endargs@\relax
8231\let\nil@\relax
8232\def\nilm@{\nil@}%
8233\long\def\nillm@{\nil@}%
8234
8235% This macro is expanded during the Texinfo macro expansion, not during its
8236% definition. It gets all the arguments' values and assigns them to macros
8237% macarg.ARGNAME
8238%
8239% #1 is the macro name
8240% #2 is the list of argument names
8241% #3 is the list of argument values
8242\def\getargvals@#1#2#3{%
8243 \def\macargdeflist@{}%
8244 \def\saveparamlist@{#2}% Need to keep a copy for parameter expansion.
8245 \def\paramlist{#2,\nil@}%
8246 \def\macroname{#1}%
8247 \begingroup
8248 \macroargctxt
8249 \def\argvaluelist{#3,\nil@}%
8250 \def\@tempa{#3}%
8251 \ifx\@tempa\empty
8252 \setemptyargvalues@
8253 \else
8254 \getargvals@@
8255 \fi
8256}
8257\def\getargvals@@{%
8258 \ifx\paramlist\nilm@
8259 % Some sanity check needed here that \argvaluelist is also empty.
8260 \ifx\argvaluelist\nillm@
8261 \else
8262 \errhelp = \EMsimple
8263 \errmessage{Too many arguments in macro `\macroname'!}%
8264 \fi
8265 \let\next\macargexpandinbody@
8266 \else
8267 \ifx\argvaluelist\nillm@
8268 % No more arguments values passed to macro. Set remaining named-arg
8269 % macros to empty.
8270 \let\next\setemptyargvalues@
8271 \else
8272 % pop current arg name into \@tempb
8273 \def\@tempa##1{\pop@{\@tempb}{\paramlist}##1\endargs@}%
8274 \expandafter\@tempa\expandafter{\paramlist}%
8275 % pop current argument value into \@tempc
8276 \def\@tempa##1{\longpop@{\@tempc}{\argvaluelist}##1\endargs@}%
8277 \expandafter\@tempa\expandafter{\argvaluelist}%
8278 % Here \@tempb is the current arg name and \@tempc is the current arg value.
8279 % First place the new argument macro definition into \@tempd
8280 \expandafter\macname\expandafter{\@tempc}%
8281 \expandafter\let\csname macarg.\@tempb\endcsname\relax
8282 \expandafter\def\expandafter\@tempe\expandafter{%
8283 \csname macarg.\@tempb\endcsname}%
8284 \edef\@tempd{\long\def\@tempe{\the\macname}}%
8285 \push@\@tempd\macargdeflist@
8286 \let\next\getargvals@@
8287 \fi
8288 \fi
8289 \next
8290}
8291
8292\def\push@#1#2{%
8293 \expandafter\expandafter\expandafter\def
8294 \expandafter\expandafter\expandafter#2%
8295 \expandafter\expandafter\expandafter{%
8296 \expandafter#1#2}%
8297}
8298
8299% Replace arguments by their values in the macro body, and place the result
8300% in macro \@tempa.
8301%
8302\def\macvalstoargs@{%
8303 % To do this we use the property that token registers that are \the'ed
8304 % within an \edef expand only once. So we are going to place all argument
8305 % values into respective token registers.
8306 %
8307 % First we save the token context, and initialize argument numbering.
8308 \begingroup
8309 \paramno0\relax
8310 % Then, for each argument number #N, we place the corresponding argument
8311 % value into a new token list register \toks#N
8312 \expandafter\putargsintokens@\saveparamlist@,;,%
8313 % Then, we expand the body so that argument are replaced by their
8314 % values. The trick for values not to be expanded themselves is that they
8315 % are within tokens and that tokens expand only once in an \edef .
8316 \edef\@tempc{\csname mac.\macroname .body\endcsname}%
8317 % Now we restore the token stack pointer to free the token list registers
8318 % which we have used, but we make sure that expanded body is saved after
8319 % group.
8320 \expandafter
8321 \endgroup
8322 \expandafter\def\expandafter\@tempa\expandafter{\@tempc}%
8323 }
8324
8325% Define the named-macro outside of this group and then close this group.
8326%
8327\def\macargexpandinbody@{%
8328 \expandafter
8329 \endgroup
8330 \macargdeflist@
8331 % First the replace in body the macro arguments by their values, the result
8332 % is in \@tempa .
8333 \macvalstoargs@
8334 % Then we point at the \norecurse or \gobble (for recursive) macro value
8335 % with \@tempb .
8336 \expandafter\let\expandafter\@tempb\csname mac.\macroname .recurse\endcsname
8337 % Depending on whether it is recursive or not, we need some tailing
8338 % \egroup .
8339 \ifx\@tempb\gobble
8340 \let\@tempc\relax
8341 \else
8342 \let\@tempc\egroup
8343 \fi
8344 % And now we do the real job:
8345 \edef\@tempd{\noexpand\@tempb{\macroname}\noexpand\scanmacro{\@tempa}\@tempc}%
8346 \@tempd
8347}
8348
8349\def\putargsintokens@#1,{%
8350 \if#1;\let\next\relax
8351 \else
8352 \let\next\putargsintokens@
8353 % First we allocate the new token list register, and give it a temporary
8354 % alias \@tempb .
8355 \toksdef\@tempb\the\paramno
8356 % Then we place the argument value into that token list register.
8357 \expandafter\let\expandafter\@tempa\csname macarg.#1\endcsname
8358 \expandafter\@tempb\expandafter{\@tempa}%
8359 \advance\paramno by 1\relax
8360 \fi
8361 \next
8362}
8363
8364% Trailing missing arguments are set to empty.
8365%
8366\def\setemptyargvalues@{%
8367 \ifx\paramlist\nilm@
8368 \let\next\macargexpandinbody@
8369 \else
8370 \expandafter\setemptyargvaluesparser@\paramlist\endargs@
8371 \let\next\setemptyargvalues@
8372 \fi
8373 \next
8374}
8375
8376\def\setemptyargvaluesparser@#1,#2\endargs@{%
8377 \expandafter\def\expandafter\@tempa\expandafter{%
8378 \expandafter\def\csname macarg.#1\endcsname{}}%
8379 \push@\@tempa\macargdeflist@
8380 \def\paramlist{#2}%
8381}
8382
8383% #1 is the element target macro
8384% #2 is the list macro
8385% #3,#4\endargs@ is the list value
8386\def\pop@#1#2#3,#4\endargs@{%
8387 \def#1{#3}%
8388 \def#2{#4}%
8389}
8390\long\def\longpop@#1#2#3,#4\endargs@{%
8391 \long\def#1{#3}%
8392 \long\def#2{#4}%
8393}
8394
8395
8396%%%%%%%%%%%%%% End of code for > 10 arguments %%%%%%%%%%%%%%%%%%
8397
8398
8399% This defines a Texinfo @macro or @rmacro, called by \parsemacbody.
8400% \macrobody has the body of the macro in it, with placeholders for
8401% its parameters, looking like "\xeatspaces{\hash 1}".
8402% \paramno is the number of parameters
8403% \paramlist is a TeX parameter text, e.g. "#1,#2,#3,"
8404% There are four cases: macros of zero, one, up to nine, and many arguments.
8405% \xdef is used so that macro definitions will survive the file
8406% they're defined in: @include reads the file inside a group.
8407%
8408\def\defmacro{%
8409 \let\hash=##% convert placeholders to macro parameter chars
8410 \ifnum\paramno=1
8411 \def\xeatspaces##1{##1}%
8412 % This removes the pair of braces around the argument. We don't
8413 % use \eatspaces, because this can cause ends of lines to be lost
8414 % when the argument to \eatspaces is read, leading to line-based
8415 % commands like "@itemize" not being read correctly.
8416 \else
8417 \let\xeatspaces\relax % suppress expansion
8418 \fi
8419 \ifcase\paramno
8420 % 0
8421 \expandafter\xdef\csname\the\macname\endcsname{%
8422 \bgroup
8423 \noexpand\spaceisspace
8424 \noexpand\endlineisspace
8425 \noexpand\expandafter % skip any whitespace after the macro name.
8426 \expandafter\noexpand\csname\the\macname @@@\endcsname}%
8427 \expandafter\xdef\csname\the\macname @@@\endcsname{%
8428 \egroup
8429 \noexpand\scanmacro{\macrobody}}%
8430 \or % 1
8431 \expandafter\xdef\csname\the\macname\endcsname{%
8432 \bgroup
8433 \noexpand\braceorline
8434 \expandafter\noexpand\csname\the\macname @@@\endcsname}%
8435 \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8436 \egroup
8437 \noexpand\scanmacro{\macrobody}%
8438 }%
8439 \else % at most 9
8440 \ifnum\paramno<10\relax
8441 % @MACNAME sets the context for reading the macro argument
8442 % @MACNAME@@ gets the argument, processes backslashes and appends a
8443 % comma.
8444 % @MACNAME@@@ removes braces surrounding the argument list.
8445 % @MACNAME@@@@ scans the macro body with arguments substituted.
8446 \expandafter\xdef\csname\the\macname\endcsname{%
8447 \bgroup
8448 \noexpand\expandafter % This \expandafter skip any spaces after the
8449 \noexpand\macroargctxt % macro before we change the catcode of space.
8450 \noexpand\expandafter
8451 \expandafter\noexpand\csname\the\macname @@\endcsname}%
8452 \expandafter\xdef\csname\the\macname @@\endcsname##1{%
8453 \noexpand\passargtomacro
8454 \expandafter\noexpand\csname\the\macname @@@\endcsname{##1,}}%
8455 \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8456 \expandafter\noexpand\csname\the\macname @@@@\endcsname ##1}%
8457 \expandafter\expandafter
8458 \expandafter\xdef
8459 \expandafter\expandafter
8460 \csname\the\macname @@@@\endcsname\paramlist{%
8461 \egroup\noexpand\scanmacro{\macrobody}}%
8462 \else % 10 or more:
8463 \expandafter\xdef\csname\the\macname\endcsname{%
8464 \noexpand\getargvals@{\the\macname}{\argl}%
8465 }%
8466 \global\expandafter\let\csname mac.\the\macname .body\endcsname\macrobody
8467 \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\gobble
8468 \fi
8469 \fi}
8470
8471\catcode `\@\texiatcatcode\relax % end private-to-Texinfo catcodes
8472
8473\def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
8474
8475
8476%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8477%
8478{\catcode`\@=0 \catcode`\\=13 % We need to manipulate \ so use @ as escape
8479@catcode`@_=11 % private names
8480@catcode`@!=11 % used as argument separator
8481
8482% \passargtomacro#1#2 -
8483% Call #1 with a list of tokens #2, with any doubled backslashes in #2
8484% compressed to one.
8485%
8486% This implementation works by expansion, and not execution (so we cannot use
8487% \def or similar). This reduces the risk of this failing in contexts where
8488% complete expansion is done with no execution (for example, in writing out to
8489% an auxiliary file for an index entry).
8490%
8491% State is kept in the input stream: the argument passed to
8492% @look_ahead, @gobble_and_check_finish and @add_segment is
8493%
8494% THE_MACRO ARG_RESULT ! {PENDING_BS} NEXT_TOKEN (... rest of input)
8495%
8496% where:
8497% THE_MACRO - name of the macro we want to call
8498% ARG_RESULT - argument list we build to pass to that macro
8499% PENDING_BS - either a backslash or nothing
8500% NEXT_TOKEN - used to look ahead in the input stream to see what's coming next
8501
8502@gdef@passargtomacro#1#2{%
8503 @add_segment #1!{}@relax#2\@_finish\%
8504}
8505@gdef@_finish{@_finishx} @global@let@_finishx@relax
8506
8507% #1 - THE_MACRO ARG_RESULT
8508% #2 - PENDING_BS
8509% #3 - NEXT_TOKEN
8510% #4 used to look ahead
8511%
8512% If the next token is not a backslash, process the rest of the argument;
8513% otherwise, remove the next token.
8514@gdef@look_ahead#1!#2#3#4{%
8515 @ifx#4\%
8516 @expandafter@gobble_and_check_finish
8517 @else
8518 @expandafter@add_segment
8519 @fi#1!{#2}#4#4%
8520}
8521
8522% #1 - THE_MACRO ARG_RESULT
8523% #2 - PENDING_BS
8524% #3 - NEXT_TOKEN
8525% #4 should be a backslash, which is gobbled.
8526% #5 looks ahead
8527%
8528% Double backslash found. Add a single backslash, and look ahead.
8529@gdef@gobble_and_check_finish#1!#2#3#4#5{%
8530 @add_segment#1\!{}#5#5%
8531}
8532
8533@gdef@is_fi{@fi}
8534
8535% #1 - THE_MACRO ARG_RESULT
8536% #2 - PENDING_BS
8537% #3 - NEXT_TOKEN
8538% #4 is input stream until next backslash
8539%
8540% Input stream is either at the start of the argument, or just after a
8541% backslash sequence, either a lone backslash, or a doubled backslash.
8542% NEXT_TOKEN contains the first token in the input stream: if it is \finish,
8543% finish; otherwise, append to ARG_RESULT the segment of the argument up until
8544% the next backslash. PENDING_BACKSLASH contains a backslash to represent
8545% a backslash just before the start of the input stream that has not been
8546% added to ARG_RESULT.
8547@gdef@add_segment#1!#2#3#4\{%
8548@ifx#3@_finish
8549 @call_the_macro#1!%
8550@else
8551 % append the pending backslash to the result, followed by the next segment
8552 @expandafter@is_fi@look_ahead#1#2#4!{\}@fi
8553 % this @fi is discarded by @look_ahead.
8554 % we can't get rid of it with \expandafter because we don't know how
8555 % long #4 is.
8556}
8557
8558% #1 - THE_MACRO
8559% #2 - ARG_RESULT
8560% #3 discards the res of the conditional in @add_segment, and @is_fi ends the
8561% conditional.
8562@gdef@call_the_macro#1#2!#3@fi{@is_fi #1{#2}}
8563
8564}
8565%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8566
8567% \braceorline MAC is used for a one-argument macro MAC. It checks
8568% whether the next non-whitespace character is a {. It sets the context
8569% for reading the argument (slightly different in the two cases). Then,
8570% to read the argument, in the whole-line case, it then calls the regular
8571% \parsearg MAC; in the lbrace case, it calls \passargtomacro MAC.
8572%
8573\def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx}
8574\def\braceorlinexxx{%
8575 \ifx\nchar\bgroup
8576 \macroargctxt
8577 \expandafter\passargtomacro
8578 \else
8579 \macrolineargctxt\expandafter\parsearg
8580 \fi \macnamexxx}
8581
8582
8583% @alias.
8584% We need some trickery to remove the optional spaces around the equal
8585% sign. Make them active and then expand them all to nothing.
8586%
8587\def\alias{\parseargusing\obeyspaces\aliasxxx}
8588\def\aliasxxx #1{\aliasyyy#1\relax}
8589\def\aliasyyy #1=#2\relax{%
8590 {%
8591 \expandafter\let\obeyedspace=\empty
8592 \addtomacrolist{#1}%
8593 \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}%
8594 }%
8595 \next
8596}
8597
8598
8599\message{cross references,}
8600
8601\newwrite\auxfile
8602\newif\ifhavexrefs % True if xref values are known.
8603\newif\ifwarnedxrefs % True if we warned once that they aren't known.
8604
8605% @inforef is relatively simple.
8606\def\inforef #1{\inforefzzz #1,,,,**}
8607\def\inforefzzz #1,#2,#3,#4**{%
8608 \putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
8609 node \samp{\ignorespaces#1{}}}
8610
8611% @node's only job in TeX is to define \lastnode, which is used in
8612% cross-references. The @node line might or might not have commas, and
8613% might or might not have spaces before the first comma, like:
8614% @node foo , bar , ...
8615% We don't want such trailing spaces in the node name.
8616%
8617\parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse}
8618%
8619% also remove a trailing comma, in case of something like this:
8620% @node Help-Cross, , , Cross-refs
8621\def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse}
8622\def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}\omittopnode}
8623
8624% Used so that the @top node doesn't have to be wrapped in an @ifnottex
8625% conditional.
8626% \doignore goes to more effort to skip nested conditionals but we don't need
8627% that here.
8628\def\omittopnode{%
8629 \ifx\lastnode\wordTop
8630 \expandafter\ignorenode\fi
8631}
8632\def\wordTop{Top}
8633
8634% Until the next @node, @part or @bye command, divert output to a box that
8635% is not output.
8636\def\ignorenode{\setbox\dummybox\vbox\bgroup
8637\def\part{\egroup\part}%
8638\def\node{\egroup\node}%
8639\ignorenodebye
8640}
8641
8642{\let\bye\relax
8643\gdef\ignorenodebye{\let\bye\ignorenodebyedef}
8644\gdef\ignorenodebyedef{\egroup(`Top' node ignored)\bye}}
8645% The redefinition of \bye here is because it is declared \outer
8646
8647\let\lastnode=\empty
8648
8649% Write a cross-reference definition for the current node. #1 is the
8650% type (Ynumbered, Yappendix, Ynothing).
8651%
8652\def\donoderef#1{%
8653 \ifx\lastnode\empty\else
8654 \setref{\lastnode}{#1}%
8655 \global\let\lastnode=\empty
8656 \fi
8657}
8658
8659% @anchor{NAME} -- define xref target at arbitrary point.
8660%
8661\newcount\savesfregister
8662%
8663\def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi}
8664\def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi}
8665\def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces}
8666
8667% \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an
8668% anchor), which consists of three parts:
8669% 1) NAME-title - the current sectioning name taken from \currentsection,
8670% or the anchor name.
8671% 2) NAME-snt - section number and type, passed as the SNT arg, or
8672% empty for anchors.
8673% 3) NAME-pg - the page number.
8674%
8675% This is called from \donoderef, \anchor, and \dofloat. In the case of
8676% floats, there is an additional part, which is not written here:
8677% 4) NAME-lof - the text as it should appear in a @listoffloats.
8678%
8679\def\setref#1#2{%
8680 \pdfmkdest{#1}%
8681 \iflinks
8682 {%
8683 \requireauxfile
8684 \atdummies % preserve commands, but don't expand them
8685 % match definition in \xrdef, \refx, \xrefX.
8686 \def\value##1{##1}%
8687 \edef\writexrdef##1##2{%
8688 \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef
8689 ##1}{##2}}% these are parameters of \writexrdef
8690 }%
8691 \toks0 = \expandafter{\currentsection}%
8692 \immediate \writexrdef{title}{\the\toks0 }%
8693 \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc.
8694 \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout
8695 }%
8696 \fi
8697}
8698
8699% @xrefautosectiontitle on|off says whether @section(ing) names are used
8700% automatically in xrefs, if the third arg is not explicitly specified.
8701% This was provided as a "secret" @set xref-automatic-section-title
8702% variable, now it's official.
8703%
8704\parseargdef\xrefautomaticsectiontitle{%
8705 \def\temp{#1}%
8706 \ifx\temp\onword
8707 \expandafter\let\csname SETxref-automatic-section-title\endcsname
8708 = \empty
8709 \else\ifx\temp\offword
8710 \expandafter\let\csname SETxref-automatic-section-title\endcsname
8711 = \relax
8712 \else
8713 \errhelp = \EMsimple
8714 \errmessage{Unknown @xrefautomaticsectiontitle value `\temp',
8715 must be on|off}%
8716 \fi\fi
8717}
8718
8719%
8720% @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is
8721% the node name, #2 the name of the Info cross-reference, #3 the printed
8722% node name, #4 the name of the Info file, #5 the name of the printed
8723% manual. All but the node name can be omitted.
8724%
8725\def\pxref{\putwordsee{} \xrefXX}
8726\def\xref{\putwordSee{} \xrefXX}
8727\def\ref{\xrefXX}
8728
8729\def\xrefXX#1{\def\xrefXXarg{#1}\futurelet\tokenafterxref\xrefXXX}
8730\def\xrefXXX{\expandafter\xrefX\expandafter[\xrefXXarg,,,,,,,]}
8731%
8732\newbox\toprefbox
8733\newbox\printedrefnamebox
8734\newbox\infofilenamebox
8735\newbox\printedmanualbox
8736%
8737\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
8738 \unsepspaces
8739 %
8740 % Get args without leading/trailing spaces.
8741 \def\printedrefname{\ignorespaces #3}%
8742 \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}%
8743 %
8744 \def\infofilename{\ignorespaces #4}%
8745 \setbox\infofilenamebox = \hbox{\infofilename\unskip}%
8746 %
8747 \def\printedmanual{\ignorespaces #5}%
8748 \setbox\printedmanualbox = \hbox{\printedmanual\unskip}%
8749 %
8750 % If the printed reference name (arg #3) was not explicitly given in
8751 % the @xref, figure out what we want to use.
8752 \ifdim \wd\printedrefnamebox = 0pt
8753 % No printed node name was explicitly given.
8754 \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax
8755 % Not auto section-title: use node name inside the square brackets.
8756 \def\printedrefname{\ignorespaces #1}%
8757 \else
8758 % Auto section-title: use chapter/section title inside
8759 % the square brackets if we have it.
8760 \ifdim \wd\printedmanualbox > 0pt
8761 % It is in another manual, so we don't have it; use node name.
8762 \def\printedrefname{\ignorespaces #1}%
8763 \else
8764 \ifhavexrefs
8765 % We (should) know the real title if we have the xref values.
8766 \def\printedrefname{\refx{#1-title}}%
8767 \else
8768 % Otherwise just copy the Info node name.
8769 \def\printedrefname{\ignorespaces #1}%
8770 \fi%
8771 \fi
8772 \fi
8773 \fi
8774 %
8775 % Make link in pdf output.
8776 \ifpdf
8777 % For pdfTeX and LuaTeX
8778 {\indexnofonts
8779 \makevalueexpandable
8780 \turnoffactive
8781 % This expands tokens, so do it after making catcode changes, so _
8782 % etc. don't get their TeX definitions. This ignores all spaces in
8783 % #4, including (wrongly) those in the middle of the filename.
8784 \getfilename{#4}%
8785 %
8786 % This (wrongly) does not take account of leading or trailing
8787 % spaces in #1, which should be ignored.
8788 \setpdfdestname{#1}%
8789 %
8790 \ifx\pdfdestname\empty
8791 \def\pdfdestname{Top}% no empty targets
8792 \fi
8793 %
8794 \leavevmode
8795 \startlink attr{/Border [0 0 0]}%
8796 \ifnum\filenamelength>0
8797 goto file{\the\filename.pdf} name{\pdfdestname}%
8798 \else
8799 goto name{\pdfmkpgn{\pdfdestname}}%
8800 \fi
8801 }%
8802 \setcolor{\linkcolor}%
8803 \else
8804 \ifx\XeTeXrevision\thisisundefined
8805 \else
8806 % For XeTeX
8807 {\indexnofonts
8808 \makevalueexpandable
8809 \turnoffactive
8810 % This expands tokens, so do it after making catcode changes, so _
8811 % etc. don't get their TeX definitions. This ignores all spaces in
8812 % #4, including (wrongly) those in the middle of the filename.
8813 \getfilename{#4}%
8814 %
8815 % This (wrongly) does not take account of leading or trailing
8816 % spaces in #1, which should be ignored.
8817 \setpdfdestname{#1}%
8818 %
8819 \ifx\pdfdestname\empty
8820 \def\pdfdestname{Top}% no empty targets
8821 \fi
8822 %
8823 \leavevmode
8824 \ifnum\filenamelength>0
8825 % With default settings,
8826 % XeTeX (xdvipdfmx) replaces link destination names with integers.
8827 % In this case, the replaced destination names of
8828 % remote PDFs are no longer known. In order to avoid a replacement,
8829 % you can use xdvipdfmx's command line option `-C 0x0010'.
8830 % If you use XeTeX 0.99996+ (TeX Live 2016+),
8831 % this command line option is no longer necessary
8832 % because we can use the `dvipdfmx:config' special.
8833 \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A
8834 << /S /GoToR /F (\the\filename.pdf) /D (\pdfdestname) >> >>}%
8835 \else
8836 \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A
8837 << /S /GoTo /D (\pdfdestname) >> >>}%
8838 \fi
8839 }%
8840 \setcolor{\linkcolor}%
8841 \fi
8842 \fi
8843 {%
8844 % Have to otherify everything special to allow the \csname to
8845 % include an _ in the xref name, etc.
8846 \indexnofonts
8847 \turnoffactive
8848 \def\value##1{##1}%
8849 \expandafter\global\expandafter\let\expandafter\Xthisreftitle
8850 \csname XR#1-title\endcsname
8851 }%
8852 %
8853 % Float references are printed completely differently: "Figure 1.2"
8854 % instead of "[somenode], p.3". \iffloat distinguishes them by
8855 % \Xthisreftitle being set to a magic string.
8856 \iffloat\Xthisreftitle
8857 % If the user specified the print name (third arg) to the ref,
8858 % print it instead of our usual "Figure 1.2".
8859 \ifdim\wd\printedrefnamebox = 0pt
8860 \refx{#1-snt}%
8861 \else
8862 \printedrefname
8863 \fi
8864 %
8865 % If the user also gave the printed manual name (fifth arg), append
8866 % "in MANUALNAME".
8867 \ifdim \wd\printedmanualbox > 0pt
8868 \space \putwordin{} \cite{\printedmanual}%
8869 \fi
8870 \else
8871 % node/anchor (non-float) references.
8872 %
8873 % If we use \unhbox to print the node names, TeX does not insert
8874 % empty discretionaries after hyphens, which means that it will not
8875 % find a line break at a hyphen in a node names. Since some manuals
8876 % are best written with fairly long node names, containing hyphens,
8877 % this is a loss. Therefore, we give the text of the node name
8878 % again, so it is as if TeX is seeing it for the first time.
8879 %
8880 \ifdim \wd\printedmanualbox > 0pt
8881 % Cross-manual reference with a printed manual name.
8882 %
8883 \crossmanualxref{\cite{\printedmanual\unskip}}%
8884 %
8885 \else\ifdim \wd\infofilenamebox > 0pt
8886 % Cross-manual reference with only an info filename (arg 4), no
8887 % printed manual name (arg 5). This is essentially the same as
8888 % the case above; we output the filename, since we have nothing else.
8889 %
8890 \crossmanualxref{\code{\infofilename\unskip}}%
8891 %
8892 \else
8893 % Reference within this manual.
8894 %
8895 % Only output a following space if the -snt ref is nonempty, as the ref
8896 % will be empty for @unnumbered and @anchor.
8897 \setbox2 = \hbox{\ignorespaces \refx{#1-snt}}%
8898 \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
8899 %
8900 % output the `[mynode]' via the macro below so it can be overridden.
8901 \xrefprintnodename\printedrefname
8902 %
8903 \ifflagclear{txiomitxrefpg}{%
8904 % But we always want a comma and a space:
8905 ,\space
8906 %
8907 % output the `page 3'.
8908 \turnoffactive \putwordpage\tie\refx{#1-pg}%
8909 % Add a , if xref followed by a space
8910 \if\space\noexpand\tokenafterxref ,%
8911 \else\ifx\ \tokenafterxref ,% @TAB
8912 \else\ifx\*\tokenafterxref ,% @*
8913 \else\ifx\ \tokenafterxref ,% @SPACE
8914 \else\ifx\
8915 \tokenafterxref ,% @NL
8916 \else\ifx\tie\tokenafterxref ,% @tie
8917 \fi\fi\fi\fi\fi\fi
8918 }{}%
8919 \fi\fi
8920 \fi
8921 \endlink
8922\endgroup}
8923
8924% Output a cross-manual xref to #1. Used just above (twice).
8925%
8926% Only include the text "Section ``foo'' in" if the foo is neither
8927% missing or Top. Thus, @xref{,,,foo,The Foo Manual} outputs simply
8928% "see The Foo Manual", the idea being to refer to the whole manual.
8929%
8930% But, this being TeX, we can't easily compare our node name against the
8931% string "Top" while ignoring the possible spaces before and after in
8932% the input. By adding the arbitrary 7sp below, we make it much less
8933% likely that a real node name would have the same width as "Top" (e.g.,
8934% in a monospaced font). Hopefully it will never happen in practice.
8935%
8936% For the same basic reason, we retypeset the "Top" at every
8937% reference, since the current font is indeterminate.
8938%
8939\def\crossmanualxref#1{%
8940 \setbox\toprefbox = \hbox{Top\kern7sp}%
8941 \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}%
8942 \ifdim \wd2 > 7sp % nonempty?
8943 \ifdim \wd2 = \wd\toprefbox \else % same as Top?
8944 \putwordSection{} ``\printedrefname'' \putwordin{}\space
8945 \fi
8946 \fi
8947 #1%
8948}
8949
8950% This macro is called from \xrefX for the `[nodename]' part of xref
8951% output. It's a separate macro only so it can be changed more easily,
8952% since square brackets don't work well in some documents. Particularly
8953% one that Bob is working on :).
8954%
8955\def\xrefprintnodename#1{[#1]}
8956
8957% Things referred to by \setref.
8958%
8959\def\Ynothing{}
8960\def\Yomitfromtoc{}
8961\def\Ynumbered{%
8962 \ifnum\secno=0
8963 \putwordChapter@tie \the\chapno
8964 \else \ifnum\subsecno=0
8965 \putwordSection@tie \the\chapno.\the\secno
8966 \else \ifnum\subsubsecno=0
8967 \putwordSection@tie \the\chapno.\the\secno.\the\subsecno
8968 \else
8969 \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno
8970 \fi\fi\fi
8971}
8972\def\Yappendix{%
8973 \ifnum\secno=0
8974 \putwordAppendix@tie @char\the\appendixno{}%
8975 \else \ifnum\subsecno=0
8976 \putwordSection@tie @char\the\appendixno.\the\secno
8977 \else \ifnum\subsubsecno=0
8978 \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno
8979 \else
8980 \putwordSection@tie
8981 @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno
8982 \fi\fi\fi
8983}
8984
8985% \refx{NAME} - reference a cross-reference string named NAME.
8986\def\refx#1{%
8987 \requireauxfile
8988 {%
8989 \indexnofonts
8990 \turnoffactive
8991 \def\value##1{##1}%
8992 \expandafter\global\expandafter\let\expandafter\thisrefX
8993 \csname XR#1\endcsname
8994 }%
8995 \ifx\thisrefX\relax
8996 % If not defined, say something at least.
8997 \angleleft un\-de\-fined\angleright
8998 \iflinks
8999 \ifhavexrefs
9000 {\toks0 = {#1}% avoid expansion of possibly-complex value
9001 \message{\linenumber Undefined cross reference `\the\toks0'.}}%
9002 \else
9003 \ifwarnedxrefs\else
9004 \global\warnedxrefstrue
9005 \message{Cross reference values unknown; you must run TeX again.}%
9006 \fi
9007 \fi
9008 \fi
9009 \else
9010 % It's defined, so just use it.
9011 \thisrefX
9012 \fi
9013}
9014
9015% This is the macro invoked by entries in the aux file. Define a control
9016% sequence for a cross-reference target (we prepend XR to the control sequence
9017% name to avoid collisions). The value is the page number. If this is a float
9018% type, we have more work to do.
9019%
9020\def\xrdef#1#2{%
9021 {% Expand the node or anchor name to remove control sequences.
9022 % \turnoffactive stops 8-bit characters being changed to commands
9023 % like @'e. \refx does the same to retrieve the value in the definition.
9024 \indexnofonts
9025 \turnoffactive
9026 \def\value##1{##1}%
9027 \xdef\safexrefname{#1}%
9028 }%
9029 %
9030 \bgroup
9031 \expandafter\gdef\csname XR\safexrefname\endcsname{#2}%
9032 \egroup
9033 % We put the \gdef inside a group to avoid the definitions building up on
9034 % TeX's save stack, which can cause it to run out of space for aux files with
9035 % thousands of lines. \gdef doesn't use the save stack, but \csname does
9036 % when it defines an unknown control sequence as \relax.
9037 %
9038 % Was that xref control sequence that we just defined for a float?
9039 \expandafter\iffloat\csname XR\safexrefname\endcsname
9040 % it was a float, and we have the (safe) float type in \iffloattype.
9041 \expandafter\let\expandafter\floatlist
9042 \csname floatlist\iffloattype\endcsname
9043 %
9044 % Is this the first time we've seen this float type?
9045 \expandafter\ifx\floatlist\relax
9046 \toks0 = {\do}% yes, so just \do
9047 \else
9048 % had it before, so preserve previous elements in list.
9049 \toks0 = \expandafter{\floatlist\do}%
9050 \fi
9051 %
9052 % Remember this xref in the control sequence \floatlistFLOATTYPE,
9053 % for later use in \listoffloats.
9054 \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0
9055 {\safexrefname}}%
9056 \fi
9057}
9058
9059% If working on a large document in chapters, it is convenient to
9060% be able to disable indexing, cross-referencing, and contents, for test runs.
9061% This is done with @novalidate at the beginning of the file.
9062%
9063\newif\iflinks \linkstrue % by default we want the aux files.
9064\let\novalidate = \linksfalse
9065
9066% Used when writing to the aux file, or when using data from it.
9067\def\requireauxfile{%
9068 \iflinks
9069 \tryauxfile
9070 % Open the new aux file. TeX will close it automatically at exit.
9071 \immediate\openout\auxfile=\jobname.aux
9072 \fi
9073 \global\let\requireauxfile=\relax % Only do this once.
9074}
9075
9076% Read the last existing aux file, if any. No error if none exists.
9077%
9078\def\tryauxfile{%
9079 \openin 1 \jobname.aux
9080 \ifeof 1 \else
9081 \readdatafile{aux}%
9082 \global\havexrefstrue
9083 \fi
9084 \closein 1
9085}
9086
9087\def\setupdatafile{%
9088 \catcode`\^^@=\other
9089 \catcode`\^^A=\other
9090 \catcode`\^^B=\other
9091 \catcode`\^^C=\other
9092 \catcode`\^^D=\other
9093 \catcode`\^^E=\other
9094 \catcode`\^^F=\other
9095 \catcode`\^^G=\other
9096 \catcode`\^^H=\other
9097 \catcode`\^^K=\other
9098 \catcode`\^^L=\other
9099 \catcode`\^^N=\other
9100 \catcode`\^^P=\other
9101 \catcode`\^^Q=\other
9102 \catcode`\^^R=\other
9103 \catcode`\^^S=\other
9104 \catcode`\^^T=\other
9105 \catcode`\^^U=\other
9106 \catcode`\^^V=\other
9107 \catcode`\^^W=\other
9108 \catcode`\^^X=\other
9109 \catcode`\^^Z=\other
9110 \catcode`\^^[=\other
9111 \catcode`\^^\=\other
9112 \catcode`\^^]=\other
9113 \catcode`\^^^=\other
9114 \catcode`\^^_=\other
9115 \catcode`\^=\other
9116 %
9117 % Special characters. Should be turned off anyway, but...
9118 \catcode`\~=\other
9119 \catcode`\[=\other
9120 \catcode`\]=\other
9121 \catcode`\"=\other
9122 \catcode`\_=\active
9123 \catcode`\|=\active
9124 \catcode`\<=\active
9125 \catcode`\>=\active
9126 \catcode`\$=\other
9127 \catcode`\#=\other
9128 \catcode`\&=\other
9129 \catcode`\%=\other
9130 \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
9131 %
9132 \catcode`\\=\active
9133 %
9134 % @ is our escape character in .aux files, and we need braces.
9135 \catcode`\{=1
9136 \catcode`\}=2
9137 \catcode`\@=0
9138}
9139
9140\def\readdatafile#1{%
9141\begingroup
9142 \setupdatafile
9143 \input\jobname.#1
9144\endgroup}
9145
9146
9147\message{insertions,}
9148% including footnotes.
9149
9150\newcount \footnoteno
9151
9152% The trailing space in the following definition for supereject is
9153% vital for proper filling; pages come out unaligned when you do a
9154% pagealignmacro call if that space before the closing brace is
9155% removed. (Generally, numeric constants should always be followed by a
9156% space to prevent strange expansion errors.)
9157\def\supereject{\par\penalty -20000\footnoteno =0 }
9158
9159% @footnotestyle is meaningful for Info output only.
9160\let\footnotestyle=\comment
9161
9162{\catcode `\@=11
9163%
9164% Auto-number footnotes. Otherwise like plain.
9165\gdef\footnote{%
9166 \global\advance\footnoteno by \@ne
9167 \edef\thisfootno{$^{\the\footnoteno}$}%
9168 %
9169 % In case the footnote comes at the end of a sentence, preserve the
9170 % extra spacing after we do the footnote number.
9171 \let\@sf\empty
9172 \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi
9173 %
9174 % Remove inadvertent blank space before typesetting the footnote number.
9175 \unskip
9176 \thisfootno\@sf
9177 \dofootnote
9178}%
9179
9180% Don't bother with the trickery in plain.tex to not require the
9181% footnote text as a parameter. Our footnotes don't need to be so general.
9182%
9183% Oh yes, they do; otherwise, @ifset (and anything else that uses
9184% \parseargline) fails inside footnotes because the tokens are fixed when
9185% the footnote is read. --karl, 16nov96.
9186%
9187\gdef\dofootnote{%
9188 \insert\footins\bgroup
9189 %
9190 % Nested footnotes are not supported in TeX, that would take a lot
9191 % more work. (\startsavinginserts does not suffice.)
9192 \let\footnote=\errfootnotenest
9193 %
9194 % We want to typeset this text as a normal paragraph, even if the
9195 % footnote reference occurs in (for example) a display environment.
9196 % So reset some parameters.
9197 \hsize=\txipagewidth
9198 \interlinepenalty\interfootnotelinepenalty
9199 \splittopskip\ht\strutbox % top baseline for broken footnotes
9200 \splitmaxdepth\dp\strutbox
9201 \floatingpenalty\@MM
9202 \leftskip\z@skip
9203 \rightskip\z@skip
9204 \spaceskip\z@skip
9205 \xspaceskip\z@skip
9206 \parindent\defaultparindent
9207 %
9208 \smallfonts \rm
9209 %
9210 % Because we use hanging indentation in footnotes, a @noindent appears
9211 % to exdent this text, so make it be a no-op. makeinfo does not use
9212 % hanging indentation so @noindent can still be needed within footnote
9213 % text after an @example or the like (not that this is good style).
9214 \let\noindent = \relax
9215 %
9216 % Hang the footnote text off the number. Use \everypar in case the
9217 % footnote extends for more than one paragraph.
9218 \everypar = {\hang}%
9219 \textindent{\thisfootno}%
9220 %
9221 % Don't crash into the line above the footnote text. Since this
9222 % expands into a box, it must come within the paragraph, lest it
9223 % provide a place where TeX can split the footnote.
9224 \footstrut
9225 %
9226 % Invoke rest of plain TeX footnote routine.
9227 \futurelet\next\fo@t
9228}
9229}%end \catcode `\@=11
9230
9231\def\errfootnotenest{%
9232 \errhelp=\EMsimple
9233 \errmessage{Nested footnotes not supported in texinfo.tex,
9234 even though they work in makeinfo; sorry}
9235}
9236
9237\def\errfootnoteheading{%
9238 \errhelp=\EMsimple
9239 \errmessage{Footnotes in chapters, sections, etc., are not supported}
9240}
9241
9242% In case a @footnote appears in a vbox, save the footnote text and create
9243% the real \insert just after the vbox finished. Otherwise, the insertion
9244% would be lost.
9245% Similarly, if a @footnote appears inside an alignment, save the footnote
9246% text to a box and make the \insert when a row of the table is finished.
9247% And the same can be done for other insert classes. --kasal, 16nov03.
9248%
9249% Replace the \insert primitive by a cheating macro.
9250% Deeper inside, just make sure that the saved insertions are not spilled
9251% out prematurely.
9252%
9253\def\startsavinginserts{%
9254 \ifx \insert\ptexinsert
9255 \let\insert\saveinsert
9256 \else
9257 \let\checkinserts\relax
9258 \fi
9259}
9260
9261% This \insert replacement works for both \insert\footins{foo} and
9262% \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}.
9263%
9264\def\saveinsert#1{%
9265 \edef\next{\noexpand\savetobox \makeSAVEname#1}%
9266 \afterassignment\next
9267 % swallow the left brace
9268 \let\temp =
9269}
9270\def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}}
9271\def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1}
9272
9273\def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi}
9274
9275\def\placesaveins#1{%
9276 \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname
9277 {\box#1}%
9278}
9279
9280% eat @SAVE -- beware, all of them have catcode \other:
9281{
9282 \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials % ;-)
9283 \gdef\gobblesave @SAVE{}
9284}
9285
9286% initialization:
9287\def\newsaveins #1{%
9288 \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}%
9289 \next
9290}
9291\def\newsaveinsX #1{%
9292 \csname newbox\endcsname #1%
9293 \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts
9294 \checksaveins #1}%
9295}
9296
9297% initialize:
9298\let\checkinserts\empty
9299\newsaveins\footins
9300\newsaveins\margin
9301
9302
9303% @image. We use the macros from epsf.tex to support this.
9304% If epsf.tex is not installed and @image is used, we complain.
9305%
9306% Check for and read epsf.tex up front. If we read it only at @image
9307% time, we might be inside a group, and then its definitions would get
9308% undone and the next image would fail.
9309\openin 1 = epsf.tex
9310\ifeof 1 \else
9311 % Do not bother showing banner with epsf.tex v2.7k (available in
9312 % doc/epsf.tex and on ctan).
9313 \def\epsfannounce{\toks0 = }%
9314 \input epsf.tex
9315\fi
9316\closein 1
9317%
9318% We will only complain once about lack of epsf.tex.
9319\newif\ifwarnednoepsf
9320\newhelp\noepsfhelp{epsf.tex must be installed for images to
9321 work. It is also included in the Texinfo distribution, or you can get
9322 it from https://ctan.org/texarchive/macros/texinfo/texinfo/doc/epsf.tex.}
9323%
9324\def\image#1{%
9325 \ifx\epsfbox\thisisundefined
9326 \ifwarnednoepsf \else
9327 \errhelp = \noepsfhelp
9328 \errmessage{epsf.tex not found, images will be ignored}%
9329 \global\warnednoepsftrue
9330 \fi
9331 \else
9332 \imagexxx #1,,,,,\finish
9333 \fi
9334}
9335
9336% Approximate height of a line in the standard text font.
9337\newdimen\capheight
9338\setbox0=\vbox{\tenrm H}
9339\capheight=\ht0
9340
9341%
9342% Arguments to @image:
9343% #1 is (mandatory) image filename; we tack on .eps extension.
9344% #2 is (optional) width, #3 is (optional) height.
9345% #4 is (ignored optional) html alt text.
9346% #5 is (ignored optional) extension.
9347% #6 is just the usual extra ignored arg for parsing stuff.
9348\newif\ifimagevmode
9349\def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup
9350 \catcode`\^^M = 5 % in case we're inside an example
9351 \normalturnoffactive % allow _ et al. in names
9352 \makevalueexpandable
9353 \ifvmode
9354 \imagevmodetrue
9355 \medskip
9356 % Usually we'll have text after the image which will insert
9357 % \parskip glue, so insert it here too to equalize the space
9358 % above and below.
9359 \vskip\parskip
9360 %
9361 % Place image in a \vtop for a top page margin that is (close to) correct,
9362 % as \topskip glue is relative to the first baseline.
9363 \vtop\bgroup \kern -\capheight \vskip-\parskip
9364 \fi
9365 %
9366 \ifx\centersub\centerV
9367 % For @center @image, enter vertical mode and add vertical space
9368 % Enter an extra \parskip because @center doesn't add space itself.
9369 \vbox\bgroup\vskip\parskip\medskip\vskip\parskip
9370 \else
9371 % Enter horizontal mode so that indentation from an enclosing
9372 % environment such as @quotation is respected.
9373 % However, if we're at the top level, we don't want the
9374 % normal paragraph indentation.
9375 \imageindent
9376 \fi
9377 %
9378 % Output the image.
9379 \ifpdf
9380 % For pdfTeX and LuaTeX <= 0.80
9381 \dopdfimage{#1}{#2}{#3}%
9382 \else
9383 \ifx\XeTeXrevision\thisisundefined
9384 % For epsf.tex
9385 % \epsfbox itself resets \epsf?size at each figure.
9386 \setbox0 = \hbox{\ignorespaces #2}%
9387 \ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
9388 \setbox0 = \hbox{\ignorespaces #3}%
9389 \ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
9390 \epsfbox{#1.eps}%
9391 \else
9392 % For XeTeX
9393 \doxeteximage{#1}{#2}{#3}%
9394 \fi
9395 \fi
9396 %
9397 \ifimagevmode
9398 \egroup
9399 \medskip % space after a standalone image
9400 \fi
9401 \ifx\centersub\centerV % @center @image
9402 \medskip
9403 \egroup % close \vbox
9404 \fi
9405\endgroup}
9406
9407
9408% @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables,
9409% etc. We don't actually implement floating yet, we always include the
9410% float "here". But it seemed the best name for the future.
9411%
9412\envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish}
9413
9414% There may be a space before second and/or third parameter; delete it.
9415\def\eatcommaspace#1, {#1,}
9416
9417% #1 is the optional FLOATTYPE, the text label for this float, typically
9418% "Figure", "Table", "Example", etc. Can't contain commas. If omitted,
9419% this float will not be numbered and cannot be referred to.
9420%
9421% #2 is the optional xref label. Also must be present for the float to
9422% be referable.
9423%
9424% #3 is the optional positioning argument; for now, it is ignored. It
9425% will somehow specify the positions allowed to float to (here, top, bottom).
9426%
9427% We keep a separate counter for each FLOATTYPE, which we reset at each
9428% chapter-level command.
9429\let\resetallfloatnos=\empty
9430%
9431\def\dofloat#1,#2,#3,#4\finish{%
9432 \let\thiscaption=\empty
9433 \let\thisshortcaption=\empty
9434 %
9435 % don't lose footnotes inside @float.
9436 %
9437 % BEWARE: when the floats start float, we have to issue warning whenever an
9438 % insert appears inside a float which could possibly float. --kasal, 26may04
9439 %
9440 \startsavinginserts
9441 %
9442 % We can't be used inside a paragraph.
9443 \par
9444 %
9445 \vtop\bgroup
9446 \def\floattype{#1}%
9447 \def\floatlabel{#2}%
9448 \def\floatloc{#3}% we do nothing with this yet.
9449 %
9450 \ifx\floattype\empty
9451 \let\safefloattype=\empty
9452 \else
9453 {%
9454 % the floattype might have accents or other special characters,
9455 % but we need to use it in a control sequence name.
9456 \indexnofonts
9457 \turnoffactive
9458 \xdef\safefloattype{\floattype}%
9459 }%
9460 \fi
9461 %
9462 % If label is given but no type, we handle that as the empty type.
9463 \ifx\floatlabel\empty \else
9464 % We want each FLOATTYPE to be numbered separately (Figure 1,
9465 % Table 1, Figure 2, ...). (And if no label, no number.)
9466 %
9467 \expandafter\getfloatno\csname\safefloattype floatno\endcsname
9468 \global\advance\floatno by 1
9469 %
9470 {%
9471 % This magic value for \currentsection is output by \setref as the
9472 % XREFLABEL-title value. \xrefX uses it to distinguish float
9473 % labels (which have a completely different output format) from
9474 % node and anchor labels. And \xrdef uses it to construct the
9475 % lists of floats.
9476 %
9477 \edef\currentsection{\floatmagic=\safefloattype}%
9478 \setref{\floatlabel}{Yfloat}%
9479 }%
9480 \fi
9481 %
9482 % start with \parskip glue, I guess.
9483 \vskip\parskip
9484 %
9485 % Don't suppress indentation if a float happens to start a section.
9486 \restorefirstparagraphindent
9487}
9488
9489% we have these possibilities:
9490% @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap
9491% @float Foo,lbl & no caption: Foo 1.1
9492% @float Foo & @caption{Cap}: Foo: Cap
9493% @float Foo & no caption: Foo
9494% @float ,lbl & Caption{Cap}: 1.1: Cap
9495% @float ,lbl & no caption: 1.1
9496% @float & @caption{Cap}: Cap
9497% @float & no caption:
9498%
9499\def\Efloat{%
9500 \let\floatident = \empty
9501 %
9502 % In all cases, if we have a float type, it comes first.
9503 \ifx\floattype\empty \else \def\floatident{\floattype}\fi
9504 %
9505 % If we have an xref label, the number comes next.
9506 \ifx\floatlabel\empty \else
9507 \ifx\floattype\empty \else % if also had float type, need tie first.
9508 \appendtomacro\floatident{\tie}%
9509 \fi
9510 % the number.
9511 \appendtomacro\floatident{\chaplevelprefix\the\floatno}%
9512 \fi
9513 %
9514 % Start the printed caption with what we've constructed in
9515 % \floatident, but keep it separate; we need \floatident again.
9516 \let\captionline = \floatident
9517 %
9518 \ifx\thiscaption\empty \else
9519 \ifx\floatident\empty \else
9520 \appendtomacro\captionline{: }% had ident, so need a colon between
9521 \fi
9522 %
9523 % caption text.
9524 \appendtomacro\captionline{\scanexp\thiscaption}%
9525 \fi
9526 %
9527 % If we have anything to print, print it, with space before.
9528 % Eventually this needs to become an \insert.
9529 \ifx\captionline\empty \else
9530 \vskip.5\parskip
9531 \captionline
9532 %
9533 % Space below caption.
9534 \vskip\parskip
9535 \fi
9536 %
9537 % If have an xref label, write the list of floats info. Do this
9538 % after the caption, to avoid chance of it being a breakpoint.
9539 \ifx\floatlabel\empty \else
9540 % Write the text that goes in the lof to the aux file as
9541 % \floatlabel-lof. Besides \floatident, we include the short
9542 % caption if specified, else the full caption if specified, else nothing.
9543 {%
9544 \requireauxfile
9545 \atdummies
9546 %
9547 \ifx\thisshortcaption\empty
9548 \def\gtemp{\thiscaption}%
9549 \else
9550 \def\gtemp{\thisshortcaption}%
9551 \fi
9552 \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident
9553 \ifx\gtemp\empty \else : \gtemp \fi}}%
9554 }%
9555 \fi
9556 \egroup % end of \vtop
9557 %
9558 \checkinserts
9559}
9560
9561% Append the tokens #2 to the definition of macro #1, not expanding either.
9562%
9563\def\appendtomacro#1#2{%
9564 \expandafter\def\expandafter#1\expandafter{#1#2}%
9565}
9566
9567% @caption, @shortcaption
9568%
9569\def\caption{\docaption\thiscaption}
9570\def\shortcaption{\docaption\thisshortcaption}
9571\def\docaption{\checkenv\float \bgroup\scanctxt\defcaption}
9572\def\defcaption#1#2{\egroup \def#1{#2}}
9573
9574% The parameter is the control sequence identifying the counter we are
9575% going to use. Create it if it doesn't exist and assign it to \floatno.
9576\def\getfloatno#1{%
9577 \ifx#1\relax
9578 % Haven't seen this figure type before.
9579 \csname newcount\endcsname #1%
9580 %
9581 % Remember to reset this floatno at the next chap.
9582 \expandafter\gdef\expandafter\resetallfloatnos
9583 \expandafter{\resetallfloatnos #1=0 }%
9584 \fi
9585 \let\floatno#1%
9586}
9587
9588% \setref calls this to get the XREFLABEL-snt value. We want an @xref
9589% to the FLOATLABEL to expand to "Figure 3.1". We call \setref when we
9590% first read the @float command.
9591%
9592\def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}%
9593
9594% Magic string used for the XREFLABEL-title value, so \xrefX can
9595% distinguish floats from other xref types.
9596\def\floatmagic{!!float!!}
9597
9598% #1 is the control sequence we are passed; we expand into a conditional
9599% which is true if #1 represents a float ref. That is, the magic
9600% \currentsection value which we \setref above.
9601%
9602\def\iffloat#1{\expandafter\doiffloat#1==\finish}
9603%
9604% #1 is (maybe) the \floatmagic string. If so, #2 will be the
9605% (safe) float type for this float. We set \iffloattype to #2.
9606%
9607\def\doiffloat#1=#2=#3\finish{%
9608 \def\temp{#1}%
9609 \def\iffloattype{#2}%
9610 \ifx\temp\floatmagic
9611}
9612
9613% @listoffloats FLOATTYPE - print a list of floats like a table of contents.
9614%
9615\parseargdef\listoffloats{%
9616 \def\floattype{#1}% floattype
9617 {%
9618 % the floattype might have accents or other special characters,
9619 % but we need to use it in a control sequence name.
9620 \indexnofonts
9621 \turnoffactive
9622 \xdef\safefloattype{\floattype}%
9623 }%
9624 %
9625 % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE.
9626 \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax
9627 \ifhavexrefs
9628 % if the user said @listoffloats foo but never @float foo.
9629 \message{\linenumber No `\safefloattype' floats to list.}%
9630 \fi
9631 \else
9632 \begingroup
9633 \leftskip=\tocindent % indent these entries like a toc
9634 \let\do=\listoffloatsdo
9635 \csname floatlist\safefloattype\endcsname
9636 \endgroup
9637 \fi
9638}
9639
9640% This is called on each entry in a list of floats. We're passed the
9641% xref label, in the form LABEL-title, which is how we save it in the
9642% aux file. We strip off the -title and look up \XRLABEL-lof, which
9643% has the text we're supposed to typeset here.
9644%
9645% Figures without xref labels will not be included in the list (since
9646% they won't appear in the aux file).
9647%
9648\def\listoffloatsdo#1{\listoffloatsdoentry#1\finish}
9649\def\listoffloatsdoentry#1-title\finish{{%
9650 % Can't fully expand XR#1-lof because it can contain anything. Just
9651 % pass the control sequence. On the other hand, XR#1-pg is just the
9652 % page number, and we want to fully expand that so we can get a link
9653 % in pdf output.
9654 \toksA = \expandafter{\csname XR#1-lof\endcsname}%
9655 %
9656 % use the same \entry macro we use to generate the TOC and index.
9657 \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}%
9658 \writeentry
9659}}
9660
9661
9662\message{localization,}
9663
9664% For single-language documents, @documentlanguage is usually given very
9665% early, just after @documentencoding. Single argument is the language
9666% (de) or locale (de_DE) abbreviation.
9667%
9668{
9669 \catcode`\_ = \active
9670 \globaldefs=1
9671\parseargdef\documentlanguage{%
9672 \tex % read txi-??.tex file in plain TeX.
9673 % Read the file by the name they passed if it exists.
9674 \let_ = \normalunderscore % normal _ character for filename test
9675 \openin 1 txi-#1.tex
9676 \ifeof 1
9677 \documentlanguagetrywithoutunderscore #1_\finish
9678 \else
9679 \globaldefs = 1 % everything in the txi-LL files needs to persist
9680 \input txi-#1.tex
9681 \fi
9682 \closein 1
9683 \endgroup % end raw TeX
9684}
9685%
9686% If they passed de_DE, and txi-de_DE.tex doesn't exist,
9687% try txi-de.tex.
9688%
9689\gdef\documentlanguagetrywithoutunderscore#1_#2\finish{%
9690 \openin 1 txi-#1.tex
9691 \ifeof 1
9692 \errhelp = \nolanghelp
9693 \errmessage{Cannot read language file txi-#1.tex}%
9694 \else
9695 \globaldefs = 1 % everything in the txi-LL files needs to persist
9696 \input txi-#1.tex
9697 \fi
9698 \closein 1
9699}
9700}% end of special _ catcode
9701%
9702\newhelp\nolanghelp{The given language definition file cannot be found or
9703is empty. Maybe you need to install it? Putting it in the current
9704directory should work if nowhere else does.}
9705
9706% This macro is called from txi-??.tex files; the first argument is the
9707% \language name to set (without the "\lang@" prefix), the second and
9708% third args are \{left,right}hyphenmin.
9709%
9710% The language names to pass are determined when the format is built.
9711% See the etex.log file created at that time, e.g.,
9712% /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log.
9713%
9714% With TeX Live 2008, etex now includes hyphenation patterns for all
9715% available languages. This means we can support hyphenation in
9716% Texinfo, at least to some extent. (This still doesn't solve the
9717% accented characters problem.)
9718%
9719\catcode`@=11
9720\def\txisetlanguage#1#2#3{%
9721 % do not set the language if the name is undefined in the current TeX.
9722 \expandafter\ifx\csname lang@#1\endcsname \relax
9723 \message{no patterns for #1}%
9724 \else
9725 \global\language = \csname lang@#1\endcsname
9726 \fi
9727 % but there is no harm in adjusting the hyphenmin values regardless.
9728 \global\lefthyphenmin = #2\relax
9729 \global\righthyphenmin = #3\relax
9730}
9731
9732% XeTeX and LuaTeX can handle Unicode natively.
9733% Their default I/O uses UTF-8 sequences instead of a byte-wise operation.
9734% Other TeX engines' I/O (pdfTeX, etc.) is byte-wise.
9735%
9736\newif\iftxinativeunicodecapable
9737\newif\iftxiusebytewiseio
9738
9739\ifx\XeTeXrevision\thisisundefined
9740 \ifx\luatexversion\thisisundefined
9741 \txinativeunicodecapablefalse
9742 \txiusebytewiseiotrue
9743 \else
9744 \txinativeunicodecapabletrue
9745 \txiusebytewiseiofalse
9746 \fi
9747\else
9748 \txinativeunicodecapabletrue
9749 \txiusebytewiseiofalse
9750\fi
9751
9752% Set I/O by bytes instead of UTF-8 sequence for XeTeX and LuaTex
9753% for non-UTF-8 (byte-wise) encodings.
9754%
9755\def\setbytewiseio{%
9756 \ifx\XeTeXrevision\thisisundefined
9757 \else
9758 \XeTeXdefaultencoding "bytes" % For subsequent files to be read
9759 \XeTeXinputencoding "bytes" % For document root file
9760 % Unfortunately, there seems to be no corresponding XeTeX command for
9761 % output encoding. This is a problem for auxiliary index and TOC files.
9762 % The only solution would be perhaps to write out @U{...} sequences in
9763 % place of non-ASCII characters.
9764 \fi
9765
9766 \ifx\luatexversion\thisisundefined
9767 \else
9768 \directlua{
9769 local utf8_char, byte, gsub = unicode.utf8.char, string.byte, string.gsub
9770 local function convert_char (char)
9771 return utf8_char(byte(char))
9772 end
9773
9774 local function convert_line (line)
9775 return gsub(line, ".", convert_char)
9776 end
9777
9778 callback.register("process_input_buffer", convert_line)
9779
9780 local function convert_line_out (line)
9781 local line_out = ""
9782 for c in string.utfvalues(line) do
9783 line_out = line_out .. string.char(c)
9784 end
9785 return line_out
9786 end
9787
9788 callback.register("process_output_buffer", convert_line_out)
9789 }
9790 \fi
9791
9792 \txiusebytewiseiotrue
9793}
9794
9795
9796% Helpers for encodings.
9797% Set the catcode of characters 128 through 255 to the specified number.
9798%
9799\def\setnonasciicharscatcode#1{%
9800 \count255=128
9801 \loop\ifnum\count255<256
9802 \global\catcode\count255=#1\relax
9803 \advance\count255 by 1
9804 \repeat
9805}
9806
9807\def\setnonasciicharscatcodenonglobal#1{%
9808 \count255=128
9809 \loop\ifnum\count255<256
9810 \catcode\count255=#1\relax
9811 \advance\count255 by 1
9812 \repeat
9813}
9814
9815% @documentencoding sets the definition of non-ASCII characters
9816% according to the specified encoding.
9817%
9818\def\documentencoding{\parseargusing\filenamecatcodes\documentencodingzzz}
9819\def\documentencodingzzz#1{%
9820 %
9821 % Encoding being declared for the document.
9822 \def\declaredencoding{\csname #1.enc\endcsname}%
9823 %
9824 % Supported encodings: names converted to tokens in order to be able
9825 % to compare them with \ifx.
9826 \def\ascii{\csname US-ASCII.enc\endcsname}%
9827 \def\latnine{\csname ISO-8859-15.enc\endcsname}%
9828 \def\latone{\csname ISO-8859-1.enc\endcsname}%
9829 \def\lattwo{\csname ISO-8859-2.enc\endcsname}%
9830 \def\utfeight{\csname UTF-8.enc\endcsname}%
9831 %
9832 \ifx \declaredencoding \ascii
9833 \asciichardefs
9834 %
9835 \else \ifx \declaredencoding \lattwo
9836 \iftxinativeunicodecapable
9837 \setbytewiseio
9838 \fi
9839 \setnonasciicharscatcode\active
9840 \lattwochardefs
9841 %
9842 \else \ifx \declaredencoding \latone
9843 \iftxinativeunicodecapable
9844 \setbytewiseio
9845 \fi
9846 \setnonasciicharscatcode\active
9847 \latonechardefs
9848 %
9849 \else \ifx \declaredencoding \latnine
9850 \iftxinativeunicodecapable
9851 \setbytewiseio
9852 \fi
9853 \setnonasciicharscatcode\active
9854 \latninechardefs
9855 %
9856 \else \ifx \declaredencoding \utfeight
9857 \iftxinativeunicodecapable
9858 % For native Unicode handling (XeTeX and LuaTeX)
9859 \nativeunicodechardefs
9860 \else
9861 % For treating UTF-8 as byte sequences (TeX, eTeX and pdfTeX)
9862 \setnonasciicharscatcode\active
9863 % since we already invoked \utfeightchardefs at the top level
9864 % (below), do not re-invoke it, otherwise our check for duplicated
9865 % definitions gets triggered. Making non-ascii chars active is
9866 % sufficient.
9867 \fi
9868 %
9869 \else
9870 \message{Ignoring unknown document encoding: #1.}%
9871 %
9872 \fi % utfeight
9873 \fi % latnine
9874 \fi % latone
9875 \fi % lattwo
9876 \fi % ascii
9877 %
9878 \ifx\XeTeXrevision\thisisundefined
9879 \else
9880 \ifx \declaredencoding \utfeight
9881 \else
9882 \ifx \declaredencoding \ascii
9883 \else
9884 \message{Warning: XeTeX with non-UTF-8 encodings cannot handle %
9885 non-ASCII characters in auxiliary files.}%
9886 \fi
9887 \fi
9888 \fi
9889}
9890
9891% emacs-page
9892% A message to be logged when using a character that isn't available
9893% the default font encoding (OT1).
9894%
9895\def\missingcharmsg#1{\message{Character missing, sorry: #1.}}
9896
9897% Take account of \c (plain) vs. \, (Texinfo) difference.
9898\def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi}
9899
9900% First, make active non-ASCII characters in order for them to be
9901% correctly categorized when TeX reads the replacement text of
9902% macros containing the character definitions.
9903\setnonasciicharscatcode\active
9904%
9905
9906\def\gdefchar#1#2{%
9907\gdef#1{%
9908 \ifpassthroughchars
9909 \string#1%
9910 \else
9911 #2%
9912 \fi
9913}}
9914
9915% Latin1 (ISO-8859-1) character definitions.
9916\def\latonechardefs{%
9917 \gdefchar^^a0{\tie}
9918 \gdefchar^^a1{\exclamdown}
9919 \gdefchar^^a2{{\tcfont \char162}} % cent
9920 \gdefchar^^a3{\pounds{}}
9921 \gdefchar^^a4{{\tcfont \char164}} % currency
9922 \gdefchar^^a5{{\tcfont \char165}} % yen
9923 \gdefchar^^a6{{\tcfont \char166}} % broken bar
9924 \gdefchar^^a7{\S}
9925 \gdefchar^^a8{\"{}}
9926 \gdefchar^^a9{\copyright{}}
9927 \gdefchar^^aa{\ordf}
9928 \gdefchar^^ab{\guillemetleft{}}
9929 \gdefchar^^ac{\ensuremath\lnot}
9930 \gdefchar^^ad{\-}
9931 \gdefchar^^ae{\registeredsymbol{}}
9932 \gdefchar^^af{\={}}
9933 %
9934 \gdefchar^^b0{\textdegree}
9935 \gdefchar^^b1{$\pm$}
9936 \gdefchar^^b2{$^2$}
9937 \gdefchar^^b3{$^3$}
9938 \gdefchar^^b4{\'{}}
9939 \gdefchar^^b5{$\mu$}
9940 \gdefchar^^b6{\P}
9941 \gdefchar^^b7{\ensuremath\cdot}
9942 \gdefchar^^b8{\cedilla\ }
9943 \gdefchar^^b9{$^1$}
9944 \gdefchar^^ba{\ordm}
9945 \gdefchar^^bb{\guillemetright{}}
9946 \gdefchar^^bc{$1\over4$}
9947 \gdefchar^^bd{$1\over2$}
9948 \gdefchar^^be{$3\over4$}
9949 \gdefchar^^bf{\questiondown}
9950 %
9951 \gdefchar^^c0{\`A}
9952 \gdefchar^^c1{\'A}
9953 \gdefchar^^c2{\^A}
9954 \gdefchar^^c3{\~A}
9955 \gdefchar^^c4{\"A}
9956 \gdefchar^^c5{\ringaccent A}
9957 \gdefchar^^c6{\AE}
9958 \gdefchar^^c7{\cedilla C}
9959 \gdefchar^^c8{\`E}
9960 \gdefchar^^c9{\'E}
9961 \gdefchar^^ca{\^E}
9962 \gdefchar^^cb{\"E}
9963 \gdefchar^^cc{\`I}
9964 \gdefchar^^cd{\'I}
9965 \gdefchar^^ce{\^I}
9966 \gdefchar^^cf{\"I}
9967 %
9968 \gdefchar^^d0{\DH}
9969 \gdefchar^^d1{\~N}
9970 \gdefchar^^d2{\`O}
9971 \gdefchar^^d3{\'O}
9972 \gdefchar^^d4{\^O}
9973 \gdefchar^^d5{\~O}
9974 \gdefchar^^d6{\"O}
9975 \gdefchar^^d7{$\times$}
9976 \gdefchar^^d8{\O}
9977 \gdefchar^^d9{\`U}
9978 \gdefchar^^da{\'U}
9979 \gdefchar^^db{\^U}
9980 \gdefchar^^dc{\"U}
9981 \gdefchar^^dd{\'Y}
9982 \gdefchar^^de{\TH}
9983 \gdefchar^^df{\ss}
9984 %
9985 \gdefchar^^e0{\`a}
9986 \gdefchar^^e1{\'a}
9987 \gdefchar^^e2{\^a}
9988 \gdefchar^^e3{\~a}
9989 \gdefchar^^e4{\"a}
9990 \gdefchar^^e5{\ringaccent a}
9991 \gdefchar^^e6{\ae}
9992 \gdefchar^^e7{\cedilla c}
9993 \gdefchar^^e8{\`e}
9994 \gdefchar^^e9{\'e}
9995 \gdefchar^^ea{\^e}
9996 \gdefchar^^eb{\"e}
9997 \gdefchar^^ec{\`{\dotless i}}
9998 \gdefchar^^ed{\'{\dotless i}}
9999 \gdefchar^^ee{\^{\dotless i}}
10000 \gdefchar^^ef{\"{\dotless i}}
10001 %
10002 \gdefchar^^f0{\dh}
10003 \gdefchar^^f1{\~n}
10004 \gdefchar^^f2{\`o}
10005 \gdefchar^^f3{\'o}
10006 \gdefchar^^f4{\^o}
10007 \gdefchar^^f5{\~o}
10008 \gdefchar^^f6{\"o}
10009 \gdefchar^^f7{$\div$}
10010 \gdefchar^^f8{\o}
10011 \gdefchar^^f9{\`u}
10012 \gdefchar^^fa{\'u}
10013 \gdefchar^^fb{\^u}
10014 \gdefchar^^fc{\"u}
10015 \gdefchar^^fd{\'y}
10016 \gdefchar^^fe{\th}
10017 \gdefchar^^ff{\"y}
10018}
10019
10020% Latin9 (ISO-8859-15) encoding character definitions.
10021\def\latninechardefs{%
10022 % Encoding is almost identical to Latin1.
10023 \latonechardefs
10024 %
10025 \gdefchar^^a4{\euro{}}
10026 \gdefchar^^a6{\v S}
10027 \gdefchar^^a8{\v s}
10028 \gdefchar^^b4{\v Z}
10029 \gdefchar^^b8{\v z}
10030 \gdefchar^^bc{\OE}
10031 \gdefchar^^bd{\oe}
10032 \gdefchar^^be{\"Y}
10033}
10034
10035% Latin2 (ISO-8859-2) character definitions.
10036\def\lattwochardefs{%
10037 \gdefchar^^a0{\tie}
10038 \gdefchar^^a1{\ogonek{A}}
10039 \gdefchar^^a2{\u{}}
10040 \gdefchar^^a3{\L}
10041 \gdefchar^^a4{\missingcharmsg{CURRENCY SIGN}}
10042 \gdefchar^^a5{\v L}
10043 \gdefchar^^a6{\'S}
10044 \gdefchar^^a7{\S}
10045 \gdefchar^^a8{\"{}}
10046 \gdefchar^^a9{\v S}
10047 \gdefchar^^aa{\cedilla S}
10048 \gdefchar^^ab{\v T}
10049 \gdefchar^^ac{\'Z}
10050 \gdefchar^^ad{\-}
10051 \gdefchar^^ae{\v Z}
10052 \gdefchar^^af{\dotaccent Z}
10053 %
10054 \gdefchar^^b0{\textdegree{}}
10055 \gdefchar^^b1{\ogonek{a}}
10056 \gdefchar^^b2{\ogonek{ }}
10057 \gdefchar^^b3{\l}
10058 \gdefchar^^b4{\'{}}
10059 \gdefchar^^b5{\v l}
10060 \gdefchar^^b6{\'s}
10061 \gdefchar^^b7{\v{}}
10062 \gdefchar^^b8{\cedilla\ }
10063 \gdefchar^^b9{\v s}
10064 \gdefchar^^ba{\cedilla s}
10065 \gdefchar^^bb{\v t}
10066 \gdefchar^^bc{\'z}
10067 \gdefchar^^bd{\H{}}
10068 \gdefchar^^be{\v z}
10069 \gdefchar^^bf{\dotaccent z}
10070 %
10071 \gdefchar^^c0{\'R}
10072 \gdefchar^^c1{\'A}
10073 \gdefchar^^c2{\^A}
10074 \gdefchar^^c3{\u A}
10075 \gdefchar^^c4{\"A}
10076 \gdefchar^^c5{\'L}
10077 \gdefchar^^c6{\'C}
10078 \gdefchar^^c7{\cedilla C}
10079 \gdefchar^^c8{\v C}
10080 \gdefchar^^c9{\'E}
10081 \gdefchar^^ca{\ogonek{E}}
10082 \gdefchar^^cb{\"E}
10083 \gdefchar^^cc{\v E}
10084 \gdefchar^^cd{\'I}
10085 \gdefchar^^ce{\^I}
10086 \gdefchar^^cf{\v D}
10087 %
10088 \gdefchar^^d0{\DH}
10089 \gdefchar^^d1{\'N}
10090 \gdefchar^^d2{\v N}
10091 \gdefchar^^d3{\'O}
10092 \gdefchar^^d4{\^O}
10093 \gdefchar^^d5{\H O}
10094 \gdefchar^^d6{\"O}
10095 \gdefchar^^d7{$\times$}
10096 \gdefchar^^d8{\v R}
10097 \gdefchar^^d9{\ringaccent U}
10098 \gdefchar^^da{\'U}
10099 \gdefchar^^db{\H U}
10100 \gdefchar^^dc{\"U}
10101 \gdefchar^^dd{\'Y}
10102 \gdefchar^^de{\cedilla T}
10103 \gdefchar^^df{\ss}
10104 %
10105 \gdefchar^^e0{\'r}
10106 \gdefchar^^e1{\'a}
10107 \gdefchar^^e2{\^a}
10108 \gdefchar^^e3{\u a}
10109 \gdefchar^^e4{\"a}
10110 \gdefchar^^e5{\'l}
10111 \gdefchar^^e6{\'c}
10112 \gdefchar^^e7{\cedilla c}
10113 \gdefchar^^e8{\v c}
10114 \gdefchar^^e9{\'e}
10115 \gdefchar^^ea{\ogonek{e}}
10116 \gdefchar^^eb{\"e}
10117 \gdefchar^^ec{\v e}
10118 \gdefchar^^ed{\'{\dotless{i}}}
10119 \gdefchar^^ee{\^{\dotless{i}}}
10120 \gdefchar^^ef{\v d}
10121 %
10122 \gdefchar^^f0{\dh}
10123 \gdefchar^^f1{\'n}
10124 \gdefchar^^f2{\v n}
10125 \gdefchar^^f3{\'o}
10126 \gdefchar^^f4{\^o}
10127 \gdefchar^^f5{\H o}
10128 \gdefchar^^f6{\"o}
10129 \gdefchar^^f7{$\div$}
10130 \gdefchar^^f8{\v r}
10131 \gdefchar^^f9{\ringaccent u}
10132 \gdefchar^^fa{\'u}
10133 \gdefchar^^fb{\H u}
10134 \gdefchar^^fc{\"u}
10135 \gdefchar^^fd{\'y}
10136 \gdefchar^^fe{\cedilla t}
10137 \gdefchar^^ff{\dotaccent{}}
10138}
10139
10140% UTF-8 character definitions.
10141%
10142% This code to support UTF-8 is based on LaTeX's utf8.def, with some
10143% changes for Texinfo conventions. It is included here under the GPL by
10144% permission from Frank Mittelbach and the LaTeX team.
10145%
10146\newcount\countUTFx
10147\newcount\countUTFy
10148\newcount\countUTFz
10149
10150\gdef\UTFviiiTwoOctets#1#2{\expandafter
10151 \UTFviiiDefined\csname u8:#1\string #2\endcsname}
10152%
10153\gdef\UTFviiiThreeOctets#1#2#3{\expandafter
10154 \UTFviiiDefined\csname u8:#1\string #2\string #3\endcsname}
10155%
10156\gdef\UTFviiiFourOctets#1#2#3#4{\expandafter
10157 \UTFviiiDefined\csname u8:#1\string #2\string #3\string #4\endcsname}
10158
10159\gdef\UTFviiiDefined#1{%
10160 \ifx #1\relax
10161 \message{\linenumber Unicode char \string #1 not defined for Texinfo}%
10162 \else
10163 \expandafter #1%
10164 \fi
10165}
10166
10167% Give non-ASCII bytes the active definitions for processing UTF-8 sequences
10168\begingroup
10169 \catcode`\~13
10170 \catcode`\$12
10171 \catcode`\"12
10172
10173 % Loop from \countUTFx to \countUTFy, performing \UTFviiiTmp
10174 % substituting ~ and $ with a character token of that value.
10175 \def\UTFviiiLoop{%
10176 \global\catcode\countUTFx\active
10177 \uccode`\~\countUTFx
10178 \uccode`\$\countUTFx
10179 \uppercase\expandafter{\UTFviiiTmp}%
10180 \advance\countUTFx by 1
10181 \ifnum\countUTFx < \countUTFy
10182 \expandafter\UTFviiiLoop
10183 \fi}
10184
10185 % For bytes other than the first in a UTF-8 sequence. Not expected to
10186 % be expanded except when writing to auxiliary files.
10187 \countUTFx = "80
10188 \countUTFy = "C2
10189 \def\UTFviiiTmp{%
10190 \gdef~{%
10191 \ifpassthroughchars $\fi}}%
10192 \UTFviiiLoop
10193
10194 \countUTFx = "C2
10195 \countUTFy = "E0
10196 \def\UTFviiiTmp{%
10197 \gdef~{%
10198 \ifpassthroughchars $%
10199 \else\expandafter\UTFviiiTwoOctets\expandafter$\fi}}%
10200 \UTFviiiLoop
10201
10202 \countUTFx = "E0
10203 \countUTFy = "F0
10204 \def\UTFviiiTmp{%
10205 \gdef~{%
10206 \ifpassthroughchars $%
10207 \else\expandafter\UTFviiiThreeOctets\expandafter$\fi}}%
10208 \UTFviiiLoop
10209
10210 \countUTFx = "F0
10211 \countUTFy = "F4
10212 \def\UTFviiiTmp{%
10213 \gdef~{%
10214 \ifpassthroughchars $%
10215 \else\expandafter\UTFviiiFourOctets\expandafter$\fi
10216 }}%
10217 \UTFviiiLoop
10218\endgroup
10219
10220\def\globallet{\global\let} % save some \expandafter's below
10221
10222% @U{xxxx} to produce U+xxxx, if we support it.
10223\def\U#1{%
10224 \expandafter\ifx\csname uni:#1\endcsname \relax
10225 \iftxinativeunicodecapable
10226 % All Unicode characters can be used if native Unicode handling is
10227 % active. However, if the font does not have the glyph,
10228 % letters are missing.
10229 \begingroup
10230 \uccode`\.="#1\relax
10231 \uppercase{.}
10232 \endgroup
10233 \else
10234 \errhelp = \EMsimple
10235 \errmessage{Unicode character U+#1 not supported, sorry}%
10236 \fi
10237 \else
10238 \csname uni:#1\endcsname
10239 \fi
10240}
10241
10242% These macros are used here to construct the name of a control
10243% sequence to be defined.
10244\def\UTFviiiTwoOctetsName#1#2{%
10245 \csname u8:#1\string #2\endcsname}%
10246\def\UTFviiiThreeOctetsName#1#2#3{%
10247 \csname u8:#1\string #2\string #3\endcsname}%
10248\def\UTFviiiFourOctetsName#1#2#3#4{%
10249 \csname u8:#1\string #2\string #3\string #4\endcsname}%
10250
10251% For UTF-8 byte sequences (TeX, e-TeX and pdfTeX),
10252% provide a definition macro to replace a Unicode character;
10253% this gets used by the @U command
10254%
10255\begingroup
10256 \catcode`\"=12
10257 \catcode`\<=12
10258 \catcode`\.=12
10259 \catcode`\,=12
10260 \catcode`\;=12
10261 \catcode`\!=12
10262 \catcode`\~=13
10263 \gdef\DeclareUnicodeCharacterUTFviii#1#2{%
10264 \countUTFz = "#1\relax
10265 \begingroup
10266 \parseXMLCharref
10267
10268 % Give \u8:... its definition. The sequence of seven \expandafter's
10269 % expands after the \gdef three times, e.g.
10270 %
10271 % 1. \UTFviiTwoOctetsName B1 B2
10272 % 2. \csname u8:B1 \string B2 \endcsname
10273 % 3. \u8: B1 B2 (a single control sequence token)
10274 %
10275 \expandafter\expandafter
10276 \expandafter\expandafter
10277 \expandafter\expandafter
10278 \expandafter\gdef \UTFviiiTmp{#2}%
10279 %
10280 \expandafter\ifx\csname uni:#1\endcsname \relax \else
10281 \message{Internal error, already defined: #1}%
10282 \fi
10283 %
10284 % define an additional control sequence for this code point.
10285 \expandafter\globallet\csname uni:#1\endcsname \UTFviiiTmp
10286 \endgroup}
10287 %
10288 % Given the value in \countUTFz as a Unicode code point, set \UTFviiiTmp
10289 % to the corresponding UTF-8 sequence.
10290 \gdef\parseXMLCharref{%
10291 \ifnum\countUTFz < "20\relax
10292 \errhelp = \EMsimple
10293 \errmessage{Cannot define Unicode char value < 0020}%
10294 \else\ifnum\countUTFz < "800\relax
10295 \parseUTFviiiA,%
10296 \parseUTFviiiB C\UTFviiiTwoOctetsName.,%
10297 \else\ifnum\countUTFz < "10000\relax
10298 \parseUTFviiiA;%
10299 \parseUTFviiiA,%
10300 \parseUTFviiiB E\UTFviiiThreeOctetsName.{,;}%
10301 \else
10302 \parseUTFviiiA;%
10303 \parseUTFviiiA,%
10304 \parseUTFviiiA!%
10305 \parseUTFviiiB F\UTFviiiFourOctetsName.{!,;}%
10306 \fi\fi\fi
10307 }
10308
10309 % Extract a byte from the end of the UTF-8 representation of \countUTFx.
10310 % It must be a non-initial byte in the sequence.
10311 % Change \uccode of #1 for it to be used in \parseUTFviiiB as one
10312 % of the bytes.
10313 \gdef\parseUTFviiiA#1{%
10314 \countUTFx = \countUTFz
10315 \divide\countUTFz by 64
10316 \countUTFy = \countUTFz % Save to be the future value of \countUTFz.
10317 \multiply\countUTFz by 64
10318
10319 % \countUTFz is now \countUTFx with the last 5 bits cleared. Subtract
10320 % in order to get the last five bits.
10321 \advance\countUTFx by -\countUTFz
10322
10323 % Convert this to the byte in the UTF-8 sequence.
10324 \advance\countUTFx by 128
10325 \uccode `#1\countUTFx
10326 \countUTFz = \countUTFy}
10327
10328 % Used to put a UTF-8 byte sequence into \UTFviiiTmp
10329 % #1 is the increment for \countUTFz to yield a the first byte of the UTF-8
10330 % sequence.
10331 % #2 is one of the \UTFviii*OctetsName macros.
10332 % #3 is always a full stop (.)
10333 % #4 is a template for the other bytes in the sequence. The values for these
10334 % bytes is substituted in here with \uppercase using the \uccode's.
10335 \gdef\parseUTFviiiB#1#2#3#4{%
10336 \advance\countUTFz by "#10\relax
10337 \uccode `#3\countUTFz
10338 \uppercase{\gdef\UTFviiiTmp{#2#3#4}}}
10339\endgroup
10340
10341% For native Unicode handling (XeTeX and LuaTeX),
10342% provide a definition macro that sets a catcode to `other' non-globally
10343%
10344\def\DeclareUnicodeCharacterNativeOther#1#2{%
10345 \catcode"#1=\other
10346}
10347
10348% https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_M
10349% U+0000..U+007F = https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block)
10350% U+0080..U+00FF = https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)
10351% U+0100..U+017F = https://en.wikipedia.org/wiki/Latin_Extended-A
10352% U+0180..U+024F = https://en.wikipedia.org/wiki/Latin_Extended-B
10353%
10354% Many of our renditions are less than wonderful, and all the missing
10355% characters are available somewhere. Loading the necessary fonts
10356% awaits user request. We can't truly support Unicode without
10357% reimplementing everything that's been done in LaTeX for many years,
10358% plus probably using luatex or xetex, and who knows what else.
10359% We won't be doing that here in this simple file. But we can try to at
10360% least make most of the characters not bomb out.
10361%
10362\def\unicodechardefs{%
10363 \DeclareUnicodeCharacter{0020}{ } % space
10364 \DeclareUnicodeCharacter{0021}{\char"21 }% % space to terminate number
10365 \DeclareUnicodeCharacter{0022}{\char"22 }%
10366 \DeclareUnicodeCharacter{0023}{\char"23 }%
10367 \DeclareUnicodeCharacter{0024}{\char"24 }%
10368 \DeclareUnicodeCharacter{0025}{\char"25 }%
10369 \DeclareUnicodeCharacter{0026}{\char"26 }%
10370 \DeclareUnicodeCharacter{0027}{\char"27 }%
10371 \DeclareUnicodeCharacter{0028}{\char"28 }%
10372 \DeclareUnicodeCharacter{0029}{\char"29 }%
10373 \DeclareUnicodeCharacter{002A}{\char"2A }%
10374 \DeclareUnicodeCharacter{002B}{\char"2B }%
10375 \DeclareUnicodeCharacter{002C}{\char"2C }%
10376 \DeclareUnicodeCharacter{002D}{\char"2D }%
10377 \DeclareUnicodeCharacter{002E}{\char"2E }%
10378 \DeclareUnicodeCharacter{002F}{\char"2F }%
10379 \DeclareUnicodeCharacter{0030}{0}%
10380 \DeclareUnicodeCharacter{0031}{1}%
10381 \DeclareUnicodeCharacter{0032}{2}%
10382 \DeclareUnicodeCharacter{0033}{3}%
10383 \DeclareUnicodeCharacter{0034}{4}%
10384 \DeclareUnicodeCharacter{0035}{5}%
10385 \DeclareUnicodeCharacter{0036}{6}%
10386 \DeclareUnicodeCharacter{0037}{7}%
10387 \DeclareUnicodeCharacter{0038}{8}%
10388 \DeclareUnicodeCharacter{0039}{9}%
10389 \DeclareUnicodeCharacter{003A}{\char"3A }%
10390 \DeclareUnicodeCharacter{003B}{\char"3B }%
10391 \DeclareUnicodeCharacter{003C}{\char"3C }%
10392 \DeclareUnicodeCharacter{003D}{\char"3D }%
10393 \DeclareUnicodeCharacter{003E}{\char"3E }%
10394 \DeclareUnicodeCharacter{003F}{\char"3F }%
10395 \DeclareUnicodeCharacter{0040}{\char"40 }%
10396 \DeclareUnicodeCharacter{0041}{A}%
10397 \DeclareUnicodeCharacter{0042}{B}%
10398 \DeclareUnicodeCharacter{0043}{C}%
10399 \DeclareUnicodeCharacter{0044}{D}%
10400 \DeclareUnicodeCharacter{0045}{E}%
10401 \DeclareUnicodeCharacter{0046}{F}%
10402 \DeclareUnicodeCharacter{0047}{G}%
10403 \DeclareUnicodeCharacter{0048}{H}%
10404 \DeclareUnicodeCharacter{0049}{I}%
10405 \DeclareUnicodeCharacter{004A}{J}%
10406 \DeclareUnicodeCharacter{004B}{K}%
10407 \DeclareUnicodeCharacter{004C}{L}%
10408 \DeclareUnicodeCharacter{004D}{M}%
10409 \DeclareUnicodeCharacter{004E}{N}%
10410 \DeclareUnicodeCharacter{004F}{O}%
10411 \DeclareUnicodeCharacter{0050}{P}%
10412 \DeclareUnicodeCharacter{0051}{Q}%
10413 \DeclareUnicodeCharacter{0052}{R}%
10414 \DeclareUnicodeCharacter{0053}{S}%
10415 \DeclareUnicodeCharacter{0054}{T}%
10416 \DeclareUnicodeCharacter{0055}{U}%
10417 \DeclareUnicodeCharacter{0056}{V}%
10418 \DeclareUnicodeCharacter{0057}{W}%
10419 \DeclareUnicodeCharacter{0058}{X}%
10420 \DeclareUnicodeCharacter{0059}{Y}%
10421 \DeclareUnicodeCharacter{005A}{Z}%
10422 \DeclareUnicodeCharacter{005B}{\char"5B }%
10423 \DeclareUnicodeCharacter{005C}{\char"5C }%
10424 \DeclareUnicodeCharacter{005D}{\char"5D }%
10425 \DeclareUnicodeCharacter{005E}{\char"5E }%
10426 \DeclareUnicodeCharacter{005F}{\char"5F }%
10427 \DeclareUnicodeCharacter{0060}{\char"60 }%
10428 \DeclareUnicodeCharacter{0061}{a}%
10429 \DeclareUnicodeCharacter{0062}{b}%
10430 \DeclareUnicodeCharacter{0063}{c}%
10431 \DeclareUnicodeCharacter{0064}{d}%
10432 \DeclareUnicodeCharacter{0065}{e}%
10433 \DeclareUnicodeCharacter{0066}{f}%
10434 \DeclareUnicodeCharacter{0067}{g}%
10435 \DeclareUnicodeCharacter{0068}{h}%
10436 \DeclareUnicodeCharacter{0069}{i}%
10437 \DeclareUnicodeCharacter{006A}{j}%
10438 \DeclareUnicodeCharacter{006B}{k}%
10439 \DeclareUnicodeCharacter{006C}{l}%
10440 \DeclareUnicodeCharacter{006D}{m}%
10441 \DeclareUnicodeCharacter{006E}{n}%
10442 \DeclareUnicodeCharacter{006F}{o}%
10443 \DeclareUnicodeCharacter{0070}{p}%
10444 \DeclareUnicodeCharacter{0071}{q}%
10445 \DeclareUnicodeCharacter{0072}{r}%
10446 \DeclareUnicodeCharacter{0073}{s}%
10447 \DeclareUnicodeCharacter{0074}{t}%
10448 \DeclareUnicodeCharacter{0075}{u}%
10449 \DeclareUnicodeCharacter{0076}{v}%
10450 \DeclareUnicodeCharacter{0077}{w}%
10451 \DeclareUnicodeCharacter{0078}{x}%
10452 \DeclareUnicodeCharacter{0079}{y}%
10453 \DeclareUnicodeCharacter{007A}{z}%
10454 \DeclareUnicodeCharacter{007B}{\char"7B }%
10455 \DeclareUnicodeCharacter{007C}{\char"7C }%
10456 \DeclareUnicodeCharacter{007D}{\char"7D }%
10457 \DeclareUnicodeCharacter{007E}{\char"7E }%
10458 % \DeclareUnicodeCharacter{007F}{} % DEL
10459 %
10460 \DeclareUnicodeCharacter{00A0}{\tie}%
10461 \DeclareUnicodeCharacter{00A1}{\exclamdown}%
10462 \DeclareUnicodeCharacter{00A2}{{\tcfont \char162}}% 0242=cent
10463 \DeclareUnicodeCharacter{00A3}{\pounds{}}%
10464 \DeclareUnicodeCharacter{00A4}{{\tcfont \char164}}% 0244=currency
10465 \DeclareUnicodeCharacter{00A5}{{\tcfont \char165}}% 0245=yen
10466 \DeclareUnicodeCharacter{00A6}{{\tcfont \char166}}% 0246=brokenbar
10467 \DeclareUnicodeCharacter{00A7}{\S}%
10468 \DeclareUnicodeCharacter{00A8}{\"{ }}%
10469 \DeclareUnicodeCharacter{00A9}{\copyright{}}%
10470 \DeclareUnicodeCharacter{00AA}{\ordf}%
10471 \DeclareUnicodeCharacter{00AB}{\guillemetleft{}}%
10472 \DeclareUnicodeCharacter{00AC}{\ensuremath\lnot}%
10473 \DeclareUnicodeCharacter{00AD}{\-}%
10474 \DeclareUnicodeCharacter{00AE}{\registeredsymbol{}}%
10475 \DeclareUnicodeCharacter{00AF}{\={ }}%
10476 %
10477 \DeclareUnicodeCharacter{00B0}{\ringaccent{ }}%
10478 \DeclareUnicodeCharacter{00B1}{\ensuremath\pm}%
10479 \DeclareUnicodeCharacter{00B2}{$^2$}%
10480 \DeclareUnicodeCharacter{00B3}{$^3$}%
10481 \DeclareUnicodeCharacter{00B4}{\'{ }}%
10482 \DeclareUnicodeCharacter{00B5}{$\mu$}%
10483 \DeclareUnicodeCharacter{00B6}{\P}%
10484 \DeclareUnicodeCharacter{00B7}{\ensuremath\cdot}%
10485 \DeclareUnicodeCharacter{00B8}{\cedilla{ }}%
10486 \DeclareUnicodeCharacter{00B9}{$^1$}%
10487 \DeclareUnicodeCharacter{00BA}{\ordm}%
10488 \DeclareUnicodeCharacter{00BB}{\guillemetright{}}%
10489 \DeclareUnicodeCharacter{00BC}{$1\over4$}%
10490 \DeclareUnicodeCharacter{00BD}{$1\over2$}%
10491 \DeclareUnicodeCharacter{00BE}{$3\over4$}%
10492 \DeclareUnicodeCharacter{00BF}{\questiondown}%
10493 %
10494 \DeclareUnicodeCharacter{00C0}{\`A}%
10495 \DeclareUnicodeCharacter{00C1}{\'A}%
10496 \DeclareUnicodeCharacter{00C2}{\^A}%
10497 \DeclareUnicodeCharacter{00C3}{\~A}%
10498 \DeclareUnicodeCharacter{00C4}{\"A}%
10499 \DeclareUnicodeCharacter{00C5}{\AA}%
10500 \DeclareUnicodeCharacter{00C6}{\AE}%
10501 \DeclareUnicodeCharacter{00C7}{\cedilla{C}}%
10502 \DeclareUnicodeCharacter{00C8}{\`E}%
10503 \DeclareUnicodeCharacter{00C9}{\'E}%
10504 \DeclareUnicodeCharacter{00CA}{\^E}%
10505 \DeclareUnicodeCharacter{00CB}{\"E}%
10506 \DeclareUnicodeCharacter{00CC}{\`I}%
10507 \DeclareUnicodeCharacter{00CD}{\'I}%
10508 \DeclareUnicodeCharacter{00CE}{\^I}%
10509 \DeclareUnicodeCharacter{00CF}{\"I}%
10510 %
10511 \DeclareUnicodeCharacter{00D0}{\DH}%
10512 \DeclareUnicodeCharacter{00D1}{\~N}%
10513 \DeclareUnicodeCharacter{00D2}{\`O}%
10514 \DeclareUnicodeCharacter{00D3}{\'O}%
10515 \DeclareUnicodeCharacter{00D4}{\^O}%
10516 \DeclareUnicodeCharacter{00D5}{\~O}%
10517 \DeclareUnicodeCharacter{00D6}{\"O}%
10518 \DeclareUnicodeCharacter{00D7}{\ensuremath\times}%
10519 \DeclareUnicodeCharacter{00D8}{\O}%
10520 \DeclareUnicodeCharacter{00D9}{\`U}%
10521 \DeclareUnicodeCharacter{00DA}{\'U}%
10522 \DeclareUnicodeCharacter{00DB}{\^U}%
10523 \DeclareUnicodeCharacter{00DC}{\"U}%
10524 \DeclareUnicodeCharacter{00DD}{\'Y}%
10525 \DeclareUnicodeCharacter{00DE}{\TH}%
10526 \DeclareUnicodeCharacter{00DF}{\ss}%
10527 %
10528 \DeclareUnicodeCharacter{00E0}{\`a}%
10529 \DeclareUnicodeCharacter{00E1}{\'a}%
10530 \DeclareUnicodeCharacter{00E2}{\^a}%
10531 \DeclareUnicodeCharacter{00E3}{\~a}%
10532 \DeclareUnicodeCharacter{00E4}{\"a}%
10533 \DeclareUnicodeCharacter{00E5}{\aa}%
10534 \DeclareUnicodeCharacter{00E6}{\ae}%
10535 \DeclareUnicodeCharacter{00E7}{\cedilla{c}}%
10536 \DeclareUnicodeCharacter{00E8}{\`e}%
10537 \DeclareUnicodeCharacter{00E9}{\'e}%
10538 \DeclareUnicodeCharacter{00EA}{\^e}%
10539 \DeclareUnicodeCharacter{00EB}{\"e}%
10540 \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}}%
10541 \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}}%
10542 \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}}%
10543 \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}}%
10544 %
10545 \DeclareUnicodeCharacter{00F0}{\dh}%
10546 \DeclareUnicodeCharacter{00F1}{\~n}%
10547 \DeclareUnicodeCharacter{00F2}{\`o}%
10548 \DeclareUnicodeCharacter{00F3}{\'o}%
10549 \DeclareUnicodeCharacter{00F4}{\^o}%
10550 \DeclareUnicodeCharacter{00F5}{\~o}%
10551 \DeclareUnicodeCharacter{00F6}{\"o}%
10552 \DeclareUnicodeCharacter{00F7}{\ensuremath\div}%
10553 \DeclareUnicodeCharacter{00F8}{\o}%
10554 \DeclareUnicodeCharacter{00F9}{\`u}%
10555 \DeclareUnicodeCharacter{00FA}{\'u}%
10556 \DeclareUnicodeCharacter{00FB}{\^u}%
10557 \DeclareUnicodeCharacter{00FC}{\"u}%
10558 \DeclareUnicodeCharacter{00FD}{\'y}%
10559 \DeclareUnicodeCharacter{00FE}{\th}%
10560 \DeclareUnicodeCharacter{00FF}{\"y}%
10561 %
10562 \DeclareUnicodeCharacter{0100}{\=A}%
10563 \DeclareUnicodeCharacter{0101}{\=a}%
10564 \DeclareUnicodeCharacter{0102}{\u{A}}%
10565 \DeclareUnicodeCharacter{0103}{\u{a}}%
10566 \DeclareUnicodeCharacter{0104}{\ogonek{A}}%
10567 \DeclareUnicodeCharacter{0105}{\ogonek{a}}%
10568 \DeclareUnicodeCharacter{0106}{\'C}%
10569 \DeclareUnicodeCharacter{0107}{\'c}%
10570 \DeclareUnicodeCharacter{0108}{\^C}%
10571 \DeclareUnicodeCharacter{0109}{\^c}%
10572 \DeclareUnicodeCharacter{010A}{\dotaccent{C}}%
10573 \DeclareUnicodeCharacter{010B}{\dotaccent{c}}%
10574 \DeclareUnicodeCharacter{010C}{\v{C}}%
10575 \DeclareUnicodeCharacter{010D}{\v{c}}%
10576 \DeclareUnicodeCharacter{010E}{\v{D}}%
10577 \DeclareUnicodeCharacter{010F}{d'}%
10578 %
10579 \DeclareUnicodeCharacter{0110}{\DH}%
10580 \DeclareUnicodeCharacter{0111}{\dh}%
10581 \DeclareUnicodeCharacter{0112}{\=E}%
10582 \DeclareUnicodeCharacter{0113}{\=e}%
10583 \DeclareUnicodeCharacter{0114}{\u{E}}%
10584 \DeclareUnicodeCharacter{0115}{\u{e}}%
10585 \DeclareUnicodeCharacter{0116}{\dotaccent{E}}%
10586 \DeclareUnicodeCharacter{0117}{\dotaccent{e}}%
10587 \DeclareUnicodeCharacter{0118}{\ogonek{E}}%
10588 \DeclareUnicodeCharacter{0119}{\ogonek{e}}%
10589 \DeclareUnicodeCharacter{011A}{\v{E}}%
10590 \DeclareUnicodeCharacter{011B}{\v{e}}%
10591 \DeclareUnicodeCharacter{011C}{\^G}%
10592 \DeclareUnicodeCharacter{011D}{\^g}%
10593 \DeclareUnicodeCharacter{011E}{\u{G}}%
10594 \DeclareUnicodeCharacter{011F}{\u{g}}%
10595 %
10596 \DeclareUnicodeCharacter{0120}{\dotaccent{G}}%
10597 \DeclareUnicodeCharacter{0121}{\dotaccent{g}}%
10598 \DeclareUnicodeCharacter{0122}{\cedilla{G}}%
10599 \DeclareUnicodeCharacter{0123}{\cedilla{g}}%
10600 \DeclareUnicodeCharacter{0124}{\^H}%
10601 \DeclareUnicodeCharacter{0125}{\^h}%
10602 \DeclareUnicodeCharacter{0126}{\missingcharmsg{H WITH STROKE}}%
10603 \DeclareUnicodeCharacter{0127}{\missingcharmsg{h WITH STROKE}}%
10604 \DeclareUnicodeCharacter{0128}{\~I}%
10605 \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}}%
10606 \DeclareUnicodeCharacter{012A}{\=I}%
10607 \DeclareUnicodeCharacter{012B}{\={\dotless{i}}}%
10608 \DeclareUnicodeCharacter{012C}{\u{I}}%
10609 \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}}%
10610 \DeclareUnicodeCharacter{012E}{\ogonek{I}}%
10611 \DeclareUnicodeCharacter{012F}{\ogonek{i}}%
10612 %
10613 \DeclareUnicodeCharacter{0130}{\dotaccent{I}}%
10614 \DeclareUnicodeCharacter{0131}{\dotless{i}}%
10615 \DeclareUnicodeCharacter{0132}{IJ}%
10616 \DeclareUnicodeCharacter{0133}{ij}%
10617 \DeclareUnicodeCharacter{0134}{\^J}%
10618 \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}}%
10619 \DeclareUnicodeCharacter{0136}{\cedilla{K}}%
10620 \DeclareUnicodeCharacter{0137}{\cedilla{k}}%
10621 \DeclareUnicodeCharacter{0138}{\ensuremath\kappa}%
10622 \DeclareUnicodeCharacter{0139}{\'L}%
10623 \DeclareUnicodeCharacter{013A}{\'l}%
10624 \DeclareUnicodeCharacter{013B}{\cedilla{L}}%
10625 \DeclareUnicodeCharacter{013C}{\cedilla{l}}%
10626 \DeclareUnicodeCharacter{013D}{L'}% should kern
10627 \DeclareUnicodeCharacter{013E}{l'}% should kern
10628 \DeclareUnicodeCharacter{013F}{L\U{00B7}}%
10629 %
10630 \DeclareUnicodeCharacter{0140}{l\U{00B7}}%
10631 \DeclareUnicodeCharacter{0141}{\L}%
10632 \DeclareUnicodeCharacter{0142}{\l}%
10633 \DeclareUnicodeCharacter{0143}{\'N}%
10634 \DeclareUnicodeCharacter{0144}{\'n}%
10635 \DeclareUnicodeCharacter{0145}{\cedilla{N}}%
10636 \DeclareUnicodeCharacter{0146}{\cedilla{n}}%
10637 \DeclareUnicodeCharacter{0147}{\v{N}}%
10638 \DeclareUnicodeCharacter{0148}{\v{n}}%
10639 \DeclareUnicodeCharacter{0149}{'n}%
10640 \DeclareUnicodeCharacter{014A}{\missingcharmsg{ENG}}%
10641 \DeclareUnicodeCharacter{014B}{\missingcharmsg{eng}}%
10642 \DeclareUnicodeCharacter{014C}{\=O}%
10643 \DeclareUnicodeCharacter{014D}{\=o}%
10644 \DeclareUnicodeCharacter{014E}{\u{O}}%
10645 \DeclareUnicodeCharacter{014F}{\u{o}}%
10646 %
10647 \DeclareUnicodeCharacter{0150}{\H{O}}%
10648 \DeclareUnicodeCharacter{0151}{\H{o}}%
10649 \DeclareUnicodeCharacter{0152}{\OE}%
10650 \DeclareUnicodeCharacter{0153}{\oe}%
10651 \DeclareUnicodeCharacter{0154}{\'R}%
10652 \DeclareUnicodeCharacter{0155}{\'r}%
10653 \DeclareUnicodeCharacter{0156}{\cedilla{R}}%
10654 \DeclareUnicodeCharacter{0157}{\cedilla{r}}%
10655 \DeclareUnicodeCharacter{0158}{\v{R}}%
10656 \DeclareUnicodeCharacter{0159}{\v{r}}%
10657 \DeclareUnicodeCharacter{015A}{\'S}%
10658 \DeclareUnicodeCharacter{015B}{\'s}%
10659 \DeclareUnicodeCharacter{015C}{\^S}%
10660 \DeclareUnicodeCharacter{015D}{\^s}%
10661 \DeclareUnicodeCharacter{015E}{\cedilla{S}}%
10662 \DeclareUnicodeCharacter{015F}{\cedilla{s}}%
10663 %
10664 \DeclareUnicodeCharacter{0160}{\v{S}}%
10665 \DeclareUnicodeCharacter{0161}{\v{s}}%
10666 \DeclareUnicodeCharacter{0162}{\cedilla{T}}%
10667 \DeclareUnicodeCharacter{0163}{\cedilla{t}}%
10668 \DeclareUnicodeCharacter{0164}{\v{T}}%
10669 \DeclareUnicodeCharacter{0165}{\v{t}}%
10670 \DeclareUnicodeCharacter{0166}{\missingcharmsg{H WITH STROKE}}%
10671 \DeclareUnicodeCharacter{0167}{\missingcharmsg{h WITH STROKE}}%
10672 \DeclareUnicodeCharacter{0168}{\~U}%
10673 \DeclareUnicodeCharacter{0169}{\~u}%
10674 \DeclareUnicodeCharacter{016A}{\=U}%
10675 \DeclareUnicodeCharacter{016B}{\=u}%
10676 \DeclareUnicodeCharacter{016C}{\u{U}}%
10677 \DeclareUnicodeCharacter{016D}{\u{u}}%
10678 \DeclareUnicodeCharacter{016E}{\ringaccent{U}}%
10679 \DeclareUnicodeCharacter{016F}{\ringaccent{u}}%
10680 %
10681 \DeclareUnicodeCharacter{0170}{\H{U}}%
10682 \DeclareUnicodeCharacter{0171}{\H{u}}%
10683 \DeclareUnicodeCharacter{0172}{\ogonek{U}}%
10684 \DeclareUnicodeCharacter{0173}{\ogonek{u}}%
10685 \DeclareUnicodeCharacter{0174}{\^W}%
10686 \DeclareUnicodeCharacter{0175}{\^w}%
10687 \DeclareUnicodeCharacter{0176}{\^Y}%
10688 \DeclareUnicodeCharacter{0177}{\^y}%
10689 \DeclareUnicodeCharacter{0178}{\"Y}%
10690 \DeclareUnicodeCharacter{0179}{\'Z}%
10691 \DeclareUnicodeCharacter{017A}{\'z}%
10692 \DeclareUnicodeCharacter{017B}{\dotaccent{Z}}%
10693 \DeclareUnicodeCharacter{017C}{\dotaccent{z}}%
10694 \DeclareUnicodeCharacter{017D}{\v{Z}}%
10695 \DeclareUnicodeCharacter{017E}{\v{z}}%
10696 \DeclareUnicodeCharacter{017F}{\missingcharmsg{LONG S}}%
10697 %
10698 \DeclareUnicodeCharacter{01C4}{D\v{Z}}%
10699 \DeclareUnicodeCharacter{01C5}{D\v{z}}%
10700 \DeclareUnicodeCharacter{01C6}{d\v{z}}%
10701 \DeclareUnicodeCharacter{01C7}{LJ}%
10702 \DeclareUnicodeCharacter{01C8}{Lj}%
10703 \DeclareUnicodeCharacter{01C9}{lj}%
10704 \DeclareUnicodeCharacter{01CA}{NJ}%
10705 \DeclareUnicodeCharacter{01CB}{Nj}%
10706 \DeclareUnicodeCharacter{01CC}{nj}%
10707 \DeclareUnicodeCharacter{01CD}{\v{A}}%
10708 \DeclareUnicodeCharacter{01CE}{\v{a}}%
10709 \DeclareUnicodeCharacter{01CF}{\v{I}}%
10710 %
10711 \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}}%
10712 \DeclareUnicodeCharacter{01D1}{\v{O}}%
10713 \DeclareUnicodeCharacter{01D2}{\v{o}}%
10714 \DeclareUnicodeCharacter{01D3}{\v{U}}%
10715 \DeclareUnicodeCharacter{01D4}{\v{u}}%
10716 %
10717 \DeclareUnicodeCharacter{01E2}{\={\AE}}%
10718 \DeclareUnicodeCharacter{01E3}{\={\ae}}%
10719 \DeclareUnicodeCharacter{01E6}{\v{G}}%
10720 \DeclareUnicodeCharacter{01E7}{\v{g}}%
10721 \DeclareUnicodeCharacter{01E8}{\v{K}}%
10722 \DeclareUnicodeCharacter{01E9}{\v{k}}%
10723 %
10724 \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}}%
10725 \DeclareUnicodeCharacter{01F1}{DZ}%
10726 \DeclareUnicodeCharacter{01F2}{Dz}%
10727 \DeclareUnicodeCharacter{01F3}{dz}%
10728 \DeclareUnicodeCharacter{01F4}{\'G}%
10729 \DeclareUnicodeCharacter{01F5}{\'g}%
10730 \DeclareUnicodeCharacter{01F8}{\`N}%
10731 \DeclareUnicodeCharacter{01F9}{\`n}%
10732 \DeclareUnicodeCharacter{01FC}{\'{\AE}}%
10733 \DeclareUnicodeCharacter{01FD}{\'{\ae}}%
10734 \DeclareUnicodeCharacter{01FE}{\'{\O}}%
10735 \DeclareUnicodeCharacter{01FF}{\'{\o}}%
10736 %
10737 \DeclareUnicodeCharacter{021E}{\v{H}}%
10738 \DeclareUnicodeCharacter{021F}{\v{h}}%
10739 %
10740 \DeclareUnicodeCharacter{0226}{\dotaccent{A}}%
10741 \DeclareUnicodeCharacter{0227}{\dotaccent{a}}%
10742 \DeclareUnicodeCharacter{0228}{\cedilla{E}}%
10743 \DeclareUnicodeCharacter{0229}{\cedilla{e}}%
10744 \DeclareUnicodeCharacter{022E}{\dotaccent{O}}%
10745 \DeclareUnicodeCharacter{022F}{\dotaccent{o}}%
10746 %
10747 \DeclareUnicodeCharacter{0232}{\=Y}%
10748 \DeclareUnicodeCharacter{0233}{\=y}%
10749 \DeclareUnicodeCharacter{0237}{\dotless{j}}%
10750 %
10751 \DeclareUnicodeCharacter{02BC}{'}%
10752 %
10753 \DeclareUnicodeCharacter{02DB}{\ogonek{ }}%
10754 %
10755 % Greek letters upper case
10756 \DeclareUnicodeCharacter{0391}{{\it A}}%
10757 \DeclareUnicodeCharacter{0392}{{\it B}}%
10758 \DeclareUnicodeCharacter{0393}{\ensuremath{\mit\Gamma}}%
10759 \DeclareUnicodeCharacter{0394}{\ensuremath{\mit\Delta}}%
10760 \DeclareUnicodeCharacter{0395}{{\it E}}%
10761 \DeclareUnicodeCharacter{0396}{{\it Z}}%
10762 \DeclareUnicodeCharacter{0397}{{\it H}}%
10763 \DeclareUnicodeCharacter{0398}{\ensuremath{\mit\Theta}}%
10764 \DeclareUnicodeCharacter{0399}{{\it I}}%
10765 \DeclareUnicodeCharacter{039A}{{\it K}}%
10766 \DeclareUnicodeCharacter{039B}{\ensuremath{\mit\Lambda}}%
10767 \DeclareUnicodeCharacter{039C}{{\it M}}%
10768 \DeclareUnicodeCharacter{039D}{{\it N}}%
10769 \DeclareUnicodeCharacter{039E}{\ensuremath{\mit\Xi}}%
10770 \DeclareUnicodeCharacter{039F}{{\it O}}%
10771 \DeclareUnicodeCharacter{03A0}{\ensuremath{\mit\Pi}}%
10772 \DeclareUnicodeCharacter{03A1}{{\it P}}%
10773 %\DeclareUnicodeCharacter{03A2}{} % none - corresponds to final sigma
10774 \DeclareUnicodeCharacter{03A3}{\ensuremath{\mit\Sigma}}%
10775 \DeclareUnicodeCharacter{03A4}{{\it T}}%
10776 \DeclareUnicodeCharacter{03A5}{\ensuremath{\mit\Upsilon}}%
10777 \DeclareUnicodeCharacter{03A6}{\ensuremath{\mit\Phi}}%
10778 \DeclareUnicodeCharacter{03A7}{{\it X}}%
10779 \DeclareUnicodeCharacter{03A8}{\ensuremath{\mit\Psi}}%
10780 \DeclareUnicodeCharacter{03A9}{\ensuremath{\mit\Omega}}%
10781 %
10782 % Vowels with accents
10783 \DeclareUnicodeCharacter{0390}{\ensuremath{\ddot{\acute\iota}}}%
10784 \DeclareUnicodeCharacter{03AC}{\ensuremath{\acute\alpha}}%
10785 \DeclareUnicodeCharacter{03AD}{\ensuremath{\acute\epsilon}}%
10786 \DeclareUnicodeCharacter{03AE}{\ensuremath{\acute\eta}}%
10787 \DeclareUnicodeCharacter{03AF}{\ensuremath{\acute\iota}}%
10788 \DeclareUnicodeCharacter{03B0}{\ensuremath{\acute{\ddot\upsilon}}}%
10789 %
10790 % Standalone accent
10791 \DeclareUnicodeCharacter{0384}{\ensuremath{\acute{\ }}}%
10792 %
10793 % Greek letters lower case
10794 \DeclareUnicodeCharacter{03B1}{\ensuremath\alpha}%
10795 \DeclareUnicodeCharacter{03B2}{\ensuremath\beta}%
10796 \DeclareUnicodeCharacter{03B3}{\ensuremath\gamma}%
10797 \DeclareUnicodeCharacter{03B4}{\ensuremath\delta}%
10798 \DeclareUnicodeCharacter{03B5}{\ensuremath\epsilon}%
10799 \DeclareUnicodeCharacter{03B6}{\ensuremath\zeta}%
10800 \DeclareUnicodeCharacter{03B7}{\ensuremath\eta}%
10801 \DeclareUnicodeCharacter{03B8}{\ensuremath\theta}%
10802 \DeclareUnicodeCharacter{03B9}{\ensuremath\iota}%
10803 \DeclareUnicodeCharacter{03BA}{\ensuremath\kappa}%
10804 \DeclareUnicodeCharacter{03BB}{\ensuremath\lambda}%
10805 \DeclareUnicodeCharacter{03BC}{\ensuremath\mu}%
10806 \DeclareUnicodeCharacter{03BD}{\ensuremath\nu}%
10807 \DeclareUnicodeCharacter{03BE}{\ensuremath\xi}%
10808 \DeclareUnicodeCharacter{03BF}{{\it o}}% omicron
10809 \DeclareUnicodeCharacter{03C0}{\ensuremath\pi}%
10810 \DeclareUnicodeCharacter{03C1}{\ensuremath\rho}%
10811 \DeclareUnicodeCharacter{03C2}{\ensuremath\varsigma}%
10812 \DeclareUnicodeCharacter{03C3}{\ensuremath\sigma}%
10813 \DeclareUnicodeCharacter{03C4}{\ensuremath\tau}%
10814 \DeclareUnicodeCharacter{03C5}{\ensuremath\upsilon}%
10815 \DeclareUnicodeCharacter{03C6}{\ensuremath\phi}%
10816 \DeclareUnicodeCharacter{03C7}{\ensuremath\chi}%
10817 \DeclareUnicodeCharacter{03C8}{\ensuremath\psi}%
10818 \DeclareUnicodeCharacter{03C9}{\ensuremath\omega}%
10819 %
10820 % More Greek vowels with accents
10821 \DeclareUnicodeCharacter{03CA}{\ensuremath{\ddot\iota}}%
10822 \DeclareUnicodeCharacter{03CB}{\ensuremath{\ddot\upsilon}}%
10823 \DeclareUnicodeCharacter{03CC}{\ensuremath{\acute o}}%
10824 \DeclareUnicodeCharacter{03CD}{\ensuremath{\acute\upsilon}}%
10825 \DeclareUnicodeCharacter{03CE}{\ensuremath{\acute\omega}}%
10826 %
10827 % Variant Greek letters
10828 \DeclareUnicodeCharacter{03D1}{\ensuremath\vartheta}%
10829 \DeclareUnicodeCharacter{03D6}{\ensuremath\varpi}%
10830 \DeclareUnicodeCharacter{03F1}{\ensuremath\varrho}%
10831 %
10832 \DeclareUnicodeCharacter{1E02}{\dotaccent{B}}%
10833 \DeclareUnicodeCharacter{1E03}{\dotaccent{b}}%
10834 \DeclareUnicodeCharacter{1E04}{\udotaccent{B}}%
10835 \DeclareUnicodeCharacter{1E05}{\udotaccent{b}}%
10836 \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}}%
10837 \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}}%
10838 \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}}%
10839 \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}}%
10840 \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}}%
10841 \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}}%
10842 \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}}%
10843 \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}}%
10844 %
10845 \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}}%
10846 \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}}%
10847 %
10848 \DeclareUnicodeCharacter{1E20}{\=G}%
10849 \DeclareUnicodeCharacter{1E21}{\=g}%
10850 \DeclareUnicodeCharacter{1E22}{\dotaccent{H}}%
10851 \DeclareUnicodeCharacter{1E23}{\dotaccent{h}}%
10852 \DeclareUnicodeCharacter{1E24}{\udotaccent{H}}%
10853 \DeclareUnicodeCharacter{1E25}{\udotaccent{h}}%
10854 \DeclareUnicodeCharacter{1E26}{\"H}%
10855 \DeclareUnicodeCharacter{1E27}{\"h}%
10856 %
10857 \DeclareUnicodeCharacter{1E30}{\'K}%
10858 \DeclareUnicodeCharacter{1E31}{\'k}%
10859 \DeclareUnicodeCharacter{1E32}{\udotaccent{K}}%
10860 \DeclareUnicodeCharacter{1E33}{\udotaccent{k}}%
10861 \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}}%
10862 \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}}%
10863 \DeclareUnicodeCharacter{1E36}{\udotaccent{L}}%
10864 \DeclareUnicodeCharacter{1E37}{\udotaccent{l}}%
10865 \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}}%
10866 \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}}%
10867 \DeclareUnicodeCharacter{1E3E}{\'M}%
10868 \DeclareUnicodeCharacter{1E3F}{\'m}%
10869 %
10870 \DeclareUnicodeCharacter{1E40}{\dotaccent{M}}%
10871 \DeclareUnicodeCharacter{1E41}{\dotaccent{m}}%
10872 \DeclareUnicodeCharacter{1E42}{\udotaccent{M}}%
10873 \DeclareUnicodeCharacter{1E43}{\udotaccent{m}}%
10874 \DeclareUnicodeCharacter{1E44}{\dotaccent{N}}%
10875 \DeclareUnicodeCharacter{1E45}{\dotaccent{n}}%
10876 \DeclareUnicodeCharacter{1E46}{\udotaccent{N}}%
10877 \DeclareUnicodeCharacter{1E47}{\udotaccent{n}}%
10878 \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}}%
10879 \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}}%
10880 %
10881 \DeclareUnicodeCharacter{1E54}{\'P}%
10882 \DeclareUnicodeCharacter{1E55}{\'p}%
10883 \DeclareUnicodeCharacter{1E56}{\dotaccent{P}}%
10884 \DeclareUnicodeCharacter{1E57}{\dotaccent{p}}%
10885 \DeclareUnicodeCharacter{1E58}{\dotaccent{R}}%
10886 \DeclareUnicodeCharacter{1E59}{\dotaccent{r}}%
10887 \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}}%
10888 \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}}%
10889 \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}}%
10890 \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}}%
10891 %
10892 \DeclareUnicodeCharacter{1E60}{\dotaccent{S}}%
10893 \DeclareUnicodeCharacter{1E61}{\dotaccent{s}}%
10894 \DeclareUnicodeCharacter{1E62}{\udotaccent{S}}%
10895 \DeclareUnicodeCharacter{1E63}{\udotaccent{s}}%
10896 \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}}%
10897 \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}}%
10898 \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}}%
10899 \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}}%
10900 \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}}%
10901 \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}}%
10902 %
10903 \DeclareUnicodeCharacter{1E7C}{\~V}%
10904 \DeclareUnicodeCharacter{1E7D}{\~v}%
10905 \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}}%
10906 \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}}%
10907 %
10908 \DeclareUnicodeCharacter{1E80}{\`W}%
10909 \DeclareUnicodeCharacter{1E81}{\`w}%
10910 \DeclareUnicodeCharacter{1E82}{\'W}%
10911 \DeclareUnicodeCharacter{1E83}{\'w}%
10912 \DeclareUnicodeCharacter{1E84}{\"W}%
10913 \DeclareUnicodeCharacter{1E85}{\"w}%
10914 \DeclareUnicodeCharacter{1E86}{\dotaccent{W}}%
10915 \DeclareUnicodeCharacter{1E87}{\dotaccent{w}}%
10916 \DeclareUnicodeCharacter{1E88}{\udotaccent{W}}%
10917 \DeclareUnicodeCharacter{1E89}{\udotaccent{w}}%
10918 \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}}%
10919 \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}}%
10920 \DeclareUnicodeCharacter{1E8C}{\"X}%
10921 \DeclareUnicodeCharacter{1E8D}{\"x}%
10922 \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}}%
10923 \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}}%
10924 %
10925 \DeclareUnicodeCharacter{1E90}{\^Z}%
10926 \DeclareUnicodeCharacter{1E91}{\^z}%
10927 \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}}%
10928 \DeclareUnicodeCharacter{1E93}{\udotaccent{z}}%
10929 \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}}%
10930 \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}}%
10931 \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}}%
10932 \DeclareUnicodeCharacter{1E97}{\"t}%
10933 \DeclareUnicodeCharacter{1E98}{\ringaccent{w}}%
10934 \DeclareUnicodeCharacter{1E99}{\ringaccent{y}}%
10935 %
10936 \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}}%
10937 \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}}%
10938 %
10939 \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}}%
10940 \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}}%
10941 \DeclareUnicodeCharacter{1EBC}{\~E}%
10942 \DeclareUnicodeCharacter{1EBD}{\~e}%
10943 %
10944 \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}}%
10945 \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}}%
10946 \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}}%
10947 \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}}%
10948 %
10949 \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}}%
10950 \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}}%
10951 %
10952 \DeclareUnicodeCharacter{1EF2}{\`Y}%
10953 \DeclareUnicodeCharacter{1EF3}{\`y}%
10954 \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}}%
10955 %
10956 \DeclareUnicodeCharacter{1EF8}{\~Y}%
10957 \DeclareUnicodeCharacter{1EF9}{\~y}%
10958 %
10959 % Exotic spaces
10960 \DeclareUnicodeCharacter{2007}{\hphantom{0}}%
10961 %
10962 % Punctuation
10963 \DeclareUnicodeCharacter{2013}{--}%
10964 \DeclareUnicodeCharacter{2014}{---}%
10965 \DeclareUnicodeCharacter{2018}{\quoteleft{}}%
10966 \DeclareUnicodeCharacter{2019}{\quoteright{}}%
10967 \DeclareUnicodeCharacter{201A}{\quotesinglbase{}}%
10968 \DeclareUnicodeCharacter{201C}{\quotedblleft{}}%
10969 \DeclareUnicodeCharacter{201D}{\quotedblright{}}%
10970 \DeclareUnicodeCharacter{201E}{\quotedblbase{}}%
10971 \DeclareUnicodeCharacter{2020}{\ensuremath\dagger}%
10972 \DeclareUnicodeCharacter{2021}{\ensuremath\ddagger}%
10973 \DeclareUnicodeCharacter{2022}{\bullet{}}%
10974 \DeclareUnicodeCharacter{202F}{\thinspace}%
10975 \DeclareUnicodeCharacter{2026}{\dots{}}%
10976 \DeclareUnicodeCharacter{2039}{\guilsinglleft{}}%
10977 \DeclareUnicodeCharacter{203A}{\guilsinglright{}}%
10978 %
10979 \DeclareUnicodeCharacter{20AC}{\euro{}}%
10980 %
10981 \DeclareUnicodeCharacter{2192}{\expansion{}}%
10982 \DeclareUnicodeCharacter{21D2}{\result{}}%
10983 %
10984 % Mathematical symbols
10985 \DeclareUnicodeCharacter{2200}{\ensuremath\forall}%
10986 \DeclareUnicodeCharacter{2203}{\ensuremath\exists}%
10987 \DeclareUnicodeCharacter{2208}{\ensuremath\in}%
10988 \DeclareUnicodeCharacter{2212}{\minus{}}%
10989 \DeclareUnicodeCharacter{2217}{\ast}%
10990 \DeclareUnicodeCharacter{221E}{\ensuremath\infty}%
10991 \DeclareUnicodeCharacter{2225}{\ensuremath\parallel}%
10992 \DeclareUnicodeCharacter{2227}{\ensuremath\wedge}%
10993 \DeclareUnicodeCharacter{2229}{\ensuremath\cap}%
10994 \DeclareUnicodeCharacter{2261}{\equiv{}}%
10995 \DeclareUnicodeCharacter{2264}{\ensuremath\leq}%
10996 \DeclareUnicodeCharacter{2265}{\ensuremath\geq}%
10997 \DeclareUnicodeCharacter{2282}{\ensuremath\subset}%
10998 \DeclareUnicodeCharacter{2287}{\ensuremath\supseteq}%
10999 %
11000 \DeclareUnicodeCharacter{2016}{\ensuremath\Vert}%
11001 \DeclareUnicodeCharacter{2032}{\ensuremath\prime}%
11002 \DeclareUnicodeCharacter{210F}{\ensuremath\hbar}%
11003 \DeclareUnicodeCharacter{2111}{\ensuremath\Im}%
11004 \DeclareUnicodeCharacter{2113}{\ensuremath\ell}%
11005 \DeclareUnicodeCharacter{2118}{\ensuremath\wp}%
11006 \DeclareUnicodeCharacter{211C}{\ensuremath\Re}%
11007 \DeclareUnicodeCharacter{2135}{\ensuremath\aleph}%
11008 \DeclareUnicodeCharacter{2190}{\ensuremath\leftarrow}%
11009 \DeclareUnicodeCharacter{2191}{\ensuremath\uparrow}%
11010 \DeclareUnicodeCharacter{2193}{\ensuremath\downarrow}%
11011 \DeclareUnicodeCharacter{2194}{\ensuremath\leftrightarrow}%
11012 \DeclareUnicodeCharacter{2195}{\ensuremath\updownarrow}%
11013 \DeclareUnicodeCharacter{2196}{\ensuremath\nwarrow}%
11014 \DeclareUnicodeCharacter{2197}{\ensuremath\nearrow}%
11015 \DeclareUnicodeCharacter{2198}{\ensuremath\searrow}%
11016 \DeclareUnicodeCharacter{2199}{\ensuremath\swarrow}%
11017 \DeclareUnicodeCharacter{21A6}{\ensuremath\mapsto}%
11018 \DeclareUnicodeCharacter{21A9}{\ensuremath\hookleftarrow}%
11019 \DeclareUnicodeCharacter{21AA}{\ensuremath\hookrightarrow}%
11020 \DeclareUnicodeCharacter{21BC}{\ensuremath\leftharpoonup}%
11021 \DeclareUnicodeCharacter{21BD}{\ensuremath\leftharpoondown}%
11022 \DeclareUnicodeCharacter{21C0}{\ensuremath\rightharpoonup}%
11023 \DeclareUnicodeCharacter{21C1}{\ensuremath\rightharpoondown}%
11024 \DeclareUnicodeCharacter{21CC}{\ensuremath\rightleftharpoons}%
11025 \DeclareUnicodeCharacter{21D0}{\ensuremath\Leftarrow}%
11026 \DeclareUnicodeCharacter{21D1}{\ensuremath\Uparrow}%
11027 \DeclareUnicodeCharacter{21D3}{\ensuremath\Downarrow}%
11028 \DeclareUnicodeCharacter{21D4}{\ensuremath\Leftrightarrow}%
11029 \DeclareUnicodeCharacter{21D5}{\ensuremath\Updownarrow}%
11030 \DeclareUnicodeCharacter{2202}{\ensuremath\partial}%
11031 \DeclareUnicodeCharacter{2205}{\ensuremath\emptyset}%
11032 \DeclareUnicodeCharacter{2207}{\ensuremath\nabla}%
11033 \DeclareUnicodeCharacter{2209}{\ensuremath\notin}%
11034 \DeclareUnicodeCharacter{220B}{\ensuremath\owns}%
11035 \DeclareUnicodeCharacter{220F}{\ensuremath\prod}%
11036 \DeclareUnicodeCharacter{2210}{\ensuremath\coprod}%
11037 \DeclareUnicodeCharacter{2211}{\ensuremath\sum}%
11038 \DeclareUnicodeCharacter{2213}{\ensuremath\mp}%
11039 \DeclareUnicodeCharacter{2218}{\ensuremath\circ}%
11040 \DeclareUnicodeCharacter{221A}{\ensuremath\surd}%
11041 \DeclareUnicodeCharacter{221D}{\ensuremath\propto}%
11042 \DeclareUnicodeCharacter{2220}{\ensuremath\angle}%
11043 \DeclareUnicodeCharacter{2223}{\ensuremath\mid}%
11044 \DeclareUnicodeCharacter{2228}{\ensuremath\vee}%
11045 \DeclareUnicodeCharacter{222A}{\ensuremath\cup}%
11046 \DeclareUnicodeCharacter{222B}{\ensuremath\smallint}%
11047 \DeclareUnicodeCharacter{222E}{\ensuremath\oint}%
11048 \DeclareUnicodeCharacter{223C}{\ensuremath\sim}%
11049 \DeclareUnicodeCharacter{2240}{\ensuremath\wr}%
11050 \DeclareUnicodeCharacter{2243}{\ensuremath\simeq}%
11051 \DeclareUnicodeCharacter{2245}{\ensuremath\cong}%
11052 \DeclareUnicodeCharacter{2248}{\ensuremath\approx}%
11053 \DeclareUnicodeCharacter{224D}{\ensuremath\asymp}%
11054 \DeclareUnicodeCharacter{2250}{\ensuremath\doteq}%
11055 \DeclareUnicodeCharacter{2260}{\ensuremath\neq}%
11056 \DeclareUnicodeCharacter{226A}{\ensuremath\ll}%
11057 \DeclareUnicodeCharacter{226B}{\ensuremath\gg}%
11058 \DeclareUnicodeCharacter{227A}{\ensuremath\prec}%
11059 \DeclareUnicodeCharacter{227B}{\ensuremath\succ}%
11060 \DeclareUnicodeCharacter{2283}{\ensuremath\supset}%
11061 \DeclareUnicodeCharacter{2286}{\ensuremath\subseteq}%
11062 \DeclareUnicodeCharacter{228E}{\ensuremath\uplus}%
11063 \DeclareUnicodeCharacter{2291}{\ensuremath\sqsubseteq}%
11064 \DeclareUnicodeCharacter{2292}{\ensuremath\sqsupseteq}%
11065 \DeclareUnicodeCharacter{2293}{\ensuremath\sqcap}%
11066 \DeclareUnicodeCharacter{2294}{\ensuremath\sqcup}%
11067 \DeclareUnicodeCharacter{2295}{\ensuremath\oplus}%
11068 \DeclareUnicodeCharacter{2296}{\ensuremath\ominus}%
11069 \DeclareUnicodeCharacter{2297}{\ensuremath\otimes}%
11070 \DeclareUnicodeCharacter{2298}{\ensuremath\oslash}%
11071 \DeclareUnicodeCharacter{2299}{\ensuremath\odot}%
11072 \DeclareUnicodeCharacter{22A2}{\ensuremath\vdash}%
11073 \DeclareUnicodeCharacter{22A3}{\ensuremath\dashv}%
11074 \DeclareUnicodeCharacter{22A4}{\ensuremath\ptextop}%
11075 \DeclareUnicodeCharacter{22A5}{\ensuremath\bot}%
11076 \DeclareUnicodeCharacter{22A8}{\ensuremath\models}%
11077 \DeclareUnicodeCharacter{22C0}{\ensuremath\bigwedge}%
11078 \DeclareUnicodeCharacter{22C1}{\ensuremath\bigvee}%
11079 \DeclareUnicodeCharacter{22C2}{\ensuremath\bigcap}%
11080 \DeclareUnicodeCharacter{22C3}{\ensuremath\bigcup}%
11081 \DeclareUnicodeCharacter{22C4}{\ensuremath\diamond}%
11082 \DeclareUnicodeCharacter{22C5}{\ensuremath\cdot}%
11083 \DeclareUnicodeCharacter{22C6}{\ensuremath\star}%
11084 \DeclareUnicodeCharacter{22C8}{\ensuremath\bowtie}%
11085 \DeclareUnicodeCharacter{2308}{\ensuremath\lceil}%
11086 \DeclareUnicodeCharacter{2309}{\ensuremath\rceil}%
11087 \DeclareUnicodeCharacter{230A}{\ensuremath\lfloor}%
11088 \DeclareUnicodeCharacter{230B}{\ensuremath\rfloor}%
11089 \DeclareUnicodeCharacter{2322}{\ensuremath\frown}%
11090 \DeclareUnicodeCharacter{2323}{\ensuremath\smile}%
11091 %
11092 \DeclareUnicodeCharacter{25B3}{\ensuremath\triangle}%
11093 \DeclareUnicodeCharacter{25B7}{\ensuremath\triangleright}%
11094 \DeclareUnicodeCharacter{25BD}{\ensuremath\bigtriangledown}%
11095 \DeclareUnicodeCharacter{25C1}{\ensuremath\triangleleft}%
11096 \DeclareUnicodeCharacter{25C7}{\ensuremath\diamond}%
11097 \DeclareUnicodeCharacter{2660}{\ensuremath\spadesuit}%
11098 \DeclareUnicodeCharacter{2661}{\ensuremath\heartsuit}%
11099 \DeclareUnicodeCharacter{2662}{\ensuremath\diamondsuit}%
11100 \DeclareUnicodeCharacter{2663}{\ensuremath\clubsuit}%
11101 \DeclareUnicodeCharacter{266D}{\ensuremath\flat}%
11102 \DeclareUnicodeCharacter{266E}{\ensuremath\natural}%
11103 \DeclareUnicodeCharacter{266F}{\ensuremath\sharp}%
11104 \DeclareUnicodeCharacter{26AA}{\ensuremath\bigcirc}%
11105 \DeclareUnicodeCharacter{27B9}{\ensuremath\rangle}%
11106 \DeclareUnicodeCharacter{27C2}{\ensuremath\perp}%
11107 \DeclareUnicodeCharacter{27E8}{\ensuremath\langle}%
11108 \DeclareUnicodeCharacter{27F5}{\ensuremath\longleftarrow}%
11109 \DeclareUnicodeCharacter{27F6}{\ensuremath\longrightarrow}%
11110 \DeclareUnicodeCharacter{27F7}{\ensuremath\longleftrightarrow}%
11111 \DeclareUnicodeCharacter{27FC}{\ensuremath\longmapsto}%
11112 \DeclareUnicodeCharacter{29F5}{\ensuremath\setminus}%
11113 \DeclareUnicodeCharacter{2A00}{\ensuremath\bigodot}%
11114 \DeclareUnicodeCharacter{2A01}{\ensuremath\bigoplus}%
11115 \DeclareUnicodeCharacter{2A02}{\ensuremath\bigotimes}%
11116 \DeclareUnicodeCharacter{2A04}{\ensuremath\biguplus}%
11117 \DeclareUnicodeCharacter{2A06}{\ensuremath\bigsqcup}%
11118 \DeclareUnicodeCharacter{2A3F}{\ensuremath\amalg}%
11119 \DeclareUnicodeCharacter{2AAF}{\ensuremath\preceq}%
11120 \DeclareUnicodeCharacter{2AB0}{\ensuremath\succeq}%
11121 %
11122 \global\mathchardef\checkmark="1370% actually the square root sign
11123 \DeclareUnicodeCharacter{2713}{\ensuremath\checkmark}%
11124}% end of \unicodechardefs
11125
11126% UTF-8 byte sequence (pdfTeX) definitions (replacing and @U command)
11127% It makes the setting that replace UTF-8 byte sequence.
11128\def\utfeightchardefs{%
11129 \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterUTFviii
11130 \unicodechardefs
11131}
11132
11133% Whether the active definitions of non-ASCII characters expand to
11134% non-active tokens with the same character code. This is used to
11135% write characters literally, instead of using active definitions for
11136% printing the correct glyphs.
11137\newif\ifpassthroughchars
11138\passthroughcharsfalse
11139
11140% For native Unicode handling (XeTeX and LuaTeX),
11141% provide a definition macro to replace/pass-through a Unicode character
11142%
11143\def\DeclareUnicodeCharacterNative#1#2{%
11144 \ifnum"#1>"7F % only make non-ASCII chars active
11145 \catcode"#1=\active
11146 \def\dodeclareunicodecharacternative##1##2##3{%
11147 \begingroup
11148 \uccode`\~="##2\relax
11149 \uppercase{\gdef~}{%
11150 \ifpassthroughchars
11151 ##1%
11152 \else
11153 ##3%
11154 \fi
11155 }
11156 \endgroup
11157 }
11158 \begingroup
11159 \uccode`\.="#1\relax
11160 \uppercase{\def\UTFNativeTmp{.}}%
11161 \expandafter\dodeclareunicodecharacternative\UTFNativeTmp{#1}{#2}%
11162 \endgroup
11163 \fi
11164}
11165
11166% Native Unicode handling (XeTeX and LuaTeX) character replacing definition.
11167% It activates the setting that replaces Unicode characters.
11168\def\nativeunicodechardefs{%
11169 \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNative
11170 \unicodechardefs
11171}
11172
11173% For native Unicode handling (XeTeX and LuaTeX),
11174% make the character token expand
11175% to the sequences given in \unicodechardefs for printing.
11176\def\DeclareUnicodeCharacterNativeAtU#1#2{%
11177 \def\UTFAtUTmp{#2}
11178 \expandafter\globallet\csname uni:#1\endcsname \UTFAtUTmp
11179}
11180
11181% @U command definitions for native Unicode handling (XeTeX and LuaTeX).
11182\def\nativeunicodechardefsatu{%
11183 \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNativeAtU
11184 \unicodechardefs
11185}
11186
11187% US-ASCII character definitions.
11188\def\asciichardefs{% nothing need be done
11189 \relax
11190}
11191
11192% Define all Unicode characters we know about. This makes UTF-8 the default
11193% input encoding and allows @U to work.
11194\iftxinativeunicodecapable
11195 \nativeunicodechardefsatu
11196\else
11197 \utfeightchardefs
11198\fi
11199
11200\message{formatting,}
11201
11202\newdimen\defaultparindent \defaultparindent = 15pt
11203
11204\chapheadingskip = 15pt plus 4pt minus 2pt
11205\secheadingskip = 12pt plus 3pt minus 2pt
11206\subsecheadingskip = 9pt plus 2pt minus 2pt
11207
11208% Prevent underfull vbox error messages.
11209\vbadness = 10000
11210
11211% Don't be very finicky about underfull hboxes, either.
11212\hbadness = 6666
11213
11214% Following George Bush, get rid of widows and orphans.
11215\widowpenalty=10000
11216\clubpenalty=10000
11217
11218% Use TeX 3.0's \emergencystretch to help line breaking, but if we're
11219% using an old version of TeX, don't do anything. We want the amount of
11220% stretch added to depend on the line length, hence the dependence on
11221% \hsize. We call this whenever the paper size is set.
11222%
11223\def\setemergencystretch{%
11224 \ifx\emergencystretch\thisisundefined
11225 % Allow us to assign to \emergencystretch anyway.
11226 \def\emergencystretch{\dimen0}%
11227 \else
11228 \emergencystretch = .15\hsize
11229 \fi
11230}
11231
11232% Parameters in order: 1) textheight; 2) textwidth;
11233% 3) voffset; 4) hoffset; 5) binding offset; 6) topskip;
11234% 7) physical page height; 8) physical page width.
11235%
11236% We also call \setleading{\textleading}, so the caller should define
11237% \textleading. The caller should also set \parskip.
11238%
11239\def\internalpagesizes#1#2#3#4#5#6#7#8{%
11240 \voffset = #3\relax
11241 \topskip = #6\relax
11242 \splittopskip = \topskip
11243 %
11244 \vsize = #1\relax
11245 \advance\vsize by \topskip
11246 \txipageheight = \vsize
11247 %
11248 \hsize = #2\relax
11249 \txipagewidth = \hsize
11250 %
11251 \normaloffset = #4\relax
11252 \bindingoffset = #5\relax
11253 %
11254 \ifpdf
11255 \pdfpageheight #7\relax
11256 \pdfpagewidth #8\relax
11257 % if we don't reset these, they will remain at "1 true in" of
11258 % whatever layout pdftex was dumped with.
11259 \pdfhorigin = 1 true in
11260 \pdfvorigin = 1 true in
11261 \else
11262 \ifx\XeTeXrevision\thisisundefined
11263 \special{papersize=#8,#7}%
11264 \else
11265 \pdfpageheight #7\relax
11266 \pdfpagewidth #8\relax
11267 % XeTeX does not have \pdfhorigin and \pdfvorigin.
11268 \fi
11269 \fi
11270 %
11271 \setleading{\textleading}
11272 %
11273 \parindent = \defaultparindent
11274 \setemergencystretch
11275}
11276
11277% @letterpaper (the default).
11278\def\letterpaper{{\globaldefs = 1
11279 \parskip = 3pt plus 2pt minus 1pt
11280 \textleading = 13.2pt
11281 %
11282 % If page is nothing but text, make it come out even.
11283 \internalpagesizes{607.2pt}{6in}% that's 46 lines
11284 {\voffset}{.25in}%
11285 {\bindingoffset}{36pt}%
11286 {11in}{8.5in}%
11287}}
11288
11289% Use @smallbook to reset parameters for 7x9.25 trim size.
11290\def\smallbook{{\globaldefs = 1
11291 \parskip = 2pt plus 1pt
11292 \textleading = 12pt
11293 %
11294 \internalpagesizes{7.5in}{5in}%
11295 {-.2in}{0in}%
11296 {\bindingoffset}{16pt}%
11297 {9.25in}{7in}%
11298 %
11299 \lispnarrowing = 0.3in
11300 \tolerance = 700
11301 \contentsrightmargin = 0pt
11302 \defbodyindent = .5cm
11303}}
11304
11305% Use @afourpaper to print on European A4 paper.
11306\def\afourpaper{{\globaldefs = 1
11307 \parskip = 3pt plus 2pt minus 1pt
11308 \textleading = 13.2pt
11309 %
11310 % Double-side printing via postscript on Laserjet 4050
11311 % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm.
11312 % To change the settings for a different printer or situation, adjust
11313 % \normaloffset until the front-side and back-side texts align. Then
11314 % do the same for \bindingoffset. You can set these for testing in
11315 % your texinfo source file like this:
11316 % @tex
11317 % \global\normaloffset = -6mm
11318 % \global\bindingoffset = 10mm
11319 % @end tex
11320 \internalpagesizes{673.2pt}{160mm}% that's 51 lines
11321 {\voffset}{\hoffset}%
11322 {\bindingoffset}{44pt}%
11323 {297mm}{210mm}%
11324 %
11325 \tolerance = 700
11326 \contentsrightmargin = 0pt
11327 \defbodyindent = 5mm
11328}}
11329
11330% Use @afivepaper to print on European A5 paper.
11331% From [email protected], 2 July 2000.
11332% He also recommends making @example and @lisp be small.
11333\def\afivepaper{{\globaldefs = 1
11334 \parskip = 2pt plus 1pt minus 0.1pt
11335 \textleading = 12.5pt
11336 %
11337 \internalpagesizes{160mm}{120mm}%
11338 {\voffset}{-11.4mm}%
11339 {\bindingoffset}{8pt}%
11340 {210mm}{148mm}%
11341 %
11342 \lispnarrowing = 0.2in
11343 \tolerance = 800
11344 \contentsrightmargin = 0pt
11345 \defbodyindent = 2mm
11346 \tableindent = 12mm
11347}}
11348
11349% A specific text layout, 24x15cm overall, intended for A4 paper.
11350\def\afourlatex{{\globaldefs = 1
11351 \afourpaper
11352 \internalpagesizes{237mm}{150mm}%
11353 {\voffset}{4.6mm}%
11354 {\bindingoffset}{7mm}%
11355 {297mm}{210mm}%
11356 %
11357 % Must explicitly reset to 0 because we call \afourpaper.
11358 \globaldefs = 0
11359}}
11360
11361% Use @afourwide to print on A4 paper in landscape format.
11362\def\afourwide{{\globaldefs = 1
11363 \afourpaper
11364 \internalpagesizes{241mm}{165mm}%
11365 {\voffset}{-2.95mm}%
11366 {\bindingoffset}{7mm}%
11367 {297mm}{210mm}%
11368 \globaldefs = 0
11369}}
11370
11371\def\bsixpaper{{\globaldefs = 1
11372 \afourpaper
11373 \internalpagesizes{140mm}{100mm}%
11374 {-6.35mm}{-12.7mm}%
11375 {\bindingoffset}{14pt}%
11376 {176mm}{125mm}%
11377 \let\SETdispenvsize=\smallword
11378 \lispnarrowing = 0.2in
11379 \globaldefs = 0
11380}}
11381
11382
11383% @pagesizes TEXTHEIGHT[,TEXTWIDTH]
11384% Perhaps we should allow setting the margins, \topskip, \parskip,
11385% and/or leading, also. Or perhaps we should compute them somehow.
11386%
11387\parseargdef\pagesizes{\pagesizesyyy #1,,\finish}
11388\def\pagesizesyyy#1,#2,#3\finish{{%
11389 \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi
11390 \globaldefs = 1
11391 %
11392 \parskip = 3pt plus 2pt minus 1pt
11393 \setleading{\textleading}%
11394 %
11395 \dimen0 = #1\relax
11396 \advance\dimen0 by 2.5in % default 1in margin above heading line
11397 % and 1.5in to include heading, footing and
11398 % bottom margin
11399 %
11400 \dimen2 = \hsize
11401 \advance\dimen2 by 2in % default to 1 inch margin on each side
11402 %
11403 \internalpagesizes{#1}{\hsize}%
11404 {\voffset}{\normaloffset}%
11405 {\bindingoffset}{44pt}%
11406 {\dimen0}{\dimen2}%
11407}}
11408
11409% Set default to letter.
11410%
11411\letterpaper
11412
11413% Default value of \hfuzz, for suppressing warnings about overfull hboxes.
11414\hfuzz = 1pt
11415
11416
11417\message{microtype,}
11418
11419% protrusion, from Thanh's protcode.tex.
11420\def\mtsetprotcode#1{%
11421 \rpcode#1`\!=200 \rpcode#1`\,=700 \rpcode#1`\-=700 \rpcode#1`\.=700
11422 \rpcode#1`\;=500 \rpcode#1`\:=500 \rpcode#1`\?=200
11423 \rpcode#1`\'=700
11424 \rpcode#1 34=500 % ''
11425 \rpcode#1 123=300 % --
11426 \rpcode#1 124=200 % ---
11427 \rpcode#1`\)=50 \rpcode#1`\A=50 \rpcode#1`\F=50 \rpcode#1`\K=50
11428 \rpcode#1`\L=50 \rpcode#1`\T=50 \rpcode#1`\V=50 \rpcode#1`\W=50
11429 \rpcode#1`\X=50 \rpcode#1`\Y=50 \rpcode#1`\k=50 \rpcode#1`\r=50
11430 \rpcode#1`\t=50 \rpcode#1`\v=50 \rpcode#1`\w=50 \rpcode#1`\x=50
11431 \rpcode#1`\y=50
11432 %
11433 \lpcode#1`\`=700
11434 \lpcode#1 92=500 % ``
11435 \lpcode#1`\(=50 \lpcode#1`\A=50 \lpcode#1`\J=50 \lpcode#1`\T=50
11436 \lpcode#1`\V=50 \lpcode#1`\W=50 \lpcode#1`\X=50 \lpcode#1`\Y=50
11437 \lpcode#1`\v=50 \lpcode#1`\w=50 \lpcode#1`\x=50 \lpcode#1`\y=0
11438 %
11439 \mtadjustprotcode#1\relax
11440}
11441
11442\def\mtadjustprotcode#1{%
11443 \countA=0
11444 \loop
11445 \ifcase\lpcode#1\countA\else
11446 \mtadjustcp\lpcode#1\countA
11447 \fi
11448 \ifcase\rpcode#1\countA\else
11449 \mtadjustcp\rpcode#1\countA
11450 \fi
11451 \advance\countA 1
11452 \ifnum\countA < 256 \repeat
11453}
11454
11455\newcount\countB
11456\def\mtadjustcp#1#2#3{%
11457 \setbox\boxA=\hbox{%
11458 \ifx#2\font\else#2\fi
11459 \char#3}%
11460 \countB=\wd\boxA
11461 \multiply\countB #1#2#3\relax
11462 \divide\countB \fontdimen6 #2\relax
11463 #1#2#3=\countB\relax
11464}
11465
11466\ifx\XeTeXrevision\thisisundefined
11467 \ifx\luatexversion\thisisundefined
11468 \ifpdf % pdfTeX
11469 \mtsetprotcode\textrm
11470 \def\mtfontexpand#1{\pdffontexpand#1 20 20 1 autoexpand\relax}
11471 \else % TeX
11472 \def\mtfontexpand#1{}
11473 \fi
11474 \else % LuaTeX
11475 \mtsetprotcode\textrm
11476 \def\mtfontexpand#1{\expandglyphsinfont#1 20 20 1\relax}
11477 \fi
11478\else % XeTeX
11479 \mtsetprotcode\textrm
11480 \def\mtfontexpand#1{}
11481\fi
11482
11483
11484\newif\ifmicrotype
11485
11486\def\microtypeON{%
11487 \microtypetrue
11488 %
11489 \ifx\XeTeXrevision\thisisundefined
11490 \ifx\luatexversion\thisisundefined
11491 \ifpdf % pdfTeX
11492 \pdfadjustspacing=2
11493 \pdfprotrudechars=2
11494 \fi
11495 \else % LuaTeX
11496 \adjustspacing=2
11497 \protrudechars=2
11498 \fi
11499 \else % XeTeX
11500 \XeTeXprotrudechars=2
11501 \fi
11502 %
11503 \mtfontexpand\textrm
11504 \mtfontexpand\textsl
11505 \mtfontexpand\textbf
11506}
11507
11508\def\microtypeOFF{%
11509 \microtypefalse
11510 %
11511 \ifx\XeTeXrevision\thisisundefined
11512 \ifx\luatexversion\thisisundefined
11513 \ifpdf % pdfTeX
11514 \pdfadjustspacing=0
11515 \pdfprotrudechars=0
11516 \fi
11517 \else % LuaTeX
11518 \adjustspacing=0
11519 \protrudechars=0
11520 \fi
11521 \else % XeTeX
11522 \XeTeXprotrudechars=0
11523 \fi
11524}
11525
11526\microtypeON
11527
11528\parseargdef\microtype{%
11529 \def\txiarg{#1}%
11530 \ifx\txiarg\onword
11531 \microtypeON
11532 \else\ifx\txiarg\offword
11533 \microtypeOFF
11534 \else
11535 \errhelp = \EMsimple
11536 \errmessage{Unknown @microtype option `\txiarg', must be on|off}%
11537 \fi\fi
11538}
11539
11540
11541\message{and turning on texinfo input format.}
11542
11543\def^^L{\par} % remove \outer, so ^L can appear in an @comment
11544\catcode`\^^K = 10 % treat vertical tab as whitespace
11545
11546% DEL is a comment character, in case @c does not suffice.
11547\catcode`\^^? = 14
11548
11549% Define macros to output various characters with catcode for normal text.
11550\catcode`\"=\other \def\normaldoublequote{"}
11551\catcode`\$=\other \def\normaldollar{$}%$ font-lock fix
11552\catcode`\+=\other \def\normalplus{+}
11553\catcode`\<=\other \def\normalless{<}
11554\catcode`\>=\other \def\normalgreater{>}
11555\catcode`\^=\other \def\normalcaret{^}
11556\catcode`\_=\other \def\normalunderscore{_}
11557\catcode`\|=\other \def\normalverticalbar{|}
11558\catcode`\~=\other \def\normaltilde{~}
11559
11560% Set catcodes for Texinfo file
11561
11562% Active characters for printing the wanted glyph.
11563% Most of these we simply print from the \tt font, but for some, we can
11564% use math or other variants that look better in normal text.
11565%
11566\catcode`\"=\active
11567\def\activedoublequote{{\tt\char34}}
11568\let"=\activedoublequote
11569\catcode`\~=\active \def\activetilde{{\tt\char126}} \let~ = \activetilde
11570\chardef\hatchar=`\^
11571\catcode`\^=\active \def\activehat{{\tt \hatchar}} \let^ = \activehat
11572
11573\catcode`\_=\active
11574\def_{\ifusingtt\normalunderscore\_}
11575\def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }
11576\let\realunder=_
11577
11578\catcode`\|=\active \def|{{\tt\char124}}
11579
11580\chardef \less=`\<
11581\catcode`\<=\active \def\activeless{{\tt \less}}\let< = \activeless
11582\chardef \gtr=`\>
11583\catcode`\>=\active \def\activegtr{{\tt \gtr}}\let> = \activegtr
11584\catcode`\+=\active \def+{{\tt \char 43}}
11585\catcode`\$=\active \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix
11586\catcode`\-=\active \let-=\normaldash
11587
11588
11589% used for headline/footline in the output routine, in case the page
11590% breaks in the middle of an @tex block.
11591\def\texinfochars{%
11592 \let< = \activeless
11593 \let> = \activegtr
11594 \let~ = \activetilde
11595 \let^ = \activehat
11596 \setregularquotes
11597 \let\b = \strong
11598 \let\i = \smartitalic
11599 % in principle, all other definitions in \tex have to be undone too.
11600}
11601
11602% Used sometimes to turn off (effectively) the active characters even after
11603% parsing them.
11604\def\turnoffactive{%
11605 \normalturnoffactive
11606 \otherbackslash
11607}
11608
11609\catcode`\@=0
11610
11611% \backslashcurfont outputs one backslash character in current font,
11612% as in \char`\\.
11613\global\chardef\backslashcurfont=`\\
11614
11615% \realbackslash is an actual character `\' with catcode other.
11616{\catcode`\\=\other @gdef@realbackslash{\}}
11617
11618% In Texinfo, backslash is an active character; it prints the backslash
11619% in fixed width font.
11620\catcode`\\=\active % @ for escape char from now on.
11621
11622% Print a typewriter backslash. For math mode, we can't simply use
11623% \backslashcurfont: the story here is that in math mode, the \char
11624% of \backslashcurfont ends up printing the roman \ from the math symbol
11625% font (because \char in math mode uses the \mathcode, and plain.tex
11626% sets \mathcode`\\="026E). Hence we use an explicit \mathchar,
11627% which is the decimal equivalent of "715c (class 7, e.g., use \fam;
11628% ignored family value; char position "5C). We can't use " for the
11629% usual hex value because it has already been made active.
11630
11631@def@ttbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}}
11632@let@backslashchar = @ttbackslash % @backslashchar{} is for user documents.
11633
11634% \otherbackslash defines an active \ to be a literal `\' character with
11635% catcode other.
11636@gdef@otherbackslash{@let\=@realbackslash}
11637
11638% Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
11639% the literal character `\'.
11640%
11641{@catcode`- = @active
11642 @gdef@normalturnoffactive{%
11643 @passthroughcharstrue
11644 @let-=@normaldash
11645 @let"=@normaldoublequote
11646 @let$=@normaldollar %$ font-lock fix
11647 @let+=@normalplus
11648 @let<=@normalless
11649 @let>=@normalgreater
11650 @let^=@normalcaret
11651 @let_=@normalunderscore
11652 @let|=@normalverticalbar
11653 @let~=@normaltilde
11654 @let\=@ttbackslash
11655 @setregularquotes
11656 @unsepspaces
11657 }
11658}
11659
11660% If a .fmt file is being used, characters that might appear in a file
11661% name cannot be active until we have parsed the command line.
11662% So turn them off again, and have @fixbackslash turn them back on.
11663@catcode`+=@other @catcode`@_=@other
11664
11665% \enablebackslashhack - allow file to begin `\input texinfo'
11666%
11667% If a .fmt file is being used, we don't want the `\input texinfo' to show up.
11668% That is what \eatinput is for; after that, the `\' should revert to printing
11669% a backslash.
11670% If the file did not have a `\input texinfo', then it is turned off after
11671% the first line; otherwise the first `\' in the file would cause an error.
11672% This is used on the very last line of this file, texinfo.tex.
11673% We also use @c to call @fixbackslash, in case ends of lines are hidden.
11674{
11675@catcode`@^=7
11676@catcode`@^^M=13@gdef@enablebackslashhack{%
11677 @global@let\ = @eatinput%
11678 @catcode`@^^M=13%
11679 @def@c{@fixbackslash@c}%
11680 % Definition for the newline at the end of this file.
11681 @def ^^M{@let^^M@secondlinenl}%
11682 % Definition for a newline in the main Texinfo file.
11683 @gdef @secondlinenl{@fixbackslash}%
11684 % In case the first line has a whole-line command on it
11685 @let@originalparsearg@parsearg
11686 @def@parsearg{@fixbackslash@originalparsearg}
11687}}
11688
11689{@catcode`@^=7 @catcode`@^^M=13%
11690@gdef@eatinput input texinfo#1^^M{@fixbackslash}}
11691
11692% Emergency active definition of newline, in case an active newline token
11693% appears by mistake.
11694{@catcode`@^=7 @catcode13=13%
11695@gdef@enableemergencynewline{%
11696 @gdef^^M{%
11697 @par%
11698 %<warning: active newline>@par%
11699}}}
11700
11701
11702@gdef@fixbackslash{%
11703 @ifx\@eatinput @let\ = @ttbackslash @fi
11704 @catcode13=5 % regular end of line
11705 @enableemergencynewline
11706 @let@c=@comment
11707 @let@parsearg@originalparsearg
11708 % Also turn back on active characters that might appear in the input
11709 % file name, in case not using a pre-dumped format.
11710 @catcode`+=@active
11711 @catcode`@_=@active
11712 %
11713 % If texinfo.cnf is present on the system, read it.
11714 % Useful for site-wide @afourpaper, etc. This macro, @fixbackslash, gets
11715 % called at the beginning of every Texinfo file. Not opening texinfo.cnf
11716 % directly in this file, texinfo.tex, makes it possible to make a format
11717 % file for Texinfo.
11718 %
11719 @openin 1 texinfo.cnf
11720 @ifeof 1 @else @input texinfo.cnf @fi
11721 @closein 1
11722}
11723
11724
11725% Say @foo, not \foo, in error messages.
11726@escapechar = `@@
11727
11728% These (along with & and #) are made active for url-breaking, so need
11729% active definitions as the normal characters.
11730@def@normaldot{.}
11731@def@normalquest{?}
11732@def@normalslash{/}
11733
11734% These look ok in all fonts, so just make them not special.
11735% @hashchar{} gets its own user-level command, because of #line.
11736@catcode`@& = @other @def@normalamp{&}
11737@catcode`@# = @other @def@normalhash{#}
11738@catcode`@% = @other @def@normalpercent{%}
11739
11740@let @hashchar = @normalhash
11741
11742@c Finally, make ` and ' active, so that txicodequoteundirected and
11743@c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}. If we
11744@c don't make ` and ' active, @code will not get them as active chars.
11745@c Do this last of all since we use ` in the previous @catcode assignments.
11746@catcode`@'=@active
11747@catcode`@`=@active
11748@setregularquotes
11749
11750@c Local variables:
11751@c eval: (add-hook 'before-save-hook 'time-stamp nil t)
11752@c time-stamp-pattern: "texinfoversion{%Y-%02m-%02d.%02H}"
11753@c page-delimiter: "^\\\\message\\|emacs-page"
11754@c End:
11755
11756@c vim:sw=2:
11757
11758@enablebackslashhack
11759
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette