~ubuntu-branches/ubuntu/quantal/gclcvs/quantal

« back to all changes in this revision

Viewing changes to gmp3/texinfo.tex

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2004-06-24 15:13:46 UTC
  • Revision ID: james.westby@ubuntu.com-20040624151346-xh0xaaktyyp7aorc
Tags: 2.7.0-26
C_GC_OFFSET is 2 on m68k-linux

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
% texinfo.tex -- TeX macros to handle Texinfo files.
 
2
%
 
3
% Load plain if necessary, i.e., if running under initex.
 
4
\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
 
5
%
 
6
\def\texinfoversion{2000-11-09.08}
 
7
%
 
8
% Copyright (C) 1985, 86, 88, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
 
9
% Free Software Foundation, Inc.
 
10
%
 
11
% This texinfo.tex file is free software; you can redistribute it and/or
 
12
% modify it under the terms of the GNU General Public License as
 
13
% published by the Free Software Foundation; either version 2, or (at
 
14
% your option) any later version.
 
15
%
 
16
% This texinfo.tex file is distributed in the hope that it will be
 
17
% useful, but WITHOUT ANY WARRANTY; without even the implied warranty
 
18
% of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
19
% General Public License for more details.
 
20
%
 
21
% You should have received a copy of the GNU General Public License
 
22
% 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.
 
25
%
 
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!
 
29
%
 
30
% Please try the latest version of texinfo.tex before submitting bug
 
31
% 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/tex/texinfo.tex
 
35
%   ftp://us.ctan.org/macros/texinfo/texinfo.tex
 
36
%   (and all CTAN mirrors, finger ctan@us.ctan.org for a list).
 
37
%   /home/gd/gnu/doc/texinfo.tex on the GNU machines.
 
38
% The texinfo.tex in any given Texinfo distribution could well be out
 
39
% of date, so if that's what you're using, please check.
 
40
% Texinfo has a small home page at http://texinfo.org/.
 
41
%
 
42
% Send bug reports to bug-texinfo@gnu.org.  Please include including a
 
43
% complete document in each bug report with which we can reproduce the
 
44
% problem.  Patches are, of course, greatly appreciated.
 
45
%
 
46
% To process a Texinfo manual with TeX, it's most reliable to use the
 
47
% texi2dvi shell script that comes with the distribution.  For a simple
 
48
% manual foo.texi, however, you can get away with this:
 
49
%   tex foo.texi
 
50
%   texindex foo.??
 
51
%   tex foo.texi
 
52
%   tex foo.texi
 
53
%   dvips foo.dvi -o # or whatever, to process the dvi file; this makes foo.ps.
 
54
% The extra runs of TeX get the cross-reference information correct.
 
55
% Sometimes one run after texindex suffices, and sometimes you need more
 
56
% than two; texi2dvi does it as many times as necessary.
 
57
%
 
58
% It is possible to adapt texinfo.tex for other languages.  You can get
 
59
% the existing language-specific files from ftp://ftp.gnu.org/gnu/texinfo/.
 
60
 
 
61
\message{Loading texinfo [version \texinfoversion]:}
 
62
 
 
63
% If in a .fmt file, print the version number
 
64
% and turn on active characters that we couldn't do earlier because
 
65
% they might have appeared in the input file name.
 
66
\everyjob{\message{[Texinfo version \texinfoversion]}%
 
67
  \catcode`+=\active \catcode`\_=\active}
 
68
 
 
69
% Save some parts of plain tex whose names we will redefine.
 
70
\let\ptexb=\b
 
71
\let\ptexbullet=\bullet
 
72
\let\ptexc=\c
 
73
\let\ptexcomma=\,
 
74
\let\ptexdot=\.
 
75
\let\ptexdots=\dots
 
76
\let\ptexend=\end
 
77
\let\ptexequiv=\equiv
 
78
\let\ptexexclam=\!
 
79
\let\ptexi=\i
 
80
\let\ptexlbrace=\{
 
81
\let\ptexrbrace=\}
 
82
\let\ptexstar=\*
 
83
\let\ptext=\t
 
84
 
 
85
% We never want plain's outer \+ definition in Texinfo.
 
86
% For @tex, we can use \tabalign.
 
87
\let\+ = \relax
 
88
 
 
89
\message{Basics,}
 
90
\chardef\other=12
 
91
 
 
92
% If this character appears in an error message or help string, it
 
93
% starts a new line in the output.
 
94
\newlinechar = `^^J
 
95
 
 
96
% Set up fixed words for English if not already set.
 
97
\ifx\putwordAppendix\undefined  \gdef\putwordAppendix{Appendix}\fi
 
98
\ifx\putwordChapter\undefined   \gdef\putwordChapter{Chapter}\fi
 
99
\ifx\putwordfile\undefined      \gdef\putwordfile{file}\fi
 
100
\ifx\putwordin\undefined        \gdef\putwordin{in}\fi
 
101
\ifx\putwordIndexIsEmpty\undefined     \gdef\putwordIndexIsEmpty{(Index is empty)}\fi
 
102
\ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi
 
103
\ifx\putwordInfo\undefined      \gdef\putwordInfo{Info}\fi
 
104
\ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi
 
105
\ifx\putwordMethodon\undefined  \gdef\putwordMethodon{Method on}\fi
 
106
\ifx\putwordNoTitle\undefined   \gdef\putwordNoTitle{No Title}\fi
 
107
\ifx\putwordof\undefined        \gdef\putwordof{of}\fi
 
108
\ifx\putwordon\undefined        \gdef\putwordon{on}\fi
 
109
\ifx\putwordpage\undefined      \gdef\putwordpage{page}\fi
 
110
\ifx\putwordsection\undefined   \gdef\putwordsection{section}\fi
 
111
\ifx\putwordSection\undefined   \gdef\putwordSection{Section}\fi
 
112
\ifx\putwordsee\undefined       \gdef\putwordsee{see}\fi
 
113
\ifx\putwordSee\undefined       \gdef\putwordSee{See}\fi
 
114
\ifx\putwordShortTOC\undefined  \gdef\putwordShortTOC{Short Contents}\fi
 
115
\ifx\putwordTOC\undefined       \gdef\putwordTOC{Table of Contents}\fi
 
116
%
 
117
\ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi
 
118
\ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi
 
119
\ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi
 
120
\ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi
 
121
\ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi
 
122
\ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi
 
123
\ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi
 
124
\ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi
 
125
\ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi
 
126
\ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi
 
127
\ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi
 
128
\ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi
 
129
%
 
130
\ifx\putwordDefmac\undefined    \gdef\putwordDefmac{Macro}\fi
 
131
\ifx\putwordDefspec\undefined   \gdef\putwordDefspec{Special Form}\fi
 
132
\ifx\putwordDefvar\undefined    \gdef\putwordDefvar{Variable}\fi
 
133
\ifx\putwordDefopt\undefined    \gdef\putwordDefopt{User Option}\fi
 
134
\ifx\putwordDeftypevar\undefined\gdef\putwordDeftypevar{Variable}\fi
 
135
\ifx\putwordDeffunc\undefined   \gdef\putwordDeffunc{Function}\fi
 
136
\ifx\putwordDeftypefun\undefined\gdef\putwordDeftypefun{Function}\fi
 
137
 
 
138
% Ignore a token.
 
139
%
 
140
\def\gobble#1{}
 
141
 
 
142
\hyphenation{ap-pen-dix}
 
143
\hyphenation{mini-buf-fer mini-buf-fers}
 
144
\hyphenation{eshell}
 
145
\hyphenation{white-space}
 
146
 
 
147
% Margin to add to right of even pages, to left of odd pages.
 
148
\newdimen \bindingoffset
 
149
\newdimen \normaloffset
 
150
\newdimen\pagewidth \newdimen\pageheight
 
151
 
 
152
% Sometimes it is convenient to have everything in the transcript file
 
153
% and nothing on the terminal.  We don't just call \tracingall here,
 
154
% since that produces some useless output on the terminal.
 
155
%
 
156
\def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
 
157
\ifx\eTeXversion\undefined
 
158
\def\loggingall{\tracingcommands2 \tracingstats2
 
159
   \tracingpages1 \tracingoutput1 \tracinglostchars1
 
160
   \tracingmacros2 \tracingparagraphs1 \tracingrestores1
 
161
   \showboxbreadth\maxdimen\showboxdepth\maxdimen
 
162
}%
 
163
\else
 
164
\def\loggingall{\tracingcommands3 \tracingstats2
 
165
   \tracingpages1 \tracingoutput1 \tracinglostchars1
 
166
   \tracingmacros2 \tracingparagraphs1 \tracingrestores1
 
167
   \tracingscantokens1 \tracingassigns1 \tracingifs1
 
168
   \tracinggroups1 \tracingnesting2
 
169
   \showboxbreadth\maxdimen\showboxdepth\maxdimen
 
170
}%
 
171
\fi
 
172
 
 
173
% For @cropmarks command.
 
174
% Do @cropmarks to get crop marks.
 
175
%
 
176
\newif\ifcropmarks
 
177
\let\cropmarks = \cropmarkstrue
 
178
%
 
179
% Dimensions to add cropmarks at corners.
 
180
% Added by P. A. MacKay, 12 Nov. 1986
 
181
%
 
182
\newdimen\outerhsize \newdimen\outervsize % set by the paper size routines
 
183
\newdimen\cornerlong  \cornerlong=1pc
 
184
\newdimen\cornerthick \cornerthick=.3pt
 
185
\newdimen\topandbottommargin \topandbottommargin=.75in
 
186
 
 
187
% Main output routine.
 
188
\chardef\PAGE = 255
 
189
\output = {\onepageout{\pagecontents\PAGE}}
 
190
 
 
191
\newbox\headlinebox
 
192
\newbox\footlinebox
 
193
 
 
194
% \onepageout takes a vbox as an argument.  Note that \pagecontents
 
195
% does insertions, but you have to call it yourself.
 
196
\def\onepageout#1{%
 
197
  \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi
 
198
  %
 
199
  \ifodd\pageno  \advance\hoffset by \bindingoffset
 
200
  \else \advance\hoffset by -\bindingoffset\fi
 
201
  %
 
202
  % Do this outside of the \shipout so @code etc. will be expanded in
 
203
  % the headline as they should be, not taken literally (outputting ''code).
 
204
  \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}%
 
205
  \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}%
 
206
  %
 
207
  {%
 
208
    % Have to do this stuff outside the \shipout because we want it to
 
209
    % take effect in \write's, yet the group defined by the \vbox ends
 
210
    % before the \shipout runs.
 
211
    %
 
212
    \escapechar = `\\     % use backslash in output files.
 
213
    \indexdummies         % don't expand commands in the output.
 
214
    \normalturnoffactive  % \ in index entries must not stay \, e.g., if
 
215
                   % the page break happens to be in the middle of an example.
 
216
    \shipout\vbox{%
 
217
      % Do this early so pdf references go to the beginning of the page.
 
218
      \ifpdfmakepagedest \pdfmkdest{\the\pageno} \fi
 
219
      %
 
220
      \ifcropmarks \vbox to \outervsize\bgroup
 
221
        \hsize = \outerhsize
 
222
        \vskip-\topandbottommargin
 
223
        \vtop to0pt{%
 
224
          \line{\ewtop\hfil\ewtop}%
 
225
          \nointerlineskip
 
226
          \line{%
 
227
            \vbox{\moveleft\cornerthick\nstop}%
 
228
            \hfill
 
229
            \vbox{\moveright\cornerthick\nstop}%
 
230
          }%
 
231
          \vss}%
 
232
        \vskip\topandbottommargin
 
233
        \line\bgroup
 
234
          \hfil % center the page within the outer (page) hsize.
 
235
          \ifodd\pageno\hskip\bindingoffset\fi
 
236
          \vbox\bgroup
 
237
      \fi
 
238
      %
 
239
      \unvbox\headlinebox
 
240
      \pagebody{#1}%
 
241
      \ifdim\ht\footlinebox > 0pt
 
242
        % Only leave this space if the footline is nonempty.
 
243
        % (We lessened \vsize for it in \oddfootingxxx.)
 
244
        % The \baselineskip=24pt in plain's \makefootline has no effect.
 
245
        \vskip 2\baselineskip
 
246
        \unvbox\footlinebox
 
247
      \fi
 
248
      %
 
249
      \ifcropmarks
 
250
          \egroup % end of \vbox\bgroup
 
251
        \hfil\egroup % end of (centering) \line\bgroup
 
252
        \vskip\topandbottommargin plus1fill minus1fill
 
253
        \boxmaxdepth = \cornerthick
 
254
        \vbox to0pt{\vss
 
255
          \line{%
 
256
            \vbox{\moveleft\cornerthick\nsbot}%
 
257
            \hfill
 
258
            \vbox{\moveright\cornerthick\nsbot}%
 
259
          }%
 
260
          \nointerlineskip
 
261
          \line{\ewbot\hfil\ewbot}%
 
262
        }%
 
263
      \egroup % \vbox from first cropmarks clause
 
264
      \fi
 
265
    }% end of \shipout\vbox
 
266
  }% end of group with \turnoffactive
 
267
  \advancepageno
 
268
  \ifnum\outputpenalty>-20000 \else\dosupereject\fi
 
269
}
 
270
 
 
271
\newinsert\margin \dimen\margin=\maxdimen
 
272
 
 
273
\def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
 
274
{\catcode`\@ =11
 
275
\gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
 
276
% marginal hacks, juha@viisa.uucp (Juha Takala)
 
277
\ifvoid\margin\else % marginal info is present
 
278
  \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi
 
279
\dimen@=\dp#1 \unvbox#1
 
280
\ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
 
281
\ifr@ggedbottom \kern-\dimen@ \vfil \fi}
 
282
}
 
283
 
 
284
% Here are the rules for the cropmarks.  Note that they are
 
285
% offset so that the space between them is truly \outerhsize or \outervsize
 
286
% (P. A. MacKay, 12 November, 1986)
 
287
%
 
288
\def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
 
289
\def\nstop{\vbox
 
290
  {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
 
291
\def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
 
292
\def\nsbot{\vbox
 
293
  {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
 
294
 
 
295
% Parse an argument, then pass it to #1.  The argument is the rest of
 
296
% the input line (except we remove a trailing comment).  #1 should be a
 
297
% macro which expects an ordinary undelimited TeX argument.
 
298
%
 
299
\def\parsearg#1{%
 
300
  \let\next = #1%
 
301
  \begingroup
 
302
    \obeylines
 
303
    \futurelet\temp\parseargx
 
304
}
 
305
 
 
306
% If the next token is an obeyed space (from an @example environment or
 
307
% the like), remove it and recurse.  Otherwise, we're done.
 
308
\def\parseargx{%
 
309
  % \obeyedspace is defined far below, after the definition of \sepspaces.
 
310
  \ifx\obeyedspace\temp
 
311
    \expandafter\parseargdiscardspace
 
312
  \else
 
313
    \expandafter\parseargline
 
314
  \fi
 
315
}
 
316
 
 
317
% Remove a single space (as the delimiter token to the macro call).
 
318
{\obeyspaces %
 
319
 \gdef\parseargdiscardspace {\futurelet\temp\parseargx}}
 
320
 
 
321
{\obeylines %
 
322
  \gdef\parseargline#1^^M{%
 
323
    \endgroup % End of the group started in \parsearg.
 
324
    %
 
325
    % First remove any @c comment, then any @comment.
 
326
    % Result of each macro is put in \toks0.
 
327
    \argremovec #1\c\relax %
 
328
    \expandafter\argremovecomment \the\toks0 \comment\relax %
 
329
    %
 
330
    % Call the caller's macro, saved as \next in \parsearg.
 
331
    \expandafter\next\expandafter{\the\toks0}%
 
332
  }%
 
333
}
 
334
 
 
335
% Since all \c{,omment} does is throw away the argument, we can let TeX
 
336
% do that for us.  The \relax here is matched by the \relax in the call
 
337
% in \parseargline; it could be more or less anything, its purpose is
 
338
% just to delimit the argument to the \c.
 
339
\def\argremovec#1\c#2\relax{\toks0 = {#1}}
 
340
\def\argremovecomment#1\comment#2\relax{\toks0 = {#1}}
 
341
 
 
342
% \argremovec{,omment} might leave us with trailing spaces, though; e.g.,
 
343
%    @end itemize  @c foo
 
344
% will have two active spaces as part of the argument with the
 
345
% `itemize'.  Here we remove all active spaces from #1, and assign the
 
346
% result to \toks0.
 
347
%
 
348
% This loses if there are any *other* active characters besides spaces
 
349
% in the argument -- _ ^ +, for example -- since they get expanded.
 
350
% Fortunately, Texinfo does not define any such commands.  (If it ever
 
351
% does, the catcode of the characters in questionwill have to be changed
 
352
% here.)  But this means we cannot call \removeactivespaces as part of
 
353
% \argremovec{,omment}, since @c uses \parsearg, and thus the argument
 
354
% that \parsearg gets might well have any character at all in it.
 
355
%
 
356
\def\removeactivespaces#1{%
 
357
  \begingroup
 
358
    \ignoreactivespaces
 
359
    \edef\temp{#1}%
 
360
    \global\toks0 = \expandafter{\temp}%
 
361
  \endgroup
 
362
}
 
363
 
 
364
% Change the active space to expand to nothing.
 
365
%
 
366
\begingroup
 
367
  \obeyspaces
 
368
  \gdef\ignoreactivespaces{\obeyspaces\let =\empty}
 
369
\endgroup
 
370
 
 
371
 
 
372
\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
 
373
 
 
374
%% These are used to keep @begin/@end levels from running away
 
375
%% Call \inENV within environments (after a \begingroup)
 
376
\newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi}
 
377
\def\ENVcheck{%
 
378
\ifENV\errmessage{Still within an environment; press RETURN to continue}
 
379
\endgroup\fi} % This is not perfect, but it should reduce lossage
 
380
 
 
381
% @begin foo  is the same as @foo, for now.
 
382
\newhelp\EMsimple{Press RETURN to continue.}
 
383
 
 
384
\outer\def\begin{\parsearg\beginxxx}
 
385
 
 
386
\def\beginxxx #1{%
 
387
\expandafter\ifx\csname #1\endcsname\relax
 
388
{\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else
 
389
\csname #1\endcsname\fi}
 
390
 
 
391
% @end foo executes the definition of \Efoo.
 
392
%
 
393
\def\end{\parsearg\endxxx}
 
394
\def\endxxx #1{%
 
395
  \removeactivespaces{#1}%
 
396
  \edef\endthing{\the\toks0}%
 
397
  %
 
398
  \expandafter\ifx\csname E\endthing\endcsname\relax
 
399
    \expandafter\ifx\csname \endthing\endcsname\relax
 
400
      % There's no \foo, i.e., no ``environment'' foo.
 
401
      \errhelp = \EMsimple
 
402
      \errmessage{Undefined command `@end \endthing'}%
 
403
    \else
 
404
      \unmatchedenderror\endthing
 
405
    \fi
 
406
  \else
 
407
    % Everything's ok; the right environment has been started.
 
408
    \csname E\endthing\endcsname
 
409
  \fi
 
410
}
 
411
 
 
412
% There is an environment #1, but it hasn't been started.  Give an error.
 
413
%
 
414
\def\unmatchedenderror#1{%
 
415
  \errhelp = \EMsimple
 
416
  \errmessage{This `@end #1' doesn't have a matching `@#1'}%
 
417
}
 
418
 
 
419
% Define the control sequence \E#1 to give an unmatched @end error.
 
420
%
 
421
\def\defineunmatchedend#1{%
 
422
  \expandafter\def\csname E#1\endcsname{\unmatchedenderror{#1}}%
 
423
}
 
424
 
 
425
 
 
426
% Single-spacing is done by various environments (specifically, in
 
427
% \nonfillstart and \quotations).
 
428
\newskip\singlespaceskip \singlespaceskip = 12.5pt
 
429
\def\singlespace{%
 
430
  % Why was this kern here?  It messes up equalizing space above and below
 
431
  % environments.  --karl, 6may93
 
432
  %{\advance \baselineskip by -\singlespaceskip
 
433
  %\kern \baselineskip}%
 
434
  \setleading \singlespaceskip
 
435
}
 
436
 
 
437
%% Simple single-character @ commands
 
438
 
 
439
% @@ prints an @
 
440
% Kludge this until the fonts are right (grr).
 
441
\def\@{{\tt\char64}}
 
442
 
 
443
% This is turned off because it was never documented
 
444
% and you can use @w{...} around a quote to suppress ligatures.
 
445
%% Define @` and @' to be the same as ` and '
 
446
%% but suppressing ligatures.
 
447
%\def\`{{`}}
 
448
%\def\'{{'}}
 
449
 
 
450
% Used to generate quoted braces.
 
451
\def\mylbrace {{\tt\char123}}
 
452
\def\myrbrace {{\tt\char125}}
 
453
\let\{=\mylbrace
 
454
\let\}=\myrbrace
 
455
\begingroup
 
456
  % Definitions to produce actual \{ & \} command in an index.
 
457
  \catcode`\{ = 12 \catcode`\} = 12
 
458
  \catcode`\[ = 1 \catcode`\] = 2
 
459
  \catcode`\@ = 0 \catcode`\\ = 12
 
460
  @gdef@lbracecmd[\{]%
 
461
  @gdef@rbracecmd[\}]%
 
462
@endgroup
 
463
 
 
464
% Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
 
465
% Others are defined by plain TeX: @` @' @" @^ @~ @= @v @H.
 
466
\let\, = \c
 
467
\let\dotaccent = \.
 
468
\def\ringaccent#1{{\accent23 #1}}
 
469
\let\tieaccent = \t
 
470
\let\ubaraccent = \b
 
471
\let\udotaccent = \d
 
472
 
 
473
% Other special characters: @questiondown @exclamdown
 
474
% Plain TeX defines: @AA @AE @O @OE @L (and lowercase versions) @ss.
 
475
\def\questiondown{?`}
 
476
\def\exclamdown{!`}
 
477
 
 
478
% Dotless i and dotless j, used for accents.
 
479
\def\imacro{i}
 
480
\def\jmacro{j}
 
481
\def\dotless#1{%
 
482
  \def\temp{#1}%
 
483
  \ifx\temp\imacro \ptexi
 
484
  \else\ifx\temp\jmacro \j
 
485
  \else \errmessage{@dotless can be used only with i or j}%
 
486
  \fi\fi
 
487
}
 
488
 
 
489
% Be sure we're in horizontal mode when doing a tie, since we make space
 
490
% equivalent to this in @example-like environments. Otherwise, a space
 
491
% at the beginning of a line will start with \penalty -- and
 
492
% since \penalty is valid in vertical mode, we'd end up putting the
 
493
% penalty on the vertical list instead of in the new paragraph.
 
494
{\catcode`@ = 11
 
495
 % Avoid using \@M directly, because that causes trouble
 
496
 % if the definition is written into an index file.
 
497
 \global\let\tiepenalty = \@M
 
498
 \gdef\tie{\leavevmode\penalty\tiepenalty\ }
 
499
}
 
500
 
 
501
% @: forces normal size whitespace following.
 
502
\def\:{\spacefactor=1000 }
 
503
 
 
504
% @* forces a line break.
 
505
\def\*{\hfil\break\hbox{}\ignorespaces}
 
506
 
 
507
% @. is an end-of-sentence period.
 
508
\def\.{.\spacefactor=3000 }
 
509
 
 
510
% @! is an end-of-sentence bang.
 
511
\def\!{!\spacefactor=3000 }
 
512
 
 
513
% @? is an end-of-sentence query.
 
514
\def\?{?\spacefactor=3000 }
 
515
 
 
516
% @w prevents a word break.  Without the \leavevmode, @w at the
 
517
% beginning of a paragraph, when TeX is still in vertical mode, would
 
518
% produce a whole line of output instead of starting the paragraph.
 
519
\def\w#1{\leavevmode\hbox{#1}}
 
520
 
 
521
% @group ... @end group forces ... to be all on one page, by enclosing
 
522
% it in a TeX vbox.  We use \vtop instead of \vbox to construct the box
 
523
% to keep its height that of a normal line.  According to the rules for
 
524
% \topskip (p.114 of the TeXbook), the glue inserted is
 
525
% max (\topskip - \ht (first item), 0).  If that height is large,
 
526
% therefore, no glue is inserted, and the space between the headline and
 
527
% the text is small, which looks bad.
 
528
%
 
