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