336
388
% the input line (except we remove a trailing comment). #1 should be a
337
389
% macro which expects an ordinary undelimited TeX argument.
391
\def\parsearg{\parseargusing{}}
392
\def\parseargusing#1#2{%
343
\futurelet\temp\parseargx
346
% If the next token is an obeyed space (from an @example environment or
347
% the like), remove it and recurse. Otherwise, we're done.
349
% \obeyedspace is defined far below, after the definition of \sepspaces.
350
\ifx\obeyedspace\temp
351
\expandafter\parseargdiscardspace
353
\expandafter\parseargline
357
% Remove a single space (as the delimiter token to the macro call).
359
\gdef\parseargdiscardspace {\futurelet\temp\parseargx}}
398
\parseargline\empty% Insert the \empty token, see \finishparsearg below.
362
402
\gdef\parseargline#1^^M{%
363
403
\endgroup % End of the group started in \parsearg.
365
% First remove any @c comment, then any @comment.
366
% Result of each macro is put in \toks0.
367
\argremovec #1\c\relax %
368
\expandafter\argremovecomment \the\toks0 \comment\relax %
370
% Call the caller's macro, saved as \next in \parsearg.
371
\expandafter\next\expandafter{\the\toks0}%
404
\argremovecomment #1\comment\ArgTerm%
375
% Since all \c{,omment} does is throw away the argument, we can let TeX
376
% do that for us. The \relax here is matched by the \relax in the call
377
% in \parseargline; it could be more or less anything, its purpose is
378
% just to delimit the argument to the \c.
379
\def\argremovec#1\c#2\relax{\toks0 = {#1}}
380
\def\argremovecomment#1\comment#2\relax{\toks0 = {#1}}
408
% First remove any @comment, then any @c comment.
409
\def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm}
410
\def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
382
% \argremovec{,omment} might leave us with trailing spaces, though; e.g.,
412
% Each occurence of `\^^M' or `<space>\^^M' is replaced by a single space.
414
% \argremovec might leave us with trailing space, e.g.,
383
415
% @end itemize @c foo
384
% will have two active spaces as part of the argument with the
385
% `itemize'. Here we remove all active spaces from #1, and assign the
388
% This loses if there are any *other* active characters besides spaces
389
% in the argument -- _ ^ +, for example -- since they get expanded.
390
% Fortunately, Texinfo does not define any such commands. (If it ever
391
% does, the catcode of the characters in questionwill have to be changed
392
% here.) But this means we cannot call \removeactivespaces as part of
393
% \argremovec{,omment}, since @c uses \parsearg, and thus the argument
394
% that \parsearg gets might well have any character at all in it.
396
\def\removeactivespaces#1{%
400
\global\toks0 = \expandafter{\temp}%
404
% Change the active space to expand to nothing.
416
% This space token undergoes the same procedure and is eventually removed
417
% by \finishparsearg.
419
\def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M}
420
\def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M}
421
\def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{%
424
% We cannot use \next here, as it holds the macro to run;
425
% thus we reuse \temp.
426
\let\temp\finishparsearg
428
\let\temp\argcheckspaces
430
% Put the space token in:
434
% If a _delimited_ argument is enclosed in braces, they get stripped; so
435
% to get _exactly_ the rest of the line, we had to prevent such situation.
436
% We prepended an \empty token at the very beginning and we expand it now,
437
% just before passing the control to \next.
438
% (Similarily, we have to think about #3 of \argcheckspacesY above: it is
439
% either the null string, or it ends with \^^M---thus there is no danger
440
% that a pair of braces would be stripped.
442
% But first, we have to remove the trailing space token.
444
\def\finishparsearg#1 \ArgTerm{\expandafter\next\expandafter{#1}}
446
% \parseargdef\foo{...}
447
% is roughly equivalent to
448
% \def\foo{\parsearg\Xfoo}
451
% Actually, I use \csname\string\foo\endcsname, ie. \\foo, as it is my
452
% favourite TeX trick. --kasal, 16nov03
455
\expandafter \doparseargdef \csname\string#1\endcsname #1%
457
\def\doparseargdef#1#2{%
462
% Several utility definitions with active space:
408
\gdef\ignoreactivespaces{\obeyspaces\let =\empty}
467
% Make each space character in the input produce a normal interword
468
% space in the output. Don't allow a line break at this space, as this
469
% is used only in environments like @example, where each line of input
470
% should produce a line of output anyway.
472
\gdef\sepspaces{\obeyspaces\let =\tie}
474
% If an index command is used in an @example environment, any spaces
475
% therein should become regular spaces in the raw index file, not the
476
% expansion of \tie (\leavevmode \penalty \@M \ ).
477
\gdef\unsepspaces{\let =\space}
412
481
\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
414
%% These are used to keep @begin/@end levels from running away
415
%% Call \inENV within environments (after a \begingroup)
416
\newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi}
418
\ifENV\errmessage{Still within an environment; press RETURN to continue}
419
\endgroup\fi} % This is not perfect, but it should reduce lossage
421
% @begin foo is the same as @foo, for now.
483
% Define the framework for environments in texinfo.tex. It's used like this:
488
% It's the responsibility of \envdef to insert \begingroup before the
489
% actual body; @end closes the group after calling \Efoo. \envdef also
490
% defines \thisenv, so the current environment is known; @end checks
491
% whether the environment name matches. The \checkenv macro can also be
492
% used to check whether the current environment is the one expected.
494
% Non-false conditionals (@iftex, @ifset) don't fit into this, so they
495
% are not treated as enviroments; they don't open a group. (The
496
% implementation of @end takes care not to call \endgroup in this
500
% At runtime, environments start with this:
501
\def\startenvironment#1{\begingroup\def\thisenv{#1}}
505
% ... but they get defined via ``\envdef\foo{...}'':
506
\long\def\envdef#1#2{\def#1{\startenvironment#1#2}}
507
\def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}}
509
% Check whether we're in the right environment:
518
% Evironment mismatch, #1 expected:
521
\errmessage{This command can appear only \inenvironment\temp,
522
not \inenvironment\thisenv}%
524
\def\inenvironment#1{%
526
out of any environment%
528
in environment \expandafter\string#1%
532
% @end foo executes the definition of \Efoo.
533
% But first, it executes a specialized version of \checkenv
536
\if 1\csname iscond.#1\endcsname
538
% The general wording of \badenverr may not be ideal, but... --kasal, 06nov03
539
\expandafter\checkenv\csname#1\endcsname
540
\csname E#1\endcsname
422
545
\newhelp\EMsimple{Press RETURN to continue.}
424
\outer\def\begin{\parsearg\beginxxx}
427
\expandafter\ifx\csname #1\endcsname\relax
428
{\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else
429
\csname #1\endcsname\fi}
431
% @end foo executes the definition of \Efoo.
433
\def\end{\parsearg\endxxx}
435
\removeactivespaces{#1}%
436
\edef\endthing{\the\toks0}%
438
\expandafter\ifx\csname E\endthing\endcsname\relax
439
\expandafter\ifx\csname \endthing\endcsname\relax
440
% There's no \foo, i.e., no ``environment'' foo.
442
\errmessage{Undefined command `@end \endthing'}%
444
\unmatchedenderror\endthing
447
% Everything's ok; the right environment has been started.
448
\csname E\endthing\endcsname
452
% There is an environment #1, but it hasn't been started. Give an error.
454
\def\unmatchedenderror#1{%
456
\errmessage{This `@end #1' doesn't have a matching `@#1'}%
459
% Define the control sequence \E#1 to give an unmatched @end error.
461
\def\defineunmatchedend#1{%
462
\expandafter\def\csname E#1\endcsname{\unmatchedenderror{#1}}%
466
548
%% Simple single-character @ commands
2599
2768
\def\menu{\doignore{menu}}
2600
2769
\def\xml{\doignore{xml}}
2602
% @dircategory CATEGORY -- specify a category of the dir file
2603
% which this file should belong to. Ignore this in TeX.
2604
\let\dircategory = \comment
2606
% Ignore text until a line `@end #1'.
2771
% Ignore text until a line `@end #1', keeping track of nested conditionals.
2773
% A count to remember the depth of nesting.
2774
\newcount\doignorecount
2608
2776
\def\doignore#1{\begingroup
2609
% Don't complain about control sequences we have declared \outer.
2612
% Define a command to swallow text until we reach `@end #1'.
2613
% This @ is a catcode 12 token (that is the normal catcode of @ in
2614
% this texinfo.tex file). We change the catcode of @ below to match.
2615
\long\def\doignoretext##1@end #1{\enddoignore}%
2777
% Scan in ``verbatim'' mode:
2778
\catcode`\@ = \other
2779
\catcode`\{ = \other
2780
\catcode`\} = \other
2617
2782
% Make sure that spaces turn into tokens that match what \doignoretext wants.
2618
\catcode\spaceChar = 10
2620
% Ignore braces, too, so mismatched braces don't cause trouble.
2624
% We must not have @c interpreted as a control sequence.
2627
\def\ignoreword{#1}%
2628
\ifx\ignoreword\documentdescriptionword
2629
% The c kludge breaks documentdescription, since
2630
% `documentdescription' contains a `c'. Means not everything will
2631
% be ignored inside @documentdescription, but oh well...
2633
% Make the letter c a comment character so that the rest of the line
2634
% will be ignored. This way, the document can have (for example)
2636
% and the @end ifinfo will be properly ignored.
2637
% (We've just changed @ to catcode 12.)
2641
% And now expand the command defined above.
2645
% What we do to finish off ignored text.
2647
\def\enddoignore{\endgroup\ignorespaces}%
2649
\newif\ifwarnedobs\warnedobsfalse
2651
\ifwarnedobs\relax\else
2652
% We need to warn folks that they may have trouble with TeX 3.0.
2653
% This uses \immediate\write16 rather than \message to get newlines.
2654
\immediate\write16{}
2655
\immediate\write16{WARNING: for users of Unix TeX 3.0!}
2656
\immediate\write16{This manual trips a bug in TeX version 3.0 (tex hangs).}
2657
\immediate\write16{If you are running another version of TeX, relax.}
2658
\immediate\write16{If you are running Unix TeX 3.0, kill this TeX process.}
2659
\immediate\write16{ Then upgrade your TeX installation if you can.}
2660
\immediate\write16{ (See ftp://ftp.gnu.org/non-gnu/TeX.README.)}
2661
\immediate\write16{If you are stuck with version 3.0, run the}
2662
\immediate\write16{ script ``tex3patch'' from the Texinfo distribution}
2663
\immediate\write16{ to use a workaround.}
2664
\immediate\write16{}
2665
\global\warnedobstrue
2669
% **In TeX 3.0, setting text in \nullfont hangs tex. For a
2670
% workaround (which requires the file ``dummy.tfm'' to be installed),
2671
% uncomment the following line:
2672
%%%%%\font\nullfont=dummy\let\obstexwarn=\relax
2674
% Ignore text, except that we keep track of conditional commands for
2675
% purposes of nesting, up to an `@end #1' command.
2677
\def\nestedignore#1{%
2679
% We must actually expand the ignored text to look for the @end
2680
% command, so that nested ignore constructs work. Thus, we put the
2681
% text into a \vbox and then do nothing with the result. To minimize
2682
% the chance of memory overflow, we follow the approach outlined on
2683
% page 401 of the TeXbook.
2685
\setbox0 = \vbox\bgroup
2686
% Don't complain about control sequences we have declared \outer.
2689
% Define `@end #1' to end the box, which will in turn undefine the
2690
% @end command again.
2691
\expandafter\def\csname E#1\endcsname{\egroup\ignorespaces}%
2693
% We are going to be parsing Texinfo commands. Most cause no
2694
% trouble when they are used incorrectly, but some commands do
2695
% complicated argument parsing or otherwise get confused, so we
2698
% We can't do anything about stray @-signs, unfortunately;
2699
% they'll produce `undefined control sequence' errors.
2702
% Set the current font to be \nullfont, a TeX primitive, and define
2703
% all the font commands to also use \nullfont. We don't use
2704
% dummy.tfm, as suggested in the TeXbook, because some sites
2705
% might not have that installed. Therefore, math mode will still
2706
% produce output, but that should be an extremely small amount of
2707
% stuff compared to the main input.
2710
\let\tenrm=\nullfont \let\tenit=\nullfont \let\tensl=\nullfont
2711
\let\tenbf=\nullfont \let\tentt=\nullfont \let\smallcaps=\nullfont
2712
\let\tensf=\nullfont
2713
% Similarly for index fonts.
2714
\let\smallrm=\nullfont \let\smallit=\nullfont \let\smallsl=\nullfont
2715
\let\smallbf=\nullfont \let\smalltt=\nullfont \let\smallsc=\nullfont
2716
\let\smallsf=\nullfont
2717
% Similarly for smallexample fonts.
2718
\let\smallerrm=\nullfont \let\smallerit=\nullfont \let\smallersl=\nullfont
2719
\let\smallerbf=\nullfont \let\smallertt=\nullfont \let\smallersc=\nullfont
2720
\let\smallersf=\nullfont
2722
% Don't complain when characters are missing from the fonts.
2723
\tracinglostchars = 0
2725
% Don't bother to do space factor calculations.
2728
% Don't report underfull hboxes.
2731
% Do minimal line-breaking.
2732
\pretolerance = 10000
2734
% Do not execute instructions in @tex.
2735
\def\tex{\doignore{tex}}%
2736
% Do not execute macro definitions.
2737
% `c' is a comment character, so the word `macro' will get cut off.
2738
\def\macro{\doignore{ma}}%
2785
% Count number of #1's that we've seen.
2788
% Swallow text until we reach the matching `@end #1'.
2792
{ \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source.
2795
\gdef\dodoignore#1{%
2796
% #1 contains the string `ifinfo'.
2798
% Define a command to find the next `@end #1', which must be on a line
2800
\long\def\doignoretext##1^^M@end #1{\doignoretextyyy##1^^M@#1\_STOP_}%
2801
% And this command to find another #1 command, at the beginning of a
2802
% line. (Otherwise, we would consider a line `@c @ifset', for
2803
% example, to count as an @ifset for nesting.)
2804
\long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}%
2806
% And now expand that command.
2812
\def\doignoreyyy#1{%
2814
\ifx\temp\empty % Nothing found.
2815
\let\next\doignoretextzzz
2816
\else % Found a nested condition, ...
2817
\advance\doignorecount by 1
2818
\let\next\doignoretextyyy % ..., look for another.
2819
% If we're here, #1 ends with ^^M\ifinfo (for example).
2821
\next #1% the token \_STOP_ is present just after this macro.
2824
% We have to swallow the remaining "\_STOP_".
2826
\def\doignoretextzzz#1{%
2827
\ifnum\doignorecount = 0 % We have just found the outermost @end.
2828
\let\next\enddoignore
2829
\else % Still inside a nested condition.
2830
\advance\doignorecount by -1
2831
\let\next\doignoretext % Look for the next @end.
2836
% Finish off ignored text.
2837
\def\enddoignore{\endgroup\ignorespaces}
2741
2840
% @set VAR sets the variable VAR to an empty value.
2742
2841
% @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
3160
3263
\def\exclamdown{!}%
3161
3264
\def\questiondown{?}%
3163
% Don't no-op \tt, since it isn't a user-level command
3164
% and is used in the definitions of the active chars like <, >, |, etc.
3165
% Likewise with the other plain tex font commands.
3168
% Texinfo font commands.
3175
\let\TeX=\indexdummytex
3181
\let\dots=\indexdummydots
3271
% Assorted special characters.
3272
% (The following {} will end up in the sort string, but that's ok.)
3273
\def\bullet{bullet}%
3274
\def\copyright{copyright}%
3275
\def\registeredsymbol{R}%
3280
\def\expansion{==>}%
3282
\def\pounds{pounds}%
3287
% Don't write macro names.
3197
3291
\let\indexbackslash=0 %overridden during \printindex.
3198
3292
\let\SETmarginindex=\relax % put index entries in margin (undocumented)?
3200
% For \ifx comparisons.
3201
\def\emptymacro{\empty}
3203
3294
% Most index entries go through here, but \dosubind is the general case.
3205
\def\doind#1#2{\dosubind{#1}{#2}\empty}
3295
% #1 is the index name, #2 is the entry text.
3296
\def\doind#1#2{\dosubind{#1}{#2}{}}
3207
3298
% Workhorse for all \fooindexes.
3208
3299
% #1 is name of index, #2 is stuff to put there, #3 is subentry --
3209
% \empty if called from \doind, as we usually are. The main exception
3210
% is with defuns, which call us directly.
3300
% empty if called from \doind, as we usually are (the main exception
3301
% is with most defuns, which call us directly).
3212
3303
\def\dosubind#1#2#3{%
3306
% Store the main index entry text (including the third arg).
3308
% If third arg is present, precede it with a space.
3310
\ifx\thirdarg\empty \else
3311
\toks0 = \expandafter{\the\toks0 \space #3}%
3314
\edef\writeto{\csname#1indfile\endcsname}%
3325
% Write the entry in \toks0 to the index file:
3327
\def\dosubindwrite{%
3213
3328
% Put the index entry in the margin if desired.
3214
3329
\ifx\SETmarginindex\relax\else
3215
\insert\margin{\hbox{\vrule height8pt depth3pt width0pt #2}}%
3218
\count255=\lastpenalty
3220
\indexdummies % Must do this here, since \bf, etc expand at this stage
3223
\let\folio = 0% We will expand all macros now EXCEPT \folio.
3224
\def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now
3225
% so it will be output as is; and it will print as backslash.
3227
% The main index entry text.
3230
% If third arg is present, precede it with space in sort key.
3232
\ifx\thirdarg\emptymacro \else
3233
% If the third (subentry) arg is present, add it to the index
3235
\toks0 = \expandafter{\the\toks0 \space #3}%
3238
% Process the index entry with all font commands turned off, to
3239
% get the string to sort by.
3241
\edef\temp{\the\toks0}% need full expansion
3242
\xdef\indexsorttmp{\temp}%
3245
% Set up the complete index entry, with both the sort key and
3246
% the original text, including any font commands. We write
3247
% three arguments to \entry to the .?? file (four in the
3248
% subentry case), texindex reduces to two when writing the .??s
3251
\write\csname#1indfile\endcsname{%
3252
\realbackslash entry{\indexsorttmp}{\folio}{\the\toks0}}%
3255
% If a skip is the last thing on the list now, preserve it
3256
% by backing up by \lastskip, doing the \write, then inserting
3257
% the skip again. Otherwise, the whatsit generated by the
3258
% \write will make \lastskip zero. The result is that sequences
3263
% will have extra space inserted, because the \medbreak in the
3264
% start of the @defun won't see the skip inserted by the @end of
3265
% the previous defun.
3267
% But don't do any of this if we're not in vertical mode. We
3268
% don't want to do a \vskip and prematurely end a paragraph.
3270
% Avoid page breaks due to these extra skips, too.
3275
\ifdim\lastskip = 0pt \else \nobreak\vskip-\skip0 \fi
3278
\temp % do the write
3280
\ifvmode \ifdim\skip0 = 0pt \else \nobreak\vskip\skip0 \fi \fi
3330
\insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}%
3333
% Remember, we are within a group.
3334
\indexdummies % Must do this here, since \bf, etc expand at this stage
3336
\def\backslashcurfont{\indexbackslash}% \indexbackslash isn't defined now
3337
% so it will be output as is; and it will print as backslash.
3339
% Process the index entry with all font commands turned off, to
3340
% get the string to sort by.
3342
\edef\temp{\the\toks0}% need full expansion
3343
\xdef\indexsorttmp{\temp}%
3346
% Set up the complete index entry, with both the sort key and
3347
% the original text, including any font commands. We write
3348
% three arguments to \entry to the .?? file (four in the
3349
% subentry case), texindex reduces to two when writing the .??s
3353
\string\entry{\indexsorttmp}{\noexpand\folio}{\the\toks0}}%
3358
% Take care of unwanted page breaks:
3360
% If a skip is the last thing on the list now, preserve it
3361
% by backing up by \lastskip, doing the \write, then inserting
3362
% the skip again. Otherwise, the whatsit generated by the
3363
% \write will make \lastskip zero. The result is that sequences
3368
% will have extra space inserted, because the \medbreak in the
3369
% start of the @defun won't see the skip inserted by the @end of
3370
% the previous defun.
3372
% But don't do any of this if we're not in vertical mode. We
3373
% don't want to do a \vskip and prematurely end a paragraph.
3375
% Avoid page breaks due to these extra skips, too.
3377
% But wait, there is a catch there:
3378
% We'll have to check whether \lastskip is zero skip. \ifdim is not
3379
% sufficient for this purpose, as it ignores stretch and shrink parts
3380
% of the skip. The only way seems to be to check the textual
3381
% representation of the skip.
3383
% The following is almost like \def\zeroskipmacro{0.0pt} except that
3384
% the ``p'' and ``t'' characters have catcode \other, not 11 (letter).
3386
\edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname}
3390
\def\dosubindsanitize{%
3391
% \lastskip and \lastpenalty cannot both be nonzero simultaneously.
3393
\edef\lastskipmacro{\the\lastskip}%
3394
\count255 = \lastpenalty
3396
% If \lastskip is nonzero, that means the last item was a
3397
% skip. And since a skip is discardable, that means this
3398
% -\skip0 glue we're inserting is preceded by a
3399
% non-discardable item, therefore it is not a potential
3400
% breakpoint, therefore no \nobreak needed.
3401
\ifx\lastskipmacro\zeroskipmacro
3408
\ifx\lastskipmacro\zeroskipmacro
3409
% if \lastskip was zero, perhaps the last item was a
3410
% penalty, and perhaps it was >=10000, e.g., a \nobreak.
3411
% In that case, we want to re-insert the penalty; since we
3412
% just inserted a non-discardable item, any following glue
3413
% (such as a \parskip) would be a breakpoint. For example:
3414
% @deffn deffn-whatever
3415
% @vindex index-whatever
3417
% would allow a break between the index-whatever whatsit
3418
% and the "Description." paragraph.
3419
\ifnum\count255>9999 \nobreak \fi
3421
% On the other hand, if we had a nonzero \lastskip,
3422
% this make-up glue would be preceded by a non-discardable item
3423
% (the whatsit from the \write), so we must insert a \nobreak.
3424
\nobreak\vskip\skip0
3288
3428
% The index entry written in the file actually looks like
3688
3858
\def\lowersections{\global\advance\secbase by 1}
3689
3859
\let\down=\lowersections % original BFox name
3691
% Choose a numbered-heading macro
3692
% #1 is heading level if unmodified by @raisesections or @lowersections
3693
% #2 is text for heading
3694
\def\numhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
3700
\numberedsubseczzz{#2}
3702
\numberedsubsubseczzz{#2}
3704
\ifnum \absseclevel<0
3707
\numberedsubsubseczzz{#2}
3712
% like \numhead, but chooses appendix heading levels
3713
\def\apphead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
3717
\appendixsectionzzz{#2}
3719
\appendixsubseczzz{#2}
3721
\appendixsubsubseczzz{#2}
3723
\ifnum \absseclevel<0
3726
\appendixsubsubseczzz{#2}
3731
% like \numhead, but chooses numberless heading levels
3732
\def\unnmhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
3736
\unnumberedseczzz{#2}
3738
\unnumberedsubseczzz{#2}
3740
\unnumberedsubsubseczzz{#2}
3742
\ifnum \absseclevel<0
3745
\unnumberedsubsubseczzz{#2}
3750
% @chapter, @appendix, @unnumbered.
3751
\def\thischaptername{No Chapter Title}
3752
\outer\def\chapter{\parsearg\chapteryyy}
3753
\def\chapteryyy #1{\numhead0{#1}} % normally numhead0 calls chapterzzz
3754
\def\chapterzzz #1{%
3755
\secno=0 \subsecno=0 \subsubsecno=0
3756
\global\advance \chapno by 1 \message{\putwordChapter\space \the\chapno}%
3757
\chapmacro {#1}{\the\chapno}%
3758
\gdef\thissection{#1}%
3759
\gdef\thischaptername{#1}%
3760
% We don't substitute the actual chapter name into \thischapter
3761
% because we don't want its macros evaluated now.
3762
\xdef\thischapter{\putwordChapter{} \the\chapno: \noexpand\thischaptername}%
3763
\writetocentry{chap}{#1}{{\the\chapno}}
3861
% we only have subsub.
3862
\chardef\maxseclevel = 3
3864
% A numbered section within an unnumbered changes to unnumbered too.
3865
% To achive this, remember the "biggest" unnum. sec. we are currently in:
3866
\chardef\unmlevel = \maxseclevel
3868
% Trace whether the current chapter is an appendix or not:
3869
% \chapheadtype is "N" or "A", unnumbered chapters are ignored.
3870
\def\chapheadtype{N}
3872
% Choose a heading macro
3873
% #1 is heading type
3874
% #2 is heading level
3875
% #3 is text for heading
3876
\def\genhead#1#2#3{%
3877
% Compute the abs. sec. level:
3879
\advance\absseclevel by \secbase
3880
% Make sure \absseclevel doesn't fall outside the range:
3881
\ifnum \absseclevel < 0
3884
\ifnum \absseclevel > 3
3891
\ifnum \absseclevel < \unmlevel
3892
\chardef\unmlevel = \absseclevel
3895
% Check for appendix sections:
3896
\ifnum \absseclevel = 0
3897
\edef\chapheadtype{\headtype}%
3899
\if \headtype A\if \chapheadtype N%
3900
\errmessage{@appendix... within a non-appendix chapter}%
3903
% Check for numbered within unnumbered:
3904
\ifnum \absseclevel > \unmlevel
3907
\chardef\unmlevel = 3
3910
% Now print the heading:
3914
\or \unnumberedseczzz{#3}%
3915
\or \unnumberedsubseczzz{#3}%
3916
\or \unnumberedsubsubseczzz{#3}%
3922
\or \appendixsectionzzz{#3}%
3923
\or \appendixsubseczzz{#3}%
3924
\or \appendixsubsubseczzz{#3}%
3930
\or \numberedsubseczzz{#3}%
3931
\or \numberedsubsubseczzz{#3}%
3935
\suppressfirstparagraphindent
3939
\def\numhead{\genhead N}
3940
\def\apphead{\genhead A}
3941
\def\unnmhead{\genhead U}
3943
% @chapter, @appendix, @unnumbered. Increment top-level counter, reset
3944
% all lower-level sectioning counters to zero.
3946
% Also set \chaplevelprefix, which we prepend to @float sequence numbers
3947
% (e.g., figures), q.v. By default (before any chapter), that is empty.
3948
\let\chaplevelprefix = \empty
3950
\outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz
3952
% section resetting is \global in case the chapter is in a group, such
3953
% as an @include file.
3954
\global\secno=0 \global\subsecno=0 \global\subsubsecno=0
3955
\global\advance\chapno by 1
3958
\gdef\chaplevelprefix{\the\chapno.}%
3961
\message{\putwordChapter\space \the\chapno}%
3963
% Write the actual heading.
3964
\chapmacro{#1}{Ynumbered}{\the\chapno}%
3966
% So @section and the like are numbered underneath this chapter.
3765
3967
\global\let\section = \numberedsec
3766
3968
\global\let\subsection = \numberedsubsec
3767
3969
\global\let\subsubsection = \numberedsubsubsec
3770
% we use \chapno to avoid indenting back
3771
\def\appendixbox#1{%
3772
\setbox0 = \hbox{\putwordAppendix{} \the\chapno}%
3773
\hbox to \wd0{#1\hss}}
3775
\outer\def\appendix{\parsearg\appendixyyy}
3776
\def\appendixyyy #1{\apphead0{#1}} % normally apphead0 calls appendixzzz
3777
\def\appendixzzz #1{%
3778
\secno=0 \subsecno=0 \subsubsecno=0
3779
\global\advance \appendixno by 1
3780
\message{\putwordAppendix\space \appendixletter}%
3781
\chapmacro {#1}{\appendixbox{\putwordAppendix{} \appendixletter}}%
3782
\gdef\thissection{#1}%
3783
\gdef\thischaptername{#1}%
3784
\xdef\thischapter{\putwordAppendix{} \appendixletter: \noexpand\thischaptername}%
3785
\writetocentry{appendix}{#1}{{\appendixletter}}
3972
\outer\parseargdef\appendix{\apphead0{#1}} % normally apphead0 calls appendixzzz
3973
\def\appendixzzz#1{%
3974
\global\secno=0 \global\subsecno=0 \global\subsubsecno=0
3975
\global\advance\appendixno by 1
3976
\gdef\chaplevelprefix{\appendixletter.}%
3979
\def\appendixnum{\putwordAppendix\space \appendixletter}%
3980
\message{\appendixnum}%
3982
\chapmacro{#1}{Yappendix}{\appendixletter}%
3787
3984
\global\let\section = \appendixsec
3788
3985
\global\let\subsection = \appendixsubsec
3789
3986
\global\let\subsubsection = \appendixsubsubsec
3792
% @centerchap is like @unnumbered, but the heading is centered.
3793
\outer\def\centerchap{\parsearg\centerchapyyy}
3794
\def\centerchapyyy #1{{\let\unnumbchapmacro=\centerchapmacro \unnumberedyyy{#1}}}
3796
% @top is like @unnumbered.
3797
\outer\def\top{\parsearg\unnumberedyyy}
3799
\outer\def\unnumbered{\parsearg\unnumberedyyy}
3800
\def\unnumberedyyy #1{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz
3801
\def\unnumberedzzz #1{%
3802
\secno=0 \subsecno=0 \subsubsecno=0
3989
\outer\parseargdef\unnumbered{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz
3990
\def\unnumberedzzz#1{%
3991
\global\secno=0 \global\subsecno=0 \global\subsubsecno=0
3992
\global\advance\unnumberedno by 1
3994
% Since an unnumbered has no number, no prefix for figures.
3995
\global\let\chaplevelprefix = \empty
3804
3998
% This used to be simply \message{#1}, but TeX fully expands the
3805
3999
% argument to \message. Therefore, if #1 contained @-commands, TeX
3812
4006
% \the<toks register> to achieve this: TeX expands \the<toks> only once,
3813
4007
% simply yielding the contents of <toks register>. (We also do this for
3814
4008
% the toc entries.)
3815
\toks0 = {#1}\message{(\the\toks0)}%
3817
\unnumbchapmacro {#1}%
3818
\gdef\thischapter{#1}\gdef\thissection{#1}%
3819
\writetocentry{unnumbchap}{#1}{{\the\chapno}}
4010
\message{(\the\toks0)}%
4012
\chapmacro{#1}{Ynothing}{\the\unnumberedno}%
3821
4014
\global\let\section = \unnumberedsec
3822
4015
\global\let\subsection = \unnumberedsubsec
3823
4016
\global\let\subsubsection = \unnumberedsubsubsec
4019
% @centerchap is like @unnumbered, but the heading is centered.
4020
\outer\parseargdef\centerchap{%
4021
% Well, we could do the following in a group, but that would break
4022
% an assumption that \chapmacro is called at the outermost level.
4023
% Thus we are safer this way: --kasal, 24feb04
4024
\let\centerparametersmaybe = \centerparameters
4026
\let\centerparametersmaybe = \relax
4029
% @top is like @unnumbered.
3827
\outer\def\numberedsec{\parsearg\secyyy}
3828
\def\secyyy #1{\numhead1{#1}} % normally calls seczzz
3830
\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
3831
\gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}%
3832
\writetocentry{sec}{#1}{{\the\chapno}{\the\secno}}
3837
\outer\def\appendixsection{\parsearg\appendixsecyyy}
3838
\outer\def\appendixsec{\parsearg\appendixsecyyy}
3839
\def\appendixsecyyy #1{\apphead1{#1}} % normally calls appendixsectionzzz
3840
\def\appendixsectionzzz #1{%
3841
\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
3842
\gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}%
3843
\writetocentry{sec}{#1}{{\appendixletter}{\the\secno}}
3848
\outer\def\unnumberedsec{\parsearg\unnumberedsecyyy}
3849
\def\unnumberedsecyyy #1{\unnmhead1{#1}} % normally calls unnumberedseczzz
3850
\def\unnumberedseczzz #1{%
3851
\plainsecheading {#1}\gdef\thissection{#1}%
3852
\writetocentry{unnumbsec}{#1}{{\the\chapno}{\the\secno}}
4033
\outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
4035
\global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
4036
\sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}%
4039
\outer\parseargdef\appendixsection{\apphead1{#1}} % normally calls appendixsectionzzz
4040
\def\appendixsectionzzz#1{%
4041
\global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
4042
\sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}%
4044
\let\appendixsec\appendixsection
4046
\outer\parseargdef\unnumberedsec{\unnmhead1{#1}} % normally calls unnumberedseczzz
4047
\def\unnumberedseczzz#1{%
4048
\global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
4049
\sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%
3858
\outer\def\numberedsubsec{\parsearg\numberedsubsecyyy}
3859
\def\numberedsubsecyyy #1{\numhead2{#1}} % normally calls numberedsubseczzz
3860
\def\numberedsubseczzz #1{%
3861
\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
3862
\subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}%
3863
\writetocentry{subsec}{#1}{{\the\chapno}{\the\secno}{\the\subsecno}}
3868
\outer\def\appendixsubsec{\parsearg\appendixsubsecyyy}
3869
\def\appendixsubsecyyy #1{\apphead2{#1}} % normally calls appendixsubseczzz
3870
\def\appendixsubseczzz #1{%
3871
\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
3872
\subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}%
3873
\writetocentry{subsec}{#1}{{\appendixletter}{\the\secno}{\the\subsecno}}
3878
\outer\def\unnumberedsubsec{\parsearg\unnumberedsubsecyyy}
3879
\def\unnumberedsubsecyyy #1{\unnmhead2{#1}} %normally calls unnumberedsubseczzz
3880
\def\unnumberedsubseczzz #1{%
3881
\plainsubsecheading {#1}\gdef\thissection{#1}%
3882
\writetocentry{unnumbsubsec}{#1}{{\the\chapno}{\the\secno}{\the\subsecno}}
4053
\outer\parseargdef\numberedsubsec{\numhead2{#1}} % normally calls numberedsubseczzz
4054
\def\numberedsubseczzz#1{%
4055
\global\subsubsecno=0 \global\advance\subsecno by 1
4056
\sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}%
4059
\outer\parseargdef\appendixsubsec{\apphead2{#1}} % normally calls appendixsubseczzz
4060
\def\appendixsubseczzz#1{%
4061
\global\subsubsecno=0 \global\advance\subsecno by 1
4062
\sectionheading{#1}{subsec}{Yappendix}%
4063
{\appendixletter.\the\secno.\the\subsecno}%
4066
\outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}} %normally calls unnumberedsubseczzz
4067
\def\unnumberedsubseczzz#1{%
4068
\global\subsubsecno=0 \global\advance\subsecno by 1
4069
\sectionheading{#1}{subsec}{Ynothing}%
4070
{\the\unnumberedno.\the\secno.\the\subsecno}%
3887
4073
% Subsubsections.
3888
\outer\def\numberedsubsubsec{\parsearg\numberedsubsubsecyyy}
3889
\def\numberedsubsubsecyyy #1{\numhead3{#1}} % normally numberedsubsubseczzz
3890
\def\numberedsubsubseczzz #1{%
3891
\gdef\thissection{#1}\global\advance \subsubsecno by 1 %
3892
\subsubsecheading {#1}
3893
{\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
3894
\writetocentry{subsubsec}{#1}{{\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}}
3899
\outer\def\appendixsubsubsec{\parsearg\appendixsubsubsecyyy}
3900
\def\appendixsubsubsecyyy #1{\apphead3{#1}} % normally appendixsubsubseczzz
3901
\def\appendixsubsubseczzz #1{%
3902
\gdef\thissection{#1}\global\advance \subsubsecno by 1 %
3903
\subsubsecheading {#1}
3904
{\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
3905
\writetocentry{subsubsec}{#1}{{\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}}
3910
\outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubsecyyy}
3911
\def\unnumberedsubsubsecyyy #1{\unnmhead3{#1}} %normally unnumberedsubsubseczzz
3912
\def\unnumberedsubsubseczzz #1{%
3913
\plainsubsubsecheading {#1}\gdef\thissection{#1}%
3914
\writetocentry{unnumbsubsubsec}{#1}{{\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}}
3919
% These are variants which are not "outer", so they can appear in @ifinfo.
3920
% Actually, they should now be obsolete; ordinary section commands should work.
3921
\def\infotop{\parsearg\unnumberedzzz}
3922
\def\infounnumbered{\parsearg\unnumberedzzz}
3923
\def\infounnumberedsec{\parsearg\unnumberedseczzz}
3924
\def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz}
3925
\def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
3927
\def\infoappendix{\parsearg\appendixzzz}
3928
\def\infoappendixsec{\parsearg\appendixseczzz}
3929
\def\infoappendixsubsec{\parsearg\appendixsubseczzz}
3930
\def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz}
3932
\def\infochapter{\parsearg\chapterzzz}
3933
\def\infosection{\parsearg\sectionzzz}
3934
\def\infosubsection{\parsearg\subsectionzzz}
3935
\def\infosubsubsection{\parsearg\subsubsectionzzz}
4074
\outer\parseargdef\numberedsubsubsec{\numhead3{#1}} % normally numberedsubsubseczzz
4075
\def\numberedsubsubseczzz#1{%
4076
\global\advance\subsubsecno by 1
4077
\sectionheading{#1}{subsubsec}{Ynumbered}%
4078
{\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}%
4081
\outer\parseargdef\appendixsubsubsec{\apphead3{#1}} % normally appendixsubsubseczzz
4082
\def\appendixsubsubseczzz#1{%
4083
\global\advance\subsubsecno by 1
4084
\sectionheading{#1}{subsubsec}{Yappendix}%
4085
{\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}%
4088
\outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}} %normally unnumberedsubsubseczzz
4089
\def\unnumberedsubsubseczzz#1{%
4090
\global\advance\subsubsecno by 1
4091
\sectionheading{#1}{subsubsec}{Ynothing}%
4092
{\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}%
3937
4095
% These macros control what the section commands do, according
3938
4096
% to what kind of chapter we are in (ordinary, appendix, or unnumbered).
3939
4097
% Define them by default for a numbered chapter.
3940
\global\let\section = \numberedsec
3941
\global\let\subsection = \numberedsubsec
3942
\global\let\subsubsection = \numberedsubsubsec
4098
\let\section = \numberedsec
4099
\let\subsection = \numberedsubsec
4100
\let\subsubsection = \numberedsubsubsec
3944
4102
% Define @majorheading, @heading and @subheading
4013
\global\let\chapmacro=\chfplain
4014
\global\let\unnumbchapmacro=\unnchfplain
4015
\global\let\centerchapmacro=\centerchfplain}
4017
% Plain chapter opening.
4018
% #1 is the text, #2 the chapter number or empty if unnumbered.
4174
% #1 is the text, #2 is the section type (Ynumbered, Ynothing,
4175
% Yappendix, Yomitfromtoc), #3 the chapter number.
4177
% To test against our argument.
4178
\def\Ynothingkeyword{Ynothing}
4179
\def\Yomitfromtockeyword{Yomitfromtoc}
4180
\def\Yappendixkeyword{Yappendix}
4182
\def\chapmacro#1#2#3{%
4024
\setbox0 = \hbox{#2\ifx\chapnum\empty\else\enspace\fi}%
4187
% Have to define \thissection before calling \donoderef, because the
4188
% xref code eventually uses it. On the other hand, it has to be called
4189
% after \pchapsepmacro, or the headline will change too soon.
4190
\gdef\thissection{#1}%
4191
\gdef\thischaptername{#1}%
4193
% Only insert the separating space if we have a chapter/appendix
4194
% number, and don't print the unnumbered ``number''.
4196
\ifx\temptype\Ynothingkeyword
4198
\def\toctype{unnchap}%
4199
\def\thischapter{#1}%
4200
\else\ifx\temptype\Yomitfromtockeyword
4201
\setbox0 = \hbox{}% contents like unnumbered, but no toc entry
4203
\xdef\thischapter{}%
4204
\else\ifx\temptype\Yappendixkeyword
4205
\setbox0 = \hbox{\putwordAppendix{} #3\enspace}%
4207
% We don't substitute the actual chapter name into \thischapter
4208
% because we don't want its macros evaluated now. And we don't
4209
% use \thissection because that changes with each section.
4211
\xdef\thischapter{\putwordAppendix{} \appendixletter:
4212
\noexpand\thischaptername}%
4214
\setbox0 = \hbox{#3\enspace}%
4215
\def\toctype{numchap}%
4216
\xdef\thischapter{\putwordChapter{} \the\chapno:
4217
\noexpand\thischaptername}%
4220
% Write the toc entry for this chapter. Must come before the
4221
% \donoderef, because we include the current node name in the toc
4222
% entry, and \donoderef resets it to empty.
4223
\writetocentry{\toctype}{#1}{#3}%
4225
% For pdftex, we have to write out the node definition (aka, make
4226
% the pdfdest) after any page break, but before the actual text has
4227
% been typeset. If the destination for the pdf outline is after the
4228
% text, then jumping from the outline may wind up with the text not
4229
% being visible, for instance under high magnification.
4232
% Typeset the actual heading.
4025
4233
\vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
4026
\hangindent = \wd0 \centerparametersmaybe
4234
\hangindent=\wd0 \centerparametersmaybe
4027
4235
\unhbox0 #1\par}%
4029
4237
\nobreak\bigskip % no page break after a chapter title
4033
% Plain opening for unnumbered.
4034
\def\unnchfplain#1{\chfplain{#1}{}}
4036
4241
% @centerchap -- centered and unnumbered.
4037
4242
\let\centerparametersmaybe = \relax
4038
\def\centerchfplain#1{{%
4039
\def\centerparametersmaybe{%
4040
\advance\rightskip by 3\rightskip
4041
\leftskip = \rightskip
4047
\CHAPFplain % The default
4243
\def\centerparameters{%
4244
\advance\rightskip by 3\rightskip
4245
\leftskip = \rightskip
4250
% I don't think this chapter style is supported any more, so I'm not
4251
% updating it with the new noderef stuff. We'll see. --karl, 11aug03.
4253
\def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
4049
4255
\def\unnchfopen #1{%
4050
4256
\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
4051
4257
\parindent=0pt\raggedright
4052
4258
\rm #1\hfill}}\bigskip \par\nobreak
4055
4260
\def\chfopen #1#2{\chapoddpage {\chapfonts
4056
4261
\vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
4057
4262
\par\penalty 5000 %
4060
4264
\def\centerchfopen #1{%
4061
4265
\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
4063
4267
\hfill {\rm #1}\hfill}}\bigskip \par\nobreak
4067
\global\let\chapmacro=\chfopen
4068
\global\let\unnumbchapmacro=\unnchfopen
4069
\global\let\centerchapmacro=\centerchfopen}
4270
\global\let\chapmacro=\chfopen
4271
\global\let\centerchapmacro=\centerchfopen}
4274
% Section titles. These macros combine the section number parts and
4275
% call the generic \sectionheading to do the printing.
4073
4277
\newskip\secheadingskip
4074
\def\secheadingbreak{\dobreak \secheadingskip {-1000}}
4075
\def\secheading#1#2#3{\sectionheading{sec}{#2.#3}{#1}}
4076
\def\plainsecheading#1{\sectionheading{sec}{}{#1}}
4278
\def\secheadingbreak{\dobreak \secheadingskip{-1000}}
4078
4280
% Subsection titles.
4079
\newskip \subsecheadingskip
4080
\def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}}
4081
\def\subsecheading#1#2#3#4{\sectionheading{subsec}{#2.#3.#4}{#1}}
4082
\def\plainsubsecheading#1{\sectionheading{subsec}{}{#1}}
4281
\newskip\subsecheadingskip
4282
\def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}}
4084
4284
% Subsubsection titles.
4085
\let\subsubsecheadingskip = \subsecheadingskip
4086
\let\subsubsecheadingbreak = \subsecheadingbreak
4087
\def\subsubsecheading#1#2#3#4#5{\sectionheading{subsubsec}{#2.#3.#4.#5}{#1}}
4088
\def\plainsubsubsecheading#1{\sectionheading{subsubsec}{}{#1}}
4091
% Print any size section title.
4093
% #1 is the section type (sec/subsec/subsubsec), #2 is the section
4094
% number (maybe empty), #3 the text.
4095
\def\sectionheading#1#2#3{%
4097
\expandafter\advance\csname #1headingskip\endcsname by \parskip
4098
\csname #1headingbreak\endcsname
4285
\def\subsubsecheadingskip{\subsecheadingskip}
4286
\def\subsubsecheadingbreak{\subsecheadingbreak}
4289
% Print any size, any type, section title.
4291
% #1 is the text, #2 is the section level (sec/subsec/subsubsec), #3 is
4292
% the section type for xrefs (Ynumbered, Ynothing, Yappendix), #4 is the
4295
\def\sectionheading#1#2#3#4{%
4101
4297
% Switch to the right set of fonts.
4102
\csname #1fonts\endcsname \rm
4104
% Only insert the separating space if we have a section number.
4106
\setbox0 = \hbox{#2\ifx\secnum\empty\else\enspace\fi}%
4298
\csname #2fonts\endcsname \rm
4300
% Insert space above the heading.
4301
\csname #2headingbreak\endcsname
4303
% Only insert the space after the number if we have a section number.
4304
\def\sectionlevel{#2}%
4307
\ifx\temptype\Ynothingkeyword
4310
\gdef\thissection{#1}%
4311
\else\ifx\temptype\Yomitfromtockeyword
4312
% for @headings -- no section number, don't include in toc,
4313
% and don't redefine \thissection.
4316
\let\sectionlevel=\empty
4317
\else\ifx\temptype\Yappendixkeyword
4318
\setbox0 = \hbox{#4\enspace}%
4320
\gdef\thissection{#1}%
4322
\setbox0 = \hbox{#4\enspace}%
4324
\gdef\thissection{#1}%
4327
% Write the toc entry (before \donoderef). See comments in \chfplain.
4328
\writetocentry{\toctype\sectionlevel}{#1}{#4}%
4330
% Write the node reference (= pdf destination for pdftex).
4331
% Again, see comments in \chfplain.
4334
% Output the actual section heading.
4108
4335
\vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
4109
\hangindent = \wd0 % zero if no section number
4336
\hangindent=\wd0 % zero if no section number
4112
% Add extra space after the heading -- either a line space or a
4113
% paragraph space, whichever is more. (Some people like to set
4114
% \parskip to large values for some reason.) Don't allow stretch, though.
4339
% Add extra space after the heading -- half of whatever came above it.
4340
% Don't allow stretch, though.
4341
\kern .5 \csname #2headingskip\endcsname
4343
% Do not let the kern be a potential breakpoint, as it would be if it
4344
% was followed by glue.
4116
\ifdim\parskip>\normalbaselineskip
4119
\kern\normalbaselineskip
4347
% We'll almost certainly start a paragraph next, so don't let that
4348
% glue accumulate. (Not a breakpoint because it's preceded by a
4349
% discardable item.)
4352
% This \nobreak is purely so the last item on the list is a \penalty
4353
% of 10000. This is so other code, for instance \parsebodycommon, can
4354
% check for and avoid allowing breakpoints. Otherwise, it would
4355
% insert a valid breakpoint between:
4356
% @section sec-whatever
4357
% @deffn def-whatever
4127
4364
\newwrite\tocfile
4129
4366
% Write an entry to the toc file, opening it if necessary.
4130
% Called from @chapter, etc. We supply {\folio} at the end of the
4131
% argument, which will end up as the last argument to the \...entry macro.
4133
% Usage: \writetocentry{chap}{The Name of The Game}{{\the\chapno}}
4367
% Called from @chapter, etc.
4369
% Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno}
4370
% We append the current node name (if any) and page number as additional
4371
% arguments for the \{chap,sec,...}entry macros which will eventually
4372
% read this. The node name is used in the pdf outlines as the
4373
% destination to jump to.
4134
4375
% We open the .toc file for writing here instead of at @setfilename (or
4135
4376
% any other fixed time) so that @contents can be anywhere in the document.
4377
% But if #1 is `omit', then we don't do anything. This is used for the
4378
% table of contents chapter openings themselves.
4137
4380
\newif\iftocfileopened
4381
\def\omitkeyword{omit}%
4138
4383
\def\writetocentry#1#2#3{%
4139
\iftocfileopened\else
4140
\immediate\openout\tocfile = \jobname.toc
4141
\global\tocfileopenedtrue
4146
\edef\temp{\write\tocfile{\realbackslash #1entry{\the\toks0}#3{\folio}}}%
4150
% Tell \shipout to create a page destination if we're doing pdf, which
4151
% will be the target of the links in the table of contents. We can't
4152
% just do it on every page because the title pages are numbered 1 and
4153
% 2 (the page numbers aren't printed), and so are the first two pages
4154
% of the document. Thus, we'd have two destinations named `1', and
4156
\ifpdf \pdfmakepagedesttrue \fi
4384
\edef\writetoctype{#1}%
4385
\ifx\writetoctype\omitkeyword \else
4386
\iftocfileopened\else
4387
\immediate\openout\tocfile = \jobname.toc
4388
\global\tocfileopenedtrue
4393
\toks2 = \expandafter{\lastnode}%
4394
\edef\temp{\write\tocfile{\realbackslash #1entry{\the\toks0}{#3}%
4395
{\the\toks2}{\noexpand\folio}}}%
4400
% Tell \shipout to create a pdf destination on each page, if we're
4401
% writing pdf. These are used in the table of contents. We can't
4402
% just write one on every page because the title pages are numbered
4403
% 1 and 2 (the page numbers aren't printed), and so are the first
4404
% two pages of the document. Thus, we'd have two destinations named
4405
% `1', and two named `2'.
4406
\ifpdf \global\pdfmakepagedesttrue \fi
4159
4409
\newskip\contentsrightmargin \contentsrightmargin=1in
4160
4410
\newcount\savepageno
4161
4411
\newcount\lastnegativepageno \lastnegativepageno = -1
4163
% Finish up the main text and prepare to read what we've written
4413
% Prepare to read what we've written to \tocfile.
4166
4415
\def\startcontents#1{%
4167
% If @setchapternewpage on, and @headings double, the contents should
4168
% start on an odd page, unlike chapters. Thus, we maintain
4169
% \contentsalignmacro in parallel with \pagealignmacro.
4170
% From: Torbjorn Granlund <tege@matematik.su.se>
4172
\immediate\closeout\tocfile
4174
% Don't need to put `Contents' or `Short Contents' in the headline.
4175
% It is abundantly clear what they are.
4176
\unnumbchapmacro{#1}\def\thischapter{}%
4177
\savepageno = \pageno
4178
\begingroup % Set up to handle contents files properly.
4179
\catcode`\\=0 \catcode`\{=1 \catcode`\}=2 \catcode`\@=11
4180
% We can't do this, because then an actual ^ in a section
4181
% title fails, e.g., @chapter ^ -- exponentiation. --karl, 9jul97.
4182
%\catcode`\^=7 % to see ^^e4 as \"a etc. juha@piuha.ydi.vtt.fi
4183
\raggedbottom % Worry more about breakpoints than the bottom.
4184
\advance\hsize by -\contentsrightmargin % Don't use the full line length.
4186
% Roman numerals for page numbers.
4187
\ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
4416
% If @setchapternewpage on, and @headings double, the contents should
4417
% start on an odd page, unlike chapters. Thus, we maintain
4418
% \contentsalignmacro in parallel with \pagealignmacro.
4419
% From: Torbjorn Granlund <tege@matematik.su.se>
4421
\immediate\closeout\tocfile
4423
% Don't need to put `Contents' or `Short Contents' in the headline.
4424
% It is abundantly clear what they are.
4426
\chapmacro{#1}{Yomitfromtoc}{}%
4428
\savepageno = \pageno
4429
\begingroup % Set up to handle contents files properly.
4430
\catcode`\\=0 \catcode`\{=1 \catcode`\}=2 \catcode`\@=11
4431
% We can't do this, because then an actual ^ in a section
4432
% title fails, e.g., @chapter ^ -- exponentiation. --karl, 9jul97.
4433
%\catcode`\^=7 % to see ^^e4 as \"a etc. juha@piuha.ydi.vtt.fi
4434
\raggedbottom % Worry more about breakpoints than the bottom.
4435
\advance\hsize by -\contentsrightmargin % Don't use the full line length.
4437
% Roman numerals for page numbers.
4438
\ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
4191
4442
% Normal (long) toc.
4192
4443
\def\contents{%
4193
\startcontents{\putwordTOC}%
4194
\openin 1 \jobname.toc
4200
\contentsalignmacro % in case @setchapternewpage odd is in effect
4203
\lastnegativepageno = \pageno
4204
\global\pageno = \savepageno
4444
\startcontents{\putwordTOC}%
4445
\openin 1 \jobname.toc
4450
\contentsalignmacro % in case @setchapternewpage odd is in effect
4456
\lastnegativepageno = \pageno
4457
\global\pageno = \savepageno
4207
4460
% And just the chapters.
4208
4461
\def\summarycontents{%
4209
\startcontents{\putwordShortTOC}%
4211
\let\chapentry = \shortchapentry
4212
\let\appendixentry = \shortappendixentry
4213
\let\unnumbchapentry = \shortunnumberedentry
4214
% We want a true roman here for the page numbers.
4216
\let\rm=\shortcontrm \let\bf=\shortcontbf
4217
\let\sl=\shortcontsl \let\tt=\shortconttt
4219
\hyphenpenalty = 10000
4220
\advance\baselineskip by 1pt % Open it up a little.
4221
\def\secentry ##1##2##3##4{}
4222
\def\subsecentry ##1##2##3##4##5{}
4223
\def\subsubsecentry ##1##2##3##4##5##6{}
4224
\let\unnumbsecentry = \secentry
4225
\let\unnumbsubsecentry = \subsecentry
4226
\let\unnumbsubsubsecentry = \subsubsecentry
4227
\openin 1 \jobname.toc
4233
\contentsalignmacro % in case @setchapternewpage odd is in effect
4235
\lastnegativepageno = \pageno
4236
\global\pageno = \savepageno
4462
\startcontents{\putwordShortTOC}%
4464
\let\numchapentry = \shortchapentry
4465
\let\appentry = \shortchapentry
4466
\let\unnchapentry = \shortunnchapentry
4467
% We want a true roman here for the page numbers.
4469
\let\rm=\shortcontrm \let\bf=\shortcontbf
4470
\let\sl=\shortcontsl \let\tt=\shortconttt
4472
\hyphenpenalty = 10000
4473
\advance\baselineskip by 1pt % Open it up a little.
4474
\def\numsecentry##1##2##3##4{}
4475
\let\appsecentry = \numsecentry
4476
\let\unnsecentry = \numsecentry
4477
\let\numsubsecentry = \numsecentry
4478
\let\appsubsecentry = \numsecentry
4479
\let\unnsubsecentry = \numsecentry
4480
\let\numsubsubsecentry = \numsecentry
4481
\let\appsubsubsecentry = \numsecentry
4482
\let\unnsubsubsecentry = \numsecentry
4483
\openin 1 \jobname.toc
4489
\contentsalignmacro % in case @setchapternewpage odd is in effect
4491
\lastnegativepageno = \pageno
4492
\global\pageno = \savepageno
4238
4494
\let\shortcontents = \summarycontents
4241
\pdfcatalog{/PageMode /UseOutlines}%
4496
% Typeset the label for a chapter or appendix for the short contents.
4497
% The arg is, e.g., `A' for an appendix, or `3' for a chapter.
4499
\def\shortchaplabel#1{%
4500
% This space should be enough, since a single number is .5em, and the
4501
% widest letter (M) is 1em, at least in the Computer Modern fonts.
4502
% But use \hss just in case.
4503
% (This space doesn't include the extra space that gets added after
4504
% the label; that gets put in by \shortchapentry above.)
4506
% We'd like to right-justify chapter numbers, but that looks strange
4507
% with appendix letters. And right-justifying numbers and
4508
% left-justifying letters looks strange when there is less than 10
4509
% chapters. Have to read the whole toc once to know how many chapters
4510
% there are before deciding ...
4511
\hbox to 1em{#1\hss}%
4244
4514
% These macros generate individual entries in the table of contents.
4245
4515
% The first argument is the chapter or section name.
4902
5132
\message{defuns,}
4905
% Allow user to change definition object font (\df) internally
4906
\def\setdeffont#1 {\csname DEF#1\endcsname}
4908
5135
\newskip\defbodyindent \defbodyindent=.4in
4909
5136
\newskip\defargsindent \defargsindent=50pt
4910
5137
\newskip\deflastargmargin \deflastargmargin=18pt
4912
\newcount\parencount
5139
% Start the processing of @deffn:
5141
\ifnum\lastpenalty<10000
5144
% If there are two @def commands in a row, we'll have a \nobreak,
5145
% which is there to keep the function description together with its
5146
% header. But if there's nothing but headers, we need to allow a
5147
% break somewhere. Check for penalty 10002 (inserted by
5148
% \defargscommonending) instead of 10000, since the sectioning
5149
% commands insert a \penalty10000, and we don't want to allow a break
5150
% between a section heading and a defun.
5151
\ifnum\lastpenalty=10002 \penalty2000 \fi
5153
% Similarly, after a section heading, do not allow a break.
5154
% But do insert the glue.
5155
\medskip % preceded by discardable penalty, so not a breakpoint
5159
\advance\leftskip by \defbodyindent
5160
\exdentamount=\defbodyindent
5164
% First, check whether we are in the right environment:
5167
% As above, allow line break if we have multiple x headers in a row.
5168
% It's not a great place, though.
5169
\ifnum\lastpenalty=10002 \penalty3000 \fi
5171
% And now, it's time to reuse the body of the original defun:
5172
\expandafter\gobbledefun#1%
5174
\def\gobbledefun#1\startdefun{}
5176
% \printdefunline \deffnheader{text}
5178
\def\printdefunline#1#2{%
5180
% call \deffnheader:
5183
\interlinepenalty = 10000
5184
\advance\rightskip by 0pt plus 1fil
5186
\nobreak\vskip -\parskip
5187
\penalty 10002 % signal to \startdefun and \dodefunx
5188
% Some of the @defun-type tags do not enable magic parentheses,
5189
% rendering the following check redundant. But we don't optimize.
5194
\def\Edefun{\endgraf\medbreak}
5196
% \makedefun{deffn} creates \deffn, \deffnx and \Edeffn;
5197
% the only thing remainnig is to define \deffnheader.
5200
\expandafter\let\csname E#1\endcsname = \Edefun
5201
\edef\temp{\noexpand\domakedefun
5202
\makecsname{#1}\makecsname{#1x}\makecsname{#1header}}%
5206
% \domakedefun \deffn \deffnx \deffnheader
5208
% Define \deffn and \deffnx, without parameters.
5209
% \deffnheader has to be defined explicitly.
5211
\def\domakedefun#1#2#3{%
5214
\parseargusing\activeparens{\printdefunline#3}%
5216
\def#2{\dodefunx#1}%
5220
%%% Untyped functions:
5222
% @deffn category name args
5223
\makedefun{deffn}{\deffngeneral{}}
5225
% @deffn category class name args
5226
\makedefun{defop}#1 {\defopon{#1\ \putwordon}}
5228
% \defopon {category on}class name args
5229
\def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
5231
% \deffngeneral {subind}category name args
5233
\def\deffngeneral#1#2 #3 #4\endheader{%
5234
% Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}.
5235
\dosubind{fn}{\code{#3}}{#1}%
5236
\defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
5239
%%% Typed functions:
5241
% @deftypefn category type name args
5242
\makedefun{deftypefn}{\deftypefngeneral{}}
5244
% @deftypeop category class type name args
5245
\makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}}
5247
% \deftypeopon {category on}class type name args
5248
\def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
5250
% \deftypefngeneral {subind}category type name args
5252
\def\deftypefngeneral#1#2 #3 #4 #5\endheader{%
5253
\dosubind{fn}{\code{#4}}{#1}%
5254
\defname{#2}{#3}{#4}\defunargs{#5\unskip}%
5257
%%% Typed variables:
5259
% @deftypevr category type var args
5260
\makedefun{deftypevr}{\deftypecvgeneral{}}
5262
% @deftypecv category class type var args
5263
\makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}}
5265
% \deftypecvof {category of}class type var args
5266
\def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} }
5268
% \deftypecvgeneral {subind}category type var args
5270
\def\deftypecvgeneral#1#2 #3 #4 #5\endheader{%
5271
\dosubind{vr}{\code{#4}}{#1}%
5272
\defname{#2}{#3}{#4}\defunargs{#5\unskip}%
5275
%%% Untyped variables:
5277
% @defvr category var args
5278
\makedefun{defvr}#1 {\deftypevrheader{#1} {} }
5280
% @defcv category class var args
5281
\makedefun{defcv}#1 {\defcvof{#1\ \putwordof}}
5283
% \defcvof {category of}class var args
5284
\def\defcvof#1#2 {\deftypecvof{#1}#2 {} }
5287
% @deftp category name args
5288
\makedefun{deftp}#1 #2 #3\endheader{%
5289
\doind{tp}{\code{#2}}%
5290
\defname{#1}{}{#2}\defunargs{#3\unskip}%
5293
% Remaining @defun-like shortcuts:
5294
\makedefun{defun}{\deffnheader{\putwordDeffunc} }
5295
\makedefun{defmac}{\deffnheader{\putwordDefmac} }
5296
\makedefun{defspec}{\deffnheader{\putwordDefspec} }
5297
\makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} }
5298
\makedefun{defvar}{\defvrheader{\putwordDefvar} }
5299
\makedefun{defopt}{\defvrheader{\putwordDefopt} }
5300
\makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} }
5301
\makedefun{defmethod}{\defopon\putwordMethodon}
5302
\makedefun{deftypemethod}{\deftypeopon\putwordMethodon}
5303
\makedefun{defivar}{\defcvof\putwordInstanceVariableof}
5304
\makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof}
5306
% \defname, which formats the name of the @def (not the args).
5307
% #1 is the category, such as "Function".
5308
% #2 is the return type, if any.
5309
% #3 is the function name.
5311
% We are followed by (but not passed) the arguments, if any.
5313
\def\defname#1#2#3{%
5314
% Get the values of \leftskip and \rightskip as they were outside the @def...
5315
\advance\leftskip by -\defbodyindent
5317
% How we'll format the type name. Putting it in brackets helps
5318
% distinguish it from the body text that may end up on the next line
5321
\setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
5323
% Figure out line sizes for the paragraph shape.
5324
% The first line needs space for \box0; but if \rightskip is nonzero,
5325
% we need only space for the part of \box0 which exceeds it:
5326
\dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip
5327
% The continuations:
5328
\dimen2=\hsize \advance\dimen2 by -\defargsindent
5329
% (plain.tex says that \dimen1 should be used only as global.)
5330
\parshape 2 0in \dimen0 \defargsindent \dimen2
5332
% Put the type name to the right margin.
5335
\hfil\box0 \kern-\hsize
5336
% \hsize has to be shortened this way:
5338
% Intentionally do not respect \rightskip, since we need the space.
5341
% Allow all lines to be underfull without complaint:
5342
\tolerance=10000 \hbadness=10000
5343
\exdentamount=\defbodyindent
5345
% defun fonts. We use typewriter by default (used to be bold) because:
5346
% . we're printing identifiers, they should be in tt in principle.
5347
% . in languages with many accents, such as Czech or French, it's
5348
% common to leave accents off identifiers. The result looks ok in
5349
% tt, but exceedingly strange in rm.
5350
% . we don't want -- and --- to be treated as ligatures.
5351
% . this still does not fix the ?` and !` ligatures, but so far no
5352
% one has made identifiers using them :).
5354
\def\temp{#2}% return value type
5355
\ifx\temp\empty\else \tclose{\temp} \fi
5356
#3% output function name
5358
{\rm\enskip}% hskip 0.5 em of \tenrm
5361
% arguments will be output next, if any.
5364
% Print arguments in slanted roman (not ttsl), inconsistently with using
5365
% tt for the name. This is because literal text is sometimes needed in
5366
% the argument list (groff manual), and ttsl and tt are not very
5367
% distinguishable. Prevent hyphenation at `-' chars.
5370
% use sl by default (not ttsl),
5372
\df \sl \hyphenchar\font=0
5374
% On the other hand, if an argument has two dashes (for instance), we
5375
% want a way to get ttsl. Let's try @var for that.
5378
\sl\hyphenchar\font=45
4914
5381
% We want ()&[] to print specially on the defun line.
4916
5383
\def\activeparens{%
4917
5384
\catcode`\(=\active \catcode`\)=\active
5385
\catcode`\[=\active \catcode`\]=\active
4918
5386
\catcode`\&=\active
4919
\catcode`\[=\active \catcode`\]=\active
4922
5389
% Make control sequences which act like normal parenthesis chars.
4923
5390
\let\lparen = ( \let\rparen = )
4925
{\activeparens % Now, smart parens don't turn on until &foo (see \amprm)
4927
5392
% Be sure that we always have a definition for `(', etc. For example,
4928
5393
% if the fn name has parens in it, \boldbrax will not be in effect yet,
4929
5394
% so TeX would otherwise complain about undefined control sequence.
4930
\global\let(=\lparen \global\let)=\rparen
4931
\global\let[=\lbrack \global\let]=\rbrack
4933
\gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 }
4934
\gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
4935
% This is used to turn on special parens
4936
% but make & act ordinary (given that it's active).
4937
\gdef\boldbraxnoamp{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb\let&=\ampnr}
4939
% Definitions of (, ) and & used in args for functions.
4940
% This is the definition of ( outside of all parentheses.
4941
\gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested
5397
\global\let(=\lparen \global\let)=\rparen
5398
\global\let[=\lbrack \global\let]=\rbrack
5401
\gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
5402
\gdef\magicamp{\let&=\amprm}
5405
\newcount\parencount
5407
% If we encounter &foo, then turn on ()-hacking afterwards
5409
\def\amprm#1 {\ampseentrue{\bf\ }}
5413
% At the first level, print parens in roman,
5414
% otherwise use the default font.
5415
\ifnum \parencount=1 \rm \fi
5417
% The \sf parens (in \boldbrax) actually are a little bolder than
5418
% the contained text. This is especially needed for [ and ] .
5422
\def\infirstlevel#1{%
5429
\def\bfafterword#1 {#1 \bf}
4942
5432
\global\advance\parencount by 1
4945
% This is the definition of ( when already inside a level of parens.
4946
\gdef\opnested{\char`\(\global\advance\parencount by 1 }
4948
\gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0.
4949
% also in that case restore the outer-level definition of (.
4950
\ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi
4951
\global\advance \parencount by -1 }
4952
% If we encounter &foo, then turn on ()-hacking afterwards
4953
\gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ }
4955
\gdef\normalparens{\boldbrax\let&=\ampnr}
4956
} % End of definition inside \activeparens
4957
%% These parens (in \boldbrax) actually are a little bolder than the
4958
%% contained text. This is especially needed for [ and ]
4959
\def\opnr{{\sf\char`\(}\global\advance\parencount by 1 }
4960
\def\clnr{{\sf\char`\)}\global\advance\parencount by -1 }
4962
\def\lbrb{{\bf\char`\[}}
4963
\def\rbrb{{\bf\char`\]}}
4965
% Active &'s sneak into the index arguments, so make sure it's defined.
4967
\catcode`& = \active
4968
\global\let& = \ampnr
4971
% \defname, which formats the name of the @def (not the args).
4972
% #1 is the function name.
4973
% #2 is the type of definition, such as "Function".
4976
% How we'll output the type name. Putting it in brackets helps
4977
% distinguish it from the body text that may end up on the next line
4982
\def\defnametype{[\rm #2]}%
4985
% Get the values of \leftskip and \rightskip as they were outside the @def...
4987
\advance\dimen2 by -\defbodyindent
4989
% Figure out values for the paragraph shape.
4990
\setbox0=\hbox{\hskip \deflastargmargin{\defnametype}}%
4991
\dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line
4992
\dimen1=\hsize \advance \dimen1 by -\defargsindent % size for continuations
4993
\parshape 2 0in \dimen0 \defargsindent \dimen1
4995
% Output arg 2 ("Function" or some such) but stuck inside a box of
4996
% width 0 so it does not interfere with linebreaking.
4999
{% Adjust \hsize to exclude the ambient margins,
5000
% so that \rightline will obey them.
5001
\advance \hsize by -\dimen2
5002
\dimen3 = 0pt % was -1.25pc
5003
\rlap{\rightline{\defnametype\kern\dimen3}}%
5006
% Allow all lines to be underfull without complaint:
5007
\tolerance=10000 \hbadness=10000
5008
\advance\leftskip by -\defbodyindent
5009
\exdentamount=\defbodyindent
5010
{\df #1}\enskip % output function name
5011
% \defunargs will be called next to output the arguments, if any.
5014
% Common pieces to start any @def...
5015
% #1 is the \E... control sequence to end the definition (which we define).
5016
% #2 is the \...x control sequence (which our caller defines).
5017
% #3 is the control sequence to process the header, such as \defunheader.
5019
\def\parsebodycommon#1#2#3{%
5021
% If there are two @def commands in a row, we'll have a \nobreak,
5022
% which is there to keep the function description together with its
5023
% header. But if there's nothing but headers, we want to allow a
5024
% break after all. Check for penalty 10002 (inserted by
5025
% \defargscommonending) instead of 10000, since the sectioning
5026
% commands insert a \penalty10000, and we don't want to allow a break
5027
% between a section heading and a defun.
5028
\ifnum\lastpenalty=10002 \penalty0 \fi
5031
% Define the \E... end token that this defining construct specifies
5032
% so that it will exit this group.
5033
\def#1{\endgraf\endgroup\medbreak}%
5036
\advance\leftskip by \defbodyindent
5037
\exdentamount=\defbodyindent
5040
% Common part of the \...x definitions.
5042
\def\defxbodycommon{%
5043
% As with \parsebodycommon above, allow line break if we have multiple
5044
% x headers in a row. It's not a great place, though.
5045
\ifnum\lastpenalty=10000 \penalty1000 \fi
5047
\begingroup\obeylines
5050
% Process body of @defun, @deffn, @defmac, etc.
5052
\def\defparsebody#1#2#3{%
5053
\parsebodycommon{#1}{#2}{#3}%
5054
\def#2{\defxbodycommon \activeparens \spacesplit#3}%
5055
\catcode\equalChar=\active
5056
\begingroup\obeylines\activeparens
5060
% #1, #2, #3 are the common arguments (see \parsebodycommon above).
5061
% #4, delimited by the space, is the class name.
5063
\def\defmethparsebody#1#2#3#4 {%
5064
\parsebodycommon{#1}{#2}{#3}%
5065
\def#2##1 {\defxbodycommon \activeparens \spacesplit{#3{##1}}}%
5066
\begingroup\obeylines\activeparens
5067
% The \empty here prevents misinterpretation of a construct such as
5068
% @deffn {whatever} {Enharmonic comma}
5069
% See comments at \deftpparsebody, although in our case we don't have
5070
% to remove the \empty afterwards, since it is empty.
5071
\spacesplit{#3{#4}}\empty
5074
% Used for @deftypemethod and @deftypeivar.
5075
% #1, #2, #3 are the common arguments (see \defparsebody).
5076
% #4, delimited by a space, is the class name.
5077
% #5 is the method's return type.
5079
\def\deftypemethparsebody#1#2#3#4 #5 {%
5080
\parsebodycommon{#1}{#2}{#3}%
5081
\def#2##1 ##2 {\defxbodycommon \activeparens \spacesplit{#3{##1}{##2}}}%
5082
\begingroup\obeylines\activeparens
5083
\spacesplit{#3{#4}{#5}}%
5086
% Used for @deftypeop. The change from \deftypemethparsebody is an
5087
% extra argument at the beginning which is the `category', instead of it
5088
% being the hardwired string `Method' or `Instance Variable'. We have
5089
% to account for this both in the \...x definition and in parsing the
5090
% input at hand. Thus also need a control sequence (passed as #5) for
5091
% the \E... definition to assign the category name to.
5093
\def\deftypeopparsebody#1#2#3#4#5 #6 {%
5094
\parsebodycommon{#1}{#2}{#3}%
5095
\def#2##1 ##2 ##3 {\def#4{##1}%
5096
\defxbodycommon \activeparens \spacesplit{#3{##2}{##3}}}%
5097
\begingroup\obeylines\activeparens
5098
\spacesplit{#3{#5}{#6}}%
5102
\def\defopparsebody #1#2#3#4#5 {%
5103
\parsebodycommon{#1}{#2}{#3}%
5104
\def#2##1 ##2 {\def#4{##1}%
5105
\defxbodycommon \activeparens \spacesplit{#3{##2}}}%
5106
\begingroup\obeylines\activeparens
5107
\spacesplit{#3{#5}}%
5110
% These parsing functions are similar to the preceding ones
5111
% except that they do not make parens into active characters.
5112
% These are used for "variables" since they have no arguments.
5114
\def\defvarparsebody #1#2#3{%
5115
\parsebodycommon{#1}{#2}{#3}%
5116
\def#2{\defxbodycommon \spacesplit#3}%
5117
\catcode\equalChar=\active
5118
\begingroup\obeylines
5123
\def\defopvarparsebody #1#2#3#4#5 {%
5124
\parsebodycommon{#1}{#2}{#3}%
5125
\def#2##1 ##2 {\def#4{##1}%
5126
\defxbodycommon \spacesplit{#3{##2}}}%
5127
\begingroup\obeylines
5128
\spacesplit{#3{#5}}%
5131
\def\defvrparsebody#1#2#3#4 {%
5132
\parsebodycommon{#1}{#2}{#3}%
5133
\def#2##1 {\defxbodycommon \spacesplit{#3{##1}}}%
5134
\begingroup\obeylines
5135
\spacesplit{#3{#4}}%
5138
% This loses on `@deftp {Data Type} {struct termios}' -- it thinks the
5139
% type is just `struct', because we lose the braces in `{struct
5140
% termios}' when \spacesplit reads its undelimited argument. Sigh.
5141
% \let\deftpparsebody=\defvrparsebody
5143
% So, to get around this, we put \empty in with the type name. That
5144
% way, TeX won't find exactly `{...}' as an undelimited argument, and
5145
% won't strip off the braces.
5147
\def\deftpparsebody #1#2#3#4 {%
5148
\parsebodycommon{#1}{#2}{#3}%
5149
\def#2##1 {\defxbodycommon \spacesplit{#3{##1}}}%
5150
\begingroup\obeylines
5151
\spacesplit{\parsetpheaderline{#3{#4}}}\empty
5154
% Fine, but then we have to eventually remove the \empty *and* the
5155
% braces (if any). That's what this does.
5157
\def\removeemptybraces\empty#1\relax{#1}
5159
% After \spacesplit has done its work, this is called -- #1 is the final
5160
% thing to call, #2 the type name (which starts with \empty), and #3
5161
% (which might be empty) the arguments.
5163
\def\parsetpheaderline#1#2#3{%
5164
#1{\removeemptybraces#2\relax}{#3}%
5167
% Split up #2 (the rest of the input line) at the first space token.
5168
% call #1 with two arguments:
5169
% the first is all of #2 before the space token,
5170
% the second is all of #2 after that space token.
5171
% If #2 contains no space token, all of it is passed as the first arg
5172
% and the second is passed as empty.
5175
\gdef\spacesplit#1#2^^M{\endgroup\spacesplitx{#1}#2 \relax\spacesplitx}%
5176
\long\gdef\spacesplitx#1#2 #3#4\spacesplitx{%
5186
% This is called to end the arguments processing for all the @def... commands.
5188
\def\defargscommonending{%
5189
\interlinepenalty = 10000
5190
\advance\rightskip by 0pt plus 1fil
5192
\nobreak\vskip -\parskip
5193
\penalty 10002 % signal to \parsebodycommon.
5196
% This expands the args and terminates the paragraph they comprise.
5198
\def\defunargs#1{\functionparens \sl
5199
% Expand, preventing hyphenation at `-' chars.
5200
% Note that groups don't affect changes in \hyphenchar.
5201
% Set the font temporarily and use \font in case \setfont made \tensl a macro.
5202
{\tensl\hyphenchar\font=0}%
5204
{\tensl\hyphenchar\font=45}%
5205
\ifnum\parencount=0 \else \errmessage{Unbalanced parentheses in @def}\fi%
5206
\defargscommonending
5209
\def\deftypefunargs #1{%
5210
% Expand, preventing hyphenation at `-' chars.
5211
% Note that groups don't affect changes in \hyphenchar.
5212
% Use \boldbraxnoamp, not \functionparens, so that & is not special.
5214
\tclose{#1}% avoid \code because of side effects on active chars
5215
\defargscommonending
5218
% Do complete processing of one @defun or @defunx line already parsed.
5220
% @deffn Command forward-char nchars
5222
\def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader}
5224
\def\deffnheader #1#2#3{\doind {fn}{\code{#2}}%
5225
\begingroup\defname {#2}{#1}\defunargs{#3}\endgroup %
5226
\catcode\equalChar=\other % Turn off change made in \defparsebody
5229
% @defun == @deffn Function
5231
\def\defun{\defparsebody\Edefun\defunx\defunheader}
5233
\def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
5234
\begingroup\defname {#1}{\putwordDeffunc}%
5235
\defunargs {#2}\endgroup %
5236
\catcode\equalChar=\other % Turn off change made in \defparsebody
5239
% @deftypefun int foobar (int @var{foo}, float @var{bar})
5241
\def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader}
5243
% #1 is the data type. #2 is the name and args.
5244
\def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax}
5245
% #1 is the data type, #2 the name, #3 the args.
5246
\def\deftypefunheaderx #1#2 #3\relax{%
5247
\doind {fn}{\code{#2}}% Make entry in function index
5248
\begingroup\defname {\defheaderxcond#1\relax$.$#2}{\putwordDeftypefun}%
5249
\deftypefunargs {#3}\endgroup %
5250
\catcode\equalChar=\other % Turn off change made in \defparsebody
5253
% @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar})
5255
\def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader}
5257
% \defheaderxcond#1\relax$.$
5258
% puts #1 in @code, followed by a space, but does nothing if #1 is null.
5259
\def\defheaderxcond#1#2$.${\ifx#1\relax\else\code{#1#2} \fi}
5261
% #1 is the classification. #2 is the data type. #3 is the name and args.
5262
\def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax}
5263
% #1 is the classification, #2 the data type, #3 the name, #4 the args.
5264
\def\deftypefnheaderx #1#2#3 #4\relax{%
5265
\doind {fn}{\code{#3}}% Make entry in function index
5267
\normalparens % notably, turn off `&' magic, which prevents
5268
% at least some C++ text from working
5269
\defname {\defheaderxcond#2\relax$.$#3}{#1}%
5270
\deftypefunargs {#4}\endgroup %
5271
\catcode\equalChar=\other % Turn off change made in \defparsebody
5274
% @defmac == @deffn Macro
5276
\def\defmac{\defparsebody\Edefmac\defmacx\defmacheader}
5278
\def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
5279
\begingroup\defname {#1}{\putwordDefmac}%
5280
\defunargs {#2}\endgroup %
5281
\catcode\equalChar=\other % Turn off change made in \defparsebody
5284
% @defspec == @deffn Special Form
5286
\def\defspec{\defparsebody\Edefspec\defspecx\defspecheader}
5288
\def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
5289
\begingroup\defname {#1}{\putwordDefspec}%
5290
\defunargs {#2}\endgroup %
5291
\catcode\equalChar=\other % Turn off change made in \defparsebody
5294
% @defop CATEGORY CLASS OPERATION ARG...
5296
\def\defop #1 {\def\defoptype{#1}%
5297
\defopparsebody\Edefop\defopx\defopheader\defoptype}
5299
\def\defopheader#1#2#3{%
5300
\dosubind{fn}{\code{#2}}{\putwordon\ \code{#1}}% function index entry
5302
\defname{#2}{\defoptype\ \putwordon\ #1}%
5307
% @deftypeop CATEGORY CLASS TYPE OPERATION ARG...
5309
\def\deftypeop #1 {\def\deftypeopcategory{#1}%
5310
\deftypeopparsebody\Edeftypeop\deftypeopx\deftypeopheader
5313
% #1 is the class name, #2 the data type, #3 the operation name, #4 the args.
5314
\def\deftypeopheader#1#2#3#4{%
5315
\dosubind{fn}{\code{#3}}{\putwordon\ \code{#1}}% entry in function index
5317
\defname{\defheaderxcond#2\relax$.$#3}
5318
{\deftypeopcategory\ \putwordon\ \code{#1}}%
5319
\deftypefunargs{#4}%
5323
% @deftypemethod CLASS TYPE METHOD ARG...
5325
\def\deftypemethod{%
5326
\deftypemethparsebody\Edeftypemethod\deftypemethodx\deftypemethodheader}
5328
% #1 is the class name, #2 the data type, #3 the method name, #4 the args.
5329
\def\deftypemethodheader#1#2#3#4{%
5330
\dosubind{fn}{\code{#3}}{\putwordon\ \code{#1}}% entry in function index
5332
\defname{\defheaderxcond#2\relax$.$#3}{\putwordMethodon\ \code{#1}}%
5333
\deftypefunargs{#4}%
5337
% @deftypeivar CLASS TYPE VARNAME
5340
\deftypemethparsebody\Edeftypeivar\deftypeivarx\deftypeivarheader}
5342
% #1 is the class name, #2 the data type, #3 the variable name.
5343
\def\deftypeivarheader#1#2#3{%
5344
\dosubind{vr}{\code{#3}}{\putwordof\ \code{#1}}% entry in variable index
5346
\defname{\defheaderxcond#2\relax$.$#3}
5347
{\putwordInstanceVariableof\ \code{#1}}%
5352
% @defmethod == @defop Method
5354
\def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader}
5356
% #1 is the class name, #2 the method name, #3 the args.
5357
\def\defmethodheader#1#2#3{%
5358
\dosubind{fn}{\code{#2}}{\putwordon\ \code{#1}}% entry in function index
5360
\defname{#2}{\putwordMethodon\ \code{#1}}%
5365
% @defcv {Class Option} foo-class foo-flag
5367
\def\defcv #1 {\def\defcvtype{#1}%
5368
\defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype}
5370
\def\defcvarheader #1#2#3{%
5371
\dosubind{vr}{\code{#2}}{\putwordof\ \code{#1}}% variable index entry
5373
\defname{#2}{\defcvtype\ \putwordof\ #1}%
5378
% @defivar CLASS VARNAME == @defcv {Instance Variable} CLASS VARNAME
5380
\def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader}
5382
\def\defivarheader#1#2#3{%
5383
\dosubind{vr}{\code{#2}}{\putwordof\ \code{#1}}% entry in var index
5385
\defname{#2}{\putwordInstanceVariableof\ #1}%
5391
% First, define the processing that is wanted for arguments of @defvar.
5392
% This is actually simple: just print them in roman.
5393
% This must expand the args and terminate the paragraph they make up
5394
\def\defvarargs #1{\normalparens #1%
5395
\defargscommonending
5398
% @defvr Counter foo-count
5400
\def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader}
5402
\def\defvrheader #1#2#3{\doind {vr}{\code{#2}}%
5403
\begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup}
5405
% @defvar == @defvr Variable
5407
\def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader}
5409
\def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
5410
\begingroup\defname {#1}{\putwordDefvar}%
5411
\defvarargs {#2}\endgroup %
5414
% @defopt == @defvr {User Option}
5416
\def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader}
5418
\def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
5419
\begingroup\defname {#1}{\putwordDefopt}%
5420
\defvarargs {#2}\endgroup %
5423
% @deftypevar int foobar
5425
\def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader}
5427
% #1 is the data type. #2 is the name, perhaps followed by text that
5428
% is actually part of the data type, which should not be put into the index.
5429
\def\deftypevarheader #1#2{%
5430
\dovarind#2 \relax% Make entry in variables index
5431
\begingroup\defname {\defheaderxcond#1\relax$.$#2}{\putwordDeftypevar}%
5432
\defargscommonending
5434
\def\dovarind#1 #2\relax{\doind{vr}{\code{#1}}}
5436
% @deftypevr {Global Flag} int enable
5438
\def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader}
5440
\def\deftypevrheader #1#2#3{\dovarind#3 \relax%
5441
\begingroup\defname {\defheaderxcond#2\relax$.$#3}{#1}
5442
\defargscommonending
5446
% Args are printed in bold, a slight difference from @defvar.
5448
\def\deftpargs #1{\bf \defvarargs{#1}}
5450
% @deftp Class window height width ...
5452
\def\deftp{\deftpparsebody\Edeftp\deftpx\deftpheader}
5454
\def\deftpheader #1#2#3{\doind {tp}{\code{#2}}%
5455
\begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup}
5457
% These definitions are used if you use @defunx (etc.)
5458
% anywhere other than immediately after a @defun or @defunx.
5460
\def\defcvx#1 {\errmessage{@defcvx in invalid context}}
5461
\def\deffnx#1 {\errmessage{@deffnx in invalid context}}
5462
\def\defivarx#1 {\errmessage{@defivarx in invalid context}}
5463
\def\defmacx#1 {\errmessage{@defmacx in invalid context}}
5464
\def\defmethodx#1 {\errmessage{@defmethodx in invalid context}}
5465
\def\defoptx #1 {\errmessage{@defoptx in invalid context}}
5466
\def\defopx#1 {\errmessage{@defopx in invalid context}}
5467
\def\defspecx#1 {\errmessage{@defspecx in invalid context}}
5468
\def\deftpx#1 {\errmessage{@deftpx in invalid context}}
5469
\def\deftypefnx#1 {\errmessage{@deftypefnx in invalid context}}
5470
\def\deftypefunx#1 {\errmessage{@deftypefunx in invalid context}}
5471
\def\deftypeivarx#1 {\errmessage{@deftypeivarx in invalid context}}
5472
\def\deftypemethodx#1 {\errmessage{@deftypemethodx in invalid context}}
5473
\def\deftypeopx#1 {\errmessage{@deftypeopx in invalid context}}
5474
\def\deftypevarx#1 {\errmessage{@deftypevarx in invalid context}}
5475
\def\deftypevrx#1 {\errmessage{@deftypevrx in invalid context}}
5476
\def\defunx#1 {\errmessage{@defunx in invalid context}}
5477
\def\defvarx#1 {\errmessage{@defvarx in invalid context}}
5478
\def\defvrx#1 {\errmessage{@defvrx in invalid context}}
5434
\infirstlevel \bfafterword
5439
\global\advance\parencount by -1
5442
\newcount\brackcount
5444
\global\advance\brackcount by 1
5449
\global\advance\brackcount by -1
5452
\def\checkparencounts{%
5453
\ifnum\parencount=0 \else \badparencount \fi
5454
\ifnum\brackcount=0 \else \badbrackcount \fi
5456
\def\badparencount{%
5457
\errmessage{Unbalanced parentheses in @def}%
5458
\global\parencount=0
5460
\def\badbrackcount{%
5461
\errmessage{Unbalanced square braces in @def}%
5462
\global\brackcount=0
5481
5466
\message{macros,}
6368
% @float FLOATTYPE,LOC ... @end float for displayed figures, tables, etc.
6369
% We don't actually implement floating yet, we just plop the float "here".
6370
% But it seemed the best name for the future.
6372
\envparseargdef\float{\dofloat #1,,,\finish}
6374
% #1 is the optional FLOATTYPE, the text label for this float, typically
6375
% "Figure", "Table", "Example", etc. Can't contain commas. If omitted,
6376
% this float will not be numbered and cannot be referred to.
6378
% #2 is the optional xref label. Also must be present for the float to
6381
% #3 is the optional positioning argument; for now, it is ignored. It
6382
% will somehow specify the positions allowed to float to (here, top, bottom).
6384
% We keep a separate counter for each FLOATTYPE, which we reset at each
6385
% chapter-level command.
6386
\let\resetallfloatnos=\empty
6388
\def\dofloat#1,#2,#3,#4\finish{%
6389
\let\thiscaption=\empty
6390
\let\thisshortcaption=\empty
6392
% don't lose footnotes inside @float.
6395
% We can't be used inside a paragraph.
6400
\def\floatlabel{#2}%
6401
\def\floatloc{#3}% we do nothing with this yet.
6403
\ifx\floattype\empty
6404
\let\safefloattype=\empty
6407
% the floattype might have accents or other special characters,
6408
% but we need to use it in a control sequence name.
6411
\xdef\safefloattype{\floattype}%
6415
% If label is given but no type, we handle that as the empty type.
6416
\ifx\floatlabel\empty \else
6417
% We want each FLOATTYPE to be numbered separately (Figure 1,
6418
% Table 1, Figure 2, ...). (And if no label, no number.)
6420
\expandafter\getfloatno\csname\safefloattype floatno\endcsname
6421
\global\advance\floatno by 1
6424
% This magic value for \thissection is output by \setref as the
6425
% XREFLABEL-title value. \xrefX uses it to distinguish float
6426
% labels (which have a completely different output format) from
6427
% node and anchor labels. And \xrdef uses it to construct the
6430
\edef\thissection{\floatmagic=\safefloattype}%
6431
\setref{\floatlabel}{Yfloat}%
6435
% start with \parskip glue, I guess.
6438
% Don't suppress indentation if a float happens to start a section.
6439
\restorefirstparagraphindent
6442
% we have these possibilities:
6443
% @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap
6444
% @float Foo,lbl & no caption: Foo 1.1
6445
% @float Foo & @caption{Cap}: Foo: Cap
6446
% @float Foo & no caption: Foo
6447
% @float ,lbl & Caption{Cap}: 1.1: Cap
6448
% @float ,lbl & no caption: 1.1
6449
% @float & @caption{Cap}: Cap
6450
% @float & no caption:
6453
\let\floatident = \empty
6455
% In all cases, if we have a float type, it comes first.
6456
\ifx\floattype\empty \else \def\floatident{\floattype}\fi
6458
% If we have an xref label, the number comes next.
6459
\ifx\floatlabel\empty \else
6460
\ifx\floattype\empty \else % if also had float type, need tie first.
6461
\appendtomacro\floatident{\tie}%
6464
\appendtomacro\floatident{\chaplevelprefix\the\floatno}%
6467
% Start the printed caption with what we've constructed in
6468
% \floatident, but keep it separate; we need \floatident again.
6469
\let\captionline = \floatident
6471
\ifx\thiscaption\empty \else
6472
\ifx\floatident\empty \else
6473
\appendtomacro\captionline{: }% had ident, so need a colon between
6477
\appendtomacro\captionline\thiscaption
6480
% If we have anything to print, print it, with space before.
6481
% Eventually this needs to become an \insert.
6482
\ifx\captionline\empty \else
6487
% If have an xref label, write the list of floats info. Do this
6488
% after the caption, to avoid chance of it being a breakpoint.
6489
\ifx\floatlabel\empty \else
6490
% Write the text that goes in the lof to the aux file as
6491
% \floatlabel-lof. Besides \floatident, we include the short
6492
% caption if specified, else the full caption if specified, else nothing.
6494
\atdummies \turnoffactive \otherbackslash
6495
\immediate\write\auxfile{@xrdef{\floatlabel-lof}{%
6497
\ifx\thisshortcaption\empty
6498
\ifx\thiscaption\empty \else : \thiscaption \fi
6506
% Space below caption, if we printed anything.
6507
\ifx\printedsomething\empty \else \vskip\parskip \fi
6508
\egroup % end of \vtop
6512
% Append the tokens #2 to the definition of macro #1, not expanding either.
6514
\newtoks\appendtomacroAtoks
6515
\newtoks\appendtomacroBtoks
6516
\def\appendtomacro#1#2{%
6517
\appendtomacroAtoks = \expandafter{#1}%
6518
\appendtomacroBtoks = {#2}%
6519
\edef#1{\the\appendtomacroAtoks \the\appendtomacroBtoks}%
6522
% @caption, @shortcaption are easy.
6524
\long\def\caption#1{\checkenv\float \def\thiscaption{#1}}
6525
\def\shortcaption#1{\checkenv\float \def\thisshortcaption{#1}}
6527
% The parameter is the control sequence identifying the counter we are
6528
% going to use. Create it if it doesn't exist and assign it to \floatno.
6531
% Haven't seen this figure type before.
6532
\csname newcount\endcsname #1%
6534
% Remember to reset this floatno at the next chap.
6535
\expandafter\gdef\expandafter\resetallfloatnos
6536
\expandafter{\resetallfloatnos #1=0 }%
6541
% \setref calls this to get the XREFLABEL-snt value. We want an @xref
6542
% to the FLOATLABEL to expand to "Figure 3.1". We call \setref when we
6543
% first read the @float command.
6545
\def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}%
6547
% Magic string used for the XREFLABEL-title value, so \xrefX can
6548
% distinguish floats from other xref types.
6549
\def\floatmagic{!!float!!}
6551
% #1 is the control sequence we are passed; we expand into a conditional
6552
% which is true if #1 represents a float ref. That is, the magic
6553
% \thissection value which we \setref above.
6555
\def\iffloat#1{\expandafter\doiffloat#1==\finish}
6557
% #1 is (maybe) the \floatmagic string. If so, #2 will be the
6558
% (safe) float type for this float. We set \iffloattype to #2.
6560
\def\doiffloat#1=#2=#3\finish{%
6562
\def\iffloattype{#2}%
6563
\ifx\temp\floatmagic
6566
% @listoffloats FLOATTYPE - print a list of floats like a table of contents.
6568
\parseargdef\listoffloats{%
6569
\def\floattype{#1}% floattype
6571
% the floattype might have accents or other special characters,
6572
% but we need to use it in a control sequence name.
6575
\xdef\safefloattype{\floattype}%
6578
% \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE.
6579
\expandafter\ifx\csname floatlist\safefloattype\endcsname \relax
6581
% if the user said @listoffloats foo but never @float foo.
6582
\message{\linenumber No `\safefloattype' floats to list.}%
6586
\leftskip=\tocindent % indent these entries like a toc
6587
\let\do=\listoffloatsdo
6588
\csname floatlist\safefloattype\endcsname
6593
% This is called on each entry in a list of floats. We're passed the
6594
% xref label, in the form LABEL-title, which is how we save it in the
6595
% aux file. We strip off the -title and look up \XRLABEL-lof, which
6596
% has the text we're supposed to typeset here.
6598
% Figures without xref labels will not be included in the list (since
6599
% they won't appear in the aux file).
6601
\def\listoffloatsdo#1{\listoffloatsdoentry#1\finish}
6602
\def\listoffloatsdoentry#1-title\finish{{%
6603
% Can't fully expand XR#1-lof because it can contain anything. Just
6604
% pass the control sequence. On the other hand, XR#1-pg is just the
6605
% page number, and we want to fully expand that so we can get a link
6607
\toksA = \expandafter{\csname XR#1-lof\endcsname}%
6609
% use the same \entry macro we use to generate the TOC and index.
6610
\edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}%
6290
6614
\message{localization,}