529
\def\group{\begingroup
 
530
  \ifnum\catcode13=\active \else
 
531
    \errhelp = \groupinvalidhelp
 
532
    \errmessage{@group invalid in context where filling is enabled}%
 
533
  \fi
 
534
  %
 
535
  % The \vtop we start below produces a box with normal height and large
 
536
  % depth; thus, TeX puts \baselineskip glue before it, and (when the
 
537
  % next line of text is done) \lineskip glue after it.  (See p.82 of
 
538
  % the TeXbook.)  Thus, space below is not quite equal to space
 
539
  % above.  But it's pretty close.
 
540
  \def\Egroup{%
 
541
    \egroup           % End the \vtop.
 
542
    \endgroup         % End the \group.
 
543
  }%
 
544
  %
 
545
  \vtop\bgroup
 
546
    % We have to put a strut on the last line in case the @group is in
 
547
    % the midst of an example, rather than completely enclosing it.
 
548
    % Otherwise, the interline space between the last line of the group
 
549
    % and the first line afterwards is too small.  But we can't put the
 
550
    % strut in \Egroup, since there it would be on a line by itself.
 
551
    % Hence this just inserts a strut at the beginning of each line.
 
552
    \everypar = {\strut}%
 
553
    %
 
554
    % Since we have a strut on every line, we don't need any of TeX's
 
555
    % normal interline spacing.
 
556
    \offinterlineskip
 
557
    %
 
558
    % OK, but now we have to do something about blank
 
559
    % lines in the input in @example-like environments, which normally
 
560
    % just turn into \lisppar, which will insert no space now that we've
 
561
    % turned off the interline space.  Simplest is to make them be an
 
562
    % empty paragraph.
 
563
    \ifx\par\lisppar
 
564
      \edef\par{\leavevmode \par}%
 
565
      %
 
566
      % Reset ^^M's definition to new definition of \par.
 
567
      \obeylines
 
568
    \fi
 
569
    %
 
570
    % Do @comment since we are called inside an environment such as
 
571
    % @example, where each end-of-line in the input causes an
 
572
    % end-of-line in the output.  We don't want the end-of-line after
 
573
    % the `@group' to put extra space in the output.  Since @group
 
574
    % should appear on a line by itself (according to the Texinfo
 
575
    % manual), we don't worry about eating any user text.
 
576
    \comment
 
577
}
 
578
%
 
579
% TeX puts in an \escapechar (i.e., `@') at the beginning of the help
 
580
% message, so this ends up printing `@group can only ...'.
 
581
%
 
582
\newhelp\groupinvalidhelp{%
 
583
group can only be used in environments such as @example,^^J%
 
584
where each line of input produces a line of output.}
 
585
 
 
586
% @need space-in-mils
 
587
% forces a page break if there is not space-in-mils remaining.
 
588
 
 
589
\newdimen\mil  \mil=0.001in
 
590
 
 
591
\def\need{\parsearg\needx}
 
592
 
 
593
% Old definition--didn't work.
 
594
%\def\needx #1{\par %
 
595
%% This method tries to make TeX break the page naturally
 
596
%% if the depth of the box does not fit.
 
597
%{\baselineskip=0pt%
 
598
%\vtop to #1\mil{\vfil}\kern -#1\mil\nobreak
 
599
%\prevdepth=-1000pt
 
600
%}}
 
601
 
 
602
\def\needx#1{%
 
603
  % Ensure vertical mode, so we don't make a big box in the middle of a
 
604
  % paragraph.
 
605
  \par
 
606
  %
 
607
  % If the @need value is less than one line space, it's useless.
 
608
  \dimen0 = #1\mil
 
609
  \dimen2 = \ht\strutbox
 
610
  \advance\dimen2 by \dp\strutbox
 
611
  \ifdim\dimen0 > \dimen2
 
612
    %
 
613
    % Do a \strut just to make the height of this box be normal, so the
 
614
    % normal leading is inserted relative to the preceding line.
 
615
    % And a page break here is fine.
 
616
    \vtop to #1\mil{\strut\vfil}%
 
617
    %
 
618
    % TeX does not even consider page breaks if a penalty added to the
 
619
    % main vertical list is 10000 or more.  But in order to see if the
 
620
    % empty box we just added fits on the page, we must make it consider
 
621
    % page breaks.  On the other hand, we don't want to actually break the
 
622
    % page after the empty box.  So we use a penalty of 9999.
 
623
    %
 
624
    % There is an extremely small chance that TeX will actually break the
 
625
    % page at this \penalty, if there are no other feasible breakpoints in
 
626
    % sight.  (If the user is using lots of big @group commands, which
 
627
    % almost-but-not-quite fill up a page, TeX will have a hard time doing
 
628
    % good page breaking, for example.)  However, I could not construct an
 
629
    % example where a page broke at this \penalty; if it happens in a real
 
630
    % document, then we can reconsider our strategy.
 
631
    \penalty9999
 
632
    %
 
633
    % Back up by the size of the box, whether we did a page break or not.
 
634
    \kern -#1\mil
 
635
    %
 
636
    % Do not allow a page break right after this kern.
 
637
    \nobreak
 
638
  \fi
 
639
}
 
640
 
 
641
% @br   forces paragraph break
 
642
 
 
643
\let\br = \par
 
644
 
 
645
% @dots{} output an ellipsis using the current font.
 
646
% We do .5em per period so that it has the same spacing in a typewriter
 
647
% font as three actual period characters.
 
648
%
 
649
\def\dots{%
 
650
  \leavevmode
 
651
  \hbox to 1.5em{%
 
652
    \hskip 0pt plus 0.25fil minus 0.25fil
 
653
    .\hss.\hss.%
 
654
    \hskip 0pt plus 0.5fil minus 0.5fil
 
655
  }%
 
656
}
 
657
 
 
658
% @enddots{} is an end-of-sentence ellipsis.
 
659
%
 
660
\def\enddots{%
 
661
  \leavevmode
 
662
  \hbox to 2em{%
 
663
    \hskip 0pt plus 0.25fil minus 0.25fil
 
664
    .\hss.\hss.\hss.%
 
665
    \hskip 0pt plus 0.5fil minus 0.5fil
 
666
  }%
 
667
  \spacefactor=3000
 
668
}
 
669
 
 
670
 
 
671
% @page    forces the start of a new page
 
672
%
 
673
\def\page{\par\vfill\supereject}
 
674
 
 
675
% @exdent text....
 
676
% outputs text on separate line in roman font, starting at standard page margin
 
677
 
 
678
% This records the amount of indent in the innermost environment.
 
679
% That's how much \exdent should take out.
 
680
\newskip\exdentamount
 
681
 
 
682
% This defn is used inside fill environments such as @defun.
 
683
\def\exdent{\parsearg\exdentyyy}
 
684
\def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}}
 
685
 
 
686
% This defn is used inside nofill environments such as @example.
 
687
\def\nofillexdent{\parsearg\nofillexdentyyy}
 
688
\def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount
 
689
\leftline{\hskip\leftskip{\rm#1}}}}
 
690
 
 
691
% @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current
 
692
% paragraph.  For more general purposes, use the \margin insertion
 
693
% class.  WHICH is `l' or `r'.
 
694
%
 
695
\newskip\inmarginspacing \inmarginspacing=1cm
 
696
\def\strutdepth{\dp\strutbox}
 
697
%
 
698
\def\doinmargin#1#2{\strut\vadjust{%
 
699
  \nobreak
 
700
  \kern-\strutdepth
 
701
  \vtop to \strutdepth{%
 
702
    \baselineskip=\strutdepth
 
703
    \vss
 
704
    % if you have multiple lines of stuff to put here, you'll need to
 
705
    % make the vbox yourself of the appropriate size.
 
706
    \ifx#1l%
 
707
      \llap{#2\hskip\inmarginspacing}%
 
708
    \else
 
709
      \rlap{\hskip\hsize\hskip\inmarginspacing#2}%
 
710
    \fi
 
711
    \null
 
712
  }%
 
713
}}
 
714
\def\inleftmargin{\doinmargin l}
 
715
\def\inrightmargin{\doinmargin r}
 
716
\def\inmargin{% not perfect, but better than nothing.
 
717
  \ifodd\pageno
 
718
    \let\temp=\inleftmargin
 
719
  \else
 
720
    \let\temp=\inrightmargin
 
721
  \fi
 
722
  \temp
 
723
}
 
724
 
 
725
% @include file    insert text of that file as input.
 
726
% Allow normal characters that  we make active in the argument (a file name).
 
727
\def\include{\begingroup
 
728
  \catcode`\\=12
 
729
  \catcode`~=12
 
730
  \catcode`^=12
 
731
  \catcode`_=12
 
732
  \catcode`|=12
 
733
  \catcode`<=12
 
734
  \catcode`>=12
 
735
  \catcode`+=12
 
736
  \parsearg\includezzz}
 
737
% Restore active chars for included file.
 
738
\def\includezzz#1{\endgroup\begingroup
 
739
  % Read the included file in a group so nested @include's work.
 
740
  \def\thisfile{#1}%
 
741
  \input\thisfile
 
742
\endgroup}
 
743
 
 
744
\def\thisfile{}
 
745
 
 
746
% @center line   outputs that line, centered
 
747
 
 
748
\def\center{\parsearg\centerzzz}
 
749
\def\centerzzz #1{{\advance\hsize by -\leftskip
 
750
\advance\hsize by -\rightskip
 
751
\centerline{#1}}}
 
752
 
 
753
% @sp n   outputs n lines of vertical space
 
754
 
 
755
\def\sp{\parsearg\spxxx}
 
756
\def\spxxx #1{\vskip #1\baselineskip}
 
757
 
 
758
% @comment ...line which is ignored...
 
759
% @c is the same as @comment
 
760
% @ignore ... @end ignore  is another way to write a comment
 
761
 
 
762
\def\comment{\begingroup \catcode`\^^M=\other%
 
763
\catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
 
764
\commentxxx}
 
765
{\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}}
 
766
 
 
767
\let\c=\comment
 
768
 
 
769
% @paragraphindent NCHARS
 
770
% We'll use ems for NCHARS, close enough.
 
771
% We cannot implement @paragraphindent asis, though.
 
772
 
773
\def\asisword{asis} % no translation, these are keywords
 
774
\def\noneword{none}
 
775
%
 
776
\def\paragraphindent{\parsearg\doparagraphindent}
 
777
\def\doparagraphindent#1{%
 
778
  \def\temp{#1}%
 
779
  \ifx\temp\asisword
 
780
  \else
 
781
    \ifx\temp\noneword
 
782
      \defaultparindent = 0pt
 
783
    \else
 
784
      \defaultparindent = #1em
 
785
    \fi
 
786
  \fi
 
787
  \parindent = \defaultparindent
 
788
}
 
789
 
 
790
% @exampleindent NCHARS
 
791
% We'll use ems for NCHARS like @paragraphindent.
 
792
% It seems @exampleindent asis isn't necessary, but
 
793
% I preserve it to make it similar to @paragraphindent.
 
794
\def\exampleindent{\parsearg\doexampleindent}
 
795
\def\doexampleindent#1{%
 
796
  \def\temp{#1}%
 
797
  \ifx\temp\asisword
 
798
  \else
 
799
    \ifx\temp\noneword
 
800
      \lispnarrowing = 0pt
 
801
    \else
 
802
      \lispnarrowing = #1em
 
803
    \fi
 
804
  \fi
 
805
}
 
806
 
 
807
% @asis just yields its argument.  Used with @table, for example.
 
808
%
 
809
\def\asis#1{#1}
 
810
 
 
811
% @math means output in math mode.
 
812
% We don't use $'s directly in the definition of \math because control
 
813
% sequences like \math are expanded when the toc file is written.  Then,
 
814
% we read the toc file back, the $'s will be normal characters (as they
 
815
% should be, according to the definition of Texinfo).  So we must use a
 
816
% control sequence to switch into and out of math mode.
 
817
%
 
818
% This isn't quite enough for @math to work properly in indices, but it
 
819
% seems unlikely it will ever be needed there.
 
820
%
 
821
\let\implicitmath = $
 
822
\def\math#1{\implicitmath #1\implicitmath}
 
823
 
 
824
% @bullet and @minus need the same treatment as @math, just above.
 
825
\def\bullet{\implicitmath\ptexbullet\implicitmath}
 
826
\def\minus{\implicitmath-\implicitmath}
 
827
 
 
828
% @refill is a no-op.
 
829
\let\refill=\relax
 
830
 
 
831
% If working on a large document in chapters, it is convenient to
 
832
% be able to disable indexing, cross-referencing, and contents, for test runs.
 
833
% This is done with @novalidate (before @setfilename).
 
834
%
 
835
\newif\iflinks \linkstrue % by default we want the aux files.
 
836
\let\novalidate = \linksfalse
 
837
 
 
838
% @setfilename is done at the beginning of every texinfo file.
 
839
% So open here the files we need to have open while reading the input.
 
840
% This makes it possible to make a .fmt file for texinfo.
 
841
\def\setfilename{%
 
842
   \iflinks
 
843
     \readauxfile
 
844
   \fi % \openindices needs to do some work in any case.
 
845
   \openindices
 
846
   \fixbackslash  % Turn off hack to swallow `\input texinfo'.
 
847
   \global\let\setfilename=\comment % Ignore extra @setfilename cmds.
 
848
   %
 
849
   % If texinfo.cnf is present on the system, read it.
 
850
   % Useful for site-wide @afourpaper, etc.
 
851
   % Just to be on the safe side, close the input stream before the \input.
 
852
   \openin 1 texinfo.cnf
 
853
   \ifeof1 \let\temp=\relax \else \def\temp{\input texinfo.cnf }\fi
 
854
   \closein1
 
855
   \temp
 
856
   %
 
857
   \comment % Ignore the actual filename.
 
858
}
 
859
 
 
860
% Called from \setfilename.
 
861
%
 
862
\def\openindices{%
 
863
  \newindex{cp}%
 
864
  \newcodeindex{fn}%
 
865
  \newcodeindex{vr}%
 
866
  \newcodeindex{tp}%
 
867
  \newcodeindex{ky}%
 
868
  \newcodeindex{pg}%
 
869
}
 
870
 
 
871
% @bye.
 
872
\outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
 
873
 
 
874
 
 
875
\message{pdf,}
 
876
% adobe `portable' document format
 
877
\newcount\tempnum
 
878
\newcount\lnkcount
 
879
\newtoks\filename
 
880
\newcount\filenamelength
 
881
\newcount\pgn
 
882
\newtoks\toksA
 
883
\newtoks\toksB
 
884
\newtoks\toksC
 
885
\newtoks\toksD
 
886
\newbox\boxA
 
887
\newcount\countA
 
888
\newif\ifpdf
 
889
\newif\ifpdfmakepagedest
 
890
 
 
891
\ifx\pdfoutput\undefined
 
892
  \pdffalse
 
893
  \let\pdfmkdest = \gobble
 
894
  \let\pdfurl = \gobble
 
895
  \let\endlink = \relax
 
896
  \let\linkcolor = \relax
 
897
  \let\pdfmakeoutlines = \relax
 
898
\else
 
899
  \pdftrue
 
900
  \pdfoutput = 1
 
901
  \input pdfcolor
 
902
  \def\dopdfimage#1#2#3{%
 
903
    \def\imagewidth{#2}%
 
904
    \def\imageheight{#3}%
 
905
    \ifnum\pdftexversion < 14
 
906
      \pdfimage
 
907
    \else
 
908
      \pdfximage
 
909
    \fi
 
910
      \ifx\empty\imagewidth\else width \imagewidth \fi
 
911
      \ifx\empty\imageheight\else height \imageheight \fi
 
912
      {#1.pdf}%
 
913
    \ifnum\pdftexversion < 14 \else
 
914
      \pdfrefximage \pdflastximage
 
915
    \fi}
 
916
  \def\pdfmkdest#1{\pdfdest name{#1@} xyz}
 
917
  \def\pdfmkpgn#1{#1@}
 
918
  \let\linkcolor = \Blue  % was Cyan, but that seems light?
 
919
  \def\endlink{\Black\pdfendlink}
 
920
  % Adding outlines to PDF; macros for calculating structure of outlines
 
921
  % come from Petr Olsak
 
922
  \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
 
923
    \else \csname#1\endcsname \fi}
 
924
  \def\advancenumber#1{\tempnum=\expnumber{#1}\relax
 
925
    \advance\tempnum by1
 
926
    \expandafter\xdef\csname#1\endcsname{\the\tempnum}}
 
927
  \def\pdfmakeoutlines{{%
 
928
    \openin 1 \jobname.toc
 
929
    \ifeof 1\else\bgroup
 
930
      \closein 1 
 
931
      \indexnofonts
 
932
      \def\tt{}
 
933
      \let\_ = \normalunderscore
 
934
      % Thanh's hack / proper braces in bookmarks  
 
935
      \edef\mylbrace{\iftrue \string{\else}\fi}\let\{=\mylbrace
 
936
      \edef\myrbrace{\iffalse{\else\string}\fi}\let\}=\myrbrace
 
937
      %
 
938
      \def\chapentry ##1##2##3{}
 
939
      \def\unnumbchapentry ##1##2{}
 
940
      \def\secentry ##1##2##3##4{\advancenumber{chap##2}}
 
941
      \def\unnumbsecentry ##1##2{}
 
942
      \def\subsecentry ##1##2##3##4##5{\advancenumber{sec##2.##3}}
 
943
      \def\unnumbsubsecentry ##1##2{}
 
944
      \def\subsubsecentry ##1##2##3##4##5##6{\advancenumber{subsec##2.##3.##4}}
 
945
      \def\unnumbsubsubsecentry ##1##2{}
 
946
      \input \jobname.toc
 
947
      \def\chapentry ##1##2##3{%
 
948
        \pdfoutline goto name{\pdfmkpgn{##3}}count-\expnumber{chap##2}{##1}}
 
949
      \def\unnumbchapentry ##1##2{%
 
950
        \pdfoutline goto name{\pdfmkpgn{##2}}{##1}}
 
951
      \def\secentry ##1##2##3##4{%
 
952
        \pdfoutline goto name{\pdfmkpgn{##4}}count-\expnumber{sec##2.##3}{##1}}
 
953
      \def\unnumbsecentry ##1##2{%
 
954
        \pdfoutline goto name{\pdfmkpgn{##2}}{##1}}
 
955
      \def\subsecentry ##1##2##3##4##5{%
 
956
        \pdfoutline goto name{\pdfmkpgn{##5}}count-\expnumber{subsec##2.##3.##4}{##1}}
 
957
      \def\unnumbsubsecentry ##1##2{%
 
958
        \pdfoutline goto name{\pdfmkpgn{##2}}{##1}}
 
959
      \def\subsubsecentry ##1##2##3##4##5##6{%
 
960
        \pdfoutline goto name{\pdfmkpgn{##6}}{##1}}
 
961
      \def\unnumbsubsubsecentry ##1##2{%
 
962
        \pdfoutline goto name{\pdfmkpgn{##2}}{##1}}
 
963
      \input \jobname.toc
 
964
    \egroup\fi
 
965
  }}
 
966
  \def\makelinks #1,{%
 
967
    \def\params{#1}\def\E{END}%
 
968
    \ifx\params\E
 
969
      \let\nextmakelinks=\relax
 
970
    \else
 
971
      \let\nextmakelinks=\makelinks
 
972
      \ifnum\lnkcount>0,\fi
 
973
      \picknum{#1}%
 
974
      \startlink attr{/Border [0 0 0]} 
 
975
        goto name{\pdfmkpgn{\the\pgn}}%
 
976
      \linkcolor #1%
 
977
      \advance\lnkcount by 1%
 
978
      \endlink
 
979
    \fi
 
980
    \nextmakelinks
 
981
  }
 
982
  \def\picknum#1{\expandafter\pn#1}
 
983
  \def\pn#1{%
 
984
    \def\p{#1}%
 
985
    \ifx\p\lbrace
 
986
      \let\nextpn=\ppn
 
987
    \else
 
988
      \let\nextpn=\ppnn
 
989
      \def\first{#1}
 
990
    \fi
 
991
    \nextpn
 
992
  }
 
993
  \def\ppn#1{\pgn=#1\gobble}
 
994
  \def\ppnn{\pgn=\first}
 
995
  \def\pdfmklnk#1{\lnkcount=0\makelinks #1,END,}
 
996
  \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
 
997
  \def\skipspaces#1{\def\PP{#1}\def\D{|}%
 
998
    \ifx\PP\D\let\nextsp\relax
 
999
    \else\let\nextsp\skipspaces
 
1000
      \ifx\p\space\else\addtokens{\filename}{\PP}%
 
1001
        \advance\filenamelength by 1
 
1002
      \fi
 
1003
    \fi
 
1004
    \nextsp}
 
1005
  \def\getfilename#1{\filenamelength=0\expandafter\skipspaces#1|\relax}
 
1006
  \ifnum\pdftexversion < 14
 
1007
    \let \startlink \pdfannotlink
 
1008
  \else
 
1009
    \let \startlink \pdfstartlink
 
1010
  \fi
 
1011
  \def\pdfurl#1{%
 
1012
    \begingroup
 
1013
      \normalturnoffactive\def\@{@}%
 
1014
      \leavevmode\Red
 
1015
      \startlink attr{/Border [0 0 0]}%
 
1016
        user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
 
1017
        % #1
 
1018
    \endgroup}
 
1019
  \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
 
1020
  \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
 
1021
  \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
 
1022
  \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
 
1023
  \def\maketoks{%
 
1024
    \expandafter\poptoks\the\toksA|ENDTOKS|
 
1025
    \ifx\first0\adn0
 
1026
    \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
 
1027
    \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
 
1028
    \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9 
 
1029
    \else
 
1030
      \ifnum0=\countA\else\makelink\fi
 
1031
      \ifx\first.\let\next=\done\else
 
1032
        \let\next=\maketoks
 
1033
        \addtokens{\toksB}{\the\toksD}
 
1034
        \ifx\first,\addtokens{\toksB}{\space}\fi
 
1035
      \fi
 
1036
    \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
 
1037
    \next}
 
1038
  \def\makelink{\addtokens{\toksB}%
 
1039
    {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
 
1040
  \def\pdflink#1{%
 
1041
    \startlink attr{/Border [0 0 0]} goto name{\mkpgn{#1}}
 
1042
    \linkcolor #1\endlink}
 
1043
  \def\mkpgn#1{#1@} 
 
1044
  \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
 
1045
\fi % \ifx\pdfoutput
 
1046
 
 
1047
 
 
1048
\message{fonts,}
 
1049
% Font-change commands.
 
1050
 
 
1051
% Texinfo sort of supports the sans serif font style, which plain TeX does not.
 
1052
% So we set up a \sf analogous to plain's \rm, etc.
 
1053
\newfam\sffam
 
1054
\def\sf{\fam=\sffam \tensf}
 
1055
\let\li = \sf % Sometimes we call it \li, not \sf.
 
1056
 
 
1057
% We don't need math for this one.
 
1058
\def\ttsl{\tenttsl}
 
1059
 
 
1060
% Use Computer Modern fonts at \magstephalf (11pt).
 
1061
\newcount\mainmagstep
 
1062
\mainmagstep=\magstephalf
 
1063
 
 
1064
% Set the font macro #1 to the font named #2, adding on the
 
1065
% specified font prefix (normally `cm').
 
1066
% #3 is the font's design size, #4 is a scale factor
 
1067
\def\setfont#1#2#3#4{\font#1=\fontprefix#2#3 scaled #4}
 
1068
 
 
1069
% Use cm as the default font prefix.
 
1070
% To specify the font prefix, you must define \fontprefix
 
1071
% before you read in texinfo.tex.
 
1072
\ifx\fontprefix\undefined
 
1073
\def\fontprefix{cm}
 
1074
\fi
 
1075
% Support font families that don't use the same naming scheme as CM.
 
1076
\def\rmshape{r}
 
1077
\def\rmbshape{bx}               %where the normal face is bold
 
1078
\def\bfshape{b}
 
1079
\def\bxshape{bx}
 
1080
\def\ttshape{tt}
 
1081
\def\ttbshape{tt}
 
1082
\def\ttslshape{sltt}
 
1083
\def\itshape{ti}
 
1084
\def\itbshape{bxti}
 
1085
\def\slshape{sl}
 
1086
\def\slbshape{bxsl}
 
1087
\def\sfshape{ss}
 
1088
\def\sfbshape{ss}
 
1089
\def\scshape{csc}
 
1090
\def\scbshape{csc}
 
1091
 
 
1092
\ifx\bigger\relax
 
1093
\let\mainmagstep=\magstep1
 
1094
\setfont\textrm\rmshape{12}{1000}
 
1095
\setfont\texttt\ttshape{12}{1000}
 
1096
\else
 
1097
\setfont\textrm\rmshape{10}{\mainmagstep}
 
1098
\setfont\texttt\ttshape{10}{\mainmagstep}
 
1099
\fi
 
1100
% Instead of cmb10, you many want to use cmbx10.
 
1101
% cmbx10 is a prettier font on its own, but cmb10
 
1102
% looks better when embedded in a line with cmr10.
 
1103
\setfont\textbf\bfshape{10}{\mainmagstep}
 
1104
\setfont\textit\itshape{10}{\mainmagstep}
 
1105
\setfont\textsl\slshape{10}{\mainmagstep}
 
1106
\setfont\textsf\sfshape{10}{\mainmagstep}
 
1107
\setfont\textsc\scshape{10}{\mainmagstep}
 
1108
\setfont\textttsl\ttslshape{10}{\mainmagstep}
 
1109
\font\texti=cmmi10 scaled \mainmagstep
 
1110
\font\textsy=cmsy10 scaled \mainmagstep
 
1111
 
 
1112
% A few fonts for @defun, etc.
 
1113
\setfont\defbf\bxshape{10}{\magstep1} %was 1314
 
1114
\setfont\deftt\ttshape{10}{\magstep1}
 
1115
\def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf}
 
1116
 
 
1117
% Fonts for indices, footnotes, small examples (9pt).
 
1118
\setfont\smallrm\rmshape{9}{1000}
 
1119
\setfont\smalltt\ttshape{9}{1000}
 
1120
\setfont\smallbf\bfshape{10}{900}
 
1121
\setfont\smallit\itshape{9}{1000}
 
1122
\setfont\smallsl\slshape{9}{1000}
 
1123
\setfont\smallsf\sfshape{9}{1000}
 
1124
\setfont\smallsc\scshape{10}{900}
 
1125
\setfont\smallttsl\ttslshape{10}{900}
 
1126
\font\smalli=cmmi9
 
1127
\font\smallsy=cmsy9
 
1128
 
 
1129
% Fonts for title page:
 
1130
\setfont\titlerm\rmbshape{12}{\magstep3}
 
1131
\setfont\titleit\itbshape{10}{\magstep4}
 
1132
\setfont\titlesl\slbshape{10}{\magstep4}
 
1133
\setfont\titlett\ttbshape{12}{\magstep3}
 
1134
\setfont\titlettsl\ttslshape{10}{\magstep4}
 
1135
\setfont\titlesf\sfbshape{17}{\magstep1}
 
1136
\let\titlebf=\titlerm
 
1137
\setfont\titlesc\scbshape{10}{\magstep4}
 
1138
\font\titlei=cmmi12 scaled \magstep3
 
1139
\font\titlesy=cmsy10 scaled \magstep4
 
1140
\def\authorrm{\secrm}
 
1141
 
 
1142
% Chapter (and unnumbered) fonts (17.28pt).
 
1143
\setfont\chaprm\rmbshape{12}{\magstep2}
 
1144
\setfont\chapit\itbshape{10}{\magstep3}
 
1145
\setfont\chapsl\slbshape{10}{\magstep3}
 
1146
\setfont\chaptt\ttbshape{12}{\magstep2}
 
1147
\setfont\chapttsl\ttslshape{10}{\magstep3}
 
1148
\setfont\chapsf\sfbshape{17}{1000}
 
1149
\let\chapbf=\chaprm
 
1150
\setfont\chapsc\scbshape{10}{\magstep3}
 
1151
\font\chapi=cmmi12 scaled \magstep2
 
1152
\font\chapsy=cmsy10 scaled \magstep3
 
1153
 
 
1154
% Section fonts (14.4pt).
 
1155
\setfont\secrm\rmbshape{12}{\magstep1}
 
1156
\setfont\secit\itbshape{10}{\magstep2}
 
1157
\setfont\secsl\slbshape{10}{\magstep2}
 
1158
\setfont\sectt\ttbshape{12}{\magstep1}
 
1159
\setfont\secttsl\ttslshape{10}{\magstep2}
 
1160
\setfont\secsf\sfbshape{12}{\magstep1}
 
1161
\let\secbf\secrm
 
1162
\setfont\secsc\scbshape{10}{\magstep2}
 
1163
\font\seci=cmmi12 scaled \magstep1
 
1164
\font\secsy=cmsy10 scaled \magstep2
 
1165
 
 
1166
% \setfont\ssecrm\bxshape{10}{\magstep1}    % This size an font looked bad.
 
1167
% \setfont\ssecit\itshape{10}{\magstep1}    % The letters were too crowded.
 
1168
% \setfont\ssecsl\slshape{10}{\magstep1}
 
1169
% \setfont\ssectt\ttshape{10}{\magstep1}
 
1170
% \setfont\ssecsf\sfshape{10}{\magstep1}
 
1171
 
 
1172
%\setfont\ssecrm\bfshape{10}{1315}      % Note the use of cmb rather than cmbx.
 
1173
%\setfont\ssecit\itshape{10}{1315}      % Also, the size is a little larger than
 
1174
%\setfont\ssecsl\slshape{10}{1315}      % being scaled magstep1.
 
1175
%\setfont\ssectt\ttshape{10}{1315}
 
1176
%\setfont\ssecsf\sfshape{10}{1315}
 
1177
 
 
1178
%\let\ssecbf=\ssecrm
 
1179
 
 
1180
% Subsection fonts (13.15pt).
 
1181
\setfont\ssecrm\rmbshape{12}{\magstephalf}
 
1182
\setfont\ssecit\itbshape{10}{1315}
 
1183
\setfont\ssecsl\slbshape{10}{1315}
 
1184
\setfont\ssectt\ttbshape{12}{\magstephalf}
 
1185
\setfont\ssecttsl\ttslshape{10}{1315}
 
1186
\setfont\ssecsf\sfbshape{12}{\magstephalf}
 
1187
\let\ssecbf\ssecrm
 
1188
\setfont\ssecsc\scbshape{10}{\magstep1}
 
1189
\font\sseci=cmmi12 scaled \magstephalf
 
1190
\font\ssecsy=cmsy10 scaled 1315
 
1191
% The smallcaps and symbol fonts should actually be scaled \magstep1.5,
 
1192
% but that is not a standard magnification.
 
1193
 
 
1194
% In order for the font changes to affect most math symbols and letters,
 
1195
% we have to define the \textfont of the standard families.  Since
 
1196
% texinfo doesn't allow for producing subscripts and superscripts, we
 
1197
% don't bother to reset \scriptfont and \scriptscriptfont (which would
 
1198
% also require loading a lot more fonts).
 
1199
%
 
1200
\def\resetmathfonts{%
 
1201
  \textfont0 = \tenrm \textfont1 = \teni \textfont2 = \tensy
 
1202
  \textfont\itfam = \tenit \textfont\slfam = \tensl \textfont\bffam = \tenbf
 
1203
  \textfont\ttfam = \tentt \textfont\sffam = \tensf
 
1204
}
 
1205
 
 
1206
 
 
1207
% The font-changing commands redefine the meanings of \tenSTYLE, instead
 
1208
% of just \STYLE.  We do this so that font changes will continue to work
 
1209
% in math mode, where it is the current \fam that is relevant in most
 
1210
% cases, not the current font.  Plain TeX does \def\bf{\fam=\bffam
 
1211
% \tenbf}, for example.  By redefining \tenbf, we obviate the need to
 
1212
% redefine \bf itself.
 
1213
\def\textfonts{%
 
1214
  \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
 
1215
  \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
 
1216
  \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy \let\tenttsl=\textttsl
 
1217
  \resetmathfonts}
 
1218
\def\titlefonts{%
 
1219
  \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl
 
1220
  \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc
 
1221
  \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy
 
1222
  \let\tenttsl=\titlettsl
 
1223
  \resetmathfonts \setleading{25pt}}
 
1224
\def\titlefont#1{{\titlefonts\rm #1}}
 
1225
\def\chapfonts{%
 
1226
  \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl
 
1227
  \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
 
1228
  \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy \let\tenttsl=\chapttsl
 
1229
  \resetmathfonts \setleading{19pt}}
 
1230
\def\secfonts{%
 
1231
  \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl
 
1232
  \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc
 
1233
  \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy \let\tenttsl=\secttsl
 
1234
  \resetmathfonts \setleading{16pt}}
 
1235
\def\subsecfonts{%
 
1236
  \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl
 
1237
  \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc
 
1238
  \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy \let\tenttsl=\ssecttsl
 
1239
  \resetmathfonts \setleading{15pt}}
 
1240
\let\subsubsecfonts = \subsecfonts % Maybe make sssec fonts scaled magstephalf?
 
1241
\def\smallfonts{%
 
1242
  \let\tenrm=\smallrm \let\tenit=\smallit \let\tensl=\smallsl
 
1243
  \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc
 
1244
  \let\tensf=\smallsf \let\teni=\smalli \let\tensy=\smallsy
 
1245
  \let\tenttsl=\smallttsl
 
1246
  \resetmathfonts \setleading{11pt}}
 
1247
 
 
1248
% Set up the default fonts, so we can use them for creating boxes.
 
1249
%
 
1250
\textfonts
 
1251
 
 
1252
% Define these so they can be easily changed for other fonts.
 
1253
\def\angleleft{$\langle$}
 
1254
\def\angleright{$\rangle$}
 
1255
 
 
1256
% Count depth in font-changes, for error checks
 
1257
\newcount\fontdepth \fontdepth=0
 
1258
 
 
1259
% Fonts for short table of contents.
 
1260
\setfont\shortcontrm\rmshape{12}{1000}
 
1261
\setfont\shortcontbf\bxshape{12}{1000}
 
1262
\setfont\shortcontsl\slshape{12}{1000}
 
1263
 
 
1264
%% Add scribe-like font environments, plus @l for inline lisp (usually sans
 
1265
%% serif) and @ii for TeX italic
 
1266
 
 
1267
% \smartitalic{ARG} outputs arg in italics, followed by an italic correction
 
1268
% unless the following character is such as not to need one.
 
1269
\def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi}
 
1270
\def\smartslanted#1{{\sl #1}\futurelet\next\smartitalicx}
 
1271
\def\smartitalic#1{{\it #1}\futurelet\next\smartitalicx}
 
1272
 
 
1273
\let\i=\smartitalic
 
1274
\let\var=\smartslanted
 
1275
\let\dfn=\smartslanted
 
1276
\let\emph=\smartitalic
 
1277
\let\cite=\smartslanted
 
1278
 
 
1279
\def\b#1{{\bf #1}}
 
1280
\let\strong=\b
 
1281
 
 
1282
% We can't just use \exhyphenpenalty, because that only has effect at
 
1283
% the end of a paragraph.  Restore normal hyphenation at the end of the
 
1284
% group within which \nohyphenation is presumably called.
 
1285
%
 
1286
\def\nohyphenation{\hyphenchar\font = -1  \aftergroup\restorehyphenation}
 
1287
\def\restorehyphenation{\hyphenchar\font = `- }
 
1288
 
 
1289
\def\t#1{%
 
1290
  {\tt \rawbackslash \frenchspacing #1}%
 
1291
  \null
 
1292
}
 
1293
\let\ttfont=\t
 
1294
\def\samp#1{`\tclose{#1}'\null}
 
1295
\setfont\keyrm\rmshape{8}{1000}
 
1296
\font\keysy=cmsy9
 
1297
\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
 
1298
  \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
 
1299
    \vbox{\hrule\kern-0.4pt
 
1300
     \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
 
1301
    \kern-0.4pt\hrule}%
 
1302
  \kern-.06em\raise0.4pt\hbox{\angleright}}}}
 
1303
% The old definition, with no lozenge:
 
1304
%\def\key #1{{\ttsl \nohyphenation \uppercase{#1}}\null}
 
1305
\def\ctrl #1{{\tt \rawbackslash \hat}#1}
 
1306
 
 
1307
% @file, @option are the same as @samp.
 
1308
\let\file=\samp
 
1309
\let\option=\samp
 
1310
 
 
1311
% @code is a modification of @t,
 
1312
% which makes spaces the same size as normal in the surrounding text.
 
1313
\def\tclose#1{%
 
1314
  {%
 
1315
    % Change normal interword space to be same as for the current font.
 
1316
    \spaceskip = \fontdimen2\font
 
1317
    %
 
1318
    % Switch to typewriter.
 
1319
    \tt
 
1320
    %
 
1321
    % But `\ ' produces the large typewriter interword space.
 
1322
    \def\ {{\spaceskip = 0pt{} }}%
 
1323
    %
 
1324
    % Turn off hyphenation.
 
1325
    \nohyphenation
 
1326
    %
 
1327
    \rawbackslash
 
1328
    \frenchspacing
 
1329
    #1%
 
1330
  }%
 
1331
  \null
 
1332
}
 
1333
 
 
1334
% We *must* turn on hyphenation at `-' and `_' in \code.
 
1335
% Otherwise, it is too hard to avoid overfull hboxes
 
1336
% in the Emacs manual, the Library manual, etc.
 
1337
 
 
1338
% Unfortunately, TeX uses one parameter (\hyphenchar) to control
 
1339
% both hyphenation at - and hyphenation within words.
 
1340
% We must therefore turn them both off (\tclose does that)
 
1341
% and arrange explicitly to hyphenate at a dash.
 
1342
%  -- rms.
 
1343
{
 
1344
  \catcode`\-=\active
 
1345
  \catcode`\_=\active
 
1346
  %
 
1347
  \global\def\code{\begingroup
 
1348
    \catcode`\-=\active \let-\codedash
 
1349
    \catcode`\_=\active \let_\codeunder
 
1350
    \codex
 
1351
  }
 
1352
  %
 
1353
  % If we end up with any active - characters when handling the index,
 
1354
  % just treat them as a normal -.
 
1355
  \global\def\indexbreaks{\catcode`\-=\active \let-\realdash}
 
1356
}
 
1357
 
 
1358
\def\realdash{-}
 
1359
\def\codedash{-\discretionary{}{}{}}
 
1360
\def\codeunder{\ifusingtt{\normalunderscore\discretionary{}{}{}}{\_}}
 
1361
\def\codex #1{\tclose{#1}\endgroup}
 
1362
 
 
1363
%\let\exp=\tclose  %Was temporary
 
1364
 
 
1365
% @kbd is like @code, except that if the argument is just one @key command,
 
1366
% then @kbd has no effect.
 
1367
 
 
1368
% @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
 
1369
%   `example' (@kbd uses ttsl only inside of @example and friends),
 
1370
%   or `code' (@kbd uses normal tty font always).
 
1371
\def\kbdinputstyle{\parsearg\kbdinputstylexxx}
 
1372
\def\kbdinputstylexxx#1{%
 
1373
  \def\arg{#1}%
 
1374
  \ifx\arg\worddistinct
 
1375
    \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
 
1376
  \else\ifx\arg\wordexample
 
1377
    \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
 
1378
  \else\ifx\arg\wordcode
 
1379
    \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
 
1380
  \fi\fi\fi
 
1381
}
 
1382
\def\worddistinct{distinct}
 
1383
\def\wordexample{example}
 
1384
\def\wordcode{code}
 
1385
 
 
1386
% Default is kbdinputdistinct.  (Too much of a hassle to call the macro,
 
1387
% the catcodes are wrong for parsearg to work.)
 
1388
\gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}
 
1389
 
 
1390
\def\xkey{\key}
 
1391
\def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}%
 
1392
\ifx\one\xkey\ifx\threex\three \key{#2}%
 
1393
\else{\tclose{\kbdfont\look}}\fi
 
1394
\else{\tclose{\kbdfont\look}}\fi}
 
1395
 
 
1396
% For @url, @env, @command quotes seem unnecessary, so use \code.
 
1397
\let\url=\code
 
1398
\let\env=\code
 
1399
\let\command=\code
 
1400
 
 
1401
% @uref (abbreviation for `urlref') takes an optional (comma-separated)
 
1402
% second argument specifying the text to display and an optional third
 
1403
% arg as text to display instead of (rather than in addition to) the url
 
1404
% itself.  First (mandatory) arg is the url.  Perhaps eventually put in
 
1405
% a hypertex \special here.
 
1406
%
 
1407
\def\uref#1{\douref #1,,,\finish}
 
1408
\def\douref#1,#2,#3,#4\finish{\begingroup
 
1409
  \unsepspaces
 
1410
  \pdfurl{#1}%
 
1411
  \setbox0 = \hbox{\ignorespaces #3}%
 
1412
  \ifdim\wd0 > 0pt
 
1413
    \unhbox0 % third arg given, show only that
 
1414
  \else
 
1415
    \setbox0 = \hbox{\ignorespaces #2}%
 
1416
    \ifdim\wd0 > 0pt
 
1417
      \ifpdf
 
1418
        \unhbox0             % PDF: 2nd arg given, show only it
 
1419
      \else
 
1420
        \unhbox0\ (\code{#1})% DVI: 2nd arg given, show both it and url
 
1421
      \fi
 
1422
    \else
 
1423
      \code{#1}% only url given, so show it
 
1424
    \fi
 
1425
  \fi
 
1426
  \endlink
 
1427
\endgroup}
 
1428
 
 
1429
% rms does not like angle brackets --karl, 17may97.
 
1430
% So now @email is just like @uref, unless we are pdf.
 
1431
 
1432
%\def\email#1{\angleleft{\tt #1}\angleright}
 
1433
\ifpdf
 
1434
  \def\email#1{\doemail#1,,\finish}
 
1435
  \def\doemail#1,#2,#3\finish{\begingroup
 
1436
    \unsepspaces
 
1437
    \pdfurl{mailto:#1}%
 
1438
    \setbox0 = \hbox{\ignorespaces #2}%
 
1439
    \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
 
1440
    \endlink
 
1441
  \endgroup}
 
1442
\else
 
1443
  \let\email=\uref
 
1444
\fi
 
1445
 
 
1446
% Check if we are currently using a typewriter font.  Since all the
 
1447
% Computer Modern typewriter fonts have zero interword stretch (and
 
1448
% shrink), and it is reasonable to expect all typewriter fonts to have
 
1449
% this property, we can check that font parameter.
 
1450
%
 
1451
\def\ifmonospace{\ifdim\fontdimen3\font=0pt }
 
1452
 
 
1453
% Typeset a dimension, e.g., `in' or `pt'.  The only reason for the
 
1454
% argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
 
1455
%
 
1456
\def\dmn#1{\thinspace #1}
 
1457
 
 
1458
\def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par}
 
1459
 
 
1460
% @l was never documented to mean ``switch to the Lisp font'',
 
1461
% and it is not used as such in any manual I can find.  We need it for
 
1462
% Polish suppressed-l.  --karl, 22sep96.
 
1463
%\def\l#1{{\li #1}\null}
 
1464
 
 
1465
% Explicit font changes: @r, @sc, undocumented @ii.
 
1466
\def\r#1{{\rm #1}}              % roman font
 
1467
\def\sc#1{{\smallcaps#1}}       % smallcaps font
 
1468
\def\ii#1{{\it #1}}             % italic font
 
1469
 
 
1470
% @acronym downcases the argument and prints in smallcaps.
 
1471
\def\acronym#1{{\smallcaps \lowercase{#1}}}
 
1472
 
 
1473
% @pounds{} is a sterling sign.
 
1474
\def\pounds{{\it\$}}
 
1475
 
 
1476
 
 
1477
\message{page headings,}
 
1478
 
 
1479
\newskip\titlepagetopglue \titlepagetopglue = 1.5in
 
1480
\newskip\titlepagebottomglue \titlepagebottomglue = 2pc
 
1481
 
 
1482
% First the title page.  Must do @settitle before @titlepage.
 
1483
\newif\ifseenauthor
 
1484
\newif\iffinishedtitlepage
 
1485
 
 
1486
% Do an implicit @contents or @shortcontents after @end titlepage if the
 
1487
% user says @setcontentsaftertitlepage or @setshortcontentsaftertitlepage.
 
1488
%
 
1489
\newif\ifsetcontentsaftertitlepage
 
1490
 \let\setcontentsaftertitlepage = \setcontentsaftertitlepagetrue
 
1491
\newif\ifsetshortcontentsaftertitlepage
 
1492
 \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue
 
1493
 
 
1494
\def\shorttitlepage{\parsearg\shorttitlepagezzz}
 
1495
\def\shorttitlepagezzz #1{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}%
 
1496
        \endgroup\page\hbox{}\page}
 
1497
 
 
1498
\def\titlepage{\begingroup \parindent=0pt \textfonts
 
1499
   \let\subtitlerm=\tenrm
 
1500
   \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}%
 
1501
   %
 
1502
   \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}%
 
1503
   %
 
1504
   % Leave some space at the very top of the page.
 
1505
   \vglue\titlepagetopglue
 
1506
   %
 
1507
   % Now you can print the title using @title.
 
1508
   \def\title{\parsearg\titlezzz}%
 
1509
   \def\titlezzz##1{\leftline{\titlefonts\rm ##1}
 
1510
                    % print a rule at the page bottom also.
 
1511
                    \finishedtitlepagefalse
 
1512
                    \vskip4pt \hrule height 4pt width \hsize \vskip4pt}%
 
1513
   % No rule at page bottom unless we print one at the top with @title.
 
1514
   \finishedtitlepagetrue
 
1515
   %
 
1516
   % Now you can put text using @subtitle.
 
1517
   \def\subtitle{\parsearg\subtitlezzz}%
 
1518
   \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}%
 
1519
   %
 
1520
   % @author should come last, but may come many times.
 
1521
   \def\author{\parsearg\authorzzz}%
 
1522
   \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi
 
1523
      {\authorfont \leftline{##1}}}%
 
1524
   %
 
1525
   % Most title ``pages'' are actually two pages long, with space
 
1526
   % at the top of the second.  We don't want the ragged left on the second.
 
1527
   \let\oldpage = \page
 
1528
   \def\page{%
 
1529
      \iffinishedtitlepage\else
 
1530
         \finishtitlepage
 
1531
      \fi
 
1532
      \oldpage
 
1533
      \let\page = \oldpage
 
1534
      \hbox{}}%
 
1535
%   \def\page{\oldpage \hbox{}}
 
1536
}
 
1537
 
 
1538
\def\Etitlepage{%
 
1539
   \iffinishedtitlepage\else
 
1540
      \finishtitlepage
 
1541
   \fi
 
1542
   % It is important to do the page break before ending the group,
 
1543
   % because the headline and footline are only empty inside the group.
 
1544
   % If we use the new definition of \page, we always get a blank page
 
1545
   % after the title page, which we certainly don't want.
 
1546
   \oldpage
 
1547
   \endgroup
 
1548
   %
 
1549
   % If they want short, they certainly want long too.
 
1550
   \ifsetshortcontentsaftertitlepage
 
1551
     \shortcontents
 
1552
     \contents
 
1553
     \global\let\shortcontents = \relax
 
1554
     \global\let\contents = \relax
 
1555
   \fi
 
1556
   %
 
1557
   \ifsetcontentsaftertitlepage
 
1558
     \contents
 
1559
     \global\let\contents = \relax
 
1560
     \global\let\shortcontents = \relax
 
1561
   \fi
 
1562
   %
 
1563
   \ifpdf \pdfmakepagedesttrue \fi
 
1564
   %
 
1565
   \HEADINGSon
 
1566
}
 
1567
 
 
1568
\def\finishtitlepage{%
 
1569
   \vskip4pt \hrule height 2pt width \hsize
 
1570
   \vskip\titlepagebottomglue
 
1571
   \finishedtitlepagetrue
 
1572
}
 
1573
 
 
1574
%%% Set up page headings and footings.
 
1575
 
 
1576
\let\thispage=\folio
 
1577
 
 
1578
\newtoks\evenheadline    % headline on even pages
 
1579
\newtoks\oddheadline     % headline on odd pages
 
1580
\newtoks\evenfootline    % footline on even pages
 
1581
\newtoks\oddfootline     % footline on odd pages
 
1582
 
 
1583
% Now make Tex use those variables
 
1584
\headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
 
1585
                            \else \the\evenheadline \fi}}
 
1586
\footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
 
1587
                            \else \the\evenfootline \fi}\HEADINGShook}
 
1588
\let\HEADINGShook=\relax
 
1589
 
 
1590
% Commands to set those variables.
 
1591
% For example, this is what  @headings on  does
 
1592
% @evenheading @thistitle|@thispage|@thischapter
 
1593
% @oddheading @thischapter|@thispage|@thistitle
 
1594
% @evenfooting @thisfile||
 
1595
% @oddfooting ||@thisfile
 
1596
 
 
1597
\def\evenheading{\parsearg\evenheadingxxx}
 
1598
\def\oddheading{\parsearg\oddheadingxxx}
 
1599
\def\everyheading{\parsearg\everyheadingxxx}
 
1600
 
 
1601
\def\evenfooting{\parsearg\evenfootingxxx}
 
1602
\def\oddfooting{\parsearg\oddfootingxxx}
 
1603
\def\everyfooting{\parsearg\everyfootingxxx}
 
1604
 
 
1605
{\catcode`\@=0 %
 
1606
 
 
1607
\gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish}
 
1608
\gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{%
 
1609
\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
 
1610
 
 
1611
\gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish}
 
1612
\gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{%
 
1613
\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
 
1614
 
 
1615
\gdef\everyheadingxxx#1{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
 
1616
 
 
1617
\gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish}
 
1618
\gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{%
 
1619
\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
 
1620
 
 
1621
\gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish}
 
1622
\gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{%
 
1623
  \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}%
 
1624
  %
 
1625
  % Leave some space for the footline.  Hopefully ok to assume
 
1626
  % @evenfooting will not be used by itself.
 
1627
  \global\advance\pageheight by -\baselineskip
 
1628
  \global\advance\vsize by -\baselineskip
 
1629
}
 
1630
 
 
1631
\gdef\everyfootingxxx#1{\oddfootingxxx{#1}\evenfootingxxx{#1}}
 
1632
%
 
1633
}% unbind the catcode of @.
 
1634
 
 
1635
% @headings double      turns headings on for double-sided printing.
 
1636
% @headings single      turns headings on for single-sided printing.
 
1637
% @headings off         turns them off.
 
1638
% @headings on          same as @headings double, retained for compatibility.
 
1639
% @headings after       turns on double-sided headings after this page.
 
1640
% @headings doubleafter turns on double-sided headings after this page.
 
1641
% @headings singleafter turns on single-sided headings after this page.
 
1642
% By default, they are off at the start of a document,
 
1643
% and turned `on' after @end titlepage.
 
1644
 
 
1645
\def\headings #1 {\csname HEADINGS#1\endcsname}
 
1646
 
 
1647
\def\HEADINGSoff{
 
1648
\global\evenheadline={\hfil} \global\evenfootline={\hfil}
 
1649
\global\oddheadline={\hfil} \global\oddfootline={\hfil}}
 
1650
\HEADINGSoff
 
1651
% When we turn headings on, set the page number to 1.
 
1652
% For double-sided printing, put current file name in lower left corner,
 
1653
% chapter name on inside top of right hand pages, document
 
1654
% title on inside top of left hand pages, and page numbers on outside top
 
1655
% edge of all pages.
 
1656
\def\HEADINGSdouble{
 
1657
\global\pageno=1
 
1658
\global\evenfootline={\hfil}
 
1659
\global\oddfootline={\hfil}
 
1660
\global\evenheadline={\line{\folio\hfil\thistitle}}
 
1661
\global\oddheadline={\line{\thischapter\hfil\folio}}
 
1662
\global\let\contentsalignmacro = \chapoddpage
 
1663
}
 
1664
\let\contentsalignmacro = \chappager
 
1665
 
 
1666
% For single-sided printing, chapter title goes across top left of page,
 
1667
% page number on top right.
 
1668
\def\HEADINGSsingle{
 
1669
\global\pageno=1
 
1670
\global\evenfootline={\hfil}
 
1671
\global\oddfootline={\hfil}
 
1672
\global\evenheadline={\line{\thischapter\hfil\folio}}
 
1673
\global\oddheadline={\line{\thischapter\hfil\folio}}
 
1674
\global\let\contentsalignmacro = \chappager
 
1675
}
 
1676
\def\HEADINGSon{\HEADINGSdouble}
 
1677
 
 
1678
\def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
 
1679
\let\HEADINGSdoubleafter=\HEADINGSafter
 
1680
\def\HEADINGSdoublex{%
 
1681
\global\evenfootline={\hfil}
 
1682
\global\oddfootline={\hfil}
 
1683
\global\evenheadline={\line{\folio\hfil\thistitle}}
 
1684
\global\oddheadline={\line{\thischapter\hfil\folio}}
 
1685
\global\let\contentsalignmacro = \chapoddpage
 
1686
}
 
1687
 
 
1688
\def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
 
1689
\def\HEADINGSsinglex{%
 
1690
\global\evenfootline={\hfil}
 
1691
\global\oddfootline={\hfil}
 
1692
\global\evenheadline={\line{\thischapter\hfil\folio}}
 
1693
\global\oddheadline={\line{\thischapter\hfil\folio}}
 
1694
\global\let\contentsalignmacro = \chappager
 
1695
}
 
1696
 
 
1697
% Subroutines used in generating headings
 
1698
% This produces Day Month Year style of output.
 
1699
% Only define if not already defined, in case a txi-??.tex file has set
 
1700
% up a different format (e.g., txi-cs.tex does this).
 
1701
\ifx\today\undefined
 
1702
\def\today{%
 
1703
  \number\day\space
 
1704
  \ifcase\month
 
1705
  \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr
 
1706
  \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug
 
1707
  \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec
 
1708
  \fi
 
1709
  \space\number\year}
 
1710
\fi
 
1711
 
 
1712
% @settitle line...  specifies the title of the document, for headings.
 
1713
% It generates no output of its own.
 
1714
\def\thistitle{\putwordNoTitle}
 
1715
\def\settitle{\parsearg\settitlezzz}
 
1716
\def\settitlezzz #1{\gdef\thistitle{#1}}
 
1717
 
 
1718
 
 
1719
\message{tables,}
 
1720
% Tables -- @table, @ftable, @vtable, @item(x), @kitem(x), @xitem(x).
 
1721
 
 
1722
% default indentation of table text
 
1723
\newdimen\tableindent \tableindent=.8in
 
1724
% default indentation of @itemize and @enumerate text
 
1725
\newdimen\itemindent  \itemindent=.3in
 
1726
% margin between end of table item and start of table text.
 
1727
\newdimen\itemmargin  \itemmargin=.1in
 
1728
 
 
1729
% used internally for \itemindent minus \itemmargin
 
1730
\newdimen\itemmax
 
1731
 
 
1732
% Note @table, @vtable, and @vtable define @item, @itemx, etc., with
 
1733
% these defs.
 
1734
% They also define \itemindex
 
1735
% to index the item name in whatever manner is desired (perhaps none).
 
1736
 
 
1737
\newif\ifitemxneedsnegativevskip
 
1738
 
 
1739
\def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
 
1740
 
 
1741
\def\internalBitem{\smallbreak \parsearg\itemzzz}
 
1742
\def\internalBitemx{\itemxpar \parsearg\itemzzz}
 
1743
 
 
1744
\def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz}
 
1745
\def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \itemxpar \parsearg\xitemzzz}
 
