aboutsummaryrefslogtreecommitdiff
path: root/doc/texinfo.tex
diff options
context:
space:
mode:
Diffstat (limited to 'doc/texinfo.tex')
-rw-r--r--doc/texinfo.tex11772
1 files changed, 11772 insertions, 0 deletions
diff --git a/doc/texinfo.tex b/doc/texinfo.tex
new file mode 100644
index 0000000..3c7051d
--- /dev/null
+++ b/doc/texinfo.tex
@@ -0,0 +1,11772 @@
1% texinfo.tex -- TeX macros to handle Texinfo files.
2%
3% Load plain if necessary, i.e., if running under initex.
4\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
5%
6\def\texinfoversion{2020-10-24.12}
7%
8% Copyright 1985, 1986, 1988, 1990-2020 Free Software Foundation, Inc.
9%
10% This texinfo.tex file is free software: you can redistribute it and/or
11% modify it under the terms of the GNU General Public License as
12% published by the Free Software Foundation, either version 3 of the
13% License, or (at your option) any later version.
14%
15% This texinfo.tex file is distributed in the hope that it will be
16% useful, but WITHOUT ANY WARRANTY; without even the implied warranty
17% of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18% General Public License for more details.
19%
20% You should have received a copy of the GNU General Public License
21% along with this program. If not, see <https://www.gnu.org/licenses/>.
22%
23% As a special exception, when this file is read by TeX when processing
24% a Texinfo source document, you may use the result without
25% restriction. This Exception is an additional permission under section 7
26% of the GNU General Public License, version 3 ("GPLv3").
27%
28% Please try the latest version of texinfo.tex before submitting bug
29% reports; you can get the latest version from:
30% https://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or
31% https://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or
32% https://www.gnu.org/software/texinfo/ (the Texinfo home page)
33% The texinfo.tex in any given distribution could well be out
34% of date, so if that's what you're using, please check.
35%
36% Send bug reports to bug-texinfo@gnu.org. Please include a
37% complete document in each bug report with which we can reproduce the
38% problem. Patches are, of course, greatly appreciated.
39%
40% To process a Texinfo manual with TeX, it's most reliable to use the
41% texi2dvi shell script that comes with the distribution. For a simple
42% manual foo.texi, however, you can get away with this:
43% tex foo.texi
44% texindex foo.??
45% tex foo.texi
46% tex foo.texi
47% dvips foo.dvi -o # or whatever; this makes foo.ps.
48% The extra TeX runs get the cross-reference information correct.
49% Sometimes one run after texindex suffices, and sometimes you need more
50% than two; texi2dvi does it as many times as necessary.
51%
52% It is possible to adapt texinfo.tex for other languages, to some
53% extent. You can get the existing language-specific files from the
54% full Texinfo distribution.
55%
56% The GNU Texinfo home page is https://www.gnu.org/software/texinfo.
57
58
59\message{Loading texinfo [version \texinfoversion]:}
60
61% If in a .fmt file, print the version number
62% and turn on active characters that we couldn't do earlier because
63% they might have appeared in the input file name.
64\everyjob{\message{[Texinfo version \texinfoversion]}%
65 \catcode`+=\active \catcode`\_=\active}
66
67% LaTeX's \typeout. This ensures that the messages it is used for
68% are identical in format to the corresponding ones from latex/pdflatex.
69\def\typeout{\immediate\write17}%
70
71\chardef\other=12
72
73% We never want plain's \outer definition of \+ in Texinfo.
74% For @tex, we can use \tabalign.
75\let\+ = \relax
76
77% Save some plain tex macros whose names we will redefine.
78\let\ptexb=\b
79\let\ptexbullet=\bullet
80\let\ptexc=\c
81\let\ptexcomma=\,
82\let\ptexdot=\.
83\let\ptexdots=\dots
84\let\ptexend=\end
85\let\ptexequiv=\equiv
86\let\ptexexclam=\!
87\let\ptexfootnote=\footnote
88\let\ptexgtr=>
89\let\ptexhat=^
90\let\ptexi=\i
91\let\ptexindent=\indent
92\let\ptexinsert=\insert
93\let\ptexlbrace=\{
94\let\ptexless=<
95\let\ptexnewwrite\newwrite
96\let\ptexnoindent=\noindent
97\let\ptexplus=+
98\let\ptexraggedright=\raggedright
99\let\ptexrbrace=\}
100\let\ptexslash=\/
101\let\ptexsp=\sp
102\let\ptexstar=\*
103\let\ptexsup=\sup
104\let\ptext=\t
105\let\ptextop=\top
106{\catcode`\'=\active \global\let\ptexquoteright'}% active in plain's math mode
107
108% If this character appears in an error message or help string, it
109% starts a new line in the output.
110\newlinechar = `^^J
111
112% Use TeX 3.0's \inputlineno to get the line number, for better error
113% messages, but if we're using an old version of TeX, don't do anything.
114%
115\ifx\inputlineno\thisisundefined
116 \let\linenumber = \empty % Pre-3.0.
117\else
118 \def\linenumber{l.\the\inputlineno:\space}
119\fi
120
121% Set up fixed words for English if not already set.
122\ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi
123\ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi
124\ifx\putworderror\undefined \gdef\putworderror{error}\fi
125\ifx\putwordfile\undefined \gdef\putwordfile{file}\fi
126\ifx\putwordin\undefined \gdef\putwordin{in}\fi
127\ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi
128\ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi
129\ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi
130\ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi
131\ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi
132\ifx\putwordNoTitle\undefined \gdef\putwordNoTitle{No Title}\fi
133\ifx\putwordof\undefined \gdef\putwordof{of}\fi
134\ifx\putwordon\undefined \gdef\putwordon{on}\fi
135\ifx\putwordpage\undefined \gdef\putwordpage{page}\fi
136\ifx\putwordsection\undefined \gdef\putwordsection{section}\fi
137\ifx\putwordSection\undefined \gdef\putwordSection{Section}\fi
138\ifx\putwordsee\undefined \gdef\putwordsee{see}\fi
139\ifx\putwordSee\undefined \gdef\putwordSee{See}\fi
140\ifx\putwordShortTOC\undefined \gdef\putwordShortTOC{Short Contents}\fi
141\ifx\putwordTOC\undefined \gdef\putwordTOC{Table of Contents}\fi
142%
143\ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi
144\ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi
145\ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi
146\ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi
147\ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi
148\ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi
149\ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi
150\ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi
151\ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi
152\ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi
153\ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi
154\ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi
155%
156\ifx\putwordDefmac\undefined \gdef\putwordDefmac{Macro}\fi
157\ifx\putwordDefspec\undefined \gdef\putwordDefspec{Special Form}\fi
158\ifx\putwordDefvar\undefined \gdef\putwordDefvar{Variable}\fi
159\ifx\putwordDefopt\undefined \gdef\putwordDefopt{User Option}\fi
160\ifx\putwordDeffunc\undefined \gdef\putwordDeffunc{Function}\fi
161
162% Give the space character the catcode for a space.
163\def\spaceisspace{\catcode`\ =10\relax}
164
165% Likewise for ^^M, the end of line character.
166\def\endlineisspace{\catcode13=10\relax}
167
168\chardef\dashChar = `\-
169\chardef\slashChar = `\/
170\chardef\underChar = `\_
171
172% Ignore a token.
173%
174\def\gobble#1{}
175
176% The following is used inside several \edef's.
177\def\makecsname#1{\expandafter\noexpand\csname#1\endcsname}
178
179% Hyphenation fixes.
180\hyphenation{
181 Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script
182 ap-pen-dix bit-map bit-maps
183 data-base data-bases eshell fall-ing half-way long-est man-u-script
184 man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm
185 par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces
186 spell-ing spell-ings
187 stand-alone strong-est time-stamp time-stamps which-ever white-space
188 wide-spread wrap-around
189}
190
191% Sometimes it is convenient to have everything in the transcript file
192% and nothing on the terminal. We don't just call \tracingall here,
193% since that produces some useless output on the terminal. We also make
194% some effort to order the tracing commands to reduce output in the log
195% file; cf. trace.sty in LaTeX.
196%
197\def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
198\def\loggingall{%
199 \tracingstats2
200 \tracingpages1
201 \tracinglostchars2 % 2 gives us more in etex
202 \tracingparagraphs1
203 \tracingoutput1
204 \tracingmacros2
205 \tracingrestores1
206 \showboxbreadth\maxdimen \showboxdepth\maxdimen
207 \ifx\eTeXversion\thisisundefined\else % etex gives us more logging
208 \tracingscantokens1
209 \tracingifs1
210 \tracinggroups1
211 \tracingnesting2
212 \tracingassigns1
213 \fi
214 \tracingcommands3 % 3 gives us more in etex
215 \errorcontextlines16
216}%
217
218% @errormsg{MSG}. Do the index-like expansions on MSG, but if things
219% aren't perfect, it's not the end of the world, being an error message,
220% after all.
221%
222\def\errormsg{\begingroup \indexnofonts \doerrormsg}
223\def\doerrormsg#1{\errmessage{#1}}
224
225% add check for \lastpenalty to plain's definitions. If the last thing
226% we did was a \nobreak, we don't want to insert more space.
227%
228\def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount
229 \removelastskip\penalty-50\smallskip\fi\fi}
230\def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount
231 \removelastskip\penalty-100\medskip\fi\fi}
232\def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount
233 \removelastskip\penalty-200\bigskip\fi\fi}
234
235% 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
244\newdimen\outerhsize \newdimen\outervsize % set by the paper size routines
245\newdimen\topandbottommargin \topandbottommargin=.75in
246
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
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 \currentchapterdefs,
261% and \prevsectiondefs is the same as \currentsectiondefs.
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.
268\def\domark{%
269 \toks0=\expandafter{\currentchapterdefs}%
270 \toks2=\expandafter{\currentsectiondefs}%
271 \toks4=\expandafter{\prevchapterdefs}%
272 \toks6=\expandafter{\prevsectiondefs}%
273 \toks8=\expandafter{\currentcolordefs}%
274 \mark{%
275 \the\toks0 \the\toks2 % 0: marks for @everyheadingmarks top
276 \noexpand\or \the\toks4 \the\toks6 % 1: for @everyheadingmarks bottom
277 \noexpand\else \the\toks8 % 2: color marks
278 }%
279}
280
281% \gettopheadingmarks, \getbottomheadingmarks,
282% \getcolormarks - extract needed part of mark.
283%
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\the\savedtopmark\fi
291 \ifx\thischapter\empty \ifcase0\firstmark\fi \fi
292}
293\def\getbottomheadingmarks{\ifcase1\botmark\fi}
294\def\getcolormarks{\ifcase2\the\savedtopmark\fi}
295
296% Avoid "undefined control sequence" errors.
297\def\currentchapterdefs{}
298\def\currentsectiondefs{}
299\def\currentsection{}
300\def\prevchapterdefs{}
301\def\prevsectiondefs{}
302\def\currentcolordefs{}
303
304% Margin to add to right of even pages, to left of odd pages.
305\newdimen\bindingoffset
306\newdimen\normaloffset
307\newdimen\txipagewidth \newdimen\txipageheight
308
309% Main output routine.
310%
311\chardef\PAGE = 255
312\newtoks\defaultoutput
313\defaultoutput = {\savetopmark\onepageout{\pagecontents\PAGE}}
314\output=\expandafter{\the\defaultoutput}
315
316\newbox\headlinebox
317\newbox\footlinebox
318
319% When outputting the double column layout for indices, an output routine
320% is run several times, which hides the original value of \topmark. This
321% can lead to a page heading being output and duplicating the chapter heading
322% of the index. Hence, save the contents of \topmark at the beginning of
323% the output routine. The saved contents are valid until we actually
324% \shipout a page.
325%
326% (We used to run a short output routine to actually set \topmark and
327% \firstmark to the right values, but if this was called with an empty page
328% containing whatsits for writing index entries, the whatsits would be thrown
329% away and the index auxiliary file would remain empty.)
330%
331\newtoks\savedtopmark
332\newif\iftopmarksaved
333\topmarksavedtrue
334\def\savetopmark{%
335 \iftopmarksaved\else
336 \global\savedtopmark=\expandafter{\topmark}%
337 \global\topmarksavedtrue
338 \fi
339}
340
341% \onepageout takes a vbox as an argument.
342% \shipout a vbox for a single page, adding an optional header, footer
343% and footnote. This also causes index entries for this page to be written
344% to the auxiliary files.
345%
346\def\onepageout#1{%
347 \hoffset=\normaloffset
348 %
349 \ifodd\pageno \advance\hoffset by \bindingoffset
350 \else \advance\hoffset by -\bindingoffset\fi
351 %
352 \checkchapterpage
353 %
354 % Retrieve the information for the headings from the marks in the page,
355 % and call Plain TeX's \makeheadline and \makefootline, which use the
356 % values in \headline and \footline.
357 %
358 % Common context changes for both heading and footing.
359 % Do this outside of the \shipout so @code etc. will be expanded in
360 % the headline as they should be, not taken literally (outputting ''code).
361 \def\commonheadfootline{\let\hsize=\txipagewidth \texinfochars}
362 %
363 \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi
364 \global\setbox\headlinebox = \vbox{\commonheadfootline \makeheadline}%
365 \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi
366 \global\setbox\footlinebox = \vbox{\commonheadfootline \makefootline}%
367 %
368 {%
369 % Set context for writing to auxiliary files like index files.
370 % Have to do this stuff outside the \shipout because we want it to
371 % take effect in \write's, yet the group defined by the \vbox ends
372 % before the \shipout runs.
373 %
374 \atdummies % don't expand commands in the output.
375 \turnoffactive
376 \shipout\vbox{%
377 % Do this early so pdf references go to the beginning of the page.
378 \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi
379 %
380 \unvbox\headlinebox
381 \pagebody{#1}%
382 \ifdim\ht\footlinebox > 0pt
383 % Only leave this space if the footline is nonempty.
384 % (We lessened \vsize for it in \oddfootingyyy.)
385 % The \baselineskip=24pt in plain's \makefootline has no effect.
386 \vskip 24pt
387 \unvbox\footlinebox
388 \fi
389 %
390 }%
391 }%
392 \global\topmarksavedfalse
393 \advancepageno
394 \ifnum\outputpenalty>-20000 \else\dosupereject\fi
395}
396
397\newinsert\margin \dimen\margin=\maxdimen
398
399% Main part of page, including any footnotes
400\def\pagebody#1{\vbox to\txipageheight{\boxmaxdepth=\maxdepth #1}}
401{\catcode`\@ =11
402\gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
403% marginal hacks, juha@viisa.uucp (Juha Takala)
404\ifvoid\margin\else % marginal info is present
405 \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi
406\dimen@=\dp#1\relax \unvbox#1\relax
407\ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
408\ifr@ggedbottom \kern-\dimen@ \vfil \fi}
409}
410
411% Check if we are on the first page of a chapter. Used for printing headings.
412\newif\ifchapterpage
413\def\checkchapterpage{%
414 % Get the chapter that was current at the end of the last page
415 \ifcase1\the\savedtopmark\fi
416 \let\prevchaptername\thischaptername
417 %
418 \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi
419 \let\curchaptername\thischaptername
420 %
421 \ifx\curchaptername\prevchaptername
422 \chapterpagefalse
423 \else
424 \chapterpagetrue
425 \fi
426}
427
428% Argument parsing
429
430% Parse an argument, then pass it to #1. The argument is the rest of
431% the input line (except we remove a trailing comment). #1 should be a
432% macro which expects an ordinary undelimited TeX argument.
433% For example, \def\foo{\parsearg\fooxxx}.
434%
435\def\parsearg{\parseargusing{}}
436\def\parseargusing#1#2{%
437 \def\argtorun{#2}%
438 \begingroup
439 \obeylines
440 \spaceisspace
441 #1%
442 \parseargline\empty% Insert the \empty token, see \finishparsearg below.
443}
444
445{\obeylines %
446 \gdef\parseargline#1^^M{%
447 \endgroup % End of the group started in \parsearg.
448 \argremovecomment #1\comment\ArgTerm%
449 }%
450}
451
452% First remove any @comment, then any @c comment. Pass the result on to
453% \argcheckspaces.
454\def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm}
455\def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
456
457% Each occurrence of `\^^M' or `<space>\^^M' is replaced by a single space.
458%
459% \argremovec might leave us with trailing space, e.g.,
460% @end itemize @c foo
461% This space token undergoes the same procedure and is eventually removed
462% by \finishparsearg.
463%
464\def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M}
465\def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M}
466\def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{%
467 \def\temp{#3}%
468 \ifx\temp\empty
469 % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp:
470 \let\temp\finishparsearg
471 \else
472 \let\temp\argcheckspaces
473 \fi
474 % Put the space token in:
475 \temp#1 #3\ArgTerm
476}
477
478% If a _delimited_ argument is enclosed in braces, they get stripped; so
479% to get _exactly_ the rest of the line, we had to prevent such situation.
480% We prepended an \empty token at the very beginning and we expand it now,
481% just before passing the control to \argtorun.
482% (Similarly, we have to think about #3 of \argcheckspacesY above: it is
483% either the null string, or it ends with \^^M---thus there is no danger
484% that a pair of braces would be stripped.
485%
486% But first, we have to remove the trailing space token.
487%
488\def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}}
489
490
491% \parseargdef - define a command taking an argument on the line
492%
493% \parseargdef\foo{...}
494% is roughly equivalent to
495% \def\foo{\parsearg\Xfoo}
496% \def\Xfoo#1{...}
497\def\parseargdef#1{%
498 \expandafter \doparseargdef \csname\string#1\endcsname #1%
499}
500\def\doparseargdef#1#2{%
501 \def#2{\parsearg#1}%
502 \def#1##1%
503}
504
505% Several utility definitions with active space:
506{
507 \obeyspaces
508 \gdef\obeyedspace{ }
509
510 % Make each space character in the input produce a normal interword
511 % space in the output. Don't allow a line break at this space, as this
512 % is used only in environments like @example, where each line of input
513 % should produce a line of output anyway.
514 %
515 \gdef\sepspaces{\obeyspaces\let =\tie}
516
517 % If an index command is used in an @example environment, any spaces
518 % therein should become regular spaces in the raw index file, not the
519 % expansion of \tie (\leavevmode \penalty \@M \ ).
520 \gdef\unsepspaces{\let =\space}
521}
522
523
524\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
525
526% Define the framework for environments in texinfo.tex. It's used like this:
527%
528% \envdef\foo{...}
529% \def\Efoo{...}
530%
531% It's the responsibility of \envdef to insert \begingroup before the
532% actual body; @end closes the group after calling \Efoo. \envdef also
533% defines \thisenv, so the current environment is known; @end checks
534% whether the environment name matches. The \checkenv macro can also be
535% used to check whether the current environment is the one expected.
536%
537% Non-false conditionals (@iftex, @ifset) don't fit into this, so they
538% are not treated as environments; they don't open a group. (The
539% implementation of @end takes care not to call \endgroup in this
540% special case.)
541
542
543% At run-time, environments start with this:
544\def\startenvironment#1{\begingroup\def\thisenv{#1}}
545% initialize
546\let\thisenv\empty
547
548% ... but they get defined via ``\envdef\foo{...}'':
549\long\def\envdef#1#2{\def#1{\startenvironment#1#2}}
550\def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}}
551
552% Check whether we're in the right environment:
553\def\checkenv#1{%
554 \def\temp{#1}%
555 \ifx\thisenv\temp
556 \else
557 \badenverr
558 \fi
559}
560
561% Environment mismatch, #1 expected:
562\def\badenverr{%
563 \errhelp = \EMsimple
564 \errmessage{This command can appear only \inenvironment\temp,
565 not \inenvironment\thisenv}%
566}
567\def\inenvironment#1{%
568 \ifx#1\empty
569 outside of any environment%
570 \else
571 in environment \expandafter\string#1%
572 \fi
573}
574
575% @end foo executes the definition of \Efoo.
576% But first, it executes a specialized version of \checkenv
577%
578\parseargdef\end{%
579 \if 1\csname iscond.#1\endcsname
580 \else
581 % The general wording of \badenverr may not be ideal.
582 \expandafter\checkenv\csname#1\endcsname
583 \csname E#1\endcsname
584 \endgroup
585 \fi
586}
587
588\newhelp\EMsimple{Press RETURN to continue.}
589
590
591% Be sure we're in horizontal mode when doing a tie, since we make space
592% equivalent to this in @example-like environments. Otherwise, a space
593% at the beginning of a line will start with \penalty -- and
594% since \penalty is valid in vertical mode, we'd end up putting the
595% penalty on the vertical list instead of in the new paragraph.
596{\catcode`@ = 11
597 % Avoid using \@M directly, because that causes trouble
598 % if the definition is written into an index file.
599 \global\let\tiepenalty = \@M
600 \gdef\tie{\leavevmode\penalty\tiepenalty\ }
601}
602
603% @: forces normal size whitespace following.
604\def\:{\spacefactor=1000 }
605
606% @* forces a line break.
607\def\*{\unskip\hfil\break\hbox{}\ignorespaces}
608
609% @/ allows a line break.
610\let\/=\allowbreak
611
612% @. is an end-of-sentence period.
613\def\.{.\spacefactor=\endofsentencespacefactor\space}
614
615% @! is an end-of-sentence bang.
616\def\!{!\spacefactor=\endofsentencespacefactor\space}
617
618% @? is an end-of-sentence query.
619\def\?{?\spacefactor=\endofsentencespacefactor\space}
620
621% @frenchspacing on|off says whether to put extra space after punctuation.
622%
623\def\onword{on}
624\def\offword{off}
625%
626\parseargdef\frenchspacing{%
627 \def\temp{#1}%
628 \ifx\temp\onword \plainfrenchspacing
629 \else\ifx\temp\offword \plainnonfrenchspacing
630 \else
631 \errhelp = \EMsimple
632 \errmessage{Unknown @frenchspacing option `\temp', must be on|off}%
633 \fi\fi
634}
635
636% @w prevents a word break. Without the \leavevmode, @w at the
637% beginning of a paragraph, when TeX is still in vertical mode, would
638% produce a whole line of output instead of starting the paragraph.
639\def\w#1{\leavevmode\hbox{#1}}
640
641% @group ... @end group forces ... to be all on one page, by enclosing
642% it in a TeX vbox. We use \vtop instead of \vbox to construct the box
643% to keep its height that of a normal line. According to the rules for
644% \topskip (p.114 of the TeXbook), the glue inserted is
645% max (\topskip - \ht (first item), 0). If that height is large,
646% therefore, no glue is inserted, and the space between the headline and
647% the text is small, which looks bad.
648%
649% Another complication is that the group might be very large. This can
650% cause the glue on the previous page to be unduly stretched, because it
651% does not have much material. In this case, it's better to add an
652% explicit \vfill so that the extra space is at the bottom. The
653% threshold for doing this is if the group is more than \vfilllimit
654% percent of a page (\vfilllimit can be changed inside of @tex).
655%
656\newbox\groupbox
657\def\vfilllimit{0.7}
658%
659\envdef\group{%
660 \ifnum\catcode`\^^M=\active \else
661 \errhelp = \groupinvalidhelp
662 \errmessage{@group invalid in context where filling is enabled}%
663 \fi
664 \startsavinginserts
665 %
666 \setbox\groupbox = \vtop\bgroup
667 % Do @comment since we are called inside an environment such as
668 % @example, where each end-of-line in the input causes an
669 % end-of-line in the output. We don't want the end-of-line after
670 % the `@group' to put extra space in the output. Since @group
671 % should appear on a line by itself (according to the Texinfo
672 % manual), we don't worry about eating any user text.
673 \comment
674}
675%
676% The \vtop produces a box with normal height and large depth; thus, TeX puts
677% \baselineskip glue before it, and (when the next line of text is done)
678% \lineskip glue after it. Thus, space below is not quite equal to space
679% above. But it's pretty close.
680\def\Egroup{%
681 % To get correct interline space between the last line of the group
682 % and the first line afterwards, we have to propagate \prevdepth.
683 \endgraf % Not \par, as it may have been set to \lisppar.
684 \global\dimen1 = \prevdepth
685 \egroup % End the \vtop.
686 \addgroupbox
687 \prevdepth = \dimen1
688 \checkinserts
689}
690
691\def\addgroupbox{
692 % \dimen0 is the vertical size of the group's box.
693 \dimen0 = \ht\groupbox \advance\dimen0 by \dp\groupbox
694 % \dimen2 is how much space is left on the page (more or less).
695 \dimen2 = \txipageheight \advance\dimen2 by -\pagetotal
696 % if the group doesn't fit on the current page, and it's a big big
697 % group, force a page break.
698 \ifdim \dimen0 > \dimen2
699 \ifdim \pagetotal < \vfilllimit\txipageheight
700 \page
701 \fi
702 \fi
703 \box\groupbox
704}
705
706%
707% TeX puts in an \escapechar (i.e., `@') at the beginning of the help
708% message, so this ends up printing `@group can only ...'.
709%
710\newhelp\groupinvalidhelp{%
711group can only be used in environments such as @example,^^J%
712where each line of input produces a line of output.}
713
714% @need space-in-mils
715% forces a page break if there is not space-in-mils remaining.
716
717\newdimen\mil \mil=0.001in
718
719\parseargdef\need{%
720 % Ensure vertical mode, so we don't make a big box in the middle of a
721 % paragraph.
722 \par
723 %
724 % If the @need value is less than one line space, it's useless.
725 \dimen0 = #1\mil
726 \dimen2 = \ht\strutbox
727 \advance\dimen2 by \dp\strutbox
728 \ifdim\dimen0 > \dimen2
729 %
730 % Do a \strut just to make the height of this box be normal, so the
731 % normal leading is inserted relative to the preceding line.
732 % And a page break here is fine.
733 \vtop to #1\mil{\strut\vfil}%
734 %
735 % TeX does not even consider page breaks if a penalty added to the
736 % main vertical list is 10000 or more. But in order to see if the
737 % empty box we just added fits on the page, we must make it consider
738 % page breaks. On the other hand, we don't want to actually break the
739 % page after the empty box. So we use a penalty of 9999.
740 %
741 % There is an extremely small chance that TeX will actually break the
742 % page at this \penalty, if there are no other feasible breakpoints in
743 % sight. (If the user is using lots of big @group commands, which
744 % almost-but-not-quite fill up a page, TeX will have a hard time doing
745 % good page breaking, for example.) However, I could not construct an
746 % example where a page broke at this \penalty; if it happens in a real
747 % document, then we can reconsider our strategy.
748 \penalty9999
749 %
750 % Back up by the size of the box, whether we did a page break or not.
751 \kern -#1\mil
752 %
753 % Do not allow a page break right after this kern.
754 \nobreak
755 \fi
756}
757
758% @br forces paragraph break (and is undocumented).
759
760\let\br = \par
761
762% @page forces the start of a new page.
763%
764\def\page{\par\vfill\supereject}
765
766% @exdent text....
767% outputs text on separate line in roman font, starting at standard page margin
768
769% This records the amount of indent in the innermost environment.
770% That's how much \exdent should take out.
771\newskip\exdentamount
772
773% This defn is used inside fill environments such as @defun.
774\parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}
775
776% This defn is used inside nofill environments such as @example.
777\parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount
778 \leftline{\hskip\leftskip{\rm#1}}}}
779
780% @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current
781% paragraph. For more general purposes, use the \margin insertion
782% class. WHICH is `l' or `r'. Not documented, written for gawk manual.
783%
784\newskip\inmarginspacing \inmarginspacing=1cm
785\def\strutdepth{\dp\strutbox}
786%
787\def\doinmargin#1#2{\strut\vadjust{%
788 \nobreak
789 \kern-\strutdepth
790 \vtop to \strutdepth{%
791 \baselineskip=\strutdepth
792 \vss
793 % if you have multiple lines of stuff to put here, you'll need to
794 % make the vbox yourself of the appropriate size.
795 \ifx#1l%
796 \llap{\ignorespaces #2\hskip\inmarginspacing}%
797 \else
798 \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}%
799 \fi
800 \null
801 }%
802}}
803\def\inleftmargin{\doinmargin l}
804\def\inrightmargin{\doinmargin r}
805%
806% @inmargin{TEXT [, RIGHT-TEXT]}
807% (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right;
808% else use TEXT for both).
809%
810\def\inmargin#1{\parseinmargin #1,,\finish}
811\def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing.
812 \setbox0 = \hbox{\ignorespaces #2}%
813 \ifdim\wd0 > 0pt
814 \def\lefttext{#1}% have both texts
815 \def\righttext{#2}%
816 \else
817 \def\lefttext{#1}% have only one text
818 \def\righttext{#1}%
819 \fi
820 %
821 \ifodd\pageno
822 \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin
823 \else
824 \def\temp{\inleftmargin\lefttext}%
825 \fi
826 \temp
827}
828
829% @include FILE -- \input text of FILE.
830%
831\def\include{\parseargusing\filenamecatcodes\includezzz}
832\def\includezzz#1{%
833 \pushthisfilestack
834 \def\thisfile{#1}%
835 {%
836 \makevalueexpandable % we want to expand any @value in FILE.
837 \turnoffactive % and allow special characters in the expansion
838 \indexnofonts % Allow `@@' and other weird things in file names.
839 \wlog{texinfo.tex: doing @include of #1^^J}%
840 \edef\temp{\noexpand\input #1 }%
841 %
842 % This trickery is to read FILE outside of a group, in case it makes
843 % definitions, etc.
844 \expandafter
845 }\temp
846 \popthisfilestack
847}
848\def\filenamecatcodes{%
849 \catcode`\\=\other
850 \catcode`~=\other
851 \catcode`^=\other
852 \catcode`_=\other
853 \catcode`|=\other
854 \catcode`<=\other
855 \catcode`>=\other
856 \catcode`+=\other
857 \catcode`-=\other
858 \catcode`\`=\other
859 \catcode`\'=\other
860}
861
862\def\pushthisfilestack{%
863 \expandafter\pushthisfilestackX\popthisfilestack\StackTerm
864}
865\def\pushthisfilestackX{%
866 \expandafter\pushthisfilestackY\thisfile\StackTerm
867}
868\def\pushthisfilestackY #1\StackTerm #2\StackTerm {%
869 \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}%
870}
871
872\def\popthisfilestack{\errthisfilestackempty}
873\def\errthisfilestackempty{\errmessage{Internal error:
874 the stack of filenames is empty.}}
875%
876\def\thisfile{}
877
878% @center line
879% outputs that line, centered.
880%
881\parseargdef\center{%
882 \ifhmode
883 \let\centersub\centerH
884 \else
885 \let\centersub\centerV
886 \fi
887 \centersub{\hfil \ignorespaces#1\unskip \hfil}%
888 \let\centersub\relax % don't let the definition persist, just in case
889}
890\def\centerH#1{{%
891 \hfil\break
892 \advance\hsize by -\leftskip
893 \advance\hsize by -\rightskip
894 \line{#1}%
895 \break
896}}
897%
898\newcount\centerpenalty
899\def\centerV#1{%
900 % The idea here is the same as in \startdefun, \cartouche, etc.: if
901 % @center is the first thing after a section heading, we need to wipe
902 % out the negative parskip inserted by \sectionheading, but still
903 % prevent a page break here.
904 \centerpenalty = \lastpenalty
905 \ifnum\centerpenalty>10000 \vskip\parskip \fi
906 \ifnum\centerpenalty>9999 \penalty\centerpenalty \fi
907 \line{\kern\leftskip #1\kern\rightskip}%
908}
909
910% @sp n outputs n lines of vertical space
911%
912\parseargdef\sp{\vskip #1\baselineskip}
913
914% @comment ...line which is ignored...
915% @c is the same as @comment
916% @ignore ... @end ignore is another way to write a comment
917
918
919\def\c{\begingroup \catcode`\^^M=\active%
920\catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
921\cxxx}
922{\catcode`\^^M=\active \gdef\cxxx#1^^M{\endgroup}}
923%
924\let\comment\c
925
926% @paragraphindent NCHARS
927% We'll use ems for NCHARS, close enough.
928% NCHARS can also be the word `asis' or `none'.
929% We cannot feasibly implement @paragraphindent asis, though.
930%
931\def\asisword{asis} % no translation, these are keywords
932\def\noneword{none}
933%
934\parseargdef\paragraphindent{%
935 \def\temp{#1}%
936 \ifx\temp\asisword
937 \else
938 \ifx\temp\noneword
939 \defaultparindent = 0pt
940 \else
941 \defaultparindent = #1em
942 \fi
943 \fi
944 \parindent = \defaultparindent
945}
946
947% @exampleindent NCHARS
948% We'll use ems for NCHARS like @paragraphindent.
949% It seems @exampleindent asis isn't necessary, but
950% I preserve it to make it similar to @paragraphindent.
951\parseargdef\exampleindent{%
952 \def\temp{#1}%
953 \ifx\temp\asisword
954 \else
955 \ifx\temp\noneword
956 \lispnarrowing = 0pt
957 \else
958 \lispnarrowing = #1em
959 \fi
960 \fi
961}
962
963% @firstparagraphindent WORD
964% If WORD is `none', then suppress indentation of the first paragraph
965% after a section heading. If WORD is `insert', then do indent at such
966% paragraphs.
967%
968% The paragraph indentation is suppressed or not by calling
969% \suppressfirstparagraphindent, which the sectioning commands do.
970% We switch the definition of this back and forth according to WORD.
971% By default, we suppress indentation.
972%
973\def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent}
974\def\insertword{insert}
975%
976\parseargdef\firstparagraphindent{%
977 \def\temp{#1}%
978 \ifx\temp\noneword
979 \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent
980 \else\ifx\temp\insertword
981 \let\suppressfirstparagraphindent = \relax
982 \else
983 \errhelp = \EMsimple
984 \errmessage{Unknown @firstparagraphindent option `\temp'}%
985 \fi\fi
986}
987
988% Here is how we actually suppress indentation. Redefine \everypar to
989% \kern backwards by \parindent, and then reset itself to empty.
990%
991% We also make \indent itself not actually do anything until the next
992% paragraph.
993%
994\gdef\dosuppressfirstparagraphindent{%
995 \gdef\indent {\restorefirstparagraphindent \indent}%
996 \gdef\noindent{\restorefirstparagraphindent \noindent}%
997 \global\everypar = {\kern -\parindent \restorefirstparagraphindent}%
998}
999%
1000\gdef\restorefirstparagraphindent{%
1001 \global\let\indent = \ptexindent
1002 \global\let\noindent = \ptexnoindent
1003 \global\everypar = {}%
1004}
1005
1006
1007% @refill is a no-op.
1008\let\refill=\relax
1009
1010% @setfilename INFO-FILENAME - ignored
1011\let\setfilename=\comment
1012
1013% @bye.
1014\outer\def\bye{\chappager\pagelabels\tracingstats=1\ptexend}
1015
1016
1017\message{pdf,}
1018% adobe `portable' document format
1019\newcount\tempnum
1020\newcount\lnkcount
1021\newtoks\filename
1022\newcount\filenamelength
1023\newcount\pgn
1024\newtoks\toksA
1025\newtoks\toksB
1026\newtoks\toksC
1027\newtoks\toksD
1028\newbox\boxA
1029\newbox\boxB
1030\newcount\countA
1031\newif\ifpdf
1032\newif\ifpdfmakepagedest
1033
1034%
1035% For LuaTeX
1036%
1037
1038\newif\iftxiuseunicodedestname
1039\txiuseunicodedestnamefalse % For pdfTeX etc.
1040
1041\ifx\luatexversion\thisisundefined
1042\else
1043 % Use Unicode destination names
1044 \txiuseunicodedestnametrue
1045 % Escape PDF strings with converting UTF-16 from UTF-8
1046 \begingroup
1047 \catcode`\%=12
1048 \directlua{
1049 function UTF16oct(str)
1050 tex.sprint(string.char(0x5c) .. '376' .. string.char(0x5c) .. '377')
1051 for c in string.utfvalues(str) do
1052 if c < 0x10000 then
1053 tex.sprint(
1054 string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
1055 string.char(0x5c) .. string.char(0x25) .. '03o',
1056 math.floor(c / 256), math.floor(c % 256)))
1057 else
1058 c = c - 0x10000
1059 local c_hi = c / 1024 + 0xd800
1060 local c_lo = c % 1024 + 0xdc00
1061 tex.sprint(
1062 string.format(string.char(0x5c) .. string.char(0x25) .. '03o' ..
1063 string.char(0x5c) .. string.char(0x25) .. '03o' ..
1064 string.char(0x5c) .. string.char(0x25) .. '03o' ..
1065 string.char(0x5c) .. string.char(0x25) .. '03o',
1066 math.floor(c_hi / 256), math.floor(c_hi % 256),
1067 math.floor(c_lo / 256), math.floor(c_lo % 256)))
1068 end
1069 end
1070 end
1071 }
1072 \endgroup
1073 \def\pdfescapestrutfsixteen#1{\directlua{UTF16oct('\luaescapestring{#1}')}}
1074 % Escape PDF strings without converting
1075 \begingroup
1076 \directlua{
1077 function PDFescstr(str)
1078 for c in string.bytes(str) do
1079 if c <= 0x20 or c >= 0x80 or c == 0x28 or c == 0x29 or c == 0x5c then
1080 tex.sprint(-2,
1081 string.format(string.char(0x5c) .. string.char(0x25) .. '03o',
1082 c))
1083 else
1084 tex.sprint(-2, string.char(c))
1085 end
1086 end
1087 end
1088 }
1089 % The -2 in the arguments here gives all the input to TeX catcode 12
1090 % (other) or 10 (space), preventing undefined control sequence errors. See
1091 % https://lists.gnu.org/archive/html/bug-texinfo/2019-08/msg00031.html
1092 %
1093 \endgroup
1094 \def\pdfescapestring#1{\directlua{PDFescstr('\luaescapestring{#1}')}}
1095 \ifnum\luatexversion>84
1096 % For LuaTeX >= 0.85
1097 \def\pdfdest{\pdfextension dest}
1098 \let\pdfoutput\outputmode
1099 \def\pdfliteral{\pdfextension literal}
1100 \def\pdfcatalog{\pdfextension catalog}
1101 \def\pdftexversion{\numexpr\pdffeedback version\relax}
1102 \let\pdfximage\saveimageresource
1103 \let\pdfrefximage\useimageresource
1104 \let\pdflastximage\lastsavedimageresourceindex
1105 \def\pdfendlink{\pdfextension endlink\relax}
1106 \def\pdfoutline{\pdfextension outline}
1107 \def\pdfstartlink{\pdfextension startlink}
1108 \def\pdffontattr{\pdfextension fontattr}
1109 \def\pdfobj{\pdfextension obj}
1110 \def\pdflastobj{\numexpr\pdffeedback lastobj\relax}
1111 \let\pdfpagewidth\pagewidth
1112 \let\pdfpageheight\pageheight
1113 \edef\pdfhorigin{\pdfvariable horigin}
1114 \edef\pdfvorigin{\pdfvariable vorigin}
1115 \fi
1116\fi
1117
1118% when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1
1119% can be set). So we test for \relax and 0 as well as being undefined.
1120\ifx\pdfoutput\thisisundefined
1121\else
1122 \ifx\pdfoutput\relax
1123 \else
1124 \ifcase\pdfoutput
1125 \else
1126 \pdftrue
1127 \fi
1128 \fi
1129\fi
1130
1131\newif\ifpdforxetex
1132\pdforxetexfalse
1133\ifpdf
1134 \pdforxetextrue
1135\fi
1136\ifx\XeTeXrevision\thisisundefined\else
1137 \pdforxetextrue
1138\fi
1139
1140
1141% Output page labels information.
1142% See PDF reference v.1.7 p.594, section 8.3.1.
1143\ifpdf
1144\def\pagelabels{%
1145 \def\title{0 << /P (T-) /S /D >>}%
1146 \edef\roman{\the\romancount << /S /r >>}%
1147 \edef\arabic{\the\arabiccount << /S /D >>}%
1148 %
1149 % Page label ranges must be increasing. Remove any duplicates.
1150 % (There is a slight chance of this being wrong if e.g. there is
1151 % a @contents but no @titlepage, etc.)
1152 %
1153 \ifnum\romancount=0 \def\roman{}\fi
1154 \ifnum\arabiccount=0 \def\title{}%
1155 \else
1156 \ifnum\romancount=\arabiccount \def\roman{}\fi
1157 \fi
1158 %
1159 \ifnum\romancount<\arabiccount
1160 \pdfcatalog{/PageLabels << /Nums [\title \roman \arabic ] >> }\relax
1161 \else
1162 \pdfcatalog{/PageLabels << /Nums [\title \arabic \roman ] >> }\relax
1163 \fi
1164}
1165\else
1166 \let\pagelabels\relax
1167\fi
1168
1169\newcount\pagecount \pagecount=0
1170\newcount\romancount \romancount=0
1171\newcount\arabiccount \arabiccount=0
1172\ifpdf
1173 \let\ptxadvancepageno\advancepageno
1174 \def\advancepageno{%
1175 \ptxadvancepageno\global\advance\pagecount by 1
1176 }
1177\fi
1178
1179
1180% PDF uses PostScript string constants for the names of xref targets,
1181% for display in the outlines, and in other places. Thus, we have to
1182% double any backslashes. Otherwise, a name like "\node" will be
1183% interpreted as a newline (\n), followed by o, d, e. Not good.
1184%
1185% See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and
1186% related messages. The final outcome is that it is up to the TeX user
1187% to double the backslashes and otherwise make the string valid, so
1188% that's what we do. pdftex 1.30.0 (ca.2005) introduced a primitive to
1189% do this reliably, so we use it.
1190
1191% #1 is a control sequence in which to do the replacements,
1192% which we \xdef.
1193\def\txiescapepdf#1{%
1194 \ifx\pdfescapestring\thisisundefined
1195 % No primitive available; should we give a warning or log?
1196 % Many times it won't matter.
1197 \xdef#1{#1}%
1198 \else
1199 % The expandable \pdfescapestring primitive escapes parentheses,
1200 % backslashes, and other special chars.
1201 \xdef#1{\pdfescapestring{#1}}%
1202 \fi
1203}
1204\def\txiescapepdfutfsixteen#1{%
1205 \ifx\pdfescapestrutfsixteen\thisisundefined
1206 % No UTF-16 converting macro available.
1207 \txiescapepdf{#1}%
1208 \else
1209 \xdef#1{\pdfescapestrutfsixteen{#1}}%
1210 \fi
1211}
1212
1213\newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images
1214with PDF output, and none of those formats could be found. (.eps cannot
1215be supported due to the design of the PDF format; use regular TeX (DVI
1216output) for that.)}
1217
1218\ifpdf
1219 %
1220 % Color manipulation macros using ideas from pdfcolor.tex,
1221 % except using rgb instead of cmyk; the latter is said to render as a
1222 % very dark gray on-screen and a very dark halftone in print, instead
1223 % of actual black. The dark red here is dark enough to print on paper as
1224 % nearly black, but still distinguishable for online viewing. We use
1225 % black by default, though.
1226 \def\rgbDarkRed{0.50 0.09 0.12}
1227 \def\rgbBlack{0 0 0}
1228 %
1229 % rg sets the color for filling (usual text, etc.);
1230 % RG sets the color for stroking (thin rules, e.g., normal _'s).
1231 \def\pdfsetcolor#1{\pdfliteral{#1 rg #1 RG}}
1232 %
1233 % Set color, and create a mark which defines \thiscolor accordingly,
1234 % so that \makeheadline knows which color to restore.
1235 \def\setcolor#1{%
1236 \xdef\currentcolordefs{\gdef\noexpand\thiscolor{#1}}%
1237 \domark
1238 \pdfsetcolor{#1}%
1239 }
1240 %
1241 \def\maincolor{\rgbBlack}
1242 \pdfsetcolor{\maincolor}
1243 \edef\thiscolor{\maincolor}
1244 \def\currentcolordefs{}
1245 %
1246 \def\makefootline{%
1247 \baselineskip24pt
1248 \line{\pdfsetcolor{\maincolor}\the\footline}%
1249 }
1250 %
1251 \def\makeheadline{%
1252 \vbox to 0pt{%
1253 \vskip-22.5pt
1254 \line{%
1255 \vbox to8.5pt{}%
1256 % Extract \thiscolor definition from the marks.
1257 \getcolormarks
1258 % Typeset the headline with \maincolor, then restore the color.
1259 \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
1260 }%
1261 \vss
1262 }%
1263 \nointerlineskip
1264 }
1265 %
1266 %
1267 \pdfcatalog{/PageMode /UseOutlines}
1268 %
1269 % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
1270 \def\dopdfimage#1#2#3{%
1271 \def\pdfimagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
1272 \def\pdfimageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
1273 %
1274 % pdftex (and the PDF format) support .pdf, .png, .jpg (among
1275 % others). Let's try in that order, PDF first since if
1276 % someone has a scalable image, presumably better to use that than a
1277 % bitmap.
1278 \let\pdfimgext=\empty
1279 \begingroup
1280 \openin 1 #1.pdf \ifeof 1
1281 \openin 1 #1.PDF \ifeof 1
1282 \openin 1 #1.png \ifeof 1
1283 \openin 1 #1.jpg \ifeof 1
1284 \openin 1 #1.jpeg \ifeof 1
1285 \openin 1 #1.JPG \ifeof 1
1286 \errhelp = \nopdfimagehelp
1287 \errmessage{Could not find image file #1 for pdf}%
1288 \else \gdef\pdfimgext{JPG}%
1289 \fi
1290 \else \gdef\pdfimgext{jpeg}%
1291 \fi
1292 \else \gdef\pdfimgext{jpg}%
1293 \fi
1294 \else \gdef\pdfimgext{png}%
1295 \fi
1296 \else \gdef\pdfimgext{PDF}%
1297 \fi
1298 \else \gdef\pdfimgext{pdf}%
1299 \fi
1300 \closein 1
1301 \endgroup
1302 %
1303 % without \immediate, ancient pdftex seg faults when the same image is
1304 % included twice. (Version 3.14159-pre-1.0-unofficial-20010704.)
1305 \ifnum\pdftexversion < 14
1306 \immediate\pdfimage
1307 \else
1308 \immediate\pdfximage
1309 \fi
1310 \ifdim \wd0 >0pt width \pdfimagewidth \fi
1311 \ifdim \wd2 >0pt height \pdfimageheight \fi
1312 \ifnum\pdftexversion<13
1313 #1.\pdfimgext
1314 \else
1315 {#1.\pdfimgext}%
1316 \fi
1317 \ifnum\pdftexversion < 14 \else
1318 \pdfrefximage \pdflastximage
1319 \fi}
1320 %
1321 \def\setpdfdestname#1{{%
1322 % We have to set dummies so commands such as @code, and characters
1323 % such as \, aren't expanded when present in a section title.
1324 \indexnofonts
1325 \makevalueexpandable
1326 \turnoffactive
1327 \iftxiuseunicodedestname
1328 \ifx \declaredencoding \latone
1329 % Pass through Latin-1 characters.
1330 % LuaTeX with byte wise I/O converts Latin-1 characters to Unicode.
1331 \else
1332 \ifx \declaredencoding \utfeight
1333 % Pass through Unicode characters.
1334 \else
1335 % Use ASCII approximations in destination names.
1336 \passthroughcharsfalse
1337 \fi
1338 \fi
1339 \else
1340 % Use ASCII approximations in destination names.
1341 \passthroughcharsfalse
1342 \fi
1343 \def\pdfdestname{#1}%
1344 \txiescapepdf\pdfdestname
1345 }}
1346 %
1347 \def\setpdfoutlinetext#1{{%
1348 \indexnofonts
1349 \makevalueexpandable
1350 \turnoffactive
1351 \ifx \declaredencoding \latone
1352 % The PDF format can use an extended form of Latin-1 in bookmark
1353 % strings. See Appendix D of the PDF Reference, Sixth Edition, for
1354 % the "PDFDocEncoding".
1355 \passthroughcharstrue
1356 % Pass through Latin-1 characters.
1357 % LuaTeX: Convert to Unicode
1358 % pdfTeX: Use Latin-1 as PDFDocEncoding
1359 \def\pdfoutlinetext{#1}%
1360 \else
1361 \ifx \declaredencoding \utfeight
1362 \ifx\luatexversion\thisisundefined
1363 % For pdfTeX with UTF-8.
1364 % TODO: the PDF format can use UTF-16 in bookmark strings,
1365 % but the code for this isn't done yet.
1366 % Use ASCII approximations.
1367 \passthroughcharsfalse
1368 \def\pdfoutlinetext{#1}%
1369 \else
1370 % For LuaTeX with UTF-8.
1371 % Pass through Unicode characters for title texts.
1372 \passthroughcharstrue
1373 \def\pdfoutlinetext{#1}%
1374 \fi
1375 \else
1376 % For non-Latin-1 or non-UTF-8 encodings.
1377 % Use ASCII approximations.
1378 \passthroughcharsfalse
1379 \def\pdfoutlinetext{#1}%
1380 \fi
1381 \fi
1382 % LuaTeX: Convert to UTF-16
1383 % pdfTeX: Use Latin-1 as PDFDocEncoding
1384 \txiescapepdfutfsixteen\pdfoutlinetext
1385 }}
1386 %
1387 \def\pdfmkdest#1{%
1388 \setpdfdestname{#1}%
1389 \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
1390 }
1391 %
1392 % used to mark target names; must be expandable.
1393 \def\pdfmkpgn#1{#1}
1394 %
1395 % by default, use black for everything.
1396 \def\urlcolor{\rgbBlack}
1397 \def\linkcolor{\rgbBlack}
1398 \def\endlink{\setcolor{\maincolor}\pdfendlink}
1399 %
1400 % Adding outlines to PDF; macros for calculating structure of outlines
1401 % come from Petr Olsak
1402 \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
1403 \else \csname#1\endcsname \fi}
1404 \def\advancenumber#1{\tempnum=\expnumber{#1}\relax
1405 \advance\tempnum by 1
1406 \expandafter\xdef\csname#1\endcsname{\the\tempnum}}
1407 %
1408 % #1 is the section text, which is what will be displayed in the
1409 % outline by the pdf viewer. #2 is the pdf expression for the number
1410 % of subentries (or empty, for subsubsections). #3 is the node text,
1411 % which might be empty if this toc entry had no corresponding node.
1412 % #4 is the page number
1413 %
1414 \def\dopdfoutline#1#2#3#4{%
1415 % Generate a link to the node text if that exists; else, use the
1416 % page number. We could generate a destination for the section
1417 % text in the case where a section has no node, but it doesn't
1418 % seem worth the trouble, since most documents are normally structured.
1419 \setpdfoutlinetext{#1}
1420 \setpdfdestname{#3}
1421 \ifx\pdfdestname\empty
1422 \def\pdfdestname{#4}%
1423 \fi
1424 %
1425 \pdfoutline goto name{\pdfmkpgn{\pdfdestname}}#2{\pdfoutlinetext}%
1426 }
1427 %
1428 \def\pdfmakeoutlines{%
1429 \begingroup
1430 % Read toc silently, to get counts of subentries for \pdfoutline.
1431 \def\partentry##1##2##3##4{}% ignore parts in the outlines
1432 \def\numchapentry##1##2##3##4{%
1433 \def\thischapnum{##2}%
1434 \def\thissecnum{0}%
1435 \def\thissubsecnum{0}%
1436 }%
1437 \def\numsecentry##1##2##3##4{%
1438 \advancenumber{chap\thischapnum}%
1439 \def\thissecnum{##2}%
1440 \def\thissubsecnum{0}%
1441 }%
1442 \def\numsubsecentry##1##2##3##4{%
1443 \advancenumber{sec\thissecnum}%
1444 \def\thissubsecnum{##2}%
1445 }%
1446 \def\numsubsubsecentry##1##2##3##4{%
1447 \advancenumber{subsec\thissubsecnum}%
1448 }%
1449 \def\thischapnum{0}%
1450 \def\thissecnum{0}%
1451 \def\thissubsecnum{0}%
1452 %
1453 % use \def rather than \let here because we redefine \chapentry et
1454 % al. a second time, below.
1455 \def\appentry{\numchapentry}%
1456 \def\appsecentry{\numsecentry}%
1457 \def\appsubsecentry{\numsubsecentry}%
1458 \def\appsubsubsecentry{\numsubsubsecentry}%
1459 \def\unnchapentry{\numchapentry}%
1460 \def\unnsecentry{\numsecentry}%
1461 \def\unnsubsecentry{\numsubsecentry}%
1462 \def\unnsubsubsecentry{\numsubsubsecentry}%
1463 \readdatafile{toc}%
1464 %
1465 % Read toc second time, this time actually producing the outlines.
1466 % The `-' means take the \expnumber as the absolute number of
1467 % subentries, which we calculated on our first read of the .toc above.
1468 %
1469 % We use the node names as the destinations.
1470 %
1471 % Currently we prefix the section name with the section number
1472 % for chapter and appendix headings only in order to avoid too much
1473 % horizontal space being required in the PDF viewer.
1474 \def\numchapentry##1##2##3##4{%
1475 \dopdfoutline{##2 ##1}{count-\expnumber{chap##2}}{##3}{##4}}%
1476 \def\unnchapentry##1##2##3##4{%
1477 \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}%
1478 \def\numsecentry##1##2##3##4{%
1479 \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}%
1480 \def\numsubsecentry##1##2##3##4{%
1481 \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}%
1482 \def\numsubsubsecentry##1##2##3##4{% count is always zero
1483 \dopdfoutline{##1}{}{##3}{##4}}%
1484 %
1485 % PDF outlines are displayed using system fonts, instead of
1486 % document fonts. Therefore we cannot use special characters,
1487 % since the encoding is unknown. For example, the eogonek from
1488 % Latin 2 (0xea) gets translated to a | character. Info from
1489 % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100.
1490 %
1491 % TODO this right, we have to translate 8-bit characters to
1492 % their "best" equivalent, based on the @documentencoding. Too
1493 % much work for too little return. Just use the ASCII equivalents
1494 % we use for the index sort strings.
1495 %
1496 \indexnofonts
1497 \setupdatafile
1498 % We can have normal brace characters in the PDF outlines, unlike
1499 % Texinfo index files. So set that up.
1500 \def\{{\lbracecharliteral}%
1501 \def\}{\rbracecharliteral}%
1502 \catcode`\\=\active \otherbackslash
1503 \input \tocreadfilename
1504 \endgroup
1505 }
1506 {\catcode`[=1 \catcode`]=2
1507 \catcode`{=\other \catcode`}=\other
1508 \gdef\lbracecharliteral[{]%
1509 \gdef\rbracecharliteral[}]%
1510 ]
1511 %
1512 \def\skipspaces#1{\def\PP{#1}\def\D{|}%
1513 \ifx\PP\D\let\nextsp\relax
1514 \else\let\nextsp\skipspaces
1515 \addtokens{\filename}{\PP}%
1516 \advance\filenamelength by 1
1517 \fi
1518 \nextsp}
1519 \def\getfilename#1{%
1520 \filenamelength=0
1521 % If we don't expand the argument now, \skipspaces will get
1522 % snagged on things like "@value{foo}".
1523 \edef\temp{#1}%
1524 \expandafter\skipspaces\temp|\relax
1525 }
1526 \ifnum\pdftexversion < 14
1527 \let \startlink \pdfannotlink
1528 \else
1529 \let \startlink \pdfstartlink
1530 \fi
1531 % make a live url in pdf output.
1532 \def\pdfurl#1{%
1533 \begingroup
1534 % it seems we really need yet another set of dummies; have not
1535 % tried to figure out what each command should do in the context
1536 % of @url. for now, just make @/ a no-op, that's the only one
1537 % people have actually reported a problem with.
1538 %
1539 \normalturnoffactive
1540 \def\@{@}%
1541 \let\/=\empty
1542 \makevalueexpandable
1543 % do we want to go so far as to use \indexnofonts instead of just
1544 % special-casing \var here?
1545 \def\var##1{##1}%
1546 %
1547 \leavevmode\setcolor{\urlcolor}%
1548 \startlink attr{/Border [0 0 0]}%
1549 user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
1550 \endgroup}
1551 % \pdfgettoks - Surround page numbers in #1 with @pdflink. #1 may
1552 % be a simple number, or a list of numbers in the case of an index
1553 % entry.
1554 \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1555 \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1556 \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1557 \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1558 \def\maketoks{%
1559 \expandafter\poptoks\the\toksA|ENDTOKS|\relax
1560 \ifx\first0\adn0
1561 \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1562 \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
1563 \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
1564 \else
1565 \ifnum0=\countA\else\makelink\fi
1566 \ifx\first.\let\next=\done\else
1567 \let\next=\maketoks
1568 \addtokens{\toksB}{\the\toksD}
1569 \ifx\first,\addtokens{\toksB}{\space}\fi
1570 \fi
1571 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1572 \next}
1573 \def\makelink{\addtokens{\toksB}%
1574 {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1575 \def\pdflink#1{%
1576 \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}}
1577 \setcolor{\linkcolor}#1\endlink}
1578 \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1579\else
1580 % non-pdf mode
1581 \let\pdfmkdest = \gobble
1582 \let\pdfurl = \gobble
1583 \let\endlink = \relax
1584 \let\setcolor = \gobble
1585 \let\pdfsetcolor = \gobble
1586 \let\pdfmakeoutlines = \relax
1587\fi % \ifx\pdfoutput
1588
1589%
1590% For XeTeX
1591%
1592\ifx\XeTeXrevision\thisisundefined
1593\else
1594 %
1595 % XeTeX version check
1596 %
1597 \ifnum\strcmp{\the\XeTeXversion\XeTeXrevision}{0.99996}>-1
1598 % TeX Live 2016 contains XeTeX 0.99996 and xdvipdfmx 20160307.
1599 % It can use the `dvipdfmx:config' special (from TeX Live SVN r40941).
1600 % For avoiding PDF destination name replacement, we use this special
1601 % instead of xdvipdfmx's command line option `-C 0x0010'.
1602 \special{dvipdfmx:config C 0x0010}
1603 % XeTeX 0.99995+ comes with xdvipdfmx 20160307+.
1604 % It can handle Unicode destination names for PDF.
1605 \txiuseunicodedestnametrue
1606 \else
1607 % XeTeX < 0.99996 (TeX Live < 2016) cannot use the
1608 % `dvipdfmx:config' special.
1609 % So for avoiding PDF destination name replacement,
1610 % xdvipdfmx's command line option `-C 0x0010' is necessary.
1611 %
1612 % XeTeX < 0.99995 can not handle Unicode destination names for PDF
1613 % because xdvipdfmx 20150315 has a UTF-16 conversion issue.
1614 % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753).
1615 \txiuseunicodedestnamefalse
1616 \fi
1617 %
1618 % Color support
1619 %
1620 \def\rgbDarkRed{0.50 0.09 0.12}
1621 \def\rgbBlack{0 0 0}
1622 %
1623 \def\pdfsetcolor#1{\special{pdf:scolor [#1]}}
1624 %
1625 % Set color, and create a mark which defines \thiscolor accordingly,
1626 % so that \makeheadline knows which color to restore.
1627 \def\setcolor#1{%
1628 \xdef\currentcolordefs{\gdef\noexpand\thiscolor{#1}}%
1629 \domark
1630 \pdfsetcolor{#1}%
1631 }
1632 %
1633 \def\maincolor{\rgbBlack}
1634 \pdfsetcolor{\maincolor}
1635 \edef\thiscolor{\maincolor}
1636 \def\currentcolordefs{}
1637 %
1638 \def\makefootline{%
1639 \baselineskip24pt
1640 \line{\pdfsetcolor{\maincolor}\the\footline}%
1641 }
1642 %
1643 \def\makeheadline{%
1644 \vbox to 0pt{%
1645 \vskip-22.5pt
1646 \line{%
1647 \vbox to8.5pt{}%
1648 % Extract \thiscolor definition from the marks.
1649 \getcolormarks
1650 % Typeset the headline with \maincolor, then restore the color.
1651 \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
1652 }%
1653 \vss
1654 }%
1655 \nointerlineskip
1656 }
1657 %
1658 % PDF outline support
1659 %
1660 % Emulate pdfTeX primitive
1661 \def\pdfdest name#1 xyz{%
1662 \special{pdf:dest (#1) [@thispage /XYZ @xpos @ypos null]}%
1663 }
1664 %
1665 \def\setpdfdestname#1{{%
1666 % We have to set dummies so commands such as @code, and characters
1667 % such as \, aren't expanded when present in a section title.
1668 \indexnofonts
1669 \makevalueexpandable
1670 \turnoffactive
1671 \iftxiuseunicodedestname
1672 % Pass through Unicode characters.
1673 \else
1674 % Use ASCII approximations in destination names.
1675 \passthroughcharsfalse
1676 \fi
1677 \def\pdfdestname{#1}%
1678 \txiescapepdf\pdfdestname
1679 }}
1680 %
1681 \def\setpdfoutlinetext#1{{%
1682 \turnoffactive
1683 % Always use Unicode characters in title texts.
1684 \def\pdfoutlinetext{#1}%
1685 % For XeTeX, xdvipdfmx converts to UTF-16.
1686 % So we do not convert.
1687 \txiescapepdf\pdfoutlinetext
1688 }}
1689 %
1690 \def\pdfmkdest#1{%
1691 \setpdfdestname{#1}%
1692 \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
1693 }
1694 %
1695 % by default, use black for everything.
1696 \def\urlcolor{\rgbBlack}
1697 \def\linkcolor{\rgbBlack}
1698 \def\endlink{\setcolor{\maincolor}\pdfendlink}
1699 %
1700 \def\dopdfoutline#1#2#3#4{%
1701 \setpdfoutlinetext{#1}
1702 \setpdfdestname{#3}
1703 \ifx\pdfdestname\empty
1704 \def\pdfdestname{#4}%
1705 \fi
1706 %
1707 \special{pdf:out [-] #2 << /Title (\pdfoutlinetext) /A
1708 << /S /GoTo /D (\pdfdestname) >> >> }%
1709 }
1710 %
1711 \def\pdfmakeoutlines{%
1712 \begingroup
1713 %
1714 % For XeTeX, counts of subentries are not necessary.
1715 % Therefore, we read toc only once.
1716 %
1717 % We use node names as destinations.
1718 %
1719 % Currently we prefix the section name with the section number
1720 % for chapter and appendix headings only in order to avoid too much
1721 % horizontal space being required in the PDF viewer.
1722 \def\partentry##1##2##3##4{}% ignore parts in the outlines
1723 \def\numchapentry##1##2##3##4{%
1724 \dopdfoutline{##2 ##1}{1}{##3}{##4}}%
1725 \def\numsecentry##1##2##3##4{%
1726 \dopdfoutline{##1}{2}{##3}{##4}}%
1727 \def\numsubsecentry##1##2##3##4{%
1728 \dopdfoutline{##1}{3}{##3}{##4}}%
1729 \def\numsubsubsecentry##1##2##3##4{%
1730 \dopdfoutline{##1}{4}{##3}{##4}}%
1731 %
1732 \let\appentry\numchapentry%
1733 \let\appsecentry\numsecentry%
1734 \let\appsubsecentry\numsubsecentry%
1735 \let\appsubsubsecentry\numsubsubsecentry%
1736 \def\unnchapentry##1##2##3##4{%
1737 \dopdfoutline{##1}{1}{##3}{##4}}%
1738 \let\unnsecentry\numsecentry%
1739 \let\unnsubsecentry\numsubsecentry%
1740 \let\unnsubsubsecentry\numsubsubsecentry%
1741 %
1742 % For XeTeX, xdvipdfmx converts strings to UTF-16.
1743 % Therefore, the encoding and the language may not be considered.
1744 %
1745 \indexnofonts
1746 \setupdatafile
1747 % We can have normal brace characters in the PDF outlines, unlike
1748 % Texinfo index files. So set that up.
1749 \def\{{\lbracecharliteral}%
1750 \def\}{\rbracecharliteral}%
1751 \catcode`\\=\active \otherbackslash
1752 \input \tocreadfilename
1753 \endgroup
1754 }
1755 {\catcode`[=1 \catcode`]=2
1756 \catcode`{=\other \catcode`}=\other
1757 \gdef\lbracecharliteral[{]%
1758 \gdef\rbracecharliteral[}]%
1759 ]
1760
1761 \special{pdf:docview << /PageMode /UseOutlines >> }
1762 % ``\special{pdf:tounicode ...}'' is not necessary
1763 % because xdvipdfmx converts strings from UTF-8 to UTF-16 without it.
1764 % However, due to a UTF-16 conversion issue of xdvipdfmx 20150315,
1765 % ``\special{pdf:dest ...}'' cannot handle non-ASCII strings.
1766 % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753).
1767%
1768 \def\skipspaces#1{\def\PP{#1}\def\D{|}%
1769 \ifx\PP\D\let\nextsp\relax
1770 \else\let\nextsp\skipspaces
1771 \addtokens{\filename}{\PP}%
1772 \advance\filenamelength by 1
1773 \fi
1774 \nextsp}
1775 \def\getfilename#1{%
1776 \filenamelength=0
1777 % If we don't expand the argument now, \skipspaces will get
1778 % snagged on things like "@value{foo}".
1779 \edef\temp{#1}%
1780 \expandafter\skipspaces\temp|\relax
1781 }
1782 % make a live url in pdf output.
1783 \def\pdfurl#1{%
1784 \begingroup
1785 % it seems we really need yet another set of dummies; have not
1786 % tried to figure out what each command should do in the context
1787 % of @url. for now, just make @/ a no-op, that's the only one
1788 % people have actually reported a problem with.
1789 %
1790 \normalturnoffactive
1791 \def\@{@}%
1792 \let\/=\empty
1793 \makevalueexpandable
1794 % do we want to go so far as to use \indexnofonts instead of just
1795 % special-casing \var here?
1796 \def\var##1{##1}%
1797 %
1798 \leavevmode\setcolor{\urlcolor}%
1799 \special{pdf:bann << /Border [0 0 0]
1800 /Subtype /Link /A << /S /URI /URI (#1) >> >>}%
1801 \endgroup}
1802 \def\endlink{\setcolor{\maincolor}\special{pdf:eann}}
1803 \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1804 \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1805 \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1806 \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1807 \def\maketoks{%
1808 \expandafter\poptoks\the\toksA|ENDTOKS|\relax
1809 \ifx\first0\adn0
1810 \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1811 \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
1812 \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
1813 \else
1814 \ifnum0=\countA\else\makelink\fi
1815 \ifx\first.\let\next=\done\else
1816 \let\next=\maketoks
1817 \addtokens{\toksB}{\the\toksD}
1818 \ifx\first,\addtokens{\toksB}{\space}\fi
1819 \fi
1820 \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
1821 \next}
1822 \def\makelink{\addtokens{\toksB}%
1823 {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
1824 \def\pdflink#1{%
1825 \special{pdf:bann << /Border [0 0 0]
1826 /Type /Annot /Subtype /Link /A << /S /GoTo /D (#1) >> >>}%
1827 \setcolor{\linkcolor}#1\endlink}
1828 \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1829%
1830 %
1831 % @image support
1832 %
1833 % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
1834 \def\doxeteximage#1#2#3{%
1835 \def\xeteximagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
1836 \def\xeteximageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
1837 %
1838 % XeTeX (and the PDF format) supports .pdf, .png, .jpg (among
1839 % others). Let's try in that order, PDF first since if
1840 % someone has a scalable image, presumably better to use that than a
1841 % bitmap.
1842 \let\xeteximgext=\empty
1843 \begingroup
1844 \openin 1 #1.pdf \ifeof 1
1845 \openin 1 #1.PDF \ifeof 1
1846 \openin 1 #1.png \ifeof 1
1847 \openin 1 #1.jpg \ifeof 1
1848 \openin 1 #1.jpeg \ifeof 1
1849 \openin 1 #1.JPG \ifeof 1
1850 \errmessage{Could not find image file #1 for XeTeX}%
1851 \else \gdef\xeteximgext{JPG}%
1852 \fi
1853 \else \gdef\xeteximgext{jpeg}%
1854 \fi
1855 \else \gdef\xeteximgext{jpg}%
1856 \fi
1857 \else \gdef\xeteximgext{png}%
1858 \fi
1859 \else \gdef\xeteximgext{PDF}%
1860 \fi
1861 \else \gdef\xeteximgext{pdf}%
1862 \fi
1863 \closein 1
1864 \endgroup
1865 %
1866 \def\xetexpdfext{pdf}%
1867 \ifx\xeteximgext\xetexpdfext
1868 \XeTeXpdffile "#1".\xeteximgext ""
1869 \else
1870 \def\xetexpdfext{PDF}%
1871 \ifx\xeteximgext\xetexpdfext
1872 \XeTeXpdffile "#1".\xeteximgext ""
1873 \else
1874 \XeTeXpicfile "#1".\xeteximgext ""
1875 \fi
1876 \fi
1877 \ifdim \wd0 >0pt width \xeteximagewidth \fi
1878 \ifdim \wd2 >0pt height \xeteximageheight \fi \relax
1879 }
1880\fi
1881
1882
1883%
1884\message{fonts,}
1885
1886% Set the baselineskip to #1, and the lineskip and strut size
1887% correspondingly. There is no deep meaning behind these magic numbers
1888% used as factors; they just match (closely enough) what Knuth defined.
1889%
1890\def\lineskipfactor{.08333}
1891\def\strutheightpercent{.70833}
1892\def\strutdepthpercent {.29167}
1893%
1894% can get a sort of poor man's double spacing by redefining this.
1895\def\baselinefactor{1}
1896%
1897\newdimen\textleading
1898\def\setleading#1{%
1899 \dimen0 = #1\relax
1900 \normalbaselineskip = \baselinefactor\dimen0
1901 \normallineskip = \lineskipfactor\normalbaselineskip
1902 \normalbaselines
1903 \setbox\strutbox =\hbox{%
1904 \vrule width0pt height\strutheightpercent\baselineskip
1905 depth \strutdepthpercent \baselineskip
1906 }%
1907}
1908
1909% PDF CMaps. See also LaTeX's t1.cmap.
1910%
1911% do nothing with this by default.
1912\expandafter\let\csname cmapOT1\endcsname\gobble
1913\expandafter\let\csname cmapOT1IT\endcsname\gobble
1914\expandafter\let\csname cmapOT1TT\endcsname\gobble
1915
1916% if we are producing pdf, and we have \pdffontattr, then define cmaps.
1917% (\pdffontattr was introduced many years ago, but people still run
1918% older pdftex's; it's easy to conditionalize, so we do.)
1919\ifpdf \ifx\pdffontattr\thisisundefined \else
1920 \begingroup
1921 \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
1922 \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
1923%%DocumentNeededResources: ProcSet (CIDInit)
1924%%IncludeResource: ProcSet (CIDInit)
1925%%BeginResource: CMap (TeX-OT1-0)
1926%%Title: (TeX-OT1-0 TeX OT1 0)
1927%%Version: 1.000
1928%%EndComments
1929/CIDInit /ProcSet findresource begin
193012 dict begin
1931begincmap
1932/CIDSystemInfo
1933<< /Registry (TeX)
1934/Ordering (OT1)
1935/Supplement 0
1936>> def
1937/CMapName /TeX-OT1-0 def
1938/CMapType 2 def
19391 begincodespacerange
1940<00> <7F>
1941endcodespacerange
19428 beginbfrange
1943<00> <01> <0393>
1944<09> <0A> <03A8>
1945<23> <26> <0023>
1946<28> <3B> <0028>
1947<3F> <5B> <003F>
1948<5D> <5E> <005D>
1949<61> <7A> <0061>
1950<7B> <7C> <2013>
1951endbfrange
195240 beginbfchar
1953<02> <0398>
1954<03> <039B>
1955<04> <039E>
1956<05> <03A0>
1957<06> <03A3>
1958<07> <03D2>
1959<08> <03A6>
1960<0B> <00660066>
1961<0C> <00660069>
1962<0D> <0066006C>
1963<0E> <006600660069>
1964<0F> <00660066006C>
1965<10> <0131>
1966<11> <0237>
1967<12> <0060>
1968<13> <00B4>
1969<14> <02C7>
1970<15> <02D8>
1971<16> <00AF>
1972<17> <02DA>
1973<18> <00B8>
1974<19> <00DF>
1975<1A> <00E6>
1976<1B> <0153>
1977<1C> <00F8>
1978<1D> <00C6>
1979<1E> <0152>
1980<1F> <00D8>
1981<21> <0021>
1982<22> <201D>
1983<27> <2019>
1984<3C> <00A1>
1985<3D> <003D>
1986<3E> <00BF>
1987<5C> <201C>
1988<5F> <02D9>
1989<60> <2018>
1990<7D> <02DD>
1991<7E> <007E>
1992<7F> <00A8>
1993endbfchar
1994endcmap
1995CMapName currentdict /CMap defineresource pop
1996end
1997end
1998%%EndResource
1999%%EOF
2000 }\endgroup
2001 \expandafter\edef\csname cmapOT1\endcsname#1{%
2002 \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
2003 }%
2004%
2005% \cmapOT1IT
2006 \begingroup
2007 \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
2008 \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
2009%%DocumentNeededResources: ProcSet (CIDInit)
2010%%IncludeResource: ProcSet (CIDInit)
2011%%BeginResource: CMap (TeX-OT1IT-0)
2012%%Title: (TeX-OT1IT-0 TeX OT1IT 0)
2013%%Version: 1.000
2014%%EndComments
2015/CIDInit /ProcSet findresource begin
201612 dict begin
2017begincmap
2018/CIDSystemInfo
2019<< /Registry (TeX)
2020/Ordering (OT1IT)
2021/Supplement 0
2022>> def
2023/CMapName /TeX-OT1IT-0 def
2024/CMapType 2 def
20251 begincodespacerange
2026<00> <7F>
2027endcodespacerange
20288 beginbfrange
2029<00> <01> <0393>
2030<09> <0A> <03A8>
2031<25> <26> <0025>
2032<28> <3B> <0028>
2033<3F> <5B> <003F>
2034<5D> <5E> <005D>
2035<61> <7A> <0061>
2036<7B> <7C> <2013>
2037endbfrange
203842 beginbfchar
2039<02> <0398>
2040<03> <039B>
2041<04> <039E>
2042<05> <03A0>
2043<06> <03A3>
2044<07> <03D2>
2045<08> <03A6>
2046<0B> <00660066>
2047<0C> <00660069>
2048<0D> <0066006C>
2049<0E> <006600660069>
2050<0F> <00660066006C>
2051<10> <0131>
2052<11> <0237>
2053<12> <0060>
2054<13> <00B4>
2055<14> <02C7>
2056<15> <02D8>
2057<16> <00AF>
2058<17> <02DA>
2059<18> <00B8>
2060<19> <00DF>
2061<1A> <00E6>
2062<1B> <0153>
2063<1C> <00F8>
2064<1D> <00C6>
2065<1E> <0152>
2066<1F> <00D8>
2067<21> <0021>
2068<22> <201D>
2069<23> <0023>
2070<24> <00A3>
2071<27> <2019>
2072<3C> <00A1>
2073<3D> <003D>
2074<3E> <00BF>
2075<5C> <201C>
2076<5F> <02D9>
2077<60> <2018>
2078<7D> <02DD>
2079<7E> <007E>
2080<7F> <00A8>
2081endbfchar
2082endcmap
2083CMapName currentdict /CMap defineresource pop
2084end
2085end
2086%%EndResource
2087%%EOF
2088 }\endgroup
2089 \expandafter\edef\csname cmapOT1IT\endcsname#1{%
2090 \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
2091 }%
2092%
2093% \cmapOT1TT
2094 \begingroup
2095 \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
2096 \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
2097%%DocumentNeededResources: ProcSet (CIDInit)
2098%%IncludeResource: ProcSet (CIDInit)
2099%%BeginResource: CMap (TeX-OT1TT-0)
2100%%Title: (TeX-OT1TT-0 TeX OT1TT 0)
2101%%Version: 1.000
2102%%EndComments
2103/CIDInit /ProcSet findresource begin
210412 dict begin
2105begincmap
2106/CIDSystemInfo
2107<< /Registry (TeX)
2108/Ordering (OT1TT)
2109/Supplement 0
2110>> def
2111/CMapName /TeX-OT1TT-0 def
2112/CMapType 2 def
21131 begincodespacerange
2114<00> <7F>
2115endcodespacerange
21165 beginbfrange
2117<00> <01> <0393>
2118<09> <0A> <03A8>
2119<21> <26> <0021>
2120<28> <5F> <0028>
2121<61> <7E> <0061>
2122endbfrange
212332 beginbfchar
2124<02> <0398>
2125<03> <039B>
2126<04> <039E>
2127<05> <03A0>
2128<06> <03A3>
2129<07> <03D2>
2130<08> <03A6>
2131<0B> <2191>
2132<0C> <2193>
2133<0D> <0027>
2134<0E> <00A1>
2135<0F> <00BF>
2136<10> <0131>
2137<11> <0237>
2138<12> <0060>
2139<13> <00B4>
2140<14> <02C7>
2141<15> <02D8>
2142<16> <00AF>
2143<17> <02DA>
2144<18> <00B8>
2145<19> <00DF>
2146<1A> <00E6>
2147<1B> <0153>
2148<1C> <00F8>
2149<1D> <00C6>
2150<1E> <0152>
2151<1F> <00D8>
2152<20> <2423>
2153<27> <2019>
2154<60> <2018>
2155<7F> <00A8>
2156endbfchar
2157endcmap
2158CMapName currentdict /CMap defineresource pop
2159end
2160end
2161%%EndResource
2162%%EOF
2163 }\endgroup
2164 \expandafter\edef\csname cmapOT1TT\endcsname#1{%
2165 \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
2166 }%
2167\fi\fi
2168
2169
2170% Set the font macro #1 to the font named \fontprefix#2.
2171% #3 is the font's design size, #4 is a scale factor, #5 is the CMap
2172% encoding (only OT1, OT1IT and OT1TT are allowed, or empty to omit).
2173% Example:
2174% #1 = \textrm
2175% #2 = \rmshape
2176% #3 = 10
2177% #4 = \mainmagstep
2178% #5 = OT1
2179%
2180\def\setfont#1#2#3#4#5{%
2181 \font#1=\fontprefix#2#3 scaled #4
2182 \csname cmap#5\endcsname#1%
2183}
2184% This is what gets called when #5 of \setfont is empty.
2185\let\cmap\gobble
2186%
2187% (end of cmaps)
2188
2189% Use cm as the default font prefix.
2190% To specify the font prefix, you must define \fontprefix
2191% before you read in texinfo.tex.
2192\ifx\fontprefix\thisisundefined
2193\def\fontprefix{cm}
2194\fi
2195% Support font families that don't use the same naming scheme as CM.
2196\def\rmshape{r}
2197\def\rmbshape{bx} % where the normal face is bold
2198\def\bfshape{b}
2199\def\bxshape{bx}
2200\def\ttshape{tt}
2201\def\ttbshape{tt}
2202\def\ttslshape{sltt}
2203\def\itshape{ti}
2204\def\itbshape{bxti}
2205\def\slshape{sl}
2206\def\slbshape{bxsl}
2207\def\sfshape{ss}
2208\def\sfbshape{ss}
2209\def\scshape{csc}
2210\def\scbshape{csc}
2211
2212% Definitions for a main text size of 11pt. (The default in Texinfo.)
2213%
2214\def\definetextfontsizexi{%
2215% Text fonts (11.2pt, magstep1).
2216\def\textnominalsize{11pt}
2217\edef\mainmagstep{\magstephalf}
2218\setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
2219\setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
2220\setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
2221\setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
2222\setfont\textsl\slshape{10}{\mainmagstep}{OT1}
2223\setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
2224\setfont\textsc\scshape{10}{\mainmagstep}{OT1}
2225\setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
2226\font\texti=cmmi10 scaled \mainmagstep
2227\font\textsy=cmsy10 scaled \mainmagstep
2228\def\textecsize{1095}
2229
2230% A few fonts for @defun names and args.
2231\setfont\defbf\bfshape{10}{\magstep1}{OT1}
2232\setfont\deftt\ttshape{10}{\magstep1}{OT1TT}
2233\setfont\defsl\slshape{10}{\magstep1}{OT1}
2234\setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT}
2235\def\df{\let\ttfont=\deftt \let\bffont = \defbf
2236\let\ttslfont=\defttsl \let\slfont=\defsl \bf}
2237
2238% Fonts for indices, footnotes, small examples (9pt).
2239\def\smallnominalsize{9pt}
2240\setfont\smallrm\rmshape{9}{1000}{OT1}
2241\setfont\smalltt\ttshape{9}{1000}{OT1TT}
2242\setfont\smallbf\bfshape{10}{900}{OT1}
2243\setfont\smallit\itshape{9}{1000}{OT1IT}
2244\setfont\smallsl\slshape{9}{1000}{OT1}
2245\setfont\smallsf\sfshape{9}{1000}{OT1}
2246\setfont\smallsc\scshape{10}{900}{OT1}
2247\setfont\smallttsl\ttslshape{10}{900}{OT1TT}
2248\font\smalli=cmmi9
2249\font\smallsy=cmsy9
2250\def\smallecsize{0900}
2251
2252% Fonts for small examples (8pt).
2253\def\smallernominalsize{8pt}
2254\setfont\smallerrm\rmshape{8}{1000}{OT1}
2255\setfont\smallertt\ttshape{8}{1000}{OT1TT}
2256\setfont\smallerbf\bfshape{10}{800}{OT1}
2257\setfont\smallerit\itshape{8}{1000}{OT1IT}
2258\setfont\smallersl\slshape{8}{1000}{OT1}
2259\setfont\smallersf\sfshape{8}{1000}{OT1}
2260\setfont\smallersc\scshape{10}{800}{OT1}
2261\setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
2262\font\smalleri=cmmi8
2263\font\smallersy=cmsy8
2264\def\smallerecsize{0800}
2265
2266% Fonts for math mode superscripts (7pt).
2267\def\sevennominalsize{7pt}
2268\setfont\sevenrm\rmshape{7}{1000}{OT1}
2269\setfont\seventt\ttshape{10}{700}{OT1TT}
2270\setfont\sevenbf\bfshape{10}{700}{OT1}
2271\setfont\sevenit\itshape{7}{1000}{OT1IT}
2272\setfont\sevensl\slshape{10}{700}{OT1}
2273\setfont\sevensf\sfshape{10}{700}{OT1}
2274\setfont\sevensc\scshape{10}{700}{OT1}
2275\setfont\seventtsl\ttslshape{10}{700}{OT1TT}
2276\font\seveni=cmmi7
2277\font\sevensy=cmsy7
2278\def\sevenecsize{0700}
2279
2280% Fonts for title page (20.4pt):
2281\def\titlenominalsize{20pt}
2282\setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
2283\setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
2284\setfont\titlesl\slbshape{10}{\magstep4}{OT1}
2285\setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
2286\setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
2287\setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
2288\let\titlebf=\titlerm
2289\setfont\titlesc\scbshape{10}{\magstep4}{OT1}
2290\font\titlei=cmmi12 scaled \magstep3
2291\font\titlesy=cmsy10 scaled \magstep4
2292\def\titleecsize{2074}
2293
2294% Chapter (and unnumbered) fonts (17.28pt).
2295\def\chapnominalsize{17pt}
2296\setfont\chaprm\rmbshape{12}{\magstep2}{OT1}
2297\setfont\chapit\itbshape{10}{\magstep3}{OT1IT}
2298\setfont\chapsl\slbshape{10}{\magstep3}{OT1}
2299\setfont\chaptt\ttbshape{12}{\magstep2}{OT1TT}
2300\setfont\chapttsl\ttslshape{10}{\magstep3}{OT1TT}
2301\setfont\chapsf\sfbshape{17}{1000}{OT1}
2302\let\chapbf=\chaprm
2303\setfont\chapsc\scbshape{10}{\magstep3}{OT1}
2304\font\chapi=cmmi12 scaled \magstep2
2305\font\chapsy=cmsy10 scaled \magstep3
2306\def\chapecsize{1728}
2307
2308% Section fonts (14.4pt).
2309\def\secnominalsize{14pt}
2310\setfont\secrm\rmbshape{12}{\magstep1}{OT1}
2311\setfont\secrmnotbold\rmshape{12}{\magstep1}{OT1}
2312\setfont\secit\itbshape{10}{\magstep2}{OT1IT}
2313\setfont\secsl\slbshape{10}{\magstep2}{OT1}
2314\setfont\sectt\ttbshape{12}{\magstep1}{OT1TT}
2315\setfont\secttsl\ttslshape{10}{\magstep2}{OT1TT}
2316\setfont\secsf\sfbshape{12}{\magstep1}{OT1}
2317\let\secbf\secrm
2318\setfont\secsc\scbshape{10}{\magstep2}{OT1}
2319\font\seci=cmmi12 scaled \magstep1
2320\font\secsy=cmsy10 scaled \magstep2
2321\def\sececsize{1440}
2322
2323% Subsection fonts (13.15pt).
2324\def\ssecnominalsize{13pt}
2325\setfont\ssecrm\rmbshape{12}{\magstephalf}{OT1}
2326\setfont\ssecit\itbshape{10}{1315}{OT1IT}
2327\setfont\ssecsl\slbshape{10}{1315}{OT1}
2328\setfont\ssectt\ttbshape{12}{\magstephalf}{OT1TT}
2329\setfont\ssecttsl\ttslshape{10}{1315}{OT1TT}
2330\setfont\ssecsf\sfbshape{12}{\magstephalf}{OT1}
2331\let\ssecbf\ssecrm
2332\setfont\ssecsc\scbshape{10}{1315}{OT1}
2333\font\sseci=cmmi12 scaled \magstephalf
2334\font\ssecsy=cmsy10 scaled 1315
2335\def\ssececsize{1200}
2336
2337% Reduced fonts for @acronym in text (10pt).
2338\def\reducednominalsize{10pt}
2339\setfont\reducedrm\rmshape{10}{1000}{OT1}
2340\setfont\reducedtt\ttshape{10}{1000}{OT1TT}
2341\setfont\reducedbf\bfshape{10}{1000}{OT1}
2342\setfont\reducedit\itshape{10}{1000}{OT1IT}
2343\setfont\reducedsl\slshape{10}{1000}{OT1}
2344\setfont\reducedsf\sfshape{10}{1000}{OT1}
2345\setfont\reducedsc\scshape{10}{1000}{OT1}
2346\setfont\reducedttsl\ttslshape{10}{1000}{OT1TT}
2347\font\reducedi=cmmi10
2348\font\reducedsy=cmsy10
2349\def\reducedecsize{1000}
2350
2351\textleading = 13.2pt % line spacing for 11pt CM
2352\textfonts % reset the current fonts
2353\rm
2354} % end of 11pt text font size definitions, \definetextfontsizexi
2355
2356
2357% Definitions to make the main text be 10pt Computer Modern, with
2358% section, chapter, etc., sizes following suit. This is for the GNU
2359% Press printing of the Emacs 22 manual. Maybe other manuals in the
2360% future. Used with @smallbook, which sets the leading to 12pt.
2361%
2362\def\definetextfontsizex{%
2363% Text fonts (10pt).
2364\def\textnominalsize{10pt}
2365\edef\mainmagstep{1000}
2366\setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
2367\setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
2368\setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
2369\setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
2370\setfont\textsl\slshape{10}{\mainmagstep}{OT1}
2371\setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
2372\setfont\textsc\scshape{10}{\mainmagstep}{OT1}
2373\setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
2374\font\texti=cmmi10 scaled \mainmagstep
2375\font\textsy=cmsy10 scaled \mainmagstep
2376\def\textecsize{1000}
2377
2378% A few fonts for @defun names and args.
2379\setfont\defbf\bfshape{10}{\magstephalf}{OT1}
2380\setfont\deftt\ttshape{10}{\magstephalf}{OT1TT}
2381\setfont\defsl\slshape{10}{\magstephalf}{OT1}
2382\setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT}
2383\def\df{\let\ttfont=\deftt \let\bffont = \defbf
2384\let\slfont=\defsl \let\ttslfont=\defttsl \bf}
2385
2386% Fonts for indices, footnotes, small examples (9pt).
2387\def\smallnominalsize{9pt}
2388\setfont\smallrm\rmshape{9}{1000}{OT1}
2389\setfont\smalltt\ttshape{9}{1000}{OT1TT}
2390\setfont\smallbf\bfshape{10}{900}{OT1}
2391\setfont\smallit\itshape{9}{1000}{OT1IT}
2392\setfont\smallsl\slshape{9}{1000}{OT1}
2393\setfont\smallsf\sfshape{9}{1000}{OT1}
2394\setfont\smallsc\scshape{10}{900}{OT1}
2395\setfont\smallttsl\ttslshape{10}{900}{OT1TT}
2396\font\smalli=cmmi9
2397\font\smallsy=cmsy9
2398\def\smallecsize{0900}
2399
2400% Fonts for small examples (8pt).
2401\def\smallernominalsize{8pt}
2402\setfont\smallerrm\rmshape{8}{1000}{OT1}
2403\setfont\smallertt\ttshape{8}{1000}{OT1TT}
2404\setfont\smallerbf\bfshape{10}{800}{OT1}
2405\setfont\smallerit\itshape{8}{1000}{OT1IT}
2406\setfont\smallersl\slshape{8}{1000}{OT1}
2407\setfont\smallersf\sfshape{8}{1000}{OT1}
2408\setfont\smallersc\scshape{10}{800}{OT1}
2409\setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
2410\font\smalleri=cmmi8
2411\font\smallersy=cmsy8
2412\def\smallerecsize{0800}
2413
2414% Fonts for math mode superscripts (7pt).
2415\def\sevennominalsize{7pt}
2416\setfont\sevenrm\rmshape{7}{1000}{OT1}
2417\setfont\seventt\ttshape{10}{700}{OT1TT}
2418\setfont\sevenbf\bfshape{10}{700}{OT1}
2419\setfont\sevenit\itshape{7}{1000}{OT1IT}
2420\setfont\sevensl\slshape{10}{700}{OT1}
2421\setfont\sevensf\sfshape{10}{700}{OT1}
2422\setfont\sevensc\scshape{10}{700}{OT1}
2423\setfont\seventtsl\ttslshape{10}{700}{OT1TT}
2424\font\seveni=cmmi7
2425\font\sevensy=cmsy7
2426\def\sevenecsize{0700}
2427
2428% Fonts for title page (20.4pt):
2429\def\titlenominalsize{20pt}
2430\setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
2431\setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
2432\setfont\titlesl\slbshape{10}{\magstep4}{OT1}
2433\setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
2434\setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
2435\setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
2436\let\titlebf=\titlerm
2437\setfont\titlesc\scbshape{10}{\magstep4}{OT1}
2438\font\titlei=cmmi12 scaled \magstep3
2439\font\titlesy=cmsy10 scaled \magstep4
2440\def\titleecsize{2074}
2441
2442% Chapter fonts (14.4pt).
2443\def\chapnominalsize{14pt}
2444\setfont\chaprm\rmbshape{12}{\magstep1}{OT1}
2445\setfont\chapit\itbshape{10}{\magstep2}{OT1IT}
2446\setfont\chapsl\slbshape{10}{\magstep2}{OT1}
2447\setfont\chaptt\ttbshape{12}{\magstep1}{OT1TT}
2448\setfont\chapttsl\ttslshape{10}{\magstep2}{OT1TT}
2449\setfont\chapsf\sfbshape{12}{\magstep1}{OT1}
2450\let\chapbf\chaprm
2451\setfont\chapsc\scbshape{10}{\magstep2}{OT1}
2452\font\chapi=cmmi12 scaled \magstep1
2453\font\chapsy=cmsy10 scaled \magstep2
2454\def\chapecsize{1440}
2455
2456% Section fonts (12pt).
2457\def\secnominalsize{12pt}
2458\setfont\secrm\rmbshape{12}{1000}{OT1}
2459\setfont\secit\itbshape{10}{\magstep1}{OT1IT}
2460\setfont\secsl\slbshape{10}{\magstep1}{OT1}
2461\setfont\sectt\ttbshape{12}{1000}{OT1TT}
2462\setfont\secttsl\ttslshape{10}{\magstep1}{OT1TT}
2463\setfont\secsf\sfbshape{12}{1000}{OT1}
2464\let\secbf\secrm
2465\setfont\secsc\scbshape{10}{\magstep1}{OT1}
2466\font\seci=cmmi12
2467\font\secsy=cmsy10 scaled \magstep1
2468\def\sececsize{1200}
2469
2470% Subsection fonts (10pt).
2471\def\ssecnominalsize{10pt}
2472\setfont\ssecrm\rmbshape{10}{1000}{OT1}
2473\setfont\ssecit\itbshape{10}{1000}{OT1IT}
2474\setfont\ssecsl\slbshape{10}{1000}{OT1}
2475\setfont\ssectt\ttbshape{10}{1000}{OT1TT}
2476\setfont\ssecttsl\ttslshape{10}{1000}{OT1TT}
2477\setfont\ssecsf\sfbshape{10}{1000}{OT1}
2478\let\ssecbf\ssecrm
2479\setfont\ssecsc\scbshape{10}{1000}{OT1}
2480\font\sseci=cmmi10
2481\font\ssecsy=cmsy10
2482\def\ssececsize{1000}
2483
2484% Reduced fonts for @acronym in text (9pt).
2485\def\reducednominalsize{9pt}
2486\setfont\reducedrm\rmshape{9}{1000}{OT1}
2487\setfont\reducedtt\ttshape{9}{1000}{OT1TT}
2488\setfont\reducedbf\bfshape{10}{900}{OT1}
2489\setfont\reducedit\itshape{9}{1000}{OT1IT}
2490\setfont\reducedsl\slshape{9}{1000}{OT1}
2491\setfont\reducedsf\sfshape{9}{1000}{OT1}
2492\setfont\reducedsc\scshape{10}{900}{OT1}
2493\setfont\reducedttsl\ttslshape{10}{900}{OT1TT}
2494\font\reducedi=cmmi9
2495\font\reducedsy=cmsy9
2496\def\reducedecsize{0900}
2497
2498\divide\parskip by 2 % reduce space between paragraphs
2499\textleading = 12pt % line spacing for 10pt CM
2500\textfonts % reset the current fonts
2501\rm
2502} % end of 10pt text font size definitions, \definetextfontsizex
2503
2504% Fonts for short table of contents.
2505\setfont\shortcontrm\rmshape{12}{1000}{OT1}
2506\setfont\shortcontbf\bfshape{10}{\magstep1}{OT1} % no cmb12
2507\setfont\shortcontsl\slshape{12}{1000}{OT1}
2508\setfont\shortconttt\ttshape{12}{1000}{OT1TT}
2509
2510
2511% We provide the user-level command
2512% @fonttextsize 10
2513% (or 11) to redefine the text font size. pt is assumed.
2514%
2515\def\xiword{11}
2516\def\xword{10}
2517\def\xwordpt{10pt}
2518%
2519\parseargdef\fonttextsize{%
2520 \def\textsizearg{#1}%
2521 %\wlog{doing @fonttextsize \textsizearg}%
2522 %
2523 % Set \globaldefs so that documents can use this inside @tex, since
2524 % makeinfo 4.8 does not support it, but we need it nonetheless.
2525 %
2526 \begingroup \globaldefs=1
2527 \ifx\textsizearg\xword \definetextfontsizex
2528 \else \ifx\textsizearg\xiword \definetextfontsizexi
2529 \else
2530 \errhelp=\EMsimple
2531 \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'}
2532 \fi\fi
2533 \endgroup
2534}
2535
2536%
2537% Change the current font style to #1, remembering it in \curfontstyle.
2538% For now, we do not accumulate font styles: @b{@i{foo}} prints foo in
2539% italics, not bold italics.
2540%
2541\def\setfontstyle#1{%
2542 \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd.
2543 \csname #1font\endcsname % change the current font
2544}
2545
2546\def\rm{\fam=0 \setfontstyle{rm}}
2547\def\it{\fam=\itfam \setfontstyle{it}}
2548\def\sl{\fam=\slfam \setfontstyle{sl}}
2549\def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf}
2550\def\tt{\fam=\ttfam \setfontstyle{tt}}\def\ttstylename{tt}
2551
2552% Texinfo sort of supports the sans serif font style, which plain TeX does not.
2553% So we set up a \sf.
2554\newfam\sffam
2555\def\sf{\fam=\sffam \setfontstyle{sf}}
2556
2557% We don't need math for this font style.
2558\def\ttsl{\setfontstyle{ttsl}}
2559
2560
2561% In order for the font changes to affect most math symbols and letters,
2562% we have to define the \textfont of the standard families.
2563% We don't bother to reset \scriptscriptfont; awaiting user need.
2564%
2565\def\resetmathfonts{%
2566 \textfont0=\rmfont \textfont1=\ifont \textfont2=\syfont
2567 \textfont\itfam=\itfont \textfont\slfam=\slfont \textfont\bffam=\bffont
2568 \textfont\ttfam=\ttfont \textfont\sffam=\sffont
2569 %
2570 % Fonts for superscript. Note that the 7pt fonts are used regardless
2571 % of the current font size.
2572 \scriptfont0=\sevenrm \scriptfont1=\seveni \scriptfont2=\sevensy
2573 \scriptfont\itfam=\sevenit \scriptfont\slfam=\sevensl
2574 \scriptfont\bffam=\sevenbf \scriptfont\ttfam=\seventt
2575 \scriptfont\sffam=\sevensf
2576}
2577
2578%
2579
2580% The font-changing commands (all called \...fonts) redefine the meanings
2581% of \STYLEfont, instead of just \STYLE. We do this because \STYLE needs
2582% to also set the current \fam for math mode. Our \STYLE (e.g., \rm)
2583% commands hardwire \STYLEfont to set the current font.
2584%
2585% The fonts used for \ifont are for "math italics" (\itfont is for italics
2586% in regular text). \syfont is also used in math mode only.
2587%
2588% Each font-changing command also sets the names \lsize (one size lower)
2589% and \lllsize (three sizes lower). These relative commands are used
2590% in, e.g., the LaTeX logo and acronyms.
2591%
2592% This all needs generalizing, badly.
2593%
2594
2595\def\assignfonts#1{%
2596 \expandafter\let\expandafter\rmfont\csname #1rm\endcsname
2597 \expandafter\let\expandafter\itfont\csname #1it\endcsname
2598 \expandafter\let\expandafter\slfont\csname #1sl\endcsname
2599 \expandafter\let\expandafter\bffont\csname #1bf\endcsname
2600 \expandafter\let\expandafter\ttfont\csname #1tt\endcsname
2601 \expandafter\let\expandafter\smallcaps\csname #1sc\endcsname
2602 \expandafter\let\expandafter\sffont \csname #1sf\endcsname
2603 \expandafter\let\expandafter\ifont \csname #1i\endcsname
2604 \expandafter\let\expandafter\syfont \csname #1sy\endcsname
2605 \expandafter\let\expandafter\ttslfont\csname #1ttsl\endcsname
2606}
2607
2608\newif\ifrmisbold
2609
2610% Select smaller font size with the current style. Used to change font size
2611% in, e.g., the LaTeX logo and acronyms. If we are using bold fonts for
2612% normal roman text, also use bold fonts for roman text in the smaller size.
2613\def\switchtolllsize{%
2614 \expandafter\assignfonts\expandafter{\lllsize}%
2615 \ifrmisbold
2616 \let\rmfont\bffont
2617 \fi
2618 \csname\curfontstyle\endcsname
2619}%
2620
2621\def\switchtolsize{%
2622 \expandafter\assignfonts\expandafter{\lsize}%
2623 \ifrmisbold
2624 \let\rmfont\bffont
2625 \fi
2626 \csname\curfontstyle\endcsname
2627}%
2628
2629\def\definefontsetatsize#1#2#3#4#5{%
2630\expandafter\def\csname #1fonts\endcsname{%
2631 \def\curfontsize{#1}%
2632 \def\lsize{#2}\def\lllsize{#3}%
2633 \csname rmisbold#5\endcsname
2634 \assignfonts{#1}%
2635 \resetmathfonts
2636 \setleading{#4}%
2637}}
2638
2639\definefontsetatsize{text} {reduced}{smaller}{\textleading}{false}
2640\definefontsetatsize{title} {chap} {subsec} {27pt} {true}
2641\definefontsetatsize{chap} {sec} {text} {19pt} {true}
2642\definefontsetatsize{sec} {subsec} {reduced}{17pt} {true}
2643\definefontsetatsize{ssec} {text} {small} {15pt} {true}
2644\definefontsetatsize{reduced}{small} {smaller}{10.5pt}{false}
2645\definefontsetatsize{small} {smaller}{smaller}{10.5pt}{false}
2646\definefontsetatsize{smaller}{smaller}{smaller}{9.5pt} {false}
2647
2648\def\titlefont#1{{\titlefonts\rm #1}}
2649\let\subsecfonts = \ssecfonts
2650\let\subsubsecfonts = \ssecfonts
2651
2652% Define these just so they can be easily changed for other fonts.
2653\def\angleleft{$\langle$}
2654\def\angleright{$\rangle$}
2655
2656% Set the fonts to use with the @small... environments.
2657\let\smallexamplefonts = \smallfonts
2658
2659% About \smallexamplefonts. If we use \smallfonts (9pt), @smallexample
2660% can fit this many characters:
2661% 8.5x11=86 smallbook=72 a4=90 a5=69
2662% If we use \scriptfonts (8pt), then we can fit this many characters:
2663% 8.5x11=90+ smallbook=80 a4=90+ a5=77
2664% For me, subjectively, the few extra characters that fit aren't worth
2665% the additional smallness of 8pt. So I'm making the default 9pt.
2666%
2667% By the way, for comparison, here's what fits with @example (10pt):
2668% 8.5x11=71 smallbook=60 a4=75 a5=58
2669% --karl, 24jan03.
2670
2671% Set up the default fonts, so we can use them for creating boxes.
2672%
2673\definetextfontsizexi
2674
2675
2676\message{markup,}
2677
2678% Check if we are currently using a typewriter font. Since all the
2679% Computer Modern typewriter fonts have zero interword stretch (and
2680% shrink), and it is reasonable to expect all typewriter fonts to have
2681% this property, we can check that font parameter.
2682%
2683\def\ifmonospace{\ifdim\fontdimen3\font=0pt }
2684
2685% Markup style infrastructure. \defmarkupstylesetup\INITMACRO will
2686% define and register \INITMACRO to be called on markup style changes.
2687% \INITMACRO can check \currentmarkupstyle for the innermost
2688% style.
2689
2690\let\currentmarkupstyle\empty
2691
2692\def\setupmarkupstyle#1{%
2693 \def\currentmarkupstyle{#1}%
2694 \markupstylesetup
2695}
2696
2697\let\markupstylesetup\empty
2698
2699\def\defmarkupstylesetup#1{%
2700 \expandafter\def\expandafter\markupstylesetup
2701 \expandafter{\markupstylesetup #1}%
2702 \def#1%
2703}
2704
2705% Markup style setup for left and right quotes.
2706\defmarkupstylesetup\markupsetuplq{%
2707 \expandafter\let\expandafter \temp
2708 \csname markupsetuplq\currentmarkupstyle\endcsname
2709 \ifx\temp\relax \markupsetuplqdefault \else \temp \fi
2710}
2711
2712\defmarkupstylesetup\markupsetuprq{%
2713 \expandafter\let\expandafter \temp
2714 \csname markupsetuprq\currentmarkupstyle\endcsname
2715 \ifx\temp\relax \markupsetuprqdefault \else \temp \fi
2716}
2717
2718{
2719\catcode`\'=\active
2720\catcode`\`=\active
2721
2722\gdef\markupsetuplqdefault{\let`\lq}
2723\gdef\markupsetuprqdefault{\let'\rq}
2724
2725\gdef\markupsetcodequoteleft{\let`\codequoteleft}
2726\gdef\markupsetcodequoteright{\let'\codequoteright}
2727}
2728
2729\let\markupsetuplqcode \markupsetcodequoteleft
2730\let\markupsetuprqcode \markupsetcodequoteright
2731%
2732\let\markupsetuplqexample \markupsetcodequoteleft
2733\let\markupsetuprqexample \markupsetcodequoteright
2734%
2735\let\markupsetuplqkbd \markupsetcodequoteleft
2736\let\markupsetuprqkbd \markupsetcodequoteright
2737%
2738\let\markupsetuplqsamp \markupsetcodequoteleft
2739\let\markupsetuprqsamp \markupsetcodequoteright
2740%
2741\let\markupsetuplqverb \markupsetcodequoteleft
2742\let\markupsetuprqverb \markupsetcodequoteright
2743%
2744\let\markupsetuplqverbatim \markupsetcodequoteleft
2745\let\markupsetuprqverbatim \markupsetcodequoteright
2746
2747% Allow an option to not use regular directed right quote/apostrophe
2748% (char 0x27), but instead the undirected quote from cmtt (char 0x0d).
2749% The undirected quote is ugly, so don't make it the default, but it
2750% works for pasting with more pdf viewers (at least evince), the
2751% lilypond developers report. xpdf does work with the regular 0x27.
2752%
2753\def\codequoteright{%
2754 \ifmonospace
2755 \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax
2756 \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax
2757 '%
2758 \else \char'15 \fi
2759 \else \char'15 \fi
2760 \else
2761 '%
2762 \fi
2763}
2764%
2765% and a similar option for the left quote char vs. a grave accent.
2766% Modern fonts display ASCII 0x60 as a grave accent, so some people like
2767% the code environments to do likewise.
2768%
2769\def\codequoteleft{%
2770 \ifmonospace
2771 \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax
2772 \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax
2773 % [Knuth] pp. 380,381,391
2774 % \relax disables Spanish ligatures ?` and !` of \tt font.
2775 \relax`%
2776 \else \char'22 \fi
2777 \else \char'22 \fi
2778 \else
2779 \relax`%
2780 \fi
2781}
2782
2783% Commands to set the quote options.
2784%
2785\parseargdef\codequoteundirected{%
2786 \def\temp{#1}%
2787 \ifx\temp\onword
2788 \expandafter\let\csname SETtxicodequoteundirected\endcsname
2789 = t%
2790 \else\ifx\temp\offword
2791 \expandafter\let\csname SETtxicodequoteundirected\endcsname
2792 = \relax
2793 \else
2794 \errhelp = \EMsimple
2795 \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}%
2796 \fi\fi
2797}
2798%
2799\parseargdef\codequotebacktick{%
2800 \def\temp{#1}%
2801 \ifx\temp\onword
2802 \expandafter\let\csname SETtxicodequotebacktick\endcsname
2803 = t%
2804 \else\ifx\temp\offword
2805 \expandafter\let\csname SETtxicodequotebacktick\endcsname
2806 = \relax
2807 \else
2808 \errhelp = \EMsimple
2809 \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}%
2810 \fi\fi
2811}
2812
2813% [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font.
2814\def\noligaturesquoteleft{\relax\lq}
2815
2816% Count depth in font-changes, for error checks
2817\newcount\fontdepth \fontdepth=0
2818
2819% Font commands.
2820
2821% #1 is the font command (\sl or \it), #2 is the text to slant.
2822% If we are in a monospaced environment, however, 1) always use \ttsl,
2823% and 2) do not add an italic correction.
2824\def\dosmartslant#1#2{%
2825 \ifusingtt
2826 {{\ttsl #2}\let\next=\relax}%
2827 {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}%
2828 \next
2829}
2830\def\smartslanted{\dosmartslant\sl}
2831\def\smartitalic{\dosmartslant\it}
2832
2833% Output an italic correction unless \next (presumed to be the following
2834% character) is such as not to need one.
2835\def\smartitaliccorrection{%
2836 \ifx\next,%
2837 \else\ifx\next-%
2838 \else\ifx\next.%
2839 \else\ifx\next\.%
2840 \else\ifx\next\comma%
2841 \else\ptexslash
2842 \fi\fi\fi\fi\fi
2843 \aftersmartic
2844}
2845
2846% Unconditional use \ttsl, and no ic. @var is set to this for defuns.
2847\def\ttslanted#1{{\ttsl #1}}
2848
2849% @cite is like \smartslanted except unconditionally use \sl. We never want
2850% ttsl for book titles, do we?
2851\def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection}
2852
2853\def\aftersmartic{}
2854\def\var#1{%
2855 \let\saveaftersmartic = \aftersmartic
2856 \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}%
2857 \smartslanted{#1}%
2858}
2859
2860\let\i=\smartitalic
2861\let\slanted=\smartslanted
2862\let\dfn=\smartslanted
2863\let\emph=\smartitalic
2864
2865% Explicit font changes: @r, @sc, undocumented @ii.
2866\def\r#1{{\rm #1}} % roman font
2867\def\sc#1{{\smallcaps#1}} % smallcaps font
2868\def\ii#1{{\it #1}} % italic font
2869
2870% @b, explicit bold. Also @strong.
2871\def\b#1{{\bf #1}}
2872\let\strong=\b
2873
2874% @sansserif, explicit sans.
2875\def\sansserif#1{{\sf #1}}
2876
2877% We can't just use \exhyphenpenalty, because that only has effect at
2878% the end of a paragraph. Restore normal hyphenation at the end of the
2879% group within which \nohyphenation is presumably called.
2880%
2881\def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation}
2882\def\restorehyphenation{\hyphenchar\font = `- }
2883
2884% Set sfcode to normal for the chars that usually have another value.
2885% Can't use plain's \frenchspacing because it uses the `\x notation, and
2886% sometimes \x has an active definition that messes things up.
2887%
2888\catcode`@=11
2889 \def\plainfrenchspacing{%
2890 \sfcode`\.=\@m \sfcode`\?=\@m \sfcode`\!=\@m
2891 \sfcode`\:=\@m \sfcode`\;=\@m \sfcode`\,=\@m
2892 \def\endofsentencespacefactor{1000}% for @. and friends
2893 }
2894 \def\plainnonfrenchspacing{%
2895 \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000
2896 \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250
2897 \def\endofsentencespacefactor{3000}% for @. and friends
2898 }
2899\catcode`@=\other
2900\def\endofsentencespacefactor{3000}% default
2901
2902% @t, explicit typewriter.
2903\def\t#1{%
2904 {\tt \plainfrenchspacing #1}%
2905 \null
2906}
2907
2908% @samp.
2909\def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}}
2910
2911% @indicateurl is \samp, that is, with quotes.
2912\let\indicateurl=\samp
2913
2914% @code (and similar) prints in typewriter, but with spaces the same
2915% size as normal in the surrounding text, without hyphenation, etc.
2916% This is a subroutine for that.
2917\def\tclose#1{%
2918 {%
2919 % Change normal interword space to be same as for the current font.
2920 \spaceskip = \fontdimen2\font
2921 %
2922 % Switch to typewriter.
2923 \tt
2924 %
2925 % But `\ ' produces the large typewriter interword space.
2926 \def\ {{\spaceskip = 0pt{} }}%
2927 %
2928 % Turn off hyphenation.
2929 \nohyphenation
2930 %
2931 \plainfrenchspacing
2932 #1%
2933 }%
2934 \null % reset spacefactor to 1000
2935}
2936
2937% We *must* turn on hyphenation at `-' and `_' in @code.
2938% (But see \codedashfinish below.)
2939% Otherwise, it is too hard to avoid overfull hboxes
2940% in the Emacs manual, the Library manual, etc.
2941%
2942% Unfortunately, TeX uses one parameter (\hyphenchar) to control
2943% both hyphenation at - and hyphenation within words.
2944% We must therefore turn them both off (\tclose does that)
2945% and arrange explicitly to hyphenate at a dash. -- rms.
2946{
2947 \catcode`\-=\active \catcode`\_=\active
2948 \catcode`\'=\active \catcode`\`=\active
2949 \global\let'=\rq \global\let`=\lq % default definitions
2950 %
2951 \global\def\code{\begingroup
2952 \setupmarkupstyle{code}%
2953 % The following should really be moved into \setupmarkupstyle handlers.
2954 \catcode\dashChar=\active \catcode\underChar=\active
2955 \ifallowcodebreaks
2956 \let-\codedash
2957 \let_\codeunder
2958 \else
2959 \let-\normaldash
2960 \let_\realunder
2961 \fi
2962 % Given -foo (with a single dash), we do not want to allow a break
2963 % after the hyphen.
2964 \global\let\codedashprev=\codedash
2965 %
2966 \codex
2967 }
2968 %
2969 \gdef\codedash{\futurelet\next\codedashfinish}
2970 \gdef\codedashfinish{%
2971 \normaldash % always output the dash character itself.
2972 %
2973 % Now, output a discretionary to allow a line break, unless
2974 % (a) the next character is a -, or
2975 % (b) the preceding character is a -.
2976 % E.g., given --posix, we do not want to allow a break after either -.
2977 % Given --foo-bar, we do want to allow a break between the - and the b.
2978 \ifx\next\codedash \else
2979 \ifx\codedashprev\codedash
2980 \else \discretionary{}{}{}\fi
2981 \fi
2982 % we need the space after the = for the case when \next itself is a
2983 % space token; it would get swallowed otherwise. As in @code{- a}.
2984 \global\let\codedashprev= \next
2985 }
2986}
2987\def\normaldash{-}
2988%
2989\def\codex #1{\tclose{#1}\endgroup}
2990
2991\def\codeunder{%
2992 % this is all so @math{@code{var_name}+1} can work. In math mode, _
2993 % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.)
2994 % will therefore expand the active definition of _, which is us
2995 % (inside @code that is), therefore an endless loop.
2996 \ifusingtt{\ifmmode
2997 \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_.
2998 \else\normalunderscore \fi
2999 \discretionary{}{}{}}%
3000 {\_}%
3001}
3002
3003% An additional complication: the above will allow breaks after, e.g.,
3004% each of the four underscores in __typeof__. This is bad.
3005% @allowcodebreaks provides a document-level way to turn breaking at -
3006% and _ on and off.
3007%
3008\newif\ifallowcodebreaks \allowcodebreakstrue
3009
3010\def\keywordtrue{true}
3011\def\keywordfalse{false}
3012
3013\parseargdef\allowcodebreaks{%
3014 \def\txiarg{#1}%
3015 \ifx\txiarg\keywordtrue
3016 \allowcodebreakstrue
3017 \else\ifx\txiarg\keywordfalse
3018 \allowcodebreaksfalse
3019 \else
3020 \errhelp = \EMsimple
3021 \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}%
3022 \fi\fi
3023}
3024
3025% For @command, @env, @file, @option quotes seem unnecessary,
3026% so use \code rather than \samp.
3027\let\command=\code
3028\let\env=\code
3029\let\file=\code
3030\let\option=\code
3031
3032% @uref (abbreviation for `urlref') aka @url takes an optional
3033% (comma-separated) second argument specifying the text to display and
3034% an optional third arg as text to display instead of (rather than in
3035% addition to) the url itself. First (mandatory) arg is the url.
3036
3037% TeX-only option to allow changing PDF output to show only the second
3038% arg (if given), and not the url (which is then just the link target).
3039\newif\ifurefurlonlylink
3040
3041% The default \pretolerance setting stops the penalty inserted in
3042% \urefallowbreak being a discouragement to line breaking. Set it to
3043% a negative value for this paragraph only. Hopefully this does not
3044% conflict with redefinitions of \par done elsewhere.
3045\def\nopretolerance{%
3046\pretolerance=-1
3047\def\par{\endgraf\pretolerance=100 \let\par\endgraf}%
3048}
3049
3050% The main macro is \urefbreak, which allows breaking at expected
3051% places within the url.
3052\def\urefbreak{\nopretolerance \begingroup \urefcatcodes \dourefbreak}
3053\let\uref=\urefbreak
3054%
3055\def\dourefbreak#1{\urefbreakfinish #1,,,\finish}
3056\def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example
3057 \unsepspaces
3058 \pdfurl{#1}%
3059 \setbox0 = \hbox{\ignorespaces #3}%
3060 \ifdim\wd0 > 0pt
3061 \unhbox0 % third arg given, show only that
3062 \else
3063 \setbox0 = \hbox{\ignorespaces #2}% look for second arg
3064 \ifdim\wd0 > 0pt
3065 \ifpdf
3066 % For pdfTeX and LuaTeX
3067 \ifurefurlonlylink
3068 % PDF plus option to not display url, show just arg
3069 \unhbox0
3070 \else
3071 % PDF, normally display both arg and url for consistency,
3072 % visibility, if the pdf is eventually used to print, etc.
3073 \unhbox0\ (\urefcode{#1})%
3074 \fi
3075 \else
3076 \ifx\XeTeXrevision\thisisundefined
3077 \unhbox0\ (\urefcode{#1})% DVI, always show arg and url
3078 \else
3079 % For XeTeX
3080 \ifurefurlonlylink
3081 % PDF plus option to not display url, show just arg
3082 \unhbox0
3083 \else
3084 % PDF, normally display both arg and url for consistency,
3085 % visibility, if the pdf is eventually used to print, etc.
3086 \unhbox0\ (\urefcode{#1})%
3087 \fi
3088 \fi
3089 \fi
3090 \else
3091 \urefcode{#1}% only url given, so show it
3092 \fi
3093 \fi
3094 \endlink
3095\endgroup}
3096
3097% Allow line breaks around only a few characters (only).
3098\def\urefcatcodes{%
3099 \catcode`\&=\active \catcode`\.=\active
3100 \catcode`\#=\active \catcode`\?=\active
3101 \catcode`\/=\active
3102}
3103{
3104 \urefcatcodes
3105 %
3106 \global\def\urefcode{\begingroup
3107 \setupmarkupstyle{code}%
3108 \urefcatcodes
3109 \let&\urefcodeamp
3110 \let.\urefcodedot
3111 \let#\urefcodehash
3112 \let?\urefcodequest
3113 \let/\urefcodeslash
3114 \codex
3115 }
3116 %
3117 % By default, they are just regular characters.
3118 \global\def&{\normalamp}
3119 \global\def.{\normaldot}
3120 \global\def#{\normalhash}
3121 \global\def?{\normalquest}
3122 \global\def/{\normalslash}
3123}
3124
3125\def\urefcodeamp{\urefprebreak \&\urefpostbreak}
3126\def\urefcodedot{\urefprebreak .\urefpostbreak}
3127\def\urefcodehash{\urefprebreak \#\urefpostbreak}
3128\def\urefcodequest{\urefprebreak ?\urefpostbreak}
3129\def\urefcodeslash{\futurelet\next\urefcodeslashfinish}
3130{
3131 \catcode`\/=\active
3132 \global\def\urefcodeslashfinish{%
3133 \urefprebreak \slashChar
3134 % Allow line break only after the final / in a sequence of
3135 % slashes, to avoid line break between the slashes in http://.
3136 \ifx\next/\else \urefpostbreak \fi
3137 }
3138}
3139
3140% By default we'll break after the special characters, but some people like to
3141% break before the special chars, so allow that. Also allow no breaking at
3142% all, for manual control.
3143%
3144\parseargdef\urefbreakstyle{%
3145 \def\txiarg{#1}%
3146 \ifx\txiarg\wordnone
3147 \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak}
3148 \else\ifx\txiarg\wordbefore
3149 \def\urefprebreak{\urefallowbreak}\def\urefpostbreak{\nobreak}
3150 \else\ifx\txiarg\wordafter
3151 \def\urefprebreak{\nobreak}\def\urefpostbreak{\urefallowbreak}
3152 \else
3153 \errhelp = \EMsimple
3154 \errmessage{Unknown @urefbreakstyle setting `\txiarg'}%
3155 \fi\fi\fi
3156}
3157\def\wordafter{after}
3158\def\wordbefore{before}
3159\def\wordnone{none}
3160
3161% Allow a ragged right output to aid breaking long URL's. There can
3162% be a break at the \allowbreak with no extra glue (if the existing stretch in
3163% the line is sufficient), a break at the \penalty with extra glue added
3164% at the end of the line, or no break at all here.
3165% Changing the value of the penalty and/or the amount of stretch affects how
3166% preferable one choice is over the other.
3167\def\urefallowbreak{%
3168 \penalty0\relax
3169 \hskip 0pt plus 2 em\relax
3170 \penalty1000\relax
3171 \hskip 0pt plus -2 em\relax
3172}
3173
3174\urefbreakstyle after
3175
3176% @url synonym for @uref, since that's how everyone uses it.
3177%
3178\let\url=\uref
3179
3180% rms does not like angle brackets --karl, 17may97.
3181% So now @email is just like @uref, unless we are pdf.
3182%
3183%\def\email#1{\angleleft{\tt #1}\angleright}
3184\ifpdforxetex
3185 \def\email#1{\doemail#1,,\finish}
3186 \def\doemail#1,#2,#3\finish{\begingroup
3187 \unsepspaces
3188 \pdfurl{mailto:#1}%
3189 \setbox0 = \hbox{\ignorespaces #2}%
3190 \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
3191 \endlink
3192 \endgroup}
3193\else
3194 \let\email=\uref
3195\fi
3196
3197% @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
3198% `example' (@kbd uses ttsl only inside of @example and friends),
3199% or `code' (@kbd uses normal tty font always).
3200\parseargdef\kbdinputstyle{%
3201 \def\txiarg{#1}%
3202 \ifx\txiarg\worddistinct
3203 \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
3204 \else\ifx\txiarg\wordexample
3205 \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
3206 \else\ifx\txiarg\wordcode
3207 \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
3208 \else
3209 \errhelp = \EMsimple
3210 \errmessage{Unknown @kbdinputstyle setting `\txiarg'}%
3211 \fi\fi\fi
3212}
3213\def\worddistinct{distinct}
3214\def\wordexample{example}
3215\def\wordcode{code}
3216
3217% Default is `distinct'.
3218\kbdinputstyle distinct
3219
3220% @kbd is like @code, except that if the argument is just one @key command,
3221% then @kbd has no effect.
3222\def\kbd#1{{\def\look{#1}\expandafter\kbdsub\look??\par}}
3223
3224\def\xkey{\key}
3225\def\kbdsub#1#2#3\par{%
3226 \def\one{#1}\def\three{#3}\def\threex{??}%
3227 \ifx\one\xkey\ifx\threex\three \key{#2}%
3228 \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
3229 \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
3230}
3231
3232% definition of @key that produces a lozenge. Doesn't adjust to text size.
3233%\setfont\keyrm\rmshape{8}{1000}{OT1}
3234%\font\keysy=cmsy9
3235%\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
3236% \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
3237% \vbox{\hrule\kern-0.4pt
3238% \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
3239% \kern-0.4pt\hrule}%
3240% \kern-.06em\raise0.4pt\hbox{\angleright}}}}
3241
3242% definition of @key with no lozenge. If the current font is already
3243% monospace, don't change it; that way, we respect @kbdinputstyle. But
3244% if it isn't monospace, then use \tt.
3245%
3246\def\key#1{{\setupmarkupstyle{key}%
3247 \nohyphenation
3248 \ifmonospace\else\tt\fi
3249 #1}\null}
3250
3251% @clicksequence{File @click{} Open ...}
3252\def\clicksequence#1{\begingroup #1\endgroup}
3253
3254% @clickstyle @arrow (by default)
3255\parseargdef\clickstyle{\def\click{#1}}
3256\def\click{\arrow}
3257
3258% Typeset a dimension, e.g., `in' or `pt'. The only reason for the
3259% argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
3260%
3261\def\dmn#1{\thinspace #1}
3262
3263% @acronym for "FBI", "NATO", and the like.
3264% We print this one point size smaller, since it's intended for
3265% all-uppercase.
3266%
3267\def\acronym#1{\doacronym #1,,\finish}
3268\def\doacronym#1,#2,#3\finish{%
3269 {\switchtolsize #1}%
3270 \def\temp{#2}%
3271 \ifx\temp\empty \else
3272 \space ({\unsepspaces \ignorespaces \temp \unskip})%
3273 \fi
3274 \null % reset \spacefactor=1000
3275}
3276
3277% @abbr for "Comput. J." and the like.
3278% No font change, but don't do end-of-sentence spacing.
3279%
3280\def\abbr#1{\doabbr #1,,\finish}
3281\def\doabbr#1,#2,#3\finish{%
3282 {\plainfrenchspacing #1}%
3283 \def\temp{#2}%
3284 \ifx\temp\empty \else
3285 \space ({\unsepspaces \ignorespaces \temp \unskip})%
3286 \fi
3287 \null % reset \spacefactor=1000
3288}
3289
3290% @asis just yields its argument. Used with @table, for example.
3291%
3292\def\asis#1{#1}
3293
3294% @math outputs its argument in math mode.
3295%
3296% One complication: _ usually means subscripts, but it could also mean
3297% an actual _ character, as in @math{@var{some_variable} + 1}. So make
3298% _ active, and distinguish by seeing if the current family is \slfam,
3299% which is what @var uses.
3300{
3301 \catcode`\_ = \active
3302 \gdef\mathunderscore{%
3303 \catcode`\_=\active
3304 \def_{\ifnum\fam=\slfam \_\else\sb\fi}%
3305 }
3306}
3307% Another complication: we want \\ (and @\) to output a math (or tt) \.
3308% FYI, plain.tex uses \\ as a temporary control sequence (for no
3309% particular reason), but this is not advertised and we don't care.
3310%
3311% The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\.
3312\def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi}
3313%
3314\def\math{%
3315 \ifmmode\else % only go into math if not in math mode already
3316 \tex
3317 \mathunderscore
3318 \let\\ = \mathbackslash
3319 \mathactive
3320 % make the texinfo accent commands work in math mode
3321 \let\"=\ddot
3322 \let\'=\acute
3323 \let\==\bar
3324 \let\^=\hat
3325 \let\`=\grave
3326 \let\u=\breve
3327 \let\v=\check
3328 \let\~=\tilde
3329 \let\dotaccent=\dot
3330 % have to provide another name for sup operator
3331 \let\mathopsup=\sup
3332 $\expandafter\finishmath\fi
3333}
3334\def\finishmath#1{#1$\endgroup} % Close the group opened by \tex.
3335
3336% Some active characters (such as <) are spaced differently in math.
3337% We have to reset their definitions in case the @math was an argument
3338% to a command which sets the catcodes (such as @item or @section).
3339%
3340{
3341 \catcode`^ = \active
3342 \catcode`< = \active
3343 \catcode`> = \active
3344 \catcode`+ = \active
3345 \catcode`' = \active
3346 \gdef\mathactive{%
3347 \let^ = \ptexhat
3348 \let< = \ptexless
3349 \let> = \ptexgtr
3350 \let+ = \ptexplus
3351 \let' = \ptexquoteright
3352 }
3353}
3354
3355% for @sub and @sup, if in math mode, just do a normal sub/superscript.
3356% If in text, use math to place as sub/superscript, but switch
3357% into text mode, with smaller fonts. This is a different font than the
3358% one used for real math sub/superscripts (8pt vs. 7pt), but let's not
3359% fix it (significant additions to font machinery) until someone notices.
3360%
3361\def\sub{\ifmmode \expandafter\sb \else \expandafter\finishsub\fi}
3362\def\finishsub#1{$\sb{\hbox{\switchtolllsize #1}}$}%
3363%
3364\def\sup{\ifmmode \expandafter\ptexsp \else \expandafter\finishsup\fi}
3365\def\finishsup#1{$\ptexsp{\hbox{\switchtolllsize #1}}$}%
3366
3367% provide this command from LaTeX as it is very common
3368\def\frac#1#2{{{#1}\over{#2}}}
3369
3370% @displaymath.
3371% \globaldefs is needed to recognize the end lines in \tex and
3372% \end tex. Set \thisenv as @end displaymath is seen before @end tex.
3373{\obeylines
3374\globaldefs=1
3375\envdef\displaymath{%
3376\tex
3377\def\thisenv{\displaymath}%
3378$$%
3379}
3380
3381\def\Edisplaymath{$$
3382\def\thisenv{\tex}%
3383\end tex
3384}}
3385
3386% @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}.
3387% Ignore unless FMTNAME == tex; then it is like @iftex and @tex,
3388% except specified as a normal braced arg, so no newlines to worry about.
3389%
3390\def\outfmtnametex{tex}
3391%
3392\long\def\inlinefmt#1{\doinlinefmt #1,\finish}
3393\long\def\doinlinefmt#1,#2,\finish{%
3394 \def\inlinefmtname{#1}%
3395 \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi
3396}
3397%
3398% @inlinefmtifelse{FMTNAME,THEN-TEXT,ELSE-TEXT} expands THEN-TEXT if
3399% FMTNAME is tex, else ELSE-TEXT.
3400\long\def\inlinefmtifelse#1{\doinlinefmtifelse #1,,,\finish}
3401\long\def\doinlinefmtifelse#1,#2,#3,#4,\finish{%
3402 \def\inlinefmtname{#1}%
3403 \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\else \ignorespaces #3\fi
3404}
3405%
3406% For raw, must switch into @tex before parsing the argument, to avoid
3407% setting catcodes prematurely. Doing it this way means that, for
3408% example, @inlineraw{html, foo{bar} gets a parse error instead of being
3409% ignored. But this isn't important because if people want a literal
3410% *right* brace they would have to use a command anyway, so they may as
3411% well use a command to get a left brace too. We could re-use the
3412% delimiter character idea from \verb, but it seems like overkill.
3413%
3414\long\def\inlineraw{\tex \doinlineraw}
3415\long\def\doinlineraw#1{\doinlinerawtwo #1,\finish}
3416\def\doinlinerawtwo#1,#2,\finish{%
3417 \def\inlinerawname{#1}%
3418 \ifx\inlinerawname\outfmtnametex \ignorespaces #2\fi
3419 \endgroup % close group opened by \tex.
3420}
3421
3422% @inlineifset{VAR, TEXT} expands TEXT if VAR is @set.
3423%
3424\long\def\inlineifset#1{\doinlineifset #1,\finish}
3425\long\def\doinlineifset#1,#2,\finish{%
3426 \def\inlinevarname{#1}%
3427 \expandafter\ifx\csname SET\inlinevarname\endcsname\relax
3428 \else\ignorespaces#2\fi
3429}
3430
3431% @inlineifclear{VAR, TEXT} expands TEXT if VAR is not @set.
3432%
3433\long\def\inlineifclear#1{\doinlineifclear #1,\finish}
3434\long\def\doinlineifclear#1,#2,\finish{%
3435 \def\inlinevarname{#1}%
3436 \expandafter\ifx\csname SET\inlinevarname\endcsname\relax \ignorespaces#2\fi
3437}
3438
3439
3440\message{glyphs,}
3441% and logos.
3442
3443% @@ prints an @, as does @atchar{}.
3444\def\@{\char64 }
3445\let\atchar=\@
3446
3447% @{ @} @lbracechar{} @rbracechar{} all generate brace characters.
3448\def\lbracechar{{\ifmonospace\char123\else\ensuremath\lbrace\fi}}
3449\def\rbracechar{{\ifmonospace\char125\else\ensuremath\rbrace\fi}}
3450\let\{=\lbracechar
3451\let\}=\rbracechar
3452
3453% @comma{} to avoid , parsing problems.
3454\let\comma = ,
3455
3456% Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
3457% Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H.
3458\let\, = \ptexc
3459\let\dotaccent = \ptexdot
3460\def\ringaccent#1{{\accent23 #1}}
3461\let\tieaccent = \ptext
3462\let\ubaraccent = \ptexb
3463\let\udotaccent = \d
3464
3465% Other special characters: @questiondown @exclamdown @ordf @ordm
3466% Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss.
3467\def\questiondown{?`}
3468\def\exclamdown{!`}
3469\def\ordf{\leavevmode\raise1ex\hbox{\switchtolllsize \underbar{a}}}
3470\def\ordm{\leavevmode\raise1ex\hbox{\switchtolllsize \underbar{o}}}
3471
3472% Dotless i and dotless j, used for accents.
3473\def\imacro{i}
3474\def\jmacro{j}
3475\def\dotless#1{%
3476 \def\temp{#1}%
3477 \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi
3478 \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi
3479 \else \errmessage{@dotless can be used only with i or j}%
3480 \fi\fi
3481}
3482
3483% The \TeX{} logo, as in plain, but resetting the spacing so that a
3484% period following counts as ending a sentence. (Idea found in latex.)
3485%
3486\edef\TeX{\TeX \spacefactor=1000 }
3487
3488% @LaTeX{} logo. Not quite the same results as the definition in
3489% latex.ltx, since we use a different font for the raised A; it's most
3490% convenient for us to use an explicitly smaller font, rather than using
3491% the \scriptstyle font (since we don't reset \scriptstyle and
3492% \scriptscriptstyle).
3493%
3494\def\LaTeX{%
3495 L\kern-.36em
3496 {\setbox0=\hbox{T}%
3497 \vbox to \ht0{\hbox{%
3498 \ifx\textnominalsize\xwordpt
3499 % for 10pt running text, lllsize (8pt) is too small for the A in LaTeX.
3500 % Revert to plain's \scriptsize, which is 7pt.
3501 \count255=\the\fam $\fam\count255 \scriptstyle A$%
3502 \else
3503 % For 11pt, we can use our lllsize.
3504 \switchtolllsize A%
3505 \fi
3506 }%
3507 \vss
3508 }}%
3509 \kern-.15em
3510 \TeX
3511}
3512
3513% Some math mode symbols. Define \ensuremath to switch into math mode
3514% unless we are already there. Expansion tricks may not be needed here,
3515% but safer, and can't hurt.
3516\def\ensuremath{\ifmmode \expandafter\asis \else\expandafter\ensuredmath \fi}
3517\def\ensuredmath#1{$\relax#1$}
3518%
3519\def\bullet{\ensuremath\ptexbullet}
3520\def\geq{\ensuremath\ge}
3521\def\leq{\ensuremath\le}
3522\def\minus{\ensuremath-}
3523
3524% @dots{} outputs an ellipsis using the current font.
3525% We do .5em per period so that it has the same spacing in the cm
3526% typewriter fonts as three actual period characters; on the other hand,
3527% in other typewriter fonts three periods are wider than 1.5em. So do
3528% whichever is larger.
3529%
3530\def\dots{%
3531 \leavevmode
3532 \setbox0=\hbox{...}% get width of three periods
3533 \ifdim\wd0 > 1.5em
3534 \dimen0 = \wd0
3535 \else
3536 \dimen0 = 1.5em
3537 \fi
3538 \hbox to \dimen0{%
3539 \hskip 0pt plus.25fil
3540 .\hskip 0pt plus1fil
3541 .\hskip 0pt plus1fil
3542 .\hskip 0pt plus.5fil
3543 }%
3544}
3545
3546% @enddots{} is an end-of-sentence ellipsis.
3547%
3548\def\enddots{%
3549 \dots
3550 \spacefactor=\endofsentencespacefactor
3551}
3552
3553% @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
3554%
3555% Since these characters are used in examples, they should be an even number of
3556% \tt widths. Each \tt character is 1en, so two makes it 1em.
3557%
3558\def\point{$\star$}
3559\def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}}
3560\def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
3561\def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}}
3562\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
3563\def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}}
3564
3565% The @error{} command.
3566% Adapted from the TeXbook's \boxit.
3567%
3568\newbox\errorbox
3569%
3570{\ttfont \global\dimen0 = 3em}% Width of the box.
3571\dimen2 = .55pt % Thickness of rules
3572% The text. (`r' is open on the right, `e' somewhat less so on the left.)
3573\setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt}
3574%
3575\setbox\errorbox=\hbox to \dimen0{\hfil
3576 \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
3577 \advance\hsize by -2\dimen2 % Rules.
3578 \vbox{%
3579 \hrule height\dimen2
3580 \hbox{\vrule width\dimen2 \kern3pt % Space to left of text.
3581 \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
3582 \kern3pt\vrule width\dimen2}% Space to right.
3583 \hrule height\dimen2}
3584 \hfil}
3585%
3586\def\error{\leavevmode\lower.7ex\copy\errorbox}
3587
3588% @pounds{} is a sterling sign, which Knuth put in the CM italic font.
3589%
3590\def\pounds{\ifmonospace{\ecfont\char"BF}\else{\it\$}\fi}
3591
3592% @euro{} comes from a separate font, depending on the current style.
3593% We use the free feym* fonts from the eurosym package by Henrik
3594% Theiling, which support regular, slanted, bold and bold slanted (and
3595% "outlined" (blackboard board, sort of) versions, which we don't need).
3596% It is available from http://www.ctan.org/tex-archive/fonts/eurosym.
3597%
3598% Although only regular is the truly official Euro symbol, we ignore
3599% that. The Euro is designed to be slightly taller than the regular
3600% font height.
3601%
3602% feymr - regular
3603% feymo - slanted
3604% feybr - bold
3605% feybo - bold slanted
3606%
3607% There is no good (free) typewriter version, to my knowledge.
3608% A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide.
3609% Hmm.
3610%
3611% Also doesn't work in math. Do we need to do math with euro symbols?
3612% Hope not.
3613%
3614%
3615\def\euro{{\eurofont e}}
3616\def\eurofont{%
3617 % We set the font at each command, rather than predefining it in
3618 % \textfonts and the other font-switching commands, so that
3619 % installations which never need the symbol don't have to have the
3620 % font installed.
3621 %
3622 % There is only one designed size (nominal 10pt), so we always scale
3623 % that to the current nominal size.
3624 %
3625 % By the way, simply using "at 1em" works for cmr10 and the like, but
3626 % does not work for cmbx10 and other extended/shrunken fonts.
3627 %
3628 \def\eurosize{\csname\curfontsize nominalsize\endcsname}%
3629 %
3630 \ifx\curfontstyle\bfstylename
3631 % bold:
3632 \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize
3633 \else
3634 % regular:
3635 \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize
3636 \fi
3637 \thiseurofont
3638}
3639
3640% Glyphs from the EC fonts. We don't use \let for the aliases, because
3641% sometimes we redefine the original macro, and the alias should reflect
3642% the redefinition.
3643%
3644% Use LaTeX names for the Icelandic letters.
3645\def\DH{{\ecfont \char"D0}} % Eth
3646\def\dh{{\ecfont \char"F0}} % eth
3647\def\TH{{\ecfont \char"DE}} % Thorn
3648\def\th{{\ecfont \char"FE}} % thorn
3649%
3650\def\guillemetleft{{\ecfont \char"13}}
3651\def\guillemotleft{\guillemetleft}
3652\def\guillemetright{{\ecfont \char"14}}
3653\def\guillemotright{\guillemetright}
3654\def\guilsinglleft{{\ecfont \char"0E}}
3655\def\guilsinglright{{\ecfont \char"0F}}
3656\def\quotedblbase{{\ecfont \char"12}}
3657\def\quotesinglbase{{\ecfont \char"0D}}
3658%
3659% This positioning is not perfect (see the ogonek LaTeX package), but
3660% we have the precomposed glyphs for the most common cases. We put the
3661% tests to use those glyphs in the single \ogonek macro so we have fewer
3662% dummy definitions to worry about for index entries, etc.
3663%
3664% ogonek is also used with other letters in Lithuanian (IOU), but using
3665% the precomposed glyphs for those is not so easy since they aren't in
3666% the same EC font.
3667\def\ogonek#1{{%
3668 \def\temp{#1}%
3669 \ifx\temp\macrocharA\Aogonek
3670 \else\ifx\temp\macrochara\aogonek
3671 \else\ifx\temp\macrocharE\Eogonek
3672 \else\ifx\temp\macrochare\eogonek
3673 \else
3674 \ecfont \setbox0=\hbox{#1}%
3675 \ifdim\ht0=1ex\accent"0C #1%
3676 \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}%
3677 \fi
3678 \fi\fi\fi\fi
3679 }%
3680}
3681\def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A}
3682\def\aogonek{{\ecfont \char"A1}}\def\macrochara{a}
3683\def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E}
3684\def\eogonek{{\ecfont \char"A6}}\def\macrochare{e}
3685%
3686% Use the European Computer Modern fonts (cm-super in outline format)
3687% for non-CM glyphs. That is ec* for regular text and tc* for the text
3688% companion symbols (LaTeX TS1 encoding). Both are part of the ec
3689% package and follow the same conventions.
3690%
3691\def\ecfont{\etcfont{e}}
3692\def\tcfont{\etcfont{t}}
3693%
3694\def\etcfont#1{%
3695 % We can't distinguish serif/sans and italic/slanted, but this
3696 % is used for crude hacks anyway (like adding French and German
3697 % quotes to documents typeset with CM, where we lose kerning), so
3698 % hopefully nobody will notice/care.
3699 \edef\ecsize{\csname\curfontsize ecsize\endcsname}%
3700 \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}%
3701 \ifmonospace
3702 % typewriter:
3703 \font\thisecfont = #1ctt\ecsize \space at \nominalsize
3704 \else
3705 \ifx\curfontstyle\bfstylename
3706 % bold:
3707 \font\thisecfont = #1cb\ifusingit{i}{x}\ecsize \space at \nominalsize
3708 \else
3709 % regular:
3710 \font\thisecfont = #1c\ifusingit{ti}{rm}\ecsize \space at \nominalsize
3711 \fi
3712 \fi
3713 \thisecfont
3714}
3715
3716% @registeredsymbol - R in a circle. The font for the R should really
3717% be smaller yet, but lllsize is the best we can do for now.
3718% Adapted from the plain.tex definition of \copyright.
3719%
3720\def\registeredsymbol{%
3721 $^{{\ooalign{\hfil\raise.07ex\hbox{\switchtolllsize R}%
3722 \hfil\crcr\Orb}}%
3723 }$%
3724}
3725
3726% @textdegree - the normal degrees sign.
3727%
3728\def\textdegree{$^\circ$}
3729
3730% Laurent Siebenmann reports \Orb undefined with:
3731% Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38
3732% so we'll define it if necessary.
3733%
3734\ifx\Orb\thisisundefined
3735\def\Orb{\mathhexbox20D}
3736\fi
3737
3738% Quotes.
3739\chardef\quoteleft=`\`
3740\chardef\quoteright=`\'
3741
3742% only change font for tt for correct kerning and to avoid using
3743% \ecfont unless necessary.
3744\def\quotedblleft{%
3745 \ifmonospace{\ecfont\char"10}\else{\char"5C}\fi
3746}
3747
3748\def\quotedblright{%
3749 \ifmonospace{\ecfont\char"11}\else{\char`\"}\fi
3750}
3751
3752
3753\message{page headings,}
3754
3755\newskip\titlepagetopglue \titlepagetopglue = 1.5in
3756\newskip\titlepagebottomglue \titlepagebottomglue = 2pc
3757
3758% First the title page. Must do @settitle before @titlepage.
3759\newif\ifseenauthor
3760\newif\iffinishedtitlepage
3761
3762% @setcontentsaftertitlepage used to do an implicit @contents or
3763% @shortcontents after @end titlepage, but it is now obsolete.
3764\def\setcontentsaftertitlepage{%
3765 \errmessage{@setcontentsaftertitlepage has been removed as a Texinfo
3766 command; move your @contents command if you want the contents
3767 after the title page.}}%
3768\def\setshortcontentsaftertitlepage{%
3769 \errmessage{@setshortcontentsaftertitlepage has been removed as a Texinfo
3770 command; move your @shortcontents and @contents commands if you
3771 want the contents after the title page.}}%
3772
3773\parseargdef\shorttitlepage{%
3774 \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}%
3775 \endgroup\page\hbox{}\page}
3776
3777\envdef\titlepage{%
3778 % Open one extra group, as we want to close it in the middle of \Etitlepage.
3779 \begingroup
3780 \parindent=0pt \textfonts
3781 % Leave some space at the very top of the page.
3782 \vglue\titlepagetopglue
3783 % No rule at page bottom unless we print one at the top with @title.
3784 \finishedtitlepagetrue
3785 %
3786 % Most title ``pages'' are actually two pages long, with space
3787 % at the top of the second. We don't want the ragged left on the second.
3788 \let\oldpage = \page
3789 \def\page{%
3790 \iffinishedtitlepage\else
3791 \finishtitlepage
3792 \fi
3793 \let\page = \oldpage
3794 \page
3795 \null
3796 }%
3797}
3798
3799\def\Etitlepage{%
3800 \iffinishedtitlepage\else
3801 \finishtitlepage
3802 \fi
3803 % It is important to do the page break before ending the group,
3804 % because the headline and footline are only empty inside the group.
3805 % If we use the new definition of \page, we always get a blank page
3806 % after the title page, which we certainly don't want.
3807 \oldpage
3808 \endgroup
3809 %
3810 % Need this before the \...aftertitlepage checks so that if they are
3811 % in effect the toc pages will come out with page numbers.
3812 \HEADINGSon
3813}
3814
3815\def\finishtitlepage{%
3816 \vskip4pt \hrule height 2pt width \hsize
3817 \vskip\titlepagebottomglue
3818 \finishedtitlepagetrue
3819}
3820
3821% Settings used for typesetting titles: no hyphenation, no indentation,
3822% don't worry much about spacing, ragged right. This should be used
3823% inside a \vbox, and fonts need to be set appropriately first. \par should
3824% be specified before the end of the \vbox, since a vbox is a group.
3825%
3826\def\raggedtitlesettings{%
3827 \rm
3828 \hyphenpenalty=10000
3829 \parindent=0pt
3830 \tolerance=5000
3831 \ptexraggedright
3832}
3833
3834% Macros to be used within @titlepage:
3835
3836\let\subtitlerm=\rmfont
3837\def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}
3838
3839\parseargdef\title{%
3840 \checkenv\titlepage
3841 \vbox{\titlefonts \raggedtitlesettings #1\par}%
3842 % print a rule at the page bottom also.
3843 \finishedtitlepagefalse
3844 \vskip4pt \hrule height 4pt width \hsize \vskip4pt
3845}
3846
3847\parseargdef\subtitle{%
3848 \checkenv\titlepage
3849 {\subtitlefont \rightline{#1}}%
3850}
3851
3852% @author should come last, but may come many times.
3853% It can also be used inside @quotation.
3854%
3855\parseargdef\author{%
3856 \def\temp{\quotation}%
3857 \ifx\thisenv\temp
3858 \def\quotationauthor{#1}% printed in \Equotation.
3859 \else
3860 \checkenv\titlepage
3861 \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi
3862 {\secfonts\rm \leftline{#1}}%
3863 \fi
3864}
3865
3866
3867% Set up page headings and footings.
3868
3869\let\thispage=\folio
3870
3871\newtoks\evenheadline % headline on even pages
3872\newtoks\oddheadline % headline on odd pages
3873\newtoks\evenchapheadline% headline on even pages with a new chapter
3874\newtoks\oddchapheadline % headline on odd pages with a new chapter
3875\newtoks\evenfootline % footline on even pages
3876\newtoks\oddfootline % footline on odd pages
3877
3878% Now make \makeheadline and \makefootline in Plain TeX use those variables
3879\headline={{\textfonts\rm
3880 \ifchapterpage
3881 \ifodd\pageno\the\oddchapheadline\else\the\evenchapheadline\fi
3882 \else
3883 \ifodd\pageno\the\oddheadline\else\the\evenheadline\fi
3884 \fi}}
3885
3886\footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
3887 \else \the\evenfootline \fi}\HEADINGShook}
3888\let\HEADINGShook=\relax
3889
3890% Commands to set those variables.
3891% For example, this is what @headings on does
3892% @evenheading @thistitle|@thispage|@thischapter
3893% @oddheading @thischapter|@thispage|@thistitle
3894% @evenfooting @thisfile||
3895% @oddfooting ||@thisfile
3896
3897
3898\def\evenheading{\parsearg\evenheadingxxx}
3899\def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish}
3900\def\evenheadingyyy #1\|#2\|#3\|#4\finish{%
3901 \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}
3902 \global\evenchapheadline=\evenheadline}
3903
3904\def\oddheading{\parsearg\oddheadingxxx}
3905\def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish}
3906\def\oddheadingyyy #1\|#2\|#3\|#4\finish{%
3907 \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}%
3908 \global\oddchapheadline=\oddheadline}
3909
3910\parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
3911
3912\def\evenfooting{\parsearg\evenfootingxxx}
3913\def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish}
3914\def\evenfootingyyy #1\|#2\|#3\|#4\finish{%
3915\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
3916
3917\def\oddfooting{\parsearg\oddfootingxxx}
3918\def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish}
3919\def\oddfootingyyy #1\|#2\|#3\|#4\finish{%
3920 \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}%
3921 %
3922 % Leave some space for the footline. Hopefully ok to assume
3923 % @evenfooting will not be used by itself.
3924 \global\advance\txipageheight by -12pt
3925 \global\advance\vsize by -12pt
3926}
3927
3928\parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}}
3929
3930% @evenheadingmarks top \thischapter <- chapter at the top of a page
3931% @evenheadingmarks bottom \thischapter <- chapter at the bottom of a page
3932%
3933% The same set of arguments for:
3934%
3935% @oddheadingmarks
3936% @evenfootingmarks
3937% @oddfootingmarks
3938% @everyheadingmarks
3939% @everyfootingmarks
3940
3941% These define \getoddheadingmarks, \getevenheadingmarks,
3942% \getoddfootingmarks, and \getevenfootingmarks, each to one of
3943% \gettopheadingmarks, \getbottomheadingmarks.
3944%
3945\def\evenheadingmarks{\headingmarks{even}{heading}}
3946\def\oddheadingmarks{\headingmarks{odd}{heading}}
3947\def\evenfootingmarks{\headingmarks{even}{footing}}
3948\def\oddfootingmarks{\headingmarks{odd}{footing}}
3949\parseargdef\everyheadingmarks{\headingmarks{even}{heading}{#1}
3950 \headingmarks{odd}{heading}{#1} }
3951\parseargdef\everyfootingmarks{\headingmarks{even}{footing}{#1}
3952 \headingmarks{odd}{footing}{#1} }
3953% #1 = even/odd, #2 = heading/footing, #3 = top/bottom.
3954\def\headingmarks#1#2#3 {%
3955 \expandafter\let\expandafter\temp \csname get#3headingmarks\endcsname
3956 \global\expandafter\let\csname get#1#2marks\endcsname \temp
3957}
3958
3959\everyheadingmarks bottom
3960\everyfootingmarks bottom
3961
3962% @headings double turns headings on for double-sided printing.
3963% @headings single turns headings on for single-sided printing.
3964% @headings off turns them off.
3965% @headings on same as @headings double, retained for compatibility.
3966% @headings after turns on double-sided headings after this page.
3967% @headings doubleafter turns on double-sided headings after this page.
3968% @headings singleafter turns on single-sided headings after this page.
3969% By default, they are off at the start of a document,
3970% and turned `on' after @end titlepage.
3971
3972\parseargdef\headings{\csname HEADINGS#1\endcsname}
3973
3974\def\headingsoff{% non-global headings elimination
3975 \evenheadline={\hfil}\evenfootline={\hfil}\evenchapheadline={\hfil}%
3976 \oddheadline={\hfil}\oddfootline={\hfil}\oddchapheadline={\hfil}%
3977}
3978
3979\def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting
3980\HEADINGSoff % it's the default
3981
3982% When we turn headings on, set the page number to 1.
3983\def\pageone{
3984 \global\pageno=1
3985 \global\arabiccount = \pagecount
3986}
3987
3988% For double-sided printing, put current file name in lower left corner,
3989% chapter name on inside top of right hand pages, document
3990% title on inside top of left hand pages, and page numbers on outside top
3991% edge of all pages.
3992\def\HEADINGSdouble{%
3993\pageone
3994\HEADINGSdoublex
3995}
3996\let\contentsalignmacro = \chappager
3997
3998% For single-sided printing, chapter title goes across top left of page,
3999% page number on top right.
4000\def\HEADINGSsingle{%
4001\pageone
4002\HEADINGSsinglex
4003}
4004\def\HEADINGSon{\HEADINGSdouble}
4005
4006\def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
4007\let\HEADINGSdoubleafter=\HEADINGSafter
4008\def\HEADINGSdoublex{%
4009\global\evenfootline={\hfil}
4010\global\oddfootline={\hfil}
4011\global\evenheadline={\line{\folio\hfil\thistitle}}
4012\global\oddheadline={\line{\thischapter\hfil\folio}}
4013\global\evenchapheadline={\line{\folio\hfil}}
4014\global\oddchapheadline={\line{\hfil\folio}}
4015\global\let\contentsalignmacro = \chapoddpage
4016}
4017
4018\def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
4019\def\HEADINGSsinglex{%
4020\global\evenfootline={\hfil}
4021\global\oddfootline={\hfil}
4022\global\evenheadline={\line{\thischapter\hfil\folio}}
4023\global\oddheadline={\line{\thischapter\hfil\folio}}
4024\global\evenchapheadline={\line{\hfil\folio}}
4025\global\oddchapheadline={\line{\hfil\folio}}
4026\global\let\contentsalignmacro = \chappager
4027}
4028
4029% for @setchapternewpage off
4030\def\HEADINGSsinglechapoff{%
4031\pageone
4032\global\evenfootline={\hfil}
4033\global\oddfootline={\hfil}
4034\global\evenheadline={\line{\thischapter\hfil\folio}}
4035\global\oddheadline={\line{\thischapter\hfil\folio}}
4036\global\evenchapheadline=\evenheadline
4037\global\oddchapheadline=\oddheadline
4038\global\let\contentsalignmacro = \chappager
4039}
4040
4041% Subroutines used in generating headings
4042% This produces Day Month Year style of output.
4043% Only define if not already defined, in case a txi-??.tex file has set
4044% up a different format (e.g., txi-cs.tex does this).
4045\ifx\today\thisisundefined
4046\def\today{%
4047 \number\day\space
4048 \ifcase\month
4049 \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr
4050 \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug
4051 \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec
4052 \fi
4053 \space\number\year}
4054\fi
4055
4056% @settitle line... specifies the title of the document, for headings.
4057% It generates no output of its own.
4058\def\thistitle{\putwordNoTitle}
4059\def\settitle{\parsearg{\gdef\thistitle}}
4060
4061
4062\message{tables,}
4063% Tables -- @table, @ftable, @vtable, @item(x).
4064
4065% default indentation of table text
4066\newdimen\tableindent \tableindent=.8in
4067% default indentation of @itemize and @enumerate text
4068\newdimen\itemindent \itemindent=.3in
4069% margin between end of table item and start of table text.
4070\newdimen\itemmargin \itemmargin=.1in
4071
4072% used internally for \itemindent minus \itemmargin
4073\newdimen\itemmax
4074
4075% Note @table, @ftable, and @vtable define @item, @itemx, etc., with
4076% these defs.
4077% They also define \itemindex
4078% to index the item name in whatever manner is desired (perhaps none).
4079
4080\newif\ifitemxneedsnegativevskip
4081
4082\def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
4083
4084\def\internalBitem{\smallbreak \parsearg\itemzzz}
4085\def\internalBitemx{\itemxpar \parsearg\itemzzz}
4086
4087\def\itemzzz #1{\begingroup %
4088 \advance\hsize by -\rightskip
4089 \advance\hsize by -\tableindent
4090 \setbox0=\hbox{\itemindicate{#1}}%
4091 \itemindex{#1}%
4092 \nobreak % This prevents a break before @itemx.
4093 %
4094 % If the item text does not fit in the space we have, put it on a line
4095 % by itself, and do not allow a page break either before or after that
4096 % line. We do not start a paragraph here because then if the next
4097 % command is, e.g., @kindex, the whatsit would get put into the
4098 % horizontal list on a line by itself, resulting in extra blank space.
4099 \ifdim \wd0>\itemmax
4100 %
4101 % Make this a paragraph so we get the \parskip glue and wrapping,
4102 % but leave it ragged-right.
4103 \begingroup
4104 \advance\leftskip by-\tableindent
4105 \advance\hsize by\tableindent
4106 \advance\rightskip by0pt plus1fil\relax
4107 \leavevmode\unhbox0\par
4108 \endgroup
4109 %
4110 % We're going to be starting a paragraph, but we don't want the
4111 % \parskip glue -- logically it's part of the @item we just started.
4112 \nobreak \vskip-\parskip
4113 %
4114 % Stop a page break at the \parskip glue coming up. However, if
4115 % what follows is an environment such as @example, there will be no
4116 % \parskip glue; then the negative vskip we just inserted would
4117 % cause the example and the item to crash together. So we use this
4118 % bizarre value of 10001 as a signal to \aboveenvbreak to insert
4119 % \parskip glue after all. Section titles are handled this way also.
4120 %
4121 \penalty 10001
4122 \endgroup
4123 \itemxneedsnegativevskipfalse
4124 \else
4125 % The item text fits into the space. Start a paragraph, so that the
4126 % following text (if any) will end up on the same line.
4127 \noindent
4128 % Do this with kerns and \unhbox so that if there is a footnote in
4129 % the item text, it can migrate to the main vertical list and
4130 % eventually be printed.
4131 \nobreak\kern-\tableindent
4132 \dimen0 = \itemmax \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0
4133 \unhbox0
4134 \nobreak\kern\dimen0
4135 \endgroup
4136 \itemxneedsnegativevskiptrue
4137 \fi
4138}
4139
4140\def\item{\errmessage{@item while not in a list environment}}
4141\def\itemx{\errmessage{@itemx while not in a list environment}}
4142
4143% @table, @ftable, @vtable.
4144\envdef\table{%
4145 \let\itemindex\gobble
4146 \tablecheck{table}%
4147}
4148\envdef\ftable{%
4149 \def\itemindex ##1{\doind {fn}{\code{##1}}}%
4150 \tablecheck{ftable}%
4151}
4152\envdef\vtable{%
4153 \def\itemindex ##1{\doind {vr}{\code{##1}}}%
4154 \tablecheck{vtable}%
4155}
4156\def\tablecheck#1{%
4157 \ifnum \the\catcode`\^^M=\active
4158 \endgroup
4159 \errmessage{This command won't work in this context; perhaps the problem is
4160 that we are \inenvironment\thisenv}%
4161 \def\next{\doignore{#1}}%
4162 \else
4163 \let\next\tablex
4164 \fi
4165 \next
4166}
4167\def\tablex#1{%
4168 \def\itemindicate{#1}%
4169 \parsearg\tabley
4170}
4171\def\tabley#1{%
4172 {%
4173 \makevalueexpandable
4174 \edef\temp{\noexpand\tablez #1\space\space\space}%
4175 \expandafter
4176 }\temp \endtablez
4177}
4178\def\tablez #1 #2 #3 #4\endtablez{%
4179 \aboveenvbreak
4180 \ifnum 0#1>0 \advance \leftskip by #1\mil \fi
4181 \ifnum 0#2>0 \tableindent=#2\mil \fi
4182 \ifnum 0#3>0 \advance \rightskip by #3\mil \fi
4183 \itemmax=\tableindent
4184 \advance \itemmax by -\itemmargin
4185 \advance \leftskip by \tableindent
4186 \exdentamount=\tableindent
4187 \parindent = 0pt
4188 \parskip = \smallskipamount
4189 \ifdim \parskip=0pt \parskip=2pt \fi
4190 \let\item = \internalBitem
4191 \let\itemx = \internalBitemx
4192}
4193\def\Etable{\endgraf\afterenvbreak}
4194\let\Eftable\Etable
4195\let\Evtable\Etable
4196\let\Eitemize\Etable
4197\let\Eenumerate\Etable
4198
4199% This is the counter used by @enumerate, which is really @itemize
4200
4201\newcount \itemno
4202
4203\envdef\itemize{\parsearg\doitemize}
4204
4205\def\doitemize#1{%
4206 \aboveenvbreak
4207 \itemmax=\itemindent
4208 \advance\itemmax by -\itemmargin
4209 \advance\leftskip by \itemindent
4210 \exdentamount=\itemindent
4211 \parindent=0pt
4212 \parskip=\smallskipamount
4213 \ifdim\parskip=0pt \parskip=2pt \fi
4214 %
4215 % Try typesetting the item mark so that if the document erroneously says
4216 % something like @itemize @samp (intending @table), there's an error
4217 % right away at the @itemize. It's not the best error message in the
4218 % world, but it's better than leaving it to the @item. This means if
4219 % the user wants an empty mark, they have to say @w{} not just @w.
4220 \def\itemcontents{#1}%
4221 \setbox0 = \hbox{\itemcontents}%
4222 %
4223 % @itemize with no arg is equivalent to @itemize @bullet.
4224 \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi
4225 %
4226 \let\item=\itemizeitem
4227}
4228
4229% Definition of @item while inside @itemize and @enumerate.
4230%
4231\def\itemizeitem{%
4232 \advance\itemno by 1 % for enumerations
4233 {\let\par=\endgraf \smallbreak}% reasonable place to break
4234 {%
4235 % If the document has an @itemize directly after a section title, a
4236 % \nobreak will be last on the list, and \sectionheading will have
4237 % done a \vskip-\parskip. In that case, we don't want to zero
4238 % parskip, or the item text will crash with the heading. On the
4239 % other hand, when there is normal text preceding the item (as there
4240 % usually is), we do want to zero parskip, or there would be too much
4241 % space. In that case, we won't have a \nobreak before. At least
4242 % that's the theory.
4243 \ifnum\lastpenalty<10000 \parskip=0in \fi
4244 \noindent
4245 \hbox to 0pt{\hss \itemcontents \kern\itemmargin}%
4246 %
4247 \ifinner\else
4248 \vadjust{\penalty 1200}% not good to break after first line of item.
4249 \fi
4250 % We can be in inner vertical mode in a footnote, although an
4251 % @itemize looks awful there.
4252 }%
4253 \flushcr
4254}
4255
4256% \splitoff TOKENS\endmark defines \first to be the first token in
4257% TOKENS, and \rest to be the remainder.
4258%
4259\def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
4260
4261% Allow an optional argument of an uppercase letter, lowercase letter,
4262% or number, to specify the first label in the enumerated list. No
4263% argument is the same as `1'.
4264%
4265\envparseargdef\enumerate{\enumeratey #1 \endenumeratey}
4266\def\enumeratey #1 #2\endenumeratey{%
4267 % If we were given no argument, pretend we were given `1'.
4268 \def\thearg{#1}%
4269 \ifx\thearg\empty \def\thearg{1}\fi
4270 %
4271 % Detect if the argument is a single token. If so, it might be a
4272 % letter. Otherwise, the only valid thing it can be is a number.
4273 % (We will always have one token, because of the test we just made.
4274 % This is a good thing, since \splitoff doesn't work given nothing at
4275 % all -- the first parameter is undelimited.)
4276 \expandafter\splitoff\thearg\endmark
4277 \ifx\rest\empty
4278 % Only one token in the argument. It could still be anything.
4279 % A ``lowercase letter'' is one whose \lccode is nonzero.
4280 % An ``uppercase letter'' is one whose \lccode is both nonzero, and
4281 % not equal to itself.
4282 % Otherwise, we assume it's a number.
4283 %
4284 % We need the \relax at the end of the \ifnum lines to stop TeX from
4285 % continuing to look for a <number>.
4286 %
4287 \ifnum\lccode\expandafter`\thearg=0\relax
4288 \numericenumerate % a number (we hope)
4289 \else
4290 % It's a letter.
4291 \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
4292 \lowercaseenumerate % lowercase letter
4293 \else
4294 \uppercaseenumerate % uppercase letter
4295 \fi
4296 \fi
4297 \else
4298 % Multiple tokens in the argument. We hope it's a number.
4299 \numericenumerate
4300 \fi
4301}
4302
4303% An @enumerate whose labels are integers. The starting integer is
4304% given in \thearg.
4305%
4306\def\numericenumerate{%
4307 \itemno = \thearg
4308 \startenumeration{\the\itemno}%
4309}
4310
4311% The starting (lowercase) letter is in \thearg.
4312\def\lowercaseenumerate{%
4313 \itemno = \expandafter`\thearg
4314 \startenumeration{%
4315 % Be sure we're not beyond the end of the alphabet.
4316 \ifnum\itemno=0
4317 \errmessage{No more lowercase letters in @enumerate; get a bigger
4318 alphabet}%
4319 \fi
4320 \char\lccode\itemno
4321 }%
4322}
4323
4324% The starting (uppercase) letter is in \thearg.
4325\def\uppercaseenumerate{%
4326 \itemno = \expandafter`\thearg
4327 \startenumeration{%
4328 % Be sure we're not beyond the end of the alphabet.