aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl Berry2006-04-03 00:08:06 +0000
committerKarl Berry2006-04-03 00:08:06 +0000
commit0f9c19753b197f4d8ced6aa711da4f2fe7f12ef4 (patch)
treeacdcb0c4ba1bd42784a0091bde4c41b982b69d2c
parentb641fbd7f4cd1069ec2e709dea275d7698525d4d (diff)
downloademacs-0f9c19753b197f4d8ced6aa711da4f2fe7f12ef4.tar.gz
emacs-0f9c19753b197f4d8ced6aa711da4f2fe7f12ef4.zip
update to current texinfo.tex
-rw-r--r--man/ChangeLog4
-rw-r--r--man/texinfo.tex6702
2 files changed, 3794 insertions, 2912 deletions
diff --git a/man/ChangeLog b/man/ChangeLog
index 115cfe74b11..abe32a31868 100644
--- a/man/ChangeLog
+++ b/man/ChangeLog
@@ -1,3 +1,7 @@
12006-04-02 Karl Berry <karl@gnu.org>
2
3 * texinfo.tex: update to current version (2006-03-21.13).
4
12006-04-02 Bill Wohler <wohler@newt.com> 52006-04-02 Bill Wohler <wohler@newt.com>
2 6
3 * mh-e.texi (Getting Started, Junk, Bug Reports) 7 * mh-e.texi (Getting Started, Junk, Bug Reports)
diff --git a/man/texinfo.tex b/man/texinfo.tex
index 80a6d085f5d..7ed20f016b1 100644
--- a/man/texinfo.tex
+++ b/man/texinfo.tex
@@ -3,11 +3,11 @@
3% Load plain if necessary, i.e., if running under initex. 3% Load plain if necessary, i.e., if running under initex.
4\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi 4\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
5% 5%
6\def\texinfoversion{2006-02-05.23} 6\def\texinfoversion{2006-03-21.13}
7% 7%
8% Copyright (C) 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 8% Copyright (C) 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
9% 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 9% 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free
10% 2005, 2006 Free Software Foundation, Inc. 10% Software Foundation, Inc.
11% 11%
12% This texinfo.tex file is free software; you can redistribute it and/or 12% This texinfo.tex file is free software; you can redistribute it and/or
13% modify it under the terms of the GNU General Public License as 13% modify it under the terms of the GNU General Public License as
@@ -24,25 +24,18 @@
24% to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 24% to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25% Boston, MA 02110-1301, USA. 25% Boston, MA 02110-1301, USA.
26% 26%
27% In other words, you are welcome to use, share and improve this program. 27% As a special exception, when this file is read by TeX when processing
28% You are forbidden to forbid anyone else to use, share and improve 28% a Texinfo source document, you may use the result without
29% what you give them. Help stamp out software-hoarding! 29% restriction. (This has been our intent since Texinfo was invented.)
30% 30%
31% Please try the latest version of texinfo.tex before submitting bug 31% Please try the latest version of texinfo.tex before submitting bug
32% reports; you can get the latest version from: 32% reports; you can get the latest version from:
33% ftp://ftp.gnu.org/gnu/texinfo.tex 33% http://www.gnu.org/software/texinfo/ (the Texinfo home page), or
34% (and all GNU mirrors, see http://www.gnu.org/order/ftp.html)
35% ftp://texinfo.org/texinfo/texinfo.tex
36% ftp://tug.org/tex/texinfo.tex 34% ftp://tug.org/tex/texinfo.tex
37% (and all CTAN mirrors, see http://www.ctan.org), 35% (and all CTAN mirrors, see http://www.ctan.org).
38% and /home/gd/gnu/doc/texinfo.tex on the GNU machines. 36% The texinfo.tex in any given distribution could well be out
39%
40% The texinfo.tex in any given Texinfo distribution could well be out
41% of date, so if that's what you're using, please check. 37% of date, so if that's what you're using, please check.
42% 38%
43% Texinfo has a small home page at http://texinfo.org/ and also
44% http://www.gnu.org/software/texinfo.
45%
46% Send bug reports to bug-texinfo@gnu.org. Please include including a 39% Send bug reports to bug-texinfo@gnu.org. Please include including a
47% complete document in each bug report with which we can reproduce the 40% complete document in each bug report with which we can reproduce the
48% problem. Patches are, of course, greatly appreciated. 41% problem. Patches are, of course, greatly appreciated.
@@ -59,8 +52,12 @@
59% Sometimes one run after texindex suffices, and sometimes you need more 52% Sometimes one run after texindex suffices, and sometimes you need more
60% than two; texi2dvi does it as many times as necessary. 53% than two; texi2dvi does it as many times as necessary.
61% 54%
62% It is possible to adapt texinfo.tex for other languages. You can get 55% It is possible to adapt texinfo.tex for other languages, to some
63% the existing language-specific files from the full Texinfo distribution. 56% extent. You can get the existing language-specific files from the
57% full Texinfo distribution.
58%
59% The GNU Texinfo home page is http://www.gnu.org/software/texinfo.
60
64 61
65\message{Loading texinfo [version \texinfoversion]:} 62\message{Loading texinfo [version \texinfoversion]:}
66 63
@@ -70,7 +67,14 @@
70\everyjob{\message{[Texinfo version \texinfoversion]}% 67\everyjob{\message{[Texinfo version \texinfoversion]}%
71 \catcode`+=\active \catcode`\_=\active} 68 \catcode`+=\active \catcode`\_=\active}
72 69
73% Save some parts of plain tex whose names we will redefine. 70\message{Basics,}
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.
74\let\ptexb=\b 78\let\ptexb=\b
75\let\ptexbullet=\bullet 79\let\ptexbullet=\bullet
76\let\ptexc=\c 80\let\ptexc=\c
@@ -80,23 +84,35 @@
80\let\ptexend=\end 84\let\ptexend=\end
81\let\ptexequiv=\equiv 85\let\ptexequiv=\equiv
82\let\ptexexclam=\! 86\let\ptexexclam=\!
87\let\ptexfootnote=\footnote
88\let\ptexgtr=>
89\let\ptexhat=^
83\let\ptexi=\i 90\let\ptexi=\i
91\let\ptexindent=\indent
92\let\ptexinsert=\insert
84\let\ptexlbrace=\{ 93\let\ptexlbrace=\{
94\let\ptexless=<
95\let\ptexnewwrite\newwrite
96\let\ptexnoindent=\noindent
97\let\ptexplus=+
85\let\ptexrbrace=\} 98\let\ptexrbrace=\}
99\let\ptexslash=\/
86\let\ptexstar=\* 100\let\ptexstar=\*
87\let\ptext=\t 101\let\ptext=\t
88 102
89% We never want plain's outer \+ definition in Texinfo.
90% For @tex, we can use \tabalign.
91\let\+ = \relax
92
93\message{Basics,}
94\chardef\other=12
95
96% If this character appears in an error message or help string, it 103% If this character appears in an error message or help string, it
97% starts a new line in the output. 104% starts a new line in the output.
98\newlinechar = `^^J 105\newlinechar = `^^J
99 106
107% Use TeX 3.0's \inputlineno to get the line number, for better error
108% messages, but if we're using an old version of TeX, don't do anything.
109%
110\ifx\inputlineno\thisisundefined
111 \let\linenumber = \empty % Pre-3.0.
112\else
113 \def\linenumber{l.\the\inputlineno:\space}
114\fi
115
100% Set up fixed words for English if not already set. 116% Set up fixed words for English if not already set.
101\ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi 117\ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi
102\ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi 118\ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi
@@ -135,44 +151,97 @@
135\ifx\putwordDefspec\undefined \gdef\putwordDefspec{Special Form}\fi 151\ifx\putwordDefspec\undefined \gdef\putwordDefspec{Special Form}\fi
136\ifx\putwordDefvar\undefined \gdef\putwordDefvar{Variable}\fi 152\ifx\putwordDefvar\undefined \gdef\putwordDefvar{Variable}\fi
137\ifx\putwordDefopt\undefined \gdef\putwordDefopt{User Option}\fi 153\ifx\putwordDefopt\undefined \gdef\putwordDefopt{User Option}\fi
138\ifx\putwordDeftypevar\undefined\gdef\putwordDeftypevar{Variable}\fi
139\ifx\putwordDeffunc\undefined \gdef\putwordDeffunc{Function}\fi 154\ifx\putwordDeffunc\undefined \gdef\putwordDeffunc{Function}\fi
140\ifx\putwordDeftypefun\undefined\gdef\putwordDeftypefun{Function}\fi 155
156% Since the category of space is not known, we have to be careful.
157\chardef\spacecat = 10
158\def\spaceisspace{\catcode`\ =\spacecat}
141 159
142% Ignore a token. 160% Ignore a token.
143% 161%
144\def\gobble#1{} 162\def\gobble#1{}
145 163
146\hyphenation{ap-pen-dix} 164% The following is used inside several \edef's.
147\hyphenation{mini-buf-fer mini-buf-fers} 165\def\makecsname#1{\expandafter\noexpand\csname#1\endcsname}
148\hyphenation{eshell} 166
149\hyphenation{white-space} 167% Hyphenation fixes.
168\hyphenation{
169 Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script
170 ap-pen-dix bit-map bit-maps
171 data-base data-bases eshell fall-ing half-way long-est man-u-script
172 man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm
173 par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces
174 spell-ing spell-ings
175 stand-alone strong-est time-stamp time-stamps which-ever white-space
176 wide-spread wrap-around
177}
150 178
151% Margin to add to right of even pages, to left of odd pages. 179% Margin to add to right of even pages, to left of odd pages.
152\newdimen \bindingoffset 180\newdimen\bindingoffset
153\newdimen \normaloffset 181\newdimen\normaloffset
154\newdimen\pagewidth \newdimen\pageheight 182\newdimen\pagewidth \newdimen\pageheight
155 183
184% For a final copy, take out the rectangles
185% that mark overfull boxes (in case you have decided
186% that the text looks ok even though it passes the margin).
187%
188\def\finalout{\overfullrule=0pt}
189
190% @| inserts a changebar to the left of the current line. It should
191% surround any changed text. This approach does *not* work if the
192% change spans more than two lines of output. To handle that, we would
193% have adopt a much more difficult approach (putting marks into the main
194% vertical list for the beginning and end of each change).
195%
196\def\|{%
197 % \vadjust can only be used in horizontal mode.
198 \leavevmode
199 %
200 % Append this vertical mode material after the current line in the output.
201 \vadjust{%
202 % We want to insert a rule with the height and depth of the current
203 % leading; that is exactly what \strutbox is supposed to record.
204 \vskip-\baselineskip
205 %
206 % \vadjust-items are inserted at the left edge of the type. So
207 % the \llap here moves out into the left-hand margin.
208 \llap{%
209 %
210 % For a thicker or thinner bar, change the `1pt'.
211 \vrule height\baselineskip width1pt
212 %
213 % This is the space between the bar and the text.
214 \hskip 12pt
215 }%
216 }%
217}
218
156% Sometimes it is convenient to have everything in the transcript file 219% Sometimes it is convenient to have everything in the transcript file
157% and nothing on the terminal. We don't just call \tracingall here, 220% and nothing on the terminal. We don't just call \tracingall here,
158% since that produces some useless output on the terminal. 221% since that produces some useless output on the terminal. We also make
222% some effort to order the tracing commands to reduce output in the log
223% file; cf. trace.sty in LaTeX.
159% 224%
160\def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}% 225\def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
161\ifx\eTeXversion\undefined 226\def\loggingall{%
162\def\loggingall{\tracingcommands2 \tracingstats2 227 \tracingstats2
163 \tracingpages1 \tracingoutput1 \tracinglostchars1 228 \tracingpages1
164 \tracingmacros2 \tracingparagraphs1 \tracingrestores1 229 \tracinglostchars2 % 2 gives us more in etex
165 \showboxbreadth\maxdimen\showboxdepth\maxdimen 230 \tracingparagraphs1
166}% 231 \tracingoutput1
167\else 232 \tracingmacros2
168\def\loggingall{\tracingcommands3 \tracingstats2 233 \tracingrestores1
169 \tracingpages1 \tracingoutput1 \tracinglostchars1 234 \showboxbreadth\maxdimen \showboxdepth\maxdimen
170 \tracingmacros2 \tracingparagraphs1 \tracingrestores1 235 \ifx\eTeXversion\undefined\else % etex gives us more logging
171 \tracingscantokens1 \tracingassigns1 \tracingifs1 236 \tracingscantokens1
172 \tracinggroups1 \tracingnesting2 237 \tracingifs1
173 \showboxbreadth\maxdimen\showboxdepth\maxdimen 238 \tracinggroups1
239 \tracingnesting2
240 \tracingassigns1
241 \fi
242 \tracingcommands3 % 3 gives us more in etex
243 \errorcontextlines16
174}% 244}%
175\fi
176 245
177% add check for \lastpenalty to plain's definitions. If the last thing 246% add check for \lastpenalty to plain's definitions. If the last thing
178% we did was a \nobreak, we don't want to insert more space. 247% we did was a \nobreak, we don't want to insert more space.
@@ -223,13 +292,17 @@
223 % take effect in \write's, yet the group defined by the \vbox ends 292 % take effect in \write's, yet the group defined by the \vbox ends
224 % before the \shipout runs. 293 % before the \shipout runs.
225 % 294 %
226 \escapechar = `\\ % use backslash in output files.
227 \indexdummies % don't expand commands in the output. 295 \indexdummies % don't expand commands in the output.
228 \normalturnoffactive % \ in index entries must not stay \, e.g., if 296 \normalturnoffactive % \ in index entries must not stay \, e.g., if
229 % the page break happens to be in the middle of an example. 297 % the page break happens to be in the middle of an example.
298 % We don't want .vr (or whatever) entries like this:
299 % \entry{{\tt \indexbackslash }acronym}{32}{\code {\acronym}}
300 % "\acronym" won't work when it's read back in;
301 % it needs to be
302 % {\code {{\tt \backslashcurfont }acronym}
230 \shipout\vbox{% 303 \shipout\vbox{%
231 % Do this early so pdf references go to the beginning of the page. 304 % Do this early so pdf references go to the beginning of the page.
232 \ifpdfmakepagedest \pdfmkdest{\the\pageno} \fi 305 \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi
233 % 306 %
234 \ifcropmarks \vbox to \outervsize\bgroup 307 \ifcropmarks \vbox to \outervsize\bgroup
235 \hsize = \outerhsize 308 \hsize = \outerhsize
@@ -277,7 +350,7 @@
277 \egroup % \vbox from first cropmarks clause 350 \egroup % \vbox from first cropmarks clause
278 \fi 351 \fi
279 }% end of \shipout\vbox 352 }% end of \shipout\vbox
280 }% end of group with \turnoffactive 353 }% end of group with \indexdummies
281 \advancepageno 354 \advancepageno
282 \ifnum\outputpenalty>-20000 \else\dosupereject\fi 355 \ifnum\outputpenalty>-20000 \else\dosupereject\fi
283} 356}
@@ -310,143 +383,161 @@
310% the input line (except we remove a trailing comment). #1 should be a 383% the input line (except we remove a trailing comment). #1 should be a
311% macro which expects an ordinary undelimited TeX argument. 384% macro which expects an ordinary undelimited TeX argument.
312% 385%
313\def\parsearg#1{% 386\def\parsearg{\parseargusing{}}
314 \let\next = #1% 387\def\parseargusing#1#2{%
388 \def\argtorun{#2}%
315 \begingroup 389 \begingroup
316 \obeylines 390 \obeylines
317 \futurelet\temp\parseargx 391 \spaceisspace
318} 392 #1%
319 393 \parseargline\empty% Insert the \empty token, see \finishparsearg below.
320% If the next token is an obeyed space (from an @example environment or
321% the like), remove it and recurse. Otherwise, we're done.
322\def\parseargx{%
323 % \obeyedspace is defined far below, after the definition of \sepspaces.
324 \ifx\obeyedspace\temp
325 \expandafter\parseargdiscardspace
326 \else
327 \expandafter\parseargline
328 \fi
329} 394}
330 395
331% Remove a single space (as the delimiter token to the macro call).
332{\obeyspaces %
333 \gdef\parseargdiscardspace {\futurelet\temp\parseargx}}
334
335{\obeylines % 396{\obeylines %
336 \gdef\parseargline#1^^M{% 397 \gdef\parseargline#1^^M{%
337 \endgroup % End of the group started in \parsearg. 398 \endgroup % End of the group started in \parsearg.
338 % 399 \argremovecomment #1\comment\ArgTerm%
339 % First remove any @c comment, then any @comment.
340 % Result of each macro is put in \toks0.
341 \argremovec #1\c\relax %
342 \expandafter\argremovecomment \the\toks0 \comment\relax %
343 %
344 % Call the caller's macro, saved as \next in \parsearg.
345 \expandafter\next\expandafter{\the\toks0}%
346 }% 400 }%
347} 401}
348 402
349% Since all \c{,omment} does is throw away the argument, we can let TeX 403% First remove any @comment, then any @c comment.
350% do that for us. The \relax here is matched by the \relax in the call 404\def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm}
351% in \parseargline; it could be more or less anything, its purpose is 405\def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
352% just to delimit the argument to the \c.
353\def\argremovec#1\c#2\relax{\toks0 = {#1}}
354\def\argremovecomment#1\comment#2\relax{\toks0 = {#1}}
355 406
356% \argremovec{,omment} might leave us with trailing spaces, though; e.g., 407% Each occurence of `\^^M' or `<space>\^^M' is replaced by a single space.
408%
409% \argremovec might leave us with trailing space, e.g.,
357% @end itemize @c foo 410% @end itemize @c foo
358% will have two active spaces as part of the argument with the 411% This space token undergoes the same procedure and is eventually removed
359% `itemize'. Here we remove all active spaces from #1, and assign the 412% by \finishparsearg.
360% result to \toks0. 413%
361% 414\def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M}
362% This loses if there are any *other* active characters besides spaces 415\def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M}
363% in the argument -- _ ^ +, for example -- since they get expanded. 416\def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{%
364% Fortunately, Texinfo does not define any such commands. (If it ever 417 \def\temp{#3}%
365% does, the catcode of the characters in questionwill have to be changed 418 \ifx\temp\empty
366% here.) But this means we cannot call \removeactivespaces as part of 419 % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp:
367% \argremovec{,omment}, since @c uses \parsearg, and thus the argument 420 \let\temp\finishparsearg
368% that \parsearg gets might well have any character at all in it. 421 \else
369% 422 \let\temp\argcheckspaces
370\def\removeactivespaces#1{% 423 \fi
371 \begingroup 424 % Put the space token in:
372 \ignoreactivespaces 425 \temp#1 #3\ArgTerm
373 \edef\temp{#1}%
374 \global\toks0 = \expandafter{\temp}%
375 \endgroup
376} 426}
377 427
378% Change the active space to expand to nothing. 428% If a _delimited_ argument is enclosed in braces, they get stripped; so
429% to get _exactly_ the rest of the line, we had to prevent such situation.
430% We prepended an \empty token at the very beginning and we expand it now,
431% just before passing the control to \argtorun.
432% (Similarily, we have to think about #3 of \argcheckspacesY above: it is
433% either the null string, or it ends with \^^M---thus there is no danger
434% that a pair of braces would be stripped.
379% 435%
380\begingroup 436% But first, we have to remove the trailing space token.
437%
438\def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}}
439
440% \parseargdef\foo{...}
441% is roughly equivalent to
442% \def\foo{\parsearg\Xfoo}
443% \def\Xfoo#1{...}
444%
445% Actually, I use \csname\string\foo\endcsname, ie. \\foo, as it is my
446% favourite TeX trick. --kasal, 16nov03
447
448\def\parseargdef#1{%
449 \expandafter \doparseargdef \csname\string#1\endcsname #1%
450}
451\def\doparseargdef#1#2{%
452 \def#2{\parsearg#1}%
453 \def#1##1%
454}
455
456% Several utility definitions with active space:
457{
381 \obeyspaces 458 \obeyspaces
382 \gdef\ignoreactivespaces{\obeyspaces\let =\empty} 459 \gdef\obeyedspace{ }
383\endgroup 460
461 % Make each space character in the input produce a normal interword
462 % space in the output. Don't allow a line break at this space, as this
463 % is used only in environments like @example, where each line of input
464 % should produce a line of output anyway.
465 %
466 \gdef\sepspaces{\obeyspaces\let =\tie}
467
468 % If an index command is used in an @example environment, any spaces
469 % therein should become regular spaces in the raw index file, not the
470 % expansion of \tie (\leavevmode \penalty \@M \ ).
471 \gdef\unsepspaces{\let =\space}
472}
384 473
385 474
386\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next} 475\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
387 476
388%% These are used to keep @begin/@end levels from running away 477% Define the framework for environments in texinfo.tex. It's used like this:
389%% Call \inENV within environments (after a \begingroup) 478%
390\newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi} 479% \envdef\foo{...}
391\def\ENVcheck{% 480% \def\Efoo{...}
392\ifENV\errmessage{Still within an environment; press RETURN to continue} 481%
393\endgroup\fi} % This is not perfect, but it should reduce lossage 482% It's the responsibility of \envdef to insert \begingroup before the
483% actual body; @end closes the group after calling \Efoo. \envdef also
484% defines \thisenv, so the current environment is known; @end checks
485% whether the environment name matches. The \checkenv macro can also be
486% used to check whether the current environment is the one expected.
487%
488% Non-false conditionals (@iftex, @ifset) don't fit into this, so they
489% are not treated as enviroments; they don't open a group. (The
490% implementation of @end takes care not to call \endgroup in this
491% special case.)
394 492
395% @begin foo is the same as @foo, for now.
396\newhelp\EMsimple{Press RETURN to continue.}
397 493
398\outer\def\begin{\parsearg\beginxxx} 494% At runtime, environments start with this:
495\def\startenvironment#1{\begingroup\def\thisenv{#1}}
496% initialize
497\let\thisenv\empty
399 498
400\def\beginxxx #1{% 499% ... but they get defined via ``\envdef\foo{...}'':
401\expandafter\ifx\csname #1\endcsname\relax 500\long\def\envdef#1#2{\def#1{\startenvironment#1#2}}
402{\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else 501\def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}}
403\csname #1\endcsname\fi}
404 502
405% @end foo executes the definition of \Efoo. 503% Check whether we're in the right environment:
406% 504\def\checkenv#1{%
407\def\end{\parsearg\endxxx} 505 \def\temp{#1}%
408\def\endxxx #1{% 506 \ifx\thisenv\temp
409 \removeactivespaces{#1}%
410 \edef\endthing{\the\toks0}%
411 %
412 \expandafter\ifx\csname E\endthing\endcsname\relax
413 \expandafter\ifx\csname \endthing\endcsname\relax
414 % There's no \foo, i.e., no ``environment'' foo.
415 \errhelp = \EMsimple
416 \errmessage{Undefined command `@end \endthing'}%
417 \else
418 \unmatchedenderror\endthing
419 \fi
420 \else 507 \else
421 % Everything's ok; the right environment has been started. 508 \badenverr
422 \csname E\endthing\endcsname
423 \fi 509 \fi
424} 510}
425 511
426% There is an environment #1, but it hasn't been started. Give an error. 512% Evironment mismatch, #1 expected:
427% 513\def\badenverr{%
428\def\unmatchedenderror#1{%
429 \errhelp = \EMsimple 514 \errhelp = \EMsimple
430 \errmessage{This `@end #1' doesn't have a matching `@#1'}% 515 \errmessage{This command can appear only \inenvironment\temp,
516 not \inenvironment\thisenv}%
517}
518\def\inenvironment#1{%
519 \ifx#1\empty
520 out of any environment%
521 \else
522 in environment \expandafter\string#1%
523 \fi
431} 524}
432 525
433% Define the control sequence \E#1 to give an unmatched @end error. 526% @end foo executes the definition of \Efoo.
527% But first, it executes a specialized version of \checkenv
434% 528%
435\def\defineunmatchedend#1{% 529\parseargdef\end{%
436 \expandafter\def\csname E#1\endcsname{\unmatchedenderror{#1}}% 530 \if 1\csname iscond.#1\endcsname
531 \else
532 % The general wording of \badenverr may not be ideal, but... --kasal, 06nov03
533 \expandafter\checkenv\csname#1\endcsname
534 \csname E#1\endcsname
535 \endgroup
536 \fi
437} 537}
438 538
539\newhelp\EMsimple{Press RETURN to continue.}
439 540
440% Single-spacing is done by various environments (specifically, in
441% \nonfillstart and \quotations).
442\newskip\singlespaceskip \singlespaceskip = 12.5pt
443\def\singlespace{%
444 % Why was this kern here? It messes up equalizing space above and below
445 % environments. --karl, 6may93
446 %{\advance \baselineskip by -\singlespaceskip
447 %\kern \baselineskip}%
448 \setleading\singlespaceskip
449}
450 541
451%% Simple single-character @ commands 542%% Simple single-character @ commands
452 543
@@ -467,16 +558,22 @@
467\let\{=\mylbrace 558\let\{=\mylbrace
468\let\}=\myrbrace 559\let\}=\myrbrace
469\begingroup 560\begingroup
470 % Definitions to produce actual \{ & \} command in an index. 561 % Definitions to produce \{ and \} commands for indices,
471 \catcode`\{ = 12 \catcode`\} = 12 562 % and @{ and @} for the aux/toc files.
563 \catcode`\{ = \other \catcode`\} = \other
472 \catcode`\[ = 1 \catcode`\] = 2 564 \catcode`\[ = 1 \catcode`\] = 2
473 \catcode`\@ = 0 \catcode`\\ = 12 565 \catcode`\! = 0 \catcode`\\ = \other
474 @gdef@lbracecmd[\{]% 566 !gdef!lbracecmd[\{]%
475 @gdef@rbracecmd[\}]% 567 !gdef!rbracecmd[\}]%
476@endgroup 568 !gdef!lbraceatcmd[@{]%
569 !gdef!rbraceatcmd[@}]%
570!endgroup
571
572% @comma{} to avoid , parsing problems.
573\let\comma = ,
477 574
478% Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent 575% Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
479% Others are defined by plain TeX: @` @' @" @^ @~ @= @v @H. 576% Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H.
480\let\, = \c 577\let\, = \c
481\let\dotaccent = \. 578\let\dotaccent = \.
482\def\ringaccent#1{{\accent23 #1}} 579\def\ringaccent#1{{\accent23 #1}}
@@ -484,10 +581,12 @@
484\let\ubaraccent = \b 581\let\ubaraccent = \b
485\let\udotaccent = \d 582\let\udotaccent = \d
486 583
487% Other special characters: @questiondown @exclamdown 584% Other special characters: @questiondown @exclamdown @ordf @ordm
488% Plain TeX defines: @AA @AE @O @OE @L (and lowercase versions) @ss. 585% Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss.
489\def\questiondown{?`} 586\def\questiondown{?`}
490\def\exclamdown{!`} 587\def\exclamdown{!`}
588\def\ordf{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{a}}}
589\def\ordm{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{o}}}
491 590
492% Dotless i and dotless j, used for accents. 591% Dotless i and dotless j, used for accents.
493\def\imacro{i} 592\def\imacro{i}
@@ -500,6 +599,25 @@
500 \fi\fi 599 \fi\fi
501} 600}
502 601
602% The \TeX{} logo, as in plain, but resetting the spacing so that a
603% period following counts as ending a sentence. (Idea found in latex.)
604%
605\edef\TeX{\TeX \spacefactor=1000 }
606
607% @LaTeX{} logo. Not quite the same results as the definition in
608% latex.ltx, since we use a different font for the raised A; it's most
609% convenient for us to use an explicitly smaller font, rather than using
610% the \scriptstyle font (since we don't reset \scriptstyle and
611% \scriptscriptstyle).
612%
613\def\LaTeX{%
614 L\kern-.36em
615 {\setbox0=\hbox{T}%
616 \vbox to \ht0{\hbox{\selectfonts\lllsize A}\vss}}%
617 \kern-.15em
618 \TeX
619}
620
503% Be sure we're in horizontal mode when doing a tie, since we make space 621% Be sure we're in horizontal mode when doing a tie, since we make space
504% equivalent to this in @example-like environments. Otherwise, a space 622% equivalent to this in @example-like environments. Otherwise, a space
505% at the beginning of a line will start with \penalty -- and 623% at the beginning of a line will start with \penalty -- and
@@ -518,14 +636,32 @@
518% @* forces a line break. 636% @* forces a line break.
519\def\*{\hfil\break\hbox{}\ignorespaces} 637\def\*{\hfil\break\hbox{}\ignorespaces}
520 638
639% @/ allows a line break.
640\let\/=\allowbreak
641
521% @. is an end-of-sentence period. 642% @. is an end-of-sentence period.
522\def\.{.\spacefactor=3000 } 643\def\.{.\spacefactor=\endofsentencespacefactor\space}
523 644
524% @! is an end-of-sentence bang. 645% @! is an end-of-sentence bang.
525\def\!{!\spacefactor=3000 } 646\def\!{!\spacefactor=\endofsentencespacefactor\space}
526 647
527% @? is an end-of-sentence query. 648% @? is an end-of-sentence query.
528\def\?{?\spacefactor=3000 } 649\def\?{?\spacefactor=\endofsentencespacefactor\space}
650
651% @frenchspacing on|off says whether to put extra space after punctuation.
652%
653\def\onword{on}
654\def\offword{off}
655%
656\parseargdef\frenchspacing{%
657 \def\temp{#1}%
658 \ifx\temp\onword \plainfrenchspacing
659 \else\ifx\temp\offword \plainnonfrenchspacing
660 \else
661 \errhelp = \EMsimple
662 \errmessage{Unknown @frenchspacing option `\temp', must be on/off}%
663 \fi\fi
664}
529 665
530% @w prevents a word break. Without the \leavevmode, @w at the 666% @w prevents a word break. Without the \leavevmode, @w at the
531% beginning of a paragraph, when TeX is still in vertical mode, would 667% beginning of a paragraph, when TeX is still in vertical mode, would
@@ -540,47 +676,24 @@
540% therefore, no glue is inserted, and the space between the headline and 676% therefore, no glue is inserted, and the space between the headline and
541% the text is small, which looks bad. 677% the text is small, which looks bad.
542% 678%
543\def\group{\begingroup 679% Another complication is that the group might be very large. This can
544 \ifnum\catcode13=\active \else 680% cause the glue on the previous page to be unduly stretched, because it
681% does not have much material. In this case, it's better to add an
682% explicit \vfill so that the extra space is at the bottom. The
683% threshold for doing this is if the group is more than \vfilllimit
684% percent of a page (\vfilllimit can be changed inside of @tex).
685%
686\newbox\groupbox
687\def\vfilllimit{0.7}
688%
689\envdef\group{%
690 \ifnum\catcode`\^^M=\active \else
545 \errhelp = \groupinvalidhelp 691 \errhelp = \groupinvalidhelp
546 \errmessage{@group invalid in context where filling is enabled}% 692 \errmessage{@group invalid in context where filling is enabled}%
547 \fi 693 \fi
694 \startsavinginserts
548 % 695 %
549 % The \vtop we start below produces a box with normal height and large 696 \setbox\groupbox = \vtop\bgroup
550 % depth; thus, TeX puts \baselineskip glue before it, and (when the
551 % next line of text is done) \lineskip glue after it. (See p.82 of
552 % the TeXbook.) Thus, space below is not quite equal to space
553 % above. But it's pretty close.
554 \def\Egroup{%
555 \egroup % End the \vtop.
556 \endgroup % End the \group.
557 }%
558 %
559 \vtop\bgroup
560 % We have to put a strut on the last line in case the @group is in
561 % the midst of an example, rather than completely enclosing it.
562 % Otherwise, the interline space between the last line of the group
563 % and the first line afterwards is too small. But we can't put the
564 % strut in \Egroup, since there it would be on a line by itself.
565 % Hence this just inserts a strut at the beginning of each line.
566 \everypar = {\strut}%
567 %
568 % Since we have a strut on every line, we don't need any of TeX's
569 % normal interline spacing.
570 \offinterlineskip
571 %
572 % OK, but now we have to do something about blank
573 % lines in the input in @example-like environments, which normally
574 % just turn into \lisppar, which will insert no space now that we've
575 % turned off the interline space. Simplest is to make them be an
576 % empty paragraph.
577 \ifx\par\lisppar
578 \edef\par{\leavevmode \par}%
579 %
580 % Reset ^^M's definition to new definition of \par.
581 \obeylines
582 \fi
583 %
584 % Do @comment since we are called inside an environment such as 697 % Do @comment since we are called inside an environment such as
585 % @example, where each end-of-line in the input causes an 698 % @example, where each end-of-line in the input causes an
586 % end-of-line in the output. We don't want the end-of-line after 699 % end-of-line in the output. We don't want the end-of-line after
@@ -590,6 +703,32 @@
590 \comment 703 \comment
591} 704}
592% 705%
706% The \vtop produces a box with normal height and large depth; thus, TeX puts
707% \baselineskip glue before it, and (when the next line of text is done)
708% \lineskip glue after it. Thus, space below is not quite equal to space
709% above. But it's pretty close.
710\def\Egroup{%
711 % To get correct interline space between the last line of the group
712 % and the first line afterwards, we have to propagate \prevdepth.
713 \endgraf % Not \par, as it may have been set to \lisppar.
714 \global\dimen1 = \prevdepth
715 \egroup % End the \vtop.
716 % \dimen0 is the vertical size of the group's box.
717 \dimen0 = \ht\groupbox \advance\dimen0 by \dp\groupbox
718 % \dimen2 is how much space is left on the page (more or less).
719 \dimen2 = \pageheight \advance\dimen2 by -\pagetotal
720 % if the group doesn't fit on the current page, and it's a big big
721 % group, force a page break.
722 \ifdim \dimen0 > \dimen2
723 \ifdim \pagetotal < \vfilllimit\pageheight
724 \page
725 \fi
726 \fi
727 \box\groupbox
728 \prevdepth = \dimen1
729 \checkinserts
730}
731%
593% TeX puts in an \escapechar (i.e., `@') at the beginning of the help 732% TeX puts in an \escapechar (i.e., `@') at the beginning of the help
594% message, so this ends up printing `@group can only ...'. 733% message, so this ends up printing `@group can only ...'.
595% 734%
@@ -602,10 +741,8 @@ where each line of input produces a line of output.}
602 741
603\newdimen\mil \mil=0.001in 742\newdimen\mil \mil=0.001in
604 743
605\def\need{\parsearg\needx}
606
607% Old definition--didn't work. 744% Old definition--didn't work.
608%\def\needx #1{\par % 745%\parseargdef\need{\par %
609%% This method tries to make TeX break the page naturally 746%% This method tries to make TeX break the page naturally
610%% if the depth of the box does not fit. 747%% if the depth of the box does not fit.
611%{\baselineskip=0pt% 748%{\baselineskip=0pt%
@@ -613,7 +750,7 @@ where each line of input produces a line of output.}
613%\prevdepth=-1000pt 750%\prevdepth=-1000pt
614%}} 751%}}
615 752
616\def\needx#1{% 753\parseargdef\need{%
617 % Ensure vertical mode, so we don't make a big box in the middle of a 754 % Ensure vertical mode, so we don't make a big box in the middle of a
618 % paragraph. 755 % paragraph.
619 \par 756 \par
@@ -652,37 +789,11 @@ where each line of input produces a line of output.}
652 \fi 789 \fi
653} 790}
654 791
655% @br forces paragraph break 792% @br forces paragraph break (and is undocumented).
656 793
657\let\br = \par 794\let\br = \par
658 795
659% @dots{} output an ellipsis using the current font. 796% @page forces the start of a new page.
660% We do .5em per period so that it has the same spacing in a typewriter
661% font as three actual period characters.
662%
663\def\dots{%
664 \leavevmode
665 \hbox to 1.5em{%
666 \hskip 0pt plus 0.25fil minus 0.25fil
667 .\hss.\hss.%
668 \hskip 0pt plus 0.5fil minus 0.5fil
669 }%
670}
671
672% @enddots{} is an end-of-sentence ellipsis.
673%
674\def\enddots{%
675 \leavevmode
676 \hbox to 2em{%
677 \hskip 0pt plus 0.25fil minus 0.25fil
678 .\hss.\hss.\hss.%
679 \hskip 0pt plus 0.5fil minus 0.5fil
680 }%
681 \spacefactor=3000
682}
683
684
685% @page forces the start of a new page
686% 797%
687\def\page{\par\vfill\supereject} 798\def\page{\par\vfill\supereject}
688 799
@@ -694,13 +805,11 @@ where each line of input produces a line of output.}
694\newskip\exdentamount 805\newskip\exdentamount
695 806
696% This defn is used inside fill environments such as @defun. 807% This defn is used inside fill environments such as @defun.
697\def\exdent{\parsearg\exdentyyy} 808\parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}
698\def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}}
699 809
700% This defn is used inside nofill environments such as @example. 810% This defn is used inside nofill environments such as @example.
701\def\nofillexdent{\parsearg\nofillexdentyyy} 811\parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount
702\def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount 812 \leftline{\hskip\leftskip{\rm#1}}}}
703\leftline{\hskip\leftskip{\rm#1}}}}
704 813
705% @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current 814% @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current
706% paragraph. For more general purposes, use the \margin insertion 815% paragraph. For more general purposes, use the \margin insertion
@@ -752,37 +861,71 @@ where each line of input produces a line of output.}
752} 861}
753 862
754% @include file insert text of that file as input. 863% @include file insert text of that file as input.
755% Allow normal characters that we make active in the argument (a file name). 864%
756\def\include{\begingroup 865\def\include{\parseargusing\filenamecatcodes\includezzz}
757 \catcode`\\=12 866\def\includezzz#1{%
758 \catcode`~=12 867 \pushthisfilestack
759 \catcode`^=12
760 \catcode`_=12
761 \catcode`|=12
762 \catcode`<=12
763 \catcode`>=12
764 \catcode`+=12
765 \parsearg\includezzz}
766% Restore active chars for included file.
767\def\includezzz#1{\endgroup\begingroup
768 % Read the included file in a group so nested @include's work.
769 \def\thisfile{#1}% 868 \def\thisfile{#1}%
770 \input\thisfile 869 {%
771\endgroup} 870 \makevalueexpandable
871 \def\temp{\input #1 }%
872 \expandafter
873 }\temp
874 \popthisfilestack
875}
876\def\filenamecatcodes{%
877 \catcode`\\=\other
878 \catcode`~=\other
879 \catcode`^=\other
880 \catcode`_=\other
881 \catcode`|=\other
882 \catcode`<=\other
883 \catcode`>=\other
884 \catcode`+=\other
885 \catcode`-=\other
886}
772 887
773\def\thisfile{} 888\def\pushthisfilestack{%
889 \expandafter\pushthisfilestackX\popthisfilestack\StackTerm
890}
891\def\pushthisfilestackX{%
892 \expandafter\pushthisfilestackY\thisfile\StackTerm
893}
894\def\pushthisfilestackY #1\StackTerm #2\StackTerm {%
895 \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}%
896}
774 897
775% @center line outputs that line, centered 898\def\popthisfilestack{\errthisfilestackempty}
899\def\errthisfilestackempty{\errmessage{Internal error:
900 the stack of filenames is empty.}}
776 901
777\def\center{\parsearg\centerzzz} 902\def\thisfile{}
778\def\centerzzz #1{{\advance\hsize by -\leftskip 903
779\advance\hsize by -\rightskip 904% @center line
780\centerline{#1}}} 905% outputs that line, centered.
906%
907\parseargdef\center{%
908 \ifhmode
909 \let\next\centerH
910 \else
911 \let\next\centerV
912 \fi
913 \next{\hfil \ignorespaces#1\unskip \hfil}%
914}
915\def\centerH#1{%
916 {%
917 \hfil\break
918 \advance\hsize by -\leftskip
919 \advance\hsize by -\rightskip
920 \line{#1}%
921 \break
922 }%
923}
924\def\centerV#1{\line{\kern\leftskip #1\kern\rightskip}}
781 925
782% @sp n outputs n lines of vertical space 926% @sp n outputs n lines of vertical space
783 927
784\def\sp{\parsearg\spxxx} 928\parseargdef\sp{\vskip #1\baselineskip}
785\def\spxxx #1{\vskip #1\baselineskip}
786 929
787% @comment ...line which is ignored... 930% @comment ...line which is ignored...
788% @c is the same as @comment 931% @c is the same as @comment
@@ -797,13 +940,13 @@ where each line of input produces a line of output.}
797 940
798% @paragraphindent NCHARS 941% @paragraphindent NCHARS
799% We'll use ems for NCHARS, close enough. 942% We'll use ems for NCHARS, close enough.
800% We cannot implement @paragraphindent asis, though. 943% NCHARS can also be the word `asis' or `none'.
944% We cannot feasibly implement @paragraphindent asis, though.
801% 945%
802\def\asisword{asis} % no translation, these are keywords 946\def\asisword{asis} % no translation, these are keywords
803\def\noneword{none} 947\def\noneword{none}
804% 948%
805\def\paragraphindent{\parsearg\doparagraphindent} 949\parseargdef\paragraphindent{%
806\def\doparagraphindent#1{%
807 \def\temp{#1}% 950 \def\temp{#1}%
808 \ifx\temp\asisword 951 \ifx\temp\asisword
809 \else 952 \else
@@ -820,8 +963,7 @@ where each line of input produces a line of output.}
820% We'll use ems for NCHARS like @paragraphindent. 963% We'll use ems for NCHARS like @paragraphindent.
821% It seems @exampleindent asis isn't necessary, but 964% It seems @exampleindent asis isn't necessary, but
822% I preserve it to make it similar to @paragraphindent. 965% I preserve it to make it similar to @paragraphindent.
823\def\exampleindent{\parsearg\doexampleindent} 966\parseargdef\exampleindent{%
824\def\doexampleindent#1{%
825 \def\temp{#1}% 967 \def\temp{#1}%
826 \ifx\temp\asisword 968 \ifx\temp\asisword
827 \else 969 \else
@@ -833,33 +975,76 @@ where each line of input produces a line of output.}
833 \fi 975 \fi
834} 976}
835 977
978% @firstparagraphindent WORD
979% If WORD is `none', then suppress indentation of the first paragraph
980% after a section heading. If WORD is `insert', then do indent at such
981% paragraphs.
982%
983% The paragraph indentation is suppressed or not by calling
984% \suppressfirstparagraphindent, which the sectioning commands do.
985% We switch the definition of this back and forth according to WORD.
986% By default, we suppress indentation.
987%
988\def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent}
989\def\insertword{insert}
990%
991\parseargdef\firstparagraphindent{%
992 \def\temp{#1}%
993 \ifx\temp\noneword
994 \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent
995 \else\ifx\temp\insertword
996 \let\suppressfirstparagraphindent = \relax
997 \else
998 \errhelp = \EMsimple
999 \errmessage{Unknown @firstparagraphindent option `\temp'}%
1000 \fi\fi
1001}
1002
1003% Here is how we actually suppress indentation. Redefine \everypar to
1004% \kern backwards by \parindent, and then reset itself to empty.
1005%
1006% We also make \indent itself not actually do anything until the next
1007% paragraph.
1008%
1009\gdef\dosuppressfirstparagraphindent{%
1010 \gdef\indent{%
1011 \restorefirstparagraphindent
1012 \indent
1013 }%
1014 \gdef\noindent{%
1015 \restorefirstparagraphindent
1016 \noindent
1017 }%
1018 \global\everypar = {%
1019 \kern -\parindent
1020 \restorefirstparagraphindent
1021 }%
1022}
1023
1024\gdef\restorefirstparagraphindent{%
1025 \global \let \indent = \ptexindent
1026 \global \let \noindent = \ptexnoindent
1027 \global \everypar = {}%
1028}
1029
1030
836% @asis just yields its argument. Used with @table, for example. 1031% @asis just yields its argument. Used with @table, for example.
837% 1032%
838\def\asis#1{#1} 1033\def\asis#1{#1}
839 1034
840% @math outputs its argument in math mode. 1035% @math outputs its argument in math mode.
841% We don't use $'s directly in the definition of \math because we need
842% to set catcodes according to plain TeX first, to allow for subscripts,
843% superscripts, special math chars, etc.
844%
845% @math does not do math typesetting in section titles, index
846% entries, and other such contexts where the catcodes are set before
847% @math gets a chance to work. This could perhaps be fixed, but for now
848% at least we can have real math in the main text, where it's needed most.
849%
850\let\implicitmath = $%$ font-lock fix
851% 1036%
852% One complication: _ usually means subscripts, but it could also mean 1037% One complication: _ usually means subscripts, but it could also mean
853% an actual _ character, as in @math{@var{some_variable} + 1}. So make 1038% an actual _ character, as in @math{@var{some_variable} + 1}. So make
854% _ within @math be active (mathcode "8000), and distinguish by seeing 1039% _ active, and distinguish by seeing if the current family is \slfam,
855% if the current family is \slfam, which is what @var uses. 1040% which is what @var uses.
856% 1041{
857{\catcode95 = \active % 95 = _ 1042 \catcode`\_ = \active
858\gdef\mathunderscore{% 1043 \gdef\mathunderscore{%
859 \catcode95=\active 1044 \catcode`\_=\active
860 \def_{\ifnum\fam=\slfam \_\else\sb\fi}% 1045 \def_{\ifnum\fam=\slfam \_\else\sb\fi}%
861}} 1046 }
862% 1047}
863% Another complication: we want \\ (and @\) to output a \ character. 1048% Another complication: we want \\ (and @\) to output a \ character.
864% FYI, plain.tex uses \\ as a temporary control sequence (why?), but 1049% FYI, plain.tex uses \\ as a temporary control sequence (why?), but
865% this is not advertised and we don't care. Texinfo does not 1050% this is not advertised and we don't care. Texinfo does not
@@ -870,14 +1055,58 @@ where each line of input produces a line of output.}
870% 1055%
871\def\math{% 1056\def\math{%
872 \tex 1057 \tex
873 \mathcode`\_="8000 \mathunderscore 1058 \mathunderscore
874 \let\\ = \mathbackslash 1059 \let\\ = \mathbackslash
875 \implicitmath\finishmath} 1060 \mathactive
876\def\finishmath#1{#1\implicitmath\Etex} 1061 $\finishmath
1062}
1063\def\finishmath#1{#1$\endgroup} % Close the group opened by \tex.
1064
1065% Some active characters (such as <) are spaced differently in math.
1066% We have to reset their definitions in case the @math was an argument
1067% to a command which sets the catcodes (such as @item or @section).
1068%
1069{
1070 \catcode`^ = \active
1071 \catcode`< = \active
1072 \catcode`> = \active
1073 \catcode`+ = \active
1074 \gdef\mathactive{%
1075 \let^ = \ptexhat
1076 \let< = \ptexless
1077 \let> = \ptexgtr
1078 \let+ = \ptexplus
1079 }
1080}
877 1081
878% @bullet and @minus need the same treatment as @math, just above. 1082% @bullet and @minus need the same treatment as @math, just above.
879\def\bullet{\implicitmath\ptexbullet\implicitmath} 1083\def\bullet{$\ptexbullet$}
880\def\minus{\implicitmath-\implicitmath} 1084\def\minus{$-$}
1085
1086% @dots{} outputs an ellipsis using the current font.
1087% We do .5em per period so that it has the same spacing in a typewriter
1088% font as three actual period characters.
1089%
1090\def\dots{%
1091 \leavevmode
1092 \hbox to 1.5em{%
1093 \hskip 0pt plus 0.25fil
1094 .\hfil.\hfil.%
1095 \hskip 0pt plus 0.5fil
1096 }%
1097}
1098
1099% @enddots{} is an end-of-sentence ellipsis.
1100%
1101\def\enddots{%
1102 \dots
1103 \spacefactor=\endofsentencespacefactor
1104}
1105
1106% @comma{} is so commas can be inserted into text without messing up
1107% Texinfo's parsing.
1108%
1109\let\comma = ,
881 1110
882% @refill is a no-op. 1111% @refill is a no-op.
883\let\refill=\relax 1112\let\refill=\relax
@@ -893,20 +1122,20 @@ where each line of input produces a line of output.}
893% So open here the files we need to have open while reading the input. 1122% So open here the files we need to have open while reading the input.
894% This makes it possible to make a .fmt file for texinfo. 1123% This makes it possible to make a .fmt file for texinfo.
895\def\setfilename{% 1124\def\setfilename{%
1125 \fixbackslash % Turn off hack to swallow `\input texinfo'.
896 \iflinks 1126 \iflinks
897 \readauxfile 1127 \tryauxfile
1128 % Open the new aux file. TeX will close it automatically at exit.
1129 \immediate\openout\auxfile=\jobname.aux
898 \fi % \openindices needs to do some work in any case. 1130 \fi % \openindices needs to do some work in any case.
899 \openindices 1131 \openindices
900 \fixbackslash % Turn off hack to swallow `\input texinfo'. 1132 \let\setfilename=\comment % Ignore extra @setfilename cmds.
901 \global\let\setfilename=\comment % Ignore extra @setfilename cmds.
902 % 1133 %
903 % If texinfo.cnf is present on the system, read it. 1134 % If texinfo.cnf is present on the system, read it.
904 % Useful for site-wide @afourpaper, etc. 1135 % Useful for site-wide @afourpaper, etc.
905 % Just to be on the safe side, close the input stream before the \input.
906 \openin 1 texinfo.cnf 1136 \openin 1 texinfo.cnf
907 \ifeof1 \let\temp=\relax \else \def\temp{\input texinfo.cnf }\fi 1137 \ifeof 1 \else \input texinfo.cnf \fi
908 \closein1 1138 \closein 1
909 \temp
910 % 1139 %
911 \comment % Ignore the actual filename. 1140 \comment % Ignore the actual filename.
912} 1141}
@@ -942,17 +1171,72 @@ where each line of input produces a line of output.}
942\newif\ifpdf 1171\newif\ifpdf
943\newif\ifpdfmakepagedest 1172\newif\ifpdfmakepagedest
944 1173
1174% when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1
1175% can be set). So we test for \relax and 0 as well as \undefined,
1176% borrowed from ifpdf.sty.
945\ifx\pdfoutput\undefined 1177\ifx\pdfoutput\undefined
946 \pdffalse
947 \let\pdfmkdest = \gobble
948 \let\pdfurl = \gobble
949 \let\endlink = \relax
950 \let\linkcolor = \relax
951 \let\pdfmakeoutlines = \relax
952\else 1178\else
953 \pdftrue 1179 \ifx\pdfoutput\relax
954 \pdfoutput = 1 1180 \else
1181 \ifcase\pdfoutput
1182 \else
1183 \pdftrue
1184 \fi
1185 \fi
1186\fi
1187
1188% PDF uses PostScript string constants for the names of xref targets,
1189% for display in the outlines, and in other places. Thus, we have to
1190% double any backslashes. Otherwise, a name like "\node" will be
1191% interpreted as a newline (\n), followed by o, d, e. Not good.
1192% http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html
1193% (and related messages, the final outcome is that it is up to the TeX
1194% user to double the backslashes and otherwise make the string valid, so
1195% that's what we do).
1196
1197% double active backslashes.
1198%
1199{\catcode`\@=0 \catcode`\\=\active
1200 @gdef@activebackslashdouble{%
1201 @catcode`@\=@active
1202 @let\=@doublebackslash}
1203}
1204
1205% To handle parens, we must adopt a different approach, since parens are
1206% not active characters. hyperref.dtx (which has the same problem as
1207% us) handles it with this amazing macro to replace tokens. I've
1208% tinkered with it a little for texinfo, but it's definitely from there.
1209%
1210% #1 is the tokens to replace.
1211% #2 is the replacement.
1212% #3 is the control sequence with the string.
1213%
1214\def\HyPsdSubst#1#2#3{%
1215 \def\HyPsdReplace##1#1##2\END{%
1216 ##1%
1217 \ifx\\##2\\%
1218 \else
1219 #2%
1220 \HyReturnAfterFi{%
1221 \HyPsdReplace##2\END
1222 }%
1223 \fi
1224 }%
1225 \xdef#3{\expandafter\HyPsdReplace#3#1\END}%
1226}
1227\long\def\HyReturnAfterFi#1\fi{\fi#1}
1228
1229% #1 is a control sequence in which to do the replacements.
1230\def\backslashparens#1{%
1231 \xdef#1{#1}% redefine it as its expansion; the definition is simply
1232 % \lastnode when called from \setref -> \pdfmkdest.
1233 \HyPsdSubst{(}{\realbackslash(}{#1}%
1234 \HyPsdSubst{)}{\realbackslash)}{#1}%
1235}
1236
1237\ifpdf
955 \input pdfcolor 1238 \input pdfcolor
1239 \pdfcatalog{/PageMode /UseOutlines}%
956 \def\dopdfimage#1#2#3{% 1240 \def\dopdfimage#1#2#3{%
957 \def\imagewidth{#2}% 1241 \def\imagewidth{#2}%
958 \def\imageheight{#3}% 1242 \def\imageheight{#3}%
@@ -966,15 +1250,26 @@ where each line of input produces a line of output.}
966 \ifx\empty\imagewidth\else width \imagewidth \fi 1250 \ifx\empty\imagewidth\else width \imagewidth \fi
967 \ifx\empty\imageheight\else height \imageheight \fi 1251 \ifx\empty\imageheight\else height \imageheight \fi
968 \ifnum\pdftexversion<13 1252 \ifnum\pdftexversion<13
969 #1.pdf% 1253 #1.pdf%
970 \else 1254 \else
971 {#1.pdf}% 1255 {#1.pdf}%
972 \fi 1256 \fi
973 \ifnum\pdftexversion < 14 \else 1257 \ifnum\pdftexversion < 14 \else
974 \pdfrefximage \pdflastximage 1258 \pdfrefximage \pdflastximage
975 \fi} 1259 \fi}
976 \def\pdfmkdest#1{{\normalturnoffactive \pdfdest name{#1} xyz}} 1260 \def\pdfmkdest#1{{%
977 \def\pdfmkpgn#1{#1} 1261 % We have to set dummies so commands such as @code, and characters
1262 % such as \, aren't expanded when present in a section title.
1263 \atdummies
1264 \activebackslashdouble
1265 \def\pdfdestname{#1}%
1266 \backslashparens\pdfdestname
1267 \pdfdest name{\pdfdestname} xyz%
1268 }}%
1269 %
1270 % used to mark target names; must be expandable.
1271 \def\pdfmkpgn#1{#1}%
1272 %
978 \let\linkcolor = \Blue % was Cyan, but that seems light? 1273 \let\linkcolor = \Blue % was Cyan, but that seems light?
979 \def\endlink{\Black\pdfendlink} 1274 \def\endlink{\Black\pdfendlink}
980 % Adding outlines to PDF; macros for calculating structure of outlines 1275 % Adding outlines to PDF; macros for calculating structure of outlines
@@ -982,80 +1277,106 @@ where each line of input produces a line of output.}
982 \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0% 1277 \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
983 \else \csname#1\endcsname \fi} 1278 \else \csname#1\endcsname \fi}
984 \def\advancenumber#1{\tempnum=\expnumber{#1}\relax 1279 \def\advancenumber#1{\tempnum=\expnumber{#1}\relax
985 \advance\tempnum by1 1280 \advance\tempnum by 1
986 \expandafter\xdef\csname#1\endcsname{\the\tempnum}} 1281 \expandafter\xdef\csname#1\endcsname{\the\tempnum}}
987 \def\pdfmakeoutlines{{% 1282 %
988 \openin 1 \jobname.toc 1283 % #1 is the section text, which is what will be displayed in the
989 \ifeof 1\else\begingroup 1284 % outline by the pdf viewer. #2 is the pdf expression for the number
990 \closein 1 1285 % of subentries (or empty, for subsubsections). #3 is the node text,
991 \indexnofonts 1286 % which might be empty if this toc entry had no corresponding node.
992 \def\tt{} 1287 % #4 is the page number
993 \let\_ = \normalunderscore 1288 %
1289 \def\dopdfoutline#1#2#3#4{%
1290 % Generate a link to the node text if that exists; else, use the
1291 % page number. We could generate a destination for the section
1292 % text in the case where a section has no node, but it doesn't
1293 % seem worth the trouble, since most documents are normally structured.
1294 \def\pdfoutlinedest{#3}%
1295 \ifx\pdfoutlinedest\empty
1296 \def\pdfoutlinedest{#4}%
1297 \else
1298 % Doubled backslashes in the name.
1299 {\activebackslashdouble \xdef\pdfoutlinedest{#3}%
1300 \backslashparens\pdfoutlinedest}%
1301 \fi
1302 %
1303 % Also double the backslashes in the display string.
1304 {\activebackslashdouble \xdef\pdfoutlinetext{#1}%
1305 \backslashparens\pdfoutlinetext}%
1306 %
1307 \pdfoutline goto name{\pdfmkpgn{\pdfoutlinedest}}#2{\pdfoutlinetext}%
1308 }
1309 %
1310 \def\pdfmakeoutlines{%
1311 \begingroup
994 % Thanh's hack / proper braces in bookmarks 1312 % Thanh's hack / proper braces in bookmarks
995 \edef\mylbrace{\iftrue \string{\else}\fi}\let\{=\mylbrace 1313 \edef\mylbrace{\iftrue \string{\else}\fi}\let\{=\mylbrace
996 \edef\myrbrace{\iffalse{\else\string}\fi}\let\}=\myrbrace 1314 \edef\myrbrace{\iffalse{\else\string}\fi}\let\}=\myrbrace
997 % 1315 %
998 \def\chapentry ##1##2##3{} 1316 % Read toc silently, to get counts of subentries for \pdfoutline.
999 \let\appendixentry = \chapentry 1317 \def\numchapentry##1##2##3##4{%
1000 \def\unnumbchapentry ##1##2{} 1318 \def\thischapnum{##2}%
1001 \def\secentry ##1##2##3##4{\advancenumber{chap##2}} 1319 \def\thissecnum{0}%
1002 \def\unnumbsecentry ##1##2##3{\advancenumber{chap##2}} 1320 \def\thissubsecnum{0}%
1003 \def\subsecentry ##1##2##3##4##5{\advancenumber{sec##2.##3}} 1321 }%
1004 \def\unnumbsubsecentry ##1##2##3##4{\advancenumber{sec##2.##3}} 1322 \def\numsecentry##1##2##3##4{%
1005 \def\subsubsecentry ##1##2##3##4##5##6{\advancenumber{subsec##2.##3.##4}} 1323 \advancenumber{chap\thischapnum}%
1006 \def\unnumbsubsubsecentry ##1##2##3##4##5{\advancenumber{subsec##2.##3.##4}} 1324 \def\thissecnum{##2}%
1007 \input \jobname.toc 1325 \def\thissubsecnum{0}%
1008 \def\chapentry ##1##2##3{% 1326 }%
1009 \pdfoutline goto name{\pdfmkpgn{##3}}count-\expnumber{chap##2}{##1}} 1327 \def\numsubsecentry##1##2##3##4{%
1010 \let\appendixentry = \chapentry 1328 \advancenumber{sec\thissecnum}%
1011 \def\unnumbchapentry ##1##2{% 1329 \def\thissubsecnum{##2}%
1012 \pdfoutline goto name{\pdfmkpgn{##2}}{##1}} 1330 }%
1013 \def\secentry ##1##2##3##4{% 1331 \def\numsubsubsecentry##1##2##3##4{%
1014 \pdfoutline goto name{\pdfmkpgn{##4}}count-\expnumber{sec##2.##3}{##1}} 1332 \advancenumber{subsec\thissubsecnum}%
1015 \def\unnumbsecentry ##1##2##3{% 1333 }%
1016 \pdfoutline goto name{\pdfmkpgn{##3}}{##1}} 1334 \def\thischapnum{0}%
1017 \def\subsecentry ##1##2##3##4##5{% 1335 \def\thissecnum{0}%
1018 \pdfoutline goto name{\pdfmkpgn{##5}}count-\expnumber{subsec##2.##3.##4}{##1}} 1336 \def\thissubsecnum{0}%
1019 \def\unnumbsubsecentry ##1##2##3##4{% 1337 %
1020 \pdfoutline goto name{\pdfmkpgn{##4}}{##1}} 1338 % use \def rather than \let here because we redefine \chapentry et
1021 \def\subsubsecentry ##1##2##3##4##5##6{% 1339 % al. a second time, below.
1022 \pdfoutline goto name{\pdfmkpgn{##6}}{##1}} 1340 \def\appentry{\numchapentry}%
1023 \def\unnumbsubsubsecentry ##1##2##3##4##5{% 1341 \def\appsecentry{\numsecentry}%
1024 \pdfoutline goto name{\pdfmkpgn{##5}}{##1}} 1342 \def\appsubsecentry{\numsubsecentry}%
1343 \def\appsubsubsecentry{\numsubsubsecentry}%
1344 \def\unnchapentry{\numchapentry}%
1345 \def\unnsecentry{\numsecentry}%
1346 \def\unnsubsecentry{\numsubsecentry}%
1347 \def\unnsubsubsecentry{\numsubsubsecentry}%
1348 \readdatafile{toc}%
1349 %
1350 % Read toc second time, this time actually producing the outlines.
1351 % The `-' means take the \expnumber as the absolute number of
1352 % subentries, which we calculated on our first read of the .toc above.
1353 %
1354 % We use the node names as the destinations.
1355 \def\numchapentry##1##2##3##4{%
1356 \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}%
1357 \def\numsecentry##1##2##3##4{%
1358 \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}%
1359 \def\numsubsecentry##1##2##3##4{%
1360 \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}%
1361 \def\numsubsubsecentry##1##2##3##4{% count is always zero
1362 \dopdfoutline{##1}{}{##3}{##4}}%
1363 %
1364 % PDF outlines are displayed using system fonts, instead of
1365 % document fonts. Therefore we cannot use special characters,
1366 % since the encoding is unknown. For example, the eogonek from
1367 % Latin 2 (0xea) gets translated to a | character. Info from
1368 % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100.
1369 %
1370 % xx to do this right, we have to translate 8-bit characters to
1371 % their "best" equivalent, based on the @documentencoding. Right
1372 % now, I guess we'll just let the pdf reader have its way.
1373 \indexnofonts
1374 \setupdatafile
1375 \catcode`\\=\active \otherbackslash
1025 \input \jobname.toc 1376 \input \jobname.toc
1026 \endgroup\fi 1377 \endgroup
1027 }}
1028 \def\makelinks #1,{%
1029 \def\params{#1}\def\E{END}%
1030 \ifx\params\E
1031 \let\nextmakelinks=\relax
1032 \else
1033 \let\nextmakelinks=\makelinks
1034 \ifnum\lnkcount>0,\fi
1035 \picknum{#1}%
1036 \startlink attr{/Border [0 0 0]}
1037 goto name{\pdfmkpgn{\the\pgn}}%
1038 \linkcolor #1%
1039 \advance\lnkcount by 1%
1040 \endlink
1041 \fi
1042 \nextmakelinks
1043 }
1044 \def\picknum#1{\expandafter\pn#1}
1045 \def\pn#1{%
1046 \def\p{#1}%
1047 \ifx\p\lbrace
1048 \let\nextpn=\ppn
1049 \else
1050 \let\nextpn=\ppnn
1051 \def\first{#1}
1052 \fi
1053 \nextpn
1054 } 1378 }
1055 \def\ppn#1{\pgn=#1\gobble} 1379 %
1056 \def\ppnn{\pgn=\first}
1057 \def\pdfmklnk#1{\lnkcount=0\makelinks #1,END,}
1058 \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1059 \def\skipspaces#1{\def\PP{#1}\def\D{|}% 1380 \def\skipspaces#1{\def\PP{#1}\def\D{|}%
1060 \ifx\PP\D\let\nextsp\relax 1381 \ifx\PP\D\let\nextsp\relax
1061 \else\let\nextsp\skipspaces 1382 \else\let\nextsp\skipspaces
@@ -1070,21 +1391,28 @@ where each line of input produces a line of output.}
1070 \else 1391 \else
1071 \let \startlink \pdfstartlink 1392 \let \startlink \pdfstartlink
1072 \fi 1393 \fi
1394 % make a live url in pdf output.
1073 \def\pdfurl#1{% 1395 \def\pdfurl#1{%
1074 \begingroup 1396 \begingroup
1075 \normalturnoffactive\def\@{@}% 1397 % it seems we really need yet another set of dummies; have not
1076 \let\value=\expandablevalue 1398 % tried to figure out what each command should do in the context
1399 % of @url. for now, just make @/ a no-op, that's the only one
1400 % people have actually reported a problem with.
1401 %
1402 \normalturnoffactive
1403 \def\@{@}%
1404 \let\/=\empty
1405 \makevalueexpandable
1077 \leavevmode\Red 1406 \leavevmode\Red
1078 \startlink attr{/Border [0 0 0]}% 1407 \startlink attr{/Border [0 0 0]}%
1079 user{/Subtype /Link /A << /S /URI /URI (#1) >>}% 1408 user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
1080 % #1
1081 \endgroup} 1409 \endgroup}
1082 \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}} 1410 \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
1083 \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks} 1411 \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
1084 \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks} 1412 \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
1085 \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}} 1413 \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
1086 \def\maketoks{% 1414 \def\maketoks{%
1087 \expandafter\poptoks\the\toksA|ENDTOKS| 1415 \expandafter\poptoks\the\toksA|ENDTOKS|\relax
1088 \ifx\first0\adn0 1416 \ifx\first0\adn0
1089 \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3 1417 \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
1090 \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6 1418 \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
@@ -1104,20 +1432,44 @@ where each line of input produces a line of output.}
1104 \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}} 1432 \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}}
1105 \linkcolor #1\endlink} 1433 \linkcolor #1\endlink}
1106 \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st} 1434 \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
1107\fi % \ifx\pdfoutput 1435\else
1436 \let\pdfmkdest = \gobble
1437 \let\pdfurl = \gobble
1438 \let\endlink = \relax
1439 \let\linkcolor = \relax
1440 \let\pdfmakeoutlines = \relax
1441\fi % \ifx\pdfoutput
1108 1442
1109 1443
1110\message{fonts,} 1444\message{fonts,}
1111% Font-change commands. 1445
1446% Change the current font style to #1, remembering it in \curfontstyle.
1447% For now, we do not accumulate font styles: @b{@i{foo}} prints foo in
1448% italics, not bold italics.
1449%
1450\def\setfontstyle#1{%
1451 \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd.
1452 \csname ten#1\endcsname % change the current font
1453}
1454
1455% Select #1 fonts with the current style.
1456%
1457\def\selectfonts#1{\csname #1fonts\endcsname \csname\curfontstyle\endcsname}
1458
1459\def\rm{\fam=0 \setfontstyle{rm}}
1460\def\it{\fam=\itfam \setfontstyle{it}}
1461\def\sl{\fam=\slfam \setfontstyle{sl}}
1462\def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf}
1463\def\tt{\fam=\ttfam \setfontstyle{tt}}
1112 1464
1113% Texinfo sort of supports the sans serif font style, which plain TeX does not. 1465% Texinfo sort of supports the sans serif font style, which plain TeX does not.
1114% So we set up a \sf analogous to plain's \rm, etc. 1466% So we set up a \sf.
1115\newfam\sffam 1467\newfam\sffam
1116\def\sf{\fam=\sffam \tensf} 1468\def\sf{\fam=\sffam \setfontstyle{sf}}
1117\let\li = \sf % Sometimes we call it \li, not \sf. 1469\let\li = \sf % Sometimes we call it \li, not \sf.
1118 1470
1119% We don't need math for this one. 1471% We don't need math for this font style.
1120\def\ttsl{\tenttsl} 1472\def\ttsl{\setfontstyle{ttsl}}
1121 1473
1122% Default leading. 1474% Default leading.
1123\newdimen\textleading \textleading = 13.2pt 1475\newdimen\textleading \textleading = 13.2pt
@@ -1168,20 +1520,11 @@ where each line of input produces a line of output.}
1168\def\scshape{csc} 1520\def\scshape{csc}
1169\def\scbshape{csc} 1521\def\scbshape{csc}
1170 1522
1171\newcount\mainmagstep 1523% Text fonts (11.2pt, magstep1).
1172\ifx\bigger\relax 1524\def\textnominalsize{11pt}
1173 % not really supported. 1525\edef\mainmagstep{\magstephalf}
1174 \let\mainmagstep=\magstep1 1526\setfont\textrm\rmshape{10}{\mainmagstep}
1175 \setfont\textrm\rmshape{12}{1000} 1527\setfont\texttt\ttshape{10}{\mainmagstep}
1176 \setfont\texttt\ttshape{12}{1000}
1177\else
1178 \mainmagstep=\magstephalf
1179 \setfont\textrm\rmshape{10}{\mainmagstep}
1180 \setfont\texttt\ttshape{10}{\mainmagstep}
1181\fi
1182% Instead of cmb10, you many want to use cmbx10.
1183% cmbx10 is a prettier font on its own, but cmb10
1184% looks better when embedded in a line with cmr10.
1185\setfont\textbf\bfshape{10}{\mainmagstep} 1528\setfont\textbf\bfshape{10}{\mainmagstep}
1186\setfont\textit\itshape{10}{\mainmagstep} 1529\setfont\textit\itshape{10}{\mainmagstep}
1187\setfont\textsl\slshape{10}{\mainmagstep} 1530\setfont\textsl\slshape{10}{\mainmagstep}
@@ -1191,12 +1534,14 @@ where each line of input produces a line of output.}
1191\font\texti=cmmi10 scaled \mainmagstep 1534\font\texti=cmmi10 scaled \mainmagstep
1192\font\textsy=cmsy10 scaled \mainmagstep 1535\font\textsy=cmsy10 scaled \mainmagstep
1193 1536
1194% A few fonts for @defun, etc. 1537% A few fonts for @defun names and args.
1195\setfont\defbf\bxshape{10}{\magstep1} %was 1314 1538\setfont\defbf\bfshape{10}{\magstep1}
1196\setfont\deftt\ttshape{10}{\magstep1} 1539\setfont\deftt\ttshape{10}{\magstep1}
1197\def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf} 1540\setfont\defttsl\ttslshape{10}{\magstep1}
1541\def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf}
1198 1542
1199% Fonts for indices, footnotes, small examples (9pt). 1543% Fonts for indices, footnotes, small examples (9pt).
1544\def\smallnominalsize{9pt}
1200\setfont\smallrm\rmshape{9}{1000} 1545\setfont\smallrm\rmshape{9}{1000}
1201\setfont\smalltt\ttshape{9}{1000} 1546\setfont\smalltt\ttshape{9}{1000}
1202\setfont\smallbf\bfshape{10}{900} 1547\setfont\smallbf\bfshape{10}{900}
@@ -1209,6 +1554,7 @@ where each line of input produces a line of output.}
1209\font\smallsy=cmsy9 1554\font\smallsy=cmsy9
1210 1555
1211% Fonts for small examples (8pt). 1556% Fonts for small examples (8pt).
1557\def\smallernominalsize{8pt}
1212\setfont\smallerrm\rmshape{8}{1000} 1558\setfont\smallerrm\rmshape{8}{1000}
1213\setfont\smallertt\ttshape{8}{1000} 1559\setfont\smallertt\ttshape{8}{1000}
1214\setfont\smallerbf\bfshape{10}{800} 1560\setfont\smallerbf\bfshape{10}{800}
@@ -1220,7 +1566,8 @@ where each line of input produces a line of output.}
1220\font\smalleri=cmmi8 1566\font\smalleri=cmmi8
1221\font\smallersy=cmsy8 1567\font\smallersy=cmsy8
1222 1568
1223% Fonts for title page: 1569% Fonts for title page (20.4pt):
1570\def\titlenominalsize{20pt}
1224\setfont\titlerm\rmbshape{12}{\magstep3} 1571\setfont\titlerm\rmbshape{12}{\magstep3}
1225\setfont\titleit\itbshape{10}{\magstep4} 1572\setfont\titleit\itbshape{10}{\magstep4}
1226\setfont\titlesl\slbshape{10}{\magstep4} 1573\setfont\titlesl\slbshape{10}{\magstep4}
@@ -1232,8 +1579,10 @@ where each line of input produces a line of output.}
1232\font\titlei=cmmi12 scaled \magstep3 1579\font\titlei=cmmi12 scaled \magstep3
1233\font\titlesy=cmsy10 scaled \magstep4 1580\font\titlesy=cmsy10 scaled \magstep4
1234\def\authorrm{\secrm} 1581\def\authorrm{\secrm}
1582\def\authortt{\sectt}
1235 1583
1236% Chapter (and unnumbered) fonts (17.28pt). 1584% Chapter (and unnumbered) fonts (17.28pt).
1585\def\chapnominalsize{17pt}
1237\setfont\chaprm\rmbshape{12}{\magstep2} 1586\setfont\chaprm\rmbshape{12}{\magstep2}
1238\setfont\chapit\itbshape{10}{\magstep3} 1587\setfont\chapit\itbshape{10}{\magstep3}
1239\setfont\chapsl\slbshape{10}{\magstep3} 1588\setfont\chapsl\slbshape{10}{\magstep3}
@@ -1246,6 +1595,7 @@ where each line of input produces a line of output.}
1246\font\chapsy=cmsy10 scaled \magstep3 1595\font\chapsy=cmsy10 scaled \magstep3
1247 1596
1248% Section fonts (14.4pt). 1597% Section fonts (14.4pt).
1598\def\secnominalsize{14pt}
1249\setfont\secrm\rmbshape{12}{\magstep1} 1599\setfont\secrm\rmbshape{12}{\magstep1}
1250\setfont\secit\itbshape{10}{\magstep2} 1600\setfont\secit\itbshape{10}{\magstep2}
1251\setfont\secsl\slbshape{10}{\magstep2} 1601\setfont\secsl\slbshape{10}{\magstep2}
@@ -1258,6 +1608,7 @@ where each line of input produces a line of output.}
1258\font\secsy=cmsy10 scaled \magstep2 1608\font\secsy=cmsy10 scaled \magstep2
1259 1609
1260% Subsection fonts (13.15pt). 1610% Subsection fonts (13.15pt).
1611\def\ssecnominalsize{13pt}
1261\setfont\ssecrm\rmbshape{12}{\magstephalf} 1612\setfont\ssecrm\rmbshape{12}{\magstephalf}
1262\setfont\ssecit\itbshape{10}{1315} 1613\setfont\ssecit\itbshape{10}{1315}
1263\setfont\ssecsl\slbshape{10}{1315} 1614\setfont\ssecsl\slbshape{10}{1315}
@@ -1265,11 +1616,22 @@ where each line of input produces a line of output.}
1265\setfont\ssecttsl\ttslshape{10}{1315} 1616\setfont\ssecttsl\ttslshape{10}{1315}
1266\setfont\ssecsf\sfbshape{12}{\magstephalf} 1617\setfont\ssecsf\sfbshape{12}{\magstephalf}
1267\let\ssecbf\ssecrm 1618\let\ssecbf\ssecrm
1268\setfont\ssecsc\scbshape{10}{\magstep1} 1619\setfont\ssecsc\scbshape{10}{1315}
1269\font\sseci=cmmi12 scaled \magstephalf 1620\font\sseci=cmmi12 scaled \magstephalf
1270\font\ssecsy=cmsy10 scaled 1315 1621\font\ssecsy=cmsy10 scaled 1315
1271% The smallcaps and symbol fonts should actually be scaled \magstep1.5, 1622
1272% but that is not a standard magnification. 1623% Reduced fonts for @acro in text (10pt).
1624\def\reducednominalsize{10pt}
1625\setfont\reducedrm\rmshape{10}{1000}
1626\setfont\reducedtt\ttshape{10}{1000}
1627\setfont\reducedbf\bfshape{10}{1000}
1628\setfont\reducedit\itshape{10}{1000}
1629\setfont\reducedsl\slshape{10}{1000}
1630\setfont\reducedsf\sfshape{10}{1000}
1631\setfont\reducedsc\scshape{10}{1000}
1632\setfont\reducedttsl\ttslshape{10}{1000}
1633\font\reducedi=cmmi10
1634\font\reducedsy=cmsy10
1273 1635
1274% In order for the font changes to affect most math symbols and letters, 1636% In order for the font changes to affect most math symbols and letters,
1275% we have to define the \textfont of the standard families. Since 1637% we have to define the \textfont of the standard families. Since
@@ -1284,56 +1646,104 @@ where each line of input produces a line of output.}
1284} 1646}
1285 1647
1286% The font-changing commands redefine the meanings of \tenSTYLE, instead 1648% The font-changing commands redefine the meanings of \tenSTYLE, instead
1287% of just \STYLE. We do this so that font changes will continue to work 1649% of just \STYLE. We do this because \STYLE needs to also set the
1288% in math mode, where it is the current \fam that is relevant in most 1650% current \fam for math mode. Our \STYLE (e.g., \rm) commands hardwire
1289% cases, not the current font. Plain TeX does \def\bf{\fam=\bffam 1651% \tenSTYLE to set the current font.
1290% \tenbf}, for example. By redefining \tenbf, we obviate the need to 1652%
1291% redefine \bf itself. 1653% Each font-changing command also sets the names \lsize (one size lower)
1654% and \lllsize (three sizes lower). These relative commands are used in
1655% the LaTeX logo and acronyms.
1656%
1657% This all needs generalizing, badly.
1658%
1292\def\textfonts{% 1659\def\textfonts{%
1293 \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl 1660 \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
1294 \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc 1661 \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
1295 \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy \let\tenttsl=\textttsl 1662 \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy
1663 \let\tenttsl=\textttsl
1664 \def\curfontsize{text}%
1665 \def\lsize{reduced}\def\lllsize{smaller}%
1296 \resetmathfonts \setleading{\textleading}} 1666 \resetmathfonts \setleading{\textleading}}
1297\def\titlefonts{% 1667\def\titlefonts{%
1298 \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl 1668 \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl
1299 \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc 1669 \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc
1300 \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy 1670 \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy
1301 \let\tenttsl=\titlettsl 1671 \let\tenttsl=\titlettsl
1672 \def\curfontsize{title}%
1673 \def\lsize{chap}\def\lllsize{subsec}%
1302 \resetmathfonts \setleading{25pt}} 1674 \resetmathfonts \setleading{25pt}}
1303\def\titlefont#1{{\titlefonts\rm #1}} 1675\def\titlefont#1{{\titlefonts\rm #1}}
1304\def\chapfonts{% 1676\def\chapfonts{%
1305 \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl 1677 \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl
1306 \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc 1678 \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
1307 \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy \let\tenttsl=\chapttsl 1679 \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy
1680 \let\tenttsl=\chapttsl
1681 \def\curfontsize{chap}%
1682 \def\lsize{sec}\def\lllsize{text}%
1308 \resetmathfonts \setleading{19pt}} 1683 \resetmathfonts \setleading{19pt}}
1309\def\secfonts{% 1684\def\secfonts{%
1310 \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl 1685 \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl
1311 \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc 1686 \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc
1312 \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy \let\tenttsl=\secttsl 1687 \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy
1688 \let\tenttsl=\secttsl
1689 \def\curfontsize{sec}%
1690 \def\lsize{subsec}\def\lllsize{reduced}%
1313 \resetmathfonts \setleading{16pt}} 1691 \resetmathfonts \setleading{16pt}}
1314\def\subsecfonts{% 1692\def\subsecfonts{%
1315 \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl 1693 \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl
1316 \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc 1694 \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc
1317 \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy \let\tenttsl=\ssecttsl 1695 \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy
1696 \let\tenttsl=\ssecttsl
1697 \def\curfontsize{ssec}%
1698 \def\lsize{text}\def\lllsize{small}%
1318 \resetmathfonts \setleading{15pt}} 1699 \resetmathfonts \setleading{15pt}}
1319\let\subsubsecfonts = \subsecfonts % Maybe make sssec fonts scaled magstephalf? 1700\let\subsubsecfonts = \subsecfonts
1701\def\reducedfonts{%
1702 \let\tenrm=\reducedrm \let\tenit=\reducedit \let\tensl=\reducedsl
1703 \let\tenbf=\reducedbf \let\tentt=\reducedtt \let\reducedcaps=\reducedsc
1704 \let\tensf=\reducedsf \let\teni=\reducedi \let\tensy=\reducedsy
1705 \let\tenttsl=\reducedttsl
1706 \def\curfontsize{reduced}%
1707 \def\lsize{small}\def\lllsize{smaller}%
1708 \resetmathfonts \setleading{10.5pt}}
1320\def\smallfonts{% 1709\def\smallfonts{%
1321 \let\tenrm=\smallrm \let\tenit=\smallit \let\tensl=\smallsl 1710 \let\tenrm=\smallrm \let\tenit=\smallit \let\tensl=\smallsl
1322 \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc 1711 \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc
1323 \let\tensf=\smallsf \let\teni=\smalli \let\tensy=\smallsy 1712 \let\tensf=\smallsf \let\teni=\smalli \let\tensy=\smallsy
1324 \let\tenttsl=\smallttsl 1713 \let\tenttsl=\smallttsl
1714 \def\curfontsize{small}%
1715 \def\lsize{smaller}\def\lllsize{smaller}%
1325 \resetmathfonts \setleading{10.5pt}} 1716 \resetmathfonts \setleading{10.5pt}}
1326\def\smallerfonts{% 1717\def\smallerfonts{%
1327 \let\tenrm=\smallerrm \let\tenit=\smallerit \let\tensl=\smallersl 1718 \let\tenrm=\smallerrm \let\tenit=\smallerit \let\tensl=\smallersl
1328 \let\tenbf=\smallerbf \let\tentt=\smallertt \let\smallcaps=\smallersc 1719 \let\tenbf=\smallerbf \let\tentt=\smallertt \let\smallcaps=\smallersc
1329 \let\tensf=\smallersf \let\teni=\smalleri \let\tensy=\smallersy 1720 \let\tensf=\smallersf \let\teni=\smalleri \let\tensy=\smallersy
1330 \let\tenttsl=\smallerttsl 1721 \let\tenttsl=\smallerttsl
1722 \def\curfontsize{smaller}%
1723 \def\lsize{smaller}\def\lllsize{smaller}%
1331 \resetmathfonts \setleading{9.5pt}} 1724 \resetmathfonts \setleading{9.5pt}}
1332\let\smallexamplefonts = \smallerfonts 1725
1726% Set the fonts to use with the @small... environments.
1727\let\smallexamplefonts = \smallfonts
1728
1729% About \smallexamplefonts. If we use \smallfonts (9pt), @smallexample
1730% can fit this many characters:
1731% 8.5x11=86 smallbook=72 a4=90 a5=69
1732% If we use \scriptfonts (8pt), then we can fit this many characters:
1733% 8.5x11=90+ smallbook=80 a4=90+ a5=77
1734% For me, subjectively, the few extra characters that fit aren't worth
1735% the additional smallness of 8pt. So I'm making the default 9pt.
1736%
1737% By the way, for comparison, here's what fits with @example (10pt):
1738% 8.5x11=71 smallbook=60 a4=75 a5=58
1739%
1740% I wish the USA used A4 paper.
1741% --karl, 24jan03.
1742
1333 1743
1334% Set up the default fonts, so we can use them for creating boxes. 1744% Set up the default fonts, so we can use them for creating boxes.
1335% 1745%
1336\textfonts 1746\textfonts \rm
1337 1747
1338% Define these so they can be easily changed for other fonts. 1748% Define these so they can be easily changed for other fonts.
1339\def\angleleft{$\langle$} 1749\def\angleleft{$\langle$}
@@ -1344,27 +1754,41 @@ where each line of input produces a line of output.}
1344 1754
1345% Fonts for short table of contents. 1755% Fonts for short table of contents.
1346\setfont\shortcontrm\rmshape{12}{1000} 1756\setfont\shortcontrm\rmshape{12}{1000}
1347\setfont\shortcontbf\bxshape{12}{1000} 1757\setfont\shortcontbf\bfshape{10}{\magstep1} % no cmb12
1348\setfont\shortcontsl\slshape{12}{1000} 1758\setfont\shortcontsl\slshape{12}{1000}
1759\setfont\shortconttt\ttshape{12}{1000}
1349 1760
1350%% Add scribe-like font environments, plus @l for inline lisp (usually sans 1761%% Add scribe-like font environments, plus @l for inline lisp (usually sans
1351%% serif) and @ii for TeX italic 1762%% serif) and @ii for TeX italic
1352 1763
1353% \smartitalic{ARG} outputs arg in italics, followed by an italic correction 1764% \smartitalic{ARG} outputs arg in italics, followed by an italic correction
1354% unless the following character is such as not to need one. 1765% unless the following character is such as not to need one.
1355\def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi} 1766\def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else
1356\def\smartslanted#1{{\sl #1}\futurelet\next\smartitalicx} 1767 \ptexslash\fi\fi\fi}
1357\def\smartitalic#1{{\it #1}\futurelet\next\smartitalicx} 1768\def\smartslanted#1{{\ifusingtt\ttsl\sl #1}\futurelet\next\smartitalicx}
1769\def\smartitalic#1{{\ifusingtt\ttsl\it #1}\futurelet\next\smartitalicx}
1770
1771% like \smartslanted except unconditionally uses \ttsl.
1772% @var is set to this for defun arguments.
1773\def\ttslanted#1{{\ttsl #1}\futurelet\next\smartitalicx}
1774
1775% like \smartslanted except unconditionally use \sl. We never want
1776% ttsl for book titles, do we?
1777\def\cite#1{{\sl #1}\futurelet\next\smartitalicx}
1358 1778
1359\let\i=\smartitalic 1779\let\i=\smartitalic
1780\let\slanted=\smartslanted
1360\let\var=\smartslanted 1781\let\var=\smartslanted
1361\let\dfn=\smartslanted 1782\let\dfn=\smartslanted
1362\let\emph=\smartitalic 1783\let\emph=\smartitalic
1363\let\cite=\smartslanted
1364 1784
1785% @b, explicit bold.
1365\def\b#1{{\bf #1}} 1786\def\b#1{{\bf #1}}
1366\let\strong=\b 1787\let\strong=\b
1367 1788
1789% @sansserif, explicit sans.
1790\def\sansserif#1{{\sf #1}}
1791
1368% We can't just use \exhyphenpenalty, because that only has effect at 1792% We can't just use \exhyphenpenalty, because that only has effect at
1369% the end of a paragraph. Restore normal hyphenation at the end of the 1793% the end of a paragraph. Restore normal hyphenation at the end of the
1370% group within which \nohyphenation is presumably called. 1794% group within which \nohyphenation is presumably called.
@@ -1372,11 +1796,35 @@ where each line of input produces a line of output.}
1372\def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation} 1796\def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation}
1373\def\restorehyphenation{\hyphenchar\font = `- } 1797\def\restorehyphenation{\hyphenchar\font = `- }
1374 1798
1799% Set sfcode to normal for the chars that usually have another value.
1800% Can't use plain's \frenchspacing because it uses the `\x notation, and
1801% sometimes \x has an active definition that messes things up.
1802%
1803\chardef\colonChar = `\:
1804\chardef\commaChar = `\,
1805\chardef\dotChar = `\.
1806\chardef\exclamChar= `\!
1807\chardef\questChar = `\?
1808\chardef\semiChar = `\;
1809%
1810\catcode`@=11
1811 \def\plainfrenchspacing{%
1812 \sfcode\dotChar =\@m \sfcode\questChar=\@m \sfcode\exclamChar=\@m
1813 \sfcode\colonChar=\@m \sfcode\semiChar =\@m \sfcode\commaChar =\@m
1814 \def\endofsentencespacefactor{1000}% for @. and friends
1815 }
1816 \def\plainnonfrenchspacing{%
1817 \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000
1818 \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250
1819 \def\endofsentencespacefactor{3000}% for @. and friends
1820 }
1821\catcode`@=\other
1822\def\endofsentencespacefactor{3000}% default
1823
1375\def\t#1{% 1824\def\t#1{%
1376 {\tt \rawbackslash \frenchspacing #1}% 1825 {\tt \rawbackslash \plainfrenchspacing #1}%
1377 \null 1826 \null
1378} 1827}
1379\let\ttfont=\t
1380\def\samp#1{`\tclose{#1}'\null} 1828\def\samp#1{`\tclose{#1}'\null}
1381\setfont\keyrm\rmshape{8}{1000} 1829\setfont\keyrm\rmshape{8}{1000}
1382\font\keysy=cmsy9 1830\font\keysy=cmsy9
@@ -1411,13 +1859,13 @@ where each line of input produces a line of output.}
1411 \nohyphenation 1859 \nohyphenation
1412 % 1860 %
1413 \rawbackslash 1861 \rawbackslash
1414 \frenchspacing 1862 \plainfrenchspacing
1415 #1% 1863 #1%
1416 }% 1864 }%
1417 \null 1865 \null
1418} 1866}
1419 1867
1420% We *must* turn on hyphenation at `-' and `_' in \code. 1868% We *must* turn on hyphenation at `-' and `_' in @code.
1421% Otherwise, it is too hard to avoid overfull hboxes 1869% Otherwise, it is too hard to avoid overfull hboxes
1422% in the Emacs manual, the Library manual, etc. 1870% in the Emacs manual, the Library manual, etc.
1423 1871
@@ -1431,14 +1879,16 @@ where each line of input produces a line of output.}
1431 \catcode`\_=\active 1879 \catcode`\_=\active
1432 % 1880 %
1433 \global\def\code{\begingroup 1881 \global\def\code{\begingroup
1434 \catcode`\-=\active \let-\codedash 1882 \catcode`\-=\active \catcode`\_=\active
1435 \catcode`\_=\active \let_\codeunder 1883 \ifallowcodebreaks
1884 \let-\codedash
1885 \let_\codeunder
1886 \else
1887 \let-\realdash
1888 \let_\realunder
1889 \fi
1436 \codex 1890 \codex
1437 } 1891 }
1438 %
1439 % If we end up with any active - characters when handling the index,
1440 % just treat them as a normal -.
1441 \global\def\indexbreaks{\catcode`\-=\active \let-\realdash}
1442} 1892}
1443 1893
1444\def\realdash{-} 1894\def\realdash{-}
@@ -1456,30 +1906,53 @@ where each line of input produces a line of output.}
1456} 1906}
1457\def\codex #1{\tclose{#1}\endgroup} 1907\def\codex #1{\tclose{#1}\endgroup}
1458 1908
1909% An additional complication: the above will allow breaks after, e.g.,
1910% each of the four underscores in __typeof__. This is undesirable in
1911% some manuals, especially if they don't have long identifiers in
1912% general. @allowcodebreaks provides a way to control this.
1913%
1914\newif\ifallowcodebreaks \allowcodebreakstrue
1915
1916\def\keywordtrue{true}
1917\def\keywordfalse{false}
1918
1919\parseargdef\allowcodebreaks{%
1920 \def\txiarg{#1}%
1921 \ifx\txiarg\keywordtrue
1922 \allowcodebreakstrue
1923 \else\ifx\txiarg\keywordfalse
1924 \allowcodebreaksfalse
1925 \else
1926 \errhelp = \EMsimple
1927 \errmessage{Unknown @allowcodebreaks option `\txiarg'}%
1928 \fi\fi
1929}
1930
1459% @kbd is like @code, except that if the argument is just one @key command, 1931% @kbd is like @code, except that if the argument is just one @key command,
1460% then @kbd has no effect. 1932% then @kbd has no effect.
1461 1933
1462% @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always), 1934% @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
1463% `example' (@kbd uses ttsl only inside of @example and friends), 1935% `example' (@kbd uses ttsl only inside of @example and friends),
1464% or `code' (@kbd uses normal tty font always). 1936% or `code' (@kbd uses normal tty font always).
1465\def\kbdinputstyle{\parsearg\kbdinputstylexxx} 1937\parseargdef\kbdinputstyle{%
1466\def\kbdinputstylexxx#1{% 1938 \def\txiarg{#1}%
1467 \def\arg{#1}% 1939 \ifx\txiarg\worddistinct
1468 \ifx\arg\worddistinct
1469 \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}% 1940 \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
1470 \else\ifx\arg\wordexample 1941 \else\ifx\txiarg\wordexample
1471 \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}% 1942 \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
1472 \else\ifx\arg\wordcode 1943 \else\ifx\txiarg\wordcode
1473 \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}% 1944 \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
1945 \else
1946 \errhelp = \EMsimple
1947 \errmessage{Unknown @kbdinputstyle option `\txiarg'}%
1474 \fi\fi\fi 1948 \fi\fi\fi
1475} 1949}
1476\def\worddistinct{distinct} 1950\def\worddistinct{distinct}
1477\def\wordexample{example} 1951\def\wordexample{example}
1478\def\wordcode{code} 1952\def\wordcode{code}
1479 1953
1480% Default is kbdinputdistinct. (Too much of a hassle to call the macro, 1954% Default is `distinct.'
1481% the catcodes are wrong for parsearg to work.) 1955\kbdinputstyle distinct
1482\gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}
1483 1956
1484\def\xkey{\key} 1957\def\xkey{\key}
1485\def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}% 1958\def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}%
@@ -1487,8 +1960,8 @@ where each line of input produces a line of output.}
1487\else{\tclose{\kbdfont\look}}\fi 1960\else{\tclose{\kbdfont\look}}\fi
1488\else{\tclose{\kbdfont\look}}\fi} 1961\else{\tclose{\kbdfont\look}}\fi}
1489 1962
1490% For @url, @env, @command quotes seem unnecessary, so use \code. 1963% For @indicateurl, @env, @command quotes seem unnecessary, so use \code.
1491\let\url=\code 1964\let\indicateurl=\code
1492\let\env=\code 1965\let\env=\code
1493\let\command=\code 1966\let\command=\code
1494 1967
@@ -1520,6 +1993,10 @@ where each line of input produces a line of output.}
1520 \endlink 1993 \endlink
1521\endgroup} 1994\endgroup}
1522 1995
1996% @url synonym for @uref, since that's how everyone uses it.
1997%
1998\let\url=\uref
1999
1523% rms does not like angle brackets --karl, 17may97. 2000% rms does not like angle brackets --karl, 17may97.
1524% So now @email is just like @uref, unless we are pdf. 2001% So now @email is just like @uref, unless we are pdf.
1525% 2002%
@@ -1561,12 +2038,101 @@ where each line of input produces a line of output.}
1561\def\sc#1{{\smallcaps#1}} % smallcaps font 2038\def\sc#1{{\smallcaps#1}} % smallcaps font
1562\def\ii#1{{\it #1}} % italic font 2039\def\ii#1{{\it #1}} % italic font
1563 2040
1564% @acronym downcases the argument and prints in smallcaps. 2041% @acronym for "FBI", "NATO", and the like.
1565\def\acronym#1{{\smallcaps \lowercase{#1}}} 2042% We print this one point size smaller, since it's intended for
2043% all-uppercase.
2044%
2045\def\acronym#1{\doacronym #1,,\finish}
2046\def\doacronym#1,#2,#3\finish{%
2047 {\selectfonts\lsize #1}%
2048 \def\temp{#2}%
2049 \ifx\temp\empty \else
2050 \space ({\unsepspaces \ignorespaces \temp \unskip})%
2051 \fi
2052}
1566 2053
1567% @pounds{} is a sterling sign. 2054% @abbr for "Comput. J." and the like.
2055% No font change, but don't do end-of-sentence spacing.
2056%
2057\def\abbr#1{\doabbr #1,,\finish}
2058\def\doabbr#1,#2,#3\finish{%
2059 {\plainfrenchspacing #1}%
2060 \def\temp{#2}%
2061 \ifx\temp\empty \else
2062 \space ({\unsepspaces \ignorespaces \temp \unskip})%
2063 \fi
2064}
2065
2066% @pounds{} is a sterling sign, which Knuth put in the CM italic font.
2067%
1568\def\pounds{{\it\$}} 2068\def\pounds{{\it\$}}
1569 2069
2070% @euro{} comes from a separate font, depending on the current style.
2071% We use the free feym* fonts from the eurosym package by Henrik
2072% Theiling, which support regular, slanted, bold and bold slanted (and
2073% "outlined" (blackboard board, sort of) versions, which we don't need).
2074% It is available from http://www.ctan.org/tex-archive/fonts/eurosym.
2075%
2076% Although only regular is the truly official Euro symbol, we ignore
2077% that. The Euro is designed to be slightly taller than the regular
2078% font height.
2079%
2080% feymr - regular
2081% feymo - slanted
2082% feybr - bold
2083% feybo - bold slanted
2084%
2085% There is no good (free) typewriter version, to my knowledge.
2086% A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide.
2087% Hmm.
2088%
2089% Also doesn't work in math. Do we need to do math with euro symbols?
2090% Hope not.
2091%
2092%
2093\def\euro{{\eurofont e}}
2094\def\eurofont{%
2095 % We set the font at each command, rather than predefining it in
2096 % \textfonts and the other font-switching commands, so that
2097 % installations which never need the symbol don't have to have the
2098 % font installed.
2099 %
2100 % There is only one designed size (nominal 10pt), so we always scale
2101 % that to the current nominal size.
2102 %
2103 % By the way, simply using "at 1em" works for cmr10 and the like, but
2104 % does not work for cmbx10 and other extended/shrunken fonts.
2105 %
2106 \def\eurosize{\csname\curfontsize nominalsize\endcsname}%
2107 %
2108 \ifx\curfontstyle\bfstylename
2109 % bold:
2110 \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize
2111 \else
2112 % regular:
2113 \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize
2114 \fi
2115 \thiseurofont
2116}
2117
2118% @registeredsymbol - R in a circle. The font for the R should really
2119% be smaller yet, but lllsize is the best we can do for now.
2120% Adapted from the plain.tex definition of \copyright.
2121%
2122\def\registeredsymbol{%
2123 $^{{\ooalign{\hfil\raise.07ex\hbox{\selectfonts\lllsize R}%
2124 \hfil\crcr\Orb}}%
2125 }$%
2126}
2127
2128% Laurent Siebenmann reports \Orb undefined with:
2129% Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38
2130% so we'll define it if necessary.
2131%
2132\ifx\Orb\undefined
2133\def\Orb{\mathhexbox20D}
2134\fi
2135
1570 2136
1571\message{page headings,} 2137\message{page headings,}
1572 2138
@@ -1585,86 +2151,103 @@ where each line of input produces a line of output.}
1585\newif\ifsetshortcontentsaftertitlepage 2151\newif\ifsetshortcontentsaftertitlepage
1586 \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue 2152 \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue
1587 2153
1588\def\shorttitlepage{\parsearg\shorttitlepagezzz} 2154\parseargdef\shorttitlepage{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}%
1589\def\shorttitlepagezzz #1{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}%
1590 \endgroup\page\hbox{}\page} 2155 \endgroup\page\hbox{}\page}
1591 2156
1592\def\titlepage{\begingroup \parindent=0pt \textfonts 2157\envdef\titlepage{%
1593 \let\subtitlerm=\tenrm 2158 % Open one extra group, as we want to close it in the middle of \Etitlepage.
1594 \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}% 2159 \begingroup
1595 % 2160 \parindent=0pt \textfonts
1596 \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}% 2161 % Leave some space at the very top of the page.
1597 % 2162 \vglue\titlepagetopglue
1598 % Leave some space at the very top of the page. 2163 % No rule at page bottom unless we print one at the top with @title.
1599 \vglue\titlepagetopglue 2164 \finishedtitlepagetrue
1600 % 2165 %
1601 % Now you can print the title using @title. 2166 % Most title ``pages'' are actually two pages long, with space
1602 \def\title{\parsearg\titlezzz}% 2167 % at the top of the second. We don't want the ragged left on the second.
1603 \def\titlezzz##1{\leftline{\titlefonts\rm ##1} 2168 \let\oldpage = \page
1604 % print a rule at the page bottom also. 2169 \def\page{%
1605 \finishedtitlepagefalse
1606 \vskip4pt \hrule height 4pt width \hsize \vskip4pt}%
1607 % No rule at page bottom unless we print one at the top with @title.
1608 \finishedtitlepagetrue
1609 %
1610 % Now you can put text using @subtitle.
1611 \def\subtitle{\parsearg\subtitlezzz}%
1612 \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}%
1613 %
1614 % @author should come last, but may come many times.
1615 \def\author{\parsearg\authorzzz}%
1616 \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi
1617 {\authorfont \leftline{##1}}}%
1618 %
1619 % Most title ``pages'' are actually two pages long, with space
1620 % at the top of the second. We don't want the ragged left on the second.
1621 \let\oldpage = \page
1622 \def\page{%
1623 \iffinishedtitlepage\else 2170 \iffinishedtitlepage\else
1624 \finishtitlepage 2171 \finishtitlepage
1625 \fi 2172 \fi
1626 \oldpage
1627 \let\page = \oldpage 2173 \let\page = \oldpage
1628 \hbox{}}% 2174 \page
1629% \def\page{\oldpage \hbox{}} 2175 \null
2176 }%
1630} 2177}
1631 2178
1632\def\Etitlepage{% 2179\def\Etitlepage{%
1633 \iffinishedtitlepage\else 2180 \iffinishedtitlepage\else
1634 \finishtitlepage 2181 \finishtitlepage
1635 \fi 2182 \fi
1636 % It is important to do the page break before ending the group, 2183 % It is important to do the page break before ending the group,
1637 % because the headline and footline are only empty inside the group. 2184 % because the headline and footline are only empty inside the group.
1638 % If we use the new definition of \page, we always get a blank page 2185 % If we use the new definition of \page, we always get a blank page
1639 % after the title page, which we certainly don't want. 2186 % after the title page, which we certainly don't want.
1640 \oldpage 2187 \oldpage
1641 \endgroup 2188 \endgroup
1642 % 2189 %
1643 % Need this before the \...aftertitlepage checks so that if they are 2190 % Need this before the \...aftertitlepage checks so that if they are
1644 % in effect the toc pages will come out with page numbers. 2191 % in effect the toc pages will come out with page numbers.
1645 \HEADINGSon 2192 \HEADINGSon
1646 % 2193 %
1647 % If they want short, they certainly want long too. 2194 % If they want short, they certainly want long too.
1648 \ifsetshortcontentsaftertitlepage 2195 \ifsetshortcontentsaftertitlepage
1649 \shortcontents 2196 \shortcontents
1650 \contents 2197 \contents
1651 \global\let\shortcontents = \relax 2198 \global\let\shortcontents = \relax
1652 \global\let\contents = \relax 2199 \global\let\contents = \relax
1653 \fi 2200 \fi
1654 % 2201 %
1655 \ifsetcontentsaftertitlepage 2202 \ifsetcontentsaftertitlepage
1656 \contents 2203 \contents
1657 \global\let\contents = \relax 2204 \global\let\contents = \relax
1658 \global\let\shortcontents = \relax 2205 \global\let\shortcontents = \relax
1659 \fi 2206 \fi
1660} 2207}
1661 2208
1662\def\finishtitlepage{% 2209\def\finishtitlepage{%
1663 \vskip4pt \hrule height 2pt width \hsize 2210 \vskip4pt \hrule height 2pt width \hsize
1664 \vskip\titlepagebottomglue 2211 \vskip\titlepagebottomglue
1665 \finishedtitlepagetrue 2212 \finishedtitlepagetrue
2213}
2214
2215%%% Macros to be used within @titlepage:
2216
2217\let\subtitlerm=\tenrm
2218\def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}
2219
2220\def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines
2221 \let\tt=\authortt}
2222
2223\parseargdef\title{%
2224 \checkenv\titlepage
2225 \leftline{\titlefonts\rm #1}
2226 % print a rule at the page bottom also.
2227 \finishedtitlepagefalse
2228 \vskip4pt \hrule height 4pt width \hsize \vskip4pt
2229}
2230
2231\parseargdef\subtitle{%
2232 \checkenv\titlepage
2233 {\subtitlefont \rightline{#1}}%
2234}
2235
2236% @author should come last, but may come many times.
2237% It can also be used inside @quotation.
2238%
2239\parseargdef\author{%
2240 \def\temp{\quotation}%
2241 \ifx\thisenv\temp
2242 \def\quotationauthor{#1}% printed in \Equotation.
2243 \else
2244 \checkenv\titlepage
2245 \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi
2246 {\authorfont \leftline{#1}}%
2247 \fi
1666} 2248}
1667 2249
2250
1668%%% Set up page headings and footings. 2251%%% Set up page headings and footings.
1669 2252
1670\let\thispage=\folio 2253\let\thispage=\folio
@@ -1674,7 +2257,7 @@ where each line of input produces a line of output.}
1674\newtoks\evenfootline % footline on even pages 2257\newtoks\evenfootline % footline on even pages
1675\newtoks\oddfootline % footline on odd pages 2258\newtoks\oddfootline % footline on odd pages
1676 2259
1677% Now make Tex use those variables 2260% Now make TeX use those variables
1678\headline={{\textfonts\rm \ifodd\pageno \the\oddheadline 2261\headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
1679 \else \the\evenheadline \fi}} 2262 \else \the\evenheadline \fi}}
1680\footline={{\textfonts\rm \ifodd\pageno \the\oddfootline 2263\footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
@@ -1688,32 +2271,27 @@ where each line of input produces a line of output.}
1688% @evenfooting @thisfile|| 2271% @evenfooting @thisfile||
1689% @oddfooting ||@thisfile 2272% @oddfooting ||@thisfile
1690 2273
1691\def\evenheading{\parsearg\evenheadingxxx}
1692\def\oddheading{\parsearg\oddheadingxxx}
1693\def\everyheading{\parsearg\everyheadingxxx}
1694 2274
1695\def\evenfooting{\parsearg\evenfootingxxx} 2275\def\evenheading{\parsearg\evenheadingxxx}
1696\def\oddfooting{\parsearg\oddfootingxxx} 2276\def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish}
1697\def\everyfooting{\parsearg\everyfootingxxx} 2277\def\evenheadingyyy #1\|#2\|#3\|#4\finish{%
1698
1699{\catcode`\@=0 %
1700
1701\gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish}
1702\gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{%
1703\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} 2278\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
1704 2279
1705\gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish} 2280\def\oddheading{\parsearg\oddheadingxxx}
1706\gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{% 2281\def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish}
2282\def\oddheadingyyy #1\|#2\|#3\|#4\finish{%
1707\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} 2283\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
1708 2284
1709\gdef\everyheadingxxx#1{\oddheadingxxx{#1}\evenheadingxxx{#1}}% 2285\parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
1710 2286
1711\gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish} 2287\def\evenfooting{\parsearg\evenfootingxxx}
1712\gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{% 2288\def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish}
2289\def\evenfootingyyy #1\|#2\|#3\|#4\finish{%
1713\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} 2290\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
1714 2291
1715\gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish} 2292\def\oddfooting{\parsearg\oddfootingxxx}
1716\gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{% 2293\def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish}
2294\def\oddfootingyyy #1\|#2\|#3\|#4\finish{%
1717 \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}% 2295 \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}%
1718 % 2296 %
1719 % Leave some space for the footline. Hopefully ok to assume 2297 % Leave some space for the footline. Hopefully ok to assume
@@ -1722,9 +2300,8 @@ where each line of input produces a line of output.}
1722 \global\advance\vsize by -\baselineskip 2300 \global\advance\vsize by -\baselineskip
1723} 2301}
1724 2302
1725\gdef\everyfootingxxx#1{\oddfootingxxx{#1}\evenfootingxxx{#1}} 2303\parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}}
1726% 2304
1727}% unbind the catcode of @.
1728 2305
1729% @headings double turns headings on for double-sided printing. 2306% @headings double turns headings on for double-sided printing.
1730% @headings single turns headings on for single-sided printing. 2307% @headings single turns headings on for single-sided printing.
@@ -1738,7 +2315,7 @@ where each line of input produces a line of output.}
1738 2315
1739\def\headings #1 {\csname HEADINGS#1\endcsname} 2316\def\headings #1 {\csname HEADINGS#1\endcsname}
1740 2317
1741\def\HEADINGSoff{ 2318\def\HEADINGSoff{%
1742\global\evenheadline={\hfil} \global\evenfootline={\hfil} 2319\global\evenheadline={\hfil} \global\evenfootline={\hfil}
1743\global\oddheadline={\hfil} \global\oddfootline={\hfil}} 2320\global\oddheadline={\hfil} \global\oddfootline={\hfil}}
1744\HEADINGSoff 2321\HEADINGSoff
@@ -1747,7 +2324,7 @@ where each line of input produces a line of output.}
1747% chapter name on inside top of right hand pages, document 2324% chapter name on inside top of right hand pages, document
1748% title on inside top of left hand pages, and page numbers on outside top 2325% title on inside top of left hand pages, and page numbers on outside top
1749% edge of all pages. 2326% edge of all pages.
1750\def\HEADINGSdouble{ 2327\def\HEADINGSdouble{%
1751\global\pageno=1 2328\global\pageno=1
1752\global\evenfootline={\hfil} 2329\global\evenfootline={\hfil}
1753\global\oddfootline={\hfil} 2330\global\oddfootline={\hfil}
@@ -1759,7 +2336,7 @@ where each line of input produces a line of output.}
1759 2336
1760% For single-sided printing, chapter title goes across top left of page, 2337% For single-sided printing, chapter title goes across top left of page,
1761% page number on top right. 2338% page number on top right.
1762\def\HEADINGSsingle{ 2339\def\HEADINGSsingle{%
1763\global\pageno=1 2340\global\pageno=1
1764\global\evenfootline={\hfil} 2341\global\evenfootline={\hfil}
1765\global\oddfootline={\hfil} 2342\global\oddfootline={\hfil}
@@ -1806,12 +2383,11 @@ where each line of input produces a line of output.}
1806% @settitle line... specifies the title of the document, for headings. 2383% @settitle line... specifies the title of the document, for headings.
1807% It generates no output of its own. 2384% It generates no output of its own.
1808\def\thistitle{\putwordNoTitle} 2385\def\thistitle{\putwordNoTitle}
1809\def\settitle{\parsearg\settitlezzz} 2386\def\settitle{\parsearg{\gdef\thistitle}}
1810\def\settitlezzz #1{\gdef\thistitle{#1}}
1811 2387
1812 2388
1813\message{tables,} 2389\message{tables,}
1814% Tables -- @table, @ftable, @vtable, @item(x), @kitem(x), @xitem(x). 2390% Tables -- @table, @ftable, @vtable, @item(x).
1815 2391
1816% default indentation of table text 2392% default indentation of table text
1817\newdimen\tableindent \tableindent=.8in 2393\newdimen\tableindent \tableindent=.8in
@@ -1823,7 +2399,7 @@ where each line of input produces a line of output.}
1823% used internally for \itemindent minus \itemmargin 2399% used internally for \itemindent minus \itemmargin
1824\newdimen\itemmax 2400\newdimen\itemmax
1825 2401
1826% Note @table, @vtable, and @vtable define @item, @itemx, etc., with 2402% Note @table, @ftable, and @vtable define @item, @itemx, etc., with
1827% these defs. 2403% these defs.
1828% They also define \itemindex 2404% They also define \itemindex
1829% to index the item name in whatever manner is desired (perhaps none). 2405% to index the item name in whatever manner is desired (perhaps none).
@@ -1835,22 +2411,10 @@ where each line of input produces a line of output.}
1835\def\internalBitem{\smallbreak \parsearg\itemzzz} 2411\def\internalBitem{\smallbreak \parsearg\itemzzz}
1836\def\internalBitemx{\itemxpar \parsearg\itemzzz} 2412\def\internalBitemx{\itemxpar \parsearg\itemzzz}
1837 2413
1838\def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz}
1839\def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \itemxpar \parsearg\xitemzzz}
1840
1841\def\internalBkitem{\smallbreak \parsearg\kitemzzz}
1842\def\internalBkitemx{\itemxpar \parsearg\kitemzzz}
1843
1844\def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}%
1845 \itemzzz {#1}}
1846
1847\def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}%
1848 \itemzzz {#1}}
1849
1850\def\itemzzz #1{\begingroup % 2414\def\itemzzz #1{\begingroup %
1851 \advance\hsize by -\rightskip 2415 \advance\hsize by -\rightskip
1852 \advance\hsize by -\tableindent 2416 \advance\hsize by -\tableindent
1853 \setbox0=\hbox{\itemfont{#1}}% 2417 \setbox0=\hbox{\itemindicate{#1}}%
1854 \itemindex{#1}% 2418 \itemindex{#1}%
1855 \nobreak % This prevents a break before @itemx. 2419 \nobreak % This prevents a break before @itemx.
1856 % 2420 %
@@ -1874,10 +2438,14 @@ where each line of input produces a line of output.}
1874 % \parskip glue -- logically it's part of the @item we just started. 2438 % \parskip glue -- logically it's part of the @item we just started.
1875 \nobreak \vskip-\parskip 2439 \nobreak \vskip-\parskip
1876 % 2440 %
1877 % Stop a page break at the \parskip glue coming up. Unfortunately 2441 % Stop a page break at the \parskip glue coming up. However, if
1878 % we can't prevent a possible page break at the following 2442 % what follows is an environment such as @example, there will be no
1879 % \baselineskip glue. 2443 % \parskip glue; then the negative vskip we just inserted would
1880 \nobreak 2444 % cause the example and the item to crash together. So we use this
2445 % bizarre value of 10001 as a signal to \aboveenvbreak to insert
2446 % \parskip glue after all. Section titles are handled this way also.
2447 %
2448 \penalty 10001
1881 \endgroup 2449 \endgroup
1882 \itemxneedsnegativevskipfalse 2450 \itemxneedsnegativevskipfalse
1883 \else 2451 \else
@@ -1896,97 +2464,106 @@ where each line of input produces a line of output.}
1896 \fi 2464 \fi
1897} 2465}
1898 2466
1899\def\item{\errmessage{@item while not in a table}} 2467\def\item{\errmessage{@item while not in a list environment}}
1900\def\itemx{\errmessage{@itemx while not in a table}} 2468\def\itemx{\errmessage{@itemx while not in a list environment}}
1901\def\kitem{\errmessage{@kitem while not in a table}}
1902\def\kitemx{\errmessage{@kitemx while not in a table}}
1903\def\xitem{\errmessage{@xitem while not in a table}}
1904\def\xitemx{\errmessage{@xitemx while not in a table}}
1905
1906% Contains a kludge to get @end[description] to work.
1907\def\description{\tablez{\dontindex}{1}{}{}{}{}}
1908 2469
1909% @table, @ftable, @vtable. 2470% @table, @ftable, @vtable.
1910\def\table{\begingroup\inENV\obeylines\obeyspaces\tablex} 2471\envdef\table{%
1911{\obeylines\obeyspaces% 2472 \let\itemindex\gobble
1912\gdef\tablex #1^^M{% 2473 \tablecheck{table}%
1913\tabley\dontindex#1 \endtabley}} 2474}
1914 2475\envdef\ftable{%
1915\def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex} 2476 \def\itemindex ##1{\doind {fn}{\code{##1}}}%
1916{\obeylines\obeyspaces% 2477 \tablecheck{ftable}%
1917\gdef\ftablex #1^^M{% 2478}
1918\tabley\fnitemindex#1 \endtabley 2479\envdef\vtable{%
1919\def\Eftable{\endgraf\afterenvbreak\endgroup}% 2480 \def\itemindex ##1{\doind {vr}{\code{##1}}}%
1920\let\Etable=\relax}} 2481 \tablecheck{vtable}%
1921 2482}
1922\def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex} 2483\def\tablecheck#1{%
1923{\obeylines\obeyspaces% 2484 \ifnum \the\catcode`\^^M=\active
1924\gdef\vtablex #1^^M{% 2485 \endgroup
1925\tabley\vritemindex#1 \endtabley 2486 \errmessage{This command won't work in this context; perhaps the problem is
1926\def\Evtable{\endgraf\afterenvbreak\endgroup}% 2487 that we are \inenvironment\thisenv}%
1927\let\Etable=\relax}} 2488 \def\next{\doignore{#1}}%
1928 2489 \else
1929\def\dontindex #1{} 2490 \let\next\tablex
1930\def\fnitemindex #1{\doind {fn}{\code{#1}}}% 2491 \fi
1931\def\vritemindex #1{\doind {vr}{\code{#1}}}% 2492 \next
1932 2493}
1933{\obeyspaces % 2494\def\tablex#1{%
1934\gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup% 2495 \def\itemindicate{#1}%
1935\tablez{#1}{#2}{#3}{#4}{#5}{#6}}} 2496 \parsearg\tabley
1936 2497}
1937\def\tablez #1#2#3#4#5#6{% 2498\def\tabley#1{%
1938\aboveenvbreak % 2499 {%
1939\begingroup % 2500 \makevalueexpandable
1940\def\Edescription{\Etable}% Necessary kludge. 2501 \edef\temp{\noexpand\tablez #1\space\space\space}%
1941\let\itemindex=#1% 2502 \expandafter
1942\ifnum 0#3>0 \advance \leftskip by #3\mil \fi % 2503 }\temp \endtablez
1943\ifnum 0#4>0 \tableindent=#4\mil \fi %
1944\ifnum 0#5>0 \advance \rightskip by #5\mil \fi %
1945\def\itemfont{#2}%
1946\itemmax=\tableindent %
1947\advance \itemmax by -\itemmargin %
1948\advance \leftskip by \tableindent %
1949\exdentamount=\tableindent
1950\parindent = 0pt
1951\parskip = \smallskipamount
1952\ifdim \parskip=0pt \parskip=2pt \fi%
1953\def\Etable{\endgraf\afterenvbreak\endgroup}%
1954\let\item = \internalBitem %
1955\let\itemx = \internalBitemx %
1956\let\kitem = \internalBkitem %
1957\let\kitemx = \internalBkitemx %
1958\let\xitem = \internalBxitem %
1959\let\xitemx = \internalBxitemx %
1960} 2504}
2505\def\tablez #1 #2 #3 #4\endtablez{%
2506 \aboveenvbreak
2507 \ifnum 0#1>0 \advance \leftskip by #1\mil \fi
2508 \ifnum 0#2>0 \tableindent=#2\mil \fi
2509 \ifnum 0#3>0 \advance \rightskip by #3\mil \fi
2510 \itemmax=\tableindent
2511 \advance \itemmax by -\itemmargin
2512 \advance \leftskip by \tableindent
2513 \exdentamount=\tableindent
2514 \parindent = 0pt
2515 \parskip = \smallskipamount
2516 \ifdim \parskip=0pt \parskip=2pt \fi
2517 \let\item = \internalBitem
2518 \let\itemx = \internalBitemx
2519}
2520\def\Etable{\endgraf\afterenvbreak}
2521\let\Eftable\Etable
2522\let\Evtable\Etable
2523\let\Eitemize\Etable
2524\let\Eenumerate\Etable
1961 2525
1962% This is the counter used by @enumerate, which is really @itemize 2526% This is the counter used by @enumerate, which is really @itemize
1963 2527
1964\newcount \itemno 2528\newcount \itemno
1965 2529
1966\def\itemize{\parsearg\itemizezzz} 2530\envdef\itemize{\parsearg\doitemize}
1967 2531
1968\def\itemizezzz #1{% 2532\def\doitemize#1{%
1969 \begingroup % ended by the @end itemize 2533 \aboveenvbreak
1970 \itemizey {#1}{\Eitemize} 2534 \itemmax=\itemindent
2535 \advance\itemmax by -\itemmargin
2536 \advance\leftskip by \itemindent
2537 \exdentamount=\itemindent
2538 \parindent=0pt
2539 \parskip=\smallskipamount
2540 \ifdim\parskip=0pt \parskip=2pt \fi
2541 \def\itemcontents{#1}%
2542 % @itemize with no arg is equivalent to @itemize @bullet.
2543 \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi
2544 \let\item=\itemizeitem
1971} 2545}
1972 2546
1973\def\itemizey #1#2{% 2547% Definition of @item while inside @itemize and @enumerate.
1974\aboveenvbreak % 2548%
1975\itemmax=\itemindent % 2549\def\itemizeitem{%
1976\advance \itemmax by -\itemmargin % 2550 \advance\itemno by 1 % for enumerations
1977\advance \leftskip by \itemindent % 2551 {\let\par=\endgraf \smallbreak}% reasonable place to break
1978\exdentamount=\itemindent 2552 {%
1979\parindent = 0pt % 2553 % If the document has an @itemize directly after a section title, a
1980\parskip = \smallskipamount % 2554 % \nobreak will be last on the list, and \sectionheading will have
1981\ifdim \parskip=0pt \parskip=2pt \fi% 2555 % done a \vskip-\parskip. In that case, we don't want to zero
1982\def#2{\endgraf\afterenvbreak\endgroup}% 2556 % parskip, or the item text will crash with the heading. On the
1983\def\itemcontents{#1}% 2557 % other hand, when there is normal text preceding the item (as there
1984\let\item=\itemizeitem} 2558 % usually is), we do want to zero parskip, or there would be too much
1985 2559 % space. In that case, we won't have a \nobreak before. At least
1986% Set sfcode to normal for the chars that usually have another value. 2560 % that's the theory.
1987% These are `.?!:;,' 2561 \ifnum\lastpenalty<10000 \parskip=0in \fi
1988\def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000 2562 \noindent
1989 \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 } 2563 \hbox to 0pt{\hss \itemcontents \kern\itemmargin}%
2564 \vadjust{\penalty 1200}}% not good to break after first line of item.
2565 \flushcr
2566}
1990 2567
1991% \splitoff TOKENS\endmark defines \first to be the first token in 2568% \splitoff TOKENS\endmark defines \first to be the first token in
1992% TOKENS, and \rest to be the remainder. 2569% TOKENS, and \rest to be the remainder.
@@ -1997,11 +2574,8 @@ where each line of input produces a line of output.}
1997% or number, to specify the first label in the enumerated list. No 2574% or number, to specify the first label in the enumerated list. No
1998% argument is the same as `1'. 2575% argument is the same as `1'.
1999% 2576%
2000\def\enumerate{\parsearg\enumeratezzz} 2577\envparseargdef\enumerate{\enumeratey #1 \endenumeratey}
2001\def\enumeratezzz #1{\enumeratey #1 \endenumeratey}
2002\def\enumeratey #1 #2\endenumeratey{% 2578\def\enumeratey #1 #2\endenumeratey{%
2003 \begingroup % ended by the @end enumerate
2004 %
2005 % If we were given no argument, pretend we were given `1'. 2579 % If we were given no argument, pretend we were given `1'.
2006 \def\thearg{#1}% 2580 \def\thearg{#1}%
2007 \ifx\thearg\empty \def\thearg{1}\fi 2581 \ifx\thearg\empty \def\thearg{1}\fi
@@ -2072,13 +2646,13 @@ where each line of input produces a line of output.}
2072 }% 2646 }%
2073} 2647}
2074 2648
2075% Call itemizey, adding a period to the first argument and supplying the 2649% Call \doitemize, adding a period to the first argument and supplying the
2076% common last two arguments. Also subtract one from the initial value in 2650% common last two arguments. Also subtract one from the initial value in
2077% \itemno, since @item increments \itemno. 2651% \itemno, since @item increments \itemno.
2078% 2652%
2079\def\startenumeration#1{% 2653\def\startenumeration#1{%
2080 \advance\itemno by -1 2654 \advance\itemno by -1
2081 \itemizey{#1.}\Eenumerate\flushcr 2655 \doitemize{#1.}\flushcr
2082} 2656}
2083 2657
2084% @alphaenumerate and @capsenumerate are abbreviations for giving an arg 2658% @alphaenumerate and @capsenumerate are abbreviations for giving an arg
@@ -2089,16 +2663,6 @@ where each line of input produces a line of output.}
2089\def\Ealphaenumerate{\Eenumerate} 2663\def\Ealphaenumerate{\Eenumerate}
2090\def\Ecapsenumerate{\Eenumerate} 2664\def\Ecapsenumerate{\Eenumerate}
2091 2665
2092% Definition of @item while inside @itemize.
2093
2094\def\itemizeitem{%
2095\advance\itemno by 1
2096{\let\par=\endgraf \smallbreak}%
2097\ifhmode \errmessage{In hmode at itemizeitem}\fi
2098{\parskip=0in \hskip 0pt
2099\hbox to 0pt{\hss \itemcontents\hskip \itemmargin}%
2100\vadjust{\penalty 1200}}%
2101\flushcr}
2102 2666
2103% @multitable macros 2667% @multitable macros
2104% Amy Hendrickson, 8/18/94, 3/6/96 2668% Amy Hendrickson, 8/18/94, 3/6/96
@@ -2125,24 +2689,14 @@ where each line of input produces a line of output.}
2125% @multitable {Column 1 template} {Column 2 template} {Column 3 template} 2689% @multitable {Column 1 template} {Column 2 template} {Column 3 template}
2126% @item ... 2690% @item ...
2127% using the widest term desired in each column. 2691% using the widest term desired in each column.
2128%
2129% For those who want to use more than one line's worth of words in
2130% the preamble, break the line within one argument and it
2131% will parse correctly, i.e.,
2132%
2133% @multitable {Column 1 template} {Column 2 template} {Column 3
2134% template}
2135% Not:
2136% @multitable {Column 1 template} {Column 2 template}
2137% {Column 3 template}
2138 2692
2139% Each new table line starts with @item, each subsequent new column 2693% Each new table line starts with @item, each subsequent new column
2140% starts with @tab. Empty columns may be produced by supplying @tab's 2694% starts with @tab. Empty columns may be produced by supplying @tab's
2141% with nothing between them for as many times as empty columns are needed, 2695% with nothing between them for as many times as empty columns are needed,
2142% ie, @tab@tab@tab will produce two empty columns. 2696% ie, @tab@tab@tab will produce two empty columns.
2143 2697
2144% @item, @tab, @multitable or @end multitable do not need to be on their 2698% @item, @tab do not need to be on their own lines, but it will not hurt
2145% own lines, but it will not hurt if they are. 2699% if they are.
2146 2700
2147% Sample multitable: 2701% Sample multitable:
2148 2702
@@ -2186,13 +2740,12 @@ where each line of input produces a line of output.}
2186\def\xcolumnfractions{\columnfractions} 2740\def\xcolumnfractions{\columnfractions}
2187\newif\ifsetpercent 2741\newif\ifsetpercent
2188 2742
2189% #1 is the part of the @columnfraction before the decimal point, which 2743% #1 is the @columnfraction, usually a decimal number like .5, but might
2190% is presumably either 0 or the empty string (but we don't check, we 2744% be just 1. We just use it, whatever it is.
2191% just throw it away). #2 is the decimal part, which we use as the 2745%
2192% percent of \hsize for this column. 2746\def\pickupwholefraction#1 {%
2193\def\pickupwholefraction#1.#2 {%
2194 \global\advance\colcount by 1 2747 \global\advance\colcount by 1
2195 \expandafter\xdef\csname col\the\colcount\endcsname{.#2\hsize}% 2748 \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}%
2196 \setuptable 2749 \setuptable
2197} 2750}
2198 2751
@@ -2209,8 +2762,8 @@ where each line of input produces a line of output.}
2209 \let\go\pickupwholefraction 2762 \let\go\pickupwholefraction
2210 \else 2763 \else
2211 \global\advance\colcount by 1 2764 \global\advance\colcount by 1
2212 \setbox0=\hbox{#1\unskip }% Add a normal word space as a separator; 2765 \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a
2213 % typically that is always in the input, anyway. 2766 % separator; typically that is always in the input, anyway.
2214 \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}% 2767 \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
2215 \fi 2768 \fi
2216 \fi 2769 \fi
@@ -2225,18 +2778,33 @@ where each line of input produces a line of output.}
2225 \go 2778 \go
2226} 2779}
2227 2780
2228% This used to have \hskip1sp. But then the space in a template line is 2781% multitable-only commands.
2229% not enough. That is bad. So let's go back to just & until we 2782%
2230% encounter the problem it was intended to solve again. 2783% @headitem starts a heading row, which we typeset in bold.
2231% --karl, nathan@acm.org, 20apr99. 2784% Assignments have to be global since we are inside the implicit group
2232\def\tab{&} 2785% of an alignment entry. Note that \everycr resets \everytab.
2786\def\headitem{\checkenv\multitable \crcr \global\everytab={\bf}\the\everytab}%
2787%
2788% A \tab used to include \hskip1sp. But then the space in a template
2789% line is not enough. That is bad. So let's go back to just `&' until
2790% we encounter the problem it was intended to solve again.
2791% --karl, nathan@acm.org, 20apr99.
2792\def\tab{\checkenv\multitable &\the\everytab}%
2233 2793
2234% @multitable ... @end multitable definitions: 2794% @multitable ... @end multitable definitions:
2235% 2795%
2236\def\multitable{\parsearg\dotable} 2796\newtoks\everytab % insert after every tab.
2237\def\dotable#1{\bgroup 2797%
2798\envdef\multitable{%
2238 \vskip\parskip 2799 \vskip\parskip
2239 \let\item\crcr 2800 \startsavinginserts
2801 %
2802 % @item within a multitable starts a normal row.
2803 % We use \def instead of \let so that if one of the multitable entries
2804 % contains an @itemize, we don't choke on the \item (seen as \crcr aka
2805 % \endtemplate) expanding \doitemize.
2806 \def\item{\crcr}%
2807 %
2240 \tolerance=9500 2808 \tolerance=9500
2241 \hbadness=9500 2809 \hbadness=9500
2242 \setmultitablespacing 2810 \setmultitablespacing
@@ -2244,81 +2812,93 @@ where each line of input produces a line of output.}
2244 \parindent=\multitableparindent 2812 \parindent=\multitableparindent
2245 \overfullrule=0pt 2813 \overfullrule=0pt
2246 \global\colcount=0 2814 \global\colcount=0
2247 \def\Emultitable{\global\setpercentfalse\cr\egroup\egroup}%
2248 % 2815 %
2816 \everycr = {%
2817 \noalign{%
2818 \global\everytab={}%
2819 \global\colcount=0 % Reset the column counter.
2820 % Check for saved footnotes, etc.
2821 \checkinserts
2822 % Keeps underfull box messages off when table breaks over pages.
2823 %\filbreak
2824 % Maybe so, but it also creates really weird page breaks when the
2825 % table breaks over pages. Wouldn't \vfil be better? Wait until the
2826 % problem manifests itself, so it can be fixed for real --karl.
2827 }%
2828 }%
2829 %
2830 \parsearg\domultitable
2831}
2832\def\domultitable#1{%
2249 % To parse everything between @multitable and @item: 2833 % To parse everything between @multitable and @item:
2250 \setuptable#1 \endsetuptable 2834 \setuptable#1 \endsetuptable
2251 % 2835 %
2252 % \everycr will reset column counter, \colcount, at the end of
2253 % each line. Every column entry will cause \colcount to advance by one.
2254 % The table preamble
2255 % looks at the current \colcount to find the correct column width.
2256 \everycr{\noalign{%
2257 %
2258 % \filbreak%% keeps underfull box messages off when table breaks over pages.
2259 % Maybe so, but it also creates really weird page breaks when the table
2260 % breaks over pages. Wouldn't \vfil be better? Wait until the problem
2261 % manifests itself, so it can be fixed for real --karl.
2262 \global\colcount=0\relax}}%
2263 %
2264 % This preamble sets up a generic column definition, which will 2836 % This preamble sets up a generic column definition, which will
2265 % be used as many times as user calls for columns. 2837 % be used as many times as user calls for columns.
2266 % \vtop will set a single line and will also let text wrap and 2838 % \vtop will set a single line and will also let text wrap and
2267 % continue for many paragraphs if desired. 2839 % continue for many paragraphs if desired.
2268 \halign\bgroup&\global\advance\colcount by 1\relax 2840 \halign\bgroup &%
2269 \multistrut\vtop{\hsize=\expandafter\csname col\the\colcount\endcsname 2841 \global\advance\colcount by 1
2270 % 2842 \multistrut
2271 % In order to keep entries from bumping into each other 2843 \vtop{%
2272 % we will add a \leftskip of \multitablecolspace to all columns after 2844 % Use the current \colcount to find the correct column width:
2273 % the first one. 2845 \hsize=\expandafter\csname col\the\colcount\endcsname
2274 % 2846 %
2275 % If a template has been used, we will add \multitablecolspace 2847 % In order to keep entries from bumping into each other
2276 % to the width of each template entry. 2848 % we will add a \leftskip of \multitablecolspace to all columns after
2277 % 2849 % the first one.
2278 % If the user has set preamble in terms of percent of \hsize we will 2850 %
2279 % use that dimension as the width of the column, and the \leftskip 2851 % If a template has been used, we will add \multitablecolspace
2280 % will keep entries from bumping into each other. Table will start at 2852 % to the width of each template entry.
2281 % left margin and final column will justify at right margin. 2853 %
2282 % 2854 % If the user has set preamble in terms of percent of \hsize we will
2283 % Make sure we don't inherit \rightskip from the outer environment. 2855 % use that dimension as the width of the column, and the \leftskip
2284 \rightskip=0pt 2856 % will keep entries from bumping into each other. Table will start at
2285 \ifnum\colcount=1 2857 % left margin and final column will justify at right margin.
2286 % The first column will be indented with the surrounding text. 2858 %
2287 \advance\hsize by\leftskip 2859 % Make sure we don't inherit \rightskip from the outer environment.
2288 \else 2860 \rightskip=0pt
2289 \ifsetpercent \else 2861 \ifnum\colcount=1
2290 % If user has not set preamble in terms of percent of \hsize 2862 % The first column will be indented with the surrounding text.
2291 % we will advance \hsize by \multitablecolspace. 2863 \advance\hsize by\leftskip
2292 \advance\hsize by \multitablecolspace 2864 \else
2293 \fi 2865 \ifsetpercent \else
2294 % In either case we will make \leftskip=\multitablecolspace: 2866 % If user has not set preamble in terms of percent of \hsize
2295 \leftskip=\multitablecolspace 2867 % we will advance \hsize by \multitablecolspace.
2296 \fi 2868 \advance\hsize by \multitablecolspace
2297 % Ignoring space at the beginning and end avoids an occasional spurious 2869 \fi
2298 % blank line, when TeX decides to break the line at the space before the 2870 % In either case we will make \leftskip=\multitablecolspace:
2299 % box from the multistrut, so the strut ends up on a line by itself. 2871 \leftskip=\multitablecolspace
2300 % For example: 2872 \fi
2301 % @multitable @columnfractions .11 .89 2873 % Ignoring space at the beginning and end avoids an occasional spurious
2302 % @item @code{#} 2874 % blank line, when TeX decides to break the line at the space before the
2303 % @tab Legal holiday which is valid in major parts of the whole country. 2875 % box from the multistrut, so the strut ends up on a line by itself.
2304 % Is automatically provided with highlighting sequences respectively marking 2876 % For example:
2305 % characters. 2877 % @multitable @columnfractions .11 .89
2306 \noindent\ignorespaces##\unskip\multistrut}\cr 2878 % @item @code{#}
2307} 2879 % @tab Legal holiday which is valid in major parts of the whole country.
2308 2880 % Is automatically provided with highlighting sequences respectively
2309\def\setmultitablespacing{% test to see if user has set \multitablelinespace. 2881 % marking characters.
2310% If so, do nothing. If not, give it an appropriate dimension based on 2882 \noindent\ignorespaces##\unskip\multistrut
2311% current baselineskip. 2883 }\cr
2884}
2885\def\Emultitable{%
2886 \crcr
2887 \egroup % end the \halign
2888 \global\setpercentfalse
2889}
2890
2891\def\setmultitablespacing{%
2892 \def\multistrut{\strut}% just use the standard line spacing
2893 %
2894 % Compute \multitablelinespace (if not defined by user) for use in
2895 % \multitableparskip calculation. We used define \multistrut based on
2896 % this, but (ironically) that caused the spacing to be off.
2897 % See bug-texinfo report from Werner Lemberg, 31 Oct 2004 12:52:20 +0100.
2312\ifdim\multitablelinespace=0pt 2898\ifdim\multitablelinespace=0pt
2313\setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip 2899\setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip
2314\global\advance\multitablelinespace by-\ht0 2900\global\advance\multitablelinespace by-\ht0
2315%% strut to put in table in case some entry doesn't have descenders, 2901\fi
2316%% to keep lines equally spaced
2317\let\multistrut = \strut
2318\else
2319%% FIXME: what is \box0 supposed to be?
2320\gdef\multistrut{\vrule height\multitablelinespace depth\dp0
2321width0pt\relax} \fi
2322%% Test to see if parskip is larger than space between lines of 2902%% Test to see if parskip is larger than space between lines of
2323%% table. If not, do nothing. 2903%% table. If not, do nothing.
2324%% If so, set to same dimension as multitablelinespace. 2904%% If so, set to same dimension as multitablelinespace.
@@ -2335,294 +2915,178 @@ width0pt\relax} \fi
2335 2915
2336 2916
2337\message{conditionals,} 2917\message{conditionals,}
2338% Prevent errors for section commands. 2918
2339% Used in @ignore and in failing conditionals. 2919% @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext,
2340\def\ignoresections{% 2920% @ifnotxml always succeed. They currently do nothing; we don't
2341 \let\chapter=\relax 2921% attempt to check whether the conditionals are properly nested. But we
2342 \let\unnumbered=\relax 2922% have to remember that they are conditionals, so that @end doesn't
2343 \let\top=\relax 2923% attempt to close an environment group.
2344 \let\unnumberedsec=\relax
2345 \let\unnumberedsection=\relax
2346 \let\unnumberedsubsec=\relax
2347 \let\unnumberedsubsection=\relax
2348 \let\unnumberedsubsubsec=\relax
2349 \let\unnumberedsubsubsection=\relax
2350 \let\section=\relax
2351 \let\subsec=\relax
2352 \let\subsubsec=\relax
2353 \let\subsection=\relax
2354 \let\subsubsection=\relax
2355 \let\appendix=\relax
2356 \let\appendixsec=\relax
2357 \let\appendixsection=\relax
2358 \let\appendixsubsec=\relax
2359 \let\appendixsubsection=\relax
2360 \let\appendixsubsubsec=\relax
2361 \let\appendixsubsubsection=\relax
2362 \let\contents=\relax
2363 \let\smallbook=\relax
2364 \let\titlepage=\relax
2365}
2366
2367% Used in nested conditionals, where we have to parse the Texinfo source
2368% and so want to turn off most commands, in case they are used
2369% incorrectly.
2370%
2371\def\ignoremorecommands{%
2372 \let\defcodeindex = \relax
2373 \let\defcv = \relax
2374 \let\deffn = \relax
2375 \let\deffnx = \relax
2376 \let\defindex = \relax
2377 \let\defivar = \relax
2378 \let\defmac = \relax
2379 \let\defmethod = \relax
2380 \let\defop = \relax
2381 \let\defopt = \relax
2382 \let\defspec = \relax
2383 \let\deftp = \relax
2384 \let\deftypefn = \relax
2385 \let\deftypefun = \relax
2386 \let\deftypeivar = \relax
2387 \let\deftypeop = \relax
2388 \let\deftypevar = \relax
2389 \let\deftypevr = \relax
2390 \let\defun = \relax
2391 \let\defvar = \relax
2392 \let\defvr = \relax
2393 \let\ref = \relax
2394 \let\xref = \relax
2395 \let\printindex = \relax
2396 \let\pxref = \relax
2397 \let\settitle = \relax
2398 \let\setchapternewpage = \relax
2399 \let\setchapterstyle = \relax
2400 \let\everyheading = \relax
2401 \let\evenheading = \relax
2402 \let\oddheading = \relax
2403 \let\everyfooting = \relax
2404 \let\evenfooting = \relax
2405 \let\oddfooting = \relax
2406 \let\headings = \relax
2407 \let\include = \relax
2408 \let\lowersections = \relax
2409 \let\down = \relax
2410 \let\raisesections = \relax
2411 \let\up = \relax
2412 \let\set = \relax
2413 \let\clear = \relax
2414 \let\item = \relax
2415}
2416
2417% Ignore @ignore, @ifhtml, @ifinfo, @ifplaintext, @ifnottex, @html, @menu,
2418% @direntry, and @documentdescription.
2419% 2924%
2420\def\ignore{\doignore{ignore}} 2925\def\makecond#1{%
2926 \expandafter\let\csname #1\endcsname = \relax
2927 \expandafter\let\csname iscond.#1\endcsname = 1
2928}
2929\makecond{iftex}
2930\makecond{ifnotdocbook}
2931\makecond{ifnothtml}
2932\makecond{ifnotinfo}
2933\makecond{ifnotplaintext}
2934\makecond{ifnotxml}
2935
2936% Ignore @ignore, @ifhtml, @ifinfo, and the like.
2937%
2938\def\direntry{\doignore{direntry}}
2939\def\documentdescription{\doignore{documentdescription}}
2940\def\docbook{\doignore{docbook}}
2941\def\html{\doignore{html}}
2942\def\ifdocbook{\doignore{ifdocbook}}
2421\def\ifhtml{\doignore{ifhtml}} 2943\def\ifhtml{\doignore{ifhtml}}
2422\def\ifinfo{\doignore{ifinfo}} 2944\def\ifinfo{\doignore{ifinfo}}
2423\def\ifplaintext{\doignore{ifplaintext}}
2424\def\ifnottex{\doignore{ifnottex}} 2945\def\ifnottex{\doignore{ifnottex}}
2425\def\html{\doignore{html}} 2946\def\ifplaintext{\doignore{ifplaintext}}
2947\def\ifxml{\doignore{ifxml}}
2948\def\ignore{\doignore{ignore}}
2426\def\menu{\doignore{menu}} 2949\def\menu{\doignore{menu}}
2427\def\direntry{\doignore{direntry}} 2950\def\xml{\doignore{xml}}
2428\def\documentdescription{\doignore{documentdescription}}
2429\def\documentdescriptionword{documentdescription}
2430
2431% @dircategory CATEGORY -- specify a category of the dir file
2432% which this file should belong to. Ignore this in TeX.
2433\let\dircategory = \comment
2434 2951
2435% Ignore text until a line `@end #1'. 2952% Ignore text until a line `@end #1', keeping track of nested conditionals.
2436% 2953%
2954% A count to remember the depth of nesting.
2955\newcount\doignorecount
2956
2437\def\doignore#1{\begingroup 2957\def\doignore#1{\begingroup
2438 % Don't complain about control sequences we have declared \outer. 2958 % Scan in ``verbatim'' mode:
2439 \ignoresections 2959 \obeylines
2440 % 2960 \catcode`\@ = \other
2441 % Define a command to swallow text until we reach `@end #1'. 2961 \catcode`\{ = \other
2442 % This @ is a catcode 12 token (that is the normal catcode of @ in 2962 \catcode`\} = \other
2443 % this texinfo.tex file). We change the catcode of @ below to match.
2444 \long\def\doignoretext##1@end #1{\enddoignore}%
2445 % 2963 %
2446 % Make sure that spaces turn into tokens that match what \doignoretext wants. 2964 % Make sure that spaces turn into tokens that match what \doignoretext wants.
2447 \catcode32 = 10 2965 \spaceisspace
2448 %
2449 % Ignore braces, too, so mismatched braces don't cause trouble.
2450 \catcode`\{ = 9
2451 \catcode`\} = 9
2452 % 2966 %
2453 % We must not have @c interpreted as a control sequence. 2967 % Count number of #1's that we've seen.
2454 \catcode`\@ = 12 2968 \doignorecount = 0
2455 % 2969 %
2456 \def\ignoreword{#1}% 2970 % Swallow text until we reach the matching `@end #1'.
2457 \ifx\ignoreword\documentdescriptionword 2971 \dodoignore{#1}%
2458 % The c kludge breaks documentdescription, since
2459 % `documentdescription' contains a `c'. Means not everything will
2460 % be ignored inside @documentdescription, but oh well...
2461 \else
2462 % Make the letter c a comment character so that the rest of the line
2463 % will be ignored. This way, the document can have (for example)
2464 % @c @end ifinfo
2465 % and the @end ifinfo will be properly ignored.
2466 % (We've just changed @ to catcode 12.)
2467 \catcode`\c = 14
2468 \fi
2469 %
2470 % And now expand the command defined above.
2471 \doignoretext
2472}
2473
2474% What we do to finish off ignored text.
2475%
2476\def\enddoignore{\endgroup\ignorespaces}%
2477
2478\newif\ifwarnedobs\warnedobsfalse
2479\def\obstexwarn{%
2480 \ifwarnedobs\relax\else
2481 % We need to warn folks that they may have trouble with TeX 3.0.
2482 % This uses \immediate\write16 rather than \message to get newlines.
2483 \immediate\write16{}
2484 \immediate\write16{WARNING: for users of Unix TeX 3.0!}
2485 \immediate\write16{This manual trips a bug in TeX version 3.0 (tex hangs).}
2486 \immediate\write16{If you are running another version of TeX, relax.}
2487 \immediate\write16{If you are running Unix TeX 3.0, kill this TeX process.}
2488 \immediate\write16{ Then upgrade your TeX installation if you can.}
2489 \immediate\write16{ (See ftp://ftp.gnu.org/pub/gnu/TeX.README.)}
2490 \immediate\write16{If you are stuck with version 3.0, run the}
2491 \immediate\write16{ script ``tex3patch'' from the Texinfo distribution}
2492 \immediate\write16{ to use a workaround.}
2493 \immediate\write16{}
2494 \global\warnedobstrue
2495 \fi
2496} 2972}
2497 2973
2498% **In TeX 3.0, setting text in \nullfont hangs tex. For a 2974{ \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source.
2499% workaround (which requires the file ``dummy.tfm'' to be installed), 2975 \obeylines %
2500% uncomment the following line:
2501%%%%%\font\nullfont=dummy\let\obstexwarn=\relax
2502
2503% Ignore text, except that we keep track of conditional commands for
2504% purposes of nesting, up to an `@end #1' command.
2505%
2506\def\nestedignore#1{%
2507 \obstexwarn
2508 % We must actually expand the ignored text to look for the @end
2509 % command, so that nested ignore constructs work. Thus, we put the
2510 % text into a \vbox and then do nothing with the result. To minimize
2511 % the change of memory overflow, we follow the approach outlined on
2512 % page 401 of the TeXbook: make the current font be a dummy font.
2513 % 2976 %
2514 \setbox0 = \vbox\bgroup 2977 \gdef\dodoignore#1{%
2515 % Don't complain about control sequences we have declared \outer. 2978 % #1 contains the command name as a string, e.g., `ifinfo'.
2516 \ignoresections
2517 %
2518 % Define `@end #1' to end the box, which will in turn undefine the
2519 % @end command again.
2520 \expandafter\def\csname E#1\endcsname{\egroup\ignorespaces}%
2521 %
2522 % We are going to be parsing Texinfo commands. Most cause no
2523 % trouble when they are used incorrectly, but some commands do
2524 % complicated argument parsing or otherwise get confused, so we
2525 % undefine them.
2526 %
2527 % We can't do anything about stray @-signs, unfortunately;
2528 % they'll produce `undefined control sequence' errors.
2529 \ignoremorecommands
2530 %
2531 % Set the current font to be \nullfont, a TeX primitive, and define
2532 % all the font commands to also use \nullfont. We don't use
2533 % dummy.tfm, as suggested in the TeXbook, because not all sites
2534 % might have that installed. Therefore, math mode will still
2535 % produce output, but that should be an extremely small amount of
2536 % stuff compared to the main input.
2537 %
2538 \nullfont
2539 \let\tenrm=\nullfont \let\tenit=\nullfont \let\tensl=\nullfont
2540 \let\tenbf=\nullfont \let\tentt=\nullfont \let\smallcaps=\nullfont
2541 \let\tensf=\nullfont
2542 % Similarly for index fonts.
2543 \let\smallrm=\nullfont \let\smallit=\nullfont \let\smallsl=\nullfont
2544 \let\smallbf=\nullfont \let\smalltt=\nullfont \let\smallsc=\nullfont
2545 \let\smallsf=\nullfont
2546 % Similarly for smallexample fonts.
2547 \let\smallerrm=\nullfont \let\smallerit=\nullfont \let\smallersl=\nullfont
2548 \let\smallerbf=\nullfont \let\smallertt=\nullfont \let\smallersc=\nullfont
2549 \let\smallersf=\nullfont
2550 %
2551 % Don't complain when characters are missing from the fonts.
2552 \tracinglostchars = 0
2553 % 2979 %
2554 % Don't bother to do space factor calculations. 2980 % Define a command to find the next `@end #1'.
2555 \frenchspacing 2981 \long\def\doignoretext##1^^M@end #1{%
2982 \doignoretextyyy##1^^M@#1\_STOP_}%
2556 % 2983 %
2557 % Don't report underfull hboxes. 2984 % And this command to find another #1 command, at the beginning of a
2558 \hbadness = 10000 2985 % line. (Otherwise, we would consider a line `@c @ifset', for
2986 % example, to count as an @ifset for nesting.)
2987 \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}%
2559 % 2988 %
2560 % Do minimal line-breaking. 2989 % And now expand that command.
2561 \pretolerance = 10000 2990 \doignoretext ^^M%
2562 % 2991 }%
2563 % Do not execute instructions in @tex 2992}
2564 \def\tex{\doignore{tex}}% 2993
2565 % Do not execute macro definitions. 2994\def\doignoreyyy#1{%
2566 % `c' is a comment character, so the word `macro' will get cut off. 2995 \def\temp{#1}%
2567 \def\macro{\doignore{ma}}% 2996 \ifx\temp\empty % Nothing found.
2997 \let\next\doignoretextzzz
2998 \else % Found a nested condition, ...
2999 \advance\doignorecount by 1
3000 \let\next\doignoretextyyy % ..., look for another.
3001 % If we're here, #1 ends with ^^M\ifinfo (for example).
3002 \fi
3003 \next #1% the token \_STOP_ is present just after this macro.
3004}
3005
3006% We have to swallow the remaining "\_STOP_".
3007%
3008\def\doignoretextzzz#1{%
3009 \ifnum\doignorecount = 0 % We have just found the outermost @end.
3010 \let\next\enddoignore
3011 \else % Still inside a nested condition.
3012 \advance\doignorecount by -1
3013 \let\next\doignoretext % Look for the next @end.
3014 \fi
3015 \next
2568} 3016}
2569 3017
3018% Finish off ignored text.
3019{ \obeylines%
3020 % Ignore anything after the last `@end #1'; this matters in verbatim
3021 % environments, where otherwise the newline after an ignored conditional
3022 % would result in a blank line in the output.
3023 \gdef\enddoignore#1^^M{\endgroup\ignorespaces}%
3024}
3025
3026
2570% @set VAR sets the variable VAR to an empty value. 3027% @set VAR sets the variable VAR to an empty value.
2571% @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE. 3028% @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
2572% 3029%
2573% Since we want to separate VAR from REST-OF-LINE (which might be 3030% Since we want to separate VAR from REST-OF-LINE (which might be
2574% empty), we can't just use \parsearg; we have to insert a space of our 3031% empty), we can't just use \parsearg; we have to insert a space of our
2575% own to delimit the rest of the line, and then take it out again if we 3032% own to delimit the rest of the line, and then take it out again if we
2576% didn't need it. Make sure the catcode of space is correct to avoid 3033% didn't need it.
2577% losing inside @example, for instance. 3034% We rely on the fact that \parsearg sets \catcode`\ =10.
2578% 3035%
2579\def\set{\begingroup\catcode` =10 3036\parseargdef\set{\setyyy#1 \endsetyyy}
2580 \catcode`\-=12 \catcode`\_=12 % Allow - and _ in VAR.
2581 \parsearg\setxxx}
2582\def\setxxx#1{\setyyy#1 \endsetyyy}
2583\def\setyyy#1 #2\endsetyyy{% 3037\def\setyyy#1 #2\endsetyyy{%
2584 \def\temp{#2}% 3038 {%
2585 \ifx\temp\empty \global\expandafter\let\csname SET#1\endcsname = \empty 3039 \makevalueexpandable
2586 \else \setzzz{#1}#2\endsetzzz % Remove the trailing space \setxxx inserted. 3040 \def\temp{#2}%
2587 \fi 3041 \edef\next{\gdef\makecsname{SET#1}}%
2588 \endgroup 3042 \ifx\temp\empty
3043 \next{}%
3044 \else
3045 \setzzz#2\endsetzzz
3046 \fi
3047 }%
2589} 3048}
2590% Can't use \xdef to pre-expand #2 and save some time, since \temp or 3049% Remove the trailing space \setxxx inserted.
2591% \next or other control sequences that we've defined might get us into 3050\def\setzzz#1 \endsetzzz{\next{#1}}
2592% an infinite loop. Consider `@set foo @cite{bar}'.
2593\def\setzzz#1#2 \endsetzzz{\expandafter\gdef\csname SET#1\endcsname{#2}}
2594 3051
2595% @clear VAR clears (i.e., unsets) the variable VAR. 3052% @clear VAR clears (i.e., unsets) the variable VAR.
2596% 3053%
2597\def\clear{\parsearg\clearxxx} 3054\parseargdef\clear{%
2598\def\clearxxx#1{\global\expandafter\let\csname SET#1\endcsname=\relax} 3055 {%
3056 \makevalueexpandable
3057 \global\expandafter\let\csname SET#1\endcsname=\relax
3058 }%
3059}
2599 3060
2600% @value{foo} gets the text saved in variable foo. 3061% @value{foo} gets the text saved in variable foo.
3062\def\value{\begingroup\makevalueexpandable\valuexxx}
3063\def\valuexxx#1{\expandablevalue{#1}\endgroup}
2601{ 3064{
2602 \catcode`\_ = \active 3065 \catcode`\- = \active \catcode`\_ = \active
2603 % 3066 %
2604 % We might end up with active _ or - characters in the argument if 3067 \gdef\makevalueexpandable{%
2605 % we're called from @code, as @code{@value{foo-bar_}}. So \let any 3068 \let\value = \expandablevalue
2606 % such active characters to their normal equivalents. 3069 % We don't want these characters active, ...
2607 \gdef\value{\begingroup 3070 \catcode`\-=\other \catcode`\_=\other
2608 \catcode`\-=12 \catcode`\_=12 3071 % ..., but we might end up with active ones in the argument if
2609 \indexbreaks \let_\normalunderscore 3072 % we're called from @code, as @code{@value{foo-bar_}}, though.
2610 \valuexxx} 3073 % So \let them to their normal equivalents.
3074 \let-\realdash \let_\normalunderscore
3075 }
2611} 3076}
2612\def\valuexxx#1{\expandablevalue{#1}\endgroup}
2613 3077
2614% We have this subroutine so that we can handle at least some @value's 3078% We have this subroutine so that we can handle at least some @value's
2615% properly in indexes (we \let\value to this in \indexdummies). Ones 3079% properly in indexes (we call \makevalueexpandable in \indexdummies).
2616% whose names contain - or _ still won't work, but we can't do anything 3080% The command has to be fully expandable (if the variable is set), since
2617% about that. The command has to be fully expandable, since the result 3081% the result winds up in the index file. This means that if the
2618% winds up in the index file. This means that if the variable's value 3082% variable's value contains other Texinfo commands, it's almost certain
2619% contains other Texinfo commands, it's almost certain it will fail 3083% it will fail (although perhaps we could fix that with sufficient work
2620% (although perhaps we could fix that with sufficient work to do a 3084% to do a one-level expansion on the result, instead of complete).
2621% one-level expansion on the result, instead of complete).
2622% 3085%
2623\def\expandablevalue#1{% 3086\def\expandablevalue#1{%
2624 \expandafter\ifx\csname SET#1\endcsname\relax 3087 \expandafter\ifx\csname SET#1\endcsname\relax
2625 {[No value for ``#1'']}% 3088 {[No value for ``#1'']}%
3089 \message{Variable `#1', used in @value, is not set.}%
2626 \else 3090 \else
2627 \csname SET#1\endcsname 3091 \csname SET#1\endcsname
2628 \fi 3092 \fi
@@ -2631,68 +3095,36 @@ width0pt\relax} \fi
2631% @ifset VAR ... @end ifset reads the `...' iff VAR has been defined 3095% @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
2632% with @set. 3096% with @set.
2633% 3097%
2634\def\ifset{\parsearg\ifsetxxx} 3098% To get special treatment of `@end ifset,' call \makeond and the redefine.
2635\def\ifsetxxx #1{% 3099%
2636 \expandafter\ifx\csname SET#1\endcsname\relax 3100\makecond{ifset}
2637 \expandafter\ifsetfail 3101\def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}}
2638 \else 3102\def\doifset#1#2{%
2639 \expandafter\ifsetsucceed 3103 {%
2640 \fi 3104 \makevalueexpandable
3105 \let\next=\empty
3106 \expandafter\ifx\csname SET#2\endcsname\relax
3107 #1% If not set, redefine \next.
3108 \fi
3109 \expandafter
3110 }\next
2641} 3111}
2642\def\ifsetsucceed{\conditionalsucceed{ifset}} 3112\def\ifsetfail{\doignore{ifset}}
2643\def\ifsetfail{\nestedignore{ifset}}
2644\defineunmatchedend{ifset}
2645 3113
2646% @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been 3114% @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been
2647% defined with @set, or has been undefined with @clear. 3115% defined with @set, or has been undefined with @clear.
2648% 3116%
2649\def\ifclear{\parsearg\ifclearxxx} 3117% The `\else' inside the `\doifset' parameter is a trick to reuse the
2650\def\ifclearxxx #1{% 3118% above code: if the variable is not set, do nothing, if it is set,
2651 \expandafter\ifx\csname SET#1\endcsname\relax 3119% then redefine \next to \ifclearfail.
2652 \expandafter\ifclearsucceed
2653 \else
2654 \expandafter\ifclearfail
2655 \fi
2656}
2657\def\ifclearsucceed{\conditionalsucceed{ifclear}}
2658\def\ifclearfail{\nestedignore{ifclear}}
2659\defineunmatchedend{ifclear}
2660
2661% @iftex, @ifnothtml, @ifnotinfo, @ifnotplaintext always succeed; we
2662% read the text following, through the first @end iftex (etc.). Make
2663% `@end iftex' (etc.) valid only after an @iftex.
2664%
2665\def\iftex{\conditionalsucceed{iftex}}
2666\def\ifnothtml{\conditionalsucceed{ifnothtml}}
2667\def\ifnotinfo{\conditionalsucceed{ifnotinfo}}
2668\def\ifnotplaintext{\conditionalsucceed{ifnotplaintext}}
2669\defineunmatchedend{iftex}
2670\defineunmatchedend{ifnothtml}
2671\defineunmatchedend{ifnotinfo}
2672\defineunmatchedend{ifnotplaintext}
2673
2674% We can't just want to start a group at @iftex (etc.) and end it at
2675% @end iftex, since then @set commands inside the conditional have no
2676% effect (they'd get reverted at the end of the group). So we must
2677% define \Eiftex to redefine itself to be its previous value. (We can't
2678% just define it to fail again with an ``unmatched end'' error, since
2679% the @ifset might be nested.)
2680%
2681\def\conditionalsucceed#1{%
2682 \edef\temp{%
2683 % Remember the current value of \E#1.
2684 \let\nece{prevE#1} = \nece{E#1}%
2685 %
2686 % At the `@end #1', redefine \E#1 to be its previous value.
2687 \def\nece{E#1}{\let\nece{E#1} = \nece{prevE#1}}%
2688 }%
2689 \temp
2690}
2691
2692% We need to expand lots of \csname's, but we don't want to expand the
2693% control sequences after we've constructed them.
2694% 3120%
2695\def\nece#1{\expandafter\noexpand\csname#1\endcsname} 3121\makecond{ifclear}
3122\def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}}
3123\def\ifclearfail{\doignore{ifclear}}
3124
3125% @dircategory CATEGORY -- specify a category of the dir file
3126% which this file should belong to. Ignore this in TeX.
3127\let\dircategory=\comment
2696 3128
2697% @defininfoenclose. 3129% @defininfoenclose.
2698\let\definfoenclose=\comment 3130\let\definfoenclose=\comment
@@ -2702,9 +3134,8 @@ width0pt\relax} \fi
2702% Index generation facilities 3134% Index generation facilities
2703 3135
2704% Define \newwrite to be identical to plain tex's \newwrite 3136% Define \newwrite to be identical to plain tex's \newwrite
2705% except not \outer, so it can be used within \newindex. 3137% except not \outer, so it can be used within macros and \if's.
2706{\catcode`\@=11 3138\edef\newwrite{\makecsname{ptexnewwrite}}
2707\gdef\newwrite{\alloc@7\write\chardef\sixt@@n}}
2708 3139
2709% \newindex {foo} defines an index named foo. 3140% \newindex {foo} defines an index named foo.
2710% It automatically defines \fooindex such that 3141% It automatically defines \fooindex such that
@@ -2785,285 +3216,393 @@ width0pt\relax} \fi
2785\def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer} 3216\def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
2786\def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}} 3217\def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
2787 3218
2788% Take care of texinfo commands likely to appear in an index entry. 3219% Take care of Texinfo commands that can appear in an index entry.
2789% (Must be a way to avoid doing expansion at all, and thus not have to 3220% Since there are some commands we want to expand, and others we don't,
2790% laboriously list every single command here.) 3221% we have to laboriously prevent expansion for those that we don't.
2791% 3222%
2792\def\indexdummies{% 3223\def\indexdummies{%
2793\def\ { }% 3224 \escapechar = `\\ % use backslash in output files.
2794\def\@{@}% change to @@ when we switch to @ as escape char in aux files. 3225 \def\@{@}% change to @@ when we switch to @ as escape char in index files.
2795% Need these in case \tex is in effect and \{ is a \delimiter again. 3226 \def\ {\realbackslash\space }%
2796% But can't use \lbracecmd and \rbracecmd because texindex assumes 3227 % Need these in case \tex is in effect and \{ is a \delimiter again.
2797% braces and backslashes are used only as delimiters. 3228 % But can't use \lbracecmd and \rbracecmd because texindex assumes
2798\let\{ = \mylbrace 3229 % braces and backslashes are used only as delimiters.
2799\let\} = \myrbrace 3230 \let\{ = \mylbrace
2800\def\_{{\realbackslash _}}% 3231 \let\} = \myrbrace
2801\normalturnoffactive 3232 %
2802% 3233 % Do the redefinitions.
2803% Take care of the plain tex accent commands. 3234 \commondummies
2804\def\,##1{\realbackslash ,{##1}}% 3235}
2805\def\"{\realbackslash "}% 3236
2806\def\`{\realbackslash `}% 3237% For the aux and toc files, @ is the escape character. So we want to
2807\def\'{\realbackslash '}% 3238% redefine everything using @ as the escape character (instead of
2808\def\^{\realbackslash ^}% 3239% \realbackslash, still used for index files). When everything uses @,
2809\def\~{\realbackslash ~}% 3240% this will be simpler.
2810\def\={\realbackslash =}% 3241%
2811\def\b{\realbackslash b}% 3242\def\atdummies{%
2812\def\c{\realbackslash c}% 3243 \def\@{@@}%
2813\def\d{\realbackslash d}% 3244 \def\ {@ }%
2814\def\u{\realbackslash u}% 3245 \let\{ = \lbraceatcmd
2815\def\v{\realbackslash v}% 3246 \let\} = \rbraceatcmd
2816\def\H{\realbackslash H}% 3247 %
2817\def\dotless##1{\realbackslash dotless {##1}}% 3248 % Do the redefinitions.
2818% Take care of the plain tex special European modified letters. 3249 \commondummies
2819\def\AA{\realbackslash AA}% 3250 \otherbackslash
2820\def\AE{\realbackslash AE}% 3251}
2821\def\L{\realbackslash L}%
2822\def\OE{\realbackslash OE}%
2823\def\O{\realbackslash O}%
2824\def\aa{\realbackslash aa}%
2825\def\ae{\realbackslash ae}%
2826\def\l{\realbackslash l}%
2827\def\oe{\realbackslash oe}%
2828\def\o{\realbackslash o}%
2829\def\ss{\realbackslash ss}%
2830%
2831% Although these internals commands shouldn't show up, sometimes they do.
2832\def\bf{\realbackslash bf }%
2833\def\gtr{\realbackslash gtr}%
2834\def\hat{\realbackslash hat}%
2835\def\less{\realbackslash less}%
2836%\def\rm{\realbackslash rm }%
2837\def\sf{\realbackslash sf}%
2838\def\sl{\realbackslash sl }%
2839\def\tclose##1{\realbackslash tclose {##1}}%
2840\def\tt{\realbackslash tt}%
2841%
2842\def\b##1{\realbackslash b {##1}}%
2843\def\i##1{\realbackslash i {##1}}%
2844\def\sc##1{\realbackslash sc {##1}}%
2845\def\t##1{\realbackslash t {##1}}%
2846\def\r##1{\realbackslash r {##1}}%
2847%
2848\def\TeX{\realbackslash TeX}%
2849\def\LaTeX{\realbackslash LaTeX}%
2850\def\acronym##1{\realbackslash acronym {##1}}%
2851\def\cite##1{\realbackslash cite {##1}}%
2852\def\code##1{\realbackslash code {##1}}%
2853\def\command##1{\realbackslash command {##1}}%
2854\def\dfn##1{\realbackslash dfn {##1}}%
2855\def\dots{\realbackslash dots }%
2856\def\emph##1{\realbackslash emph {##1}}%
2857\def\env##1{\realbackslash env {##1}}%
2858\def\file##1{\realbackslash file {##1}}%
2859\def\kbd##1{\realbackslash kbd {##1}}%
2860\def\key##1{\realbackslash key {##1}}%
2861\def\math##1{\realbackslash math {##1}}%
2862\def\option##1{\realbackslash option {##1}}%
2863\def\samp##1{\realbackslash samp {##1}}%
2864\def\strong##1{\realbackslash strong {##1}}%
2865\def\uref##1{\realbackslash uref {##1}}%
2866\def\url##1{\realbackslash url {##1}}%
2867\def\var##1{\realbackslash var {##1}}%
2868\def\w{\realbackslash w }%
2869%
2870% These math commands don't seem likely to be used in index entries.
2871\def\copyright{\realbackslash copyright}%
2872\def\equiv{\realbackslash equiv}%
2873\def\error{\realbackslash error}%
2874\def\expansion{\realbackslash expansion}%
2875\def\point{\realbackslash point}%
2876\def\print{\realbackslash print}%
2877\def\result{\realbackslash result}%
2878%
2879% Handle some cases of @value -- where the variable name does not
2880% contain - or _, and the value does not contain any
2881% (non-fully-expandable) commands.
2882\let\value = \expandablevalue
2883%
2884\unsepspaces
2885% Turn off macro expansion
2886\turnoffmacros
2887}
2888
2889% If an index command is used in an @example environment, any spaces
2890% therein should become regular spaces in the raw index file, not the
2891% expansion of \tie (\leavevmode \penalty \@M \ ).
2892{\obeyspaces
2893 \gdef\unsepspaces{\obeyspaces\let =\space}}
2894
2895% \indexnofonts no-ops all font-change commands.
2896% This is used when outputting the strings to sort the index by.
2897\def\indexdummyfont#1{#1}
2898\def\indexdummytex{TeX}
2899\def\indexdummydots{...}
2900 3252
3253% Called from \indexdummies and \atdummies.
3254%
3255\def\commondummies{%
3256 %
3257 % \definedummyword defines \#1 as \string\#1\space, thus effectively
3258 % preventing its expansion. This is used only for control% words,
3259 % not control letters, because the \space would be incorrect for
3260 % control characters, but is needed to separate the control word
3261 % from whatever follows.
3262 %
3263 % For control letters, we have \definedummyletter, which omits the
3264 % space.
3265 %
3266 % These can be used both for control words that take an argument and
3267 % those that do not. If it is followed by {arg} in the input, then
3268 % that will dutifully get written to the index (or wherever).
3269 %
3270 \def\definedummyword ##1{\def##1{\string##1\space}}%
3271 \def\definedummyletter##1{\def##1{\string##1}}%
3272 \let\definedummyaccent\definedummyletter
3273 %
3274 \commondummiesnofonts
3275 %
3276 \definedummyletter\_%
3277 %
3278 % Non-English letters.
3279 \definedummyword\AA
3280 \definedummyword\AE
3281 \definedummyword\L
3282 \definedummyword\OE
3283 \definedummyword\O
3284 \definedummyword\aa
3285 \definedummyword\ae
3286 \definedummyword\l
3287 \definedummyword\oe
3288 \definedummyword\o
3289 \definedummyword\ss
3290 \definedummyword\exclamdown
3291 \definedummyword\questiondown
3292 \definedummyword\ordf
3293 \definedummyword\ordm
3294 %
3295 % Although these internal commands shouldn't show up, sometimes they do.
3296 \definedummyword\bf
3297 \definedummyword\gtr
3298 \definedummyword\hat
3299 \definedummyword\less
3300 \definedummyword\sf
3301 \definedummyword\sl
3302 \definedummyword\tclose
3303 \definedummyword\tt
3304 %
3305 \definedummyword\LaTeX
3306 \definedummyword\TeX
3307 %
3308 % Assorted special characters.
3309 \definedummyword\bullet
3310 \definedummyword\comma
3311 \definedummyword\copyright
3312 \definedummyword\registeredsymbol
3313 \definedummyword\dots
3314 \definedummyword\enddots
3315 \definedummyword\equiv
3316 \definedummyword\error
3317 \definedummyword\euro
3318 \definedummyword\expansion
3319 \definedummyword\minus
3320 \definedummyword\pounds
3321 \definedummyword\point
3322 \definedummyword\print
3323 \definedummyword\result
3324 %
3325 % We want to disable all macros so that they are not expanded by \write.
3326 \macrolist
3327 %
3328 \normalturnoffactive
3329 %
3330 % Handle some cases of @value -- where it does not contain any
3331 % (non-fully-expandable) commands.
3332 \makevalueexpandable
3333}
3334
3335% \commondummiesnofonts: common to \commondummies and \indexnofonts.
3336%
3337\def\commondummiesnofonts{%
3338 % Control letters and accents.
3339 \definedummyletter\!%
3340 \definedummyaccent\"%
3341 \definedummyaccent\'%
3342 \definedummyletter\*%
3343 \definedummyaccent\,%
3344 \definedummyletter\.%
3345 \definedummyletter\/%
3346 \definedummyletter\:%
3347 \definedummyaccent\=%
3348 \definedummyletter\?%
3349 \definedummyaccent\^%
3350 \definedummyaccent\`%
3351 \definedummyaccent\~%
3352 \definedummyword\u
3353 \definedummyword\v
3354 \definedummyword\H
3355 \definedummyword\dotaccent
3356 \definedummyword\ringaccent
3357 \definedummyword\tieaccent
3358 \definedummyword\ubaraccent
3359 \definedummyword\udotaccent
3360 \definedummyword\dotless
3361 %
3362 % Texinfo font commands.
3363 \definedummyword\b
3364 \definedummyword\i
3365 \definedummyword\r
3366 \definedummyword\sc
3367 \definedummyword\t
3368 %
3369 % Commands that take arguments.
3370 \definedummyword\acronym
3371 \definedummyword\cite
3372 \definedummyword\code
3373 \definedummyword\command
3374 \definedummyword\dfn
3375 \definedummyword\emph
3376 \definedummyword\env
3377 \definedummyword\file
3378 \definedummyword\kbd
3379 \definedummyword\key
3380 \definedummyword\math
3381 \definedummyword\option
3382 \definedummyword\pxref
3383 \definedummyword\ref
3384 \definedummyword\samp
3385 \definedummyword\strong
3386 \definedummyword\tie
3387 \definedummyword\uref
3388 \definedummyword\url
3389 \definedummyword\var
3390 \definedummyword\verb
3391 \definedummyword\w
3392 \definedummyword\xref
3393}
3394
3395% \indexnofonts is used when outputting the strings to sort the index
3396% by, and when constructing control sequence names. It eliminates all
3397% control sequences and just writes whatever the best ASCII sort string
3398% would be for a given command (usually its argument).
3399%
2901\def\indexnofonts{% 3400\def\indexnofonts{%
2902\def\@{@}% 3401 % Accent commands should become @asis.
2903% how to handle braces? 3402 \def\definedummyaccent##1{\let##1\asis}%
2904\def\_{\normalunderscore}% 3403 % We can just ignore other control letters.
2905% 3404 \def\definedummyletter##1{\let##1\empty}%
2906\let\,=\indexdummyfont 3405 % Hopefully, all control words can become @asis.
2907\let\"=\indexdummyfont 3406 \let\definedummyword\definedummyaccent
2908\let\`=\indexdummyfont 3407 %
2909\let\'=\indexdummyfont 3408 \commondummiesnofonts
2910\let\^=\indexdummyfont 3409 %
2911\let\~=\indexdummyfont 3410 % Don't no-op \tt, since it isn't a user-level command
2912\let\==\indexdummyfont 3411 % and is used in the definitions of the active chars like <, >, |, etc.
2913\let\b=\indexdummyfont 3412 % Likewise with the other plain tex font commands.
2914\let\c=\indexdummyfont 3413 %\let\tt=\asis
2915\let\d=\indexdummyfont 3414 %
2916\let\u=\indexdummyfont 3415 \def\ { }%
2917\let\v=\indexdummyfont 3416 \def\@{@}%
2918\let\H=\indexdummyfont 3417 % how to handle braces?
2919\let\dotless=\indexdummyfont 3418 \def\_{\normalunderscore}%
2920% Take care of the plain tex special European modified letters. 3419 %
2921\def\AA{AA}% 3420 % Non-English letters.
2922\def\AE{AE}% 3421 \def\AA{AA}%
2923\def\L{L}% 3422 \def\AE{AE}%
2924\def\OE{OE}% 3423 \def\L{L}%
2925\def\O{O}% 3424 \def\OE{OE}%
2926\def\aa{aa}% 3425 \def\O{O}%
2927\def\ae{ae}% 3426 \def\aa{aa}%
2928\def\l{l}% 3427 \def\ae{ae}%
2929\def\oe{oe}% 3428 \def\l{l}%
2930\def\o{o}% 3429 \def\oe{oe}%
2931\def\ss{ss}% 3430 \def\o{o}%
2932% 3431 \def\ss{ss}%
2933% Don't no-op \tt, since it isn't a user-level command 3432 \def\exclamdown{!}%
2934% and is used in the definitions of the active chars like <, >, |, etc. 3433 \def\questiondown{?}%
2935% Likewise with the other plain tex font commands. 3434 \def\ordf{a}%
2936%\let\tt=\indexdummyfont 3435 \def\ordm{o}%
2937% 3436 %
2938\let\b=\indexdummyfont 3437 \def\LaTeX{LaTeX}%
2939\let\i=\indexdummyfont 3438 \def\TeX{TeX}%
2940\let\r=\indexdummyfont 3439 %
2941\let\sc=\indexdummyfont 3440 % Assorted special characters.
2942\let\t=\indexdummyfont 3441 % (The following {} will end up in the sort string, but that's ok.)
2943% 3442 \def\bullet{bullet}%
2944\let\TeX=\indexdummytex 3443 \def\comma{,}%
2945\let\acronym=\indexdummyfont 3444 \def\copyright{copyright}%
2946\let\cite=\indexdummyfont 3445 \def\registeredsymbol{R}%
2947\let\code=\indexdummyfont 3446 \def\dots{...}%
2948\let\command=\indexdummyfont 3447 \def\enddots{...}%
2949\let\dfn=\indexdummyfont 3448 \def\equiv{==}%
2950\let\dots=\indexdummydots 3449 \def\error{error}%
2951\let\emph=\indexdummyfont 3450 \def\euro{euro}%
2952\let\env=\indexdummyfont 3451 \def\expansion{==>}%
2953\let\file=\indexdummyfont 3452 \def\minus{-}%
2954\let\kbd=\indexdummyfont 3453 \def\pounds{pounds}%
2955\let\key=\indexdummyfont 3454 \def\point{.}%
2956\let\math=\indexdummyfont 3455 \def\print{-|}%
2957\let\option=\indexdummyfont 3456 \def\result{=>}%
2958\let\samp=\indexdummyfont 3457 %
2959\let\strong=\indexdummyfont 3458 % We need to get rid of all macros, leaving only the arguments (if present).
2960\let\uref=\indexdummyfont 3459 % Of course this is not nearly correct, but it is the best we can do for now.
2961\let\url=\indexdummyfont 3460 % makeinfo does not expand macros in the argument to @deffn, which ends up
2962\let\var=\indexdummyfont 3461 % writing an index entry, and texindex isn't prepared for an index sort entry
2963\let\w=\indexdummyfont 3462 % that starts with \.
2964} 3463 %
2965 3464 % Since macro invocations are followed by braces, we can just redefine them
2966% To define \realbackslash, we must make \ not be an escape. 3465 % to take a single TeX argument. The case of a macro invocation that
2967% We must first make another character (@) an escape 3466 % goes to end-of-line is not handled.
2968% so we do not become unable to do a definition. 3467 %
2969 3468 \macrolist
2970{\catcode`\@=0 \catcode`\\=\other 3469}
2971 @gdef@realbackslash{\}}
2972 3470
2973\let\indexbackslash=0 %overridden during \printindex. 3471\let\indexbackslash=0 %overridden during \printindex.
2974\let\SETmarginindex=\relax % put index entries in margin (undocumented)? 3472\let\SETmarginindex=\relax % put index entries in margin (undocumented)?
2975 3473
2976% For \ifx comparisons.
2977\def\emptymacro{\empty}
2978
2979% Most index entries go through here, but \dosubind is the general case. 3474% Most index entries go through here, but \dosubind is the general case.
2980% 3475% #1 is the index name, #2 is the entry text.
2981\def\doind#1#2{\dosubind{#1}{#2}\empty} 3476\def\doind#1#2{\dosubind{#1}{#2}{}}
2982 3477
2983% Workhorse for all \fooindexes. 3478% Workhorse for all \fooindexes.
2984% #1 is name of index, #2 is stuff to put there, #3 is subentry -- 3479% #1 is name of index, #2 is stuff to put there, #3 is subentry --
2985% \empty if called from \doind, as we usually are. The main exception 3480% empty if called from \doind, as we usually are (the main exception
2986% is with defuns, which call us directly. 3481% is with most defuns, which call us directly).
2987% 3482%
2988\def\dosubind#1#2#3{% 3483\def\dosubind#1#2#3{%
3484 \iflinks
3485 {%
3486 % Store the main index entry text (including the third arg).
3487 \toks0 = {#2}%
3488 % If third arg is present, precede it with a space.
3489 \def\thirdarg{#3}%
3490 \ifx\thirdarg\empty \else
3491 \toks0 = \expandafter{\the\toks0 \space #3}%
3492 \fi
3493 %
3494 \edef\writeto{\csname#1indfile\endcsname}%
3495 %
3496 \ifvmode
3497 \dosubindsanitize
3498 \else
3499 \dosubindwrite
3500 \fi
3501 }%
3502 \fi
3503}
3504
3505% Write the entry in \toks0 to the index file:
3506%
3507\def\dosubindwrite{%
2989 % Put the index entry in the margin if desired. 3508 % Put the index entry in the margin if desired.
2990 \ifx\SETmarginindex\relax\else 3509 \ifx\SETmarginindex\relax\else
2991 \insert\margin{\hbox{\vrule height8pt depth3pt width0pt #2}}% 3510 \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}%
2992 \fi 3511 \fi
2993 {% 3512 %
2994 \count255=\lastpenalty 3513 % Remember, we are within a group.
2995 {% 3514 \indexdummies % Must do this here, since \bf, etc expand at this stage
2996 \indexdummies % Must do this here, since \bf, etc expand at this stage 3515 \def\backslashcurfont{\indexbackslash}% \indexbackslash isn't defined now
2997 \escapechar=`\\ 3516 % so it will be output as is; and it will print as backslash.
2998 {% 3517 %
2999 \let\folio = 0% We will expand all macros now EXCEPT \folio. 3518 % Process the index entry with all font commands turned off, to
3000 \def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now 3519 % get the string to sort by.
3001 % so it will be output as is; and it will print as backslash. 3520 {\indexnofonts
3002 % 3521 \edef\temp{\the\toks0}% need full expansion
3003 \def\thirdarg{#3}% 3522 \xdef\indexsorttmp{\temp}%
3004 % 3523 }%
3005 % If third arg is present, precede it with space in sort key. 3524 %
3006 \ifx\thirdarg\emptymacro 3525 % Set up the complete index entry, with both the sort key and
3007 \let\subentry = \empty 3526 % the original text, including any font commands. We write
3008 \else 3527 % three arguments to \entry to the .?? file (four in the
3009 \def\subentry{ #3}% 3528 % subentry case), texindex reduces to two when writing the .??s
3010 \fi 3529 % sorted result.
3011 % 3530 \edef\temp{%
3012 % First process the index entry with all font commands turned 3531 \write\writeto{%
3013 % off to get the string to sort by. 3532 \string\entry{\indexsorttmp}{\noexpand\folio}{\the\toks0}}%
3014 {\indexnofonts \xdef\indexsorttmp{#2\subentry}}%
3015 %
3016 % Now the real index entry with the fonts.
3017 \toks0 = {#2}%
3018 %
3019 % If the third (subentry) arg is present, add it to the index
3020 % line to write.
3021 \ifx\thirdarg\emptymacro \else
3022 \toks0 = \expandafter{\the\toks0{#3}}%
3023 \fi
3024 %
3025 % Set up the complete index entry, with both the sort key and
3026 % the original text, including any font commands. We write
3027 % three arguments to \entry to the .?? file (four in the
3028 % subentry case), texindex reduces to two when writing the .??s
3029 % sorted result.
3030 \edef\temp{%
3031 \write\csname#1indfile\endcsname{%
3032 \realbackslash entry{\indexsorttmp}{\folio}{\the\toks0}}%
3033 }%
3034 %
3035 % If a skip is the last thing on the list now, preserve it
3036 % by backing up by \lastskip, doing the \write, then inserting
3037 % the skip again. Otherwise, the whatsit generated by the
3038 % \write will make \lastskip zero. The result is that sequences
3039 % like this:
3040 % @end defun
3041 % @tindex whatever
3042 % @defun ...
3043 % will have extra space inserted, because the \medbreak in the
3044 % start of the @defun won't see the skip inserted by the @end of
3045 % the previous defun.
3046 %
3047 % But don't do any of this if we're not in vertical mode. We
3048 % don't want to do a \vskip and prematurely end a paragraph.
3049 %
3050 % Avoid page breaks due to these extra skips, too.
3051 %
3052 \iflinks
3053 \ifvmode
3054 \skip0 = \lastskip
3055 \ifdim\lastskip = 0pt \else \nobreak\vskip-\lastskip \fi
3056 \fi
3057 %
3058 \temp % do the write
3059 %
3060 %
3061 \ifvmode \ifdim\skip0 = 0pt \else \nobreak\vskip\skip0 \fi \fi
3062 \fi
3063 }%
3064 }%
3065 \penalty\count255
3066 }% 3533 }%
3534 \temp
3535}
3536
3537% Take care of unwanted page breaks:
3538%
3539% If a skip is the last thing on the list now, preserve it
3540% by backing up by \lastskip, doing the \write, then inserting
3541% the skip again. Otherwise, the whatsit generated by the
3542% \write will make \lastskip zero. The result is that sequences
3543% like this:
3544% @end defun
3545% @tindex whatever
3546% @defun ...
3547% will have extra space inserted, because the \medbreak in the
3548% start of the @defun won't see the skip inserted by the @end of
3549% the previous defun.
3550%
3551% But don't do any of this if we're not in vertical mode. We
3552% don't want to do a \vskip and prematurely end a paragraph.
3553%
3554% Avoid page breaks due to these extra skips, too.
3555%
3556% But wait, there is a catch there:
3557% We'll have to check whether \lastskip is zero skip. \ifdim is not
3558% sufficient for this purpose, as it ignores stretch and shrink parts
3559% of the skip. The only way seems to be to check the textual
3560% representation of the skip.
3561%
3562% The following is almost like \def\zeroskipmacro{0.0pt} except that
3563% the ``p'' and ``t'' characters have catcode \other, not 11 (letter).
3564%
3565\edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname}
3566%
3567% ..., ready, GO:
3568%
3569\def\dosubindsanitize{%
3570 % \lastskip and \lastpenalty cannot both be nonzero simultaneously.
3571 \skip0 = \lastskip
3572 \edef\lastskipmacro{\the\lastskip}%
3573 \count255 = \lastpenalty
3574 %
3575 % If \lastskip is nonzero, that means the last item was a
3576 % skip. And since a skip is discardable, that means this
3577 % -\skip0 glue we're inserting is preceded by a
3578 % non-discardable item, therefore it is not a potential
3579 % breakpoint, therefore no \nobreak needed.
3580 \ifx\lastskipmacro\zeroskipmacro
3581 \else
3582 \vskip-\skip0
3583 \fi
3584 %
3585 \dosubindwrite
3586 %
3587 \ifx\lastskipmacro\zeroskipmacro
3588 % If \lastskip was zero, perhaps the last item was a penalty, and
3589 % perhaps it was >=10000, e.g., a \nobreak. In that case, we want
3590 % to re-insert the same penalty (values >10000 are used for various
3591 % signals); since we just inserted a non-discardable item, any
3592 % following glue (such as a \parskip) would be a breakpoint. For example:
3593 %
3594 % @deffn deffn-whatever
3595 % @vindex index-whatever
3596 % Description.
3597 % would allow a break between the index-whatever whatsit
3598 % and the "Description." paragraph.
3599 \ifnum\count255>9999 \penalty\count255 \fi
3600 \else
3601 % On the other hand, if we had a nonzero \lastskip,
3602 % this make-up glue would be preceded by a non-discardable item
3603 % (the whatsit from the \write), so we must insert a \nobreak.
3604 \nobreak\vskip\skip0
3605 \fi
3067} 3606}
3068 3607
3069% The index entry written in the file actually looks like 3608% The index entry written in the file actually looks like
@@ -3101,13 +3640,12 @@ width0pt\relax} \fi
3101% @printindex causes a particular index (the ??s file) to get printed. 3640% @printindex causes a particular index (the ??s file) to get printed.
3102% It does not print any chapter heading (usually an @unnumbered). 3641% It does not print any chapter heading (usually an @unnumbered).
3103% 3642%
3104\def\printindex{\parsearg\doprintindex} 3643\parseargdef\printindex{\begingroup
3105\def\doprintindex#1{\begingroup
3106 \dobreak \chapheadingskip{10000}% 3644 \dobreak \chapheadingskip{10000}%
3107 % 3645 %
3108 \smallfonts \rm 3646 \smallfonts \rm
3109 \tolerance = 9500 3647 \tolerance = 9500
3110 \indexbreaks 3648 \everypar = {}% don't want the \kern\-parindent from indentation suppression.
3111 % 3649 %
3112 % See if the index file exists and is nonempty. 3650 % See if the index file exists and is nonempty.
3113 % Change catcode of @ here so that if the index file contains 3651 % Change catcode of @ here so that if the index file contains
@@ -3134,7 +3672,7 @@ width0pt\relax} \fi
3134 % Index files are almost Texinfo source, but we use \ as the escape 3672 % Index files are almost Texinfo source, but we use \ as the escape
3135 % character. It would be better to use @, but that's too big a change 3673 % character. It would be better to use @, but that's too big a change
3136 % to make right now. 3674 % to make right now.
3137 \def\indexbackslash{\rawbackslashxx}% 3675 \def\indexbackslash{\backslashcurfont}%
3138 \catcode`\\ = 0 3676 \catcode`\\ = 0
3139 \escapechar = `\\ 3677 \escapechar = `\\
3140 \begindoublecolumns 3678 \begindoublecolumns
@@ -3156,7 +3694,10 @@ width0pt\relax} \fi
3156 \removelastskip 3694 \removelastskip
3157 % 3695 %
3158 % We like breaks before the index initials, so insert a bonus. 3696 % We like breaks before the index initials, so insert a bonus.
3159 \penalty -300 3697 \nobreak
3698 \vskip 0pt plus 3\baselineskip
3699 \penalty 0
3700 \vskip 0pt plus -3\baselineskip
3160 % 3701 %
3161 % Typeset the initial. Making this add up to a whole number of 3702 % Typeset the initial. Making this add up to a whole number of
3162 % baselineskips increases the chance of the dots lining up from column 3703 % baselineskips increases the chance of the dots lining up from column
@@ -3166,80 +3707,100 @@ width0pt\relax} \fi
3166 % No shrink because it confuses \balancecolumns. 3707 % No shrink because it confuses \balancecolumns.
3167 \vskip 1.67\baselineskip plus .5\baselineskip 3708 \vskip 1.67\baselineskip plus .5\baselineskip
3168 \leftline{\secbf #1}% 3709 \leftline{\secbf #1}%
3169 \vskip .33\baselineskip plus .1\baselineskip
3170 %
3171 % Do our best not to break after the initial. 3710 % Do our best not to break after the initial.
3172 \nobreak 3711 \nobreak
3712 \vskip .33\baselineskip plus .1\baselineskip
3173}} 3713}}
3174 3714
3175% This typesets a paragraph consisting of #1, dot leaders, and then #2 3715% \entry typesets a paragraph consisting of the text (#1), dot leaders, and
3176% flush to the right margin. It is used for index and table of contents 3716% then page number (#2) flushed to the right margin. It is used for index
3177% entries. The paragraph is indented by \leftskip. 3717% and table of contents entries. The paragraph is indented by \leftskip.
3178% 3718%
3179\def\entry#1#2{\begingroup 3719% A straightforward implementation would start like this:
3180 % 3720% \def\entry#1#2{...
3181 % Start a new paragraph if necessary, so our assignments below can't 3721% But this frozes the catcodes in the argument, and can cause problems to
3182 % affect previous text. 3722% @code, which sets - active. This problem was fixed by a kludge---
3183 \par 3723% ``-'' was active throughout whole index, but this isn't really right.
3184 % 3724%
3185 % Do not fill out the last line with white space. 3725% The right solution is to prevent \entry from swallowing the whole text.
3186 \parfillskip = 0in 3726% --kasal, 21nov03
3187 % 3727\def\entry{%
3188 % No extra space above this paragraph. 3728 \begingroup
3189 \parskip = 0in 3729 %
3190 % 3730 % Start a new paragraph if necessary, so our assignments below can't
3191 % Do not prefer a separate line ending with a hyphen to fewer lines. 3731 % affect previous text.
3192 \finalhyphendemerits = 0 3732 \par
3193 % 3733 %
3194 % \hangindent is only relevant when the entry text and page number 3734 % Do not fill out the last line with white space.
3195 % don't both fit on one line. In that case, bob suggests starting the 3735 \parfillskip = 0in
3196 % dots pretty far over on the line. Unfortunately, a large 3736 %
3197 % indentation looks wrong when the entry text itself is broken across 3737 % No extra space above this paragraph.
3198 % lines. So we use a small indentation and put up with long leaders. 3738 \parskip = 0in
3199 % 3739 %
3200 % \hangafter is reset to 1 (which is the value we want) at the start 3740 % Do not prefer a separate line ending with a hyphen to fewer lines.
3201 % of each paragraph, so we need not do anything with that. 3741 \finalhyphendemerits = 0
3202 \hangindent = 2em
3203 %
3204 % When the entry text needs to be broken, just fill out the first line
3205 % with blank space.
3206 \rightskip = 0pt plus1fil
3207 %
3208 % A bit of stretch before each entry for the benefit of balancing columns.
3209 \vskip 0pt plus1pt
3210 %
3211 % Start a ``paragraph'' for the index entry so the line breaking
3212 % parameters we've set above will have an effect.
3213 \noindent
3214 %
3215 % Insert the text of the index entry. TeX will do line-breaking on it.
3216 #1%
3217 % The following is kludged to not output a line of dots in the index if
3218 % there are no page numbers. The next person who breaks this will be
3219 % cursed by a Unix daemon.
3220 \def\tempa{{\rm }}%
3221 \def\tempb{#2}%
3222 \edef\tempc{\tempa}%
3223 \edef\tempd{\tempb}%
3224 \ifx\tempc\tempd\ \else%
3225 % 3742 %
3226 % If we must, put the page number on a line of its own, and fill out 3743 % \hangindent is only relevant when the entry text and page number
3227 % this line with blank space. (The \hfil is overwhelmed with the 3744 % don't both fit on one line. In that case, bob suggests starting the
3228 % fill leaders glue in \indexdotfill if the page number does fit.) 3745 % dots pretty far over on the line. Unfortunately, a large
3229 \hfil\penalty50 3746 % indentation looks wrong when the entry text itself is broken across
3230 \null\nobreak\indexdotfill % Have leaders before the page number. 3747 % lines. So we use a small indentation and put up with long leaders.
3231 % 3748 %
3232 % The `\ ' here is removed by the implicit \unskip that TeX does as 3749 % \hangafter is reset to 1 (which is the value we want) at the start
3233 % part of (the primitive) \par. Without it, a spurious underfull 3750 % of each paragraph, so we need not do anything with that.
3234 % \hbox ensues. 3751 \hangindent = 2em
3235 \ifpdf 3752 %
3236 \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph. 3753 % When the entry text needs to be broken, just fill out the first line
3754 % with blank space.
3755 \rightskip = 0pt plus1fil
3756 %
3757 % A bit of stretch before each entry for the benefit of balancing
3758 % columns.
3759 \vskip 0pt plus1pt
3760 %
3761 % Swallow the left brace of the text (first parameter):
3762 \afterassignment\doentry
3763 \let\temp =
3764}
3765\def\doentry{%
3766 \bgroup % Instead of the swallowed brace.
3767 \noindent
3768 \aftergroup\finishentry
3769 % And now comes the text of the entry.
3770}
3771\def\finishentry#1{%
3772 % #1 is the page number.
3773 %
3774 % The following is kludged to not output a line of dots in the index if
3775 % there are no page numbers. The next person who breaks this will be
3776 % cursed by a Unix daemon.
3777 \def\tempa{{\rm }}%
3778 \def\tempb{#1}%
3779 \edef\tempc{\tempa}%
3780 \edef\tempd{\tempb}%
3781 \ifx\tempc\tempd
3782 \ %
3237 \else 3783 \else
3238 \ #2% The page number ends the paragraph. 3784 %
3785 % If we must, put the page number on a line of its own, and fill out
3786 % this line with blank space. (The \hfil is overwhelmed with the
3787 % fill leaders glue in \indexdotfill if the page number does fit.)
3788 \hfil\penalty50
3789 \null\nobreak\indexdotfill % Have leaders before the page number.
3790 %
3791 % The `\ ' here is removed by the implicit \unskip that TeX does as
3792 % part of (the primitive) \par. Without it, a spurious underfull
3793 % \hbox ensues.
3794 \ifpdf
3795 \pdfgettoks#1.%
3796 \ \the\toksA
3797 \else
3798 \ #1%
3799 \fi
3239 \fi 3800 \fi
3240 \fi% 3801 \par
3241 \par 3802 \endgroup
3242\endgroup} 3803}
3243 3804
3244% Like \dotfill except takes at least 1 em. 3805% Like \dotfill except takes at least 1 em.
3245\def\indexdotfill{\cleaders 3806\def\indexdotfill{\cleaders
@@ -3408,6 +3969,12 @@ width0pt\relax} \fi
3408\message{sectioning,} 3969\message{sectioning,}
3409% Chapters, sections, etc. 3970% Chapters, sections, etc.
3410 3971
3972% \unnumberedno is an oxymoron, of course. But we count the unnumbered
3973% sections so that we can refer to them unambiguously in the pdf
3974% outlines by their "section number". We avoid collisions with chapter
3975% numbers by starting them at 10000. (If a document ever has 10000
3976% chapters, we're in trouble anyway, I'm sure.)
3977\newcount\unnumberedno \unnumberedno = 10000
3411\newcount\chapno 3978\newcount\chapno
3412\newcount\secno \secno=0 3979\newcount\secno \secno=0
3413\newcount\subsecno \subsecno=0 3980\newcount\subsecno \subsecno=0
@@ -3415,9 +3982,12 @@ width0pt\relax} \fi
3415 3982
3416% This counter is funny since it counts through charcodes of letters A, B, ... 3983% This counter is funny since it counts through charcodes of letters A, B, ...
3417\newcount\appendixno \appendixno = `\@ 3984\newcount\appendixno \appendixno = `\@
3985%
3418% \def\appendixletter{\char\the\appendixno} 3986% \def\appendixletter{\char\the\appendixno}
3419% We do the following for the sake of pdftex, which needs the actual 3987% We do the following ugly conditional instead of the above simple
3988% construct for the sake of pdftex, which needs the actual
3420% letter in the expansion, not just typeset. 3989% letter in the expansion, not just typeset.
3990%
3421\def\appendixletter{% 3991\def\appendixletter{%
3422 \ifnum\appendixno=`A A% 3992 \ifnum\appendixno=`A A%
3423 \else\ifnum\appendixno=`B B% 3993 \else\ifnum\appendixno=`B B%
@@ -3455,11 +4025,12 @@ width0pt\relax} \fi
3455 4025
3456% Each @chapter defines this as the name of the chapter. 4026% Each @chapter defines this as the name of the chapter.
3457% page headings and footings can use it. @section does likewise. 4027% page headings and footings can use it. @section does likewise.
4028% However, they are not reliable, because we don't use marks.
3458\def\thischapter{} 4029\def\thischapter{}
3459\def\thissection{} 4030\def\thissection{}
3460 4031
3461\newcount\absseclevel % used to calculate proper heading level 4032\newcount\absseclevel % used to calculate proper heading level
3462\newcount\secbase\secbase=0 % @raise/lowersections modify this count 4033\newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count
3463 4034
3464% @raisesections: treat @section as chapter, @subsection as section, etc. 4035% @raisesections: treat @section as chapter, @subsection as section, etc.
3465\def\raisesections{\global\advance\secbase by -1} 4036\def\raisesections{\global\advance\secbase by -1}
@@ -3469,288 +4040,246 @@ width0pt\relax} \fi
3469\def\lowersections{\global\advance\secbase by 1} 4040\def\lowersections{\global\advance\secbase by 1}
3470\let\down=\lowersections % original BFox name 4041\let\down=\lowersections % original BFox name
3471 4042
3472% Choose a numbered-heading macro 4043% we only have subsub.
3473% #1 is heading level if unmodified by @raisesections or @lowersections 4044\chardef\maxseclevel = 3
3474% #2 is text for heading 4045%
3475\def\numhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 4046% A numbered section within an unnumbered changes to unnumbered too.
3476\ifcase\absseclevel 4047% To achive this, remember the "biggest" unnum. sec. we are currently in:
3477 \chapterzzz{#2} 4048\chardef\unmlevel = \maxseclevel
3478\or 4049%
3479 \seczzz{#2} 4050% Trace whether the current chapter is an appendix or not:
3480\or 4051% \chapheadtype is "N" or "A", unnumbered chapters are ignored.
3481 \numberedsubseczzz{#2} 4052\def\chapheadtype{N}
3482\or 4053
3483 \numberedsubsubseczzz{#2} 4054% Choose a heading macro
3484\else 4055% #1 is heading type
3485 \ifnum \absseclevel<0 4056% #2 is heading level
3486 \chapterzzz{#2} 4057% #3 is text for heading
4058\def\genhead#1#2#3{%
4059 % Compute the abs. sec. level:
4060 \absseclevel=#2
4061 \advance\absseclevel by \secbase
4062 % Make sure \absseclevel doesn't fall outside the range:
4063 \ifnum \absseclevel < 0
4064 \absseclevel = 0
3487 \else 4065 \else
3488 \numberedsubsubseczzz{#2} 4066 \ifnum \absseclevel > 3
4067 \absseclevel = 3
4068 \fi
3489 \fi 4069 \fi
3490\fi 4070 % The heading type:
3491} 4071 \def\headtype{#1}%
3492 4072 \if \headtype U%
3493% like \numhead, but chooses appendix heading levels 4073 \ifnum \absseclevel < \unmlevel
3494\def\apphead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 4074 \chardef\unmlevel = \absseclevel
3495\ifcase\absseclevel 4075 \fi
3496 \appendixzzz{#2} 4076 \else
3497\or 4077 % Check for appendix sections:
3498 \appendixsectionzzz{#2} 4078 \ifnum \absseclevel = 0
3499\or 4079 \edef\chapheadtype{\headtype}%
3500 \appendixsubseczzz{#2} 4080 \else
3501\or 4081 \if \headtype A\if \chapheadtype N%
3502 \appendixsubsubseczzz{#2} 4082 \errmessage{@appendix... within a non-appendix chapter}%
3503\else 4083 \fi\fi
3504 \ifnum \absseclevel<0 4084 \fi
3505 \appendixzzz{#2} 4085 % Check for numbered within unnumbered:
4086 \ifnum \absseclevel > \unmlevel
4087 \def\headtype{U}%
4088 \else
4089 \chardef\unmlevel = 3
4090 \fi
4091 \fi
4092 % Now print the heading:
4093 \if \headtype U%
4094 \ifcase\absseclevel
4095 \unnumberedzzz{#3}%
4096 \or \unnumberedseczzz{#3}%
4097 \or \unnumberedsubseczzz{#3}%
4098 \or \unnumberedsubsubseczzz{#3}%
4099 \fi
3506 \else 4100 \else
3507 \appendixsubsubseczzz{#2} 4101 \if \headtype A%
4102 \ifcase\absseclevel
4103 \appendixzzz{#3}%
4104 \or \appendixsectionzzz{#3}%
4105 \or \appendixsubseczzz{#3}%
4106 \or \appendixsubsubseczzz{#3}%
4107 \fi
4108 \else
4109 \ifcase\absseclevel
4110 \chapterzzz{#3}%
4111 \or \seczzz{#3}%
4112 \or \numberedsubseczzz{#3}%
4113 \or \numberedsubsubseczzz{#3}%
4114 \fi
4115 \fi
3508 \fi 4116 \fi
3509\fi 4117 \suppressfirstparagraphindent
3510} 4118}
3511 4119
3512% like \numhead, but chooses numberless heading levels 4120% an interface:
3513\def\unnmhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 4121\def\numhead{\genhead N}
3514\ifcase\absseclevel 4122\def\apphead{\genhead A}
3515 \unnumberedzzz{#2} 4123\def\unnmhead{\genhead U}
3516\or 4124
3517 \unnumberedseczzz{#2} 4125% @chapter, @appendix, @unnumbered. Increment top-level counter, reset
3518\or 4126% all lower-level sectioning counters to zero.
3519 \unnumberedsubseczzz{#2} 4127%
3520\or 4128% Also set \chaplevelprefix, which we prepend to @float sequence numbers
3521 \unnumberedsubsubseczzz{#2} 4129% (e.g., figures), q.v. By default (before any chapter), that is empty.
3522\else 4130\let\chaplevelprefix = \empty
3523 \ifnum \absseclevel<0 4131%
3524 \unnumberedzzz{#2} 4132\outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz
3525 \else 4133\def\chapterzzz#1{%
3526 \unnumberedsubsubseczzz{#2} 4134 % section resetting is \global in case the chapter is in a group, such
3527 \fi 4135 % as an @include file.
3528\fi 4136 \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
4137 \global\advance\chapno by 1
4138 %
4139 % Used for \float.
4140 \gdef\chaplevelprefix{\the\chapno.}%
4141 \resetallfloatnos
4142 %
4143 \message{\putwordChapter\space \the\chapno}%
4144 %
4145 % Write the actual heading.
4146 \chapmacro{#1}{Ynumbered}{\the\chapno}%
4147 %
4148 % So @section and the like are numbered underneath this chapter.
4149 \global\let\section = \numberedsec
4150 \global\let\subsection = \numberedsubsec
4151 \global\let\subsubsection = \numberedsubsubsec
4152}
4153
4154\outer\parseargdef\appendix{\apphead0{#1}} % normally apphead0 calls appendixzzz
4155\def\appendixzzz#1{%
4156 \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
4157 \global\advance\appendixno by 1
4158 \gdef\chaplevelprefix{\appendixletter.}%
4159 \resetallfloatnos
4160 %
4161 \def\appendixnum{\putwordAppendix\space \appendixletter}%
4162 \message{\appendixnum}%
4163 %
4164 \chapmacro{#1}{Yappendix}{\appendixletter}%
4165 %
4166 \global\let\section = \appendixsec
4167 \global\let\subsection = \appendixsubsec
4168 \global\let\subsubsection = \appendixsubsubsec
3529} 4169}
3530 4170
3531% @chapter, @appendix, @unnumbered. 4171\outer\parseargdef\unnumbered{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz
3532\def\thischaptername{No Chapter Title} 4172\def\unnumberedzzz#1{%
3533\outer\def\chapter{\parsearg\chapteryyy} 4173 \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
3534\def\chapteryyy #1{\numhead0{#1}} % normally numhead0 calls chapterzzz 4174 \global\advance\unnumberedno by 1
3535\def\chapterzzz #1{% 4175 %
3536\secno=0 \subsecno=0 \subsubsecno=0 4176 % Since an unnumbered has no number, no prefix for figures.
3537\global\advance \chapno by 1 \message{\putwordChapter\space \the\chapno}% 4177 \global\let\chaplevelprefix = \empty
3538\chapmacro {#1}{\the\chapno}% 4178 \resetallfloatnos
3539\gdef\thissection{#1}% 4179 %
3540\gdef\thischaptername{#1}% 4180 % This used to be simply \message{#1}, but TeX fully expands the
3541% We don't substitute the actual chapter name into \thischapter 4181 % argument to \message. Therefore, if #1 contained @-commands, TeX
3542% because we don't want its macros evaluated now. 4182 % expanded them. For example, in `@unnumbered The @cite{Book}', TeX
3543\xdef\thischapter{\putwordChapter{} \the\chapno: \noexpand\thischaptername}% 4183 % expanded @cite (which turns out to cause errors because \cite is meant
3544\toks0 = {#1}% 4184 % to be executed, not expanded).
3545\edef\temp{\noexpand\writetocentry{\realbackslash chapentry{\the\toks0}% 4185 %
3546 {\the\chapno}}}% 4186 % Anyway, we don't want the fully-expanded definition of @cite to appear
3547\temp 4187 % as a result of the \message, we just want `@cite' itself. We use
3548\donoderef 4188 % \the<toks register> to achieve this: TeX expands \the<toks> only once,
3549\global\let\section = \numberedsec 4189 % simply yielding the contents of <toks register>. (We also do this for
3550\global\let\subsection = \numberedsubsec 4190 % the toc entries.)
3551\global\let\subsubsection = \numberedsubsubsec 4191 \toks0 = {#1}%
3552} 4192 \message{(\the\toks0)}%
3553 4193 %
3554\outer\def\appendix{\parsearg\appendixyyy} 4194 \chapmacro{#1}{Ynothing}{\the\unnumberedno}%
3555\def\appendixyyy #1{\apphead0{#1}} % normally apphead0 calls appendixzzz 4195 %
3556\def\appendixzzz #1{% 4196 \global\let\section = \unnumberedsec
3557\secno=0 \subsecno=0 \subsubsecno=0 4197 \global\let\subsection = \unnumberedsubsec
3558\global\advance \appendixno by 1 4198 \global\let\subsubsection = \unnumberedsubsubsec
3559\message{\putwordAppendix\space \appendixletter}%
3560\chapmacro {#1}{\putwordAppendix{} \appendixletter}%
3561\gdef\thissection{#1}%
3562\gdef\thischaptername{#1}%
3563\xdef\thischapter{\putwordAppendix{} \appendixletter: \noexpand\thischaptername}%
3564\toks0 = {#1}%
3565\edef\temp{\noexpand\writetocentry{\realbackslash appendixentry{\the\toks0}%
3566 {\appendixletter}}}%
3567\temp
3568\appendixnoderef
3569\global\let\section = \appendixsec
3570\global\let\subsection = \appendixsubsec
3571\global\let\subsubsection = \appendixsubsubsec
3572} 4199}
3573 4200
3574% @centerchap is like @unnumbered, but the heading is centered. 4201% @centerchap is like @unnumbered, but the heading is centered.
3575\outer\def\centerchap{\parsearg\centerchapyyy} 4202\outer\parseargdef\centerchap{%
3576\def\centerchapyyy #1{{\let\unnumbchapmacro=\centerchapmacro \unnumberedyyy{#1}}} 4203 % Well, we could do the following in a group, but that would break
4204 % an assumption that \chapmacro is called at the outermost level.
4205 % Thus we are safer this way: --kasal, 24feb04
4206 \let\centerparametersmaybe = \centerparameters
4207 \unnmhead0{#1}%
4208 \let\centerparametersmaybe = \relax
4209}
3577 4210
3578% @top is like @unnumbered. 4211% @top is like @unnumbered.
3579\outer\def\top{\parsearg\unnumberedyyy} 4212\let\top\unnumbered
3580
3581\outer\def\unnumbered{\parsearg\unnumberedyyy}
3582\def\unnumberedyyy #1{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz
3583\def\unnumberedzzz #1{%
3584\secno=0 \subsecno=0 \subsubsecno=0
3585%
3586% This used to be simply \message{#1}, but TeX fully expands the
3587% argument to \message. Therefore, if #1 contained @-commands, TeX
3588% expanded them. For example, in `@unnumbered The @cite{Book}', TeX
3589% expanded @cite (which turns out to cause errors because \cite is meant
3590% to be executed, not expanded).
3591%
3592% Anyway, we don't want the fully-expanded definition of @cite to appear
3593% as a result of the \message, we just want `@cite' itself. We use
3594% \the<toks register> to achieve this: TeX expands \the<toks> only once,
3595% simply yielding the contents of <toks register>. (We also do this for
3596% the toc entries.)
3597\toks0 = {#1}\message{(\the\toks0)}%
3598%
3599\unnumbchapmacro {#1}%
3600\gdef\thischapter{#1}\gdef\thissection{#1}%
3601\toks0 = {#1}%
3602\edef\temp{\noexpand\writetocentry{\realbackslash unnumbchapentry{\the\toks0}}}%
3603\temp
3604\unnumbnoderef
3605\global\let\section = \unnumberedsec
3606\global\let\subsection = \unnumberedsubsec
3607\global\let\subsubsection = \unnumberedsubsubsec
3608}
3609 4213
3610% Sections. 4214% Sections.
3611\outer\def\numberedsec{\parsearg\secyyy} 4215\outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
3612\def\secyyy #1{\numhead1{#1}} % normally calls seczzz 4216\def\seczzz#1{%
3613\def\seczzz #1{% 4217 \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
3614\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % 4218 \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}%
3615\gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}% 4219}
3616\toks0 = {#1}% 4220
3617\edef\temp{\noexpand\writetocentry{\realbackslash secentry{\the\toks0}% 4221\outer\parseargdef\appendixsection{\apphead1{#1}} % normally calls appendixsectionzzz
3618 {\the\chapno}{\the\secno}}}% 4222\def\appendixsectionzzz#1{%
3619\temp 4223 \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
3620\donoderef 4224 \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}%
3621\nobreak 4225}
3622} 4226\let\appendixsec\appendixsection
3623 4227
3624\outer\def\appendixsection{\parsearg\appendixsecyyy} 4228\outer\parseargdef\unnumberedsec{\unnmhead1{#1}} % normally calls unnumberedseczzz
3625\outer\def\appendixsec{\parsearg\appendixsecyyy} 4229\def\unnumberedseczzz#1{%
3626\def\appendixsecyyy #1{\apphead1{#1}} % normally calls appendixsectionzzz 4230 \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
3627\def\appendixsectionzzz #1{% 4231 \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%
3628\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
3629\gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}%
3630\toks0 = {#1}%
3631\edef\temp{\noexpand\writetocentry{\realbackslash secentry{\the\toks0}%
3632 {\appendixletter}{\the\secno}}}%
3633\temp
3634\appendixnoderef
3635\nobreak
3636}
3637
3638\outer\def\unnumberedsec{\parsearg\unnumberedsecyyy}
3639\def\unnumberedsecyyy #1{\unnmhead1{#1}} % normally calls unnumberedseczzz
3640\def\unnumberedseczzz #1{%
3641\plainsecheading {#1}\gdef\thissection{#1}%
3642\toks0 = {#1}%
3643\edef\temp{\noexpand\writetocentry{\realbackslash unnumbsecentry%
3644 {\the\toks0}{\the\chapno}}}%
3645\temp
3646\unnumbnoderef
3647\nobreak
3648} 4232}
3649 4233
3650% Subsections. 4234% Subsections.
3651\outer\def\numberedsubsec{\parsearg\numberedsubsecyyy} 4235\outer\parseargdef\numberedsubsec{\numhead2{#1}} % normally calls numberedsubseczzz
3652\def\numberedsubsecyyy #1{\numhead2{#1}} % normally calls numberedsubseczzz 4236\def\numberedsubseczzz#1{%
3653\def\numberedsubseczzz #1{% 4237 \global\subsubsecno=0 \global\advance\subsecno by 1
3654\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % 4238 \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}%
3655\subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}% 4239}
3656\toks0 = {#1}% 4240
3657\edef\temp{\noexpand\writetocentry{\realbackslash subsecentry{\the\toks0}% 4241\outer\parseargdef\appendixsubsec{\apphead2{#1}} % normally calls appendixsubseczzz
3658 {\the\chapno}{\the\secno}{\the\subsecno}}}% 4242\def\appendixsubseczzz#1{%
3659\temp 4243 \global\subsubsecno=0 \global\advance\subsecno by 1
3660\donoderef 4244 \sectionheading{#1}{subsec}{Yappendix}%
3661\nobreak 4245 {\appendixletter.\the\secno.\the\subsecno}%
3662} 4246}
3663 4247
3664\outer\def\appendixsubsec{\parsearg\appendixsubsecyyy} 4248\outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}} %normally calls unnumberedsubseczzz
3665\def\appendixsubsecyyy #1{\apphead2{#1}} % normally calls appendixsubseczzz 4249\def\unnumberedsubseczzz#1{%
3666\def\appendixsubseczzz #1{% 4250 \global\subsubsecno=0 \global\advance\subsecno by 1
3667\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % 4251 \sectionheading{#1}{subsec}{Ynothing}%
3668\subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}% 4252 {\the\unnumberedno.\the\secno.\the\subsecno}%
3669\toks0 = {#1}%
3670\edef\temp{\noexpand\writetocentry{\realbackslash subsecentry{\the\toks0}%
3671 {\appendixletter}{\the\secno}{\the\subsecno}}}%
3672\temp
3673\appendixnoderef
3674\nobreak
3675}
3676
3677\outer\def\unnumberedsubsec{\parsearg\unnumberedsubsecyyy}
3678\def\unnumberedsubsecyyy #1{\unnmhead2{#1}} %normally calls unnumberedsubseczzz
3679\def\unnumberedsubseczzz #1{%
3680\plainsubsecheading {#1}\gdef\thissection{#1}%
3681\toks0 = {#1}%
3682\edef\temp{\noexpand\writetocentry{\realbackslash unnumbsubsecentry%
3683 {\the\toks0}{\the\chapno}{\the\secno}}}%
3684\temp
3685\unnumbnoderef
3686\nobreak
3687} 4253}
3688 4254
3689% Subsubsections. 4255% Subsubsections.
3690\outer\def\numberedsubsubsec{\parsearg\numberedsubsubsecyyy} 4256\outer\parseargdef\numberedsubsubsec{\numhead3{#1}} % normally numberedsubsubseczzz
3691\def\numberedsubsubsecyyy #1{\numhead3{#1}} % normally numberedsubsubseczzz 4257\def\numberedsubsubseczzz#1{%
3692\def\numberedsubsubseczzz #1{% 4258 \global\advance\subsubsecno by 1
3693\gdef\thissection{#1}\global\advance \subsubsecno by 1 % 4259 \sectionheading{#1}{subsubsec}{Ynumbered}%
3694\subsubsecheading {#1} 4260 {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}%
3695 {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}% 4261}
3696\toks0 = {#1}% 4262
3697\edef\temp{\noexpand\writetocentry{\realbackslash subsubsecentry{\the\toks0}% 4263\outer\parseargdef\appendixsubsubsec{\apphead3{#1}} % normally appendixsubsubseczzz
3698 {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}}}% 4264\def\appendixsubsubseczzz#1{%
3699\temp 4265 \global\advance\subsubsecno by 1
3700\donoderef 4266 \sectionheading{#1}{subsubsec}{Yappendix}%
3701\nobreak 4267 {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}%
3702} 4268}
3703 4269
3704\outer\def\appendixsubsubsec{\parsearg\appendixsubsubsecyyy} 4270\outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}} %normally unnumberedsubsubseczzz
3705\def\appendixsubsubsecyyy #1{\apphead3{#1}} % normally appendixsubsubseczzz 4271\def\unnumberedsubsubseczzz#1{%
3706\def\appendixsubsubseczzz #1{% 4272 \global\advance\subsubsecno by 1
3707\gdef\thissection{#1}\global\advance \subsubsecno by 1 % 4273 \sectionheading{#1}{subsubsec}{Ynothing}%
3708\subsubsecheading {#1} 4274 {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}%
3709 {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}% 4275}
3710\toks0 = {#1}%
3711\edef\temp{\noexpand\writetocentry{\realbackslash subsubsecentry{\the\toks0}%
3712 {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}}}%
3713\temp
3714\appendixnoderef
3715\nobreak
3716}
3717
3718\outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubsecyyy}
3719\def\unnumberedsubsubsecyyy #1{\unnmhead3{#1}} %normally unnumberedsubsubseczzz
3720\def\unnumberedsubsubseczzz #1{%
3721\plainsubsubsecheading {#1}\gdef\thissection{#1}%
3722\toks0 = {#1}%
3723\edef\temp{\noexpand\writetocentry{\realbackslash unnumbsubsubsecentry%
3724 {\the\toks0}{\the\chapno}{\the\secno}{\the\subsecno}}}%
3725\temp
3726\unnumbnoderef
3727\nobreak
3728}
3729
3730% These are variants which are not "outer", so they can appear in @ifinfo.
3731% Actually, they should now be obsolete; ordinary section commands should work.
3732\def\infotop{\parsearg\unnumberedzzz}
3733\def\infounnumbered{\parsearg\unnumberedzzz}
3734\def\infounnumberedsec{\parsearg\unnumberedseczzz}
3735\def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz}
3736\def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
3737
3738\def\infoappendix{\parsearg\appendixzzz}
3739\def\infoappendixsec{\parsearg\appendixseczzz}
3740\def\infoappendixsubsec{\parsearg\appendixsubseczzz}
3741\def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz}
3742
3743\def\infochapter{\parsearg\chapterzzz}
3744\def\infosection{\parsearg\sectionzzz}
3745\def\infosubsection{\parsearg\subsectionzzz}
3746\def\infosubsubsection{\parsearg\subsubsectionzzz}
3747 4276
3748% These macros control what the section commands do, according 4277% These macros control what the section commands do, according
3749% to what kind of chapter we are in (ordinary, appendix, or unnumbered). 4278% to what kind of chapter we are in (ordinary, appendix, or unnumbered).
3750% Define them by default for a numbered chapter. 4279% Define them by default for a numbered chapter.
3751\global\let\section = \numberedsec 4280\let\section = \numberedsec
3752\global\let\subsection = \numberedsubsec 4281\let\subsection = \numberedsubsec
3753\global\let\subsubsection = \numberedsubsubsec 4282\let\subsubsection = \numberedsubsubsec
3754 4283
3755% Define @majorheading, @heading and @subheading 4284% Define @majorheading, @heading and @subheading
3756 4285
@@ -3763,23 +4292,27 @@ width0pt\relax} \fi
3763% if justification is not attempted. Hence \raggedright. 4292% if justification is not attempted. Hence \raggedright.
3764 4293
3765 4294
3766\def\majorheading{\parsearg\majorheadingzzz} 4295\def\majorheading{%
3767\def\majorheadingzzz #1{% 4296 {\advance\chapheadingskip by 10pt \chapbreak }%
3768{\advance\chapheadingskip by 10pt \chapbreak }% 4297 \parsearg\chapheadingzzz
3769{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 4298}
3770 \parindent=0pt\raggedright
3771 \rm #1\hfill}}\bigskip \par\penalty 200}
3772 4299
3773\def\chapheading{\parsearg\chapheadingzzz} 4300\def\chapheading{\chapbreak \parsearg\chapheadingzzz}
3774\def\chapheadingzzz #1{\chapbreak % 4301\def\chapheadingzzz#1{%
3775{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 4302 {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
3776 \parindent=0pt\raggedright 4303 \parindent=0pt\raggedright
3777 \rm #1\hfill}}\bigskip \par\penalty 200} 4304 \rm #1\hfill}}%
4305 \bigskip \par\penalty 200\relax
4306 \suppressfirstparagraphindent
4307}
3778 4308
3779% @heading, @subheading, @subsubheading. 4309% @heading, @subheading, @subsubheading.
3780\def\heading{\parsearg\plainsecheading} 4310\parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{}
3781\def\subheading{\parsearg\plainsubsecheading} 4311 \suppressfirstparagraphindent}
3782\def\subsubheading{\parsearg\plainsubsubsecheading} 4312\parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{}
4313 \suppressfirstparagraphindent}
4314\parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{}
4315 \suppressfirstparagraphindent}
3783 4316
3784% These macros generate a chapter, section, etc. heading only 4317% These macros generate a chapter, section, etc. heading only
3785% (including whitespace, linebreaking, etc. around it), 4318% (including whitespace, linebreaking, etc. around it),
@@ -3788,8 +4321,6 @@ width0pt\relax} \fi
3788%%% Args are the skip and penalty (usually negative) 4321%%% Args are the skip and penalty (usually negative)
3789\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi} 4322\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
3790 4323
3791\def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
3792
3793%%% Define plain chapter starts, and page on/off switching for it 4324%%% Define plain chapter starts, and page on/off switching for it
3794% Parameter controlling skip before chapter headings (if needed) 4325% Parameter controlling skip before chapter headings (if needed)
3795 4326
@@ -3812,7 +4343,7 @@ width0pt\relax} \fi
3812\global\let\pagealignmacro=\chappager 4343\global\let\pagealignmacro=\chappager
3813\global\def\HEADINGSon{\HEADINGSsingle}} 4344\global\def\HEADINGSon{\HEADINGSsingle}}
3814 4345
3815\def\CHAPPAGodd{ 4346\def\CHAPPAGodd{%
3816\global\let\contentsalignmacro = \chapoddpage 4347\global\let\contentsalignmacro = \chapoddpage
3817\global\let\pchapsepmacro=\chapoddpage 4348\global\let\pchapsepmacro=\chapoddpage
3818\global\let\pagealignmacro=\chapoddpage 4349\global\let\pagealignmacro=\chapoddpage
@@ -3820,107 +4351,201 @@ width0pt\relax} \fi
3820 4351
3821\CHAPPAGon 4352\CHAPPAGon
3822 4353
3823\def\CHAPFplain{ 4354% Chapter opening.
3824\global\let\chapmacro=\chfplain 4355%
3825\global\let\unnumbchapmacro=\unnchfplain 4356% #1 is the text, #2 is the section type (Ynumbered, Ynothing,
3826\global\let\centerchapmacro=\centerchfplain} 4357% Yappendix, Yomitfromtoc), #3 the chapter number.
3827 4358%
3828% Plain chapter opening. 4359% To test against our argument.
3829% #1 is the text, #2 the chapter number or empty if unnumbered. 4360\def\Ynothingkeyword{Ynothing}
3830\def\chfplain#1#2{% 4361\def\Yomitfromtockeyword{Yomitfromtoc}
4362\def\Yappendixkeyword{Yappendix}
4363%
4364\def\chapmacro#1#2#3{%
3831 \pchapsepmacro 4365 \pchapsepmacro
3832 {% 4366 {%
3833 \chapfonts \rm 4367 \chapfonts \rm
3834 \def\chapnum{#2}% 4368 %
3835 \setbox0 = \hbox{#2\ifx\chapnum\empty\else\enspace\fi}% 4369 % Have to define \thissection before calling \donoderef, because the
4370 % xref code eventually uses it. On the other hand, it has to be called
4371 % after \pchapsepmacro, or the headline will change too soon.
4372 \gdef\thissection{#1}%
4373 \gdef\thischaptername{#1}%
4374 %
4375 % Only insert the separating space if we have a chapter/appendix
4376 % number, and don't print the unnumbered ``number''.
4377 \def\temptype{#2}%
4378 \ifx\temptype\Ynothingkeyword
4379 \setbox0 = \hbox{}%
4380 \def\toctype{unnchap}%
4381 \gdef\thischapter{#1}%
4382 \else\ifx\temptype\Yomitfromtockeyword
4383 \setbox0 = \hbox{}% contents like unnumbered, but no toc entry
4384 \def\toctype{omit}%
4385 \gdef\thischapter{}%
4386 \else\ifx\temptype\Yappendixkeyword
4387 \setbox0 = \hbox{\putwordAppendix{} #3\enspace}%
4388 \def\toctype{app}%
4389 % We don't substitute the actual chapter name into \thischapter
4390 % because we don't want its macros evaluated now. And we don't
4391 % use \thissection because that changes with each section.
4392 %
4393 \xdef\thischapter{\putwordAppendix{} \appendixletter:
4394 \noexpand\thischaptername}%
4395 \else
4396 \setbox0 = \hbox{#3\enspace}%
4397 \def\toctype{numchap}%
4398 \xdef\thischapter{\putwordChapter{} \the\chapno:
4399 \noexpand\thischaptername}%
4400 \fi\fi\fi
4401 %
4402 % Write the toc entry for this chapter. Must come before the
4403 % \donoderef, because we include the current node name in the toc
4404 % entry, and \donoderef resets it to empty.
4405 \writetocentry{\toctype}{#1}{#3}%
4406 %
4407 % For pdftex, we have to write out the node definition (aka, make
4408 % the pdfdest) after any page break, but before the actual text has
4409 % been typeset. If the destination for the pdf outline is after the
4410 % text, then jumping from the outline may wind up with the text not
4411 % being visible, for instance under high magnification.
4412 \donoderef{#2}%
4413 %
4414 % Typeset the actual heading.
3836 \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright 4415 \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
3837 \hangindent = \wd0 \centerparametersmaybe 4416 \hangindent=\wd0 \centerparametersmaybe
3838 \unhbox0 #1\par}% 4417 \unhbox0 #1\par}%
3839 }% 4418 }%
3840 \nobreak\bigskip % no page break after a chapter title 4419 \nobreak\bigskip % no page break after a chapter title
3841 \nobreak 4420 \nobreak
3842} 4421}
3843 4422
3844% Plain opening for unnumbered.
3845\def\unnchfplain#1{\chfplain{#1}{}}
3846
3847% @centerchap -- centered and unnumbered. 4423% @centerchap -- centered and unnumbered.
3848\let\centerparametersmaybe = \relax 4424\let\centerparametersmaybe = \relax
3849\def\centerchfplain#1{{% 4425\def\centerparameters{%
3850 \def\centerparametersmaybe{% 4426 \advance\rightskip by 3\rightskip
3851 \advance\rightskip by 3\rightskip 4427 \leftskip = \rightskip
3852 \leftskip = \rightskip 4428 \parfillskip = 0pt
3853 \parfillskip = 0pt 4429}
3854 }%
3855 \chfplain{#1}{}%
3856}}
3857 4430
3858\CHAPFplain % The default
3859 4431
4432% I don't think this chapter style is supported any more, so I'm not
4433% updating it with the new noderef stuff. We'll see. --karl, 11aug03.
4434%
4435\def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
4436%
3860\def\unnchfopen #1{% 4437\def\unnchfopen #1{%
3861\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 4438\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
3862 \parindent=0pt\raggedright 4439 \parindent=0pt\raggedright
3863 \rm #1\hfill}}\bigskip \par\nobreak 4440 \rm #1\hfill}}\bigskip \par\nobreak
3864} 4441}
3865
3866\def\chfopen #1#2{\chapoddpage {\chapfonts 4442\def\chfopen #1#2{\chapoddpage {\chapfonts
3867\vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}% 4443\vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
3868\par\penalty 5000 % 4444\par\penalty 5000 %
3869} 4445}
3870
3871\def\centerchfopen #1{% 4446\def\centerchfopen #1{%
3872\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 4447\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
3873 \parindent=0pt 4448 \parindent=0pt
3874 \hfill {\rm #1}\hfill}}\bigskip \par\nobreak 4449 \hfill {\rm #1}\hfill}}\bigskip \par\nobreak
3875} 4450}
3876 4451\def\CHAPFopen{%
3877\def\CHAPFopen{ 4452 \global\let\chapmacro=\chfopen
3878\global\let\chapmacro=\chfopen 4453 \global\let\centerchapmacro=\centerchfopen}
3879\global\let\unnumbchapmacro=\unnchfopen
3880\global\let\centerchapmacro=\centerchfopen}
3881 4454
3882 4455
3883% Section titles. 4456% Section titles. These macros combine the section number parts and
4457% call the generic \sectionheading to do the printing.
4458%
3884\newskip\secheadingskip 4459\newskip\secheadingskip
3885\def\secheadingbreak{\dobreak \secheadingskip {-1000}} 4460\def\secheadingbreak{\dobreak \secheadingskip{-1000}}
3886\def\secheading#1#2#3{\sectionheading{sec}{#2.#3}{#1}}
3887\def\plainsecheading#1{\sectionheading{sec}{}{#1}}
3888 4461
3889% Subsection titles. 4462% Subsection titles.
3890\newskip \subsecheadingskip 4463\newskip\subsecheadingskip
3891\def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}} 4464\def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}}
3892\def\subsecheading#1#2#3#4{\sectionheading{subsec}{#2.#3.#4}{#1}}
3893\def\plainsubsecheading#1{\sectionheading{subsec}{}{#1}}
3894 4465
3895% Subsubsection titles. 4466% Subsubsection titles.
3896\let\subsubsecheadingskip = \subsecheadingskip 4467\def\subsubsecheadingskip{\subsecheadingskip}
3897\let\subsubsecheadingbreak = \subsecheadingbreak 4468\def\subsubsecheadingbreak{\subsecheadingbreak}
3898\def\subsubsecheading#1#2#3#4#5{\sectionheading{subsubsec}{#2.#3.#4.#5}{#1}}
3899\def\plainsubsubsecheading#1{\sectionheading{subsubsec}{}{#1}}
3900 4469
3901 4470
3902% Print any size section title. 4471% Print any size, any type, section title.
3903% 4472%
3904% #1 is the section type (sec/subsec/subsubsec), #2 is the section 4473% #1 is the text, #2 is the section level (sec/subsec/subsubsec), #3 is
3905% number (maybe empty), #3 the text. 4474% the section type for xrefs (Ynumbered, Ynothing, Yappendix), #4 is the
3906\def\sectionheading#1#2#3{% 4475% section number.
3907 {% 4476%
3908 \expandafter\advance\csname #1headingskip\endcsname by \parskip 4477\def\sectionheading#1#2#3#4{%
3909 \csname #1headingbreak\endcsname
3910 }%
3911 {% 4478 {%
3912 % Switch to the right set of fonts. 4479 % Switch to the right set of fonts.
3913 \csname #1fonts\endcsname \rm 4480 \csname #2fonts\endcsname \rm
4481 %
4482 % Insert space above the heading.
4483 \csname #2headingbreak\endcsname
3914 % 4484 %
3915 % Only insert the separating space if we have a section number. 4485 % Only insert the space after the number if we have a section number.
3916 \def\secnum{#2}% 4486 \def\sectionlevel{#2}%
3917 \setbox0 = \hbox{#2\ifx\secnum\empty\else\enspace\fi}% 4487 \def\temptype{#3}%
3918 % 4488 %
4489 \ifx\temptype\Ynothingkeyword
4490 \setbox0 = \hbox{}%
4491 \def\toctype{unn}%
4492 \gdef\thissection{#1}%
4493 \else\ifx\temptype\Yomitfromtockeyword
4494 % for @headings -- no section number, don't include in toc,
4495 % and don't redefine \thissection.
4496 \setbox0 = \hbox{}%
4497 \def\toctype{omit}%
4498 \let\sectionlevel=\empty
4499 \else\ifx\temptype\Yappendixkeyword
4500 \setbox0 = \hbox{#4\enspace}%
4501 \def\toctype{app}%
4502 \gdef\thissection{#1}%
4503 \else
4504 \setbox0 = \hbox{#4\enspace}%
4505 \def\toctype{num}%
4506 \gdef\thissection{#1}%
4507 \fi\fi\fi
4508 %
4509 % Write the toc entry (before \donoderef). See comments in \chapmacro.
4510 \writetocentry{\toctype\sectionlevel}{#1}{#4}%
4511 %
4512 % Write the node reference (= pdf destination for pdftex).
4513 % Again, see comments in \chapmacro.
4514 \donoderef{#3}%
4515 %
4516 % Interline glue will be inserted when the vbox is completed.
4517 % That glue will be a valid breakpoint for the page, since it'll be
4518 % preceded by a whatsit (usually from the \donoderef, or from the
4519 % \writetocentry if there was no node). We don't want to allow that
4520 % break, since then the whatsits could end up on page n while the
4521 % section is on page n+1, thus toc/etc. are wrong. Debian bug 276000.
4522 \nobreak
4523 %
4524 % Output the actual section heading.
3919 \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright 4525 \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
3920 \hangindent = \wd0 % zero if no section number 4526 \hangindent=\wd0 % zero if no section number
3921 \unhbox0 #3}% 4527 \unhbox0 #1}%
3922 }% 4528 }%
3923 \ifdim\parskip<10pt \nobreak\kern10pt\nobreak\kern-\parskip\fi \nobreak 4529 % Add extra space after the heading -- half of whatever came above it.
4530 % Don't allow stretch, though.
4531 \kern .5 \csname #2headingskip\endcsname
4532 %
4533 % Do not let the kern be a potential breakpoint, as it would be if it
4534 % was followed by glue.
4535 \nobreak
4536 %
4537 % We'll almost certainly start a paragraph next, so don't let that
4538 % glue accumulate. (Not a breakpoint because it's preceded by a
4539 % discardable item.)
4540 \vskip-\parskip
4541 %
4542 % This is purely so the last item on the list is a known \penalty >
4543 % 10000. This is so \startdefun can avoid allowing breakpoints after
4544 % section headings. Otherwise, it would insert a valid breakpoint between:
4545 %
4546 % @section sec-whatever
4547 % @deffn def-whatever
4548 \penalty 10001
3924} 4549}
3925 4550
3926 4551
@@ -3929,112 +4554,173 @@ width0pt\relax} \fi
3929\newwrite\tocfile 4554\newwrite\tocfile
3930 4555
3931% Write an entry to the toc file, opening it if necessary. 4556% Write an entry to the toc file, opening it if necessary.
3932% Called from @chapter, etc. We supply {\folio} at the end of the 4557% Called from @chapter, etc.
3933% argument, which will end up as the last argument to the \...entry macro. 4558%
4559% Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno}
4560% We append the current node name (if any) and page number as additional
4561% arguments for the \{chap,sec,...}entry macros which will eventually
4562% read this. The node name is used in the pdf outlines as the
4563% destination to jump to.
3934% 4564%
3935% We open the .toc file here instead of at @setfilename or any other 4565% We open the .toc file for writing here instead of at @setfilename (or
3936% fixed time so that @contents can be put in the document anywhere. 4566% any other fixed time) so that @contents can be anywhere in the document.
4567% But if #1 is `omit', then we don't do anything. This is used for the
4568% table of contents chapter openings themselves.
3937% 4569%
3938\newif\iftocfileopened 4570\newif\iftocfileopened
3939\def\writetocentry#1{% 4571\def\omitkeyword{omit}%
3940 \iftocfileopened\else 4572%
3941 \immediate\openout\tocfile = \jobname.toc 4573\def\writetocentry#1#2#3{%
3942 \global\tocfileopenedtrue 4574 \edef\writetoctype{#1}%
4575 \ifx\writetoctype\omitkeyword \else
4576 \iftocfileopened\else
4577 \immediate\openout\tocfile = \jobname.toc
4578 \global\tocfileopenedtrue
4579 \fi
4580 %
4581 \iflinks
4582 {\atdummies
4583 \edef\temp{%
4584 \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}%
4585 \temp
4586 }%
4587 \fi
3943 \fi 4588 \fi
3944 \iflinks \write\tocfile{#1{\folio}}\fi
3945 % 4589 %
3946 % Tell \shipout to create a page destination if we're doing pdf, which 4590 % Tell \shipout to create a pdf destination on each page, if we're
3947 % will be the target of the links in the table of contents. We can't 4591 % writing pdf. These are used in the table of contents. We can't
3948 % just do it on every page because the title pages are numbered 1 and 4592 % just write one on every page because the title pages are numbered
3949 % 2 (the page numbers aren't printed), and so are the first two pages 4593 % 1 and 2 (the page numbers aren't printed), and so are the first
3950 % of the document. Thus, we'd have two destinations named `1', and 4594 % two pages of the document. Thus, we'd have two destinations named
3951 % two named `2'. 4595 % `1', and two named `2'.
3952 \ifpdf \pdfmakepagedesttrue \fi 4596 \ifpdf \global\pdfmakepagedesttrue \fi
4597}
4598
4599
4600% These characters do not print properly in the Computer Modern roman
4601% fonts, so we must take special care. This is more or less redundant
4602% with the Texinfo input format setup at the end of this file.
4603%
4604\def\activecatcodes{%
4605 \catcode`\"=\active
4606 \catcode`\$=\active
4607 \catcode`\<=\active
4608 \catcode`\>=\active
4609 \catcode`\\=\active
4610 \catcode`\^=\active
4611 \catcode`\_=\active
4612 \catcode`\|=\active
4613 \catcode`\~=\active
4614}
4615
4616
4617% Read the toc file, which is essentially Texinfo input.
4618\def\readtocfile{%
4619 \setupdatafile
4620 \activecatcodes
4621 \input \jobname.toc
3953} 4622}
3954 4623
3955\newskip\contentsrightmargin \contentsrightmargin=1in 4624\newskip\contentsrightmargin \contentsrightmargin=1in
3956\newcount\savepageno 4625\newcount\savepageno
3957\newcount\lastnegativepageno \lastnegativepageno = -1 4626\newcount\lastnegativepageno \lastnegativepageno = -1
3958 4627
3959% Finish up the main text and prepare to read what we've written 4628% Prepare to read what we've written to \tocfile.
3960% to \tocfile.
3961% 4629%
3962\def\startcontents#1{% 4630\def\startcontents#1{%
3963 % If @setchapternewpage on, and @headings double, the contents should 4631 % If @setchapternewpage on, and @headings double, the contents should
3964 % start on an odd page, unlike chapters. Thus, we maintain 4632 % start on an odd page, unlike chapters. Thus, we maintain
3965 % \contentsalignmacro in parallel with \pagealignmacro. 4633 % \contentsalignmacro in parallel with \pagealignmacro.
3966 % From: Torbjorn Granlund <tege@matematik.su.se> 4634 % From: Torbjorn Granlund <tege@matematik.su.se>
3967 \contentsalignmacro 4635 \contentsalignmacro
3968 \immediate\closeout\tocfile 4636 \immediate\closeout\tocfile
3969 % 4637 %
3970 % Don't need to put `Contents' or `Short Contents' in the headline. 4638 % Don't need to put `Contents' or `Short Contents' in the headline.
3971 % It is abundantly clear what they are. 4639 % It is abundantly clear what they are.
3972 \unnumbchapmacro{#1}\def\thischapter{}% 4640 \def\thischapter{}%
3973 \savepageno = \pageno 4641 \chapmacro{#1}{Yomitfromtoc}{}%
3974 \begingroup % Set up to handle contents files properly. 4642 %
3975 \catcode`\\=0 \catcode`\{=1 \catcode`\}=2 \catcode`\@=11 4643 \savepageno = \pageno
3976 % We can't do this, because then an actual ^ in a section 4644 \begingroup % Set up to handle contents files properly.
3977 % title fails, e.g., @chapter ^ -- exponentiation. --karl, 9jul97. 4645 \raggedbottom % Worry more about breakpoints than the bottom.
3978 %\catcode`\^=7 % to see ^^e4 as \"a etc. juha@piuha.ydi.vtt.fi 4646 \advance\hsize by -\contentsrightmargin % Don't use the full line length.
3979 \raggedbottom % Worry more about breakpoints than the bottom. 4647 %
3980 \advance\hsize by -\contentsrightmargin % Don't use the full line length. 4648 % Roman numerals for page numbers.
3981 % 4649 \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
3982 % Roman numerals for page numbers.
3983 \ifnum \pageno>0 \pageno = \lastnegativepageno \fi
3984} 4650}
3985 4651
3986 4652
3987% Normal (long) toc. 4653% Normal (long) toc.
3988\def\contents{% 4654\def\contents{%
3989 \startcontents{\putwordTOC}% 4655 \startcontents{\putwordTOC}%
3990 \openin 1 \jobname.toc 4656 \openin 1 \jobname.toc
3991 \ifeof 1 \else 4657 \ifeof 1 \else
3992 \closein 1 4658 \readtocfile
3993 \input \jobname.toc 4659 \fi
3994 \fi 4660 \vfill \eject
3995 \vfill \eject 4661 \contentsalignmacro % in case @setchapternewpage odd is in effect
3996 \contentsalignmacro % in case @setchapternewpage odd is in effect 4662 \ifeof 1 \else
3997 \pdfmakeoutlines 4663 \pdfmakeoutlines
3998 \endgroup 4664 \fi
3999 \lastnegativepageno = \pageno 4665 \closein 1
4000 \pageno = \savepageno 4666 \endgroup
4667 \lastnegativepageno = \pageno
4668 \global\pageno = \savepageno
4001} 4669}
4002 4670
4003% And just the chapters. 4671% And just the chapters.
4004\def\summarycontents{% 4672\def\summarycontents{%
4005 \startcontents{\putwordShortTOC}% 4673 \startcontents{\putwordShortTOC}%
4006 % 4674 %
4007 \let\chapentry = \shortchapentry 4675 \let\numchapentry = \shortchapentry
4008 \let\appendixentry = \shortappendixentry 4676 \let\appentry = \shortchapentry
4009 \let\unnumbchapentry = \shortunnumberedentry 4677 \let\unnchapentry = \shortunnchapentry
4010 % We want a true roman here for the page numbers. 4678 % We want a true roman here for the page numbers.
4011 \secfonts 4679 \secfonts
4012 \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl 4680 \let\rm=\shortcontrm \let\bf=\shortcontbf
4013 \rm 4681 \let\sl=\shortcontsl \let\tt=\shortconttt
4014 \hyphenpenalty = 10000 4682 \rm
4015 \advance\baselineskip by 1pt % Open it up a little. 4683 \hyphenpenalty = 10000
4016 \def\secentry ##1##2##3##4{} 4684 \advance\baselineskip by 1pt % Open it up a little.
4017 \def\unnumbsecentry ##1##2##3{} 4685 \def\numsecentry##1##2##3##4{}
4018 \def\subsecentry ##1##2##3##4##5{} 4686 \let\appsecentry = \numsecentry
4019 \def\unnumbsubsecentry ##1##2##3##4{} 4687 \let\unnsecentry = \numsecentry
4020 \def\subsubsecentry ##1##2##3##4##5##6{} 4688 \let\numsubsecentry = \numsecentry
4021 \def\unnumbsubsubsecentry ##1##2##3##4##5{} 4689 \let\appsubsecentry = \numsecentry
4022 \openin 1 \jobname.toc 4690 \let\unnsubsecentry = \numsecentry
4023 \ifeof 1 \else 4691 \let\numsubsubsecentry = \numsecentry
4024 \closein 1 4692 \let\appsubsubsecentry = \numsecentry
4025 \input \jobname.toc 4693 \let\unnsubsubsecentry = \numsecentry
4026 \fi 4694 \openin 1 \jobname.toc
4027 \vfill \eject 4695 \ifeof 1 \else
4028 \contentsalignmacro % in case @setchapternewpage odd is in effect 4696 \readtocfile
4029 \endgroup 4697 \fi
4030 \lastnegativepageno = \pageno 4698 \closein 1
4031 \pageno = \savepageno 4699 \vfill \eject
4700 \contentsalignmacro % in case @setchapternewpage odd is in effect
4701 \endgroup
4702 \lastnegativepageno = \pageno
4703 \global\pageno = \savepageno
4032} 4704}
4033\let\shortcontents = \summarycontents 4705\let\shortcontents = \summarycontents
4034 4706
4035\ifpdf 4707% Typeset the label for a chapter or appendix for the short contents.
4036 \pdfcatalog{/PageMode /UseOutlines}% 4708% The arg is, e.g., `A' for an appendix, or `3' for a chapter.
4037\fi 4709%
4710\def\shortchaplabel#1{%
4711 % This space should be enough, since a single number is .5em, and the
4712 % widest letter (M) is 1em, at least in the Computer Modern fonts.
4713 % But use \hss just in case.
4714 % (This space doesn't include the extra space that gets added after
4715 % the label; that gets put in by \shortchapentry above.)
4716 %
4717 % We'd like to right-justify chapter numbers, but that looks strange
4718 % with appendix letters. And right-justifying numbers and
4719 % left-justifying letters looks strange when there is less than 10
4720 % chapters. Have to read the whole toc once to know how many chapters
4721 % there are before deciding ...
4722 \hbox to 1em{#1\hss}%
4723}
4038 4724
4039% These macros generate individual entries in the table of contents. 4725% These macros generate individual entries in the table of contents.
4040% The first argument is the chapter or section name. 4726% The first argument is the chapter or section name.
@@ -4042,57 +4728,46 @@ width0pt\relax} \fi
4042% The arguments in between are the chapter number, section number, ... 4728% The arguments in between are the chapter number, section number, ...
4043 4729
4044% Chapters, in the main contents. 4730% Chapters, in the main contents.
4045\def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}} 4731\def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}}
4046% 4732%
4047% Chapters, in the short toc. 4733% Chapters, in the short toc.
4048% See comments in \dochapentry re vbox and related settings. 4734% See comments in \dochapentry re vbox and related settings.
4049\def\shortchapentry#1#2#3{% 4735\def\shortchapentry#1#2#3#4{%
4050 \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#3\egroup}% 4736 \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}%
4051} 4737}
4052 4738
4053% Appendices, in the main contents. 4739% Appendices, in the main contents.
4054\def\appendixentry#1#2#3{\dochapentry{\putwordAppendix{} #2\labelspace#1}{#3}} 4740% Need the word Appendix, and a fixed-size box.
4055%
4056% Appendices, in the short toc.
4057\let\shortappendixentry = \shortchapentry
4058
4059% Typeset the label for a chapter or appendix for the short contents.
4060% The arg is, e.g., `Appendix A' for an appendix, or `3' for a chapter.
4061% We could simplify the code here by writing out an \appendixentry
4062% command in the toc file for appendices, instead of using \chapentry
4063% for both, but it doesn't seem worth it.
4064% 4741%
4065\newdimen\shortappendixwidth 4742\def\appendixbox#1{%
4743 % We use M since it's probably the widest letter.
4744 \setbox0 = \hbox{\putwordAppendix{} M}%
4745 \hbox to \wd0{\putwordAppendix{} #1\hss}}
4066% 4746%
4067\def\shortchaplabel#1{% 4747\def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\labelspace#1}{#4}}
4068 % This space should be enough, since a single number is .5em, and the
4069 % widest letter (M) is 1em, at least in the Computer Modern fonts.
4070 % But use \hss just in case.
4071 % (This space doesn't include the extra space that gets added after
4072 % the label; that gets put in by \shortchapentry above.)
4073 \dimen0 = 1em
4074 \hbox to \dimen0{#1\hss}%
4075}
4076 4748
4077% Unnumbered chapters. 4749% Unnumbered chapters.
4078\def\unnumbchapentry#1#2{\dochapentry{#1}{#2}} 4750\def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}}
4079\def\shortunnumberedentry#1#2{\tocentry{#1}{\doshortpageno\bgroup#2\egroup}} 4751\def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}}
4080 4752
4081% Sections. 4753% Sections.
4082\def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}} 4754\def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}}
4083\def\unnumbsecentry#1#2#3{\dosecentry{#1}{#3}} 4755\let\appsecentry=\numsecentry
4756\def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}}
4084 4757
4085% Subsections. 4758% Subsections.
4086\def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}} 4759\def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}}
4087\def\unnumbsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}} 4760\let\appsubsecentry=\numsubsecentry
4761\def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}}
4088 4762
4089% And subsubsections. 4763% And subsubsections.
4090\def\subsubsecentry#1#2#3#4#5#6{% 4764\def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}}
4091 \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}} 4765\let\appsubsubsecentry=\numsubsubsecentry
4092\def\unnumbsubsubsecentry#1#2#3#4#5{\dosubsubsecentry{#1}{#5}} 4766\def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}}
4093 4767
4094% This parameter controls the indentation of the various levels. 4768% This parameter controls the indentation of the various levels.
4095\newdimen\tocindent \tocindent = 3pc 4769% Same as \defaultparindent.
4770\newdimen\tocindent \tocindent = 15pt
4096 4771
4097% Now for the actual typesetting. In all these, #1 is the text and #2 is the 4772% Now for the actual typesetting. In all these, #1 is the text and #2 is the
4098% page number. 4773% page number.
@@ -4123,17 +4798,8 @@ width0pt\relax} \fi
4123 \tocentry{#1}{\dopageno\bgroup#2\egroup}% 4798 \tocentry{#1}{\dopageno\bgroup#2\egroup}%
4124\endgroup} 4799\endgroup}
4125 4800
4126% Final typesetting of a toc entry; we use the same \entry macro as for 4801% We use the same \entry macro as for the index entries.
4127% the index entries, but we want to suppress hyphenation here. (We 4802\let\tocentry = \entry
4128% can't do that in the \entry macro, since index entries might consist
4129% of hyphenated-identifiers-that-do-not-fit-on-a-line-and-nothing-else.)
4130\def\tocentry#1#2{\begingroup
4131 \vskip 0pt plus1pt % allow a little stretch for the sake of nice page breaks
4132 % Do not use \turnoffactive in these arguments. Since the toc is
4133 % typeset in cmr, characters such as _ would come out wrong; we
4134 % have to do the usual translation tricks.
4135 \entry{#1}{#2}%
4136\endgroup}
4137 4803
4138% Space between chapter (or whatever) number and the title. 4804% Space between chapter (or whatever) number and the title.
4139\def\labelspace{\hskip1em \relax} 4805\def\labelspace{\hskip1em \relax}
@@ -4143,8 +4809,8 @@ width0pt\relax} \fi
4143 4809
4144\def\chapentryfonts{\secfonts \rm} 4810\def\chapentryfonts{\secfonts \rm}
4145\def\secentryfonts{\textfonts} 4811\def\secentryfonts{\textfonts}
4146\let\subsecentryfonts = \textfonts 4812\def\subsecentryfonts{\textfonts}
4147\let\subsubsecentryfonts = \textfonts 4813\def\subsubsecentryfonts{\textfonts}
4148 4814
4149 4815
4150\message{environments,} 4816\message{environments,}
@@ -4171,10 +4837,10 @@ width0pt\relax} \fi
4171% The text. (`r' is open on the right, `e' somewhat less so on the left.) 4837% The text. (`r' is open on the right, `e' somewhat less so on the left.)
4172\setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt} 4838\setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt}
4173% 4839%
4174\global\setbox\errorbox=\hbox to \dimen0{\hfil 4840\setbox\errorbox=\hbox to \dimen0{\hfil
4175 \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right. 4841 \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
4176 \advance\hsize by -2\dimen2 % Rules. 4842 \advance\hsize by -2\dimen2 % Rules.
4177 \vbox{ 4843 \vbox{%
4178 \hrule height\dimen2 4844 \hrule height\dimen2
4179 \hbox{\vrule width\dimen2 \kern3pt % Space to left of text. 4845 \hbox{\vrule width\dimen2 \kern3pt % Space to left of text.
4180 \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below. 4846 \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
@@ -4188,17 +4854,16 @@ width0pt\relax} \fi
4188% One exception: @ is still an escape character, so that @end tex works. 4854% One exception: @ is still an escape character, so that @end tex works.
4189% But \@ or @@ will get a plain tex @ character. 4855% But \@ or @@ will get a plain tex @ character.
4190 4856
4191\def\tex{\begingroup 4857\envdef\tex{%
4192 \catcode `\\=0 \catcode `\{=1 \catcode `\}=2 4858 \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
4193 \catcode `\$=3 \catcode `\&=4 \catcode `\#=6 4859 \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
4194 \catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie 4860 \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
4195 \catcode `\%=14 4861 \catcode `\%=14
4196 \catcode 43=12 % plus 4862 \catcode `\+=\other
4197 \catcode`\"=12 4863 \catcode `\"=\other
4198 \catcode`\==12 4864 \catcode `\|=\other
4199 \catcode`\|=12 4865 \catcode `\<=\other
4200 \catcode`\<=12 4866 \catcode `\>=\other
4201 \catcode`\>=12
4202 \escapechar=`\\ 4867 \escapechar=`\\
4203 % 4868 %
4204 \let\b=\ptexb 4869 \let\b=\ptexb
@@ -4210,19 +4875,24 @@ width0pt\relax} \fi
4210 \let\equiv=\ptexequiv 4875 \let\equiv=\ptexequiv
4211 \let\!=\ptexexclam 4876 \let\!=\ptexexclam
4212 \let\i=\ptexi 4877 \let\i=\ptexi
4878 \let\indent=\ptexindent
4879 \let\noindent=\ptexnoindent
4213 \let\{=\ptexlbrace 4880 \let\{=\ptexlbrace
4214 \let\+=\tabalign 4881 \let\+=\tabalign
4215 \let\}=\ptexrbrace 4882 \let\}=\ptexrbrace
4883 \let\/=\ptexslash
4216 \let\*=\ptexstar 4884 \let\*=\ptexstar
4217 \let\t=\ptext 4885 \let\t=\ptext
4886 \let\frenchspacing=\plainfrenchspacing
4218 % 4887 %
4219 \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}% 4888 \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
4220 \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}% 4889 \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
4221 \def\@{@}% 4890 \def\@{@}%
4222\let\Etex=\endgroup} 4891}
4892% There is no need to define \Etex.
4223 4893
4224% Define @lisp ... @end lisp. 4894% Define @lisp ... @end lisp.
4225% @lisp does a \begingroup so it can rebind things, 4895% @lisp environment forms a group so it can rebind things,
4226% including the definition of @end lisp (which normally is erroneous). 4896% including the definition of @end lisp (which normally is erroneous).
4227 4897
4228% Amount to narrow the margins by for @lisp. 4898% Amount to narrow the margins by for @lisp.
@@ -4233,34 +4903,25 @@ width0pt\relax} \fi
4233% have any width. 4903% have any width.
4234\def\lisppar{\null\endgraf} 4904\def\lisppar{\null\endgraf}
4235 4905
4236% Make each space character in the input produce a normal interword
4237% space in the output. Don't allow a line break at this space, as this
4238% is used only in environments like @example, where each line of input
4239% should produce a line of output anyway.
4240%
4241{\obeyspaces %
4242\gdef\sepspaces{\obeyspaces\let =\tie}}
4243
4244% Define \obeyedspace to be our active space, whatever it is. This is
4245% for use in \parsearg.
4246{\sepspaces%
4247\global\let\obeyedspace= }
4248
4249% This space is always present above and below environments. 4906% This space is always present above and below environments.
4250\newskip\envskipamount \envskipamount = 0pt 4907\newskip\envskipamount \envskipamount = 0pt
4251 4908
4252% Make spacing and below environment symmetrical. We use \parskip here 4909% Make spacing and below environment symmetrical. We use \parskip here
4253% to help in doing that, since in @example-like environments \parskip 4910% to help in doing that, since in @example-like environments \parskip
4254% is reset to zero; thus the \afterenvbreak inserts no space -- but the 4911% is reset to zero; thus the \afterenvbreak inserts no space -- but the
4255% start of the next paragraph will insert \parskip 4912% start of the next paragraph will insert \parskip.
4256% 4913%
4257\def\aboveenvbreak{{% 4914\def\aboveenvbreak{{%
4258 \ifnum\lastpenalty < 10000 4915 % =10000 instead of <10000 because of a special case in \itemzzz and
4916 % \sectionheading, q.v.
4917 \ifnum \lastpenalty=10000 \else
4259 \advance\envskipamount by \parskip 4918 \advance\envskipamount by \parskip
4260 \endgraf 4919 \endgraf
4261 \ifdim\lastskip<\envskipamount 4920 \ifdim\lastskip<\envskipamount
4262 \removelastskip 4921 \removelastskip
4263 \penalty-50 4922 % it's not a good place to break if the last penalty was \nobreak
4923 % or better ...
4924 \ifnum\lastpenalty<10000 \penalty-50 \fi
4264 \vskip\envskipamount 4925 \vskip\envskipamount
4265 \fi 4926 \fi
4266 \fi 4927 \fi
@@ -4268,7 +4929,8 @@ width0pt\relax} \fi
4268 4929
4269\let\afterenvbreak = \aboveenvbreak 4930\let\afterenvbreak = \aboveenvbreak
4270 4931
4271% \nonarrowing is a flag. If "set", @lisp etc don't narrow margins. 4932% \nonarrowing is a flag. If "set", @lisp etc don't narrow margins; it will
4933% also clear it, so that its embedded environments do the narrowing again.
4272\let\nonarrowing=\relax 4934\let\nonarrowing=\relax
4273 4935
4274% @cartouche ... @end cartouche: draw rectangle w/rounded corners around 4936% @cartouche ... @end cartouche: draw rectangle w/rounded corners around
@@ -4292,181 +4954,187 @@ width0pt\relax} \fi
4292% 4954%
4293\newskip\lskip\newskip\rskip 4955\newskip\lskip\newskip\rskip
4294 4956
4295\long\def\cartouche{% 4957\envdef\cartouche{%
4296\begingroup 4958 \ifhmode\par\fi % can't be in the midst of a paragraph.
4297 \lskip=\leftskip \rskip=\rightskip 4959 \startsavinginserts
4298 \leftskip=0pt\rightskip=0pt %we want these *outside*. 4960 \lskip=\leftskip \rskip=\rightskip
4299 \cartinner=\hsize \advance\cartinner by-\lskip 4961 \leftskip=0pt\rightskip=0pt % we want these *outside*.
4300 \advance\cartinner by-\rskip 4962 \cartinner=\hsize \advance\cartinner by-\lskip
4301 \cartouter=\hsize 4963 \advance\cartinner by-\rskip
4302 \advance\cartouter by 18.4pt % allow for 3pt kerns on either 4964 \cartouter=\hsize
4303% side, and for 6pt waste from 4965 \advance\cartouter by 18.4pt % allow for 3pt kerns on either
4304% each corner char, and rule thickness 4966 % side, and for 6pt waste from
4305 \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip 4967 % each corner char, and rule thickness
4306 % Flag to tell @lisp, etc., not to narrow margin. 4968 \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
4307 \let\nonarrowing=\comment 4969 % Flag to tell @lisp, etc., not to narrow margin.
4308 \vbox\bgroup 4970 \let\nonarrowing = t%
4309 \baselineskip=0pt\parskip=0pt\lineskip=0pt 4971 \vbox\bgroup
4310 \carttop 4972 \baselineskip=0pt\parskip=0pt\lineskip=0pt
4311 \hbox\bgroup 4973 \carttop
4312 \hskip\lskip 4974 \hbox\bgroup
4313 \vrule\kern3pt 4975 \hskip\lskip
4314 \vbox\bgroup 4976 \vrule\kern3pt
4315 \hsize=\cartinner 4977 \vbox\bgroup
4316 \kern3pt 4978 \kern3pt
4317 \begingroup 4979 \hsize=\cartinner
4318 \baselineskip=\normbskip 4980 \baselineskip=\normbskip
4319 \lineskip=\normlskip 4981 \lineskip=\normlskip
4320 \parskip=\normpskip 4982 \parskip=\normpskip
4321 \vskip -\parskip 4983 \vskip -\parskip
4984 \comment % For explanation, see the end of \def\group.
4985}
4322\def\Ecartouche{% 4986\def\Ecartouche{%
4323 \endgroup 4987 \ifhmode\par\fi
4324 \kern3pt 4988 \kern3pt
4325 \egroup 4989 \egroup
4326 \kern3pt\vrule 4990 \kern3pt\vrule
4327 \hskip\rskip 4991 \hskip\rskip
4328 \egroup 4992 \egroup
4329 \cartbot 4993 \cartbot
4330 \egroup 4994 \egroup
4331\endgroup 4995 \checkinserts
4332}} 4996}
4333 4997
4334 4998
4335% This macro is called at the beginning of all the @example variants, 4999% This macro is called at the beginning of all the @example variants,
4336% inside a group. 5000% inside a group.
4337\def\nonfillstart{% 5001\def\nonfillstart{%
4338 \aboveenvbreak 5002 \aboveenvbreak
4339 \inENV % This group ends at the end of the body
4340 \hfuzz = 12pt % Don't be fussy 5003 \hfuzz = 12pt % Don't be fussy
4341 \sepspaces % Make spaces be word-separators rather than space tokens. 5004 \sepspaces % Make spaces be word-separators rather than space tokens.
4342 \singlespace
4343 \let\par = \lisppar % don't ignore blank lines 5005 \let\par = \lisppar % don't ignore blank lines
4344 \obeylines % each line of input is a line of output 5006 \obeylines % each line of input is a line of output
4345 \parskip = 0pt 5007 \parskip = 0pt
4346 \parindent = 0pt 5008 \parindent = 0pt
4347 \emergencystretch = 0pt % don't try to avoid overfull boxes 5009 \emergencystretch = 0pt % don't try to avoid overfull boxes
4348 % @cartouche defines \nonarrowing to inhibit narrowing
4349 % at next level down.
4350 \ifx\nonarrowing\relax 5010 \ifx\nonarrowing\relax
4351 \advance \leftskip by \lispnarrowing 5011 \advance \leftskip by \lispnarrowing
4352 \exdentamount=\lispnarrowing 5012 \exdentamount=\lispnarrowing
4353 \let\exdent=\nofillexdent 5013 \else
4354 \let\nonarrowing=\relax 5014 \let\nonarrowing = \relax
4355 \fi 5015 \fi
5016 \let\exdent=\nofillexdent
4356} 5017}
4357 5018
4358% Define the \E... control sequence only if we are inside the particular 5019% If you want all examples etc. small: @set dispenvsize small.
4359% environment, so the error checking in \end will work. 5020% If you want even small examples the full size: @set dispenvsize nosmall.
5021% This affects the following displayed environments:
5022% @example, @display, @format, @lisp
4360% 5023%
4361% To end an @example-like environment, we first end the paragraph (via 5024\def\smallword{small}
4362% \afterenvbreak's vertical glue), and then the group. That way we keep 5025\def\nosmallword{nosmall}
4363% the zero \parskip that the environments set -- \parskip glue will be 5026\let\SETdispenvsize\relax
4364% inserted at the beginning of the next paragraph in the document, after 5027\def\setnormaldispenv{%
4365% the environment. 5028 \ifx\SETdispenvsize\smallword
4366% 5029 \smallexamplefonts \rm
4367\def\nonfillfinish{\afterenvbreak\endgroup} 5030 \fi
5031}
5032\def\setsmalldispenv{%
5033 \ifx\SETdispenvsize\nosmallword
5034 \else
5035 \smallexamplefonts \rm
5036 \fi
5037}
4368 5038
4369% @lisp: indented, narrowed, typewriter font. 5039% We often define two environments, @foo and @smallfoo.
4370\def\lisp{\begingroup 5040% Let's do it by one command:
4371 \nonfillstart 5041\def\makedispenv #1#2{
4372 \let\Elisp = \nonfillfinish 5042 \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}
4373 \tt 5043 \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}
4374 \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special. 5044 \expandafter\let\csname E#1\endcsname \afterenvbreak
4375 \gobble % eat return 5045 \expandafter\let\csname Esmall#1\endcsname \afterenvbreak
4376} 5046}
4377 5047
4378% @example: Same as @lisp. 5048% Define two synonyms:
4379\def\example{\begingroup \def\Eexample{\nonfillfinish\endgroup}\lisp} 5049\def\maketwodispenvs #1#2#3{
5050 \makedispenv{#1}{#3}
5051 \makedispenv{#2}{#3}
5052}
4380 5053
4381% @small... is usually equivalent to the non-small (@smallbook 5054% @lisp: indented, narrowed, typewriter font; @example: same as @lisp.
4382% redefines). We must call \example (or whatever) last in the
4383% definition, since it reads the return following the @example (or
4384% whatever) command.
4385%
4386% This actually allows (for example) @end display inside an
4387% @smalldisplay. Too bad, but makeinfo will catch the error anyway.
4388% 5055%
4389\def\smalldisplay{\begingroup\def\Esmalldisplay{\nonfillfinish\endgroup}\display} 5056% @smallexample and @smalllisp: use smaller fonts.
4390\def\smallexample{\begingroup\def\Esmallexample{\nonfillfinish\endgroup}\lisp}
4391\def\smallformat{\begingroup\def\Esmallformat{\nonfillfinish\endgroup}\format}
4392\def\smalllisp{\begingroup\def\Esmalllisp{\nonfillfinish\endgroup}\lisp}
4393
4394% Real @smallexample and @smalllisp (when @smallbook): use smaller fonts.
4395% Originally contributed by Pavel@xerox. 5057% Originally contributed by Pavel@xerox.
4396\def\smalllispx{\begingroup 5058%
4397 \def\Esmalllisp{\nonfillfinish\endgroup}% 5059\maketwodispenvs {lisp}{example}{%
4398 \def\Esmallexample{\nonfillfinish\endgroup}% 5060 \nonfillstart
4399 \smallexamplefonts 5061 \tt
4400 \lisp 5062 \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
5063 \gobble % eat return
4401} 5064}
4402 5065
4403% @display: same as @lisp except keep current font. 5066% @display/@smalldisplay: same as @lisp except keep current font.
4404% 5067%
4405\def\display{\begingroup 5068\makedispenv {display}{%
4406 \nonfillstart 5069 \nonfillstart
4407 \let\Edisplay = \nonfillfinish
4408 \gobble 5070 \gobble
4409} 5071}
4410%
4411% @smalldisplay (when @smallbook): @display plus smaller fonts.
4412%
4413\def\smalldisplayx{\begingroup
4414 \def\Esmalldisplay{\nonfillfinish\endgroup}%
4415 \smallexamplefonts \rm
4416 \display
4417}
4418 5072
4419% @format: same as @display except don't narrow margins. 5073% @format/@smallformat: same as @display except don't narrow margins.
4420% 5074%
4421\def\format{\begingroup 5075\makedispenv{format}{%
4422 \let\nonarrowing = t 5076 \let\nonarrowing = t%
4423 \nonfillstart 5077 \nonfillstart
4424 \let\Eformat = \nonfillfinish
4425 \gobble 5078 \gobble
4426} 5079}
4427%
4428% @smallformat (when @smallbook): @format plus smaller fonts.
4429%
4430\def\smallformatx{\begingroup
4431 \def\Esmallformat{\nonfillfinish\endgroup}%
4432 \smallexamplefonts \rm
4433 \format
4434}
4435 5080
4436% @flushleft (same as @format). 5081% @flushleft: same as @format, but doesn't obey \SETdispenvsize.
4437% 5082\envdef\flushleft{%
4438\def\flushleft{\begingroup \def\Eflushleft{\nonfillfinish\endgroup}\format} 5083 \let\nonarrowing = t%
5084 \nonfillstart
5085 \gobble
5086}
5087\let\Eflushleft = \afterenvbreak
4439 5088
4440% @flushright. 5089% @flushright.
4441% 5090%
4442\def\flushright{\begingroup 5091\envdef\flushright{%
4443 \let\nonarrowing = t 5092 \let\nonarrowing = t%
4444 \nonfillstart 5093 \nonfillstart
4445 \let\Eflushright = \nonfillfinish
4446 \advance\leftskip by 0pt plus 1fill 5094 \advance\leftskip by 0pt plus 1fill
4447 \gobble 5095 \gobble
4448} 5096}
5097\let\Eflushright = \afterenvbreak
4449 5098
4450 5099
4451% @quotation does normal linebreaking (hence we can't use \nonfillstart) 5100% @quotation does normal linebreaking (hence we can't use \nonfillstart)
4452% and narrows the margins. 5101% and narrows the margins. We keep \parskip nonzero in general, since
5102% we're doing normal filling. So, when using \aboveenvbreak and
5103% \afterenvbreak, temporarily make \parskip 0.
4453% 5104%
4454\def\quotation{% 5105\envdef\quotation{%
4455 \begingroup\inENV %This group ends at the end of the @quotation body
4456 {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip 5106 {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
4457 \singlespace
4458 \parindent=0pt 5107 \parindent=0pt
4459 % We have retained a nonzero parskip for the environment, since we're
4460 % doing normal filling. So to avoid extra space below the environment...
4461 \def\Equotation{\parskip = 0pt \nonfillfinish}%
4462 % 5108 %
4463 % @cartouche defines \nonarrowing to inhibit narrowing at next level down. 5109 % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
4464 \ifx\nonarrowing\relax 5110 \ifx\nonarrowing\relax
4465 \advance\leftskip by \lispnarrowing 5111 \advance\leftskip by \lispnarrowing
4466 \advance\rightskip by \lispnarrowing 5112 \advance\rightskip by \lispnarrowing
4467 \exdentamount = \lispnarrowing 5113 \exdentamount = \lispnarrowing
5114 \else
4468 \let\nonarrowing = \relax 5115 \let\nonarrowing = \relax
4469 \fi 5116 \fi
5117 \parsearg\quotationlabel
5118}
5119
5120% We have retained a nonzero parskip for the environment, since we're
5121% doing normal filling.
5122%
5123\def\Equotation{%
5124 \par
5125 \ifx\quotationauthor\undefined\else
5126 % indent a bit.
5127 \leftline{\kern 2\leftskip \sl ---\quotationauthor}%
5128 \fi
5129 {\parskip=0pt \afterenvbreak}%
5130}
5131
5132% If we're given an argument, typeset it in bold with a colon after.
5133\def\quotationlabel#1{%
5134 \def\temp{#1}%
5135 \ifx\temp\empty \else
5136 {\bf #1: }%
5137 \fi
4470} 5138}
4471 5139
4472 5140
@@ -4477,14 +5145,18 @@ width0pt\relax} \fi
4477% 5145%
4478% [Knuth]: Donald Ervin Knuth, 1996. The TeXbook. 5146% [Knuth]: Donald Ervin Knuth, 1996. The TeXbook.
4479% 5147%
4480% [Knuth] p. 344; only we need to do '@' too 5148% [Knuth] p.344; only we need to do the other characters Texinfo sets
5149% active too. Otherwise, they get lost as the first character on a
5150% verbatim line.
4481\def\dospecials{% 5151\def\dospecials{%
4482 \do\ \do\\\do\@\do\{\do\}\do\$\do\&% 5152 \do\ \do\\\do\{\do\}\do\$\do\&%
4483 \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~} 5153 \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~%
5154 \do\<\do\>\do\|\do\@\do+\do\"%
5155}
4484% 5156%
4485% [Knuth] p. 380 5157% [Knuth] p. 380
4486\def\uncatcodespecials{% 5158\def\uncatcodespecials{%
4487 \def\do##1{\catcode`##1=12}\dospecials} 5159 \def\do##1{\catcode`##1=\other}\dospecials}
4488% 5160%
4489% [Knuth] pp. 380,381,391 5161% [Knuth] pp. 380,381,391
4490% Disable Spanish ligatures ?` and !` of \tt font 5162% Disable Spanish ligatures ?` and !` of \tt font
@@ -4532,6 +5204,8 @@ width0pt\relax} \fi
4532 } 5204 }
4533\endgroup 5205\endgroup
4534\def\setupverbatim{% 5206\def\setupverbatim{%
5207 \let\nonarrowing = t%
5208 \nonfillstart
4535 % Easiest (and conventionally used) font for verbatim 5209 % Easiest (and conventionally used) font for verbatim
4536 \tt 5210 \tt
4537 \def\par{\leavevmode\egroup\box0\endgraf}% 5211 \def\par{\leavevmode\egroup\box0\endgraf}%
@@ -4553,7 +5227,7 @@ width0pt\relax} \fi
4553% 5227%
4554% [Knuth] p. 382; only eat outer {} 5228% [Knuth] p. 382; only eat outer {}
4555\begingroup 5229\begingroup
4556 \catcode`[=1\catcode`]=2\catcode`\{=12\catcode`\}=12 5230 \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other
4557 \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next] 5231 \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next]
4558\endgroup 5232\endgroup
4559% 5233%
@@ -4567,609 +5241,393 @@ width0pt\relax} \fi
4567% 5241%
4568% For Texinfo it's a lot easier than for LaTeX, 5242% For Texinfo it's a lot easier than for LaTeX,
4569% because texinfo's \verbatim doesn't stop at '\end{verbatim}': 5243% because texinfo's \verbatim doesn't stop at '\end{verbatim}':
4570% we need not redefine '\', '{' and '}' 5244% we need not redefine '\', '{' and '}'.
4571% 5245%
4572% Inspired by LaTeX's verbatim command set [latex.ltx] 5246% Inspired by LaTeX's verbatim command set [latex.ltx]
4573%% Include LaTeX hack for completeness -- never know 5247%
4574%% \begingroup
4575%% \catcode`|=0 \catcode`[=1
4576%% \catcode`]=2\catcode`\{=12\catcode`\}=12\catcode`\ =\active
4577%% \catcode`\\=12|gdef|doverbatim#1@end verbatim[
4578%% #1|endgroup|def|Everbatim[]|end[verbatim]]
4579%% |endgroup
4580\begingroup 5248\begingroup
4581 \catcode`\ =\active 5249 \catcode`\ =\active
4582 \gdef\doverbatim#1@end verbatim{#1\end{verbatim}} 5250 \obeylines %
5251 % ignore everything up to the first ^^M, that's the newline at the end
5252 % of the @verbatim input line itself. Otherwise we get an extra blank
5253 % line in the output.
5254 \xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}%
5255 % We really want {...\end verbatim} in the body of the macro, but
5256 % without the active space; thus we have to use \xdef and \gobble.
4583\endgroup 5257\endgroup
4584% 5258%
4585\def\verbatim{% 5259\envdef\verbatim{%
4586 \def\Everbatim{\nonfillfinish\endgroup}% 5260 \setupverbatim\doverbatim
4587 \begingroup
4588 \nonfillstart
4589 \advance\leftskip by -\defbodyindent
4590 \begingroup\setupverbatim\doverbatim
4591} 5261}
5262\let\Everbatim = \afterenvbreak
5263
4592 5264
4593% @verbatiminclude FILE - insert text of file in verbatim environment. 5265% @verbatiminclude FILE - insert text of file in verbatim environment.
4594% 5266%
4595% Allow normal characters that we make active in the argument (a file name). 5267\def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude}
4596\def\verbatiminclude{%
4597 \begingroup
4598 \catcode`\\=12
4599 \catcode`~=12
4600 \catcode`^=12
4601 \catcode`_=12
4602 \catcode`|=12
4603 \catcode`<=12
4604 \catcode`>=12
4605 \catcode`+=12
4606 \parsearg\doverbatiminclude
4607}
4608\def\setupverbatiminclude{%
4609 \begingroup
4610 \nonfillstart
4611 \advance\leftskip by -\defbodyindent
4612 \begingroup\setupverbatim
4613}
4614% 5268%
4615\def\doverbatiminclude#1{% 5269\def\doverbatiminclude#1{%
4616 % Restore active chars for included file. 5270 {%
4617 \endgroup 5271 \makevalueexpandable
4618 \begingroup 5272 \setupverbatim
4619 \def\thisfile{#1}% 5273 \input #1
4620 \expandafter\expandafter\setupverbatiminclude\input\thisfile 5274 \afterenvbreak
4621 \endgroup\nonfillfinish\endgroup 5275 }%
4622} 5276}
4623 5277
4624% @copying ... @end copying. 5278% @copying ... @end copying.
4625% Save the text away for @insertcopying later. 5279% Save the text away for @insertcopying later.
4626% 5280%
4627\newbox\copyingbox 5281% We save the uninterpreted tokens, rather than creating a box.
5282% Saving the text in a box would be much easier, but then all the
5283% typesetting commands (@smallbook, font changes, etc.) have to be done
5284% beforehand -- and a) we want @copying to be done first in the source
5285% file; b) letting users define the frontmatter in as flexible order as
5286% possible is very desirable.
4628% 5287%
4629\def\copying{\begingroup 5288\def\copying{\checkenv{}\begingroup\scanargctxt\docopying}
4630 \parindent = 0pt % looks wrong on title page 5289\def\docopying#1@end copying{\endgroup\def\copyingtext{#1}}
4631 \def\Ecopying{\egroup\endgroup}%
4632 \global\setbox\copyingbox = \vbox\bgroup
4633}
4634
4635% @insertcopying.
4636% 5290%
4637\def\insertcopying{\unvcopy\copyingbox} 5291\def\insertcopying{%
4638 5292 \begingroup
5293 \parindent = 0pt % paragraph indentation looks wrong on title page
5294 \scanexp\copyingtext
5295 \endgroup
5296}
4639 5297
4640\message{defuns,} 5298\message{defuns,}
4641% @defun etc. 5299% @defun etc.
4642 5300
4643% Allow user to change definition object font (\df) internally
4644\def\setdeffont #1 {\csname DEF#1\endcsname}
4645
4646\newskip\defbodyindent \defbodyindent=.4in 5301\newskip\defbodyindent \defbodyindent=.4in
4647\newskip\defargsindent \defargsindent=50pt 5302\newskip\defargsindent \defargsindent=50pt
4648\newskip\deftypemargin \deftypemargin=12pt
4649\newskip\deflastargmargin \deflastargmargin=18pt 5303\newskip\deflastargmargin \deflastargmargin=18pt
4650 5304
4651\newcount\parencount 5305% Start the processing of @deffn:
4652% define \functionparens, which makes ( and ) and & do special things. 5306\def\startdefun{%
4653% \functionparens affects the group it is contained in. 5307 \ifnum\lastpenalty<10000
4654\def\activeparens{% 5308 \medbreak
4655\catcode`\(=\active \catcode`\)=\active \catcode`\&=\active 5309 \else
4656\catcode`\[=\active \catcode`\]=\active} 5310 % If there are two @def commands in a row, we'll have a \nobreak,
4657 5311 % which is there to keep the function description together with its
4658% Make control sequences which act like normal parenthesis chars. 5312 % header. But if there's nothing but headers, we need to allow a
4659\let\lparen = ( \let\rparen = ) 5313 % break somewhere. Check specifically for penalty 10002, inserted
4660 5314 % by \defargscommonending, instead of 10000, since the sectioning
4661{\activeparens % Now, smart parens don't turn on until &foo (see \amprm) 5315 % commands also insert a nobreak penalty, and we don't want to allow
4662 5316 % a break between a section heading and a defun.
4663% Be sure that we always have a definition for `(', etc. For example, 5317 %
4664% if the fn name has parens in it, \boldbrax will not be in effect yet, 5318 \ifnum\lastpenalty=10002 \penalty2000 \fi
4665% so TeX would otherwise complain about undefined control sequence. 5319 %
4666\global\let(=\lparen \global\let)=\rparen 5320 % Similarly, after a section heading, do not allow a break.
4667\global\let[=\lbrack \global\let]=\rbrack 5321 % But do insert the glue.
4668 5322 \medskip % preceded by discardable penalty, so not a breakpoint
4669\gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 } 5323 \fi
4670\gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
4671% This is used to turn on special parens
4672% but make & act ordinary (given that it's active).
4673\gdef\boldbraxnoamp{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb\let&=\ampnr}
4674
4675% Definitions of (, ) and & used in args for functions.
4676% This is the definition of ( outside of all parentheses.
4677\gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested
4678 \global\advance\parencount by 1
4679}
4680%
4681% This is the definition of ( when already inside a level of parens.
4682\gdef\opnested{\char`\(\global\advance\parencount by 1 }
4683%
4684\gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0.
4685 % also in that case restore the outer-level definition of (.
4686 \ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi
4687 \global\advance \parencount by -1 }
4688% If we encounter &foo, then turn on ()-hacking afterwards
4689\gdef\amprm#1 {{\rm\&#1}\let(=\oprm \let)=\clrm\ }
4690%
4691\gdef\normalparens{\boldbrax\let&=\ampnr}
4692} % End of definition inside \activeparens
4693%% These parens (in \boldbrax) actually are a little bolder than the
4694%% contained text. This is especially needed for [ and ]
4695\def\opnr{{\sf\char`\(}\global\advance\parencount by 1 }
4696\def\clnr{{\sf\char`\)}\global\advance\parencount by -1 }
4697\let\ampnr = \&
4698\def\lbrb{{\bf\char`\[}}
4699\def\rbrb{{\bf\char`\]}}
4700
4701% Active &'s sneak into the index arguments, so make sure it's defined.
4702{
4703 \catcode`& = 13
4704 \global\let& = \ampnr
4705}
4706
4707% First, defname, which formats the header line itself.
4708% #1 should be the function name.
4709% #2 should be the type of definition, such as "Function".
4710
4711\def\defname #1#2{%
4712% Get the values of \leftskip and \rightskip as they were
4713% outside the @def...
4714\dimen2=\leftskip
4715\advance\dimen2 by -\defbodyindent
4716\noindent
4717\setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}%
4718\dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line
4719\dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations
4720\parshape 2 0in \dimen0 \defargsindent \dimen1
4721% Now output arg 2 ("Function" or some such)
4722% ending at \deftypemargin from the right margin,
4723% but stuck inside a box of width 0 so it does not interfere with linebreaking
4724{% Adjust \hsize to exclude the ambient margins,
4725% so that \rightline will obey them.
4726\advance \hsize by -\dimen2
4727\rlap{\rightline{{\rm #2}\hskip -1.25pc }}}%
4728% Make all lines underfull and no complaints:
4729\tolerance=10000 \hbadness=10000
4730\advance\leftskip by -\defbodyindent
4731\exdentamount=\defbodyindent
4732{\df #1}\enskip % Generate function name
4733}
4734
4735% Common pieces to start any @def...
4736% #1 is the \E... control sequence to end the definition (which we define).
4737% #2 is the \...x control sequence (which our caller defines).
4738% #3 is the control sequence to process the header, such as \defunheader.
4739%
4740\def\parsebodycommon#1#2#3{%
4741 \begingroup\inENV
4742 % If there are two @def commands in a row, we'll have a \nobreak,
4743 % which is there to keep the function description together with its
4744 % header. But if there's nothing but headers, we want to allow a
4745 % break after all.
4746 \ifnum\lastpenalty = 10000 \penalty0 \fi
4747 \medbreak
4748 %
4749 % Define the \E... end token that this defining construct specifies
4750 % so that it will exit this group.
4751 \def#1{\endgraf\endgroup\medbreak}%
4752 % 5324 %
4753 \parindent=0in 5325 \parindent=0in
4754 \advance\leftskip by \defbodyindent 5326 \advance\leftskip by \defbodyindent
4755 \exdentamount=\defbodyindent 5327 \exdentamount=\defbodyindent
4756} 5328}
4757 5329
4758% Process body of @defun, @deffn, @defmac, etc. 5330\def\dodefunx#1{%
4759% 5331 % First, check whether we are in the right environment:
4760\def\defparsebody#1#2#3{% 5332 \checkenv#1%
4761 \parsebodycommon{#1}{#2}{#3}% 5333 %
4762 \def#2{\begingroup\obeylines\activeparens\spacesplit#3}% 5334 % As above, allow line break if we have multiple x headers in a row.
4763 \catcode61=\active % 61 is `=' 5335 % It's not a great place, though.
4764 \begingroup\obeylines\activeparens 5336 \ifnum\lastpenalty=10002 \penalty3000 \fi
4765 \spacesplit#3% 5337 %
4766} 5338 % And now, it's time to reuse the body of the original defun:
4767 5339 \expandafter\gobbledefun#1%
4768% #1, #2, #3 are the common arguments (see \defparsebody).
4769% #4, delimited by the space, is the class name.
4770%
4771\def\defmethparsebody#1#2#3#4 {%
4772 \parsebodycommon{#1}{#2}{#3}%
4773 \def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}%
4774 \begingroup\obeylines\activeparens
4775 \spacesplit{#3{#4}}%
4776}
4777
4778% Used for @deftypemethod and @deftypeivar.
4779% #1, #2, #3 are the common arguments (see \defparsebody).
4780% #4, delimited by a space, is the class name.
4781% #5 is the method's return type.
4782%
4783\def\deftypemethparsebody#1#2#3#4 #5 {%
4784 \parsebodycommon{#1}{#2}{#3}%
4785 \def#2##1 ##2 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}{##2}}}%
4786 \begingroup\obeylines\activeparens
4787 \spacesplit{#3{#4}{#5}}%
4788} 5340}
5341\def\gobbledefun#1\startdefun{}
4789 5342
4790% Used for @deftypeop. The change from \deftypemethparsebody is an 5343% \printdefunline \deffnheader{text}
4791% extra argument at the beginning which is the `category', instead of it
4792% being the hardwired string `Method' or `Instance Variable'. We have
4793% to account for this both in the \...x definition and in parsing the
4794% input at hand. Thus also need a control sequence (passed as #5) for
4795% the \E... definition to assign the category name to.
4796% 5344%
4797\def\deftypeopparsebody#1#2#3#4#5 #6 {% 5345\def\printdefunline#1#2{%
4798 \parsebodycommon{#1}{#2}{#3}% 5346 \begingroup
4799 \def#2##1 ##2 ##3 {% 5347 % call \deffnheader:
4800 \def#4{##1}% 5348 #1#2 \endheader
4801 \begingroup\obeylines\activeparens\spacesplit{#3{##2}{##3}}}% 5349 % common ending:
4802 \begingroup\obeylines\activeparens 5350 \interlinepenalty = 10000
4803 \spacesplit{#3{#5}{#6}}% 5351 \advance\rightskip by 0pt plus 1fil
5352 \endgraf
5353 \nobreak\vskip -\parskip
5354 \penalty 10002 % signal to \startdefun and \dodefunx
5355 % Some of the @defun-type tags do not enable magic parentheses,
5356 % rendering the following check redundant. But we don't optimize.
5357 \checkparencounts
5358 \endgroup
4804} 5359}
4805 5360
4806% For @defop. 5361\def\Edefun{\endgraf\medbreak}
4807\def\defopparsebody #1#2#3#4#5 {%
4808 \parsebodycommon{#1}{#2}{#3}%
4809 \def#2##1 ##2 {\def#4{##1}%
4810 \begingroup\obeylines\activeparens\spacesplit{#3{##2}}}%
4811 \begingroup\obeylines\activeparens
4812 \spacesplit{#3{#5}}%
4813}
4814 5362
4815% These parsing functions are similar to the preceding ones 5363% \makedefun{deffn} creates \deffn, \deffnx and \Edeffn;
4816% except that they do not make parens into active characters. 5364% the only thing remainnig is to define \deffnheader.
4817% These are used for "variables" since they have no arguments.
4818% 5365%
4819\def\defvarparsebody #1#2#3{% 5366\def\makedefun#1{%
4820 \parsebodycommon{#1}{#2}{#3}% 5367 \expandafter\let\csname E#1\endcsname = \Edefun
4821 \def#2{\begingroup\obeylines\spacesplit#3}% 5368 \edef\temp{\noexpand\domakedefun
4822 \catcode61=\active % 5369 \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}%
4823 \begingroup\obeylines 5370 \temp
4824 \spacesplit#3%
4825}
4826
4827% @defopvar.
4828\def\defopvarparsebody #1#2#3#4#5 {%
4829 \parsebodycommon{#1}{#2}{#3}%
4830 \def#2##1 ##2 {\def#4{##1}%
4831 \begingroup\obeylines\spacesplit{#3{##2}}}%
4832 \begingroup\obeylines
4833 \spacesplit{#3{#5}}%
4834}
4835
4836\def\defvrparsebody#1#2#3#4 {%
4837 \parsebodycommon{#1}{#2}{#3}%
4838 \def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}%
4839 \begingroup\obeylines
4840 \spacesplit{#3{#4}}%
4841} 5371}
4842 5372
4843% This loses on `@deftp {Data Type} {struct termios}' -- it thinks the 5373% \domakedefun \deffn \deffnx \deffnheader
4844% type is just `struct', because we lose the braces in `{struct
4845% termios}' when \spacesplit reads its undelimited argument. Sigh.
4846% \let\deftpparsebody=\defvrparsebody
4847% 5374%
4848% So, to get around this, we put \empty in with the type name. That 5375% Define \deffn and \deffnx, without parameters.
4849% way, TeX won't find exactly `{...}' as an undelimited argument, and 5376% \deffnheader has to be defined explicitly.
4850% won't strip off the braces.
4851% 5377%
4852\def\deftpparsebody #1#2#3#4 {% 5378\def\domakedefun#1#2#3{%
4853 \parsebodycommon{#1}{#2}{#3}% 5379 \envdef#1{%
4854 \def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}% 5380 \startdefun
4855 \begingroup\obeylines 5381 \parseargusing\activeparens{\printdefunline#3}%
4856 \spacesplit{\parsetpheaderline{#3{#4}}}\empty 5382 }%
5383 \def#2{\dodefunx#1}%
5384 \def#3%
4857} 5385}
4858 5386
4859% Fine, but then we have to eventually remove the \empty *and* the 5387%%% Untyped functions:
4860% braces (if any). That's what this does.
4861%
4862\def\removeemptybraces\empty#1\relax{#1}
4863
4864% After \spacesplit has done its work, this is called -- #1 is the final
4865% thing to call, #2 the type name (which starts with \empty), and #3
4866% (which might be empty) the arguments.
4867%
4868\def\parsetpheaderline#1#2#3{%
4869 #1{\removeemptybraces#2\relax}{#3}%
4870}%
4871 5388
4872% Split up #2 at the first space token. 5389% @deffn category name args
4873% call #1 with two arguments: 5390\makedefun{deffn}{\deffngeneral{}}
4874% the first is all of #2 before the space token,
4875% the second is all of #2 after that space token.
4876% If #2 contains no space token, all of it is passed as the first arg
4877% and the second is passed as empty.
4878%
4879{\obeylines
4880\gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}%
4881\long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{%
4882\ifx\relax #3%
4883#1{#2}{}\else #1{#2}{#3#4}\fi}}
4884 5391
4885% Define @defun. 5392% @deffn category class name args
5393\makedefun{defop}#1 {\defopon{#1\ \putwordon}}
4886 5394
4887% First, define the processing that is wanted for arguments of \defun 5395% \defopon {category on}class name args
4888% Use this to expand the args and terminate the paragraph they make up 5396\def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
4889 5397
4890\def\defunargs#1{\functionparens \sl 5398% \deffngeneral {subind}category name args
4891% Expand, preventing hyphenation at `-' chars. 5399%
4892% Note that groups don't affect changes in \hyphenchar. 5400\def\deffngeneral#1#2 #3 #4\endheader{%
4893% Set the font temporarily and use \font in case \setfont made \tensl a macro. 5401 % Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}.
4894{\tensl\hyphenchar\font=0}% 5402 \dosubind{fn}{\code{#3}}{#1}%
4895#1% 5403 \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
4896{\tensl\hyphenchar\font=45}%
4897\ifnum\parencount=0 \else \errmessage{Unbalanced parentheses in @def}\fi%
4898\interlinepenalty=10000
4899\advance\rightskip by 0pt plus 1fil
4900\endgraf\nobreak\vskip -\parskip\nobreak
4901} 5404}
4902 5405
4903\def\deftypefunargs #1{% 5406%%% Typed functions:
4904% Expand, preventing hyphenation at `-' chars.
4905% Note that groups don't affect changes in \hyphenchar.
4906% Use \boldbraxnoamp, not \functionparens, so that & is not special.
4907\boldbraxnoamp
4908\tclose{#1}% avoid \code because of side effects on active chars
4909\interlinepenalty=10000
4910\advance\rightskip by 0pt plus 1fil
4911\endgraf\nobreak\vskip -\parskip\nobreak
4912}
4913 5407
4914% Do complete processing of one @defun or @defunx line already parsed. 5408% @deftypefn category type name args
5409\makedefun{deftypefn}{\deftypefngeneral{}}
4915 5410
4916% @deffn Command forward-char nchars 5411% @deftypeop category class type name args
5412\makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}}
4917 5413
4918\def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader} 5414% \deftypeopon {category on}class type name args
5415\def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
4919 5416
4920\def\deffnheader #1#2#3{\doind {fn}{\code{#2}}% 5417% \deftypefngeneral {subind}category type name args
4921\begingroup\defname {#2}{#1}\defunargs{#3}\endgroup % 5418%
4922\catcode 61=\other % Turn off change made in \defparsebody 5419\def\deftypefngeneral#1#2 #3 #4 #5\endheader{%
5420 \dosubind{fn}{\code{#4}}{#1}%
5421 \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
4923} 5422}
4924 5423
4925% @defun == @deffn Function 5424%%% Typed variables:
4926 5425
4927\def\defun{\defparsebody\Edefun\defunx\defunheader} 5426% @deftypevr category type var args
5427\makedefun{deftypevr}{\deftypecvgeneral{}}
4928 5428
4929\def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index 5429% @deftypecv category class type var args
4930\begingroup\defname {#1}{\putwordDeffunc}% 5430\makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}}
4931\defunargs {#2}\endgroup %
4932\catcode 61=\other % Turn off change made in \defparsebody
4933}
4934 5431
4935% @deftypefun int foobar (int @var{foo}, float @var{bar}) 5432% \deftypecvof {category of}class type var args
5433\def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} }
4936 5434
4937\def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader} 5435% \deftypecvgeneral {subind}category type var args
4938 5436%
4939% #1 is the data type. #2 is the name and args. 5437\def\deftypecvgeneral#1#2 #3 #4 #5\endheader{%
4940\def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax} 5438 \dosubind{vr}{\code{#4}}{#1}%
4941% #1 is the data type, #2 the name, #3 the args. 5439 \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
4942\def\deftypefunheaderx #1#2 #3\relax{%
4943\doind {fn}{\code{#2}}% Make entry in function index
4944\begingroup\defname {\defheaderxcond#1\relax$.$#2}{\putwordDeftypefun}%
4945\deftypefunargs {#3}\endgroup %
4946\catcode 61=\other % Turn off change made in \defparsebody
4947} 5440}
4948 5441
4949% @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar}) 5442%%% Untyped variables:
4950
4951\def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader}
4952 5443
4953% \defheaderxcond#1\relax$.$ 5444% @defvr category var args
4954% puts #1 in @code, followed by a space, but does nothing if #1 is null. 5445\makedefun{defvr}#1 {\deftypevrheader{#1} {} }
4955\def\defheaderxcond#1#2$.${\ifx#1\relax\else\code{#1#2} \fi}
4956 5446
4957% #1 is the classification. #2 is the data type. #3 is the name and args. 5447% @defcv category class var args
4958\def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax} 5448\makedefun{defcv}#1 {\defcvof{#1\ \putwordof}}
4959% #1 is the classification, #2 the data type, #3 the name, #4 the args.
4960\def\deftypefnheaderx #1#2#3 #4\relax{%
4961\doind {fn}{\code{#3}}% Make entry in function index
4962\begingroup
4963\normalparens % notably, turn off `&' magic, which prevents
4964% at least some C++ text from working
4965\defname {\defheaderxcond#2\relax$.$#3}{#1}%
4966\deftypefunargs {#4}\endgroup %
4967\catcode 61=\other % Turn off change made in \defparsebody
4968}
4969 5449
4970% @defmac == @deffn Macro 5450% \defcvof {category of}class var args
5451\def\defcvof#1#2 {\deftypecvof{#1}#2 {} }
4971 5452
4972\def\defmac{\defparsebody\Edefmac\defmacx\defmacheader} 5453%%% Type:
4973 5454% @deftp category name args
4974\def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index 5455\makedefun{deftp}#1 #2 #3\endheader{%
4975\begingroup\defname {#1}{\putwordDefmac}% 5456 \doind{tp}{\code{#2}}%
4976\defunargs {#2}\endgroup % 5457 \defname{#1}{}{#2}\defunargs{#3\unskip}%
4977\catcode 61=\other % Turn off change made in \defparsebody
4978} 5458}
4979 5459
4980% @defspec == @deffn Special Form 5460% Remaining @defun-like shortcuts:
4981 5461\makedefun{defun}{\deffnheader{\putwordDeffunc} }
4982\def\defspec{\defparsebody\Edefspec\defspecx\defspecheader} 5462\makedefun{defmac}{\deffnheader{\putwordDefmac} }
5463\makedefun{defspec}{\deffnheader{\putwordDefspec} }
5464\makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} }
5465\makedefun{defvar}{\defvrheader{\putwordDefvar} }
5466\makedefun{defopt}{\defvrheader{\putwordDefopt} }
5467\makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} }
5468\makedefun{defmethod}{\defopon\putwordMethodon}
5469\makedefun{deftypemethod}{\deftypeopon\putwordMethodon}
5470\makedefun{defivar}{\defcvof\putwordInstanceVariableof}
5471\makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof}
4983 5472
4984\def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index 5473% \defname, which formats the name of the @def (not the args).
4985\begingroup\defname {#1}{\putwordDefspec}% 5474% #1 is the category, such as "Function".
4986\defunargs {#2}\endgroup % 5475% #2 is the return type, if any.
4987\catcode 61=\other % Turn off change made in \defparsebody 5476% #3 is the function name.
4988}
4989
4990% @defop CATEGORY CLASS OPERATION ARG...
4991% 5477%
4992\def\defop #1 {\def\defoptype{#1}% 5478% We are followed by (but not passed) the arguments, if any.
4993\defopparsebody\Edefop\defopx\defopheader\defoptype}
4994% 5479%
4995\def\defopheader#1#2#3{% 5480\def\defname#1#2#3{%
4996\dosubind {fn}{\code{#2}}{\putwordon\ #1}% Make entry in function index 5481 % Get the values of \leftskip and \rightskip as they were outside the @def...
4997\begingroup\defname {#2}{\defoptype\ \putwordon\ #1}% 5482 \advance\leftskip by -\defbodyindent
4998\defunargs {#3}\endgroup % 5483 %
5484 % How we'll format the type name. Putting it in brackets helps
5485 % distinguish it from the body text that may end up on the next line
5486 % just below it.
5487 \def\temp{#1}%
5488 \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
5489 %
5490 % Figure out line sizes for the paragraph shape.
5491 % The first line needs space for \box0; but if \rightskip is nonzero,
5492 % we need only space for the part of \box0 which exceeds it:
5493 \dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip
5494 % The continuations:
5495 \dimen2=\hsize \advance\dimen2 by -\defargsindent
5496 % (plain.tex says that \dimen1 should be used only as global.)
5497 \parshape 2 0in \dimen0 \defargsindent \dimen2
5498 %
5499 % Put the type name to the right margin.
5500 \noindent
5501 \hbox to 0pt{%
5502 \hfil\box0 \kern-\hsize
5503 % \hsize has to be shortened this way:
5504 \kern\leftskip
5505 % Intentionally do not respect \rightskip, since we need the space.
5506 }%
5507 %
5508 % Allow all lines to be underfull without complaint:
5509 \tolerance=10000 \hbadness=10000
5510 \exdentamount=\defbodyindent
5511 {%
5512 % defun fonts. We use typewriter by default (used to be bold) because:
5513 % . we're printing identifiers, they should be in tt in principle.
5514 % . in languages with many accents, such as Czech or French, it's
5515 % common to leave accents off identifiers. The result looks ok in
5516 % tt, but exceedingly strange in rm.
5517 % . we don't want -- and --- to be treated as ligatures.
5518 % . this still does not fix the ?` and !` ligatures, but so far no
5519 % one has made identifiers using them :).
5520 \df \tt
5521 \def\temp{#2}% return value type
5522 \ifx\temp\empty\else \tclose{\temp} \fi
5523 #3% output function name
5524 }%
5525 {\rm\enskip}% hskip 0.5 em of \tenrm
5526 %
5527 \boldbrax
5528 % arguments will be output next, if any.
4999} 5529}
5000 5530
5001% @deftypeop CATEGORY CLASS TYPE OPERATION ARG... 5531% Print arguments in slanted roman (not ttsl), inconsistently with using
5532% tt for the name. This is because literal text is sometimes needed in
5533% the argument list (groff manual), and ttsl and tt are not very
5534% distinguishable. Prevent hyphenation at `-' chars.
5002% 5535%
5003\def\deftypeop #1 {\def\deftypeopcategory{#1}% 5536\def\defunargs#1{%
5004 \deftypeopparsebody\Edeftypeop\deftypeopx\deftypeopheader 5537 % use sl by default (not ttsl),
5005 \deftypeopcategory} 5538 % tt for the names.
5006% 5539 \df \sl \hyphenchar\font=0
5007% #1 is the class name, #2 the data type, #3 the operation name, #4 the args. 5540 %
5008\def\deftypeopheader#1#2#3#4{% 5541 % On the other hand, if an argument has two dashes (for instance), we
5009 \dosubind{fn}{\code{#3}}{\putwordon\ \code{#1}}% entry in function index 5542 % want a way to get ttsl. Let's try @var for that.
5010 \begingroup 5543 \let\var=\ttslanted
5011 \defname{\defheaderxcond#2\relax$.$#3} 5544 #1%
5012 {\deftypeopcategory\ \putwordon\ \code{#1}}% 5545 \sl\hyphenchar\font=45
5013 \deftypefunargs{#4}%
5014 \endgroup
5015} 5546}
5016 5547
5017% @deftypemethod CLASS TYPE METHOD ARG... 5548% We want ()&[] to print specially on the defun line.
5018% 5549%
5019\def\deftypemethod{% 5550\def\activeparens{%
5020 \deftypemethparsebody\Edeftypemethod\deftypemethodx\deftypemethodheader} 5551 \catcode`\(=\active \catcode`\)=\active
5021% 5552 \catcode`\[=\active \catcode`\]=\active
5022% #1 is the class name, #2 the data type, #3 the method name, #4 the args. 5553 \catcode`\&=\active
5023\def\deftypemethodheader#1#2#3#4{%
5024 \dosubind{fn}{\code{#3}}{\putwordon\ \code{#1}}% entry in function index
5025 \begingroup
5026 \defname{\defheaderxcond#2\relax$.$#3}{\putwordMethodon\ \code{#1}}%
5027 \deftypefunargs{#4}%
5028 \endgroup
5029} 5554}
5030 5555
5031% @deftypeivar CLASS TYPE VARNAME 5556% Make control sequences which act like normal parenthesis chars.
5032% 5557\let\lparen = ( \let\rparen = )
5033\def\deftypeivar{%
5034 \deftypemethparsebody\Edeftypeivar\deftypeivarx\deftypeivarheader}
5035%
5036% #1 is the class name, #2 the data type, #3 the variable name.
5037\def\deftypeivarheader#1#2#3{%
5038 \dosubind{vr}{\code{#3}}{\putwordof\ \code{#1}}% entry in variable index
5039 \begingroup
5040 \defname{\defheaderxcond#2\relax$.$#3}
5041 {\putwordInstanceVariableof\ \code{#1}}%
5042 \defvarargs{#3}%
5043 \endgroup
5044}
5045 5558
5046% @defmethod == @defop Method 5559% Be sure that we always have a definition for `(', etc. For example,
5047% 5560% if the fn name has parens in it, \boldbrax will not be in effect yet,
5048\def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader} 5561% so TeX would otherwise complain about undefined control sequence.
5049% 5562{
5050% #1 is the class name, #2 the method name, #3 the args. 5563 \activeparens
5051\def\defmethodheader#1#2#3{% 5564 \global\let(=\lparen \global\let)=\rparen
5052 \dosubind{fn}{\code{#2}}{\putwordon\ \code{#1}}% entry in function index 5565 \global\let[=\lbrack \global\let]=\rbrack
5053 \begingroup 5566 \global\let& = \&
5054 \defname{#2}{\putwordMethodon\ \code{#1}}%
5055 \defunargs{#3}%
5056 \endgroup
5057}
5058 5567
5059% @defcv {Class Option} foo-class foo-flag 5568 \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
5569 \gdef\magicamp{\let&=\amprm}
5570}
5060 5571
5061\def\defcv #1 {\def\defcvtype{#1}% 5572\newcount\parencount
5062\defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype}
5063 5573
5064\def\defcvarheader #1#2#3{% 5574% If we encounter &foo, then turn on ()-hacking afterwards
5065\dosubind {vr}{\code{#2}}{\putwordof\ #1}% Make entry in var index 5575\newif\ifampseen
5066\begingroup\defname {#2}{\defcvtype\ \putwordof\ #1}% 5576\def\amprm#1 {\ampseentrue{\bf\&#1 }}
5067\defvarargs {#3}\endgroup % 5577
5578\def\parenfont{%
5579 \ifampseen
5580 % At the first level, print parens in roman,
5581 % otherwise use the default font.
5582 \ifnum \parencount=1 \rm \fi
5583 \else
5584 % The \sf parens (in \boldbrax) actually are a little bolder than
5585 % the contained text. This is especially needed for [ and ] .
5586 \sf
5587 \fi
5068} 5588}
5069 5589\def\infirstlevel#1{%
5070% @defivar CLASS VARNAME == @defcv {Instance Variable} CLASS VARNAME 5590 \ifampseen
5071% 5591 \ifnum\parencount=1
5072\def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader} 5592 #1%
5073% 5593 \fi
5074\def\defivarheader#1#2#3{% 5594 \fi
5075 \dosubind {vr}{\code{#2}}{\putwordof\ #1}% entry in var index
5076 \begingroup
5077 \defname{#2}{\putwordInstanceVariableof\ #1}%
5078 \defvarargs{#3}%
5079 \endgroup
5080} 5595}
5596\def\bfafterword#1 {#1 \bf}
5081 5597
5082% @defvar 5598\def\opnr{%
5083% First, define the processing that is wanted for arguments of @defvar. 5599 \global\advance\parencount by 1
5084% This is actually simple: just print them in roman. 5600 {\parenfont(}%
5085% This must expand the args and terminate the paragraph they make up 5601 \infirstlevel \bfafterword
5086\def\defvarargs #1{\normalparens #1%
5087\interlinepenalty=10000
5088\endgraf\nobreak\vskip -\parskip\nobreak}
5089
5090% @defvr Counter foo-count
5091
5092\def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader}
5093
5094\def\defvrheader #1#2#3{\doind {vr}{\code{#2}}%
5095\begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup}
5096
5097% @defvar == @defvr Variable
5098
5099\def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader}
5100
5101\def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
5102\begingroup\defname {#1}{\putwordDefvar}%
5103\defvarargs {#2}\endgroup %
5104} 5602}
5105 5603\def\clnr{%
5106% @defopt == @defvr {User Option} 5604 {\parenfont)}%
5107 5605 \infirstlevel \sl
5108\def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader} 5606 \global\advance\parencount by -1
5109
5110\def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
5111\begingroup\defname {#1}{\putwordDefopt}%
5112\defvarargs {#2}\endgroup %
5113} 5607}
5114 5608
5115% @deftypevar int foobar 5609\newcount\brackcount
5116 5610\def\lbrb{%
5117\def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader} 5611 \global\advance\brackcount by 1
5118 5612 {\bf[}%
5119% #1 is the data type. #2 is the name, perhaps followed by text that 5613}
5120% is actually part of the data type, which should not be put into the index. 5614\def\rbrb{%
5121\def\deftypevarheader #1#2{% 5615 {\bf]}%
5122\dovarind#2 \relax% Make entry in variables index 5616 \global\advance\brackcount by -1
5123\begingroup\defname {\defheaderxcond#1\relax$.$#2}{\putwordDeftypevar}% 5617}
5124\interlinepenalty=10000
5125\endgraf\nobreak\vskip -\parskip\nobreak
5126\endgroup}
5127\def\dovarind#1 #2\relax{\doind{vr}{\code{#1}}}
5128
5129% @deftypevr {Global Flag} int enable
5130
5131\def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader}
5132
5133\def\deftypevrheader #1#2#3{\dovarind#3 \relax%
5134\begingroup\defname {\defheaderxcond#2\relax$.$#3}{#1}
5135\interlinepenalty=10000
5136\endgraf\nobreak\vskip -\parskip\nobreak
5137\endgroup}
5138
5139% Now define @deftp
5140% Args are printed in bold, a slight difference from @defvar.
5141
5142\def\deftpargs #1{\bf \defvarargs{#1}}
5143
5144% @deftp Class window height width ...
5145
5146\def\deftp{\deftpparsebody\Edeftp\deftpx\deftpheader}
5147
5148\def\deftpheader #1#2#3{\doind {tp}{\code{#2}}%
5149\begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup}
5150 5618
5151% These definitions are used if you use @defunx (etc.) 5619\def\checkparencounts{%
5152% anywhere other than immediately after a @defun or @defunx. 5620 \ifnum\parencount=0 \else \badparencount \fi
5153% 5621 \ifnum\brackcount=0 \else \badbrackcount \fi
5154\def\defcvx#1 {\errmessage{@defcvx in invalid context}} 5622}
5155\def\deffnx#1 {\errmessage{@deffnx in invalid context}} 5623\def\badparencount{%
5156\def\defivarx#1 {\errmessage{@defivarx in invalid context}} 5624 \errmessage{Unbalanced parentheses in @def}%
5157\def\defmacx#1 {\errmessage{@defmacx in invalid context}} 5625 \global\parencount=0
5158\def\defmethodx#1 {\errmessage{@defmethodx in invalid context}} 5626}
5159\def\defoptx #1 {\errmessage{@defoptx in invalid context}} 5627\def\badbrackcount{%
5160\def\defopx#1 {\errmessage{@defopx in invalid context}} 5628 \errmessage{Unbalanced square braces in @def}%
5161\def\defspecx#1 {\errmessage{@defspecx in invalid context}} 5629 \global\brackcount=0
5162\def\deftpx#1 {\errmessage{@deftpx in invalid context}} 5630}
5163\def\deftypefnx#1 {\errmessage{@deftypefnx in invalid context}}
5164\def\deftypefunx#1 {\errmessage{@deftypefunx in invalid context}}
5165\def\deftypeivarx#1 {\errmessage{@deftypeivarx in invalid context}}
5166\def\deftypemethodx#1 {\errmessage{@deftypemethodx in invalid context}}
5167\def\deftypeopx#1 {\errmessage{@deftypeopx in invalid context}}
5168\def\deftypevarx#1 {\errmessage{@deftypevarx in invalid context}}
5169\def\deftypevrx#1 {\errmessage{@deftypevrx in invalid context}}
5170\def\defunx#1 {\errmessage{@defunx in invalid context}}
5171\def\defvarx#1 {\errmessage{@defvarx in invalid context}}
5172\def\defvrx#1 {\errmessage{@defvrx in invalid context}}
5173 5631
5174 5632
5175\message{macros,} 5633\message{macros,}
@@ -5178,42 +5636,69 @@ width0pt\relax} \fi
5178% To do this right we need a feature of e-TeX, \scantokens, 5636% To do this right we need a feature of e-TeX, \scantokens,
5179% which we arrange to emulate with a temporary file in ordinary TeX. 5637% which we arrange to emulate with a temporary file in ordinary TeX.
5180\ifx\eTeXversion\undefined 5638\ifx\eTeXversion\undefined
5181 \newwrite\macscribble 5639 \newwrite\macscribble
5182 \def\scanmacro#1{% 5640 \def\scantokens#1{%
5183 \begingroup \newlinechar`\^^M 5641 \toks0={#1}%
5184 % Undo catcode changes of \startcontents and \doprintindex 5642 \immediate\openout\macscribble=\jobname.tmp
5185 \catcode`\@=0 \catcode`\\=12 \escapechar=`\@ 5643 \immediate\write\macscribble{\the\toks0}%
5186 % Append \endinput to make sure that TeX does not see the ending newline. 5644 \immediate\closeout\macscribble
5187 \toks0={#1\endinput}% 5645 \input \jobname.tmp
5188 \immediate\openout\macscribble=\jobname.tmp 5646 }
5189 \immediate\write\macscribble{\the\toks0}%
5190 \immediate\closeout\macscribble
5191 \let\xeatspaces\eatspaces
5192 \input \jobname.tmp
5193 \endgroup
5194}
5195\else
5196\def\scanmacro#1{%
5197\begingroup \newlinechar`\^^M
5198% Undo catcode changes of \startcontents and \doprintindex
5199\catcode`\@=0 \catcode`\\=12 \escapechar=`\@
5200\let\xeatspaces\eatspaces\scantokens{#1\endinput}\endgroup}
5201\fi 5647\fi
5202 5648
5649\def\scanmacro#1{%
5650 \begingroup
5651 \newlinechar`\^^M
5652 \let\xeatspaces\eatspaces
5653 % Undo catcode changes of \startcontents and \doprintindex
5654 % When called from @insertcopying or (short)caption, we need active
5655 % backslash to get it printed correctly. Previously, we had
5656 % \catcode`\\=\other instead. We'll see whether a problem appears
5657 % with macro expansion. --kasal, 19aug04
5658 \catcode`\@=0 \catcode`\\=\active \escapechar=`\@
5659 % ... and \example
5660 \spaceisspace
5661 %
5662 % Append \endinput to make sure that TeX does not see the ending newline.
5663 %
5664 % I've verified that it is necessary both for e-TeX and for ordinary TeX
5665 % --kasal, 29nov03
5666 \scantokens{#1\endinput}%
5667 \endgroup
5668}
5669
5670\def\scanexp#1{%
5671 \edef\temp{\noexpand\scanmacro{#1}}%
5672 \temp
5673}
5674
5203\newcount\paramno % Count of parameters 5675\newcount\paramno % Count of parameters
5204\newtoks\macname % Macro name 5676\newtoks\macname % Macro name
5205\newif\ifrecursive % Is it recursive? 5677\newif\ifrecursive % Is it recursive?
5206\def\macrolist{} % List of all defined macros in the form 5678
5207 % \do\macro1\do\macro2... 5679% List of all defined macros in the form
5680% \definedummyword\macro1\definedummyword\macro2...
5681% Currently is also contains all @aliases; the list can be split
5682% if there is a need.
5683\def\macrolist{}
5684
5685% Add the macro to \macrolist
5686\def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname}
5687\def\addtomacrolistxxx#1{%
5688 \toks0 = \expandafter{\macrolist\definedummyword#1}%
5689 \xdef\macrolist{\the\toks0}%
5690}
5208 5691
5209% Utility routines. 5692% Utility routines.
5210% Thisdoes \let #1 = #2, except with \csnames. 5693% This does \let #1 = #2, with \csnames; that is,
5694% \let \csname#1\endcsname = \csname#2\endcsname
5695% (except of course we have to play expansion games).
5696%
5211\def\cslet#1#2{% 5697\def\cslet#1#2{%
5212\expandafter\expandafter 5698 \expandafter\let
5213\expandafter\let 5699 \csname#1\expandafter\endcsname
5214\expandafter\expandafter 5700 \csname#2\endcsname
5215\csname#1\endcsname 5701}
5216\csname#2\endcsname}
5217 5702
5218% Trim leading and trailing spaces off a string. 5703% Trim leading and trailing spaces off a string.
5219% Concepts from aro-bend problem 15 (see CTAN). 5704% Concepts from aro-bend problem 15 (see CTAN).
@@ -5226,7 +5711,7 @@ width0pt\relax} \fi
5226} 5711}
5227 5712
5228% Trim a single trailing ^^M off a string. 5713% Trim a single trailing ^^M off a string.
5229{\catcode`\^^M=12\catcode`\Q=3% 5714{\catcode`\^^M=\other \catcode`\Q=3%
5230\gdef\eatcr #1{\eatcra #1Q^^MQ}% 5715\gdef\eatcr #1{\eatcra #1Q^^MQ}%
5231\gdef\eatcra#1^^MQ{\eatcrb#1Q}% 5716\gdef\eatcra#1^^MQ{\eatcrb#1Q}%
5232\gdef\eatcrb#1Q#2Q{#1}% 5717\gdef\eatcrb#1Q#2Q{#1}%
@@ -5240,30 +5725,36 @@ width0pt\relax} \fi
5240% done by making ^^M (\endlinechar) catcode 12 when reading the macro 5725% done by making ^^M (\endlinechar) catcode 12 when reading the macro
5241% body, and then making it the \newlinechar in \scanmacro. 5726% body, and then making it the \newlinechar in \scanmacro.
5242 5727
5728\def\scanctxt{%
5729 \catcode`\"=\other
5730 \catcode`\+=\other
5731 \catcode`\<=\other
5732 \catcode`\>=\other
5733 \catcode`\@=\other
5734 \catcode`\^=\other
5735 \catcode`\_=\other
5736 \catcode`\|=\other
5737 \catcode`\~=\other
5738}
5739
5740\def\scanargctxt{%
5741 \scanctxt
5742 \catcode`\\=\other
5743 \catcode`\^^M=\other
5744}
5745
5243\def\macrobodyctxt{% 5746\def\macrobodyctxt{%
5244 \catcode`\~=12 5747 \scanctxt
5245 \catcode`\^=12 5748 \catcode`\{=\other
5246 \catcode`\_=12 5749 \catcode`\}=\other
5247 \catcode`\|=12 5750 \catcode`\^^M=\other
5248 \catcode`\<=12 5751 \usembodybackslash
5249 \catcode`\>=12 5752}
5250 \catcode`\+=12
5251 \catcode`\{=12
5252 \catcode`\}=12
5253 \catcode`\@=12
5254 \catcode`\^^M=12
5255 \usembodybackslash}
5256 5753
5257\def\macroargctxt{% 5754\def\macroargctxt{%
5258 \catcode`\~=12 5755 \scanctxt
5259 \catcode`\^=12 5756 \catcode`\\=\other
5260 \catcode`\_=12 5757}
5261 \catcode`\|=12
5262 \catcode`\<=12
5263 \catcode`\>=12
5264 \catcode`\+=12
5265 \catcode`\@=12
5266 \catcode`\\=12}
5267 5758
5268% \mbodybackslash is the definition of \ in @macro bodies. 5759% \mbodybackslash is the definition of \ in @macro bodies.
5269% It maps \foo\ => \csname macarg.foo\endcsname => #N 5760% It maps \foo\ => \csname macarg.foo\endcsname => #N
@@ -5294,42 +5785,39 @@ width0pt\relax} \fi
5294 \else \errmessage{Macro name \the\macname\space already defined}\fi 5785 \else \errmessage{Macro name \the\macname\space already defined}\fi
5295 \global\cslet{macsave.\the\macname}{\the\macname}% 5786 \global\cslet{macsave.\the\macname}{\the\macname}%
5296 \global\expandafter\let\csname ismacro.\the\macname\endcsname=1% 5787 \global\expandafter\let\csname ismacro.\the\macname\endcsname=1%
5297 % Add the macroname to \macrolist 5788 \addtomacrolist{\the\macname}%
5298 \toks0 = \expandafter{\macrolist\do}%
5299 \xdef\macrolist{\the\toks0
5300 \expandafter\noexpand\csname\the\macname\endcsname}%
5301 \fi 5789 \fi
5302 \begingroup \macrobodyctxt 5790 \begingroup \macrobodyctxt
5303 \ifrecursive \expandafter\parsermacbody 5791 \ifrecursive \expandafter\parsermacbody
5304 \else \expandafter\parsemacbody 5792 \else \expandafter\parsemacbody
5305 \fi} 5793 \fi}
5306 5794
5307\def\unmacro{\parsearg\unmacroxxx} 5795\parseargdef\unmacro{%
5308\def\unmacroxxx#1{%
5309 \if1\csname ismacro.#1\endcsname 5796 \if1\csname ismacro.#1\endcsname
5310 \global\cslet{#1}{macsave.#1}% 5797 \global\cslet{#1}{macsave.#1}%
5311 \global\expandafter\let \csname ismacro.#1\endcsname=0% 5798 \global\expandafter\let \csname ismacro.#1\endcsname=0%
5312 % Remove the macro name from \macrolist 5799 % Remove the macro name from \macrolist:
5313 \begingroup 5800 \begingroup
5314 \edef\tempa{\expandafter\noexpand\csname#1\endcsname}% 5801 \expandafter\let\csname#1\endcsname \relax
5315 \def\do##1{% 5802 \let\definedummyword\unmacrodo
5316 \def\tempb{##1}% 5803 \xdef\macrolist{\macrolist}%
5317 \ifx\tempa\tempb
5318 % remove this
5319 \else
5320 \toks0 = \expandafter{\newmacrolist\do}%
5321 \edef\newmacrolist{\the\toks0\expandafter\noexpand\tempa}%
5322 \fi}%
5323 \def\newmacrolist{}%
5324 % Execute macro list to define \newmacrolist
5325 \macrolist
5326 \global\let\macrolist\newmacrolist
5327 \endgroup 5804 \endgroup
5328 \else 5805 \else
5329 \errmessage{Macro #1 not defined}% 5806 \errmessage{Macro #1 not defined}%
5330 \fi 5807 \fi
5331} 5808}
5332 5809
5810% Called by \do from \dounmacro on each macro. The idea is to omit any
5811% macro definitions that have been changed to \relax.
5812%
5813\def\unmacrodo#1{%
5814 \ifx #1\relax
5815 % remove this
5816 \else
5817 \noexpand\definedummyword \noexpand#1%
5818 \fi
5819}
5820
5333% This makes use of the obscure feature that if the last token of a 5821% This makes use of the obscure feature that if the last token of a
5334% <parameter list> is #, then the preceding argument is delimited by 5822% <parameter list> is #, then the preceding argument is delimited by
5335% an opening brace, and that opening brace is not consumed. 5823% an opening brace, and that opening brace is not consumed.
@@ -5439,31 +5927,29 @@ width0pt\relax} \fi
5439% {. If so it reads up to the closing }, if not, it reads the whole 5927% {. If so it reads up to the closing }, if not, it reads the whole
5440% line. Whatever was read is then fed to the next control sequence 5928% line. Whatever was read is then fed to the next control sequence
5441% as an argument (by \parsebrace or \parsearg) 5929% as an argument (by \parsebrace or \parsearg)
5442\def\braceorline#1{\let\next=#1\futurelet\nchar\braceorlinexxx} 5930\def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx}
5443\def\braceorlinexxx{% 5931\def\braceorlinexxx{%
5444 \ifx\nchar\bgroup\else 5932 \ifx\nchar\bgroup\else
5445 \expandafter\parsearg 5933 \expandafter\parsearg
5446 \fi \next} 5934 \fi \macnamexxx}
5447
5448% We mant to disable all macros during \shipout so that they are not
5449% expanded by \write.
5450\def\turnoffmacros{\begingroup \def\do##1{\let\noexpand##1=\relax}%
5451 \edef\next{\macrolist}\expandafter\endgroup\next}
5452 5935
5453 5936
5454% @alias. 5937% @alias.
5455% We need some trickery to remove the optional spaces around the equal 5938% We need some trickery to remove the optional spaces around the equal
5456% sign. Just make them active and then expand them all to nothing. 5939% sign. Just make them active and then expand them all to nothing.
5457\def\alias{\begingroup\obeyspaces\parsearg\aliasxxx} 5940\def\alias{\parseargusing\obeyspaces\aliasxxx}
5458\def\aliasxxx #1{\aliasyyy#1\relax} 5941\def\aliasxxx #1{\aliasyyy#1\relax}
5459\def\aliasyyy #1=#2\relax{\ignoreactivespaces 5942\def\aliasyyy #1=#2\relax{%
5460\edef\next{\global\let\expandafter\noexpand\csname#1\endcsname=% 5943 {%
5461 \expandafter\noexpand\csname#2\endcsname}% 5944 \expandafter\let\obeyedspace=\empty
5462\expandafter\endgroup\next} 5945 \addtomacrolist{#1}%
5946 \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}%
5947 }%
5948 \next
5949}
5463 5950
5464 5951
5465\message{cross references,} 5952\message{cross references,}
5466% @xref etc.
5467 5953
5468\newwrite\auxfile 5954\newwrite\auxfile
5469 5955
@@ -5475,56 +5961,68 @@ width0pt\relax} \fi
5475\def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}}, 5961\def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
5476 node \samp{\ignorespaces#1{}}} 5962 node \samp{\ignorespaces#1{}}}
5477 5963
5478% @node's job is to define \lastnode. 5964% @node's only job in TeX is to define \lastnode, which is used in
5479\def\node{\ENVcheck\parsearg\nodezzz} 5965% cross-references. The @node line might or might not have commas, and
5480\def\nodezzz#1{\nodexxx [#1,]} 5966% might or might not have spaces before the first comma, like:
5481\def\nodexxx[#1,#2]{\gdef\lastnode{#1}} 5967% @node foo , bar , ...
5968% We don't want such trailing spaces in the node name.
5969%
5970\parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse}
5971%
5972% also remove a trailing comma, in case of something like this:
5973% @node Help-Cross, , , Cross-refs
5974\def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse}
5975\def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}}
5976
5482\let\nwnode=\node 5977\let\nwnode=\node
5483\let\lastnode=\relax 5978\let\lastnode=\empty
5484 5979
5485% The sectioning commands (@chapter, etc.) call these. 5980% Write a cross-reference definition for the current node. #1 is the
5486\def\donoderef{% 5981% type (Ynumbered, Yappendix, Ynothing).
5487 \ifx\lastnode\relax\else 5982%
5488 \expandafter\expandafter\expandafter\setref{\lastnode}% 5983\def\donoderef#1{%
5489 {Ysectionnumberandtype}% 5984 \ifx\lastnode\empty\else
5490 \global\let\lastnode=\relax 5985 \setref{\lastnode}{#1}%
5491 \fi 5986 \global\let\lastnode=\empty
5492}
5493\def\unnumbnoderef{%
5494 \ifx\lastnode\relax\else
5495 \expandafter\expandafter\expandafter\setref{\lastnode}{Ynothing}%
5496 \global\let\lastnode=\relax
5497 \fi
5498}
5499\def\appendixnoderef{%
5500 \ifx\lastnode\relax\else
5501 \expandafter\expandafter\expandafter\setref{\lastnode}%
5502 {Yappendixletterandtype}%
5503 \global\let\lastnode=\relax
5504 \fi 5987 \fi
5505} 5988}
5506 5989
5507
5508% @anchor{NAME} -- define xref target at arbitrary point. 5990% @anchor{NAME} -- define xref target at arbitrary point.
5509% 5991%
5510\newcount\savesfregister 5992\newcount\savesfregister
5511\gdef\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi} 5993%
5512\gdef\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi} 5994\def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi}
5513\gdef\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces} 5995\def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi}
5514 5996\def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces}
5515% \setref{NAME}{SNT} defines a cross-reference point NAME, namely 5997
5516% NAME-title, NAME-pg, and NAME-SNT. Called from \foonoderef. We have 5998% \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an
5517% to set \indexdummies so commands such as @code in a section title 5999% anchor), which consists of three parts:
5518% aren't expanded. It would be nicer not to expand the titles in the 6000% 1) NAME-title - the current sectioning name taken from \thissection,
5519% first place, but there's so many layers that that is hard to do. 6001% or the anchor name.
5520% 6002% 2) NAME-snt - section number and type, passed as the SNT arg, or
5521\def\setref#1#2{{% 6003% empty for anchors.
5522 \indexdummies 6004% 3) NAME-pg - the page number.
6005%
6006% This is called from \donoderef, \anchor, and \dofloat. In the case of
6007% floats, there is an additional part, which is not written here:
6008% 4) NAME-lof - the text as it should appear in a @listoffloats.
6009%
6010\def\setref#1#2{%
5523 \pdfmkdest{#1}% 6011 \pdfmkdest{#1}%
5524 \dosetq{#1-title}{Ytitle}% 6012 \iflinks
5525 \dosetq{#1-pg}{Ypagenumber}% 6013 {%
5526 \dosetq{#1-snt}{#2}% 6014 \atdummies % preserve commands, but don't expand them
5527}} 6015 \edef\writexrdef##1##2{%
6016 \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef
6017 ##1}{##2}}% these are parameters of \writexrdef
6018 }%
6019 \toks0 = \expandafter{\thissection}%
6020 \immediate \writexrdef{title}{\the\toks0 }%
6021 \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc.
6022 \writexrdef{pg}{\folio}% will be written later, during \shipout
6023 }%
6024 \fi
6025}
5528 6026
5529% @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is 6027% @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is
5530% the node name, #2 the name of the Info cross-reference, #3 the printed 6028% the node name, #2 the name of the Info cross-reference, #3 the printed
@@ -5537,137 +6035,159 @@ width0pt\relax} \fi
5537\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup 6035\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
5538 \unsepspaces 6036 \unsepspaces
5539 \def\printedmanual{\ignorespaces #5}% 6037 \def\printedmanual{\ignorespaces #5}%
5540 \def\printednodename{\ignorespaces #3}% 6038 \def\printedrefname{\ignorespaces #3}%
5541 \setbox1=\hbox{\printedmanual}% 6039 \setbox1=\hbox{\printedmanual\unskip}%
5542 \setbox0=\hbox{\printednodename}% 6040 \setbox0=\hbox{\printedrefname\unskip}%
5543 \ifdim \wd0 = 0pt 6041 \ifdim \wd0 = 0pt
5544 % No printed node name was explicitly given. 6042 % No printed node name was explicitly given.
5545 \expandafter\ifx\csname SETxref-automatic-section-title\endcsname\relax 6043 \expandafter\ifx\csname SETxref-automatic-section-title\endcsname\relax
5546 % Use the node name inside the square brackets. 6044 % Use the node name inside the square brackets.
5547 \def\printednodename{\ignorespaces #1}% 6045 \def\printedrefname{\ignorespaces #1}%
5548 \else 6046 \else
5549 % Use the actual chapter/section title appear inside 6047 % Use the actual chapter/section title appear inside
5550 % the square brackets. Use the real section title if we have it. 6048 % the square brackets. Use the real section title if we have it.
5551 \ifdim \wd1 > 0pt 6049 \ifdim \wd1 > 0pt
5552 % It is in another manual, so we don't have it. 6050 % It is in another manual, so we don't have it.
5553 \def\printednodename{\ignorespaces #1}% 6051 \def\printedrefname{\ignorespaces #1}%
5554 \else 6052 \else
5555 \ifhavexrefs 6053 \ifhavexrefs
5556 % We know the real title if we have the xref values. 6054 % We know the real title if we have the xref values.
5557 \def\printednodename{\refx{#1-title}{}}% 6055 \def\printedrefname{\refx{#1-title}{}}%
5558 \else 6056 \else
5559 % Otherwise just copy the Info node name. 6057 % Otherwise just copy the Info node name.
5560 \def\printednodename{\ignorespaces #1}% 6058 \def\printedrefname{\ignorespaces #1}%
5561 \fi% 6059 \fi%
5562 \fi 6060 \fi
5563 \fi 6061 \fi
5564 \fi 6062 \fi
5565 % 6063 %
5566 % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not 6064 % Make link in pdf output.
5567 % insert empty discretionaries after hyphens, which means that it will
5568 % not find a line break at a hyphen in a node names. Since some manuals
5569 % are best written with fairly long node names, containing hyphens, this
5570 % is a loss. Therefore, we give the text of the node name again, so it
5571 % is as if TeX is seeing it for the first time.
5572 \ifpdf 6065 \ifpdf
5573 \leavevmode 6066 \leavevmode
5574 \getfilename{#4}% 6067 \getfilename{#4}%
5575 {\normalturnoffactive 6068 {\turnoffactive
6069 % See comments at \activebackslashdouble.
6070 {\activebackslashdouble \xdef\pdfxrefdest{#1}%
6071 \backslashparens\pdfxrefdest}%
6072 %
5576 \ifnum\filenamelength>0 6073 \ifnum\filenamelength>0
5577 \startlink attr{/Border [0 0 0]}% 6074 \startlink attr{/Border [0 0 0]}%
5578 goto file{\the\filename.pdf} name{#1}% 6075 goto file{\the\filename.pdf} name{\pdfxrefdest}%
5579 \else 6076 \else
5580 \startlink attr{/Border [0 0 0]}% 6077 \startlink attr{/Border [0 0 0]}%
5581 goto name{#1}% 6078 goto name{\pdfmkpgn{\pdfxrefdest}}%
5582 \fi 6079 \fi
5583 }% 6080 }%
5584 \linkcolor 6081 \linkcolor
5585 \fi 6082 \fi
5586 % 6083 %
5587 \ifdim \wd1 > 0pt 6084 % Float references are printed completely differently: "Figure 1.2"
5588 \putwordsection{} ``\printednodename'' \putwordin{} \cite{\printedmanual}% 6085 % instead of "[somenode], p.3". We distinguish them by the
6086 % LABEL-title being set to a magic string.
6087 {%
6088 % Have to otherify everything special to allow the \csname to
6089 % include an _ in the xref name, etc.
6090 \indexnofonts
6091 \turnoffactive
6092 \expandafter\global\expandafter\let\expandafter\Xthisreftitle
6093 \csname XR#1-title\endcsname
6094 }%
6095 \iffloat\Xthisreftitle
6096 % If the user specified the print name (third arg) to the ref,
6097 % print it instead of our usual "Figure 1.2".
6098 \ifdim\wd0 = 0pt
6099 \refx{#1-snt}{}%
6100 \else
6101 \printedrefname
6102 \fi
6103 %
6104 % if the user also gave the printed manual name (fifth arg), append
6105 % "in MANUALNAME".
6106 \ifdim \wd1 > 0pt
6107 \space \putwordin{} \cite{\printedmanual}%
6108 \fi
5589 \else 6109 \else
5590 % _ (for example) has to be the character _ for the purposes of the 6110 % node/anchor (non-float) references.
5591 % control sequence corresponding to the node, but it has to expand 6111 %
5592 % into the usual \leavevmode...\vrule stuff for purposes of 6112 % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not
5593 % printing. So we \turnoffactive for the \refx-snt, back on for the 6113 % insert empty discretionaries after hyphens, which means that it will
5594 % printing, back off for the \refx-pg. 6114 % not find a line break at a hyphen in a node names. Since some manuals
5595 {\normalturnoffactive 6115 % are best written with fairly long node names, containing hyphens, this
5596 % Only output a following space if the -snt ref is nonempty; for 6116 % is a loss. Therefore, we give the text of the node name again, so it
5597 % @unnumbered and @anchor, it won't be. 6117 % is as if TeX is seeing it for the first time.
5598 \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}% 6118 \ifdim \wd1 > 0pt
5599 \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi 6119 \putwordsection{} ``\printedrefname'' \putwordin{} \cite{\printedmanual}%
5600 }% 6120 \else
5601 % [mynode], 6121 % _ (for example) has to be the character _ for the purposes of the
5602 [\printednodename],\space 6122 % control sequence corresponding to the node, but it has to expand
5603 % page 3 6123 % into the usual \leavevmode...\vrule stuff for purposes of
5604 \turnoffactive \putwordpage\tie\refx{#1-pg}{}% 6124 % printing. So we \turnoffactive for the \refx-snt, back on for the
6125 % printing, back off for the \refx-pg.
6126 {\turnoffactive
6127 % Only output a following space if the -snt ref is nonempty; for
6128 % @unnumbered and @anchor, it won't be.
6129 \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
6130 \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
6131 }%
6132 % output the `[mynode]' via a macro so it can be overridden.
6133 \xrefprintnodename\printedrefname
6134 %
6135 % But we always want a comma and a space:
6136 ,\space
6137 %
6138 % output the `page 3'.
6139 \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
6140 \fi
5605 \fi 6141 \fi
5606 \endlink 6142 \endlink
5607\endgroup} 6143\endgroup}
5608 6144
5609% \dosetq is the interface for calls from other macros 6145% This macro is called from \xrefX for the `[nodename]' part of xref
5610 6146% output. It's a separate macro only so it can be changed more easily,
5611% Use \normalturnoffactive so that punctuation chars such as underscore 6147% since square brackets don't work well in some documents. Particularly
5612% and backslash work in node names. (\turnoffactive doesn't do \.) 6148% one that Bob is working on :).
5613\def\dosetq#1#2{% 6149%
5614 {\let\folio=0% 6150\def\xrefprintnodename#1{[#1]}
5615 \normalturnoffactive
5616 \edef\next{\write\auxfile{\internalsetq{#1}{#2}}}%
5617 \iflinks
5618 \next
5619 \fi
5620 }%
5621}
5622
5623% \internalsetq {foo}{page} expands into
5624% CHARACTERS 'xrdef {foo}{...expansion of \Ypage...}
5625% When the aux file is read, ' is the escape character
5626
5627\def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}}
5628
5629% Things to be expanded by \internalsetq
5630
5631\def\Ypagenumber{\folio}
5632
5633\def\Ytitle{\thissection}
5634
5635\def\Ynothing{}
5636
5637\def\Ysectionnumberandtype{%
5638\ifnum\secno=0 \putwordChapter\xreftie\the\chapno %
5639\else \ifnum \subsecno=0 \putwordSection\xreftie\the\chapno.\the\secno %
5640\else \ifnum \subsubsecno=0 %
5641\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno %
5642\else %
5643\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno %
5644\fi \fi \fi }
5645
5646\def\Yappendixletterandtype{%
5647\ifnum\secno=0 \putwordAppendix\xreftie'char\the\appendixno{}%
5648\else \ifnum \subsecno=0 \putwordSection\xreftie'char\the\appendixno.\the\secno %
5649\else \ifnum \subsubsecno=0 %
5650\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno %
5651\else %
5652\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno %
5653\fi \fi \fi }
5654
5655\gdef\xreftie{'tie}
5656 6151
5657% Use TeX 3.0's \inputlineno to get the line number, for better error 6152% Things referred to by \setref.
5658% messages, but if we're using an old version of TeX, don't do anything.
5659% 6153%
5660\ifx\inputlineno\thisisundefined 6154\def\Ynothing{}
5661 \let\linenumber = \empty % Non-3.0. 6155\def\Yomitfromtoc{}
5662\else 6156\def\Ynumbered{%
5663 \def\linenumber{\the\inputlineno:\space} 6157 \ifnum\secno=0
5664\fi 6158 \putwordChapter@tie \the\chapno
6159 \else \ifnum\subsecno=0
6160 \putwordSection@tie \the\chapno.\the\secno
6161 \else \ifnum\subsubsecno=0
6162 \putwordSection@tie \the\chapno.\the\secno.\the\subsecno
6163 \else
6164 \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno
6165 \fi\fi\fi
6166}
6167\def\Yappendix{%
6168 \ifnum\secno=0
6169 \putwordAppendix@tie @char\the\appendixno{}%
6170 \else \ifnum\subsecno=0
6171 \putwordSection@tie @char\the\appendixno.\the\secno
6172 \else \ifnum\subsubsecno=0
6173 \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno
6174 \else
6175 \putwordSection@tie
6176 @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno
6177 \fi\fi\fi
6178}
5665 6179
5666% Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME. 6180% Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
5667% If its value is nonempty, SUFFIX is output afterward. 6181% If its value is nonempty, SUFFIX is output afterward.
5668 6182%
5669\def\refx#1#2{% 6183\def\refx#1#2{%
5670 \expandafter\ifx\csname X#1\endcsname\relax 6184 {%
6185 \indexnofonts
6186 \otherbackslash
6187 \expandafter\global\expandafter\let\expandafter\thisrefX
6188 \csname XR#1\endcsname
6189 }%
6190 \ifx\thisrefX\relax
5671 % If not defined, say something at least. 6191 % If not defined, say something at least.
5672 \angleleft un\-de\-fined\angleright 6192 \angleleft un\-de\-fined\angleright
5673 \iflinks 6193 \iflinks
@@ -5682,22 +6202,50 @@ width0pt\relax} \fi
5682 \fi 6202 \fi
5683 \else 6203 \else
5684 % It's defined, so just use it. 6204 % It's defined, so just use it.
5685 \csname X#1\endcsname 6205 \thisrefX
5686 \fi 6206 \fi
5687 #2% Output the suffix in any case. 6207 #2% Output the suffix in any case.
5688} 6208}
5689 6209
5690% This is the macro invoked by entries in the aux file. 6210% This is the macro invoked by entries in the aux file. Usually it's
6211% just a \def (we prepend XR to the control sequence name to avoid
6212% collisions). But if this is a float type, we have more work to do.
5691% 6213%
5692\def\xrdef#1{\begingroup 6214\def\xrdef#1#2{%
5693 % Reenable \ as an escape while reading the second argument. 6215 \expandafter\gdef\csname XR#1\endcsname{#2}% remember this xref value.
5694 \catcode`\\ = 0 6216 %
5695 \afterassignment\endgroup 6217 % Was that xref control sequence that we just defined for a float?
5696 \expandafter\gdef\csname X#1\endcsname 6218 \expandafter\iffloat\csname XR#1\endcsname
6219 % it was a float, and we have the (safe) float type in \iffloattype.
6220 \expandafter\let\expandafter\floatlist
6221 \csname floatlist\iffloattype\endcsname
6222 %
6223 % Is this the first time we've seen this float type?
6224 \expandafter\ifx\floatlist\relax
6225 \toks0 = {\do}% yes, so just \do
6226 \else
6227 % had it before, so preserve previous elements in list.
6228 \toks0 = \expandafter{\floatlist\do}%
6229 \fi
6230 %
6231 % Remember this xref in the control sequence \floatlistFLOATTYPE,
6232 % for later use in \listoffloats.
6233 \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0{#1}}%
6234 \fi
5697} 6235}
5698 6236
5699% Read the last existing aux file, if any. No error if none exists. 6237% Read the last existing aux file, if any. No error if none exists.
5700\def\readauxfile{\begingroup 6238%
6239\def\tryauxfile{%
6240 \openin 1 \jobname.aux
6241 \ifeof 1 \else
6242 \readdatafile{aux}%
6243 \global\havexrefstrue
6244 \fi
6245 \closein 1
6246}
6247
6248\def\setupdatafile{%
5701 \catcode`\^^@=\other 6249 \catcode`\^^@=\other
5702 \catcode`\^^A=\other 6250 \catcode`\^^A=\other
5703 \catcode`\^^B=\other 6251 \catcode`\^^B=\other
@@ -5725,9 +6273,7 @@ width0pt\relax} \fi
5725 \catcode`\^^]=\other 6273 \catcode`\^^]=\other
5726 \catcode`\^^^=\other 6274 \catcode`\^^^=\other
5727 \catcode`\^^_=\other 6275 \catcode`\^^_=\other
5728 \catcode`\@=\other 6276 % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc.
5729 \catcode`\^=\other
5730 % It was suggested to define this as 7, which would allow ^^e4 etc.
5731 % in xref tags, i.e., node names. But since ^^e4 notation isn't 6277 % in xref tags, i.e., node names. But since ^^e4 notation isn't
5732 % supported in the main text, it doesn't seem desirable. Furthermore, 6278 % supported in the main text, it doesn't seem desirable. Furthermore,
5733 % that is not enough: for node names that actually contain a ^ 6279 % that is not enough: for node names that actually contain a ^
@@ -5740,6 +6286,9 @@ width0pt\relax} \fi
5740 % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter 6286 % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter
5741 % and then to call \auxhat in \setq. 6287 % and then to call \auxhat in \setq.
5742 % 6288 %
6289 \catcode`\^=\other
6290 %
6291 % Special characters. Should be turned off anyway, but...
5743 \catcode`\~=\other 6292 \catcode`\~=\other
5744 \catcode`\[=\other 6293 \catcode`\[=\other
5745 \catcode`\]=\other 6294 \catcode`\]=\other
@@ -5751,41 +6300,42 @@ width0pt\relax} \fi
5751 \catcode`\$=\other 6300 \catcode`\$=\other
5752 \catcode`\#=\other 6301 \catcode`\#=\other
5753 \catcode`\&=\other 6302 \catcode`\&=\other
6303 \catcode`\%=\other
5754 \catcode`+=\other % avoid \+ for paranoia even though we've turned it off 6304 \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
5755 % Make the characters 128-255 be printing characters 6305 %
6306 % This is to support \ in node names and titles, since the \
6307 % characters end up in a \csname. It's easier than
6308 % leaving it active and making its active definition an actual \
6309 % character. What I don't understand is why it works in the *value*
6310 % of the xrdef. Seems like it should be a catcode12 \, and that
6311 % should not typeset properly. But it works, so I'm moving on for
6312 % now. --karl, 15jan04.
6313 \catcode`\\=\other
6314 %
6315 % Make the characters 128-255 be printing characters.
5756 {% 6316 {%
5757 \count 1=128 6317 \count1=128
5758 \def\loop{% 6318 \def\loop{%
5759 \catcode\count 1=\other 6319 \catcode\count1=\other
5760 \advance\count 1 by 1 6320 \advance\count1 by 1
5761 \ifnum \count 1<256 \loop \fi 6321 \ifnum \count1<256 \loop \fi
5762 }% 6322 }%
5763 }% 6323 }%
5764 % The aux file uses ' as the escape (for now). 6324 %
5765 % Turn off \ as an escape so we do not lose on 6325 % @ is our escape character in .aux files, and we need braces.
5766 % entries which were dumped with control sequences in their names.
5767 % For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^
5768 % Reference to such entries still does not work the way one would wish,
5769 % but at least they do not bomb out when the aux file is read in.
5770 \catcode`\{=1 6326 \catcode`\{=1
5771 \catcode`\}=2 6327 \catcode`\}=2
5772 \catcode`\%=\other 6328 \catcode`\@=0
5773 \catcode`\'=0 6329}
5774 \catcode`\\=\other
5775 %
5776 \openin 1 \jobname.aux
5777 \ifeof 1 \else
5778 \closein 1
5779 \input \jobname.aux
5780 \global\havexrefstrue
5781 \global\warnedobstrue
5782 \fi
5783 % Open the new aux file. TeX will close it automatically at exit.
5784 \openout\auxfile=\jobname.aux
5785\endgroup}
5786 6330
6331\def\readdatafile#1{%
6332\begingroup
6333 \setupdatafile
6334 \input\jobname.#1
6335\endgroup}
5787 6336
5788% Footnotes. 6337\message{insertions,}
6338% including footnotes.
5789 6339
5790\newcount \footnoteno 6340\newcount \footnoteno
5791 6341
@@ -5799,37 +6349,39 @@ width0pt\relax} \fi
5799% @footnotestyle is meaningful for info output only. 6349% @footnotestyle is meaningful for info output only.
5800\let\footnotestyle=\comment 6350\let\footnotestyle=\comment
5801 6351
5802\let\ptexfootnote=\footnote
5803
5804{\catcode `\@=11 6352{\catcode `\@=11
5805% 6353%
5806% Auto-number footnotes. Otherwise like plain. 6354% Auto-number footnotes. Otherwise like plain.
5807\gdef\footnote{% 6355\gdef\footnote{%
6356 \let\indent=\ptexindent
6357 \let\noindent=\ptexnoindent
5808 \global\advance\footnoteno by \@ne 6358 \global\advance\footnoteno by \@ne
5809 \edef\thisfootno{$^{\the\footnoteno}$}% 6359 \edef\thisfootno{$^{\the\footnoteno}$}%
5810 % 6360 %
5811 % In case the footnote comes at the end of a sentence, preserve the 6361 % In case the footnote comes at the end of a sentence, preserve the
5812 % extra spacing after we do the footnote number. 6362 % extra spacing after we do the footnote number.
5813 \let\@sf\empty 6363 \let\@sf\empty
5814 \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi 6364 \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi
5815 % 6365 %
5816 % Remove inadvertent blank space before typesetting the footnote number. 6366 % Remove inadvertent blank space before typesetting the footnote number.
5817 \unskip 6367 \unskip
5818 \thisfootno\@sf 6368 \thisfootno\@sf
5819 \footnotezzz 6369 \dofootnote
5820}% 6370}%
5821 6371
5822% Don't bother with the trickery in plain.tex to not require the 6372% Don't bother with the trickery in plain.tex to not require the
5823% footnote text as a parameter. Our footnotes don't need to be so general. 6373% footnote text as a parameter. Our footnotes don't need to be so general.
5824% 6374%
5825% Oh yes, they do; otherwise, @ifset and anything else that uses 6375% Oh yes, they do; otherwise, @ifset (and anything else that uses
5826% \parseargline fail inside footnotes because the tokens are fixed when 6376% \parseargline) fails inside footnotes because the tokens are fixed when
5827% the footnote is read. --karl, 16nov96. 6377% the footnote is read. --karl, 16nov96.
5828% 6378%
5829\long\gdef\footnotezzz{\insert\footins\bgroup 6379\gdef\dofootnote{%
6380 \insert\footins\bgroup
5830 % We want to typeset this text as a normal paragraph, even if the 6381 % We want to typeset this text as a normal paragraph, even if the
5831 % footnote reference occurs in (for example) a display environment. 6382 % footnote reference occurs in (for example) a display environment.
5832 % So reset some parameters. 6383 % So reset some parameters.
6384 \hsize=\pagewidth
5833 \interlinepenalty\interfootnotelinepenalty 6385 \interlinepenalty\interfootnotelinepenalty
5834 \splittopskip\ht\strutbox % top baseline for broken footnotes 6386 \splittopskip\ht\strutbox % top baseline for broken footnotes
5835 \splitmaxdepth\dp\strutbox 6387 \splitmaxdepth\dp\strutbox
@@ -5859,48 +6411,68 @@ width0pt\relax} \fi
5859 \footstrut 6411 \footstrut
5860 \futurelet\next\fo@t 6412 \futurelet\next\fo@t
5861} 6413}
5862\def\fo@t{\ifcat\bgroup\noexpand\next \let\next\f@@t
5863 \else\let\next\f@t\fi \next}
5864\def\f@@t{\bgroup\aftergroup\@foot\let\next}
5865\def\f@t#1{#1\@foot}
5866\def\@foot{\strut\par\egroup}
5867
5868}%end \catcode `\@=11 6414}%end \catcode `\@=11
5869 6415
5870% @| inserts a changebar to the left of the current line. It should 6416% In case a @footnote appears in a vbox, save the footnote text and create
5871% surround any changed text. This approach does *not* work if the 6417% the real \insert just after the vbox finished. Otherwise, the insertion
5872% change spans more than two lines of output. To handle that, we would 6418% would be lost.
5873% have adopt a much more difficult approach (putting marks into the main 6419% Similarily, if a @footnote appears inside an alignment, save the footnote
5874% vertical list for the beginning and end of each change). 6420% text to a box and make the \insert when a row of the table is finished.
6421% And the same can be done for other insert classes. --kasal, 16nov03.
6422
6423% Replace the \insert primitive by a cheating macro.
6424% Deeper inside, just make sure that the saved insertions are not spilled
6425% out prematurely.
5875% 6426%
5876\def\|{% 6427\def\startsavinginserts{%
5877 % \vadjust can only be used in horizontal mode. 6428 \ifx \insert\ptexinsert
5878 \leavevmode 6429 \let\insert\saveinsert
5879 % 6430 \else
5880 % Append this vertical mode material after the current line in the output. 6431 \let\checkinserts\relax
5881 \vadjust{% 6432 \fi
5882 % We want to insert a rule with the height and depth of the current
5883 % leading; that is exactly what \strutbox is supposed to record.
5884 \vskip-\baselineskip
5885 %
5886 % \vadjust-items are inserted at the left edge of the type. So
5887 % the \llap here moves out into the left-hand margin.
5888 \llap{%
5889 %
5890 % For a thicker or thinner bar, change the `1pt'.
5891 \vrule height\baselineskip width1pt
5892 %
5893 % This is the space between the bar and the text.
5894 \hskip 12pt
5895 }%
5896 }%
5897} 6433}
5898 6434
5899% For a final copy, take out the rectangles 6435% This \insert replacement works for both \insert\footins{foo} and
5900% that mark overfull boxes (in case you have decided 6436% \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}.
5901% that the text looks ok even though it passes the margin).
5902% 6437%
5903\def\finalout{\overfullrule=0pt} 6438\def\saveinsert#1{%
6439 \edef\next{\noexpand\savetobox \makeSAVEname#1}%
6440 \afterassignment\next
6441 % swallow the left brace
6442 \let\temp =
6443}
6444\def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}}
6445\def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1}
6446
6447\def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi}
6448
6449\def\placesaveins#1{%
6450 \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname
6451 {\box#1}%
6452}
6453
6454% eat @SAVE -- beware, all of them have catcode \other:
6455{
6456 \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials % ;-)
6457 \gdef\gobblesave @SAVE{}
6458}
6459
6460% initialization:
6461\def\newsaveins #1{%
6462 \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}%
6463 \next
6464}
6465\def\newsaveinsX #1{%
6466 \csname newbox\endcsname #1%
6467 \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts
6468 \checksaveins #1}%
6469}
6470
6471% initialize:
6472\let\checkinserts\empty
6473\newsaveins\footins
6474\newsaveins\margin
6475
5904 6476
5905% @image. We use the macros from epsf.tex to support this. 6477% @image. We use the macros from epsf.tex to support this.
5906% If epsf.tex is not installed and @image is used, we complain. 6478% If epsf.tex is not installed and @image is used, we complain.
@@ -5910,12 +6482,12 @@ width0pt\relax} \fi
5910% undone and the next image would fail. 6482% undone and the next image would fail.
5911\openin 1 = epsf.tex 6483\openin 1 = epsf.tex
5912\ifeof 1 \else 6484\ifeof 1 \else
5913 \closein 1 6485 % Do not bother showing banner with epsf.tex v2.7k (available in
5914 % Do not bother showing banner with post-v2.7 epsf.tex (available in 6486 % doc/epsf.tex and on ctan).
5915 % doc/epsf.tex until it shows up on ctan).
5916 \def\epsfannounce{\toks0 = }% 6487 \def\epsfannounce{\toks0 = }%
5917 \input epsf.tex 6488 \input epsf.tex
5918\fi 6489\fi
6490\closein 1
5919% 6491%
5920% We will only complain once about lack of epsf.tex. 6492% We will only complain once about lack of epsf.tex.
5921\newif\ifwarnednoepsf 6493\newif\ifwarnednoepsf
@@ -5954,7 +6526,7 @@ width0pt\relax} \fi
5954 % above and below. 6526 % above and below.
5955 \nobreak\vskip\parskip 6527 \nobreak\vskip\parskip
5956 \nobreak 6528 \nobreak
5957 \line\bgroup\hss 6529 \line\bgroup
5958 \fi 6530 \fi
5959 % 6531 %
5960 % Output the image. 6532 % Output the image.
@@ -5967,10 +6539,275 @@ width0pt\relax} \fi
5967 \epsfbox{#1.eps}% 6539 \epsfbox{#1.eps}%
5968 \fi 6540 \fi
5969 % 6541 %
5970 \ifimagevmode \hss \egroup \bigbreak \fi % space after the image 6542 \ifimagevmode \egroup \bigbreak \fi % space after the image
5971\endgroup} 6543\endgroup}
5972 6544
5973 6545
6546% @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables,
6547% etc. We don't actually implement floating yet, we always include the
6548% float "here". But it seemed the best name for the future.
6549%
6550\envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish}
6551
6552% There may be a space before second and/or third parameter; delete it.
6553\def\eatcommaspace#1, {#1,}
6554
6555% #1 is the optional FLOATTYPE, the text label for this float, typically
6556% "Figure", "Table", "Example", etc. Can't contain commas. If omitted,
6557% this float will not be numbered and cannot be referred to.
6558%
6559% #2 is the optional xref label. Also must be present for the float to
6560% be referable.
6561%
6562% #3 is the optional positioning argument; for now, it is ignored. It
6563% will somehow specify the positions allowed to float to (here, top, bottom).
6564%
6565% We keep a separate counter for each FLOATTYPE, which we reset at each
6566% chapter-level command.
6567\let\resetallfloatnos=\empty
6568%
6569\def\dofloat#1,#2,#3,#4\finish{%
6570 \let\thiscaption=\empty
6571 \let\thisshortcaption=\empty
6572 %
6573 % don't lose footnotes inside @float.
6574 %
6575 % BEWARE: when the floats start float, we have to issue warning whenever an
6576 % insert appears inside a float which could possibly float. --kasal, 26may04
6577 %
6578 \startsavinginserts
6579 %
6580 % We can't be used inside a paragraph.
6581 \par
6582 %
6583 \vtop\bgroup
6584 \def\floattype{#1}%
6585 \def\floatlabel{#2}%
6586 \def\floatloc{#3}% we do nothing with this yet.
6587 %
6588 \ifx\floattype\empty
6589 \let\safefloattype=\empty
6590 \else
6591 {%
6592 % the floattype might have accents or other special characters,
6593 % but we need to use it in a control sequence name.
6594 \indexnofonts
6595 \turnoffactive
6596 \xdef\safefloattype{\floattype}%
6597 }%
6598 \fi
6599 %
6600 % If label is given but no type, we handle that as the empty type.
6601 \ifx\floatlabel\empty \else
6602 % We want each FLOATTYPE to be numbered separately (Figure 1,
6603 % Table 1, Figure 2, ...). (And if no label, no number.)
6604 %
6605 \expandafter\getfloatno\csname\safefloattype floatno\endcsname
6606 \global\advance\floatno by 1
6607 %
6608 {%
6609 % This magic value for \thissection is output by \setref as the
6610 % XREFLABEL-title value. \xrefX uses it to distinguish float
6611 % labels (which have a completely different output format) from
6612 % node and anchor labels. And \xrdef uses it to construct the
6613 % lists of floats.
6614 %
6615 \edef\thissection{\floatmagic=\safefloattype}%
6616 \setref{\floatlabel}{Yfloat}%
6617 }%
6618 \fi
6619 %
6620 % start with \parskip glue, I guess.
6621 \vskip\parskip
6622 %
6623 % Don't suppress indentation if a float happens to start a section.
6624 \restorefirstparagraphindent
6625}
6626
6627% we have these possibilities:
6628% @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap
6629% @float Foo,lbl & no caption: Foo 1.1
6630% @float Foo & @caption{Cap}: Foo: Cap
6631% @float Foo & no caption: Foo
6632% @float ,lbl & Caption{Cap}: 1.1: Cap
6633% @float ,lbl & no caption: 1.1
6634% @float & @caption{Cap}: Cap
6635% @float & no caption:
6636%
6637\def\Efloat{%
6638 \let\floatident = \empty
6639 %
6640 % In all cases, if we have a float type, it comes first.
6641 \ifx\floattype\empty \else \def\floatident{\floattype}\fi
6642 %
6643 % If we have an xref label, the number comes next.
6644 \ifx\floatlabel\empty \else
6645 \ifx\floattype\empty \else % if also had float type, need tie first.
6646 \appendtomacro\floatident{\tie}%
6647 \fi
6648 % the number.
6649 \appendtomacro\floatident{\chaplevelprefix\the\floatno}%
6650 \fi
6651 %
6652 % Start the printed caption with what we've constructed in
6653 % \floatident, but keep it separate; we need \floatident again.
6654 \let\captionline = \floatident
6655 %
6656 \ifx\thiscaption\empty \else
6657 \ifx\floatident\empty \else
6658 \appendtomacro\captionline{: }% had ident, so need a colon between
6659 \fi
6660 %
6661 % caption text.
6662 \appendtomacro\captionline{\scanexp\thiscaption}%
6663 \fi
6664 %
6665 % If we have anything to print, print it, with space before.
6666 % Eventually this needs to become an \insert.
6667 \ifx\captionline\empty \else
6668 \vskip.5\parskip
6669 \captionline
6670 %
6671 % Space below caption.
6672 \vskip\parskip
6673 \fi
6674 %
6675 % If have an xref label, write the list of floats info. Do this
6676 % after the caption, to avoid chance of it being a breakpoint.
6677 \ifx\floatlabel\empty \else
6678 % Write the text that goes in the lof to the aux file as
6679 % \floatlabel-lof. Besides \floatident, we include the short
6680 % caption if specified, else the full caption if specified, else nothing.
6681 {%
6682 \atdummies
6683 %
6684 % since we read the caption text in the macro world, where ^^M
6685 % is turned into a normal character, we have to scan it back, so
6686 % we don't write the literal three characters "^^M" into the aux file.
6687 \scanexp{%
6688 \xdef\noexpand\gtemp{%
6689 \ifx\thisshortcaption\empty
6690 \thiscaption
6691 \else
6692 \thisshortcaption
6693 \fi
6694 }%
6695 }%
6696 \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident
6697 \ifx\gtemp\empty \else : \gtemp \fi}}%
6698 }%
6699 \fi
6700 \egroup % end of \vtop
6701 %
6702 % place the captured inserts
6703 %
6704 % BEWARE: when the floats start floating, we have to issue warning
6705 % whenever an insert appears inside a float which could possibly
6706 % float. --kasal, 26may04
6707 %
6708 \checkinserts
6709}
6710
6711% Append the tokens #2 to the definition of macro #1, not expanding either.
6712%
6713\def\appendtomacro#1#2{%
6714 \expandafter\def\expandafter#1\expandafter{#1#2}%
6715}
6716
6717% @caption, @shortcaption
6718%
6719\def\caption{\docaption\thiscaption}
6720\def\shortcaption{\docaption\thisshortcaption}
6721\def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption}
6722\def\defcaption#1#2{\egroup \def#1{#2}}
6723
6724% The parameter is the control sequence identifying the counter we are
6725% going to use. Create it if it doesn't exist and assign it to \floatno.
6726\def\getfloatno#1{%
6727 \ifx#1\relax
6728 % Haven't seen this figure type before.
6729 \csname newcount\endcsname #1%
6730 %
6731 % Remember to reset this floatno at the next chap.
6732 \expandafter\gdef\expandafter\resetallfloatnos
6733 \expandafter{\resetallfloatnos #1=0 }%
6734 \fi
6735 \let\floatno#1%
6736}
6737
6738% \setref calls this to get the XREFLABEL-snt value. We want an @xref
6739% to the FLOATLABEL to expand to "Figure 3.1". We call \setref when we
6740% first read the @float command.
6741%
6742\def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}%
6743
6744% Magic string used for the XREFLABEL-title value, so \xrefX can
6745% distinguish floats from other xref types.
6746\def\floatmagic{!!float!!}
6747
6748% #1 is the control sequence we are passed; we expand into a conditional
6749% which is true if #1 represents a float ref. That is, the magic
6750% \thissection value which we \setref above.
6751%
6752\def\iffloat#1{\expandafter\doiffloat#1==\finish}
6753%
6754% #1 is (maybe) the \floatmagic string. If so, #2 will be the
6755% (safe) float type for this float. We set \iffloattype to #2.
6756%
6757\def\doiffloat#1=#2=#3\finish{%
6758 \def\temp{#1}%
6759 \def\iffloattype{#2}%
6760 \ifx\temp\floatmagic
6761}
6762
6763% @listoffloats FLOATTYPE - print a list of floats like a table of contents.
6764%
6765\parseargdef\listoffloats{%
6766 \def\floattype{#1}% floattype
6767 {%
6768 % the floattype might have accents or other special characters,
6769 % but we need to use it in a control sequence name.
6770 \indexnofonts
6771 \turnoffactive
6772 \xdef\safefloattype{\floattype}%
6773 }%
6774 %
6775 % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE.
6776 \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax
6777 \ifhavexrefs
6778 % if the user said @listoffloats foo but never @float foo.
6779 \message{\linenumber No `\safefloattype' floats to list.}%
6780 \fi
6781 \else
6782 \begingroup
6783 \leftskip=\tocindent % indent these entries like a toc
6784 \let\do=\listoffloatsdo
6785 \csname floatlist\safefloattype\endcsname
6786 \endgroup
6787 \fi
6788}
6789
6790% This is called on each entry in a list of floats. We're passed the
6791% xref label, in the form LABEL-title, which is how we save it in the
6792% aux file. We strip off the -title and look up \XRLABEL-lof, which
6793% has the text we're supposed to typeset here.
6794%
6795% Figures without xref labels will not be included in the list (since
6796% they won't appear in the aux file).
6797%
6798\def\listoffloatsdo#1{\listoffloatsdoentry#1\finish}
6799\def\listoffloatsdoentry#1-title\finish{{%
6800 % Can't fully expand XR#1-lof because it can contain anything. Just
6801 % pass the control sequence. On the other hand, XR#1-pg is just the
6802 % page number, and we want to fully expand that so we can get a link
6803 % in pdf output.
6804 \toksA = \expandafter{\csname XR#1-lof\endcsname}%
6805 %
6806 % use the same \entry macro we use to generate the TOC and index.
6807 \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}%
6808 \writeentry
6809}}
6810
5974\message{localization,} 6811\message{localization,}
5975% and i18n. 6812% and i18n.
5976 6813
@@ -5979,19 +6816,17 @@ width0pt\relax} \fi
5979% properly. Single argument is the language abbreviation. 6816% properly. Single argument is the language abbreviation.
5980% It would be nice if we could set up a hyphenation file here. 6817% It would be nice if we could set up a hyphenation file here.
5981% 6818%
5982\def\documentlanguage{\parsearg\dodocumentlanguage} 6819\parseargdef\documentlanguage{%
5983\def\dodocumentlanguage#1{%
5984 \tex % read txi-??.tex file in plain TeX. 6820 \tex % read txi-??.tex file in plain TeX.
5985 % Read the file if it exists. 6821 % Read the file if it exists.
5986 \openin 1 txi-#1.tex 6822 \openin 1 txi-#1.tex
5987 \ifeof1 6823 \ifeof 1
5988 \errhelp = \nolanghelp 6824 \errhelp = \nolanghelp
5989 \errmessage{Cannot read language file txi-#1.tex}% 6825 \errmessage{Cannot read language file txi-#1.tex}%
5990 \let\temp = \relax 6826 \else
5991 \else 6827 \input txi-#1.tex
5992 \def\temp{\input txi-#1.tex }% 6828 \fi
5993 \fi 6829 \closein 1
5994 \temp
5995 \endgroup 6830 \endgroup
5996} 6831}
5997\newhelp\nolanghelp{The given language definition file cannot be found or 6832\newhelp\nolanghelp{The given language definition file cannot be found or
@@ -6036,12 +6871,14 @@ should work if nowhere else does.}
6036 \fi 6871 \fi
6037} 6872}
6038 6873
6039% Parameters in order: 1) textheight; 2) textwidth; 3) voffset; 6874% Parameters in order: 1) textheight; 2) textwidth;
6040% 4) hoffset; 5) binding offset; 6) topskip. We also call 6875% 3) voffset; 4) hoffset; 5) binding offset; 6) topskip;
6041% \setleading{\textleading}, so the caller should define \textleading. 6876% 7) physical page height; 8) physical page width.
6042% The caller should also set \parskip. 6877%
6878% We also call \setleading{\textleading}, so the caller should define
6879% \textleading. The caller should also set \parskip.
6043% 6880%
6044\def\internalpagesizes#1#2#3#4#5#6{% 6881\def\internalpagesizes#1#2#3#4#5#6#7#8{%
6045 \voffset = #3\relax 6882 \voffset = #3\relax
6046 \topskip = #6\relax 6883 \topskip = #6\relax
6047 \splittopskip = \topskip 6884 \splittopskip = \topskip
@@ -6060,55 +6897,88 @@ should work if nowhere else does.}
6060 \normaloffset = #4\relax 6897 \normaloffset = #4\relax
6061 \bindingoffset = #5\relax 6898 \bindingoffset = #5\relax
6062 % 6899 %
6900 \ifpdf
6901 \pdfpageheight #7\relax
6902 \pdfpagewidth #8\relax
6903 \fi
6904 %
6063 \setleading{\textleading} 6905 \setleading{\textleading}
6064 % 6906 %
6065 \parindent = \defaultparindent 6907 \parindent = \defaultparindent
6066 \setemergencystretch 6908 \setemergencystretch
6067} 6909}
6068 6910
6069% Use `small' versions.
6070%
6071\def\smallenvironments{%
6072 \let\smalldisplay = \smalldisplayx
6073 \let\smallexample = \smalllispx
6074 \let\smallformat = \smallformatx
6075 \let\smalllisp = \smalllispx
6076}
6077
6078% @letterpaper (the default). 6911% @letterpaper (the default).
6079\def\letterpaper{{\globaldefs = 1 6912\def\letterpaper{{\globaldefs = 1
6080 \parskip = 3pt plus 2pt minus 1pt 6913 \parskip = 3pt plus 2pt minus 1pt
6081 \textleading = 13.2pt 6914 \textleading = 13.2pt
6082 % 6915 %
6083 % If page is nothing but text, make it come out even. 6916 % If page is nothing but text, make it come out even.
6084 \internalpagesizes{46\baselineskip}{6in}{\voffset}{.25in}{\bindingoffset}{36pt}% 6917 \internalpagesizes{46\baselineskip}{6in}%
6918 {\voffset}{.25in}%
6919 {\bindingoffset}{36pt}%
6920 {11in}{8.5in}%
6085}} 6921}}
6086 6922
6087% Use @smallbook to reset parameters for 7x9.5 (or so) format. 6923% Use @smallbook to reset parameters for 7x9.25 trim size.
6088\def\smallbook{{\globaldefs = 1 6924\def\smallbook{{\globaldefs = 1
6089 \parskip = 2pt plus 1pt 6925 \parskip = 2pt plus 1pt
6090 \textleading = 12pt 6926 \textleading = 12pt
6091 % 6927 %
6092 \internalpagesizes{7.5in}{5.in}{\voffset}{.25in}{\bindingoffset}{16pt}% 6928 \internalpagesizes{7.5in}{5in}%
6929 {\voffset}{.25in}%
6930 {\bindingoffset}{16pt}%
6931 {9.25in}{7in}%
6093 % 6932 %
6094 \lispnarrowing = 0.3in 6933 \lispnarrowing = 0.3in
6095 \tolerance = 700 6934 \tolerance = 700
6096 \hfuzz = 1pt 6935 \hfuzz = 1pt
6097 \contentsrightmargin = 0pt 6936 \contentsrightmargin = 0pt
6098 \deftypemargin = 0pt
6099 \defbodyindent = .5cm 6937 \defbodyindent = .5cm
6100 \smallenvironments 6938}}
6939
6940% Use @smallerbook to reset parameters for 6x9 trim size.
6941% (Just testing, parameters still in flux.)
6942\def\smallerbook{{\globaldefs = 1
6943 \parskip = 1.5pt plus 1pt
6944 \textleading = 12pt
6945 %
6946 \internalpagesizes{7.4in}{4.8in}%
6947 {-.2in}{-.4in}%
6948 {0pt}{14pt}%
6949 {9in}{6in}%
6950 %
6951 \lispnarrowing = 0.25in
6952 \tolerance = 700
6953 \hfuzz = 1pt
6954 \contentsrightmargin = 0pt
6955 \defbodyindent = .4cm
6101}} 6956}}
6102 6957
6103% Use @afourpaper to print on European A4 paper. 6958% Use @afourpaper to print on European A4 paper.
6104\def\afourpaper{{\globaldefs = 1 6959\def\afourpaper{{\globaldefs = 1
6105 \parskip = 3pt plus 2pt minus 1pt 6960 \parskip = 3pt plus 2pt minus 1pt
6106 \textleading = 12pt 6961 \textleading = 13.2pt
6107 % 6962 %
6108 \internalpagesizes{53\baselineskip}{160mm}{\voffset}{4mm}{\bindingoffset}{44pt}% 6963 % Double-side printing via postscript on Laserjet 4050
6964 % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm.
6965 % To change the settings for a different printer or situation, adjust
6966 % \normaloffset until the front-side and back-side texts align. Then
6967 % do the same for \bindingoffset. You can set these for testing in
6968 % your texinfo source file like this:
6969 % @tex
6970 % \global\normaloffset = -6mm
6971 % \global\bindingoffset = 10mm
6972 % @end tex
6973 \internalpagesizes{51\baselineskip}{160mm}
6974 {\voffset}{\hoffset}%
6975 {\bindingoffset}{44pt}%
6976 {297mm}{210mm}%
6109 % 6977 %
6110 \tolerance = 700 6978 \tolerance = 700
6111 \hfuzz = 1pt 6979 \hfuzz = 1pt
6980 \contentsrightmargin = 0pt
6981 \defbodyindent = 5mm
6112}} 6982}}
6113 6983
6114% Use @afivepaper to print on European A5 paper. 6984% Use @afivepaper to print on European A5 paper.
@@ -6118,44 +6988,46 @@ should work if nowhere else does.}
6118 \parskip = 2pt plus 1pt minus 0.1pt 6988 \parskip = 2pt plus 1pt minus 0.1pt
6119 \textleading = 12.5pt 6989 \textleading = 12.5pt
6120 % 6990 %
6121 \internalpagesizes{166mm}{120mm}{\voffset}{-8mm}{\bindingoffset}{8pt}% 6991 \internalpagesizes{160mm}{120mm}%
6992 {\voffset}{\hoffset}%
6993 {\bindingoffset}{8pt}%
6994 {210mm}{148mm}%
6122 % 6995 %
6123 \lispnarrowing = 0.2in 6996 \lispnarrowing = 0.2in
6124 \tolerance = 800 6997 \tolerance = 800
6125 \hfuzz = 1.2pt 6998 \hfuzz = 1.2pt
6126 \contentsrightmargin = 0mm 6999 \contentsrightmargin = 0pt
6127 \deftypemargin = 0pt
6128 \defbodyindent = 2mm 7000 \defbodyindent = 2mm
6129 \tableindent = 12mm 7001 \tableindent = 12mm
6130 %
6131 \smallenvironments
6132}} 7002}}
6133 7003
6134% A specific text layout, 24x15cm overall, intended for A4 paper. Top margin 7004% A specific text layout, 24x15cm overall, intended for A4 paper.
6135% 29mm, hence bottom margin 28mm, nominal side margin 3cm.
6136\def\afourlatex{{\globaldefs = 1 7005\def\afourlatex{{\globaldefs = 1
6137 \textleading = 13.6pt
6138 %
6139 \afourpaper 7006 \afourpaper
6140 \internalpagesizes{237mm}{150mm}{3.6mm}{3.6mm}{3mm}{7mm}% 7007 \internalpagesizes{237mm}{150mm}%
7008 {\voffset}{4.6mm}%
7009 {\bindingoffset}{7mm}%
7010 {297mm}{210mm}%
6141 % 7011 %
6142 % Must explicitly reset to 0 because we call \afourpaper, apparently, 7012 % Must explicitly reset to 0 because we call \afourpaper.
6143 % although this does not entirely make sense.
6144 \globaldefs = 0 7013 \globaldefs = 0
6145}} 7014}}
6146 7015
6147% Use @afourwide to print on European A4 paper in wide format. 7016% Use @afourwide to print on A4 paper in landscape format.
6148\def\afourwide{% 7017\def\afourwide{{\globaldefs = 1
6149 \afourpaper 7018 \afourpaper
6150 \internalpagesizes{6.5in}{9.5in}{\hoffset}{\normaloffset}{\bindingoffset}{7mm}% 7019 \internalpagesizes{241mm}{165mm}%
6151} 7020 {\voffset}{-2.95mm}%
7021 {\bindingoffset}{7mm}%
7022 {297mm}{210mm}%
7023 \globaldefs = 0
7024}}
6152 7025
6153% @pagesizes TEXTHEIGHT[,TEXTWIDTH] 7026% @pagesizes TEXTHEIGHT[,TEXTWIDTH]
6154% Perhaps we should allow setting the margins, \topskip, \parskip, 7027% Perhaps we should allow setting the margins, \topskip, \parskip,
6155% and/or leading, also. Or perhaps we should compute them somehow. 7028% and/or leading, also. Or perhaps we should compute them somehow.
6156% 7029%
6157\def\pagesizes{\parsearg\pagesizesxxx} 7030\parseargdef\pagesizes{\pagesizesyyy #1,,\finish}
6158\def\pagesizesxxx#1{\pagesizesyyy #1,,\finish}
6159\def\pagesizesyyy#1,#2,#3\finish{{% 7031\def\pagesizesyyy#1,#2,#3\finish{{%
6160 \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi 7032 \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi
6161 \globaldefs = 1 7033 \globaldefs = 1
@@ -6163,7 +7035,16 @@ should work if nowhere else does.}
6163 \parskip = 3pt plus 2pt minus 1pt 7035 \parskip = 3pt plus 2pt minus 1pt
6164 \setleading{\textleading}% 7036 \setleading{\textleading}%
6165 % 7037 %
6166 \internalpagesizes{#1}{\hsize}{\voffset}{\normaloffset}{\bindingoffset}{44pt}% 7038 \dimen0 = #1
7039 \advance\dimen0 by \voffset
7040 %
7041 \dimen2 = \hsize
7042 \advance\dimen2 by \normaloffset
7043 %
7044 \internalpagesizes{#1}{\hsize}%
7045 {\voffset}{\normaloffset}%
7046 {\bindingoffset}{44pt}%
7047 {\dimen0}{\dimen2}%
6167}} 7048}}
6168 7049
6169% Set default to letter. 7050% Set default to letter.
@@ -6193,8 +7074,8 @@ should work if nowhere else does.}
6193\def\normalplus{+} 7074\def\normalplus{+}
6194\def\normaldollar{$}%$ font-lock fix 7075\def\normaldollar{$}%$ font-lock fix
6195 7076
6196% This macro is used to make a character print one way in ttfont 7077% This macro is used to make a character print one way in \tt
6197% where it can probably just be output, and another way in other fonts, 7078% (where it can probably be output as-is), and another way in other fonts,
6198% where something hairier probably needs to be done. 7079% where something hairier probably needs to be done.
6199% 7080%
6200% #1 is what to print if we are indeed using \tt; #2 is what to print 7081% #1 is what to print if we are indeed using \tt; #2 is what to print
@@ -6226,8 +7107,9 @@ should work if nowhere else does.}
6226 7107
6227\catcode`\_=\active 7108\catcode`\_=\active
6228\def_{\ifusingtt\normalunderscore\_} 7109\def_{\ifusingtt\normalunderscore\_}
7110\let\realunder=_
6229% Subroutine for the previous macro. 7111% Subroutine for the previous macro.
6230\def\_{\leavevmode \kern.06em \vbox{\hrule width.3em height.1ex}} 7112\def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }
6231 7113
6232\catcode`\|=\active 7114\catcode`\|=\active
6233\def|{{\tt\char124}} 7115\def|{{\tt\char124}}
@@ -6241,15 +7123,6 @@ should work if nowhere else does.}
6241\def+{{\tt \char 43}} 7123\def+{{\tt \char 43}}
6242\catcode`\$=\active 7124\catcode`\$=\active
6243\def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix 7125\def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix
6244%\catcode 27=\active
6245%\def^^[{$\diamondsuit$}
6246
6247% Set up an active definition for =, but don't enable it most of the time.
6248{\catcode`\==\active
6249\global\def={{\tt \char 61}}}
6250
6251\catcode`+=\active
6252\catcode`\_=\active
6253 7126
6254% If a .fmt file is being used, characters that might appear in a file 7127% If a .fmt file is being used, characters that might appear in a file
6255% name cannot be active until we have parsed the command line. 7128% name cannot be active until we have parsed the command line.
@@ -6257,46 +7130,53 @@ should work if nowhere else does.}
6257% \otherifyactive is called near the end of this file. 7130% \otherifyactive is called near the end of this file.
6258\def\otherifyactive{\catcode`+=\other \catcode`\_=\other} 7131\def\otherifyactive{\catcode`+=\other \catcode`\_=\other}
6259 7132
6260\catcode`\@=0 7133% Used sometimes to turn off (effectively) the active characters even after
7134% parsing them.
7135\def\turnoffactive{%
7136 \normalturnoffactive
7137 \otherbackslash
7138}
6261 7139
6262% \rawbackslashxx output one backslash character in current font 7140\catcode`\@=0
6263\global\chardef\rawbackslashxx=`\\
6264%{\catcode`\\=\other
6265%@gdef@rawbackslashxx{\}}
6266 7141
6267% \rawbackslash redefines \ as input to do \rawbackslashxx. 7142% \backslashcurfont outputs one backslash character in current font,
6268{\catcode`\\=\active 7143% as in \char`\\.
6269@gdef@rawbackslash{@let\=@rawbackslashxx }} 7144\global\chardef\backslashcurfont=`\\
7145\global\let\rawbackslashxx=\backslashcurfont % let existing .??s files work
6270 7146
6271% \normalbackslash outputs one backslash in fixed width font. 7147% \realbackslash is an actual character `\' with catcode other, and
6272\def\normalbackslash{{\tt\rawbackslashxx}} 7148% \doublebackslash is two of them (for the pdf outlines).
7149{\catcode`\\=\other @gdef@realbackslash{\} @gdef@doublebackslash{\\}}
6273 7150
6274% \catcode 17=0 % Define control-q 7151% In texinfo, backslash is an active character; it prints the backslash
7152% in fixed width font.
6275\catcode`\\=\active 7153\catcode`\\=\active
6276 7154@def@normalbackslash{{@tt@backslashcurfont}}
6277% Used sometimes to turn off (effectively) the active characters 7155% On startup, @fixbackslash assigns:
6278% even after parsing them. 7156% @let \ = @normalbackslash
6279@def@turnoffactive{@let"=@normaldoublequote 7157
6280@let\=@realbackslash 7158% \rawbackslash defines an active \ to do \backslashcurfont.
6281@let~=@normaltilde 7159% \otherbackslash defines an active \ to be a literal `\' character with
6282@let^=@normalcaret 7160% catcode other.
6283@let_=@normalunderscore 7161@gdef@rawbackslash{@let\=@backslashcurfont}
6284@let|=@normalverticalbar 7162@gdef@otherbackslash{@let\=@realbackslash}
6285@let<=@normalless 7163
6286@let>=@normalgreater 7164% Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
6287@let+=@normalplus 7165% the literal character `\'.
6288@let$=@normaldollar}%$ font-lock fix 7166%
6289 7167@def@normalturnoffactive{%
6290@def@normalturnoffactive{@let"=@normaldoublequote 7168 @let\=@normalbackslash
6291@let\=@normalbackslash 7169 @let"=@normaldoublequote
6292@let~=@normaltilde 7170 @let~=@normaltilde
6293@let^=@normalcaret 7171 @let^=@normalcaret
6294@let_=@normalunderscore 7172 @let_=@normalunderscore
6295@let|=@normalverticalbar 7173 @let|=@normalverticalbar
6296@let<=@normalless 7174 @let<=@normalless
6297@let>=@normalgreater 7175 @let>=@normalgreater
6298@let+=@normalplus 7176 @let+=@normalplus
6299@let$=@normaldollar}%$ font-lock fix 7177 @let$=@normaldollar %$ font-lock fix
7178 @unsepspaces
7179}
6300 7180
6301% Make _ and + \other characters, temporarily. 7181% Make _ and + \other characters, temporarily.
6302% This is canceled by @fixbackslash. 7182% This is canceled by @fixbackslash.
@@ -6310,9 +7190,9 @@ should work if nowhere else does.}
6310@global@let\ = @eatinput 7190@global@let\ = @eatinput
6311 7191
6312% On the other hand, perhaps the file did not have a `\input texinfo'. Then 7192% On the other hand, perhaps the file did not have a `\input texinfo'. Then
6313% the first `\{ in the file would cause an error. This macro tries to fix 7193% the first `\' in the file would cause an error. This macro tries to fix
6314% that, assuming it is called before the first `\' could plausibly occur. 7194% that, assuming it is called before the first `\' could plausibly occur.
6315% Also back turn on active characters that might appear in the input 7195% Also turn back on active characters that might appear in the input
6316% file name, in case not using a pre-dumped format. 7196% file name, in case not using a pre-dumped format.
6317% 7197%
6318@gdef@fixbackslash{% 7198@gdef@fixbackslash{%
@@ -6329,10 +7209,6 @@ should work if nowhere else does.}
6329@catcode`@# = @other 7209@catcode`@# = @other
6330@catcode`@% = @other 7210@catcode`@% = @other
6331 7211
6332@c Set initial fonts.
6333@textfonts
6334@rm
6335
6336 7212
6337@c Local variables: 7213@c Local variables:
6338@c eval: (add-hook 'write-file-hooks 'time-stamp) 7214@c eval: (add-hook 'write-file-hooks 'time-stamp)
@@ -6342,6 +7218,8 @@ should work if nowhere else does.}
6342@c time-stamp-end: "}" 7218@c time-stamp-end: "}"
6343@c End: 7219@c End:
6344 7220
7221@c vim:sw=2:
7222
6345@ignore 7223@ignore
6346 arch-tag: e1b36e32-c96e-4135-a41a-0b2efa2ea115 7224 arch-tag: e1b36e32-c96e-4135-a41a-0b2efa2ea115
6347@end ignore 7225@end ignore