1746
 
 
1747
\def\internalBkitem{\smallbreak \parsearg\kitemzzz}
 
1748
\def\internalBkitemx{\itemxpar \parsearg\kitemzzz}
 
1749
 
 
1750
\def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}%
 
1751
                 \itemzzz {#1}}
 
1752
 
 
1753
\def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}%
 
1754
                 \itemzzz {#1}}
 
1755
 
 
1756
\def\itemzzz #1{\begingroup %
 
1757
  \advance\hsize by -\rightskip
 
1758
  \advance\hsize by -\tableindent
 
1759
  \setbox0=\hbox{\itemfont{#1}}%
 
1760
  \itemindex{#1}%
 
1761
  \nobreak % This prevents a break before @itemx.
 
1762
  %
 
1763
  % If the item text does not fit in the space we have, put it on a line
 
1764
  % by itself, and do not allow a page break either before or after that
 
1765
  % line.  We do not start a paragraph here because then if the next
 
1766
  % command is, e.g., @kindex, the whatsit would get put into the
 
1767
  % horizontal list on a line by itself, resulting in extra blank space.
 
1768
  \ifdim \wd0>\itemmax
 
1769
    %
 
1770
    % Make this a paragraph so we get the \parskip glue and wrapping,
 
1771
    % but leave it ragged-right.
 
1772
    \begingroup
 
1773
      \advance\leftskip by-\tableindent
 
1774
      \advance\hsize by\tableindent
 
1775
      \advance\rightskip by0pt plus1fil
 
1776
      \leavevmode\unhbox0\par
 
1777
    \endgroup
 
1778
    %
 
1779
    % We're going to be starting a paragraph, but we don't want the
 
1780
    % \parskip glue -- logically it's part of the @item we just started.
 
1781
    \nobreak \vskip-\parskip
 
1782
    %
 
1783
    % Stop a page break at the \parskip glue coming up.  Unfortunately
 
1784
    % we can't prevent a possible page break at the following
 
1785
    % \baselineskip glue.
 
1786
    \nobreak
 
1787
    \endgroup
 
1788
    \itemxneedsnegativevskipfalse
 
1789
  \else
 
1790
    % The item text fits into the space.  Start a paragraph, so that the
 
1791
    % following text (if any) will end up on the same line.
 
1792
    \noindent
 
1793
    % Do this with kerns and \unhbox so that if there is a footnote in
 
1794
    % the item text, it can migrate to the main vertical list and
 
1795
    % eventually be printed.
 
1796
    \nobreak\kern-\tableindent
 
1797
    \dimen0 = \itemmax  \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0
 
1798
    \unhbox0
 
1799
    \nobreak\kern\dimen0
 
1800
    \endgroup
 
1801
    \itemxneedsnegativevskiptrue
 
1802
  \fi
 
1803
}
 
1804
 
 
1805
\def\item{\errmessage{@item while not in a table}}
 
1806
\def\itemx{\errmessage{@itemx while not in a table}}
 
1807
\def\kitem{\errmessage{@kitem while not in a table}}
 
1808
\def\kitemx{\errmessage{@kitemx while not in a table}}
 
1809
\def\xitem{\errmessage{@xitem while not in a table}}
 
1810
\def\xitemx{\errmessage{@xitemx while not in a table}}
 
1811
 
 
1812
% Contains a kludge to get @end[description] to work.
 
1813
\def\description{\tablez{\dontindex}{1}{}{}{}{}}
 
1814
 
 
1815
% @table, @ftable, @vtable.
 
1816
\def\table{\begingroup\inENV\obeylines\obeyspaces\tablex}
 
1817
{\obeylines\obeyspaces%
 
1818
\gdef\tablex #1^^M{%
 
1819
\tabley\dontindex#1        \endtabley}}
 
1820
 
 
1821
\def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex}
 
1822
{\obeylines\obeyspaces%
 
1823
\gdef\ftablex #1^^M{%
 
1824
\tabley\fnitemindex#1        \endtabley
 
1825
\def\Eftable{\endgraf\afterenvbreak\endgroup}%
 
1826
\let\Etable=\relax}}
 
1827
 
 
1828
\def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex}
 
1829
{\obeylines\obeyspaces%
 
1830
\gdef\vtablex #1^^M{%
 
1831
\tabley\vritemindex#1        \endtabley
 
1832
\def\Evtable{\endgraf\afterenvbreak\endgroup}%
 
1833
\let\Etable=\relax}}
 
1834
 
 
1835
\def\dontindex #1{}
 
1836
\def\fnitemindex #1{\doind {fn}{\code{#1}}}%
 
1837
\def\vritemindex #1{\doind {vr}{\code{#1}}}%
 
1838
 
 
1839
{\obeyspaces %
 
1840
\gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup%
 
1841
\tablez{#1}{#2}{#3}{#4}{#5}{#6}}}
 
1842
 
 
1843
\def\tablez #1#2#3#4#5#6{%
 
1844
\aboveenvbreak %
 
1845
\begingroup %
 
1846
\def\Edescription{\Etable}% Necessary kludge.
 
1847
\let\itemindex=#1%
 
1848
\ifnum 0#3>0 \advance \leftskip by #3\mil \fi %
 
1849
\ifnum 0#4>0 \tableindent=#4\mil \fi %
 
1850
\ifnum 0#5>0 \advance \rightskip by #5\mil \fi %
 
1851
\def\itemfont{#2}%
 
1852
\itemmax=\tableindent %
 
1853
\advance \itemmax by -\itemmargin %
 
1854
\advance \leftskip by \tableindent %
 
1855
\exdentamount=\tableindent
 
1856
\parindent = 0pt
 
1857
\parskip = \smallskipamount
 
1858
\ifdim \parskip=0pt \parskip=2pt \fi%
 
1859
\def\Etable{\endgraf\afterenvbreak\endgroup}%
 
1860
\let\item = \internalBitem %
 
1861
\let\itemx = \internalBitemx %
 
1862
\let\kitem = \internalBkitem %
 
1863
\let\kitemx = \internalBkitemx %
 
1864
\let\xitem = \internalBxitem %
 
1865
\let\xitemx = \internalBxitemx %
 
1866
}
 
1867
 
 
1868
% This is the counter used by @enumerate, which is really @itemize
 
1869
 
 
1870
\newcount \itemno
 
1871
 
 
1872
\def\itemize{\parsearg\itemizezzz}
 
1873
 
 
1874
\def\itemizezzz #1{%
 
1875
  \begingroup % ended by the @end itemize
 
1876
  \itemizey {#1}{\Eitemize}
 
1877
}
 
1878
 
 
1879
\def\itemizey #1#2{%
 
1880
\aboveenvbreak %
 
1881
\itemmax=\itemindent %
 
1882
\advance \itemmax by -\itemmargin %
 
1883
\advance \leftskip by \itemindent %
 
1884
\exdentamount=\itemindent
 
1885
\parindent = 0pt %
 
1886
\parskip = \smallskipamount %
 
1887
\ifdim \parskip=0pt \parskip=2pt \fi%
 
1888
\def#2{\endgraf\afterenvbreak\endgroup}%
 
1889
\def\itemcontents{#1}%
 
1890
\let\item=\itemizeitem}
 
1891
 
 
1892
% Set sfcode to normal for the chars that usually have another value.
 
1893
% These are `.?!:;,'
 
1894
\def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000
 
1895
  \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 }
 
1896
 
 
1897
% \splitoff TOKENS\endmark defines \first to be the first token in
 
1898
% TOKENS, and \rest to be the remainder.
 
1899
%
 
1900
\def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
 
1901
 
 
1902
% Allow an optional argument of an uppercase letter, lowercase letter,
 
1903
% or number, to specify the first label in the enumerated list.  No
 
1904
% argument is the same as `1'.
 
1905
%
 
1906
\def\enumerate{\parsearg\enumeratezzz}
 
1907
\def\enumeratezzz #1{\enumeratey #1  \endenumeratey}
 
1908
\def\enumeratey #1 #2\endenumeratey{%
 
1909
  \begingroup % ended by the @end enumerate
 
1910
  %
 
1911
  % If we were given no argument, pretend we were given `1'.
 
1912
  \def\thearg{#1}%
 
1913
  \ifx\thearg\empty \def\thearg{1}\fi
 
1914
  %
 
1915
  % Detect if the argument is a single token.  If so, it might be a
 
1916
  % letter.  Otherwise, the only valid thing it can be is a number.
 
1917
  % (We will always have one token, because of the test we just made.
 
1918
  % This is a good thing, since \splitoff doesn't work given nothing at
 
1919
  % all -- the first parameter is undelimited.)
 
1920
  \expandafter\splitoff\thearg\endmark
 
1921
  \ifx\rest\empty
 
1922
    % Only one token in the argument.  It could still be anything.
 
1923
    % A ``lowercase letter'' is one whose \lccode is nonzero.
 
1924
    % An ``uppercase letter'' is one whose \lccode is both nonzero, and
 
1925
    %   not equal to itself.
 
1926
    % Otherwise, we assume it's a number.
 
1927
    %
 
1928
    % We need the \relax at the end of the \ifnum lines to stop TeX from
 
1929
    % continuing to look for a <number>.
 
1930
    %
 
1931
    \ifnum\lccode\expandafter`\thearg=0\relax
 
1932
      \numericenumerate % a number (we hope)
 
1933
    \else
 
1934
      % It's a letter.
 
1935
      \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
 
1936
        \lowercaseenumerate % lowercase letter
 
1937
      \else
 
1938
        \uppercaseenumerate % uppercase letter
 
1939
      \fi
 
1940
    \fi
 
1941
  \else
 
1942
    % Multiple tokens in the argument.  We hope it's a number.
 
1943
    \numericenumerate
 
1944
  \fi
 
1945
}
 
1946
 
 
1947
% An @enumerate whose labels are integers.  The starting integer is
 
1948
% given in \thearg.
 
1949
%
 
1950
\def\numericenumerate{%
 
1951
  \itemno = \thearg
 
1952
  \startenumeration{\the\itemno}%
 
1953
}
 
1954
 
 
1955
% The starting (lowercase) letter is in \thearg.
 
1956
\def\lowercaseenumerate{%
 
1957
  \itemno = \expandafter`\thearg
 
1958
  \startenumeration{%
 
1959
    % Be sure we're not beyond the end of the alphabet.
 
1960
    \ifnum\itemno=0
 
1961
      \errmessage{No more lowercase letters in @enumerate; get a bigger
 
1962
                  alphabet}%
 
1963
    \fi
 
1964
    \char\lccode\itemno
 
1965
  }%
 
1966
}
 
1967
 
 
1968
% The starting (uppercase) letter is in \thearg.
 
1969
\def\uppercaseenumerate{%
 
1970
  \itemno = \expandafter`\thearg
 
1971
  \startenumeration{%
 
1972
    % Be sure we're not beyond the end of the alphabet.
 
1973
    \ifnum\itemno=0
 
1974
      \errmessage{No more uppercase letters in @enumerate; get a bigger
 
1975
                  alphabet}
 
1976
    \fi
 
1977
    \char\uccode\itemno
 
1978
  }%
 
1979
}
 
1980
 
 
1981
% Call itemizey, adding a period to the first argument and supplying the
 
1982
% common last two arguments.  Also subtract one from the initial value in
 
1983
% \itemno, since @item increments \itemno.
 
1984
%
 
1985
\def\startenumeration#1{%
 
1986
  \advance\itemno by -1
 
1987
  \itemizey{#1.}\Eenumerate\flushcr
 
1988
}
 
1989
 
 
1990
% @alphaenumerate and @capsenumerate are abbreviations for giving an arg
 
1991
% to @enumerate.
 
1992
%
 
1993
\def\alphaenumerate{\enumerate{a}}
 
1994
\def\capsenumerate{\enumerate{A}}
 
1995
\def\Ealphaenumerate{\Eenumerate}
 
1996
\def\Ecapsenumerate{\Eenumerate}
 
1997
 
 
1998
% Definition of @item while inside @itemize.
 
1999
 
 
2000
\def\itemizeitem{%
 
2001
\advance\itemno by 1
 
2002
{\let\par=\endgraf \smallbreak}%
 
2003
\ifhmode \errmessage{In hmode at itemizeitem}\fi
 
2004
{\parskip=0in \hskip 0pt
 
2005
\hbox to 0pt{\hss \itemcontents\hskip \itemmargin}%
 
2006
\vadjust{\penalty 1200}}%
 
2007
\flushcr}
 
2008
 
 
2009
% @multitable macros
 
2010
% Amy Hendrickson, 8/18/94, 3/6/96
 
2011
%
 
2012
% @multitable ... @end multitable will make as many columns as desired.
 
2013
% Contents of each column will wrap at width given in preamble.  Width
 
2014
% can be specified either with sample text given in a template line,
 
2015
% or in percent of \hsize, the current width of text on page.
 
2016
 
 
2017
% Table can continue over pages but will only break between lines.
 
2018
 
 
2019
% To make preamble:
 
2020
%
 
2021
% Either define widths of columns in terms of percent of \hsize:
 
2022
%   @multitable @columnfractions .25 .3 .45
 
2023
%   @item ...
 
2024
%
 
2025
%   Numbers following @columnfractions are the percent of the total
 
2026
%   current hsize to be used for each column. You may use as many
 
2027
%   columns as desired.
 
2028
 
 
2029
 
 
2030
% Or use a template:
 
2031
%   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
 
2032
%   @item ...
 
2033
%   using the widest term desired in each column.
 
2034
%
 
2035
% For those who want to use more than one line's worth of words in
 
2036
% the preamble, break the line within one argument and it
 
2037
% will parse correctly, i.e.,
 
2038
%
 
2039
%     @multitable {Column 1 template} {Column 2 template} {Column 3
 
2040
%      template}
 
2041
% Not:
 
2042
%     @multitable {Column 1 template} {Column 2 template}
 
2043
%      {Column 3 template}
 
2044
 
 
2045
% Each new table line starts with @item, each subsequent new column
 
2046
% starts with @tab. Empty columns may be produced by supplying @tab's
 
2047
% with nothing between them for as many times as empty columns are needed,
 
2048
% ie, @tab@tab@tab will produce two empty columns.
 
2049
 
 
2050
% @item, @tab, @multitable or @end multitable do not need to be on their
 
2051
% own lines, but it will not hurt if they are.
 
2052
 
 
2053
% Sample multitable:
 
2054
 
 
2055
%   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
 
2056
%   @item first col stuff @tab second col stuff @tab third col
 
2057
%   @item
 
2058
%   first col stuff
 
2059
%   @tab
 
2060
%   second col stuff
 
2061
%   @tab
 
2062
%   third col
 
2063
%   @item first col stuff @tab second col stuff
 
2064
%   @tab Many paragraphs of text may be used in any column.
 
2065
%
 
2066
%         They will wrap at the width determined by the template.
 
2067
%   @item@tab@tab This will be in third column.
 
2068
%   @end multitable
 
2069
 
 
2070
% Default dimensions may be reset by user.
 
2071
% @multitableparskip is vertical space between paragraphs in table.
 
2072
% @multitableparindent is paragraph indent in table.
 
2073
% @multitablecolmargin is horizontal space to be left between columns.
 
2074
% @multitablelinespace is space to leave between table items, baseline
 
2075
%                                                            to baseline.
 
2076
%   0pt means it depends on current normal line spacing.
 
2077
%
 
2078
\newskip\multitableparskip
 
2079
\newskip\multitableparindent
 
2080
\newdimen\multitablecolspace
 
2081
\newskip\multitablelinespace
 
2082
\multitableparskip=0pt
 
2083
\multitableparindent=6pt
 
2084
\multitablecolspace=12pt
 
2085
\multitablelinespace=0pt
 
2086
 
 
2087
% Macros used to set up halign preamble:
 
2088
%
 
2089
\let\endsetuptable\relax
 
2090
\def\xendsetuptable{\endsetuptable}
 
2091
\let\columnfractions\relax
 
2092
\def\xcolumnfractions{\columnfractions}
 
2093
\newif\ifsetpercent
 
2094
 
 
2095
% #1 is the part of the @columnfraction before the decimal point, which
 
2096
% is presumably either 0 or the empty string (but we don't check, we
 
2097
% just throw it away).  #2 is the decimal part, which we use as the
 
2098
% percent of \hsize for this column.
 
2099
\def\pickupwholefraction#1.#2 {%
 
2100
  \global\advance\colcount by 1
 
2101
  \expandafter\xdef\csname col\the\colcount\endcsname{.#2\hsize}%
 
2102
  \setuptable
 
2103
}
 
2104
 
 
2105
\newcount\colcount
 
2106
\def\setuptable#1{%
 
2107
  \def\firstarg{#1}%
 
2108
  \ifx\firstarg\xendsetuptable
 
2109
    \let\go = \relax
 
2110
  \else
 
2111
    \ifx\firstarg\xcolumnfractions
 
2112
      \global\setpercenttrue
 
2113
    \else
 
2114
      \ifsetpercent
 
2115
         \let\go\pickupwholefraction
 
2116
      \else
 
2117
         \global\advance\colcount by 1
 
2118
         \setbox0=\hbox{#1\unskip }% Add a normal word space as a separator;
 
2119
                            % typically that is always in the input, anyway.
 
2120
         \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
 
2121
      \fi
 
2122
    \fi
 
2123
    \ifx\go\pickupwholefraction
 
2124
      % Put the argument back for the \pickupwholefraction call, so
 
2125
      % we'll always have a period there to be parsed.
 
2126
      \def\go{\pickupwholefraction#1}%
 
2127
    \else
 
2128
      \let\go = \setuptable
 
2129
    \fi%
 
2130
  \fi
 
2131
  \go
 
2132
}
 
2133
 
 
2134
% This used to have \hskip1sp.  But then the space in a template line is
 
2135
% not enough.  That is bad.  So let's go back to just & until we
 
2136
% encounter the problem it was intended to solve again.
 
2137
% --karl, nathan@acm.org, 20apr99.
 
2138
\def\tab{&}
 
2139
 
 
2140
% @multitable ... @end multitable definitions:
 
2141
%
 
2142
\def\multitable{\parsearg\dotable}
 
2143
\def\dotable#1{\bgroup
 
2144
  \vskip\parskip
 
2145
  \let\item\crcr
 
2146
  \tolerance=9500
 
2147
  \hbadness=9500
 
2148
  \setmultitablespacing
 
2149
  \parskip=\multitableparskip
 
2150
  \parindent=\multitableparindent
 
2151
  \overfullrule=0pt
 
2152
  \global\colcount=0
 
2153
  \def\Emultitable{\global\setpercentfalse\cr\egroup\egroup}%
 
2154
  %
 
2155
  % To parse everything between @multitable and @item:
 
2156
  \setuptable#1 \endsetuptable
 
2157
  %
 
2158
  % \everycr will reset column counter, \colcount, at the end of
 
2159
  % each line. Every column entry will cause \colcount to advance by one.
 
2160
  % The table preamble
 
2161
  % looks at the current \colcount to find the correct column width.
 
2162
  \everycr{\noalign{%
 
2163
  %
 
2164
  % \filbreak%% keeps underfull box messages off when table breaks over pages.
 
2165
  % Maybe so, but it also creates really weird page breaks when the table
 
2166
  % breaks over pages. Wouldn't \vfil be better?  Wait until the problem
 
2167
  % manifests itself, so it can be fixed for real --karl.
 
2168
    \global\colcount=0\relax}}%
 
2169
  %
 
2170
  % This preamble sets up a generic column definition, which will
 
2171
  % be used as many times as user calls for columns.
 
2172
  % \vtop will set a single line and will also let text wrap and
 
2173
  % continue for many paragraphs if desired.
 
2174
  \halign\bgroup&\global\advance\colcount by 1\relax
 
2175
    \multistrut\vtop{\hsize=\expandafter\csname col\the\colcount\endcsname
 
2176
  %
 
2177
  % In order to keep entries from bumping into each other
 
2178
  % we will add a \leftskip of \multitablecolspace to all columns after
 
2179
  % the first one.
 
2180
  %
 
2181
  % If a template has been used, we will add \multitablecolspace
 
2182
  % to the width of each template entry.
 
2183
  %
 
2184
  % If the user has set preamble in terms of percent of \hsize we will
 
2185
  % use that dimension as the width of the column, and the \leftskip
 
2186
  % will keep entries from bumping into each other.  Table will start at
 
2187
  % left margin and final column will justify at right margin.
 
2188
  %
 
2189
  % Make sure we don't inherit \rightskip from the outer environment.
 
2190
  \rightskip=0pt
 
2191
  \ifnum\colcount=1
 
2192
    % The first column will be indented with the surrounding text.
 
2193
    \advance\hsize by\leftskip
 
2194
  \else
 
2195
    \ifsetpercent \else
 
2196
      % If user has not set preamble in terms of percent of \hsize
 
2197
      % we will advance \hsize by \multitablecolspace.
 
2198
      \advance\hsize by \multitablecolspace
 
2199
    \fi
 
2200
   % In either case we will make \leftskip=\multitablecolspace:
 
2201
  \leftskip=\multitablecolspace
 
2202
  \fi
 
2203
  % Ignoring space at the beginning and end avoids an occasional spurious
 
2204
  % blank line, when TeX decides to break the line at the space before the
 
2205
  % box from the multistrut, so the strut ends up on a line by itself.
 
2206
  % For example:
 
2207
  % @multitable @columnfractions .11 .89
 
2208
  % @item @code{#}
 
2209
  % @tab Legal holiday which is valid in major parts of the whole country.
 
2210
  % Is automatically provided with highlighting sequences respectively marking
 
2211
  % characters.
 
2212
  \noindent\ignorespaces##\unskip\multistrut}\cr
 
2213
}
 
2214
 
 
2215
\def\setmultitablespacing{% test to see if user has set \multitablelinespace.
 
2216
% If so, do nothing. If not, give it an appropriate dimension based on
 
2217
% current baselineskip.
 
2218
\ifdim\multitablelinespace=0pt
 
2219
\setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip
 
2220
\global\advance\multitablelinespace by-\ht0
 
2221
%% strut to put in table in case some entry doesn't have descenders,
 
2222
%% to keep lines equally spaced
 
2223
\let\multistrut = \strut
 
2224
\else
 
2225
%% FIXME: what is \box0 supposed to be?
 
2226
\gdef\multistrut{\vrule height\multitablelinespace depth\dp0
 
2227
width0pt\relax} \fi
 
2228
%% Test to see if parskip is larger than space between lines of
 
2229
%% table. If not, do nothing.
 
2230
%%        If so, set to same dimension as multitablelinespace.
 
2231
\ifdim\multitableparskip>\multitablelinespace
 
2232
\global\multitableparskip=\multitablelinespace
 
2233
\global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller
 
2234
                                      %% than skip between lines in the table.
 
2235
\fi%
 
2236
\ifdim\multitableparskip=0pt
 
2237
\global\multitableparskip=\multitablelinespace
 
2238
\global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller
 
2239
                                      %% than skip between lines in the table.
 
2240
\fi}
 
2241
 
 
2242
 
 
2243
\message{conditionals,}
 
2244
% Prevent errors for section commands.
 
2245
% Used in @ignore and in failing conditionals.
 
2246
\def\ignoresections{%
 
2247
  \let\chapter=\relax
 
2248
  \let\unnumbered=\relax
 
2249
  \let\top=\relax
 
2250
  \let\unnumberedsec=\relax
 
2251
  \let\unnumberedsection=\relax
 
2252
  \let\unnumberedsubsec=\relax
 
2253
  \let\unnumberedsubsection=\relax
 
2254
  \let\unnumberedsubsubsec=\relax
 
2255
  \let\unnumberedsubsubsection=\relax
 
2256
  \let\section=\relax
 
2257
  \let\subsec=\relax
 
2258
  \let\subsubsec=\relax
 
2259
  \let\subsection=\relax
 
2260
  \let\subsubsection=\relax
 
2261
  \let\appendix=\relax
 
2262
  \let\appendixsec=\relax
 
2263
  \let\appendixsection=\relax
 
2264
  \let\appendixsubsec=\relax
 
2265
  \let\appendixsubsection=\relax
 
2266
  \let\appendixsubsubsec=\relax
 
2267
  \let\appendixsubsubsection=\relax
 
2268
  \let\contents=\relax
 
2269
  \let\smallbook=\relax
 
2270
  \let\titlepage=\relax
 
2271
}
 
2272
 
 
2273
% Used in nested conditionals, where we have to parse the Texinfo source
 
2274
% and so want to turn off most commands, in case they are used
 
2275
% incorrectly.
 
2276
%
 
2277
\def\ignoremorecommands{%
 
2278
  \let\defcodeindex = \relax
 
2279
  \let\defcv = \relax
 
2280
  \let\deffn = \relax
 
2281
  \let\deffnx = \relax
 
2282
  \let\defindex = \relax
 
2283
  \let\defivar = \relax
 
2284
  \let\defmac = \relax
 
2285
  \let\defmethod = \relax
 
2286
  \let\defop = \relax
 
2287
  \let\defopt = \relax
 
2288
  \let\defspec = \relax
 
2289
  \let\deftp = \relax
 
2290
  \let\deftypefn = \relax
 
2291
  \let\deftypefun = \relax
 
2292
  \let\deftypeivar = \relax
 
2293
  \let\deftypeop = \relax
 
2294
  \let\deftypevar = \relax
 
2295
  \let\deftypevr = \relax
 
2296
  \let\defun = \relax
 
2297
  \let\defvar = \relax
 
2298
  \let\defvr = \relax
 
2299
  \let\ref = \relax
 
2300
  \let\xref = \relax
 
2301
  \let\printindex = \relax
 
2302
  \let\pxref = \relax
 
2303
  \let\settitle = \relax
 
2304
  \let\setchapternewpage = \relax
 
2305
  \let\setchapterstyle = \relax
 
2306
  \let\everyheading = \relax
 
2307
  \let\evenheading = \relax
 
2308
  \let\oddheading = \relax
 
2309
  \let\everyfooting = \relax
 
2310
  \let\evenfooting = \relax
 
2311
  \let\oddfooting = \relax
 
2312
  \let\headings = \relax
 
2313
  \let\include = \relax
 
2314
  \let\lowersections = \relax
 
2315
  \let\down = \relax
 
2316
  \let\raisesections = \relax
 
2317
  \let\up = \relax
 
2318
  \let\set = \relax
 
2319
  \let\clear = \relax
 
2320
  \let\item = \relax
 
2321
}
 
2322
 
 
2323
% Ignore @ignore ... @end ignore.
 
2324
%
 
2325
\def\ignore{\doignore{ignore}}
 
2326
 
 
2327
% Ignore @ifinfo, @ifhtml, @ifnottex, @html, @menu, and @direntry text.
 
2328
%
 
2329
\def\ifinfo{\doignore{ifinfo}}
 
2330
\def\ifhtml{\doignore{ifhtml}}
 
2331
\def\ifnottex{\doignore{ifnottex}}
 
2332
\def\html{\doignore{html}}
 
2333
\def\menu{\doignore{menu}}
 
2334
\def\direntry{\doignore{direntry}}
 
2335
 
 
2336
% @dircategory CATEGORY  -- specify a category of the dir file
 
2337
% which this file should belong to.  Ignore this in TeX.
 
2338
\let\dircategory = \comment
 
2339
 
 
2340
% Ignore text until a line `@end #1'.
 
2341
%
 
2342
\def\doignore#1{\begingroup
 
2343
  % Don't complain about control sequences we have declared \outer.
 
2344
  \ignoresections
 
2345
  %
 
2346
  % Define a command to swallow text until we reach `@end #1'.
 
2347
  % This @ is a catcode 12 token (that is the normal catcode of @ in
 
2348
  % this texinfo.tex file).  We change the catcode of @ below to match.
 
2349
  \long\def\doignoretext##1@end #1{\enddoignore}%
 
2350
  %
 
2351
  % Make sure that spaces turn into tokens that match what \doignoretext wants.
 
2352
  \catcode32 = 10
 
2353
  %
 
2354
  % Ignore braces, too, so mismatched braces don't cause trouble.
 
2355
  \catcode`\{ = 9
 
2356
  \catcode`\} = 9
 
2357
  %
 
2358
  % We must not have @c interpreted as a control sequence.
 
2359
  \catcode`\@ = 12
 
2360
  %
 
2361
  % Make the letter c a comment character so that the rest of the line
 
2362
  % will be ignored. This way, the document can have (for example)
 
2363
  %   @c @end ifinfo
 
2364
  % and the @end ifinfo will be properly ignored.
 
2365
  % (We've just changed @ to catcode 12.)
 
2366
  \catcode`\c = 14
 
2367
  %
 
2368
  % And now expand that command.
 
2369
  \doignoretext
 
2370
}
 
2371
 
 
2372
% What we do to finish off ignored text.
 
2373
%
 
2374
\def\enddoignore{\endgroup\ignorespaces}%
 
2375
 
 
2376
\newif\ifwarnedobs\warnedobsfalse
 
2377
\def\obstexwarn{%
 
2378
  \ifwarnedobs\relax\else
 
2379
  % We need to warn folks that they may have trouble with TeX 3.0.
 
2380
  % This uses \immediate\write16 rather than \message to get newlines.
 
2381
    \immediate\write16{}
 
2382
    \immediate\write16{WARNING: for users of Unix TeX 3.0!}
 
2383
    \immediate\write16{This manual trips a bug in TeX version 3.0 (tex hangs).}
 
2384
    \immediate\write16{If you are running another version of TeX, relax.}
 
2385
    \immediate\write16{If you are running Unix TeX 3.0, kill this TeX process.}
 
2386
    \immediate\write16{  Then upgrade your TeX installation if you can.}
 
2387
    \immediate\write16{  (See ftp://ftp.gnu.org/pub/gnu/TeX.README.)}
 
2388
    \immediate\write16{If you are stuck with version 3.0, run the}
 
2389
    \immediate\write16{  script ``tex3patch'' from the Texinfo distribution}
 
2390
    \immediate\write16{  to use a workaround.}
 
2391
    \immediate\write16{}
 
2392
    \global\warnedobstrue
 
2393
    \fi
 
2394
}
 
2395
 
 
2396
% **In TeX 3.0, setting text in \nullfont hangs tex.  For a
 
2397
% workaround (which requires the file ``dummy.tfm'' to be installed),
 
2398
% uncomment the following line:
 
2399
%%%%%\font\nullfont=dummy\let\obstexwarn=\relax
 
2400
 
 
2401
% Ignore text, except that we keep track of conditional commands for
 
2402
% purposes of nesting, up to an `@end #1' command.
 
2403
%
 
2404
\def\nestedignore#1{%
 
2405
  \obstexwarn
 
2406
  % We must actually expand the ignored text to look for the @end
 
2407
  % command, so that nested ignore constructs work.  Thus, we put the
 
2408
  % text into a \vbox and then do nothing with the result.  To minimize
 
2409
  % the change of memory overflow, we follow the approach outlined on
 
2410
  % page 401 of the TeXbook: make the current font be a dummy font.
 
2411
  %
 
2412
  \setbox0 = \vbox\bgroup
 
2413
    % Don't complain about control sequences we have declared \outer.
 
2414
    \ignoresections
 
2415
    %
 
2416
    % Define `@end #1' to end the box, which will in turn undefine the
 
2417
    % @end command again.
 
2418
    \expandafter\def\csname E#1\endcsname{\egroup\ignorespaces}%
 
2419
    %
 
2420
    % We are going to be parsing Texinfo commands.  Most cause no
 
2421
    % trouble when they are used incorrectly, but some commands do
 
2422
    % complicated argument parsing or otherwise get confused, so we
 
2423
    % undefine them.
 
2424
    %
 
2425
    % We can't do anything about stray @-signs, unfortunately;
 
2426
    % they'll produce `undefined control sequence' errors.
 
2427
    \ignoremorecommands
 
2428
    %
 
2429
    % Set the current font to be \nullfont, a TeX primitive, and define
 
2430
    % all the font commands to also use \nullfont.  We don't use
 
2431
    % dummy.tfm, as suggested in the TeXbook, because not all sites
 
2432
    % might have that installed.  Therefore, math mode will still
 
2433
    % produce output, but that should be an extremely small amount of
 
2434
    % stuff compared to the main input.
 
2435
    %
 
2436
    \nullfont
 
2437
    \let\tenrm=\nullfont \let\tenit=\nullfont \let\tensl=\nullfont
 
2438
    \let\tenbf=\nullfont \let\tentt=\nullfont \let\smallcaps=\nullfont
 
2439
    \let\tensf=\nullfont
 
2440
    % Similarly for index fonts (mostly for their use in smallexample).
 
2441
    \let\smallrm=\nullfont \let\smallit=\nullfont \let\smallsl=\nullfont
 
2442
    \let\smallbf=\nullfont \let\smalltt=\nullfont \let\smallsc=\nullfont
 
2443
    \let\smallsf=\nullfont
 
2444
    %
 
2445
    % Don't complain when characters are missing from the fonts.
 
2446
    \tracinglostchars = 0
 
2447
    %
 
2448
    % Don't bother to do space factor calculations.
 
2449
    \frenchspacing
 
2450
    %
 
2451
    % Don't report underfull hboxes.
 
2452
    \hbadness = 10000
 
2453
    %
 
2454
    % Do minimal line-breaking.
 
2455
    \pretolerance = 10000
 
2456
    %
 
2457
    % Do not execute instructions in @tex
 
2458
    \def\tex{\doignore{tex}}%
 
2459
    % Do not execute macro definitions.
 
2460
    % `c' is a comment character, so the word `macro' will get cut off.
 
2461
    \def\macro{\doignore{ma}}%
 
2462
}
 
2463
 
 
2464
% @set VAR sets the variable VAR to an empty value.
 
2465
% @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
 
2466
%
 
2467
% Since we want to separate VAR from REST-OF-LINE (which might be
 
2468
% empty), we can't just use \parsearg; we have to insert a space of our
 
2469
% own to delimit the rest of the line, and then take it out again if we
 
2470
% didn't need it.  Make sure the catcode of space is correct to avoid
 
2471
% losing inside @example, for instance.
 
2472
%
 
2473
\def\set{\begingroup\catcode` =10
 
2474
  \catcode`\-=12 \catcode`\_=12 % Allow - and _ in VAR.
 
2475
  \parsearg\setxxx}
 
2476
\def\setxxx#1{\setyyy#1 \endsetyyy}
 
2477
\def\setyyy#1 #2\endsetyyy{%
 
2478
  \def\temp{#2}%
 
2479
  \ifx\temp\empty \global\expandafter\let\csname SET#1\endcsname = \empty
 
2480
  \else \setzzz{#1}#2\endsetzzz % Remove the trailing space \setxxx inserted.
 
2481
  \fi
 
2482
  \endgroup
 
2483
}
 
2484
% Can't use \xdef to pre-expand #2 and save some time, since \temp or
 
2485
% \next or other control sequences that we've defined might get us into
 
2486
% an infinite loop. Consider `@set foo @cite{bar}'.
 
2487
\def\setzzz#1#2 \endsetzzz{\expandafter\gdef\csname SET#1\endcsname{#2}}
 
2488
 
 
2489
% @clear VAR clears (i.e., unsets) the variable VAR.
 
2490
%
 
2491
\def\clear{\parsearg\clearxxx}
 
2492
\def\clearxxx#1{\global\expandafter\let\csname SET#1\endcsname=\relax}
 
2493
 
 
2494
% @value{foo} gets the text saved in variable foo.
 
2495
{
 
2496
  \catcode`\_ = \active
 
2497
  %
 
2498
  % We might end up with active _ or - characters in the argument if
 
2499
  % we're called from @code, as @code{@value{foo-bar_}}.  So \let any
 
2500
  % such active characters to their normal equivalents.
 
2501
  \gdef\value{\begingroup
 
2502
    \catcode`\-=12 \catcode`\_=12
 
2503
    \indexbreaks \let_\normalunderscore
 
2504
    \valuexxx}
 
2505
}
 
2506
\def\valuexxx#1{\expandablevalue{#1}\endgroup}
 
2507
 
 
2508
% We have this subroutine so that we can handle at least some @value's
 
2509
% properly in indexes (we \let\value to this in \indexdummies).  Ones
 
2510
% whose names contain - or _ still won't work, but we can't do anything
 
2511
% about that.  The command has to be fully expandable, since the result
 
2512
% winds up in the index file.  This means that if the variable's value
 
2513
% contains other Texinfo commands, it's almost certain it will fail
 
2514
% (although perhaps we could fix that with sufficient work to do a
 
2515
% one-level expansion on the result, instead of complete).
 
2516
%
 
2517
\def\expandablevalue#1{%
 
2518
  \expandafter\ifx\csname SET#1\endcsname\relax
 
2519
    {[No value for ``#1'']}%
 
2520
  \else
 
2521
    \csname SET#1\endcsname
 
2522
  \fi
 
2523
}
 
2524
 
 
2525
% @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
 
2526
% with @set.
 
2527
%
 
2528
\def\ifset{\parsearg\ifsetxxx}
 
2529
\def\ifsetxxx #1{%
 
2530
  \expandafter\ifx\csname SET#1\endcsname\relax
 
2531
    \expandafter\ifsetfail
 
2532
  \else
 
2533
    \expandafter\ifsetsucceed
 
2534
  \fi
 
2535
}
 
2536
\def\ifsetsucceed{\conditionalsucceed{ifset}}
 
2537
\def\ifsetfail{\nestedignore{ifset}}
 
2538
\defineunmatchedend{ifset}
 
2539
 
 
2540
% @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been
 
2541
% defined with @set, or has been undefined with @clear.
 
2542
%
 
2543
\def\ifclear{\parsearg\ifclearxxx}
 
2544
\def\ifclearxxx #1{%
 
2545
  \expandafter\ifx\csname SET#1\endcsname\relax
 
2546
    \expandafter\ifclearsucceed
 
2547
  \else
 
2548
    \expandafter\ifclearfail
 
2549
  \fi
 
2550
}
 
2551
\def\ifclearsucceed{\conditionalsucceed{ifclear}}
 
2552
\def\ifclearfail{\nestedignore{ifclear}}
 
2553
\defineunmatchedend{ifclear}
 
2554
 
 
2555
% @iftex, @ifnothtml, @ifnotinfo always succeed; we read the text
 
2556
% following, through the first @end iftex (etc.).  Make `@end iftex'
 
2557
% (etc.) valid only after an @iftex.
 
2558
%
 
2559
\def\iftex{\conditionalsucceed{iftex}}
 
2560
\def\ifnothtml{\conditionalsucceed{ifnothtml}}
 
2561
\def\ifnotinfo{\conditionalsucceed{ifnotinfo}}
 
2562
\defineunmatchedend{iftex}
 
2563
\defineunmatchedend{ifnothtml}
 
2564
\defineunmatchedend{ifnotinfo}
 
2565
 
 
2566
% We can't just want to start a group at @iftex (for example) and end it
 
2567
% at @end iftex, since then @set commands inside the conditional have no
 
2568
% effect (they'd get reverted at the end of the group).  So we must
 
2569
% define \Eiftex to redefine itself to be its previous value.  (We can't
 
2570
% just define it to fail again with an ``unmatched end'' error, since
 
2571
% the @ifset might be nested.)
 
2572
%
 
2573
\def\conditionalsucceed#1{%
 
2574
  \edef\temp{%
 
2575
    % Remember the current value of \E#1.
 
2576
    \let\nece{prevE#1} = \nece{E#1}%
 
2577
    %
 
2578
    % At the `@end #1', redefine \E#1 to be its previous value.
 
2579
    \def\nece{E#1}{\let\nece{E#1} = \nece{prevE#1}}%
 
2580
  }%
 
2581
  \temp
 
2582
}
 
2583
 
 
2584
% We need to expand lots of \csname's, but we don't want to expand the
 
2585
% control sequences after we've constructed them.
 
2586
%
 
2587
\def\nece#1{\expandafter\noexpand\csname#1\endcsname}
 
2588
 
 
2589
% @defininfoenclose.
 
2590
\let\definfoenclose=\comment
 
2591
 
 
2592
 
 
2593
\message{indexing,}
 
2594
% Index generation facilities
 
2595
 
 
2596
% Define \newwrite to be identical to plain tex's \newwrite
 
2597
% except not \outer, so it can be used within \newindex.
 
2598
{\catcode`\@=11
 
2599
\gdef\newwrite{\alloc@7\write\chardef\sixt@@n}}
 
2600
 
 
2601
% \newindex {foo} defines an index named foo.
 
2602
% It automatically defines \fooindex such that
 
2603
% \fooindex ...rest of line... puts an entry in the index foo.
 
2604
% It also defines \fooindfile to be the number of the output channel for
 
2605
% the file that accumulates this index.  The file's extension is foo.
 
2606
% The name of an index should be no more than 2 characters long
 
2607
% for the sake of vms.
 
2608
%
 
2609
\def\newindex#1{%
 
2610
  \iflinks
 
2611
    \expandafter\newwrite \csname#1indfile\endcsname
 
2612
    \openout \csname#1indfile\endcsname \jobname.#1 % Open the file
 
2613
  \fi
 
2614
  \expandafter\xdef\csname#1index\endcsname{%     % Define @#1index
 
2615
    \noexpand\doindex{#1}}
 
2616
}
 
2617
 
 
2618
% @defindex foo  ==  \newindex{foo}
 
2619
%
 
2620
\def\defindex{\parsearg\newindex}
 
2621
 
 
2622
% Define @defcodeindex, like @defindex except put all entries in @code.
 
2623
%
 
2624
\def\defcodeindex{\parsearg\newcodeindex}
 
2625
%
 
2626
\def\newcodeindex#1{%
 
2627
  \iflinks
 
2628
    \expandafter\newwrite \csname#1indfile\endcsname
 
2629
    \openout \csname#1indfile\endcsname \jobname.#1
 
2630
  \fi
 
2631
  \expandafter\xdef\csname#1index\endcsname{%
 
2632
    \noexpand\docodeindex{#1}}%
 
2633
}
 
2634
 
 
2635
 
 
2636
% @synindex foo bar    makes index foo feed into index bar.
 
2637
% Do this instead of @defindex foo if you don't want it as a separate index.
 
2638
 
2639
% @syncodeindex foo bar   similar, but put all entries made for index foo
 
2640
% inside @code.
 
2641
 
2642
\def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}}
 
2643
\def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}}
 
2644
 
 
2645
% #1 is \doindex or \docodeindex, #2 the index getting redefined (foo),
 
2646
% #3 the target index (bar).
 
2647
\def\dosynindex#1#2#3{%
 
2648
  % Only do \closeout if we haven't already done it, else we'll end up
 
2649
  % closing the target index.
 
2650
  \expandafter \ifx\csname donesynindex#2\endcsname \undefined
 
2651
    % The \closeout helps reduce unnecessary open files; the limit on the
 
2652
    % Acorn RISC OS is a mere 16 files.
 
2653
    \expandafter\closeout\csname#2indfile\endcsname
 
2654
    \expandafter\let\csname\donesynindex#2\endcsname = 1
 
2655
  \fi
 
2656
  % redefine \fooindfile:
 
2657
  \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname
 
2658
  \expandafter\let\csname#2indfile\endcsname=\temp
 
2659
  % redefine \fooindex:
 
2660
  \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}%
 
2661
}
 
2662
 
 
2663
% Define \doindex, the driver for all \fooindex macros.
 
2664
% Argument #1 is generated by the calling \fooindex macro,
 
2665
%  and it is "foo", the name of the index.
 
2666
 
 
2667
% \doindex just uses \parsearg; it calls \doind for the actual work.
 
2668
% This is because \doind is more useful to call from other macros.
 
2669
 
 
2670
% There is also \dosubind {index}{topic}{subtopic}
 
2671
% which makes an entry in a two-level index such as the operation index.
 
2672
 
 
2673
\def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer}
 
