~ubuntu-branches/ubuntu/hardy/gengetopt/hardy

« back to all changes in this revision

Viewing changes to doc/texinfo.tex

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2008-01-29 14:55:40 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080129145540-bkah1bl330gpelmh
Tags: 2.22-1ubuntu1
* Merge with Debian; remaining changes:
  - Fix build failures with g++-4.3.

Show diffs side-by-side

added added

removed removed

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