]> git.ipfire.org Git - thirdparty/glibc.git/blame - manual/texinfo.tex
locale: Avoid zero-length array in _nl_category_names [BZ #24962]
[thirdparty/glibc.git] / manual / texinfo.tex
CommitLineData
2eb45444 1% texinfo.tex -- TeX macros to handle Texinfo files.
d667195c
UD
2%
3% Load plain if necessary, i.e., if running under initex.
4\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
5%
7628a1b0 6\def\texinfoversion{2018-12-28.17}
2eb45444 7%
7628a1b0 8% Copyright 1985, 1986, 1988, 1990-2018 Free Software Foundation, Inc.
2eb45444 9%
c94f48d7 10% This texinfo.tex file is free software: you can redistribute it and/or
2eb45444 11% modify it under the terms of the GNU General Public License as
c94f48d7
AJ
12% published by the Free Software Foundation, either version 3 of the
13% License, or (at your option) any later version.
2eb45444
UD
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
41d11b15 21% along with this program. If not, see <https://www.gnu.org/licenses/>.
2eb45444 22%
82d5ce1d
UD
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
8fcb833a
JM
25% restriction. This Exception is an additional permission under section 7
26% of the GNU General Public License, version 3 ("GPLv3").
2eb45444
UD
27%
28% Please try the latest version of texinfo.tex before submitting bug
29% reports; you can get the latest version from:
41d11b15
JM
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)
82d5ce1d 33% The texinfo.tex in any given distribution could well be out
0c2b5752 34% of date, so if that's what you're using, please check.
7158eae4 35%
407dc7a0
UD
36% Send bug reports to bug-texinfo@gnu.org. Please include including a
37% complete document in each bug report with which we can reproduce the
38% problem. Patches are, of course, greatly appreciated.
b710a6e2 39%
40c0dc53 40% To process a Texinfo manual with TeX, it's most reliable to use the
407dc7a0
UD
41% texi2dvi shell script that comes with the distribution. For a simple
42% manual foo.texi, however, you can get away with this:
40c0dc53
UD
43% tex foo.texi
44% texindex foo.??
45% tex foo.texi
46% tex foo.texi
27692f89 47% dvips foo.dvi -o # or whatever; this makes foo.ps.
7ed7ad59 48% The extra TeX runs get the cross-reference information correct.
40c0dc53
UD
49% Sometimes one run after texindex suffices, and sometimes you need more
50% than two; texi2dvi does it as many times as necessary.
7158eae4 51%
e0f86659
UD
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.
82d5ce1d 55%
41d11b15 56% The GNU Texinfo home page is https://www.gnu.org/software/texinfo.
82d5ce1d 57
9e9f9cc2 58
1e02536f 59\message{Loading texinfo [version \texinfoversion]:}
9e9f9cc2
KB
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.
1e02536f 64\everyjob{\message{[Texinfo version \texinfoversion]}%
9e9f9cc2
KB
65 \catcode`+=\active \catcode`\_=\active}
66
7f7dd1d3
JM
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
2f5b1124
UD
71\chardef\other=12
72
7158eae4 73% We never want plain's \outer definition of \+ in Texinfo.
2f5b1124
UD
74% For @tex, we can use \tabalign.
75\let\+ = \relax
76
7158eae4 77% Save some plain tex macros whose names we will redefine.
9e9f9cc2 78\let\ptexb=\b
359a1d0b 79\let\ptexbullet=\bullet
9e9f9cc2 80\let\ptexc=\c
359a1d0b
KB
81\let\ptexcomma=\,
82\let\ptexdot=\.
83\let\ptexdots=\dots
84\let\ptexend=\end
2eb45444
UD
85\let\ptexequiv=\equiv
86\let\ptexexclam=\!
82d5ce1d 87\let\ptexfootnote=\footnote
2f5b1124
UD
88\let\ptexgtr=>
89\let\ptexhat=^
9e9f9cc2 90\let\ptexi=\i
7158eae4 91\let\ptexindent=\indent
82d5ce1d 92\let\ptexinsert=\insert
359a1d0b 93\let\ptexlbrace=\{
2f5b1124 94\let\ptexless=<
82d5ce1d
UD
95\let\ptexnewwrite\newwrite
96\let\ptexnoindent=\noindent
2f5b1124 97\let\ptexplus=+
0f8bbd69 98\let\ptexraggedright=\raggedright
359a1d0b 99\let\ptexrbrace=\}
7158eae4 100\let\ptexslash=\/
084e7d57 101\let\ptexsp=\sp
359a1d0b 102\let\ptexstar=\*
084e7d57 103\let\ptexsup=\sup
9e9f9cc2 104\let\ptext=\t
0f8bbd69
JM
105\let\ptextop=\top
106{\catcode`\'=\active \global\let\ptexquoteright'}% active in plain's math mode
9e9f9cc2 107
9e9f9cc2
KB
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
82d5ce1d
UD
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
f962d792 121% Set up fixed words for English if not already set.
407dc7a0 122\ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi
b710a6e2 123\ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi
0f8bbd69 124\ifx\putworderror\undefined \gdef\putworderror{error}\fi
b710a6e2 125\ifx\putwordfile\undefined \gdef\putwordfile{file}\fi
13632cfc 126\ifx\putwordin\undefined \gdef\putwordin{in}\fi
0f8bbd69
JM
127\ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi
128\ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi
b710a6e2 129\ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi
13632cfc 130\ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi
b710a6e2 131\ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi
407dc7a0
UD
132\ifx\putwordNoTitle\undefined \gdef\putwordNoTitle{No Title}\fi
133\ifx\putwordof\undefined \gdef\putwordof{of}\fi
b710a6e2
UD
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
407dc7a0
UD
140\ifx\putwordShortTOC\undefined \gdef\putwordShortTOC{Short Contents}\fi
141\ifx\putwordTOC\undefined \gdef\putwordTOC{Table of Contents}\fi
b710a6e2
UD
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
407dc7a0 147\ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi
b710a6e2
UD
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%
407dc7a0
UD
156\ifx\putwordDefmac\undefined \gdef\putwordDefmac{Macro}\fi
157\ifx\putwordDefspec\undefined \gdef\putwordDefspec{Special Form}\fi
407dc7a0
UD
158\ifx\putwordDefvar\undefined \gdef\putwordDefvar{Variable}\fi
159\ifx\putwordDefopt\undefined \gdef\putwordDefopt{User Option}\fi
407dc7a0 160\ifx\putwordDeffunc\undefined \gdef\putwordDeffunc{Function}\fi
9e9f9cc2 161
084e7d57
JM
162% Give the space character the catcode for a space.
163\def\spaceisspace{\catcode`\ =10\relax}
9251c568 164
41d11b15
JM
165% Likewise for ^^M, the end of line character.
166\def\endlineisspace{\catcode13=10\relax}
167
9251c568 168\chardef\dashChar = `\-
0f8bbd69 169\chardef\slashChar = `\/
a334319f 170\chardef\underChar = `\_
0ecb606c 171
9e9f9cc2
KB
172% Ignore a token.
173%
174\def\gobble#1{}
175
82d5ce1d
UD
176% The following is used inside several \edef's.
177\def\makecsname#1{\expandafter\noexpand\csname#1\endcsname}
2f5b1124
UD
178
179% Hyphenation fixes.
82d5ce1d
UD
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}
9e9f9cc2 190
9e9f9cc2
KB
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,
2f5b1124
UD
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.
9e9f9cc2
KB
196%
197\def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
2f5b1124
UD
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
0f8bbd69 207 \ifx\eTeXversion\thisisundefined\else % etex gives us more logging
2f5b1124
UD
208 \tracingscantokens1
209 \tracingifs1
210 \tracinggroups1
211 \tracingnesting2
212 \tracingassigns1
213 \fi
214 \tracingcommands3 % 3 gives us more in etex
82d5ce1d 215 \errorcontextlines16
61027f30 216}%
9e9f9cc2 217
0f8bbd69
JM
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
be1152ca
UD
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.
7158eae4 227%
be1152ca
UD
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
084e7d57
JM
235%\f Output routine
236%
237
238% For a final copy, take out the rectangles
239% that mark overfull boxes (in case you have decided
240% that the text looks ok even though it passes the margin).
241%
242\def\finalout{\overfullrule=0pt }
243
0c2b5752 244\newdimen\outerhsize \newdimen\outervsize % set by the paper size routines
0c2b5752 245\newdimen\topandbottommargin \topandbottommargin=.75in
9e9f9cc2 246
c94f48d7
AJ
247% Output a mark which sets \thischapter, \thissection and \thiscolor.
248% We dump everything together because we only have one kind of mark.
249% This works because we only use \botmark / \topmark, not \firstmark.
250%
251% A mark contains a subexpression of the \ifcase ... \fi construct.
252% \get*marks macros below extract the needed part using \ifcase.
253%
254% Another complication is to let the user choose whether \thischapter
255% (\thissection) refers to the chapter (section) in effect at the top
084e7d57
JM
256% of a page, or that at the bottom of a page.
257
258% \domark is called twice inside \chapmacro, to add one
259% mark before the section break, and one after.
260% In the second call \prevchapterdefs is the same as \lastchapterdefs,
261% and \prevsectiondefs is the same as \lastsectiondefs.
262% Then if the page is not broken at the mark, some of the previous
263% section appears on the page, and we can get the name of this section
264% from \firstmark for @everyheadingmarks top.
265% @everyheadingmarks bottom uses \botmark.
266%
267% See page 260 of The TeXbook.
c94f48d7
AJ
268\def\domark{%
269 \toks0=\expandafter{\lastchapterdefs}%
270 \toks2=\expandafter{\lastsectiondefs}%
271 \toks4=\expandafter{\prevchapterdefs}%
272 \toks6=\expandafter{\prevsectiondefs}%
273 \toks8=\expandafter{\lastcolordefs}%
274 \mark{%
084e7d57
JM
275 \the\toks0 \the\toks2 % 0: marks for @everyheadingmarks top
276 \noexpand\or \the\toks4 \the\toks6 % 1: for @everyheadingmarks bottom
21fea2e2 277 \noexpand\else \the\toks8 % 2: color marks
c94f48d7
AJ
278 }%
279}
084e7d57
JM
280
281% \gettopheadingmarks, \getbottomheadingmarks,
282% \getcolormarks - extract needed part of mark.
283%
c94f48d7
AJ
284% \topmark doesn't work for the very first chapter (after the title
285% page or the contents), so we use \firstmark there -- this gets us
286% the mark with the chapter defs, unless the user sneaks in, e.g.,
287% @setcolor (or @url, or @link, etc.) between @contents and the very
288% first @chapter.
289\def\gettopheadingmarks{%
290 \ifcase0\topmark\fi
291 \ifx\thischapter\empty \ifcase0\firstmark\fi \fi
292}
293\def\getbottomheadingmarks{\ifcase1\botmark\fi}
294\def\getcolormarks{\ifcase2\topmark\fi}
295
296% Avoid "undefined control sequence" errors.
297\def\lastchapterdefs{}
298\def\lastsectiondefs{}
084e7d57 299\def\lastsection{}
c94f48d7
AJ
300\def\prevchapterdefs{}
301\def\prevsectiondefs{}
302\def\lastcolordefs{}
303
084e7d57
JM
304% Margin to add to right of even pages, to left of odd pages.
305\newdimen\bindingoffset
306\newdimen\normaloffset
7f7dd1d3 307\newdimen\txipagewidth \newdimen\txipageheight
084e7d57 308
f5311448 309% Main output routine.
084e7d57 310%
f5311448
KB
311\chardef\PAGE = 255
312\output = {\onepageout{\pagecontents\PAGE}}
313
779ae82e
UD
314\newbox\headlinebox
315\newbox\footlinebox
f5311448 316
084e7d57 317% \onepageout takes a vbox as an argument.
7628a1b0
JM
318% \shipout a vbox for a single page, adding an optional header, footer
319% and footnote. This also causes index entries for this page to be written
320% to the auxiliary files.
084e7d57 321%
359a1d0b 322\def\onepageout#1{%
7628a1b0 323 \hoffset=\normaloffset
779ae82e 324 %
359a1d0b
KB
325 \ifodd\pageno \advance\hoffset by \bindingoffset
326 \else \advance\hoffset by -\bindingoffset\fi
f5311448 327 %
084e7d57 328 % Common context changes for both heading and footing.
f5311448
KB
329 % Do this outside of the \shipout so @code etc. will be expanded in
330 % the headline as they should be, not taken literally (outputting ''code).
7f7dd1d3 331 \def\commmonheadfootline{\let\hsize=\txipagewidth \texinfochars}
21fea2e2 332 %
084e7d57
JM
333 % Retrieve the information for the headings from the marks in the page,
334 % and call Plain TeX's \makeheadline and \makefootline, which use the
335 % values in \headline and \footline.
336 %
337 % This is used to check if we are on the first page of a chapter.
338 \ifcase1\topmark\fi
339 \let\prevchaptername\thischaptername
340 \ifcase0\firstmark\fi
341 \let\curchaptername\thischaptername
21fea2e2 342 %
084e7d57 343 \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi
c94f48d7 344 \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi
084e7d57
JM
345 %
346 \ifx\curchaptername\prevchaptername
347 \let\thischapterheading\thischapter
348 \else
349 % \thischapterheading is the same as \thischapter except it is blank
350 % for the first page of a chapter. This is to prevent the chapter name
351 % being shown twice.
352 \def\thischapterheading{}%
353 \fi
354 %
355 \global\setbox\headlinebox = \vbox{\commmonheadfootline \makeheadline}%
21fea2e2 356 \global\setbox\footlinebox = \vbox{\commmonheadfootline \makefootline}%
f5311448 357 %
359a1d0b 358 {%
084e7d57 359 % Set context for writing to auxiliary files like index files.
f5311448
KB
360 % Have to do this stuff outside the \shipout because we want it to
361 % take effect in \write's, yet the group defined by the \vbox ends
362 % before the \shipout runs.
363 %
23a01afe
KB
364 \indexdummies % don't expand commands in the output.
365 \normalturnoffactive % \ in index entries must not stay \, e.g., if
9251c568
AJ
366 % the page break happens to be in the middle of an example.
367 % We don't want .vr (or whatever) entries like this:
084e7d57 368 % \entry{{\indexbackslash }acronym}{32}{\code {\acronym}}
9251c568 369 % "\acronym" won't work when it's read back in;
0f8bbd69 370 % it needs to be
084e7d57 371 % {\code {{\backslashcurfont }acronym}
359a1d0b 372 \shipout\vbox{%
3bc88c40 373 % Do this early so pdf references go to the beginning of the page.
82d5ce1d 374 \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi
3bc88c40 375 %
f5311448 376 \unvbox\headlinebox
359a1d0b 377 \pagebody{#1}%
d705269e
UD
378 \ifdim\ht\footlinebox > 0pt
379 % Only leave this space if the footline is nonempty.
9251c568 380 % (We lessened \vsize for it in \oddfootingyyy.)
d705269e 381 % The \baselineskip=24pt in plain's \makefootline has no effect.
9251c568 382 \vskip 24pt
d705269e
UD
383 \unvbox\footlinebox
384 \fi
779ae82e 385 %
51702635 386 }% end of \shipout\vbox
9251c568 387 }% end of group with \indexdummies
359a1d0b
KB
388 \advancepageno
389 \ifnum\outputpenalty>-20000 \else\dosupereject\fi
390}
9e9f9cc2 391
9e9f9cc2
KB
392\newinsert\margin \dimen\margin=\maxdimen
393
084e7d57 394% Main part of page, including any footnotes
7f7dd1d3 395\def\pagebody#1{\vbox to\txipageheight{\boxmaxdepth=\maxdepth #1}}
9e9f9cc2
KB
396{\catcode`\@ =11
397\gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
398% marginal hacks, juha@viisa.uucp (Juha Takala)
399\ifvoid\margin\else % marginal info is present
400 \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi
c94f48d7 401\dimen@=\dp#1\relax \unvbox#1\relax
9e9f9cc2
KB
402\ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
403\ifr@ggedbottom \kern-\dimen@ \vfil \fi}
404}
405
084e7d57
JM
406
407% Argument parsing
408
9e9f9cc2
KB
409% Parse an argument, then pass it to #1. The argument is the rest of
410% the input line (except we remove a trailing comment). #1 should be a
411% macro which expects an ordinary undelimited TeX argument.
084e7d57 412% For example, \def\foo{\parsearg\fooxxx}.
9e9f9cc2 413%
82d5ce1d
UD
414\def\parsearg{\parseargusing{}}
415\def\parseargusing#1#2{%
9251c568 416 \def\argtorun{#2}%
9e9f9cc2
KB
417 \begingroup
418 \obeylines
82d5ce1d
UD
419 \spaceisspace
420 #1%
421 \parseargline\empty% Insert the \empty token, see \finishparsearg below.
a334319f
UD
422}
423
9e9f9cc2
KB
424{\obeylines %
425 \gdef\parseargline#1^^M{%
426 \endgroup % End of the group started in \parsearg.
82d5ce1d 427 \argremovecomment #1\comment\ArgTerm%
9e9f9cc2
KB
428 }%
429}
430
084e7d57
JM
431% First remove any @comment, then any @c comment. Also remove a @texinfoc
432% comment (see \scanmacro for details). Pass the result on to \argcheckspaces.
82d5ce1d 433\def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm}
084e7d57
JM
434\def\argremovec#1\c#2\ArgTerm{\argremovetexinfoc #1\texinfoc\ArgTerm}
435\def\argremovetexinfoc#1\texinfoc#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
9e9f9cc2 436
0f8bbd69 437% Each occurrence of `\^^M' or `<space>\^^M' is replaced by a single space.
82d5ce1d
UD
438%
439% \argremovec might leave us with trailing space, e.g.,
9e9f9cc2 440% @end itemize @c foo
82d5ce1d
UD
441% This space token undergoes the same procedure and is eventually removed
442% by \finishparsearg.
443%
444\def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M}
445\def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M}
446\def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{%
447 \def\temp{#3}%
448 \ifx\temp\empty
9251c568 449 % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp:
82d5ce1d
UD
450 \let\temp\finishparsearg
451 \else
452 \let\temp\argcheckspaces
453 \fi
454 % Put the space token in:
455 \temp#1 #3\ArgTerm
9e9f9cc2
KB
456}
457
82d5ce1d
UD
458% If a _delimited_ argument is enclosed in braces, they get stripped; so
459% to get _exactly_ the rest of the line, we had to prevent such situation.
460% We prepended an \empty token at the very beginning and we expand it now,
9251c568 461% just before passing the control to \argtorun.
0f8bbd69 462% (Similarly, we have to think about #3 of \argcheckspacesY above: it is
82d5ce1d
UD
463% either the null string, or it ends with \^^M---thus there is no danger
464% that a pair of braces would be stripped.
9e9f9cc2 465%
82d5ce1d
UD
466% But first, we have to remove the trailing space token.
467%
9251c568 468\def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}}
82d5ce1d 469
084e7d57
JM
470
471% \parseargdef - define a command taking an argument on the line
472%
82d5ce1d
UD
473% \parseargdef\foo{...}
474% is roughly equivalent to
475% \def\foo{\parsearg\Xfoo}
476% \def\Xfoo#1{...}
82d5ce1d
UD
477\def\parseargdef#1{%
478 \expandafter \doparseargdef \csname\string#1\endcsname #1%
479}
480\def\doparseargdef#1#2{%
481 \def#2{\parsearg#1}%
482 \def#1##1%
483}
484
485% Several utility definitions with active space:
486{
9e9f9cc2 487 \obeyspaces
82d5ce1d
UD
488 \gdef\obeyedspace{ }
489
490 % Make each space character in the input produce a normal interword
491 % space in the output. Don't allow a line break at this space, as this
492 % is used only in environments like @example, where each line of input
493 % should produce a line of output anyway.
494 %
495 \gdef\sepspaces{\obeyspaces\let =\tie}
496
497 % If an index command is used in an @example environment, any spaces
498 % therein should become regular spaces in the raw index file, not the
499 % expansion of \tie (\leavevmode \penalty \@M \ ).
500 \gdef\unsepspaces{\let =\space}
501}
9e9f9cc2
KB
502
503
504\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
505
82d5ce1d
UD
506% Define the framework for environments in texinfo.tex. It's used like this:
507%
508% \envdef\foo{...}
509% \def\Efoo{...}
510%
511% It's the responsibility of \envdef to insert \begingroup before the
512% actual body; @end closes the group after calling \Efoo. \envdef also
513% defines \thisenv, so the current environment is known; @end checks
514% whether the environment name matches. The \checkenv macro can also be
515% used to check whether the current environment is the one expected.
516%
517% Non-false conditionals (@iftex, @ifset) don't fit into this, so they
0f8bbd69 518% are not treated as environments; they don't open a group. (The
82d5ce1d
UD
519% implementation of @end takes care not to call \endgroup in this
520% special case.)
9e9f9cc2 521
9e9f9cc2 522
0f8bbd69 523% At run-time, environments start with this:
82d5ce1d
UD
524\def\startenvironment#1{\begingroup\def\thisenv{#1}}
525% initialize
526\let\thisenv\empty
9e9f9cc2 527
82d5ce1d
UD
528% ... but they get defined via ``\envdef\foo{...}'':
529\long\def\envdef#1#2{\def#1{\startenvironment#1#2}}
530\def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}}
9e9f9cc2 531
82d5ce1d
UD
532% Check whether we're in the right environment:
533\def\checkenv#1{%
534 \def\temp{#1}%
535 \ifx\thisenv\temp
9e9f9cc2 536 \else
82d5ce1d 537 \badenverr
9e9f9cc2
KB
538 \fi
539}
540
0f8bbd69 541% Environment mismatch, #1 expected:
82d5ce1d 542\def\badenverr{%
9e9f9cc2 543 \errhelp = \EMsimple
82d5ce1d
UD
544 \errmessage{This command can appear only \inenvironment\temp,
545 not \inenvironment\thisenv}%
546}
547\def\inenvironment#1{%
548 \ifx#1\empty
0f8bbd69 549 outside of any environment%
82d5ce1d
UD
550 \else
551 in environment \expandafter\string#1%
552 \fi
9e9f9cc2
KB
553}
554
82d5ce1d
UD
555% @end foo executes the definition of \Efoo.
556% But first, it executes a specialized version of \checkenv
9e9f9cc2 557%
82d5ce1d
UD
558\parseargdef\end{%
559 \if 1\csname iscond.#1\endcsname
560 \else
0f8bbd69 561 % The general wording of \badenverr may not be ideal.
82d5ce1d
UD
562 \expandafter\checkenv\csname#1\endcsname
563 \csname E#1\endcsname
564 \endgroup
565 \fi
9e9f9cc2
KB
566}
567
82d5ce1d
UD
568\newhelp\EMsimple{Press RETURN to continue.}
569
9e9f9cc2 570
40c0dc53
UD
571% Be sure we're in horizontal mode when doing a tie, since we make space
572% equivalent to this in @example-like environments. Otherwise, a space
573% at the beginning of a line will start with \penalty -- and
574% since \penalty is valid in vertical mode, we'd end up putting the
575% penalty on the vertical list instead of in the new paragraph.
576{\catcode`@ = 11
577 % Avoid using \@M directly, because that causes trouble
578 % if the definition is written into an index file.
579 \global\let\tiepenalty = \@M
580 \gdef\tie{\leavevmode\penalty\tiepenalty\ }
581}
582
9e9f9cc2
KB
583% @: forces normal size whitespace following.
584\def\:{\spacefactor=1000 }
585
586% @* forces a line break.
8fcb833a 587\def\*{\unskip\hfil\break\hbox{}\ignorespaces}
9e9f9cc2 588
7158eae4
UD
589% @/ allows a line break.
590\let\/=\allowbreak
591
9e9f9cc2 592% @. is an end-of-sentence period.
9251c568 593\def\.{.\spacefactor=\endofsentencespacefactor\space}
9e9f9cc2 594
9e9f9cc2 595% @! is an end-of-sentence bang.
9251c568 596\def\!{!\spacefactor=\endofsentencespacefactor\space}
9e9f9cc2
KB
597
598% @? is an end-of-sentence query.
9251c568
AJ
599\def\?{?\spacefactor=\endofsentencespacefactor\space}
600
601% @frenchspacing on|off says whether to put extra space after punctuation.
0f8bbd69 602%
9251c568
AJ
603\def\onword{on}
604\def\offword{off}
605%
606\parseargdef\frenchspacing{%
607 \def\temp{#1}%
608 \ifx\temp\onword \plainfrenchspacing
609 \else\ifx\temp\offword \plainnonfrenchspacing
610 \else
611 \errhelp = \EMsimple
0f8bbd69 612 \errmessage{Unknown @frenchspacing option `\temp', must be on|off}%
9251c568
AJ
613 \fi\fi
614}
9e9f9cc2
KB
615
616% @w prevents a word break. Without the \leavevmode, @w at the
617% beginning of a paragraph, when TeX is still in vertical mode, would
618% produce a whole line of output instead of starting the paragraph.
619\def\w#1{\leavevmode\hbox{#1}}
620
621% @group ... @end group forces ... to be all on one page, by enclosing
622% it in a TeX vbox. We use \vtop instead of \vbox to construct the box
623% to keep its height that of a normal line. According to the rules for
624% \topskip (p.114 of the TeXbook), the glue inserted is
625% max (\topskip - \ht (first item), 0). If that height is large,
626% therefore, no glue is inserted, and the space between the headline and
627% the text is small, which looks bad.
628%
e0f86659
UD
629% Another complication is that the group might be very large. This can
630% cause the glue on the previous page to be unduly stretched, because it
631% does not have much material. In this case, it's better to add an
632% explicit \vfill so that the extra space is at the bottom. The
633% threshold for doing this is if the group is more than \vfilllimit
634% percent of a page (\vfilllimit can be changed inside of @tex).
7158eae4 635%
e0f86659
UD
636\newbox\groupbox
637\def\vfilllimit{0.7}
638%
82d5ce1d
UD
639\envdef\group{%
640 \ifnum\catcode`\^^M=\active \else
9e9f9cc2
KB
641 \errhelp = \groupinvalidhelp
642 \errmessage{@group invalid in context where filling is enabled}%
643 \fi
82d5ce1d 644 \startsavinginserts
9e9f9cc2 645 %
e0f86659 646 \setbox\groupbox = \vtop\bgroup
9e9f9cc2
KB
647 % Do @comment since we are called inside an environment such as
648 % @example, where each end-of-line in the input causes an
649 % end-of-line in the output. We don't want the end-of-line after
650 % the `@group' to put extra space in the output. Since @group
651 % should appear on a line by itself (according to the Texinfo
652 % manual), we don't worry about eating any user text.
653 \comment
654}
655%
82d5ce1d
UD
656% The \vtop produces a box with normal height and large depth; thus, TeX puts
657% \baselineskip glue before it, and (when the next line of text is done)
658% \lineskip glue after it. Thus, space below is not quite equal to space
659% above. But it's pretty close.
660\def\Egroup{%
661 % To get correct interline space between the last line of the group
662 % and the first line afterwards, we have to propagate \prevdepth.
663 \endgraf % Not \par, as it may have been set to \lisppar.
664 \global\dimen1 = \prevdepth
665 \egroup % End the \vtop.
084e7d57
JM
666 \addgroupbox
667 \prevdepth = \dimen1
668 \checkinserts
669}
670
671\def\addgroupbox{
82d5ce1d
UD
672 % \dimen0 is the vertical size of the group's box.
673 \dimen0 = \ht\groupbox \advance\dimen0 by \dp\groupbox
674 % \dimen2 is how much space is left on the page (more or less).
7f7dd1d3 675 \dimen2 = \txipageheight \advance\dimen2 by -\pagetotal
82d5ce1d
UD
676 % if the group doesn't fit on the current page, and it's a big big
677 % group, force a page break.
678 \ifdim \dimen0 > \dimen2
7f7dd1d3 679 \ifdim \pagetotal < \vfilllimit\txipageheight
82d5ce1d
UD
680 \page
681 \fi
682 \fi
683 \box\groupbox
82d5ce1d 684}
084e7d57 685
82d5ce1d 686%
9e9f9cc2
KB
687% TeX puts in an \escapechar (i.e., `@') at the beginning of the help
688% message, so this ends up printing `@group can only ...'.
689%
690\newhelp\groupinvalidhelp{%
691group can only be used in environments such as @example,^^J%
692where each line of input produces a line of output.}
693
694% @need space-in-mils
695% forces a page break if there is not space-in-mils remaining.
696
697\newdimen\mil \mil=0.001in
698
82d5ce1d 699\parseargdef\need{%
3b82ab1c 700 % Ensure vertical mode, so we don't make a big box in the middle of a
9e9f9cc2
KB
701 % paragraph.
702 \par
703 %
3b82ab1c
UD
704 % If the @need value is less than one line space, it's useless.
705 \dimen0 = #1\mil
706 \dimen2 = \ht\strutbox
707 \advance\dimen2 by \dp\strutbox
708 \ifdim\dimen0 > \dimen2
709 %
710 % Do a \strut just to make the height of this box be normal, so the
711 % normal leading is inserted relative to the preceding line.
712 % And a page break here is fine.
713 \vtop to #1\mil{\strut\vfil}%
714 %
715 % TeX does not even consider page breaks if a penalty added to the
716 % main vertical list is 10000 or more. But in order to see if the
717 % empty box we just added fits on the page, we must make it consider
718 % page breaks. On the other hand, we don't want to actually break the
719 % page after the empty box. So we use a penalty of 9999.
720 %
721 % There is an extremely small chance that TeX will actually break the
722 % page at this \penalty, if there are no other feasible breakpoints in
723 % sight. (If the user is using lots of big @group commands, which
724 % almost-but-not-quite fill up a page, TeX will have a hard time doing
725 % good page breaking, for example.) However, I could not construct an
726 % example where a page broke at this \penalty; if it happens in a real
727 % document, then we can reconsider our strategy.
728 \penalty9999
729 %
730 % Back up by the size of the box, whether we did a page break or not.
731 \kern -#1\mil
732 %
733 % Do not allow a page break right after this kern.
734 \nobreak
735 \fi
9e9f9cc2
KB
736}
737
82d5ce1d 738% @br forces paragraph break (and is undocumented).
9e9f9cc2
KB
739
740\let\br = \par
741
7158eae4 742% @page forces the start of a new page.
313a1174 743%
9e9f9cc2
KB
744\def\page{\par\vfill\supereject}
745
746% @exdent text....
747% outputs text on separate line in roman font, starting at standard page margin
748
749% This records the amount of indent in the innermost environment.
750% That's how much \exdent should take out.
751\newskip\exdentamount
752
753% This defn is used inside fill environments such as @defun.
82d5ce1d 754\parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}
9e9f9cc2
KB
755
756% This defn is used inside nofill environments such as @example.
82d5ce1d
UD
757\parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount
758 \leftline{\hskip\leftskip{\rm#1}}}}
9e9f9cc2 759
366d6851
UD
760% @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current
761% paragraph. For more general purposes, use the \margin insertion
0f8bbd69 762% class. WHICH is `l' or `r'. Not documented, written for gawk manual.
366d6851 763%
9e9f9cc2
KB
764\newskip\inmarginspacing \inmarginspacing=1cm
765\def\strutdepth{\dp\strutbox}
366d6851
UD
766%
767\def\doinmargin#1#2{\strut\vadjust{%
768 \nobreak
769 \kern-\strutdepth
770 \vtop to \strutdepth{%
771 \baselineskip=\strutdepth
772 \vss
773 % if you have multiple lines of stuff to put here, you'll need to
774 % make the vbox yourself of the appropriate size.
775 \ifx#1l%
776 \llap{\ignorespaces #2\hskip\inmarginspacing}%
777 \else
778 \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}%
779 \fi
780 \null
781 }%
782}}
783\def\inleftmargin{\doinmargin l}
784\def\inrightmargin{\doinmargin r}
785%
786% @inmargin{TEXT [, RIGHT-TEXT]}
787% (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right;
788% else use TEXT for both).
7158eae4 789%
366d6851
UD
790\def\inmargin#1{\parseinmargin #1,,\finish}
791\def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing.
7158eae4 792 \setbox0 = \hbox{\ignorespaces #2}%
366d6851
UD
793 \ifdim\wd0 > 0pt
794 \def\lefttext{#1}% have both texts
795 \def\righttext{#2}%
796 \else
797 \def\lefttext{#1}% have only one text
798 \def\righttext{#1}%
799 \fi
800 %
801 \ifodd\pageno
be1152ca 802 \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin
366d6851 803 \else
be1152ca 804 \def\temp{\inleftmargin\lefttext}%
366d6851
UD
805 \fi
806 \temp
807}
9e9f9cc2 808
0f8bbd69 809% @include FILE -- \input text of FILE.
82d5ce1d
UD
810%
811\def\include{\parseargusing\filenamecatcodes\includezzz}
812\def\includezzz#1{%
813 \pushthisfilestack
814 \def\thisfile{#1}%
815 {%
0f8bbd69
JM
816 \makevalueexpandable % we want to expand any @value in FILE.
817 \turnoffactive % and allow special characters in the expansion
818 \indexnofonts % Allow `@@' and other weird things in file names.
819 \wlog{texinfo.tex: doing @include of #1^^J}%
820 \edef\temp{\noexpand\input #1 }%
821 %
822 % This trickery is to read FILE outside of a group, in case it makes
823 % definitions, etc.
82d5ce1d
UD
824 \expandafter
825 }\temp
826 \popthisfilestack
827}
828\def\filenamecatcodes{%
e0f86659
UD
829 \catcode`\\=\other
830 \catcode`~=\other
831 \catcode`^=\other
832 \catcode`_=\other
833 \catcode`|=\other
834 \catcode`<=\other
835 \catcode`>=\other
836 \catcode`+=\other
82d5ce1d 837 \catcode`-=\other
0f8bbd69
JM
838 \catcode`\`=\other
839 \catcode`\'=\other
82d5ce1d
UD
840}
841
842\def\pushthisfilestack{%
843 \expandafter\pushthisfilestackX\popthisfilestack\StackTerm
844}
845\def\pushthisfilestackX{%
846 \expandafter\pushthisfilestackY\thisfile\StackTerm
847}
848\def\pushthisfilestackY #1\StackTerm #2\StackTerm {%
849 \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}%
850}
851
852\def\popthisfilestack{\errthisfilestackempty}
853\def\errthisfilestackempty{\errmessage{Internal error:
854 the stack of filenames is empty.}}
8fcb833a 855%
9e9f9cc2
KB
856\def\thisfile{}
857
e0f86659
UD
858% @center line
859% outputs that line, centered.
860%
82d5ce1d
UD
861\parseargdef\center{%
862 \ifhmode
8fcb833a 863 \let\centersub\centerH
82d5ce1d 864 \else
8fcb833a 865 \let\centersub\centerV
82d5ce1d 866 \fi
8fcb833a
JM
867 \centersub{\hfil \ignorespaces#1\unskip \hfil}%
868 \let\centersub\relax % don't let the definition persist, just in case
82d5ce1d 869}
8fcb833a
JM
870\def\centerH#1{{%
871 \hfil\break
872 \advance\hsize by -\leftskip
873 \advance\hsize by -\rightskip
874 \line{#1}%
875 \break
876}}
877%
878\newcount\centerpenalty
879\def\centerV#1{%
880 % The idea here is the same as in \startdefun, \cartouche, etc.: if
881 % @center is the first thing after a section heading, we need to wipe
882 % out the negative parskip inserted by \sectionheading, but still
883 % prevent a page break here.
884 \centerpenalty = \lastpenalty
885 \ifnum\centerpenalty>10000 \vskip\parskip \fi
886 \ifnum\centerpenalty>9999 \penalty\centerpenalty \fi
887 \line{\kern\leftskip #1\kern\rightskip}%
82d5ce1d 888}
9e9f9cc2
KB
889
890% @sp n outputs n lines of vertical space
8fcb833a 891%
82d5ce1d 892\parseargdef\sp{\vskip #1\baselineskip}
9e9f9cc2
KB
893
894% @comment ...line which is ignored...
895% @c is the same as @comment
896% @ignore ... @end ignore is another way to write a comment
084e7d57 897
084e7d57
JM
898
899\def\c{\begingroup \catcode`\^^M=\active%
61027f30 900\catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
084e7d57
JM
901\cxxx}
902{\catcode`\^^M=\active \gdef\cxxx#1^^M{\endgroup}}
41d11b15
JM
903%
904\let\comment\c
9e9f9cc2 905
407dc7a0
UD
906% @paragraphindent NCHARS
907% We'll use ems for NCHARS, close enough.
7158eae4
UD
908% NCHARS can also be the word `asis' or `none'.
909% We cannot feasibly implement @paragraphindent asis, though.
910%
407dc7a0
UD
911\def\asisword{asis} % no translation, these are keywords
912\def\noneword{none}
9e9f9cc2 913%
82d5ce1d 914\parseargdef\paragraphindent{%
407dc7a0
UD
915 \def\temp{#1}%
916 \ifx\temp\asisword
917 \else
918 \ifx\temp\noneword
919 \defaultparindent = 0pt
920 \else
921 \defaultparindent = #1em
922 \fi
923 \fi
924 \parindent = \defaultparindent
9e9f9cc2
KB
925}
926
13632cfc
UD
927% @exampleindent NCHARS
928% We'll use ems for NCHARS like @paragraphindent.
929% It seems @exampleindent asis isn't necessary, but
930% I preserve it to make it similar to @paragraphindent.
82d5ce1d 931\parseargdef\exampleindent{%
13632cfc
UD
932 \def\temp{#1}%
933 \ifx\temp\asisword
934 \else
935 \ifx\temp\noneword
936 \lispnarrowing = 0pt
937 \else
938 \lispnarrowing = #1em
939 \fi
940 \fi
941}
942
7158eae4
UD
943% @firstparagraphindent WORD
944% If WORD is `none', then suppress indentation of the first paragraph
82d5ce1d 945% after a section heading. If WORD is `insert', then do indent at such
7158eae4
UD
946% paragraphs.
947%
948% The paragraph indentation is suppressed or not by calling
82d5ce1d
UD
949% \suppressfirstparagraphindent, which the sectioning commands do.
950% We switch the definition of this back and forth according to WORD.
951% By default, we suppress indentation.
7158eae4
UD
952%
953\def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent}
7158eae4
UD
954\def\insertword{insert}
955%
82d5ce1d 956\parseargdef\firstparagraphindent{%
7158eae4
UD
957 \def\temp{#1}%
958 \ifx\temp\noneword
959 \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent
960 \else\ifx\temp\insertword
961 \let\suppressfirstparagraphindent = \relax
962 \else
963 \errhelp = \EMsimple
964 \errmessage{Unknown @firstparagraphindent option `\temp'}%
965 \fi\fi
966}
967
968% Here is how we actually suppress indentation. Redefine \everypar to
969% \kern backwards by \parindent, and then reset itself to empty.
970%
971% We also make \indent itself not actually do anything until the next
972% paragraph.
973%
974\gdef\dosuppressfirstparagraphindent{%
084e7d57
JM
975 \gdef\indent {\restorefirstparagraphindent \indent}%
976 \gdef\noindent{\restorefirstparagraphindent \noindent}%
977 \global\everypar = {\kern -\parindent \restorefirstparagraphindent}%
82d5ce1d 978}
084e7d57 979%
82d5ce1d 980\gdef\restorefirstparagraphindent{%
084e7d57
JM
981 \global\let\indent = \ptexindent
982 \global\let\noindent = \ptexnoindent
983 \global\everypar = {}%
82d5ce1d 984}
7158eae4
UD
985
986
407dc7a0
UD
987% @refill is a no-op.
988\let\refill=\relax
9e9f9cc2 989
084e7d57
JM
990% @setfilename INFO-FILENAME - ignored
991\let\setfilename=\comment
0c2b5752 992
d66b7b41 993% @bye.
9e9f9cc2
KB
994\outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
995
d66b7b41 996
13632cfc
UD
997\message{pdf,}
998% adobe `portable' document format
13632cfc
UD
999\newcount\tempnum
1000\newcount\lnkcount
1001\newtoks\filename
1002\newcount\filenamelength
1003\newcount\pgn
3b82ab1c
UD
1004\newtoks\toksA
1005\newtoks\toksB
1006\newtoks\toksC
1007\newtoks\toksD
1008\newbox\boxA
084e7d57 1009\newbox\boxB
3b82ab1c
UD
1010\newcount\countA
1011\newif\ifpdf
1012\newif\ifpdfmakepagedest
1013
7f7dd1d3
JM
1014%
1015% For LuaTeX
1016%
1017
1018\newif\iftxiuseunicodedestname
1019\txiuseunicodedestnamefalse % For pdfTeX etc.
1020
1021\ifx\luatexversion\thisisundefined
1022\else
1023 % Use Unicode destination names
1024 \txiuseunicodedestnametrue
1025 % Escape PDF strings with converting UTF-16 from UTF-8
1026 \begingroup
1027 \catcode`\%=12
1028 \directlua{
1029 function UTF16oct(str)
1030 tex.sprint(string.char(0x5c) .. '376' .. string.char(0x5c) .. '377')
1031 for c in string.utfvalues(str) do
1032 if c < 0x10000 then
1033 tex.sprint(
1034 string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
1035 string.char(0x5c) .. string.char(0x25) .. '03o',
1036 (c / 256), (c % 256)))
1037 else
1038 c = c - 0x10000
1039 local c_hi = c / 1024 + 0xd800
1040 local c_lo = c % 1024 + 0xdc00
1041 tex.sprint(
1042 string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
1043 string.char(0x5c) .. string.char(0x25) .. '03o' ..
1044 string.char(0x5c) .. string.char(0x25) .. '03o' ..
1045 string.char(0x5c) .. string.char(0x25) .. '03o',
1046 (c_hi / 256), (c_hi % 256),
1047 (c_lo / 256), (c_lo % 256)))
1048 end
1049 end
1050 end
1051 }
1052 \endgroup
1053 \def\pdfescapestrutfsixteen#1{\directlua{UTF16oct('\luaescapestring{#1}')}}
1054 % Escape PDF strings without converting
1055 \begingroup
1056 \directlua{
1057 function PDFescstr(str)
1058 for c in string.bytes(str) do
1059 if c <= 0x20 or c >= 0x80 or c == 0x28 or c == 0x29 or c == 0x5c then
1060 tex.sprint(
1061 string.format(string.char(0x5c) .. string.char(0x25) .. '03o',
1062 c))
1063 else
1064 tex.sprint(string.char(c))
1065 end
1066 end
1067 end
1068 }
1069 \endgroup
1070 \def\pdfescapestring#1{\directlua{PDFescstr('\luaescapestring{#1}')}}
1071 \ifnum\luatexversion>84
1072 % For LuaTeX >= 0.85
1073 \def\pdfdest{\pdfextension dest}
1074 \let\pdfoutput\outputmode
1075 \def\pdfliteral{\pdfextension literal}
1076 \def\pdfcatalog{\pdfextension catalog}
1077 \def\pdftexversion{\numexpr\pdffeedback version\relax}
1078 \let\pdfximage\saveimageresource
1079 \let\pdfrefximage\useimageresource
1080 \let\pdflastximage\lastsavedimageresourceindex
1081 \def\pdfendlink{\pdfextension endlink\relax}
1082 \def\pdfoutline{\pdfextension outline}
1083 \def\pdfstartlink{\pdfextension startlink}
1084 \def\pdffontattr{\pdfextension fontattr}
1085 \def\pdfobj{\pdfextension obj}
1086 \def\pdflastobj{\numexpr\pdffeedback lastobj\relax}
1087 \let\pdfpagewidth\pagewidth
1088 \let\pdfpageheight\pageheight
1089 \edef\pdfhorigin{\pdfvariable horigin}
1090 \edef\pdfvorigin{\pdfvariable vorigin}
1091 \fi
1092\fi
1093
82d5ce1d 1094% when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1
0f8bbd69
JM
1095% can be set). So we test for \relax and 0 as well as being undefined.
1096\ifx\pdfoutput\thisisundefined
3b82ab1c 1097\else
82d5ce1d
UD
1098 \ifx\pdfoutput\relax
1099 \else
1100 \ifcase\pdfoutput
1101 \else
1102 \pdftrue
1103 \fi
1104 \fi
1105\fi
9251c568
AJ
1106
1107% PDF uses PostScript string constants for the names of xref targets,
1108% for display in the outlines, and in other places. Thus, we have to
1109% double any backslashes. Otherwise, a name like "\node" will be
1110% interpreted as a newline (\n), followed by o, d, e. Not good.
8fcb833a 1111%
0f8bbd69
JM
1112% See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and
1113% related messages. The final outcome is that it is up to the TeX user
1114% to double the backslashes and otherwise make the string valid, so
1115% that's what we do. pdftex 1.30.0 (ca.2005) introduced a primitive to
1116% do this reliably, so we use it.
1117
1118% #1 is a control sequence in which to do the replacements,
1119% which we \xdef.
1120\def\txiescapepdf#1{%
8fcb833a 1121 \ifx\pdfescapestring\thisisundefined
0f8bbd69
JM
1122 % No primitive available; should we give a warning or log?
1123 % Many times it won't matter.
7f7dd1d3 1124 \xdef#1{#1}%
0f8bbd69
JM
1125 \else
1126 % The expandable \pdfescapestring primitive escapes parentheses,
1127 % backslashes, and other special chars.
1128 \xdef#1{\pdfescapestring{#1}}%
1129 \fi
9251c568 1130}
7f7dd1d3
JM
1131\def\txiescapepdfutfsixteen#1{%
1132 \ifx\pdfescapestrutfsixteen\thisisundefined
1133 % No UTF-16 converting macro available.
1134 \txiescapepdf{#1}%
1135 \else
1136 \xdef#1{\pdfescapestrutfsixteen{#1}}%
1137 \fi
1138}
9251c568
AJ
1139
1140\newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images
1141with PDF output, and none of those formats could be found. (.eps cannot
1142be supported due to the design of the PDF format; use regular TeX (DVI
1143output) for that.)}
1144
82d5ce1d 1145\ifpdf
c94f48d7 1146 %
e66a8203 1147 % Color manipulation macros using ideas from pdfcolor.tex,
0f8bbd69
JM
1148 % except using rgb instead of cmyk; the latter is said to render as a
1149 % very dark gray on-screen and a very dark halftone in print, instead
e66a8203 1150 % of actual black. The dark red here is dark enough to print on paper as
21fea2e2
JM
1151 % nearly black, but still distinguishable for online viewing. We use
1152 % black by default, though.
0f8bbd69
JM
1153 \def\rgbDarkRed{0.50 0.09 0.12}
1154 \def\rgbBlack{0 0 0}
1155 %
084e7d57
JM
1156 % rg sets the color for filling (usual text, etc.);
1157 % RG sets the color for stroking (thin rules, e.g., normal _'s).
0f8bbd69 1158 \def\pdfsetcolor#1{\pdfliteral{#1 rg #1 RG}}
c94f48d7 1159 %
c94f48d7
AJ
1160 % Set color, and create a mark which defines \thiscolor accordingly,
1161 % so that \makeheadline knows which color to restore.
1162 \def\setcolor#1{%
1163 \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}%
1164 \domark
1165 \pdfsetcolor{#1}%
1166 }
1167 %
0f8bbd69 1168 \def\maincolor{\rgbBlack}
c94f48d7
AJ
1169 \pdfsetcolor{\maincolor}
1170 \edef\thiscolor{\maincolor}
1171 \def\lastcolordefs{}
1172 %
1173 \def\makefootline{%
1174 \baselineskip24pt
1175 \line{\pdfsetcolor{\maincolor}\the\footline}%
1176 }
1177 %
1178 \def\makeheadline{%
1179 \vbox to 0pt{%
1180 \vskip-22.5pt
1181 \line{%
1182 \vbox to8.5pt{}%
1183 % Extract \thiscolor definition from the marks.
1184 \getcolormarks
1185 % Typeset the headline with \maincolor, then restore the color.
1186 \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
1187 }%
1188 \vss
1189 }%
1190 \nointerlineskip
1191 }
1192 %
1193 %
1194 \pdfcatalog{/PageMode /UseOutlines}
1195 %
9251c568 1196 % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
3b82ab1c 1197 \def\dopdfimage#1#2#3{%
8fcb833a
JM
1198 \def\pdfimagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
1199 \def\pdfimageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
9251c568 1200 %
0f8bbd69
JM
1201 % pdftex (and the PDF format) support .pdf, .png, .jpg (among
1202 % others). Let's try in that order, PDF first since if
1203 % someone has a scalable image, presumably better to use that than a
1204 % bitmap.
9251c568
AJ
1205 \let\pdfimgext=\empty
1206 \begingroup
0f8bbd69
JM
1207 \openin 1 #1.pdf \ifeof 1
1208 \openin 1 #1.PDF \ifeof 1
1209 \openin 1 #1.png \ifeof 1
1210 \openin 1 #1.jpg \ifeof 1
1211 \openin 1 #1.jpeg \ifeof 1
1212 \openin 1 #1.JPG \ifeof 1
1213 \errhelp = \nopdfimagehelp
1214 \errmessage{Could not find image file #1 for pdf}%
1215 \else \gdef\pdfimgext{JPG}%
1216 \fi
1217 \else \gdef\pdfimgext{jpeg}%
9251c568 1218 \fi
0f8bbd69 1219 \else \gdef\pdfimgext{jpg}%
9251c568 1220 \fi
0f8bbd69 1221 \else \gdef\pdfimgext{png}%
9251c568 1222 \fi
0f8bbd69 1223 \else \gdef\pdfimgext{PDF}%
9251c568 1224 \fi
0f8bbd69 1225 \else \gdef\pdfimgext{pdf}%
9251c568
AJ
1226 \fi
1227 \closein 1
1228 \endgroup
1229 %
0f8bbd69 1230 % without \immediate, ancient pdftex seg faults when the same image is
e23f8d20 1231 % included twice. (Version 3.14159-pre-1.0-unofficial-20010704.)
3b82ab1c 1232 \ifnum\pdftexversion < 14
e23f8d20 1233 \immediate\pdfimage
3b82ab1c 1234 \else
e23f8d20 1235 \immediate\pdfximage
3b82ab1c 1236 \fi
8fcb833a
JM
1237 \ifdim \wd0 >0pt width \pdfimagewidth \fi
1238 \ifdim \wd2 >0pt height \pdfimageheight \fi
be1152ca 1239 \ifnum\pdftexversion<13
9251c568 1240 #1.\pdfimgext
be1152ca 1241 \else
9251c568 1242 {#1.\pdfimgext}%
be1152ca 1243 \fi
3b82ab1c
UD
1244 \ifnum\pdftexversion < 14 \else
1245 \pdfrefximage \pdflastximage
1246 \fi}
c94f48d7 1247 %
7f7dd1d3 1248 \def\setpdfdestname#1{{%
9251c568
AJ
1249 % We have to set dummies so commands such as @code, and characters
1250 % such as \, aren't expanded when present in a section title.
c94f48d7 1251 \indexnofonts
c94f48d7 1252 \makevalueexpandable
7f7dd1d3
JM
1253 \turnoffactive
1254 \iftxiuseunicodedestname
1255 \ifx \declaredencoding \latone
1256 % Pass through Latin-1 characters.
1257 % LuaTeX with byte wise I/O converts Latin-1 characters to Unicode.
1258 \else
1259 \ifx \declaredencoding \utfeight
1260 % Pass through Unicode characters.
1261 \else
1262 % Use ASCII approximations in destination names.
1263 \passthroughcharsfalse
1264 \fi
1265 \fi
1266 \else
1267 % Use ASCII approximations in destination names.
1268 \passthroughcharsfalse
1269 \fi
9251c568 1270 \def\pdfdestname{#1}%
0f8bbd69 1271 \txiescapepdf\pdfdestname
c94f48d7 1272 }}
9251c568 1273 %
7f7dd1d3
JM
1274 \def\setpdfoutlinetext#1{{%
1275 \indexnofonts
1276 \makevalueexpandable
1277 \turnoffactive
1278 \ifx \declaredencoding \latone
1279 % The PDF format can use an extended form of Latin-1 in bookmark
1280 % strings. See Appendix D of the PDF Reference, Sixth Edition, for
1281 % the "PDFDocEncoding".
1282 \passthroughcharstrue
1283 % Pass through Latin-1 characters.
1284 % LuaTeX: Convert to Unicode
1285 % pdfTeX: Use Latin-1 as PDFDocEncoding
1286 \def\pdfoutlinetext{#1}%
1287 \else
1288 \ifx \declaredencoding \utfeight
1289 \ifx\luatexversion\thisisundefined
1290 % For pdfTeX with UTF-8.
1291 % TODO: the PDF format can use UTF-16 in bookmark strings,
1292 % but the code for this isn't done yet.
1293 % Use ASCII approximations.
1294 \passthroughcharsfalse
1295 \def\pdfoutlinetext{#1}%
1296 \else
1297 % For LuaTeX with UTF-8.
1298 % Pass through Unicode characters for title texts.
1299 \passthroughcharstrue
1300 \def\pdfoutlinetext{#1}%
1301 \fi
1302 \else
1303 % For non-Latin-1 or non-UTF-8 encodings.
1304 % Use ASCII approximations.
1305 \passthroughcharsfalse
1306 \def\pdfoutlinetext{#1}%
1307 \fi
1308 \fi
1309 % LuaTeX: Convert to UTF-16
1310 % pdfTeX: Use Latin-1 as PDFDocEncoding
1311 \txiescapepdfutfsixteen\pdfoutlinetext
1312 }}
1313 %
1314 \def\pdfmkdest#1{%
1315 \setpdfdestname{#1}%
1316 \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
1317 }
1318 %
9251c568 1319 % used to mark target names; must be expandable.
c94f48d7
AJ
1320 \def\pdfmkpgn#1{#1}
1321 %
21fea2e2
JM
1322 % by default, use black for everything.
1323 \def\urlcolor{\rgbBlack}
1324 \def\linkcolor{\rgbBlack}
c94f48d7 1325 \def\endlink{\setcolor{\maincolor}\pdfendlink}
9251c568 1326 %
3b82ab1c
UD
1327 % Adding outlines to PDF; macros for calculating structure of outlines
1328 % come from Petr Olsak
1329 \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
1330 \else \csname#1\endcsname \fi}
1331 \def\advancenumber#1{\tempnum=\expnumber{#1}\relax
82d5ce1d 1332 \advance\tempnum by 1
3b82ab1c 1333 \expandafter\xdef\csname#1\endcsname{\the\tempnum}}
82d5ce1d 1334 %
9251c568
AJ
1335 % #1 is the section text, which is what will be displayed in the
1336 % outline by the pdf viewer. #2 is the pdf expression for the number
1337 % of subentries (or empty, for subsubsections). #3 is the node text,
1338 % which might be empty if this toc entry had no corresponding node.
1339 % #4 is the page number
82d5ce1d
UD
1340 %
1341 \def\dopdfoutline#1#2#3#4{%
1342 % Generate a link to the node text if that exists; else, use the
1343 % page number. We could generate a destination for the section
1344 % text in the case where a section has no node, but it doesn't
9251c568 1345 % seem worth the trouble, since most documents are normally structured.
7f7dd1d3
JM
1346 \setpdfoutlinetext{#1}
1347 \setpdfdestname{#3}
1348 \ifx\pdfdestname\empty
1349 \def\pdfdestname{#4}%
9251c568
AJ
1350 \fi
1351 %
7f7dd1d3 1352 \pdfoutline goto name{\pdfmkpgn{\pdfdestname}}#2{\pdfoutlinetext}%
82d5ce1d
UD
1353 }
1354 %
1355 \def\pdfmakeoutlines{%
1356 \begingroup
82d5ce1d 1357 % Read toc silently, to get counts of subentries for \pdfoutline.
0f8bbd69 1358 \def\partentry##1##2##3##4{}% ignore parts in the outlines
82d5ce1d
UD
1359 \def\numchapentry##1##2##3##4{%
1360 \def\thischapnum{##2}%
1361 \def\thissecnum{0}%
1362 \def\thissubsecnum{0}%
1363 }%
1364 \def\numsecentry##1##2##3##4{%
1365 \advancenumber{chap\thischapnum}%
1366 \def\thissecnum{##2}%
1367 \def\thissubsecnum{0}%
1368 }%
1369 \def\numsubsecentry##1##2##3##4{%
1370 \advancenumber{sec\thissecnum}%
1371 \def\thissubsecnum{##2}%
1372 }%
1373 \def\numsubsubsecentry##1##2##3##4{%
1374 \advancenumber{subsec\thissubsecnum}%
1375 }%
1376 \def\thischapnum{0}%
1377 \def\thissecnum{0}%
1378 \def\thissubsecnum{0}%
1379 %
1380 % use \def rather than \let here because we redefine \chapentry et
1381 % al. a second time, below.
1382 \def\appentry{\numchapentry}%
1383 \def\appsecentry{\numsecentry}%
1384 \def\appsubsecentry{\numsubsecentry}%
1385 \def\appsubsubsecentry{\numsubsubsecentry}%
1386 \def\unnchapentry{\numchapentry}%
1387 \def\unnsecentry{\numsecentry}%
1388 \def\unnsubsecentry{\numsubsecentry}%
1389 \def\unnsubsubsecentry{\numsubsubsecentry}%
9251c568 1390 \readdatafile{toc}%
2f5b1124 1391 %
82d5ce1d
UD
1392 % Read toc second time, this time actually producing the outlines.
1393 % The `-' means take the \expnumber as the absolute number of
1394 % subentries, which we calculated on our first read of the .toc above.
1395 %
1396 % We use the node names as the destinations.
1397 \def\numchapentry##1##2##3##4{%
1398 \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}%
1399 \def\numsecentry##1##2##3##4{%
1400 \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}%
1401 \def\numsubsecentry##1##2##3##4{%
1402 \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}%
1403 \def\numsubsubsecentry##1##2##3##4{% count is always zero
1404 \dopdfoutline{##1}{}{##3}{##4}}%
1405 %
1406 % PDF outlines are displayed using system fonts, instead of
1407 % document fonts. Therefore we cannot use special characters,
1408 % since the encoding is unknown. For example, the eogonek from
1409 % Latin 2 (0xea) gets translated to a | character. Info from
1410 % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100.
7158eae4 1411 %
0f8bbd69
JM
1412 % TODO this right, we have to translate 8-bit characters to
1413 % their "best" equivalent, based on the @documentencoding. Too
1414 % much work for too little return. Just use the ASCII equivalents
1415 % we use for the index sort strings.
1416 %
2f5b1124 1417 \indexnofonts
9251c568 1418 \setupdatafile
0f8bbd69
JM
1419 % We can have normal brace characters in the PDF outlines, unlike
1420 % Texinfo index files. So set that up.
1421 \def\{{\lbracecharliteral}%
1422 \def\}{\rbracecharliteral}%
9251c568 1423 \catcode`\\=\active \otherbackslash
c94f48d7 1424 \input \tocreadfilename
82d5ce1d
UD
1425 \endgroup
1426 }
0f8bbd69
JM
1427 {\catcode`[=1 \catcode`]=2
1428 \catcode`{=\other \catcode`}=\other
1429 \gdef\lbracecharliteral[{]%
1430 \gdef\rbracecharliteral[}]%
1431 ]
82d5ce1d 1432 %
3b82ab1c
UD
1433 \def\skipspaces#1{\def\PP{#1}\def\D{|}%
1434 \ifx\PP\D\let\nextsp\relax
1435 \else\let\nextsp\skipspaces
8fcb833a
JM
1436 \addtokens{\filename}{\PP}%
1437 \advance\filenamelength by 1
3b82ab1c
UD
1438 \fi
1439 \nextsp}
8fcb833a
JM
1440 \def\getfilename#1{%
1441 \filenamelength=0
1442 % If we don't expand the argument now, \skipspaces will get
1443 % snagged on things like "@value{foo}".
1444 \edef\temp{#1}%
1445 \expandafter\skipspaces\temp|\relax
1446 }
3b82ab1c
UD
1447 \ifnum\pdftexversion < 14
1448 \let \startlink \pdfannotlink
1449 \else
1450 \let \startlink \pdfstartlink
13632cfc 1451 \fi
9251c568 1452 % make a live url in pdf output.
3b82ab1c
UD
1453 \def\pdfurl#1{%
1454 \begingroup
9251c568
AJ
1455 % it seems we really need yet another set of dummies; have not
1456 % tried to figure out what each command should do in the context
1457 % of @url. for now, just make @/ a no-op, that's the only one
1458 % people have actually reported a problem with.
0f8bbd69 1459 %
9251c568
AJ
1460 \normalturnoffactive
1461 \def\@{@}%
1462 \let\/=\empty
82d5ce1d 1463 \makevalueexpandable
0f8bbd69
JM
1464 % do we want to go so far as to use \indexnofonts instead of just
1465 % special-casing \var here?
1466 \def\var##1{##1}%
1467 %
c94f48d7 1468 \leavevmode\setcolor{\urlcolor}%
3b82ab1c
UD
1469 \startlink attr{/Border [0 0 0]}%
1470 user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
3b82ab1c 1471 \endgroup}
c37cd439
JM
1472 % \pdfgettoks - Surround page numbers in #1 with @pdflink. #1 may
1473 % be a simple number, or a list of numbers in the case of an index
1474 % entry.
3b82ab1c
UD
1475 \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1476 \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1477 \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1478 \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1479 \def\maketoks{%
82d5ce1d 1480 \expandafter\poptoks\the\toksA|ENDTOKS|\relax
3b82ab1c
UD
1481 \ifx\first0\adn0
1482 \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1483 \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
7158eae4 1484 \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
3b82ab1c
UD
1485 \else
1486 \ifnum0=\countA\else\makelink\fi
1487 \ifx\first.\let\next=\done\else
1488 \let\next=\maketoks
1489 \addtokens{\toksB}{\the\toksD}
1490 \ifx\first,\addtokens{\toksB}{\space}\fi
1491 \fi
1492 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1493 \next}
1494 \def\makelink{\addtokens{\toksB}%
1495 {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1496 \def\pdflink#1{%
e23f8d20 1497 \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}}
c94f48d7 1498 \setcolor{\linkcolor}#1\endlink}
3b82ab1c 1499 \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
82d5ce1d 1500\else
0f8bbd69 1501 % non-pdf mode
82d5ce1d
UD
1502 \let\pdfmkdest = \gobble
1503 \let\pdfurl = \gobble
1504 \let\endlink = \relax
c94f48d7
AJ
1505 \let\setcolor = \gobble
1506 \let\pdfsetcolor = \gobble
82d5ce1d
UD
1507 \let\pdfmakeoutlines = \relax
1508\fi % \ifx\pdfoutput
13632cfc 1509
82d5ce1d 1510%
7f7dd1d3 1511% For XeTeX
82d5ce1d 1512%
7f7dd1d3
JM
1513\ifx\XeTeXrevision\thisisundefined
1514\else
1515 %
1516 % XeTeX version check
1517 %
1518 \ifnum\strcmp{\the\XeTeXversion\XeTeXrevision}{0.99996}>-1
1519 % TeX Live 2016 contains XeTeX 0.99996 and xdvipdfmx 20160307.
1520 % It can use the `dvipdfmx:config' special (from TeX Live SVN r40941).
1521 % For avoiding PDF destination name replacement, we use this special
1522 % instead of xdvipdfmx's command line option `-C 0x0010'.
1523 \special{dvipdfmx:config C 0x0010}
1524 % XeTeX 0.99995+ comes with xdvipdfmx 20160307+.
1525 % It can handle Unicode destination names for PDF.
1526 \txiuseunicodedestnametrue
1527 \else
1528 % XeTeX < 0.99996 (TeX Live < 2016) cannot use the
1529 % `dvipdfmx:config' special.
1530 % So for avoiding PDF destination name replacement,
1531 % xdvipdfmx's command line option `-C 0x0010' is necessary.
1532 %
1533 % XeTeX < 0.99995 can not handle Unicode destination names for PDF
1534 % because xdvipdfmx 20150315 has a UTF-16 conversion issue.
1535 % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753).
1536 \txiuseunicodedestnamefalse
1537 \fi
1538 %
1539 % Color support
1540 %
1541 \def\rgbDarkRed{0.50 0.09 0.12}
1542 \def\rgbBlack{0 0 0}
1543 %
1544 \def\pdfsetcolor#1{\special{pdf:scolor [#1]}}
1545 %
1546 % Set color, and create a mark which defines \thiscolor accordingly,
1547 % so that \makeheadline knows which color to restore.
1548 \def\setcolor#1{%
1549 \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}%
1550 \domark
1551 \pdfsetcolor{#1}%
1552 }
1553 %
1554 \def\maincolor{\rgbBlack}
1555 \pdfsetcolor{\maincolor}
1556 \edef\thiscolor{\maincolor}
1557 \def\lastcolordefs{}
1558 %
1559 \def\makefootline{%
1560 \baselineskip24pt
1561 \line{\pdfsetcolor{\maincolor}\the\footline}%
1562 }
1563 %
1564 \def\makeheadline{%
1565 \vbox to 0pt{%
1566 \vskip-22.5pt
1567 \line{%
1568 \vbox to8.5pt{}%
1569 % Extract \thiscolor definition from the marks.
1570 \getcolormarks
1571 % Typeset the headline with \maincolor, then restore the color.
1572 \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
1573 }%
1574 \vss
1575 }%
1576 \nointerlineskip
1577 }
1578 %
1579 % PDF outline support
1580 %
1581 % Emulate pdfTeX primitive
1582 \def\pdfdest name#1 xyz{%
1583 \special{pdf:dest (#1) [@thispage /XYZ @xpos @ypos null]}%
1584 }
1585 %
1586 \def\setpdfdestname#1{{%
1587 % We have to set dummies so commands such as @code, and characters
1588 % such as \, aren't expanded when present in a section title.
1589 \indexnofonts
1590 \makevalueexpandable
1591 \turnoffactive
1592 \iftxiuseunicodedestname
1593 % Pass through Unicode characters.
1594 \else
1595 % Use ASCII approximations in destination names.
1596 \passthroughcharsfalse
1597 \fi
1598 \def\pdfdestname{#1}%
1599 \txiescapepdf\pdfdestname
1600 }}
1601 %
1602 \def\setpdfoutlinetext#1{{%
1603 \turnoffactive
1604 % Always use Unicode characters in title texts.
1605 \def\pdfoutlinetext{#1}%
1606 % For XeTeX, xdvipdfmx converts to UTF-16.
1607 % So we do not convert.
1608 \txiescapepdf\pdfoutlinetext
1609 }}
1610 %
1611 \def\pdfmkdest#1{%
1612 \setpdfdestname{#1}%
1613 \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
1614 }
1615 %
1616 % by default, use black for everything.
1617 \def\urlcolor{\rgbBlack}
1618 \def\linkcolor{\rgbBlack}
1619 \def\endlink{\setcolor{\maincolor}\pdfendlink}
1620 %
1621 \def\dopdfoutline#1#2#3#4{%
1622 \setpdfoutlinetext{#1}
1623 \setpdfdestname{#3}
1624 \ifx\pdfdestname\empty
1625 \def\pdfdestname{#4}%
1626 \fi
1627 %
1628 \special{pdf:out [-] #2 << /Title (\pdfoutlinetext) /A
1629 << /S /GoTo /D (\pdfdestname) >> >> }%
1630 }
1631 %
1632 \def\pdfmakeoutlines{%
1633 \begingroup
1634 %
1635 % For XeTeX, counts of subentries are not necessary.
1636 % Therefore, we read toc only once.
1637 %
1638 % We use node names as destinations.
1639 \def\partentry##1##2##3##4{}% ignore parts in the outlines
1640 \def\numchapentry##1##2##3##4{%
1641 \dopdfoutline{##1}{1}{##3}{##4}}%
1642 \def\numsecentry##1##2##3##4{%
1643 \dopdfoutline{##1}{2}{##3}{##4}}%
1644 \def\numsubsecentry##1##2##3##4{%
1645 \dopdfoutline{##1}{3}{##3}{##4}}%
1646 \def\numsubsubsecentry##1##2##3##4{%
1647 \dopdfoutline{##1}{4}{##3}{##4}}%
1648 %
1649 \let\appentry\numchapentry%
1650 \let\appsecentry\numsecentry%
1651 \let\appsubsecentry\numsubsecentry%
1652 \let\appsubsubsecentry\numsubsubsecentry%
1653 \let\unnchapentry\numchapentry%
1654 \let\unnsecentry\numsecentry%
1655 \let\unnsubsecentry\numsubsecentry%
1656 \let\unnsubsubsecentry\numsubsubsecentry%
1657 %
1658 % For XeTeX, xdvipdfmx converts strings to UTF-16.
1659 % Therefore, the encoding and the language may not be considered.
1660 %
1661 \indexnofonts
1662 \setupdatafile
1663 % We can have normal brace characters in the PDF outlines, unlike
1664 % Texinfo index files. So set that up.
1665 \def\{{\lbracecharliteral}%
1666 \def\}{\rbracecharliteral}%
1667 \catcode`\\=\active \otherbackslash
1668 \input \tocreadfilename
1669 \endgroup
1670 }
1671 {\catcode`[=1 \catcode`]=2
1672 \catcode`{=\other \catcode`}=\other
1673 \gdef\lbracecharliteral[{]%
1674 \gdef\rbracecharliteral[}]%
1675 ]
0f8bbd69 1676
7f7dd1d3
JM
1677 \special{pdf:docview << /PageMode /UseOutlines >> }
1678 % ``\special{pdf:tounicode ...}'' is not necessary
1679 % because xdvipdfmx converts strings from UTF-8 to UTF-16 without it.
1680 % However, due to a UTF-16 conversion issue of xdvipdfmx 20150315,
1681 % ``\special{pdf:dest ...}'' cannot handle non-ASCII strings.
1682 % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753).
1683%
1684 \def\skipspaces#1{\def\PP{#1}\def\D{|}%
1685 \ifx\PP\D\let\nextsp\relax
1686 \else\let\nextsp\skipspaces
1687 \addtokens{\filename}{\PP}%
1688 \advance\filenamelength by 1
1689 \fi
1690 \nextsp}
1691 \def\getfilename#1{%
1692 \filenamelength=0
1693 % If we don't expand the argument now, \skipspaces will get
1694 % snagged on things like "@value{foo}".
1695 \edef\temp{#1}%
1696 \expandafter\skipspaces\temp|\relax
1697 }
1698 % make a live url in pdf output.
1699 \def\pdfurl#1{%
1700 \begingroup
1701 % it seems we really need yet another set of dummies; have not
1702 % tried to figure out what each command should do in the context
1703 % of @url. for now, just make @/ a no-op, that's the only one
1704 % people have actually reported a problem with.
1705 %
1706 \normalturnoffactive
1707 \def\@{@}%
1708 \let\/=\empty
1709 \makevalueexpandable
1710 % do we want to go so far as to use \indexnofonts instead of just
1711 % special-casing \var here?
1712 \def\var##1{##1}%
1713 %
1714 \leavevmode\setcolor{\urlcolor}%
1715 \special{pdf:bann << /Border [0 0 0]
1716 /Subtype /Link /A << /S /URI /URI (#1) >> >>}%
1717 \endgroup}
1718 \def\endlink{\setcolor{\maincolor}\special{pdf:eann}}
1719 \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1720 \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1721 \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1722 \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1723 \def\maketoks{%
1724 \expandafter\poptoks\the\toksA|ENDTOKS|\relax
1725 \ifx\first0\adn0
1726 \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1727 \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
1728 \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
1729 \else
1730 \ifnum0=\countA\else\makelink\fi
1731 \ifx\first.\let\next=\done\else
1732 \let\next=\maketoks
1733 \addtokens{\toksB}{\the\toksD}
1734 \ifx\first,\addtokens{\toksB}{\space}\fi
1735 \fi
1736 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1737 \next}
1738 \def\makelink{\addtokens{\toksB}%
1739 {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1740 \def\pdflink#1{%
1741 \special{pdf:bann << /Border [0 0 0]
1742 /Type /Annot /Subtype /Link /A << /S /GoTo /D (#1) >> >>}%
1743 \setcolor{\linkcolor}#1\endlink}
1744 \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1745%
1746 %
1747 % @image support
1748 %
1749 % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
1750 \def\doxeteximage#1#2#3{%
1751 \def\xeteximagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
1752 \def\xeteximageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
1753 %
1754 % XeTeX (and the PDF format) supports .pdf, .png, .jpg (among
1755 % others). Let's try in that order, PDF first since if
1756 % someone has a scalable image, presumably better to use that than a
1757 % bitmap.
1758 \let\xeteximgext=\empty
1759 \begingroup
1760 \openin 1 #1.pdf \ifeof 1
1761 \openin 1 #1.PDF \ifeof 1
1762 \openin 1 #1.png \ifeof 1
1763 \openin 1 #1.jpg \ifeof 1
1764 \openin 1 #1.jpeg \ifeof 1
1765 \openin 1 #1.JPG \ifeof 1
1766 \errmessage{Could not find image file #1 for XeTeX}%
1767 \else \gdef\xeteximgext{JPG}%
1768 \fi
1769 \else \gdef\xeteximgext{jpeg}%
1770 \fi
1771 \else \gdef\xeteximgext{jpg}%
1772 \fi
1773 \else \gdef\xeteximgext{png}%
1774 \fi
1775 \else \gdef\xeteximgext{PDF}%
1776 \fi
1777 \else \gdef\xeteximgext{pdf}%
1778 \fi
1779 \closein 1
1780 \endgroup
1781 %
1782 \def\xetexpdfext{pdf}%
1783 \ifx\xeteximgext\xetexpdfext
1784 \XeTeXpdffile "#1".\xeteximgext ""
1785 \else
1786 \def\xetexpdfext{PDF}%
1787 \ifx\xeteximgext\xetexpdfext
1788 \XeTeXpdffile "#1".\xeteximgext ""
1789 \else
1790 \XeTeXpicfile "#1".\xeteximgext ""
1791 \fi
1792 \fi
1793 \ifdim \wd0 >0pt width \xeteximagewidth \fi
1794 \ifdim \wd2 >0pt height \xeteximageheight \fi \relax
1795 }
1796\fi
9e9f9cc2 1797
9e9f9cc2 1798
7f7dd1d3
JM
1799%
1800\message{fonts,}
9251c568 1801
e23f8d20
UD
1802% Set the baselineskip to #1, and the lineskip and strut size
1803% correspondingly. There is no deep meaning behind these magic numbers
1804% used as factors; they just match (closely enough) what Knuth defined.
1805%
1806\def\lineskipfactor{.08333}
1807\def\strutheightpercent{.70833}
1808\def\strutdepthpercent {.29167}
1809%
c94f48d7
AJ
1810% can get a sort of poor man's double spacing by redefining this.
1811\def\baselinefactor{1}
1812%
8fcb833a 1813\newdimen\textleading
e23f8d20 1814\def\setleading#1{%
c94f48d7
AJ
1815 \dimen0 = #1\relax
1816 \normalbaselineskip = \baselinefactor\dimen0
e23f8d20
UD
1817 \normallineskip = \lineskipfactor\normalbaselineskip
1818 \normalbaselines
1819 \setbox\strutbox =\hbox{%
1820 \vrule width0pt height\strutheightpercent\baselineskip
1821 depth \strutdepthpercent \baselineskip
1822 }%
1823}
1824
c94f48d7
AJ
1825% PDF CMaps. See also LaTeX's t1.cmap.
1826%
0f8bbd69
JM
1827% do nothing with this by default.
1828\expandafter\let\csname cmapOT1\endcsname\gobble
1829\expandafter\let\csname cmapOT1IT\endcsname\gobble
1830\expandafter\let\csname cmapOT1TT\endcsname\gobble
1831
1832% if we are producing pdf, and we have \pdffontattr, then define cmaps.
1833% (\pdffontattr was introduced many years ago, but people still run
1834% older pdftex's; it's easy to conditionalize, so we do.)
1835\ifpdf \ifx\pdffontattr\thisisundefined \else
c94f48d7
AJ
1836 \begingroup
1837 \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
1838 \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
1839%%DocumentNeededResources: ProcSet (CIDInit)
1840%%IncludeResource: ProcSet (CIDInit)
1841%%BeginResource: CMap (TeX-OT1-0)
1842%%Title: (TeX-OT1-0 TeX OT1 0)
1843%%Version: 1.000
1844%%EndComments
1845/CIDInit /ProcSet findresource begin
184612 dict begin
1847begincmap
1848/CIDSystemInfo
1849<< /Registry (TeX)
1850/Ordering (OT1)
1851/Supplement 0
1852>> def
1853/CMapName /TeX-OT1-0 def
1854/CMapType 2 def
18551 begincodespacerange
1856<00> <7F>
1857endcodespacerange
18588 beginbfrange
1859<00> <01> <0393>
1860<09> <0A> <03A8>
1861<23> <26> <0023>
1862<28> <3B> <0028>
1863<3F> <5B> <003F>
1864<5D> <5E> <005D>
1865<61> <7A> <0061>
1866<7B> <7C> <2013>
1867endbfrange
186840 beginbfchar
1869<02> <0398>
1870<03> <039B>
1871<04> <039E>
1872<05> <03A0>
1873<06> <03A3>
1874<07> <03D2>
1875<08> <03A6>
1876<0B> <00660066>
1877<0C> <00660069>
1878<0D> <0066006C>
1879<0E> <006600660069>
1880<0F> <00660066006C>
1881<10> <0131>
1882<11> <0237>
1883<12> <0060>
1884<13> <00B4>
1885<14> <02C7>
1886<15> <02D8>
1887<16> <00AF>
1888<17> <02DA>
1889<18> <00B8>
1890<19> <00DF>
1891<1A> <00E6>
1892<1B> <0153>
1893<1C> <00F8>
1894<1D> <00C6>
1895<1E> <0152>
1896<1F> <00D8>
1897<21> <0021>
1898<22> <201D>
1899<27> <2019>
1900<3C> <00A1>
1901<3D> <003D>
1902<3E> <00BF>
1903<5C> <201C>
1904<5F> <02D9>
1905<60> <2018>
1906<7D> <02DD>
1907<7E> <007E>
1908<7F> <00A8>
1909endbfchar
1910endcmap
1911CMapName currentdict /CMap defineresource pop
1912end
1913end
1914%%EndResource
1915%%EOF
1916 }\endgroup
1917 \expandafter\edef\csname cmapOT1\endcsname#1{%
1918 \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
1919 }%
1920%
1921% \cmapOT1IT
1922 \begingroup
1923 \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
1924 \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
1925%%DocumentNeededResources: ProcSet (CIDInit)
1926%%IncludeResource: ProcSet (CIDInit)
1927%%BeginResource: CMap (TeX-OT1IT-0)
1928%%Title: (TeX-OT1IT-0 TeX OT1IT 0)
1929%%Version: 1.000
1930%%EndComments
1931/CIDInit /ProcSet findresource begin
193212 dict begin
1933begincmap
1934/CIDSystemInfo
1935<< /Registry (TeX)
1936/Ordering (OT1IT)
1937/Supplement 0
1938>> def
1939/CMapName /TeX-OT1IT-0 def
1940/CMapType 2 def
19411 begincodespacerange
1942<00> <7F>
1943endcodespacerange
19448 beginbfrange
1945<00> <01> <0393>
1946<09> <0A> <03A8>
1947<25> <26> <0025>
1948<28> <3B> <0028>
1949<3F> <5B> <003F>
1950<5D> <5E> <005D>
1951<61> <7A> <0061>
1952<7B> <7C> <2013>
1953endbfrange
195442 beginbfchar
1955<02> <0398>
1956<03> <039B>
1957<04> <039E>
1958<05> <03A0>
1959<06> <03A3>
1960<07> <03D2>
1961<08> <03A6>
1962<0B> <00660066>
1963<0C> <00660069>
1964<0D> <0066006C>
1965<0E> <006600660069>
1966<0F> <00660066006C>
1967<10> <0131>
1968<11> <0237>
1969<12> <0060>
1970<13> <00B4>
1971<14> <02C7>
1972<15> <02D8>
1973<16> <00AF>
1974<17> <02DA>
1975<18> <00B8>
1976<19> <00DF>
1977<1A> <00E6>
1978<1B> <0153>
1979<1C> <00F8>
1980<1D> <00C6>
1981<1E> <0152>
1982<1F> <00D8>
1983<21> <0021>
1984<22> <201D>
1985<23> <0023>
1986<24> <00A3>
1987<27> <2019>
1988<3C> <00A1>
1989<3D> <003D>
1990<3E> <00BF>
1991<5C> <201C>
1992<5F> <02D9>
1993<60> <2018>
1994<7D> <02DD>
1995<7E> <007E>
1996<7F> <00A8>
1997endbfchar
1998endcmap
1999CMapName currentdict /CMap defineresource pop
2000end
2001end
2002%%EndResource
2003%%EOF
2004 }\endgroup
2005 \expandafter\edef\csname cmapOT1IT\endcsname#1{%
2006 \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
2007 }%
2008%
2009% \cmapOT1TT
2010 \begingroup
2011 \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
2012 \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
2013%%DocumentNeededResources: ProcSet (CIDInit)
2014%%IncludeResource: ProcSet (CIDInit)
2015%%BeginResource: CMap (TeX-OT1TT-0)
2016%%Title: (TeX-OT1TT-0 TeX OT1TT 0)
2017%%Version: 1.000
2018%%EndComments
2019/CIDInit /ProcSet findresource begin
202012 dict begin
2021begincmap
2022/CIDSystemInfo
2023<< /Registry (TeX)
2024/Ordering (OT1TT)
2025/Supplement 0
2026>> def
2027/CMapName /TeX-OT1TT-0 def
2028/CMapType 2 def
20291 begincodespacerange
2030<00> <7F>
2031endcodespacerange
20325 beginbfrange
2033<00> <01> <0393>
2034<09> <0A> <03A8>
2035<21> <26> <0021>
2036<28> <5F> <0028>
2037<61> <7E> <0061>
2038endbfrange
203932 beginbfchar
2040<02> <0398>
2041<03> <039B>
2042<04> <039E>
2043<05> <03A0>
2044<06> <03A3>
2045<07> <03D2>
2046<08> <03A6>
2047<0B> <2191>
2048<0C> <2193>
2049<0D> <0027>
2050<0E> <00A1>
2051<0F> <00BF>
2052<10> <0131>
2053<11> <0237>
2054<12> <0060>
2055<13> <00B4>
2056<14> <02C7>
2057<15> <02D8>
2058<16> <00AF>
2059<17> <02DA>
2060<18> <00B8>
2061<19> <00DF>
2062<1A> <00E6>
2063<1B> <0153>
2064<1C> <00F8>
2065<1D> <00C6>
2066<1E> <0152>
2067<1F> <00D8>
2068<20> <2423>
2069<27> <2019>
2070<60> <2018>
2071<7F> <00A8>
2072endbfchar
2073endcmap
2074CMapName currentdict /CMap defineresource pop
2075end
2076end
2077%%EndResource
2078%%EOF
2079 }\endgroup
2080 \expandafter\edef\csname cmapOT1TT\endcsname#1{%
2081 \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
2082 }%
0f8bbd69 2083\fi\fi
c94f48d7 2084
9251c568 2085
8fcb833a 2086% Set the font macro #1 to the font named \fontprefix#2.
c94f48d7 2087% #3 is the font's design size, #4 is a scale factor, #5 is the CMap
8fcb833a
JM
2088% encoding (only OT1, OT1IT and OT1TT are allowed, or empty to omit).
2089% Example:
2090% #1 = \textrm
2091% #2 = \rmshape
2092% #3 = 10
2093% #4 = \mainmagstep
2094% #5 = OT1
2095%
c94f48d7
AJ
2096\def\setfont#1#2#3#4#5{%
2097 \font#1=\fontprefix#2#3 scaled #4
2098 \csname cmap#5\endcsname#1%
2099}
2100% This is what gets called when #5 of \setfont is empty.
2101\let\cmap\gobble
8fcb833a
JM
2102%
2103% (end of cmaps)
9251c568 2104
9e9f9cc2
KB
2105% Use cm as the default font prefix.
2106% To specify the font prefix, you must define \fontprefix
2107% before you read in texinfo.tex.
0f8bbd69 2108\ifx\fontprefix\thisisundefined
9e9f9cc2
KB
2109\def\fontprefix{cm}
2110\fi
2111% Support font families that don't use the same naming scheme as CM.
2112\def\rmshape{r}
8fcb833a 2113\def\rmbshape{bx} % where the normal face is bold
9e9f9cc2
KB
2114\def\bfshape{b}
2115\def\bxshape{bx}
2116\def\ttshape{tt}
2117\def\ttbshape{tt}
2118\def\ttslshape{sltt}
2119\def\itshape{ti}
2120\def\itbshape{bxti}
2121\def\slshape{sl}
2122\def\slbshape{bxsl}
2123\def\sfshape{ss}
2124\def\sfbshape{ss}
2125\def\scshape{csc}
2126\def\scbshape{csc}
2127
8fcb833a 2128% Definitions for a main text size of 11pt. (The default in Texinfo.)
0f8bbd69 2129%
c94f48d7 2130\def\definetextfontsizexi{%
82d5ce1d
UD
2131% Text fonts (11.2pt, magstep1).
2132\def\textnominalsize{11pt}
2133\edef\mainmagstep{\magstephalf}
c94f48d7
AJ
2134\setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
2135\setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
2136\setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
2137\setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
2138\setfont\textsl\slshape{10}{\mainmagstep}{OT1}
2139\setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
2140\setfont\textsc\scshape{10}{\mainmagstep}{OT1}
2141\setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
9e9f9cc2
KB
2142\font\texti=cmmi10 scaled \mainmagstep
2143\font\textsy=cmsy10 scaled \mainmagstep
c94f48d7 2144\def\textecsize{1095}
9e9f9cc2 2145
82d5ce1d 2146% A few fonts for @defun names and args.
c94f48d7
AJ
2147\setfont\defbf\bfshape{10}{\magstep1}{OT1}
2148\setfont\deftt\ttshape{10}{\magstep1}{OT1TT}
084e7d57 2149\setfont\defsl\slshape{10}{\magstep1}{OT1TT}
c94f48d7 2150\setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT}
7f7dd1d3
JM
2151\def\df{\let\ttfont=\deftt \let\bffont = \defbf
2152\let\ttslfont=\defttsl \let\slfont=\defsl \bf}
9e9f9cc2 2153
3b82ab1c 2154% Fonts for indices, footnotes, small examples (9pt).
82d5ce1d 2155\def\smallnominalsize{9pt}
c94f48d7
AJ
2156\setfont\smallrm\rmshape{9}{1000}{OT1}
2157\setfont\smalltt\ttshape{9}{1000}{OT1TT}
2158\setfont\smallbf\bfshape{10}{900}{OT1}
2159\setfont\smallit\itshape{9}{1000}{OT1IT}
2160\setfont\smallsl\slshape{9}{1000}{OT1}
2161\setfont\smallsf\sfshape{9}{1000}{OT1}
2162\setfont\smallsc\scshape{10}{900}{OT1}
2163\setfont\smallttsl\ttslshape{10}{900}{OT1TT}
3b82ab1c
UD
2164\font\smalli=cmmi9
2165\font\smallsy=cmsy9
c94f48d7 2166\def\smallecsize{0900}
9e9f9cc2 2167
be1152ca 2168% Fonts for small examples (8pt).
82d5ce1d 2169\def\smallernominalsize{8pt}
c94f48d7
AJ
2170\setfont\smallerrm\rmshape{8}{1000}{OT1}
2171\setfont\smallertt\ttshape{8}{1000}{OT1TT}
2172\setfont\smallerbf\bfshape{10}{800}{OT1}
2173\setfont\smallerit\itshape{8}{1000}{OT1IT}
2174\setfont\smallersl\slshape{8}{1000}{OT1}
2175\setfont\smallersf\sfshape{8}{1000}{OT1}
2176\setfont\smallersc\scshape{10}{800}{OT1}
2177\setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
be1152ca
UD
2178\font\smalleri=cmmi8
2179\font\smallersy=cmsy8
c94f48d7 2180\def\smallerecsize{0800}
be1152ca 2181
c37cd439
JM
2182% Fonts for math mode superscripts (7pt).
2183\def\sevennominalsize{7pt}
2184\setfont\sevenrm\rmshape{7}{1000}{OT1}
2185\setfont\seventt\ttshape{10}{700}{OT1TT}
2186\setfont\sevenbf\bfshape{10}{700}{OT1}
2187\setfont\sevenit\itshape{7}{1000}{OT1IT}
2188\setfont\sevensl\slshape{10}{700}{OT1}
2189\setfont\sevensf\sfshape{10}{700}{OT1}
2190\setfont\sevensc\scshape{10}{700}{OT1}
2191\setfont\seventtsl\ttslshape{10}{700}{OT1TT}
2192\font\seveni=cmmi7
2193\font\sevensy=cmsy7
2194\def\sevenecsize{0700}
2195
82d5ce1d
UD
2196% Fonts for title page (20.4pt):
2197\def\titlenominalsize{20pt}
c94f48d7
AJ
2198\setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
2199\setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
2200\setfont\titlesl\slbshape{10}{\magstep4}{OT1}
2201\setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
2202\setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
2203\setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
9c2322bc 2204\let\titlebf=\titlerm
c94f48d7 2205\setfont\titlesc\scbshape{10}{\magstep4}{OT1}
9c2322bc
UD
2206\font\titlei=cmmi12 scaled \magstep3
2207\font\titlesy=cmsy10 scaled \magstep4
c94f48d7 2208\def\titleecsize{2074}
9c2322bc 2209
cd4e176c 2210% Chapter (and unnumbered) fonts (17.28pt).
82d5ce1d 2211\def\chapnominalsize{17pt}
c94f48d7
AJ
2212\setfont\chaprm\rmbshape{12}{\magstep2}{OT1}
2213\setfont\chapit\itbshape{10}{\magstep3}{OT1IT}
2214\setfont\chapsl\slbshape{10}{\magstep3}{OT1}
2215\setfont\chaptt\ttbshape{12}{\magstep2}{OT1TT}
2216\setfont\chapttsl\ttslshape{10}{\magstep3}{OT1TT}
2217\setfont\chapsf\sfbshape{17}{1000}{OT1}
9e9f9cc2 2218\let\chapbf=\chaprm
c94f48d7 2219\setfont\chapsc\scbshape{10}{\magstep3}{OT1}
9e9f9cc2
KB
2220\font\chapi=cmmi12 scaled \magstep2
2221\font\chapsy=cmsy10 scaled \magstep3
c94f48d7 2222\def\chapecsize{1728}
9e9f9cc2 2223
cd4e176c 2224% Section fonts (14.4pt).
82d5ce1d 2225\def\secnominalsize{14pt}
c94f48d7 2226\setfont\secrm\rmbshape{12}{\magstep1}{OT1}
084e7d57 2227\setfont\secrmnotbold\rmshape{12}{\magstep1}{OT1}
c94f48d7
AJ
2228\setfont\secit\itbshape{10}{\magstep2}{OT1IT}
2229\setfont\secsl\slbshape{10}{\magstep2}{OT1}
2230\setfont\sectt\ttbshape{12}{\magstep1}{OT1TT}
2231\setfont\secttsl\ttslshape{10}{\magstep2}{OT1TT}
2232\setfont\secsf\sfbshape{12}{\magstep1}{OT1}
9e9f9cc2 2233\let\secbf\secrm
c94f48d7 2234\setfont\secsc\scbshape{10}{\magstep2}{OT1}
9e9f9cc2
KB
2235\font\seci=cmmi12 scaled \magstep1
2236\font\secsy=cmsy10 scaled \magstep2
c94f48d7 2237\def\sececsize{1440}
9e9f9cc2 2238
cd4e176c 2239% Subsection fonts (13.15pt).
82d5ce1d 2240\def\ssecnominalsize{13pt}
c94f48d7
AJ
2241\setfont\ssecrm\rmbshape{12}{\magstephalf}{OT1}
2242\setfont\ssecit\itbshape{10}{1315}{OT1IT}
2243\setfont\ssecsl\slbshape{10}{1315}{OT1}
2244\setfont\ssectt\ttbshape{12}{\magstephalf}{OT1TT}
2245\setfont\ssecttsl\ttslshape{10}{1315}{OT1TT}
2246\setfont\ssecsf\sfbshape{12}{\magstephalf}{OT1}
9e9f9cc2 2247\let\ssecbf\ssecrm
c94f48d7 2248\setfont\ssecsc\scbshape{10}{1315}{OT1}
9e9f9cc2 2249\font\sseci=cmmi12 scaled \magstephalf
9c2322bc 2250\font\ssecsy=cmsy10 scaled 1315
c94f48d7 2251\def\ssececsize{1200}
82d5ce1d 2252
7f7dd1d3 2253% Reduced fonts for @acronym in text (10pt).
82d5ce1d 2254\def\reducednominalsize{10pt}
c94f48d7
AJ
2255\setfont\reducedrm\rmshape{10}{1000}{OT1}
2256\setfont\reducedtt\ttshape{10}{1000}{OT1TT}
2257\setfont\reducedbf\bfshape{10}{1000}{OT1}
2258\setfont\reducedit\itshape{10}{1000}{OT1IT}
2259\setfont\reducedsl\slshape{10}{1000}{OT1}
2260\setfont\reducedsf\sfshape{10}{1000}{OT1}
2261\setfont\reducedsc\scshape{10}{1000}{OT1}
2262\setfont\reducedttsl\ttslshape{10}{1000}{OT1TT}
82d5ce1d
UD
2263\font\reducedi=cmmi10
2264\font\reducedsy=cmsy10
c94f48d7 2265\def\reducedecsize{1000}
9e9f9cc2 2266
0f8bbd69
JM
2267\textleading = 13.2pt % line spacing for 11pt CM
2268\textfonts % reset the current fonts
9251c568 2269\rm
8fcb833a 2270} % end of 11pt text font size definitions, \definetextfontsizexi
9251c568
AJ
2271
2272
2273% Definitions to make the main text be 10pt Computer Modern, with
2274% section, chapter, etc., sizes following suit. This is for the GNU
2275% Press printing of the Emacs 22 manual. Maybe other manuals in the
2276% future. Used with @smallbook, which sets the leading to 12pt.
0f8bbd69 2277%
9251c568
AJ
2278\def\definetextfontsizex{%
2279% Text fonts (10pt).
2280\def\textnominalsize{10pt}
2281\edef\mainmagstep{1000}
c94f48d7
AJ
2282\setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
2283\setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
2284\setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
2285\setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
2286\setfont\textsl\slshape{10}{\mainmagstep}{OT1}
2287\setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
2288\setfont\textsc\scshape{10}{\mainmagstep}{OT1}
2289\setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
9251c568
AJ
2290\font\texti=cmmi10 scaled \mainmagstep
2291\font\textsy=cmsy10 scaled \mainmagstep
c94f48d7 2292\def\textecsize{1000}
9251c568
AJ
2293
2294% A few fonts for @defun names and args.
c94f48d7
AJ
2295\setfont\defbf\bfshape{10}{\magstephalf}{OT1}
2296\setfont\deftt\ttshape{10}{\magstephalf}{OT1TT}
084e7d57 2297\setfont\defsl\slshape{10}{\magstephalf}{OT1TT}
c94f48d7 2298\setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT}
7f7dd1d3
JM
2299\def\df{\let\ttfont=\deftt \let\bffont = \defbf
2300\let\slfont=\defsl \let\ttslfont=\defttsl \bf}
9251c568
AJ
2301
2302% Fonts for indices, footnotes, small examples (9pt).
2303\def\smallnominalsize{9pt}
c94f48d7
AJ
2304\setfont\smallrm\rmshape{9}{1000}{OT1}
2305\setfont\smalltt\ttshape{9}{1000}{OT1TT}
2306\setfont\smallbf\bfshape{10}{900}{OT1}
2307\setfont\smallit\itshape{9}{1000}{OT1IT}
2308\setfont\smallsl\slshape{9}{1000}{OT1}
2309\setfont\smallsf\sfshape{9}{1000}{OT1}
2310\setfont\smallsc\scshape{10}{900}{OT1}
2311\setfont\smallttsl\ttslshape{10}{900}{OT1TT}
9251c568
AJ
2312\font\smalli=cmmi9
2313\font\smallsy=cmsy9
c94f48d7 2314\def\smallecsize{0900}
9251c568
AJ
2315
2316% Fonts for small examples (8pt).
2317\def\smallernominalsize{8pt}
c94f48d7
AJ
2318\setfont\smallerrm\rmshape{8}{1000}{OT1}
2319\setfont\smallertt\ttshape{8}{1000}{OT1TT}
2320\setfont\smallerbf\bfshape{10}{800}{OT1}
2321\setfont\smallerit\itshape{8}{1000}{OT1IT}
2322\setfont\smallersl\slshape{8}{1000}{OT1}
2323\setfont\smallersf\sfshape{8}{1000}{OT1}
2324\setfont\smallersc\scshape{10}{800}{OT1}
2325\setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
9251c568
AJ
2326\font\smalleri=cmmi8
2327\font\smallersy=cmsy8
c94f48d7 2328\def\smallerecsize{0800}
9251c568 2329
c37cd439
JM
2330% Fonts for math mode superscripts (7pt).
2331\def\sevennominalsize{7pt}
2332\setfont\sevenrm\rmshape{7}{1000}{OT1}
2333\setfont\seventt\ttshape{10}{700}{OT1TT}
2334\setfont\sevenbf\bfshape{10}{700}{OT1}
2335\setfont\sevenit\itshape{7}{1000}{OT1IT}
2336\setfont\sevensl\slshape{10}{700}{OT1}
2337\setfont\sevensf\sfshape{10}{700}{OT1}
2338\setfont\sevensc\scshape{10}{700}{OT1}
2339\setfont\seventtsl\ttslshape{10}{700}{OT1TT}
2340\font\seveni=cmmi7
2341\font\sevensy=cmsy7
2342\def\sevenecsize{0700}
2343
9251c568
AJ
2344% Fonts for title page (20.4pt):
2345\def\titlenominalsize{20pt}
c94f48d7
AJ
2346\setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
2347\setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
2348\setfont\titlesl\slbshape{10}{\magstep4}{OT1}
2349\setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
2350\setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
2351\setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
9251c568 2352\let\titlebf=\titlerm
c94f48d7 2353\setfont\titlesc\scbshape{10}{\magstep4}{OT1}
9251c568
AJ
2354\font\titlei=cmmi12 scaled \magstep3
2355\font\titlesy=cmsy10 scaled \magstep4
c94f48d7 2356\def\titleecsize{2074}
9251c568
AJ
2357
2358% Chapter fonts (14.4pt).
2359\def\chapnominalsize{14pt}
c94f48d7
AJ
2360\setfont\chaprm\rmbshape{12}{\magstep1}{OT1}
2361\setfont\chapit\itbshape{10}{\magstep2}{OT1IT}
2362\setfont\chapsl\slbshape{10}{\magstep2}{OT1}
2363\setfont\chaptt\ttbshape{12}{\magstep1}{OT1TT}
2364\setfont\chapttsl\ttslshape{10}{\magstep2}{OT1TT}
2365\setfont\chapsf\sfbshape{12}{\magstep1}{OT1}
9251c568 2366\let\chapbf\chaprm
c94f48d7 2367\setfont\chapsc\scbshape{10}{\magstep2}{OT1}
9251c568
AJ
2368\font\chapi=cmmi12 scaled \magstep1
2369\font\chapsy=cmsy10 scaled \magstep2
c94f48d7 2370\def\chapecsize{1440}
9251c568
AJ
2371
2372% Section fonts (12pt).
2373\def\secnominalsize{12pt}
c94f48d7
AJ
2374\setfont\secrm\rmbshape{12}{1000}{OT1}
2375\setfont\secit\itbshape{10}{\magstep1}{OT1IT}
2376\setfont\secsl\slbshape{10}{\magstep1}{OT1}
2377\setfont\sectt\ttbshape{12}{1000}{OT1TT}
2378\setfont\secttsl\ttslshape{10}{\magstep1}{OT1TT}
2379\setfont\secsf\sfbshape{12}{1000}{OT1}
9251c568 2380\let\secbf\secrm
c94f48d7 2381\setfont\secsc\scbshape{10}{\magstep1}{OT1}
0f8bbd69 2382\font\seci=cmmi12
9251c568 2383\font\secsy=cmsy10 scaled \magstep1
c94f48d7 2384\def\sececsize{1200}
9251c568
AJ
2385
2386% Subsection fonts (10pt).
2387\def\ssecnominalsize{10pt}
c94f48d7
AJ
2388\setfont\ssecrm\rmbshape{10}{1000}{OT1}
2389\setfont\ssecit\itbshape{10}{1000}{OT1IT}
2390\setfont\ssecsl\slbshape{10}{1000}{OT1}
2391\setfont\ssectt\ttbshape{10}{1000}{OT1TT}
2392\setfont\ssecttsl\ttslshape{10}{1000}{OT1TT}
2393\setfont\ssecsf\sfbshape{10}{1000}{OT1}
9251c568 2394\let\ssecbf\ssecrm
c94f48d7 2395\setfont\ssecsc\scbshape{10}{1000}{OT1}
9251c568
AJ
2396\font\sseci=cmmi10
2397\font\ssecsy=cmsy10
c94f48d7 2398\def\ssececsize{1000}
9251c568 2399
7f7dd1d3 2400% Reduced fonts for @acronym in text (9pt).
9251c568 2401\def\reducednominalsize{9pt}
c94f48d7
AJ
2402\setfont\reducedrm\rmshape{9}{1000}{OT1}
2403\setfont\reducedtt\ttshape{9}{1000}{OT1TT}
2404\setfont\reducedbf\bfshape{10}{900}{OT1}
2405\setfont\reducedit\itshape{9}{1000}{OT1IT}
2406\setfont\reducedsl\slshape{9}{1000}{OT1}
2407\setfont\reducedsf\sfshape{9}{1000}{OT1}
2408\setfont\reducedsc\scshape{10}{900}{OT1}
2409\setfont\reducedttsl\ttslshape{10}{900}{OT1TT}
9251c568
AJ
2410\font\reducedi=cmmi9
2411\font\reducedsy=cmsy9
c94f48d7 2412\def\reducedecsize{0900}
9251c568 2413
0f8bbd69
JM
2414\divide\parskip by 2 % reduce space between paragraphs
2415\textleading = 12pt % line spacing for 10pt CM
2416\textfonts % reset the current fonts
9251c568 2417\rm
8fcb833a 2418} % end of 10pt text font size definitions, \definetextfontsizex
9251c568 2419
7f7dd1d3
JM
2420% Fonts for short table of contents.
2421\setfont\shortcontrm\rmshape{12}{1000}{OT1}
2422\setfont\shortcontbf\bfshape{10}{\magstep1}{OT1} % no cmb12
2423\setfont\shortcontsl\slshape{12}{1000}{OT1}
2424\setfont\shortconttt\ttshape{12}{1000}{OT1TT}
2425
9251c568
AJ
2426
2427% We provide the user-level command
2428% @fonttextsize 10
2429% (or 11) to redefine the text font size. pt is assumed.
0f8bbd69 2430%
9251c568 2431\def\xiword{11}
0f8bbd69
JM
2432\def\xword{10}
2433\def\xwordpt{10pt}
9251c568
AJ
2434%
2435\parseargdef\fonttextsize{%
2436 \def\textsizearg{#1}%
0f8bbd69 2437 %\wlog{doing @fonttextsize \textsizearg}%
9251c568
AJ
2438 %
2439 % Set \globaldefs so that documents can use this inside @tex, since
2440 % makeinfo 4.8 does not support it, but we need it nonetheless.
0f8bbd69 2441 %
9251c568
AJ
2442 \begingroup \globaldefs=1
2443 \ifx\textsizearg\xword \definetextfontsizex
2444 \else \ifx\textsizearg\xiword \definetextfontsizexi
2445 \else
2446 \errhelp=\EMsimple
2447 \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'}
2448 \fi\fi
2449 \endgroup
2450}
2451
7f7dd1d3
JM
2452%
2453% Change the current font style to #1, remembering it in \curfontstyle.
2454% For now, we do not accumulate font styles: @b{@i{foo}} prints foo in
2455% italics, not bold italics.
2456%
2457\def\setfontstyle#1{%
2458 \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd.
2459 \csname #1font\endcsname % change the current font
2460}
2461
2462\def\rm{\fam=0 \setfontstyle{rm}}
2463\def\it{\fam=\itfam \setfontstyle{it}}
2464\def\sl{\fam=\slfam \setfontstyle{sl}}
2465\def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf}
2466\def\tt{\fam=\ttfam \setfontstyle{tt}}
2467
2468% Texinfo sort of supports the sans serif font style, which plain TeX does not.
2469% So we set up a \sf.
2470\newfam\sffam
2471\def\sf{\fam=\sffam \setfontstyle{sf}}
2472
2473% We don't need math for this font style.
2474\def\ttsl{\setfontstyle{ttsl}}
2475
2476
9e9f9cc2 2477% In order for the font changes to affect most math symbols and letters,
c37cd439
JM
2478% we have to define the \textfont of the standard families.
2479% We don't bother to reset \scriptscriptfont; awaiting user need.
9e9f9cc2
KB
2480%
2481\def\resetmathfonts{%
7f7dd1d3
JM
2482 \textfont0=\rmfont \textfont1=\ifont \textfont2=\syfont
2483 \textfont\itfam=\itfont \textfont\slfam=\slfont \textfont\bffam=\bffont
2484 \textfont\ttfam=\ttfont \textfont\sffam=\sffont
c37cd439
JM
2485 %
2486 % Fonts for superscript. Note that the 7pt fonts are used regardless
2487 % of the current font size.
2488 \scriptfont0=\sevenrm \scriptfont1=\seveni \scriptfont2=\sevensy
2489 \scriptfont\itfam=\sevenit \scriptfont\slfam=\sevensl
2490 \scriptfont\bffam=\sevenbf \scriptfont\ttfam=\seventt
2491 \scriptfont\sffam=\sevensf
9e9f9cc2
KB
2492}
2493
7f7dd1d3
JM
2494%
2495
2496% The font-changing commands (all called \...fonts) redefine the meanings
2497% of \STYLEfont, instead of just \STYLE. We do this because \STYLE needs
2498% to also set the current \fam for math mode. Our \STYLE (e.g., \rm)
2499% commands hardwire \STYLEfont to set the current font.
82d5ce1d 2500%
c37cd439
JM
2501% The fonts used for \ifont are for "math italics" (\itfont is for italics
2502% in regular text). \syfont is also used in math mode only.
2503%
82d5ce1d 2504% Each font-changing command also sets the names \lsize (one size lower)
084e7d57
JM
2505% and \lllsize (three sizes lower). These relative commands are used
2506% in, e.g., the LaTeX logo and acronyms.
82d5ce1d
UD
2507%
2508% This all needs generalizing, badly.
2509%
e0f86659 2510
7f7dd1d3
JM
2511\def\assignfonts#1{%
2512 \expandafter\let\expandafter\rmfont\csname #1rm\endcsname
2513 \expandafter\let\expandafter\itfont\csname #1it\endcsname
2514 \expandafter\let\expandafter\slfont\csname #1sl\endcsname
2515 \expandafter\let\expandafter\bffont\csname #1bf\endcsname
2516 \expandafter\let\expandafter\ttfont\csname #1tt\endcsname
2517 \expandafter\let\expandafter\smallcaps\csname #1sc\endcsname
2518 \expandafter\let\expandafter\sffont \csname #1sf\endcsname
2519 \expandafter\let\expandafter\ifont \csname #1i\endcsname
2520 \expandafter\let\expandafter\syfont \csname #1sy\endcsname
2521 \expandafter\let\expandafter\ttslfont\csname #1ttsl\endcsname
2522}
2523
2524\newif\ifrmisbold
2525
2526% Select smaller font size with the current style. Used to change font size
2527% in, e.g., the LaTeX logo and acronyms. If we are using bold fonts for
2528% normal roman text, also use bold fonts for roman text in the smaller size.
2529\def\switchtolllsize{%
2530 \expandafter\assignfonts\expandafter{\lllsize}%
2531 \ifrmisbold
2532 \let\rmfont\bffont
2533 \fi
2534 \csname\curfontstyle\endcsname
2535}%
2536
2537\def\switchtolsize{%
2538 \expandafter\assignfonts\expandafter{\lsize}%
2539 \ifrmisbold
2540 \let\rmfont\bffont
2541 \fi
2542 \csname\curfontstyle\endcsname
2543}%
2544
2545\def\definefontsetatsize#1#2#3#4#5{%
2546\expandafter\def\csname #1fonts\endcsname{%
2547 \def\curfontsize{#1}%
2548 \def\lsize{#2}\def\lllsize{#3}%
2549 \csname rmisbold#5\endcsname
2550 \assignfonts{#1}%
2551 \resetmathfonts
2552 \setleading{#4}%
2553}}
2554
2555\definefontsetatsize{text} {reduced}{smaller}{\textleading}{false}
2556\definefontsetatsize{title} {chap} {subsec} {27pt} {true}
2557\definefontsetatsize{chap} {sec} {text} {19pt} {true}
2558\definefontsetatsize{sec} {subsec} {reduced}{17pt} {true}
2559\definefontsetatsize{ssec} {text} {small} {15pt} {true}
2560\definefontsetatsize{reduced}{small} {smaller}{10.5pt}{false}
2561\definefontsetatsize{small} {smaller}{smaller}{10.5pt}{false}
2562\definefontsetatsize{smaller}{smaller}{smaller}{9.5pt} {false}
2563
2564\def\titlefont#1{{\titlefonts\rm #1}}
2565\let\subsecfonts = \ssecfonts
2566\let\subsubsecfonts = \ssecfonts
0f8bbd69
JM
2567
2568% Define these just so they can be easily changed for other fonts.
2569\def\angleleft{$\langle$}
2570\def\angleright{$\rangle$}
2571
e0f86659
UD
2572% Set the fonts to use with the @small... environments.
2573\let\smallexamplefonts = \smallfonts
2574
2575% About \smallexamplefonts. If we use \smallfonts (9pt), @smallexample
2576% can fit this many characters:
2577% 8.5x11=86 smallbook=72 a4=90 a5=69
82d5ce1d 2578% If we use \scriptfonts (8pt), then we can fit this many characters:
e0f86659
UD
2579% 8.5x11=90+ smallbook=80 a4=90+ a5=77
2580% For me, subjectively, the few extra characters that fit aren't worth
2581% the additional smallness of 8pt. So I'm making the default 9pt.
7158eae4 2582%
e0f86659
UD
2583% By the way, for comparison, here's what fits with @example (10pt):
2584% 8.5x11=71 smallbook=60 a4=75 a5=58
e0f86659
UD
2585% --karl, 24jan03.
2586
9e9f9cc2
KB
2587% Set up the default fonts, so we can use them for creating boxes.
2588%
9251c568 2589\definetextfontsizexi
9e9f9cc2 2590
2eb45444 2591
0f8bbd69 2592\message{markup,}
9e9f9cc2 2593
0f8bbd69
JM
2594% Check if we are currently using a typewriter font. Since all the
2595% Computer Modern typewriter fonts have zero interword stretch (and
2596% shrink), and it is reasonable to expect all typewriter fonts to have
2597% this property, we can check that font parameter.
2598%
2599\def\ifmonospace{\ifdim\fontdimen3\font=0pt }
2600
2601% Markup style infrastructure. \defmarkupstylesetup\INITMACRO will
2602% define and register \INITMACRO to be called on markup style changes.
2603% \INITMACRO can check \currentmarkupstyle for the innermost
66ac23de 2604% style.
9e9f9cc2 2605
0f8bbd69 2606\let\currentmarkupstyle\empty
9e9f9cc2 2607
0f8bbd69 2608\def\setupmarkupstyle#1{%
0f8bbd69
JM
2609 \def\currentmarkupstyle{#1}%
2610 \markupstylesetup
2611}
9e9f9cc2 2612
0f8bbd69
JM
2613\let\markupstylesetup\empty
2614
2615\def\defmarkupstylesetup#1{%
2616 \expandafter\def\expandafter\markupstylesetup
2617 \expandafter{\markupstylesetup #1}%
2618 \def#1%
2619}
2620
2621% Markup style setup for left and right quotes.
2622\defmarkupstylesetup\markupsetuplq{%
2623 \expandafter\let\expandafter \temp
2624 \csname markupsetuplq\currentmarkupstyle\endcsname
2625 \ifx\temp\relax \markupsetuplqdefault \else \temp \fi
2626}
2627
2628\defmarkupstylesetup\markupsetuprq{%
2629 \expandafter\let\expandafter \temp
2630 \csname markupsetuprq\currentmarkupstyle\endcsname
2631 \ifx\temp\relax \markupsetuprqdefault \else \temp \fi
2632}
2633
2634{
2635\catcode`\'=\active
2636\catcode`\`=\active
2637
2638\gdef\markupsetuplqdefault{\let`\lq}
2639\gdef\markupsetuprqdefault{\let'\rq}
2640
2641\gdef\markupsetcodequoteleft{\let`\codequoteleft}
2642\gdef\markupsetcodequoteright{\let'\codequoteright}
0f8bbd69
JM
2643}
2644
2645\let\markupsetuplqcode \markupsetcodequoteleft
2646\let\markupsetuprqcode \markupsetcodequoteright
2647%
2648\let\markupsetuplqexample \markupsetcodequoteleft
2649\let\markupsetuprqexample \markupsetcodequoteright
2650%
8fcb833a
JM
2651\let\markupsetuplqkbd \markupsetcodequoteleft
2652\let\markupsetuprqkbd \markupsetcodequoteright
2653%
0f8bbd69
JM
2654\let\markupsetuplqsamp \markupsetcodequoteleft
2655\let\markupsetuprqsamp \markupsetcodequoteright
2656%
2657\let\markupsetuplqverb \markupsetcodequoteleft
2658\let\markupsetuprqverb \markupsetcodequoteright
2659%
2660\let\markupsetuplqverbatim \markupsetcodequoteleft
2661\let\markupsetuprqverbatim \markupsetcodequoteright
2662
0f8bbd69
JM
2663% Allow an option to not use regular directed right quote/apostrophe
2664% (char 0x27), but instead the undirected quote from cmtt (char 0x0d).
2665% The undirected quote is ugly, so don't make it the default, but it
2666% works for pasting with more pdf viewers (at least evince), the
2667% lilypond developers report. xpdf does work with the regular 0x27.
2668%
2669\def\codequoteright{%
66ac23de
JM
2670 \ifmonospace
2671 \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax
2672 \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax
2673 '%
2674 \else \char'15 \fi
0f8bbd69 2675 \else \char'15 \fi
66ac23de
JM
2676 \else
2677 '%
2678 \fi
0f8bbd69
JM
2679}
2680%
2681% and a similar option for the left quote char vs. a grave accent.
2682% Modern fonts display ASCII 0x60 as a grave accent, so some people like
2683% the code environments to do likewise.
2684%
2685\def\codequoteleft{%
66ac23de
JM
2686 \ifmonospace
2687 \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax
2688 \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax
2689 % [Knuth] pp. 380,381,391
2690 % \relax disables Spanish ligatures ?` and !` of \tt font.
2691 \relax`%
2692 \else \char'22 \fi
0f8bbd69 2693 \else \char'22 \fi
66ac23de
JM
2694 \else
2695 \relax`%
2696 \fi
0f8bbd69
JM
2697}
2698
2699% Commands to set the quote options.
2700%
2701\parseargdef\codequoteundirected{%
2702 \def\temp{#1}%
2703 \ifx\temp\onword
2704 \expandafter\let\csname SETtxicodequoteundirected\endcsname
2705 = t%
2706 \else\ifx\temp\offword
2707 \expandafter\let\csname SETtxicodequoteundirected\endcsname
2708 = \relax
2709 \else
2710 \errhelp = \EMsimple
2711 \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}%
2712 \fi\fi
2713}
2714%
2715\parseargdef\codequotebacktick{%
2716 \def\temp{#1}%
2717 \ifx\temp\onword
2718 \expandafter\let\csname SETtxicodequotebacktick\endcsname
2719 = t%
2720 \else\ifx\temp\offword
2721 \expandafter\let\csname SETtxicodequotebacktick\endcsname
2722 = \relax
2723 \else
2724 \errhelp = \EMsimple
2725 \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}%
2726 \fi\fi
2727}
2728
2729% [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font.
2730\def\noligaturesquoteleft{\relax\lq}
2731
2732% Count depth in font-changes, for error checks
2733\newcount\fontdepth \fontdepth=0
2734
2735% Font commands.
2736
2737% #1 is the font command (\sl or \it), #2 is the text to slant.
2738% If we are in a monospaced environment, however, 1) always use \ttsl,
2739% and 2) do not add an italic correction.
2740\def\dosmartslant#1#2{%
2741 \ifusingtt
2742 {{\ttsl #2}\let\next=\relax}%
2743 {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}%
2744 \next
2745}
2746\def\smartslanted{\dosmartslant\sl}
2747\def\smartitalic{\dosmartslant\it}
2748
2749% Output an italic correction unless \next (presumed to be the following
2750% character) is such as not to need one.
2751\def\smartitaliccorrection{%
2752 \ifx\next,%
2753 \else\ifx\next-%
2754 \else\ifx\next.%
21fea2e2
JM
2755 \else\ifx\next\.%
2756 \else\ifx\next\comma%
0f8bbd69 2757 \else\ptexslash
21fea2e2 2758 \fi\fi\fi\fi\fi
0f8bbd69
JM
2759 \aftersmartic
2760}
2761
8fcb833a 2762% Unconditional use \ttsl, and no ic. @var is set to this for defuns.
0f8bbd69 2763\def\ttslanted#1{{\ttsl #1}}
82d5ce1d 2764
0f8bbd69 2765% @cite is like \smartslanted except unconditionally use \sl. We never want
82d5ce1d 2766% ttsl for book titles, do we?
0f8bbd69
JM
2767\def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection}
2768
2769\def\aftersmartic{}
2770\def\var#1{%
2771 \let\saveaftersmartic = \aftersmartic
2772 \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}%
2773 \smartslanted{#1}%
2774}
82d5ce1d 2775
9e9f9cc2 2776\let\i=\smartitalic
82d5ce1d 2777\let\slanted=\smartslanted
409dfcea 2778\let\dfn=\smartslanted
9e9f9cc2 2779\let\emph=\smartitalic
9e9f9cc2 2780
0f8bbd69
JM
2781% Explicit font changes: @r, @sc, undocumented @ii.
2782\def\r#1{{\rm #1}} % roman font
2783\def\sc#1{{\smallcaps#1}} % smallcaps font
2784\def\ii#1{{\it #1}} % italic font
2785
2786% @b, explicit bold. Also @strong.
9e9f9cc2
KB
2787\def\b#1{{\bf #1}}
2788\let\strong=\b
2789
82d5ce1d
UD
2790% @sansserif, explicit sans.
2791\def\sansserif#1{{\sf #1}}
2792
9e9f9cc2
KB
2793% We can't just use \exhyphenpenalty, because that only has effect at
2794% the end of a paragraph. Restore normal hyphenation at the end of the
2795% group within which \nohyphenation is presumably called.
2796%
2797\def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation}
2798\def\restorehyphenation{\hyphenchar\font = `- }
2799
e0f86659
UD
2800% Set sfcode to normal for the chars that usually have another value.
2801% Can't use plain's \frenchspacing because it uses the `\x notation, and
2802% sometimes \x has an active definition that messes things up.
7158eae4 2803%
e0f86659 2804\catcode`@=11
9251c568 2805 \def\plainfrenchspacing{%
084e7d57
JM
2806 \sfcode`\.=\@m \sfcode`\?=\@m \sfcode`\!=\@m
2807 \sfcode`\:=\@m \sfcode`\;=\@m \sfcode`\,=\@m
9251c568
AJ
2808 \def\endofsentencespacefactor{1000}% for @. and friends
2809 }
2810 \def\plainnonfrenchspacing{%
2811 \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000
2812 \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250
2813 \def\endofsentencespacefactor{3000}% for @. and friends
e0f86659
UD
2814 }
2815\catcode`@=\other
9251c568 2816\def\endofsentencespacefactor{3000}% default
e0f86659 2817
0f8bbd69 2818% @t, explicit typewriter.
9e9f9cc2 2819\def\t#1{%
9251c568 2820 {\tt \rawbackslash \plainfrenchspacing #1}%
9e9f9cc2
KB
2821 \null
2822}
0f8bbd69
JM
2823
2824% @samp.
2825\def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}}
2826
8fcb833a
JM
2827% @indicateurl is \samp, that is, with quotes.
2828\let\indicateurl=\samp
9e9f9cc2 2829
8fcb833a
JM
2830% @code (and similar) prints in typewriter, but with spaces the same
2831% size as normal in the surrounding text, without hyphenation, etc.
2832% This is a subroutine for that.
9e9f9cc2
KB
2833\def\tclose#1{%
2834 {%
2835 % Change normal interword space to be same as for the current font.
2836 \spaceskip = \fontdimen2\font
2837 %
2838 % Switch to typewriter.
2839 \tt
2840 %
2841 % But `\ ' produces the large typewriter interword space.
2842 \def\ {{\spaceskip = 0pt{} }}%
2843 %
2844 % Turn off hyphenation.
2845 \nohyphenation
2846 %
2847 \rawbackslash
9251c568 2848 \plainfrenchspacing
9e9f9cc2
KB
2849 #1%
2850 }%
0f8bbd69 2851 \null % reset spacefactor to 1000
9e9f9cc2
KB
2852}
2853
82d5ce1d 2854% We *must* turn on hyphenation at `-' and `_' in @code.
8fcb833a 2855% (But see \codedashfinish below.)
9e9f9cc2
KB
2856% Otherwise, it is too hard to avoid overfull hboxes
2857% in the Emacs manual, the Library manual, etc.
8fcb833a 2858%
9e9f9cc2
KB
2859% Unfortunately, TeX uses one parameter (\hyphenchar) to control
2860% both hyphenation at - and hyphenation within words.
2861% We must therefore turn them both off (\tclose does that)
8fcb833a 2862% and arrange explicitly to hyphenate at a dash. -- rms.
9e9f9cc2 2863{
9251c568
AJ
2864 \catcode`\-=\active \catcode`\_=\active
2865 \catcode`\'=\active \catcode`\`=\active
0f8bbd69 2866 \global\let'=\rq \global\let`=\lq % default definitions
409dfcea
UD
2867 %
2868 \global\def\code{\begingroup
0f8bbd69
JM
2869 \setupmarkupstyle{code}%
2870 % The following should really be moved into \setupmarkupstyle handlers.
9251c568
AJ
2871 \catcode\dashChar=\active \catcode\underChar=\active
2872 \ifallowcodebreaks
2873 \let-\codedash
2874 \let_\codeunder
2875 \else
8fcb833a 2876 \let-\normaldash
9251c568
AJ
2877 \let_\realunder
2878 \fi
8fcb833a
JM
2879 % Given -foo (with a single dash), we do not want to allow a break
2880 % after the hyphen.
2881 \global\let\codedashprev=\codedash
2882 %
409dfcea
UD
2883 \codex
2884 }
8fcb833a
JM
2885 %
2886 \gdef\codedash{\futurelet\next\codedashfinish}
2887 \gdef\codedashfinish{%
2888 \normaldash % always output the dash character itself.
2889 %
2890 % Now, output a discretionary to allow a line break, unless
2891 % (a) the next character is a -, or
2892 % (b) the preceding character is a -.
2893 % E.g., given --posix, we do not want to allow a break after either -.
2894 % Given --foo-bar, we do want to allow a break between the - and the b.
2895 \ifx\next\codedash \else
2896 \ifx\codedashprev\codedash
2897 \else \discretionary{}{}{}\fi
2898 \fi
21fea2e2
JM
2899 % we need the space after the = for the case when \next itself is a
2900 % space token; it would get swallowed otherwise. As in @code{- a}.
2901 \global\let\codedashprev= \next
8fcb833a 2902 }
9e9f9cc2 2903}
8fcb833a
JM
2904\def\normaldash{-}
2905%
0f8bbd69
JM
2906\def\codex #1{\tclose{#1}\endgroup}
2907
27692f89
UD
2908\def\codeunder{%
2909 % this is all so @math{@code{var_name}+1} can work. In math mode, _
2910 % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.)
2911 % will therefore expand the active definition of _, which is us
2912 % (inside @code that is), therefore an endless loop.
2913 \ifusingtt{\ifmmode
2914 \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_.
2915 \else\normalunderscore \fi
2916 \discretionary{}{}{}}%
2917 {\_}%
2918}
9e9f9cc2 2919
9251c568 2920% An additional complication: the above will allow breaks after, e.g.,
8fcb833a
JM
2921% each of the four underscores in __typeof__. This is bad.
2922% @allowcodebreaks provides a document-level way to turn breaking at -
2923% and _ on and off.
0f8bbd69 2924%
9251c568
AJ
2925\newif\ifallowcodebreaks \allowcodebreakstrue
2926
2927\def\keywordtrue{true}
2928\def\keywordfalse{false}
2929
2930\parseargdef\allowcodebreaks{%
2931 \def\txiarg{#1}%
2932 \ifx\txiarg\keywordtrue
2933 \allowcodebreakstrue
2934 \else\ifx\txiarg\keywordfalse
2935 \allowcodebreaksfalse
2936 \else
2937 \errhelp = \EMsimple
0f8bbd69 2938 \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}%
9251c568
AJ
2939 \fi\fi
2940}
2941
8fcb833a
JM
2942% For @command, @env, @file, @option quotes seem unnecessary,
2943% so use \code rather than \samp.
2944\let\command=\code
2945\let\env=\code
2946\let\file=\code
2947\let\option=\code
2948
e66a8203
JM
2949% @uref (abbreviation for `urlref') aka @url takes an optional
2950% (comma-separated) second argument specifying the text to display and
2951% an optional third arg as text to display instead of (rather than in
2952% addition to) the url itself. First (mandatory) arg is the url.
714a562f 2953
e66a8203 2954% TeX-only option to allow changing PDF output to show only the second
21fea2e2
JM
2955% arg (if given), and not the url (which is then just the link target).
2956\newif\ifurefurlonlylink
2957
2958% The main macro is \urefbreak, which allows breaking at expected
2959% places within the url. (There used to be another version, which
2960% didn't support automatic breaking.)
0f8bbd69
JM
2961\def\urefbreak{\begingroup \urefcatcodes \dourefbreak}
2962\let\uref=\urefbreak
21fea2e2 2963%
0f8bbd69
JM
2964\def\dourefbreak#1{\urefbreakfinish #1,,,\finish}
2965\def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example
2966 \unsepspaces
2967 \pdfurl{#1}%
2968 \setbox0 = \hbox{\ignorespaces #3}%
2969 \ifdim\wd0 > 0pt
2970 \unhbox0 % third arg given, show only that
2971 \else
21fea2e2 2972 \setbox0 = \hbox{\ignorespaces #2}% look for second arg
0f8bbd69
JM
2973 \ifdim\wd0 > 0pt
2974 \ifpdf
7f7dd1d3 2975 % For pdfTeX and LuaTeX
21fea2e2
JM
2976 \ifurefurlonlylink
2977 % PDF plus option to not display url, show just arg
2978 \unhbox0
2979 \else
2980 % PDF, normally display both arg and url for consistency,
2981 % visibility, if the pdf is eventually used to print, etc.
2982 \unhbox0\ (\urefcode{#1})%
2983 \fi
0f8bbd69 2984 \else
7f7dd1d3
JM
2985 \ifx\XeTeXrevision\thisisundefined
2986 \unhbox0\ (\urefcode{#1})% DVI, always show arg and url
2987 \else
2988 % For XeTeX
2989 \ifurefurlonlylink
2990 % PDF plus option to not display url, show just arg
2991 \unhbox0
2992 \else
2993 % PDF, normally display both arg and url for consistency,
2994 % visibility, if the pdf is eventually used to print, etc.
2995 \unhbox0\ (\urefcode{#1})%
2996 \fi
2997 \fi
0f8bbd69
JM
2998 \fi
2999 \else
3000 \urefcode{#1}% only url given, so show it
3001 \fi
3002 \fi
3003 \endlink
3004\endgroup}
3005
3006% Allow line breaks around only a few characters (only).
3007\def\urefcatcodes{%
084e7d57
JM
3008 \catcode`\&=\active \catcode`\.=\active
3009 \catcode`\#=\active \catcode`\?=\active
3010 \catcode`\/=\active
0f8bbd69
JM
3011}
3012{
3013 \urefcatcodes
3014 %
3015 \global\def\urefcode{\begingroup
3016 \setupmarkupstyle{code}%
3017 \urefcatcodes
3018 \let&\urefcodeamp
3019 \let.\urefcodedot
3020 \let#\urefcodehash
3021 \let?\urefcodequest
3022 \let/\urefcodeslash
3023 \codex
3024 }
3025 %
3026 % By default, they are just regular characters.
3027 \global\def&{\normalamp}
3028 \global\def.{\normaldot}
3029 \global\def#{\normalhash}
3030 \global\def?{\normalquest}
3031 \global\def/{\normalslash}
3032}
3033
3034% we put a little stretch before and after the breakable chars, to help
3035% line breaking of long url's. The unequal skips make look better in
3036% cmtt at least, especially for dots.
e66a8203
JM
3037\def\urefprestretchamount{.13em}
3038\def\urefpoststretchamount{.1em}
3039\def\urefprestretch{\urefprebreak \hskip0pt plus\urefprestretchamount\relax}
3040\def\urefpoststretch{\urefpostbreak \hskip0pt plus\urefprestretchamount\relax}
0f8bbd69
JM
3041%
3042\def\urefcodeamp{\urefprestretch \&\urefpoststretch}
3043\def\urefcodedot{\urefprestretch .\urefpoststretch}
3044\def\urefcodehash{\urefprestretch \#\urefpoststretch}
3045\def\urefcodequest{\urefprestretch ?\urefpoststretch}
3046\def\urefcodeslash{\futurelet\next\urefcodeslashfinish}
3047{
3048 \catcode`\/=\active
3049 \global\def\urefcodeslashfinish{%
3050 \urefprestretch \slashChar
3051 % Allow line break only after the final / in a sequence of
3052 % slashes, to avoid line break between the slashes in http://.
3053 \ifx\next/\else \urefpoststretch \fi
3054 }
3055}
3056
3057% One more complication: by default we'll break after the special
3058% characters, but some people like to break before the special chars, so
3059% allow that. Also allow no breaking at all, for manual control.
3060%
3061\parseargdef\urefbreakstyle{%
3062 \def\txiarg{#1}%
3063 \ifx\txiarg\wordnone
3064 \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak}
3065 \else\ifx\txiarg\wordbefore
3066 \def\urefprebreak{\allowbreak}\def\urefpostbreak{\nobreak}
3067 \else\ifx\txiarg\wordafter
3068 \def\urefprebreak{\nobreak}\def\urefpostbreak{\allowbreak}
3069 \else
3070 \errhelp = \EMsimple
3071 \errmessage{Unknown @urefbreakstyle setting `\txiarg'}%
3072 \fi\fi\fi
3073}
3074\def\wordafter{after}
3075\def\wordbefore{before}
3076\def\wordnone{none}
3077
3078\urefbreakstyle after
3079
82d5ce1d
UD
3080% @url synonym for @uref, since that's how everyone uses it.
3081%
3082\let\url=\uref
3083
13632cfc
UD
3084% rms does not like angle brackets --karl, 17may97.
3085% So now @email is just like @uref, unless we are pdf.
7158eae4 3086%
2eb45444 3087%\def\email#1{\angleleft{\tt #1}\angleright}
13632cfc
UD
3088\ifpdf
3089 \def\email#1{\doemail#1,,\finish}
3b82ab1c
UD
3090 \def\doemail#1,#2,#3\finish{\begingroup
3091 \unsepspaces
3092 \pdfurl{mailto:#1}%
13632cfc
UD
3093 \setbox0 = \hbox{\ignorespaces #2}%
3094 \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
3b82ab1c
UD
3095 \endlink
3096 \endgroup}
13632cfc 3097\else
7f7dd1d3
JM
3098 \ifx\XeTeXrevision\thisisundefined
3099 \let\email=\uref
3100 \else
3101 \def\email#1{\doemail#1,,\finish}
3102 \def\doemail#1,#2,#3\finish{\begingroup
3103 \unsepspaces
3104 \pdfurl{mailto:#1}%
3105 \setbox0 = \hbox{\ignorespaces #2}%
3106 \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
3107 \endlink
3108 \endgroup}
3109 \fi
13632cfc 3110\fi
3996f34b 3111
0f8bbd69
JM
3112% @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
3113% `example' (@kbd uses ttsl only inside of @example and friends),
3114% or `code' (@kbd uses normal tty font always).
3115\parseargdef\kbdinputstyle{%
3116 \def\txiarg{#1}%
3117 \ifx\txiarg\worddistinct
3118 \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
3119 \else\ifx\txiarg\wordexample
3120 \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
3121 \else\ifx\txiarg\wordcode
3122 \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
3123 \else
3124 \errhelp = \EMsimple
3125 \errmessage{Unknown @kbdinputstyle setting `\txiarg'}%
3126 \fi\fi\fi
3127}
3128\def\worddistinct{distinct}
3129\def\wordexample{example}
3130\def\wordcode{code}
3131
3132% Default is `distinct'.
3133\kbdinputstyle distinct
3134
8fcb833a
JM
3135% @kbd is like @code, except that if the argument is just one @key command,
3136% then @kbd has no effect.
3137\def\kbd#1{{\def\look{#1}\expandafter\kbdsub\look??\par}}
3138
0f8bbd69 3139\def\xkey{\key}
8fcb833a
JM
3140\def\kbdsub#1#2#3\par{%
3141 \def\one{#1}\def\three{#3}\def\threex{??}%
3142 \ifx\one\xkey\ifx\threex\three \key{#2}%
3143 \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
3144 \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
3145}
0f8bbd69 3146
8fcb833a
JM
3147% definition of @key that produces a lozenge. Doesn't adjust to text size.
3148%\setfont\keyrm\rmshape{8}{1000}{OT1}
3149%\font\keysy=cmsy9
3150%\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
3151% \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
3152% \vbox{\hrule\kern-0.4pt
3153% \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
3154% \kern-0.4pt\hrule}%
3155% \kern-.06em\raise0.4pt\hbox{\angleright}}}}
3156
3157% definition of @key with no lozenge. If the current font is already
3158% monospace, don't change it; that way, we respect @kbdinputstyle. But
3159% if it isn't monospace, then use \tt.
3160%
3161\def\key#1{{\setupmarkupstyle{key}%
3162 \nohyphenation
3163 \ifmonospace\else\tt\fi
3164 #1}\null}
0f8bbd69
JM
3165
3166% @clicksequence{File @click{} Open ...}
3167\def\clicksequence#1{\begingroup #1\endgroup}
3168
3169% @clickstyle @arrow (by default)
3170\parseargdef\clickstyle{\def\click{#1}}
3171\def\click{\arrow}
3172
3173% Typeset a dimension, e.g., `in' or `pt'. The only reason for the
3174% argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
10dc2a90 3175%
0f8bbd69
JM
3176\def\dmn#1{\thinspace #1}
3177
0f8bbd69
JM
3178% @acronym for "FBI", "NATO", and the like.
3179% We print this one point size smaller, since it's intended for
3180% all-uppercase.
3181%
3182\def\acronym#1{\doacronym #1,,\finish}
3183\def\doacronym#1,#2,#3\finish{%
7f7dd1d3 3184 {\switchtolsize #1}%
0f8bbd69
JM
3185 \def\temp{#2}%
3186 \ifx\temp\empty \else
3187 \space ({\unsepspaces \ignorespaces \temp \unskip})%
3188 \fi
3189 \null % reset \spacefactor=1000
3190}
3191
3192% @abbr for "Comput. J." and the like.
3193% No font change, but don't do end-of-sentence spacing.
3194%
3195\def\abbr#1{\doabbr #1,,\finish}
3196\def\doabbr#1,#2,#3\finish{%
3197 {\plainfrenchspacing #1}%
3198 \def\temp{#2}%
3199 \ifx\temp\empty \else
3200 \space ({\unsepspaces \ignorespaces \temp \unskip})%
3201 \fi
3202 \null % reset \spacefactor=1000
3203}
3204
3205% @asis just yields its argument. Used with @table, for example.
3206%
3207\def\asis#1{#1}
3208
3209% @math outputs its argument in math mode.
3210%
3211% One complication: _ usually means subscripts, but it could also mean
3212% an actual _ character, as in @math{@var{some_variable} + 1}. So make
3213% _ active, and distinguish by seeing if the current family is \slfam,
3214% which is what @var uses.
3215{
3216 \catcode`\_ = \active
3217 \gdef\mathunderscore{%
3218 \catcode`\_=\active
3219 \def_{\ifnum\fam=\slfam \_\else\sb\fi}%
3220 }
3221}
3222% Another complication: we want \\ (and @\) to output a math (or tt) \.
3223% FYI, plain.tex uses \\ as a temporary control sequence (for no
3224% particular reason), but this is not advertised and we don't care.
3225%
3226% The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\.
3227\def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi}
3228%
3229\def\math{%
084e7d57
JM
3230 \ifmmode\else % only go into math if not in math mode already
3231 \tex
3232 \mathunderscore
3233 \let\\ = \mathbackslash
3234 \mathactive
3235 % make the texinfo accent commands work in math mode
3236 \let\"=\ddot
3237 \let\'=\acute
3238 \let\==\bar
3239 \let\^=\hat
3240 \let\`=\grave
3241 \let\u=\breve
3242 \let\v=\check
3243 \let\~=\tilde
3244 \let\dotaccent=\dot
3245 % have to provide another name for sup operator
3246 \let\mathopsup=\sup
3247 $\expandafter\finishmath\fi
0f8bbd69
JM
3248}
3249\def\finishmath#1{#1$\endgroup} % Close the group opened by \tex.
3250
3251% Some active characters (such as <) are spaced differently in math.
3252% We have to reset their definitions in case the @math was an argument
3253% to a command which sets the catcodes (such as @item or @section).
3254%
3255{
3256 \catcode`^ = \active
3257 \catcode`< = \active
3258 \catcode`> = \active
3259 \catcode`+ = \active
3260 \catcode`' = \active
3261 \gdef\mathactive{%
3262 \let^ = \ptexhat
3263 \let< = \ptexless
3264 \let> = \ptexgtr
3265 \let+ = \ptexplus
3266 \let' = \ptexquoteright
3267 }
3268}
3269
084e7d57
JM
3270% for @sub and @sup, if in math mode, just do a normal sub/superscript.
3271% If in text, use math to place as sub/superscript, but switch
3272% into text mode, with smaller fonts. This is a different font than the
3273% one used for real math sub/superscripts (8pt vs. 7pt), but let's not
3274% fix it (significant additions to font machinery) until someone notices.
3275%
3276\def\sub{\ifmmode \expandafter\sb \else \expandafter\finishsub\fi}
7f7dd1d3 3277\def\finishsub#1{$\sb{\hbox{\switchtolllsize #1}}$}%
084e7d57
JM
3278%
3279\def\sup{\ifmmode \expandafter\ptexsp \else \expandafter\finishsup\fi}
7f7dd1d3 3280\def\finishsup#1{$\ptexsp{\hbox{\switchtolllsize #1}}$}%
8fcb833a 3281
0f8bbd69
JM
3282% @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}.
3283% Ignore unless FMTNAME == tex; then it is like @iftex and @tex,
3284% except specified as a normal braced arg, so no newlines to worry about.
3285%
3286\def\outfmtnametex{tex}
3287%
3288\long\def\inlinefmt#1{\doinlinefmt #1,\finish}
3289\long\def\doinlinefmt#1,#2,\finish{%
3290 \def\inlinefmtname{#1}%
3291 \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi
3292}
21fea2e2
JM
3293%
3294% @inlinefmtifelse{FMTNAME,THEN-TEXT,ELSE-TEXT} expands THEN-TEXT if
3295% FMTNAME is tex, else ELSE-TEXT.
3296\long\def\inlinefmtifelse#1{\doinlinefmtifelse #1,,,\finish}
3297\long\def\doinlinefmtifelse#1,#2,#3,#4,\finish{%
3298 \def\inlinefmtname{#1}%
3299 \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\else \ignorespaces #3\fi
3300}
3301%
0f8bbd69
JM
3302% For raw, must switch into @tex before parsing the argument, to avoid
3303% setting catcodes prematurely. Doing it this way means that, for
3304% example, @inlineraw{html, foo{bar} gets a parse error instead of being
3305% ignored. But this isn't important because if people want a literal
3306% *right* brace they would have to use a command anyway, so they may as
3307% well use a command to get a left brace too. We could re-use the
3308% delimiter character idea from \verb, but it seems like overkill.
3309%
3310\long\def\inlineraw{\tex \doinlineraw}
3311\long\def\doinlineraw#1{\doinlinerawtwo #1,\finish}
3312\def\doinlinerawtwo#1,#2,\finish{%
3313 \def\inlinerawname{#1}%
3314 \ifx\inlinerawname\outfmtnametex \ignorespaces #2\fi
3315 \endgroup % close group opened by \tex.
3316}
3317
21fea2e2
JM
3318% @inlineifset{VAR, TEXT} expands TEXT if VAR is @set.
3319%
3320\long\def\inlineifset#1{\doinlineifset #1,\finish}
3321\long\def\doinlineifset#1,#2,\finish{%
3322 \def\inlinevarname{#1}%
3323 \expandafter\ifx\csname SET\inlinevarname\endcsname\relax
3324 \else\ignorespaces#2\fi
3325}
3326
3327% @inlineifclear{VAR, TEXT} expands TEXT if VAR is not @set.
3328%
3329\long\def\inlineifclear#1{\doinlineifclear #1,\finish}
3330\long\def\doinlineifclear#1,#2,\finish{%
3331 \def\inlinevarname{#1}%
3332 \expandafter\ifx\csname SET\inlinevarname\endcsname\relax \ignorespaces#2\fi
3333}
3334
0f8bbd69
JM
3335
3336\message{glyphs,}
3337% and logos.
3338
3339% @@ prints an @, as does @atchar{}.
3340\def\@{\char64 }
3341\let\atchar=\@
3342
3343% @{ @} @lbracechar{} @rbracechar{} all generate brace characters.
7f7dd1d3
JM
3344\def\lbracechar{{\ifmonospace\char123\else\ensuremath\lbrace\fi}}
3345\def\rbracechar{{\ifmonospace\char125\else\ensuremath\rbrace\fi}}
3346\let\{=\lbracechar
3347\let\}=\rbracechar
0f8bbd69
JM
3348
3349% @comma{} to avoid , parsing problems.
3350\let\comma = ,
3351
3352% Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
3353% Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H.
3354\let\, = \ptexc
3355\let\dotaccent = \ptexdot
3356\def\ringaccent#1{{\accent23 #1}}
3357\let\tieaccent = \ptext
3358\let\ubaraccent = \ptexb
3359\let\udotaccent = \d
3360
3361% Other special characters: @questiondown @exclamdown @ordf @ordm
3362% Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss.
3363\def\questiondown{?`}
3364\def\exclamdown{!`}
7f7dd1d3
JM
3365\def\ordf{\leavevmode\raise1ex\hbox{\switchtolllsize \underbar{a}}}
3366\def\ordm{\leavevmode\raise1ex\hbox{\switchtolllsize \underbar{o}}}
0f8bbd69
JM
3367
3368% Dotless i and dotless j, used for accents.
3369\def\imacro{i}
3370\def\jmacro{j}
3371\def\dotless#1{%
3372 \def\temp{#1}%
3373 \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi
3374 \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi
3375 \else \errmessage{@dotless can be used only with i or j}%
3376 \fi\fi
3377}
9e9f9cc2 3378
0f8bbd69
JM
3379% The \TeX{} logo, as in plain, but resetting the spacing so that a
3380% period following counts as ending a sentence. (Idea found in latex.)
9e9f9cc2 3381%
0f8bbd69 3382\edef\TeX{\TeX \spacefactor=1000 }
9e9f9cc2 3383
0f8bbd69
JM
3384% @LaTeX{} logo. Not quite the same results as the definition in
3385% latex.ltx, since we use a different font for the raised A; it's most
3386% convenient for us to use an explicitly smaller font, rather than using
3387% the \scriptstyle font (since we don't reset \scriptstyle and
3388% \scriptscriptstyle).
3389%
3390\def\LaTeX{%
3391 L\kern-.36em
3392 {\setbox0=\hbox{T}%
3393 \vbox to \ht0{\hbox{%
3394 \ifx\textnominalsize\xwordpt
7f7dd1d3 3395 % for 10pt running text, lllsize (8pt) is too small for the A in LaTeX.
0f8bbd69
JM
3396 % Revert to plain's \scriptsize, which is 7pt.
3397 \count255=\the\fam $\fam\count255 \scriptstyle A$%
3398 \else
3399 % For 11pt, we can use our lllsize.
7f7dd1d3 3400 \switchtolllsize A%
0f8bbd69
JM
3401 \fi
3402 }%
3403 \vss
3404 }}%
3405 \kern-.15em
3406 \TeX
3407}
9e9f9cc2 3408
084e7d57
JM
3409% Some math mode symbols. Define \ensuremath to switch into math mode
3410% unless we are already there. Expansion tricks may not be needed here,
3411% but safer, and can't hurt.
3412\def\ensuremath{\ifmmode \expandafter\asis \else\expandafter\ensuredmath \fi}
3413\def\ensuredmath#1{$\relax#1$}
3414%
3415\def\bullet{\ensuremath\ptexbullet}
3416\def\geq{\ensuremath\ge}
3417\def\leq{\ensuremath\le}
3418\def\minus{\ensuremath-}
9e9f9cc2 3419
0f8bbd69
JM
3420% @dots{} outputs an ellipsis using the current font.
3421% We do .5em per period so that it has the same spacing in the cm
3422% typewriter fonts as three actual period characters; on the other hand,
3423% in other typewriter fonts three periods are wider than 1.5em. So do
3424% whichever is larger.
3425%
3426\def\dots{%
3427 \leavevmode
3428 \setbox0=\hbox{...}% get width of three periods
3429 \ifdim\wd0 > 1.5em
3430 \dimen0 = \wd0
3431 \else
3432 \dimen0 = 1.5em
82d5ce1d 3433 \fi
0f8bbd69
JM
3434 \hbox to \dimen0{%
3435 \hskip 0pt plus.25fil
3436 .\hskip 0pt plus1fil
3437 .\hskip 0pt plus1fil
3438 .\hskip 0pt plus.5fil
3439 }%
82d5ce1d 3440}
0ecb606c 3441
0f8bbd69
JM
3442% @enddots{} is an end-of-sentence ellipsis.
3443%
3444\def\enddots{%
3445 \dots
3446 \spacefactor=\endofsentencespacefactor
82d5ce1d
UD
3447}
3448
0f8bbd69
JM
3449% @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
3450%
3451% Since these characters are used in examples, they should be an even number of
3452% \tt widths. Each \tt character is 1en, so two makes it 1em.
3453%
3454\def\point{$\star$}
3455\def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}}
3456\def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
3457\def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}}
3458\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
3459\def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}}
3460
3461% The @error{} command.
3462% Adapted from the TeXbook's \boxit.
3463%
3464\newbox\errorbox
3465%
7f7dd1d3 3466{\ttfont \global\dimen0 = 3em}% Width of the box.
0f8bbd69
JM
3467\dimen2 = .55pt % Thickness of rules
3468% The text. (`r' is open on the right, `e' somewhat less so on the left.)
3469\setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt}
3470%
3471\setbox\errorbox=\hbox to \dimen0{\hfil
3472 \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
3473 \advance\hsize by -2\dimen2 % Rules.
3474 \vbox{%
3475 \hrule height\dimen2
3476 \hbox{\vrule width\dimen2 \kern3pt % Space to left of text.
3477 \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
3478 \kern3pt\vrule width\dimen2}% Space to right.
3479 \hrule height\dimen2}
3480 \hfil}
3481%
3482\def\error{\leavevmode\lower.7ex\copy\errorbox}
3483
82d5ce1d
UD
3484% @pounds{} is a sterling sign, which Knuth put in the CM italic font.
3485%
3486\def\pounds{{\it\$}}
3487
3488% @euro{} comes from a separate font, depending on the current style.
3489% We use the free feym* fonts from the eurosym package by Henrik
3490% Theiling, which support regular, slanted, bold and bold slanted (and
3491% "outlined" (blackboard board, sort of) versions, which we don't need).
3492% It is available from http://www.ctan.org/tex-archive/fonts/eurosym.
0f8bbd69 3493%
82d5ce1d
UD
3494% Although only regular is the truly official Euro symbol, we ignore
3495% that. The Euro is designed to be slightly taller than the regular
3496% font height.
0f8bbd69 3497%
82d5ce1d
UD
3498% feymr - regular
3499% feymo - slanted
3500% feybr - bold
3501% feybo - bold slanted
0f8bbd69 3502%
82d5ce1d
UD
3503% There is no good (free) typewriter version, to my knowledge.
3504% A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide.
3505% Hmm.
0f8bbd69 3506%
82d5ce1d
UD
3507% Also doesn't work in math. Do we need to do math with euro symbols?
3508% Hope not.
0f8bbd69
JM
3509%
3510%
82d5ce1d
UD
3511\def\euro{{\eurofont e}}
3512\def\eurofont{%
3513 % We set the font at each command, rather than predefining it in
3514 % \textfonts and the other font-switching commands, so that
9251c568 3515 % installations which never need the symbol don't have to have the
82d5ce1d 3516 % font installed.
0f8bbd69 3517 %
82d5ce1d
UD
3518 % There is only one designed size (nominal 10pt), so we always scale
3519 % that to the current nominal size.
0f8bbd69 3520 %
82d5ce1d
UD
3521 % By the way, simply using "at 1em" works for cmr10 and the like, but
3522 % does not work for cmbx10 and other extended/shrunken fonts.
0f8bbd69 3523 %
82d5ce1d
UD
3524 \def\eurosize{\csname\curfontsize nominalsize\endcsname}%
3525 %
0f8bbd69 3526 \ifx\curfontstyle\bfstylename
82d5ce1d
UD
3527 % bold:
3528 \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize
0f8bbd69 3529 \else
82d5ce1d
UD
3530 % regular:
3531 \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize
3532 \fi
3533 \thiseurofont
3534}
3535
0f8bbd69
JM
3536% Glyphs from the EC fonts. We don't use \let for the aliases, because
3537% sometimes we redefine the original macro, and the alias should reflect
3538% the redefinition.
3539%
3540% Use LaTeX names for the Icelandic letters.
3541\def\DH{{\ecfont \char"D0}} % Eth
3542\def\dh{{\ecfont \char"F0}} % eth
3543\def\TH{{\ecfont \char"DE}} % Thorn
3544\def\th{{\ecfont \char"FE}} % thorn
3545%
c94f48d7
AJ
3546\def\guillemetleft{{\ecfont \char"13}}
3547\def\guillemotleft{\guillemetleft}
3548\def\guillemetright{{\ecfont \char"14}}
3549\def\guillemotright{\guillemetright}
3550\def\guilsinglleft{{\ecfont \char"0E}}
3551\def\guilsinglright{{\ecfont \char"0F}}
3552\def\quotedblbase{{\ecfont \char"12}}
3553\def\quotesinglbase{{\ecfont \char"0D}}
3554%
0f8bbd69
JM
3555% This positioning is not perfect (see the ogonek LaTeX package), but
3556% we have the precomposed glyphs for the most common cases. We put the
3557% tests to use those glyphs in the single \ogonek macro so we have fewer
3558% dummy definitions to worry about for index entries, etc.
3559%
3560% ogonek is also used with other letters in Lithuanian (IOU), but using
3561% the precomposed glyphs for those is not so easy since they aren't in
3562% the same EC font.
3563\def\ogonek#1{{%
3564 \def\temp{#1}%
3565 \ifx\temp\macrocharA\Aogonek
3566 \else\ifx\temp\macrochara\aogonek
3567 \else\ifx\temp\macrocharE\Eogonek
3568 \else\ifx\temp\macrochare\eogonek
3569 \else
3570 \ecfont \setbox0=\hbox{#1}%
3571 \ifdim\ht0=1ex\accent"0C #1%
3572 \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}%
3573 \fi
3574 \fi\fi\fi\fi
3575 }%
3576}
3577\def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A}
3578\def\aogonek{{\ecfont \char"A1}}\def\macrochara{a}
3579\def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E}
3580\def\eogonek{{\ecfont \char"A6}}\def\macrochare{e}
3581%
084e7d57
JM
3582% Use the European Computer Modern fonts (cm-super in outline format)
3583% for non-CM glyphs. That is ec* for regular text and tc* for the text
3584% companion symbols (LaTeX TS1 encoding). Both are part of the ec
3585% package and follow the same conventions.
3586%
3587\def\ecfont{\etcfont{e}}
3588\def\tcfont{\etcfont{t}}
3589%
3590\def\etcfont#1{%
0f8bbd69 3591 % We can't distinguish serif/sans and italic/slanted, but this
c94f48d7
AJ
3592 % is used for crude hacks anyway (like adding French and German
3593 % quotes to documents typeset with CM, where we lose kerning), so
3594 % hopefully nobody will notice/care.
3595 \edef\ecsize{\csname\curfontsize ecsize\endcsname}%
3596 \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}%
8fcb833a
JM
3597 \ifmonospace
3598 % typewriter:
084e7d57 3599 \font\thisecfont = #1ctt\ecsize \space at \nominalsize
c94f48d7 3600 \else
8fcb833a
JM
3601 \ifx\curfontstyle\bfstylename
3602 % bold:
084e7d57 3603 \font\thisecfont = #1cb\ifusingit{i}{x}\ecsize \space at \nominalsize
8fcb833a
JM
3604 \else
3605 % regular:
084e7d57 3606 \font\thisecfont = #1c\ifusingit{ti}{rm}\ecsize \space at \nominalsize
8fcb833a 3607 \fi
c94f48d7
AJ
3608 \fi
3609 \thisecfont
3610}
3611
82d5ce1d
UD
3612% @registeredsymbol - R in a circle. The font for the R should really
3613% be smaller yet, but lllsize is the best we can do for now.
7158eae4
UD
3614% Adapted from the plain.tex definition of \copyright.
3615%
3616\def\registeredsymbol{%
7f7dd1d3 3617 $^{{\ooalign{\hfil\raise.07ex\hbox{\switchtolllsize R}%
82d5ce1d 3618 \hfil\crcr\Orb}}%
7158eae4
UD
3619 }$%
3620}
3621
9251c568
AJ
3622% @textdegree - the normal degrees sign.
3623%
3624\def\textdegree{$^\circ$}
3625
82d5ce1d
UD
3626% Laurent Siebenmann reports \Orb undefined with:
3627% Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38
3628% so we'll define it if necessary.
0f8bbd69
JM
3629%
3630\ifx\Orb\thisisundefined
82d5ce1d
UD
3631\def\Orb{\mathhexbox20D}
3632\fi
3633
c94f48d7
AJ
3634% Quotes.
3635\chardef\quotedblleft="5C
3636\chardef\quotedblright=`\"
3637\chardef\quoteleft=`\`
3638\chardef\quoteright=`\'
474be527 3639
0f8bbd69 3640
9e9f9cc2
KB
3641\message{page headings,}
3642
3643\newskip\titlepagetopglue \titlepagetopglue = 1.5in
3644\newskip\titlepagebottomglue \titlepagebottomglue = 2pc
3645
3646% First the title page. Must do @settitle before @titlepage.
9e9f9cc2
KB
3647\newif\ifseenauthor
3648\newif\iffinishedtitlepage
3649
7f7dd1d3
JM
3650% @setcontentsaftertitlepage used to do an implicit @contents or
3651% @shortcontents after @end titlepage, but it is now obsolete.
3652\def\setcontentsaftertitlepage{%
3653 \errmessage{@setcontentsaftertitlepage has been removed as a Texinfo
3654 command; move your @contents command if you want the contents
3655 after the title page.}}%
3656\def\setshortcontentsaftertitlepage{%
3657 \errmessage{@setshortcontentsaftertitlepage has been removed as a Texinfo
3658 command; move your @shortcontents and @contents commands if you
3659 want the contents after the title page.}}%
313a1174 3660
0f8bbd69
JM
3661\parseargdef\shorttitlepage{%
3662 \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}%
3663 \endgroup\page\hbox{}\page}
9e9f9cc2 3664
82d5ce1d
UD
3665\envdef\titlepage{%
3666 % Open one extra group, as we want to close it in the middle of \Etitlepage.
3667 \begingroup
3668 \parindent=0pt \textfonts
3669 % Leave some space at the very top of the page.
3670 \vglue\titlepagetopglue
3671 % No rule at page bottom unless we print one at the top with @title.
3672 \finishedtitlepagetrue
3673 %
3674 % Most title ``pages'' are actually two pages long, with space
3675 % at the top of the second. We don't want the ragged left on the second.
3676 \let\oldpage = \page
3677 \def\page{%
9e9f9cc2 3678 \iffinishedtitlepage\else
82d5ce1d 3679 \finishtitlepage
9e9f9cc2 3680 \fi
9e9f9cc2 3681 \let\page = \oldpage
82d5ce1d
UD
3682 \page
3683 \null
3684 }%
9e9f9cc2
KB
3685}
3686
3687\def\Etitlepage{%
82d5ce1d
UD
3688 \iffinishedtitlepage\else
3689 \finishtitlepage
3690 \fi
3691 % It is important to do the page break before ending the group,
3692 % because the headline and footline are only empty inside the group.
3693 % If we use the new definition of \page, we always get a blank page
3694 % after the title page, which we certainly don't want.
3695 \oldpage
3696 \endgroup
3697 %
3698 % Need this before the \...aftertitlepage checks so that if they are
3699 % in effect the toc pages will come out with page numbers.
3700 \HEADINGSon
9e9f9cc2
KB
3701}
3702
3703\def\finishtitlepage{%
82d5ce1d
UD
3704 \vskip4pt \hrule height 2pt width \hsize
3705 \vskip\titlepagebottomglue
3706 \finishedtitlepagetrue
0ecb606c
JJ
3707}
3708
8fcb833a
JM
3709% Settings used for typesetting titles: no hyphenation, no indentation,
3710% don't worry much about spacing, ragged right. This should be used
7f7dd1d3
JM
3711% inside a \vbox, and fonts need to be set appropriately first. \par should
3712% be specified before the end of the \vbox, since a vbox is a group.
8fcb833a
JM
3713%
3714\def\raggedtitlesettings{%
7f7dd1d3 3715 \rm
8fcb833a
JM
3716 \hyphenpenalty=10000
3717 \parindent=0pt
3718 \tolerance=5000
3719 \ptexraggedright
3720}
3721
0f8bbd69 3722% Macros to be used within @titlepage:
82d5ce1d 3723
7f7dd1d3 3724\let\subtitlerm=\rmfont
82d5ce1d
UD
3725\def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}
3726
82d5ce1d
UD
3727\parseargdef\title{%
3728 \checkenv\titlepage
8fcb833a 3729 \vbox{\titlefonts \raggedtitlesettings #1\par}%
82d5ce1d
UD
3730 % print a rule at the page bottom also.
3731 \finishedtitlepagefalse
3732 \vskip4pt \hrule height 4pt width \hsize \vskip4pt
3733}
3734
3735\parseargdef\subtitle{%
3736 \checkenv\titlepage
3737 {\subtitlefont \rightline{#1}}%
3738}
3739
3740% @author should come last, but may come many times.
3741% It can also be used inside @quotation.
3742%
3743\parseargdef\author{%
3744 \def\temp{\quotation}%
3745 \ifx\thisenv\temp
3746 \def\quotationauthor{#1}% printed in \Equotation.
3747 \else
3748 \checkenv\titlepage
3749 \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi
7f7dd1d3 3750 {\secfonts\rm \leftline{#1}}%
82d5ce1d
UD
3751 \fi
3752}
3753
3754
0f8bbd69 3755% Set up page headings and footings.
9e9f9cc2
KB
3756
3757\let\thispage=\folio
3758
313a1174
UD
3759\newtoks\evenheadline % headline on even pages
3760\newtoks\oddheadline % headline on odd pages
3761\newtoks\evenfootline % footline on even pages
3762\newtoks\oddfootline % footline on odd pages
9e9f9cc2 3763
084e7d57 3764% Now make \makeheadline and \makefootline in Plain TeX use those variables
9e9f9cc2
KB
3765\headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
3766 \else \the\evenheadline \fi}}
3767\footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
3768 \else \the\evenfootline \fi}\HEADINGShook}
3769\let\HEADINGShook=\relax
3770
3771% Commands to set those variables.
3772% For example, this is what @headings on does
3773% @evenheading @thistitle|@thispage|@thischapter
3774% @oddheading @thischapter|@thispage|@thistitle
3775% @evenfooting @thisfile||
3776% @oddfooting ||@thisfile
3777
a334319f 3778
82d5ce1d
UD
3779\def\evenheading{\parsearg\evenheadingxxx}
3780\def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish}
3781\def\evenheadingyyy #1\|#2\|#3\|#4\finish{%
9e9f9cc2
KB
3782\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3783
82d5ce1d
UD
3784\def\oddheading{\parsearg\oddheadingxxx}
3785\def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish}
3786\def\oddheadingyyy #1\|#2\|#3\|#4\finish{%
9e9f9cc2
KB
3787\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3788
82d5ce1d 3789\parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
9e9f9cc2 3790
82d5ce1d
UD
3791\def\evenfooting{\parsearg\evenfootingxxx}
3792\def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish}
3793\def\evenfootingyyy #1\|#2\|#3\|#4\finish{%
9e9f9cc2
KB
3794\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3795
82d5ce1d
UD
3796\def\oddfooting{\parsearg\oddfootingxxx}
3797\def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish}
3798\def\oddfootingyyy #1\|#2\|#3\|#4\finish{%
d705269e
UD
3799 \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}%
3800 %
3801 % Leave some space for the footline. Hopefully ok to assume
3802 % @evenfooting will not be used by itself.
7f7dd1d3 3803 \global\advance\txipageheight by -12pt
9251c568 3804 \global\advance\vsize by -12pt
d705269e 3805}
9e9f9cc2 3806
82d5ce1d
UD
3807\parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}}
3808
c94f48d7
AJ
3809% @evenheadingmarks top \thischapter <- chapter at the top of a page
3810% @evenheadingmarks bottom \thischapter <- chapter at the bottom of a page
3811%
3812% The same set of arguments for:
3813%
3814% @oddheadingmarks
3815% @evenfootingmarks
3816% @oddfootingmarks
3817% @everyheadingmarks
3818% @everyfootingmarks
3819
084e7d57
JM
3820% These define \getoddheadingmarks, \getevenheadingmarks,
3821% \getoddfootingmarks, and \getevenfootingmarks, each to one of
3822% \gettopheadingmarks, \getbottomheadingmarks.
3823%
c94f48d7
AJ
3824\def\evenheadingmarks{\headingmarks{even}{heading}}
3825\def\oddheadingmarks{\headingmarks{odd}{heading}}
3826\def\evenfootingmarks{\headingmarks{even}{footing}}
3827\def\oddfootingmarks{\headingmarks{odd}{footing}}
7f7dd1d3 3828\parseargdef\everyheadingmarks{\headingmarks{even}{heading}{#1}
c94f48d7 3829 \headingmarks{odd}{heading}{#1} }
7f7dd1d3 3830\parseargdef\everyfootingmarks{\headingmarks{even}{footing}{#1}
c94f48d7
AJ
3831 \headingmarks{odd}{footing}{#1} }
3832% #1 = even/odd, #2 = heading/footing, #3 = top/bottom.
3833\def\headingmarks#1#2#3 {%
3834 \expandafter\let\expandafter\temp \csname get#3headingmarks\endcsname
3835 \global\expandafter\let\csname get#1#2marks\endcsname \temp
3836}
3837
3838\everyheadingmarks bottom
3839\everyfootingmarks bottom
9e9f9cc2 3840
2d07133b
KB
3841% @headings double turns headings on for double-sided printing.
3842% @headings single turns headings on for single-sided printing.
3843% @headings off turns them off.
3844% @headings on same as @headings double, retained for compatibility.
3845% @headings after turns on double-sided headings after this page.
3846% @headings doubleafter turns on double-sided headings after this page.
9e9f9cc2 3847% @headings singleafter turns on single-sided headings after this page.
793fde8a
KB
3848% By default, they are off at the start of a document,
3849% and turned `on' after @end titlepage.
9e9f9cc2 3850
7f7dd1d3 3851\parseargdef\headings{\csname HEADINGS#1\endcsname}
9e9f9cc2 3852
0f8bbd69
JM
3853\def\headingsoff{% non-global headings elimination
3854 \evenheadline={\hfil}\evenfootline={\hfil}%
3855 \oddheadline={\hfil}\oddfootline={\hfil}%
3856}
3857
3858\def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting
3859\HEADINGSoff % it's the default
3860
9e9f9cc2
KB
3861% When we turn headings on, set the page number to 1.
3862% For double-sided printing, put current file name in lower left corner,
3863% chapter name on inside top of right hand pages, document
3864% title on inside top of left hand pages, and page numbers on outside top
3865% edge of all pages.
82d5ce1d 3866\def\HEADINGSdouble{%
9e9f9cc2
KB
3867\global\pageno=1
3868\global\evenfootline={\hfil}
3869\global\oddfootline={\hfil}
3870\global\evenheadline={\line{\folio\hfil\thistitle}}
084e7d57 3871\global\oddheadline={\line{\thischapterheading\hfil\folio}}
793fde8a 3872\global\let\contentsalignmacro = \chapoddpage
9e9f9cc2 3873}
793fde8a
KB
3874\let\contentsalignmacro = \chappager
3875
9e9f9cc2
KB
3876% For single-sided printing, chapter title goes across top left of page,
3877% page number on top right.
82d5ce1d 3878\def\HEADINGSsingle{%
9e9f9cc2
KB
3879\global\pageno=1
3880\global\evenfootline={\hfil}
3881\global\oddfootline={\hfil}
084e7d57
JM
3882\global\evenheadline={\line{\thischapterheading\hfil\folio}}
3883\global\oddheadline={\line{\thischapterheading\hfil\folio}}
793fde8a 3884\global\let\contentsalignmacro = \chappager
9e9f9cc2
KB
3885}
3886\def\HEADINGSon{\HEADINGSdouble}
3887
3888\def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
3889\let\HEADINGSdoubleafter=\HEADINGSafter
3890\def\HEADINGSdoublex{%
3891\global\evenfootline={\hfil}
3892\global\oddfootline={\hfil}
3893\global\evenheadline={\line{\folio\hfil\thistitle}}
084e7d57 3894\global\oddheadline={\line{\thischapterheading\hfil\folio}}
793fde8a 3895\global\let\contentsalignmacro = \chapoddpage
9e9f9cc2
KB
3896}
3897
3898\def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
3899\def\HEADINGSsinglex{%
3900\global\evenfootline={\hfil}
3901\global\oddfootline={\hfil}
084e7d57
JM
3902\global\evenheadline={\line{\thischapterheading\hfil\folio}}
3903\global\oddheadline={\line{\thischapterheading\hfil\folio}}
793fde8a 3904\global\let\contentsalignmacro = \chappager
9e9f9cc2
KB
3905}
3906
3907% Subroutines used in generating headings
3bc88c40
AJ
3908% This produces Day Month Year style of output.
3909% Only define if not already defined, in case a txi-??.tex file has set
3910% up a different format (e.g., txi-cs.tex does this).
0f8bbd69 3911\ifx\today\thisisundefined
b710a6e2
UD
3912\def\today{%
3913 \number\day\space
3914 \ifcase\month
3915 \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr
3916 \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug
3917 \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec
3918 \fi
3919 \space\number\year}
3bc88c40 3920\fi
b710a6e2
UD
3921
3922% @settitle line... specifies the title of the document, for headings.
3923% It generates no output of its own.
3924\def\thistitle{\putwordNoTitle}
82d5ce1d 3925\def\settitle{\parsearg{\gdef\thistitle}}
9e9f9cc2 3926
d66b7b41 3927
9e9f9cc2 3928\message{tables,}
82d5ce1d 3929% Tables -- @table, @ftable, @vtable, @item(x).
9e9f9cc2
KB
3930
3931% default indentation of table text
3932\newdimen\tableindent \tableindent=.8in
3933% default indentation of @itemize and @enumerate text
3934\newdimen\itemindent \itemindent=.3in
3935% margin between end of table item and start of table text.
3936\newdimen\itemmargin \itemmargin=.1in
3937
3938% used internally for \itemindent minus \itemmargin
3939\newdimen\itemmax
3940
82d5ce1d 3941% Note @table, @ftable, and @vtable define @item, @itemx, etc., with
9e9f9cc2
KB
3942% these defs.
3943% They also define \itemindex
3944% to index the item name in whatever manner is desired (perhaps none).
3945
3946\newif\ifitemxneedsnegativevskip
3947
3948\def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
3949
3950\def\internalBitem{\smallbreak \parsearg\itemzzz}
3951\def\internalBitemx{\itemxpar \parsearg\itemzzz}
3952
9e9f9cc2
KB
3953\def\itemzzz #1{\begingroup %
3954 \advance\hsize by -\rightskip
3955 \advance\hsize by -\tableindent
82d5ce1d 3956 \setbox0=\hbox{\itemindicate{#1}}%
9e9f9cc2
KB
3957 \itemindex{#1}%
3958 \nobreak % This prevents a break before @itemx.
3959 %
9e9f9cc2
KB
3960 % If the item text does not fit in the space we have, put it on a line
3961 % by itself, and do not allow a page break either before or after that
3962 % line. We do not start a paragraph here because then if the next
3963 % command is, e.g., @kindex, the whatsit would get put into the
3964 % horizontal list on a line by itself, resulting in extra blank space.
3965 \ifdim \wd0>\itemmax
3966 %
3967 % Make this a paragraph so we get the \parskip glue and wrapping,
3968 % but leave it ragged-right.
3969 \begingroup
3970 \advance\leftskip by-\tableindent
3971 \advance\hsize by\tableindent
0f8bbd69 3972 \advance\rightskip by0pt plus1fil\relax
9e9f9cc2
KB
3973 \leavevmode\unhbox0\par
3974 \endgroup
3975 %
3976 % We're going to be starting a paragraph, but we don't want the
3977 % \parskip glue -- logically it's part of the @item we just started.
3978 \nobreak \vskip-\parskip
3979 %
82d5ce1d
UD
3980 % Stop a page break at the \parskip glue coming up. However, if
3981 % what follows is an environment such as @example, there will be no
3982 % \parskip glue; then the negative vskip we just inserted would
3983 % cause the example and the item to crash together. So we use this
3984 % bizarre value of 10001 as a signal to \aboveenvbreak to insert
3985 % \parskip glue after all. Section titles are handled this way also.
0f8bbd69 3986 %
2f5b1124 3987 \penalty 10001
9e9f9cc2
KB
3988 \endgroup
3989 \itemxneedsnegativevskipfalse
3990 \else
3991 % The item text fits into the space. Start a paragraph, so that the
b710a6e2 3992 % following text (if any) will end up on the same line.
9e9f9cc2 3993 \noindent
61027f30
UD
3994 % Do this with kerns and \unhbox so that if there is a footnote in
3995 % the item text, it can migrate to the main vertical list and
3996 % eventually be printed.
3997 \nobreak\kern-\tableindent
85c165be 3998 \dimen0 = \itemmax \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0
61027f30
UD
3999 \unhbox0
4000 \nobreak\kern\dimen0
4001 \endgroup
4002 \itemxneedsnegativevskiptrue
9e9f9cc2
KB
4003 \fi
4004}
4005
82d5ce1d
UD
4006\def\item{\errmessage{@item while not in a list environment}}
4007\def\itemx{\errmessage{@itemx while not in a list environment}}
9e9f9cc2 4008
61027f30 4009% @table, @ftable, @vtable.
82d5ce1d
UD
4010\envdef\table{%
4011 \let\itemindex\gobble
4012 \tablecheck{table}%
4013}
4014\envdef\ftable{%
4015 \def\itemindex ##1{\doind {fn}{\code{##1}}}%
4016 \tablecheck{ftable}%
4017}
4018\envdef\vtable{%
4019 \def\itemindex ##1{\doind {vr}{\code{##1}}}%
4020 \tablecheck{vtable}%
0ecb606c 4021}
82d5ce1d
UD
4022\def\tablecheck#1{%
4023 \ifnum \the\catcode`\^^M=\active
4024 \endgroup
4025 \errmessage{This command won't work in this context; perhaps the problem is
4026 that we are \inenvironment\thisenv}%
4027 \def\next{\doignore{#1}}%
4028 \else
4029 \let\next\tablex
4030 \fi
4031 \next
4032}
4033\def\tablex#1{%
4034 \def\itemindicate{#1}%
4035 \parsearg\tabley
4036}
4037\def\tabley#1{%
4038 {%
4039 \makevalueexpandable
4040 \edef\temp{\noexpand\tablez #1\space\space\space}%
4041 \expandafter
4042 }\temp \endtablez
4043}
4044\def\tablez #1 #2 #3 #4\endtablez{%
4045 \aboveenvbreak
4046 \ifnum 0#1>0 \advance \leftskip by #1\mil \fi
4047 \ifnum 0#2>0 \tableindent=#2\mil \fi
4048 \ifnum 0#3>0 \advance \rightskip by #3\mil \fi
4049 \itemmax=\tableindent
4050 \advance \itemmax by -\itemmargin
4051 \advance \leftskip by \tableindent
4052 \exdentamount=\tableindent
4053 \parindent = 0pt
4054 \parskip = \smallskipamount
4055 \ifdim \parskip=0pt \parskip=2pt \fi
4056 \let\item = \internalBitem
4057 \let\itemx = \internalBitemx
4058}
4059\def\Etable{\endgraf\afterenvbreak}
4060\let\Eftable\Etable
4061\let\Evtable\Etable
4062\let\Eitemize\Etable
4063\let\Eenumerate\Etable
9e9f9cc2
KB
4064
4065% This is the counter used by @enumerate, which is really @itemize
4066
4067\newcount \itemno
4068
82d5ce1d 4069\envdef\itemize{\parsearg\doitemize}
9e9f9cc2 4070
82d5ce1d 4071\def\doitemize#1{%
7158eae4
UD
4072 \aboveenvbreak
4073 \itemmax=\itemindent
4074 \advance\itemmax by -\itemmargin
4075 \advance\leftskip by \itemindent
4076 \exdentamount=\itemindent
4077 \parindent=0pt
4078 \parskip=\smallskipamount
4079 \ifdim\parskip=0pt \parskip=2pt \fi
0f8bbd69 4080 %
21fea2e2 4081 % Try typesetting the item mark so that if the document erroneously says
0f8bbd69
JM
4082 % something like @itemize @samp (intending @table), there's an error
4083 % right away at the @itemize. It's not the best error message in the
4084 % world, but it's better than leaving it to the @item. This means if
4085 % the user wants an empty mark, they have to say @w{} not just @w.
7158eae4 4086 \def\itemcontents{#1}%
0f8bbd69
JM
4087 \setbox0 = \hbox{\itemcontents}%
4088 %
7158eae4
UD
4089 % @itemize with no arg is equivalent to @itemize @bullet.
4090 \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi
0f8bbd69 4091 %
7158eae4
UD
4092 \let\item=\itemizeitem
4093}
9e9f9cc2 4094
82d5ce1d
UD
4095% Definition of @item while inside @itemize and @enumerate.
4096%
4097\def\itemizeitem{%
4098 \advance\itemno by 1 % for enumerations
4099 {\let\par=\endgraf \smallbreak}% reasonable place to break
4100 {%
4101 % If the document has an @itemize directly after a section title, a
4102 % \nobreak will be last on the list, and \sectionheading will have
4103 % done a \vskip-\parskip. In that case, we don't want to zero
4104 % parskip, or the item text will crash with the heading. On the
4105 % other hand, when there is normal text preceding the item (as there
4106 % usually is), we do want to zero parskip, or there would be too much
4107 % space. In that case, we won't have a \nobreak before. At least
4108 % that's the theory.
4109 \ifnum\lastpenalty<10000 \parskip=0in \fi
4110 \noindent
4111 \hbox to 0pt{\hss \itemcontents \kern\itemmargin}%
0f8bbd69 4112 %
084e7d57
JM
4113 \ifinner\else
4114 \vadjust{\penalty 1200}% not good to break after first line of item.
4115 \fi
4116 % We can be in inner vertical mode in a footnote, although an
4117 % @itemize looks awful there.
4118 }%
82d5ce1d
UD
4119 \flushcr
4120}
4121
9e9f9cc2
KB
4122% \splitoff TOKENS\endmark defines \first to be the first token in
4123% TOKENS, and \rest to be the remainder.
4124%
4125\def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
4126
4127% Allow an optional argument of an uppercase letter, lowercase letter,
4128% or number, to specify the first label in the enumerated list. No
4129% argument is the same as `1'.
4130%
82d5ce1d 4131\envparseargdef\enumerate{\enumeratey #1 \endenumeratey}
9e9f9cc2 4132\def\enumeratey #1 #2\endenumeratey{%
9e9f9cc2
KB
4133 % If we were given no argument, pretend we were given `1'.
4134 \def\thearg{#1}%
4135 \ifx\thearg\empty \def\thearg{1}\fi
4136 %
4137 % Detect if the argument is a single token. If so, it might be a
4138 % letter. Otherwise, the only valid thing it can be is a number.
4139 % (We will always have one token, because of the test we just made.
4140 % This is a good thing, since \splitoff doesn't work given nothing at
4141 % all -- the first parameter is undelimited.)
4142 \expandafter\splitoff\thearg\endmark
4143 \ifx\rest\empty
4144 % Only one token in the argument. It could still be anything.
4145 % A ``lowercase letter'' is one whose \lccode is nonzero.
4146 % An ``uppercase letter'' is one whose \lccode is both nonzero, and
4147 % not equal to itself.
4148 % Otherwise, we assume it's a number.
4149 %
4150 % We need the \relax at the end of the \ifnum lines to stop TeX from
4151 % continuing to look for a <number>.
4152 %
4153 \ifnum\lccode\expandafter`\thearg=0\relax
4154 \numericenumerate % a number (we hope)
4155 \else
4156 % It's a letter.
4157 \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
4158 \lowercaseenumerate % lowercase letter
4159 \else
4160 \uppercaseenumerate % uppercase letter
4161 \fi
4162 \fi
4163 \else
4164 % Multiple tokens in the argument. We hope it's a number.
4165 \numericenumerate
4166 \fi
4167}
4168
4169% An @enumerate whose labels are integers. The starting integer is
4170% given in \thearg.
4171%
4172\def\numericenumerate{%
4173 \itemno = \thearg
4174 \startenumeration{\the\itemno}%
4175}
4176
4177% The starting (lowercase) letter is in \thearg.
4178\def\lowercaseenumerate{%
4179 \itemno = \expandafter`\thearg
4180 \startenumeration{%
4181 % Be sure we're not beyond the end of the alphabet.
4182 \ifnum\itemno=0
4183 \errmessage{No more lowercase letters in @enumerate; get a bigger
4184 alphabet}%
4185 \fi
4186 \char\lccode\itemno
4187 }%
4188}
4189
4190% The starting (uppercase) letter is in \thearg.
4191\def\uppercaseenumerate{%
4192 \itemno = \expandafter`\thearg
4193 \startenumeration{%
4194 % Be sure we're not beyond the end of the alphabet.
4195 \ifnum\itemno=0
4196 \errmessage{No more uppercase letters in @enumerate; get a bigger
4197 alphabet}
4198 \fi
4199 \char\uccode\itemno
4200 }%
4201}
4202
82d5ce1d 4203% Call \doitemize, adding a period to the first argument and supplying the
9e9f9cc2
KB
4204% common last two arguments. Also subtract one from the initial value in
4205% \itemno, since @item increments \itemno.
4206%
4207\def\startenumeration#1{%
4208 \advance\itemno by -1
82d5ce1d 4209 \doitemize{#1.}\flushcr
9e9f9cc2
KB
4210}
4211
4212% @alphaenumerate and @capsenumerate are abbreviations for giving an arg
4213% to @enumerate.
4214%
4215\def\alphaenumerate{\enumerate{a}}
4216\def\capsenumerate{\enumerate{A}}
4217\def\Ealphaenumerate{\Eenumerate}
4218\def\Ecapsenumerate{\Eenumerate}
4219
9e9f9cc2
KB
4220
4221% @multitable macros
4222% Amy Hendrickson, 8/18/94, 3/6/96
4223%
4224% @multitable ... @end multitable will make as many columns as desired.
4225% Contents of each column will wrap at width given in preamble. Width
4226% can be specified either with sample text given in a template line,
4227% or in percent of \hsize, the current width of text on page.
4228
4229% Table can continue over pages but will only break between lines.
4230
4231% To make preamble:
4232%
10dc2a90 4233% Either define widths of columns in terms of percent of \hsize:
9e9f9cc2
KB
4234% @multitable @columnfractions .25 .3 .45
4235% @item ...
4236%
4237% Numbers following @columnfractions are the percent of the total
4238% current hsize to be used for each column. You may use as many
4239% columns as desired.
4240
d66b7b41 4241
9e9f9cc2
KB
4242% Or use a template:
4243% @multitable {Column 1 template} {Column 2 template} {Column 3 template}
4244% @item ...
4245% using the widest term desired in each column.
9e9f9cc2 4246
10dc2a90 4247% Each new table line starts with @item, each subsequent new column
9e9f9cc2
KB
4248% starts with @tab. Empty columns may be produced by supplying @tab's
4249% with nothing between them for as many times as empty columns are needed,
4250% ie, @tab@tab@tab will produce two empty columns.
4251
82d5ce1d
UD
4252% @item, @tab do not need to be on their own lines, but it will not hurt
4253% if they are.
9e9f9cc2
KB
4254
4255% Sample multitable:
4256
4257% @multitable {Column 1 template} {Column 2 template} {Column 3 template}
4258% @item first col stuff @tab second col stuff @tab third col
10dc2a90
UD
4259% @item
4260% first col stuff
4261% @tab
4262% second col stuff
4263% @tab
4264% third col
4265% @item first col stuff @tab second col stuff
9e9f9cc2 4266% @tab Many paragraphs of text may be used in any column.
10dc2a90 4267%
9e9f9cc2
KB
4268% They will wrap at the width determined by the template.
4269% @item@tab@tab This will be in third column.
4270% @end multitable
4271
4272% Default dimensions may be reset by user.
4273% @multitableparskip is vertical space between paragraphs in table.
4274% @multitableparindent is paragraph indent in table.
4275% @multitablecolmargin is horizontal space to be left between columns.
4276% @multitablelinespace is space to leave between table items, baseline
4277% to baseline.
4278% 0pt means it depends on current normal line spacing.
2eb45444 4279%
9e9f9cc2
KB
4280\newskip\multitableparskip
4281\newskip\multitableparindent
4282\newdimen\multitablecolspace
4283\newskip\multitablelinespace
4284\multitableparskip=0pt
4285\multitableparindent=6pt
4286\multitablecolspace=12pt
4287\multitablelinespace=0pt
4288
407dc7a0
UD
4289% Macros used to set up halign preamble:
4290%
4291\let\endsetuptable\relax
4292\def\xendsetuptable{\endsetuptable}
4293\let\columnfractions\relax
4294\def\xcolumnfractions{\columnfractions}
4295\newif\ifsetpercent
4296
82d5ce1d
UD
4297% #1 is the @columnfraction, usually a decimal number like .5, but might
4298% be just 1. We just use it, whatever it is.
4299%
4300\def\pickupwholefraction#1 {%
407dc7a0 4301 \global\advance\colcount by 1
82d5ce1d 4302 \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}%
407dc7a0
UD
4303 \setuptable
4304}
4305
4306\newcount\colcount
4307\def\setuptable#1{%
4308 \def\firstarg{#1}%
4309 \ifx\firstarg\xendsetuptable
4310 \let\go = \relax
4311 \else
4312 \ifx\firstarg\xcolumnfractions
4313 \global\setpercenttrue
4314 \else
4315 \ifsetpercent
4316 \let\go\pickupwholefraction
4317 \else
4318 \global\advance\colcount by 1
e0f86659
UD
4319 \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a
4320 % separator; typically that is always in the input, anyway.
407dc7a0
UD
4321 \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
4322 \fi
4323 \fi
4324 \ifx\go\pickupwholefraction
4325 % Put the argument back for the \pickupwholefraction call, so
4326 % we'll always have a period there to be parsed.
4327 \def\go{\pickupwholefraction#1}%
4328 \else
4329 \let\go = \setuptable
4330 \fi%
4331 \fi
4332 \go
4333}
4334
82d5ce1d
UD
4335% multitable-only commands.
4336%
e66a8203
JM
4337% @headitem starts a heading row, which we typeset in bold. Assignments
4338% have to be global since we are inside the implicit group of an
4339% alignment entry. \everycr below resets \everytab so we don't have to
0f8bbd69
JM
4340% undo it ourselves.
4341\def\headitemfont{\b}% for people to use in the template row; not changeable
4342\def\headitem{%
4343 \checkenv\multitable
4344 \crcr
e66a8203 4345 \gdef\headitemcrhook{\nobreak}% attempt to avoid page break after headings
0f8bbd69
JM
4346 \global\everytab={\bf}% can't use \headitemfont since the parsing differs
4347 \the\everytab % for the first item
4348}%
82d5ce1d 4349%
e66a8203
JM
4350% default for tables with no headings.
4351\let\headitemcrhook=\relax
4352%
82d5ce1d
UD
4353% A \tab used to include \hskip1sp. But then the space in a template
4354% line is not enough. That is bad. So let's go back to just `&' until
0f8bbd69 4355% we again encounter the problem the 1sp was intended to solve.
82d5ce1d
UD
4356% --karl, nathan@acm.org, 20apr99.
4357\def\tab{\checkenv\multitable &\the\everytab}%
4358
407dc7a0
UD
4359% @multitable ... @end multitable definitions:
4360%
82d5ce1d
UD
4361\newtoks\everytab % insert after every tab.
4362%
4363\envdef\multitable{%
407dc7a0 4364 \vskip\parskip
82d5ce1d
UD
4365 \startsavinginserts
4366 %
4367 % @item within a multitable starts a normal row.
4368 % We use \def instead of \let so that if one of the multitable entries
4369 % contains an @itemize, we don't choke on the \item (seen as \crcr aka
4370 % \endtemplate) expanding \doitemize.
4371 \def\item{\crcr}%
4372 %
407dc7a0
UD
4373 \tolerance=9500
4374 \hbadness=9500
4375 \setmultitablespacing
4376 \parskip=\multitableparskip
4377 \parindent=\multitableparindent
4378 \overfullrule=0pt
4379 \global\colcount=0
82d5ce1d
UD
4380 %
4381 \everycr = {%
4382 \noalign{%
e66a8203 4383 \global\everytab={}% Reset from possible headitem.
82d5ce1d 4384 \global\colcount=0 % Reset the column counter.
e66a8203
JM
4385 %
4386 % Check for saved footnotes, etc.:
82d5ce1d 4387 \checkinserts
e66a8203
JM
4388 %
4389 % Perhaps a \nobreak, then reset:
4390 \headitemcrhook
4391 \global\let\headitemcrhook=\relax
82d5ce1d 4392 }%
e0f86659 4393 }%
407dc7a0 4394 %
82d5ce1d
UD
4395 \parsearg\domultitable
4396}
4397\def\domultitable#1{%
407dc7a0
UD
4398 % To parse everything between @multitable and @item:
4399 \setuptable#1 \endsetuptable
4400 %
407dc7a0
UD
4401 % This preamble sets up a generic column definition, which will
4402 % be used as many times as user calls for columns.
4403 % \vtop will set a single line and will also let text wrap and
4404 % continue for many paragraphs if desired.
82d5ce1d
UD
4405 \halign\bgroup &%
4406 \global\advance\colcount by 1
4407 \multistrut
4408 \vtop{%
4409 % Use the current \colcount to find the correct column width:
4410 \hsize=\expandafter\csname col\the\colcount\endcsname
4411 %
4412 % In order to keep entries from bumping into each other
4413 % we will add a \leftskip of \multitablecolspace to all columns after
4414 % the first one.
4415 %
4416 % If a template has been used, we will add \multitablecolspace
4417 % to the width of each template entry.
4418 %
4419 % If the user has set preamble in terms of percent of \hsize we will
4420 % use that dimension as the width of the column, and the \leftskip
4421 % will keep entries from bumping into each other. Table will start at
4422 % left margin and final column will justify at right margin.
4423 %
4424 % Make sure we don't inherit \rightskip from the outer environment.
4425 \rightskip=0pt
4426 \ifnum\colcount=1
4427 % The first column will be indented with the surrounding text.
4428 \advance\hsize by\leftskip
4429 \else
4430 \ifsetpercent \else
4431 % If user has not set preamble in terms of percent of \hsize
4432 % we will advance \hsize by \multitablecolspace.
4433 \advance\hsize by \multitablecolspace
4434 \fi
4435 % In either case we will make \leftskip=\multitablecolspace:
4436 \leftskip=\multitablecolspace
4437 \fi
4438 % Ignoring space at the beginning and end avoids an occasional spurious
4439 % blank line, when TeX decides to break the line at the space before the
4440 % box from the multistrut, so the strut ends up on a line by itself.
4441 % For example:
4442 % @multitable @columnfractions .11 .89
4443 % @item @code{#}
4444 % @tab Legal holiday which is valid in major parts of the whole country.
4445 % Is automatically provided with highlighting sequences respectively
4446 % marking characters.
4447 \noindent\ignorespaces##\unskip\multistrut
4448 }\cr
4449}
4450\def\Emultitable{%
4451 \crcr
4452 \egroup % end the \halign
4453 \global\setpercentfalse
4454}
4455
4456\def\setmultitablespacing{%
4457 \def\multistrut{\strut}% just use the standard line spacing
4458 %
4459 % Compute \multitablelinespace (if not defined by user) for use in
4460 % \multitableparskip calculation. We used define \multistrut based on
4461 % this, but (ironically) that caused the spacing to be off.
4462 % See bug-texinfo report from Werner Lemberg, 31 Oct 2004 12:52:20 +0100.
407dc7a0 4463\ifdim\multitablelinespace=0pt
3b82ab1c
UD
4464\setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip
4465\global\advance\multitablelinespace by-\ht0
82d5ce1d 4466\fi
0f8bbd69
JM
4467% Test to see if parskip is larger than space between lines of
4468% table. If not, do nothing.
4469% If so, set to same dimension as multitablelinespace.
407dc7a0
UD
4470\ifdim\multitableparskip>\multitablelinespace
4471\global\multitableparskip=\multitablelinespace
0f8bbd69
JM
4472\global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
4473 % than skip between lines in the table.
407dc7a0
UD
4474\fi%
4475\ifdim\multitableparskip=0pt
4476\global\multitableparskip=\multitablelinespace
0f8bbd69
JM
4477\global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
4478 % than skip between lines in the table.
407dc7a0
UD
4479\fi}
4480
4481
4482\message{conditionals,}
82d5ce1d
UD
4483
4484% @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext,
4485% @ifnotxml always succeed. They currently do nothing; we don't
4486% attempt to check whether the conditionals are properly nested. But we
4487% have to remember that they are conditionals, so that @end doesn't
4488% attempt to close an environment group.
4489%
4490\def\makecond#1{%
4491 \expandafter\let\csname #1\endcsname = \relax
4492 \expandafter\let\csname iscond.#1\endcsname = 1
407dc7a0 4493}
82d5ce1d
UD
4494\makecond{iftex}
4495\makecond{ifnotdocbook}
4496\makecond{ifnothtml}
4497\makecond{ifnotinfo}
4498\makecond{ifnotplaintext}
4499\makecond{ifnotxml}
407dc7a0 4500
2f5b1124 4501% Ignore @ignore, @ifhtml, @ifinfo, and the like.
407dc7a0 4502%
2f5b1124 4503\def\direntry{\doignore{direntry}}
2f5b1124 4504\def\documentdescription{\doignore{documentdescription}}
82d5ce1d 4505\def\docbook{\doignore{docbook}}
2f5b1124 4506\def\html{\doignore{html}}
82d5ce1d 4507\def\ifdocbook{\doignore{ifdocbook}}
407dc7a0 4508\def\ifhtml{\doignore{ifhtml}}
27692f89 4509\def\ifinfo{\doignore{ifinfo}}
407dc7a0 4510\def\ifnottex{\doignore{ifnottex}}
2f5b1124
UD
4511\def\ifplaintext{\doignore{ifplaintext}}
4512\def\ifxml{\doignore{ifxml}}
4513\def\ignore{\doignore{ignore}}
407dc7a0 4514\def\menu{\doignore{menu}}
2f5b1124 4515\def\xml{\doignore{xml}}
407dc7a0 4516
82d5ce1d 4517% Ignore text until a line `@end #1', keeping track of nested conditionals.
a334319f 4518%
82d5ce1d
UD
4519% A count to remember the depth of nesting.
4520\newcount\doignorecount
4521
407dc7a0 4522\def\doignore#1{\begingroup
82d5ce1d 4523 % Scan in ``verbatim'' mode:
9251c568 4524 \obeylines
82d5ce1d
UD
4525 \catcode`\@ = \other
4526 \catcode`\{ = \other
4527 \catcode`\} = \other
407dc7a0
UD
4528 %
4529 % Make sure that spaces turn into tokens that match what \doignoretext wants.
82d5ce1d 4530 \spaceisspace
407dc7a0 4531 %
82d5ce1d
UD
4532 % Count number of #1's that we've seen.
4533 \doignorecount = 0
407dc7a0 4534 %
82d5ce1d
UD
4535 % Swallow text until we reach the matching `@end #1'.
4536 \dodoignore{#1}%
0ecb606c
JJ
4537}
4538
82d5ce1d
UD
4539{ \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source.
4540 \obeylines %
a334319f 4541 %
82d5ce1d
UD
4542 \gdef\dodoignore#1{%
4543 % #1 contains the command name as a string, e.g., `ifinfo'.
a334319f 4544 %
9251c568
AJ
4545 % Define a command to find the next `@end #1'.
4546 \long\def\doignoretext##1^^M@end #1{%
4547 \doignoretextyyy##1^^M@#1\_STOP_}%
4548 %
82d5ce1d
UD
4549 % And this command to find another #1 command, at the beginning of a
4550 % line. (Otherwise, we would consider a line `@c @ifset', for
4551 % example, to count as an @ifset for nesting.)
4552 \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}%
a334319f 4553 %
82d5ce1d 4554 % And now expand that command.
82d5ce1d
UD
4555 \doignoretext ^^M%
4556 }%
4557}
4558
4559\def\doignoreyyy#1{%
4560 \def\temp{#1}%
4561 \ifx\temp\empty % Nothing found.
4562 \let\next\doignoretextzzz
4563 \else % Found a nested condition, ...
4564 \advance\doignorecount by 1
4565 \let\next\doignoretextyyy % ..., look for another.
4566 % If we're here, #1 ends with ^^M\ifinfo (for example).
4567 \fi
4568 \next #1% the token \_STOP_ is present just after this macro.
4569}
4570
4571% We have to swallow the remaining "\_STOP_".
4572%
4573\def\doignoretextzzz#1{%
4574 \ifnum\doignorecount = 0 % We have just found the outermost @end.
4575 \let\next\enddoignore
4576 \else % Still inside a nested condition.
4577 \advance\doignorecount by -1
4578 \let\next\doignoretext % Look for the next @end.
4579 \fi
4580 \next
407dc7a0
UD
4581}
4582
82d5ce1d 4583% Finish off ignored text.
9251c568
AJ
4584{ \obeylines%
4585 % Ignore anything after the last `@end #1'; this matters in verbatim
4586 % environments, where otherwise the newline after an ignored conditional
4587 % would result in a blank line in the output.
4588 \gdef\enddoignore#1^^M{\endgroup\ignorespaces}%
4589}
82d5ce1d
UD
4590
4591
407dc7a0
UD
4592% @set VAR sets the variable VAR to an empty value.
4593% @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
4594%
4595% Since we want to separate VAR from REST-OF-LINE (which might be
4596% empty), we can't just use \parsearg; we have to insert a space of our
4597% own to delimit the rest of the line, and then take it out again if we
82d5ce1d
UD
4598% didn't need it.
4599% We rely on the fact that \parsearg sets \catcode`\ =10.
407dc7a0 4600%
82d5ce1d 4601\parseargdef\set{\setyyy#1 \endsetyyy}
407dc7a0 4602\def\setyyy#1 #2\endsetyyy{%
82d5ce1d
UD
4603 {%
4604 \makevalueexpandable
4605 \def\temp{#2}%
4606 \edef\next{\gdef\makecsname{SET#1}}%
4607 \ifx\temp\empty
4608 \next{}%
4609 \else
4610 \setzzz#2\endsetzzz
4611 \fi
4612 }%
407dc7a0 4613}
82d5ce1d
UD
4614% Remove the trailing space \setxxx inserted.
4615\def\setzzz#1 \endsetzzz{\next{#1}}
407dc7a0
UD
4616
4617% @clear VAR clears (i.e., unsets) the variable VAR.
b710a6e2 4618%
82d5ce1d
UD
4619\parseargdef\clear{%
4620 {%
4621 \makevalueexpandable
4622 \global\expandafter\let\csname SET#1\endcsname=\relax
4623 }%
4624}
9e9f9cc2 4625
407dc7a0 4626% @value{foo} gets the text saved in variable foo.
82d5ce1d
UD
4627\def\value{\begingroup\makevalueexpandable\valuexxx}
4628\def\valuexxx#1{\expandablevalue{#1}\endgroup}
407dc7a0 4629{
21fea2e2 4630 \catcode`\-=\active \catcode`\_=\active
407dc7a0 4631 %
82d5ce1d
UD
4632 \gdef\makevalueexpandable{%
4633 \let\value = \expandablevalue
4634 % We don't want these characters active, ...
e0f86659 4635 \catcode`\-=\other \catcode`\_=\other
82d5ce1d
UD
4636 % ..., but we might end up with active ones in the argument if
4637 % we're called from @code, as @code{@value{foo-bar_}}, though.
4638 % So \let them to their normal equivalents.
8fcb833a 4639 \let-\normaldash \let_\normalunderscore
82d5ce1d 4640 }
b710a6e2 4641}
9e9f9cc2 4642
407dc7a0 4643% We have this subroutine so that we can handle at least some @value's
82d5ce1d
UD
4644% properly in indexes (we call \makevalueexpandable in \indexdummies).
4645% The command has to be fully expandable (if the variable is set), since
4646% the result winds up in the index file. This means that if the
4647% variable's value contains other Texinfo commands, it's almost certain
4648% it will fail (although perhaps we could fix that with sufficient work
4649% to do a one-level expansion on the result, instead of complete).
407dc7a0 4650%
21fea2e2
JM
4651% Unfortunately, this has the consequence that when _ is in the *value*
4652% of an @set, it does not print properly in the roman fonts (get the cmr
4653% dot accent at position 126 instead). No fix comes to mind, and it's
4654% been this way since 2003 or earlier, so just ignore it.
4655%
407dc7a0
UD
4656\def\expandablevalue#1{%
4657 \expandafter\ifx\csname SET#1\endcsname\relax
4658 {[No value for ``#1'']}%
e0f86659 4659 \message{Variable `#1', used in @value, is not set.}%
9e9f9cc2 4660 \else
407dc7a0 4661 \csname SET#1\endcsname
b710a6e2 4662 \fi
b710a6e2 4663}
9e9f9cc2 4664
7f7dd1d3
JM
4665% Like \expandablevalue, but completely expandable (the \message in the
4666% definition above operates at the execution level of TeX). Used when
4667% writing to auxiliary files, due to the expansion that \write does.
4668% If flag is undefined, pass through an unexpanded @value command: maybe it
4669% will be set by the time it is read back in.
4670%
4671% NB flag names containing - or _ may not work here.
4672\def\dummyvalue#1{%
4673 \expandafter\ifx\csname SET#1\endcsname\relax
4674 \noexpand\value{#1}%
4675 \else
4676 \csname SET#1\endcsname
4677 \fi
4678}
4679
4680% Used for @value's in index entries to form the sort key: expand the @value
4681% if possible, otherwise sort late.
4682\def\indexnofontsvalue#1{%
4683 \expandafter\ifx\csname SET#1\endcsname\relax
4684 ZZZZZZZ
4685 \else
4686 \csname SET#1\endcsname
4687 \fi
4688}
4689
407dc7a0
UD
4690% @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
4691% with @set.
4692%
8fcb833a
JM
4693% To get the special treatment we need for `@end ifset,' we call
4694% \makecond and then redefine.
82d5ce1d
UD
4695%
4696\makecond{ifset}
4697\def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}}
4698\def\doifset#1#2{%
4699 {%
4700 \makevalueexpandable
4701 \let\next=\empty
4702 \expandafter\ifx\csname SET#2\endcsname\relax
4703 #1% If not set, redefine \next.
4704 \fi
4705 \expandafter
4706 }\next
407dc7a0 4707}
82d5ce1d 4708\def\ifsetfail{\doignore{ifset}}
9e9f9cc2 4709
8fcb833a 4710% @ifclear VAR ... @end executes the `...' iff VAR has never been
407dc7a0 4711% defined with @set, or has been undefined with @clear.
b710a6e2 4712%
82d5ce1d
UD
4713% The `\else' inside the `\doifset' parameter is a trick to reuse the
4714% above code: if the variable is not set, do nothing, if it is set,
4715% then redefine \next to \ifclearfail.
407dc7a0 4716%
82d5ce1d
UD
4717\makecond{ifclear}
4718\def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}}
4719\def\ifclearfail{\doignore{ifclear}}
407dc7a0 4720
8fcb833a
JM
4721% @ifcommandisdefined CMD ... @end executes the `...' if CMD (written
4722% without the @) is in fact defined. We can only feasibly check at the
4723% TeX level, so something like `mathcode' is going to considered
4724% defined even though it is not a Texinfo command.
4725%
4726\makecond{ifcommanddefined}
4727\def\ifcommanddefined{\parsearg{\doifcmddefined{\let\next=\ifcmddefinedfail}}}
4728%
4729\def\doifcmddefined#1#2{{%
4730 \makevalueexpandable
4731 \let\next=\empty
4732 \expandafter\ifx\csname #2\endcsname\relax
4733 #1% If not defined, \let\next as above.
4734 \fi
4735 \expandafter
4736 }\next
4737}
4738\def\ifcmddefinedfail{\doignore{ifcommanddefined}}
4739
4740% @ifcommandnotdefined CMD ... handled similar to @ifclear above.
4741\makecond{ifcommandnotdefined}
4742\def\ifcommandnotdefined{%
4743 \parsearg{\doifcmddefined{\else \let\next=\ifcmdnotdefinedfail}}}
4744\def\ifcmdnotdefinedfail{\doignore{ifcommandnotdefined}}
4745
4746% Set the `txicommandconditionals' variable, so documents have a way to
4747% test if the @ifcommand...defined conditionals are available.
4748\set txicommandconditionals
4749
82d5ce1d
UD
4750% @dircategory CATEGORY -- specify a category of the dir file
4751% which this file should belong to. Ignore this in TeX.
4752\let\dircategory=\comment
407dc7a0
UD
4753
4754% @defininfoenclose.
4755\let\definfoenclose=\comment
d66b7b41
KB
4756
4757
9e9f9cc2
KB
4758\message{indexing,}
4759% Index generation facilities
4760
4761% Define \newwrite to be identical to plain tex's \newwrite
82d5ce1d
UD
4762% except not \outer, so it can be used within macros and \if's.
4763\edef\newwrite{\makecsname{ptexnewwrite}}
9e9f9cc2 4764
084e7d57
JM
4765% \newindex {foo} defines an index named IX.
4766% It automatically defines \IXindex such that
4767% \IXindex ...rest of line... puts an entry in the index IX.
4768% It also defines \IXindfile to be the number of the output channel for
4769% the file that accumulates this index. The file's extension is IX.
9e9f9cc2
KB
4770% The name of an index should be no more than 2 characters long
4771% for the sake of vms.
f962d792
UD
4772%
4773\def\newindex#1{%
084e7d57 4774 \expandafter\chardef\csname#1indfile\endcsname=0
f962d792
UD
4775 \expandafter\xdef\csname#1index\endcsname{% % Define @#1index
4776 \noexpand\doindex{#1}}
9e9f9cc2
KB
4777}
4778
4779% @defindex foo == \newindex{foo}
366d6851 4780%
9e9f9cc2
KB
4781\def\defindex{\parsearg\newindex}
4782
4783% Define @defcodeindex, like @defindex except put all entries in @code.
366d6851
UD
4784%
4785\def\defcodeindex{\parsearg\newcodeindex}
4786%
f962d792 4787\def\newcodeindex#1{%
084e7d57 4788 \expandafter\chardef\csname#1indfile\endcsname=0
f962d792 4789 \expandafter\xdef\csname#1index\endcsname{%
366d6851 4790 \noexpand\docodeindex{#1}}%
9e9f9cc2
KB
4791}
4792
084e7d57
JM
4793% The default indices:
4794\newindex{cp}% concepts,
4795\newcodeindex{fn}% functions,
4796\newcodeindex{vr}% variables,
4797\newcodeindex{tp}% types,
4798\newcodeindex{ky}% keys
4799\newcodeindex{pg}% and programs.
4800
9e9f9cc2
KB
4801
4802% @synindex foo bar makes index foo feed into index bar.
4803% Do this instead of @defindex foo if you don't want it as a separate index.
7158eae4 4804%
9e9f9cc2
KB
4805% @syncodeindex foo bar similar, but put all entries made for index foo
4806% inside @code.
7158eae4 4807%
366d6851
UD
4808\def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}}
4809\def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}}
4810
4811% #1 is \doindex or \docodeindex, #2 the index getting redefined (foo),
4812% #3 the target index (bar).
4813\def\dosynindex#1#2#3{%
7f7dd1d3 4814 \requireopenindexfile{#3}%
366d6851
UD
4815 % redefine \fooindfile:
4816 \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname
4817 \expandafter\let\csname#2indfile\endcsname=\temp
4818 % redefine \fooindex:
4819 \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}%
9e9f9cc2
KB
4820}
4821
084e7d57 4822% Define \doindex, the driver for all index macros.
9e9f9cc2 4823% Argument #1 is generated by the calling \fooindex macro,
7f7dd1d3 4824% and it is the two-letter name of the index.
9e9f9cc2 4825
084e7d57
JM
4826\def\doindex#1{\edef\indexname{#1}\parsearg\doindexxxx}
4827\def\doindexxxx #1{\doind{\indexname}{#1}}
9e9f9cc2
KB
4828
4829% like the previous two, but they put @code around the argument.
084e7d57
JM
4830\def\docodeindex#1{\edef\indexname{#1}\parsearg\docodeindexxxx}
4831\def\docodeindexxxx #1{\doind{\indexname}{\code{#1}}}
9e9f9cc2 4832
7f7dd1d3
JM
4833\f
4834% Used when writing an index entry out to an index file to prevent
084e7d57 4835% expansion of Texinfo commands that can appear in an index entry.
7158eae4 4836%
9e9f9cc2 4837\def\indexdummies{%
9251c568 4838 \escapechar = `\\ % use backslash in output files.
7f7dd1d3
JM
4839 \definedummyletter\@%
4840 \definedummyletter\ %
4841 %
4842 % For texindex which always views { and } as separators.
4843 \def\{{\lbracechar{}}%
4844 \def\}{\rbracechar{}}%
e0f86659 4845 %
e0f86659 4846 % Do the redefinitions.
7f7dd1d3 4847 \definedummies
e0f86659
UD
4848}
4849
7f7dd1d3 4850% Used for the aux and toc files, where @ is the escape character.
7158eae4 4851%
e0f86659 4852\def\atdummies{%
7f7dd1d3
JM
4853 \definedummyletter\@%
4854 \definedummyletter\ %
4855 \definedummyletter\{%
4856 \definedummyletter\}%
e0f86659 4857 %
e0f86659 4858 % Do the redefinitions.
7f7dd1d3 4859 \definedummies
9251c568 4860 \otherbackslash
e0f86659
UD
4861}
4862
7f7dd1d3
JM
4863% \definedummyword defines \#1 as \string\#1\space, thus effectively
4864% preventing its expansion. This is used only for control words,
4865% not control letters, because the \space would be incorrect for
4866% control characters, but is needed to separate the control word
4867% from whatever follows.
7158eae4 4868%
7f7dd1d3
JM
4869% These can be used both for control words that take an argument and
4870% those that do not. If it is followed by {arg} in the input, then
4871% that will dutifully get written to the index (or wherever).
4872%
4873% For control letters, we have \definedummyletter, which omits the
4874% space.
4875%
4876\def\definedummyword #1{\def#1{\string#1\space}}%
4877\def\definedummyletter#1{\def#1{\string#1}}%
4878\let\definedummyaccent\definedummyletter
4879
4880% Called from \indexdummies and \atdummies, to effectively prevent
4881% the expansion of commands.
4882%
4883\def\definedummies{%
e0f86659 4884 %
7f7dd1d3
JM
4885 \let\commondummyword\definedummyword
4886 \let\commondummyletter\definedummyletter
4887 \let\commondummyaccent\definedummyaccent
82d5ce1d
UD
4888 \commondummiesnofonts
4889 %
9251c568 4890 \definedummyletter\_%
0f8bbd69 4891 \definedummyletter\-%
82d5ce1d
UD
4892 %
4893 % Non-English letters.
9251c568
AJ
4894 \definedummyword\AA
4895 \definedummyword\AE
0f8bbd69 4896 \definedummyword\DH
9251c568 4897 \definedummyword\L
9251c568 4898 \definedummyword\O
0f8bbd69
JM
4899 \definedummyword\OE
4900 \definedummyword\TH
9251c568
AJ
4901 \definedummyword\aa
4902 \definedummyword\ae
0f8bbd69
JM
4903 \definedummyword\dh
4904 \definedummyword\exclamdown
9251c568 4905 \definedummyword\l
9251c568 4906 \definedummyword\o
0f8bbd69 4907 \definedummyword\oe
9251c568
AJ
4908 \definedummyword\ordf
4909 \definedummyword\ordm
0f8bbd69
JM
4910 \definedummyword\questiondown
4911 \definedummyword\ss
4912 \definedummyword\th
e0f86659
UD
4913 %
4914 % Although these internal commands shouldn't show up, sometimes they do.
9251c568
AJ
4915 \definedummyword\bf
4916 \definedummyword\gtr
4917 \definedummyword\hat
4918 \definedummyword\less
4919 \definedummyword\sf
4920 \definedummyword\sl
4921 \definedummyword\tclose
4922 \definedummyword\tt
4923 %
4924 \definedummyword\LaTeX
4925 \definedummyword\TeX
e0f86659
UD
4926 %
4927 % Assorted special characters.
7f7dd1d3 4928 \definedummyword\atchar
0f8bbd69 4929 \definedummyword\arrow
9251c568
AJ
4930 \definedummyword\bullet
4931 \definedummyword\comma
4932 \definedummyword\copyright
4933 \definedummyword\registeredsymbol
4934 \definedummyword\dots
4935 \definedummyword\enddots
0f8bbd69 4936 \definedummyword\entrybreak
9251c568
AJ
4937 \definedummyword\equiv
4938 \definedummyword\error
4939 \definedummyword\euro
0f8bbd69
JM
4940 \definedummyword\expansion
4941 \definedummyword\geq
c94f48d7
AJ
4942 \definedummyword\guillemetleft
4943 \definedummyword\guillemetright
4944 \definedummyword\guilsinglleft
4945 \definedummyword\guilsinglright
8fcb833a 4946 \definedummyword\lbracechar
0f8bbd69 4947 \definedummyword\leq
084e7d57 4948 \definedummyword\mathopsup
9251c568 4949 \definedummyword\minus
0f8bbd69 4950 \definedummyword\ogonek
9251c568
AJ
4951 \definedummyword\pounds
4952 \definedummyword\point
4953 \definedummyword\print
c94f48d7
AJ
4954 \definedummyword\quotedblbase
4955 \definedummyword\quotedblleft
4956 \definedummyword\quotedblright
4957 \definedummyword\quoteleft
4958 \definedummyword\quoteright
4959 \definedummyword\quotesinglbase
8fcb833a 4960 \definedummyword\rbracechar
9251c568 4961 \definedummyword\result
084e7d57
JM
4962 \definedummyword\sub
4963 \definedummyword\sup
9251c568
AJ
4964 \definedummyword\textdegree
4965 %
4966 % We want to disable all macros so that they are not expanded by \write.
4967 \macrolist
7f7dd1d3 4968 \let\value\dummyvalue
9251c568
AJ
4969 %
4970 \normalturnoffactive
9e9f9cc2
KB
4971}
4972
7f7dd1d3
JM
4973% \commondummiesnofonts: common to \definedummies and \indexnofonts.
4974% Define \commondummyletter, \commondummyaccent and \commondummyword before
4975% using. Used for accents, font commands, and various control letters.
82d5ce1d 4976%
9251c568
AJ
4977\def\commondummiesnofonts{%
4978 % Control letters and accents.
7f7dd1d3
JM
4979 \commondummyletter\!%
4980 \commondummyaccent\"%
4981 \commondummyaccent\'%
4982 \commondummyletter\*%
4983 \commondummyaccent\,%
4984 \commondummyletter\.%
4985 \commondummyletter\/%
4986 \commondummyletter\:%
4987 \commondummyaccent\=%
4988 \commondummyletter\?%
4989 \commondummyaccent\^%
4990 \commondummyaccent\`%
4991 \commondummyaccent\~%
4992 \commondummyword\u
4993 \commondummyword\v
4994 \commondummyword\H
4995 \commondummyword\dotaccent
4996 \commondummyword\ogonek
4997 \commondummyword\ringaccent
4998 \commondummyword\tieaccent
4999 \commondummyword\ubaraccent
5000 \commondummyword\udotaccent
5001 \commondummyword\dotless
9251c568
AJ
5002 %
5003 % Texinfo font commands.
7f7dd1d3
JM
5004 \commondummyword\b
5005 \commondummyword\i
5006 \commondummyword\r
5007 \commondummyword\sansserif
5008 \commondummyword\sc
5009 \commondummyword\slanted
5010 \commondummyword\t
9251c568
AJ
5011 %
5012 % Commands that take arguments.
7f7dd1d3
JM
5013 \commondummyword\abbr
5014 \commondummyword\acronym
5015 \commondummyword\anchor
5016 \commondummyword\cite
5017 \commondummyword\code
5018 \commondummyword\command
5019 \commondummyword\dfn
5020 \commondummyword\dmn
5021 \commondummyword\email
5022 \commondummyword\emph
5023 \commondummyword\env
5024 \commondummyword\file
5025 \commondummyword\image
5026 \commondummyword\indicateurl
5027 \commondummyword\inforef
5028 \commondummyword\kbd
5029 \commondummyword\key
5030 \commondummyword\math
5031 \commondummyword\option
5032 \commondummyword\pxref
5033 \commondummyword\ref
5034 \commondummyword\samp
5035 \commondummyword\strong
5036 \commondummyword\tie
5037 \commondummyword\U
5038 \commondummyword\uref
5039 \commondummyword\url
5040 \commondummyword\var
5041 \commondummyword\verb
5042 \commondummyword\w
5043 \commondummyword\xref
82d5ce1d 5044}
e0f86659 5045
e66a8203
JM
5046% For testing: output @{ and @} in index sort strings as \{ and \}.
5047\newif\ifusebracesinindexes
5048
084e7d57
JM
5049\let\indexlbrace\relax
5050\let\indexrbrace\relax
5051
5052{\catcode`\@=0
5053\catcode`\\=13
5054 @gdef@backslashdisappear{@def\{}}
5055}
5056
5057{
5058\catcode`\<=13
5059\catcode`\-=13
5060\catcode`\`=13
5061 \gdef\indexnonalnumdisappear{%
5062 \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax\else
5063 % @set txiindexlquoteignore makes us ignore left quotes in the sort term.
5064 % (Introduced for FSFS 2nd ed.)
5065 \let`=\empty
5066 \fi
5067 %
5068 \expandafter\ifx\csname SETtxiindexbackslashignore\endcsname\relax\else
5069 \backslashdisappear
5070 \fi
5071 %
5072 \expandafter\ifx\csname SETtxiindexhyphenignore\endcsname\relax\else
5073 \def-{}%
5074 \fi
5075 \expandafter\ifx\csname SETtxiindexlessthanignore\endcsname\relax\else
5076 \def<{}%
5077 \fi
5078 \expandafter\ifx\csname SETtxiindexatsignignore\endcsname\relax\else
5079 \def\@{}%
5080 \fi
5081 }
5082
5083 \gdef\indexnonalnumreappear{%
5084 \useindexbackslash
5085 \let-\normaldash
5086 \let<\normalless
5087 \def\@{@}%
5088 }
5089}
5090
5091
e0f86659
UD
5092% \indexnofonts is used when outputting the strings to sort the index
5093% by, and when constructing control sequence names. It eliminates all
5094% control sequences and just writes whatever the best ASCII sort string
5095% would be for a given command (usually its argument).
5096%
9e9f9cc2 5097\def\indexnofonts{%
82d5ce1d 5098 % Accent commands should become @asis.
7f7dd1d3 5099 \def\commondummyaccent##1{\let##1\asis}%
82d5ce1d 5100 % We can just ignore other control letters.
7f7dd1d3 5101 \def\commondummyletter##1{\let##1\empty}%
0f8bbd69 5102 % All control words become @asis by default; overrides below.
7f7dd1d3 5103 \let\commondummyword\commondummyaccent
82d5ce1d
UD
5104 \commondummiesnofonts
5105 %
5106 % Don't no-op \tt, since it isn't a user-level command
5107 % and is used in the definitions of the active chars like <, >, |, etc.
5108 % Likewise with the other plain tex font commands.
5109 %\let\tt=\asis
5110 %
e0f86659
UD
5111 \def\ { }%
5112 \def\@{@}%
e0f86659 5113 \def\_{\normalunderscore}%
0f8bbd69
JM
5114 \def\-{}% @- shouldn't affect sorting
5115 %
7f7dd1d3
JM
5116 \uccode`\1=`\{ \uppercase{\def\{{1}}%
5117 \uccode`\1=`\} \uppercase{\def\}{1}}%
5118 \let\lbracechar\{%
5119 \let\rbracechar\}%
e0f86659 5120 %
82d5ce1d 5121 % Non-English letters.
e0f86659
UD
5122 \def\AA{AA}%
5123 \def\AE{AE}%
0f8bbd69 5124 \def\DH{DZZ}%
e0f86659
UD
5125 \def\L{L}%
5126 \def\OE{OE}%
5127 \def\O{O}%
084e7d57 5128 \def\TH{TH}%
e0f86659
UD
5129 \def\aa{aa}%
5130 \def\ae{ae}%
0f8bbd69
JM
5131 \def\dh{dzz}%
5132 \def\exclamdown{!}%
e0f86659
UD
5133 \def\l{l}%
5134 \def\oe{oe}%
82d5ce1d
UD
5135 \def\ordf{a}%
5136 \def\ordm{o}%
0f8bbd69
JM
5137 \def\o{o}%
5138 \def\questiondown{?}%
5139 \def\ss{ss}%
084e7d57 5140 \def\th{th}%
e0f86659 5141 %
82d5ce1d
UD
5142 \def\LaTeX{LaTeX}%
5143 \def\TeX{TeX}%
e0f86659 5144 %
7f7dd1d3
JM
5145 % Assorted special characters. \defglyph gives the control sequence a
5146 % definition that removes the {} that follows its use.
5147 \defglyph\atchar{@}%
5148 \defglyph\arrow{->}%
5149 \defglyph\bullet{bullet}%
5150 \defglyph\comma{,}%
5151 \defglyph\copyright{copyright}%
5152 \defglyph\dots{...}%
5153 \defglyph\enddots{...}%
5154 \defglyph\equiv{==}%
5155 \defglyph\error{error}%
5156 \defglyph\euro{euro}%
5157 \defglyph\expansion{==>}%
5158 \defglyph\geq{>=}%
5159 \defglyph\guillemetleft{<<}%
5160 \defglyph\guillemetright{>>}%
5161 \defglyph\guilsinglleft{<}%
5162 \defglyph\guilsinglright{>}%
5163 \defglyph\leq{<=}%
5164 \defglyph\lbracechar{\{}%
5165 \defglyph\minus{-}%
5166 \defglyph\point{.}%
5167 \defglyph\pounds{pounds}%
5168 \defglyph\print{-|}%
5169 \defglyph\quotedblbase{"}%
5170 \defglyph\quotedblleft{"}%
5171 \defglyph\quotedblright{"}%
5172 \defglyph\quoteleft{`}%
5173 \defglyph\quoteright{'}%
5174 \defglyph\quotesinglbase{,}%
5175 \defglyph\rbracechar{\}}%
5176 \defglyph\registeredsymbol{R}%
5177 \defglyph\result{=>}%
5178 \defglyph\textdegree{o}%
0f8bbd69 5179 %
9251c568
AJ
5180 % We need to get rid of all macros, leaving only the arguments (if present).
5181 % Of course this is not nearly correct, but it is the best we can do for now.
5182 % makeinfo does not expand macros in the argument to @deffn, which ends up
5183 % writing an index entry, and texindex isn't prepared for an index sort entry
5184 % that starts with \.
0f8bbd69 5185 %
9251c568
AJ
5186 % Since macro invocations are followed by braces, we can just redefine them
5187 % to take a single TeX argument. The case of a macro invocation that
5188 % goes to end-of-line is not handled.
0f8bbd69 5189 %
9251c568 5190 \macrolist
7f7dd1d3 5191 \let\value\indexnofontsvalue
e0f86659 5192}
7f7dd1d3
JM
5193\def\defglyph#1#2{\def#1##1{#2}} % see above
5194
5195\f
9e9f9cc2 5196
0f8bbd69 5197
f962d792
UD
5198\let\SETmarginindex=\relax % put index entries in margin (undocumented)?
5199
f962d792 5200% Most index entries go through here, but \dosubind is the general case.
82d5ce1d
UD
5201% #1 is the index name, #2 is the entry text.
5202\def\doind#1#2{\dosubind{#1}{#2}{}}
f962d792 5203
084e7d57
JM
5204% There is also \dosubind {index}{topic}{subtopic}
5205% which makes an entry in a two-level index such as the operation index.
5206% TODO: Two-level index? Operation index?
5207
5208% Workhorse for all indexes.
f962d792 5209% #1 is name of index, #2 is stuff to put there, #3 is subentry --
82d5ce1d
UD
5210% empty if called from \doind, as we usually are (the main exception
5211% is with most defuns, which call us directly).
b710a6e2 5212%
f962d792 5213\def\dosubind#1#2#3{%
82d5ce1d
UD
5214 \iflinks
5215 {%
084e7d57 5216 \requireopenindexfile{#1}%
82d5ce1d
UD
5217 % Store the main index entry text (including the third arg).
5218 \toks0 = {#2}%
5219 % If third arg is present, precede it with a space.
5220 \def\thirdarg{#3}%
5221 \ifx\thirdarg\empty \else
5222 \toks0 = \expandafter{\the\toks0 \space #3}%
5223 \fi
5224 %
5225 \edef\writeto{\csname#1indfile\endcsname}%
5226 %
c94f48d7 5227 \safewhatsit\dosubindwrite
82d5ce1d
UD
5228 }%
5229 \fi
5230}
5231
084e7d57
JM
5232% Check if an index file has been opened, and if not, open it.
5233\def\requireopenindexfile#1{%
5234\ifnum\csname #1indfile\endcsname=0
5235 \expandafter\newwrite \csname#1indfile\endcsname
5236 \edef\suffix{#1}%
5237 % A .fls suffix would conflict with the file extension for the output
5238 % of -recorder, so use .f1s instead.
5239 \ifx\suffix\indexisfl\def\suffix{f1}\fi
5240 % Open the file
5241 \immediate\openout\csname#1indfile\endcsname \jobname.\suffix
7f7dd1d3
JM
5242 % Using \immediate above here prevents an object entering into the current
5243 % box, which could confound checks such as those in \safewhatsit for
5244 % preceding skips.
5245 \typeout{Writing index file \jobname.\suffix}%
084e7d57
JM
5246\fi}
5247\def\indexisfl{fl}
5248
5249% Output \ as {\indexbackslash}, because \ is an escape character in
5250% the index files.
5251\let\indexbackslash=\relax
5252{\catcode`\@=0 \catcode`\\=\active
5253 @gdef@useindexbackslash{@def\{{@indexbackslash}}}
5254}
5255
5256% Definition for writing index entry text.
5257\def\sortas#1{\ignorespaces}%
5258
5259% Definition for writing index entry sort key. Should occur at the at
5260% the beginning of the index entry, like
5261% @cindex @sortas{september} \september
5262% The \ignorespaces takes care of following space, but there's no way
5263% to remove space before it.
5264{
5265\catcode`\-=13
5266\gdef\indexwritesortas{%
5267 \begingroup
5268 \indexnonalnumreappear
5269 \indexwritesortasxxx}
5270\gdef\indexwritesortasxxx#1{%
5271 \xdef\indexsortkey{#1}\endgroup}
5272}
5273
5274
5275% Write the entry in \toks0 to the index file.
82d5ce1d
UD
5276%
5277\def\dosubindwrite{%
359a1d0b
KB
5278 % Put the index entry in the margin if desired.
5279 \ifx\SETmarginindex\relax\else
82d5ce1d 5280 \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}%
359a1d0b 5281 \fi
82d5ce1d
UD
5282 %
5283 % Remember, we are within a group.
5284 \indexdummies % Must do this here, since \bf, etc expand at this stage
084e7d57
JM
5285 \useindexbackslash % \indexbackslash isn't defined now so it will be output
5286 % as is; and it will print as backslash.
7f7dd1d3
JM
5287 % The braces around \indexbrace are recognized by texindex.
5288 %
084e7d57
JM
5289 % Get the string to sort by, by processing the index entry with all
5290 % font commands turned off.
82d5ce1d 5291 {\indexnofonts
7f7dd1d3
JM
5292 \def\lbracechar{{\indexlbrace}}%
5293 \def\rbracechar{{\indexrbrace}}%
5294 \let\{=\lbracechar
5295 \let\}=\rbracechar
084e7d57
JM
5296 \indexnonalnumdisappear
5297 \xdef\indexsortkey{}%
5298 \let\sortas=\indexwritesortas
5299 \edef\temp{\the\toks0}%
5300 \setbox\dummybox = \hbox{\temp}% Make sure to execute any \sortas
5301 \ifx\indexsortkey\empty
5302 \xdef\indexsortkey{\temp}%
5303 \ifx\indexsortkey\empty\xdef\indexsortkey{ }\fi
5304 \fi
82d5ce1d
UD
5305 }%
5306 %
5307 % Set up the complete index entry, with both the sort key and
5308 % the original text, including any font commands. We write
5309 % three arguments to \entry to the .?? file (four in the
5310 % subentry case), texindex reduces to two when writing the .??s
5311 % sorted result.
5312 \edef\temp{%
5313 \write\writeto{%
084e7d57 5314 \string\entry{\indexsortkey}{\noexpand\folio}{\the\toks0}}%
359a1d0b 5315 }%
82d5ce1d 5316 \temp
0ecb606c 5317}
084e7d57 5318\newbox\dummybox % used above
0ecb606c 5319
c94f48d7 5320% Take care of unwanted page breaks/skips around a whatsit:
82d5ce1d
UD
5321%
5322% If a skip is the last thing on the list now, preserve it
5323% by backing up by \lastskip, doing the \write, then inserting
5324% the skip again. Otherwise, the whatsit generated by the
c94f48d7
AJ
5325% \write or \pdfdest will make \lastskip zero. The result is that
5326% sequences like this:
82d5ce1d
UD
5327% @end defun
5328% @tindex whatever
5329% @defun ...
5330% will have extra space inserted, because the \medbreak in the
5331% start of the @defun won't see the skip inserted by the @end of
5332% the previous defun.
5333%
5334% But don't do any of this if we're not in vertical mode. We
5335% don't want to do a \vskip and prematurely end a paragraph.
5336%
5337% Avoid page breaks due to these extra skips, too.
5338%
5339% But wait, there is a catch there:
5340% We'll have to check whether \lastskip is zero skip. \ifdim is not
5341% sufficient for this purpose, as it ignores stretch and shrink parts
5342% of the skip. The only way seems to be to check the textual
5343% representation of the skip.
5344%
5345% The following is almost like \def\zeroskipmacro{0.0pt} except that
5346% the ``p'' and ``t'' characters have catcode \other, not 11 (letter).
5347%
5348\edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname}
5349%
c94f48d7
AJ
5350\newskip\whatsitskip
5351\newcount\whatsitpenalty
5352%
82d5ce1d
UD
5353% ..., ready, GO:
5354%
8fcb833a 5355\def\safewhatsit#1{\ifhmode
c94f48d7 5356 #1%
8fcb833a 5357 \else
82d5ce1d 5358 % \lastskip and \lastpenalty cannot both be nonzero simultaneously.
c94f48d7 5359 \whatsitskip = \lastskip
82d5ce1d 5360 \edef\lastskipmacro{\the\lastskip}%
c94f48d7 5361 \whatsitpenalty = \lastpenalty
82d5ce1d
UD
5362 %
5363 % If \lastskip is nonzero, that means the last item was a
5364 % skip. And since a skip is discardable, that means this
c94f48d7 5365 % -\whatsitskip glue we're inserting is preceded by a
82d5ce1d
UD
5366 % non-discardable item, therefore it is not a potential
5367 % breakpoint, therefore no \nobreak needed.
5368 \ifx\lastskipmacro\zeroskipmacro
5369 \else
c94f48d7 5370 \vskip-\whatsitskip
82d5ce1d
UD
5371 \fi
5372 %
c94f48d7 5373 #1%
82d5ce1d
UD
5374 %
5375 \ifx\lastskipmacro\zeroskipmacro
5376 % If \lastskip was zero, perhaps the last item was a penalty, and
5377 % perhaps it was >=10000, e.g., a \nobreak. In that case, we want
5378 % to re-insert the same penalty (values >10000 are used for various
5379 % signals); since we just inserted a non-discardable item, any
5380 % following glue (such as a \parskip) would be a breakpoint. For example:
82d5ce1d
UD
5381 % @deffn deffn-whatever
5382 % @vindex index-whatever
5383 % Description.
5384 % would allow a break between the index-whatever whatsit
5385 % and the "Description." paragraph.
c94f48d7 5386 \ifnum\whatsitpenalty>9999 \penalty\whatsitpenalty \fi
82d5ce1d
UD
5387 \else
5388 % On the other hand, if we had a nonzero \lastskip,
5389 % this make-up glue would be preceded by a non-discardable item
5390 % (the whatsit from the \write), so we must insert a \nobreak.
c94f48d7 5391 \nobreak\vskip\whatsitskip
82d5ce1d 5392 \fi
8fcb833a 5393\fi}
82d5ce1d
UD
5394
5395% The index entry written in the file actually looks like
5396% \entry {sortstring}{page}{topic}
5397% or
5398% \entry {sortstring}{page}{topic}{subtopic}
9e9f9cc2
KB
5399% The texindex program reads in these files and writes files
5400% containing these kinds of lines:
5401% \initial {c}
5402% before the first topic whose initial is c
5403% \entry {topic}{pagelist}
5404% for a topic that is used without subtopics
5405% \primary {topic}
5406% for the beginning of a topic that is used with subtopics
5407% \secondary {subtopic}{pagelist}
5408% for each subtopic.
5409
5410% Define the user-accessible indexing commands
5411% @findex, @vindex, @kindex, @cindex.
5412
5413\def\findex {\fnindex}
5414\def\kindex {\kyindex}
5415\def\cindex {\cpindex}
5416\def\vindex {\vrindex}
5417\def\tindex {\tpindex}
5418\def\pindex {\pgindex}
5419
5420\def\cindexsub {\begingroup\obeylines\cindexsub}
5421{\obeylines %
5422\gdef\cindexsub "#1" #2^^M{\endgroup %
5423\dosubind{cp}{#2}{#1}}}
5424
5425% Define the macros used in formatting output of the sorted index material.
5426
51702635
UD
5427% @printindex causes a particular index (the ??s file) to get printed.
5428% It does not print any chapter heading (usually an @unnumbered).
5429%
82d5ce1d 5430\parseargdef\printindex{\begingroup
ea6631a2 5431 \dobreak \chapheadingskip{10000}%
9e9f9cc2 5432 %
3b82ab1c 5433 \smallfonts \rm
ea6631a2 5434 \tolerance = 9500
c94f48d7 5435 \plainfrenchspacing
7158eae4 5436 \everypar = {}% don't want the \kern\-parindent from indentation suppression.
9e9f9cc2
KB
5437 %
5438 % See if the index file exists and is nonempty.
2eb45444
UD
5439 % Change catcode of @ here so that if the index file contains
5440 % \initial {@}
5441 % as its first line, TeX doesn't complain about mismatched braces
5442 % (because it thinks @} is a control sequence).
7f7dd1d3 5443 \catcode`\@ = 12
084e7d57
JM
5444 % See comment in \requireopenindexfile.
5445 \def\indexname{#1}\ifx\indexname\indexisfl\def\indexname{f1}\fi
5446 \openin 1 \jobname.\indexname s
9e9f9cc2
KB
5447 \ifeof 1
5448 % \enddoublecolumns gets confused if there is no text in the index,
5449 % and it loses the chapter title and the aux file entries for the
5450 % index. The easiest way to prevent this problem is to make sure
5451 % there is some text.
b710a6e2 5452 \putwordIndexNonexistent
7f7dd1d3 5453 \typeout{No file \jobname.\indexname s.}%
ea6631a2 5454 \else
084e7d57 5455 \catcode`\\ = 0
9e9f9cc2
KB
5456 %
5457 % If the index file exists but is empty, then \openin leaves \ifeof
5458 % false. We have to make TeX try to read something from the file, so
5459 % it can discover if there is anything in it.
084e7d57 5460 \read 1 to \thisline
9e9f9cc2 5461 \ifeof 1
b710a6e2 5462 \putwordIndexIsEmpty
9e9f9cc2 5463 \else
51702635
UD
5464 % Index files are almost Texinfo source, but we use \ as the escape
5465 % character. It would be better to use @, but that's too big a change
5466 % to make right now.
084e7d57
JM
5467 \def\indexbackslash{\ttbackslash}%
5468 \let\indexlbrace\{ % Likewise, set these sequences for braces
5469 \let\indexrbrace\} % used in the sort key.
51702635 5470 \begindoublecolumns
41d11b15 5471 \let\dotheinsertentrybox\dotheinsertentryboxwithpenalty
084e7d57
JM
5472 %
5473 % Read input from the index file line by line.
5474 \loopdo
41d11b15 5475 \ifeof1 \else
084e7d57 5476 \read 1 to \nextline
084e7d57 5477 \fi
41d11b15
JM
5478 %
5479 \indexinputprocessing
084e7d57
JM
5480 \thisline
5481 %
5482 \ifeof1\else
5483 \let\thisline\nextline
5484 \repeat
5485 %%
51702635 5486 \enddoublecolumns
9e9f9cc2
KB
5487 \fi
5488 \fi
5489 \closein 1
ea6631a2 5490\endgroup}
41d11b15
JM
5491\def\loopdo#1\repeat{\def\body{#1}\loopdoxxx}
5492\def\loopdoxxx{\let\next=\relax\body\let\next=\loopdoxxx\fi\next}
9e9f9cc2 5493
41d11b15
JM
5494\def\indexinputprocessing{%
5495 \ifeof1
5496 \let\firsttoken\relax
5497 \else
5498 \edef\act{\gdef\noexpand\firsttoken{\getfirsttoken\nextline}}%
5499 \act
5500 \fi
5501}
084e7d57
JM
5502\def\getfirsttoken#1{\expandafter\getfirsttokenx#1\endfirsttoken}
5503\long\def\getfirsttokenx#1#2\endfirsttoken{\noexpand#1}
5504
084e7d57 5505
9e9f9cc2
KB
5506% These macros are used by the sorted index file itself.
5507% Change them to control the appearance of the index.
5508
084e7d57
JM
5509{\catcode`\/=13 \catcode`\-=13 \catcode`\^=13 \catcode`\~=13 \catcode`\_=13
5510\catcode`\|=13 \catcode`\<=13 \catcode`\>=13 \catcode`\+=13 \catcode`\"=13
5511\catcode`\$=3
5512\gdef\initialglyphs{%
5513 % Some changes for non-alphabetic characters. Using the glyphs from the
5514 % math fonts looks more consistent than the typewriter font used elsewhere
5515 % for these characters.
5516 \def\indexbackslash{\math{\backslash}}%
5517 \let\\=\indexbackslash
5518 %
5519 % Can't get bold backslash so don't use bold forward slash
5520 \catcode`\/=13
5521 \def/{{\secrmnotbold \normalslash}}%
5522 \def-{{\normaldash\normaldash}}% en dash `--'
5523 \def^{{\chapbf \normalcaret}}%
5524 \def~{{\chapbf \normaltilde}}%
5525 \def\_{%
5526 \leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }%
5527 \def|{$\vert$}%
5528 \def<{$\less$}%
5529 \def>{$\gtr$}%
5530 \def+{$\normalplus$}%
5531}}
5532
5533\def\initial{%
5534 \bgroup
5535 \initialglyphs
5536 \initialx
5537}
5538
5539\def\initialx#1{%
313a1174
UD
5540 % Remove any glue we may have, we'll be inserting our own.
5541 \removelastskip
b710a6e2 5542 %
313a1174 5543 % We like breaks before the index initials, so insert a bonus.
084e7d57
JM
5544 % The glue before the bonus allows a little bit of space at the
5545 % bottom of a column to reduce an increase in inter-line spacing.
82d5ce1d 5546 \nobreak
084e7d57
JM
5547 \vskip 0pt plus 5\baselineskip
5548 \penalty -300
5549 \vskip 0pt plus -5\baselineskip
313a1174
UD
5550 %
5551 % Typeset the initial. Making this add up to a whole number of
5552 % baselineskips increases the chance of the dots lining up from column
5553 % to column. It still won't often be perfect, because of the stretch
5554 % we need before each entry, but it's better.
b710a6e2 5555 %
313a1174 5556 % No shrink because it confuses \balancecolumns.
084e7d57
JM
5557 \vskip 1.67\baselineskip plus 1\baselineskip
5558 \leftline{\secfonts \kern-0.05em \secbf #1}%
5559 % \secfonts is inside the argument of \leftline so that the change of
5560 % \baselineskip will not affect any glue inserted before the vbox that
5561 % \leftline creates.
313a1174
UD
5562 % Do our best not to break after the initial.
5563 \nobreak
82d5ce1d 5564 \vskip .33\baselineskip plus .1\baselineskip
084e7d57
JM
5565 \egroup % \initialglyphs
5566}
5567
5568\newdimen\entryrightmargin
5569\entryrightmargin=0pt
9e9f9cc2 5570
82d5ce1d
UD
5571% \entry typesets a paragraph consisting of the text (#1), dot leaders, and
5572% then page number (#2) flushed to the right margin. It is used for index
5573% and table of contents entries. The paragraph is indented by \leftskip.
9e9f9cc2 5574%
82d5ce1d
UD
5575\def\entry{%
5576 \begingroup
7f7dd1d3
JM
5577 %
5578 % For pdfTeX and XeTeX.
5579 % The redefinition of \domark stops marks being added in \pdflink to
5580 % preserve coloured links across page boundaries. Otherwise the marks
41d11b15 5581 % would get in the way of \lastbox in \insertentrybox.
7f7dd1d3 5582 \let\domark\relax
82d5ce1d
UD
5583 %
5584 % Start a new paragraph if necessary, so our assignments below can't
5585 % affect previous text.
5586 \par
5587 %
82d5ce1d
UD
5588 % No extra space above this paragraph.
5589 \parskip = 0in
5590 %
0f8bbd69
JM
5591 % When reading the text of entry, convert explicit line breaks
5592 % from @* into spaces. The user might give these in long section
5593 % titles, for instance.
5594 \def\*{\unskip\space\ignorespaces}%
084e7d57
JM
5595 \def\entrybreak{\hfil\break}% An undocumented command
5596 %
82d5ce1d
UD
5597 % Swallow the left brace of the text (first parameter):
5598 \afterassignment\doentry
5599 \let\temp =
5600}
0f8bbd69 5601\def\entrybreak{\unskip\space\ignorespaces}%
82d5ce1d 5602\def\doentry{%
084e7d57
JM
5603 % Save the text of the entry
5604 \global\setbox\boxA=\hbox\bgroup
82d5ce1d
UD
5605 \bgroup % Instead of the swallowed brace.
5606 \noindent
5607 \aftergroup\finishentry
5608 % And now comes the text of the entry.
084e7d57
JM
5609 % Not absorbing as a macro argument reduces the chance of problems
5610 % with catcodes occurring.
82d5ce1d 5611}
084e7d57
JM
5612{\catcode`\@=11
5613\gdef\finishentry#1{%
5614 \egroup % end box A
5615 \dimen@ = \wd\boxA % Length of text of entry
5616 \global\setbox\boxA=\hbox\bgroup\unhbox\boxA
82d5ce1d
UD
5617 % #1 is the page number.
5618 %
084e7d57
JM
5619 % Get the width of the page numbers, and only use
5620 % leaders if they are present.
5621 \global\setbox\boxB = \hbox{#1}%
5622 \ifdim\wd\boxB = 0pt
5623 \null\nobreak\hfill\ %
3b82ab1c 5624 \else
82d5ce1d 5625 %
82d5ce1d
UD
5626 \null\nobreak\indexdotfill % Have leaders before the page number.
5627 %
82d5ce1d 5628 \ifpdf
084e7d57 5629 \pdfgettoks#1.%
7f7dd1d3 5630 \hskip\skip\thinshrinkable\the\toksA
82d5ce1d 5631 \else
7f7dd1d3
JM
5632 \ifx\XeTeXrevision\thisisundefined
5633 \hskip\skip\thinshrinkable #1%
5634 \else
5635 \pdfgettoks#1.%
5636 \hskip\skip\thinshrinkable\the\toksA
5637 \fi
82d5ce1d 5638 \fi
3b82ab1c 5639 \fi
084e7d57
JM
5640 \egroup % end \boxA
5641 \ifdim\wd\boxB = 0pt
41d11b15 5642 \global\setbox\entrybox=\vbox{\unhbox\boxA}%
084e7d57 5643 \else
41d11b15 5644 \global\setbox\entrybox=\vbox\bgroup
084e7d57
JM
5645 % We want the text of the entries to be aligned to the left, and the
5646 % page numbers to be aligned to the right.
5647 %
7f7dd1d3 5648 \parindent = 0pt
084e7d57
JM
5649 \advance\leftskip by 0pt plus 1fil
5650 \advance\leftskip by 0pt plus -1fill
5651 \rightskip = 0pt plus -1fil
5652 \advance\rightskip by 0pt plus 1fill
5653 % Cause last line, which could consist of page numbers on their own
5654 % if the list of page numbers is long, to be aligned to the right.
5655 \parfillskip=0pt plus -1fill
5656 %
084e7d57
JM
5657 \advance\rightskip by \entryrightmargin
5658 % Determine how far we can stretch into the margin.
5659 % This allows, e.g., "Appendix H GNU Free Documentation License" to
5660 % fit on one line in @letterpaper format.
5661 \ifdim\entryrightmargin>2.1em
5662 \dimen@i=2.1em
5663 \else
5664 \dimen@i=0em
5665 \fi
5666 \advance \parfillskip by 0pt minus 1\dimen@i
5667 %
5668 \dimen@ii = \hsize
5669 \advance\dimen@ii by -1\leftskip
5670 \advance\dimen@ii by -1\entryrightmargin
5671 \advance\dimen@ii by 1\dimen@i
5672 \ifdim\wd\boxA > \dimen@ii % If the entry doesn't fit in one line
5673 \ifdim\dimen@ > 0.8\dimen@ii % due to long index text
41d11b15
JM
5674 % Try to split the text roughly evenly. \dimen@ will be the length of
5675 % the first line.
5676 \dimen@ = 0.7\dimen@
084e7d57 5677 \dimen@ii = \hsize
084e7d57 5678 \ifnum\dimen@>\dimen@ii
41d11b15
JM
5679 % If the entry is too long (for example, if it needs more than
5680 % two lines), use all the space in the first line.
084e7d57
JM
5681 \dimen@ = \dimen@ii
5682 \fi
5683 \advance\leftskip by 0pt plus 1fill % ragged right
5684 \advance \dimen@ by 1\rightskip
7f7dd1d3
JM
5685 \parshape = 2 0pt \dimen@ 0em \dimen@ii
5686 % Ideally we'd add a finite glue at the end of the first line only,
5687 % instead of using \parshape with explicit line lengths, but TeX
5688 % doesn't seem to provide a way to do such a thing.
5689 %
41d11b15
JM
5690 % Indent all lines but the first one.
5691 \advance\leftskip by 1em
5692 \advance\parindent by -1em
084e7d57 5693 \fi\fi
7f7dd1d3 5694 \indent % start paragraph
084e7d57
JM
5695 \unhbox\boxA
5696 %
5697 % Do not prefer a separate line ending with a hyphen to fewer lines.
5698 \finalhyphendemerits = 0
5699 %
5700 % Word spacing - no stretch
5701 \spaceskip=\fontdimen2\font minus \fontdimen4\font
5702 %
5703 \linepenalty=1000 % Discourage line breaks.
5704 \hyphenpenalty=5000 % Discourage hyphenation.
5705 %
5706 \par % format the paragraph
5707 \egroup % The \vbox
5708 \fi
82d5ce1d 5709 \endgroup
41d11b15 5710 \dotheinsertentrybox
084e7d57
JM
5711}}
5712
5713\newskip\thinshrinkable
5714\skip\thinshrinkable=.15em minus .15em
5715
41d11b15
JM
5716\newbox\entrybox
5717\def\insertentrybox{%
5718 \ourunvbox\entrybox
7f7dd1d3
JM
5719}
5720
41d11b15
JM
5721% default definition
5722\let\dotheinsertentrybox\insertentrybox
5723
7f7dd1d3
JM
5724% Use \lastbox to take apart vbox box by box, and add each sub-box
5725% to the current vertical list.
5726\def\ourunvbox#1{%
5727\bgroup % for local binding of \delayedbox
5728 % Remove the last box from box #1
5729 \global\setbox#1=\vbox{%
5730 \unvbox#1%
5731 \unskip % remove any glue
5732 \unpenalty
5733 \global\setbox\interbox=\lastbox
084e7d57 5734 }%
7f7dd1d3
JM
5735 \setbox\delayedbox=\box\interbox
5736 \ifdim\ht#1=0pt\else
5737 \ourunvbox#1 % Repeat on what's left of the box
5738 \nobreak
5739 \fi
5740 \box\delayedbox
5741\egroup
084e7d57 5742}
7f7dd1d3
JM
5743\newbox\delayedbox
5744\newbox\interbox
084e7d57 5745
084e7d57
JM
5746% Used from \printindex. \firsttoken should be the first token
5747% after the \entry. If it's not another \entry, we are at the last
5748% line of a group of index entries, so insert a penalty to discourage
7f7dd1d3 5749% widowed index entries.
41d11b15 5750\def\dotheinsertentryboxwithpenalty{%
084e7d57
JM
5751 \ifx\firsttoken\isentry
5752 \else
7f7dd1d3 5753 \penalty 9000
084e7d57 5754 \fi
41d11b15 5755 \insertentrybox
82d5ce1d 5756}
41d11b15 5757\def\isentry{\entry}%
9e9f9cc2 5758
9251c568 5759% Like plain.tex's \dotfill, except uses up at least 1 em.
084e7d57
JM
5760% The filll stretch here overpowers both the fil and fill stretch to push
5761% the page number to the right.
9e9f9cc2 5762\def\indexdotfill{\cleaders
084e7d57
JM
5763 \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1filll}
5764
9e9f9cc2
KB
5765
5766\def\primary #1{\line{#1\hfil}}
5767
5768\newskip\secondaryindent \secondaryindent=0.5cm
be1152ca
UD
5769\def\secondary#1#2{{%
5770 \parfillskip=0in
5771 \parskip=0in
5772 \hangindent=1in
5773 \hangafter=1
5774 \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill
5775 \ifpdf
5776 \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
5777 \else
7f7dd1d3
JM
5778 \ifx\XeTeXrevision\thisisundefined
5779 #2
5780 \else
5781 \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
5782 \fi
be1152ca
UD
5783 \fi
5784 \par
9e9f9cc2
KB
5785}}
5786
359a1d0b
KB
5787% Define two-column mode, which we use to typeset indexes.
5788% Adapted from the TeXbook, page 416, which is to say,
5789% the manmac.tex format used to print the TeXbook itself.
084e7d57 5790\catcode`\@=11 % private names
9e9f9cc2
KB
5791
5792\newbox\partialpage
9e9f9cc2 5793\newdimen\doublecolumnhsize
084e7d57
JM
5794
5795% Use inside an output routine to save \topmark and \firstmark
5796\def\savemarks{%
5797 \global\savedtopmark=\expandafter{\topmark }%
5798 \global\savedfirstmark=\expandafter{\firstmark }%
5799}
5800\newtoks\savedtopmark
5801\newtoks\savedfirstmark
5802
5803% Set \topmark and \firstmark for next time \output runs.
5804% Can't be run from withinside \output (because any material
5805% added while an output routine is active, including
5806% penalties, is saved for after it finishes). The page so far
5807% should be empty, otherwise what's on it will be thrown away.
5808\def\restoremarks{%
5809 \mark{\the\savedtopmark}%
5810 \bgroup\output = {%
5811 \setbox\dummybox=\box\PAGE
5812 }abc\eject\egroup
5813 % "abc" because output routine doesn't fire for a completely empty page.
5814 \mark{\the\savedfirstmark}%
5815}
9e9f9cc2 5816
359a1d0b 5817\def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
084e7d57
JM
5818 % If not much space left on page, start a new page.
5819 \ifdim\pagetotal>0.8\vsize\vfill\eject\fi
5820 %
9e9f9cc2 5821 % Grab any single-column material above us.
b710a6e2
UD
5822 \output = {%
5823 %
51702635
UD
5824 % Here is a possibility not foreseen in manmac: if we accumulate a
5825 % whole lot of material, we might end up calling this \output
5826 % routine twice in a row (see the doublecol-lose test, which is
5827 % essentially a couple of indexes with @setchapternewpage off). In
b710a6e2
UD
5828 % that case we just ship out what is in \partialpage with the normal
5829 % output routine. Generally, \partialpage will be empty when this
5830 % runs and this will be a no-op. See the indexspread.tex test case.
5831 \ifvoid\partialpage \else
5832 \onepageout{\pagecontents\partialpage}%
5833 \fi
51702635 5834 %
b710a6e2
UD
5835 \global\setbox\partialpage = \vbox{%
5836 % Unvbox the main output page.
5837 \unvbox\PAGE
5838 \kern-\topskip \kern\baselineskip
5839 }%
084e7d57 5840 \savemarks
b710a6e2
UD
5841 }%
5842 \eject % run that output routine to set \partialpage
084e7d57
JM
5843 \restoremarks
5844 %
5845 % We recover the two marks that the last output routine saved in order
5846 % to propagate the information in marks added around a chapter heading,
5847 % which could be otherwise be lost by the time the final page is output.
5848 %
9e9f9cc2 5849 %
51702635
UD
5850 % Use the double-column output routine for subsequent pages.
5851 \output = {\doublecolumnout}%
9e9f9cc2
KB
5852 %
5853 % Change the page size parameters. We could do this once outside this
5854 % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
5855 % format, but then we repeat the same computation. Repeating a couple
5856 % of assignments once per index is clearly meaningless for the
51702635 5857 % execution time, so we may as well do it in one place.
9e9f9cc2
KB
5858 %
5859 % First we halve the line length, less a little for the gutter between
5860 % the columns. We compute the gutter based on the line length, so it
5861 % changes automatically with the paper format. The magic constant
51702635
UD
5862 % below is chosen so that the gutter has the same value (well, +-<1pt)
5863 % as it did when we hard-coded it.
9e9f9cc2
KB
5864 %
5865 % We put the result in a separate register, \doublecolumhsize, so we
5866 % can restore it in \pagesofar, after \hsize itself has (potentially)
5867 % been clobbered.
5868 %
5869 \doublecolumnhsize = \hsize
5870 \advance\doublecolumnhsize by -.04154\hsize
5871 \divide\doublecolumnhsize by 2
5872 \hsize = \doublecolumnhsize
5873 %
41d11b15
JM
5874 % Double the \vsize as well.
5875 \advance\vsize by -\ht\partialpage
9e9f9cc2 5876 \vsize = 2\vsize
7f7dd1d3
JM
5877 %
5878 % For the benefit of balancing columns
5879 \advance\baselineskip by 0pt plus 0.5pt
9e9f9cc2 5880}
313a1174
UD
5881
5882% The double-column output routine for all double-column pages except
084e7d57 5883% the last, which is done by \balancecolumns.
b710a6e2 5884%
9e9f9cc2 5885\def\doublecolumnout{%
084e7d57 5886 %
359a1d0b
KB
5887 \splittopskip=\topskip \splitmaxdepth=\maxdepth
5888 % Get the available space for the double columns -- the normal
5889 % (undoubled) page height minus any material left over from the
5890 % previous page.
313a1174
UD
5891 \dimen@ = \vsize
5892 \divide\dimen@ by 2
5893 %
51702635 5894 % box0 will be the left-hand column, box2 the right.
41d11b15
JM
5895 \setbox0=\vsplit\PAGE to\dimen@ \setbox2=\vsplit\PAGE to\dimen@
5896 \global\advance\vsize by 2\ht\partialpage
359a1d0b 5897 \onepageout\pagesofar
41d11b15 5898 \unvbox\PAGE
51702635 5899 \penalty\outputpenalty
359a1d0b 5900}
366d6851
UD
5901%
5902% Re-output the contents of the output page -- any previous material,
5903% followed by the two boxes we just split, in box0 and box2.
359a1d0b 5904\def\pagesofar{%
359a1d0b 5905 \unvbox\partialpage
313a1174 5906 %
359a1d0b 5907 \hsize = \doublecolumnhsize
313a1174 5908 \wd0=\hsize \wd2=\hsize
7f7dd1d3 5909 \hbox to\txipagewidth{\box0\hfil\box2}%
359a1d0b 5910}
084e7d57
JM
5911
5912
5913% Finished with with double columns.
359a1d0b 5914\def\enddoublecolumns{%
c94f48d7
AJ
5915 % The following penalty ensures that the page builder is exercised
5916 % _before_ we change the output routine. This is necessary in the
5917 % following situation:
5918 %
5919 % The last section of the index consists only of a single entry.
5920 % Before this section, \pagetotal is less than \pagegoal, so no
5921 % break occurs before the last section starts. However, the last
5922 % section, consisting of \initial and the single \entry, does not
5923 % fit on the page and has to be broken off. Without the following
5924 % penalty the page builder will not be exercised until \eject
5925 % below, and by that time we'll already have changed the output
5926 % routine to the \balancecolumns version, so the next-to-last
5927 % double-column page will be processed with \balancecolumns, which
5928 % is wrong: The two columns will go to the main vertical list, with
5929 % the broken-off section in the recent contributions. As soon as
5930 % the output routine finishes, TeX starts reconsidering the page
5931 % break. The two columns and the broken-off section both fit on the
5932 % page, because the two columns now take up only half of the page
5933 % goal. When TeX sees \eject from below which follows the final
5934 % section, it invokes the new output routine that we've set after
5935 % \balancecolumns below; \onepageout will try to fit the two columns
7f7dd1d3 5936 % and the final section into the vbox of \txipageheight (see
c94f48d7
AJ
5937 % \pagebody), causing an overfull box.
5938 %
5939 % Note that glue won't work here, because glue does not exercise the
5940 % page builder, unlike penalties (see The TeXbook, pp. 280-281).
5941 \penalty0
5942 %
313a1174 5943 \output = {%
084e7d57
JM
5944 % Split the last of the double-column material.
5945 \savemarks
313a1174 5946 \balancecolumns
41d11b15
JM
5947 }%
5948 \eject % call the \output just set
5949 \ifdim\pagetotal=0pt
084e7d57 5950 % Having called \balancecolumns once, we do not
313a1174 5951 % want to call it again. Therefore, reset \output to its normal
084e7d57 5952 % definition right away.
313a1174 5953 \global\output = {\onepageout{\pagecontents\PAGE}}%
41d11b15
JM
5954 %
5955 \endgroup % started in \begindoublecolumns
5956 \restoremarks
5957 % Leave the double-column material on the current page, no automatic
5958 % page break.
5959 \box\balancedcolumns
5960 %
5961 % \pagegoal was set to the doubled \vsize above, since we restarted
5962 % the current page. We're now back to normal single-column
5963 % typesetting, so reset \pagegoal to the normal \vsize.
5964 \global\vsize = \txipageheight %
5965 \pagegoal = \txipageheight %
5966 \else
5967 % We had some left-over material. This might happen when \doublecolumnout
5968 % is called in \balancecolumns. Try again.
5969 \expandafter\enddoublecolumns
5970 \fi
359a1d0b 5971}
084e7d57
JM
5972\newbox\balancedcolumns
5973\setbox\balancedcolumns=\vbox{shouldnt see this}%
366d6851 5974%
084e7d57
JM
5975% Only called for the last of the double column material. \doublecolumnout
5976% does the others.
359a1d0b 5977\def\balancecolumns{%
41d11b15 5978 \setbox0 = \vbox{\unvbox\PAGE}% like \box255 but more efficient, see p.120.
359a1d0b
KB
5979 \dimen@ = \ht0
5980 \advance\dimen@ by \topskip
5981 \advance\dimen@ by-\baselineskip
7f7dd1d3 5982 \ifdim\dimen@<5\baselineskip
084e7d57
JM
5983 % Don't split a short final column in two.
5984 \setbox2=\vbox{}%
41d11b15 5985 \global\setbox\balancedcolumns=\vbox{\pagesofar}%
084e7d57
JM
5986 \else
5987 \divide\dimen@ by 2 % target to split to
5988 \dimen@ii = \dimen@
5989 \splittopskip = \topskip
7f7dd1d3 5990 % Loop until left column is at least as high as the right column.
084e7d57
JM
5991 {%
5992 \vbadness = 10000
5993 \loop
5994 \global\setbox3 = \copy0
5995 \global\setbox1 = \vsplit3 to \dimen@
7f7dd1d3 5996 \ifdim\ht1<\ht3
084e7d57
JM
5997 \global\advance\dimen@ by 1pt
5998 \repeat
5999 }%
7f7dd1d3 6000 % Now the left column is in box 1, and the right column in box 3.
41d11b15 6001 %
7f7dd1d3
JM
6002 % Check whether the left column has come out higher than the page itself.
6003 % (Note that we have doubled \vsize for the double columns, so
6004 % the actual height of the page is 0.5\vsize).
6005 \ifdim2\ht1>\vsize
41d11b15
JM
6006 % It appears that we have been called upon to balance too much material.
6007 % Output some of it with \doublecolumnout, leaving the rest on the page.
6008 \setbox\PAGE=\box0
6009 \doublecolumnout
084e7d57 6010 \else
7f7dd1d3
JM
6011 % Compare the heights of the two columns.
6012 \ifdim4\ht1>5\ht3
6013 % Column heights are too different, so don't make their bottoms
6014 % flush with each other.
6015 \setbox2=\vbox to \ht1 {\unvbox3\vfill}%
6016 \setbox0=\vbox to \ht1 {\unvbox1\vfill}%
6017 \else
6018 % Make column bottoms flush with each other.
6019 \setbox2=\vbox to\ht1{\unvbox3\unskip}%
6020 \setbox0=\vbox to\ht1{\unvbox1\unskip}%
6021 \fi
41d11b15 6022 \global\setbox\balancedcolumns=\vbox{\pagesofar}%
084e7d57
JM
6023 \fi
6024 \fi
313a1174 6025 %
9e9f9cc2 6026}
51702635 6027\catcode`\@ = \other
d66b7b41
KB
6028
6029
9e9f9cc2 6030\message{sectioning,}
13632cfc 6031% Chapters, sections, etc.
9e9f9cc2 6032
0f8bbd69
JM
6033% Let's start with @part.
6034\outer\parseargdef\part{\partzzz{#1}}
6035\def\partzzz#1{%
6036 \chapoddpage
6037 \null
6038 \vskip.3\vsize % move it down on the page a bit
6039 \begingroup
7f7dd1d3 6040 \noindent \titlefonts\rm #1\par % the text
0f8bbd69
JM
6041 \let\lastnode=\empty % no node to associate with
6042 \writetocentry{part}{#1}{}% but put it in the toc
6043 \headingsoff % no headline or footline on the part page
084e7d57
JM
6044 % This outputs a mark at the end of the page that clears \thischapter
6045 % and \thissection, as is done in \startcontents.
6046 \let\pchapsepmacro\relax
6047 \chapmacro{}{Yomitfromtoc}{}%
0f8bbd69
JM
6048 \chapoddpage
6049 \endgroup
6050}
6051
6052% \unnumberedno is an oxymoron. But we count the unnumbered
82d5ce1d
UD
6053% sections so that we can refer to them unambiguously in the pdf
6054% outlines by their "section number". We avoid collisions with chapter
6055% numbers by starting them at 10000. (If a document ever has 10000
6056% chapters, we're in trouble anyway, I'm sure.)
6057\newcount\unnumberedno \unnumberedno = 10000
51702635
UD
6058\newcount\chapno
6059\newcount\secno \secno=0
6060\newcount\subsecno \subsecno=0
6061\newcount\subsubsecno \subsubsecno=0
9e9f9cc2
KB
6062
6063% This counter is funny since it counts through charcodes of letters A, B, ...
51702635 6064\newcount\appendixno \appendixno = `\@
82d5ce1d 6065%
3b82ab1c 6066% \def\appendixletter{\char\the\appendixno}
82d5ce1d
UD
6067% We do the following ugly conditional instead of the above simple
6068% construct for the sake of pdftex, which needs the actual
3b82ab1c 6069% letter in the expansion, not just typeset.
82d5ce1d 6070%
3b82ab1c
UD
6071\def\appendixletter{%
6072 \ifnum\appendixno=`A A%
6073 \else\ifnum\appendixno=`B B%
6074 \else\ifnum\appendixno=`C C%
6075 \else\ifnum\appendixno=`D D%
6076 \else\ifnum\appendixno=`E E%
6077 \else\ifnum\appendixno=`F F%
6078 \else\ifnum\appendixno=`G G%
6079 \else\ifnum\appendixno=`H H%
6080 \else\ifnum\appendixno=`I I%
6081 \else\ifnum\appendixno=`J J%
6082 \else\ifnum\appendixno=`K K%
6083 \else\ifnum\appendixno=`L L%
6084 \else\ifnum\appendixno=`M M%
6085 \else\ifnum\appendixno=`N N%
6086 \else\ifnum\appendixno=`O O%
6087 \else\ifnum\appendixno=`P P%
6088 \else\ifnum\appendixno=`Q Q%
6089 \else\ifnum\appendixno=`R R%
6090 \else\ifnum\appendixno=`S S%
6091 \else\ifnum\appendixno=`T T%
6092 \else\ifnum\appendixno=`U U%
6093 \else\ifnum\appendixno=`V V%
6094 \else\ifnum\appendixno=`W W%
6095 \else\ifnum\appendixno=`X X%
6096 \else\ifnum\appendixno=`Y Y%
6097 \else\ifnum\appendixno=`Z Z%
6098 % The \the is necessary, despite appearances, because \appendixletter is
6099 % expanded while writing the .toc file. \char\appendixno is not
6100 % expandable, thus it is written literally, thus all appendixes come out
6101 % with the same letter (or @) in the toc without it.
6102 \else\char\the\appendixno
6103 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
6104 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
9e9f9cc2 6105
c94f48d7
AJ
6106% Each @chapter defines these (using marks) as the number+name, number
6107% and name of the chapter. Page headings and footings can use
6108% these. @section does likewise.
313a1174 6109\def\thischapter{}
c94f48d7
AJ
6110\def\thischapternum{}
6111\def\thischaptername{}
313a1174 6112\def\thissection{}
c94f48d7
AJ
6113\def\thissectionnum{}
6114\def\thissectionname{}
9e9f9cc2
KB
6115
6116\newcount\absseclevel % used to calculate proper heading level
82d5ce1d 6117\newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count
9e9f9cc2
KB
6118
6119% @raisesections: treat @section as chapter, @subsection as section, etc.
6120\def\raisesections{\global\advance\secbase by -1}
6121\let\up=\raisesections % original BFox name
6122
6123% @lowersections: treat @chapter as section, @section as subsection, etc.
6124\def\lowersections{\global\advance\secbase by 1}
6125\let\down=\lowersections % original BFox name
6126
82d5ce1d
UD
6127% we only have subsub.
6128\chardef\maxseclevel = 3
6129%
6130% A numbered section within an unnumbered changes to unnumbered too.
0f8bbd69
JM
6131% To achieve this, remember the "biggest" unnum. sec. we are currently in:
6132\chardef\unnlevel = \maxseclevel
82d5ce1d
UD
6133%
6134% Trace whether the current chapter is an appendix or not:
6135% \chapheadtype is "N" or "A", unnumbered chapters are ignored.
6136\def\chapheadtype{N}
6137
6138% Choose a heading macro
6139% #1 is heading type
6140% #2 is heading level
6141% #3 is text for heading
6142\def\genhead#1#2#3{%
6143 % Compute the abs. sec. level:
6144 \absseclevel=#2
6145 \advance\absseclevel by \secbase
6146 % Make sure \absseclevel doesn't fall outside the range:
6147 \ifnum \absseclevel < 0
6148 \absseclevel = 0
9e9f9cc2 6149 \else
82d5ce1d
UD
6150 \ifnum \absseclevel > 3
6151 \absseclevel = 3
6152 \fi
9e9f9cc2 6153 \fi
82d5ce1d
UD
6154 % The heading type:
6155 \def\headtype{#1}%
6156 \if \headtype U%
0f8bbd69
JM
6157 \ifnum \absseclevel < \unnlevel
6158 \chardef\unnlevel = \absseclevel
82d5ce1d 6159 \fi
9e9f9cc2 6160 \else
82d5ce1d
UD
6161 % Check for appendix sections:
6162 \ifnum \absseclevel = 0
6163 \edef\chapheadtype{\headtype}%
6164 \else
6165 \if \headtype A\if \chapheadtype N%
6166 \errmessage{@appendix... within a non-appendix chapter}%
6167 \fi\fi
6168 \fi
6169 % Check for numbered within unnumbered:
0f8bbd69 6170 \ifnum \absseclevel > \unnlevel
82d5ce1d
UD
6171 \def\headtype{U}%
6172 \else
0f8bbd69 6173 \chardef\unnlevel = 3
82d5ce1d 6174 \fi
9e9f9cc2 6175 \fi
82d5ce1d
UD
6176 % Now print the heading:
6177 \if \headtype U%
6178 \ifcase\absseclevel
6179 \unnumberedzzz{#3}%
6180 \or \unnumberedseczzz{#3}%
6181 \or \unnumberedsubseczzz{#3}%
6182 \or \unnumberedsubsubseczzz{#3}%
6183 \fi
9e9f9cc2 6184 \else
82d5ce1d
UD
6185 \if \headtype A%
6186 \ifcase\absseclevel
6187 \appendixzzz{#3}%
6188 \or \appendixsectionzzz{#3}%
6189 \or \appendixsubseczzz{#3}%
6190 \or \appendixsubsubseczzz{#3}%
6191 \fi
6192 \else
6193 \ifcase\absseclevel
6194 \chapterzzz{#3}%
6195 \or \seczzz{#3}%
6196 \or \numberedsubseczzz{#3}%
6197 \or \numberedsubsubseczzz{#3}%
6198 \fi
6199 \fi
9e9f9cc2 6200 \fi
82d5ce1d
UD
6201 \suppressfirstparagraphindent
6202}
6203
6204% an interface:
6205\def\numhead{\genhead N}
6206\def\apphead{\genhead A}
6207\def\unnmhead{\genhead U}
6208
6209% @chapter, @appendix, @unnumbered. Increment top-level counter, reset
6210% all lower-level sectioning counters to zero.
6211%
6212% Also set \chaplevelprefix, which we prepend to @float sequence numbers
6213% (e.g., figures), q.v. By default (before any chapter), that is empty.
6214\let\chaplevelprefix = \empty
6215%
6216\outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz
6217\def\chapterzzz#1{%
6218 % section resetting is \global in case the chapter is in a group, such
6219 % as an @include file.
6220 \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6221 \global\advance\chapno by 1
6222 %
6223 % Used for \float.
6224 \gdef\chaplevelprefix{\the\chapno.}%
6225 \resetallfloatnos
6226 %
0f8bbd69
JM
6227 % \putwordChapter can contain complex things in translations.
6228 \toks0=\expandafter{\putwordChapter}%
6229 \message{\the\toks0 \space \the\chapno}%
82d5ce1d
UD
6230 %
6231 % Write the actual heading.
6232 \chapmacro{#1}{Ynumbered}{\the\chapno}%
6233 %
6234 % So @section and the like are numbered underneath this chapter.
e0f86659
UD
6235 \global\let\section = \numberedsec
6236 \global\let\subsection = \numberedsubsec
6237 \global\let\subsubsection = \numberedsubsubsec
313a1174 6238}
9e9f9cc2 6239
0f8bbd69
JM
6240\outer\parseargdef\appendix{\apphead0{#1}} % normally calls appendixzzz
6241%
82d5ce1d
UD
6242\def\appendixzzz#1{%
6243 \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6244 \global\advance\appendixno by 1
6245 \gdef\chaplevelprefix{\appendixletter.}%
6246 \resetallfloatnos
6247 %
0f8bbd69
JM
6248 % \putwordAppendix can contain complex things in translations.
6249 \toks0=\expandafter{\putwordAppendix}%
6250 \message{\the\toks0 \space \appendixletter}%
82d5ce1d
UD
6251 %
6252 \chapmacro{#1}{Yappendix}{\appendixletter}%
6253 %
e0f86659
UD
6254 \global\let\section = \appendixsec
6255 \global\let\subsection = \appendixsubsec
6256 \global\let\subsubsection = \appendixsubsubsec
313a1174 6257}
9e9f9cc2 6258
0f8bbd69
JM
6259% normally unnmhead0 calls unnumberedzzz:
6260\outer\parseargdef\unnumbered{\unnmhead0{#1}}
82d5ce1d
UD
6261\def\unnumberedzzz#1{%
6262 \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
6263 \global\advance\unnumberedno by 1
6264 %
6265 % Since an unnumbered has no number, no prefix for figures.
6266 \global\let\chaplevelprefix = \empty
6267 \resetallfloatnos
e0f86659
UD
6268 %
6269 % This used to be simply \message{#1}, but TeX fully expands the
6270 % argument to \message. Therefore, if #1 contained @-commands, TeX
6271 % expanded them. For example, in `@unnumbered The @cite{Book}', TeX
6272 % expanded @cite (which turns out to cause errors because \cite is meant
6273 % to be executed, not expanded).
6274 %
6275 % Anyway, we don't want the fully-expanded definition of @cite to appear
6276 % as a result of the \message, we just want `@cite' itself. We use
6277 % \the<toks register> to achieve this: TeX expands \the<toks> only once,
6278 % simply yielding the contents of <toks register>. (We also do this for
6279 % the toc entries.)
82d5ce1d
UD
6280 \toks0 = {#1}%
6281 \message{(\the\toks0)}%
6282 %
6283 \chapmacro{#1}{Ynothing}{\the\unnumberedno}%
e0f86659 6284 %
e0f86659
UD
6285 \global\let\section = \unnumberedsec
6286 \global\let\subsection = \unnumberedsubsec
6287 \global\let\subsubsection = \unnumberedsubsubsec
313a1174 6288}
9e9f9cc2 6289
82d5ce1d
UD
6290% @centerchap is like @unnumbered, but the heading is centered.
6291\outer\parseargdef\centerchap{%
82d5ce1d
UD
6292 \let\centerparametersmaybe = \centerparameters
6293 \unnmhead0{#1}%
6294 \let\centerparametersmaybe = \relax
6295}
6296
6297% @top is like @unnumbered.
6298\let\top\unnumbered
6299
313a1174 6300% Sections.
0f8bbd69 6301%
82d5ce1d
UD
6302\outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
6303\def\seczzz#1{%
6304 \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
6305 \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}%
313a1174 6306}
9e9f9cc2 6307
0f8bbd69
JM
6308% normally calls appendixsectionzzz:
6309\outer\parseargdef\appendixsection{\apphead1{#1}}
82d5ce1d
UD
6310\def\appendixsectionzzz#1{%
6311 \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
6312 \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}%
313a1174 6313}
82d5ce1d 6314\let\appendixsec\appendixsection
9e9f9cc2 6315
0f8bbd69
JM
6316% normally calls unnumberedseczzz:
6317\outer\parseargdef\unnumberedsec{\unnmhead1{#1}}
82d5ce1d
UD
6318\def\unnumberedseczzz#1{%
6319 \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
6320 \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%
313a1174 6321}
9e9f9cc2 6322
313a1174 6323% Subsections.
0f8bbd69
JM
6324%
6325% normally calls numberedsubseczzz:
6326\outer\parseargdef\numberedsubsec{\numhead2{#1}}
82d5ce1d
UD
6327\def\numberedsubseczzz#1{%
6328 \global\subsubsecno=0 \global\advance\subsecno by 1
6329 \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}%
313a1174 6330}
9e9f9cc2 6331
0f8bbd69
JM
6332% normally calls appendixsubseczzz:
6333\outer\parseargdef\appendixsubsec{\apphead2{#1}}
82d5ce1d
UD
6334\def\appendixsubseczzz#1{%
6335 \global\subsubsecno=0 \global\advance\subsecno by 1
6336 \sectionheading{#1}{subsec}{Yappendix}%
6337 {\appendixletter.\the\secno.\the\subsecno}%
313a1174 6338}
9e9f9cc2 6339
0f8bbd69
JM
6340% normally calls unnumberedsubseczzz:
6341\outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}}
82d5ce1d
UD
6342\def\unnumberedsubseczzz#1{%
6343 \global\subsubsecno=0 \global\advance\subsecno by 1
6344 \sectionheading{#1}{subsec}{Ynothing}%
6345 {\the\unnumberedno.\the\secno.\the\subsecno}%
313a1174 6346}
9e9f9cc2 6347
313a1174 6348% Subsubsections.
0f8bbd69
JM
6349%
6350% normally numberedsubsubseczzz:
6351\outer\parseargdef\numberedsubsubsec{\numhead3{#1}}
82d5ce1d
UD
6352\def\numberedsubsubseczzz#1{%
6353 \global\advance\subsubsecno by 1
6354 \sectionheading{#1}{subsubsec}{Ynumbered}%
6355 {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}%
313a1174 6356}
9e9f9cc2 6357
0f8bbd69
JM
6358% normally appendixsubsubseczzz:
6359\outer\parseargdef\appendixsubsubsec{\apphead3{#1}}
82d5ce1d
UD
6360\def\appendixsubsubseczzz#1{%
6361 \global\advance\subsubsecno by 1
6362 \sectionheading{#1}{subsubsec}{Yappendix}%
6363 {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}%
313a1174 6364}
9e9f9cc2 6365
0f8bbd69
JM
6366% normally unnumberedsubsubseczzz:
6367\outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}}
82d5ce1d
UD
6368\def\unnumberedsubsubseczzz#1{%
6369 \global\advance\subsubsecno by 1
6370 \sectionheading{#1}{subsubsec}{Ynothing}%
6371 {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}%
313a1174 6372}
9e9f9cc2 6373
9e9f9cc2
KB
6374% These macros control what the section commands do, according
6375% to what kind of chapter we are in (ordinary, appendix, or unnumbered).
6376% Define them by default for a numbered chapter.
82d5ce1d
UD
6377\let\section = \numberedsec
6378\let\subsection = \numberedsubsec
6379\let\subsubsection = \numberedsubsubsec
9e9f9cc2
KB
6380
6381% Define @majorheading, @heading and @subheading
6382
82d5ce1d 6383\def\majorheading{%
e0f86659 6384 {\advance\chapheadingskip by 10pt \chapbreak }%
82d5ce1d
UD
6385 \parsearg\chapheadingzzz
6386}
9e9f9cc2 6387
82d5ce1d
UD
6388\def\chapheading{\chapbreak \parsearg\chapheadingzzz}
6389\def\chapheadingzzz#1{%
8fcb833a
JM
6390 \vbox{\chapfonts \raggedtitlesettings #1\par}%
6391 \nobreak\bigskip \nobreak
82d5ce1d
UD
6392 \suppressfirstparagraphindent
6393}
9e9f9cc2 6394
f2fec269 6395% @heading, @subheading, @subsubheading.
82d5ce1d
UD
6396\parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{}
6397 \suppressfirstparagraphindent}
6398\parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{}
6399 \suppressfirstparagraphindent}
6400\parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{}
6401 \suppressfirstparagraphindent}
9e9f9cc2
KB
6402
6403% These macros generate a chapter, section, etc. heading only
6404% (including whitespace, linebreaking, etc. around it),
6405% given all the information in convenient, parsed form.
6406
0f8bbd69 6407% Args are the skip and penalty (usually negative)
9e9f9cc2
KB
6408\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
6409
9e9f9cc2 6410% Parameter controlling skip before chapter headings (if needed)
474be527 6411\newskip\chapheadingskip
9e9f9cc2 6412
0f8bbd69 6413% Define plain chapter starts, and page on/off switching for it.
9e9f9cc2 6414\def\chapbreak{\dobreak \chapheadingskip {-4000}}
084e7d57
JM
6415
6416% Start a new page
9e9f9cc2 6417\def\chappager{\par\vfill\supereject}
084e7d57
JM
6418
6419% \chapoddpage - start on an odd page for a new chapter
c94f48d7
AJ
6420% Because \domark is called before \chapoddpage, the filler page will
6421% get the headings for the next chapter, which is wrong. But we don't
6422% care -- we just disable all headings on the filler page.
6423\def\chapoddpage{%
6424 \chappager
6425 \ifodd\pageno \else
6426 \begingroup
0f8bbd69
JM
6427 \headingsoff
6428 \null
c94f48d7
AJ
6429 \chappager
6430 \endgroup
6431 \fi
6432}
9e9f9cc2 6433
7f7dd1d3 6434\parseargdef\setchapternewpage{\csname CHAPPAG#1\endcsname}
9e9f9cc2 6435
313a1174 6436\def\CHAPPAGoff{%
793fde8a 6437\global\let\contentsalignmacro = \chappager
9e9f9cc2
KB
6438\global\let\pchapsepmacro=\chapbreak
6439\global\let\pagealignmacro=\chappager}
6440
313a1174 6441\def\CHAPPAGon{%
793fde8a 6442\global\let\contentsalignmacro = \chappager
9e9f9cc2
KB
6443\global\let\pchapsepmacro=\chappager
6444\global\let\pagealignmacro=\chappager
6445\global\def\HEADINGSon{\HEADINGSsingle}}
6446
82d5ce1d 6447\def\CHAPPAGodd{%
793fde8a 6448\global\let\contentsalignmacro = \chapoddpage
9e9f9cc2
KB
6449\global\let\pchapsepmacro=\chapoddpage
6450\global\let\pagealignmacro=\chapoddpage
6451\global\def\HEADINGSon{\HEADINGSdouble}}
6452
6453\CHAPPAGon
6454
084e7d57 6455% \chapmacro - Chapter opening.
82d5ce1d
UD
6456%
6457% #1 is the text, #2 is the section type (Ynumbered, Ynothing,
6458% Yappendix, Yomitfromtoc), #3 the chapter number.
084e7d57 6459% Not used for @heading series.
82d5ce1d
UD
6460%
6461% To test against our argument.
6462\def\Ynothingkeyword{Ynothing}
82d5ce1d 6463\def\Yappendixkeyword{Yappendix}
084e7d57 6464\def\Yomitfromtockeyword{Yomitfromtoc}
82d5ce1d
UD
6465%
6466\def\chapmacro#1#2#3{%
7f7dd1d3
JM
6467 \expandafter\ifx\thisenv\titlepage\else
6468 \checkenv{}% chapters, etc., should not start inside an environment.
6469 \fi
6470 % FIXME: \chapmacro is currently called from inside \titlepage when
6471 % \setcontentsaftertitlepage to print the "Table of Contents" heading, but
6472 % this should probably be done by \sectionheading with an option to print
6473 % in chapter size.
084e7d57 6474 %
c94f48d7
AJ
6475 % Insert the first mark before the heading break (see notes for \domark).
6476 \let\prevchapterdefs=\lastchapterdefs
6477 \let\prevsectiondefs=\lastsectiondefs
6478 \gdef\lastsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}%
6479 \gdef\thissection{}}%
6480 %
6481 \def\temptype{#2}%
6482 \ifx\temptype\Ynothingkeyword
6483 \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
6484 \gdef\thischapter{\thischaptername}}%
6485 \else\ifx\temptype\Yomitfromtockeyword
6486 \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
6487 \gdef\thischapter{}}%
6488 \else\ifx\temptype\Yappendixkeyword
6489 \toks0={#1}%
6490 \xdef\lastchapterdefs{%
6491 \gdef\noexpand\thischaptername{\the\toks0}%
6492 \gdef\noexpand\thischapternum{\appendixletter}%
0f8bbd69
JM
6493 % \noexpand\putwordAppendix avoids expanding indigestible
6494 % commands in some of the translations.
6495 \gdef\noexpand\thischapter{\noexpand\putwordAppendix{}
6496 \noexpand\thischapternum:
c94f48d7
AJ
6497 \noexpand\thischaptername}%
6498 }%
6499 \else
6500 \toks0={#1}%
6501 \xdef\lastchapterdefs{%
6502 \gdef\noexpand\thischaptername{\the\toks0}%
6503 \gdef\noexpand\thischapternum{\the\chapno}%
0f8bbd69
JM
6504 % \noexpand\putwordChapter avoids expanding indigestible
6505 % commands in some of the translations.
6506 \gdef\noexpand\thischapter{\noexpand\putwordChapter{}
6507 \noexpand\thischapternum:
c94f48d7
AJ
6508 \noexpand\thischaptername}%
6509 }%
6510 \fi\fi\fi
6511 %
6512 % Output the mark. Pass it through \safewhatsit, to take care of
6513 % the preceding space.
6514 \safewhatsit\domark
6515 %
6516 % Insert the chapter heading break.
9e9f9cc2 6517 \pchapsepmacro
c94f48d7
AJ
6518 %
6519 % Now the second mark, after the heading break. No break points
6520 % between here and the heading.
6521 \let\prevchapterdefs=\lastchapterdefs
6522 \let\prevsectiondefs=\lastsectiondefs
6523 \domark
6524 %
9e9f9cc2 6525 {%
7f7dd1d3 6526 \chapfonts \rm
084e7d57 6527 \let\footnote=\errfootnoteheading % give better error message
82d5ce1d 6528 %
c94f48d7 6529 % Have to define \lastsection before calling \donoderef, because the
82d5ce1d
UD
6530 % xref code eventually uses it. On the other hand, it has to be called
6531 % after \pchapsepmacro, or the headline will change too soon.
c94f48d7 6532 \gdef\lastsection{#1}%
82d5ce1d
UD
6533 %
6534 % Only insert the separating space if we have a chapter/appendix
6535 % number, and don't print the unnumbered ``number''.
82d5ce1d
UD
6536 \ifx\temptype\Ynothingkeyword
6537 \setbox0 = \hbox{}%
6538 \def\toctype{unnchap}%
82d5ce1d
UD
6539 \else\ifx\temptype\Yomitfromtockeyword
6540 \setbox0 = \hbox{}% contents like unnumbered, but no toc entry
6541 \def\toctype{omit}%
82d5ce1d
UD
6542 \else\ifx\temptype\Yappendixkeyword
6543 \setbox0 = \hbox{\putwordAppendix{} #3\enspace}%
6544 \def\toctype{app}%
82d5ce1d
UD
6545 \else
6546 \setbox0 = \hbox{#3\enspace}%
6547 \def\toctype{numchap}%
82d5ce1d
UD
6548 \fi\fi\fi
6549 %
6550 % Write the toc entry for this chapter. Must come before the
6551 % \donoderef, because we include the current node name in the toc
6552 % entry, and \donoderef resets it to empty.
6553 \writetocentry{\toctype}{#1}{#3}%
6554 %
6555 % For pdftex, we have to write out the node definition (aka, make
6556 % the pdfdest) after any page break, but before the actual text has
6557 % been typeset. If the destination for the pdf outline is after the
6558 % text, then jumping from the outline may wind up with the text not
6559 % being visible, for instance under high magnification.
6560 \donoderef{#2}%
6561 %
6562 % Typeset the actual heading.
c94f48d7 6563 \nobreak % Avoid page breaks at the interline glue.
8fcb833a 6564 \vbox{\raggedtitlesettings \hangindent=\wd0 \centerparametersmaybe
843be0d3 6565 \unhbox0 #1\par}%
9e9f9cc2 6566 }%
cd4e176c
KB
6567 \nobreak\bigskip % no page break after a chapter title
6568 \nobreak
9e9f9cc2
KB
6569}
6570
843be0d3
KB
6571% @centerchap -- centered and unnumbered.
6572\let\centerparametersmaybe = \relax
82d5ce1d
UD
6573\def\centerparameters{%
6574 \advance\rightskip by 3\rightskip
6575 \leftskip = \rightskip
6576 \parfillskip = 0pt
6577}
9e9f9cc2 6578
9e9f9cc2 6579
82d5ce1d
UD
6580% Section titles. These macros combine the section number parts and
6581% call the generic \sectionheading to do the printing.
6582%
474be527 6583\newskip\secheadingskip
82d5ce1d 6584\def\secheadingbreak{\dobreak \secheadingskip{-1000}}
cd4e176c
KB
6585
6586% Subsection titles.
82d5ce1d
UD
6587\newskip\subsecheadingskip
6588\def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}}
9e9f9cc2 6589
cd4e176c 6590% Subsubsection titles.
82d5ce1d
UD
6591\def\subsubsecheadingskip{\subsecheadingskip}
6592\def\subsubsecheadingbreak{\subsecheadingbreak}
9e9f9cc2 6593
9e9f9cc2 6594
82d5ce1d 6595% Print any size, any type, section title.
0ecb606c 6596%
084e7d57
JM
6597% #1 is the text of the title,
6598% #2 is the section level (sec/subsec/subsubsec),
6599% #3 is the section type (Ynumbered, Ynothing, Yappendix, Yomitfromtoc),
6600% #4 is the section number.
82d5ce1d 6601%
c94f48d7
AJ
6602\def\seckeyword{sec}
6603%
82d5ce1d 6604\def\sectionheading#1#2#3#4{%
cd4e176c 6605 {%
084e7d57
JM
6606 \def\sectionlevel{#2}%
6607 \def\temptype{#3}%
6608 %
6609 % It is ok for the @heading series commands to appear inside an
6610 % environment (it's been historically allowed, though the logic is
6611 % dubious), but not the others.
6612 \ifx\temptype\Yomitfromtockeyword\else
6613 \checkenv{}% non-@*heading should not be in an environment.
6614 \fi
6615 \let\footnote=\errfootnoteheading
0f8bbd69 6616 %
843be0d3 6617 % Switch to the right set of fonts.
7f7dd1d3 6618 \csname #2fonts\endcsname \rm
82d5ce1d 6619 %
c94f48d7
AJ
6620 % Insert first mark before the heading break (see notes for \domark).
6621 \let\prevsectiondefs=\lastsectiondefs
6622 \ifx\temptype\Ynothingkeyword
6623 \ifx\sectionlevel\seckeyword
6624 \gdef\lastsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}%
6625 \gdef\thissection{\thissectionname}}%
6626 \fi
6627 \else\ifx\temptype\Yomitfromtockeyword
6628 % Don't redefine \thissection.
6629 \else\ifx\temptype\Yappendixkeyword
6630 \ifx\sectionlevel\seckeyword
6631 \toks0={#1}%
6632 \xdef\lastsectiondefs{%
6633 \gdef\noexpand\thissectionname{\the\toks0}%
6634 \gdef\noexpand\thissectionnum{#4}%
0f8bbd69
JM
6635 % \noexpand\putwordSection avoids expanding indigestible
6636 % commands in some of the translations.
6637 \gdef\noexpand\thissection{\noexpand\putwordSection{}
6638 \noexpand\thissectionnum:
c94f48d7
AJ
6639 \noexpand\thissectionname}%
6640 }%
6641 \fi
6642 \else
6643 \ifx\sectionlevel\seckeyword
6644 \toks0={#1}%
6645 \xdef\lastsectiondefs{%
6646 \gdef\noexpand\thissectionname{\the\toks0}%
6647 \gdef\noexpand\thissectionnum{#4}%
0f8bbd69
JM
6648 % \noexpand\putwordSection avoids expanding indigestible
6649 % commands in some of the translations.
6650 \gdef\noexpand\thissection{\noexpand\putwordSection{}
6651 \noexpand\thissectionnum:
c94f48d7
AJ
6652 \noexpand\thissectionname}%
6653 }%
6654 \fi
6655 \fi\fi\fi
6656 %
0f8bbd69
JM
6657 % Go into vertical mode. Usually we'll already be there, but we
6658 % don't want the following whatsit to end up in a preceding paragraph
6659 % if the document didn't happen to have a blank line.
6660 \par
6661 %
c94f48d7
AJ
6662 % Output the mark. Pass it through \safewhatsit, to take care of
6663 % the preceding space.
6664 \safewhatsit\domark
6665 %
82d5ce1d
UD
6666 % Insert space above the heading.
6667 \csname #2headingbreak\endcsname
6668 %
c94f48d7
AJ
6669 % Now the second mark, after the heading break. No break points
6670 % between here and the heading.
21fea2e2 6671 \global\let\prevsectiondefs=\lastsectiondefs
c94f48d7 6672 \domark
82d5ce1d 6673 %
c94f48d7 6674 % Only insert the space after the number if we have a section number.
82d5ce1d
UD
6675 \ifx\temptype\Ynothingkeyword
6676 \setbox0 = \hbox{}%
6677 \def\toctype{unn}%
c94f48d7 6678 \gdef\lastsection{#1}%
82d5ce1d
UD
6679 \else\ifx\temptype\Yomitfromtockeyword
6680 % for @headings -- no section number, don't include in toc,
c94f48d7 6681 % and don't redefine \lastsection.
82d5ce1d
UD
6682 \setbox0 = \hbox{}%
6683 \def\toctype{omit}%
6684 \let\sectionlevel=\empty
6685 \else\ifx\temptype\Yappendixkeyword
6686 \setbox0 = \hbox{#4\enspace}%
6687 \def\toctype{app}%
c94f48d7 6688 \gdef\lastsection{#1}%
82d5ce1d
UD
6689 \else
6690 \setbox0 = \hbox{#4\enspace}%
6691 \def\toctype{num}%
c94f48d7 6692 \gdef\lastsection{#1}%
82d5ce1d 6693 \fi\fi\fi
0ecb606c 6694 %
9251c568 6695 % Write the toc entry (before \donoderef). See comments in \chapmacro.
82d5ce1d 6696 \writetocentry{\toctype\sectionlevel}{#1}{#4}%
0ecb606c 6697 %
82d5ce1d 6698 % Write the node reference (= pdf destination for pdftex).
9251c568 6699 % Again, see comments in \chapmacro.
82d5ce1d
UD
6700 \donoderef{#3}%
6701 %
9251c568
AJ
6702 % Interline glue will be inserted when the vbox is completed.
6703 % That glue will be a valid breakpoint for the page, since it'll be
6704 % preceded by a whatsit (usually from the \donoderef, or from the
6705 % \writetocentry if there was no node). We don't want to allow that
6706 % break, since then the whatsits could end up on page n while the
6707 % section is on page n+1, thus toc/etc. are wrong. Debian bug 276000.
6708 \nobreak
6709 %
82d5ce1d 6710 % Output the actual section heading.
0f8bbd69 6711 \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright
82d5ce1d
UD
6712 \hangindent=\wd0 % zero if no section number
6713 \unhbox0 #1}%
cd4e176c 6714 }%
82d5ce1d
UD
6715 % Add extra space after the heading -- half of whatever came above it.
6716 % Don't allow stretch, though.
6717 \kern .5 \csname #2headingskip\endcsname
6718 %
6719 % Do not let the kern be a potential breakpoint, as it would be if it
6720 % was followed by glue.
2f5b1124 6721 \nobreak
82d5ce1d
UD
6722 %
6723 % We'll almost certainly start a paragraph next, so don't let that
6724 % glue accumulate. (Not a breakpoint because it's preceded by a
8fcb833a
JM
6725 % discardable item.) However, when a paragraph is not started next
6726 % (\startdefun, \cartouche, \center, etc.), this needs to be wiped out
6727 % or the negative glue will cause weirdly wrong output, typically
6728 % obscuring the section heading with something else.
82d5ce1d 6729 \vskip-\parskip
0f8bbd69 6730 %
8fcb833a
JM
6731 % This is so the last item on the main vertical list is a known
6732 % \penalty > 10000, so \startdefun, etc., can recognize the situation
6733 % and do the needful.
82d5ce1d 6734 \penalty 10001
cd4e176c 6735}
9e9f9cc2
KB
6736
6737
313a1174 6738\message{toc,}
13632cfc 6739% Table of contents.
313a1174
UD
6740\newwrite\tocfile
6741
6742% Write an entry to the toc file, opening it if necessary.
82d5ce1d
UD
6743% Called from @chapter, etc.
6744%
6745% Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno}
6746% We append the current node name (if any) and page number as additional
6747% arguments for the \{chap,sec,...}entry macros which will eventually
6748% read this. The node name is used in the pdf outlines as the
6749% destination to jump to.
b710a6e2 6750%
e0f86659
UD
6751% We open the .toc file for writing here instead of at @setfilename (or
6752% any other fixed time) so that @contents can be anywhere in the document.
82d5ce1d
UD
6753% But if #1 is `omit', then we don't do anything. This is used for the
6754% table of contents chapter openings themselves.
b710a6e2 6755%
313a1174 6756\newif\iftocfileopened
82d5ce1d
UD
6757\def\omitkeyword{omit}%
6758%
e0f86659 6759\def\writetocentry#1#2#3{%
82d5ce1d
UD
6760 \edef\writetoctype{#1}%
6761 \ifx\writetoctype\omitkeyword \else
6762 \iftocfileopened\else
6763 \immediate\openout\tocfile = \jobname.toc
6764 \global\tocfileopenedtrue
6765 \fi
6766 %
6767 \iflinks
9251c568
AJ
6768 {\atdummies
6769 \edef\temp{%
6770 \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}%
6771 \temp
6772 }%
82d5ce1d 6773 \fi
e0f86659 6774 \fi
27692f89 6775 %
82d5ce1d
UD
6776 % Tell \shipout to create a pdf destination on each page, if we're
6777 % writing pdf. These are used in the table of contents. We can't
6778 % just write one on every page because the title pages are numbered
6779 % 1 and 2 (the page numbers aren't printed), and so are the first
6780 % two pages of the document. Thus, we'd have two destinations named
6781 % `1', and two named `2'.
7f7dd1d3
JM
6782 \ifpdf
6783 \global\pdfmakepagedesttrue
6784 \else
6785 \ifx\XeTeXrevision\thisisundefined
6786 \else
6787 \global\pdfmakepagedesttrue
6788 \fi
6789 \fi
313a1174
UD
6790}
6791
9251c568
AJ
6792
6793% These characters do not print properly in the Computer Modern roman
6794% fonts, so we must take special care. This is more or less redundant
6795% with the Texinfo input format setup at the end of this file.
0f8bbd69 6796%
9251c568
AJ
6797\def\activecatcodes{%
6798 \catcode`\"=\active
6799 \catcode`\$=\active
6800 \catcode`\<=\active
6801 \catcode`\>=\active
6802 \catcode`\\=\active
6803 \catcode`\^=\active
6804 \catcode`\_=\active
6805 \catcode`\|=\active
6806 \catcode`\~=\active
6807}
6808
6809
6810% Read the toc file, which is essentially Texinfo input.
6811\def\readtocfile{%
6812 \setupdatafile
6813 \activecatcodes
c94f48d7 6814 \input \tocreadfilename
9251c568
AJ
6815}
6816
61027f30
UD
6817\newskip\contentsrightmargin \contentsrightmargin=1in
6818\newcount\savepageno
6819\newcount\lastnegativepageno \lastnegativepageno = -1
6820
82d5ce1d 6821% Prepare to read what we've written to \tocfile.
b710a6e2 6822%
9e9f9cc2 6823\def\startcontents#1{%
82d5ce1d
UD
6824 % If @setchapternewpage on, and @headings double, the contents should
6825 % start on an odd page, unlike chapters. Thus, we maintain
6826 % \contentsalignmacro in parallel with \pagealignmacro.
6827 % From: Torbjorn Granlund <tege@matematik.su.se>
6828 \contentsalignmacro
6829 \immediate\closeout\tocfile
6830 %
6831 % Don't need to put `Contents' or `Short Contents' in the headline.
6832 % It is abundantly clear what they are.
82d5ce1d
UD
6833 \chapmacro{#1}{Yomitfromtoc}{}%
6834 %
6835 \savepageno = \pageno
6836 \begingroup % Set up to handle contents files properly.
9251c568 6837 \raggedbottom % Worry more about breakpoints than the bottom.
084e7d57 6838 \entryrightmargin=\contentsrightmargin % Don't use the full line length.
82d5ce1d
UD
6839 %
6840 % Roman numerals for page numbers.
6841 \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
9e9f9cc2
KB
6842}
6843
c94f48d7
AJ
6844% redefined for the two-volume lispref. We always output on
6845% \jobname.toc even if this is redefined.
0f8bbd69 6846%
c94f48d7 6847\def\tocreadfilename{\jobname.toc}
9e9f9cc2
KB
6848
6849% Normal (long) toc.
c94f48d7 6850%
313a1174 6851\def\contents{%
82d5ce1d 6852 \startcontents{\putwordTOC}%
c94f48d7 6853 \openin 1 \tocreadfilename\space
82d5ce1d 6854 \ifeof 1 \else
9251c568 6855 \readtocfile
82d5ce1d
UD
6856 \fi
6857 \vfill \eject
6858 \contentsalignmacro % in case @setchapternewpage odd is in effect
6859 \ifeof 1 \else
6860 \pdfmakeoutlines
6861 \fi
6862 \closein 1
6863 \endgroup
6864 \lastnegativepageno = \pageno
6865 \global\pageno = \savepageno
9e9f9cc2
KB
6866}
6867
6868% And just the chapters.
313a1174 6869\def\summarycontents{%
82d5ce1d
UD
6870 \startcontents{\putwordShortTOC}%
6871 %
0f8bbd69 6872 \let\partentry = \shortpartentry
82d5ce1d
UD
6873 \let\numchapentry = \shortchapentry
6874 \let\appentry = \shortchapentry
6875 \let\unnchapentry = \shortunnchapentry
6876 % We want a true roman here for the page numbers.
6877 \secfonts
6878 \let\rm=\shortcontrm \let\bf=\shortcontbf
6879 \let\sl=\shortcontsl \let\tt=\shortconttt
6880 \rm
6881 \hyphenpenalty = 10000
6882 \advance\baselineskip by 1pt % Open it up a little.
6883 \def\numsecentry##1##2##3##4{}
6884 \let\appsecentry = \numsecentry
6885 \let\unnsecentry = \numsecentry
6886 \let\numsubsecentry = \numsecentry
6887 \let\appsubsecentry = \numsecentry
6888 \let\unnsubsecentry = \numsecentry
6889 \let\numsubsubsecentry = \numsecentry
6890 \let\appsubsubsecentry = \numsecentry
6891 \let\unnsubsubsecentry = \numsecentry
c94f48d7 6892 \openin 1 \tocreadfilename\space
82d5ce1d 6893 \ifeof 1 \else
9251c568 6894 \readtocfile
82d5ce1d
UD
6895 \fi
6896 \closein 1
6897 \vfill \eject
6898 \contentsalignmacro % in case @setchapternewpage odd is in effect
6899 \endgroup
6900 \lastnegativepageno = \pageno
6901 \global\pageno = \savepageno
9e9f9cc2
KB
6902}
6903\let\shortcontents = \summarycontents
6904
82d5ce1d
UD
6905% Typeset the label for a chapter or appendix for the short contents.
6906% The arg is, e.g., `A' for an appendix, or `3' for a chapter.
6907%
6908\def\shortchaplabel#1{%
6909 % This space should be enough, since a single number is .5em, and the
6910 % widest letter (M) is 1em, at least in the Computer Modern fonts.
6911 % But use \hss just in case.
6912 % (This space doesn't include the extra space that gets added after
6913 % the label; that gets put in by \shortchapentry above.)
6914 %
6915 % We'd like to right-justify chapter numbers, but that looks strange
6916 % with appendix letters. And right-justifying numbers and
6917 % left-justifying letters looks strange when there is less than 10
6918 % chapters. Have to read the whole toc once to know how many chapters
6919 % there are before deciding ...
6920 \hbox to 1em{#1\hss}%
6921}
13632cfc 6922
9e9f9cc2
KB
6923% These macros generate individual entries in the table of contents.
6924% The first argument is the chapter or section name.
6925% The last argument is the page number.
6926% The arguments in between are the chapter number, section number, ...
6927
0f8bbd69
JM
6928% Parts, in the main contents. Replace the part number, which doesn't
6929% exist, with an empty box. Let's hope all the numbers have the same width.
6930% Also ignore the page number, which is conventionally not printed.
6931\def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}}
41d11b15
JM
6932\def\partentry#1#2#3#4{%
6933 % Add stretch and a bonus for breaking the page before the part heading.
6934 % This reduces the chance of the page being broken immediately after the
6935 % part heading, before a following chapter heading.
6936 \vskip 0pt plus 5\baselineskip
6937 \penalty-300
6938 \vskip 0pt plus -5\baselineskip
6939 \dochapentry{\numeralbox\labelspace#1}{}%
6940}
0f8bbd69
JM
6941%
6942% Parts, in the short toc.
6943\def\shortpartentry#1#2#3#4{%
6944 \penalty-300
6945 \vskip.5\baselineskip plus.15\baselineskip minus.1\baselineskip
6946 \shortchapentry{{\bf #1}}{\numeralbox}{}{}%
6947}
6948
7ed7ad59 6949% Chapters, in the main contents.
82d5ce1d 6950\def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}}
084e7d57 6951
7ed7ad59
UD
6952% Chapters, in the short toc.
6953% See comments in \dochapentry re vbox and related settings.
82d5ce1d
UD
6954\def\shortchapentry#1#2#3#4{%
6955 \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}%
9e9f9cc2
KB
6956}
6957
7ed7ad59 6958% Appendices, in the main contents.
82d5ce1d 6959% Need the word Appendix, and a fixed-size box.
3b82ab1c 6960%
82d5ce1d
UD
6961\def\appendixbox#1{%
6962 % We use M since it's probably the widest letter.
6963 \setbox0 = \hbox{\putwordAppendix{} M}%
6964 \hbox to \wd0{\putwordAppendix{} #1\hss}}
a334319f 6965%
084e7d57 6966\def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\hskip.7em#1}{#4}}
9e9f9cc2 6967
7ed7ad59 6968% Unnumbered chapters.
82d5ce1d
UD
6969\def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}}
6970\def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}}
9e9f9cc2
KB
6971
6972% Sections.
82d5ce1d
UD
6973\def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}}
6974\let\appsecentry=\numsecentry
6975\def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}}
9e9f9cc2
KB
6976
6977% Subsections.
82d5ce1d
UD
6978\def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}}
6979\let\appsubsecentry=\numsubsecentry
6980\def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}}
9e9f9cc2
KB
6981
6982% And subsubsections.
82d5ce1d
UD
6983\def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}}
6984\let\appsubsubsecentry=\numsubsubsecentry
6985\def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}}
9e9f9cc2 6986
9e9f9cc2 6987% This parameter controls the indentation of the various levels.
82d5ce1d
UD
6988% Same as \defaultparindent.
6989\newdimen\tocindent \tocindent = 15pt
9e9f9cc2
KB
6990
6991% Now for the actual typesetting. In all these, #1 is the text and #2 is the
6992% page number.
6993%
359a1d0b 6994% If the toc has to be broken over pages, we want it to be at chapters
9e9f9cc2
KB
6995% if at all possible; hence the \penalty.
6996\def\dochapentry#1#2{%
359a1d0b 6997 \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
9e9f9cc2 6998 \begingroup
084e7d57
JM
6999 % Move the page numbers slightly to the right
7000 \advance\entryrightmargin by -0.05em
9e9f9cc2 7001 \chapentryfonts
3b82ab1c 7002 \tocentry{#1}{\dopageno\bgroup#2\egroup}%
9e9f9cc2 7003 \endgroup
359a1d0b 7004 \nobreak\vskip .25\baselineskip plus.1\baselineskip
9e9f9cc2
KB
7005}
7006
7007\def\dosecentry#1#2{\begingroup
7008 \secentryfonts \leftskip=\tocindent
3b82ab1c 7009 \tocentry{#1}{\dopageno\bgroup#2\egroup}%
9e9f9cc2
KB
7010\endgroup}
7011
7012\def\dosubsecentry#1#2{\begingroup
7013 \subsecentryfonts \leftskip=2\tocindent
3b82ab1c 7014 \tocentry{#1}{\dopageno\bgroup#2\egroup}%
9e9f9cc2
KB
7015\endgroup}
7016
7017\def\dosubsubsecentry#1#2{\begingroup
7018 \subsubsecentryfonts \leftskip=3\tocindent
3b82ab1c 7019 \tocentry{#1}{\dopageno\bgroup#2\egroup}%
0f8bbd69
JM
7020\endgroup}
7021
7022% We use the same \entry macro as for the index entries.
7023\let\tocentry = \entry
7024
7025% Space between chapter (or whatever) number and the title.
7026\def\labelspace{\hskip1em \relax}
7027
7028\def\dopageno#1{{\rm #1}}
7029\def\doshortpageno#1{{\rm #1}}
7030
7031\def\chapentryfonts{\secfonts \rm}
7032\def\secentryfonts{\textfonts}
7033\def\subsecentryfonts{\textfonts}
7034\def\subsubsecentryfonts{\textfonts}
7035
9e9f9cc2 7036
0f8bbd69
JM
7037\message{environments,}
7038% @foo ... @end foo.
7039
7040% @tex ... @end tex escapes into raw TeX temporarily.
9e9f9cc2 7041% One exception: @ is still an escape character, so that @end tex works.
0f8bbd69 7042% But \@ or @@ will get a plain @ character.
9e9f9cc2 7043
82d5ce1d 7044\envdef\tex{%
0f8bbd69 7045 \setupmarkupstyle{tex}%
2eb45444
UD
7046 \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
7047 \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
e0f86659 7048 \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
2eb45444 7049 \catcode `\%=14
e0f86659
UD
7050 \catcode `\+=\other
7051 \catcode `\"=\other
e0f86659
UD
7052 \catcode `\|=\other
7053 \catcode `\<=\other
7054 \catcode `\>=\other
21fea2e2
JM
7055 \catcode `\`=\other
7056 \catcode `\'=\other
2eb45444 7057 %
0f8bbd69
JM
7058 % ' is active in math mode (mathcode"8000). So reset it, and all our
7059 % other math active characters (just in case), to plain's definitions.
7060 \mathactive
7061 %
084e7d57 7062 % Inverse of the list at the beginning of the file.
2eb45444
UD
7063 \let\b=\ptexb
7064 \let\bullet=\ptexbullet
7065 \let\c=\ptexc
7066 \let\,=\ptexcomma
7067 \let\.=\ptexdot
7068 \let\dots=\ptexdots
7069 \let\equiv=\ptexequiv
7070 \let\!=\ptexexclam
7071 \let\i=\ptexi
7158eae4 7072 \let\indent=\ptexindent
82d5ce1d 7073 \let\noindent=\ptexnoindent
2eb45444 7074 \let\{=\ptexlbrace
40c0dc53 7075 \let\+=\tabalign
2eb45444 7076 \let\}=\ptexrbrace
7158eae4 7077 \let\/=\ptexslash
084e7d57 7078 \let\sp=\ptexsp
2eb45444 7079 \let\*=\ptexstar
084e7d57 7080 %\let\sup=\ptexsup % do not redefine, we want @sup to work in math mode
2eb45444 7081 \let\t=\ptext
21fea2e2 7082 \expandafter \let\csname top\endcsname=\ptextop % we've made it outer
9251c568 7083 \let\frenchspacing=\plainfrenchspacing
2eb45444
UD
7084 %
7085 \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
7086 \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
7087 \def\@{@}%
82d5ce1d
UD
7088}
7089% There is no need to define \Etex.
9e9f9cc2 7090
27692f89 7091% Define @lisp ... @end lisp.
82d5ce1d 7092% @lisp environment forms a group so it can rebind things,
27692f89 7093% including the definition of @end lisp (which normally is erroneous).
9e9f9cc2
KB
7094
7095% Amount to narrow the margins by for @lisp.
7096\newskip\lispnarrowing \lispnarrowing=0.4in
7097
7098% This is the definition that ^^M gets inside @lisp, @example, and other
7099% such environments. \null is better than a space, since it doesn't
7100% have any width.
7101\def\lisppar{\null\endgraf}
7102
9e9f9cc2
KB
7103% This space is always present above and below environments.
7104\newskip\envskipamount \envskipamount = 0pt
7105
7106% Make spacing and below environment symmetrical. We use \parskip here
7107% to help in doing that, since in @example-like environments \parskip
7108% is reset to zero; thus the \afterenvbreak inserts no space -- but the
2f5b1124 7109% start of the next paragraph will insert \parskip.
9e9f9cc2 7110%
be1152ca 7111\def\aboveenvbreak{{%
084e7d57
JM
7112 % =10000 instead of <10000 because of a special case in \itemzzz and
7113 % \sectionheading, q.v.
7114 \ifnum \lastpenalty=10000 \else
7115 \advance\envskipamount by \parskip
7116 \endgraf
7117 \ifdim\lastskip<\envskipamount
7118 \removelastskip
7119 \ifnum\lastpenalty<10000
7120 % Penalize breaking before the environment, because preceding text
7121 % often leads into it.
7122 \penalty100
7123 \fi
7124 \vskip\envskipamount
7125 \fi
7126 \fi
7127}}
7128
7129\def\afterenvbreak{{%
82d5ce1d
UD
7130 % =10000 instead of <10000 because of a special case in \itemzzz and
7131 % \sectionheading, q.v.
2f5b1124 7132 \ifnum \lastpenalty=10000 \else
be1152ca
UD
7133 \advance\envskipamount by \parskip
7134 \endgraf
7135 \ifdim\lastskip<\envskipamount
7136 \removelastskip
2f5b1124
UD
7137 % it's not a good place to break if the last penalty was \nobreak
7138 % or better ...
82d5ce1d 7139 \ifnum\lastpenalty<10000 \penalty-50 \fi
be1152ca
UD
7140 \vskip\envskipamount
7141 \fi
7142 \fi
7143}}
9e9f9cc2 7144
9251c568
AJ
7145% \nonarrowing is a flag. If "set", @lisp etc don't narrow margins; it will
7146% also clear it, so that its embedded environments do the narrowing again.
9e9f9cc2
KB
7147\let\nonarrowing=\relax
7148
40c0dc53
UD
7149% @cartouche ... @end cartouche: draw rectangle w/rounded corners around
7150% environment contents.
9e9f9cc2
KB
7151\font\circle=lcircle10
7152\newdimen\circthick
7153\newdimen\cartouter\newdimen\cartinner
7154\newskip\normbskip\newskip\normpskip\newskip\normlskip
7155\circthick=\fontdimen8\circle
7156%
7157\def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
7158\def\ctr{{\hskip 6pt\circle\char'010}}
7159\def\cbl{{\circle\char'012\hskip -6pt}}
7160\def\cbr{{\hskip 6pt\circle\char'011}}
7161\def\carttop{\hbox to \cartouter{\hskip\lskip
2d07133b
KB
7162 \ctl\leaders\hrule height\circthick\hfil\ctr
7163 \hskip\rskip}}
9e9f9cc2 7164\def\cartbot{\hbox to \cartouter{\hskip\lskip
2d07133b
KB
7165 \cbl\leaders\hrule height\circthick\hfil\cbr
7166 \hskip\rskip}}
9e9f9cc2
KB
7167%
7168\newskip\lskip\newskip\rskip
7169
82d5ce1d
UD
7170\envdef\cartouche{%
7171 \ifhmode\par\fi % can't be in the midst of a paragraph.
7172 \startsavinginserts
7173 \lskip=\leftskip \rskip=\rightskip
7174 \leftskip=0pt\rightskip=0pt % we want these *outside*.
7175 \cartinner=\hsize \advance\cartinner by-\lskip
7176 \advance\cartinner by-\rskip
7177 \cartouter=\hsize
7178 \advance\cartouter by 18.4pt % allow for 3pt kerns on either
7179 % side, and for 6pt waste from
7180 % each corner char, and rule thickness
7181 \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
0f8bbd69
JM
7182 %
7183 % If this cartouche directly follows a sectioning command, we need the
7184 % \parskip glue (backspaced over by default) or the cartouche can
7185 % collide with the section heading.
8fcb833a 7186 \ifnum\lastpenalty>10000 \vskip\parskip \penalty\lastpenalty \fi
0f8bbd69 7187 %
084e7d57 7188 \setbox\groupbox=\vbox\bgroup
82d5ce1d
UD
7189 \baselineskip=0pt\parskip=0pt\lineskip=0pt
7190 \carttop
7191 \hbox\bgroup
7192 \hskip\lskip
7193 \vrule\kern3pt
7194 \vbox\bgroup
7195 \kern3pt
7196 \hsize=\cartinner
7197 \baselineskip=\normbskip
7198 \lineskip=\normlskip
7199 \parskip=\normpskip
7200 \vskip -\parskip
0f8bbd69 7201 \comment % For explanation, see the end of def\group.
82d5ce1d 7202}
9e9f9cc2 7203\def\Ecartouche{%
82d5ce1d
UD
7204 \ifhmode\par\fi
7205 \kern3pt
7206 \egroup
7207 \kern3pt\vrule
7208 \hskip\rskip
7209 \egroup
7210 \cartbot
7211 \egroup
084e7d57 7212 \addgroupbox
82d5ce1d
UD
7213 \checkinserts
7214}
9e9f9cc2
KB
7215
7216
7217% This macro is called at the beginning of all the @example variants,
7218% inside a group.
0f8bbd69 7219\newdimen\nonfillparindent
9e9f9cc2
KB
7220\def\nonfillstart{%
7221 \aboveenvbreak
8fcb833a 7222 \ifdim\hfuzz < 12pt \hfuzz = 12pt \fi % Don't be fussy
9e9f9cc2 7223 \sepspaces % Make spaces be word-separators rather than space tokens.
9e9f9cc2
KB
7224 \let\par = \lisppar % don't ignore blank lines
7225 \obeylines % each line of input is a line of output
7226 \parskip = 0pt
0f8bbd69
JM
7227 % Turn off paragraph indentation but redefine \indent to emulate
7228 % the normal \indent.
7229 \nonfillparindent=\parindent
9e9f9cc2 7230 \parindent = 0pt
0f8bbd69
JM
7231 \let\indent\nonfillindent
7232 %
9e9f9cc2 7233 \emergencystretch = 0pt % don't try to avoid overfull boxes
9e9f9cc2
KB
7234 \ifx\nonarrowing\relax
7235 \advance \leftskip by \lispnarrowing
7236 \exdentamount=\lispnarrowing
9251c568
AJ
7237 \else
7238 \let\nonarrowing = \relax
9e9f9cc2 7239 \fi
82d5ce1d 7240 \let\exdent=\nofillexdent
9e9f9cc2
KB
7241}
7242
0f8bbd69
JM
7243\begingroup
7244\obeyspaces
7245% We want to swallow spaces (but not other tokens) after the fake
7246% @indent in our nonfill-environments, where spaces are normally
7247% active and set to @tie, resulting in them not being ignored after
7248% @indent.
7249\gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}%
7250\gdef\nonfillindentcheck{%
7251\ifx\temp %
7252\expandafter\nonfillindentgobble%
7253\else%
7254\leavevmode\nonfillindentbox%
7255\fi%
7256}%
7257\endgroup
7258\def\nonfillindentgobble#1{\nonfillindent}
7259\def\nonfillindentbox{\hbox to \nonfillparindent{\hss}}
7260
82d5ce1d
UD
7261% If you want all examples etc. small: @set dispenvsize small.
7262% If you want even small examples the full size: @set dispenvsize nosmall.
7263% This affects the following displayed environments:
7264% @example, @display, @format, @lisp
a334319f 7265%
82d5ce1d
UD
7266\def\smallword{small}
7267\def\nosmallword{nosmall}
7268\let\SETdispenvsize\relax
7269\def\setnormaldispenv{%
7270 \ifx\SETdispenvsize\smallword
c94f48d7
AJ
7271 % end paragraph for sake of leading, in case document has no blank
7272 % line. This is redundant with what happens in \aboveenvbreak, but
7273 % we need to do it before changing the fonts, and it's inconvenient
7274 % to change the fonts afterward.
7275 \ifnum \lastpenalty=10000 \else \endgraf \fi
82d5ce1d
UD
7276 \smallexamplefonts \rm
7277 \fi
7278}
7279\def\setsmalldispenv{%
7280 \ifx\SETdispenvsize\nosmallword
7281 \else
c94f48d7 7282 \ifnum \lastpenalty=10000 \else \endgraf \fi
82d5ce1d
UD
7283 \smallexamplefonts \rm
7284 \fi
7285}
9e9f9cc2 7286
82d5ce1d 7287% We often define two environments, @foo and @smallfoo.
0f8bbd69
JM
7288% Let's do it in one command. #1 is the env name, #2 the definition.
7289\def\makedispenvdef#1#2{%
7290 \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}%
7291 \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}%
82d5ce1d
UD
7292 \expandafter\let\csname E#1\endcsname \afterenvbreak
7293 \expandafter\let\csname Esmall#1\endcsname \afterenvbreak
9e9f9cc2
KB
7294}
7295
0f8bbd69
JM
7296% Define two environment synonyms (#1 and #2) for an environment.
7297\def\maketwodispenvdef#1#2#3{%
7298 \makedispenvdef{#1}{#3}%
7299 \makedispenvdef{#2}{#3}%
82d5ce1d 7300}
0f8bbd69
JM
7301%
7302% @lisp: indented, narrowed, typewriter font;
7303% @example: same as @lisp.
82d5ce1d 7304%
e0f86659 7305% @smallexample and @smalllisp: use smaller fonts.
0c2b5752 7306% Originally contributed by Pavel@xerox.
82d5ce1d 7307%
0f8bbd69 7308\maketwodispenvdef{lisp}{example}{%
82d5ce1d 7309 \nonfillstart
0f8bbd69 7310 \tt\setupmarkupstyle{example}%
82d5ce1d 7311 \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
0f8bbd69 7312 \gobble % eat return
9e9f9cc2 7313}
82d5ce1d 7314% @display/@smalldisplay: same as @lisp except keep current font.
9e9f9cc2 7315%
0f8bbd69 7316\makedispenvdef{display}{%
9e9f9cc2 7317 \nonfillstart
9e9f9cc2
KB
7318 \gobble
7319}
0c2b5752 7320
82d5ce1d 7321% @format/@smallformat: same as @display except don't narrow margins.
a334319f 7322%
0f8bbd69 7323\makedispenvdef{format}{%
82d5ce1d 7324 \let\nonarrowing = t%
0ecb606c
JJ
7325 \nonfillstart
7326 \gobble
7327}
a334319f 7328
82d5ce1d
UD
7329% @flushleft: same as @format, but doesn't obey \SETdispenvsize.
7330\envdef\flushleft{%
7331 \let\nonarrowing = t%
7332 \nonfillstart
7333 \gobble
7334}
7335\let\Eflushleft = \afterenvbreak
0c2b5752
UD
7336
7337% @flushright.
b710a6e2 7338%
82d5ce1d
UD
7339\envdef\flushright{%
7340 \let\nonarrowing = t%
9e9f9cc2 7341 \nonfillstart
0f8bbd69 7342 \advance\leftskip by 0pt plus 1fill\relax
0c2b5752
UD
7343 \gobble
7344}
82d5ce1d 7345\let\Eflushright = \afterenvbreak
9e9f9cc2 7346
366d6851 7347
0f8bbd69 7348% @raggedright does more-or-less normal line breaking but no right
e66a8203
JM
7349% justification. From plain.tex. Don't stretch around special
7350% characters in urls in this environment, since the stretch at the right
7351% should be enough.
0f8bbd69 7352\envdef\raggedright{%
e66a8203
JM
7353 \rightskip0pt plus2.4em \spaceskip.3333em \xspaceskip.5em\relax
7354 \def\urefprestretchamount{0pt}%
7355 \def\urefpoststretchamount{0pt}%
0f8bbd69
JM
7356}
7357\let\Eraggedright\par
7358
7359\envdef\raggedleft{%
7360 \parindent=0pt \leftskip0pt plus2em
7361 \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
7362 \hbadness=10000 % Last line will usually be underfull, so turn off
7363 % badness reporting.
7364}
7365\let\Eraggedleft\par
7366
7367\envdef\raggedcenter{%
7368 \parindent=0pt \rightskip0pt plus1em \leftskip0pt plus1em
7369 \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
7370 \hbadness=10000 % Last line will usually be underfull, so turn off
7371 % badness reporting.
7372}
7373\let\Eraggedcenter\par
7374
7375
9e9f9cc2 7376% @quotation does normal linebreaking (hence we can't use \nonfillstart)
82d5ce1d
UD
7377% and narrows the margins. We keep \parskip nonzero in general, since
7378% we're doing normal filling. So, when using \aboveenvbreak and
7379% \afterenvbreak, temporarily make \parskip 0.
9e9f9cc2 7380%
0f8bbd69
JM
7381\makedispenvdef{quotation}{\quotationstart}
7382%
7383\def\quotationstart{%
8fcb833a 7384 \indentedblockstart % same as \indentedblock, but increase right margin too.
9e9f9cc2 7385 \ifx\nonarrowing\relax
9e9f9cc2 7386 \advance\rightskip by \lispnarrowing
9e9f9cc2 7387 \fi
82d5ce1d
UD
7388 \parsearg\quotationlabel
7389}
7390
7391% We have retained a nonzero parskip for the environment, since we're
7392% doing normal filling.
7393%
7394\def\Equotation{%
7395 \par
0f8bbd69 7396 \ifx\quotationauthor\thisisundefined\else
82d5ce1d
UD
7397 % indent a bit.
7398 \leftline{\kern 2\leftskip \sl ---\quotationauthor}%
7399 \fi
7400 {\parskip=0pt \afterenvbreak}%
7401}
0f8bbd69 7402\def\Esmallquotation{\Equotation}
82d5ce1d
UD
7403
7404% If we're given an argument, typeset it in bold with a colon after.
7405\def\quotationlabel#1{%
7406 \def\temp{#1}%
7407 \ifx\temp\empty \else
7408 {\bf #1: }%
7409 \fi
9e9f9cc2
KB
7410}
7411
8fcb833a
JM
7412% @indentedblock is like @quotation, but indents only on the left and
7413% has no optional argument.
7414%
7415\makedispenvdef{indentedblock}{\indentedblockstart}
7416%
7417\def\indentedblockstart{%
7418 {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
7419 \parindent=0pt
7420 %
7421 % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
7422 \ifx\nonarrowing\relax
7423 \advance\leftskip by \lispnarrowing
7424 \exdentamount = \lispnarrowing
7425 \else
7426 \let\nonarrowing = \relax
7427 \fi
7428}
7429
7430% Keep a nonzero parskip for the environment, since we're doing normal filling.
7431%
7432\def\Eindentedblock{%
7433 \par
7434 {\parskip=0pt \afterenvbreak}%
7435}
7436\def\Esmallindentedblock{\Eindentedblock}
7437
0c2b5752 7438
366d6851 7439% LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>}
7158eae4 7440% If we want to allow any <char> as delimiter,
366d6851
UD
7441% we need the curly braces so that makeinfo sees the @verb command, eg:
7442% `@verbx...x' would look like the '@verbx' command. --janneke@gnu.org
7443%
7444% [Knuth]: Donald Ervin Knuth, 1996. The TeXbook.
7445%
2f5b1124
UD
7446% [Knuth] p.344; only we need to do the other characters Texinfo sets
7447% active too. Otherwise, they get lost as the first character on a
7448% verbatim line.
366d6851 7449\def\dospecials{%
2f5b1124
UD
7450 \do\ \do\\\do\{\do\}\do\$\do\&%
7451 \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~%
7452 \do\<\do\>\do\|\do\@\do+\do\"%
0f8bbd69
JM
7453 % Don't do the quotes -- if we do, @set txicodequoteundirected and
7454 % @set txicodequotebacktick will not have effect on @verb and
7455 % @verbatim, and ?` and !` ligatures won't get disabled.
7456 %\do\`\do\'%
2f5b1124 7457}
366d6851
UD
7458%
7459% [Knuth] p. 380
7460\def\uncatcodespecials{%
82d5ce1d 7461 \def\do##1{\catcode`##1=\other}\dospecials}
366d6851 7462%
366d6851
UD
7463% Setup for the @verb command.
7464%
7465% Eight spaces for a tab
7466\begingroup
7467 \catcode`\^^I=\active
7468 \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }}
7469\endgroup
7470%
7471\def\setupverb{%
7472 \tt % easiest (and conventionally used) font for verbatim
7473 \def\par{\leavevmode\endgraf}%
0f8bbd69 7474 \setupmarkupstyle{verb}%
366d6851
UD
7475 \tabeightspaces
7476 % Respect line breaks,
7477 % print special symbols as themselves, and
7478 % make each space count
7479 % must do in this order:
7480 \obeylines \uncatcodespecials \sepspaces
7481}
7482
7483% Setup for the @verbatim environment
7484%
0f8bbd69 7485% Real tab expansion.
366d6851
UD
7486\newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
7487%
0f8bbd69
JM
7488% We typeset each line of the verbatim in an \hbox, so we can handle
7489% tabs. The \global is in case the verbatim line starts with an accent,
7490% or some other command that starts with a begin-group. Otherwise, the
7491% entire \verbbox would disappear at the corresponding end-group, before
7492% it is typeset. Meanwhile, we can't have nested verbatim commands
7493% (can we?), so the \global won't be overwriting itself.
7494\newbox\verbbox
7495\def\starttabbox{\global\setbox\verbbox=\hbox\bgroup}
9251c568 7496%
366d6851
UD
7497\begingroup
7498 \catcode`\^^I=\active
7499 \gdef\tabexpand{%
7500 \catcode`\^^I=\active
7501 \def^^I{\leavevmode\egroup
0f8bbd69
JM
7502 \dimen\verbbox=\wd\verbbox % the width so far, or since the previous tab
7503 \divide\dimen\verbbox by\tabw
7504 \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw
7505 \advance\dimen\verbbox by\tabw % advance to next multiple of \tabw
7506 \wd\verbbox=\dimen\verbbox \box\verbbox \starttabbox
366d6851
UD
7507 }%
7508 }
7509\endgroup
9251c568
AJ
7510
7511% start the verbatim environment.
366d6851 7512\def\setupverbatim{%
9251c568 7513 \let\nonarrowing = t%
82d5ce1d 7514 \nonfillstart
0f8bbd69
JM
7515 \tt % easiest (and conventionally used) font for verbatim
7516 % The \leavevmode here is for blank lines. Otherwise, we would
7517 % never \starttabox and the \egroup would end verbatim mode.
7518 \def\par{\leavevmode\egroup\box\verbbox\endgraf}%
366d6851 7519 \tabexpand
0f8bbd69 7520 \setupmarkupstyle{verbatim}%
366d6851
UD
7521 % Respect line breaks,
7522 % print special symbols as themselves, and
0f8bbd69
JM
7523 % make each space count.
7524 % Must do in this order:
366d6851
UD
7525 \obeylines \uncatcodespecials \sepspaces
7526 \everypar{\starttabbox}%
7527}
7528
7158eae4
UD
7529% Do the @verb magic: verbatim text is quoted by unique
7530% delimiter characters. Before first delimiter expect a
366d6851
UD
7531% right brace, after last delimiter expect closing brace:
7532%
7533% \def\doverb'{'<char>#1<char>'}'{#1}
7534%
7535% [Knuth] p. 382; only eat outer {}
7536\begingroup
82d5ce1d 7537 \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other
366d6851
UD
7538 \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next]
7539\endgroup
7540%
7541\def\verb{\begingroup\setupverb\doverb}
7542%
7543%
7544% Do the @verbatim magic: define the macro \doverbatim so that
7545% the (first) argument ends when '@end verbatim' is reached, ie:
7546%
7547% \def\doverbatim#1@end verbatim{#1}
7548%
7158eae4 7549% For Texinfo it's a lot easier than for LaTeX,
366d6851 7550% because texinfo's \verbatim doesn't stop at '\end{verbatim}':
2f5b1124 7551% we need not redefine '\', '{' and '}'.
366d6851
UD
7552%
7553% Inspired by LaTeX's verbatim command set [latex.ltx]
2f5b1124 7554%
366d6851
UD
7555\begingroup
7556 \catcode`\ =\active
2f5b1124
UD
7557 \obeylines %
7558 % ignore everything up to the first ^^M, that's the newline at the end
7559 % of the @verbatim input line itself. Otherwise we get an extra blank
7560 % line in the output.
82d5ce1d
UD
7561 \xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}%
7562 % We really want {...\end verbatim} in the body of the macro, but
7563 % without the active space; thus we have to use \xdef and \gobble.
366d6851
UD
7564\endgroup
7565%
82d5ce1d
UD
7566\envdef\verbatim{%
7567 \setupverbatim\doverbatim
366d6851 7568}
82d5ce1d
UD
7569\let\Everbatim = \afterenvbreak
7570
366d6851
UD
7571
7572% @verbatiminclude FILE - insert text of file in verbatim environment.
7573%
82d5ce1d 7574\def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude}
366d6851
UD
7575%
7576\def\doverbatiminclude#1{%
82d5ce1d
UD
7577 {%
7578 \makevalueexpandable
7579 \setupverbatim
0f8bbd69
JM
7580 \indexnofonts % Allow `@@' and other weird things in file names.
7581 \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}%
82d5ce1d
UD
7582 \input #1
7583 \afterenvbreak
7584 }%
366d6851
UD
7585}
7586
27692f89 7587% @copying ... @end copying.
82d5ce1d 7588% Save the text away for @insertcopying later.
7158eae4 7589%
2f5b1124
UD
7590% We save the uninterpreted tokens, rather than creating a box.
7591% Saving the text in a box would be much easier, but then all the
7592% typesetting commands (@smallbook, font changes, etc.) have to be done
7593% beforehand -- and a) we want @copying to be done first in the source
7594% file; b) letting users define the frontmatter in as flexible order as
084e7d57 7595% possible is desirable.
7158eae4 7596%
82d5ce1d
UD
7597\def\copying{\checkenv{}\begingroup\scanargctxt\docopying}
7598\def\docopying#1@end copying{\endgroup\def\copyingtext{#1}}
7599%
7600\def\insertcopying{%
7601 \begingroup
7602 \parindent = 0pt % paragraph indentation looks wrong on title page
7603 \scanexp\copyingtext
7604 \endgroup
2f5b1124 7605}
366d6851 7606
c94f48d7 7607
9e9f9cc2 7608\message{defuns,}
13632cfc
UD
7609% @defun etc.
7610
9e9f9cc2
KB
7611\newskip\defbodyindent \defbodyindent=.4in
7612\newskip\defargsindent \defargsindent=50pt
9e9f9cc2 7613\newskip\deflastargmargin \deflastargmargin=18pt
c94f48d7 7614\newcount\defunpenalty
9e9f9cc2 7615
82d5ce1d
UD
7616% Start the processing of @deffn:
7617\def\startdefun{%
7618 \ifnum\lastpenalty<10000
7619 \medbreak
c94f48d7
AJ
7620 \defunpenalty=10003 % Will keep this @deffn together with the
7621 % following @def command, see below.
2f5b1124 7622 \else
82d5ce1d
UD
7623 % If there are two @def commands in a row, we'll have a \nobreak,
7624 % which is there to keep the function description together with its
7625 % header. But if there's nothing but headers, we need to allow a
7626 % break somewhere. Check specifically for penalty 10002, inserted
c94f48d7 7627 % by \printdefunline, instead of 10000, since the sectioning
82d5ce1d
UD
7628 % commands also insert a nobreak penalty, and we don't want to allow
7629 % a break between a section heading and a defun.
c94f48d7 7630 %
0f8bbd69 7631 % As a further refinement, we avoid "club" headers by signalling
c94f48d7
AJ
7632 % with penalty of 10003 after the very first @deffn in the
7633 % sequence (see above), and penalty of 10002 after any following
7634 % @def command.
7635 \ifnum\lastpenalty=10002 \penalty2000 \else \defunpenalty=10002 \fi
82d5ce1d
UD
7636 %
7637 % Similarly, after a section heading, do not allow a break.
7638 % But do insert the glue.
7639 \medskip % preceded by discardable penalty, so not a breakpoint
2f5b1124
UD
7640 \fi
7641 %
27692f89
UD
7642 \parindent=0in
7643 \advance\leftskip by \defbodyindent
7644 \exdentamount=\defbodyindent
7645}
7646
82d5ce1d
UD
7647\def\dodefunx#1{%
7648 % First, check whether we are in the right environment:
7649 \checkenv#1%
0ecb606c 7650 %
82d5ce1d
UD
7651 % As above, allow line break if we have multiple x headers in a row.
7652 % It's not a great place, though.
c94f48d7 7653 \ifnum\lastpenalty=10002 \penalty3000 \else \defunpenalty=10002 \fi
82d5ce1d
UD
7654 %
7655 % And now, it's time to reuse the body of the original defun:
7656 \expandafter\gobbledefun#1%
2f5b1124 7657}
82d5ce1d 7658\def\gobbledefun#1\startdefun{}
2f5b1124 7659
82d5ce1d 7660% \printdefunline \deffnheader{text}
27692f89 7661%
82d5ce1d
UD
7662\def\printdefunline#1#2{%
7663 \begingroup
7664 % call \deffnheader:
7665 #1#2 \endheader
7666 % common ending:
7667 \interlinepenalty = 10000
0f8bbd69 7668 \advance\rightskip by 0pt plus 1fil\relax
82d5ce1d
UD
7669 \endgraf
7670 \nobreak\vskip -\parskip
c94f48d7 7671 \penalty\defunpenalty % signal to \startdefun and \dodefunx
82d5ce1d
UD
7672 % Some of the @defun-type tags do not enable magic parentheses,
7673 % rendering the following check redundant. But we don't optimize.
7674 \checkparencounts
7675 \endgroup
27692f89
UD
7676}
7677
82d5ce1d 7678\def\Edefun{\endgraf\medbreak}
9e9f9cc2 7679
82d5ce1d 7680% \makedefun{deffn} creates \deffn, \deffnx and \Edeffn;
0f8bbd69 7681% the only thing remaining is to define \deffnheader.
b710a6e2 7682%
82d5ce1d
UD
7683\def\makedefun#1{%
7684 \expandafter\let\csname E#1\endcsname = \Edefun
7685 \edef\temp{\noexpand\domakedefun
7686 \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}%
7687 \temp
27692f89 7688}
3b82ab1c 7689
084e7d57 7690% \domakedefun \deffn \deffnx \deffnheader { (defn. of \deffnheader) }
7158eae4 7691%
82d5ce1d
UD
7692% Define \deffn and \deffnx, without parameters.
7693% \deffnheader has to be defined explicitly.
10dc2a90 7694%
82d5ce1d
UD
7695\def\domakedefun#1#2#3{%
7696 \envdef#1{%
7697 \startdefun
0f8bbd69 7698 \doingtypefnfalse % distinguish typed functions from all else
82d5ce1d
UD
7699 \parseargusing\activeparens{\printdefunline#3}%
7700 }%
7701 \def#2{\dodefunx#1}%
7702 \def#3%
a334319f
UD
7703}
7704
0f8bbd69
JM
7705\newif\ifdoingtypefn % doing typed function?
7706\newif\ifrettypeownline % typeset return type on its own line?
7707
7708% @deftypefnnewline on|off says whether the return type of typed functions
7709% are printed on their own line. This affects @deftypefn, @deftypefun,
7710% @deftypeop, and @deftypemethod.
7711%
7712\parseargdef\deftypefnnewline{%
7713 \def\temp{#1}%
7714 \ifx\temp\onword
7715 \expandafter\let\csname SETtxideftypefnnl\endcsname
7716 = \empty
7717 \else\ifx\temp\offword
7718 \expandafter\let\csname SETtxideftypefnnl\endcsname
7719 = \relax
7720 \else
7721 \errhelp = \EMsimple
7722 \errmessage{Unknown @txideftypefnnl value `\temp',
7723 must be on|off}%
7724 \fi\fi
7725}
7726
7727% Untyped functions:
27692f89 7728
82d5ce1d
UD
7729% @deffn category name args
7730\makedefun{deffn}{\deffngeneral{}}
9e9f9cc2 7731
82d5ce1d
UD
7732% @deffn category class name args
7733\makedefun{defop}#1 {\defopon{#1\ \putwordon}}
9e9f9cc2 7734
82d5ce1d
UD
7735% \defopon {category on}class name args
7736\def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
9e9f9cc2 7737
82d5ce1d 7738% \deffngeneral {subind}category name args
a334319f 7739%
82d5ce1d
UD
7740\def\deffngeneral#1#2 #3 #4\endheader{%
7741 % Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}.
7742 \dosubind{fn}{\code{#3}}{#1}%
7743 \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
a334319f 7744}
9e9f9cc2 7745
0f8bbd69 7746% Typed functions:
9e9f9cc2 7747
82d5ce1d
UD
7748% @deftypefn category type name args
7749\makedefun{deftypefn}{\deftypefngeneral{}}
9e9f9cc2 7750
82d5ce1d
UD
7751% @deftypeop category class type name args
7752\makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}}
9e9f9cc2 7753
82d5ce1d
UD
7754% \deftypeopon {category on}class type name args
7755\def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
a334319f 7756
82d5ce1d
UD
7757% \deftypefngeneral {subind}category type name args
7758%
7759\def\deftypefngeneral#1#2 #3 #4 #5\endheader{%
7760 \dosubind{fn}{\code{#4}}{#1}%
0f8bbd69 7761 \doingtypefntrue
82d5ce1d 7762 \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
9e9f9cc2
KB
7763}
7764
0f8bbd69 7765% Typed variables:
a334319f 7766
82d5ce1d
UD
7767% @deftypevr category type var args
7768\makedefun{deftypevr}{\deftypecvgeneral{}}
9e9f9cc2 7769
82d5ce1d
UD
7770% @deftypecv category class type var args
7771\makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}}
9e9f9cc2 7772
82d5ce1d
UD
7773% \deftypecvof {category of}class type var args
7774\def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} }
9e9f9cc2 7775
82d5ce1d
UD
7776% \deftypecvgeneral {subind}category type var args
7777%
7778\def\deftypecvgeneral#1#2 #3 #4 #5\endheader{%
7779 \dosubind{vr}{\code{#4}}{#1}%
7780 \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
9e9f9cc2
KB
7781}
7782
0f8bbd69 7783% Untyped variables:
9e9f9cc2 7784
82d5ce1d
UD
7785% @defvr category var args
7786\makedefun{defvr}#1 {\deftypevrheader{#1} {} }
a334319f 7787
82d5ce1d
UD
7788% @defcv category class var args
7789\makedefun{defcv}#1 {\defcvof{#1\ \putwordof}}
a334319f 7790
82d5ce1d
UD
7791% \defcvof {category of}class var args
7792\def\defcvof#1#2 {\deftypecvof{#1}#2 {} }
9e9f9cc2 7793
0f8bbd69
JM
7794% Types:
7795
82d5ce1d
UD
7796% @deftp category name args
7797\makedefun{deftp}#1 #2 #3\endheader{%
7798 \doind{tp}{\code{#2}}%
7799 \defname{#1}{}{#2}\defunargs{#3\unskip}%
9e9f9cc2
KB
7800}
7801
82d5ce1d
UD
7802% Remaining @defun-like shortcuts:
7803\makedefun{defun}{\deffnheader{\putwordDeffunc} }
7804\makedefun{defmac}{\deffnheader{\putwordDefmac} }
7805\makedefun{defspec}{\deffnheader{\putwordDefspec} }
7806\makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} }
7807\makedefun{defvar}{\defvrheader{\putwordDefvar} }
7808\makedefun{defopt}{\defvrheader{\putwordDefopt} }
7809\makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} }
7810\makedefun{defmethod}{\defopon\putwordMethodon}
7811\makedefun{deftypemethod}{\deftypeopon\putwordMethodon}
7812\makedefun{defivar}{\defcvof\putwordInstanceVariableof}
7813\makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof}
9e9f9cc2 7814
82d5ce1d
UD
7815% \defname, which formats the name of the @def (not the args).
7816% #1 is the category, such as "Function".
7817% #2 is the return type, if any.
7818% #3 is the function name.
13632cfc 7819%
82d5ce1d 7820% We are followed by (but not passed) the arguments, if any.
13632cfc 7821%
82d5ce1d 7822\def\defname#1#2#3{%
0f8bbd69 7823 \par
82d5ce1d
UD
7824 % Get the values of \leftskip and \rightskip as they were outside the @def...
7825 \advance\leftskip by -\defbodyindent
7826 %
0f8bbd69
JM
7827 % Determine if we are typesetting the return type of a typed function
7828 % on a line by itself.
7829 \rettypeownlinefalse
7830 \ifdoingtypefn % doing a typed function specifically?
7831 % then check user option for putting return type on its own line:
7832 \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else
7833 \rettypeownlinetrue
7834 \fi
7835 \fi
7836 %
7837 % How we'll format the category name. Putting it in brackets helps
82d5ce1d
UD
7838 % distinguish it from the body text that may end up on the next line
7839 % just below it.
7840 \def\temp{#1}%
7841 \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
7842 %
0f8bbd69
JM
7843 % Figure out line sizes for the paragraph shape. We'll always have at
7844 % least two.
7845 \tempnum = 2
7846 %
82d5ce1d
UD
7847 % The first line needs space for \box0; but if \rightskip is nonzero,
7848 % we need only space for the part of \box0 which exceeds it:
7849 \dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip
0f8bbd69
JM
7850 %
7851 % If doing a return type on its own line, we'll have another line.
7852 \ifrettypeownline
7853 \advance\tempnum by 1
7854 \def\maybeshapeline{0in \hsize}%
7855 \else
7856 \def\maybeshapeline{}%
7857 \fi
7858 %
82d5ce1d
UD
7859 % The continuations:
7860 \dimen2=\hsize \advance\dimen2 by -\defargsindent
82d5ce1d 7861 %
0f8bbd69
JM
7862 % The final paragraph shape:
7863 \parshape \tempnum 0in \dimen0 \maybeshapeline \defargsindent \dimen2
7864 %
7865 % Put the category name at the right margin.
82d5ce1d
UD
7866 \noindent
7867 \hbox to 0pt{%
7868 \hfil\box0 \kern-\hsize
7869 % \hsize has to be shortened this way:
7870 \kern\leftskip
7871 % Intentionally do not respect \rightskip, since we need the space.
7872 }%
7873 %
7874 % Allow all lines to be underfull without complaint:
7875 \tolerance=10000 \hbadness=10000
7876 \exdentamount=\defbodyindent
7877 {%
7878 % defun fonts. We use typewriter by default (used to be bold) because:
7879 % . we're printing identifiers, they should be in tt in principle.
7880 % . in languages with many accents, such as Czech or French, it's
7881 % common to leave accents off identifiers. The result looks ok in
7882 % tt, but exceedingly strange in rm.
7883 % . we don't want -- and --- to be treated as ligatures.
7884 % . this still does not fix the ?` and !` ligatures, but so far no
7885 % one has made identifiers using them :).
7886 \df \tt
0f8bbd69
JM
7887 \def\temp{#2}% text of the return type
7888 \ifx\temp\empty\else
7889 \tclose{\temp}% typeset the return type
7890 \ifrettypeownline
7891 % put return type on its own line; prohibit line break following:
7892 \hfil\vadjust{\nobreak}\break
7893 \else
7894 \space % type on same line, so just followed by a space
7895 \fi
7896 \fi % no return type
82d5ce1d
UD
7897 #3% output function name
7898 }%
7f7dd1d3 7899 {\rm\enskip}% hskip 0.5 em of \rmfont
82d5ce1d
UD
7900 %
7901 \boldbrax
7902 % arguments will be output next, if any.
9e9f9cc2
KB
7903}
7904
82d5ce1d
UD
7905% Print arguments in slanted roman (not ttsl), inconsistently with using
7906% tt for the name. This is because literal text is sometimes needed in
7907% the argument list (groff manual), and ttsl and tt are not very
7908% distinguishable. Prevent hyphenation at `-' chars.
a334319f 7909%
82d5ce1d
UD
7910\def\defunargs#1{%
7911 % use sl by default (not ttsl),
7912 % tt for the names.
7913 \df \sl \hyphenchar\font=0
7914 %
7915 % On the other hand, if an argument has two dashes (for instance), we
8fcb833a
JM
7916 % want a way to get ttsl. We used to recommend @var for that, so
7917 % leave the code in, but it's strange for @var to lead to typewriter.
7918 % Nowadays we recommend @code, since the difference between a ttsl hyphen
7919 % and a tt hyphen is pretty tiny. @code also disables ?` !`.
0f8bbd69 7920 \def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}%
82d5ce1d
UD
7921 #1%
7922 \sl\hyphenchar\font=45
3b82ab1c
UD
7923}
7924
82d5ce1d 7925% We want ()&[] to print specially on the defun line.
a334319f 7926%
82d5ce1d
UD
7927\def\activeparens{%
7928 \catcode`\(=\active \catcode`\)=\active
7929 \catcode`\[=\active \catcode`\]=\active
7930 \catcode`\&=\active
ebbad4cc
UD
7931}
7932
82d5ce1d
UD
7933% Make control sequences which act like normal parenthesis chars.
7934\let\lparen = ( \let\rparen = )
9e9f9cc2 7935
82d5ce1d
UD
7936% Be sure that we always have a definition for `(', etc. For example,
7937% if the fn name has parens in it, \boldbrax will not be in effect yet,
7938% so TeX would otherwise complain about undefined control sequence.
7939{
7940 \activeparens
7941 \global\let(=\lparen \global\let)=\rparen
7942 \global\let[=\lbrack \global\let]=\rbrack
7943 \global\let& = \&
9e9f9cc2 7944
82d5ce1d
UD
7945 \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
7946 \gdef\magicamp{\let&=\amprm}
7947}
c37cd439 7948\let\ampchar\&
9e9f9cc2 7949
82d5ce1d 7950\newcount\parencount
9e9f9cc2 7951
82d5ce1d
UD
7952% If we encounter &foo, then turn on ()-hacking afterwards
7953\newif\ifampseen
7954\def\amprm#1 {\ampseentrue{\bf\&#1 }}
7955
7956\def\parenfont{%
7957 \ifampseen
7958 % At the first level, print parens in roman,
7959 % otherwise use the default font.
7960 \ifnum \parencount=1 \rm \fi
7961 \else
7962 % The \sf parens (in \boldbrax) actually are a little bolder than
7963 % the contained text. This is especially needed for [ and ] .
7964 \sf
7965 \fi
9e9f9cc2 7966}
82d5ce1d
UD
7967\def\infirstlevel#1{%
7968 \ifampseen
7969 \ifnum\parencount=1
7970 #1%
7971 \fi
7972 \fi
9e9f9cc2 7973}
82d5ce1d 7974\def\bfafterword#1 {#1 \bf}
9e9f9cc2 7975
82d5ce1d
UD
7976\def\opnr{%
7977 \global\advance\parencount by 1
7978 {\parenfont(}%
7979 \infirstlevel \bfafterword
0ecb606c 7980}
82d5ce1d
UD
7981\def\clnr{%
7982 {\parenfont)}%
7983 \infirstlevel \sl
7984 \global\advance\parencount by -1
0ecb606c 7985}
a334319f 7986
82d5ce1d
UD
7987\newcount\brackcount
7988\def\lbrb{%
7989 \global\advance\brackcount by 1
7990 {\bf[}%
7991}
7992\def\rbrb{%
7993 {\bf]}%
7994 \global\advance\brackcount by -1
0ecb606c 7995}
9e9f9cc2 7996
82d5ce1d
UD
7997\def\checkparencounts{%
7998 \ifnum\parencount=0 \else \badparencount \fi
7999 \ifnum\brackcount=0 \else \badbrackcount \fi
8000}
c94f48d7
AJ
8001% these should not use \errmessage; the glibc manual, at least, actually
8002% has such constructs (when documenting function pointers).
82d5ce1d 8003\def\badparencount{%
c94f48d7 8004 \message{Warning: unbalanced parentheses in @def...}%
82d5ce1d
UD
8005 \global\parencount=0
8006}
8007\def\badbrackcount{%
c94f48d7 8008 \message{Warning: unbalanced square brackets in @def...}%
82d5ce1d
UD
8009 \global\brackcount=0
8010}
a334319f 8011
d66b7b41 8012
f962d792
UD
8013\message{macros,}
8014% @macro.
f962d792 8015
b710a6e2 8016% To do this right we need a feature of e-TeX, \scantokens,
0c2b5752 8017% which we arrange to emulate with a temporary file in ordinary TeX.
0f8bbd69 8018\ifx\eTeXversion\thisisundefined
82d5ce1d
UD
8019 \newwrite\macscribble
8020 \def\scantokens#1{%
8021 \toks0={#1}%
8022 \immediate\openout\macscribble=\jobname.tmp
8023 \immediate\write\macscribble{\the\toks0}%
8024 \immediate\closeout\macscribble
8025 \input \jobname.tmp
8026 }
a334319f 8027\fi
0ecb606c 8028
084e7d57
JM
8029% alias because \c means cedilla in @tex or @math
8030\let\texinfoc=\c
8031
7f7dd1d3
JM
8032\newcount\savedcatcodeone
8033\newcount\savedcatcodetwo
8034
084e7d57
JM
8035% Used at the time of macro expansion.
8036% Argument is macro body with arguments substituted
8037\def\scanmacro#1{%
0f8bbd69 8038 \newlinechar`\^^M
7f7dd1d3
JM
8039 \def\xeatspaces{\eatspaces}%
8040 %
8041 % Temporarily undo catcode changes of \printindex. Set catcode of @ to
8042 % 0 so that @-commands in macro expansions aren't printed literally when
8043 % formatting an index file, where \ is used as the escape character.
8044 \savedcatcodeone=\catcode`\@
8045 \savedcatcodetwo=\catcode`\\
8046 \catcode`\@=0
8047 \catcode`\\=\active
0f8bbd69 8048 %
084e7d57 8049 % Process the macro body under the current catcode regime.
41d11b15 8050 \scantokens{#1@texinfoc}%
7f7dd1d3
JM
8051 %
8052 \catcode`\@=\savedcatcodeone
8053 \catcode`\\=\savedcatcodetwo
0f8bbd69 8054 %
7f7dd1d3 8055 % The \texinfoc is to remove the \newlinechar added by \scantokens, and
084e7d57 8056 % can be noticed by \parsearg.
084e7d57
JM
8057 % We avoid surrounding the call to \scantokens with \bgroup and \egroup
8058 % to allow macros to open or close groups themselves.
8059}
82d5ce1d 8060
084e7d57 8061% Used for copying and captions
82d5ce1d 8062\def\scanexp#1{%
7f7dd1d3 8063 \expandafter\scanmacro\expandafter{#1}%
82d5ce1d
UD
8064}
8065
0c2b5752
UD
8066\newcount\paramno % Count of parameters
8067\newtoks\macname % Macro name
8068\newif\ifrecursive % Is it recursive?
9251c568
AJ
8069
8070% List of all defined macros in the form
7f7dd1d3 8071% \commondummyword\macro1\commondummyword\macro2...
9251c568
AJ
8072% Currently is also contains all @aliases; the list can be split
8073% if there is a need.
8074\def\macrolist{}
8075
8076% Add the macro to \macrolist
8077\def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname}
8078\def\addtomacrolistxxx#1{%
7f7dd1d3 8079 \toks0 = \expandafter{\macrolist\commondummyword#1}%
9251c568
AJ
8080 \xdef\macrolist{\the\toks0}%
8081}
f962d792 8082
61027f30 8083% Utility routines.
82d5ce1d
UD
8084% This does \let #1 = #2, with \csnames; that is,
8085% \let \csname#1\endcsname = \csname#2\endcsname
8086% (except of course we have to play expansion games).
0f8bbd69 8087%
f962d792 8088\def\cslet#1#2{%
82d5ce1d
UD
8089 \expandafter\let
8090 \csname#1\expandafter\endcsname
8091 \csname#2\endcsname
8092}
f962d792 8093
61027f30
UD
8094% Trim leading and trailing spaces off a string.
8095% Concepts from aro-bend problem 15 (see CTAN).
8096{\catcode`\@=11
8097\gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }}
8098\gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@}
8099\gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @}
8100\def\unbrace#1{#1}
8101\unbrace{\gdef\trim@@@ #1 } #2@{#1}
8102}
8103
8104% Trim a single trailing ^^M off a string.
e0f86659 8105{\catcode`\^^M=\other \catcode`\Q=3%
61027f30
UD
8106\gdef\eatcr #1{\eatcra #1Q^^MQ}%
8107\gdef\eatcra#1^^MQ{\eatcrb#1Q}%
8108\gdef\eatcrb#1Q#2Q{#1}%
8109}
8110
0c2b5752
UD
8111% Macro bodies are absorbed as an argument in a context where
8112% all characters are catcode 10, 11 or 12, except \ which is active
0f8bbd69
JM
8113% (as in normal texinfo). It is necessary to change the definition of \
8114% to recognize macro arguments; this is the job of \mbodybackslash.
8115%
c94f48d7
AJ
8116% Non-ASCII encodings make 8-bit characters active, so un-activate
8117% them to avoid their expansion. Must do this non-globally, to
8118% confine the change to the current group.
0f8bbd69 8119%
a334319f 8120% It's necessary to have hard CRs when the macro is executed. This is
0f8bbd69 8121% done by making ^^M (\endlinechar) catcode 12 when reading the macro
a334319f 8122% body, and then making it the \newlinechar in \scanmacro.
0f8bbd69
JM
8123%
8124\def\scanctxt{% used as subroutine
82d5ce1d
UD
8125 \catcode`\"=\other
8126 \catcode`\+=\other
8127 \catcode`\<=\other
8128 \catcode`\>=\other
a334319f
UD
8129 \catcode`\^=\other
8130 \catcode`\_=\other
8131 \catcode`\|=\other
82d5ce1d 8132 \catcode`\~=\other
7f7dd1d3 8133 \passthroughcharstrue
82d5ce1d
UD
8134}
8135
0f8bbd69 8136\def\scanargctxt{% used for copying and captions, not macros.
82d5ce1d 8137 \scanctxt
084e7d57 8138 \catcode`\@=\other
82d5ce1d
UD
8139 \catcode`\\=\other
8140 \catcode`\^^M=\other
8141}
8142
0f8bbd69 8143\def\macrobodyctxt{% used for @macro definitions
82d5ce1d 8144 \scanctxt
084e7d57
JM
8145 \catcode`\ =\other
8146 \catcode`\@=\other
e0f86659
UD
8147 \catcode`\{=\other
8148 \catcode`\}=\other
e0f86659 8149 \catcode`\^^M=\other
82d5ce1d
UD
8150 \usembodybackslash
8151}
0c2b5752 8152
084e7d57
JM
8153% Used when scanning braced macro arguments. Note, however, that catcode
8154% changes here are ineffectual if the macro invocation was nested inside
8155% an argument to another Texinfo command.
8156\def\macroargctxt{%
82d5ce1d 8157 \scanctxt
084e7d57
JM
8158 \catcode`\ =\active
8159 \catcode`\^^M=\other
8160 \catcode`\\=\active
82d5ce1d 8161}
0f8bbd69 8162
084e7d57
JM
8163\def\macrolineargctxt{% used for whole-line arguments without braces
8164 \scanctxt
8165 \catcode`\{=\other
8166 \catcode`\}=\other
8167}
1e02536f 8168
0c2b5752 8169% \mbodybackslash is the definition of \ in @macro bodies.
b710a6e2 8170% It maps \foo\ => \csname macarg.foo\endcsname => #N
0c2b5752
UD
8171% where N is the macro parameter number.
8172% We define \csname macarg.\endcsname to be \realbackslash, so
8173% \\ in macro replacement text gets you a backslash.
0f8bbd69 8174%
313a1174 8175{\catcode`@=0 @catcode`@\=@active
0c2b5752
UD
8176 @gdef@usembodybackslash{@let\=@mbodybackslash}
8177 @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname}
8178}
8179\expandafter\def\csname macarg.\endcsname{\realbackslash}
8180
0f8bbd69
JM
8181\def\margbackslash#1{\char`\#1 }
8182
313a1174
UD
8183\def\macro{\recursivefalse\parsearg\macroxxx}
8184\def\rmacro{\recursivetrue\parsearg\macroxxx}
8185
8186\def\macroxxx#1{%
0f8bbd69 8187 \getargs{#1}% now \macname is the macname and \argl the arglist
313a1174 8188 \ifx\argl\empty % no arguments
0f8bbd69 8189 \paramno=0\relax
f962d792 8190 \else
b710a6e2 8191 \expandafter\parsemargdef \argl;%
0f8bbd69
JM
8192 \if\paramno>256\relax
8193 \ifx\eTeXversion\thisisundefined
8194 \errhelp = \EMsimple
8195 \errmessage{You need eTeX to compile a file with macros with more than 256 arguments}
8196 \fi
8197 \fi
f962d792 8198 \fi
b1418d8f 8199 \if1\csname ismacro.\the\macname\endcsname
0c2b5752 8200 \message{Warning: redefining \the\macname}%
b1418d8f
UD
8201 \else
8202 \expandafter\ifx\csname \the\macname\endcsname \relax
27692f89 8203 \else \errmessage{Macro name \the\macname\space already defined}\fi
b1418d8f
UD
8204 \global\cslet{macsave.\the\macname}{\the\macname}%
8205 \global\expandafter\let\csname ismacro.\the\macname\endcsname=1%
9251c568 8206 \addtomacrolist{\the\macname}%
f962d792 8207 \fi
0c2b5752
UD
8208 \begingroup \macrobodyctxt
8209 \ifrecursive \expandafter\parsermacbody
b710a6e2 8210 \else \expandafter\parsemacbody
0c2b5752
UD
8211 \fi}
8212
82d5ce1d 8213\parseargdef\unmacro{%
b1418d8f
UD
8214 \if1\csname ismacro.#1\endcsname
8215 \global\cslet{#1}{macsave.#1}%
8216 \global\expandafter\let \csname ismacro.#1\endcsname=0%
e0f86659 8217 % Remove the macro name from \macrolist:
b1418d8f 8218 \begingroup
e0f86659 8219 \expandafter\let\csname#1\endcsname \relax
7f7dd1d3 8220 \let\commondummyword\unmacrodo
e0f86659 8221 \xdef\macrolist{\macrolist}%
b1418d8f 8222 \endgroup
f962d792 8223 \else
b1418d8f 8224 \errmessage{Macro #1 not defined}%
f962d792 8225 \fi
0c2b5752
UD
8226}
8227
e0f86659
UD
8228% Called by \do from \dounmacro on each macro. The idea is to omit any
8229% macro definitions that have been changed to \relax.
7158eae4 8230%
e0f86659 8231\def\unmacrodo#1{%
9251c568 8232 \ifx #1\relax
e0f86659
UD
8233 % remove this
8234 \else
7f7dd1d3 8235 \noexpand\commondummyword \noexpand#1%
e0f86659
UD
8236 \fi
8237}
8238
084e7d57
JM
8239% \getargs -- Parse the arguments to a @macro line. Set \macname to
8240% the name of the macro, and \argl to the braced argument list.
313a1174
UD
8241\def\getargs#1{\getargsxxx#1{}}
8242\def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
0f8bbd69 8243\def\getmacname#1 #2\relax{\macname={#1}}
313a1174 8244\def\getmacargs#1{\def\argl{#1}}
084e7d57
JM
8245% This made use of the feature that if the last token of a
8246% <parameter list> is #, then the preceding argument is delimited by
8247% an opening brace, and that opening brace is not consumed.
313a1174 8248
084e7d57
JM
8249% Parse the optional {params} list to @macro or @rmacro.
8250% Set \paramno to the number of arguments,
8251% and \paramlist to a parameter text for the macro (e.g. #1,#2,#3 for a
8252% three-param macro.) Define \macarg.BLAH for each BLAH in the params
8253% list to some hook where the argument is to be expanded. If there are
8254% less than 10 arguments that hook is to be replaced by ##N where N
0f8bbd69
JM
8255% is the position in that list, that is to say the macro arguments are to be
8256% defined `a la TeX in the macro body.
8257%
0c2b5752 8258% That gets used by \mbodybackslash (above).
0f8bbd69 8259%
084e7d57
JM
8260% If there are 10 or more arguments, a different technique is used: see
8261% \parsemmanyargdef.
61027f30 8262%
0f8bbd69
JM
8263\def\parsemargdef#1;{%
8264 \paramno=0\def\paramlist{}%
8265 \let\hash\relax
084e7d57 8266 % \hash is redefined to `#' later to get it into definitions
7f7dd1d3 8267 \let\xeatspaces\relax
0f8bbd69 8268 \parsemargdefxxx#1,;,%
0f8bbd69
JM
8269 \ifnum\paramno<10\relax\else
8270 \paramno0\relax
8271 \parsemmanyargdef@@#1,;,% 10 or more arguments
8272 \fi
8273}
0c2b5752 8274\def\parsemargdefxxx#1,{%
313a1174 8275 \if#1;\let\next=\relax
0c2b5752 8276 \else \let\next=\parsemargdefxxx
0f8bbd69 8277 \advance\paramno by 1
61027f30 8278 \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
7f7dd1d3 8279 {\xeatspaces{\hash\the\paramno}}%
313a1174 8280 \edef\paramlist{\paramlist\hash\the\paramno,}%
0c2b5752 8281 \fi\next}
0c2b5752 8282
084e7d57
JM
8283% \parsemacbody, \parsermacbody
8284%
8285% Read recursive and nonrecursive macro bodies. (They're different since
8286% rec and nonrec macros end differently.)
8287%
8288% We are in \macrobodyctxt, and the \xdef causes backslashshes in the macro
8289% body to be transformed.
8290% Set \macrobody to the body of the macro, and call \defmacro.
8291%
8292{\catcode`\ =\other\long\gdef\parsemacbody#1@end macro{%
8293\xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}%
8294{\catcode`\ =\other\long\gdef\parsermacbody#1@end rmacro{%
8295\xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}%
8296
8297% Make @ a letter, so that we can make private-to-Texinfo macro names.
8298\edef\texiatcatcode{\the\catcode`\@}
8299\catcode `@=11\relax
8300
8301%%%%%%%%%%%%%% Code for > 10 arguments only %%%%%%%%%%%%%%%%%%
8302
8303% If there are 10 or more arguments, a different technique is used, where the
8304% hook remains in the body, and when macro is to be expanded the body is
8305% processed again to replace the arguments.
8306%
8307% In that case, the hook is \the\toks N-1, and we simply set \toks N-1 to the
8308% argument N value and then \edef the body (nothing else will expand because of
8309% the catcode regime under which the body was input).
8310%
8311% If you compile with TeX (not eTeX), and you have macros with 10 or more
8312% arguments, no macro can have more than 256 arguments (else error).
8313%
8314% In case that there are 10 or more arguments we parse again the arguments
8315% list to set new definitions for the \macarg.BLAH macros corresponding to
8316% each BLAH argument. It was anyhow needed to parse already once this list
8317% in order to count the arguments, and as macros with at most 9 arguments
8318% are by far more frequent than macro with 10 or more arguments, defining
8319% twice the \macarg.BLAH macros does not cost too much processing power.
0f8bbd69
JM
8320\def\parsemmanyargdef@@#1,{%
8321 \if#1;\let\next=\relax
8322 \else
8323 \let\next=\parsemmanyargdef@@
8324 \edef\tempb{\eatspaces{#1}}%
8325 \expandafter\def\expandafter\tempa
8326 \expandafter{\csname macarg.\tempb\endcsname}%
8327 % Note that we need some extra \noexpand\noexpand, this is because we
8328 % don't want \the to be expanded in the \parsermacbody as it uses an
8329 % \xdef .
8330 \expandafter\edef\tempa
8331 {\noexpand\noexpand\noexpand\the\toks\the\paramno}%
8332 \advance\paramno by 1\relax
8333 \fi\next}
8334
0f8bbd69
JM
8335
8336\let\endargs@\relax
8337\let\nil@\relax
8338\def\nilm@{\nil@}%
8339\long\def\nillm@{\nil@}%
8340
8341% This macro is expanded during the Texinfo macro expansion, not during its
084e7d57 8342% definition. It gets all the arguments' values and assigns them to macros
0f8bbd69
JM
8343% macarg.ARGNAME
8344%
8345% #1 is the macro name
8346% #2 is the list of argument names
8347% #3 is the list of argument values
8348\def\getargvals@#1#2#3{%
8349 \def\macargdeflist@{}%
8350 \def\saveparamlist@{#2}% Need to keep a copy for parameter expansion.
8351 \def\paramlist{#2,\nil@}%
8352 \def\macroname{#1}%
8353 \begingroup
8354 \macroargctxt
8355 \def\argvaluelist{#3,\nil@}%
8356 \def\@tempa{#3}%
8357 \ifx\@tempa\empty
8358 \setemptyargvalues@
8359 \else
8360 \getargvals@@
8361 \fi
8362}
0f8bbd69
JM
8363\def\getargvals@@{%
8364 \ifx\paramlist\nilm@
8365 % Some sanity check needed here that \argvaluelist is also empty.
8366 \ifx\argvaluelist\nillm@
8367 \else
8368 \errhelp = \EMsimple
8369 \errmessage{Too many arguments in macro `\macroname'!}%
8370 \fi
8371 \let\next\macargexpandinbody@
8372 \else
8373 \ifx\argvaluelist\nillm@
8374 % No more arguments values passed to macro. Set remaining named-arg
8375 % macros to empty.
8376 \let\next\setemptyargvalues@
8377 \else
8378 % pop current arg name into \@tempb
8379 \def\@tempa##1{\pop@{\@tempb}{\paramlist}##1\endargs@}%
8380 \expandafter\@tempa\expandafter{\paramlist}%
8381 % pop current argument value into \@tempc
8382 \def\@tempa##1{\longpop@{\@tempc}{\argvaluelist}##1\endargs@}%
8383 \expandafter\@tempa\expandafter{\argvaluelist}%
8384 % Here \@tempb is the current arg name and \@tempc is the current arg value.
8385 % First place the new argument macro definition into \@tempd
8386 \expandafter\macname\expandafter{\@tempc}%
8387 \expandafter\let\csname macarg.\@tempb\endcsname\relax
8388 \expandafter\def\expandafter\@tempe\expandafter{%
8389 \csname macarg.\@tempb\endcsname}%
8390 \edef\@tempd{\long\def\@tempe{\the\macname}}%
8391 \push@\@tempd\macargdeflist@
8392 \let\next\getargvals@@
8393 \fi
8394 \fi
8395 \next
8396}
8397
8398\def\push@#1#2{%
8399 \expandafter\expandafter\expandafter\def
8400 \expandafter\expandafter\expandafter#2%
8401 \expandafter\expandafter\expandafter{%
8402 \expandafter#1#2}%
8403}
8404
8405% Replace arguments by their values in the macro body, and place the result
084e7d57
JM
8406% in macro \@tempa.
8407%
0f8bbd69
JM
8408\def\macvalstoargs@{%
8409 % To do this we use the property that token registers that are \the'ed
8410 % within an \edef expand only once. So we are going to place all argument
8411 % values into respective token registers.
8412 %
8413 % First we save the token context, and initialize argument numbering.
8414 \begingroup
8415 \paramno0\relax
8416 % Then, for each argument number #N, we place the corresponding argument
8417 % value into a new token list register \toks#N
8418 \expandafter\putargsintokens@\saveparamlist@,;,%
8419 % Then, we expand the body so that argument are replaced by their
8420 % values. The trick for values not to be expanded themselves is that they
8421 % are within tokens and that tokens expand only once in an \edef .
8422 \edef\@tempc{\csname mac.\macroname .body\endcsname}%
8423 % Now we restore the token stack pointer to free the token list registers
8424 % which we have used, but we make sure that expanded body is saved after
8425 % group.
8426 \expandafter
8427 \endgroup
8428 \expandafter\def\expandafter\@tempa\expandafter{\@tempc}%
8429 }
8430
084e7d57
JM
8431% Define the named-macro outside of this group and then close this group.
8432%
0f8bbd69 8433\def\macargexpandinbody@{%
0f8bbd69
JM
8434 \expandafter
8435 \endgroup
8436 \macargdeflist@
8437 % First the replace in body the macro arguments by their values, the result
8438 % is in \@tempa .
8439 \macvalstoargs@
8440 % Then we point at the \norecurse or \gobble (for recursive) macro value
8441 % with \@tempb .
8442 \expandafter\let\expandafter\@tempb\csname mac.\macroname .recurse\endcsname
8443 % Depending on whether it is recursive or not, we need some tailing
8444 % \egroup .
8445 \ifx\@tempb\gobble
8446 \let\@tempc\relax
8447 \else
8448 \let\@tempc\egroup
8449 \fi
8450 % And now we do the real job:
8451 \edef\@tempd{\noexpand\@tempb{\macroname}\noexpand\scanmacro{\@tempa}\@tempc}%
8452 \@tempd
8453}
8454
8455\def\putargsintokens@#1,{%
8456 \if#1;\let\next\relax
8457 \else
8458 \let\next\putargsintokens@
8459 % First we allocate the new token list register, and give it a temporary
8460 % alias \@tempb .
8461 \toksdef\@tempb\the\paramno
8462 % Then we place the argument value into that token list register.
8463 \expandafter\let\expandafter\@tempa\csname macarg.#1\endcsname
8464 \expandafter\@tempb\expandafter{\@tempa}%
8465 \advance\paramno by 1\relax
8466 \fi
8467 \next
8468}
8469
084e7d57
JM
8470% Trailing missing arguments are set to empty.
8471%
0f8bbd69
JM
8472\def\setemptyargvalues@{%
8473 \ifx\paramlist\nilm@
8474 \let\next\macargexpandinbody@
8475 \else
8476 \expandafter\setemptyargvaluesparser@\paramlist\endargs@
8477 \let\next\setemptyargvalues@
8478 \fi
8479 \next
8480}
8481
8482\def\setemptyargvaluesparser@#1,#2\endargs@{%
8483 \expandafter\def\expandafter\@tempa\expandafter{%
8484 \expandafter\def\csname macarg.#1\endcsname{}}%
8485 \push@\@tempa\macargdeflist@
8486 \def\paramlist{#2}%
8487}
8488
8489% #1 is the element target macro
8490% #2 is the list macro
8491% #3,#4\endargs@ is the list value
8492\def\pop@#1#2#3,#4\endargs@{%
8493 \def#1{#3}%
8494 \def#2{#4}%
8495}
8496\long\def\longpop@#1#2#3,#4\endargs@{%
8497 \long\def#1{#3}%
8498 \long\def#2{#4}%
8499}
0c2b5752 8500
084e7d57
JM
8501
8502%%%%%%%%%%%%%% End of code for > 10 arguments %%%%%%%%%%%%%%%%%%
8503
8504
084e7d57
JM
8505% This defines a Texinfo @macro or @rmacro, called by \parsemacbody.
8506% \macrobody has the body of the macro in it, with placeholders for
7f7dd1d3 8507% its parameters, looking like "\xeatspaces{\hash 1}".
084e7d57
JM
8508% \paramno is the number of parameters
8509% \paramlist is a TeX parameter text, e.g. "#1,#2,#3,"
7f7dd1d3 8510% There are four cases: macros of zero, one, up to nine, and many arguments.
61027f30 8511% \xdef is used so that macro definitions will survive the file
084e7d57 8512% they're defined in: @include reads the file inside a group.
0f8bbd69 8513%
0c2b5752 8514\def\defmacro{%
313a1174 8515 \let\hash=##% convert placeholders to macro parameter chars
084e7d57 8516 \ifnum\paramno=1
7f7dd1d3 8517 \def\xeatspaces##1{##1}%
084e7d57
JM
8518 % This removes the pair of braces around the argument. We don't
8519 % use \eatspaces, because this can cause ends of lines to be lost
8520 % when the argument to \eatspaces is read, leading to line-based
8521 % commands like "@itemize" not being read correctly.
8522 \else
7f7dd1d3 8523 \let\xeatspaces\relax % suppress expansion
084e7d57 8524 \fi
7f7dd1d3
JM
8525 \ifcase\paramno
8526 % 0
8527 \expandafter\xdef\csname\the\macname\endcsname{%
41d11b15
JM
8528 \bgroup
8529 \noexpand\spaceisspace
8530 \noexpand\endlineisspace
8531 \noexpand\expandafter % skip any whitespace after the macro name.
8532 \expandafter\noexpand\csname\the\macname @@@\endcsname}%
8533 \expandafter\xdef\csname\the\macname @@@\endcsname{%
8534 \egroup
7f7dd1d3
JM
8535 \noexpand\scanmacro{\macrobody}}%
8536 \or % 1
8537 \expandafter\xdef\csname\the\macname\endcsname{%
8538 \bgroup
8539 \noexpand\braceorline
8540 \expandafter\noexpand\csname\the\macname @@@\endcsname}%
8541 \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
8542 \egroup
8543 \noexpand\scanmacro{\macrobody}%
8544 }%
8545 \else % at most 9
8546 \ifnum\paramno<10\relax
8547 % @MACNAME sets the context for reading the macro argument
8548 % @MACNAME@@ gets the argument, processes backslashes and appends a
8549 % comma.
8550 % @MACNAME@@@ removes braces surrounding the argument list.
8551 % @MACNAME@@@@ scans the macro body with arguments substituted.
61027f30 8552 \expandafter\xdef\csname\the\macname\endcsname{%
7f7dd1d3
JM
8553 \bgroup
8554 \noexpand\expandafter % This \expandafter skip any spaces after the
8555 \noexpand\macroargctxt % macro before we change the catcode of space.
8556 \noexpand\expandafter
8557 \expandafter\noexpand\csname\the\macname @@\endcsname}%
8558 \expandafter\xdef\csname\the\macname @@\endcsname##1{%
8559 \noexpand\passargtomacro
8560 \expandafter\noexpand\csname\the\macname @@@\endcsname{##1,}}%
084e7d57 8561 \expandafter\xdef\csname\the\macname @@@\endcsname##1{%
7f7dd1d3
JM
8562 \expandafter\noexpand\csname\the\macname @@@@\endcsname ##1}%
8563 \expandafter\expandafter
8564 \expandafter\xdef
8565 \expandafter\expandafter
8566 \csname\the\macname @@@@\endcsname\paramlist{%
8567 \egroup\noexpand\scanmacro{\macrobody}}%
8568 \else % 10 or more:
61027f30 8569 \expandafter\xdef\csname\the\macname\endcsname{%
7f7dd1d3
JM
8570 \noexpand\getargvals@{\the\macname}{\argl}%
8571 }%
8572 \global\expandafter\let\csname mac.\the\macname .body\endcsname\macrobody
8573 \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\gobble
0c2b5752
UD
8574 \fi
8575 \fi}
8576
084e7d57 8577\catcode `\@\texiatcatcode\relax % end private-to-Texinfo catcodes
0f8bbd69 8578
0c2b5752
UD
8579\def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
8580
084e7d57
JM
8581
8582%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8583%
8584{\catcode`\@=0 \catcode`\\=13 % We need to manipulate \ so use @ as escape
8585@catcode`@_=11 % private names
8586@catcode`@!=11 % used as argument separator
8587
8588% \passargtomacro#1#2 -
8589% Call #1 with a list of tokens #2, with any doubled backslashes in #2
8590% compressed to one.
8591%
8592% This implementation works by expansion, and not execution (so we cannot use
8593% \def or similar). This reduces the risk of this failing in contexts where
8594% complete expansion is done with no execution (for example, in writing out to
8595% an auxiliary file for an index entry).
8596%
8597% State is kept in the input stream: the argument passed to
8598% @look_ahead, @gobble_and_check_finish and @add_segment is
8599%
8600% THE_MACRO ARG_RESULT ! {PENDING_BS} NEXT_TOKEN (... rest of input)
8601%
8602% where:
8603% THE_MACRO - name of the macro we want to call
8604% ARG_RESULT - argument list we build to pass to that macro
8605% PENDING_BS - either a backslash or nothing
8606% NEXT_TOKEN - used to look ahead in the input stream to see what's coming next
8607
8608@gdef@passargtomacro#1#2{%
8609 @add_segment #1!{}@relax#2\@_finish\%
8610}
8611@gdef@_finish{@_finishx} @global@let@_finishx@relax
8612
8613% #1 - THE_MACRO ARG_RESULT
8614% #2 - PENDING_BS
8615% #3 - NEXT_TOKEN
8616% #4 used to look ahead
8617%
8618% If the next token is not a backslash, process the rest of the argument;
8619% otherwise, remove the next token.
8620@gdef@look_ahead#1!#2#3#4{%
8621 @ifx#4\%
8622 @expandafter@gobble_and_check_finish
8623 @else
8624 @expandafter@add_segment
8625 @fi#1!{#2}#4#4%
8626}
8627
8628% #1 - THE_MACRO ARG_RESULT
8629% #2 - PENDING_BS
8630% #3 - NEXT_TOKEN
8631% #4 should be a backslash, which is gobbled.
8632% #5 looks ahead
8633%
8634% Double backslash found. Add a single backslash, and look ahead.
8635@gdef@gobble_and_check_finish#1!#2#3#4#5{%
8636 @add_segment#1\!{}#5#5%
8637}
8638
8639@gdef@is_fi{@fi}
8640
8641% #1 - THE_MACRO ARG_RESULT
8642% #2 - PENDING_BS
8643% #3 - NEXT_TOKEN
8644% #4 is input stream until next backslash
8645%
8646% Input stream is either at the start of the argument, or just after a
8647% backslash sequence, either a lone backslash, or a doubled backslash.
8648% NEXT_TOKEN contains the first token in the input stream: if it is \finish,
8649% finish; otherwise, append to ARG_RESULT the segment of the argument up until
8650% the next backslash. PENDING_BACKSLASH contains a backslash to represent
8651% a backslash just before the start of the input stream that has not been
8652% added to ARG_RESULT.
8653@gdef@add_segment#1!#2#3#4\{%
8654@ifx#3@_finish
8655 @call_the_macro#1!%
8656@else
8657 % append the pending backslash to the result, followed by the next segment
8658 @expandafter@is_fi@look_ahead#1#2#4!{\}@fi
8659 % this @fi is discarded by @look_ahead.
8660 % we can't get rid of it with \expandafter because we don't know how
8661 % long #4 is.
8662}
8663
8664% #1 - THE_MACRO
8665% #2 - ARG_RESULT
8666% #3 discards the res of the conditional in @add_segment, and @is_fi ends the
8667% conditional.
8668@gdef@call_the_macro#1#2!#3@fi{@is_fi #1{#2}}
8669
8670}
8671%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
8672
8673% \braceorline MAC is used for a one-argument macro MAC. It checks
8674% whether the next non-whitespace character is a {. It sets the context
8675% for reading the argument (slightly different in the two cases). Then,
8676% to read the argument, in the whole-line case, it then calls the regular
8677% \parsearg MAC; in the lbrace case, it calls \passargtomacro MAC.
0f8bbd69 8678%
9251c568 8679\def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx}
0c2b5752 8680\def\braceorlinexxx{%
084e7d57
JM
8681 \ifx\nchar\bgroup
8682 \macroargctxt
8683 \expandafter\passargtomacro
8684 \else
8685 \macrolineargctxt\expandafter\parsearg
9251c568 8686 \fi \macnamexxx}
82d5ce1d 8687
407dc7a0
UD
8688
8689% @alias.
3b82ab1c 8690% We need some trickery to remove the optional spaces around the equal
0f8bbd69
JM
8691% sign. Make them active and then expand them all to nothing.
8692%
82d5ce1d 8693\def\alias{\parseargusing\obeyspaces\aliasxxx}
3b82ab1c 8694\def\aliasxxx #1{\aliasyyy#1\relax}
82d5ce1d
UD
8695\def\aliasyyy #1=#2\relax{%
8696 {%
8697 \expandafter\let\obeyedspace=\empty
9251c568 8698 \addtomacrolist{#1}%
82d5ce1d
UD
8699 \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}%
8700 }%
8701 \next
8702}
407dc7a0
UD
8703
8704
f962d792 8705\message{cross references,}
13632cfc 8706
40c0dc53 8707\newwrite\auxfile
40c0dc53 8708\newif\ifhavexrefs % True if xref values are known.
9e9f9cc2
KB
8709\newif\ifwarnedxrefs % True if we warned once that they aren't known.
8710
40c0dc53 8711% @inforef is relatively simple.
d66b7b41 8712\def\inforef #1{\inforefzzz #1,,,,**}
0f8bbd69
JM
8713\def\inforefzzz #1,#2,#3,#4**{%
8714 \putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
d66b7b41
KB
8715 node \samp{\ignorespaces#1{}}}
8716
82d5ce1d
UD
8717% @node's only job in TeX is to define \lastnode, which is used in
8718% cross-references. The @node line might or might not have commas, and
8719% might or might not have spaces before the first comma, like:
8720% @node foo , bar , ...
8721% We don't want such trailing spaces in the node name.
8722%
8723\parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse}
8724%
8725% also remove a trailing comma, in case of something like this:
8726% @node Help-Cross, , , Cross-refs
8727\def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse}
8728\def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}}
8729
313a1174 8730\let\nwnode=\node
82d5ce1d
UD
8731\let\lastnode=\empty
8732
8733% Write a cross-reference definition for the current node. #1 is the
8734% type (Ynumbered, Yappendix, Ynothing).
8735%
8736\def\donoderef#1{%
8737 \ifx\lastnode\empty\else
8738 \setref{\lastnode}{#1}%
8739 \global\let\lastnode=\empty
313a1174
UD
8740 \fi
8741}
9e9f9cc2 8742
61027f30 8743% @anchor{NAME} -- define xref target at arbitrary point.
b710a6e2 8744%
3b82ab1c 8745\newcount\savesfregister
82d5ce1d
UD
8746%
8747\def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi}
8748\def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi}
8749\def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces}
61027f30 8750
e0f86659 8751% \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an
82d5ce1d 8752% anchor), which consists of three parts:
c94f48d7 8753% 1) NAME-title - the current sectioning name taken from \lastsection,
82d5ce1d
UD
8754% or the anchor name.
8755% 2) NAME-snt - section number and type, passed as the SNT arg, or
8756% empty for anchors.
8757% 3) NAME-pg - the page number.
8758%
8759% This is called from \donoderef, \anchor, and \dofloat. In the case of
8760% floats, there is an additional part, which is not written here:
8761% 4) NAME-lof - the text as it should appear in a @listoffloats.
8762%
8763\def\setref#1#2{%
3b82ab1c 8764 \pdfmkdest{#1}%
82d5ce1d
UD
8765 \iflinks
8766 {%
084e7d57 8767 \requireauxfile
82d5ce1d 8768 \atdummies % preserve commands, but don't expand them
7f7dd1d3
JM
8769 % match definition in \xrdef, \refx, \xrefX.
8770 \def\value##1{##1}%
82d5ce1d
UD
8771 \edef\writexrdef##1##2{%
8772 \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef
8773 ##1}{##2}}% these are parameters of \writexrdef
8774 }%
c94f48d7 8775 \toks0 = \expandafter{\lastsection}%
82d5ce1d
UD
8776 \immediate \writexrdef{title}{\the\toks0 }%
8777 \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc.
0f8bbd69 8778 \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout
82d5ce1d
UD
8779 }%
8780 \fi
8781}
9e9f9cc2 8782
0f8bbd69
JM
8783% @xrefautosectiontitle on|off says whether @section(ing) names are used
8784% automatically in xrefs, if the third arg is not explicitly specified.
8785% This was provided as a "secret" @set xref-automatic-section-title
8786% variable, now it's official.
8787%
8788\parseargdef\xrefautomaticsectiontitle{%
8789 \def\temp{#1}%
8790 \ifx\temp\onword
8791 \expandafter\let\csname SETxref-automatic-section-title\endcsname
8792 = \empty
8793 \else\ifx\temp\offword
8794 \expandafter\let\csname SETxref-automatic-section-title\endcsname
8795 = \relax
8796 \else
8797 \errhelp = \EMsimple
8798 \errmessage{Unknown @xrefautomaticsectiontitle value `\temp',
8799 must be on|off}%
8800 \fi\fi
8801}
8802
8fcb833a 8803% \f
313a1174
UD
8804% @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is
8805% the node name, #2 the name of the Info cross-reference, #3 the printed
8806% node name, #4 the name of the Info file, #5 the name of the printed
8807% manual. All but the node name can be omitted.
9e9f9cc2 8808%
084e7d57
JM
8809\def\pxref{\putwordsee{} \xrefXX}
8810\def\xref{\putwordSee{} \xrefXX}
8811\def\ref{\xrefXX}
8812
8813\def\xrefXX#1{\def\xrefXXarg{#1}\futurelet\tokenafterxref\xrefXXX}
8814\def\xrefXXX{\expandafter\xrefX\expandafter[\xrefXXarg,,,,,,,]}
0f8bbd69 8815%
8fcb833a 8816\newbox\toprefbox
0f8bbd69 8817\newbox\printedrefnamebox
8fcb833a 8818\newbox\infofilenamebox
0f8bbd69
JM
8819\newbox\printedmanualbox
8820%
9e9f9cc2 8821\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
3b82ab1c 8822 \unsepspaces
0f8bbd69 8823 %
8fcb833a 8824 % Get args without leading/trailing spaces.
82d5ce1d 8825 \def\printedrefname{\ignorespaces #3}%
0f8bbd69
JM
8826 \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}%
8827 %
8fcb833a
JM
8828 \def\infofilename{\ignorespaces #4}%
8829 \setbox\infofilenamebox = \hbox{\infofilename\unskip}%
8830 %
0f8bbd69
JM
8831 \def\printedmanual{\ignorespaces #5}%
8832 \setbox\printedmanualbox = \hbox{\printedmanual\unskip}%
8833 %
8834 % If the printed reference name (arg #3) was not explicitly given in
8835 % the @xref, figure out what we want to use.
8836 \ifdim \wd\printedrefnamebox = 0pt
9e9f9cc2 8837 % No printed node name was explicitly given.
0f8bbd69
JM
8838 \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax
8839 % Not auto section-title: use node name inside the square brackets.
82d5ce1d 8840 \def\printedrefname{\ignorespaces #1}%
9e9f9cc2 8841 \else
0f8bbd69
JM
8842 % Auto section-title: use chapter/section title inside
8843 % the square brackets if we have it.
8844 \ifdim \wd\printedmanualbox > 0pt
8845 % It is in another manual, so we don't have it; use node name.
82d5ce1d 8846 \def\printedrefname{\ignorespaces #1}%
9e9f9cc2
KB
8847 \else
8848 \ifhavexrefs
0f8bbd69 8849 % We (should) know the real title if we have the xref values.
82d5ce1d 8850 \def\printedrefname{\refx{#1-title}{}}%
9e9f9cc2
KB
8851 \else
8852 % Otherwise just copy the Info node name.
82d5ce1d 8853 \def\printedrefname{\ignorespaces #1}%
9e9f9cc2
KB
8854 \fi%
8855 \fi
8856 \fi
8857 \fi
8858 %
82d5ce1d 8859 % Make link in pdf output.
13632cfc 8860 \ifpdf
7f7dd1d3 8861 % For pdfTeX and LuaTeX
c94f48d7 8862 {\indexnofonts
8fcb833a 8863 \makevalueexpandable
7f7dd1d3 8864 \turnoffactive
0f8bbd69 8865 % This expands tokens, so do it after making catcode changes, so _
8fcb833a
JM
8866 % etc. don't get their TeX definitions. This ignores all spaces in
8867 % #4, including (wrongly) those in the middle of the filename.
0f8bbd69 8868 \getfilename{#4}%
9251c568 8869 %
8fcb833a
JM
8870 % This (wrongly) does not take account of leading or trailing
8871 % spaces in #1, which should be ignored.
7f7dd1d3
JM
8872 \setpdfdestname{#1}%
8873 %
8874 \ifx\pdfdestname\empty
8875 \def\pdfdestname{Top}% no empty targets
8fcb833a 8876 \fi
0f8bbd69
JM
8877 %
8878 \leavevmode
8879 \startlink attr{/Border [0 0 0]}%
e23f8d20 8880 \ifnum\filenamelength>0
7f7dd1d3 8881 goto file{\the\filename.pdf} name{\pdfdestname}%
e23f8d20 8882 \else
7f7dd1d3 8883 goto name{\pdfmkpgn{\pdfdestname}}%
e23f8d20
UD
8884 \fi
8885 }%
c94f48d7 8886 \setcolor{\linkcolor}%
7f7dd1d3
JM
8887 \else
8888 \ifx\XeTeXrevision\thisisundefined
8889 \else
8890 % For XeTeX
8891 {\indexnofonts
8892 \makevalueexpandable
8893 \turnoffactive
8894 % This expands tokens, so do it after making catcode changes, so _
8895 % etc. don't get their TeX definitions. This ignores all spaces in
8896 % #4, including (wrongly) those in the middle of the filename.
8897 \getfilename{#4}%
8898 %
8899 % This (wrongly) does not take account of leading or trailing
8900 % spaces in #1, which should be ignored.
8901 \setpdfdestname{#1}%
8902 %
8903 \ifx\pdfdestname\empty
8904 \def\pdfdestname{Top}% no empty targets
8905 \fi
8906 %
8907 \leavevmode
8908 \ifnum\filenamelength>0
8909 % With default settings,
8910 % XeTeX (xdvipdfmx) replaces link destination names with integers.
8911 % In this case, the replaced destination names of
8912 % remote PDFs are no longer known. In order to avoid a replacement,
8913 % you can use xdvipdfmx's command line option `-C 0x0010'.
8914 % If you use XeTeX 0.99996+ (TeX Live 2016+),
8915 % this command line option is no longer necessary
8916 % because we can use the `dvipdfmx:config' special.
8917 \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A
8918 << /S /GoToR /F (\the\filename.pdf) /D (\pdfdestname) >> >>}%
8919 \else
8920 \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A
8921 << /S /GoTo /D (\pdfdestname) >> >>}%
8922 \fi
8923 }%
8924 \setcolor{\linkcolor}%
8925 \fi
13632cfc 8926 \fi
82d5ce1d
UD
8927 {%
8928 % Have to otherify everything special to allow the \csname to
8929 % include an _ in the xref name, etc.
8930 \indexnofonts
8931 \turnoffactive
7f7dd1d3 8932 \def\value##1{##1}%
82d5ce1d
UD
8933 \expandafter\global\expandafter\let\expandafter\Xthisreftitle
8934 \csname XR#1-title\endcsname
8935 }%
7f7dd1d3
JM
8936 %
8937 % Float references are printed completely differently: "Figure 1.2"
8938 % instead of "[somenode], p.3". \iffloat distinguishes them by
8939 % \Xthisreftitle being set to a magic string.
82d5ce1d
UD
8940 \iffloat\Xthisreftitle
8941 % If the user specified the print name (third arg) to the ref,
8942 % print it instead of our usual "Figure 1.2".
0f8bbd69 8943 \ifdim\wd\printedrefnamebox = 0pt
9251c568 8944 \refx{#1-snt}{}%
82d5ce1d
UD
8945 \else
8946 \printedrefname
8947 \fi
7158eae4 8948 %
8fcb833a 8949 % If the user also gave the printed manual name (fifth arg), append
82d5ce1d 8950 % "in MANUALNAME".
0f8bbd69 8951 \ifdim \wd\printedmanualbox > 0pt
82d5ce1d
UD
8952 \space \putwordin{} \cite{\printedmanual}%
8953 \fi
8954 \else
8955 % node/anchor (non-float) references.
a334319f 8956 %
0f8bbd69
JM
8957 % If we use \unhbox to print the node names, TeX does not insert
8958 % empty discretionaries after hyphens, which means that it will not
8959 % find a line break at a hyphen in a node names. Since some manuals
8960 % are best written with fairly long node names, containing hyphens,
8961 % this is a loss. Therefore, we give the text of the node name
8962 % again, so it is as if TeX is seeing it for the first time.
8963 %
0f8bbd69 8964 \ifdim \wd\printedmanualbox > 0pt
8fcb833a 8965 % Cross-manual reference with a printed manual name.
0f8bbd69 8966 %
8fcb833a
JM
8967 \crossmanualxref{\cite{\printedmanual\unskip}}%
8968 %
8969 \else\ifdim \wd\infofilenamebox > 0pt
8970 % Cross-manual reference with only an info filename (arg 4), no
8971 % printed manual name (arg 5). This is essentially the same as
8972 % the case above; we output the filename, since we have nothing else.
0f8bbd69 8973 %
8fcb833a
JM
8974 \crossmanualxref{\code{\infofilename\unskip}}%
8975 %
82d5ce1d 8976 \else
8fcb833a 8977 % Reference within this manual.
0f8bbd69 8978 %
82d5ce1d
UD
8979 % _ (for example) has to be the character _ for the purposes of the
8980 % control sequence corresponding to the node, but it has to expand
8981 % into the usual \leavevmode...\vrule stuff for purposes of
8982 % printing. So we \turnoffactive for the \refx-snt, back on for the
8983 % printing, back off for the \refx-pg.
9251c568 8984 {\turnoffactive
82d5ce1d
UD
8985 % Only output a following space if the -snt ref is nonempty; for
8986 % @unnumbered and @anchor, it won't be.
8987 \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
8988 \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
8989 }%
0f8bbd69 8990 % output the `[mynode]' via the macro below so it can be overridden.
82d5ce1d
UD
8991 \xrefprintnodename\printedrefname
8992 %
8993 % But we always want a comma and a space:
8994 ,\space
8995 %
8996 % output the `page 3'.
9251c568 8997 \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
7f7dd1d3
JM
8998 % Add a , if xref followed by a space
8999 \if\space\noexpand\tokenafterxref ,%
9000 \else\ifx\ \tokenafterxref ,% @TAB
9001 \else\ifx\*\tokenafterxref ,% @*
9002 \else\ifx\ \tokenafterxref ,% @SPACE
9003 \else\ifx\
9004 \tokenafterxref ,% @NL
9005 \else\ifx\tie\tokenafterxref ,% @tie
9006 \fi\fi\fi\fi\fi\fi
8fcb833a 9007 \fi\fi
9e9f9cc2 9008 \fi
3b82ab1c 9009 \endlink
9e9f9cc2
KB
9010\endgroup}
9011
8fcb833a
JM
9012% Output a cross-manual xref to #1. Used just above (twice).
9013%
9014% Only include the text "Section ``foo'' in" if the foo is neither
9015% missing or Top. Thus, @xref{,,,foo,The Foo Manual} outputs simply
9016% "see The Foo Manual", the idea being to refer to the whole manual.
9017%
9018% But, this being TeX, we can't easily compare our node name against the
9019% string "Top" while ignoring the possible spaces before and after in
9020% the input. By adding the arbitrary 7sp below, we make it much less
9021% likely that a real node name would have the same width as "Top" (e.g.,
9022% in a monospaced font). Hopefully it will never happen in practice.
9023%
9024% For the same basic reason, we retypeset the "Top" at every
9025% reference, since the current font is indeterminate.
9026%
9027\def\crossmanualxref#1{%
9028 \setbox\toprefbox = \hbox{Top\kern7sp}%
9029 \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}%
9030 \ifdim \wd2 > 7sp % nonempty?
9031 \ifdim \wd2 = \wd\toprefbox \else % same as Top?
9032 \putwordSection{} ``\printedrefname'' \putwordin{}\space
9033 \fi
9034 \fi
9035 #1%
9036}
9037
7158eae4
UD
9038% This macro is called from \xrefX for the `[nodename]' part of xref
9039% output. It's a separate macro only so it can be changed more easily,
82d5ce1d 9040% since square brackets don't work well in some documents. Particularly
7158eae4
UD
9041% one that Bob is working on :).
9042%
9043\def\xrefprintnodename#1{[#1]}
9044
82d5ce1d 9045% Things referred to by \setref.
7158eae4 9046%
9e9f9cc2 9047\def\Ynothing{}
82d5ce1d
UD
9048\def\Yomitfromtoc{}
9049\def\Ynumbered{%
e0f86659
UD
9050 \ifnum\secno=0
9051 \putwordChapter@tie \the\chapno
9052 \else \ifnum\subsecno=0
9053 \putwordSection@tie \the\chapno.\the\secno
9054 \else \ifnum\subsubsecno=0
9055 \putwordSection@tie \the\chapno.\the\secno.\the\subsecno
9056 \else
9057 \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno
9058 \fi\fi\fi
9059}
82d5ce1d 9060\def\Yappendix{%
e0f86659
UD
9061 \ifnum\secno=0
9062 \putwordAppendix@tie @char\the\appendixno{}%
9063 \else \ifnum\subsecno=0
9064 \putwordSection@tie @char\the\appendixno.\the\secno
9065 \else \ifnum\subsubsecno=0
9066 \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno
9067 \else
9068 \putwordSection@tie
9069 @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno
9070 \fi\fi\fi
9071}
9e9f9cc2 9072
7f7dd1d3
JM
9073% \refx{NAME}{SUFFIX} - reference a cross-reference string named NAME. SUFFIX
9074% is output afterwards if non-empty.
9e9f9cc2 9075\def\refx#1#2{%
084e7d57 9076 \requireauxfile
e0f86659
UD
9077 {%
9078 \indexnofonts
9079 \otherbackslash
7f7dd1d3 9080 \def\value##1{##1}%
e0f86659 9081 \expandafter\global\expandafter\let\expandafter\thisrefX
82d5ce1d 9082 \csname XR#1\endcsname
e0f86659
UD
9083 }%
9084 \ifx\thisrefX\relax
9e9f9cc2 9085 % If not defined, say something at least.
2eb45444 9086 \angleleft un\-de\-fined\angleright
f962d792
UD
9087 \iflinks
9088 \ifhavexrefs
0f8bbd69
JM
9089 {\toks0 = {#1}% avoid expansion of possibly-complex value
9090 \message{\linenumber Undefined cross reference `\the\toks0'.}}%
f962d792
UD
9091 \else
9092 \ifwarnedxrefs\else
9093 \global\warnedxrefstrue
9094 \message{Cross reference values unknown; you must run TeX again.}%
9095 \fi
9e9f9cc2
KB
9096 \fi
9097 \fi
9098 \else
9099 % It's defined, so just use it.
e0f86659 9100 \thisrefX
9e9f9cc2
KB
9101 \fi
9102 #2% Output the suffix in any case.
9103}
9104
7f7dd1d3
JM
9105% This is the macro invoked by entries in the aux file. Define a control
9106% sequence for a cross-reference target (we prepend XR to the control sequence
9107% name to avoid collisions). The value is the page number. If this is a float
9108% type, we have more work to do.
b710a6e2 9109%
82d5ce1d 9110\def\xrdef#1#2{%
7f7dd1d3
JM
9111 {% Expand the node or anchor name to remove control sequences.
9112 % \turnoffactive stops 8-bit characters being changed to commands
9113 % like @'e. \refx does the same to retrieve the value in the definition.
c94f48d7
AJ
9114 \indexnofonts
9115 \turnoffactive
7f7dd1d3 9116 \def\value##1{##1}%
c94f48d7
AJ
9117 \xdef\safexrefname{#1}%
9118 }%
9119 %
41d11b15
JM
9120 \bgroup
9121 \expandafter\gdef\csname XR\safexrefname\endcsname{#2}%
9122 \egroup
9123 % We put the \gdef inside a group to avoid the definitions building up on
9124 % TeX's save stack, which can cause it to run out of space for aux files with
9125 % thousands of lines. \gdef doesn't use the save stack, but \csname does
9126 % when it defines an unknown control sequence as \relax.
82d5ce1d
UD
9127 %
9128 % Was that xref control sequence that we just defined for a float?
c94f48d7 9129 \expandafter\iffloat\csname XR\safexrefname\endcsname
82d5ce1d
UD
9130 % it was a float, and we have the (safe) float type in \iffloattype.
9131 \expandafter\let\expandafter\floatlist
9132 \csname floatlist\iffloattype\endcsname
9133 %
9134 % Is this the first time we've seen this float type?
9135 \expandafter\ifx\floatlist\relax
9136 \toks0 = {\do}% yes, so just \do
9137 \else
9138 % had it before, so preserve previous elements in list.
9139 \toks0 = \expandafter{\floatlist\do}%
9140 \fi
9141 %
9142 % Remember this xref in the control sequence \floatlistFLOATTYPE,
9143 % for later use in \listoffloats.
c94f48d7
AJ
9144 \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0
9145 {\safexrefname}}%
82d5ce1d
UD
9146 \fi
9147}
9e9f9cc2 9148
084e7d57
JM
9149% If working on a large document in chapters, it is convenient to
9150% be able to disable indexing, cross-referencing, and contents, for test runs.
9151% This is done with @novalidate at the beginning of the file.
9152%
9153\newif\iflinks \linkstrue % by default we want the aux files.
9154\let\novalidate = \linksfalse
9155
9156% Used when writing to the aux file, or when using data from it.
9157\def\requireauxfile{%
9158 \iflinks
9159 \tryauxfile
9160 % Open the new aux file. TeX will close it automatically at exit.
9161 \immediate\openout\auxfile=\jobname.aux
9162 \fi
9163 \global\let\requireauxfile=\relax % Only do this once.
9164}
9165
4dbca03b 9166% Read the last existing aux file, if any. No error if none exists.
82d5ce1d
UD
9167%
9168\def\tryauxfile{%
9169 \openin 1 \jobname.aux
9170 \ifeof 1 \else
9251c568 9171 \readdatafile{aux}%
82d5ce1d
UD
9172 \global\havexrefstrue
9173 \fi
9174 \closein 1
9175}
9176
9251c568 9177\def\setupdatafile{%
4dbca03b 9178 \catcode`\^^@=\other
55c14926
UD
9179 \catcode`\^^A=\other
9180 \catcode`\^^B=\other
4dbca03b
KB
9181 \catcode`\^^C=\other
9182 \catcode`\^^D=\other
9183 \catcode`\^^E=\other
9184 \catcode`\^^F=\other
9185 \catcode`\^^G=\other
9186 \catcode`\^^H=\other
55c14926 9187 \catcode`\^^K=\other
4dbca03b 9188 \catcode`\^^L=\other
9c2322bc
UD
9189 \catcode`\^^N=\other
9190 \catcode`\^^P=\other
9191 \catcode`\^^Q=\other
9192 \catcode`\^^R=\other
9193 \catcode`\^^S=\other
9194 \catcode`\^^T=\other
9195 \catcode`\^^U=\other
9196 \catcode`\^^V=\other
9197 \catcode`\^^W=\other
9198 \catcode`\^^X=\other
9199 \catcode`\^^Z=\other
4dbca03b
KB
9200 \catcode`\^^[=\other
9201 \catcode`\^^\=\other
9202 \catcode`\^^]=\other
9203 \catcode`\^^^=\other
9204 \catcode`\^^_=\other
e0f86659 9205 % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc.
4dbca03b
KB
9206 % in xref tags, i.e., node names. But since ^^e4 notation isn't
9207 % supported in the main text, it doesn't seem desirable. Furthermore,
9208 % that is not enough: for node names that actually contain a ^
9209 % character, we would end up writing a line like this: 'xrdef {'hat
9210 % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first
9211 % argument, and \hat is not an expandable control sequence. It could
9212 % all be worked out, but why? Either we support ^^ or we don't.
10dc2a90 9213 %
4dbca03b
KB
9214 % The other change necessary for this was to define \auxhat:
9215 % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter
9216 % and then to call \auxhat in \setq.
10dc2a90 9217 %
e0f86659
UD
9218 \catcode`\^=\other
9219 %
9220 % Special characters. Should be turned off anyway, but...
4dbca03b
KB
9221 \catcode`\~=\other
9222 \catcode`\[=\other
9223 \catcode`\]=\other
9224 \catcode`\"=\other
9225 \catcode`\_=\other
9226 \catcode`\|=\other
9227 \catcode`\<=\other
9228 \catcode`\>=\other
9229 \catcode`\$=\other
9230 \catcode`\#=\other
9231 \catcode`\&=\other
e0f86659 9232 \catcode`\%=\other
40c0dc53 9233 \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
e0f86659 9234 %
82d5ce1d
UD
9235 % This is to support \ in node names and titles, since the \
9236 % characters end up in a \csname. It's easier than
9237 % leaving it active and making its active definition an actual \
9238 % character. What I don't understand is why it works in the *value*
9239 % of the xrdef. Seems like it should be a catcode12 \, and that
9240 % should not typeset properly. But it works, so I'm moving on for
9241 % now. --karl, 15jan04.
9242 \catcode`\\=\other
9243 %
82d5ce1d 9244 % @ is our escape character in .aux files, and we need braces.
4dbca03b
KB
9245 \catcode`\{=1
9246 \catcode`\}=2
e0f86659 9247 \catcode`\@=0
9251c568 9248}
9e9f9cc2 9249
9251c568
AJ
9250\def\readdatafile#1{%
9251\begingroup
9252 \setupdatafile
9253 \input\jobname.#1
9254\endgroup}
9e9f9cc2 9255
c94f48d7 9256
82d5ce1d
UD
9257\message{insertions,}
9258% including footnotes.
9e9f9cc2
KB
9259
9260\newcount \footnoteno
9261
9262% The trailing space in the following definition for supereject is
9263% vital for proper filling; pages come out unaligned when you do a
9264% pagealignmacro call if that space before the closing brace is
793fde8a
KB
9265% removed. (Generally, numeric constants should always be followed by a
9266% space to prevent strange expansion errors.)
9e9f9cc2
KB
9267\def\supereject{\par\penalty -20000\footnoteno =0 }
9268
0f8bbd69 9269% @footnotestyle is meaningful for Info output only.
9e9f9cc2
KB
9270\let\footnotestyle=\comment
9271
9e9f9cc2
KB
9272{\catcode `\@=11
9273%
9274% Auto-number footnotes. Otherwise like plain.
9275\gdef\footnote{%
9276 \global\advance\footnoteno by \@ne
9277 \edef\thisfootno{$^{\the\footnoteno}$}%
9278 %
9279 % In case the footnote comes at the end of a sentence, preserve the
9280 % extra spacing after we do the footnote number.
9281 \let\@sf\empty
7158eae4 9282 \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi
9e9f9cc2
KB
9283 %
9284 % Remove inadvertent blank space before typesetting the footnote number.
9285 \unskip
9286 \thisfootno\@sf
e0f86659 9287 \dofootnote
9e9f9cc2
KB
9288}%
9289
9290% Don't bother with the trickery in plain.tex to not require the
9291% footnote text as a parameter. Our footnotes don't need to be so general.
10dc2a90 9292%
82d5ce1d
UD
9293% Oh yes, they do; otherwise, @ifset (and anything else that uses
9294% \parseargline) fails inside footnotes because the tokens are fixed when
3a3df4c7 9295% the footnote is read. --karl, 16nov96.
9e9f9cc2 9296%
e0f86659 9297\gdef\dofootnote{%
82d5ce1d 9298 \insert\footins\bgroup
e66a8203
JM
9299 %
9300 % Nested footnotes are not supported in TeX, that would take a lot
9301 % more work. (\startsavinginserts does not suffice.)
084e7d57 9302 \let\footnote=\errfootnotenest
e66a8203 9303 %
9e9f9cc2
KB
9304 % We want to typeset this text as a normal paragraph, even if the
9305 % footnote reference occurs in (for example) a display environment.
9306 % So reset some parameters.
7f7dd1d3 9307 \hsize=\txipagewidth
9e9f9cc2
KB
9308 \interlinepenalty\interfootnotelinepenalty
9309 \splittopskip\ht\strutbox % top baseline for broken footnotes
9310 \splitmaxdepth\dp\strutbox
9311 \floatingpenalty\@MM
9312 \leftskip\z@skip
9313 \rightskip\z@skip
9314 \spaceskip\z@skip
9315 \xspaceskip\z@skip
9316 \parindent\defaultparindent
9317 %
3b82ab1c
UD
9318 \smallfonts \rm
9319 %
e23f8d20
UD
9320 % Because we use hanging indentation in footnotes, a @noindent appears
9321 % to exdent this text, so make it be a no-op. makeinfo does not use
9322 % hanging indentation so @noindent can still be needed within footnote
9323 % text after an @example or the like (not that this is good style).
9324 \let\noindent = \relax
9325 %
9326 % Hang the footnote text off the number. Use \everypar in case the
9327 % footnote extends for more than one paragraph.
9328 \everypar = {\hang}%
9e9f9cc2
KB
9329 \textindent{\thisfootno}%
9330 %
9331 % Don't crash into the line above the footnote text. Since this
9332 % expands into a box, it must come within the paragraph, lest it
9333 % provide a place where TeX can split the footnote.
9334 \footstrut
0f8bbd69
JM
9335 %
9336 % Invoke rest of plain TeX footnote routine.
3a3df4c7 9337 \futurelet\next\fo@t
9e9f9cc2 9338}
9e9f9cc2
KB
9339}%end \catcode `\@=11
9340
084e7d57 9341\def\errfootnotenest{%
e66a8203
JM
9342 \errhelp=\EMsimple
9343 \errmessage{Nested footnotes not supported in texinfo.tex,
9344 even though they work in makeinfo; sorry}
9345}
9346
084e7d57
JM
9347\def\errfootnoteheading{%
9348 \errhelp=\EMsimple
9349 \errmessage{Footnotes in chapters, sections, etc., are not supported}
9350}
9351
82d5ce1d
UD
9352% In case a @footnote appears in a vbox, save the footnote text and create
9353% the real \insert just after the vbox finished. Otherwise, the insertion
9354% would be lost.
0f8bbd69 9355% Similarly, if a @footnote appears inside an alignment, save the footnote
82d5ce1d
UD
9356% text to a box and make the \insert when a row of the table is finished.
9357% And the same can be done for other insert classes. --kasal, 16nov03.
e66a8203 9358%
82d5ce1d
UD
9359% Replace the \insert primitive by a cheating macro.
9360% Deeper inside, just make sure that the saved insertions are not spilled
9361% out prematurely.
9e9f9cc2 9362%
82d5ce1d
UD
9363\def\startsavinginserts{%
9364 \ifx \insert\ptexinsert
9365 \let\insert\saveinsert
9366 \else
9367 \let\checkinserts\relax
9368 \fi
9e9f9cc2
KB
9369}
9370
82d5ce1d
UD
9371% This \insert replacement works for both \insert\footins{foo} and
9372% \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}.
9e9f9cc2 9373%
82d5ce1d
UD
9374\def\saveinsert#1{%
9375 \edef\next{\noexpand\savetobox \makeSAVEname#1}%
9376 \afterassignment\next
9377 % swallow the left brace
9378 \let\temp =
9379}
9380\def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}}
9381\def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1}
9382
9383\def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi}
9384
9385\def\placesaveins#1{%
9386 \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname
9387 {\box#1}%
9388}
9389
9390% eat @SAVE -- beware, all of them have catcode \other:
9391{
9392 \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials % ;-)
9393 \gdef\gobblesave @SAVE{}
9394}
9395
9396% initialization:
9397\def\newsaveins #1{%
9398 \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}%
9399 \next
9400}
9401\def\newsaveinsX #1{%
9402 \csname newbox\endcsname #1%
9403 \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts
9404 \checksaveins #1}%
9405}
9406
9407% initialize:
9408\let\checkinserts\empty
9409\newsaveins\footins
9410\newsaveins\margin
9411
9e9f9cc2 9412
5ae3e846
UD
9413% @image. We use the macros from epsf.tex to support this.
9414% If epsf.tex is not installed and @image is used, we complain.
b710a6e2 9415%
5ae3e846
UD
9416% Check for and read epsf.tex up front. If we read it only at @image
9417% time, we might be inside a group, and then its definitions would get
9418% undone and the next image would fail.
2eb45444 9419\openin 1 = epsf.tex
5ae3e846 9420\ifeof 1 \else
e0f86659
UD
9421 % Do not bother showing banner with epsf.tex v2.7k (available in
9422 % doc/epsf.tex and on ctan).
f962d792 9423 \def\epsfannounce{\toks0 = }%
5ae3e846
UD
9424 \input epsf.tex
9425\fi
82d5ce1d 9426\closein 1
5ae3e846 9427%
13632cfc 9428% We will only complain once about lack of epsf.tex.
5ae3e846
UD
9429\newif\ifwarnednoepsf
9430\newhelp\noepsfhelp{epsf.tex must be installed for images to
9431 work. It is also included in the Texinfo distribution, or you can get
41d11b15 9432 it from https://ctan.org/texarchive/macros/texinfo/texinfo/doc/epsf.tex.}
5ae3e846 9433%
5ae3e846 9434\def\image#1{%
8fcb833a 9435 \ifx\epsfbox\thisisundefined
13632cfc
UD
9436 \ifwarnednoepsf \else
9437 \errhelp = \noepsfhelp
9438 \errmessage{epsf.tex not found, images will be ignored}%
9439 \global\warnednoepsftrue
5ae3e846
UD
9440 \fi
9441 \else
e23f8d20 9442 \imagexxx #1,,,,,\finish
5ae3e846
UD
9443 \fi
9444}
9445%
9446% Arguments to @image:
9447% #1 is (mandatory) image filename; we tack on .eps extension.
9448% #2 is (optional) width, #3 is (optional) height.
e23f8d20
UD
9449% #4 is (ignored optional) html alt text.
9450% #5 is (ignored optional) extension.
0f8bbd69 9451% #6 is just the usual extra ignored arg for parsing stuff.
e23f8d20 9452\newif\ifimagevmode
7ed7ad59 9453\def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup
e23f8d20
UD
9454 \catcode`\^^M = 5 % in case we're inside an example
9455 \normalturnoffactive % allow _ et al. in names
084e7d57 9456 \def\xprocessmacroarg{\eatspaces}% in case we are being used via a macro
e23f8d20
UD
9457 % If the image is by itself, center it.
9458 \ifvmode
9459 \imagevmodetrue
8fcb833a
JM
9460 \else \ifx\centersub\centerV
9461 % for @center @image, we need a vbox so we can have our vertical space
9462 \imagevmodetrue
9463 \vbox\bgroup % vbox has better behavior than vtop herev
9464 \fi\fi
9465 %
9466 \ifimagevmode
0f8bbd69 9467 \nobreak\medskip
e23f8d20
UD
9468 % Usually we'll have text after the image which will insert
9469 % \parskip glue, so insert it here too to equalize the space
7158eae4 9470 % above and below.
e23f8d20
UD
9471 \nobreak\vskip\parskip
9472 \nobreak
e23f8d20
UD
9473 \fi
9474 %
0f8bbd69 9475 % Leave vertical mode so that indentation from an enclosing
8fcb833a
JM
9476 % environment such as @quotation is respected.
9477 % However, if we're at the top level, we don't want the
9478 % normal paragraph indentation.
9479 % On the other hand, if we are in the case of @center @image, we don't
9480 % want to start a paragraph, which will create a hsize-width box and
9481 % eradicate the centering.
9482 \ifx\centersub\centerV\else \noindent \fi
0f8bbd69 9483 %
e23f8d20 9484 % Output the image.
3b82ab1c 9485 \ifpdf
7f7dd1d3 9486 % For pdfTeX and LuaTeX <= 0.80
e23f8d20 9487 \dopdfimage{#1}{#2}{#3}%
3b82ab1c 9488 \else
7f7dd1d3
JM
9489 \ifx\XeTeXrevision\thisisundefined
9490 % For epsf.tex
9491 % \epsfbox itself resets \epsf?size at each figure.
9492 \setbox0 = \hbox{\ignorespaces #2}%
9493 \ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
9494 \setbox0 = \hbox{\ignorespaces #3}%
9495 \ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
9496 \epsfbox{#1.eps}%
9497 \else
9498 % For XeTeX
9499 \doxeteximage{#1}{#2}{#3}%
9500 \fi
f962d792 9501 \fi
e23f8d20 9502 %
8fcb833a
JM
9503 \ifimagevmode
9504 \medskip % space after a standalone image
9505 \fi
9506 \ifx\centersub\centerV \egroup \fi
e23f8d20 9507\endgroup}
9e9f9cc2 9508
5ae3e846 9509
82d5ce1d
UD
9510% @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables,
9511% etc. We don't actually implement floating yet, we always include the
9512% float "here". But it seemed the best name for the future.
9513%
9514\envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish}
9515
9516% There may be a space before second and/or third parameter; delete it.
9517\def\eatcommaspace#1, {#1,}
9518
9519% #1 is the optional FLOATTYPE, the text label for this float, typically
9520% "Figure", "Table", "Example", etc. Can't contain commas. If omitted,
9521% this float will not be numbered and cannot be referred to.
9522%
9523% #2 is the optional xref label. Also must be present for the float to
9524% be referable.
9525%
9526% #3 is the optional positioning argument; for now, it is ignored. It
9527% will somehow specify the positions allowed to float to (here, top, bottom).
9528%
9529% We keep a separate counter for each FLOATTYPE, which we reset at each
9530% chapter-level command.
9531\let\resetallfloatnos=\empty
9532%
9533\def\dofloat#1,#2,#3,#4\finish{%
9534 \let\thiscaption=\empty
9535 \let\thisshortcaption=\empty
9536 %
9537 % don't lose footnotes inside @float.
9538 %
9539 % BEWARE: when the floats start float, we have to issue warning whenever an
9540 % insert appears inside a float which could possibly float. --kasal, 26may04
9541 %
9542 \startsavinginserts
9543 %
9544 % We can't be used inside a paragraph.
9545 \par
9546 %
9547 \vtop\bgroup
9548 \def\floattype{#1}%
9549 \def\floatlabel{#2}%
9550 \def\floatloc{#3}% we do nothing with this yet.
9551 %
9552 \ifx\floattype\empty
9553 \let\safefloattype=\empty
9554 \else
9555 {%
9556 % the floattype might have accents or other special characters,
9557 % but we need to use it in a control sequence name.
9558 \indexnofonts
9559 \turnoffactive
9560 \xdef\safefloattype{\floattype}%
9561 }%
9562 \fi
9563 %
9564 % If label is given but no type, we handle that as the empty type.
9565 \ifx\floatlabel\empty \else
9566 % We want each FLOATTYPE to be numbered separately (Figure 1,
9567 % Table 1, Figure 2, ...). (And if no label, no number.)
9568 %
9569 \expandafter\getfloatno\csname\safefloattype floatno\endcsname
9570 \global\advance\floatno by 1
9571 %
9572 {%
c94f48d7 9573 % This magic value for \lastsection is output by \setref as the
82d5ce1d
UD
9574 % XREFLABEL-title value. \xrefX uses it to distinguish float
9575 % labels (which have a completely different output format) from
9576 % node and anchor labels. And \xrdef uses it to construct the
9577 % lists of floats.
9578 %
c94f48d7 9579 \edef\lastsection{\floatmagic=\safefloattype}%
82d5ce1d
UD
9580 \setref{\floatlabel}{Yfloat}%
9581 }%
9582 \fi
9583 %
9584 % start with \parskip glue, I guess.
9585 \vskip\parskip
9586 %
9587 % Don't suppress indentation if a float happens to start a section.
9588 \restorefirstparagraphindent
9589}
9590
9591% we have these possibilities:
9592% @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap
9593% @float Foo,lbl & no caption: Foo 1.1
9594% @float Foo & @caption{Cap}: Foo: Cap
9595% @float Foo & no caption: Foo
9596% @float ,lbl & Caption{Cap}: 1.1: Cap
9597% @float ,lbl & no caption: 1.1
9598% @float & @caption{Cap}: Cap
9599% @float & no caption:
9600%
9601\def\Efloat{%
9602 \let\floatident = \empty
9603 %
9604 % In all cases, if we have a float type, it comes first.
9605 \ifx\floattype\empty \else \def\floatident{\floattype}\fi
9606 %
9607 % If we have an xref label, the number comes next.
9608 \ifx\floatlabel\empty \else
9609 \ifx\floattype\empty \else % if also had float type, need tie first.
9610 \appendtomacro\floatident{\tie}%
9611 \fi
9612 % the number.
9613 \appendtomacro\floatident{\chaplevelprefix\the\floatno}%
9614 \fi
9615 %
9616 % Start the printed caption with what we've constructed in
9617 % \floatident, but keep it separate; we need \floatident again.
9618 \let\captionline = \floatident
9619 %
9620 \ifx\thiscaption\empty \else
9621 \ifx\floatident\empty \else
7f7dd1d3 9622 \appendtomacro\captionline{: }% had ident, so need a colon between
82d5ce1d
UD
9623 \fi
9624 %
9625 % caption text.
9626 \appendtomacro\captionline{\scanexp\thiscaption}%
9627 \fi
9628 %
9629 % If we have anything to print, print it, with space before.
9630 % Eventually this needs to become an \insert.
9631 \ifx\captionline\empty \else
9632 \vskip.5\parskip
9633 \captionline
9634 %
9635 % Space below caption.
9636 \vskip\parskip
9637 \fi
9638 %
9639 % If have an xref label, write the list of floats info. Do this
9640 % after the caption, to avoid chance of it being a breakpoint.
9641 \ifx\floatlabel\empty \else
9642 % Write the text that goes in the lof to the aux file as
9643 % \floatlabel-lof. Besides \floatident, we include the short
9644 % caption if specified, else the full caption if specified, else nothing.
9645 {%
084e7d57 9646 \requireauxfile
9251c568
AJ
9647 \atdummies
9648 %
7f7dd1d3
JM
9649 \ifx\thisshortcaption\empty
9650 \def\gtemp{\thiscaption}%
9651 \else
9652 \def\gtemp{\thisshortcaption}%
9653 \fi
82d5ce1d 9654 \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident
7f7dd1d3 9655 \ifx\gtemp\empty \else : \gtemp \fi}}%
82d5ce1d
UD
9656 }%
9657 \fi
9658 \egroup % end of \vtop
9659 %
82d5ce1d
UD
9660 \checkinserts
9661}
9662
9663% Append the tokens #2 to the definition of macro #1, not expanding either.
9664%
9665\def\appendtomacro#1#2{%
9666 \expandafter\def\expandafter#1\expandafter{#1#2}%
9667}
9668
9669% @caption, @shortcaption
9670%
9671\def\caption{\docaption\thiscaption}
9672\def\shortcaption{\docaption\thisshortcaption}
9673\def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption}
9674\def\defcaption#1#2{\egroup \def#1{#2}}
9675
9676% The parameter is the control sequence identifying the counter we are
9677% going to use. Create it if it doesn't exist and assign it to \floatno.
9678\def\getfloatno#1{%
9679 \ifx#1\relax
9680 % Haven't seen this figure type before.
9681 \csname newcount\endcsname #1%
9682 %
9683 % Remember to reset this floatno at the next chap.
9684 \expandafter\gdef\expandafter\resetallfloatnos
9685 \expandafter{\resetallfloatnos #1=0 }%
9686 \fi
9687 \let\floatno#1%
9688}
9689
9690% \setref calls this to get the XREFLABEL-snt value. We want an @xref
9691% to the FLOATLABEL to expand to "Figure 3.1". We call \setref when we
9692% first read the @float command.
9693%
9694\def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}%
9695
9696% Magic string used for the XREFLABEL-title value, so \xrefX can
9697% distinguish floats from other xref types.
9698\def\floatmagic{!!float!!}
9699
9700% #1 is the control sequence we are passed; we expand into a conditional
9701% which is true if #1 represents a float ref. That is, the magic
c94f48d7 9702% \lastsection value which we \setref above.
82d5ce1d
UD
9703%
9704\def\iffloat#1{\expandafter\doiffloat#1==\finish}
9705%
9706% #1 is (maybe) the \floatmagic string. If so, #2 will be the
9707% (safe) float type for this float. We set \iffloattype to #2.
9708%
9709\def\doiffloat#1=#2=#3\finish{%
9710 \def\temp{#1}%
9711 \def\iffloattype{#2}%
9712 \ifx\temp\floatmagic
9713}
9714
9715% @listoffloats FLOATTYPE - print a list of floats like a table of contents.
9716%
9717\parseargdef\listoffloats{%
9718 \def\floattype{#1}% floattype
9719 {%
9720 % the floattype might have accents or other special characters,
9721 % but we need to use it in a control sequence name.
9722 \indexnofonts
9723 \turnoffactive
9724 \xdef\safefloattype{\floattype}%
9725 }%
9726 %
9727 % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE.
9728 \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax
9729 \ifhavexrefs
9730 % if the user said @listoffloats foo but never @float foo.
9731 \message{\linenumber No `\safefloattype' floats to list.}%
9732 \fi
9733 \else
9734 \begingroup
9735 \leftskip=\tocindent % indent these entries like a toc
9736 \let\do=\listoffloatsdo
9737 \csname floatlist\safefloattype\endcsname
9738 \endgroup
9739 \fi
9740}
9741
9742% This is called on each entry in a list of floats. We're passed the
9743% xref label, in the form LABEL-title, which is how we save it in the
9744% aux file. We strip off the -title and look up \XRLABEL-lof, which
9745% has the text we're supposed to typeset here.
9746%
9747% Figures without xref labels will not be included in the list (since
9748% they won't appear in the aux file).
9749%
9750\def\listoffloatsdo#1{\listoffloatsdoentry#1\finish}
9751\def\listoffloatsdoentry#1-title\finish{{%
9752 % Can't fully expand XR#1-lof because it can contain anything. Just
9753 % pass the control sequence. On the other hand, XR#1-pg is just the
9754 % page number, and we want to fully expand that so we can get a link
9755 % in pdf output.
9756 \toksA = \expandafter{\csname XR#1-lof\endcsname}%
9757 %
9758 % use the same \entry macro we use to generate the TOC and index.
9759 \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}%
9760 \writeentry
9761}}
9762
c94f48d7 9763
407dc7a0
UD
9764\message{localization,}
9765
0f8bbd69
JM
9766% For single-language documents, @documentlanguage is usually given very
9767% early, just after @documentencoding. Single argument is the language
9768% (de) or locale (de_DE) abbreviation.
407dc7a0 9769%
c94f48d7
AJ
9770{
9771 \catcode`\_ = \active
9772 \globaldefs=1
084e7d57 9773\parseargdef\documentlanguage{%
407dc7a0 9774 \tex % read txi-??.tex file in plain TeX.
c94f48d7 9775 % Read the file by the name they passed if it exists.
084e7d57 9776 \let_ = \normalunderscore % normal _ character for filename test
82d5ce1d
UD
9777 \openin 1 txi-#1.tex
9778 \ifeof 1
084e7d57 9779 \documentlanguagetrywithoutunderscore #1_\finish
82d5ce1d 9780 \else
0f8bbd69 9781 \globaldefs = 1 % everything in the txi-LL files needs to persist
82d5ce1d
UD
9782 \input txi-#1.tex
9783 \fi
9784 \closein 1
0f8bbd69 9785 \endgroup % end raw TeX
084e7d57 9786}
c94f48d7
AJ
9787%
9788% If they passed de_DE, and txi-de_DE.tex doesn't exist,
9789% try txi-de.tex.
0f8bbd69
JM
9790%
9791\gdef\documentlanguagetrywithoutunderscore#1_#2\finish{%
c94f48d7
AJ
9792 \openin 1 txi-#1.tex
9793 \ifeof 1
9794 \errhelp = \nolanghelp
9795 \errmessage{Cannot read language file txi-#1.tex}%
9796 \else
0f8bbd69 9797 \globaldefs = 1 % everything in the txi-LL files needs to persist
c94f48d7
AJ
9798 \input txi-#1.tex
9799 \fi
9800 \closein 1
9801}
0f8bbd69 9802}% end of special _ catcode
c94f48d7 9803%
407dc7a0 9804\newhelp\nolanghelp{The given language definition file cannot be found or
0f8bbd69
JM
9805is empty. Maybe you need to install it? Putting it in the current
9806directory should work if nowhere else does.}
9807
9808% This macro is called from txi-??.tex files; the first argument is the
9809% \language name to set (without the "\lang@" prefix), the second and
9810% third args are \{left,right}hyphenmin.
9811%
9812% The language names to pass are determined when the format is built.
9813% See the etex.log file created at that time, e.g.,
9814% /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log.
9815%
9816% With TeX Live 2008, etex now includes hyphenation patterns for all
9817% available languages. This means we can support hyphenation in
9818% Texinfo, at least to some extent. (This still doesn't solve the
9819% accented characters problem.)
9820%
9821\catcode`@=11
9822\def\txisetlanguage#1#2#3{%
9823 % do not set the language if the name is undefined in the current TeX.
9824 \expandafter\ifx\csname lang@#1\endcsname \relax
9825 \message{no patterns for #1}%
9826 \else
9827 \global\language = \csname lang@#1\endcsname
9828 \fi
9829 % but there is no harm in adjusting the hyphenmin values regardless.
9830 \global\lefthyphenmin = #2\relax
9831 \global\righthyphenmin = #3\relax
9832}
407dc7a0 9833
7f7dd1d3
JM
9834% XeTeX and LuaTeX can handle Unicode natively.
9835% Their default I/O uses UTF-8 sequences instead of a byte-wise operation.
9836% Other TeX engines' I/O (pdfTeX, etc.) is byte-wise.
9837%
9838\newif\iftxinativeunicodecapable
9839\newif\iftxiusebytewiseio
9840
084e7d57 9841\ifx\XeTeXrevision\thisisundefined
7f7dd1d3
JM
9842 \ifx\luatexversion\thisisundefined
9843 \txinativeunicodecapablefalse
9844 \txiusebytewiseiotrue
9845 \else
9846 \txinativeunicodecapabletrue
9847 \txiusebytewiseiofalse
9848 \fi
084e7d57 9849\else
7f7dd1d3
JM
9850 \txinativeunicodecapabletrue
9851 \txiusebytewiseiofalse
084e7d57
JM
9852\fi
9853
7f7dd1d3
JM
9854% Set I/O by bytes instead of UTF-8 sequence for XeTeX and LuaTex
9855% for non-UTF-8 (byte-wise) encodings.
9856%
9857\def\setbytewiseio{%
9858 \ifx\XeTeXrevision\thisisundefined
9859 \else
9860 \XeTeXdefaultencoding "bytes" % For subsequent files to be read
9861 \XeTeXinputencoding "bytes" % For document root file
9862 % Unfortunately, there seems to be no corresponding XeTeX command for
9863 % output encoding. This is a problem for auxiliary index and TOC files.
9864 % The only solution would be perhaps to write out @U{...} sequences in
9865 % place of non-ASCII characters.
9866 \fi
084e7d57 9867
7f7dd1d3
JM
9868 \ifx\luatexversion\thisisundefined
9869 \else
9870 \directlua{
9871 local utf8_char, byte, gsub = unicode.utf8.char, string.byte, string.gsub
9872 local function convert_char (char)
9873 return utf8_char(byte(char))
9874 end
9875
9876 local function convert_line (line)
9877 return gsub(line, ".", convert_char)
9878 end
9879
9880 callback.register("process_input_buffer", convert_line)
9881
9882 local function convert_line_out (line)
9883 local line_out = ""
9884 for c in string.utfvalues(line) do
9885 line_out = line_out .. string.char(c)
9886 end
9887 return line_out
9888 end
9889
9890 callback.register("process_output_buffer", convert_line_out)
9891 }
9892 \fi
084e7d57 9893
7f7dd1d3 9894 \txiusebytewiseiotrue
084e7d57 9895}
084e7d57
JM
9896
9897
0f8bbd69 9898% Helpers for encodings.
c94f48d7
AJ
9899% Set the catcode of characters 128 through 255 to the specified number.
9900%
9901\def\setnonasciicharscatcode#1{%
9902 \count255=128
9903 \loop\ifnum\count255<256
9904 \global\catcode\count255=#1\relax
9905 \advance\count255 by 1
9906 \repeat
9907}
407dc7a0 9908
c94f48d7
AJ
9909\def\setnonasciicharscatcodenonglobal#1{%
9910 \count255=128
9911 \loop\ifnum\count255<256
9912 \catcode\count255=#1\relax
9913 \advance\count255 by 1
9914 \repeat
9915}
9916
9917% @documentencoding sets the definition of non-ASCII characters
9918% according to the specified encoding.
9919%
084e7d57
JM
9920\def\documentencoding{\parseargusing\filenamecatcodes\documentencodingzzz}
9921\def\documentencodingzzz#1{%
7f7dd1d3 9922 %
c94f48d7
AJ
9923 % Encoding being declared for the document.
9924 \def\declaredencoding{\csname #1.enc\endcsname}%
9925 %
9926 % Supported encodings: names converted to tokens in order to be able
9927 % to compare them with \ifx.
9928 \def\ascii{\csname US-ASCII.enc\endcsname}%
9929 \def\latnine{\csname ISO-8859-15.enc\endcsname}%
9930 \def\latone{\csname ISO-8859-1.enc\endcsname}%
9931 \def\lattwo{\csname ISO-8859-2.enc\endcsname}%
9932 \def\utfeight{\csname UTF-8.enc\endcsname}%
9933 %
9934 \ifx \declaredencoding \ascii
9935 \asciichardefs
9936 %
9937 \else \ifx \declaredencoding \lattwo
7f7dd1d3
JM
9938 \iftxinativeunicodecapable
9939 \setbytewiseio
9940 \fi
c94f48d7
AJ
9941 \setnonasciicharscatcode\active
9942 \lattwochardefs
9943 %
0f8bbd69 9944 \else \ifx \declaredencoding \latone
7f7dd1d3
JM
9945 \iftxinativeunicodecapable
9946 \setbytewiseio
9947 \fi
c94f48d7
AJ
9948 \setnonasciicharscatcode\active
9949 \latonechardefs
9950 %
9951 \else \ifx \declaredencoding \latnine
7f7dd1d3
JM
9952 \iftxinativeunicodecapable
9953 \setbytewiseio
9954 \fi
c94f48d7
AJ
9955 \setnonasciicharscatcode\active
9956 \latninechardefs
9957 %
9958 \else \ifx \declaredencoding \utfeight
7f7dd1d3
JM
9959 \iftxinativeunicodecapable
9960 % For native Unicode handling (XeTeX and LuaTeX)
9961 \nativeunicodechardefs
9962 \else
9963 % For treating UTF-8 as byte sequences (TeX, eTeX and pdfTeX)
9964 \setnonasciicharscatcode\active
9965 % since we already invoked \utfeightchardefs at the top level
9966 % (below), do not re-invoke it, otherwise our check for duplicated
9967 % definitions gets triggered. Making non-ascii chars active is
9968 % sufficient.
9969 \fi
c94f48d7 9970 %
0f8bbd69 9971 \else
084e7d57 9972 \message{Ignoring unknown document encoding: #1.}%
c94f48d7
AJ
9973 %
9974 \fi % utfeight
9975 \fi % latnine
9976 \fi % latone
9977 \fi % lattwo
9978 \fi % ascii
7f7dd1d3
JM
9979 %
9980 \ifx\XeTeXrevision\thisisundefined
9981 \else
9982 \ifx \declaredencoding \utfeight
9983 \else
9984 \ifx \declaredencoding \ascii
9985 \else
9986 \message{Warning: XeTeX with non-UTF-8 encodings cannot handle %
9987 non-ASCII characters in auxiliary files.}%
9988 \fi
9989 \fi
9990 \fi
c94f48d7 9991}
9e9f9cc2 9992
084e7d57 9993% emacs-page
c94f48d7
AJ
9994% A message to be logged when using a character that isn't available
9995% the default font encoding (OT1).
0f8bbd69 9996%
084e7d57 9997\def\missingcharmsg#1{\message{Character missing, sorry: #1.}}
c94f48d7
AJ
9998
9999% Take account of \c (plain) vs. \, (Texinfo) difference.
10000\def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi}
10001
10002% First, make active non-ASCII characters in order for them to be
10003% correctly categorized when TeX reads the replacement text of
10004% macros containing the character definitions.
10005\setnonasciicharscatcode\active
10006%
7f7dd1d3
JM
10007
10008\def\gdefchar#1#2{%
10009\gdef#1{%
10010 \ifpassthroughchars
10011 \string#1%
10012 \else
10013 #2%
10014 \fi
10015}}
10016
c94f48d7
AJ
10017% Latin1 (ISO-8859-1) character definitions.
10018\def\latonechardefs{%
7f7dd1d3
JM
10019 \gdefchar^^a0{\tie}
10020 \gdefchar^^a1{\exclamdown}
10021 \gdefchar^^a2{{\tcfont \char162}} % cent
10022 \gdefchar^^a3{\pounds{}}
10023 \gdefchar^^a4{{\tcfont \char164}} % currency
10024 \gdefchar^^a5{{\tcfont \char165}} % yen
10025 \gdefchar^^a6{{\tcfont \char166}} % broken bar
10026 \gdefchar^^a7{\S}
10027 \gdefchar^^a8{\"{}}
10028 \gdefchar^^a9{\copyright{}}
10029 \gdefchar^^aa{\ordf}
10030 \gdefchar^^ab{\guillemetleft{}}
10031 \gdefchar^^ac{\ensuremath\lnot}
10032 \gdefchar^^ad{\-}
10033 \gdefchar^^ae{\registeredsymbol{}}
10034 \gdefchar^^af{\={}}
10035 %
10036 \gdefchar^^b0{\textdegree}
10037 \gdefchar^^b1{$\pm$}
10038 \gdefchar^^b2{$^2$}
10039 \gdefchar^^b3{$^3$}
10040 \gdefchar^^b4{\'{}}
10041 \gdefchar^^b5{$\mu$}
10042 \gdefchar^^b6{\P}
10043 \gdefchar^^b7{\ensuremath\cdot}
10044 \gdefchar^^b8{\cedilla\ }
10045 \gdefchar^^b9{$^1$}
10046 \gdefchar^^ba{\ordm}
10047 \gdefchar^^bb{\guillemetright{}}
10048 \gdefchar^^bc{$1\over4$}
10049 \gdefchar^^bd{$1\over2$}
10050 \gdefchar^^be{$3\over4$}
10051 \gdefchar^^bf{\questiondown}
10052 %
10053 \gdefchar^^c0{\`A}
10054 \gdefchar^^c1{\'A}
10055 \gdefchar^^c2{\^A}
10056 \gdefchar^^c3{\~A}
10057 \gdefchar^^c4{\"A}
10058 \gdefchar^^c5{\ringaccent A}
10059 \gdefchar^^c6{\AE}
10060 \gdefchar^^c7{\cedilla C}
10061 \gdefchar^^c8{\`E}
10062 \gdefchar^^c9{\'E}
10063 \gdefchar^^ca{\^E}
10064 \gdefchar^^cb{\"E}
10065 \gdefchar^^cc{\`I}
10066 \gdefchar^^cd{\'I}
10067 \gdefchar^^ce{\^I}
10068 \gdefchar^^cf{\"I}
10069 %
10070 \gdefchar^^d0{\DH}
10071 \gdefchar^^d1{\~N}
10072 \gdefchar^^d2{\`O}
10073 \gdefchar^^d3{\'O}
10074 \gdefchar^^d4{\^O}
10075 \gdefchar^^d5{\~O}
10076 \gdefchar^^d6{\"O}
10077 \gdefchar^^d7{$\times$}
10078 \gdefchar^^d8{\O}
10079 \gdefchar^^d9{\`U}
10080 \gdefchar^^da{\'U}
10081 \gdefchar^^db{\^U}
10082 \gdefchar^^dc{\"U}
10083 \gdefchar^^dd{\'Y}
10084 \gdefchar^^de{\TH}
10085 \gdefchar^^df{\ss}
10086 %
10087 \gdefchar^^e0{\`a}
10088 \gdefchar^^e1{\'a}
10089 \gdefchar^^e2{\^a}
10090 \gdefchar^^e3{\~a}
10091 \gdefchar^^e4{\"a}
10092 \gdefchar^^e5{\ringaccent a}
10093 \gdefchar^^e6{\ae}
10094 \gdefchar^^e7{\cedilla c}
10095 \gdefchar^^e8{\`e}
10096 \gdefchar^^e9{\'e}
10097 \gdefchar^^ea{\^e}
10098 \gdefchar^^eb{\"e}
10099 \gdefchar^^ec{\`{\dotless i}}
10100 \gdefchar^^ed{\'{\dotless i}}
10101 \gdefchar^^ee{\^{\dotless i}}
10102 \gdefchar^^ef{\"{\dotless i}}
10103 %
10104 \gdefchar^^f0{\dh}
10105 \gdefchar^^f1{\~n}
10106 \gdefchar^^f2{\`o}
10107 \gdefchar^^f3{\'o}
10108 \gdefchar^^f4{\^o}
10109 \gdefchar^^f5{\~o}
10110 \gdefchar^^f6{\"o}
10111 \gdefchar^^f7{$\div$}
10112 \gdefchar^^f8{\o}
10113 \gdefchar^^f9{\`u}
10114 \gdefchar^^fa{\'u}
10115 \gdefchar^^fb{\^u}
10116 \gdefchar^^fc{\"u}
10117 \gdefchar^^fd{\'y}
10118 \gdefchar^^fe{\th}
10119 \gdefchar^^ff{\"y}
c94f48d7
AJ
10120}
10121
10122% Latin9 (ISO-8859-15) encoding character definitions.
10123\def\latninechardefs{%
10124 % Encoding is almost identical to Latin1.
10125 \latonechardefs
10126 %
7f7dd1d3
JM
10127 \gdefchar^^a4{\euro{}}
10128 \gdefchar^^a6{\v S}
10129 \gdefchar^^a8{\v s}
10130 \gdefchar^^b4{\v Z}
10131 \gdefchar^^b8{\v z}
10132 \gdefchar^^bc{\OE}
10133 \gdefchar^^bd{\oe}
10134 \gdefchar^^be{\"Y}
c94f48d7
AJ
10135}
10136
10137% Latin2 (ISO-8859-2) character definitions.
10138\def\lattwochardefs{%
7f7dd1d3
JM
10139 \gdefchar^^a0{\tie}
10140 \gdefchar^^a1{\ogonek{A}}
10141 \gdefchar^^a2{\u{}}
10142 \gdefchar^^a3{\L}
10143 \gdefchar^^a4{\missingcharmsg{CURRENCY SIGN}}
10144 \gdefchar^^a5{\v L}
10145 \gdefchar^^a6{\'S}
10146 \gdefchar^^a7{\S}
10147 \gdefchar^^a8{\"{}}
10148 \gdefchar^^a9{\v S}
10149 \gdefchar^^aa{\cedilla S}
10150 \gdefchar^^ab{\v T}
10151 \gdefchar^^ac{\'Z}
10152 \gdefchar^^ad{\-}
10153 \gdefchar^^ae{\v Z}
10154 \gdefchar^^af{\dotaccent Z}
10155 %
10156 \gdefchar^^b0{\textdegree{}}
10157 \gdefchar^^b1{\ogonek{a}}
10158 \gdefchar^^b2{\ogonek{ }}
10159 \gdefchar^^b3{\l}
10160 \gdefchar^^b4{\'{}}
10161 \gdefchar^^b5{\v l}
10162 \gdefchar^^b6{\'s}
10163 \gdefchar^^b7{\v{}}
10164 \gdefchar^^b8{\cedilla\ }
10165 \gdefchar^^b9{\v s}
10166 \gdefchar^^ba{\cedilla s}
10167 \gdefchar^^bb{\v t}
10168 \gdefchar^^bc{\'z}
10169 \gdefchar^^bd{\H{}}
10170 \gdefchar^^be{\v z}
10171 \gdefchar^^bf{\dotaccent z}
10172 %
10173 \gdefchar^^c0{\'R}
10174 \gdefchar^^c1{\'A}
10175 \gdefchar^^c2{\^A}
10176 \gdefchar^^c3{\u A}
10177 \gdefchar^^c4{\"A}
10178 \gdefchar^^c5{\'L}
10179 \gdefchar^^c6{\'C}
10180 \gdefchar^^c7{\cedilla C}
10181 \gdefchar^^c8{\v C}
10182 \gdefchar^^c9{\'E}
10183 \gdefchar^^ca{\ogonek{E}}
10184 \gdefchar^^cb{\"E}
10185 \gdefchar^^cc{\v E}
10186 \gdefchar^^cd{\'I}
10187 \gdefchar^^ce{\^I}
10188 \gdefchar^^cf{\v D}
10189 %
10190 \gdefchar^^d0{\DH}
10191 \gdefchar^^d1{\'N}
10192 \gdefchar^^d2{\v N}
10193 \gdefchar^^d3{\'O}
10194 \gdefchar^^d4{\^O}
10195 \gdefchar^^d5{\H O}
10196 \gdefchar^^d6{\"O}
10197 \gdefchar^^d7{$\times$}
10198 \gdefchar^^d8{\v R}
10199 \gdefchar^^d9{\ringaccent U}
10200 \gdefchar^^da{\'U}
10201 \gdefchar^^db{\H U}
10202 \gdefchar^^dc{\"U}
10203 \gdefchar^^dd{\'Y}
10204 \gdefchar^^de{\cedilla T}
10205 \gdefchar^^df{\ss}
10206 %
10207 \gdefchar^^e0{\'r}
10208 \gdefchar^^e1{\'a}
10209 \gdefchar^^e2{\^a}
10210 \gdefchar^^e3{\u a}
10211 \gdefchar^^e4{\"a}
10212 \gdefchar^^e5{\'l}
10213 \gdefchar^^e6{\'c}
10214 \gdefchar^^e7{\cedilla c}
10215 \gdefchar^^e8{\v c}
10216 \gdefchar^^e9{\'e}
10217 \gdefchar^^ea{\ogonek{e}}
10218 \gdefchar^^eb{\"e}
10219 \gdefchar^^ec{\v e}
10220 \gdefchar^^ed{\'{\dotless{i}}}
10221 \gdefchar^^ee{\^{\dotless{i}}}
10222 \gdefchar^^ef{\v d}
10223 %
10224 \gdefchar^^f0{\dh}
10225 \gdefchar^^f1{\'n}
10226 \gdefchar^^f2{\v n}
10227 \gdefchar^^f3{\'o}
10228 \gdefchar^^f4{\^o}
10229 \gdefchar^^f5{\H o}
10230 \gdefchar^^f6{\"o}
10231 \gdefchar^^f7{$\div$}
10232 \gdefchar^^f8{\v r}
10233 \gdefchar^^f9{\ringaccent u}
10234 \gdefchar^^fa{\'u}
10235 \gdefchar^^fb{\H u}
10236 \gdefchar^^fc{\"u}
10237 \gdefchar^^fd{\'y}
10238 \gdefchar^^fe{\cedilla t}
10239 \gdefchar^^ff{\dotaccent{}}
c94f48d7
AJ
10240}
10241
10242% UTF-8 character definitions.
0f8bbd69 10243%
c94f48d7
AJ
10244% This code to support UTF-8 is based on LaTeX's utf8.def, with some
10245% changes for Texinfo conventions. It is included here under the GPL by
10246% permission from Frank Mittelbach and the LaTeX team.
0f8bbd69 10247%
c94f48d7
AJ
10248\newcount\countUTFx
10249\newcount\countUTFy
10250\newcount\countUTFz
407dc7a0 10251
c94f48d7
AJ
10252\gdef\UTFviiiTwoOctets#1#2{\expandafter
10253 \UTFviiiDefined\csname u8:#1\string #2\endcsname}
10254%
10255\gdef\UTFviiiThreeOctets#1#2#3{\expandafter
10256 \UTFviiiDefined\csname u8:#1\string #2\string #3\endcsname}
407dc7a0 10257%
c94f48d7
AJ
10258\gdef\UTFviiiFourOctets#1#2#3#4{\expandafter
10259 \UTFviiiDefined\csname u8:#1\string #2\string #3\string #4\endcsname}
10260
10261\gdef\UTFviiiDefined#1{%
10262 \ifx #1\relax
10263 \message{\linenumber Unicode char \string #1 not defined for Texinfo}%
10264 \else
10265 \expandafter #1%
10266 \fi
10267}
10268
7f7dd1d3 10269% Give non-ASCII bytes the active definitions for processing UTF-8 sequences
c94f48d7
AJ
10270\begingroup
10271 \catcode`\~13
7f7dd1d3 10272 \catcode`\$12
c94f48d7
AJ
10273 \catcode`\"12
10274
7f7dd1d3
JM
10275 % Loop from \countUTFx to \countUTFy, performing \UTFviiiTmp
10276 % substituting ~ and $ with a character token of that value.
c94f48d7
AJ
10277 \def\UTFviiiLoop{%
10278 \global\catcode\countUTFx\active
10279 \uccode`\~\countUTFx
7f7dd1d3 10280 \uccode`\$\countUTFx
c94f48d7
AJ
10281 \uppercase\expandafter{\UTFviiiTmp}%
10282 \advance\countUTFx by 1
10283 \ifnum\countUTFx < \countUTFy
10284 \expandafter\UTFviiiLoop
10285 \fi}
10286
7f7dd1d3
JM
10287 % For bytes other than the first in a UTF-8 sequence. Not expected to
10288 % be expanded except when writing to auxiliary files.
10289 \countUTFx = "80
10290 \countUTFy = "C2
10291 \def\UTFviiiTmp{%
10292 \gdef~{%
10293 \ifpassthroughchars $\fi}}%
10294 \UTFviiiLoop
10295
c94f48d7
AJ
10296 \countUTFx = "C2
10297 \countUTFy = "E0
10298 \def\UTFviiiTmp{%
7f7dd1d3
JM
10299 \gdef~{%
10300 \ifpassthroughchars $%
10301 \else\expandafter\UTFviiiTwoOctets\expandafter$\fi}}%
c94f48d7
AJ
10302 \UTFviiiLoop
10303
10304 \countUTFx = "E0
10305 \countUTFy = "F0
10306 \def\UTFviiiTmp{%
7f7dd1d3
JM
10307 \gdef~{%
10308 \ifpassthroughchars $%
10309 \else\expandafter\UTFviiiThreeOctets\expandafter$\fi}}%
c94f48d7
AJ
10310 \UTFviiiLoop
10311
10312 \countUTFx = "F0
10313 \countUTFy = "F4
10314 \def\UTFviiiTmp{%
7f7dd1d3
JM
10315 \gdef~{%
10316 \ifpassthroughchars $%
10317 \else\expandafter\UTFviiiFourOctets\expandafter$\fi
10318 }}%
c94f48d7
AJ
10319 \UTFviiiLoop
10320\endgroup
10321
084e7d57
JM
10322\def\globallet{\global\let} % save some \expandafter's below
10323
10324% @U{xxxx} to produce U+xxxx, if we support it.
10325\def\U#1{%
10326 \expandafter\ifx\csname uni:#1\endcsname \relax
7f7dd1d3
JM
10327 \iftxinativeunicodecapable
10328 % All Unicode characters can be used if native Unicode handling is
10329 % active. However, if the font does not have the glyph,
10330 % letters are missing.
10331 \begingroup
10332 \uccode`\.="#1\relax
10333 \uppercase{.}
10334 \endgroup
10335 \else
10336 \errhelp = \EMsimple
10337 \errmessage{Unicode character U+#1 not supported, sorry}%
10338 \fi
084e7d57
JM
10339 \else
10340 \csname uni:#1\endcsname
10341 \fi
10342}
10343
7f7dd1d3
JM
10344% These macros are used here to construct the name of a control
10345% sequence to be defined.
10346\def\UTFviiiTwoOctetsName#1#2{%
10347 \csname u8:#1\string #2\endcsname}%
10348\def\UTFviiiThreeOctetsName#1#2#3{%
10349 \csname u8:#1\string #2\string #3\endcsname}%
10350\def\UTFviiiFourOctetsName#1#2#3#4{%
10351 \csname u8:#1\string #2\string #3\string #4\endcsname}%
10352
10353% For UTF-8 byte sequences (TeX, e-TeX and pdfTeX),
10354% provide a definition macro to replace a Unicode character;
10355% this gets used by the @U command
10356%
c94f48d7
AJ
10357\begingroup
10358 \catcode`\"=12
10359 \catcode`\<=12
10360 \catcode`\.=12
10361 \catcode`\,=12
10362 \catcode`\;=12
10363 \catcode`\!=12
10364 \catcode`\~=13
7f7dd1d3 10365 \gdef\DeclareUnicodeCharacterUTFviii#1#2{%
c94f48d7 10366 \countUTFz = "#1\relax
c94f48d7
AJ
10367 \begingroup
10368 \parseXMLCharref
7f7dd1d3
JM
10369
10370 % Give \u8:... its definition. The sequence of seven \expandafter's
10371 % expands after the \gdef three times, e.g.
10372 %
10373 % 1. \UTFviiTwoOctetsName B1 B2
10374 % 2. \csname u8:B1 \string B2 \endcsname
10375 % 3. \u8: B1 B2 (a single control sequence token)
10376 %
10377 \expandafter\expandafter
10378 \expandafter\expandafter
10379 \expandafter\expandafter
10380 \expandafter\gdef \UTFviiiTmp{#2}%
084e7d57
JM
10381 %
10382 \expandafter\ifx\csname uni:#1\endcsname \relax \else
10383 \message{Internal error, already defined: #1}%
10384 \fi
10385 %
10386 % define an additional control sequence for this code point.
10387 \expandafter\globallet\csname uni:#1\endcsname \UTFviiiTmp
c94f48d7 10388 \endgroup}
7f7dd1d3
JM
10389 %
10390 % Given the value in \countUTFz as a Unicode code point, set \UTFviiiTmp
10391 % to the corresponding UTF-8 sequence.
c94f48d7
AJ
10392 \gdef\parseXMLCharref{%
10393 \ifnum\countUTFz < "A0\relax
10394 \errhelp = \EMsimple
10395 \errmessage{Cannot define Unicode char value < 00A0}%
10396 \else\ifnum\countUTFz < "800\relax
10397 \parseUTFviiiA,%
7f7dd1d3 10398 \parseUTFviiiB C\UTFviiiTwoOctetsName.,%
c94f48d7
AJ
10399 \else\ifnum\countUTFz < "10000\relax
10400 \parseUTFviiiA;%
10401 \parseUTFviiiA,%
7f7dd1d3 10402 \parseUTFviiiB E\UTFviiiThreeOctetsName.{,;}%
c94f48d7
AJ
10403 \else
10404 \parseUTFviiiA;%
10405 \parseUTFviiiA,%
10406 \parseUTFviiiA!%
7f7dd1d3 10407 \parseUTFviiiB F\UTFviiiFourOctetsName.{!,;}%
c94f48d7
AJ
10408 \fi\fi\fi
10409 }
10410
7f7dd1d3
JM
10411 % Extract a byte from the end of the UTF-8 representation of \countUTFx.
10412 % It must be a non-initial byte in the sequence.
10413 % Change \uccode of #1 for it to be used in \parseUTFviiiB as one
10414 % of the bytes.
c94f48d7
AJ
10415 \gdef\parseUTFviiiA#1{%
10416 \countUTFx = \countUTFz
10417 \divide\countUTFz by 64
7f7dd1d3 10418 \countUTFy = \countUTFz % Save to be the future value of \countUTFz.
c94f48d7 10419 \multiply\countUTFz by 64
7f7dd1d3
JM
10420
10421 % \countUTFz is now \countUTFx with the last 5 bits cleared. Subtract
10422 % in order to get the last five bits.
c94f48d7 10423 \advance\countUTFx by -\countUTFz
7f7dd1d3
JM
10424
10425 % Convert this to the byte in the UTF-8 sequence.
c94f48d7
AJ
10426 \advance\countUTFx by 128
10427 \uccode `#1\countUTFx
10428 \countUTFz = \countUTFy}
10429
7f7dd1d3
JM
10430 % Used to put a UTF-8 byte sequence into \UTFviiiTmp
10431 % #1 is the increment for \countUTFz to yield a the first byte of the UTF-8
10432 % sequence.
10433 % #2 is one of the \UTFviii*OctetsName macros.
10434 % #3 is always a full stop (.)
10435 % #4 is a template for the other bytes in the sequence. The values for these
10436 % bytes is substituted in here with \uppercase using the \uccode's.
c94f48d7
AJ
10437 \gdef\parseUTFviiiB#1#2#3#4{%
10438 \advance\countUTFz by "#10\relax
10439 \uccode `#3\countUTFz
10440 \uppercase{\gdef\UTFviiiTmp{#2#3#4}}}
10441\endgroup
10442
7f7dd1d3
JM
10443% For native Unicode handling (XeTeX and LuaTeX),
10444% provide a definition macro that sets a catcode to `other' non-globally
10445%
10446\def\DeclareUnicodeCharacterNativeOther#1#2{%
10447 \catcode"#1=\other
10448}
10449
084e7d57
JM
10450% https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_M
10451% U+0000..U+007F = https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block)
10452% U+0080..U+00FF = https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block)
10453% U+0100..U+017F = https://en.wikipedia.org/wiki/Latin_Extended-A
10454% U+0180..U+024F = https://en.wikipedia.org/wiki/Latin_Extended-B
10455%
10456% Many of our renditions are less than wonderful, and all the missing
10457% characters are available somewhere. Loading the necessary fonts
10458% awaits user request. We can't truly support Unicode without
10459% reimplementing everything that's been done in LaTeX for many years,
10460% plus probably using luatex or xetex, and who knows what else.
10461% We won't be doing that here in this simple file. But we can try to at
10462% least make most of the characters not bomb out.
10463%
7f7dd1d3
JM
10464\def\unicodechardefs{%
10465 \DeclareUnicodeCharacter{00A0}{\tie}%
10466 \DeclareUnicodeCharacter{00A1}{\exclamdown}%
084e7d57 10467 \DeclareUnicodeCharacter{00A2}{{\tcfont \char162}}% 0242=cent
7f7dd1d3 10468 \DeclareUnicodeCharacter{00A3}{\pounds{}}%
084e7d57
JM
10469 \DeclareUnicodeCharacter{00A4}{{\tcfont \char164}}% 0244=currency
10470 \DeclareUnicodeCharacter{00A5}{{\tcfont \char165}}% 0245=yen
10471 \DeclareUnicodeCharacter{00A6}{{\tcfont \char166}}% 0246=brokenbar
7f7dd1d3
JM
10472 \DeclareUnicodeCharacter{00A7}{\S}%
10473 \DeclareUnicodeCharacter{00A8}{\"{ }}%
10474 \DeclareUnicodeCharacter{00A9}{\copyright{}}%
10475 \DeclareUnicodeCharacter{00AA}{\ordf}%
10476 \DeclareUnicodeCharacter{00AB}{\guillemetleft{}}%
10477 \DeclareUnicodeCharacter{00AC}{\ensuremath\lnot}%
10478 \DeclareUnicodeCharacter{00AD}{\-}%
10479 \DeclareUnicodeCharacter{00AE}{\registeredsymbol{}}%
10480 \DeclareUnicodeCharacter{00AF}{\={ }}%
10481 %
10482 \DeclareUnicodeCharacter{00B0}{\ringaccent{ }}%
10483 \DeclareUnicodeCharacter{00B1}{\ensuremath\pm}%
10484 \DeclareUnicodeCharacter{00B2}{$^2$}%
10485 \DeclareUnicodeCharacter{00B3}{$^3$}%
10486 \DeclareUnicodeCharacter{00B4}{\'{ }}%
10487 \DeclareUnicodeCharacter{00B5}{$\mu$}%
10488 \DeclareUnicodeCharacter{00B6}{\P}%
10489 \DeclareUnicodeCharacter{00B7}{\ensuremath\cdot}%
10490 \DeclareUnicodeCharacter{00B8}{\cedilla{ }}%
10491 \DeclareUnicodeCharacter{00B9}{$^1$}%
10492 \DeclareUnicodeCharacter{00BA}{\ordm}%
10493 \DeclareUnicodeCharacter{00BB}{\guillemetright{}}%
10494 \DeclareUnicodeCharacter{00BC}{$1\over4$}%
10495 \DeclareUnicodeCharacter{00BD}{$1\over2$}%
10496 \DeclareUnicodeCharacter{00BE}{$3\over4$}%
10497 \DeclareUnicodeCharacter{00BF}{\questiondown}%
10498 %
10499 \DeclareUnicodeCharacter{00C0}{\`A}%
10500 \DeclareUnicodeCharacter{00C1}{\'A}%
10501 \DeclareUnicodeCharacter{00C2}{\^A}%
10502 \DeclareUnicodeCharacter{00C3}{\~A}%
10503 \DeclareUnicodeCharacter{00C4}{\"A}%
10504 \DeclareUnicodeCharacter{00C5}{\AA}%
10505 \DeclareUnicodeCharacter{00C6}{\AE}%
10506 \DeclareUnicodeCharacter{00C7}{\cedilla{C}}%
10507 \DeclareUnicodeCharacter{00C8}{\`E}%
10508 \DeclareUnicodeCharacter{00C9}{\'E}%
10509 \DeclareUnicodeCharacter{00CA}{\^E}%
10510 \DeclareUnicodeCharacter{00CB}{\"E}%
10511 \DeclareUnicodeCharacter{00CC}{\`I}%
10512 \DeclareUnicodeCharacter{00CD}{\'I}%
10513 \DeclareUnicodeCharacter{00CE}{\^I}%
10514 \DeclareUnicodeCharacter{00CF}{\"I}%
10515 %
10516 \DeclareUnicodeCharacter{00D0}{\DH}%
10517 \DeclareUnicodeCharacter{00D1}{\~N}%
10518 \DeclareUnicodeCharacter{00D2}{\`O}%
10519 \DeclareUnicodeCharacter{00D3}{\'O}%
10520 \DeclareUnicodeCharacter{00D4}{\^O}%
10521 \DeclareUnicodeCharacter{00D5}{\~O}%
10522 \DeclareUnicodeCharacter{00D6}{\"O}%
10523 \DeclareUnicodeCharacter{00D7}{\ensuremath\times}%
10524 \DeclareUnicodeCharacter{00D8}{\O}%
10525 \DeclareUnicodeCharacter{00D9}{\`U}%
10526 \DeclareUnicodeCharacter{00DA}{\'U}%
10527 \DeclareUnicodeCharacter{00DB}{\^U}%
10528 \DeclareUnicodeCharacter{00DC}{\"U}%
10529 \DeclareUnicodeCharacter{00DD}{\'Y}%
10530 \DeclareUnicodeCharacter{00DE}{\TH}%
10531 \DeclareUnicodeCharacter{00DF}{\ss}%
10532 %
10533 \DeclareUnicodeCharacter{00E0}{\`a}%
10534 \DeclareUnicodeCharacter{00E1}{\'a}%
10535 \DeclareUnicodeCharacter{00E2}{\^a}%
10536 \DeclareUnicodeCharacter{00E3}{\~a}%
10537 \DeclareUnicodeCharacter{00E4}{\"a}%
10538 \DeclareUnicodeCharacter{00E5}{\aa}%
10539 \DeclareUnicodeCharacter{00E6}{\ae}%
10540 \DeclareUnicodeCharacter{00E7}{\cedilla{c}}%
10541 \DeclareUnicodeCharacter{00E8}{\`e}%
10542 \DeclareUnicodeCharacter{00E9}{\'e}%
10543 \DeclareUnicodeCharacter{00EA}{\^e}%
10544 \DeclareUnicodeCharacter{00EB}{\"e}%
10545 \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}}%
10546 \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}}%
10547 \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}}%
10548 \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}}%
10549 %
10550 \DeclareUnicodeCharacter{00F0}{\dh}%
10551 \DeclareUnicodeCharacter{00F1}{\~n}%
10552 \DeclareUnicodeCharacter{00F2}{\`o}%
10553 \DeclareUnicodeCharacter{00F3}{\'o}%
10554 \DeclareUnicodeCharacter{00F4}{\^o}%
10555 \DeclareUnicodeCharacter{00F5}{\~o}%
10556 \DeclareUnicodeCharacter{00F6}{\"o}%
10557 \DeclareUnicodeCharacter{00F7}{\ensuremath\div}%
10558 \DeclareUnicodeCharacter{00F8}{\o}%
10559 \DeclareUnicodeCharacter{00F9}{\`u}%
10560 \DeclareUnicodeCharacter{00FA}{\'u}%
10561 \DeclareUnicodeCharacter{00FB}{\^u}%
10562 \DeclareUnicodeCharacter{00FC}{\"u}%
10563 \DeclareUnicodeCharacter{00FD}{\'y}%
10564 \DeclareUnicodeCharacter{00FE}{\th}%
10565 \DeclareUnicodeCharacter{00FF}{\"y}%
10566 %
10567 \DeclareUnicodeCharacter{0100}{\=A}%
10568 \DeclareUnicodeCharacter{0101}{\=a}%
10569 \DeclareUnicodeCharacter{0102}{\u{A}}%
10570 \DeclareUnicodeCharacter{0103}{\u{a}}%
10571 \DeclareUnicodeCharacter{0104}{\ogonek{A}}%
10572 \DeclareUnicodeCharacter{0105}{\ogonek{a}}%
10573 \DeclareUnicodeCharacter{0106}{\'C}%
10574 \DeclareUnicodeCharacter{0107}{\'c}%
10575 \DeclareUnicodeCharacter{0108}{\^C}%
10576 \DeclareUnicodeCharacter{0109}{\^c}%
10577 \DeclareUnicodeCharacter{010A}{\dotaccent{C}}%
10578 \DeclareUnicodeCharacter{010B}{\dotaccent{c}}%
10579 \DeclareUnicodeCharacter{010C}{\v{C}}%
10580 \DeclareUnicodeCharacter{010D}{\v{c}}%
10581 \DeclareUnicodeCharacter{010E}{\v{D}}%
10582 \DeclareUnicodeCharacter{010F}{d'}%
10583 %
10584 \DeclareUnicodeCharacter{0110}{\DH}%
10585 \DeclareUnicodeCharacter{0111}{\dh}%
10586 \DeclareUnicodeCharacter{0112}{\=E}%
10587 \DeclareUnicodeCharacter{0113}{\=e}%
10588 \DeclareUnicodeCharacter{0114}{\u{E}}%
10589 \DeclareUnicodeCharacter{0115}{\u{e}}%
10590 \DeclareUnicodeCharacter{0116}{\dotaccent{E}}%
10591 \DeclareUnicodeCharacter{0117}{\dotaccent{e}}%
10592 \DeclareUnicodeCharacter{0118}{\ogonek{E}}%
10593 \DeclareUnicodeCharacter{0119}{\ogonek{e}}%
10594 \DeclareUnicodeCharacter{011A}{\v{E}}%
10595 \DeclareUnicodeCharacter{011B}{\v{e}}%
10596 \DeclareUnicodeCharacter{011C}{\^G}%
10597 \DeclareUnicodeCharacter{011D}{\^g}%
10598 \DeclareUnicodeCharacter{011E}{\u{G}}%
10599 \DeclareUnicodeCharacter{011F}{\u{g}}%
10600 %
10601 \DeclareUnicodeCharacter{0120}{\dotaccent{G}}%
10602 \DeclareUnicodeCharacter{0121}{\dotaccent{g}}%
10603 \DeclareUnicodeCharacter{0122}{\cedilla{G}}%
10604 \DeclareUnicodeCharacter{0123}{\cedilla{g}}%
10605 \DeclareUnicodeCharacter{0124}{\^H}%
10606 \DeclareUnicodeCharacter{0125}{\^h}%
10607 \DeclareUnicodeCharacter{0126}{\missingcharmsg{H WITH STROKE}}%
10608 \DeclareUnicodeCharacter{0127}{\missingcharmsg{h WITH STROKE}}%
10609 \DeclareUnicodeCharacter{0128}{\~I}%
10610 \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}}%
10611 \DeclareUnicodeCharacter{012A}{\=I}%
10612 \DeclareUnicodeCharacter{012B}{\={\dotless{i}}}%
10613 \DeclareUnicodeCharacter{012C}{\u{I}}%
10614 \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}}%
10615 \DeclareUnicodeCharacter{012E}{\ogonek{I}}%
10616 \DeclareUnicodeCharacter{012F}{\ogonek{i}}%
10617 %
10618 \DeclareUnicodeCharacter{0130}{\dotaccent{I}}%
10619 \DeclareUnicodeCharacter{0131}{\dotless{i}}%
10620 \DeclareUnicodeCharacter{0132}{IJ}%
10621 \DeclareUnicodeCharacter{0133}{ij}%
10622 \DeclareUnicodeCharacter{0134}{\^J}%
10623 \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}}%
10624 \DeclareUnicodeCharacter{0136}{\cedilla{K}}%
10625 \DeclareUnicodeCharacter{0137}{\cedilla{k}}%
10626 \DeclareUnicodeCharacter{0138}{\ensuremath\kappa}%
10627 \DeclareUnicodeCharacter{0139}{\'L}%
10628 \DeclareUnicodeCharacter{013A}{\'l}%
10629 \DeclareUnicodeCharacter{013B}{\cedilla{L}}%
10630 \DeclareUnicodeCharacter{013C}{\cedilla{l}}%
084e7d57
JM
10631 \DeclareUnicodeCharacter{013D}{L'}% should kern
10632 \DeclareUnicodeCharacter{013E}{l'}% should kern
7f7dd1d3
JM
10633 \DeclareUnicodeCharacter{013F}{L\U{00B7}}%
10634 %
10635 \DeclareUnicodeCharacter{0140}{l\U{00B7}}%
10636 \DeclareUnicodeCharacter{0141}{\L}%
10637 \DeclareUnicodeCharacter{0142}{\l}%
10638 \DeclareUnicodeCharacter{0143}{\'N}%
10639 \DeclareUnicodeCharacter{0144}{\'n}%
10640 \DeclareUnicodeCharacter{0145}{\cedilla{N}}%
10641 \DeclareUnicodeCharacter{0146}{\cedilla{n}}%
10642 \DeclareUnicodeCharacter{0147}{\v{N}}%
10643 \DeclareUnicodeCharacter{0148}{\v{n}}%
10644 \DeclareUnicodeCharacter{0149}{'n}%
10645 \DeclareUnicodeCharacter{014A}{\missingcharmsg{ENG}}%
10646 \DeclareUnicodeCharacter{014B}{\missingcharmsg{eng}}%
10647 \DeclareUnicodeCharacter{014C}{\=O}%
10648 \DeclareUnicodeCharacter{014D}{\=o}%
10649 \DeclareUnicodeCharacter{014E}{\u{O}}%
10650 \DeclareUnicodeCharacter{014F}{\u{o}}%
10651 %
10652 \DeclareUnicodeCharacter{0150}{\H{O}}%
10653 \DeclareUnicodeCharacter{0151}{\H{o}}%
10654 \DeclareUnicodeCharacter{0152}{\OE}%
10655 \DeclareUnicodeCharacter{0153}{\oe}%
10656 \DeclareUnicodeCharacter{0154}{\'R}%
10657 \DeclareUnicodeCharacter{0155}{\'r}%
10658 \DeclareUnicodeCharacter{0156}{\cedilla{R}}%
10659 \DeclareUnicodeCharacter{0157}{\cedilla{r}}%
10660 \DeclareUnicodeCharacter{0158}{\v{R}}%
10661 \DeclareUnicodeCharacter{0159}{\v{r}}%
10662 \DeclareUnicodeCharacter{015A}{\'S}%
10663 \DeclareUnicodeCharacter{015B}{\'s}%
10664 \DeclareUnicodeCharacter{015C}{\^S}%
10665 \DeclareUnicodeCharacter{015D}{\^s}%
10666 \DeclareUnicodeCharacter{015E}{\cedilla{S}}%
10667 \DeclareUnicodeCharacter{015F}{\cedilla{s}}%
10668 %
10669 \DeclareUnicodeCharacter{0160}{\v{S}}%
10670 \DeclareUnicodeCharacter{0161}{\v{s}}%
10671 \DeclareUnicodeCharacter{0162}{\cedilla{T}}%
10672 \DeclareUnicodeCharacter{0163}{\cedilla{t}}%
10673 \DeclareUnicodeCharacter{0164}{\v{T}}%
10674 \DeclareUnicodeCharacter{0165}{\v{t}}%
10675 \DeclareUnicodeCharacter{0166}{\missingcharmsg{H WITH STROKE}}%
10676 \DeclareUnicodeCharacter{0167}{\missingcharmsg{h WITH STROKE}}%
10677 \DeclareUnicodeCharacter{0168}{\~U}%
10678 \DeclareUnicodeCharacter{0169}{\~u}%
10679 \DeclareUnicodeCharacter{016A}{\=U}%
10680 \DeclareUnicodeCharacter{016B}{\=u}%
10681 \DeclareUnicodeCharacter{016C}{\u{U}}%
10682 \DeclareUnicodeCharacter{016D}{\u{u}}%
10683 \DeclareUnicodeCharacter{016E}{\ringaccent{U}}%
10684 \DeclareUnicodeCharacter{016F}{\ringaccent{u}}%
10685 %
10686 \DeclareUnicodeCharacter{0170}{\H{U}}%
10687 \DeclareUnicodeCharacter{0171}{\H{u}}%
10688 \DeclareUnicodeCharacter{0172}{\ogonek{U}}%
10689 \DeclareUnicodeCharacter{0173}{\ogonek{u}}%
10690 \DeclareUnicodeCharacter{0174}{\^W}%
10691 \DeclareUnicodeCharacter{0175}{\^w}%
10692 \DeclareUnicodeCharacter{0176}{\^Y}%
10693 \DeclareUnicodeCharacter{0177}{\^y}%
10694 \DeclareUnicodeCharacter{0178}{\"Y}%
10695 \DeclareUnicodeCharacter{0179}{\'Z}%
10696 \DeclareUnicodeCharacter{017A}{\'z}%
10697 \DeclareUnicodeCharacter{017B}{\dotaccent{Z}}%
10698 \DeclareUnicodeCharacter{017C}{\dotaccent{z}}%
10699 \DeclareUnicodeCharacter{017D}{\v{Z}}%
10700 \DeclareUnicodeCharacter{017E}{\v{z}}%
10701 \DeclareUnicodeCharacter{017F}{\missingcharmsg{LONG S}}%
10702 %
10703 \DeclareUnicodeCharacter{01C4}{D\v{Z}}%
10704 \DeclareUnicodeCharacter{01C5}{D\v{z}}%
10705 \DeclareUnicodeCharacter{01C6}{d\v{z}}%
10706 \DeclareUnicodeCharacter{01C7}{LJ}%
10707 \DeclareUnicodeCharacter{01C8}{Lj}%
10708 \DeclareUnicodeCharacter{01C9}{lj}%
10709 \DeclareUnicodeCharacter{01CA}{NJ}%
10710 \DeclareUnicodeCharacter{01CB}{Nj}%
10711 \DeclareUnicodeCharacter{01CC}{nj}%
10712 \DeclareUnicodeCharacter{01CD}{\v{A}}%
10713 \DeclareUnicodeCharacter{01CE}{\v{a}}%
10714 \DeclareUnicodeCharacter{01CF}{\v{I}}%
10715 %
10716 \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}}%
10717 \DeclareUnicodeCharacter{01D1}{\v{O}}%
10718 \DeclareUnicodeCharacter{01D2}{\v{o}}%
10719 \DeclareUnicodeCharacter{01D3}{\v{U}}%
10720 \DeclareUnicodeCharacter{01D4}{\v{u}}%
10721 %
10722 \DeclareUnicodeCharacter{01E2}{\={\AE}}%
10723 \DeclareUnicodeCharacter{01E3}{\={\ae}}%
10724 \DeclareUnicodeCharacter{01E6}{\v{G}}%
10725 \DeclareUnicodeCharacter{01E7}{\v{g}}%
10726 \DeclareUnicodeCharacter{01E8}{\v{K}}%
10727 \DeclareUnicodeCharacter{01E9}{\v{k}}%
10728 %
10729 \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}}%
10730 \DeclareUnicodeCharacter{01F1}{DZ}%
10731 \DeclareUnicodeCharacter{01F2}{Dz}%
10732 \DeclareUnicodeCharacter{01F3}{dz}%
10733 \DeclareUnicodeCharacter{01F4}{\'G}%
10734 \DeclareUnicodeCharacter{01F5}{\'g}%
10735 \DeclareUnicodeCharacter{01F8}{\`N}%
10736 \DeclareUnicodeCharacter{01F9}{\`n}%
10737 \DeclareUnicodeCharacter{01FC}{\'{\AE}}%
10738 \DeclareUnicodeCharacter{01FD}{\'{\ae}}%
10739 \DeclareUnicodeCharacter{01FE}{\'{\O}}%
10740 \DeclareUnicodeCharacter{01FF}{\'{\o}}%
10741 %
10742 \DeclareUnicodeCharacter{021E}{\v{H}}%
10743 \DeclareUnicodeCharacter{021F}{\v{h}}%
10744 %
10745 \DeclareUnicodeCharacter{0226}{\dotaccent{A}}%
10746 \DeclareUnicodeCharacter{0227}{\dotaccent{a}}%
10747 \DeclareUnicodeCharacter{0228}{\cedilla{E}}%
10748 \DeclareUnicodeCharacter{0229}{\cedilla{e}}%
10749 \DeclareUnicodeCharacter{022E}{\dotaccent{O}}%
10750 \DeclareUnicodeCharacter{022F}{\dotaccent{o}}%
10751 %
10752 \DeclareUnicodeCharacter{0232}{\=Y}%
10753 \DeclareUnicodeCharacter{0233}{\=y}%
10754 \DeclareUnicodeCharacter{0237}{\dotless{j}}%
10755 %
10756 \DeclareUnicodeCharacter{02DB}{\ogonek{ }}%
10757 %
084e7d57 10758 % Greek letters upper case
7f7dd1d3
JM
10759 \DeclareUnicodeCharacter{0391}{{\it A}}%
10760 \DeclareUnicodeCharacter{0392}{{\it B}}%
10761 \DeclareUnicodeCharacter{0393}{\ensuremath{\mit\Gamma}}%
10762 \DeclareUnicodeCharacter{0394}{\ensuremath{\mit\Delta}}%
10763 \DeclareUnicodeCharacter{0395}{{\it E}}%
10764 \DeclareUnicodeCharacter{0396}{{\it Z}}%
10765 \DeclareUnicodeCharacter{0397}{{\it H}}%
10766 \DeclareUnicodeCharacter{0398}{\ensuremath{\mit\Theta}}%
10767 \DeclareUnicodeCharacter{0399}{{\it I}}%
10768 \DeclareUnicodeCharacter{039A}{{\it K}}%
10769 \DeclareUnicodeCharacter{039B}{\ensuremath{\mit\Lambda}}%
10770 \DeclareUnicodeCharacter{039C}{{\it M}}%
10771 \DeclareUnicodeCharacter{039D}{{\it N}}%
10772 \DeclareUnicodeCharacter{039E}{\ensuremath{\mit\Xi}}%
10773 \DeclareUnicodeCharacter{039F}{{\it O}}%
10774 \DeclareUnicodeCharacter{03A0}{\ensuremath{\mit\Pi}}%
10775 \DeclareUnicodeCharacter{03A1}{{\it P}}%
084e7d57 10776 %\DeclareUnicodeCharacter{03A2}{} % none - corresponds to final sigma
7f7dd1d3
JM
10777 \DeclareUnicodeCharacter{03A3}{\ensuremath{\mit\Sigma}}%
10778 \DeclareUnicodeCharacter{03A4}{{\it T}}%
10779 \DeclareUnicodeCharacter{03A5}{\ensuremath{\mit\Upsilon}}%
10780 \DeclareUnicodeCharacter{03A6}{\ensuremath{\mit\Phi}}%
10781 \DeclareUnicodeCharacter{03A7}{{\it X}}%
10782 \DeclareUnicodeCharacter{03A8}{\ensuremath{\mit\Psi}}%
10783 \DeclareUnicodeCharacter{03A9}{\ensuremath{\mit\Omega}}%
10784 %
084e7d57 10785 % Vowels with accents
7f7dd1d3
JM
10786 \DeclareUnicodeCharacter{0390}{\ensuremath{\ddot{\acute\iota}}}%
10787 \DeclareUnicodeCharacter{03AC}{\ensuremath{\acute\alpha}}%
10788 \DeclareUnicodeCharacter{03AD}{\ensuremath{\acute\epsilon}}%
10789 \DeclareUnicodeCharacter{03AE}{\ensuremath{\acute\eta}}%
10790 \DeclareUnicodeCharacter{03AF}{\ensuremath{\acute\iota}}%
10791 \DeclareUnicodeCharacter{03B0}{\ensuremath{\acute{\ddot\upsilon}}}%
10792 %
084e7d57 10793 % Standalone accent
7f7dd1d3
JM
10794 \DeclareUnicodeCharacter{0384}{\ensuremath{\acute{\ }}}%
10795 %
084e7d57 10796 % Greek letters lower case
7f7dd1d3
JM
10797 \DeclareUnicodeCharacter{03B1}{\ensuremath\alpha}%
10798 \DeclareUnicodeCharacter{03B2}{\ensuremath\beta}%
10799 \DeclareUnicodeCharacter{03B3}{\ensuremath\gamma}%
10800 \DeclareUnicodeCharacter{03B4}{\ensuremath\delta}%
10801 \DeclareUnicodeCharacter{03B5}{\ensuremath\epsilon}%
10802 \DeclareUnicodeCharacter{03B6}{\ensuremath\zeta}%
10803 \DeclareUnicodeCharacter{03B7}{\ensuremath\eta}%
10804 \DeclareUnicodeCharacter{03B8}{\ensuremath\theta}%
10805 \DeclareUnicodeCharacter{03B9}{\ensuremath\iota}%
10806 \DeclareUnicodeCharacter{03BA}{\ensuremath\kappa}%
10807 \DeclareUnicodeCharacter{03BB}{\ensuremath\lambda}%
10808 \DeclareUnicodeCharacter{03BC}{\ensuremath\mu}%
10809 \DeclareUnicodeCharacter{03BD}{\ensuremath\nu}%
10810 \DeclareUnicodeCharacter{03BE}{\ensuremath\xi}%
10811 \DeclareUnicodeCharacter{03BF}{{\it o}}% omicron
10812 \DeclareUnicodeCharacter{03C0}{\ensuremath\pi}%
10813 \DeclareUnicodeCharacter{03C1}{\ensuremath\rho}%
10814 \DeclareUnicodeCharacter{03C2}{\ensuremath\varsigma}%
10815 \DeclareUnicodeCharacter{03C3}{\ensuremath\sigma}%
10816 \DeclareUnicodeCharacter{03C4}{\ensuremath\tau}%
10817 \DeclareUnicodeCharacter{03C5}{\ensuremath\upsilon}%
10818 \DeclareUnicodeCharacter{03C6}{\ensuremath\phi}%
10819 \DeclareUnicodeCharacter{03C7}{\ensuremath\chi}%
10820 \DeclareUnicodeCharacter{03C8}{\ensuremath\psi}%
10821 \DeclareUnicodeCharacter{03C9}{\ensuremath\omega}%
10822 %
084e7d57 10823 % More Greek vowels with accents
7f7dd1d3
JM
10824 \DeclareUnicodeCharacter{03CA}{\ensuremath{\ddot\iota}}%
10825 \DeclareUnicodeCharacter{03CB}{\ensuremath{\ddot\upsilon}}%
10826 \DeclareUnicodeCharacter{03CC}{\ensuremath{\acute o}}%
10827 \DeclareUnicodeCharacter{03CD}{\ensuremath{\acute\upsilon}}%
10828 \DeclareUnicodeCharacter{03CE}{\ensuremath{\acute\omega}}%
10829 %
084e7d57 10830 % Variant Greek letters
7f7dd1d3
JM
10831 \DeclareUnicodeCharacter{03D1}{\ensuremath\vartheta}%
10832 \DeclareUnicodeCharacter{03D6}{\ensuremath\varpi}%
10833 \DeclareUnicodeCharacter{03F1}{\ensuremath\varrho}%
10834 %
10835 \DeclareUnicodeCharacter{1E02}{\dotaccent{B}}%
10836 \DeclareUnicodeCharacter{1E03}{\dotaccent{b}}%
10837 \DeclareUnicodeCharacter{1E04}{\udotaccent{B}}%
10838 \DeclareUnicodeCharacter{1E05}{\udotaccent{b}}%
10839 \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}}%
10840 \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}}%
10841 \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}}%
10842 \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}}%
10843 \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}}%
10844 \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}}%
10845 \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}}%
10846 \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}}%
10847 %
10848 \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}}%
10849 \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}}%
10850 %
10851 \DeclareUnicodeCharacter{1E20}{\=G}%
10852 \DeclareUnicodeCharacter{1E21}{\=g}%
10853 \DeclareUnicodeCharacter{1E22}{\dotaccent{H}}%
10854 \DeclareUnicodeCharacter{1E23}{\dotaccent{h}}%
10855 \DeclareUnicodeCharacter{1E24}{\udotaccent{H}}%
10856 \DeclareUnicodeCharacter{1E25}{\udotaccent{h}}%
10857 \DeclareUnicodeCharacter{1E26}{\"H}%
10858 \DeclareUnicodeCharacter{1E27}{\"h}%
10859 %
10860 \DeclareUnicodeCharacter{1E30}{\'K}%
10861 \DeclareUnicodeCharacter{1E31}{\'k}%
10862 \DeclareUnicodeCharacter{1E32}{\udotaccent{K}}%
10863 \DeclareUnicodeCharacter{1E33}{\udotaccent{k}}%
10864 \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}}%
10865 \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}}%
10866 \DeclareUnicodeCharacter{1E36}{\udotaccent{L}}%
10867 \DeclareUnicodeCharacter{1E37}{\udotaccent{l}}%
10868 \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}}%
10869 \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}}%
10870 \DeclareUnicodeCharacter{1E3E}{\'M}%
10871 \DeclareUnicodeCharacter{1E3F}{\'m}%
10872 %
10873 \DeclareUnicodeCharacter{1E40}{\dotaccent{M}}%
10874 \DeclareUnicodeCharacter{1E41}{\dotaccent{m}}%
10875 \DeclareUnicodeCharacter{1E42}{\udotaccent{M}}%
10876 \DeclareUnicodeCharacter{1E43}{\udotaccent{m}}%
10877 \DeclareUnicodeCharacter{1E44}{\dotaccent{N}}%
10878 \DeclareUnicodeCharacter{1E45}{\dotaccent{n}}%
10879 \DeclareUnicodeCharacter{1E46}{\udotaccent{N}}%
10880 \DeclareUnicodeCharacter{1E47}{\udotaccent{n}}%
10881 \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}}%
10882 \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}}%
10883 %
10884 \DeclareUnicodeCharacter{1E54}{\'P}%
10885 \DeclareUnicodeCharacter{1E55}{\'p}%
10886 \DeclareUnicodeCharacter{1E56}{\dotaccent{P}}%
10887 \DeclareUnicodeCharacter{1E57}{\dotaccent{p}}%
10888 \DeclareUnicodeCharacter{1E58}{\dotaccent{R}}%
10889 \DeclareUnicodeCharacter{1E59}{\dotaccent{r}}%
10890 \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}}%
10891 \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}}%
10892 \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}}%
10893 \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}}%
10894 %
10895 \DeclareUnicodeCharacter{1E60}{\dotaccent{S}}%
10896 \DeclareUnicodeCharacter{1E61}{\dotaccent{s}}%
10897 \DeclareUnicodeCharacter{1E62}{\udotaccent{S}}%
10898 \DeclareUnicodeCharacter{1E63}{\udotaccent{s}}%
10899 \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}}%
10900 \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}}%
10901 \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}}%
10902 \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}}%
10903 \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}}%
10904 \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}}%
10905 %
10906 \DeclareUnicodeCharacter{1E7C}{\~V}%
10907 \DeclareUnicodeCharacter{1E7D}{\~v}%
10908 \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}}%
10909 \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}}%
10910 %
10911 \DeclareUnicodeCharacter{1E80}{\`W}%
10912 \DeclareUnicodeCharacter{1E81}{\`w}%
10913 \DeclareUnicodeCharacter{1E82}{\'W}%
10914 \DeclareUnicodeCharacter{1E83}{\'w}%
10915 \DeclareUnicodeCharacter{1E84}{\"W}%
10916 \DeclareUnicodeCharacter{1E85}{\"w}%
10917 \DeclareUnicodeCharacter{1E86}{\dotaccent{W}}%
10918 \DeclareUnicodeCharacter{1E87}{\dotaccent{w}}%
10919 \DeclareUnicodeCharacter{1E88}{\udotaccent{W}}%
10920 \DeclareUnicodeCharacter{1E89}{\udotaccent{w}}%
10921 \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}}%
10922 \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}}%
10923 \DeclareUnicodeCharacter{1E8C}{\"X}%
10924 \DeclareUnicodeCharacter{1E8D}{\"x}%
10925 \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}}%
10926 \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}}%
10927 %
10928 \DeclareUnicodeCharacter{1E90}{\^Z}%
10929 \DeclareUnicodeCharacter{1E91}{\^z}%
10930 \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}}%
10931 \DeclareUnicodeCharacter{1E93}{\udotaccent{z}}%
10932 \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}}%
10933 \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}}%
10934 \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}}%
10935 \DeclareUnicodeCharacter{1E97}{\"t}%
10936 \DeclareUnicodeCharacter{1E98}{\ringaccent{w}}%
10937 \DeclareUnicodeCharacter{1E99}{\ringaccent{y}}%
10938 %
10939 \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}}%
10940 \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}}%
10941 %
10942 \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}}%
10943 \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}}%
10944 \DeclareUnicodeCharacter{1EBC}{\~E}%
10945 \DeclareUnicodeCharacter{1EBD}{\~e}%
10946 %
10947 \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}}%
10948 \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}}%
10949 \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}}%
10950 \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}}%
10951 %
10952 \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}}%
10953 \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}}%
10954 %
10955 \DeclareUnicodeCharacter{1EF2}{\`Y}%
10956 \DeclareUnicodeCharacter{1EF3}{\`y}%
10957 \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}}%
10958 %
10959 \DeclareUnicodeCharacter{1EF8}{\~Y}%
10960 \DeclareUnicodeCharacter{1EF9}{\~y}%
10961 %
084e7d57 10962 % Punctuation
7f7dd1d3
JM
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 %
084e7d57 10984 % Mathematical symbols
7f7dd1d3
JM
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}%
7f7dd1d3
JM
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}%
7f7dd1d3
JM
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}%
7f7dd1d3
JM
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}%
7f7dd1d3
JM
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}%
7f7dd1d3
JM
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 %
7f7dd1d3
JM
11092 \DeclareUnicodeCharacter{25B3}{\ensuremath\triangle}%
11093 \DeclareUnicodeCharacter{25B7}{\ensuremath\triangleright}%
11094 \DeclareUnicodeCharacter{25BD}{\ensuremath\bigtriangledown}%
11095 \DeclareUnicodeCharacter{25C1}{\ensuremath\triangleleft}%
41d11b15 11096 \DeclareUnicodeCharacter{25C7}{\ensuremath\diamond}%
7f7dd1d3
JM
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}%
7f7dd1d3
JM
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}
c94f48d7 11132
7f7dd1d3
JM
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 \catcode"#1=\active
11145 \def\dodeclareunicodecharacternative##1##2##3{%
11146 \begingroup
11147 \uccode`\~="##2\relax
11148 \uppercase{\gdef~}{%
11149 \ifpassthroughchars
11150 ##1%
11151 \else
11152 ##3%
11153 \fi
11154 }
11155 \endgroup
11156 }
11157 \begingroup
11158 \uccode`\.="#1\relax
11159 \uppercase{\def\UTFNativeTmp{.}}%
11160 \expandafter\dodeclareunicodecharacternative\UTFNativeTmp{#1}{#2}%
11161 \endgroup
c94f48d7
AJ
11162}
11163
7f7dd1d3
JM
11164% Native Unicode handling (XeTeX and LuaTeX) character replacing definition.
11165% It activates the setting that replaces Unicode characters.
11166\def\nativeunicodechardefs{%
11167 \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNative
11168 \unicodechardefs
11169}
11170
11171% For native Unicode handling (XeTeX and LuaTeX),
11172% make the character token expand
11173% to the sequences given in \unicodechardefs for printing.
11174\def\DeclareUnicodeCharacterNativeAtU#1#2{%
11175 \def\UTFAtUTmp{#2}
11176 \expandafter\globallet\csname uni:#1\endcsname \UTFAtUTmp
11177}
11178
11179% @U command definitions for native Unicode handling (XeTeX and LuaTeX).
11180\def\nativeunicodechardefsatu{%
11181 \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNativeAtU
11182 \unicodechardefs
084e7d57
JM
11183}
11184
7f7dd1d3
JM
11185% US-ASCII character definitions.
11186\def\asciichardefs{% nothing need be done
11187 \relax
11188}
084e7d57 11189
7f7dd1d3
JM
11190% define all Unicode characters we know about, for the sake of @U.
11191\iftxinativeunicodecapable
11192 \nativeunicodechardefsatu
11193\else
11194 \utfeightchardefs
11195\fi
084e7d57
JM
11196
11197
c94f48d7
AJ
11198% Make non-ASCII characters printable again for compatibility with
11199% existing Texinfo documents that may use them, even without declaring a
11200% document encoding.
11201%
11202\setnonasciicharscatcode \other
11203
11204
11205\message{formatting,}
11206
9e9f9cc2 11207\newdimen\defaultparindent \defaultparindent = 15pt
9e9f9cc2 11208
474be527
KB
11209\chapheadingskip = 15pt plus 4pt minus 2pt
11210\secheadingskip = 12pt plus 3pt minus 2pt
11211\subsecheadingskip = 9pt plus 2pt minus 2pt
11212
9e9f9cc2 11213% Prevent underfull vbox error messages.
0c2b5752 11214\vbadness = 10000
9e9f9cc2 11215
0f8bbd69
JM
11216% Don't be very finicky about underfull hboxes, either.
11217\hbadness = 6666
313a1174 11218
c94f48d7 11219% Following George Bush, get rid of widows and orphans.
9e9f9cc2
KB
11220\widowpenalty=10000
11221\clubpenalty=10000
11222
11223% Use TeX 3.0's \emergencystretch to help line breaking, but if we're
11224% using an old version of TeX, don't do anything. We want the amount of
11225% stretch added to depend on the line length, hence the dependence on
407dc7a0 11226% \hsize. We call this whenever the paper size is set.
9e9f9cc2 11227%
0c2b5752
UD
11228\def\setemergencystretch{%
11229 \ifx\emergencystretch\thisisundefined
11230 % Allow us to assign to \emergencystretch anyway.
11231 \def\emergencystretch{\dimen0}%
11232 \else
13632cfc 11233 \emergencystretch = .15\hsize
0c2b5752
UD
11234 \fi
11235}
9e9f9cc2 11236
9251c568
AJ
11237% Parameters in order: 1) textheight; 2) textwidth;
11238% 3) voffset; 4) hoffset; 5) binding offset; 6) topskip;
11239% 7) physical page height; 8) physical page width.
7158eae4 11240%
2f5b1124
UD
11241% We also call \setleading{\textleading}, so the caller should define
11242% \textleading. The caller should also set \parskip.
0c2b5752 11243%
2f5b1124 11244\def\internalpagesizes#1#2#3#4#5#6#7#8{%
0c2b5752
UD
11245 \voffset = #3\relax
11246 \topskip = #6\relax
11247 \splittopskip = \topskip
11248 %
11249 \vsize = #1\relax
11250 \advance\vsize by \topskip
11251 \outervsize = \vsize
d667195c 11252 \advance\outervsize by 2\topandbottommargin
7f7dd1d3 11253 \txipageheight = \vsize
474be527 11254 %
0c2b5752
UD
11255 \hsize = #2\relax
11256 \outerhsize = \hsize
11257 \advance\outerhsize by 0.5in
7f7dd1d3 11258 \txipagewidth = \hsize
474be527 11259 %
0c2b5752
UD
11260 \normaloffset = #4\relax
11261 \bindingoffset = #5\relax
474be527 11262 %
2f5b1124
UD
11263 \ifpdf
11264 \pdfpageheight #7\relax
11265 \pdfpagewidth #8\relax
c94f48d7
AJ
11266 % if we don't reset these, they will remain at "1 true in" of
11267 % whatever layout pdftex was dumped with.
11268 \pdfhorigin = 1 true in
11269 \pdfvorigin = 1 true in
7f7dd1d3
JM
11270 \else
11271 \ifx\XeTeXrevision\thisisundefined
41d11b15 11272 \special{papersize=#8,#7}%
7f7dd1d3
JM
11273 \else
11274 \pdfpageheight #7\relax
11275 \pdfpagewidth #8\relax
11276 % XeTeX does not have \pdfhorigin and \pdfvorigin.
11277 \fi
2f5b1124
UD
11278 \fi
11279 %
e23f8d20
UD
11280 \setleading{\textleading}
11281 %
0c2b5752
UD
11282 \parindent = \defaultparindent
11283 \setemergencystretch
9e9f9cc2
KB
11284}
11285
0c2b5752
UD
11286% @letterpaper (the default).
11287\def\letterpaper{{\globaldefs = 1
11288 \parskip = 3pt plus 2pt minus 1pt
e23f8d20 11289 \textleading = 13.2pt
0c2b5752
UD
11290 %
11291 % If page is nothing but text, make it come out even.
c94f48d7 11292 \internalpagesizes{607.2pt}{6in}% that's 46 lines
2f5b1124
UD
11293 {\voffset}{.25in}%
11294 {\bindingoffset}{36pt}%
11295 {11in}{8.5in}%
0c2b5752 11296}}
9e9f9cc2 11297
9251c568 11298% Use @smallbook to reset parameters for 7x9.25 trim size.
0c2b5752
UD
11299\def\smallbook{{\globaldefs = 1
11300 \parskip = 2pt plus 1pt
e23f8d20 11301 \textleading = 12pt
0c2b5752 11302 %
2f5b1124 11303 \internalpagesizes{7.5in}{5in}%
c94f48d7 11304 {-.2in}{0in}%
2f5b1124
UD
11305 {\bindingoffset}{16pt}%
11306 {9.25in}{7in}%
0c2b5752
UD
11307 %
11308 \lispnarrowing = 0.3in
11309 \tolerance = 700
0c2b5752 11310 \contentsrightmargin = 0pt
0c2b5752 11311 \defbodyindent = .5cm
0c2b5752
UD
11312}}
11313
9251c568
AJ
11314% Use @smallerbook to reset parameters for 6x9 trim size.
11315% (Just testing, parameters still in flux.)
11316\def\smallerbook{{\globaldefs = 1
11317 \parskip = 1.5pt plus 1pt
11318 \textleading = 12pt
11319 %
11320 \internalpagesizes{7.4in}{4.8in}%
11321 {-.2in}{-.4in}%
11322 {0pt}{14pt}%
11323 {9in}{6in}%
11324 %
11325 \lispnarrowing = 0.25in
11326 \tolerance = 700
9251c568
AJ
11327 \contentsrightmargin = 0pt
11328 \defbodyindent = .4cm
11329}}
11330
0c2b5752
UD
11331% Use @afourpaper to print on European A4 paper.
11332\def\afourpaper{{\globaldefs = 1
0c2b5752 11333 \parskip = 3pt plus 2pt minus 1pt
2f5b1124 11334 \textleading = 13.2pt
0c2b5752 11335 %
7158eae4 11336 % Double-side printing via postscript on Laserjet 4050
2f5b1124
UD
11337 % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm.
11338 % To change the settings for a different printer or situation, adjust
11339 % \normaloffset until the front-side and back-side texts align. Then
11340 % do the same for \bindingoffset. You can set these for testing in
11341 % your texinfo source file like this:
11342 % @tex
11343 % \global\normaloffset = -6mm
11344 % \global\bindingoffset = 10mm
11345 % @end tex
c94f48d7 11346 \internalpagesizes{673.2pt}{160mm}% that's 51 lines
2f5b1124
UD
11347 {\voffset}{\hoffset}%
11348 {\bindingoffset}{44pt}%
11349 {297mm}{210mm}%
0c2b5752
UD
11350 %
11351 \tolerance = 700
2f5b1124
UD
11352 \contentsrightmargin = 0pt
11353 \defbodyindent = 5mm
0c2b5752 11354}}
9e9f9cc2 11355
be1152ca
UD
11356% Use @afivepaper to print on European A5 paper.
11357% From romildo@urano.iceb.ufop.br, 2 July 2000.
11358% He also recommends making @example and @lisp be small.
11359\def\afivepaper{{\globaldefs = 1
be1152ca 11360 \parskip = 2pt plus 1pt minus 0.1pt
e23f8d20 11361 \textleading = 12.5pt
be1152ca 11362 %
2f5b1124
UD
11363 \internalpagesizes{160mm}{120mm}%
11364 {\voffset}{\hoffset}%
11365 {\bindingoffset}{8pt}%
11366 {210mm}{148mm}%
be1152ca
UD
11367 %
11368 \lispnarrowing = 0.2in
11369 \tolerance = 800
2f5b1124 11370 \contentsrightmargin = 0pt
be1152ca
UD
11371 \defbodyindent = 2mm
11372 \tableindent = 12mm
be1152ca
UD
11373}}
11374
7158eae4 11375% A specific text layout, 24x15cm overall, intended for A4 paper.
0c2b5752 11376\def\afourlatex{{\globaldefs = 1
0c2b5752 11377 \afourpaper
2f5b1124
UD
11378 \internalpagesizes{237mm}{150mm}%
11379 {\voffset}{4.6mm}%
11380 {\bindingoffset}{7mm}%
11381 {297mm}{210mm}%
0c2b5752 11382 %
2f5b1124 11383 % Must explicitly reset to 0 because we call \afourpaper.
0c2b5752
UD
11384 \globaldefs = 0
11385}}
9e9f9cc2 11386
2f5b1124
UD
11387% Use @afourwide to print on A4 paper in landscape format.
11388\def\afourwide{{\globaldefs = 1
0c2b5752 11389 \afourpaper
2f5b1124
UD
11390 \internalpagesizes{241mm}{165mm}%
11391 {\voffset}{-2.95mm}%
11392 {\bindingoffset}{7mm}%
11393 {297mm}{210mm}%
11394 \globaldefs = 0
11395}}
0c2b5752
UD
11396
11397% @pagesizes TEXTHEIGHT[,TEXTWIDTH]
11398% Perhaps we should allow setting the margins, \topskip, \parskip,
11399% and/or leading, also. Or perhaps we should compute them somehow.
b710a6e2 11400%
82d5ce1d 11401\parseargdef\pagesizes{\pagesizesyyy #1,,\finish}
0c2b5752
UD
11402\def\pagesizesyyy#1,#2,#3\finish{{%
11403 \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi
11404 \globaldefs = 1
11405 %
11406 \parskip = 3pt plus 2pt minus 1pt
e23f8d20 11407 \setleading{\textleading}%
0c2b5752 11408 %
c94f48d7 11409 \dimen0 = #1\relax
2f5b1124 11410 \advance\dimen0 by \voffset
41d11b15 11411 \advance\dimen0 by 1in % reference point for DVI is 1 inch from top of page
2f5b1124
UD
11412 %
11413 \dimen2 = \hsize
11414 \advance\dimen2 by \normaloffset
41d11b15 11415 \advance\dimen2 by 1in % reference point is 1 inch from left edge of page
2f5b1124
UD
11416 %
11417 \internalpagesizes{#1}{\hsize}%
11418 {\voffset}{\normaloffset}%
11419 {\bindingoffset}{44pt}%
11420 {\dimen0}{\dimen2}%
0c2b5752
UD
11421}}
11422
11423% Set default to letter.
b710a6e2 11424%
0c2b5752
UD
11425\letterpaper
11426
41d11b15
JM
11427% Default value of \hfuzz, for suppressing warnings about overfull hboxes.
11428\hfuzz = 1pt
11429
13632cfc 11430
0c2b5752 11431\message{and turning on texinfo input format.}
9e9f9cc2 11432
0f8bbd69
JM
11433\def^^L{\par} % remove \outer, so ^L can appear in an @comment
11434
11435% DEL is a comment character, in case @c does not suffice.
11436\catcode`\^^? = 14
11437
9e9f9cc2 11438% Define macros to output various characters with catcode for normal text.
0f8bbd69
JM
11439\catcode`\"=\other \def\normaldoublequote{"}
11440\catcode`\$=\other \def\normaldollar{$}%$ font-lock fix
11441\catcode`\+=\other \def\normalplus{+}
11442\catcode`\<=\other \def\normalless{<}
11443\catcode`\>=\other \def\normalgreater{>}
11444\catcode`\^=\other \def\normalcaret{^}
11445\catcode`\_=\other \def\normalunderscore{_}
11446\catcode`\|=\other \def\normalverticalbar{|}
11447\catcode`\~=\other \def\normaltilde{~}
9e9f9cc2 11448
82d5ce1d
UD
11449% This macro is used to make a character print one way in \tt
11450% (where it can probably be output as-is), and another way in other fonts,
9e9f9cc2
KB
11451% where something hairier probably needs to be done.
11452%
11453% #1 is what to print if we are indeed using \tt; #2 is what to print
11454% otherwise. Since all the Computer Modern typewriter fonts have zero
11455% interword stretch (and shrink), and it is reasonable to expect all
11456% typewriter fonts to have this, we can check that font parameter.
11457%
13632cfc
UD
11458\def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi}
11459
11460% Same as above, but check for italic font. Actually this also catches
11461% non-italic slanted fonts since it is impossible to distinguish them from
11462% italic fonts. But since this is only used by $ and it uses \sl anyway
11463% this is not a problem.
11464\def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi}
9e9f9cc2 11465
084e7d57
JM
11466% Set catcodes for Texinfo file
11467
11468% Active characters for printing the wanted glyph.
9e9f9cc2
KB
11469% Most of these we simply print from the \tt font, but for some, we can
11470% use math or other variants that look better in normal text.
084e7d57 11471%
9e9f9cc2 11472\catcode`\"=\active
40c0dc53 11473\def\activedoublequote{{\tt\char34}}
9e9f9cc2 11474\let"=\activedoublequote
21fea2e2 11475\catcode`\~=\active \def\activetilde{{\tt\char126}} \let~ = \activetilde
084e7d57
JM
11476\chardef\hatchar=`\^
11477\catcode`\^=\active \def\activehat{{\tt \hatchar}} \let^ = \activehat
9e9f9cc2
KB
11478
11479\catcode`\_=\active
11480\def_{\ifusingtt\normalunderscore\_}
e0f86659 11481\def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }
084e7d57 11482\let\realunder=_
9e9f9cc2 11483
084e7d57 11484\catcode`\|=\active \def|{{\tt\char124}}
21fea2e2 11485
9e9f9cc2 11486\chardef \less=`\<
21fea2e2 11487\catcode`\<=\active \def\activeless{{\tt \less}}\let< = \activeless
9e9f9cc2 11488\chardef \gtr=`\>
21fea2e2
JM
11489\catcode`\>=\active \def\activegtr{{\tt \gtr}}\let> = \activegtr
11490\catcode`\+=\active \def+{{\tt \char 43}}
11491\catcode`\$=\active \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix
084e7d57
JM
11492\catcode`\-=\active \let-=\normaldash
11493
21fea2e2
JM
11494
11495% used for headline/footline in the output routine, in case the page
11496% breaks in the middle of an @tex block.
11497\def\texinfochars{%
11498 \let< = \activeless
11499 \let> = \activegtr
11500 \let~ = \activetilde
11501 \let^ = \activehat
11502 \markupsetuplqdefault \markupsetuprqdefault
11503 \let\b = \strong
11504 \let\i = \smartitalic
11505 % in principle, all other definitions in \tex have to be undone too.
11506}
9e9f9cc2 11507
9251c568
AJ
11508% Used sometimes to turn off (effectively) the active characters even after
11509% parsing them.
11510\def\turnoffactive{%
11511 \normalturnoffactive
11512 \otherbackslash
11513}
11514
9e9f9cc2
KB
11515\catcode`\@=0
11516
82d5ce1d 11517% \backslashcurfont outputs one backslash character in current font,
e0f86659 11518% as in \char`\\.
82d5ce1d
UD
11519\global\chardef\backslashcurfont=`\\
11520\global\let\rawbackslashxx=\backslashcurfont % let existing .??s files work
9e9f9cc2 11521
9251c568
AJ
11522% \realbackslash is an actual character `\' with catcode other, and
11523% \doublebackslash is two of them (for the pdf outlines).
11524{\catcode`\\=\other @gdef@realbackslash{\} @gdef@doublebackslash{\\}}
11525
084e7d57 11526% In Texinfo, backslash is an active character; it prints the backslash
9251c568 11527% in fixed width font.
0f8bbd69
JM
11528\catcode`\\=\active % @ for escape char from now on.
11529
084e7d57
JM
11530% Print a typewriter backslash. For math mode, we can't simply use
11531% \backslashcurfont: the story here is that in math mode, the \char
11532% of \backslashcurfont ends up printing the roman \ from the math symbol
11533% font (because \char in math mode uses the \mathcode, and plain.tex
11534% sets \mathcode`\\="026E). Hence we use an explicit \mathchar,
0f8bbd69
JM
11535% which is the decimal equivalent of "715c (class 7, e.g., use \fam;
11536% ignored family value; char position "5C). We can't use " for the
11537% usual hex value because it has already been made active.
0f8bbd69 11538
084e7d57
JM
11539@def@ttbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}}
11540@let@backslashchar = @ttbackslash % @backslashchar{} is for user documents.
11541
82d5ce1d 11542% \rawbackslash defines an active \ to do \backslashcurfont.
e0f86659 11543% \otherbackslash defines an active \ to be a literal `\' character with
0f8bbd69 11544% catcode other. We switch back and forth between these.
9251c568
AJ
11545@gdef@rawbackslash{@let\=@backslashcurfont}
11546@gdef@otherbackslash{@let\=@realbackslash}
9e9f9cc2 11547
9251c568 11548% Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
084e7d57 11549% the literal character `\'.
8fcb833a
JM
11550%
11551{@catcode`- = @active
11552 @gdef@normalturnoffactive{%
7f7dd1d3 11553 @passthroughcharstrue
8fcb833a
JM
11554 @let-=@normaldash
11555 @let"=@normaldoublequote
11556 @let$=@normaldollar %$ font-lock fix
11557 @let+=@normalplus
11558 @let<=@normalless
11559 @let>=@normalgreater
8fcb833a
JM
11560 @let^=@normalcaret
11561 @let_=@normalunderscore
11562 @let|=@normalverticalbar
11563 @let~=@normaltilde
084e7d57 11564 @let\=@ttbackslash
8fcb833a
JM
11565 @markupsetuplqdefault
11566 @markupsetuprqdefault
11567 @unsepspaces
11568 }
e0f86659
UD
11569}
11570
084e7d57
JM
11571% If a .fmt file is being used, characters that might appear in a file
11572% name cannot be active until we have parsed the command line.
11573% So turn them off again, and have @fixbackslash turn them back on.
11574@catcode`+=@other @catcode`@_=@other
9e9f9cc2 11575
084e7d57
JM
11576% \enablebackslashhack - allow file to begin `\input texinfo'
11577%
9e9f9cc2
KB
11578% If a .fmt file is being used, we don't want the `\input texinfo' to show up.
11579% That is what \eatinput is for; after that, the `\' should revert to printing
11580% a backslash.
084e7d57
JM
11581% If the file did not have a `\input texinfo', then it is turned off after
11582% the first line; otherwise the first `\' in the file would cause an error.
11583% This is used on the very last line of this file, texinfo.tex.
11584% We also use @c to call @fixbackslash, in case ends of lines are hidden.
11585{
11586@catcode`@^=7
11587@catcode`@^^M=13@gdef@enablebackslashhack{%
11588 @global@let\ = @eatinput%
11589 @catcode`@^^M=13%
11590 @def@c{@fixbackslash@c}%
7f7dd1d3 11591 % Definition for the newline at the end of this file.
084e7d57 11592 @def ^^M{@let^^M@secondlinenl}%
7f7dd1d3
JM
11593 % Definition for a newline in the main Texinfo file.
11594 @gdef @secondlinenl{@fixbackslash}%
41d11b15
JM
11595 % In case the first line has a whole-line command on it
11596 @let@originalparsearg@parsearg
11597 @def@parsearg{@fixbackslash@originalparsearg}
084e7d57
JM
11598}}
11599
11600{@catcode`@^=7 @catcode`@^^M=13%
11601@gdef@eatinput input texinfo#1^^M{@fixbackslash}}
11602
11603% Emergency active definition of newline, in case an active newline token
11604% appears by mistake.
11605{@catcode`@^=7 @catcode13=13%
11606@gdef@enableemergencynewline{%
11607 @gdef^^M{%
11608 @par%
11609 %<warning: active newline>@par%
11610}}}
11611
9e9f9cc2 11612
13632cfc 11613@gdef@fixbackslash{%
084e7d57
JM
11614 @ifx\@eatinput @let\ = @ttbackslash @fi
11615 @catcode13=5 % regular end of line
11616 @enableemergencynewline
11617 @let@c=@texinfoc
41d11b15 11618 @let@parsearg@originalparsearg
084e7d57
JM
11619 % Also turn back on active characters that might appear in the input
11620 % file name, in case not using a pre-dumped format.
13632cfc
UD
11621 @catcode`+=@active
11622 @catcode`@_=@active
084e7d57
JM
11623 %
11624 % If texinfo.cnf is present on the system, read it.
11625 % Useful for site-wide @afourpaper, etc. This macro, @fixbackslash, gets
11626 % called at the beginning of every Texinfo file. Not opening texinfo.cnf
11627 % directly in this file, texinfo.tex, makes it possible to make a format
11628 % file for Texinfo.
11629 %
11630 @openin 1 texinfo.cnf
11631 @ifeof 1 @else @input texinfo.cnf @fi
11632 @closein 1
13632cfc 11633}
9e9f9cc2 11634
084e7d57 11635
13632cfc
UD
11636% Say @foo, not \foo, in error messages.
11637@escapechar = `@@
11638
0f8bbd69
JM
11639% These (along with & and #) are made active for url-breaking, so need
11640% active definitions as the normal characters.
11641@def@normaldot{.}
11642@def@normalquest{?}
11643@def@normalslash{/}
9e9f9cc2 11644
0f8bbd69
JM
11645% These look ok in all fonts, so just make them not special.
11646% @hashchar{} gets its own user-level command, because of #line.
11647@catcode`@& = @other @def@normalamp{&}
11648@catcode`@# = @other @def@normalhash{#}
11649@catcode`@% = @other @def@normalpercent{%}
11650
11651@let @hashchar = @normalhash
11652
11653@c Finally, make ` and ' active, so that txicodequoteundirected and
11654@c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}. If we
11655@c don't make ` and ' active, @code will not get them as active chars.
11656@c Do this last of all since we use ` in the previous @catcode assignments.
11657@catcode`@'=@active
11658@catcode`@`=@active
11659@markupsetuplqdefault
11660@markupsetuprqdefault
13632cfc 11661
9e9f9cc2 11662@c Local variables:
c37cd439 11663@c eval: (add-hook 'before-save-hook 'time-stamp)
084e7d57 11664@c page-delimiter: "^\\\\message\\|emacs-page"
d667195c 11665@c time-stamp-start: "def\\\\texinfoversion{"
3b82ab1c 11666@c time-stamp-format: "%:y-%02m-%02d.%02H"
d667195c 11667@c time-stamp-end: "}"
9e9f9cc2 11668@c End:
82d5ce1d
UD
11669
11670@c vim:sw=2:
11671
084e7d57 11672@enablebackslashhack