2674
\def\singleindexer #1{\doind{\indexname}{#1}}
 
2675
 
 
2676
% like the previous two, but they put @code around the argument.
 
2677
\def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
 
2678
\def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
 
2679
 
 
2680
\def\indexdummies{%
 
2681
\def\ { }%
 
2682
% Take care of the plain tex accent commands.
 
2683
\def\"{\realbackslash "}%
 
2684
\def\`{\realbackslash `}%
 
2685
\def\'{\realbackslash '}%
 
2686
\def\^{\realbackslash ^}%
 
2687
\def\~{\realbackslash ~}%
 
2688
\def\={\realbackslash =}%
 
2689
\def\b{\realbackslash b}%
 
2690
\def\c{\realbackslash c}%
 
2691
\def\d{\realbackslash d}%
 
2692
\def\u{\realbackslash u}%
 
2693
\def\v{\realbackslash v}%
 
2694
\def\H{\realbackslash H}%
 
2695
% Take care of the plain tex special European modified letters.
 
2696
\def\oe{\realbackslash oe}%
 
2697
\def\ae{\realbackslash ae}%
 
2698
\def\aa{\realbackslash aa}%
 
2699
\def\OE{\realbackslash OE}%
 
2700
\def\AE{\realbackslash AE}%
 
2701
\def\AA{\realbackslash AA}%
 
2702
\def\o{\realbackslash o}%
 
2703
\def\O{\realbackslash O}%
 
2704
\def\l{\realbackslash l}%
 
2705
\def\L{\realbackslash L}%
 
2706
\def\ss{\realbackslash ss}%
 
2707
% Take care of texinfo commands likely to appear in an index entry.
 
2708
% (Must be a way to avoid doing expansion at all, and thus not have to
 
2709
% laboriously list every single command here.)
 
2710
\def\@{@}% will be @@ when we switch to @ as escape char.
 
2711
% Need these in case \tex is in effect and \{ is a \delimiter again.
 
2712
% But can't use \lbracecmd and \rbracecmd because texindex assumes
 
2713
% braces and backslashes are used only as delimiters.  
 
2714
\let\{ = \mylbrace
 
2715
\let\} = \myrbrace
 
2716
\def\_{{\realbackslash _}}%
 
2717
\def\w{\realbackslash w }%
 
2718
\def\bf{\realbackslash bf }%
 
2719
%\def\rm{\realbackslash rm }%
 
2720
\def\sl{\realbackslash sl }%
 
2721
\def\sf{\realbackslash sf}%
 
2722
\def\tt{\realbackslash tt}%
 
2723
\def\gtr{\realbackslash gtr}%
 
2724
\def\less{\realbackslash less}%
 
2725
\def\hat{\realbackslash hat}%
 
2726
\def\TeX{\realbackslash TeX}%
 
2727
\def\dots{\realbackslash dots }%
 
2728
\def\result{\realbackslash result}%
 
2729
\def\equiv{\realbackslash equiv}%
 
2730
\def\expansion{\realbackslash expansion}%
 
2731
\def\print{\realbackslash print}%
 
2732
\def\error{\realbackslash error}%
 
2733
\def\point{\realbackslash point}%
 
2734
\def\copyright{\realbackslash copyright}%
 
2735
\def\tclose##1{\realbackslash tclose {##1}}%
 
2736
\def\code##1{\realbackslash code {##1}}%
 
2737
\def\uref##1{\realbackslash uref {##1}}%
 
2738
\def\url##1{\realbackslash url {##1}}%
 
2739
\def\env##1{\realbackslash env {##1}}%
 
2740
\def\command##1{\realbackslash command {##1}}%
 
2741
\def\option##1{\realbackslash option {##1}}%
 
2742
\def\dotless##1{\realbackslash dotless {##1}}%
 
2743
\def\samp##1{\realbackslash samp {##1}}%
 
2744
\def\,##1{\realbackslash ,{##1}}%
 
2745
\def\t##1{\realbackslash t {##1}}%
 
2746
\def\r##1{\realbackslash r {##1}}%
 
2747
\def\i##1{\realbackslash i {##1}}%
 
2748
\def\b##1{\realbackslash b {##1}}%
 
2749
\def\sc##1{\realbackslash sc {##1}}%
 
2750
\def\cite##1{\realbackslash cite {##1}}%
 
2751
\def\key##1{\realbackslash key {##1}}%
 
2752
\def\file##1{\realbackslash file {##1}}%
 
2753
\def\var##1{\realbackslash var {##1}}%
 
2754
\def\kbd##1{\realbackslash kbd {##1}}%
 
2755
\def\dfn##1{\realbackslash dfn {##1}}%
 
2756
\def\emph##1{\realbackslash emph {##1}}%
 
2757
\def\acronym##1{\realbackslash acronym {##1}}%
 
2758
%
 
2759
% Handle some cases of @value -- where the variable name does not
 
2760
% contain - or _, and the value does not contain any
 
2761
% (non-fully-expandable) commands.
 
2762
\let\value = \expandablevalue
 
2763
%
 
2764
\unsepspaces
 
2765
% Turn off macro expansion
 
2766
\turnoffmacros
 
2767
}
 
2768
 
 
2769
% If an index command is used in an @example environment, any spaces
 
2770
% therein should become regular spaces in the raw index file, not the
 
2771
% expansion of \tie (\\leavevmode \penalty \@M \ ).
 
2772
{\obeyspaces
 
2773
 \gdef\unsepspaces{\obeyspaces\let =\space}}
 
2774
 
 
2775
% \indexnofonts no-ops all font-change commands.
 
2776
% This is used when outputting the strings to sort the index by.
 
2777
\def\indexdummyfont#1{#1}
 
2778
\def\indexdummytex{TeX}
 
2779
\def\indexdummydots{...}
 
