339
388
% the input line (except we remove a trailing comment). #1 should be a
340
389
% macro which expects an ordinary undelimited TeX argument.
391
\def\parsearg{\parseargusing{}}
392
\def\parseargusing#1#2{%
346
\futurelet\temp\parseargx
349
% If the next token is an obeyed space (from an @example environment or
350
% the like), remove it and recurse. Otherwise, we're done.
352
% \obeyedspace is defined far below, after the definition of \sepspaces.
353
\ifx\obeyedspace\temp
354
\expandafter\parseargdiscardspace
356
\expandafter\parseargline
360
% Remove a single space (as the delimiter token to the macro call).
362
\gdef\parseargdiscardspace {\futurelet\temp\parseargx}}
398
\parseargline\empty% Insert the \empty token, see \finishparsearg below.
365
402
\gdef\parseargline#1^^M{%
366
403
\endgroup % End of the group started in \parsearg.
368
% First remove any @c comment, then any @comment.
369
% Result of each macro is put in \toks0.
370
\argremovec #1\c\relax %
371
\expandafter\argremovecomment \the\toks0 \comment\relax %
373
% Call the caller's macro, saved as \next in \parsearg.
374
\expandafter\next\expandafter{\the\toks0}%
404
\argremovecomment #1\comment\ArgTerm%
378
% Since all \c{,omment} does is throw away the argument, we can let TeX
379
% do that for us. The \relax here is matched by the \relax in the call
380
% in \parseargline; it could be more or less anything, its purpose is
381
% just to delimit the argument to the \c.
382
\def\argremovec#1\c#2\relax{\toks0 = {#1}}
383
\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}
385
% \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.,
386
415
% @end itemize @c foo
387
% will have two active spaces as part of the argument with the
388
% `itemize'. Here we remove all active spaces from #1, and assign the
391
% This loses if there are any *other* active characters besides spaces
392
% in the argument -- _ ^ +, for example -- since they get expanded.
393
% Fortunately, Texinfo does not define any such commands. (If it ever
394
% does, the catcode of the characters in questionwill have to be changed
395
% here.) But this means we cannot call \removeactivespaces as part of
396
% \argremovec{,omment}, since @c uses \parsearg, and thus the argument
397
% that \parsearg gets might well have any character at all in it.
399
\def\removeactivespaces#1{%
403
\global\toks0 = \expandafter{\temp}%
407
% 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:
411
\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}
415
481
\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
417
%% These are used to keep @begin/@end levels from running away
418
%% Call \inENV within environments (after a \begingroup)
419
\newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi}
421
\ifENV\errmessage{Still within an environment; press RETURN to continue}
422
\endgroup\fi} % This is not perfect, but it should reduce lossage
424
% @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
425
545
\newhelp\EMsimple{Press RETURN to continue.}
427
\outer\def\begin{\parsearg\beginxxx}
430
\expandafter\ifx\csname #1\endcsname\relax
431
{\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else
432
\csname #1\endcsname\fi}
434
% @end foo executes the definition of \Efoo.
436
\def\end{\parsearg\endxxx}
438
\removeactivespaces{#1}%
439
\edef\endthing{\the\toks0}%
441
\expandafter\ifx\csname E\endthing\endcsname\relax
442
\expandafter\ifx\csname \endthing\endcsname\relax
443
% There's no \foo, i.e., no ``environment'' foo.
445
\errmessage{Undefined command `@end \endthing'}%
447
\unmatchedenderror\endthing
450
% Everything's ok; the right environment has been started.
451
\csname E\endthing\endcsname
455
% There is an environment #1, but it hasn't been started. Give an error.
457
\def\unmatchedenderror#1{%
459
\errmessage{This `@end #1' doesn't have a matching `@#1'}%
462
% Define the control sequence \E#1 to give an unmatched @end error.
464
\def\defineunmatchedend#1{%
465
\expandafter\def\csname E#1\endcsname{\unmatchedenderror{#1}}%
469
548
%% Simple single-character @ commands
2666
2793
\def\menu{\doignore{menu}}
2667
2794
\def\xml{\doignore{xml}}
2669
% @dircategory CATEGORY -- specify a category of the dir file
2670
% which this file should belong to. Ignore this in TeX.
2671
\let\dircategory = \comment
2673
% Ignore text until a line `@end #1'.
2796
% Ignore text until a line `@end #1', keeping track of nested conditionals.
2798
% A count to remember the depth of nesting.
2799
\newcount\doignorecount
2675
2801
\def\doignore#1{\begingroup
2676
% Don't complain about control sequences we have declared \outer.
2679
% Define a command to swallow text until we reach `@end #1'.
2680
% This @ is a catcode 12 token (that is the normal catcode of @ in
2681
% this texinfo.tex file). We change the catcode of @ below to match.
2682
\long\def\doignoretext##1@end #1{\enddoignore}%
2802
% Scan in ``verbatim'' mode:
2803
\catcode`\@ = \other
2804
\catcode`\{ = \other
2805
\catcode`\} = \other
2684
2807
% Make sure that spaces turn into tokens that match what \doignoretext wants.
2685
\catcode\spaceChar = 10
2687
% Ignore braces, too, so mismatched braces don't cause trouble.
2691
% We must not have @c interpreted as a control sequence.
2694
\def\ignoreword{#1}%
2695
\ifx\ignoreword\documentdescriptionword
2696
% The c kludge breaks documentdescription, since
2697
% `documentdescription' contains a `c'. Means not everything will
2698
% be ignored inside @documentdescription, but oh well...
2700
% Make the letter c a comment character so that the rest of the line
2701
% will be ignored. This way, the document can have (for example)
2703
% and the @end ifinfo will be properly ignored.
2704
% (We've just changed @ to catcode 12.)
2708
% And now expand the command defined above.
2712
% What we do to finish off ignored text.
2714
\def\enddoignore{\endgroup\ignorespaces}%
2716
\newif\ifwarnedobs\warnedobsfalse
2718
\ifwarnedobs\relax\else
2719
% We need to warn folks that they may have trouble with TeX 3.0.
2720
% This uses \immediate\write16 rather than \message to get newlines.
2721
\immediate\write16{}
2722
\immediate\write16{WARNING: for users of Unix TeX 3.0!}
2723
\immediate\write16{This manual trips a bug in TeX version 3.0 (tex hangs).}
2724
\immediate\write16{If you are running another version of TeX, relax.}
2725
\immediate\write16{If you are running Unix TeX 3.0, kill this TeX process.}
2726
\immediate\write16{ Then upgrade your TeX installation if you can.}
2727
\immediate\write16{ (See ftp://ftp.gnu.org/non-gnu/TeX.README.)}
2728
\immediate\write16{If you are stuck with version 3.0, run the}
2729
\immediate\write16{ script ``tex3patch'' from the Texinfo distribution}
2730
\immediate\write16{ to use a workaround.}
2731
\immediate\write16{}
2732
\global\warnedobstrue
2736
% **In TeX 3.0, setting text in \nullfont hangs tex. For a
2737
% workaround (which requires the file ``dummy.tfm'' to be installed),
2738
% uncomment the following line:
2739
%%%%%\font\nullfont=dummy\let\obstexwarn=\relax
2741
% Ignore text, except that we keep track of conditional commands for
2742
% purposes of nesting, up to an `@end #1' command.
2744
\def\nestedignore#1{%
2746
% We must actually expand the ignored text to look for the @end
2747
% command, so that nested ignore constructs work. Thus, we put the
2748
% text into a \vbox and then do nothing with the result. To minimize
2749
% the chance of memory overflow, we follow the approach outlined on
2750
% page 401 of the TeXbook.
2752
\setbox0 = \vbox\bgroup
2753
% Don't complain about control sequences we have declared \outer.
2756
% Define `@end #1' to end the box, which will in turn undefine the
2757
% @end command again.
2758
\expandafter\def\csname E#1\endcsname{\egroup\ignorespaces}%
2760
% We are going to be parsing Texinfo commands. Most cause no
2761
% trouble when they are used incorrectly, but some commands do
2762
% complicated argument parsing or otherwise get confused, so we
2765
% We can't do anything about stray @-signs, unfortunately;
2766
% they'll produce `undefined control sequence' errors.
2769
% Set the current font to be \nullfont, a TeX primitive, and define
2770
% all the font commands to also use \nullfont. We don't use
2771
% dummy.tfm, as suggested in the TeXbook, because some sites
2772
% might not have that installed. Therefore, math mode will still
2773
% produce output, but that should be an extremely small amount of
2774
% stuff compared to the main input.
2777
\let\tenrm=\nullfont \let\tenit=\nullfont \let\tensl=\nullfont
2778
\let\tenbf=\nullfont \let\tentt=\nullfont \let\smallcaps=\nullfont
2779
\let\tensf=\nullfont
2780
% Similarly for index fonts.
2781
\let\smallrm=\nullfont \let\smallit=\nullfont \let\smallsl=\nullfont
2782
\let\smallbf=\nullfont \let\smalltt=\nullfont \let\smallsc=\nullfont
2783
\let\smallsf=\nullfont
2784
% Similarly for smallexample fonts.
2785
\let\smallerrm=\nullfont \let\smallerit=\nullfont \let\smallersl=\nullfont
2786
\let\smallerbf=\nullfont \let\smallertt=\nullfont \let\smallersc=\nullfont
2787
\let\smallersf=\nullfont
2789
% Don't complain when characters are missing from the fonts.
2790
\tracinglostchars = 0
2792
% Don't bother to do space factor calculations.
2795
% Don't report underfull hboxes.
2798
% Do minimal line-breaking.
2799
\pretolerance = 10000
2801
% Do not execute instructions in @tex.
2802
\def\tex{\doignore{tex}}%
2803
% Do not execute macro definitions.
2804
% `c' is a comment character, so the word `macro' will get cut off.
2805
\def\macro{\doignore{ma}}%
2810
% Count number of #1's that we've seen.
2813
% Swallow text until we reach the matching `@end #1'.
2817
{ \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source.
2820
\gdef\dodoignore#1{%
2821
% #1 contains the command name as a string, e.g., `ifinfo'.
2823
% Define a command to find the next `@end #1', which must be on a line
2825
\long\def\doignoretext##1^^M@end #1{\doignoretextyyy##1^^M@#1\_STOP_}%
2826
% And this command to find another #1 command, at the beginning of a
2827
% line. (Otherwise, we would consider a line `@c @ifset', for
2828
% example, to count as an @ifset for nesting.)
2829
\long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}%
2831
% And now expand that command.
2837
\def\doignoreyyy#1{%
2839
\ifx\temp\empty % Nothing found.
2840
\let\next\doignoretextzzz
2841
\else % Found a nested condition, ...
2842
\advance\doignorecount by 1
2843
\let\next\doignoretextyyy % ..., look for another.
2844
% If we're here, #1 ends with ^^M\ifinfo (for example).
2846
\next #1% the token \_STOP_ is present just after this macro.
2849
% We have to swallow the remaining "\_STOP_".
2851
\def\doignoretextzzz#1{%
2852
\ifnum\doignorecount = 0 % We have just found the outermost @end.
2853
\let\next\enddoignore
2854
\else % Still inside a nested condition.
2855
\advance\doignorecount by -1
2856
\let\next\doignoretext % Look for the next @end.
2861
% Finish off ignored text.
2862
\def\enddoignore{\endgroup\ignorespaces}
2808
2865
% @set VAR sets the variable VAR to an empty value.
2809
2866
% @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
3227
3289
\def\exclamdown{!}%
3228
3290
\def\questiondown{?}%
3230
% Don't no-op \tt, since it isn't a user-level command
3231
% and is used in the definitions of the active chars like <, >, |, etc.
3232
% Likewise with the other plain tex font commands.
3235
% Texinfo font commands.
3242
\let\TeX=\indexdummytex
3248
\let\dots=\indexdummydots
3297
% Assorted special characters.
3298
% (The following {} will end up in the sort string, but that's ok.)
3299
\def\bullet{bullet}%
3301
\def\copyright{copyright}%
3302
\def\registeredsymbol{R}%
3307
\def\expansion{==>}%
3309
\def\pounds{pounds}%
3314
% Don't write macro names.
3264
3318
\let\indexbackslash=0 %overridden during \printindex.
3265
3319
\let\SETmarginindex=\relax % put index entries in margin (undocumented)?
3267
% For \ifx comparisons.
3268
\def\emptymacro{\empty}
3270
3321
% Most index entries go through here, but \dosubind is the general case.
3272
\def\doind#1#2{\dosubind{#1}{#2}\empty}
3322
% #1 is the index name, #2 is the entry text.
3323
\def\doind#1#2{\dosubind{#1}{#2}{}}
3274
3325
% Workhorse for all \fooindexes.
3275
3326
% #1 is name of index, #2 is stuff to put there, #3 is subentry --
3276
% \empty if called from \doind, as we usually are. The main exception
3277
% is with defuns, which call us directly.
3327
% empty if called from \doind, as we usually are (the main exception
3328
% is with most defuns, which call us directly).
3279
3330
\def\dosubind#1#2#3{%
3333
% Store the main index entry text (including the third arg).
3335
% If third arg is present, precede it with a space.
3337
\ifx\thirdarg\empty \else
3338
\toks0 = \expandafter{\the\toks0 \space #3}%
3341
\edef\writeto{\csname#1indfile\endcsname}%
3352
% Write the entry in \toks0 to the index file:
3354
\def\dosubindwrite{%
3280
3355
% Put the index entry in the margin if desired.
3281
3356
\ifx\SETmarginindex\relax\else
3282
\insert\margin{\hbox{\vrule height8pt depth3pt width0pt #2}}%
3285
\count255=\lastpenalty
3287
\indexdummies % Must do this here, since \bf, etc expand at this stage
3290
\let\folio = 0% We will expand all macros now EXCEPT \folio.
3291
\def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now
3292
% so it will be output as is; and it will print as backslash.
3294
% The main index entry text.
3297
% If third arg is present, precede it with space in sort key.
3299
\ifx\thirdarg\emptymacro \else
3300
% If the third (subentry) arg is present, add it to the index
3302
\toks0 = \expandafter{\the\toks0 \space #3}%
3305
% Process the index entry with all font commands turned off, to
3306
% get the string to sort by.
3308
\edef\temp{\the\toks0}% need full expansion
3309
\xdef\indexsorttmp{\temp}%
3312
% Set up the complete index entry, with both the sort key and
3313
% the original text, including any font commands. We write
3314
% three arguments to \entry to the .?? file (four in the
3315
% subentry case), texindex reduces to two when writing the .??s
3318
\write\csname#1indfile\endcsname{%
3319
\realbackslash entry{\indexsorttmp}{\folio}{\the\toks0}}%
3322
% If a skip is the last thing on the list now, preserve it
3323
% by backing up by \lastskip, doing the \write, then inserting
3324
% the skip again. Otherwise, the whatsit generated by the
3325
% \write will make \lastskip zero. The result is that sequences
3330
% will have extra space inserted, because the \medbreak in the
3331
% start of the @defun won't see the skip inserted by the @end of
3332
% the previous defun.
3334
% But don't do any of this if we're not in vertical mode. We
3335
% don't want to do a \vskip and prematurely end a paragraph.
3337
% Avoid page breaks due to these extra skips, too.
3342
\ifdim\lastskip = 0pt \else \nobreak\vskip-\skip0 \fi
3345
\temp % do the write
3347
\ifvmode \ifdim\skip0 = 0pt \else \nobreak\vskip\skip0 \fi \fi
3357
\insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}%
3360
% Remember, we are within a group.
3361
\indexdummies % Must do this here, since \bf, etc expand at this stage
3363
\def\backslashcurfont{\indexbackslash}% \indexbackslash isn't defined now
3364
% so it will be output as is; and it will print as backslash.
3366
% Process the index entry with all font commands turned off, to
3367
% get the string to sort by.
3369
\edef\temp{\the\toks0}% need full expansion
3370
\xdef\indexsorttmp{\temp}%
3373
% Set up the complete index entry, with both the sort key and
3374
% the original text, including any font commands. We write
3375
% three arguments to \entry to the .?? file (four in the
3376
% subentry case), texindex reduces to two when writing the .??s
3380
\string\entry{\indexsorttmp}{\noexpand\folio}{\the\toks0}}%
3385
% Take care of unwanted page breaks:
3387
% If a skip is the last thing on the list now, preserve it
3388
% by backing up by \lastskip, doing the \write, then inserting
3389
% the skip again. Otherwise, the whatsit generated by the
3390
% \write will make \lastskip zero. The result is that sequences
3395
% will have extra space inserted, because the \medbreak in the
3396
% start of the @defun won't see the skip inserted by the @end of
3397
% the previous defun.
3399
% But don't do any of this if we're not in vertical mode. We
3400
% don't want to do a \vskip and prematurely end a paragraph.
3402
% Avoid page breaks due to these extra skips, too.
3404
% But wait, there is a catch there:
3405
% We'll have to check whether \lastskip is zero skip. \ifdim is not
3406
% sufficient for this purpose, as it ignores stretch and shrink parts
3407
% of the skip. The only way seems to be to check the textual
3408
% representation of the skip.
3410
% The following is almost like \def\zeroskipmacro{0.0pt} except that
3411
% the ``p'' and ``t'' characters have catcode \other, not 11 (letter).
3413
\edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname}
3417
\def\dosubindsanitize{%
3418
% \lastskip and \lastpenalty cannot both be nonzero simultaneously.
3420
\edef\lastskipmacro{\the\lastskip}%
3421
\count255 = \lastpenalty
3423
% If \lastskip is nonzero, that means the last item was a
3424
% skip. And since a skip is discardable, that means this
3425
% -\skip0 glue we're inserting is preceded by a
3426
% non-discardable item, therefore it is not a potential
3427
% breakpoint, therefore no \nobreak needed.
3428
\ifx\lastskipmacro\zeroskipmacro
3435
\ifx\lastskipmacro\zeroskipmacro
3436
% If \lastskip was zero, perhaps the last item was a penalty, and
3437
% perhaps it was >=10000, e.g., a \nobreak. In that case, we want
3438
% to re-insert the same penalty (values >10000 are used for various
3439
% signals); since we just inserted a non-discardable item, any
3440
% following glue (such as a \parskip) would be a breakpoint. For example:
3442
% @deffn deffn-whatever
3443
% @vindex index-whatever
3445
% would allow a break between the index-whatever whatsit
3446
% and the "Description." paragraph.
3447
\ifnum\count255>9999 \penalty\count255 \fi
3449
% On the other hand, if we had a nonzero \lastskip,
3450
% this make-up glue would be preceded by a non-discardable item
3451
% (the whatsit from the \write), so we must insert a \nobreak.
3452
\nobreak\vskip\skip0
3355
3456
% The index entry written in the file actually looks like
3756
3888
\def\lowersections{\global\advance\secbase by 1}
3757
3889
\let\down=\lowersections % original BFox name
3759
% Choose a numbered-heading macro
3760
% #1 is heading level if unmodified by @raisesections or @lowersections
3761
% #2 is text for heading
3762
\def\numhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
3768
\numberedsubseczzz{#2}
3770
\numberedsubsubseczzz{#2}
3772
\ifnum \absseclevel<0
3775
\numberedsubsubseczzz{#2}
3778
\suppressfirstparagraphindent
3781
% like \numhead, but chooses appendix heading levels
3782
\def\apphead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
3786
\appendixsectionzzz{#2}
3788
\appendixsubseczzz{#2}
3790
\appendixsubsubseczzz{#2}
3792
\ifnum \absseclevel<0
3795
\appendixsubsubseczzz{#2}
3798
\suppressfirstparagraphindent
3801
% like \numhead, but chooses numberless heading levels
3802
\def\unnmhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
3806
\unnumberedseczzz{#2}
3808
\unnumberedsubseczzz{#2}
3810
\unnumberedsubsubseczzz{#2}
3812
\ifnum \absseclevel<0
3815
\unnumberedsubsubseczzz{#2}
3818
\suppressfirstparagraphindent
3821
% @chapter, @appendix, @unnumbered.
3822
\def\thischaptername{No Chapter Title}
3823
\outer\def\chapter{\parsearg\chapteryyy}
3824
\def\chapteryyy #1{\numhead0{#1}} % normally numhead0 calls chapterzzz
3825
\def\chapterzzz #1{%
3826
\secno=0 \subsecno=0 \subsubsecno=0
3827
\global\advance \chapno by 1 \message{\putwordChapter\space \the\chapno}%
3828
\chapmacro {#1}{\the\chapno}%
3829
\gdef\thissection{#1}%
3830
\gdef\thischaptername{#1}%
3831
% We don't substitute the actual chapter name into \thischapter
3832
% because we don't want its macros evaluated now.
3833
\xdef\thischapter{\putwordChapter{} \the\chapno: \noexpand\thischaptername}%
3834
\writetocentry{chap}{#1}{{\the\chapno}}
3891
% we only have subsub.
3892
\chardef\maxseclevel = 3
3894
% A numbered section within an unnumbered changes to unnumbered too.
3895
% To achive this, remember the "biggest" unnum. sec. we are currently in:
3896
\chardef\unmlevel = \maxseclevel
3898
% Trace whether the current chapter is an appendix or not:
3899
% \chapheadtype is "N" or "A", unnumbered chapters are ignored.
3900
\def\chapheadtype{N}
3902
% Choose a heading macro
3903
% #1 is heading type
3904
% #2 is heading level
3905
% #3 is text for heading
3906
\def\genhead#1#2#3{%
3907
% Compute the abs. sec. level:
3909
\advance\absseclevel by \secbase
3910
% Make sure \absseclevel doesn't fall outside the range:
3911
\ifnum \absseclevel < 0
3914
\ifnum \absseclevel > 3
3921
\ifnum \absseclevel < \unmlevel
3922
\chardef\unmlevel = \absseclevel
3925
% Check for appendix sections:
3926
\ifnum \absseclevel = 0
3927
\edef\chapheadtype{\headtype}%
3929
\if \headtype A\if \chapheadtype N%
3930
\errmessage{@appendix... within a non-appendix chapter}%
3933
% Check for numbered within unnumbered:
3934
\ifnum \absseclevel > \unmlevel
3937
\chardef\unmlevel = 3
3940
% Now print the heading:
3944
\or \unnumberedseczzz{#3}%
3945
\or \unnumberedsubseczzz{#3}%
3946
\or \unnumberedsubsubseczzz{#3}%
3952
\or \appendixsectionzzz{#3}%
3953
\or \appendixsubseczzz{#3}%
3954
\or \appendixsubsubseczzz{#3}%
3960
\or \numberedsubseczzz{#3}%
3961
\or \numberedsubsubseczzz{#3}%
3965
\suppressfirstparagraphindent
3969
\def\numhead{\genhead N}
3970
\def\apphead{\genhead A}
3971
\def\unnmhead{\genhead U}
3973
% @chapter, @appendix, @unnumbered. Increment top-level counter, reset
3974
% all lower-level sectioning counters to zero.
3976
% Also set \chaplevelprefix, which we prepend to @float sequence numbers
3977
% (e.g., figures), q.v. By default (before any chapter), that is empty.
3978
\let\chaplevelprefix = \empty
3980
\outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz
3982
% section resetting is \global in case the chapter is in a group, such
3983
% as an @include file.
3984
\global\secno=0 \global\subsecno=0 \global\subsubsecno=0
3985
\global\advance\chapno by 1
3988
\gdef\chaplevelprefix{\the\chapno.}%
3991
\message{\putwordChapter\space \the\chapno}%
3993
% Write the actual heading.
3994
\chapmacro{#1}{Ynumbered}{\the\chapno}%
3996
% So @section and the like are numbered underneath this chapter.
3836
3997
\global\let\section = \numberedsec
3837
3998
\global\let\subsection = \numberedsubsec
3838
3999
\global\let\subsubsection = \numberedsubsubsec
3841
% we use \chapno to avoid indenting back
3842
\def\appendixbox#1{%
3843
\setbox0 = \hbox{\putwordAppendix{} \the\chapno}%
3844
\hbox to \wd0{#1\hss}}
3846
\outer\def\appendix{\parsearg\appendixyyy}
3847
\def\appendixyyy #1{\apphead0{#1}} % normally apphead0 calls appendixzzz
3848
\def\appendixzzz #1{%
3849
\secno=0 \subsecno=0 \subsubsecno=0
3850
\global\advance \appendixno by 1
3851
\message{\putwordAppendix\space \appendixletter}%
3852
\chapmacro {#1}{\appendixbox{\putwordAppendix{} \appendixletter}}%
3853
\gdef\thissection{#1}%
3854
\gdef\thischaptername{#1}%
3855
\xdef\thischapter{\putwordAppendix{} \appendixletter: \noexpand\thischaptername}%
3856
\writetocentry{appendix}{#1}{{\appendixletter}}
4002
\outer\parseargdef\appendix{\apphead0{#1}} % normally apphead0 calls appendixzzz
4003
\def\appendixzzz#1{%
4004
\global\secno=0 \global\subsecno=0 \global\subsubsecno=0
4005
\global\advance\appendixno by 1
4006
\gdef\chaplevelprefix{\appendixletter.}%
4009
\def\appendixnum{\putwordAppendix\space \appendixletter}%
4010
\message{\appendixnum}%
4012
\chapmacro{#1}{Yappendix}{\appendixletter}%
3858
4014
\global\let\section = \appendixsec
3859
4015
\global\let\subsection = \appendixsubsec
3860
4016
\global\let\subsubsection = \appendixsubsubsec
3863
% @centerchap is like @unnumbered, but the heading is centered.
3864
\outer\def\centerchap{\parsearg\centerchapyyy}
3865
\def\centerchapyyy #1{{\let\unnumbchapmacro=\centerchapmacro \unnumberedyyy{#1}}}
3867
% @top is like @unnumbered.
3868
\outer\def\top{\parsearg\unnumberedyyy}
3870
\outer\def\unnumbered{\parsearg\unnumberedyyy}
3871
\def\unnumberedyyy #1{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz
3872
\def\unnumberedzzz #1{%
3873
\secno=0 \subsecno=0 \subsubsecno=0
4019
\outer\parseargdef\unnumbered{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz
4020
\def\unnumberedzzz#1{%
4021
\global\secno=0 \global\subsecno=0 \global\subsubsecno=0
4022
\global\advance\unnumberedno by 1
4024
% Since an unnumbered has no number, no prefix for figures.
4025
\global\let\chaplevelprefix = \empty
3875
4028
% This used to be simply \message{#1}, but TeX fully expands the
3876
4029
% argument to \message. Therefore, if #1 contained @-commands, TeX
3883
4036
% \the<toks register> to achieve this: TeX expands \the<toks> only once,
3884
4037
% simply yielding the contents of <toks register>. (We also do this for
3885
4038
% the toc entries.)
3886
\toks0 = {#1}\message{(\the\toks0)}%
3888
\unnumbchapmacro {#1}%
3889
\gdef\thischapter{#1}\gdef\thissection{#1}%
3890
\writetocentry{unnumbchap}{#1}{{\the\chapno}}
4040
\message{(\the\toks0)}%
4042
\chapmacro{#1}{Ynothing}{\the\unnumberedno}%
3892
4044
\global\let\section = \unnumberedsec
3893
4045
\global\let\subsection = \unnumberedsubsec
3894
4046
\global\let\subsubsection = \unnumberedsubsubsec
4049
% @centerchap is like @unnumbered, but the heading is centered.
4050
\outer\parseargdef\centerchap{%
4051
% Well, we could do the following in a group, but that would break
4052
% an assumption that \chapmacro is called at the outermost level.
4053
% Thus we are safer this way: --kasal, 24feb04
4054
\let\centerparametersmaybe = \centerparameters
4056
\let\centerparametersmaybe = \relax
4059
% @top is like @unnumbered.
3898
\outer\def\numberedsec{\parsearg\secyyy}
3899
\def\secyyy #1{\numhead1{#1}} % normally calls seczzz
3901
\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
3902
\gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}%
3903
\writetocentry{sec}{#1}{{\the\chapno}{\the\secno}}
3908
\outer\def\appendixsection{\parsearg\appendixsecyyy}
3909
\outer\def\appendixsec{\parsearg\appendixsecyyy}
3910
\def\appendixsecyyy #1{\apphead1{#1}} % normally calls appendixsectionzzz
3911
\def\appendixsectionzzz #1{%
3912
\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
3913
\gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}%
3914
\writetocentry{sec}{#1}{{\appendixletter}{\the\secno}}
3919
\outer\def\unnumberedsec{\parsearg\unnumberedsecyyy}
3920
\def\unnumberedsecyyy #1{\unnmhead1{#1}} % normally calls unnumberedseczzz
3921
\def\unnumberedseczzz #1{%
3922
\plainsecheading {#1}\gdef\thissection{#1}%
3923
\writetocentry{unnumbsec}{#1}{{\the\chapno}{\the\secno}}
4063
\outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
4065
\global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
4066
\sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}%
4069
\outer\parseargdef\appendixsection{\apphead1{#1}} % normally calls appendixsectionzzz
4070
\def\appendixsectionzzz#1{%
4071
\global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
4072
\sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}%
4074
\let\appendixsec\appendixsection
4076
\outer\parseargdef\unnumberedsec{\unnmhead1{#1}} % normally calls unnumberedseczzz
4077
\def\unnumberedseczzz#1{%
4078
\global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
4079
\sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%
3929
\outer\def\numberedsubsec{\parsearg\numberedsubsecyyy}
3930
\def\numberedsubsecyyy #1{\numhead2{#1}} % normally calls numberedsubseczzz
3931
\def\numberedsubseczzz #1{%
3932
\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
3933
\subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}%
3934
\writetocentry{subsec}{#1}{{\the\chapno}{\the\secno}{\the\subsecno}}
3939
\outer\def\appendixsubsec{\parsearg\appendixsubsecyyy}
3940
\def\appendixsubsecyyy #1{\apphead2{#1}} % normally calls appendixsubseczzz
3941
\def\appendixsubseczzz #1{%
3942
\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
3943
\subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}%
3944
\writetocentry{subsec}{#1}{{\appendixletter}{\the\secno}{\the\subsecno}}
3949
\outer\def\unnumberedsubsec{\parsearg\unnumberedsubsecyyy}
3950
\def\unnumberedsubsecyyy #1{\unnmhead2{#1}} %normally calls unnumberedsubseczzz
3951
\def\unnumberedsubseczzz #1{%
3952
\plainsubsecheading {#1}\gdef\thissection{#1}%
3953
\writetocentry{unnumbsubsec}{#1}{{\the\chapno}{\the\secno}{\the\subsecno}}
4083
\outer\parseargdef\numberedsubsec{\numhead2{#1}} % normally calls numberedsubseczzz
4084
\def\numberedsubseczzz#1{%
4085
\global\subsubsecno=0 \global\advance\subsecno by 1
4086
\sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}%
4089
\outer\parseargdef\appendixsubsec{\apphead2{#1}} % normally calls appendixsubseczzz
4090
\def\appendixsubseczzz#1{%
4091
\global\subsubsecno=0 \global\advance\subsecno by 1
4092
\sectionheading{#1}{subsec}{Yappendix}%
4093
{\appendixletter.\the\secno.\the\subsecno}%
4096
\outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}} %normally calls unnumberedsubseczzz
4097
\def\unnumberedsubseczzz#1{%
4098
\global\subsubsecno=0 \global\advance\subsecno by 1
4099
\sectionheading{#1}{subsec}{Ynothing}%
4100
{\the\unnumberedno.\the\secno.\the\subsecno}%
3958
4103
% Subsubsections.
3959
\outer\def\numberedsubsubsec{\parsearg\numberedsubsubsecyyy}
3960
\def\numberedsubsubsecyyy #1{\numhead3{#1}} % normally numberedsubsubseczzz
3961
\def\numberedsubsubseczzz #1{%
3962
\gdef\thissection{#1}\global\advance \subsubsecno by 1 %
3963
\subsubsecheading {#1}
3964
{\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
3965
\writetocentry{subsubsec}{#1}{{\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}}
3970
\outer\def\appendixsubsubsec{\parsearg\appendixsubsubsecyyy}
3971
\def\appendixsubsubsecyyy #1{\apphead3{#1}} % normally appendixsubsubseczzz
3972
\def\appendixsubsubseczzz #1{%
3973
\gdef\thissection{#1}\global\advance \subsubsecno by 1 %
3974
\subsubsecheading {#1}
3975
{\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
3976
\writetocentry{subsubsec}{#1}{{\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}}
3981
\outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubsecyyy}
3982
\def\unnumberedsubsubsecyyy #1{\unnmhead3{#1}} %normally unnumberedsubsubseczzz
3983
\def\unnumberedsubsubseczzz #1{%
3984
\plainsubsubsecheading {#1}\gdef\thissection{#1}%
3985
\writetocentry{unnumbsubsubsec}{#1}{{\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}}
3990
% These are variants which are not "outer", so they can appear in @ifinfo.
3991
% Actually, they should now be obsolete; ordinary section commands should work.
3992
\def\infotop{\parsearg\unnumberedzzz}
3993
\def\infounnumbered{\parsearg\unnumberedzzz}
3994
\def\infounnumberedsec{\parsearg\unnumberedseczzz}
3995
\def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz}
3996
\def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
3998
\def\infoappendix{\parsearg\appendixzzz}
3999
\def\infoappendixsec{\parsearg\appendixseczzz}
4000
\def\infoappendixsubsec{\parsearg\appendixsubseczzz}
4001
\def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz}
4003
\def\infochapter{\parsearg\chapterzzz}
4004
\def\infosection{\parsearg\sectionzzz}
4005
\def\infosubsection{\parsearg\subsectionzzz}
4006
\def\infosubsubsection{\parsearg\subsubsectionzzz}
4104
\outer\parseargdef\numberedsubsubsec{\numhead3{#1}} % normally numberedsubsubseczzz
4105
\def\numberedsubsubseczzz#1{%
4106
\global\advance\subsubsecno by 1
4107
\sectionheading{#1}{subsubsec}{Ynumbered}%
4108
{\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}%
4111
\outer\parseargdef\appendixsubsubsec{\apphead3{#1}} % normally appendixsubsubseczzz
4112
\def\appendixsubsubseczzz#1{%
4113
\global\advance\subsubsecno by 1
4114
\sectionheading{#1}{subsubsec}{Yappendix}%
4115
{\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}%
4118
\outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}} %normally unnumberedsubsubseczzz
4119
\def\unnumberedsubsubseczzz#1{%
4120
\global\advance\subsubsecno by 1
4121
\sectionheading{#1}{subsubsec}{Ynothing}%
4122
{\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}%
4008
4125
% These macros control what the section commands do, according
4009
4126
% to what kind of chapter we are in (ordinary, appendix, or unnumbered).
4010
4127
% Define them by default for a numbered chapter.
4011
\global\let\section = \numberedsec
4012
\global\let\subsection = \numberedsubsec
4013
\global\let\subsubsection = \numberedsubsubsec
4128
\let\section = \numberedsec
4129
\let\subsection = \numberedsubsec
4130
\let\subsubsection = \numberedsubsubsec
4015
4132
% Define @majorheading, @heading and @subheading
4084
\global\let\chapmacro=\chfplain
4085
\global\let\unnumbchapmacro=\unnchfplain
4086
\global\let\centerchapmacro=\centerchfplain}
4088
% Plain chapter opening.
4089
% #1 is the text, #2 the chapter number or empty if unnumbered.
4204
% #1 is the text, #2 is the section type (Ynumbered, Ynothing,
4205
% Yappendix, Yomitfromtoc), #3 the chapter number.
4207
% To test against our argument.
4208
\def\Ynothingkeyword{Ynothing}
4209
\def\Yomitfromtockeyword{Yomitfromtoc}
4210
\def\Yappendixkeyword{Yappendix}
4212
\def\chapmacro#1#2#3{%
4095
\setbox0 = \hbox{#2\ifx\chapnum\empty\else\enspace\fi}%
4217
% Have to define \thissection before calling \donoderef, because the
4218
% xref code eventually uses it. On the other hand, it has to be called
4219
% after \pchapsepmacro, or the headline will change too soon.
4220
\gdef\thissection{#1}%
4221
\gdef\thischaptername{#1}%
4223
% Only insert the separating space if we have a chapter/appendix
4224
% number, and don't print the unnumbered ``number''.
4226
\ifx\temptype\Ynothingkeyword
4228
\def\toctype{unnchap}%
4229
\def\thischapter{#1}%
4230
\else\ifx\temptype\Yomitfromtockeyword
4231
\setbox0 = \hbox{}% contents like unnumbered, but no toc entry
4233
\xdef\thischapter{}%
4234
\else\ifx\temptype\Yappendixkeyword
4235
\setbox0 = \hbox{\putwordAppendix{} #3\enspace}%
4237
% We don't substitute the actual chapter name into \thischapter
4238
% because we don't want its macros evaluated now. And we don't
4239
% use \thissection because that changes with each section.
4241
\xdef\thischapter{\putwordAppendix{} \appendixletter:
4242
\noexpand\thischaptername}%
4244
\setbox0 = \hbox{#3\enspace}%
4245
\def\toctype{numchap}%
4246
\xdef\thischapter{\putwordChapter{} \the\chapno:
4247
\noexpand\thischaptername}%
4250
% Write the toc entry for this chapter. Must come before the
4251
% \donoderef, because we include the current node name in the toc
4252
% entry, and \donoderef resets it to empty.
4253
\writetocentry{\toctype}{#1}{#3}%
4255
% For pdftex, we have to write out the node definition (aka, make
4256
% the pdfdest) after any page break, but before the actual text has
4257
% been typeset. If the destination for the pdf outline is after the
4258
% text, then jumping from the outline may wind up with the text not
4259
% being visible, for instance under high magnification.
4262
% Typeset the actual heading.
4096
4263
\vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
4097
\hangindent = \wd0 \centerparametersmaybe
4264
\hangindent=\wd0 \centerparametersmaybe
4098
4265
\unhbox0 #1\par}%
4100
4267
\nobreak\bigskip % no page break after a chapter title
4104
% Plain opening for unnumbered.
4105
\def\unnchfplain#1{\chfplain{#1}{}}
4107
4271
% @centerchap -- centered and unnumbered.
4108
4272
\let\centerparametersmaybe = \relax
4109
\def\centerchfplain#1{{%
4110
\def\centerparametersmaybe{%
4111
\advance\rightskip by 3\rightskip
4112
\leftskip = \rightskip
4118
\CHAPFplain % The default
4273
\def\centerparameters{%
4274
\advance\rightskip by 3\rightskip
4275
\leftskip = \rightskip
4280
% I don't think this chapter style is supported any more, so I'm not
4281
% updating it with the new noderef stuff. We'll see. --karl, 11aug03.
4283
\def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
4120
4285
\def\unnchfopen #1{%
4121
4286
\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
4122
4287
\parindent=0pt\raggedright
4123
4288
\rm #1\hfill}}\bigskip \par\nobreak
4126
4290
\def\chfopen #1#2{\chapoddpage {\chapfonts
4127
4291
\vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
4128
4292
\par\penalty 5000 %
4131
4294
\def\centerchfopen #1{%
4132
4295
\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
4134
4297
\hfill {\rm #1}\hfill}}\bigskip \par\nobreak
4138
\global\let\chapmacro=\chfopen
4139
\global\let\unnumbchapmacro=\unnchfopen
4140
\global\let\centerchapmacro=\centerchfopen}
4300
\global\let\chapmacro=\chfopen
4301
\global\let\centerchapmacro=\centerchfopen}
4304
% Section titles. These macros combine the section number parts and
4305
% call the generic \sectionheading to do the printing.
4144
4307
\newskip\secheadingskip
4145
\def\secheadingbreak{\dobreak \secheadingskip {-1000}}
4146
\def\secheading#1#2#3{\sectionheading{sec}{#2.#3}{#1}}
4147
\def\plainsecheading#1{\sectionheading{sec}{}{#1}}
4308
\def\secheadingbreak{\dobreak \secheadingskip{-1000}}
4149
4310
% Subsection titles.
4150
\newskip \subsecheadingskip
4151
\def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}}
4152
\def\subsecheading#1#2#3#4{\sectionheading{subsec}{#2.#3.#4}{#1}}
4153
\def\plainsubsecheading#1{\sectionheading{subsec}{}{#1}}
4311
\newskip\subsecheadingskip
4312
\def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}}
4155
4314
% Subsubsection titles.
4156
\let\subsubsecheadingskip = \subsecheadingskip
4157
\let\subsubsecheadingbreak = \subsecheadingbreak
4158
\def\subsubsecheading#1#2#3#4#5{\sectionheading{subsubsec}{#2.#3.#4.#5}{#1}}
4159
\def\plainsubsubsecheading#1{\sectionheading{subsubsec}{}{#1}}
4162
% Print any size section title.
4164
% #1 is the section type (sec/subsec/subsubsec), #2 is the section
4165
% number (maybe empty), #3 the text.
4166
\def\sectionheading#1#2#3{%
4168
\expandafter\advance\csname #1headingskip\endcsname by \parskip
4169
\csname #1headingbreak\endcsname
4315
\def\subsubsecheadingskip{\subsecheadingskip}
4316
\def\subsubsecheadingbreak{\subsecheadingbreak}
4319
% Print any size, any type, section title.
4321
% #1 is the text, #2 is the section level (sec/subsec/subsubsec), #3 is
4322
% the section type for xrefs (Ynumbered, Ynothing, Yappendix), #4 is the
4325
\def\sectionheading#1#2#3#4{%
4172
4327
% Switch to the right set of fonts.
4173
\csname #1fonts\endcsname \rm
4175
% Only insert the separating space if we have a section number.
4177
\setbox0 = \hbox{#2\ifx\secnum\empty\else\enspace\fi}%
4328
\csname #2fonts\endcsname \rm
4330
% Insert space above the heading.
4331
\csname #2headingbreak\endcsname
4333
% Only insert the space after the number if we have a section number.
4334
\def\sectionlevel{#2}%
4337
\ifx\temptype\Ynothingkeyword
4340
\gdef\thissection{#1}%
4341
\else\ifx\temptype\Yomitfromtockeyword
4342
% for @headings -- no section number, don't include in toc,
4343
% and don't redefine \thissection.
4346
\let\sectionlevel=\empty
4347
\else\ifx\temptype\Yappendixkeyword
4348
\setbox0 = \hbox{#4\enspace}%
4350
\gdef\thissection{#1}%
4352
\setbox0 = \hbox{#4\enspace}%
4354
\gdef\thissection{#1}%
4357
% Write the toc entry (before \donoderef). See comments in \chfplain.
4358
\writetocentry{\toctype\sectionlevel}{#1}{#4}%
4360
% Write the node reference (= pdf destination for pdftex).
4361
% Again, see comments in \chfplain.
4364
% Output the actual section heading.
4179
4365
\vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
4180
\hangindent = \wd0 % zero if no section number
4366
\hangindent=\wd0 % zero if no section number
4183
% Add extra space after the heading -- either a line space or a
4184
% paragraph space, whichever is more. (Some people like to set
4185
% \parskip to large values for some reason.) Don't allow stretch, though.
4187
\ifdim\parskip>\normalbaselineskip
4190
\kern\normalbaselineskip
4369
% Add extra space after the heading -- half of whatever came above it.
4370
% Don't allow stretch, though.
4371
\kern .5 \csname #2headingskip\endcsname
4373
% Do not let the kern be a potential breakpoint, as it would be if it
4374
% was followed by glue.
4377
% We'll almost certainly start a paragraph next, so don't let that
4378
% glue accumulate. (Not a breakpoint because it's preceded by a
4379
% discardable item.)
4382
% This is purely so the last item on the list is a known \penalty >
4383
% 10000. This is so \startdefun can avoid allowing breakpoints after
4384
% section headings. Otherwise, it would insert a valid breakpoint between:
4386
% @section sec-whatever
4387
% @deffn def-whatever
4198
4394
\newwrite\tocfile
4200
4396
% Write an entry to the toc file, opening it if necessary.
4201
% Called from @chapter, etc. We supply {\folio} at the end of the
4202
% argument, which will end up as the last argument to the \...entry macro.
4204
% Usage: \writetocentry{chap}{The Name of The Game}{{\the\chapno}}
4397
% Called from @chapter, etc.
4399
% Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno}
4400
% We append the current node name (if any) and page number as additional
4401
% arguments for the \{chap,sec,...}entry macros which will eventually
4402
% read this. The node name is used in the pdf outlines as the
4403
% destination to jump to.
4205
4405
% We open the .toc file for writing here instead of at @setfilename (or
4206
4406
% any other fixed time) so that @contents can be anywhere in the document.
4407
% But if #1 is `omit', then we don't do anything. This is used for the
4408
% table of contents chapter openings themselves.
4208
4410
\newif\iftocfileopened
4411
\def\omitkeyword{omit}%
4209
4413
\def\writetocentry#1#2#3{%
4210
\iftocfileopened\else
4211
\immediate\openout\tocfile = \jobname.toc
4212
\global\tocfileopenedtrue
4217
\edef\temp{\write\tocfile{\realbackslash #1entry{\the\toks0}#3{\folio}}}%
4221
% Tell \shipout to create a page destination if we're doing pdf, which
4222
% will be the target of the links in the table of contents. We can't
4223
% just do it on every page because the title pages are numbered 1 and
4224
% 2 (the page numbers aren't printed), and so are the first two pages
4225
% of the document. Thus, we'd have two destinations named `1', and
4227
\ifpdf \pdfmakepagedesttrue \fi
4414
\edef\writetoctype{#1}%
4415
\ifx\writetoctype\omitkeyword \else
4416
\iftocfileopened\else
4417
\immediate\openout\tocfile = \jobname.toc
4418
\global\tocfileopenedtrue
4423
\toks2 = \expandafter{\lastnode}%
4424
\edef\temp{\write\tocfile{\realbackslash #1entry{\the\toks0}{#3}%
4425
{\the\toks2}{\noexpand\folio}}}%
4430
% Tell \shipout to create a pdf destination on each page, if we're
4431
% writing pdf. These are used in the table of contents. We can't
4432
% just write one on every page because the title pages are numbered
4433
% 1 and 2 (the page numbers aren't printed), and so are the first
4434
% two pages of the document. Thus, we'd have two destinations named
4435
% `1', and two named `2'.
4436
\ifpdf \global\pdfmakepagedesttrue \fi
4230
4439
\newskip\contentsrightmargin \contentsrightmargin=1in
4231
4440
\newcount\savepageno
4232
4441
\newcount\lastnegativepageno \lastnegativepageno = -1
4234
% Finish up the main text and prepare to read what we've written
4443
% Prepare to read what we've written to \tocfile.
4237
4445
\def\startcontents#1{%
4238
% If @setchapternewpage on, and @headings double, the contents should
4239
% start on an odd page, unlike chapters. Thus, we maintain
4240
% \contentsalignmacro in parallel with \pagealignmacro.
4241
% From: Torbjorn Granlund <tege@matematik.su.se>
4243
\immediate\closeout\tocfile
4245
% Don't need to put `Contents' or `Short Contents' in the headline.
4246
% It is abundantly clear what they are.
4247
\unnumbchapmacro{#1}\def\thischapter{}%
4248
\savepageno = \pageno
4249
\begingroup % Set up to handle contents files properly.
4250
\catcode`\\=0 \catcode`\{=1 \catcode`\}=2 \catcode`\@=11
4251
% We can't do this, because then an actual ^ in a section
4252
% title fails, e.g., @chapter ^ -- exponentiation. --karl, 9jul97.
4253
%\catcode`\^=7 % to see ^^e4 as \"a etc. juha@piuha.ydi.vtt.fi
4254
\raggedbottom % Worry more about breakpoints than the bottom.
4255
\advance\hsize by -\contentsrightmargin % Don't use the full line length.
4257
% Roman numerals for page numbers.
4258
\ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
4446
% If @setchapternewpage on, and @headings double, the contents should
4447
% start on an odd page, unlike chapters. Thus, we maintain
4448
% \contentsalignmacro in parallel with \pagealignmacro.
4449
% From: Torbjorn Granlund <tege@matematik.su.se>
4451
\immediate\closeout\tocfile
4453
% Don't need to put `Contents' or `Short Contents' in the headline.
4454
% It is abundantly clear what they are.
4456
\chapmacro{#1}{Yomitfromtoc}{}%
4458
\savepageno = \pageno
4459
\begingroup % Set up to handle contents files properly.
4460
\catcode`\\=0 \catcode`\{=1 \catcode`\}=2 \catcode`\@=11
4461
% We can't do this, because then an actual ^ in a section
4462
% title fails, e.g., @chapter ^ -- exponentiation. --karl, 9jul97.
4463
%\catcode`\^=7 % to see ^^e4 as \"a etc. juha@piuha.ydi.vtt.fi
4464
\raggedbottom % Worry more about breakpoints than the bottom.
4465
\advance\hsize by -\contentsrightmargin % Don't use the full line length.
4467
% Roman numerals for page numbers.
4468
\ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
4262
4472
% Normal (long) toc.
4263
4473
\def\contents{%
4264
\startcontents{\putwordTOC}%
4265
\openin 1 \jobname.toc
4271
\contentsalignmacro % in case @setchapternewpage odd is in effect
4274
\lastnegativepageno = \pageno
4275
\global\pageno = \savepageno
4474
\startcontents{\putwordTOC}%
4475
\openin 1 \jobname.toc
4480
\contentsalignmacro % in case @setchapternewpage odd is in effect
4486
\lastnegativepageno = \pageno
4487
\global\pageno = \savepageno
4278
4490
% And just the chapters.
4279
4491
\def\summarycontents{%
4280
\startcontents{\putwordShortTOC}%
4282
\let\chapentry = \shortchapentry
4283
\let\appendixentry = \shortappendixentry
4284
\let\unnumbchapentry = \shortunnumberedentry
4285
% We want a true roman here for the page numbers.
4287
\let\rm=\shortcontrm \let\bf=\shortcontbf
4288
\let\sl=\shortcontsl \let\tt=\shortconttt
4290
\hyphenpenalty = 10000
4291
\advance\baselineskip by 1pt % Open it up a little.
4292
\def\secentry ##1##2##3##4{}
4293
\def\subsecentry ##1##2##3##4##5{}
4294
\def\subsubsecentry ##1##2##3##4##5##6{}
4295
\let\unnumbsecentry = \secentry
4296
\let\unnumbsubsecentry = \subsecentry
4297
\let\unnumbsubsubsecentry = \subsubsecentry
4298
\openin 1 \jobname.toc
4304
\contentsalignmacro % in case @setchapternewpage odd is in effect
4306
\lastnegativepageno = \pageno
4307
\global\pageno = \savepageno
4492
\startcontents{\putwordShortTOC}%
4494
\let\numchapentry = \shortchapentry
4495
\let\appentry = \shortchapentry
4496
\let\unnchapentry = \shortunnchapentry
4497
% We want a true roman here for the page numbers.
4499
\let\rm=\shortcontrm \let\bf=\shortcontbf
4500
\let\sl=\shortcontsl \let\tt=\shortconttt
4502
\hyphenpenalty = 10000
4503
\advance\baselineskip by 1pt % Open it up a little.
4504
\def\numsecentry##1##2##3##4{}
4505
\let\appsecentry = \numsecentry
4506
\let\unnsecentry = \numsecentry
4507
\let\numsubsecentry = \numsecentry
4508
\let\appsubsecentry = \numsecentry
4509
\let\unnsubsecentry = \numsecentry
4510
\let\numsubsubsecentry = \numsecentry
4511
\let\appsubsubsecentry = \numsecentry
4512
\let\unnsubsubsecentry = \numsecentry
4513
\openin 1 \jobname.toc
4519
\contentsalignmacro % in case @setchapternewpage odd is in effect
4521
\lastnegativepageno = \pageno
4522
\global\pageno = \savepageno
4309
4524
\let\shortcontents = \summarycontents
4312
\pdfcatalog{/PageMode /UseOutlines}%
4526
% Typeset the label for a chapter or appendix for the short contents.
4527
% The arg is, e.g., `A' for an appendix, or `3' for a chapter.
4529
\def\shortchaplabel#1{%
4530
% This space should be enough, since a single number is .5em, and the
4531
% widest letter (M) is 1em, at least in the Computer Modern fonts.
4532
% But use \hss just in case.
4533
% (This space doesn't include the extra space that gets added after
4534
% the label; that gets put in by \shortchapentry above.)
4536
% We'd like to right-justify chapter numbers, but that looks strange
4537
% with appendix letters. And right-justifying numbers and
4538
% left-justifying letters looks strange when there is less than 10
4539
% chapters. Have to read the whole toc once to know how many chapters
4540
% there are before deciding ...
4541
\hbox to 1em{#1\hss}%
4315
4544
% These macros generate individual entries in the table of contents.
4316
4545
% The first argument is the chapter or section name.
4914
5101
% file; b) letting users define the frontmatter in as flexible order as
4915
5102
% possible is very desirable.
4917
\def\copying{\begingroup
4918
% Define a command to swallow text until we reach `@end copying'.
4919
% \ is the escape char in this texinfo.tex file, so it is the
4920
% delimiter for the command; @ will be the escape char when we read
4921
% it, but that doesn't matter.
4922
\long\def\docopying##1\end copying{\gdef\copyingtext{##1}\enddocopying}%
4924
% We must preserve ^^M's in the input file; see \insertcopying below.
4925
\catcode`\^^M = \active
4929
% What we do to finish off the copying text.
4931
\def\enddocopying{\endgroup\ignorespaces}
4933
% @insertcopying. Here we must play games with ^^M's. On the one hand,
4934
% we need them to delimit commands such as `@end quotation', so they
4935
% must be active. On the other hand, we certainly don't want every
4936
% end-of-line to be a \par, as would happen with the normal active
4937
% definition of ^^M. On the third hand, two ^^M's in a row should still
4940
% Our approach is to make ^^M insert a space and a penalty1 normally;
4941
% then it can also check if \lastpenalty=1. If it does, then manually
4944
% This messes up the normal definitions of @c[omment], so we redefine
4945
% it. Similarly for @ignore. (These commands are used in the gcc
4946
% manual for man page generation.)
4948
% Seems pretty fragile, most line-oriented commands will presumably
4949
% fail, but for the limited use of getting the copying text (which
4950
% should be quite simple) inserted, we can hope it's ok.
4952
{\catcode`\^^M=\active %
4953
\gdef\insertcopying{\begingroup %
4954
\parindent = 0pt % looks wrong on title page
4956
\ifnum \lastpenalty=1 %
4963
% Fix @c[omment] for catcode 13 ^^M's.
4964
\def\c##1^^M{\ignorespaces}%
4967
% Don't bother jumping through all the hoops that \doignore does, it
4968
% would be very hard since the catcodes are already set.
4969
\long\def\ignore##1\end ignore{\ignorespaces}%
5104
\def\copying{\checkenv{}\begingroup\scanargctxt\docopying}
5105
\def\docopying#1@end copying{\endgroup\def\copyingtext{#1}}
5107
\def\insertcopying{%
5109
\parindent = 0pt % paragraph indentation looks wrong on title page
5110
\scanexp\copyingtext
4975
5114
\message{defuns,}
4978
% Allow user to change definition object font (\df) internally
4979
\def\setdeffont#1 {\csname DEF#1\endcsname}
4981
5117
\newskip\defbodyindent \defbodyindent=.4in
4982
5118
\newskip\defargsindent \defargsindent=50pt
4983
5119
\newskip\deflastargmargin \deflastargmargin=18pt
4985
\newcount\parencount
5121
% Start the processing of @deffn:
5123
\ifnum\lastpenalty<10000
5126
% If there are two @def commands in a row, we'll have a \nobreak,
5127
% which is there to keep the function description together with its
5128
% header. But if there's nothing but headers, we need to allow a
5129
% break somewhere. Check specifically for penalty 10002, inserted
5130
% by \defargscommonending, instead of 10000, since the sectioning
5131
% commands also insert a nobreak penalty, and we don't want to allow
5132
% a break between a section heading and a defun.
5134
\ifnum\lastpenalty=10002 \penalty2000 \fi
5136
% Similarly, after a section heading, do not allow a break.
5137
% But do insert the glue.
5138
\medskip % preceded by discardable penalty, so not a breakpoint
5142
\advance\leftskip by \defbodyindent
5143
\exdentamount=\defbodyindent
5147
% First, check whether we are in the right environment:
5150
% As above, allow line break if we have multiple x headers in a row.
5151
% It's not a great place, though.
5152
\ifnum\lastpenalty=10002 \penalty3000 \fi
5154
% And now, it's time to reuse the body of the original defun:
5155
\expandafter\gobbledefun#1%
5157
\def\gobbledefun#1\startdefun{}
5159
% \printdefunline \deffnheader{text}
5161
\def\printdefunline#1#2{%
5163
% call \deffnheader:
5166
\interlinepenalty = 10000
5167
\advance\rightskip by 0pt plus 1fil
5169
\nobreak\vskip -\parskip
5170
\penalty 10002 % signal to \startdefun and \dodefunx
5171
% Some of the @defun-type tags do not enable magic parentheses,
5172
% rendering the following check redundant. But we don't optimize.
5177
\def\Edefun{\endgraf\medbreak}
5179
% \makedefun{deffn} creates \deffn, \deffnx and \Edeffn;
5180
% the only thing remainnig is to define \deffnheader.
5183
\expandafter\let\csname E#1\endcsname = \Edefun
5184
\edef\temp{\noexpand\domakedefun
5185
\makecsname{#1}\makecsname{#1x}\makecsname{#1header}}%
5189
% \domakedefun \deffn \deffnx \deffnheader
5191
% Define \deffn and \deffnx, without parameters.
5192
% \deffnheader has to be defined explicitly.
5194
\def\domakedefun#1#2#3{%
5197
\parseargusing\activeparens{\printdefunline#3}%
5199
\def#2{\dodefunx#1}%
5203
%%% Untyped functions:
5205
% @deffn category name args
5206
\makedefun{deffn}{\deffngeneral{}}
5208
% @deffn category class name args
5209
\makedefun{defop}#1 {\defopon{#1\ \putwordon}}
5211
% \defopon {category on}class name args
5212
\def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
5214
% \deffngeneral {subind}category name args
5216
\def\deffngeneral#1#2 #3 #4\endheader{%
5217
% Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}.
5218
\dosubind{fn}{\code{#3}}{#1}%
5219
\defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
5222
%%% Typed functions:
5224
% @deftypefn category type name args
5225
\makedefun{deftypefn}{\deftypefngeneral{}}
5227
% @deftypeop category class type name args
5228
\makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}}
5230
% \deftypeopon {category on}class type name args
5231
\def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
5233
% \deftypefngeneral {subind}category type name args
5235
\def\deftypefngeneral#1#2 #3 #4 #5\endheader{%
5236
\dosubind{fn}{\code{#4}}{#1}%
5237
\defname{#2}{#3}{#4}\defunargs{#5\unskip}%
5240
%%% Typed variables:
5242
% @deftypevr category type var args
5243
\makedefun{deftypevr}{\deftypecvgeneral{}}
5245
% @deftypecv category class type var args
5246
\makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}}
5248
% \deftypecvof {category of}class type var args
5249
\def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} }
5251
% \deftypecvgeneral {subind}category type var args
5253
\def\deftypecvgeneral#1#2 #3 #4 #5\endheader{%
5254
\dosubind{vr}{\code{#4}}{#1}%
5255
\defname{#2}{#3}{#4}\defunargs{#5\unskip}%
5258
%%% Untyped variables:
5260
% @defvr category var args
5261
\makedefun{defvr}#1 {\deftypevrheader{#1} {} }
5263
% @defcv category class var args
5264
\makedefun{defcv}#1 {\defcvof{#1\ \putwordof}}
5266
% \defcvof {category of}class var args
5267
\def\defcvof#1#2 {\deftypecvof{#1}#2 {} }
5270
% @deftp category name args
5271
\makedefun{deftp}#1 #2 #3\endheader{%
5272
\doind{tp}{\code{#2}}%
5273
\defname{#1}{}{#2}\defunargs{#3\unskip}%
5276
% Remaining @defun-like shortcuts:
5277
\makedefun{defun}{\deffnheader{\putwordDeffunc} }
5278
\makedefun{defmac}{\deffnheader{\putwordDefmac} }
5279
\makedefun{defspec}{\deffnheader{\putwordDefspec} }
5280
\makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} }
5281
\makedefun{defvar}{\defvrheader{\putwordDefvar} }
5282
\makedefun{defopt}{\defvrheader{\putwordDefopt} }
5283
\makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} }
5284
\makedefun{defmethod}{\defopon\putwordMethodon}
5285
\makedefun{deftypemethod}{\deftypeopon\putwordMethodon}
5286
\makedefun{defivar}{\defcvof\putwordInstanceVariableof}
5287
\makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof}
5289
% \defname, which formats the name of the @def (not the args).
5290
% #1 is the category, such as "Function".
5291
% #2 is the return type, if any.
5292
% #3 is the function name.
5294
% We are followed by (but not passed) the arguments, if any.
5296
\def\defname#1#2#3{%
5297
% Get the values of \leftskip and \rightskip as they were outside the @def...
5298
\advance\leftskip by -\defbodyindent
5300
% How we'll format the type name. Putting it in brackets helps
5301
% distinguish it from the body text that may end up on the next line
5304
\setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
5306
% Figure out line sizes for the paragraph shape.
5307
% The first line needs space for \box0; but if \rightskip is nonzero,
5308
% we need only space for the part of \box0 which exceeds it:
5309
\dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip
5310
% The continuations:
5311
\dimen2=\hsize \advance\dimen2 by -\defargsindent
5312
% (plain.tex says that \dimen1 should be used only as global.)
5313
\parshape 2 0in \dimen0 \defargsindent \dimen2
5315
% Put the type name to the right margin.
5318
\hfil\box0 \kern-\hsize
5319
% \hsize has to be shortened this way:
5321
% Intentionally do not respect \rightskip, since we need the space.
5324
% Allow all lines to be underfull without complaint:
5325
\tolerance=10000 \hbadness=10000
5326
\exdentamount=\defbodyindent
5328
% defun fonts. We use typewriter by default (used to be bold) because:
5329
% . we're printing identifiers, they should be in tt in principle.
5330
% . in languages with many accents, such as Czech or French, it's
5331
% common to leave accents off identifiers. The result looks ok in
5332
% tt, but exceedingly strange in rm.
5333
% . we don't want -- and --- to be treated as ligatures.
5334
% . this still does not fix the ?` and !` ligatures, but so far no
5335
% one has made identifiers using them :).
5337
\def\temp{#2}% return value type
5338
\ifx\temp\empty\else \tclose{\temp} \fi
5339
#3% output function name
5341
{\rm\enskip}% hskip 0.5 em of \tenrm
5344
% arguments will be output next, if any.
5347
% Print arguments in slanted roman (not ttsl), inconsistently with using
5348
% tt for the name. This is because literal text is sometimes needed in
5349
% the argument list (groff manual), and ttsl and tt are not very
5350
% distinguishable. Prevent hyphenation at `-' chars.
5353
% use sl by default (not ttsl),
5355
\df \sl \hyphenchar\font=0
5357
% On the other hand, if an argument has two dashes (for instance), we
5358
% want a way to get ttsl. Let's try @var for that.
5361
\sl\hyphenchar\font=45
4987
5364
% We want ()&[] to print specially on the defun line.
4989
5366
\def\activeparens{%
4990
5367
\catcode`\(=\active \catcode`\)=\active
5368
\catcode`\[=\active \catcode`\]=\active
4991
5369
\catcode`\&=\active
4992
\catcode`\[=\active \catcode`\]=\active
4995
5372
% Make control sequences which act like normal parenthesis chars.
4996
5373
\let\lparen = ( \let\rparen = )
4998
{\activeparens % Now, smart parens don't turn on until &foo (see \amprm)
5000
5375
% Be sure that we always have a definition for `(', etc. For example,
5001
5376
% if the fn name has parens in it, \boldbrax will not be in effect yet,
5002
5377
% so TeX would otherwise complain about undefined control sequence.
5003
\global\let(=\lparen \global\let)=\rparen
5004
\global\let[=\lbrack \global\let]=\rbrack
5006
\gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 }
5007
\gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
5008
% This is used to turn on special parens
5009
% but make & act ordinary (given that it's active).
5010
\gdef\boldbraxnoamp{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb\let&=\ampnr}
5012
% Definitions of (, ) and & used in args for functions.
5013
% This is the definition of ( outside of all parentheses.
5014
\gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested
5380
\global\let(=\lparen \global\let)=\rparen
5381
\global\let[=\lbrack \global\let]=\rbrack
5384
\gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
5385
\gdef\magicamp{\let&=\amprm}
5388
\newcount\parencount
5390
% If we encounter &foo, then turn on ()-hacking afterwards
5392
\def\amprm#1 {\ampseentrue{\bf\ }}
5396
% At the first level, print parens in roman,
5397
% otherwise use the default font.
5398
\ifnum \parencount=1 \rm \fi
5400
% The \sf parens (in \boldbrax) actually are a little bolder than
5401
% the contained text. This is especially needed for [ and ] .
5405
\def\infirstlevel#1{%
5412
\def\bfafterword#1 {#1 \bf}
5015
5415
\global\advance\parencount by 1
5018
% This is the definition of ( when already inside a level of parens.
5019
\gdef\opnested{\char`\(\global\advance\parencount by 1 }
5021
\gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0.
5022
% also in that case restore the outer-level definition of (.
5023
\ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi
5024
\global\advance \parencount by -1 }
5025
% If we encounter &foo, then turn on ()-hacking afterwards
5026
\gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ }
5028
\gdef\normalparens{\boldbrax\let&=\ampnr}
5029
} % End of definition inside \activeparens
5030
%% These parens (in \boldbrax) actually are a little bolder than the
5031
%% contained text. This is especially needed for [ and ]
5032
\def\opnr{{\sf\char`\(}\global\advance\parencount by 1 }
5033
\def\clnr{{\sf\char`\)}\global\advance\parencount by -1 }
5035
\def\lbrb{{\bf\char`\[}}
5036
\def\rbrb{{\bf\char`\]}}
5038
% Active &'s sneak into the index arguments, so make sure it's defined.
5040
\catcode`& = \active
5041
\global\let& = \ampnr
5044
% \defname, which formats the name of the @def (not the args).
5045
% #1 is the function name.
5046
% #2 is the type of definition, such as "Function".
5049
% How we'll output the type name. Putting it in brackets helps
5050
% distinguish it from the body text that may end up on the next line
5055
\def\defnametype{[\rm #2]}%
5058
% Get the values of \leftskip and \rightskip as they were outside the @def...
5060
\advance\dimen2 by -\defbodyindent
5062
% Figure out values for the paragraph shape.
5063
\setbox0=\hbox{\hskip \deflastargmargin{\defnametype}}%
5064
\dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line
5065
\dimen1=\hsize \advance \dimen1 by -\defargsindent % size for continuations
5066
\parshape 2 0in \dimen0 \defargsindent \dimen1
5068
% Output arg 2 ("Function" or some such) but stuck inside a box of
5069
% width 0 so it does not interfere with linebreaking.
5072
{% Adjust \hsize to exclude the ambient margins,
5073
% so that \rightline will obey them.
5074
\advance \hsize by -\dimen2
5075
\dimen3 = 0pt % was -1.25pc
5076
\rlap{\rightline{\defnametype\kern\dimen3}}%
5079
% Allow all lines to be underfull without complaint:
5080
\tolerance=10000 \hbadness=10000
5081
\advance\leftskip by -\defbodyindent
5082
\exdentamount=\defbodyindent
5083
{\df #1}\enskip % output function name
5084
% \defunargs will be called next to output the arguments, if any.
5087
% Common pieces to start any @def...
5088
% #1 is the \E... control sequence to end the definition (which we define).
5089
% #2 is the \...x control sequence (which our caller defines).
5090
% #3 is the control sequence to process the header, such as \defunheader.
5092
\def\parsebodycommon#1#2#3{%
5094
% If there are two @def commands in a row, we'll have a \nobreak,
5095
% which is there to keep the function description together with its
5096
% header. But if there's nothing but headers, we want to allow a
5097
% break after all. Check for penalty 10002 (inserted by
5098
% \defargscommonending) instead of 10000, since the sectioning
5099
% commands insert a \penalty10000, and we don't want to allow a break
5100
% between a section heading and a defun.
5101
\ifnum\lastpenalty=10002 \penalty0 \fi
5104
% Define the \E... end token that this defining construct specifies
5105
% so that it will exit this group.
5106
\def#1{\endgraf\endgroup\medbreak}%
5109
\advance\leftskip by \defbodyindent
5110
\exdentamount=\defbodyindent
5113
% Common part of the \...x definitions.
5115
\def\defxbodycommon{%
5116
% As with \parsebodycommon above, allow line break if we have multiple
5117
% x headers in a row. It's not a great place, though.
5118
\ifnum\lastpenalty=10000 \penalty1000 \fi
5120
\begingroup\obeylines
5123
% Process body of @defun, @deffn, @defmac, etc.
5125
\def\defparsebody#1#2#3{%
5126
\parsebodycommon{#1}{#2}{#3}%
5127
\def#2{\defxbodycommon \activeparens \spacesplit#3}%
5128
\catcode\equalChar=\active
5129
\begingroup\obeylines\activeparens
5133
% #1, #2, #3 are the common arguments (see \parsebodycommon above).
5134
% #4, delimited by the space, is the class name.
5136
\def\defmethparsebody#1#2#3#4 {%
5137
\parsebodycommon{#1}{#2}{#3}%
5138
\def#2##1 {\defxbodycommon \activeparens \spacesplit{#3{##1}}}%
5139
\begingroup\obeylines\activeparens
5140
% The \empty here prevents misinterpretation of a construct such as
5141
% @deffn {whatever} {Enharmonic comma}
5142
% See comments at \deftpparsebody, although in our case we don't have
5143
% to remove the \empty afterwards, since it is empty.
5144
\spacesplit{#3{#4}}\empty
5147
% Used for @deftypemethod and @deftypeivar.
5148
% #1, #2, #3 are the common arguments (see \defparsebody).
5149
% #4, delimited by a space, is the class name.
5150
% #5 is the method's return type.
5152
\def\deftypemethparsebody#1#2#3#4 #5 {%
5153
\parsebodycommon{#1}{#2}{#3}%
5154
\def#2##1 ##2 {\defxbodycommon \activeparens \spacesplit{#3{##1}{##2}}}%
5155
\begingroup\obeylines\activeparens
5156
\spacesplit{#3{#4}{#5}}%
5159
% Used for @deftypeop. The change from \deftypemethparsebody is an
5160
% extra argument at the beginning which is the `category', instead of it
5161
% being the hardwired string `Method' or `Instance Variable'. We have
5162
% to account for this both in the \...x definition and in parsing the
5163
% input at hand. Thus also need a control sequence (passed as #5) for
5164
% the \E... definition to assign the category name to.
5166
\def\deftypeopparsebody#1#2#3#4#5 #6 {%
5167
\parsebodycommon{#1}{#2}{#3}%
5168
\def#2##1 ##2 ##3 {\def#4{##1}%
5169
\defxbodycommon \activeparens \spacesplit{#3{##2}{##3}}}%
5170
\begingroup\obeylines\activeparens
5171
\spacesplit{#3{#5}{#6}}%
5175
\def\defopparsebody #1#2#3#4#5 {%
5176
\parsebodycommon{#1}{#2}{#3}%
5177
\def#2##1 ##2 {\def#4{##1}%
5178
\defxbodycommon \activeparens \spacesplit{#3{##2}}}%
5179
\begingroup\obeylines\activeparens
5180
\spacesplit{#3{#5}}%
5183
% These parsing functions are similar to the preceding ones
5184
% except that they do not make parens into active characters.
5185
% These are used for "variables" since they have no arguments.
5187
\def\defvarparsebody #1#2#3{%
5188
\parsebodycommon{#1}{#2}{#3}%
5189
\def#2{\defxbodycommon \spacesplit#3}%
5190
\catcode\equalChar=\active
5191
\begingroup\obeylines
5196
\def\defopvarparsebody #1#2#3#4#5 {%
5197
\parsebodycommon{#1}{#2}{#3}%
5198
\def#2##1 ##2 {\def#4{##1}%
5199
\defxbodycommon \spacesplit{#3{##2}}}%
5200
\begingroup\obeylines
5201
\spacesplit{#3{#5}}%
5204
\def\defvrparsebody#1#2#3#4 {%
5205
\parsebodycommon{#1}{#2}{#3}%
5206
\def#2##1 {\defxbodycommon \spacesplit{#3{##1}}}%
5207
\begingroup\obeylines
5208
\spacesplit{#3{#4}}%
5211
% This loses on `@deftp {Data Type} {struct termios}' -- it thinks the
5212
% type is just `struct', because we lose the braces in `{struct
5213
% termios}' when \spacesplit reads its undelimited argument. Sigh.
5214
% \let\deftpparsebody=\defvrparsebody
5216
% So, to get around this, we put \empty in with the type name. That
5217
% way, TeX won't find exactly `{...}' as an undelimited argument, and
5218
% won't strip off the braces.
5220
\def\deftpparsebody #1#2#3#4 {%
5221
\parsebodycommon{#1}{#2}{#3}%
5222
\def#2##1 {\defxbodycommon \spacesplit{#3{##1}}}%
5223
\begingroup\obeylines
5224
\spacesplit{\parsetpheaderline{#3{#4}}}\empty
5227
% Fine, but then we have to eventually remove the \empty *and* the
5228
% braces (if any). That's what this does.
5230
\def\removeemptybraces\empty#1\relax{#1}
5232
% After \spacesplit has done its work, this is called -- #1 is the final
5233
% thing to call, #2 the type name (which starts with \empty), and #3
5234
% (which might be empty) the arguments.
5236
\def\parsetpheaderline#1#2#3{%
5237
#1{\removeemptybraces#2\relax}{#3}%
5240
% Split up #2 (the rest of the input line) at the first space token.
5241
% call #1 with two arguments:
5242
% the first is all of #2 before the space token,
5243
% the second is all of #2 after that space token.
5244
% If #2 contains no space token, all of it is passed as the first arg
5245
% and the second is passed as empty.
5248
\gdef\spacesplit#1#2^^M{\endgroup\spacesplitx{#1}#2 \relax\spacesplitx}%
5249
\long\gdef\spacesplitx#1#2 #3#4\spacesplitx{%
5259
% This is called to end the arguments processing for all the @def... commands.
5261
\def\defargscommonending{%
5262
\interlinepenalty = 10000
5263
\advance\rightskip by 0pt plus 1fil
5265
\nobreak\vskip -\parskip
5266
\penalty 10002 % signal to \parsebodycommon.
5269
% This expands the args and terminates the paragraph they comprise.
5271
\def\defunargs#1{\functionparens \sl
5272
% Expand, preventing hyphenation at `-' chars.
5273
% Note that groups don't affect changes in \hyphenchar.
5274
% Set the font temporarily and use \font in case \setfont made \tensl a macro.
5275
{\tensl\hyphenchar\font=0}%
5277
{\tensl\hyphenchar\font=45}%
5278
\ifnum\parencount=0 \else \errmessage{Unbalanced parentheses in @def}\fi%
5279
\defargscommonending
5282
\def\deftypefunargs #1{%
5283
% Expand, preventing hyphenation at `-' chars.
5284
% Note that groups don't affect changes in \hyphenchar.
5285
% Use \boldbraxnoamp, not \functionparens, so that & is not special.
5287
\tclose{#1}% avoid \code because of side effects on active chars
5288
\defargscommonending
5291
% Do complete processing of one @defun or @defunx line already parsed.
5293
% @deffn Command forward-char nchars
5295
\def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader}
5297
\def\deffnheader #1#2#3{\doind {fn}{\code{#2}}%
5298
\begingroup\defname {#2}{#1}\defunargs{#3}\endgroup %
5299
\catcode\equalChar=\other % Turn off change made in \defparsebody
5302
% @defun == @deffn Function
5304
\def\defun{\defparsebody\Edefun\defunx\defunheader}
5306
\def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
5307
\begingroup\defname {#1}{\putwordDeffunc}%
5308
\defunargs {#2}\endgroup %
5309
\catcode\equalChar=\other % Turn off change made in \defparsebody
5312
% @deftypefun int foobar (int @var{foo}, float @var{bar})
5314
\def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader}
5316
% #1 is the data type. #2 is the name and args.
5317
\def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax}
5318
% #1 is the data type, #2 the name, #3 the args.
5319
\def\deftypefunheaderx #1#2 #3\relax{%
5320
\doind {fn}{\code{#2}}% Make entry in function index
5321
\begingroup\defname {\defheaderxcond#1\relax$.$#2}{\putwordDeftypefun}%
5322
\deftypefunargs {#3}\endgroup %
5323
\catcode\equalChar=\other % Turn off change made in \defparsebody
5326
% @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar})
5328
\def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader}
5330
% \defheaderxcond#1\relax$.$
5331
% puts #1 in @code, followed by a space, but does nothing if #1 is null.
5332
\def\defheaderxcond#1#2$.${\ifx#1\relax\else\code{#1#2} \fi}
5334
% #1 is the classification. #2 is the data type. #3 is the name and args.
5335
\def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax}
5336
% #1 is the classification, #2 the data type, #3 the name, #4 the args.
5337
\def\deftypefnheaderx #1#2#3 #4\relax{%
5338
\doind {fn}{\code{#3}}% Make entry in function index
5340
\normalparens % notably, turn off `&' magic, which prevents
5341
% at least some C++ text from working
5342
\defname {\defheaderxcond#2\relax$.$#3}{#1}%
5343
\deftypefunargs {#4}\endgroup %
5344
\catcode\equalChar=\other % Turn off change made in \defparsebody
5347
% @defmac == @deffn Macro
5349
\def\defmac{\defparsebody\Edefmac\defmacx\defmacheader}
5351
\def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
5352
\begingroup\defname {#1}{\putwordDefmac}%
5353
\defunargs {#2}\endgroup %
5354
\catcode\equalChar=\other % Turn off change made in \defparsebody
5357
% @defspec == @deffn Special Form
5359
\def\defspec{\defparsebody\Edefspec\defspecx\defspecheader}
5361
\def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
5362
\begingroup\defname {#1}{\putwordDefspec}%
5363
\defunargs {#2}\endgroup %
5364
\catcode\equalChar=\other % Turn off change made in \defparsebody
5367
% @defop CATEGORY CLASS OPERATION ARG...
5369
\def\defop #1 {\def\defoptype{#1}%
5370
\defopparsebody\Edefop\defopx\defopheader\defoptype}
5372
\def\defopheader#1#2#3{%
5373
\dosubind{fn}{\code{#2}}{\putwordon\ \code{#1}}% function index entry
5375
\defname{#2}{\defoptype\ \putwordon\ #1}%
5380
% @deftypeop CATEGORY CLASS TYPE OPERATION ARG...
5382
\def\deftypeop #1 {\def\deftypeopcategory{#1}%
5383
\deftypeopparsebody\Edeftypeop\deftypeopx\deftypeopheader
5386
% #1 is the class name, #2 the data type, #3 the operation name, #4 the args.
5387
\def\deftypeopheader#1#2#3#4{%
5388
\dosubind{fn}{\code{#3}}{\putwordon\ \code{#1}}% entry in function index
5390
\defname{\defheaderxcond#2\relax$.$#3}
5391
{\deftypeopcategory\ \putwordon\ \code{#1}}%
5392
\deftypefunargs{#4}%
5396
% @deftypemethod CLASS TYPE METHOD ARG...
5398
\def\deftypemethod{%
5399
\deftypemethparsebody\Edeftypemethod\deftypemethodx\deftypemethodheader}
5401
% #1 is the class name, #2 the data type, #3 the method name, #4 the args.
5402
\def\deftypemethodheader#1#2#3#4{%
5403
\dosubind{fn}{\code{#3}}{\putwordon\ \code{#1}}% entry in function index
5405
\defname{\defheaderxcond#2\relax$.$#3}{\putwordMethodon\ \code{#1}}%
5406
\deftypefunargs{#4}%
5410
% @deftypeivar CLASS TYPE VARNAME
5413
\deftypemethparsebody\Edeftypeivar\deftypeivarx\deftypeivarheader}
5415
% #1 is the class name, #2 the data type, #3 the variable name.
5416
\def\deftypeivarheader#1#2#3{%
5417
\dosubind{vr}{\code{#3}}{\putwordof\ \code{#1}}% entry in variable index
5419
\defname{\defheaderxcond#2\relax$.$#3}
5420
{\putwordInstanceVariableof\ \code{#1}}%
5425
% @defmethod == @defop Method
5427
\def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader}
5429
% #1 is the class name, #2 the method name, #3 the args.
5430
\def\defmethodheader#1#2#3{%
5431
\dosubind{fn}{\code{#2}}{\putwordon\ \code{#1}}% entry in function index
5433
\defname{#2}{\putwordMethodon\ \code{#1}}%
5438
% @defcv {Class Option} foo-class foo-flag
5440
\def\defcv #1 {\def\defcvtype{#1}%
5441
\defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype}
5443
\def\defcvarheader #1#2#3{%
5444
\dosubind{vr}{\code{#2}}{\putwordof\ \code{#1}}% variable index entry
5446
\defname{#2}{\defcvtype\ \putwordof\ #1}%
5451
% @defivar CLASS VARNAME == @defcv {Instance Variable} CLASS VARNAME
5453
\def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader}
5455
\def\defivarheader#1#2#3{%
5456
\dosubind{vr}{\code{#2}}{\putwordof\ \code{#1}}% entry in var index
5458
\defname{#2}{\putwordInstanceVariableof\ #1}%
5464
% First, define the processing that is wanted for arguments of @defvar.
5465
% This is actually simple: just print them in roman.
5466
% This must expand the args and terminate the paragraph they make up
5467
\def\defvarargs #1{\normalparens #1%
5468
\defargscommonending
5471
% @defvr Counter foo-count
5473
\def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader}
5475
\def\defvrheader #1#2#3{\doind {vr}{\code{#2}}%
5476
\begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup}
5478
% @defvar == @defvr Variable
5480
\def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader}
5482
\def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
5483
\begingroup\defname {#1}{\putwordDefvar}%
5484
\defvarargs {#2}\endgroup %
5487
% @defopt == @defvr {User Option}
5489
\def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader}
5491
\def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
5492
\begingroup\defname {#1}{\putwordDefopt}%
5493
\defvarargs {#2}\endgroup %
5496
% @deftypevar int foobar
5498
\def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader}
5500
% #1 is the data type. #2 is the name, perhaps followed by text that
5501
% is actually part of the data type, which should not be put into the index.
5502
\def\deftypevarheader #1#2{%
5503
\dovarind#2 \relax% Make entry in variables index
5504
\begingroup\defname {\defheaderxcond#1\relax$.$#2}{\putwordDeftypevar}%
5505
\defargscommonending
5507
\def\dovarind#1 #2\relax{\doind{vr}{\code{#1}}}
5509
% @deftypevr {Global Flag} int enable
5511
\def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader}
5513
\def\deftypevrheader #1#2#3{\dovarind#3 \relax%
5514
\begingroup\defname {\defheaderxcond#2\relax$.$#3}{#1}
5515
\defargscommonending
5519
% Args are printed in bold, a slight difference from @defvar.
5521
\def\deftpargs #1{\bf \defvarargs{#1}}
5523
% @deftp Class window height width ...
5525
\def\deftp{\deftpparsebody\Edeftp\deftpx\deftpheader}
5527
\def\deftpheader #1#2#3{\doind {tp}{\code{#2}}%
5528
\begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup}
5530
% These definitions are used if you use @defunx (etc.)
5531
% anywhere other than immediately after a @defun or @defunx.
5533
\def\defcvx#1 {\errmessage{@defcvx in invalid context}}
5534
\def\deffnx#1 {\errmessage{@deffnx in invalid context}}
5535
\def\defivarx#1 {\errmessage{@defivarx in invalid context}}
5536
\def\defmacx#1 {\errmessage{@defmacx in invalid context}}
5537
\def\defmethodx#1 {\errmessage{@defmethodx in invalid context}}
5538
\def\defoptx #1 {\errmessage{@defoptx in invalid context}}
5539
\def\defopx#1 {\errmessage{@defopx in invalid context}}
5540
\def\defspecx#1 {\errmessage{@defspecx in invalid context}}
5541
\def\deftpx#1 {\errmessage{@deftpx in invalid context}}
5542
\def\deftypefnx#1 {\errmessage{@deftypefnx in invalid context}}
5543
\def\deftypefunx#1 {\errmessage{@deftypefunx in invalid context}}
5544
\def\deftypeivarx#1 {\errmessage{@deftypeivarx in invalid context}}
5545
\def\deftypemethodx#1 {\errmessage{@deftypemethodx in invalid context}}
5546
\def\deftypeopx#1 {\errmessage{@deftypeopx in invalid context}}
5547
\def\deftypevarx#1 {\errmessage{@deftypevarx in invalid context}}
5548
\def\deftypevrx#1 {\errmessage{@deftypevrx in invalid context}}
5549
\def\defunx#1 {\errmessage{@defunx in invalid context}}
5550
\def\defvarx#1 {\errmessage{@defvarx in invalid context}}
5551
\def\defvrx#1 {\errmessage{@defvrx in invalid context}}
5417
\infirstlevel \bfafterword
5422
\global\advance\parencount by -1
5425
\newcount\brackcount
5427
\global\advance\brackcount by 1
5432
\global\advance\brackcount by -1
5435
\def\checkparencounts{%
5436
\ifnum\parencount=0 \else \badparencount \fi
5437
\ifnum\brackcount=0 \else \badbrackcount \fi
5439
\def\badparencount{%
5440
\errmessage{Unbalanced parentheses in @def}%
5441
\global\parencount=0
5443
\def\badbrackcount{%
5444
\errmessage{Unbalanced square braces in @def}%
5445
\global\brackcount=0
5554
5449
\message{macros,}
6368
% @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables,
6369
% etc. We don't actually implement floating yet, we always include the
6370
% float "here". But it seemed the best name for the future.
6372
\envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish}
6374
% There may be a space before second and/or third parameter; delete it.
6375
\def\eatcommaspace#1, {#1,}
6377
% #1 is the optional FLOATTYPE, the text label for this float, typically
6378
% "Figure", "Table", "Example", etc. Can't contain commas. If omitted,
6379
% this float will not be numbered and cannot be referred to.
6381
% #2 is the optional xref label. Also must be present for the float to
6384
% #3 is the optional positioning argument; for now, it is ignored. It
6385
% will somehow specify the positions allowed to float to (here, top, bottom).
6387
% We keep a separate counter for each FLOATTYPE, which we reset at each
6388
% chapter-level command.
6389
\let\resetallfloatnos=\empty
6391
\def\dofloat#1,#2,#3,#4\finish{%
6392
\let\thiscaption=\empty
6393
\let\thisshortcaption=\empty
6395
% don't lose footnotes inside @float.
6397
% BEWARE: when the floats start float, we have to issue warning whenever an
6398
% insert appears inside a float which could possibly float. --kasal, 26may04
6402
% We can't be used inside a paragraph.
6407
\def\floatlabel{#2}%
6408
\def\floatloc{#3}% we do nothing with this yet.
6410
\ifx\floattype\empty
6411
\let\safefloattype=\empty
6414
% the floattype might have accents or other special characters,
6415
% but we need to use it in a control sequence name.
6418
\xdef\safefloattype{\floattype}%
6422
% If label is given but no type, we handle that as the empty type.
6423
\ifx\floatlabel\empty \else
6424
% We want each FLOATTYPE to be numbered separately (Figure 1,
6425
% Table 1, Figure 2, ...). (And if no label, no number.)
6427
\expandafter\getfloatno\csname\safefloattype floatno\endcsname
6428
\global\advance\floatno by 1
6431
% This magic value for \thissection is output by \setref as the
6432
% XREFLABEL-title value. \xrefX uses it to distinguish float
6433
% labels (which have a completely different output format) from
6434
% node and anchor labels. And \xrdef uses it to construct the
6437
\edef\thissection{\floatmagic=\safefloattype}%
6438
\setref{\floatlabel}{Yfloat}%
6442
% start with \parskip glue, I guess.
6445
% Don't suppress indentation if a float happens to start a section.
6446
\restorefirstparagraphindent
6449
% we have these possibilities:
6450
% @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap
6451
% @float Foo,lbl & no caption: Foo 1.1
6452
% @float Foo & @caption{Cap}: Foo: Cap
6453
% @float Foo & no caption: Foo
6454
% @float ,lbl & Caption{Cap}: 1.1: Cap
6455
% @float ,lbl & no caption: 1.1
6456
% @float & @caption{Cap}: Cap
6457
% @float & no caption:
6460
\let\floatident = \empty
6462
% In all cases, if we have a float type, it comes first.
6463
\ifx\floattype\empty \else \def\floatident{\floattype}\fi
6465
% If we have an xref label, the number comes next.
6466
\ifx\floatlabel\empty \else
6467
\ifx\floattype\empty \else % if also had float type, need tie first.
6468
\appendtomacro\floatident{\tie}%
6471
\appendtomacro\floatident{\chaplevelprefix\the\floatno}%
6474
% Start the printed caption with what we've constructed in
6475
% \floatident, but keep it separate; we need \floatident again.
6476
\let\captionline = \floatident
6478
\ifx\thiscaption\empty \else
6479
\ifx\floatident\empty \else
6480
\appendtomacro\captionline{: }% had ident, so need a colon between
6484
\appendtomacro\captionline{\scanexp\thiscaption}%
6487
% If we have anything to print, print it, with space before.
6488
% Eventually this needs to become an \insert.
6489
\ifx\captionline\empty \else
6493
% Space below caption.
6497
% If have an xref label, write the list of floats info. Do this
6498
% after the caption, to avoid chance of it being a breakpoint.
6499
\ifx\floatlabel\empty \else
6500
% Write the text that goes in the lof to the aux file as
6501
% \floatlabel-lof. Besides \floatident, we include the short
6502
% caption if specified, else the full caption if specified, else nothing.
6504
\atdummies \turnoffactive \otherbackslash
6505
% since we read the caption text in the macro world, where ^^M
6506
% is turned into a normal character, we have to scan it back, so
6507
% we don't write the literal three characters "^^M" into the aux file.
6509
\xdef\noexpand\gtemp{%
6510
\ifx\thisshortcaption\empty
6517
\immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident
6518
\ifx\gtemp\empty \else : \gtemp \fi}}%
6521
\egroup % end of \vtop
6523
% place the captured inserts
6525
% BEWARE: when the floats start float, we have to issue warning whenever an
6526
% insert appears inside a float which could possibly float. --kasal, 26may04
6531
% Append the tokens #2 to the definition of macro #1, not expanding either.
6533
\def\appendtomacro#1#2{%
6534
\expandafter\def\expandafter#1\expandafter{#1#2}%
6537
% @caption, @shortcaption
6539
\def\caption{\docaption\thiscaption}
6540
\def\shortcaption{\docaption\thisshortcaption}
6541
\def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption}
6542
\def\defcaption#1#2{\egroup \def#1{#2}}
6544
% The parameter is the control sequence identifying the counter we are
6545
% going to use. Create it if it doesn't exist and assign it to \floatno.
6548
% Haven't seen this figure type before.
6549
\csname newcount\endcsname #1%
6551
% Remember to reset this floatno at the next chap.
6552
\expandafter\gdef\expandafter\resetallfloatnos
6553
\expandafter{\resetallfloatnos #1=0 }%
6558
% \setref calls this to get the XREFLABEL-snt value. We want an @xref
6559
% to the FLOATLABEL to expand to "Figure 3.1". We call \setref when we
6560
% first read the @float command.
6562
\def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}%
6564
% Magic string used for the XREFLABEL-title value, so \xrefX can
6565
% distinguish floats from other xref types.
6566
\def\floatmagic{!!float!!}
6568
% #1 is the control sequence we are passed; we expand into a conditional
6569
% which is true if #1 represents a float ref. That is, the magic
6570
% \thissection value which we \setref above.
6572
\def\iffloat#1{\expandafter\doiffloat#1==\finish}
6574
% #1 is (maybe) the \floatmagic string. If so, #2 will be the
6575
% (safe) float type for this float. We set \iffloattype to #2.
6577
\def\doiffloat#1=#2=#3\finish{%
6579
\def\iffloattype{#2}%
6580
\ifx\temp\floatmagic
6583
% @listoffloats FLOATTYPE - print a list of floats like a table of contents.
6585
\parseargdef\listoffloats{%
6586
\def\floattype{#1}% floattype
6588
% the floattype might have accents or other special characters,
6589
% but we need to use it in a control sequence name.
6592
\xdef\safefloattype{\floattype}%
6595
% \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE.
6596
\expandafter\ifx\csname floatlist\safefloattype\endcsname \relax
6598
% if the user said @listoffloats foo but never @float foo.
6599
\message{\linenumber No `\safefloattype' floats to list.}%
6603
\leftskip=\tocindent % indent these entries like a toc
6604
\let\do=\listoffloatsdo
6605
\csname floatlist\safefloattype\endcsname
6610
% This is called on each entry in a list of floats. We're passed the
6611
% xref label, in the form LABEL-title, which is how we save it in the
6612
% aux file. We strip off the -title and look up \XRLABEL-lof, which
6613
% has the text we're supposed to typeset here.
6615
% Figures without xref labels will not be included in the list (since
6616
% they won't appear in the aux file).
6618
\def\listoffloatsdo#1{\listoffloatsdoentry#1\finish}
6619
\def\listoffloatsdoentry#1-title\finish{{%
6620
% Can't fully expand XR#1-lof because it can contain anything. Just
6621
% pass the control sequence. On the other hand, XR#1-pg is just the
6622
% page number, and we want to fully expand that so we can get a link
6624
\toksA = \expandafter{\csname XR#1-lof\endcsname}%
6626
% use the same \entry macro we use to generate the TOC and index.
6627
\edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}%
6375
6631
\message{localization,}