309
395
% the input line (except we remove a trailing comment). #1 should be a
310
396
% macro which expects an ordinary undelimited TeX argument.
398
\def\parsearg{\parseargusing{}}
399
\def\parseargusing#1#2{%
316
\futurelet\temp\parseargx
319
% If the next token is an obeyed space (from an @example environment or
320
% the like), remove it and recurse. Otherwise, we're done.
322
% \obeyedspace is defined far below, after the definition of \sepspaces.
323
\ifx\obeyedspace\temp
324
\expandafter\parseargdiscardspace
326
\expandafter\parseargline
330
% Remove a single space (as the delimiter token to the macro call).
332
\gdef\parseargdiscardspace {\futurelet\temp\parseargx}}
405
\parseargline\empty% Insert the \empty token, see \finishparsearg below.
335
409
\gdef\parseargline#1^^M{%
336
410
\endgroup % End of the group started in \parsearg.
338
% First remove any @c comment, then any @comment.
339
% Result of each macro is put in \toks0.
340
\argremovec #1\c\relax %
341
\expandafter\argremovecomment \the\toks0 \comment\relax %
343
% Call the caller's macro, saved as \next in \parsearg.
344
\expandafter\next\expandafter{\the\toks0}%
411
\argremovecomment #1\comment\ArgTerm%
348
% Since all \c{,omment} does is throw away the argument, we can let TeX
349
% do that for us. The \relax here is matched by the \relax in the call
350
% in \parseargline; it could be more or less anything, its purpose is
351
% just to delimit the argument to the \c.
352
\def\argremovec#1\c#2\relax{\toks0 = {#1}}
353
\def\argremovecomment#1\comment#2\relax{\toks0 = {#1}}
415
% First remove any @comment, then any @c comment.
416
\def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm}
417
\def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
355
% \argremovec{,omment} might leave us with trailing spaces, though; e.g.,
419
% Each occurence of `\^^M' or `<space>\^^M' is replaced by a single space.
421
% \argremovec might leave us with trailing space, e.g.,
356
422
% @end itemize @c foo
357
% will have two active spaces as part of the argument with the
358
% `itemize'. Here we remove all active spaces from #1, and assign the
361
% This loses if there are any *other* active characters besides spaces
362
% in the argument -- _ ^ +, for example -- since they get expanded.
363
% Fortunately, Texinfo does not define any such commands. (If it ever
364
% does, the catcode of the characters in questionwill have to be changed
365
% here.) But this means we cannot call \removeactivespaces as part of
366
% \argremovec{,omment}, since @c uses \parsearg, and thus the argument
367
% that \parsearg gets might well have any character at all in it.
369
\def\removeactivespaces#1{%
373
\global\toks0 = \expandafter{\temp}%
377
% Change the active space to expand to nothing.
423
% This space token undergoes the same procedure and is eventually removed
424
% by \finishparsearg.
426
\def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M}
427
\def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M}
428
\def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{%
431
% Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp:
432
\let\temp\finishparsearg
434
\let\temp\argcheckspaces
436
% Put the space token in:
440
% If a _delimited_ argument is enclosed in braces, they get stripped; so
441
% to get _exactly_ the rest of the line, we had to prevent such situation.
442
% We prepended an \empty token at the very beginning and we expand it now,
443
% just before passing the control to \argtorun.
444
% (Similarily, we have to think about #3 of \argcheckspacesY above: it is
445
% either the null string, or it ends with \^^M---thus there is no danger
446
% that a pair of braces would be stripped.
448
% But first, we have to remove the trailing space token.
450
\def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}}
452
% \parseargdef\foo{...}
453
% is roughly equivalent to
454
% \def\foo{\parsearg\Xfoo}
457
% Actually, I use \csname\string\foo\endcsname, ie. \\foo, as it is my
458
% favourite TeX trick. --kasal, 16nov03
461
\expandafter \doparseargdef \csname\string#1\endcsname #1%
463
\def\doparseargdef#1#2{%
468
% Several utility definitions with active space:
381
\gdef\ignoreactivespaces{\obeyspaces\let =\empty}
473
% Make each space character in the input produce a normal interword
474
% space in the output. Don't allow a line break at this space, as this
475
% is used only in environments like @example, where each line of input
476
% should produce a line of output anyway.
478
\gdef\sepspaces{\obeyspaces\let =\tie}
480
% If an index command is used in an @example environment, any spaces
481
% therein should become regular spaces in the raw index file, not the
482
% expansion of \tie (\leavevmode \penalty \@M \ ).
483
\gdef\unsepspaces{\let =\space}
385
487
\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
387
%% These are used to keep @begin/@end levels from running away
388
%% Call \inENV within environments (after a \begingroup)
389
\newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi}
391
\ifENV\errmessage{Still within an environment; press RETURN to continue}
392
\endgroup\fi} % This is not perfect, but it should reduce lossage
394
% @begin foo is the same as @foo, for now.
489
% Define the framework for environments in texinfo.tex. It's used like this:
494
% It's the responsibility of \envdef to insert \begingroup before the
495
% actual body; @end closes the group after calling \Efoo. \envdef also
496
% defines \thisenv, so the current environment is known; @end checks
497
% whether the environment name matches. The \checkenv macro can also be
498
% used to check whether the current environment is the one expected.
500
% Non-false conditionals (@iftex, @ifset) don't fit into this, so they
501
% are not treated as enviroments; they don't open a group. (The
502
% implementation of @end takes care not to call \endgroup in this
506
% At runtime, environments start with this:
507
\def\startenvironment#1{\begingroup\def\thisenv{#1}}
511
% ... but they get defined via ``\envdef\foo{...}'':
512
\long\def\envdef#1#2{\def#1{\startenvironment#1#2}}
513
\def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}}
515
% Check whether we're in the right environment:
524
% Evironment mismatch, #1 expected:
527
\errmessage{This command can appear only \inenvironment\temp,
528
not \inenvironment\thisenv}%
530
\def\inenvironment#1{%
532
out of any environment%
534
in environment \expandafter\string#1%
538
% @end foo executes the definition of \Efoo.
539
% But first, it executes a specialized version of \checkenv
542
\if 1\csname iscond.#1\endcsname
544
% The general wording of \badenverr may not be ideal, but... --kasal, 06nov03
545
\expandafter\checkenv\csname#1\endcsname
546
\csname E#1\endcsname
395
551
\newhelp\EMsimple{Press RETURN to continue.}
397
\outer\def\begin{\parsearg\beginxxx}
400
\expandafter\ifx\csname #1\endcsname\relax
401
{\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else
402
\csname #1\endcsname\fi}
404
% @end foo executes the definition of \Efoo.
406
\def\end{\parsearg\endxxx}
408
\removeactivespaces{#1}%
409
\edef\endthing{\the\toks0}%
411
\expandafter\ifx\csname E\endthing\endcsname\relax
412
\expandafter\ifx\csname \endthing\endcsname\relax
413
% There's no \foo, i.e., no ``environment'' foo.
415
\errmessage{Undefined command `@end \endthing'}%
417
\unmatchedenderror\endthing
420
% Everything's ok; the right environment has been started.
421
\csname E\endthing\endcsname
425
% There is an environment #1, but it hasn't been started. Give an error.
427
\def\unmatchedenderror#1{%
429
\errmessage{This `@end #1' doesn't have a matching `@#1'}%
432
% Define the control sequence \E#1 to give an unmatched @end error.
434
\def\defineunmatchedend#1{%
435
\expandafter\def\csname E#1\endcsname{\unmatchedenderror{#1}}%
439
% Single-spacing is done by various environments (specifically, in
440
% \nonfillstart and \quotations).
441
\newskip\singlespaceskip \singlespaceskip = 12.5pt
443
% Why was this kern here? It messes up equalizing space above and below
444
% environments. --karl, 6may93
445
%{\advance \baselineskip by -\singlespaceskip
446
%\kern \baselineskip}%
447
\setleading\singlespaceskip
450
554
%% Simple single-character @ commands
1264
1645
\setfont\ssecttsl\ttslshape{10}{1315}
1265
1646
\setfont\ssecsf\sfbshape{12}{\magstephalf}
1266
1647
\let\ssecbf\ssecrm
1267
\setfont\ssecsc\scbshape{10}{\magstep1}
1648
\setfont\ssecsc\scbshape{10}{1315}
1268
1649
\font\sseci=cmmi12 scaled \magstephalf
1269
1650
\font\ssecsy=cmsy10 scaled 1315
1270
% The smallcaps and symbol fonts should actually be scaled \magstep1.5,
1271
% but that is not a standard magnification.
1652
% Reduced fonts for @acro in text (10pt).
1653
\def\reducednominalsize{10pt}
1654
\setfont\reducedrm\rmshape{10}{1000}
1655
\setfont\reducedtt\ttshape{10}{1000}
1656
\setfont\reducedbf\bfshape{10}{1000}
1657
\setfont\reducedit\itshape{10}{1000}
1658
\setfont\reducedsl\slshape{10}{1000}
1659
\setfont\reducedsf\sfshape{10}{1000}
1660
\setfont\reducedsc\scshape{10}{1000}
1661
\setfont\reducedttsl\ttslshape{10}{1000}
1662
\font\reducedi=cmmi10
1663
\font\reducedsy=cmsy10
1665
% reset the current fonts
1668
} % end of 11pt text font size definitions
1671
% Definitions to make the main text be 10pt Computer Modern, with
1672
% section, chapter, etc., sizes following suit. This is for the GNU
1673
% Press printing of the Emacs 22 manual. Maybe other manuals in the
1674
% future. Used with @smallbook, which sets the leading to 12pt.
1676
\def\definetextfontsizex{%
1677
% Text fonts (10pt).
1678
\def\textnominalsize{10pt}
1679
\edef\mainmagstep{1000}
1680
\setfont\textrm\rmshape{10}{\mainmagstep}
1681
\setfont\texttt\ttshape{10}{\mainmagstep}
1682
\setfont\textbf\bfshape{10}{\mainmagstep}
1683
\setfont\textit\itshape{10}{\mainmagstep}
1684
\setfont\textsl\slshape{10}{\mainmagstep}
1685
\setfont\textsf\sfshape{10}{\mainmagstep}
1686
\setfont\textsc\scshape{10}{\mainmagstep}
1687
\setfont\textttsl\ttslshape{10}{\mainmagstep}
1688
\font\texti=cmmi10 scaled \mainmagstep
1689
\font\textsy=cmsy10 scaled \mainmagstep
1691
% A few fonts for @defun names and args.
1692
\setfont\defbf\bfshape{10}{\magstephalf}
1693
\setfont\deftt\ttshape{10}{\magstephalf}
1694
\setfont\defttsl\ttslshape{10}{\magstephalf}
1695
\def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf}
1697
% Fonts for indices, footnotes, small examples (9pt).
1698
\def\smallnominalsize{9pt}
1699
\setfont\smallrm\rmshape{9}{1000}
1700
\setfont\smalltt\ttshape{9}{1000}
1701
\setfont\smallbf\bfshape{10}{900}
1702
\setfont\smallit\itshape{9}{1000}
1703
\setfont\smallsl\slshape{9}{1000}
1704
\setfont\smallsf\sfshape{9}{1000}
1705
\setfont\smallsc\scshape{10}{900}
1706
\setfont\smallttsl\ttslshape{10}{900}
1710
% Fonts for small examples (8pt).
1711
\def\smallernominalsize{8pt}
1712
\setfont\smallerrm\rmshape{8}{1000}
1713
\setfont\smallertt\ttshape{8}{1000}
1714
\setfont\smallerbf\bfshape{10}{800}
1715
\setfont\smallerit\itshape{8}{1000}
1716
\setfont\smallersl\slshape{8}{1000}
1717
\setfont\smallersf\sfshape{8}{1000}
1718
\setfont\smallersc\scshape{10}{800}
1719
\setfont\smallerttsl\ttslshape{10}{800}
1720
\font\smalleri=cmmi8
1721
\font\smallersy=cmsy8
1723
% Fonts for title page (20.4pt):
1724
\def\titlenominalsize{20pt}
1725
\setfont\titlerm\rmbshape{12}{\magstep3}
1726
\setfont\titleit\itbshape{10}{\magstep4}
1727
\setfont\titlesl\slbshape{10}{\magstep4}
1728
\setfont\titlett\ttbshape{12}{\magstep3}
1729
\setfont\titlettsl\ttslshape{10}{\magstep4}
1730
\setfont\titlesf\sfbshape{17}{\magstep1}
1731
\let\titlebf=\titlerm
1732
\setfont\titlesc\scbshape{10}{\magstep4}
1733
\font\titlei=cmmi12 scaled \magstep3
1734
\font\titlesy=cmsy10 scaled \magstep4
1735
\def\authorrm{\secrm}
1736
\def\authortt{\sectt}
1738
% Chapter fonts (14.4pt).
1739
\def\chapnominalsize{14pt}
1740
\setfont\chaprm\rmbshape{12}{\magstep1}
1741
\setfont\chapit\itbshape{10}{\magstep2}
1742
\setfont\chapsl\slbshape{10}{\magstep2}
1743
\setfont\chaptt\ttbshape{12}{\magstep1}
1744
\setfont\chapttsl\ttslshape{10}{\magstep2}
1745
\setfont\chapsf\sfbshape{12}{\magstep1}
1747
\setfont\chapsc\scbshape{10}{\magstep2}
1748
\font\chapi=cmmi12 scaled \magstep1
1749
\font\chapsy=cmsy10 scaled \magstep2
1751
% Section fonts (12pt).
1752
\def\secnominalsize{12pt}
1753
\setfont\secrm\rmbshape{12}{1000}
1754
\setfont\secit\itbshape{10}{\magstep1}
1755
\setfont\secsl\slbshape{10}{\magstep1}
1756
\setfont\sectt\ttbshape{12}{1000}
1757
\setfont\secttsl\ttslshape{10}{\magstep1}
1758
\setfont\secsf\sfbshape{12}{1000}
1760
\setfont\secsc\scbshape{10}{\magstep1}
1762
\font\secsy=cmsy10 scaled \magstep1
1764
% Subsection fonts (10pt).
1765
\def\ssecnominalsize{10pt}
1766
\setfont\ssecrm\rmbshape{10}{1000}
1767
\setfont\ssecit\itbshape{10}{1000}
1768
\setfont\ssecsl\slbshape{10}{1000}
1769
\setfont\ssectt\ttbshape{10}{1000}
1770
\setfont\ssecttsl\ttslshape{10}{1000}
1771
\setfont\ssecsf\sfbshape{10}{1000}
1773
\setfont\ssecsc\scbshape{10}{1000}
1777
% Reduced fonts for @acro in text (9pt).
1778
\def\reducednominalsize{9pt}
1779
\setfont\reducedrm\rmshape{9}{1000}
1780
\setfont\reducedtt\ttshape{9}{1000}
1781
\setfont\reducedbf\bfshape{10}{900}
1782
\setfont\reducedit\itshape{9}{1000}
1783
\setfont\reducedsl\slshape{9}{1000}
1784
\setfont\reducedsf\sfshape{9}{1000}
1785
\setfont\reducedsc\scshape{10}{900}
1786
\setfont\reducedttsl\ttslshape{10}{900}
1787
\font\reducedi=cmmi9
1788
\font\reducedsy=cmsy9
1790
% reduce space between paragraphs
1791
\divide\parskip by 2
1793
% reset the current fonts
1796
} % end of 10pt text font size definitions
1799
% We provide the user-level command
1801
% (or 11) to redefine the text font size. pt is assumed.
1806
\parseargdef\fonttextsize{%
1807
\def\textsizearg{#1}%
1808
\wlog{doing @fonttextsize \textsizearg}%
1810
% Set \globaldefs so that documents can use this inside @tex, since
1811
% makeinfo 4.8 does not support it, but we need it nonetheless.
1813
\begingroup \globaldefs=1
1814
\ifx\textsizearg\xword \definetextfontsizex
1815
\else \ifx\textsizearg\xiword \definetextfontsizexi
1818
\errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'}
1273
1824
% In order for the font changes to affect most math symbols and letters,
1274
1825
% we have to define the \textfont of the standard families. Since
2336
3105
\message{conditionals,}
2337
% Prevent errors for section commands.
2338
% Used in @ignore and in failing conditionals.
2339
\def\ignoresections{%
2341
\let\unnumbered=\relax
2343
\let\unnumberedsec=\relax
2344
\let\unnumberedsection=\relax
2345
\let\unnumberedsubsec=\relax
2346
\let\unnumberedsubsection=\relax
2347
\let\unnumberedsubsubsec=\relax
2348
\let\unnumberedsubsubsection=\relax
2351
\let\subsubsec=\relax
2352
\let\subsection=\relax
2353
\let\subsubsection=\relax
2354
\let\appendix=\relax
2355
\let\appendixsec=\relax
2356
\let\appendixsection=\relax
2357
\let\appendixsubsec=\relax
2358
\let\appendixsubsection=\relax
2359
\let\appendixsubsubsec=\relax
2360
\let\appendixsubsubsection=\relax
2361
\let\contents=\relax
2362
\let\smallbook=\relax
2363
\let\titlepage=\relax
2366
% Used in nested conditionals, where we have to parse the Texinfo source
2367
% and so want to turn off most commands, in case they are used
2370
\def\ignoremorecommands{%
2371
\let\defcodeindex = \relax
2374
\let\deffnx = \relax
2375
\let\defindex = \relax
2376
\let\defivar = \relax
2377
\let\defmac = \relax
2378
\let\defmethod = \relax
2380
\let\defopt = \relax
2381
\let\defspec = \relax
2383
\let\deftypefn = \relax
2384
\let\deftypefun = \relax
2385
\let\deftypeivar = \relax
2386
\let\deftypeop = \relax
2387
\let\deftypevar = \relax
2388
\let\deftypevr = \relax
2390
\let\defvar = \relax
2394
\let\printindex = \relax
2396
\let\settitle = \relax
2397
\let\setchapternewpage = \relax
2398
\let\setchapterstyle = \relax
2399
\let\everyheading = \relax
2400
\let\evenheading = \relax
2401
\let\oddheading = \relax
2402
\let\everyfooting = \relax
2403
\let\evenfooting = \relax
2404
\let\oddfooting = \relax
2405
\let\headings = \relax
2406
\let\include = \relax
2407
\let\lowersections = \relax
2409
\let\raisesections = \relax
2416
% Ignore @ignore, @ifhtml, @ifinfo, @ifplaintext, @ifnottex, @html, @menu,
2417
% @direntry, and @documentdescription.
2419
\def\ignore{\doignore{ignore}}
3107
% @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext,
3108
% @ifnotxml always succeed. They currently do nothing; we don't
3109
% attempt to check whether the conditionals are properly nested. But we
3110
% have to remember that they are conditionals, so that @end doesn't
3111
% attempt to close an environment group.
3114
\expandafter\let\csname #1\endcsname = \relax
3115
\expandafter\let\csname iscond.#1\endcsname = 1
3118
\makecond{ifnotdocbook}
3119
\makecond{ifnothtml}
3120
\makecond{ifnotinfo}
3121
\makecond{ifnotplaintext}
3124
% Ignore @ignore, @ifhtml, @ifinfo, and the like.
3126
\def\direntry{\doignore{direntry}}
3127
\def\documentdescription{\doignore{documentdescription}}
3128
\def\docbook{\doignore{docbook}}
3129
\def\html{\doignore{html}}
3130
\def\ifdocbook{\doignore{ifdocbook}}
2420
3131
\def\ifhtml{\doignore{ifhtml}}
2421
3132
\def\ifinfo{\doignore{ifinfo}}
3133
\def\ifnottex{\doignore{ifnottex}}
2422
3134
\def\ifplaintext{\doignore{ifplaintext}}
2423
\def\ifnottex{\doignore{ifnottex}}
2424
\def\html{\doignore{html}}
3135
\def\ifxml{\doignore{ifxml}}
3136
\def\ignore{\doignore{ignore}}
2425
3137
\def\menu{\doignore{menu}}
2426
\def\direntry{\doignore{direntry}}
2427
\def\documentdescription{\doignore{documentdescription}}
2428
\def\documentdescriptionword{documentdescription}
2430
% @dircategory CATEGORY -- specify a category of the dir file
2431
% which this file should belong to. Ignore this in TeX.
2432
\let\dircategory = \comment
2434
% Ignore text until a line `@end #1'.
3138
\def\xml{\doignore{xml}}
3140
% Ignore text until a line `@end #1', keeping track of nested conditionals.
3142
% A count to remember the depth of nesting.
3143
\newcount\doignorecount
2436
3145
\def\doignore#1{\begingroup
2437
% Don't complain about control sequences we have declared \outer.
2440
% Define a command to swallow text until we reach `@end #1'.
2441
% This @ is a catcode 12 token (that is the normal catcode of @ in
2442
% this texinfo.tex file). We change the catcode of @ below to match.
2443
\long\def\doignoretext##1@end #1{\enddoignore}%
3146
% Scan in ``verbatim'' mode:
3148
\catcode`\@ = \other
3149
\catcode`\{ = \other
3150
\catcode`\} = \other
2445
3152
% Make sure that spaces turn into tokens that match what \doignoretext wants.
2448
% Ignore braces, too, so mismatched braces don't cause trouble.
2452
% We must not have @c interpreted as a control sequence.
2455
\def\ignoreword{#1}%
2456
\ifx\ignoreword\documentdescriptionword
2457
% The c kludge breaks documentdescription, since
2458
% `documentdescription' contains a `c'. Means not everything will
2459
% be ignored inside @documentdescription, but oh well...
2461
% Make the letter c a comment character so that the rest of the line
2462
% will be ignored. This way, the document can have (for example)
2464
% and the @end ifinfo will be properly ignored.
2465
% (We've just changed @ to catcode 12.)
2469
% And now expand the command defined above.
2473
% What we do to finish off ignored text.
2475
\def\enddoignore{\endgroup\ignorespaces}%
2477
\newif\ifwarnedobs\warnedobsfalse
2479
\ifwarnedobs\relax\else
2480
% We need to warn folks that they may have trouble with TeX 3.0.
2481
% This uses \immediate\write16 rather than \message to get newlines.
2482
\immediate\write16{}
2483
\immediate\write16{WARNING: for users of Unix TeX 3.0!}
2484
\immediate\write16{This manual trips a bug in TeX version 3.0 (tex hangs).}
2485
\immediate\write16{If you are running another version of TeX, relax.}
2486
\immediate\write16{If you are running Unix TeX 3.0, kill this TeX process.}
2487
\immediate\write16{ Then upgrade your TeX installation if you can.}
2488
\immediate\write16{ (See ftp://ftp.gnu.org/pub/gnu/TeX.README.)}
2489
\immediate\write16{If you are stuck with version 3.0, run the}
2490
\immediate\write16{ script ``tex3patch'' from the Texinfo distribution}
2491
\immediate\write16{ to use a workaround.}
2492
\immediate\write16{}
2493
\global\warnedobstrue
2497
% **In TeX 3.0, setting text in \nullfont hangs tex. For a
2498
% workaround (which requires the file ``dummy.tfm'' to be installed),
2499
% uncomment the following line:
2500
%%%%%\font\nullfont=dummy\let\obstexwarn=\relax
2502
% Ignore text, except that we keep track of conditional commands for
2503
% purposes of nesting, up to an `@end #1' command.
2505
\def\nestedignore#1{%
2507
% We must actually expand the ignored text to look for the @end
2508
% command, so that nested ignore constructs work. Thus, we put the
2509
% text into a \vbox and then do nothing with the result. To minimize
2510
% the change of memory overflow, we follow the approach outlined on
2511
% page 401 of the TeXbook: make the current font be a dummy font.
2513
\setbox0 = \vbox\bgroup
2514
% Don't complain about control sequences we have declared \outer.
2517
% Define `@end #1' to end the box, which will in turn undefine the
2518
% @end command again.
2519
\expandafter\def\csname E#1\endcsname{\egroup\ignorespaces}%
2521
% We are going to be parsing Texinfo commands. Most cause no
2522
% trouble when they are used incorrectly, but some commands do
2523
% complicated argument parsing or otherwise get confused, so we
2526
% We can't do anything about stray @-signs, unfortunately;
2527
% they'll produce `undefined control sequence' errors.
2530
% Set the current font to be \nullfont, a TeX primitive, and define
2531
% all the font commands to also use \nullfont. We don't use
2532
% dummy.tfm, as suggested in the TeXbook, because not all sites
2533
% might have that installed. Therefore, math mode will still
2534
% produce output, but that should be an extremely small amount of
2535
% stuff compared to the main input.
2538
\let\tenrm=\nullfont \let\tenit=\nullfont \let\tensl=\nullfont
2539
\let\tenbf=\nullfont \let\tentt=\nullfont \let\smallcaps=\nullfont
2540
\let\tensf=\nullfont
2541
% Similarly for index fonts.
2542
\let\smallrm=\nullfont \let\smallit=\nullfont \let\smallsl=\nullfont
2543
\let\smallbf=\nullfont \let\smalltt=\nullfont \let\smallsc=\nullfont
2544
\let\smallsf=\nullfont
2545
% Similarly for smallexample fonts.
2546
\let\smallerrm=\nullfont \let\smallerit=\nullfont \let\smallersl=\nullfont
2547
\let\smallerbf=\nullfont \let\smallertt=\nullfont \let\smallersc=\nullfont
2548
\let\smallersf=\nullfont
2550
% Don't complain when characters are missing from the fonts.
2551
\tracinglostchars = 0
2553
% Don't bother to do space factor calculations.
2556
% Don't report underfull hboxes.
2559
% Do minimal line-breaking.
2560
\pretolerance = 10000
2562
% Do not execute instructions in @tex
2563
\def\tex{\doignore{tex}}%
2564
% Do not execute macro definitions.
2565
% `c' is a comment character, so the word `macro' will get cut off.
2566
\def\macro{\doignore{ma}}%
3155
% Count number of #1's that we've seen.
3158
% Swallow text until we reach the matching `@end #1'.
3162
{ \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source.
3165
\gdef\dodoignore#1{%
3166
% #1 contains the command name as a string, e.g., `ifinfo'.
3168
% Define a command to find the next `@end #1'.
3169
\long\def\doignoretext##1^^M@end #1{%
3170
\doignoretextyyy##1^^M@#1\_STOP_}%
3172
% And this command to find another #1 command, at the beginning of a
3173
% line. (Otherwise, we would consider a line `@c @ifset', for
3174
% example, to count as an @ifset for nesting.)
3175
\long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}%
3177
% And now expand that command.
3182
\def\doignoreyyy#1{%
3184
\ifx\temp\empty % Nothing found.
3185
\let\next\doignoretextzzz
3186
\else % Found a nested condition, ...
3187
\advance\doignorecount by 1
3188
\let\next\doignoretextyyy % ..., look for another.
3189
% If we're here, #1 ends with ^^M\ifinfo (for example).
3191
\next #1% the token \_STOP_ is present just after this macro.
3194
% We have to swallow the remaining "\_STOP_".
3196
\def\doignoretextzzz#1{%
3197
\ifnum\doignorecount = 0 % We have just found the outermost @end.
3198
\let\next\enddoignore
3199
\else % Still inside a nested condition.
3200
\advance\doignorecount by -1
3201
\let\next\doignoretext % Look for the next @end.
3206
% Finish off ignored text.
3208
% Ignore anything after the last `@end #1'; this matters in verbatim
3209
% environments, where otherwise the newline after an ignored conditional
3210
% would result in a blank line in the output.
3211
\gdef\enddoignore#1^^M{\endgroup\ignorespaces}%
2569
3215
% @set VAR sets the variable VAR to an empty value.
2570
3216
% @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
2784
3404
\def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
2785
3405
\def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
2787
% Take care of texinfo commands likely to appear in an index entry.
2788
% (Must be a way to avoid doing expansion at all, and thus not have to
2789
% laboriously list every single command here.)
3407
% Take care of Texinfo commands that can appear in an index entry.
3408
% Since there are some commands we want to expand, and others we don't,
3409
% we have to laboriously prevent expansion for those that we don't.
2791
3411
\def\indexdummies{%
2793
\def\@{@}% change to @@ when we switch to @ as escape char in aux files.
2794
% Need these in case \tex is in effect and \{ is a \delimiter again.
2795
% But can't use \lbracecmd and \rbracecmd because texindex assumes
2796
% braces and backslashes are used only as delimiters.
2799
\def\_{{\realbackslash _}}%
2800
\normalturnoffactive
2802
% Take care of the plain tex accent commands.
2803
\def\,##1{\realbackslash ,{##1}}%
2804
\def\"{\realbackslash "}%
2805
\def\`{\realbackslash `}%
2806
\def\'{\realbackslash '}%
2807
\def\^{\realbackslash ^}%
2808
\def\~{\realbackslash ~}%
2809
\def\={\realbackslash =}%
2810
\def\b{\realbackslash b}%
2811
\def\c{\realbackslash c}%
2812
\def\d{\realbackslash d}%
2813
\def\u{\realbackslash u}%
2814
\def\v{\realbackslash v}%
2815
\def\H{\realbackslash H}%
2816
\def\dotless##1{\realbackslash dotless {##1}}%
2817
% Take care of the plain tex special European modified letters.
2818
\def\AA{\realbackslash AA}%
2819
\def\AE{\realbackslash AE}%
2820
\def\L{\realbackslash L}%
2821
\def\OE{\realbackslash OE}%
2822
\def\O{\realbackslash O}%
2823
\def\aa{\realbackslash aa}%
2824
\def\ae{\realbackslash ae}%
2825
\def\l{\realbackslash l}%
2826
\def\oe{\realbackslash oe}%
2827
\def\o{\realbackslash o}%
2828
\def\ss{\realbackslash ss}%
2830
% Although these internals commands shouldn't show up, sometimes they do.
2831
\def\bf{\realbackslash bf }%
2832
\def\gtr{\realbackslash gtr}%
2833
\def\hat{\realbackslash hat}%
2834
\def\less{\realbackslash less}%
2835
%\def\rm{\realbackslash rm }%
2836
\def\sf{\realbackslash sf}%
2837
\def\sl{\realbackslash sl }%
2838
\def\tclose##1{\realbackslash tclose {##1}}%
2839
\def\tt{\realbackslash tt}%
2841
\def\b##1{\realbackslash b {##1}}%
2842
\def\i##1{\realbackslash i {##1}}%
2843
\def\sc##1{\realbackslash sc {##1}}%
2844
\def\t##1{\realbackslash t {##1}}%
2845
\def\r##1{\realbackslash r {##1}}%
2847
\def\TeX{\realbackslash TeX}%
2848
\def\acronym##1{\realbackslash acronym {##1}}%
2849
\def\cite##1{\realbackslash cite {##1}}%
2850
\def\code##1{\realbackslash code {##1}}%
2851
\def\command##1{\realbackslash command {##1}}%
2852
\def\dfn##1{\realbackslash dfn {##1}}%
2853
\def\dots{\realbackslash dots }%
2854
\def\emph##1{\realbackslash emph {##1}}%
2855
\def\env##1{\realbackslash env {##1}}%
2856
\def\file##1{\realbackslash file {##1}}%
2857
\def\kbd##1{\realbackslash kbd {##1}}%
2858
\def\key##1{\realbackslash key {##1}}%
2859
\def\math##1{\realbackslash math {##1}}%
2860
\def\option##1{\realbackslash option {##1}}%
2861
\def\samp##1{\realbackslash samp {##1}}%
2862
\def\strong##1{\realbackslash strong {##1}}%
2863
\def\uref##1{\realbackslash uref {##1}}%
2864
\def\url##1{\realbackslash url {##1}}%
2865
\def\var##1{\realbackslash var {##1}}%
2866
\def\w{\realbackslash w }%
2868
% These math commands don't seem likely to be used in index entries.
2869
\def\copyright{\realbackslash copyright}%
2870
\def\equiv{\realbackslash equiv}%
2871
\def\error{\realbackslash error}%
2872
\def\expansion{\realbackslash expansion}%
2873
\def\point{\realbackslash point}%
2874
\def\print{\realbackslash print}%
2875
\def\result{\realbackslash result}%
2877
% Handle some cases of @value -- where the variable name does not
2878
% contain - or _, and the value does not contain any
2879
% (non-fully-expandable) commands.
2880
\let\value = \expandablevalue
2883
% Turn off macro expansion
2887
% If an index command is used in an @example environment, any spaces
2888
% therein should become regular spaces in the raw index file, not the
2889
% expansion of \tie (\leavevmode \penalty \@M \ ).
2891
\gdef\unsepspaces{\obeyspaces\let =\space}}
2893
% \indexnofonts no-ops all font-change commands.
2894
% This is used when outputting the strings to sort the index by.
2895
\def\indexdummyfont#1{#1}
2896
\def\indexdummytex{TeX}
2897
\def\indexdummydots{...}
3412
\escapechar = `\\ % use backslash in output files.
3413
\def\@{@}% change to @@ when we switch to @ as escape char in index files.
3414
\def\ {\realbackslash\space }%
3416
% Need these in case \tex is in effect and \{ is a \delimiter again.
3417
% But can't use \lbracecmd and \rbracecmd because texindex assumes
3418
% braces and backslashes are used only as delimiters.
3422
% I don't entirely understand this, but when an index entry is
3423
% generated from a macro call, the \endinput which \scanmacro inserts
3424
% causes processing to be prematurely terminated. This is,
3425
% apparently, because \indexsorttmp is fully expanded, and \endinput
3426
% is an expandable command. The redefinition below makes \endinput
3427
% disappear altogether for that purpose -- although logging shows that
3428
% processing continues to some further point. On the other hand, it
3429
% seems \endinput does not hurt in the printed index arg, since that
3430
% is still getting written without apparent harm.
3432
% Sample source (mac-idx3.tex, reported by Graham Percival to
3433
% help-texinfo, 22may06):
3434
% @macro funindex {WORD}
3438
% @funindex commtest
3440
% The above is not enough to reproduce the bug, but it gives the flavor.
3442
% Sample whatsit resulting:
3443
% .@write3{\entry{xyz}{@folio }{@code {xyz@endinput }}}
3446
\let\endinput = \empty
3448
% Do the redefinitions.
3452
% For the aux and toc files, @ is the escape character. So we want to
3453
% redefine everything using @ as the escape character (instead of
3454
% \realbackslash, still used for index files). When everything uses @,
3455
% this will be simpler.
3460
\let\{ = \lbraceatcmd
3461
\let\} = \rbraceatcmd
3463
% Do the redefinitions.
3468
% Called from \indexdummies and \atdummies.
3470
\def\commondummies{%
3472
% \definedummyword defines \#1 as \string\#1\space, thus effectively
3473
% preventing its expansion. This is used only for control% words,
3474
% not control letters, because the \space would be incorrect for
3475
% control characters, but is needed to separate the control word
3476
% from whatever follows.
3478
% For control letters, we have \definedummyletter, which omits the
3481
% These can be used both for control words that take an argument and
3482
% those that do not. If it is followed by {arg} in the input, then
3483
% that will dutifully get written to the index (or wherever).
3485
\def\definedummyword ##1{\def##1{\string##1\space}}%
3486
\def\definedummyletter##1{\def##1{\string##1}}%
3487
\let\definedummyaccent\definedummyletter
3489
\commondummiesnofonts
3491
\definedummyletter\_%
3493
% Non-English letters.
3505
\definedummyword\exclamdown
3506
\definedummyword\questiondown
3507
\definedummyword\ordf
3508
\definedummyword\ordm
3510
% Although these internal commands shouldn't show up, sometimes they do.
3512
\definedummyword\gtr
3513
\definedummyword\hat
3514
\definedummyword\less
3517
\definedummyword\tclose
3520
\definedummyword\LaTeX
3521
\definedummyword\TeX
3523
% Assorted special characters.
3524
\definedummyword\bullet
3525
\definedummyword\comma
3526
\definedummyword\copyright
3527
\definedummyword\registeredsymbol
3528
\definedummyword\dots
3529
\definedummyword\enddots
3530
\definedummyword\equiv
3531
\definedummyword\error
3532
\definedummyword\euro
3533
\definedummyword\expansion
3534
\definedummyword\minus
3535
\definedummyword\pounds
3536
\definedummyword\point
3537
\definedummyword\print
3538
\definedummyword\result
3539
\definedummyword\textdegree
3541
% We want to disable all macros so that they are not expanded by \write.
3544
\normalturnoffactive
3546
% Handle some cases of @value -- where it does not contain any
3547
% (non-fully-expandable) commands.
3548
\makevalueexpandable
3551
% \commondummiesnofonts: common to \commondummies and \indexnofonts.
3553
\def\commondummiesnofonts{%
3554
% Control letters and accents.
3555
\definedummyletter\!%
3556
\definedummyaccent\"%
3557
\definedummyaccent\'%
3558
\definedummyletter\*%
3559
\definedummyaccent\,%
3560
\definedummyletter\.%
3561
\definedummyletter\/%
3562
\definedummyletter\:%
3563
\definedummyaccent\=%
3564
\definedummyletter\?%
3565
\definedummyaccent\^%
3566
\definedummyaccent\`%
3567
\definedummyaccent\~%
3571
\definedummyword\dotaccent
3572
\definedummyword\ringaccent
3573
\definedummyword\tieaccent
3574
\definedummyword\ubaraccent
3575
\definedummyword\udotaccent
3576
\definedummyword\dotless
3578
% Texinfo font commands.
3585
% Commands that take arguments.
3586
\definedummyword\acronym
3587
\definedummyword\cite
3588
\definedummyword\code
3589
\definedummyword\command
3590
\definedummyword\dfn
3591
\definedummyword\emph
3592
\definedummyword\env
3593
\definedummyword\file
3594
\definedummyword\kbd
3595
\definedummyword\key
3596
\definedummyword\math
3597
\definedummyword\option
3598
\definedummyword\pxref
3599
\definedummyword\ref
3600
\definedummyword\samp
3601
\definedummyword\strong
3602
\definedummyword\tie
3603
\definedummyword\uref
3604
\definedummyword\url
3605
\definedummyword\var
3606
\definedummyword\verb
3608
\definedummyword\xref
3611
% \indexnofonts is used when outputting the strings to sort the index
3612
% by, and when constructing control sequence names. It eliminates all
3613
% control sequences and just writes whatever the best ASCII sort string
3614
% would be for a given command (usually its argument).
2899
3616
\def\indexnofonts{%
2901
% how to handle braces?
2902
\def\_{\normalunderscore}%
2904
\let\,=\indexdummyfont
2905
\let\"=\indexdummyfont
2906
\let\`=\indexdummyfont
2907
\let\'=\indexdummyfont
2908
\let\^=\indexdummyfont
2909
\let\~=\indexdummyfont
2910
\let\==\indexdummyfont
2911
\let\b=\indexdummyfont
2912
\let\c=\indexdummyfont
2913
\let\d=\indexdummyfont
2914
\let\u=\indexdummyfont
2915
\let\v=\indexdummyfont
2916
\let\H=\indexdummyfont
2917
\let\dotless=\indexdummyfont
2918
% Take care of the plain tex special European modified letters.
2931
% Don't no-op \tt, since it isn't a user-level command
2932
% and is used in the definitions of the active chars like <, >, |, etc.
2933
% Likewise with the other plain tex font commands.
2934
%\let\tt=\indexdummyfont
2936
\let\b=\indexdummyfont
2937
\let\i=\indexdummyfont
2938
\let\r=\indexdummyfont
2939
\let\sc=\indexdummyfont
2940
\let\t=\indexdummyfont
2942
\let\TeX=\indexdummytex
2943
\let\acronym=\indexdummyfont
2944
\let\cite=\indexdummyfont
2945
\let\code=\indexdummyfont
2946
\let\command=\indexdummyfont
2947
\let\dfn=\indexdummyfont
2948
\let\dots=\indexdummydots
2949
\let\emph=\indexdummyfont
2950
\let\env=\indexdummyfont
2951
\let\file=\indexdummyfont
2952
\let\kbd=\indexdummyfont
2953
\let\key=\indexdummyfont
2954
\let\math=\indexdummyfont
2955
\let\option=\indexdummyfont
2956
\let\samp=\indexdummyfont
2957
\let\strong=\indexdummyfont
2958
\let\uref=\indexdummyfont
2959
\let\url=\indexdummyfont
2960
\let\var=\indexdummyfont
2961
\let\w=\indexdummyfont
3617
% Accent commands should become @asis.
3618
\def\definedummyaccent##1{\let##1\asis}%
3619
% We can just ignore other control letters.
3620
\def\definedummyletter##1{\let##1\empty}%
3621
% Hopefully, all control words can become @asis.
3622
\let\definedummyword\definedummyaccent
3624
\commondummiesnofonts
3626
% Don't no-op \tt, since it isn't a user-level command
3627
% and is used in the definitions of the active chars like <, >, |, etc.
3628
% Likewise with the other plain tex font commands.
3633
% how to handle braces?
3634
\def\_{\normalunderscore}%
3636
% Non-English letters.
3649
\def\questiondown{?}%
3656
% Assorted special characters.
3657
% (The following {} will end up in the sort string, but that's ok.)
3658
\def\bullet{bullet}%
3660
\def\copyright{copyright}%
3661
\def\registeredsymbol{R}%
3667
\def\expansion{==>}%
3669
\def\pounds{pounds}%
3673
\def\textdegree{degrees}%
3675
% We need to get rid of all macros, leaving only the arguments (if present).
3676
% Of course this is not nearly correct, but it is the best we can do for now.
3677
% makeinfo does not expand macros in the argument to @deffn, which ends up
3678
% writing an index entry, and texindex isn't prepared for an index sort entry
3679
% that starts with \.
3681
% Since macro invocations are followed by braces, we can just redefine them
3682
% to take a single TeX argument. The case of a macro invocation that
3683
% goes to end-of-line is not handled.
2964
% To define \realbackslash, we must make \ not be an escape.
2965
% We must first make another character (@) an escape
2966
% so we do not become unable to do a definition.
2968
{\catcode`\@=0 \catcode`\\=\other
2969
@gdef@realbackslash{\}}
2971
3688
\let\indexbackslash=0 %overridden during \printindex.
2972
3689
\let\SETmarginindex=\relax % put index entries in margin (undocumented)?
2974
% For \ifx comparisons.
2975
\def\emptymacro{\empty}
2977
3691
% Most index entries go through here, but \dosubind is the general case.
2979
\def\doind#1#2{\dosubind{#1}{#2}\empty}
3692
% #1 is the index name, #2 is the entry text.
3693
\def\doind#1#2{\dosubind{#1}{#2}{}}
2981
3695
% Workhorse for all \fooindexes.
2982
3696
% #1 is name of index, #2 is stuff to put there, #3 is subentry --
2983
% \empty if called from \doind, as we usually are. The main exception
2984
% is with defuns, which call us directly.
3697
% empty if called from \doind, as we usually are (the main exception
3698
% is with most defuns, which call us directly).
2986
3700
\def\dosubind#1#2#3{%
3703
% Store the main index entry text (including the third arg).
3705
% If third arg is present, precede it with a space.
3707
\ifx\thirdarg\empty \else
3708
\toks0 = \expandafter{\the\toks0 \space #3}%
3711
\edef\writeto{\csname#1indfile\endcsname}%
3722
% Write the entry in \toks0 to the index file:
3724
\def\dosubindwrite{%
2987
3725
% Put the index entry in the margin if desired.
2988
3726
\ifx\SETmarginindex\relax\else
2989
\insert\margin{\hbox{\vrule height8pt depth3pt width0pt #2}}%
2992
\count255=\lastpenalty
2994
\indexdummies % Must do this here, since \bf, etc expand at this stage
2997
\let\folio = 0% We will expand all macros now EXCEPT \folio.
2998
\def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now
2999
% so it will be output as is; and it will print as backslash.
3003
% If third arg is present, precede it with space in sort key.
3004
\ifx\thirdarg\emptymacro
3005
\let\subentry = \empty
3010
% First process the index entry with all font commands turned
3011
% off to get the string to sort by.
3012
{\indexnofonts \xdef\indexsorttmp{#2\subentry}}%
3014
% Now the real index entry with the fonts.
3017
% If the third (subentry) arg is present, add it to the index
3019
\ifx\thirdarg\emptymacro \else
3020
\toks0 = \expandafter{\the\toks0{#3}}%
3023
% Set up the complete index entry, with both the sort key and
3024
% the original text, including any font commands. We write
3025
% three arguments to \entry to the .?? file (four in the
3026
% subentry case), texindex reduces to two when writing the .??s
3029
\write\csname#1indfile\endcsname{%
3030
\realbackslash entry{\indexsorttmp}{\folio}{\the\toks0}}%
3033
% If a skip is the last thing on the list now, preserve it
3034
% by backing up by \lastskip, doing the \write, then inserting
3035
% the skip again. Otherwise, the whatsit generated by the
3036
% \write will make \lastskip zero. The result is that sequences
3041
% will have extra space inserted, because the \medbreak in the
3042
% start of the @defun won't see the skip inserted by the @end of
3043
% the previous defun.
3045
% But don't do any of this if we're not in vertical mode. We
3046
% don't want to do a \vskip and prematurely end a paragraph.
3048
% Avoid page breaks due to these extra skips, too.
3053
\ifdim\lastskip = 0pt \else \nobreak\vskip-\lastskip \fi
3056
\temp % do the write
3059
\ifvmode \ifdim\skip0 = 0pt \else \nobreak\vskip\skip0 \fi \fi
3727
\insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}%
3730
% Remember, we are within a group.
3731
\indexdummies % Must do this here, since \bf, etc expand at this stage
3732
\def\backslashcurfont{\indexbackslash}% \indexbackslash isn't defined now
3733
% so it will be output as is; and it will print as backslash.
3735
% Process the index entry with all font commands turned off, to
3736
% get the string to sort by.
3738
\edef\temp{\the\toks0}% need full expansion
3739
\xdef\indexsorttmp{\temp}%
3742
% Set up the complete index entry, with both the sort key and
3743
% the original text, including any font commands. We write
3744
% three arguments to \entry to the .?? file (four in the
3745
% subentry case), texindex reduces to two when writing the .??s
3749
\string\entry{\indexsorttmp}{\noexpand\folio}{\the\toks0}}%
3754
% Take care of unwanted page breaks:
3756
% If a skip is the last thing on the list now, preserve it
3757
% by backing up by \lastskip, doing the \write, then inserting
3758
% the skip again. Otherwise, the whatsit generated by the
3759
% \write will make \lastskip zero. The result is that sequences
3764
% will have extra space inserted, because the \medbreak in the
3765
% start of the @defun won't see the skip inserted by the @end of
3766
% the previous defun.
3768
% But don't do any of this if we're not in vertical mode. We
3769
% don't want to do a \vskip and prematurely end a paragraph.
3771
% Avoid page breaks due to these extra skips, too.
3773
% But wait, there is a catch there:
3774
% We'll have to check whether \lastskip is zero skip. \ifdim is not
3775
% sufficient for this purpose, as it ignores stretch and shrink parts
3776
% of the skip. The only way seems to be to check the textual
3777
% representation of the skip.
3779
% The following is almost like \def\zeroskipmacro{0.0pt} except that
3780
% the ``p'' and ``t'' characters have catcode \other, not 11 (letter).
3782
\edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname}
3786
\def\dosubindsanitize{%
3787
% \lastskip and \lastpenalty cannot both be nonzero simultaneously.
3789
\edef\lastskipmacro{\the\lastskip}%
3790
\count255 = \lastpenalty
3792
% If \lastskip is nonzero, that means the last item was a
3793
% skip. And since a skip is discardable, that means this
3794
% -\skip0 glue we're inserting is preceded by a
3795
% non-discardable item, therefore it is not a potential
3796
% breakpoint, therefore no \nobreak needed.
3797
\ifx\lastskipmacro\zeroskipmacro
3804
\ifx\lastskipmacro\zeroskipmacro
3805
% If \lastskip was zero, perhaps the last item was a penalty, and
3806
% perhaps it was >=10000, e.g., a \nobreak. In that case, we want
3807
% to re-insert the same penalty (values >10000 are used for various
3808
% signals); since we just inserted a non-discardable item, any
3809
% following glue (such as a \parskip) would be a breakpoint. For example:
3811
% @deffn deffn-whatever
3812
% @vindex index-whatever
3814
% would allow a break between the index-whatever whatsit
3815
% and the "Description." paragraph.
3816
\ifnum\count255>9999 \penalty\count255 \fi
3818
% On the other hand, if we had a nonzero \lastskip,
3819
% this make-up glue would be preceded by a non-discardable item
3820
% (the whatsit from the \write), so we must insert a \nobreak.
3821
\nobreak\vskip\skip0
3067
3825
% The index entry written in the file actually looks like
3467
4257
\def\lowersections{\global\advance\secbase by 1}
3468
4258
\let\down=\lowersections % original BFox name
3470
% Choose a numbered-heading macro
3471
% #1 is heading level if unmodified by @raisesections or @lowersections
3472
% #2 is text for heading
3473
\def\numhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
3479
\numberedsubseczzz{#2}
3481
\numberedsubsubseczzz{#2}
3483
\ifnum \absseclevel<0
3486
\numberedsubsubseczzz{#2}
3491
% like \numhead, but chooses appendix heading levels
3492
\def\apphead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
3496
\appendixsectionzzz{#2}
3498
\appendixsubseczzz{#2}
3500
\appendixsubsubseczzz{#2}
3502
\ifnum \absseclevel<0
3505
\appendixsubsubseczzz{#2}
3510
% like \numhead, but chooses numberless heading levels
3511
\def\unnmhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1
3515
\unnumberedseczzz{#2}
3517
\unnumberedsubseczzz{#2}
3519
\unnumberedsubsubseczzz{#2}
3521
\ifnum \absseclevel<0
3524
\unnumberedsubsubseczzz{#2}
3529
% @chapter, @appendix, @unnumbered.
3530
\def\thischaptername{No Chapter Title}
3531
\outer\def\chapter{\parsearg\chapteryyy}
3532
\def\chapteryyy #1{\numhead0{#1}} % normally numhead0 calls chapterzzz
3533
\def\chapterzzz #1{%
3534
\secno=0 \subsecno=0 \subsubsecno=0
3535
\global\advance \chapno by 1 \message{\putwordChapter\space \the\chapno}%
3536
\chapmacro {#1}{\the\chapno}%
3537
\gdef\thissection{#1}%
3538
\gdef\thischaptername{#1}%
3539
% We don't substitute the actual chapter name into \thischapter
3540
% because we don't want its macros evaluated now.
3541
\xdef\thischapter{\putwordChapter{} \the\chapno: \noexpand\thischaptername}%
3543
\edef\temp{\noexpand\writetocentry{\realbackslash chapentry{\the\toks0}%
3547
\global\let\section = \numberedsec
3548
\global\let\subsection = \numberedsubsec
3549
\global\let\subsubsection = \numberedsubsubsec
3552
\outer\def\appendix{\parsearg\appendixyyy}
3553
\def\appendixyyy #1{\apphead0{#1}} % normally apphead0 calls appendixzzz
3554
\def\appendixzzz #1{%
3555
\secno=0 \subsecno=0 \subsubsecno=0
3556
\global\advance \appendixno by 1
3557
\message{\putwordAppendix\space \appendixletter}%
3558
\chapmacro {#1}{\putwordAppendix{} \appendixletter}%
3559
\gdef\thissection{#1}%
3560
\gdef\thischaptername{#1}%
3561
\xdef\thischapter{\putwordAppendix{} \appendixletter: \noexpand\thischaptername}%
3563
\edef\temp{\noexpand\writetocentry{\realbackslash appendixentry{\the\toks0}%
3564
{\appendixletter}}}%
3567
\global\let\section = \appendixsec
3568
\global\let\subsection = \appendixsubsec
3569
\global\let\subsubsection = \appendixsubsubsec
4260
% we only have subsub.
4261
\chardef\maxseclevel = 3
4263
% A numbered section within an unnumbered changes to unnumbered too.
4264
% To achive this, remember the "biggest" unnum. sec. we are currently in:
4265
\chardef\unmlevel = \maxseclevel
4267
% Trace whether the current chapter is an appendix or not:
4268
% \chapheadtype is "N" or "A", unnumbered chapters are ignored.
4269
\def\chapheadtype{N}
4271
% Choose a heading macro
4272
% #1 is heading type
4273
% #2 is heading level
4274
% #3 is text for heading
4275
\def\genhead#1#2#3{%
4276
% Compute the abs. sec. level:
4278
\advance\absseclevel by \secbase
4279
% Make sure \absseclevel doesn't fall outside the range:
4280
\ifnum \absseclevel < 0
4283
\ifnum \absseclevel > 3
4290
\ifnum \absseclevel < \unmlevel
4291
\chardef\unmlevel = \absseclevel
4294
% Check for appendix sections:
4295
\ifnum \absseclevel = 0
4296
\edef\chapheadtype{\headtype}%
4298
\if \headtype A\if \chapheadtype N%
4299
\errmessage{@appendix... within a non-appendix chapter}%
4302
% Check for numbered within unnumbered:
4303
\ifnum \absseclevel > \unmlevel
4306
\chardef\unmlevel = 3
4309
% Now print the heading:
4313
\or \unnumberedseczzz{#3}%
4314
\or \unnumberedsubseczzz{#3}%
4315
\or \unnumberedsubsubseczzz{#3}%
4321
\or \appendixsectionzzz{#3}%
4322
\or \appendixsubseczzz{#3}%
4323
\or \appendixsubsubseczzz{#3}%
4329
\or \numberedsubseczzz{#3}%
4330
\or \numberedsubsubseczzz{#3}%
4334
\suppressfirstparagraphindent
4338
\def\numhead{\genhead N}
4339
\def\apphead{\genhead A}
4340
\def\unnmhead{\genhead U}
4342
% @chapter, @appendix, @unnumbered. Increment top-level counter, reset
4343
% all lower-level sectioning counters to zero.
4345
% Also set \chaplevelprefix, which we prepend to @float sequence numbers
4346
% (e.g., figures), q.v. By default (before any chapter), that is empty.
4347
\let\chaplevelprefix = \empty
4349
\outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz
4351
% section resetting is \global in case the chapter is in a group, such
4352
% as an @include file.
4353
\global\secno=0 \global\subsecno=0 \global\subsubsecno=0
4354
\global\advance\chapno by 1
4357
\gdef\chaplevelprefix{\the\chapno.}%
4360
\message{\putwordChapter\space \the\chapno}%
4362
% Write the actual heading.
4363
\chapmacro{#1}{Ynumbered}{\the\chapno}%
4365
% So @section and the like are numbered underneath this chapter.
4366
\global\let\section = \numberedsec
4367
\global\let\subsection = \numberedsubsec
4368
\global\let\subsubsection = \numberedsubsubsec
4371
\outer\parseargdef\appendix{\apphead0{#1}} % normally apphead0 calls appendixzzz
4372
\def\appendixzzz#1{%
4373
\global\secno=0 \global\subsecno=0 \global\subsubsecno=0
4374
\global\advance\appendixno by 1
4375
\gdef\chaplevelprefix{\appendixletter.}%
4378
\def\appendixnum{\putwordAppendix\space \appendixletter}%
4379
\message{\appendixnum}%
4381
\chapmacro{#1}{Yappendix}{\appendixletter}%
4383
\global\let\section = \appendixsec
4384
\global\let\subsection = \appendixsubsec
4385
\global\let\subsubsection = \appendixsubsubsec
4388
\outer\parseargdef\unnumbered{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz
4389
\def\unnumberedzzz#1{%
4390
\global\secno=0 \global\subsecno=0 \global\subsubsecno=0
4391
\global\advance\unnumberedno by 1
4393
% Since an unnumbered has no number, no prefix for figures.
4394
\global\let\chaplevelprefix = \empty
4397
% This used to be simply \message{#1}, but TeX fully expands the
4398
% argument to \message. Therefore, if #1 contained @-commands, TeX
4399
% expanded them. For example, in `@unnumbered The @cite{Book}', TeX
4400
% expanded @cite (which turns out to cause errors because \cite is meant
4401
% to be executed, not expanded).
4403
% Anyway, we don't want the fully-expanded definition of @cite to appear
4404
% as a result of the \message, we just want `@cite' itself. We use
4405
% \the<toks register> to achieve this: TeX expands \the<toks> only once,
4406
% simply yielding the contents of <toks register>. (We also do this for
4409
\message{(\the\toks0)}%
4411
\chapmacro{#1}{Ynothing}{\the\unnumberedno}%
4413
\global\let\section = \unnumberedsec
4414
\global\let\subsection = \unnumberedsubsec
4415
\global\let\subsubsection = \unnumberedsubsubsec
3572
4418
% @centerchap is like @unnumbered, but the heading is centered.
3573
\outer\def\centerchap{\parsearg\centerchapyyy}
3574
\def\centerchapyyy #1{{\let\unnumbchapmacro=\centerchapmacro \unnumberedyyy{#1}}}
4419
\outer\parseargdef\centerchap{%
4420
% Well, we could do the following in a group, but that would break
4421
% an assumption that \chapmacro is called at the outermost level.
4422
% Thus we are safer this way: --kasal, 24feb04
4423
\let\centerparametersmaybe = \centerparameters
4425
\let\centerparametersmaybe = \relax
3576
4428
% @top is like @unnumbered.
3577
\outer\def\top{\parsearg\unnumberedyyy}
3579
\outer\def\unnumbered{\parsearg\unnumberedyyy}
3580
\def\unnumberedyyy #1{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz
3581
\def\unnumberedzzz #1{%
3582
\secno=0 \subsecno=0 \subsubsecno=0
3584
% This used to be simply \message{#1}, but TeX fully expands the
3585
% argument to \message. Therefore, if #1 contained @-commands, TeX
3586
% expanded them. For example, in `@unnumbered The @cite{Book}', TeX
3587
% expanded @cite (which turns out to cause errors because \cite is meant
3588
% to be executed, not expanded).
3590
% Anyway, we don't want the fully-expanded definition of @cite to appear
3591
% as a result of the \message, we just want `@cite' itself. We use
3592
% \the<toks register> to achieve this: TeX expands \the<toks> only once,
3593
% simply yielding the contents of <toks register>. (We also do this for
3595
\toks0 = {#1}\message{(\the\toks0)}%
3597
\unnumbchapmacro {#1}%
3598
\gdef\thischapter{#1}\gdef\thissection{#1}%
3600
\edef\temp{\noexpand\writetocentry{\realbackslash unnumbchapentry{\the\toks0}}}%
3603
\global\let\section = \unnumberedsec
3604
\global\let\subsection = \unnumberedsubsec
3605
\global\let\subsubsection = \unnumberedsubsubsec
3609
\outer\def\numberedsec{\parsearg\secyyy}
3610
\def\secyyy #1{\numhead1{#1}} % normally calls seczzz
3612
\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
3613
\gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}%
3615
\edef\temp{\noexpand\writetocentry{\realbackslash secentry{\the\toks0}%
3616
{\the\chapno}{\the\secno}}}%
3622
\outer\def\appendixsection{\parsearg\appendixsecyyy}
3623
\outer\def\appendixsec{\parsearg\appendixsecyyy}
3624
\def\appendixsecyyy #1{\apphead1{#1}} % normally calls appendixsectionzzz
3625
\def\appendixsectionzzz #1{%
3626
\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 %
3627
\gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}%
3629
\edef\temp{\noexpand\writetocentry{\realbackslash secentry{\the\toks0}%
3630
{\appendixletter}{\the\secno}}}%
3636
\outer\def\unnumberedsec{\parsearg\unnumberedsecyyy}
3637
\def\unnumberedsecyyy #1{\unnmhead1{#1}} % normally calls unnumberedseczzz
3638
\def\unnumberedseczzz #1{%
3639
\plainsecheading {#1}\gdef\thissection{#1}%
3641
\edef\temp{\noexpand\writetocentry{\realbackslash unnumbsecentry%
3642
{\the\toks0}{\the\chapno}}}%
4432
\outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
4434
\global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
4435
\sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}%
4438
\outer\parseargdef\appendixsection{\apphead1{#1}} % normally calls appendixsectionzzz
4439
\def\appendixsectionzzz#1{%
4440
\global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
4441
\sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}%
4443
\let\appendixsec\appendixsection
4445
\outer\parseargdef\unnumberedsec{\unnmhead1{#1}} % normally calls unnumberedseczzz
4446
\def\unnumberedseczzz#1{%
4447
\global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
4448
\sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%
3649
\outer\def\numberedsubsec{\parsearg\numberedsubsecyyy}
3650
\def\numberedsubsecyyy #1{\numhead2{#1}} % normally calls numberedsubseczzz
3651
\def\numberedsubseczzz #1{%
3652
\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
3653
\subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}%
3655
\edef\temp{\noexpand\writetocentry{\realbackslash subsecentry{\the\toks0}%
3656
{\the\chapno}{\the\secno}{\the\subsecno}}}%
3662
\outer\def\appendixsubsec{\parsearg\appendixsubsecyyy}
3663
\def\appendixsubsecyyy #1{\apphead2{#1}} % normally calls appendixsubseczzz
3664
\def\appendixsubseczzz #1{%
3665
\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 %
3666
\subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}%
3668
\edef\temp{\noexpand\writetocentry{\realbackslash subsecentry{\the\toks0}%
3669
{\appendixletter}{\the\secno}{\the\subsecno}}}%
3675
\outer\def\unnumberedsubsec{\parsearg\unnumberedsubsecyyy}
3676
\def\unnumberedsubsecyyy #1{\unnmhead2{#1}} %normally calls unnumberedsubseczzz
3677
\def\unnumberedsubseczzz #1{%
3678
\plainsubsecheading {#1}\gdef\thissection{#1}%
3680
\edef\temp{\noexpand\writetocentry{\realbackslash unnumbsubsecentry%
3681
{\the\toks0}{\the\chapno}{\the\secno}}}%
4452
\outer\parseargdef\numberedsubsec{\numhead2{#1}} % normally calls numberedsubseczzz
4453
\def\numberedsubseczzz#1{%
4454
\global\subsubsecno=0 \global\advance\subsecno by 1
4455
\sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}%
4458
\outer\parseargdef\appendixsubsec{\apphead2{#1}} % normally calls appendixsubseczzz
4459
\def\appendixsubseczzz#1{%
4460
\global\subsubsecno=0 \global\advance\subsecno by 1
4461
\sectionheading{#1}{subsec}{Yappendix}%
4462
{\appendixletter.\the\secno.\the\subsecno}%
4465
\outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}} %normally calls unnumberedsubseczzz
4466
\def\unnumberedsubseczzz#1{%
4467
\global\subsubsecno=0 \global\advance\subsecno by 1
4468
\sectionheading{#1}{subsec}{Ynothing}%
4469
{\the\unnumberedno.\the\secno.\the\subsecno}%
3687
4472
% Subsubsections.
3688
\outer\def\numberedsubsubsec{\parsearg\numberedsubsubsecyyy}
3689
\def\numberedsubsubsecyyy #1{\numhead3{#1}} % normally numberedsubsubseczzz
3690
\def\numberedsubsubseczzz #1{%
3691
\gdef\thissection{#1}\global\advance \subsubsecno by 1 %
3692
\subsubsecheading {#1}
3693
{\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
3695
\edef\temp{\noexpand\writetocentry{\realbackslash subsubsecentry{\the\toks0}%
3696
{\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}}}%
3702
\outer\def\appendixsubsubsec{\parsearg\appendixsubsubsecyyy}
3703
\def\appendixsubsubsecyyy #1{\apphead3{#1}} % normally appendixsubsubseczzz
3704
\def\appendixsubsubseczzz #1{%
3705
\gdef\thissection{#1}\global\advance \subsubsecno by 1 %
3706
\subsubsecheading {#1}
3707
{\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}%
3709
\edef\temp{\noexpand\writetocentry{\realbackslash subsubsecentry{\the\toks0}%
3710
{\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}}}%
3716
\outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubsecyyy}
3717
\def\unnumberedsubsubsecyyy #1{\unnmhead3{#1}} %normally unnumberedsubsubseczzz
3718
\def\unnumberedsubsubseczzz #1{%
3719
\plainsubsubsecheading {#1}\gdef\thissection{#1}%
3721
\edef\temp{\noexpand\writetocentry{\realbackslash unnumbsubsubsecentry%
3722
{\the\toks0}{\the\chapno}{\the\secno}{\the\subsecno}}}%
3728
% These are variants which are not "outer", so they can appear in @ifinfo.
3729
% Actually, they should now be obsolete; ordinary section commands should work.
3730
\def\infotop{\parsearg\unnumberedzzz}
3731
\def\infounnumbered{\parsearg\unnumberedzzz}
3732
\def\infounnumberedsec{\parsearg\unnumberedseczzz}
3733
\def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz}
3734
\def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz}
3736
\def\infoappendix{\parsearg\appendixzzz}
3737
\def\infoappendixsec{\parsearg\appendixseczzz}
3738
\def\infoappendixsubsec{\parsearg\appendixsubseczzz}
3739
\def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz}
3741
\def\infochapter{\parsearg\chapterzzz}
3742
\def\infosection{\parsearg\sectionzzz}
3743
\def\infosubsection{\parsearg\subsectionzzz}
3744
\def\infosubsubsection{\parsearg\subsubsectionzzz}
4473
\outer\parseargdef\numberedsubsubsec{\numhead3{#1}} % normally numberedsubsubseczzz
4474
\def\numberedsubsubseczzz#1{%
4475
\global\advance\subsubsecno by 1
4476
\sectionheading{#1}{subsubsec}{Ynumbered}%
4477
{\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}%
4480
\outer\parseargdef\appendixsubsubsec{\apphead3{#1}} % normally appendixsubsubseczzz
4481
\def\appendixsubsubseczzz#1{%
4482
\global\advance\subsubsecno by 1
4483
\sectionheading{#1}{subsubsec}{Yappendix}%
4484
{\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}%
4487
\outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}} %normally unnumberedsubsubseczzz
4488
\def\unnumberedsubsubseczzz#1{%
4489
\global\advance\subsubsecno by 1
4490
\sectionheading{#1}{subsubsec}{Ynothing}%
4491
{\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}%
3746
4494
% These macros control what the section commands do, according
3747
4495
% to what kind of chapter we are in (ordinary, appendix, or unnumbered).
3748
4496
% Define them by default for a numbered chapter.
3749
\global\let\section = \numberedsec
3750
\global\let\subsection = \numberedsubsec
3751
\global\let\subsubsection = \numberedsubsubsec
4497
\let\section = \numberedsec
4498
\let\subsection = \numberedsubsec
4499
\let\subsubsection = \numberedsubsubsec
3753
4501
% Define @majorheading, @heading and @subheading
3822
\global\let\chapmacro=\chfplain
3823
\global\let\unnumbchapmacro=\unnchfplain
3824
\global\let\centerchapmacro=\centerchfplain}
3826
% Plain chapter opening.
3827
% #1 is the text, #2 the chapter number or empty if unnumbered.
4573
% #1 is the text, #2 is the section type (Ynumbered, Ynothing,
4574
% Yappendix, Yomitfromtoc), #3 the chapter number.
4576
% To test against our argument.
4577
\def\Ynothingkeyword{Ynothing}
4578
\def\Yomitfromtockeyword{Yomitfromtoc}
4579
\def\Yappendixkeyword{Yappendix}
4581
\def\chapmacro#1#2#3{%
3833
\setbox0 = \hbox{#2\ifx\chapnum\empty\else\enspace\fi}%
4586
% Have to define \thissection before calling \donoderef, because the
4587
% xref code eventually uses it. On the other hand, it has to be called
4588
% after \pchapsepmacro, or the headline will change too soon.
4589
\gdef\thissection{#1}%
4590
\gdef\thischaptername{#1}%
4592
% Only insert the separating space if we have a chapter/appendix
4593
% number, and don't print the unnumbered ``number''.
4595
\ifx\temptype\Ynothingkeyword
4597
\def\toctype{unnchap}%
4598
\gdef\thischapternum{}%
4599
\gdef\thischapter{#1}%
4600
\else\ifx\temptype\Yomitfromtockeyword
4601
\setbox0 = \hbox{}% contents like unnumbered, but no toc entry
4603
\gdef\thischapternum{}%
4604
\gdef\thischapter{}%
4605
\else\ifx\temptype\Yappendixkeyword
4606
\setbox0 = \hbox{\putwordAppendix{} #3\enspace}%
4608
\xdef\thischapternum{\appendixletter}%
4609
% We don't substitute the actual chapter name into \thischapter
4610
% because we don't want its macros evaluated now. And we don't
4611
% use \thissection because that changes with each section.
4613
\xdef\thischapter{\putwordAppendix{} \appendixletter:
4614
\noexpand\thischaptername}%
4616
\setbox0 = \hbox{#3\enspace}%
4617
\def\toctype{numchap}%
4618
\xdef\thischapternum{\the\chapno}%
4619
\xdef\thischapter{\putwordChapter{} \the\chapno:
4620
\noexpand\thischaptername}%
4623
% Write the toc entry for this chapter. Must come before the
4624
% \donoderef, because we include the current node name in the toc
4625
% entry, and \donoderef resets it to empty.
4626
\writetocentry{\toctype}{#1}{#3}%
4628
% For pdftex, we have to write out the node definition (aka, make
4629
% the pdfdest) after any page break, but before the actual text has
4630
% been typeset. If the destination for the pdf outline is after the
4631
% text, then jumping from the outline may wind up with the text not
4632
% being visible, for instance under high magnification.
4635
% Typeset the actual heading.
3834
4636
\vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
3835
\hangindent = \wd0 \centerparametersmaybe
4637
\hangindent=\wd0 \centerparametersmaybe
3836
4638
\unhbox0 #1\par}%
3838
4640
\nobreak\bigskip % no page break after a chapter title
3842
% Plain opening for unnumbered.
3843
\def\unnchfplain#1{\chfplain{#1}{}}
3845
4644
% @centerchap -- centered and unnumbered.
3846
4645
\let\centerparametersmaybe = \relax
3847
\def\centerchfplain#1{{%
3848
\def\centerparametersmaybe{%
3849
\advance\rightskip by 3\rightskip
3850
\leftskip = \rightskip
3856
\CHAPFplain % The default
4646
\def\centerparameters{%
4647
\advance\rightskip by 3\rightskip
4648
\leftskip = \rightskip
4653
% I don't think this chapter style is supported any more, so I'm not
4654
% updating it with the new noderef stuff. We'll see. --karl, 11aug03.
4656
\def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
3858
4658
\def\unnchfopen #1{%
3859
4659
\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
3860
4660
\parindent=0pt\raggedright
3861
4661
\rm #1\hfill}}\bigskip \par\nobreak
3864
4663
\def\chfopen #1#2{\chapoddpage {\chapfonts
3865
4664
\vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
3866
4665
\par\penalty 5000 %
3869
4667
\def\centerchfopen #1{%
3870
4668
\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
3872
4670
\hfill {\rm #1}\hfill}}\bigskip \par\nobreak
3876
\global\let\chapmacro=\chfopen
3877
\global\let\unnumbchapmacro=\unnchfopen
3878
\global\let\centerchapmacro=\centerchfopen}
4673
\global\let\chapmacro=\chfopen
4674
\global\let\centerchapmacro=\centerchfopen}
4677
% Section titles. These macros combine the section number parts and
4678
% call the generic \sectionheading to do the printing.
3882
4680
\newskip\secheadingskip
3883
\def\secheadingbreak{\dobreak \secheadingskip {-1000}}
3884
\def\secheading#1#2#3{\sectionheading{sec}{#2.#3}{#1}}
3885
\def\plainsecheading#1{\sectionheading{sec}{}{#1}}
4681
\def\secheadingbreak{\dobreak \secheadingskip{-1000}}
3887
4683
% Subsection titles.
3888
\newskip \subsecheadingskip
3889
\def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}}
3890
\def\subsecheading#1#2#3#4{\sectionheading{subsec}{#2.#3.#4}{#1}}
3891
\def\plainsubsecheading#1{\sectionheading{subsec}{}{#1}}
4684
\newskip\subsecheadingskip
4685
\def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}}
3893
4687
% Subsubsection titles.
3894
\let\subsubsecheadingskip = \subsecheadingskip
3895
\let\subsubsecheadingbreak = \subsecheadingbreak
3896
\def\subsubsecheading#1#2#3#4#5{\sectionheading{subsubsec}{#2.#3.#4.#5}{#1}}
3897
\def\plainsubsubsecheading#1{\sectionheading{subsubsec}{}{#1}}
3900
% Print any size section title.
3902
% #1 is the section type (sec/subsec/subsubsec), #2 is the section
3903
% number (maybe empty), #3 the text.
3904
\def\sectionheading#1#2#3{%
3906
\expandafter\advance\csname #1headingskip\endcsname by \parskip
3907
\csname #1headingbreak\endcsname
4688
\def\subsubsecheadingskip{\subsecheadingskip}
4689
\def\subsubsecheadingbreak{\subsecheadingbreak}
4692
% Print any size, any type, section title.
4694
% #1 is the text, #2 is the section level (sec/subsec/subsubsec), #3 is
4695
% the section type for xrefs (Ynumbered, Ynothing, Yappendix), #4 is the
4698
\def\sectionheading#1#2#3#4{%
3910
4700
% Switch to the right set of fonts.
3911
\csname #1fonts\endcsname \rm
3913
% Only insert the separating space if we have a section number.
3915
\setbox0 = \hbox{#2\ifx\secnum\empty\else\enspace\fi}%
4701
\csname #2fonts\endcsname \rm
4703
% Insert space above the heading.
4704
\csname #2headingbreak\endcsname
4706
% Only insert the space after the number if we have a section number.
4707
\def\sectionlevel{#2}%
4710
\ifx\temptype\Ynothingkeyword
4713
\gdef\thissection{#1}%
4714
\else\ifx\temptype\Yomitfromtockeyword
4715
% for @headings -- no section number, don't include in toc,
4716
% and don't redefine \thissection.
4719
\let\sectionlevel=\empty
4720
\else\ifx\temptype\Yappendixkeyword
4721
\setbox0 = \hbox{#4\enspace}%
4723
\gdef\thissection{#1}%
4725
\setbox0 = \hbox{#4\enspace}%
4727
\gdef\thissection{#1}%
4730
% Write the toc entry (before \donoderef). See comments in \chapmacro.
4731
\writetocentry{\toctype\sectionlevel}{#1}{#4}%
4733
% Write the node reference (= pdf destination for pdftex).
4734
% Again, see comments in \chapmacro.
4737
% Interline glue will be inserted when the vbox is completed.
4738
% That glue will be a valid breakpoint for the page, since it'll be
4739
% preceded by a whatsit (usually from the \donoderef, or from the
4740
% \writetocentry if there was no node). We don't want to allow that
4741
% break, since then the whatsits could end up on page n while the
4742
% section is on page n+1, thus toc/etc. are wrong. Debian bug 276000.
4745
% Output the actual section heading.
3917
4746
\vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright
3918
\hangindent = \wd0 % zero if no section number
4747
\hangindent=\wd0 % zero if no section number
3921
\ifdim\parskip<10pt \nobreak\kern10pt\nobreak\kern-\parskip\fi \nobreak
4750
% Add extra space after the heading -- half of whatever came above it.
4751
% Don't allow stretch, though.
4752
\kern .5 \csname #2headingskip\endcsname
4754
% Do not let the kern be a potential breakpoint, as it would be if it
4755
% was followed by glue.
4758
% We'll almost certainly start a paragraph next, so don't let that
4759
% glue accumulate. (Not a breakpoint because it's preceded by a
4760
% discardable item.)
4763
% This is purely so the last item on the list is a known \penalty >
4764
% 10000. This is so \startdefun can avoid allowing breakpoints after
4765
% section headings. Otherwise, it would insert a valid breakpoint between:
4767
% @section sec-whatever
4768
% @deffn def-whatever
3927
4775
\newwrite\tocfile
3929
4777
% Write an entry to the toc file, opening it if necessary.
3930
% Called from @chapter, etc. We supply {\folio} at the end of the
3931
% argument, which will end up as the last argument to the \...entry macro.
3933
% We open the .toc file here instead of at @setfilename or any other
3934
% fixed time so that @contents can be put in the document anywhere.
4778
% Called from @chapter, etc.
4780
% Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno}
4781
% We append the current node name (if any) and page number as additional
4782
% arguments for the \{chap,sec,...}entry macros which will eventually
4783
% read this. The node name is used in the pdf outlines as the
4784
% destination to jump to.
4786
% We open the .toc file for writing here instead of at @setfilename (or
4787
% any other fixed time) so that @contents can be anywhere in the document.
4788
% But if #1 is `omit', then we don't do anything. This is used for the
4789
% table of contents chapter openings themselves.
3936
4791
\newif\iftocfileopened
3937
\def\writetocentry#1{%
3938
\iftocfileopened\else
3939
\immediate\openout\tocfile = \jobname.toc
3940
\global\tocfileopenedtrue
4792
\def\omitkeyword{omit}%
4794
\def\writetocentry#1#2#3{%
4795
\edef\writetoctype{#1}%
4796
\ifx\writetoctype\omitkeyword \else
4797
\iftocfileopened\else
4798
\immediate\openout\tocfile = \jobname.toc
4799
\global\tocfileopenedtrue
4805
\write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}%
3942
\iflinks \write\tocfile{#1{\folio}}\fi
3944
% Tell \shipout to create a page destination if we're doing pdf, which
3945
% will be the target of the links in the table of contents. We can't
3946
% just do it on every page because the title pages are numbered 1 and
3947
% 2 (the page numbers aren't printed), and so are the first two pages
3948
% of the document. Thus, we'd have two destinations named `1', and
3950
\ifpdf \pdfmakepagedesttrue \fi
4811
% Tell \shipout to create a pdf destination on each page, if we're
4812
% writing pdf. These are used in the table of contents. We can't
4813
% just write one on every page because the title pages are numbered
4814
% 1 and 2 (the page numbers aren't printed), and so are the first
4815
% two pages of the document. Thus, we'd have two destinations named
4816
% `1', and two named `2'.
4817
\ifpdf \global\pdfmakepagedesttrue \fi
4821
% These characters do not print properly in the Computer Modern roman
4822
% fonts, so we must take special care. This is more or less redundant
4823
% with the Texinfo input format setup at the end of this file.
4825
\def\activecatcodes{%
4838
% Read the toc file, which is essentially Texinfo input.
3953
4845
\newskip\contentsrightmargin \contentsrightmargin=1in
3954
4846
\newcount\savepageno
3955
4847
\newcount\lastnegativepageno \lastnegativepageno = -1
3957
% Finish up the main text and prepare to read what we've written
4849
% Prepare to read what we've written to \tocfile.
3960
4851
\def\startcontents#1{%
3961
% If @setchapternewpage on, and @headings double, the contents should
3962
% start on an odd page, unlike chapters. Thus, we maintain
3963
% \contentsalignmacro in parallel with \pagealignmacro.
3964
% From: Torbjorn Granlund <tege@matematik.su.se>
3966
\immediate\closeout\tocfile
3968
% Don't need to put `Contents' or `Short Contents' in the headline.
3969
% It is abundantly clear what they are.
3970
\unnumbchapmacro{#1}\def\thischapter{}%
3971
\savepageno = \pageno
3972
\begingroup % Set up to handle contents files properly.
3973
\catcode`\\=0 \catcode`\{=1 \catcode`\}=2 \catcode`\@=11
3974
% We can't do this, because then an actual ^ in a section
3975
% title fails, e.g., @chapter ^ -- exponentiation. --karl, 9jul97.
3976
%\catcode`\^=7 % to see ^^e4 as \"a etc. juha@piuha.ydi.vtt.fi
3977
\raggedbottom % Worry more about breakpoints than the bottom.
3978
\advance\hsize by -\contentsrightmargin % Don't use the full line length.
3980
% Roman numerals for page numbers.
3981
\ifnum \pageno>0 \pageno = \lastnegativepageno \fi
4852
% If @setchapternewpage on, and @headings double, the contents should
4853
% start on an odd page, unlike chapters. Thus, we maintain
4854
% \contentsalignmacro in parallel with \pagealignmacro.
4855
% From: Torbjorn Granlund <tege@matematik.su.se>
4857
\immediate\closeout\tocfile
4859
% Don't need to put `Contents' or `Short Contents' in the headline.
4860
% It is abundantly clear what they are.
4862
\chapmacro{#1}{Yomitfromtoc}{}%
4864
\savepageno = \pageno
4865
\begingroup % Set up to handle contents files properly.
4866
\raggedbottom % Worry more about breakpoints than the bottom.
4867
\advance\hsize by -\contentsrightmargin % Don't use the full line length.
4869
% Roman numerals for page numbers.
4870
\ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
3985
4874
% Normal (long) toc.
3986
4875
\def\contents{%
3987
\startcontents{\putwordTOC}%
3988
\openin 1 \jobname.toc
3994
\contentsalignmacro % in case @setchapternewpage odd is in effect
3997
\lastnegativepageno = \pageno
3998
\pageno = \savepageno
4876
\startcontents{\putwordTOC}%
4877
\openin 1 \jobname.toc
4882
\contentsalignmacro % in case @setchapternewpage odd is in effect
4888
\lastnegativepageno = \pageno
4889
\global\pageno = \savepageno
4001
4892
% And just the chapters.
4002
4893
\def\summarycontents{%
4003
\startcontents{\putwordShortTOC}%
4005
\let\chapentry = \shortchapentry
4006
\let\appendixentry = \shortappendixentry
4007
\let\unnumbchapentry = \shortunnumberedentry
4008
% We want a true roman here for the page numbers.
4010
\let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl
4012
\hyphenpenalty = 10000
4013
\advance\baselineskip by 1pt % Open it up a little.
4014
\def\secentry ##1##2##3##4{}
4015
\def\unnumbsecentry ##1##2##3{}
4016
\def\subsecentry ##1##2##3##4##5{}
4017
\def\unnumbsubsecentry ##1##2##3##4{}
4018
\def\subsubsecentry ##1##2##3##4##5##6{}
4019
\def\unnumbsubsubsecentry ##1##2##3##4##5{}
4020
\openin 1 \jobname.toc
4026
\contentsalignmacro % in case @setchapternewpage odd is in effect
4028
\lastnegativepageno = \pageno
4029
\pageno = \savepageno
4894
\startcontents{\putwordShortTOC}%
4896
\let\numchapentry = \shortchapentry
4897
\let\appentry = \shortchapentry
4898
\let\unnchapentry = \shortunnchapentry
4899
% We want a true roman here for the page numbers.
4901
\let\rm=\shortcontrm \let\bf=\shortcontbf
4902
\let\sl=\shortcontsl \let\tt=\shortconttt
4904
\hyphenpenalty = 10000
4905
\advance\baselineskip by 1pt % Open it up a little.
4906
\def\numsecentry##1##2##3##4{}
4907
\let\appsecentry = \numsecentry
4908
\let\unnsecentry = \numsecentry
4909
\let\numsubsecentry = \numsecentry
4910
\let\appsubsecentry = \numsecentry
4911
\let\unnsubsecentry = \numsecentry
4912
\let\numsubsubsecentry = \numsecentry
4913
\let\appsubsubsecentry = \numsecentry
4914
\let\unnsubsubsecentry = \numsecentry
4915
\openin 1 \jobname.toc
4921
\contentsalignmacro % in case @setchapternewpage odd is in effect
4923
\lastnegativepageno = \pageno
4924
\global\pageno = \savepageno
4031
4926
\let\shortcontents = \summarycontents
4034
\pdfcatalog{/PageMode /UseOutlines}%
4928
% Typeset the label for a chapter or appendix for the short contents.
4929
% The arg is, e.g., `A' for an appendix, or `3' for a chapter.
4931
\def\shortchaplabel#1{%
4932
% This space should be enough, since a single number is .5em, and the
4933
% widest letter (M) is 1em, at least in the Computer Modern fonts.
4934
% But use \hss just in case.
4935
% (This space doesn't include the extra space that gets added after
4936
% the label; that gets put in by \shortchapentry above.)
4938
% We'd like to right-justify chapter numbers, but that looks strange
4939
% with appendix letters. And right-justifying numbers and
4940
% left-justifying letters looks strange when there is less than 10
4941
% chapters. Have to read the whole toc once to know how many chapters
4942
% there are before deciding ...
4943
\hbox to 1em{#1\hss}%
4037
4946
% These macros generate individual entries in the table of contents.
4038
4947
% The first argument is the chapter or section name.
4291
5176
\newskip\lskip\newskip\rskip
4293
\long\def\cartouche{%
4295
\lskip=\leftskip \rskip=\rightskip
4296
\leftskip=0pt\rightskip=0pt %we want these *outside*.
4297
\cartinner=\hsize \advance\cartinner by-\lskip
4298
\advance\cartinner by-\rskip
4300
\advance\cartouter by 18.4pt % allow for 3pt kerns on either
4301
% side, and for 6pt waste from
4302
% each corner char, and rule thickness
4303
\normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
4304
% Flag to tell @lisp, etc., not to narrow margin.
4305
\let\nonarrowing=\comment
4307
\baselineskip=0pt\parskip=0pt\lineskip=0pt
4316
\baselineskip=\normbskip
4317
\lineskip=\normlskip
5179
\ifhmode\par\fi % can't be in the midst of a paragraph.
5181
\lskip=\leftskip \rskip=\rightskip
5182
\leftskip=0pt\rightskip=0pt % we want these *outside*.
5183
\cartinner=\hsize \advance\cartinner by-\lskip
5184
\advance\cartinner by-\rskip
5186
\advance\cartouter by 18.4pt % allow for 3pt kerns on either
5187
% side, and for 6pt waste from
5188
% each corner char, and rule thickness
5189
\normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
5190
% Flag to tell @lisp, etc., not to narrow margin.
5191
\let\nonarrowing = t%
5193
\baselineskip=0pt\parskip=0pt\lineskip=0pt
5201
\baselineskip=\normbskip
5202
\lineskip=\normlskip
5205
\comment % For explanation, see the end of \def\group.
4320
5207
\def\Ecartouche{%
4333
5220
% This macro is called at the beginning of all the @example variants,
4334
5221
% inside a group.
4335
5222
\def\nonfillstart{%
4337
\inENV % This group ends at the end of the body
4338
5224
\hfuzz = 12pt % Don't be fussy
4339
5225
\sepspaces % Make spaces be word-separators rather than space tokens.
4341
5226
\let\par = \lisppar % don't ignore blank lines
4342
5227
\obeylines % each line of input is a line of output
4344
5229
\parindent = 0pt
4345
5230
\emergencystretch = 0pt % don't try to avoid overfull boxes
4346
% @cartouche defines \nonarrowing to inhibit narrowing
4347
% at next level down.
4348
5231
\ifx\nonarrowing\relax
4349
5232
\advance \leftskip by \lispnarrowing
4350
5233
\exdentamount=\lispnarrowing
4351
\let\exdent=\nofillexdent
4352
\let\nonarrowing=\relax
4356
% Define the \E... control sequence only if we are inside the particular
4357
% environment, so the error checking in \end will work.
4359
% To end an @example-like environment, we first end the paragraph (via
4360
% \afterenvbreak's vertical glue), and then the group. That way we keep
4361
% the zero \parskip that the environments set -- \parskip glue will be
4362
% inserted at the beginning of the next paragraph in the document, after
4365
\def\nonfillfinish{\afterenvbreak\endgroup}
4367
% @lisp: indented, narrowed, typewriter font.
4368
\def\lisp{\begingroup
5235
\let\nonarrowing = \relax
5237
\let\exdent=\nofillexdent
5240
% If you want all examples etc. small: @set dispenvsize small.
5241
% If you want even small examples the full size: @set dispenvsize nosmall.
5242
% This affects the following displayed environments:
5243
% @example, @display, @format, @lisp
5245
\def\smallword{small}
5246
\def\nosmallword{nosmall}
5247
\let\SETdispenvsize\relax
5248
\def\setnormaldispenv{%
5249
\ifx\SETdispenvsize\smallword
5250
\smallexamplefonts \rm
5253
\def\setsmalldispenv{%
5254
\ifx\SETdispenvsize\nosmallword
5256
\smallexamplefonts \rm
5260
% We often define two environments, @foo and @smallfoo.
5261
% Let's do it by one command:
5262
\def\makedispenv #1#2{
5263
\expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}
5264
\expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}
5265
\expandafter\let\csname E#1\endcsname \afterenvbreak
5266
\expandafter\let\csname Esmall#1\endcsname \afterenvbreak
5269
% Define two synonyms:
5270
\def\maketwodispenvs #1#2#3{
5271
\makedispenv{#1}{#3}
5272
\makedispenv{#2}{#3}
5275
% @lisp: indented, narrowed, typewriter font; @example: same as @lisp.
5277
% @smallexample and @smalllisp: use smaller fonts.
5278
% Originally contributed by Pavel@xerox.
5280
\maketwodispenvs {lisp}{example}{%
4370
\let\Elisp = \nonfillfinish
4372
5283
\let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
4373
5284
\gobble % eat return
4376
% @example: Same as @lisp.
4377
\def\example{\begingroup \def\Eexample{\nonfillfinish\endgroup}\lisp}
4379
% @small... is usually equivalent to the non-small (@smallbook
4380
% redefines). We must call \example (or whatever) last in the
4381
% definition, since it reads the return following the @example (or
4382
% whatever) command.
4384
% This actually allows (for example) @end display inside an
4385
% @smalldisplay. Too bad, but makeinfo will catch the error anyway.
4387
\def\smalldisplay{\begingroup\def\Esmalldisplay{\nonfillfinish\endgroup}\display}
4388
\def\smallexample{\begingroup\def\Esmallexample{\nonfillfinish\endgroup}\lisp}
4389
\def\smallformat{\begingroup\def\Esmallformat{\nonfillfinish\endgroup}\format}
4390
\def\smalllisp{\begingroup\def\Esmalllisp{\nonfillfinish\endgroup}\lisp}
4392
% Real @smallexample and @smalllisp (when @smallbook): use smaller fonts.
4393
% Originally contributed by Pavel@xerox.
4394
\def\smalllispx{\begingroup
4395
\def\Esmalllisp{\nonfillfinish\endgroup}%
4396
\def\Esmallexample{\nonfillfinish\endgroup}%
4401
% @display: same as @lisp except keep current font.
4403
\def\display{\begingroup
4405
\let\Edisplay = \nonfillfinish
4409
% @smalldisplay (when @smallbook): @display plus smaller fonts.
4411
\def\smalldisplayx{\begingroup
4412
\def\Esmalldisplay{\nonfillfinish\endgroup}%
4413
\smallexamplefonts \rm
4417
% @format: same as @display except don't narrow margins.
4419
\def\format{\begingroup
4420
\let\nonarrowing = t
4422
\let\Eformat = \nonfillfinish
4426
% @smallformat (when @smallbook): @format plus smaller fonts.
4428
\def\smallformatx{\begingroup
4429
\def\Esmallformat{\nonfillfinish\endgroup}%
4430
\smallexamplefonts \rm
4434
% @flushleft (same as @format).
4436
\def\flushleft{\begingroup \def\Eflushleft{\nonfillfinish\endgroup}\format}
5286
% @display/@smalldisplay: same as @lisp except keep current font.
5288
\makedispenv {display}{%
5293
% @format/@smallformat: same as @display except don't narrow margins.
5295
\makedispenv{format}{%
5296
\let\nonarrowing = t%
5301
% @flushleft: same as @format, but doesn't obey \SETdispenvsize.
5303
\let\nonarrowing = t%
5307
\let\Eflushleft = \afterenvbreak
4440
\def\flushright{\begingroup
4441
\let\nonarrowing = t
5311
\envdef\flushright{%
5312
\let\nonarrowing = t%
4443
\let\Eflushright = \nonfillfinish
4444
5314
\advance\leftskip by 0pt plus 1fill
5317
\let\Eflushright = \afterenvbreak
4449
5320
% @quotation does normal linebreaking (hence we can't use \nonfillstart)
4450
% and narrows the margins.
5321
% and narrows the margins. We keep \parskip nonzero in general, since
5322
% we're doing normal filling. So, when using \aboveenvbreak and
5323
% \afterenvbreak, temporarily make \parskip 0.
4453
\begingroup\inENV %This group ends at the end of the @quotation body
4454
5326
{\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
4457
% We have retained a nonzero parskip for the environment, since we're
4458
% doing normal filling. So to avoid extra space below the environment...
4459
\def\Equotation{\parskip = 0pt \nonfillfinish}%
4461
5329
% @cartouche defines \nonarrowing to inhibit narrowing at next level down.
4462
5330
\ifx\nonarrowing\relax
4463
5331
\advance\leftskip by \lispnarrowing
4464
5332
\advance\rightskip by \lispnarrowing
4465
5333
\exdentamount = \lispnarrowing
4466
5335
\let\nonarrowing = \relax
5337
\parsearg\quotationlabel
5340
% We have retained a nonzero parskip for the environment, since we're
5341
% doing normal filling.
5345
\ifx\quotationauthor\undefined\else
5347
\leftline{\kern 2\leftskip \sl ---\quotationauthor}%
5349
{\parskip=0pt \afterenvbreak}%
5352
% If we're given an argument, typeset it in bold with a colon after.
5353
\def\quotationlabel#1{%
5355
\ifx\temp\empty \else
4471
5361
% LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>}
4472
% If we want to allow any <char> as delimiter,
5362
% If we want to allow any <char> as delimiter,
4473
5363
% we need the curly braces so that makeinfo sees the @verb command, eg:
4474
5364
% `@verbx...x' would look like the '@verbx' command. --janneke@gnu.org
4476
5366
% [Knuth]: Donald Ervin Knuth, 1996. The TeXbook.
4478
% [Knuth] p. 344; only we need to do '@' too
5368
% [Knuth] p.344; only we need to do the other characters Texinfo sets
5369
% active too. Otherwise, they get lost as the first character on a
4479
5371
\def\dospecials{%
4480
\do\ \do\\\do\@\do\{\do\}\do\$\do\&%
4481
\do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~}
5372
\do\ \do\\\do\{\do\}\do\$\do\&%
5373
\do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~%
5374
\do\<\do\>\do\|\do\@\do+\do\"%
4483
5377
% [Knuth] p. 380
4484
5378
\def\uncatcodespecials{%
4485
\def\do##1{\catcode`##1=12}\dospecials}
5379
\def\do##1{\catcode`##1=\other}\dospecials}
4487
5381
% [Knuth] pp. 380,381,391
4488
5382
% Disable Spanish ligatures ?` and !` of \tt font
4564
5498
% \def\doverbatim#1@end verbatim{#1}
4566
% For Texinfo it's a lot easier than for LaTeX,
5500
% For Texinfo it's a lot easier than for LaTeX,
4567
5501
% because texinfo's \verbatim doesn't stop at '\end{verbatim}':
4568
% we need not redefine '\', '{' and '}'
5502
% we need not redefine '\', '{' and '}'.
4570
5504
% Inspired by LaTeX's verbatim command set [latex.ltx]
4571
%% Include LaTeX hack for completeness -- never know
4573
%% \catcode`|=0 \catcode`[=1
4574
%% \catcode`]=2\catcode`\{=12\catcode`\}=12\catcode`\ =\active
4575
%% \catcode`\\=12|gdef|doverbatim#1@end verbatim[
4576
%% #1|endgroup|def|Everbatim[]|end[verbatim]]
4579
5507
\catcode`\ =\active
4580
\gdef\doverbatim#1@end verbatim{#1\end{verbatim}}
5509
% ignore everything up to the first ^^M, that's the newline at the end
5510
% of the @verbatim input line itself. Otherwise we get an extra blank
5511
% line in the output.
5512
\xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}%
5513
% We really want {...\end verbatim} in the body of the macro, but
5514
% without the active space; thus we have to use \xdef and \gobble.
4584
\def\Everbatim{\nonfillfinish\endgroup}%
4587
\advance\leftskip by -\defbodyindent
4588
\begingroup\setupverbatim\doverbatim
5518
\setupverbatim\doverbatim
5520
\let\Everbatim = \afterenvbreak
4591
5523
% @verbatiminclude FILE - insert text of file in verbatim environment.
4593
% Allow normal characters that we make active in the argument (a file name).
4594
\def\verbatiminclude{%
4604
\parsearg\doverbatiminclude
4606
\def\setupverbatiminclude{%
4609
\advance\leftskip by -\defbodyindent
4610
\begingroup\setupverbatim
5525
\def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude}
4613
5527
\def\doverbatiminclude#1{%
4614
% Restore active chars for included file.
4618
\expandafter\expandafter\setupverbatiminclude\input\thisfile
4619
\endgroup\nonfillfinish\endgroup
5529
\makevalueexpandable
4622
5536
% @copying ... @end copying.
4623
5537
% Save the text away for @insertcopying later.
4627
\def\copying{\begingroup
4628
\parindent = 0pt % looks wrong on title page
4629
\def\Ecopying{\egroup\endgroup}%
4630
\global\setbox\copyingbox = \vbox\bgroup
5539
% We save the uninterpreted tokens, rather than creating a box.
5540
% Saving the text in a box would be much easier, but then all the
5541
% typesetting commands (@smallbook, font changes, etc.) have to be done
5542
% beforehand -- and a) we want @copying to be done first in the source
5543
% file; b) letting users define the frontmatter in as flexible order as
5544
% possible is very desirable.
5546
\def\copying{\checkenv{}\begingroup\scanargctxt\docopying}
5547
\def\docopying#1@end copying{\endgroup\def\copyingtext{#1}}
5549
\def\insertcopying{%
5551
\parindent = 0pt % paragraph indentation looks wrong on title page
5552
\scanexp\copyingtext
4635
\def\insertcopying{\unvcopy\copyingbox}
4638
5556
\message{defuns,}
4641
% Allow user to change definition object font (\df) internally
4642
\def\setdeffont #1 {\csname DEF#1\endcsname}
4644
5559
\newskip\defbodyindent \defbodyindent=.4in
4645
5560
\newskip\defargsindent \defargsindent=50pt
4646
\newskip\deftypemargin \deftypemargin=12pt
4647
5561
\newskip\deflastargmargin \deflastargmargin=18pt
4649
\newcount\parencount
4650
% define \functionparens, which makes ( and ) and & do special things.
4651
% \functionparens affects the group it is contained in.
5563
% Start the processing of @deffn:
5565
\ifnum\lastpenalty<10000
5568
% If there are two @def commands in a row, we'll have a \nobreak,
5569
% which is there to keep the function description together with its
5570
% header. But if there's nothing but headers, we need to allow a
5571
% break somewhere. Check specifically for penalty 10002, inserted
5572
% by \defargscommonending, instead of 10000, since the sectioning
5573
% commands also insert a nobreak penalty, and we don't want to allow
5574
% a break between a section heading and a defun.
5576
\ifnum\lastpenalty=10002 \penalty2000 \fi
5578
% Similarly, after a section heading, do not allow a break.
5579
% But do insert the glue.
5580
\medskip % preceded by discardable penalty, so not a breakpoint
5584
\advance\leftskip by \defbodyindent
5585
\exdentamount=\defbodyindent
5589
% First, check whether we are in the right environment:
5592
% As above, allow line break if we have multiple x headers in a row.
5593
% It's not a great place, though.
5594
\ifnum\lastpenalty=10002 \penalty3000 \fi
5596
% And now, it's time to reuse the body of the original defun:
5597
\expandafter\gobbledefun#1%
5599
\def\gobbledefun#1\startdefun{}
5601
% \printdefunline \deffnheader{text}
5603
\def\printdefunline#1#2{%
5605
% call \deffnheader:
5608
\interlinepenalty = 10000
5609
\advance\rightskip by 0pt plus 1fil
5611
\nobreak\vskip -\parskip
5612
\penalty 10002 % signal to \startdefun and \dodefunx
5613
% Some of the @defun-type tags do not enable magic parentheses,
5614
% rendering the following check redundant. But we don't optimize.
5619
\def\Edefun{\endgraf\medbreak}
5621
% \makedefun{deffn} creates \deffn, \deffnx and \Edeffn;
5622
% the only thing remainnig is to define \deffnheader.
5625
\expandafter\let\csname E#1\endcsname = \Edefun
5626
\edef\temp{\noexpand\domakedefun
5627
\makecsname{#1}\makecsname{#1x}\makecsname{#1header}}%
5631
% \domakedefun \deffn \deffnx \deffnheader
5633
% Define \deffn and \deffnx, without parameters.
5634
% \deffnheader has to be defined explicitly.
5636
\def\domakedefun#1#2#3{%
5639
\parseargusing\activeparens{\printdefunline#3}%
5641
\def#2{\dodefunx#1}%
5645
%%% Untyped functions:
5647
% @deffn category name args
5648
\makedefun{deffn}{\deffngeneral{}}
5650
% @deffn category class name args
5651
\makedefun{defop}#1 {\defopon{#1\ \putwordon}}
5653
% \defopon {category on}class name args
5654
\def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
5656
% \deffngeneral {subind}category name args
5658
\def\deffngeneral#1#2 #3 #4\endheader{%
5659
% Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}.
5660
\dosubind{fn}{\code{#3}}{#1}%
5661
\defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
5664
%%% Typed functions:
5666
% @deftypefn category type name args
5667
\makedefun{deftypefn}{\deftypefngeneral{}}
5669
% @deftypeop category class type name args
5670
\makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}}
5672
% \deftypeopon {category on}class type name args
5673
\def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
5675
% \deftypefngeneral {subind}category type name args
5677
\def\deftypefngeneral#1#2 #3 #4 #5\endheader{%
5678
\dosubind{fn}{\code{#4}}{#1}%
5679
\defname{#2}{#3}{#4}\defunargs{#5\unskip}%
5682
%%% Typed variables:
5684
% @deftypevr category type var args
5685
\makedefun{deftypevr}{\deftypecvgeneral{}}
5687
% @deftypecv category class type var args
5688
\makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}}
5690
% \deftypecvof {category of}class type var args
5691
\def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} }
5693
% \deftypecvgeneral {subind}category type var args
5695
\def\deftypecvgeneral#1#2 #3 #4 #5\endheader{%
5696
\dosubind{vr}{\code{#4}}{#1}%
5697
\defname{#2}{#3}{#4}\defunargs{#5\unskip}%
5700
%%% Untyped variables:
5702
% @defvr category var args
5703
\makedefun{defvr}#1 {\deftypevrheader{#1} {} }
5705
% @defcv category class var args
5706
\makedefun{defcv}#1 {\defcvof{#1\ \putwordof}}
5708
% \defcvof {category of}class var args
5709
\def\defcvof#1#2 {\deftypecvof{#1}#2 {} }
5712
% @deftp category name args
5713
\makedefun{deftp}#1 #2 #3\endheader{%
5714
\doind{tp}{\code{#2}}%
5715
\defname{#1}{}{#2}\defunargs{#3\unskip}%
5718
% Remaining @defun-like shortcuts:
5719
\makedefun{defun}{\deffnheader{\putwordDeffunc} }
5720
\makedefun{defmac}{\deffnheader{\putwordDefmac} }
5721
\makedefun{defspec}{\deffnheader{\putwordDefspec} }
5722
\makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} }
5723
\makedefun{defvar}{\defvrheader{\putwordDefvar} }
5724
\makedefun{defopt}{\defvrheader{\putwordDefopt} }
5725
\makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} }
5726
\makedefun{defmethod}{\defopon\putwordMethodon}
5727
\makedefun{deftypemethod}{\deftypeopon\putwordMethodon}
5728
\makedefun{defivar}{\defcvof\putwordInstanceVariableof}
5729
\makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof}
5731
% \defname, which formats the name of the @def (not the args).
5732
% #1 is the category, such as "Function".
5733
% #2 is the return type, if any.
5734
% #3 is the function name.
5736
% We are followed by (but not passed) the arguments, if any.
5738
\def\defname#1#2#3{%
5739
% Get the values of \leftskip and \rightskip as they were outside the @def...
5740
\advance\leftskip by -\defbodyindent
5742
% How we'll format the type name. Putting it in brackets helps
5743
% distinguish it from the body text that may end up on the next line
5746
\setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
5748
% Figure out line sizes for the paragraph shape.
5749
% The first line needs space for \box0; but if \rightskip is nonzero,
5750
% we need only space for the part of \box0 which exceeds it:
5751
\dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip
5752
% The continuations:
5753
\dimen2=\hsize \advance\dimen2 by -\defargsindent
5754
% (plain.tex says that \dimen1 should be used only as global.)
5755
\parshape 2 0in \dimen0 \defargsindent \dimen2
5757
% Put the type name to the right margin.
5760
\hfil\box0 \kern-\hsize
5761
% \hsize has to be shortened this way:
5763
% Intentionally do not respect \rightskip, since we need the space.
5766
% Allow all lines to be underfull without complaint:
5767
\tolerance=10000 \hbadness=10000
5768
\exdentamount=\defbodyindent
5770
% defun fonts. We use typewriter by default (used to be bold) because:
5771
% . we're printing identifiers, they should be in tt in principle.
5772
% . in languages with many accents, such as Czech or French, it's
5773
% common to leave accents off identifiers. The result looks ok in
5774
% tt, but exceedingly strange in rm.
5775
% . we don't want -- and --- to be treated as ligatures.
5776
% . this still does not fix the ?` and !` ligatures, but so far no
5777
% one has made identifiers using them :).
5779
\def\temp{#2}% return value type
5780
\ifx\temp\empty\else \tclose{\temp} \fi
5781
#3% output function name
5783
{\rm\enskip}% hskip 0.5 em of \tenrm
5786
% arguments will be output next, if any.
5789
% Print arguments in slanted roman (not ttsl), inconsistently with using
5790
% tt for the name. This is because literal text is sometimes needed in
5791
% the argument list (groff manual), and ttsl and tt are not very
5792
% distinguishable. Prevent hyphenation at `-' chars.
5795
% use sl by default (not ttsl),
5797
\df \sl \hyphenchar\font=0
5799
% On the other hand, if an argument has two dashes (for instance), we
5800
% want a way to get ttsl. Let's try @var for that.
5803
\sl\hyphenchar\font=45
5806
% We want ()&[] to print specially on the defun line.
4652
5808
\def\activeparens{%
4653
\catcode`\(=\active \catcode`\)=\active \catcode`\&=\active
4654
\catcode`\[=\active \catcode`\]=\active}
5809
\catcode`\(=\active \catcode`\)=\active
5810
\catcode`\[=\active \catcode`\]=\active
4656
5814
% Make control sequences which act like normal parenthesis chars.
4657
5815
\let\lparen = ( \let\rparen = )
4659
{\activeparens % Now, smart parens don't turn on until &foo (see \amprm)
4661
5817
% Be sure that we always have a definition for `(', etc. For example,
4662
5818
% if the fn name has parens in it, \boldbrax will not be in effect yet,
4663
5819
% so TeX would otherwise complain about undefined control sequence.
4664
\global\let(=\lparen \global\let)=\rparen
4665
\global\let[=\lbrack \global\let]=\rbrack
4667
\gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 }
4668
\gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
4669
% This is used to turn on special parens
4670
% but make & act ordinary (given that it's active).
4671
\gdef\boldbraxnoamp{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb\let&=\ampnr}
4673
% Definitions of (, ) and & used in args for functions.
4674
% This is the definition of ( outside of all parentheses.
4675
\gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested
5822
\global\let(=\lparen \global\let)=\rparen
5823
\global\let[=\lbrack \global\let]=\rbrack
5826
\gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
5827
\gdef\magicamp{\let&=\amprm}
5830
\newcount\parencount
5832
% If we encounter &foo, then turn on ()-hacking afterwards
5834
\def\amprm#1 {\ampseentrue{\bf\ }}
5838
% At the first level, print parens in roman,
5839
% otherwise use the default font.
5840
\ifnum \parencount=1 \rm \fi
5842
% The \sf parens (in \boldbrax) actually are a little bolder than
5843
% the contained text. This is especially needed for [ and ] .
5847
\def\infirstlevel#1{%
5854
\def\bfafterword#1 {#1 \bf}
4676
5857
\global\advance\parencount by 1
4679
% This is the definition of ( when already inside a level of parens.
4680
\gdef\opnested{\char`\(\global\advance\parencount by 1 }
4682
\gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0.
4683
% also in that case restore the outer-level definition of (.
4684
\ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi
4685
\global\advance \parencount by -1 }
4686
% If we encounter &foo, then turn on ()-hacking afterwards
4687
\gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ }
4689
\gdef\normalparens{\boldbrax\let&=\ampnr}
4690
} % End of definition inside \activeparens
4691
%% These parens (in \boldbrax) actually are a little bolder than the
4692
%% contained text. This is especially needed for [ and ]
4693
\def\opnr{{\sf\char`\(}\global\advance\parencount by 1 }
4694
\def\clnr{{\sf\char`\)}\global\advance\parencount by -1 }
4696
\def\lbrb{{\bf\char`\[}}
4697
\def\rbrb{{\bf\char`\]}}
4699
% Active &'s sneak into the index arguments, so make sure it's defined.
4702
\global\let& = \ampnr
4705
% First, defname, which formats the header line itself.
4706
% #1 should be the function name.
4707
% #2 should be the type of definition, such as "Function".
4710
% Get the values of \leftskip and \rightskip as they were
4711
% outside the @def...
4713
\advance\dimen2 by -\defbodyindent
4715
\setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}%
4716
\dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line
4717
\dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations
4718
\parshape 2 0in \dimen0 \defargsindent \dimen1
4719
% Now output arg 2 ("Function" or some such)
4720
% ending at \deftypemargin from the right margin,
4721
% but stuck inside a box of width 0 so it does not interfere with linebreaking
4722
{% Adjust \hsize to exclude the ambient margins,
4723
% so that \rightline will obey them.
4724
\advance \hsize by -\dimen2
4725
\rlap{\rightline{{\rm #2}\hskip -1.25pc }}}%
4726
% Make all lines underfull and no complaints:
4727
\tolerance=10000 \hbadness=10000
4728
\advance\leftskip by -\defbodyindent
4729
\exdentamount=\defbodyindent
4730
{\df #1}\enskip % Generate function name
4733
% Common pieces to start any @def...
4734
% #1 is the \E... control sequence to end the definition (which we define).
4735
% #2 is the \...x control sequence (which our caller defines).
4736
% #3 is the control sequence to process the header, such as \defunheader.
4738
\def\parsebodycommon#1#2#3{%
4740
% If there are two @def commands in a row, we'll have a \nobreak,
4741
% which is there to keep the function description together with its
4742
% header. But if there's nothing but headers, we want to allow a
4744
\ifnum\lastpenalty = 10000 \penalty0 \fi
4747
% Define the \E... end token that this defining construct specifies
4748
% so that it will exit this group.
4749
\def#1{\endgraf\endgroup\medbreak}%
4752
\advance\leftskip by \defbodyindent
4753
\exdentamount=\defbodyindent
4756
% Process body of @defun, @deffn, @defmac, etc.
4758
\def\defparsebody#1#2#3{%
4759
\parsebodycommon{#1}{#2}{#3}%
4760
\def#2{\begingroup\obeylines\activeparens\spacesplit#3}%
4761
\catcode61=\active % 61 is `='
4762
\begingroup\obeylines\activeparens
4766
% #1, #2, #3 are the common arguments (see \defparsebody).
4767
% #4, delimited by the space, is the class name.
4769
\def\defmethparsebody#1#2#3#4 {%
4770
\parsebodycommon{#1}{#2}{#3}%
4771
\def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}%
4772
\begingroup\obeylines\activeparens
4773
\spacesplit{#3{#4}}%
4776
% Used for @deftypemethod and @deftypeivar.
4777
% #1, #2, #3 are the common arguments (see \defparsebody).
4778
% #4, delimited by a space, is the class name.
4779
% #5 is the method's return type.
4781
\def\deftypemethparsebody#1#2#3#4 #5 {%
4782
\parsebodycommon{#1}{#2}{#3}%
4783
\def#2##1 ##2 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}{##2}}}%
4784
\begingroup\obeylines\activeparens
4785
\spacesplit{#3{#4}{#5}}%
4788
% Used for @deftypeop. The change from \deftypemethparsebody is an
4789
% extra argument at the beginning which is the `category', instead of it
4790
% being the hardwired string `Method' or `Instance Variable'. We have
4791
% to account for this both in the \...x definition and in parsing the
4792
% input at hand. Thus also need a control sequence (passed as #5) for
4793
% the \E... definition to assign the category name to.
4795
\def\deftypeopparsebody#1#2#3#4#5 #6 {%
4796
\parsebodycommon{#1}{#2}{#3}%
4797
\def#2##1 ##2 ##3 {%
4799
\begingroup\obeylines\activeparens\spacesplit{#3{##2}{##3}}}%
4800
\begingroup\obeylines\activeparens
4801
\spacesplit{#3{#5}{#6}}%
4805
\def\defopparsebody #1#2#3#4#5 {%
4806
\parsebodycommon{#1}{#2}{#3}%
4807
\def#2##1 ##2 {\def#4{##1}%
4808
\begingroup\obeylines\activeparens\spacesplit{#3{##2}}}%
4809
\begingroup\obeylines\activeparens
4810
\spacesplit{#3{#5}}%
4813
% These parsing functions are similar to the preceding ones
4814
% except that they do not make parens into active characters.
4815
% These are used for "variables" since they have no arguments.
4817
\def\defvarparsebody #1#2#3{%
4818
\parsebodycommon{#1}{#2}{#3}%
4819
\def#2{\begingroup\obeylines\spacesplit#3}%
4820
\catcode61=\active %
4821
\begingroup\obeylines
4826
\def\defopvarparsebody #1#2#3#4#5 {%
4827
\parsebodycommon{#1}{#2}{#3}%
4828
\def#2##1 ##2 {\def#4{##1}%
4829
\begingroup\obeylines\spacesplit{#3{##2}}}%
4830
\begingroup\obeylines
4831
\spacesplit{#3{#5}}%
4834
\def\defvrparsebody#1#2#3#4 {%
4835
\parsebodycommon{#1}{#2}{#3}%
4836
\def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}%
4837
\begingroup\obeylines
4838
\spacesplit{#3{#4}}%
4841
% This loses on `@deftp {Data Type} {struct termios}' -- it thinks the
4842
% type is just `struct', because we lose the braces in `{struct
4843
% termios}' when \spacesplit reads its undelimited argument. Sigh.
4844
% \let\deftpparsebody=\defvrparsebody
4846
% So, to get around this, we put \empty in with the type name. That
4847
% way, TeX won't find exactly `{...}' as an undelimited argument, and
4848
% won't strip off the braces.
4850
\def\deftpparsebody #1#2#3#4 {%
4851
\parsebodycommon{#1}{#2}{#3}%
4852
\def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}%
4853
\begingroup\obeylines
4854
\spacesplit{\parsetpheaderline{#3{#4}}}\empty
4857
% Fine, but then we have to eventually remove the \empty *and* the
4858
% braces (if any). That's what this does.
4860
\def\removeemptybraces\empty#1\relax{#1}
4862
% After \spacesplit has done its work, this is called -- #1 is the final
4863
% thing to call, #2 the type name (which starts with \empty), and #3
4864
% (which might be empty) the arguments.
4866
\def\parsetpheaderline#1#2#3{%
4867
#1{\removeemptybraces#2\relax}{#3}%
4870
% Split up #2 at the first space token.
4871
% call #1 with two arguments:
4872
% the first is all of #2 before the space token,
4873
% the second is all of #2 after that space token.
4874
% If #2 contains no space token, all of it is passed as the first arg
4875
% and the second is passed as empty.
4878
\gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}%
4879
\long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{%
4881
#1{#2}{}\else #1{#2}{#3#4}\fi}}
4885
% First, define the processing that is wanted for arguments of \defun
4886
% Use this to expand the args and terminate the paragraph they make up
4888
\def\defunargs#1{\functionparens \sl
4889
% Expand, preventing hyphenation at `-' chars.
4890
% Note that groups don't affect changes in \hyphenchar.
4891
% Set the font temporarily and use \font in case \setfont made \tensl a macro.
4892
{\tensl\hyphenchar\font=0}%
4894
{\tensl\hyphenchar\font=45}%
4895
\ifnum\parencount=0 \else \errmessage{Unbalanced parentheses in @def}\fi%
4896
\interlinepenalty=10000
4897
\advance\rightskip by 0pt plus 1fil
4898
\endgraf\nobreak\vskip -\parskip\nobreak
4901
\def\deftypefunargs #1{%
4902
% Expand, preventing hyphenation at `-' chars.
4903
% Note that groups don't affect changes in \hyphenchar.
4904
% Use \boldbraxnoamp, not \functionparens, so that & is not special.
4906
\tclose{#1}% avoid \code because of side effects on active chars
4907
\interlinepenalty=10000
4908
\advance\rightskip by 0pt plus 1fil
4909
\endgraf\nobreak\vskip -\parskip\nobreak
4912
% Do complete processing of one @defun or @defunx line already parsed.
4914
% @deffn Command forward-char nchars
4916
\def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader}
4918
\def\deffnheader #1#2#3{\doind {fn}{\code{#2}}%
4919
\begingroup\defname {#2}{#1}\defunargs{#3}\endgroup %
4920
\catcode 61=\other % Turn off change made in \defparsebody
4923
% @defun == @deffn Function
4925
\def\defun{\defparsebody\Edefun\defunx\defunheader}
4927
\def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
4928
\begingroup\defname {#1}{\putwordDeffunc}%
4929
\defunargs {#2}\endgroup %
4930
\catcode 61=\other % Turn off change made in \defparsebody
4933
% @deftypefun int foobar (int @var{foo}, float @var{bar})
4935
\def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader}
4937
% #1 is the data type. #2 is the name and args.
4938
\def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax}
4939
% #1 is the data type, #2 the name, #3 the args.
4940
\def\deftypefunheaderx #1#2 #3\relax{%
4941
\doind {fn}{\code{#2}}% Make entry in function index
4942
\begingroup\defname {\defheaderxcond#1\relax$.$#2}{\putwordDeftypefun}%
4943
\deftypefunargs {#3}\endgroup %
4944
\catcode 61=\other % Turn off change made in \defparsebody
4947
% @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar})
4949
\def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader}
4951
% \defheaderxcond#1\relax$.$
4952
% puts #1 in @code, followed by a space, but does nothing if #1 is null.
4953
\def\defheaderxcond#1#2$.${\ifx#1\relax\else\code{#1#2} \fi}
4955
% #1 is the classification. #2 is the data type. #3 is the name and args.
4956
\def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax}
4957
% #1 is the classification, #2 the data type, #3 the name, #4 the args.
4958
\def\deftypefnheaderx #1#2#3 #4\relax{%
4959
\doind {fn}{\code{#3}}% Make entry in function index
4961
\normalparens % notably, turn off `&' magic, which prevents
4962
% at least some C++ text from working
4963
\defname {\defheaderxcond#2\relax$.$#3}{#1}%
4964
\deftypefunargs {#4}\endgroup %
4965
\catcode 61=\other % Turn off change made in \defparsebody
4968
% @defmac == @deffn Macro
4970
\def\defmac{\defparsebody\Edefmac\defmacx\defmacheader}
4972
\def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
4973
\begingroup\defname {#1}{\putwordDefmac}%
4974
\defunargs {#2}\endgroup %
4975
\catcode 61=\other % Turn off change made in \defparsebody
4978
% @defspec == @deffn Special Form
4980
\def\defspec{\defparsebody\Edefspec\defspecx\defspecheader}
4982
\def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index
4983
\begingroup\defname {#1}{\putwordDefspec}%
4984
\defunargs {#2}\endgroup %
4985
\catcode 61=\other % Turn off change made in \defparsebody
4988
% @defop CATEGORY CLASS OPERATION ARG...
4990
\def\defop #1 {\def\defoptype{#1}%
4991
\defopparsebody\Edefop\defopx\defopheader\defoptype}
4993
\def\defopheader#1#2#3{%
4994
\dosubind {fn}{\code{#2}}{\putwordon\ #1}% Make entry in function index
4995
\begingroup\defname {#2}{\defoptype\ \putwordon\ #1}%
4996
\defunargs {#3}\endgroup %
4999
% @deftypeop CATEGORY CLASS TYPE OPERATION ARG...
5001
\def\deftypeop #1 {\def\deftypeopcategory{#1}%
5002
\deftypeopparsebody\Edeftypeop\deftypeopx\deftypeopheader
5005
% #1 is the class name, #2 the data type, #3 the operation name, #4 the args.
5006
\def\deftypeopheader#1#2#3#4{%
5007
\dosubind{fn}{\code{#3}}{\putwordon\ \code{#1}}% entry in function index
5009
\defname{\defheaderxcond#2\relax$.$#3}
5010
{\deftypeopcategory\ \putwordon\ \code{#1}}%
5011
\deftypefunargs{#4}%
5015
% @deftypemethod CLASS TYPE METHOD ARG...
5017
\def\deftypemethod{%
5018
\deftypemethparsebody\Edeftypemethod\deftypemethodx\deftypemethodheader}
5020
% #1 is the class name, #2 the data type, #3 the method name, #4 the args.
5021
\def\deftypemethodheader#1#2#3#4{%
5022
\dosubind{fn}{\code{#3}}{\putwordon\ \code{#1}}% entry in function index
5024
\defname{\defheaderxcond#2\relax$.$#3}{\putwordMethodon\ \code{#1}}%
5025
\deftypefunargs{#4}%
5029
% @deftypeivar CLASS TYPE VARNAME
5032
\deftypemethparsebody\Edeftypeivar\deftypeivarx\deftypeivarheader}
5034
% #1 is the class name, #2 the data type, #3 the variable name.
5035
\def\deftypeivarheader#1#2#3{%
5036
\dosubind{vr}{\code{#3}}{\putwordof\ \code{#1}}% entry in variable index
5038
\defname{\defheaderxcond#2\relax$.$#3}
5039
{\putwordInstanceVariableof\ \code{#1}}%
5044
% @defmethod == @defop Method
5046
\def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader}
5048
% #1 is the class name, #2 the method name, #3 the args.
5049
\def\defmethodheader#1#2#3{%
5050
\dosubind{fn}{\code{#2}}{\putwordon\ \code{#1}}% entry in function index
5052
\defname{#2}{\putwordMethodon\ \code{#1}}%
5057
% @defcv {Class Option} foo-class foo-flag
5059
\def\defcv #1 {\def\defcvtype{#1}%
5060
\defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype}
5062
\def\defcvarheader #1#2#3{%
5063
\dosubind {vr}{\code{#2}}{\putwordof\ #1}% Make entry in var index
5064
\begingroup\defname {#2}{\defcvtype\ \putwordof\ #1}%
5065
\defvarargs {#3}\endgroup %
5068
% @defivar CLASS VARNAME == @defcv {Instance Variable} CLASS VARNAME
5070
\def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader}
5072
\def\defivarheader#1#2#3{%
5073
\dosubind {vr}{\code{#2}}{\putwordof\ #1}% entry in var index
5075
\defname{#2}{\putwordInstanceVariableof\ #1}%
5081
% First, define the processing that is wanted for arguments of @defvar.
5082
% This is actually simple: just print them in roman.
5083
% This must expand the args and terminate the paragraph they make up
5084
\def\defvarargs #1{\normalparens #1%
5085
\interlinepenalty=10000
5086
\endgraf\nobreak\vskip -\parskip\nobreak}
5088
% @defvr Counter foo-count
5090
\def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader}
5092
\def\defvrheader #1#2#3{\doind {vr}{\code{#2}}%
5093
\begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup}
5095
% @defvar == @defvr Variable
5097
\def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader}
5099
\def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
5100
\begingroup\defname {#1}{\putwordDefvar}%
5101
\defvarargs {#2}\endgroup %
5104
% @defopt == @defvr {User Option}
5106
\def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader}
5108
\def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index
5109
\begingroup\defname {#1}{\putwordDefopt}%
5110
\defvarargs {#2}\endgroup %
5113
% @deftypevar int foobar
5115
\def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader}
5117
% #1 is the data type. #2 is the name, perhaps followed by text that
5118
% is actually part of the data type, which should not be put into the index.
5119
\def\deftypevarheader #1#2{%
5120
\dovarind#2 \relax% Make entry in variables index
5121
\begingroup\defname {\defheaderxcond#1\relax$.$#2}{\putwordDeftypevar}%
5122
\interlinepenalty=10000
5123
\endgraf\nobreak\vskip -\parskip\nobreak
5125
\def\dovarind#1 #2\relax{\doind{vr}{\code{#1}}}
5127
% @deftypevr {Global Flag} int enable
5129
\def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader}
5131
\def\deftypevrheader #1#2#3{\dovarind#3 \relax%
5132
\begingroup\defname {\defheaderxcond#2\relax$.$#3}{#1}
5133
\interlinepenalty=10000
5134
\endgraf\nobreak\vskip -\parskip\nobreak
5138
% Args are printed in bold, a slight difference from @defvar.
5140
\def\deftpargs #1{\bf \defvarargs{#1}}
5142
% @deftp Class window height width ...
5144
\def\deftp{\deftpparsebody\Edeftp\deftpx\deftpheader}
5146
\def\deftpheader #1#2#3{\doind {tp}{\code{#2}}%
5147
\begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup}
5149
% These definitions are used if you use @defunx (etc.)
5150
% anywhere other than immediately after a @defun or @defunx.
5152
\def\defcvx#1 {\errmessage{@defcvx in invalid context}}
5153
\def\deffnx#1 {\errmessage{@deffnx in invalid context}}
5154
\def\defivarx#1 {\errmessage{@defivarx in invalid context}}
5155
\def\defmacx#1 {\errmessage{@defmacx in invalid context}}
5156
\def\defmethodx#1 {\errmessage{@defmethodx in invalid context}}
5157
\def\defoptx #1 {\errmessage{@defoptx in invalid context}}
5158
\def\defopx#1 {\errmessage{@defopx in invalid context}}
5159
\def\defspecx#1 {\errmessage{@defspecx in invalid context}}
5160
\def\deftpx#1 {\errmessage{@deftpx in invalid context}}
5161
\def\deftypefnx#1 {\errmessage{@deftypefnx in invalid context}}
5162
\def\deftypefunx#1 {\errmessage{@deftypefunx in invalid context}}
5163
\def\deftypeivarx#1 {\errmessage{@deftypeivarx in invalid context}}
5164
\def\deftypemethodx#1 {\errmessage{@deftypemethodx in invalid context}}
5165
\def\deftypeopx#1 {\errmessage{@deftypeopx in invalid context}}
5166
\def\deftypevarx#1 {\errmessage{@deftypevarx in invalid context}}
5167
\def\deftypevrx#1 {\errmessage{@deftypevrx in invalid context}}
5168
\def\defunx#1 {\errmessage{@defunx in invalid context}}
5169
\def\defvarx#1 {\errmessage{@defvarx in invalid context}}
5170
\def\defvrx#1 {\errmessage{@defvrx in invalid context}}
5859
\infirstlevel \bfafterword
5864
\global\advance\parencount by -1
5867
\newcount\brackcount
5869
\global\advance\brackcount by 1
5874
\global\advance\brackcount by -1
5877
\def\checkparencounts{%
5878
\ifnum\parencount=0 \else \badparencount \fi
5879
\ifnum\brackcount=0 \else \badbrackcount \fi
5881
\def\badparencount{%
5882
\errmessage{Unbalanced parentheses in @def}%
5883
\global\parencount=0
5885
\def\badbrackcount{%
5886
\errmessage{Unbalanced square braces in @def}%
5887
\global\brackcount=0
5173
5891
\message{macros,}
5535
6292
\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
5537
6294
\def\printedmanual{\ignorespaces #5}%
5538
\def\printednodename{\ignorespaces #3}%
5539
\setbox1=\hbox{\printedmanual}%
5540
\setbox0=\hbox{\printednodename}%
6295
\def\printedrefname{\ignorespaces #3}%
6296
\setbox1=\hbox{\printedmanual\unskip}%
6297
\setbox0=\hbox{\printedrefname\unskip}%
5541
6298
\ifdim \wd0 = 0pt
5542
6299
% No printed node name was explicitly given.
5543
6300
\expandafter\ifx\csname SETxref-automatic-section-title\endcsname\relax
5544
6301
% Use the node name inside the square brackets.
5545
\def\printednodename{\ignorespaces #1}%
6302
\def\printedrefname{\ignorespaces #1}%
5547
6304
% Use the actual chapter/section title appear inside
5548
6305
% the square brackets. Use the real section title if we have it.
5549
6306
\ifdim \wd1 > 0pt
5550
6307
% It is in another manual, so we don't have it.
5551
\def\printednodename{\ignorespaces #1}%
6308
\def\printedrefname{\ignorespaces #1}%
5554
6311
% We know the real title if we have the xref values.
5555
\def\printednodename{\refx{#1-title}{}}%
6312
\def\printedrefname{\refx{#1-title}{}}%
5557
6314
% Otherwise just copy the Info node name.
5558
\def\printednodename{\ignorespaces #1}%
6315
\def\printedrefname{\ignorespaces #1}%
5564
% If we use \unhbox0 and \unhbox1 to print the node names, TeX does not
5565
% insert empty discretionaries after hyphens, which means that it will
5566
% not find a line break at a hyphen in a node names. Since some manuals
5567
% are best written with fairly long node names, containing hyphens, this
5568
% is a loss. Therefore, we give the text of the node name again, so it
5569
% is as if TeX is seeing it for the first time.
6321
% Make link in pdf output.
5572
6324
\getfilename{#4}%
5573
{\normalturnoffactive
6326
% See comments at \activebackslashdouble.
6327
{\activebackslashdouble \xdef\pdfxrefdest{#1}%
6328
\backslashparens\pdfxrefdest}%
5574
6330
\ifnum\filenamelength>0
5575
6331
\startlink attr{/Border [0 0 0]}%
5576
goto file{\the\filename.pdf} name{#1}%
6332
goto file{\the\filename.pdf} name{\pdfxrefdest}%
5578
6334
\startlink attr{/Border [0 0 0]}%
6335
goto name{\pdfmkpgn{\pdfxrefdest}}%
5586
\putwordsection{} ``\printednodename'' \putwordin{} \cite{\printedmanual}%
6341
% Float references are printed completely differently: "Figure 1.2"
6342
% instead of "[somenode], p.3". We distinguish them by the
6343
% LABEL-title being set to a magic string.
6345
% Have to otherify everything special to allow the \csname to
6346
% include an _ in the xref name, etc.
6349
\expandafter\global\expandafter\let\expandafter\Xthisreftitle
6350
\csname XR#1-title\endcsname
6352
\iffloat\Xthisreftitle
6353
% If the user specified the print name (third arg) to the ref,
6354
% print it instead of our usual "Figure 1.2".
6361
% if the user also gave the printed manual name (fifth arg), append
6364
\space \putwordin{} \cite{\printedmanual}%
5588
% _ (for example) has to be the character _ for the purposes of the
5589
% control sequence corresponding to the node, but it has to expand
5590
% into the usual \leavevmode...\vrule stuff for purposes of
5591
% printing. So we \turnoffactive for the \refx-snt, back on for the
5592
% printing, back off for the \refx-pg.
5593
{\normalturnoffactive
5594
% Only output a following space if the -snt ref is nonempty; for
5595
% @unnumbered and @anchor, it won't be.
5596
\setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
5597
\ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
5600
[\printednodename],\space
5602
\turnoffactive \putwordpage\tie\refx{#1-pg}{}%
6367
% node/anchor (non-float) references.
6369
% If we use \unhbox0 and \unhbox1 to print the node names, TeX does not
6370
% insert empty discretionaries after hyphens, which means that it will
6371
% not find a line break at a hyphen in a node names. Since some manuals
6372
% are best written with fairly long node names, containing hyphens, this
6373
% is a loss. Therefore, we give the text of the node name again, so it
6374
% is as if TeX is seeing it for the first time.
6376
\putwordsection{} ``\printedrefname'' \putwordin{} \cite{\printedmanual}%
6378
% _ (for example) has to be the character _ for the purposes of the
6379
% control sequence corresponding to the node, but it has to expand
6380
% into the usual \leavevmode...\vrule stuff for purposes of
6381
% printing. So we \turnoffactive for the \refx-snt, back on for the
6382
% printing, back off for the \refx-pg.
6384
% Only output a following space if the -snt ref is nonempty; for
6385
% @unnumbered and @anchor, it won't be.
6386
\setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
6387
\ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
6389
% output the `[mynode]' via a macro so it can be overridden.
6390
\xrefprintnodename\printedrefname
6392
% But we always want a comma and a space:
6395
% output the `page 3'.
6396
\turnoffactive \putwordpage\tie\refx{#1-pg}{}%
5607
% \dosetq is the interface for calls from other macros
5609
% Use \normalturnoffactive so that punctuation chars such as underscore
5610
% and backslash work in node names. (\turnoffactive doesn't do \.)
5613
\normalturnoffactive
5614
\edef\next{\write\auxfile{\internalsetq{#1}{#2}}}%
5621
% \internalsetq {foo}{page} expands into
5622
% CHARACTERS 'xrdef {foo}{...expansion of \Ypage...}
5623
% When the aux file is read, ' is the escape character
5625
\def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}}
5627
% Things to be expanded by \internalsetq
5629
\def\Ypagenumber{\folio}
5631
\def\Ytitle{\thissection}
6402
% This macro is called from \xrefX for the `[nodename]' part of xref
6403
% output. It's a separate macro only so it can be changed more easily,
6404
% since square brackets don't work well in some documents. Particularly
6405
% one that Bob is working on :).
6407
\def\xrefprintnodename#1{[#1]}
6409
% Things referred to by \setref.
5633
6411
\def\Ynothing{}
5635
\def\Ysectionnumberandtype{%
5636
\ifnum\secno=0 \putwordChapter\xreftie\the\chapno %
5637
\else \ifnum \subsecno=0 \putwordSection\xreftie\the\chapno.\the\secno %
5638
\else \ifnum \subsubsecno=0 %
5639
\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno %
5641
\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno %
5644
\def\Yappendixletterandtype{%
5645
\ifnum\secno=0 \putwordAppendix\xreftie'char\the\appendixno{}%
5646
\else \ifnum \subsecno=0 \putwordSection\xreftie'char\the\appendixno.\the\secno %
5647
\else \ifnum \subsubsecno=0 %
5648
\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno %
5650
\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno %
5655
% Use TeX 3.0's \inputlineno to get the line number, for better error
5656
% messages, but if we're using an old version of TeX, don't do anything.
5658
\ifx\inputlineno\thisisundefined
5659
\let\linenumber = \empty % Non-3.0.
5661
\def\linenumber{\the\inputlineno:\space}
6415
\putwordChapter@tie \the\chapno
6416
\else \ifnum\subsecno=0
6417
\putwordSection@tie \the\chapno.\the\secno
6418
\else \ifnum\subsubsecno=0
6419
\putwordSection@tie \the\chapno.\the\secno.\the\subsecno
6421
\putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno
6426
\putwordAppendix@tie @char\the\appendixno{}%
6427
\else \ifnum\subsecno=0
6428
\putwordSection@tie @char\the\appendixno.\the\secno
6429
\else \ifnum\subsubsecno=0
6430
\putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno
6433
@char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno
5664
6437
% Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
5665
6438
% If its value is nonempty, SUFFIX is output afterward.
5667
6440
\def\refx#1#2{%
5668
\expandafter\ifx\csname X#1\endcsname\relax
6444
\expandafter\global\expandafter\let\expandafter\thisrefX
6445
\csname XR#1\endcsname
5669
6448
% If not defined, say something at least.
5670
6449
\angleleft un\-de\-fined\angleright
5965
6796
\epsfbox{#1.eps}%
5968
\ifimagevmode \hss \egroup \bigbreak \fi % space after the image
6799
\ifimagevmode \egroup \bigbreak \fi % space after the image
6803
% @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables,
6804
% etc. We don't actually implement floating yet, we always include the
6805
% float "here". But it seemed the best name for the future.
6807
\envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish}
6809
% There may be a space before second and/or third parameter; delete it.
6810
\def\eatcommaspace#1, {#1,}
6812
% #1 is the optional FLOATTYPE, the text label for this float, typically
6813
% "Figure", "Table", "Example", etc. Can't contain commas. If omitted,
6814
% this float will not be numbered and cannot be referred to.
6816
% #2 is the optional xref label. Also must be present for the float to
6819
% #3 is the optional positioning argument; for now, it is ignored. It
6820
% will somehow specify the positions allowed to float to (here, top, bottom).
6822
% We keep a separate counter for each FLOATTYPE, which we reset at each
6823
% chapter-level command.
6824
\let\resetallfloatnos=\empty
6826
\def\dofloat#1,#2,#3,#4\finish{%
6827
\let\thiscaption=\empty
6828
\let\thisshortcaption=\empty
6830
% don't lose footnotes inside @float.
6832
% BEWARE: when the floats start float, we have to issue warning whenever an
6833
% insert appears inside a float which could possibly float. --kasal, 26may04
6837
% We can't be used inside a paragraph.
6842
\def\floatlabel{#2}%
6843
\def\floatloc{#3}% we do nothing with this yet.
6845
\ifx\floattype\empty
6846
\let\safefloattype=\empty
6849
% the floattype might have accents or other special characters,
6850
% but we need to use it in a control sequence name.
6853
\xdef\safefloattype{\floattype}%
6857
% If label is given but no type, we handle that as the empty type.
6858
\ifx\floatlabel\empty \else
6859
% We want each FLOATTYPE to be numbered separately (Figure 1,
6860
% Table 1, Figure 2, ...). (And if no label, no number.)
6862
\expandafter\getfloatno\csname\safefloattype floatno\endcsname
6863
\global\advance\floatno by 1
6866
% This magic value for \thissection is output by \setref as the
6867
% XREFLABEL-title value. \xrefX uses it to distinguish float
6868
% labels (which have a completely different output format) from
6869
% node and anchor labels. And \xrdef uses it to construct the
6872
\edef\thissection{\floatmagic=\safefloattype}%
6873
\setref{\floatlabel}{Yfloat}%
6877
% start with \parskip glue, I guess.
6880
% Don't suppress indentation if a float happens to start a section.
6881
\restorefirstparagraphindent
6884
% we have these possibilities:
6885
% @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap
6886
% @float Foo,lbl & no caption: Foo 1.1
6887
% @float Foo & @caption{Cap}: Foo: Cap
6888
% @float Foo & no caption: Foo
6889
% @float ,lbl & Caption{Cap}: 1.1: Cap
6890
% @float ,lbl & no caption: 1.1
6891
% @float & @caption{Cap}: Cap
6892
% @float & no caption:
6895
\let\floatident = \empty
6897
% In all cases, if we have a float type, it comes first.
6898
\ifx\floattype\empty \else \def\floatident{\floattype}\fi
6900
% If we have an xref label, the number comes next.
6901
\ifx\floatlabel\empty \else
6902
\ifx\floattype\empty \else % if also had float type, need tie first.
6903
\appendtomacro\floatident{\tie}%
6906
\appendtomacro\floatident{\chaplevelprefix\the\floatno}%
6909
% Start the printed caption with what we've constructed in
6910
% \floatident, but keep it separate; we need \floatident again.
6911
\let\captionline = \floatident
6913
\ifx\thiscaption\empty \else
6914
\ifx\floatident\empty \else
6915
\appendtomacro\captionline{: }% had ident, so need a colon between
6919
\appendtomacro\captionline{\scanexp\thiscaption}%
6922
% If we have anything to print, print it, with space before.
6923
% Eventually this needs to become an \insert.
6924
\ifx\captionline\empty \else
6928
% Space below caption.
6932
% If have an xref label, write the list of floats info. Do this
6933
% after the caption, to avoid chance of it being a breakpoint.
6934
\ifx\floatlabel\empty \else
6935
% Write the text that goes in the lof to the aux file as
6936
% \floatlabel-lof. Besides \floatident, we include the short
6937
% caption if specified, else the full caption if specified, else nothing.
6941
% since we read the caption text in the macro world, where ^^M
6942
% is turned into a normal character, we have to scan it back, so
6943
% we don't write the literal three characters "^^M" into the aux file.
6945
\xdef\noexpand\gtemp{%
6946
\ifx\thisshortcaption\empty
6953
\immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident
6954
\ifx\gtemp\empty \else : \gtemp \fi}}%
6957
\egroup % end of \vtop
6959
% place the captured inserts
6961
% BEWARE: when the floats start floating, we have to issue warning
6962
% whenever an insert appears inside a float which could possibly
6963
% float. --kasal, 26may04
6968
% Append the tokens #2 to the definition of macro #1, not expanding either.
6970
\def\appendtomacro#1#2{%
6971
\expandafter\def\expandafter#1\expandafter{#1#2}%
6974
% @caption, @shortcaption
6976
\def\caption{\docaption\thiscaption}
6977
\def\shortcaption{\docaption\thisshortcaption}
6978
\def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption}
6979
\def\defcaption#1#2{\egroup \def#1{#2}}
6981
% The parameter is the control sequence identifying the counter we are
6982
% going to use. Create it if it doesn't exist and assign it to \floatno.
6985
% Haven't seen this figure type before.
6986
\csname newcount\endcsname #1%
6988
% Remember to reset this floatno at the next chap.
6989
\expandafter\gdef\expandafter\resetallfloatnos
6990
\expandafter{\resetallfloatnos #1=0 }%
6995
% \setref calls this to get the XREFLABEL-snt value. We want an @xref
6996
% to the FLOATLABEL to expand to "Figure 3.1". We call \setref when we
6997
% first read the @float command.
6999
\def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}%
7001
% Magic string used for the XREFLABEL-title value, so \xrefX can
7002
% distinguish floats from other xref types.
7003
\def\floatmagic{!!float!!}
7005
% #1 is the control sequence we are passed; we expand into a conditional
7006
% which is true if #1 represents a float ref. That is, the magic
7007
% \thissection value which we \setref above.
7009
\def\iffloat#1{\expandafter\doiffloat#1==\finish}
7011
% #1 is (maybe) the \floatmagic string. If so, #2 will be the
7012
% (safe) float type for this float. We set \iffloattype to #2.
7014
\def\doiffloat#1=#2=#3\finish{%
7016
\def\iffloattype{#2}%
7017
\ifx\temp\floatmagic
7020
% @listoffloats FLOATTYPE - print a list of floats like a table of contents.
7022
\parseargdef\listoffloats{%
7023
\def\floattype{#1}% floattype
7025
% the floattype might have accents or other special characters,
7026
% but we need to use it in a control sequence name.
7029
\xdef\safefloattype{\floattype}%
7032
% \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE.
7033
\expandafter\ifx\csname floatlist\safefloattype\endcsname \relax
7035
% if the user said @listoffloats foo but never @float foo.
7036
\message{\linenumber No `\safefloattype' floats to list.}%
7040
\leftskip=\tocindent % indent these entries like a toc
7041
\let\do=\listoffloatsdo
7042
\csname floatlist\safefloattype\endcsname
7047
% This is called on each entry in a list of floats. We're passed the
7048
% xref label, in the form LABEL-title, which is how we save it in the
7049
% aux file. We strip off the -title and look up \XRLABEL-lof, which
7050
% has the text we're supposed to typeset here.
7052
% Figures without xref labels will not be included in the list (since
7053
% they won't appear in the aux file).
7055
\def\listoffloatsdo#1{\listoffloatsdoentry#1\finish}
7056
\def\listoffloatsdoentry#1-title\finish{{%
7057
% Can't fully expand XR#1-lof because it can contain anything. Just
7058
% pass the control sequence. On the other hand, XR#1-pg is just the
7059
% page number, and we want to fully expand that so we can get a link
7061
\toksA = \expandafter{\csname XR#1-lof\endcsname}%
7063
% use the same \entry macro we use to generate the TOC and index.
7064
\edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}%
5972
7068
\message{localization,}