2780
 
 
2781
\def\indexnofonts{%
 
2782
% Just ignore accents.
 
2783
\let\,=\indexdummyfont
 
2784
\let\"=\indexdummyfont
 
2785
\let\`=\indexdummyfont
 
2786
\let\'=\indexdummyfont
 
2787
\let\^=\indexdummyfont
 
2788
\let\~=\indexdummyfont
 
2789
\let\==\indexdummyfont
 
2790
\let\b=\indexdummyfont
 
2791
\let\c=\indexdummyfont
 
2792
\let\d=\indexdummyfont
 
2793
\let\u=\indexdummyfont
 
2794
\let\v=\indexdummyfont
 
2795
\let\H=\indexdummyfont
 
2796
\let\dotless=\indexdummyfont
 
2797
% Take care of the plain tex special European modified letters.
 
2798
\def\oe{oe}%
 
2799
\def\ae{ae}%
 
2800
\def\aa{aa}%
 
2801
\def\OE{OE}%
 
2802
\def\AE{AE}%
 
2803
\def\AA{AA}%
 
2804
\def\o{o}%
 
2805
\def\O{O}%
 
2806
\def\l{l}%
 
2807
\def\L{L}%
 
2808
\def\ss{ss}%
 
2809
\let\w=\indexdummyfont
 
2810
\let\t=\indexdummyfont
 
2811
\let\r=\indexdummyfont
 
2812
\let\i=\indexdummyfont
 
2813
\let\b=\indexdummyfont
 
2814
\let\emph=\indexdummyfont
 
2815
\let\strong=\indexdummyfont
 
2816
\let\cite=\indexdummyfont
 
2817
\let\sc=\indexdummyfont
 
2818
%Don't no-op \tt, since it isn't a user-level command
 
2819
% and is used in the definitions of the active chars like <, >, |...
 
2820
%\let\tt=\indexdummyfont
 
2821
\let\tclose=\indexdummyfont
 
2822
\let\code=\indexdummyfont
 
2823
\let\url=\indexdummyfont
 
2824
\let\uref=\indexdummyfont
 
2825
\let\env=\indexdummyfont
 
2826
\let\acronym=\indexdummyfont
 
2827
\let\command=\indexdummyfont
 
2828
\let\option=\indexdummyfont
 
2829
\let\file=\indexdummyfont
 
2830
\let\samp=\indexdummyfont
 
2831
\let\kbd=\indexdummyfont
 
2832
\let\key=\indexdummyfont
 
2833
\let\var=\indexdummyfont
 
2834
\let\TeX=\indexdummytex
 
2835
\let\dots=\indexdummydots
 
2836
\def\@{@}%
 
2837
}
 
2838
 
 
2839
% To define \realbackslash, we must make \ not be an escape.
 
2840
% We must first make another character (@) an escape
 
2841
% so we do not become unable to do a definition.
 
2842
 
 
2843
{\catcode`\@=0 \catcode`\\=\other
 
2844
 @gdef@realbackslash{\}}
 
2845
 
 
2846
\let\indexbackslash=0  %overridden during \printindex.
 
2847
\let\SETmarginindex=\relax % put index entries in margin (undocumented)?
 
2848
 
 
2849
% For \ifx comparisons.
 
2850
\def\emptymacro{\empty}
 
2851
 
 
2852
% Most index entries go through here, but \dosubind is the general case.
 
2853
%
 
2854
\def\doind#1#2{\dosubind{#1}{#2}\empty}
 
2855
 
 
2856
% Workhorse for all \fooindexes.
 
2857
% #1 is name of index, #2 is stuff to put there, #3 is subentry --
 
2858
% \empty if called from \doind, as we usually are.  The main exception
 
2859
% is with defuns, which call us directly.
 
2860
%
 
2861
\def\dosubind#1#2#3{%
 
2862
  % Put the index entry in the margin if desired.
 
2863
  \ifx\SETmarginindex\relax\else
 
2864
    \insert\margin{\hbox{\vrule height8pt depth3pt width0pt #2}}%
 
2865
  \fi
 
2866
  {%
 
2867
    \count255=\lastpenalty
 
2868
    {%
 
2869
      \indexdummies % Must do this here, since \bf, etc expand at this stage
 
2870
      \escapechar=`\\
 
2871
      {%
 
2872
        \let\folio = 0% We will expand all macros now EXCEPT \folio.
 
2873
        \def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now
 
2874
        % so it will be output as is; and it will print as backslash.
 
2875
        %
 
2876
        \def\thirdarg{#3}%
 
2877
        %
 
2878
        % If third arg is present, precede it with space in sort key.
 
2879
        \ifx\thirdarg\emptymacro
 
2880
          \let\subentry = \empty
 
2881
        \else
 
2882
          \def\subentry{ #3}%
 
2883
        \fi
 
2884
        %
 
2885
        % First process the index entry with all font commands turned
 
2886
        % off to get the string to sort by.
 
2887
        {\indexnofonts \xdef\indexsorttmp{#2\subentry}}%
 
2888
        %
 
2889
        % Now the real index entry with the fonts.
 
2890
        \toks0 = {#2}%
 
2891
        %
 
2892
        % If third (subentry) arg is present, add it to the index
 
2893
        % string.  And include a space.
 
2894
        \ifx\thirdarg\emptymacro \else
 
2895
          \toks0 = \expandafter{\the\toks0 \space #3}%
 
2896
        \fi
 
2897
        %
 
2898
        % Set up the complete index entry, with both the sort key
 
2899
        % and the original text, including any font commands.  We write
 
2900
        % three arguments to \entry to the .?? file, texindex reduces to
 
2901
        % two when writing the .??s sorted result.
 
2902
        \edef\temp{%
 
2903
          \write\csname#1indfile\endcsname{%
 
2904
            \realbackslash entry{\indexsorttmp}{\folio}{\the\toks0}}%
 
2905
        }%
 
2906
        %
 
2907
        % If a skip is the last thing on the list now, preserve it
 
2908
        % by backing up by \lastskip, doing the \write, then inserting
 
2909
        % the skip again.  Otherwise, the whatsit generated by the
 
2910
        % \write will make \lastskip zero.  The result is that sequences
 
2911
        % like this:
 
2912
        % @end defun
 
2913
        % @tindex whatever
 
2914
        % @defun ...
 
2915
        % will have extra space inserted, because the \medbreak in the
 
2916
        % start of the @defun won't see the skip inserted by the @end of
 
2917
        % the previous defun.
 
2918
        %
 
2919
        % But don't do any of this if we're not in vertical mode.  We
 
2920
        % don't want to do a \vskip and prematurely end a paragraph.
 
2921
        %
 
2922
        % Avoid page breaks due to these extra skips, too.
 
2923
        %
 
2924
        \iflinks
 
2925
          \ifvmode
 
2926
            \skip0 = \lastskip
 
2927
            \ifdim\lastskip = 0pt \else \nobreak\vskip-\lastskip \fi
 
2928
          \fi
 
2929
          %
 
2930
          \temp % do the write
 
2931
          %
 
2932
          %
 
2933
          \ifvmode \ifdim\skip0 = 0pt \else \nobreak\vskip\skip0 \fi \fi
 
2934
        \fi
 
2935
      }%
 
2936
    }%
 
2937
    \penalty\count255
 
2938
  }%
 
2939
}
 
2940
 
 
2941
% The index entry written in the file actually looks like
 
2942
%  \entry {sortstring}{page}{topic}
 
2943
% or
 
2944
%  \entry {sortstring}{page}{topic}{subtopic}
 
2945
% The texindex program reads in these files and writes files
 
2946
% containing these kinds of lines:
 
2947
%  \initial {c}
 
2948
%     before the first topic whose initial is c
 
2949
%  \entry {topic}{pagelist}
 
2950
%     for a topic that is used without subtopics
 
2951
%  \primary {topic}
 
2952
%     for the beginning of a topic that is used with subtopics
 
2953
%  \secondary {subtopic}{pagelist}
 
2954
%     for each subtopic.
 
2955
 
 
2956
% Define the user-accessible indexing commands
 
2957
% @findex, @vindex, @kindex, @cindex.
 
2958
 
 
2959
\def\findex {\fnindex}
 
2960
\def\kindex {\kyindex}
 
2961
\def\cindex {\cpindex}
 
2962
\def\vindex {\vrindex}
 
2963
\def\tindex {\tpindex}
 
2964
\def\pindex {\pgindex}
 
2965
 
 
2966
\def\cindexsub {\begingroup\obeylines\cindexsub}
 
2967
{\obeylines %
 
2968
\gdef\cindexsub "#1" #2^^M{\endgroup %
 
2969
\dosubind{cp}{#2}{#1}}}
 
2970
 
 
2971
% Define the macros used in formatting output of the sorted index material.
 
2972
 
 
2973
% @printindex causes a particular index (the ??s file) to get printed.
 
2974
% It does not print any chapter heading (usually an @unnumbered).
 
2975
%
 
2976
\def\printindex{\parsearg\doprintindex}
 
2977
\def\doprintindex#1{\begingroup
 
2978
  \dobreak \chapheadingskip{10000}%
 
2979
  %
 
2980
  \smallfonts \rm
 
2981
  \tolerance = 9500
 
2982
  \indexbreaks
 
2983
  %
 
2984
  % See if the index file exists and is nonempty.
 
2985
  % Change catcode of @ here so that if the index file contains
 
2986
  % \initial {@}
 
2987
  % as its first line, TeX doesn't complain about mismatched braces
 
2988
  % (because it thinks @} is a control sequence).
 
2989
  \catcode`\@ = 11
 
2990
  \openin 1 \jobname.#1s
 
2991
  \ifeof 1
 
2992
    % \enddoublecolumns gets confused if there is no text in the index,
 
2993
    % and it loses the chapter title and the aux file entries for the
 
2994
    % index.  The easiest way to prevent this problem is to make sure
 
2995
    % there is some text.
 
2996
    \putwordIndexNonexistent
 
2997
  \else
 
2998
    %
 
2999
    % If the index file exists but is empty, then \openin leaves \ifeof
 
3000
    % false.  We have to make TeX try to read something from the file, so
 
3001
    % it can discover if there is anything in it.
 
3002
    \read 1 to \temp
 
3003
    \ifeof 1
 
3004
      \putwordIndexIsEmpty
 
3005
    \else
 
3006
      % Index files are almost Texinfo source, but we use \ as the escape
 
3007
      % character.  It would be better to use @, but that's too big a change
 
3008
      % to make right now.
 
3009
      \def\indexbackslash{\rawbackslashxx}%
 
3010
      \catcode`\\ = 0
 
3011
      \escapechar = `\\
 
3012
      \begindoublecolumns
 
3013
      \input \jobname.#1s
 
3014
      \enddoublecolumns
 
3015
    \fi
 
3016
  \fi
 
3017
  \closein 1
 
3018
\endgroup}
 
3019
 
 
3020
% These macros are used by the sorted index file itself.
 
3021
% Change them to control the appearance of the index.
 
3022
 
 
3023
\def\initial#1{{%
 
3024
  % Some minor font changes for the special characters.
 
3025
  \let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt
 
3026
  %
 
3027
  % Remove any glue we may have, we'll be inserting our own.
 
3028
  \removelastskip
 
3029
  %
 
3030
  % We like breaks before the index initials, so insert a bonus.
 
3031
  \penalty -300
 
3032
  %
 
3033
  % Typeset the initial.  Making this add up to a whole number of
 
3034
  % baselineskips increases the chance of the dots lining up from column
 
3035
  % to column.  It still won't often be perfect, because of the stretch
 
3036
  % we need before each entry, but it's better.
 
3037
  %
 
3038
  % No shrink because it confuses \balancecolumns.
 
3039
  \vskip 1.67\baselineskip plus .5\baselineskip
 
3040
  \leftline{\secbf #1}%
 
3041
  \vskip .33\baselineskip plus .1\baselineskip
 
3042
  %
 
3043
  % Do our best not to break after the initial.
 
3044
  \nobreak
 
3045
}}
 
3046
 
 
3047
% This typesets a paragraph consisting of #1, dot leaders, and then #2
 
3048
% flush to the right margin.  It is used for index and table of contents
 
3049
% entries.  The paragraph is indented by \leftskip.
 
3050
%
 
3051
\def\entry#1#2{\begingroup
 
3052
  %
 
3053
  % Start a new paragraph if necessary, so our assignments below can't
 
3054
  % affect previous text.
 
3055
  \par
 
3056
  %
 
3057
  % Do not fill out the last line with white space.
 
3058
  \parfillskip = 0in
 
3059
  %
 
3060
  % No extra space above this paragraph.
 
3061
  \parskip = 0in
 
3062
  %
 
3063
  % Do not prefer a separate line ending with a hyphen to fewer lines.
 
3064
  \finalhyphendemerits = 0
 
3065
  %
 
3066
  % \hangindent is only relevant when the entry text and page number
 
3067
  % don't both fit on one line.  In that case, bob suggests starting the
 
3068
  % dots pretty far over on the line.  Unfortunately, a large
 
3069
  % indentation looks wrong when the entry text itself is broken across
 
3070
  % lines.  So we use a small indentation and put up with long leaders.
 
3071
  %
 
3072
  % \hangafter is reset to 1 (which is the value we want) at the start
 
3073
  % of each paragraph, so we need not do anything with that.
 
3074
  \hangindent = 2em
 
3075
  %
 
3076
  % When the entry text needs to be broken, just fill out the first line
 
3077
  % with blank space.
 
3078
  \rightskip = 0pt plus1fil
 
3079
  %
 
3080
  % A bit of stretch before each entry for the benefit of balancing columns.
 
3081
  \vskip 0pt plus1pt
 
3082
  %
 
3083
  % Start a ``paragraph'' for the index entry so the line breaking
 
3084
  % parameters we've set above will have an effect.
 
3085
  \noindent
 
3086
  %
 
3087
  % Insert the text of the index entry.  TeX will do line-breaking on it.
 
3088
  #1%
 
3089
  % The following is kludged to not output a line of dots in the index if
 
3090
  % there are no page numbers.  The next person who breaks this will be
 
3091
  % cursed by a Unix daemon.
 
3092
  \def\tempa{{\rm }}%
 
3093
  \def\tempb{#2}%
 
3094
  \edef\tempc{\tempa}%
 
3095
  \edef\tempd{\tempb}%
 
3096
  \ifx\tempc\tempd\ \else%
 
3097
    %
 
3098
    % If we must, put the page number on a line of its own, and fill out
 
3099
    % this line with blank space.  (The \hfil is overwhelmed with the
 
3100
    % fill leaders glue in \indexdotfill if the page number does fit.)
 
3101
    \hfil\penalty50
 
3102
    \null\nobreak\indexdotfill % Have leaders before the page number.
 
3103
    %
 
3104
    % The `\ ' here is removed by the implicit \unskip that TeX does as
 
3105
    % part of (the primitive) \par.  Without it, a spurious underfull
 
3106
    % \hbox ensues.
 
3107
    \ifpdf
 
3108
      \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
 
3109
    \else
 
3110
      \ #2% The page number ends the paragraph.
 
3111
    \fi
 
3112
  \fi%
 
3113
  \par
 
3114
\endgroup}
 
3115
 
 
3116
% Like \dotfill except takes at least 1 em.
 
3117
\def\indexdotfill{\cleaders
 
3118
  \hbox{$\mathsurround=0pt \mkern1.5mu ${\it .}$ \mkern1.5mu$}\hskip 1em plus 1fill}
 
3119
 
 
3120
\def\primary #1{\line{#1\hfil}}
 
3121
 
 
3122
\newskip\secondaryindent \secondaryindent=0.5cm
 
3123
 
 
3124
\def\secondary #1#2{
 
3125
{\parfillskip=0in \parskip=0in
 
3126
\hangindent =1in \hangafter=1
 
3127
\noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par
 
3128
}}
 
3129
 
 
3130
% Define two-column mode, which we use to typeset indexes.
 
3131
% Adapted from the TeXbook, page 416, which is to say,
 
3132
% the manmac.tex format used to print the TeXbook itself.
 
3133
\catcode`\@=11
 
3134
 
 
3135
\newbox\partialpage
 
3136
\newdimen\doublecolumnhsize
 
3137
 
 
3138
\def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
 
3139
  % Grab any single-column material above us.
 
3140
  \output = {%
 
3141
    %
 
3142
    % Here is a possibility not foreseen in manmac: if we accumulate a
 
3143
    % whole lot of material, we might end up calling this \output
 
3144
    % routine twice in a row (see the doublecol-lose test, which is
 
3145
    % essentially a couple of indexes with @setchapternewpage off).  In
 
3146
    % that case we just ship out what is in \partialpage with the normal
 
3147
    % output routine.  Generally, \partialpage will be empty when this
 
3148
    % runs and this will be a no-op.  See the indexspread.tex test case.
 
3149
    \ifvoid\partialpage \else
 
3150
      \onepageout{\pagecontents\partialpage}%
 
3151
    \fi
 
3152
    %
 
3153
    \global\setbox\partialpage = \vbox{%
 
3154
      % Unvbox the main output page.
 
3155
      \unvbox\PAGE
 
3156
      \kern-\topskip \kern\baselineskip
 
3157
    }%
 
3158
  }%
 
3159
  \eject % run that output routine to set \partialpage
 
3160
  %
 
3161
  % Use the double-column output routine for subsequent pages.
 
3162
  \output = {\doublecolumnout}%
 
3163
  %
 
3164
  % Change the page size parameters.  We could do this once outside this
 
3165
  % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
 
3166
  % format, but then we repeat the same computation.  Repeating a couple
 
3167
  % of assignments once per index is clearly meaningless for the
 
3168
  % execution time, so we may as well do it in one place.
 
3169
  %
 
3170
  % First we halve the line length, less a little for the gutter between
 
3171
  % the columns.  We compute the gutter based on the line length, so it
 
3172
  % changes automatically with the paper format.  The magic constant
 
3173
  % below is chosen so that the gutter has the same value (well, +-<1pt)
 
3174
  % as it did when we hard-coded it.
 
3175
  %
 
3176
  % We put the result in a separate register, \doublecolumhsize, so we
 
3177
  % can restore it in \pagesofar, after \hsize itself has (potentially)
 
3178
  % been clobbered.
 
3179
  %
 
3180
  \doublecolumnhsize = \hsize
 
3181
    \advance\doublecolumnhsize by -.04154\hsize
 
3182
    \divide\doublecolumnhsize by 2
 
3183
  \hsize = \doublecolumnhsize
 
3184
  %
 
3185
  % Double the \vsize as well.  (We don't need a separate register here,
 
3186
  % since nobody clobbers \vsize.)
 
3187
  \vsize = 2\vsize
 
3188
}
 
3189
 
 
3190
% The double-column output routine for all double-column pages except
 
3191
% the last.
 
3192
%
 
3193
\def\doublecolumnout{%
 
3194
  \splittopskip=\topskip \splitmaxdepth=\maxdepth
 
3195
  % Get the available space for the double columns -- the normal
 
3196
  % (undoubled) page height minus any material left over from the
 
3197
  % previous page.
 
3198
  \dimen@ = \vsize
 
3199
  \divide\dimen@ by 2
 
3200
  \advance\dimen@ by -\ht\partialpage
 
3201
  %
 
3202
  % box0 will be the left-hand column, box2 the right.
 
3203
  \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
 
3204
  \onepageout\pagesofar
 
3205
  \unvbox255
 
3206
  \penalty\outputpenalty
 
3207
}
 
3208
%
 
3209
% Re-output the contents of the output page -- any previous material,
 
3210
% followed by the two boxes we just split, in box0 and box2.
 
3211
\def\pagesofar{%
 
3212
  \unvbox\partialpage
 
3213
  %
 
3214
  \hsize = \doublecolumnhsize
 
3215
  \wd0=\hsize \wd2=\hsize
 
3216
  \hbox to\pagewidth{\box0\hfil\box2}%
 
3217
}
 
3218
 
3219
% All done with double columns.
 
3220
\def\enddoublecolumns{%
 
3221
  \output = {%
 
3222
    % Split the last of the double-column material.  Leave it on the
 
3223
    % current page, no automatic page break.
 
3224
    \balancecolumns
 
3225
    %
 
3226
    % If we end up splitting too much material for the current page,
 
3227
    % though, there will be another page break right after this \output
 
3228
    % invocation ends.  Having called \balancecolumns once, we do not
 
3229
    % want to call it again.  Therefore, reset \output to its normal
 
3230
    % definition right away.  (We hope \balancecolumns will never be
 
3231
    % called on to balance too much material, but if it is, this makes
 
3232
    % the output somewhat more palatable.)
 
3233
    \global\output = {\onepageout{\pagecontents\PAGE}}%
 
3234
  }%
 
3235
  \eject
 
3236
  \endgroup % started in \begindoublecolumns
 
3237
  %
 
3238
  % \pagegoal was set to the doubled \vsize above, since we restarted
 
3239
  % the current page.  We're now back to normal single-column
 
3240
  % typesetting, so reset \pagegoal to the normal \vsize (after the
 
3241
  % \endgroup where \vsize got restored).
 
3242
  \pagegoal = \vsize
 
3243
}
 
3244
%
 
3245
% Called at the end of the double column material.
 
3246
\def\balancecolumns{%
 
3247
  \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120.
 
3248
  \dimen@ = \ht0
 
3249
  \advance\dimen@ by \topskip
 
3250
  \advance\dimen@ by-\baselineskip
 
3251
  \divide\dimen@ by 2 % target to split to
 
3252
  %debug\message{final 2-column material height=\the\ht0, target=\the\dimen@.}%
 
3253
  \splittopskip = \topskip
 
3254
  % Loop until we get a decent breakpoint.
 
3255
  {%
 
3256
    \vbadness = 10000
 
3257
    \loop
 
3258
      \global\setbox3 = \copy0
 
3259
      \global\setbox1 = \vsplit3 to \dimen@
 
3260
    \ifdim\ht3>\dimen@
 
3261
      \global\advance\dimen@ by 1pt
 
3262
    \repeat
 
3263
  }%
 
3264
  %debug\message{split to \the\dimen@, column heights: \the\ht1, \the\ht3.}%
 
3265
  \setbox0=\vbox to\dimen@{\unvbox1}%
 
3266
  \setbox2=\vbox to\dimen@{\unvbox3}%
 
3267
  %
 
3268
  \pagesofar
 
3269
}
 
3270
\catcode`\@ = \other
 
3271
 
 
3272
 
 
3273
\message{sectioning,}
 
3274
% Chapters, sections, etc.
 
3275
 
 
3276
\newcount\chapno
 
3277
\newcount\secno        \secno=0
 
3278
\newcount\subsecno     \subsecno=0
 
3279
\newcount\subsubsecno  \subsubsecno=0
 
3280
 
 
3281
% This counter is funny since it counts through charcodes of letters A, B, ...
 
3282
\newcount\appendixno  \appendixno = `\@
 
3283
% \def\appendixletter{\char\the\appendixno}
 
3284
% We do the following for the sake of pdftex, which needs the actual
 
3285
% letter in the expansion, not just typeset.
 
3286
\def\appendixletter{%
 
3287
  \ifnum\appendixno=`A A%
 
3288
  \else\ifnum\appendixno=`B B%
 
3289
  \else\ifnum\appendixno=`C C%
 
3290
  \else\ifnum\appendixno=`D D%
 
3291
  \else\ifnum\appendixno=`E E%
 
3292
  \else\ifnum\appendixno=`F F%
 
3293
  \else\ifnum\appendixno=`G G%
 
3294
  \else\ifnum\appendixno=`H H%
 
3295
  \else\ifnum\appendixno=`I I%
 
3296
  \else\ifnum\appendixno=`J J%
 
3297
  \else\ifnum\appendixno=`K K%
 
3298
  \else\ifnum\appendixno=`L L%
 
3299
  \else\ifnum\appendixno=`M M%
 
3300
  \else\ifnum\appendixno=`N N%
 
3301
  \else\ifnum\appendixno=`O O%
 
3302
  \else\ifnum\appendixno=`P P%
 
3303
  \else\ifnum\appendixno=`Q Q%
 
3304
  \else\ifnum\appendixno=`R R%
 
3305
  \else\ifnum\appendixno=`S S%
 
3306
  \else\ifnum\appendixno=`T T%
 
3307
  \else\ifnum\appendixno=`U U%
 
3308
  \else\ifnum\appendixno=`V V%
 
3309
  \else\ifnum\appendixno=`W W%
 
3310
  \else\ifnum\appendixno=`X X%
 
3311
  \else\ifnum\appendixno=`Y Y%
 
3312
  \else\ifnum\appendixno=`Z Z%
 
3313
  % The \the is necessary, despite appearances, because \appendixletter is
 
3314
  % expanded while writing the .toc file.  \char\appendixno is not
 
3315
  % expandable, thus it is written literally, thus all appendixes come out
 
3316
  % with the same letter (or @) in the toc without it.
 
3317
  \else\char\the\appendixno
 
3318
  \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
 
3319
  \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
 
3320
 
 
3321
% Each @chapter defines this as the name of the chapter.
 
3322
% page headings and footings can use it.  @section does likewise.
 
3323
\def\thischapter{}
 
3324
\def\thissection{}
 
3325
 
 
3326
\newcount\absseclevel % used to calculate proper heading level
 
3327
\newcount\secbase\secbase=0 % @raise/lowersections modify this count
 
3328
 
 
3329
% @raisesections: treat @section as chapter, @subsection as section, etc.
 
3330
\def\raisesections{\global\advance\secbase by -1}
 
3331
\let\up=\raisesections % original BFox name
 
3332
 
 
3333
% @lowersections: treat @chapter as section, @section as subsection, etc.
 
3334
\def\lowersections{\global\advance\secbase by 1}
 
3335
\let\down=\lowersections % original BFox name
 
3336
 
 
3337
% Choose a numbered-heading macro
 
3338
% #1 is heading level if unmodified by @raisesections or @lowersections
 
3339
% #2 is text for heading
 
3340
\def\numhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
 
3341
\ifcase\absseclevel
 
3342
  \chapterzzz{#2}
 
3343
\or
 
3344
  \seczzz{#2}
 
3345
\or
 
3346
  \numberedsubseczzz{#2}
 
3347
\or
 
3348
  \numberedsubsubseczzz{#2}
 
3349
\else
 
3350
  \ifnum \absseclevel<0
 
3351
    \chapterzzz{#2}
 
3352
  \else
 
3353
    \numberedsubsubseczzz{#2}
 
3354
  \fi
 
3355
\fi
 
3356
}
 
3357
 
 
3358
% like \numhead, but chooses appendix heading levels
 
3359
\def\apphead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
 
3360
\ifcase\absseclevel
 
3361
  \appendixzzz{#2}
 
3362
\or
 
3363
  \appendixsectionzzz{#2}
 
3364
\or
 
3365
  \appendixsubseczzz{#2}
 
3366
\or
 
3367
  \appendixsubsubseczzz{#2}
 
3368
\else
 
3369
  \ifnum \absseclevel<0
 
3370
    \appendixzzz{#2}
 
3371
  \else
 
3372
    \appendixsubsubseczzz{#2}
 
3373
  \fi
 
3374
\fi
 
3375
}
 
3376
 
 
3377
% like \numhead, but chooses numberless heading levels
 
3378
\def\unnmhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
 
3379
\ifcase\absseclevel
 
3380
  \unnumberedzzz{#2}
 
3381
\or
 
3382
  \unnumberedseczzz{#2}
 
3383
\or
 
3384
  \unnumberedsubseczzz{#2}
 
3385
\or
 
3386
  \unnumberedsubsubseczzz{#2}
 
3387
\else
 
3388
  \ifnum \absseclevel<0
 
3389
    \unnumberedzzz{#2}
 
3390
  \else
 
3391
    \unnumberedsubsubseczzz{#2}
 
3392
  \fi
 
3393
\fi
 
3394
}
 
3395
 
 
3396
% @chapter, @appendix, @unnumbered.
 
3397
\def\thischaptername{No Chapter Title}
 
3398
\outer\def\chapter{\parsearg\chapteryyy}
 
3399
\def\chapteryyy #1{\numhead0{#1}} % normally numhead0 calls chapterzzz
 
3400
\def\chapterzzz #1{%
 
3401
\secno=0 \subsecno=0 \subsubsecno=0
 
3402
\global\advance \chapno by 1 \message{\putwordChapter\space \the\chapno}%
 
3403
\chapmacro {#1}{\the\chapno}%
 
3404
\gdef\thissection{#1}%
 
3405
\gdef\thischaptername{#1}%
 
3406
% We don't substitute the actual chapter name into \thischapter
 
3407
% because we don't want its macros evaluated now.
 
3408
\xdef\thischapter{\putwordChapter{} \the\chapno: \noexpand\thischaptername}%
 
3409
\toks0 = {#1}%
 
3410
\edef\temp{\noexpand\writetocentry{\realbackslash chapentry{\the\toks0}%
 
3411
                                  {\the\chapno}}}%
 
3412
\temp
 
3413
\donoderef
 
3414
\global\let\section = \numberedsec
 
3415
\global\let\subsection = \numberedsubsec
 
3416
\global\let\subsubsection = \numberedsubsubsec
 
3417
}
 
3418
 
 
3419
\outer\def\appendix{\parsearg\appendixyyy}
 
3420
\def\appendixyyy #1{\apphead0{#1}} % normally apphead0 calls appendixzzz
 
3421
\def\appendixzzz #1{%
 
3422
\secno=0 \subsecno=0 \subsubsecno=0
 
3423
\global\advance \appendixno by 1
 
3424
\message{\putwordAppendix\space \appendixletter}%
 
3425
\chapmacro {#1}{\putwordAppendix{} \appendixletter}%
 
3426
\gdef\thissection{#1}%
 
3427
\gdef\thischaptername{#1}%
 
3428
\xdef\thischapter{\putwordAppendix{} \appendixletter: \noexpand\thischaptername}%
 
3429
\toks0 = {#1}%
 
3430
\edef\temp{\noexpand\writetocentry{\realbackslash chapentry{\the\toks0}%
 
3431
                       {\putwordAppendix{} \appendixletter}}}%
 
3432
\temp
 
3433
\appendixnoderef
 
3434
\global\let\section = \appendixsec
 
3435
\global\let\subsection = \appendixsubsec
 
3436
\global\let\subsubsection = \appendixsubsubsec
 
3437
}
 
3438
 
 
3439
% @centerchap is like @unnumbered, but the heading is centered.
 
3440
\outer\def\centerchap{\parsearg\centerchapyyy}
 
3441
\def\centerchapyyy #1{{\let\unnumbchapmacro=\centerchapmacro \unnumberedyyy{#1}}}
 
3442
 
 
3443
% @top is like @unnumbered.
 
3444
\outer\def\top{\parsearg\unnumberedyyy}
 
3445
 
 
3446
\outer\def\unnumbered{\parsearg\unnumberedyyy}
 
3447
\def\unnumberedyyy #1{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz
 
3448
\def\unnumberedzzz #1{%
 
3449
\secno=0 \subsecno=0 \subsubsecno=0
 
3450
%
 
3451
% This used to be simply \message{#1}, but TeX fully expands the
 
3452
% argument to \message.  Therefore, if #1 contained @-commands, TeX
 
3453
% expanded them.  For example, in `@unnumbered The @cite{Book}', TeX
 
3454
% expanded @cite (which turns out to cause errors because \cite is meant
 
3455
% to be executed, not expanded).
 
3456
%
 
3457
% Anyway, we don't want the fully-expanded definition of @cite to appear
 
3458
% as a result of the \message, we just want `@cite' itself.  We use
 
3459
% \the<toks register> to achieve this: TeX expands \the<toks> only once,
 
3460
% simply yielding the contents of <toks register>.  (We also do this for
 
3461
% the toc entries.)
 
3462
\toks0 = {#1}\message{(\the\toks0)}%
 
3463
%
 
3464
\unnumbchapmacro {#1}%
 
3465
\gdef\thischapter{#1}\gdef\thissection{#1}%
 
3466
\toks0 = {#1}%
 
3467
\edef\temp{\noexpand\writetocentry{\realbackslash unnumbchapentry{\the\toks0}}}%
 
3468
\temp
 
3469
\unnumbnoderef
 
3470
\global\let\section = \unnumberedsec
 
3471
\global\let\subsection = \unnumberedsubsec
 
3472
\global\let\subsubsection = \unnumberedsubsubsec
 
3473
}
 
3474
 
 
3475
% Sections.
 
3476
\outer\def\numberedsec{\parsearg\secyyy}
 
3477
\def\secyyy #1{\numhead1{#1}} % normally calls seczzz
 
3478
\def\seczzz #1{%
 
3479
\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
 
3480
\gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}%
 
3481
\toks0 = {#1}%
 
3482
\edef\temp{\noexpand\writetocentry{\realbackslash secentry{\the\toks0}%
 
3483
                                  {\the\chapno}{\the\secno}}}%
 
3484
\temp
 
3485
\donoderef
 
3486
\nobreak
 
3487
}
 
3488
 
 
3489
\outer\def\appendixsection{\parsearg\appendixsecyyy}
 
3490
\outer\def\appendixsec{\parsearg\appendixsecyyy}
 
3491
\def\appendixsecyyy #1{\apphead1{#1}} % normally calls appendixsectionzzz
 
3492
\def\appendixsectionzzz #1{%
 
3493
\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
 
3494
\gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}%
 
3495
\toks0 = {#1}%
 
3496
\edef\temp{\noexpand\writetocentry{\realbackslash secentry{\the\toks0}%
 
3497
                                  {\appendixletter}{\the\secno}}}%
 
3498
\temp
 
3499
\appendixnoderef
 
3500
\nobreak
 
3501
}
 
3502
 
 
3503
\outer\def\unnumberedsec{\parsearg\unnumberedsecyyy}
 
3504
\def\unnumberedsecyyy #1{\unnmhead1{#1}} % normally calls unnumberedseczzz
 
3505
\def\unnumberedseczzz #1{%
 
3506
\plainsecheading {#1}\gdef\thissection{#1}%
 
3507
\toks0 = {#1}%
 
3508
\edef\temp{\noexpand\writetocentry{\realbackslash unnumbsecentry{\the\toks0}}}%
 
3509
\temp
 
3510
\unnumbnoderef
 
3511
\nobreak
 
3512
}
 
3513
 
 
3514
% Subsections.
 
3515
\outer\def\numberedsubsec{\parsearg\numberedsubsecyyy}
 
3516
\def\numberedsubsecyyy #1{\numhead2{#1}} % normally calls numberedsubseczzz
 
3517
\def\numberedsubseczzz #1{%
 
3518
\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
 
3519
\subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}%
 
3520
\toks0 = {#1}%
 
3521
\edef\temp{\noexpand\writetocentry{\realbackslash subsecentry{\the\toks0}%
 
3522
                                    {\the\chapno}{\the\secno}{\the\subsecno}}}%
 
3523
\temp
 
3524
\donoderef
 
3525
\nobreak
 
3526
}
 
3527
 
 
3528
\outer\def\appendixsubsec{\parsearg\appendixsubsecyyy}
 
3529
\def\appendixsubsecyyy #1{\apphead2{#1}} % normally calls appendixsubseczzz
 
3530
\def\appendixsubseczzz #1{%
 
3531
\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
 
3532
\subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}%
 
3533
\toks0 = {#1}%
 
3534
\edef\temp{\noexpand\writetocentry{\realbackslash subsecentry{\the\toks0}%
 
3535
                                {\appendixletter}{\the\secno}{\the\subsecno}}}%
 
3536
\temp
 
3537
\appendixnoderef
 
3538
\nobreak
 
3539
}
 
3540
 
 
3541
\outer\def\unnumberedsubsec{\parsearg\unnumberedsubsecyyy}
 
3542
\def\unnumberedsubsecyyy #1{\unnmhead2{#1}} %normally calls unnumberedsubseczzz
 
3543
\def\unnumberedsubseczzz #1{%
 
3544
\plainsubsecheading {#1}\gdef\thissection{#1}%
 
3545
\toks0 = {#1}%
 
3546
\edef\temp{\noexpand\writetocentry{\realbackslash unnumbsubsecentry%
 
3547
                                    {\the\toks0}}}%
 
3548
\temp
 
3549
\unnumbnoderef
 
3550
\nobreak
 
3551
}
 
3552
 
 
3553
% Subsubsections.
 
3554
\outer\def\numberedsubsubsec{\parsearg\numberedsubsubsecyyy}
 
3555
\def\numberedsubsubsecyyy #1{\numhead3{#1}} % normally numberedsubsubseczzz
 
3556
\def\numberedsubsubseczzz #1{%
 
3557
\gdef\thissection{#1}\global\advance \subsubsecno by 1 %
 
3558
\subsubsecheading {#1}
 
3559
  {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
 
3560
\toks0 = {#1}%
 
3561
\edef\temp{\noexpand\writetocentry{\realbackslash subsubsecentry{\the\toks0}%
 
3562
  {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}}}%
 
3563
\temp
 
3564
\donoderef
 
3565
\nobreak
 
3566
}
 
3567
 
 
3568
\outer\def\appendixsubsubsec{\parsearg\appendixsubsubsecyyy}
 
3569
\def\appendixsubsubsecyyy #1{\apphead3{#1}} % normally appendixsubsubseczzz
 
3570
\def\appendixsubsubseczzz #1{%
 
3571
\gdef\thissection{#1}\global\advance \subsubsecno by 1 %
 
3572
\subsubsecheading {#1}
 
3573
  {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
 
3574
\toks0 = {#1}%
 
3575
\edef\temp{\noexpand\writetocentry{\realbackslash subsubsecentry{\the\toks0}%
 
3576
  {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}}}%
 
3577
\temp
 
3578
\appendixnoderef
 
3579
\nobreak
 
3580
}
 
3581
 
 
3582
\outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubsecyyy}
 
3583
\def\unnumberedsubsubsecyyy #1{\unnmhead3{#1}} %normally unnumberedsubsubseczzz
 
3584
\def\unnumberedsubsubseczzz #1{%
 
3585
\plainsubsubsecheading {#1}\gdef\thissection{#1}%
 
3586
\toks0 = {#1}%
 
3587
\edef\temp{\noexpand\writetocentry{\realbackslash unnumbsubsubsecentry%
 
3588
                                    {\the\toks0}}}%
 
3589
\temp
 
3590
\unnumbnoderef
 
3591
\nobreak
 
3592
}
 
3593
 
 
3594
% These are variants which are not "outer", so they can appear in @ifinfo.
 
3595
% Actually, they should now be obsolete; ordinary section commands should work.
 
3596
\def\infotop{\parsearg\unnumberedzzz}
 
3597
\def\infounnumbered{\parsearg\unnumberedzzz}
 
3598
\def\infounnumberedsec{\parsearg\unnumberedseczzz}
 
3599
\def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz}
 
3600
\def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
 
3601
 
 
3602
\def\infoappendix{\parsearg\appendixzzz}
 
3603
\def\infoappendixsec{\parsearg\appendixseczzz}
 
3604
\def\infoappendixsubsec{\parsearg\appendixsubseczzz}
 
3605
\def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz}
 
3606
 
 
3607
\def\infochapter{\parsearg\chapterzzz}
 
3608
\def\infosection{\parsearg\sectionzzz}
 
3609
\def\infosubsection{\parsearg\subsectionzzz}
 
3610
\def\infosubsubsection{\parsearg\subsubsectionzzz}
 
3611
 
 
3612
% These macros control what the section commands do, according
 
3613
% to what kind of chapter we are in (ordinary, appendix, or unnumbered).
 
3614
% Define them by default for a numbered chapter.
 
3615
\global\let\section = \numberedsec
 
3616
\global\let\subsection = \numberedsubsec
 
3617
\global\let\subsubsection = \numberedsubsubsec
 
3618
 
 
3619
% Define @majorheading, @heading and @subheading
 
3620
 
 
3621
% NOTE on use of \vbox for chapter headings, section headings, and such:
 
3622
%       1) We use \vbox rather than the earlier \line to permit
 
3623
%          overlong headings to fold.
 
3624
%       2) \hyphenpenalty is set to 10000 because hyphenation in a
 
3625
%          heading is obnoxious; this forbids it.
 
3626
%       3) Likewise, headings look best if no \parindent is used, and
 
3627
%          if justification is not attempted.  Hence \raggedright.
 
3628
 
 
3629
 
 
3630
\def\majorheading{\parsearg\majorheadingzzz}
 
3631
\def\majorheadingzzz #1{%
 
3632
{\advance\chapheadingskip by 10pt \chapbreak }%
 
3633
{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
 
3634
                  \parindent=0pt\raggedright
 
3635
                  \rm #1\hfill}}\bigskip \par\penalty 200}
 
3636
 
 
3637
\def\chapheading{\parsearg\chapheadingzzz}
 
3638
\def\chapheadingzzz #1{\chapbreak %
 
3639
{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
 
3640
                  \parindent=0pt\raggedright
 
3641
                  \rm #1\hfill}}\bigskip \par\penalty 200}
 
3642
 
 
3643
% @heading, @subheading, @subsubheading.
 
3644
\def\heading{\parsearg\plainsecheading}
 
3645
\def\subheading{\parsearg\plainsubsecheading}
 
3646
\def\subsubheading{\parsearg\plainsubsubsecheading}
 
3647
 
 
3648
% These macros generate a chapter, section, etc. heading only
 
3649
% (including whitespace, linebreaking, etc. around it),
 
3650
% given all the information in convenient, parsed form.
 
3651
 
 
3652
%%% Args are the skip and penalty (usually negative)
 
3653
\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
 
3654
 
 
3655
\def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
 
3656
 
 
3657
%%% Define plain chapter starts, and page on/off switching for it
 
3658
% Parameter controlling skip before chapter headings (if needed)
 
3659
 
 
3660
\newskip\chapheadingskip
 
3661
 
 
3662
\def\chapbreak{\dobreak \chapheadingskip {-4000}}
 
3663
\def\chappager{\par\vfill\supereject}
 
3664
\def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi}
 
3665
 
 
3666
\def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
 
3667
 
 
3668
\def\CHAPPAGoff{%
 
3669
\global\let\contentsalignmacro = \chappager
 
3670
\global\let\pchapsepmacro=\chapbreak
 
3671
\global\let\pagealignmacro=\chappager}
 
3672
 
 
3673
\def\CHAPPAGon{%
 
3674
\global\let\contentsalignmacro = \chappager
 
3675
\global\let\pchapsepmacro=\chappager
 
3676
\global\let\pagealignmacro=\chappager
 
3677
\global\def\HEADINGSon{\HEADINGSsingle}}
 
3678
 
 
3679
\def\CHAPPAGodd{
 
3680
\global\let\contentsalignmacro = \chapoddpage
 
3681
\global\let\pchapsepmacro=\chapoddpage
 
3682
\global\let\pagealignmacro=\chapoddpage
 
3683
\global\def\HEADINGSon{\HEADINGSdouble}}
 
3684
 
 
3685
\CHAPPAGon
 
3686
 
 
3687
\def\CHAPFplain{
 
3688
\global\let\chapmacro=\chfplain
 
3689
\global\let\unnumbchapmacro=\unnchfplain
 
3690
\global\let\centerchapmacro=\centerchfplain}
 
3691
 
 
3692
% Plain chapter opening.
 
3693
% #1 is the text, #2 the chapter number or empty if unnumbered.
 
3694
\def\chfplain#1#2{%
 
3695
  \pchapsepmacro
 
3696
  {%
 
3697
    \chapfonts \rm
 
3698
    \def\chapnum{#2}%
 
3699
    \setbox0 = \hbox{#2\ifx\chapnum\empty\else\enspace\fi}%
 
3700
    \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
 
3701
          \hangindent = \wd0 \centerparametersmaybe
 
3702
          \unhbox0 #1\par}%
 
3703
  }%
 
3704
  \nobreak\bigskip % no page break after a chapter title
 
3705
  \nobreak
 
3706
}
 
3707
 
 
3708
% Plain opening for unnumbered.
 
3709
\def\unnchfplain#1{\chfplain{#1}{}}
 
3710
 
 
3711
% @centerchap -- centered and unnumbered.
 
3712
\let\centerparametersmaybe = \relax
 
3713
\def\centerchfplain#1{{%
 
3714
  \def\centerparametersmaybe{%
 
3715
    \advance\rightskip by 3\rightskip
 
3716
    \leftskip = \rightskip
 
3717
    \parfillskip = 0pt
 
3718
  }%
 
3719
  \chfplain{#1}{}%
 
3720
}}
 
3721
 
 
3722
\CHAPFplain % The default
 
3723
 
 
3724
\def\unnchfopen #1{%
 
3725
\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
 
3726
                       \parindent=0pt\raggedright
 
3727
                       \rm #1\hfill}}\bigskip \par\nobreak
 
3728
}
 
3729
 
 
3730
\def\chfopen #1#2{\chapoddpage {\chapfonts
 
3731
\vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
 
3732
\par\penalty 5000 %
 
3733
}
 
3734
 
 
3735
\def\centerchfopen #1{%
 
3736
\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
 
3737
                       \parindent=0pt
 
3738
                       \hfill {\rm #1}\hfill}}\bigskip \par\nobreak
 
3739
}
 
3740
 
 
3741
\def\CHAPFopen{
 
3742
\global\let\chapmacro=\chfopen
 
3743
\global\let\unnumbchapmacro=\unnchfopen
 
3744
\global\let\centerchapmacro=\centerchfopen}
 
3745
 
 
3746
 
 
3747
% Section titles.
 
3748
\newskip\secheadingskip
 
3749
\def\secheadingbreak{\dobreak \secheadingskip {-1000}}
 
3750
\def\secheading#1#2#3{\sectionheading{sec}{#2.#3}{#1}}
 
3751
\def\plainsecheading#1{\sectionheading{sec}{}{#1}}
 
3752
 
 
3753
% Subsection titles.
 
3754
\newskip \subsecheadingskip
 
3755
\def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}}
 
3756
\def\subsecheading#1#2#3#4{\sectionheading{subsec}{#2.#3.#4}{#1}}
 
3757
\def\plainsubsecheading#1{\sectionheading{subsec}{}{#1}}
 
3758
 
 
3759
% Subsubsection titles.
 
3760
\let\subsubsecheadingskip = \subsecheadingskip
 
3761
\let\subsubsecheadingbreak = \subsecheadingbreak
 
3762
\def\subsubsecheading#1#2#3#4#5{\sectionheading{subsubsec}{#2.#3.#4.#5}{#1}}
 
3763
\def\plainsubsubsecheading#1{\sectionheading{subsubsec}{}{#1}}
 
3764
 
 
3765
 
 
3766
% Print any size section title.
 
3767
%
 
3768
% #1 is the section type (sec/subsec/subsubsec), #2 is the section
 
3769
% number (maybe empty), #3 the text.
 
3770
\def\sectionheading#1#2#3{%
 
3771
  {%
 
3772
    \expandafter\advance\csname #1headingskip\endcsname by \parskip
 
3773
    \csname #1headingbreak\endcsname
 
3774
  }%
 
3775
  {%
 
3776
    % Switch to the right set of fonts.
 
3777
    \csname #1fonts\endcsname \rm
 
3778
    %
 
3779
    % Only insert the separating space if we have a section number.
 
3780
    \def\secnum{#2}%
 
3781
    \setbox0 = \hbox{#2\ifx\secnum\empty\else\enspace\fi}%
 
3782
    %
 
3783
    \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
 
3784
          \hangindent = \wd0 % zero if no section number
 
3785
          \unhbox0 #3}%
 
3786
  }%
 
3787
  \ifdim\parskip<10pt \nobreak\kern10pt\nobreak\kern-\parskip\fi \nobreak
 
3788
}
 
3789
 
 
3790
 
 
3791
\message{toc,}
 
3792
% Table of contents.
 
3793
\newwrite\tocfile
 
3794
 
 
3795
% Write an entry to the toc file, opening it if necessary.
 
3796
% Called from @chapter, etc.  We supply {\folio} at the end of the
 
3797
% argument, which will end up as the last argument to the \...entry macro.
 
3798
%
 
3799
% We open the .toc file here instead of at @setfilename or any other
 
3800
% given time so that @contents can be put in the document anywhere.
 
3801
%
 
3802
\newif\iftocfileopened
 
3803
\def\writetocentry#1{%
 
3804
  \iftocfileopened\else
 
3805
    \immediate\openout\tocfile = \jobname.toc
 
3806
    \global\tocfileopenedtrue
 
3807
  \fi
 
3808
  \iflinks \write\tocfile{#1{\folio}}\fi
 
3809
}
 
3810
 
 
3811
\newskip\contentsrightmargin \contentsrightmargin=1in
 
3812
\newcount\savepageno
 
3813
\newcount\lastnegativepageno \lastnegativepageno = -1
 
3814
 
 
3815
% Finish up the main text and prepare to read what we've written
 
3816
% to \tocfile.
 
3817
%
 
3818
\def\startcontents#1{%
 
3819
   % If @setchapternewpage on, and @headings double, the contents should
 
3820
   % start on an odd page, unlike chapters.  Thus, we maintain
 
3821
   % \contentsalignmacro in parallel with \pagealignmacro.
 
3822
   % From: Torbjorn Granlund <tege@matematik.su.se>
 
3823
   \contentsalignmacro
 
3824
   \immediate\closeout\tocfile
 
3825
   %
 
3826
   % Don't need to put `Contents' or `Short Contents' in the headline.
 
3827
   % It is abundantly clear what they are.
 
3828
   \unnumbchapmacro{#1}\def\thischapter{}%
 
3829
   \savepageno = \pageno
 
3830
   \begingroup                  % Set up to handle contents files properly.
 
3831
      \catcode`\\=0  \catcode`\{=1  \catcode`\}=2  \catcode`\@=11
 
3832
      % We can't do this, because then an actual ^ in a section
 
3833
      % title fails, e.g., @chapter ^ -- exponentiation.  --karl, 9jul97.
 
3834
      %\catcode`\^=7 % to see ^^e4 as \"a etc. juha@piuha.ydi.vtt.fi
 
3835
      \raggedbottom             % Worry more about breakpoints than the bottom.
 
3836
      \advance\hsize by -\contentsrightmargin % Don't use the full line length.
 
3837
      %
 
3838
      % Roman numerals for page numbers.
 
3839
      \ifnum \pageno>0 \pageno = \lastnegativepageno \fi
 
3840
}
 
3841
 
 
3842
 
 
3843
% Normal (long) toc.
 
3844
\def\contents{%
 
3845
   \startcontents{\putwordTOC}%
 
3846
     \openin 1 \jobname.toc
 
3847
     \ifeof 1 \else
 
3848
       \closein 1
 
3849
       \input \jobname.toc
 
3850
     \fi
 
3851
     \vfill \eject
 
3852
     \contentsalignmacro % in case @setchapternewpage odd is in effect
 
3853
     \pdfmakeoutlines
 
3854
   \endgroup
 
3855
   \lastnegativepageno = \pageno
 
3856
   \pageno = \savepageno
 
3857
}
 
3858
 
 
3859
% And just the chapters.
 
3860
\def\summarycontents{%
 
3861
   \startcontents{\putwordShortTOC}%
 
3862
      %
 
3863
      \let\chapentry = \shortchapentry
 
3864
      \let\unnumbchapentry = \shortunnumberedentry
 
3865
      % We want a true roman here for the page numbers.
 
3866
      \secfonts
 
3867
      \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl
 
3868
      \rm
 
3869
      \hyphenpenalty = 10000
 
3870
      \advance\baselineskip by 1pt % Open it up a little.
 
3871
      \def\secentry ##1##2##3##4{}
 
3872
      \def\unnumbsecentry ##1##2{}
 
3873
      \def\subsecentry ##1##2##3##4##5{}
 
3874
      \def\unnumbsubsecentry ##1##2{}
 
3875
      \def\subsubsecentry ##1##2##3##4##5##6{}
 
3876
      \def\unnumbsubsubsecentry ##1##2{}
 
3877
      \openin 1 \jobname.toc
 
3878
      \ifeof 1 \else
 
3879
        \closein 1
 
3880
        \input \jobname.toc
 
3881
      \fi
 
3882
     \vfill \eject
 
3883
     \contentsalignmacro % in case @setchapternewpage odd is in effect
 
3884
   \endgroup
 
3885
   \lastnegativepageno = \pageno
 
3886
   \pageno = \savepageno
 
3887
}
 
3888
\let\shortcontents = \summarycontents
 
3889
 
 
3890
\ifpdf
 
3891
  \pdfcatalog{/PageMode /UseOutlines}%
 
3892
\fi
 
3893
 
 
3894
% These macros generate individual entries in the table of contents.
 
3895
% The first argument is the chapter or section name.
 
3896
% The last argument is the page number.
 
3897
% The arguments in between are the chapter number, section number, ...
 
3898
 
 
3899
% Chapter-level things, for both the long and short contents.
 
3900
\def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}}
 
3901
 
 
3902
% See comments in \dochapentry re vbox and related settings
 
3903
\def\shortchapentry#1#2#3{%
 
3904
  \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#3\egroup}%
 
3905
}
 
3906
 
 
3907
% Typeset the label for a chapter or appendix for the short contents.
 
3908
% The arg is, e.g. `Appendix A' for an appendix, or `3' for a chapter.
 
3909
% We could simplify the code here by writing out an \appendixentry
 
3910
% command in the toc file for appendices, instead of using \chapentry
 
3911
% for both, but it doesn't seem worth it.
 
3912
%
 
3913
\newdimen\shortappendixwidth
 
3914
%
 
3915
\def\shortchaplabel#1{%
 
3916
  % Compute width of word "Appendix", may change with language.
 
3917
  \setbox0 = \hbox{\shortcontrm \putwordAppendix}%
 
3918
  \shortappendixwidth = \wd0
 
3919
  %
 
3920
  % We typeset #1 in a box of constant width, regardless of the text of
 
3921
  % #1, so the chapter titles will come out aligned.
 
3922
  \setbox0 = \hbox{#1}%
 
3923
  \dimen0 = \ifdim\wd0 > \shortappendixwidth \shortappendixwidth \else 0pt \fi
 
3924
  %
 
3925
  % This space should be plenty, since a single number is .5em, and the
 
3926
  % widest letter (M) is 1em, at least in the Computer Modern fonts.
 
3927
  % (This space doesn't include the extra space that gets added after
 
3928
  % the label; that gets put in by \shortchapentry above.)
 
3929
  \advance\dimen0 by 1.1em
 
3930
  \hbox to \dimen0{#1\hfil}%
 
3931
}
 
3932
 
 
3933
\def\unnumbchapentry#1#2{\dochapentry{#1}{#2}}
 
3934
\def\shortunnumberedentry#1#2{\tocentry{#1}{\doshortpageno\bgroup#2\egroup}}
 
3935
 
 
3936
% Sections.
 
3937
\def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}}
 
3938
\def\unnumbsecentry#1#2{\dosecentry{#1}{#2}}
 
3939
 
 
3940
% Subsections.
 
3941
\def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}}
 
3942
\def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}}
 
