
Chris@10: % texinfo.tex -- TeX macros to handle Texinfo files.
Chris@10: % 
Chris@10: % Load plain if necessary, i.e., if running under initex.
Chris@10: \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
Chris@10: %
Chris@10: \def\texinfoversion{2012-03-11.15}
Chris@10: %
Chris@10: % Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
Chris@10: % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
Chris@10: % 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
Chris@10: %
Chris@10: % This texinfo.tex file is free software: you can redistribute it and/or
Chris@10: % modify it under the terms of the GNU General Public License as
Chris@10: % published by the Free Software Foundation, either version 3 of the
Chris@10: % License, or (at your option) any later version.
Chris@10: %
Chris@10: % This texinfo.tex file is distributed in the hope that it will be
Chris@10: % useful, but WITHOUT ANY WARRANTY; without even the implied warranty
Chris@10: % of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Chris@10: % General Public License for more details.
Chris@10: %
Chris@10: % You should have received a copy of the GNU General Public License
Chris@10: % along with this program.  If not, see <http://www.gnu.org/licenses/>.
Chris@10: %
Chris@10: % As a special exception, when this file is read by TeX when processing
Chris@10: % a Texinfo source document, you may use the result without
Chris@10: % restriction.  (This has been our intent since Texinfo was invented.)
Chris@10: %
Chris@10: % Please try the latest version of texinfo.tex before submitting bug
Chris@10: % reports; you can get the latest version from:
Chris@10: %   http://www.gnu.org/software/texinfo/ (the Texinfo home page), or
Chris@10: %   ftp://tug.org/tex/texinfo.tex
Chris@10: %     (and all CTAN mirrors, see http://www.ctan.org).
Chris@10: % The texinfo.tex in any given distribution could well be out
Chris@10: % of date, so if that's what you're using, please check.
Chris@10: %
Chris@10: % Send bug reports to bug-texinfo@gnu.org.  Please include including a
Chris@10: % complete document in each bug report with which we can reproduce the
Chris@10: % problem.  Patches are, of course, greatly appreciated.
Chris@10: %
Chris@10: % To process a Texinfo manual with TeX, it's most reliable to use the
Chris@10: % texi2dvi shell script that comes with the distribution.  For a simple
Chris@10: % manual foo.texi, however, you can get away with this:
Chris@10: %   tex foo.texi
Chris@10: %   texindex foo.??
Chris@10: %   tex foo.texi
Chris@10: %   tex foo.texi
Chris@10: %   dvips foo.dvi -o  # or whatever; this makes foo.ps.
Chris@10: % The extra TeX runs get the cross-reference information correct.
Chris@10: % Sometimes one run after texindex suffices, and sometimes you need more
Chris@10: % than two; texi2dvi does it as many times as necessary.
Chris@10: %
Chris@10: % It is possible to adapt texinfo.tex for other languages, to some
Chris@10: % extent.  You can get the existing language-specific files from the
Chris@10: % full Texinfo distribution.
Chris@10: %
Chris@10: % The GNU Texinfo home page is http://www.gnu.org/software/texinfo.
Chris@10: 
Chris@10: 
Chris@10: \message{Loading texinfo [version \texinfoversion]:}
Chris@10: 
Chris@10: % If in a .fmt file, print the version number
Chris@10: % and turn on active characters that we couldn't do earlier because
Chris@10: % they might have appeared in the input file name.
Chris@10: \everyjob{\message{[Texinfo version \texinfoversion]}%
Chris@10:   \catcode`+=\active \catcode`\_=\active}
Chris@10: 
Chris@10: \chardef\other=12
Chris@10: 
Chris@10: % We never want plain's \outer definition of \+ in Texinfo.
Chris@10: % For @tex, we can use \tabalign.
Chris@10: \let\+ = \relax
Chris@10: 
Chris@10: % Save some plain tex macros whose names we will redefine.
Chris@10: \let\ptexb=\b
Chris@10: \let\ptexbullet=\bullet
Chris@10: \let\ptexc=\c
Chris@10: \let\ptexcomma=\,
Chris@10: \let\ptexdot=\.
Chris@10: \let\ptexdots=\dots
Chris@10: \let\ptexend=\end
Chris@10: \let\ptexequiv=\equiv
Chris@10: \let\ptexexclam=\!
Chris@10: \let\ptexfootnote=\footnote
Chris@10: \let\ptexgtr=>
Chris@10: \let\ptexhat=^
Chris@10: \let\ptexi=\i
Chris@10: \let\ptexindent=\indent
Chris@10: \let\ptexinsert=\insert
Chris@10: \let\ptexlbrace=\{
Chris@10: \let\ptexless=<
Chris@10: \let\ptexnewwrite\newwrite
Chris@10: \let\ptexnoindent=\noindent
Chris@10: \let\ptexplus=+
Chris@10: \let\ptexraggedright=\raggedright
Chris@10: \let\ptexrbrace=\}
Chris@10: \let\ptexslash=\/
Chris@10: \let\ptexstar=\*
Chris@10: \let\ptext=\t
Chris@10: \let\ptextop=\top
Chris@10: {\catcode`\'=\active \global\let\ptexquoteright'}% active in plain's math mode
Chris@10: 
Chris@10: % If this character appears in an error message or help string, it
Chris@10: % starts a new line in the output.
Chris@10: \newlinechar = `^^J
Chris@10: 
Chris@10: % Use TeX 3.0's \inputlineno to get the line number, for better error
Chris@10: % messages, but if we're using an old version of TeX, don't do anything.
Chris@10: %
Chris@10: \ifx\inputlineno\thisisundefined
Chris@10:   \let\linenumber = \empty % Pre-3.0.
Chris@10: \else
Chris@10:   \def\linenumber{l.\the\inputlineno:\space}
Chris@10: \fi
Chris@10: 
Chris@10: % Set up fixed words for English if not already set.
Chris@10: \ifx\putwordAppendix\undefined  \gdef\putwordAppendix{Appendix}\fi
Chris@10: \ifx\putwordChapter\undefined   \gdef\putwordChapter{Chapter}\fi
Chris@10: \ifx\putworderror\undefined     \gdef\putworderror{error}\fi
Chris@10: \ifx\putwordfile\undefined      \gdef\putwordfile{file}\fi
Chris@10: \ifx\putwordin\undefined        \gdef\putwordin{in}\fi
Chris@10: \ifx\putwordIndexIsEmpty\undefined       \gdef\putwordIndexIsEmpty{(Index is empty)}\fi
Chris@10: \ifx\putwordIndexNonexistent\undefined   \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi
Chris@10: \ifx\putwordInfo\undefined      \gdef\putwordInfo{Info}\fi
Chris@10: \ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi
Chris@10: \ifx\putwordMethodon\undefined  \gdef\putwordMethodon{Method on}\fi
Chris@10: \ifx\putwordNoTitle\undefined   \gdef\putwordNoTitle{No Title}\fi
Chris@10: \ifx\putwordof\undefined        \gdef\putwordof{of}\fi
Chris@10: \ifx\putwordon\undefined        \gdef\putwordon{on}\fi
Chris@10: \ifx\putwordpage\undefined      \gdef\putwordpage{page}\fi
Chris@10: \ifx\putwordsection\undefined   \gdef\putwordsection{section}\fi
Chris@10: \ifx\putwordSection\undefined   \gdef\putwordSection{Section}\fi
Chris@10: \ifx\putwordsee\undefined       \gdef\putwordsee{see}\fi
Chris@10: \ifx\putwordSee\undefined       \gdef\putwordSee{See}\fi
Chris@10: \ifx\putwordShortTOC\undefined  \gdef\putwordShortTOC{Short Contents}\fi
Chris@10: \ifx\putwordTOC\undefined       \gdef\putwordTOC{Table of Contents}\fi
Chris@10: %
Chris@10: \ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi
Chris@10: \ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi
Chris@10: \ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi
Chris@10: \ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi
Chris@10: \ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi
Chris@10: \ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi
Chris@10: \ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi
Chris@10: \ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi
Chris@10: \ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi
Chris@10: \ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi
Chris@10: \ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi
Chris@10: \ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi
Chris@10: %
Chris@10: \ifx\putwordDefmac\undefined    \gdef\putwordDefmac{Macro}\fi
Chris@10: \ifx\putwordDefspec\undefined   \gdef\putwordDefspec{Special Form}\fi
Chris@10: \ifx\putwordDefvar\undefined    \gdef\putwordDefvar{Variable}\fi
Chris@10: \ifx\putwordDefopt\undefined    \gdef\putwordDefopt{User Option}\fi
Chris@10: \ifx\putwordDeffunc\undefined   \gdef\putwordDeffunc{Function}\fi
Chris@10: 
Chris@10: % Since the category of space is not known, we have to be careful.
Chris@10: \chardef\spacecat = 10
Chris@10: \def\spaceisspace{\catcode`\ =\spacecat}
Chris@10: 
Chris@10: % sometimes characters are active, so we need control sequences.
Chris@10: \chardef\ampChar   = `\&
Chris@10: \chardef\colonChar = `\:
Chris@10: \chardef\commaChar = `\,
Chris@10: \chardef\dashChar  = `\-
Chris@10: \chardef\dotChar   = `\.
Chris@10: \chardef\exclamChar= `\!
Chris@10: \chardef\hashChar  = `\#
Chris@10: \chardef\lquoteChar= `\`
Chris@10: \chardef\questChar = `\?
Chris@10: \chardef\rquoteChar= `\'
Chris@10: \chardef\semiChar  = `\;
Chris@10: \chardef\slashChar = `\/
Chris@10: \chardef\underChar = `\_
Chris@10: 
Chris@10: % Ignore a token.
Chris@10: %
Chris@10: \def\gobble#1{}
Chris@10: 
Chris@10: % The following is used inside several \edef's.
Chris@10: \def\makecsname#1{\expandafter\noexpand\csname#1\endcsname}
Chris@10: 
Chris@10: % Hyphenation fixes.
Chris@10: \hyphenation{
Chris@10:   Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script
Chris@10:   ap-pen-dix bit-map bit-maps
Chris@10:   data-base data-bases eshell fall-ing half-way long-est man-u-script
Chris@10:   man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm
Chris@10:   par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces
Chris@10:   spell-ing spell-ings
Chris@10:   stand-alone strong-est time-stamp time-stamps which-ever white-space
Chris@10:   wide-spread wrap-around
Chris@10: }
Chris@10: 
Chris@10: % Margin to add to right of even pages, to left of odd pages.
Chris@10: \newdimen\bindingoffset
Chris@10: \newdimen\normaloffset
Chris@10: \newdimen\pagewidth \newdimen\pageheight
Chris@10: 
Chris@10: % For a final copy, take out the rectangles
Chris@10: % that mark overfull boxes (in case you have decided
Chris@10: % that the text looks ok even though it passes the margin).
Chris@10: %
Chris@10: \def\finalout{\overfullrule=0pt }
Chris@10: 
Chris@10: % Sometimes it is convenient to have everything in the transcript file
Chris@10: % and nothing on the terminal.  We don't just call \tracingall here,
Chris@10: % since that produces some useless output on the terminal.  We also make
Chris@10: % some effort to order the tracing commands to reduce output in the log
Chris@10: % file; cf. trace.sty in LaTeX.
Chris@10: %
Chris@10: \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
Chris@10: \def\loggingall{%
Chris@10:   \tracingstats2
Chris@10:   \tracingpages1
Chris@10:   \tracinglostchars2  % 2 gives us more in etex
Chris@10:   \tracingparagraphs1
Chris@10:   \tracingoutput1
Chris@10:   \tracingmacros2
Chris@10:   \tracingrestores1
Chris@10:   \showboxbreadth\maxdimen \showboxdepth\maxdimen
Chris@10:   \ifx\eTeXversion\thisisundefined\else % etex gives us more logging
Chris@10:     \tracingscantokens1
Chris@10:     \tracingifs1
Chris@10:     \tracinggroups1
Chris@10:     \tracingnesting2
Chris@10:     \tracingassigns1
Chris@10:   \fi
Chris@10:   \tracingcommands3  % 3 gives us more in etex
Chris@10:   \errorcontextlines16
Chris@10: }%
Chris@10: 
Chris@10: % @errormsg{MSG}.  Do the index-like expansions on MSG, but if things
Chris@10: % aren't perfect, it's not the end of the world, being an error message,
Chris@10: % after all.
Chris@10: % 
Chris@10: \def\errormsg{\begingroup \indexnofonts \doerrormsg}
Chris@10: \def\doerrormsg#1{\errmessage{#1}}
Chris@10: 
Chris@10: % add check for \lastpenalty to plain's definitions.  If the last thing
Chris@10: % we did was a \nobreak, we don't want to insert more space.
Chris@10: %
Chris@10: \def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount
Chris@10:   \removelastskip\penalty-50\smallskip\fi\fi}
Chris@10: \def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount
Chris@10:   \removelastskip\penalty-100\medskip\fi\fi}
Chris@10: \def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount
Chris@10:   \removelastskip\penalty-200\bigskip\fi\fi}
Chris@10: 
Chris@10: % Do @cropmarks to get crop marks.
Chris@10: %
Chris@10: \newif\ifcropmarks
Chris@10: \let\cropmarks = \cropmarkstrue
Chris@10: %
Chris@10: % Dimensions to add cropmarks at corners.
Chris@10: % Added by P. A. MacKay, 12 Nov. 1986
Chris@10: %
Chris@10: \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines
Chris@10: \newdimen\cornerlong  \cornerlong=1pc
Chris@10: \newdimen\cornerthick \cornerthick=.3pt
Chris@10: \newdimen\topandbottommargin \topandbottommargin=.75in
Chris@10: 
Chris@10: % Output a mark which sets \thischapter, \thissection and \thiscolor.
Chris@10: % We dump everything together because we only have one kind of mark.
Chris@10: % This works because we only use \botmark / \topmark, not \firstmark.
Chris@10: %
Chris@10: % A mark contains a subexpression of the \ifcase ... \fi construct.
Chris@10: % \get*marks macros below extract the needed part using \ifcase.
Chris@10: %
Chris@10: % Another complication is to let the user choose whether \thischapter
Chris@10: % (\thissection) refers to the chapter (section) in effect at the top
Chris@10: % of a page, or that at the bottom of a page.  The solution is
Chris@10: % described on page 260 of The TeXbook.  It involves outputting two
Chris@10: % marks for the sectioning macros, one before the section break, and
Chris@10: % one after.  I won't pretend I can describe this better than DEK...
Chris@10: \def\domark{%
Chris@10:   \toks0=\expandafter{\lastchapterdefs}%
Chris@10:   \toks2=\expandafter{\lastsectiondefs}%
Chris@10:   \toks4=\expandafter{\prevchapterdefs}%
Chris@10:   \toks6=\expandafter{\prevsectiondefs}%
Chris@10:   \toks8=\expandafter{\lastcolordefs}%
Chris@10:   \mark{%
Chris@10:                    \the\toks0 \the\toks2
Chris@10:       \noexpand\or \the\toks4 \the\toks6
Chris@10:     \noexpand\else \the\toks8
Chris@10:   }%
Chris@10: }
Chris@10: % \topmark doesn't work for the very first chapter (after the title
Chris@10: % page or the contents), so we use \firstmark there -- this gets us
Chris@10: % the mark with the chapter defs, unless the user sneaks in, e.g.,
Chris@10: % @setcolor (or @url, or @link, etc.) between @contents and the very
Chris@10: % first @chapter.
Chris@10: \def\gettopheadingmarks{%
Chris@10:   \ifcase0\topmark\fi
Chris@10:   \ifx\thischapter\empty \ifcase0\firstmark\fi \fi
Chris@10: }
Chris@10: \def\getbottomheadingmarks{\ifcase1\botmark\fi}
Chris@10: \def\getcolormarks{\ifcase2\topmark\fi}
Chris@10: 
Chris@10: % Avoid "undefined control sequence" errors.
Chris@10: \def\lastchapterdefs{}
Chris@10: \def\lastsectiondefs{}
Chris@10: \def\prevchapterdefs{}
Chris@10: \def\prevsectiondefs{}
Chris@10: \def\lastcolordefs{}
Chris@10: 
Chris@10: % Main output routine.
Chris@10: \chardef\PAGE = 255
Chris@10: \output = {\onepageout{\pagecontents\PAGE}}
Chris@10: 
Chris@10: \newbox\headlinebox
Chris@10: \newbox\footlinebox
Chris@10: 
Chris@10: % \onepageout takes a vbox as an argument.  Note that \pagecontents
Chris@10: % does insertions, but you have to call it yourself.
Chris@10: \def\onepageout#1{%
Chris@10:   \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi
Chris@10:   %
Chris@10:   \ifodd\pageno  \advance\hoffset by \bindingoffset
Chris@10:   \else \advance\hoffset by -\bindingoffset\fi
Chris@10:   %
Chris@10:   % Do this outside of the \shipout so @code etc. will be expanded in
Chris@10:   % the headline as they should be, not taken literally (outputting ''code).
Chris@10:   \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi
Chris@10:   \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}%
Chris@10:   \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi
Chris@10:   \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}%
Chris@10:   %
Chris@10:   {%
Chris@10:     % Have to do this stuff outside the \shipout because we want it to
Chris@10:     % take effect in \write's, yet the group defined by the \vbox ends
Chris@10:     % before the \shipout runs.
Chris@10:     %
Chris@10:     \indexdummies         % don't expand commands in the output.
Chris@10:     \normalturnoffactive  % \ in index entries must not stay \, e.g., if
Chris@10:                % the page break happens to be in the middle of an example.
Chris@10:                % We don't want .vr (or whatever) entries like this:
Chris@10:                % \entry{{\tt \indexbackslash }acronym}{32}{\code {\acronym}}
Chris@10:                % "\acronym" won't work when it's read back in;
Chris@10:                % it needs to be
Chris@10:                % {\code {{\tt \backslashcurfont }acronym}
Chris@10:     \shipout\vbox{%
Chris@10:       % Do this early so pdf references go to the beginning of the page.
Chris@10:       \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi
Chris@10:       %
Chris@10:       \ifcropmarks \vbox to \outervsize\bgroup
Chris@10:         \hsize = \outerhsize
Chris@10:         \vskip-\topandbottommargin
Chris@10:         \vtop to0pt{%
Chris@10:           \line{\ewtop\hfil\ewtop}%
Chris@10:           \nointerlineskip
Chris@10:           \line{%
Chris@10:             \vbox{\moveleft\cornerthick\nstop}%
Chris@10:             \hfill
Chris@10:             \vbox{\moveright\cornerthick\nstop}%
Chris@10:           }%
Chris@10:           \vss}%
Chris@10:         \vskip\topandbottommargin
Chris@10:         \line\bgroup
Chris@10:           \hfil % center the page within the outer (page) hsize.
Chris@10:           \ifodd\pageno\hskip\bindingoffset\fi
Chris@10:           \vbox\bgroup
Chris@10:       \fi
Chris@10:       %
Chris@10:       \unvbox\headlinebox
Chris@10:       \pagebody{#1}%
Chris@10:       \ifdim\ht\footlinebox > 0pt
Chris@10:         % Only leave this space if the footline is nonempty.
Chris@10:         % (We lessened \vsize for it in \oddfootingyyy.)
Chris@10:         % The \baselineskip=24pt in plain's \makefootline has no effect.
Chris@10:         \vskip 24pt
Chris@10:         \unvbox\footlinebox
Chris@10:       \fi
Chris@10:       %
Chris@10:       \ifcropmarks
Chris@10:           \egroup % end of \vbox\bgroup
Chris@10:         \hfil\egroup % end of (centering) \line\bgroup
Chris@10:         \vskip\topandbottommargin plus1fill minus1fill
Chris@10:         \boxmaxdepth = \cornerthick
Chris@10:         \vbox to0pt{\vss
Chris@10:           \line{%
Chris@10:             \vbox{\moveleft\cornerthick\nsbot}%
Chris@10:             \hfill
Chris@10:             \vbox{\moveright\cornerthick\nsbot}%
Chris@10:           }%
Chris@10:           \nointerlineskip
Chris@10:           \line{\ewbot\hfil\ewbot}%
Chris@10:         }%
Chris@10:       \egroup % \vbox from first cropmarks clause
Chris@10:       \fi
Chris@10:     }% end of \shipout\vbox
Chris@10:   }% end of group with \indexdummies
Chris@10:   \advancepageno
Chris@10:   \ifnum\outputpenalty>-20000 \else\dosupereject\fi
Chris@10: }
Chris@10: 
Chris@10: \newinsert\margin \dimen\margin=\maxdimen
Chris@10: 
Chris@10: \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
Chris@10: {\catcode`\@ =11
Chris@10: \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
Chris@10: % marginal hacks, juha@viisa.uucp (Juha Takala)
Chris@10: \ifvoid\margin\else % marginal info is present
Chris@10:   \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi
Chris@10: \dimen@=\dp#1\relax \unvbox#1\relax
Chris@10: \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
Chris@10: \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
Chris@10: }
Chris@10: 
Chris@10: % Here are the rules for the cropmarks.  Note that they are
Chris@10: % offset so that the space between them is truly \outerhsize or \outervsize
Chris@10: % (P. A. MacKay, 12 November, 1986)
Chris@10: %
Chris@10: \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
Chris@10: \def\nstop{\vbox
Chris@10:   {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
Chris@10: \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
Chris@10: \def\nsbot{\vbox
Chris@10:   {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
Chris@10: 
Chris@10: % Parse an argument, then pass it to #1.  The argument is the rest of
Chris@10: % the input line (except we remove a trailing comment).  #1 should be a
Chris@10: % macro which expects an ordinary undelimited TeX argument.
Chris@10: %
Chris@10: \def\parsearg{\parseargusing{}}
Chris@10: \def\parseargusing#1#2{%
Chris@10:   \def\argtorun{#2}%
Chris@10:   \begingroup
Chris@10:     \obeylines
Chris@10:     \spaceisspace
Chris@10:     #1%
Chris@10:     \parseargline\empty% Insert the \empty token, see \finishparsearg below.
Chris@10: }
Chris@10: 
Chris@10: {\obeylines %
Chris@10:   \gdef\parseargline#1^^M{%
Chris@10:     \endgroup % End of the group started in \parsearg.
Chris@10:     \argremovecomment #1\comment\ArgTerm%
Chris@10:   }%
Chris@10: }
Chris@10: 
Chris@10: % First remove any @comment, then any @c comment.
Chris@10: \def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm}
Chris@10: \def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
Chris@10: 
Chris@10: % Each occurrence of `\^^M' or `<space>\^^M' is replaced by a single space.
Chris@10: %
Chris@10: % \argremovec might leave us with trailing space, e.g.,
Chris@10: %    @end itemize  @c foo
Chris@10: % This space token undergoes the same procedure and is eventually removed
Chris@10: % by \finishparsearg.
Chris@10: %
Chris@10: \def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M}
Chris@10: \def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M}
Chris@10: \def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{%
Chris@10:   \def\temp{#3}%
Chris@10:   \ifx\temp\empty
Chris@10:     % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp:
Chris@10:     \let\temp\finishparsearg
Chris@10:   \else
Chris@10:     \let\temp\argcheckspaces
Chris@10:   \fi
Chris@10:   % Put the space token in:
Chris@10:   \temp#1 #3\ArgTerm
Chris@10: }
Chris@10: 
Chris@10: % If a _delimited_ argument is enclosed in braces, they get stripped; so
Chris@10: % to get _exactly_ the rest of the line, we had to prevent such situation.
Chris@10: % We prepended an \empty token at the very beginning and we expand it now,
Chris@10: % just before passing the control to \argtorun.
Chris@10: % (Similarly, we have to think about #3 of \argcheckspacesY above: it is
Chris@10: % either the null string, or it ends with \^^M---thus there is no danger
Chris@10: % that a pair of braces would be stripped.
Chris@10: %
Chris@10: % But first, we have to remove the trailing space token.
Chris@10: %
Chris@10: \def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}}
Chris@10: 
Chris@10: % \parseargdef\foo{...}
Chris@10: %	is roughly equivalent to
Chris@10: % \def\foo{\parsearg\Xfoo}
Chris@10: % \def\Xfoo#1{...}
Chris@10: %
Chris@10: % Actually, I use \csname\string\foo\endcsname, ie. \\foo, as it is my
Chris@10: % favourite TeX trick.  --kasal, 16nov03
Chris@10: 
Chris@10: \def\parseargdef#1{%
Chris@10:   \expandafter \doparseargdef \csname\string#1\endcsname #1%
Chris@10: }
Chris@10: \def\doparseargdef#1#2{%
Chris@10:   \def#2{\parsearg#1}%
Chris@10:   \def#1##1%
Chris@10: }
Chris@10: 
Chris@10: % Several utility definitions with active space:
Chris@10: {
Chris@10:   \obeyspaces
Chris@10:   \gdef\obeyedspace{ }
Chris@10: 
Chris@10:   % Make each space character in the input produce a normal interword
Chris@10:   % space in the output.  Don't allow a line break at this space, as this
Chris@10:   % is used only in environments like @example, where each line of input
Chris@10:   % should produce a line of output anyway.
Chris@10:   %
Chris@10:   \gdef\sepspaces{\obeyspaces\let =\tie}
Chris@10: 
Chris@10:   % If an index command is used in an @example environment, any spaces
Chris@10:   % therein should become regular spaces in the raw index file, not the
Chris@10:   % expansion of \tie (\leavevmode \penalty \@M \ ).
Chris@10:   \gdef\unsepspaces{\let =\space}
Chris@10: }
Chris@10: 
Chris@10: 
Chris@10: \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
Chris@10: 
Chris@10: % Define the framework for environments in texinfo.tex.  It's used like this:
Chris@10: %
Chris@10: %   \envdef\foo{...}
Chris@10: %   \def\Efoo{...}
Chris@10: %
Chris@10: % It's the responsibility of \envdef to insert \begingroup before the
Chris@10: % actual body; @end closes the group after calling \Efoo.  \envdef also
Chris@10: % defines \thisenv, so the current environment is known; @end checks
Chris@10: % whether the environment name matches.  The \checkenv macro can also be
Chris@10: % used to check whether the current environment is the one expected.
Chris@10: %
Chris@10: % Non-false conditionals (@iftex, @ifset) don't fit into this, so they
Chris@10: % are not treated as environments; they don't open a group.  (The
Chris@10: % implementation of @end takes care not to call \endgroup in this
Chris@10: % special case.)
Chris@10: 
Chris@10: 
Chris@10: % At run-time, environments start with this:
Chris@10: \def\startenvironment#1{\begingroup\def\thisenv{#1}}
Chris@10: % initialize
Chris@10: \let\thisenv\empty
Chris@10: 
Chris@10: % ... but they get defined via ``\envdef\foo{...}'':
Chris@10: \long\def\envdef#1#2{\def#1{\startenvironment#1#2}}
Chris@10: \def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}}
Chris@10: 
Chris@10: % Check whether we're in the right environment:
Chris@10: \def\checkenv#1{%
Chris@10:   \def\temp{#1}%
Chris@10:   \ifx\thisenv\temp
Chris@10:   \else
Chris@10:     \badenverr
Chris@10:   \fi
Chris@10: }
Chris@10: 
Chris@10: % Environment mismatch, #1 expected:
Chris@10: \def\badenverr{%
Chris@10:   \errhelp = \EMsimple
Chris@10:   \errmessage{This command can appear only \inenvironment\temp,
Chris@10:     not \inenvironment\thisenv}%
Chris@10: }
Chris@10: \def\inenvironment#1{%
Chris@10:   \ifx#1\empty
Chris@10:     outside of any environment%
Chris@10:   \else
Chris@10:     in environment \expandafter\string#1%
Chris@10:   \fi
Chris@10: }
Chris@10: 
Chris@10: % @end foo executes the definition of \Efoo.
Chris@10: % But first, it executes a specialized version of \checkenv
Chris@10: %
Chris@10: \parseargdef\end{%
Chris@10:   \if 1\csname iscond.#1\endcsname
Chris@10:   \else
Chris@10:     % The general wording of \badenverr may not be ideal.
Chris@10:     \expandafter\checkenv\csname#1\endcsname
Chris@10:     \csname E#1\endcsname
Chris@10:     \endgroup
Chris@10:   \fi
Chris@10: }
Chris@10: 
Chris@10: \newhelp\EMsimple{Press RETURN to continue.}
Chris@10: 
Chris@10: 
Chris@10: % Be sure we're in horizontal mode when doing a tie, since we make space
Chris@10: % equivalent to this in @example-like environments. Otherwise, a space
Chris@10: % at the beginning of a line will start with \penalty -- and
Chris@10: % since \penalty is valid in vertical mode, we'd end up putting the
Chris@10: % penalty on the vertical list instead of in the new paragraph.
Chris@10: {\catcode`@ = 11
Chris@10:  % Avoid using \@M directly, because that causes trouble
Chris@10:  % if the definition is written into an index file.
Chris@10:  \global\let\tiepenalty = \@M
Chris@10:  \gdef\tie{\leavevmode\penalty\tiepenalty\ }
Chris@10: }
Chris@10: 
Chris@10: % @: forces normal size whitespace following.
Chris@10: \def\:{\spacefactor=1000 }
Chris@10: 
Chris@10: % @* forces a line break.
Chris@10: \def\*{\hfil\break\hbox{}\ignorespaces}
Chris@10: 
Chris@10: % @/ allows a line break.
Chris@10: \let\/=\allowbreak
Chris@10: 
Chris@10: % @. is an end-of-sentence period.
Chris@10: \def\.{.\spacefactor=\endofsentencespacefactor\space}
Chris@10: 
Chris@10: % @! is an end-of-sentence bang.
Chris@10: \def\!{!\spacefactor=\endofsentencespacefactor\space}
Chris@10: 
Chris@10: % @? is an end-of-sentence query.
Chris@10: \def\?{?\spacefactor=\endofsentencespacefactor\space}
Chris@10: 
Chris@10: % @frenchspacing on|off  says whether to put extra space after punctuation.
Chris@10: %
Chris@10: \def\onword{on}
Chris@10: \def\offword{off}
Chris@10: %
Chris@10: \parseargdef\frenchspacing{%
Chris@10:   \def\temp{#1}%
Chris@10:   \ifx\temp\onword \plainfrenchspacing
Chris@10:   \else\ifx\temp\offword \plainnonfrenchspacing
Chris@10:   \else
Chris@10:     \errhelp = \EMsimple
Chris@10:     \errmessage{Unknown @frenchspacing option `\temp', must be on|off}%
Chris@10:   \fi\fi
Chris@10: }
Chris@10: 
Chris@10: % @w prevents a word break.  Without the \leavevmode, @w at the
Chris@10: % beginning of a paragraph, when TeX is still in vertical mode, would
Chris@10: % produce a whole line of output instead of starting the paragraph.
Chris@10: \def\w#1{\leavevmode\hbox{#1}}
Chris@10: 
Chris@10: % @group ... @end group forces ... to be all on one page, by enclosing
Chris@10: % it in a TeX vbox.  We use \vtop instead of \vbox to construct the box
Chris@10: % to keep its height that of a normal line.  According to the rules for
Chris@10: % \topskip (p.114 of the TeXbook), the glue inserted is
Chris@10: % max (\topskip - \ht (first item), 0).  If that height is large,
Chris@10: % therefore, no glue is inserted, and the space between the headline and
Chris@10: % the text is small, which looks bad.
Chris@10: %
Chris@10: % Another complication is that the group might be very large.  This can
Chris@10: % cause the glue on the previous page to be unduly stretched, because it
Chris@10: % does not have much material.  In this case, it's better to add an
Chris@10: % explicit \vfill so that the extra space is at the bottom.  The
Chris@10: % threshold for doing this is if the group is more than \vfilllimit
Chris@10: % percent of a page (\vfilllimit can be changed inside of @tex).
Chris@10: %
Chris@10: \newbox\groupbox
Chris@10: \def\vfilllimit{0.7}
Chris@10: %
Chris@10: \envdef\group{%
Chris@10:   \ifnum\catcode`\^^M=\active \else
Chris@10:     \errhelp = \groupinvalidhelp
Chris@10:     \errmessage{@group invalid in context where filling is enabled}%
Chris@10:   \fi
Chris@10:   \startsavinginserts
Chris@10:   %
Chris@10:   \setbox\groupbox = \vtop\bgroup
Chris@10:     % Do @comment since we are called inside an environment such as
Chris@10:     % @example, where each end-of-line in the input causes an
Chris@10:     % end-of-line in the output.  We don't want the end-of-line after
Chris@10:     % the `@group' to put extra space in the output.  Since @group
Chris@10:     % should appear on a line by itself (according to the Texinfo
Chris@10:     % manual), we don't worry about eating any user text.
Chris@10:     \comment
Chris@10: }
Chris@10: %
Chris@10: % The \vtop produces a box with normal height and large depth; thus, TeX puts
Chris@10: % \baselineskip glue before it, and (when the next line of text is done)
Chris@10: % \lineskip glue after it.  Thus, space below is not quite equal to space
Chris@10: % above.  But it's pretty close.
Chris@10: \def\Egroup{%
Chris@10:     % To get correct interline space between the last line of the group
Chris@10:     % and the first line afterwards, we have to propagate \prevdepth.
Chris@10:     \endgraf % Not \par, as it may have been set to \lisppar.
Chris@10:     \global\dimen1 = \prevdepth
Chris@10:   \egroup           % End the \vtop.
Chris@10:   % \dimen0 is the vertical size of the group's box.
Chris@10:   \dimen0 = \ht\groupbox  \advance\dimen0 by \dp\groupbox
Chris@10:   % \dimen2 is how much space is left on the page (more or less).
Chris@10:   \dimen2 = \pageheight   \advance\dimen2 by -\pagetotal
Chris@10:   % if the group doesn't fit on the current page, and it's a big big
Chris@10:   % group, force a page break.
Chris@10:   \ifdim \dimen0 > \dimen2
Chris@10:     \ifdim \pagetotal < \vfilllimit\pageheight
Chris@10:       \page
Chris@10:     \fi
Chris@10:   \fi
Chris@10:   \box\groupbox
Chris@10:   \prevdepth = \dimen1
Chris@10:   \checkinserts
Chris@10: }
Chris@10: %
Chris@10: % TeX puts in an \escapechar (i.e., `@') at the beginning of the help
Chris@10: % message, so this ends up printing `@group can only ...'.
Chris@10: %
Chris@10: \newhelp\groupinvalidhelp{%
Chris@10: group can only be used in environments such as @example,^^J%
Chris@10: where each line of input produces a line of output.}
Chris@10: 
Chris@10: % @need space-in-mils
Chris@10: % forces a page break if there is not space-in-mils remaining.
Chris@10: 
Chris@10: \newdimen\mil  \mil=0.001in
Chris@10: 
Chris@10: \parseargdef\need{%
Chris@10:   % Ensure vertical mode, so we don't make a big box in the middle of a
Chris@10:   % paragraph.
Chris@10:   \par
Chris@10:   %
Chris@10:   % If the @need value is less than one line space, it's useless.
Chris@10:   \dimen0 = #1\mil
Chris@10:   \dimen2 = \ht\strutbox
Chris@10:   \advance\dimen2 by \dp\strutbox
Chris@10:   \ifdim\dimen0 > \dimen2
Chris@10:     %
Chris@10:     % Do a \strut just to make the height of this box be normal, so the
Chris@10:     % normal leading is inserted relative to the preceding line.
Chris@10:     % And a page break here is fine.
Chris@10:     \vtop to #1\mil{\strut\vfil}%
Chris@10:     %
Chris@10:     % TeX does not even consider page breaks if a penalty added to the
Chris@10:     % main vertical list is 10000 or more.  But in order to see if the
Chris@10:     % empty box we just added fits on the page, we must make it consider
Chris@10:     % page breaks.  On the other hand, we don't want to actually break the
Chris@10:     % page after the empty box.  So we use a penalty of 9999.
Chris@10:     %
Chris@10:     % There is an extremely small chance that TeX will actually break the
Chris@10:     % page at this \penalty, if there are no other feasible breakpoints in
Chris@10:     % sight.  (If the user is using lots of big @group commands, which
Chris@10:     % almost-but-not-quite fill up a page, TeX will have a hard time doing
Chris@10:     % good page breaking, for example.)  However, I could not construct an
Chris@10:     % example where a page broke at this \penalty; if it happens in a real
Chris@10:     % document, then we can reconsider our strategy.
Chris@10:     \penalty9999
Chris@10:     %
Chris@10:     % Back up by the size of the box, whether we did a page break or not.
Chris@10:     \kern -#1\mil
Chris@10:     %
Chris@10:     % Do not allow a page break right after this kern.
Chris@10:     \nobreak
Chris@10:   \fi
Chris@10: }
Chris@10: 
Chris@10: % @br   forces paragraph break (and is undocumented).
Chris@10: 
Chris@10: \let\br = \par
Chris@10: 
Chris@10: % @page forces the start of a new page.
Chris@10: %
Chris@10: \def\page{\par\vfill\supereject}
Chris@10: 
Chris@10: % @exdent text....
Chris@10: % outputs text on separate line in roman font, starting at standard page margin
Chris@10: 
Chris@10: % This records the amount of indent in the innermost environment.
Chris@10: % That's how much \exdent should take out.
Chris@10: \newskip\exdentamount
Chris@10: 
Chris@10: % This defn is used inside fill environments such as @defun.
Chris@10: \parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}
Chris@10: 
Chris@10: % This defn is used inside nofill environments such as @example.
Chris@10: \parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount
Chris@10:   \leftline{\hskip\leftskip{\rm#1}}}}
Chris@10: 
Chris@10: % @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current
Chris@10: % paragraph.  For more general purposes, use the \margin insertion
Chris@10: % class.  WHICH is `l' or `r'.  Not documented, written for gawk manual.
Chris@10: %
Chris@10: \newskip\inmarginspacing \inmarginspacing=1cm
Chris@10: \def\strutdepth{\dp\strutbox}
Chris@10: %
Chris@10: \def\doinmargin#1#2{\strut\vadjust{%
Chris@10:   \nobreak
Chris@10:   \kern-\strutdepth
Chris@10:   \vtop to \strutdepth{%
Chris@10:     \baselineskip=\strutdepth
Chris@10:     \vss
Chris@10:     % if you have multiple lines of stuff to put here, you'll need to
Chris@10:     % make the vbox yourself of the appropriate size.
Chris@10:     \ifx#1l%
Chris@10:       \llap{\ignorespaces #2\hskip\inmarginspacing}%
Chris@10:     \else
Chris@10:       \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}%
Chris@10:     \fi
Chris@10:     \null
Chris@10:   }%
Chris@10: }}
Chris@10: \def\inleftmargin{\doinmargin l}
Chris@10: \def\inrightmargin{\doinmargin r}
Chris@10: %
Chris@10: % @inmargin{TEXT [, RIGHT-TEXT]}
Chris@10: % (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right;
Chris@10: % else use TEXT for both).
Chris@10: %
Chris@10: \def\inmargin#1{\parseinmargin #1,,\finish}
Chris@10: \def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing.
Chris@10:   \setbox0 = \hbox{\ignorespaces #2}%
Chris@10:   \ifdim\wd0 > 0pt
Chris@10:     \def\lefttext{#1}%  have both texts
Chris@10:     \def\righttext{#2}%
Chris@10:   \else
Chris@10:     \def\lefttext{#1}%  have only one text
Chris@10:     \def\righttext{#1}%
Chris@10:   \fi
Chris@10:   %
Chris@10:   \ifodd\pageno
Chris@10:     \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin
Chris@10:   \else
Chris@10:     \def\temp{\inleftmargin\lefttext}%
Chris@10:   \fi
Chris@10:   \temp
Chris@10: }
Chris@10: 
Chris@10: % @| inserts a changebar to the left of the current line.  It should
Chris@10: % surround any changed text.  This approach does *not* work if the
Chris@10: % change spans more than two lines of output.  To handle that, we would
Chris@10: % have adopt a much more difficult approach (putting marks into the main
Chris@10: % vertical list for the beginning and end of each change).  This command
Chris@10: % is not documented, not supported, and doesn't work.
Chris@10: %
Chris@10: \def\|{%
Chris@10:   % \vadjust can only be used in horizontal mode.
Chris@10:   \leavevmode
Chris@10:   %
Chris@10:   % Append this vertical mode material after the current line in the output.
Chris@10:   \vadjust{%
Chris@10:     % We want to insert a rule with the height and depth of the current
Chris@10:     % leading; that is exactly what \strutbox is supposed to record.
Chris@10:     \vskip-\baselineskip
Chris@10:     %
Chris@10:     % \vadjust-items are inserted at the left edge of the type.  So
Chris@10:     % the \llap here moves out into the left-hand margin.
Chris@10:     \llap{%
Chris@10:       %
Chris@10:       % For a thicker or thinner bar, change the `1pt'.
Chris@10:       \vrule height\baselineskip width1pt
Chris@10:       %
Chris@10:       % This is the space between the bar and the text.
Chris@10:       \hskip 12pt
Chris@10:     }%
Chris@10:   }%
Chris@10: }
Chris@10: 
Chris@10: % @include FILE -- \input text of FILE.
Chris@10: %
Chris@10: \def\include{\parseargusing\filenamecatcodes\includezzz}
Chris@10: \def\includezzz#1{%
Chris@10:   \pushthisfilestack
Chris@10:   \def\thisfile{#1}%
Chris@10:   {%
Chris@10:     \makevalueexpandable  % we want to expand any @value in FILE.
Chris@10:     \turnoffactive        % and allow special characters in the expansion
Chris@10:     \indexnofonts         % Allow `@@' and other weird things in file names.
Chris@10:     \wlog{texinfo.tex: doing @include of #1^^J}%
Chris@10:     \edef\temp{\noexpand\input #1 }%
Chris@10:     %
Chris@10:     % This trickery is to read FILE outside of a group, in case it makes
Chris@10:     % definitions, etc.
Chris@10:     \expandafter
Chris@10:   }\temp
Chris@10:   \popthisfilestack
Chris@10: }
Chris@10: \def\filenamecatcodes{%
Chris@10:   \catcode`\\=\other
Chris@10:   \catcode`~=\other
Chris@10:   \catcode`^=\other
Chris@10:   \catcode`_=\other
Chris@10:   \catcode`|=\other
Chris@10:   \catcode`<=\other
Chris@10:   \catcode`>=\other
Chris@10:   \catcode`+=\other
Chris@10:   \catcode`-=\other
Chris@10:   \catcode`\`=\other
Chris@10:   \catcode`\'=\other
Chris@10: }
Chris@10: 
Chris@10: \def\pushthisfilestack{%
Chris@10:   \expandafter\pushthisfilestackX\popthisfilestack\StackTerm
Chris@10: }
Chris@10: \def\pushthisfilestackX{%
Chris@10:   \expandafter\pushthisfilestackY\thisfile\StackTerm
Chris@10: }
Chris@10: \def\pushthisfilestackY #1\StackTerm #2\StackTerm {%
Chris@10:   \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}%
Chris@10: }
Chris@10: 
Chris@10: \def\popthisfilestack{\errthisfilestackempty}
Chris@10: \def\errthisfilestackempty{\errmessage{Internal error:
Chris@10:   the stack of filenames is empty.}}
Chris@10: %
Chris@10: \def\thisfile{}
Chris@10: 
Chris@10: % @center line
Chris@10: % outputs that line, centered.
Chris@10: %
Chris@10: \parseargdef\center{%
Chris@10:   \ifhmode
Chris@10:     \let\centersub\centerH
Chris@10:   \else
Chris@10:     \let\centersub\centerV
Chris@10:   \fi
Chris@10:   \centersub{\hfil \ignorespaces#1\unskip \hfil}%
Chris@10:   \let\centersub\relax % don't let the definition persist, just in case
Chris@10: }
Chris@10: \def\centerH#1{{%
Chris@10:   \hfil\break
Chris@10:   \advance\hsize by -\leftskip
Chris@10:   \advance\hsize by -\rightskip
Chris@10:   \line{#1}%
Chris@10:   \break
Chris@10: }}
Chris@10: %
Chris@10: \newcount\centerpenalty
Chris@10: \def\centerV#1{%
Chris@10:   % The idea here is the same as in \startdefun, \cartouche, etc.: if
Chris@10:   % @center is the first thing after a section heading, we need to wipe
Chris@10:   % out the negative parskip inserted by \sectionheading, but still
Chris@10:   % prevent a page break here.
Chris@10:   \centerpenalty = \lastpenalty
Chris@10:   \ifnum\centerpenalty>10000 \vskip\parskip \fi
Chris@10:   \ifnum\centerpenalty>9999 \penalty\centerpenalty \fi
Chris@10:   \line{\kern\leftskip #1\kern\rightskip}%
Chris@10: }
Chris@10: 
Chris@10: % @sp n   outputs n lines of vertical space
Chris@10: %
Chris@10: \parseargdef\sp{\vskip #1\baselineskip}
Chris@10: 
Chris@10: % @comment ...line which is ignored...
Chris@10: % @c is the same as @comment
Chris@10: % @ignore ... @end ignore  is another way to write a comment
Chris@10: %
Chris@10: \def\comment{\begingroup \catcode`\^^M=\other%
Chris@10: \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
Chris@10: \commentxxx}
Chris@10: {\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}}
Chris@10: %
Chris@10: \let\c=\comment
Chris@10: 
Chris@10: % @paragraphindent NCHARS
Chris@10: % We'll use ems for NCHARS, close enough.
Chris@10: % NCHARS can also be the word `asis' or `none'.
Chris@10: % We cannot feasibly implement @paragraphindent asis, though.
Chris@10: %
Chris@10: \def\asisword{asis} % no translation, these are keywords
Chris@10: \def\noneword{none}
Chris@10: %
Chris@10: \parseargdef\paragraphindent{%
Chris@10:   \def\temp{#1}%
Chris@10:   \ifx\temp\asisword
Chris@10:   \else
Chris@10:     \ifx\temp\noneword
Chris@10:       \defaultparindent = 0pt
Chris@10:     \else
Chris@10:       \defaultparindent = #1em
Chris@10:     \fi
Chris@10:   \fi
Chris@10:   \parindent = \defaultparindent
Chris@10: }
Chris@10: 
Chris@10: % @exampleindent NCHARS
Chris@10: % We'll use ems for NCHARS like @paragraphindent.
Chris@10: % It seems @exampleindent asis isn't necessary, but
Chris@10: % I preserve it to make it similar to @paragraphindent.
Chris@10: \parseargdef\exampleindent{%
Chris@10:   \def\temp{#1}%
Chris@10:   \ifx\temp\asisword
Chris@10:   \else
Chris@10:     \ifx\temp\noneword
Chris@10:       \lispnarrowing = 0pt
Chris@10:     \else
Chris@10:       \lispnarrowing = #1em
Chris@10:     \fi
Chris@10:   \fi
Chris@10: }
Chris@10: 
Chris@10: % @firstparagraphindent WORD
Chris@10: % If WORD is `none', then suppress indentation of the first paragraph
Chris@10: % after a section heading.  If WORD is `insert', then do indent at such
Chris@10: % paragraphs.
Chris@10: %
Chris@10: % The paragraph indentation is suppressed or not by calling
Chris@10: % \suppressfirstparagraphindent, which the sectioning commands do.
Chris@10: % We switch the definition of this back and forth according to WORD.
Chris@10: % By default, we suppress indentation.
Chris@10: %
Chris@10: \def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent}
Chris@10: \def\insertword{insert}
Chris@10: %
Chris@10: \parseargdef\firstparagraphindent{%
Chris@10:   \def\temp{#1}%
Chris@10:   \ifx\temp\noneword
Chris@10:     \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent
Chris@10:   \else\ifx\temp\insertword
Chris@10:     \let\suppressfirstparagraphindent = \relax
Chris@10:   \else
Chris@10:     \errhelp = \EMsimple
Chris@10:     \errmessage{Unknown @firstparagraphindent option `\temp'}%
Chris@10:   \fi\fi
Chris@10: }
Chris@10: 
Chris@10: % Here is how we actually suppress indentation.  Redefine \everypar to
Chris@10: % \kern backwards by \parindent, and then reset itself to empty.
Chris@10: %
Chris@10: % We also make \indent itself not actually do anything until the next
Chris@10: % paragraph.
Chris@10: %
Chris@10: \gdef\dosuppressfirstparagraphindent{%
Chris@10:   \gdef\indent{%
Chris@10:     \restorefirstparagraphindent
Chris@10:     \indent
Chris@10:   }%
Chris@10:   \gdef\noindent{%
Chris@10:     \restorefirstparagraphindent
Chris@10:     \noindent
Chris@10:   }%
Chris@10:   \global\everypar = {%
Chris@10:     \kern -\parindent
Chris@10:     \restorefirstparagraphindent
Chris@10:   }%
Chris@10: }
Chris@10: 
Chris@10: \gdef\restorefirstparagraphindent{%
Chris@10:   \global \let \indent = \ptexindent
Chris@10:   \global \let \noindent = \ptexnoindent
Chris@10:   \global \everypar = {}%
Chris@10: }
Chris@10: 
Chris@10: 
Chris@10: % @refill is a no-op.
Chris@10: \let\refill=\relax
Chris@10: 
Chris@10: % If working on a large document in chapters, it is convenient to
Chris@10: % be able to disable indexing, cross-referencing, and contents, for test runs.
Chris@10: % This is done with @novalidate (before @setfilename).
Chris@10: %
Chris@10: \newif\iflinks \linkstrue % by default we want the aux files.
Chris@10: \let\novalidate = \linksfalse
Chris@10: 
Chris@10: % @setfilename is done at the beginning of every texinfo file.
Chris@10: % So open here the files we need to have open while reading the input.
Chris@10: % This makes it possible to make a .fmt file for texinfo.
Chris@10: \def\setfilename{%
Chris@10:    \fixbackslash  % Turn off hack to swallow `\input texinfo'.
Chris@10:    \iflinks
Chris@10:      \tryauxfile
Chris@10:      % Open the new aux file.  TeX will close it automatically at exit.
Chris@10:      \immediate\openout\auxfile=\jobname.aux
Chris@10:    \fi % \openindices needs to do some work in any case.
Chris@10:    \openindices
Chris@10:    \let\setfilename=\comment % Ignore extra @setfilename cmds.
Chris@10:    %
Chris@10:    % If texinfo.cnf is present on the system, read it.
Chris@10:    % Useful for site-wide @afourpaper, etc.
Chris@10:    \openin 1 texinfo.cnf
Chris@10:    \ifeof 1 \else \input texinfo.cnf \fi
Chris@10:    \closein 1
Chris@10:    %
Chris@10:    \comment % Ignore the actual filename.
Chris@10: }
Chris@10: 
Chris@10: % Called from \setfilename.
Chris@10: %
Chris@10: \def\openindices{%
Chris@10:   \newindex{cp}%
Chris@10:   \newcodeindex{fn}%
Chris@10:   \newcodeindex{vr}%
Chris@10:   \newcodeindex{tp}%
Chris@10:   \newcodeindex{ky}%
Chris@10:   \newcodeindex{pg}%
Chris@10: }
Chris@10: 
Chris@10: % @bye.
Chris@10: \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
Chris@10: 
Chris@10: 
Chris@10: \message{pdf,}
Chris@10: % adobe `portable' document format
Chris@10: \newcount\tempnum
Chris@10: \newcount\lnkcount
Chris@10: \newtoks\filename
Chris@10: \newcount\filenamelength
Chris@10: \newcount\pgn
Chris@10: \newtoks\toksA
Chris@10: \newtoks\toksB
Chris@10: \newtoks\toksC
Chris@10: \newtoks\toksD
Chris@10: \newbox\boxA
Chris@10: \newcount\countA
Chris@10: \newif\ifpdf
Chris@10: \newif\ifpdfmakepagedest
Chris@10: 
Chris@10: % when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1
Chris@10: % can be set).  So we test for \relax and 0 as well as being undefined.
Chris@10: \ifx\pdfoutput\thisisundefined
Chris@10: \else
Chris@10:   \ifx\pdfoutput\relax
Chris@10:   \else
Chris@10:     \ifcase\pdfoutput
Chris@10:     \else
Chris@10:       \pdftrue
Chris@10:     \fi
Chris@10:   \fi
Chris@10: \fi
Chris@10: 
Chris@10: % PDF uses PostScript string constants for the names of xref targets,
Chris@10: % for display in the outlines, and in other places.  Thus, we have to
Chris@10: % double any backslashes.  Otherwise, a name like "\node" will be
Chris@10: % interpreted as a newline (\n), followed by o, d, e.  Not good.
Chris@10: % 
Chris@10: % See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and
Chris@10: % related messages.  The final outcome is that it is up to the TeX user
Chris@10: % to double the backslashes and otherwise make the string valid, so
Chris@10: % that's what we do.  pdftex 1.30.0 (ca.2005) introduced a primitive to
Chris@10: % do this reliably, so we use it.
Chris@10: 
Chris@10: % #1 is a control sequence in which to do the replacements,
Chris@10: % which we \xdef.
Chris@10: \def\txiescapepdf#1{%
Chris@10:   \ifx\pdfescapestring\relax
Chris@10:     % No primitive available; should we give a warning or log?
Chris@10:     % Many times it won't matter.
Chris@10:   \else
Chris@10:     % The expandable \pdfescapestring primitive escapes parentheses,
Chris@10:     % backslashes, and other special chars.
Chris@10:     \xdef#1{\pdfescapestring{#1}}%
Chris@10:   \fi
Chris@10: }
Chris@10: 
Chris@10: \newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images
Chris@10: with PDF output, and none of those formats could be found.  (.eps cannot
Chris@10: be supported due to the design of the PDF format; use regular TeX (DVI
Chris@10: output) for that.)}
Chris@10: 
Chris@10: \ifpdf
Chris@10:   %
Chris@10:   % Color manipulation macros based on pdfcolor.tex,
Chris@10:   % except using rgb instead of cmyk; the latter is said to render as a
Chris@10:   % very dark gray on-screen and a very dark halftone in print, instead
Chris@10:   % of actual black.
Chris@10:   \def\rgbDarkRed{0.50 0.09 0.12}
Chris@10:   \def\rgbBlack{0 0 0}
Chris@10:   %
Chris@10:   % k sets the color for filling (usual text, etc.);
Chris@10:   % K sets the color for stroking (thin rules, e.g., normal _'s).
Chris@10:   \def\pdfsetcolor#1{\pdfliteral{#1 rg  #1 RG}}
Chris@10:   %
Chris@10:   % Set color, and create a mark which defines \thiscolor accordingly,
Chris@10:   % so that \makeheadline knows which color to restore.
Chris@10:   \def\setcolor#1{%
Chris@10:     \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}%
Chris@10:     \domark
Chris@10:     \pdfsetcolor{#1}%
Chris@10:   }
Chris@10:   %
Chris@10:   \def\maincolor{\rgbBlack}
Chris@10:   \pdfsetcolor{\maincolor}
Chris@10:   \edef\thiscolor{\maincolor}
Chris@10:   \def\lastcolordefs{}
Chris@10:   %
Chris@10:   \def\makefootline{%
Chris@10:     \baselineskip24pt
Chris@10:     \line{\pdfsetcolor{\maincolor}\the\footline}%
Chris@10:   }
Chris@10:   %
Chris@10:   \def\makeheadline{%
Chris@10:     \vbox to 0pt{%
Chris@10:       \vskip-22.5pt
Chris@10:       \line{%
Chris@10:         \vbox to8.5pt{}%
Chris@10:         % Extract \thiscolor definition from the marks.
Chris@10:         \getcolormarks
Chris@10:         % Typeset the headline with \maincolor, then restore the color.
Chris@10:         \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
Chris@10:       }%
Chris@10:       \vss
Chris@10:     }%
Chris@10:     \nointerlineskip
Chris@10:   }
Chris@10:   %
Chris@10:   %
Chris@10:   \pdfcatalog{/PageMode /UseOutlines}
Chris@10:   %
Chris@10:   % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
Chris@10:   \def\dopdfimage#1#2#3{%
Chris@10:     \def\pdfimagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
Chris@10:     \def\pdfimageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
Chris@10:     %
Chris@10:     % pdftex (and the PDF format) support .pdf, .png, .jpg (among
Chris@10:     % others).  Let's try in that order, PDF first since if
Chris@10:     % someone has a scalable image, presumably better to use that than a
Chris@10:     % bitmap.
Chris@10:     \let\pdfimgext=\empty
Chris@10:     \begingroup
Chris@10:       \openin 1 #1.pdf \ifeof 1
Chris@10:         \openin 1 #1.PDF \ifeof 1
Chris@10:           \openin 1 #1.png \ifeof 1
Chris@10:             \openin 1 #1.jpg \ifeof 1
Chris@10:               \openin 1 #1.jpeg \ifeof 1
Chris@10:                 \openin 1 #1.JPG \ifeof 1
Chris@10:                   \errhelp = \nopdfimagehelp
Chris@10:                   \errmessage{Could not find image file #1 for pdf}%
Chris@10:                 \else \gdef\pdfimgext{JPG}%
Chris@10:                 \fi
Chris@10:               \else \gdef\pdfimgext{jpeg}%
Chris@10:               \fi
Chris@10:             \else \gdef\pdfimgext{jpg}%
Chris@10:             \fi
Chris@10:           \else \gdef\pdfimgext{png}%
Chris@10:           \fi
Chris@10:         \else \gdef\pdfimgext{PDF}%
Chris@10:         \fi
Chris@10:       \else \gdef\pdfimgext{pdf}%
Chris@10:       \fi
Chris@10:       \closein 1
Chris@10:     \endgroup
Chris@10:     %
Chris@10:     % without \immediate, ancient pdftex seg faults when the same image is
Chris@10:     % included twice.  (Version 3.14159-pre-1.0-unofficial-20010704.)
Chris@10:     \ifnum\pdftexversion < 14
Chris@10:       \immediate\pdfimage
Chris@10:     \else
Chris@10:       \immediate\pdfximage
Chris@10:     \fi
Chris@10:       \ifdim \wd0 >0pt width \pdfimagewidth \fi
Chris@10:       \ifdim \wd2 >0pt height \pdfimageheight \fi
Chris@10:       \ifnum\pdftexversion<13
Chris@10:          #1.\pdfimgext
Chris@10:        \else
Chris@10:          {#1.\pdfimgext}%
Chris@10:        \fi
Chris@10:     \ifnum\pdftexversion < 14 \else
Chris@10:       \pdfrefximage \pdflastximage
Chris@10:     \fi}
Chris@10:   %
Chris@10:   \def\pdfmkdest#1{{%
Chris@10:     % We have to set dummies so commands such as @code, and characters
Chris@10:     % such as \, aren't expanded when present in a section title.
Chris@10:     \indexnofonts
Chris@10:     \turnoffactive
Chris@10:     \makevalueexpandable
Chris@10:     \def\pdfdestname{#1}%
Chris@10:     \txiescapepdf\pdfdestname
Chris@10:     \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
Chris@10:   }}
Chris@10:   %
Chris@10:   % used to mark target names; must be expandable.
Chris@10:   \def\pdfmkpgn#1{#1}
Chris@10:   %
Chris@10:   % by default, use a color that is dark enough to print on paper as
Chris@10:   % nearly black, but still distinguishable for online viewing.
Chris@10:   \def\urlcolor{\rgbDarkRed}
Chris@10:   \def\linkcolor{\rgbDarkRed}
Chris@10:   \def\endlink{\setcolor{\maincolor}\pdfendlink}
Chris@10:   %
Chris@10:   % Adding outlines to PDF; macros for calculating structure of outlines
Chris@10:   % come from Petr Olsak
Chris@10:   \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
Chris@10:     \else \csname#1\endcsname \fi}
Chris@10:   \def\advancenumber#1{\tempnum=\expnumber{#1}\relax
Chris@10:     \advance\tempnum by 1
Chris@10:     \expandafter\xdef\csname#1\endcsname{\the\tempnum}}
Chris@10:   %
Chris@10:   % #1 is the section text, which is what will be displayed in the
Chris@10:   % outline by the pdf viewer.  #2 is the pdf expression for the number
Chris@10:   % of subentries (or empty, for subsubsections).  #3 is the node text,
Chris@10:   % which might be empty if this toc entry had no corresponding node.
Chris@10:   % #4 is the page number
Chris@10:   %
Chris@10:   \def\dopdfoutline#1#2#3#4{%
Chris@10:     % Generate a link to the node text if that exists; else, use the
Chris@10:     % page number.  We could generate a destination for the section
Chris@10:     % text in the case where a section has no node, but it doesn't
Chris@10:     % seem worth the trouble, since most documents are normally structured.
Chris@10:     \edef\pdfoutlinedest{#3}%
Chris@10:     \ifx\pdfoutlinedest\empty
Chris@10:       \def\pdfoutlinedest{#4}%
Chris@10:     \else
Chris@10:       \txiescapepdf\pdfoutlinedest
Chris@10:     \fi
Chris@10:     %
Chris@10:     % Also escape PDF chars in the display string.
Chris@10:     \edef\pdfoutlinetext{#1}%
Chris@10:     \txiescapepdf\pdfoutlinetext
Chris@10:     %
Chris@10:     \pdfoutline goto name{\pdfmkpgn{\pdfoutlinedest}}#2{\pdfoutlinetext}%
Chris@10:   }
Chris@10:   %
Chris@10:   \def\pdfmakeoutlines{%
Chris@10:     \begingroup
Chris@10:       % Read toc silently, to get counts of subentries for \pdfoutline.
Chris@10:       \def\partentry##1##2##3##4{}% ignore parts in the outlines
Chris@10:       \def\numchapentry##1##2##3##4{%
Chris@10: 	\def\thischapnum{##2}%
Chris@10: 	\def\thissecnum{0}%
Chris@10: 	\def\thissubsecnum{0}%
Chris@10:       }%
Chris@10:       \def\numsecentry##1##2##3##4{%
Chris@10: 	\advancenumber{chap\thischapnum}%
Chris@10: 	\def\thissecnum{##2}%
Chris@10: 	\def\thissubsecnum{0}%
Chris@10:       }%
Chris@10:       \def\numsubsecentry##1##2##3##4{%
Chris@10: 	\advancenumber{sec\thissecnum}%
Chris@10: 	\def\thissubsecnum{##2}%
Chris@10:       }%
Chris@10:       \def\numsubsubsecentry##1##2##3##4{%
Chris@10: 	\advancenumber{subsec\thissubsecnum}%
Chris@10:       }%
Chris@10:       \def\thischapnum{0}%
Chris@10:       \def\thissecnum{0}%
Chris@10:       \def\thissubsecnum{0}%
Chris@10:       %
Chris@10:       % use \def rather than \let here because we redefine \chapentry et
Chris@10:       % al. a second time, below.
Chris@10:       \def\appentry{\numchapentry}%
Chris@10:       \def\appsecentry{\numsecentry}%
Chris@10:       \def\appsubsecentry{\numsubsecentry}%
Chris@10:       \def\appsubsubsecentry{\numsubsubsecentry}%
Chris@10:       \def\unnchapentry{\numchapentry}%
Chris@10:       \def\unnsecentry{\numsecentry}%
Chris@10:       \def\unnsubsecentry{\numsubsecentry}%
Chris@10:       \def\unnsubsubsecentry{\numsubsubsecentry}%
Chris@10:       \readdatafile{toc}%
Chris@10:       %
Chris@10:       % Read toc second time, this time actually producing the outlines.
Chris@10:       % The `-' means take the \expnumber as the absolute number of
Chris@10:       % subentries, which we calculated on our first read of the .toc above.
Chris@10:       %
Chris@10:       % We use the node names as the destinations.
Chris@10:       \def\numchapentry##1##2##3##4{%
Chris@10:         \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}%
Chris@10:       \def\numsecentry##1##2##3##4{%
Chris@10:         \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}%
Chris@10:       \def\numsubsecentry##1##2##3##4{%
Chris@10:         \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}%
Chris@10:       \def\numsubsubsecentry##1##2##3##4{% count is always zero
Chris@10:         \dopdfoutline{##1}{}{##3}{##4}}%
Chris@10:       %
Chris@10:       % PDF outlines are displayed using system fonts, instead of
Chris@10:       % document fonts.  Therefore we cannot use special characters,
Chris@10:       % since the encoding is unknown.  For example, the eogonek from
Chris@10:       % Latin 2 (0xea) gets translated to a | character.  Info from
Chris@10:       % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100.
Chris@10:       %
Chris@10:       % TODO this right, we have to translate 8-bit characters to
Chris@10:       % their "best" equivalent, based on the @documentencoding.  Too
Chris@10:       % much work for too little return.  Just use the ASCII equivalents
Chris@10:       % we use for the index sort strings.
Chris@10:       % 
Chris@10:       \indexnofonts
Chris@10:       \setupdatafile
Chris@10:       % We can have normal brace characters in the PDF outlines, unlike
Chris@10:       % Texinfo index files.  So set that up.
Chris@10:       \def\{{\lbracecharliteral}%
Chris@10:       \def\}{\rbracecharliteral}%
Chris@10:       \catcode`\\=\active \otherbackslash
Chris@10:       \input \tocreadfilename
Chris@10:     \endgroup
Chris@10:   }
Chris@10:   {\catcode`[=1 \catcode`]=2
Chris@10:    \catcode`{=\other \catcode`}=\other
Chris@10:    \gdef\lbracecharliteral[{]%
Chris@10:    \gdef\rbracecharliteral[}]%
Chris@10:   ]
Chris@10:   %
Chris@10:   \def\skipspaces#1{\def\PP{#1}\def\D{|}%
Chris@10:     \ifx\PP\D\let\nextsp\relax
Chris@10:     \else\let\nextsp\skipspaces
Chris@10:       \ifx\p\space\else\addtokens{\filename}{\PP}%
Chris@10:         \advance\filenamelength by 1
Chris@10:       \fi
Chris@10:     \fi
Chris@10:     \nextsp}
Chris@10:   \def\getfilename#1{%
Chris@10:     \filenamelength=0
Chris@10:     % If we don't expand the argument now, \skipspaces will get
Chris@10:     % snagged on things like "@value{foo}".
Chris@10:     \edef\temp{#1}%
Chris@10:     \expandafter\skipspaces\temp|\relax
Chris@10:   }
Chris@10:   \ifnum\pdftexversion < 14
Chris@10:     \let \startlink \pdfannotlink
Chris@10:   \else
Chris@10:     \let \startlink \pdfstartlink
Chris@10:   \fi
Chris@10:   % make a live url in pdf output.
Chris@10:   \def\pdfurl#1{%
Chris@10:     \begingroup
Chris@10:       % it seems we really need yet another set of dummies; have not
Chris@10:       % tried to figure out what each command should do in the context
Chris@10:       % of @url.  for now, just make @/ a no-op, that's the only one
Chris@10:       % people have actually reported a problem with.
Chris@10:       %
Chris@10:       \normalturnoffactive
Chris@10:       \def\@{@}%
Chris@10:       \let\/=\empty
Chris@10:       \makevalueexpandable
Chris@10:       % do we want to go so far as to use \indexnofonts instead of just
Chris@10:       % special-casing \var here?
Chris@10:       \def\var##1{##1}%
Chris@10:       %
Chris@10:       \leavevmode\setcolor{\urlcolor}%
Chris@10:       \startlink attr{/Border [0 0 0]}%
Chris@10:         user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
Chris@10:     \endgroup}
Chris@10:   \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
Chris@10:   \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
Chris@10:   \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
Chris@10:   \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
Chris@10:   \def\maketoks{%
Chris@10:     \expandafter\poptoks\the\toksA|ENDTOKS|\relax
Chris@10:     \ifx\first0\adn0
Chris@10:     \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
Chris@10:     \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
Chris@10:     \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
Chris@10:     \else
Chris@10:       \ifnum0=\countA\else\makelink\fi
Chris@10:       \ifx\first.\let\next=\done\else
Chris@10:         \let\next=\maketoks
Chris@10:         \addtokens{\toksB}{\the\toksD}
Chris@10:         \ifx\first,\addtokens{\toksB}{\space}\fi
Chris@10:       \fi
Chris@10:     \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
Chris@10:     \next}
Chris@10:   \def\makelink{\addtokens{\toksB}%
Chris@10:     {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
Chris@10:   \def\pdflink#1{%
Chris@10:     \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}}
Chris@10:     \setcolor{\linkcolor}#1\endlink}
Chris@10:   \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
Chris@10: \else
Chris@10:   % non-pdf mode
Chris@10:   \let\pdfmkdest = \gobble
Chris@10:   \let\pdfurl = \gobble
Chris@10:   \let\endlink = \relax
Chris@10:   \let\setcolor = \gobble
Chris@10:   \let\pdfsetcolor = \gobble
Chris@10:   \let\pdfmakeoutlines = \relax
Chris@10: \fi  % \ifx\pdfoutput
Chris@10: 
Chris@10: 
Chris@10: \message{fonts,}
Chris@10: 
Chris@10: % Change the current font style to #1, remembering it in \curfontstyle.
Chris@10: % For now, we do not accumulate font styles: @b{@i{foo}} prints foo in
Chris@10: % italics, not bold italics.
Chris@10: %
Chris@10: \def\setfontstyle#1{%
Chris@10:   \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd.
Chris@10:   \csname ten#1\endcsname  % change the current font
Chris@10: }
Chris@10: 
Chris@10: % Select #1 fonts with the current style.
Chris@10: %
Chris@10: \def\selectfonts#1{\csname #1fonts\endcsname \csname\curfontstyle\endcsname}
Chris@10: 
Chris@10: \def\rm{\fam=0 \setfontstyle{rm}}
Chris@10: \def\it{\fam=\itfam \setfontstyle{it}}
Chris@10: \def\sl{\fam=\slfam \setfontstyle{sl}}
Chris@10: \def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf}
Chris@10: \def\tt{\fam=\ttfam \setfontstyle{tt}}
Chris@10: 
Chris@10: % Unfortunately, we have to override this for titles and the like, since
Chris@10: % in those cases "rm" is bold.  Sigh.
Chris@10: \def\rmisbold{\rm\def\curfontstyle{bf}}
Chris@10: 
Chris@10: % Texinfo sort of supports the sans serif font style, which plain TeX does not.
Chris@10: % So we set up a \sf.
Chris@10: \newfam\sffam
Chris@10: \def\sf{\fam=\sffam \setfontstyle{sf}}
Chris@10: \let\li = \sf % Sometimes we call it \li, not \sf.
Chris@10: 
Chris@10: % We don't need math for this font style.
Chris@10: \def\ttsl{\setfontstyle{ttsl}}
Chris@10: 
Chris@10: 
Chris@10: % Default leading.
Chris@10: \newdimen\textleading  \textleading = 13.2pt
Chris@10: 
Chris@10: % Set the baselineskip to #1, and the lineskip and strut size
Chris@10: % correspondingly.  There is no deep meaning behind these magic numbers
Chris@10: % used as factors; they just match (closely enough) what Knuth defined.
Chris@10: %
Chris@10: \def\lineskipfactor{.08333}
Chris@10: \def\strutheightpercent{.70833}
Chris@10: \def\strutdepthpercent {.29167}
Chris@10: %
Chris@10: % can get a sort of poor man's double spacing by redefining this.
Chris@10: \def\baselinefactor{1}
Chris@10: %
Chris@10: \def\setleading#1{%
Chris@10:   \dimen0 = #1\relax
Chris@10:   \normalbaselineskip = \baselinefactor\dimen0
Chris@10:   \normallineskip = \lineskipfactor\normalbaselineskip
Chris@10:   \normalbaselines
Chris@10:   \setbox\strutbox =\hbox{%
Chris@10:     \vrule width0pt height\strutheightpercent\baselineskip
Chris@10:                     depth \strutdepthpercent \baselineskip
Chris@10:   }%
Chris@10: }
Chris@10: 
Chris@10: % PDF CMaps.  See also LaTeX's t1.cmap.
Chris@10: %
Chris@10: % do nothing with this by default.
Chris@10: \expandafter\let\csname cmapOT1\endcsname\gobble
Chris@10: \expandafter\let\csname cmapOT1IT\endcsname\gobble
Chris@10: \expandafter\let\csname cmapOT1TT\endcsname\gobble
Chris@10: 
Chris@10: % if we are producing pdf, and we have \pdffontattr, then define cmaps.
Chris@10: % (\pdffontattr was introduced many years ago, but people still run
Chris@10: % older pdftex's; it's easy to conditionalize, so we do.)
Chris@10: \ifpdf \ifx\pdffontattr\thisisundefined \else
Chris@10:   \begingroup
Chris@10:     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
Chris@10:     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
Chris@10: %%DocumentNeededResources: ProcSet (CIDInit)
Chris@10: %%IncludeResource: ProcSet (CIDInit)
Chris@10: %%BeginResource: CMap (TeX-OT1-0)
Chris@10: %%Title: (TeX-OT1-0 TeX OT1 0)
Chris@10: %%Version: 1.000
Chris@10: %%EndComments
Chris@10: /CIDInit /ProcSet findresource begin
Chris@10: 12 dict begin
Chris@10: begincmap
Chris@10: /CIDSystemInfo
Chris@10: << /Registry (TeX)
Chris@10: /Ordering (OT1)
Chris@10: /Supplement 0
Chris@10: >> def
Chris@10: /CMapName /TeX-OT1-0 def
Chris@10: /CMapType 2 def
Chris@10: 1 begincodespacerange
Chris@10: <00> <7F>
Chris@10: endcodespacerange
Chris@10: 8 beginbfrange
Chris@10: <00> <01> <0393>
Chris@10: <09> <0A> <03A8>
Chris@10: <23> <26> <0023>
Chris@10: <28> <3B> <0028>
Chris@10: <3F> <5B> <003F>
Chris@10: <5D> <5E> <005D>
Chris@10: <61> <7A> <0061>
Chris@10: <7B> <7C> <2013>
Chris@10: endbfrange
Chris@10: 40 beginbfchar
Chris@10: <02> <0398>
Chris@10: <03> <039B>
Chris@10: <04> <039E>
Chris@10: <05> <03A0>
Chris@10: <06> <03A3>
Chris@10: <07> <03D2>
Chris@10: <08> <03A6>
Chris@10: <0B> <00660066>
Chris@10: <0C> <00660069>
Chris@10: <0D> <0066006C>
Chris@10: <0E> <006600660069>
Chris@10: <0F> <00660066006C>
Chris@10: <10> <0131>
Chris@10: <11> <0237>
Chris@10: <12> <0060>
Chris@10: <13> <00B4>
Chris@10: <14> <02C7>
Chris@10: <15> <02D8>
Chris@10: <16> <00AF>
Chris@10: <17> <02DA>
Chris@10: <18> <00B8>
Chris@10: <19> <00DF>
Chris@10: <1A> <00E6>
Chris@10: <1B> <0153>
Chris@10: <1C> <00F8>
Chris@10: <1D> <00C6>
Chris@10: <1E> <0152>
Chris@10: <1F> <00D8>
Chris@10: <21> <0021>
Chris@10: <22> <201D>
Chris@10: <27> <2019>
Chris@10: <3C> <00A1>
Chris@10: <3D> <003D>
Chris@10: <3E> <00BF>
Chris@10: <5C> <201C>
Chris@10: <5F> <02D9>
Chris@10: <60> <2018>
Chris@10: <7D> <02DD>
Chris@10: <7E> <007E>
Chris@10: <7F> <00A8>
Chris@10: endbfchar
Chris@10: endcmap
Chris@10: CMapName currentdict /CMap defineresource pop
Chris@10: end
Chris@10: end
Chris@10: %%EndResource
Chris@10: %%EOF
Chris@10:     }\endgroup
Chris@10:   \expandafter\edef\csname cmapOT1\endcsname#1{%
Chris@10:     \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
Chris@10:   }%
Chris@10: %
Chris@10: % \cmapOT1IT
Chris@10:   \begingroup
Chris@10:     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
Chris@10:     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
Chris@10: %%DocumentNeededResources: ProcSet (CIDInit)
Chris@10: %%IncludeResource: ProcSet (CIDInit)
Chris@10: %%BeginResource: CMap (TeX-OT1IT-0)
Chris@10: %%Title: (TeX-OT1IT-0 TeX OT1IT 0)
Chris@10: %%Version: 1.000
Chris@10: %%EndComments
Chris@10: /CIDInit /ProcSet findresource begin
Chris@10: 12 dict begin
Chris@10: begincmap
Chris@10: /CIDSystemInfo
Chris@10: << /Registry (TeX)
Chris@10: /Ordering (OT1IT)
Chris@10: /Supplement 0
Chris@10: >> def
Chris@10: /CMapName /TeX-OT1IT-0 def
Chris@10: /CMapType 2 def
Chris@10: 1 begincodespacerange
Chris@10: <00> <7F>
Chris@10: endcodespacerange
Chris@10: 8 beginbfrange
Chris@10: <00> <01> <0393>
Chris@10: <09> <0A> <03A8>
Chris@10: <25> <26> <0025>
Chris@10: <28> <3B> <0028>
Chris@10: <3F> <5B> <003F>
Chris@10: <5D> <5E> <005D>
Chris@10: <61> <7A> <0061>
Chris@10: <7B> <7C> <2013>
Chris@10: endbfrange
Chris@10: 42 beginbfchar
Chris@10: <02> <0398>
Chris@10: <03> <039B>
Chris@10: <04> <039E>
Chris@10: <05> <03A0>
Chris@10: <06> <03A3>
Chris@10: <07> <03D2>
Chris@10: <08> <03A6>
Chris@10: <0B> <00660066>
Chris@10: <0C> <00660069>
Chris@10: <0D> <0066006C>
Chris@10: <0E> <006600660069>
Chris@10: <0F> <00660066006C>
Chris@10: <10> <0131>
Chris@10: <11> <0237>
Chris@10: <12> <0060>
Chris@10: <13> <00B4>
Chris@10: <14> <02C7>
Chris@10: <15> <02D8>
Chris@10: <16> <00AF>
Chris@10: <17> <02DA>
Chris@10: <18> <00B8>
Chris@10: <19> <00DF>
Chris@10: <1A> <00E6>
Chris@10: <1B> <0153>
Chris@10: <1C> <00F8>
Chris@10: <1D> <00C6>
Chris@10: <1E> <0152>
Chris@10: <1F> <00D8>
Chris@10: <21> <0021>
Chris@10: <22> <201D>
Chris@10: <23> <0023>
Chris@10: <24> <00A3>
Chris@10: <27> <2019>
Chris@10: <3C> <00A1>
Chris@10: <3D> <003D>
Chris@10: <3E> <00BF>
Chris@10: <5C> <201C>
Chris@10: <5F> <02D9>
Chris@10: <60> <2018>
Chris@10: <7D> <02DD>
Chris@10: <7E> <007E>
Chris@10: <7F> <00A8>
Chris@10: endbfchar
Chris@10: endcmap
Chris@10: CMapName currentdict /CMap defineresource pop
Chris@10: end
Chris@10: end
Chris@10: %%EndResource
Chris@10: %%EOF
Chris@10:     }\endgroup
Chris@10:   \expandafter\edef\csname cmapOT1IT\endcsname#1{%
Chris@10:     \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
Chris@10:   }%
Chris@10: %
Chris@10: % \cmapOT1TT
Chris@10:   \begingroup
Chris@10:     \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
Chris@10:     \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
Chris@10: %%DocumentNeededResources: ProcSet (CIDInit)
Chris@10: %%IncludeResource: ProcSet (CIDInit)
Chris@10: %%BeginResource: CMap (TeX-OT1TT-0)
Chris@10: %%Title: (TeX-OT1TT-0 TeX OT1TT 0)
Chris@10: %%Version: 1.000
Chris@10: %%EndComments
Chris@10: /CIDInit /ProcSet findresource begin
Chris@10: 12 dict begin
Chris@10: begincmap
Chris@10: /CIDSystemInfo
Chris@10: << /Registry (TeX)
Chris@10: /Ordering (OT1TT)
Chris@10: /Supplement 0
Chris@10: >> def
Chris@10: /CMapName /TeX-OT1TT-0 def
Chris@10: /CMapType 2 def
Chris@10: 1 begincodespacerange
Chris@10: <00> <7F>
Chris@10: endcodespacerange
Chris@10: 5 beginbfrange
Chris@10: <00> <01> <0393>
Chris@10: <09> <0A> <03A8>
Chris@10: <21> <26> <0021>
Chris@10: <28> <5F> <0028>
Chris@10: <61> <7E> <0061>
Chris@10: endbfrange
Chris@10: 32 beginbfchar
Chris@10: <02> <0398>
Chris@10: <03> <039B>
Chris@10: <04> <039E>
Chris@10: <05> <03A0>
Chris@10: <06> <03A3>
Chris@10: <07> <03D2>
Chris@10: <08> <03A6>
Chris@10: <0B> <2191>
Chris@10: <0C> <2193>
Chris@10: <0D> <0027>
Chris@10: <0E> <00A1>
Chris@10: <0F> <00BF>
Chris@10: <10> <0131>
Chris@10: <11> <0237>
Chris@10: <12> <0060>
Chris@10: <13> <00B4>
Chris@10: <14> <02C7>
Chris@10: <15> <02D8>
Chris@10: <16> <00AF>
Chris@10: <17> <02DA>
Chris@10: <18> <00B8>
Chris@10: <19> <00DF>
Chris@10: <1A> <00E6>
Chris@10: <1B> <0153>
Chris@10: <1C> <00F8>
Chris@10: <1D> <00C6>
Chris@10: <1E> <0152>
Chris@10: <1F> <00D8>
Chris@10: <20> <2423>
Chris@10: <27> <2019>
Chris@10: <60> <2018>
Chris@10: <7F> <00A8>
Chris@10: endbfchar
Chris@10: endcmap
Chris@10: CMapName currentdict /CMap defineresource pop
Chris@10: end
Chris@10: end
Chris@10: %%EndResource
Chris@10: %%EOF
Chris@10:     }\endgroup
Chris@10:   \expandafter\edef\csname cmapOT1TT\endcsname#1{%
Chris@10:     \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
Chris@10:   }%
Chris@10: \fi\fi
Chris@10: 
Chris@10: 
Chris@10: % Set the font macro #1 to the font named #2, adding on the
Chris@10: % specified font prefix (normally `cm').
Chris@10: % #3 is the font's design size, #4 is a scale factor, #5 is the CMap
Chris@10: % encoding (currently only OT1, OT1IT and OT1TT are allowed, pass
Chris@10: % empty to omit).
Chris@10: \def\setfont#1#2#3#4#5{%
Chris@10:   \font#1=\fontprefix#2#3 scaled #4
Chris@10:   \csname cmap#5\endcsname#1%
Chris@10: }
Chris@10: % This is what gets called when #5 of \setfont is empty.
Chris@10: \let\cmap\gobble
Chris@10: % emacs-page end of cmaps
Chris@10: 
Chris@10: % Use cm as the default font prefix.
Chris@10: % To specify the font prefix, you must define \fontprefix
Chris@10: % before you read in texinfo.tex.
Chris@10: \ifx\fontprefix\thisisundefined
Chris@10: \def\fontprefix{cm}
Chris@10: \fi
Chris@10: % Support font families that don't use the same naming scheme as CM.
Chris@10: \def\rmshape{r}
Chris@10: \def\rmbshape{bx}               %where the normal face is bold
Chris@10: \def\bfshape{b}
Chris@10: \def\bxshape{bx}
Chris@10: \def\ttshape{tt}
Chris@10: \def\ttbshape{tt}
Chris@10: \def\ttslshape{sltt}
Chris@10: \def\itshape{ti}
Chris@10: \def\itbshape{bxti}
Chris@10: \def\slshape{sl}
Chris@10: \def\slbshape{bxsl}
Chris@10: \def\sfshape{ss}
Chris@10: \def\sfbshape{ss}
Chris@10: \def\scshape{csc}
Chris@10: \def\scbshape{csc}
Chris@10: 
Chris@10: % Definitions for a main text size of 11pt.  This is the default in
Chris@10: % Texinfo.
Chris@10: %
Chris@10: \def\definetextfontsizexi{%
Chris@10: % Text fonts (11.2pt, magstep1).
Chris@10: \def\textnominalsize{11pt}
Chris@10: \edef\mainmagstep{\magstephalf}
Chris@10: \setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
Chris@10: \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
Chris@10: \setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
Chris@10: \setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
Chris@10: \setfont\textsl\slshape{10}{\mainmagstep}{OT1}
Chris@10: \setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
Chris@10: \setfont\textsc\scshape{10}{\mainmagstep}{OT1}
Chris@10: \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
Chris@10: \font\texti=cmmi10 scaled \mainmagstep
Chris@10: \font\textsy=cmsy10 scaled \mainmagstep
Chris@10: \def\textecsize{1095}
Chris@10: 
Chris@10: % A few fonts for @defun names and args.
Chris@10: \setfont\defbf\bfshape{10}{\magstep1}{OT1}
Chris@10: \setfont\deftt\ttshape{10}{\magstep1}{OT1TT}
Chris@10: \setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT}
Chris@10: \def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf}
Chris@10: 
Chris@10: % Fonts for indices, footnotes, small examples (9pt).
Chris@10: \def\smallnominalsize{9pt}
Chris@10: \setfont\smallrm\rmshape{9}{1000}{OT1}
Chris@10: \setfont\smalltt\ttshape{9}{1000}{OT1TT}
Chris@10: \setfont\smallbf\bfshape{10}{900}{OT1}
Chris@10: \setfont\smallit\itshape{9}{1000}{OT1IT}
Chris@10: \setfont\smallsl\slshape{9}{1000}{OT1}
Chris@10: \setfont\smallsf\sfshape{9}{1000}{OT1}
Chris@10: \setfont\smallsc\scshape{10}{900}{OT1}
Chris@10: \setfont\smallttsl\ttslshape{10}{900}{OT1TT}
Chris@10: \font\smalli=cmmi9
Chris@10: \font\smallsy=cmsy9
Chris@10: \def\smallecsize{0900}
Chris@10: 
Chris@10: % Fonts for small examples (8pt).
Chris@10: \def\smallernominalsize{8pt}
Chris@10: \setfont\smallerrm\rmshape{8}{1000}{OT1}
Chris@10: \setfont\smallertt\ttshape{8}{1000}{OT1TT}
Chris@10: \setfont\smallerbf\bfshape{10}{800}{OT1}
Chris@10: \setfont\smallerit\itshape{8}{1000}{OT1IT}
Chris@10: \setfont\smallersl\slshape{8}{1000}{OT1}
Chris@10: \setfont\smallersf\sfshape{8}{1000}{OT1}
Chris@10: \setfont\smallersc\scshape{10}{800}{OT1}
Chris@10: \setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
Chris@10: \font\smalleri=cmmi8
Chris@10: \font\smallersy=cmsy8
Chris@10: \def\smallerecsize{0800}
Chris@10: 
Chris@10: % Fonts for title page (20.4pt):
Chris@10: \def\titlenominalsize{20pt}
Chris@10: \setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
Chris@10: \setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
Chris@10: \setfont\titlesl\slbshape{10}{\magstep4}{OT1}
Chris@10: \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
Chris@10: \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
Chris@10: \setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
Chris@10: \let\titlebf=\titlerm
Chris@10: \setfont\titlesc\scbshape{10}{\magstep4}{OT1}
Chris@10: \font\titlei=cmmi12 scaled \magstep3
Chris@10: \font\titlesy=cmsy10 scaled \magstep4
Chris@10: \def\titleecsize{2074}
Chris@10: 
Chris@10: % Chapter (and unnumbered) fonts (17.28pt).
Chris@10: \def\chapnominalsize{17pt}
Chris@10: \setfont\chaprm\rmbshape{12}{\magstep2}{OT1}
Chris@10: \setfont\chapit\itbshape{10}{\magstep3}{OT1IT}
Chris@10: \setfont\chapsl\slbshape{10}{\magstep3}{OT1}
Chris@10: \setfont\chaptt\ttbshape{12}{\magstep2}{OT1TT}
Chris@10: \setfont\chapttsl\ttslshape{10}{\magstep3}{OT1TT}
Chris@10: \setfont\chapsf\sfbshape{17}{1000}{OT1}
Chris@10: \let\chapbf=\chaprm
Chris@10: \setfont\chapsc\scbshape{10}{\magstep3}{OT1}
Chris@10: \font\chapi=cmmi12 scaled \magstep2
Chris@10: \font\chapsy=cmsy10 scaled \magstep3
Chris@10: \def\chapecsize{1728}
Chris@10: 
Chris@10: % Section fonts (14.4pt).
Chris@10: \def\secnominalsize{14pt}
Chris@10: \setfont\secrm\rmbshape{12}{\magstep1}{OT1}
Chris@10: \setfont\secit\itbshape{10}{\magstep2}{OT1IT}
Chris@10: \setfont\secsl\slbshape{10}{\magstep2}{OT1}
Chris@10: \setfont\sectt\ttbshape{12}{\magstep1}{OT1TT}
Chris@10: \setfont\secttsl\ttslshape{10}{\magstep2}{OT1TT}
Chris@10: \setfont\secsf\sfbshape{12}{\magstep1}{OT1}
Chris@10: \let\secbf\secrm
Chris@10: \setfont\secsc\scbshape{10}{\magstep2}{OT1}
Chris@10: \font\seci=cmmi12 scaled \magstep1
Chris@10: \font\secsy=cmsy10 scaled \magstep2
Chris@10: \def\sececsize{1440}
Chris@10: 
Chris@10: % Subsection fonts (13.15pt).
Chris@10: \def\ssecnominalsize{13pt}
Chris@10: \setfont\ssecrm\rmbshape{12}{\magstephalf}{OT1}
Chris@10: \setfont\ssecit\itbshape{10}{1315}{OT1IT}
Chris@10: \setfont\ssecsl\slbshape{10}{1315}{OT1}
Chris@10: \setfont\ssectt\ttbshape{12}{\magstephalf}{OT1TT}
Chris@10: \setfont\ssecttsl\ttslshape{10}{1315}{OT1TT}
Chris@10: \setfont\ssecsf\sfbshape{12}{\magstephalf}{OT1}
Chris@10: \let\ssecbf\ssecrm
Chris@10: \setfont\ssecsc\scbshape{10}{1315}{OT1}
Chris@10: \font\sseci=cmmi12 scaled \magstephalf
Chris@10: \font\ssecsy=cmsy10 scaled 1315
Chris@10: \def\ssececsize{1200}
Chris@10: 
Chris@10: % Reduced fonts for @acro in text (10pt).
Chris@10: \def\reducednominalsize{10pt}
Chris@10: \setfont\reducedrm\rmshape{10}{1000}{OT1}
Chris@10: \setfont\reducedtt\ttshape{10}{1000}{OT1TT}
Chris@10: \setfont\reducedbf\bfshape{10}{1000}{OT1}
Chris@10: \setfont\reducedit\itshape{10}{1000}{OT1IT}
Chris@10: \setfont\reducedsl\slshape{10}{1000}{OT1}
Chris@10: \setfont\reducedsf\sfshape{10}{1000}{OT1}
Chris@10: \setfont\reducedsc\scshape{10}{1000}{OT1}
Chris@10: \setfont\reducedttsl\ttslshape{10}{1000}{OT1TT}
Chris@10: \font\reducedi=cmmi10
Chris@10: \font\reducedsy=cmsy10
Chris@10: \def\reducedecsize{1000}
Chris@10: 
Chris@10: \textleading = 13.2pt % line spacing for 11pt CM
Chris@10: \textfonts            % reset the current fonts
Chris@10: \rm
Chris@10: } % end of 11pt text font size definitions
Chris@10: 
Chris@10: 
Chris@10: % Definitions to make the main text be 10pt Computer Modern, with
Chris@10: % section, chapter, etc., sizes following suit.  This is for the GNU
Chris@10: % Press printing of the Emacs 22 manual.  Maybe other manuals in the
Chris@10: % future.  Used with @smallbook, which sets the leading to 12pt.
Chris@10: %
Chris@10: \def\definetextfontsizex{%
Chris@10: % Text fonts (10pt).
Chris@10: \def\textnominalsize{10pt}
Chris@10: \edef\mainmagstep{1000}
Chris@10: \setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
Chris@10: \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
Chris@10: \setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
Chris@10: \setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
Chris@10: \setfont\textsl\slshape{10}{\mainmagstep}{OT1}
Chris@10: \setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
Chris@10: \setfont\textsc\scshape{10}{\mainmagstep}{OT1}
Chris@10: \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
Chris@10: \font\texti=cmmi10 scaled \mainmagstep
Chris@10: \font\textsy=cmsy10 scaled \mainmagstep
Chris@10: \def\textecsize{1000}
Chris@10: 
Chris@10: % A few fonts for @defun names and args.
Chris@10: \setfont\defbf\bfshape{10}{\magstephalf}{OT1}
Chris@10: \setfont\deftt\ttshape{10}{\magstephalf}{OT1TT}
Chris@10: \setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT}
Chris@10: \def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf}
Chris@10: 
Chris@10: % Fonts for indices, footnotes, small examples (9pt).
Chris@10: \def\smallnominalsize{9pt}
Chris@10: \setfont\smallrm\rmshape{9}{1000}{OT1}
Chris@10: \setfont\smalltt\ttshape{9}{1000}{OT1TT}
Chris@10: \setfont\smallbf\bfshape{10}{900}{OT1}
Chris@10: \setfont\smallit\itshape{9}{1000}{OT1IT}
Chris@10: \setfont\smallsl\slshape{9}{1000}{OT1}
Chris@10: \setfont\smallsf\sfshape{9}{1000}{OT1}
Chris@10: \setfont\smallsc\scshape{10}{900}{OT1}
Chris@10: \setfont\smallttsl\ttslshape{10}{900}{OT1TT}
Chris@10: \font\smalli=cmmi9
Chris@10: \font\smallsy=cmsy9
Chris@10: \def\smallecsize{0900}
Chris@10: 
Chris@10: % Fonts for small examples (8pt).
Chris@10: \def\smallernominalsize{8pt}
Chris@10: \setfont\smallerrm\rmshape{8}{1000}{OT1}
Chris@10: \setfont\smallertt\ttshape{8}{1000}{OT1TT}
Chris@10: \setfont\smallerbf\bfshape{10}{800}{OT1}
Chris@10: \setfont\smallerit\itshape{8}{1000}{OT1IT}
Chris@10: \setfont\smallersl\slshape{8}{1000}{OT1}
Chris@10: \setfont\smallersf\sfshape{8}{1000}{OT1}
Chris@10: \setfont\smallersc\scshape{10}{800}{OT1}
Chris@10: \setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
Chris@10: \font\smalleri=cmmi8
Chris@10: \font\smallersy=cmsy8
Chris@10: \def\smallerecsize{0800}
Chris@10: 
Chris@10: % Fonts for title page (20.4pt):
Chris@10: \def\titlenominalsize{20pt}
Chris@10: \setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
Chris@10: \setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
Chris@10: \setfont\titlesl\slbshape{10}{\magstep4}{OT1}
Chris@10: \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
Chris@10: \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
Chris@10: \setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
Chris@10: \let\titlebf=\titlerm
Chris@10: \setfont\titlesc\scbshape{10}{\magstep4}{OT1}
Chris@10: \font\titlei=cmmi12 scaled \magstep3
Chris@10: \font\titlesy=cmsy10 scaled \magstep4
Chris@10: \def\titleecsize{2074}
Chris@10: 
Chris@10: % Chapter fonts (14.4pt).
Chris@10: \def\chapnominalsize{14pt}
Chris@10: \setfont\chaprm\rmbshape{12}{\magstep1}{OT1}
Chris@10: \setfont\chapit\itbshape{10}{\magstep2}{OT1IT}
Chris@10: \setfont\chapsl\slbshape{10}{\magstep2}{OT1}
Chris@10: \setfont\chaptt\ttbshape{12}{\magstep1}{OT1TT}
Chris@10: \setfont\chapttsl\ttslshape{10}{\magstep2}{OT1TT}
Chris@10: \setfont\chapsf\sfbshape{12}{\magstep1}{OT1}
Chris@10: \let\chapbf\chaprm
Chris@10: \setfont\chapsc\scbshape{10}{\magstep2}{OT1}
Chris@10: \font\chapi=cmmi12 scaled \magstep1
Chris@10: \font\chapsy=cmsy10 scaled \magstep2
Chris@10: \def\chapecsize{1440}
Chris@10: 
Chris@10: % Section fonts (12pt).
Chris@10: \def\secnominalsize{12pt}
Chris@10: \setfont\secrm\rmbshape{12}{1000}{OT1}
Chris@10: \setfont\secit\itbshape{10}{\magstep1}{OT1IT}
Chris@10: \setfont\secsl\slbshape{10}{\magstep1}{OT1}
Chris@10: \setfont\sectt\ttbshape{12}{1000}{OT1TT}
Chris@10: \setfont\secttsl\ttslshape{10}{\magstep1}{OT1TT}
Chris@10: \setfont\secsf\sfbshape{12}{1000}{OT1}
Chris@10: \let\secbf\secrm
Chris@10: \setfont\secsc\scbshape{10}{\magstep1}{OT1}
Chris@10: \font\seci=cmmi12
Chris@10: \font\secsy=cmsy10 scaled \magstep1
Chris@10: \def\sececsize{1200}
Chris@10: 
Chris@10: % Subsection fonts (10pt).
Chris@10: \def\ssecnominalsize{10pt}
Chris@10: \setfont\ssecrm\rmbshape{10}{1000}{OT1}
Chris@10: \setfont\ssecit\itbshape{10}{1000}{OT1IT}
Chris@10: \setfont\ssecsl\slbshape{10}{1000}{OT1}
Chris@10: \setfont\ssectt\ttbshape{10}{1000}{OT1TT}
Chris@10: \setfont\ssecttsl\ttslshape{10}{1000}{OT1TT}
Chris@10: \setfont\ssecsf\sfbshape{10}{1000}{OT1}
Chris@10: \let\ssecbf\ssecrm
Chris@10: \setfont\ssecsc\scbshape{10}{1000}{OT1}
Chris@10: \font\sseci=cmmi10
Chris@10: \font\ssecsy=cmsy10
Chris@10: \def\ssececsize{1000}
Chris@10: 
Chris@10: % Reduced fonts for @acro in text (9pt).
Chris@10: \def\reducednominalsize{9pt}
Chris@10: \setfont\reducedrm\rmshape{9}{1000}{OT1}
Chris@10: \setfont\reducedtt\ttshape{9}{1000}{OT1TT}
Chris@10: \setfont\reducedbf\bfshape{10}{900}{OT1}
Chris@10: \setfont\reducedit\itshape{9}{1000}{OT1IT}
Chris@10: \setfont\reducedsl\slshape{9}{1000}{OT1}
Chris@10: \setfont\reducedsf\sfshape{9}{1000}{OT1}
Chris@10: \setfont\reducedsc\scshape{10}{900}{OT1}
Chris@10: \setfont\reducedttsl\ttslshape{10}{900}{OT1TT}
Chris@10: \font\reducedi=cmmi9
Chris@10: \font\reducedsy=cmsy9
Chris@10: \def\reducedecsize{0900}
Chris@10: 
Chris@10: \divide\parskip by 2  % reduce space between paragraphs
Chris@10: \textleading = 12pt   % line spacing for 10pt CM
Chris@10: \textfonts            % reset the current fonts
Chris@10: \rm
Chris@10: } % end of 10pt text font size definitions
Chris@10: 
Chris@10: 
Chris@10: % We provide the user-level command
Chris@10: %   @fonttextsize 10
Chris@10: % (or 11) to redefine the text font size.  pt is assumed.
Chris@10: %
Chris@10: \def\xiword{11}
Chris@10: \def\xword{10}
Chris@10: \def\xwordpt{10pt}
Chris@10: %
Chris@10: \parseargdef\fonttextsize{%
Chris@10:   \def\textsizearg{#1}%
Chris@10:   %\wlog{doing @fonttextsize \textsizearg}%
Chris@10:   %
Chris@10:   % Set \globaldefs so that documents can use this inside @tex, since
Chris@10:   % makeinfo 4.8 does not support it, but we need it nonetheless.
Chris@10:   %
Chris@10:  \begingroup \globaldefs=1
Chris@10:   \ifx\textsizearg\xword \definetextfontsizex
Chris@10:   \else \ifx\textsizearg\xiword \definetextfontsizexi
Chris@10:   \else
Chris@10:     \errhelp=\EMsimple
Chris@10:     \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'}
Chris@10:   \fi\fi
Chris@10:  \endgroup
Chris@10: }
Chris@10: 
Chris@10: 
Chris@10: % In order for the font changes to affect most math symbols and letters,
Chris@10: % we have to define the \textfont of the standard families.  Since
Chris@10: % texinfo doesn't allow for producing subscripts and superscripts except
Chris@10: % in the main text, we don't bother to reset \scriptfont and
Chris@10: % \scriptscriptfont (which would also require loading a lot more fonts).
Chris@10: %
Chris@10: \def\resetmathfonts{%
Chris@10:   \textfont0=\tenrm \textfont1=\teni \textfont2=\tensy
Chris@10:   \textfont\itfam=\tenit \textfont\slfam=\tensl \textfont\bffam=\tenbf
Chris@10:   \textfont\ttfam=\tentt \textfont\sffam=\tensf
Chris@10: }
Chris@10: 
Chris@10: % The font-changing commands redefine the meanings of \tenSTYLE, instead
Chris@10: % of just \STYLE.  We do this because \STYLE needs to also set the
Chris@10: % current \fam for math mode.  Our \STYLE (e.g., \rm) commands hardwire
Chris@10: % \tenSTYLE to set the current font.
Chris@10: %
Chris@10: % Each font-changing command also sets the names \lsize (one size lower)
Chris@10: % and \lllsize (three sizes lower).  These relative commands are used in
Chris@10: % the LaTeX logo and acronyms.
Chris@10: %
Chris@10: % This all needs generalizing, badly.
Chris@10: %
Chris@10: \def\textfonts{%
Chris@10:   \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
Chris@10:   \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
Chris@10:   \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy
Chris@10:   \let\tenttsl=\textttsl
Chris@10:   \def\curfontsize{text}%
Chris@10:   \def\lsize{reduced}\def\lllsize{smaller}%
Chris@10:   \resetmathfonts \setleading{\textleading}}
Chris@10: \def\titlefonts{%
Chris@10:   \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl
Chris@10:   \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc
Chris@10:   \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy
Chris@10:   \let\tenttsl=\titlettsl
Chris@10:   \def\curfontsize{title}%
Chris@10:   \def\lsize{chap}\def\lllsize{subsec}%
Chris@10:   \resetmathfonts \setleading{27pt}}
Chris@10: \def\titlefont#1{{\titlefonts\rmisbold #1}}
Chris@10: \def\chapfonts{%
Chris@10:   \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl
Chris@10:   \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
Chris@10:   \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy
Chris@10:   \let\tenttsl=\chapttsl
Chris@10:   \def\curfontsize{chap}%
Chris@10:   \def\lsize{sec}\def\lllsize{text}%
Chris@10:   \resetmathfonts \setleading{19pt}}
Chris@10: \def\secfonts{%
Chris@10:   \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl
Chris@10:   \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc
Chris@10:   \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy
Chris@10:   \let\tenttsl=\secttsl
Chris@10:   \def\curfontsize{sec}%
Chris@10:   \def\lsize{subsec}\def\lllsize{reduced}%
Chris@10:   \resetmathfonts \setleading{16pt}}
Chris@10: \def\subsecfonts{%
Chris@10:   \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl
Chris@10:   \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc
Chris@10:   \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy
Chris@10:   \let\tenttsl=\ssecttsl
Chris@10:   \def\curfontsize{ssec}%
Chris@10:   \def\lsize{text}\def\lllsize{small}%
Chris@10:   \resetmathfonts \setleading{15pt}}
Chris@10: \let\subsubsecfonts = \subsecfonts
Chris@10: \def\reducedfonts{%
Chris@10:   \let\tenrm=\reducedrm \let\tenit=\reducedit \let\tensl=\reducedsl
Chris@10:   \let\tenbf=\reducedbf \let\tentt=\reducedtt \let\reducedcaps=\reducedsc
Chris@10:   \let\tensf=\reducedsf \let\teni=\reducedi \let\tensy=\reducedsy
Chris@10:   \let\tenttsl=\reducedttsl
Chris@10:   \def\curfontsize{reduced}%
Chris@10:   \def\lsize{small}\def\lllsize{smaller}%
Chris@10:   \resetmathfonts \setleading{10.5pt}}
Chris@10: \def\smallfonts{%
Chris@10:   \let\tenrm=\smallrm \let\tenit=\smallit \let\tensl=\smallsl
Chris@10:   \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc
Chris@10:   \let\tensf=\smallsf \let\teni=\smalli \let\tensy=\smallsy
Chris@10:   \let\tenttsl=\smallttsl
Chris@10:   \def\curfontsize{small}%
Chris@10:   \def\lsize{smaller}\def\lllsize{smaller}%
Chris@10:   \resetmathfonts \setleading{10.5pt}}
Chris@10: \def\smallerfonts{%
Chris@10:   \let\tenrm=\smallerrm \let\tenit=\smallerit \let\tensl=\smallersl
Chris@10:   \let\tenbf=\smallerbf \let\tentt=\smallertt \let\smallcaps=\smallersc
Chris@10:   \let\tensf=\smallersf \let\teni=\smalleri \let\tensy=\smallersy
Chris@10:   \let\tenttsl=\smallerttsl
Chris@10:   \def\curfontsize{smaller}%
Chris@10:   \def\lsize{smaller}\def\lllsize{smaller}%
Chris@10:   \resetmathfonts \setleading{9.5pt}}
Chris@10: 
Chris@10: % Fonts for short table of contents.
Chris@10: \setfont\shortcontrm\rmshape{12}{1000}{OT1}
Chris@10: \setfont\shortcontbf\bfshape{10}{\magstep1}{OT1}  % no cmb12
Chris@10: \setfont\shortcontsl\slshape{12}{1000}{OT1}
Chris@10: \setfont\shortconttt\ttshape{12}{1000}{OT1TT}
Chris@10: 
Chris@10: % Define these just so they can be easily changed for other fonts.
Chris@10: \def\angleleft{$\langle$}
Chris@10: \def\angleright{$\rangle$}
Chris@10: 
Chris@10: % Set the fonts to use with the @small... environments.
Chris@10: \let\smallexamplefonts = \smallfonts
Chris@10: 
Chris@10: % About \smallexamplefonts.  If we use \smallfonts (9pt), @smallexample
Chris@10: % can fit this many characters:
Chris@10: %   8.5x11=86   smallbook=72  a4=90  a5=69
Chris@10: % If we use \scriptfonts (8pt), then we can fit this many characters:
Chris@10: %   8.5x11=90+  smallbook=80  a4=90+  a5=77
Chris@10: % For me, subjectively, the few extra characters that fit aren't worth
Chris@10: % the additional smallness of 8pt.  So I'm making the default 9pt.
Chris@10: %
Chris@10: % By the way, for comparison, here's what fits with @example (10pt):
Chris@10: %   8.5x11=71  smallbook=60  a4=75  a5=58
Chris@10: % --karl, 24jan03.
Chris@10: 
Chris@10: % Set up the default fonts, so we can use them for creating boxes.
Chris@10: %
Chris@10: \definetextfontsizexi
Chris@10: 
Chris@10: 
Chris@10: \message{markup,}
Chris@10: 
Chris@10: % Check if we are currently using a typewriter font.  Since all the
Chris@10: % Computer Modern typewriter fonts have zero interword stretch (and
Chris@10: % shrink), and it is reasonable to expect all typewriter fonts to have
Chris@10: % this property, we can check that font parameter.
Chris@10: %
Chris@10: \def\ifmonospace{\ifdim\fontdimen3\font=0pt }
Chris@10: 
Chris@10: % Markup style infrastructure.  \defmarkupstylesetup\INITMACRO will
Chris@10: % define and register \INITMACRO to be called on markup style changes.
Chris@10: % \INITMACRO can check \currentmarkupstyle for the innermost
Chris@10: % style and the set of \ifmarkupSTYLE switches for all styles
Chris@10: % currently in effect.
Chris@10: \newif\ifmarkupvar
Chris@10: \newif\ifmarkupsamp
Chris@10: \newif\ifmarkupkey
Chris@10: %\newif\ifmarkupfile % @file == @samp.
Chris@10: %\newif\ifmarkupoption % @option == @samp.
Chris@10: \newif\ifmarkupcode
Chris@10: \newif\ifmarkupkbd
Chris@10: %\newif\ifmarkupenv % @env == @code.
Chris@10: %\newif\ifmarkupcommand % @command == @code.
Chris@10: \newif\ifmarkuptex % @tex (and part of @math, for now).
Chris@10: \newif\ifmarkupexample
Chris@10: \newif\ifmarkupverb
Chris@10: \newif\ifmarkupverbatim
Chris@10: 
Chris@10: \let\currentmarkupstyle\empty
Chris@10: 
Chris@10: \def\setupmarkupstyle#1{%
Chris@10:   \csname markup#1true\endcsname
Chris@10:   \def\currentmarkupstyle{#1}%
Chris@10:   \markupstylesetup
Chris@10: }
Chris@10: 
Chris@10: \let\markupstylesetup\empty
Chris@10: 
Chris@10: \def\defmarkupstylesetup#1{%
Chris@10:   \expandafter\def\expandafter\markupstylesetup
Chris@10:     \expandafter{\markupstylesetup #1}%
Chris@10:   \def#1%
Chris@10: }
Chris@10: 
Chris@10: % Markup style setup for left and right quotes.
Chris@10: \defmarkupstylesetup\markupsetuplq{%
Chris@10:   \expandafter\let\expandafter \temp
Chris@10:     \csname markupsetuplq\currentmarkupstyle\endcsname
Chris@10:   \ifx\temp\relax \markupsetuplqdefault \else \temp \fi
Chris@10: }
Chris@10: 
Chris@10: \defmarkupstylesetup\markupsetuprq{%
Chris@10:   \expandafter\let\expandafter \temp
Chris@10:     \csname markupsetuprq\currentmarkupstyle\endcsname
Chris@10:   \ifx\temp\relax \markupsetuprqdefault \else \temp \fi
Chris@10: }
Chris@10: 
Chris@10: {
Chris@10: \catcode`\'=\active
Chris@10: \catcode`\`=\active
Chris@10: 
Chris@10: \gdef\markupsetuplqdefault{\let`\lq}
Chris@10: \gdef\markupsetuprqdefault{\let'\rq}
Chris@10: 
Chris@10: \gdef\markupsetcodequoteleft{\let`\codequoteleft}
Chris@10: \gdef\markupsetcodequoteright{\let'\codequoteright}
Chris@10: 
Chris@10: \gdef\markupsetnoligaturesquoteleft{\let`\noligaturesquoteleft}
Chris@10: }
Chris@10: 
Chris@10: \let\markupsetuplqcode \markupsetcodequoteleft
Chris@10: \let\markupsetuprqcode \markupsetcodequoteright
Chris@10: %
Chris@10: \let\markupsetuplqexample \markupsetcodequoteleft
Chris@10: \let\markupsetuprqexample \markupsetcodequoteright
Chris@10: %
Chris@10: \let\markupsetuplqsamp \markupsetcodequoteleft
Chris@10: \let\markupsetuprqsamp \markupsetcodequoteright
Chris@10: %
Chris@10: \let\markupsetuplqverb \markupsetcodequoteleft
Chris@10: \let\markupsetuprqverb \markupsetcodequoteright
Chris@10: %
Chris@10: \let\markupsetuplqverbatim \markupsetcodequoteleft
Chris@10: \let\markupsetuprqverbatim \markupsetcodequoteright
Chris@10: 
Chris@10: \let\markupsetuplqkbd \markupsetnoligaturesquoteleft
Chris@10: 
Chris@10: % Allow an option to not use regular directed right quote/apostrophe
Chris@10: % (char 0x27), but instead the undirected quote from cmtt (char 0x0d).
Chris@10: % The undirected quote is ugly, so don't make it the default, but it
Chris@10: % works for pasting with more pdf viewers (at least evince), the
Chris@10: % lilypond developers report.  xpdf does work with the regular 0x27.
Chris@10: %
Chris@10: \def\codequoteright{%
Chris@10:   \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax
Chris@10:     \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax
Chris@10:       '%
Chris@10:     \else \char'15 \fi
Chris@10:   \else \char'15 \fi
Chris@10: }
Chris@10: %
Chris@10: % and a similar option for the left quote char vs. a grave accent.
Chris@10: % Modern fonts display ASCII 0x60 as a grave accent, so some people like
Chris@10: % the code environments to do likewise.
Chris@10: %
Chris@10: \def\codequoteleft{%
Chris@10:   \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax
Chris@10:     \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax
Chris@10:       % [Knuth] pp. 380,381,391
Chris@10:       % \relax disables Spanish ligatures ?` and !` of \tt font.
Chris@10:       \relax`%
Chris@10:     \else \char'22 \fi
Chris@10:   \else \char'22 \fi
Chris@10: }
Chris@10: 
Chris@10: % Commands to set the quote options.
Chris@10: % 
Chris@10: \parseargdef\codequoteundirected{%
Chris@10:   \def\temp{#1}%
Chris@10:   \ifx\temp\onword
Chris@10:     \expandafter\let\csname SETtxicodequoteundirected\endcsname
Chris@10:       = t%
Chris@10:   \else\ifx\temp\offword
Chris@10:     \expandafter\let\csname SETtxicodequoteundirected\endcsname
Chris@10:       = \relax
Chris@10:   \else
Chris@10:     \errhelp = \EMsimple
Chris@10:     \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}%
Chris@10:   \fi\fi
Chris@10: }
Chris@10: %
Chris@10: \parseargdef\codequotebacktick{%
Chris@10:   \def\temp{#1}%
Chris@10:   \ifx\temp\onword
Chris@10:     \expandafter\let\csname SETtxicodequotebacktick\endcsname
Chris@10:       = t%
Chris@10:   \else\ifx\temp\offword
Chris@10:     \expandafter\let\csname SETtxicodequotebacktick\endcsname
Chris@10:       = \relax
Chris@10:   \else
Chris@10:     \errhelp = \EMsimple
Chris@10:     \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}%
Chris@10:   \fi\fi
Chris@10: }
Chris@10: 
Chris@10: % [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font.
Chris@10: \def\noligaturesquoteleft{\relax\lq}
Chris@10: 
Chris@10: % Count depth in font-changes, for error checks
Chris@10: \newcount\fontdepth \fontdepth=0
Chris@10: 
Chris@10: % Font commands.
Chris@10: 
Chris@10: % #1 is the font command (\sl or \it), #2 is the text to slant.
Chris@10: % If we are in a monospaced environment, however, 1) always use \ttsl,
Chris@10: % and 2) do not add an italic correction.
Chris@10: \def\dosmartslant#1#2{%
Chris@10:   \ifusingtt 
Chris@10:     {{\ttsl #2}\let\next=\relax}%
Chris@10:     {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}%
Chris@10:   \next
Chris@10: }
Chris@10: \def\smartslanted{\dosmartslant\sl}
Chris@10: \def\smartitalic{\dosmartslant\it}
Chris@10: 
Chris@10: % Output an italic correction unless \next (presumed to be the following
Chris@10: % character) is such as not to need one.
Chris@10: \def\smartitaliccorrection{%
Chris@10:   \ifx\next,%
Chris@10:   \else\ifx\next-%
Chris@10:   \else\ifx\next.%
Chris@10:   \else\ptexslash
Chris@10:   \fi\fi\fi
Chris@10:   \aftersmartic
Chris@10: }
Chris@10: 
Chris@10: % like \smartslanted except unconditionally uses \ttsl, and no ic.
Chris@10: % @var is set to this for defun arguments.
Chris@10: \def\ttslanted#1{{\ttsl #1}}
Chris@10: 
Chris@10: % @cite is like \smartslanted except unconditionally use \sl.  We never want
Chris@10: % ttsl for book titles, do we?
Chris@10: \def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection}
Chris@10: 
Chris@10: \def\aftersmartic{}
Chris@10: \def\var#1{%
Chris@10:   \let\saveaftersmartic = \aftersmartic
Chris@10:   \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}%
Chris@10:   \smartslanted{#1}%
Chris@10: }
Chris@10: 
Chris@10: \let\i=\smartitalic
Chris@10: \let\slanted=\smartslanted
Chris@10: \let\dfn=\smartslanted
Chris@10: \let\emph=\smartitalic
Chris@10: 
Chris@10: % Explicit font changes: @r, @sc, undocumented @ii.
Chris@10: \def\r#1{{\rm #1}}              % roman font
Chris@10: \def\sc#1{{\smallcaps#1}}       % smallcaps font
Chris@10: \def\ii#1{{\it #1}}             % italic font
Chris@10: 
Chris@10: % @b, explicit bold.  Also @strong.
Chris@10: \def\b#1{{\bf #1}}
Chris@10: \let\strong=\b
Chris@10: 
Chris@10: % @sansserif, explicit sans.
Chris@10: \def\sansserif#1{{\sf #1}}
Chris@10: 
Chris@10: % We can't just use \exhyphenpenalty, because that only has effect at
Chris@10: % the end of a paragraph.  Restore normal hyphenation at the end of the
Chris@10: % group within which \nohyphenation is presumably called.
Chris@10: %
Chris@10: \def\nohyphenation{\hyphenchar\font = -1  \aftergroup\restorehyphenation}
Chris@10: \def\restorehyphenation{\hyphenchar\font = `- }
Chris@10: 
Chris@10: % Set sfcode to normal for the chars that usually have another value.
Chris@10: % Can't use plain's \frenchspacing because it uses the `\x notation, and
Chris@10: % sometimes \x has an active definition that messes things up.
Chris@10: %
Chris@10: \catcode`@=11
Chris@10:   \def\plainfrenchspacing{%
Chris@10:     \sfcode\dotChar  =\@m \sfcode\questChar=\@m \sfcode\exclamChar=\@m
Chris@10:     \sfcode\colonChar=\@m \sfcode\semiChar =\@m \sfcode\commaChar =\@m
Chris@10:     \def\endofsentencespacefactor{1000}% for @. and friends
Chris@10:   }
Chris@10:   \def\plainnonfrenchspacing{%
Chris@10:     \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000
Chris@10:     \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250
Chris@10:     \def\endofsentencespacefactor{3000}% for @. and friends
Chris@10:   }
Chris@10: \catcode`@=\other
Chris@10: \def\endofsentencespacefactor{3000}% default
Chris@10: 
Chris@10: % @t, explicit typewriter.
Chris@10: \def\t#1{%
Chris@10:   {\tt \rawbackslash \plainfrenchspacing #1}%
Chris@10:   \null
Chris@10: }
Chris@10: 
Chris@10: % @samp.
Chris@10: \def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}}
Chris@10: 
Chris@10: % definition of @key that produces a lozenge.  Doesn't adjust to text size.
Chris@10: %\setfont\keyrm\rmshape{8}{1000}{OT1}
Chris@10: %\font\keysy=cmsy9
Chris@10: %\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
Chris@10: %  \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
Chris@10: %    \vbox{\hrule\kern-0.4pt
Chris@10: %     \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
Chris@10: %    \kern-0.4pt\hrule}%
Chris@10: %  \kern-.06em\raise0.4pt\hbox{\angleright}}}}
Chris@10: 
Chris@10: % definition of @key with no lozenge.  If the current font is already
Chris@10: % monospace, don't change it; that way, we respect @kbdinputstyle.  But
Chris@10: % if it isn't monospace, then use \tt.
Chris@10: %
Chris@10: \def\key#1{{\setupmarkupstyle{key}%
Chris@10:   \nohyphenation
Chris@10:   \ifmonospace\else\tt\fi
Chris@10:   #1}\null}
Chris@10: 
Chris@10: % ctrl is no longer a Texinfo command.
Chris@10: \def\ctrl #1{{\tt \rawbackslash \hat}#1}
Chris@10: 
Chris@10: % @file, @option are the same as @samp.
Chris@10: \let\file=\samp
Chris@10: \let\option=\samp
Chris@10: 
Chris@10: % @code is a modification of @t,
Chris@10: % which makes spaces the same size as normal in the surrounding text.
Chris@10: \def\tclose#1{%
Chris@10:   {%
Chris@10:     % Change normal interword space to be same as for the current font.
Chris@10:     \spaceskip = \fontdimen2\font
Chris@10:     %
Chris@10:     % Switch to typewriter.
Chris@10:     \tt
Chris@10:     %
Chris@10:     % But `\ ' produces the large typewriter interword space.
Chris@10:     \def\ {{\spaceskip = 0pt{} }}%
Chris@10:     %
Chris@10:     % Turn off hyphenation.
Chris@10:     \nohyphenation
Chris@10:     %
Chris@10:     \rawbackslash
Chris@10:     \plainfrenchspacing
Chris@10:     #1%
Chris@10:   }%
Chris@10:   \null % reset spacefactor to 1000
Chris@10: }
Chris@10: 
Chris@10: % We *must* turn on hyphenation at `-' and `_' in @code.
Chris@10: % Otherwise, it is too hard to avoid overfull hboxes
Chris@10: % in the Emacs manual, the Library manual, etc.
Chris@10: 
Chris@10: % Unfortunately, TeX uses one parameter (\hyphenchar) to control
Chris@10: % both hyphenation at - and hyphenation within words.
Chris@10: % We must therefore turn them both off (\tclose does that)
Chris@10: % and arrange explicitly to hyphenate at a dash.
Chris@10: %  -- rms.
Chris@10: {
Chris@10:   \catcode`\-=\active \catcode`\_=\active
Chris@10:   \catcode`\'=\active \catcode`\`=\active
Chris@10:   \global\let'=\rq \global\let`=\lq  % default definitions
Chris@10:   %
Chris@10:   \global\def\code{\begingroup
Chris@10:     \setupmarkupstyle{code}%
Chris@10:     % The following should really be moved into \setupmarkupstyle handlers.
Chris@10:     \catcode\dashChar=\active  \catcode\underChar=\active
Chris@10:     \ifallowcodebreaks
Chris@10:      \let-\codedash
Chris@10:      \let_\codeunder
Chris@10:     \else
Chris@10:      \let-\realdash
Chris@10:      \let_\realunder
Chris@10:     \fi
Chris@10:     \codex
Chris@10:   }
Chris@10: }
Chris@10: 
Chris@10: \def\codex #1{\tclose{#1}\endgroup}
Chris@10: 
Chris@10: \def\realdash{-}
Chris@10: \def\codedash{-\discretionary{}{}{}}
Chris@10: \def\codeunder{%
Chris@10:   % this is all so @math{@code{var_name}+1} can work.  In math mode, _
Chris@10:   % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.)
Chris@10:   % will therefore expand the active definition of _, which is us
Chris@10:   % (inside @code that is), therefore an endless loop.
Chris@10:   \ifusingtt{\ifmmode
Chris@10:                \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_.
Chris@10:              \else\normalunderscore \fi
Chris@10:              \discretionary{}{}{}}%
Chris@10:             {\_}%
Chris@10: }
Chris@10: 
Chris@10: % An additional complication: the above will allow breaks after, e.g.,
Chris@10: % each of the four underscores in __typeof__.  This is undesirable in
Chris@10: % some manuals, especially if they don't have long identifiers in
Chris@10: % general.  @allowcodebreaks provides a way to control this.
Chris@10: %
Chris@10: \newif\ifallowcodebreaks  \allowcodebreakstrue
Chris@10: 
Chris@10: \def\keywordtrue{true}
Chris@10: \def\keywordfalse{false}
Chris@10: 
Chris@10: \parseargdef\allowcodebreaks{%
Chris@10:   \def\txiarg{#1}%
Chris@10:   \ifx\txiarg\keywordtrue
Chris@10:     \allowcodebreakstrue
Chris@10:   \else\ifx\txiarg\keywordfalse
Chris@10:     \allowcodebreaksfalse
Chris@10:   \else
Chris@10:     \errhelp = \EMsimple
Chris@10:     \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}%
Chris@10:   \fi\fi
Chris@10: }
Chris@10: 
Chris@10: % @uref (abbreviation for `urlref') takes an optional (comma-separated)
Chris@10: % second argument specifying the text to display and an optional third
Chris@10: % arg as text to display instead of (rather than in addition to) the url
Chris@10: % itself.  First (mandatory) arg is the url.
Chris@10: % (This \urefnobreak definition isn't used now, leaving it for a while
Chris@10: % for comparison.)
Chris@10: \def\urefnobreak#1{\dourefnobreak #1,,,\finish}
Chris@10: \def\dourefnobreak#1,#2,#3,#4\finish{\begingroup
Chris@10:   \unsepspaces
Chris@10:   \pdfurl{#1}%
Chris@10:   \setbox0 = \hbox{\ignorespaces #3}%
Chris@10:   \ifdim\wd0 > 0pt
Chris@10:     \unhbox0 % third arg given, show only that
Chris@10:   \else
Chris@10:     \setbox0 = \hbox{\ignorespaces #2}%
Chris@10:     \ifdim\wd0 > 0pt
Chris@10:       \ifpdf
Chris@10:         \unhbox0             % PDF: 2nd arg given, show only it
Chris@10:       \else
Chris@10:         \unhbox0\ (\code{#1})% DVI: 2nd arg given, show both it and url
Chris@10:       \fi
Chris@10:     \else
Chris@10:       \code{#1}% only url given, so show it
Chris@10:     \fi
Chris@10:   \fi
Chris@10:   \endlink
Chris@10: \endgroup}
Chris@10: 
Chris@10: % This \urefbreak definition is the active one.
Chris@10: \def\urefbreak{\begingroup \urefcatcodes \dourefbreak}
Chris@10: \let\uref=\urefbreak
Chris@10: \def\dourefbreak#1{\urefbreakfinish #1,,,\finish}
Chris@10: \def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example
Chris@10:   \unsepspaces
Chris@10:   \pdfurl{#1}%
Chris@10:   \setbox0 = \hbox{\ignorespaces #3}%
Chris@10:   \ifdim\wd0 > 0pt
Chris@10:     \unhbox0 % third arg given, show only that
Chris@10:   \else
Chris@10:     \setbox0 = \hbox{\ignorespaces #2}%
Chris@10:     \ifdim\wd0 > 0pt
Chris@10:       \ifpdf
Chris@10:         \unhbox0             % PDF: 2nd arg given, show only it
Chris@10:       \else
Chris@10:         \unhbox0\ (\urefcode{#1})% DVI: 2nd arg given, show both it and url
Chris@10:       \fi
Chris@10:     \else
Chris@10:       \urefcode{#1}% only url given, so show it
Chris@10:     \fi
Chris@10:   \fi
Chris@10:   \endlink
Chris@10: \endgroup}
Chris@10: 
Chris@10: % Allow line breaks around only a few characters (only).
Chris@10: \def\urefcatcodes{%
Chris@10:   \catcode\ampChar=\active   \catcode\dotChar=\active
Chris@10:   \catcode\hashChar=\active  \catcode\questChar=\active
Chris@10:   \catcode\slashChar=\active
Chris@10: }
Chris@10: {
Chris@10:   \urefcatcodes
Chris@10:   %
Chris@10:   \global\def\urefcode{\begingroup
Chris@10:     \setupmarkupstyle{code}%
Chris@10:     \urefcatcodes
Chris@10:     \let&\urefcodeamp
Chris@10:     \let.\urefcodedot
Chris@10:     \let#\urefcodehash
Chris@10:     \let?\urefcodequest
Chris@10:     \let/\urefcodeslash
Chris@10:     \codex
Chris@10:   }
Chris@10:   %
Chris@10:   % By default, they are just regular characters.
Chris@10:   \global\def&{\normalamp}
Chris@10:   \global\def.{\normaldot}
Chris@10:   \global\def#{\normalhash}
Chris@10:   \global\def?{\normalquest}
Chris@10:   \global\def/{\normalslash}
Chris@10: }
Chris@10: 
Chris@10: % we put a little stretch before and after the breakable chars, to help
Chris@10: % line breaking of long url's.  The unequal skips make look better in
Chris@10: % cmtt at least, especially for dots.
Chris@10: \def\urefprestretch{\urefprebreak \hskip0pt plus.13em }
Chris@10: \def\urefpoststretch{\urefpostbreak \hskip0pt plus.1em }
Chris@10: %
Chris@10: \def\urefcodeamp{\urefprestretch \&\urefpoststretch}
Chris@10: \def\urefcodedot{\urefprestretch .\urefpoststretch}
Chris@10: \def\urefcodehash{\urefprestretch \#\urefpoststretch}
Chris@10: \def\urefcodequest{\urefprestretch ?\urefpoststretch}
Chris@10: \def\urefcodeslash{\futurelet\next\urefcodeslashfinish}
Chris@10: {
Chris@10:   \catcode`\/=\active
Chris@10:   \global\def\urefcodeslashfinish{%
Chris@10:     \urefprestretch \slashChar
Chris@10:     % Allow line break only after the final / in a sequence of
Chris@10:     % slashes, to avoid line break between the slashes in http://.
Chris@10:     \ifx\next/\else \urefpoststretch \fi
Chris@10:   }
Chris@10: }
Chris@10: 
Chris@10: % One more complication: by default we'll break after the special
Chris@10: % characters, but some people like to break before the special chars, so
Chris@10: % allow that.  Also allow no breaking at all, for manual control.
Chris@10: % 
Chris@10: \parseargdef\urefbreakstyle{%
Chris@10:   \def\txiarg{#1}%
Chris@10:   \ifx\txiarg\wordnone
Chris@10:     \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak}
Chris@10:   \else\ifx\txiarg\wordbefore
Chris@10:     \def\urefprebreak{\allowbreak}\def\urefpostbreak{\nobreak}
Chris@10:   \else\ifx\txiarg\wordafter
Chris@10:     \def\urefprebreak{\nobreak}\def\urefpostbreak{\allowbreak}
Chris@10:   \else
Chris@10:     \errhelp = \EMsimple
Chris@10:     \errmessage{Unknown @urefbreakstyle setting `\txiarg'}%
Chris@10:   \fi\fi\fi
Chris@10: }
Chris@10: \def\wordafter{after}
Chris@10: \def\wordbefore{before}
Chris@10: \def\wordnone{none}
Chris@10: 
Chris@10: \urefbreakstyle after
Chris@10: 
Chris@10: % @url synonym for @uref, since that's how everyone uses it.
Chris@10: %
Chris@10: \let\url=\uref
Chris@10: 
Chris@10: % rms does not like angle brackets --karl, 17may97.
Chris@10: % So now @email is just like @uref, unless we are pdf.
Chris@10: %
Chris@10: %\def\email#1{\angleleft{\tt #1}\angleright}
Chris@10: \ifpdf
Chris@10:   \def\email#1{\doemail#1,,\finish}
Chris@10:   \def\doemail#1,#2,#3\finish{\begingroup
Chris@10:     \unsepspaces
Chris@10:     \pdfurl{mailto:#1}%
Chris@10:     \setbox0 = \hbox{\ignorespaces #2}%
Chris@10:     \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
Chris@10:     \endlink
Chris@10:   \endgroup}
Chris@10: \else
Chris@10:   \let\email=\uref
Chris@10: \fi
Chris@10: 
Chris@10: % @kbd is like @code, except that if the argument is just one @key command,
Chris@10: % then @kbd has no effect.
Chris@10: \def\kbd#1{{\setupmarkupstyle{kbd}\def\look{#1}\expandafter\kbdfoo\look??\par}}
Chris@10: 
Chris@10: % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
Chris@10: %   `example' (@kbd uses ttsl only inside of @example and friends),
Chris@10: %   or `code' (@kbd uses normal tty font always).
Chris@10: \parseargdef\kbdinputstyle{%
Chris@10:   \def\txiarg{#1}%
Chris@10:   \ifx\txiarg\worddistinct
Chris@10:     \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
Chris@10:   \else\ifx\txiarg\wordexample
Chris@10:     \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
Chris@10:   \else\ifx\txiarg\wordcode
Chris@10:     \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
Chris@10:   \else
Chris@10:     \errhelp = \EMsimple
Chris@10:     \errmessage{Unknown @kbdinputstyle setting `\txiarg'}%
Chris@10:   \fi\fi\fi
Chris@10: }
Chris@10: \def\worddistinct{distinct}
Chris@10: \def\wordexample{example}
Chris@10: \def\wordcode{code}
Chris@10: 
Chris@10: % Default is `distinct'.
Chris@10: \kbdinputstyle distinct
Chris@10: 
Chris@10: \def\xkey{\key}
Chris@10: \def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}%
Chris@10: \ifx\one\xkey\ifx\threex\three \key{#2}%
Chris@10: \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
Chris@10: \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi}
Chris@10: 
Chris@10: % For @indicateurl, @env, @command quotes seem unnecessary, so use \code.
Chris@10: \let\indicateurl=\code
Chris@10: \let\env=\code
Chris@10: \let\command=\code
Chris@10: 
Chris@10: % @clicksequence{File @click{} Open ...}
Chris@10: \def\clicksequence#1{\begingroup #1\endgroup}
Chris@10: 
Chris@10: % @clickstyle @arrow   (by default)
Chris@10: \parseargdef\clickstyle{\def\click{#1}}
Chris@10: \def\click{\arrow}
Chris@10: 
Chris@10: % Typeset a dimension, e.g., `in' or `pt'.  The only reason for the
Chris@10: % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
Chris@10: %
Chris@10: \def\dmn#1{\thinspace #1}
Chris@10: 
Chris@10: % @l was never documented to mean ``switch to the Lisp font'',
Chris@10: % and it is not used as such in any manual I can find.  We need it for
Chris@10: % Polish suppressed-l.  --karl, 22sep96.
Chris@10: %\def\l#1{{\li #1}\null}
Chris@10: 
Chris@10: % @acronym for "FBI", "NATO", and the like.
Chris@10: % We print this one point size smaller, since it's intended for
Chris@10: % all-uppercase.
Chris@10: %
Chris@10: \def\acronym#1{\doacronym #1,,\finish}
Chris@10: \def\doacronym#1,#2,#3\finish{%
Chris@10:   {\selectfonts\lsize #1}%
Chris@10:   \def\temp{#2}%
Chris@10:   \ifx\temp\empty \else
Chris@10:     \space ({\unsepspaces \ignorespaces \temp \unskip})%
Chris@10:   \fi
Chris@10:   \null % reset \spacefactor=1000
Chris@10: }
Chris@10: 
Chris@10: % @abbr for "Comput. J." and the like.
Chris@10: % No font change, but don't do end-of-sentence spacing.
Chris@10: %
Chris@10: \def\abbr#1{\doabbr #1,,\finish}
Chris@10: \def\doabbr#1,#2,#3\finish{%
Chris@10:   {\plainfrenchspacing #1}%
Chris@10:   \def\temp{#2}%
Chris@10:   \ifx\temp\empty \else
Chris@10:     \space ({\unsepspaces \ignorespaces \temp \unskip})%
Chris@10:   \fi
Chris@10:   \null % reset \spacefactor=1000
Chris@10: }
Chris@10: 
Chris@10: % @asis just yields its argument.  Used with @table, for example.
Chris@10: %
Chris@10: \def\asis#1{#1}
Chris@10: 
Chris@10: % @math outputs its argument in math mode.
Chris@10: %
Chris@10: % One complication: _ usually means subscripts, but it could also mean
Chris@10: % an actual _ character, as in @math{@var{some_variable} + 1}.  So make
Chris@10: % _ active, and distinguish by seeing if the current family is \slfam,
Chris@10: % which is what @var uses.
Chris@10: {
Chris@10:   \catcode`\_ = \active
Chris@10:   \gdef\mathunderscore{%
Chris@10:     \catcode`\_=\active
Chris@10:     \def_{\ifnum\fam=\slfam \_\else\sb\fi}%
Chris@10:   }
Chris@10: }
Chris@10: % Another complication: we want \\ (and @\) to output a math (or tt) \.
Chris@10: % FYI, plain.tex uses \\ as a temporary control sequence (for no
Chris@10: % particular reason), but this is not advertised and we don't care.
Chris@10: %
Chris@10: % The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\.
Chris@10: \def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi}
Chris@10: %
Chris@10: \def\math{%
Chris@10:   \tex
Chris@10:   \mathunderscore
Chris@10:   \let\\ = \mathbackslash
Chris@10:   \mathactive
Chris@10:   % make the texinfo accent commands work in math mode
Chris@10:   \let\"=\ddot
Chris@10:   \let\'=\acute
Chris@10:   \let\==\bar
Chris@10:   \let\^=\hat
Chris@10:   \let\`=\grave
Chris@10:   \let\u=\breve
Chris@10:   \let\v=\check
Chris@10:   \let\~=\tilde
Chris@10:   \let\dotaccent=\dot
Chris@10:   $\finishmath
Chris@10: }
Chris@10: \def\finishmath#1{#1$\endgroup}  % Close the group opened by \tex.
Chris@10: 
Chris@10: % Some active characters (such as <) are spaced differently in math.
Chris@10: % We have to reset their definitions in case the @math was an argument
Chris@10: % to a command which sets the catcodes (such as @item or @section).
Chris@10: %
Chris@10: {
Chris@10:   \catcode`^ = \active
Chris@10:   \catcode`< = \active
Chris@10:   \catcode`> = \active
Chris@10:   \catcode`+ = \active
Chris@10:   \catcode`' = \active
Chris@10:   \gdef\mathactive{%
Chris@10:     \let^ = \ptexhat
Chris@10:     \let< = \ptexless
Chris@10:     \let> = \ptexgtr
Chris@10:     \let+ = \ptexplus
Chris@10:     \let' = \ptexquoteright
Chris@10:   }
Chris@10: }
Chris@10: 
Chris@10: % @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}.
Chris@10: % Ignore unless FMTNAME == tex; then it is like @iftex and @tex,
Chris@10: % except specified as a normal braced arg, so no newlines to worry about.
Chris@10: % 
Chris@10: \def\outfmtnametex{tex}
Chris@10: %
Chris@10: \long\def\inlinefmt#1{\doinlinefmt #1,\finish}
Chris@10: \long\def\doinlinefmt#1,#2,\finish{%
Chris@10:   \def\inlinefmtname{#1}%
Chris@10:   \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi
Chris@10: }
Chris@10: % For raw, must switch into @tex before parsing the argument, to avoid
Chris@10: % setting catcodes prematurely.  Doing it this way means that, for
Chris@10: % example, @inlineraw{html, foo{bar} gets a parse error instead of being
Chris@10: % ignored.  But this isn't important because if people want a literal
Chris@10: % *right* brace they would have to use a command anyway, so they may as
Chris@10: % well use a command to get a left brace too.  We could re-use the
Chris@10: % delimiter character idea from \verb, but it seems like overkill.
Chris@10: % 
Chris@10: \long\def\inlineraw{\tex \doinlineraw}
Chris@10: \long\def\doinlineraw#1{\doinlinerawtwo #1,\finish}
Chris@10: \def\doinlinerawtwo#1,#2,\finish{%
Chris@10:   \def\inlinerawname{#1}%
Chris@10:   \ifx\inlinerawname\outfmtnametex \ignorespaces #2\fi
Chris@10:   \endgroup % close group opened by \tex.
Chris@10: }
Chris@10: 
Chris@10: 
Chris@10: \message{glyphs,}
Chris@10: % and logos.
Chris@10: 
Chris@10: % @@ prints an @, as does @atchar{}.
Chris@10: \def\@{\char64 }
Chris@10: \let\atchar=\@
Chris@10: 
Chris@10: % @{ @} @lbracechar{} @rbracechar{} all generate brace characters.
Chris@10: % Unless we're in typewriter, use \ecfont because the CM text fonts do
Chris@10: % not have braces, and we don't want to switch into math.
Chris@10: \def\mylbrace{{\ifmonospace\else\ecfont\fi \char123}}
Chris@10: \def\myrbrace{{\ifmonospace\else\ecfont\fi \char125}}
Chris@10: \let\{=\mylbrace \let\lbracechar=\{
Chris@10: \let\}=\myrbrace \let\rbracechar=\}
Chris@10: \begingroup
Chris@10:   % Definitions to produce \{ and \} commands for indices,
Chris@10:   % and @{ and @} for the aux/toc files.
Chris@10:   \catcode`\{ = \other \catcode`\} = \other
Chris@10:   \catcode`\[ = 1 \catcode`\] = 2
Chris@10:   \catcode`\! = 0 \catcode`\\ = \other
Chris@10:   !gdef!lbracecmd[\{]%
Chris@10:   !gdef!rbracecmd[\}]%
Chris@10:   !gdef!lbraceatcmd[@{]%
Chris@10:   !gdef!rbraceatcmd[@}]%
Chris@10: !endgroup
Chris@10: 
Chris@10: % @comma{} to avoid , parsing problems.
Chris@10: \let\comma = ,
Chris@10: 
Chris@10: % Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
Chris@10: % Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H.
Chris@10: \let\, = \ptexc
Chris@10: \let\dotaccent = \ptexdot
Chris@10: \def\ringaccent#1{{\accent23 #1}}
Chris@10: \let\tieaccent = \ptext
Chris@10: \let\ubaraccent = \ptexb
Chris@10: \let\udotaccent = \d
Chris@10: 
Chris@10: % Other special characters: @questiondown @exclamdown @ordf @ordm
Chris@10: % Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss.
Chris@10: \def\questiondown{?`}
Chris@10: \def\exclamdown{!`}
Chris@10: \def\ordf{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{a}}}
Chris@10: \def\ordm{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{o}}}
Chris@10: 
Chris@10: % Dotless i and dotless j, used for accents.
Chris@10: \def\imacro{i}
Chris@10: \def\jmacro{j}
Chris@10: \def\dotless#1{%
Chris@10:   \def\temp{#1}%
Chris@10:   \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi
Chris@10:   \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi
Chris@10:   \else \errmessage{@dotless can be used only with i or j}%
Chris@10:   \fi\fi
Chris@10: }
Chris@10: 
Chris@10: % The \TeX{} logo, as in plain, but resetting the spacing so that a
Chris@10: % period following counts as ending a sentence.  (Idea found in latex.)
Chris@10: %
Chris@10: \edef\TeX{\TeX \spacefactor=1000 }
Chris@10: 
Chris@10: % @LaTeX{} logo.  Not quite the same results as the definition in
Chris@10: % latex.ltx, since we use a different font for the raised A; it's most
Chris@10: % convenient for us to use an explicitly smaller font, rather than using
Chris@10: % the \scriptstyle font (since we don't reset \scriptstyle and
Chris@10: % \scriptscriptstyle).
Chris@10: %
Chris@10: \def\LaTeX{%
Chris@10:   L\kern-.36em
Chris@10:   {\setbox0=\hbox{T}%
Chris@10:    \vbox to \ht0{\hbox{%
Chris@10:      \ifx\textnominalsize\xwordpt
Chris@10:        % for 10pt running text, \lllsize (8pt) is too small for the A in LaTeX.
Chris@10:        % Revert to plain's \scriptsize, which is 7pt.
Chris@10:        \count255=\the\fam $\fam\count255 \scriptstyle A$%
Chris@10:      \else
Chris@10:        % For 11pt, we can use our lllsize.
Chris@10:        \selectfonts\lllsize A%
Chris@10:      \fi
Chris@10:      }%
Chris@10:      \vss
Chris@10:   }}%
Chris@10:   \kern-.15em
Chris@10:   \TeX
Chris@10: }
Chris@10: 
Chris@10: % Some math mode symbols.
Chris@10: \def\bullet{$\ptexbullet$}
Chris@10: \def\geq{\ifmmode \ge\else $\ge$\fi}
Chris@10: \def\leq{\ifmmode \le\else $\le$\fi}
Chris@10: \def\minus{\ifmmode -\else $-$\fi}
Chris@10: 
Chris@10: % @dots{} outputs an ellipsis using the current font.
Chris@10: % We do .5em per period so that it has the same spacing in the cm
Chris@10: % typewriter fonts as three actual period characters; on the other hand,
Chris@10: % in other typewriter fonts three periods are wider than 1.5em.  So do
Chris@10: % whichever is larger.
Chris@10: %
Chris@10: \def\dots{%
Chris@10:   \leavevmode
Chris@10:   \setbox0=\hbox{...}% get width of three periods
Chris@10:   \ifdim\wd0 > 1.5em
Chris@10:     \dimen0 = \wd0
Chris@10:   \else
Chris@10:     \dimen0 = 1.5em
Chris@10:   \fi
Chris@10:   \hbox to \dimen0{%
Chris@10:     \hskip 0pt plus.25fil
Chris@10:     .\hskip 0pt plus1fil
Chris@10:     .\hskip 0pt plus1fil
Chris@10:     .\hskip 0pt plus.5fil
Chris@10:   }%
Chris@10: }
Chris@10: 
Chris@10: % @enddots{} is an end-of-sentence ellipsis.
Chris@10: %
Chris@10: \def\enddots{%
Chris@10:   \dots
Chris@10:   \spacefactor=\endofsentencespacefactor
Chris@10: }
Chris@10: 
Chris@10: % @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
Chris@10: %
Chris@10: % Since these characters are used in examples, they should be an even number of
Chris@10: % \tt widths. Each \tt character is 1en, so two makes it 1em.
Chris@10: %
Chris@10: \def\point{$\star$}
Chris@10: \def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}}
Chris@10: \def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
Chris@10: \def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}}
Chris@10: \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
Chris@10: \def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}}
Chris@10: 
Chris@10: % The @error{} command.
Chris@10: % Adapted from the TeXbook's \boxit.
Chris@10: %
Chris@10: \newbox\errorbox
Chris@10: %
Chris@10: {\tentt \global\dimen0 = 3em}% Width of the box.
Chris@10: \dimen2 = .55pt % Thickness of rules
Chris@10: % The text. (`r' is open on the right, `e' somewhat less so on the left.)
Chris@10: \setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt}
Chris@10: %
Chris@10: \setbox\errorbox=\hbox to \dimen0{\hfil
Chris@10:    \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
Chris@10:    \advance\hsize by -2\dimen2 % Rules.
Chris@10:    \vbox{%
Chris@10:       \hrule height\dimen2
Chris@10:       \hbox{\vrule width\dimen2 \kern3pt          % Space to left of text.
Chris@10:          \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
Chris@10:          \kern3pt\vrule width\dimen2}% Space to right.
Chris@10:       \hrule height\dimen2}
Chris@10:     \hfil}
Chris@10: %
Chris@10: \def\error{\leavevmode\lower.7ex\copy\errorbox}
Chris@10: 
Chris@10: % @pounds{} is a sterling sign, which Knuth put in the CM italic font.
Chris@10: %
Chris@10: \def\pounds{{\it\$}}
Chris@10: 
Chris@10: % @euro{} comes from a separate font, depending on the current style.
Chris@10: % We use the free feym* fonts from the eurosym package by Henrik
Chris@10: % Theiling, which support regular, slanted, bold and bold slanted (and
Chris@10: % "outlined" (blackboard board, sort of) versions, which we don't need).
Chris@10: % It is available from http://www.ctan.org/tex-archive/fonts/eurosym.
Chris@10: %
Chris@10: % Although only regular is the truly official Euro symbol, we ignore
Chris@10: % that.  The Euro is designed to be slightly taller than the regular
Chris@10: % font height.
Chris@10: %
Chris@10: % feymr - regular
Chris@10: % feymo - slanted
Chris@10: % feybr - bold
Chris@10: % feybo - bold slanted
Chris@10: %
Chris@10: % There is no good (free) typewriter version, to my knowledge.
Chris@10: % A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide.
Chris@10: % Hmm.
Chris@10: %
Chris@10: % Also doesn't work in math.  Do we need to do math with euro symbols?
Chris@10: % Hope not.
Chris@10: %
Chris@10: %
Chris@10: \def\euro{{\eurofont e}}
Chris@10: \def\eurofont{%
Chris@10:   % We set the font at each command, rather than predefining it in
Chris@10:   % \textfonts and the other font-switching commands, so that
Chris@10:   % installations which never need the symbol don't have to have the
Chris@10:   % font installed.
Chris@10:   %
Chris@10:   % There is only one designed size (nominal 10pt), so we always scale
Chris@10:   % that to the current nominal size.
Chris@10:   %
Chris@10:   % By the way, simply using "at 1em" works for cmr10 and the like, but
Chris@10:   % does not work for cmbx10 and other extended/shrunken fonts.
Chris@10:   %
Chris@10:   \def\eurosize{\csname\curfontsize nominalsize\endcsname}%
Chris@10:   %
Chris@10:   \ifx\curfontstyle\bfstylename
Chris@10:     % bold:
Chris@10:     \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize
Chris@10:   \else
Chris@10:     % regular:
Chris@10:     \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize
Chris@10:   \fi
Chris@10:   \thiseurofont
Chris@10: }
Chris@10: 
Chris@10: % Glyphs from the EC fonts.  We don't use \let for the aliases, because
Chris@10: % sometimes we redefine the original macro, and the alias should reflect
Chris@10: % the redefinition.
Chris@10: %
Chris@10: % Use LaTeX names for the Icelandic letters.
Chris@10: \def\DH{{\ecfont \char"D0}} % Eth
Chris@10: \def\dh{{\ecfont \char"F0}} % eth
Chris@10: \def\TH{{\ecfont \char"DE}} % Thorn
Chris@10: \def\th{{\ecfont \char"FE}} % thorn
Chris@10: %
Chris@10: \def\guillemetleft{{\ecfont \char"13}}
Chris@10: \def\guillemotleft{\guillemetleft}
Chris@10: \def\guillemetright{{\ecfont \char"14}}
Chris@10: \def\guillemotright{\guillemetright}
Chris@10: \def\guilsinglleft{{\ecfont \char"0E}}
Chris@10: \def\guilsinglright{{\ecfont \char"0F}}
Chris@10: \def\quotedblbase{{\ecfont \char"12}}
Chris@10: \def\quotesinglbase{{\ecfont \char"0D}}
Chris@10: %
Chris@10: % This positioning is not perfect (see the ogonek LaTeX package), but
Chris@10: % we have the precomposed glyphs for the most common cases.  We put the
Chris@10: % tests to use those glyphs in the single \ogonek macro so we have fewer
Chris@10: % dummy definitions to worry about for index entries, etc.
Chris@10: %
Chris@10: % ogonek is also used with other letters in Lithuanian (IOU), but using
Chris@10: % the precomposed glyphs for those is not so easy since they aren't in
Chris@10: % the same EC font.
Chris@10: \def\ogonek#1{{%
Chris@10:   \def\temp{#1}%
Chris@10:   \ifx\temp\macrocharA\Aogonek
Chris@10:   \else\ifx\temp\macrochara\aogonek
Chris@10:   \else\ifx\temp\macrocharE\Eogonek
Chris@10:   \else\ifx\temp\macrochare\eogonek
Chris@10:   \else
Chris@10:     \ecfont \setbox0=\hbox{#1}%
Chris@10:     \ifdim\ht0=1ex\accent"0C #1%
Chris@10:     \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}%
Chris@10:     \fi
Chris@10:   \fi\fi\fi\fi
Chris@10:   }%
Chris@10: }
Chris@10: \def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A}
Chris@10: \def\aogonek{{\ecfont \char"A1}}\def\macrochara{a}
Chris@10: \def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E}
Chris@10: \def\eogonek{{\ecfont \char"A6}}\def\macrochare{e}
Chris@10: %
Chris@10: % Use the ec* fonts (cm-super in outline format) for non-CM glyphs.
Chris@10: \def\ecfont{%
Chris@10:   % We can't distinguish serif/sans and italic/slanted, but this
Chris@10:   % is used for crude hacks anyway (like adding French and German
Chris@10:   % quotes to documents typeset with CM, where we lose kerning), so
Chris@10:   % hopefully nobody will notice/care.
Chris@10:   \edef\ecsize{\csname\curfontsize ecsize\endcsname}%
Chris@10:   \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}%
Chris@10:   \ifx\curfontstyle\bfstylename
Chris@10:     % bold:
Chris@10:     \font\thisecfont = ecb\ifusingit{i}{x}\ecsize \space at \nominalsize
Chris@10:   \else
Chris@10:     % regular:
Chris@10:     \font\thisecfont = ec\ifusingit{ti}{rm}\ecsize \space at \nominalsize
Chris@10:   \fi
Chris@10:   \thisecfont
Chris@10: }
Chris@10: 
Chris@10: % @registeredsymbol - R in a circle.  The font for the R should really
Chris@10: % be smaller yet, but lllsize is the best we can do for now.
Chris@10: % Adapted from the plain.tex definition of \copyright.
Chris@10: %
Chris@10: \def\registeredsymbol{%
Chris@10:   $^{{\ooalign{\hfil\raise.07ex\hbox{\selectfonts\lllsize R}%
Chris@10:                \hfil\crcr\Orb}}%
Chris@10:     }$%
Chris@10: }
Chris@10: 
Chris@10: % @textdegree - the normal degrees sign.
Chris@10: %
Chris@10: \def\textdegree{$^\circ$}
Chris@10: 
Chris@10: % Laurent Siebenmann reports \Orb undefined with:
Chris@10: %  Textures 1.7.7 (preloaded format=plain 93.10.14)  (68K)  16 APR 2004 02:38
Chris@10: % so we'll define it if necessary.
Chris@10: %
Chris@10: \ifx\Orb\thisisundefined
Chris@10: \def\Orb{\mathhexbox20D}
Chris@10: \fi
Chris@10: 
Chris@10: % Quotes.
Chris@10: \chardef\quotedblleft="5C
Chris@10: \chardef\quotedblright=`\"
Chris@10: \chardef\quoteleft=`\`
Chris@10: \chardef\quoteright=`\'
Chris@10: 
Chris@10: 
Chris@10: \message{page headings,}
Chris@10: 
Chris@10: \newskip\titlepagetopglue \titlepagetopglue = 1.5in
Chris@10: \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
Chris@10: 
Chris@10: % First the title page.  Must do @settitle before @titlepage.
Chris@10: \newif\ifseenauthor
Chris@10: \newif\iffinishedtitlepage
Chris@10: 
Chris@10: % Do an implicit @contents or @shortcontents after @end titlepage if the
Chris@10: % user says @setcontentsaftertitlepage or @setshortcontentsaftertitlepage.
Chris@10: %
Chris@10: \newif\ifsetcontentsaftertitlepage
Chris@10:  \let\setcontentsaftertitlepage = \setcontentsaftertitlepagetrue
Chris@10: \newif\ifsetshortcontentsaftertitlepage
Chris@10:  \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue
Chris@10: 
Chris@10: \parseargdef\shorttitlepage{%
Chris@10:   \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}%
Chris@10:   \endgroup\page\hbox{}\page}
Chris@10: 
Chris@10: \envdef\titlepage{%
Chris@10:   % Open one extra group, as we want to close it in the middle of \Etitlepage.
Chris@10:   \begingroup
Chris@10:     \parindent=0pt \textfonts
Chris@10:     % Leave some space at the very top of the page.
Chris@10:     \vglue\titlepagetopglue
Chris@10:     % No rule at page bottom unless we print one at the top with @title.
Chris@10:     \finishedtitlepagetrue
Chris@10:     %
Chris@10:     % Most title ``pages'' are actually two pages long, with space
Chris@10:     % at the top of the second.  We don't want the ragged left on the second.
Chris@10:     \let\oldpage = \page
Chris@10:     \def\page{%
Chris@10:       \iffinishedtitlepage\else
Chris@10: 	 \finishtitlepage
Chris@10:       \fi
Chris@10:       \let\page = \oldpage
Chris@10:       \page
Chris@10:       \null
Chris@10:     }%
Chris@10: }
Chris@10: 
Chris@10: \def\Etitlepage{%
Chris@10:     \iffinishedtitlepage\else
Chris@10: 	\finishtitlepage
Chris@10:     \fi
Chris@10:     % It is important to do the page break before ending the group,
Chris@10:     % because the headline and footline are only empty inside the group.
Chris@10:     % If we use the new definition of \page, we always get a blank page
Chris@10:     % after the title page, which we certainly don't want.
Chris@10:     \oldpage
Chris@10:   \endgroup
Chris@10:   %
Chris@10:   % Need this before the \...aftertitlepage checks so that if they are
Chris@10:   % in effect the toc pages will come out with page numbers.
Chris@10:   \HEADINGSon
Chris@10:   %
Chris@10:   % If they want short, they certainly want long too.
Chris@10:   \ifsetshortcontentsaftertitlepage
Chris@10:     \shortcontents
Chris@10:     \contents
Chris@10:     \global\let\shortcontents = \relax
Chris@10:     \global\let\contents = \relax
Chris@10:   \fi
Chris@10:   %
Chris@10:   \ifsetcontentsaftertitlepage
Chris@10:     \contents
Chris@10:     \global\let\contents = \relax
Chris@10:     \global\let\shortcontents = \relax
Chris@10:   \fi
Chris@10: }
Chris@10: 
Chris@10: \def\finishtitlepage{%
Chris@10:   \vskip4pt \hrule height 2pt width \hsize
Chris@10:   \vskip\titlepagebottomglue
Chris@10:   \finishedtitlepagetrue
Chris@10: }
Chris@10: 
Chris@10: % Macros to be used within @titlepage:
Chris@10: 
Chris@10: \let\subtitlerm=\tenrm
Chris@10: \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}
Chris@10: 
Chris@10: \parseargdef\title{%
Chris@10:   \checkenv\titlepage
Chris@10:   \leftline{\titlefonts\rmisbold #1}
Chris@10:   % print a rule at the page bottom also.
Chris@10:   \finishedtitlepagefalse
Chris@10:   \vskip4pt \hrule height 4pt width \hsize \vskip4pt
Chris@10: }
Chris@10: 
Chris@10: \parseargdef\subtitle{%
Chris@10:   \checkenv\titlepage
Chris@10:   {\subtitlefont \rightline{#1}}%
Chris@10: }
Chris@10: 
Chris@10: % @author should come last, but may come many times.
Chris@10: % It can also be used inside @quotation.
Chris@10: %
Chris@10: \parseargdef\author{%
Chris@10:   \def\temp{\quotation}%
Chris@10:   \ifx\thisenv\temp
Chris@10:     \def\quotationauthor{#1}% printed in \Equotation.
Chris@10:   \else
Chris@10:     \checkenv\titlepage
Chris@10:     \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi
Chris@10:     {\secfonts\rmisbold \leftline{#1}}%
Chris@10:   \fi
Chris@10: }
Chris@10: 
Chris@10: 
Chris@10: % Set up page headings and footings.
Chris@10: 
Chris@10: \let\thispage=\folio
Chris@10: 
Chris@10: \newtoks\evenheadline    % headline on even pages
Chris@10: \newtoks\oddheadline     % headline on odd pages
Chris@10: \newtoks\evenfootline    % footline on even pages
Chris@10: \newtoks\oddfootline     % footline on odd pages
Chris@10: 
Chris@10: % Now make TeX use those variables
Chris@10: \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
Chris@10:                             \else \the\evenheadline \fi}}
Chris@10: \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
Chris@10:                             \else \the\evenfootline \fi}\HEADINGShook}
Chris@10: \let\HEADINGShook=\relax
Chris@10: 
Chris@10: % Commands to set those variables.
Chris@10: % For example, this is what  @headings on  does
Chris@10: % @evenheading @thistitle|@thispage|@thischapter
Chris@10: % @oddheading @thischapter|@thispage|@thistitle
Chris@10: % @evenfooting @thisfile||
Chris@10: % @oddfooting ||@thisfile
Chris@10: 
Chris@10: 
Chris@10: \def\evenheading{\parsearg\evenheadingxxx}
Chris@10: \def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish}
Chris@10: \def\evenheadingyyy #1\|#2\|#3\|#4\finish{%
Chris@10: \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
Chris@10: 
Chris@10: \def\oddheading{\parsearg\oddheadingxxx}
Chris@10: \def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish}
Chris@10: \def\oddheadingyyy #1\|#2\|#3\|#4\finish{%
Chris@10: \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
Chris@10: 
Chris@10: \parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
Chris@10: 
Chris@10: \def\evenfooting{\parsearg\evenfootingxxx}
Chris@10: \def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish}
Chris@10: \def\evenfootingyyy #1\|#2\|#3\|#4\finish{%
Chris@10: \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
Chris@10: 
Chris@10: \def\oddfooting{\parsearg\oddfootingxxx}
Chris@10: \def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish}
Chris@10: \def\oddfootingyyy #1\|#2\|#3\|#4\finish{%
Chris@10:   \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}%
Chris@10:   %
Chris@10:   % Leave some space for the footline.  Hopefully ok to assume
Chris@10:   % @evenfooting will not be used by itself.
Chris@10:   \global\advance\pageheight by -12pt
Chris@10:   \global\advance\vsize by -12pt
Chris@10: }
Chris@10: 
Chris@10: \parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}}
Chris@10: 
Chris@10: % @evenheadingmarks top     \thischapter <- chapter at the top of a page
Chris@10: % @evenheadingmarks bottom  \thischapter <- chapter at the bottom of a page
Chris@10: %
Chris@10: % The same set of arguments for:
Chris@10: %
Chris@10: % @oddheadingmarks
Chris@10: % @evenfootingmarks
Chris@10: % @oddfootingmarks
Chris@10: % @everyheadingmarks
Chris@10: % @everyfootingmarks
Chris@10: 
Chris@10: \def\evenheadingmarks{\headingmarks{even}{heading}}
Chris@10: \def\oddheadingmarks{\headingmarks{odd}{heading}}
Chris@10: \def\evenfootingmarks{\headingmarks{even}{footing}}
Chris@10: \def\oddfootingmarks{\headingmarks{odd}{footing}}
Chris@10: \def\everyheadingmarks#1 {\headingmarks{even}{heading}{#1}
Chris@10:                           \headingmarks{odd}{heading}{#1} }
Chris@10: \def\everyfootingmarks#1 {\headingmarks{even}{footing}{#1}
Chris@10:                           \headingmarks{odd}{footing}{#1} }
Chris@10: % #1 = even/odd, #2 = heading/footing, #3 = top/bottom.
Chris@10: \def\headingmarks#1#2#3 {%
Chris@10:   \expandafter\let\expandafter\temp \csname get#3headingmarks\endcsname
Chris@10:   \global\expandafter\let\csname get#1#2marks\endcsname \temp
Chris@10: }
Chris@10: 
Chris@10: \everyheadingmarks bottom
Chris@10: \everyfootingmarks bottom
Chris@10: 
Chris@10: % @headings double      turns headings on for double-sided printing.
Chris@10: % @headings single      turns headings on for single-sided printing.
Chris@10: % @headings off         turns them off.
Chris@10: % @headings on          same as @headings double, retained for compatibility.
Chris@10: % @headings after       turns on double-sided headings after this page.
Chris@10: % @headings doubleafter turns on double-sided headings after this page.
Chris@10: % @headings singleafter turns on single-sided headings after this page.
Chris@10: % By default, they are off at the start of a document,
Chris@10: % and turned `on' after @end titlepage.
Chris@10: 
Chris@10: \def\headings #1 {\csname HEADINGS#1\endcsname}
Chris@10: 
Chris@10: \def\headingsoff{% non-global headings elimination
Chris@10:   \evenheadline={\hfil}\evenfootline={\hfil}%
Chris@10:    \oddheadline={\hfil}\oddfootline={\hfil}%
Chris@10: }
Chris@10: 
Chris@10: \def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting
Chris@10: \HEADINGSoff  % it's the default
Chris@10: 
Chris@10: % When we turn headings on, set the page number to 1.
Chris@10: % For double-sided printing, put current file name in lower left corner,
Chris@10: % chapter name on inside top of right hand pages, document
Chris@10: % title on inside top of left hand pages, and page numbers on outside top
Chris@10: % edge of all pages.
Chris@10: \def\HEADINGSdouble{%
Chris@10: \global\pageno=1
Chris@10: \global\evenfootline={\hfil}
Chris@10: \global\oddfootline={\hfil}
Chris@10: \global\evenheadline={\line{\folio\hfil\thistitle}}
Chris@10: \global\oddheadline={\line{\thischapter\hfil\folio}}
Chris@10: \global\let\contentsalignmacro = \chapoddpage
Chris@10: }
Chris@10: \let\contentsalignmacro = \chappager
Chris@10: 
Chris@10: % For single-sided printing, chapter title goes across top left of page,
Chris@10: % page number on top right.
Chris@10: \def\HEADINGSsingle{%
Chris@10: \global\pageno=1
Chris@10: \global\evenfootline={\hfil}
Chris@10: \global\oddfootline={\hfil}
Chris@10: \global\evenheadline={\line{\thischapter\hfil\folio}}
Chris@10: \global\oddheadline={\line{\thischapter\hfil\folio}}
Chris@10: \global\let\contentsalignmacro = \chappager
Chris@10: }
Chris@10: \def\HEADINGSon{\HEADINGSdouble}
Chris@10: 
Chris@10: \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
Chris@10: \let\HEADINGSdoubleafter=\HEADINGSafter
Chris@10: \def\HEADINGSdoublex{%
Chris@10: \global\evenfootline={\hfil}
Chris@10: \global\oddfootline={\hfil}
Chris@10: \global\evenheadline={\line{\folio\hfil\thistitle}}
Chris@10: \global\oddheadline={\line{\thischapter\hfil\folio}}
Chris@10: \global\let\contentsalignmacro = \chapoddpage
Chris@10: }
Chris@10: 
Chris@10: \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
Chris@10: \def\HEADINGSsinglex{%
Chris@10: \global\evenfootline={\hfil}
Chris@10: \global\oddfootline={\hfil}
Chris@10: \global\evenheadline={\line{\thischapter\hfil\folio}}
Chris@10: \global\oddheadline={\line{\thischapter\hfil\folio}}
Chris@10: \global\let\contentsalignmacro = \chappager
Chris@10: }
Chris@10: 
Chris@10: % Subroutines used in generating headings
Chris@10: % This produces Day Month Year style of output.
Chris@10: % Only define if not already defined, in case a txi-??.tex file has set
Chris@10: % up a different format (e.g., txi-cs.tex does this).
Chris@10: \ifx\today\thisisundefined
Chris@10: \def\today{%
Chris@10:   \number\day\space
Chris@10:   \ifcase\month
Chris@10:   \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr
Chris@10:   \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug
Chris@10:   \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec
Chris@10:   \fi
Chris@10:   \space\number\year}
Chris@10: \fi
Chris@10: 
Chris@10: % @settitle line...  specifies the title of the document, for headings.
Chris@10: % It generates no output of its own.
Chris@10: \def\thistitle{\putwordNoTitle}
Chris@10: \def\settitle{\parsearg{\gdef\thistitle}}
Chris@10: 
Chris@10: 
Chris@10: \message{tables,}
Chris@10: % Tables -- @table, @ftable, @vtable, @item(x).
Chris@10: 
Chris@10: % default indentation of table text
Chris@10: \newdimen\tableindent \tableindent=.8in
Chris@10: % default indentation of @itemize and @enumerate text
Chris@10: \newdimen\itemindent  \itemindent=.3in
Chris@10: % margin between end of table item and start of table text.
Chris@10: \newdimen\itemmargin  \itemmargin=.1in
Chris@10: 
Chris@10: % used internally for \itemindent minus \itemmargin
Chris@10: \newdimen\itemmax
Chris@10: 
Chris@10: % Note @table, @ftable, and @vtable define @item, @itemx, etc., with
Chris@10: % these defs.
Chris@10: % They also define \itemindex
Chris@10: % to index the item name in whatever manner is desired (perhaps none).
Chris@10: 
Chris@10: \newif\ifitemxneedsnegativevskip
Chris@10: 
Chris@10: \def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
Chris@10: 
Chris@10: \def\internalBitem{\smallbreak \parsearg\itemzzz}
Chris@10: \def\internalBitemx{\itemxpar \parsearg\itemzzz}
Chris@10: 
Chris@10: \def\itemzzz #1{\begingroup %
Chris@10:   \advance\hsize by -\rightskip
Chris@10:   \advance\hsize by -\tableindent
Chris@10:   \setbox0=\hbox{\itemindicate{#1}}%
Chris@10:   \itemindex{#1}%
Chris@10:   \nobreak % This prevents a break before @itemx.
Chris@10:   %
Chris@10:   % If the item text does not fit in the space we have, put it on a line
Chris@10:   % by itself, and do not allow a page break either before or after that
Chris@10:   % line.  We do not start a paragraph here because then if the next
Chris@10:   % command is, e.g., @kindex, the whatsit would get put into the
Chris@10:   % horizontal list on a line by itself, resulting in extra blank space.
Chris@10:   \ifdim \wd0>\itemmax
Chris@10:     %
Chris@10:     % Make this a paragraph so we get the \parskip glue and wrapping,
Chris@10:     % but leave it ragged-right.
Chris@10:     \begingroup
Chris@10:       \advance\leftskip by-\tableindent
Chris@10:       \advance\hsize by\tableindent
Chris@10:       \advance\rightskip by0pt plus1fil\relax
Chris@10:       \leavevmode\unhbox0\par
Chris@10:     \endgroup
Chris@10:     %
Chris@10:     % We're going to be starting a paragraph, but we don't want the
Chris@10:     % \parskip glue -- logically it's part of the @item we just started.
Chris@10:     \nobreak \vskip-\parskip
Chris@10:     %
Chris@10:     % Stop a page break at the \parskip glue coming up.  However, if
Chris@10:     % what follows is an environment such as @example, there will be no
Chris@10:     % \parskip glue; then the negative vskip we just inserted would
Chris@10:     % cause the example and the item to crash together.  So we use this
Chris@10:     % bizarre value of 10001 as a signal to \aboveenvbreak to insert
Chris@10:     % \parskip glue after all.  Section titles are handled this way also.
Chris@10:     %
Chris@10:     \penalty 10001
Chris@10:     \endgroup
Chris@10:     \itemxneedsnegativevskipfalse
Chris@10:   \else
Chris@10:     % The item text fits into the space.  Start a paragraph, so that the
Chris@10:     % following text (if any) will end up on the same line.
Chris@10:     \noindent
Chris@10:     % Do this with kerns and \unhbox so that if there is a footnote in
Chris@10:     % the item text, it can migrate to the main vertical list and
Chris@10:     % eventually be printed.
Chris@10:     \nobreak\kern-\tableindent
Chris@10:     \dimen0 = \itemmax  \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0
Chris@10:     \unhbox0
Chris@10:     \nobreak\kern\dimen0
Chris@10:     \endgroup
Chris@10:     \itemxneedsnegativevskiptrue
Chris@10:   \fi
Chris@10: }
Chris@10: 
Chris@10: \def\item{\errmessage{@item while not in a list environment}}
Chris@10: \def\itemx{\errmessage{@itemx while not in a list environment}}
Chris@10: 
Chris@10: % @table, @ftable, @vtable.
Chris@10: \envdef\table{%
Chris@10:   \let\itemindex\gobble
Chris@10:   \tablecheck{table}%
Chris@10: }
Chris@10: \envdef\ftable{%
Chris@10:   \def\itemindex ##1{\doind {fn}{\code{##1}}}%
Chris@10:   \tablecheck{ftable}%
Chris@10: }
Chris@10: \envdef\vtable{%
Chris@10:   \def\itemindex ##1{\doind {vr}{\code{##1}}}%
Chris@10:   \tablecheck{vtable}%
Chris@10: }
Chris@10: \def\tablecheck#1{%
Chris@10:   \ifnum \the\catcode`\^^M=\active
Chris@10:     \endgroup
Chris@10:     \errmessage{This command won't work in this context; perhaps the problem is
Chris@10:       that we are \inenvironment\thisenv}%
Chris@10:     \def\next{\doignore{#1}}%
Chris@10:   \else
Chris@10:     \let\next\tablex
Chris@10:   \fi
Chris@10:   \next
Chris@10: }
Chris@10: \def\tablex#1{%
Chris@10:   \def\itemindicate{#1}%
Chris@10:   \parsearg\tabley
Chris@10: }
Chris@10: \def\tabley#1{%
Chris@10:   {%
Chris@10:     \makevalueexpandable
Chris@10:     \edef\temp{\noexpand\tablez #1\space\space\space}%
Chris@10:     \expandafter
Chris@10:   }\temp \endtablez
Chris@10: }
Chris@10: \def\tablez #1 #2 #3 #4\endtablez{%
Chris@10:   \aboveenvbreak
Chris@10:   \ifnum 0#1>0 \advance \leftskip by #1\mil \fi
Chris@10:   \ifnum 0#2>0 \tableindent=#2\mil \fi
Chris@10:   \ifnum 0#3>0 \advance \rightskip by #3\mil \fi
Chris@10:   \itemmax=\tableindent
Chris@10:   \advance \itemmax by -\itemmargin
Chris@10:   \advance \leftskip by \tableindent
Chris@10:   \exdentamount=\tableindent
Chris@10:   \parindent = 0pt
Chris@10:   \parskip = \smallskipamount
Chris@10:   \ifdim \parskip=0pt \parskip=2pt \fi
Chris@10:   \let\item = \internalBitem
Chris@10:   \let\itemx = \internalBitemx
Chris@10: }
Chris@10: \def\Etable{\endgraf\afterenvbreak}
Chris@10: \let\Eftable\Etable
Chris@10: \let\Evtable\Etable
Chris@10: \let\Eitemize\Etable
Chris@10: \let\Eenumerate\Etable
Chris@10: 
Chris@10: % This is the counter used by @enumerate, which is really @itemize
Chris@10: 
Chris@10: \newcount \itemno
Chris@10: 
Chris@10: \envdef\itemize{\parsearg\doitemize}
Chris@10: 
Chris@10: \def\doitemize#1{%
Chris@10:   \aboveenvbreak
Chris@10:   \itemmax=\itemindent
Chris@10:   \advance\itemmax by -\itemmargin
Chris@10:   \advance\leftskip by \itemindent
Chris@10:   \exdentamount=\itemindent
Chris@10:   \parindent=0pt
Chris@10:   \parskip=\smallskipamount
Chris@10:   \ifdim\parskip=0pt \parskip=2pt \fi
Chris@10:   %
Chris@10:   % Try typesetting the item mark that if the document erroneously says
Chris@10:   % something like @itemize @samp (intending @table), there's an error
Chris@10:   % right away at the @itemize.  It's not the best error message in the
Chris@10:   % world, but it's better than leaving it to the @item.  This means if
Chris@10:   % the user wants an empty mark, they have to say @w{} not just @w.
Chris@10:   \def\itemcontents{#1}%
Chris@10:   \setbox0 = \hbox{\itemcontents}%
Chris@10:   %
Chris@10:   % @itemize with no arg is equivalent to @itemize @bullet.
Chris@10:   \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi
Chris@10:   %
Chris@10:   \let\item=\itemizeitem
Chris@10: }
Chris@10: 
Chris@10: % Definition of @item while inside @itemize and @enumerate.
Chris@10: %
Chris@10: \def\itemizeitem{%
Chris@10:   \advance\itemno by 1  % for enumerations
Chris@10:   {\let\par=\endgraf \smallbreak}% reasonable place to break
Chris@10:   {%
Chris@10:    % If the document has an @itemize directly after a section title, a
Chris@10:    % \nobreak will be last on the list, and \sectionheading will have
Chris@10:    % done a \vskip-\parskip.  In that case, we don't want to zero
Chris@10:    % parskip, or the item text will crash with the heading.  On the
Chris@10:    % other hand, when there is normal text preceding the item (as there
Chris@10:    % usually is), we do want to zero parskip, or there would be too much
Chris@10:    % space.  In that case, we won't have a \nobreak before.  At least
Chris@10:    % that's the theory.
Chris@10:    \ifnum\lastpenalty<10000 \parskip=0in \fi
Chris@10:    \noindent
Chris@10:    \hbox to 0pt{\hss \itemcontents \kern\itemmargin}%
Chris@10:    %
Chris@10:    \vadjust{\penalty 1200}}% not good to break after first line of item.
Chris@10:   \flushcr
Chris@10: }
Chris@10: 
Chris@10: % \splitoff TOKENS\endmark defines \first to be the first token in
Chris@10: % TOKENS, and \rest to be the remainder.
Chris@10: %
Chris@10: \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
Chris@10: 
Chris@10: % Allow an optional argument of an uppercase letter, lowercase letter,
Chris@10: % or number, to specify the first label in the enumerated list.  No
Chris@10: % argument is the same as `1'.
Chris@10: %
Chris@10: \envparseargdef\enumerate{\enumeratey #1  \endenumeratey}
Chris@10: \def\enumeratey #1 #2\endenumeratey{%
Chris@10:   % If we were given no argument, pretend we were given `1'.
Chris@10:   \def\thearg{#1}%
Chris@10:   \ifx\thearg\empty \def\thearg{1}\fi
Chris@10:   %
Chris@10:   % Detect if the argument is a single token.  If so, it might be a
Chris@10:   % letter.  Otherwise, the only valid thing it can be is a number.
Chris@10:   % (We will always have one token, because of the test we just made.
Chris@10:   % This is a good thing, since \splitoff doesn't work given nothing at
Chris@10:   % all -- the first parameter is undelimited.)
Chris@10:   \expandafter\splitoff\thearg\endmark
Chris@10:   \ifx\rest\empty
Chris@10:     % Only one token in the argument.  It could still be anything.
Chris@10:     % A ``lowercase letter'' is one whose \lccode is nonzero.
Chris@10:     % An ``uppercase letter'' is one whose \lccode is both nonzero, and
Chris@10:     %   not equal to itself.
Chris@10:     % Otherwise, we assume it's a number.
Chris@10:     %
Chris@10:     % We need the \relax at the end of the \ifnum lines to stop TeX from
Chris@10:     % continuing to look for a <number>.
Chris@10:     %
Chris@10:     \ifnum\lccode\expandafter`\thearg=0\relax
Chris@10:       \numericenumerate % a number (we hope)
Chris@10:     \else
Chris@10:       % It's a letter.
Chris@10:       \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
Chris@10:         \lowercaseenumerate % lowercase letter
Chris@10:       \else
Chris@10:         \uppercaseenumerate % uppercase letter
Chris@10:       \fi
Chris@10:     \fi
Chris@10:   \else
Chris@10:     % Multiple tokens in the argument.  We hope it's a number.
Chris@10:     \numericenumerate
Chris@10:   \fi
Chris@10: }
Chris@10: 
Chris@10: % An @enumerate whose labels are integers.  The starting integer is
Chris@10: % given in \thearg.
Chris@10: %
Chris@10: \def\numericenumerate{%
Chris@10:   \itemno = \thearg
Chris@10:   \startenumeration{\the\itemno}%
Chris@10: }
Chris@10: 
Chris@10: % The starting (lowercase) letter is in \thearg.
Chris@10: \def\lowercaseenumerate{%
Chris@10:   \itemno = \expandafter`\thearg
Chris@10:   \startenumeration{%
Chris@10:     % Be sure we're not beyond the end of the alphabet.
Chris@10:     \ifnum\itemno=0
Chris@10:       \errmessage{No more lowercase letters in @enumerate; get a bigger
Chris@10:                   alphabet}%
Chris@10:     \fi
Chris@10:     \char\lccode\itemno
Chris@10:   }%
Chris@10: }
Chris@10: 
Chris@10: % The starting (uppercase) letter is in \thearg.
Chris@10: \def\uppercaseenumerate{%
Chris@10:   \itemno = \expandafter`\thearg
Chris@10:   \startenumeration{%
Chris@10:     % Be sure we're not beyond the end of the alphabet.
Chris@10:     \ifnum\itemno=0
Chris@10:       \errmessage{No more uppercase letters in @enumerate; get a bigger
Chris@10:                   alphabet}
Chris@10:     \fi
Chris@10:     \char\uccode\itemno
Chris@10:   }%
Chris@10: }
Chris@10: 
Chris@10: % Call \doitemize, adding a period to the first argument and supplying the
Chris@10: % common last two arguments.  Also subtract one from the initial value in
Chris@10: % \itemno, since @item increments \itemno.
Chris@10: %
Chris@10: \def\startenumeration#1{%
Chris@10:   \advance\itemno by -1
Chris@10:   \doitemize{#1.}\flushcr
Chris@10: }
Chris@10: 
Chris@10: % @alphaenumerate and @capsenumerate are abbreviations for giving an arg
Chris@10: % to @enumerate.
Chris@10: %
Chris@10: \def\alphaenumerate{\enumerate{a}}
Chris@10: \def\capsenumerate{\enumerate{A}}
Chris@10: \def\Ealphaenumerate{\Eenumerate}
Chris@10: \def\Ecapsenumerate{\Eenumerate}
Chris@10: 
Chris@10: 
Chris@10: % @multitable macros
Chris@10: % Amy Hendrickson, 8/18/94, 3/6/96
Chris@10: %
Chris@10: % @multitable ... @end multitable will make as many columns as desired.
Chris@10: % Contents of each column will wrap at width given in preamble.  Width
Chris@10: % can be specified either with sample text given in a template line,
Chris@10: % or in percent of \hsize, the current width of text on page.
Chris@10: 
Chris@10: % Table can continue over pages but will only break between lines.
Chris@10: 
Chris@10: % To make preamble:
Chris@10: %
Chris@10: % Either define widths of columns in terms of percent of \hsize:
Chris@10: %   @multitable @columnfractions .25 .3 .45
Chris@10: %   @item ...
Chris@10: %
Chris@10: %   Numbers following @columnfractions are the percent of the total
Chris@10: %   current hsize to be used for each column. You may use as many
Chris@10: %   columns as desired.
Chris@10: 
Chris@10: 
Chris@10: % Or use a template:
Chris@10: %   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
Chris@10: %   @item ...
Chris@10: %   using the widest term desired in each column.
Chris@10: 
Chris@10: % Each new table line starts with @item, each subsequent new column
Chris@10: % starts with @tab. Empty columns may be produced by supplying @tab's
Chris@10: % with nothing between them for as many times as empty columns are needed,
Chris@10: % ie, @tab@tab@tab will produce two empty columns.
Chris@10: 
Chris@10: % @item, @tab do not need to be on their own lines, but it will not hurt
Chris@10: % if they are.
Chris@10: 
Chris@10: % Sample multitable:
Chris@10: 
Chris@10: %   @multitable {Column 1 template} {Column 2 template} {Column 3 template}
Chris@10: %   @item first col stuff @tab second col stuff @tab third col
Chris@10: %   @item
Chris@10: %   first col stuff
Chris@10: %   @tab
Chris@10: %   second col stuff
Chris@10: %   @tab
Chris@10: %   third col
Chris@10: %   @item first col stuff @tab second col stuff
Chris@10: %   @tab Many paragraphs of text may be used in any column.
Chris@10: %
Chris@10: %         They will wrap at the width determined by the template.
Chris@10: %   @item@tab@tab This will be in third column.
Chris@10: %   @end multitable
Chris@10: 
Chris@10: % Default dimensions may be reset by user.
Chris@10: % @multitableparskip is vertical space between paragraphs in table.
Chris@10: % @multitableparindent is paragraph indent in table.
Chris@10: % @multitablecolmargin is horizontal space to be left between columns.
Chris@10: % @multitablelinespace is space to leave between table items, baseline
Chris@10: %                                                            to baseline.
Chris@10: %   0pt means it depends on current normal line spacing.
Chris@10: %
Chris@10: \newskip\multitableparskip
Chris@10: \newskip\multitableparindent
Chris@10: \newdimen\multitablecolspace
Chris@10: \newskip\multitablelinespace
Chris@10: \multitableparskip=0pt
Chris@10: \multitableparindent=6pt
Chris@10: \multitablecolspace=12pt
Chris@10: \multitablelinespace=0pt
Chris@10: 
Chris@10: % Macros used to set up halign preamble:
Chris@10: %
Chris@10: \let\endsetuptable\relax
Chris@10: \def\xendsetuptable{\endsetuptable}
Chris@10: \let\columnfractions\relax
Chris@10: \def\xcolumnfractions{\columnfractions}
Chris@10: \newif\ifsetpercent
Chris@10: 
Chris@10: % #1 is the @columnfraction, usually a decimal number like .5, but might
Chris@10: % be just 1.  We just use it, whatever it is.
Chris@10: %
Chris@10: \def\pickupwholefraction#1 {%
Chris@10:   \global\advance\colcount by 1
Chris@10:   \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}%
Chris@10:   \setuptable
Chris@10: }
Chris@10: 
Chris@10: \newcount\colcount
Chris@10: \def\setuptable#1{%
Chris@10:   \def\firstarg{#1}%
Chris@10:   \ifx\firstarg\xendsetuptable
Chris@10:     \let\go = \relax
Chris@10:   \else
Chris@10:     \ifx\firstarg\xcolumnfractions
Chris@10:       \global\setpercenttrue
Chris@10:     \else
Chris@10:       \ifsetpercent
Chris@10:          \let\go\pickupwholefraction
Chris@10:       \else
Chris@10:          \global\advance\colcount by 1
Chris@10:          \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a
Chris@10:                    % separator; typically that is always in the input, anyway.
Chris@10:          \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
Chris@10:       \fi
Chris@10:     \fi
Chris@10:     \ifx\go\pickupwholefraction
Chris@10:       % Put the argument back for the \pickupwholefraction call, so
Chris@10:       % we'll always have a period there to be parsed.
Chris@10:       \def\go{\pickupwholefraction#1}%
Chris@10:     \else
Chris@10:       \let\go = \setuptable
Chris@10:     \fi%
Chris@10:   \fi
Chris@10:   \go
Chris@10: }
Chris@10: 
Chris@10: % multitable-only commands.
Chris@10: %
Chris@10: % @headitem starts a heading row, which we typeset in bold.
Chris@10: % Assignments have to be global since we are inside the implicit group
Chris@10: % of an alignment entry.  \everycr resets \everytab so we don't have to
Chris@10: % undo it ourselves.
Chris@10: \def\headitemfont{\b}% for people to use in the template row; not changeable
Chris@10: \def\headitem{%
Chris@10:   \checkenv\multitable
Chris@10:   \crcr
Chris@10:   \global\everytab={\bf}% can't use \headitemfont since the parsing differs
Chris@10:   \the\everytab % for the first item
Chris@10: }%
Chris@10: %
Chris@10: % A \tab used to include \hskip1sp.  But then the space in a template
Chris@10: % line is not enough.  That is bad.  So let's go back to just `&' until
Chris@10: % we again encounter the problem the 1sp was intended to solve.
Chris@10: %					--karl, nathan@acm.org, 20apr99.
Chris@10: \def\tab{\checkenv\multitable &\the\everytab}%
Chris@10: 
Chris@10: % @multitable ... @end multitable definitions:
Chris@10: %
Chris@10: \newtoks\everytab  % insert after every tab.
Chris@10: %
Chris@10: \envdef\multitable{%
Chris@10:   \vskip\parskip
Chris@10:   \startsavinginserts
Chris@10:   %
Chris@10:   % @item within a multitable starts a normal row.
Chris@10:   % We use \def instead of \let so that if one of the multitable entries
Chris@10:   % contains an @itemize, we don't choke on the \item (seen as \crcr aka
Chris@10:   % \endtemplate) expanding \doitemize.
Chris@10:   \def\item{\crcr}%
Chris@10:   %
Chris@10:   \tolerance=9500
Chris@10:   \hbadness=9500
Chris@10:   \setmultitablespacing
Chris@10:   \parskip=\multitableparskip
Chris@10:   \parindent=\multitableparindent
Chris@10:   \overfullrule=0pt
Chris@10:   \global\colcount=0
Chris@10:   %
Chris@10:   \everycr = {%
Chris@10:     \noalign{%
Chris@10:       \global\everytab={}%
Chris@10:       \global\colcount=0 % Reset the column counter.
Chris@10:       % Check for saved footnotes, etc.
Chris@10:       \checkinserts
Chris@10:       % Keeps underfull box messages off when table breaks over pages.
Chris@10:       %\filbreak
Chris@10: 	% Maybe so, but it also creates really weird page breaks when the
Chris@10: 	% table breaks over pages. Wouldn't \vfil be better?  Wait until the
Chris@10: 	% problem manifests itself, so it can be fixed for real --karl.
Chris@10:     }%
Chris@10:   }%
Chris@10:   %
Chris@10:   \parsearg\domultitable
Chris@10: }
Chris@10: \def\domultitable#1{%
Chris@10:   % To parse everything between @multitable and @item:
Chris@10:   \setuptable#1 \endsetuptable
Chris@10:   %
Chris@10:   % This preamble sets up a generic column definition, which will
Chris@10:   % be used as many times as user calls for columns.
Chris@10:   % \vtop will set a single line and will also let text wrap and
Chris@10:   % continue for many paragraphs if desired.
Chris@10:   \halign\bgroup &%
Chris@10:     \global\advance\colcount by 1
Chris@10:     \multistrut
Chris@10:     \vtop{%
Chris@10:       % Use the current \colcount to find the correct column width:
Chris@10:       \hsize=\expandafter\csname col\the\colcount\endcsname
Chris@10:       %
Chris@10:       % In order to keep entries from bumping into each other
Chris@10:       % we will add a \leftskip of \multitablecolspace to all columns after
Chris@10:       % the first one.
Chris@10:       %
Chris@10:       % If a template has been used, we will add \multitablecolspace
Chris@10:       % to the width of each template entry.
Chris@10:       %
Chris@10:       % If the user has set preamble in terms of percent of \hsize we will
Chris@10:       % use that dimension as the width of the column, and the \leftskip
Chris@10:       % will keep entries from bumping into each other.  Table will start at
Chris@10:       % left margin and final column will justify at right margin.
Chris@10:       %
Chris@10:       % Make sure we don't inherit \rightskip from the outer environment.
Chris@10:       \rightskip=0pt
Chris@10:       \ifnum\colcount=1
Chris@10: 	% The first column will be indented with the surrounding text.
Chris@10: 	\advance\hsize by\leftskip
Chris@10:       \else
Chris@10: 	\ifsetpercent \else
Chris@10: 	  % If user has not set preamble in terms of percent of \hsize
Chris@10: 	  % we will advance \hsize by \multitablecolspace.
Chris@10: 	  \advance\hsize by \multitablecolspace
Chris@10: 	\fi
Chris@10:        % In either case we will make \leftskip=\multitablecolspace:
Chris@10:       \leftskip=\multitablecolspace
Chris@10:       \fi
Chris@10:       % Ignoring space at the beginning and end avoids an occasional spurious
Chris@10:       % blank line, when TeX decides to break the line at the space before the
Chris@10:       % box from the multistrut, so the strut ends up on a line by itself.
Chris@10:       % For example:
Chris@10:       % @multitable @columnfractions .11 .89
Chris@10:       % @item @code{#}
Chris@10:       % @tab Legal holiday which is valid in major parts of the whole country.
Chris@10:       % Is automatically provided with highlighting sequences respectively
Chris@10:       % marking characters.
Chris@10:       \noindent\ignorespaces##\unskip\multistrut
Chris@10:     }\cr
Chris@10: }
Chris@10: \def\Emultitable{%
Chris@10:   \crcr
Chris@10:   \egroup % end the \halign
Chris@10:   \global\setpercentfalse
Chris@10: }
Chris@10: 
Chris@10: \def\setmultitablespacing{%
Chris@10:   \def\multistrut{\strut}% just use the standard line spacing
Chris@10:   %
Chris@10:   % Compute \multitablelinespace (if not defined by user) for use in
Chris@10:   % \multitableparskip calculation.  We used define \multistrut based on
Chris@10:   % this, but (ironically) that caused the spacing to be off.
Chris@10:   % See bug-texinfo report from Werner Lemberg, 31 Oct 2004 12:52:20 +0100.
Chris@10: \ifdim\multitablelinespace=0pt
Chris@10: \setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip
Chris@10: \global\advance\multitablelinespace by-\ht0
Chris@10: \fi
Chris@10: % Test to see if parskip is larger than space between lines of
Chris@10: % table. If not, do nothing.
Chris@10: %        If so, set to same dimension as multitablelinespace.
Chris@10: \ifdim\multitableparskip>\multitablelinespace
Chris@10: \global\multitableparskip=\multitablelinespace
Chris@10: \global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
Chris@10:                                       % than skip between lines in the table.
Chris@10: \fi%
Chris@10: \ifdim\multitableparskip=0pt
Chris@10: \global\multitableparskip=\multitablelinespace
Chris@10: \global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
Chris@10:                                       % than skip between lines in the table.
Chris@10: \fi}
Chris@10: 
Chris@10: 
Chris@10: \message{conditionals,}
Chris@10: 
Chris@10: % @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext,
Chris@10: % @ifnotxml always succeed.  They currently do nothing; we don't
Chris@10: % attempt to check whether the conditionals are properly nested.  But we
Chris@10: % have to remember that they are conditionals, so that @end doesn't
Chris@10: % attempt to close an environment group.
Chris@10: %
Chris@10: \def\makecond#1{%
Chris@10:   \expandafter\let\csname #1\endcsname = \relax
Chris@10:   \expandafter\let\csname iscond.#1\endcsname = 1
Chris@10: }
Chris@10: \makecond{iftex}
Chris@10: \makecond{ifnotdocbook}
Chris@10: \makecond{ifnothtml}
Chris@10: \makecond{ifnotinfo}
Chris@10: \makecond{ifnotplaintext}
Chris@10: \makecond{ifnotxml}
Chris@10: 
Chris@10: % Ignore @ignore, @ifhtml, @ifinfo, and the like.
Chris@10: %
Chris@10: \def\direntry{\doignore{direntry}}
Chris@10: \def\documentdescription{\doignore{documentdescription}}
Chris@10: \def\docbook{\doignore{docbook}}
Chris@10: \def\html{\doignore{html}}
Chris@10: \def\ifdocbook{\doignore{ifdocbook}}
Chris@10: \def\ifhtml{\doignore{ifhtml}}
Chris@10: \def\ifinfo{\doignore{ifinfo}}
Chris@10: \def\ifnottex{\doignore{ifnottex}}
Chris@10: \def\ifplaintext{\doignore{ifplaintext}}
Chris@10: \def\ifxml{\doignore{ifxml}}
Chris@10: \def\ignore{\doignore{ignore}}
Chris@10: \def\menu{\doignore{menu}}
Chris@10: \def\xml{\doignore{xml}}
Chris@10: 
Chris@10: % Ignore text until a line `@end #1', keeping track of nested conditionals.
Chris@10: %
Chris@10: % A count to remember the depth of nesting.
Chris@10: \newcount\doignorecount
Chris@10: 
Chris@10: \def\doignore#1{\begingroup
Chris@10:   % Scan in ``verbatim'' mode:
Chris@10:   \obeylines
Chris@10:   \catcode`\@ = \other
Chris@10:   \catcode`\{ = \other
Chris@10:   \catcode`\} = \other
Chris@10:   %
Chris@10:   % Make sure that spaces turn into tokens that match what \doignoretext wants.
Chris@10:   \spaceisspace
Chris@10:   %
Chris@10:   % Count number of #1's that we've seen.
Chris@10:   \doignorecount = 0
Chris@10:   %
Chris@10:   % Swallow text until we reach the matching `@end #1'.
Chris@10:   \dodoignore{#1}%
Chris@10: }
Chris@10: 
Chris@10: { \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source.
Chris@10:   \obeylines %
Chris@10:   %
Chris@10:   \gdef\dodoignore#1{%
Chris@10:     % #1 contains the command name as a string, e.g., `ifinfo'.
Chris@10:     %
Chris@10:     % Define a command to find the next `@end #1'.
Chris@10:     \long\def\doignoretext##1^^M@end #1{%
Chris@10:       \doignoretextyyy##1^^M@#1\_STOP_}%
Chris@10:     %
Chris@10:     % And this command to find another #1 command, at the beginning of a
Chris@10:     % line.  (Otherwise, we would consider a line `@c @ifset', for
Chris@10:     % example, to count as an @ifset for nesting.)
Chris@10:     \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}%
Chris@10:     %
Chris@10:     % And now expand that command.
Chris@10:     \doignoretext ^^M%
Chris@10:   }%
Chris@10: }
Chris@10: 
Chris@10: \def\doignoreyyy#1{%
Chris@10:   \def\temp{#1}%
Chris@10:   \ifx\temp\empty			% Nothing found.
Chris@10:     \let\next\doignoretextzzz
Chris@10:   \else					% Found a nested condition, ...
Chris@10:     \advance\doignorecount by 1
Chris@10:     \let\next\doignoretextyyy		% ..., look for another.
Chris@10:     % If we're here, #1 ends with ^^M\ifinfo (for example).
Chris@10:   \fi
Chris@10:   \next #1% the token \_STOP_ is present just after this macro.
Chris@10: }
Chris@10: 
Chris@10: % We have to swallow the remaining "\_STOP_".
Chris@10: %
Chris@10: \def\doignoretextzzz#1{%
Chris@10:   \ifnum\doignorecount = 0	% We have just found the outermost @end.
Chris@10:     \let\next\enddoignore
Chris@10:   \else				% Still inside a nested condition.
Chris@10:     \advance\doignorecount by -1
Chris@10:     \let\next\doignoretext      % Look for the next @end.
Chris@10:   \fi
Chris@10:   \next
Chris@10: }
Chris@10: 
Chris@10: % Finish off ignored text.
Chris@10: { \obeylines%
Chris@10:   % Ignore anything after the last `@end #1'; this matters in verbatim
Chris@10:   % environments, where otherwise the newline after an ignored conditional
Chris@10:   % would result in a blank line in the output.
Chris@10:   \gdef\enddoignore#1^^M{\endgroup\ignorespaces}%
Chris@10: }
Chris@10: 
Chris@10: 
Chris@10: % @set VAR sets the variable VAR to an empty value.
Chris@10: % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
Chris@10: %
Chris@10: % Since we want to separate VAR from REST-OF-LINE (which might be
Chris@10: % empty), we can't just use \parsearg; we have to insert a space of our
Chris@10: % own to delimit the rest of the line, and then take it out again if we
Chris@10: % didn't need it.
Chris@10: % We rely on the fact that \parsearg sets \catcode`\ =10.
Chris@10: %
Chris@10: \parseargdef\set{\setyyy#1 \endsetyyy}
Chris@10: \def\setyyy#1 #2\endsetyyy{%
Chris@10:   {%
Chris@10:     \makevalueexpandable
Chris@10:     \def\temp{#2}%
Chris@10:     \edef\next{\gdef\makecsname{SET#1}}%
Chris@10:     \ifx\temp\empty
Chris@10:       \next{}%
Chris@10:     \else
Chris@10:       \setzzz#2\endsetzzz
Chris@10:     \fi
Chris@10:   }%
Chris@10: }
Chris@10: % Remove the trailing space \setxxx inserted.
Chris@10: \def\setzzz#1 \endsetzzz{\next{#1}}
Chris@10: 
Chris@10: % @clear VAR clears (i.e., unsets) the variable VAR.
Chris@10: %
Chris@10: \parseargdef\clear{%
Chris@10:   {%
Chris@10:     \makevalueexpandable
Chris@10:     \global\expandafter\let\csname SET#1\endcsname=\relax
Chris@10:   }%
Chris@10: }
Chris@10: 
Chris@10: % @value{foo} gets the text saved in variable foo.
Chris@10: \def\value{\begingroup\makevalueexpandable\valuexxx}
Chris@10: \def\valuexxx#1{\expandablevalue{#1}\endgroup}
Chris@10: {
Chris@10:   \catcode`\- = \active \catcode`\_ = \active
Chris@10:   %
Chris@10:   \gdef\makevalueexpandable{%
Chris@10:     \let\value = \expandablevalue
Chris@10:     % We don't want these characters active, ...
Chris@10:     \catcode`\-=\other \catcode`\_=\other
Chris@10:     % ..., but we might end up with active ones in the argument if
Chris@10:     % we're called from @code, as @code{@value{foo-bar_}}, though.
Chris@10:     % So \let them to their normal equivalents.
Chris@10:     \let-\realdash \let_\normalunderscore
Chris@10:   }
Chris@10: }
Chris@10: 
Chris@10: % We have this subroutine so that we can handle at least some @value's
Chris@10: % properly in indexes (we call \makevalueexpandable in \indexdummies).
Chris@10: % The command has to be fully expandable (if the variable is set), since
Chris@10: % the result winds up in the index file.  This means that if the
Chris@10: % variable's value contains other Texinfo commands, it's almost certain
Chris@10: % it will fail (although perhaps we could fix that with sufficient work
Chris@10: % to do a one-level expansion on the result, instead of complete).
Chris@10: %
Chris@10: \def\expandablevalue#1{%
Chris@10:   \expandafter\ifx\csname SET#1\endcsname\relax
Chris@10:     {[No value for ``#1'']}%
Chris@10:     \message{Variable `#1', used in @value, is not set.}%
Chris@10:   \else
Chris@10:     \csname SET#1\endcsname
Chris@10:   \fi
Chris@10: }
Chris@10: 
Chris@10: % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
Chris@10: % with @set.
Chris@10: %
Chris@10: % To get special treatment of `@end ifset,' call \makeond and the redefine.
Chris@10: %
Chris@10: \makecond{ifset}
Chris@10: \def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}}
Chris@10: \def\doifset#1#2{%
Chris@10:   {%
Chris@10:     \makevalueexpandable
Chris@10:     \let\next=\empty
Chris@10:     \expandafter\ifx\csname SET#2\endcsname\relax
Chris@10:       #1% If not set, redefine \next.
Chris@10:     \fi
Chris@10:     \expandafter
Chris@10:   }\next
Chris@10: }
Chris@10: \def\ifsetfail{\doignore{ifset}}
Chris@10: 
Chris@10: % @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been
Chris@10: % defined with @set, or has been undefined with @clear.
Chris@10: %
Chris@10: % The `\else' inside the `\doifset' parameter is a trick to reuse the
Chris@10: % above code: if the variable is not set, do nothing, if it is set,
Chris@10: % then redefine \next to \ifclearfail.
Chris@10: %
Chris@10: \makecond{ifclear}
Chris@10: \def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}}
Chris@10: \def\ifclearfail{\doignore{ifclear}}
Chris@10: 
Chris@10: % @dircategory CATEGORY  -- specify a category of the dir file
Chris@10: % which this file should belong to.  Ignore this in TeX.
Chris@10: \let\dircategory=\comment
Chris@10: 
Chris@10: % @defininfoenclose.
Chris@10: \let\definfoenclose=\comment
Chris@10: 
Chris@10: 
Chris@10: \message{indexing,}
Chris@10: % Index generation facilities
Chris@10: 
Chris@10: % Define \newwrite to be identical to plain tex's \newwrite
Chris@10: % except not \outer, so it can be used within macros and \if's.
Chris@10: \edef\newwrite{\makecsname{ptexnewwrite}}
Chris@10: 
Chris@10: % \newindex {foo} defines an index named foo.
Chris@10: % It automatically defines \fooindex such that
Chris@10: % \fooindex ...rest of line... puts an entry in the index foo.
Chris@10: % It also defines \fooindfile to be the number of the output channel for
Chris@10: % the file that accumulates this index.  The file's extension is foo.
Chris@10: % The name of an index should be no more than 2 characters long
Chris@10: % for the sake of vms.
Chris@10: %
Chris@10: \def\newindex#1{%
Chris@10:   \iflinks
Chris@10:     \expandafter\newwrite \csname#1indfile\endcsname
Chris@10:     \openout \csname#1indfile\endcsname \jobname.#1 % Open the file
Chris@10:   \fi
Chris@10:   \expandafter\xdef\csname#1index\endcsname{%     % Define @#1index
Chris@10:     \noexpand\doindex{#1}}
Chris@10: }
Chris@10: 
Chris@10: % @defindex foo  ==  \newindex{foo}
Chris@10: %
Chris@10: \def\defindex{\parsearg\newindex}
Chris@10: 
Chris@10: % Define @defcodeindex, like @defindex except put all entries in @code.
Chris@10: %
Chris@10: \def\defcodeindex{\parsearg\newcodeindex}
Chris@10: %
Chris@10: \def\newcodeindex#1{%
Chris@10:   \iflinks
Chris@10:     \expandafter\newwrite \csname#1indfile\endcsname
Chris@10:     \openout \csname#1indfile\endcsname \jobname.#1
Chris@10:   \fi
Chris@10:   \expandafter\xdef\csname#1index\endcsname{%
Chris@10:     \noexpand\docodeindex{#1}}%
Chris@10: }
Chris@10: 
Chris@10: 
Chris@10: % @synindex foo bar    makes index foo feed into index bar.
Chris@10: % Do this instead of @defindex foo if you don't want it as a separate index.
Chris@10: %
Chris@10: % @syncodeindex foo bar   similar, but put all entries made for index foo
Chris@10: % inside @code.
Chris@10: %
Chris@10: \def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}}
Chris@10: \def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}}
Chris@10: 
Chris@10: % #1 is \doindex or \docodeindex, #2 the index getting redefined (foo),
Chris@10: % #3 the target index (bar).
Chris@10: \def\dosynindex#1#2#3{%
Chris@10:   % Only do \closeout if we haven't already done it, else we'll end up
Chris@10:   % closing the target index.
Chris@10:   \expandafter \ifx\csname donesynindex#2\endcsname \relax
Chris@10:     % The \closeout helps reduce unnecessary open files; the limit on the
Chris@10:     % Acorn RISC OS is a mere 16 files.
Chris@10:     \expandafter\closeout\csname#2indfile\endcsname
Chris@10:     \expandafter\let\csname donesynindex#2\endcsname = 1
Chris@10:   \fi
Chris@10:   % redefine \fooindfile:
Chris@10:   \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname
Chris@10:   \expandafter\let\csname#2indfile\endcsname=\temp
Chris@10:   % redefine \fooindex:
Chris@10:   \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}%
Chris@10: }
Chris@10: 
Chris@10: % Define \doindex, the driver for all \fooindex macros.
Chris@10: % Argument #1 is generated by the calling \fooindex macro,
Chris@10: %  and it is "foo", the name of the index.
Chris@10: 
Chris@10: % \doindex just uses \parsearg; it calls \doind for the actual work.
Chris@10: % This is because \doind is more useful to call from other macros.
Chris@10: 
Chris@10: % There is also \dosubind {index}{topic}{subtopic}
Chris@10: % which makes an entry in a two-level index such as the operation index.
Chris@10: 
Chris@10: \def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer}
Chris@10: \def\singleindexer #1{\doind{\indexname}{#1}}
Chris@10: 
Chris@10: % like the previous two, but they put @code around the argument.
Chris@10: \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
Chris@10: \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
Chris@10: 
Chris@10: % Take care of Texinfo commands that can appear in an index entry.
Chris@10: % Since there are some commands we want to expand, and others we don't,
Chris@10: % we have to laboriously prevent expansion for those that we don't.
Chris@10: %
Chris@10: \def\indexdummies{%
Chris@10:   \escapechar = `\\     % use backslash in output files.
Chris@10:   \def\@{@}% change to @@ when we switch to @ as escape char in index files.
Chris@10:   \def\ {\realbackslash\space }%
Chris@10:   %
Chris@10:   % Need these unexpandable (because we define \tt as a dummy)
Chris@10:   % definitions when @{ or @} appear in index entry text.  Also, more
Chris@10:   % complicated, when \tex is in effect and \{ is a \delimiter again.
Chris@10:   % We can't use \lbracecmd and \rbracecmd because texindex assumes
Chris@10:   % braces and backslashes are used only as delimiters.  Perhaps we
Chris@10:   % should define @lbrace and @rbrace commands a la @comma.
Chris@10:   \def\{{{\tt\char123}}%
Chris@10:   \def\}{{\tt\char125}}%
Chris@10:   %
Chris@10:   % I don't entirely understand this, but when an index entry is
Chris@10:   % generated from a macro call, the \endinput which \scanmacro inserts
Chris@10:   % causes processing to be prematurely terminated.  This is,
Chris@10:   % apparently, because \indexsorttmp is fully expanded, and \endinput
Chris@10:   % is an expandable command.  The redefinition below makes \endinput
Chris@10:   % disappear altogether for that purpose -- although logging shows that
Chris@10:   % processing continues to some further point.  On the other hand, it
Chris@10:   % seems \endinput does not hurt in the printed index arg, since that
Chris@10:   % is still getting written without apparent harm.
Chris@10:   %
Chris@10:   % Sample source (mac-idx3.tex, reported by Graham Percival to
Chris@10:   % help-texinfo, 22may06):
Chris@10:   % @macro funindex {WORD}
Chris@10:   % @findex xyz
Chris@10:   % @end macro
Chris@10:   % ...
Chris@10:   % @funindex commtest
Chris@10:   %
Chris@10:   % The above is not enough to reproduce the bug, but it gives the flavor.
Chris@10:   %
Chris@10:   % Sample whatsit resulting:
Chris@10:   % .@write3{\entry{xyz}{@folio }{@code {xyz@endinput }}}
Chris@10:   %
Chris@10:   % So:
Chris@10:   \let\endinput = \empty
Chris@10:   %
Chris@10:   % Do the redefinitions.
Chris@10:   \commondummies
Chris@10: }
Chris@10: 
Chris@10: % For the aux and toc files, @ is the escape character.  So we want to
Chris@10: % redefine everything using @ as the escape character (instead of
Chris@10: % \realbackslash, still used for index files).  When everything uses @,
Chris@10: % this will be simpler.
Chris@10: %
Chris@10: \def\atdummies{%
Chris@10:   \def\@{@@}%
Chris@10:   \def\ {@ }%
Chris@10:   \let\{ = \lbraceatcmd
Chris@10:   \let\} = \rbraceatcmd
Chris@10:   %
Chris@10:   % Do the redefinitions.
Chris@10:   \commondummies
Chris@10:   \otherbackslash
Chris@10: }
Chris@10: 
Chris@10: % Called from \indexdummies and \atdummies.
Chris@10: %
Chris@10: \def\commondummies{%
Chris@10:   %
Chris@10:   % \definedummyword defines \#1 as \string\#1\space, thus effectively
Chris@10:   % preventing its expansion.  This is used only for control words,
Chris@10:   % not control letters, because the \space would be incorrect for
Chris@10:   % control characters, but is needed to separate the control word
Chris@10:   % from whatever follows.
Chris@10:   %
Chris@10:   % For control letters, we have \definedummyletter, which omits the
Chris@10:   % space.
Chris@10:   %
Chris@10:   % These can be used both for control words that take an argument and
Chris@10:   % those that do not.  If it is followed by {arg} in the input, then
Chris@10:   % that will dutifully get written to the index (or wherever).
Chris@10:   %
Chris@10:   \def\definedummyword  ##1{\def##1{\string##1\space}}%
Chris@10:   \def\definedummyletter##1{\def##1{\string##1}}%
Chris@10:   \let\definedummyaccent\definedummyletter
Chris@10:   %
Chris@10:   \commondummiesnofonts
Chris@10:   %
Chris@10:   \definedummyletter\_%
Chris@10:   \definedummyletter\-%
Chris@10:   %
Chris@10:   % Non-English letters.
Chris@10:   \definedummyword\AA
Chris@10:   \definedummyword\AE
Chris@10:   \definedummyword\DH
Chris@10:   \definedummyword\L
Chris@10:   \definedummyword\O
Chris@10:   \definedummyword\OE
Chris@10:   \definedummyword\TH
Chris@10:   \definedummyword\aa
Chris@10:   \definedummyword\ae
Chris@10:   \definedummyword\dh
Chris@10:   \definedummyword\exclamdown
Chris@10:   \definedummyword\l
Chris@10:   \definedummyword\o
Chris@10:   \definedummyword\oe
Chris@10:   \definedummyword\ordf
Chris@10:   \definedummyword\ordm
Chris@10:   \definedummyword\questiondown
Chris@10:   \definedummyword\ss
Chris@10:   \definedummyword\th
Chris@10:   %
Chris@10:   % Although these internal commands shouldn't show up, sometimes they do.
Chris@10:   \definedummyword\bf
Chris@10:   \definedummyword\gtr
Chris@10:   \definedummyword\hat
Chris@10:   \definedummyword\less
Chris@10:   \definedummyword\sf
Chris@10:   \definedummyword\sl
Chris@10:   \definedummyword\tclose
Chris@10:   \definedummyword\tt
Chris@10:   %
Chris@10:   \definedummyword\LaTeX
Chris@10:   \definedummyword\TeX
Chris@10:   %
Chris@10:   % Assorted special characters.
Chris@10:   \definedummyword\arrow
Chris@10:   \definedummyword\bullet
Chris@10:   \definedummyword\comma
Chris@10:   \definedummyword\copyright
Chris@10:   \definedummyword\registeredsymbol
Chris@10:   \definedummyword\dots
Chris@10:   \definedummyword\enddots
Chris@10:   \definedummyword\entrybreak
Chris@10:   \definedummyword\equiv
Chris@10:   \definedummyword\error
Chris@10:   \definedummyword\euro
Chris@10:   \definedummyword\expansion
Chris@10:   \definedummyword\geq
Chris@10:   \definedummyword\guillemetleft
Chris@10:   \definedummyword\guillemetright
Chris@10:   \definedummyword\guilsinglleft
Chris@10:   \definedummyword\guilsinglright
Chris@10:   \definedummyword\leq
Chris@10:   \definedummyword\minus
Chris@10:   \definedummyword\ogonek
Chris@10:   \definedummyword\pounds
Chris@10:   \definedummyword\point
Chris@10:   \definedummyword\print
Chris@10:   \definedummyword\quotedblbase
Chris@10:   \definedummyword\quotedblleft
Chris@10:   \definedummyword\quotedblright
Chris@10:   \definedummyword\quoteleft
Chris@10:   \definedummyword\quoteright
Chris@10:   \definedummyword\quotesinglbase
Chris@10:   \definedummyword\result
Chris@10:   \definedummyword\textdegree
Chris@10:   %
Chris@10:   % We want to disable all macros so that they are not expanded by \write.
Chris@10:   \macrolist
Chris@10:   %
Chris@10:   \normalturnoffactive
Chris@10:   %
Chris@10:   % Handle some cases of @value -- where it does not contain any
Chris@10:   % (non-fully-expandable) commands.
Chris@10:   \makevalueexpandable
Chris@10: }
Chris@10: 
Chris@10: % \commondummiesnofonts: common to \commondummies and \indexnofonts.
Chris@10: %
Chris@10: \def\commondummiesnofonts{%
Chris@10:   % Control letters and accents.
Chris@10:   \definedummyletter\!%
Chris@10:   \definedummyaccent\"%
Chris@10:   \definedummyaccent\'%
Chris@10:   \definedummyletter\*%
Chris@10:   \definedummyaccent\,%
Chris@10:   \definedummyletter\.%
Chris@10:   \definedummyletter\/%
Chris@10:   \definedummyletter\:%
Chris@10:   \definedummyaccent\=%
Chris@10:   \definedummyletter\?%
Chris@10:   \definedummyaccent\^%
Chris@10:   \definedummyaccent\`%
Chris@10:   \definedummyaccent\~%
Chris@10:   \definedummyword\u
Chris@10:   \definedummyword\v
Chris@10:   \definedummyword\H
Chris@10:   \definedummyword\dotaccent
Chris@10:   \definedummyword\ogonek
Chris@10:   \definedummyword\ringaccent
Chris@10:   \definedummyword\tieaccent
Chris@10:   \definedummyword\ubaraccent
Chris@10:   \definedummyword\udotaccent
Chris@10:   \definedummyword\dotless
Chris@10:   %
Chris@10:   % Texinfo font commands.
Chris@10:   \definedummyword\b
Chris@10:   \definedummyword\i
Chris@10:   \definedummyword\r
Chris@10:   \definedummyword\sansserif
Chris@10:   \definedummyword\sc
Chris@10:   \definedummyword\slanted
Chris@10:   \definedummyword\t
Chris@10:   %
Chris@10:   % Commands that take arguments.
Chris@10:   \definedummyword\acronym
Chris@10:   \definedummyword\anchor
Chris@10:   \definedummyword\cite
Chris@10:   \definedummyword\code
Chris@10:   \definedummyword\command
Chris@10:   \definedummyword\dfn
Chris@10:   \definedummyword\dmn
Chris@10:   \definedummyword\email
Chris@10:   \definedummyword\emph
Chris@10:   \definedummyword\env
Chris@10:   \definedummyword\file
Chris@10:   \definedummyword\indicateurl
Chris@10:   \definedummyword\kbd
Chris@10:   \definedummyword\key
Chris@10:   \definedummyword\math
Chris@10:   \definedummyword\option
Chris@10:   \definedummyword\pxref
Chris@10:   \definedummyword\ref
Chris@10:   \definedummyword\samp
Chris@10:   \definedummyword\strong
Chris@10:   \definedummyword\tie
Chris@10:   \definedummyword\uref
Chris@10:   \definedummyword\url
Chris@10:   \definedummyword\var
Chris@10:   \definedummyword\verb
Chris@10:   \definedummyword\w
Chris@10:   \definedummyword\xref
Chris@10: }
Chris@10: 
Chris@10: % \indexnofonts is used when outputting the strings to sort the index
Chris@10: % by, and when constructing control sequence names.  It eliminates all
Chris@10: % control sequences and just writes whatever the best ASCII sort string
Chris@10: % would be for a given command (usually its argument).
Chris@10: %
Chris@10: \def\indexnofonts{%
Chris@10:   % Accent commands should become @asis.
Chris@10:   \def\definedummyaccent##1{\let##1\asis}%
Chris@10:   % We can just ignore other control letters.
Chris@10:   \def\definedummyletter##1{\let##1\empty}%
Chris@10:   % All control words become @asis by default; overrides below.
Chris@10:   \let\definedummyword\definedummyaccent
Chris@10:   %
Chris@10:   \commondummiesnofonts
Chris@10:   %
Chris@10:   % Don't no-op \tt, since it isn't a user-level command
Chris@10:   % and is used in the definitions of the active chars like <, >, |, etc.
Chris@10:   % Likewise with the other plain tex font commands.
Chris@10:   %\let\tt=\asis
Chris@10:   %
Chris@10:   \def\ { }%
Chris@10:   \def\@{@}%
Chris@10:   \def\_{\normalunderscore}%
Chris@10:   \def\-{}% @- shouldn't affect sorting
Chris@10:   %
Chris@10:   % Unfortunately, texindex is not prepared to handle braces in the
Chris@10:   % content at all.  So for index sorting, we map @{ and @} to strings
Chris@10:   % starting with |, since that ASCII character is between ASCII { and }.
Chris@10:   \def\{{|a}%
Chris@10:   \def\}{|b}%
Chris@10:   %
Chris@10:   % Non-English letters.
Chris@10:   \def\AA{AA}%
Chris@10:   \def\AE{AE}%
Chris@10:   \def\DH{DZZ}%
Chris@10:   \def\L{L}%
Chris@10:   \def\OE{OE}%
Chris@10:   \def\O{O}%
Chris@10:   \def\TH{ZZZ}%
Chris@10:   \def\aa{aa}%
Chris@10:   \def\ae{ae}%
Chris@10:   \def\dh{dzz}%
Chris@10:   \def\exclamdown{!}%
Chris@10:   \def\l{l}%
Chris@10:   \def\oe{oe}%
Chris@10:   \def\ordf{a}%
Chris@10:   \def\ordm{o}%
Chris@10:   \def\o{o}%
Chris@10:   \def\questiondown{?}%
Chris@10:   \def\ss{ss}%
Chris@10:   \def\th{zzz}%
Chris@10:   %
Chris@10:   \def\LaTeX{LaTeX}%
Chris@10:   \def\TeX{TeX}%
Chris@10:   %
Chris@10:   % Assorted special characters.
Chris@10:   % (The following {} will end up in the sort string, but that's ok.)
Chris@10:   \def\arrow{->}%
Chris@10:   \def\bullet{bullet}%
Chris@10:   \def\comma{,}%
Chris@10:   \def\copyright{copyright}%
Chris@10:   \def\dots{...}%
Chris@10:   \def\enddots{...}%
Chris@10:   \def\equiv{==}%
Chris@10:   \def\error{error}%
Chris@10:   \def\euro{euro}%
Chris@10:   \def\expansion{==>}%
Chris@10:   \def\geq{>=}%
Chris@10:   \def\guillemetleft{<<}%
Chris@10:   \def\guillemetright{>>}%
Chris@10:   \def\guilsinglleft{<}%
Chris@10:   \def\guilsinglright{>}%
Chris@10:   \def\leq{<=}%
Chris@10:   \def\minus{-}%
Chris@10:   \def\point{.}%
Chris@10:   \def\pounds{pounds}%
Chris@10:   \def\print{-|}%
Chris@10:   \def\quotedblbase{"}%
Chris@10:   \def\quotedblleft{"}%
Chris@10:   \def\quotedblright{"}%
Chris@10:   \def\quoteleft{`}%
Chris@10:   \def\quoteright{'}%
Chris@10:   \def\quotesinglbase{,}%
Chris@10:   \def\registeredsymbol{R}%
Chris@10:   \def\result{=>}%
Chris@10:   \def\textdegree{o}%
Chris@10:   %
Chris@10:   \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax
Chris@10:   \else \indexlquoteignore \fi
Chris@10:   %
Chris@10:   % We need to get rid of all macros, leaving only the arguments (if present).
Chris@10:   % Of course this is not nearly correct, but it is the best we can do for now.
Chris@10:   % makeinfo does not expand macros in the argument to @deffn, which ends up
Chris@10:   % writing an index entry, and texindex isn't prepared for an index sort entry
Chris@10:   % that starts with \.
Chris@10:   %
Chris@10:   % Since macro invocations are followed by braces, we can just redefine them
Chris@10:   % to take a single TeX argument.  The case of a macro invocation that
Chris@10:   % goes to end-of-line is not handled.
Chris@10:   %
Chris@10:   \macrolist
Chris@10: }
Chris@10: 
Chris@10: % Undocumented (for FSFS 2nd ed.): @set txiindexlquoteignore makes us
Chris@10: % ignore left quotes in the sort term.
Chris@10: {\catcode`\`=\active
Chris@10:  \gdef\indexlquoteignore{\let`=\empty}}
Chris@10: 
Chris@10: \let\indexbackslash=0  %overridden during \printindex.
Chris@10: \let\SETmarginindex=\relax % put index entries in margin (undocumented)?
Chris@10: 
Chris@10: % Most index entries go through here, but \dosubind is the general case.
Chris@10: % #1 is the index name, #2 is the entry text.
Chris@10: \def\doind#1#2{\dosubind{#1}{#2}{}}
Chris@10: 
Chris@10: % Workhorse for all \fooindexes.
Chris@10: % #1 is name of index, #2 is stuff to put there, #3 is subentry --
Chris@10: % empty if called from \doind, as we usually are (the main exception
Chris@10: % is with most defuns, which call us directly).
Chris@10: %
Chris@10: \def\dosubind#1#2#3{%
Chris@10:   \iflinks
Chris@10:   {%
Chris@10:     % Store the main index entry text (including the third arg).
Chris@10:     \toks0 = {#2}%
Chris@10:     % If third arg is present, precede it with a space.
Chris@10:     \def\thirdarg{#3}%
Chris@10:     \ifx\thirdarg\empty \else
Chris@10:       \toks0 = \expandafter{\the\toks0 \space #3}%
Chris@10:     \fi
Chris@10:     %
Chris@10:     \edef\writeto{\csname#1indfile\endcsname}%
Chris@10:     %
Chris@10:     \safewhatsit\dosubindwrite
Chris@10:   }%
Chris@10:   \fi
Chris@10: }
Chris@10: 
Chris@10: % Write the entry in \toks0 to the index file:
Chris@10: %
Chris@10: \def\dosubindwrite{%
Chris@10:   % Put the index entry in the margin if desired.
Chris@10:   \ifx\SETmarginindex\relax\else
Chris@10:     \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}%
Chris@10:   \fi
Chris@10:   %
Chris@10:   % Remember, we are within a group.
Chris@10:   \indexdummies % Must do this here, since \bf, etc expand at this stage
Chris@10:   \def\backslashcurfont{\indexbackslash}% \indexbackslash isn't defined now
Chris@10:       % so it will be output as is; and it will print as backslash.
Chris@10:   %
Chris@10:   % Process the index entry with all font commands turned off, to
Chris@10:   % get the string to sort by.
Chris@10:   {\indexnofonts
Chris@10:    \edef\temp{\the\toks0}% need full expansion
Chris@10:    \xdef\indexsorttmp{\temp}%
Chris@10:   }%
Chris@10:   %
Chris@10:   % Set up the complete index entry, with both the sort key and
Chris@10:   % the original text, including any font commands.  We write
Chris@10:   % three arguments to \entry to the .?? file (four in the
Chris@10:   % subentry case), texindex reduces to two when writing the .??s
Chris@10:   % sorted result.
Chris@10:   \edef\temp{%
Chris@10:     \write\writeto{%
Chris@10:       \string\entry{\indexsorttmp}{\noexpand\folio}{\the\toks0}}%
Chris@10:   }%
Chris@10:   \temp
Chris@10: }
Chris@10: 
Chris@10: % Take care of unwanted page breaks/skips around a whatsit:
Chris@10: %
Chris@10: % If a skip is the last thing on the list now, preserve it
Chris@10: % by backing up by \lastskip, doing the \write, then inserting
Chris@10: % the skip again.  Otherwise, the whatsit generated by the
Chris@10: % \write or \pdfdest will make \lastskip zero.  The result is that
Chris@10: % sequences like this:
Chris@10: % @end defun
Chris@10: % @tindex whatever
Chris@10: % @defun ...
Chris@10: % will have extra space inserted, because the \medbreak in the
Chris@10: % start of the @defun won't see the skip inserted by the @end of
Chris@10: % the previous defun.
Chris@10: %
Chris@10: % But don't do any of this if we're not in vertical mode.  We
Chris@10: % don't want to do a \vskip and prematurely end a paragraph.
Chris@10: %
Chris@10: % Avoid page breaks due to these extra skips, too.
Chris@10: %
Chris@10: % But wait, there is a catch there:
Chris@10: % We'll have to check whether \lastskip is zero skip.  \ifdim is not
Chris@10: % sufficient for this purpose, as it ignores stretch and shrink parts
Chris@10: % of the skip.  The only way seems to be to check the textual
Chris@10: % representation of the skip.
Chris@10: %
Chris@10: % The following is almost like \def\zeroskipmacro{0.0pt} except that
Chris@10: % the ``p'' and ``t'' characters have catcode \other, not 11 (letter).
Chris@10: %
Chris@10: \edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname}
Chris@10: %
Chris@10: \newskip\whatsitskip
Chris@10: \newcount\whatsitpenalty
Chris@10: %
Chris@10: % ..., ready, GO:
Chris@10: %
Chris@10: \def\safewhatsit#1{\ifhmode
Chris@10:   #1%
Chris@10:  \else
Chris@10:   % \lastskip and \lastpenalty cannot both be nonzero simultaneously.
Chris@10:   \whatsitskip = \lastskip
Chris@10:   \edef\lastskipmacro{\the\lastskip}%
Chris@10:   \whatsitpenalty = \lastpenalty
Chris@10:   %
Chris@10:   % If \lastskip is nonzero, that means the last item was a
Chris@10:   % skip.  And since a skip is discardable, that means this
Chris@10:   % -\whatsitskip glue we're inserting is preceded by a
Chris@10:   % non-discardable item, therefore it is not a potential
Chris@10:   % breakpoint, therefore no \nobreak needed.
Chris@10:   \ifx\lastskipmacro\zeroskipmacro
Chris@10:   \else
Chris@10:     \vskip-\whatsitskip
Chris@10:   \fi
Chris@10:   %
Chris@10:   #1%
Chris@10:   %
Chris@10:   \ifx\lastskipmacro\zeroskipmacro
Chris@10:     % If \lastskip was zero, perhaps the last item was a penalty, and
Chris@10:     % perhaps it was >=10000, e.g., a \nobreak.  In that case, we want
Chris@10:     % to re-insert the same penalty (values >10000 are used for various
Chris@10:     % signals); since we just inserted a non-discardable item, any
Chris@10:     % following glue (such as a \parskip) would be a breakpoint.  For example:
Chris@10:     %   @deffn deffn-whatever
Chris@10:     %   @vindex index-whatever
Chris@10:     %   Description.
Chris@10:     % would allow a break between the index-whatever whatsit
Chris@10:     % and the "Description." paragraph.
Chris@10:     \ifnum\whatsitpenalty>9999 \penalty\whatsitpenalty \fi
Chris@10:   \else
Chris@10:     % On the other hand, if we had a nonzero \lastskip,
Chris@10:     % this make-up glue would be preceded by a non-discardable item
Chris@10:     % (the whatsit from the \write), so we must insert a \nobreak.
Chris@10:     \nobreak\vskip\whatsitskip
Chris@10:   \fi
Chris@10: \fi}
Chris@10: 
Chris@10: % The index entry written in the file actually looks like
Chris@10: %  \entry {sortstring}{page}{topic}
Chris@10: % or
Chris@10: %  \entry {sortstring}{page}{topic}{subtopic}
Chris@10: % The texindex program reads in these files and writes files
Chris@10: % containing these kinds of lines:
Chris@10: %  \initial {c}
Chris@10: %     before the first topic whose initial is c
Chris@10: %  \entry {topic}{pagelist}
Chris@10: %     for a topic that is used without subtopics
Chris@10: %  \primary {topic}
Chris@10: %     for the beginning of a topic that is used with subtopics
Chris@10: %  \secondary {subtopic}{pagelist}
Chris@10: %     for each subtopic.
Chris@10: 
Chris@10: % Define the user-accessible indexing commands
Chris@10: % @findex, @vindex, @kindex, @cindex.
Chris@10: 
Chris@10: \def\findex {\fnindex}
Chris@10: \def\kindex {\kyindex}
Chris@10: \def\cindex {\cpindex}
Chris@10: \def\vindex {\vrindex}
Chris@10: \def\tindex {\tpindex}
Chris@10: \def\pindex {\pgindex}
Chris@10: 
Chris@10: \def\cindexsub {\begingroup\obeylines\cindexsub}
Chris@10: {\obeylines %
Chris@10: \gdef\cindexsub "#1" #2^^M{\endgroup %
Chris@10: \dosubind{cp}{#2}{#1}}}
Chris@10: 
Chris@10: % Define the macros used in formatting output of the sorted index material.
Chris@10: 
Chris@10: % @printindex causes a particular index (the ??s file) to get printed.
Chris@10: % It does not print any chapter heading (usually an @unnumbered).
Chris@10: %
Chris@10: \parseargdef\printindex{\begingroup
Chris@10:   \dobreak \chapheadingskip{10000}%
Chris@10:   %
Chris@10:   \smallfonts \rm
Chris@10:   \tolerance = 9500
Chris@10:   \plainfrenchspacing
Chris@10:   \everypar = {}% don't want the \kern\-parindent from indentation suppression.
Chris@10:   %
Chris@10:   % See if the index file exists and is nonempty.
Chris@10:   % Change catcode of @ here so that if the index file contains
Chris@10:   % \initial {@}
Chris@10:   % as its first line, TeX doesn't complain about mismatched braces
Chris@10:   % (because it thinks @} is a control sequence).
Chris@10:   \catcode`\@ = 11
Chris@10:   \openin 1 \jobname.#1s
Chris@10:   \ifeof 1
Chris@10:     % \enddoublecolumns gets confused if there is no text in the index,
Chris@10:     % and it loses the chapter title and the aux file entries for the
Chris@10:     % index.  The easiest way to prevent this problem is to make sure
Chris@10:     % there is some text.
Chris@10:     \putwordIndexNonexistent
Chris@10:   \else
Chris@10:     %
Chris@10:     % If the index file exists but is empty, then \openin leaves \ifeof
Chris@10:     % false.  We have to make TeX try to read something from the file, so
Chris@10:     % it can discover if there is anything in it.
Chris@10:     \read 1 to \temp
Chris@10:     \ifeof 1
Chris@10:       \putwordIndexIsEmpty
Chris@10:     \else
Chris@10:       % Index files are almost Texinfo source, but we use \ as the escape
Chris@10:       % character.  It would be better to use @, but that's too big a change
Chris@10:       % to make right now.
Chris@10:       \def\indexbackslash{\backslashcurfont}%
Chris@10:       \catcode`\\ = 0
Chris@10:       \escapechar = `\\
Chris@10:       \begindoublecolumns
Chris@10:       \input \jobname.#1s
Chris@10:       \enddoublecolumns
Chris@10:     \fi
Chris@10:   \fi
Chris@10:   \closein 1
Chris@10: \endgroup}
Chris@10: 
Chris@10: % These macros are used by the sorted index file itself.
Chris@10: % Change them to control the appearance of the index.
Chris@10: 
Chris@10: \def\initial#1{{%
Chris@10:   % Some minor font changes for the special characters.
Chris@10:   \let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt
Chris@10:   %
Chris@10:   % Remove any glue we may have, we'll be inserting our own.
Chris@10:   \removelastskip
Chris@10:   %
Chris@10:   % We like breaks before the index initials, so insert a bonus.
Chris@10:   \nobreak
Chris@10:   \vskip 0pt plus 3\baselineskip
Chris@10:   \penalty 0
Chris@10:   \vskip 0pt plus -3\baselineskip
Chris@10:   %
Chris@10:   % Typeset the initial.  Making this add up to a whole number of
Chris@10:   % baselineskips increases the chance of the dots lining up from column
Chris@10:   % to column.  It still won't often be perfect, because of the stretch
Chris@10:   % we need before each entry, but it's better.
Chris@10:   %
Chris@10:   % No shrink because it confuses \balancecolumns.
Chris@10:   \vskip 1.67\baselineskip plus .5\baselineskip
Chris@10:   \leftline{\secbf #1}%
Chris@10:   % Do our best not to break after the initial.
Chris@10:   \nobreak
Chris@10:   \vskip .33\baselineskip plus .1\baselineskip
Chris@10: }}
Chris@10: 
Chris@10: % \entry typesets a paragraph consisting of the text (#1), dot leaders, and
Chris@10: % then page number (#2) flushed to the right margin.  It is used for index
Chris@10: % and table of contents entries.  The paragraph is indented by \leftskip.
Chris@10: %
Chris@10: % A straightforward implementation would start like this:
Chris@10: %	\def\entry#1#2{...
Chris@10: % But this freezes the catcodes in the argument, and can cause problems to
Chris@10: % @code, which sets - active.  This problem was fixed by a kludge---
Chris@10: % ``-'' was active throughout whole index, but this isn't really right.
Chris@10: % The right solution is to prevent \entry from swallowing the whole text.
Chris@10: %                                 --kasal, 21nov03
Chris@10: \def\entry{%
Chris@10:   \begingroup
Chris@10:     %
Chris@10:     % Start a new paragraph if necessary, so our assignments below can't
Chris@10:     % affect previous text.
Chris@10:     \par
Chris@10:     %
Chris@10:     % Do not fill out the last line with white space.
Chris@10:     \parfillskip = 0in
Chris@10:     %
Chris@10:     % No extra space above this paragraph.
Chris@10:     \parskip = 0in
Chris@10:     %
Chris@10:     % Do not prefer a separate line ending with a hyphen to fewer lines.
Chris@10:     \finalhyphendemerits = 0
Chris@10:     %
Chris@10:     % \hangindent is only relevant when the entry text and page number
Chris@10:     % don't both fit on one line.  In that case, bob suggests starting the
Chris@10:     % dots pretty far over on the line.  Unfortunately, a large
Chris@10:     % indentation looks wrong when the entry text itself is broken across
Chris@10:     % lines.  So we use a small indentation and put up with long leaders.
Chris@10:     %
Chris@10:     % \hangafter is reset to 1 (which is the value we want) at the start
Chris@10:     % of each paragraph, so we need not do anything with that.
Chris@10:     \hangindent = 2em
Chris@10:     %
Chris@10:     % When the entry text needs to be broken, just fill out the first line
Chris@10:     % with blank space.
Chris@10:     \rightskip = 0pt plus1fil
Chris@10:     %
Chris@10:     % A bit of stretch before each entry for the benefit of balancing
Chris@10:     % columns.
Chris@10:     \vskip 0pt plus1pt
Chris@10:     %
Chris@10:     % When reading the text of entry, convert explicit line breaks
Chris@10:     % from @* into spaces.  The user might give these in long section
Chris@10:     % titles, for instance.
Chris@10:     \def\*{\unskip\space\ignorespaces}%
Chris@10:     \def\entrybreak{\hfil\break}%
Chris@10:     %
Chris@10:     % Swallow the left brace of the text (first parameter):
Chris@10:     \afterassignment\doentry
Chris@10:     \let\temp =
Chris@10: }
Chris@10: \def\entrybreak{\unskip\space\ignorespaces}%
Chris@10: \def\doentry{%
Chris@10:     \bgroup % Instead of the swallowed brace.
Chris@10:       \noindent
Chris@10:       \aftergroup\finishentry
Chris@10:       % And now comes the text of the entry.
Chris@10: }
Chris@10: \def\finishentry#1{%
Chris@10:     % #1 is the page number.
Chris@10:     %
Chris@10:     % The following is kludged to not output a line of dots in the index if
Chris@10:     % there are no page numbers.  The next person who breaks this will be
Chris@10:     % cursed by a Unix daemon.
Chris@10:     \setbox\boxA = \hbox{#1}%
Chris@10:     \ifdim\wd\boxA = 0pt
Chris@10:       \ %
Chris@10:     \else
Chris@10:       %
Chris@10:       % If we must, put the page number on a line of its own, and fill out
Chris@10:       % this line with blank space.  (The \hfil is overwhelmed with the
Chris@10:       % fill leaders glue in \indexdotfill if the page number does fit.)
Chris@10:       \hfil\penalty50
Chris@10:       \null\nobreak\indexdotfill % Have leaders before the page number.
Chris@10:       %
Chris@10:       % The `\ ' here is removed by the implicit \unskip that TeX does as
Chris@10:       % part of (the primitive) \par.  Without it, a spurious underfull
Chris@10:       % \hbox ensues.
Chris@10:       \ifpdf
Chris@10: 	\pdfgettoks#1.%
Chris@10: 	\ \the\toksA
Chris@10:       \else
Chris@10: 	\ #1%
Chris@10:       \fi
Chris@10:     \fi
Chris@10:     \par
Chris@10:   \endgroup
Chris@10: }
Chris@10: 
Chris@10: % Like plain.tex's \dotfill, except uses up at least 1 em.
Chris@10: \def\indexdotfill{\cleaders
Chris@10:   \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1fill}
Chris@10: 
Chris@10: \def\primary #1{\line{#1\hfil}}
Chris@10: 
Chris@10: \newskip\secondaryindent \secondaryindent=0.5cm
Chris@10: \def\secondary#1#2{{%
Chris@10:   \parfillskip=0in
Chris@10:   \parskip=0in
Chris@10:   \hangindent=1in
Chris@10:   \hangafter=1
Chris@10:   \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill
Chris@10:   \ifpdf
Chris@10:     \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
Chris@10:   \else
Chris@10:     #2
Chris@10:   \fi
Chris@10:   \par
Chris@10: }}
Chris@10: 
Chris@10: % Define two-column mode, which we use to typeset indexes.
Chris@10: % Adapted from the TeXbook, page 416, which is to say,
Chris@10: % the manmac.tex format used to print the TeXbook itself.
Chris@10: \catcode`\@=11
Chris@10: 
Chris@10: \newbox\partialpage
Chris@10: \newdimen\doublecolumnhsize
Chris@10: 
Chris@10: \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
Chris@10:   % Grab any single-column material above us.
Chris@10:   \output = {%
Chris@10:     %
Chris@10:     % Here is a possibility not foreseen in manmac: if we accumulate a
Chris@10:     % whole lot of material, we might end up calling this \output
Chris@10:     % routine twice in a row (see the doublecol-lose test, which is
Chris@10:     % essentially a couple of indexes with @setchapternewpage off).  In
Chris@10:     % that case we just ship out what is in \partialpage with the normal
Chris@10:     % output routine.  Generally, \partialpage will be empty when this
Chris@10:     % runs and this will be a no-op.  See the indexspread.tex test case.
Chris@10:     \ifvoid\partialpage \else
Chris@10:       \onepageout{\pagecontents\partialpage}%
Chris@10:     \fi
Chris@10:     %
Chris@10:     \global\setbox\partialpage = \vbox{%
Chris@10:       % Unvbox the main output page.
Chris@10:       \unvbox\PAGE
Chris@10:       \kern-\topskip \kern\baselineskip
Chris@10:     }%
Chris@10:   }%
Chris@10:   \eject % run that output routine to set \partialpage
Chris@10:   %
Chris@10:   % Use the double-column output routine for subsequent pages.
Chris@10:   \output = {\doublecolumnout}%
Chris@10:   %
Chris@10:   % Change the page size parameters.  We could do this once outside this
Chris@10:   % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
Chris@10:   % format, but then we repeat the same computation.  Repeating a couple
Chris@10:   % of assignments once per index is clearly meaningless for the
Chris@10:   % execution time, so we may as well do it in one place.
Chris@10:   %
Chris@10:   % First we halve the line length, less a little for the gutter between
Chris@10:   % the columns.  We compute the gutter based on the line length, so it
Chris@10:   % changes automatically with the paper format.  The magic constant
Chris@10:   % below is chosen so that the gutter has the same value (well, +-<1pt)
Chris@10:   % as it did when we hard-coded it.
Chris@10:   %
Chris@10:   % We put the result in a separate register, \doublecolumhsize, so we
Chris@10:   % can restore it in \pagesofar, after \hsize itself has (potentially)
Chris@10:   % been clobbered.
Chris@10:   %
Chris@10:   \doublecolumnhsize = \hsize
Chris@10:     \advance\doublecolumnhsize by -.04154\hsize
Chris@10:     \divide\doublecolumnhsize by 2
Chris@10:   \hsize = \doublecolumnhsize
Chris@10:   %
Chris@10:   % Double the \vsize as well.  (We don't need a separate register here,
Chris@10:   % since nobody clobbers \vsize.)
Chris@10:   \vsize = 2\vsize
Chris@10: }
Chris@10: 
Chris@10: % The double-column output routine for all double-column pages except
Chris@10: % the last.
Chris@10: %
Chris@10: \def\doublecolumnout{%
Chris@10:   \splittopskip=\topskip \splitmaxdepth=\maxdepth
Chris@10:   % Get the available space for the double columns -- the normal
Chris@10:   % (undoubled) page height minus any material left over from the
Chris@10:   % previous page.
Chris@10:   \dimen@ = \vsize
Chris@10:   \divide\dimen@ by 2
Chris@10:   \advance\dimen@ by -\ht\partialpage
Chris@10:   %
Chris@10:   % box0 will be the left-hand column, box2 the right.
Chris@10:   \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
Chris@10:   \onepageout\pagesofar
Chris@10:   \unvbox255
Chris@10:   \penalty\outputpenalty
Chris@10: }
Chris@10: %
Chris@10: % Re-output the contents of the output page -- any previous material,
Chris@10: % followed by the two boxes we just split, in box0 and box2.
Chris@10: \def\pagesofar{%
Chris@10:   \unvbox\partialpage
Chris@10:   %
Chris@10:   \hsize = \doublecolumnhsize
Chris@10:   \wd0=\hsize \wd2=\hsize
Chris@10:   \hbox to\pagewidth{\box0\hfil\box2}%
Chris@10: }
Chris@10: %
Chris@10: % All done with double columns.
Chris@10: \def\enddoublecolumns{%
Chris@10:   % The following penalty ensures that the page builder is exercised
Chris@10:   % _before_ we change the output routine.  This is necessary in the
Chris@10:   % following situation:
Chris@10:   %
Chris@10:   % The last section of the index consists only of a single entry.
Chris@10:   % Before this section, \pagetotal is less than \pagegoal, so no
Chris@10:   % break occurs before the last section starts.  However, the last
Chris@10:   % section, consisting of \initial and the single \entry, does not
Chris@10:   % fit on the page and has to be broken off.  Without the following
Chris@10:   % penalty the page builder will not be exercised until \eject
Chris@10:   % below, and by that time we'll already have changed the output
Chris@10:   % routine to the \balancecolumns version, so the next-to-last
Chris@10:   % double-column page will be processed with \balancecolumns, which
Chris@10:   % is wrong:  The two columns will go to the main vertical list, with
Chris@10:   % the broken-off section in the recent contributions.  As soon as
Chris@10:   % the output routine finishes, TeX starts reconsidering the page
Chris@10:   % break.  The two columns and the broken-off section both fit on the
Chris@10:   % page, because the two columns now take up only half of the page
Chris@10:   % goal.  When TeX sees \eject from below which follows the final
Chris@10:   % section, it invokes the new output routine that we've set after
Chris@10:   % \balancecolumns below; \onepageout will try to fit the two columns
Chris@10:   % and the final section into the vbox of \pageheight (see
Chris@10:   % \pagebody), causing an overfull box.
Chris@10:   %
Chris@10:   % Note that glue won't work here, because glue does not exercise the
Chris@10:   % page builder, unlike penalties (see The TeXbook, pp. 280-281).
Chris@10:   \penalty0
Chris@10:   %
Chris@10:   \output = {%
Chris@10:     % Split the last of the double-column material.  Leave it on the
Chris@10:     % current page, no automatic page break.
Chris@10:     \balancecolumns
Chris@10:     %
Chris@10:     % If we end up splitting too much material for the current page,
Chris@10:     % though, there will be another page break right after this \output
Chris@10:     % invocation ends.  Having called \balancecolumns once, we do not
Chris@10:     % want to call it again.  Therefore, reset \output to its normal
Chris@10:     % definition right away.  (We hope \balancecolumns will never be
Chris@10:     % called on to balance too much material, but if it is, this makes
Chris@10:     % the output somewhat more palatable.)
Chris@10:     \global\output = {\onepageout{\pagecontents\PAGE}}%
Chris@10:   }%
Chris@10:   \eject
Chris@10:   \endgroup % started in \begindoublecolumns
Chris@10:   %
Chris@10:   % \pagegoal was set to the doubled \vsize above, since we restarted
Chris@10:   % the current page.  We're now back to normal single-column
Chris@10:   % typesetting, so reset \pagegoal to the normal \vsize (after the
Chris@10:   % \endgroup where \vsize got restored).
Chris@10:   \pagegoal = \vsize
Chris@10: }
Chris@10: %
Chris@10: % Called at the end of the double column material.
Chris@10: \def\balancecolumns{%
Chris@10:   \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120.
Chris@10:   \dimen@ = \ht0
Chris@10:   \advance\dimen@ by \topskip
Chris@10:   \advance\dimen@ by-\baselineskip
Chris@10:   \divide\dimen@ by 2 % target to split to
Chris@10:   %debug\message{final 2-column material height=\the\ht0, target=\the\dimen@.}%
Chris@10:   \splittopskip = \topskip
Chris@10:   % Loop until we get a decent breakpoint.
Chris@10:   {%
Chris@10:     \vbadness = 10000
Chris@10:     \loop
Chris@10:       \global\setbox3 = \copy0
Chris@10:       \global\setbox1 = \vsplit3 to \dimen@
Chris@10:     \ifdim\ht3>\dimen@
Chris@10:       \global\advance\dimen@ by 1pt
Chris@10:     \repeat
Chris@10:   }%
Chris@10:   %debug\message{split to \the\dimen@, column heights: \the\ht1, \the\ht3.}%
Chris@10:   \setbox0=\vbox to\dimen@{\unvbox1}%
Chris@10:   \setbox2=\vbox to\dimen@{\unvbox3}%
Chris@10:   %
Chris@10:   \pagesofar
Chris@10: }
Chris@10: \catcode`\@ = \other
Chris@10: 
Chris@10: 
Chris@10: \message{sectioning,}
Chris@10: % Chapters, sections, etc.
Chris@10: 
Chris@10: % Let's start with @part.
Chris@10: \outer\parseargdef\part{\partzzz{#1}}
Chris@10: \def\partzzz#1{%
Chris@10:   \chapoddpage
Chris@10:   \null
Chris@10:   \vskip.3\vsize  % move it down on the page a bit
Chris@10:   \begingroup
Chris@10:     \noindent \titlefonts\rmisbold #1\par % the text
Chris@10:     \let\lastnode=\empty      % no node to associate with
Chris@10:     \writetocentry{part}{#1}{}% but put it in the toc
Chris@10:     \headingsoff              % no headline or footline on the part page
Chris@10:     \chapoddpage
Chris@10:   \endgroup
Chris@10: }
Chris@10: 
Chris@10: % \unnumberedno is an oxymoron.  But we count the unnumbered
Chris@10: % sections so that we can refer to them unambiguously in the pdf
Chris@10: % outlines by their "section number".  We avoid collisions with chapter
Chris@10: % numbers by starting them at 10000.  (If a document ever has 10000
Chris@10: % chapters, we're in trouble anyway, I'm sure.)
Chris@10: \newcount\unnumberedno \unnumberedno = 10000
Chris@10: \newcount\chapno
Chris@10: \newcount\secno        \secno=0
Chris@10: \newcount\subsecno     \subsecno=0
Chris@10: \newcount\subsubsecno  \subsubsecno=0
Chris@10: 
Chris@10: % This counter is funny since it counts through charcodes of letters A, B, ...
Chris@10: \newcount\appendixno  \appendixno = `\@
Chris@10: %
Chris@10: % \def\appendixletter{\char\the\appendixno}
Chris@10: % We do the following ugly conditional instead of the above simple
Chris@10: % construct for the sake of pdftex, which needs the actual
Chris@10: % letter in the expansion, not just typeset.
Chris@10: %
Chris@10: \def\appendixletter{%
Chris@10:   \ifnum\appendixno=`A A%
Chris@10:   \else\ifnum\appendixno=`B B%
Chris@10:   \else\ifnum\appendixno=`C C%
Chris@10:   \else\ifnum\appendixno=`D D%
Chris@10:   \else\ifnum\appendixno=`E E%
Chris@10:   \else\ifnum\appendixno=`F F%
Chris@10:   \else\ifnum\appendixno=`G G%
Chris@10:   \else\ifnum\appendixno=`H H%
Chris@10:   \else\ifnum\appendixno=`I I%
Chris@10:   \else\ifnum\appendixno=`J J%
Chris@10:   \else\ifnum\appendixno=`K K%
Chris@10:   \else\ifnum\appendixno=`L L%
Chris@10:   \else\ifnum\appendixno=`M M%
Chris@10:   \else\ifnum\appendixno=`N N%
Chris@10:   \else\ifnum\appendixno=`O O%
Chris@10:   \else\ifnum\appendixno=`P P%
Chris@10:   \else\ifnum\appendixno=`Q Q%
Chris@10:   \else\ifnum\appendixno=`R R%
Chris@10:   \else\ifnum\appendixno=`S S%
Chris@10:   \else\ifnum\appendixno=`T T%
Chris@10:   \else\ifnum\appendixno=`U U%
Chris@10:   \else\ifnum\appendixno=`V V%
Chris@10:   \else\ifnum\appendixno=`W W%
Chris@10:   \else\ifnum\appendixno=`X X%
Chris@10:   \else\ifnum\appendixno=`Y Y%
Chris@10:   \else\ifnum\appendixno=`Z Z%
Chris@10:   % The \the is necessary, despite appearances, because \appendixletter is
Chris@10:   % expanded while writing the .toc file.  \char\appendixno is not
Chris@10:   % expandable, thus it is written literally, thus all appendixes come out
Chris@10:   % with the same letter (or @) in the toc without it.
Chris@10:   \else\char\the\appendixno
Chris@10:   \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
Chris@10:   \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
Chris@10: 
Chris@10: % Each @chapter defines these (using marks) as the number+name, number
Chris@10: % and name of the chapter.  Page headings and footings can use
Chris@10: % these.  @section does likewise.
Chris@10: \def\thischapter{}
Chris@10: \def\thischapternum{}
Chris@10: \def\thischaptername{}
Chris@10: \def\thissection{}
Chris@10: \def\thissectionnum{}
Chris@10: \def\thissectionname{}
Chris@10: 
Chris@10: \newcount\absseclevel % used to calculate proper heading level
Chris@10: \newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count
Chris@10: 
Chris@10: % @raisesections: treat @section as chapter, @subsection as section, etc.
Chris@10: \def\raisesections{\global\advance\secbase by -1}
Chris@10: \let\up=\raisesections % original BFox name
Chris@10: 
Chris@10: % @lowersections: treat @chapter as section, @section as subsection, etc.
Chris@10: \def\lowersections{\global\advance\secbase by 1}
Chris@10: \let\down=\lowersections % original BFox name
Chris@10: 
Chris@10: % we only have subsub.
Chris@10: \chardef\maxseclevel = 3
Chris@10: %
Chris@10: % A numbered section within an unnumbered changes to unnumbered too.
Chris@10: % To achieve this, remember the "biggest" unnum. sec. we are currently in:
Chris@10: \chardef\unnlevel = \maxseclevel
Chris@10: %
Chris@10: % Trace whether the current chapter is an appendix or not:
Chris@10: % \chapheadtype is "N" or "A", unnumbered chapters are ignored.
Chris@10: \def\chapheadtype{N}
Chris@10: 
Chris@10: % Choose a heading macro
Chris@10: % #1 is heading type
Chris@10: % #2 is heading level
Chris@10: % #3 is text for heading
Chris@10: \def\genhead#1#2#3{%
Chris@10:   % Compute the abs. sec. level:
Chris@10:   \absseclevel=#2
Chris@10:   \advance\absseclevel by \secbase
Chris@10:   % Make sure \absseclevel doesn't fall outside the range:
Chris@10:   \ifnum \absseclevel < 0
Chris@10:     \absseclevel = 0
Chris@10:   \else
Chris@10:     \ifnum \absseclevel > 3
Chris@10:       \absseclevel = 3
Chris@10:     \fi
Chris@10:   \fi
Chris@10:   % The heading type:
Chris@10:   \def\headtype{#1}%
Chris@10:   \if \headtype U%
Chris@10:     \ifnum \absseclevel < \unnlevel
Chris@10:       \chardef\unnlevel = \absseclevel
Chris@10:     \fi
Chris@10:   \else
Chris@10:     % Check for appendix sections:
Chris@10:     \ifnum \absseclevel = 0
Chris@10:       \edef\chapheadtype{\headtype}%
Chris@10:     \else
Chris@10:       \if \headtype A\if \chapheadtype N%
Chris@10: 	\errmessage{@appendix... within a non-appendix chapter}%
Chris@10:       \fi\fi
Chris@10:     \fi
Chris@10:     % Check for numbered within unnumbered:
Chris@10:     \ifnum \absseclevel > \unnlevel
Chris@10:       \def\headtype{U}%
Chris@10:     \else
Chris@10:       \chardef\unnlevel = 3
Chris@10:     \fi
Chris@10:   \fi
Chris@10:   % Now print the heading:
Chris@10:   \if \headtype U%
Chris@10:     \ifcase\absseclevel
Chris@10: 	\unnumberedzzz{#3}%
Chris@10:     \or \unnumberedseczzz{#3}%
Chris@10:     \or \unnumberedsubseczzz{#3}%
Chris@10:     \or \unnumberedsubsubseczzz{#3}%
Chris@10:     \fi
Chris@10:   \else
Chris@10:     \if \headtype A%
Chris@10:       \ifcase\absseclevel
Chris@10: 	  \appendixzzz{#3}%
Chris@10:       \or \appendixsectionzzz{#3}%
Chris@10:       \or \appendixsubseczzz{#3}%
Chris@10:       \or \appendixsubsubseczzz{#3}%
Chris@10:       \fi
Chris@10:     \else
Chris@10:       \ifcase\absseclevel
Chris@10: 	  \chapterzzz{#3}%
Chris@10:       \or \seczzz{#3}%
Chris@10:       \or \numberedsubseczzz{#3}%
Chris@10:       \or \numberedsubsubseczzz{#3}%
Chris@10:       \fi
Chris@10:     \fi
Chris@10:   \fi
Chris@10:   \suppressfirstparagraphindent
Chris@10: }
Chris@10: 
Chris@10: % an interface:
Chris@10: \def\numhead{\genhead N}
Chris@10: \def\apphead{\genhead A}
Chris@10: \def\unnmhead{\genhead U}
Chris@10: 
Chris@10: % @chapter, @appendix, @unnumbered.  Increment top-level counter, reset
Chris@10: % all lower-level sectioning counters to zero.
Chris@10: %
Chris@10: % Also set \chaplevelprefix, which we prepend to @float sequence numbers
Chris@10: % (e.g., figures), q.v.  By default (before any chapter), that is empty.
Chris@10: \let\chaplevelprefix = \empty
Chris@10: %
Chris@10: \outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz
Chris@10: \def\chapterzzz#1{%
Chris@10:   % section resetting is \global in case the chapter is in a group, such
Chris@10:   % as an @include file.
Chris@10:   \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
Chris@10:     \global\advance\chapno by 1
Chris@10:   %
Chris@10:   % Used for \float.
Chris@10:   \gdef\chaplevelprefix{\the\chapno.}%
Chris@10:   \resetallfloatnos
Chris@10:   %
Chris@10:   % \putwordChapter can contain complex things in translations.
Chris@10:   \toks0=\expandafter{\putwordChapter}%
Chris@10:   \message{\the\toks0 \space \the\chapno}%
Chris@10:   %
Chris@10:   % Write the actual heading.
Chris@10:   \chapmacro{#1}{Ynumbered}{\the\chapno}%
Chris@10:   %
Chris@10:   % So @section and the like are numbered underneath this chapter.
Chris@10:   \global\let\section = \numberedsec
Chris@10:   \global\let\subsection = \numberedsubsec
Chris@10:   \global\let\subsubsection = \numberedsubsubsec
Chris@10: }
Chris@10: 
Chris@10: \outer\parseargdef\appendix{\apphead0{#1}} % normally calls appendixzzz
Chris@10: %
Chris@10: \def\appendixzzz#1{%
Chris@10:   \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
Chris@10:     \global\advance\appendixno by 1
Chris@10:   \gdef\chaplevelprefix{\appendixletter.}%
Chris@10:   \resetallfloatnos
Chris@10:   %
Chris@10:   % \putwordAppendix can contain complex things in translations.
Chris@10:   \toks0=\expandafter{\putwordAppendix}%
Chris@10:   \message{\the\toks0 \space \appendixletter}%
Chris@10:   %
Chris@10:   \chapmacro{#1}{Yappendix}{\appendixletter}%
Chris@10:   %
Chris@10:   \global\let\section = \appendixsec
Chris@10:   \global\let\subsection = \appendixsubsec
Chris@10:   \global\let\subsubsection = \appendixsubsubsec
Chris@10: }
Chris@10: 
Chris@10: % normally unnmhead0 calls unnumberedzzz:
Chris@10: \outer\parseargdef\unnumbered{\unnmhead0{#1}}
Chris@10: \def\unnumberedzzz#1{%
Chris@10:   \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
Chris@10:     \global\advance\unnumberedno by 1
Chris@10:   %
Chris@10:   % Since an unnumbered has no number, no prefix for figures.
Chris@10:   \global\let\chaplevelprefix = \empty
Chris@10:   \resetallfloatnos
Chris@10:   %
Chris@10:   % This used to be simply \message{#1}, but TeX fully expands the
Chris@10:   % argument to \message.  Therefore, if #1 contained @-commands, TeX
Chris@10:   % expanded them.  For example, in `@unnumbered The @cite{Book}', TeX
Chris@10:   % expanded @cite (which turns out to cause errors because \cite is meant
Chris@10:   % to be executed, not expanded).
Chris@10:   %
Chris@10:   % Anyway, we don't want the fully-expanded definition of @cite to appear
Chris@10:   % as a result of the \message, we just want `@cite' itself.  We use
Chris@10:   % \the<toks register> to achieve this: TeX expands \the<toks> only once,
Chris@10:   % simply yielding the contents of <toks register>.  (We also do this for
Chris@10:   % the toc entries.)
Chris@10:   \toks0 = {#1}%
Chris@10:   \message{(\the\toks0)}%
Chris@10:   %
Chris@10:   \chapmacro{#1}{Ynothing}{\the\unnumberedno}%
Chris@10:   %
Chris@10:   \global\let\section = \unnumberedsec
Chris@10:   \global\let\subsection = \unnumberedsubsec
Chris@10:   \global\let\subsubsection = \unnumberedsubsubsec
Chris@10: }
Chris@10: 
Chris@10: % @centerchap is like @unnumbered, but the heading is centered.
Chris@10: \outer\parseargdef\centerchap{%
Chris@10:   % Well, we could do the following in a group, but that would break
Chris@10:   % an assumption that \chapmacro is called at the outermost level.
Chris@10:   % Thus we are safer this way:		--kasal, 24feb04
Chris@10:   \let\centerparametersmaybe = \centerparameters
Chris@10:   \unnmhead0{#1}%
Chris@10:   \let\centerparametersmaybe = \relax
Chris@10: }
Chris@10: 
Chris@10: % @top is like @unnumbered.
Chris@10: \let\top\unnumbered
Chris@10: 
Chris@10: % Sections.
Chris@10: % 
Chris@10: \outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
Chris@10: \def\seczzz#1{%
Chris@10:   \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
Chris@10:   \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}%
Chris@10: }
Chris@10: 
Chris@10: % normally calls appendixsectionzzz:
Chris@10: \outer\parseargdef\appendixsection{\apphead1{#1}}
Chris@10: \def\appendixsectionzzz#1{%
Chris@10:   \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
Chris@10:   \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}%
Chris@10: }
Chris@10: \let\appendixsec\appendixsection
Chris@10: 
Chris@10: % normally calls unnumberedseczzz:
Chris@10: \outer\parseargdef\unnumberedsec{\unnmhead1{#1}}
Chris@10: \def\unnumberedseczzz#1{%
Chris@10:   \global\subsecno=0 \global\subsubsecno=0  \global\advance\secno by 1
Chris@10:   \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%
Chris@10: }
Chris@10: 
Chris@10: % Subsections.
Chris@10: % 
Chris@10: % normally calls numberedsubseczzz:
Chris@10: \outer\parseargdef\numberedsubsec{\numhead2{#1}}
Chris@10: \def\numberedsubseczzz#1{%
Chris@10:   \global\subsubsecno=0  \global\advance\subsecno by 1
Chris@10:   \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}%
Chris@10: }
Chris@10: 
Chris@10: % normally calls appendixsubseczzz:
Chris@10: \outer\parseargdef\appendixsubsec{\apphead2{#1}}
Chris@10: \def\appendixsubseczzz#1{%
Chris@10:   \global\subsubsecno=0  \global\advance\subsecno by 1
Chris@10:   \sectionheading{#1}{subsec}{Yappendix}%
Chris@10:                  {\appendixletter.\the\secno.\the\subsecno}%
Chris@10: }
Chris@10: 
Chris@10: % normally calls unnumberedsubseczzz:
Chris@10: \outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}}
Chris@10: \def\unnumberedsubseczzz#1{%
Chris@10:   \global\subsubsecno=0  \global\advance\subsecno by 1
Chris@10:   \sectionheading{#1}{subsec}{Ynothing}%
Chris@10:                  {\the\unnumberedno.\the\secno.\the\subsecno}%
Chris@10: }
Chris@10: 
Chris@10: % Subsubsections.
Chris@10: % 
Chris@10: % normally numberedsubsubseczzz:
Chris@10: \outer\parseargdef\numberedsubsubsec{\numhead3{#1}}
Chris@10: \def\numberedsubsubseczzz#1{%
Chris@10:   \global\advance\subsubsecno by 1
Chris@10:   \sectionheading{#1}{subsubsec}{Ynumbered}%
Chris@10:                  {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}%
Chris@10: }
Chris@10: 
Chris@10: % normally appendixsubsubseczzz:
Chris@10: \outer\parseargdef\appendixsubsubsec{\apphead3{#1}}
Chris@10: \def\appendixsubsubseczzz#1{%
Chris@10:   \global\advance\subsubsecno by 1
Chris@10:   \sectionheading{#1}{subsubsec}{Yappendix}%
Chris@10:                  {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}%
Chris@10: }
Chris@10: 
Chris@10: % normally unnumberedsubsubseczzz:
Chris@10: \outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}}
Chris@10: \def\unnumberedsubsubseczzz#1{%
Chris@10:   \global\advance\subsubsecno by 1
Chris@10:   \sectionheading{#1}{subsubsec}{Ynothing}%
Chris@10:                  {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}%
Chris@10: }
Chris@10: 
Chris@10: % These macros control what the section commands do, according
Chris@10: % to what kind of chapter we are in (ordinary, appendix, or unnumbered).
Chris@10: % Define them by default for a numbered chapter.
Chris@10: \let\section = \numberedsec
Chris@10: \let\subsection = \numberedsubsec
Chris@10: \let\subsubsection = \numberedsubsubsec
Chris@10: 
Chris@10: % Define @majorheading, @heading and @subheading
Chris@10: 
Chris@10: % NOTE on use of \vbox for chapter headings, section headings, and such:
Chris@10: %       1) We use \vbox rather than the earlier \line to permit
Chris@10: %          overlong headings to fold.
Chris@10: %       2) \hyphenpenalty is set to 10000 because hyphenation in a
Chris@10: %          heading is obnoxious; this forbids it.
Chris@10: %       3) Likewise, headings look best if no \parindent is used, and
Chris@10: %          if justification is not attempted.  Hence \raggedright.
Chris@10: 
Chris@10: \def\majorheading{%
Chris@10:   {\advance\chapheadingskip by 10pt \chapbreak }%
Chris@10:   \parsearg\chapheadingzzz
Chris@10: }
Chris@10: 
Chris@10: \def\chapheading{\chapbreak \parsearg\chapheadingzzz}
Chris@10: \def\chapheadingzzz#1{%
Chris@10:   {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
Chris@10:                     \parindent=0pt\ptexraggedright
Chris@10:                     \rmisbold #1\hfill}}%
Chris@10:   \bigskip \par\penalty 200\relax
Chris@10:   \suppressfirstparagraphindent
Chris@10: }
Chris@10: 
Chris@10: % @heading, @subheading, @subsubheading.
Chris@10: \parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{}
Chris@10:   \suppressfirstparagraphindent}
Chris@10: \parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{}
Chris@10:   \suppressfirstparagraphindent}
Chris@10: \parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{}
Chris@10:   \suppressfirstparagraphindent}
Chris@10: 
Chris@10: % These macros generate a chapter, section, etc. heading only
Chris@10: % (including whitespace, linebreaking, etc. around it),
Chris@10: % given all the information in convenient, parsed form.
Chris@10: 
Chris@10: % Args are the skip and penalty (usually negative)
Chris@10: \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
Chris@10: 
Chris@10: % Parameter controlling skip before chapter headings (if needed)
Chris@10: \newskip\chapheadingskip
Chris@10: 
Chris@10: % Define plain chapter starts, and page on/off switching for it.
Chris@10: \def\chapbreak{\dobreak \chapheadingskip {-4000}}
Chris@10: \def\chappager{\par\vfill\supereject}
Chris@10: % Because \domark is called before \chapoddpage, the filler page will
Chris@10: % get the headings for the next chapter, which is wrong.  But we don't
Chris@10: % care -- we just disable all headings on the filler page.
Chris@10: \def\chapoddpage{%
Chris@10:   \chappager
Chris@10:   \ifodd\pageno \else
Chris@10:     \begingroup
Chris@10:       \headingsoff
Chris@10:       \null
Chris@10:       \chappager
Chris@10:     \endgroup
Chris@10:   \fi
Chris@10: }
Chris@10: 
Chris@10: \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
Chris@10: 
Chris@10: \def\CHAPPAGoff{%
Chris@10: \global\let\contentsalignmacro = \chappager
Chris@10: \global\let\pchapsepmacro=\chapbreak
Chris@10: \global\let\pagealignmacro=\chappager}
Chris@10: 
Chris@10: \def\CHAPPAGon{%
Chris@10: \global\let\contentsalignmacro = \chappager
Chris@10: \global\let\pchapsepmacro=\chappager
Chris@10: \global\let\pagealignmacro=\chappager
Chris@10: \global\def\HEADINGSon{\HEADINGSsingle}}
Chris@10: 
Chris@10: \def\CHAPPAGodd{%
Chris@10: \global\let\contentsalignmacro = \chapoddpage
Chris@10: \global\let\pchapsepmacro=\chapoddpage
Chris@10: \global\let\pagealignmacro=\chapoddpage
Chris@10: \global\def\HEADINGSon{\HEADINGSdouble}}
Chris@10: 
Chris@10: \CHAPPAGon
Chris@10: 
Chris@10: % Chapter opening.
Chris@10: %
Chris@10: % #1 is the text, #2 is the section type (Ynumbered, Ynothing,
Chris@10: % Yappendix, Yomitfromtoc), #3 the chapter number.
Chris@10: %
Chris@10: % To test against our argument.
Chris@10: \def\Ynothingkeyword{Ynothing}
Chris@10: \def\Yomitfromtockeyword{Yomitfromtoc}
Chris@10: \def\Yappendixkeyword{Yappendix}
Chris@10: %
Chris@10: \def\chapmacro#1#2#3{%
Chris@10:   % Insert the first mark before the heading break (see notes for \domark).
Chris@10:   \let\prevchapterdefs=\lastchapterdefs
Chris@10:   \let\prevsectiondefs=\lastsectiondefs
Chris@10:   \gdef\lastsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}%
Chris@10:                         \gdef\thissection{}}%
Chris@10:   %
Chris@10:   \def\temptype{#2}%
Chris@10:   \ifx\temptype\Ynothingkeyword
Chris@10:     \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
Chris@10:                           \gdef\thischapter{\thischaptername}}%
Chris@10:   \else\ifx\temptype\Yomitfromtockeyword
Chris@10:     \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
Chris@10:                           \gdef\thischapter{}}%
Chris@10:   \else\ifx\temptype\Yappendixkeyword
Chris@10:     \toks0={#1}%
Chris@10:     \xdef\lastchapterdefs{%
Chris@10:       \gdef\noexpand\thischaptername{\the\toks0}%
Chris@10:       \gdef\noexpand\thischapternum{\appendixletter}%
Chris@10:       % \noexpand\putwordAppendix avoids expanding indigestible
Chris@10:       % commands in some of the translations.
Chris@10:       \gdef\noexpand\thischapter{\noexpand\putwordAppendix{}
Chris@10:                                  \noexpand\thischapternum:
Chris@10:                                  \noexpand\thischaptername}%
Chris@10:     }%
Chris@10:   \else
Chris@10:     \toks0={#1}%
Chris@10:     \xdef\lastchapterdefs{%
Chris@10:       \gdef\noexpand\thischaptername{\the\toks0}%
Chris@10:       \gdef\noexpand\thischapternum{\the\chapno}%
Chris@10:       % \noexpand\putwordChapter avoids expanding indigestible
Chris@10:       % commands in some of the translations.
Chris@10:       \gdef\noexpand\thischapter{\noexpand\putwordChapter{}
Chris@10:                                  \noexpand\thischapternum:
Chris@10:                                  \noexpand\thischaptername}%
Chris@10:     }%
Chris@10:   \fi\fi\fi
Chris@10:   %
Chris@10:   % Output the mark.  Pass it through \safewhatsit, to take care of
Chris@10:   % the preceding space.
Chris@10:   \safewhatsit\domark
Chris@10:   %
Chris@10:   % Insert the chapter heading break.
Chris@10:   \pchapsepmacro
Chris@10:   %
Chris@10:   % Now the second mark, after the heading break.  No break points
Chris@10:   % between here and the heading.
Chris@10:   \let\prevchapterdefs=\lastchapterdefs
Chris@10:   \let\prevsectiondefs=\lastsectiondefs
Chris@10:   \domark
Chris@10:   %
Chris@10:   {%
Chris@10:     \chapfonts \rmisbold
Chris@10:     %
Chris@10:     % Have to define \lastsection before calling \donoderef, because the
Chris@10:     % xref code eventually uses it.  On the other hand, it has to be called
Chris@10:     % after \pchapsepmacro, or the headline will change too soon.
Chris@10:     \gdef\lastsection{#1}%
Chris@10:     %
Chris@10:     % Only insert the separating space if we have a chapter/appendix
Chris@10:     % number, and don't print the unnumbered ``number''.
Chris@10:     \ifx\temptype\Ynothingkeyword
Chris@10:       \setbox0 = \hbox{}%
Chris@10:       \def\toctype{unnchap}%
Chris@10:     \else\ifx\temptype\Yomitfromtockeyword
Chris@10:       \setbox0 = \hbox{}% contents like unnumbered, but no toc entry
Chris@10:       \def\toctype{omit}%
Chris@10:     \else\ifx\temptype\Yappendixkeyword
Chris@10:       \setbox0 = \hbox{\putwordAppendix{} #3\enspace}%
Chris@10:       \def\toctype{app}%
Chris@10:     \else
Chris@10:       \setbox0 = \hbox{#3\enspace}%
Chris@10:       \def\toctype{numchap}%
Chris@10:     \fi\fi\fi
Chris@10:     %
Chris@10:     % Write the toc entry for this chapter.  Must come before the
Chris@10:     % \donoderef, because we include the current node name in the toc
Chris@10:     % entry, and \donoderef resets it to empty.
Chris@10:     \writetocentry{\toctype}{#1}{#3}%
Chris@10:     %
Chris@10:     % For pdftex, we have to write out the node definition (aka, make
Chris@10:     % the pdfdest) after any page break, but before the actual text has
Chris@10:     % been typeset.  If the destination for the pdf outline is after the
Chris@10:     % text, then jumping from the outline may wind up with the text not
Chris@10:     % being visible, for instance under high magnification.
Chris@10:     \donoderef{#2}%
Chris@10:     %
Chris@10:     % Typeset the actual heading.
Chris@10:     \nobreak % Avoid page breaks at the interline glue.
Chris@10:     \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright
Chris@10:           \hangindent=\wd0 \centerparametersmaybe
Chris@10:           \unhbox0 #1\par}%
Chris@10:   }%
Chris@10:   \nobreak\bigskip % no page break after a chapter title
Chris@10:   \nobreak
Chris@10: }
Chris@10: 
Chris@10: % @centerchap -- centered and unnumbered.
Chris@10: \let\centerparametersmaybe = \relax
Chris@10: \def\centerparameters{%
Chris@10:   \advance\rightskip by 3\rightskip
Chris@10:   \leftskip = \rightskip
Chris@10:   \parfillskip = 0pt
Chris@10: }
Chris@10: 
Chris@10: 
Chris@10: % I don't think this chapter style is supported any more, so I'm not
Chris@10: % updating it with the new noderef stuff.  We'll see.  --karl, 11aug03.
Chris@10: %
Chris@10: \def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
Chris@10: %
Chris@10: \def\unnchfopen #1{%
Chris@10: \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
Chris@10:                        \parindent=0pt\ptexraggedright
Chris@10:                        \rmisbold #1\hfill}}\bigskip \par\nobreak
Chris@10: }
Chris@10: \def\chfopen #1#2{\chapoddpage {\chapfonts
Chris@10: \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
Chris@10: \par\penalty 5000 %
Chris@10: }
Chris@10: \def\centerchfopen #1{%
Chris@10: \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000
Chris@10:                        \parindent=0pt
Chris@10:                        \hfill {\rmisbold #1}\hfill}}\bigskip \par\nobreak
Chris@10: }
Chris@10: \def\CHAPFopen{%
Chris@10:   \global\let\chapmacro=\chfopen
Chris@10:   \global\let\centerchapmacro=\centerchfopen}
Chris@10: 
Chris@10: 
Chris@10: % Section titles.  These macros combine the section number parts and
Chris@10: % call the generic \sectionheading to do the printing.
Chris@10: %
Chris@10: \newskip\secheadingskip
Chris@10: \def\secheadingbreak{\dobreak \secheadingskip{-1000}}
Chris@10: 
Chris@10: % Subsection titles.
Chris@10: \newskip\subsecheadingskip
Chris@10: \def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}}
Chris@10: 
Chris@10: % Subsubsection titles.
Chris@10: \def\subsubsecheadingskip{\subsecheadingskip}
Chris@10: \def\subsubsecheadingbreak{\subsecheadingbreak}
Chris@10: 
Chris@10: 
Chris@10: % Print any size, any type, section title.
Chris@10: %
Chris@10: % #1 is the text, #2 is the section level (sec/subsec/subsubsec), #3 is
Chris@10: % the section type for xrefs (Ynumbered, Ynothing, Yappendix), #4 is the
Chris@10: % section number.
Chris@10: %
Chris@10: \def\seckeyword{sec}
Chris@10: %
Chris@10: \def\sectionheading#1#2#3#4{%
Chris@10:   {%
Chris@10:     \checkenv{}% should not be in an environment.
Chris@10:     %
Chris@10:     % Switch to the right set of fonts.
Chris@10:     \csname #2fonts\endcsname \rmisbold
Chris@10:     %
Chris@10:     \def\sectionlevel{#2}%
Chris@10:     \def\temptype{#3}%
Chris@10:     %
Chris@10:     % Insert first mark before the heading break (see notes for \domark).
Chris@10:     \let\prevsectiondefs=\lastsectiondefs
Chris@10:     \ifx\temptype\Ynothingkeyword
Chris@10:       \ifx\sectionlevel\seckeyword
Chris@10:         \gdef\lastsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}%
Chris@10:                               \gdef\thissection{\thissectionname}}%
Chris@10:       \fi
Chris@10:     \else\ifx\temptype\Yomitfromtockeyword
Chris@10:       % Don't redefine \thissection.
Chris@10:     \else\ifx\temptype\Yappendixkeyword
Chris@10:       \ifx\sectionlevel\seckeyword
Chris@10:         \toks0={#1}%
Chris@10:         \xdef\lastsectiondefs{%
Chris@10:           \gdef\noexpand\thissectionname{\the\toks0}%
Chris@10:           \gdef\noexpand\thissectionnum{#4}%
Chris@10:           % \noexpand\putwordSection avoids expanding indigestible
Chris@10:           % commands in some of the translations.
Chris@10:           \gdef\noexpand\thissection{\noexpand\putwordSection{}
Chris@10:                                      \noexpand\thissectionnum:
Chris@10:                                      \noexpand\thissectionname}%
Chris@10:         }%
Chris@10:       \fi
Chris@10:     \else
Chris@10:       \ifx\sectionlevel\seckeyword
Chris@10:         \toks0={#1}%
Chris@10:         \xdef\lastsectiondefs{%
Chris@10:           \gdef\noexpand\thissectionname{\the\toks0}%
Chris@10:           \gdef\noexpand\thissectionnum{#4}%
Chris@10:           % \noexpand\putwordSection avoids expanding indigestible
Chris@10:           % commands in some of the translations.
Chris@10:           \gdef\noexpand\thissection{\noexpand\putwordSection{}
Chris@10:                                      \noexpand\thissectionnum:
Chris@10:                                      \noexpand\thissectionname}%
Chris@10:         }%
Chris@10:       \fi
Chris@10:     \fi\fi\fi
Chris@10:     %
Chris@10:     % Go into vertical mode.  Usually we'll already be there, but we
Chris@10:     % don't want the following whatsit to end up in a preceding paragraph
Chris@10:     % if the document didn't happen to have a blank line.
Chris@10:     \par
Chris@10:     %
Chris@10:     % Output the mark.  Pass it through \safewhatsit, to take care of
Chris@10:     % the preceding space.
Chris@10:     \safewhatsit\domark
Chris@10:     %
Chris@10:     % Insert space above the heading.
Chris@10:     \csname #2headingbreak\endcsname
Chris@10:     %
Chris@10:     % Now the second mark, after the heading break.  No break points
Chris@10:     % between here and the heading.
Chris@10:     \let\prevsectiondefs=\lastsectiondefs
Chris@10:     \domark
Chris@10:     %
Chris@10:     % Only insert the space after the number if we have a section number.
Chris@10:     \ifx\temptype\Ynothingkeyword
Chris@10:       \setbox0 = \hbox{}%
Chris@10:       \def\toctype{unn}%
Chris@10:       \gdef\lastsection{#1}%
Chris@10:     \else\ifx\temptype\Yomitfromtockeyword
Chris@10:       % for @headings -- no section number, don't include in toc,
Chris@10:       % and don't redefine \lastsection.
Chris@10:       \setbox0 = \hbox{}%
Chris@10:       \def\toctype{omit}%
Chris@10:       \let\sectionlevel=\empty
Chris@10:     \else\ifx\temptype\Yappendixkeyword
Chris@10:       \setbox0 = \hbox{#4\enspace}%
Chris@10:       \def\toctype{app}%
Chris@10:       \gdef\lastsection{#1}%
Chris@10:     \else
Chris@10:       \setbox0 = \hbox{#4\enspace}%
Chris@10:       \def\toctype{num}%
Chris@10:       \gdef\lastsection{#1}%
Chris@10:     \fi\fi\fi
Chris@10:     %
Chris@10:     % Write the toc entry (before \donoderef).  See comments in \chapmacro.
Chris@10:     \writetocentry{\toctype\sectionlevel}{#1}{#4}%
Chris@10:     %
Chris@10:     % Write the node reference (= pdf destination for pdftex).
Chris@10:     % Again, see comments in \chapmacro.
Chris@10:     \donoderef{#3}%
Chris@10:     %
Chris@10:     % Interline glue will be inserted when the vbox is completed.
Chris@10:     % That glue will be a valid breakpoint for the page, since it'll be
Chris@10:     % preceded by a whatsit (usually from the \donoderef, or from the
Chris@10:     % \writetocentry if there was no node).  We don't want to allow that
Chris@10:     % break, since then the whatsits could end up on page n while the
Chris@10:     % section is on page n+1, thus toc/etc. are wrong.  Debian bug 276000.
Chris@10:     \nobreak
Chris@10:     %
Chris@10:     % Output the actual section heading.
Chris@10:     \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright
Chris@10:           \hangindent=\wd0  % zero if no section number
Chris@10:           \unhbox0 #1}%
Chris@10:   }%
Chris@10:   % Add extra space after the heading -- half of whatever came above it.
Chris@10:   % Don't allow stretch, though.
Chris@10:   \kern .5 \csname #2headingskip\endcsname
Chris@10:   %
Chris@10:   % Do not let the kern be a potential breakpoint, as it would be if it
Chris@10:   % was followed by glue.
Chris@10:   \nobreak
Chris@10:   %
Chris@10:   % We'll almost certainly start a paragraph next, so don't let that
Chris@10:   % glue accumulate.  (Not a breakpoint because it's preceded by a
Chris@10:   % discardable item.)  However, when a paragraph is not started next
Chris@10:   % (\startdefun, \cartouche, \center, etc.), this needs to be wiped out
Chris@10:   % or the negative glue will cause weirdly wrong output, typically
Chris@10:   % obscuring the section heading with something else.
Chris@10:   \vskip-\parskip
Chris@10:   %
Chris@10:   % This is so the last item on the main vertical list is a known
Chris@10:   % \penalty > 10000, so \startdefun, etc., can recognize the situation
Chris@10:   % and do the needful.
Chris@10:   \penalty 10001
Chris@10: }
Chris@10: 
Chris@10: 
Chris@10: \message{toc,}
Chris@10: % Table of contents.
Chris@10: \newwrite\tocfile
Chris@10: 
Chris@10: % Write an entry to the toc file, opening it if necessary.
Chris@10: % Called from @chapter, etc.
Chris@10: %
Chris@10: % Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno}
Chris@10: % We append the current node name (if any) and page number as additional
Chris@10: % arguments for the \{chap,sec,...}entry macros which will eventually
Chris@10: % read this.  The node name is used in the pdf outlines as the
Chris@10: % destination to jump to.
Chris@10: %
Chris@10: % We open the .toc file for writing here instead of at @setfilename (or
Chris@10: % any other fixed time) so that @contents can be anywhere in the document.
Chris@10: % But if #1 is `omit', then we don't do anything.  This is used for the
Chris@10: % table of contents chapter openings themselves.
Chris@10: %
Chris@10: \newif\iftocfileopened
Chris@10: \def\omitkeyword{omit}%
Chris@10: %
Chris@10: \def\writetocentry#1#2#3{%
Chris@10:   \edef\writetoctype{#1}%
Chris@10:   \ifx\writetoctype\omitkeyword \else
Chris@10:     \iftocfileopened\else
Chris@10:       \immediate\openout\tocfile = \jobname.toc
Chris@10:       \global\tocfileopenedtrue
Chris@10:     \fi
Chris@10:     %
Chris@10:     \iflinks
Chris@10:       {\atdummies
Chris@10:        \edef\temp{%
Chris@10:          \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}%
Chris@10:        \temp
Chris@10:       }%
Chris@10:     \fi
Chris@10:   \fi
Chris@10:   %
Chris@10:   % Tell \shipout to create a pdf destination on each page, if we're
Chris@10:   % writing pdf.  These are used in the table of contents.  We can't
Chris@10:   % just write one on every page because the title pages are numbered
Chris@10:   % 1 and 2 (the page numbers aren't printed), and so are the first
Chris@10:   % two pages of the document.  Thus, we'd have two destinations named
Chris@10:   % `1', and two named `2'.
Chris@10:   \ifpdf \global\pdfmakepagedesttrue \fi
Chris@10: }
Chris@10: 
Chris@10: 
Chris@10: % These characters do not print properly in the Computer Modern roman
Chris@10: % fonts, so we must take special care.  This is more or less redundant
Chris@10: % with the Texinfo input format setup at the end of this file.
Chris@10: %
Chris@10: \def\activecatcodes{%
Chris@10:   \catcode`\"=\active
Chris@10:   \catcode`\$=\active
Chris@10:   \catcode`\<=\active
Chris@10:   \catcode`\>=\active
Chris@10:   \catcode`\\=\active
Chris@10:   \catcode`\^=\active
Chris@10:   \catcode`\_=\active
Chris@10:   \catcode`\|=\active
Chris@10:   \catcode`\~=\active
Chris@10: }
Chris@10: 
Chris@10: 
Chris@10: % Read the toc file, which is essentially Texinfo input.
Chris@10: \def\readtocfile{%
Chris@10:   \setupdatafile
Chris@10:   \activecatcodes
Chris@10:   \input \tocreadfilename
Chris@10: }
Chris@10: 
Chris@10: \newskip\contentsrightmargin \contentsrightmargin=1in
Chris@10: \newcount\savepageno
Chris@10: \newcount\lastnegativepageno \lastnegativepageno = -1
Chris@10: 
Chris@10: % Prepare to read what we've written to \tocfile.
Chris@10: %
Chris@10: \def\startcontents#1{%
Chris@10:   % If @setchapternewpage on, and @headings double, the contents should
Chris@10:   % start on an odd page, unlike chapters.  Thus, we maintain
Chris@10:   % \contentsalignmacro in parallel with \pagealignmacro.
Chris@10:   % From: Torbjorn Granlund <tege@matematik.su.se>
Chris@10:   \contentsalignmacro
Chris@10:   \immediate\closeout\tocfile
Chris@10:   %
Chris@10:   % Don't need to put `Contents' or `Short Contents' in the headline.
Chris@10:   % It is abundantly clear what they are.
Chris@10:   \chapmacro{#1}{Yomitfromtoc}{}%
Chris@10:   %
Chris@10:   \savepageno = \pageno
Chris@10:   \begingroup                  % Set up to handle contents files properly.
Chris@10:     \raggedbottom              % Worry more about breakpoints than the bottom.
Chris@10:     \advance\hsize by -\contentsrightmargin % Don't use the full line length.
Chris@10:     %
Chris@10:     % Roman numerals for page numbers.
Chris@10:     \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
Chris@10: }
Chris@10: 
Chris@10: % redefined for the two-volume lispref.  We always output on
Chris@10: % \jobname.toc even if this is redefined.
Chris@10: %
Chris@10: \def\tocreadfilename{\jobname.toc}
Chris@10: 
Chris@10: % Normal (long) toc.
Chris@10: %
Chris@10: \def\contents{%
Chris@10:   \startcontents{\putwordTOC}%
Chris@10:     \openin 1 \tocreadfilename\space
Chris@10:     \ifeof 1 \else
Chris@10:       \readtocfile
Chris@10:     \fi
Chris@10:     \vfill \eject
Chris@10:     \contentsalignmacro % in case @setchapternewpage odd is in effect
Chris@10:     \ifeof 1 \else
Chris@10:       \pdfmakeoutlines
Chris@10:     \fi
Chris@10:     \closein 1
Chris@10:   \endgroup
Chris@10:   \lastnegativepageno = \pageno
Chris@10:   \global\pageno = \savepageno
Chris@10: }
Chris@10: 
Chris@10: % And just the chapters.
Chris@10: \def\summarycontents{%
Chris@10:   \startcontents{\putwordShortTOC}%
Chris@10:     %
Chris@10:     \let\partentry = \shortpartentry
Chris@10:     \let\numchapentry = \shortchapentry
Chris@10:     \let\appentry = \shortchapentry
Chris@10:     \let\unnchapentry = \shortunnchapentry
Chris@10:     % We want a true roman here for the page numbers.
Chris@10:     \secfonts
Chris@10:     \let\rm=\shortcontrm \let\bf=\shortcontbf
Chris@10:     \let\sl=\shortcontsl \let\tt=\shortconttt
Chris@10:     \rm
Chris@10:     \hyphenpenalty = 10000
Chris@10:     \advance\baselineskip by 1pt % Open it up a little.
Chris@10:     \def\numsecentry##1##2##3##4{}
Chris@10:     \let\appsecentry = \numsecentry
Chris@10:     \let\unnsecentry = \numsecentry
Chris@10:     \let\numsubsecentry = \numsecentry
Chris@10:     \let\appsubsecentry = \numsecentry
Chris@10:     \let\unnsubsecentry = \numsecentry
Chris@10:     \let\numsubsubsecentry = \numsecentry
Chris@10:     \let\appsubsubsecentry = \numsecentry
Chris@10:     \let\unnsubsubsecentry = \numsecentry
Chris@10:     \openin 1 \tocreadfilename\space
Chris@10:     \ifeof 1 \else
Chris@10:       \readtocfile
Chris@10:     \fi
Chris@10:     \closein 1
Chris@10:     \vfill \eject
Chris@10:     \contentsalignmacro % in case @setchapternewpage odd is in effect
Chris@10:   \endgroup
Chris@10:   \lastnegativepageno = \pageno
Chris@10:   \global\pageno = \savepageno
Chris@10: }
Chris@10: \let\shortcontents = \summarycontents
Chris@10: 
Chris@10: % Typeset the label for a chapter or appendix for the short contents.
Chris@10: % The arg is, e.g., `A' for an appendix, or `3' for a chapter.
Chris@10: %
Chris@10: \def\shortchaplabel#1{%
Chris@10:   % This space should be enough, since a single number is .5em, and the
Chris@10:   % widest letter (M) is 1em, at least in the Computer Modern fonts.
Chris@10:   % But use \hss just in case.
Chris@10:   % (This space doesn't include the extra space that gets added after
Chris@10:   % the label; that gets put in by \shortchapentry above.)
Chris@10:   %
Chris@10:   % We'd like to right-justify chapter numbers, but that looks strange
Chris@10:   % with appendix letters.  And right-justifying numbers and
Chris@10:   % left-justifying letters looks strange when there is less than 10
Chris@10:   % chapters.  Have to read the whole toc once to know how many chapters
Chris@10:   % there are before deciding ...
Chris@10:   \hbox to 1em{#1\hss}%
Chris@10: }
Chris@10: 
Chris@10: % These macros generate individual entries in the table of contents.
Chris@10: % The first argument is the chapter or section name.
Chris@10: % The last argument is the page number.
Chris@10: % The arguments in between are the chapter number, section number, ...
Chris@10: 
Chris@10: % Parts, in the main contents.  Replace the part number, which doesn't
Chris@10: % exist, with an empty box.  Let's hope all the numbers have the same width.
Chris@10: % Also ignore the page number, which is conventionally not printed.
Chris@10: \def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}}
Chris@10: \def\partentry#1#2#3#4{\dochapentry{\numeralbox\labelspace#1}{}}
Chris@10: %
Chris@10: % Parts, in the short toc.
Chris@10: \def\shortpartentry#1#2#3#4{%
Chris@10:   \penalty-300
Chris@10:   \vskip.5\baselineskip plus.15\baselineskip minus.1\baselineskip
Chris@10:   \shortchapentry{{\bf #1}}{\numeralbox}{}{}%
Chris@10: }
Chris@10: 
Chris@10: % Chapters, in the main contents.
Chris@10: \def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}}
Chris@10: %
Chris@10: % Chapters, in the short toc.
Chris@10: % See comments in \dochapentry re vbox and related settings.
Chris@10: \def\shortchapentry#1#2#3#4{%
Chris@10:   \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}%
Chris@10: }
Chris@10: 
Chris@10: % Appendices, in the main contents.
Chris@10: % Need the word Appendix, and a fixed-size box.
Chris@10: %
Chris@10: \def\appendixbox#1{%
Chris@10:   % We use M since it's probably the widest letter.
Chris@10:   \setbox0 = \hbox{\putwordAppendix{} M}%
Chris@10:   \hbox to \wd0{\putwordAppendix{} #1\hss}}
Chris@10: %
Chris@10: \def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\labelspace#1}{#4}}
Chris@10: 
Chris@10: % Unnumbered chapters.
Chris@10: \def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}}
Chris@10: \def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}}
Chris@10: 
Chris@10: % Sections.
Chris@10: \def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}}
Chris@10: \let\appsecentry=\numsecentry
Chris@10: \def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}}
Chris@10: 
Chris@10: % Subsections.
Chris@10: \def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}}
Chris@10: \let\appsubsecentry=\numsubsecentry
Chris@10: \def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}}
Chris@10: 
Chris@10: % And subsubsections.
Chris@10: \def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}}
Chris@10: \let\appsubsubsecentry=\numsubsubsecentry
Chris@10: \def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}}
Chris@10: 
Chris@10: % This parameter controls the indentation of the various levels.
Chris@10: % Same as \defaultparindent.
Chris@10: \newdimen\tocindent \tocindent = 15pt
Chris@10: 
Chris@10: % Now for the actual typesetting. In all these, #1 is the text and #2 is the
Chris@10: % page number.
Chris@10: %
Chris@10: % If the toc has to be broken over pages, we want it to be at chapters
Chris@10: % if at all possible; hence the \penalty.
Chris@10: \def\dochapentry#1#2{%
Chris@10:    \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
Chris@10:    \begingroup
Chris@10:      \chapentryfonts
Chris@10:      \tocentry{#1}{\dopageno\bgroup#2\egroup}%
Chris@10:    \endgroup
Chris@10:    \nobreak\vskip .25\baselineskip plus.1\baselineskip
Chris@10: }
Chris@10: 
Chris@10: \def\dosecentry#1#2{\begingroup
Chris@10:   \secentryfonts \leftskip=\tocindent
Chris@10:   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
Chris@10: \endgroup}
Chris@10: 
Chris@10: \def\dosubsecentry#1#2{\begingroup
Chris@10:   \subsecentryfonts \leftskip=2\tocindent
Chris@10:   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
Chris@10: \endgroup}
Chris@10: 
Chris@10: \def\dosubsubsecentry#1#2{\begingroup
Chris@10:   \subsubsecentryfonts \leftskip=3\tocindent
Chris@10:   \tocentry{#1}{\dopageno\bgroup#2\egroup}%
Chris@10: \endgroup}
Chris@10: 
Chris@10: % We use the same \entry macro as for the index entries.
Chris@10: \let\tocentry = \entry
Chris@10: 
Chris@10: % Space between chapter (or whatever) number and the title.
Chris@10: \def\labelspace{\hskip1em \relax}
Chris@10: 
Chris@10: \def\dopageno#1{{\rm #1}}
Chris@10: \def\doshortpageno#1{{\rm #1}}
Chris@10: 
Chris@10: \def\chapentryfonts{\secfonts \rm}
Chris@10: \def\secentryfonts{\textfonts}
Chris@10: \def\subsecentryfonts{\textfonts}
Chris@10: \def\subsubsecentryfonts{\textfonts}
Chris@10: 
Chris@10: 
Chris@10: \message{environments,}
Chris@10: % @foo ... @end foo.
Chris@10: 
Chris@10: % @tex ... @end tex    escapes into raw TeX temporarily.
Chris@10: % One exception: @ is still an escape character, so that @end tex works.
Chris@10: % But \@ or @@ will get a plain @ character.
Chris@10: 
Chris@10: \envdef\tex{%
Chris@10:   \setupmarkupstyle{tex}%
Chris@10:   \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
Chris@10:   \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
Chris@10:   \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
Chris@10:   \catcode `\%=14
Chris@10:   \catcode `\+=\other
Chris@10:   \catcode `\"=\other
Chris@10:   \catcode `\|=\other
Chris@10:   \catcode `\<=\other
Chris@10:   \catcode `\>=\other
Chris@10:   \catcode`\`=\other
Chris@10:   \catcode`\'=\other
Chris@10:   \escapechar=`\\
Chris@10:   %
Chris@10:   % ' is active in math mode (mathcode"8000).  So reset it, and all our
Chris@10:   % other math active characters (just in case), to plain's definitions.
Chris@10:   \mathactive
Chris@10:   %
Chris@10:   \let\b=\ptexb
Chris@10:   \let\bullet=\ptexbullet
Chris@10:   \let\c=\ptexc
Chris@10:   \let\,=\ptexcomma
Chris@10:   \let\.=\ptexdot
Chris@10:   \let\dots=\ptexdots
Chris@10:   \let\equiv=\ptexequiv
Chris@10:   \let\!=\ptexexclam
Chris@10:   \let\i=\ptexi
Chris@10:   \let\indent=\ptexindent
Chris@10:   \let\noindent=\ptexnoindent
Chris@10:   \let\{=\ptexlbrace
Chris@10:   \let\+=\tabalign
Chris@10:   \let\}=\ptexrbrace
Chris@10:   \let\/=\ptexslash
Chris@10:   \let\*=\ptexstar
Chris@10:   \let\t=\ptext
Chris@10:   \expandafter \let\csname top\endcsname=\ptextop  % outer
Chris@10:   \let\frenchspacing=\plainfrenchspacing
Chris@10:   %
Chris@10:   \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
Chris@10:   \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
Chris@10:   \def\@{@}%
Chris@10: }
Chris@10: % There is no need to define \Etex.
Chris@10: 
Chris@10: % Define @lisp ... @end lisp.
Chris@10: % @lisp environment forms a group so it can rebind things,
Chris@10: % including the definition of @end lisp (which normally is erroneous).
Chris@10: 
Chris@10: % Amount to narrow the margins by for @lisp.
Chris@10: \newskip\lispnarrowing \lispnarrowing=0.4in
Chris@10: 
Chris@10: % This is the definition that ^^M gets inside @lisp, @example, and other
Chris@10: % such environments.  \null is better than a space, since it doesn't
Chris@10: % have any width.
Chris@10: \def\lisppar{\null\endgraf}
Chris@10: 
Chris@10: % This space is always present above and below environments.
Chris@10: \newskip\envskipamount \envskipamount = 0pt
Chris@10: 
Chris@10: % Make spacing and below environment symmetrical.  We use \parskip here
Chris@10: % to help in doing that, since in @example-like environments \parskip
Chris@10: % is reset to zero; thus the \afterenvbreak inserts no space -- but the
Chris@10: % start of the next paragraph will insert \parskip.
Chris@10: %
Chris@10: \def\aboveenvbreak{{%
Chris@10:   % =10000 instead of <10000 because of a special case in \itemzzz and
Chris@10:   % \sectionheading, q.v.
Chris@10:   \ifnum \lastpenalty=10000 \else
Chris@10:     \advance\envskipamount by \parskip
Chris@10:     \endgraf
Chris@10:     \ifdim\lastskip<\envskipamount
Chris@10:       \removelastskip
Chris@10:       % it's not a good place to break if the last penalty was \nobreak
Chris@10:       % or better ...
Chris@10:       \ifnum\lastpenalty<10000 \penalty-50 \fi
Chris@10:       \vskip\envskipamount
Chris@10:     \fi
Chris@10:   \fi
Chris@10: }}
Chris@10: 
Chris@10: \let\afterenvbreak = \aboveenvbreak
Chris@10: 
Chris@10: % \nonarrowing is a flag.  If "set", @lisp etc don't narrow margins; it will
Chris@10: % also clear it, so that its embedded environments do the narrowing again.
Chris@10: \let\nonarrowing=\relax
Chris@10: 
Chris@10: % @cartouche ... @end cartouche: draw rectangle w/rounded corners around
Chris@10: % environment contents.
Chris@10: \font\circle=lcircle10
Chris@10: \newdimen\circthick
Chris@10: \newdimen\cartouter\newdimen\cartinner
Chris@10: \newskip\normbskip\newskip\normpskip\newskip\normlskip
Chris@10: \circthick=\fontdimen8\circle
Chris@10: %
Chris@10: \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
Chris@10: \def\ctr{{\hskip 6pt\circle\char'010}}
Chris@10: \def\cbl{{\circle\char'012\hskip -6pt}}
Chris@10: \def\cbr{{\hskip 6pt\circle\char'011}}
Chris@10: \def\carttop{\hbox to \cartouter{\hskip\lskip
Chris@10:         \ctl\leaders\hrule height\circthick\hfil\ctr
Chris@10:         \hskip\rskip}}
Chris@10: \def\cartbot{\hbox to \cartouter{\hskip\lskip
Chris@10:         \cbl\leaders\hrule height\circthick\hfil\cbr
Chris@10:         \hskip\rskip}}
Chris@10: %
Chris@10: \newskip\lskip\newskip\rskip
Chris@10: 
Chris@10: \envdef\cartouche{%
Chris@10:   \ifhmode\par\fi  % can't be in the midst of a paragraph.
Chris@10:   \startsavinginserts
Chris@10:   \lskip=\leftskip \rskip=\rightskip
Chris@10:   \leftskip=0pt\rightskip=0pt % we want these *outside*.
Chris@10:   \cartinner=\hsize \advance\cartinner by-\lskip
Chris@10:   \advance\cartinner by-\rskip
Chris@10:   \cartouter=\hsize
Chris@10:   \advance\cartouter by 18.4pt	% allow for 3pt kerns on either
Chris@10: 				% side, and for 6pt waste from
Chris@10: 				% each corner char, and rule thickness
Chris@10:   \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
Chris@10:   % Flag to tell @lisp, etc., not to narrow margin.
Chris@10:   \let\nonarrowing = t%
Chris@10:   %
Chris@10:   % If this cartouche directly follows a sectioning command, we need the
Chris@10:   % \parskip glue (backspaced over by default) or the cartouche can
Chris@10:   % collide with the section heading.
Chris@10:   \ifnum\lastpenalty>10000 \vskip\parskip \penalty\lastpenalty \fi
Chris@10:   %
Chris@10:   \vbox\bgroup
Chris@10:       \baselineskip=0pt\parskip=0pt\lineskip=0pt
Chris@10:       \carttop
Chris@10:       \hbox\bgroup
Chris@10: 	  \hskip\lskip
Chris@10: 	  \vrule\kern3pt
Chris@10: 	  \vbox\bgroup
Chris@10: 	      \kern3pt
Chris@10: 	      \hsize=\cartinner
Chris@10: 	      \baselineskip=\normbskip
Chris@10: 	      \lineskip=\normlskip
Chris@10: 	      \parskip=\normpskip
Chris@10: 	      \vskip -\parskip
Chris@10: 	      \comment % For explanation, see the end of def\group.
Chris@10: }
Chris@10: \def\Ecartouche{%
Chris@10:               \ifhmode\par\fi
Chris@10: 	      \kern3pt
Chris@10: 	  \egroup
Chris@10: 	  \kern3pt\vrule
Chris@10: 	  \hskip\rskip
Chris@10:       \egroup
Chris@10:       \cartbot
Chris@10:   \egroup
Chris@10:   \checkinserts
Chris@10: }
Chris@10: 
Chris@10: 
Chris@10: % This macro is called at the beginning of all the @example variants,
Chris@10: % inside a group.
Chris@10: \newdimen\nonfillparindent
Chris@10: \def\nonfillstart{%
Chris@10:   \aboveenvbreak
Chris@10:   \hfuzz = 12pt % Don't be fussy
Chris@10:   \sepspaces % Make spaces be word-separators rather than space tokens.
Chris@10:   \let\par = \lisppar % don't ignore blank lines
Chris@10:   \obeylines % each line of input is a line of output
Chris@10:   \parskip = 0pt
Chris@10:   % Turn off paragraph indentation but redefine \indent to emulate
Chris@10:   % the normal \indent.
Chris@10:   \nonfillparindent=\parindent
Chris@10:   \parindent = 0pt
Chris@10:   \let\indent\nonfillindent
Chris@10:   %
Chris@10:   \emergencystretch = 0pt % don't try to avoid overfull boxes
Chris@10:   \ifx\nonarrowing\relax
Chris@10:     \advance \leftskip by \lispnarrowing
Chris@10:     \exdentamount=\lispnarrowing
Chris@10:   \else
Chris@10:     \let\nonarrowing = \relax
Chris@10:   \fi
Chris@10:   \let\exdent=\nofillexdent
Chris@10: }
Chris@10: 
Chris@10: \begingroup
Chris@10: \obeyspaces
Chris@10: % We want to swallow spaces (but not other tokens) after the fake
Chris@10: % @indent in our nonfill-environments, where spaces are normally
Chris@10: % active and set to @tie, resulting in them not being ignored after
Chris@10: % @indent.
Chris@10: \gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}%
Chris@10: \gdef\nonfillindentcheck{%
Chris@10: \ifx\temp %
Chris@10: \expandafter\nonfillindentgobble%
Chris@10: \else%
Chris@10: \leavevmode\nonfillindentbox%
Chris@10: \fi%
Chris@10: }%
Chris@10: \endgroup
Chris@10: \def\nonfillindentgobble#1{\nonfillindent}
Chris@10: \def\nonfillindentbox{\hbox to \nonfillparindent{\hss}}
Chris@10: 
Chris@10: % If you want all examples etc. small: @set dispenvsize small.
Chris@10: % If you want even small examples the full size: @set dispenvsize nosmall.
Chris@10: % This affects the following displayed environments:
Chris@10: %    @example, @display, @format, @lisp
Chris@10: %
Chris@10: \def\smallword{small}
Chris@10: \def\nosmallword{nosmall}
Chris@10: \let\SETdispenvsize\relax
Chris@10: \def\setnormaldispenv{%
Chris@10:   \ifx\SETdispenvsize\smallword
Chris@10:     % end paragraph for sake of leading, in case document has no blank
Chris@10:     % line.  This is redundant with what happens in \aboveenvbreak, but
Chris@10:     % we need to do it before changing the fonts, and it's inconvenient
Chris@10:     % to change the fonts afterward.
Chris@10:     \ifnum \lastpenalty=10000 \else \endgraf \fi
Chris@10:     \smallexamplefonts \rm
Chris@10:   \fi
Chris@10: }
Chris@10: \def\setsmalldispenv{%
Chris@10:   \ifx\SETdispenvsize\nosmallword
Chris@10:   \else
Chris@10:     \ifnum \lastpenalty=10000 \else \endgraf \fi
Chris@10:     \smallexamplefonts \rm
Chris@10:   \fi
Chris@10: }
Chris@10: 
Chris@10: % We often define two environments, @foo and @smallfoo.
Chris@10: % Let's do it in one command.  #1 is the env name, #2 the definition.
Chris@10: \def\makedispenvdef#1#2{%
Chris@10:   \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}%
Chris@10:   \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}%
Chris@10:   \expandafter\let\csname E#1\endcsname \afterenvbreak
Chris@10:   \expandafter\let\csname Esmall#1\endcsname \afterenvbreak
Chris@10: }
Chris@10: 
Chris@10: % Define two environment synonyms (#1 and #2) for an environment.
Chris@10: \def\maketwodispenvdef#1#2#3{%
Chris@10:   \makedispenvdef{#1}{#3}%
Chris@10:   \makedispenvdef{#2}{#3}%
Chris@10: }
Chris@10: %
Chris@10: % @lisp: indented, narrowed, typewriter font;
Chris@10: % @example: same as @lisp.
Chris@10: %
Chris@10: % @smallexample and @smalllisp: use smaller fonts.
Chris@10: % Originally contributed by Pavel@xerox.
Chris@10: %
Chris@10: \maketwodispenvdef{lisp}{example}{%
Chris@10:   \nonfillstart
Chris@10:   \tt\setupmarkupstyle{example}%
Chris@10:   \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
Chris@10:   \gobble % eat return
Chris@10: }
Chris@10: % @display/@smalldisplay: same as @lisp except keep current font.
Chris@10: %
Chris@10: \makedispenvdef{display}{%
Chris@10:   \nonfillstart
Chris@10:   \gobble
Chris@10: }
Chris@10: 
Chris@10: % @format/@smallformat: same as @display except don't narrow margins.
Chris@10: %
Chris@10: \makedispenvdef{format}{%
Chris@10:   \let\nonarrowing = t%
Chris@10:   \nonfillstart
Chris@10:   \gobble
Chris@10: }
Chris@10: 
Chris@10: % @flushleft: same as @format, but doesn't obey \SETdispenvsize.
Chris@10: \envdef\flushleft{%
Chris@10:   \let\nonarrowing = t%
Chris@10:   \nonfillstart
Chris@10:   \gobble
Chris@10: }
Chris@10: \let\Eflushleft = \afterenvbreak
Chris@10: 
Chris@10: % @flushright.
Chris@10: %
Chris@10: \envdef\flushright{%
Chris@10:   \let\nonarrowing = t%
Chris@10:   \nonfillstart
Chris@10:   \advance\leftskip by 0pt plus 1fill\relax
Chris@10:   \gobble
Chris@10: }
Chris@10: \let\Eflushright = \afterenvbreak
Chris@10: 
Chris@10: 
Chris@10: % @raggedright does more-or-less normal line breaking but no right
Chris@10: % justification.  From plain.tex.
Chris@10: \envdef\raggedright{%
Chris@10:   \rightskip0pt plus2em \spaceskip.3333em \xspaceskip.5em\relax
Chris@10: }
Chris@10: \let\Eraggedright\par
Chris@10: 
Chris@10: \envdef\raggedleft{%
Chris@10:   \parindent=0pt \leftskip0pt plus2em
Chris@10:   \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
Chris@10:   \hbadness=10000 % Last line will usually be underfull, so turn off
Chris@10:                   % badness reporting.
Chris@10: }
Chris@10: \let\Eraggedleft\par
Chris@10: 
Chris@10: \envdef\raggedcenter{%
Chris@10:   \parindent=0pt \rightskip0pt plus1em \leftskip0pt plus1em
Chris@10:   \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
Chris@10:   \hbadness=10000 % Last line will usually be underfull, so turn off
Chris@10:                   % badness reporting.
Chris@10: }
Chris@10: \let\Eraggedcenter\par
Chris@10: 
Chris@10: 
Chris@10: % @quotation does normal linebreaking (hence we can't use \nonfillstart)
Chris@10: % and narrows the margins.  We keep \parskip nonzero in general, since
Chris@10: % we're doing normal filling.  So, when using \aboveenvbreak and
Chris@10: % \afterenvbreak, temporarily make \parskip 0.
Chris@10: %
Chris@10: \makedispenvdef{quotation}{\quotationstart}
Chris@10: %
Chris@10: \def\quotationstart{%
Chris@10:   {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
Chris@10:   \parindent=0pt
Chris@10:   %
Chris@10:   % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
Chris@10:   \ifx\nonarrowing\relax
Chris@10:     \advance\leftskip by \lispnarrowing
Chris@10:     \advance\rightskip by \lispnarrowing
Chris@10:     \exdentamount = \lispnarrowing
Chris@10:   \else
Chris@10:     \let\nonarrowing = \relax
Chris@10:   \fi
Chris@10:   \parsearg\quotationlabel
Chris@10: }
Chris@10: 
Chris@10: % We have retained a nonzero parskip for the environment, since we're
Chris@10: % doing normal filling.
Chris@10: %
Chris@10: \def\Equotation{%
Chris@10:   \par
Chris@10:   \ifx\quotationauthor\thisisundefined\else
Chris@10:     % indent a bit.
Chris@10:     \leftline{\kern 2\leftskip \sl ---\quotationauthor}%
Chris@10:   \fi
Chris@10:   {\parskip=0pt \afterenvbreak}%
Chris@10: }
Chris@10: \def\Esmallquotation{\Equotation}
Chris@10: 
Chris@10: % If we're given an argument, typeset it in bold with a colon after.
Chris@10: \def\quotationlabel#1{%
Chris@10:   \def\temp{#1}%
Chris@10:   \ifx\temp\empty \else
Chris@10:     {\bf #1: }%
Chris@10:   \fi
Chris@10: }
Chris@10: 
Chris@10: 
Chris@10: % LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>}
Chris@10: % If we want to allow any <char> as delimiter,
Chris@10: % we need the curly braces so that makeinfo sees the @verb command, eg:
Chris@10: % `@verbx...x' would look like the '@verbx' command.  --janneke@gnu.org
Chris@10: %
Chris@10: % [Knuth]: Donald Ervin Knuth, 1996.  The TeXbook.
Chris@10: %
Chris@10: % [Knuth] p.344; only we need to do the other characters Texinfo sets
Chris@10: % active too.  Otherwise, they get lost as the first character on a
Chris@10: % verbatim line.
Chris@10: \def\dospecials{%
Chris@10:   \do\ \do\\\do\{\do\}\do\$\do\&%
Chris@10:   \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~%
Chris@10:   \do\<\do\>\do\|\do\@\do+\do\"%
Chris@10:   % Don't do the quotes -- if we do, @set txicodequoteundirected and
Chris@10:   % @set txicodequotebacktick will not have effect on @verb and
Chris@10:   % @verbatim, and ?` and !` ligatures won't get disabled.
Chris@10:   %\do\`\do\'%
Chris@10: }
Chris@10: %
Chris@10: % [Knuth] p. 380
Chris@10: \def\uncatcodespecials{%
Chris@10:   \def\do##1{\catcode`##1=\other}\dospecials}
Chris@10: %
Chris@10: % Setup for the @verb command.
Chris@10: %
Chris@10: % Eight spaces for a tab
Chris@10: \begingroup
Chris@10:   \catcode`\^^I=\active
Chris@10:   \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }}
Chris@10: \endgroup
Chris@10: %
Chris@10: \def\setupverb{%
Chris@10:   \tt  % easiest (and conventionally used) font for verbatim
Chris@10:   \def\par{\leavevmode\endgraf}%
Chris@10:   \setupmarkupstyle{verb}%
Chris@10:   \tabeightspaces
Chris@10:   % Respect line breaks,
Chris@10:   % print special symbols as themselves, and
Chris@10:   % make each space count
Chris@10:   % must do in this order:
Chris@10:   \obeylines \uncatcodespecials \sepspaces
Chris@10: }
Chris@10: 
Chris@10: % Setup for the @verbatim environment
Chris@10: %
Chris@10: % Real tab expansion.
Chris@10: \newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
Chris@10: %
Chris@10: % We typeset each line of the verbatim in an \hbox, so we can handle
Chris@10: % tabs.  The \global is in case the verbatim line starts with an accent,
Chris@10: % or some other command that starts with a begin-group.  Otherwise, the
Chris@10: % entire \verbbox would disappear at the corresponding end-group, before
Chris@10: % it is typeset.  Meanwhile, we can't have nested verbatim commands
Chris@10: % (can we?), so the \global won't be overwriting itself.
Chris@10: \newbox\verbbox
Chris@10: \def\starttabbox{\global\setbox\verbbox=\hbox\bgroup}
Chris@10: %
Chris@10: \begingroup
Chris@10:   \catcode`\^^I=\active
Chris@10:   \gdef\tabexpand{%
Chris@10:     \catcode`\^^I=\active
Chris@10:     \def^^I{\leavevmode\egroup
Chris@10:       \dimen\verbbox=\wd\verbbox % the width so far, or since the previous tab
Chris@10:       \divide\dimen\verbbox by\tabw
Chris@10:       \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw
Chris@10:       \advance\dimen\verbbox by\tabw  % advance to next multiple of \tabw
Chris@10:       \wd\verbbox=\dimen\verbbox \box\verbbox \starttabbox
Chris@10:     }%
Chris@10:   }
Chris@10: \endgroup
Chris@10: 
Chris@10: % start the verbatim environment.
Chris@10: \def\setupverbatim{%
Chris@10:   \let\nonarrowing = t%
Chris@10:   \nonfillstart
Chris@10:   \tt % easiest (and conventionally used) font for verbatim
Chris@10:   % The \leavevmode here is for blank lines.  Otherwise, we would
Chris@10:   % never \starttabox and the \egroup would end verbatim mode.
Chris@10:   \def\par{\leavevmode\egroup\box\verbbox\endgraf}%
Chris@10:   \tabexpand
Chris@10:   \setupmarkupstyle{verbatim}%
Chris@10:   % Respect line breaks,
Chris@10:   % print special symbols as themselves, and
Chris@10:   % make each space count.
Chris@10:   % Must do in this order:
Chris@10:   \obeylines \uncatcodespecials \sepspaces
Chris@10:   \everypar{\starttabbox}%
Chris@10: }
Chris@10: 
Chris@10: % Do the @verb magic: verbatim text is quoted by unique
Chris@10: % delimiter characters.  Before first delimiter expect a
Chris@10: % right brace, after last delimiter expect closing brace:
Chris@10: %
Chris@10: %    \def\doverb'{'<char>#1<char>'}'{#1}
Chris@10: %
Chris@10: % [Knuth] p. 382; only eat outer {}
Chris@10: \begingroup
Chris@10:   \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other
Chris@10:   \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next]
Chris@10: \endgroup
Chris@10: %
Chris@10: \def\verb{\begingroup\setupverb\doverb}
Chris@10: %
Chris@10: %
Chris@10: % Do the @verbatim magic: define the macro \doverbatim so that
Chris@10: % the (first) argument ends when '@end verbatim' is reached, ie:
Chris@10: %
Chris@10: %     \def\doverbatim#1@end verbatim{#1}
Chris@10: %
Chris@10: % For Texinfo it's a lot easier than for LaTeX,
Chris@10: % because texinfo's \verbatim doesn't stop at '\end{verbatim}':
Chris@10: % we need not redefine '\', '{' and '}'.
Chris@10: %
Chris@10: % Inspired by LaTeX's verbatim command set [latex.ltx]
Chris@10: %
Chris@10: \begingroup
Chris@10:   \catcode`\ =\active
Chris@10:   \obeylines %
Chris@10:   % ignore everything up to the first ^^M, that's the newline at the end
Chris@10:   % of the @verbatim input line itself.  Otherwise we get an extra blank
Chris@10:   % line in the output.
Chris@10:   \xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}%
Chris@10:   % We really want {...\end verbatim} in the body of the macro, but
Chris@10:   % without the active space; thus we have to use \xdef and \gobble.
Chris@10: \endgroup
Chris@10: %
Chris@10: \envdef\verbatim{%
Chris@10:     \setupverbatim\doverbatim
Chris@10: }
Chris@10: \let\Everbatim = \afterenvbreak
Chris@10: 
Chris@10: 
Chris@10: % @verbatiminclude FILE - insert text of file in verbatim environment.
Chris@10: %
Chris@10: \def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude}
Chris@10: %
Chris@10: \def\doverbatiminclude#1{%
Chris@10:   {%
Chris@10:     \makevalueexpandable
Chris@10:     \setupverbatim
Chris@10:     \indexnofonts       % Allow `@@' and other weird things in file names.
Chris@10:     \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}%
Chris@10:     \input #1
Chris@10:     \afterenvbreak
Chris@10:   }%
Chris@10: }
Chris@10: 
Chris@10: % @copying ... @end copying.
Chris@10: % Save the text away for @insertcopying later.
Chris@10: %
Chris@10: % We save the uninterpreted tokens, rather than creating a box.
Chris@10: % Saving the text in a box would be much easier, but then all the
Chris@10: % typesetting commands (@smallbook, font changes, etc.) have to be done
Chris@10: % beforehand -- and a) we want @copying to be done first in the source
Chris@10: % file; b) letting users define the frontmatter in as flexible order as
Chris@10: % possible is very desirable.
Chris@10: %
Chris@10: \def\copying{\checkenv{}\begingroup\scanargctxt\docopying}
Chris@10: \def\docopying#1@end copying{\endgroup\def\copyingtext{#1}}
Chris@10: %
Chris@10: \def\insertcopying{%
Chris@10:   \begingroup
Chris@10:     \parindent = 0pt  % paragraph indentation looks wrong on title page
Chris@10:     \scanexp\copyingtext
Chris@10:   \endgroup
Chris@10: }
Chris@10: 
Chris@10: 
Chris@10: \message{defuns,}
Chris@10: % @defun etc.
Chris@10: 
Chris@10: \newskip\defbodyindent \defbodyindent=.4in
Chris@10: \newskip\defargsindent \defargsindent=50pt
Chris@10: \newskip\deflastargmargin \deflastargmargin=18pt
Chris@10: \newcount\defunpenalty
Chris@10: 
Chris@10: % Start the processing of @deffn:
Chris@10: \def\startdefun{%
Chris@10:   \ifnum\lastpenalty<10000
Chris@10:     \medbreak
Chris@10:     \defunpenalty=10003 % Will keep this @deffn together with the
Chris@10:                         % following @def command, see below.
Chris@10:   \else
Chris@10:     % If there are two @def commands in a row, we'll have a \nobreak,
Chris@10:     % which is there to keep the function description together with its
Chris@10:     % header.  But if there's nothing but headers, we need to allow a
Chris@10:     % break somewhere.  Check specifically for penalty 10002, inserted
Chris@10:     % by \printdefunline, instead of 10000, since the sectioning
Chris@10:     % commands also insert a nobreak penalty, and we don't want to allow
Chris@10:     % a break between a section heading and a defun.
Chris@10:     %
Chris@10:     % As a further refinement, we avoid "club" headers by signalling
Chris@10:     % with penalty of 10003 after the very first @deffn in the
Chris@10:     % sequence (see above), and penalty of 10002 after any following
Chris@10:     % @def command.
Chris@10:     \ifnum\lastpenalty=10002 \penalty2000 \else \defunpenalty=10002 \fi
Chris@10:     %
Chris@10:     % Similarly, after a section heading, do not allow a break.
Chris@10:     % But do insert the glue.
Chris@10:     \medskip  % preceded by discardable penalty, so not a breakpoint
Chris@10:   \fi
Chris@10:   %
Chris@10:   \parindent=0in
Chris@10:   \advance\leftskip by \defbodyindent
Chris@10:   \exdentamount=\defbodyindent
Chris@10: }
Chris@10: 
Chris@10: \def\dodefunx#1{%
Chris@10:   % First, check whether we are in the right environment:
Chris@10:   \checkenv#1%
Chris@10:   %
Chris@10:   % As above, allow line break if we have multiple x headers in a row.
Chris@10:   % It's not a great place, though.
Chris@10:   \ifnum\lastpenalty=10002 \penalty3000 \else \defunpenalty=10002 \fi
Chris@10:   %
Chris@10:   % And now, it's time to reuse the body of the original defun:
Chris@10:   \expandafter\gobbledefun#1%
Chris@10: }
Chris@10: \def\gobbledefun#1\startdefun{}
Chris@10: 
Chris@10: % \printdefunline \deffnheader{text}
Chris@10: %
Chris@10: \def\printdefunline#1#2{%
Chris@10:   \begingroup
Chris@10:     % call \deffnheader:
Chris@10:     #1#2 \endheader
Chris@10:     % common ending:
Chris@10:     \interlinepenalty = 10000
Chris@10:     \advance\rightskip by 0pt plus 1fil\relax
Chris@10:     \endgraf
Chris@10:     \nobreak\vskip -\parskip
Chris@10:     \penalty\defunpenalty  % signal to \startdefun and \dodefunx
Chris@10:     % Some of the @defun-type tags do not enable magic parentheses,
Chris@10:     % rendering the following check redundant.  But we don't optimize.
Chris@10:     \checkparencounts
Chris@10:   \endgroup
Chris@10: }
Chris@10: 
Chris@10: \def\Edefun{\endgraf\medbreak}
Chris@10: 
Chris@10: % \makedefun{deffn} creates \deffn, \deffnx and \Edeffn;
Chris@10: % the only thing remaining is to define \deffnheader.
Chris@10: %
Chris@10: \def\makedefun#1{%
Chris@10:   \expandafter\let\csname E#1\endcsname = \Edefun
Chris@10:   \edef\temp{\noexpand\domakedefun
Chris@10:     \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}%
Chris@10:   \temp
Chris@10: }
Chris@10: 
Chris@10: % \domakedefun \deffn \deffnx \deffnheader
Chris@10: %
Chris@10: % Define \deffn and \deffnx, without parameters.
Chris@10: % \deffnheader has to be defined explicitly.
Chris@10: %
Chris@10: \def\domakedefun#1#2#3{%
Chris@10:   \envdef#1{%
Chris@10:     \startdefun
Chris@10:     \doingtypefnfalse    % distinguish typed functions from all else
Chris@10:     \parseargusing\activeparens{\printdefunline#3}%
Chris@10:   }%
Chris@10:   \def#2{\dodefunx#1}%
Chris@10:   \def#3%
Chris@10: }
Chris@10: 
Chris@10: \newif\ifdoingtypefn       % doing typed function?
Chris@10: \newif\ifrettypeownline    % typeset return type on its own line?
Chris@10: 
Chris@10: % @deftypefnnewline on|off says whether the return type of typed functions
Chris@10: % are printed on their own line.  This affects @deftypefn, @deftypefun,
Chris@10: % @deftypeop, and @deftypemethod.
Chris@10: % 
Chris@10: \parseargdef\deftypefnnewline{%
Chris@10:   \def\temp{#1}%
Chris@10:   \ifx\temp\onword
Chris@10:     \expandafter\let\csname SETtxideftypefnnl\endcsname
Chris@10:       = \empty
Chris@10:   \else\ifx\temp\offword
Chris@10:     \expandafter\let\csname SETtxideftypefnnl\endcsname
Chris@10:       = \relax
Chris@10:   \else
Chris@10:     \errhelp = \EMsimple
Chris@10:     \errmessage{Unknown @txideftypefnnl value `\temp',
Chris@10:                 must be on|off}%
Chris@10:   \fi\fi
Chris@10: }
Chris@10: 
Chris@10: % Untyped functions:
Chris@10: 
Chris@10: % @deffn category name args
Chris@10: \makedefun{deffn}{\deffngeneral{}}
Chris@10: 
Chris@10: % @deffn category class name args
Chris@10: \makedefun{defop}#1 {\defopon{#1\ \putwordon}}
Chris@10: 
Chris@10: % \defopon {category on}class name args
Chris@10: \def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
Chris@10: 
Chris@10: % \deffngeneral {subind}category name args
Chris@10: %
Chris@10: \def\deffngeneral#1#2 #3 #4\endheader{%
Chris@10:   % Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}.
Chris@10:   \dosubind{fn}{\code{#3}}{#1}%
Chris@10:   \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
Chris@10: }
Chris@10: 
Chris@10: % Typed functions:
Chris@10: 
Chris@10: % @deftypefn category type name args
Chris@10: \makedefun{deftypefn}{\deftypefngeneral{}}
Chris@10: 
Chris@10: % @deftypeop category class type name args
Chris@10: \makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}}
Chris@10: 
Chris@10: % \deftypeopon {category on}class type name args
Chris@10: \def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
Chris@10: 
Chris@10: % \deftypefngeneral {subind}category type name args
Chris@10: %
Chris@10: \def\deftypefngeneral#1#2 #3 #4 #5\endheader{%
Chris@10:   \dosubind{fn}{\code{#4}}{#1}%
Chris@10:   \doingtypefntrue
Chris@10:   \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
Chris@10: }
Chris@10: 
Chris@10: % Typed variables:
Chris@10: 
Chris@10: % @deftypevr category type var args
Chris@10: \makedefun{deftypevr}{\deftypecvgeneral{}}
Chris@10: 
Chris@10: % @deftypecv category class type var args
Chris@10: \makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}}
Chris@10: 
Chris@10: % \deftypecvof {category of}class type var args
Chris@10: \def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} }
Chris@10: 
Chris@10: % \deftypecvgeneral {subind}category type var args
Chris@10: %
Chris@10: \def\deftypecvgeneral#1#2 #3 #4 #5\endheader{%
Chris@10:   \dosubind{vr}{\code{#4}}{#1}%
Chris@10:   \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
Chris@10: }
Chris@10: 
Chris@10: % Untyped variables:
Chris@10: 
Chris@10: % @defvr category var args
Chris@10: \makedefun{defvr}#1 {\deftypevrheader{#1} {} }
Chris@10: 
Chris@10: % @defcv category class var args
Chris@10: \makedefun{defcv}#1 {\defcvof{#1\ \putwordof}}
Chris@10: 
Chris@10: % \defcvof {category of}class var args
Chris@10: \def\defcvof#1#2 {\deftypecvof{#1}#2 {} }
Chris@10: 
Chris@10: % Types:
Chris@10: 
Chris@10: % @deftp category name args
Chris@10: \makedefun{deftp}#1 #2 #3\endheader{%
Chris@10:   \doind{tp}{\code{#2}}%
Chris@10:   \defname{#1}{}{#2}\defunargs{#3\unskip}%
Chris@10: }
Chris@10: 
Chris@10: % Remaining @defun-like shortcuts:
Chris@10: \makedefun{defun}{\deffnheader{\putwordDeffunc} }
Chris@10: \makedefun{defmac}{\deffnheader{\putwordDefmac} }
Chris@10: \makedefun{defspec}{\deffnheader{\putwordDefspec} }
Chris@10: \makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} }
Chris@10: \makedefun{defvar}{\defvrheader{\putwordDefvar} }
Chris@10: \makedefun{defopt}{\defvrheader{\putwordDefopt} }
Chris@10: \makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} }
Chris@10: \makedefun{defmethod}{\defopon\putwordMethodon}
Chris@10: \makedefun{deftypemethod}{\deftypeopon\putwordMethodon}
Chris@10: \makedefun{defivar}{\defcvof\putwordInstanceVariableof}
Chris@10: \makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof}
Chris@10: 
Chris@10: % \defname, which formats the name of the @def (not the args).
Chris@10: % #1 is the category, such as "Function".
Chris@10: % #2 is the return type, if any.
Chris@10: % #3 is the function name.
Chris@10: %
Chris@10: % We are followed by (but not passed) the arguments, if any.
Chris@10: %
Chris@10: \def\defname#1#2#3{%
Chris@10:   \par
Chris@10:   % Get the values of \leftskip and \rightskip as they were outside the @def...
Chris@10:   \advance\leftskip by -\defbodyindent
Chris@10:   %
Chris@10:   % Determine if we are typesetting the return type of a typed function
Chris@10:   % on a line by itself.
Chris@10:   \rettypeownlinefalse
Chris@10:   \ifdoingtypefn  % doing a typed function specifically?
Chris@10:     % then check user option for putting return type on its own line:
Chris@10:     \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else
Chris@10:       \rettypeownlinetrue
Chris@10:     \fi
Chris@10:   \fi
Chris@10:   %
Chris@10:   % How we'll format the category name.  Putting it in brackets helps
Chris@10:   % distinguish it from the body text that may end up on the next line
Chris@10:   % just below it.
Chris@10:   \def\temp{#1}%
Chris@10:   \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
Chris@10:   %
Chris@10:   % Figure out line sizes for the paragraph shape.  We'll always have at
Chris@10:   % least two.
Chris@10:   \tempnum = 2
Chris@10:   %
Chris@10:   % The first line needs space for \box0; but if \rightskip is nonzero,
Chris@10:   % we need only space for the part of \box0 which exceeds it:
Chris@10:   \dimen0=\hsize  \advance\dimen0 by -\wd0  \advance\dimen0 by \rightskip
Chris@10:   %
Chris@10:   % If doing a return type on its own line, we'll have another line.
Chris@10:   \ifrettypeownline
Chris@10:     \advance\tempnum by 1
Chris@10:     \def\maybeshapeline{0in \hsize}%
Chris@10:   \else
Chris@10:     \def\maybeshapeline{}%
Chris@10:   \fi
Chris@10:   %
Chris@10:   % The continuations:
Chris@10:   \dimen2=\hsize  \advance\dimen2 by -\defargsindent
Chris@10:   %
Chris@10:   % The final paragraph shape:
Chris@10:   \parshape \tempnum  0in \dimen0  \maybeshapeline  \defargsindent \dimen2
Chris@10:   %
Chris@10:   % Put the category name at the right margin.
Chris@10:   \noindent
Chris@10:   \hbox to 0pt{%
Chris@10:     \hfil\box0 \kern-\hsize
Chris@10:     % \hsize has to be shortened this way:
Chris@10:     \kern\leftskip
Chris@10:     % Intentionally do not respect \rightskip, since we need the space.
Chris@10:   }%
Chris@10:   %
Chris@10:   % Allow all lines to be underfull without complaint:
Chris@10:   \tolerance=10000 \hbadness=10000
Chris@10:   \exdentamount=\defbodyindent
Chris@10:   {%
Chris@10:     % defun fonts. We use typewriter by default (used to be bold) because:
Chris@10:     % . we're printing identifiers, they should be in tt in principle.
Chris@10:     % . in languages with many accents, such as Czech or French, it's
Chris@10:     %   common to leave accents off identifiers.  The result looks ok in
Chris@10:     %   tt, but exceedingly strange in rm.
Chris@10:     % . we don't want -- and --- to be treated as ligatures.
Chris@10:     % . this still does not fix the ?` and !` ligatures, but so far no
Chris@10:     %   one has made identifiers using them :).
Chris@10:     \df \tt
Chris@10:     \def\temp{#2}% text of the return type
Chris@10:     \ifx\temp\empty\else
Chris@10:       \tclose{\temp}% typeset the return type
Chris@10:       \ifrettypeownline
Chris@10:         % put return type on its own line; prohibit line break following:
Chris@10:         \hfil\vadjust{\nobreak}\break  
Chris@10:       \else
Chris@10:         \space  % type on same line, so just followed by a space
Chris@10:       \fi
Chris@10:     \fi           % no return type
Chris@10:     #3% output function name
Chris@10:   }%
Chris@10:   {\rm\enskip}% hskip 0.5 em of \tenrm
Chris@10:   %
Chris@10:   \boldbrax
Chris@10:   % arguments will be output next, if any.
Chris@10: }
Chris@10: 
Chris@10: % Print arguments in slanted roman (not ttsl), inconsistently with using
Chris@10: % tt for the name.  This is because literal text is sometimes needed in
Chris@10: % the argument list (groff manual), and ttsl and tt are not very
Chris@10: % distinguishable.  Prevent hyphenation at `-' chars.
Chris@10: %
Chris@10: \def\defunargs#1{%
Chris@10:   % use sl by default (not ttsl),
Chris@10:   % tt for the names.
Chris@10:   \df \sl \hyphenchar\font=0
Chris@10:   %
Chris@10:   % On the other hand, if an argument has two dashes (for instance), we
Chris@10:   % want a way to get ttsl.  Let's try @var for that.
Chris@10:   \def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}%
Chris@10:   #1%
Chris@10:   \sl\hyphenchar\font=45
Chris@10: }
Chris@10: 
Chris@10: % We want ()&[] to print specially on the defun line.
Chris@10: %
Chris@10: \def\activeparens{%
Chris@10:   \catcode`\(=\active \catcode`\)=\active
Chris@10:   \catcode`\[=\active \catcode`\]=\active
Chris@10:   \catcode`\&=\active
Chris@10: }
Chris@10: 
Chris@10: % Make control sequences which act like normal parenthesis chars.
Chris@10: \let\lparen = ( \let\rparen = )
Chris@10: 
Chris@10: % Be sure that we always have a definition for `(', etc.  For example,
Chris@10: % if the fn name has parens in it, \boldbrax will not be in effect yet,
Chris@10: % so TeX would otherwise complain about undefined control sequence.
Chris@10: {
Chris@10:   \activeparens
Chris@10:   \global\let(=\lparen \global\let)=\rparen
Chris@10:   \global\let[=\lbrack \global\let]=\rbrack
Chris@10:   \global\let& = \&
Chris@10: 
Chris@10:   \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
Chris@10:   \gdef\magicamp{\let&=\amprm}
Chris@10: }
Chris@10: 
Chris@10: \newcount\parencount
Chris@10: 
Chris@10: % If we encounter &foo, then turn on ()-hacking afterwards
Chris@10: \newif\ifampseen
Chris@10: \def\amprm#1 {\ampseentrue{\bf\&#1 }}
Chris@10: 
Chris@10: \def\parenfont{%
Chris@10:   \ifampseen
Chris@10:     % At the first level, print parens in roman,
Chris@10:     % otherwise use the default font.
Chris@10:     \ifnum \parencount=1 \rm \fi
Chris@10:   \else
Chris@10:     % The \sf parens (in \boldbrax) actually are a little bolder than
Chris@10:     % the contained text.  This is especially needed for [ and ] .
Chris@10:     \sf
Chris@10:   \fi
Chris@10: }
Chris@10: \def\infirstlevel#1{%
Chris@10:   \ifampseen
Chris@10:     \ifnum\parencount=1
Chris@10:       #1%
Chris@10:     \fi
Chris@10:   \fi
Chris@10: }
Chris@10: \def\bfafterword#1 {#1 \bf}
Chris@10: 
Chris@10: \def\opnr{%
Chris@10:   \global\advance\parencount by 1
Chris@10:   {\parenfont(}%
Chris@10:   \infirstlevel \bfafterword
Chris@10: }
Chris@10: \def\clnr{%
Chris@10:   {\parenfont)}%
Chris@10:   \infirstlevel \sl
Chris@10:   \global\advance\parencount by -1
Chris@10: }
Chris@10: 
Chris@10: \newcount\brackcount
Chris@10: \def\lbrb{%
Chris@10:   \global\advance\brackcount by 1
Chris@10:   {\bf[}%
Chris@10: }
Chris@10: \def\rbrb{%
Chris@10:   {\bf]}%
Chris@10:   \global\advance\brackcount by -1
Chris@10: }
Chris@10: 
Chris@10: \def\checkparencounts{%
Chris@10:   \ifnum\parencount=0 \else \badparencount \fi
Chris@10:   \ifnum\brackcount=0 \else \badbrackcount \fi
Chris@10: }
Chris@10: % these should not use \errmessage; the glibc manual, at least, actually
Chris@10: % has such constructs (when documenting function pointers).
Chris@10: \def\badparencount{%
Chris@10:   \message{Warning: unbalanced parentheses in @def...}%
Chris@10:   \global\parencount=0
Chris@10: }
Chris@10: \def\badbrackcount{%
Chris@10:   \message{Warning: unbalanced square brackets in @def...}%
Chris@10:   \global\brackcount=0
Chris@10: }
Chris@10: 
Chris@10: 
Chris@10: \message{macros,}
Chris@10: % @macro.
Chris@10: 
Chris@10: % To do this right we need a feature of e-TeX, \scantokens,
Chris@10: % which we arrange to emulate with a temporary file in ordinary TeX.
Chris@10: \ifx\eTeXversion\thisisundefined
Chris@10:   \newwrite\macscribble
Chris@10:   \def\scantokens#1{%
Chris@10:     \toks0={#1}%
Chris@10:     \immediate\openout\macscribble=\jobname.tmp
Chris@10:     \immediate\write\macscribble{\the\toks0}%
Chris@10:     \immediate\closeout\macscribble
Chris@10:     \input \jobname.tmp
Chris@10:   }
Chris@10: \fi
Chris@10: 
Chris@10: \def\scanmacro#1{\begingroup
Chris@10:   \newlinechar`\^^M
Chris@10:   \let\xeatspaces\eatspaces
Chris@10:   %
Chris@10:   % Undo catcode changes of \startcontents and \doprintindex
Chris@10:   % When called from @insertcopying or (short)caption, we need active
Chris@10:   % backslash to get it printed correctly.  Previously, we had
Chris@10:   % \catcode`\\=\other instead.  We'll see whether a problem appears
Chris@10:   % with macro expansion.				--kasal, 19aug04
Chris@10:   \catcode`\@=0 \catcode`\\=\active \escapechar=`\@
Chris@10:   %
Chris@10:   % ... and for \example:
Chris@10:   \spaceisspace
Chris@10:   %
Chris@10:   % The \empty here causes a following catcode 5 newline to be eaten as
Chris@10:   % part of reading whitespace after a control sequence.  It does not
Chris@10:   % eat a catcode 13 newline.  There's no good way to handle the two
Chris@10:   % cases (untried: maybe e-TeX's \everyeof could help, though plain TeX
Chris@10:   % would then have different behavior).  See the Macro Details node in
Chris@10:   % the manual for the workaround we recommend for macros and
Chris@10:   % line-oriented commands.
Chris@10:   % 
Chris@10:   \scantokens{#1\empty}%
Chris@10: \endgroup}
Chris@10: 
Chris@10: \def\scanexp#1{%
Chris@10:   \edef\temp{\noexpand\scanmacro{#1}}%
Chris@10:   \temp
Chris@10: }
Chris@10: 
Chris@10: \newcount\paramno   % Count of parameters
Chris@10: \newtoks\macname    % Macro name
Chris@10: \newif\ifrecursive  % Is it recursive?
Chris@10: 
Chris@10: % List of all defined macros in the form
Chris@10: %    \definedummyword\macro1\definedummyword\macro2...
Chris@10: % Currently is also contains all @aliases; the list can be split
Chris@10: % if there is a need.
Chris@10: \def\macrolist{}
Chris@10: 
Chris@10: % Add the macro to \macrolist
Chris@10: \def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname}
Chris@10: \def\addtomacrolistxxx#1{%
Chris@10:      \toks0 = \expandafter{\macrolist\definedummyword#1}%
Chris@10:      \xdef\macrolist{\the\toks0}%
Chris@10: }
Chris@10: 
Chris@10: % Utility routines.
Chris@10: % This does \let #1 = #2, with \csnames; that is,
Chris@10: %   \let \csname#1\endcsname = \csname#2\endcsname
Chris@10: % (except of course we have to play expansion games).
Chris@10: %
Chris@10: \def\cslet#1#2{%
Chris@10:   \expandafter\let
Chris@10:   \csname#1\expandafter\endcsname
Chris@10:   \csname#2\endcsname
Chris@10: }
Chris@10: 
Chris@10: % Trim leading and trailing spaces off a string.
Chris@10: % Concepts from aro-bend problem 15 (see CTAN).
Chris@10: {\catcode`\@=11
Chris@10: \gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }}
Chris@10: \gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@}
Chris@10: \gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @}
Chris@10: \def\unbrace#1{#1}
Chris@10: \unbrace{\gdef\trim@@@ #1 } #2@{#1}
Chris@10: }
Chris@10: 
Chris@10: % Trim a single trailing ^^M off a string.
Chris@10: {\catcode`\^^M=\other \catcode`\Q=3%
Chris@10: \gdef\eatcr #1{\eatcra #1Q^^MQ}%
Chris@10: \gdef\eatcra#1^^MQ{\eatcrb#1Q}%
Chris@10: \gdef\eatcrb#1Q#2Q{#1}%
Chris@10: }
Chris@10: 
Chris@10: % Macro bodies are absorbed as an argument in a context where
Chris@10: % all characters are catcode 10, 11 or 12, except \ which is active
Chris@10: % (as in normal texinfo). It is necessary to change the definition of \
Chris@10: % to recognize macro arguments; this is the job of \mbodybackslash.
Chris@10: %
Chris@10: % Non-ASCII encodings make 8-bit characters active, so un-activate
Chris@10: % them to avoid their expansion.  Must do this non-globally, to
Chris@10: % confine the change to the current group.
Chris@10: %
Chris@10: % It's necessary to have hard CRs when the macro is executed. This is
Chris@10: % done by making ^^M (\endlinechar) catcode 12 when reading the macro
Chris@10: % body, and then making it the \newlinechar in \scanmacro.
Chris@10: %
Chris@10: \def\scanctxt{% used as subroutine
Chris@10:   \catcode`\"=\other
Chris@10:   \catcode`\+=\other
Chris@10:   \catcode`\<=\other
Chris@10:   \catcode`\>=\other
Chris@10:   \catcode`\@=\other
Chris@10:   \catcode`\^=\other
Chris@10:   \catcode`\_=\other
Chris@10:   \catcode`\|=\other
Chris@10:   \catcode`\~=\other
Chris@10:   \ifx\declaredencoding\ascii \else \setnonasciicharscatcodenonglobal\other \fi
Chris@10: }
Chris@10: 
Chris@10: \def\scanargctxt{% used for copying and captions, not macros.
Chris@10:   \scanctxt
Chris@10:   \catcode`\\=\other
Chris@10:   \catcode`\^^M=\other
Chris@10: }
Chris@10: 
Chris@10: \def\macrobodyctxt{% used for @macro definitions
Chris@10:   \scanctxt
Chris@10:   \catcode`\{=\other
Chris@10:   \catcode`\}=\other
Chris@10:   \catcode`\^^M=\other
Chris@10:   \usembodybackslash
Chris@10: }
Chris@10: 
Chris@10: \def\macroargctxt{% used when scanning invocations
Chris@10:   \scanctxt
Chris@10:   \catcode`\\=0
Chris@10: }
Chris@10: % why catcode 0 for \ in the above?  To recognize \\ \{ \} as "escapes"
Chris@10: % for the single characters \ { }.  Thus, we end up with the "commands"
Chris@10: % that would be written @\ @{ @} in a Texinfo document.
Chris@10: % 
Chris@10: % We already have @{ and @}.  For @\, we define it here, and only for
Chris@10: % this purpose, to produce a typewriter backslash (so, the @\ that we
Chris@10: % define for @math can't be used with @macro calls):
Chris@10: %
Chris@10: \def\\{\normalbackslash}%
Chris@10: % 
Chris@10: % We would like to do this for \, too, since that is what makeinfo does.
Chris@10: % But it is not possible, because Texinfo already has a command @, for a
Chris@10: % cedilla accent.  Documents must use @comma{} instead.
Chris@10: %
Chris@10: % \anythingelse will almost certainly be an error of some kind.
Chris@10: 
Chris@10: 
Chris@10: % \mbodybackslash is the definition of \ in @macro bodies.
Chris@10: % It maps \foo\ => \csname macarg.foo\endcsname => #N
Chris@10: % where N is the macro parameter number.
Chris@10: % We define \csname macarg.\endcsname to be \realbackslash, so
Chris@10: % \\ in macro replacement text gets you a backslash.
Chris@10: %
Chris@10: {\catcode`@=0 @catcode`@\=@active
Chris@10:  @gdef@usembodybackslash{@let\=@mbodybackslash}
Chris@10:  @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname}
Chris@10: }
Chris@10: \expandafter\def\csname macarg.\endcsname{\realbackslash}
Chris@10: 
Chris@10: \def\margbackslash#1{\char`\#1 }
Chris@10: 
Chris@10: \def\macro{\recursivefalse\parsearg\macroxxx}
Chris@10: \def\rmacro{\recursivetrue\parsearg\macroxxx}
Chris@10: 
Chris@10: \def\macroxxx#1{%
Chris@10:   \getargs{#1}% now \macname is the macname and \argl the arglist
Chris@10:   \ifx\argl\empty       % no arguments
Chris@10:      \paramno=0\relax
Chris@10:   \else
Chris@10:      \expandafter\parsemargdef \argl;%
Chris@10:      \if\paramno>256\relax
Chris@10:        \ifx\eTeXversion\thisisundefined
Chris@10:          \errhelp = \EMsimple
Chris@10:          \errmessage{You need eTeX to compile a file with macros with more than 256 arguments}
Chris@10:        \fi
Chris@10:      \fi
Chris@10:   \fi
Chris@10:   \if1\csname ismacro.\the\macname\endcsname
Chris@10:      \message{Warning: redefining \the\macname}%
Chris@10:   \else
Chris@10:      \expandafter\ifx\csname \the\macname\endcsname \relax
Chris@10:      \else \errmessage{Macro name \the\macname\space already defined}\fi
Chris@10:      \global\cslet{macsave.\the\macname}{\the\macname}%
Chris@10:      \global\expandafter\let\csname ismacro.\the\macname\endcsname=1%
Chris@10:      \addtomacrolist{\the\macname}%
Chris@10:   \fi
Chris@10:   \begingroup \macrobodyctxt
Chris@10:   \ifrecursive \expandafter\parsermacbody
Chris@10:   \else \expandafter\parsemacbody
Chris@10:   \fi}
Chris@10: 
Chris@10: \parseargdef\unmacro{%
Chris@10:   \if1\csname ismacro.#1\endcsname
Chris@10:     \global\cslet{#1}{macsave.#1}%
Chris@10:     \global\expandafter\let \csname ismacro.#1\endcsname=0%
Chris@10:     % Remove the macro name from \macrolist:
Chris@10:     \begingroup
Chris@10:       \expandafter\let\csname#1\endcsname \relax
Chris@10:       \let\definedummyword\unmacrodo
Chris@10:       \xdef\macrolist{\macrolist}%
Chris@10:     \endgroup
Chris@10:   \else
Chris@10:     \errmessage{Macro #1 not defined}%
Chris@10:   \fi
Chris@10: }
Chris@10: 
Chris@10: % Called by \do from \dounmacro on each macro.  The idea is to omit any
Chris@10: % macro definitions that have been changed to \relax.
Chris@10: %
Chris@10: \def\unmacrodo#1{%
Chris@10:   \ifx #1\relax
Chris@10:     % remove this
Chris@10:   \else
Chris@10:     \noexpand\definedummyword \noexpand#1%
Chris@10:   \fi
Chris@10: }
Chris@10: 
Chris@10: % This makes use of the obscure feature that if the last token of a
Chris@10: % <parameter list> is #, then the preceding argument is delimited by
Chris@10: % an opening brace, and that opening brace is not consumed.
Chris@10: \def\getargs#1{\getargsxxx#1{}}
Chris@10: \def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
Chris@10: \def\getmacname#1 #2\relax{\macname={#1}}
Chris@10: \def\getmacargs#1{\def\argl{#1}}
Chris@10: 
Chris@10: % For macro processing make @ a letter so that we can make Texinfo private macro names.
Chris@10: \edef\texiatcatcode{\the\catcode`\@}
Chris@10: \catcode `@=11\relax
Chris@10: 
Chris@10: % Parse the optional {params} list.  Set up \paramno and \paramlist
Chris@10: % so \defmacro knows what to do.  Define \macarg.BLAH for each BLAH
Chris@10: % in the params list to some hook where the argument si to be expanded.  If
Chris@10: % there are less than 10 arguments that hook is to be replaced by ##N where N
Chris@10: % is the position in that list, that is to say the macro arguments are to be
Chris@10: % defined `a la TeX in the macro body.  
Chris@10: %
Chris@10: % That gets used by \mbodybackslash (above).
Chris@10: %
Chris@10: % We need to get `macro parameter char #' into several definitions.
Chris@10: % The technique used is stolen from LaTeX: let \hash be something
Chris@10: % unexpandable, insert that wherever you need a #, and then redefine
Chris@10: % it to # just before using the token list produced.
Chris@10: %
Chris@10: % The same technique is used to protect \eatspaces till just before
Chris@10: % the macro is used.
Chris@10: %
Chris@10: % If there are 10 or more arguments, a different technique is used, where the
Chris@10: % hook remains in the body, and when macro is to be expanded the body is
Chris@10: % processed again to replace the arguments.
Chris@10: %
Chris@10: % In that case, the hook is \the\toks N-1, and we simply set \toks N-1 to the
Chris@10: % argument N value and then \edef  the body (nothing else will expand because of
Chris@10: % the catcode regime underwhich the body was input).
Chris@10: %
Chris@10: % If you compile with TeX (not eTeX), and you have macros with 10 or more
Chris@10: % arguments, you need that no macro has more than 256 arguments, otherwise an
Chris@10: % error is produced.
Chris@10: \def\parsemargdef#1;{%
Chris@10:   \paramno=0\def\paramlist{}%
Chris@10:   \let\hash\relax
Chris@10:   \let\xeatspaces\relax
Chris@10:   \parsemargdefxxx#1,;,%
Chris@10:   % In case that there are 10 or more arguments we parse again the arguments
Chris@10:   % list to set new definitions for the \macarg.BLAH macros corresponding to
Chris@10:   % each BLAH argument. It was anyhow needed to parse already once this list
Chris@10:   % in order to count the arguments, and as macros with at most 9 arguments
Chris@10:   % are by far more frequent than macro with 10 or more arguments, defining
Chris@10:   % twice the \macarg.BLAH macros does not cost too much processing power.
Chris@10:   \ifnum\paramno<10\relax\else
Chris@10:     \paramno0\relax
Chris@10:     \parsemmanyargdef@@#1,;,% 10 or more arguments
Chris@10:   \fi
Chris@10: }
Chris@10: \def\parsemargdefxxx#1,{%
Chris@10:   \if#1;\let\next=\relax
Chris@10:   \else \let\next=\parsemargdefxxx
Chris@10:     \advance\paramno by 1
Chris@10:     \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
Chris@10:         {\xeatspaces{\hash\the\paramno}}%
Chris@10:     \edef\paramlist{\paramlist\hash\the\paramno,}%
Chris@10:   \fi\next}
Chris@10: 
Chris@10: \def\parsemmanyargdef@@#1,{%
Chris@10:   \if#1;\let\next=\relax
Chris@10:   \else 
Chris@10:     \let\next=\parsemmanyargdef@@
Chris@10:     \edef\tempb{\eatspaces{#1}}%
Chris@10:     \expandafter\def\expandafter\tempa
Chris@10:        \expandafter{\csname macarg.\tempb\endcsname}%
Chris@10:     % Note that we need some extra \noexpand\noexpand, this is because we
Chris@10:     % don't want \the  to be expanded in the \parsermacbody  as it uses an
Chris@10:     % \xdef .
Chris@10:     \expandafter\edef\tempa
Chris@10:       {\noexpand\noexpand\noexpand\the\toks\the\paramno}%
Chris@10:     \advance\paramno by 1\relax
Chris@10:   \fi\next}
Chris@10: 
Chris@10: % These two commands read recursive and nonrecursive macro bodies.
Chris@10: % (They're different since rec and nonrec macros end differently.)
Chris@10: %
Chris@10: 
Chris@10: \catcode `\@\texiatcatcode
Chris@10: \long\def\parsemacbody#1@end macro%
Chris@10: {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
Chris@10: \long\def\parsermacbody#1@end rmacro%
Chris@10: {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
Chris@10: \catcode `\@=11\relax
Chris@10: 
Chris@10: \let\endargs@\relax
Chris@10: \let\nil@\relax
Chris@10: \def\nilm@{\nil@}%
Chris@10: \long\def\nillm@{\nil@}%
Chris@10: 
Chris@10: % This macro is expanded during the Texinfo macro expansion, not during its
Chris@10: % definition.  It gets all the arguments values and assigns them to macros
Chris@10: % macarg.ARGNAME
Chris@10: %
Chris@10: % #1 is the macro name
Chris@10: % #2 is the list of argument names
Chris@10: % #3 is the list of argument values
Chris@10: \def\getargvals@#1#2#3{%
Chris@10:   \def\macargdeflist@{}%
Chris@10:   \def\saveparamlist@{#2}% Need to keep a copy for parameter expansion.
Chris@10:   \def\paramlist{#2,\nil@}%
Chris@10:   \def\macroname{#1}%
Chris@10:   \begingroup
Chris@10:   \macroargctxt
Chris@10:   \def\argvaluelist{#3,\nil@}%
Chris@10:   \def\@tempa{#3}%
Chris@10:   \ifx\@tempa\empty
Chris@10:     \setemptyargvalues@
Chris@10:   \else
Chris@10:     \getargvals@@
Chris@10:   \fi
Chris@10: }
Chris@10: 
Chris@10: % 
Chris@10: \def\getargvals@@{%
Chris@10:   \ifx\paramlist\nilm@
Chris@10:       % Some sanity check needed here that \argvaluelist is also empty.
Chris@10:       \ifx\argvaluelist\nillm@
Chris@10:       \else
Chris@10:         \errhelp = \EMsimple
Chris@10:         \errmessage{Too many arguments in macro `\macroname'!}%
Chris@10:       \fi
Chris@10:       \let\next\macargexpandinbody@
Chris@10:   \else
Chris@10:     \ifx\argvaluelist\nillm@
Chris@10:        % No more arguments values passed to macro.  Set remaining named-arg
Chris@10:        % macros to empty.
Chris@10:        \let\next\setemptyargvalues@
Chris@10:     \else
Chris@10:       % pop current arg name into \@tempb
Chris@10:       \def\@tempa##1{\pop@{\@tempb}{\paramlist}##1\endargs@}%
Chris@10:       \expandafter\@tempa\expandafter{\paramlist}%
Chris@10:        % pop current argument value into \@tempc
Chris@10:       \def\@tempa##1{\longpop@{\@tempc}{\argvaluelist}##1\endargs@}%
Chris@10:       \expandafter\@tempa\expandafter{\argvaluelist}%
Chris@10:        % Here \@tempb is the current arg name and \@tempc is the current arg value.
Chris@10:        % First place the new argument macro definition into \@tempd
Chris@10:        \expandafter\macname\expandafter{\@tempc}%
Chris@10:        \expandafter\let\csname macarg.\@tempb\endcsname\relax
Chris@10:        \expandafter\def\expandafter\@tempe\expandafter{%
Chris@10:          \csname macarg.\@tempb\endcsname}%
Chris@10:        \edef\@tempd{\long\def\@tempe{\the\macname}}%
Chris@10:        \push@\@tempd\macargdeflist@
Chris@10:        \let\next\getargvals@@
Chris@10:     \fi
Chris@10:   \fi
Chris@10:   \next
Chris@10: }
Chris@10: 
Chris@10: \def\push@#1#2{%
Chris@10:   \expandafter\expandafter\expandafter\def
Chris@10:   \expandafter\expandafter\expandafter#2%
Chris@10:   \expandafter\expandafter\expandafter{%
Chris@10:   \expandafter#1#2}%
Chris@10: }
Chris@10: 
Chris@10: % Replace arguments by their values in the macro body, and place the result
Chris@10: % in macro \@tempa
Chris@10: \def\macvalstoargs@{%
Chris@10:   %  To do this we use the property that token registers that are \the'ed
Chris@10:   % within an \edef  expand only once. So we are going to place all argument
Chris@10:   % values into respective token registers.
Chris@10:   %
Chris@10:   % First we save the token context, and initialize argument numbering.
Chris@10:   \begingroup
Chris@10:     \paramno0\relax
Chris@10:     % Then, for each argument number #N, we place the corresponding argument
Chris@10:     % value into a new token list register \toks#N
Chris@10:     \expandafter\putargsintokens@\saveparamlist@,;,%
Chris@10:     % Then, we expand the body so that argument are replaced by their
Chris@10:     % values. The trick for values not to be expanded themselves is that they
Chris@10:     % are within tokens and that tokens expand only once in an \edef .
Chris@10:     \edef\@tempc{\csname mac.\macroname .body\endcsname}%
Chris@10:     % Now we restore the token stack pointer to free the token list registers
Chris@10:     % which we have used, but we make sure that expanded body is saved after
Chris@10:     % group.
Chris@10:     \expandafter
Chris@10:   \endgroup
Chris@10:   \expandafter\def\expandafter\@tempa\expandafter{\@tempc}%
Chris@10:   }
Chris@10: 
Chris@10: \def\macargexpandinbody@{% 
Chris@10:   %% Define the named-macro outside of this group and then close this group. 
Chris@10:   \expandafter
Chris@10:   \endgroup
Chris@10:   \macargdeflist@
Chris@10:   % First the replace in body the macro arguments by their values, the result
Chris@10:   % is in \@tempa .
Chris@10:   \macvalstoargs@
Chris@10:   % Then we point at the \norecurse or \gobble (for recursive) macro value
Chris@10:   % with \@tempb .
Chris@10:   \expandafter\let\expandafter\@tempb\csname mac.\macroname .recurse\endcsname
Chris@10:   % Depending on whether it is recursive or not, we need some tailing
Chris@10:   % \egroup .
Chris@10:   \ifx\@tempb\gobble
Chris@10:      \let\@tempc\relax
Chris@10:   \else
Chris@10:      \let\@tempc\egroup
Chris@10:   \fi
Chris@10:   % And now we do the real job:
Chris@10:   \edef\@tempd{\noexpand\@tempb{\macroname}\noexpand\scanmacro{\@tempa}\@tempc}%
Chris@10:   \@tempd
Chris@10: }
Chris@10: 
Chris@10: \def\putargsintokens@#1,{%
Chris@10:   \if#1;\let\next\relax
Chris@10:   \else
Chris@10:     \let\next\putargsintokens@
Chris@10:     % First we allocate the new token list register, and give it a temporary
Chris@10:     % alias \@tempb .
Chris@10:     \toksdef\@tempb\the\paramno
Chris@10:     % Then we place the argument value into that token list register.
Chris@10:     \expandafter\let\expandafter\@tempa\csname macarg.#1\endcsname
Chris@10:     \expandafter\@tempb\expandafter{\@tempa}%
Chris@10:     \advance\paramno by 1\relax
Chris@10:   \fi
Chris@10:   \next
Chris@10: }
Chris@10: 
Chris@10: % Save the token stack pointer into macro #1
Chris@10: \def\texisavetoksstackpoint#1{\edef#1{\the\@cclvi}}
Chris@10: % Restore the token stack pointer from number in macro #1
Chris@10: \def\texirestoretoksstackpoint#1{\expandafter\mathchardef\expandafter\@cclvi#1\relax}
Chris@10: % newtoks that can be used non \outer .
Chris@10: \def\texinonouternewtoks{\alloc@ 5\toks \toksdef \@cclvi}
Chris@10: 
Chris@10: % Tailing missing arguments are set to empty
Chris@10: \def\setemptyargvalues@{%
Chris@10:   \ifx\paramlist\nilm@
Chris@10:     \let\next\macargexpandinbody@
Chris@10:   \else
Chris@10:     \expandafter\setemptyargvaluesparser@\paramlist\endargs@
Chris@10:     \let\next\setemptyargvalues@
Chris@10:   \fi
Chris@10:   \next
Chris@10: }
Chris@10: 
Chris@10: \def\setemptyargvaluesparser@#1,#2\endargs@{%
Chris@10:   \expandafter\def\expandafter\@tempa\expandafter{%
Chris@10:     \expandafter\def\csname macarg.#1\endcsname{}}%
Chris@10:   \push@\@tempa\macargdeflist@
Chris@10:   \def\paramlist{#2}%
Chris@10: }
Chris@10: 
Chris@10: % #1 is the element target macro
Chris@10: % #2 is the list macro
Chris@10: % #3,#4\endargs@ is the list value
Chris@10: \def\pop@#1#2#3,#4\endargs@{%
Chris@10:    \def#1{#3}%
Chris@10:    \def#2{#4}%
Chris@10: }
Chris@10: \long\def\longpop@#1#2#3,#4\endargs@{%
Chris@10:    \long\def#1{#3}%
Chris@10:    \long\def#2{#4}%
Chris@10: }
Chris@10: 
Chris@10: % This defines a Texinfo @macro. There are eight cases: recursive and
Chris@10: % nonrecursive macros of zero, one, up to nine, and many arguments.
Chris@10: % Much magic with \expandafter here.
Chris@10: % \xdef is used so that macro definitions will survive the file
Chris@10: % they're defined in; @include reads the file inside a group.
Chris@10: %
Chris@10: \def\defmacro{%
Chris@10:   \let\hash=##% convert placeholders to macro parameter chars
Chris@10:   \ifrecursive
Chris@10:     \ifcase\paramno
Chris@10:     % 0
Chris@10:       \expandafter\xdef\csname\the\macname\endcsname{%
Chris@10:         \noexpand\scanmacro{\temp}}%
Chris@10:     \or % 1
Chris@10:       \expandafter\xdef\csname\the\macname\endcsname{%
Chris@10:          \bgroup\noexpand\macroargctxt
Chris@10:          \noexpand\braceorline
Chris@10:          \expandafter\noexpand\csname\the\macname xxx\endcsname}%
Chris@10:       \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
Chris@10:          \egroup\noexpand\scanmacro{\temp}}%
Chris@10:     \else
Chris@10:       \ifnum\paramno<10\relax % at most 9
Chris@10:         \expandafter\xdef\csname\the\macname\endcsname{%
Chris@10:            \bgroup\noexpand\macroargctxt
Chris@10:            \noexpand\csname\the\macname xx\endcsname}%
Chris@10:         \expandafter\xdef\csname\the\macname xx\endcsname##1{%
Chris@10:             \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
Chris@10:         \expandafter\expandafter
Chris@10:         \expandafter\xdef
Chris@10:         \expandafter\expandafter
Chris@10:           \csname\the\macname xxx\endcsname
Chris@10:             \paramlist{\egroup\noexpand\scanmacro{\temp}}%
Chris@10:       \else % 10 or more
Chris@10:         \expandafter\xdef\csname\the\macname\endcsname{%
Chris@10:           \noexpand\getargvals@{\the\macname}{\argl}%
Chris@10:         }%    
Chris@10:         \global\expandafter\let\csname mac.\the\macname .body\endcsname\temp
Chris@10:         \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\gobble
Chris@10:       \fi
Chris@10:     \fi
Chris@10:   \else
Chris@10:     \ifcase\paramno
Chris@10:     % 0
Chris@10:       \expandafter\xdef\csname\the\macname\endcsname{%
Chris@10:         \noexpand\norecurse{\the\macname}%
Chris@10:         \noexpand\scanmacro{\temp}\egroup}%
Chris@10:     \or % 1
Chris@10:       \expandafter\xdef\csname\the\macname\endcsname{%
Chris@10:          \bgroup\noexpand\macroargctxt
Chris@10:          \noexpand\braceorline
Chris@10:          \expandafter\noexpand\csname\the\macname xxx\endcsname}%
Chris@10:       \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
Chris@10:         \egroup
Chris@10:         \noexpand\norecurse{\the\macname}%
Chris@10:         \noexpand\scanmacro{\temp}\egroup}%
Chris@10:     \else % at most 9
Chris@10:       \ifnum\paramno<10\relax
Chris@10:         \expandafter\xdef\csname\the\macname\endcsname{%
Chris@10:            \bgroup\noexpand\macroargctxt
Chris@10:            \expandafter\noexpand\csname\the\macname xx\endcsname}%
Chris@10:         \expandafter\xdef\csname\the\macname xx\endcsname##1{%
Chris@10:             \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
Chris@10:         \expandafter\expandafter
Chris@10:         \expandafter\xdef
Chris@10:         \expandafter\expandafter
Chris@10:         \csname\the\macname xxx\endcsname
Chris@10:         \paramlist{%
Chris@10:             \egroup
Chris@10:             \noexpand\norecurse{\the\macname}%
Chris@10:             \noexpand\scanmacro{\temp}\egroup}%
Chris@10:       \else % 10 or more:
Chris@10:         \expandafter\xdef\csname\the\macname\endcsname{%
Chris@10:           \noexpand\getargvals@{\the\macname}{\argl}%
Chris@10:         }%
Chris@10:         \global\expandafter\let\csname mac.\the\macname .body\endcsname\temp
Chris@10:         \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\norecurse
Chris@10:       \fi
Chris@10:     \fi
Chris@10:   \fi}
Chris@10: 
Chris@10: \catcode `\@\texiatcatcode\relax
Chris@10: 
Chris@10: \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
Chris@10: 
Chris@10: % \braceorline decides whether the next nonwhitespace character is a
Chris@10: % {.  If so it reads up to the closing }, if not, it reads the whole
Chris@10: % line.  Whatever was read is then fed to the next control sequence
Chris@10: % as an argument (by \parsebrace or \parsearg).
Chris@10: % 
Chris@10: \def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx}
Chris@10: \def\braceorlinexxx{%
Chris@10:   \ifx\nchar\bgroup\else
Chris@10:     \expandafter\parsearg
Chris@10:   \fi \macnamexxx}
Chris@10: 
Chris@10: 
Chris@10: % @alias.
Chris@10: % We need some trickery to remove the optional spaces around the equal
Chris@10: % sign.  Make them active and then expand them all to nothing.
Chris@10: %
Chris@10: \def\alias{\parseargusing\obeyspaces\aliasxxx}
Chris@10: \def\aliasxxx #1{\aliasyyy#1\relax}
Chris@10: \def\aliasyyy #1=#2\relax{%
Chris@10:   {%
Chris@10:     \expandafter\let\obeyedspace=\empty
Chris@10:     \addtomacrolist{#1}%
Chris@10:     \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}%
Chris@10:   }%
Chris@10:   \next
Chris@10: }
Chris@10: 
Chris@10: 
Chris@10: \message{cross references,}
Chris@10: 
Chris@10: \newwrite\auxfile
Chris@10: \newif\ifhavexrefs    % True if xref values are known.
Chris@10: \newif\ifwarnedxrefs  % True if we warned once that they aren't known.
Chris@10: 
Chris@10: % @inforef is relatively simple.
Chris@10: \def\inforef #1{\inforefzzz #1,,,,**}
Chris@10: \def\inforefzzz #1,#2,#3,#4**{%
Chris@10:   \putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
Chris@10:   node \samp{\ignorespaces#1{}}}
Chris@10: 
Chris@10: % @node's only job in TeX is to define \lastnode, which is used in
Chris@10: % cross-references.  The @node line might or might not have commas, and
Chris@10: % might or might not have spaces before the first comma, like:
Chris@10: % @node foo , bar , ...
Chris@10: % We don't want such trailing spaces in the node name.
Chris@10: %
Chris@10: \parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse}
Chris@10: %
Chris@10: % also remove a trailing comma, in case of something like this:
Chris@10: % @node Help-Cross,  ,  , Cross-refs
Chris@10: \def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse}
Chris@10: \def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}}
Chris@10: 
Chris@10: \let\nwnode=\node
Chris@10: \let\lastnode=\empty
Chris@10: 
Chris@10: % Write a cross-reference definition for the current node.  #1 is the
Chris@10: % type (Ynumbered, Yappendix, Ynothing).
Chris@10: %
Chris@10: \def\donoderef#1{%
Chris@10:   \ifx\lastnode\empty\else
Chris@10:     \setref{\lastnode}{#1}%
Chris@10:     \global\let\lastnode=\empty
Chris@10:   \fi
Chris@10: }
Chris@10: 
Chris@10: % @anchor{NAME} -- define xref target at arbitrary point.
Chris@10: %
Chris@10: \newcount\savesfregister
Chris@10: %
Chris@10: \def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi}
Chris@10: \def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi}
Chris@10: \def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces}
Chris@10: 
Chris@10: % \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an
Chris@10: % anchor), which consists of three parts:
Chris@10: % 1) NAME-title - the current sectioning name taken from \lastsection,
Chris@10: %                 or the anchor name.
Chris@10: % 2) NAME-snt   - section number and type, passed as the SNT arg, or
Chris@10: %                 empty for anchors.
Chris@10: % 3) NAME-pg    - the page number.
Chris@10: %
Chris@10: % This is called from \donoderef, \anchor, and \dofloat.  In the case of
Chris@10: % floats, there is an additional part, which is not written here:
Chris@10: % 4) NAME-lof   - the text as it should appear in a @listoffloats.
Chris@10: %
Chris@10: \def\setref#1#2{%
Chris@10:   \pdfmkdest{#1}%
Chris@10:   \iflinks
Chris@10:     {%
Chris@10:       \atdummies  % preserve commands, but don't expand them
Chris@10:       \edef\writexrdef##1##2{%
Chris@10: 	\write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef
Chris@10: 	  ##1}{##2}}% these are parameters of \writexrdef
Chris@10:       }%
Chris@10:       \toks0 = \expandafter{\lastsection}%
Chris@10:       \immediate \writexrdef{title}{\the\toks0 }%
Chris@10:       \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc.
Chris@10:       \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout
Chris@10:     }%
Chris@10:   \fi
Chris@10: }
Chris@10: 
Chris@10: % @xrefautosectiontitle on|off says whether @section(ing) names are used
Chris@10: % automatically in xrefs, if the third arg is not explicitly specified.
Chris@10: % This was provided as a "secret" @set xref-automatic-section-title
Chris@10: % variable, now it's official.
Chris@10: % 
Chris@10: \parseargdef\xrefautomaticsectiontitle{%
Chris@10:   \def\temp{#1}%
Chris@10:   \ifx\temp\onword
Chris@10:     \expandafter\let\csname SETxref-automatic-section-title\endcsname
Chris@10:       = \empty
Chris@10:   \else\ifx\temp\offword
Chris@10:     \expandafter\let\csname SETxref-automatic-section-title\endcsname
Chris@10:       = \relax
Chris@10:   \else
Chris@10:     \errhelp = \EMsimple
Chris@10:     \errmessage{Unknown @xrefautomaticsectiontitle value `\temp',
Chris@10:                 must be on|off}%
Chris@10:   \fi\fi
Chris@10: }
Chris@10: 
Chris@10: 
Chris@10: % @xref, @pxref, and @ref generate cross-references.  For \xrefX, #1 is
Chris@10: % the node name, #2 the name of the Info cross-reference, #3 the printed
Chris@10: % node name, #4 the name of the Info file, #5 the name of the printed
Chris@10: % manual.  All but the node name can be omitted.
Chris@10: %
Chris@10: \def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]}
Chris@10: \def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]}
Chris@10: \def\ref#1{\xrefX[#1,,,,,,,]}
Chris@10: %
Chris@10: \newbox\topbox
Chris@10: \newbox\printedrefnamebox
Chris@10: \newbox\printedmanualbox
Chris@10: %
Chris@10: \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
Chris@10:   \unsepspaces
Chris@10:   %
Chris@10:   \def\printedrefname{\ignorespaces #3}%
Chris@10:   \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}%
Chris@10:   %
Chris@10:   \def\printedmanual{\ignorespaces #5}%
Chris@10:   \setbox\printedmanualbox  = \hbox{\printedmanual\unskip}%
Chris@10:   %
Chris@10:   % If the printed reference name (arg #3) was not explicitly given in
Chris@10:   % the @xref, figure out what we want to use.
Chris@10:   \ifdim \wd\printedrefnamebox = 0pt
Chris@10:     % No printed node name was explicitly given.
Chris@10:     \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax
Chris@10:       % Not auto section-title: use node name inside the square brackets.
Chris@10:       \def\printedrefname{\ignorespaces #1}%
Chris@10:     \else
Chris@10:       % Auto section-title: use chapter/section title inside
Chris@10:       % the square brackets if we have it.
Chris@10:       \ifdim \wd\printedmanualbox > 0pt
Chris@10:         % It is in another manual, so we don't have it; use node name.
Chris@10:         \def\printedrefname{\ignorespaces #1}%
Chris@10:       \else
Chris@10:         \ifhavexrefs
Chris@10:           % We (should) know the real title if we have the xref values.
Chris@10:           \def\printedrefname{\refx{#1-title}{}}%
Chris@10:         \else
Chris@10:           % Otherwise just copy the Info node name.
Chris@10:           \def\printedrefname{\ignorespaces #1}%
Chris@10:         \fi%
Chris@10:       \fi
Chris@10:     \fi
Chris@10:   \fi
Chris@10:   %
Chris@10:   % Make link in pdf output.
Chris@10:   \ifpdf
Chris@10:     {\indexnofonts
Chris@10:      \turnoffactive
Chris@10:      \makevalueexpandable
Chris@10:      % This expands tokens, so do it after making catcode changes, so _
Chris@10:      % etc. don't get their TeX definitions.
Chris@10:      \getfilename{#4}%
Chris@10:      %
Chris@10:      \edef\pdfxrefdest{#1}%
Chris@10:      \txiescapepdf\pdfxrefdest
Chris@10:      %
Chris@10:      \leavevmode
Chris@10:      \startlink attr{/Border [0 0 0]}%
Chris@10:      \ifnum\filenamelength>0
Chris@10:        goto file{\the\filename.pdf} name{\pdfxrefdest}%
Chris@10:      \else
Chris@10:        goto name{\pdfmkpgn{\pdfxrefdest}}%
Chris@10:      \fi
Chris@10:     }%
Chris@10:     \setcolor{\linkcolor}%
Chris@10:   \fi
Chris@10:   %
Chris@10:   % Float references are printed completely differently: "Figure 1.2"
Chris@10:   % instead of "[somenode], p.3".  We distinguish them by the
Chris@10:   % LABEL-title being set to a magic string.
Chris@10:   {%
Chris@10:     % Have to otherify everything special to allow the \csname to
Chris@10:     % include an _ in the xref name, etc.
Chris@10:     \indexnofonts
Chris@10:     \turnoffactive
Chris@10:     \expandafter\global\expandafter\let\expandafter\Xthisreftitle
Chris@10:       \csname XR#1-title\endcsname
Chris@10:   }%
Chris@10:   \iffloat\Xthisreftitle
Chris@10:     % If the user specified the print name (third arg) to the ref,
Chris@10:     % print it instead of our usual "Figure 1.2".
Chris@10:     \ifdim\wd\printedrefnamebox = 0pt
Chris@10:       \refx{#1-snt}{}%
Chris@10:     \else
Chris@10:       \printedrefname
Chris@10:     \fi
Chris@10:     %
Chris@10:     % if the user also gave the printed manual name (fifth arg), append
Chris@10:     % "in MANUALNAME".
Chris@10:     \ifdim \wd\printedmanualbox > 0pt
Chris@10:       \space \putwordin{} \cite{\printedmanual}%
Chris@10:     \fi
Chris@10:   \else
Chris@10:     % node/anchor (non-float) references.
Chris@10:     % 
Chris@10:     % If we use \unhbox to print the node names, TeX does not insert
Chris@10:     % empty discretionaries after hyphens, which means that it will not
Chris@10:     % find a line break at a hyphen in a node names.  Since some manuals
Chris@10:     % are best written with fairly long node names, containing hyphens,
Chris@10:     % this is a loss.  Therefore, we give the text of the node name
Chris@10:     % again, so it is as if TeX is seeing it for the first time.
Chris@10:     % 
Chris@10:     % Cross-manual reference.  Only include the "Section ``foo'' in" if
Chris@10:     % the foo is neither missing or Top.  Thus, @xref{,,,foo,The Foo Manual}
Chris@10:     % outputs simply "see The Foo Manual".
Chris@10:     \ifdim \wd\printedmanualbox > 0pt
Chris@10:       % What is the 7sp about?  The idea is that we also want to omit
Chris@10:       % the Section part if we would be printing "Top", since they are
Chris@10:       % clearly trying to refer to the whole manual.  But, this being
Chris@10:       % TeX, we can't easily compare strings while ignoring the possible
Chris@10:       % spaces before and after in the input.  By adding the arbitrary
Chris@10:       % 7sp, we make it much less likely that a real node name would
Chris@10:       % happen to have the same width as "Top" (e.g., in a monospaced font).
Chris@10:       % I hope it will never happen in practice.
Chris@10:       % 
Chris@10:       % For the same basic reason, we retypeset the "Top" at every
Chris@10:       % reference, since the current font is indeterminate.
Chris@10:       % 
Chris@10:       \setbox\topbox = \hbox{Top\kern7sp}%
Chris@10:       \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}%
Chris@10:       \ifdim \wd2 > 7sp
Chris@10:         \ifdim \wd2 = \wd\topbox \else
Chris@10:           \putwordSection{} ``\printedrefname'' \putwordin{}\space
Chris@10:         \fi
Chris@10:       \fi
Chris@10:       \cite{\printedmanual}%
Chris@10:     \else
Chris@10:       % Reference in this manual.
Chris@10:       %
Chris@10:       % _ (for example) has to be the character _ for the purposes of the
Chris@10:       % control sequence corresponding to the node, but it has to expand
Chris@10:       % into the usual \leavevmode...\vrule stuff for purposes of
Chris@10:       % printing. So we \turnoffactive for the \refx-snt, back on for the
Chris@10:       % printing, back off for the \refx-pg.
Chris@10:       {\turnoffactive
Chris@10:        % Only output a following space if the -snt ref is nonempty; for
Chris@10:        % @unnumbered and @anchor, it won't be.
Chris@10:        \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
Chris@10:        \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
Chris@10:       }%
Chris@10:       % output the `[mynode]' via the macro below so it can be overridden.
Chris@10:       \xrefprintnodename\printedrefname
Chris@10:       %
Chris@10:       % But we always want a comma and a space:
Chris@10:       ,\space
Chris@10:       %
Chris@10:       % output the `page 3'.
Chris@10:       \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
Chris@10:     \fi
Chris@10:   \fi
Chris@10:   \endlink
Chris@10: \endgroup}
Chris@10: 
Chris@10: % This macro is called from \xrefX for the `[nodename]' part of xref
Chris@10: % output.  It's a separate macro only so it can be changed more easily,
Chris@10: % since square brackets don't work well in some documents.  Particularly
Chris@10: % one that Bob is working on :).
Chris@10: %
Chris@10: \def\xrefprintnodename#1{[#1]}
Chris@10: 
Chris@10: % Things referred to by \setref.
Chris@10: %
Chris@10: \def\Ynothing{}
Chris@10: \def\Yomitfromtoc{}
Chris@10: \def\Ynumbered{%
Chris@10:   \ifnum\secno=0
Chris@10:     \putwordChapter@tie \the\chapno
Chris@10:   \else \ifnum\subsecno=0
Chris@10:     \putwordSection@tie \the\chapno.\the\secno
Chris@10:   \else \ifnum\subsubsecno=0
Chris@10:     \putwordSection@tie \the\chapno.\the\secno.\the\subsecno
Chris@10:   \else
Chris@10:     \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno
Chris@10:   \fi\fi\fi
Chris@10: }
Chris@10: \def\Yappendix{%
Chris@10:   \ifnum\secno=0
Chris@10:      \putwordAppendix@tie @char\the\appendixno{}%
Chris@10:   \else \ifnum\subsecno=0
Chris@10:      \putwordSection@tie @char\the\appendixno.\the\secno
Chris@10:   \else \ifnum\subsubsecno=0
Chris@10:     \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno
Chris@10:   \else
Chris@10:     \putwordSection@tie
Chris@10:       @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno
Chris@10:   \fi\fi\fi
Chris@10: }
Chris@10: 
Chris@10: % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
Chris@10: % If its value is nonempty, SUFFIX is output afterward.
Chris@10: %
Chris@10: \def\refx#1#2{%
Chris@10:   {%
Chris@10:     \indexnofonts
Chris@10:     \otherbackslash
Chris@10:     \expandafter\global\expandafter\let\expandafter\thisrefX
Chris@10:       \csname XR#1\endcsname
Chris@10:   }%
Chris@10:   \ifx\thisrefX\relax
Chris@10:     % If not defined, say something at least.
Chris@10:     \angleleft un\-de\-fined\angleright
Chris@10:     \iflinks
Chris@10:       \ifhavexrefs
Chris@10:         {\toks0 = {#1}% avoid expansion of possibly-complex value
Chris@10:          \message{\linenumber Undefined cross reference `\the\toks0'.}}%
Chris@10:       \else
Chris@10:         \ifwarnedxrefs\else
Chris@10:           \global\warnedxrefstrue
Chris@10:           \message{Cross reference values unknown; you must run TeX again.}%
Chris@10:         \fi
Chris@10:       \fi
Chris@10:     \fi
Chris@10:   \else
Chris@10:     % It's defined, so just use it.
Chris@10:     \thisrefX
Chris@10:   \fi
Chris@10:   #2% Output the suffix in any case.
Chris@10: }
Chris@10: 
Chris@10: % This is the macro invoked by entries in the aux file.  Usually it's
Chris@10: % just a \def (we prepend XR to the control sequence name to avoid
Chris@10: % collisions).  But if this is a float type, we have more work to do.
Chris@10: %
Chris@10: \def\xrdef#1#2{%
Chris@10:   {% The node name might contain 8-bit characters, which in our current
Chris@10:    % implementation are changed to commands like @'e.  Don't let these
Chris@10:    % mess up the control sequence name.
Chris@10:     \indexnofonts
Chris@10:     \turnoffactive
Chris@10:     \xdef\safexrefname{#1}%
Chris@10:   }%
Chris@10:   %
Chris@10:   \expandafter\gdef\csname XR\safexrefname\endcsname{#2}% remember this xref
Chris@10:   %
Chris@10:   % Was that xref control sequence that we just defined for a float?
Chris@10:   \expandafter\iffloat\csname XR\safexrefname\endcsname
Chris@10:     % it was a float, and we have the (safe) float type in \iffloattype.
Chris@10:     \expandafter\let\expandafter\floatlist
Chris@10:       \csname floatlist\iffloattype\endcsname
Chris@10:     %
Chris@10:     % Is this the first time we've seen this float type?
Chris@10:     \expandafter\ifx\floatlist\relax
Chris@10:       \toks0 = {\do}% yes, so just \do
Chris@10:     \else
Chris@10:       % had it before, so preserve previous elements in list.
Chris@10:       \toks0 = \expandafter{\floatlist\do}%
Chris@10:     \fi
Chris@10:     %
Chris@10:     % Remember this xref in the control sequence \floatlistFLOATTYPE,
Chris@10:     % for later use in \listoffloats.
Chris@10:     \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0
Chris@10:       {\safexrefname}}%
Chris@10:   \fi
Chris@10: }
Chris@10: 
Chris@10: % Read the last existing aux file, if any.  No error if none exists.
Chris@10: %
Chris@10: \def\tryauxfile{%
Chris@10:   \openin 1 \jobname.aux
Chris@10:   \ifeof 1 \else
Chris@10:     \readdatafile{aux}%
Chris@10:     \global\havexrefstrue
Chris@10:   \fi
Chris@10:   \closein 1
Chris@10: }
Chris@10: 
Chris@10: \def\setupdatafile{%
Chris@10:   \catcode`\^^@=\other
Chris@10:   \catcode`\^^A=\other
Chris@10:   \catcode`\^^B=\other
Chris@10:   \catcode`\^^C=\other
Chris@10:   \catcode`\^^D=\other
Chris@10:   \catcode`\^^E=\other
Chris@10:   \catcode`\^^F=\other
Chris@10:   \catcode`\^^G=\other
Chris@10:   \catcode`\^^H=\other
Chris@10:   \catcode`\^^K=\other
Chris@10:   \catcode`\^^L=\other
Chris@10:   \catcode`\^^N=\other
Chris@10:   \catcode`\^^P=\other
Chris@10:   \catcode`\^^Q=\other
Chris@10:   \catcode`\^^R=\other
Chris@10:   \catcode`\^^S=\other
Chris@10:   \catcode`\^^T=\other
Chris@10:   \catcode`\^^U=\other
Chris@10:   \catcode`\^^V=\other
Chris@10:   \catcode`\^^W=\other
Chris@10:   \catcode`\^^X=\other
Chris@10:   \catcode`\^^Z=\other
Chris@10:   \catcode`\^^[=\other
Chris@10:   \catcode`\^^\=\other
Chris@10:   \catcode`\^^]=\other
Chris@10:   \catcode`\^^^=\other
Chris@10:   \catcode`\^^_=\other
Chris@10:   % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc.
Chris@10:   % in xref tags, i.e., node names.  But since ^^e4 notation isn't
Chris@10:   % supported in the main text, it doesn't seem desirable.  Furthermore,
Chris@10:   % that is not enough: for node names that actually contain a ^
Chris@10:   % character, we would end up writing a line like this: 'xrdef {'hat
Chris@10:   % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first
Chris@10:   % argument, and \hat is not an expandable control sequence.  It could
Chris@10:   % all be worked out, but why?  Either we support ^^ or we don't.
Chris@10:   %
Chris@10:   % The other change necessary for this was to define \auxhat:
Chris@10:   % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter
Chris@10:   % and then to call \auxhat in \setq.
Chris@10:   %
Chris@10:   \catcode`\^=\other
Chris@10:   %
Chris@10:   % Special characters.  Should be turned off anyway, but...
Chris@10:   \catcode`\~=\other
Chris@10:   \catcode`\[=\other
Chris@10:   \catcode`\]=\other
Chris@10:   \catcode`\"=\other
Chris@10:   \catcode`\_=\other
Chris@10:   \catcode`\|=\other
Chris@10:   \catcode`\<=\other
Chris@10:   \catcode`\>=\other
Chris@10:   \catcode`\$=\other
Chris@10:   \catcode`\#=\other
Chris@10:   \catcode`\&=\other
Chris@10:   \catcode`\%=\other
Chris@10:   \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
Chris@10:   %
Chris@10:   % This is to support \ in node names and titles, since the \
Chris@10:   % characters end up in a \csname.  It's easier than
Chris@10:   % leaving it active and making its active definition an actual \
Chris@10:   % character.  What I don't understand is why it works in the *value*
Chris@10:   % of the xrdef.  Seems like it should be a catcode12 \, and that
Chris@10:   % should not typeset properly.  But it works, so I'm moving on for
Chris@10:   % now.  --karl, 15jan04.
Chris@10:   \catcode`\\=\other
Chris@10:   %
Chris@10:   % Make the characters 128-255 be printing characters.
Chris@10:   {%
Chris@10:     \count1=128
Chris@10:     \def\loop{%
Chris@10:       \catcode\count1=\other
Chris@10:       \advance\count1 by 1
Chris@10:       \ifnum \count1<256 \loop \fi
Chris@10:     }%
Chris@10:   }%
Chris@10:   %
Chris@10:   % @ is our escape character in .aux files, and we need braces.
Chris@10:   \catcode`\{=1
Chris@10:   \catcode`\}=2
Chris@10:   \catcode`\@=0
Chris@10: }
Chris@10: 
Chris@10: \def\readdatafile#1{%
Chris@10: \begingroup
Chris@10:   \setupdatafile
Chris@10:   \input\jobname.#1
Chris@10: \endgroup}
Chris@10: 
Chris@10: 
Chris@10: \message{insertions,}
Chris@10: % including footnotes.
Chris@10: 
Chris@10: \newcount \footnoteno
Chris@10: 
Chris@10: % The trailing space in the following definition for supereject is
Chris@10: % vital for proper filling; pages come out unaligned when you do a
Chris@10: % pagealignmacro call if that space before the closing brace is
Chris@10: % removed. (Generally, numeric constants should always be followed by a
Chris@10: % space to prevent strange expansion errors.)
Chris@10: \def\supereject{\par\penalty -20000\footnoteno =0 }
Chris@10: 
Chris@10: % @footnotestyle is meaningful for Info output only.
Chris@10: \let\footnotestyle=\comment
Chris@10: 
Chris@10: {\catcode `\@=11
Chris@10: %
Chris@10: % Auto-number footnotes.  Otherwise like plain.
Chris@10: \gdef\footnote{%
Chris@10:   \let\indent=\ptexindent
Chris@10:   \let\noindent=\ptexnoindent
Chris@10:   \global\advance\footnoteno by \@ne
Chris@10:   \edef\thisfootno{$^{\the\footnoteno}$}%
Chris@10:   %
Chris@10:   % In case the footnote comes at the end of a sentence, preserve the
Chris@10:   % extra spacing after we do the footnote number.
Chris@10:   \let\@sf\empty
Chris@10:   \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi
Chris@10:   %
Chris@10:   % Remove inadvertent blank space before typesetting the footnote number.
Chris@10:   \unskip
Chris@10:   \thisfootno\@sf
Chris@10:   \dofootnote
Chris@10: }%
Chris@10: 
Chris@10: % Don't bother with the trickery in plain.tex to not require the
Chris@10: % footnote text as a parameter.  Our footnotes don't need to be so general.
Chris@10: %
Chris@10: % Oh yes, they do; otherwise, @ifset (and anything else that uses
Chris@10: % \parseargline) fails inside footnotes because the tokens are fixed when
Chris@10: % the footnote is read.  --karl, 16nov96.
Chris@10: %
Chris@10: \gdef\dofootnote{%
Chris@10:   \insert\footins\bgroup
Chris@10:   % We want to typeset this text as a normal paragraph, even if the
Chris@10:   % footnote reference occurs in (for example) a display environment.
Chris@10:   % So reset some parameters.
Chris@10:   \hsize=\pagewidth
Chris@10:   \interlinepenalty\interfootnotelinepenalty
Chris@10:   \splittopskip\ht\strutbox % top baseline for broken footnotes
Chris@10:   \splitmaxdepth\dp\strutbox
Chris@10:   \floatingpenalty\@MM
Chris@10:   \leftskip\z@skip
Chris@10:   \rightskip\z@skip
Chris@10:   \spaceskip\z@skip
Chris@10:   \xspaceskip\z@skip
Chris@10:   \parindent\defaultparindent
Chris@10:   %
Chris@10:   \smallfonts \rm
Chris@10:   %
Chris@10:   % Because we use hanging indentation in footnotes, a @noindent appears
Chris@10:   % to exdent this text, so make it be a no-op.  makeinfo does not use
Chris@10:   % hanging indentation so @noindent can still be needed within footnote
Chris@10:   % text after an @example or the like (not that this is good style).
Chris@10:   \let\noindent = \relax
Chris@10:   %
Chris@10:   % Hang the footnote text off the number.  Use \everypar in case the
Chris@10:   % footnote extends for more than one paragraph.
Chris@10:   \everypar = {\hang}%
Chris@10:   \textindent{\thisfootno}%
Chris@10:   %
Chris@10:   % Don't crash into the line above the footnote text.  Since this
Chris@10:   % expands into a box, it must come within the paragraph, lest it
Chris@10:   % provide a place where TeX can split the footnote.
Chris@10:   \footstrut
Chris@10:   %
Chris@10:   % Invoke rest of plain TeX footnote routine.
Chris@10:   \futurelet\next\fo@t
Chris@10: }
Chris@10: }%end \catcode `\@=11
Chris@10: 
Chris@10: % In case a @footnote appears in a vbox, save the footnote text and create
Chris@10: % the real \insert just after the vbox finished.  Otherwise, the insertion
Chris@10: % would be lost.
Chris@10: % Similarly, if a @footnote appears inside an alignment, save the footnote
Chris@10: % text to a box and make the \insert when a row of the table is finished.
Chris@10: % And the same can be done for other insert classes.  --kasal, 16nov03.
Chris@10: 
Chris@10: % Replace the \insert primitive by a cheating macro.
Chris@10: % Deeper inside, just make sure that the saved insertions are not spilled
Chris@10: % out prematurely.
Chris@10: %
Chris@10: \def\startsavinginserts{%
Chris@10:   \ifx \insert\ptexinsert
Chris@10:     \let\insert\saveinsert
Chris@10:   \else
Chris@10:     \let\checkinserts\relax
Chris@10:   \fi
Chris@10: }
Chris@10: 
Chris@10: % This \insert replacement works for both \insert\footins{foo} and
Chris@10: % \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}.
Chris@10: %
Chris@10: \def\saveinsert#1{%
Chris@10:   \edef\next{\noexpand\savetobox \makeSAVEname#1}%
Chris@10:   \afterassignment\next
Chris@10:   % swallow the left brace
Chris@10:   \let\temp =
Chris@10: }
Chris@10: \def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}}
Chris@10: \def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1}
Chris@10: 
Chris@10: \def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi}
Chris@10: 
Chris@10: \def\placesaveins#1{%
Chris@10:   \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname
Chris@10:     {\box#1}%
Chris@10: }
Chris@10: 
Chris@10: % eat @SAVE -- beware, all of them have catcode \other:
Chris@10: {
Chris@10:   \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials  %  ;-)
Chris@10:   \gdef\gobblesave @SAVE{}
Chris@10: }
Chris@10: 
Chris@10: % initialization:
Chris@10: \def\newsaveins #1{%
Chris@10:   \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}%
Chris@10:   \next
Chris@10: }
Chris@10: \def\newsaveinsX #1{%
Chris@10:   \csname newbox\endcsname #1%
Chris@10:   \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts
Chris@10:     \checksaveins #1}%
Chris@10: }
Chris@10: 
Chris@10: % initialize:
Chris@10: \let\checkinserts\empty
Chris@10: \newsaveins\footins
Chris@10: \newsaveins\margin
Chris@10: 
Chris@10: 
Chris@10: % @image.  We use the macros from epsf.tex to support this.
Chris@10: % If epsf.tex is not installed and @image is used, we complain.
Chris@10: %
Chris@10: % Check for and read epsf.tex up front.  If we read it only at @image
Chris@10: % time, we might be inside a group, and then its definitions would get
Chris@10: % undone and the next image would fail.
Chris@10: \openin 1 = epsf.tex
Chris@10: \ifeof 1 \else
Chris@10:   % Do not bother showing banner with epsf.tex v2.7k (available in
Chris@10:   % doc/epsf.tex and on ctan).
Chris@10:   \def\epsfannounce{\toks0 = }%
Chris@10:   \input epsf.tex
Chris@10: \fi
Chris@10: \closein 1
Chris@10: %
Chris@10: % We will only complain once about lack of epsf.tex.
Chris@10: \newif\ifwarnednoepsf
Chris@10: \newhelp\noepsfhelp{epsf.tex must be installed for images to
Chris@10:   work.  It is also included in the Texinfo distribution, or you can get
Chris@10:   it from ftp://tug.org/tex/epsf.tex.}
Chris@10: %
Chris@10: \def\image#1{%
Chris@10:   \ifx\epsfbox\thisisundefined
Chris@10:     \ifwarnednoepsf \else
Chris@10:       \errhelp = \noepsfhelp
Chris@10:       \errmessage{epsf.tex not found, images will be ignored}%
Chris@10:       \global\warnednoepsftrue
Chris@10:     \fi
Chris@10:   \else
Chris@10:     \imagexxx #1,,,,,\finish
Chris@10:   \fi
Chris@10: }
Chris@10: %
Chris@10: % Arguments to @image:
Chris@10: % #1 is (mandatory) image filename; we tack on .eps extension.
Chris@10: % #2 is (optional) width, #3 is (optional) height.
Chris@10: % #4 is (ignored optional) html alt text.
Chris@10: % #5 is (ignored optional) extension.
Chris@10: % #6 is just the usual extra ignored arg for parsing stuff.
Chris@10: \newif\ifimagevmode
Chris@10: \def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup
Chris@10:   \catcode`\^^M = 5     % in case we're inside an example
Chris@10:   \normalturnoffactive  % allow _ et al. in names
Chris@10:   % If the image is by itself, center it.
Chris@10:   \ifvmode
Chris@10:     \imagevmodetrue
Chris@10:   \else \ifx\centersub\centerV
Chris@10:     % for @center @image, we need a vbox so we can have our vertical space
Chris@10:     \imagevmodetrue
Chris@10:     \vbox\bgroup % vbox has better behavior than vtop herev
Chris@10:   \fi\fi
Chris@10:   %
Chris@10:   \ifimagevmode
Chris@10:     \nobreak\medskip
Chris@10:     % Usually we'll have text after the image which will insert
Chris@10:     % \parskip glue, so insert it here too to equalize the space
Chris@10:     % above and below.
Chris@10:     \nobreak\vskip\parskip
Chris@10:     \nobreak
Chris@10:   \fi
Chris@10:   %
Chris@10:   % Leave vertical mode so that indentation from an enclosing
Chris@10:   %  environment such as @quotation is respected.
Chris@10:   % However, if we're at the top level, we don't want the
Chris@10:   %  normal paragraph indentation.
Chris@10:   % On the other hand, if we are in the case of @center @image, we don't
Chris@10:   %  want to start a paragraph, which will create a hsize-width box and
Chris@10:   %  eradicate the centering.
Chris@10:   \ifx\centersub\centerV\else \noindent \fi
Chris@10:   %
Chris@10:   % Output the image.
Chris@10:   \ifpdf
Chris@10:     \dopdfimage{#1}{#2}{#3}%
Chris@10:   \else
Chris@10:     % \epsfbox itself resets \epsf?size at each figure.
Chris@10:     \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
Chris@10:     \setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
Chris@10:     \epsfbox{#1.eps}%
Chris@10:   \fi
Chris@10:   %
Chris@10:   \ifimagevmode
Chris@10:     \medskip  % space after a standalone image
Chris@10:   \fi  
Chris@10:   \ifx\centersub\centerV \egroup \fi
Chris@10: \endgroup}
Chris@10: 
Chris@10: 
Chris@10: % @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables,
Chris@10: % etc.  We don't actually implement floating yet, we always include the
Chris@10: % float "here".  But it seemed the best name for the future.
Chris@10: %
Chris@10: \envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish}
Chris@10: 
Chris@10: % There may be a space before second and/or third parameter; delete it.
Chris@10: \def\eatcommaspace#1, {#1,}
Chris@10: 
Chris@10: % #1 is the optional FLOATTYPE, the text label for this float, typically
Chris@10: % "Figure", "Table", "Example", etc.  Can't contain commas.  If omitted,
Chris@10: % this float will not be numbered and cannot be referred to.
Chris@10: %
Chris@10: % #2 is the optional xref label.  Also must be present for the float to
Chris@10: % be referable.
Chris@10: %
Chris@10: % #3 is the optional positioning argument; for now, it is ignored.  It
Chris@10: % will somehow specify the positions allowed to float to (here, top, bottom).
Chris@10: %
Chris@10: % We keep a separate counter for each FLOATTYPE, which we reset at each
Chris@10: % chapter-level command.
Chris@10: \let\resetallfloatnos=\empty
Chris@10: %
Chris@10: \def\dofloat#1,#2,#3,#4\finish{%
Chris@10:   \let\thiscaption=\empty
Chris@10:   \let\thisshortcaption=\empty
Chris@10:   %
Chris@10:   % don't lose footnotes inside @float.
Chris@10:   %
Chris@10:   % BEWARE: when the floats start float, we have to issue warning whenever an
Chris@10:   % insert appears inside a float which could possibly float. --kasal, 26may04
Chris@10:   %
Chris@10:   \startsavinginserts
Chris@10:   %
Chris@10:   % We can't be used inside a paragraph.
Chris@10:   \par
Chris@10:   %
Chris@10:   \vtop\bgroup
Chris@10:     \def\floattype{#1}%
Chris@10:     \def\floatlabel{#2}%
Chris@10:     \def\floatloc{#3}% we do nothing with this yet.
Chris@10:     %
Chris@10:     \ifx\floattype\empty
Chris@10:       \let\safefloattype=\empty
Chris@10:     \else
Chris@10:       {%
Chris@10:         % the floattype might have accents or other special characters,
Chris@10:         % but we need to use it in a control sequence name.
Chris@10:         \indexnofonts
Chris@10:         \turnoffactive
Chris@10:         \xdef\safefloattype{\floattype}%
Chris@10:       }%
Chris@10:     \fi
Chris@10:     %
Chris@10:     % If label is given but no type, we handle that as the empty type.
Chris@10:     \ifx\floatlabel\empty \else
Chris@10:       % We want each FLOATTYPE to be numbered separately (Figure 1,
Chris@10:       % Table 1, Figure 2, ...).  (And if no label, no number.)
Chris@10:       %
Chris@10:       \expandafter\getfloatno\csname\safefloattype floatno\endcsname
Chris@10:       \global\advance\floatno by 1
Chris@10:       %
Chris@10:       {%
Chris@10:         % This magic value for \lastsection is output by \setref as the
Chris@10:         % XREFLABEL-title value.  \xrefX uses it to distinguish float
Chris@10:         % labels (which have a completely different output format) from
Chris@10:         % node and anchor labels.  And \xrdef uses it to construct the
Chris@10:         % lists of floats.
Chris@10:         %
Chris@10:         \edef\lastsection{\floatmagic=\safefloattype}%
Chris@10:         \setref{\floatlabel}{Yfloat}%
Chris@10:       }%
Chris@10:     \fi
Chris@10:     %
Chris@10:     % start with \parskip glue, I guess.
Chris@10:     \vskip\parskip
Chris@10:     %
Chris@10:     % Don't suppress indentation if a float happens to start a section.
Chris@10:     \restorefirstparagraphindent
Chris@10: }
Chris@10: 
Chris@10: % we have these possibilities:
Chris@10: % @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap
Chris@10: % @float Foo,lbl & no caption:    Foo 1.1
Chris@10: % @float Foo & @caption{Cap}:     Foo: Cap
Chris@10: % @float Foo & no caption:        Foo
Chris@10: % @float ,lbl & Caption{Cap}:     1.1: Cap
Chris@10: % @float ,lbl & no caption:       1.1
Chris@10: % @float & @caption{Cap}:         Cap
Chris@10: % @float & no caption:
Chris@10: %
Chris@10: \def\Efloat{%
Chris@10:     \let\floatident = \empty
Chris@10:     %
Chris@10:     % In all cases, if we have a float type, it comes first.
Chris@10:     \ifx\floattype\empty \else \def\floatident{\floattype}\fi
Chris@10:     %
Chris@10:     % If we have an xref label, the number comes next.
Chris@10:     \ifx\floatlabel\empty \else
Chris@10:       \ifx\floattype\empty \else % if also had float type, need tie first.
Chris@10:         \appendtomacro\floatident{\tie}%
Chris@10:       \fi
Chris@10:       % the number.
Chris@10:       \appendtomacro\floatident{\chaplevelprefix\the\floatno}%
Chris@10:     \fi
Chris@10:     %
Chris@10:     % Start the printed caption with what we've constructed in
Chris@10:     % \floatident, but keep it separate; we need \floatident again.
Chris@10:     \let\captionline = \floatident
Chris@10:     %
Chris@10:     \ifx\thiscaption\empty \else
Chris@10:       \ifx\floatident\empty \else
Chris@10: 	\appendtomacro\captionline{: }% had ident, so need a colon between
Chris@10:       \fi
Chris@10:       %
Chris@10:       % caption text.
Chris@10:       \appendtomacro\captionline{\scanexp\thiscaption}%
Chris@10:     \fi
Chris@10:     %
Chris@10:     % If we have anything to print, print it, with space before.
Chris@10:     % Eventually this needs to become an \insert.
Chris@10:     \ifx\captionline\empty \else
Chris@10:       \vskip.5\parskip
Chris@10:       \captionline
Chris@10:       %
Chris@10:       % Space below caption.
Chris@10:       \vskip\parskip
Chris@10:     \fi
Chris@10:     %
Chris@10:     % If have an xref label, write the list of floats info.  Do this
Chris@10:     % after the caption, to avoid chance of it being a breakpoint.
Chris@10:     \ifx\floatlabel\empty \else
Chris@10:       % Write the text that goes in the lof to the aux file as
Chris@10:       % \floatlabel-lof.  Besides \floatident, we include the short
Chris@10:       % caption if specified, else the full caption if specified, else nothing.
Chris@10:       {%
Chris@10:         \atdummies
Chris@10:         %
Chris@10:         % since we read the caption text in the macro world, where ^^M
Chris@10:         % is turned into a normal character, we have to scan it back, so
Chris@10:         % we don't write the literal three characters "^^M" into the aux file.
Chris@10: 	\scanexp{%
Chris@10: 	  \xdef\noexpand\gtemp{%
Chris@10: 	    \ifx\thisshortcaption\empty
Chris@10: 	      \thiscaption
Chris@10: 	    \else
Chris@10: 	      \thisshortcaption
Chris@10: 	    \fi
Chris@10: 	  }%
Chris@10: 	}%
Chris@10:         \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident
Chris@10: 	  \ifx\gtemp\empty \else : \gtemp \fi}}%
Chris@10:       }%
Chris@10:     \fi
Chris@10:   \egroup  % end of \vtop
Chris@10:   %
Chris@10:   % place the captured inserts
Chris@10:   %
Chris@10:   % BEWARE: when the floats start floating, we have to issue warning
Chris@10:   % whenever an insert appears inside a float which could possibly
Chris@10:   % float. --kasal, 26may04
Chris@10:   %
Chris@10:   \checkinserts
Chris@10: }
Chris@10: 
Chris@10: % Append the tokens #2 to the definition of macro #1, not expanding either.
Chris@10: %
Chris@10: \def\appendtomacro#1#2{%
Chris@10:   \expandafter\def\expandafter#1\expandafter{#1#2}%
Chris@10: }
Chris@10: 
Chris@10: % @caption, @shortcaption
Chris@10: %
Chris@10: \def\caption{\docaption\thiscaption}
Chris@10: \def\shortcaption{\docaption\thisshortcaption}
Chris@10: \def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption}
Chris@10: \def\defcaption#1#2{\egroup \def#1{#2}}
Chris@10: 
Chris@10: % The parameter is the control sequence identifying the counter we are
Chris@10: % going to use.  Create it if it doesn't exist and assign it to \floatno.
Chris@10: \def\getfloatno#1{%
Chris@10:   \ifx#1\relax
Chris@10:       % Haven't seen this figure type before.
Chris@10:       \csname newcount\endcsname #1%
Chris@10:       %
Chris@10:       % Remember to reset this floatno at the next chap.
Chris@10:       \expandafter\gdef\expandafter\resetallfloatnos
Chris@10:         \expandafter{\resetallfloatnos #1=0 }%
Chris@10:   \fi
Chris@10:   \let\floatno#1%
Chris@10: }
Chris@10: 
Chris@10: % \setref calls this to get the XREFLABEL-snt value.  We want an @xref
Chris@10: % to the FLOATLABEL to expand to "Figure 3.1".  We call \setref when we
Chris@10: % first read the @float command.
Chris@10: %
Chris@10: \def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}%
Chris@10: 
Chris@10: % Magic string used for the XREFLABEL-title value, so \xrefX can
Chris@10: % distinguish floats from other xref types.
Chris@10: \def\floatmagic{!!float!!}
Chris@10: 
Chris@10: % #1 is the control sequence we are passed; we expand into a conditional
Chris@10: % which is true if #1 represents a float ref.  That is, the magic
Chris@10: % \lastsection value which we \setref above.
Chris@10: %
Chris@10: \def\iffloat#1{\expandafter\doiffloat#1==\finish}
Chris@10: %
Chris@10: % #1 is (maybe) the \floatmagic string.  If so, #2 will be the
Chris@10: % (safe) float type for this float.  We set \iffloattype to #2.
Chris@10: %
Chris@10: \def\doiffloat#1=#2=#3\finish{%
Chris@10:   \def\temp{#1}%
Chris@10:   \def\iffloattype{#2}%
Chris@10:   \ifx\temp\floatmagic
Chris@10: }
Chris@10: 
Chris@10: % @listoffloats FLOATTYPE - print a list of floats like a table of contents.
Chris@10: %
Chris@10: \parseargdef\listoffloats{%
Chris@10:   \def\floattype{#1}% floattype
Chris@10:   {%
Chris@10:     % the floattype might have accents or other special characters,
Chris@10:     % but we need to use it in a control sequence name.
Chris@10:     \indexnofonts
Chris@10:     \turnoffactive
Chris@10:     \xdef\safefloattype{\floattype}%
Chris@10:   }%
Chris@10:   %
Chris@10:   % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE.
Chris@10:   \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax
Chris@10:     \ifhavexrefs
Chris@10:       % if the user said @listoffloats foo but never @float foo.
Chris@10:       \message{\linenumber No `\safefloattype' floats to list.}%
Chris@10:     \fi
Chris@10:   \else
Chris@10:     \begingroup
Chris@10:       \leftskip=\tocindent  % indent these entries like a toc
Chris@10:       \let\do=\listoffloatsdo
Chris@10:       \csname floatlist\safefloattype\endcsname
Chris@10:     \endgroup
Chris@10:   \fi
Chris@10: }
Chris@10: 
Chris@10: % This is called on each entry in a list of floats.  We're passed the
Chris@10: % xref label, in the form LABEL-title, which is how we save it in the
Chris@10: % aux file.  We strip off the -title and look up \XRLABEL-lof, which
Chris@10: % has the text we're supposed to typeset here.
Chris@10: %
Chris@10: % Figures without xref labels will not be included in the list (since
Chris@10: % they won't appear in the aux file).
Chris@10: %
Chris@10: \def\listoffloatsdo#1{\listoffloatsdoentry#1\finish}
Chris@10: \def\listoffloatsdoentry#1-title\finish{{%
Chris@10:   % Can't fully expand XR#1-lof because it can contain anything.  Just
Chris@10:   % pass the control sequence.  On the other hand, XR#1-pg is just the
Chris@10:   % page number, and we want to fully expand that so we can get a link
Chris@10:   % in pdf output.
Chris@10:   \toksA = \expandafter{\csname XR#1-lof\endcsname}%
Chris@10:   %
Chris@10:   % use the same \entry macro we use to generate the TOC and index.
Chris@10:   \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}%
Chris@10:   \writeentry
Chris@10: }}
Chris@10: 
Chris@10: 
Chris@10: \message{localization,}
Chris@10: 
Chris@10: % For single-language documents, @documentlanguage is usually given very
Chris@10: % early, just after @documentencoding.  Single argument is the language
Chris@10: % (de) or locale (de_DE) abbreviation.
Chris@10: %
Chris@10: {
Chris@10:   \catcode`\_ = \active
Chris@10:   \globaldefs=1
Chris@10: \parseargdef\documentlanguage{\begingroup
Chris@10:   \let_=\normalunderscore  % normal _ character for filenames
Chris@10:   \tex % read txi-??.tex file in plain TeX.
Chris@10:     % Read the file by the name they passed if it exists.
Chris@10:     \openin 1 txi-#1.tex
Chris@10:     \ifeof 1
Chris@10:       \documentlanguagetrywithoutunderscore{#1_\finish}%
Chris@10:     \else
Chris@10:       \globaldefs = 1  % everything in the txi-LL files needs to persist
Chris@10:       \input txi-#1.tex
Chris@10:     \fi
Chris@10:     \closein 1
Chris@10:   \endgroup % end raw TeX
Chris@10: \endgroup}
Chris@10: %
Chris@10: % If they passed de_DE, and txi-de_DE.tex doesn't exist,
Chris@10: % try txi-de.tex.
Chris@10: %
Chris@10: \gdef\documentlanguagetrywithoutunderscore#1_#2\finish{%
Chris@10:   \openin 1 txi-#1.tex
Chris@10:   \ifeof 1
Chris@10:     \errhelp = \nolanghelp
Chris@10:     \errmessage{Cannot read language file txi-#1.tex}%
Chris@10:   \else
Chris@10:     \globaldefs = 1  % everything in the txi-LL files needs to persist
Chris@10:     \input txi-#1.tex
Chris@10:   \fi
Chris@10:   \closein 1
Chris@10: }
Chris@10: }% end of special _ catcode
Chris@10: %
Chris@10: \newhelp\nolanghelp{The given language definition file cannot be found or
Chris@10: is empty.  Maybe you need to install it?  Putting it in the current
Chris@10: directory should work if nowhere else does.}
Chris@10: 
Chris@10: % This macro is called from txi-??.tex files; the first argument is the
Chris@10: % \language name to set (without the "\lang@" prefix), the second and
Chris@10: % third args are \{left,right}hyphenmin.
Chris@10: %
Chris@10: % The language names to pass are determined when the format is built.
Chris@10: % See the etex.log file created at that time, e.g.,
Chris@10: % /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log.
Chris@10: %
Chris@10: % With TeX Live 2008, etex now includes hyphenation patterns for all
Chris@10: % available languages.  This means we can support hyphenation in
Chris@10: % Texinfo, at least to some extent.  (This still doesn't solve the
Chris@10: % accented characters problem.)
Chris@10: %
Chris@10: \catcode`@=11
Chris@10: \def\txisetlanguage#1#2#3{%
Chris@10:   % do not set the language if the name is undefined in the current TeX.
Chris@10:   \expandafter\ifx\csname lang@#1\endcsname \relax
Chris@10:     \message{no patterns for #1}%
Chris@10:   \else
Chris@10:     \global\language = \csname lang@#1\endcsname
Chris@10:   \fi
Chris@10:   % but there is no harm in adjusting the hyphenmin values regardless.
Chris@10:   \global\lefthyphenmin = #2\relax
Chris@10:   \global\righthyphenmin = #3\relax
Chris@10: }
Chris@10: 
Chris@10: % Helpers for encodings.
Chris@10: % Set the catcode of characters 128 through 255 to the specified number.
Chris@10: %
Chris@10: \def\setnonasciicharscatcode#1{%
Chris@10:    \count255=128
Chris@10:    \loop\ifnum\count255<256
Chris@10:       \global\catcode\count255=#1\relax
Chris@10:       \advance\count255 by 1
Chris@10:    \repeat
Chris@10: }
Chris@10: 
Chris@10: \def\setnonasciicharscatcodenonglobal#1{%
Chris@10:    \count255=128
Chris@10:    \loop\ifnum\count255<256
Chris@10:       \catcode\count255=#1\relax
Chris@10:       \advance\count255 by 1
Chris@10:    \repeat
Chris@10: }
Chris@10: 
Chris@10: % @documentencoding sets the definition of non-ASCII characters
Chris@10: % according to the specified encoding.
Chris@10: %
Chris@10: \parseargdef\documentencoding{%
Chris@10:   % Encoding being declared for the document.
Chris@10:   \def\declaredencoding{\csname #1.enc\endcsname}%
Chris@10:   %
Chris@10:   % Supported encodings: names converted to tokens in order to be able
Chris@10:   % to compare them with \ifx.
Chris@10:   \def\ascii{\csname US-ASCII.enc\endcsname}%
Chris@10:   \def\latnine{\csname ISO-8859-15.enc\endcsname}%
Chris@10:   \def\latone{\csname ISO-8859-1.enc\endcsname}%
Chris@10:   \def\lattwo{\csname ISO-8859-2.enc\endcsname}%
Chris@10:   \def\utfeight{\csname UTF-8.enc\endcsname}%
Chris@10:   %
Chris@10:   \ifx \declaredencoding \ascii
Chris@10:      \asciichardefs
Chris@10:   %
Chris@10:   \else \ifx \declaredencoding \lattwo
Chris@10:      \setnonasciicharscatcode\active
Chris@10:      \lattwochardefs
Chris@10:   %
Chris@10:   \else \ifx \declaredencoding \latone
Chris@10:      \setnonasciicharscatcode\active
Chris@10:      \latonechardefs
Chris@10:   %
Chris@10:   \else \ifx \declaredencoding \latnine
Chris@10:      \setnonasciicharscatcode\active
Chris@10:      \latninechardefs
Chris@10:   %
Chris@10:   \else \ifx \declaredencoding \utfeight
Chris@10:      \setnonasciicharscatcode\active
Chris@10:      \utfeightchardefs
Chris@10:   %
Chris@10:   \else
Chris@10:     \message{Unknown document encoding #1, ignoring.}%
Chris@10:   %
Chris@10:   \fi % utfeight
Chris@10:   \fi % latnine
Chris@10:   \fi % latone
Chris@10:   \fi % lattwo
Chris@10:   \fi % ascii
Chris@10: }
Chris@10: 
Chris@10: % A message to be logged when using a character that isn't available
Chris@10: % the default font encoding (OT1).
Chris@10: %
Chris@10: \def\missingcharmsg#1{\message{Character missing in OT1 encoding: #1.}}
Chris@10: 
Chris@10: % Take account of \c (plain) vs. \, (Texinfo) difference.
Chris@10: \def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi}
Chris@10: 
Chris@10: % First, make active non-ASCII characters in order for them to be
Chris@10: % correctly categorized when TeX reads the replacement text of
Chris@10: % macros containing the character definitions.
Chris@10: \setnonasciicharscatcode\active
Chris@10: %
Chris@10: % Latin1 (ISO-8859-1) character definitions.
Chris@10: \def\latonechardefs{%
Chris@10:   \gdef^^a0{\tie}
Chris@10:   \gdef^^a1{\exclamdown}
Chris@10:   \gdef^^a2{\missingcharmsg{CENT SIGN}}
Chris@10:   \gdef^^a3{{\pounds}}
Chris@10:   \gdef^^a4{\missingcharmsg{CURRENCY SIGN}}
Chris@10:   \gdef^^a5{\missingcharmsg{YEN SIGN}}
Chris@10:   \gdef^^a6{\missingcharmsg{BROKEN BAR}}
Chris@10:   \gdef^^a7{\S}
Chris@10:   \gdef^^a8{\"{}}
Chris@10:   \gdef^^a9{\copyright}
Chris@10:   \gdef^^aa{\ordf}
Chris@10:   \gdef^^ab{\guillemetleft}
Chris@10:   \gdef^^ac{$\lnot$}
Chris@10:   \gdef^^ad{\-}
Chris@10:   \gdef^^ae{\registeredsymbol}
Chris@10:   \gdef^^af{\={}}
Chris@10:   %
Chris@10:   \gdef^^b0{\textdegree}
Chris@10:   \gdef^^b1{$\pm$}
Chris@10:   \gdef^^b2{$^2$}
Chris@10:   \gdef^^b3{$^3$}
Chris@10:   \gdef^^b4{\'{}}
Chris@10:   \gdef^^b5{$\mu$}
Chris@10:   \gdef^^b6{\P}
Chris@10:   %
Chris@10:   \gdef^^b7{$^.$}
Chris@10:   \gdef^^b8{\cedilla\ }
Chris@10:   \gdef^^b9{$^1$}
Chris@10:   \gdef^^ba{\ordm}
Chris@10:   %
Chris@10:   \gdef^^bb{\guillemetright}
Chris@10:   \gdef^^bc{$1\over4$}
Chris@10:   \gdef^^bd{$1\over2$}
Chris@10:   \gdef^^be{$3\over4$}
Chris@10:   \gdef^^bf{\questiondown}
Chris@10:   %
Chris@10:   \gdef^^c0{\`A}
Chris@10:   \gdef^^c1{\'A}
Chris@10:   \gdef^^c2{\^A}
Chris@10:   \gdef^^c3{\~A}
Chris@10:   \gdef^^c4{\"A}
Chris@10:   \gdef^^c5{\ringaccent A}
Chris@10:   \gdef^^c6{\AE}
Chris@10:   \gdef^^c7{\cedilla C}
Chris@10:   \gdef^^c8{\`E}
Chris@10:   \gdef^^c9{\'E}
Chris@10:   \gdef^^ca{\^E}
Chris@10:   \gdef^^cb{\"E}
Chris@10:   \gdef^^cc{\`I}
Chris@10:   \gdef^^cd{\'I}
Chris@10:   \gdef^^ce{\^I}
Chris@10:   \gdef^^cf{\"I}
Chris@10:   %
Chris@10:   \gdef^^d0{\DH}
Chris@10:   \gdef^^d1{\~N}
Chris@10:   \gdef^^d2{\`O}
Chris@10:   \gdef^^d3{\'O}
Chris@10:   \gdef^^d4{\^O}
Chris@10:   \gdef^^d5{\~O}
Chris@10:   \gdef^^d6{\"O}
Chris@10:   \gdef^^d7{$\times$}
Chris@10:   \gdef^^d8{\O}
Chris@10:   \gdef^^d9{\`U}
Chris@10:   \gdef^^da{\'U}
Chris@10:   \gdef^^db{\^U}
Chris@10:   \gdef^^dc{\"U}
Chris@10:   \gdef^^dd{\'Y}
Chris@10:   \gdef^^de{\TH}
Chris@10:   \gdef^^df{\ss}
Chris@10:   %
Chris@10:   \gdef^^e0{\`a}
Chris@10:   \gdef^^e1{\'a}
Chris@10:   \gdef^^e2{\^a}
Chris@10:   \gdef^^e3{\~a}
Chris@10:   \gdef^^e4{\"a}
Chris@10:   \gdef^^e5{\ringaccent a}
Chris@10:   \gdef^^e6{\ae}
Chris@10:   \gdef^^e7{\cedilla c}
Chris@10:   \gdef^^e8{\`e}
Chris@10:   \gdef^^e9{\'e}
Chris@10:   \gdef^^ea{\^e}
Chris@10:   \gdef^^eb{\"e}
Chris@10:   \gdef^^ec{\`{\dotless i}}
Chris@10:   \gdef^^ed{\'{\dotless i}}
Chris@10:   \gdef^^ee{\^{\dotless i}}
Chris@10:   \gdef^^ef{\"{\dotless i}}
Chris@10:   %
Chris@10:   \gdef^^f0{\dh}
Chris@10:   \gdef^^f1{\~n}
Chris@10:   \gdef^^f2{\`o}
Chris@10:   \gdef^^f3{\'o}
Chris@10:   \gdef^^f4{\^o}
Chris@10:   \gdef^^f5{\~o}
Chris@10:   \gdef^^f6{\"o}
Chris@10:   \gdef^^f7{$\div$}
Chris@10:   \gdef^^f8{\o}
Chris@10:   \gdef^^f9{\`u}
Chris@10:   \gdef^^fa{\'u}
Chris@10:   \gdef^^fb{\^u}
Chris@10:   \gdef^^fc{\"u}
Chris@10:   \gdef^^fd{\'y}
Chris@10:   \gdef^^fe{\th}
Chris@10:   \gdef^^ff{\"y}
Chris@10: }
Chris@10: 
Chris@10: % Latin9 (ISO-8859-15) encoding character definitions.
Chris@10: \def\latninechardefs{%
Chris@10:   % Encoding is almost identical to Latin1.
Chris@10:   \latonechardefs
Chris@10:   %
Chris@10:   \gdef^^a4{\euro}
Chris@10:   \gdef^^a6{\v S}
Chris@10:   \gdef^^a8{\v s}
Chris@10:   \gdef^^b4{\v Z}
Chris@10:   \gdef^^b8{\v z}
Chris@10:   \gdef^^bc{\OE}
Chris@10:   \gdef^^bd{\oe}
Chris@10:   \gdef^^be{\"Y}
Chris@10: }
Chris@10: 
Chris@10: % Latin2 (ISO-8859-2) character definitions.
Chris@10: \def\lattwochardefs{%
Chris@10:   \gdef^^a0{\tie}
Chris@10:   \gdef^^a1{\ogonek{A}}
Chris@10:   \gdef^^a2{\u{}}
Chris@10:   \gdef^^a3{\L}
Chris@10:   \gdef^^a4{\missingcharmsg{CURRENCY SIGN}}
Chris@10:   \gdef^^a5{\v L}
Chris@10:   \gdef^^a6{\'S}
Chris@10:   \gdef^^a7{\S}
Chris@10:   \gdef^^a8{\"{}}
Chris@10:   \gdef^^a9{\v S}
Chris@10:   \gdef^^aa{\cedilla S}
Chris@10:   \gdef^^ab{\v T}
Chris@10:   \gdef^^ac{\'Z}
Chris@10:   \gdef^^ad{\-}
Chris@10:   \gdef^^ae{\v Z}
Chris@10:   \gdef^^af{\dotaccent Z}
Chris@10:   %
Chris@10:   \gdef^^b0{\textdegree}
Chris@10:   \gdef^^b1{\ogonek{a}}
Chris@10:   \gdef^^b2{\ogonek{ }}
Chris@10:   \gdef^^b3{\l}
Chris@10:   \gdef^^b4{\'{}}
Chris@10:   \gdef^^b5{\v l}
Chris@10:   \gdef^^b6{\'s}
Chris@10:   \gdef^^b7{\v{}}
Chris@10:   \gdef^^b8{\cedilla\ }
Chris@10:   \gdef^^b9{\v s}
Chris@10:   \gdef^^ba{\cedilla s}
Chris@10:   \gdef^^bb{\v t}
Chris@10:   \gdef^^bc{\'z}
Chris@10:   \gdef^^bd{\H{}}
Chris@10:   \gdef^^be{\v z}
Chris@10:   \gdef^^bf{\dotaccent z}
Chris@10:   %
Chris@10:   \gdef^^c0{\'R}
Chris@10:   \gdef^^c1{\'A}
Chris@10:   \gdef^^c2{\^A}
Chris@10:   \gdef^^c3{\u A}
Chris@10:   \gdef^^c4{\"A}
Chris@10:   \gdef^^c5{\'L}
Chris@10:   \gdef^^c6{\'C}
Chris@10:   \gdef^^c7{\cedilla C}
Chris@10:   \gdef^^c8{\v C}
Chris@10:   \gdef^^c9{\'E}
Chris@10:   \gdef^^ca{\ogonek{E}}
Chris@10:   \gdef^^cb{\"E}
Chris@10:   \gdef^^cc{\v E}
Chris@10:   \gdef^^cd{\'I}
Chris@10:   \gdef^^ce{\^I}
Chris@10:   \gdef^^cf{\v D}
Chris@10:   %
Chris@10:   \gdef^^d0{\DH}
Chris@10:   \gdef^^d1{\'N}
Chris@10:   \gdef^^d2{\v N}
Chris@10:   \gdef^^d3{\'O}
Chris@10:   \gdef^^d4{\^O}
Chris@10:   \gdef^^d5{\H O}
Chris@10:   \gdef^^d6{\"O}
Chris@10:   \gdef^^d7{$\times$}
Chris@10:   \gdef^^d8{\v R}
Chris@10:   \gdef^^d9{\ringaccent U}
Chris@10:   \gdef^^da{\'U}
Chris@10:   \gdef^^db{\H U}
Chris@10:   \gdef^^dc{\"U}
Chris@10:   \gdef^^dd{\'Y}
Chris@10:   \gdef^^de{\cedilla T}
Chris@10:   \gdef^^df{\ss}
Chris@10:   %
Chris@10:   \gdef^^e0{\'r}
Chris@10:   \gdef^^e1{\'a}
Chris@10:   \gdef^^e2{\^a}
Chris@10:   \gdef^^e3{\u a}
Chris@10:   \gdef^^e4{\"a}
Chris@10:   \gdef^^e5{\'l}
Chris@10:   \gdef^^e6{\'c}
Chris@10:   \gdef^^e7{\cedilla c}
Chris@10:   \gdef^^e8{\v c}
Chris@10:   \gdef^^e9{\'e}
Chris@10:   \gdef^^ea{\ogonek{e}}
Chris@10:   \gdef^^eb{\"e}
Chris@10:   \gdef^^ec{\v e}
Chris@10:   \gdef^^ed{\'{\dotless{i}}}
Chris@10:   \gdef^^ee{\^{\dotless{i}}}
Chris@10:   \gdef^^ef{\v d}
Chris@10:   %
Chris@10:   \gdef^^f0{\dh}
Chris@10:   \gdef^^f1{\'n}
Chris@10:   \gdef^^f2{\v n}
Chris@10:   \gdef^^f3{\'o}
Chris@10:   \gdef^^f4{\^o}
Chris@10:   \gdef^^f5{\H o}
Chris@10:   \gdef^^f6{\"o}
Chris@10:   \gdef^^f7{$\div$}
Chris@10:   \gdef^^f8{\v r}
Chris@10:   \gdef^^f9{\ringaccent u}
Chris@10:   \gdef^^fa{\'u}
Chris@10:   \gdef^^fb{\H u}
Chris@10:   \gdef^^fc{\"u}
Chris@10:   \gdef^^fd{\'y}
Chris@10:   \gdef^^fe{\cedilla t}
Chris@10:   \gdef^^ff{\dotaccent{}}
Chris@10: }
Chris@10: 
Chris@10: % UTF-8 character definitions.
Chris@10: %
Chris@10: % This code to support UTF-8 is based on LaTeX's utf8.def, with some
Chris@10: % changes for Texinfo conventions.  It is included here under the GPL by
Chris@10: % permission from Frank Mittelbach and the LaTeX team.
Chris@10: %
Chris@10: \newcount\countUTFx
Chris@10: \newcount\countUTFy
Chris@10: \newcount\countUTFz
Chris@10: 
Chris@10: \gdef\UTFviiiTwoOctets#1#2{\expandafter
Chris@10:    \UTFviiiDefined\csname u8:#1\string #2\endcsname}
Chris@10: %
Chris@10: \gdef\UTFviiiThreeOctets#1#2#3{\expandafter
Chris@10:    \UTFviiiDefined\csname u8:#1\string #2\string #3\endcsname}
Chris@10: %
Chris@10: \gdef\UTFviiiFourOctets#1#2#3#4{\expandafter
Chris@10:    \UTFviiiDefined\csname u8:#1\string #2\string #3\string #4\endcsname}
Chris@10: 
Chris@10: \gdef\UTFviiiDefined#1{%
Chris@10:   \ifx #1\relax
Chris@10:     \message{\linenumber Unicode char \string #1 not defined for Texinfo}%
Chris@10:   \else
Chris@10:     \expandafter #1%
Chris@10:   \fi
Chris@10: }
Chris@10: 
Chris@10: \begingroup
Chris@10:   \catcode`\~13
Chris@10:   \catcode`\"12
Chris@10: 
Chris@10:   \def\UTFviiiLoop{%
Chris@10:     \global\catcode\countUTFx\active
Chris@10:     \uccode`\~\countUTFx
Chris@10:     \uppercase\expandafter{\UTFviiiTmp}%
Chris@10:     \advance\countUTFx by 1
Chris@10:     \ifnum\countUTFx < \countUTFy
Chris@10:       \expandafter\UTFviiiLoop
Chris@10:     \fi}
Chris@10: 
Chris@10:   \countUTFx = "C2
Chris@10:   \countUTFy = "E0
Chris@10:   \def\UTFviiiTmp{%
Chris@10:     \xdef~{\noexpand\UTFviiiTwoOctets\string~}}
Chris@10:   \UTFviiiLoop
Chris@10: 
Chris@10:   \countUTFx = "E0
Chris@10:   \countUTFy = "F0
Chris@10:   \def\UTFviiiTmp{%
Chris@10:     \xdef~{\noexpand\UTFviiiThreeOctets\string~}}
Chris@10:   \UTFviiiLoop
Chris@10: 
Chris@10:   \countUTFx = "F0
Chris@10:   \countUTFy = "F4
Chris@10:   \def\UTFviiiTmp{%
Chris@10:     \xdef~{\noexpand\UTFviiiFourOctets\string~}}
Chris@10:   \UTFviiiLoop
Chris@10: \endgroup
Chris@10: 
Chris@10: \begingroup
Chris@10:   \catcode`\"=12
Chris@10:   \catcode`\<=12
Chris@10:   \catcode`\.=12
Chris@10:   \catcode`\,=12
Chris@10:   \catcode`\;=12
Chris@10:   \catcode`\!=12
Chris@10:   \catcode`\~=13
Chris@10: 
Chris@10:   \gdef\DeclareUnicodeCharacter#1#2{%
Chris@10:     \countUTFz = "#1\relax
Chris@10:     %\wlog{\space\space defining Unicode char U+#1 (decimal \the\countUTFz)}%
Chris@10:     \begingroup
Chris@10:       \parseXMLCharref
Chris@10:       \def\UTFviiiTwoOctets##1##2{%
Chris@10:         \csname u8:##1\string ##2\endcsname}%
Chris@10:       \def\UTFviiiThreeOctets##1##2##3{%
Chris@10:         \csname u8:##1\string ##2\string ##3\endcsname}%
Chris@10:       \def\UTFviiiFourOctets##1##2##3##4{%
Chris@10:         \csname u8:##1\string ##2\string ##3\string ##4\endcsname}%
Chris@10:       \expandafter\expandafter\expandafter\expandafter
Chris@10:        \expandafter\expandafter\expandafter
Chris@10:        \gdef\UTFviiiTmp{#2}%
Chris@10:     \endgroup}
Chris@10: 
Chris@10:   \gdef\parseXMLCharref{%
Chris@10:     \ifnum\countUTFz < "A0\relax
Chris@10:       \errhelp = \EMsimple
Chris@10:       \errmessage{Cannot define Unicode char value < 00A0}%
Chris@10:     \else\ifnum\countUTFz < "800\relax
Chris@10:       \parseUTFviiiA,%
Chris@10:       \parseUTFviiiB C\UTFviiiTwoOctets.,%
Chris@10:     \else\ifnum\countUTFz < "10000\relax
Chris@10:       \parseUTFviiiA;%
Chris@10:       \parseUTFviiiA,%
Chris@10:       \parseUTFviiiB E\UTFviiiThreeOctets.{,;}%
Chris@10:     \else
Chris@10:       \parseUTFviiiA;%
Chris@10:       \parseUTFviiiA,%
Chris@10:       \parseUTFviiiA!%
Chris@10:       \parseUTFviiiB F\UTFviiiFourOctets.{!,;}%
Chris@10:     \fi\fi\fi
Chris@10:   }
Chris@10: 
Chris@10:   \gdef\parseUTFviiiA#1{%
Chris@10:     \countUTFx = \countUTFz
Chris@10:     \divide\countUTFz by 64
Chris@10:     \countUTFy = \countUTFz
Chris@10:     \multiply\countUTFz by 64
Chris@10:     \advance\countUTFx by -\countUTFz
Chris@10:     \advance\countUTFx by 128
Chris@10:     \uccode `#1\countUTFx
Chris@10:     \countUTFz = \countUTFy}
Chris@10: 
Chris@10:   \gdef\parseUTFviiiB#1#2#3#4{%
Chris@10:     \advance\countUTFz by "#10\relax
Chris@10:     \uccode `#3\countUTFz
Chris@10:     \uppercase{\gdef\UTFviiiTmp{#2#3#4}}}
Chris@10: \endgroup
Chris@10: 
Chris@10: \def\utfeightchardefs{%
Chris@10:   \DeclareUnicodeCharacter{00A0}{\tie}
Chris@10:   \DeclareUnicodeCharacter{00A1}{\exclamdown}
Chris@10:   \DeclareUnicodeCharacter{00A3}{\pounds}
Chris@10:   \DeclareUnicodeCharacter{00A8}{\"{ }}
Chris@10:   \DeclareUnicodeCharacter{00A9}{\copyright}
Chris@10:   \DeclareUnicodeCharacter{00AA}{\ordf}
Chris@10:   \DeclareUnicodeCharacter{00AB}{\guillemetleft}
Chris@10:   \DeclareUnicodeCharacter{00AD}{\-}
Chris@10:   \DeclareUnicodeCharacter{00AE}{\registeredsymbol}
Chris@10:   \DeclareUnicodeCharacter{00AF}{\={ }}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{00B0}{\ringaccent{ }}
Chris@10:   \DeclareUnicodeCharacter{00B4}{\'{ }}
Chris@10:   \DeclareUnicodeCharacter{00B8}{\cedilla{ }}
Chris@10:   \DeclareUnicodeCharacter{00BA}{\ordm}
Chris@10:   \DeclareUnicodeCharacter{00BB}{\guillemetright}
Chris@10:   \DeclareUnicodeCharacter{00BF}{\questiondown}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{00C0}{\`A}
Chris@10:   \DeclareUnicodeCharacter{00C1}{\'A}
Chris@10:   \DeclareUnicodeCharacter{00C2}{\^A}
Chris@10:   \DeclareUnicodeCharacter{00C3}{\~A}
Chris@10:   \DeclareUnicodeCharacter{00C4}{\"A}
Chris@10:   \DeclareUnicodeCharacter{00C5}{\AA}
Chris@10:   \DeclareUnicodeCharacter{00C6}{\AE}
Chris@10:   \DeclareUnicodeCharacter{00C7}{\cedilla{C}}
Chris@10:   \DeclareUnicodeCharacter{00C8}{\`E}
Chris@10:   \DeclareUnicodeCharacter{00C9}{\'E}
Chris@10:   \DeclareUnicodeCharacter{00CA}{\^E}
Chris@10:   \DeclareUnicodeCharacter{00CB}{\"E}
Chris@10:   \DeclareUnicodeCharacter{00CC}{\`I}
Chris@10:   \DeclareUnicodeCharacter{00CD}{\'I}
Chris@10:   \DeclareUnicodeCharacter{00CE}{\^I}
Chris@10:   \DeclareUnicodeCharacter{00CF}{\"I}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{00D0}{\DH}
Chris@10:   \DeclareUnicodeCharacter{00D1}{\~N}
Chris@10:   \DeclareUnicodeCharacter{00D2}{\`O}
Chris@10:   \DeclareUnicodeCharacter{00D3}{\'O}
Chris@10:   \DeclareUnicodeCharacter{00D4}{\^O}
Chris@10:   \DeclareUnicodeCharacter{00D5}{\~O}
Chris@10:   \DeclareUnicodeCharacter{00D6}{\"O}
Chris@10:   \DeclareUnicodeCharacter{00D8}{\O}
Chris@10:   \DeclareUnicodeCharacter{00D9}{\`U}
Chris@10:   \DeclareUnicodeCharacter{00DA}{\'U}
Chris@10:   \DeclareUnicodeCharacter{00DB}{\^U}
Chris@10:   \DeclareUnicodeCharacter{00DC}{\"U}
Chris@10:   \DeclareUnicodeCharacter{00DD}{\'Y}
Chris@10:   \DeclareUnicodeCharacter{00DE}{\TH}
Chris@10:   \DeclareUnicodeCharacter{00DF}{\ss}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{00E0}{\`a}
Chris@10:   \DeclareUnicodeCharacter{00E1}{\'a}
Chris@10:   \DeclareUnicodeCharacter{00E2}{\^a}
Chris@10:   \DeclareUnicodeCharacter{00E3}{\~a}
Chris@10:   \DeclareUnicodeCharacter{00E4}{\"a}
Chris@10:   \DeclareUnicodeCharacter{00E5}{\aa}
Chris@10:   \DeclareUnicodeCharacter{00E6}{\ae}
Chris@10:   \DeclareUnicodeCharacter{00E7}{\cedilla{c}}
Chris@10:   \DeclareUnicodeCharacter{00E8}{\`e}
Chris@10:   \DeclareUnicodeCharacter{00E9}{\'e}
Chris@10:   \DeclareUnicodeCharacter{00EA}{\^e}
Chris@10:   \DeclareUnicodeCharacter{00EB}{\"e}
Chris@10:   \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}}
Chris@10:   \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}}
Chris@10:   \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}}
Chris@10:   \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{00F0}{\dh}
Chris@10:   \DeclareUnicodeCharacter{00F1}{\~n}
Chris@10:   \DeclareUnicodeCharacter{00F2}{\`o}
Chris@10:   \DeclareUnicodeCharacter{00F3}{\'o}
Chris@10:   \DeclareUnicodeCharacter{00F4}{\^o}
Chris@10:   \DeclareUnicodeCharacter{00F5}{\~o}
Chris@10:   \DeclareUnicodeCharacter{00F6}{\"o}
Chris@10:   \DeclareUnicodeCharacter{00F8}{\o}
Chris@10:   \DeclareUnicodeCharacter{00F9}{\`u}
Chris@10:   \DeclareUnicodeCharacter{00FA}{\'u}
Chris@10:   \DeclareUnicodeCharacter{00FB}{\^u}
Chris@10:   \DeclareUnicodeCharacter{00FC}{\"u}
Chris@10:   \DeclareUnicodeCharacter{00FD}{\'y}
Chris@10:   \DeclareUnicodeCharacter{00FE}{\th}
Chris@10:   \DeclareUnicodeCharacter{00FF}{\"y}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{0100}{\=A}
Chris@10:   \DeclareUnicodeCharacter{0101}{\=a}
Chris@10:   \DeclareUnicodeCharacter{0102}{\u{A}}
Chris@10:   \DeclareUnicodeCharacter{0103}{\u{a}}
Chris@10:   \DeclareUnicodeCharacter{0104}{\ogonek{A}}
Chris@10:   \DeclareUnicodeCharacter{0105}{\ogonek{a}}
Chris@10:   \DeclareUnicodeCharacter{0106}{\'C}
Chris@10:   \DeclareUnicodeCharacter{0107}{\'c}
Chris@10:   \DeclareUnicodeCharacter{0108}{\^C}
Chris@10:   \DeclareUnicodeCharacter{0109}{\^c}
Chris@10:   \DeclareUnicodeCharacter{0118}{\ogonek{E}}
Chris@10:   \DeclareUnicodeCharacter{0119}{\ogonek{e}}
Chris@10:   \DeclareUnicodeCharacter{010A}{\dotaccent{C}}
Chris@10:   \DeclareUnicodeCharacter{010B}{\dotaccent{c}}
Chris@10:   \DeclareUnicodeCharacter{010C}{\v{C}}
Chris@10:   \DeclareUnicodeCharacter{010D}{\v{c}}
Chris@10:   \DeclareUnicodeCharacter{010E}{\v{D}}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{0112}{\=E}
Chris@10:   \DeclareUnicodeCharacter{0113}{\=e}
Chris@10:   \DeclareUnicodeCharacter{0114}{\u{E}}
Chris@10:   \DeclareUnicodeCharacter{0115}{\u{e}}
Chris@10:   \DeclareUnicodeCharacter{0116}{\dotaccent{E}}
Chris@10:   \DeclareUnicodeCharacter{0117}{\dotaccent{e}}
Chris@10:   \DeclareUnicodeCharacter{011A}{\v{E}}
Chris@10:   \DeclareUnicodeCharacter{011B}{\v{e}}
Chris@10:   \DeclareUnicodeCharacter{011C}{\^G}
Chris@10:   \DeclareUnicodeCharacter{011D}{\^g}
Chris@10:   \DeclareUnicodeCharacter{011E}{\u{G}}
Chris@10:   \DeclareUnicodeCharacter{011F}{\u{g}}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{0120}{\dotaccent{G}}
Chris@10:   \DeclareUnicodeCharacter{0121}{\dotaccent{g}}
Chris@10:   \DeclareUnicodeCharacter{0124}{\^H}
Chris@10:   \DeclareUnicodeCharacter{0125}{\^h}
Chris@10:   \DeclareUnicodeCharacter{0128}{\~I}
Chris@10:   \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}}
Chris@10:   \DeclareUnicodeCharacter{012A}{\=I}
Chris@10:   \DeclareUnicodeCharacter{012B}{\={\dotless{i}}}
Chris@10:   \DeclareUnicodeCharacter{012C}{\u{I}}
Chris@10:   \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{0130}{\dotaccent{I}}
Chris@10:   \DeclareUnicodeCharacter{0131}{\dotless{i}}
Chris@10:   \DeclareUnicodeCharacter{0132}{IJ}
Chris@10:   \DeclareUnicodeCharacter{0133}{ij}
Chris@10:   \DeclareUnicodeCharacter{0134}{\^J}
Chris@10:   \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}}
Chris@10:   \DeclareUnicodeCharacter{0139}{\'L}
Chris@10:   \DeclareUnicodeCharacter{013A}{\'l}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{0141}{\L}
Chris@10:   \DeclareUnicodeCharacter{0142}{\l}
Chris@10:   \DeclareUnicodeCharacter{0143}{\'N}
Chris@10:   \DeclareUnicodeCharacter{0144}{\'n}
Chris@10:   \DeclareUnicodeCharacter{0147}{\v{N}}
Chris@10:   \DeclareUnicodeCharacter{0148}{\v{n}}
Chris@10:   \DeclareUnicodeCharacter{014C}{\=O}
Chris@10:   \DeclareUnicodeCharacter{014D}{\=o}
Chris@10:   \DeclareUnicodeCharacter{014E}{\u{O}}
Chris@10:   \DeclareUnicodeCharacter{014F}{\u{o}}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{0150}{\H{O}}
Chris@10:   \DeclareUnicodeCharacter{0151}{\H{o}}
Chris@10:   \DeclareUnicodeCharacter{0152}{\OE}
Chris@10:   \DeclareUnicodeCharacter{0153}{\oe}
Chris@10:   \DeclareUnicodeCharacter{0154}{\'R}
Chris@10:   \DeclareUnicodeCharacter{0155}{\'r}
Chris@10:   \DeclareUnicodeCharacter{0158}{\v{R}}
Chris@10:   \DeclareUnicodeCharacter{0159}{\v{r}}
Chris@10:   \DeclareUnicodeCharacter{015A}{\'S}
Chris@10:   \DeclareUnicodeCharacter{015B}{\'s}
Chris@10:   \DeclareUnicodeCharacter{015C}{\^S}
Chris@10:   \DeclareUnicodeCharacter{015D}{\^s}
Chris@10:   \DeclareUnicodeCharacter{015E}{\cedilla{S}}
Chris@10:   \DeclareUnicodeCharacter{015F}{\cedilla{s}}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{0160}{\v{S}}
Chris@10:   \DeclareUnicodeCharacter{0161}{\v{s}}
Chris@10:   \DeclareUnicodeCharacter{0162}{\cedilla{t}}
Chris@10:   \DeclareUnicodeCharacter{0163}{\cedilla{T}}
Chris@10:   \DeclareUnicodeCharacter{0164}{\v{T}}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{0168}{\~U}
Chris@10:   \DeclareUnicodeCharacter{0169}{\~u}
Chris@10:   \DeclareUnicodeCharacter{016A}{\=U}
Chris@10:   \DeclareUnicodeCharacter{016B}{\=u}
Chris@10:   \DeclareUnicodeCharacter{016C}{\u{U}}
Chris@10:   \DeclareUnicodeCharacter{016D}{\u{u}}
Chris@10:   \DeclareUnicodeCharacter{016E}{\ringaccent{U}}
Chris@10:   \DeclareUnicodeCharacter{016F}{\ringaccent{u}}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{0170}{\H{U}}
Chris@10:   \DeclareUnicodeCharacter{0171}{\H{u}}
Chris@10:   \DeclareUnicodeCharacter{0174}{\^W}
Chris@10:   \DeclareUnicodeCharacter{0175}{\^w}
Chris@10:   \DeclareUnicodeCharacter{0176}{\^Y}
Chris@10:   \DeclareUnicodeCharacter{0177}{\^y}
Chris@10:   \DeclareUnicodeCharacter{0178}{\"Y}
Chris@10:   \DeclareUnicodeCharacter{0179}{\'Z}
Chris@10:   \DeclareUnicodeCharacter{017A}{\'z}
Chris@10:   \DeclareUnicodeCharacter{017B}{\dotaccent{Z}}
Chris@10:   \DeclareUnicodeCharacter{017C}{\dotaccent{z}}
Chris@10:   \DeclareUnicodeCharacter{017D}{\v{Z}}
Chris@10:   \DeclareUnicodeCharacter{017E}{\v{z}}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{01C4}{D\v{Z}}
Chris@10:   \DeclareUnicodeCharacter{01C5}{D\v{z}}
Chris@10:   \DeclareUnicodeCharacter{01C6}{d\v{z}}
Chris@10:   \DeclareUnicodeCharacter{01C7}{LJ}
Chris@10:   \DeclareUnicodeCharacter{01C8}{Lj}
Chris@10:   \DeclareUnicodeCharacter{01C9}{lj}
Chris@10:   \DeclareUnicodeCharacter{01CA}{NJ}
Chris@10:   \DeclareUnicodeCharacter{01CB}{Nj}
Chris@10:   \DeclareUnicodeCharacter{01CC}{nj}
Chris@10:   \DeclareUnicodeCharacter{01CD}{\v{A}}
Chris@10:   \DeclareUnicodeCharacter{01CE}{\v{a}}
Chris@10:   \DeclareUnicodeCharacter{01CF}{\v{I}}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}}
Chris@10:   \DeclareUnicodeCharacter{01D1}{\v{O}}
Chris@10:   \DeclareUnicodeCharacter{01D2}{\v{o}}
Chris@10:   \DeclareUnicodeCharacter{01D3}{\v{U}}
Chris@10:   \DeclareUnicodeCharacter{01D4}{\v{u}}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{01E2}{\={\AE}}
Chris@10:   \DeclareUnicodeCharacter{01E3}{\={\ae}}
Chris@10:   \DeclareUnicodeCharacter{01E6}{\v{G}}
Chris@10:   \DeclareUnicodeCharacter{01E7}{\v{g}}
Chris@10:   \DeclareUnicodeCharacter{01E8}{\v{K}}
Chris@10:   \DeclareUnicodeCharacter{01E9}{\v{k}}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}}
Chris@10:   \DeclareUnicodeCharacter{01F1}{DZ}
Chris@10:   \DeclareUnicodeCharacter{01F2}{Dz}
Chris@10:   \DeclareUnicodeCharacter{01F3}{dz}
Chris@10:   \DeclareUnicodeCharacter{01F4}{\'G}
Chris@10:   \DeclareUnicodeCharacter{01F5}{\'g}
Chris@10:   \DeclareUnicodeCharacter{01F8}{\`N}
Chris@10:   \DeclareUnicodeCharacter{01F9}{\`n}
Chris@10:   \DeclareUnicodeCharacter{01FC}{\'{\AE}}
Chris@10:   \DeclareUnicodeCharacter{01FD}{\'{\ae}}
Chris@10:   \DeclareUnicodeCharacter{01FE}{\'{\O}}
Chris@10:   \DeclareUnicodeCharacter{01FF}{\'{\o}}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{021E}{\v{H}}
Chris@10:   \DeclareUnicodeCharacter{021F}{\v{h}}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{0226}{\dotaccent{A}}
Chris@10:   \DeclareUnicodeCharacter{0227}{\dotaccent{a}}
Chris@10:   \DeclareUnicodeCharacter{0228}{\cedilla{E}}
Chris@10:   \DeclareUnicodeCharacter{0229}{\cedilla{e}}
Chris@10:   \DeclareUnicodeCharacter{022E}{\dotaccent{O}}
Chris@10:   \DeclareUnicodeCharacter{022F}{\dotaccent{o}}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{0232}{\=Y}
Chris@10:   \DeclareUnicodeCharacter{0233}{\=y}
Chris@10:   \DeclareUnicodeCharacter{0237}{\dotless{j}}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{02DB}{\ogonek{ }}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{1E02}{\dotaccent{B}}
Chris@10:   \DeclareUnicodeCharacter{1E03}{\dotaccent{b}}
Chris@10:   \DeclareUnicodeCharacter{1E04}{\udotaccent{B}}
Chris@10:   \DeclareUnicodeCharacter{1E05}{\udotaccent{b}}
Chris@10:   \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}}
Chris@10:   \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}}
Chris@10:   \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}}
Chris@10:   \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}}
Chris@10:   \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}}
Chris@10:   \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}}
Chris@10:   \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}}
Chris@10:   \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}}
Chris@10:   \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{1E20}{\=G}
Chris@10:   \DeclareUnicodeCharacter{1E21}{\=g}
Chris@10:   \DeclareUnicodeCharacter{1E22}{\dotaccent{H}}
Chris@10:   \DeclareUnicodeCharacter{1E23}{\dotaccent{h}}
Chris@10:   \DeclareUnicodeCharacter{1E24}{\udotaccent{H}}
Chris@10:   \DeclareUnicodeCharacter{1E25}{\udotaccent{h}}
Chris@10:   \DeclareUnicodeCharacter{1E26}{\"H}
Chris@10:   \DeclareUnicodeCharacter{1E27}{\"h}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{1E30}{\'K}
Chris@10:   \DeclareUnicodeCharacter{1E31}{\'k}
Chris@10:   \DeclareUnicodeCharacter{1E32}{\udotaccent{K}}
Chris@10:   \DeclareUnicodeCharacter{1E33}{\udotaccent{k}}
Chris@10:   \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}}
Chris@10:   \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}}
Chris@10:   \DeclareUnicodeCharacter{1E36}{\udotaccent{L}}
Chris@10:   \DeclareUnicodeCharacter{1E37}{\udotaccent{l}}
Chris@10:   \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}}
Chris@10:   \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}}
Chris@10:   \DeclareUnicodeCharacter{1E3E}{\'M}
Chris@10:   \DeclareUnicodeCharacter{1E3F}{\'m}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{1E40}{\dotaccent{M}}
Chris@10:   \DeclareUnicodeCharacter{1E41}{\dotaccent{m}}
Chris@10:   \DeclareUnicodeCharacter{1E42}{\udotaccent{M}}
Chris@10:   \DeclareUnicodeCharacter{1E43}{\udotaccent{m}}
Chris@10:   \DeclareUnicodeCharacter{1E44}{\dotaccent{N}}
Chris@10:   \DeclareUnicodeCharacter{1E45}{\dotaccent{n}}
Chris@10:   \DeclareUnicodeCharacter{1E46}{\udotaccent{N}}
Chris@10:   \DeclareUnicodeCharacter{1E47}{\udotaccent{n}}
Chris@10:   \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}}
Chris@10:   \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{1E54}{\'P}
Chris@10:   \DeclareUnicodeCharacter{1E55}{\'p}
Chris@10:   \DeclareUnicodeCharacter{1E56}{\dotaccent{P}}
Chris@10:   \DeclareUnicodeCharacter{1E57}{\dotaccent{p}}
Chris@10:   \DeclareUnicodeCharacter{1E58}{\dotaccent{R}}
Chris@10:   \DeclareUnicodeCharacter{1E59}{\dotaccent{r}}
Chris@10:   \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}}
Chris@10:   \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}}
Chris@10:   \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}}
Chris@10:   \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{1E60}{\dotaccent{S}}
Chris@10:   \DeclareUnicodeCharacter{1E61}{\dotaccent{s}}
Chris@10:   \DeclareUnicodeCharacter{1E62}{\udotaccent{S}}
Chris@10:   \DeclareUnicodeCharacter{1E63}{\udotaccent{s}}
Chris@10:   \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}}
Chris@10:   \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}}
Chris@10:   \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}}
Chris@10:   \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}}
Chris@10:   \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}}
Chris@10:   \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{1E7C}{\~V}
Chris@10:   \DeclareUnicodeCharacter{1E7D}{\~v}
Chris@10:   \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}}
Chris@10:   \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{1E80}{\`W}
Chris@10:   \DeclareUnicodeCharacter{1E81}{\`w}
Chris@10:   \DeclareUnicodeCharacter{1E82}{\'W}
Chris@10:   \DeclareUnicodeCharacter{1E83}{\'w}
Chris@10:   \DeclareUnicodeCharacter{1E84}{\"W}
Chris@10:   \DeclareUnicodeCharacter{1E85}{\"w}
Chris@10:   \DeclareUnicodeCharacter{1E86}{\dotaccent{W}}
Chris@10:   \DeclareUnicodeCharacter{1E87}{\dotaccent{w}}
Chris@10:   \DeclareUnicodeCharacter{1E88}{\udotaccent{W}}
Chris@10:   \DeclareUnicodeCharacter{1E89}{\udotaccent{w}}
Chris@10:   \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}}
Chris@10:   \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}}
Chris@10:   \DeclareUnicodeCharacter{1E8C}{\"X}
Chris@10:   \DeclareUnicodeCharacter{1E8D}{\"x}
Chris@10:   \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}}
Chris@10:   \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{1E90}{\^Z}
Chris@10:   \DeclareUnicodeCharacter{1E91}{\^z}
Chris@10:   \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}}
Chris@10:   \DeclareUnicodeCharacter{1E93}{\udotaccent{z}}
Chris@10:   \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}}
Chris@10:   \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}}
Chris@10:   \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}}
Chris@10:   \DeclareUnicodeCharacter{1E97}{\"t}
Chris@10:   \DeclareUnicodeCharacter{1E98}{\ringaccent{w}}
Chris@10:   \DeclareUnicodeCharacter{1E99}{\ringaccent{y}}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}}
Chris@10:   \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}}
Chris@10:   \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}}
Chris@10:   \DeclareUnicodeCharacter{1EBC}{\~E}
Chris@10:   \DeclareUnicodeCharacter{1EBD}{\~e}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}}
Chris@10:   \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}}
Chris@10:   \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}}
Chris@10:   \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}}
Chris@10:   \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{1EF2}{\`Y}
Chris@10:   \DeclareUnicodeCharacter{1EF3}{\`y}
Chris@10:   \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{1EF8}{\~Y}
Chris@10:   \DeclareUnicodeCharacter{1EF9}{\~y}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{2013}{--}
Chris@10:   \DeclareUnicodeCharacter{2014}{---}
Chris@10:   \DeclareUnicodeCharacter{2018}{\quoteleft}
Chris@10:   \DeclareUnicodeCharacter{2019}{\quoteright}
Chris@10:   \DeclareUnicodeCharacter{201A}{\quotesinglbase}
Chris@10:   \DeclareUnicodeCharacter{201C}{\quotedblleft}
Chris@10:   \DeclareUnicodeCharacter{201D}{\quotedblright}
Chris@10:   \DeclareUnicodeCharacter{201E}{\quotedblbase}
Chris@10:   \DeclareUnicodeCharacter{2022}{\bullet}
Chris@10:   \DeclareUnicodeCharacter{2026}{\dots}
Chris@10:   \DeclareUnicodeCharacter{2039}{\guilsinglleft}
Chris@10:   \DeclareUnicodeCharacter{203A}{\guilsinglright}
Chris@10:   \DeclareUnicodeCharacter{20AC}{\euro}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{2192}{\expansion}
Chris@10:   \DeclareUnicodeCharacter{21D2}{\result}
Chris@10: 
Chris@10:   \DeclareUnicodeCharacter{2212}{\minus}
Chris@10:   \DeclareUnicodeCharacter{2217}{\point}
Chris@10:   \DeclareUnicodeCharacter{2261}{\equiv}
Chris@10: }% end of \utfeightchardefs
Chris@10: 
Chris@10: 
Chris@10: % US-ASCII character definitions.
Chris@10: \def\asciichardefs{% nothing need be done
Chris@10:    \relax
Chris@10: }
Chris@10: 
Chris@10: % Make non-ASCII characters printable again for compatibility with
Chris@10: % existing Texinfo documents that may use them, even without declaring a
Chris@10: % document encoding.
Chris@10: %
Chris@10: \setnonasciicharscatcode \other
Chris@10: 
Chris@10: 
Chris@10: \message{formatting,}
Chris@10: 
Chris@10: \newdimen\defaultparindent \defaultparindent = 15pt
Chris@10: 
Chris@10: \chapheadingskip = 15pt plus 4pt minus 2pt
Chris@10: \secheadingskip = 12pt plus 3pt minus 2pt
Chris@10: \subsecheadingskip = 9pt plus 2pt minus 2pt
Chris@10: 
Chris@10: % Prevent underfull vbox error messages.
Chris@10: \vbadness = 10000
Chris@10: 
Chris@10: % Don't be very finicky about underfull hboxes, either.
Chris@10: \hbadness = 6666
Chris@10: 
Chris@10: % Following George Bush, get rid of widows and orphans.
Chris@10: \widowpenalty=10000
Chris@10: \clubpenalty=10000
Chris@10: 
Chris@10: % Use TeX 3.0's \emergencystretch to help line breaking, but if we're
Chris@10: % using an old version of TeX, don't do anything.  We want the amount of
Chris@10: % stretch added to depend on the line length, hence the dependence on
Chris@10: % \hsize.  We call this whenever the paper size is set.
Chris@10: %
Chris@10: \def\setemergencystretch{%
Chris@10:   \ifx\emergencystretch\thisisundefined
Chris@10:     % Allow us to assign to \emergencystretch anyway.
Chris@10:     \def\emergencystretch{\dimen0}%
Chris@10:   \else
Chris@10:     \emergencystretch = .15\hsize
Chris@10:   \fi
Chris@10: }
Chris@10: 
Chris@10: % Parameters in order: 1) textheight; 2) textwidth;
Chris@10: % 3) voffset; 4) hoffset; 5) binding offset; 6) topskip;
Chris@10: % 7) physical page height; 8) physical page width.
Chris@10: %
Chris@10: % We also call \setleading{\textleading}, so the caller should define
Chris@10: % \textleading.  The caller should also set \parskip.
Chris@10: %
Chris@10: \def\internalpagesizes#1#2#3#4#5#6#7#8{%
Chris@10:   \voffset = #3\relax
Chris@10:   \topskip = #6\relax
Chris@10:   \splittopskip = \topskip
Chris@10:   %
Chris@10:   \vsize = #1\relax
Chris@10:   \advance\vsize by \topskip
Chris@10:   \outervsize = \vsize
Chris@10:   \advance\outervsize by 2\topandbottommargin
Chris@10:   \pageheight = \vsize
Chris@10:   %
Chris@10:   \hsize = #2\relax
Chris@10:   \outerhsize = \hsize
Chris@10:   \advance\outerhsize by 0.5in
Chris@10:   \pagewidth = \hsize
Chris@10:   %
Chris@10:   \normaloffset = #4\relax
Chris@10:   \bindingoffset = #5\relax
Chris@10:   %
Chris@10:   \ifpdf
Chris@10:     \pdfpageheight #7\relax
Chris@10:     \pdfpagewidth #8\relax
Chris@10:     % if we don't reset these, they will remain at "1 true in" of
Chris@10:     % whatever layout pdftex was dumped with.
Chris@10:     \pdfhorigin = 1 true in
Chris@10:     \pdfvorigin = 1 true in
Chris@10:   \fi
Chris@10:   %
Chris@10:   \setleading{\textleading}
Chris@10:   %
Chris@10:   \parindent = \defaultparindent
Chris@10:   \setemergencystretch
Chris@10: }
Chris@10: 
Chris@10: % @letterpaper (the default).
Chris@10: \def\letterpaper{{\globaldefs = 1
Chris@10:   \parskip = 3pt plus 2pt minus 1pt
Chris@10:   \textleading = 13.2pt
Chris@10:   %
Chris@10:   % If page is nothing but text, make it come out even.
Chris@10:   \internalpagesizes{607.2pt}{6in}% that's 46 lines
Chris@10:                     {\voffset}{.25in}%
Chris@10:                     {\bindingoffset}{36pt}%
Chris@10:                     {11in}{8.5in}%
Chris@10: }}
Chris@10: 
Chris@10: % Use @smallbook to reset parameters for 7x9.25 trim size.
Chris@10: \def\smallbook{{\globaldefs = 1
Chris@10:   \parskip = 2pt plus 1pt
Chris@10:   \textleading = 12pt
Chris@10:   %
Chris@10:   \internalpagesizes{7.5in}{5in}%
Chris@10:                     {-.2in}{0in}%
Chris@10:                     {\bindingoffset}{16pt}%
Chris@10:                     {9.25in}{7in}%
Chris@10:   %
Chris@10:   \lispnarrowing = 0.3in
Chris@10:   \tolerance = 700
Chris@10:   \hfuzz = 1pt
Chris@10:   \contentsrightmargin = 0pt
Chris@10:   \defbodyindent = .5cm
Chris@10: }}
Chris@10: 
Chris@10: % Use @smallerbook to reset parameters for 6x9 trim size.
Chris@10: % (Just testing, parameters still in flux.)
Chris@10: \def\smallerbook{{\globaldefs = 1
Chris@10:   \parskip = 1.5pt plus 1pt
Chris@10:   \textleading = 12pt
Chris@10:   %
Chris@10:   \internalpagesizes{7.4in}{4.8in}%
Chris@10:                     {-.2in}{-.4in}%
Chris@10:                     {0pt}{14pt}%
Chris@10:                     {9in}{6in}%
Chris@10:   %
Chris@10:   \lispnarrowing = 0.25in
Chris@10:   \tolerance = 700
Chris@10:   \hfuzz = 1pt
Chris@10:   \contentsrightmargin = 0pt
Chris@10:   \defbodyindent = .4cm
Chris@10: }}
Chris@10: 
Chris@10: % Use @afourpaper to print on European A4 paper.
Chris@10: \def\afourpaper{{\globaldefs = 1
Chris@10:   \parskip = 3pt plus 2pt minus 1pt
Chris@10:   \textleading = 13.2pt
Chris@10:   %
Chris@10:   % Double-side printing via postscript on Laserjet 4050
Chris@10:   % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm.
Chris@10:   % To change the settings for a different printer or situation, adjust
Chris@10:   % \normaloffset until the front-side and back-side texts align.  Then
Chris@10:   % do the same for \bindingoffset.  You can set these for testing in
Chris@10:   % your texinfo source file like this:
Chris@10:   % @tex
Chris@10:   % \global\normaloffset = -6mm
Chris@10:   % \global\bindingoffset = 10mm
Chris@10:   % @end tex
Chris@10:   \internalpagesizes{673.2pt}{160mm}% that's 51 lines
Chris@10:                     {\voffset}{\hoffset}%
Chris@10:                     {\bindingoffset}{44pt}%
Chris@10:                     {297mm}{210mm}%
Chris@10:   %
Chris@10:   \tolerance = 700
Chris@10:   \hfuzz = 1pt
Chris@10:   \contentsrightmargin = 0pt
Chris@10:   \defbodyindent = 5mm
Chris@10: }}
Chris@10: 
Chris@10: % Use @afivepaper to print on European A5 paper.
Chris@10: % From romildo@urano.iceb.ufop.br, 2 July 2000.
Chris@10: % He also recommends making @example and @lisp be small.
Chris@10: \def\afivepaper{{\globaldefs = 1
Chris@10:   \parskip = 2pt plus 1pt minus 0.1pt
Chris@10:   \textleading = 12.5pt
Chris@10:   %
Chris@10:   \internalpagesizes{160mm}{120mm}%
Chris@10:                     {\voffset}{\hoffset}%
Chris@10:                     {\bindingoffset}{8pt}%
Chris@10:                     {210mm}{148mm}%
Chris@10:   %
Chris@10:   \lispnarrowing = 0.2in
Chris@10:   \tolerance = 800
Chris@10:   \hfuzz = 1.2pt
Chris@10:   \contentsrightmargin = 0pt
Chris@10:   \defbodyindent = 2mm
Chris@10:   \tableindent = 12mm
Chris@10: }}
Chris@10: 
Chris@10: % A specific text layout, 24x15cm overall, intended for A4 paper.
Chris@10: \def\afourlatex{{\globaldefs = 1
Chris@10:   \afourpaper
Chris@10:   \internalpagesizes{237mm}{150mm}%
Chris@10:                     {\voffset}{4.6mm}%
Chris@10:                     {\bindingoffset}{7mm}%
Chris@10:                     {297mm}{210mm}%
Chris@10:   %
Chris@10:   % Must explicitly reset to 0 because we call \afourpaper.
Chris@10:   \globaldefs = 0
Chris@10: }}
Chris@10: 
Chris@10: % Use @afourwide to print on A4 paper in landscape format.
Chris@10: \def\afourwide{{\globaldefs = 1
Chris@10:   \afourpaper
Chris@10:   \internalpagesizes{241mm}{165mm}%
Chris@10:                     {\voffset}{-2.95mm}%
Chris@10:                     {\bindingoffset}{7mm}%
Chris@10:                     {297mm}{210mm}%
Chris@10:   \globaldefs = 0
Chris@10: }}
Chris@10: 
Chris@10: % @pagesizes TEXTHEIGHT[,TEXTWIDTH]
Chris@10: % Perhaps we should allow setting the margins, \topskip, \parskip,
Chris@10: % and/or leading, also. Or perhaps we should compute them somehow.
Chris@10: %
Chris@10: \parseargdef\pagesizes{\pagesizesyyy #1,,\finish}
Chris@10: \def\pagesizesyyy#1,#2,#3\finish{{%
Chris@10:   \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi
Chris@10:   \globaldefs = 1
Chris@10:   %
Chris@10:   \parskip = 3pt plus 2pt minus 1pt
Chris@10:   \setleading{\textleading}%
Chris@10:   %
Chris@10:   \dimen0 = #1\relax
Chris@10:   \advance\dimen0 by \voffset
Chris@10:   %
Chris@10:   \dimen2 = \hsize
Chris@10:   \advance\dimen2 by \normaloffset
Chris@10:   %
Chris@10:   \internalpagesizes{#1}{\hsize}%
Chris@10:                     {\voffset}{\normaloffset}%
Chris@10:                     {\bindingoffset}{44pt}%
Chris@10:                     {\dimen0}{\dimen2}%
Chris@10: }}
Chris@10: 
Chris@10: % Set default to letter.
Chris@10: %
Chris@10: \letterpaper
Chris@10: 
Chris@10: 
Chris@10: \message{and turning on texinfo input format.}
Chris@10: 
Chris@10: \def^^L{\par} % remove \outer, so ^L can appear in an @comment
Chris@10: 
Chris@10: % DEL is a comment character, in case @c does not suffice.
Chris@10: \catcode`\^^? = 14
Chris@10: 
Chris@10: % Define macros to output various characters with catcode for normal text.
Chris@10: \catcode`\"=\other \def\normaldoublequote{"}
Chris@10: \catcode`\$=\other \def\normaldollar{$}%$ font-lock fix
Chris@10: \catcode`\+=\other \def\normalplus{+}
Chris@10: \catcode`\<=\other \def\normalless{<}
Chris@10: \catcode`\>=\other \def\normalgreater{>}
Chris@10: \catcode`\^=\other \def\normalcaret{^}
Chris@10: \catcode`\_=\other \def\normalunderscore{_}
Chris@10: \catcode`\|=\other \def\normalverticalbar{|}
Chris@10: \catcode`\~=\other \def\normaltilde{~}
Chris@10: 
Chris@10: % This macro is used to make a character print one way in \tt
Chris@10: % (where it can probably be output as-is), and another way in other fonts,
Chris@10: % where something hairier probably needs to be done.
Chris@10: %
Chris@10: % #1 is what to print if we are indeed using \tt; #2 is what to print
Chris@10: % otherwise.  Since all the Computer Modern typewriter fonts have zero
Chris@10: % interword stretch (and shrink), and it is reasonable to expect all
Chris@10: % typewriter fonts to have this, we can check that font parameter.
Chris@10: %
Chris@10: \def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi}
Chris@10: 
Chris@10: % Same as above, but check for italic font.  Actually this also catches
Chris@10: % non-italic slanted fonts since it is impossible to distinguish them from
Chris@10: % italic fonts.  But since this is only used by $ and it uses \sl anyway
Chris@10: % this is not a problem.
Chris@10: \def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi}
Chris@10: 
Chris@10: % Turn off all special characters except @
Chris@10: % (and those which the user can use as if they were ordinary).
Chris@10: % Most of these we simply print from the \tt font, but for some, we can
Chris@10: % use math or other variants that look better in normal text.
Chris@10: 
Chris@10: \catcode`\"=\active
Chris@10: \def\activedoublequote{{\tt\char34}}
Chris@10: \let"=\activedoublequote
Chris@10: \catcode`\~=\active
Chris@10: \def~{{\tt\char126}}
Chris@10: \chardef\hat=`\^
Chris@10: \catcode`\^=\active
Chris@10: \def^{{\tt \hat}}
Chris@10: 
Chris@10: \catcode`\_=\active
Chris@10: \def_{\ifusingtt\normalunderscore\_}
Chris@10: \let\realunder=_
Chris@10: % Subroutine for the previous macro.
Chris@10: \def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }
Chris@10: 
Chris@10: \catcode`\|=\active
Chris@10: \def|{{\tt\char124}}
Chris@10: \chardef \less=`\<
Chris@10: \catcode`\<=\active
Chris@10: \def<{{\tt \less}}
Chris@10: \chardef \gtr=`\>
Chris@10: \catcode`\>=\active
Chris@10: \def>{{\tt \gtr}}
Chris@10: \catcode`\+=\active
Chris@10: \def+{{\tt \char 43}}
Chris@10: \catcode`\$=\active
Chris@10: \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix
Chris@10: 
Chris@10: % If a .fmt file is being used, characters that might appear in a file
Chris@10: % name cannot be active until we have parsed the command line.
Chris@10: % So turn them off again, and have \everyjob (or @setfilename) turn them on.
Chris@10: % \otherifyactive is called near the end of this file.
Chris@10: \def\otherifyactive{\catcode`+=\other \catcode`\_=\other}
Chris@10: 
Chris@10: % Used sometimes to turn off (effectively) the active characters even after
Chris@10: % parsing them.
Chris@10: \def\turnoffactive{%
Chris@10:   \normalturnoffactive
Chris@10:   \otherbackslash
Chris@10: }
Chris@10: 
Chris@10: \catcode`\@=0
Chris@10: 
Chris@10: % \backslashcurfont outputs one backslash character in current font,
Chris@10: % as in \char`\\.
Chris@10: \global\chardef\backslashcurfont=`\\
Chris@10: \global\let\rawbackslashxx=\backslashcurfont  % let existing .??s files work
Chris@10: 
Chris@10: % \realbackslash is an actual character `\' with catcode other, and
Chris@10: % \doublebackslash is two of them (for the pdf outlines).
Chris@10: {\catcode`\\=\other @gdef@realbackslash{\} @gdef@doublebackslash{\\}}
Chris@10: 
Chris@10: % In texinfo, backslash is an active character; it prints the backslash
Chris@10: % in fixed width font.
Chris@10: \catcode`\\=\active  % @ for escape char from now on.
Chris@10: 
Chris@10: % The story here is that in math mode, the \char of \backslashcurfont
Chris@10: % ends up printing the roman \ from the math symbol font (because \char
Chris@10: % in math mode uses the \mathcode, and plain.tex sets
Chris@10: % \mathcode`\\="026E).  It seems better for @backslashchar{} to always
Chris@10: % print a typewriter backslash, hence we use an explicit \mathchar,
Chris@10: % which is the decimal equivalent of "715c (class 7, e.g., use \fam;
Chris@10: % ignored family value; char position "5C).  We can't use " for the
Chris@10: % usual hex value because it has already been made active.
Chris@10: @def@normalbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}}
Chris@10: @let@backslashchar = @normalbackslash % @backslashchar{} is for user documents.
Chris@10: 
Chris@10: % On startup, @fixbackslash assigns:
Chris@10: %  @let \ = @normalbackslash
Chris@10: % \rawbackslash defines an active \ to do \backslashcurfont.
Chris@10: % \otherbackslash defines an active \ to be a literal `\' character with
Chris@10: % catcode other.  We switch back and forth between these.
Chris@10: @gdef@rawbackslash{@let\=@backslashcurfont}
Chris@10: @gdef@otherbackslash{@let\=@realbackslash}
Chris@10: 
Chris@10: % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
Chris@10: % the literal character `\'.
Chris@10: %
Chris@10: @def@normalturnoffactive{%
Chris@10:   @let"=@normaldoublequote
Chris@10:   @let$=@normaldollar %$ font-lock fix
Chris@10:   @let+=@normalplus
Chris@10:   @let<=@normalless
Chris@10:   @let>=@normalgreater
Chris@10:   @let\=@normalbackslash
Chris@10:   @let^=@normalcaret
Chris@10:   @let_=@normalunderscore
Chris@10:   @let|=@normalverticalbar
Chris@10:   @let~=@normaltilde
Chris@10:   @markupsetuplqdefault
Chris@10:   @markupsetuprqdefault
Chris@10:   @unsepspaces
Chris@10: }
Chris@10: 
Chris@10: % Make _ and + \other characters, temporarily.
Chris@10: % This is canceled by @fixbackslash.
Chris@10: @otherifyactive
Chris@10: 
Chris@10: % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
Chris@10: % That is what \eatinput is for; after that, the `\' should revert to printing
Chris@10: % a backslash.
Chris@10: %
Chris@10: @gdef@eatinput input texinfo{@fixbackslash}
Chris@10: @global@let\ = @eatinput
Chris@10: 
Chris@10: % On the other hand, perhaps the file did not have a `\input texinfo'. Then
Chris@10: % the first `\' in the file would cause an error. This macro tries to fix
Chris@10: % that, assuming it is called before the first `\' could plausibly occur.
Chris@10: % Also turn back on active characters that might appear in the input
Chris@10: % file name, in case not using a pre-dumped format.
Chris@10: %
Chris@10: @gdef@fixbackslash{%
Chris@10:   @ifx\@eatinput @let\ = @normalbackslash @fi
Chris@10:   @catcode`+=@active
Chris@10:   @catcode`@_=@active
Chris@10: }
Chris@10: 
Chris@10: % Say @foo, not \foo, in error messages.
Chris@10: @escapechar = `@@
Chris@10: 
Chris@10: % These (along with & and #) are made active for url-breaking, so need
Chris@10: % active definitions as the normal characters.
Chris@10: @def@normaldot{.}
Chris@10: @def@normalquest{?}
Chris@10: @def@normalslash{/}
Chris@10: 
Chris@10: % These look ok in all fonts, so just make them not special.
Chris@10: % @hashchar{} gets its own user-level command, because of #line.
Chris@10: @catcode`@& = @other @def@normalamp{&}
Chris@10: @catcode`@# = @other @def@normalhash{#}
Chris@10: @catcode`@% = @other @def@normalpercent{%}
Chris@10: 
Chris@10: @let @hashchar = @normalhash
Chris@10: 
Chris@10: @c Finally, make ` and ' active, so that txicodequoteundirected and
Chris@10: @c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}.  If we
Chris@10: @c don't make ` and ' active, @code will not get them as active chars.
Chris@10: @c Do this last of all since we use ` in the previous @catcode assignments.
Chris@10: @catcode`@'=@active
Chris@10: @catcode`@`=@active
Chris@10: @markupsetuplqdefault
Chris@10: @markupsetuprqdefault
Chris@10: 
Chris@10: @c Local variables:
Chris@10: @c eval: (add-hook 'write-file-hooks 'time-stamp)
Chris@10: @c page-delimiter: "^\\\\message"
Chris@10: @c time-stamp-start: "def\\\\texinfoversion{"
Chris@10: @c time-stamp-format: "%:y-%02m-%02d.%02H"
Chris@10: @c time-stamp-end: "}"
Chris@10: @c End:
Chris@10: 
Chris@10: @c vim:sw=2:
Chris@10: 
Chris@10: @ignore
Chris@10:    arch-tag: e1b36e32-c96e-4135-a41a-0b2efa2ea115
Chris@10: @end ignore




