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