3943
 
 
3944
% And subsubsections.
 
3945
\def\subsubsecentry#1#2#3#4#5#6{%
 
3946
  \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}}
 
3947
\def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}}
 
3948
 
 
3949
% This parameter controls the indentation of the various levels.
 
3950
\newdimen\tocindent \tocindent = 3pc
 
3951
 
 
3952
% Now for the actual typesetting. In all these, #1 is the text and #2 is the
 
3953
% page number.
 
3954
%
 
3955
% If the toc has to be broken over pages, we want it to be at chapters
 
3956
% if at all possible; hence the \penalty.
 
3957
\def\dochapentry#1#2{%
 
3958
   \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
 
3959
   \begingroup
 
3960
     \chapentryfonts
 
3961
     \tocentry{#1}{\dopageno\bgroup#2\egroup}%
 
3962
   \endgroup
 
3963
   \nobreak\vskip .25\baselineskip plus.1\baselineskip
 
3964
}
 
3965
 
 
3966
\def\dosecentry#1#2{\begingroup
 
3967
  \secentryfonts \leftskip=\tocindent
 
3968
  \tocentry{#1}{\dopageno\bgroup#2\egroup}%
 
3969
\endgroup}
 
3970
 
 
3971
\def\dosubsecentry#1#2{\begingroup
 
3972
  \subsecentryfonts \leftskip=2\tocindent
 
3973
  \tocentry{#1}{\dopageno\bgroup#2\egroup}%
 
3974
\endgroup}
 
3975
 
 
3976
\def\dosubsubsecentry#1#2{\begingroup
 
3977
  \subsubsecentryfonts \leftskip=3\tocindent
 
3978
  \tocentry{#1}{\dopageno\bgroup#2\egroup}%
 
3979
\endgroup}
 
3980
 
 
3981
% Final typesetting of a toc entry; we use the same \entry macro as for
 
3982
% the index entries, but we want to suppress hyphenation here.  (We
 
3983
% can't do that in the \entry macro, since index entries might consist
 
3984
% of hyphenated-identifiers-that-do-not-fit-on-a-line-and-nothing-else.)
 
3985
\def\tocentry#1#2{\begingroup
 
3986
  \vskip 0pt plus1pt % allow a little stretch for the sake of nice page breaks
 
3987
  % Do not use \turnoffactive in these arguments.  Since the toc is
 
3988
  % typeset in cmr, so characters such as _ would come out wrong; we
 
3989
  % have to do the usual translation tricks.
 
3990
  \entry{#1}{#2}%
 
3991
\endgroup}
 
3992
 
 
3993
% Space between chapter (or whatever) number and the title.
 
3994
\def\labelspace{\hskip1em \relax}
 
3995
 
 
3996
\def\dopageno#1{{\rm #1}}
 
3997
\def\doshortpageno#1{{\rm #1}}
 
3998
 
 
3999
\def\chapentryfonts{\secfonts \rm}
 
4000
\def\secentryfonts{\textfonts}
 
4001
\let\subsecentryfonts = \textfonts
 
4002
\let\subsubsecentryfonts = \textfonts
 
4003
 
 
4004
 
 
4005
\message{environments,}
 
4006
% @foo ... @end foo.
 
4007
 
 
4008
% Since these characters are used in examples, it should be an even number of
 
4009
% \tt widths. Each \tt character is 1en, so two makes it 1em.
 
4010
% Furthermore, these definitions must come after we define our fonts.
 
4011
\newbox\dblarrowbox    \newbox\longdblarrowbox
 
4012
\newbox\pushcharbox    \newbox\bullbox
 
4013
\newbox\equivbox       \newbox\errorbox
 
4014
 
 
4015
%{\tentt
 
4016
%\global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil}
 
4017
%\global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil}
 
4018
%\global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil}
 
4019
%\global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil}
 
4020
% Adapted from the manmac format (p.420 of TeXbook)
 
4021
%\global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex
 
4022
%                                      depth .1ex\hfil}
 
4023
%}
 
4024
 
 
4025
% @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
 
4026
\def\point{$\star$}
 
4027
\def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
 
4028
\def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}}
 
4029
\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
 
4030
\def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}}
 
4031
 
 
4032
% Adapted from the TeXbook's \boxit.
 
4033
{\tentt \global\dimen0 = 3em}% Width of the box.
 
4034
\dimen2 = .55pt % Thickness of rules
 
4035
% The text. (`r' is open on the right, `e' somewhat less so on the left.)
 
4036
\setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt}
 
4037
 
 
4038
\global\setbox\errorbox=\hbox to \dimen0{\hfil
 
4039
   \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
 
4040
   \advance\hsize by -2\dimen2 % Rules.
 
4041
   \vbox{
 
4042
      \hrule height\dimen2
 
4043
      \hbox{\vrule width\dimen2 \kern3pt          % Space to left of text.
 
4044
         \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
 
4045
         \kern3pt\vrule width\dimen2}% Space to right.
 
4046
      \hrule height\dimen2}
 
4047
    \hfil}
 
4048
 
 
4049
% The @error{} command.
 
4050
\def\error{\leavevmode\lower.7ex\copy\errorbox}
 
4051
 
 
4052
% @tex ... @end tex    escapes into raw Tex temporarily.
 
4053
% One exception: @ is still an escape character, so that @end tex works.
 
4054
% But \@ or @@ will get a plain tex @ character.
 
4055
 
 
4056
\def\tex{\begingroup
 
4057
  \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
 
4058
  \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
 
4059
  \catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie
 
4060
  \catcode `\%=14
 
4061
  \catcode 43=12 % plus
 
4062
  \catcode`\"=12
 
4063
  \catcode`\==12
 
4064
  \catcode`\|=12
 
4065
  \catcode`\<=12
 
4066
  \catcode`\>=12
 
4067
  \escapechar=`\\
 
4068
  %
 
4069
  \let\b=\ptexb
 
4070
  \let\bullet=\ptexbullet
 
4071
  \let\c=\ptexc
 
4072
  \let\,=\ptexcomma
 
4073
  \let\.=\ptexdot
 
4074
  \let\dots=\ptexdots
 
4075
  \let\equiv=\ptexequiv
 
4076
  \let\!=\ptexexclam
 
4077
  \let\i=\ptexi
 
4078
  \let\{=\ptexlbrace
 
4079
  \let\+=\tabalign
 
4080
  \let\}=\ptexrbrace
 
4081
  \let\*=\ptexstar
 
4082
  \let\t=\ptext
 
4083
  %
 
4084
  \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
 
4085
  \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
 
4086
  \def\@{@}%
 
4087
\let\Etex=\endgroup}
 
4088
 
 
4089
% Define @lisp ... @endlisp.
 
4090
% @lisp does a \begingroup so it can rebind things,
 
4091
% including the definition of @endlisp (which normally is erroneous).
 
4092
 
 
4093
% Amount to narrow the margins by for @lisp.
 
4094
\newskip\lispnarrowing \lispnarrowing=0.4in
 
4095
 
 
4096
% This is the definition that ^^M gets inside @lisp, @example, and other
 
4097
% such environments.  \null is better than a space, since it doesn't
 
4098
% have any width.
 
4099
\def\lisppar{\null\endgraf}
 
4100
 
 
4101
% Make each space character in the input produce a normal interword
 
4102
% space in the output.  Don't allow a line break at this space, as this
 
4103
% is used only in environments like @example, where each line of input
 
4104
% should produce a line of output anyway.
 
4105
%
 
4106
{\obeyspaces %
 
4107
\gdef\sepspaces{\obeyspaces\let =\tie}}
 
4108
 
 
4109
% Define \obeyedspace to be our active space, whatever it is.  This is
 
4110
% for use in \parsearg.
 
4111
{\sepspaces%
 
4112
\global\let\obeyedspace= }
 
4113
 
 
4114
% This space is always present above and below environments.
 
4115
\newskip\envskipamount \envskipamount = 0pt
 
4116
 
 
4117
% Make spacing and below environment symmetrical.  We use \parskip here
 
4118
% to help in doing that, since in @example-like environments \parskip
 
4119
% is reset to zero; thus the \afterenvbreak inserts no space -- but the
 
4120
% start of the next paragraph will insert \parskip
 
4121
%
 
4122
\def\aboveenvbreak{{\advance\envskipamount by \parskip
 
4123
\endgraf \ifdim\lastskip<\envskipamount
 
4124
\removelastskip \penalty-50 \vskip\envskipamount \fi}}
 
4125
 
 
4126
\let\afterenvbreak = \aboveenvbreak
 
4127
 
 
4128
% \nonarrowing is a flag.  If "set", @lisp etc don't narrow margins.
 
4129
\let\nonarrowing=\relax
 
4130
 
 
4131
% @cartouche ... @end cartouche: draw rectangle w/rounded corners around
 
4132
% environment contents.
 
4133
\font\circle=lcircle10
 
4134
\newdimen\circthick
 
4135
\newdimen\cartouter\newdimen\cartinner
 
4136
\newskip\normbskip\newskip\normpskip\newskip\normlskip
 
4137
\circthick=\fontdimen8\circle
 
4138
%
 
4139
\def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
 
4140
\def\ctr{{\hskip 6pt\circle\char'010}}
 
4141
\def\cbl{{\circle\char'012\hskip -6pt}}
 
4142
\def\cbr{{\hskip 6pt\circle\char'011}}
 
4143
\def\carttop{\hbox to \cartouter{\hskip\lskip
 
4144
        \ctl\leaders\hrule height\circthick\hfil\ctr
 
4145
        \hskip\rskip}}
 
4146
\def\cartbot{\hbox to \cartouter{\hskip\lskip
 
4147
        \cbl\leaders\hrule height\circthick\hfil\cbr
 
4148
        \hskip\rskip}}
 
4149
%
 
4150
\newskip\lskip\newskip\rskip
 
4151
 
 
4152
\long\def\cartouche{%
 
4153
\begingroup
 
4154
        \lskip=\leftskip \rskip=\rightskip
 
4155
        \leftskip=0pt\rightskip=0pt %we want these *outside*.
 
4156
        \cartinner=\hsize \advance\cartinner by-\lskip
 
4157
                          \advance\cartinner by-\rskip
 
4158
        \cartouter=\hsize
 
4159
        \advance\cartouter by 18.4pt % allow for 3pt kerns on either
 
4160
%                                    side, and for 6pt waste from
 
4161
%                                    each corner char, and rule thickness
 
4162
        \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
 
4163
        % Flag to tell @lisp, etc., not to narrow margin.
 
4164
        \let\nonarrowing=\comment
 
4165
        \vbox\bgroup
 
4166
                \baselineskip=0pt\parskip=0pt\lineskip=0pt
 
4167
                \carttop
 
4168
                \hbox\bgroup
 
4169
                        \hskip\lskip
 
4170
                        \vrule\kern3pt
 
4171
                        \vbox\bgroup
 
4172
                                \hsize=\cartinner
 
4173
                                \kern3pt
 
4174
                                \begingroup
 
4175
                                        \baselineskip=\normbskip
 
4176
                                        \lineskip=\normlskip
 
4177
                                        \parskip=\normpskip
 
4178
                                        \vskip -\parskip
 
4179
\def\Ecartouche{%
 
4180
                                \endgroup
 
4181
                                \kern3pt
 
4182
                        \egroup
 
4183
                        \kern3pt\vrule
 
4184
                        \hskip\rskip
 
4185
                \egroup
 
4186
                \cartbot
 
4187
        \egroup
 
4188
\endgroup
 
4189
}}
 
4190
 
 
4191
 
 
4192
% This macro is called at the beginning of all the @example variants,
 
4193
% inside a group.
 
4194
\def\nonfillstart{%
 
4195
  \aboveenvbreak
 
4196
  \inENV % This group ends at the end of the body
 
4197
  \hfuzz = 12pt % Don't be fussy
 
4198
  \sepspaces % Make spaces be word-separators rather than space tokens.
 
4199
  \singlespace
 
4200
  \let\par = \lisppar % don't ignore blank lines
 
4201
  \obeylines % each line of input is a line of output
 
4202
  \parskip = 0pt
 
4203
  \parindent = 0pt
 
4204
  \emergencystretch = 0pt % don't try to avoid overfull boxes
 
4205
  % @cartouche defines \nonarrowing to inhibit narrowing
 
4206
  % at next level down.
 
4207
  \ifx\nonarrowing\relax
 
4208
    \advance \leftskip by \lispnarrowing
 
4209
    \exdentamount=\lispnarrowing
 
4210
    \let\exdent=\nofillexdent
 
4211
    \let\nonarrowing=\relax
 
4212
  \fi
 
4213
}
 
4214
 
 
4215
% Define the \E... control sequence only if we are inside the particular
 
4216
% environment, so the error checking in \end will work.
 
4217
%
 
4218
% To end an @example-like environment, we first end the paragraph (via
 
4219
% \afterenvbreak's vertical glue), and then the group.  That way we keep
 
4220
% the zero \parskip that the environments set -- \parskip glue will be
 
4221
% inserted at the beginning of the next paragraph in the document, after
 
4222
% the environment.
 
4223
%
 
4224
\def\nonfillfinish{\afterenvbreak\endgroup}
 
4225
 
 
4226
% @lisp: indented, narrowed, typewriter font.
 
4227
\def\lisp{\begingroup
 
4228
  \nonfillstart
 
4229
  \let\Elisp = \nonfillfinish
 
4230
  \tt
 
4231
  \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
 
4232
  \gobble       % eat return
 
4233
}
 
4234
 
 
4235
% @example: Same as @lisp.
 
4236
\def\example{\begingroup \def\Eexample{\nonfillfinish\endgroup}\lisp}
 
4237
 
 
4238
% @small... is usually equivalent to the non-small (@smallbook
 
4239
% redefines).  We must call \example (or whatever) last in the
 
4240
% definition, since it reads the return following the @example (or
 
4241
% whatever) command.
 
4242
%
 
4243
% This actually allows (for example) @end display inside an
 
4244
% @smalldisplay.  Too bad, but makeinfo will catch the error anyway.
 
4245
%
 
4246
\def\smalldisplay{\begingroup\def\Esmalldisplay{\nonfillfinish\endgroup}\display}
 
4247
\def\smallexample{\begingroup\def\Esmallexample{\nonfillfinish\endgroup}\lisp}
 
4248
\def\smallformat{\begingroup\def\Esmallformat{\nonfillfinish\endgroup}\format}
 
4249
\def\smalllisp{\begingroup\def\Esmalllisp{\nonfillfinish\endgroup}\lisp}
 
4250
 
 
4251
% Real @smallexample and @smalllisp (when @smallbook): use smaller fonts.
 
4252
% Originally contributed by Pavel@xerox.
 
4253
\def\smalllispx{\begingroup
 
4254
  \def\Esmalllisp{\nonfillfinish\endgroup}%
 
4255
  \def\Esmallexample{\nonfillfinish\endgroup}%
 
4256
  \smallfonts
 
4257
  \lisp
 
4258
}
 
4259
 
 
4260
% @display: same as @lisp except keep current font.
 
4261
%
 
4262
\def\display{\begingroup
 
4263
  \nonfillstart
 
4264
  \let\Edisplay = \nonfillfinish
 
4265
  \gobble
 
4266
}
 
4267
 
 
4268
% @smalldisplay (when @smallbook): @display plus smaller fonts.
 
4269
%
 
4270
\def\smalldisplayx{\begingroup
 
4271
  \def\Esmalldisplay{\nonfillfinish\endgroup}%
 
4272
  \smallfonts \rm
 
4273
  \display
 
4274
}
 
4275
 
 
4276
% @format: same as @display except don't narrow margins.
 
4277
%
 
4278
\def\format{\begingroup
 
4279
  \let\nonarrowing = t
 
4280
  \nonfillstart
 
4281
  \let\Eformat = \nonfillfinish
 
4282
  \gobble
 
4283
}
 
4284
 
 
4285
% @smallformat (when @smallbook): @format plus smaller fonts.
 
4286
%
 
4287
\def\smallformatx{\begingroup
 
4288
  \def\Esmallformat{\nonfillfinish\endgroup}%
 
4289
  \smallfonts \rm
 
4290
  \format
 
4291
}
 
4292
 
 
4293
% @flushleft (same as @format).
 
4294
%
 
4295
\def\flushleft{\begingroup \def\Eflushleft{\nonfillfinish\endgroup}\format}
 
4296
 
 
4297
% @flushright.
 
4298
%
 
4299
\def\flushright{\begingroup
 
4300
  \let\nonarrowing = t
 
4301
  \nonfillstart
 
4302
  \let\Eflushright = \nonfillfinish
 
4303
  \advance\leftskip by 0pt plus 1fill
 
4304
  \gobble
 
4305
}
 
4306
 
 
4307
% @quotation does normal linebreaking (hence we can't use \nonfillstart)
 
4308
% and narrows the margins.
 
4309
%
 
4310
\def\quotation{%
 
4311
  \begingroup\inENV %This group ends at the end of the @quotation body
 
4312
  {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
 
4313
  \singlespace
 
4314
  \parindent=0pt
 
4315
  % We have retained a nonzero parskip for the environment, since we're
 
4316
  % doing normal filling. So to avoid extra space below the environment...
 
4317
  \def\Equotation{\parskip = 0pt \nonfillfinish}%
 
4318
  %
 
4319
  % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
 
4320
  \ifx\nonarrowing\relax
 
4321
    \advance\leftskip by \lispnarrowing
 
4322
    \advance\rightskip by \lispnarrowing
 
4323
    \exdentamount = \lispnarrowing
 
4324
    \let\nonarrowing = \relax
 
4325
  \fi
 
4326
}
 
4327
 
 
4328
 
 
4329
\message{defuns,}
 
4330
% @defun etc.
 
4331
 
 
4332
% Allow user to change definition object font (\df) internally
 
4333
\def\setdeffont #1 {\csname DEF#1\endcsname}
 
4334
 
 
4335
\newskip\defbodyindent \defbodyindent=.4in
 
4336
\newskip\defargsindent \defargsindent=50pt
 
4337
\newskip\deftypemargin \deftypemargin=12pt
 
4338
\newskip\deflastargmargin \deflastargmargin=18pt
 
4339
 
 
4340
\newcount\parencount
 
4341
% define \functionparens, which makes ( and ) and & do special things.
 
4342
% \functionparens affects the group it is contained in.
 
4343
\def\activeparens{%
 
4344
\catcode`\(=\active \catcode`\)=\active \catcode`\&=\active
 
4345
\catcode`\[=\active \catcode`\]=\active}
 
4346
 
 
4347
% Make control sequences which act like normal parenthesis chars.
 
4348
\let\lparen = ( \let\rparen = )
 
4349
 
 
4350
{\activeparens % Now, smart parens don't turn on until &foo (see \amprm)
 
4351
 
 
4352
% Be sure that we always have a definition for `(', etc.  For example,
 
4353
% if the fn name has parens in it, \boldbrax will not be in effect yet,
 
4354
% so TeX would otherwise complain about undefined control sequence.
 
4355
\global\let(=\lparen \global\let)=\rparen
 
4356
\global\let[=\lbrack \global\let]=\rbrack
 
4357
 
 
4358
\gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 }
 
4359
\gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
 
4360
% This is used to turn on special parens
 
4361
% but make & act ordinary (given that it's active).
 
4362
\gdef\boldbraxnoamp{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb\let&=\ampnr}
 
4363
 
 
4364
% Definitions of (, ) and & used in args for functions.
 
4365
% This is the definition of ( outside of all parentheses.
 
4366
\gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested
 
4367
  \global\advance\parencount by 1
 
4368
}
 
4369
%
 
4370
% This is the definition of ( when already inside a level of parens.
 
4371
\gdef\opnested{\char`\(\global\advance\parencount by 1 }
 
4372
%
 
4373
\gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0.
 
4374
  % also in that case restore the outer-level definition of (.
 
4375
  \ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi
 
4376
  \global\advance \parencount by -1 }
 
4377
% If we encounter &foo, then turn on ()-hacking afterwards
 
4378
\gdef\amprm#1 {{\rm\&#1}\let(=\oprm \let)=\clrm\ }
 
4379
%
 
4380
\gdef\normalparens{\boldbrax\let&=\ampnr}
 
4381
} % End of definition inside \activeparens
 
4382
%% These parens (in \boldbrax) actually are a little bolder than the
 
4383
%% contained text.  This is especially needed for [ and ]
 
4384
\def\opnr{{\sf\char`\(}\global\advance\parencount by 1 }
 
4385
\def\clnr{{\sf\char`\)}\global\advance\parencount by -1 }
 
4386
\let\ampnr = \&
 
4387
\def\lbrb{{\bf\char`\[}}
 
4388
\def\rbrb{{\bf\char`\]}}
 
4389
 
 
4390
% Active &'s sneak into the index arguments, so make sure it's defined.
 
4391
{
 
4392
  \catcode`& = 13
 
4393
  \global\let& = \ampnr
 
4394
}
 
4395
 
 
4396
% First, defname, which formats the header line itself.
 
4397
% #1 should be the function name.
 
4398
% #2 should be the type of definition, such as "Function".
 
4399
 
 
4400
\def\defname #1#2{%
 
4401
% Get the values of \leftskip and \rightskip as they were
 
4402
% outside the @def...
 
4403
\dimen2=\leftskip
 
4404
\advance\dimen2 by -\defbodyindent
 
4405
\noindent
 
4406
\setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}%
 
4407
\dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line
 
4408
\dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations
 
4409
\parshape 2 0in \dimen0 \defargsindent \dimen1
 
4410
% Now output arg 2 ("Function" or some such)
 
4411
% ending at \deftypemargin from the right margin,
 
4412
% but stuck inside a box of width 0 so it does not interfere with linebreaking
 
4413
{% Adjust \hsize to exclude the ambient margins,
 
4414
% so that \rightline will obey them.
 
4415
\advance \hsize by -\dimen2
 
4416
\rlap{\rightline{{\rm #2}\hskip -1.25pc }}}%
 
4417
% Make all lines underfull and no complaints:
 
4418
\tolerance=10000 \hbadness=10000
 
4419
\advance\leftskip by -\defbodyindent
 
4420
\exdentamount=\defbodyindent
 
4421
{\df #1}\enskip        % Generate function name
 
4422
}
 
4423
 
 
4424
% Actually process the body of a definition
 
4425
% #1 should be the terminating control sequence, such as \Edefun.
 
4426
% #2 should be the "another name" control sequence, such as \defunx.
 
4427
% #3 should be the control sequence that actually processes the header,
 
4428
%    such as \defunheader.
 
4429
 
 
4430
\def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
 
4431
\medbreak %
 
4432
% Define the end token that this defining construct specifies
 
4433
% so that it will exit this group.
 
4434
\def#1{\endgraf\endgroup\medbreak}%
 
4435
\def#2{\begingroup\obeylines\activeparens\spacesplit#3}%
 
4436
\parindent=0in
 
4437
\advance\leftskip by \defbodyindent
 
4438
\exdentamount=\defbodyindent
 
4439
\begingroup %
 
4440
\catcode 61=\active % 61 is `='
 
4441
\obeylines\activeparens\spacesplit#3}
 
4442
 
 
4443
% #1 is the \E... control sequence to end the definition (which we define).
 
4444
% #2 is the \...x control sequence for consecutive fns (which we define).
 
4445
% #3 is the control sequence to call to resume processing.
 
4446
% #4, delimited by the space, is the class name.
 
4447
%
 
4448
\def\defmethparsebody#1#2#3#4 {\begingroup\inENV %
 
4449
\medbreak %
 
4450
% Define the end token that this defining construct specifies
 
4451
% so that it will exit this group.
 
4452
\def#1{\endgraf\endgroup\medbreak}%
 
4453
\def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}%
 
4454
\parindent=0in
 
4455
\advance\leftskip by \defbodyindent
 
4456
\exdentamount=\defbodyindent
 
