Chris@42: % texinfo.tex -- TeX macros to handle Texinfo files.
Chris@42: %
Chris@42: % Load plain if necessary, i.e., if running under initex.
Chris@42: \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi
Chris@42: %
Chris@42: \def\texinfoversion{2013-02-01.11}
Chris@42: %
Chris@42: % Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995,
Chris@42: % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
Chris@42: % 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc.
Chris@42: %
Chris@42: % This texinfo.tex file is free software: you can redistribute it and/or
Chris@42: % modify it under the terms of the GNU General Public License as
Chris@42: % published by the Free Software Foundation, either version 3 of the
Chris@42: % License, or (at your option) any later version.
Chris@42: %
Chris@42: % This texinfo.tex file is distributed in the hope that it will be
Chris@42: % useful, but WITHOUT ANY WARRANTY; without even the implied warranty
Chris@42: % of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Chris@42: % General Public License for more details.
Chris@42: %
Chris@42: % You should have received a copy of the GNU General Public License
Chris@42: % along with this program. If not, see .
Chris@42: %
Chris@42: % As a special exception, when this file is read by TeX when processing
Chris@42: % a Texinfo source document, you may use the result without
Chris@42: % restriction. This Exception is an additional permission under section 7
Chris@42: % of the GNU General Public License, version 3 ("GPLv3").
Chris@42: %
Chris@42: % Please try the latest version of texinfo.tex before submitting bug
Chris@42: % reports; you can get the latest version from:
Chris@42: % http://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or
Chris@42: % http://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or
Chris@42: % http://www.gnu.org/software/texinfo/ (the Texinfo home page)
Chris@42: % The texinfo.tex in any given distribution could well be out
Chris@42: % of date, so if that's what you're using, please check.
Chris@42: %
Chris@42: % Send bug reports to bug-texinfo@gnu.org. Please include including a
Chris@42: % complete document in each bug report with which we can reproduce the
Chris@42: % problem. Patches are, of course, greatly appreciated.
Chris@42: %
Chris@42: % To process a Texinfo manual with TeX, it's most reliable to use the
Chris@42: % texi2dvi shell script that comes with the distribution. For a simple
Chris@42: % manual foo.texi, however, you can get away with this:
Chris@42: % tex foo.texi
Chris@42: % texindex foo.??
Chris@42: % tex foo.texi
Chris@42: % tex foo.texi
Chris@42: % dvips foo.dvi -o # or whatever; this makes foo.ps.
Chris@42: % The extra TeX runs get the cross-reference information correct.
Chris@42: % Sometimes one run after texindex suffices, and sometimes you need more
Chris@42: % than two; texi2dvi does it as many times as necessary.
Chris@42: %
Chris@42: % It is possible to adapt texinfo.tex for other languages, to some
Chris@42: % extent. You can get the existing language-specific files from the
Chris@42: % full Texinfo distribution.
Chris@42: %
Chris@42: % The GNU Texinfo home page is http://www.gnu.org/software/texinfo.
Chris@42:
Chris@42:
Chris@42: \message{Loading texinfo [version \texinfoversion]:}
Chris@42:
Chris@42: % If in a .fmt file, print the version number
Chris@42: % and turn on active characters that we couldn't do earlier because
Chris@42: % they might have appeared in the input file name.
Chris@42: \everyjob{\message{[Texinfo version \texinfoversion]}%
Chris@42: \catcode`+=\active \catcode`\_=\active}
Chris@42:
Chris@42: \chardef\other=12
Chris@42:
Chris@42: % We never want plain's \outer definition of \+ in Texinfo.
Chris@42: % For @tex, we can use \tabalign.
Chris@42: \let\+ = \relax
Chris@42:
Chris@42: % Save some plain tex macros whose names we will redefine.
Chris@42: \let\ptexb=\b
Chris@42: \let\ptexbullet=\bullet
Chris@42: \let\ptexc=\c
Chris@42: \let\ptexcomma=\,
Chris@42: \let\ptexdot=\.
Chris@42: \let\ptexdots=\dots
Chris@42: \let\ptexend=\end
Chris@42: \let\ptexequiv=\equiv
Chris@42: \let\ptexexclam=\!
Chris@42: \let\ptexfootnote=\footnote
Chris@42: \let\ptexgtr=>
Chris@42: \let\ptexhat=^
Chris@42: \let\ptexi=\i
Chris@42: \let\ptexindent=\indent
Chris@42: \let\ptexinsert=\insert
Chris@42: \let\ptexlbrace=\{
Chris@42: \let\ptexless=<
Chris@42: \let\ptexnewwrite\newwrite
Chris@42: \let\ptexnoindent=\noindent
Chris@42: \let\ptexplus=+
Chris@42: \let\ptexraggedright=\raggedright
Chris@42: \let\ptexrbrace=\}
Chris@42: \let\ptexslash=\/
Chris@42: \let\ptexstar=\*
Chris@42: \let\ptext=\t
Chris@42: \let\ptextop=\top
Chris@42: {\catcode`\'=\active \global\let\ptexquoteright'}% active in plain's math mode
Chris@42:
Chris@42: % If this character appears in an error message or help string, it
Chris@42: % starts a new line in the output.
Chris@42: \newlinechar = `^^J
Chris@42:
Chris@42: % Use TeX 3.0's \inputlineno to get the line number, for better error
Chris@42: % messages, but if we're using an old version of TeX, don't do anything.
Chris@42: %
Chris@42: \ifx\inputlineno\thisisundefined
Chris@42: \let\linenumber = \empty % Pre-3.0.
Chris@42: \else
Chris@42: \def\linenumber{l.\the\inputlineno:\space}
Chris@42: \fi
Chris@42:
Chris@42: % Set up fixed words for English if not already set.
Chris@42: \ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi
Chris@42: \ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi
Chris@42: \ifx\putworderror\undefined \gdef\putworderror{error}\fi
Chris@42: \ifx\putwordfile\undefined \gdef\putwordfile{file}\fi
Chris@42: \ifx\putwordin\undefined \gdef\putwordin{in}\fi
Chris@42: \ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi
Chris@42: \ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi
Chris@42: \ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi
Chris@42: \ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi
Chris@42: \ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi
Chris@42: \ifx\putwordNoTitle\undefined \gdef\putwordNoTitle{No Title}\fi
Chris@42: \ifx\putwordof\undefined \gdef\putwordof{of}\fi
Chris@42: \ifx\putwordon\undefined \gdef\putwordon{on}\fi
Chris@42: \ifx\putwordpage\undefined \gdef\putwordpage{page}\fi
Chris@42: \ifx\putwordsection\undefined \gdef\putwordsection{section}\fi
Chris@42: \ifx\putwordSection\undefined \gdef\putwordSection{Section}\fi
Chris@42: \ifx\putwordsee\undefined \gdef\putwordsee{see}\fi
Chris@42: \ifx\putwordSee\undefined \gdef\putwordSee{See}\fi
Chris@42: \ifx\putwordShortTOC\undefined \gdef\putwordShortTOC{Short Contents}\fi
Chris@42: \ifx\putwordTOC\undefined \gdef\putwordTOC{Table of Contents}\fi
Chris@42: %
Chris@42: \ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi
Chris@42: \ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi
Chris@42: \ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi
Chris@42: \ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi
Chris@42: \ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi
Chris@42: \ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi
Chris@42: \ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi
Chris@42: \ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi
Chris@42: \ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi
Chris@42: \ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi
Chris@42: \ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi
Chris@42: \ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi
Chris@42: %
Chris@42: \ifx\putwordDefmac\undefined \gdef\putwordDefmac{Macro}\fi
Chris@42: \ifx\putwordDefspec\undefined \gdef\putwordDefspec{Special Form}\fi
Chris@42: \ifx\putwordDefvar\undefined \gdef\putwordDefvar{Variable}\fi
Chris@42: \ifx\putwordDefopt\undefined \gdef\putwordDefopt{User Option}\fi
Chris@42: \ifx\putwordDeffunc\undefined \gdef\putwordDeffunc{Function}\fi
Chris@42:
Chris@42: % Since the category of space is not known, we have to be careful.
Chris@42: \chardef\spacecat = 10
Chris@42: \def\spaceisspace{\catcode`\ =\spacecat}
Chris@42:
Chris@42: % sometimes characters are active, so we need control sequences.
Chris@42: \chardef\ampChar = `\&
Chris@42: \chardef\colonChar = `\:
Chris@42: \chardef\commaChar = `\,
Chris@42: \chardef\dashChar = `\-
Chris@42: \chardef\dotChar = `\.
Chris@42: \chardef\exclamChar= `\!
Chris@42: \chardef\hashChar = `\#
Chris@42: \chardef\lquoteChar= `\`
Chris@42: \chardef\questChar = `\?
Chris@42: \chardef\rquoteChar= `\'
Chris@42: \chardef\semiChar = `\;
Chris@42: \chardef\slashChar = `\/
Chris@42: \chardef\underChar = `\_
Chris@42:
Chris@42: % Ignore a token.
Chris@42: %
Chris@42: \def\gobble#1{}
Chris@42:
Chris@42: % The following is used inside several \edef's.
Chris@42: \def\makecsname#1{\expandafter\noexpand\csname#1\endcsname}
Chris@42:
Chris@42: % Hyphenation fixes.
Chris@42: \hyphenation{
Chris@42: Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script
Chris@42: ap-pen-dix bit-map bit-maps
Chris@42: data-base data-bases eshell fall-ing half-way long-est man-u-script
Chris@42: man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm
Chris@42: par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces
Chris@42: spell-ing spell-ings
Chris@42: stand-alone strong-est time-stamp time-stamps which-ever white-space
Chris@42: wide-spread wrap-around
Chris@42: }
Chris@42:
Chris@42: % Margin to add to right of even pages, to left of odd pages.
Chris@42: \newdimen\bindingoffset
Chris@42: \newdimen\normaloffset
Chris@42: \newdimen\pagewidth \newdimen\pageheight
Chris@42:
Chris@42: % For a final copy, take out the rectangles
Chris@42: % that mark overfull boxes (in case you have decided
Chris@42: % that the text looks ok even though it passes the margin).
Chris@42: %
Chris@42: \def\finalout{\overfullrule=0pt }
Chris@42:
Chris@42: % Sometimes it is convenient to have everything in the transcript file
Chris@42: % and nothing on the terminal. We don't just call \tracingall here,
Chris@42: % since that produces some useless output on the terminal. We also make
Chris@42: % some effort to order the tracing commands to reduce output in the log
Chris@42: % file; cf. trace.sty in LaTeX.
Chris@42: %
Chris@42: \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}%
Chris@42: \def\loggingall{%
Chris@42: \tracingstats2
Chris@42: \tracingpages1
Chris@42: \tracinglostchars2 % 2 gives us more in etex
Chris@42: \tracingparagraphs1
Chris@42: \tracingoutput1
Chris@42: \tracingmacros2
Chris@42: \tracingrestores1
Chris@42: \showboxbreadth\maxdimen \showboxdepth\maxdimen
Chris@42: \ifx\eTeXversion\thisisundefined\else % etex gives us more logging
Chris@42: \tracingscantokens1
Chris@42: \tracingifs1
Chris@42: \tracinggroups1
Chris@42: \tracingnesting2
Chris@42: \tracingassigns1
Chris@42: \fi
Chris@42: \tracingcommands3 % 3 gives us more in etex
Chris@42: \errorcontextlines16
Chris@42: }%
Chris@42:
Chris@42: % @errormsg{MSG}. Do the index-like expansions on MSG, but if things
Chris@42: % aren't perfect, it's not the end of the world, being an error message,
Chris@42: % after all.
Chris@42: %
Chris@42: \def\errormsg{\begingroup \indexnofonts \doerrormsg}
Chris@42: \def\doerrormsg#1{\errmessage{#1}}
Chris@42:
Chris@42: % add check for \lastpenalty to plain's definitions. If the last thing
Chris@42: % we did was a \nobreak, we don't want to insert more space.
Chris@42: %
Chris@42: \def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount
Chris@42: \removelastskip\penalty-50\smallskip\fi\fi}
Chris@42: \def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount
Chris@42: \removelastskip\penalty-100\medskip\fi\fi}
Chris@42: \def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount
Chris@42: \removelastskip\penalty-200\bigskip\fi\fi}
Chris@42:
Chris@42: % Do @cropmarks to get crop marks.
Chris@42: %
Chris@42: \newif\ifcropmarks
Chris@42: \let\cropmarks = \cropmarkstrue
Chris@42: %
Chris@42: % Dimensions to add cropmarks at corners.
Chris@42: % Added by P. A. MacKay, 12 Nov. 1986
Chris@42: %
Chris@42: \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines
Chris@42: \newdimen\cornerlong \cornerlong=1pc
Chris@42: \newdimen\cornerthick \cornerthick=.3pt
Chris@42: \newdimen\topandbottommargin \topandbottommargin=.75in
Chris@42:
Chris@42: % Output a mark which sets \thischapter, \thissection and \thiscolor.
Chris@42: % We dump everything together because we only have one kind of mark.
Chris@42: % This works because we only use \botmark / \topmark, not \firstmark.
Chris@42: %
Chris@42: % A mark contains a subexpression of the \ifcase ... \fi construct.
Chris@42: % \get*marks macros below extract the needed part using \ifcase.
Chris@42: %
Chris@42: % Another complication is to let the user choose whether \thischapter
Chris@42: % (\thissection) refers to the chapter (section) in effect at the top
Chris@42: % of a page, or that at the bottom of a page. The solution is
Chris@42: % described on page 260 of The TeXbook. It involves outputting two
Chris@42: % marks for the sectioning macros, one before the section break, and
Chris@42: % one after. I won't pretend I can describe this better than DEK...
Chris@42: \def\domark{%
Chris@42: \toks0=\expandafter{\lastchapterdefs}%
Chris@42: \toks2=\expandafter{\lastsectiondefs}%
Chris@42: \toks4=\expandafter{\prevchapterdefs}%
Chris@42: \toks6=\expandafter{\prevsectiondefs}%
Chris@42: \toks8=\expandafter{\lastcolordefs}%
Chris@42: \mark{%
Chris@42: \the\toks0 \the\toks2
Chris@42: \noexpand\or \the\toks4 \the\toks6
Chris@42: \noexpand\else \the\toks8
Chris@42: }%
Chris@42: }
Chris@42: % \topmark doesn't work for the very first chapter (after the title
Chris@42: % page or the contents), so we use \firstmark there -- this gets us
Chris@42: % the mark with the chapter defs, unless the user sneaks in, e.g.,
Chris@42: % @setcolor (or @url, or @link, etc.) between @contents and the very
Chris@42: % first @chapter.
Chris@42: \def\gettopheadingmarks{%
Chris@42: \ifcase0\topmark\fi
Chris@42: \ifx\thischapter\empty \ifcase0\firstmark\fi \fi
Chris@42: }
Chris@42: \def\getbottomheadingmarks{\ifcase1\botmark\fi}
Chris@42: \def\getcolormarks{\ifcase2\topmark\fi}
Chris@42:
Chris@42: % Avoid "undefined control sequence" errors.
Chris@42: \def\lastchapterdefs{}
Chris@42: \def\lastsectiondefs{}
Chris@42: \def\prevchapterdefs{}
Chris@42: \def\prevsectiondefs{}
Chris@42: \def\lastcolordefs{}
Chris@42:
Chris@42: % Main output routine.
Chris@42: \chardef\PAGE = 255
Chris@42: \output = {\onepageout{\pagecontents\PAGE}}
Chris@42:
Chris@42: \newbox\headlinebox
Chris@42: \newbox\footlinebox
Chris@42:
Chris@42: % \onepageout takes a vbox as an argument. Note that \pagecontents
Chris@42: % does insertions, but you have to call it yourself.
Chris@42: \def\onepageout#1{%
Chris@42: \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi
Chris@42: %
Chris@42: \ifodd\pageno \advance\hoffset by \bindingoffset
Chris@42: \else \advance\hoffset by -\bindingoffset\fi
Chris@42: %
Chris@42: % Do this outside of the \shipout so @code etc. will be expanded in
Chris@42: % the headline as they should be, not taken literally (outputting ''code).
Chris@42: \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi
Chris@42: \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}%
Chris@42: \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi
Chris@42: \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}%
Chris@42: %
Chris@42: {%
Chris@42: % Have to do this stuff outside the \shipout because we want it to
Chris@42: % take effect in \write's, yet the group defined by the \vbox ends
Chris@42: % before the \shipout runs.
Chris@42: %
Chris@42: \indexdummies % don't expand commands in the output.
Chris@42: \normalturnoffactive % \ in index entries must not stay \, e.g., if
Chris@42: % the page break happens to be in the middle of an example.
Chris@42: % We don't want .vr (or whatever) entries like this:
Chris@42: % \entry{{\tt \indexbackslash }acronym}{32}{\code {\acronym}}
Chris@42: % "\acronym" won't work when it's read back in;
Chris@42: % it needs to be
Chris@42: % {\code {{\tt \backslashcurfont }acronym}
Chris@42: \shipout\vbox{%
Chris@42: % Do this early so pdf references go to the beginning of the page.
Chris@42: \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi
Chris@42: %
Chris@42: \ifcropmarks \vbox to \outervsize\bgroup
Chris@42: \hsize = \outerhsize
Chris@42: \vskip-\topandbottommargin
Chris@42: \vtop to0pt{%
Chris@42: \line{\ewtop\hfil\ewtop}%
Chris@42: \nointerlineskip
Chris@42: \line{%
Chris@42: \vbox{\moveleft\cornerthick\nstop}%
Chris@42: \hfill
Chris@42: \vbox{\moveright\cornerthick\nstop}%
Chris@42: }%
Chris@42: \vss}%
Chris@42: \vskip\topandbottommargin
Chris@42: \line\bgroup
Chris@42: \hfil % center the page within the outer (page) hsize.
Chris@42: \ifodd\pageno\hskip\bindingoffset\fi
Chris@42: \vbox\bgroup
Chris@42: \fi
Chris@42: %
Chris@42: \unvbox\headlinebox
Chris@42: \pagebody{#1}%
Chris@42: \ifdim\ht\footlinebox > 0pt
Chris@42: % Only leave this space if the footline is nonempty.
Chris@42: % (We lessened \vsize for it in \oddfootingyyy.)
Chris@42: % The \baselineskip=24pt in plain's \makefootline has no effect.
Chris@42: \vskip 24pt
Chris@42: \unvbox\footlinebox
Chris@42: \fi
Chris@42: %
Chris@42: \ifcropmarks
Chris@42: \egroup % end of \vbox\bgroup
Chris@42: \hfil\egroup % end of (centering) \line\bgroup
Chris@42: \vskip\topandbottommargin plus1fill minus1fill
Chris@42: \boxmaxdepth = \cornerthick
Chris@42: \vbox to0pt{\vss
Chris@42: \line{%
Chris@42: \vbox{\moveleft\cornerthick\nsbot}%
Chris@42: \hfill
Chris@42: \vbox{\moveright\cornerthick\nsbot}%
Chris@42: }%
Chris@42: \nointerlineskip
Chris@42: \line{\ewbot\hfil\ewbot}%
Chris@42: }%
Chris@42: \egroup % \vbox from first cropmarks clause
Chris@42: \fi
Chris@42: }% end of \shipout\vbox
Chris@42: }% end of group with \indexdummies
Chris@42: \advancepageno
Chris@42: \ifnum\outputpenalty>-20000 \else\dosupereject\fi
Chris@42: }
Chris@42:
Chris@42: \newinsert\margin \dimen\margin=\maxdimen
Chris@42:
Chris@42: \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}}
Chris@42: {\catcode`\@ =11
Chris@42: \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi
Chris@42: % marginal hacks, juha@viisa.uucp (Juha Takala)
Chris@42: \ifvoid\margin\else % marginal info is present
Chris@42: \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi
Chris@42: \dimen@=\dp#1\relax \unvbox#1\relax
Chris@42: \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi
Chris@42: \ifr@ggedbottom \kern-\dimen@ \vfil \fi}
Chris@42: }
Chris@42:
Chris@42: % Here are the rules for the cropmarks. Note that they are
Chris@42: % offset so that the space between them is truly \outerhsize or \outervsize
Chris@42: % (P. A. MacKay, 12 November, 1986)
Chris@42: %
Chris@42: \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong}
Chris@42: \def\nstop{\vbox
Chris@42: {\hrule height\cornerthick depth\cornerlong width\cornerthick}}
Chris@42: \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong}
Chris@42: \def\nsbot{\vbox
Chris@42: {\hrule height\cornerlong depth\cornerthick width\cornerthick}}
Chris@42:
Chris@42: % Parse an argument, then pass it to #1. The argument is the rest of
Chris@42: % the input line (except we remove a trailing comment). #1 should be a
Chris@42: % macro which expects an ordinary undelimited TeX argument.
Chris@42: %
Chris@42: \def\parsearg{\parseargusing{}}
Chris@42: \def\parseargusing#1#2{%
Chris@42: \def\argtorun{#2}%
Chris@42: \begingroup
Chris@42: \obeylines
Chris@42: \spaceisspace
Chris@42: #1%
Chris@42: \parseargline\empty% Insert the \empty token, see \finishparsearg below.
Chris@42: }
Chris@42:
Chris@42: {\obeylines %
Chris@42: \gdef\parseargline#1^^M{%
Chris@42: \endgroup % End of the group started in \parsearg.
Chris@42: \argremovecomment #1\comment\ArgTerm%
Chris@42: }%
Chris@42: }
Chris@42:
Chris@42: % First remove any @comment, then any @c comment.
Chris@42: \def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm}
Chris@42: \def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm}
Chris@42:
Chris@42: % Each occurrence of `\^^M' or `\^^M' is replaced by a single space.
Chris@42: %
Chris@42: % \argremovec might leave us with trailing space, e.g.,
Chris@42: % @end itemize @c foo
Chris@42: % This space token undergoes the same procedure and is eventually removed
Chris@42: % by \finishparsearg.
Chris@42: %
Chris@42: \def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M}
Chris@42: \def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M}
Chris@42: \def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{%
Chris@42: \def\temp{#3}%
Chris@42: \ifx\temp\empty
Chris@42: % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp:
Chris@42: \let\temp\finishparsearg
Chris@42: \else
Chris@42: \let\temp\argcheckspaces
Chris@42: \fi
Chris@42: % Put the space token in:
Chris@42: \temp#1 #3\ArgTerm
Chris@42: }
Chris@42:
Chris@42: % If a _delimited_ argument is enclosed in braces, they get stripped; so
Chris@42: % to get _exactly_ the rest of the line, we had to prevent such situation.
Chris@42: % We prepended an \empty token at the very beginning and we expand it now,
Chris@42: % just before passing the control to \argtorun.
Chris@42: % (Similarly, we have to think about #3 of \argcheckspacesY above: it is
Chris@42: % either the null string, or it ends with \^^M---thus there is no danger
Chris@42: % that a pair of braces would be stripped.
Chris@42: %
Chris@42: % But first, we have to remove the trailing space token.
Chris@42: %
Chris@42: \def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}}
Chris@42:
Chris@42: % \parseargdef\foo{...}
Chris@42: % is roughly equivalent to
Chris@42: % \def\foo{\parsearg\Xfoo}
Chris@42: % \def\Xfoo#1{...}
Chris@42: %
Chris@42: % Actually, I use \csname\string\foo\endcsname, ie. \\foo, as it is my
Chris@42: % favourite TeX trick. --kasal, 16nov03
Chris@42:
Chris@42: \def\parseargdef#1{%
Chris@42: \expandafter \doparseargdef \csname\string#1\endcsname #1%
Chris@42: }
Chris@42: \def\doparseargdef#1#2{%
Chris@42: \def#2{\parsearg#1}%
Chris@42: \def#1##1%
Chris@42: }
Chris@42:
Chris@42: % Several utility definitions with active space:
Chris@42: {
Chris@42: \obeyspaces
Chris@42: \gdef\obeyedspace{ }
Chris@42:
Chris@42: % Make each space character in the input produce a normal interword
Chris@42: % space in the output. Don't allow a line break at this space, as this
Chris@42: % is used only in environments like @example, where each line of input
Chris@42: % should produce a line of output anyway.
Chris@42: %
Chris@42: \gdef\sepspaces{\obeyspaces\let =\tie}
Chris@42:
Chris@42: % If an index command is used in an @example environment, any spaces
Chris@42: % therein should become regular spaces in the raw index file, not the
Chris@42: % expansion of \tie (\leavevmode \penalty \@M \ ).
Chris@42: \gdef\unsepspaces{\let =\space}
Chris@42: }
Chris@42:
Chris@42:
Chris@42: \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next}
Chris@42:
Chris@42: % Define the framework for environments in texinfo.tex. It's used like this:
Chris@42: %
Chris@42: % \envdef\foo{...}
Chris@42: % \def\Efoo{...}
Chris@42: %
Chris@42: % It's the responsibility of \envdef to insert \begingroup before the
Chris@42: % actual body; @end closes the group after calling \Efoo. \envdef also
Chris@42: % defines \thisenv, so the current environment is known; @end checks
Chris@42: % whether the environment name matches. The \checkenv macro can also be
Chris@42: % used to check whether the current environment is the one expected.
Chris@42: %
Chris@42: % Non-false conditionals (@iftex, @ifset) don't fit into this, so they
Chris@42: % are not treated as environments; they don't open a group. (The
Chris@42: % implementation of @end takes care not to call \endgroup in this
Chris@42: % special case.)
Chris@42:
Chris@42:
Chris@42: % At run-time, environments start with this:
Chris@42: \def\startenvironment#1{\begingroup\def\thisenv{#1}}
Chris@42: % initialize
Chris@42: \let\thisenv\empty
Chris@42:
Chris@42: % ... but they get defined via ``\envdef\foo{...}'':
Chris@42: \long\def\envdef#1#2{\def#1{\startenvironment#1#2}}
Chris@42: \def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}}
Chris@42:
Chris@42: % Check whether we're in the right environment:
Chris@42: \def\checkenv#1{%
Chris@42: \def\temp{#1}%
Chris@42: \ifx\thisenv\temp
Chris@42: \else
Chris@42: \badenverr
Chris@42: \fi
Chris@42: }
Chris@42:
Chris@42: % Environment mismatch, #1 expected:
Chris@42: \def\badenverr{%
Chris@42: \errhelp = \EMsimple
Chris@42: \errmessage{This command can appear only \inenvironment\temp,
Chris@42: not \inenvironment\thisenv}%
Chris@42: }
Chris@42: \def\inenvironment#1{%
Chris@42: \ifx#1\empty
Chris@42: outside of any environment%
Chris@42: \else
Chris@42: in environment \expandafter\string#1%
Chris@42: \fi
Chris@42: }
Chris@42:
Chris@42: % @end foo executes the definition of \Efoo.
Chris@42: % But first, it executes a specialized version of \checkenv
Chris@42: %
Chris@42: \parseargdef\end{%
Chris@42: \if 1\csname iscond.#1\endcsname
Chris@42: \else
Chris@42: % The general wording of \badenverr may not be ideal.
Chris@42: \expandafter\checkenv\csname#1\endcsname
Chris@42: \csname E#1\endcsname
Chris@42: \endgroup
Chris@42: \fi
Chris@42: }
Chris@42:
Chris@42: \newhelp\EMsimple{Press RETURN to continue.}
Chris@42:
Chris@42:
Chris@42: % Be sure we're in horizontal mode when doing a tie, since we make space
Chris@42: % equivalent to this in @example-like environments. Otherwise, a space
Chris@42: % at the beginning of a line will start with \penalty -- and
Chris@42: % since \penalty is valid in vertical mode, we'd end up putting the
Chris@42: % penalty on the vertical list instead of in the new paragraph.
Chris@42: {\catcode`@ = 11
Chris@42: % Avoid using \@M directly, because that causes trouble
Chris@42: % if the definition is written into an index file.
Chris@42: \global\let\tiepenalty = \@M
Chris@42: \gdef\tie{\leavevmode\penalty\tiepenalty\ }
Chris@42: }
Chris@42:
Chris@42: % @: forces normal size whitespace following.
Chris@42: \def\:{\spacefactor=1000 }
Chris@42:
Chris@42: % @* forces a line break.
Chris@42: \def\*{\unskip\hfil\break\hbox{}\ignorespaces}
Chris@42:
Chris@42: % @/ allows a line break.
Chris@42: \let\/=\allowbreak
Chris@42:
Chris@42: % @. is an end-of-sentence period.
Chris@42: \def\.{.\spacefactor=\endofsentencespacefactor\space}
Chris@42:
Chris@42: % @! is an end-of-sentence bang.
Chris@42: \def\!{!\spacefactor=\endofsentencespacefactor\space}
Chris@42:
Chris@42: % @? is an end-of-sentence query.
Chris@42: \def\?{?\spacefactor=\endofsentencespacefactor\space}
Chris@42:
Chris@42: % @frenchspacing on|off says whether to put extra space after punctuation.
Chris@42: %
Chris@42: \def\onword{on}
Chris@42: \def\offword{off}
Chris@42: %
Chris@42: \parseargdef\frenchspacing{%
Chris@42: \def\temp{#1}%
Chris@42: \ifx\temp\onword \plainfrenchspacing
Chris@42: \else\ifx\temp\offword \plainnonfrenchspacing
Chris@42: \else
Chris@42: \errhelp = \EMsimple
Chris@42: \errmessage{Unknown @frenchspacing option `\temp', must be on|off}%
Chris@42: \fi\fi
Chris@42: }
Chris@42:
Chris@42: % @w prevents a word break. Without the \leavevmode, @w at the
Chris@42: % beginning of a paragraph, when TeX is still in vertical mode, would
Chris@42: % produce a whole line of output instead of starting the paragraph.
Chris@42: \def\w#1{\leavevmode\hbox{#1}}
Chris@42:
Chris@42: % @group ... @end group forces ... to be all on one page, by enclosing
Chris@42: % it in a TeX vbox. We use \vtop instead of \vbox to construct the box
Chris@42: % to keep its height that of a normal line. According to the rules for
Chris@42: % \topskip (p.114 of the TeXbook), the glue inserted is
Chris@42: % max (\topskip - \ht (first item), 0). If that height is large,
Chris@42: % therefore, no glue is inserted, and the space between the headline and
Chris@42: % the text is small, which looks bad.
Chris@42: %
Chris@42: % Another complication is that the group might be very large. This can
Chris@42: % cause the glue on the previous page to be unduly stretched, because it
Chris@42: % does not have much material. In this case, it's better to add an
Chris@42: % explicit \vfill so that the extra space is at the bottom. The
Chris@42: % threshold for doing this is if the group is more than \vfilllimit
Chris@42: % percent of a page (\vfilllimit can be changed inside of @tex).
Chris@42: %
Chris@42: \newbox\groupbox
Chris@42: \def\vfilllimit{0.7}
Chris@42: %
Chris@42: \envdef\group{%
Chris@42: \ifnum\catcode`\^^M=\active \else
Chris@42: \errhelp = \groupinvalidhelp
Chris@42: \errmessage{@group invalid in context where filling is enabled}%
Chris@42: \fi
Chris@42: \startsavinginserts
Chris@42: %
Chris@42: \setbox\groupbox = \vtop\bgroup
Chris@42: % Do @comment since we are called inside an environment such as
Chris@42: % @example, where each end-of-line in the input causes an
Chris@42: % end-of-line in the output. We don't want the end-of-line after
Chris@42: % the `@group' to put extra space in the output. Since @group
Chris@42: % should appear on a line by itself (according to the Texinfo
Chris@42: % manual), we don't worry about eating any user text.
Chris@42: \comment
Chris@42: }
Chris@42: %
Chris@42: % The \vtop produces a box with normal height and large depth; thus, TeX puts
Chris@42: % \baselineskip glue before it, and (when the next line of text is done)
Chris@42: % \lineskip glue after it. Thus, space below is not quite equal to space
Chris@42: % above. But it's pretty close.
Chris@42: \def\Egroup{%
Chris@42: % To get correct interline space between the last line of the group
Chris@42: % and the first line afterwards, we have to propagate \prevdepth.
Chris@42: \endgraf % Not \par, as it may have been set to \lisppar.
Chris@42: \global\dimen1 = \prevdepth
Chris@42: \egroup % End the \vtop.
Chris@42: % \dimen0 is the vertical size of the group's box.
Chris@42: \dimen0 = \ht\groupbox \advance\dimen0 by \dp\groupbox
Chris@42: % \dimen2 is how much space is left on the page (more or less).
Chris@42: \dimen2 = \pageheight \advance\dimen2 by -\pagetotal
Chris@42: % if the group doesn't fit on the current page, and it's a big big
Chris@42: % group, force a page break.
Chris@42: \ifdim \dimen0 > \dimen2
Chris@42: \ifdim \pagetotal < \vfilllimit\pageheight
Chris@42: \page
Chris@42: \fi
Chris@42: \fi
Chris@42: \box\groupbox
Chris@42: \prevdepth = \dimen1
Chris@42: \checkinserts
Chris@42: }
Chris@42: %
Chris@42: % TeX puts in an \escapechar (i.e., `@') at the beginning of the help
Chris@42: % message, so this ends up printing `@group can only ...'.
Chris@42: %
Chris@42: \newhelp\groupinvalidhelp{%
Chris@42: group can only be used in environments such as @example,^^J%
Chris@42: where each line of input produces a line of output.}
Chris@42:
Chris@42: % @need space-in-mils
Chris@42: % forces a page break if there is not space-in-mils remaining.
Chris@42:
Chris@42: \newdimen\mil \mil=0.001in
Chris@42:
Chris@42: \parseargdef\need{%
Chris@42: % Ensure vertical mode, so we don't make a big box in the middle of a
Chris@42: % paragraph.
Chris@42: \par
Chris@42: %
Chris@42: % If the @need value is less than one line space, it's useless.
Chris@42: \dimen0 = #1\mil
Chris@42: \dimen2 = \ht\strutbox
Chris@42: \advance\dimen2 by \dp\strutbox
Chris@42: \ifdim\dimen0 > \dimen2
Chris@42: %
Chris@42: % Do a \strut just to make the height of this box be normal, so the
Chris@42: % normal leading is inserted relative to the preceding line.
Chris@42: % And a page break here is fine.
Chris@42: \vtop to #1\mil{\strut\vfil}%
Chris@42: %
Chris@42: % TeX does not even consider page breaks if a penalty added to the
Chris@42: % main vertical list is 10000 or more. But in order to see if the
Chris@42: % empty box we just added fits on the page, we must make it consider
Chris@42: % page breaks. On the other hand, we don't want to actually break the
Chris@42: % page after the empty box. So we use a penalty of 9999.
Chris@42: %
Chris@42: % There is an extremely small chance that TeX will actually break the
Chris@42: % page at this \penalty, if there are no other feasible breakpoints in
Chris@42: % sight. (If the user is using lots of big @group commands, which
Chris@42: % almost-but-not-quite fill up a page, TeX will have a hard time doing
Chris@42: % good page breaking, for example.) However, I could not construct an
Chris@42: % example where a page broke at this \penalty; if it happens in a real
Chris@42: % document, then we can reconsider our strategy.
Chris@42: \penalty9999
Chris@42: %
Chris@42: % Back up by the size of the box, whether we did a page break or not.
Chris@42: \kern -#1\mil
Chris@42: %
Chris@42: % Do not allow a page break right after this kern.
Chris@42: \nobreak
Chris@42: \fi
Chris@42: }
Chris@42:
Chris@42: % @br forces paragraph break (and is undocumented).
Chris@42:
Chris@42: \let\br = \par
Chris@42:
Chris@42: % @page forces the start of a new page.
Chris@42: %
Chris@42: \def\page{\par\vfill\supereject}
Chris@42:
Chris@42: % @exdent text....
Chris@42: % outputs text on separate line in roman font, starting at standard page margin
Chris@42:
Chris@42: % This records the amount of indent in the innermost environment.
Chris@42: % That's how much \exdent should take out.
Chris@42: \newskip\exdentamount
Chris@42:
Chris@42: % This defn is used inside fill environments such as @defun.
Chris@42: \parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}
Chris@42:
Chris@42: % This defn is used inside nofill environments such as @example.
Chris@42: \parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount
Chris@42: \leftline{\hskip\leftskip{\rm#1}}}}
Chris@42:
Chris@42: % @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current
Chris@42: % paragraph. For more general purposes, use the \margin insertion
Chris@42: % class. WHICH is `l' or `r'. Not documented, written for gawk manual.
Chris@42: %
Chris@42: \newskip\inmarginspacing \inmarginspacing=1cm
Chris@42: \def\strutdepth{\dp\strutbox}
Chris@42: %
Chris@42: \def\doinmargin#1#2{\strut\vadjust{%
Chris@42: \nobreak
Chris@42: \kern-\strutdepth
Chris@42: \vtop to \strutdepth{%
Chris@42: \baselineskip=\strutdepth
Chris@42: \vss
Chris@42: % if you have multiple lines of stuff to put here, you'll need to
Chris@42: % make the vbox yourself of the appropriate size.
Chris@42: \ifx#1l%
Chris@42: \llap{\ignorespaces #2\hskip\inmarginspacing}%
Chris@42: \else
Chris@42: \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}%
Chris@42: \fi
Chris@42: \null
Chris@42: }%
Chris@42: }}
Chris@42: \def\inleftmargin{\doinmargin l}
Chris@42: \def\inrightmargin{\doinmargin r}
Chris@42: %
Chris@42: % @inmargin{TEXT [, RIGHT-TEXT]}
Chris@42: % (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right;
Chris@42: % else use TEXT for both).
Chris@42: %
Chris@42: \def\inmargin#1{\parseinmargin #1,,\finish}
Chris@42: \def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing.
Chris@42: \setbox0 = \hbox{\ignorespaces #2}%
Chris@42: \ifdim\wd0 > 0pt
Chris@42: \def\lefttext{#1}% have both texts
Chris@42: \def\righttext{#2}%
Chris@42: \else
Chris@42: \def\lefttext{#1}% have only one text
Chris@42: \def\righttext{#1}%
Chris@42: \fi
Chris@42: %
Chris@42: \ifodd\pageno
Chris@42: \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin
Chris@42: \else
Chris@42: \def\temp{\inleftmargin\lefttext}%
Chris@42: \fi
Chris@42: \temp
Chris@42: }
Chris@42:
Chris@42: % @| inserts a changebar to the left of the current line. It should
Chris@42: % surround any changed text. This approach does *not* work if the
Chris@42: % change spans more than two lines of output. To handle that, we would
Chris@42: % have adopt a much more difficult approach (putting marks into the main
Chris@42: % vertical list for the beginning and end of each change). This command
Chris@42: % is not documented, not supported, and doesn't work.
Chris@42: %
Chris@42: \def\|{%
Chris@42: % \vadjust can only be used in horizontal mode.
Chris@42: \leavevmode
Chris@42: %
Chris@42: % Append this vertical mode material after the current line in the output.
Chris@42: \vadjust{%
Chris@42: % We want to insert a rule with the height and depth of the current
Chris@42: % leading; that is exactly what \strutbox is supposed to record.
Chris@42: \vskip-\baselineskip
Chris@42: %
Chris@42: % \vadjust-items are inserted at the left edge of the type. So
Chris@42: % the \llap here moves out into the left-hand margin.
Chris@42: \llap{%
Chris@42: %
Chris@42: % For a thicker or thinner bar, change the `1pt'.
Chris@42: \vrule height\baselineskip width1pt
Chris@42: %
Chris@42: % This is the space between the bar and the text.
Chris@42: \hskip 12pt
Chris@42: }%
Chris@42: }%
Chris@42: }
Chris@42:
Chris@42: % @include FILE -- \input text of FILE.
Chris@42: %
Chris@42: \def\include{\parseargusing\filenamecatcodes\includezzz}
Chris@42: \def\includezzz#1{%
Chris@42: \pushthisfilestack
Chris@42: \def\thisfile{#1}%
Chris@42: {%
Chris@42: \makevalueexpandable % we want to expand any @value in FILE.
Chris@42: \turnoffactive % and allow special characters in the expansion
Chris@42: \indexnofonts % Allow `@@' and other weird things in file names.
Chris@42: \wlog{texinfo.tex: doing @include of #1^^J}%
Chris@42: \edef\temp{\noexpand\input #1 }%
Chris@42: %
Chris@42: % This trickery is to read FILE outside of a group, in case it makes
Chris@42: % definitions, etc.
Chris@42: \expandafter
Chris@42: }\temp
Chris@42: \popthisfilestack
Chris@42: }
Chris@42: \def\filenamecatcodes{%
Chris@42: \catcode`\\=\other
Chris@42: \catcode`~=\other
Chris@42: \catcode`^=\other
Chris@42: \catcode`_=\other
Chris@42: \catcode`|=\other
Chris@42: \catcode`<=\other
Chris@42: \catcode`>=\other
Chris@42: \catcode`+=\other
Chris@42: \catcode`-=\other
Chris@42: \catcode`\`=\other
Chris@42: \catcode`\'=\other
Chris@42: }
Chris@42:
Chris@42: \def\pushthisfilestack{%
Chris@42: \expandafter\pushthisfilestackX\popthisfilestack\StackTerm
Chris@42: }
Chris@42: \def\pushthisfilestackX{%
Chris@42: \expandafter\pushthisfilestackY\thisfile\StackTerm
Chris@42: }
Chris@42: \def\pushthisfilestackY #1\StackTerm #2\StackTerm {%
Chris@42: \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}%
Chris@42: }
Chris@42:
Chris@42: \def\popthisfilestack{\errthisfilestackempty}
Chris@42: \def\errthisfilestackempty{\errmessage{Internal error:
Chris@42: the stack of filenames is empty.}}
Chris@42: %
Chris@42: \def\thisfile{}
Chris@42:
Chris@42: % @center line
Chris@42: % outputs that line, centered.
Chris@42: %
Chris@42: \parseargdef\center{%
Chris@42: \ifhmode
Chris@42: \let\centersub\centerH
Chris@42: \else
Chris@42: \let\centersub\centerV
Chris@42: \fi
Chris@42: \centersub{\hfil \ignorespaces#1\unskip \hfil}%
Chris@42: \let\centersub\relax % don't let the definition persist, just in case
Chris@42: }
Chris@42: \def\centerH#1{{%
Chris@42: \hfil\break
Chris@42: \advance\hsize by -\leftskip
Chris@42: \advance\hsize by -\rightskip
Chris@42: \line{#1}%
Chris@42: \break
Chris@42: }}
Chris@42: %
Chris@42: \newcount\centerpenalty
Chris@42: \def\centerV#1{%
Chris@42: % The idea here is the same as in \startdefun, \cartouche, etc.: if
Chris@42: % @center is the first thing after a section heading, we need to wipe
Chris@42: % out the negative parskip inserted by \sectionheading, but still
Chris@42: % prevent a page break here.
Chris@42: \centerpenalty = \lastpenalty
Chris@42: \ifnum\centerpenalty>10000 \vskip\parskip \fi
Chris@42: \ifnum\centerpenalty>9999 \penalty\centerpenalty \fi
Chris@42: \line{\kern\leftskip #1\kern\rightskip}%
Chris@42: }
Chris@42:
Chris@42: % @sp n outputs n lines of vertical space
Chris@42: %
Chris@42: \parseargdef\sp{\vskip #1\baselineskip}
Chris@42:
Chris@42: % @comment ...line which is ignored...
Chris@42: % @c is the same as @comment
Chris@42: % @ignore ... @end ignore is another way to write a comment
Chris@42: %
Chris@42: \def\comment{\begingroup \catcode`\^^M=\other%
Chris@42: \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other%
Chris@42: \commentxxx}
Chris@42: {\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}}
Chris@42: %
Chris@42: \let\c=\comment
Chris@42:
Chris@42: % @paragraphindent NCHARS
Chris@42: % We'll use ems for NCHARS, close enough.
Chris@42: % NCHARS can also be the word `asis' or `none'.
Chris@42: % We cannot feasibly implement @paragraphindent asis, though.
Chris@42: %
Chris@42: \def\asisword{asis} % no translation, these are keywords
Chris@42: \def\noneword{none}
Chris@42: %
Chris@42: \parseargdef\paragraphindent{%
Chris@42: \def\temp{#1}%
Chris@42: \ifx\temp\asisword
Chris@42: \else
Chris@42: \ifx\temp\noneword
Chris@42: \defaultparindent = 0pt
Chris@42: \else
Chris@42: \defaultparindent = #1em
Chris@42: \fi
Chris@42: \fi
Chris@42: \parindent = \defaultparindent
Chris@42: }
Chris@42:
Chris@42: % @exampleindent NCHARS
Chris@42: % We'll use ems for NCHARS like @paragraphindent.
Chris@42: % It seems @exampleindent asis isn't necessary, but
Chris@42: % I preserve it to make it similar to @paragraphindent.
Chris@42: \parseargdef\exampleindent{%
Chris@42: \def\temp{#1}%
Chris@42: \ifx\temp\asisword
Chris@42: \else
Chris@42: \ifx\temp\noneword
Chris@42: \lispnarrowing = 0pt
Chris@42: \else
Chris@42: \lispnarrowing = #1em
Chris@42: \fi
Chris@42: \fi
Chris@42: }
Chris@42:
Chris@42: % @firstparagraphindent WORD
Chris@42: % If WORD is `none', then suppress indentation of the first paragraph
Chris@42: % after a section heading. If WORD is `insert', then do indent at such
Chris@42: % paragraphs.
Chris@42: %
Chris@42: % The paragraph indentation is suppressed or not by calling
Chris@42: % \suppressfirstparagraphindent, which the sectioning commands do.
Chris@42: % We switch the definition of this back and forth according to WORD.
Chris@42: % By default, we suppress indentation.
Chris@42: %
Chris@42: \def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent}
Chris@42: \def\insertword{insert}
Chris@42: %
Chris@42: \parseargdef\firstparagraphindent{%
Chris@42: \def\temp{#1}%
Chris@42: \ifx\temp\noneword
Chris@42: \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent
Chris@42: \else\ifx\temp\insertword
Chris@42: \let\suppressfirstparagraphindent = \relax
Chris@42: \else
Chris@42: \errhelp = \EMsimple
Chris@42: \errmessage{Unknown @firstparagraphindent option `\temp'}%
Chris@42: \fi\fi
Chris@42: }
Chris@42:
Chris@42: % Here is how we actually suppress indentation. Redefine \everypar to
Chris@42: % \kern backwards by \parindent, and then reset itself to empty.
Chris@42: %
Chris@42: % We also make \indent itself not actually do anything until the next
Chris@42: % paragraph.
Chris@42: %
Chris@42: \gdef\dosuppressfirstparagraphindent{%
Chris@42: \gdef\indent{%
Chris@42: \restorefirstparagraphindent
Chris@42: \indent
Chris@42: }%
Chris@42: \gdef\noindent{%
Chris@42: \restorefirstparagraphindent
Chris@42: \noindent
Chris@42: }%
Chris@42: \global\everypar = {%
Chris@42: \kern -\parindent
Chris@42: \restorefirstparagraphindent
Chris@42: }%
Chris@42: }
Chris@42:
Chris@42: \gdef\restorefirstparagraphindent{%
Chris@42: \global \let \indent = \ptexindent
Chris@42: \global \let \noindent = \ptexnoindent
Chris@42: \global \everypar = {}%
Chris@42: }
Chris@42:
Chris@42:
Chris@42: % @refill is a no-op.
Chris@42: \let\refill=\relax
Chris@42:
Chris@42: % If working on a large document in chapters, it is convenient to
Chris@42: % be able to disable indexing, cross-referencing, and contents, for test runs.
Chris@42: % This is done with @novalidate (before @setfilename).
Chris@42: %
Chris@42: \newif\iflinks \linkstrue % by default we want the aux files.
Chris@42: \let\novalidate = \linksfalse
Chris@42:
Chris@42: % @setfilename is done at the beginning of every texinfo file.
Chris@42: % So open here the files we need to have open while reading the input.
Chris@42: % This makes it possible to make a .fmt file for texinfo.
Chris@42: \def\setfilename{%
Chris@42: \fixbackslash % Turn off hack to swallow `\input texinfo'.
Chris@42: \iflinks
Chris@42: \tryauxfile
Chris@42: % Open the new aux file. TeX will close it automatically at exit.
Chris@42: \immediate\openout\auxfile=\jobname.aux
Chris@42: \fi % \openindices needs to do some work in any case.
Chris@42: \openindices
Chris@42: \let\setfilename=\comment % Ignore extra @setfilename cmds.
Chris@42: %
Chris@42: % If texinfo.cnf is present on the system, read it.
Chris@42: % Useful for site-wide @afourpaper, etc.
Chris@42: \openin 1 texinfo.cnf
Chris@42: \ifeof 1 \else \input texinfo.cnf \fi
Chris@42: \closein 1
Chris@42: %
Chris@42: \comment % Ignore the actual filename.
Chris@42: }
Chris@42:
Chris@42: % Called from \setfilename.
Chris@42: %
Chris@42: \def\openindices{%
Chris@42: \newindex{cp}%
Chris@42: \newcodeindex{fn}%
Chris@42: \newcodeindex{vr}%
Chris@42: \newcodeindex{tp}%
Chris@42: \newcodeindex{ky}%
Chris@42: \newcodeindex{pg}%
Chris@42: }
Chris@42:
Chris@42: % @bye.
Chris@42: \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend}
Chris@42:
Chris@42:
Chris@42: \message{pdf,}
Chris@42: % adobe `portable' document format
Chris@42: \newcount\tempnum
Chris@42: \newcount\lnkcount
Chris@42: \newtoks\filename
Chris@42: \newcount\filenamelength
Chris@42: \newcount\pgn
Chris@42: \newtoks\toksA
Chris@42: \newtoks\toksB
Chris@42: \newtoks\toksC
Chris@42: \newtoks\toksD
Chris@42: \newbox\boxA
Chris@42: \newcount\countA
Chris@42: \newif\ifpdf
Chris@42: \newif\ifpdfmakepagedest
Chris@42:
Chris@42: % when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1
Chris@42: % can be set). So we test for \relax and 0 as well as being undefined.
Chris@42: \ifx\pdfoutput\thisisundefined
Chris@42: \else
Chris@42: \ifx\pdfoutput\relax
Chris@42: \else
Chris@42: \ifcase\pdfoutput
Chris@42: \else
Chris@42: \pdftrue
Chris@42: \fi
Chris@42: \fi
Chris@42: \fi
Chris@42:
Chris@42: % PDF uses PostScript string constants for the names of xref targets,
Chris@42: % for display in the outlines, and in other places. Thus, we have to
Chris@42: % double any backslashes. Otherwise, a name like "\node" will be
Chris@42: % interpreted as a newline (\n), followed by o, d, e. Not good.
Chris@42: %
Chris@42: % See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and
Chris@42: % related messages. The final outcome is that it is up to the TeX user
Chris@42: % to double the backslashes and otherwise make the string valid, so
Chris@42: % that's what we do. pdftex 1.30.0 (ca.2005) introduced a primitive to
Chris@42: % do this reliably, so we use it.
Chris@42:
Chris@42: % #1 is a control sequence in which to do the replacements,
Chris@42: % which we \xdef.
Chris@42: \def\txiescapepdf#1{%
Chris@42: \ifx\pdfescapestring\thisisundefined
Chris@42: % No primitive available; should we give a warning or log?
Chris@42: % Many times it won't matter.
Chris@42: \else
Chris@42: % The expandable \pdfescapestring primitive escapes parentheses,
Chris@42: % backslashes, and other special chars.
Chris@42: \xdef#1{\pdfescapestring{#1}}%
Chris@42: \fi
Chris@42: }
Chris@42:
Chris@42: \newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images
Chris@42: with PDF output, and none of those formats could be found. (.eps cannot
Chris@42: be supported due to the design of the PDF format; use regular TeX (DVI
Chris@42: output) for that.)}
Chris@42:
Chris@42: \ifpdf
Chris@42: %
Chris@42: % Color manipulation macros based on pdfcolor.tex,
Chris@42: % except using rgb instead of cmyk; the latter is said to render as a
Chris@42: % very dark gray on-screen and a very dark halftone in print, instead
Chris@42: % of actual black.
Chris@42: \def\rgbDarkRed{0.50 0.09 0.12}
Chris@42: \def\rgbBlack{0 0 0}
Chris@42: %
Chris@42: % k sets the color for filling (usual text, etc.);
Chris@42: % K sets the color for stroking (thin rules, e.g., normal _'s).
Chris@42: \def\pdfsetcolor#1{\pdfliteral{#1 rg #1 RG}}
Chris@42: %
Chris@42: % Set color, and create a mark which defines \thiscolor accordingly,
Chris@42: % so that \makeheadline knows which color to restore.
Chris@42: \def\setcolor#1{%
Chris@42: \xdef\lastcolordefs{\gdef\noexpand\thiscolor{#1}}%
Chris@42: \domark
Chris@42: \pdfsetcolor{#1}%
Chris@42: }
Chris@42: %
Chris@42: \def\maincolor{\rgbBlack}
Chris@42: \pdfsetcolor{\maincolor}
Chris@42: \edef\thiscolor{\maincolor}
Chris@42: \def\lastcolordefs{}
Chris@42: %
Chris@42: \def\makefootline{%
Chris@42: \baselineskip24pt
Chris@42: \line{\pdfsetcolor{\maincolor}\the\footline}%
Chris@42: }
Chris@42: %
Chris@42: \def\makeheadline{%
Chris@42: \vbox to 0pt{%
Chris@42: \vskip-22.5pt
Chris@42: \line{%
Chris@42: \vbox to8.5pt{}%
Chris@42: % Extract \thiscolor definition from the marks.
Chris@42: \getcolormarks
Chris@42: % Typeset the headline with \maincolor, then restore the color.
Chris@42: \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}%
Chris@42: }%
Chris@42: \vss
Chris@42: }%
Chris@42: \nointerlineskip
Chris@42: }
Chris@42: %
Chris@42: %
Chris@42: \pdfcatalog{/PageMode /UseOutlines}
Chris@42: %
Chris@42: % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto).
Chris@42: \def\dopdfimage#1#2#3{%
Chris@42: \def\pdfimagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}%
Chris@42: \def\pdfimageheight{#3}\setbox2 = \hbox{\ignorespaces #3}%
Chris@42: %
Chris@42: % pdftex (and the PDF format) support .pdf, .png, .jpg (among
Chris@42: % others). Let's try in that order, PDF first since if
Chris@42: % someone has a scalable image, presumably better to use that than a
Chris@42: % bitmap.
Chris@42: \let\pdfimgext=\empty
Chris@42: \begingroup
Chris@42: \openin 1 #1.pdf \ifeof 1
Chris@42: \openin 1 #1.PDF \ifeof 1
Chris@42: \openin 1 #1.png \ifeof 1
Chris@42: \openin 1 #1.jpg \ifeof 1
Chris@42: \openin 1 #1.jpeg \ifeof 1
Chris@42: \openin 1 #1.JPG \ifeof 1
Chris@42: \errhelp = \nopdfimagehelp
Chris@42: \errmessage{Could not find image file #1 for pdf}%
Chris@42: \else \gdef\pdfimgext{JPG}%
Chris@42: \fi
Chris@42: \else \gdef\pdfimgext{jpeg}%
Chris@42: \fi
Chris@42: \else \gdef\pdfimgext{jpg}%
Chris@42: \fi
Chris@42: \else \gdef\pdfimgext{png}%
Chris@42: \fi
Chris@42: \else \gdef\pdfimgext{PDF}%
Chris@42: \fi
Chris@42: \else \gdef\pdfimgext{pdf}%
Chris@42: \fi
Chris@42: \closein 1
Chris@42: \endgroup
Chris@42: %
Chris@42: % without \immediate, ancient pdftex seg faults when the same image is
Chris@42: % included twice. (Version 3.14159-pre-1.0-unofficial-20010704.)
Chris@42: \ifnum\pdftexversion < 14
Chris@42: \immediate\pdfimage
Chris@42: \else
Chris@42: \immediate\pdfximage
Chris@42: \fi
Chris@42: \ifdim \wd0 >0pt width \pdfimagewidth \fi
Chris@42: \ifdim \wd2 >0pt height \pdfimageheight \fi
Chris@42: \ifnum\pdftexversion<13
Chris@42: #1.\pdfimgext
Chris@42: \else
Chris@42: {#1.\pdfimgext}%
Chris@42: \fi
Chris@42: \ifnum\pdftexversion < 14 \else
Chris@42: \pdfrefximage \pdflastximage
Chris@42: \fi}
Chris@42: %
Chris@42: \def\pdfmkdest#1{{%
Chris@42: % We have to set dummies so commands such as @code, and characters
Chris@42: % such as \, aren't expanded when present in a section title.
Chris@42: \indexnofonts
Chris@42: \turnoffactive
Chris@42: \makevalueexpandable
Chris@42: \def\pdfdestname{#1}%
Chris@42: \txiescapepdf\pdfdestname
Chris@42: \safewhatsit{\pdfdest name{\pdfdestname} xyz}%
Chris@42: }}
Chris@42: %
Chris@42: % used to mark target names; must be expandable.
Chris@42: \def\pdfmkpgn#1{#1}
Chris@42: %
Chris@42: % by default, use a color that is dark enough to print on paper as
Chris@42: % nearly black, but still distinguishable for online viewing.
Chris@42: \def\urlcolor{\rgbDarkRed}
Chris@42: \def\linkcolor{\rgbDarkRed}
Chris@42: \def\endlink{\setcolor{\maincolor}\pdfendlink}
Chris@42: %
Chris@42: % Adding outlines to PDF; macros for calculating structure of outlines
Chris@42: % come from Petr Olsak
Chris@42: \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0%
Chris@42: \else \csname#1\endcsname \fi}
Chris@42: \def\advancenumber#1{\tempnum=\expnumber{#1}\relax
Chris@42: \advance\tempnum by 1
Chris@42: \expandafter\xdef\csname#1\endcsname{\the\tempnum}}
Chris@42: %
Chris@42: % #1 is the section text, which is what will be displayed in the
Chris@42: % outline by the pdf viewer. #2 is the pdf expression for the number
Chris@42: % of subentries (or empty, for subsubsections). #3 is the node text,
Chris@42: % which might be empty if this toc entry had no corresponding node.
Chris@42: % #4 is the page number
Chris@42: %
Chris@42: \def\dopdfoutline#1#2#3#4{%
Chris@42: % Generate a link to the node text if that exists; else, use the
Chris@42: % page number. We could generate a destination for the section
Chris@42: % text in the case where a section has no node, but it doesn't
Chris@42: % seem worth the trouble, since most documents are normally structured.
Chris@42: \edef\pdfoutlinedest{#3}%
Chris@42: \ifx\pdfoutlinedest\empty
Chris@42: \def\pdfoutlinedest{#4}%
Chris@42: \else
Chris@42: \txiescapepdf\pdfoutlinedest
Chris@42: \fi
Chris@42: %
Chris@42: % Also escape PDF chars in the display string.
Chris@42: \edef\pdfoutlinetext{#1}%
Chris@42: \txiescapepdf\pdfoutlinetext
Chris@42: %
Chris@42: \pdfoutline goto name{\pdfmkpgn{\pdfoutlinedest}}#2{\pdfoutlinetext}%
Chris@42: }
Chris@42: %
Chris@42: \def\pdfmakeoutlines{%
Chris@42: \begingroup
Chris@42: % Read toc silently, to get counts of subentries for \pdfoutline.
Chris@42: \def\partentry##1##2##3##4{}% ignore parts in the outlines
Chris@42: \def\numchapentry##1##2##3##4{%
Chris@42: \def\thischapnum{##2}%
Chris@42: \def\thissecnum{0}%
Chris@42: \def\thissubsecnum{0}%
Chris@42: }%
Chris@42: \def\numsecentry##1##2##3##4{%
Chris@42: \advancenumber{chap\thischapnum}%
Chris@42: \def\thissecnum{##2}%
Chris@42: \def\thissubsecnum{0}%
Chris@42: }%
Chris@42: \def\numsubsecentry##1##2##3##4{%
Chris@42: \advancenumber{sec\thissecnum}%
Chris@42: \def\thissubsecnum{##2}%
Chris@42: }%
Chris@42: \def\numsubsubsecentry##1##2##3##4{%
Chris@42: \advancenumber{subsec\thissubsecnum}%
Chris@42: }%
Chris@42: \def\thischapnum{0}%
Chris@42: \def\thissecnum{0}%
Chris@42: \def\thissubsecnum{0}%
Chris@42: %
Chris@42: % use \def rather than \let here because we redefine \chapentry et
Chris@42: % al. a second time, below.
Chris@42: \def\appentry{\numchapentry}%
Chris@42: \def\appsecentry{\numsecentry}%
Chris@42: \def\appsubsecentry{\numsubsecentry}%
Chris@42: \def\appsubsubsecentry{\numsubsubsecentry}%
Chris@42: \def\unnchapentry{\numchapentry}%
Chris@42: \def\unnsecentry{\numsecentry}%
Chris@42: \def\unnsubsecentry{\numsubsecentry}%
Chris@42: \def\unnsubsubsecentry{\numsubsubsecentry}%
Chris@42: \readdatafile{toc}%
Chris@42: %
Chris@42: % Read toc second time, this time actually producing the outlines.
Chris@42: % The `-' means take the \expnumber as the absolute number of
Chris@42: % subentries, which we calculated on our first read of the .toc above.
Chris@42: %
Chris@42: % We use the node names as the destinations.
Chris@42: \def\numchapentry##1##2##3##4{%
Chris@42: \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}%
Chris@42: \def\numsecentry##1##2##3##4{%
Chris@42: \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}%
Chris@42: \def\numsubsecentry##1##2##3##4{%
Chris@42: \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}%
Chris@42: \def\numsubsubsecentry##1##2##3##4{% count is always zero
Chris@42: \dopdfoutline{##1}{}{##3}{##4}}%
Chris@42: %
Chris@42: % PDF outlines are displayed using system fonts, instead of
Chris@42: % document fonts. Therefore we cannot use special characters,
Chris@42: % since the encoding is unknown. For example, the eogonek from
Chris@42: % Latin 2 (0xea) gets translated to a | character. Info from
Chris@42: % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100.
Chris@42: %
Chris@42: % TODO this right, we have to translate 8-bit characters to
Chris@42: % their "best" equivalent, based on the @documentencoding. Too
Chris@42: % much work for too little return. Just use the ASCII equivalents
Chris@42: % we use for the index sort strings.
Chris@42: %
Chris@42: \indexnofonts
Chris@42: \setupdatafile
Chris@42: % We can have normal brace characters in the PDF outlines, unlike
Chris@42: % Texinfo index files. So set that up.
Chris@42: \def\{{\lbracecharliteral}%
Chris@42: \def\}{\rbracecharliteral}%
Chris@42: \catcode`\\=\active \otherbackslash
Chris@42: \input \tocreadfilename
Chris@42: \endgroup
Chris@42: }
Chris@42: {\catcode`[=1 \catcode`]=2
Chris@42: \catcode`{=\other \catcode`}=\other
Chris@42: \gdef\lbracecharliteral[{]%
Chris@42: \gdef\rbracecharliteral[}]%
Chris@42: ]
Chris@42: %
Chris@42: \def\skipspaces#1{\def\PP{#1}\def\D{|}%
Chris@42: \ifx\PP\D\let\nextsp\relax
Chris@42: \else\let\nextsp\skipspaces
Chris@42: \addtokens{\filename}{\PP}%
Chris@42: \advance\filenamelength by 1
Chris@42: \fi
Chris@42: \nextsp}
Chris@42: \def\getfilename#1{%
Chris@42: \filenamelength=0
Chris@42: % If we don't expand the argument now, \skipspaces will get
Chris@42: % snagged on things like "@value{foo}".
Chris@42: \edef\temp{#1}%
Chris@42: \expandafter\skipspaces\temp|\relax
Chris@42: }
Chris@42: \ifnum\pdftexversion < 14
Chris@42: \let \startlink \pdfannotlink
Chris@42: \else
Chris@42: \let \startlink \pdfstartlink
Chris@42: \fi
Chris@42: % make a live url in pdf output.
Chris@42: \def\pdfurl#1{%
Chris@42: \begingroup
Chris@42: % it seems we really need yet another set of dummies; have not
Chris@42: % tried to figure out what each command should do in the context
Chris@42: % of @url. for now, just make @/ a no-op, that's the only one
Chris@42: % people have actually reported a problem with.
Chris@42: %
Chris@42: \normalturnoffactive
Chris@42: \def\@{@}%
Chris@42: \let\/=\empty
Chris@42: \makevalueexpandable
Chris@42: % do we want to go so far as to use \indexnofonts instead of just
Chris@42: % special-casing \var here?
Chris@42: \def\var##1{##1}%
Chris@42: %
Chris@42: \leavevmode\setcolor{\urlcolor}%
Chris@42: \startlink attr{/Border [0 0 0]}%
Chris@42: user{/Subtype /Link /A << /S /URI /URI (#1) >>}%
Chris@42: \endgroup}
Chris@42: \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}}
Chris@42: \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks}
Chris@42: \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks}
Chris@42: \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}}
Chris@42: \def\maketoks{%
Chris@42: \expandafter\poptoks\the\toksA|ENDTOKS|\relax
Chris@42: \ifx\first0\adn0
Chris@42: \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3
Chris@42: \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6
Chris@42: \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9
Chris@42: \else
Chris@42: \ifnum0=\countA\else\makelink\fi
Chris@42: \ifx\first.\let\next=\done\else
Chris@42: \let\next=\maketoks
Chris@42: \addtokens{\toksB}{\the\toksD}
Chris@42: \ifx\first,\addtokens{\toksB}{\space}\fi
Chris@42: \fi
Chris@42: \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
Chris@42: \next}
Chris@42: \def\makelink{\addtokens{\toksB}%
Chris@42: {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0}
Chris@42: \def\pdflink#1{%
Chris@42: \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}}
Chris@42: \setcolor{\linkcolor}#1\endlink}
Chris@42: \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st}
Chris@42: \else
Chris@42: % non-pdf mode
Chris@42: \let\pdfmkdest = \gobble
Chris@42: \let\pdfurl = \gobble
Chris@42: \let\endlink = \relax
Chris@42: \let\setcolor = \gobble
Chris@42: \let\pdfsetcolor = \gobble
Chris@42: \let\pdfmakeoutlines = \relax
Chris@42: \fi % \ifx\pdfoutput
Chris@42:
Chris@42:
Chris@42: \message{fonts,}
Chris@42:
Chris@42: % Change the current font style to #1, remembering it in \curfontstyle.
Chris@42: % For now, we do not accumulate font styles: @b{@i{foo}} prints foo in
Chris@42: % italics, not bold italics.
Chris@42: %
Chris@42: \def\setfontstyle#1{%
Chris@42: \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd.
Chris@42: \csname ten#1\endcsname % change the current font
Chris@42: }
Chris@42:
Chris@42: % Select #1 fonts with the current style.
Chris@42: %
Chris@42: \def\selectfonts#1{\csname #1fonts\endcsname \csname\curfontstyle\endcsname}
Chris@42:
Chris@42: \def\rm{\fam=0 \setfontstyle{rm}}
Chris@42: \def\it{\fam=\itfam \setfontstyle{it}}
Chris@42: \def\sl{\fam=\slfam \setfontstyle{sl}}
Chris@42: \def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf}
Chris@42: \def\tt{\fam=\ttfam \setfontstyle{tt}}
Chris@42:
Chris@42: % Unfortunately, we have to override this for titles and the like, since
Chris@42: % in those cases "rm" is bold. Sigh.
Chris@42: \def\rmisbold{\rm\def\curfontstyle{bf}}
Chris@42:
Chris@42: % Texinfo sort of supports the sans serif font style, which plain TeX does not.
Chris@42: % So we set up a \sf.
Chris@42: \newfam\sffam
Chris@42: \def\sf{\fam=\sffam \setfontstyle{sf}}
Chris@42: \let\li = \sf % Sometimes we call it \li, not \sf.
Chris@42:
Chris@42: % We don't need math for this font style.
Chris@42: \def\ttsl{\setfontstyle{ttsl}}
Chris@42:
Chris@42:
Chris@42: % Set the baselineskip to #1, and the lineskip and strut size
Chris@42: % correspondingly. There is no deep meaning behind these magic numbers
Chris@42: % used as factors; they just match (closely enough) what Knuth defined.
Chris@42: %
Chris@42: \def\lineskipfactor{.08333}
Chris@42: \def\strutheightpercent{.70833}
Chris@42: \def\strutdepthpercent {.29167}
Chris@42: %
Chris@42: % can get a sort of poor man's double spacing by redefining this.
Chris@42: \def\baselinefactor{1}
Chris@42: %
Chris@42: \newdimen\textleading
Chris@42: \def\setleading#1{%
Chris@42: \dimen0 = #1\relax
Chris@42: \normalbaselineskip = \baselinefactor\dimen0
Chris@42: \normallineskip = \lineskipfactor\normalbaselineskip
Chris@42: \normalbaselines
Chris@42: \setbox\strutbox =\hbox{%
Chris@42: \vrule width0pt height\strutheightpercent\baselineskip
Chris@42: depth \strutdepthpercent \baselineskip
Chris@42: }%
Chris@42: }
Chris@42:
Chris@42: % PDF CMaps. See also LaTeX's t1.cmap.
Chris@42: %
Chris@42: % do nothing with this by default.
Chris@42: \expandafter\let\csname cmapOT1\endcsname\gobble
Chris@42: \expandafter\let\csname cmapOT1IT\endcsname\gobble
Chris@42: \expandafter\let\csname cmapOT1TT\endcsname\gobble
Chris@42:
Chris@42: % if we are producing pdf, and we have \pdffontattr, then define cmaps.
Chris@42: % (\pdffontattr was introduced many years ago, but people still run
Chris@42: % older pdftex's; it's easy to conditionalize, so we do.)
Chris@42: \ifpdf \ifx\pdffontattr\thisisundefined \else
Chris@42: \begingroup
Chris@42: \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
Chris@42: \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
Chris@42: %%DocumentNeededResources: ProcSet (CIDInit)
Chris@42: %%IncludeResource: ProcSet (CIDInit)
Chris@42: %%BeginResource: CMap (TeX-OT1-0)
Chris@42: %%Title: (TeX-OT1-0 TeX OT1 0)
Chris@42: %%Version: 1.000
Chris@42: %%EndComments
Chris@42: /CIDInit /ProcSet findresource begin
Chris@42: 12 dict begin
Chris@42: begincmap
Chris@42: /CIDSystemInfo
Chris@42: << /Registry (TeX)
Chris@42: /Ordering (OT1)
Chris@42: /Supplement 0
Chris@42: >> def
Chris@42: /CMapName /TeX-OT1-0 def
Chris@42: /CMapType 2 def
Chris@42: 1 begincodespacerange
Chris@42: <00> <7F>
Chris@42: endcodespacerange
Chris@42: 8 beginbfrange
Chris@42: <00> <01> <0393>
Chris@42: <09> <0A> <03A8>
Chris@42: <23> <26> <0023>
Chris@42: <28> <3B> <0028>
Chris@42: <3F> <5B> <003F>
Chris@42: <5D> <5E> <005D>
Chris@42: <61> <7A> <0061>
Chris@42: <7B> <7C> <2013>
Chris@42: endbfrange
Chris@42: 40 beginbfchar
Chris@42: <02> <0398>
Chris@42: <03> <039B>
Chris@42: <04> <039E>
Chris@42: <05> <03A0>
Chris@42: <06> <03A3>
Chris@42: <07> <03D2>
Chris@42: <08> <03A6>
Chris@42: <0B> <00660066>
Chris@42: <0C> <00660069>
Chris@42: <0D> <0066006C>
Chris@42: <0E> <006600660069>
Chris@42: <0F> <00660066006C>
Chris@42: <10> <0131>
Chris@42: <11> <0237>
Chris@42: <12> <0060>
Chris@42: <13> <00B4>
Chris@42: <14> <02C7>
Chris@42: <15> <02D8>
Chris@42: <16> <00AF>
Chris@42: <17> <02DA>
Chris@42: <18> <00B8>
Chris@42: <19> <00DF>
Chris@42: <1A> <00E6>
Chris@42: <1B> <0153>
Chris@42: <1C> <00F8>
Chris@42: <1D> <00C6>
Chris@42: <1E> <0152>
Chris@42: <1F> <00D8>
Chris@42: <21> <0021>
Chris@42: <22> <201D>
Chris@42: <27> <2019>
Chris@42: <3C> <00A1>
Chris@42: <3D> <003D>
Chris@42: <3E> <00BF>
Chris@42: <5C> <201C>
Chris@42: <5F> <02D9>
Chris@42: <60> <2018>
Chris@42: <7D> <02DD>
Chris@42: <7E> <007E>
Chris@42: <7F> <00A8>
Chris@42: endbfchar
Chris@42: endcmap
Chris@42: CMapName currentdict /CMap defineresource pop
Chris@42: end
Chris@42: end
Chris@42: %%EndResource
Chris@42: %%EOF
Chris@42: }\endgroup
Chris@42: \expandafter\edef\csname cmapOT1\endcsname#1{%
Chris@42: \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
Chris@42: }%
Chris@42: %
Chris@42: % \cmapOT1IT
Chris@42: \begingroup
Chris@42: \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
Chris@42: \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
Chris@42: %%DocumentNeededResources: ProcSet (CIDInit)
Chris@42: %%IncludeResource: ProcSet (CIDInit)
Chris@42: %%BeginResource: CMap (TeX-OT1IT-0)
Chris@42: %%Title: (TeX-OT1IT-0 TeX OT1IT 0)
Chris@42: %%Version: 1.000
Chris@42: %%EndComments
Chris@42: /CIDInit /ProcSet findresource begin
Chris@42: 12 dict begin
Chris@42: begincmap
Chris@42: /CIDSystemInfo
Chris@42: << /Registry (TeX)
Chris@42: /Ordering (OT1IT)
Chris@42: /Supplement 0
Chris@42: >> def
Chris@42: /CMapName /TeX-OT1IT-0 def
Chris@42: /CMapType 2 def
Chris@42: 1 begincodespacerange
Chris@42: <00> <7F>
Chris@42: endcodespacerange
Chris@42: 8 beginbfrange
Chris@42: <00> <01> <0393>
Chris@42: <09> <0A> <03A8>
Chris@42: <25> <26> <0025>
Chris@42: <28> <3B> <0028>
Chris@42: <3F> <5B> <003F>
Chris@42: <5D> <5E> <005D>
Chris@42: <61> <7A> <0061>
Chris@42: <7B> <7C> <2013>
Chris@42: endbfrange
Chris@42: 42 beginbfchar
Chris@42: <02> <0398>
Chris@42: <03> <039B>
Chris@42: <04> <039E>
Chris@42: <05> <03A0>
Chris@42: <06> <03A3>
Chris@42: <07> <03D2>
Chris@42: <08> <03A6>
Chris@42: <0B> <00660066>
Chris@42: <0C> <00660069>
Chris@42: <0D> <0066006C>
Chris@42: <0E> <006600660069>
Chris@42: <0F> <00660066006C>
Chris@42: <10> <0131>
Chris@42: <11> <0237>
Chris@42: <12> <0060>
Chris@42: <13> <00B4>
Chris@42: <14> <02C7>
Chris@42: <15> <02D8>
Chris@42: <16> <00AF>
Chris@42: <17> <02DA>
Chris@42: <18> <00B8>
Chris@42: <19> <00DF>
Chris@42: <1A> <00E6>
Chris@42: <1B> <0153>
Chris@42: <1C> <00F8>
Chris@42: <1D> <00C6>
Chris@42: <1E> <0152>
Chris@42: <1F> <00D8>
Chris@42: <21> <0021>
Chris@42: <22> <201D>
Chris@42: <23> <0023>
Chris@42: <24> <00A3>
Chris@42: <27> <2019>
Chris@42: <3C> <00A1>
Chris@42: <3D> <003D>
Chris@42: <3E> <00BF>
Chris@42: <5C> <201C>
Chris@42: <5F> <02D9>
Chris@42: <60> <2018>
Chris@42: <7D> <02DD>
Chris@42: <7E> <007E>
Chris@42: <7F> <00A8>
Chris@42: endbfchar
Chris@42: endcmap
Chris@42: CMapName currentdict /CMap defineresource pop
Chris@42: end
Chris@42: end
Chris@42: %%EndResource
Chris@42: %%EOF
Chris@42: }\endgroup
Chris@42: \expandafter\edef\csname cmapOT1IT\endcsname#1{%
Chris@42: \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
Chris@42: }%
Chris@42: %
Chris@42: % \cmapOT1TT
Chris@42: \begingroup
Chris@42: \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char.
Chris@42: \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap
Chris@42: %%DocumentNeededResources: ProcSet (CIDInit)
Chris@42: %%IncludeResource: ProcSet (CIDInit)
Chris@42: %%BeginResource: CMap (TeX-OT1TT-0)
Chris@42: %%Title: (TeX-OT1TT-0 TeX OT1TT 0)
Chris@42: %%Version: 1.000
Chris@42: %%EndComments
Chris@42: /CIDInit /ProcSet findresource begin
Chris@42: 12 dict begin
Chris@42: begincmap
Chris@42: /CIDSystemInfo
Chris@42: << /Registry (TeX)
Chris@42: /Ordering (OT1TT)
Chris@42: /Supplement 0
Chris@42: >> def
Chris@42: /CMapName /TeX-OT1TT-0 def
Chris@42: /CMapType 2 def
Chris@42: 1 begincodespacerange
Chris@42: <00> <7F>
Chris@42: endcodespacerange
Chris@42: 5 beginbfrange
Chris@42: <00> <01> <0393>
Chris@42: <09> <0A> <03A8>
Chris@42: <21> <26> <0021>
Chris@42: <28> <5F> <0028>
Chris@42: <61> <7E> <0061>
Chris@42: endbfrange
Chris@42: 32 beginbfchar
Chris@42: <02> <0398>
Chris@42: <03> <039B>
Chris@42: <04> <039E>
Chris@42: <05> <03A0>
Chris@42: <06> <03A3>
Chris@42: <07> <03D2>
Chris@42: <08> <03A6>
Chris@42: <0B> <2191>
Chris@42: <0C> <2193>
Chris@42: <0D> <0027>
Chris@42: <0E> <00A1>
Chris@42: <0F> <00BF>
Chris@42: <10> <0131>
Chris@42: <11> <0237>
Chris@42: <12> <0060>
Chris@42: <13> <00B4>
Chris@42: <14> <02C7>
Chris@42: <15> <02D8>
Chris@42: <16> <00AF>
Chris@42: <17> <02DA>
Chris@42: <18> <00B8>
Chris@42: <19> <00DF>
Chris@42: <1A> <00E6>
Chris@42: <1B> <0153>
Chris@42: <1C> <00F8>
Chris@42: <1D> <00C6>
Chris@42: <1E> <0152>
Chris@42: <1F> <00D8>
Chris@42: <20> <2423>
Chris@42: <27> <2019>
Chris@42: <60> <2018>
Chris@42: <7F> <00A8>
Chris@42: endbfchar
Chris@42: endcmap
Chris@42: CMapName currentdict /CMap defineresource pop
Chris@42: end
Chris@42: end
Chris@42: %%EndResource
Chris@42: %%EOF
Chris@42: }\endgroup
Chris@42: \expandafter\edef\csname cmapOT1TT\endcsname#1{%
Chris@42: \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}%
Chris@42: }%
Chris@42: \fi\fi
Chris@42:
Chris@42:
Chris@42: % Set the font macro #1 to the font named \fontprefix#2.
Chris@42: % #3 is the font's design size, #4 is a scale factor, #5 is the CMap
Chris@42: % encoding (only OT1, OT1IT and OT1TT are allowed, or empty to omit).
Chris@42: % Example:
Chris@42: % #1 = \textrm
Chris@42: % #2 = \rmshape
Chris@42: % #3 = 10
Chris@42: % #4 = \mainmagstep
Chris@42: % #5 = OT1
Chris@42: %
Chris@42: \def\setfont#1#2#3#4#5{%
Chris@42: \font#1=\fontprefix#2#3 scaled #4
Chris@42: \csname cmap#5\endcsname#1%
Chris@42: }
Chris@42: % This is what gets called when #5 of \setfont is empty.
Chris@42: \let\cmap\gobble
Chris@42: %
Chris@42: % (end of cmaps)
Chris@42:
Chris@42: % Use cm as the default font prefix.
Chris@42: % To specify the font prefix, you must define \fontprefix
Chris@42: % before you read in texinfo.tex.
Chris@42: \ifx\fontprefix\thisisundefined
Chris@42: \def\fontprefix{cm}
Chris@42: \fi
Chris@42: % Support font families that don't use the same naming scheme as CM.
Chris@42: \def\rmshape{r}
Chris@42: \def\rmbshape{bx} % where the normal face is bold
Chris@42: \def\bfshape{b}
Chris@42: \def\bxshape{bx}
Chris@42: \def\ttshape{tt}
Chris@42: \def\ttbshape{tt}
Chris@42: \def\ttslshape{sltt}
Chris@42: \def\itshape{ti}
Chris@42: \def\itbshape{bxti}
Chris@42: \def\slshape{sl}
Chris@42: \def\slbshape{bxsl}
Chris@42: \def\sfshape{ss}
Chris@42: \def\sfbshape{ss}
Chris@42: \def\scshape{csc}
Chris@42: \def\scbshape{csc}
Chris@42:
Chris@42: % Definitions for a main text size of 11pt. (The default in Texinfo.)
Chris@42: %
Chris@42: \def\definetextfontsizexi{%
Chris@42: % Text fonts (11.2pt, magstep1).
Chris@42: \def\textnominalsize{11pt}
Chris@42: \edef\mainmagstep{\magstephalf}
Chris@42: \setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
Chris@42: \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
Chris@42: \setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
Chris@42: \setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
Chris@42: \setfont\textsl\slshape{10}{\mainmagstep}{OT1}
Chris@42: \setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
Chris@42: \setfont\textsc\scshape{10}{\mainmagstep}{OT1}
Chris@42: \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
Chris@42: \font\texti=cmmi10 scaled \mainmagstep
Chris@42: \font\textsy=cmsy10 scaled \mainmagstep
Chris@42: \def\textecsize{1095}
Chris@42:
Chris@42: % A few fonts for @defun names and args.
Chris@42: \setfont\defbf\bfshape{10}{\magstep1}{OT1}
Chris@42: \setfont\deftt\ttshape{10}{\magstep1}{OT1TT}
Chris@42: \setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT}
Chris@42: \def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf}
Chris@42:
Chris@42: % Fonts for indices, footnotes, small examples (9pt).
Chris@42: \def\smallnominalsize{9pt}
Chris@42: \setfont\smallrm\rmshape{9}{1000}{OT1}
Chris@42: \setfont\smalltt\ttshape{9}{1000}{OT1TT}
Chris@42: \setfont\smallbf\bfshape{10}{900}{OT1}
Chris@42: \setfont\smallit\itshape{9}{1000}{OT1IT}
Chris@42: \setfont\smallsl\slshape{9}{1000}{OT1}
Chris@42: \setfont\smallsf\sfshape{9}{1000}{OT1}
Chris@42: \setfont\smallsc\scshape{10}{900}{OT1}
Chris@42: \setfont\smallttsl\ttslshape{10}{900}{OT1TT}
Chris@42: \font\smalli=cmmi9
Chris@42: \font\smallsy=cmsy9
Chris@42: \def\smallecsize{0900}
Chris@42:
Chris@42: % Fonts for small examples (8pt).
Chris@42: \def\smallernominalsize{8pt}
Chris@42: \setfont\smallerrm\rmshape{8}{1000}{OT1}
Chris@42: \setfont\smallertt\ttshape{8}{1000}{OT1TT}
Chris@42: \setfont\smallerbf\bfshape{10}{800}{OT1}
Chris@42: \setfont\smallerit\itshape{8}{1000}{OT1IT}
Chris@42: \setfont\smallersl\slshape{8}{1000}{OT1}
Chris@42: \setfont\smallersf\sfshape{8}{1000}{OT1}
Chris@42: \setfont\smallersc\scshape{10}{800}{OT1}
Chris@42: \setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
Chris@42: \font\smalleri=cmmi8
Chris@42: \font\smallersy=cmsy8
Chris@42: \def\smallerecsize{0800}
Chris@42:
Chris@42: % Fonts for title page (20.4pt):
Chris@42: \def\titlenominalsize{20pt}
Chris@42: \setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
Chris@42: \setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
Chris@42: \setfont\titlesl\slbshape{10}{\magstep4}{OT1}
Chris@42: \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
Chris@42: \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
Chris@42: \setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
Chris@42: \let\titlebf=\titlerm
Chris@42: \setfont\titlesc\scbshape{10}{\magstep4}{OT1}
Chris@42: \font\titlei=cmmi12 scaled \magstep3
Chris@42: \font\titlesy=cmsy10 scaled \magstep4
Chris@42: \def\titleecsize{2074}
Chris@42:
Chris@42: % Chapter (and unnumbered) fonts (17.28pt).
Chris@42: \def\chapnominalsize{17pt}
Chris@42: \setfont\chaprm\rmbshape{12}{\magstep2}{OT1}
Chris@42: \setfont\chapit\itbshape{10}{\magstep3}{OT1IT}
Chris@42: \setfont\chapsl\slbshape{10}{\magstep3}{OT1}
Chris@42: \setfont\chaptt\ttbshape{12}{\magstep2}{OT1TT}
Chris@42: \setfont\chapttsl\ttslshape{10}{\magstep3}{OT1TT}
Chris@42: \setfont\chapsf\sfbshape{17}{1000}{OT1}
Chris@42: \let\chapbf=\chaprm
Chris@42: \setfont\chapsc\scbshape{10}{\magstep3}{OT1}
Chris@42: \font\chapi=cmmi12 scaled \magstep2
Chris@42: \font\chapsy=cmsy10 scaled \magstep3
Chris@42: \def\chapecsize{1728}
Chris@42:
Chris@42: % Section fonts (14.4pt).
Chris@42: \def\secnominalsize{14pt}
Chris@42: \setfont\secrm\rmbshape{12}{\magstep1}{OT1}
Chris@42: \setfont\secit\itbshape{10}{\magstep2}{OT1IT}
Chris@42: \setfont\secsl\slbshape{10}{\magstep2}{OT1}
Chris@42: \setfont\sectt\ttbshape{12}{\magstep1}{OT1TT}
Chris@42: \setfont\secttsl\ttslshape{10}{\magstep2}{OT1TT}
Chris@42: \setfont\secsf\sfbshape{12}{\magstep1}{OT1}
Chris@42: \let\secbf\secrm
Chris@42: \setfont\secsc\scbshape{10}{\magstep2}{OT1}
Chris@42: \font\seci=cmmi12 scaled \magstep1
Chris@42: \font\secsy=cmsy10 scaled \magstep2
Chris@42: \def\sececsize{1440}
Chris@42:
Chris@42: % Subsection fonts (13.15pt).
Chris@42: \def\ssecnominalsize{13pt}
Chris@42: \setfont\ssecrm\rmbshape{12}{\magstephalf}{OT1}
Chris@42: \setfont\ssecit\itbshape{10}{1315}{OT1IT}
Chris@42: \setfont\ssecsl\slbshape{10}{1315}{OT1}
Chris@42: \setfont\ssectt\ttbshape{12}{\magstephalf}{OT1TT}
Chris@42: \setfont\ssecttsl\ttslshape{10}{1315}{OT1TT}
Chris@42: \setfont\ssecsf\sfbshape{12}{\magstephalf}{OT1}
Chris@42: \let\ssecbf\ssecrm
Chris@42: \setfont\ssecsc\scbshape{10}{1315}{OT1}
Chris@42: \font\sseci=cmmi12 scaled \magstephalf
Chris@42: \font\ssecsy=cmsy10 scaled 1315
Chris@42: \def\ssececsize{1200}
Chris@42:
Chris@42: % Reduced fonts for @acro in text (10pt).
Chris@42: \def\reducednominalsize{10pt}
Chris@42: \setfont\reducedrm\rmshape{10}{1000}{OT1}
Chris@42: \setfont\reducedtt\ttshape{10}{1000}{OT1TT}
Chris@42: \setfont\reducedbf\bfshape{10}{1000}{OT1}
Chris@42: \setfont\reducedit\itshape{10}{1000}{OT1IT}
Chris@42: \setfont\reducedsl\slshape{10}{1000}{OT1}
Chris@42: \setfont\reducedsf\sfshape{10}{1000}{OT1}
Chris@42: \setfont\reducedsc\scshape{10}{1000}{OT1}
Chris@42: \setfont\reducedttsl\ttslshape{10}{1000}{OT1TT}
Chris@42: \font\reducedi=cmmi10
Chris@42: \font\reducedsy=cmsy10
Chris@42: \def\reducedecsize{1000}
Chris@42:
Chris@42: \textleading = 13.2pt % line spacing for 11pt CM
Chris@42: \textfonts % reset the current fonts
Chris@42: \rm
Chris@42: } % end of 11pt text font size definitions, \definetextfontsizexi
Chris@42:
Chris@42:
Chris@42: % Definitions to make the main text be 10pt Computer Modern, with
Chris@42: % section, chapter, etc., sizes following suit. This is for the GNU
Chris@42: % Press printing of the Emacs 22 manual. Maybe other manuals in the
Chris@42: % future. Used with @smallbook, which sets the leading to 12pt.
Chris@42: %
Chris@42: \def\definetextfontsizex{%
Chris@42: % Text fonts (10pt).
Chris@42: \def\textnominalsize{10pt}
Chris@42: \edef\mainmagstep{1000}
Chris@42: \setfont\textrm\rmshape{10}{\mainmagstep}{OT1}
Chris@42: \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT}
Chris@42: \setfont\textbf\bfshape{10}{\mainmagstep}{OT1}
Chris@42: \setfont\textit\itshape{10}{\mainmagstep}{OT1IT}
Chris@42: \setfont\textsl\slshape{10}{\mainmagstep}{OT1}
Chris@42: \setfont\textsf\sfshape{10}{\mainmagstep}{OT1}
Chris@42: \setfont\textsc\scshape{10}{\mainmagstep}{OT1}
Chris@42: \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT}
Chris@42: \font\texti=cmmi10 scaled \mainmagstep
Chris@42: \font\textsy=cmsy10 scaled \mainmagstep
Chris@42: \def\textecsize{1000}
Chris@42:
Chris@42: % A few fonts for @defun names and args.
Chris@42: \setfont\defbf\bfshape{10}{\magstephalf}{OT1}
Chris@42: \setfont\deftt\ttshape{10}{\magstephalf}{OT1TT}
Chris@42: \setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT}
Chris@42: \def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf}
Chris@42:
Chris@42: % Fonts for indices, footnotes, small examples (9pt).
Chris@42: \def\smallnominalsize{9pt}
Chris@42: \setfont\smallrm\rmshape{9}{1000}{OT1}
Chris@42: \setfont\smalltt\ttshape{9}{1000}{OT1TT}
Chris@42: \setfont\smallbf\bfshape{10}{900}{OT1}
Chris@42: \setfont\smallit\itshape{9}{1000}{OT1IT}
Chris@42: \setfont\smallsl\slshape{9}{1000}{OT1}
Chris@42: \setfont\smallsf\sfshape{9}{1000}{OT1}
Chris@42: \setfont\smallsc\scshape{10}{900}{OT1}
Chris@42: \setfont\smallttsl\ttslshape{10}{900}{OT1TT}
Chris@42: \font\smalli=cmmi9
Chris@42: \font\smallsy=cmsy9
Chris@42: \def\smallecsize{0900}
Chris@42:
Chris@42: % Fonts for small examples (8pt).
Chris@42: \def\smallernominalsize{8pt}
Chris@42: \setfont\smallerrm\rmshape{8}{1000}{OT1}
Chris@42: \setfont\smallertt\ttshape{8}{1000}{OT1TT}
Chris@42: \setfont\smallerbf\bfshape{10}{800}{OT1}
Chris@42: \setfont\smallerit\itshape{8}{1000}{OT1IT}
Chris@42: \setfont\smallersl\slshape{8}{1000}{OT1}
Chris@42: \setfont\smallersf\sfshape{8}{1000}{OT1}
Chris@42: \setfont\smallersc\scshape{10}{800}{OT1}
Chris@42: \setfont\smallerttsl\ttslshape{10}{800}{OT1TT}
Chris@42: \font\smalleri=cmmi8
Chris@42: \font\smallersy=cmsy8
Chris@42: \def\smallerecsize{0800}
Chris@42:
Chris@42: % Fonts for title page (20.4pt):
Chris@42: \def\titlenominalsize{20pt}
Chris@42: \setfont\titlerm\rmbshape{12}{\magstep3}{OT1}
Chris@42: \setfont\titleit\itbshape{10}{\magstep4}{OT1IT}
Chris@42: \setfont\titlesl\slbshape{10}{\magstep4}{OT1}
Chris@42: \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT}
Chris@42: \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT}
Chris@42: \setfont\titlesf\sfbshape{17}{\magstep1}{OT1}
Chris@42: \let\titlebf=\titlerm
Chris@42: \setfont\titlesc\scbshape{10}{\magstep4}{OT1}
Chris@42: \font\titlei=cmmi12 scaled \magstep3
Chris@42: \font\titlesy=cmsy10 scaled \magstep4
Chris@42: \def\titleecsize{2074}
Chris@42:
Chris@42: % Chapter fonts (14.4pt).
Chris@42: \def\chapnominalsize{14pt}
Chris@42: \setfont\chaprm\rmbshape{12}{\magstep1}{OT1}
Chris@42: \setfont\chapit\itbshape{10}{\magstep2}{OT1IT}
Chris@42: \setfont\chapsl\slbshape{10}{\magstep2}{OT1}
Chris@42: \setfont\chaptt\ttbshape{12}{\magstep1}{OT1TT}
Chris@42: \setfont\chapttsl\ttslshape{10}{\magstep2}{OT1TT}
Chris@42: \setfont\chapsf\sfbshape{12}{\magstep1}{OT1}
Chris@42: \let\chapbf\chaprm
Chris@42: \setfont\chapsc\scbshape{10}{\magstep2}{OT1}
Chris@42: \font\chapi=cmmi12 scaled \magstep1
Chris@42: \font\chapsy=cmsy10 scaled \magstep2
Chris@42: \def\chapecsize{1440}
Chris@42:
Chris@42: % Section fonts (12pt).
Chris@42: \def\secnominalsize{12pt}
Chris@42: \setfont\secrm\rmbshape{12}{1000}{OT1}
Chris@42: \setfont\secit\itbshape{10}{\magstep1}{OT1IT}
Chris@42: \setfont\secsl\slbshape{10}{\magstep1}{OT1}
Chris@42: \setfont\sectt\ttbshape{12}{1000}{OT1TT}
Chris@42: \setfont\secttsl\ttslshape{10}{\magstep1}{OT1TT}
Chris@42: \setfont\secsf\sfbshape{12}{1000}{OT1}
Chris@42: \let\secbf\secrm
Chris@42: \setfont\secsc\scbshape{10}{\magstep1}{OT1}
Chris@42: \font\seci=cmmi12
Chris@42: \font\secsy=cmsy10 scaled \magstep1
Chris@42: \def\sececsize{1200}
Chris@42:
Chris@42: % Subsection fonts (10pt).
Chris@42: \def\ssecnominalsize{10pt}
Chris@42: \setfont\ssecrm\rmbshape{10}{1000}{OT1}
Chris@42: \setfont\ssecit\itbshape{10}{1000}{OT1IT}
Chris@42: \setfont\ssecsl\slbshape{10}{1000}{OT1}
Chris@42: \setfont\ssectt\ttbshape{10}{1000}{OT1TT}
Chris@42: \setfont\ssecttsl\ttslshape{10}{1000}{OT1TT}
Chris@42: \setfont\ssecsf\sfbshape{10}{1000}{OT1}
Chris@42: \let\ssecbf\ssecrm
Chris@42: \setfont\ssecsc\scbshape{10}{1000}{OT1}
Chris@42: \font\sseci=cmmi10
Chris@42: \font\ssecsy=cmsy10
Chris@42: \def\ssececsize{1000}
Chris@42:
Chris@42: % Reduced fonts for @acro in text (9pt).
Chris@42: \def\reducednominalsize{9pt}
Chris@42: \setfont\reducedrm\rmshape{9}{1000}{OT1}
Chris@42: \setfont\reducedtt\ttshape{9}{1000}{OT1TT}
Chris@42: \setfont\reducedbf\bfshape{10}{900}{OT1}
Chris@42: \setfont\reducedit\itshape{9}{1000}{OT1IT}
Chris@42: \setfont\reducedsl\slshape{9}{1000}{OT1}
Chris@42: \setfont\reducedsf\sfshape{9}{1000}{OT1}
Chris@42: \setfont\reducedsc\scshape{10}{900}{OT1}
Chris@42: \setfont\reducedttsl\ttslshape{10}{900}{OT1TT}
Chris@42: \font\reducedi=cmmi9
Chris@42: \font\reducedsy=cmsy9
Chris@42: \def\reducedecsize{0900}
Chris@42:
Chris@42: \divide\parskip by 2 % reduce space between paragraphs
Chris@42: \textleading = 12pt % line spacing for 10pt CM
Chris@42: \textfonts % reset the current fonts
Chris@42: \rm
Chris@42: } % end of 10pt text font size definitions, \definetextfontsizex
Chris@42:
Chris@42:
Chris@42: % We provide the user-level command
Chris@42: % @fonttextsize 10
Chris@42: % (or 11) to redefine the text font size. pt is assumed.
Chris@42: %
Chris@42: \def\xiword{11}
Chris@42: \def\xword{10}
Chris@42: \def\xwordpt{10pt}
Chris@42: %
Chris@42: \parseargdef\fonttextsize{%
Chris@42: \def\textsizearg{#1}%
Chris@42: %\wlog{doing @fonttextsize \textsizearg}%
Chris@42: %
Chris@42: % Set \globaldefs so that documents can use this inside @tex, since
Chris@42: % makeinfo 4.8 does not support it, but we need it nonetheless.
Chris@42: %
Chris@42: \begingroup \globaldefs=1
Chris@42: \ifx\textsizearg\xword \definetextfontsizex
Chris@42: \else \ifx\textsizearg\xiword \definetextfontsizexi
Chris@42: \else
Chris@42: \errhelp=\EMsimple
Chris@42: \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'}
Chris@42: \fi\fi
Chris@42: \endgroup
Chris@42: }
Chris@42:
Chris@42:
Chris@42: % In order for the font changes to affect most math symbols and letters,
Chris@42: % we have to define the \textfont of the standard families. Since
Chris@42: % texinfo doesn't allow for producing subscripts and superscripts except
Chris@42: % in the main text, we don't bother to reset \scriptfont and
Chris@42: % \scriptscriptfont (which would also require loading a lot more fonts).
Chris@42: %
Chris@42: \def\resetmathfonts{%
Chris@42: \textfont0=\tenrm \textfont1=\teni \textfont2=\tensy
Chris@42: \textfont\itfam=\tenit \textfont\slfam=\tensl \textfont\bffam=\tenbf
Chris@42: \textfont\ttfam=\tentt \textfont\sffam=\tensf
Chris@42: }
Chris@42:
Chris@42: % The font-changing commands redefine the meanings of \tenSTYLE, instead
Chris@42: % of just \STYLE. We do this because \STYLE needs to also set the
Chris@42: % current \fam for math mode. Our \STYLE (e.g., \rm) commands hardwire
Chris@42: % \tenSTYLE to set the current font.
Chris@42: %
Chris@42: % Each font-changing command also sets the names \lsize (one size lower)
Chris@42: % and \lllsize (three sizes lower). These relative commands are used in
Chris@42: % the LaTeX logo and acronyms.
Chris@42: %
Chris@42: % This all needs generalizing, badly.
Chris@42: %
Chris@42: \def\textfonts{%
Chris@42: \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl
Chris@42: \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc
Chris@42: \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy
Chris@42: \let\tenttsl=\textttsl
Chris@42: \def\curfontsize{text}%
Chris@42: \def\lsize{reduced}\def\lllsize{smaller}%
Chris@42: \resetmathfonts \setleading{\textleading}}
Chris@42: \def\titlefonts{%
Chris@42: \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl
Chris@42: \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc
Chris@42: \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy
Chris@42: \let\tenttsl=\titlettsl
Chris@42: \def\curfontsize{title}%
Chris@42: \def\lsize{chap}\def\lllsize{subsec}%
Chris@42: \resetmathfonts \setleading{27pt}}
Chris@42: \def\titlefont#1{{\titlefonts\rmisbold #1}}
Chris@42: \def\chapfonts{%
Chris@42: \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl
Chris@42: \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc
Chris@42: \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy
Chris@42: \let\tenttsl=\chapttsl
Chris@42: \def\curfontsize{chap}%
Chris@42: \def\lsize{sec}\def\lllsize{text}%
Chris@42: \resetmathfonts \setleading{19pt}}
Chris@42: \def\secfonts{%
Chris@42: \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl
Chris@42: \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc
Chris@42: \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy
Chris@42: \let\tenttsl=\secttsl
Chris@42: \def\curfontsize{sec}%
Chris@42: \def\lsize{subsec}\def\lllsize{reduced}%
Chris@42: \resetmathfonts \setleading{16pt}}
Chris@42: \def\subsecfonts{%
Chris@42: \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl
Chris@42: \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc
Chris@42: \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy
Chris@42: \let\tenttsl=\ssecttsl
Chris@42: \def\curfontsize{ssec}%
Chris@42: \def\lsize{text}\def\lllsize{small}%
Chris@42: \resetmathfonts \setleading{15pt}}
Chris@42: \let\subsubsecfonts = \subsecfonts
Chris@42: \def\reducedfonts{%
Chris@42: \let\tenrm=\reducedrm \let\tenit=\reducedit \let\tensl=\reducedsl
Chris@42: \let\tenbf=\reducedbf \let\tentt=\reducedtt \let\reducedcaps=\reducedsc
Chris@42: \let\tensf=\reducedsf \let\teni=\reducedi \let\tensy=\reducedsy
Chris@42: \let\tenttsl=\reducedttsl
Chris@42: \def\curfontsize{reduced}%
Chris@42: \def\lsize{small}\def\lllsize{smaller}%
Chris@42: \resetmathfonts \setleading{10.5pt}}
Chris@42: \def\smallfonts{%
Chris@42: \let\tenrm=\smallrm \let\tenit=\smallit \let\tensl=\smallsl
Chris@42: \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc
Chris@42: \let\tensf=\smallsf \let\teni=\smalli \let\tensy=\smallsy
Chris@42: \let\tenttsl=\smallttsl
Chris@42: \def\curfontsize{small}%
Chris@42: \def\lsize{smaller}\def\lllsize{smaller}%
Chris@42: \resetmathfonts \setleading{10.5pt}}
Chris@42: \def\smallerfonts{%
Chris@42: \let\tenrm=\smallerrm \let\tenit=\smallerit \let\tensl=\smallersl
Chris@42: \let\tenbf=\smallerbf \let\tentt=\smallertt \let\smallcaps=\smallersc
Chris@42: \let\tensf=\smallersf \let\teni=\smalleri \let\tensy=\smallersy
Chris@42: \let\tenttsl=\smallerttsl
Chris@42: \def\curfontsize{smaller}%
Chris@42: \def\lsize{smaller}\def\lllsize{smaller}%
Chris@42: \resetmathfonts \setleading{9.5pt}}
Chris@42:
Chris@42: % Fonts for short table of contents.
Chris@42: \setfont\shortcontrm\rmshape{12}{1000}{OT1}
Chris@42: \setfont\shortcontbf\bfshape{10}{\magstep1}{OT1} % no cmb12
Chris@42: \setfont\shortcontsl\slshape{12}{1000}{OT1}
Chris@42: \setfont\shortconttt\ttshape{12}{1000}{OT1TT}
Chris@42:
Chris@42: % Define these just so they can be easily changed for other fonts.
Chris@42: \def\angleleft{$\langle$}
Chris@42: \def\angleright{$\rangle$}
Chris@42:
Chris@42: % Set the fonts to use with the @small... environments.
Chris@42: \let\smallexamplefonts = \smallfonts
Chris@42:
Chris@42: % About \smallexamplefonts. If we use \smallfonts (9pt), @smallexample
Chris@42: % can fit this many characters:
Chris@42: % 8.5x11=86 smallbook=72 a4=90 a5=69
Chris@42: % If we use \scriptfonts (8pt), then we can fit this many characters:
Chris@42: % 8.5x11=90+ smallbook=80 a4=90+ a5=77
Chris@42: % For me, subjectively, the few extra characters that fit aren't worth
Chris@42: % the additional smallness of 8pt. So I'm making the default 9pt.
Chris@42: %
Chris@42: % By the way, for comparison, here's what fits with @example (10pt):
Chris@42: % 8.5x11=71 smallbook=60 a4=75 a5=58
Chris@42: % --karl, 24jan03.
Chris@42:
Chris@42: % Set up the default fonts, so we can use them for creating boxes.
Chris@42: %
Chris@42: \definetextfontsizexi
Chris@42:
Chris@42:
Chris@42: \message{markup,}
Chris@42:
Chris@42: % Check if we are currently using a typewriter font. Since all the
Chris@42: % Computer Modern typewriter fonts have zero interword stretch (and
Chris@42: % shrink), and it is reasonable to expect all typewriter fonts to have
Chris@42: % this property, we can check that font parameter.
Chris@42: %
Chris@42: \def\ifmonospace{\ifdim\fontdimen3\font=0pt }
Chris@42:
Chris@42: % Markup style infrastructure. \defmarkupstylesetup\INITMACRO will
Chris@42: % define and register \INITMACRO to be called on markup style changes.
Chris@42: % \INITMACRO can check \currentmarkupstyle for the innermost
Chris@42: % style and the set of \ifmarkupSTYLE switches for all styles
Chris@42: % currently in effect.
Chris@42: \newif\ifmarkupvar
Chris@42: \newif\ifmarkupsamp
Chris@42: \newif\ifmarkupkey
Chris@42: %\newif\ifmarkupfile % @file == @samp.
Chris@42: %\newif\ifmarkupoption % @option == @samp.
Chris@42: \newif\ifmarkupcode
Chris@42: \newif\ifmarkupkbd
Chris@42: %\newif\ifmarkupenv % @env == @code.
Chris@42: %\newif\ifmarkupcommand % @command == @code.
Chris@42: \newif\ifmarkuptex % @tex (and part of @math, for now).
Chris@42: \newif\ifmarkupexample
Chris@42: \newif\ifmarkupverb
Chris@42: \newif\ifmarkupverbatim
Chris@42:
Chris@42: \let\currentmarkupstyle\empty
Chris@42:
Chris@42: \def\setupmarkupstyle#1{%
Chris@42: \csname markup#1true\endcsname
Chris@42: \def\currentmarkupstyle{#1}%
Chris@42: \markupstylesetup
Chris@42: }
Chris@42:
Chris@42: \let\markupstylesetup\empty
Chris@42:
Chris@42: \def\defmarkupstylesetup#1{%
Chris@42: \expandafter\def\expandafter\markupstylesetup
Chris@42: \expandafter{\markupstylesetup #1}%
Chris@42: \def#1%
Chris@42: }
Chris@42:
Chris@42: % Markup style setup for left and right quotes.
Chris@42: \defmarkupstylesetup\markupsetuplq{%
Chris@42: \expandafter\let\expandafter \temp
Chris@42: \csname markupsetuplq\currentmarkupstyle\endcsname
Chris@42: \ifx\temp\relax \markupsetuplqdefault \else \temp \fi
Chris@42: }
Chris@42:
Chris@42: \defmarkupstylesetup\markupsetuprq{%
Chris@42: \expandafter\let\expandafter \temp
Chris@42: \csname markupsetuprq\currentmarkupstyle\endcsname
Chris@42: \ifx\temp\relax \markupsetuprqdefault \else \temp \fi
Chris@42: }
Chris@42:
Chris@42: {
Chris@42: \catcode`\'=\active
Chris@42: \catcode`\`=\active
Chris@42:
Chris@42: \gdef\markupsetuplqdefault{\let`\lq}
Chris@42: \gdef\markupsetuprqdefault{\let'\rq}
Chris@42:
Chris@42: \gdef\markupsetcodequoteleft{\let`\codequoteleft}
Chris@42: \gdef\markupsetcodequoteright{\let'\codequoteright}
Chris@42: }
Chris@42:
Chris@42: \let\markupsetuplqcode \markupsetcodequoteleft
Chris@42: \let\markupsetuprqcode \markupsetcodequoteright
Chris@42: %
Chris@42: \let\markupsetuplqexample \markupsetcodequoteleft
Chris@42: \let\markupsetuprqexample \markupsetcodequoteright
Chris@42: %
Chris@42: \let\markupsetuplqkbd \markupsetcodequoteleft
Chris@42: \let\markupsetuprqkbd \markupsetcodequoteright
Chris@42: %
Chris@42: \let\markupsetuplqsamp \markupsetcodequoteleft
Chris@42: \let\markupsetuprqsamp \markupsetcodequoteright
Chris@42: %
Chris@42: \let\markupsetuplqverb \markupsetcodequoteleft
Chris@42: \let\markupsetuprqverb \markupsetcodequoteright
Chris@42: %
Chris@42: \let\markupsetuplqverbatim \markupsetcodequoteleft
Chris@42: \let\markupsetuprqverbatim \markupsetcodequoteright
Chris@42:
Chris@42: % Allow an option to not use regular directed right quote/apostrophe
Chris@42: % (char 0x27), but instead the undirected quote from cmtt (char 0x0d).
Chris@42: % The undirected quote is ugly, so don't make it the default, but it
Chris@42: % works for pasting with more pdf viewers (at least evince), the
Chris@42: % lilypond developers report. xpdf does work with the regular 0x27.
Chris@42: %
Chris@42: \def\codequoteright{%
Chris@42: \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax
Chris@42: \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax
Chris@42: '%
Chris@42: \else \char'15 \fi
Chris@42: \else \char'15 \fi
Chris@42: }
Chris@42: %
Chris@42: % and a similar option for the left quote char vs. a grave accent.
Chris@42: % Modern fonts display ASCII 0x60 as a grave accent, so some people like
Chris@42: % the code environments to do likewise.
Chris@42: %
Chris@42: \def\codequoteleft{%
Chris@42: \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax
Chris@42: \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax
Chris@42: % [Knuth] pp. 380,381,391
Chris@42: % \relax disables Spanish ligatures ?` and !` of \tt font.
Chris@42: \relax`%
Chris@42: \else \char'22 \fi
Chris@42: \else \char'22 \fi
Chris@42: }
Chris@42:
Chris@42: % Commands to set the quote options.
Chris@42: %
Chris@42: \parseargdef\codequoteundirected{%
Chris@42: \def\temp{#1}%
Chris@42: \ifx\temp\onword
Chris@42: \expandafter\let\csname SETtxicodequoteundirected\endcsname
Chris@42: = t%
Chris@42: \else\ifx\temp\offword
Chris@42: \expandafter\let\csname SETtxicodequoteundirected\endcsname
Chris@42: = \relax
Chris@42: \else
Chris@42: \errhelp = \EMsimple
Chris@42: \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}%
Chris@42: \fi\fi
Chris@42: }
Chris@42: %
Chris@42: \parseargdef\codequotebacktick{%
Chris@42: \def\temp{#1}%
Chris@42: \ifx\temp\onword
Chris@42: \expandafter\let\csname SETtxicodequotebacktick\endcsname
Chris@42: = t%
Chris@42: \else\ifx\temp\offword
Chris@42: \expandafter\let\csname SETtxicodequotebacktick\endcsname
Chris@42: = \relax
Chris@42: \else
Chris@42: \errhelp = \EMsimple
Chris@42: \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}%
Chris@42: \fi\fi
Chris@42: }
Chris@42:
Chris@42: % [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font.
Chris@42: \def\noligaturesquoteleft{\relax\lq}
Chris@42:
Chris@42: % Count depth in font-changes, for error checks
Chris@42: \newcount\fontdepth \fontdepth=0
Chris@42:
Chris@42: % Font commands.
Chris@42:
Chris@42: % #1 is the font command (\sl or \it), #2 is the text to slant.
Chris@42: % If we are in a monospaced environment, however, 1) always use \ttsl,
Chris@42: % and 2) do not add an italic correction.
Chris@42: \def\dosmartslant#1#2{%
Chris@42: \ifusingtt
Chris@42: {{\ttsl #2}\let\next=\relax}%
Chris@42: {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}%
Chris@42: \next
Chris@42: }
Chris@42: \def\smartslanted{\dosmartslant\sl}
Chris@42: \def\smartitalic{\dosmartslant\it}
Chris@42:
Chris@42: % Output an italic correction unless \next (presumed to be the following
Chris@42: % character) is such as not to need one.
Chris@42: \def\smartitaliccorrection{%
Chris@42: \ifx\next,%
Chris@42: \else\ifx\next-%
Chris@42: \else\ifx\next.%
Chris@42: \else\ptexslash
Chris@42: \fi\fi\fi
Chris@42: \aftersmartic
Chris@42: }
Chris@42:
Chris@42: % Unconditional use \ttsl, and no ic. @var is set to this for defuns.
Chris@42: \def\ttslanted#1{{\ttsl #1}}
Chris@42:
Chris@42: % @cite is like \smartslanted except unconditionally use \sl. We never want
Chris@42: % ttsl for book titles, do we?
Chris@42: \def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection}
Chris@42:
Chris@42: \def\aftersmartic{}
Chris@42: \def\var#1{%
Chris@42: \let\saveaftersmartic = \aftersmartic
Chris@42: \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}%
Chris@42: \smartslanted{#1}%
Chris@42: }
Chris@42:
Chris@42: \let\i=\smartitalic
Chris@42: \let\slanted=\smartslanted
Chris@42: \let\dfn=\smartslanted
Chris@42: \let\emph=\smartitalic
Chris@42:
Chris@42: % Explicit font changes: @r, @sc, undocumented @ii.
Chris@42: \def\r#1{{\rm #1}} % roman font
Chris@42: \def\sc#1{{\smallcaps#1}} % smallcaps font
Chris@42: \def\ii#1{{\it #1}} % italic font
Chris@42:
Chris@42: % @b, explicit bold. Also @strong.
Chris@42: \def\b#1{{\bf #1}}
Chris@42: \let\strong=\b
Chris@42:
Chris@42: % @sansserif, explicit sans.
Chris@42: \def\sansserif#1{{\sf #1}}
Chris@42:
Chris@42: % We can't just use \exhyphenpenalty, because that only has effect at
Chris@42: % the end of a paragraph. Restore normal hyphenation at the end of the
Chris@42: % group within which \nohyphenation is presumably called.
Chris@42: %
Chris@42: \def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation}
Chris@42: \def\restorehyphenation{\hyphenchar\font = `- }
Chris@42:
Chris@42: % Set sfcode to normal for the chars that usually have another value.
Chris@42: % Can't use plain's \frenchspacing because it uses the `\x notation, and
Chris@42: % sometimes \x has an active definition that messes things up.
Chris@42: %
Chris@42: \catcode`@=11
Chris@42: \def\plainfrenchspacing{%
Chris@42: \sfcode\dotChar =\@m \sfcode\questChar=\@m \sfcode\exclamChar=\@m
Chris@42: \sfcode\colonChar=\@m \sfcode\semiChar =\@m \sfcode\commaChar =\@m
Chris@42: \def\endofsentencespacefactor{1000}% for @. and friends
Chris@42: }
Chris@42: \def\plainnonfrenchspacing{%
Chris@42: \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000
Chris@42: \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250
Chris@42: \def\endofsentencespacefactor{3000}% for @. and friends
Chris@42: }
Chris@42: \catcode`@=\other
Chris@42: \def\endofsentencespacefactor{3000}% default
Chris@42:
Chris@42: % @t, explicit typewriter.
Chris@42: \def\t#1{%
Chris@42: {\tt \rawbackslash \plainfrenchspacing #1}%
Chris@42: \null
Chris@42: }
Chris@42:
Chris@42: % @samp.
Chris@42: \def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}}
Chris@42:
Chris@42: % @indicateurl is \samp, that is, with quotes.
Chris@42: \let\indicateurl=\samp
Chris@42:
Chris@42: % @code (and similar) prints in typewriter, but with spaces the same
Chris@42: % size as normal in the surrounding text, without hyphenation, etc.
Chris@42: % This is a subroutine for that.
Chris@42: \def\tclose#1{%
Chris@42: {%
Chris@42: % Change normal interword space to be same as for the current font.
Chris@42: \spaceskip = \fontdimen2\font
Chris@42: %
Chris@42: % Switch to typewriter.
Chris@42: \tt
Chris@42: %
Chris@42: % But `\ ' produces the large typewriter interword space.
Chris@42: \def\ {{\spaceskip = 0pt{} }}%
Chris@42: %
Chris@42: % Turn off hyphenation.
Chris@42: \nohyphenation
Chris@42: %
Chris@42: \rawbackslash
Chris@42: \plainfrenchspacing
Chris@42: #1%
Chris@42: }%
Chris@42: \null % reset spacefactor to 1000
Chris@42: }
Chris@42:
Chris@42: % We *must* turn on hyphenation at `-' and `_' in @code.
Chris@42: % Otherwise, it is too hard to avoid overfull hboxes
Chris@42: % in the Emacs manual, the Library manual, etc.
Chris@42: %
Chris@42: % Unfortunately, TeX uses one parameter (\hyphenchar) to control
Chris@42: % both hyphenation at - and hyphenation within words.
Chris@42: % We must therefore turn them both off (\tclose does that)
Chris@42: % and arrange explicitly to hyphenate at a dash.
Chris@42: % -- rms.
Chris@42: {
Chris@42: \catcode`\-=\active \catcode`\_=\active
Chris@42: \catcode`\'=\active \catcode`\`=\active
Chris@42: \global\let'=\rq \global\let`=\lq % default definitions
Chris@42: %
Chris@42: \global\def\code{\begingroup
Chris@42: \setupmarkupstyle{code}%
Chris@42: % The following should really be moved into \setupmarkupstyle handlers.
Chris@42: \catcode\dashChar=\active \catcode\underChar=\active
Chris@42: \ifallowcodebreaks
Chris@42: \let-\codedash
Chris@42: \let_\codeunder
Chris@42: \else
Chris@42: \let-\normaldash
Chris@42: \let_\realunder
Chris@42: \fi
Chris@42: \codex
Chris@42: }
Chris@42: }
Chris@42:
Chris@42: \def\codex #1{\tclose{#1}\endgroup}
Chris@42:
Chris@42: \def\normaldash{-}
Chris@42: \def\codedash{-\discretionary{}{}{}}
Chris@42: \def\codeunder{%
Chris@42: % this is all so @math{@code{var_name}+1} can work. In math mode, _
Chris@42: % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.)
Chris@42: % will therefore expand the active definition of _, which is us
Chris@42: % (inside @code that is), therefore an endless loop.
Chris@42: \ifusingtt{\ifmmode
Chris@42: \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_.
Chris@42: \else\normalunderscore \fi
Chris@42: \discretionary{}{}{}}%
Chris@42: {\_}%
Chris@42: }
Chris@42:
Chris@42: % An additional complication: the above will allow breaks after, e.g.,
Chris@42: % each of the four underscores in __typeof__. This is bad.
Chris@42: % @allowcodebreaks provides a document-level way to turn breaking at -
Chris@42: % and _ on and off.
Chris@42: %
Chris@42: \newif\ifallowcodebreaks \allowcodebreakstrue
Chris@42:
Chris@42: \def\keywordtrue{true}
Chris@42: \def\keywordfalse{false}
Chris@42:
Chris@42: \parseargdef\allowcodebreaks{%
Chris@42: \def\txiarg{#1}%
Chris@42: \ifx\txiarg\keywordtrue
Chris@42: \allowcodebreakstrue
Chris@42: \else\ifx\txiarg\keywordfalse
Chris@42: \allowcodebreaksfalse
Chris@42: \else
Chris@42: \errhelp = \EMsimple
Chris@42: \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}%
Chris@42: \fi\fi
Chris@42: }
Chris@42:
Chris@42: % For @command, @env, @file, @option quotes seem unnecessary,
Chris@42: % so use \code rather than \samp.
Chris@42: \let\command=\code
Chris@42: \let\env=\code
Chris@42: \let\file=\code
Chris@42: \let\option=\code
Chris@42:
Chris@42: % @uref (abbreviation for `urlref') takes an optional (comma-separated)
Chris@42: % second argument specifying the text to display and an optional third
Chris@42: % arg as text to display instead of (rather than in addition to) the url
Chris@42: % itself. First (mandatory) arg is the url.
Chris@42: % (This \urefnobreak definition isn't used now, leaving it for a while
Chris@42: % for comparison.)
Chris@42: \def\urefnobreak#1{\dourefnobreak #1,,,\finish}
Chris@42: \def\dourefnobreak#1,#2,#3,#4\finish{\begingroup
Chris@42: \unsepspaces
Chris@42: \pdfurl{#1}%
Chris@42: \setbox0 = \hbox{\ignorespaces #3}%
Chris@42: \ifdim\wd0 > 0pt
Chris@42: \unhbox0 % third arg given, show only that
Chris@42: \else
Chris@42: \setbox0 = \hbox{\ignorespaces #2}%
Chris@42: \ifdim\wd0 > 0pt
Chris@42: \ifpdf
Chris@42: \unhbox0 % PDF: 2nd arg given, show only it
Chris@42: \else
Chris@42: \unhbox0\ (\code{#1})% DVI: 2nd arg given, show both it and url
Chris@42: \fi
Chris@42: \else
Chris@42: \code{#1}% only url given, so show it
Chris@42: \fi
Chris@42: \fi
Chris@42: \endlink
Chris@42: \endgroup}
Chris@42:
Chris@42: % This \urefbreak definition is the active one.
Chris@42: \def\urefbreak{\begingroup \urefcatcodes \dourefbreak}
Chris@42: \let\uref=\urefbreak
Chris@42: \def\dourefbreak#1{\urefbreakfinish #1,,,\finish}
Chris@42: \def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example
Chris@42: \unsepspaces
Chris@42: \pdfurl{#1}%
Chris@42: \setbox0 = \hbox{\ignorespaces #3}%
Chris@42: \ifdim\wd0 > 0pt
Chris@42: \unhbox0 % third arg given, show only that
Chris@42: \else
Chris@42: \setbox0 = \hbox{\ignorespaces #2}%
Chris@42: \ifdim\wd0 > 0pt
Chris@42: \ifpdf
Chris@42: \unhbox0 % PDF: 2nd arg given, show only it
Chris@42: \else
Chris@42: \unhbox0\ (\urefcode{#1})% DVI: 2nd arg given, show both it and url
Chris@42: \fi
Chris@42: \else
Chris@42: \urefcode{#1}% only url given, so show it
Chris@42: \fi
Chris@42: \fi
Chris@42: \endlink
Chris@42: \endgroup}
Chris@42:
Chris@42: % Allow line breaks around only a few characters (only).
Chris@42: \def\urefcatcodes{%
Chris@42: \catcode\ampChar=\active \catcode\dotChar=\active
Chris@42: \catcode\hashChar=\active \catcode\questChar=\active
Chris@42: \catcode\slashChar=\active
Chris@42: }
Chris@42: {
Chris@42: \urefcatcodes
Chris@42: %
Chris@42: \global\def\urefcode{\begingroup
Chris@42: \setupmarkupstyle{code}%
Chris@42: \urefcatcodes
Chris@42: \let&\urefcodeamp
Chris@42: \let.\urefcodedot
Chris@42: \let#\urefcodehash
Chris@42: \let?\urefcodequest
Chris@42: \let/\urefcodeslash
Chris@42: \codex
Chris@42: }
Chris@42: %
Chris@42: % By default, they are just regular characters.
Chris@42: \global\def&{\normalamp}
Chris@42: \global\def.{\normaldot}
Chris@42: \global\def#{\normalhash}
Chris@42: \global\def?{\normalquest}
Chris@42: \global\def/{\normalslash}
Chris@42: }
Chris@42:
Chris@42: % we put a little stretch before and after the breakable chars, to help
Chris@42: % line breaking of long url's. The unequal skips make look better in
Chris@42: % cmtt at least, especially for dots.
Chris@42: \def\urefprestretch{\urefprebreak \hskip0pt plus.13em }
Chris@42: \def\urefpoststretch{\urefpostbreak \hskip0pt plus.1em }
Chris@42: %
Chris@42: \def\urefcodeamp{\urefprestretch \&\urefpoststretch}
Chris@42: \def\urefcodedot{\urefprestretch .\urefpoststretch}
Chris@42: \def\urefcodehash{\urefprestretch \#\urefpoststretch}
Chris@42: \def\urefcodequest{\urefprestretch ?\urefpoststretch}
Chris@42: \def\urefcodeslash{\futurelet\next\urefcodeslashfinish}
Chris@42: {
Chris@42: \catcode`\/=\active
Chris@42: \global\def\urefcodeslashfinish{%
Chris@42: \urefprestretch \slashChar
Chris@42: % Allow line break only after the final / in a sequence of
Chris@42: % slashes, to avoid line break between the slashes in http://.
Chris@42: \ifx\next/\else \urefpoststretch \fi
Chris@42: }
Chris@42: }
Chris@42:
Chris@42: % One more complication: by default we'll break after the special
Chris@42: % characters, but some people like to break before the special chars, so
Chris@42: % allow that. Also allow no breaking at all, for manual control.
Chris@42: %
Chris@42: \parseargdef\urefbreakstyle{%
Chris@42: \def\txiarg{#1}%
Chris@42: \ifx\txiarg\wordnone
Chris@42: \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak}
Chris@42: \else\ifx\txiarg\wordbefore
Chris@42: \def\urefprebreak{\allowbreak}\def\urefpostbreak{\nobreak}
Chris@42: \else\ifx\txiarg\wordafter
Chris@42: \def\urefprebreak{\nobreak}\def\urefpostbreak{\allowbreak}
Chris@42: \else
Chris@42: \errhelp = \EMsimple
Chris@42: \errmessage{Unknown @urefbreakstyle setting `\txiarg'}%
Chris@42: \fi\fi\fi
Chris@42: }
Chris@42: \def\wordafter{after}
Chris@42: \def\wordbefore{before}
Chris@42: \def\wordnone{none}
Chris@42:
Chris@42: \urefbreakstyle after
Chris@42:
Chris@42: % @url synonym for @uref, since that's how everyone uses it.
Chris@42: %
Chris@42: \let\url=\uref
Chris@42:
Chris@42: % rms does not like angle brackets --karl, 17may97.
Chris@42: % So now @email is just like @uref, unless we are pdf.
Chris@42: %
Chris@42: %\def\email#1{\angleleft{\tt #1}\angleright}
Chris@42: \ifpdf
Chris@42: \def\email#1{\doemail#1,,\finish}
Chris@42: \def\doemail#1,#2,#3\finish{\begingroup
Chris@42: \unsepspaces
Chris@42: \pdfurl{mailto:#1}%
Chris@42: \setbox0 = \hbox{\ignorespaces #2}%
Chris@42: \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi
Chris@42: \endlink
Chris@42: \endgroup}
Chris@42: \else
Chris@42: \let\email=\uref
Chris@42: \fi
Chris@42:
Chris@42: % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always),
Chris@42: % `example' (@kbd uses ttsl only inside of @example and friends),
Chris@42: % or `code' (@kbd uses normal tty font always).
Chris@42: \parseargdef\kbdinputstyle{%
Chris@42: \def\txiarg{#1}%
Chris@42: \ifx\txiarg\worddistinct
Chris@42: \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}%
Chris@42: \else\ifx\txiarg\wordexample
Chris@42: \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}%
Chris@42: \else\ifx\txiarg\wordcode
Chris@42: \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}%
Chris@42: \else
Chris@42: \errhelp = \EMsimple
Chris@42: \errmessage{Unknown @kbdinputstyle setting `\txiarg'}%
Chris@42: \fi\fi\fi
Chris@42: }
Chris@42: \def\worddistinct{distinct}
Chris@42: \def\wordexample{example}
Chris@42: \def\wordcode{code}
Chris@42:
Chris@42: % Default is `distinct'.
Chris@42: \kbdinputstyle distinct
Chris@42:
Chris@42: % @kbd is like @code, except that if the argument is just one @key command,
Chris@42: % then @kbd has no effect.
Chris@42: \def\kbd#1{{\def\look{#1}\expandafter\kbdsub\look??\par}}
Chris@42:
Chris@42: \def\xkey{\key}
Chris@42: \def\kbdsub#1#2#3\par{%
Chris@42: \def\one{#1}\def\three{#3}\def\threex{??}%
Chris@42: \ifx\one\xkey\ifx\threex\three \key{#2}%
Chris@42: \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
Chris@42: \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi
Chris@42: }
Chris@42:
Chris@42: % definition of @key that produces a lozenge. Doesn't adjust to text size.
Chris@42: %\setfont\keyrm\rmshape{8}{1000}{OT1}
Chris@42: %\font\keysy=cmsy9
Chris@42: %\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{%
Chris@42: % \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{%
Chris@42: % \vbox{\hrule\kern-0.4pt
Chris@42: % \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}%
Chris@42: % \kern-0.4pt\hrule}%
Chris@42: % \kern-.06em\raise0.4pt\hbox{\angleright}}}}
Chris@42:
Chris@42: % definition of @key with no lozenge. If the current font is already
Chris@42: % monospace, don't change it; that way, we respect @kbdinputstyle. But
Chris@42: % if it isn't monospace, then use \tt.
Chris@42: %
Chris@42: \def\key#1{{\setupmarkupstyle{key}%
Chris@42: \nohyphenation
Chris@42: \ifmonospace\else\tt\fi
Chris@42: #1}\null}
Chris@42:
Chris@42: % @clicksequence{File @click{} Open ...}
Chris@42: \def\clicksequence#1{\begingroup #1\endgroup}
Chris@42:
Chris@42: % @clickstyle @arrow (by default)
Chris@42: \parseargdef\clickstyle{\def\click{#1}}
Chris@42: \def\click{\arrow}
Chris@42:
Chris@42: % Typeset a dimension, e.g., `in' or `pt'. The only reason for the
Chris@42: % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt.
Chris@42: %
Chris@42: \def\dmn#1{\thinspace #1}
Chris@42:
Chris@42: % @l was never documented to mean ``switch to the Lisp font'',
Chris@42: % and it is not used as such in any manual I can find. We need it for
Chris@42: % Polish suppressed-l. --karl, 22sep96.
Chris@42: %\def\l#1{{\li #1}\null}
Chris@42:
Chris@42: % @acronym for "FBI", "NATO", and the like.
Chris@42: % We print this one point size smaller, since it's intended for
Chris@42: % all-uppercase.
Chris@42: %
Chris@42: \def\acronym#1{\doacronym #1,,\finish}
Chris@42: \def\doacronym#1,#2,#3\finish{%
Chris@42: {\selectfonts\lsize #1}%
Chris@42: \def\temp{#2}%
Chris@42: \ifx\temp\empty \else
Chris@42: \space ({\unsepspaces \ignorespaces \temp \unskip})%
Chris@42: \fi
Chris@42: \null % reset \spacefactor=1000
Chris@42: }
Chris@42:
Chris@42: % @abbr for "Comput. J." and the like.
Chris@42: % No font change, but don't do end-of-sentence spacing.
Chris@42: %
Chris@42: \def\abbr#1{\doabbr #1,,\finish}
Chris@42: \def\doabbr#1,#2,#3\finish{%
Chris@42: {\plainfrenchspacing #1}%
Chris@42: \def\temp{#2}%
Chris@42: \ifx\temp\empty \else
Chris@42: \space ({\unsepspaces \ignorespaces \temp \unskip})%
Chris@42: \fi
Chris@42: \null % reset \spacefactor=1000
Chris@42: }
Chris@42:
Chris@42: % @asis just yields its argument. Used with @table, for example.
Chris@42: %
Chris@42: \def\asis#1{#1}
Chris@42:
Chris@42: % @math outputs its argument in math mode.
Chris@42: %
Chris@42: % One complication: _ usually means subscripts, but it could also mean
Chris@42: % an actual _ character, as in @math{@var{some_variable} + 1}. So make
Chris@42: % _ active, and distinguish by seeing if the current family is \slfam,
Chris@42: % which is what @var uses.
Chris@42: {
Chris@42: \catcode`\_ = \active
Chris@42: \gdef\mathunderscore{%
Chris@42: \catcode`\_=\active
Chris@42: \def_{\ifnum\fam=\slfam \_\else\sb\fi}%
Chris@42: }
Chris@42: }
Chris@42: % Another complication: we want \\ (and @\) to output a math (or tt) \.
Chris@42: % FYI, plain.tex uses \\ as a temporary control sequence (for no
Chris@42: % particular reason), but this is not advertised and we don't care.
Chris@42: %
Chris@42: % The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\.
Chris@42: \def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi}
Chris@42: %
Chris@42: \def\math{%
Chris@42: \tex
Chris@42: \mathunderscore
Chris@42: \let\\ = \mathbackslash
Chris@42: \mathactive
Chris@42: % make the texinfo accent commands work in math mode
Chris@42: \let\"=\ddot
Chris@42: \let\'=\acute
Chris@42: \let\==\bar
Chris@42: \let\^=\hat
Chris@42: \let\`=\grave
Chris@42: \let\u=\breve
Chris@42: \let\v=\check
Chris@42: \let\~=\tilde
Chris@42: \let\dotaccent=\dot
Chris@42: $\finishmath
Chris@42: }
Chris@42: \def\finishmath#1{#1$\endgroup} % Close the group opened by \tex.
Chris@42:
Chris@42: % Some active characters (such as <) are spaced differently in math.
Chris@42: % We have to reset their definitions in case the @math was an argument
Chris@42: % to a command which sets the catcodes (such as @item or @section).
Chris@42: %
Chris@42: {
Chris@42: \catcode`^ = \active
Chris@42: \catcode`< = \active
Chris@42: \catcode`> = \active
Chris@42: \catcode`+ = \active
Chris@42: \catcode`' = \active
Chris@42: \gdef\mathactive{%
Chris@42: \let^ = \ptexhat
Chris@42: \let< = \ptexless
Chris@42: \let> = \ptexgtr
Chris@42: \let+ = \ptexplus
Chris@42: \let' = \ptexquoteright
Chris@42: }
Chris@42: }
Chris@42:
Chris@42: % ctrl is no longer a Texinfo command, but leave this definition for fun.
Chris@42: \def\ctrl #1{{\tt \rawbackslash \hat}#1}
Chris@42:
Chris@42: % @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}.
Chris@42: % Ignore unless FMTNAME == tex; then it is like @iftex and @tex,
Chris@42: % except specified as a normal braced arg, so no newlines to worry about.
Chris@42: %
Chris@42: \def\outfmtnametex{tex}
Chris@42: %
Chris@42: \long\def\inlinefmt#1{\doinlinefmt #1,\finish}
Chris@42: \long\def\doinlinefmt#1,#2,\finish{%
Chris@42: \def\inlinefmtname{#1}%
Chris@42: \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi
Chris@42: }
Chris@42: % For raw, must switch into @tex before parsing the argument, to avoid
Chris@42: % setting catcodes prematurely. Doing it this way means that, for
Chris@42: % example, @inlineraw{html, foo{bar} gets a parse error instead of being
Chris@42: % ignored. But this isn't important because if people want a literal
Chris@42: % *right* brace they would have to use a command anyway, so they may as
Chris@42: % well use a command to get a left brace too. We could re-use the
Chris@42: % delimiter character idea from \verb, but it seems like overkill.
Chris@42: %
Chris@42: \long\def\inlineraw{\tex \doinlineraw}
Chris@42: \long\def\doinlineraw#1{\doinlinerawtwo #1,\finish}
Chris@42: \def\doinlinerawtwo#1,#2,\finish{%
Chris@42: \def\inlinerawname{#1}%
Chris@42: \ifx\inlinerawname\outfmtnametex \ignorespaces #2\fi
Chris@42: \endgroup % close group opened by \tex.
Chris@42: }
Chris@42:
Chris@42:
Chris@42: \message{glyphs,}
Chris@42: % and logos.
Chris@42:
Chris@42: % @@ prints an @, as does @atchar{}.
Chris@42: \def\@{\char64 }
Chris@42: \let\atchar=\@
Chris@42:
Chris@42: % @{ @} @lbracechar{} @rbracechar{} all generate brace characters.
Chris@42: % Unless we're in typewriter, use \ecfont because the CM text fonts do
Chris@42: % not have braces, and we don't want to switch into math.
Chris@42: \def\mylbrace{{\ifmonospace\else\ecfont\fi \char123}}
Chris@42: \def\myrbrace{{\ifmonospace\else\ecfont\fi \char125}}
Chris@42: \let\{=\mylbrace \let\lbracechar=\{
Chris@42: \let\}=\myrbrace \let\rbracechar=\}
Chris@42: \begingroup
Chris@42: % Definitions to produce \{ and \} commands for indices,
Chris@42: % and @{ and @} for the aux/toc files.
Chris@42: \catcode`\{ = \other \catcode`\} = \other
Chris@42: \catcode`\[ = 1 \catcode`\] = 2
Chris@42: \catcode`\! = 0 \catcode`\\ = \other
Chris@42: !gdef!lbracecmd[\{]%
Chris@42: !gdef!rbracecmd[\}]%
Chris@42: !gdef!lbraceatcmd[@{]%
Chris@42: !gdef!rbraceatcmd[@}]%
Chris@42: !endgroup
Chris@42:
Chris@42: % @comma{} to avoid , parsing problems.
Chris@42: \let\comma = ,
Chris@42:
Chris@42: % Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent
Chris@42: % Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H.
Chris@42: \let\, = \ptexc
Chris@42: \let\dotaccent = \ptexdot
Chris@42: \def\ringaccent#1{{\accent23 #1}}
Chris@42: \let\tieaccent = \ptext
Chris@42: \let\ubaraccent = \ptexb
Chris@42: \let\udotaccent = \d
Chris@42:
Chris@42: % Other special characters: @questiondown @exclamdown @ordf @ordm
Chris@42: % Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss.
Chris@42: \def\questiondown{?`}
Chris@42: \def\exclamdown{!`}
Chris@42: \def\ordf{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{a}}}
Chris@42: \def\ordm{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{o}}}
Chris@42:
Chris@42: % Dotless i and dotless j, used for accents.
Chris@42: \def\imacro{i}
Chris@42: \def\jmacro{j}
Chris@42: \def\dotless#1{%
Chris@42: \def\temp{#1}%
Chris@42: \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi
Chris@42: \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi
Chris@42: \else \errmessage{@dotless can be used only with i or j}%
Chris@42: \fi\fi
Chris@42: }
Chris@42:
Chris@42: % The \TeX{} logo, as in plain, but resetting the spacing so that a
Chris@42: % period following counts as ending a sentence. (Idea found in latex.)
Chris@42: %
Chris@42: \edef\TeX{\TeX \spacefactor=1000 }
Chris@42:
Chris@42: % @LaTeX{} logo. Not quite the same results as the definition in
Chris@42: % latex.ltx, since we use a different font for the raised A; it's most
Chris@42: % convenient for us to use an explicitly smaller font, rather than using
Chris@42: % the \scriptstyle font (since we don't reset \scriptstyle and
Chris@42: % \scriptscriptstyle).
Chris@42: %
Chris@42: \def\LaTeX{%
Chris@42: L\kern-.36em
Chris@42: {\setbox0=\hbox{T}%
Chris@42: \vbox to \ht0{\hbox{%
Chris@42: \ifx\textnominalsize\xwordpt
Chris@42: % for 10pt running text, \lllsize (8pt) is too small for the A in LaTeX.
Chris@42: % Revert to plain's \scriptsize, which is 7pt.
Chris@42: \count255=\the\fam $\fam\count255 \scriptstyle A$%
Chris@42: \else
Chris@42: % For 11pt, we can use our lllsize.
Chris@42: \selectfonts\lllsize A%
Chris@42: \fi
Chris@42: }%
Chris@42: \vss
Chris@42: }}%
Chris@42: \kern-.15em
Chris@42: \TeX
Chris@42: }
Chris@42:
Chris@42: % Some math mode symbols.
Chris@42: \def\bullet{$\ptexbullet$}
Chris@42: \def\geq{\ifmmode \ge\else $\ge$\fi}
Chris@42: \def\leq{\ifmmode \le\else $\le$\fi}
Chris@42: \def\minus{\ifmmode -\else $-$\fi}
Chris@42:
Chris@42: % @dots{} outputs an ellipsis using the current font.
Chris@42: % We do .5em per period so that it has the same spacing in the cm
Chris@42: % typewriter fonts as three actual period characters; on the other hand,
Chris@42: % in other typewriter fonts three periods are wider than 1.5em. So do
Chris@42: % whichever is larger.
Chris@42: %
Chris@42: \def\dots{%
Chris@42: \leavevmode
Chris@42: \setbox0=\hbox{...}% get width of three periods
Chris@42: \ifdim\wd0 > 1.5em
Chris@42: \dimen0 = \wd0
Chris@42: \else
Chris@42: \dimen0 = 1.5em
Chris@42: \fi
Chris@42: \hbox to \dimen0{%
Chris@42: \hskip 0pt plus.25fil
Chris@42: .\hskip 0pt plus1fil
Chris@42: .\hskip 0pt plus1fil
Chris@42: .\hskip 0pt plus.5fil
Chris@42: }%
Chris@42: }
Chris@42:
Chris@42: % @enddots{} is an end-of-sentence ellipsis.
Chris@42: %
Chris@42: \def\enddots{%
Chris@42: \dots
Chris@42: \spacefactor=\endofsentencespacefactor
Chris@42: }
Chris@42:
Chris@42: % @point{}, @result{}, @expansion{}, @print{}, @equiv{}.
Chris@42: %
Chris@42: % Since these characters are used in examples, they should be an even number of
Chris@42: % \tt widths. Each \tt character is 1en, so two makes it 1em.
Chris@42: %
Chris@42: \def\point{$\star$}
Chris@42: \def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}}
Chris@42: \def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}}
Chris@42: \def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}}
Chris@42: \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}}
Chris@42: \def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}}
Chris@42:
Chris@42: % The @error{} command.
Chris@42: % Adapted from the TeXbook's \boxit.
Chris@42: %
Chris@42: \newbox\errorbox
Chris@42: %
Chris@42: {\tentt \global\dimen0 = 3em}% Width of the box.
Chris@42: \dimen2 = .55pt % Thickness of rules
Chris@42: % The text. (`r' is open on the right, `e' somewhat less so on the left.)
Chris@42: \setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt}
Chris@42: %
Chris@42: \setbox\errorbox=\hbox to \dimen0{\hfil
Chris@42: \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right.
Chris@42: \advance\hsize by -2\dimen2 % Rules.
Chris@42: \vbox{%
Chris@42: \hrule height\dimen2
Chris@42: \hbox{\vrule width\dimen2 \kern3pt % Space to left of text.
Chris@42: \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below.
Chris@42: \kern3pt\vrule width\dimen2}% Space to right.
Chris@42: \hrule height\dimen2}
Chris@42: \hfil}
Chris@42: %
Chris@42: \def\error{\leavevmode\lower.7ex\copy\errorbox}
Chris@42:
Chris@42: % @pounds{} is a sterling sign, which Knuth put in the CM italic font.
Chris@42: %
Chris@42: \def\pounds{{\it\$}}
Chris@42:
Chris@42: % @euro{} comes from a separate font, depending on the current style.
Chris@42: % We use the free feym* fonts from the eurosym package by Henrik
Chris@42: % Theiling, which support regular, slanted, bold and bold slanted (and
Chris@42: % "outlined" (blackboard board, sort of) versions, which we don't need).
Chris@42: % It is available from http://www.ctan.org/tex-archive/fonts/eurosym.
Chris@42: %
Chris@42: % Although only regular is the truly official Euro symbol, we ignore
Chris@42: % that. The Euro is designed to be slightly taller than the regular
Chris@42: % font height.
Chris@42: %
Chris@42: % feymr - regular
Chris@42: % feymo - slanted
Chris@42: % feybr - bold
Chris@42: % feybo - bold slanted
Chris@42: %
Chris@42: % There is no good (free) typewriter version, to my knowledge.
Chris@42: % A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide.
Chris@42: % Hmm.
Chris@42: %
Chris@42: % Also doesn't work in math. Do we need to do math with euro symbols?
Chris@42: % Hope not.
Chris@42: %
Chris@42: %
Chris@42: \def\euro{{\eurofont e}}
Chris@42: \def\eurofont{%
Chris@42: % We set the font at each command, rather than predefining it in
Chris@42: % \textfonts and the other font-switching commands, so that
Chris@42: % installations which never need the symbol don't have to have the
Chris@42: % font installed.
Chris@42: %
Chris@42: % There is only one designed size (nominal 10pt), so we always scale
Chris@42: % that to the current nominal size.
Chris@42: %
Chris@42: % By the way, simply using "at 1em" works for cmr10 and the like, but
Chris@42: % does not work for cmbx10 and other extended/shrunken fonts.
Chris@42: %
Chris@42: \def\eurosize{\csname\curfontsize nominalsize\endcsname}%
Chris@42: %
Chris@42: \ifx\curfontstyle\bfstylename
Chris@42: % bold:
Chris@42: \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize
Chris@42: \else
Chris@42: % regular:
Chris@42: \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize
Chris@42: \fi
Chris@42: \thiseurofont
Chris@42: }
Chris@42:
Chris@42: % Glyphs from the EC fonts. We don't use \let for the aliases, because
Chris@42: % sometimes we redefine the original macro, and the alias should reflect
Chris@42: % the redefinition.
Chris@42: %
Chris@42: % Use LaTeX names for the Icelandic letters.
Chris@42: \def\DH{{\ecfont \char"D0}} % Eth
Chris@42: \def\dh{{\ecfont \char"F0}} % eth
Chris@42: \def\TH{{\ecfont \char"DE}} % Thorn
Chris@42: \def\th{{\ecfont \char"FE}} % thorn
Chris@42: %
Chris@42: \def\guillemetleft{{\ecfont \char"13}}
Chris@42: \def\guillemotleft{\guillemetleft}
Chris@42: \def\guillemetright{{\ecfont \char"14}}
Chris@42: \def\guillemotright{\guillemetright}
Chris@42: \def\guilsinglleft{{\ecfont \char"0E}}
Chris@42: \def\guilsinglright{{\ecfont \char"0F}}
Chris@42: \def\quotedblbase{{\ecfont \char"12}}
Chris@42: \def\quotesinglbase{{\ecfont \char"0D}}
Chris@42: %
Chris@42: % This positioning is not perfect (see the ogonek LaTeX package), but
Chris@42: % we have the precomposed glyphs for the most common cases. We put the
Chris@42: % tests to use those glyphs in the single \ogonek macro so we have fewer
Chris@42: % dummy definitions to worry about for index entries, etc.
Chris@42: %
Chris@42: % ogonek is also used with other letters in Lithuanian (IOU), but using
Chris@42: % the precomposed glyphs for those is not so easy since they aren't in
Chris@42: % the same EC font.
Chris@42: \def\ogonek#1{{%
Chris@42: \def\temp{#1}%
Chris@42: \ifx\temp\macrocharA\Aogonek
Chris@42: \else\ifx\temp\macrochara\aogonek
Chris@42: \else\ifx\temp\macrocharE\Eogonek
Chris@42: \else\ifx\temp\macrochare\eogonek
Chris@42: \else
Chris@42: \ecfont \setbox0=\hbox{#1}%
Chris@42: \ifdim\ht0=1ex\accent"0C #1%
Chris@42: \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}%
Chris@42: \fi
Chris@42: \fi\fi\fi\fi
Chris@42: }%
Chris@42: }
Chris@42: \def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A}
Chris@42: \def\aogonek{{\ecfont \char"A1}}\def\macrochara{a}
Chris@42: \def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E}
Chris@42: \def\eogonek{{\ecfont \char"A6}}\def\macrochare{e}
Chris@42: %
Chris@42: % Use the ec* fonts (cm-super in outline format) for non-CM glyphs.
Chris@42: \def\ecfont{%
Chris@42: % We can't distinguish serif/sans and italic/slanted, but this
Chris@42: % is used for crude hacks anyway (like adding French and German
Chris@42: % quotes to documents typeset with CM, where we lose kerning), so
Chris@42: % hopefully nobody will notice/care.
Chris@42: \edef\ecsize{\csname\curfontsize ecsize\endcsname}%
Chris@42: \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}%
Chris@42: \ifmonospace
Chris@42: % typewriter:
Chris@42: \font\thisecfont = ectt\ecsize \space at \nominalsize
Chris@42: \else
Chris@42: \ifx\curfontstyle\bfstylename
Chris@42: % bold:
Chris@42: \font\thisecfont = ecb\ifusingit{i}{x}\ecsize \space at \nominalsize
Chris@42: \else
Chris@42: % regular:
Chris@42: \font\thisecfont = ec\ifusingit{ti}{rm}\ecsize \space at \nominalsize
Chris@42: \fi
Chris@42: \fi
Chris@42: \thisecfont
Chris@42: }
Chris@42:
Chris@42: % @registeredsymbol - R in a circle. The font for the R should really
Chris@42: % be smaller yet, but lllsize is the best we can do for now.
Chris@42: % Adapted from the plain.tex definition of \copyright.
Chris@42: %
Chris@42: \def\registeredsymbol{%
Chris@42: $^{{\ooalign{\hfil\raise.07ex\hbox{\selectfonts\lllsize R}%
Chris@42: \hfil\crcr\Orb}}%
Chris@42: }$%
Chris@42: }
Chris@42:
Chris@42: % @textdegree - the normal degrees sign.
Chris@42: %
Chris@42: \def\textdegree{$^\circ$}
Chris@42:
Chris@42: % Laurent Siebenmann reports \Orb undefined with:
Chris@42: % Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38
Chris@42: % so we'll define it if necessary.
Chris@42: %
Chris@42: \ifx\Orb\thisisundefined
Chris@42: \def\Orb{\mathhexbox20D}
Chris@42: \fi
Chris@42:
Chris@42: % Quotes.
Chris@42: \chardef\quotedblleft="5C
Chris@42: \chardef\quotedblright=`\"
Chris@42: \chardef\quoteleft=`\`
Chris@42: \chardef\quoteright=`\'
Chris@42:
Chris@42:
Chris@42: \message{page headings,}
Chris@42:
Chris@42: \newskip\titlepagetopglue \titlepagetopglue = 1.5in
Chris@42: \newskip\titlepagebottomglue \titlepagebottomglue = 2pc
Chris@42:
Chris@42: % First the title page. Must do @settitle before @titlepage.
Chris@42: \newif\ifseenauthor
Chris@42: \newif\iffinishedtitlepage
Chris@42:
Chris@42: % Do an implicit @contents or @shortcontents after @end titlepage if the
Chris@42: % user says @setcontentsaftertitlepage or @setshortcontentsaftertitlepage.
Chris@42: %
Chris@42: \newif\ifsetcontentsaftertitlepage
Chris@42: \let\setcontentsaftertitlepage = \setcontentsaftertitlepagetrue
Chris@42: \newif\ifsetshortcontentsaftertitlepage
Chris@42: \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue
Chris@42:
Chris@42: \parseargdef\shorttitlepage{%
Chris@42: \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}%
Chris@42: \endgroup\page\hbox{}\page}
Chris@42:
Chris@42: \envdef\titlepage{%
Chris@42: % Open one extra group, as we want to close it in the middle of \Etitlepage.
Chris@42: \begingroup
Chris@42: \parindent=0pt \textfonts
Chris@42: % Leave some space at the very top of the page.
Chris@42: \vglue\titlepagetopglue
Chris@42: % No rule at page bottom unless we print one at the top with @title.
Chris@42: \finishedtitlepagetrue
Chris@42: %
Chris@42: % Most title ``pages'' are actually two pages long, with space
Chris@42: % at the top of the second. We don't want the ragged left on the second.
Chris@42: \let\oldpage = \page
Chris@42: \def\page{%
Chris@42: \iffinishedtitlepage\else
Chris@42: \finishtitlepage
Chris@42: \fi
Chris@42: \let\page = \oldpage
Chris@42: \page
Chris@42: \null
Chris@42: }%
Chris@42: }
Chris@42:
Chris@42: \def\Etitlepage{%
Chris@42: \iffinishedtitlepage\else
Chris@42: \finishtitlepage
Chris@42: \fi
Chris@42: % It is important to do the page break before ending the group,
Chris@42: % because the headline and footline are only empty inside the group.
Chris@42: % If we use the new definition of \page, we always get a blank page
Chris@42: % after the title page, which we certainly don't want.
Chris@42: \oldpage
Chris@42: \endgroup
Chris@42: %
Chris@42: % Need this before the \...aftertitlepage checks so that if they are
Chris@42: % in effect the toc pages will come out with page numbers.
Chris@42: \HEADINGSon
Chris@42: %
Chris@42: % If they want short, they certainly want long too.
Chris@42: \ifsetshortcontentsaftertitlepage
Chris@42: \shortcontents
Chris@42: \contents
Chris@42: \global\let\shortcontents = \relax
Chris@42: \global\let\contents = \relax
Chris@42: \fi
Chris@42: %
Chris@42: \ifsetcontentsaftertitlepage
Chris@42: \contents
Chris@42: \global\let\contents = \relax
Chris@42: \global\let\shortcontents = \relax
Chris@42: \fi
Chris@42: }
Chris@42:
Chris@42: \def\finishtitlepage{%
Chris@42: \vskip4pt \hrule height 2pt width \hsize
Chris@42: \vskip\titlepagebottomglue
Chris@42: \finishedtitlepagetrue
Chris@42: }
Chris@42:
Chris@42: % Settings used for typesetting titles: no hyphenation, no indentation,
Chris@42: % don't worry much about spacing, ragged right. This should be used
Chris@42: % inside a \vbox, and fonts need to be set appropriately first. Because
Chris@42: % it is always used for titles, nothing else, we call \rmisbold. \par
Chris@42: % should be specified before the end of the \vbox, since a vbox is a group.
Chris@42: %
Chris@42: \def\raggedtitlesettings{%
Chris@42: \rmisbold
Chris@42: \hyphenpenalty=10000
Chris@42: \parindent=0pt
Chris@42: \tolerance=5000
Chris@42: \ptexraggedright
Chris@42: }
Chris@42:
Chris@42: % Macros to be used within @titlepage:
Chris@42:
Chris@42: \let\subtitlerm=\tenrm
Chris@42: \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}
Chris@42:
Chris@42: \parseargdef\title{%
Chris@42: \checkenv\titlepage
Chris@42: \vbox{\titlefonts \raggedtitlesettings #1\par}%
Chris@42: % print a rule at the page bottom also.
Chris@42: \finishedtitlepagefalse
Chris@42: \vskip4pt \hrule height 4pt width \hsize \vskip4pt
Chris@42: }
Chris@42:
Chris@42: \parseargdef\subtitle{%
Chris@42: \checkenv\titlepage
Chris@42: {\subtitlefont \rightline{#1}}%
Chris@42: }
Chris@42:
Chris@42: % @author should come last, but may come many times.
Chris@42: % It can also be used inside @quotation.
Chris@42: %
Chris@42: \parseargdef\author{%
Chris@42: \def\temp{\quotation}%
Chris@42: \ifx\thisenv\temp
Chris@42: \def\quotationauthor{#1}% printed in \Equotation.
Chris@42: \else
Chris@42: \checkenv\titlepage
Chris@42: \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi
Chris@42: {\secfonts\rmisbold \leftline{#1}}%
Chris@42: \fi
Chris@42: }
Chris@42:
Chris@42:
Chris@42: % Set up page headings and footings.
Chris@42:
Chris@42: \let\thispage=\folio
Chris@42:
Chris@42: \newtoks\evenheadline % headline on even pages
Chris@42: \newtoks\oddheadline % headline on odd pages
Chris@42: \newtoks\evenfootline % footline on even pages
Chris@42: \newtoks\oddfootline % footline on odd pages
Chris@42:
Chris@42: % Now make TeX use those variables
Chris@42: \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline
Chris@42: \else \the\evenheadline \fi}}
Chris@42: \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline
Chris@42: \else \the\evenfootline \fi}\HEADINGShook}
Chris@42: \let\HEADINGShook=\relax
Chris@42:
Chris@42: % Commands to set those variables.
Chris@42: % For example, this is what @headings on does
Chris@42: % @evenheading @thistitle|@thispage|@thischapter
Chris@42: % @oddheading @thischapter|@thispage|@thistitle
Chris@42: % @evenfooting @thisfile||
Chris@42: % @oddfooting ||@thisfile
Chris@42:
Chris@42:
Chris@42: \def\evenheading{\parsearg\evenheadingxxx}
Chris@42: \def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish}
Chris@42: \def\evenheadingyyy #1\|#2\|#3\|#4\finish{%
Chris@42: \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
Chris@42:
Chris@42: \def\oddheading{\parsearg\oddheadingxxx}
Chris@42: \def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish}
Chris@42: \def\oddheadingyyy #1\|#2\|#3\|#4\finish{%
Chris@42: \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
Chris@42:
Chris@42: \parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}%
Chris@42:
Chris@42: \def\evenfooting{\parsearg\evenfootingxxx}
Chris@42: \def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish}
Chris@42: \def\evenfootingyyy #1\|#2\|#3\|#4\finish{%
Chris@42: \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}}
Chris@42:
Chris@42: \def\oddfooting{\parsearg\oddfootingxxx}
Chris@42: \def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish}
Chris@42: \def\oddfootingyyy #1\|#2\|#3\|#4\finish{%
Chris@42: \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}%
Chris@42: %
Chris@42: % Leave some space for the footline. Hopefully ok to assume
Chris@42: % @evenfooting will not be used by itself.
Chris@42: \global\advance\pageheight by -12pt
Chris@42: \global\advance\vsize by -12pt
Chris@42: }
Chris@42:
Chris@42: \parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}}
Chris@42:
Chris@42: % @evenheadingmarks top \thischapter <- chapter at the top of a page
Chris@42: % @evenheadingmarks bottom \thischapter <- chapter at the bottom of a page
Chris@42: %
Chris@42: % The same set of arguments for:
Chris@42: %
Chris@42: % @oddheadingmarks
Chris@42: % @evenfootingmarks
Chris@42: % @oddfootingmarks
Chris@42: % @everyheadingmarks
Chris@42: % @everyfootingmarks
Chris@42:
Chris@42: \def\evenheadingmarks{\headingmarks{even}{heading}}
Chris@42: \def\oddheadingmarks{\headingmarks{odd}{heading}}
Chris@42: \def\evenfootingmarks{\headingmarks{even}{footing}}
Chris@42: \def\oddfootingmarks{\headingmarks{odd}{footing}}
Chris@42: \def\everyheadingmarks#1 {\headingmarks{even}{heading}{#1}
Chris@42: \headingmarks{odd}{heading}{#1} }
Chris@42: \def\everyfootingmarks#1 {\headingmarks{even}{footing}{#1}
Chris@42: \headingmarks{odd}{footing}{#1} }
Chris@42: % #1 = even/odd, #2 = heading/footing, #3 = top/bottom.
Chris@42: \def\headingmarks#1#2#3 {%
Chris@42: \expandafter\let\expandafter\temp \csname get#3headingmarks\endcsname
Chris@42: \global\expandafter\let\csname get#1#2marks\endcsname \temp
Chris@42: }
Chris@42:
Chris@42: \everyheadingmarks bottom
Chris@42: \everyfootingmarks bottom
Chris@42:
Chris@42: % @headings double turns headings on for double-sided printing.
Chris@42: % @headings single turns headings on for single-sided printing.
Chris@42: % @headings off turns them off.
Chris@42: % @headings on same as @headings double, retained for compatibility.
Chris@42: % @headings after turns on double-sided headings after this page.
Chris@42: % @headings doubleafter turns on double-sided headings after this page.
Chris@42: % @headings singleafter turns on single-sided headings after this page.
Chris@42: % By default, they are off at the start of a document,
Chris@42: % and turned `on' after @end titlepage.
Chris@42:
Chris@42: \def\headings #1 {\csname HEADINGS#1\endcsname}
Chris@42:
Chris@42: \def\headingsoff{% non-global headings elimination
Chris@42: \evenheadline={\hfil}\evenfootline={\hfil}%
Chris@42: \oddheadline={\hfil}\oddfootline={\hfil}%
Chris@42: }
Chris@42:
Chris@42: \def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting
Chris@42: \HEADINGSoff % it's the default
Chris@42:
Chris@42: % When we turn headings on, set the page number to 1.
Chris@42: % For double-sided printing, put current file name in lower left corner,
Chris@42: % chapter name on inside top of right hand pages, document
Chris@42: % title on inside top of left hand pages, and page numbers on outside top
Chris@42: % edge of all pages.
Chris@42: \def\HEADINGSdouble{%
Chris@42: \global\pageno=1
Chris@42: \global\evenfootline={\hfil}
Chris@42: \global\oddfootline={\hfil}
Chris@42: \global\evenheadline={\line{\folio\hfil\thistitle}}
Chris@42: \global\oddheadline={\line{\thischapter\hfil\folio}}
Chris@42: \global\let\contentsalignmacro = \chapoddpage
Chris@42: }
Chris@42: \let\contentsalignmacro = \chappager
Chris@42:
Chris@42: % For single-sided printing, chapter title goes across top left of page,
Chris@42: % page number on top right.
Chris@42: \def\HEADINGSsingle{%
Chris@42: \global\pageno=1
Chris@42: \global\evenfootline={\hfil}
Chris@42: \global\oddfootline={\hfil}
Chris@42: \global\evenheadline={\line{\thischapter\hfil\folio}}
Chris@42: \global\oddheadline={\line{\thischapter\hfil\folio}}
Chris@42: \global\let\contentsalignmacro = \chappager
Chris@42: }
Chris@42: \def\HEADINGSon{\HEADINGSdouble}
Chris@42:
Chris@42: \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex}
Chris@42: \let\HEADINGSdoubleafter=\HEADINGSafter
Chris@42: \def\HEADINGSdoublex{%
Chris@42: \global\evenfootline={\hfil}
Chris@42: \global\oddfootline={\hfil}
Chris@42: \global\evenheadline={\line{\folio\hfil\thistitle}}
Chris@42: \global\oddheadline={\line{\thischapter\hfil\folio}}
Chris@42: \global\let\contentsalignmacro = \chapoddpage
Chris@42: }
Chris@42:
Chris@42: \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex}
Chris@42: \def\HEADINGSsinglex{%
Chris@42: \global\evenfootline={\hfil}
Chris@42: \global\oddfootline={\hfil}
Chris@42: \global\evenheadline={\line{\thischapter\hfil\folio}}
Chris@42: \global\oddheadline={\line{\thischapter\hfil\folio}}
Chris@42: \global\let\contentsalignmacro = \chappager
Chris@42: }
Chris@42:
Chris@42: % Subroutines used in generating headings
Chris@42: % This produces Day Month Year style of output.
Chris@42: % Only define if not already defined, in case a txi-??.tex file has set
Chris@42: % up a different format (e.g., txi-cs.tex does this).
Chris@42: \ifx\today\thisisundefined
Chris@42: \def\today{%
Chris@42: \number\day\space
Chris@42: \ifcase\month
Chris@42: \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr
Chris@42: \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug
Chris@42: \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec
Chris@42: \fi
Chris@42: \space\number\year}
Chris@42: \fi
Chris@42:
Chris@42: % @settitle line... specifies the title of the document, for headings.
Chris@42: % It generates no output of its own.
Chris@42: \def\thistitle{\putwordNoTitle}
Chris@42: \def\settitle{\parsearg{\gdef\thistitle}}
Chris@42:
Chris@42:
Chris@42: \message{tables,}
Chris@42: % Tables -- @table, @ftable, @vtable, @item(x).
Chris@42:
Chris@42: % default indentation of table text
Chris@42: \newdimen\tableindent \tableindent=.8in
Chris@42: % default indentation of @itemize and @enumerate text
Chris@42: \newdimen\itemindent \itemindent=.3in
Chris@42: % margin between end of table item and start of table text.
Chris@42: \newdimen\itemmargin \itemmargin=.1in
Chris@42:
Chris@42: % used internally for \itemindent minus \itemmargin
Chris@42: \newdimen\itemmax
Chris@42:
Chris@42: % Note @table, @ftable, and @vtable define @item, @itemx, etc., with
Chris@42: % these defs.
Chris@42: % They also define \itemindex
Chris@42: % to index the item name in whatever manner is desired (perhaps none).
Chris@42:
Chris@42: \newif\ifitemxneedsnegativevskip
Chris@42:
Chris@42: \def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi}
Chris@42:
Chris@42: \def\internalBitem{\smallbreak \parsearg\itemzzz}
Chris@42: \def\internalBitemx{\itemxpar \parsearg\itemzzz}
Chris@42:
Chris@42: \def\itemzzz #1{\begingroup %
Chris@42: \advance\hsize by -\rightskip
Chris@42: \advance\hsize by -\tableindent
Chris@42: \setbox0=\hbox{\itemindicate{#1}}%
Chris@42: \itemindex{#1}%
Chris@42: \nobreak % This prevents a break before @itemx.
Chris@42: %
Chris@42: % If the item text does not fit in the space we have, put it on a line
Chris@42: % by itself, and do not allow a page break either before or after that
Chris@42: % line. We do not start a paragraph here because then if the next
Chris@42: % command is, e.g., @kindex, the whatsit would get put into the
Chris@42: % horizontal list on a line by itself, resulting in extra blank space.
Chris@42: \ifdim \wd0>\itemmax
Chris@42: %
Chris@42: % Make this a paragraph so we get the \parskip glue and wrapping,
Chris@42: % but leave it ragged-right.
Chris@42: \begingroup
Chris@42: \advance\leftskip by-\tableindent
Chris@42: \advance\hsize by\tableindent
Chris@42: \advance\rightskip by0pt plus1fil\relax
Chris@42: \leavevmode\unhbox0\par
Chris@42: \endgroup
Chris@42: %
Chris@42: % We're going to be starting a paragraph, but we don't want the
Chris@42: % \parskip glue -- logically it's part of the @item we just started.
Chris@42: \nobreak \vskip-\parskip
Chris@42: %
Chris@42: % Stop a page break at the \parskip glue coming up. However, if
Chris@42: % what follows is an environment such as @example, there will be no
Chris@42: % \parskip glue; then the negative vskip we just inserted would
Chris@42: % cause the example and the item to crash together. So we use this
Chris@42: % bizarre value of 10001 as a signal to \aboveenvbreak to insert
Chris@42: % \parskip glue after all. Section titles are handled this way also.
Chris@42: %
Chris@42: \penalty 10001
Chris@42: \endgroup
Chris@42: \itemxneedsnegativevskipfalse
Chris@42: \else
Chris@42: % The item text fits into the space. Start a paragraph, so that the
Chris@42: % following text (if any) will end up on the same line.
Chris@42: \noindent
Chris@42: % Do this with kerns and \unhbox so that if there is a footnote in
Chris@42: % the item text, it can migrate to the main vertical list and
Chris@42: % eventually be printed.
Chris@42: \nobreak\kern-\tableindent
Chris@42: \dimen0 = \itemmax \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0
Chris@42: \unhbox0
Chris@42: \nobreak\kern\dimen0
Chris@42: \endgroup
Chris@42: \itemxneedsnegativevskiptrue
Chris@42: \fi
Chris@42: }
Chris@42:
Chris@42: \def\item{\errmessage{@item while not in a list environment}}
Chris@42: \def\itemx{\errmessage{@itemx while not in a list environment}}
Chris@42:
Chris@42: % @table, @ftable, @vtable.
Chris@42: \envdef\table{%
Chris@42: \let\itemindex\gobble
Chris@42: \tablecheck{table}%
Chris@42: }
Chris@42: \envdef\ftable{%
Chris@42: \def\itemindex ##1{\doind {fn}{\code{##1}}}%
Chris@42: \tablecheck{ftable}%
Chris@42: }
Chris@42: \envdef\vtable{%
Chris@42: \def\itemindex ##1{\doind {vr}{\code{##1}}}%
Chris@42: \tablecheck{vtable}%
Chris@42: }
Chris@42: \def\tablecheck#1{%
Chris@42: \ifnum \the\catcode`\^^M=\active
Chris@42: \endgroup
Chris@42: \errmessage{This command won't work in this context; perhaps the problem is
Chris@42: that we are \inenvironment\thisenv}%
Chris@42: \def\next{\doignore{#1}}%
Chris@42: \else
Chris@42: \let\next\tablex
Chris@42: \fi
Chris@42: \next
Chris@42: }
Chris@42: \def\tablex#1{%
Chris@42: \def\itemindicate{#1}%
Chris@42: \parsearg\tabley
Chris@42: }
Chris@42: \def\tabley#1{%
Chris@42: {%
Chris@42: \makevalueexpandable
Chris@42: \edef\temp{\noexpand\tablez #1\space\space\space}%
Chris@42: \expandafter
Chris@42: }\temp \endtablez
Chris@42: }
Chris@42: \def\tablez #1 #2 #3 #4\endtablez{%
Chris@42: \aboveenvbreak
Chris@42: \ifnum 0#1>0 \advance \leftskip by #1\mil \fi
Chris@42: \ifnum 0#2>0 \tableindent=#2\mil \fi
Chris@42: \ifnum 0#3>0 \advance \rightskip by #3\mil \fi
Chris@42: \itemmax=\tableindent
Chris@42: \advance \itemmax by -\itemmargin
Chris@42: \advance \leftskip by \tableindent
Chris@42: \exdentamount=\tableindent
Chris@42: \parindent = 0pt
Chris@42: \parskip = \smallskipamount
Chris@42: \ifdim \parskip=0pt \parskip=2pt \fi
Chris@42: \let\item = \internalBitem
Chris@42: \let\itemx = \internalBitemx
Chris@42: }
Chris@42: \def\Etable{\endgraf\afterenvbreak}
Chris@42: \let\Eftable\Etable
Chris@42: \let\Evtable\Etable
Chris@42: \let\Eitemize\Etable
Chris@42: \let\Eenumerate\Etable
Chris@42:
Chris@42: % This is the counter used by @enumerate, which is really @itemize
Chris@42:
Chris@42: \newcount \itemno
Chris@42:
Chris@42: \envdef\itemize{\parsearg\doitemize}
Chris@42:
Chris@42: \def\doitemize#1{%
Chris@42: \aboveenvbreak
Chris@42: \itemmax=\itemindent
Chris@42: \advance\itemmax by -\itemmargin
Chris@42: \advance\leftskip by \itemindent
Chris@42: \exdentamount=\itemindent
Chris@42: \parindent=0pt
Chris@42: \parskip=\smallskipamount
Chris@42: \ifdim\parskip=0pt \parskip=2pt \fi
Chris@42: %
Chris@42: % Try typesetting the item mark that if the document erroneously says
Chris@42: % something like @itemize @samp (intending @table), there's an error
Chris@42: % right away at the @itemize. It's not the best error message in the
Chris@42: % world, but it's better than leaving it to the @item. This means if
Chris@42: % the user wants an empty mark, they have to say @w{} not just @w.
Chris@42: \def\itemcontents{#1}%
Chris@42: \setbox0 = \hbox{\itemcontents}%
Chris@42: %
Chris@42: % @itemize with no arg is equivalent to @itemize @bullet.
Chris@42: \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi
Chris@42: %
Chris@42: \let\item=\itemizeitem
Chris@42: }
Chris@42:
Chris@42: % Definition of @item while inside @itemize and @enumerate.
Chris@42: %
Chris@42: \def\itemizeitem{%
Chris@42: \advance\itemno by 1 % for enumerations
Chris@42: {\let\par=\endgraf \smallbreak}% reasonable place to break
Chris@42: {%
Chris@42: % If the document has an @itemize directly after a section title, a
Chris@42: % \nobreak will be last on the list, and \sectionheading will have
Chris@42: % done a \vskip-\parskip. In that case, we don't want to zero
Chris@42: % parskip, or the item text will crash with the heading. On the
Chris@42: % other hand, when there is normal text preceding the item (as there
Chris@42: % usually is), we do want to zero parskip, or there would be too much
Chris@42: % space. In that case, we won't have a \nobreak before. At least
Chris@42: % that's the theory.
Chris@42: \ifnum\lastpenalty<10000 \parskip=0in \fi
Chris@42: \noindent
Chris@42: \hbox to 0pt{\hss \itemcontents \kern\itemmargin}%
Chris@42: %
Chris@42: \vadjust{\penalty 1200}}% not good to break after first line of item.
Chris@42: \flushcr
Chris@42: }
Chris@42:
Chris@42: % \splitoff TOKENS\endmark defines \first to be the first token in
Chris@42: % TOKENS, and \rest to be the remainder.
Chris@42: %
Chris@42: \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}%
Chris@42:
Chris@42: % Allow an optional argument of an uppercase letter, lowercase letter,
Chris@42: % or number, to specify the first label in the enumerated list. No
Chris@42: % argument is the same as `1'.
Chris@42: %
Chris@42: \envparseargdef\enumerate{\enumeratey #1 \endenumeratey}
Chris@42: \def\enumeratey #1 #2\endenumeratey{%
Chris@42: % If we were given no argument, pretend we were given `1'.
Chris@42: \def\thearg{#1}%
Chris@42: \ifx\thearg\empty \def\thearg{1}\fi
Chris@42: %
Chris@42: % Detect if the argument is a single token. If so, it might be a
Chris@42: % letter. Otherwise, the only valid thing it can be is a number.
Chris@42: % (We will always have one token, because of the test we just made.
Chris@42: % This is a good thing, since \splitoff doesn't work given nothing at
Chris@42: % all -- the first parameter is undelimited.)
Chris@42: \expandafter\splitoff\thearg\endmark
Chris@42: \ifx\rest\empty
Chris@42: % Only one token in the argument. It could still be anything.
Chris@42: % A ``lowercase letter'' is one whose \lccode is nonzero.
Chris@42: % An ``uppercase letter'' is one whose \lccode is both nonzero, and
Chris@42: % not equal to itself.
Chris@42: % Otherwise, we assume it's a number.
Chris@42: %
Chris@42: % We need the \relax at the end of the \ifnum lines to stop TeX from
Chris@42: % continuing to look for a .
Chris@42: %
Chris@42: \ifnum\lccode\expandafter`\thearg=0\relax
Chris@42: \numericenumerate % a number (we hope)
Chris@42: \else
Chris@42: % It's a letter.
Chris@42: \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax
Chris@42: \lowercaseenumerate % lowercase letter
Chris@42: \else
Chris@42: \uppercaseenumerate % uppercase letter
Chris@42: \fi
Chris@42: \fi
Chris@42: \else
Chris@42: % Multiple tokens in the argument. We hope it's a number.
Chris@42: \numericenumerate
Chris@42: \fi
Chris@42: }
Chris@42:
Chris@42: % An @enumerate whose labels are integers. The starting integer is
Chris@42: % given in \thearg.
Chris@42: %
Chris@42: \def\numericenumerate{%
Chris@42: \itemno = \thearg
Chris@42: \startenumeration{\the\itemno}%
Chris@42: }
Chris@42:
Chris@42: % The starting (lowercase) letter is in \thearg.
Chris@42: \def\lowercaseenumerate{%
Chris@42: \itemno = \expandafter`\thearg
Chris@42: \startenumeration{%
Chris@42: % Be sure we're not beyond the end of the alphabet.
Chris@42: \ifnum\itemno=0
Chris@42: \errmessage{No more lowercase letters in @enumerate; get a bigger
Chris@42: alphabet}%
Chris@42: \fi
Chris@42: \char\lccode\itemno
Chris@42: }%
Chris@42: }
Chris@42:
Chris@42: % The starting (uppercase) letter is in \thearg.
Chris@42: \def\uppercaseenumerate{%
Chris@42: \itemno = \expandafter`\thearg
Chris@42: \startenumeration{%
Chris@42: % Be sure we're not beyond the end of the alphabet.
Chris@42: \ifnum\itemno=0
Chris@42: \errmessage{No more uppercase letters in @enumerate; get a bigger
Chris@42: alphabet}
Chris@42: \fi
Chris@42: \char\uccode\itemno
Chris@42: }%
Chris@42: }
Chris@42:
Chris@42: % Call \doitemize, adding a period to the first argument and supplying the
Chris@42: % common last two arguments. Also subtract one from the initial value in
Chris@42: % \itemno, since @item increments \itemno.
Chris@42: %
Chris@42: \def\startenumeration#1{%
Chris@42: \advance\itemno by -1
Chris@42: \doitemize{#1.}\flushcr
Chris@42: }
Chris@42:
Chris@42: % @alphaenumerate and @capsenumerate are abbreviations for giving an arg
Chris@42: % to @enumerate.
Chris@42: %
Chris@42: \def\alphaenumerate{\enumerate{a}}
Chris@42: \def\capsenumerate{\enumerate{A}}
Chris@42: \def\Ealphaenumerate{\Eenumerate}
Chris@42: \def\Ecapsenumerate{\Eenumerate}
Chris@42:
Chris@42:
Chris@42: % @multitable macros
Chris@42: % Amy Hendrickson, 8/18/94, 3/6/96
Chris@42: %
Chris@42: % @multitable ... @end multitable will make as many columns as desired.
Chris@42: % Contents of each column will wrap at width given in preamble. Width
Chris@42: % can be specified either with sample text given in a template line,
Chris@42: % or in percent of \hsize, the current width of text on page.
Chris@42:
Chris@42: % Table can continue over pages but will only break between lines.
Chris@42:
Chris@42: % To make preamble:
Chris@42: %
Chris@42: % Either define widths of columns in terms of percent of \hsize:
Chris@42: % @multitable @columnfractions .25 .3 .45
Chris@42: % @item ...
Chris@42: %
Chris@42: % Numbers following @columnfractions are the percent of the total
Chris@42: % current hsize to be used for each column. You may use as many
Chris@42: % columns as desired.
Chris@42:
Chris@42:
Chris@42: % Or use a template:
Chris@42: % @multitable {Column 1 template} {Column 2 template} {Column 3 template}
Chris@42: % @item ...
Chris@42: % using the widest term desired in each column.
Chris@42:
Chris@42: % Each new table line starts with @item, each subsequent new column
Chris@42: % starts with @tab. Empty columns may be produced by supplying @tab's
Chris@42: % with nothing between them for as many times as empty columns are needed,
Chris@42: % ie, @tab@tab@tab will produce two empty columns.
Chris@42:
Chris@42: % @item, @tab do not need to be on their own lines, but it will not hurt
Chris@42: % if they are.
Chris@42:
Chris@42: % Sample multitable:
Chris@42:
Chris@42: % @multitable {Column 1 template} {Column 2 template} {Column 3 template}
Chris@42: % @item first col stuff @tab second col stuff @tab third col
Chris@42: % @item
Chris@42: % first col stuff
Chris@42: % @tab
Chris@42: % second col stuff
Chris@42: % @tab
Chris@42: % third col
Chris@42: % @item first col stuff @tab second col stuff
Chris@42: % @tab Many paragraphs of text may be used in any column.
Chris@42: %
Chris@42: % They will wrap at the width determined by the template.
Chris@42: % @item@tab@tab This will be in third column.
Chris@42: % @end multitable
Chris@42:
Chris@42: % Default dimensions may be reset by user.
Chris@42: % @multitableparskip is vertical space between paragraphs in table.
Chris@42: % @multitableparindent is paragraph indent in table.
Chris@42: % @multitablecolmargin is horizontal space to be left between columns.
Chris@42: % @multitablelinespace is space to leave between table items, baseline
Chris@42: % to baseline.
Chris@42: % 0pt means it depends on current normal line spacing.
Chris@42: %
Chris@42: \newskip\multitableparskip
Chris@42: \newskip\multitableparindent
Chris@42: \newdimen\multitablecolspace
Chris@42: \newskip\multitablelinespace
Chris@42: \multitableparskip=0pt
Chris@42: \multitableparindent=6pt
Chris@42: \multitablecolspace=12pt
Chris@42: \multitablelinespace=0pt
Chris@42:
Chris@42: % Macros used to set up halign preamble:
Chris@42: %
Chris@42: \let\endsetuptable\relax
Chris@42: \def\xendsetuptable{\endsetuptable}
Chris@42: \let\columnfractions\relax
Chris@42: \def\xcolumnfractions{\columnfractions}
Chris@42: \newif\ifsetpercent
Chris@42:
Chris@42: % #1 is the @columnfraction, usually a decimal number like .5, but might
Chris@42: % be just 1. We just use it, whatever it is.
Chris@42: %
Chris@42: \def\pickupwholefraction#1 {%
Chris@42: \global\advance\colcount by 1
Chris@42: \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}%
Chris@42: \setuptable
Chris@42: }
Chris@42:
Chris@42: \newcount\colcount
Chris@42: \def\setuptable#1{%
Chris@42: \def\firstarg{#1}%
Chris@42: \ifx\firstarg\xendsetuptable
Chris@42: \let\go = \relax
Chris@42: \else
Chris@42: \ifx\firstarg\xcolumnfractions
Chris@42: \global\setpercenttrue
Chris@42: \else
Chris@42: \ifsetpercent
Chris@42: \let\go\pickupwholefraction
Chris@42: \else
Chris@42: \global\advance\colcount by 1
Chris@42: \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a
Chris@42: % separator; typically that is always in the input, anyway.
Chris@42: \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}%
Chris@42: \fi
Chris@42: \fi
Chris@42: \ifx\go\pickupwholefraction
Chris@42: % Put the argument back for the \pickupwholefraction call, so
Chris@42: % we'll always have a period there to be parsed.
Chris@42: \def\go{\pickupwholefraction#1}%
Chris@42: \else
Chris@42: \let\go = \setuptable
Chris@42: \fi%
Chris@42: \fi
Chris@42: \go
Chris@42: }
Chris@42:
Chris@42: % multitable-only commands.
Chris@42: %
Chris@42: % @headitem starts a heading row, which we typeset in bold.
Chris@42: % Assignments have to be global since we are inside the implicit group
Chris@42: % of an alignment entry. \everycr resets \everytab so we don't have to
Chris@42: % undo it ourselves.
Chris@42: \def\headitemfont{\b}% for people to use in the template row; not changeable
Chris@42: \def\headitem{%
Chris@42: \checkenv\multitable
Chris@42: \crcr
Chris@42: \global\everytab={\bf}% can't use \headitemfont since the parsing differs
Chris@42: \the\everytab % for the first item
Chris@42: }%
Chris@42: %
Chris@42: % A \tab used to include \hskip1sp. But then the space in a template
Chris@42: % line is not enough. That is bad. So let's go back to just `&' until
Chris@42: % we again encounter the problem the 1sp was intended to solve.
Chris@42: % --karl, nathan@acm.org, 20apr99.
Chris@42: \def\tab{\checkenv\multitable &\the\everytab}%
Chris@42:
Chris@42: % @multitable ... @end multitable definitions:
Chris@42: %
Chris@42: \newtoks\everytab % insert after every tab.
Chris@42: %
Chris@42: \envdef\multitable{%
Chris@42: \vskip\parskip
Chris@42: \startsavinginserts
Chris@42: %
Chris@42: % @item within a multitable starts a normal row.
Chris@42: % We use \def instead of \let so that if one of the multitable entries
Chris@42: % contains an @itemize, we don't choke on the \item (seen as \crcr aka
Chris@42: % \endtemplate) expanding \doitemize.
Chris@42: \def\item{\crcr}%
Chris@42: %
Chris@42: \tolerance=9500
Chris@42: \hbadness=9500
Chris@42: \setmultitablespacing
Chris@42: \parskip=\multitableparskip
Chris@42: \parindent=\multitableparindent
Chris@42: \overfullrule=0pt
Chris@42: \global\colcount=0
Chris@42: %
Chris@42: \everycr = {%
Chris@42: \noalign{%
Chris@42: \global\everytab={}%
Chris@42: \global\colcount=0 % Reset the column counter.
Chris@42: % Check for saved footnotes, etc.
Chris@42: \checkinserts
Chris@42: % Keeps underfull box messages off when table breaks over pages.
Chris@42: %\filbreak
Chris@42: % Maybe so, but it also creates really weird page breaks when the
Chris@42: % table breaks over pages. Wouldn't \vfil be better? Wait until the
Chris@42: % problem manifests itself, so it can be fixed for real --karl.
Chris@42: }%
Chris@42: }%
Chris@42: %
Chris@42: \parsearg\domultitable
Chris@42: }
Chris@42: \def\domultitable#1{%
Chris@42: % To parse everything between @multitable and @item:
Chris@42: \setuptable#1 \endsetuptable
Chris@42: %
Chris@42: % This preamble sets up a generic column definition, which will
Chris@42: % be used as many times as user calls for columns.
Chris@42: % \vtop will set a single line and will also let text wrap and
Chris@42: % continue for many paragraphs if desired.
Chris@42: \halign\bgroup &%
Chris@42: \global\advance\colcount by 1
Chris@42: \multistrut
Chris@42: \vtop{%
Chris@42: % Use the current \colcount to find the correct column width:
Chris@42: \hsize=\expandafter\csname col\the\colcount\endcsname
Chris@42: %
Chris@42: % In order to keep entries from bumping into each other
Chris@42: % we will add a \leftskip of \multitablecolspace to all columns after
Chris@42: % the first one.
Chris@42: %
Chris@42: % If a template has been used, we will add \multitablecolspace
Chris@42: % to the width of each template entry.
Chris@42: %
Chris@42: % If the user has set preamble in terms of percent of \hsize we will
Chris@42: % use that dimension as the width of the column, and the \leftskip
Chris@42: % will keep entries from bumping into each other. Table will start at
Chris@42: % left margin and final column will justify at right margin.
Chris@42: %
Chris@42: % Make sure we don't inherit \rightskip from the outer environment.
Chris@42: \rightskip=0pt
Chris@42: \ifnum\colcount=1
Chris@42: % The first column will be indented with the surrounding text.
Chris@42: \advance\hsize by\leftskip
Chris@42: \else
Chris@42: \ifsetpercent \else
Chris@42: % If user has not set preamble in terms of percent of \hsize
Chris@42: % we will advance \hsize by \multitablecolspace.
Chris@42: \advance\hsize by \multitablecolspace
Chris@42: \fi
Chris@42: % In either case we will make \leftskip=\multitablecolspace:
Chris@42: \leftskip=\multitablecolspace
Chris@42: \fi
Chris@42: % Ignoring space at the beginning and end avoids an occasional spurious
Chris@42: % blank line, when TeX decides to break the line at the space before the
Chris@42: % box from the multistrut, so the strut ends up on a line by itself.
Chris@42: % For example:
Chris@42: % @multitable @columnfractions .11 .89
Chris@42: % @item @code{#}
Chris@42: % @tab Legal holiday which is valid in major parts of the whole country.
Chris@42: % Is automatically provided with highlighting sequences respectively
Chris@42: % marking characters.
Chris@42: \noindent\ignorespaces##\unskip\multistrut
Chris@42: }\cr
Chris@42: }
Chris@42: \def\Emultitable{%
Chris@42: \crcr
Chris@42: \egroup % end the \halign
Chris@42: \global\setpercentfalse
Chris@42: }
Chris@42:
Chris@42: \def\setmultitablespacing{%
Chris@42: \def\multistrut{\strut}% just use the standard line spacing
Chris@42: %
Chris@42: % Compute \multitablelinespace (if not defined by user) for use in
Chris@42: % \multitableparskip calculation. We used define \multistrut based on
Chris@42: % this, but (ironically) that caused the spacing to be off.
Chris@42: % See bug-texinfo report from Werner Lemberg, 31 Oct 2004 12:52:20 +0100.
Chris@42: \ifdim\multitablelinespace=0pt
Chris@42: \setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip
Chris@42: \global\advance\multitablelinespace by-\ht0
Chris@42: \fi
Chris@42: % Test to see if parskip is larger than space between lines of
Chris@42: % table. If not, do nothing.
Chris@42: % If so, set to same dimension as multitablelinespace.
Chris@42: \ifdim\multitableparskip>\multitablelinespace
Chris@42: \global\multitableparskip=\multitablelinespace
Chris@42: \global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
Chris@42: % than skip between lines in the table.
Chris@42: \fi%
Chris@42: \ifdim\multitableparskip=0pt
Chris@42: \global\multitableparskip=\multitablelinespace
Chris@42: \global\advance\multitableparskip-7pt % to keep parskip somewhat smaller
Chris@42: % than skip between lines in the table.
Chris@42: \fi}
Chris@42:
Chris@42:
Chris@42: \message{conditionals,}
Chris@42:
Chris@42: % @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext,
Chris@42: % @ifnotxml always succeed. They currently do nothing; we don't
Chris@42: % attempt to check whether the conditionals are properly nested. But we
Chris@42: % have to remember that they are conditionals, so that @end doesn't
Chris@42: % attempt to close an environment group.
Chris@42: %
Chris@42: \def\makecond#1{%
Chris@42: \expandafter\let\csname #1\endcsname = \relax
Chris@42: \expandafter\let\csname iscond.#1\endcsname = 1
Chris@42: }
Chris@42: \makecond{iftex}
Chris@42: \makecond{ifnotdocbook}
Chris@42: \makecond{ifnothtml}
Chris@42: \makecond{ifnotinfo}
Chris@42: \makecond{ifnotplaintext}
Chris@42: \makecond{ifnotxml}
Chris@42:
Chris@42: % Ignore @ignore, @ifhtml, @ifinfo, and the like.
Chris@42: %
Chris@42: \def\direntry{\doignore{direntry}}
Chris@42: \def\documentdescription{\doignore{documentdescription}}
Chris@42: \def\docbook{\doignore{docbook}}
Chris@42: \def\html{\doignore{html}}
Chris@42: \def\ifdocbook{\doignore{ifdocbook}}
Chris@42: \def\ifhtml{\doignore{ifhtml}}
Chris@42: \def\ifinfo{\doignore{ifinfo}}
Chris@42: \def\ifnottex{\doignore{ifnottex}}
Chris@42: \def\ifplaintext{\doignore{ifplaintext}}
Chris@42: \def\ifxml{\doignore{ifxml}}
Chris@42: \def\ignore{\doignore{ignore}}
Chris@42: \def\menu{\doignore{menu}}
Chris@42: \def\xml{\doignore{xml}}
Chris@42:
Chris@42: % Ignore text until a line `@end #1', keeping track of nested conditionals.
Chris@42: %
Chris@42: % A count to remember the depth of nesting.
Chris@42: \newcount\doignorecount
Chris@42:
Chris@42: \def\doignore#1{\begingroup
Chris@42: % Scan in ``verbatim'' mode:
Chris@42: \obeylines
Chris@42: \catcode`\@ = \other
Chris@42: \catcode`\{ = \other
Chris@42: \catcode`\} = \other
Chris@42: %
Chris@42: % Make sure that spaces turn into tokens that match what \doignoretext wants.
Chris@42: \spaceisspace
Chris@42: %
Chris@42: % Count number of #1's that we've seen.
Chris@42: \doignorecount = 0
Chris@42: %
Chris@42: % Swallow text until we reach the matching `@end #1'.
Chris@42: \dodoignore{#1}%
Chris@42: }
Chris@42:
Chris@42: { \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source.
Chris@42: \obeylines %
Chris@42: %
Chris@42: \gdef\dodoignore#1{%
Chris@42: % #1 contains the command name as a string, e.g., `ifinfo'.
Chris@42: %
Chris@42: % Define a command to find the next `@end #1'.
Chris@42: \long\def\doignoretext##1^^M@end #1{%
Chris@42: \doignoretextyyy##1^^M@#1\_STOP_}%
Chris@42: %
Chris@42: % And this command to find another #1 command, at the beginning of a
Chris@42: % line. (Otherwise, we would consider a line `@c @ifset', for
Chris@42: % example, to count as an @ifset for nesting.)
Chris@42: \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}%
Chris@42: %
Chris@42: % And now expand that command.
Chris@42: \doignoretext ^^M%
Chris@42: }%
Chris@42: }
Chris@42:
Chris@42: \def\doignoreyyy#1{%
Chris@42: \def\temp{#1}%
Chris@42: \ifx\temp\empty % Nothing found.
Chris@42: \let\next\doignoretextzzz
Chris@42: \else % Found a nested condition, ...
Chris@42: \advance\doignorecount by 1
Chris@42: \let\next\doignoretextyyy % ..., look for another.
Chris@42: % If we're here, #1 ends with ^^M\ifinfo (for example).
Chris@42: \fi
Chris@42: \next #1% the token \_STOP_ is present just after this macro.
Chris@42: }
Chris@42:
Chris@42: % We have to swallow the remaining "\_STOP_".
Chris@42: %
Chris@42: \def\doignoretextzzz#1{%
Chris@42: \ifnum\doignorecount = 0 % We have just found the outermost @end.
Chris@42: \let\next\enddoignore
Chris@42: \else % Still inside a nested condition.
Chris@42: \advance\doignorecount by -1
Chris@42: \let\next\doignoretext % Look for the next @end.
Chris@42: \fi
Chris@42: \next
Chris@42: }
Chris@42:
Chris@42: % Finish off ignored text.
Chris@42: { \obeylines%
Chris@42: % Ignore anything after the last `@end #1'; this matters in verbatim
Chris@42: % environments, where otherwise the newline after an ignored conditional
Chris@42: % would result in a blank line in the output.
Chris@42: \gdef\enddoignore#1^^M{\endgroup\ignorespaces}%
Chris@42: }
Chris@42:
Chris@42:
Chris@42: % @set VAR sets the variable VAR to an empty value.
Chris@42: % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE.
Chris@42: %
Chris@42: % Since we want to separate VAR from REST-OF-LINE (which might be
Chris@42: % empty), we can't just use \parsearg; we have to insert a space of our
Chris@42: % own to delimit the rest of the line, and then take it out again if we
Chris@42: % didn't need it.
Chris@42: % We rely on the fact that \parsearg sets \catcode`\ =10.
Chris@42: %
Chris@42: \parseargdef\set{\setyyy#1 \endsetyyy}
Chris@42: \def\setyyy#1 #2\endsetyyy{%
Chris@42: {%
Chris@42: \makevalueexpandable
Chris@42: \def\temp{#2}%
Chris@42: \edef\next{\gdef\makecsname{SET#1}}%
Chris@42: \ifx\temp\empty
Chris@42: \next{}%
Chris@42: \else
Chris@42: \setzzz#2\endsetzzz
Chris@42: \fi
Chris@42: }%
Chris@42: }
Chris@42: % Remove the trailing space \setxxx inserted.
Chris@42: \def\setzzz#1 \endsetzzz{\next{#1}}
Chris@42:
Chris@42: % @clear VAR clears (i.e., unsets) the variable VAR.
Chris@42: %
Chris@42: \parseargdef\clear{%
Chris@42: {%
Chris@42: \makevalueexpandable
Chris@42: \global\expandafter\let\csname SET#1\endcsname=\relax
Chris@42: }%
Chris@42: }
Chris@42:
Chris@42: % @value{foo} gets the text saved in variable foo.
Chris@42: \def\value{\begingroup\makevalueexpandable\valuexxx}
Chris@42: \def\valuexxx#1{\expandablevalue{#1}\endgroup}
Chris@42: {
Chris@42: \catcode`\- = \active \catcode`\_ = \active
Chris@42: %
Chris@42: \gdef\makevalueexpandable{%
Chris@42: \let\value = \expandablevalue
Chris@42: % We don't want these characters active, ...
Chris@42: \catcode`\-=\other \catcode`\_=\other
Chris@42: % ..., but we might end up with active ones in the argument if
Chris@42: % we're called from @code, as @code{@value{foo-bar_}}, though.
Chris@42: % So \let them to their normal equivalents.
Chris@42: \let-\normaldash \let_\normalunderscore
Chris@42: }
Chris@42: }
Chris@42:
Chris@42: % We have this subroutine so that we can handle at least some @value's
Chris@42: % properly in indexes (we call \makevalueexpandable in \indexdummies).
Chris@42: % The command has to be fully expandable (if the variable is set), since
Chris@42: % the result winds up in the index file. This means that if the
Chris@42: % variable's value contains other Texinfo commands, it's almost certain
Chris@42: % it will fail (although perhaps we could fix that with sufficient work
Chris@42: % to do a one-level expansion on the result, instead of complete).
Chris@42: %
Chris@42: \def\expandablevalue#1{%
Chris@42: \expandafter\ifx\csname SET#1\endcsname\relax
Chris@42: {[No value for ``#1'']}%
Chris@42: \message{Variable `#1', used in @value, is not set.}%
Chris@42: \else
Chris@42: \csname SET#1\endcsname
Chris@42: \fi
Chris@42: }
Chris@42:
Chris@42: % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined
Chris@42: % with @set.
Chris@42: %
Chris@42: % To get special treatment of `@end ifset,' call \makeond and the redefine.
Chris@42: %
Chris@42: \makecond{ifset}
Chris@42: \def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}}
Chris@42: \def\doifset#1#2{%
Chris@42: {%
Chris@42: \makevalueexpandable
Chris@42: \let\next=\empty
Chris@42: \expandafter\ifx\csname SET#2\endcsname\relax
Chris@42: #1% If not set, redefine \next.
Chris@42: \fi
Chris@42: \expandafter
Chris@42: }\next
Chris@42: }
Chris@42: \def\ifsetfail{\doignore{ifset}}
Chris@42:
Chris@42: % @ifclear VAR ... @end executes the `...' iff VAR has never been
Chris@42: % defined with @set, or has been undefined with @clear.
Chris@42: %
Chris@42: % The `\else' inside the `\doifset' parameter is a trick to reuse the
Chris@42: % above code: if the variable is not set, do nothing, if it is set,
Chris@42: % then redefine \next to \ifclearfail.
Chris@42: %
Chris@42: \makecond{ifclear}
Chris@42: \def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}}
Chris@42: \def\ifclearfail{\doignore{ifclear}}
Chris@42:
Chris@42: % @ifcommandisdefined CMD ... @end executes the `...' if CMD (written
Chris@42: % without the @) is in fact defined. We can only feasibly check at the
Chris@42: % TeX level, so something like `mathcode' is going to considered
Chris@42: % defined even though it is not a Texinfo command.
Chris@42: %
Chris@42: \makecond{ifcommanddefined}
Chris@42: \def\ifcommanddefined{\parsearg{\doifcmddefined{\let\next=\ifcmddefinedfail}}}
Chris@42: %
Chris@42: \def\doifcmddefined#1#2{{%
Chris@42: \makevalueexpandable
Chris@42: \let\next=\empty
Chris@42: \expandafter\ifx\csname #2\endcsname\relax
Chris@42: #1% If not defined, \let\next as above.
Chris@42: \fi
Chris@42: \expandafter
Chris@42: }\next
Chris@42: }
Chris@42: \def\ifcmddefinedfail{\doignore{ifcommanddefined}}
Chris@42:
Chris@42: % @ifcommandnotdefined CMD ... handled similar to @ifclear above.
Chris@42: \makecond{ifcommandnotdefined}
Chris@42: \def\ifcommandnotdefined{%
Chris@42: \parsearg{\doifcmddefined{\else \let\next=\ifcmdnotdefinedfail}}}
Chris@42: \def\ifcmdnotdefinedfail{\doignore{ifcommandnotdefined}}
Chris@42:
Chris@42: % Set the `txicommandconditionals' variable, so documents have a way to
Chris@42: % test if the @ifcommand...defined conditionals are available.
Chris@42: \set txicommandconditionals
Chris@42:
Chris@42: % @dircategory CATEGORY -- specify a category of the dir file
Chris@42: % which this file should belong to. Ignore this in TeX.
Chris@42: \let\dircategory=\comment
Chris@42:
Chris@42: % @defininfoenclose.
Chris@42: \let\definfoenclose=\comment
Chris@42:
Chris@42:
Chris@42: \message{indexing,}
Chris@42: % Index generation facilities
Chris@42:
Chris@42: % Define \newwrite to be identical to plain tex's \newwrite
Chris@42: % except not \outer, so it can be used within macros and \if's.
Chris@42: \edef\newwrite{\makecsname{ptexnewwrite}}
Chris@42:
Chris@42: % \newindex {foo} defines an index named foo.
Chris@42: % It automatically defines \fooindex such that
Chris@42: % \fooindex ...rest of line... puts an entry in the index foo.
Chris@42: % It also defines \fooindfile to be the number of the output channel for
Chris@42: % the file that accumulates this index. The file's extension is foo.
Chris@42: % The name of an index should be no more than 2 characters long
Chris@42: % for the sake of vms.
Chris@42: %
Chris@42: \def\newindex#1{%
Chris@42: \iflinks
Chris@42: \expandafter\newwrite \csname#1indfile\endcsname
Chris@42: \openout \csname#1indfile\endcsname \jobname.#1 % Open the file
Chris@42: \fi
Chris@42: \expandafter\xdef\csname#1index\endcsname{% % Define @#1index
Chris@42: \noexpand\doindex{#1}}
Chris@42: }
Chris@42:
Chris@42: % @defindex foo == \newindex{foo}
Chris@42: %
Chris@42: \def\defindex{\parsearg\newindex}
Chris@42:
Chris@42: % Define @defcodeindex, like @defindex except put all entries in @code.
Chris@42: %
Chris@42: \def\defcodeindex{\parsearg\newcodeindex}
Chris@42: %
Chris@42: \def\newcodeindex#1{%
Chris@42: \iflinks
Chris@42: \expandafter\newwrite \csname#1indfile\endcsname
Chris@42: \openout \csname#1indfile\endcsname \jobname.#1
Chris@42: \fi
Chris@42: \expandafter\xdef\csname#1index\endcsname{%
Chris@42: \noexpand\docodeindex{#1}}%
Chris@42: }
Chris@42:
Chris@42:
Chris@42: % @synindex foo bar makes index foo feed into index bar.
Chris@42: % Do this instead of @defindex foo if you don't want it as a separate index.
Chris@42: %
Chris@42: % @syncodeindex foo bar similar, but put all entries made for index foo
Chris@42: % inside @code.
Chris@42: %
Chris@42: \def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}}
Chris@42: \def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}}
Chris@42:
Chris@42: % #1 is \doindex or \docodeindex, #2 the index getting redefined (foo),
Chris@42: % #3 the target index (bar).
Chris@42: \def\dosynindex#1#2#3{%
Chris@42: % Only do \closeout if we haven't already done it, else we'll end up
Chris@42: % closing the target index.
Chris@42: \expandafter \ifx\csname donesynindex#2\endcsname \relax
Chris@42: % The \closeout helps reduce unnecessary open files; the limit on the
Chris@42: % Acorn RISC OS is a mere 16 files.
Chris@42: \expandafter\closeout\csname#2indfile\endcsname
Chris@42: \expandafter\let\csname donesynindex#2\endcsname = 1
Chris@42: \fi
Chris@42: % redefine \fooindfile:
Chris@42: \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname
Chris@42: \expandafter\let\csname#2indfile\endcsname=\temp
Chris@42: % redefine \fooindex:
Chris@42: \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}%
Chris@42: }
Chris@42:
Chris@42: % Define \doindex, the driver for all \fooindex macros.
Chris@42: % Argument #1 is generated by the calling \fooindex macro,
Chris@42: % and it is "foo", the name of the index.
Chris@42:
Chris@42: % \doindex just uses \parsearg; it calls \doind for the actual work.
Chris@42: % This is because \doind is more useful to call from other macros.
Chris@42:
Chris@42: % There is also \dosubind {index}{topic}{subtopic}
Chris@42: % which makes an entry in a two-level index such as the operation index.
Chris@42:
Chris@42: \def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer}
Chris@42: \def\singleindexer #1{\doind{\indexname}{#1}}
Chris@42:
Chris@42: % like the previous two, but they put @code around the argument.
Chris@42: \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer}
Chris@42: \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}}
Chris@42:
Chris@42: % Take care of Texinfo commands that can appear in an index entry.
Chris@42: % Since there are some commands we want to expand, and others we don't,
Chris@42: % we have to laboriously prevent expansion for those that we don't.
Chris@42: %
Chris@42: \def\indexdummies{%
Chris@42: \escapechar = `\\ % use backslash in output files.
Chris@42: \def\@{@}% change to @@ when we switch to @ as escape char in index files.
Chris@42: \def\ {\realbackslash\space }%
Chris@42: %
Chris@42: % Need these unexpandable (because we define \tt as a dummy)
Chris@42: % definitions when @{ or @} appear in index entry text. Also, more
Chris@42: % complicated, when \tex is in effect and \{ is a \delimiter again.
Chris@42: % We can't use \lbracecmd and \rbracecmd because texindex assumes
Chris@42: % braces and backslashes are used only as delimiters. Perhaps we
Chris@42: % should define @lbrace and @rbrace commands a la @comma.
Chris@42: \def\{{{\tt\char123}}%
Chris@42: \def\}{{\tt\char125}}%
Chris@42: %
Chris@42: % I don't entirely understand this, but when an index entry is
Chris@42: % generated from a macro call, the \endinput which \scanmacro inserts
Chris@42: % causes processing to be prematurely terminated. This is,
Chris@42: % apparently, because \indexsorttmp is fully expanded, and \endinput
Chris@42: % is an expandable command. The redefinition below makes \endinput
Chris@42: % disappear altogether for that purpose -- although logging shows that
Chris@42: % processing continues to some further point. On the other hand, it
Chris@42: % seems \endinput does not hurt in the printed index arg, since that
Chris@42: % is still getting written without apparent harm.
Chris@42: %
Chris@42: % Sample source (mac-idx3.tex, reported by Graham Percival to
Chris@42: % help-texinfo, 22may06):
Chris@42: % @macro funindex {WORD}
Chris@42: % @findex xyz
Chris@42: % @end macro
Chris@42: % ...
Chris@42: % @funindex commtest
Chris@42: %
Chris@42: % The above is not enough to reproduce the bug, but it gives the flavor.
Chris@42: %
Chris@42: % Sample whatsit resulting:
Chris@42: % .@write3{\entry{xyz}{@folio }{@code {xyz@endinput }}}
Chris@42: %
Chris@42: % So:
Chris@42: \let\endinput = \empty
Chris@42: %
Chris@42: % Do the redefinitions.
Chris@42: \commondummies
Chris@42: }
Chris@42:
Chris@42: % For the aux and toc files, @ is the escape character. So we want to
Chris@42: % redefine everything using @ as the escape character (instead of
Chris@42: % \realbackslash, still used for index files). When everything uses @,
Chris@42: % this will be simpler.
Chris@42: %
Chris@42: \def\atdummies{%
Chris@42: \def\@{@@}%
Chris@42: \def\ {@ }%
Chris@42: \let\{ = \lbraceatcmd
Chris@42: \let\} = \rbraceatcmd
Chris@42: %
Chris@42: % Do the redefinitions.
Chris@42: \commondummies
Chris@42: \otherbackslash
Chris@42: }
Chris@42:
Chris@42: % Called from \indexdummies and \atdummies.
Chris@42: %
Chris@42: \def\commondummies{%
Chris@42: %
Chris@42: % \definedummyword defines \#1 as \string\#1\space, thus effectively
Chris@42: % preventing its expansion. This is used only for control words,
Chris@42: % not control letters, because the \space would be incorrect for
Chris@42: % control characters, but is needed to separate the control word
Chris@42: % from whatever follows.
Chris@42: %
Chris@42: % For control letters, we have \definedummyletter, which omits the
Chris@42: % space.
Chris@42: %
Chris@42: % These can be used both for control words that take an argument and
Chris@42: % those that do not. If it is followed by {arg} in the input, then
Chris@42: % that will dutifully get written to the index (or wherever).
Chris@42: %
Chris@42: \def\definedummyword ##1{\def##1{\string##1\space}}%
Chris@42: \def\definedummyletter##1{\def##1{\string##1}}%
Chris@42: \let\definedummyaccent\definedummyletter
Chris@42: %
Chris@42: \commondummiesnofonts
Chris@42: %
Chris@42: \definedummyletter\_%
Chris@42: \definedummyletter\-%
Chris@42: %
Chris@42: % Non-English letters.
Chris@42: \definedummyword\AA
Chris@42: \definedummyword\AE
Chris@42: \definedummyword\DH
Chris@42: \definedummyword\L
Chris@42: \definedummyword\O
Chris@42: \definedummyword\OE
Chris@42: \definedummyword\TH
Chris@42: \definedummyword\aa
Chris@42: \definedummyword\ae
Chris@42: \definedummyword\dh
Chris@42: \definedummyword\exclamdown
Chris@42: \definedummyword\l
Chris@42: \definedummyword\o
Chris@42: \definedummyword\oe
Chris@42: \definedummyword\ordf
Chris@42: \definedummyword\ordm
Chris@42: \definedummyword\questiondown
Chris@42: \definedummyword\ss
Chris@42: \definedummyword\th
Chris@42: %
Chris@42: % Although these internal commands shouldn't show up, sometimes they do.
Chris@42: \definedummyword\bf
Chris@42: \definedummyword\gtr
Chris@42: \definedummyword\hat
Chris@42: \definedummyword\less
Chris@42: \definedummyword\sf
Chris@42: \definedummyword\sl
Chris@42: \definedummyword\tclose
Chris@42: \definedummyword\tt
Chris@42: %
Chris@42: \definedummyword\LaTeX
Chris@42: \definedummyword\TeX
Chris@42: %
Chris@42: % Assorted special characters.
Chris@42: \definedummyword\arrow
Chris@42: \definedummyword\bullet
Chris@42: \definedummyword\comma
Chris@42: \definedummyword\copyright
Chris@42: \definedummyword\registeredsymbol
Chris@42: \definedummyword\dots
Chris@42: \definedummyword\enddots
Chris@42: \definedummyword\entrybreak
Chris@42: \definedummyword\equiv
Chris@42: \definedummyword\error
Chris@42: \definedummyword\euro
Chris@42: \definedummyword\expansion
Chris@42: \definedummyword\geq
Chris@42: \definedummyword\guillemetleft
Chris@42: \definedummyword\guillemetright
Chris@42: \definedummyword\guilsinglleft
Chris@42: \definedummyword\guilsinglright
Chris@42: \definedummyword\lbracechar
Chris@42: \definedummyword\leq
Chris@42: \definedummyword\minus
Chris@42: \definedummyword\ogonek
Chris@42: \definedummyword\pounds
Chris@42: \definedummyword\point
Chris@42: \definedummyword\print
Chris@42: \definedummyword\quotedblbase
Chris@42: \definedummyword\quotedblleft
Chris@42: \definedummyword\quotedblright
Chris@42: \definedummyword\quoteleft
Chris@42: \definedummyword\quoteright
Chris@42: \definedummyword\quotesinglbase
Chris@42: \definedummyword\rbracechar
Chris@42: \definedummyword\result
Chris@42: \definedummyword\textdegree
Chris@42: %
Chris@42: % We want to disable all macros so that they are not expanded by \write.
Chris@42: \macrolist
Chris@42: %
Chris@42: \normalturnoffactive
Chris@42: %
Chris@42: % Handle some cases of @value -- where it does not contain any
Chris@42: % (non-fully-expandable) commands.
Chris@42: \makevalueexpandable
Chris@42: }
Chris@42:
Chris@42: % \commondummiesnofonts: common to \commondummies and \indexnofonts.
Chris@42: %
Chris@42: \def\commondummiesnofonts{%
Chris@42: % Control letters and accents.
Chris@42: \definedummyletter\!%
Chris@42: \definedummyaccent\"%
Chris@42: \definedummyaccent\'%
Chris@42: \definedummyletter\*%
Chris@42: \definedummyaccent\,%
Chris@42: \definedummyletter\.%
Chris@42: \definedummyletter\/%
Chris@42: \definedummyletter\:%
Chris@42: \definedummyaccent\=%
Chris@42: \definedummyletter\?%
Chris@42: \definedummyaccent\^%
Chris@42: \definedummyaccent\`%
Chris@42: \definedummyaccent\~%
Chris@42: \definedummyword\u
Chris@42: \definedummyword\v
Chris@42: \definedummyword\H
Chris@42: \definedummyword\dotaccent
Chris@42: \definedummyword\ogonek
Chris@42: \definedummyword\ringaccent
Chris@42: \definedummyword\tieaccent
Chris@42: \definedummyword\ubaraccent
Chris@42: \definedummyword\udotaccent
Chris@42: \definedummyword\dotless
Chris@42: %
Chris@42: % Texinfo font commands.
Chris@42: \definedummyword\b
Chris@42: \definedummyword\i
Chris@42: \definedummyword\r
Chris@42: \definedummyword\sansserif
Chris@42: \definedummyword\sc
Chris@42: \definedummyword\slanted
Chris@42: \definedummyword\t
Chris@42: %
Chris@42: % Commands that take arguments.
Chris@42: \definedummyword\abbr
Chris@42: \definedummyword\acronym
Chris@42: \definedummyword\anchor
Chris@42: \definedummyword\cite
Chris@42: \definedummyword\code
Chris@42: \definedummyword\command
Chris@42: \definedummyword\dfn
Chris@42: \definedummyword\dmn
Chris@42: \definedummyword\email
Chris@42: \definedummyword\emph
Chris@42: \definedummyword\env
Chris@42: \definedummyword\file
Chris@42: \definedummyword\image
Chris@42: \definedummyword\indicateurl
Chris@42: \definedummyword\inforef
Chris@42: \definedummyword\kbd
Chris@42: \definedummyword\key
Chris@42: \definedummyword\math
Chris@42: \definedummyword\option
Chris@42: \definedummyword\pxref
Chris@42: \definedummyword\ref
Chris@42: \definedummyword\samp
Chris@42: \definedummyword\strong
Chris@42: \definedummyword\tie
Chris@42: \definedummyword\uref
Chris@42: \definedummyword\url
Chris@42: \definedummyword\var
Chris@42: \definedummyword\verb
Chris@42: \definedummyword\w
Chris@42: \definedummyword\xref
Chris@42: }
Chris@42:
Chris@42: % \indexnofonts is used when outputting the strings to sort the index
Chris@42: % by, and when constructing control sequence names. It eliminates all
Chris@42: % control sequences and just writes whatever the best ASCII sort string
Chris@42: % would be for a given command (usually its argument).
Chris@42: %
Chris@42: \def\indexnofonts{%
Chris@42: % Accent commands should become @asis.
Chris@42: \def\definedummyaccent##1{\let##1\asis}%
Chris@42: % We can just ignore other control letters.
Chris@42: \def\definedummyletter##1{\let##1\empty}%
Chris@42: % All control words become @asis by default; overrides below.
Chris@42: \let\definedummyword\definedummyaccent
Chris@42: %
Chris@42: \commondummiesnofonts
Chris@42: %
Chris@42: % Don't no-op \tt, since it isn't a user-level command
Chris@42: % and is used in the definitions of the active chars like <, >, |, etc.
Chris@42: % Likewise with the other plain tex font commands.
Chris@42: %\let\tt=\asis
Chris@42: %
Chris@42: \def\ { }%
Chris@42: \def\@{@}%
Chris@42: \def\_{\normalunderscore}%
Chris@42: \def\-{}% @- shouldn't affect sorting
Chris@42: %
Chris@42: % Unfortunately, texindex is not prepared to handle braces in the
Chris@42: % content at all. So for index sorting, we map @{ and @} to strings
Chris@42: % starting with |, since that ASCII character is between ASCII { and }.
Chris@42: \def\{{|a}%
Chris@42: \def\lbracechar{|a}%
Chris@42: %
Chris@42: \def\}{|b}%
Chris@42: \def\rbracechar{|b}%
Chris@42: %
Chris@42: % Non-English letters.
Chris@42: \def\AA{AA}%
Chris@42: \def\AE{AE}%
Chris@42: \def\DH{DZZ}%
Chris@42: \def\L{L}%
Chris@42: \def\OE{OE}%
Chris@42: \def\O{O}%
Chris@42: \def\TH{ZZZ}%
Chris@42: \def\aa{aa}%
Chris@42: \def\ae{ae}%
Chris@42: \def\dh{dzz}%
Chris@42: \def\exclamdown{!}%
Chris@42: \def\l{l}%
Chris@42: \def\oe{oe}%
Chris@42: \def\ordf{a}%
Chris@42: \def\ordm{o}%
Chris@42: \def\o{o}%
Chris@42: \def\questiondown{?}%
Chris@42: \def\ss{ss}%
Chris@42: \def\th{zzz}%
Chris@42: %
Chris@42: \def\LaTeX{LaTeX}%
Chris@42: \def\TeX{TeX}%
Chris@42: %
Chris@42: % Assorted special characters.
Chris@42: % (The following {} will end up in the sort string, but that's ok.)
Chris@42: \def\arrow{->}%
Chris@42: \def\bullet{bullet}%
Chris@42: \def\comma{,}%
Chris@42: \def\copyright{copyright}%
Chris@42: \def\dots{...}%
Chris@42: \def\enddots{...}%
Chris@42: \def\equiv{==}%
Chris@42: \def\error{error}%
Chris@42: \def\euro{euro}%
Chris@42: \def\expansion{==>}%
Chris@42: \def\geq{>=}%
Chris@42: \def\guillemetleft{<<}%
Chris@42: \def\guillemetright{>>}%
Chris@42: \def\guilsinglleft{<}%
Chris@42: \def\guilsinglright{>}%
Chris@42: \def\leq{<=}%
Chris@42: \def\minus{-}%
Chris@42: \def\point{.}%
Chris@42: \def\pounds{pounds}%
Chris@42: \def\print{-|}%
Chris@42: \def\quotedblbase{"}%
Chris@42: \def\quotedblleft{"}%
Chris@42: \def\quotedblright{"}%
Chris@42: \def\quoteleft{`}%
Chris@42: \def\quoteright{'}%
Chris@42: \def\quotesinglbase{,}%
Chris@42: \def\registeredsymbol{R}%
Chris@42: \def\result{=>}%
Chris@42: \def\textdegree{o}%
Chris@42: %
Chris@42: \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax
Chris@42: \else \indexlquoteignore \fi
Chris@42: %
Chris@42: % We need to get rid of all macros, leaving only the arguments (if present).
Chris@42: % Of course this is not nearly correct, but it is the best we can do for now.
Chris@42: % makeinfo does not expand macros in the argument to @deffn, which ends up
Chris@42: % writing an index entry, and texindex isn't prepared for an index sort entry
Chris@42: % that starts with \.
Chris@42: %
Chris@42: % Since macro invocations are followed by braces, we can just redefine them
Chris@42: % to take a single TeX argument. The case of a macro invocation that
Chris@42: % goes to end-of-line is not handled.
Chris@42: %
Chris@42: \macrolist
Chris@42: }
Chris@42:
Chris@42: % Undocumented (for FSFS 2nd ed.): @set txiindexlquoteignore makes us
Chris@42: % ignore left quotes in the sort term.
Chris@42: {\catcode`\`=\active
Chris@42: \gdef\indexlquoteignore{\let`=\empty}}
Chris@42:
Chris@42: \let\indexbackslash=0 %overridden during \printindex.
Chris@42: \let\SETmarginindex=\relax % put index entries in margin (undocumented)?
Chris@42:
Chris@42: % Most index entries go through here, but \dosubind is the general case.
Chris@42: % #1 is the index name, #2 is the entry text.
Chris@42: \def\doind#1#2{\dosubind{#1}{#2}{}}
Chris@42:
Chris@42: % Workhorse for all \fooindexes.
Chris@42: % #1 is name of index, #2 is stuff to put there, #3 is subentry --
Chris@42: % empty if called from \doind, as we usually are (the main exception
Chris@42: % is with most defuns, which call us directly).
Chris@42: %
Chris@42: \def\dosubind#1#2#3{%
Chris@42: \iflinks
Chris@42: {%
Chris@42: % Store the main index entry text (including the third arg).
Chris@42: \toks0 = {#2}%
Chris@42: % If third arg is present, precede it with a space.
Chris@42: \def\thirdarg{#3}%
Chris@42: \ifx\thirdarg\empty \else
Chris@42: \toks0 = \expandafter{\the\toks0 \space #3}%
Chris@42: \fi
Chris@42: %
Chris@42: \edef\writeto{\csname#1indfile\endcsname}%
Chris@42: %
Chris@42: \safewhatsit\dosubindwrite
Chris@42: }%
Chris@42: \fi
Chris@42: }
Chris@42:
Chris@42: % Write the entry in \toks0 to the index file:
Chris@42: %
Chris@42: \def\dosubindwrite{%
Chris@42: % Put the index entry in the margin if desired.
Chris@42: \ifx\SETmarginindex\relax\else
Chris@42: \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}%
Chris@42: \fi
Chris@42: %
Chris@42: % Remember, we are within a group.
Chris@42: \indexdummies % Must do this here, since \bf, etc expand at this stage
Chris@42: \def\backslashcurfont{\indexbackslash}% \indexbackslash isn't defined now
Chris@42: % so it will be output as is; and it will print as backslash.
Chris@42: %
Chris@42: % Process the index entry with all font commands turned off, to
Chris@42: % get the string to sort by.
Chris@42: {\indexnofonts
Chris@42: \edef\temp{\the\toks0}% need full expansion
Chris@42: \xdef\indexsorttmp{\temp}%
Chris@42: }%
Chris@42: %
Chris@42: % Set up the complete index entry, with both the sort key and
Chris@42: % the original text, including any font commands. We write
Chris@42: % three arguments to \entry to the .?? file (four in the
Chris@42: % subentry case), texindex reduces to two when writing the .??s
Chris@42: % sorted result.
Chris@42: \edef\temp{%
Chris@42: \write\writeto{%
Chris@42: \string\entry{\indexsorttmp}{\noexpand\folio}{\the\toks0}}%
Chris@42: }%
Chris@42: \temp
Chris@42: }
Chris@42:
Chris@42: % Take care of unwanted page breaks/skips around a whatsit:
Chris@42: %
Chris@42: % If a skip is the last thing on the list now, preserve it
Chris@42: % by backing up by \lastskip, doing the \write, then inserting
Chris@42: % the skip again. Otherwise, the whatsit generated by the
Chris@42: % \write or \pdfdest will make \lastskip zero. The result is that
Chris@42: % sequences like this:
Chris@42: % @end defun
Chris@42: % @tindex whatever
Chris@42: % @defun ...
Chris@42: % will have extra space inserted, because the \medbreak in the
Chris@42: % start of the @defun won't see the skip inserted by the @end of
Chris@42: % the previous defun.
Chris@42: %
Chris@42: % But don't do any of this if we're not in vertical mode. We
Chris@42: % don't want to do a \vskip and prematurely end a paragraph.
Chris@42: %
Chris@42: % Avoid page breaks due to these extra skips, too.
Chris@42: %
Chris@42: % But wait, there is a catch there:
Chris@42: % We'll have to check whether \lastskip is zero skip. \ifdim is not
Chris@42: % sufficient for this purpose, as it ignores stretch and shrink parts
Chris@42: % of the skip. The only way seems to be to check the textual
Chris@42: % representation of the skip.
Chris@42: %
Chris@42: % The following is almost like \def\zeroskipmacro{0.0pt} except that
Chris@42: % the ``p'' and ``t'' characters have catcode \other, not 11 (letter).
Chris@42: %
Chris@42: \edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname}
Chris@42: %
Chris@42: \newskip\whatsitskip
Chris@42: \newcount\whatsitpenalty
Chris@42: %
Chris@42: % ..., ready, GO:
Chris@42: %
Chris@42: \def\safewhatsit#1{\ifhmode
Chris@42: #1%
Chris@42: \else
Chris@42: % \lastskip and \lastpenalty cannot both be nonzero simultaneously.
Chris@42: \whatsitskip = \lastskip
Chris@42: \edef\lastskipmacro{\the\lastskip}%
Chris@42: \whatsitpenalty = \lastpenalty
Chris@42: %
Chris@42: % If \lastskip is nonzero, that means the last item was a
Chris@42: % skip. And since a skip is discardable, that means this
Chris@42: % -\whatsitskip glue we're inserting is preceded by a
Chris@42: % non-discardable item, therefore it is not a potential
Chris@42: % breakpoint, therefore no \nobreak needed.
Chris@42: \ifx\lastskipmacro\zeroskipmacro
Chris@42: \else
Chris@42: \vskip-\whatsitskip
Chris@42: \fi
Chris@42: %
Chris@42: #1%
Chris@42: %
Chris@42: \ifx\lastskipmacro\zeroskipmacro
Chris@42: % If \lastskip was zero, perhaps the last item was a penalty, and
Chris@42: % perhaps it was >=10000, e.g., a \nobreak. In that case, we want
Chris@42: % to re-insert the same penalty (values >10000 are used for various
Chris@42: % signals); since we just inserted a non-discardable item, any
Chris@42: % following glue (such as a \parskip) would be a breakpoint. For example:
Chris@42: % @deffn deffn-whatever
Chris@42: % @vindex index-whatever
Chris@42: % Description.
Chris@42: % would allow a break between the index-whatever whatsit
Chris@42: % and the "Description." paragraph.
Chris@42: \ifnum\whatsitpenalty>9999 \penalty\whatsitpenalty \fi
Chris@42: \else
Chris@42: % On the other hand, if we had a nonzero \lastskip,
Chris@42: % this make-up glue would be preceded by a non-discardable item
Chris@42: % (the whatsit from the \write), so we must insert a \nobreak.
Chris@42: \nobreak\vskip\whatsitskip
Chris@42: \fi
Chris@42: \fi}
Chris@42:
Chris@42: % The index entry written in the file actually looks like
Chris@42: % \entry {sortstring}{page}{topic}
Chris@42: % or
Chris@42: % \entry {sortstring}{page}{topic}{subtopic}
Chris@42: % The texindex program reads in these files and writes files
Chris@42: % containing these kinds of lines:
Chris@42: % \initial {c}
Chris@42: % before the first topic whose initial is c
Chris@42: % \entry {topic}{pagelist}
Chris@42: % for a topic that is used without subtopics
Chris@42: % \primary {topic}
Chris@42: % for the beginning of a topic that is used with subtopics
Chris@42: % \secondary {subtopic}{pagelist}
Chris@42: % for each subtopic.
Chris@42:
Chris@42: % Define the user-accessible indexing commands
Chris@42: % @findex, @vindex, @kindex, @cindex.
Chris@42:
Chris@42: \def\findex {\fnindex}
Chris@42: \def\kindex {\kyindex}
Chris@42: \def\cindex {\cpindex}
Chris@42: \def\vindex {\vrindex}
Chris@42: \def\tindex {\tpindex}
Chris@42: \def\pindex {\pgindex}
Chris@42:
Chris@42: \def\cindexsub {\begingroup\obeylines\cindexsub}
Chris@42: {\obeylines %
Chris@42: \gdef\cindexsub "#1" #2^^M{\endgroup %
Chris@42: \dosubind{cp}{#2}{#1}}}
Chris@42:
Chris@42: % Define the macros used in formatting output of the sorted index material.
Chris@42:
Chris@42: % @printindex causes a particular index (the ??s file) to get printed.
Chris@42: % It does not print any chapter heading (usually an @unnumbered).
Chris@42: %
Chris@42: \parseargdef\printindex{\begingroup
Chris@42: \dobreak \chapheadingskip{10000}%
Chris@42: %
Chris@42: \smallfonts \rm
Chris@42: \tolerance = 9500
Chris@42: \plainfrenchspacing
Chris@42: \everypar = {}% don't want the \kern\-parindent from indentation suppression.
Chris@42: %
Chris@42: % See if the index file exists and is nonempty.
Chris@42: % Change catcode of @ here so that if the index file contains
Chris@42: % \initial {@}
Chris@42: % as its first line, TeX doesn't complain about mismatched braces
Chris@42: % (because it thinks @} is a control sequence).
Chris@42: \catcode`\@ = 11
Chris@42: \openin 1 \jobname.#1s
Chris@42: \ifeof 1
Chris@42: % \enddoublecolumns gets confused if there is no text in the index,
Chris@42: % and it loses the chapter title and the aux file entries for the
Chris@42: % index. The easiest way to prevent this problem is to make sure
Chris@42: % there is some text.
Chris@42: \putwordIndexNonexistent
Chris@42: \else
Chris@42: %
Chris@42: % If the index file exists but is empty, then \openin leaves \ifeof
Chris@42: % false. We have to make TeX try to read something from the file, so
Chris@42: % it can discover if there is anything in it.
Chris@42: \read 1 to \temp
Chris@42: \ifeof 1
Chris@42: \putwordIndexIsEmpty
Chris@42: \else
Chris@42: % Index files are almost Texinfo source, but we use \ as the escape
Chris@42: % character. It would be better to use @, but that's too big a change
Chris@42: % to make right now.
Chris@42: \def\indexbackslash{\backslashcurfont}%
Chris@42: \catcode`\\ = 0
Chris@42: \escapechar = `\\
Chris@42: \begindoublecolumns
Chris@42: \input \jobname.#1s
Chris@42: \enddoublecolumns
Chris@42: \fi
Chris@42: \fi
Chris@42: \closein 1
Chris@42: \endgroup}
Chris@42:
Chris@42: % These macros are used by the sorted index file itself.
Chris@42: % Change them to control the appearance of the index.
Chris@42:
Chris@42: \def\initial#1{{%
Chris@42: % Some minor font changes for the special characters.
Chris@42: \let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt
Chris@42: %
Chris@42: % Remove any glue we may have, we'll be inserting our own.
Chris@42: \removelastskip
Chris@42: %
Chris@42: % We like breaks before the index initials, so insert a bonus.
Chris@42: \nobreak
Chris@42: \vskip 0pt plus 3\baselineskip
Chris@42: \penalty 0
Chris@42: \vskip 0pt plus -3\baselineskip
Chris@42: %
Chris@42: % Typeset the initial. Making this add up to a whole number of
Chris@42: % baselineskips increases the chance of the dots lining up from column
Chris@42: % to column. It still won't often be perfect, because of the stretch
Chris@42: % we need before each entry, but it's better.
Chris@42: %
Chris@42: % No shrink because it confuses \balancecolumns.
Chris@42: \vskip 1.67\baselineskip plus .5\baselineskip
Chris@42: \leftline{\secbf #1}%
Chris@42: % Do our best not to break after the initial.
Chris@42: \nobreak
Chris@42: \vskip .33\baselineskip plus .1\baselineskip
Chris@42: }}
Chris@42:
Chris@42: % \entry typesets a paragraph consisting of the text (#1), dot leaders, and
Chris@42: % then page number (#2) flushed to the right margin. It is used for index
Chris@42: % and table of contents entries. The paragraph is indented by \leftskip.
Chris@42: %
Chris@42: % A straightforward implementation would start like this:
Chris@42: % \def\entry#1#2{...
Chris@42: % But this freezes the catcodes in the argument, and can cause problems to
Chris@42: % @code, which sets - active. This problem was fixed by a kludge---
Chris@42: % ``-'' was active throughout whole index, but this isn't really right.
Chris@42: % The right solution is to prevent \entry from swallowing the whole text.
Chris@42: % --kasal, 21nov03
Chris@42: \def\entry{%
Chris@42: \begingroup
Chris@42: %
Chris@42: % Start a new paragraph if necessary, so our assignments below can't
Chris@42: % affect previous text.
Chris@42: \par
Chris@42: %
Chris@42: % Do not fill out the last line with white space.
Chris@42: \parfillskip = 0in
Chris@42: %
Chris@42: % No extra space above this paragraph.
Chris@42: \parskip = 0in
Chris@42: %
Chris@42: % Do not prefer a separate line ending with a hyphen to fewer lines.
Chris@42: \finalhyphendemerits = 0
Chris@42: %
Chris@42: % \hangindent is only relevant when the entry text and page number
Chris@42: % don't both fit on one line. In that case, bob suggests starting the
Chris@42: % dots pretty far over on the line. Unfortunately, a large
Chris@42: % indentation looks wrong when the entry text itself is broken across
Chris@42: % lines. So we use a small indentation and put up with long leaders.
Chris@42: %
Chris@42: % \hangafter is reset to 1 (which is the value we want) at the start
Chris@42: % of each paragraph, so we need not do anything with that.
Chris@42: \hangindent = 2em
Chris@42: %
Chris@42: % When the entry text needs to be broken, just fill out the first line
Chris@42: % with blank space.
Chris@42: \rightskip = 0pt plus1fil
Chris@42: %
Chris@42: % A bit of stretch before each entry for the benefit of balancing
Chris@42: % columns.
Chris@42: \vskip 0pt plus1pt
Chris@42: %
Chris@42: % When reading the text of entry, convert explicit line breaks
Chris@42: % from @* into spaces. The user might give these in long section
Chris@42: % titles, for instance.
Chris@42: \def\*{\unskip\space\ignorespaces}%
Chris@42: \def\entrybreak{\hfil\break}%
Chris@42: %
Chris@42: % Swallow the left brace of the text (first parameter):
Chris@42: \afterassignment\doentry
Chris@42: \let\temp =
Chris@42: }
Chris@42: \def\entrybreak{\unskip\space\ignorespaces}%
Chris@42: \def\doentry{%
Chris@42: \bgroup % Instead of the swallowed brace.
Chris@42: \noindent
Chris@42: \aftergroup\finishentry
Chris@42: % And now comes the text of the entry.
Chris@42: }
Chris@42: \def\finishentry#1{%
Chris@42: % #1 is the page number.
Chris@42: %
Chris@42: % The following is kludged to not output a line of dots in the index if
Chris@42: % there are no page numbers. The next person who breaks this will be
Chris@42: % cursed by a Unix daemon.
Chris@42: \setbox\boxA = \hbox{#1}%
Chris@42: \ifdim\wd\boxA = 0pt
Chris@42: \ %
Chris@42: \else
Chris@42: %
Chris@42: % If we must, put the page number on a line of its own, and fill out
Chris@42: % this line with blank space. (The \hfil is overwhelmed with the
Chris@42: % fill leaders glue in \indexdotfill if the page number does fit.)
Chris@42: \hfil\penalty50
Chris@42: \null\nobreak\indexdotfill % Have leaders before the page number.
Chris@42: %
Chris@42: % The `\ ' here is removed by the implicit \unskip that TeX does as
Chris@42: % part of (the primitive) \par. Without it, a spurious underfull
Chris@42: % \hbox ensues.
Chris@42: \ifpdf
Chris@42: \pdfgettoks#1.%
Chris@42: \ \the\toksA
Chris@42: \else
Chris@42: \ #1%
Chris@42: \fi
Chris@42: \fi
Chris@42: \par
Chris@42: \endgroup
Chris@42: }
Chris@42:
Chris@42: % Like plain.tex's \dotfill, except uses up at least 1 em.
Chris@42: \def\indexdotfill{\cleaders
Chris@42: \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1fill}
Chris@42:
Chris@42: \def\primary #1{\line{#1\hfil}}
Chris@42:
Chris@42: \newskip\secondaryindent \secondaryindent=0.5cm
Chris@42: \def\secondary#1#2{{%
Chris@42: \parfillskip=0in
Chris@42: \parskip=0in
Chris@42: \hangindent=1in
Chris@42: \hangafter=1
Chris@42: \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill
Chris@42: \ifpdf
Chris@42: \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph.
Chris@42: \else
Chris@42: #2
Chris@42: \fi
Chris@42: \par
Chris@42: }}
Chris@42:
Chris@42: % Define two-column mode, which we use to typeset indexes.
Chris@42: % Adapted from the TeXbook, page 416, which is to say,
Chris@42: % the manmac.tex format used to print the TeXbook itself.
Chris@42: \catcode`\@=11
Chris@42:
Chris@42: \newbox\partialpage
Chris@42: \newdimen\doublecolumnhsize
Chris@42:
Chris@42: \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns
Chris@42: % Grab any single-column material above us.
Chris@42: \output = {%
Chris@42: %
Chris@42: % Here is a possibility not foreseen in manmac: if we accumulate a
Chris@42: % whole lot of material, we might end up calling this \output
Chris@42: % routine twice in a row (see the doublecol-lose test, which is
Chris@42: % essentially a couple of indexes with @setchapternewpage off). In
Chris@42: % that case we just ship out what is in \partialpage with the normal
Chris@42: % output routine. Generally, \partialpage will be empty when this
Chris@42: % runs and this will be a no-op. See the indexspread.tex test case.
Chris@42: \ifvoid\partialpage \else
Chris@42: \onepageout{\pagecontents\partialpage}%
Chris@42: \fi
Chris@42: %
Chris@42: \global\setbox\partialpage = \vbox{%
Chris@42: % Unvbox the main output page.
Chris@42: \unvbox\PAGE
Chris@42: \kern-\topskip \kern\baselineskip
Chris@42: }%
Chris@42: }%
Chris@42: \eject % run that output routine to set \partialpage
Chris@42: %
Chris@42: % Use the double-column output routine for subsequent pages.
Chris@42: \output = {\doublecolumnout}%
Chris@42: %
Chris@42: % Change the page size parameters. We could do this once outside this
Chris@42: % routine, in each of @smallbook, @afourpaper, and the default 8.5x11
Chris@42: % format, but then we repeat the same computation. Repeating a couple
Chris@42: % of assignments once per index is clearly meaningless for the
Chris@42: % execution time, so we may as well do it in one place.
Chris@42: %
Chris@42: % First we halve the line length, less a little for the gutter between
Chris@42: % the columns. We compute the gutter based on the line length, so it
Chris@42: % changes automatically with the paper format. The magic constant
Chris@42: % below is chosen so that the gutter has the same value (well, +-<1pt)
Chris@42: % as it did when we hard-coded it.
Chris@42: %
Chris@42: % We put the result in a separate register, \doublecolumhsize, so we
Chris@42: % can restore it in \pagesofar, after \hsize itself has (potentially)
Chris@42: % been clobbered.
Chris@42: %
Chris@42: \doublecolumnhsize = \hsize
Chris@42: \advance\doublecolumnhsize by -.04154\hsize
Chris@42: \divide\doublecolumnhsize by 2
Chris@42: \hsize = \doublecolumnhsize
Chris@42: %
Chris@42: % Double the \vsize as well. (We don't need a separate register here,
Chris@42: % since nobody clobbers \vsize.)
Chris@42: \vsize = 2\vsize
Chris@42: }
Chris@42:
Chris@42: % The double-column output routine for all double-column pages except
Chris@42: % the last.
Chris@42: %
Chris@42: \def\doublecolumnout{%
Chris@42: \splittopskip=\topskip \splitmaxdepth=\maxdepth
Chris@42: % Get the available space for the double columns -- the normal
Chris@42: % (undoubled) page height minus any material left over from the
Chris@42: % previous page.
Chris@42: \dimen@ = \vsize
Chris@42: \divide\dimen@ by 2
Chris@42: \advance\dimen@ by -\ht\partialpage
Chris@42: %
Chris@42: % box0 will be the left-hand column, box2 the right.
Chris@42: \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@
Chris@42: \onepageout\pagesofar
Chris@42: \unvbox255
Chris@42: \penalty\outputpenalty
Chris@42: }
Chris@42: %
Chris@42: % Re-output the contents of the output page -- any previous material,
Chris@42: % followed by the two boxes we just split, in box0 and box2.
Chris@42: \def\pagesofar{%
Chris@42: \unvbox\partialpage
Chris@42: %
Chris@42: \hsize = \doublecolumnhsize
Chris@42: \wd0=\hsize \wd2=\hsize
Chris@42: \hbox to\pagewidth{\box0\hfil\box2}%
Chris@42: }
Chris@42: %
Chris@42: % All done with double columns.
Chris@42: \def\enddoublecolumns{%
Chris@42: % The following penalty ensures that the page builder is exercised
Chris@42: % _before_ we change the output routine. This is necessary in the
Chris@42: % following situation:
Chris@42: %
Chris@42: % The last section of the index consists only of a single entry.
Chris@42: % Before this section, \pagetotal is less than \pagegoal, so no
Chris@42: % break occurs before the last section starts. However, the last
Chris@42: % section, consisting of \initial and the single \entry, does not
Chris@42: % fit on the page and has to be broken off. Without the following
Chris@42: % penalty the page builder will not be exercised until \eject
Chris@42: % below, and by that time we'll already have changed the output
Chris@42: % routine to the \balancecolumns version, so the next-to-last
Chris@42: % double-column page will be processed with \balancecolumns, which
Chris@42: % is wrong: The two columns will go to the main vertical list, with
Chris@42: % the broken-off section in the recent contributions. As soon as
Chris@42: % the output routine finishes, TeX starts reconsidering the page
Chris@42: % break. The two columns and the broken-off section both fit on the
Chris@42: % page, because the two columns now take up only half of the page
Chris@42: % goal. When TeX sees \eject from below which follows the final
Chris@42: % section, it invokes the new output routine that we've set after
Chris@42: % \balancecolumns below; \onepageout will try to fit the two columns
Chris@42: % and the final section into the vbox of \pageheight (see
Chris@42: % \pagebody), causing an overfull box.
Chris@42: %
Chris@42: % Note that glue won't work here, because glue does not exercise the
Chris@42: % page builder, unlike penalties (see The TeXbook, pp. 280-281).
Chris@42: \penalty0
Chris@42: %
Chris@42: \output = {%
Chris@42: % Split the last of the double-column material. Leave it on the
Chris@42: % current page, no automatic page break.
Chris@42: \balancecolumns
Chris@42: %
Chris@42: % If we end up splitting too much material for the current page,
Chris@42: % though, there will be another page break right after this \output
Chris@42: % invocation ends. Having called \balancecolumns once, we do not
Chris@42: % want to call it again. Therefore, reset \output to its normal
Chris@42: % definition right away. (We hope \balancecolumns will never be
Chris@42: % called on to balance too much material, but if it is, this makes
Chris@42: % the output somewhat more palatable.)
Chris@42: \global\output = {\onepageout{\pagecontents\PAGE}}%
Chris@42: }%
Chris@42: \eject
Chris@42: \endgroup % started in \begindoublecolumns
Chris@42: %
Chris@42: % \pagegoal was set to the doubled \vsize above, since we restarted
Chris@42: % the current page. We're now back to normal single-column
Chris@42: % typesetting, so reset \pagegoal to the normal \vsize (after the
Chris@42: % \endgroup where \vsize got restored).
Chris@42: \pagegoal = \vsize
Chris@42: }
Chris@42: %
Chris@42: % Called at the end of the double column material.
Chris@42: \def\balancecolumns{%
Chris@42: \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120.
Chris@42: \dimen@ = \ht0
Chris@42: \advance\dimen@ by \topskip
Chris@42: \advance\dimen@ by-\baselineskip
Chris@42: \divide\dimen@ by 2 % target to split to
Chris@42: %debug\message{final 2-column material height=\the\ht0, target=\the\dimen@.}%
Chris@42: \splittopskip = \topskip
Chris@42: % Loop until we get a decent breakpoint.
Chris@42: {%
Chris@42: \vbadness = 10000
Chris@42: \loop
Chris@42: \global\setbox3 = \copy0
Chris@42: \global\setbox1 = \vsplit3 to \dimen@
Chris@42: \ifdim\ht3>\dimen@
Chris@42: \global\advance\dimen@ by 1pt
Chris@42: \repeat
Chris@42: }%
Chris@42: %debug\message{split to \the\dimen@, column heights: \the\ht1, \the\ht3.}%
Chris@42: \setbox0=\vbox to\dimen@{\unvbox1}%
Chris@42: \setbox2=\vbox to\dimen@{\unvbox3}%
Chris@42: %
Chris@42: \pagesofar
Chris@42: }
Chris@42: \catcode`\@ = \other
Chris@42:
Chris@42:
Chris@42: \message{sectioning,}
Chris@42: % Chapters, sections, etc.
Chris@42:
Chris@42: % Let's start with @part.
Chris@42: \outer\parseargdef\part{\partzzz{#1}}
Chris@42: \def\partzzz#1{%
Chris@42: \chapoddpage
Chris@42: \null
Chris@42: \vskip.3\vsize % move it down on the page a bit
Chris@42: \begingroup
Chris@42: \noindent \titlefonts\rmisbold #1\par % the text
Chris@42: \let\lastnode=\empty % no node to associate with
Chris@42: \writetocentry{part}{#1}{}% but put it in the toc
Chris@42: \headingsoff % no headline or footline on the part page
Chris@42: \chapoddpage
Chris@42: \endgroup
Chris@42: }
Chris@42:
Chris@42: % \unnumberedno is an oxymoron. But we count the unnumbered
Chris@42: % sections so that we can refer to them unambiguously in the pdf
Chris@42: % outlines by their "section number". We avoid collisions with chapter
Chris@42: % numbers by starting them at 10000. (If a document ever has 10000
Chris@42: % chapters, we're in trouble anyway, I'm sure.)
Chris@42: \newcount\unnumberedno \unnumberedno = 10000
Chris@42: \newcount\chapno
Chris@42: \newcount\secno \secno=0
Chris@42: \newcount\subsecno \subsecno=0
Chris@42: \newcount\subsubsecno \subsubsecno=0
Chris@42:
Chris@42: % This counter is funny since it counts through charcodes of letters A, B, ...
Chris@42: \newcount\appendixno \appendixno = `\@
Chris@42: %
Chris@42: % \def\appendixletter{\char\the\appendixno}
Chris@42: % We do the following ugly conditional instead of the above simple
Chris@42: % construct for the sake of pdftex, which needs the actual
Chris@42: % letter in the expansion, not just typeset.
Chris@42: %
Chris@42: \def\appendixletter{%
Chris@42: \ifnum\appendixno=`A A%
Chris@42: \else\ifnum\appendixno=`B B%
Chris@42: \else\ifnum\appendixno=`C C%
Chris@42: \else\ifnum\appendixno=`D D%
Chris@42: \else\ifnum\appendixno=`E E%
Chris@42: \else\ifnum\appendixno=`F F%
Chris@42: \else\ifnum\appendixno=`G G%
Chris@42: \else\ifnum\appendixno=`H H%
Chris@42: \else\ifnum\appendixno=`I I%
Chris@42: \else\ifnum\appendixno=`J J%
Chris@42: \else\ifnum\appendixno=`K K%
Chris@42: \else\ifnum\appendixno=`L L%
Chris@42: \else\ifnum\appendixno=`M M%
Chris@42: \else\ifnum\appendixno=`N N%
Chris@42: \else\ifnum\appendixno=`O O%
Chris@42: \else\ifnum\appendixno=`P P%
Chris@42: \else\ifnum\appendixno=`Q Q%
Chris@42: \else\ifnum\appendixno=`R R%
Chris@42: \else\ifnum\appendixno=`S S%
Chris@42: \else\ifnum\appendixno=`T T%
Chris@42: \else\ifnum\appendixno=`U U%
Chris@42: \else\ifnum\appendixno=`V V%
Chris@42: \else\ifnum\appendixno=`W W%
Chris@42: \else\ifnum\appendixno=`X X%
Chris@42: \else\ifnum\appendixno=`Y Y%
Chris@42: \else\ifnum\appendixno=`Z Z%
Chris@42: % The \the is necessary, despite appearances, because \appendixletter is
Chris@42: % expanded while writing the .toc file. \char\appendixno is not
Chris@42: % expandable, thus it is written literally, thus all appendixes come out
Chris@42: % with the same letter (or @) in the toc without it.
Chris@42: \else\char\the\appendixno
Chris@42: \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
Chris@42: \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi}
Chris@42:
Chris@42: % Each @chapter defines these (using marks) as the number+name, number
Chris@42: % and name of the chapter. Page headings and footings can use
Chris@42: % these. @section does likewise.
Chris@42: \def\thischapter{}
Chris@42: \def\thischapternum{}
Chris@42: \def\thischaptername{}
Chris@42: \def\thissection{}
Chris@42: \def\thissectionnum{}
Chris@42: \def\thissectionname{}
Chris@42:
Chris@42: \newcount\absseclevel % used to calculate proper heading level
Chris@42: \newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count
Chris@42:
Chris@42: % @raisesections: treat @section as chapter, @subsection as section, etc.
Chris@42: \def\raisesections{\global\advance\secbase by -1}
Chris@42: \let\up=\raisesections % original BFox name
Chris@42:
Chris@42: % @lowersections: treat @chapter as section, @section as subsection, etc.
Chris@42: \def\lowersections{\global\advance\secbase by 1}
Chris@42: \let\down=\lowersections % original BFox name
Chris@42:
Chris@42: % we only have subsub.
Chris@42: \chardef\maxseclevel = 3
Chris@42: %
Chris@42: % A numbered section within an unnumbered changes to unnumbered too.
Chris@42: % To achieve this, remember the "biggest" unnum. sec. we are currently in:
Chris@42: \chardef\unnlevel = \maxseclevel
Chris@42: %
Chris@42: % Trace whether the current chapter is an appendix or not:
Chris@42: % \chapheadtype is "N" or "A", unnumbered chapters are ignored.
Chris@42: \def\chapheadtype{N}
Chris@42:
Chris@42: % Choose a heading macro
Chris@42: % #1 is heading type
Chris@42: % #2 is heading level
Chris@42: % #3 is text for heading
Chris@42: \def\genhead#1#2#3{%
Chris@42: % Compute the abs. sec. level:
Chris@42: \absseclevel=#2
Chris@42: \advance\absseclevel by \secbase
Chris@42: % Make sure \absseclevel doesn't fall outside the range:
Chris@42: \ifnum \absseclevel < 0
Chris@42: \absseclevel = 0
Chris@42: \else
Chris@42: \ifnum \absseclevel > 3
Chris@42: \absseclevel = 3
Chris@42: \fi
Chris@42: \fi
Chris@42: % The heading type:
Chris@42: \def\headtype{#1}%
Chris@42: \if \headtype U%
Chris@42: \ifnum \absseclevel < \unnlevel
Chris@42: \chardef\unnlevel = \absseclevel
Chris@42: \fi
Chris@42: \else
Chris@42: % Check for appendix sections:
Chris@42: \ifnum \absseclevel = 0
Chris@42: \edef\chapheadtype{\headtype}%
Chris@42: \else
Chris@42: \if \headtype A\if \chapheadtype N%
Chris@42: \errmessage{@appendix... within a non-appendix chapter}%
Chris@42: \fi\fi
Chris@42: \fi
Chris@42: % Check for numbered within unnumbered:
Chris@42: \ifnum \absseclevel > \unnlevel
Chris@42: \def\headtype{U}%
Chris@42: \else
Chris@42: \chardef\unnlevel = 3
Chris@42: \fi
Chris@42: \fi
Chris@42: % Now print the heading:
Chris@42: \if \headtype U%
Chris@42: \ifcase\absseclevel
Chris@42: \unnumberedzzz{#3}%
Chris@42: \or \unnumberedseczzz{#3}%
Chris@42: \or \unnumberedsubseczzz{#3}%
Chris@42: \or \unnumberedsubsubseczzz{#3}%
Chris@42: \fi
Chris@42: \else
Chris@42: \if \headtype A%
Chris@42: \ifcase\absseclevel
Chris@42: \appendixzzz{#3}%
Chris@42: \or \appendixsectionzzz{#3}%
Chris@42: \or \appendixsubseczzz{#3}%
Chris@42: \or \appendixsubsubseczzz{#3}%
Chris@42: \fi
Chris@42: \else
Chris@42: \ifcase\absseclevel
Chris@42: \chapterzzz{#3}%
Chris@42: \or \seczzz{#3}%
Chris@42: \or \numberedsubseczzz{#3}%
Chris@42: \or \numberedsubsubseczzz{#3}%
Chris@42: \fi
Chris@42: \fi
Chris@42: \fi
Chris@42: \suppressfirstparagraphindent
Chris@42: }
Chris@42:
Chris@42: % an interface:
Chris@42: \def\numhead{\genhead N}
Chris@42: \def\apphead{\genhead A}
Chris@42: \def\unnmhead{\genhead U}
Chris@42:
Chris@42: % @chapter, @appendix, @unnumbered. Increment top-level counter, reset
Chris@42: % all lower-level sectioning counters to zero.
Chris@42: %
Chris@42: % Also set \chaplevelprefix, which we prepend to @float sequence numbers
Chris@42: % (e.g., figures), q.v. By default (before any chapter), that is empty.
Chris@42: \let\chaplevelprefix = \empty
Chris@42: %
Chris@42: \outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz
Chris@42: \def\chapterzzz#1{%
Chris@42: % section resetting is \global in case the chapter is in a group, such
Chris@42: % as an @include file.
Chris@42: \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
Chris@42: \global\advance\chapno by 1
Chris@42: %
Chris@42: % Used for \float.
Chris@42: \gdef\chaplevelprefix{\the\chapno.}%
Chris@42: \resetallfloatnos
Chris@42: %
Chris@42: % \putwordChapter can contain complex things in translations.
Chris@42: \toks0=\expandafter{\putwordChapter}%
Chris@42: \message{\the\toks0 \space \the\chapno}%
Chris@42: %
Chris@42: % Write the actual heading.
Chris@42: \chapmacro{#1}{Ynumbered}{\the\chapno}%
Chris@42: %
Chris@42: % So @section and the like are numbered underneath this chapter.
Chris@42: \global\let\section = \numberedsec
Chris@42: \global\let\subsection = \numberedsubsec
Chris@42: \global\let\subsubsection = \numberedsubsubsec
Chris@42: }
Chris@42:
Chris@42: \outer\parseargdef\appendix{\apphead0{#1}} % normally calls appendixzzz
Chris@42: %
Chris@42: \def\appendixzzz#1{%
Chris@42: \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
Chris@42: \global\advance\appendixno by 1
Chris@42: \gdef\chaplevelprefix{\appendixletter.}%
Chris@42: \resetallfloatnos
Chris@42: %
Chris@42: % \putwordAppendix can contain complex things in translations.
Chris@42: \toks0=\expandafter{\putwordAppendix}%
Chris@42: \message{\the\toks0 \space \appendixletter}%
Chris@42: %
Chris@42: \chapmacro{#1}{Yappendix}{\appendixletter}%
Chris@42: %
Chris@42: \global\let\section = \appendixsec
Chris@42: \global\let\subsection = \appendixsubsec
Chris@42: \global\let\subsubsection = \appendixsubsubsec
Chris@42: }
Chris@42:
Chris@42: % normally unnmhead0 calls unnumberedzzz:
Chris@42: \outer\parseargdef\unnumbered{\unnmhead0{#1}}
Chris@42: \def\unnumberedzzz#1{%
Chris@42: \global\secno=0 \global\subsecno=0 \global\subsubsecno=0
Chris@42: \global\advance\unnumberedno by 1
Chris@42: %
Chris@42: % Since an unnumbered has no number, no prefix for figures.
Chris@42: \global\let\chaplevelprefix = \empty
Chris@42: \resetallfloatnos
Chris@42: %
Chris@42: % This used to be simply \message{#1}, but TeX fully expands the
Chris@42: % argument to \message. Therefore, if #1 contained @-commands, TeX
Chris@42: % expanded them. For example, in `@unnumbered The @cite{Book}', TeX
Chris@42: % expanded @cite (which turns out to cause errors because \cite is meant
Chris@42: % to be executed, not expanded).
Chris@42: %
Chris@42: % Anyway, we don't want the fully-expanded definition of @cite to appear
Chris@42: % as a result of the \message, we just want `@cite' itself. We use
Chris@42: % \the to achieve this: TeX expands \the only once,
Chris@42: % simply yielding the contents of . (We also do this for
Chris@42: % the toc entries.)
Chris@42: \toks0 = {#1}%
Chris@42: \message{(\the\toks0)}%
Chris@42: %
Chris@42: \chapmacro{#1}{Ynothing}{\the\unnumberedno}%
Chris@42: %
Chris@42: \global\let\section = \unnumberedsec
Chris@42: \global\let\subsection = \unnumberedsubsec
Chris@42: \global\let\subsubsection = \unnumberedsubsubsec
Chris@42: }
Chris@42:
Chris@42: % @centerchap is like @unnumbered, but the heading is centered.
Chris@42: \outer\parseargdef\centerchap{%
Chris@42: % Well, we could do the following in a group, but that would break
Chris@42: % an assumption that \chapmacro is called at the outermost level.
Chris@42: % Thus we are safer this way: --kasal, 24feb04
Chris@42: \let\centerparametersmaybe = \centerparameters
Chris@42: \unnmhead0{#1}%
Chris@42: \let\centerparametersmaybe = \relax
Chris@42: }
Chris@42:
Chris@42: % @top is like @unnumbered.
Chris@42: \let\top\unnumbered
Chris@42:
Chris@42: % Sections.
Chris@42: %
Chris@42: \outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz
Chris@42: \def\seczzz#1{%
Chris@42: \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
Chris@42: \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}%
Chris@42: }
Chris@42:
Chris@42: % normally calls appendixsectionzzz:
Chris@42: \outer\parseargdef\appendixsection{\apphead1{#1}}
Chris@42: \def\appendixsectionzzz#1{%
Chris@42: \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
Chris@42: \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}%
Chris@42: }
Chris@42: \let\appendixsec\appendixsection
Chris@42:
Chris@42: % normally calls unnumberedseczzz:
Chris@42: \outer\parseargdef\unnumberedsec{\unnmhead1{#1}}
Chris@42: \def\unnumberedseczzz#1{%
Chris@42: \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1
Chris@42: \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}%
Chris@42: }
Chris@42:
Chris@42: % Subsections.
Chris@42: %
Chris@42: % normally calls numberedsubseczzz:
Chris@42: \outer\parseargdef\numberedsubsec{\numhead2{#1}}
Chris@42: \def\numberedsubseczzz#1{%
Chris@42: \global\subsubsecno=0 \global\advance\subsecno by 1
Chris@42: \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}%
Chris@42: }
Chris@42:
Chris@42: % normally calls appendixsubseczzz:
Chris@42: \outer\parseargdef\appendixsubsec{\apphead2{#1}}
Chris@42: \def\appendixsubseczzz#1{%
Chris@42: \global\subsubsecno=0 \global\advance\subsecno by 1
Chris@42: \sectionheading{#1}{subsec}{Yappendix}%
Chris@42: {\appendixletter.\the\secno.\the\subsecno}%
Chris@42: }
Chris@42:
Chris@42: % normally calls unnumberedsubseczzz:
Chris@42: \outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}}
Chris@42: \def\unnumberedsubseczzz#1{%
Chris@42: \global\subsubsecno=0 \global\advance\subsecno by 1
Chris@42: \sectionheading{#1}{subsec}{Ynothing}%
Chris@42: {\the\unnumberedno.\the\secno.\the\subsecno}%
Chris@42: }
Chris@42:
Chris@42: % Subsubsections.
Chris@42: %
Chris@42: % normally numberedsubsubseczzz:
Chris@42: \outer\parseargdef\numberedsubsubsec{\numhead3{#1}}
Chris@42: \def\numberedsubsubseczzz#1{%
Chris@42: \global\advance\subsubsecno by 1
Chris@42: \sectionheading{#1}{subsubsec}{Ynumbered}%
Chris@42: {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}%
Chris@42: }
Chris@42:
Chris@42: % normally appendixsubsubseczzz:
Chris@42: \outer\parseargdef\appendixsubsubsec{\apphead3{#1}}
Chris@42: \def\appendixsubsubseczzz#1{%
Chris@42: \global\advance\subsubsecno by 1
Chris@42: \sectionheading{#1}{subsubsec}{Yappendix}%
Chris@42: {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}%
Chris@42: }
Chris@42:
Chris@42: % normally unnumberedsubsubseczzz:
Chris@42: \outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}}
Chris@42: \def\unnumberedsubsubseczzz#1{%
Chris@42: \global\advance\subsubsecno by 1
Chris@42: \sectionheading{#1}{subsubsec}{Ynothing}%
Chris@42: {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}%
Chris@42: }
Chris@42:
Chris@42: % These macros control what the section commands do, according
Chris@42: % to what kind of chapter we are in (ordinary, appendix, or unnumbered).
Chris@42: % Define them by default for a numbered chapter.
Chris@42: \let\section = \numberedsec
Chris@42: \let\subsection = \numberedsubsec
Chris@42: \let\subsubsection = \numberedsubsubsec
Chris@42:
Chris@42: % Define @majorheading, @heading and @subheading
Chris@42:
Chris@42: \def\majorheading{%
Chris@42: {\advance\chapheadingskip by 10pt \chapbreak }%
Chris@42: \parsearg\chapheadingzzz
Chris@42: }
Chris@42:
Chris@42: \def\chapheading{\chapbreak \parsearg\chapheadingzzz}
Chris@42: \def\chapheadingzzz#1{%
Chris@42: \vbox{\chapfonts \raggedtitlesettings #1\par}%
Chris@42: \nobreak\bigskip \nobreak
Chris@42: \suppressfirstparagraphindent
Chris@42: }
Chris@42:
Chris@42: % @heading, @subheading, @subsubheading.
Chris@42: \parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{}
Chris@42: \suppressfirstparagraphindent}
Chris@42: \parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{}
Chris@42: \suppressfirstparagraphindent}
Chris@42: \parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{}
Chris@42: \suppressfirstparagraphindent}
Chris@42:
Chris@42: % These macros generate a chapter, section, etc. heading only
Chris@42: % (including whitespace, linebreaking, etc. around it),
Chris@42: % given all the information in convenient, parsed form.
Chris@42:
Chris@42: % Args are the skip and penalty (usually negative)
Chris@42: \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi}
Chris@42:
Chris@42: % Parameter controlling skip before chapter headings (if needed)
Chris@42: \newskip\chapheadingskip
Chris@42:
Chris@42: % Define plain chapter starts, and page on/off switching for it.
Chris@42: \def\chapbreak{\dobreak \chapheadingskip {-4000}}
Chris@42: \def\chappager{\par\vfill\supereject}
Chris@42: % Because \domark is called before \chapoddpage, the filler page will
Chris@42: % get the headings for the next chapter, which is wrong. But we don't
Chris@42: % care -- we just disable all headings on the filler page.
Chris@42: \def\chapoddpage{%
Chris@42: \chappager
Chris@42: \ifodd\pageno \else
Chris@42: \begingroup
Chris@42: \headingsoff
Chris@42: \null
Chris@42: \chappager
Chris@42: \endgroup
Chris@42: \fi
Chris@42: }
Chris@42:
Chris@42: \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname}
Chris@42:
Chris@42: \def\CHAPPAGoff{%
Chris@42: \global\let\contentsalignmacro = \chappager
Chris@42: \global\let\pchapsepmacro=\chapbreak
Chris@42: \global\let\pagealignmacro=\chappager}
Chris@42:
Chris@42: \def\CHAPPAGon{%
Chris@42: \global\let\contentsalignmacro = \chappager
Chris@42: \global\let\pchapsepmacro=\chappager
Chris@42: \global\let\pagealignmacro=\chappager
Chris@42: \global\def\HEADINGSon{\HEADINGSsingle}}
Chris@42:
Chris@42: \def\CHAPPAGodd{%
Chris@42: \global\let\contentsalignmacro = \chapoddpage
Chris@42: \global\let\pchapsepmacro=\chapoddpage
Chris@42: \global\let\pagealignmacro=\chapoddpage
Chris@42: \global\def\HEADINGSon{\HEADINGSdouble}}
Chris@42:
Chris@42: \CHAPPAGon
Chris@42:
Chris@42: % Chapter opening.
Chris@42: %
Chris@42: % #1 is the text, #2 is the section type (Ynumbered, Ynothing,
Chris@42: % Yappendix, Yomitfromtoc), #3 the chapter number.
Chris@42: %
Chris@42: % To test against our argument.
Chris@42: \def\Ynothingkeyword{Ynothing}
Chris@42: \def\Yomitfromtockeyword{Yomitfromtoc}
Chris@42: \def\Yappendixkeyword{Yappendix}
Chris@42: %
Chris@42: \def\chapmacro#1#2#3{%
Chris@42: % Insert the first mark before the heading break (see notes for \domark).
Chris@42: \let\prevchapterdefs=\lastchapterdefs
Chris@42: \let\prevsectiondefs=\lastsectiondefs
Chris@42: \gdef\lastsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}%
Chris@42: \gdef\thissection{}}%
Chris@42: %
Chris@42: \def\temptype{#2}%
Chris@42: \ifx\temptype\Ynothingkeyword
Chris@42: \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
Chris@42: \gdef\thischapter{\thischaptername}}%
Chris@42: \else\ifx\temptype\Yomitfromtockeyword
Chris@42: \gdef\lastchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}%
Chris@42: \gdef\thischapter{}}%
Chris@42: \else\ifx\temptype\Yappendixkeyword
Chris@42: \toks0={#1}%
Chris@42: \xdef\lastchapterdefs{%
Chris@42: \gdef\noexpand\thischaptername{\the\toks0}%
Chris@42: \gdef\noexpand\thischapternum{\appendixletter}%
Chris@42: % \noexpand\putwordAppendix avoids expanding indigestible
Chris@42: % commands in some of the translations.
Chris@42: \gdef\noexpand\thischapter{\noexpand\putwordAppendix{}
Chris@42: \noexpand\thischapternum:
Chris@42: \noexpand\thischaptername}%
Chris@42: }%
Chris@42: \else
Chris@42: \toks0={#1}%
Chris@42: \xdef\lastchapterdefs{%
Chris@42: \gdef\noexpand\thischaptername{\the\toks0}%
Chris@42: \gdef\noexpand\thischapternum{\the\chapno}%
Chris@42: % \noexpand\putwordChapter avoids expanding indigestible
Chris@42: % commands in some of the translations.
Chris@42: \gdef\noexpand\thischapter{\noexpand\putwordChapter{}
Chris@42: \noexpand\thischapternum:
Chris@42: \noexpand\thischaptername}%
Chris@42: }%
Chris@42: \fi\fi\fi
Chris@42: %
Chris@42: % Output the mark. Pass it through \safewhatsit, to take care of
Chris@42: % the preceding space.
Chris@42: \safewhatsit\domark
Chris@42: %
Chris@42: % Insert the chapter heading break.
Chris@42: \pchapsepmacro
Chris@42: %
Chris@42: % Now the second mark, after the heading break. No break points
Chris@42: % between here and the heading.
Chris@42: \let\prevchapterdefs=\lastchapterdefs
Chris@42: \let\prevsectiondefs=\lastsectiondefs
Chris@42: \domark
Chris@42: %
Chris@42: {%
Chris@42: \chapfonts \rmisbold
Chris@42: %
Chris@42: % Have to define \lastsection before calling \donoderef, because the
Chris@42: % xref code eventually uses it. On the other hand, it has to be called
Chris@42: % after \pchapsepmacro, or the headline will change too soon.
Chris@42: \gdef\lastsection{#1}%
Chris@42: %
Chris@42: % Only insert the separating space if we have a chapter/appendix
Chris@42: % number, and don't print the unnumbered ``number''.
Chris@42: \ifx\temptype\Ynothingkeyword
Chris@42: \setbox0 = \hbox{}%
Chris@42: \def\toctype{unnchap}%
Chris@42: \else\ifx\temptype\Yomitfromtockeyword
Chris@42: \setbox0 = \hbox{}% contents like unnumbered, but no toc entry
Chris@42: \def\toctype{omit}%
Chris@42: \else\ifx\temptype\Yappendixkeyword
Chris@42: \setbox0 = \hbox{\putwordAppendix{} #3\enspace}%
Chris@42: \def\toctype{app}%
Chris@42: \else
Chris@42: \setbox0 = \hbox{#3\enspace}%
Chris@42: \def\toctype{numchap}%
Chris@42: \fi\fi\fi
Chris@42: %
Chris@42: % Write the toc entry for this chapter. Must come before the
Chris@42: % \donoderef, because we include the current node name in the toc
Chris@42: % entry, and \donoderef resets it to empty.
Chris@42: \writetocentry{\toctype}{#1}{#3}%
Chris@42: %
Chris@42: % For pdftex, we have to write out the node definition (aka, make
Chris@42: % the pdfdest) after any page break, but before the actual text has
Chris@42: % been typeset. If the destination for the pdf outline is after the
Chris@42: % text, then jumping from the outline may wind up with the text not
Chris@42: % being visible, for instance under high magnification.
Chris@42: \donoderef{#2}%
Chris@42: %
Chris@42: % Typeset the actual heading.
Chris@42: \nobreak % Avoid page breaks at the interline glue.
Chris@42: \vbox{\raggedtitlesettings \hangindent=\wd0 \centerparametersmaybe
Chris@42: \unhbox0 #1\par}%
Chris@42: }%
Chris@42: \nobreak\bigskip % no page break after a chapter title
Chris@42: \nobreak
Chris@42: }
Chris@42:
Chris@42: % @centerchap -- centered and unnumbered.
Chris@42: \let\centerparametersmaybe = \relax
Chris@42: \def\centerparameters{%
Chris@42: \advance\rightskip by 3\rightskip
Chris@42: \leftskip = \rightskip
Chris@42: \parfillskip = 0pt
Chris@42: }
Chris@42:
Chris@42:
Chris@42: % I don't think this chapter style is supported any more, so I'm not
Chris@42: % updating it with the new noderef stuff. We'll see. --karl, 11aug03.
Chris@42: %
Chris@42: \def\setchapterstyle #1 {\csname CHAPF#1\endcsname}
Chris@42: %
Chris@42: \def\unnchfopen #1{%
Chris@42: \chapoddpage
Chris@42: \vbox{\chapfonts \raggedtitlesettings #1\par}%
Chris@42: \nobreak\bigskip\nobreak
Chris@42: }
Chris@42: \def\chfopen #1#2{\chapoddpage {\chapfonts
Chris@42: \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}%
Chris@42: \par\penalty 5000 %
Chris@42: }
Chris@42: \def\centerchfopen #1{%
Chris@42: \chapoddpage
Chris@42: \vbox{\chapfonts \raggedtitlesettings \hfill #1\hfill}%
Chris@42: \nobreak\bigskip \nobreak
Chris@42: }
Chris@42: \def\CHAPFopen{%
Chris@42: \global\let\chapmacro=\chfopen
Chris@42: \global\let\centerchapmacro=\centerchfopen}
Chris@42:
Chris@42:
Chris@42: % Section titles. These macros combine the section number parts and
Chris@42: % call the generic \sectionheading to do the printing.
Chris@42: %
Chris@42: \newskip\secheadingskip
Chris@42: \def\secheadingbreak{\dobreak \secheadingskip{-1000}}
Chris@42:
Chris@42: % Subsection titles.
Chris@42: \newskip\subsecheadingskip
Chris@42: \def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}}
Chris@42:
Chris@42: % Subsubsection titles.
Chris@42: \def\subsubsecheadingskip{\subsecheadingskip}
Chris@42: \def\subsubsecheadingbreak{\subsecheadingbreak}
Chris@42:
Chris@42:
Chris@42: % Print any size, any type, section title.
Chris@42: %
Chris@42: % #1 is the text, #2 is the section level (sec/subsec/subsubsec), #3 is
Chris@42: % the section type for xrefs (Ynumbered, Ynothing, Yappendix), #4 is the
Chris@42: % section number.
Chris@42: %
Chris@42: \def\seckeyword{sec}
Chris@42: %
Chris@42: \def\sectionheading#1#2#3#4{%
Chris@42: {%
Chris@42: \checkenv{}% should not be in an environment.
Chris@42: %
Chris@42: % Switch to the right set of fonts.
Chris@42: \csname #2fonts\endcsname \rmisbold
Chris@42: %
Chris@42: \def\sectionlevel{#2}%
Chris@42: \def\temptype{#3}%
Chris@42: %
Chris@42: % Insert first mark before the heading break (see notes for \domark).
Chris@42: \let\prevsectiondefs=\lastsectiondefs
Chris@42: \ifx\temptype\Ynothingkeyword
Chris@42: \ifx\sectionlevel\seckeyword
Chris@42: \gdef\lastsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}%
Chris@42: \gdef\thissection{\thissectionname}}%
Chris@42: \fi
Chris@42: \else\ifx\temptype\Yomitfromtockeyword
Chris@42: % Don't redefine \thissection.
Chris@42: \else\ifx\temptype\Yappendixkeyword
Chris@42: \ifx\sectionlevel\seckeyword
Chris@42: \toks0={#1}%
Chris@42: \xdef\lastsectiondefs{%
Chris@42: \gdef\noexpand\thissectionname{\the\toks0}%
Chris@42: \gdef\noexpand\thissectionnum{#4}%
Chris@42: % \noexpand\putwordSection avoids expanding indigestible
Chris@42: % commands in some of the translations.
Chris@42: \gdef\noexpand\thissection{\noexpand\putwordSection{}
Chris@42: \noexpand\thissectionnum:
Chris@42: \noexpand\thissectionname}%
Chris@42: }%
Chris@42: \fi
Chris@42: \else
Chris@42: \ifx\sectionlevel\seckeyword
Chris@42: \toks0={#1}%
Chris@42: \xdef\lastsectiondefs{%
Chris@42: \gdef\noexpand\thissectionname{\the\toks0}%
Chris@42: \gdef\noexpand\thissectionnum{#4}%
Chris@42: % \noexpand\putwordSection avoids expanding indigestible
Chris@42: % commands in some of the translations.
Chris@42: \gdef\noexpand\thissection{\noexpand\putwordSection{}
Chris@42: \noexpand\thissectionnum:
Chris@42: \noexpand\thissectionname}%
Chris@42: }%
Chris@42: \fi
Chris@42: \fi\fi\fi
Chris@42: %
Chris@42: % Go into vertical mode. Usually we'll already be there, but we
Chris@42: % don't want the following whatsit to end up in a preceding paragraph
Chris@42: % if the document didn't happen to have a blank line.
Chris@42: \par
Chris@42: %
Chris@42: % Output the mark. Pass it through \safewhatsit, to take care of
Chris@42: % the preceding space.
Chris@42: \safewhatsit\domark
Chris@42: %
Chris@42: % Insert space above the heading.
Chris@42: \csname #2headingbreak\endcsname
Chris@42: %
Chris@42: % Now the second mark, after the heading break. No break points
Chris@42: % between here and the heading.
Chris@42: \let\prevsectiondefs=\lastsectiondefs
Chris@42: \domark
Chris@42: %
Chris@42: % Only insert the space after the number if we have a section number.
Chris@42: \ifx\temptype\Ynothingkeyword
Chris@42: \setbox0 = \hbox{}%
Chris@42: \def\toctype{unn}%
Chris@42: \gdef\lastsection{#1}%
Chris@42: \else\ifx\temptype\Yomitfromtockeyword
Chris@42: % for @headings -- no section number, don't include in toc,
Chris@42: % and don't redefine \lastsection.
Chris@42: \setbox0 = \hbox{}%
Chris@42: \def\toctype{omit}%
Chris@42: \let\sectionlevel=\empty
Chris@42: \else\ifx\temptype\Yappendixkeyword
Chris@42: \setbox0 = \hbox{#4\enspace}%
Chris@42: \def\toctype{app}%
Chris@42: \gdef\lastsection{#1}%
Chris@42: \else
Chris@42: \setbox0 = \hbox{#4\enspace}%
Chris@42: \def\toctype{num}%
Chris@42: \gdef\lastsection{#1}%
Chris@42: \fi\fi\fi
Chris@42: %
Chris@42: % Write the toc entry (before \donoderef). See comments in \chapmacro.
Chris@42: \writetocentry{\toctype\sectionlevel}{#1}{#4}%
Chris@42: %
Chris@42: % Write the node reference (= pdf destination for pdftex).
Chris@42: % Again, see comments in \chapmacro.
Chris@42: \donoderef{#3}%
Chris@42: %
Chris@42: % Interline glue will be inserted when the vbox is completed.
Chris@42: % That glue will be a valid breakpoint for the page, since it'll be
Chris@42: % preceded by a whatsit (usually from the \donoderef, or from the
Chris@42: % \writetocentry if there was no node). We don't want to allow that
Chris@42: % break, since then the whatsits could end up on page n while the
Chris@42: % section is on page n+1, thus toc/etc. are wrong. Debian bug 276000.
Chris@42: \nobreak
Chris@42: %
Chris@42: % Output the actual section heading.
Chris@42: \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright
Chris@42: \hangindent=\wd0 % zero if no section number
Chris@42: \unhbox0 #1}%
Chris@42: }%
Chris@42: % Add extra space after the heading -- half of whatever came above it.
Chris@42: % Don't allow stretch, though.
Chris@42: \kern .5 \csname #2headingskip\endcsname
Chris@42: %
Chris@42: % Do not let the kern be a potential breakpoint, as it would be if it
Chris@42: % was followed by glue.
Chris@42: \nobreak
Chris@42: %
Chris@42: % We'll almost certainly start a paragraph next, so don't let that
Chris@42: % glue accumulate. (Not a breakpoint because it's preceded by a
Chris@42: % discardable item.) However, when a paragraph is not started next
Chris@42: % (\startdefun, \cartouche, \center, etc.), this needs to be wiped out
Chris@42: % or the negative glue will cause weirdly wrong output, typically
Chris@42: % obscuring the section heading with something else.
Chris@42: \vskip-\parskip
Chris@42: %
Chris@42: % This is so the last item on the main vertical list is a known
Chris@42: % \penalty > 10000, so \startdefun, etc., can recognize the situation
Chris@42: % and do the needful.
Chris@42: \penalty 10001
Chris@42: }
Chris@42:
Chris@42:
Chris@42: \message{toc,}
Chris@42: % Table of contents.
Chris@42: \newwrite\tocfile
Chris@42:
Chris@42: % Write an entry to the toc file, opening it if necessary.
Chris@42: % Called from @chapter, etc.
Chris@42: %
Chris@42: % Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno}
Chris@42: % We append the current node name (if any) and page number as additional
Chris@42: % arguments for the \{chap,sec,...}entry macros which will eventually
Chris@42: % read this. The node name is used in the pdf outlines as the
Chris@42: % destination to jump to.
Chris@42: %
Chris@42: % We open the .toc file for writing here instead of at @setfilename (or
Chris@42: % any other fixed time) so that @contents can be anywhere in the document.
Chris@42: % But if #1 is `omit', then we don't do anything. This is used for the
Chris@42: % table of contents chapter openings themselves.
Chris@42: %
Chris@42: \newif\iftocfileopened
Chris@42: \def\omitkeyword{omit}%
Chris@42: %
Chris@42: \def\writetocentry#1#2#3{%
Chris@42: \edef\writetoctype{#1}%
Chris@42: \ifx\writetoctype\omitkeyword \else
Chris@42: \iftocfileopened\else
Chris@42: \immediate\openout\tocfile = \jobname.toc
Chris@42: \global\tocfileopenedtrue
Chris@42: \fi
Chris@42: %
Chris@42: \iflinks
Chris@42: {\atdummies
Chris@42: \edef\temp{%
Chris@42: \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}%
Chris@42: \temp
Chris@42: }%
Chris@42: \fi
Chris@42: \fi
Chris@42: %
Chris@42: % Tell \shipout to create a pdf destination on each page, if we're
Chris@42: % writing pdf. These are used in the table of contents. We can't
Chris@42: % just write one on every page because the title pages are numbered
Chris@42: % 1 and 2 (the page numbers aren't printed), and so are the first
Chris@42: % two pages of the document. Thus, we'd have two destinations named
Chris@42: % `1', and two named `2'.
Chris@42: \ifpdf \global\pdfmakepagedesttrue \fi
Chris@42: }
Chris@42:
Chris@42:
Chris@42: % These characters do not print properly in the Computer Modern roman
Chris@42: % fonts, so we must take special care. This is more or less redundant
Chris@42: % with the Texinfo input format setup at the end of this file.
Chris@42: %
Chris@42: \def\activecatcodes{%
Chris@42: \catcode`\"=\active
Chris@42: \catcode`\$=\active
Chris@42: \catcode`\<=\active
Chris@42: \catcode`\>=\active
Chris@42: \catcode`\\=\active
Chris@42: \catcode`\^=\active
Chris@42: \catcode`\_=\active
Chris@42: \catcode`\|=\active
Chris@42: \catcode`\~=\active
Chris@42: }
Chris@42:
Chris@42:
Chris@42: % Read the toc file, which is essentially Texinfo input.
Chris@42: \def\readtocfile{%
Chris@42: \setupdatafile
Chris@42: \activecatcodes
Chris@42: \input \tocreadfilename
Chris@42: }
Chris@42:
Chris@42: \newskip\contentsrightmargin \contentsrightmargin=1in
Chris@42: \newcount\savepageno
Chris@42: \newcount\lastnegativepageno \lastnegativepageno = -1
Chris@42:
Chris@42: % Prepare to read what we've written to \tocfile.
Chris@42: %
Chris@42: \def\startcontents#1{%
Chris@42: % If @setchapternewpage on, and @headings double, the contents should
Chris@42: % start on an odd page, unlike chapters. Thus, we maintain
Chris@42: % \contentsalignmacro in parallel with \pagealignmacro.
Chris@42: % From: Torbjorn Granlund
Chris@42: \contentsalignmacro
Chris@42: \immediate\closeout\tocfile
Chris@42: %
Chris@42: % Don't need to put `Contents' or `Short Contents' in the headline.
Chris@42: % It is abundantly clear what they are.
Chris@42: \chapmacro{#1}{Yomitfromtoc}{}%
Chris@42: %
Chris@42: \savepageno = \pageno
Chris@42: \begingroup % Set up to handle contents files properly.
Chris@42: \raggedbottom % Worry more about breakpoints than the bottom.
Chris@42: \advance\hsize by -\contentsrightmargin % Don't use the full line length.
Chris@42: %
Chris@42: % Roman numerals for page numbers.
Chris@42: \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi
Chris@42: }
Chris@42:
Chris@42: % redefined for the two-volume lispref. We always output on
Chris@42: % \jobname.toc even if this is redefined.
Chris@42: %
Chris@42: \def\tocreadfilename{\jobname.toc}
Chris@42:
Chris@42: % Normal (long) toc.
Chris@42: %
Chris@42: \def\contents{%
Chris@42: \startcontents{\putwordTOC}%
Chris@42: \openin 1 \tocreadfilename\space
Chris@42: \ifeof 1 \else
Chris@42: \readtocfile
Chris@42: \fi
Chris@42: \vfill \eject
Chris@42: \contentsalignmacro % in case @setchapternewpage odd is in effect
Chris@42: \ifeof 1 \else
Chris@42: \pdfmakeoutlines
Chris@42: \fi
Chris@42: \closein 1
Chris@42: \endgroup
Chris@42: \lastnegativepageno = \pageno
Chris@42: \global\pageno = \savepageno
Chris@42: }
Chris@42:
Chris@42: % And just the chapters.
Chris@42: \def\summarycontents{%
Chris@42: \startcontents{\putwordShortTOC}%
Chris@42: %
Chris@42: \let\partentry = \shortpartentry
Chris@42: \let\numchapentry = \shortchapentry
Chris@42: \let\appentry = \shortchapentry
Chris@42: \let\unnchapentry = \shortunnchapentry
Chris@42: % We want a true roman here for the page numbers.
Chris@42: \secfonts
Chris@42: \let\rm=\shortcontrm \let\bf=\shortcontbf
Chris@42: \let\sl=\shortcontsl \let\tt=\shortconttt
Chris@42: \rm
Chris@42: \hyphenpenalty = 10000
Chris@42: \advance\baselineskip by 1pt % Open it up a little.
Chris@42: \def\numsecentry##1##2##3##4{}
Chris@42: \let\appsecentry = \numsecentry
Chris@42: \let\unnsecentry = \numsecentry
Chris@42: \let\numsubsecentry = \numsecentry
Chris@42: \let\appsubsecentry = \numsecentry
Chris@42: \let\unnsubsecentry = \numsecentry
Chris@42: \let\numsubsubsecentry = \numsecentry
Chris@42: \let\appsubsubsecentry = \numsecentry
Chris@42: \let\unnsubsubsecentry = \numsecentry
Chris@42: \openin 1 \tocreadfilename\space
Chris@42: \ifeof 1 \else
Chris@42: \readtocfile
Chris@42: \fi
Chris@42: \closein 1
Chris@42: \vfill \eject
Chris@42: \contentsalignmacro % in case @setchapternewpage odd is in effect
Chris@42: \endgroup
Chris@42: \lastnegativepageno = \pageno
Chris@42: \global\pageno = \savepageno
Chris@42: }
Chris@42: \let\shortcontents = \summarycontents
Chris@42:
Chris@42: % Typeset the label for a chapter or appendix for the short contents.
Chris@42: % The arg is, e.g., `A' for an appendix, or `3' for a chapter.
Chris@42: %
Chris@42: \def\shortchaplabel#1{%
Chris@42: % This space should be enough, since a single number is .5em, and the
Chris@42: % widest letter (M) is 1em, at least in the Computer Modern fonts.
Chris@42: % But use \hss just in case.
Chris@42: % (This space doesn't include the extra space that gets added after
Chris@42: % the label; that gets put in by \shortchapentry above.)
Chris@42: %
Chris@42: % We'd like to right-justify chapter numbers, but that looks strange
Chris@42: % with appendix letters. And right-justifying numbers and
Chris@42: % left-justifying letters looks strange when there is less than 10
Chris@42: % chapters. Have to read the whole toc once to know how many chapters
Chris@42: % there are before deciding ...
Chris@42: \hbox to 1em{#1\hss}%
Chris@42: }
Chris@42:
Chris@42: % These macros generate individual entries in the table of contents.
Chris@42: % The first argument is the chapter or section name.
Chris@42: % The last argument is the page number.
Chris@42: % The arguments in between are the chapter number, section number, ...
Chris@42:
Chris@42: % Parts, in the main contents. Replace the part number, which doesn't
Chris@42: % exist, with an empty box. Let's hope all the numbers have the same width.
Chris@42: % Also ignore the page number, which is conventionally not printed.
Chris@42: \def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}}
Chris@42: \def\partentry#1#2#3#4{\dochapentry{\numeralbox\labelspace#1}{}}
Chris@42: %
Chris@42: % Parts, in the short toc.
Chris@42: \def\shortpartentry#1#2#3#4{%
Chris@42: \penalty-300
Chris@42: \vskip.5\baselineskip plus.15\baselineskip minus.1\baselineskip
Chris@42: \shortchapentry{{\bf #1}}{\numeralbox}{}{}%
Chris@42: }
Chris@42:
Chris@42: % Chapters, in the main contents.
Chris@42: \def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}}
Chris@42: %
Chris@42: % Chapters, in the short toc.
Chris@42: % See comments in \dochapentry re vbox and related settings.
Chris@42: \def\shortchapentry#1#2#3#4{%
Chris@42: \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}%
Chris@42: }
Chris@42:
Chris@42: % Appendices, in the main contents.
Chris@42: % Need the word Appendix, and a fixed-size box.
Chris@42: %
Chris@42: \def\appendixbox#1{%
Chris@42: % We use M since it's probably the widest letter.
Chris@42: \setbox0 = \hbox{\putwordAppendix{} M}%
Chris@42: \hbox to \wd0{\putwordAppendix{} #1\hss}}
Chris@42: %
Chris@42: \def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\labelspace#1}{#4}}
Chris@42:
Chris@42: % Unnumbered chapters.
Chris@42: \def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}}
Chris@42: \def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}}
Chris@42:
Chris@42: % Sections.
Chris@42: \def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}}
Chris@42: \let\appsecentry=\numsecentry
Chris@42: \def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}}
Chris@42:
Chris@42: % Subsections.
Chris@42: \def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}}
Chris@42: \let\appsubsecentry=\numsubsecentry
Chris@42: \def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}}
Chris@42:
Chris@42: % And subsubsections.
Chris@42: \def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}}
Chris@42: \let\appsubsubsecentry=\numsubsubsecentry
Chris@42: \def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}}
Chris@42:
Chris@42: % This parameter controls the indentation of the various levels.
Chris@42: % Same as \defaultparindent.
Chris@42: \newdimen\tocindent \tocindent = 15pt
Chris@42:
Chris@42: % Now for the actual typesetting. In all these, #1 is the text and #2 is the
Chris@42: % page number.
Chris@42: %
Chris@42: % If the toc has to be broken over pages, we want it to be at chapters
Chris@42: % if at all possible; hence the \penalty.
Chris@42: \def\dochapentry#1#2{%
Chris@42: \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip
Chris@42: \begingroup
Chris@42: \chapentryfonts
Chris@42: \tocentry{#1}{\dopageno\bgroup#2\egroup}%
Chris@42: \endgroup
Chris@42: \nobreak\vskip .25\baselineskip plus.1\baselineskip
Chris@42: }
Chris@42:
Chris@42: \def\dosecentry#1#2{\begingroup
Chris@42: \secentryfonts \leftskip=\tocindent
Chris@42: \tocentry{#1}{\dopageno\bgroup#2\egroup}%
Chris@42: \endgroup}
Chris@42:
Chris@42: \def\dosubsecentry#1#2{\begingroup
Chris@42: \subsecentryfonts \leftskip=2\tocindent
Chris@42: \tocentry{#1}{\dopageno\bgroup#2\egroup}%
Chris@42: \endgroup}
Chris@42:
Chris@42: \def\dosubsubsecentry#1#2{\begingroup
Chris@42: \subsubsecentryfonts \leftskip=3\tocindent
Chris@42: \tocentry{#1}{\dopageno\bgroup#2\egroup}%
Chris@42: \endgroup}
Chris@42:
Chris@42: % We use the same \entry macro as for the index entries.
Chris@42: \let\tocentry = \entry
Chris@42:
Chris@42: % Space between chapter (or whatever) number and the title.
Chris@42: \def\labelspace{\hskip1em \relax}
Chris@42:
Chris@42: \def\dopageno#1{{\rm #1}}
Chris@42: \def\doshortpageno#1{{\rm #1}}
Chris@42:
Chris@42: \def\chapentryfonts{\secfonts \rm}
Chris@42: \def\secentryfonts{\textfonts}
Chris@42: \def\subsecentryfonts{\textfonts}
Chris@42: \def\subsubsecentryfonts{\textfonts}
Chris@42:
Chris@42:
Chris@42: \message{environments,}
Chris@42: % @foo ... @end foo.
Chris@42:
Chris@42: % @tex ... @end tex escapes into raw TeX temporarily.
Chris@42: % One exception: @ is still an escape character, so that @end tex works.
Chris@42: % But \@ or @@ will get a plain @ character.
Chris@42:
Chris@42: \envdef\tex{%
Chris@42: \setupmarkupstyle{tex}%
Chris@42: \catcode `\\=0 \catcode `\{=1 \catcode `\}=2
Chris@42: \catcode `\$=3 \catcode `\&=4 \catcode `\#=6
Chris@42: \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie
Chris@42: \catcode `\%=14
Chris@42: \catcode `\+=\other
Chris@42: \catcode `\"=\other
Chris@42: \catcode `\|=\other
Chris@42: \catcode `\<=\other
Chris@42: \catcode `\>=\other
Chris@42: \catcode`\`=\other
Chris@42: \catcode`\'=\other
Chris@42: \escapechar=`\\
Chris@42: %
Chris@42: % ' is active in math mode (mathcode"8000). So reset it, and all our
Chris@42: % other math active characters (just in case), to plain's definitions.
Chris@42: \mathactive
Chris@42: %
Chris@42: \let\b=\ptexb
Chris@42: \let\bullet=\ptexbullet
Chris@42: \let\c=\ptexc
Chris@42: \let\,=\ptexcomma
Chris@42: \let\.=\ptexdot
Chris@42: \let\dots=\ptexdots
Chris@42: \let\equiv=\ptexequiv
Chris@42: \let\!=\ptexexclam
Chris@42: \let\i=\ptexi
Chris@42: \let\indent=\ptexindent
Chris@42: \let\noindent=\ptexnoindent
Chris@42: \let\{=\ptexlbrace
Chris@42: \let\+=\tabalign
Chris@42: \let\}=\ptexrbrace
Chris@42: \let\/=\ptexslash
Chris@42: \let\*=\ptexstar
Chris@42: \let\t=\ptext
Chris@42: \expandafter \let\csname top\endcsname=\ptextop % outer
Chris@42: \let\frenchspacing=\plainfrenchspacing
Chris@42: %
Chris@42: \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}%
Chris@42: \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}%
Chris@42: \def\@{@}%
Chris@42: }
Chris@42: % There is no need to define \Etex.
Chris@42:
Chris@42: % Define @lisp ... @end lisp.
Chris@42: % @lisp environment forms a group so it can rebind things,
Chris@42: % including the definition of @end lisp (which normally is erroneous).
Chris@42:
Chris@42: % Amount to narrow the margins by for @lisp.
Chris@42: \newskip\lispnarrowing \lispnarrowing=0.4in
Chris@42:
Chris@42: % This is the definition that ^^M gets inside @lisp, @example, and other
Chris@42: % such environments. \null is better than a space, since it doesn't
Chris@42: % have any width.
Chris@42: \def\lisppar{\null\endgraf}
Chris@42:
Chris@42: % This space is always present above and below environments.
Chris@42: \newskip\envskipamount \envskipamount = 0pt
Chris@42:
Chris@42: % Make spacing and below environment symmetrical. We use \parskip here
Chris@42: % to help in doing that, since in @example-like environments \parskip
Chris@42: % is reset to zero; thus the \afterenvbreak inserts no space -- but the
Chris@42: % start of the next paragraph will insert \parskip.
Chris@42: %
Chris@42: \def\aboveenvbreak{{%
Chris@42: % =10000 instead of <10000 because of a special case in \itemzzz and
Chris@42: % \sectionheading, q.v.
Chris@42: \ifnum \lastpenalty=10000 \else
Chris@42: \advance\envskipamount by \parskip
Chris@42: \endgraf
Chris@42: \ifdim\lastskip<\envskipamount
Chris@42: \removelastskip
Chris@42: % it's not a good place to break if the last penalty was \nobreak
Chris@42: % or better ...
Chris@42: \ifnum\lastpenalty<10000 \penalty-50 \fi
Chris@42: \vskip\envskipamount
Chris@42: \fi
Chris@42: \fi
Chris@42: }}
Chris@42:
Chris@42: \let\afterenvbreak = \aboveenvbreak
Chris@42:
Chris@42: % \nonarrowing is a flag. If "set", @lisp etc don't narrow margins; it will
Chris@42: % also clear it, so that its embedded environments do the narrowing again.
Chris@42: \let\nonarrowing=\relax
Chris@42:
Chris@42: % @cartouche ... @end cartouche: draw rectangle w/rounded corners around
Chris@42: % environment contents.
Chris@42: \font\circle=lcircle10
Chris@42: \newdimen\circthick
Chris@42: \newdimen\cartouter\newdimen\cartinner
Chris@42: \newskip\normbskip\newskip\normpskip\newskip\normlskip
Chris@42: \circthick=\fontdimen8\circle
Chris@42: %
Chris@42: \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth
Chris@42: \def\ctr{{\hskip 6pt\circle\char'010}}
Chris@42: \def\cbl{{\circle\char'012\hskip -6pt}}
Chris@42: \def\cbr{{\hskip 6pt\circle\char'011}}
Chris@42: \def\carttop{\hbox to \cartouter{\hskip\lskip
Chris@42: \ctl\leaders\hrule height\circthick\hfil\ctr
Chris@42: \hskip\rskip}}
Chris@42: \def\cartbot{\hbox to \cartouter{\hskip\lskip
Chris@42: \cbl\leaders\hrule height\circthick\hfil\cbr
Chris@42: \hskip\rskip}}
Chris@42: %
Chris@42: \newskip\lskip\newskip\rskip
Chris@42:
Chris@42: \envdef\cartouche{%
Chris@42: \ifhmode\par\fi % can't be in the midst of a paragraph.
Chris@42: \startsavinginserts
Chris@42: \lskip=\leftskip \rskip=\rightskip
Chris@42: \leftskip=0pt\rightskip=0pt % we want these *outside*.
Chris@42: \cartinner=\hsize \advance\cartinner by-\lskip
Chris@42: \advance\cartinner by-\rskip
Chris@42: \cartouter=\hsize
Chris@42: \advance\cartouter by 18.4pt % allow for 3pt kerns on either
Chris@42: % side, and for 6pt waste from
Chris@42: % each corner char, and rule thickness
Chris@42: \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip
Chris@42: % Flag to tell @lisp, etc., not to narrow margin.
Chris@42: \let\nonarrowing = t%
Chris@42: %
Chris@42: % If this cartouche directly follows a sectioning command, we need the
Chris@42: % \parskip glue (backspaced over by default) or the cartouche can
Chris@42: % collide with the section heading.
Chris@42: \ifnum\lastpenalty>10000 \vskip\parskip \penalty\lastpenalty \fi
Chris@42: %
Chris@42: \vbox\bgroup
Chris@42: \baselineskip=0pt\parskip=0pt\lineskip=0pt
Chris@42: \carttop
Chris@42: \hbox\bgroup
Chris@42: \hskip\lskip
Chris@42: \vrule\kern3pt
Chris@42: \vbox\bgroup
Chris@42: \kern3pt
Chris@42: \hsize=\cartinner
Chris@42: \baselineskip=\normbskip
Chris@42: \lineskip=\normlskip
Chris@42: \parskip=\normpskip
Chris@42: \vskip -\parskip
Chris@42: \comment % For explanation, see the end of def\group.
Chris@42: }
Chris@42: \def\Ecartouche{%
Chris@42: \ifhmode\par\fi
Chris@42: \kern3pt
Chris@42: \egroup
Chris@42: \kern3pt\vrule
Chris@42: \hskip\rskip
Chris@42: \egroup
Chris@42: \cartbot
Chris@42: \egroup
Chris@42: \checkinserts
Chris@42: }
Chris@42:
Chris@42:
Chris@42: % This macro is called at the beginning of all the @example variants,
Chris@42: % inside a group.
Chris@42: \newdimen\nonfillparindent
Chris@42: \def\nonfillstart{%
Chris@42: \aboveenvbreak
Chris@42: \hfuzz = 12pt % Don't be fussy
Chris@42: \sepspaces % Make spaces be word-separators rather than space tokens.
Chris@42: \let\par = \lisppar % don't ignore blank lines
Chris@42: \obeylines % each line of input is a line of output
Chris@42: \parskip = 0pt
Chris@42: % Turn off paragraph indentation but redefine \indent to emulate
Chris@42: % the normal \indent.
Chris@42: \nonfillparindent=\parindent
Chris@42: \parindent = 0pt
Chris@42: \let\indent\nonfillindent
Chris@42: %
Chris@42: \emergencystretch = 0pt % don't try to avoid overfull boxes
Chris@42: \ifx\nonarrowing\relax
Chris@42: \advance \leftskip by \lispnarrowing
Chris@42: \exdentamount=\lispnarrowing
Chris@42: \else
Chris@42: \let\nonarrowing = \relax
Chris@42: \fi
Chris@42: \let\exdent=\nofillexdent
Chris@42: }
Chris@42:
Chris@42: \begingroup
Chris@42: \obeyspaces
Chris@42: % We want to swallow spaces (but not other tokens) after the fake
Chris@42: % @indent in our nonfill-environments, where spaces are normally
Chris@42: % active and set to @tie, resulting in them not being ignored after
Chris@42: % @indent.
Chris@42: \gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}%
Chris@42: \gdef\nonfillindentcheck{%
Chris@42: \ifx\temp %
Chris@42: \expandafter\nonfillindentgobble%
Chris@42: \else%
Chris@42: \leavevmode\nonfillindentbox%
Chris@42: \fi%
Chris@42: }%
Chris@42: \endgroup
Chris@42: \def\nonfillindentgobble#1{\nonfillindent}
Chris@42: \def\nonfillindentbox{\hbox to \nonfillparindent{\hss}}
Chris@42:
Chris@42: % If you want all examples etc. small: @set dispenvsize small.
Chris@42: % If you want even small examples the full size: @set dispenvsize nosmall.
Chris@42: % This affects the following displayed environments:
Chris@42: % @example, @display, @format, @lisp
Chris@42: %
Chris@42: \def\smallword{small}
Chris@42: \def\nosmallword{nosmall}
Chris@42: \let\SETdispenvsize\relax
Chris@42: \def\setnormaldispenv{%
Chris@42: \ifx\SETdispenvsize\smallword
Chris@42: % end paragraph for sake of leading, in case document has no blank
Chris@42: % line. This is redundant with what happens in \aboveenvbreak, but
Chris@42: % we need to do it before changing the fonts, and it's inconvenient
Chris@42: % to change the fonts afterward.
Chris@42: \ifnum \lastpenalty=10000 \else \endgraf \fi
Chris@42: \smallexamplefonts \rm
Chris@42: \fi
Chris@42: }
Chris@42: \def\setsmalldispenv{%
Chris@42: \ifx\SETdispenvsize\nosmallword
Chris@42: \else
Chris@42: \ifnum \lastpenalty=10000 \else \endgraf \fi
Chris@42: \smallexamplefonts \rm
Chris@42: \fi
Chris@42: }
Chris@42:
Chris@42: % We often define two environments, @foo and @smallfoo.
Chris@42: % Let's do it in one command. #1 is the env name, #2 the definition.
Chris@42: \def\makedispenvdef#1#2{%
Chris@42: \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}%
Chris@42: \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}%
Chris@42: \expandafter\let\csname E#1\endcsname \afterenvbreak
Chris@42: \expandafter\let\csname Esmall#1\endcsname \afterenvbreak
Chris@42: }
Chris@42:
Chris@42: % Define two environment synonyms (#1 and #2) for an environment.
Chris@42: \def\maketwodispenvdef#1#2#3{%
Chris@42: \makedispenvdef{#1}{#3}%
Chris@42: \makedispenvdef{#2}{#3}%
Chris@42: }
Chris@42: %
Chris@42: % @lisp: indented, narrowed, typewriter font;
Chris@42: % @example: same as @lisp.
Chris@42: %
Chris@42: % @smallexample and @smalllisp: use smaller fonts.
Chris@42: % Originally contributed by Pavel@xerox.
Chris@42: %
Chris@42: \maketwodispenvdef{lisp}{example}{%
Chris@42: \nonfillstart
Chris@42: \tt\setupmarkupstyle{example}%
Chris@42: \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special.
Chris@42: \gobble % eat return
Chris@42: }
Chris@42: % @display/@smalldisplay: same as @lisp except keep current font.
Chris@42: %
Chris@42: \makedispenvdef{display}{%
Chris@42: \nonfillstart
Chris@42: \gobble
Chris@42: }
Chris@42:
Chris@42: % @format/@smallformat: same as @display except don't narrow margins.
Chris@42: %
Chris@42: \makedispenvdef{format}{%
Chris@42: \let\nonarrowing = t%
Chris@42: \nonfillstart
Chris@42: \gobble
Chris@42: }
Chris@42:
Chris@42: % @flushleft: same as @format, but doesn't obey \SETdispenvsize.
Chris@42: \envdef\flushleft{%
Chris@42: \let\nonarrowing = t%
Chris@42: \nonfillstart
Chris@42: \gobble
Chris@42: }
Chris@42: \let\Eflushleft = \afterenvbreak
Chris@42:
Chris@42: % @flushright.
Chris@42: %
Chris@42: \envdef\flushright{%
Chris@42: \let\nonarrowing = t%
Chris@42: \nonfillstart
Chris@42: \advance\leftskip by 0pt plus 1fill\relax
Chris@42: \gobble
Chris@42: }
Chris@42: \let\Eflushright = \afterenvbreak
Chris@42:
Chris@42:
Chris@42: % @raggedright does more-or-less normal line breaking but no right
Chris@42: % justification. From plain.tex.
Chris@42: \envdef\raggedright{%
Chris@42: \rightskip0pt plus2em \spaceskip.3333em \xspaceskip.5em\relax
Chris@42: }
Chris@42: \let\Eraggedright\par
Chris@42:
Chris@42: \envdef\raggedleft{%
Chris@42: \parindent=0pt \leftskip0pt plus2em
Chris@42: \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
Chris@42: \hbadness=10000 % Last line will usually be underfull, so turn off
Chris@42: % badness reporting.
Chris@42: }
Chris@42: \let\Eraggedleft\par
Chris@42:
Chris@42: \envdef\raggedcenter{%
Chris@42: \parindent=0pt \rightskip0pt plus1em \leftskip0pt plus1em
Chris@42: \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt
Chris@42: \hbadness=10000 % Last line will usually be underfull, so turn off
Chris@42: % badness reporting.
Chris@42: }
Chris@42: \let\Eraggedcenter\par
Chris@42:
Chris@42:
Chris@42: % @quotation does normal linebreaking (hence we can't use \nonfillstart)
Chris@42: % and narrows the margins. We keep \parskip nonzero in general, since
Chris@42: % we're doing normal filling. So, when using \aboveenvbreak and
Chris@42: % \afterenvbreak, temporarily make \parskip 0.
Chris@42: %
Chris@42: \makedispenvdef{quotation}{\quotationstart}
Chris@42: %
Chris@42: \def\quotationstart{%
Chris@42: \indentedblockstart % same as \indentedblock, but increase right margin too.
Chris@42: \ifx\nonarrowing\relax
Chris@42: \advance\rightskip by \lispnarrowing
Chris@42: \fi
Chris@42: \parsearg\quotationlabel
Chris@42: }
Chris@42:
Chris@42: % We have retained a nonzero parskip for the environment, since we're
Chris@42: % doing normal filling.
Chris@42: %
Chris@42: \def\Equotation{%
Chris@42: \par
Chris@42: \ifx\quotationauthor\thisisundefined\else
Chris@42: % indent a bit.
Chris@42: \leftline{\kern 2\leftskip \sl ---\quotationauthor}%
Chris@42: \fi
Chris@42: {\parskip=0pt \afterenvbreak}%
Chris@42: }
Chris@42: \def\Esmallquotation{\Equotation}
Chris@42:
Chris@42: % If we're given an argument, typeset it in bold with a colon after.
Chris@42: \def\quotationlabel#1{%
Chris@42: \def\temp{#1}%
Chris@42: \ifx\temp\empty \else
Chris@42: {\bf #1: }%
Chris@42: \fi
Chris@42: }
Chris@42:
Chris@42: % @indentedblock is like @quotation, but indents only on the left and
Chris@42: % has no optional argument.
Chris@42: %
Chris@42: \makedispenvdef{indentedblock}{\indentedblockstart}
Chris@42: %
Chris@42: \def\indentedblockstart{%
Chris@42: {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip
Chris@42: \parindent=0pt
Chris@42: %
Chris@42: % @cartouche defines \nonarrowing to inhibit narrowing at next level down.
Chris@42: \ifx\nonarrowing\relax
Chris@42: \advance\leftskip by \lispnarrowing
Chris@42: \exdentamount = \lispnarrowing
Chris@42: \else
Chris@42: \let\nonarrowing = \relax
Chris@42: \fi
Chris@42: }
Chris@42:
Chris@42: % Keep a nonzero parskip for the environment, since we're doing normal filling.
Chris@42: %
Chris@42: \def\Eindentedblock{%
Chris@42: \par
Chris@42: {\parskip=0pt \afterenvbreak}%
Chris@42: }
Chris@42: \def\Esmallindentedblock{\Eindentedblock}
Chris@42:
Chris@42:
Chris@42: % LaTeX-like @verbatim...@end verbatim and @verb{...}
Chris@42: % If we want to allow any as delimiter,
Chris@42: % we need the curly braces so that makeinfo sees the @verb command, eg:
Chris@42: % `@verbx...x' would look like the '@verbx' command. --janneke@gnu.org
Chris@42: %
Chris@42: % [Knuth]: Donald Ervin Knuth, 1996. The TeXbook.
Chris@42: %
Chris@42: % [Knuth] p.344; only we need to do the other characters Texinfo sets
Chris@42: % active too. Otherwise, they get lost as the first character on a
Chris@42: % verbatim line.
Chris@42: \def\dospecials{%
Chris@42: \do\ \do\\\do\{\do\}\do\$\do\&%
Chris@42: \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~%
Chris@42: \do\<\do\>\do\|\do\@\do+\do\"%
Chris@42: % Don't do the quotes -- if we do, @set txicodequoteundirected and
Chris@42: % @set txicodequotebacktick will not have effect on @verb and
Chris@42: % @verbatim, and ?` and !` ligatures won't get disabled.
Chris@42: %\do\`\do\'%
Chris@42: }
Chris@42: %
Chris@42: % [Knuth] p. 380
Chris@42: \def\uncatcodespecials{%
Chris@42: \def\do##1{\catcode`##1=\other}\dospecials}
Chris@42: %
Chris@42: % Setup for the @verb command.
Chris@42: %
Chris@42: % Eight spaces for a tab
Chris@42: \begingroup
Chris@42: \catcode`\^^I=\active
Chris@42: \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }}
Chris@42: \endgroup
Chris@42: %
Chris@42: \def\setupverb{%
Chris@42: \tt % easiest (and conventionally used) font for verbatim
Chris@42: \def\par{\leavevmode\endgraf}%
Chris@42: \setupmarkupstyle{verb}%
Chris@42: \tabeightspaces
Chris@42: % Respect line breaks,
Chris@42: % print special symbols as themselves, and
Chris@42: % make each space count
Chris@42: % must do in this order:
Chris@42: \obeylines \uncatcodespecials \sepspaces
Chris@42: }
Chris@42:
Chris@42: % Setup for the @verbatim environment
Chris@42: %
Chris@42: % Real tab expansion.
Chris@42: \newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount
Chris@42: %
Chris@42: % We typeset each line of the verbatim in an \hbox, so we can handle
Chris@42: % tabs. The \global is in case the verbatim line starts with an accent,
Chris@42: % or some other command that starts with a begin-group. Otherwise, the
Chris@42: % entire \verbbox would disappear at the corresponding end-group, before
Chris@42: % it is typeset. Meanwhile, we can't have nested verbatim commands
Chris@42: % (can we?), so the \global won't be overwriting itself.
Chris@42: \newbox\verbbox
Chris@42: \def\starttabbox{\global\setbox\verbbox=\hbox\bgroup}
Chris@42: %
Chris@42: \begingroup
Chris@42: \catcode`\^^I=\active
Chris@42: \gdef\tabexpand{%
Chris@42: \catcode`\^^I=\active
Chris@42: \def^^I{\leavevmode\egroup
Chris@42: \dimen\verbbox=\wd\verbbox % the width so far, or since the previous tab
Chris@42: \divide\dimen\verbbox by\tabw
Chris@42: \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw
Chris@42: \advance\dimen\verbbox by\tabw % advance to next multiple of \tabw
Chris@42: \wd\verbbox=\dimen\verbbox \box\verbbox \starttabbox
Chris@42: }%
Chris@42: }
Chris@42: \endgroup
Chris@42:
Chris@42: % start the verbatim environment.
Chris@42: \def\setupverbatim{%
Chris@42: \let\nonarrowing = t%
Chris@42: \nonfillstart
Chris@42: \tt % easiest (and conventionally used) font for verbatim
Chris@42: % The \leavevmode here is for blank lines. Otherwise, we would
Chris@42: % never \starttabox and the \egroup would end verbatim mode.
Chris@42: \def\par{\leavevmode\egroup\box\verbbox\endgraf}%
Chris@42: \tabexpand
Chris@42: \setupmarkupstyle{verbatim}%
Chris@42: % Respect line breaks,
Chris@42: % print special symbols as themselves, and
Chris@42: % make each space count.
Chris@42: % Must do in this order:
Chris@42: \obeylines \uncatcodespecials \sepspaces
Chris@42: \everypar{\starttabbox}%
Chris@42: }
Chris@42:
Chris@42: % Do the @verb magic: verbatim text is quoted by unique
Chris@42: % delimiter characters. Before first delimiter expect a
Chris@42: % right brace, after last delimiter expect closing brace:
Chris@42: %
Chris@42: % \def\doverb'{'#1'}'{#1}
Chris@42: %
Chris@42: % [Knuth] p. 382; only eat outer {}
Chris@42: \begingroup
Chris@42: \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other
Chris@42: \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next]
Chris@42: \endgroup
Chris@42: %
Chris@42: \def\verb{\begingroup\setupverb\doverb}
Chris@42: %
Chris@42: %
Chris@42: % Do the @verbatim magic: define the macro \doverbatim so that
Chris@42: % the (first) argument ends when '@end verbatim' is reached, ie:
Chris@42: %
Chris@42: % \def\doverbatim#1@end verbatim{#1}
Chris@42: %
Chris@42: % For Texinfo it's a lot easier than for LaTeX,
Chris@42: % because texinfo's \verbatim doesn't stop at '\end{verbatim}':
Chris@42: % we need not redefine '\', '{' and '}'.
Chris@42: %
Chris@42: % Inspired by LaTeX's verbatim command set [latex.ltx]
Chris@42: %
Chris@42: \begingroup
Chris@42: \catcode`\ =\active
Chris@42: \obeylines %
Chris@42: % ignore everything up to the first ^^M, that's the newline at the end
Chris@42: % of the @verbatim input line itself. Otherwise we get an extra blank
Chris@42: % line in the output.
Chris@42: \xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}%
Chris@42: % We really want {...\end verbatim} in the body of the macro, but
Chris@42: % without the active space; thus we have to use \xdef and \gobble.
Chris@42: \endgroup
Chris@42: %
Chris@42: \envdef\verbatim{%
Chris@42: \setupverbatim\doverbatim
Chris@42: }
Chris@42: \let\Everbatim = \afterenvbreak
Chris@42:
Chris@42:
Chris@42: % @verbatiminclude FILE - insert text of file in verbatim environment.
Chris@42: %
Chris@42: \def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude}
Chris@42: %
Chris@42: \def\doverbatiminclude#1{%
Chris@42: {%
Chris@42: \makevalueexpandable
Chris@42: \setupverbatim
Chris@42: \indexnofonts % Allow `@@' and other weird things in file names.
Chris@42: \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}%
Chris@42: \input #1
Chris@42: \afterenvbreak
Chris@42: }%
Chris@42: }
Chris@42:
Chris@42: % @copying ... @end copying.
Chris@42: % Save the text away for @insertcopying later.
Chris@42: %
Chris@42: % We save the uninterpreted tokens, rather than creating a box.
Chris@42: % Saving the text in a box would be much easier, but then all the
Chris@42: % typesetting commands (@smallbook, font changes, etc.) have to be done
Chris@42: % beforehand -- and a) we want @copying to be done first in the source
Chris@42: % file; b) letting users define the frontmatter in as flexible order as
Chris@42: % possible is very desirable.
Chris@42: %
Chris@42: \def\copying{\checkenv{}\begingroup\scanargctxt\docopying}
Chris@42: \def\docopying#1@end copying{\endgroup\def\copyingtext{#1}}
Chris@42: %
Chris@42: \def\insertcopying{%
Chris@42: \begingroup
Chris@42: \parindent = 0pt % paragraph indentation looks wrong on title page
Chris@42: \scanexp\copyingtext
Chris@42: \endgroup
Chris@42: }
Chris@42:
Chris@42:
Chris@42: \message{defuns,}
Chris@42: % @defun etc.
Chris@42:
Chris@42: \newskip\defbodyindent \defbodyindent=.4in
Chris@42: \newskip\defargsindent \defargsindent=50pt
Chris@42: \newskip\deflastargmargin \deflastargmargin=18pt
Chris@42: \newcount\defunpenalty
Chris@42:
Chris@42: % Start the processing of @deffn:
Chris@42: \def\startdefun{%
Chris@42: \ifnum\lastpenalty<10000
Chris@42: \medbreak
Chris@42: \defunpenalty=10003 % Will keep this @deffn together with the
Chris@42: % following @def command, see below.
Chris@42: \else
Chris@42: % If there are two @def commands in a row, we'll have a \nobreak,
Chris@42: % which is there to keep the function description together with its
Chris@42: % header. But if there's nothing but headers, we need to allow a
Chris@42: % break somewhere. Check specifically for penalty 10002, inserted
Chris@42: % by \printdefunline, instead of 10000, since the sectioning
Chris@42: % commands also insert a nobreak penalty, and we don't want to allow
Chris@42: % a break between a section heading and a defun.
Chris@42: %
Chris@42: % As a further refinement, we avoid "club" headers by signalling
Chris@42: % with penalty of 10003 after the very first @deffn in the
Chris@42: % sequence (see above), and penalty of 10002 after any following
Chris@42: % @def command.
Chris@42: \ifnum\lastpenalty=10002 \penalty2000 \else \defunpenalty=10002 \fi
Chris@42: %
Chris@42: % Similarly, after a section heading, do not allow a break.
Chris@42: % But do insert the glue.
Chris@42: \medskip % preceded by discardable penalty, so not a breakpoint
Chris@42: \fi
Chris@42: %
Chris@42: \parindent=0in
Chris@42: \advance\leftskip by \defbodyindent
Chris@42: \exdentamount=\defbodyindent
Chris@42: }
Chris@42:
Chris@42: \def\dodefunx#1{%
Chris@42: % First, check whether we are in the right environment:
Chris@42: \checkenv#1%
Chris@42: %
Chris@42: % As above, allow line break if we have multiple x headers in a row.
Chris@42: % It's not a great place, though.
Chris@42: \ifnum\lastpenalty=10002 \penalty3000 \else \defunpenalty=10002 \fi
Chris@42: %
Chris@42: % And now, it's time to reuse the body of the original defun:
Chris@42: \expandafter\gobbledefun#1%
Chris@42: }
Chris@42: \def\gobbledefun#1\startdefun{}
Chris@42:
Chris@42: % \printdefunline \deffnheader{text}
Chris@42: %
Chris@42: \def\printdefunline#1#2{%
Chris@42: \begingroup
Chris@42: % call \deffnheader:
Chris@42: #1#2 \endheader
Chris@42: % common ending:
Chris@42: \interlinepenalty = 10000
Chris@42: \advance\rightskip by 0pt plus 1fil\relax
Chris@42: \endgraf
Chris@42: \nobreak\vskip -\parskip
Chris@42: \penalty\defunpenalty % signal to \startdefun and \dodefunx
Chris@42: % Some of the @defun-type tags do not enable magic parentheses,
Chris@42: % rendering the following check redundant. But we don't optimize.
Chris@42: \checkparencounts
Chris@42: \endgroup
Chris@42: }
Chris@42:
Chris@42: \def\Edefun{\endgraf\medbreak}
Chris@42:
Chris@42: % \makedefun{deffn} creates \deffn, \deffnx and \Edeffn;
Chris@42: % the only thing remaining is to define \deffnheader.
Chris@42: %
Chris@42: \def\makedefun#1{%
Chris@42: \expandafter\let\csname E#1\endcsname = \Edefun
Chris@42: \edef\temp{\noexpand\domakedefun
Chris@42: \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}%
Chris@42: \temp
Chris@42: }
Chris@42:
Chris@42: % \domakedefun \deffn \deffnx \deffnheader
Chris@42: %
Chris@42: % Define \deffn and \deffnx, without parameters.
Chris@42: % \deffnheader has to be defined explicitly.
Chris@42: %
Chris@42: \def\domakedefun#1#2#3{%
Chris@42: \envdef#1{%
Chris@42: \startdefun
Chris@42: \doingtypefnfalse % distinguish typed functions from all else
Chris@42: \parseargusing\activeparens{\printdefunline#3}%
Chris@42: }%
Chris@42: \def#2{\dodefunx#1}%
Chris@42: \def#3%
Chris@42: }
Chris@42:
Chris@42: \newif\ifdoingtypefn % doing typed function?
Chris@42: \newif\ifrettypeownline % typeset return type on its own line?
Chris@42:
Chris@42: % @deftypefnnewline on|off says whether the return type of typed functions
Chris@42: % are printed on their own line. This affects @deftypefn, @deftypefun,
Chris@42: % @deftypeop, and @deftypemethod.
Chris@42: %
Chris@42: \parseargdef\deftypefnnewline{%
Chris@42: \def\temp{#1}%
Chris@42: \ifx\temp\onword
Chris@42: \expandafter\let\csname SETtxideftypefnnl\endcsname
Chris@42: = \empty
Chris@42: \else\ifx\temp\offword
Chris@42: \expandafter\let\csname SETtxideftypefnnl\endcsname
Chris@42: = \relax
Chris@42: \else
Chris@42: \errhelp = \EMsimple
Chris@42: \errmessage{Unknown @txideftypefnnl value `\temp',
Chris@42: must be on|off}%
Chris@42: \fi\fi
Chris@42: }
Chris@42:
Chris@42: % Untyped functions:
Chris@42:
Chris@42: % @deffn category name args
Chris@42: \makedefun{deffn}{\deffngeneral{}}
Chris@42:
Chris@42: % @deffn category class name args
Chris@42: \makedefun{defop}#1 {\defopon{#1\ \putwordon}}
Chris@42:
Chris@42: % \defopon {category on}class name args
Chris@42: \def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
Chris@42:
Chris@42: % \deffngeneral {subind}category name args
Chris@42: %
Chris@42: \def\deffngeneral#1#2 #3 #4\endheader{%
Chris@42: % Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}.
Chris@42: \dosubind{fn}{\code{#3}}{#1}%
Chris@42: \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}%
Chris@42: }
Chris@42:
Chris@42: % Typed functions:
Chris@42:
Chris@42: % @deftypefn category type name args
Chris@42: \makedefun{deftypefn}{\deftypefngeneral{}}
Chris@42:
Chris@42: % @deftypeop category class type name args
Chris@42: \makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}}
Chris@42:
Chris@42: % \deftypeopon {category on}class type name args
Chris@42: \def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} }
Chris@42:
Chris@42: % \deftypefngeneral {subind}category type name args
Chris@42: %
Chris@42: \def\deftypefngeneral#1#2 #3 #4 #5\endheader{%
Chris@42: \dosubind{fn}{\code{#4}}{#1}%
Chris@42: \doingtypefntrue
Chris@42: \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
Chris@42: }
Chris@42:
Chris@42: % Typed variables:
Chris@42:
Chris@42: % @deftypevr category type var args
Chris@42: \makedefun{deftypevr}{\deftypecvgeneral{}}
Chris@42:
Chris@42: % @deftypecv category class type var args
Chris@42: \makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}}
Chris@42:
Chris@42: % \deftypecvof {category of}class type var args
Chris@42: \def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} }
Chris@42:
Chris@42: % \deftypecvgeneral {subind}category type var args
Chris@42: %
Chris@42: \def\deftypecvgeneral#1#2 #3 #4 #5\endheader{%
Chris@42: \dosubind{vr}{\code{#4}}{#1}%
Chris@42: \defname{#2}{#3}{#4}\defunargs{#5\unskip}%
Chris@42: }
Chris@42:
Chris@42: % Untyped variables:
Chris@42:
Chris@42: % @defvr category var args
Chris@42: \makedefun{defvr}#1 {\deftypevrheader{#1} {} }
Chris@42:
Chris@42: % @defcv category class var args
Chris@42: \makedefun{defcv}#1 {\defcvof{#1\ \putwordof}}
Chris@42:
Chris@42: % \defcvof {category of}class var args
Chris@42: \def\defcvof#1#2 {\deftypecvof{#1}#2 {} }
Chris@42:
Chris@42: % Types:
Chris@42:
Chris@42: % @deftp category name args
Chris@42: \makedefun{deftp}#1 #2 #3\endheader{%
Chris@42: \doind{tp}{\code{#2}}%
Chris@42: \defname{#1}{}{#2}\defunargs{#3\unskip}%
Chris@42: }
Chris@42:
Chris@42: % Remaining @defun-like shortcuts:
Chris@42: \makedefun{defun}{\deffnheader{\putwordDeffunc} }
Chris@42: \makedefun{defmac}{\deffnheader{\putwordDefmac} }
Chris@42: \makedefun{defspec}{\deffnheader{\putwordDefspec} }
Chris@42: \makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} }
Chris@42: \makedefun{defvar}{\defvrheader{\putwordDefvar} }
Chris@42: \makedefun{defopt}{\defvrheader{\putwordDefopt} }
Chris@42: \makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} }
Chris@42: \makedefun{defmethod}{\defopon\putwordMethodon}
Chris@42: \makedefun{deftypemethod}{\deftypeopon\putwordMethodon}
Chris@42: \makedefun{defivar}{\defcvof\putwordInstanceVariableof}
Chris@42: \makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof}
Chris@42:
Chris@42: % \defname, which formats the name of the @def (not the args).
Chris@42: % #1 is the category, such as "Function".
Chris@42: % #2 is the return type, if any.
Chris@42: % #3 is the function name.
Chris@42: %
Chris@42: % We are followed by (but not passed) the arguments, if any.
Chris@42: %
Chris@42: \def\defname#1#2#3{%
Chris@42: \par
Chris@42: % Get the values of \leftskip and \rightskip as they were outside the @def...
Chris@42: \advance\leftskip by -\defbodyindent
Chris@42: %
Chris@42: % Determine if we are typesetting the return type of a typed function
Chris@42: % on a line by itself.
Chris@42: \rettypeownlinefalse
Chris@42: \ifdoingtypefn % doing a typed function specifically?
Chris@42: % then check user option for putting return type on its own line:
Chris@42: \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else
Chris@42: \rettypeownlinetrue
Chris@42: \fi
Chris@42: \fi
Chris@42: %
Chris@42: % How we'll format the category name. Putting it in brackets helps
Chris@42: % distinguish it from the body text that may end up on the next line
Chris@42: % just below it.
Chris@42: \def\temp{#1}%
Chris@42: \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi}
Chris@42: %
Chris@42: % Figure out line sizes for the paragraph shape. We'll always have at
Chris@42: % least two.
Chris@42: \tempnum = 2
Chris@42: %
Chris@42: % The first line needs space for \box0; but if \rightskip is nonzero,
Chris@42: % we need only space for the part of \box0 which exceeds it:
Chris@42: \dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip
Chris@42: %
Chris@42: % If doing a return type on its own line, we'll have another line.
Chris@42: \ifrettypeownline
Chris@42: \advance\tempnum by 1
Chris@42: \def\maybeshapeline{0in \hsize}%
Chris@42: \else
Chris@42: \def\maybeshapeline{}%
Chris@42: \fi
Chris@42: %
Chris@42: % The continuations:
Chris@42: \dimen2=\hsize \advance\dimen2 by -\defargsindent
Chris@42: %
Chris@42: % The final paragraph shape:
Chris@42: \parshape \tempnum 0in \dimen0 \maybeshapeline \defargsindent \dimen2
Chris@42: %
Chris@42: % Put the category name at the right margin.
Chris@42: \noindent
Chris@42: \hbox to 0pt{%
Chris@42: \hfil\box0 \kern-\hsize
Chris@42: % \hsize has to be shortened this way:
Chris@42: \kern\leftskip
Chris@42: % Intentionally do not respect \rightskip, since we need the space.
Chris@42: }%
Chris@42: %
Chris@42: % Allow all lines to be underfull without complaint:
Chris@42: \tolerance=10000 \hbadness=10000
Chris@42: \exdentamount=\defbodyindent
Chris@42: {%
Chris@42: % defun fonts. We use typewriter by default (used to be bold) because:
Chris@42: % . we're printing identifiers, they should be in tt in principle.
Chris@42: % . in languages with many accents, such as Czech or French, it's
Chris@42: % common to leave accents off identifiers. The result looks ok in
Chris@42: % tt, but exceedingly strange in rm.
Chris@42: % . we don't want -- and --- to be treated as ligatures.
Chris@42: % . this still does not fix the ?` and !` ligatures, but so far no
Chris@42: % one has made identifiers using them :).
Chris@42: \df \tt
Chris@42: \def\temp{#2}% text of the return type
Chris@42: \ifx\temp\empty\else
Chris@42: \tclose{\temp}% typeset the return type
Chris@42: \ifrettypeownline
Chris@42: % put return type on its own line; prohibit line break following:
Chris@42: \hfil\vadjust{\nobreak}\break
Chris@42: \else
Chris@42: \space % type on same line, so just followed by a space
Chris@42: \fi
Chris@42: \fi % no return type
Chris@42: #3% output function name
Chris@42: }%
Chris@42: {\rm\enskip}% hskip 0.5 em of \tenrm
Chris@42: %
Chris@42: \boldbrax
Chris@42: % arguments will be output next, if any.
Chris@42: }
Chris@42:
Chris@42: % Print arguments in slanted roman (not ttsl), inconsistently with using
Chris@42: % tt for the name. This is because literal text is sometimes needed in
Chris@42: % the argument list (groff manual), and ttsl and tt are not very
Chris@42: % distinguishable. Prevent hyphenation at `-' chars.
Chris@42: %
Chris@42: \def\defunargs#1{%
Chris@42: % use sl by default (not ttsl),
Chris@42: % tt for the names.
Chris@42: \df \sl \hyphenchar\font=0
Chris@42: %
Chris@42: % On the other hand, if an argument has two dashes (for instance), we
Chris@42: % want a way to get ttsl. We used to recommend @var for that, so
Chris@42: % leave the code in, but it's strange for @var to lead to typewriter.
Chris@42: % Nowadays we recommend @code, since the difference between a ttsl hyphen
Chris@42: % and a tt hyphen is pretty tiny. @code also disables ?` !`.
Chris@42: \def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}%
Chris@42: #1%
Chris@42: \sl\hyphenchar\font=45
Chris@42: }
Chris@42:
Chris@42: % We want ()&[] to print specially on the defun line.
Chris@42: %
Chris@42: \def\activeparens{%
Chris@42: \catcode`\(=\active \catcode`\)=\active
Chris@42: \catcode`\[=\active \catcode`\]=\active
Chris@42: \catcode`\&=\active
Chris@42: }
Chris@42:
Chris@42: % Make control sequences which act like normal parenthesis chars.
Chris@42: \let\lparen = ( \let\rparen = )
Chris@42:
Chris@42: % Be sure that we always have a definition for `(', etc. For example,
Chris@42: % if the fn name has parens in it, \boldbrax will not be in effect yet,
Chris@42: % so TeX would otherwise complain about undefined control sequence.
Chris@42: {
Chris@42: \activeparens
Chris@42: \global\let(=\lparen \global\let)=\rparen
Chris@42: \global\let[=\lbrack \global\let]=\rbrack
Chris@42: \global\let& = \&
Chris@42:
Chris@42: \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb}
Chris@42: \gdef\magicamp{\let&=\amprm}
Chris@42: }
Chris@42:
Chris@42: \newcount\parencount
Chris@42:
Chris@42: % If we encounter &foo, then turn on ()-hacking afterwards
Chris@42: \newif\ifampseen
Chris@42: \def\amprm#1 {\ampseentrue{\bf\ }}
Chris@42:
Chris@42: \def\parenfont{%
Chris@42: \ifampseen
Chris@42: % At the first level, print parens in roman,
Chris@42: % otherwise use the default font.
Chris@42: \ifnum \parencount=1 \rm \fi
Chris@42: \else
Chris@42: % The \sf parens (in \boldbrax) actually are a little bolder than
Chris@42: % the contained text. This is especially needed for [ and ] .
Chris@42: \sf
Chris@42: \fi
Chris@42: }
Chris@42: \def\infirstlevel#1{%
Chris@42: \ifampseen
Chris@42: \ifnum\parencount=1
Chris@42: #1%
Chris@42: \fi
Chris@42: \fi
Chris@42: }
Chris@42: \def\bfafterword#1 {#1 \bf}
Chris@42:
Chris@42: \def\opnr{%
Chris@42: \global\advance\parencount by 1
Chris@42: {\parenfont(}%
Chris@42: \infirstlevel \bfafterword
Chris@42: }
Chris@42: \def\clnr{%
Chris@42: {\parenfont)}%
Chris@42: \infirstlevel \sl
Chris@42: \global\advance\parencount by -1
Chris@42: }
Chris@42:
Chris@42: \newcount\brackcount
Chris@42: \def\lbrb{%
Chris@42: \global\advance\brackcount by 1
Chris@42: {\bf[}%
Chris@42: }
Chris@42: \def\rbrb{%
Chris@42: {\bf]}%
Chris@42: \global\advance\brackcount by -1
Chris@42: }
Chris@42:
Chris@42: \def\checkparencounts{%
Chris@42: \ifnum\parencount=0 \else \badparencount \fi
Chris@42: \ifnum\brackcount=0 \else \badbrackcount \fi
Chris@42: }
Chris@42: % these should not use \errmessage; the glibc manual, at least, actually
Chris@42: % has such constructs (when documenting function pointers).
Chris@42: \def\badparencount{%
Chris@42: \message{Warning: unbalanced parentheses in @def...}%
Chris@42: \global\parencount=0
Chris@42: }
Chris@42: \def\badbrackcount{%
Chris@42: \message{Warning: unbalanced square brackets in @def...}%
Chris@42: \global\brackcount=0
Chris@42: }
Chris@42:
Chris@42:
Chris@42: \message{macros,}
Chris@42: % @macro.
Chris@42:
Chris@42: % To do this right we need a feature of e-TeX, \scantokens,
Chris@42: % which we arrange to emulate with a temporary file in ordinary TeX.
Chris@42: \ifx\eTeXversion\thisisundefined
Chris@42: \newwrite\macscribble
Chris@42: \def\scantokens#1{%
Chris@42: \toks0={#1}%
Chris@42: \immediate\openout\macscribble=\jobname.tmp
Chris@42: \immediate\write\macscribble{\the\toks0}%
Chris@42: \immediate\closeout\macscribble
Chris@42: \input \jobname.tmp
Chris@42: }
Chris@42: \fi
Chris@42:
Chris@42: \def\scanmacro#1{\begingroup
Chris@42: \newlinechar`\^^M
Chris@42: \let\xeatspaces\eatspaces
Chris@42: %
Chris@42: % Undo catcode changes of \startcontents and \doprintindex
Chris@42: % When called from @insertcopying or (short)caption, we need active
Chris@42: % backslash to get it printed correctly. Previously, we had
Chris@42: % \catcode`\\=\other instead. We'll see whether a problem appears
Chris@42: % with macro expansion. --kasal, 19aug04
Chris@42: \catcode`\@=0 \catcode`\\=\active \escapechar=`\@
Chris@42: %
Chris@42: % ... and for \example:
Chris@42: \spaceisspace
Chris@42: %
Chris@42: % The \empty here causes a following catcode 5 newline to be eaten as
Chris@42: % part of reading whitespace after a control sequence. It does not
Chris@42: % eat a catcode 13 newline. There's no good way to handle the two
Chris@42: % cases (untried: maybe e-TeX's \everyeof could help, though plain TeX
Chris@42: % would then have different behavior). See the Macro Details node in
Chris@42: % the manual for the workaround we recommend for macros and
Chris@42: % line-oriented commands.
Chris@42: %
Chris@42: \scantokens{#1\empty}%
Chris@42: \endgroup}
Chris@42:
Chris@42: \def\scanexp#1{%
Chris@42: \edef\temp{\noexpand\scanmacro{#1}}%
Chris@42: \temp
Chris@42: }
Chris@42:
Chris@42: \newcount\paramno % Count of parameters
Chris@42: \newtoks\macname % Macro name
Chris@42: \newif\ifrecursive % Is it recursive?
Chris@42:
Chris@42: % List of all defined macros in the form
Chris@42: % \definedummyword\macro1\definedummyword\macro2...
Chris@42: % Currently is also contains all @aliases; the list can be split
Chris@42: % if there is a need.
Chris@42: \def\macrolist{}
Chris@42:
Chris@42: % Add the macro to \macrolist
Chris@42: \def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname}
Chris@42: \def\addtomacrolistxxx#1{%
Chris@42: \toks0 = \expandafter{\macrolist\definedummyword#1}%
Chris@42: \xdef\macrolist{\the\toks0}%
Chris@42: }
Chris@42:
Chris@42: % Utility routines.
Chris@42: % This does \let #1 = #2, with \csnames; that is,
Chris@42: % \let \csname#1\endcsname = \csname#2\endcsname
Chris@42: % (except of course we have to play expansion games).
Chris@42: %
Chris@42: \def\cslet#1#2{%
Chris@42: \expandafter\let
Chris@42: \csname#1\expandafter\endcsname
Chris@42: \csname#2\endcsname
Chris@42: }
Chris@42:
Chris@42: % Trim leading and trailing spaces off a string.
Chris@42: % Concepts from aro-bend problem 15 (see CTAN).
Chris@42: {\catcode`\@=11
Chris@42: \gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }}
Chris@42: \gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@}
Chris@42: \gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @}
Chris@42: \def\unbrace#1{#1}
Chris@42: \unbrace{\gdef\trim@@@ #1 } #2@{#1}
Chris@42: }
Chris@42:
Chris@42: % Trim a single trailing ^^M off a string.
Chris@42: {\catcode`\^^M=\other \catcode`\Q=3%
Chris@42: \gdef\eatcr #1{\eatcra #1Q^^MQ}%
Chris@42: \gdef\eatcra#1^^MQ{\eatcrb#1Q}%
Chris@42: \gdef\eatcrb#1Q#2Q{#1}%
Chris@42: }
Chris@42:
Chris@42: % Macro bodies are absorbed as an argument in a context where
Chris@42: % all characters are catcode 10, 11 or 12, except \ which is active
Chris@42: % (as in normal texinfo). It is necessary to change the definition of \
Chris@42: % to recognize macro arguments; this is the job of \mbodybackslash.
Chris@42: %
Chris@42: % Non-ASCII encodings make 8-bit characters active, so un-activate
Chris@42: % them to avoid their expansion. Must do this non-globally, to
Chris@42: % confine the change to the current group.
Chris@42: %
Chris@42: % It's necessary to have hard CRs when the macro is executed. This is
Chris@42: % done by making ^^M (\endlinechar) catcode 12 when reading the macro
Chris@42: % body, and then making it the \newlinechar in \scanmacro.
Chris@42: %
Chris@42: \def\scanctxt{% used as subroutine
Chris@42: \catcode`\"=\other
Chris@42: \catcode`\+=\other
Chris@42: \catcode`\<=\other
Chris@42: \catcode`\>=\other
Chris@42: \catcode`\@=\other
Chris@42: \catcode`\^=\other
Chris@42: \catcode`\_=\other
Chris@42: \catcode`\|=\other
Chris@42: \catcode`\~=\other
Chris@42: \ifx\declaredencoding\ascii \else \setnonasciicharscatcodenonglobal\other \fi
Chris@42: }
Chris@42:
Chris@42: \def\scanargctxt{% used for copying and captions, not macros.
Chris@42: \scanctxt
Chris@42: \catcode`\\=\other
Chris@42: \catcode`\^^M=\other
Chris@42: }
Chris@42:
Chris@42: \def\macrobodyctxt{% used for @macro definitions
Chris@42: \scanctxt
Chris@42: \catcode`\{=\other
Chris@42: \catcode`\}=\other
Chris@42: \catcode`\^^M=\other
Chris@42: \usembodybackslash
Chris@42: }
Chris@42:
Chris@42: \def\macroargctxt{% used when scanning invocations
Chris@42: \scanctxt
Chris@42: \catcode`\\=0
Chris@42: }
Chris@42: % why catcode 0 for \ in the above? To recognize \\ \{ \} as "escapes"
Chris@42: % for the single characters \ { }. Thus, we end up with the "commands"
Chris@42: % that would be written @\ @{ @} in a Texinfo document.
Chris@42: %
Chris@42: % We already have @{ and @}. For @\, we define it here, and only for
Chris@42: % this purpose, to produce a typewriter backslash (so, the @\ that we
Chris@42: % define for @math can't be used with @macro calls):
Chris@42: %
Chris@42: \def\\{\normalbackslash}%
Chris@42: %
Chris@42: % We would like to do this for \, too, since that is what makeinfo does.
Chris@42: % But it is not possible, because Texinfo already has a command @, for a
Chris@42: % cedilla accent. Documents must use @comma{} instead.
Chris@42: %
Chris@42: % \anythingelse will almost certainly be an error of some kind.
Chris@42:
Chris@42:
Chris@42: % \mbodybackslash is the definition of \ in @macro bodies.
Chris@42: % It maps \foo\ => \csname macarg.foo\endcsname => #N
Chris@42: % where N is the macro parameter number.
Chris@42: % We define \csname macarg.\endcsname to be \realbackslash, so
Chris@42: % \\ in macro replacement text gets you a backslash.
Chris@42: %
Chris@42: {\catcode`@=0 @catcode`@\=@active
Chris@42: @gdef@usembodybackslash{@let\=@mbodybackslash}
Chris@42: @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname}
Chris@42: }
Chris@42: \expandafter\def\csname macarg.\endcsname{\realbackslash}
Chris@42:
Chris@42: \def\margbackslash#1{\char`\#1 }
Chris@42:
Chris@42: \def\macro{\recursivefalse\parsearg\macroxxx}
Chris@42: \def\rmacro{\recursivetrue\parsearg\macroxxx}
Chris@42:
Chris@42: \def\macroxxx#1{%
Chris@42: \getargs{#1}% now \macname is the macname and \argl the arglist
Chris@42: \ifx\argl\empty % no arguments
Chris@42: \paramno=0\relax
Chris@42: \else
Chris@42: \expandafter\parsemargdef \argl;%
Chris@42: \if\paramno>256\relax
Chris@42: \ifx\eTeXversion\thisisundefined
Chris@42: \errhelp = \EMsimple
Chris@42: \errmessage{You need eTeX to compile a file with macros with more than 256 arguments}
Chris@42: \fi
Chris@42: \fi
Chris@42: \fi
Chris@42: \if1\csname ismacro.\the\macname\endcsname
Chris@42: \message{Warning: redefining \the\macname}%
Chris@42: \else
Chris@42: \expandafter\ifx\csname \the\macname\endcsname \relax
Chris@42: \else \errmessage{Macro name \the\macname\space already defined}\fi
Chris@42: \global\cslet{macsave.\the\macname}{\the\macname}%
Chris@42: \global\expandafter\let\csname ismacro.\the\macname\endcsname=1%
Chris@42: \addtomacrolist{\the\macname}%
Chris@42: \fi
Chris@42: \begingroup \macrobodyctxt
Chris@42: \ifrecursive \expandafter\parsermacbody
Chris@42: \else \expandafter\parsemacbody
Chris@42: \fi}
Chris@42:
Chris@42: \parseargdef\unmacro{%
Chris@42: \if1\csname ismacro.#1\endcsname
Chris@42: \global\cslet{#1}{macsave.#1}%
Chris@42: \global\expandafter\let \csname ismacro.#1\endcsname=0%
Chris@42: % Remove the macro name from \macrolist:
Chris@42: \begingroup
Chris@42: \expandafter\let\csname#1\endcsname \relax
Chris@42: \let\definedummyword\unmacrodo
Chris@42: \xdef\macrolist{\macrolist}%
Chris@42: \endgroup
Chris@42: \else
Chris@42: \errmessage{Macro #1 not defined}%
Chris@42: \fi
Chris@42: }
Chris@42:
Chris@42: % Called by \do from \dounmacro on each macro. The idea is to omit any
Chris@42: % macro definitions that have been changed to \relax.
Chris@42: %
Chris@42: \def\unmacrodo#1{%
Chris@42: \ifx #1\relax
Chris@42: % remove this
Chris@42: \else
Chris@42: \noexpand\definedummyword \noexpand#1%
Chris@42: \fi
Chris@42: }
Chris@42:
Chris@42: % This makes use of the obscure feature that if the last token of a
Chris@42: % is #, then the preceding argument is delimited by
Chris@42: % an opening brace, and that opening brace is not consumed.
Chris@42: \def\getargs#1{\getargsxxx#1{}}
Chris@42: \def\getargsxxx#1#{\getmacname #1 \relax\getmacargs}
Chris@42: \def\getmacname#1 #2\relax{\macname={#1}}
Chris@42: \def\getmacargs#1{\def\argl{#1}}
Chris@42:
Chris@42: % For macro processing make @ a letter so that we can make Texinfo private macro names.
Chris@42: \edef\texiatcatcode{\the\catcode`\@}
Chris@42: \catcode `@=11\relax
Chris@42:
Chris@42: % Parse the optional {params} list. Set up \paramno and \paramlist
Chris@42: % so \defmacro knows what to do. Define \macarg.BLAH for each BLAH
Chris@42: % in the params list to some hook where the argument si to be expanded. If
Chris@42: % there are less than 10 arguments that hook is to be replaced by ##N where N
Chris@42: % is the position in that list, that is to say the macro arguments are to be
Chris@42: % defined `a la TeX in the macro body.
Chris@42: %
Chris@42: % That gets used by \mbodybackslash (above).
Chris@42: %
Chris@42: % We need to get `macro parameter char #' into several definitions.
Chris@42: % The technique used is stolen from LaTeX: let \hash be something
Chris@42: % unexpandable, insert that wherever you need a #, and then redefine
Chris@42: % it to # just before using the token list produced.
Chris@42: %
Chris@42: % The same technique is used to protect \eatspaces till just before
Chris@42: % the macro is used.
Chris@42: %
Chris@42: % If there are 10 or more arguments, a different technique is used, where the
Chris@42: % hook remains in the body, and when macro is to be expanded the body is
Chris@42: % processed again to replace the arguments.
Chris@42: %
Chris@42: % In that case, the hook is \the\toks N-1, and we simply set \toks N-1 to the
Chris@42: % argument N value and then \edef the body (nothing else will expand because of
Chris@42: % the catcode regime underwhich the body was input).
Chris@42: %
Chris@42: % If you compile with TeX (not eTeX), and you have macros with 10 or more
Chris@42: % arguments, you need that no macro has more than 256 arguments, otherwise an
Chris@42: % error is produced.
Chris@42: \def\parsemargdef#1;{%
Chris@42: \paramno=0\def\paramlist{}%
Chris@42: \let\hash\relax
Chris@42: \let\xeatspaces\relax
Chris@42: \parsemargdefxxx#1,;,%
Chris@42: % In case that there are 10 or more arguments we parse again the arguments
Chris@42: % list to set new definitions for the \macarg.BLAH macros corresponding to
Chris@42: % each BLAH argument. It was anyhow needed to parse already once this list
Chris@42: % in order to count the arguments, and as macros with at most 9 arguments
Chris@42: % are by far more frequent than macro with 10 or more arguments, defining
Chris@42: % twice the \macarg.BLAH macros does not cost too much processing power.
Chris@42: \ifnum\paramno<10\relax\else
Chris@42: \paramno0\relax
Chris@42: \parsemmanyargdef@@#1,;,% 10 or more arguments
Chris@42: \fi
Chris@42: }
Chris@42: \def\parsemargdefxxx#1,{%
Chris@42: \if#1;\let\next=\relax
Chris@42: \else \let\next=\parsemargdefxxx
Chris@42: \advance\paramno by 1
Chris@42: \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname
Chris@42: {\xeatspaces{\hash\the\paramno}}%
Chris@42: \edef\paramlist{\paramlist\hash\the\paramno,}%
Chris@42: \fi\next}
Chris@42:
Chris@42: \def\parsemmanyargdef@@#1,{%
Chris@42: \if#1;\let\next=\relax
Chris@42: \else
Chris@42: \let\next=\parsemmanyargdef@@
Chris@42: \edef\tempb{\eatspaces{#1}}%
Chris@42: \expandafter\def\expandafter\tempa
Chris@42: \expandafter{\csname macarg.\tempb\endcsname}%
Chris@42: % Note that we need some extra \noexpand\noexpand, this is because we
Chris@42: % don't want \the to be expanded in the \parsermacbody as it uses an
Chris@42: % \xdef .
Chris@42: \expandafter\edef\tempa
Chris@42: {\noexpand\noexpand\noexpand\the\toks\the\paramno}%
Chris@42: \advance\paramno by 1\relax
Chris@42: \fi\next}
Chris@42:
Chris@42: % These two commands read recursive and nonrecursive macro bodies.
Chris@42: % (They're different since rec and nonrec macros end differently.)
Chris@42: %
Chris@42:
Chris@42: \catcode `\@\texiatcatcode
Chris@42: \long\def\parsemacbody#1@end macro%
Chris@42: {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
Chris@42: \long\def\parsermacbody#1@end rmacro%
Chris@42: {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}%
Chris@42: \catcode `\@=11\relax
Chris@42:
Chris@42: \let\endargs@\relax
Chris@42: \let\nil@\relax
Chris@42: \def\nilm@{\nil@}%
Chris@42: \long\def\nillm@{\nil@}%
Chris@42:
Chris@42: % This macro is expanded during the Texinfo macro expansion, not during its
Chris@42: % definition. It gets all the arguments values and assigns them to macros
Chris@42: % macarg.ARGNAME
Chris@42: %
Chris@42: % #1 is the macro name
Chris@42: % #2 is the list of argument names
Chris@42: % #3 is the list of argument values
Chris@42: \def\getargvals@#1#2#3{%
Chris@42: \def\macargdeflist@{}%
Chris@42: \def\saveparamlist@{#2}% Need to keep a copy for parameter expansion.
Chris@42: \def\paramlist{#2,\nil@}%
Chris@42: \def\macroname{#1}%
Chris@42: \begingroup
Chris@42: \macroargctxt
Chris@42: \def\argvaluelist{#3,\nil@}%
Chris@42: \def\@tempa{#3}%
Chris@42: \ifx\@tempa\empty
Chris@42: \setemptyargvalues@
Chris@42: \else
Chris@42: \getargvals@@
Chris@42: \fi
Chris@42: }
Chris@42:
Chris@42: %
Chris@42: \def\getargvals@@{%
Chris@42: \ifx\paramlist\nilm@
Chris@42: % Some sanity check needed here that \argvaluelist is also empty.
Chris@42: \ifx\argvaluelist\nillm@
Chris@42: \else
Chris@42: \errhelp = \EMsimple
Chris@42: \errmessage{Too many arguments in macro `\macroname'!}%
Chris@42: \fi
Chris@42: \let\next\macargexpandinbody@
Chris@42: \else
Chris@42: \ifx\argvaluelist\nillm@
Chris@42: % No more arguments values passed to macro. Set remaining named-arg
Chris@42: % macros to empty.
Chris@42: \let\next\setemptyargvalues@
Chris@42: \else
Chris@42: % pop current arg name into \@tempb
Chris@42: \def\@tempa##1{\pop@{\@tempb}{\paramlist}##1\endargs@}%
Chris@42: \expandafter\@tempa\expandafter{\paramlist}%
Chris@42: % pop current argument value into \@tempc
Chris@42: \def\@tempa##1{\longpop@{\@tempc}{\argvaluelist}##1\endargs@}%
Chris@42: \expandafter\@tempa\expandafter{\argvaluelist}%
Chris@42: % Here \@tempb is the current arg name and \@tempc is the current arg value.
Chris@42: % First place the new argument macro definition into \@tempd
Chris@42: \expandafter\macname\expandafter{\@tempc}%
Chris@42: \expandafter\let\csname macarg.\@tempb\endcsname\relax
Chris@42: \expandafter\def\expandafter\@tempe\expandafter{%
Chris@42: \csname macarg.\@tempb\endcsname}%
Chris@42: \edef\@tempd{\long\def\@tempe{\the\macname}}%
Chris@42: \push@\@tempd\macargdeflist@
Chris@42: \let\next\getargvals@@
Chris@42: \fi
Chris@42: \fi
Chris@42: \next
Chris@42: }
Chris@42:
Chris@42: \def\push@#1#2{%
Chris@42: \expandafter\expandafter\expandafter\def
Chris@42: \expandafter\expandafter\expandafter#2%
Chris@42: \expandafter\expandafter\expandafter{%
Chris@42: \expandafter#1#2}%
Chris@42: }
Chris@42:
Chris@42: % Replace arguments by their values in the macro body, and place the result
Chris@42: % in macro \@tempa
Chris@42: \def\macvalstoargs@{%
Chris@42: % To do this we use the property that token registers that are \the'ed
Chris@42: % within an \edef expand only once. So we are going to place all argument
Chris@42: % values into respective token registers.
Chris@42: %
Chris@42: % First we save the token context, and initialize argument numbering.
Chris@42: \begingroup
Chris@42: \paramno0\relax
Chris@42: % Then, for each argument number #N, we place the corresponding argument
Chris@42: % value into a new token list register \toks#N
Chris@42: \expandafter\putargsintokens@\saveparamlist@,;,%
Chris@42: % Then, we expand the body so that argument are replaced by their
Chris@42: % values. The trick for values not to be expanded themselves is that they
Chris@42: % are within tokens and that tokens expand only once in an \edef .
Chris@42: \edef\@tempc{\csname mac.\macroname .body\endcsname}%
Chris@42: % Now we restore the token stack pointer to free the token list registers
Chris@42: % which we have used, but we make sure that expanded body is saved after
Chris@42: % group.
Chris@42: \expandafter
Chris@42: \endgroup
Chris@42: \expandafter\def\expandafter\@tempa\expandafter{\@tempc}%
Chris@42: }
Chris@42:
Chris@42: \def\macargexpandinbody@{%
Chris@42: %% Define the named-macro outside of this group and then close this group.
Chris@42: \expandafter
Chris@42: \endgroup
Chris@42: \macargdeflist@
Chris@42: % First the replace in body the macro arguments by their values, the result
Chris@42: % is in \@tempa .
Chris@42: \macvalstoargs@
Chris@42: % Then we point at the \norecurse or \gobble (for recursive) macro value
Chris@42: % with \@tempb .
Chris@42: \expandafter\let\expandafter\@tempb\csname mac.\macroname .recurse\endcsname
Chris@42: % Depending on whether it is recursive or not, we need some tailing
Chris@42: % \egroup .
Chris@42: \ifx\@tempb\gobble
Chris@42: \let\@tempc\relax
Chris@42: \else
Chris@42: \let\@tempc\egroup
Chris@42: \fi
Chris@42: % And now we do the real job:
Chris@42: \edef\@tempd{\noexpand\@tempb{\macroname}\noexpand\scanmacro{\@tempa}\@tempc}%
Chris@42: \@tempd
Chris@42: }
Chris@42:
Chris@42: \def\putargsintokens@#1,{%
Chris@42: \if#1;\let\next\relax
Chris@42: \else
Chris@42: \let\next\putargsintokens@
Chris@42: % First we allocate the new token list register, and give it a temporary
Chris@42: % alias \@tempb .
Chris@42: \toksdef\@tempb\the\paramno
Chris@42: % Then we place the argument value into that token list register.
Chris@42: \expandafter\let\expandafter\@tempa\csname macarg.#1\endcsname
Chris@42: \expandafter\@tempb\expandafter{\@tempa}%
Chris@42: \advance\paramno by 1\relax
Chris@42: \fi
Chris@42: \next
Chris@42: }
Chris@42:
Chris@42: % Save the token stack pointer into macro #1
Chris@42: \def\texisavetoksstackpoint#1{\edef#1{\the\@cclvi}}
Chris@42: % Restore the token stack pointer from number in macro #1
Chris@42: \def\texirestoretoksstackpoint#1{\expandafter\mathchardef\expandafter\@cclvi#1\relax}
Chris@42: % newtoks that can be used non \outer .
Chris@42: \def\texinonouternewtoks{\alloc@ 5\toks \toksdef \@cclvi}
Chris@42:
Chris@42: % Tailing missing arguments are set to empty
Chris@42: \def\setemptyargvalues@{%
Chris@42: \ifx\paramlist\nilm@
Chris@42: \let\next\macargexpandinbody@
Chris@42: \else
Chris@42: \expandafter\setemptyargvaluesparser@\paramlist\endargs@
Chris@42: \let\next\setemptyargvalues@
Chris@42: \fi
Chris@42: \next
Chris@42: }
Chris@42:
Chris@42: \def\setemptyargvaluesparser@#1,#2\endargs@{%
Chris@42: \expandafter\def\expandafter\@tempa\expandafter{%
Chris@42: \expandafter\def\csname macarg.#1\endcsname{}}%
Chris@42: \push@\@tempa\macargdeflist@
Chris@42: \def\paramlist{#2}%
Chris@42: }
Chris@42:
Chris@42: % #1 is the element target macro
Chris@42: % #2 is the list macro
Chris@42: % #3,#4\endargs@ is the list value
Chris@42: \def\pop@#1#2#3,#4\endargs@{%
Chris@42: \def#1{#3}%
Chris@42: \def#2{#4}%
Chris@42: }
Chris@42: \long\def\longpop@#1#2#3,#4\endargs@{%
Chris@42: \long\def#1{#3}%
Chris@42: \long\def#2{#4}%
Chris@42: }
Chris@42:
Chris@42: % This defines a Texinfo @macro. There are eight cases: recursive and
Chris@42: % nonrecursive macros of zero, one, up to nine, and many arguments.
Chris@42: % Much magic with \expandafter here.
Chris@42: % \xdef is used so that macro definitions will survive the file
Chris@42: % they're defined in; @include reads the file inside a group.
Chris@42: %
Chris@42: \def\defmacro{%
Chris@42: \let\hash=##% convert placeholders to macro parameter chars
Chris@42: \ifrecursive
Chris@42: \ifcase\paramno
Chris@42: % 0
Chris@42: \expandafter\xdef\csname\the\macname\endcsname{%
Chris@42: \noexpand\scanmacro{\temp}}%
Chris@42: \or % 1
Chris@42: \expandafter\xdef\csname\the\macname\endcsname{%
Chris@42: \bgroup\noexpand\macroargctxt
Chris@42: \noexpand\braceorline
Chris@42: \expandafter\noexpand\csname\the\macname xxx\endcsname}%
Chris@42: \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
Chris@42: \egroup\noexpand\scanmacro{\temp}}%
Chris@42: \else
Chris@42: \ifnum\paramno<10\relax % at most 9
Chris@42: \expandafter\xdef\csname\the\macname\endcsname{%
Chris@42: \bgroup\noexpand\macroargctxt
Chris@42: \noexpand\csname\the\macname xx\endcsname}%
Chris@42: \expandafter\xdef\csname\the\macname xx\endcsname##1{%
Chris@42: \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
Chris@42: \expandafter\expandafter
Chris@42: \expandafter\xdef
Chris@42: \expandafter\expandafter
Chris@42: \csname\the\macname xxx\endcsname
Chris@42: \paramlist{\egroup\noexpand\scanmacro{\temp}}%
Chris@42: \else % 10 or more
Chris@42: \expandafter\xdef\csname\the\macname\endcsname{%
Chris@42: \noexpand\getargvals@{\the\macname}{\argl}%
Chris@42: }%
Chris@42: \global\expandafter\let\csname mac.\the\macname .body\endcsname\temp
Chris@42: \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\gobble
Chris@42: \fi
Chris@42: \fi
Chris@42: \else
Chris@42: \ifcase\paramno
Chris@42: % 0
Chris@42: \expandafter\xdef\csname\the\macname\endcsname{%
Chris@42: \noexpand\norecurse{\the\macname}%
Chris@42: \noexpand\scanmacro{\temp}\egroup}%
Chris@42: \or % 1
Chris@42: \expandafter\xdef\csname\the\macname\endcsname{%
Chris@42: \bgroup\noexpand\macroargctxt
Chris@42: \noexpand\braceorline
Chris@42: \expandafter\noexpand\csname\the\macname xxx\endcsname}%
Chris@42: \expandafter\xdef\csname\the\macname xxx\endcsname##1{%
Chris@42: \egroup
Chris@42: \noexpand\norecurse{\the\macname}%
Chris@42: \noexpand\scanmacro{\temp}\egroup}%
Chris@42: \else % at most 9
Chris@42: \ifnum\paramno<10\relax
Chris@42: \expandafter\xdef\csname\the\macname\endcsname{%
Chris@42: \bgroup\noexpand\macroargctxt
Chris@42: \expandafter\noexpand\csname\the\macname xx\endcsname}%
Chris@42: \expandafter\xdef\csname\the\macname xx\endcsname##1{%
Chris@42: \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}%
Chris@42: \expandafter\expandafter
Chris@42: \expandafter\xdef
Chris@42: \expandafter\expandafter
Chris@42: \csname\the\macname xxx\endcsname
Chris@42: \paramlist{%
Chris@42: \egroup
Chris@42: \noexpand\norecurse{\the\macname}%
Chris@42: \noexpand\scanmacro{\temp}\egroup}%
Chris@42: \else % 10 or more:
Chris@42: \expandafter\xdef\csname\the\macname\endcsname{%
Chris@42: \noexpand\getargvals@{\the\macname}{\argl}%
Chris@42: }%
Chris@42: \global\expandafter\let\csname mac.\the\macname .body\endcsname\temp
Chris@42: \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\norecurse
Chris@42: \fi
Chris@42: \fi
Chris@42: \fi}
Chris@42:
Chris@42: \catcode `\@\texiatcatcode\relax
Chris@42:
Chris@42: \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}}
Chris@42:
Chris@42: % \braceorline decides whether the next nonwhitespace character is a
Chris@42: % {. If so it reads up to the closing }, if not, it reads the whole
Chris@42: % line. Whatever was read is then fed to the next control sequence
Chris@42: % as an argument (by \parsebrace or \parsearg).
Chris@42: %
Chris@42: \def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx}
Chris@42: \def\braceorlinexxx{%
Chris@42: \ifx\nchar\bgroup\else
Chris@42: \expandafter\parsearg
Chris@42: \fi \macnamexxx}
Chris@42:
Chris@42:
Chris@42: % @alias.
Chris@42: % We need some trickery to remove the optional spaces around the equal
Chris@42: % sign. Make them active and then expand them all to nothing.
Chris@42: %
Chris@42: \def\alias{\parseargusing\obeyspaces\aliasxxx}
Chris@42: \def\aliasxxx #1{\aliasyyy#1\relax}
Chris@42: \def\aliasyyy #1=#2\relax{%
Chris@42: {%
Chris@42: \expandafter\let\obeyedspace=\empty
Chris@42: \addtomacrolist{#1}%
Chris@42: \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}%
Chris@42: }%
Chris@42: \next
Chris@42: }
Chris@42:
Chris@42:
Chris@42: \message{cross references,}
Chris@42:
Chris@42: \newwrite\auxfile
Chris@42: \newif\ifhavexrefs % True if xref values are known.
Chris@42: \newif\ifwarnedxrefs % True if we warned once that they aren't known.
Chris@42:
Chris@42: % @inforef is relatively simple.
Chris@42: \def\inforef #1{\inforefzzz #1,,,,**}
Chris@42: \def\inforefzzz #1,#2,#3,#4**{%
Chris@42: \putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}},
Chris@42: node \samp{\ignorespaces#1{}}}
Chris@42:
Chris@42: % @node's only job in TeX is to define \lastnode, which is used in
Chris@42: % cross-references. The @node line might or might not have commas, and
Chris@42: % might or might not have spaces before the first comma, like:
Chris@42: % @node foo , bar , ...
Chris@42: % We don't want such trailing spaces in the node name.
Chris@42: %
Chris@42: \parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse}
Chris@42: %
Chris@42: % also remove a trailing comma, in case of something like this:
Chris@42: % @node Help-Cross, , , Cross-refs
Chris@42: \def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse}
Chris@42: \def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}}
Chris@42:
Chris@42: \let\nwnode=\node
Chris@42: \let\lastnode=\empty
Chris@42:
Chris@42: % Write a cross-reference definition for the current node. #1 is the
Chris@42: % type (Ynumbered, Yappendix, Ynothing).
Chris@42: %
Chris@42: \def\donoderef#1{%
Chris@42: \ifx\lastnode\empty\else
Chris@42: \setref{\lastnode}{#1}%
Chris@42: \global\let\lastnode=\empty
Chris@42: \fi
Chris@42: }
Chris@42:
Chris@42: % @anchor{NAME} -- define xref target at arbitrary point.
Chris@42: %
Chris@42: \newcount\savesfregister
Chris@42: %
Chris@42: \def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi}
Chris@42: \def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi}
Chris@42: \def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces}
Chris@42:
Chris@42: % \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an
Chris@42: % anchor), which consists of three parts:
Chris@42: % 1) NAME-title - the current sectioning name taken from \lastsection,
Chris@42: % or the anchor name.
Chris@42: % 2) NAME-snt - section number and type, passed as the SNT arg, or
Chris@42: % empty for anchors.
Chris@42: % 3) NAME-pg - the page number.
Chris@42: %
Chris@42: % This is called from \donoderef, \anchor, and \dofloat. In the case of
Chris@42: % floats, there is an additional part, which is not written here:
Chris@42: % 4) NAME-lof - the text as it should appear in a @listoffloats.
Chris@42: %
Chris@42: \def\setref#1#2{%
Chris@42: \pdfmkdest{#1}%
Chris@42: \iflinks
Chris@42: {%
Chris@42: \atdummies % preserve commands, but don't expand them
Chris@42: \edef\writexrdef##1##2{%
Chris@42: \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef
Chris@42: ##1}{##2}}% these are parameters of \writexrdef
Chris@42: }%
Chris@42: \toks0 = \expandafter{\lastsection}%
Chris@42: \immediate \writexrdef{title}{\the\toks0 }%
Chris@42: \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc.
Chris@42: \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout
Chris@42: }%
Chris@42: \fi
Chris@42: }
Chris@42:
Chris@42: % @xrefautosectiontitle on|off says whether @section(ing) names are used
Chris@42: % automatically in xrefs, if the third arg is not explicitly specified.
Chris@42: % This was provided as a "secret" @set xref-automatic-section-title
Chris@42: % variable, now it's official.
Chris@42: %
Chris@42: \parseargdef\xrefautomaticsectiontitle{%
Chris@42: \def\temp{#1}%
Chris@42: \ifx\temp\onword
Chris@42: \expandafter\let\csname SETxref-automatic-section-title\endcsname
Chris@42: = \empty
Chris@42: \else\ifx\temp\offword
Chris@42: \expandafter\let\csname SETxref-automatic-section-title\endcsname
Chris@42: = \relax
Chris@42: \else
Chris@42: \errhelp = \EMsimple
Chris@42: \errmessage{Unknown @xrefautomaticsectiontitle value `\temp',
Chris@42: must be on|off}%
Chris@42: \fi\fi
Chris@42: }
Chris@42:
Chris@42: %
Chris@42: % @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is
Chris@42: % the node name, #2 the name of the Info cross-reference, #3 the printed
Chris@42: % node name, #4 the name of the Info file, #5 the name of the printed
Chris@42: % manual. All but the node name can be omitted.
Chris@42: %
Chris@42: \def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]}
Chris@42: \def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]}
Chris@42: \def\ref#1{\xrefX[#1,,,,,,,]}
Chris@42: %
Chris@42: \newbox\toprefbox
Chris@42: \newbox\printedrefnamebox
Chris@42: \newbox\infofilenamebox
Chris@42: \newbox\printedmanualbox
Chris@42: %
Chris@42: \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup
Chris@42: \unsepspaces
Chris@42: %
Chris@42: % Get args without leading/trailing spaces.
Chris@42: \def\printedrefname{\ignorespaces #3}%
Chris@42: \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}%
Chris@42: %
Chris@42: \def\infofilename{\ignorespaces #4}%
Chris@42: \setbox\infofilenamebox = \hbox{\infofilename\unskip}%
Chris@42: %
Chris@42: \def\printedmanual{\ignorespaces #5}%
Chris@42: \setbox\printedmanualbox = \hbox{\printedmanual\unskip}%
Chris@42: %
Chris@42: % If the printed reference name (arg #3) was not explicitly given in
Chris@42: % the @xref, figure out what we want to use.
Chris@42: \ifdim \wd\printedrefnamebox = 0pt
Chris@42: % No printed node name was explicitly given.
Chris@42: \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax
Chris@42: % Not auto section-title: use node name inside the square brackets.
Chris@42: \def\printedrefname{\ignorespaces #1}%
Chris@42: \else
Chris@42: % Auto section-title: use chapter/section title inside
Chris@42: % the square brackets if we have it.
Chris@42: \ifdim \wd\printedmanualbox > 0pt
Chris@42: % It is in another manual, so we don't have it; use node name.
Chris@42: \def\printedrefname{\ignorespaces #1}%
Chris@42: \else
Chris@42: \ifhavexrefs
Chris@42: % We (should) know the real title if we have the xref values.
Chris@42: \def\printedrefname{\refx{#1-title}{}}%
Chris@42: \else
Chris@42: % Otherwise just copy the Info node name.
Chris@42: \def\printedrefname{\ignorespaces #1}%
Chris@42: \fi%
Chris@42: \fi
Chris@42: \fi
Chris@42: \fi
Chris@42: %
Chris@42: % Make link in pdf output.
Chris@42: \ifpdf
Chris@42: {\indexnofonts
Chris@42: \turnoffactive
Chris@42: \makevalueexpandable
Chris@42: % This expands tokens, so do it after making catcode changes, so _
Chris@42: % etc. don't get their TeX definitions. This ignores all spaces in
Chris@42: % #4, including (wrongly) those in the middle of the filename.
Chris@42: \getfilename{#4}%
Chris@42: %
Chris@42: % This (wrongly) does not take account of leading or trailing
Chris@42: % spaces in #1, which should be ignored.
Chris@42: \edef\pdfxrefdest{#1}%
Chris@42: \ifx\pdfxrefdest\empty
Chris@42: \def\pdfxrefdest{Top}% no empty targets
Chris@42: \else
Chris@42: \txiescapepdf\pdfxrefdest % escape PDF special chars
Chris@42: \fi
Chris@42: %
Chris@42: \leavevmode
Chris@42: \startlink attr{/Border [0 0 0]}%
Chris@42: \ifnum\filenamelength>0
Chris@42: goto file{\the\filename.pdf} name{\pdfxrefdest}%
Chris@42: \else
Chris@42: goto name{\pdfmkpgn{\pdfxrefdest}}%
Chris@42: \fi
Chris@42: }%
Chris@42: \setcolor{\linkcolor}%
Chris@42: \fi
Chris@42: %
Chris@42: % Float references are printed completely differently: "Figure 1.2"
Chris@42: % instead of "[somenode], p.3". We distinguish them by the
Chris@42: % LABEL-title being set to a magic string.
Chris@42: {%
Chris@42: % Have to otherify everything special to allow the \csname to
Chris@42: % include an _ in the xref name, etc.
Chris@42: \indexnofonts
Chris@42: \turnoffactive
Chris@42: \expandafter\global\expandafter\let\expandafter\Xthisreftitle
Chris@42: \csname XR#1-title\endcsname
Chris@42: }%
Chris@42: \iffloat\Xthisreftitle
Chris@42: % If the user specified the print name (third arg) to the ref,
Chris@42: % print it instead of our usual "Figure 1.2".
Chris@42: \ifdim\wd\printedrefnamebox = 0pt
Chris@42: \refx{#1-snt}{}%
Chris@42: \else
Chris@42: \printedrefname
Chris@42: \fi
Chris@42: %
Chris@42: % If the user also gave the printed manual name (fifth arg), append
Chris@42: % "in MANUALNAME".
Chris@42: \ifdim \wd\printedmanualbox > 0pt
Chris@42: \space \putwordin{} \cite{\printedmanual}%
Chris@42: \fi
Chris@42: \else
Chris@42: % node/anchor (non-float) references.
Chris@42: %
Chris@42: % If we use \unhbox to print the node names, TeX does not insert
Chris@42: % empty discretionaries after hyphens, which means that it will not
Chris@42: % find a line break at a hyphen in a node names. Since some manuals
Chris@42: % are best written with fairly long node names, containing hyphens,
Chris@42: % this is a loss. Therefore, we give the text of the node name
Chris@42: % again, so it is as if TeX is seeing it for the first time.
Chris@42: %
Chris@42: \ifdim \wd\printedmanualbox > 0pt
Chris@42: % Cross-manual reference with a printed manual name.
Chris@42: %
Chris@42: \crossmanualxref{\cite{\printedmanual\unskip}}%
Chris@42: %
Chris@42: \else\ifdim \wd\infofilenamebox > 0pt
Chris@42: % Cross-manual reference with only an info filename (arg 4), no
Chris@42: % printed manual name (arg 5). This is essentially the same as
Chris@42: % the case above; we output the filename, since we have nothing else.
Chris@42: %
Chris@42: \crossmanualxref{\code{\infofilename\unskip}}%
Chris@42: %
Chris@42: \else
Chris@42: % Reference within this manual.
Chris@42: %
Chris@42: % _ (for example) has to be the character _ for the purposes of the
Chris@42: % control sequence corresponding to the node, but it has to expand
Chris@42: % into the usual \leavevmode...\vrule stuff for purposes of
Chris@42: % printing. So we \turnoffactive for the \refx-snt, back on for the
Chris@42: % printing, back off for the \refx-pg.
Chris@42: {\turnoffactive
Chris@42: % Only output a following space if the -snt ref is nonempty; for
Chris@42: % @unnumbered and @anchor, it won't be.
Chris@42: \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}%
Chris@42: \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi
Chris@42: }%
Chris@42: % output the `[mynode]' via the macro below so it can be overridden.
Chris@42: \xrefprintnodename\printedrefname
Chris@42: %
Chris@42: % But we always want a comma and a space:
Chris@42: ,\space
Chris@42: %
Chris@42: % output the `page 3'.
Chris@42: \turnoffactive \putwordpage\tie\refx{#1-pg}{}%
Chris@42: \fi\fi
Chris@42: \fi
Chris@42: \endlink
Chris@42: \endgroup}
Chris@42:
Chris@42: % Output a cross-manual xref to #1. Used just above (twice).
Chris@42: %
Chris@42: % Only include the text "Section ``foo'' in" if the foo is neither
Chris@42: % missing or Top. Thus, @xref{,,,foo,The Foo Manual} outputs simply
Chris@42: % "see The Foo Manual", the idea being to refer to the whole manual.
Chris@42: %
Chris@42: % But, this being TeX, we can't easily compare our node name against the
Chris@42: % string "Top" while ignoring the possible spaces before and after in
Chris@42: % the input. By adding the arbitrary 7sp below, we make it much less
Chris@42: % likely that a real node name would have the same width as "Top" (e.g.,
Chris@42: % in a monospaced font). Hopefully it will never happen in practice.
Chris@42: %
Chris@42: % For the same basic reason, we retypeset the "Top" at every
Chris@42: % reference, since the current font is indeterminate.
Chris@42: %
Chris@42: \def\crossmanualxref#1{%
Chris@42: \setbox\toprefbox = \hbox{Top\kern7sp}%
Chris@42: \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}%
Chris@42: \ifdim \wd2 > 7sp % nonempty?
Chris@42: \ifdim \wd2 = \wd\toprefbox \else % same as Top?
Chris@42: \putwordSection{} ``\printedrefname'' \putwordin{}\space
Chris@42: \fi
Chris@42: \fi
Chris@42: #1%
Chris@42: }
Chris@42:
Chris@42: % This macro is called from \xrefX for the `[nodename]' part of xref
Chris@42: % output. It's a separate macro only so it can be changed more easily,
Chris@42: % since square brackets don't work well in some documents. Particularly
Chris@42: % one that Bob is working on :).
Chris@42: %
Chris@42: \def\xrefprintnodename#1{[#1]}
Chris@42:
Chris@42: % Things referred to by \setref.
Chris@42: %
Chris@42: \def\Ynothing{}
Chris@42: \def\Yomitfromtoc{}
Chris@42: \def\Ynumbered{%
Chris@42: \ifnum\secno=0
Chris@42: \putwordChapter@tie \the\chapno
Chris@42: \else \ifnum\subsecno=0
Chris@42: \putwordSection@tie \the\chapno.\the\secno
Chris@42: \else \ifnum\subsubsecno=0
Chris@42: \putwordSection@tie \the\chapno.\the\secno.\the\subsecno
Chris@42: \else
Chris@42: \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno
Chris@42: \fi\fi\fi
Chris@42: }
Chris@42: \def\Yappendix{%
Chris@42: \ifnum\secno=0
Chris@42: \putwordAppendix@tie @char\the\appendixno{}%
Chris@42: \else \ifnum\subsecno=0
Chris@42: \putwordSection@tie @char\the\appendixno.\the\secno
Chris@42: \else \ifnum\subsubsecno=0
Chris@42: \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno
Chris@42: \else
Chris@42: \putwordSection@tie
Chris@42: @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno
Chris@42: \fi\fi\fi
Chris@42: }
Chris@42:
Chris@42: % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME.
Chris@42: % If its value is nonempty, SUFFIX is output afterward.
Chris@42: %
Chris@42: \def\refx#1#2{%
Chris@42: {%
Chris@42: \indexnofonts
Chris@42: \otherbackslash
Chris@42: \expandafter\global\expandafter\let\expandafter\thisrefX
Chris@42: \csname XR#1\endcsname
Chris@42: }%
Chris@42: \ifx\thisrefX\relax
Chris@42: % If not defined, say something at least.
Chris@42: \angleleft un\-de\-fined\angleright
Chris@42: \iflinks
Chris@42: \ifhavexrefs
Chris@42: {\toks0 = {#1}% avoid expansion of possibly-complex value
Chris@42: \message{\linenumber Undefined cross reference `\the\toks0'.}}%
Chris@42: \else
Chris@42: \ifwarnedxrefs\else
Chris@42: \global\warnedxrefstrue
Chris@42: \message{Cross reference values unknown; you must run TeX again.}%
Chris@42: \fi
Chris@42: \fi
Chris@42: \fi
Chris@42: \else
Chris@42: % It's defined, so just use it.
Chris@42: \thisrefX
Chris@42: \fi
Chris@42: #2% Output the suffix in any case.
Chris@42: }
Chris@42:
Chris@42: % This is the macro invoked by entries in the aux file. Usually it's
Chris@42: % just a \def (we prepend XR to the control sequence name to avoid
Chris@42: % collisions). But if this is a float type, we have more work to do.
Chris@42: %
Chris@42: \def\xrdef#1#2{%
Chris@42: {% The node name might contain 8-bit characters, which in our current
Chris@42: % implementation are changed to commands like @'e. Don't let these
Chris@42: % mess up the control sequence name.
Chris@42: \indexnofonts
Chris@42: \turnoffactive
Chris@42: \xdef\safexrefname{#1}%
Chris@42: }%
Chris@42: %
Chris@42: \expandafter\gdef\csname XR\safexrefname\endcsname{#2}% remember this xref
Chris@42: %
Chris@42: % Was that xref control sequence that we just defined for a float?
Chris@42: \expandafter\iffloat\csname XR\safexrefname\endcsname
Chris@42: % it was a float, and we have the (safe) float type in \iffloattype.
Chris@42: \expandafter\let\expandafter\floatlist
Chris@42: \csname floatlist\iffloattype\endcsname
Chris@42: %
Chris@42: % Is this the first time we've seen this float type?
Chris@42: \expandafter\ifx\floatlist\relax
Chris@42: \toks0 = {\do}% yes, so just \do
Chris@42: \else
Chris@42: % had it before, so preserve previous elements in list.
Chris@42: \toks0 = \expandafter{\floatlist\do}%
Chris@42: \fi
Chris@42: %
Chris@42: % Remember this xref in the control sequence \floatlistFLOATTYPE,
Chris@42: % for later use in \listoffloats.
Chris@42: \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0
Chris@42: {\safexrefname}}%
Chris@42: \fi
Chris@42: }
Chris@42:
Chris@42: % Read the last existing aux file, if any. No error if none exists.
Chris@42: %
Chris@42: \def\tryauxfile{%
Chris@42: \openin 1 \jobname.aux
Chris@42: \ifeof 1 \else
Chris@42: \readdatafile{aux}%
Chris@42: \global\havexrefstrue
Chris@42: \fi
Chris@42: \closein 1
Chris@42: }
Chris@42:
Chris@42: \def\setupdatafile{%
Chris@42: \catcode`\^^@=\other
Chris@42: \catcode`\^^A=\other
Chris@42: \catcode`\^^B=\other
Chris@42: \catcode`\^^C=\other
Chris@42: \catcode`\^^D=\other
Chris@42: \catcode`\^^E=\other
Chris@42: \catcode`\^^F=\other
Chris@42: \catcode`\^^G=\other
Chris@42: \catcode`\^^H=\other
Chris@42: \catcode`\^^K=\other
Chris@42: \catcode`\^^L=\other
Chris@42: \catcode`\^^N=\other
Chris@42: \catcode`\^^P=\other
Chris@42: \catcode`\^^Q=\other
Chris@42: \catcode`\^^R=\other
Chris@42: \catcode`\^^S=\other
Chris@42: \catcode`\^^T=\other
Chris@42: \catcode`\^^U=\other
Chris@42: \catcode`\^^V=\other
Chris@42: \catcode`\^^W=\other
Chris@42: \catcode`\^^X=\other
Chris@42: \catcode`\^^Z=\other
Chris@42: \catcode`\^^[=\other
Chris@42: \catcode`\^^\=\other
Chris@42: \catcode`\^^]=\other
Chris@42: \catcode`\^^^=\other
Chris@42: \catcode`\^^_=\other
Chris@42: % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc.
Chris@42: % in xref tags, i.e., node names. But since ^^e4 notation isn't
Chris@42: % supported in the main text, it doesn't seem desirable. Furthermore,
Chris@42: % that is not enough: for node names that actually contain a ^
Chris@42: % character, we would end up writing a line like this: 'xrdef {'hat
Chris@42: % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first
Chris@42: % argument, and \hat is not an expandable control sequence. It could
Chris@42: % all be worked out, but why? Either we support ^^ or we don't.
Chris@42: %
Chris@42: % The other change necessary for this was to define \auxhat:
Chris@42: % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter
Chris@42: % and then to call \auxhat in \setq.
Chris@42: %
Chris@42: \catcode`\^=\other
Chris@42: %
Chris@42: % Special characters. Should be turned off anyway, but...
Chris@42: \catcode`\~=\other
Chris@42: \catcode`\[=\other
Chris@42: \catcode`\]=\other
Chris@42: \catcode`\"=\other
Chris@42: \catcode`\_=\other
Chris@42: \catcode`\|=\other
Chris@42: \catcode`\<=\other
Chris@42: \catcode`\>=\other
Chris@42: \catcode`\$=\other
Chris@42: \catcode`\#=\other
Chris@42: \catcode`\&=\other
Chris@42: \catcode`\%=\other
Chris@42: \catcode`+=\other % avoid \+ for paranoia even though we've turned it off
Chris@42: %
Chris@42: % This is to support \ in node names and titles, since the \
Chris@42: % characters end up in a \csname. It's easier than
Chris@42: % leaving it active and making its active definition an actual \
Chris@42: % character. What I don't understand is why it works in the *value*
Chris@42: % of the xrdef. Seems like it should be a catcode12 \, and that
Chris@42: % should not typeset properly. But it works, so I'm moving on for
Chris@42: % now. --karl, 15jan04.
Chris@42: \catcode`\\=\other
Chris@42: %
Chris@42: % Make the characters 128-255 be printing characters.
Chris@42: {%
Chris@42: \count1=128
Chris@42: \def\loop{%
Chris@42: \catcode\count1=\other
Chris@42: \advance\count1 by 1
Chris@42: \ifnum \count1<256 \loop \fi
Chris@42: }%
Chris@42: }%
Chris@42: %
Chris@42: % @ is our escape character in .aux files, and we need braces.
Chris@42: \catcode`\{=1
Chris@42: \catcode`\}=2
Chris@42: \catcode`\@=0
Chris@42: }
Chris@42:
Chris@42: \def\readdatafile#1{%
Chris@42: \begingroup
Chris@42: \setupdatafile
Chris@42: \input\jobname.#1
Chris@42: \endgroup}
Chris@42:
Chris@42:
Chris@42: \message{insertions,}
Chris@42: % including footnotes.
Chris@42:
Chris@42: \newcount \footnoteno
Chris@42:
Chris@42: % The trailing space in the following definition for supereject is
Chris@42: % vital for proper filling; pages come out unaligned when you do a
Chris@42: % pagealignmacro call if that space before the closing brace is
Chris@42: % removed. (Generally, numeric constants should always be followed by a
Chris@42: % space to prevent strange expansion errors.)
Chris@42: \def\supereject{\par\penalty -20000\footnoteno =0 }
Chris@42:
Chris@42: % @footnotestyle is meaningful for Info output only.
Chris@42: \let\footnotestyle=\comment
Chris@42:
Chris@42: {\catcode `\@=11
Chris@42: %
Chris@42: % Auto-number footnotes. Otherwise like plain.
Chris@42: \gdef\footnote{%
Chris@42: \let\indent=\ptexindent
Chris@42: \let\noindent=\ptexnoindent
Chris@42: \global\advance\footnoteno by \@ne
Chris@42: \edef\thisfootno{$^{\the\footnoteno}$}%
Chris@42: %
Chris@42: % In case the footnote comes at the end of a sentence, preserve the
Chris@42: % extra spacing after we do the footnote number.
Chris@42: \let\@sf\empty
Chris@42: \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi
Chris@42: %
Chris@42: % Remove inadvertent blank space before typesetting the footnote number.
Chris@42: \unskip
Chris@42: \thisfootno\@sf
Chris@42: \dofootnote
Chris@42: }%
Chris@42:
Chris@42: % Don't bother with the trickery in plain.tex to not require the
Chris@42: % footnote text as a parameter. Our footnotes don't need to be so general.
Chris@42: %
Chris@42: % Oh yes, they do; otherwise, @ifset (and anything else that uses
Chris@42: % \parseargline) fails inside footnotes because the tokens are fixed when
Chris@42: % the footnote is read. --karl, 16nov96.
Chris@42: %
Chris@42: \gdef\dofootnote{%
Chris@42: \insert\footins\bgroup
Chris@42: % We want to typeset this text as a normal paragraph, even if the
Chris@42: % footnote reference occurs in (for example) a display environment.
Chris@42: % So reset some parameters.
Chris@42: \hsize=\pagewidth
Chris@42: \interlinepenalty\interfootnotelinepenalty
Chris@42: \splittopskip\ht\strutbox % top baseline for broken footnotes
Chris@42: \splitmaxdepth\dp\strutbox
Chris@42: \floatingpenalty\@MM
Chris@42: \leftskip\z@skip
Chris@42: \rightskip\z@skip
Chris@42: \spaceskip\z@skip
Chris@42: \xspaceskip\z@skip
Chris@42: \parindent\defaultparindent
Chris@42: %
Chris@42: \smallfonts \rm
Chris@42: %
Chris@42: % Because we use hanging indentation in footnotes, a @noindent appears
Chris@42: % to exdent this text, so make it be a no-op. makeinfo does not use
Chris@42: % hanging indentation so @noindent can still be needed within footnote
Chris@42: % text after an @example or the like (not that this is good style).
Chris@42: \let\noindent = \relax
Chris@42: %
Chris@42: % Hang the footnote text off the number. Use \everypar in case the
Chris@42: % footnote extends for more than one paragraph.
Chris@42: \everypar = {\hang}%
Chris@42: \textindent{\thisfootno}%
Chris@42: %
Chris@42: % Don't crash into the line above the footnote text. Since this
Chris@42: % expands into a box, it must come within the paragraph, lest it
Chris@42: % provide a place where TeX can split the footnote.
Chris@42: \footstrut
Chris@42: %
Chris@42: % Invoke rest of plain TeX footnote routine.
Chris@42: \futurelet\next\fo@t
Chris@42: }
Chris@42: }%end \catcode `\@=11
Chris@42:
Chris@42: % In case a @footnote appears in a vbox, save the footnote text and create
Chris@42: % the real \insert just after the vbox finished. Otherwise, the insertion
Chris@42: % would be lost.
Chris@42: % Similarly, if a @footnote appears inside an alignment, save the footnote
Chris@42: % text to a box and make the \insert when a row of the table is finished.
Chris@42: % And the same can be done for other insert classes. --kasal, 16nov03.
Chris@42:
Chris@42: % Replace the \insert primitive by a cheating macro.
Chris@42: % Deeper inside, just make sure that the saved insertions are not spilled
Chris@42: % out prematurely.
Chris@42: %
Chris@42: \def\startsavinginserts{%
Chris@42: \ifx \insert\ptexinsert
Chris@42: \let\insert\saveinsert
Chris@42: \else
Chris@42: \let\checkinserts\relax
Chris@42: \fi
Chris@42: }
Chris@42:
Chris@42: % This \insert replacement works for both \insert\footins{foo} and
Chris@42: % \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}.
Chris@42: %
Chris@42: \def\saveinsert#1{%
Chris@42: \edef\next{\noexpand\savetobox \makeSAVEname#1}%
Chris@42: \afterassignment\next
Chris@42: % swallow the left brace
Chris@42: \let\temp =
Chris@42: }
Chris@42: \def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}}
Chris@42: \def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1}
Chris@42:
Chris@42: \def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi}
Chris@42:
Chris@42: \def\placesaveins#1{%
Chris@42: \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname
Chris@42: {\box#1}%
Chris@42: }
Chris@42:
Chris@42: % eat @SAVE -- beware, all of them have catcode \other:
Chris@42: {
Chris@42: \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials % ;-)
Chris@42: \gdef\gobblesave @SAVE{}
Chris@42: }
Chris@42:
Chris@42: % initialization:
Chris@42: \def\newsaveins #1{%
Chris@42: \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}%
Chris@42: \next
Chris@42: }
Chris@42: \def\newsaveinsX #1{%
Chris@42: \csname newbox\endcsname #1%
Chris@42: \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts
Chris@42: \checksaveins #1}%
Chris@42: }
Chris@42:
Chris@42: % initialize:
Chris@42: \let\checkinserts\empty
Chris@42: \newsaveins\footins
Chris@42: \newsaveins\margin
Chris@42:
Chris@42:
Chris@42: % @image. We use the macros from epsf.tex to support this.
Chris@42: % If epsf.tex is not installed and @image is used, we complain.
Chris@42: %
Chris@42: % Check for and read epsf.tex up front. If we read it only at @image
Chris@42: % time, we might be inside a group, and then its definitions would get
Chris@42: % undone and the next image would fail.
Chris@42: \openin 1 = epsf.tex
Chris@42: \ifeof 1 \else
Chris@42: % Do not bother showing banner with epsf.tex v2.7k (available in
Chris@42: % doc/epsf.tex and on ctan).
Chris@42: \def\epsfannounce{\toks0 = }%
Chris@42: \input epsf.tex
Chris@42: \fi
Chris@42: \closein 1
Chris@42: %
Chris@42: % We will only complain once about lack of epsf.tex.
Chris@42: \newif\ifwarnednoepsf
Chris@42: \newhelp\noepsfhelp{epsf.tex must be installed for images to
Chris@42: work. It is also included in the Texinfo distribution, or you can get
Chris@42: it from ftp://tug.org/tex/epsf.tex.}
Chris@42: %
Chris@42: \def\image#1{%
Chris@42: \ifx\epsfbox\thisisundefined
Chris@42: \ifwarnednoepsf \else
Chris@42: \errhelp = \noepsfhelp
Chris@42: \errmessage{epsf.tex not found, images will be ignored}%
Chris@42: \global\warnednoepsftrue
Chris@42: \fi
Chris@42: \else
Chris@42: \imagexxx #1,,,,,\finish
Chris@42: \fi
Chris@42: }
Chris@42: %
Chris@42: % Arguments to @image:
Chris@42: % #1 is (mandatory) image filename; we tack on .eps extension.
Chris@42: % #2 is (optional) width, #3 is (optional) height.
Chris@42: % #4 is (ignored optional) html alt text.
Chris@42: % #5 is (ignored optional) extension.
Chris@42: % #6 is just the usual extra ignored arg for parsing stuff.
Chris@42: \newif\ifimagevmode
Chris@42: \def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup
Chris@42: \catcode`\^^M = 5 % in case we're inside an example
Chris@42: \normalturnoffactive % allow _ et al. in names
Chris@42: % If the image is by itself, center it.
Chris@42: \ifvmode
Chris@42: \imagevmodetrue
Chris@42: \else \ifx\centersub\centerV
Chris@42: % for @center @image, we need a vbox so we can have our vertical space
Chris@42: \imagevmodetrue
Chris@42: \vbox\bgroup % vbox has better behavior than vtop herev
Chris@42: \fi\fi
Chris@42: %
Chris@42: \ifimagevmode
Chris@42: \nobreak\medskip
Chris@42: % Usually we'll have text after the image which will insert
Chris@42: % \parskip glue, so insert it here too to equalize the space
Chris@42: % above and below.
Chris@42: \nobreak\vskip\parskip
Chris@42: \nobreak
Chris@42: \fi
Chris@42: %
Chris@42: % Leave vertical mode so that indentation from an enclosing
Chris@42: % environment such as @quotation is respected.
Chris@42: % However, if we're at the top level, we don't want the
Chris@42: % normal paragraph indentation.
Chris@42: % On the other hand, if we are in the case of @center @image, we don't
Chris@42: % want to start a paragraph, which will create a hsize-width box and
Chris@42: % eradicate the centering.
Chris@42: \ifx\centersub\centerV\else \noindent \fi
Chris@42: %
Chris@42: % Output the image.
Chris@42: \ifpdf
Chris@42: \dopdfimage{#1}{#2}{#3}%
Chris@42: \else
Chris@42: % \epsfbox itself resets \epsf?size at each figure.
Chris@42: \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi
Chris@42: \setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi
Chris@42: \epsfbox{#1.eps}%
Chris@42: \fi
Chris@42: %
Chris@42: \ifimagevmode
Chris@42: \medskip % space after a standalone image
Chris@42: \fi
Chris@42: \ifx\centersub\centerV \egroup \fi
Chris@42: \endgroup}
Chris@42:
Chris@42:
Chris@42: % @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables,
Chris@42: % etc. We don't actually implement floating yet, we always include the
Chris@42: % float "here". But it seemed the best name for the future.
Chris@42: %
Chris@42: \envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish}
Chris@42:
Chris@42: % There may be a space before second and/or third parameter; delete it.
Chris@42: \def\eatcommaspace#1, {#1,}
Chris@42:
Chris@42: % #1 is the optional FLOATTYPE, the text label for this float, typically
Chris@42: % "Figure", "Table", "Example", etc. Can't contain commas. If omitted,
Chris@42: % this float will not be numbered and cannot be referred to.
Chris@42: %
Chris@42: % #2 is the optional xref label. Also must be present for the float to
Chris@42: % be referable.
Chris@42: %
Chris@42: % #3 is the optional positioning argument; for now, it is ignored. It
Chris@42: % will somehow specify the positions allowed to float to (here, top, bottom).
Chris@42: %
Chris@42: % We keep a separate counter for each FLOATTYPE, which we reset at each
Chris@42: % chapter-level command.
Chris@42: \let\resetallfloatnos=\empty
Chris@42: %
Chris@42: \def\dofloat#1,#2,#3,#4\finish{%
Chris@42: \let\thiscaption=\empty
Chris@42: \let\thisshortcaption=\empty
Chris@42: %
Chris@42: % don't lose footnotes inside @float.
Chris@42: %
Chris@42: % BEWARE: when the floats start float, we have to issue warning whenever an
Chris@42: % insert appears inside a float which could possibly float. --kasal, 26may04
Chris@42: %
Chris@42: \startsavinginserts
Chris@42: %
Chris@42: % We can't be used inside a paragraph.
Chris@42: \par
Chris@42: %
Chris@42: \vtop\bgroup
Chris@42: \def\floattype{#1}%
Chris@42: \def\floatlabel{#2}%
Chris@42: \def\floatloc{#3}% we do nothing with this yet.
Chris@42: %
Chris@42: \ifx\floattype\empty
Chris@42: \let\safefloattype=\empty
Chris@42: \else
Chris@42: {%
Chris@42: % the floattype might have accents or other special characters,
Chris@42: % but we need to use it in a control sequence name.
Chris@42: \indexnofonts
Chris@42: \turnoffactive
Chris@42: \xdef\safefloattype{\floattype}%
Chris@42: }%
Chris@42: \fi
Chris@42: %
Chris@42: % If label is given but no type, we handle that as the empty type.
Chris@42: \ifx\floatlabel\empty \else
Chris@42: % We want each FLOATTYPE to be numbered separately (Figure 1,
Chris@42: % Table 1, Figure 2, ...). (And if no label, no number.)
Chris@42: %
Chris@42: \expandafter\getfloatno\csname\safefloattype floatno\endcsname
Chris@42: \global\advance\floatno by 1
Chris@42: %
Chris@42: {%
Chris@42: % This magic value for \lastsection is output by \setref as the
Chris@42: % XREFLABEL-title value. \xrefX uses it to distinguish float
Chris@42: % labels (which have a completely different output format) from
Chris@42: % node and anchor labels. And \xrdef uses it to construct the
Chris@42: % lists of floats.
Chris@42: %
Chris@42: \edef\lastsection{\floatmagic=\safefloattype}%
Chris@42: \setref{\floatlabel}{Yfloat}%
Chris@42: }%
Chris@42: \fi
Chris@42: %
Chris@42: % start with \parskip glue, I guess.
Chris@42: \vskip\parskip
Chris@42: %
Chris@42: % Don't suppress indentation if a float happens to start a section.
Chris@42: \restorefirstparagraphindent
Chris@42: }
Chris@42:
Chris@42: % we have these possibilities:
Chris@42: % @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap
Chris@42: % @float Foo,lbl & no caption: Foo 1.1
Chris@42: % @float Foo & @caption{Cap}: Foo: Cap
Chris@42: % @float Foo & no caption: Foo
Chris@42: % @float ,lbl & Caption{Cap}: 1.1: Cap
Chris@42: % @float ,lbl & no caption: 1.1
Chris@42: % @float & @caption{Cap}: Cap
Chris@42: % @float & no caption:
Chris@42: %
Chris@42: \def\Efloat{%
Chris@42: \let\floatident = \empty
Chris@42: %
Chris@42: % In all cases, if we have a float type, it comes first.
Chris@42: \ifx\floattype\empty \else \def\floatident{\floattype}\fi
Chris@42: %
Chris@42: % If we have an xref label, the number comes next.
Chris@42: \ifx\floatlabel\empty \else
Chris@42: \ifx\floattype\empty \else % if also had float type, need tie first.
Chris@42: \appendtomacro\floatident{\tie}%
Chris@42: \fi
Chris@42: % the number.
Chris@42: \appendtomacro\floatident{\chaplevelprefix\the\floatno}%
Chris@42: \fi
Chris@42: %
Chris@42: % Start the printed caption with what we've constructed in
Chris@42: % \floatident, but keep it separate; we need \floatident again.
Chris@42: \let\captionline = \floatident
Chris@42: %
Chris@42: \ifx\thiscaption\empty \else
Chris@42: \ifx\floatident\empty \else
Chris@42: \appendtomacro\captionline{: }% had ident, so need a colon between
Chris@42: \fi
Chris@42: %
Chris@42: % caption text.
Chris@42: \appendtomacro\captionline{\scanexp\thiscaption}%
Chris@42: \fi
Chris@42: %
Chris@42: % If we have anything to print, print it, with space before.
Chris@42: % Eventually this needs to become an \insert.
Chris@42: \ifx\captionline\empty \else
Chris@42: \vskip.5\parskip
Chris@42: \captionline
Chris@42: %
Chris@42: % Space below caption.
Chris@42: \vskip\parskip
Chris@42: \fi
Chris@42: %
Chris@42: % If have an xref label, write the list of floats info. Do this
Chris@42: % after the caption, to avoid chance of it being a breakpoint.
Chris@42: \ifx\floatlabel\empty \else
Chris@42: % Write the text that goes in the lof to the aux file as
Chris@42: % \floatlabel-lof. Besides \floatident, we include the short
Chris@42: % caption if specified, else the full caption if specified, else nothing.
Chris@42: {%
Chris@42: \atdummies
Chris@42: %
Chris@42: % since we read the caption text in the macro world, where ^^M
Chris@42: % is turned into a normal character, we have to scan it back, so
Chris@42: % we don't write the literal three characters "^^M" into the aux file.
Chris@42: \scanexp{%
Chris@42: \xdef\noexpand\gtemp{%
Chris@42: \ifx\thisshortcaption\empty
Chris@42: \thiscaption
Chris@42: \else
Chris@42: \thisshortcaption
Chris@42: \fi
Chris@42: }%
Chris@42: }%
Chris@42: \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident
Chris@42: \ifx\gtemp\empty \else : \gtemp \fi}}%
Chris@42: }%
Chris@42: \fi
Chris@42: \egroup % end of \vtop
Chris@42: %
Chris@42: % place the captured inserts
Chris@42: %
Chris@42: % BEWARE: when the floats start floating, we have to issue warning
Chris@42: % whenever an insert appears inside a float which could possibly
Chris@42: % float. --kasal, 26may04
Chris@42: %
Chris@42: \checkinserts
Chris@42: }
Chris@42:
Chris@42: % Append the tokens #2 to the definition of macro #1, not expanding either.
Chris@42: %
Chris@42: \def\appendtomacro#1#2{%
Chris@42: \expandafter\def\expandafter#1\expandafter{#1#2}%
Chris@42: }
Chris@42:
Chris@42: % @caption, @shortcaption
Chris@42: %
Chris@42: \def\caption{\docaption\thiscaption}
Chris@42: \def\shortcaption{\docaption\thisshortcaption}
Chris@42: \def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption}
Chris@42: \def\defcaption#1#2{\egroup \def#1{#2}}
Chris@42:
Chris@42: % The parameter is the control sequence identifying the counter we are
Chris@42: % going to use. Create it if it doesn't exist and assign it to \floatno.
Chris@42: \def\getfloatno#1{%
Chris@42: \ifx#1\relax
Chris@42: % Haven't seen this figure type before.
Chris@42: \csname newcount\endcsname #1%
Chris@42: %
Chris@42: % Remember to reset this floatno at the next chap.
Chris@42: \expandafter\gdef\expandafter\resetallfloatnos
Chris@42: \expandafter{\resetallfloatnos #1=0 }%
Chris@42: \fi
Chris@42: \let\floatno#1%
Chris@42: }
Chris@42:
Chris@42: % \setref calls this to get the XREFLABEL-snt value. We want an @xref
Chris@42: % to the FLOATLABEL to expand to "Figure 3.1". We call \setref when we
Chris@42: % first read the @float command.
Chris@42: %
Chris@42: \def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}%
Chris@42:
Chris@42: % Magic string used for the XREFLABEL-title value, so \xrefX can
Chris@42: % distinguish floats from other xref types.
Chris@42: \def\floatmagic{!!float!!}
Chris@42:
Chris@42: % #1 is the control sequence we are passed; we expand into a conditional
Chris@42: % which is true if #1 represents a float ref. That is, the magic
Chris@42: % \lastsection value which we \setref above.
Chris@42: %
Chris@42: \def\iffloat#1{\expandafter\doiffloat#1==\finish}
Chris@42: %
Chris@42: % #1 is (maybe) the \floatmagic string. If so, #2 will be the
Chris@42: % (safe) float type for this float. We set \iffloattype to #2.
Chris@42: %
Chris@42: \def\doiffloat#1=#2=#3\finish{%
Chris@42: \def\temp{#1}%
Chris@42: \def\iffloattype{#2}%
Chris@42: \ifx\temp\floatmagic
Chris@42: }
Chris@42:
Chris@42: % @listoffloats FLOATTYPE - print a list of floats like a table of contents.
Chris@42: %
Chris@42: \parseargdef\listoffloats{%
Chris@42: \def\floattype{#1}% floattype
Chris@42: {%
Chris@42: % the floattype might have accents or other special characters,
Chris@42: % but we need to use it in a control sequence name.
Chris@42: \indexnofonts
Chris@42: \turnoffactive
Chris@42: \xdef\safefloattype{\floattype}%
Chris@42: }%
Chris@42: %
Chris@42: % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE.
Chris@42: \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax
Chris@42: \ifhavexrefs
Chris@42: % if the user said @listoffloats foo but never @float foo.
Chris@42: \message{\linenumber No `\safefloattype' floats to list.}%
Chris@42: \fi
Chris@42: \else
Chris@42: \begingroup
Chris@42: \leftskip=\tocindent % indent these entries like a toc
Chris@42: \let\do=\listoffloatsdo
Chris@42: \csname floatlist\safefloattype\endcsname
Chris@42: \endgroup
Chris@42: \fi
Chris@42: }
Chris@42:
Chris@42: % This is called on each entry in a list of floats. We're passed the
Chris@42: % xref label, in the form LABEL-title, which is how we save it in the
Chris@42: % aux file. We strip off the -title and look up \XRLABEL-lof, which
Chris@42: % has the text we're supposed to typeset here.
Chris@42: %
Chris@42: % Figures without xref labels will not be included in the list (since
Chris@42: % they won't appear in the aux file).
Chris@42: %
Chris@42: \def\listoffloatsdo#1{\listoffloatsdoentry#1\finish}
Chris@42: \def\listoffloatsdoentry#1-title\finish{{%
Chris@42: % Can't fully expand XR#1-lof because it can contain anything. Just
Chris@42: % pass the control sequence. On the other hand, XR#1-pg is just the
Chris@42: % page number, and we want to fully expand that so we can get a link
Chris@42: % in pdf output.
Chris@42: \toksA = \expandafter{\csname XR#1-lof\endcsname}%
Chris@42: %
Chris@42: % use the same \entry macro we use to generate the TOC and index.
Chris@42: \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}%
Chris@42: \writeentry
Chris@42: }}
Chris@42:
Chris@42:
Chris@42: \message{localization,}
Chris@42:
Chris@42: % For single-language documents, @documentlanguage is usually given very
Chris@42: % early, just after @documentencoding. Single argument is the language
Chris@42: % (de) or locale (de_DE) abbreviation.
Chris@42: %
Chris@42: {
Chris@42: \catcode`\_ = \active
Chris@42: \globaldefs=1
Chris@42: \parseargdef\documentlanguage{\begingroup
Chris@42: \let_=\normalunderscore % normal _ character for filenames
Chris@42: \tex % read txi-??.tex file in plain TeX.
Chris@42: % Read the file by the name they passed if it exists.
Chris@42: \openin 1 txi-#1.tex
Chris@42: \ifeof 1
Chris@42: \documentlanguagetrywithoutunderscore{#1_\finish}%
Chris@42: \else
Chris@42: \globaldefs = 1 % everything in the txi-LL files needs to persist
Chris@42: \input txi-#1.tex
Chris@42: \fi
Chris@42: \closein 1
Chris@42: \endgroup % end raw TeX
Chris@42: \endgroup}
Chris@42: %
Chris@42: % If they passed de_DE, and txi-de_DE.tex doesn't exist,
Chris@42: % try txi-de.tex.
Chris@42: %
Chris@42: \gdef\documentlanguagetrywithoutunderscore#1_#2\finish{%
Chris@42: \openin 1 txi-#1.tex
Chris@42: \ifeof 1
Chris@42: \errhelp = \nolanghelp
Chris@42: \errmessage{Cannot read language file txi-#1.tex}%
Chris@42: \else
Chris@42: \globaldefs = 1 % everything in the txi-LL files needs to persist
Chris@42: \input txi-#1.tex
Chris@42: \fi
Chris@42: \closein 1
Chris@42: }
Chris@42: }% end of special _ catcode
Chris@42: %
Chris@42: \newhelp\nolanghelp{The given language definition file cannot be found or
Chris@42: is empty. Maybe you need to install it? Putting it in the current
Chris@42: directory should work if nowhere else does.}
Chris@42:
Chris@42: % This macro is called from txi-??.tex files; the first argument is the
Chris@42: % \language name to set (without the "\lang@" prefix), the second and
Chris@42: % third args are \{left,right}hyphenmin.
Chris@42: %
Chris@42: % The language names to pass are determined when the format is built.
Chris@42: % See the etex.log file created at that time, e.g.,
Chris@42: % /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log.
Chris@42: %
Chris@42: % With TeX Live 2008, etex now includes hyphenation patterns for all
Chris@42: % available languages. This means we can support hyphenation in
Chris@42: % Texinfo, at least to some extent. (This still doesn't solve the
Chris@42: % accented characters problem.)
Chris@42: %
Chris@42: \catcode`@=11
Chris@42: \def\txisetlanguage#1#2#3{%
Chris@42: % do not set the language if the name is undefined in the current TeX.
Chris@42: \expandafter\ifx\csname lang@#1\endcsname \relax
Chris@42: \message{no patterns for #1}%
Chris@42: \else
Chris@42: \global\language = \csname lang@#1\endcsname
Chris@42: \fi
Chris@42: % but there is no harm in adjusting the hyphenmin values regardless.
Chris@42: \global\lefthyphenmin = #2\relax
Chris@42: \global\righthyphenmin = #3\relax
Chris@42: }
Chris@42:
Chris@42: % Helpers for encodings.
Chris@42: % Set the catcode of characters 128 through 255 to the specified number.
Chris@42: %
Chris@42: \def\setnonasciicharscatcode#1{%
Chris@42: \count255=128
Chris@42: \loop\ifnum\count255<256
Chris@42: \global\catcode\count255=#1\relax
Chris@42: \advance\count255 by 1
Chris@42: \repeat
Chris@42: }
Chris@42:
Chris@42: \def\setnonasciicharscatcodenonglobal#1{%
Chris@42: \count255=128
Chris@42: \loop\ifnum\count255<256
Chris@42: \catcode\count255=#1\relax
Chris@42: \advance\count255 by 1
Chris@42: \repeat
Chris@42: }
Chris@42:
Chris@42: % @documentencoding sets the definition of non-ASCII characters
Chris@42: % according to the specified encoding.
Chris@42: %
Chris@42: \parseargdef\documentencoding{%
Chris@42: % Encoding being declared for the document.
Chris@42: \def\declaredencoding{\csname #1.enc\endcsname}%
Chris@42: %
Chris@42: % Supported encodings: names converted to tokens in order to be able
Chris@42: % to compare them with \ifx.
Chris@42: \def\ascii{\csname US-ASCII.enc\endcsname}%
Chris@42: \def\latnine{\csname ISO-8859-15.enc\endcsname}%
Chris@42: \def\latone{\csname ISO-8859-1.enc\endcsname}%
Chris@42: \def\lattwo{\csname ISO-8859-2.enc\endcsname}%
Chris@42: \def\utfeight{\csname UTF-8.enc\endcsname}%
Chris@42: %
Chris@42: \ifx \declaredencoding \ascii
Chris@42: \asciichardefs
Chris@42: %
Chris@42: \else \ifx \declaredencoding \lattwo
Chris@42: \setnonasciicharscatcode\active
Chris@42: \lattwochardefs
Chris@42: %
Chris@42: \else \ifx \declaredencoding \latone
Chris@42: \setnonasciicharscatcode\active
Chris@42: \latonechardefs
Chris@42: %
Chris@42: \else \ifx \declaredencoding \latnine
Chris@42: \setnonasciicharscatcode\active
Chris@42: \latninechardefs
Chris@42: %
Chris@42: \else \ifx \declaredencoding \utfeight
Chris@42: \setnonasciicharscatcode\active
Chris@42: \utfeightchardefs
Chris@42: %
Chris@42: \else
Chris@42: \message{Unknown document encoding #1, ignoring.}%
Chris@42: %
Chris@42: \fi % utfeight
Chris@42: \fi % latnine
Chris@42: \fi % latone
Chris@42: \fi % lattwo
Chris@42: \fi % ascii
Chris@42: }
Chris@42:
Chris@42: % A message to be logged when using a character that isn't available
Chris@42: % the default font encoding (OT1).
Chris@42: %
Chris@42: \def\missingcharmsg#1{\message{Character missing in OT1 encoding: #1.}}
Chris@42:
Chris@42: % Take account of \c (plain) vs. \, (Texinfo) difference.
Chris@42: \def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi}
Chris@42:
Chris@42: % First, make active non-ASCII characters in order for them to be
Chris@42: % correctly categorized when TeX reads the replacement text of
Chris@42: % macros containing the character definitions.
Chris@42: \setnonasciicharscatcode\active
Chris@42: %
Chris@42: % Latin1 (ISO-8859-1) character definitions.
Chris@42: \def\latonechardefs{%
Chris@42: \gdef^^a0{\tie}
Chris@42: \gdef^^a1{\exclamdown}
Chris@42: \gdef^^a2{\missingcharmsg{CENT SIGN}}
Chris@42: \gdef^^a3{{\pounds}}
Chris@42: \gdef^^a4{\missingcharmsg{CURRENCY SIGN}}
Chris@42: \gdef^^a5{\missingcharmsg{YEN SIGN}}
Chris@42: \gdef^^a6{\missingcharmsg{BROKEN BAR}}
Chris@42: \gdef^^a7{\S}
Chris@42: \gdef^^a8{\"{}}
Chris@42: \gdef^^a9{\copyright}
Chris@42: \gdef^^aa{\ordf}
Chris@42: \gdef^^ab{\guillemetleft}
Chris@42: \gdef^^ac{$\lnot$}
Chris@42: \gdef^^ad{\-}
Chris@42: \gdef^^ae{\registeredsymbol}
Chris@42: \gdef^^af{\={}}
Chris@42: %
Chris@42: \gdef^^b0{\textdegree}
Chris@42: \gdef^^b1{$\pm$}
Chris@42: \gdef^^b2{$^2$}
Chris@42: \gdef^^b3{$^3$}
Chris@42: \gdef^^b4{\'{}}
Chris@42: \gdef^^b5{$\mu$}
Chris@42: \gdef^^b6{\P}
Chris@42: %
Chris@42: \gdef^^b7{$^.$}
Chris@42: \gdef^^b8{\cedilla\ }
Chris@42: \gdef^^b9{$^1$}
Chris@42: \gdef^^ba{\ordm}
Chris@42: %
Chris@42: \gdef^^bb{\guillemetright}
Chris@42: \gdef^^bc{$1\over4$}
Chris@42: \gdef^^bd{$1\over2$}
Chris@42: \gdef^^be{$3\over4$}
Chris@42: \gdef^^bf{\questiondown}
Chris@42: %
Chris@42: \gdef^^c0{\`A}
Chris@42: \gdef^^c1{\'A}
Chris@42: \gdef^^c2{\^A}
Chris@42: \gdef^^c3{\~A}
Chris@42: \gdef^^c4{\"A}
Chris@42: \gdef^^c5{\ringaccent A}
Chris@42: \gdef^^c6{\AE}
Chris@42: \gdef^^c7{\cedilla C}
Chris@42: \gdef^^c8{\`E}
Chris@42: \gdef^^c9{\'E}
Chris@42: \gdef^^ca{\^E}
Chris@42: \gdef^^cb{\"E}
Chris@42: \gdef^^cc{\`I}
Chris@42: \gdef^^cd{\'I}
Chris@42: \gdef^^ce{\^I}
Chris@42: \gdef^^cf{\"I}
Chris@42: %
Chris@42: \gdef^^d0{\DH}
Chris@42: \gdef^^d1{\~N}
Chris@42: \gdef^^d2{\`O}
Chris@42: \gdef^^d3{\'O}
Chris@42: \gdef^^d4{\^O}
Chris@42: \gdef^^d5{\~O}
Chris@42: \gdef^^d6{\"O}
Chris@42: \gdef^^d7{$\times$}
Chris@42: \gdef^^d8{\O}
Chris@42: \gdef^^d9{\`U}
Chris@42: \gdef^^da{\'U}
Chris@42: \gdef^^db{\^U}
Chris@42: \gdef^^dc{\"U}
Chris@42: \gdef^^dd{\'Y}
Chris@42: \gdef^^de{\TH}
Chris@42: \gdef^^df{\ss}
Chris@42: %
Chris@42: \gdef^^e0{\`a}
Chris@42: \gdef^^e1{\'a}
Chris@42: \gdef^^e2{\^a}
Chris@42: \gdef^^e3{\~a}
Chris@42: \gdef^^e4{\"a}
Chris@42: \gdef^^e5{\ringaccent a}
Chris@42: \gdef^^e6{\ae}
Chris@42: \gdef^^e7{\cedilla c}
Chris@42: \gdef^^e8{\`e}
Chris@42: \gdef^^e9{\'e}
Chris@42: \gdef^^ea{\^e}
Chris@42: \gdef^^eb{\"e}
Chris@42: \gdef^^ec{\`{\dotless i}}
Chris@42: \gdef^^ed{\'{\dotless i}}
Chris@42: \gdef^^ee{\^{\dotless i}}
Chris@42: \gdef^^ef{\"{\dotless i}}
Chris@42: %
Chris@42: \gdef^^f0{\dh}
Chris@42: \gdef^^f1{\~n}
Chris@42: \gdef^^f2{\`o}
Chris@42: \gdef^^f3{\'o}
Chris@42: \gdef^^f4{\^o}
Chris@42: \gdef^^f5{\~o}
Chris@42: \gdef^^f6{\"o}
Chris@42: \gdef^^f7{$\div$}
Chris@42: \gdef^^f8{\o}
Chris@42: \gdef^^f9{\`u}
Chris@42: \gdef^^fa{\'u}
Chris@42: \gdef^^fb{\^u}
Chris@42: \gdef^^fc{\"u}
Chris@42: \gdef^^fd{\'y}
Chris@42: \gdef^^fe{\th}
Chris@42: \gdef^^ff{\"y}
Chris@42: }
Chris@42:
Chris@42: % Latin9 (ISO-8859-15) encoding character definitions.
Chris@42: \def\latninechardefs{%
Chris@42: % Encoding is almost identical to Latin1.
Chris@42: \latonechardefs
Chris@42: %
Chris@42: \gdef^^a4{\euro}
Chris@42: \gdef^^a6{\v S}
Chris@42: \gdef^^a8{\v s}
Chris@42: \gdef^^b4{\v Z}
Chris@42: \gdef^^b8{\v z}
Chris@42: \gdef^^bc{\OE}
Chris@42: \gdef^^bd{\oe}
Chris@42: \gdef^^be{\"Y}
Chris@42: }
Chris@42:
Chris@42: % Latin2 (ISO-8859-2) character definitions.
Chris@42: \def\lattwochardefs{%
Chris@42: \gdef^^a0{\tie}
Chris@42: \gdef^^a1{\ogonek{A}}
Chris@42: \gdef^^a2{\u{}}
Chris@42: \gdef^^a3{\L}
Chris@42: \gdef^^a4{\missingcharmsg{CURRENCY SIGN}}
Chris@42: \gdef^^a5{\v L}
Chris@42: \gdef^^a6{\'S}
Chris@42: \gdef^^a7{\S}
Chris@42: \gdef^^a8{\"{}}
Chris@42: \gdef^^a9{\v S}
Chris@42: \gdef^^aa{\cedilla S}
Chris@42: \gdef^^ab{\v T}
Chris@42: \gdef^^ac{\'Z}
Chris@42: \gdef^^ad{\-}
Chris@42: \gdef^^ae{\v Z}
Chris@42: \gdef^^af{\dotaccent Z}
Chris@42: %
Chris@42: \gdef^^b0{\textdegree}
Chris@42: \gdef^^b1{\ogonek{a}}
Chris@42: \gdef^^b2{\ogonek{ }}
Chris@42: \gdef^^b3{\l}
Chris@42: \gdef^^b4{\'{}}
Chris@42: \gdef^^b5{\v l}
Chris@42: \gdef^^b6{\'s}
Chris@42: \gdef^^b7{\v{}}
Chris@42: \gdef^^b8{\cedilla\ }
Chris@42: \gdef^^b9{\v s}
Chris@42: \gdef^^ba{\cedilla s}
Chris@42: \gdef^^bb{\v t}
Chris@42: \gdef^^bc{\'z}
Chris@42: \gdef^^bd{\H{}}
Chris@42: \gdef^^be{\v z}
Chris@42: \gdef^^bf{\dotaccent z}
Chris@42: %
Chris@42: \gdef^^c0{\'R}
Chris@42: \gdef^^c1{\'A}
Chris@42: \gdef^^c2{\^A}
Chris@42: \gdef^^c3{\u A}
Chris@42: \gdef^^c4{\"A}
Chris@42: \gdef^^c5{\'L}
Chris@42: \gdef^^c6{\'C}
Chris@42: \gdef^^c7{\cedilla C}
Chris@42: \gdef^^c8{\v C}
Chris@42: \gdef^^c9{\'E}
Chris@42: \gdef^^ca{\ogonek{E}}
Chris@42: \gdef^^cb{\"E}
Chris@42: \gdef^^cc{\v E}
Chris@42: \gdef^^cd{\'I}
Chris@42: \gdef^^ce{\^I}
Chris@42: \gdef^^cf{\v D}
Chris@42: %
Chris@42: \gdef^^d0{\DH}
Chris@42: \gdef^^d1{\'N}
Chris@42: \gdef^^d2{\v N}
Chris@42: \gdef^^d3{\'O}
Chris@42: \gdef^^d4{\^O}
Chris@42: \gdef^^d5{\H O}
Chris@42: \gdef^^d6{\"O}
Chris@42: \gdef^^d7{$\times$}
Chris@42: \gdef^^d8{\v R}
Chris@42: \gdef^^d9{\ringaccent U}
Chris@42: \gdef^^da{\'U}
Chris@42: \gdef^^db{\H U}
Chris@42: \gdef^^dc{\"U}
Chris@42: \gdef^^dd{\'Y}
Chris@42: \gdef^^de{\cedilla T}
Chris@42: \gdef^^df{\ss}
Chris@42: %
Chris@42: \gdef^^e0{\'r}
Chris@42: \gdef^^e1{\'a}
Chris@42: \gdef^^e2{\^a}
Chris@42: \gdef^^e3{\u a}
Chris@42: \gdef^^e4{\"a}
Chris@42: \gdef^^e5{\'l}
Chris@42: \gdef^^e6{\'c}
Chris@42: \gdef^^e7{\cedilla c}
Chris@42: \gdef^^e8{\v c}
Chris@42: \gdef^^e9{\'e}
Chris@42: \gdef^^ea{\ogonek{e}}
Chris@42: \gdef^^eb{\"e}
Chris@42: \gdef^^ec{\v e}
Chris@42: \gdef^^ed{\'{\dotless{i}}}
Chris@42: \gdef^^ee{\^{\dotless{i}}}
Chris@42: \gdef^^ef{\v d}
Chris@42: %
Chris@42: \gdef^^f0{\dh}
Chris@42: \gdef^^f1{\'n}
Chris@42: \gdef^^f2{\v n}
Chris@42: \gdef^^f3{\'o}
Chris@42: \gdef^^f4{\^o}
Chris@42: \gdef^^f5{\H o}
Chris@42: \gdef^^f6{\"o}
Chris@42: \gdef^^f7{$\div$}
Chris@42: \gdef^^f8{\v r}
Chris@42: \gdef^^f9{\ringaccent u}
Chris@42: \gdef^^fa{\'u}
Chris@42: \gdef^^fb{\H u}
Chris@42: \gdef^^fc{\"u}
Chris@42: \gdef^^fd{\'y}
Chris@42: \gdef^^fe{\cedilla t}
Chris@42: \gdef^^ff{\dotaccent{}}
Chris@42: }
Chris@42:
Chris@42: % UTF-8 character definitions.
Chris@42: %
Chris@42: % This code to support UTF-8 is based on LaTeX's utf8.def, with some
Chris@42: % changes for Texinfo conventions. It is included here under the GPL by
Chris@42: % permission from Frank Mittelbach and the LaTeX team.
Chris@42: %
Chris@42: \newcount\countUTFx
Chris@42: \newcount\countUTFy
Chris@42: \newcount\countUTFz
Chris@42:
Chris@42: \gdef\UTFviiiTwoOctets#1#2{\expandafter
Chris@42: \UTFviiiDefined\csname u8:#1\string #2\endcsname}
Chris@42: %
Chris@42: \gdef\UTFviiiThreeOctets#1#2#3{\expandafter
Chris@42: \UTFviiiDefined\csname u8:#1\string #2\string #3\endcsname}
Chris@42: %
Chris@42: \gdef\UTFviiiFourOctets#1#2#3#4{\expandafter
Chris@42: \UTFviiiDefined\csname u8:#1\string #2\string #3\string #4\endcsname}
Chris@42:
Chris@42: \gdef\UTFviiiDefined#1{%
Chris@42: \ifx #1\relax
Chris@42: \message{\linenumber Unicode char \string #1 not defined for Texinfo}%
Chris@42: \else
Chris@42: \expandafter #1%
Chris@42: \fi
Chris@42: }
Chris@42:
Chris@42: \begingroup
Chris@42: \catcode`\~13
Chris@42: \catcode`\"12
Chris@42:
Chris@42: \def\UTFviiiLoop{%
Chris@42: \global\catcode\countUTFx\active
Chris@42: \uccode`\~\countUTFx
Chris@42: \uppercase\expandafter{\UTFviiiTmp}%
Chris@42: \advance\countUTFx by 1
Chris@42: \ifnum\countUTFx < \countUTFy
Chris@42: \expandafter\UTFviiiLoop
Chris@42: \fi}
Chris@42:
Chris@42: \countUTFx = "C2
Chris@42: \countUTFy = "E0
Chris@42: \def\UTFviiiTmp{%
Chris@42: \xdef~{\noexpand\UTFviiiTwoOctets\string~}}
Chris@42: \UTFviiiLoop
Chris@42:
Chris@42: \countUTFx = "E0
Chris@42: \countUTFy = "F0
Chris@42: \def\UTFviiiTmp{%
Chris@42: \xdef~{\noexpand\UTFviiiThreeOctets\string~}}
Chris@42: \UTFviiiLoop
Chris@42:
Chris@42: \countUTFx = "F0
Chris@42: \countUTFy = "F4
Chris@42: \def\UTFviiiTmp{%
Chris@42: \xdef~{\noexpand\UTFviiiFourOctets\string~}}
Chris@42: \UTFviiiLoop
Chris@42: \endgroup
Chris@42:
Chris@42: \begingroup
Chris@42: \catcode`\"=12
Chris@42: \catcode`\<=12
Chris@42: \catcode`\.=12
Chris@42: \catcode`\,=12
Chris@42: \catcode`\;=12
Chris@42: \catcode`\!=12
Chris@42: \catcode`\~=13
Chris@42:
Chris@42: \gdef\DeclareUnicodeCharacter#1#2{%
Chris@42: \countUTFz = "#1\relax
Chris@42: %\wlog{\space\space defining Unicode char U+#1 (decimal \the\countUTFz)}%
Chris@42: \begingroup
Chris@42: \parseXMLCharref
Chris@42: \def\UTFviiiTwoOctets##1##2{%
Chris@42: \csname u8:##1\string ##2\endcsname}%
Chris@42: \def\UTFviiiThreeOctets##1##2##3{%
Chris@42: \csname u8:##1\string ##2\string ##3\endcsname}%
Chris@42: \def\UTFviiiFourOctets##1##2##3##4{%
Chris@42: \csname u8:##1\string ##2\string ##3\string ##4\endcsname}%
Chris@42: \expandafter\expandafter\expandafter\expandafter
Chris@42: \expandafter\expandafter\expandafter
Chris@42: \gdef\UTFviiiTmp{#2}%
Chris@42: \endgroup}
Chris@42:
Chris@42: \gdef\parseXMLCharref{%
Chris@42: \ifnum\countUTFz < "A0\relax
Chris@42: \errhelp = \EMsimple
Chris@42: \errmessage{Cannot define Unicode char value < 00A0}%
Chris@42: \else\ifnum\countUTFz < "800\relax
Chris@42: \parseUTFviiiA,%
Chris@42: \parseUTFviiiB C\UTFviiiTwoOctets.,%
Chris@42: \else\ifnum\countUTFz < "10000\relax
Chris@42: \parseUTFviiiA;%
Chris@42: \parseUTFviiiA,%
Chris@42: \parseUTFviiiB E\UTFviiiThreeOctets.{,;}%
Chris@42: \else
Chris@42: \parseUTFviiiA;%
Chris@42: \parseUTFviiiA,%
Chris@42: \parseUTFviiiA!%
Chris@42: \parseUTFviiiB F\UTFviiiFourOctets.{!,;}%
Chris@42: \fi\fi\fi
Chris@42: }
Chris@42:
Chris@42: \gdef\parseUTFviiiA#1{%
Chris@42: \countUTFx = \countUTFz
Chris@42: \divide\countUTFz by 64
Chris@42: \countUTFy = \countUTFz
Chris@42: \multiply\countUTFz by 64
Chris@42: \advance\countUTFx by -\countUTFz
Chris@42: \advance\countUTFx by 128
Chris@42: \uccode `#1\countUTFx
Chris@42: \countUTFz = \countUTFy}
Chris@42:
Chris@42: \gdef\parseUTFviiiB#1#2#3#4{%
Chris@42: \advance\countUTFz by "#10\relax
Chris@42: \uccode `#3\countUTFz
Chris@42: \uppercase{\gdef\UTFviiiTmp{#2#3#4}}}
Chris@42: \endgroup
Chris@42:
Chris@42: \def\utfeightchardefs{%
Chris@42: \DeclareUnicodeCharacter{00A0}{\tie}
Chris@42: \DeclareUnicodeCharacter{00A1}{\exclamdown}
Chris@42: \DeclareUnicodeCharacter{00A3}{\pounds}
Chris@42: \DeclareUnicodeCharacter{00A8}{\"{ }}
Chris@42: \DeclareUnicodeCharacter{00A9}{\copyright}
Chris@42: \DeclareUnicodeCharacter{00AA}{\ordf}
Chris@42: \DeclareUnicodeCharacter{00AB}{\guillemetleft}
Chris@42: \DeclareUnicodeCharacter{00AD}{\-}
Chris@42: \DeclareUnicodeCharacter{00AE}{\registeredsymbol}
Chris@42: \DeclareUnicodeCharacter{00AF}{\={ }}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{00B0}{\ringaccent{ }}
Chris@42: \DeclareUnicodeCharacter{00B4}{\'{ }}
Chris@42: \DeclareUnicodeCharacter{00B8}{\cedilla{ }}
Chris@42: \DeclareUnicodeCharacter{00BA}{\ordm}
Chris@42: \DeclareUnicodeCharacter{00BB}{\guillemetright}
Chris@42: \DeclareUnicodeCharacter{00BF}{\questiondown}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{00C0}{\`A}
Chris@42: \DeclareUnicodeCharacter{00C1}{\'A}
Chris@42: \DeclareUnicodeCharacter{00C2}{\^A}
Chris@42: \DeclareUnicodeCharacter{00C3}{\~A}
Chris@42: \DeclareUnicodeCharacter{00C4}{\"A}
Chris@42: \DeclareUnicodeCharacter{00C5}{\AA}
Chris@42: \DeclareUnicodeCharacter{00C6}{\AE}
Chris@42: \DeclareUnicodeCharacter{00C7}{\cedilla{C}}
Chris@42: \DeclareUnicodeCharacter{00C8}{\`E}
Chris@42: \DeclareUnicodeCharacter{00C9}{\'E}
Chris@42: \DeclareUnicodeCharacter{00CA}{\^E}
Chris@42: \DeclareUnicodeCharacter{00CB}{\"E}
Chris@42: \DeclareUnicodeCharacter{00CC}{\`I}
Chris@42: \DeclareUnicodeCharacter{00CD}{\'I}
Chris@42: \DeclareUnicodeCharacter{00CE}{\^I}
Chris@42: \DeclareUnicodeCharacter{00CF}{\"I}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{00D0}{\DH}
Chris@42: \DeclareUnicodeCharacter{00D1}{\~N}
Chris@42: \DeclareUnicodeCharacter{00D2}{\`O}
Chris@42: \DeclareUnicodeCharacter{00D3}{\'O}
Chris@42: \DeclareUnicodeCharacter{00D4}{\^O}
Chris@42: \DeclareUnicodeCharacter{00D5}{\~O}
Chris@42: \DeclareUnicodeCharacter{00D6}{\"O}
Chris@42: \DeclareUnicodeCharacter{00D8}{\O}
Chris@42: \DeclareUnicodeCharacter{00D9}{\`U}
Chris@42: \DeclareUnicodeCharacter{00DA}{\'U}
Chris@42: \DeclareUnicodeCharacter{00DB}{\^U}
Chris@42: \DeclareUnicodeCharacter{00DC}{\"U}
Chris@42: \DeclareUnicodeCharacter{00DD}{\'Y}
Chris@42: \DeclareUnicodeCharacter{00DE}{\TH}
Chris@42: \DeclareUnicodeCharacter{00DF}{\ss}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{00E0}{\`a}
Chris@42: \DeclareUnicodeCharacter{00E1}{\'a}
Chris@42: \DeclareUnicodeCharacter{00E2}{\^a}
Chris@42: \DeclareUnicodeCharacter{00E3}{\~a}
Chris@42: \DeclareUnicodeCharacter{00E4}{\"a}
Chris@42: \DeclareUnicodeCharacter{00E5}{\aa}
Chris@42: \DeclareUnicodeCharacter{00E6}{\ae}
Chris@42: \DeclareUnicodeCharacter{00E7}{\cedilla{c}}
Chris@42: \DeclareUnicodeCharacter{00E8}{\`e}
Chris@42: \DeclareUnicodeCharacter{00E9}{\'e}
Chris@42: \DeclareUnicodeCharacter{00EA}{\^e}
Chris@42: \DeclareUnicodeCharacter{00EB}{\"e}
Chris@42: \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}}
Chris@42: \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}}
Chris@42: \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}}
Chris@42: \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{00F0}{\dh}
Chris@42: \DeclareUnicodeCharacter{00F1}{\~n}
Chris@42: \DeclareUnicodeCharacter{00F2}{\`o}
Chris@42: \DeclareUnicodeCharacter{00F3}{\'o}
Chris@42: \DeclareUnicodeCharacter{00F4}{\^o}
Chris@42: \DeclareUnicodeCharacter{00F5}{\~o}
Chris@42: \DeclareUnicodeCharacter{00F6}{\"o}
Chris@42: \DeclareUnicodeCharacter{00F8}{\o}
Chris@42: \DeclareUnicodeCharacter{00F9}{\`u}
Chris@42: \DeclareUnicodeCharacter{00FA}{\'u}
Chris@42: \DeclareUnicodeCharacter{00FB}{\^u}
Chris@42: \DeclareUnicodeCharacter{00FC}{\"u}
Chris@42: \DeclareUnicodeCharacter{00FD}{\'y}
Chris@42: \DeclareUnicodeCharacter{00FE}{\th}
Chris@42: \DeclareUnicodeCharacter{00FF}{\"y}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{0100}{\=A}
Chris@42: \DeclareUnicodeCharacter{0101}{\=a}
Chris@42: \DeclareUnicodeCharacter{0102}{\u{A}}
Chris@42: \DeclareUnicodeCharacter{0103}{\u{a}}
Chris@42: \DeclareUnicodeCharacter{0104}{\ogonek{A}}
Chris@42: \DeclareUnicodeCharacter{0105}{\ogonek{a}}
Chris@42: \DeclareUnicodeCharacter{0106}{\'C}
Chris@42: \DeclareUnicodeCharacter{0107}{\'c}
Chris@42: \DeclareUnicodeCharacter{0108}{\^C}
Chris@42: \DeclareUnicodeCharacter{0109}{\^c}
Chris@42: \DeclareUnicodeCharacter{0118}{\ogonek{E}}
Chris@42: \DeclareUnicodeCharacter{0119}{\ogonek{e}}
Chris@42: \DeclareUnicodeCharacter{010A}{\dotaccent{C}}
Chris@42: \DeclareUnicodeCharacter{010B}{\dotaccent{c}}
Chris@42: \DeclareUnicodeCharacter{010C}{\v{C}}
Chris@42: \DeclareUnicodeCharacter{010D}{\v{c}}
Chris@42: \DeclareUnicodeCharacter{010E}{\v{D}}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{0112}{\=E}
Chris@42: \DeclareUnicodeCharacter{0113}{\=e}
Chris@42: \DeclareUnicodeCharacter{0114}{\u{E}}
Chris@42: \DeclareUnicodeCharacter{0115}{\u{e}}
Chris@42: \DeclareUnicodeCharacter{0116}{\dotaccent{E}}
Chris@42: \DeclareUnicodeCharacter{0117}{\dotaccent{e}}
Chris@42: \DeclareUnicodeCharacter{011A}{\v{E}}
Chris@42: \DeclareUnicodeCharacter{011B}{\v{e}}
Chris@42: \DeclareUnicodeCharacter{011C}{\^G}
Chris@42: \DeclareUnicodeCharacter{011D}{\^g}
Chris@42: \DeclareUnicodeCharacter{011E}{\u{G}}
Chris@42: \DeclareUnicodeCharacter{011F}{\u{g}}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{0120}{\dotaccent{G}}
Chris@42: \DeclareUnicodeCharacter{0121}{\dotaccent{g}}
Chris@42: \DeclareUnicodeCharacter{0124}{\^H}
Chris@42: \DeclareUnicodeCharacter{0125}{\^h}
Chris@42: \DeclareUnicodeCharacter{0128}{\~I}
Chris@42: \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}}
Chris@42: \DeclareUnicodeCharacter{012A}{\=I}
Chris@42: \DeclareUnicodeCharacter{012B}{\={\dotless{i}}}
Chris@42: \DeclareUnicodeCharacter{012C}{\u{I}}
Chris@42: \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{0130}{\dotaccent{I}}
Chris@42: \DeclareUnicodeCharacter{0131}{\dotless{i}}
Chris@42: \DeclareUnicodeCharacter{0132}{IJ}
Chris@42: \DeclareUnicodeCharacter{0133}{ij}
Chris@42: \DeclareUnicodeCharacter{0134}{\^J}
Chris@42: \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}}
Chris@42: \DeclareUnicodeCharacter{0139}{\'L}
Chris@42: \DeclareUnicodeCharacter{013A}{\'l}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{0141}{\L}
Chris@42: \DeclareUnicodeCharacter{0142}{\l}
Chris@42: \DeclareUnicodeCharacter{0143}{\'N}
Chris@42: \DeclareUnicodeCharacter{0144}{\'n}
Chris@42: \DeclareUnicodeCharacter{0147}{\v{N}}
Chris@42: \DeclareUnicodeCharacter{0148}{\v{n}}
Chris@42: \DeclareUnicodeCharacter{014C}{\=O}
Chris@42: \DeclareUnicodeCharacter{014D}{\=o}
Chris@42: \DeclareUnicodeCharacter{014E}{\u{O}}
Chris@42: \DeclareUnicodeCharacter{014F}{\u{o}}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{0150}{\H{O}}
Chris@42: \DeclareUnicodeCharacter{0151}{\H{o}}
Chris@42: \DeclareUnicodeCharacter{0152}{\OE}
Chris@42: \DeclareUnicodeCharacter{0153}{\oe}
Chris@42: \DeclareUnicodeCharacter{0154}{\'R}
Chris@42: \DeclareUnicodeCharacter{0155}{\'r}
Chris@42: \DeclareUnicodeCharacter{0158}{\v{R}}
Chris@42: \DeclareUnicodeCharacter{0159}{\v{r}}
Chris@42: \DeclareUnicodeCharacter{015A}{\'S}
Chris@42: \DeclareUnicodeCharacter{015B}{\'s}
Chris@42: \DeclareUnicodeCharacter{015C}{\^S}
Chris@42: \DeclareUnicodeCharacter{015D}{\^s}
Chris@42: \DeclareUnicodeCharacter{015E}{\cedilla{S}}
Chris@42: \DeclareUnicodeCharacter{015F}{\cedilla{s}}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{0160}{\v{S}}
Chris@42: \DeclareUnicodeCharacter{0161}{\v{s}}
Chris@42: \DeclareUnicodeCharacter{0162}{\cedilla{t}}
Chris@42: \DeclareUnicodeCharacter{0163}{\cedilla{T}}
Chris@42: \DeclareUnicodeCharacter{0164}{\v{T}}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{0168}{\~U}
Chris@42: \DeclareUnicodeCharacter{0169}{\~u}
Chris@42: \DeclareUnicodeCharacter{016A}{\=U}
Chris@42: \DeclareUnicodeCharacter{016B}{\=u}
Chris@42: \DeclareUnicodeCharacter{016C}{\u{U}}
Chris@42: \DeclareUnicodeCharacter{016D}{\u{u}}
Chris@42: \DeclareUnicodeCharacter{016E}{\ringaccent{U}}
Chris@42: \DeclareUnicodeCharacter{016F}{\ringaccent{u}}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{0170}{\H{U}}
Chris@42: \DeclareUnicodeCharacter{0171}{\H{u}}
Chris@42: \DeclareUnicodeCharacter{0174}{\^W}
Chris@42: \DeclareUnicodeCharacter{0175}{\^w}
Chris@42: \DeclareUnicodeCharacter{0176}{\^Y}
Chris@42: \DeclareUnicodeCharacter{0177}{\^y}
Chris@42: \DeclareUnicodeCharacter{0178}{\"Y}
Chris@42: \DeclareUnicodeCharacter{0179}{\'Z}
Chris@42: \DeclareUnicodeCharacter{017A}{\'z}
Chris@42: \DeclareUnicodeCharacter{017B}{\dotaccent{Z}}
Chris@42: \DeclareUnicodeCharacter{017C}{\dotaccent{z}}
Chris@42: \DeclareUnicodeCharacter{017D}{\v{Z}}
Chris@42: \DeclareUnicodeCharacter{017E}{\v{z}}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{01C4}{D\v{Z}}
Chris@42: \DeclareUnicodeCharacter{01C5}{D\v{z}}
Chris@42: \DeclareUnicodeCharacter{01C6}{d\v{z}}
Chris@42: \DeclareUnicodeCharacter{01C7}{LJ}
Chris@42: \DeclareUnicodeCharacter{01C8}{Lj}
Chris@42: \DeclareUnicodeCharacter{01C9}{lj}
Chris@42: \DeclareUnicodeCharacter{01CA}{NJ}
Chris@42: \DeclareUnicodeCharacter{01CB}{Nj}
Chris@42: \DeclareUnicodeCharacter{01CC}{nj}
Chris@42: \DeclareUnicodeCharacter{01CD}{\v{A}}
Chris@42: \DeclareUnicodeCharacter{01CE}{\v{a}}
Chris@42: \DeclareUnicodeCharacter{01CF}{\v{I}}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}}
Chris@42: \DeclareUnicodeCharacter{01D1}{\v{O}}
Chris@42: \DeclareUnicodeCharacter{01D2}{\v{o}}
Chris@42: \DeclareUnicodeCharacter{01D3}{\v{U}}
Chris@42: \DeclareUnicodeCharacter{01D4}{\v{u}}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{01E2}{\={\AE}}
Chris@42: \DeclareUnicodeCharacter{01E3}{\={\ae}}
Chris@42: \DeclareUnicodeCharacter{01E6}{\v{G}}
Chris@42: \DeclareUnicodeCharacter{01E7}{\v{g}}
Chris@42: \DeclareUnicodeCharacter{01E8}{\v{K}}
Chris@42: \DeclareUnicodeCharacter{01E9}{\v{k}}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}}
Chris@42: \DeclareUnicodeCharacter{01F1}{DZ}
Chris@42: \DeclareUnicodeCharacter{01F2}{Dz}
Chris@42: \DeclareUnicodeCharacter{01F3}{dz}
Chris@42: \DeclareUnicodeCharacter{01F4}{\'G}
Chris@42: \DeclareUnicodeCharacter{01F5}{\'g}
Chris@42: \DeclareUnicodeCharacter{01F8}{\`N}
Chris@42: \DeclareUnicodeCharacter{01F9}{\`n}
Chris@42: \DeclareUnicodeCharacter{01FC}{\'{\AE}}
Chris@42: \DeclareUnicodeCharacter{01FD}{\'{\ae}}
Chris@42: \DeclareUnicodeCharacter{01FE}{\'{\O}}
Chris@42: \DeclareUnicodeCharacter{01FF}{\'{\o}}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{021E}{\v{H}}
Chris@42: \DeclareUnicodeCharacter{021F}{\v{h}}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{0226}{\dotaccent{A}}
Chris@42: \DeclareUnicodeCharacter{0227}{\dotaccent{a}}
Chris@42: \DeclareUnicodeCharacter{0228}{\cedilla{E}}
Chris@42: \DeclareUnicodeCharacter{0229}{\cedilla{e}}
Chris@42: \DeclareUnicodeCharacter{022E}{\dotaccent{O}}
Chris@42: \DeclareUnicodeCharacter{022F}{\dotaccent{o}}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{0232}{\=Y}
Chris@42: \DeclareUnicodeCharacter{0233}{\=y}
Chris@42: \DeclareUnicodeCharacter{0237}{\dotless{j}}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{02DB}{\ogonek{ }}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{1E02}{\dotaccent{B}}
Chris@42: \DeclareUnicodeCharacter{1E03}{\dotaccent{b}}
Chris@42: \DeclareUnicodeCharacter{1E04}{\udotaccent{B}}
Chris@42: \DeclareUnicodeCharacter{1E05}{\udotaccent{b}}
Chris@42: \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}}
Chris@42: \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}}
Chris@42: \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}}
Chris@42: \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}}
Chris@42: \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}}
Chris@42: \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}}
Chris@42: \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}}
Chris@42: \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}}
Chris@42: \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{1E20}{\=G}
Chris@42: \DeclareUnicodeCharacter{1E21}{\=g}
Chris@42: \DeclareUnicodeCharacter{1E22}{\dotaccent{H}}
Chris@42: \DeclareUnicodeCharacter{1E23}{\dotaccent{h}}
Chris@42: \DeclareUnicodeCharacter{1E24}{\udotaccent{H}}
Chris@42: \DeclareUnicodeCharacter{1E25}{\udotaccent{h}}
Chris@42: \DeclareUnicodeCharacter{1E26}{\"H}
Chris@42: \DeclareUnicodeCharacter{1E27}{\"h}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{1E30}{\'K}
Chris@42: \DeclareUnicodeCharacter{1E31}{\'k}
Chris@42: \DeclareUnicodeCharacter{1E32}{\udotaccent{K}}
Chris@42: \DeclareUnicodeCharacter{1E33}{\udotaccent{k}}
Chris@42: \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}}
Chris@42: \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}}
Chris@42: \DeclareUnicodeCharacter{1E36}{\udotaccent{L}}
Chris@42: \DeclareUnicodeCharacter{1E37}{\udotaccent{l}}
Chris@42: \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}}
Chris@42: \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}}
Chris@42: \DeclareUnicodeCharacter{1E3E}{\'M}
Chris@42: \DeclareUnicodeCharacter{1E3F}{\'m}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{1E40}{\dotaccent{M}}
Chris@42: \DeclareUnicodeCharacter{1E41}{\dotaccent{m}}
Chris@42: \DeclareUnicodeCharacter{1E42}{\udotaccent{M}}
Chris@42: \DeclareUnicodeCharacter{1E43}{\udotaccent{m}}
Chris@42: \DeclareUnicodeCharacter{1E44}{\dotaccent{N}}
Chris@42: \DeclareUnicodeCharacter{1E45}{\dotaccent{n}}
Chris@42: \DeclareUnicodeCharacter{1E46}{\udotaccent{N}}
Chris@42: \DeclareUnicodeCharacter{1E47}{\udotaccent{n}}
Chris@42: \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}}
Chris@42: \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{1E54}{\'P}
Chris@42: \DeclareUnicodeCharacter{1E55}{\'p}
Chris@42: \DeclareUnicodeCharacter{1E56}{\dotaccent{P}}
Chris@42: \DeclareUnicodeCharacter{1E57}{\dotaccent{p}}
Chris@42: \DeclareUnicodeCharacter{1E58}{\dotaccent{R}}
Chris@42: \DeclareUnicodeCharacter{1E59}{\dotaccent{r}}
Chris@42: \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}}
Chris@42: \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}}
Chris@42: \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}}
Chris@42: \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{1E60}{\dotaccent{S}}
Chris@42: \DeclareUnicodeCharacter{1E61}{\dotaccent{s}}
Chris@42: \DeclareUnicodeCharacter{1E62}{\udotaccent{S}}
Chris@42: \DeclareUnicodeCharacter{1E63}{\udotaccent{s}}
Chris@42: \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}}
Chris@42: \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}}
Chris@42: \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}}
Chris@42: \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}}
Chris@42: \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}}
Chris@42: \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{1E7C}{\~V}
Chris@42: \DeclareUnicodeCharacter{1E7D}{\~v}
Chris@42: \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}}
Chris@42: \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{1E80}{\`W}
Chris@42: \DeclareUnicodeCharacter{1E81}{\`w}
Chris@42: \DeclareUnicodeCharacter{1E82}{\'W}
Chris@42: \DeclareUnicodeCharacter{1E83}{\'w}
Chris@42: \DeclareUnicodeCharacter{1E84}{\"W}
Chris@42: \DeclareUnicodeCharacter{1E85}{\"w}
Chris@42: \DeclareUnicodeCharacter{1E86}{\dotaccent{W}}
Chris@42: \DeclareUnicodeCharacter{1E87}{\dotaccent{w}}
Chris@42: \DeclareUnicodeCharacter{1E88}{\udotaccent{W}}
Chris@42: \DeclareUnicodeCharacter{1E89}{\udotaccent{w}}
Chris@42: \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}}
Chris@42: \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}}
Chris@42: \DeclareUnicodeCharacter{1E8C}{\"X}
Chris@42: \DeclareUnicodeCharacter{1E8D}{\"x}
Chris@42: \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}}
Chris@42: \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{1E90}{\^Z}
Chris@42: \DeclareUnicodeCharacter{1E91}{\^z}
Chris@42: \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}}
Chris@42: \DeclareUnicodeCharacter{1E93}{\udotaccent{z}}
Chris@42: \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}}
Chris@42: \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}}
Chris@42: \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}}
Chris@42: \DeclareUnicodeCharacter{1E97}{\"t}
Chris@42: \DeclareUnicodeCharacter{1E98}{\ringaccent{w}}
Chris@42: \DeclareUnicodeCharacter{1E99}{\ringaccent{y}}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}}
Chris@42: \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}}
Chris@42: \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}}
Chris@42: \DeclareUnicodeCharacter{1EBC}{\~E}
Chris@42: \DeclareUnicodeCharacter{1EBD}{\~e}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}}
Chris@42: \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}}
Chris@42: \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}}
Chris@42: \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}}
Chris@42: \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{1EF2}{\`Y}
Chris@42: \DeclareUnicodeCharacter{1EF3}{\`y}
Chris@42: \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{1EF8}{\~Y}
Chris@42: \DeclareUnicodeCharacter{1EF9}{\~y}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{2013}{--}
Chris@42: \DeclareUnicodeCharacter{2014}{---}
Chris@42: \DeclareUnicodeCharacter{2018}{\quoteleft}
Chris@42: \DeclareUnicodeCharacter{2019}{\quoteright}
Chris@42: \DeclareUnicodeCharacter{201A}{\quotesinglbase}
Chris@42: \DeclareUnicodeCharacter{201C}{\quotedblleft}
Chris@42: \DeclareUnicodeCharacter{201D}{\quotedblright}
Chris@42: \DeclareUnicodeCharacter{201E}{\quotedblbase}
Chris@42: \DeclareUnicodeCharacter{2022}{\bullet}
Chris@42: \DeclareUnicodeCharacter{2026}{\dots}
Chris@42: \DeclareUnicodeCharacter{2039}{\guilsinglleft}
Chris@42: \DeclareUnicodeCharacter{203A}{\guilsinglright}
Chris@42: \DeclareUnicodeCharacter{20AC}{\euro}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{2192}{\expansion}
Chris@42: \DeclareUnicodeCharacter{21D2}{\result}
Chris@42:
Chris@42: \DeclareUnicodeCharacter{2212}{\minus}
Chris@42: \DeclareUnicodeCharacter{2217}{\point}
Chris@42: \DeclareUnicodeCharacter{2261}{\equiv}
Chris@42: }% end of \utfeightchardefs
Chris@42:
Chris@42:
Chris@42: % US-ASCII character definitions.
Chris@42: \def\asciichardefs{% nothing need be done
Chris@42: \relax
Chris@42: }
Chris@42:
Chris@42: % Make non-ASCII characters printable again for compatibility with
Chris@42: % existing Texinfo documents that may use them, even without declaring a
Chris@42: % document encoding.
Chris@42: %
Chris@42: \setnonasciicharscatcode \other
Chris@42:
Chris@42:
Chris@42: \message{formatting,}
Chris@42:
Chris@42: \newdimen\defaultparindent \defaultparindent = 15pt
Chris@42:
Chris@42: \chapheadingskip = 15pt plus 4pt minus 2pt
Chris@42: \secheadingskip = 12pt plus 3pt minus 2pt
Chris@42: \subsecheadingskip = 9pt plus 2pt minus 2pt
Chris@42:
Chris@42: % Prevent underfull vbox error messages.
Chris@42: \vbadness = 10000
Chris@42:
Chris@42: % Don't be very finicky about underfull hboxes, either.
Chris@42: \hbadness = 6666
Chris@42:
Chris@42: % Following George Bush, get rid of widows and orphans.
Chris@42: \widowpenalty=10000
Chris@42: \clubpenalty=10000
Chris@42:
Chris@42: % Use TeX 3.0's \emergencystretch to help line breaking, but if we're
Chris@42: % using an old version of TeX, don't do anything. We want the amount of
Chris@42: % stretch added to depend on the line length, hence the dependence on
Chris@42: % \hsize. We call this whenever the paper size is set.
Chris@42: %
Chris@42: \def\setemergencystretch{%
Chris@42: \ifx\emergencystretch\thisisundefined
Chris@42: % Allow us to assign to \emergencystretch anyway.
Chris@42: \def\emergencystretch{\dimen0}%
Chris@42: \else
Chris@42: \emergencystretch = .15\hsize
Chris@42: \fi
Chris@42: }
Chris@42:
Chris@42: % Parameters in order: 1) textheight; 2) textwidth;
Chris@42: % 3) voffset; 4) hoffset; 5) binding offset; 6) topskip;
Chris@42: % 7) physical page height; 8) physical page width.
Chris@42: %
Chris@42: % We also call \setleading{\textleading}, so the caller should define
Chris@42: % \textleading. The caller should also set \parskip.
Chris@42: %
Chris@42: \def\internalpagesizes#1#2#3#4#5#6#7#8{%
Chris@42: \voffset = #3\relax
Chris@42: \topskip = #6\relax
Chris@42: \splittopskip = \topskip
Chris@42: %
Chris@42: \vsize = #1\relax
Chris@42: \advance\vsize by \topskip
Chris@42: \outervsize = \vsize
Chris@42: \advance\outervsize by 2\topandbottommargin
Chris@42: \pageheight = \vsize
Chris@42: %
Chris@42: \hsize = #2\relax
Chris@42: \outerhsize = \hsize
Chris@42: \advance\outerhsize by 0.5in
Chris@42: \pagewidth = \hsize
Chris@42: %
Chris@42: \normaloffset = #4\relax
Chris@42: \bindingoffset = #5\relax
Chris@42: %
Chris@42: \ifpdf
Chris@42: \pdfpageheight #7\relax
Chris@42: \pdfpagewidth #8\relax
Chris@42: % if we don't reset these, they will remain at "1 true in" of
Chris@42: % whatever layout pdftex was dumped with.
Chris@42: \pdfhorigin = 1 true in
Chris@42: \pdfvorigin = 1 true in
Chris@42: \fi
Chris@42: %
Chris@42: \setleading{\textleading}
Chris@42: %
Chris@42: \parindent = \defaultparindent
Chris@42: \setemergencystretch
Chris@42: }
Chris@42:
Chris@42: % @letterpaper (the default).
Chris@42: \def\letterpaper{{\globaldefs = 1
Chris@42: \parskip = 3pt plus 2pt minus 1pt
Chris@42: \textleading = 13.2pt
Chris@42: %
Chris@42: % If page is nothing but text, make it come out even.
Chris@42: \internalpagesizes{607.2pt}{6in}% that's 46 lines
Chris@42: {\voffset}{.25in}%
Chris@42: {\bindingoffset}{36pt}%
Chris@42: {11in}{8.5in}%
Chris@42: }}
Chris@42:
Chris@42: % Use @smallbook to reset parameters for 7x9.25 trim size.
Chris@42: \def\smallbook{{\globaldefs = 1
Chris@42: \parskip = 2pt plus 1pt
Chris@42: \textleading = 12pt
Chris@42: %
Chris@42: \internalpagesizes{7.5in}{5in}%
Chris@42: {-.2in}{0in}%
Chris@42: {\bindingoffset}{16pt}%
Chris@42: {9.25in}{7in}%
Chris@42: %
Chris@42: \lispnarrowing = 0.3in
Chris@42: \tolerance = 700
Chris@42: \hfuzz = 1pt
Chris@42: \contentsrightmargin = 0pt
Chris@42: \defbodyindent = .5cm
Chris@42: }}
Chris@42:
Chris@42: % Use @smallerbook to reset parameters for 6x9 trim size.
Chris@42: % (Just testing, parameters still in flux.)
Chris@42: \def\smallerbook{{\globaldefs = 1
Chris@42: \parskip = 1.5pt plus 1pt
Chris@42: \textleading = 12pt
Chris@42: %
Chris@42: \internalpagesizes{7.4in}{4.8in}%
Chris@42: {-.2in}{-.4in}%
Chris@42: {0pt}{14pt}%
Chris@42: {9in}{6in}%
Chris@42: %
Chris@42: \lispnarrowing = 0.25in
Chris@42: \tolerance = 700
Chris@42: \hfuzz = 1pt
Chris@42: \contentsrightmargin = 0pt
Chris@42: \defbodyindent = .4cm
Chris@42: }}
Chris@42:
Chris@42: % Use @afourpaper to print on European A4 paper.
Chris@42: \def\afourpaper{{\globaldefs = 1
Chris@42: \parskip = 3pt plus 2pt minus 1pt
Chris@42: \textleading = 13.2pt
Chris@42: %
Chris@42: % Double-side printing via postscript on Laserjet 4050
Chris@42: % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm.
Chris@42: % To change the settings for a different printer or situation, adjust
Chris@42: % \normaloffset until the front-side and back-side texts align. Then
Chris@42: % do the same for \bindingoffset. You can set these for testing in
Chris@42: % your texinfo source file like this:
Chris@42: % @tex
Chris@42: % \global\normaloffset = -6mm
Chris@42: % \global\bindingoffset = 10mm
Chris@42: % @end tex
Chris@42: \internalpagesizes{673.2pt}{160mm}% that's 51 lines
Chris@42: {\voffset}{\hoffset}%
Chris@42: {\bindingoffset}{44pt}%
Chris@42: {297mm}{210mm}%
Chris@42: %
Chris@42: \tolerance = 700
Chris@42: \hfuzz = 1pt
Chris@42: \contentsrightmargin = 0pt
Chris@42: \defbodyindent = 5mm
Chris@42: }}
Chris@42:
Chris@42: % Use @afivepaper to print on European A5 paper.
Chris@42: % From romildo@urano.iceb.ufop.br, 2 July 2000.
Chris@42: % He also recommends making @example and @lisp be small.
Chris@42: \def\afivepaper{{\globaldefs = 1
Chris@42: \parskip = 2pt plus 1pt minus 0.1pt
Chris@42: \textleading = 12.5pt
Chris@42: %
Chris@42: \internalpagesizes{160mm}{120mm}%
Chris@42: {\voffset}{\hoffset}%
Chris@42: {\bindingoffset}{8pt}%
Chris@42: {210mm}{148mm}%
Chris@42: %
Chris@42: \lispnarrowing = 0.2in
Chris@42: \tolerance = 800
Chris@42: \hfuzz = 1.2pt
Chris@42: \contentsrightmargin = 0pt
Chris@42: \defbodyindent = 2mm
Chris@42: \tableindent = 12mm
Chris@42: }}
Chris@42:
Chris@42: % A specific text layout, 24x15cm overall, intended for A4 paper.
Chris@42: \def\afourlatex{{\globaldefs = 1
Chris@42: \afourpaper
Chris@42: \internalpagesizes{237mm}{150mm}%
Chris@42: {\voffset}{4.6mm}%
Chris@42: {\bindingoffset}{7mm}%
Chris@42: {297mm}{210mm}%
Chris@42: %
Chris@42: % Must explicitly reset to 0 because we call \afourpaper.
Chris@42: \globaldefs = 0
Chris@42: }}
Chris@42:
Chris@42: % Use @afourwide to print on A4 paper in landscape format.
Chris@42: \def\afourwide{{\globaldefs = 1
Chris@42: \afourpaper
Chris@42: \internalpagesizes{241mm}{165mm}%
Chris@42: {\voffset}{-2.95mm}%
Chris@42: {\bindingoffset}{7mm}%
Chris@42: {297mm}{210mm}%
Chris@42: \globaldefs = 0
Chris@42: }}
Chris@42:
Chris@42: % @pagesizes TEXTHEIGHT[,TEXTWIDTH]
Chris@42: % Perhaps we should allow setting the margins, \topskip, \parskip,
Chris@42: % and/or leading, also. Or perhaps we should compute them somehow.
Chris@42: %
Chris@42: \parseargdef\pagesizes{\pagesizesyyy #1,,\finish}
Chris@42: \def\pagesizesyyy#1,#2,#3\finish{{%
Chris@42: \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi
Chris@42: \globaldefs = 1
Chris@42: %
Chris@42: \parskip = 3pt plus 2pt minus 1pt
Chris@42: \setleading{\textleading}%
Chris@42: %
Chris@42: \dimen0 = #1\relax
Chris@42: \advance\dimen0 by \voffset
Chris@42: %
Chris@42: \dimen2 = \hsize
Chris@42: \advance\dimen2 by \normaloffset
Chris@42: %
Chris@42: \internalpagesizes{#1}{\hsize}%
Chris@42: {\voffset}{\normaloffset}%
Chris@42: {\bindingoffset}{44pt}%
Chris@42: {\dimen0}{\dimen2}%
Chris@42: }}
Chris@42:
Chris@42: % Set default to letter.
Chris@42: %
Chris@42: \letterpaper
Chris@42:
Chris@42:
Chris@42: \message{and turning on texinfo input format.}
Chris@42:
Chris@42: \def^^L{\par} % remove \outer, so ^L can appear in an @comment
Chris@42:
Chris@42: % DEL is a comment character, in case @c does not suffice.
Chris@42: \catcode`\^^? = 14
Chris@42:
Chris@42: % Define macros to output various characters with catcode for normal text.
Chris@42: \catcode`\"=\other \def\normaldoublequote{"}
Chris@42: \catcode`\$=\other \def\normaldollar{$}%$ font-lock fix
Chris@42: \catcode`\+=\other \def\normalplus{+}
Chris@42: \catcode`\<=\other \def\normalless{<}
Chris@42: \catcode`\>=\other \def\normalgreater{>}
Chris@42: \catcode`\^=\other \def\normalcaret{^}
Chris@42: \catcode`\_=\other \def\normalunderscore{_}
Chris@42: \catcode`\|=\other \def\normalverticalbar{|}
Chris@42: \catcode`\~=\other \def\normaltilde{~}
Chris@42:
Chris@42: % This macro is used to make a character print one way in \tt
Chris@42: % (where it can probably be output as-is), and another way in other fonts,
Chris@42: % where something hairier probably needs to be done.
Chris@42: %
Chris@42: % #1 is what to print if we are indeed using \tt; #2 is what to print
Chris@42: % otherwise. Since all the Computer Modern typewriter fonts have zero
Chris@42: % interword stretch (and shrink), and it is reasonable to expect all
Chris@42: % typewriter fonts to have this, we can check that font parameter.
Chris@42: %
Chris@42: \def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi}
Chris@42:
Chris@42: % Same as above, but check for italic font. Actually this also catches
Chris@42: % non-italic slanted fonts since it is impossible to distinguish them from
Chris@42: % italic fonts. But since this is only used by $ and it uses \sl anyway
Chris@42: % this is not a problem.
Chris@42: \def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi}
Chris@42:
Chris@42: % Turn off all special characters except @
Chris@42: % (and those which the user can use as if they were ordinary).
Chris@42: % Most of these we simply print from the \tt font, but for some, we can
Chris@42: % use math or other variants that look better in normal text.
Chris@42:
Chris@42: \catcode`\"=\active
Chris@42: \def\activedoublequote{{\tt\char34}}
Chris@42: \let"=\activedoublequote
Chris@42: \catcode`\~=\active
Chris@42: \def~{{\tt\char126}}
Chris@42: \chardef\hat=`\^
Chris@42: \catcode`\^=\active
Chris@42: \def^{{\tt \hat}}
Chris@42:
Chris@42: \catcode`\_=\active
Chris@42: \def_{\ifusingtt\normalunderscore\_}
Chris@42: \let\realunder=_
Chris@42: % Subroutine for the previous macro.
Chris@42: \def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }
Chris@42:
Chris@42: \catcode`\|=\active
Chris@42: \def|{{\tt\char124}}
Chris@42: \chardef \less=`\<
Chris@42: \catcode`\<=\active
Chris@42: \def<{{\tt \less}}
Chris@42: \chardef \gtr=`\>
Chris@42: \catcode`\>=\active
Chris@42: \def>{{\tt \gtr}}
Chris@42: \catcode`\+=\active
Chris@42: \def+{{\tt \char 43}}
Chris@42: \catcode`\$=\active
Chris@42: \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix
Chris@42:
Chris@42: % If a .fmt file is being used, characters that might appear in a file
Chris@42: % name cannot be active until we have parsed the command line.
Chris@42: % So turn them off again, and have \everyjob (or @setfilename) turn them on.
Chris@42: % \otherifyactive is called near the end of this file.
Chris@42: \def\otherifyactive{\catcode`+=\other \catcode`\_=\other}
Chris@42:
Chris@42: % Used sometimes to turn off (effectively) the active characters even after
Chris@42: % parsing them.
Chris@42: \def\turnoffactive{%
Chris@42: \normalturnoffactive
Chris@42: \otherbackslash
Chris@42: }
Chris@42:
Chris@42: \catcode`\@=0
Chris@42:
Chris@42: % \backslashcurfont outputs one backslash character in current font,
Chris@42: % as in \char`\\.
Chris@42: \global\chardef\backslashcurfont=`\\
Chris@42: \global\let\rawbackslashxx=\backslashcurfont % let existing .??s files work
Chris@42:
Chris@42: % \realbackslash is an actual character `\' with catcode other, and
Chris@42: % \doublebackslash is two of them (for the pdf outlines).
Chris@42: {\catcode`\\=\other @gdef@realbackslash{\} @gdef@doublebackslash{\\}}
Chris@42:
Chris@42: % In texinfo, backslash is an active character; it prints the backslash
Chris@42: % in fixed width font.
Chris@42: \catcode`\\=\active % @ for escape char from now on.
Chris@42:
Chris@42: % The story here is that in math mode, the \char of \backslashcurfont
Chris@42: % ends up printing the roman \ from the math symbol font (because \char
Chris@42: % in math mode uses the \mathcode, and plain.tex sets
Chris@42: % \mathcode`\\="026E). It seems better for @backslashchar{} to always
Chris@42: % print a typewriter backslash, hence we use an explicit \mathchar,
Chris@42: % which is the decimal equivalent of "715c (class 7, e.g., use \fam;
Chris@42: % ignored family value; char position "5C). We can't use " for the
Chris@42: % usual hex value because it has already been made active.
Chris@42: @def@normalbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}}
Chris@42: @let@backslashchar = @normalbackslash % @backslashchar{} is for user documents.
Chris@42:
Chris@42: % On startup, @fixbackslash assigns:
Chris@42: % @let \ = @normalbackslash
Chris@42: % \rawbackslash defines an active \ to do \backslashcurfont.
Chris@42: % \otherbackslash defines an active \ to be a literal `\' character with
Chris@42: % catcode other. We switch back and forth between these.
Chris@42: @gdef@rawbackslash{@let\=@backslashcurfont}
Chris@42: @gdef@otherbackslash{@let\=@realbackslash}
Chris@42:
Chris@42: % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of
Chris@42: % the literal character `\'. Also revert - to its normal character, in
Chris@42: % case the active - from code has slipped in.
Chris@42: %
Chris@42: {@catcode`- = @active
Chris@42: @gdef@normalturnoffactive{%
Chris@42: @let-=@normaldash
Chris@42: @let"=@normaldoublequote
Chris@42: @let$=@normaldollar %$ font-lock fix
Chris@42: @let+=@normalplus
Chris@42: @let<=@normalless
Chris@42: @let>=@normalgreater
Chris@42: @let\=@normalbackslash
Chris@42: @let^=@normalcaret
Chris@42: @let_=@normalunderscore
Chris@42: @let|=@normalverticalbar
Chris@42: @let~=@normaltilde
Chris@42: @markupsetuplqdefault
Chris@42: @markupsetuprqdefault
Chris@42: @unsepspaces
Chris@42: }
Chris@42: }
Chris@42:
Chris@42: % Make _ and + \other characters, temporarily.
Chris@42: % This is canceled by @fixbackslash.
Chris@42: @otherifyactive
Chris@42:
Chris@42: % If a .fmt file is being used, we don't want the `\input texinfo' to show up.
Chris@42: % That is what \eatinput is for; after that, the `\' should revert to printing
Chris@42: % a backslash.
Chris@42: %
Chris@42: @gdef@eatinput input texinfo{@fixbackslash}
Chris@42: @global@let\ = @eatinput
Chris@42:
Chris@42: % On the other hand, perhaps the file did not have a `\input texinfo'. Then
Chris@42: % the first `\' in the file would cause an error. This macro tries to fix
Chris@42: % that, assuming it is called before the first `\' could plausibly occur.
Chris@42: % Also turn back on active characters that might appear in the input
Chris@42: % file name, in case not using a pre-dumped format.
Chris@42: %
Chris@42: @gdef@fixbackslash{%
Chris@42: @ifx\@eatinput @let\ = @normalbackslash @fi
Chris@42: @catcode`+=@active
Chris@42: @catcode`@_=@active
Chris@42: }
Chris@42:
Chris@42: % Say @foo, not \foo, in error messages.
Chris@42: @escapechar = `@@
Chris@42:
Chris@42: % These (along with & and #) are made active for url-breaking, so need
Chris@42: % active definitions as the normal characters.
Chris@42: @def@normaldot{.}
Chris@42: @def@normalquest{?}
Chris@42: @def@normalslash{/}
Chris@42:
Chris@42: % These look ok in all fonts, so just make them not special.
Chris@42: % @hashchar{} gets its own user-level command, because of #line.
Chris@42: @catcode`@& = @other @def@normalamp{&}
Chris@42: @catcode`@# = @other @def@normalhash{#}
Chris@42: @catcode`@% = @other @def@normalpercent{%}
Chris@42:
Chris@42: @let @hashchar = @normalhash
Chris@42:
Chris@42: @c Finally, make ` and ' active, so that txicodequoteundirected and
Chris@42: @c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}. If we
Chris@42: @c don't make ` and ' active, @code will not get them as active chars.
Chris@42: @c Do this last of all since we use ` in the previous @catcode assignments.
Chris@42: @catcode`@'=@active
Chris@42: @catcode`@`=@active
Chris@42: @markupsetuplqdefault
Chris@42: @markupsetuprqdefault
Chris@42:
Chris@42: @c Local variables:
Chris@42: @c eval: (add-hook 'write-file-hooks 'time-stamp)
Chris@42: @c page-delimiter: "^\\\\message"
Chris@42: @c time-stamp-start: "def\\\\texinfoversion{"
Chris@42: @c time-stamp-format: "%:y-%02m-%02d.%02H"
Chris@42: @c time-stamp-end: "}"
Chris@42: @c End:
Chris@42:
Chris@42: @c vim:sw=2:
Chris@42:
Chris@42: @ignore
Chris@42: arch-tag: e1b36e32-c96e-4135-a41a-0b2efa2ea115
Chris@42: @end ignore