4457
\begingroup\obeylines\activeparens\spacesplit{#3{#4}}}
 
4458
 
 
4459
% Used for @deftypemethod and @deftypeivar.
 
4460
% #1 is the \E... control sequence to end the definition (which we define).
 
4461
% #2 is the \...x control sequence for consecutive fns (which we define).
 
4462
% #3 is the control sequence to call to resume processing.
 
4463
% #4, delimited by a space, is the class name.
 
4464
% #5 is the method's return type.
 
4465
%
 
4466
\def\deftypemethparsebody#1#2#3#4 #5 {\begingroup\inENV
 
4467
  \medbreak
 
4468
  \def#1{\endgraf\endgroup\medbreak}%
 
4469
  \def#2##1 ##2 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}{##2}}}%
 
4470
  \parindent=0in
 
4471
  \advance\leftskip by \defbodyindent
 
4472
  \exdentamount=\defbodyindent
 
4473
  \begingroup\obeylines\activeparens\spacesplit{#3{#4}{#5}}}
 
4474
 
 
4475
% Used for @deftypeop.  The change from \deftypemethparsebody is an
 
4476
% extra argument at the beginning which is the `category', instead of it
 
4477
% being the hardwired string `Method' or `Instance Variable'.  We have
 
4478
% to account for this both in the \...x definition and in parsing the
 
4479
% input at hand.  Thus also need a control sequence (passed as #5) for
 
4480
% the \E... definition to assign the category name to.
 
4481
 
4482
\def\deftypeopparsebody#1#2#3#4#5 #6 {\begingroup\inENV
 
4483
  \medbreak
 
4484
  \def#1{\endgraf\endgroup\medbreak}%
 
4485
  \def#2##1 ##2 ##3 {%
 
4486
    \def#4{##1}%
 
4487
    \begingroup\obeylines\activeparens\spacesplit{#3{##2}{##3}}}%
 
4488
  \parindent=0in
 
4489
  \advance\leftskip by \defbodyindent
 
4490
  \exdentamount=\defbodyindent
 
4491
  \begingroup\obeylines\activeparens\spacesplit{#3{#5}{#6}}}
 
4492
 
 
4493
\def\defopparsebody #1#2#3#4#5 {\begingroup\inENV %
 
4494
\medbreak %
 
4495
% Define the end token that this defining construct specifies
 
4496
% so that it will exit this group.
 
4497
\def#1{\endgraf\endgroup\medbreak}%
 
4498
\def#2##1 ##2 {\def#4{##1}%
 
4499
\begingroup\obeylines\activeparens\spacesplit{#3{##2}}}%
 
4500
\parindent=0in
 
4501
\advance\leftskip by \defbodyindent
 
4502
\exdentamount=\defbodyindent
 
4503
\begingroup\obeylines\activeparens\spacesplit{#3{#5}}}
 
4504
 
 
4505
% These parsing functions are similar to the preceding ones
 
4506
% except that they do not make parens into active characters.
 
4507
% These are used for "variables" since they have no arguments.
 
4508
 
 
4509
\def\defvarparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody
 
4510
\medbreak %
 
4511
% Define the end token that this defining construct specifies
 
4512
% so that it will exit this group.
 
4513
\def#1{\endgraf\endgroup\medbreak}%
 
4514
\def#2{\begingroup\obeylines\spacesplit#3}%
 
4515
\parindent=0in
 
4516
\advance\leftskip by \defbodyindent
 
4517
\exdentamount=\defbodyindent
 
4518
\begingroup %
 
4519
\catcode 61=\active %
 
4520
\obeylines\spacesplit#3}
 
4521
 
 
4522
% This is used for \def{tp,vr}parsebody.  It could probably be used for
 
4523
% some of the others, too, with some judicious conditionals.
 
4524
%
 
4525
\def\parsebodycommon#1#2#3{%
 
4526
  \begingroup\inENV %
 
4527
  \medbreak %
 
4528
  % Define the end token that this defining construct specifies
 
4529
  % so that it will exit this group.
 
4530
  \def#1{\endgraf\endgroup\medbreak}%
 
4531
  \def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}%
 
4532
  \parindent=0in
 
4533
  \advance\leftskip by \defbodyindent
 
4534
  \exdentamount=\defbodyindent
 
4535
  \begingroup\obeylines
 
4536
}
 
4537
 
 
4538
\def\defvrparsebody#1#2#3#4 {%
 
4539
  \parsebodycommon{#1}{#2}{#3}%
 
4540
  \spacesplit{#3{#4}}%
 
4541
}
 
4542
 
 
4543
% This loses on `@deftp {Data Type} {struct termios}' -- it thinks the
 
4544
% type is just `struct', because we lose the braces in `{struct
 
4545
% termios}' when \spacesplit reads its undelimited argument.  Sigh.
 
4546
% \let\deftpparsebody=\defvrparsebody
 
4547
%
 
4548
% So, to get around this, we put \empty in with the type name.  That
 
4549
% way, TeX won't find exactly `{...}' as an undelimited argument, and
 
4550
% won't strip off the braces.
 
4551
%
 
4552
\def\deftpparsebody #1#2#3#4 {%
 
4553
  \parsebodycommon{#1}{#2}{#3}%
 
4554
  \spacesplit{\parsetpheaderline{#3{#4}}}\empty
 
4555
}
 
4556
 
 
4557
% Fine, but then we have to eventually remove the \empty *and* the
 
4558
% braces (if any).  That's what this does.
 
4559
%
 
4560
\def\removeemptybraces\empty#1\relax{#1}
 
4561
 
 
4562
% After \spacesplit has done its work, this is called -- #1 is the final
 
4563
% thing to call, #2 the type name (which starts with \empty), and #3
 
4564
% (which might be empty) the arguments.
 
4565
%
 
4566
\def\parsetpheaderline#1#2#3{%
 
4567
  #1{\removeemptybraces#2\relax}{#3}%
 
4568
}%
 
4569
 
 
4570
\def\defopvarparsebody #1#2#3#4#5 {\begingroup\inENV %
 
4571
\medbreak %
 
4572
% Define the end token that this defining construct specifies
 
4573
% so that it will exit this group.
 
4574
\def#1{\endgraf\endgroup\medbreak}%
 
4575
\def#2##1 ##2 {\def#4{##1}%
 
4576
\begingroup\obeylines\spacesplit{#3{##2}}}%
 
4577
\parindent=0in
 
4578
\advance\leftskip by \defbodyindent
 
4579
\exdentamount=\defbodyindent
 
4580
\begingroup\obeylines\spacesplit{#3{#5}}}
 
4581
 
 
4582
% Split up #2 at the first space token.
 
4583
% call #1 with two arguments:
 
4584
%  the first is all of #2 before the space token,
 
4585
%  the second is all of #2 after that space token.
 
4586
% If #2 contains no space token, all of it is passed as the first arg
 
4587
% and the second is passed as empty.
 
4588
 
 
4589
{\obeylines
 
4590
\gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}%
 
4591
\long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{%
 
4592
\ifx\relax #3%
 
4593
#1{#2}{}\else #1{#2}{#3#4}\fi}}
 
4594
 
 
4595
% So much for the things common to all kinds of definitions.
 
4596
 
 
4597
% Define @defun.
 
4598
 
 
4599
% First, define the processing that is wanted for arguments of \defun
 
4600
% Use this to expand the args and terminate the paragraph they make up
 
4601
 
 
4602
\def\defunargs#1{\functionparens \sl
 
4603
% Expand, preventing hyphenation at `-' chars.
 
4604
% Note that groups don't affect changes in \hyphenchar.
 
4605
% Set the font temporarily and use \font in case \setfont made \tensl a macro.
 
4606
{\tensl\hyphenchar\font=0}%
 
4607
#1%
 
4608
{\tensl\hyphenchar\font=45}%
 
4609
\ifnum\parencount=0 \else \errmessage{Unbalanced parentheses in @def}\fi%
 
4610
\interlinepenalty=10000
 
4611
\advance\rightskip by 0pt plus 1fil
 
4612
\endgraf\nobreak\vskip -\parskip\nobreak
 
4613
}
 
4614
 
 
4615
\def\deftypefunargs #1{%
 
4616
% Expand, preventing hyphenation at `-' chars.
 
4617
% Note that groups don't affect changes in \hyphenchar.
 
4618
% Use \boldbraxnoamp, not \functionparens, so that & is not special.
 
4619
\boldbraxnoamp
 
4620
\tclose{#1}% avoid \code because of side effects on active chars
 
4621
\interlinepenalty=10000
 
4622
\advance\rightskip by 0pt plus 1fil
 
4623
\endgraf\nobreak\vskip -\parskip\nobreak
 
4624
}
 
4625
 
 
4626
% Do complete processing of one @defun or @defunx line already parsed.
 
4627
 
 
4628
% @deffn Command forward-char nchars
 
4629
 
 
4630
\def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader}
 
4631
 
 
4632
\def\deffnheader #1#2#3{\doind {fn}{\code{#2}}%
 
4633
\begingroup\defname {#2}{#1}\defunargs{#3}\endgroup %
 
4634
\catcode 61=\other % Turn off change made in \defparsebody
 
4635
}
 
4636
 
 
4637
% @defun == @deffn Function
 
4638
 
 
4639
\def\defun{\defparsebody\Edefun\defunx\defunheader}
 
4640
 
 
4641
\def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
 
4642
\begingroup\defname {#1}{\putwordDeffunc}%
 
4643
\defunargs {#2}\endgroup %
 
4644
\catcode 61=\other % Turn off change made in \defparsebody
 
4645
}
 
4646
 
 
4647
% @deftypefun int foobar (int @var{foo}, float @var{bar})
 
4648
 
 
4649
\def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader}
 
4650
 
 
4651
% #1 is the data type.  #2 is the name and args.
 
4652
\def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax}
 
4653
% #1 is the data type, #2 the name, #3 the args.
 
4654
\def\deftypefunheaderx #1#2 #3\relax{%
 
4655
\doind {fn}{\code{#2}}% Make entry in function index
 
4656
\begingroup\defname {\defheaderxcond#1\relax$$$#2}{\putwordDeftypefun}%
 
4657
\deftypefunargs {#3}\endgroup %
 
4658
\catcode 61=\other % Turn off change made in \defparsebody
 
4659
}
 
4660
 
 
4661
% @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar})
 
4662
 
 
4663
\def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader}
 
4664
 
 
4665
% \defheaderxcond#1\relax$$$
 
4666
% puts #1 in @code, followed by a space, but does nothing if #1 is null.
 
4667
\def\defheaderxcond#1#2$$${\ifx#1\relax\else\code{#1#2} \fi}
 
4668
 
 
4669
% #1 is the classification.  #2 is the data type.  #3 is the name and args.
 
4670
\def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax}
 
4671
% #1 is the classification, #2 the data type, #3 the name, #4 the args.
 
4672
\def\deftypefnheaderx #1#2#3 #4\relax{%
 
4673
\doind {fn}{\code{#3}}% Make entry in function index
 
4674
\begingroup
 
4675
\normalparens % notably, turn off `&' magic, which prevents
 
4676
%               at least some C++ text from working
 
4677
\defname {\defheaderxcond#2\relax$$$#3}{#1}%
 
4678
\deftypefunargs {#4}\endgroup %
 
4679
\catcode 61=\other % Turn off change made in \defparsebody
 
4680
}
 
4681
 
 
4682
% @defmac == @deffn Macro
 
4683
 
 
4684
\def\defmac{\defparsebody\Edefmac\defmacx\defmacheader}
 
4685
 
 
4686
\def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
 
4687
\begingroup\defname {#1}{\putwordDefmac}%
 
4688
\defunargs {#2}\endgroup %
 
4689
\catcode 61=\other % Turn off change made in \defparsebody
 
4690
}
 
4691
 
 
4692
% @defspec == @deffn Special Form
 
4693
 
 
4694
\def\defspec{\defparsebody\Edefspec\defspecx\defspecheader}
 
4695
 
 
4696
\def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
 
4697
\begingroup\defname {#1}{\putwordDefspec}%
 
4698
\defunargs {#2}\endgroup %
 
4699
\catcode 61=\other % Turn off change made in \defparsebody
 
4700
}
 
4701
 
 
4702
% @defop CATEGORY CLASS OPERATION ARG...
 
4703
%
 
4704
\def\defop #1 {\def\defoptype{#1}%
 
4705
\defopparsebody\Edefop\defopx\defopheader\defoptype}
 
4706
%
 
4707
\def\defopheader#1#2#3{%
 
4708
\dosubind {fn}{\code{#2}}{\putwordon\ #1}% Make entry in function index
 
4709
\begingroup\defname {#2}{\defoptype\ \putwordon\ #1}%
 
4710
\defunargs {#3}\endgroup %
 
4711
}
 
4712
 
 
4713
% @deftypeop CATEGORY CLASS TYPE OPERATION ARG...
 
4714
%
 
4715
\def\deftypeop #1 {\def\deftypeopcategory{#1}%
 
4716
  \deftypeopparsebody\Edeftypeop\deftypeopx\deftypeopheader
 
4717
                       \deftypeopcategory}
 
4718
%
 
4719
% #1 is the class name, #2 the data type, #3 the operation name, #4 the args.
 
4720
\def\deftypeopheader#1#2#3#4{%
 
4721
  \dosubind{fn}{\code{#3}}{\putwordon\ \code{#1}}% entry in function index
 
4722
  \begingroup
 
4723
    \defname{\defheaderxcond#2\relax$$$#3}
 
4724
            {\deftypeopcategory\ \putwordon\ \code{#1}}%
 
4725
    \deftypefunargs{#4}%
 
4726
  \endgroup
 
4727
}
 
4728
 
 
4729
% @deftypemethod CLASS TYPE METHOD ARG...
 
4730
%
 
4731
\def\deftypemethod{%
 
4732
  \deftypemethparsebody\Edeftypemethod\deftypemethodx\deftypemethodheader}
 
4733
%
 
4734
% #1 is the class name, #2 the data type, #3 the method name, #4 the args.
 
4735
\def\deftypemethodheader#1#2#3#4{%
 
4736
  \dosubind{fn}{\code{#3}}{\putwordon\ \code{#1}}% entry in function index
 
4737
  \begingroup
 
4738
    \defname{\defheaderxcond#2\relax$$$#3}{\putwordMethodon\ \code{#1}}%
 
4739
    \deftypefunargs{#4}%
 
4740
  \endgroup
 
4741
}
 
4742
 
 
4743
% @deftypeivar CLASS TYPE VARNAME
 
4744
%
 
4745
\def\deftypeivar{%
 
4746
  \deftypemethparsebody\Edeftypeivar\deftypeivarx\deftypeivarheader}
 
4747
%
 
4748
% #1 is the class name, #2 the data type, #3 the variable name.
 
4749
\def\deftypeivarheader#1#2#3{%
 
4750
  \dosubind{vr}{\code{#3}}{\putwordof\ \code{#1}}% entry in variable index
 
4751
  \begingroup
 
4752
    \defname{\defheaderxcond#2\relax$$$#3}
 
4753
            {\putwordInstanceVariableof\ \code{#1}}%
 
4754
    \defvarargs{#3}%
 
4755
  \endgroup
 
4756
}
 
4757
 
 
4758
% @defmethod == @defop Method
 
4759
%
 
4760
\def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader}
 
4761
%
 
4762
% #1 is the class name, #2 the method name, #3 the args.
 
4763
\def\defmethodheader#1#2#3{%
 
4764
  \dosubind{fn}{\code{#2}}{\putwordon\ \code{#1}}% entry in function index
 
4765
  \begingroup
 
4766
    \defname{#2}{\putwordMethodon\ \code{#1}}%
 
4767
    \defunargs{#3}%
 
4768
  \endgroup
 
4769
}
 
4770
 
 
4771
% @defcv {Class Option} foo-class foo-flag
 
4772
 
 
4773
\def\defcv #1 {\def\defcvtype{#1}%
 
4774
\defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype}
 
4775
 
 
4776
\def\defcvarheader #1#2#3{%
 
4777
\dosubind {vr}{\code{#2}}{\putwordof\ #1}% Make entry in var index
 
4778
\begingroup\defname {#2}{\defcvtype\ \putwordof\ #1}%
 
4779
\defvarargs {#3}\endgroup %
 
4780
}
 
4781
 
 
4782
% @defivar CLASS VARNAME == @defcv {Instance Variable} CLASS VARNAME
 
4783
%
 
4784
\def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader}
 
4785
%
 
4786
\def\defivarheader#1#2#3{%
 
4787
  \dosubind {vr}{\code{#2}}{\putwordof\ #1}% entry in var index
 
4788
  \begingroup
 
4789
    \defname{#2}{\putwordInstanceVariableof\ #1}%
 
4790
    \defvarargs{#3}%
 
4791
  \endgroup
 
4792
}
 
4793
 
 
4794
% @defvar
 
4795
% First, define the processing that is wanted for arguments of @defvar.
 
4796
% This is actually simple: just print them in roman.
 
4797
% This must expand the args and terminate the paragraph they make up
 
4798
\def\defvarargs #1{\normalparens #1%
 
4799
\interlinepenalty=10000
 
4800
\endgraf\nobreak\vskip -\parskip\nobreak}
 
4801
 
 
4802
% @defvr Counter foo-count
 
4803
 
 
4804
\def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader}
 
4805
 
 
4806
\def\defvrheader #1#2#3{\doind {vr}{\code{#2}}%
 
4807
\begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup}
 
4808
 
 
4809
% @defvar == @defvr Variable
 
4810
 
 
4811
\def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader}
 
4812
 
 
4813
\def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
 
4814
\begingroup\defname {#1}{\putwordDefvar}%
 
4815
\defvarargs {#2}\endgroup %
 
4816
}
 
4817
 
 
4818
% @defopt == @defvr {User Option}
 
4819
 
 
4820
\def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader}
 
4821
 
 
4822
\def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
 
4823
\begingroup\defname {#1}{\putwordDefopt}%
 
4824
\defvarargs {#2}\endgroup %
 
4825
}
 
4826
 
 
4827
% @deftypevar int foobar
 
4828
 
 
4829
\def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader}
 
4830
 
 
4831
% #1 is the data type.  #2 is the name, perhaps followed by text that
 
4832
% is actually part of the data type, which should not be put into the index.
 
4833
\def\deftypevarheader #1#2{%
 
4834
\dovarind#2 \relax% Make entry in variables index
 
4835
\begingroup\defname {\defheaderxcond#1\relax$$$#2}{\putwordDeftypevar}%
 
4836
\interlinepenalty=10000
 
4837
\endgraf\nobreak\vskip -\parskip\nobreak
 
4838
\endgroup}
 
4839
\def\dovarind#1 #2\relax{\doind{vr}{\code{#1}}}
 
4840
 
 
4841
% @deftypevr {Global Flag} int enable
 
4842
 
 
4843
\def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader}
 
4844
 
 
4845
\def\deftypevrheader #1#2#3{\dovarind#3 \relax%
 
4846
\begingroup\defname {\defheaderxcond#2\relax$$$#3}{#1}
 
4847
\interlinepenalty=10000
 
4848
\endgraf\nobreak\vskip -\parskip\nobreak
 
4849
\endgroup}
 
4850
 
 
4851
% Now define @deftp
 
4852
% Args are printed in bold, a slight difference from @defvar.
 
4853
 
 
4854
\def\deftpargs #1{\bf \defvarargs{#1}}
 
4855
 
 
4856
% @deftp Class window height width ...
 
4857
 
 
4858
\def\deftp{\deftpparsebody\Edeftp\deftpx\deftpheader}
 
4859
 
 
4860
\def\deftpheader #1#2#3{\doind {tp}{\code{#2}}%
 
4861
\begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup}
 
4862
 
 
4863
% These definitions are used if you use @defunx (etc.)
 
4864
% anywhere other than immediately after a @defun or @defunx.
 
4865
 
4866
\def\defcvx#1 {\errmessage{@defcvx in invalid context}}
 
4867
\def\deffnx#1 {\errmessage{@deffnx in invalid context}}
 
4868
\def\defivarx#1 {\errmessage{@defivarx in invalid context}}
 
4869
\def\defmacx#1 {\errmessage{@defmacx in invalid context}}
 
4870
\def\defmethodx#1 {\errmessage{@defmethodx in invalid context}}
 
4871
\def\defoptx #1 {\errmessage{@defoptx in invalid context}}
 
4872
\def\defopx#1 {\errmessage{@defopx in invalid context}}
 
4873
\def\defspecx#1 {\errmessage{@defspecx in invalid context}}
 
4874
\def\deftpx#1 {\errmessage{@deftpx in invalid context}}
 
4875
\def\deftypefnx#1 {\errmessage{@deftypefnx in invalid context}}
 
4876
\def\deftypefunx#1 {\errmessage{@deftypefunx in invalid context}}
 
4877
\def\deftypeivarx#1 {\errmessage{@deftypeivarx in invalid context}}
 
4878
\def\deftypemethodx#1 {\errmessage{@deftypemethodx in invalid context}}
 
4879
\def\deftypeopx#1 {\errmessage{@deftypeopx in invalid context}}
 
4880
\def\deftypevarx#1 {\errmessage{@deftypevarx in invalid context}}
 
4881
\def\deftypevrx#1 {\errmessage{@deftypevrx in invalid context}}
 
4882
\def\defunx#1 {\errmessage{@defunx in invalid context}}
 
4883
\def\defvarx#1 {\errmessage{@defvarx in invalid context}}
 
4884
\def\defvrx#1 {\errmessage{@defvrx in invalid context}}
 
4885
 
 
4886
 
 
4887
\message{macros,}
 
4888
% @macro.
 
4889
 
 
4890
% To do this right we need a feature of e-TeX, \scantokens,
 
4891
% which we arrange to emulate with a temporary file in ordinary TeX.
 
4892
\ifx\eTeXversion\undefined
 
4893
 \newwrite\macscribble
 
4894
 \def\scanmacro#1{%
 
4895
   \begingroup \newlinechar`\^^M
 
4896
   % Undo catcode changes of \startcontents and \doprintindex
 
4897
   \catcode`\@=0 \catcode`\\=12 \escapechar=`\@
 
4898
   % Append \endinput to make sure that TeX does not see the ending newline.
 
4899
   \toks0={#1\endinput}%
 
4900
   \immediate\openout\macscribble=\jobname.tmp
 
4901
   \immediate\write\macscribble{\the\toks0}%
 
4902
   \immediate\closeout\macscribble
 
4903
   \let\xeatspaces\eatspaces
 
4904
   \input \jobname.tmp
 
4905
   \endgroup
 
4906
}
 
4907
\else
 
4908
\def\scanmacro#1{%
 
4909
\begingroup \newlinechar`\^^M
 
4910
% Undo catcode changes of \startcontents and \doprintindex
 
4911
\catcode`\@=0 \catcode`\\=12 \escapechar=`\@
 
4912
\let\xeatspaces\eatspaces\scantokens{#1\endinput}\endgroup}
 
4913
\fi
 
4914
 
 
4915
\newcount\paramno   % Count of parameters
 
4916
\newtoks\macname    % Macro name
 
4917
\newif\ifrecursive  % Is it recursive?
 
4918
\def\macrolist{}    % List of all defined macros in the form
 
4919
                    % \do\macro1\do\macro2...
 
4920
 
 
4921
% Utility routines.
 
4922
% Thisdoes \let #1 = #2, except with \csnames.
 
4923
\def\cslet#1#2{%
 
4924
\expandafter\expandafter
 
4925
\expandafter\let
 
4926
\expandafter\expandafter
 
4927
\csname#1\endcsname
 
4928
\csname#2\endcsname}
 
4929
 
 
4930
% Trim leading and trailing spaces off a string.
 
4931
% Concepts from aro-bend problem 15 (see CTAN).
 
4932
{\catcode`\@=11
 
4933
\gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }}
 
4934
\gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@}
 
4935
\gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @}
 
4936
\def\unbrace#1{#1}
 
4937
\unbrace{\gdef\trim@@@ #1 } #2@{#1}
 
4938
}
 
4939
 
 
4940
% Trim a single trailing ^^M off a string.
 
4941
{\catcode`\^^M=12\catcode`\Q=3%
 
4942
\gdef\eatcr #1{\eatcra #1Q^^MQ}%
 
4943
\gdef\eatcra#1^^MQ{\eatcrb#1Q}%
 
4944
\gdef\eatcrb#1Q#2Q{#1}%
 
4945
}
 
4946
 
 
4947
% Macro bodies are absorbed as an argument in a context where
 
4948
% all characters are catcode 10, 11 or 12, except \ which is active
 
4949
% (as in normal texinfo). It is necessary to change the definition of \.
 
4950
 
 
4951
% It's necessary to have hard CRs when the macro is executed. This is
 
4952
% done by  making ^^M (\endlinechar) catcode 12 when reading the macro
 
4953
% body, and then making it the \newlinechar in \scanmacro.
 
4954
 
 
4955
\def\macrobodyctxt{%
 
4956
  \catcode`\~=12
 
4957
  \catcode`\^=12
 
4958
  \catcode`\_=12
 
4959
  \catcode`\|=12
 
4960
  \catcode`\<=12
 
4961
  \catcode`\>=12
 
4962
  \catcode`\+=12
 
4963
  \catcode`\{=12
 
4964
  \catcode`\}=12
 
4965
  \catcode`\@=12
 
4966
  \catcode`\^^M=12
 
4967
  \usembodybackslash}
 
4968
 
 
4969
\def\macroargctxt{%
 
4970
  \catcode`\~=12
 
4971
  \catcode`\^=12
 
4972
  \catcode`\_=12
 
4973
  \catcode`\|=12
 
4974
  \catcode`\<=12
 
4975
  \catcode`\>=12
 
4976
  \catcode`\+=12
 
4977
  \catcode`\@=12
 
4978
  \catcode`\\=12}
 
4979
 
 
4980
% \mbodybackslash is the definition of \ in @macro bodies.
 
4981
% It maps \foo\ => \csname macarg.foo\endcsname => #N
 
4982
% where N is the macro parameter number.
 
4983
% We define \csname macarg.\endcsname to be \realbackslash, so
 
4984
% \\ in macro replacement text gets you a backslash.
 
4985
 
 
4986
{\catcode`@=0 @catcode`@\=@active
 
4987
 @gdef@usembodybackslash{@let\=@mbodybackslash}
 
4988
 @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname}
 
4989
}
 
4990
\expandafter\def\csname macarg.\endcsname{\realbackslash}
 
4991
 
 
4992
\def\macro{\recursivefalse\parsearg\macroxxx}
 
4993
\def\rmacro{\recursivetrue\parsearg\macroxxx}
 
4994
 
 
4995
\def\macroxxx#1{%
 
4996
  \getargs{#1}%           now \macname is the macname and \argl the arglist
 
4997
  \ifx\argl\empty       % no arguments
 
4998
     \paramno=0%
 
4999
  \else
 
5000
     \expandafter\parsemargdef \argl;%
 
5001
  \fi
 
5002
  \if1\csname ismacro.\the\macname\endcsname
 
5003
     \message{Warning: redefining \the\macname}%
 
5004
  \else
 
5005
     \expandafter\ifx\csname \the\macname\endcsname \relax
 
5006
     \else \errmessage{The name \the\macname\space is reserved}\fi
 
5007
     \global\cslet{macsave.\the\macname}{\the\macname}%
 
5008
     \global\expandafter\let\csname ismacro.\the\macname\endcsname=1%
 
5009
     % Add the macroname to \macrolist
 
5010
     \toks0 = \expandafter{\macrolist\do}%
 
5011
     \xdef\macrolist{\the\toks0
 
5012
       \expandafter\noexpand\csname\the\macname\endcsname}%
 
5013
  \fi
 
5014
  \begingroup \macrobodyctxt
 
5015
  \ifrecursive \expandafter\parsermacbody
 
5016
  \else \expandafter\parsemacbody
 
5017
  \fi}
 
5018
 
 
5019
\def\unmacro{\parsearg\unmacroxxx}
 
5020
\def\unmacroxxx#1{%
 
5021
  \if1\csname ismacro.#1\endcsname
 
5022
    \global\cslet{#1}{macsave.#1}%
 
5023
    \global\expandafter\let \csname ismacro.#1\endcsname=0%
 
5024
    % Remove the macro name from \macrolist
 
5025
    \begingroup
 
5026
      \edef\tempa{\expandafter\noexpand\csname#1\endcsname}%
 
5027
      \def\do##1{%
 
5028
        \def\tempb{##1}%
 
5029
        \ifx\tempa\tempb
 
5030
          % remove this
 
5031
        \else
 
5032
          \toks0 = \expandafter{\newmacrolist\do}%
 
5033
          \edef\newmacrolist{\the\toks0\expandafter\noexpand\tempa}%
 
5034
        \fi}%
 
5035
      \def\newmacrolist{}%
 
5036
      % Execute macro list to define \newmacrolist
 
5037
      \macrolist
 
5038
      \global\let\macrolist\newmacrolist
 
5039
    \endgroup
 
5040
  \else
 
5041
    \errmessage{Macro #1 not defined}%
 
5042
  \fi
 
5043
}
 
5044
 
 
5045
% This makes use of the obscure feature that if the last token of a
 
5046
% <parameter list> is #, then the preceding argument is delimited by
 
5047
% an opening brace, and that opening brace is not consumed.
 
5048
\def\getargs#1{\getargsxxx#1{}}
 
5049
\def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
 
5050
\def\getmacname #1 #2\relax{\macname={#1}}
 
5051
\def\getmacargs#1{\def\argl{#1}}
 
5052
 
 
5053
% Parse the optional {params} list.  Set up \paramno and \paramlist
 
5054
% so \defmacro knows what to do.  Define \macarg.blah for each blah
 
5055
% in the params list, to be ##N where N is the position in that list.
 
5056
% That gets used by \mbodybackslash (above).
 
5057
 
 
5058
% We need to get `macro parameter char #' into several definitions.
 
5059
% The technique used is stolen from LaTeX:  let \hash be something
 
5060
% unexpandable, insert that wherever you need a #, and then redefine
 
5061
% it to # just before using the token list produced.
 
5062
%
 
5063
% The same technique is used to protect \eatspaces till just before
 
5064
% the macro is used.
 
5065
 
 
5066
\def\parsemargdef#1;{\paramno=0\def\paramlist{}%
 
5067
        \let\hash\relax\let\xeatspaces\relax\parsemargdefxxx#1,;,}
 
5068
\def\parsemargdefxxx#1,{%
 
5069
  \if#1;\let\next=\relax
 
5070
  \else \let\next=\parsemargdefxxx
 
5071
    \advance\paramno by 1%
 
5072
    \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
 
5073
        {\xeatspaces{\hash\the\paramno}}%
 
5074
    \edef\paramlist{\paramlist\hash\the\paramno,}%
 
5075
  \fi\next}
 
5076
 
 
5077
% These two commands read recursive and nonrecursive macro bodies.
 
5078
% (They're different since rec and nonrec macros end differently.)
 
5079
 
 
5080
\long\def\parsemacbody#1@end macro%
 
5081
{\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
 
5082
\long\def\parsermacbody#1@end rmacro%
 
5083
{\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
 
5084
 
 
5085
% This defines the macro itself. There are six cases: recursive and
 
5086
% nonrecursive macros of zero, one, and many arguments.
 
5087
% Much magic with \expandafter here.
 
5088
% \xdef is used so that macro definitions will survive the file
 
5089
% they're defined in; @include reads the file inside a group.
 
5090
\def\defmacro{%
 
5091
  \let\hash=##% convert placeholders to macro parameter chars
 
5092
  \ifrecursive
 
5093
    \ifcase\paramno
 
5094
    % 0
 
5095
      \expandafter\xdef\csname\the\macname\endcsname{%
 
5096
        \noexpand\scanmacro{\temp}}%
 
5097
    \or % 1
 
5098
      \expandafter\xdef\csname\the\macname\endcsname{%
 
5099
         \bgroup\noexpand\macroargctxt
 
5100
         \noexpand\braceorline
 
5101
         \expandafter\noexpand\csname\the\macname xxx\endcsname}%
 
5102
      \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
 
5103
         \egroup\noexpand\scanmacro{\temp}}%
 
5104
    \else % many
 
5105
      \expandafter\xdef\csname\the\macname\endcsname{%
 
5106
         \bgroup\noexpand\macroargctxt
 
5107
         \noexpand\csname\the\macname xx\endcsname}%
 
5108
      \expandafter\xdef\csname\the\macname xx\endcsname##1{%
 
5109
          \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
 
5110
      \expandafter\expandafter
 
5111
      \expandafter\xdef
 
5112
      \expandafter\expandafter
 
5113
        \csname\the\macname xxx\endcsname
 
5114
          \paramlist{\egroup\noexpand\scanmacro{\temp}}%
 
5115
    \fi
 
5116
  \else
 
5117
    \ifcase\paramno
 
5118
    % 0
 
5119
      \expandafter\xdef\csname\the\macname\endcsname{%
 
5120
        \noexpand\norecurse{\the\macname}%
 
5121
        \noexpand\scanmacro{\temp}\egroup}%
 
5122
    \or % 1
 
5123
      \expandafter\xdef\csname\the\macname\endcsname{%
 
5124
         \bgroup\noexpand\macroargctxt
 
5125
         \noexpand\braceorline
 
5126
         \expandafter\noexpand\csname\the\macname xxx\endcsname}%
 
5127
      \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
 
5128
        \egroup
 
5129
        \noexpand\norecurse{\the\macname}%
 
5130
        \noexpand\scanmacro{\temp}\egroup}%
 
5131
    \else % many
 
5132
      \expandafter\xdef\csname\the\macname\endcsname{%
 
5133
         \bgroup\noexpand\macroargctxt
 
5134
         \expandafter\noexpand\csname\the\macname xx\endcsname}%
 
5135
      \expandafter\xdef\csname\the\macname xx\endcsname##1{%
 
5136
          \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
 
5137
      \expandafter\expandafter
 
5138
      \expandafter\xdef
 
5139
      \expandafter\expandafter
 
5140
      \csname\the\macname xxx\endcsname
 
5141
      \paramlist{%
 
5142
          \egroup
 
5143
          \noexpand\norecurse{\the\macname}%
 
5144
          \noexpand\scanmacro{\temp}\egroup}%
 
5145
    \fi
 
5146
  \fi}
 
5147
 
 
5148
\def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
 
5149
 
 
5150
% \braceorline decides whether the next nonwhitespace character is a
 
5151
% {.  If so it reads up to the closing }, if not, it reads the whole
 
5152
% line.  Whatever was read is then fed to the next control sequence
 
5153
% as an argument (by \parsebrace or \parsearg)
 
5154
\def\braceorline#1{\let\next=#1\futurelet\nchar\braceorlinexxx}
 
5155
\def\braceorlinexxx{%
 
5156
  \ifx\nchar\bgroup\else
 
5157
    \expandafter\parsearg
 
5158
  \fi \next}
 
5159
 
 
5160
% We mant to disable all macros during \shipout so that they are not
 
5161
% expanded by \write.
 
5162
\def\turnoffmacros{\begingroup \def\do##1{\let\noexpand##1=\relax}%
 
5163
  \edef\next{\macrolist}\expandafter\endgroup\next}
 
5164
 
 
5165
 
 
5166
% @alias.
 
5167
% We need some trickery to remove the optional spaces around the equal
 
5168
% sign.  Just make them active and then expand them all to nothing.
 
5169
\def\alias{\begingroup\obeyspaces\parsearg\aliasxxx}
 
5170
\def\aliasxxx #1{\aliasyyy#1\relax}
 
5171
\def\aliasyyy #1=#2\relax{\ignoreactivespaces
 
5172
\edef\next{\global\let\expandafter\noexpand\csname#1\endcsname=%
 
5173
           \expandafter\noexpand\csname#2\endcsname}%
 
5174
\expandafter\endgroup\next}
 
5175
 
 
5176
 
 
5177
\message{cross references,}
 
5178
% @xref etc.
 
5179
 
 
5180
\newwrite\auxfile
 
5181
 
 
5182
\newif\ifhavexrefs    % True if xref values are known.
 
5183
\newif\ifwarnedxrefs  % True if we warned once that they aren't known.
 
5184
 
 
5185
% @inforef is relatively simple.
 
5186
\def\inforef #1{\inforefzzz #1,,,,**}
 
5187
\def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
 
5188
  node \samp{\ignorespaces#1{}}}
 
5189
 
 
5190
% @node's job is to define \lastnode.
 
5191
\def\node{\ENVcheck\parsearg\nodezzz}
 
5192
\def\nodezzz#1{\nodexxx [#1,]}
 
5193
\def\nodexxx[#1,#2]{\gdef\lastnode{#1}}
 
5194
\let\nwnode=\node
 
5195
\let\lastnode=\relax
 
5196
 
 
5197
% The sectioning commands (@chapter, etc.) call these.
 
5198
\def\donoderef{%
 
5199
  \ifx\lastnode\relax\else
 
5200
    \expandafter\expandafter\expandafter\setref{\lastnode}%
 
5201
      {Ysectionnumberandtype}%
 
5202
    \global\let\lastnode=\relax
 
5203
  \fi
 
5204
}
 
5205
\def\unnumbnoderef{%
 
5206
  \ifx\lastnode\relax\else
 
5207
    \expandafter\expandafter\expandafter\setref{\lastnode}{Ynothing}%
 
5208
    \global\let\lastnode=\relax
 
5209
  \fi
 
5210
}
 
5211
\def\appendixnoderef{%
 
5212
  \ifx\lastnode\relax\else
 
5213
    \expandafter\expandafter\expandafter\setref{\lastnode}%
 
5214
      {Yappendixletterandtype}%
 
5215
    \global\let\lastnode=\relax
 
5216
  \fi
 
5217
}
 
5218
 
 
5219
 
 
5220
% @anchor{NAME} -- define xref target at arbitrary point.
 
5221
%
 
5222
\newcount\savesfregister
 
5223
\gdef\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi}
 
5224
\gdef\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi}
 
5225
\gdef\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces}
 
5226
 
 
5227
% \setref{NAME}{SNT} defines a cross-reference point NAME, namely
 
5228
% NAME-title, NAME-pg, and NAME-SNT.  Called from \foonoderef.  We have
 
5229
% to set \indexdummies so commands such as @code in a section title
 
5230
% aren't expanded.  It would be nicer not to expand the titles in the
 
5231
% first place, but there's so many layers that that is hard to do.
 
5232
%
 
5233
\def\setref#1#2{{%
 
5234
  \indexdummies
 
5235
  \pdfmkdest{#1}%
 
5236
  \dosetq{#1-title}{Ytitle}%
 
5237
  \dosetq{#1-pg}{Ypagenumber}%
 
5238
  \dosetq{#1-snt}{#2}%
 
5239
}}
 
5240
 
 
5241
% @xref, @pxref, and @ref generate cross-references.  For \xrefX, #1 is
 
5242
% the node name, #2 the name of the Info cross-reference, #3 the printed
 
5243
% node name, #4 the name of the Info file, #5 the name of the printed
 
5244
% manual.  All but the node name can be omitted.
 
5245
%
 
5246
\def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]}
 
5247
\def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]}
 
5248
\def\ref#1{\xrefX[#1,,,,,,,]}
 
5249
\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
 
5250
  \unsepspaces
 
5251
  \def\printedmanual{\ignorespaces #5}%
 
5252
  \def\printednodename{\ignorespaces #3}%
 
5253
  \setbox1=\hbox{\printedmanual}%
 
5254
  \setbox0=\hbox{\printednodename}%
 
5255
  \ifdim \wd0 = 0pt
 
5256
    % No printed node name was explicitly given.
 
5257
    \expandafter\ifx\csname SETxref-automatic-section-title\endcsname\relax
 
5258
      % Use the node name inside the square brackets.
 
5259
      \def\printednodename{\ignorespaces #1}%
 
5260
    \else
 
5261
      % Use the actual chapter/section title appear inside
 
5262
      % the square brackets.  Use the real section title if we have it.
 
5263
      \ifdim \wd1 > 0pt
 
5264
        % It is in another manual, so we don't have it.
 
5265
        \def\printednodename{\ignorespaces #1}%
 
5266
      \else
 
5267
        \ifhavexrefs
 
5268
          % We know the real title if we have the xref values.
 
5269
          \def\printednodename{\refx{#1-title}{}}%
 
5270
        \else
 
5271
          % Otherwise just copy the Info node name.
 
5272
          \def\printednodename{\ignorespaces #1}%
 
5273
        \fi%
 
5274
      \fi
 
5275
    \fi
 
5276
  \fi
 
5277
  %
 
5278
  % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not
 
5279
  % insert empty discretionaries after hyphens, which means that it will
 
5280
  % not find a line break at a hyphen in a node names.  Since some manuals
 
5281
  % are best written with fairly long node names, containing hyphens, this
 
5282
  % is a loss.  Therefore, we give the text of the node name again, so it
 
5283
  % is as if TeX is seeing it for the first time.
 
5284
  \ifpdf
 
5285
    \leavevmode
 
5286
    \getfilename{#4}%
 
5287
    \ifnum\filenamelength>0
 
5288
      \startlink attr{/Border [0 0 0]}%
 
5289
        goto file{\the\filename.pdf} name{#1@}%
 
5290
    \else
 
5291
      \startlink attr{/Border [0 0 0]}%
 
5292
        goto name{#1@}%
 
5293
    \fi
 
5294
    \linkcolor
 
5295
  \fi
 
5296
  %
 
5297
  \ifdim \wd1 > 0pt
 
5298
    \putwordsection{} ``\printednodename'' \putwordin{} \cite{\printedmanual}%
 
5299
  \else
 
5300
    % _ (for example) has to be the character _ for the purposes of the
 
5301
    % control sequence corresponding to the node, but it has to expand
 
5302
    % into the usual \leavevmode...\vrule stuff for purposes of
 
5303
    % printing. So we \turnoffactive for the \refx-snt, back on for the
 
5304
    % printing, back off for the \refx-pg.
 
5305
    {\normalturnoffactive
 
5306
     % Only output a following space if the -snt ref is nonempty; for
 
5307
     % @unnumbered and @anchor, it won't be.
 
5308
     \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
 
5309
     \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
 
5310
    }%
 
5311
    % [mynode],
 
5312
    [\printednodename],\space
 
5313
    % page 3
 
5314
    \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
 
5315
  \fi
 
5316
  \endlink
 
5317
\endgroup}
 
5318
 
 
5319
% \dosetq is the interface for calls from other macros
 
5320
 
 
5321
% Use \normalturnoffactive so that punctuation chars such as underscore
 
5322
% and backslash work in node names.  (\turnoffactive doesn't do \.)
 
5323
\def\dosetq#1#2{%
 
5324
  {\let\folio=0%
 
5325
   \normalturnoffactive
 
5326
   \edef\next{\write\auxfile{\internalsetq{#1}{#2}}}%
 
5327
   \iflinks
 
5328
     \next
 
5329
   \fi
 
5330
  }%
 
5331
}
 
5332
 
 
5333
% \internalsetq {foo}{page} expands into
 
5334
% CHARACTERS 'xrdef {foo}{...expansion of \Ypage...}
 
5335
% When the aux file is read, ' is the escape character
 
5336
 
 
5337
\def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}}
 
5338
 
 
5339
% Things to be expanded by \internalsetq
 
5340
 
 
5341
\def\Ypagenumber{\folio}
 
5342
 
 
5343
\def\Ytitle{\thissection}
 
5344
 
 
5345
\def\Ynothing{}
 
5346
 
 
5347
\def\Ysectionnumberandtype{%
 
5348
\ifnum\secno=0 \putwordChapter\xreftie\the\chapno %
 
5349
\else \ifnum \subsecno=0 \putwordSection\xreftie\the\chapno.\the\secno %
 
5350
\else \ifnum \subsubsecno=0 %
 
5351
\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno %
 
5352
\else %
 
5353
\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno %
 
5354
\fi \fi \fi }
 
5355
 
 
5356
\def\Yappendixletterandtype{%
 
5357
\ifnum\secno=0 \putwordAppendix\xreftie'char\the\appendixno{}%
 
5358
\else \ifnum \subsecno=0 \putwordSection\xreftie'char\the\appendixno.\the\secno %
 
5359
\else \ifnum \subsubsecno=0 %
 
5360
\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno %
 
5361
\else %
 
5362
\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno %
 
5363
\fi \fi \fi }
 
5364
 
 
5365
\gdef\xreftie{'tie}
 
5366
 
 
5367
% Use TeX 3.0's \inputlineno to get the line number, for better error
 
5368
% messages, but if we're using an old version of TeX, don't do anything.
 
5369
%
 
5370
\ifx\inputlineno\thisisundefined
 
5371
  \let\linenumber = \empty % Non-3.0.
 
5372
\else
 
5373
  \def\linenumber{\the\inputlineno:\space}
 
5374
\fi
 
5375
 
 
5376
% Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
 
5377
% If its value is nonempty, SUFFIX is output afterward.
 
5378
 
 
5379
\def\refx#1#2{%
 
5380
  \expandafter\ifx\csname X#1\endcsname\relax
 
5381
    % If not defined, say something at least.
 
5382
    \angleleft un\-de\-fined\angleright
 
5383
    \iflinks
 
5384
      \ifhavexrefs
 
5385
        \message{\linenumber Undefined cross reference `#1'.}%
 
5386
      \else
 
5387
        \ifwarnedxrefs\else
 
5388
          \global\warnedxrefstrue
 
5389
          \message{Cross reference values unknown; you must run TeX again.}%
 
5390
        \fi
 
5391
      \fi
 
5392
    \fi
 
5393
  \else
 
5394
    % It's defined, so just use it.
 
5395
    \csname X#1\endcsname
 
5396
  \fi
 
5397
  #2% Output the suffix in any case.
 
5398
}
 
5399
 
 
5400
% This is the macro invoked by entries in the aux file.
 
5401
%
 
5402
\def\xrdef#1{\begingroup
 
5403
  % Reenable \ as an escape while reading the second argument.
 
5404
  \catcode`\\ = 0
 
5405
  \afterassignment\endgroup
 
5406
  \expandafter\gdef\csname X#1\endcsname
 
5407
}
 
5408
 
 
5409
% Read the last existing aux file, if any.  No error if none exists.
 
5410
\def\readauxfile{\begingroup
 
5411
  \catcode`\^^@=\other
 
5412
  \catcode`\^^A=\other
 
5413
  \catcode`\^^B=\other
 
5414
  \catcode`\^^C=\other
 
5415
  \catcode`\^^D=\other
 
5416
  \catcode`\^^E=\other
 
5417
  \catcode`\^^F=\other
 
5418
  \catcode`\^^G=\other
 
5419
  \catcode`\^^H=\other
 
5420
  \catcode`\^^K=\other
 
5421
  \catcode`\^^L=\other
 
5422
  \catcode`\^^N=\other
 
5423
  \catcode`\^^P=\other
 
5424
  \catcode`\^^Q=\other
 
5425
  \catcode`\^^R=\other
 
5426
  \catcode`\^^S=\other
 
5427
  \catcode`\^^T=\other
 
5428
  \catcode`\^^U=\other
 
5429
  \catcode`\^^V=\other
 
5430
  \catcode`\^^W=\other
 
5431
  \catcode`\^^X=\other
 
5432
  \catcode`\^^Z=\other
 
5433
  \catcode`\^^[=\other
 
5434
  \catcode`\^^\=\other
 
5435
  \catcode`\^^]=\other
 
5436
  \catcode`\^^^=\other
 
5437
  \catcode`\^^_=\other
 
5438
  \catcode`\@=\other
 
5439
  \catcode`\^=\other
 
5440
  % It was suggested to define this as 7, which would allow ^^e4 etc.
 
5441
  % in xref tags, i.e., node names.  But since ^^e4 notation isn't
 
5442
  % supported in the main text, it doesn't seem desirable.  Furthermore,
 
5443
  % that is not enough: for node names that actually contain a ^
 
5444
  % character, we would end up writing a line like this: 'xrdef {'hat
 
5445
  % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first
 
5446
  % argument, and \hat is not an expandable control sequence.  It could
 
5447
  % all be worked out, but why?  Either we support ^^ or we don't.
 
5448
  %
 
5449
  % The other change necessary for this was to define \auxhat:
 
5450
  % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter
 
5451
  % and then to call \auxhat in \setq.
 
5452
  %
 
5453
  \catcode`\~=\other
 
5454
  \catcode`\[=\other
 
5455
  \catcode`\]=\other
 
5456
  \catcode`\"=\other
 
5457
  \catcode`\_=\other
 
5458
  \catcode`\|=\other
 
5459
  \catcode`\<=\other
 
5460
  \catcode`\>=\other
 
5461
  \catcode`\$=\other
 
5462
  \catcode`\#=\other
 
5463
  \catcode`\&=\other
 
5464
  \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
 
5465
  % Make the characters 128-255 be printing characters
 
5466
  {%
 
5467
    \count 1=128
 
5468
    \def\loop{%
 
5469
      \catcode\count 1=\other
 
5470
      \advance\count 1 by 1
 
5471
      \ifnum \count 1<256 \loop \fi
 
5472
    }%
 
5473
  }%
 
5474
  % The aux file uses ' as the escape (for now).
 
5475
  % Turn off \ as an escape so we do not lose on
 
5476
  % entries which were dumped with control sequences in their names.
 
5477
  % For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^
 
5478
  % Reference to such entries still does not work the way one would wish,
 
5479
  % but at least they do not bomb out when the aux file is read in.
 
5480
  \catcode`\{=1
 
5481
  \catcode`\}=2
 
5482
  \catcode`\%=\other
 
5483
  \catcode`\'=0
 
5484
  \catcode`\\=\other
 
5485
  %
 
5486
  \openin 1 \jobname.aux
 
5487
  \ifeof 1 \else
 
5488
    \closein 1
 
5489
    \input \jobname.aux
 
5490
    \global\havexrefstrue
 
5491
    \global\warnedobstrue
 
5492
  \fi
 
5493
  % Open the new aux file.  TeX will close it automatically at exit.
 
5494
  \openout\auxfile=\jobname.aux
 
5495
\endgroup}
 
5496
 
 
5497
 
 
5498
% Footnotes.
 
5499
 
 
5500
\newcount \footnoteno
 
5501
 
 
5502
% The trailing space in the following definition for supereject is
 
5503
% vital for proper filling; pages come out unaligned when you do a
 
5504
% pagealignmacro call if that space before the closing brace is
 
5505
% removed. (Generally, numeric constants should always be followed by a
 
5506
% space to prevent strange expansion errors.)
 
5507
\def\supereject{\par\penalty -20000\footnoteno =0 }
 
5508
 
 
5509
% @footnotestyle is meaningful for info output only.
 
5510
\let\footnotestyle=\comment
 
5511
 
 
5512
\let\ptexfootnote=\footnote
 
5513
 
 
5514
{\catcode `\@=11
 
5515
%
 
5516
% Auto-number footnotes.  Otherwise like plain.
 
5517
\gdef\footnote{%
 
5518
  \global\advance\footnoteno by \@ne
 
5519
  \edef\thisfootno{$^{\the\footnoteno}$}%
 
5520
  %
 
5521
  % In case the footnote comes at the end of a sentence, preserve the
 
5522
  % extra spacing after we do the footnote number.
 
5523
  \let\@sf\empty
 
5524
  \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi
 
5525
  %
 
5526
  % Remove inadvertent blank space before typesetting the footnote number.
 
5527
  \unskip
 
5528
  \thisfootno\@sf
 
5529
  \footnotezzz
 
5530
}%
 
5531
 
 
5532
% Don't bother with the trickery in plain.tex to not require the
 
5533
% footnote text as a parameter.  Our footnotes don't need to be so general.
 
5534
%
 
5535
% Oh yes, they do; otherwise, @ifset and anything else that uses
 
5536
% \parseargline fail inside footnotes because the tokens are fixed when
 
5537
% the footnote is read.  --karl, 16nov96.
 
5538
%
 
5539
\long\gdef\footnotezzz{\insert\footins\bgroup
 
5540
  % We want to typeset this text as a normal paragraph, even if the
 
5541
  % footnote reference occurs in (for example) a display environment.
 
5542
  % So reset some parameters.
 
5543
  \interlinepenalty\interfootnotelinepenalty
 
5544
  \splittopskip\ht\strutbox % top baseline for broken footnotes
 
5545
  \splitmaxdepth\dp\strutbox
 
5546
  \floatingpenalty\@MM
 
5547
  \leftskip\z@skip
 
5548
  \rightskip\z@skip
 
5549
  \spaceskip\z@skip
 
5550
  \xspaceskip\z@skip
 
5551
  \parindent\defaultparindent
 
5552
  %
 
5553
  \smallfonts \rm
 
5554
  %
 
5555
  % Hang the footnote text off the number.
 
5556
  \hang
 
5557
  \textindent{\thisfootno}%
 
5558
  %
 
5559
  % Don't crash into the line above the footnote text.  Since this
 
5560
  % expands into a box, it must come within the paragraph, lest it
 
5561
  % provide a place where TeX can split the footnote.
 
5562
  \footstrut
 
5563
  \futurelet\next\fo@t
 
5564
}
 
5565
\def\fo@t{\ifcat\bgroup\noexpand\next \let\next\f@@t
 
5566
  \else\let\next\f@t\fi \next}
 
5567
\def\f@@t{\bgroup\aftergroup\@foot\let\next}
 
5568
\def\f@t#1{#1\@foot}
 
5569
\def\@foot{\strut\par\egroup}
 
5570
 
 
5571
}%end \catcode `\@=11
 
5572
 
 
5573
% Set the baselineskip to #1, and the lineskip and strut size
 
5574
% correspondingly.  There is no deep meaning behind these magic numbers
 
5575
% used as factors; they just match (closely enough) what Knuth defined.
 
5576
%
 
5577
\def\lineskipfactor{.08333}
 
5578
\def\strutheightpercent{.70833}
 
5579
\def\strutdepthpercent {.29167}
 
5580
%
 
5581
\def\setleading#1{%
 
5582
  \normalbaselineskip = #1\relax
 
5583
  \normallineskip = \lineskipfactor\normalbaselineskip
 
5584
  \normalbaselines
 
5585
  \setbox\strutbox =\hbox{%
 
5586
    \vrule width0pt height\strutheightpercent\baselineskip
 
5587
                    depth \strutdepthpercent \baselineskip
 
5588
  }%
 
5589
}
 
5590
 
 
5591
% @| inserts a changebar to the left of the current line.  It should
 
5592
% surround any changed text.  This approach does *not* work if the
 
5593
% change spans more than two lines of output.  To handle that, we would
 
5594
% have adopt a much more difficult approach (putting marks into the main
 
5595
% vertical list for the beginning and end of each change).
 
5596
%
 
5597
\def\|{%
 
5598
  % \vadjust can only be used in horizontal mode.
 
5599
  \leavevmode
 
5600
  %
 
5601
  % Append this vertical mode material after the current line in the output.
 
5602
  \vadjust{%
 
5603
    % We want to insert a rule with the height and depth of the current
 
5604
    % leading; that is exactly what \strutbox is supposed to record.
 
5605
    \vskip-\baselineskip
 
5606
    %
 
5607
    % \vadjust-items are inserted at the left edge of the type.  So
 
5608
    % the \llap here moves out into the left-hand margin.
 
5609
    \llap{%
 
5610
      %
 
5611
      % For a thicker or thinner bar, change the `1pt'.
 
5612
      \vrule height\baselineskip width1pt
 
5613
      %
 
5614
      % This is the space between the bar and the text.
 
5615
      \hskip 12pt
 
5616
    }%
 
5617
  }%
 
5618
}
 
5619
 
 
5620
% For a final copy, take out the rectangles
 
5621
% that mark overfull boxes (in case you have decided
 
5622
% that the text looks ok even though it passes the margin).
 
5623
%
 
5624
\def\finalout{\overfullrule=0pt}
 
5625
 
 
5626
% @image.  We use the macros from epsf.tex to support this.
 
5627
% If epsf.tex is not installed and @image is used, we complain.
 
5628
%
 
5629
% Check for and read epsf.tex up front.  If we read it only at @image
 
5630
% time, we might be inside a group, and then its definitions would get
 
5631
% undone and the next image would fail.
 
5632
\openin 1 = epsf.tex
 
5633
\ifeof 1 \else
 
5634
  \closein 1
 
5635
  % Do not bother showing banner with post-v2.7 epsf.tex (available in
 
5636
  % doc/epsf.tex until it shows up on ctan).
 
5637
  \def\epsfannounce{\toks0 = }%
 
5638
  \input epsf.tex
 
5639
\fi
 
5640
%
 
5641
% We will only complain once about lack of epsf.tex.
 
5642
\newif\ifwarnednoepsf
 
5643
\newhelp\noepsfhelp{epsf.tex must be installed for images to
 
5644
  work.  It is also included in the Texinfo distribution, or you can get
 
5645
  it from ftp://tug.org/tex/epsf.tex.}
 
5646
%
 
5647
\def\image#1{%
 
5648
  \ifx\epsfbox\undefined
 
5649
    \ifwarnednoepsf \else
 
5650
      \errhelp = \noepsfhelp
 
5651
      \errmessage{epsf.tex not found, images will be ignored}%
 
5652
      \global\warnednoepsftrue
 
5653
    \fi
 
5654
  \else
 
5655
    \imagexxx #1,,,\finish
 
5656
  \fi
 
5657
}
 
5658
%
 
5659
% Arguments to @image:
 
5660
% #1 is (mandatory) image filename; we tack on .eps extension.
 
5661
% #2 is (optional) width, #3 is (optional) height.
 
5662
% #4 is just the usual extra ignored arg for parsing this stuff.
 
5663
\def\imagexxx#1,#2,#3,#4\finish{%
 
5664
  \ifpdf
 
5665
    \centerline{\dopdfimage{#1}{#2}{#3}}%
 
5666
  \else
 
5667
    % \epsfbox itself resets \epsf?size at each figure.
 
5668
    \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
 
5669
    \setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
 
5670
    \begingroup
 
5671
      \catcode`\^^M = 5 % in case we're inside an example
 
5672
      % If the image is by itself, center it.
 
5673
      \ifvmode
 
5674
        \nobreak\bigskip
 
5675
        % Usually we'll have text after the image which will insert
 
5676
        % \parskip glue, so insert it here too to equalize the space
 
5677
        % above and below. 
 
5678
        \nobreak\vskip\parskip
 
5679
        \nobreak
 
5680
        \centerline{\epsfbox{#1.eps}}%
 
5681
        \bigbreak
 
5682
      \else
 
5683
        % In the middle of a paragraph, no extra space.
 
5684
        \epsfbox{#1.eps}%
 
5685
      \fi
 
5686
    \endgroup
 
5687
  \fi
 
5688
}
 
5689
 
 
5690
 
 
5691
\message{localization,}
 
5692
% and i18n.
 
5693
 
 
5694
% @documentlanguage is usually given very early, just after
 
5695
% @setfilename.  If done too late, it may not override everything
 
5696
% properly.  Single argument is the language abbreviation.
 
5697
% It would be nice if we could set up a hyphenation file here.
 
5698
%
 
5699
\def\documentlanguage{\parsearg\dodocumentlanguage}
 
5700
\def\dodocumentlanguage#1{%
 
5701
  \tex % read txi-??.tex file in plain TeX.
 
5702
  % Read the file if it exists.
 
5703
  \openin 1 txi-#1.tex
 
5704
  \ifeof1
 
5705
    \errhelp = \nolanghelp
 
5706
    \errmessage{Cannot read language file txi-#1.tex}%
 
5707
    \let\temp = \relax
 
5708
  \else
 
5709
    \def\temp{\input txi-#1.tex }%
 
5710
  \fi
 
5711
  \temp
 
5712
  \endgroup
 
5713
}
 
5714
\newhelp\nolanghelp{The given language definition file cannot be found or
 
5715
is empty.  Maybe you need to install it?  In the current directory
 
5716
should work if nowhere else does.}
 
5717
 
 
5718
 
 
5719
% @documentencoding should change something in TeX eventually, most
 
5720
% likely, but for now just recognize it.
 
5721
\let\documentencoding = \comment
 
5722
 
 
5723
 
 
5724
% Page size parameters.
 
5725
%
 
5726
\newdimen\defaultparindent \defaultparindent = 15pt
 
5727
 
 
5728
\chapheadingskip = 15pt plus 4pt minus 2pt
 
5729
\secheadingskip = 12pt plus 3pt minus 2pt
 
5730
\subsecheadingskip = 9pt plus 2pt minus 2pt
 
5731
 
 
5732
% Prevent underfull vbox error messages.
 
5733
\vbadness = 10000
 
5734
 
 
5735
% Don't be so finicky about underfull hboxes, either.
 
5736
\hbadness = 2000
 
5737
 
 
5738
% Following George Bush, just get rid of widows and orphans.
 
5739
\widowpenalty=10000
 
5740
\clubpenalty=10000
 
5741
 
 
5742
% Use TeX 3.0's \emergencystretch to help line breaking, but if we're
 
5743
% using an old version of TeX, don't do anything.  We want the amount of
 
5744
% stretch added to depend on the line length, hence the dependence on
 
5745
% \hsize.  We call this whenever the paper size is set.
 
5746
%
 
5747
\def\setemergencystretch{%
 
5748
  \ifx\emergencystretch\thisisundefined
 
5749
    % Allow us to assign to \emergencystretch anyway.
 
5750
    \def\emergencystretch{\dimen0}%
 
5751
  \else
 
5752
    \emergencystretch = .15\hsize
 
5753
  \fi
 
5754
}
 
5755
 
 
5756
% Parameters in order: 1) textheight; 2) textwidth; 3) voffset;
 
5757
% 4) hoffset; 5) binding offset; 6) topskip.  Then whoever calls us can
 
5758
% set \parskip and call \setleading for \baselineskip.
 
5759
%
 
5760
\def\internalpagesizes#1#2#3#4#5#6{%
 
5761
  \voffset = #3\relax
 
5762
  \topskip = #6\relax
 
5763
  \splittopskip = \topskip
 
5764
  %
 
5765
  \vsize = #1\relax
 
5766
  \advance\vsize by \topskip
 
5767
  \outervsize = \vsize
 
5768
  \advance\outervsize by 2\topandbottommargin
 
5769
  \pageheight = \vsize
 
5770
  %
 
5771
  \hsize = #2\relax
 
5772
  \outerhsize = \hsize
 
5773
  \advance\outerhsize by 0.5in
 
5774
  \pagewidth = \hsize
 
5775
  %
 
5776
  \normaloffset = #4\relax
 
5777
  \bindingoffset = #5\relax
 
5778
  %
 
5779
  \parindent = \defaultparindent
 
5780
  \setemergencystretch
 
5781
}
 
5782
 
 
5783
% @letterpaper (the default).
 
5784
\def\letterpaper{{\globaldefs = 1
 
5785
  \parskip = 3pt plus 2pt minus 1pt
 
5786
  \setleading{13.2pt}%
 
5787
  %
 
5788
  % If page is nothing but text, make it come out even.
 
5789
  \internalpagesizes{46\baselineskip}{6in}{\voffset}{.25in}{\bindingoffset}{36pt}%
 
5790
}}
 
5791
 
 
5792
% Use @smallbook to reset parameters for 7x9.5 (or so) format.
 
5793
\def\smallbook{{\globaldefs = 1
 
5794
  \parskip = 2pt plus 1pt
 
5795
  \setleading{12pt}%
 
5796
  %
 
5797
  \internalpagesizes{7.5in}{5.in}{\voffset}{.25in}{\bindingoffset}{16pt}%
 
5798
  %
 
5799
  \lispnarrowing = 0.3in
 
5800
  \tolerance = 700
 
5801
  \hfuzz = 1pt
 
5802
  \contentsrightmargin = 0pt
 
5803
  \deftypemargin = 0pt
 
5804
  \defbodyindent = .5cm
 
5805
  %
 
5806
  \let\smalldisplay = \smalldisplayx
 
5807
  \let\smallexample = \smalllispx
 
5808
  \let\smallformat = \smallformatx
 
5809
  \let\smalllisp = \smalllispx
 
5810
}}
 
5811
 
 
5812
% Use @afourpaper to print on European A4 paper.
 
5813
\def\afourpaper{{\globaldefs = 1
 
5814
  \setleading{12pt}%
 
5815
  \parskip = 3pt plus 2pt minus 1pt
 
5816
  %
 
5817
  \internalpagesizes{53\baselineskip}{160mm}{\voffset}{4mm}{\bindingoffset}{44pt}%
 
5818
  %
 
5819
  \tolerance = 700
 
5820
  \hfuzz = 1pt
 
5821
}}
 
5822
 
 
5823
% A specific text layout, 24x15cm overall, intended for A4 paper.  Top margin
 
5824
% 29mm, hence bottom margin 28mm, nominal side margin 3cm.
 
5825
\def\afourlatex{{\globaldefs = 1
 
5826
  \setleading{13.6pt}%
 
5827
  %
 
5828
  \afourpaper
 
5829
  \internalpagesizes{237mm}{150mm}{3.6mm}{3.6mm}{3mm}{7mm}%
 
5830
  %
 
5831
  \globaldefs = 0
 
5832
}}
 
5833
 
 
5834
% Use @afourwide to print on European A4 paper in wide format.
 
5835
\def\afourwide{%
 
5836
  \afourpaper
 
5837
  \internalpagesizes{6.5in}{9.5in}{\hoffset}{\normaloffset}{\bindingoffset}{7mm}%
 
5838
  %
 
5839
  \globaldefs = 0
 
5840
}
 
5841
 
 
5842
% @pagesizes TEXTHEIGHT[,TEXTWIDTH]
 
5843
% Perhaps we should allow setting the margins, \topskip, \parskip,
 
5844
% and/or leading, also. Or perhaps we should compute them somehow.
 
5845
%
 
5846
\def\pagesizes{\parsearg\pagesizesxxx}
 
5847
\def\pagesizesxxx#1{\pagesizesyyy #1,,\finish}
 
5848
\def\pagesizesyyy#1,#2,#3\finish{{%
 
5849
  \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi
 
5850
  \globaldefs = 1
 
5851
  %
 
5852
  \parskip = 3pt plus 2pt minus 1pt
 
5853
  \setleading{13.2pt}%
 
5854
  %
 
5855
  \internalpagesizes{#1}{\hsize}{\voffset}{\normaloffset}{\bindingoffset}{44pt}%
 
5856
}}
 
5857
 
 
5858
% Set default to letter.
 
5859
%
 
5860
\letterpaper
 
5861
 
 
5862
 
 
5863
\message{and turning on texinfo input format.}
 
5864
 
 
5865
% Define macros to output various characters with catcode for normal text.
 
5866
\catcode`\"=\other
 
5867
\catcode`\~=\other
 
5868
\catcode`\^=\other
 
5869
\catcode`\_=\other
 
5870
\catcode`\|=\other
 
5871
\catcode`\<=\other
 
5872
\catcode`\>=\other
 
5873
\catcode`\+=\other
 
5874
\catcode`\$=\other
 
5875
\def\normaldoublequote{"}
 
5876
\def\normaltilde{~}
 
5877
\def\normalcaret{^}
 
5878
\def\normalunderscore{_}
 
5879
\def\normalverticalbar{|}
 
5880
\def\normalless{<}
 
5881
\def\normalgreater{>}
 
5882
\def\normalplus{+}
 
5883
\def\normaldollar{$}
 
5884
 
 
5885
% This macro is used to make a character print one way in ttfont
 
5886
% where it can probably just be output, and another way in other fonts,
 
5887
% where something hairier probably needs to be done.
 
5888
%
 
5889
% #1 is what to print if we are indeed using \tt; #2 is what to print
 
5890
% otherwise.  Since all the Computer Modern typewriter fonts have zero
 
5891
% interword stretch (and shrink), and it is reasonable to expect all
 
5892
% typewriter fonts to have this, we can check that font parameter.
 
5893
%
 
5894
\def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi}
 
5895
 
 
5896
% Same as above, but check for italic font.  Actually this also catches
 
5897
% non-italic slanted fonts since it is impossible to distinguish them from
 
5898
% italic fonts.  But since this is only used by $ and it uses \sl anyway
 
5899
% this is not a problem.
 
5900
\def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi}
 
5901
 
 
5902
% Turn off all special characters except @
 
5903
% (and those which the user can use as if they were ordinary).
 
5904
% Most of these we simply print from the \tt font, but for some, we can
 
5905
% use math or other variants that look better in normal text.
 
5906
 
 
5907
\catcode`\"=\active
 
5908
\def\activedoublequote{{\tt\char34}}
 
5909
\let"=\activedoublequote
 
5910
\catcode`\~=\active
 
5911
\def~{{\tt\char126}}
 
5912
\chardef\hat=`\^
 
5913
\catcode`\^=\active
 
5914
\def^{{\tt \hat}}
 
5915
 
 
5916
\catcode`\_=\active
 
5917
\def_{\ifusingtt\normalunderscore\_}
 
5918
% Subroutine for the previous macro.
 
5919
\def\_{\leavevmode \kern.06em \vbox{\hrule width.3em height.1ex}}
 
5920
 
 
5921
\catcode`\|=\active
 
5922
\def|{{\tt\char124}}
 
5923
\chardef \less=`\<
 
5924
\catcode`\<=\active
 
5925
\def<{{\tt \less}}
 
5926
\chardef \gtr=`\>
 
5927
\catcode`\>=\active
 
5928
\def>{{\tt \gtr}}
 
5929
\catcode`\+=\active
 
5930
\def+{{\tt \char 43}}
 
5931
\catcode`\$=\active
 
5932
\def${\ifusingit{{\sl\$}}\normaldollar}
 
5933
%\catcode 27=\active
 
5934
%\def^^[{$\diamondsuit$}
 
5935
 
 
5936
% Set up an active definition for =, but don't enable it most of the time.
 
5937
{\catcode`\==\active
 
5938
\global\def={{\tt \char 61}}}
 
5939
 
 
5940
\catcode`+=\active
 
5941
\catcode`\_=\active
 
5942
 
 
5943
% If a .fmt file is being used, characters that might appear in a file
 
5944
% name cannot be active until we have parsed the command line.
 
5945
% So turn them off again, and have \everyjob (or @setfilename) turn them on.
 
5946
% \otherifyactive is called near the end of this file.
 
5947
\def\otherifyactive{\catcode`+=\other \catcode`\_=\other}
 
5948
 
 
5949
\catcode`\@=0
 
5950
 
 
5951
% \rawbackslashxx output one backslash character in current font
 
5952
\global\chardef\rawbackslashxx=`\\
 
5953
%{\catcode`\\=\other
 
5954
%@gdef@rawbackslashxx{\}}
 
5955
 
 
5956
% \rawbackslash redefines \ as input to do \rawbackslashxx.
 
5957
{\catcode`\\=\active
 
5958
@gdef@rawbackslash{@let\=@rawbackslashxx }}
 
5959
 
 
5960
% \normalbackslash outputs one backslash in fixed width font.
 
5961
\def\normalbackslash{{\tt\rawbackslashxx}}
 
5962
 
 
5963
% \catcode 17=0   % Define control-q
 
5964
\catcode`\\=\active
 
5965
 
 
5966
% Used sometimes to turn off (effectively) the active characters
 
5967
% even after parsing them.
 
5968
@def@turnoffactive{@let"=@normaldoublequote
 
5969
@let\=@realbackslash
 
5970
@let~=@normaltilde
 
5971
@let^=@normalcaret
 
5972
@let_=@normalunderscore
 
5973
@let|=@normalverticalbar
 
5974
@let<=@normalless
 
5975
@let>=@normalgreater
 
5976
@let+=@normalplus
 
5977
@let$=@normaldollar}
 
5978
 
 
5979
@def@normalturnoffactive{@let"=@normaldoublequote
 
5980
@let\=@normalbackslash
 
5981
@let~=@normaltilde
 
5982
@let^=@normalcaret
 
5983
@let_=@normalunderscore
 
5984
@let|=@normalverticalbar
 
5985
@let<=@normalless
 
5986
@let>=@normalgreater
 
5987
@let+=@normalplus
 
5988
@let$=@normaldollar}
 
5989
 
 
5990
% Make _ and + \other characters, temporarily.
 
5991
% This is canceled by @fixbackslash.
 
5992
@otherifyactive
 
5993
 
 
5994
% If a .fmt file is being used, we don't want the `\input texinfo' to show up.
 
5995
% That is what \eatinput is for; after that, the `\' should revert to printing
 
5996
% a backslash.
 
5997
%
 
5998
@gdef@eatinput input texinfo{@fixbackslash}
 
5999
@global@let\ = @eatinput
 
6000
 
 
6001
% On the other hand, perhaps the file did not have a `\input texinfo'. Then
 
6002
% the first `\{ in the file would cause an error. This macro tries to fix
 
6003
% that, assuming it is called before the first `\' could plausibly occur.
 
6004
% Also back turn on active characters that might appear in the input
 
6005
% file name, in case not using a pre-dumped format.
 
6006
%
 
6007
@gdef@fixbackslash{%
 
6008
  @ifx\@eatinput @let\ = @normalbackslash @fi
 
6009
  @catcode`+=@active
 
6010
  @catcode`@_=@active
 
6011
}
 
6012
 
 
6013
% Say @foo, not \foo, in error messages.
 
6014
@escapechar = `@@
 
6015
 
 
6016
% These look ok in all fonts, so just make them not special.  
 
6017
@catcode`@& = @other
 
6018
@catcode`@# = @other
 
6019
@catcode`@% = @other
 
6020
 
 
6021
@c Set initial fonts.
 
6022
@textfonts
 
6023
@rm
 
6024
 
 
6025
 
 
6026
@c Local variables:
 
6027
@c eval: (add-hook 'write-file-hooks 'time-stamp)
 
6028
@c page-delimiter: "^\\\\message"
 
6029
@c time-stamp-start: "def\\\\texinfoversion{"
 
6030
@c time-stamp-format: "%:y-%02m-%02d.%02H"
 
6031
@c time-stamp-end: "}"
 
6032
@c End: