alpar@18: % texinfo.tex -- TeX macros to handle Texinfo files. alpar@18: % alpar@18: % Load plain if necessary, i.e., if running under initex. alpar@18: \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi alpar@18: % alpar@18: \def\texinfoversion{2003-07-28.08} alpar@18: % alpar@18: % Copyright (C) 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995, alpar@18: % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. alpar@18: % alpar@18: % This texinfo.tex file is free software; you can redistribute it and/or alpar@18: % modify it under the terms of the GNU General Public License as alpar@18: % published by the Free Software Foundation; either version 2, or (at alpar@18: % your option) any later version. alpar@18: % alpar@18: % This texinfo.tex file is distributed in the hope that it will be alpar@18: % useful, but WITHOUT ANY WARRANTY; without even the implied warranty alpar@18: % of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU alpar@18: % General Public License for more details. alpar@18: % alpar@18: % You should have received a copy of the GNU General Public License alpar@18: % along with this texinfo.tex file; see the file COPYING. If not, write alpar@18: % to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, alpar@18: % Boston, MA 02111-1307, USA. alpar@18: % alpar@18: % In other words, you are welcome to use, share and improve this program. alpar@18: % You are forbidden to forbid anyone else to use, share and improve alpar@18: % what you give them. Help stamp out software-hoarding! alpar@18: % alpar@18: % Please try the latest version of texinfo.tex before submitting bug alpar@18: % reports; you can get the latest version from: alpar@18: % ftp://ftp.gnu.org/gnu/texinfo/texinfo.tex alpar@18: % (and all GNU mirrors, see http://www.gnu.org/order/ftp.html) alpar@18: % ftp://tug.org/tex/texinfo.tex alpar@18: % (and all CTAN mirrors, see http://www.ctan.org), alpar@18: % and /home/gd/gnu/doc/texinfo.tex on the GNU machines. alpar@18: % alpar@18: % The GNU Texinfo home page is http://www.gnu.org/software/texinfo. alpar@18: % alpar@18: % The texinfo.tex in any given Texinfo distribution could well be out alpar@18: % of date, so if that's what you're using, please check. alpar@18: % alpar@18: % Send bug reports to bug-texinfo@gnu.org. Please include including a alpar@18: % complete document in each bug report with which we can reproduce the alpar@18: % problem. Patches are, of course, greatly appreciated. alpar@18: % alpar@18: % To process a Texinfo manual with TeX, it's most reliable to use the alpar@18: % texi2dvi shell script that comes with the distribution. For a simple alpar@18: % manual foo.texi, however, you can get away with this: alpar@18: % tex foo.texi alpar@18: % texindex foo.?? alpar@18: % tex foo.texi alpar@18: % tex foo.texi alpar@18: % dvips foo.dvi -o # or whatever; this makes foo.ps. alpar@18: % The extra TeX runs get the cross-reference information correct. alpar@18: % Sometimes one run after texindex suffices, and sometimes you need more alpar@18: % than two; texi2dvi does it as many times as necessary. alpar@18: % alpar@18: % It is possible to adapt texinfo.tex for other languages, to some alpar@18: % extent. You can get the existing language-specific files from the alpar@18: % full Texinfo distribution. alpar@18: alpar@18: \message{Loading texinfo [version \texinfoversion]:} alpar@18: alpar@18: % If in a .fmt file, print the version number alpar@18: % and turn on active characters that we couldn't do earlier because alpar@18: % they might have appeared in the input file name. alpar@18: \everyjob{\message{[Texinfo version \texinfoversion]}% alpar@18: \catcode`+=\active \catcode`\_=\active} alpar@18: alpar@18: \message{Basics,} alpar@18: \chardef\other=12 alpar@18: alpar@18: % We never want plain's \outer definition of \+ in Texinfo. alpar@18: % For @tex, we can use \tabalign. alpar@18: \let\+ = \relax alpar@18: alpar@18: % Save some plain tex macros whose names we will redefine. alpar@18: \let\ptexb=\b alpar@18: \let\ptexbullet=\bullet alpar@18: \let\ptexc=\c alpar@18: \let\ptexcomma=\, alpar@18: \let\ptexdot=\. alpar@18: \let\ptexdots=\dots alpar@18: \let\ptexend=\end alpar@18: \let\ptexequiv=\equiv alpar@18: \let\ptexexclam=\! alpar@18: \let\ptexgtr=> alpar@18: \let\ptexhat=^ alpar@18: \let\ptexi=\i alpar@18: \let\ptexindent=\indent alpar@18: \let\ptexlbrace=\{ alpar@18: \let\ptexless=< alpar@18: \let\ptexplus=+ alpar@18: \let\ptexrbrace=\} alpar@18: \let\ptexslash=\/ alpar@18: \let\ptexstar=\* alpar@18: \let\ptext=\t alpar@18: alpar@18: % If this character appears in an error message or help string, it alpar@18: % starts a new line in the output. alpar@18: \newlinechar = `^^J alpar@18: alpar@18: % Set up fixed words for English if not already set. alpar@18: \ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi alpar@18: \ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi alpar@18: \ifx\putwordfile\undefined \gdef\putwordfile{file}\fi alpar@18: \ifx\putwordin\undefined \gdef\putwordin{in}\fi alpar@18: \ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi alpar@18: \ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi alpar@18: \ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi alpar@18: \ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi alpar@18: \ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi alpar@18: \ifx\putwordNoTitle\undefined \gdef\putwordNoTitle{No Title}\fi alpar@18: \ifx\putwordof\undefined \gdef\putwordof{of}\fi alpar@18: \ifx\putwordon\undefined \gdef\putwordon{on}\fi alpar@18: \ifx\putwordpage\undefined \gdef\putwordpage{page}\fi alpar@18: \ifx\putwordsection\undefined \gdef\putwordsection{section}\fi alpar@18: \ifx\putwordSection\undefined \gdef\putwordSection{Section}\fi alpar@18: \ifx\putwordsee\undefined \gdef\putwordsee{see}\fi alpar@18: \ifx\putwordSee\undefined \gdef\putwordSee{See}\fi alpar@18: \ifx\putwordShortTOC\undefined \gdef\putwordShortTOC{Short Contents}\fi alpar@18: \ifx\putwordTOC\undefined \gdef\putwordTOC{Table of Contents}\fi alpar@18: % alpar@18: \ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi alpar@18: \ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi alpar@18: \ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi alpar@18: \ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi alpar@18: \ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi alpar@18: \ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi alpar@18: \ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi alpar@18: \ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi alpar@18: \ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi alpar@18: \ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi alpar@18: \ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi alpar@18: \ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi alpar@18: % alpar@18: \ifx\putwordDefmac\undefined \gdef\putwordDefmac{Macro}\fi alpar@18: \ifx\putwordDefspec\undefined \gdef\putwordDefspec{Special Form}\fi alpar@18: \ifx\putwordDefvar\undefined \gdef\putwordDefvar{Variable}\fi alpar@18: \ifx\putwordDefopt\undefined \gdef\putwordDefopt{User Option}\fi alpar@18: \ifx\putwordDeftypevar\undefined\gdef\putwordDeftypevar{Variable}\fi alpar@18: \ifx\putwordDeffunc\undefined \gdef\putwordDeffunc{Function}\fi alpar@18: \ifx\putwordDeftypefun\undefined\gdef\putwordDeftypefun{Function}\fi alpar@18: alpar@18: % In some macros, we cannot use the `\? notation---the left quote is alpar@18: % in some cases the escape char. alpar@18: \chardef\colonChar = `\: alpar@18: \chardef\commaChar = `\, alpar@18: \chardef\dotChar = `\. alpar@18: \chardef\equalChar = `\= alpar@18: \chardef\exclamChar= `\! alpar@18: \chardef\questChar = `\? alpar@18: \chardef\semiChar = `\; alpar@18: \chardef\spaceChar = `\ % alpar@18: \chardef\underChar = `\_ alpar@18: alpar@18: % Ignore a token. alpar@18: % alpar@18: \def\gobble#1{} alpar@18: alpar@18: % True if #1 is the empty string, i.e., called like `\ifempty{}'. alpar@18: % alpar@18: \def\ifempty#1{\ifemptyx #1\emptymarkA\emptymarkB}% alpar@18: \def\ifemptyx#1#2\emptymarkB{\ifx #1\emptymarkA}% alpar@18: alpar@18: % Hyphenation fixes. alpar@18: \hyphenation{ap-pen-dix} alpar@18: \hyphenation{eshell} alpar@18: \hyphenation{mini-buf-fer mini-buf-fers} alpar@18: \hyphenation{time-stamp} alpar@18: \hyphenation{white-space} alpar@18: alpar@18: % Margin to add to right of even pages, to left of odd pages. alpar@18: \newdimen\bindingoffset alpar@18: \newdimen\normaloffset alpar@18: \newdimen\pagewidth \newdimen\pageheight alpar@18: alpar@18: % Sometimes it is convenient to have everything in the transcript file alpar@18: % and nothing on the terminal. We don't just call \tracingall here, alpar@18: % since that produces some useless output on the terminal. We also make alpar@18: % some effort to order the tracing commands to reduce output in the log alpar@18: % file; cf. trace.sty in LaTeX. alpar@18: % alpar@18: \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}% alpar@18: \def\loggingall{% alpar@18: \tracingstats2 alpar@18: \tracingpages1 alpar@18: \tracinglostchars2 % 2 gives us more in etex alpar@18: \tracingparagraphs1 alpar@18: \tracingoutput1 alpar@18: \tracingmacros2 alpar@18: \tracingrestores1 alpar@18: \showboxbreadth\maxdimen \showboxdepth\maxdimen alpar@18: \ifx\eTeXversion\undefined\else % etex gives us more logging alpar@18: \tracingscantokens1 alpar@18: \tracingifs1 alpar@18: \tracinggroups1 alpar@18: \tracingnesting2 alpar@18: \tracingassigns1 alpar@18: \fi alpar@18: \tracingcommands3 % 3 gives us more in etex alpar@18: \errorcontextlines\maxdimen alpar@18: }% alpar@18: alpar@18: % add check for \lastpenalty to plain's definitions. If the last thing alpar@18: % we did was a \nobreak, we don't want to insert more space. alpar@18: % alpar@18: \def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount alpar@18: \removelastskip\penalty-50\smallskip\fi\fi} alpar@18: \def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount alpar@18: \removelastskip\penalty-100\medskip\fi\fi} alpar@18: \def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount alpar@18: \removelastskip\penalty-200\bigskip\fi\fi} alpar@18: alpar@18: % For @cropmarks command. alpar@18: % Do @cropmarks to get crop marks. alpar@18: % alpar@18: \newif\ifcropmarks alpar@18: \let\cropmarks = \cropmarkstrue alpar@18: % alpar@18: % Dimensions to add cropmarks at corners. alpar@18: % Added by P. A. MacKay, 12 Nov. 1986 alpar@18: % alpar@18: \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines alpar@18: \newdimen\cornerlong \cornerlong=1pc alpar@18: \newdimen\cornerthick \cornerthick=.3pt alpar@18: \newdimen\topandbottommargin \topandbottommargin=.75in alpar@18: alpar@18: % Main output routine. alpar@18: \chardef\PAGE = 255 alpar@18: \output = {\onepageout{\pagecontents\PAGE}} alpar@18: alpar@18: \newbox\headlinebox alpar@18: \newbox\footlinebox alpar@18: alpar@18: % \onepageout takes a vbox as an argument. Note that \pagecontents alpar@18: % does insertions, but you have to call it yourself. alpar@18: \def\onepageout#1{% alpar@18: \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi alpar@18: % alpar@18: \ifodd\pageno \advance\hoffset by \bindingoffset alpar@18: \else \advance\hoffset by -\bindingoffset\fi alpar@18: % alpar@18: % Do this outside of the \shipout so @code etc. will be expanded in alpar@18: % the headline as they should be, not taken literally (outputting ''code). alpar@18: \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}% alpar@18: \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}% alpar@18: % alpar@18: {% alpar@18: % Have to do this stuff outside the \shipout because we want it to alpar@18: % take effect in \write's, yet the group defined by the \vbox ends alpar@18: % before the \shipout runs. alpar@18: % alpar@18: \escapechar = `\\ % use backslash in output files. alpar@18: \indexdummies % don't expand commands in the output. alpar@18: \normalturnoffactive % \ in index entries must not stay \, e.g., if alpar@18: % the page break happens to be in the middle of an example. alpar@18: \shipout\vbox{% alpar@18: % Do this early so pdf references go to the beginning of the page. alpar@18: \ifpdfmakepagedest \pdfmkdest{\the\pageno} \fi alpar@18: % alpar@18: \ifcropmarks \vbox to \outervsize\bgroup alpar@18: \hsize = \outerhsize alpar@18: \vskip-\topandbottommargin alpar@18: \vtop to0pt{% alpar@18: \line{\ewtop\hfil\ewtop}% alpar@18: \nointerlineskip alpar@18: \line{% alpar@18: \vbox{\moveleft\cornerthick\nstop}% alpar@18: \hfill alpar@18: \vbox{\moveright\cornerthick\nstop}% alpar@18: }% alpar@18: \vss}% alpar@18: \vskip\topandbottommargin alpar@18: \line\bgroup alpar@18: \hfil % center the page within the outer (page) hsize. alpar@18: \ifodd\pageno\hskip\bindingoffset\fi alpar@18: \vbox\bgroup alpar@18: \fi alpar@18: % alpar@18: \unvbox\headlinebox alpar@18: \pagebody{#1}% alpar@18: \ifdim\ht\footlinebox > 0pt alpar@18: % Only leave this space if the footline is nonempty. alpar@18: % (We lessened \vsize for it in \oddfootingxxx.) alpar@18: % The \baselineskip=24pt in plain's \makefootline has no effect. alpar@18: \vskip 2\baselineskip alpar@18: \unvbox\footlinebox alpar@18: \fi alpar@18: % alpar@18: \ifcropmarks alpar@18: \egroup % end of \vbox\bgroup alpar@18: \hfil\egroup % end of (centering) \line\bgroup alpar@18: \vskip\topandbottommargin plus1fill minus1fill alpar@18: \boxmaxdepth = \cornerthick alpar@18: \vbox to0pt{\vss alpar@18: \line{% alpar@18: \vbox{\moveleft\cornerthick\nsbot}% alpar@18: \hfill alpar@18: \vbox{\moveright\cornerthick\nsbot}% alpar@18: }% alpar@18: \nointerlineskip alpar@18: \line{\ewbot\hfil\ewbot}% alpar@18: }% alpar@18: \egroup % \vbox from first cropmarks clause alpar@18: \fi alpar@18: }% end of \shipout\vbox alpar@18: }% end of group with \normalturnoffactive alpar@18: \advancepageno alpar@18: \ifnum\outputpenalty>-20000 \else\dosupereject\fi alpar@18: } alpar@18: alpar@18: \newinsert\margin \dimen\margin=\maxdimen alpar@18: alpar@18: \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}} alpar@18: {\catcode`\@ =11 alpar@18: \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi alpar@18: % marginal hacks, juha@viisa.uucp (Juha Takala) alpar@18: \ifvoid\margin\else % marginal info is present alpar@18: \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi alpar@18: \dimen@=\dp#1 \unvbox#1 alpar@18: \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi alpar@18: \ifr@ggedbottom \kern-\dimen@ \vfil \fi} alpar@18: } alpar@18: alpar@18: % Here are the rules for the cropmarks. Note that they are alpar@18: % offset so that the space between them is truly \outerhsize or \outervsize alpar@18: % (P. A. MacKay, 12 November, 1986) alpar@18: % alpar@18: \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong} alpar@18: \def\nstop{\vbox alpar@18: {\hrule height\cornerthick depth\cornerlong width\cornerthick}} alpar@18: \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong} alpar@18: \def\nsbot{\vbox alpar@18: {\hrule height\cornerlong depth\cornerthick width\cornerthick}} alpar@18: alpar@18: % Parse an argument, then pass it to #1. The argument is the rest of alpar@18: % the input line (except we remove a trailing comment). #1 should be a alpar@18: % macro which expects an ordinary undelimited TeX argument. alpar@18: % alpar@18: \def\parsearg#1{% alpar@18: \let\next = #1% alpar@18: \begingroup alpar@18: \obeylines alpar@18: \futurelet\temp\parseargx alpar@18: } alpar@18: alpar@18: % If the next token is an obeyed space (from an @example environment or alpar@18: % the like), remove it and recurse. Otherwise, we're done. alpar@18: \def\parseargx{% alpar@18: % \obeyedspace is defined far below, after the definition of \sepspaces. alpar@18: \ifx\obeyedspace\temp alpar@18: \expandafter\parseargdiscardspace alpar@18: \else alpar@18: \expandafter\parseargline alpar@18: \fi alpar@18: } alpar@18: alpar@18: % Remove a single space (as the delimiter token to the macro call). alpar@18: {\obeyspaces % alpar@18: \gdef\parseargdiscardspace {\futurelet\temp\parseargx}} alpar@18: alpar@18: {\obeylines % alpar@18: \gdef\parseargline#1^^M{% alpar@18: \endgroup % End of the group started in \parsearg. alpar@18: % alpar@18: % First remove any @c comment, then any @comment. alpar@18: % Result of each macro is put in \toks0. alpar@18: \argremovec #1\c\relax % alpar@18: \expandafter\argremovecomment \the\toks0 \comment\relax % alpar@18: % alpar@18: % Call the caller's macro, saved as \next in \parsearg. alpar@18: \expandafter\next\expandafter{\the\toks0}% alpar@18: }% alpar@18: } alpar@18: alpar@18: % Since all \c{,omment} does is throw away the argument, we can let TeX alpar@18: % do that for us. The \relax here is matched by the \relax in the call alpar@18: % in \parseargline; it could be more or less anything, its purpose is alpar@18: % just to delimit the argument to the \c. alpar@18: \def\argremovec#1\c#2\relax{\toks0 = {#1}} alpar@18: \def\argremovecomment#1\comment#2\relax{\toks0 = {#1}} alpar@18: alpar@18: % \argremovec{,omment} might leave us with trailing spaces, though; e.g., alpar@18: % @end itemize @c foo alpar@18: % will have two active spaces as part of the argument with the alpar@18: % `itemize'. Here we remove all active spaces from #1, and assign the alpar@18: % result to \toks0. alpar@18: % alpar@18: % This loses if there are any *other* active characters besides spaces alpar@18: % in the argument -- _ ^ +, for example -- since they get expanded. alpar@18: % Fortunately, Texinfo does not define any such commands. (If it ever alpar@18: % does, the catcode of the characters in questionwill have to be changed alpar@18: % here.) But this means we cannot call \removeactivespaces as part of alpar@18: % \argremovec{,omment}, since @c uses \parsearg, and thus the argument alpar@18: % that \parsearg gets might well have any character at all in it. alpar@18: % alpar@18: \def\removeactivespaces#1{% alpar@18: \begingroup alpar@18: \ignoreactivespaces alpar@18: \edef\temp{#1}% alpar@18: \global\toks0 = \expandafter{\temp}% alpar@18: \endgroup alpar@18: } alpar@18: alpar@18: % Change the active space to expand to nothing. alpar@18: % alpar@18: \begingroup alpar@18: \obeyspaces alpar@18: \gdef\ignoreactivespaces{\obeyspaces\let =\empty} alpar@18: \endgroup alpar@18: alpar@18: alpar@18: \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next} alpar@18: alpar@18: %% These are used to keep @begin/@end levels from running away alpar@18: %% Call \inENV within environments (after a \begingroup) alpar@18: \newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi} alpar@18: \def\ENVcheck{% alpar@18: \ifENV\errmessage{Still within an environment; press RETURN to continue} alpar@18: \endgroup\fi} % This is not perfect, but it should reduce lossage alpar@18: alpar@18: % @begin foo is the same as @foo, for now. alpar@18: \newhelp\EMsimple{Press RETURN to continue.} alpar@18: alpar@18: \outer\def\begin{\parsearg\beginxxx} alpar@18: alpar@18: \def\beginxxx #1{% alpar@18: \expandafter\ifx\csname #1\endcsname\relax alpar@18: {\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else alpar@18: \csname #1\endcsname\fi} alpar@18: alpar@18: % @end foo executes the definition of \Efoo. alpar@18: % alpar@18: \def\end{\parsearg\endxxx} alpar@18: \def\endxxx #1{% alpar@18: \removeactivespaces{#1}% alpar@18: \edef\endthing{\the\toks0}% alpar@18: % alpar@18: \expandafter\ifx\csname E\endthing\endcsname\relax alpar@18: \expandafter\ifx\csname \endthing\endcsname\relax alpar@18: % There's no \foo, i.e., no ``environment'' foo. alpar@18: \errhelp = \EMsimple alpar@18: \errmessage{Undefined command `@end \endthing'}% alpar@18: \else alpar@18: \unmatchedenderror\endthing alpar@18: \fi alpar@18: \else alpar@18: % Everything's ok; the right environment has been started. alpar@18: \csname E\endthing\endcsname alpar@18: \fi alpar@18: } alpar@18: alpar@18: % There is an environment #1, but it hasn't been started. Give an error. alpar@18: % alpar@18: \def\unmatchedenderror#1{% alpar@18: \errhelp = \EMsimple alpar@18: \errmessage{This `@end #1' doesn't have a matching `@#1'}% alpar@18: } alpar@18: alpar@18: % Define the control sequence \E#1 to give an unmatched @end error. alpar@18: % alpar@18: \def\defineunmatchedend#1{% alpar@18: \expandafter\def\csname E#1\endcsname{\unmatchedenderror{#1}}% alpar@18: } alpar@18: alpar@18: alpar@18: %% Simple single-character @ commands alpar@18: alpar@18: % @@ prints an @ alpar@18: % Kludge this until the fonts are right (grr). alpar@18: \def\@{{\tt\char64}} alpar@18: alpar@18: % This is turned off because it was never documented alpar@18: % and you can use @w{...} around a quote to suppress ligatures. alpar@18: %% Define @` and @' to be the same as ` and ' alpar@18: %% but suppressing ligatures. alpar@18: %\def\`{{`}} alpar@18: %\def\'{{'}} alpar@18: alpar@18: % Used to generate quoted braces. alpar@18: \def\mylbrace {{\tt\char123}} alpar@18: \def\myrbrace {{\tt\char125}} alpar@18: \let\{=\mylbrace alpar@18: \let\}=\myrbrace alpar@18: \begingroup alpar@18: % Definitions to produce \{ and \} commands for indices, alpar@18: % and @{ and @} for the aux file. alpar@18: \catcode`\{ = \other \catcode`\} = \other alpar@18: \catcode`\[ = 1 \catcode`\] = 2 alpar@18: \catcode`\! = 0 \catcode`\\ = \other alpar@18: !gdef!lbracecmd[\{]% alpar@18: !gdef!rbracecmd[\}]% alpar@18: !gdef!lbraceatcmd[@{]% alpar@18: !gdef!rbraceatcmd[@}]% alpar@18: !endgroup alpar@18: alpar@18: % Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent alpar@18: % Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H. alpar@18: \let\, = \c alpar@18: \let\dotaccent = \. alpar@18: \def\ringaccent#1{{\accent23 #1}} alpar@18: \let\tieaccent = \t alpar@18: \let\ubaraccent = \b alpar@18: \let\udotaccent = \d alpar@18: alpar@18: % Other special characters: @questiondown @exclamdown alpar@18: % Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss. alpar@18: \def\questiondown{?`} alpar@18: \def\exclamdown{!`} alpar@18: alpar@18: % Dotless i and dotless j, used for accents. alpar@18: \def\imacro{i} alpar@18: \def\jmacro{j} alpar@18: \def\dotless#1{% alpar@18: \def\temp{#1}% alpar@18: \ifx\temp\imacro \ptexi alpar@18: \else\ifx\temp\jmacro \j alpar@18: \else \errmessage{@dotless can be used only with i or j}% alpar@18: \fi\fi alpar@18: } alpar@18: alpar@18: % Be sure we're in horizontal mode when doing a tie, since we make space alpar@18: % equivalent to this in @example-like environments. Otherwise, a space alpar@18: % at the beginning of a line will start with \penalty -- and alpar@18: % since \penalty is valid in vertical mode, we'd end up putting the alpar@18: % penalty on the vertical list instead of in the new paragraph. alpar@18: {\catcode`@ = 11 alpar@18: % Avoid using \@M directly, because that causes trouble alpar@18: % if the definition is written into an index file. alpar@18: \global\let\tiepenalty = \@M alpar@18: \gdef\tie{\leavevmode\penalty\tiepenalty\ } alpar@18: } alpar@18: alpar@18: % @: forces normal size whitespace following. alpar@18: \def\:{\spacefactor=1000 } alpar@18: alpar@18: % @* forces a line break. alpar@18: \def\*{\hfil\break\hbox{}\ignorespaces} alpar@18: alpar@18: % @/ allows a line break. alpar@18: \let\/=\allowbreak alpar@18: alpar@18: % @. is an end-of-sentence period. alpar@18: \def\.{.\spacefactor=3000 } alpar@18: alpar@18: % @! is an end-of-sentence bang. alpar@18: \def\!{!\spacefactor=3000 } alpar@18: alpar@18: % @? is an end-of-sentence query. alpar@18: \def\?{?\spacefactor=3000 } alpar@18: alpar@18: % @w prevents a word break. Without the \leavevmode, @w at the alpar@18: % beginning of a paragraph, when TeX is still in vertical mode, would alpar@18: % produce a whole line of output instead of starting the paragraph. alpar@18: \def\w#1{\leavevmode\hbox{#1}} alpar@18: alpar@18: % @group ... @end group forces ... to be all on one page, by enclosing alpar@18: % it in a TeX vbox. We use \vtop instead of \vbox to construct the box alpar@18: % to keep its height that of a normal line. According to the rules for alpar@18: % \topskip (p.114 of the TeXbook), the glue inserted is alpar@18: % max (\topskip - \ht (first item), 0). If that height is large, alpar@18: % therefore, no glue is inserted, and the space between the headline and alpar@18: % the text is small, which looks bad. alpar@18: % alpar@18: % Another complication is that the group might be very large. This can alpar@18: % cause the glue on the previous page to be unduly stretched, because it alpar@18: % does not have much material. In this case, it's better to add an alpar@18: % explicit \vfill so that the extra space is at the bottom. The alpar@18: % threshold for doing this is if the group is more than \vfilllimit alpar@18: % percent of a page (\vfilllimit can be changed inside of @tex). alpar@18: % alpar@18: \newbox\groupbox alpar@18: \def\vfilllimit{0.7} alpar@18: % alpar@18: \def\group{\begingroup alpar@18: \ifnum\catcode13=\active \else alpar@18: \errhelp = \groupinvalidhelp alpar@18: \errmessage{@group invalid in context where filling is enabled}% alpar@18: \fi alpar@18: % alpar@18: % The \vtop we start below produces a box with normal height and large alpar@18: % depth; thus, TeX puts \baselineskip glue before it, and (when the alpar@18: % next line of text is done) \lineskip glue after it. (See p.82 of alpar@18: % the TeXbook.) Thus, space below is not quite equal to space alpar@18: % above. But it's pretty close. alpar@18: \def\Egroup{% alpar@18: \egroup % End the \vtop. alpar@18: % \dimen0 is the vertical size of the group's box. alpar@18: \dimen0 = \ht\groupbox \advance\dimen0 by \dp\groupbox alpar@18: % \dimen2 is how much space is left on the page (more or less). alpar@18: \dimen2 = \pageheight \advance\dimen2 by -\pagetotal alpar@18: % if the group doesn't fit on the current page, and it's a big big alpar@18: % group, force a page break. alpar@18: \ifdim \dimen0 > \dimen2 alpar@18: \ifdim \pagetotal < \vfilllimit\pageheight alpar@18: \page alpar@18: \fi alpar@18: \fi alpar@18: \copy\groupbox alpar@18: \endgroup % End the \group. alpar@18: }% alpar@18: % alpar@18: \setbox\groupbox = \vtop\bgroup alpar@18: % We have to put a strut on the last line in case the @group is in alpar@18: % the midst of an example, rather than completely enclosing it. alpar@18: % Otherwise, the interline space between the last line of the group alpar@18: % and the first line afterwards is too small. But we can't put the alpar@18: % strut in \Egroup, since there it would be on a line by itself. alpar@18: % Hence this just inserts a strut at the beginning of each line. alpar@18: \everypar = {\strut}% alpar@18: % alpar@18: % Since we have a strut on every line, we don't need any of TeX's alpar@18: % normal interline spacing. alpar@18: \offinterlineskip alpar@18: % alpar@18: % OK, but now we have to do something about blank alpar@18: % lines in the input in @example-like environments, which normally alpar@18: % just turn into \lisppar, which will insert no space now that we've alpar@18: % turned off the interline space. Simplest is to make them be an alpar@18: % empty paragraph. alpar@18: \ifx\par\lisppar alpar@18: \edef\par{\leavevmode \par}% alpar@18: % alpar@18: % Reset ^^M's definition to new definition of \par. alpar@18: \obeylines alpar@18: \fi alpar@18: % alpar@18: % Do @comment since we are called inside an environment such as alpar@18: % @example, where each end-of-line in the input causes an alpar@18: % end-of-line in the output. We don't want the end-of-line after alpar@18: % the `@group' to put extra space in the output. Since @group alpar@18: % should appear on a line by itself (according to the Texinfo alpar@18: % manual), we don't worry about eating any user text. alpar@18: \comment alpar@18: } alpar@18: % alpar@18: % TeX puts in an \escapechar (i.e., `@') at the beginning of the help alpar@18: % message, so this ends up printing `@group can only ...'. alpar@18: % alpar@18: \newhelp\groupinvalidhelp{% alpar@18: group can only be used in environments such as @example,^^J% alpar@18: where each line of input produces a line of output.} alpar@18: alpar@18: % @need space-in-mils alpar@18: % forces a page break if there is not space-in-mils remaining. alpar@18: alpar@18: \newdimen\mil \mil=0.001in alpar@18: alpar@18: \def\need{\parsearg\needx} alpar@18: alpar@18: % Old definition--didn't work. alpar@18: %\def\needx #1{\par % alpar@18: %% This method tries to make TeX break the page naturally alpar@18: %% if the depth of the box does not fit. alpar@18: %{\baselineskip=0pt% alpar@18: %\vtop to #1\mil{\vfil}\kern -#1\mil\nobreak alpar@18: %\prevdepth=-1000pt alpar@18: %}} alpar@18: alpar@18: \def\needx#1{% alpar@18: % Ensure vertical mode, so we don't make a big box in the middle of a alpar@18: % paragraph. alpar@18: \par alpar@18: % alpar@18: % If the @need value is less than one line space, it's useless. alpar@18: \dimen0 = #1\mil alpar@18: \dimen2 = \ht\strutbox alpar@18: \advance\dimen2 by \dp\strutbox alpar@18: \ifdim\dimen0 > \dimen2 alpar@18: % alpar@18: % Do a \strut just to make the height of this box be normal, so the alpar@18: % normal leading is inserted relative to the preceding line. alpar@18: % And a page break here is fine. alpar@18: \vtop to #1\mil{\strut\vfil}% alpar@18: % alpar@18: % TeX does not even consider page breaks if a penalty added to the alpar@18: % main vertical list is 10000 or more. But in order to see if the alpar@18: % empty box we just added fits on the page, we must make it consider alpar@18: % page breaks. On the other hand, we don't want to actually break the alpar@18: % page after the empty box. So we use a penalty of 9999. alpar@18: % alpar@18: % There is an extremely small chance that TeX will actually break the alpar@18: % page at this \penalty, if there are no other feasible breakpoints in alpar@18: % sight. (If the user is using lots of big @group commands, which alpar@18: % almost-but-not-quite fill up a page, TeX will have a hard time doing alpar@18: % good page breaking, for example.) However, I could not construct an alpar@18: % example where a page broke at this \penalty; if it happens in a real alpar@18: % document, then we can reconsider our strategy. alpar@18: \penalty9999 alpar@18: % alpar@18: % Back up by the size of the box, whether we did a page break or not. alpar@18: \kern -#1\mil alpar@18: % alpar@18: % Do not allow a page break right after this kern. alpar@18: \nobreak alpar@18: \fi alpar@18: } alpar@18: alpar@18: % @br forces paragraph break alpar@18: alpar@18: \let\br = \par alpar@18: alpar@18: % @dots{} output an ellipsis using the current font. alpar@18: % We do .5em per period so that it has the same spacing in a typewriter alpar@18: % font as three actual period characters. alpar@18: % alpar@18: \def\dots{% alpar@18: \leavevmode alpar@18: \hbox to 1.5em{% alpar@18: \hskip 0pt plus 0.25fil minus 0.25fil alpar@18: .\hss.\hss.% alpar@18: \hskip 0pt plus 0.5fil minus 0.5fil alpar@18: }% alpar@18: } alpar@18: alpar@18: % @enddots{} is an end-of-sentence ellipsis. alpar@18: % alpar@18: \def\enddots{% alpar@18: \leavevmode alpar@18: \hbox to 2em{% alpar@18: \hskip 0pt plus 0.25fil minus 0.25fil alpar@18: .\hss.\hss.\hss.% alpar@18: \hskip 0pt plus 0.5fil minus 0.5fil alpar@18: }% alpar@18: \spacefactor=3000 alpar@18: } alpar@18: alpar@18: % @page forces the start of a new page. alpar@18: % alpar@18: \def\page{\par\vfill\supereject} alpar@18: alpar@18: % @exdent text.... alpar@18: % outputs text on separate line in roman font, starting at standard page margin alpar@18: alpar@18: % This records the amount of indent in the innermost environment. alpar@18: % That's how much \exdent should take out. alpar@18: \newskip\exdentamount alpar@18: alpar@18: % This defn is used inside fill environments such as @defun. alpar@18: \def\exdent{\parsearg\exdentyyy} alpar@18: \def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}} alpar@18: alpar@18: % This defn is used inside nofill environments such as @example. alpar@18: \def\nofillexdent{\parsearg\nofillexdentyyy} alpar@18: \def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount alpar@18: \leftline{\hskip\leftskip{\rm#1}}}} alpar@18: alpar@18: % @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current alpar@18: % paragraph. For more general purposes, use the \margin insertion alpar@18: % class. WHICH is `l' or `r'. alpar@18: % alpar@18: \newskip\inmarginspacing \inmarginspacing=1cm alpar@18: \def\strutdepth{\dp\strutbox} alpar@18: % alpar@18: \def\doinmargin#1#2{\strut\vadjust{% alpar@18: \nobreak alpar@18: \kern-\strutdepth alpar@18: \vtop to \strutdepth{% alpar@18: \baselineskip=\strutdepth alpar@18: \vss alpar@18: % if you have multiple lines of stuff to put here, you'll need to alpar@18: % make the vbox yourself of the appropriate size. alpar@18: \ifx#1l% alpar@18: \llap{\ignorespaces #2\hskip\inmarginspacing}% alpar@18: \else alpar@18: \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}% alpar@18: \fi alpar@18: \null alpar@18: }% alpar@18: }} alpar@18: \def\inleftmargin{\doinmargin l} alpar@18: \def\inrightmargin{\doinmargin r} alpar@18: % alpar@18: % @inmargin{TEXT [, RIGHT-TEXT]} alpar@18: % (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right; alpar@18: % else use TEXT for both). alpar@18: % alpar@18: \def\inmargin#1{\parseinmargin #1,,\finish} alpar@18: \def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing. alpar@18: \setbox0 = \hbox{\ignorespaces #2}% alpar@18: \ifdim\wd0 > 0pt alpar@18: \def\lefttext{#1}% have both texts alpar@18: \def\righttext{#2}% alpar@18: \else alpar@18: \def\lefttext{#1}% have only one text alpar@18: \def\righttext{#1}% alpar@18: \fi alpar@18: % alpar@18: \ifodd\pageno alpar@18: \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin alpar@18: \else alpar@18: \def\temp{\inleftmargin\lefttext}% alpar@18: \fi alpar@18: \temp alpar@18: } alpar@18: alpar@18: % @include file insert text of that file as input. alpar@18: % Allow normal characters that we make active in the argument (a file name). alpar@18: \def\include{\begingroup alpar@18: \catcode`\\=\other alpar@18: \catcode`~=\other alpar@18: \catcode`^=\other alpar@18: \catcode`_=\other alpar@18: \catcode`|=\other alpar@18: \catcode`<=\other alpar@18: \catcode`>=\other alpar@18: \catcode`+=\other alpar@18: \parsearg\includezzz} alpar@18: % Restore active chars for included file. alpar@18: \def\includezzz#1{\endgroup\begingroup alpar@18: % Read the included file in a group so nested @include's work. alpar@18: \def\thisfile{#1}% alpar@18: \let\value=\expandablevalue alpar@18: \input\thisfile alpar@18: \endgroup} alpar@18: alpar@18: \def\thisfile{} alpar@18: alpar@18: % @center line alpar@18: % outputs that line, centered. alpar@18: % alpar@18: \def\center{\parsearg\docenter} alpar@18: \def\docenter#1{{% alpar@18: \ifhmode \hfil\break \fi alpar@18: \advance\hsize by -\leftskip alpar@18: \advance\hsize by -\rightskip alpar@18: \line{\hfil \ignorespaces#1\unskip \hfil}% alpar@18: \ifhmode \break \fi alpar@18: }} alpar@18: alpar@18: % @sp n outputs n lines of vertical space alpar@18: alpar@18: \def\sp{\parsearg\spxxx} alpar@18: \def\spxxx #1{\vskip #1\baselineskip} alpar@18: alpar@18: % @comment ...line which is ignored... alpar@18: % @c is the same as @comment alpar@18: % @ignore ... @end ignore is another way to write a comment alpar@18: alpar@18: \def\comment{\begingroup \catcode`\^^M=\other% alpar@18: \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other% alpar@18: \commentxxx} alpar@18: {\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}} alpar@18: alpar@18: \let\c=\comment alpar@18: alpar@18: % @paragraphindent NCHARS alpar@18: % We'll use ems for NCHARS, close enough. alpar@18: % NCHARS can also be the word `asis' or `none'. alpar@18: % We cannot feasibly implement @paragraphindent asis, though. alpar@18: % alpar@18: \def\asisword{asis} % no translation, these are keywords alpar@18: \def\noneword{none} alpar@18: % alpar@18: \def\paragraphindent{\parsearg\doparagraphindent} alpar@18: \def\doparagraphindent#1{% alpar@18: \def\temp{#1}% alpar@18: \ifx\temp\asisword alpar@18: \else alpar@18: \ifx\temp\noneword alpar@18: \defaultparindent = 0pt alpar@18: \else alpar@18: \defaultparindent = #1em alpar@18: \fi alpar@18: \fi alpar@18: \parindent = \defaultparindent alpar@18: } alpar@18: alpar@18: % @exampleindent NCHARS alpar@18: % We'll use ems for NCHARS like @paragraphindent. alpar@18: % It seems @exampleindent asis isn't necessary, but alpar@18: % I preserve it to make it similar to @paragraphindent. alpar@18: \def\exampleindent{\parsearg\doexampleindent} alpar@18: \def\doexampleindent#1{% alpar@18: \def\temp{#1}% alpar@18: \ifx\temp\asisword alpar@18: \else alpar@18: \ifx\temp\noneword alpar@18: \lispnarrowing = 0pt alpar@18: \else alpar@18: \lispnarrowing = #1em alpar@18: \fi alpar@18: \fi alpar@18: } alpar@18: alpar@18: % @firstparagraphindent WORD alpar@18: % If WORD is `none', then suppress indentation of the first paragraph alpar@18: % after a section heading. If WORD is `insert', then do indent at such alpar@18: % paragraphs. alpar@18: % alpar@18: % The paragraph indentation is suppressed or not by calling alpar@18: % \suppressfirstparagraphindent, which the sectioning commands do. alpar@18: % We switch the definition of this back and forth according to WORD. alpar@18: % By default, we suppress indentation. alpar@18: % alpar@18: \def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent} alpar@18: \newdimen\currentparindent alpar@18: % alpar@18: \def\insertword{insert} alpar@18: % alpar@18: \def\firstparagraphindent{\parsearg\dofirstparagraphindent} alpar@18: \def\dofirstparagraphindent#1{% alpar@18: \def\temp{#1}% alpar@18: \ifx\temp\noneword alpar@18: \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent alpar@18: \else\ifx\temp\insertword alpar@18: \let\suppressfirstparagraphindent = \relax alpar@18: \else alpar@18: \errhelp = \EMsimple alpar@18: \errmessage{Unknown @firstparagraphindent option `\temp'}% alpar@18: \fi\fi alpar@18: } alpar@18: alpar@18: % Here is how we actually suppress indentation. Redefine \everypar to alpar@18: % \kern backwards by \parindent, and then reset itself to empty. alpar@18: % alpar@18: % We also make \indent itself not actually do anything until the next alpar@18: % paragraph. alpar@18: % alpar@18: \gdef\dosuppressfirstparagraphindent{% alpar@18: \gdef\indent{% alpar@18: \global\let\indent=\ptexindent alpar@18: \global\everypar = {}% alpar@18: }% alpar@18: \global\everypar = {% alpar@18: \kern-\parindent alpar@18: \global\let\indent=\ptexindent alpar@18: \global\everypar = {}% alpar@18: }% alpar@18: }% alpar@18: alpar@18: alpar@18: % @asis just yields its argument. Used with @table, for example. alpar@18: % alpar@18: \def\asis#1{#1} alpar@18: alpar@18: % @math outputs its argument in math mode. alpar@18: % We don't use $'s directly in the definition of \math because we need alpar@18: % to set catcodes according to plain TeX first, to allow for subscripts, alpar@18: % superscripts, special math chars, etc. alpar@18: % alpar@18: \let\implicitmath = $%$ font-lock fix alpar@18: % alpar@18: % One complication: _ usually means subscripts, but it could also mean alpar@18: % an actual _ character, as in @math{@var{some_variable} + 1}. So make alpar@18: % _ within @math be active (mathcode "8000), and distinguish by seeing alpar@18: % if the current family is \slfam, which is what @var uses. alpar@18: % alpar@18: {\catcode\underChar = \active alpar@18: \gdef\mathunderscore{% alpar@18: \catcode\underChar=\active alpar@18: \def_{\ifnum\fam=\slfam \_\else\sb\fi}% alpar@18: }} alpar@18: % alpar@18: % Another complication: we want \\ (and @\) to output a \ character. alpar@18: % FYI, plain.tex uses \\ as a temporary control sequence (why?), but alpar@18: % this is not advertised and we don't care. Texinfo does not alpar@18: % otherwise define @\. alpar@18: % alpar@18: % The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\. alpar@18: \def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi} alpar@18: % alpar@18: \def\math{% alpar@18: \tex alpar@18: \mathcode`\_="8000 \mathunderscore alpar@18: \let\\ = \mathbackslash alpar@18: \mathactive alpar@18: \implicitmath\finishmath} alpar@18: \def\finishmath#1{#1\implicitmath\Etex} alpar@18: alpar@18: % Some active characters (such as <) are spaced differently in math. alpar@18: % We have to reset their definitions in case the @math was an alpar@18: % argument to a command which set the catcodes (such as @item or @section). alpar@18: % alpar@18: { alpar@18: \catcode`^ = \active alpar@18: \catcode`< = \active alpar@18: \catcode`> = \active alpar@18: \catcode`+ = \active alpar@18: \gdef\mathactive{% alpar@18: \let^ = \ptexhat alpar@18: \let< = \ptexless alpar@18: \let> = \ptexgtr alpar@18: \let+ = \ptexplus alpar@18: } alpar@18: } alpar@18: alpar@18: % @bullet and @minus need the same treatment as @math, just above. alpar@18: \def\bullet{\implicitmath\ptexbullet\implicitmath} alpar@18: \def\minus{\implicitmath-\implicitmath} alpar@18: alpar@18: % @refill is a no-op. alpar@18: \let\refill=\relax alpar@18: alpar@18: % If working on a large document in chapters, it is convenient to alpar@18: % be able to disable indexing, cross-referencing, and contents, for test runs. alpar@18: % This is done with @novalidate (before @setfilename). alpar@18: % alpar@18: \newif\iflinks \linkstrue % by default we want the aux files. alpar@18: \let\novalidate = \linksfalse alpar@18: alpar@18: % @setfilename is done at the beginning of every texinfo file. alpar@18: % So open here the files we need to have open while reading the input. alpar@18: % This makes it possible to make a .fmt file for texinfo. alpar@18: \def\setfilename{% alpar@18: \iflinks alpar@18: \readauxfile alpar@18: \fi % \openindices needs to do some work in any case. alpar@18: \openindices alpar@18: \fixbackslash % Turn off hack to swallow `\input texinfo'. alpar@18: \global\let\setfilename=\comment % Ignore extra @setfilename cmds. alpar@18: % alpar@18: % If texinfo.cnf is present on the system, read it. alpar@18: % Useful for site-wide @afourpaper, etc. alpar@18: % Just to be on the safe side, close the input stream before the \input. alpar@18: \openin 1 texinfo.cnf alpar@18: \ifeof1 \let\temp=\relax \else \def\temp{\input texinfo.cnf }\fi alpar@18: \closein1 alpar@18: \temp alpar@18: % alpar@18: \comment % Ignore the actual filename. alpar@18: } alpar@18: alpar@18: % Called from \setfilename. alpar@18: % alpar@18: \def\openindices{% alpar@18: \newindex{cp}% alpar@18: \newcodeindex{fn}% alpar@18: \newcodeindex{vr}% alpar@18: \newcodeindex{tp}% alpar@18: \newcodeindex{ky}% alpar@18: \newcodeindex{pg}% alpar@18: } alpar@18: alpar@18: % @bye. alpar@18: \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend} alpar@18: alpar@18: alpar@18: \message{pdf,} alpar@18: % adobe `portable' document format alpar@18: \newcount\tempnum alpar@18: \newcount\lnkcount alpar@18: \newtoks\filename alpar@18: \newcount\filenamelength alpar@18: \newcount\pgn alpar@18: \newtoks\toksA alpar@18: \newtoks\toksB alpar@18: \newtoks\toksC alpar@18: \newtoks\toksD alpar@18: \newbox\boxA alpar@18: \newcount\countA alpar@18: \newif\ifpdf alpar@18: \newif\ifpdfmakepagedest alpar@18: alpar@18: \ifx\pdfoutput\undefined alpar@18: \pdffalse alpar@18: \let\pdfmkdest = \gobble alpar@18: \let\pdfurl = \gobble alpar@18: \let\endlink = \relax alpar@18: \let\linkcolor = \relax alpar@18: \let\pdfmakeoutlines = \relax alpar@18: \else alpar@18: \pdftrue alpar@18: \pdfoutput = 1 alpar@18: \input pdfcolor alpar@18: \def\dopdfimage#1#2#3{% alpar@18: \def\imagewidth{#2}% alpar@18: \def\imageheight{#3}% alpar@18: % without \immediate, pdftex seg faults when the same image is alpar@18: % included twice. (Version 3.14159-pre-1.0-unofficial-20010704.) alpar@18: \ifnum\pdftexversion < 14 alpar@18: \immediate\pdfimage alpar@18: \else alpar@18: \immediate\pdfximage alpar@18: \fi alpar@18: \ifx\empty\imagewidth\else width \imagewidth \fi alpar@18: \ifx\empty\imageheight\else height \imageheight \fi alpar@18: \ifnum\pdftexversion<13 alpar@18: #1.pdf% alpar@18: \else alpar@18: {#1.pdf}% alpar@18: \fi alpar@18: \ifnum\pdftexversion < 14 \else alpar@18: \pdfrefximage \pdflastximage alpar@18: \fi} alpar@18: \def\pdfmkdest#1{{\normalturnoffactive \pdfdest name{#1} xyz}} alpar@18: \def\pdfmkpgn#1{#1} alpar@18: \let\linkcolor = \Blue % was Cyan, but that seems light? alpar@18: \def\endlink{\Black\pdfendlink} alpar@18: % Adding outlines to PDF; macros for calculating structure of outlines alpar@18: % come from Petr Olsak alpar@18: \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0% alpar@18: \else \csname#1\endcsname \fi} alpar@18: \def\advancenumber#1{\tempnum=\expnumber{#1}\relax alpar@18: \advance\tempnum by1 alpar@18: \expandafter\xdef\csname#1\endcsname{\the\tempnum}} alpar@18: \def\pdfmakeoutlines{{% alpar@18: \openin 1 \jobname.toc alpar@18: \ifeof 1\else\begingroup alpar@18: \closein 1 alpar@18: % Thanh's hack / proper braces in bookmarks alpar@18: \edef\mylbrace{\iftrue \string{\else}\fi}\let\{=\mylbrace alpar@18: \edef\myrbrace{\iffalse{\else\string}\fi}\let\}=\myrbrace alpar@18: % alpar@18: \def\chapentry ##1##2##3{} alpar@18: \def\secentry ##1##2##3##4{\advancenumber{chap##2}} alpar@18: \def\subsecentry ##1##2##3##4##5{\advancenumber{sec##2.##3}} alpar@18: \def\subsubsecentry ##1##2##3##4##5##6{\advancenumber{subsec##2.##3.##4}} alpar@18: \let\appendixentry = \chapentry alpar@18: \let\unnumbchapentry = \chapentry alpar@18: \let\unnumbsecentry = \secentry alpar@18: \let\unnumbsubsecentry = \subsecentry alpar@18: \let\unnumbsubsubsecentry = \subsubsecentry alpar@18: \input \jobname.toc alpar@18: \def\chapentry ##1##2##3{% alpar@18: \pdfoutline goto name{\pdfmkpgn{##3}}count-\expnumber{chap##2}{##1}} alpar@18: \def\secentry ##1##2##3##4{% alpar@18: \pdfoutline goto name{\pdfmkpgn{##4}}count-\expnumber{sec##2.##3}{##1}} alpar@18: \def\subsecentry ##1##2##3##4##5{% alpar@18: \pdfoutline goto name{\pdfmkpgn{##5}}count-\expnumber{subsec##2.##3.##4}{##1}} alpar@18: \def\subsubsecentry ##1##2##3##4##5##6{% alpar@18: \pdfoutline goto name{\pdfmkpgn{##6}}{##1}} alpar@18: \let\appendixentry = \chapentry alpar@18: \let\unnumbchapentry = \chapentry alpar@18: \let\unnumbsecentry = \secentry alpar@18: \let\unnumbsubsecentry = \subsecentry alpar@18: \let\unnumbsubsubsecentry = \subsubsecentry alpar@18: % alpar@18: % Make special characters normal for writing to the pdf file. alpar@18: % alpar@18: \indexnofonts alpar@18: \let\tt=\relax alpar@18: \turnoffactive alpar@18: \input \jobname.toc alpar@18: \endgroup\fi alpar@18: }} alpar@18: \def\makelinks #1,{% alpar@18: \def\params{#1}\def\E{END}% alpar@18: \ifx\params\E alpar@18: \let\nextmakelinks=\relax alpar@18: \else alpar@18: \let\nextmakelinks=\makelinks alpar@18: \ifnum\lnkcount>0,\fi alpar@18: \picknum{#1}% alpar@18: \startlink attr{/Border [0 0 0]} alpar@18: goto name{\pdfmkpgn{\the\pgn}}% alpar@18: \linkcolor #1% alpar@18: \advance\lnkcount by 1% alpar@18: \endlink alpar@18: \fi alpar@18: \nextmakelinks alpar@18: } alpar@18: \def\picknum#1{\expandafter\pn#1} alpar@18: \def\pn#1{% alpar@18: \def\p{#1}% alpar@18: \ifx\p\lbrace alpar@18: \let\nextpn=\ppn alpar@18: \else alpar@18: \let\nextpn=\ppnn alpar@18: \def\first{#1} alpar@18: \fi alpar@18: \nextpn alpar@18: } alpar@18: \def\ppn#1{\pgn=#1\gobble} alpar@18: \def\ppnn{\pgn=\first} alpar@18: \def\pdfmklnk#1{\lnkcount=0\makelinks #1,END,} alpar@18: \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks} alpar@18: \def\skipspaces#1{\def\PP{#1}\def\D{|}% alpar@18: \ifx\PP\D\let\nextsp\relax alpar@18: \else\let\nextsp\skipspaces alpar@18: \ifx\p\space\else\addtokens{\filename}{\PP}% alpar@18: \advance\filenamelength by 1 alpar@18: \fi alpar@18: \fi alpar@18: \nextsp} alpar@18: \def\getfilename#1{\filenamelength=0\expandafter\skipspaces#1|\relax} alpar@18: \ifnum\pdftexversion < 14 alpar@18: \let \startlink \pdfannotlink alpar@18: \else alpar@18: \let \startlink \pdfstartlink alpar@18: \fi alpar@18: \def\pdfurl#1{% alpar@18: \begingroup alpar@18: \normalturnoffactive\def\@{@}% alpar@18: \let\value=\expandablevalue alpar@18: \leavevmode\Red alpar@18: \startlink attr{/Border [0 0 0]}% alpar@18: user{/Subtype /Link /A << /S /URI /URI (#1) >>}% alpar@18: % #1 alpar@18: \endgroup} alpar@18: \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}} alpar@18: \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks} alpar@18: \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks} alpar@18: \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}} alpar@18: \def\maketoks{% alpar@18: \expandafter\poptoks\the\toksA|ENDTOKS| alpar@18: \ifx\first0\adn0 alpar@18: \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3 alpar@18: \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6 alpar@18: \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9 alpar@18: \else alpar@18: \ifnum0=\countA\else\makelink\fi alpar@18: \ifx\first.\let\next=\done\else alpar@18: \let\next=\maketoks alpar@18: \addtokens{\toksB}{\the\toksD} alpar@18: \ifx\first,\addtokens{\toksB}{\space}\fi alpar@18: \fi alpar@18: \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi alpar@18: \next} alpar@18: \def\makelink{\addtokens{\toksB}% alpar@18: {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0} alpar@18: \def\pdflink#1{% alpar@18: \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}} alpar@18: \linkcolor #1\endlink} alpar@18: \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st} alpar@18: \fi % \ifx\pdfoutput alpar@18: alpar@18: alpar@18: \message{fonts,} alpar@18: % Font-change commands. alpar@18: alpar@18: % Texinfo sort of supports the sans serif font style, which plain TeX does not. alpar@18: % So we set up a \sf analogous to plain's \rm, etc. alpar@18: \newfam\sffam alpar@18: \def\sf{\fam=\sffam \tensf} alpar@18: \let\li = \sf % Sometimes we call it \li, not \sf. alpar@18: alpar@18: % We don't need math for this one. alpar@18: \def\ttsl{\tenttsl} alpar@18: alpar@18: % Default leading. alpar@18: \newdimen\textleading \textleading = 13.2pt alpar@18: alpar@18: % Set the baselineskip to #1, and the lineskip and strut size alpar@18: % correspondingly. There is no deep meaning behind these magic numbers alpar@18: % used as factors; they just match (closely enough) what Knuth defined. alpar@18: % alpar@18: \def\lineskipfactor{.08333} alpar@18: \def\strutheightpercent{.70833} alpar@18: \def\strutdepthpercent {.29167} alpar@18: % alpar@18: \def\setleading#1{% alpar@18: \normalbaselineskip = #1\relax alpar@18: \normallineskip = \lineskipfactor\normalbaselineskip alpar@18: \normalbaselines alpar@18: \setbox\strutbox =\hbox{% alpar@18: \vrule width0pt height\strutheightpercent\baselineskip alpar@18: depth \strutdepthpercent \baselineskip alpar@18: }% alpar@18: } alpar@18: alpar@18: % Set the font macro #1 to the font named #2, adding on the alpar@18: % specified font prefix (normally `cm'). alpar@18: % #3 is the font's design size, #4 is a scale factor alpar@18: \def\setfont#1#2#3#4{\font#1=\fontprefix#2#3 scaled #4} alpar@18: alpar@18: % Use cm as the default font prefix. alpar@18: % To specify the font prefix, you must define \fontprefix alpar@18: % before you read in texinfo.tex. alpar@18: \ifx\fontprefix\undefined alpar@18: \def\fontprefix{cm} alpar@18: \fi alpar@18: % Support font families that don't use the same naming scheme as CM. alpar@18: \def\rmshape{r} alpar@18: \def\rmbshape{bx} %where the normal face is bold alpar@18: \def\bfshape{b} alpar@18: \def\bxshape{bx} alpar@18: \def\ttshape{tt} alpar@18: \def\ttbshape{tt} alpar@18: \def\ttslshape{sltt} alpar@18: \def\itshape{ti} alpar@18: \def\itbshape{bxti} alpar@18: \def\slshape{sl} alpar@18: \def\slbshape{bxsl} alpar@18: \def\sfshape{ss} alpar@18: \def\sfbshape{ss} alpar@18: \def\scshape{csc} alpar@18: \def\scbshape{csc} alpar@18: alpar@18: \newcount\mainmagstep alpar@18: \ifx\bigger\relax alpar@18: % not really supported. alpar@18: \mainmagstep=\magstep1 alpar@18: \setfont\textrm\rmshape{12}{1000} alpar@18: \setfont\texttt\ttshape{12}{1000} alpar@18: \else alpar@18: \mainmagstep=\magstephalf alpar@18: \setfont\textrm\rmshape{10}{\mainmagstep} alpar@18: \setfont\texttt\ttshape{10}{\mainmagstep} alpar@18: \fi alpar@18: % Instead of cmb10, you may want to use cmbx10. alpar@18: % cmbx10 is a prettier font on its own, but cmb10 alpar@18: % looks better when embedded in a line with cmr10 alpar@18: % (in Bob's opinion). alpar@18: \setfont\textbf\bfshape{10}{\mainmagstep} alpar@18: \setfont\textit\itshape{10}{\mainmagstep} alpar@18: \setfont\textsl\slshape{10}{\mainmagstep} alpar@18: \setfont\textsf\sfshape{10}{\mainmagstep} alpar@18: \setfont\textsc\scshape{10}{\mainmagstep} alpar@18: \setfont\textttsl\ttslshape{10}{\mainmagstep} alpar@18: \font\texti=cmmi10 scaled \mainmagstep alpar@18: \font\textsy=cmsy10 scaled \mainmagstep alpar@18: alpar@18: % A few fonts for @defun, etc. alpar@18: \setfont\defbf\bxshape{10}{\magstep1} %was 1314 alpar@18: \setfont\deftt\ttshape{10}{\magstep1} alpar@18: \def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf} alpar@18: alpar@18: % Fonts for indices, footnotes, small examples (9pt). alpar@18: \setfont\smallrm\rmshape{9}{1000} alpar@18: \setfont\smalltt\ttshape{9}{1000} alpar@18: \setfont\smallbf\bfshape{10}{900} alpar@18: \setfont\smallit\itshape{9}{1000} alpar@18: \setfont\smallsl\slshape{9}{1000} alpar@18: \setfont\smallsf\sfshape{9}{1000} alpar@18: \setfont\smallsc\scshape{10}{900} alpar@18: \setfont\smallttsl\ttslshape{10}{900} alpar@18: \font\smalli=cmmi9 alpar@18: \font\smallsy=cmsy9 alpar@18: alpar@18: % Fonts for small examples (8pt). alpar@18: \setfont\smallerrm\rmshape{8}{1000} alpar@18: \setfont\smallertt\ttshape{8}{1000} alpar@18: \setfont\smallerbf\bfshape{10}{800} alpar@18: \setfont\smallerit\itshape{8}{1000} alpar@18: \setfont\smallersl\slshape{8}{1000} alpar@18: \setfont\smallersf\sfshape{8}{1000} alpar@18: \setfont\smallersc\scshape{10}{800} alpar@18: \setfont\smallerttsl\ttslshape{10}{800} alpar@18: \font\smalleri=cmmi8 alpar@18: \font\smallersy=cmsy8 alpar@18: alpar@18: % Fonts for title page: alpar@18: \setfont\titlerm\rmbshape{12}{\magstep3} alpar@18: \setfont\titleit\itbshape{10}{\magstep4} alpar@18: \setfont\titlesl\slbshape{10}{\magstep4} alpar@18: \setfont\titlett\ttbshape{12}{\magstep3} alpar@18: \setfont\titlettsl\ttslshape{10}{\magstep4} alpar@18: \setfont\titlesf\sfbshape{17}{\magstep1} alpar@18: \let\titlebf=\titlerm alpar@18: \setfont\titlesc\scbshape{10}{\magstep4} alpar@18: \font\titlei=cmmi12 scaled \magstep3 alpar@18: \font\titlesy=cmsy10 scaled \magstep4 alpar@18: \def\authorrm{\secrm} alpar@18: \def\authortt{\sectt} alpar@18: alpar@18: % Chapter (and unnumbered) fonts (17.28pt). alpar@18: \setfont\chaprm\rmbshape{12}{\magstep2} alpar@18: \setfont\chapit\itbshape{10}{\magstep3} alpar@18: \setfont\chapsl\slbshape{10}{\magstep3} alpar@18: \setfont\chaptt\ttbshape{12}{\magstep2} alpar@18: \setfont\chapttsl\ttslshape{10}{\magstep3} alpar@18: \setfont\chapsf\sfbshape{17}{1000} alpar@18: \let\chapbf=\chaprm alpar@18: \setfont\chapsc\scbshape{10}{\magstep3} alpar@18: \font\chapi=cmmi12 scaled \magstep2 alpar@18: \font\chapsy=cmsy10 scaled \magstep3 alpar@18: alpar@18: % Section fonts (14.4pt). alpar@18: \setfont\secrm\rmbshape{12}{\magstep1} alpar@18: \setfont\secit\itbshape{10}{\magstep2} alpar@18: \setfont\secsl\slbshape{10}{\magstep2} alpar@18: \setfont\sectt\ttbshape{12}{\magstep1} alpar@18: \setfont\secttsl\ttslshape{10}{\magstep2} alpar@18: \setfont\secsf\sfbshape{12}{\magstep1} alpar@18: \let\secbf\secrm alpar@18: \setfont\secsc\scbshape{10}{\magstep2} alpar@18: \font\seci=cmmi12 scaled \magstep1 alpar@18: \font\secsy=cmsy10 scaled \magstep2 alpar@18: alpar@18: % Subsection fonts (13.15pt). alpar@18: \setfont\ssecrm\rmbshape{12}{\magstephalf} alpar@18: \setfont\ssecit\itbshape{10}{1315} alpar@18: \setfont\ssecsl\slbshape{10}{1315} alpar@18: \setfont\ssectt\ttbshape{12}{\magstephalf} alpar@18: \setfont\ssecttsl\ttslshape{10}{1315} alpar@18: \setfont\ssecsf\sfbshape{12}{\magstephalf} alpar@18: \let\ssecbf\ssecrm alpar@18: \setfont\ssecsc\scbshape{10}{\magstep1} alpar@18: \font\sseci=cmmi12 scaled \magstephalf alpar@18: \font\ssecsy=cmsy10 scaled 1315 alpar@18: % The smallcaps and symbol fonts should actually be scaled \magstep1.5, alpar@18: % but that is not a standard magnification. alpar@18: alpar@18: % In order for the font changes to affect most math symbols and letters, alpar@18: % we have to define the \textfont of the standard families. Since alpar@18: % texinfo doesn't allow for producing subscripts and superscripts except alpar@18: % in the main text, we don't bother to reset \scriptfont and alpar@18: % \scriptscriptfont (which would also require loading a lot more fonts). alpar@18: % alpar@18: \def\resetmathfonts{% alpar@18: \textfont0=\tenrm \textfont1=\teni \textfont2=\tensy alpar@18: \textfont\itfam=\tenit \textfont\slfam=\tensl \textfont\bffam=\tenbf alpar@18: \textfont\ttfam=\tentt \textfont\sffam=\tensf alpar@18: } alpar@18: alpar@18: % The font-changing commands redefine the meanings of \tenSTYLE, instead alpar@18: % of just \STYLE. We do this so that font changes will continue to work alpar@18: % in math mode, where it is the current \fam that is relevant in most alpar@18: % cases, not the current font. Plain TeX does \def\bf{\fam=\bffam alpar@18: % \tenbf}, for example. By redefining \tenbf, we obviate the need to alpar@18: % redefine \bf itself. alpar@18: \def\textfonts{% alpar@18: \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl alpar@18: \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc alpar@18: \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy \let\tenttsl=\textttsl alpar@18: \resetmathfonts \setleading{\textleading}} alpar@18: \def\titlefonts{% alpar@18: \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl alpar@18: \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc alpar@18: \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy alpar@18: \let\tenttsl=\titlettsl alpar@18: \resetmathfonts \setleading{25pt}} alpar@18: \def\titlefont#1{{\titlefonts\rm #1}} alpar@18: \def\chapfonts{% alpar@18: \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl alpar@18: \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc alpar@18: \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy \let\tenttsl=\chapttsl alpar@18: \resetmathfonts \setleading{19pt}} alpar@18: \def\secfonts{% alpar@18: \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl alpar@18: \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc alpar@18: \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy \let\tenttsl=\secttsl alpar@18: \resetmathfonts \setleading{16pt}} alpar@18: \def\subsecfonts{% alpar@18: \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl alpar@18: \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc alpar@18: \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy \let\tenttsl=\ssecttsl alpar@18: \resetmathfonts \setleading{15pt}} alpar@18: \let\subsubsecfonts = \subsecfonts % Maybe make sssec fonts scaled magstephalf? alpar@18: \def\smallfonts{% alpar@18: \let\tenrm=\smallrm \let\tenit=\smallit \let\tensl=\smallsl alpar@18: \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc alpar@18: \let\tensf=\smallsf \let\teni=\smalli \let\tensy=\smallsy alpar@18: \let\tenttsl=\smallttsl alpar@18: \resetmathfonts \setleading{10.5pt}} alpar@18: \def\smallerfonts{% alpar@18: \let\tenrm=\smallerrm \let\tenit=\smallerit \let\tensl=\smallersl alpar@18: \let\tenbf=\smallerbf \let\tentt=\smallertt \let\smallcaps=\smallersc alpar@18: \let\tensf=\smallersf \let\teni=\smalleri \let\tensy=\smallersy alpar@18: \let\tenttsl=\smallerttsl alpar@18: \resetmathfonts \setleading{9.5pt}} alpar@18: alpar@18: % Set the fonts to use with the @small... environments. alpar@18: \let\smallexamplefonts = \smallfonts alpar@18: alpar@18: % About \smallexamplefonts. If we use \smallfonts (9pt), @smallexample alpar@18: % can fit this many characters: alpar@18: % 8.5x11=86 smallbook=72 a4=90 a5=69 alpar@18: % If we use \smallerfonts (8pt), then we can fit this many characters: alpar@18: % 8.5x11=90+ smallbook=80 a4=90+ a5=77 alpar@18: % For me, subjectively, the few extra characters that fit aren't worth alpar@18: % the additional smallness of 8pt. So I'm making the default 9pt. alpar@18: % alpar@18: % By the way, for comparison, here's what fits with @example (10pt): alpar@18: % 8.5x11=71 smallbook=60 a4=75 a5=58 alpar@18: % alpar@18: % I wish we used A4 paper on this side of the Atlantic. alpar@18: % alpar@18: % --karl, 24jan03. alpar@18: alpar@18: alpar@18: % Set up the default fonts, so we can use them for creating boxes. alpar@18: % alpar@18: \textfonts alpar@18: alpar@18: % Define these so they can be easily changed for other fonts. alpar@18: \def\angleleft{$\langle$} alpar@18: \def\angleright{$\rangle$} alpar@18: alpar@18: % Count depth in font-changes, for error checks alpar@18: \newcount\fontdepth \fontdepth=0 alpar@18: alpar@18: % Fonts for short table of contents. alpar@18: \setfont\shortcontrm\rmshape{12}{1000} alpar@18: \setfont\shortcontbf\bxshape{12}{1000} alpar@18: \setfont\shortcontsl\slshape{12}{1000} alpar@18: \setfont\shortconttt\ttshape{12}{1000} alpar@18: alpar@18: %% Add scribe-like font environments, plus @l for inline lisp (usually sans alpar@18: %% serif) and @ii for TeX italic alpar@18: alpar@18: % \smartitalic{ARG} outputs arg in italics, followed by an italic correction alpar@18: % unless the following character is such as not to need one. alpar@18: \def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else alpar@18: \ptexslash\fi\fi\fi} alpar@18: \def\smartslanted#1{{\ifusingtt\ttsl\sl #1}\futurelet\next\smartitalicx} alpar@18: \def\smartitalic#1{{\ifusingtt\ttsl\it #1}\futurelet\next\smartitalicx} alpar@18: alpar@18: \let\i=\smartitalic alpar@18: \let\var=\smartslanted alpar@18: \let\dfn=\smartslanted alpar@18: \let\emph=\smartitalic alpar@18: \let\cite=\smartslanted alpar@18: alpar@18: \def\b#1{{\bf #1}} alpar@18: \let\strong=\b alpar@18: alpar@18: % We can't just use \exhyphenpenalty, because that only has effect at alpar@18: % the end of a paragraph. Restore normal hyphenation at the end of the alpar@18: % group within which \nohyphenation is presumably called. alpar@18: % alpar@18: \def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation} alpar@18: \def\restorehyphenation{\hyphenchar\font = `- } alpar@18: alpar@18: % Set sfcode to normal for the chars that usually have another value. alpar@18: % Can't use plain's \frenchspacing because it uses the `\x notation, and alpar@18: % sometimes \x has an active definition that messes things up. alpar@18: % alpar@18: \catcode`@=11 alpar@18: \def\frenchspacing{% alpar@18: \sfcode\dotChar =\@m \sfcode\questChar=\@m \sfcode\exclamChar=\@m alpar@18: \sfcode\colonChar=\@m \sfcode\semiChar =\@m \sfcode\commaChar =\@m alpar@18: } alpar@18: \catcode`@=\other alpar@18: alpar@18: \def\t#1{% alpar@18: {\tt \rawbackslash \frenchspacing #1}% alpar@18: \null alpar@18: } alpar@18: \let\ttfont=\t alpar@18: \def\samp#1{`\tclose{#1}'\null} alpar@18: \setfont\keyrm\rmshape{8}{1000} alpar@18: \font\keysy=cmsy9 alpar@18: \def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{% alpar@18: \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{% alpar@18: \vbox{\hrule\kern-0.4pt alpar@18: \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}% alpar@18: \kern-0.4pt\hrule}% alpar@18: \kern-.06em\raise0.4pt\hbox{\angleright}}}} alpar@18: % The old definition, with no lozenge: alpar@18: %\def\key #1{{\ttsl \nohyphenation \uppercase{#1}}\null} alpar@18: \def\ctrl #1{{\tt \rawbackslash \hat}#1} alpar@18: alpar@18: % @file, @option are the same as @samp. alpar@18: \let\file=\samp alpar@18: \let\option=\samp alpar@18: alpar@18: % @code is a modification of @t, alpar@18: % which makes spaces the same size as normal in the surrounding text. alpar@18: \def\tclose#1{% alpar@18: {% alpar@18: % Change normal interword space to be same as for the current font. alpar@18: \spaceskip = \fontdimen2\font alpar@18: % alpar@18: % Switch to typewriter. alpar@18: \tt alpar@18: % alpar@18: % But `\ ' produces the large typewriter interword space. alpar@18: \def\ {{\spaceskip = 0pt{} }}% alpar@18: % alpar@18: % Turn off hyphenation. alpar@18: \nohyphenation alpar@18: % alpar@18: \rawbackslash alpar@18: \frenchspacing alpar@18: #1% alpar@18: }% alpar@18: \null alpar@18: } alpar@18: alpar@18: % We *must* turn on hyphenation at `-' and `_' in \code. alpar@18: % Otherwise, it is too hard to avoid overfull hboxes alpar@18: % in the Emacs manual, the Library manual, etc. alpar@18: alpar@18: % Unfortunately, TeX uses one parameter (\hyphenchar) to control alpar@18: % both hyphenation at - and hyphenation within words. alpar@18: % We must therefore turn them both off (\tclose does that) alpar@18: % and arrange explicitly to hyphenate at a dash. alpar@18: % -- rms. alpar@18: { alpar@18: \catcode`\-=\active alpar@18: \catcode`\_=\active alpar@18: % alpar@18: \global\def\code{\begingroup alpar@18: \catcode`\-=\active \let-\codedash alpar@18: \catcode`\_=\active \let_\codeunder alpar@18: \codex alpar@18: } alpar@18: % alpar@18: % If we end up with any active - characters when handling the index, alpar@18: % just treat them as a normal -. alpar@18: \global\def\indexbreaks{\catcode`\-=\active \let-\realdash} alpar@18: } alpar@18: alpar@18: \def\realdash{-} alpar@18: \def\codedash{-\discretionary{}{}{}} alpar@18: \def\codeunder{% alpar@18: % this is all so @math{@code{var_name}+1} can work. In math mode, _ alpar@18: % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.) alpar@18: % will therefore expand the active definition of _, which is us alpar@18: % (inside @code that is), therefore an endless loop. alpar@18: \ifusingtt{\ifmmode alpar@18: \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_. alpar@18: \else\normalunderscore \fi alpar@18: \discretionary{}{}{}}% alpar@18: {\_}% alpar@18: } alpar@18: \def\codex #1{\tclose{#1}\endgroup} alpar@18: alpar@18: % @kbd is like @code, except that if the argument is just one @key command, alpar@18: % then @kbd has no effect. alpar@18: alpar@18: % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always), alpar@18: % `example' (@kbd uses ttsl only inside of @example and friends), alpar@18: % or `code' (@kbd uses normal tty font always). alpar@18: \def\kbdinputstyle{\parsearg\kbdinputstylexxx} alpar@18: \def\kbdinputstylexxx#1{% alpar@18: \def\arg{#1}% alpar@18: \ifx\arg\worddistinct alpar@18: \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}% alpar@18: \else\ifx\arg\wordexample alpar@18: \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}% alpar@18: \else\ifx\arg\wordcode alpar@18: \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}% alpar@18: \else alpar@18: \errhelp = \EMsimple alpar@18: \errmessage{Unknown @kbdinputstyle option `\arg'}% alpar@18: \fi\fi\fi alpar@18: } alpar@18: \def\worddistinct{distinct} alpar@18: \def\wordexample{example} alpar@18: \def\wordcode{code} alpar@18: alpar@18: % Default is `distinct.' alpar@18: \kbdinputstyle distinct alpar@18: alpar@18: \def\xkey{\key} alpar@18: \def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}% alpar@18: \ifx\one\xkey\ifx\threex\three \key{#2}% alpar@18: \else{\tclose{\kbdfont\look}}\fi alpar@18: \else{\tclose{\kbdfont\look}}\fi} alpar@18: alpar@18: % For @url, @env, @command quotes seem unnecessary, so use \code. alpar@18: \let\url=\code alpar@18: \let\env=\code alpar@18: \let\command=\code alpar@18: alpar@18: % @uref (abbreviation for `urlref') takes an optional (comma-separated) alpar@18: % second argument specifying the text to display and an optional third alpar@18: % arg as text to display instead of (rather than in addition to) the url alpar@18: % itself. First (mandatory) arg is the url. Perhaps eventually put in alpar@18: % a hypertex \special here. alpar@18: % alpar@18: \def\uref#1{\douref #1,,,\finish} alpar@18: \def\douref#1,#2,#3,#4\finish{\begingroup alpar@18: \unsepspaces alpar@18: \pdfurl{#1}% alpar@18: \setbox0 = \hbox{\ignorespaces #3}% alpar@18: \ifdim\wd0 > 0pt alpar@18: \unhbox0 % third arg given, show only that alpar@18: \else alpar@18: \setbox0 = \hbox{\ignorespaces #2}% alpar@18: \ifdim\wd0 > 0pt alpar@18: \ifpdf alpar@18: \unhbox0 % PDF: 2nd arg given, show only it alpar@18: \else alpar@18: \unhbox0\ (\code{#1})% DVI: 2nd arg given, show both it and url alpar@18: \fi alpar@18: \else alpar@18: \code{#1}% only url given, so show it alpar@18: \fi alpar@18: \fi alpar@18: \endlink alpar@18: \endgroup} alpar@18: alpar@18: % rms does not like angle brackets --karl, 17may97. alpar@18: % So now @email is just like @uref, unless we are pdf. alpar@18: % alpar@18: %\def\email#1{\angleleft{\tt #1}\angleright} alpar@18: \ifpdf alpar@18: \def\email#1{\doemail#1,,\finish} alpar@18: \def\doemail#1,#2,#3\finish{\begingroup alpar@18: \unsepspaces alpar@18: \pdfurl{mailto:#1}% alpar@18: \setbox0 = \hbox{\ignorespaces #2}% alpar@18: \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi alpar@18: \endlink alpar@18: \endgroup} alpar@18: \else alpar@18: \let\email=\uref alpar@18: \fi alpar@18: alpar@18: % Check if we are currently using a typewriter font. Since all the alpar@18: % Computer Modern typewriter fonts have zero interword stretch (and alpar@18: % shrink), and it is reasonable to expect all typewriter fonts to have alpar@18: % this property, we can check that font parameter. alpar@18: % alpar@18: \def\ifmonospace{\ifdim\fontdimen3\font=0pt } alpar@18: alpar@18: % Typeset a dimension, e.g., `in' or `pt'. The only reason for the alpar@18: % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt. alpar@18: % alpar@18: \def\dmn#1{\thinspace #1} alpar@18: alpar@18: \def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par} alpar@18: alpar@18: % @l was never documented to mean ``switch to the Lisp font'', alpar@18: % and it is not used as such in any manual I can find. We need it for alpar@18: % Polish suppressed-l. --karl, 22sep96. alpar@18: %\def\l#1{{\li #1}\null} alpar@18: alpar@18: % Explicit font changes: @r, @sc, undocumented @ii. alpar@18: \def\r#1{{\rm #1}} % roman font alpar@18: \def\sc#1{{\smallcaps#1}} % smallcaps font alpar@18: \def\ii#1{{\it #1}} % italic font alpar@18: alpar@18: % @acronym downcases the argument and prints in smallcaps. alpar@18: \def\acronym#1{{\smallcaps \lowercase{#1}}} alpar@18: alpar@18: % @pounds{} is a sterling sign. alpar@18: \def\pounds{{\it\$}} alpar@18: alpar@18: % @registeredsymbol - R in a circle. For now, only works in text size; alpar@18: % we'd have to redo the font mechanism to change the \scriptstyle and alpar@18: % \scriptscriptstyle font sizes to make it look right in headings. alpar@18: % Adapted from the plain.tex definition of \copyright. alpar@18: % alpar@18: \def\registeredsymbol{% alpar@18: $^{{\ooalign{\hfil\raise.07ex\hbox{$\scriptstyle\rm R$}\hfil\crcr\Orb}}% alpar@18: }$% alpar@18: } alpar@18: alpar@18: alpar@18: \message{page headings,} alpar@18: alpar@18: \newskip\titlepagetopglue \titlepagetopglue = 1.5in alpar@18: \newskip\titlepagebottomglue \titlepagebottomglue = 2pc alpar@18: alpar@18: % First the title page. Must do @settitle before @titlepage. alpar@18: \newif\ifseenauthor alpar@18: \newif\iffinishedtitlepage alpar@18: alpar@18: % Do an implicit @contents or @shortcontents after @end titlepage if the alpar@18: % user says @setcontentsaftertitlepage or @setshortcontentsaftertitlepage. alpar@18: % alpar@18: \newif\ifsetcontentsaftertitlepage alpar@18: \let\setcontentsaftertitlepage = \setcontentsaftertitlepagetrue alpar@18: \newif\ifsetshortcontentsaftertitlepage alpar@18: \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue alpar@18: alpar@18: \def\shorttitlepage{\parsearg\shorttitlepagezzz} alpar@18: \def\shorttitlepagezzz #1{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}% alpar@18: \endgroup\page\hbox{}\page} alpar@18: alpar@18: \def\titlepage{\begingroup \parindent=0pt \textfonts alpar@18: \let\subtitlerm=\tenrm alpar@18: \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}% alpar@18: % alpar@18: \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines alpar@18: \let\tt=\authortt}% alpar@18: % alpar@18: % Leave some space at the very top of the page. alpar@18: \vglue\titlepagetopglue alpar@18: % alpar@18: % Now you can print the title using @title. alpar@18: \def\title{\parsearg\titlezzz}% alpar@18: \def\titlezzz##1{\leftline{\titlefonts\rm ##1} alpar@18: % print a rule at the page bottom also. alpar@18: \finishedtitlepagefalse alpar@18: \vskip4pt \hrule height 4pt width \hsize \vskip4pt}% alpar@18: % No rule at page bottom unless we print one at the top with @title. alpar@18: \finishedtitlepagetrue alpar@18: % alpar@18: % Now you can put text using @subtitle. alpar@18: \def\subtitle{\parsearg\subtitlezzz}% alpar@18: \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}% alpar@18: % alpar@18: % @author should come last, but may come many times. alpar@18: \def\author{\parsearg\authorzzz}% alpar@18: \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi alpar@18: {\authorfont \leftline{##1}}}% alpar@18: % alpar@18: % Most title ``pages'' are actually two pages long, with space alpar@18: % at the top of the second. We don't want the ragged left on the second. alpar@18: \let\oldpage = \page alpar@18: \def\page{% alpar@18: \iffinishedtitlepage\else alpar@18: \finishtitlepage alpar@18: \fi alpar@18: \oldpage alpar@18: \let\page = \oldpage alpar@18: \hbox{}}% alpar@18: % \def\page{\oldpage \hbox{}} alpar@18: } alpar@18: alpar@18: \def\Etitlepage{% alpar@18: \iffinishedtitlepage\else alpar@18: \finishtitlepage alpar@18: \fi alpar@18: % It is important to do the page break before ending the group, alpar@18: % because the headline and footline are only empty inside the group. alpar@18: % If we use the new definition of \page, we always get a blank page alpar@18: % after the title page, which we certainly don't want. alpar@18: \oldpage alpar@18: \endgroup alpar@18: % alpar@18: % Need this before the \...aftertitlepage checks so that if they are alpar@18: % in effect the toc pages will come out with page numbers. alpar@18: \HEADINGSon alpar@18: % alpar@18: % If they want short, they certainly want long too. alpar@18: \ifsetshortcontentsaftertitlepage alpar@18: \shortcontents alpar@18: \contents alpar@18: \global\let\shortcontents = \relax alpar@18: \global\let\contents = \relax alpar@18: \fi alpar@18: % alpar@18: \ifsetcontentsaftertitlepage alpar@18: \contents alpar@18: \global\let\contents = \relax alpar@18: \global\let\shortcontents = \relax alpar@18: \fi alpar@18: } alpar@18: alpar@18: \def\finishtitlepage{% alpar@18: \vskip4pt \hrule height 2pt width \hsize alpar@18: \vskip\titlepagebottomglue alpar@18: \finishedtitlepagetrue alpar@18: } alpar@18: alpar@18: %%% Set up page headings and footings. alpar@18: alpar@18: \let\thispage=\folio alpar@18: alpar@18: \newtoks\evenheadline % headline on even pages alpar@18: \newtoks\oddheadline % headline on odd pages alpar@18: \newtoks\evenfootline % footline on even pages alpar@18: \newtoks\oddfootline % footline on odd pages alpar@18: alpar@18: % Now make Tex use those variables alpar@18: \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline alpar@18: \else \the\evenheadline \fi}} alpar@18: \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline alpar@18: \else \the\evenfootline \fi}\HEADINGShook} alpar@18: \let\HEADINGShook=\relax alpar@18: alpar@18: % Commands to set those variables. alpar@18: % For example, this is what @headings on does alpar@18: % @evenheading @thistitle|@thispage|@thischapter alpar@18: % @oddheading @thischapter|@thispage|@thistitle alpar@18: % @evenfooting @thisfile|| alpar@18: % @oddfooting ||@thisfile alpar@18: alpar@18: \def\evenheading{\parsearg\evenheadingxxx} alpar@18: \def\oddheading{\parsearg\oddheadingxxx} alpar@18: \def\everyheading{\parsearg\everyheadingxxx} alpar@18: alpar@18: \def\evenfooting{\parsearg\evenfootingxxx} alpar@18: \def\oddfooting{\parsearg\oddfootingxxx} alpar@18: \def\everyfooting{\parsearg\everyfootingxxx} alpar@18: alpar@18: {\catcode`\@=0 % alpar@18: alpar@18: \gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish} alpar@18: \gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{% alpar@18: \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} alpar@18: alpar@18: \gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish} alpar@18: \gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{% alpar@18: \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} alpar@18: alpar@18: \gdef\everyheadingxxx#1{\oddheadingxxx{#1}\evenheadingxxx{#1}}% alpar@18: alpar@18: \gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish} alpar@18: \gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{% alpar@18: \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} alpar@18: alpar@18: \gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish} alpar@18: \gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{% alpar@18: \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}% alpar@18: % alpar@18: % Leave some space for the footline. Hopefully ok to assume alpar@18: % @evenfooting will not be used by itself. alpar@18: \global\advance\pageheight by -\baselineskip alpar@18: \global\advance\vsize by -\baselineskip alpar@18: } alpar@18: alpar@18: \gdef\everyfootingxxx#1{\oddfootingxxx{#1}\evenfootingxxx{#1}} alpar@18: % alpar@18: }% unbind the catcode of @. alpar@18: alpar@18: % @headings double turns headings on for double-sided printing. alpar@18: % @headings single turns headings on for single-sided printing. alpar@18: % @headings off turns them off. alpar@18: % @headings on same as @headings double, retained for compatibility. alpar@18: % @headings after turns on double-sided headings after this page. alpar@18: % @headings doubleafter turns on double-sided headings after this page. alpar@18: % @headings singleafter turns on single-sided headings after this page. alpar@18: % By default, they are off at the start of a document, alpar@18: % and turned `on' after @end titlepage. alpar@18: alpar@18: \def\headings #1 {\csname HEADINGS#1\endcsname} alpar@18: alpar@18: \def\HEADINGSoff{ alpar@18: \global\evenheadline={\hfil} \global\evenfootline={\hfil} alpar@18: \global\oddheadline={\hfil} \global\oddfootline={\hfil}} alpar@18: \HEADINGSoff alpar@18: % When we turn headings on, set the page number to 1. alpar@18: % For double-sided printing, put current file name in lower left corner, alpar@18: % chapter name on inside top of right hand pages, document alpar@18: % title on inside top of left hand pages, and page numbers on outside top alpar@18: % edge of all pages. alpar@18: \def\HEADINGSdouble{ alpar@18: \global\pageno=1 alpar@18: \global\evenfootline={\hfil} alpar@18: \global\oddfootline={\hfil} alpar@18: \global\evenheadline={\line{\folio\hfil\thistitle}} alpar@18: \global\oddheadline={\line{\thischapter\hfil\folio}} alpar@18: \global\let\contentsalignmacro = \chapoddpage alpar@18: } alpar@18: \let\contentsalignmacro = \chappager alpar@18: alpar@18: % For single-sided printing, chapter title goes across top left of page, alpar@18: % page number on top right. alpar@18: \def\HEADINGSsingle{ alpar@18: \global\pageno=1 alpar@18: \global\evenfootline={\hfil} alpar@18: \global\oddfootline={\hfil} alpar@18: \global\evenheadline={\line{\thischapter\hfil\folio}} alpar@18: \global\oddheadline={\line{\thischapter\hfil\folio}} alpar@18: \global\let\contentsalignmacro = \chappager alpar@18: } alpar@18: \def\HEADINGSon{\HEADINGSdouble} alpar@18: alpar@18: \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex} alpar@18: \let\HEADINGSdoubleafter=\HEADINGSafter alpar@18: \def\HEADINGSdoublex{% alpar@18: \global\evenfootline={\hfil} alpar@18: \global\oddfootline={\hfil} alpar@18: \global\evenheadline={\line{\folio\hfil\thistitle}} alpar@18: \global\oddheadline={\line{\thischapter\hfil\folio}} alpar@18: \global\let\contentsalignmacro = \chapoddpage alpar@18: } alpar@18: alpar@18: \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex} alpar@18: \def\HEADINGSsinglex{% alpar@18: \global\evenfootline={\hfil} alpar@18: \global\oddfootline={\hfil} alpar@18: \global\evenheadline={\line{\thischapter\hfil\folio}} alpar@18: \global\oddheadline={\line{\thischapter\hfil\folio}} alpar@18: \global\let\contentsalignmacro = \chappager alpar@18: } alpar@18: alpar@18: % Subroutines used in generating headings alpar@18: % This produces Day Month Year style of output. alpar@18: % Only define if not already defined, in case a txi-??.tex file has set alpar@18: % up a different format (e.g., txi-cs.tex does this). alpar@18: \ifx\today\undefined alpar@18: \def\today{% alpar@18: \number\day\space alpar@18: \ifcase\month alpar@18: \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr alpar@18: \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug alpar@18: \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec alpar@18: \fi alpar@18: \space\number\year} alpar@18: \fi alpar@18: alpar@18: % @settitle line... specifies the title of the document, for headings. alpar@18: % It generates no output of its own. alpar@18: \def\thistitle{\putwordNoTitle} alpar@18: \def\settitle{\parsearg\settitlezzz} alpar@18: \def\settitlezzz #1{\gdef\thistitle{#1}} alpar@18: alpar@18: alpar@18: \message{tables,} alpar@18: % Tables -- @table, @ftable, @vtable, @item(x), @kitem(x), @xitem(x). alpar@18: alpar@18: % default indentation of table text alpar@18: \newdimen\tableindent \tableindent=.8in alpar@18: % default indentation of @itemize and @enumerate text alpar@18: \newdimen\itemindent \itemindent=.3in alpar@18: % margin between end of table item and start of table text. alpar@18: \newdimen\itemmargin \itemmargin=.1in alpar@18: alpar@18: % used internally for \itemindent minus \itemmargin alpar@18: \newdimen\itemmax alpar@18: alpar@18: % Note @table, @vtable, and @vtable define @item, @itemx, etc., with alpar@18: % these defs. alpar@18: % They also define \itemindex alpar@18: % to index the item name in whatever manner is desired (perhaps none). alpar@18: alpar@18: \newif\ifitemxneedsnegativevskip alpar@18: alpar@18: \def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi} alpar@18: alpar@18: \def\internalBitem{\smallbreak \parsearg\itemzzz} alpar@18: \def\internalBitemx{\itemxpar \parsearg\itemzzz} alpar@18: alpar@18: \def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz} alpar@18: \def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \itemxpar \parsearg\xitemzzz} alpar@18: alpar@18: \def\internalBkitem{\smallbreak \parsearg\kitemzzz} alpar@18: \def\internalBkitemx{\itemxpar \parsearg\kitemzzz} alpar@18: alpar@18: \def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}% alpar@18: \itemzzz {#1}} alpar@18: alpar@18: \def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}% alpar@18: \itemzzz {#1}} alpar@18: alpar@18: \def\itemzzz #1{\begingroup % alpar@18: \advance\hsize by -\rightskip alpar@18: \advance\hsize by -\tableindent alpar@18: \setbox0=\hbox{\itemfont{#1}}% alpar@18: \itemindex{#1}% alpar@18: \nobreak % This prevents a break before @itemx. alpar@18: % alpar@18: % If the item text does not fit in the space we have, put it on a line alpar@18: % by itself, and do not allow a page break either before or after that alpar@18: % line. We do not start a paragraph here because then if the next alpar@18: % command is, e.g., @kindex, the whatsit would get put into the alpar@18: % horizontal list on a line by itself, resulting in extra blank space. alpar@18: \ifdim \wd0>\itemmax alpar@18: % alpar@18: % Make this a paragraph so we get the \parskip glue and wrapping, alpar@18: % but leave it ragged-right. alpar@18: \begingroup alpar@18: \advance\leftskip by-\tableindent alpar@18: \advance\hsize by\tableindent alpar@18: \advance\rightskip by0pt plus1fil alpar@18: \leavevmode\unhbox0\par alpar@18: \endgroup alpar@18: % alpar@18: % We're going to be starting a paragraph, but we don't want the alpar@18: % \parskip glue -- logically it's part of the @item we just started. alpar@18: \nobreak \vskip-\parskip alpar@18: % alpar@18: % Stop a page break at the \parskip glue coming up. (Unfortunately alpar@18: % we can't prevent a possible page break at the following alpar@18: % \baselineskip glue.) However, if what follows is an environment alpar@18: % such as @example, there will be no \parskip glue; then alpar@18: % the negative vskip we just would cause the example and the item to alpar@18: % crash together. So we use this bizarre value of 10001 as a signal alpar@18: % to \aboveenvbreak to insert \parskip glue after all. alpar@18: % (Possibly there are other commands that could be followed by alpar@18: % @example which need the same treatment, but not section titles; or alpar@18: % maybe section titles are the only special case and they should be alpar@18: % penalty 10001...) alpar@18: \penalty 10001 alpar@18: \endgroup alpar@18: \itemxneedsnegativevskipfalse alpar@18: \else alpar@18: % The item text fits into the space. Start a paragraph, so that the alpar@18: % following text (if any) will end up on the same line. alpar@18: \noindent alpar@18: % Do this with kerns and \unhbox so that if there is a footnote in alpar@18: % the item text, it can migrate to the main vertical list and alpar@18: % eventually be printed. alpar@18: \nobreak\kern-\tableindent alpar@18: \dimen0 = \itemmax \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0 alpar@18: \unhbox0 alpar@18: \nobreak\kern\dimen0 alpar@18: \endgroup alpar@18: \itemxneedsnegativevskiptrue alpar@18: \fi alpar@18: } alpar@18: alpar@18: \def\item{\errmessage{@item while not in a table}} alpar@18: \def\itemx{\errmessage{@itemx while not in a table}} alpar@18: \def\kitem{\errmessage{@kitem while not in a table}} alpar@18: \def\kitemx{\errmessage{@kitemx while not in a table}} alpar@18: \def\xitem{\errmessage{@xitem while not in a table}} alpar@18: \def\xitemx{\errmessage{@xitemx while not in a table}} alpar@18: alpar@18: % Contains a kludge to get @end[description] to work. alpar@18: \def\description{\tablez{\dontindex}{1}{}{}{}{}} alpar@18: alpar@18: % @table, @ftable, @vtable. alpar@18: \def\table{\begingroup\inENV\obeylines\obeyspaces\tablex} alpar@18: {\obeylines\obeyspaces% alpar@18: \gdef\tablex #1^^M{% alpar@18: \tabley\dontindex#1 \endtabley}} alpar@18: alpar@18: \def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex} alpar@18: {\obeylines\obeyspaces% alpar@18: \gdef\ftablex #1^^M{% alpar@18: \tabley\fnitemindex#1 \endtabley alpar@18: \def\Eftable{\endgraf\afterenvbreak\endgroup}% alpar@18: \let\Etable=\relax}} alpar@18: alpar@18: \def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex} alpar@18: {\obeylines\obeyspaces% alpar@18: \gdef\vtablex #1^^M{% alpar@18: \tabley\vritemindex#1 \endtabley alpar@18: \def\Evtable{\endgraf\afterenvbreak\endgroup}% alpar@18: \let\Etable=\relax}} alpar@18: alpar@18: \def\dontindex #1{} alpar@18: \def\fnitemindex #1{\doind {fn}{\code{#1}}}% alpar@18: \def\vritemindex #1{\doind {vr}{\code{#1}}}% alpar@18: alpar@18: {\obeyspaces % alpar@18: \gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup% alpar@18: \tablez{#1}{#2}{#3}{#4}{#5}{#6}}} alpar@18: alpar@18: \def\tablez #1#2#3#4#5#6{% alpar@18: \aboveenvbreak % alpar@18: \begingroup % alpar@18: \def\Edescription{\Etable}% Necessary kludge. alpar@18: \let\itemindex=#1% alpar@18: \ifnum 0#3>0 \advance \leftskip by #3\mil \fi % alpar@18: \ifnum 0#4>0 \tableindent=#4\mil \fi % alpar@18: \ifnum 0#5>0 \advance \rightskip by #5\mil \fi % alpar@18: \def\itemfont{#2}% alpar@18: \itemmax=\tableindent % alpar@18: \advance \itemmax by -\itemmargin % alpar@18: \advance \leftskip by \tableindent % alpar@18: \exdentamount=\tableindent alpar@18: \parindent = 0pt alpar@18: \parskip = \smallskipamount alpar@18: \ifdim \parskip=0pt \parskip=2pt \fi% alpar@18: \def\Etable{\endgraf\afterenvbreak\endgroup}% alpar@18: \let\item = \internalBitem % alpar@18: \let\itemx = \internalBitemx % alpar@18: \let\kitem = \internalBkitem % alpar@18: \let\kitemx = \internalBkitemx % alpar@18: \let\xitem = \internalBxitem % alpar@18: \let\xitemx = \internalBxitemx % alpar@18: } alpar@18: alpar@18: % This is the counter used by @enumerate, which is really @itemize alpar@18: alpar@18: \newcount \itemno alpar@18: alpar@18: \def\itemize{\parsearg\itemizezzz} alpar@18: alpar@18: \def\itemizezzz #1{% alpar@18: \begingroup % ended by the @end itemize alpar@18: \itemizey {#1}{\Eitemize} alpar@18: } alpar@18: alpar@18: \def\itemizey#1#2{% alpar@18: \aboveenvbreak alpar@18: \itemmax=\itemindent alpar@18: \advance\itemmax by -\itemmargin alpar@18: \advance\leftskip by \itemindent alpar@18: \exdentamount=\itemindent alpar@18: \parindent=0pt alpar@18: \parskip=\smallskipamount alpar@18: \ifdim\parskip=0pt \parskip=2pt \fi alpar@18: \def#2{\endgraf\afterenvbreak\endgroup}% alpar@18: \def\itemcontents{#1}% alpar@18: % @itemize with no arg is equivalent to @itemize @bullet. alpar@18: \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi alpar@18: \let\item=\itemizeitem alpar@18: } alpar@18: alpar@18: % \splitoff TOKENS\endmark defines \first to be the first token in alpar@18: % TOKENS, and \rest to be the remainder. alpar@18: % alpar@18: \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}% alpar@18: alpar@18: % Allow an optional argument of an uppercase letter, lowercase letter, alpar@18: % or number, to specify the first label in the enumerated list. No alpar@18: % argument is the same as `1'. alpar@18: % alpar@18: \def\enumerate{\parsearg\enumeratezzz} alpar@18: \def\enumeratezzz #1{\enumeratey #1 \endenumeratey} alpar@18: \def\enumeratey #1 #2\endenumeratey{% alpar@18: \begingroup % ended by the @end enumerate alpar@18: % alpar@18: % If we were given no argument, pretend we were given `1'. alpar@18: \def\thearg{#1}% alpar@18: \ifx\thearg\empty \def\thearg{1}\fi alpar@18: % alpar@18: % Detect if the argument is a single token. If so, it might be a alpar@18: % letter. Otherwise, the only valid thing it can be is a number. alpar@18: % (We will always have one token, because of the test we just made. alpar@18: % This is a good thing, since \splitoff doesn't work given nothing at alpar@18: % all -- the first parameter is undelimited.) alpar@18: \expandafter\splitoff\thearg\endmark alpar@18: \ifx\rest\empty alpar@18: % Only one token in the argument. It could still be anything. alpar@18: % A ``lowercase letter'' is one whose \lccode is nonzero. alpar@18: % An ``uppercase letter'' is one whose \lccode is both nonzero, and alpar@18: % not equal to itself. alpar@18: % Otherwise, we assume it's a number. alpar@18: % alpar@18: % We need the \relax at the end of the \ifnum lines to stop TeX from alpar@18: % continuing to look for a . alpar@18: % alpar@18: \ifnum\lccode\expandafter`\thearg=0\relax alpar@18: \numericenumerate % a number (we hope) alpar@18: \else alpar@18: % It's a letter. alpar@18: \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax alpar@18: \lowercaseenumerate % lowercase letter alpar@18: \else alpar@18: \uppercaseenumerate % uppercase letter alpar@18: \fi alpar@18: \fi alpar@18: \else alpar@18: % Multiple tokens in the argument. We hope it's a number. alpar@18: \numericenumerate alpar@18: \fi alpar@18: } alpar@18: alpar@18: % An @enumerate whose labels are integers. The starting integer is alpar@18: % given in \thearg. alpar@18: % alpar@18: \def\numericenumerate{% alpar@18: \itemno = \thearg alpar@18: \startenumeration{\the\itemno}% alpar@18: } alpar@18: alpar@18: % The starting (lowercase) letter is in \thearg. alpar@18: \def\lowercaseenumerate{% alpar@18: \itemno = \expandafter`\thearg alpar@18: \startenumeration{% alpar@18: % Be sure we're not beyond the end of the alphabet. alpar@18: \ifnum\itemno=0 alpar@18: \errmessage{No more lowercase letters in @enumerate; get a bigger alpar@18: alphabet}% alpar@18: \fi alpar@18: \char\lccode\itemno alpar@18: }% alpar@18: } alpar@18: alpar@18: % The starting (uppercase) letter is in \thearg. alpar@18: \def\uppercaseenumerate{% alpar@18: \itemno = \expandafter`\thearg alpar@18: \startenumeration{% alpar@18: % Be sure we're not beyond the end of the alphabet. alpar@18: \ifnum\itemno=0 alpar@18: \errmessage{No more uppercase letters in @enumerate; get a bigger alpar@18: alphabet} alpar@18: \fi alpar@18: \char\uccode\itemno alpar@18: }% alpar@18: } alpar@18: alpar@18: % Call itemizey, adding a period to the first argument and supplying the alpar@18: % common last two arguments. Also subtract one from the initial value in alpar@18: % \itemno, since @item increments \itemno. alpar@18: % alpar@18: \def\startenumeration#1{% alpar@18: \advance\itemno by -1 alpar@18: \itemizey{#1.}\Eenumerate\flushcr alpar@18: } alpar@18: alpar@18: % @alphaenumerate and @capsenumerate are abbreviations for giving an arg alpar@18: % to @enumerate. alpar@18: % alpar@18: \def\alphaenumerate{\enumerate{a}} alpar@18: \def\capsenumerate{\enumerate{A}} alpar@18: \def\Ealphaenumerate{\Eenumerate} alpar@18: \def\Ecapsenumerate{\Eenumerate} alpar@18: alpar@18: % Definition of @item while inside @itemize. alpar@18: alpar@18: \def\itemizeitem{% alpar@18: \advance\itemno by 1 alpar@18: {\let\par=\endgraf \smallbreak}% alpar@18: \ifhmode \errmessage{In hmode at itemizeitem}\fi alpar@18: {\parskip=0in \hskip 0pt alpar@18: \hbox to 0pt{\hss \itemcontents\hskip \itemmargin}% alpar@18: \vadjust{\penalty 1200}}% alpar@18: \flushcr} alpar@18: alpar@18: % @multitable macros alpar@18: % Amy Hendrickson, 8/18/94, 3/6/96 alpar@18: % alpar@18: % @multitable ... @end multitable will make as many columns as desired. alpar@18: % Contents of each column will wrap at width given in preamble. Width alpar@18: % can be specified either with sample text given in a template line, alpar@18: % or in percent of \hsize, the current width of text on page. alpar@18: alpar@18: % Table can continue over pages but will only break between lines. alpar@18: alpar@18: % To make preamble: alpar@18: % alpar@18: % Either define widths of columns in terms of percent of \hsize: alpar@18: % @multitable @columnfractions .25 .3 .45 alpar@18: % @item ... alpar@18: % alpar@18: % Numbers following @columnfractions are the percent of the total alpar@18: % current hsize to be used for each column. You may use as many alpar@18: % columns as desired. alpar@18: alpar@18: alpar@18: % Or use a template: alpar@18: % @multitable {Column 1 template} {Column 2 template} {Column 3 template} alpar@18: % @item ... alpar@18: % using the widest term desired in each column. alpar@18: % alpar@18: % For those who want to use more than one line's worth of words in alpar@18: % the preamble, break the line within one argument and it alpar@18: % will parse correctly, i.e., alpar@18: % alpar@18: % @multitable {Column 1 template} {Column 2 template} {Column 3 alpar@18: % template} alpar@18: % Not: alpar@18: % @multitable {Column 1 template} {Column 2 template} alpar@18: % {Column 3 template} alpar@18: alpar@18: % Each new table line starts with @item, each subsequent new column alpar@18: % starts with @tab. Empty columns may be produced by supplying @tab's alpar@18: % with nothing between them for as many times as empty columns are needed, alpar@18: % ie, @tab@tab@tab will produce two empty columns. alpar@18: alpar@18: % @item, @tab, @multitable or @end multitable do not need to be on their alpar@18: % own lines, but it will not hurt if they are. alpar@18: alpar@18: % Sample multitable: alpar@18: alpar@18: % @multitable {Column 1 template} {Column 2 template} {Column 3 template} alpar@18: % @item first col stuff @tab second col stuff @tab third col alpar@18: % @item alpar@18: % first col stuff alpar@18: % @tab alpar@18: % second col stuff alpar@18: % @tab alpar@18: % third col alpar@18: % @item first col stuff @tab second col stuff alpar@18: % @tab Many paragraphs of text may be used in any column. alpar@18: % alpar@18: % They will wrap at the width determined by the template. alpar@18: % @item@tab@tab This will be in third column. alpar@18: % @end multitable alpar@18: alpar@18: % Default dimensions may be reset by user. alpar@18: % @multitableparskip is vertical space between paragraphs in table. alpar@18: % @multitableparindent is paragraph indent in table. alpar@18: % @multitablecolmargin is horizontal space to be left between columns. alpar@18: % @multitablelinespace is space to leave between table items, baseline alpar@18: % to baseline. alpar@18: % 0pt means it depends on current normal line spacing. alpar@18: % alpar@18: \newskip\multitableparskip alpar@18: \newskip\multitableparindent alpar@18: \newdimen\multitablecolspace alpar@18: \newskip\multitablelinespace alpar@18: \multitableparskip=0pt alpar@18: \multitableparindent=6pt alpar@18: \multitablecolspace=12pt alpar@18: \multitablelinespace=0pt alpar@18: alpar@18: % Macros used to set up halign preamble: alpar@18: % alpar@18: \let\endsetuptable\relax alpar@18: \def\xendsetuptable{\endsetuptable} alpar@18: \let\columnfractions\relax alpar@18: \def\xcolumnfractions{\columnfractions} alpar@18: \newif\ifsetpercent alpar@18: alpar@18: % #1 is the part of the @columnfraction before the decimal point, which alpar@18: % is presumably either 0 or the empty string (but we don't check, we alpar@18: % just throw it away). #2 is the decimal part, which we use as the alpar@18: % percent of \hsize for this column. alpar@18: \def\pickupwholefraction#1.#2 {% alpar@18: \global\advance\colcount by 1 alpar@18: \expandafter\xdef\csname col\the\colcount\endcsname{.#2\hsize}% alpar@18: \setuptable alpar@18: } alpar@18: alpar@18: \newcount\colcount alpar@18: \def\setuptable#1{% alpar@18: \def\firstarg{#1}% alpar@18: \ifx\firstarg\xendsetuptable alpar@18: \let\go = \relax alpar@18: \else alpar@18: \ifx\firstarg\xcolumnfractions alpar@18: \global\setpercenttrue alpar@18: \else alpar@18: \ifsetpercent alpar@18: \let\go\pickupwholefraction alpar@18: \else alpar@18: \global\advance\colcount by 1 alpar@18: \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a alpar@18: % separator; typically that is always in the input, anyway. alpar@18: \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}% alpar@18: \fi alpar@18: \fi alpar@18: \ifx\go\pickupwholefraction alpar@18: % Put the argument back for the \pickupwholefraction call, so alpar@18: % we'll always have a period there to be parsed. alpar@18: \def\go{\pickupwholefraction#1}% alpar@18: \else alpar@18: \let\go = \setuptable alpar@18: \fi% alpar@18: \fi alpar@18: \go alpar@18: } alpar@18: alpar@18: % @multitable ... @end multitable definitions: alpar@18: % alpar@18: \def\multitable{\parsearg\dotable} alpar@18: \def\dotable#1{\bgroup alpar@18: \vskip\parskip alpar@18: \let\item=\crcrwithfootnotes alpar@18: % A \tab used to include \hskip1sp. But then the space in a template alpar@18: % line is not enough. That is bad. So let's go back to just & until alpar@18: % we encounter the problem it was intended to solve again. --karl, alpar@18: % nathan@acm.org, 20apr99. alpar@18: \let\tab=&% alpar@18: \let\startfootins=\startsavedfootnote alpar@18: \tolerance=9500 alpar@18: \hbadness=9500 alpar@18: \setmultitablespacing alpar@18: \parskip=\multitableparskip alpar@18: \parindent=\multitableparindent alpar@18: \overfullrule=0pt alpar@18: \global\colcount=0 alpar@18: \def\Emultitable{% alpar@18: \global\setpercentfalse alpar@18: \crcrwithfootnotes\crcr alpar@18: \egroup\egroup alpar@18: }% alpar@18: % alpar@18: % To parse everything between @multitable and @item: alpar@18: \setuptable#1 \endsetuptable alpar@18: % alpar@18: % \everycr will reset column counter, \colcount, at the end of alpar@18: % each line. Every column entry will cause \colcount to advance by one. alpar@18: % The table preamble alpar@18: % looks at the current \colcount to find the correct column width. alpar@18: \everycr{\noalign{% alpar@18: % alpar@18: % \filbreak%% keeps underfull box messages off when table breaks over pages. alpar@18: % Maybe so, but it also creates really weird page breaks when the table alpar@18: % breaks over pages. Wouldn't \vfil be better? Wait until the problem alpar@18: % manifests itself, so it can be fixed for real --karl. alpar@18: \global\colcount=0\relax}}% alpar@18: % alpar@18: % This preamble sets up a generic column definition, which will alpar@18: % be used as many times as user calls for columns. alpar@18: % \vtop will set a single line and will also let text wrap and alpar@18: % continue for many paragraphs if desired. alpar@18: \halign\bgroup&\global\advance\colcount by 1\relax alpar@18: \multistrut\vtop{\hsize=\expandafter\csname col\the\colcount\endcsname alpar@18: % alpar@18: % In order to keep entries from bumping into each other alpar@18: % we will add a \leftskip of \multitablecolspace to all columns after alpar@18: % the first one. alpar@18: % alpar@18: % If a template has been used, we will add \multitablecolspace alpar@18: % to the width of each template entry. alpar@18: % alpar@18: % If the user has set preamble in terms of percent of \hsize we will alpar@18: % use that dimension as the width of the column, and the \leftskip alpar@18: % will keep entries from bumping into each other. Table will start at alpar@18: % left margin and final column will justify at right margin. alpar@18: % alpar@18: % Make sure we don't inherit \rightskip from the outer environment. alpar@18: \rightskip=0pt alpar@18: \ifnum\colcount=1 alpar@18: % The first column will be indented with the surrounding text. alpar@18: \advance\hsize by\leftskip alpar@18: \else alpar@18: \ifsetpercent \else alpar@18: % If user has not set preamble in terms of percent of \hsize alpar@18: % we will advance \hsize by \multitablecolspace. alpar@18: \advance\hsize by \multitablecolspace alpar@18: \fi alpar@18: % In either case we will make \leftskip=\multitablecolspace: alpar@18: \leftskip=\multitablecolspace alpar@18: \fi alpar@18: % Ignoring space at the beginning and end avoids an occasional spurious alpar@18: % blank line, when TeX decides to break the line at the space before the alpar@18: % box from the multistrut, so the strut ends up on a line by itself. alpar@18: % For example: alpar@18: % @multitable @columnfractions .11 .89 alpar@18: % @item @code{#} alpar@18: % @tab Legal holiday which is valid in major parts of the whole country. alpar@18: % Is automatically provided with highlighting sequences respectively marking alpar@18: % characters. alpar@18: \noindent\ignorespaces##\unskip\multistrut}\cr alpar@18: } alpar@18: alpar@18: \def\setmultitablespacing{% test to see if user has set \multitablelinespace. alpar@18: % If so, do nothing. If not, give it an appropriate dimension based on alpar@18: % current baselineskip. alpar@18: \ifdim\multitablelinespace=0pt alpar@18: \setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip alpar@18: \global\advance\multitablelinespace by-\ht0 alpar@18: %% strut to put in table in case some entry doesn't have descenders, alpar@18: %% to keep lines equally spaced alpar@18: \let\multistrut = \strut alpar@18: \else alpar@18: %% FIXME: what is \box0 supposed to be? alpar@18: \gdef\multistrut{\vrule height\multitablelinespace depth\dp0 alpar@18: width0pt\relax} \fi alpar@18: %% Test to see if parskip is larger than space between lines of alpar@18: %% table. If not, do nothing. alpar@18: %% If so, set to same dimension as multitablelinespace. alpar@18: \ifdim\multitableparskip>\multitablelinespace alpar@18: \global\multitableparskip=\multitablelinespace alpar@18: \global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller alpar@18: %% than skip between lines in the table. alpar@18: \fi% alpar@18: \ifdim\multitableparskip=0pt alpar@18: \global\multitableparskip=\multitablelinespace alpar@18: \global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller alpar@18: %% than skip between lines in the table. alpar@18: \fi} alpar@18: alpar@18: % In case a @footnote appears inside an alignment, save the footnote alpar@18: % text to a box and make the \insert when a row of the table is alpar@18: % finished. Otherwise, the insertion is lost, it never migrates to the alpar@18: % main vertical list. --kasal, 22jan03. alpar@18: % alpar@18: \newbox\savedfootnotes alpar@18: % alpar@18: % \dotable \let's \startfootins to this, so that \dofootnote will call alpar@18: % it instead of starting the insertion right away. alpar@18: \def\startsavedfootnote{% alpar@18: \global\setbox\savedfootnotes = \vbox\bgroup alpar@18: \unvbox\savedfootnotes alpar@18: } alpar@18: \def\crcrwithfootnotes{% alpar@18: \crcr alpar@18: \ifvoid\savedfootnotes \else alpar@18: \noalign{\insert\footins{\box\savedfootnotes}}% alpar@18: \fi alpar@18: } alpar@18: alpar@18: \message{conditionals,} alpar@18: % Prevent errors for section commands. alpar@18: % Used in @ignore and in failing conditionals. alpar@18: \def\ignoresections{% alpar@18: \let\appendix=\relax alpar@18: \let\appendixsec=\relax alpar@18: \let\appendixsection=\relax alpar@18: \let\appendixsubsec=\relax alpar@18: \let\appendixsubsection=\relax alpar@18: \let\appendixsubsubsec=\relax alpar@18: \let\appendixsubsubsection=\relax alpar@18: %\let\begin=\relax alpar@18: %\let\bye=\relax alpar@18: \let\centerchap=\relax alpar@18: \let\chapter=\relax alpar@18: \let\contents=\relax alpar@18: \let\section=\relax alpar@18: \let\smallbook=\relax alpar@18: \let\subsec=\relax alpar@18: \let\subsection=\relax alpar@18: \let\subsubsec=\relax alpar@18: \let\subsubsection=\relax alpar@18: \let\titlepage=\relax alpar@18: \let\top=\relax alpar@18: \let\unnumbered=\relax alpar@18: \let\unnumberedsec=\relax alpar@18: \let\unnumberedsection=\relax alpar@18: \let\unnumberedsubsec=\relax alpar@18: \let\unnumberedsubsection=\relax alpar@18: \let\unnumberedsubsubsec=\relax alpar@18: \let\unnumberedsubsubsection=\relax alpar@18: } alpar@18: alpar@18: % Ignore @ignore, @ifhtml, @ifinfo, and the like. alpar@18: % alpar@18: \def\direntry{\doignore{direntry}} alpar@18: \def\documentdescriptionword{documentdescription} alpar@18: \def\documentdescription{\doignore{documentdescription}} alpar@18: \def\html{\doignore{html}} alpar@18: \def\ifhtml{\doignore{ifhtml}} alpar@18: \def\ifinfo{\doignore{ifinfo}} alpar@18: \def\ifnottex{\doignore{ifnottex}} alpar@18: \def\ifplaintext{\doignore{ifplaintext}} alpar@18: \def\ifxml{\doignore{ifxml}} alpar@18: \def\ignore{\doignore{ignore}} alpar@18: \def\menu{\doignore{menu}} alpar@18: \def\xml{\doignore{xml}} alpar@18: alpar@18: % @dircategory CATEGORY -- specify a category of the dir file alpar@18: % which this file should belong to. Ignore this in TeX. alpar@18: \let\dircategory = \comment alpar@18: alpar@18: % Ignore text until a line `@end #1', keeping track of nested conditionals. alpar@18: % alpar@18: % A count to remember the depth of nesting. alpar@18: \newcount\doignorecount \doignorecount = 0 alpar@18: alpar@18: \def\doignore#1{\begingroup alpar@18: % Don't complain about control sequences we have declared \outer. alpar@18: \ignoresections alpar@18: % alpar@18: % Make sure that spaces turn into tokens that match what \doignoretext wants. alpar@18: \catcode\spaceChar = 10 alpar@18: % alpar@18: % Ignore braces, so mismatched braces don't cause trouble. alpar@18: \catcode`\{ = 9 alpar@18: \catcode`\} = 9 alpar@18: % alpar@18: % Count number of #1's that we've seen. alpar@18: \doignorecount = 0 alpar@18: % alpar@18: % Swallow text until we reach the matching `@end #1'. alpar@18: \expandafter \dodoignore \csname#1\endcsname {#1}% alpar@18: } alpar@18: alpar@18: { \catcode`@=11 % We want to use \ST@P which cannot appear in texinfo source. alpar@18: \obeylines % alpar@18: % alpar@18: \gdef\dodoignore#1#2{% alpar@18: % #1 contains, e.g., \ifinfo, a.k.a. @ifinfo. alpar@18: % #2 contains the string `ifinfo'. alpar@18: % alpar@18: % Define a command to find the next `@end #2', which must be on a line alpar@18: % by itself. alpar@18: \long\def\doignoretext##1^^M\end #2{\doignoretextyyy##1^^M#1\ST@P}% alpar@18: % And this command to find another #1 command, at the beginning of a alpar@18: % line. (Otherwise, we would consider a line `@c @ifset', for alpar@18: % example, to count as an @ifset for nesting.) alpar@18: \long\def\doignoretextyyy##1^^M#1##2\ST@P{\doignoreyyy{##2}\ST@P}% alpar@18: % alpar@18: % And now expand that command. alpar@18: \obeylines % alpar@18: \doignoretext ^^M% alpar@18: }% alpar@18: } alpar@18: alpar@18: \def\doignoreyyy#1{% alpar@18: \def\temp{#1}% alpar@18: \ifx\temp\empty % Nothing found. alpar@18: \let\next\doignoretextzzz alpar@18: \else % Found a nested condition, ... alpar@18: \advance\doignorecount by 1 alpar@18: \let\next\doignoretextyyy % ..., look for another. alpar@18: % If we're here, #1 ends with \ifinfo (for example). alpar@18: \fi alpar@18: \next #1% the token \ST@P is present just after this macro. alpar@18: } alpar@18: alpar@18: % We have to swallow the remaining "\ST@P". alpar@18: % alpar@18: \def\doignoretextzzz#1{% alpar@18: \ifnum\doignorecount = 0 % We have just found the outermost @end. alpar@18: \let\next\enddoignore alpar@18: \else % Still inside a nested condition. alpar@18: \advance\doignorecount by -1 alpar@18: \let\next\doignoretext % Look for the next @end. alpar@18: \fi alpar@18: \next alpar@18: } alpar@18: alpar@18: % Finish off ignored text. alpar@18: \def\enddoignore{\endgroup\ignorespaces} alpar@18: alpar@18: alpar@18: % @set VAR sets the variable VAR to an empty value. alpar@18: % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE. alpar@18: % alpar@18: % Since we want to separate VAR from REST-OF-LINE (which might be alpar@18: % empty), we can't just use \parsearg; we have to insert a space of our alpar@18: % own to delimit the rest of the line, and then take it out again if we alpar@18: % didn't need it. Make sure the catcode of space is correct to avoid alpar@18: % losing inside @example, for instance. alpar@18: % alpar@18: \def\set{\begingroup\catcode` =10 alpar@18: \catcode`\-=12 \catcode`\_=12 % Allow - and _ in VAR. alpar@18: \parsearg\setxxx} alpar@18: \def\setxxx#1{\setyyy#1 \endsetyyy} alpar@18: \def\setyyy#1 #2\endsetyyy{% alpar@18: \def\temp{#2}% alpar@18: \ifx\temp\empty \global\expandafter\let\csname SET#1\endcsname = \empty alpar@18: \else \setzzz{#1}#2\endsetzzz % Remove the trailing space \setxxx inserted. alpar@18: \fi alpar@18: \endgroup alpar@18: } alpar@18: % Can't use \xdef to pre-expand #2 and save some time, since \temp or alpar@18: % \next or other control sequences that we've defined might get us into alpar@18: % an infinite loop. Consider `@set foo @cite{bar}'. alpar@18: \def\setzzz#1#2 \endsetzzz{\expandafter\gdef\csname SET#1\endcsname{#2}} alpar@18: alpar@18: % @clear VAR clears (i.e., unsets) the variable VAR. alpar@18: % alpar@18: \def\clear{\parsearg\clearxxx} alpar@18: \def\clearxxx#1{\global\expandafter\let\csname SET#1\endcsname=\relax} alpar@18: alpar@18: % @value{foo} gets the text saved in variable foo. alpar@18: { alpar@18: \catcode`\_ = \active alpar@18: % alpar@18: % We might end up with active _ or - characters in the argument if alpar@18: % we're called from @code, as @code{@value{foo-bar_}}. So \let any alpar@18: % such active characters to their normal equivalents. alpar@18: \gdef\value{\begingroup alpar@18: \catcode`\-=\other \catcode`\_=\other alpar@18: \indexbreaks \let_\normalunderscore alpar@18: \valuexxx} alpar@18: } alpar@18: \def\valuexxx#1{\expandablevalue{#1}\endgroup} alpar@18: alpar@18: % We have this subroutine so that we can handle at least some @value's alpar@18: % properly in indexes (we \let\value to this in \indexdummies). Ones alpar@18: % whose names contain - or _ still won't work, but we can't do anything alpar@18: % about that. The command has to be fully expandable (if the variable alpar@18: % is set), since the result winds up in the index file. This means that alpar@18: % if the variable's value contains other Texinfo commands, it's almost alpar@18: % certain it will fail (although perhaps we could fix that with alpar@18: % sufficient work to do a one-level expansion on the result, instead of alpar@18: % complete). alpar@18: % alpar@18: \def\expandablevalue#1{% alpar@18: \expandafter\ifx\csname SET#1\endcsname\relax alpar@18: {[No value for ``#1'']}% alpar@18: \message{Variable `#1', used in @value, is not set.}% alpar@18: \else alpar@18: \csname SET#1\endcsname alpar@18: \fi alpar@18: } alpar@18: alpar@18: % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined alpar@18: % with @set. alpar@18: % alpar@18: \def\ifset{\parsearg\doifset} alpar@18: \def\doifset#1{% alpar@18: \expandafter\ifx\csname SET#1\endcsname\relax alpar@18: \let\next=\ifsetfail alpar@18: \else alpar@18: \let\next=\ifsetsucceed alpar@18: \fi alpar@18: \next alpar@18: } alpar@18: \def\ifsetsucceed{\conditionalsucceed{ifset}} alpar@18: \def\ifsetfail{\doignore{ifset}} alpar@18: \defineunmatchedend{ifset} alpar@18: alpar@18: % @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been alpar@18: % defined with @set, or has been undefined with @clear. alpar@18: % alpar@18: \def\ifclear{\parsearg\doifclear} alpar@18: \def\doifclear#1{% alpar@18: \expandafter\ifx\csname SET#1\endcsname\relax alpar@18: \let\next=\ifclearsucceed alpar@18: \else alpar@18: \let\next=\ifclearfail alpar@18: \fi alpar@18: \next alpar@18: } alpar@18: \def\ifclearsucceed{\conditionalsucceed{ifclear}} alpar@18: \def\ifclearfail{\doignore{ifclear}} alpar@18: \defineunmatchedend{ifclear} alpar@18: alpar@18: % @iftex, @ifnothtml, @ifnotinfo, @ifnotplaintext always succeed; we alpar@18: % read the text following, through the first @end iftex (etc.). Make alpar@18: % `@end iftex' (etc.) valid only after an @iftex. alpar@18: % alpar@18: \def\iftex{\conditionalsucceed{iftex}} alpar@18: \def\ifnothtml{\conditionalsucceed{ifnothtml}} alpar@18: \def\ifnotinfo{\conditionalsucceed{ifnotinfo}} alpar@18: \def\ifnotplaintext{\conditionalsucceed{ifnotplaintext}} alpar@18: \defineunmatchedend{iftex} alpar@18: \defineunmatchedend{ifnothtml} alpar@18: \defineunmatchedend{ifnotinfo} alpar@18: \defineunmatchedend{ifnotplaintext} alpar@18: alpar@18: % True conditional. Since \set globally defines its variables, we can alpar@18: % just start and end a group (to keep the @end definition undefined at alpar@18: % the outer level). alpar@18: % alpar@18: \def\conditionalsucceed#1{\begingroup alpar@18: \expandafter\def\csname E#1\endcsname{\endgroup}% alpar@18: } alpar@18: alpar@18: % @defininfoenclose. alpar@18: \let\definfoenclose=\comment alpar@18: alpar@18: alpar@18: \message{indexing,} alpar@18: % Index generation facilities alpar@18: alpar@18: % Define \newwrite to be identical to plain tex's \newwrite alpar@18: % except not \outer, so it can be used within \newindex. alpar@18: {\catcode`\@=11 alpar@18: \gdef\newwrite{\alloc@7\write\chardef\sixt@@n}} alpar@18: alpar@18: % \newindex {foo} defines an index named foo. alpar@18: % It automatically defines \fooindex such that alpar@18: % \fooindex ...rest of line... puts an entry in the index foo. alpar@18: % It also defines \fooindfile to be the number of the output channel for alpar@18: % the file that accumulates this index. The file's extension is foo. alpar@18: % The name of an index should be no more than 2 characters long alpar@18: % for the sake of vms. alpar@18: % alpar@18: \def\newindex#1{% alpar@18: \iflinks alpar@18: \expandafter\newwrite \csname#1indfile\endcsname alpar@18: \openout \csname#1indfile\endcsname \jobname.#1 % Open the file alpar@18: \fi alpar@18: \expandafter\xdef\csname#1index\endcsname{% % Define @#1index alpar@18: \noexpand\doindex{#1}} alpar@18: } alpar@18: alpar@18: % @defindex foo == \newindex{foo} alpar@18: % alpar@18: \def\defindex{\parsearg\newindex} alpar@18: alpar@18: % Define @defcodeindex, like @defindex except put all entries in @code. alpar@18: % alpar@18: \def\defcodeindex{\parsearg\newcodeindex} alpar@18: % alpar@18: \def\newcodeindex#1{% alpar@18: \iflinks alpar@18: \expandafter\newwrite \csname#1indfile\endcsname alpar@18: \openout \csname#1indfile\endcsname \jobname.#1 alpar@18: \fi alpar@18: \expandafter\xdef\csname#1index\endcsname{% alpar@18: \noexpand\docodeindex{#1}}% alpar@18: } alpar@18: alpar@18: alpar@18: % @synindex foo bar makes index foo feed into index bar. alpar@18: % Do this instead of @defindex foo if you don't want it as a separate index. alpar@18: % alpar@18: % @syncodeindex foo bar similar, but put all entries made for index foo alpar@18: % inside @code. alpar@18: % alpar@18: \def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}} alpar@18: \def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}} alpar@18: alpar@18: % #1 is \doindex or \docodeindex, #2 the index getting redefined (foo), alpar@18: % #3 the target index (bar). alpar@18: \def\dosynindex#1#2#3{% alpar@18: % Only do \closeout if we haven't already done it, else we'll end up alpar@18: % closing the target index. alpar@18: \expandafter \ifx\csname donesynindex#2\endcsname \undefined alpar@18: % The \closeout helps reduce unnecessary open files; the limit on the alpar@18: % Acorn RISC OS is a mere 16 files. alpar@18: \expandafter\closeout\csname#2indfile\endcsname alpar@18: \expandafter\let\csname\donesynindex#2\endcsname = 1 alpar@18: \fi alpar@18: % redefine \fooindfile: alpar@18: \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname alpar@18: \expandafter\let\csname#2indfile\endcsname=\temp alpar@18: % redefine \fooindex: alpar@18: \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}% alpar@18: } alpar@18: alpar@18: % Define \doindex, the driver for all \fooindex macros. alpar@18: % Argument #1 is generated by the calling \fooindex macro, alpar@18: % and it is "foo", the name of the index. alpar@18: alpar@18: % \doindex just uses \parsearg; it calls \doind for the actual work. alpar@18: % This is because \doind is more useful to call from other macros. alpar@18: alpar@18: % There is also \dosubind {index}{topic}{subtopic} alpar@18: % which makes an entry in a two-level index such as the operation index. alpar@18: alpar@18: \def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer} alpar@18: \def\singleindexer #1{\doind{\indexname}{#1}} alpar@18: alpar@18: % like the previous two, but they put @code around the argument. alpar@18: \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer} alpar@18: \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}} alpar@18: alpar@18: % Take care of Texinfo commands that can appear in an index entry. alpar@18: % Since there are some commands we want to expand, and others we don't, alpar@18: % we have to laboriously prevent expansion for those that we don't. alpar@18: % alpar@18: \def\indexdummies{% alpar@18: \def\@{@}% change to @@ when we switch to @ as escape char in index files. alpar@18: \def\ {\realbackslash\space }% alpar@18: % Need these in case \tex is in effect and \{ is a \delimiter again. alpar@18: % But can't use \lbracecmd and \rbracecmd because texindex assumes alpar@18: % braces and backslashes are used only as delimiters. alpar@18: \let\{ = \mylbrace alpar@18: \let\} = \myrbrace alpar@18: % alpar@18: % \definedummyword defines \#1 as \realbackslash #1\space, thus alpar@18: % effectively preventing its expansion. This is used only for control alpar@18: % words, not control letters, because the \space would be incorrect alpar@18: % for control characters, but is needed to separate the control word alpar@18: % from whatever follows. alpar@18: % alpar@18: % For control letters, we have \definedummyletter, which omits the alpar@18: % space. alpar@18: % alpar@18: % These can be used both for control words that take an argument and alpar@18: % those that do not. If it is followed by {arg} in the input, then alpar@18: % that will dutifully get written to the index (or wherever). alpar@18: % alpar@18: \def\definedummyword##1{% alpar@18: \expandafter\def\csname ##1\endcsname{\realbackslash ##1\space}% alpar@18: }% alpar@18: \def\definedummyletter##1{% alpar@18: \expandafter\def\csname ##1\endcsname{\realbackslash ##1}% alpar@18: }% alpar@18: % alpar@18: % Do the redefinitions. alpar@18: \commondummies alpar@18: } alpar@18: alpar@18: % For the aux file, @ is the escape character. So we want to redefine alpar@18: % everything using @ instead of \realbackslash. When everything uses alpar@18: % @, this will be simpler. alpar@18: % alpar@18: \def\atdummies{% alpar@18: \def\@{@@}% alpar@18: \def\ {@ }% alpar@18: \let\{ = \lbraceatcmd alpar@18: \let\} = \rbraceatcmd alpar@18: % alpar@18: % (See comments in \indexdummies.) alpar@18: \def\definedummyword##1{% alpar@18: \expandafter\def\csname ##1\endcsname{@##1\space}% alpar@18: }% alpar@18: \def\definedummyletter##1{% alpar@18: \expandafter\def\csname ##1\endcsname{@##1}% alpar@18: }% alpar@18: % alpar@18: % Do the redefinitions. alpar@18: \commondummies alpar@18: } alpar@18: alpar@18: % Called from \indexdummies and \atdummies. \definedummyword and alpar@18: % \definedummyletter must be defined first. alpar@18: % alpar@18: \def\commondummies{% alpar@18: % alpar@18: \normalturnoffactive alpar@18: % alpar@18: % Control letters and accents. alpar@18: \definedummyletter{_}% alpar@18: \definedummyletter{,}% alpar@18: \definedummyletter{"}% alpar@18: \definedummyletter{`}% alpar@18: \definedummyletter{'}% alpar@18: \definedummyletter{^}% alpar@18: \definedummyletter{~}% alpar@18: \definedummyletter{=}% alpar@18: \definedummyword{u}% alpar@18: \definedummyword{v}% alpar@18: \definedummyword{H}% alpar@18: \definedummyword{dotaccent}% alpar@18: \definedummyword{ringaccent}% alpar@18: \definedummyword{tieaccent}% alpar@18: \definedummyword{ubaraccent}% alpar@18: \definedummyword{udotaccent}% alpar@18: \definedummyword{dotless}% alpar@18: % alpar@18: % Other non-English letters. alpar@18: \definedummyword{AA}% alpar@18: \definedummyword{AE}% alpar@18: \definedummyword{L}% alpar@18: \definedummyword{OE}% alpar@18: \definedummyword{O}% alpar@18: \definedummyword{aa}% alpar@18: \definedummyword{ae}% alpar@18: \definedummyword{l}% alpar@18: \definedummyword{oe}% alpar@18: \definedummyword{o}% alpar@18: \definedummyword{ss}% alpar@18: % alpar@18: % Although these internal commands shouldn't show up, sometimes they do. alpar@18: \definedummyword{bf}% alpar@18: \definedummyword{gtr}% alpar@18: \definedummyword{hat}% alpar@18: \definedummyword{less}% alpar@18: \definedummyword{sf}% alpar@18: \definedummyword{sl}% alpar@18: \definedummyword{tclose}% alpar@18: \definedummyword{tt}% alpar@18: % alpar@18: % Texinfo font commands. alpar@18: \definedummyword{b}% alpar@18: \definedummyword{i}% alpar@18: \definedummyword{r}% alpar@18: \definedummyword{sc}% alpar@18: \definedummyword{t}% alpar@18: % alpar@18: \definedummyword{TeX}% alpar@18: \definedummyword{acronym}% alpar@18: \definedummyword{cite}% alpar@18: \definedummyword{code}% alpar@18: \definedummyword{command}% alpar@18: \definedummyword{dfn}% alpar@18: \definedummyword{dots}% alpar@18: \definedummyword{emph}% alpar@18: \definedummyword{env}% alpar@18: \definedummyword{file}% alpar@18: \definedummyword{kbd}% alpar@18: \definedummyword{key}% alpar@18: \definedummyword{math}% alpar@18: \definedummyword{option}% alpar@18: \definedummyword{samp}% alpar@18: \definedummyword{strong}% alpar@18: \definedummyword{uref}% alpar@18: \definedummyword{url}% alpar@18: \definedummyword{var}% alpar@18: \definedummyword{w}% alpar@18: % alpar@18: % Assorted special characters. alpar@18: \definedummyword{bullet}% alpar@18: \definedummyword{copyright}% alpar@18: \definedummyword{dots}% alpar@18: \definedummyword{enddots}% alpar@18: \definedummyword{equiv}% alpar@18: \definedummyword{error}% alpar@18: \definedummyword{expansion}% alpar@18: \definedummyword{minus}% alpar@18: \definedummyword{pounds}% alpar@18: \definedummyword{point}% alpar@18: \definedummyword{print}% alpar@18: \definedummyword{result}% alpar@18: % alpar@18: % Handle some cases of @value -- where the variable name does not alpar@18: % contain - or _, and the value does not contain any alpar@18: % (non-fully-expandable) commands. alpar@18: \let\value = \expandablevalue alpar@18: % alpar@18: % Normal spaces, not active ones. alpar@18: \unsepspaces alpar@18: % alpar@18: % No macro expansion. alpar@18: \turnoffmacros alpar@18: } alpar@18: alpar@18: % If an index command is used in an @example environment, any spaces alpar@18: % therein should become regular spaces in the raw index file, not the alpar@18: % expansion of \tie (\leavevmode \penalty \@M \ ). alpar@18: {\obeyspaces alpar@18: \gdef\unsepspaces{\obeyspaces\let =\space}} alpar@18: alpar@18: alpar@18: % \indexnofonts is used when outputting the strings to sort the index alpar@18: % by, and when constructing control sequence names. It eliminates all alpar@18: % control sequences and just writes whatever the best ASCII sort string alpar@18: % would be for a given command (usually its argument). alpar@18: % alpar@18: \def\indexdummytex{TeX} alpar@18: \def\indexdummydots{...} alpar@18: % alpar@18: \def\indexnofonts{% alpar@18: \def\ { }% alpar@18: \def\@{@}% alpar@18: % how to handle braces? alpar@18: \def\_{\normalunderscore}% alpar@18: % alpar@18: \let\,=\asis alpar@18: \let\"=\asis alpar@18: \let\`=\asis alpar@18: \let\'=\asis alpar@18: \let\^=\asis alpar@18: \let\~=\asis alpar@18: \let\==\asis alpar@18: \let\u=\asis alpar@18: \let\v=\asis alpar@18: \let\H=\asis alpar@18: \let\dotaccent=\asis alpar@18: \let\ringaccent=\asis alpar@18: \let\tieaccent=\asis alpar@18: \let\ubaraccent=\asis alpar@18: \let\udotaccent=\asis alpar@18: \let\dotless=\asis alpar@18: % alpar@18: % Other non-English letters. alpar@18: \def\AA{AA}% alpar@18: \def\AE{AE}% alpar@18: \def\L{L}% alpar@18: \def\OE{OE}% alpar@18: \def\O{O}% alpar@18: \def\aa{aa}% alpar@18: \def\ae{ae}% alpar@18: \def\l{l}% alpar@18: \def\oe{oe}% alpar@18: \def\o{o}% alpar@18: \def\ss{ss}% alpar@18: \def\exclamdown{!}% alpar@18: \def\questiondown{?}% alpar@18: % alpar@18: % Don't no-op \tt, since it isn't a user-level command alpar@18: % and is used in the definitions of the active chars like <, >, |, etc. alpar@18: % Likewise with the other plain tex font commands. alpar@18: %\let\tt=\asis alpar@18: % alpar@18: % Texinfo font commands. alpar@18: \let\b=\asis alpar@18: \let\i=\asis alpar@18: \let\r=\asis alpar@18: \let\sc=\asis alpar@18: \let\t=\asis alpar@18: % alpar@18: \let\TeX=\indexdummytex alpar@18: \let\acronym=\asis alpar@18: \let\cite=\asis alpar@18: \let\code=\asis alpar@18: \let\command=\asis alpar@18: \let\dfn=\asis alpar@18: \let\dots=\indexdummydots alpar@18: \let\emph=\asis alpar@18: \let\env=\asis alpar@18: \let\file=\asis alpar@18: \let\kbd=\asis alpar@18: \let\key=\asis alpar@18: \let\math=\asis alpar@18: \let\option=\asis alpar@18: \let\samp=\asis alpar@18: \let\strong=\asis alpar@18: \let\uref=\asis alpar@18: \let\url=\asis alpar@18: \let\var=\asis alpar@18: \let\w=\asis alpar@18: } alpar@18: alpar@18: \let\indexbackslash=0 %overridden during \printindex. alpar@18: \let\SETmarginindex=\relax % put index entries in margin (undocumented)? alpar@18: alpar@18: % For \ifx comparisons. alpar@18: \def\emptymacro{\empty} alpar@18: alpar@18: % Most index entries go through here, but \dosubind is the general case. alpar@18: % alpar@18: \def\doind#1#2{\dosubind{#1}{#2}\empty} alpar@18: alpar@18: % Workhorse for all \fooindexes. alpar@18: % #1 is name of index, #2 is stuff to put there, #3 is subentry -- alpar@18: % \empty if called from \doind, as we usually are. The main exception alpar@18: % is with defuns, which call us directly. alpar@18: % alpar@18: \def\dosubind#1#2#3{% alpar@18: % Put the index entry in the margin if desired. alpar@18: \ifx\SETmarginindex\relax\else alpar@18: \insert\margin{\hbox{\vrule height8pt depth3pt width0pt #2}}% alpar@18: \fi alpar@18: {% alpar@18: \count255=\lastpenalty alpar@18: {% alpar@18: \indexdummies % Must do this here, since \bf, etc expand at this stage alpar@18: \escapechar=`\\ alpar@18: {% alpar@18: \let\folio = 0% We will expand all macros now EXCEPT \folio. alpar@18: \def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now alpar@18: % so it will be output as is; and it will print as backslash. alpar@18: % alpar@18: % The main index entry text. alpar@18: \toks0 = {#2}% alpar@18: % alpar@18: % If third arg is present, precede it with space in sort key. alpar@18: \def\thirdarg{#3}% alpar@18: \ifx\thirdarg\emptymacro \else alpar@18: % If the third (subentry) arg is present, add it to the index alpar@18: % line to write. alpar@18: \toks0 = \expandafter{\the\toks0 \space #3}% alpar@18: \fi alpar@18: % alpar@18: % Process the index entry with all font commands turned off, to alpar@18: % get the string to sort by. alpar@18: {\indexnofonts alpar@18: \edef\temp{\the\toks0}% need full expansion alpar@18: \xdef\indexsorttmp{\temp}% alpar@18: }% alpar@18: % alpar@18: % Set up the complete index entry, with both the sort key and alpar@18: % the original text, including any font commands. We write alpar@18: % three arguments to \entry to the .?? file (four in the alpar@18: % subentry case), texindex reduces to two when writing the .??s alpar@18: % sorted result. alpar@18: \edef\temp{% alpar@18: \write\csname#1indfile\endcsname{% alpar@18: \realbackslash entry{\indexsorttmp}{\folio}{\the\toks0}}% alpar@18: }% alpar@18: % alpar@18: % If a skip is the last thing on the list now, preserve it alpar@18: % by backing up by \lastskip, doing the \write, then inserting alpar@18: % the skip again. Otherwise, the whatsit generated by the alpar@18: % \write will make \lastskip zero. The result is that sequences alpar@18: % like this: alpar@18: % @end defun alpar@18: % @tindex whatever alpar@18: % @defun ... alpar@18: % will have extra space inserted, because the \medbreak in the alpar@18: % start of the @defun won't see the skip inserted by the @end of alpar@18: % the previous defun. alpar@18: % alpar@18: % But don't do any of this if we're not in vertical mode. We alpar@18: % don't want to do a \vskip and prematurely end a paragraph. alpar@18: % alpar@18: % Avoid page breaks due to these extra skips, too. alpar@18: % alpar@18: \iflinks alpar@18: \ifvmode alpar@18: \skip0 = \lastskip alpar@18: \ifdim\lastskip = 0pt \else \nobreak\vskip-\skip0 \fi alpar@18: \fi alpar@18: % alpar@18: \temp % do the write alpar@18: % alpar@18: \ifvmode \ifdim\skip0 = 0pt \else \nobreak\vskip\skip0 \fi \fi alpar@18: \fi alpar@18: }% alpar@18: }% alpar@18: \penalty\count255 alpar@18: }% alpar@18: } alpar@18: alpar@18: % The index entry written in the file actually looks like alpar@18: % \entry {sortstring}{page}{topic} alpar@18: % or alpar@18: % \entry {sortstring}{page}{topic}{subtopic} alpar@18: % The texindex program reads in these files and writes files alpar@18: % containing these kinds of lines: alpar@18: % \initial {c} alpar@18: % before the first topic whose initial is c alpar@18: % \entry {topic}{pagelist} alpar@18: % for a topic that is used without subtopics alpar@18: % \primary {topic} alpar@18: % for the beginning of a topic that is used with subtopics alpar@18: % \secondary {subtopic}{pagelist} alpar@18: % for each subtopic. alpar@18: alpar@18: % Define the user-accessible indexing commands alpar@18: % @findex, @vindex, @kindex, @cindex. alpar@18: alpar@18: \def\findex {\fnindex} alpar@18: \def\kindex {\kyindex} alpar@18: \def\cindex {\cpindex} alpar@18: \def\vindex {\vrindex} alpar@18: \def\tindex {\tpindex} alpar@18: \def\pindex {\pgindex} alpar@18: alpar@18: \def\cindexsub {\begingroup\obeylines\cindexsub} alpar@18: {\obeylines % alpar@18: \gdef\cindexsub "#1" #2^^M{\endgroup % alpar@18: \dosubind{cp}{#2}{#1}}} alpar@18: alpar@18: % Define the macros used in formatting output of the sorted index material. alpar@18: alpar@18: % @printindex causes a particular index (the ??s file) to get printed. alpar@18: % It does not print any chapter heading (usually an @unnumbered). alpar@18: % alpar@18: \def\printindex{\parsearg\doprintindex} alpar@18: \def\doprintindex#1{\begingroup alpar@18: \dobreak \chapheadingskip{10000}% alpar@18: % alpar@18: \smallfonts \rm alpar@18: \tolerance = 9500 alpar@18: \everypar = {}% don't want the \kern\-parindent from indentation suppression. alpar@18: \indexbreaks alpar@18: % alpar@18: % See if the index file exists and is nonempty. alpar@18: % Change catcode of @ here so that if the index file contains alpar@18: % \initial {@} alpar@18: % as its first line, TeX doesn't complain about mismatched braces alpar@18: % (because it thinks @} is a control sequence). alpar@18: \catcode`\@ = 11 alpar@18: \openin 1 \jobname.#1s alpar@18: \ifeof 1 alpar@18: % \enddoublecolumns gets confused if there is no text in the index, alpar@18: % and it loses the chapter title and the aux file entries for the alpar@18: % index. The easiest way to prevent this problem is to make sure alpar@18: % there is some text. alpar@18: \putwordIndexNonexistent alpar@18: \else alpar@18: % alpar@18: % If the index file exists but is empty, then \openin leaves \ifeof alpar@18: % false. We have to make TeX try to read something from the file, so alpar@18: % it can discover if there is anything in it. alpar@18: \read 1 to \temp alpar@18: \ifeof 1 alpar@18: \putwordIndexIsEmpty alpar@18: \else alpar@18: % Index files are almost Texinfo source, but we use \ as the escape alpar@18: % character. It would be better to use @, but that's too big a change alpar@18: % to make right now. alpar@18: \def\indexbackslash{\rawbackslashxx}% alpar@18: \catcode`\\ = 0 alpar@18: \escapechar = `\\ alpar@18: \begindoublecolumns alpar@18: \input \jobname.#1s alpar@18: \enddoublecolumns alpar@18: \fi alpar@18: \fi alpar@18: \closein 1 alpar@18: \endgroup} alpar@18: alpar@18: % These macros are used by the sorted index file itself. alpar@18: % Change them to control the appearance of the index. alpar@18: alpar@18: \def\initial#1{{% alpar@18: % Some minor font changes for the special characters. alpar@18: \let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt alpar@18: % alpar@18: % Remove any glue we may have, we'll be inserting our own. alpar@18: \removelastskip alpar@18: % alpar@18: % We like breaks before the index initials, so insert a bonus. alpar@18: \penalty -300 alpar@18: % alpar@18: % Typeset the initial. Making this add up to a whole number of alpar@18: % baselineskips increases the chance of the dots lining up from column alpar@18: % to column. It still won't often be perfect, because of the stretch alpar@18: % we need before each entry, but it's better. alpar@18: % alpar@18: % No shrink because it confuses \balancecolumns. alpar@18: \vskip 1.67\baselineskip plus .5\baselineskip alpar@18: \leftline{\secbf #1}% alpar@18: \vskip .33\baselineskip plus .1\baselineskip alpar@18: % alpar@18: % Do our best not to break after the initial. alpar@18: \nobreak alpar@18: }} alpar@18: alpar@18: % This typesets a paragraph consisting of #1, dot leaders, and then #2 alpar@18: % flush to the right margin. It is used for index and table of contents alpar@18: % entries. The paragraph is indented by \leftskip. alpar@18: % alpar@18: \def\entry#1#2{\begingroup alpar@18: % alpar@18: % Start a new paragraph if necessary, so our assignments below can't alpar@18: % affect previous text. alpar@18: \par alpar@18: % alpar@18: % Do not fill out the last line with white space. alpar@18: \parfillskip = 0in alpar@18: % alpar@18: % No extra space above this paragraph. alpar@18: \parskip = 0in alpar@18: % alpar@18: % Do not prefer a separate line ending with a hyphen to fewer lines. alpar@18: \finalhyphendemerits = 0 alpar@18: % alpar@18: % \hangindent is only relevant when the entry text and page number alpar@18: % don't both fit on one line. In that case, bob suggests starting the alpar@18: % dots pretty far over on the line. Unfortunately, a large alpar@18: % indentation looks wrong when the entry text itself is broken across alpar@18: % lines. So we use a small indentation and put up with long leaders. alpar@18: % alpar@18: % \hangafter is reset to 1 (which is the value we want) at the start alpar@18: % of each paragraph, so we need not do anything with that. alpar@18: \hangindent = 2em alpar@18: % alpar@18: % When the entry text needs to be broken, just fill out the first line alpar@18: % with blank space. alpar@18: \rightskip = 0pt plus1fil alpar@18: % alpar@18: % A bit of stretch before each entry for the benefit of balancing columns. alpar@18: \vskip 0pt plus1pt alpar@18: % alpar@18: % Start a ``paragraph'' for the index entry so the line breaking alpar@18: % parameters we've set above will have an effect. alpar@18: \noindent alpar@18: % alpar@18: % Insert the text of the index entry. TeX will do line-breaking on it. alpar@18: #1% alpar@18: % The following is kludged to not output a line of dots in the index if alpar@18: % there are no page numbers. The next person who breaks this will be alpar@18: % cursed by a Unix daemon. alpar@18: \def\tempa{{\rm }}% alpar@18: \def\tempb{#2}% alpar@18: \edef\tempc{\tempa}% alpar@18: \edef\tempd{\tempb}% alpar@18: \ifx\tempc\tempd\ \else% alpar@18: % alpar@18: % If we must, put the page number on a line of its own, and fill out alpar@18: % this line with blank space. (The \hfil is overwhelmed with the alpar@18: % fill leaders glue in \indexdotfill if the page number does fit.) alpar@18: \hfil\penalty50 alpar@18: \null\nobreak\indexdotfill % Have leaders before the page number. alpar@18: % alpar@18: % The `\ ' here is removed by the implicit \unskip that TeX does as alpar@18: % part of (the primitive) \par. Without it, a spurious underfull alpar@18: % \hbox ensues. alpar@18: \ifpdf alpar@18: \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph. alpar@18: \else alpar@18: \ #2% The page number ends the paragraph. alpar@18: \fi alpar@18: \fi% alpar@18: \par alpar@18: \endgroup} alpar@18: alpar@18: % Like \dotfill except takes at least 1 em. alpar@18: \def\indexdotfill{\cleaders alpar@18: \hbox{$\mathsurround=0pt \mkern1.5mu ${\it .}$ \mkern1.5mu$}\hskip 1em plus 1fill} alpar@18: alpar@18: \def\primary #1{\line{#1\hfil}} alpar@18: alpar@18: \newskip\secondaryindent \secondaryindent=0.5cm alpar@18: \def\secondary#1#2{{% alpar@18: \parfillskip=0in alpar@18: \parskip=0in alpar@18: \hangindent=1in alpar@18: \hangafter=1 alpar@18: \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill alpar@18: \ifpdf alpar@18: \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph. alpar@18: \else alpar@18: #2 alpar@18: \fi alpar@18: \par alpar@18: }} alpar@18: alpar@18: % Define two-column mode, which we use to typeset indexes. alpar@18: % Adapted from the TeXbook, page 416, which is to say, alpar@18: % the manmac.tex format used to print the TeXbook itself. alpar@18: \catcode`\@=11 alpar@18: alpar@18: \newbox\partialpage alpar@18: \newdimen\doublecolumnhsize alpar@18: alpar@18: \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns alpar@18: % Grab any single-column material above us. alpar@18: \output = {% alpar@18: % alpar@18: % Here is a possibility not foreseen in manmac: if we accumulate a alpar@18: % whole lot of material, we might end up calling this \output alpar@18: % routine twice in a row (see the doublecol-lose test, which is alpar@18: % essentially a couple of indexes with @setchapternewpage off). In alpar@18: % that case we just ship out what is in \partialpage with the normal alpar@18: % output routine. Generally, \partialpage will be empty when this alpar@18: % runs and this will be a no-op. See the indexspread.tex test case. alpar@18: \ifvoid\partialpage \else alpar@18: \onepageout{\pagecontents\partialpage}% alpar@18: \fi alpar@18: % alpar@18: \global\setbox\partialpage = \vbox{% alpar@18: % Unvbox the main output page. alpar@18: \unvbox\PAGE alpar@18: \kern-\topskip \kern\baselineskip alpar@18: }% alpar@18: }% alpar@18: \eject % run that output routine to set \partialpage alpar@18: % alpar@18: % Use the double-column output routine for subsequent pages. alpar@18: \output = {\doublecolumnout}% alpar@18: % alpar@18: % Change the page size parameters. We could do this once outside this alpar@18: % routine, in each of @smallbook, @afourpaper, and the default 8.5x11 alpar@18: % format, but then we repeat the same computation. Repeating a couple alpar@18: % of assignments once per index is clearly meaningless for the alpar@18: % execution time, so we may as well do it in one place. alpar@18: % alpar@18: % First we halve the line length, less a little for the gutter between alpar@18: % the columns. We compute the gutter based on the line length, so it alpar@18: % changes automatically with the paper format. The magic constant alpar@18: % below is chosen so that the gutter has the same value (well, +-<1pt) alpar@18: % as it did when we hard-coded it. alpar@18: % alpar@18: % We put the result in a separate register, \doublecolumhsize, so we alpar@18: % can restore it in \pagesofar, after \hsize itself has (potentially) alpar@18: % been clobbered. alpar@18: % alpar@18: \doublecolumnhsize = \hsize alpar@18: \advance\doublecolumnhsize by -.04154\hsize alpar@18: \divide\doublecolumnhsize by 2 alpar@18: \hsize = \doublecolumnhsize alpar@18: % alpar@18: % Double the \vsize as well. (We don't need a separate register here, alpar@18: % since nobody clobbers \vsize.) alpar@18: \vsize = 2\vsize alpar@18: } alpar@18: alpar@18: % The double-column output routine for all double-column pages except alpar@18: % the last. alpar@18: % alpar@18: \def\doublecolumnout{% alpar@18: \splittopskip=\topskip \splitmaxdepth=\maxdepth alpar@18: % Get the available space for the double columns -- the normal alpar@18: % (undoubled) page height minus any material left over from the alpar@18: % previous page. alpar@18: \dimen@ = \vsize alpar@18: \divide\dimen@ by 2 alpar@18: \advance\dimen@ by -\ht\partialpage alpar@18: % alpar@18: % box0 will be the left-hand column, box2 the right. alpar@18: \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@ alpar@18: \onepageout\pagesofar alpar@18: \unvbox255 alpar@18: \penalty\outputpenalty alpar@18: } alpar@18: % alpar@18: % Re-output the contents of the output page -- any previous material, alpar@18: % followed by the two boxes we just split, in box0 and box2. alpar@18: \def\pagesofar{% alpar@18: \unvbox\partialpage alpar@18: % alpar@18: \hsize = \doublecolumnhsize alpar@18: \wd0=\hsize \wd2=\hsize alpar@18: \hbox to\pagewidth{\box0\hfil\box2}% alpar@18: } alpar@18: % alpar@18: % All done with double columns. alpar@18: \def\enddoublecolumns{% alpar@18: \output = {% alpar@18: % Split the last of the double-column material. Leave it on the alpar@18: % current page, no automatic page break. alpar@18: \balancecolumns alpar@18: % alpar@18: % If we end up splitting too much material for the current page, alpar@18: % though, there will be another page break right after this \output alpar@18: % invocation ends. Having called \balancecolumns once, we do not alpar@18: % want to call it again. Therefore, reset \output to its normal alpar@18: % definition right away. (We hope \balancecolumns will never be alpar@18: % called on to balance too much material, but if it is, this makes alpar@18: % the output somewhat more palatable.) alpar@18: \global\output = {\onepageout{\pagecontents\PAGE}}% alpar@18: }% alpar@18: \eject alpar@18: \endgroup % started in \begindoublecolumns alpar@18: % alpar@18: % \pagegoal was set to the doubled \vsize above, since we restarted alpar@18: % the current page. We're now back to normal single-column alpar@18: % typesetting, so reset \pagegoal to the normal \vsize (after the alpar@18: % \endgroup where \vsize got restored). alpar@18: \pagegoal = \vsize alpar@18: } alpar@18: % alpar@18: % Called at the end of the double column material. alpar@18: \def\balancecolumns{% alpar@18: \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120. alpar@18: \dimen@ = \ht0 alpar@18: \advance\dimen@ by \topskip alpar@18: \advance\dimen@ by-\baselineskip alpar@18: \divide\dimen@ by 2 % target to split to alpar@18: %debug\message{final 2-column material height=\the\ht0, target=\the\dimen@.}% alpar@18: \splittopskip = \topskip alpar@18: % Loop until we get a decent breakpoint. alpar@18: {% alpar@18: \vbadness = 10000 alpar@18: \loop alpar@18: \global\setbox3 = \copy0 alpar@18: \global\setbox1 = \vsplit3 to \dimen@ alpar@18: \ifdim\ht3>\dimen@ alpar@18: \global\advance\dimen@ by 1pt alpar@18: \repeat alpar@18: }% alpar@18: %debug\message{split to \the\dimen@, column heights: \the\ht1, \the\ht3.}% alpar@18: \setbox0=\vbox to\dimen@{\unvbox1}% alpar@18: \setbox2=\vbox to\dimen@{\unvbox3}% alpar@18: % alpar@18: \pagesofar alpar@18: } alpar@18: \catcode`\@ = \other alpar@18: alpar@18: alpar@18: \message{sectioning,} alpar@18: % Chapters, sections, etc. alpar@18: alpar@18: \newcount\chapno alpar@18: \newcount\secno \secno=0 alpar@18: \newcount\subsecno \subsecno=0 alpar@18: \newcount\subsubsecno \subsubsecno=0 alpar@18: alpar@18: % This counter is funny since it counts through charcodes of letters A, B, ... alpar@18: \newcount\appendixno \appendixno = `\@ alpar@18: % \def\appendixletter{\char\the\appendixno} alpar@18: % We do the following for the sake of pdftex, which needs the actual alpar@18: % letter in the expansion, not just typeset. alpar@18: \def\appendixletter{% alpar@18: \ifnum\appendixno=`A A% alpar@18: \else\ifnum\appendixno=`B B% alpar@18: \else\ifnum\appendixno=`C C% alpar@18: \else\ifnum\appendixno=`D D% alpar@18: \else\ifnum\appendixno=`E E% alpar@18: \else\ifnum\appendixno=`F F% alpar@18: \else\ifnum\appendixno=`G G% alpar@18: \else\ifnum\appendixno=`H H% alpar@18: \else\ifnum\appendixno=`I I% alpar@18: \else\ifnum\appendixno=`J J% alpar@18: \else\ifnum\appendixno=`K K% alpar@18: \else\ifnum\appendixno=`L L% alpar@18: \else\ifnum\appendixno=`M M% alpar@18: \else\ifnum\appendixno=`N N% alpar@18: \else\ifnum\appendixno=`O O% alpar@18: \else\ifnum\appendixno=`P P% alpar@18: \else\ifnum\appendixno=`Q Q% alpar@18: \else\ifnum\appendixno=`R R% alpar@18: \else\ifnum\appendixno=`S S% alpar@18: \else\ifnum\appendixno=`T T% alpar@18: \else\ifnum\appendixno=`U U% alpar@18: \else\ifnum\appendixno=`V V% alpar@18: \else\ifnum\appendixno=`W W% alpar@18: \else\ifnum\appendixno=`X X% alpar@18: \else\ifnum\appendixno=`Y Y% alpar@18: \else\ifnum\appendixno=`Z Z% alpar@18: % The \the is necessary, despite appearances, because \appendixletter is alpar@18: % expanded while writing the .toc file. \char\appendixno is not alpar@18: % expandable, thus it is written literally, thus all appendixes come out alpar@18: % with the same letter (or @) in the toc without it. alpar@18: \else\char\the\appendixno alpar@18: \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi alpar@18: \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi} alpar@18: alpar@18: % Each @chapter defines this as the name of the chapter. alpar@18: % page headings and footings can use it. @section does likewise. alpar@18: \def\thischapter{} alpar@18: \def\thissection{} alpar@18: alpar@18: \newcount\absseclevel % used to calculate proper heading level alpar@18: \newcount\secbase\secbase=0 % @raise/lowersections modify this count alpar@18: alpar@18: % @raisesections: treat @section as chapter, @subsection as section, etc. alpar@18: \def\raisesections{\global\advance\secbase by -1} alpar@18: \let\up=\raisesections % original BFox name alpar@18: alpar@18: % @lowersections: treat @chapter as section, @section as subsection, etc. alpar@18: \def\lowersections{\global\advance\secbase by 1} alpar@18: \let\down=\lowersections % original BFox name alpar@18: alpar@18: % Choose a numbered-heading macro alpar@18: % #1 is heading level if unmodified by @raisesections or @lowersections alpar@18: % #2 is text for heading alpar@18: \def\numhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 alpar@18: \ifcase\absseclevel alpar@18: \chapterzzz{#2} alpar@18: \or alpar@18: \seczzz{#2} alpar@18: \or alpar@18: \numberedsubseczzz{#2} alpar@18: \or alpar@18: \numberedsubsubseczzz{#2} alpar@18: \else alpar@18: \ifnum \absseclevel<0 alpar@18: \chapterzzz{#2} alpar@18: \else alpar@18: \numberedsubsubseczzz{#2} alpar@18: \fi alpar@18: \fi alpar@18: \suppressfirstparagraphindent alpar@18: } alpar@18: alpar@18: % like \numhead, but chooses appendix heading levels alpar@18: \def\apphead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 alpar@18: \ifcase\absseclevel alpar@18: \appendixzzz{#2} alpar@18: \or alpar@18: \appendixsectionzzz{#2} alpar@18: \or alpar@18: \appendixsubseczzz{#2} alpar@18: \or alpar@18: \appendixsubsubseczzz{#2} alpar@18: \else alpar@18: \ifnum \absseclevel<0 alpar@18: \appendixzzz{#2} alpar@18: \else alpar@18: \appendixsubsubseczzz{#2} alpar@18: \fi alpar@18: \fi alpar@18: \suppressfirstparagraphindent alpar@18: } alpar@18: alpar@18: % like \numhead, but chooses numberless heading levels alpar@18: \def\unnmhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 alpar@18: \ifcase\absseclevel alpar@18: \unnumberedzzz{#2} alpar@18: \or alpar@18: \unnumberedseczzz{#2} alpar@18: \or alpar@18: \unnumberedsubseczzz{#2} alpar@18: \or alpar@18: \unnumberedsubsubseczzz{#2} alpar@18: \else alpar@18: \ifnum \absseclevel<0 alpar@18: \unnumberedzzz{#2} alpar@18: \else alpar@18: \unnumberedsubsubseczzz{#2} alpar@18: \fi alpar@18: \fi alpar@18: \suppressfirstparagraphindent alpar@18: } alpar@18: alpar@18: % @chapter, @appendix, @unnumbered. alpar@18: \def\thischaptername{No Chapter Title} alpar@18: \outer\def\chapter{\parsearg\chapteryyy} alpar@18: \def\chapteryyy #1{\numhead0{#1}} % normally numhead0 calls chapterzzz alpar@18: \def\chapterzzz #1{% alpar@18: \secno=0 \subsecno=0 \subsubsecno=0 alpar@18: \global\advance \chapno by 1 \message{\putwordChapter\space \the\chapno}% alpar@18: \chapmacro {#1}{\the\chapno}% alpar@18: \gdef\thissection{#1}% alpar@18: \gdef\thischaptername{#1}% alpar@18: % We don't substitute the actual chapter name into \thischapter alpar@18: % because we don't want its macros evaluated now. alpar@18: \xdef\thischapter{\putwordChapter{} \the\chapno: \noexpand\thischaptername}% alpar@18: \writetocentry{chap}{#1}{{\the\chapno}} alpar@18: \donoderef alpar@18: \global\let\section = \numberedsec alpar@18: \global\let\subsection = \numberedsubsec alpar@18: \global\let\subsubsection = \numberedsubsubsec alpar@18: } alpar@18: alpar@18: % we use \chapno to avoid indenting back alpar@18: \def\appendixbox#1{% alpar@18: \setbox0 = \hbox{\putwordAppendix{} \the\chapno}% alpar@18: \hbox to \wd0{#1\hss}} alpar@18: alpar@18: \outer\def\appendix{\parsearg\appendixyyy} alpar@18: \def\appendixyyy #1{\apphead0{#1}} % normally apphead0 calls appendixzzz alpar@18: \def\appendixzzz #1{% alpar@18: \secno=0 \subsecno=0 \subsubsecno=0 alpar@18: \global\advance \appendixno by 1 alpar@18: \message{\putwordAppendix\space \appendixletter}% alpar@18: \chapmacro {#1}{\appendixbox{\putwordAppendix{} \appendixletter}}% alpar@18: \gdef\thissection{#1}% alpar@18: \gdef\thischaptername{#1}% alpar@18: \xdef\thischapter{\putwordAppendix{} \appendixletter: \noexpand\thischaptername}% alpar@18: \writetocentry{appendix}{#1}{{\appendixletter}} alpar@18: \appendixnoderef alpar@18: \global\let\section = \appendixsec alpar@18: \global\let\subsection = \appendixsubsec alpar@18: \global\let\subsubsection = \appendixsubsubsec alpar@18: } alpar@18: alpar@18: % @centerchap is like @unnumbered, but the heading is centered. alpar@18: \outer\def\centerchap{\parsearg\centerchapyyy} alpar@18: \def\centerchapyyy #1{{\let\unnumbchapmacro=\centerchapmacro \unnumberedyyy{#1}}} alpar@18: alpar@18: % @top is like @unnumbered. alpar@18: \outer\def\top{\parsearg\unnumberedyyy} alpar@18: alpar@18: \outer\def\unnumbered{\parsearg\unnumberedyyy} alpar@18: \def\unnumberedyyy #1{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz alpar@18: \def\unnumberedzzz #1{% alpar@18: \secno=0 \subsecno=0 \subsubsecno=0 alpar@18: % alpar@18: % This used to be simply \message{#1}, but TeX fully expands the alpar@18: % argument to \message. Therefore, if #1 contained @-commands, TeX alpar@18: % expanded them. For example, in `@unnumbered The @cite{Book}', TeX alpar@18: % expanded @cite (which turns out to cause errors because \cite is meant alpar@18: % to be executed, not expanded). alpar@18: % alpar@18: % Anyway, we don't want the fully-expanded definition of @cite to appear alpar@18: % as a result of the \message, we just want `@cite' itself. We use alpar@18: % \the to achieve this: TeX expands \the only once, alpar@18: % simply yielding the contents of . (We also do this for alpar@18: % the toc entries.) alpar@18: \toks0 = {#1}\message{(\the\toks0)}% alpar@18: % alpar@18: \unnumbchapmacro {#1}% alpar@18: \gdef\thischapter{#1}\gdef\thissection{#1}% alpar@18: \writetocentry{unnumbchap}{#1}{{\the\chapno}} alpar@18: \unnumbnoderef alpar@18: \global\let\section = \unnumberedsec alpar@18: \global\let\subsection = \unnumberedsubsec alpar@18: \global\let\subsubsection = \unnumberedsubsubsec alpar@18: } alpar@18: alpar@18: % Sections. alpar@18: \outer\def\numberedsec{\parsearg\secyyy} alpar@18: \def\secyyy #1{\numhead1{#1}} % normally calls seczzz alpar@18: \def\seczzz #1{% alpar@18: \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % alpar@18: \gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}% alpar@18: \writetocentry{sec}{#1}{{\the\chapno}{\the\secno}} alpar@18: \donoderef alpar@18: \nobreak alpar@18: } alpar@18: alpar@18: \outer\def\appendixsection{\parsearg\appendixsecyyy} alpar@18: \outer\def\appendixsec{\parsearg\appendixsecyyy} alpar@18: \def\appendixsecyyy #1{\apphead1{#1}} % normally calls appendixsectionzzz alpar@18: \def\appendixsectionzzz #1{% alpar@18: \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % alpar@18: \gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}% alpar@18: \writetocentry{sec}{#1}{{\appendixletter}{\the\secno}} alpar@18: \appendixnoderef alpar@18: \nobreak alpar@18: } alpar@18: alpar@18: \outer\def\unnumberedsec{\parsearg\unnumberedsecyyy} alpar@18: \def\unnumberedsecyyy #1{\unnmhead1{#1}} % normally calls unnumberedseczzz alpar@18: \def\unnumberedseczzz #1{% alpar@18: \plainsecheading {#1}\gdef\thissection{#1}% alpar@18: \writetocentry{unnumbsec}{#1}{{\the\chapno}{\the\secno}} alpar@18: \unnumbnoderef alpar@18: \nobreak alpar@18: } alpar@18: alpar@18: % Subsections. alpar@18: \outer\def\numberedsubsec{\parsearg\numberedsubsecyyy} alpar@18: \def\numberedsubsecyyy #1{\numhead2{#1}} % normally calls numberedsubseczzz alpar@18: \def\numberedsubseczzz #1{% alpar@18: \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % alpar@18: \subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}% alpar@18: \writetocentry{subsec}{#1}{{\the\chapno}{\the\secno}{\the\subsecno}} alpar@18: \donoderef alpar@18: \nobreak alpar@18: } alpar@18: alpar@18: \outer\def\appendixsubsec{\parsearg\appendixsubsecyyy} alpar@18: \def\appendixsubsecyyy #1{\apphead2{#1}} % normally calls appendixsubseczzz alpar@18: \def\appendixsubseczzz #1{% alpar@18: \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % alpar@18: \subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}% alpar@18: \writetocentry{subsec}{#1}{{\appendixletter}{\the\secno}{\the\subsecno}} alpar@18: \appendixnoderef alpar@18: \nobreak alpar@18: } alpar@18: alpar@18: \outer\def\unnumberedsubsec{\parsearg\unnumberedsubsecyyy} alpar@18: \def\unnumberedsubsecyyy #1{\unnmhead2{#1}} %normally calls unnumberedsubseczzz alpar@18: \def\unnumberedsubseczzz #1{% alpar@18: \plainsubsecheading {#1}\gdef\thissection{#1}% alpar@18: \writetocentry{unnumbsubsec}{#1}{{\the\chapno}{\the\secno}{\the\subsecno}} alpar@18: \unnumbnoderef alpar@18: \nobreak alpar@18: } alpar@18: alpar@18: % Subsubsections. alpar@18: \outer\def\numberedsubsubsec{\parsearg\numberedsubsubsecyyy} alpar@18: \def\numberedsubsubsecyyy #1{\numhead3{#1}} % normally numberedsubsubseczzz alpar@18: \def\numberedsubsubseczzz #1{% alpar@18: \gdef\thissection{#1}\global\advance \subsubsecno by 1 % alpar@18: \subsubsecheading {#1} alpar@18: {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}% alpar@18: \writetocentry{subsubsec}{#1}{{\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}} alpar@18: \donoderef alpar@18: \nobreak alpar@18: } alpar@18: alpar@18: \outer\def\appendixsubsubsec{\parsearg\appendixsubsubsecyyy} alpar@18: \def\appendixsubsubsecyyy #1{\apphead3{#1}} % normally appendixsubsubseczzz alpar@18: \def\appendixsubsubseczzz #1{% alpar@18: \gdef\thissection{#1}\global\advance \subsubsecno by 1 % alpar@18: \subsubsecheading {#1} alpar@18: {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}% alpar@18: \writetocentry{subsubsec}{#1}{{\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}} alpar@18: \appendixnoderef alpar@18: \nobreak alpar@18: } alpar@18: alpar@18: \outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubsecyyy} alpar@18: \def\unnumberedsubsubsecyyy #1{\unnmhead3{#1}} %normally unnumberedsubsubseczzz alpar@18: \def\unnumberedsubsubseczzz #1{% alpar@18: \plainsubsubsecheading {#1}\gdef\thissection{#1}% alpar@18: \writetocentry{unnumbsubsubsec}{#1}{{\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}} alpar@18: \unnumbnoderef alpar@18: \nobreak alpar@18: } alpar@18: alpar@18: % These are variants which are not "outer", so they can appear in @ifinfo. alpar@18: % Actually, they should now be obsolete; ordinary section commands should work. alpar@18: \def\infotop{\parsearg\unnumberedzzz} alpar@18: \def\infounnumbered{\parsearg\unnumberedzzz} alpar@18: \def\infounnumberedsec{\parsearg\unnumberedseczzz} alpar@18: \def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz} alpar@18: \def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz} alpar@18: alpar@18: \def\infoappendix{\parsearg\appendixzzz} alpar@18: \def\infoappendixsec{\parsearg\appendixseczzz} alpar@18: \def\infoappendixsubsec{\parsearg\appendixsubseczzz} alpar@18: \def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz} alpar@18: alpar@18: \def\infochapter{\parsearg\chapterzzz} alpar@18: \def\infosection{\parsearg\sectionzzz} alpar@18: \def\infosubsection{\parsearg\subsectionzzz} alpar@18: \def\infosubsubsection{\parsearg\subsubsectionzzz} alpar@18: alpar@18: % These macros control what the section commands do, according alpar@18: % to what kind of chapter we are in (ordinary, appendix, or unnumbered). alpar@18: % Define them by default for a numbered chapter. alpar@18: \global\let\section = \numberedsec alpar@18: \global\let\subsection = \numberedsubsec alpar@18: \global\let\subsubsection = \numberedsubsubsec alpar@18: alpar@18: % Define @majorheading, @heading and @subheading alpar@18: alpar@18: % NOTE on use of \vbox for chapter headings, section headings, and such: alpar@18: % 1) We use \vbox rather than the earlier \line to permit alpar@18: % overlong headings to fold. alpar@18: % 2) \hyphenpenalty is set to 10000 because hyphenation in a alpar@18: % heading is obnoxious; this forbids it. alpar@18: % 3) Likewise, headings look best if no \parindent is used, and alpar@18: % if justification is not attempted. Hence \raggedright. alpar@18: alpar@18: alpar@18: \def\majorheading{% alpar@18: {\advance\chapheadingskip by 10pt \chapbreak }% alpar@18: \parsearg\chapheadingzzz alpar@18: } alpar@18: alpar@18: \def\chapheading{\chapbreak \parsearg\chapheadingzzz} alpar@18: \def\chapheadingzzz #1{% alpar@18: {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 alpar@18: \parindent=0pt\raggedright alpar@18: \rm #1\hfill}}% alpar@18: \bigskip \par\penalty 200\relax alpar@18: \suppressfirstparagraphindent alpar@18: } alpar@18: alpar@18: % @heading, @subheading, @subsubheading. alpar@18: \def\heading{\parsearg\doheading} alpar@18: \def\subheading{\parsearg\dosubheading} alpar@18: \def\subsubheading{\parsearg\dosubsubheading} alpar@18: \def\doheading#1{\plainsecheading{#1}\suppressfirstparagraphindent} alpar@18: \def\dosubheading#1{\plainsubsecheading{#1}\suppressfirstparagraphindent} alpar@18: \def\dosubsubheading#1{\plainsubsubsecheading{#1}\suppressfirstparagraphindent} alpar@18: alpar@18: % These macros generate a chapter, section, etc. heading only alpar@18: % (including whitespace, linebreaking, etc. around it), alpar@18: % given all the information in convenient, parsed form. alpar@18: alpar@18: %%% Args are the skip and penalty (usually negative) alpar@18: \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi} alpar@18: alpar@18: \def\setchapterstyle #1 {\csname CHAPF#1\endcsname} alpar@18: alpar@18: %%% Define plain chapter starts, and page on/off switching for it alpar@18: % Parameter controlling skip before chapter headings (if needed) alpar@18: alpar@18: \newskip\chapheadingskip alpar@18: alpar@18: \def\chapbreak{\dobreak \chapheadingskip {-4000}} alpar@18: \def\chappager{\par\vfill\supereject} alpar@18: \def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi} alpar@18: alpar@18: \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname} alpar@18: alpar@18: \def\CHAPPAGoff{% alpar@18: \global\let\contentsalignmacro = \chappager alpar@18: \global\let\pchapsepmacro=\chapbreak alpar@18: \global\let\pagealignmacro=\chappager} alpar@18: alpar@18: \def\CHAPPAGon{% alpar@18: \global\let\contentsalignmacro = \chappager alpar@18: \global\let\pchapsepmacro=\chappager alpar@18: \global\let\pagealignmacro=\chappager alpar@18: \global\def\HEADINGSon{\HEADINGSsingle}} alpar@18: alpar@18: \def\CHAPPAGodd{ alpar@18: \global\let\contentsalignmacro = \chapoddpage alpar@18: \global\let\pchapsepmacro=\chapoddpage alpar@18: \global\let\pagealignmacro=\chapoddpage alpar@18: \global\def\HEADINGSon{\HEADINGSdouble}} alpar@18: alpar@18: \CHAPPAGon alpar@18: alpar@18: \def\CHAPFplain{ alpar@18: \global\let\chapmacro=\chfplain alpar@18: \global\let\unnumbchapmacro=\unnchfplain alpar@18: \global\let\centerchapmacro=\centerchfplain} alpar@18: alpar@18: % Plain chapter opening. alpar@18: % #1 is the text, #2 the chapter number or empty if unnumbered. alpar@18: \def\chfplain#1#2{% alpar@18: \pchapsepmacro alpar@18: {% alpar@18: \chapfonts \rm alpar@18: \def\chapnum{#2}% alpar@18: \setbox0 = \hbox{#2\ifx\chapnum\empty\else\enspace\fi}% alpar@18: \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright alpar@18: \hangindent = \wd0 \centerparametersmaybe alpar@18: \unhbox0 #1\par}% alpar@18: }% alpar@18: \nobreak\bigskip % no page break after a chapter title alpar@18: \nobreak alpar@18: } alpar@18: alpar@18: % Plain opening for unnumbered. alpar@18: \def\unnchfplain#1{\chfplain{#1}{}} alpar@18: alpar@18: % @centerchap -- centered and unnumbered. alpar@18: \let\centerparametersmaybe = \relax alpar@18: \def\centerchfplain#1{{% alpar@18: \def\centerparametersmaybe{% alpar@18: \advance\rightskip by 3\rightskip alpar@18: \leftskip = \rightskip alpar@18: \parfillskip = 0pt alpar@18: }% alpar@18: \chfplain{#1}{}% alpar@18: }} alpar@18: alpar@18: \CHAPFplain % The default alpar@18: alpar@18: \def\unnchfopen #1{% alpar@18: \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 alpar@18: \parindent=0pt\raggedright alpar@18: \rm #1\hfill}}\bigskip \par\nobreak alpar@18: } alpar@18: alpar@18: \def\chfopen #1#2{\chapoddpage {\chapfonts alpar@18: \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}% alpar@18: \par\penalty 5000 % alpar@18: } alpar@18: alpar@18: \def\centerchfopen #1{% alpar@18: \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 alpar@18: \parindent=0pt alpar@18: \hfill {\rm #1}\hfill}}\bigskip \par\nobreak alpar@18: } alpar@18: alpar@18: \def\CHAPFopen{ alpar@18: \global\let\chapmacro=\chfopen alpar@18: \global\let\unnumbchapmacro=\unnchfopen alpar@18: \global\let\centerchapmacro=\centerchfopen} alpar@18: alpar@18: alpar@18: % Section titles. alpar@18: \newskip\secheadingskip alpar@18: \def\secheadingbreak{\dobreak \secheadingskip {-1000}} alpar@18: \def\secheading#1#2#3{\sectionheading{sec}{#2.#3}{#1}} alpar@18: \def\plainsecheading#1{\sectionheading{sec}{}{#1}} alpar@18: alpar@18: % Subsection titles. alpar@18: \newskip \subsecheadingskip alpar@18: \def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}} alpar@18: \def\subsecheading#1#2#3#4{\sectionheading{subsec}{#2.#3.#4}{#1}} alpar@18: \def\plainsubsecheading#1{\sectionheading{subsec}{}{#1}} alpar@18: alpar@18: % Subsubsection titles. alpar@18: \let\subsubsecheadingskip = \subsecheadingskip alpar@18: \let\subsubsecheadingbreak = \subsecheadingbreak alpar@18: \def\subsubsecheading#1#2#3#4#5{\sectionheading{subsubsec}{#2.#3.#4.#5}{#1}} alpar@18: \def\plainsubsubsecheading#1{\sectionheading{subsubsec}{}{#1}} alpar@18: alpar@18: alpar@18: % Print any size section title. alpar@18: % alpar@18: % #1 is the section type (sec/subsec/subsubsec), #2 is the section alpar@18: % number (maybe empty), #3 the text. alpar@18: \def\sectionheading#1#2#3{% alpar@18: {% alpar@18: \expandafter\advance\csname #1headingskip\endcsname by \parskip alpar@18: \csname #1headingbreak\endcsname alpar@18: }% alpar@18: {% alpar@18: % Switch to the right set of fonts. alpar@18: \csname #1fonts\endcsname \rm alpar@18: % alpar@18: % Only insert the separating space if we have a section number. alpar@18: \def\secnum{#2}% alpar@18: \setbox0 = \hbox{#2\ifx\secnum\empty\else\enspace\fi}% alpar@18: % alpar@18: \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright alpar@18: \hangindent = \wd0 % zero if no section number alpar@18: \unhbox0 #3}% alpar@18: }% alpar@18: % Add extra space after the heading -- either a line space or a alpar@18: % paragraph space, whichever is more. (Some people like to set alpar@18: % \parskip to large values for some reason.) Don't allow stretch, though. alpar@18: \nobreak alpar@18: \ifdim\parskip>\normalbaselineskip alpar@18: \kern\parskip alpar@18: \else alpar@18: \kern\normalbaselineskip alpar@18: \fi alpar@18: \nobreak alpar@18: } alpar@18: alpar@18: alpar@18: \message{toc,} alpar@18: % Table of contents. alpar@18: \newwrite\tocfile alpar@18: alpar@18: % Write an entry to the toc file, opening it if necessary. alpar@18: % Called from @chapter, etc. We supply {\folio} at the end of the alpar@18: % argument, which will end up as the last argument to the \...entry macro. alpar@18: % alpar@18: % Usage: \writetocentry{chap}{The Name of The Game}{{\the\chapno}} alpar@18: % We open the .toc file for writing here instead of at @setfilename (or alpar@18: % any other fixed time) so that @contents can be anywhere in the document. alpar@18: % alpar@18: \newif\iftocfileopened alpar@18: \def\writetocentry#1#2#3{% alpar@18: \iftocfileopened\else alpar@18: \immediate\openout\tocfile = \jobname.toc alpar@18: \global\tocfileopenedtrue alpar@18: \fi alpar@18: % alpar@18: \iflinks alpar@18: \toks0 = {#2}% alpar@18: \edef\temp{\write\tocfile{\realbackslash #1entry{\the\toks0}#3{\folio}}}% alpar@18: \temp alpar@18: \fi alpar@18: % alpar@18: % Tell \shipout to create a page destination if we're doing pdf, which alpar@18: % will be the target of the links in the table of contents. We can't alpar@18: % just do it on every page because the title pages are numbered 1 and alpar@18: % 2 (the page numbers aren't printed), and so are the first two pages alpar@18: % of the document. Thus, we'd have two destinations named `1', and alpar@18: % two named `2'. alpar@18: \ifpdf \pdfmakepagedesttrue \fi alpar@18: } alpar@18: alpar@18: \newskip\contentsrightmargin \contentsrightmargin=1in alpar@18: \newcount\savepageno alpar@18: \newcount\lastnegativepageno \lastnegativepageno = -1 alpar@18: alpar@18: % Finish up the main text and prepare to read what we've written alpar@18: % to \tocfile. alpar@18: % alpar@18: \def\startcontents#1{% alpar@18: % If @setchapternewpage on, and @headings double, the contents should alpar@18: % start on an odd page, unlike chapters. Thus, we maintain alpar@18: % \contentsalignmacro in parallel with \pagealignmacro. alpar@18: % From: Torbjorn Granlund alpar@18: \contentsalignmacro alpar@18: \immediate\closeout\tocfile alpar@18: % alpar@18: % Don't need to put `Contents' or `Short Contents' in the headline. alpar@18: % It is abundantly clear what they are. alpar@18: \unnumbchapmacro{#1}\def\thischapter{}% alpar@18: \savepageno = \pageno alpar@18: \begingroup % Set up to handle contents files properly. alpar@18: \catcode`\\=0 \catcode`\{=1 \catcode`\}=2 \catcode`\@=11 alpar@18: % We can't do this, because then an actual ^ in a section alpar@18: % title fails, e.g., @chapter ^ -- exponentiation. --karl, 9jul97. alpar@18: %\catcode`\^=7 % to see ^^e4 as \"a etc. juha@piuha.ydi.vtt.fi alpar@18: \raggedbottom % Worry more about breakpoints than the bottom. alpar@18: \advance\hsize by -\contentsrightmargin % Don't use the full line length. alpar@18: % alpar@18: % Roman numerals for page numbers. alpar@18: \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi alpar@18: } alpar@18: alpar@18: alpar@18: % Normal (long) toc. alpar@18: \def\contents{% alpar@18: \startcontents{\putwordTOC}% alpar@18: \openin 1 \jobname.toc alpar@18: \ifeof 1 \else alpar@18: \closein 1 alpar@18: \input \jobname.toc alpar@18: \fi alpar@18: \vfill \eject alpar@18: \contentsalignmacro % in case @setchapternewpage odd is in effect alpar@18: \pdfmakeoutlines alpar@18: \endgroup alpar@18: \lastnegativepageno = \pageno alpar@18: \global\pageno = \savepageno alpar@18: } alpar@18: alpar@18: % And just the chapters. alpar@18: \def\summarycontents{% alpar@18: \startcontents{\putwordShortTOC}% alpar@18: % alpar@18: \let\chapentry = \shortchapentry alpar@18: \let\appendixentry = \shortappendixentry alpar@18: \let\unnumbchapentry = \shortunnumberedentry alpar@18: % We want a true roman here for the page numbers. alpar@18: \secfonts alpar@18: \let\rm=\shortcontrm \let\bf=\shortcontbf alpar@18: \let\sl=\shortcontsl \let\tt=\shortconttt alpar@18: \rm alpar@18: \hyphenpenalty = 10000 alpar@18: \advance\baselineskip by 1pt % Open it up a little. alpar@18: \def\secentry ##1##2##3##4{} alpar@18: \def\subsecentry ##1##2##3##4##5{} alpar@18: \def\subsubsecentry ##1##2##3##4##5##6{} alpar@18: \let\unnumbsecentry = \secentry alpar@18: \let\unnumbsubsecentry = \subsecentry alpar@18: \let\unnumbsubsubsecentry = \subsubsecentry alpar@18: \openin 1 \jobname.toc alpar@18: \ifeof 1 \else alpar@18: \closein 1 alpar@18: \input \jobname.toc alpar@18: \fi alpar@18: \vfill \eject alpar@18: \contentsalignmacro % in case @setchapternewpage odd is in effect alpar@18: \endgroup alpar@18: \lastnegativepageno = \pageno alpar@18: \global\pageno = \savepageno alpar@18: } alpar@18: \let\shortcontents = \summarycontents alpar@18: alpar@18: \ifpdf alpar@18: \pdfcatalog{/PageMode /UseOutlines}% alpar@18: \fi alpar@18: alpar@18: % These macros generate individual entries in the table of contents. alpar@18: % The first argument is the chapter or section name. alpar@18: % The last argument is the page number. alpar@18: % The arguments in between are the chapter number, section number, ... alpar@18: alpar@18: % Chapters, in the main contents. alpar@18: \def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}} alpar@18: % alpar@18: % Chapters, in the short toc. alpar@18: % See comments in \dochapentry re vbox and related settings. alpar@18: \def\shortchapentry#1#2#3{% alpar@18: \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#3\egroup}% alpar@18: } alpar@18: alpar@18: % Appendices, in the main contents. alpar@18: \def\appendixentry#1#2#3{% alpar@18: \dochapentry{\appendixbox{\putwordAppendix{} #2}\labelspace#1}{#3}} alpar@18: % alpar@18: % Appendices, in the short toc. alpar@18: \let\shortappendixentry = \shortchapentry alpar@18: alpar@18: % Typeset the label for a chapter or appendix for the short contents. alpar@18: % The arg is, e.g., `Appendix A' for an appendix, or `3' for a chapter. alpar@18: % We could simplify the code here by writing out an \appendixentry alpar@18: % command in the toc file for appendices, instead of using \chapentry alpar@18: % for both, but it doesn't seem worth it. alpar@18: % alpar@18: \newdimen\shortappendixwidth alpar@18: % alpar@18: \def\shortchaplabel#1{% alpar@18: % This space should be enough, since a single number is .5em, and the alpar@18: % widest letter (M) is 1em, at least in the Computer Modern fonts. alpar@18: % But use \hss just in case. alpar@18: % (This space doesn't include the extra space that gets added after alpar@18: % the label; that gets put in by \shortchapentry above.) alpar@18: \dimen0 = 1em alpar@18: \hbox to \dimen0{#1\hss}% alpar@18: } alpar@18: alpar@18: % Unnumbered chapters. alpar@18: \def\unnumbchapentry#1#2#3{\dochapentry{#1}{#3}} alpar@18: \def\shortunnumberedentry#1#2#3{\tocentry{#1}{\doshortpageno\bgroup#3\egroup}} alpar@18: alpar@18: % Sections. alpar@18: \def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}} alpar@18: \def\unnumbsecentry#1#2#3#4{\dosecentry{#1}{#4}} alpar@18: alpar@18: % Subsections. alpar@18: \def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}} alpar@18: \def\unnumbsubsecentry#1#2#3#4#5{\dosubsecentry{#1}{#5}} alpar@18: alpar@18: % And subsubsections. alpar@18: \def\subsubsecentry#1#2#3#4#5#6{% alpar@18: \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}} alpar@18: \def\unnumbsubsubsecentry#1#2#3#4#5#6{\dosubsubsecentry{#1}{#6}} alpar@18: alpar@18: % This parameter controls the indentation of the various levels. alpar@18: \newdimen\tocindent \tocindent = 3pc alpar@18: alpar@18: % Now for the actual typesetting. In all these, #1 is the text and #2 is the alpar@18: % page number. alpar@18: % alpar@18: % If the toc has to be broken over pages, we want it to be at chapters alpar@18: % if at all possible; hence the \penalty. alpar@18: \def\dochapentry#1#2{% alpar@18: \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip alpar@18: \begingroup alpar@18: \chapentryfonts alpar@18: \tocentry{#1}{\dopageno\bgroup#2\egroup}% alpar@18: \endgroup alpar@18: \nobreak\vskip .25\baselineskip plus.1\baselineskip alpar@18: } alpar@18: alpar@18: \def\dosecentry#1#2{\begingroup alpar@18: \secentryfonts \leftskip=\tocindent alpar@18: \tocentry{#1}{\dopageno\bgroup#2\egroup}% alpar@18: \endgroup} alpar@18: alpar@18: \def\dosubsecentry#1#2{\begingroup alpar@18: \subsecentryfonts \leftskip=2\tocindent alpar@18: \tocentry{#1}{\dopageno\bgroup#2\egroup}% alpar@18: \endgroup} alpar@18: alpar@18: \def\dosubsubsecentry#1#2{\begingroup alpar@18: \subsubsecentryfonts \leftskip=3\tocindent alpar@18: \tocentry{#1}{\dopageno\bgroup#2\egroup}% alpar@18: \endgroup} alpar@18: alpar@18: % Final typesetting of a toc entry; we use the same \entry macro as for alpar@18: % the index entries, but we want to suppress hyphenation here. (We alpar@18: % can't do that in the \entry macro, since index entries might consist alpar@18: % of hyphenated-identifiers-that-do-not-fit-on-a-line-and-nothing-else.) alpar@18: \def\tocentry#1#2{\begingroup alpar@18: \vskip 0pt plus1pt % allow a little stretch for the sake of nice page breaks alpar@18: % Do not use \turnoffactive in these arguments. Since the toc is alpar@18: % typeset in cmr, characters such as _ would come out wrong; we alpar@18: % have to do the usual translation tricks. alpar@18: \entry{#1}{#2}% alpar@18: \endgroup} alpar@18: alpar@18: % Space between chapter (or whatever) number and the title. alpar@18: \def\labelspace{\hskip1em \relax} alpar@18: alpar@18: \def\dopageno#1{{\rm #1}} alpar@18: \def\doshortpageno#1{{\rm #1}} alpar@18: alpar@18: \def\chapentryfonts{\secfonts \rm} alpar@18: \def\secentryfonts{\textfonts} alpar@18: \let\subsecentryfonts = \textfonts alpar@18: \let\subsubsecentryfonts = \textfonts alpar@18: alpar@18: alpar@18: \message{environments,} alpar@18: % @foo ... @end foo. alpar@18: alpar@18: % @point{}, @result{}, @expansion{}, @print{}, @equiv{}. alpar@18: % alpar@18: % Since these characters are used in examples, it should be an even number of alpar@18: % \tt widths. Each \tt character is 1en, so two makes it 1em. alpar@18: % alpar@18: \def\point{$\star$} alpar@18: \def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}} alpar@18: \def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}} alpar@18: \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}} alpar@18: \def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}} alpar@18: alpar@18: % The @error{} command. alpar@18: % Adapted from the TeXbook's \boxit. alpar@18: % alpar@18: \newbox\errorbox alpar@18: % alpar@18: {\tentt \global\dimen0 = 3em}% Width of the box. alpar@18: \dimen2 = .55pt % Thickness of rules alpar@18: % The text. (`r' is open on the right, `e' somewhat less so on the left.) alpar@18: \setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt} alpar@18: % alpar@18: \global\setbox\errorbox=\hbox to \dimen0{\hfil alpar@18: \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right. alpar@18: \advance\hsize by -2\dimen2 % Rules. alpar@18: \vbox{ alpar@18: \hrule height\dimen2 alpar@18: \hbox{\vrule width\dimen2 \kern3pt % Space to left of text. alpar@18: \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below. alpar@18: \kern3pt\vrule width\dimen2}% Space to right. alpar@18: \hrule height\dimen2} alpar@18: \hfil} alpar@18: % alpar@18: \def\error{\leavevmode\lower.7ex\copy\errorbox} alpar@18: alpar@18: % @tex ... @end tex escapes into raw Tex temporarily. alpar@18: % One exception: @ is still an escape character, so that @end tex works. alpar@18: % But \@ or @@ will get a plain tex @ character. alpar@18: alpar@18: \def\tex{\begingroup alpar@18: \catcode `\\=0 \catcode `\{=1 \catcode `\}=2 alpar@18: \catcode `\$=3 \catcode `\&=4 \catcode `\#=6 alpar@18: \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie alpar@18: \catcode `\%=14 alpar@18: \catcode `\+=\other alpar@18: \catcode `\"=\other alpar@18: \catcode `\==\other alpar@18: \catcode `\|=\other alpar@18: \catcode `\<=\other alpar@18: \catcode `\>=\other alpar@18: \escapechar=`\\ alpar@18: % alpar@18: \let\b=\ptexb alpar@18: \let\bullet=\ptexbullet alpar@18: \let\c=\ptexc alpar@18: \let\,=\ptexcomma alpar@18: \let\.=\ptexdot alpar@18: \let\dots=\ptexdots alpar@18: \let\equiv=\ptexequiv alpar@18: \let\!=\ptexexclam alpar@18: \let\i=\ptexi alpar@18: \let\indent=\ptexindent alpar@18: \let\{=\ptexlbrace alpar@18: \let\+=\tabalign alpar@18: \let\}=\ptexrbrace alpar@18: \let\/=\ptexslash alpar@18: \let\*=\ptexstar alpar@18: \let\t=\ptext alpar@18: % alpar@18: \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}% alpar@18: \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}% alpar@18: \def\@{@}% alpar@18: \let\Etex=\endgroup} alpar@18: alpar@18: % Define @lisp ... @end lisp. alpar@18: % @lisp does a \begingroup so it can rebind things, alpar@18: % including the definition of @end lisp (which normally is erroneous). alpar@18: alpar@18: % Amount to narrow the margins by for @lisp. alpar@18: \newskip\lispnarrowing \lispnarrowing=0.4in alpar@18: alpar@18: % This is the definition that ^^M gets inside @lisp, @example, and other alpar@18: % such environments. \null is better than a space, since it doesn't alpar@18: % have any width. alpar@18: \def\lisppar{\null\endgraf} alpar@18: alpar@18: % Make each space character in the input produce a normal interword alpar@18: % space in the output. Don't allow a line break at this space, as this alpar@18: % is used only in environments like @example, where each line of input alpar@18: % should produce a line of output anyway. alpar@18: % alpar@18: {\obeyspaces % alpar@18: \gdef\sepspaces{\obeyspaces\let =\tie}} alpar@18: alpar@18: % Define \obeyedspace to be our active space, whatever it is. This is alpar@18: % for use in \parsearg. alpar@18: {\sepspaces% alpar@18: \global\let\obeyedspace= } alpar@18: alpar@18: % This space is always present above and below environments. alpar@18: \newskip\envskipamount \envskipamount = 0pt alpar@18: alpar@18: % Make spacing and below environment symmetrical. We use \parskip here alpar@18: % to help in doing that, since in @example-like environments \parskip alpar@18: % is reset to zero; thus the \afterenvbreak inserts no space -- but the alpar@18: % start of the next paragraph will insert \parskip. alpar@18: % alpar@18: \def\aboveenvbreak{{% alpar@18: % =10000 instead of <10000 because of a special case in \itemzzz, q.v. alpar@18: \ifnum \lastpenalty=10000 \else alpar@18: \advance\envskipamount by \parskip alpar@18: \endgraf alpar@18: \ifdim\lastskip<\envskipamount alpar@18: \removelastskip alpar@18: % it's not a good place to break if the last penalty was \nobreak alpar@18: % or better ... alpar@18: \ifnum\lastpenalty>10000 \else \penalty-50 \fi alpar@18: \vskip\envskipamount alpar@18: \fi alpar@18: \fi alpar@18: }} alpar@18: alpar@18: \let\afterenvbreak = \aboveenvbreak alpar@18: alpar@18: % \nonarrowing is a flag. If "set", @lisp etc don't narrow margins. alpar@18: \let\nonarrowing=\relax alpar@18: alpar@18: % @cartouche ... @end cartouche: draw rectangle w/rounded corners around alpar@18: % environment contents. alpar@18: \font\circle=lcircle10 alpar@18: \newdimen\circthick alpar@18: \newdimen\cartouter\newdimen\cartinner alpar@18: \newskip\normbskip\newskip\normpskip\newskip\normlskip alpar@18: \circthick=\fontdimen8\circle alpar@18: % alpar@18: \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth alpar@18: \def\ctr{{\hskip 6pt\circle\char'010}} alpar@18: \def\cbl{{\circle\char'012\hskip -6pt}} alpar@18: \def\cbr{{\hskip 6pt\circle\char'011}} alpar@18: \def\carttop{\hbox to \cartouter{\hskip\lskip alpar@18: \ctl\leaders\hrule height\circthick\hfil\ctr alpar@18: \hskip\rskip}} alpar@18: \def\cartbot{\hbox to \cartouter{\hskip\lskip alpar@18: \cbl\leaders\hrule height\circthick\hfil\cbr alpar@18: \hskip\rskip}} alpar@18: % alpar@18: \newskip\lskip\newskip\rskip alpar@18: alpar@18: \def\cartouche{% alpar@18: \par % can't be in the midst of a paragraph. alpar@18: \begingroup alpar@18: \lskip=\leftskip \rskip=\rightskip alpar@18: \leftskip=0pt\rightskip=0pt %we want these *outside*. alpar@18: \cartinner=\hsize \advance\cartinner by-\lskip alpar@18: \advance\cartinner by-\rskip alpar@18: \cartouter=\hsize alpar@18: \advance\cartouter by 18.4pt % allow for 3pt kerns on either alpar@18: % side, and for 6pt waste from alpar@18: % each corner char, and rule thickness alpar@18: \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip alpar@18: % Flag to tell @lisp, etc., not to narrow margin. alpar@18: \let\nonarrowing=\comment alpar@18: \vbox\bgroup alpar@18: \baselineskip=0pt\parskip=0pt\lineskip=0pt alpar@18: \carttop alpar@18: \hbox\bgroup alpar@18: \hskip\lskip alpar@18: \vrule\kern3pt alpar@18: \vbox\bgroup alpar@18: \hsize=\cartinner alpar@18: \kern3pt alpar@18: \begingroup alpar@18: \baselineskip=\normbskip alpar@18: \lineskip=\normlskip alpar@18: \parskip=\normpskip alpar@18: \vskip -\parskip alpar@18: \def\Ecartouche{% alpar@18: \endgroup alpar@18: \kern3pt alpar@18: \egroup alpar@18: \kern3pt\vrule alpar@18: \hskip\rskip alpar@18: \egroup alpar@18: \cartbot alpar@18: \egroup alpar@18: \endgroup alpar@18: }} alpar@18: alpar@18: alpar@18: % This macro is called at the beginning of all the @example variants, alpar@18: % inside a group. alpar@18: \def\nonfillstart{% alpar@18: \aboveenvbreak alpar@18: \inENV % This group ends at the end of the body alpar@18: \hfuzz = 12pt % Don't be fussy alpar@18: \sepspaces % Make spaces be word-separators rather than space tokens. alpar@18: \let\par = \lisppar % don't ignore blank lines alpar@18: \obeylines % each line of input is a line of output alpar@18: \parskip = 0pt alpar@18: \parindent = 0pt alpar@18: \emergencystretch = 0pt % don't try to avoid overfull boxes alpar@18: % @cartouche defines \nonarrowing to inhibit narrowing alpar@18: % at next level down. alpar@18: \ifx\nonarrowing\relax alpar@18: \advance \leftskip by \lispnarrowing alpar@18: \exdentamount=\lispnarrowing alpar@18: \let\exdent=\nofillexdent alpar@18: \let\nonarrowing=\relax alpar@18: \fi alpar@18: } alpar@18: alpar@18: % Define the \E... control sequence only if we are inside the particular alpar@18: % environment, so the error checking in \end will work. alpar@18: % alpar@18: % To end an @example-like environment, we first end the paragraph (via alpar@18: % \afterenvbreak's vertical glue), and then the group. That way we keep alpar@18: % the zero \parskip that the environments set -- \parskip glue will be alpar@18: % inserted at the beginning of the next paragraph in the document, after alpar@18: % the environment. alpar@18: % alpar@18: \def\nonfillfinish{\afterenvbreak\endgroup} alpar@18: alpar@18: % @lisp: indented, narrowed, typewriter font. alpar@18: \def\lisp{\begingroup alpar@18: \nonfillstart alpar@18: \let\Elisp = \nonfillfinish alpar@18: \tt alpar@18: \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special. alpar@18: \gobble % eat return alpar@18: } alpar@18: alpar@18: % @example: Same as @lisp. alpar@18: \def\example{\begingroup \def\Eexample{\nonfillfinish\endgroup}\lisp} alpar@18: alpar@18: % @smallexample and @smalllisp: use smaller fonts. alpar@18: % Originally contributed by Pavel@xerox. alpar@18: \def\smalllisp{\begingroup alpar@18: \def\Esmalllisp{\nonfillfinish\endgroup}% alpar@18: \def\Esmallexample{\nonfillfinish\endgroup}% alpar@18: \smallexamplefonts alpar@18: \lisp alpar@18: } alpar@18: \let\smallexample = \smalllisp alpar@18: alpar@18: alpar@18: % @display: same as @lisp except keep current font. alpar@18: % alpar@18: \def\display{\begingroup alpar@18: \nonfillstart alpar@18: \let\Edisplay = \nonfillfinish alpar@18: \gobble alpar@18: } alpar@18: % alpar@18: % @smalldisplay: @display plus smaller fonts. alpar@18: % alpar@18: \def\smalldisplay{\begingroup alpar@18: \def\Esmalldisplay{\nonfillfinish\endgroup}% alpar@18: \smallexamplefonts \rm alpar@18: \display alpar@18: } alpar@18: alpar@18: % @format: same as @display except don't narrow margins. alpar@18: % alpar@18: \def\format{\begingroup alpar@18: \let\nonarrowing = t alpar@18: \nonfillstart alpar@18: \let\Eformat = \nonfillfinish alpar@18: \gobble alpar@18: } alpar@18: % alpar@18: % @smallformat: @format plus smaller fonts. alpar@18: % alpar@18: \def\smallformat{\begingroup alpar@18: \def\Esmallformat{\nonfillfinish\endgroup}% alpar@18: \smallexamplefonts \rm alpar@18: \format alpar@18: } alpar@18: alpar@18: % @flushleft (same as @format). alpar@18: % alpar@18: \def\flushleft{\begingroup \def\Eflushleft{\nonfillfinish\endgroup}\format} alpar@18: alpar@18: % @flushright. alpar@18: % alpar@18: \def\flushright{\begingroup alpar@18: \let\nonarrowing = t alpar@18: \nonfillstart alpar@18: \let\Eflushright = \nonfillfinish alpar@18: \advance\leftskip by 0pt plus 1fill alpar@18: \gobble alpar@18: } alpar@18: alpar@18: alpar@18: % @quotation does normal linebreaking (hence we can't use \nonfillstart) alpar@18: % and narrows the margins. alpar@18: % alpar@18: \def\quotation{% alpar@18: \begingroup\inENV %This group ends at the end of the @quotation body alpar@18: {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip alpar@18: \parindent=0pt alpar@18: % We have retained a nonzero parskip for the environment, since we're alpar@18: % doing normal filling. So to avoid extra space below the environment... alpar@18: \def\Equotation{\parskip = 0pt \nonfillfinish}% alpar@18: % alpar@18: % @cartouche defines \nonarrowing to inhibit narrowing at next level down. alpar@18: \ifx\nonarrowing\relax alpar@18: \advance\leftskip by \lispnarrowing alpar@18: \advance\rightskip by \lispnarrowing alpar@18: \exdentamount = \lispnarrowing alpar@18: \let\nonarrowing = \relax alpar@18: \fi alpar@18: } alpar@18: alpar@18: alpar@18: % LaTeX-like @verbatim...@end verbatim and @verb{...} alpar@18: % If we want to allow any as delimiter, alpar@18: % we need the curly braces so that makeinfo sees the @verb command, eg: alpar@18: % `@verbx...x' would look like the '@verbx' command. --janneke@gnu.org alpar@18: % alpar@18: % [Knuth]: Donald Ervin Knuth, 1996. The TeXbook. alpar@18: % alpar@18: % [Knuth] p.344; only we need to do the other characters Texinfo sets alpar@18: % active too. Otherwise, they get lost as the first character on a alpar@18: % verbatim line. alpar@18: \def\dospecials{% alpar@18: \do\ \do\\\do\{\do\}\do\$\do\&% alpar@18: \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~% alpar@18: \do\<\do\>\do\|\do\@\do+\do\"% alpar@18: } alpar@18: % alpar@18: % [Knuth] p. 380 alpar@18: \def\uncatcodespecials{% alpar@18: \def\do##1{\catcode`##1=12}\dospecials} alpar@18: % alpar@18: % [Knuth] pp. 380,381,391 alpar@18: % Disable Spanish ligatures ?` and !` of \tt font alpar@18: \begingroup alpar@18: \catcode`\`=\active\gdef`{\relax\lq} alpar@18: \endgroup alpar@18: % alpar@18: % Setup for the @verb command. alpar@18: % alpar@18: % Eight spaces for a tab alpar@18: \begingroup alpar@18: \catcode`\^^I=\active alpar@18: \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }} alpar@18: \endgroup alpar@18: % alpar@18: \def\setupverb{% alpar@18: \tt % easiest (and conventionally used) font for verbatim alpar@18: \def\par{\leavevmode\endgraf}% alpar@18: \catcode`\`=\active alpar@18: \tabeightspaces alpar@18: % Respect line breaks, alpar@18: % print special symbols as themselves, and alpar@18: % make each space count alpar@18: % must do in this order: alpar@18: \obeylines \uncatcodespecials \sepspaces alpar@18: } alpar@18: alpar@18: % Setup for the @verbatim environment alpar@18: % alpar@18: % Real tab expansion alpar@18: \newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount alpar@18: % alpar@18: \def\starttabbox{\setbox0=\hbox\bgroup} alpar@18: \begingroup alpar@18: \catcode`\^^I=\active alpar@18: \gdef\tabexpand{% alpar@18: \catcode`\^^I=\active alpar@18: \def^^I{\leavevmode\egroup alpar@18: \dimen0=\wd0 % the width so far, or since the previous tab alpar@18: \divide\dimen0 by\tabw alpar@18: \multiply\dimen0 by\tabw % compute previous multiple of \tabw alpar@18: \advance\dimen0 by\tabw % advance to next multiple of \tabw alpar@18: \wd0=\dimen0 \box0 \starttabbox alpar@18: }% alpar@18: } alpar@18: \endgroup alpar@18: \def\setupverbatim{% alpar@18: % Easiest (and conventionally used) font for verbatim alpar@18: \tt alpar@18: \def\par{\leavevmode\egroup\box0\endgraf}% alpar@18: \catcode`\`=\active alpar@18: \tabexpand alpar@18: % Respect line breaks, alpar@18: % print special symbols as themselves, and alpar@18: % make each space count alpar@18: % must do in this order: alpar@18: \obeylines \uncatcodespecials \sepspaces alpar@18: \everypar{\starttabbox}% alpar@18: } alpar@18: alpar@18: % Do the @verb magic: verbatim text is quoted by unique alpar@18: % delimiter characters. Before first delimiter expect a alpar@18: % right brace, after last delimiter expect closing brace: alpar@18: % alpar@18: % \def\doverb'{'#1'}'{#1} alpar@18: % alpar@18: % [Knuth] p. 382; only eat outer {} alpar@18: \begingroup alpar@18: \catcode`[=1\catcode`]=2\catcode`\{=12\catcode`\}=12 alpar@18: \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next] alpar@18: \endgroup alpar@18: % alpar@18: \def\verb{\begingroup\setupverb\doverb} alpar@18: % alpar@18: % alpar@18: % Do the @verbatim magic: define the macro \doverbatim so that alpar@18: % the (first) argument ends when '@end verbatim' is reached, ie: alpar@18: % alpar@18: % \def\doverbatim#1@end verbatim{#1} alpar@18: % alpar@18: % For Texinfo it's a lot easier than for LaTeX, alpar@18: % because texinfo's \verbatim doesn't stop at '\end{verbatim}': alpar@18: % we need not redefine '\', '{' and '}'. alpar@18: % alpar@18: % Inspired by LaTeX's verbatim command set [latex.ltx] alpar@18: %% Include LaTeX hack for completeness -- never know alpar@18: %% \begingroup alpar@18: %% \catcode`|=0 \catcode`[=1 alpar@18: %% \catcode`]=2\catcode`\{=12\catcode`\}=12\catcode`\ =\active alpar@18: %% \catcode`\\=12|gdef|doverbatim#1@end verbatim[ alpar@18: %% #1|endgroup|def|Everbatim[]|end[verbatim]] alpar@18: %% |endgroup alpar@18: % alpar@18: \begingroup alpar@18: \catcode`\ =\active alpar@18: \obeylines % alpar@18: % ignore everything up to the first ^^M, that's the newline at the end alpar@18: % of the @verbatim input line itself. Otherwise we get an extra blank alpar@18: % line in the output. alpar@18: \gdef\doverbatim#1^^M#2@end verbatim{#2\end{verbatim}}% alpar@18: \endgroup alpar@18: % alpar@18: \def\verbatim{% alpar@18: \def\Everbatim{\nonfillfinish\endgroup}% alpar@18: \begingroup alpar@18: \nonfillstart alpar@18: \advance\leftskip by -\defbodyindent alpar@18: \begingroup\setupverbatim\doverbatim alpar@18: } alpar@18: alpar@18: % @verbatiminclude FILE - insert text of file in verbatim environment. alpar@18: % alpar@18: % Allow normal characters that we make active in the argument (a file name). alpar@18: \def\verbatiminclude{% alpar@18: \begingroup alpar@18: \catcode`\\=\other alpar@18: \catcode`~=\other alpar@18: \catcode`^=\other alpar@18: \catcode`_=\other alpar@18: \catcode`|=\other alpar@18: \catcode`<=\other alpar@18: \catcode`>=\other alpar@18: \catcode`+=\other alpar@18: \parsearg\doverbatiminclude alpar@18: } alpar@18: \def\setupverbatiminclude{% alpar@18: \begingroup alpar@18: \nonfillstart alpar@18: \advance\leftskip by -\defbodyindent alpar@18: \begingroup\setupverbatim alpar@18: } alpar@18: % alpar@18: \def\doverbatiminclude#1{% alpar@18: % Restore active chars for included file. alpar@18: \endgroup alpar@18: \begingroup alpar@18: \let\value=\expandablevalue alpar@18: \def\thisfile{#1}% alpar@18: \expandafter\expandafter\setupverbatiminclude\input\thisfile alpar@18: \endgroup alpar@18: \nonfillfinish alpar@18: \endgroup alpar@18: } alpar@18: alpar@18: % @copying ... @end copying. alpar@18: % Save the text away for @insertcopying later. Many commands won't be alpar@18: % allowed in this context, but that's ok. alpar@18: % alpar@18: % We save the uninterpreted tokens, rather than creating a box. alpar@18: % Saving the text in a box would be much easier, but then all the alpar@18: % typesetting commands (@smallbook, font changes, etc.) have to be done alpar@18: % beforehand -- and a) we want @copying to be done first in the source alpar@18: % file; b) letting users define the frontmatter in as flexible order as alpar@18: % possible is very desirable. alpar@18: % alpar@18: \def\copying{\begingroup alpar@18: % Define a command to swallow text until we reach `@end copying'. alpar@18: % \ is the escape char in this texinfo.tex file, so it is the alpar@18: % delimiter for the command; @ will be the escape char when we read alpar@18: % it, but that doesn't matter. alpar@18: \long\def\docopying##1\end copying{\gdef\copyingtext{##1}\enddocopying}% alpar@18: % alpar@18: % We must preserve ^^M's in the input file; see \insertcopying below. alpar@18: \catcode`\^^M = \active alpar@18: \docopying alpar@18: } alpar@18: alpar@18: % What we do to finish off the copying text. alpar@18: % alpar@18: \def\enddocopying{\endgroup\ignorespaces} alpar@18: alpar@18: % @insertcopying. Here we must play games with ^^M's. On the one hand, alpar@18: % we need them to delimit commands such as `@end quotation', so they alpar@18: % must be active. On the other hand, we certainly don't want every alpar@18: % end-of-line to be a \par, as would happen with the normal active alpar@18: % definition of ^^M. On the third hand, two ^^M's in a row should still alpar@18: % generate a \par. alpar@18: % alpar@18: % Our approach is to make ^^M insert a space and a penalty1 normally; alpar@18: % then it can also check if \lastpenalty=1. If it does, then manually alpar@18: % do \par. alpar@18: % alpar@18: % This messes up the normal definitions of @c[omment], so we redefine alpar@18: % it. Similarly for @ignore. (These commands are used in the gcc alpar@18: % manual for man page generation.) alpar@18: % alpar@18: % Seems pretty fragile, most line-oriented commands will presumably alpar@18: % fail, but for the limited use of getting the copying text (which alpar@18: % should be quite simple) inserted, we can hope it's ok. alpar@18: % alpar@18: {\catcode`\^^M=\active % alpar@18: \gdef\insertcopying{\begingroup % alpar@18: \parindent = 0pt % looks wrong on title page alpar@18: \def^^M{% alpar@18: \ifnum \lastpenalty=1 % alpar@18: \par % alpar@18: \else % alpar@18: \space \penalty 1 % alpar@18: \fi % alpar@18: }% alpar@18: % alpar@18: % Fix @c[omment] for catcode 13 ^^M's. alpar@18: \def\c##1^^M{\ignorespaces}% alpar@18: \let\comment = \c % alpar@18: % alpar@18: % Don't bother jumping through all the hoops that \doignore does, it alpar@18: % would be very hard since the catcodes are already set. alpar@18: \long\def\ignore##1\end ignore{\ignorespaces}% alpar@18: % alpar@18: \copyingtext % alpar@18: \endgroup}% alpar@18: } alpar@18: alpar@18: \message{defuns,} alpar@18: % @defun etc. alpar@18: alpar@18: % Allow user to change definition object font (\df) internally alpar@18: \def\setdeffont#1 {\csname DEF#1\endcsname} alpar@18: alpar@18: \newskip\defbodyindent \defbodyindent=.4in alpar@18: \newskip\defargsindent \defargsindent=50pt alpar@18: \newskip\deflastargmargin \deflastargmargin=18pt alpar@18: alpar@18: \newcount\parencount alpar@18: alpar@18: % We want ()&[] to print specially on the defun line. alpar@18: % alpar@18: \def\activeparens{% alpar@18: \catcode`\(=\active \catcode`\)=\active alpar@18: \catcode`\&=\active alpar@18: \catcode`\[=\active \catcode`\]=\active alpar@18: } alpar@18: alpar@18: % Make control sequences which act like normal parenthesis chars. alpar@18: \let\lparen = ( \let\rparen = ) alpar@18: alpar@18: {\activeparens % Now, smart parens don't turn on until &foo (see \amprm) alpar@18: alpar@18: % Be sure that we always have a definition for `(', etc. For example, alpar@18: % if the fn name has parens in it, \boldbrax will not be in effect yet, alpar@18: % so TeX would otherwise complain about undefined control sequence. alpar@18: \global\let(=\lparen \global\let)=\rparen alpar@18: \global\let[=\lbrack \global\let]=\rbrack alpar@18: alpar@18: \gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 } alpar@18: \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb} alpar@18: % This is used to turn on special parens alpar@18: % but make & act ordinary (given that it's active). alpar@18: \gdef\boldbraxnoamp{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb\let&=\ampnr} alpar@18: alpar@18: % Definitions of (, ) and & used in args for functions. alpar@18: % This is the definition of ( outside of all parentheses. alpar@18: \gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested alpar@18: \global\advance\parencount by 1 alpar@18: } alpar@18: % alpar@18: % This is the definition of ( when already inside a level of parens. alpar@18: \gdef\opnested{\char`\(\global\advance\parencount by 1 } alpar@18: % alpar@18: \gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0. alpar@18: % also in that case restore the outer-level definition of (. alpar@18: \ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi alpar@18: \global\advance \parencount by -1 } alpar@18: % If we encounter &foo, then turn on ()-hacking afterwards alpar@18: \gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ } alpar@18: % alpar@18: \gdef\normalparens{\boldbrax\let&=\ampnr} alpar@18: } % End of definition inside \activeparens alpar@18: %% These parens (in \boldbrax) actually are a little bolder than the alpar@18: %% contained text. This is especially needed for [ and ] alpar@18: \def\opnr{{\sf\char`\(}\global\advance\parencount by 1 } alpar@18: \def\clnr{{\sf\char`\)}\global\advance\parencount by -1 } alpar@18: \let\ampnr = \& alpar@18: \def\lbrb{{\bf\char`\[}} alpar@18: \def\rbrb{{\bf\char`\]}} alpar@18: alpar@18: % Active &'s sneak into the index arguments, so make sure it's defined. alpar@18: { alpar@18: \catcode`& = \active alpar@18: \global\let& = \ampnr alpar@18: } alpar@18: alpar@18: % \defname, which formats the name of the @def (not the args). alpar@18: % #1 is the function name. alpar@18: % #2 is the type of definition, such as "Function". alpar@18: % alpar@18: \def\defname#1#2{% alpar@18: % How we'll output the type name. Putting it in brackets helps alpar@18: % distinguish it from the body text that may end up on the next line alpar@18: % just below it. alpar@18: \ifempty{#2}% alpar@18: \def\defnametype{}% alpar@18: \else alpar@18: \def\defnametype{[\rm #2]}% alpar@18: \fi alpar@18: % alpar@18: % Get the values of \leftskip and \rightskip as they were outside the @def... alpar@18: \dimen2=\leftskip alpar@18: \advance\dimen2 by -\defbodyindent alpar@18: % alpar@18: % Figure out values for the paragraph shape. alpar@18: \setbox0=\hbox{\hskip \deflastargmargin{\defnametype}}% alpar@18: \dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line alpar@18: \dimen1=\hsize \advance \dimen1 by -\defargsindent % size for continuations alpar@18: \parshape 2 0in \dimen0 \defargsindent \dimen1 alpar@18: % alpar@18: % Output arg 2 ("Function" or some such) but stuck inside a box of alpar@18: % width 0 so it does not interfere with linebreaking. alpar@18: \noindent alpar@18: % alpar@18: {% Adjust \hsize to exclude the ambient margins, alpar@18: % so that \rightline will obey them. alpar@18: \advance \hsize by -\dimen2 alpar@18: \dimen3 = 0pt % was -1.25pc alpar@18: \rlap{\rightline{\defnametype\kern\dimen3}}% alpar@18: }% alpar@18: % alpar@18: % Allow all lines to be underfull without complaint: alpar@18: \tolerance=10000 \hbadness=10000 alpar@18: \advance\leftskip by -\defbodyindent alpar@18: \exdentamount=\defbodyindent alpar@18: {\df #1}\enskip % output function name alpar@18: % \defunargs will be called next to output the arguments, if any. alpar@18: } alpar@18: alpar@18: % Common pieces to start any @def... alpar@18: % #1 is the \E... control sequence to end the definition (which we define). alpar@18: % #2 is the \...x control sequence (which our caller defines). alpar@18: % #3 is the control sequence to process the header, such as \defunheader. alpar@18: % alpar@18: \def\parsebodycommon#1#2#3{% alpar@18: \begingroup\inENV alpar@18: % If there are two @def commands in a row, we'll have a \nobreak, alpar@18: % which is there to keep the function description together with its alpar@18: % header. But if there's nothing but headers, we want to allow a alpar@18: % break after all. Check for penalty 10002 (inserted by alpar@18: % \defargscommonending) instead of 10000, since the sectioning alpar@18: % commands insert a \penalty10000, and we don't want to allow a break alpar@18: % between a section heading and a defun. alpar@18: \ifnum\lastpenalty=10002 \penalty0 \fi alpar@18: \medbreak alpar@18: % alpar@18: % Define the \E... end token that this defining construct specifies alpar@18: % so that it will exit this group. alpar@18: \def#1{\endgraf\endgroup\medbreak}% alpar@18: % alpar@18: \parindent=0in alpar@18: \advance\leftskip by \defbodyindent alpar@18: \exdentamount=\defbodyindent alpar@18: } alpar@18: alpar@18: % Common part of the \...x definitions. alpar@18: % alpar@18: \def\defxbodycommon{% alpar@18: % As with \parsebodycommon above, allow line break if we have multiple alpar@18: % x headers in a row. It's not a great place, though. alpar@18: \ifnum\lastpenalty=10000 \penalty1000 \fi alpar@18: % alpar@18: \begingroup\obeylines alpar@18: } alpar@18: alpar@18: % Process body of @defun, @deffn, @defmac, etc. alpar@18: % alpar@18: \def\defparsebody#1#2#3{% alpar@18: \parsebodycommon{#1}{#2}{#3}% alpar@18: \def#2{\defxbodycommon \activeparens \spacesplit#3}% alpar@18: \catcode\equalChar=\active alpar@18: \begingroup\obeylines\activeparens alpar@18: \spacesplit#3% alpar@18: } alpar@18: alpar@18: % #1, #2, #3 are the common arguments (see \parsebodycommon above). alpar@18: % #4, delimited by the space, is the class name. alpar@18: % alpar@18: \def\defmethparsebody#1#2#3#4 {% alpar@18: \parsebodycommon{#1}{#2}{#3}% alpar@18: \def#2##1 {\defxbodycommon \activeparens \spacesplit{#3{##1}}}% alpar@18: \begingroup\obeylines\activeparens alpar@18: % The \empty here prevents misinterpretation of a construct such as alpar@18: % @deffn {whatever} {Enharmonic comma} alpar@18: % See comments at \deftpparsebody, although in our case we don't have alpar@18: % to remove the \empty afterwards, since it is empty. alpar@18: \spacesplit{#3{#4}}\empty alpar@18: } alpar@18: alpar@18: % Used for @deftypemethod and @deftypeivar. alpar@18: % #1, #2, #3 are the common arguments (see \defparsebody). alpar@18: % #4, delimited by a space, is the class name. alpar@18: % #5 is the method's return type. alpar@18: % alpar@18: \def\deftypemethparsebody#1#2#3#4 #5 {% alpar@18: \parsebodycommon{#1}{#2}{#3}% alpar@18: \def#2##1 ##2 {\defxbodycommon \activeparens \spacesplit{#3{##1}{##2}}}% alpar@18: \begingroup\obeylines\activeparens alpar@18: \spacesplit{#3{#4}{#5}}% alpar@18: } alpar@18: alpar@18: % Used for @deftypeop. The change from \deftypemethparsebody is an alpar@18: % extra argument at the beginning which is the `category', instead of it alpar@18: % being the hardwired string `Method' or `Instance Variable'. We have alpar@18: % to account for this both in the \...x definition and in parsing the alpar@18: % input at hand. Thus also need a control sequence (passed as #5) for alpar@18: % the \E... definition to assign the category name to. alpar@18: % alpar@18: \def\deftypeopparsebody#1#2#3#4#5 #6 {% alpar@18: \parsebodycommon{#1}{#2}{#3}% alpar@18: \def#2##1 ##2 ##3 {\def#4{##1}% alpar@18: \defxbodycommon \activeparens \spacesplit{#3{##2}{##3}}}% alpar@18: \begingroup\obeylines\activeparens alpar@18: \spacesplit{#3{#5}{#6}}% alpar@18: } alpar@18: alpar@18: % For @defop. alpar@18: \def\defopparsebody #1#2#3#4#5 {% alpar@18: \parsebodycommon{#1}{#2}{#3}% alpar@18: \def#2##1 ##2 {\def#4{##1}% alpar@18: \defxbodycommon \activeparens \spacesplit{#3{##2}}}% alpar@18: \begingroup\obeylines\activeparens alpar@18: \spacesplit{#3{#5}}% alpar@18: } alpar@18: alpar@18: % These parsing functions are similar to the preceding ones alpar@18: % except that they do not make parens into active characters. alpar@18: % These are used for "variables" since they have no arguments. alpar@18: % alpar@18: \def\defvarparsebody #1#2#3{% alpar@18: \parsebodycommon{#1}{#2}{#3}% alpar@18: \def#2{\defxbodycommon \spacesplit#3}% alpar@18: \catcode\equalChar=\active alpar@18: \begingroup\obeylines alpar@18: \spacesplit#3% alpar@18: } alpar@18: alpar@18: % @defopvar. alpar@18: \def\defopvarparsebody #1#2#3#4#5 {% alpar@18: \parsebodycommon{#1}{#2}{#3}% alpar@18: \def#2##1 ##2 {\def#4{##1}% alpar@18: \defxbodycommon \spacesplit{#3{##2}}}% alpar@18: \begingroup\obeylines alpar@18: \spacesplit{#3{#5}}% alpar@18: } alpar@18: alpar@18: \def\defvrparsebody#1#2#3#4 {% alpar@18: \parsebodycommon{#1}{#2}{#3}% alpar@18: \def#2##1 {\defxbodycommon \spacesplit{#3{##1}}}% alpar@18: \begingroup\obeylines alpar@18: \spacesplit{#3{#4}}% alpar@18: } alpar@18: alpar@18: % This loses on `@deftp {Data Type} {struct termios}' -- it thinks the alpar@18: % type is just `struct', because we lose the braces in `{struct alpar@18: % termios}' when \spacesplit reads its undelimited argument. Sigh. alpar@18: % \let\deftpparsebody=\defvrparsebody alpar@18: % alpar@18: % So, to get around this, we put \empty in with the type name. That alpar@18: % way, TeX won't find exactly `{...}' as an undelimited argument, and alpar@18: % won't strip off the braces. alpar@18: % alpar@18: \def\deftpparsebody #1#2#3#4 {% alpar@18: \parsebodycommon{#1}{#2}{#3}% alpar@18: \def#2##1 {\defxbodycommon \spacesplit{#3{##1}}}% alpar@18: \begingroup\obeylines alpar@18: \spacesplit{\parsetpheaderline{#3{#4}}}\empty alpar@18: } alpar@18: alpar@18: % Fine, but then we have to eventually remove the \empty *and* the alpar@18: % braces (if any). That's what this does. alpar@18: % alpar@18: \def\removeemptybraces\empty#1\relax{#1} alpar@18: alpar@18: % After \spacesplit has done its work, this is called -- #1 is the final alpar@18: % thing to call, #2 the type name (which starts with \empty), and #3 alpar@18: % (which might be empty) the arguments. alpar@18: % alpar@18: \def\parsetpheaderline#1#2#3{% alpar@18: #1{\removeemptybraces#2\relax}{#3}% alpar@18: }% alpar@18: alpar@18: % Split up #2 (the rest of the input line) at the first space token. alpar@18: % call #1 with two arguments: alpar@18: % the first is all of #2 before the space token, alpar@18: % the second is all of #2 after that space token. alpar@18: % If #2 contains no space token, all of it is passed as the first arg alpar@18: % and the second is passed as empty. alpar@18: % alpar@18: {\obeylines % alpar@18: \gdef\spacesplit#1#2^^M{\endgroup\spacesplitx{#1}#2 \relax\spacesplitx}% alpar@18: \long\gdef\spacesplitx#1#2 #3#4\spacesplitx{% alpar@18: \ifx\relax #3% alpar@18: #1{#2}{}% alpar@18: \else % alpar@18: #1{#2}{#3#4}% alpar@18: \fi}% alpar@18: } alpar@18: alpar@18: % Define @defun. alpar@18: alpar@18: % This is called to end the arguments processing for all the @def... commands. alpar@18: % alpar@18: \def\defargscommonending{% alpar@18: \interlinepenalty = 10000 alpar@18: \advance\rightskip by 0pt plus 1fil alpar@18: \endgraf alpar@18: \nobreak\vskip -\parskip alpar@18: \penalty 10002 % signal to \parsebodycommon. alpar@18: } alpar@18: alpar@18: % This expands the args and terminates the paragraph they comprise. alpar@18: % alpar@18: \def\defunargs#1{\functionparens \sl alpar@18: % Expand, preventing hyphenation at `-' chars. alpar@18: % Note that groups don't affect changes in \hyphenchar. alpar@18: % Set the font temporarily and use \font in case \setfont made \tensl a macro. alpar@18: {\tensl\hyphenchar\font=0}% alpar@18: #1% alpar@18: {\tensl\hyphenchar\font=45}% alpar@18: \ifnum\parencount=0 \else \errmessage{Unbalanced parentheses in @def}\fi% alpar@18: \defargscommonending alpar@18: } alpar@18: alpar@18: \def\deftypefunargs #1{% alpar@18: % Expand, preventing hyphenation at `-' chars. alpar@18: % Note that groups don't affect changes in \hyphenchar. alpar@18: % Use \boldbraxnoamp, not \functionparens, so that & is not special. alpar@18: \boldbraxnoamp alpar@18: \tclose{#1}% avoid \code because of side effects on active chars alpar@18: \defargscommonending alpar@18: } alpar@18: alpar@18: % Do complete processing of one @defun or @defunx line already parsed. alpar@18: alpar@18: % @deffn Command forward-char nchars alpar@18: alpar@18: \def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader} alpar@18: alpar@18: \def\deffnheader #1#2#3{\doind {fn}{\code{#2}}% alpar@18: \begingroup\defname {#2}{#1}\defunargs{#3}\endgroup % alpar@18: \catcode\equalChar=\other % Turn off change made in \defparsebody alpar@18: } alpar@18: alpar@18: % @defun == @deffn Function alpar@18: alpar@18: \def\defun{\defparsebody\Edefun\defunx\defunheader} alpar@18: alpar@18: \def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index alpar@18: \begingroup\defname {#1}{\putwordDeffunc}% alpar@18: \defunargs {#2}\endgroup % alpar@18: \catcode\equalChar=\other % Turn off change made in \defparsebody alpar@18: } alpar@18: alpar@18: % @deftypefun int foobar (int @var{foo}, float @var{bar}) alpar@18: alpar@18: \def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader} alpar@18: alpar@18: % #1 is the data type. #2 is the name and args. alpar@18: \def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax} alpar@18: % #1 is the data type, #2 the name, #3 the args. alpar@18: \def\deftypefunheaderx #1#2 #3\relax{% alpar@18: \doind {fn}{\code{#2}}% Make entry in function index alpar@18: \begingroup\defname {\defheaderxcond#1\relax$.$#2}{\putwordDeftypefun}% alpar@18: \deftypefunargs {#3}\endgroup % alpar@18: \catcode\equalChar=\other % Turn off change made in \defparsebody alpar@18: } alpar@18: alpar@18: % @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar}) alpar@18: alpar@18: \def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader} alpar@18: alpar@18: % \defheaderxcond#1\relax$.$ alpar@18: % puts #1 in @code, followed by a space, but does nothing if #1 is null. alpar@18: \def\defheaderxcond#1#2$.${\ifx#1\relax\else\code{#1#2} \fi} alpar@18: alpar@18: % #1 is the classification. #2 is the data type. #3 is the name and args. alpar@18: \def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax} alpar@18: % #1 is the classification, #2 the data type, #3 the name, #4 the args. alpar@18: \def\deftypefnheaderx #1#2#3 #4\relax{% alpar@18: \doind {fn}{\code{#3}}% Make entry in function index alpar@18: \begingroup alpar@18: \normalparens % notably, turn off `&' magic, which prevents alpar@18: % at least some C++ text from working alpar@18: \defname {\defheaderxcond#2\relax$.$#3}{#1}% alpar@18: \deftypefunargs {#4}\endgroup % alpar@18: \catcode\equalChar=\other % Turn off change made in \defparsebody alpar@18: } alpar@18: alpar@18: % @defmac == @deffn Macro alpar@18: alpar@18: \def\defmac{\defparsebody\Edefmac\defmacx\defmacheader} alpar@18: alpar@18: \def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index alpar@18: \begingroup\defname {#1}{\putwordDefmac}% alpar@18: \defunargs {#2}\endgroup % alpar@18: \catcode\equalChar=\other % Turn off change made in \defparsebody alpar@18: } alpar@18: alpar@18: % @defspec == @deffn Special Form alpar@18: alpar@18: \def\defspec{\defparsebody\Edefspec\defspecx\defspecheader} alpar@18: alpar@18: \def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index alpar@18: \begingroup\defname {#1}{\putwordDefspec}% alpar@18: \defunargs {#2}\endgroup % alpar@18: \catcode\equalChar=\other % Turn off change made in \defparsebody alpar@18: } alpar@18: alpar@18: % @defop CATEGORY CLASS OPERATION ARG... alpar@18: % alpar@18: \def\defop #1 {\def\defoptype{#1}% alpar@18: \defopparsebody\Edefop\defopx\defopheader\defoptype} alpar@18: % alpar@18: \def\defopheader#1#2#3{% alpar@18: \dosubind{fn}{\code{#2}}{\putwordon\ \code{#1}}% function index entry alpar@18: \begingroup alpar@18: \defname{#2}{\defoptype\ \putwordon\ #1}% alpar@18: \defunargs{#3}% alpar@18: \endgroup alpar@18: } alpar@18: alpar@18: % @deftypeop CATEGORY CLASS TYPE OPERATION ARG... alpar@18: % alpar@18: \def\deftypeop #1 {\def\deftypeopcategory{#1}% alpar@18: \deftypeopparsebody\Edeftypeop\deftypeopx\deftypeopheader alpar@18: \deftypeopcategory} alpar@18: % alpar@18: % #1 is the class name, #2 the data type, #3 the operation name, #4 the args. alpar@18: \def\deftypeopheader#1#2#3#4{% alpar@18: \dosubind{fn}{\code{#3}}{\putwordon\ \code{#1}}% entry in function index alpar@18: \begingroup alpar@18: \defname{\defheaderxcond#2\relax$.$#3} alpar@18: {\deftypeopcategory\ \putwordon\ \code{#1}}% alpar@18: \deftypefunargs{#4}% alpar@18: \endgroup alpar@18: } alpar@18: alpar@18: % @deftypemethod CLASS TYPE METHOD ARG... alpar@18: % alpar@18: \def\deftypemethod{% alpar@18: \deftypemethparsebody\Edeftypemethod\deftypemethodx\deftypemethodheader} alpar@18: % alpar@18: % #1 is the class name, #2 the data type, #3 the method name, #4 the args. alpar@18: \def\deftypemethodheader#1#2#3#4{% alpar@18: \dosubind{fn}{\code{#3}}{\putwordon\ \code{#1}}% entry in function index alpar@18: \begingroup alpar@18: \defname{\defheaderxcond#2\relax$.$#3}{\putwordMethodon\ \code{#1}}% alpar@18: \deftypefunargs{#4}% alpar@18: \endgroup alpar@18: } alpar@18: alpar@18: % @deftypeivar CLASS TYPE VARNAME alpar@18: % alpar@18: \def\deftypeivar{% alpar@18: \deftypemethparsebody\Edeftypeivar\deftypeivarx\deftypeivarheader} alpar@18: % alpar@18: % #1 is the class name, #2 the data type, #3 the variable name. alpar@18: \def\deftypeivarheader#1#2#3{% alpar@18: \dosubind{vr}{\code{#3}}{\putwordof\ \code{#1}}% entry in variable index alpar@18: \begingroup alpar@18: \defname{\defheaderxcond#2\relax$.$#3} alpar@18: {\putwordInstanceVariableof\ \code{#1}}% alpar@18: \defvarargs{#3}% alpar@18: \endgroup alpar@18: } alpar@18: alpar@18: % @defmethod == @defop Method alpar@18: % alpar@18: \def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader} alpar@18: % alpar@18: % #1 is the class name, #2 the method name, #3 the args. alpar@18: \def\defmethodheader#1#2#3{% alpar@18: \dosubind{fn}{\code{#2}}{\putwordon\ \code{#1}}% entry in function index alpar@18: \begingroup alpar@18: \defname{#2}{\putwordMethodon\ \code{#1}}% alpar@18: \defunargs{#3}% alpar@18: \endgroup alpar@18: } alpar@18: alpar@18: % @defcv {Class Option} foo-class foo-flag alpar@18: alpar@18: \def\defcv #1 {\def\defcvtype{#1}% alpar@18: \defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype} alpar@18: alpar@18: \def\defcvarheader #1#2#3{% alpar@18: \dosubind{vr}{\code{#2}}{\putwordof\ \code{#1}}% variable index entry alpar@18: \begingroup alpar@18: \defname{#2}{\defcvtype\ \putwordof\ #1}% alpar@18: \defvarargs{#3}% alpar@18: \endgroup alpar@18: } alpar@18: alpar@18: % @defivar CLASS VARNAME == @defcv {Instance Variable} CLASS VARNAME alpar@18: % alpar@18: \def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader} alpar@18: % alpar@18: \def\defivarheader#1#2#3{% alpar@18: \dosubind{vr}{\code{#2}}{\putwordof\ \code{#1}}% entry in var index alpar@18: \begingroup alpar@18: \defname{#2}{\putwordInstanceVariableof\ #1}% alpar@18: \defvarargs{#3}% alpar@18: \endgroup alpar@18: } alpar@18: alpar@18: % @defvar alpar@18: % First, define the processing that is wanted for arguments of @defvar. alpar@18: % This is actually simple: just print them in roman. alpar@18: % This must expand the args and terminate the paragraph they make up alpar@18: \def\defvarargs #1{\normalparens #1% alpar@18: \defargscommonending alpar@18: } alpar@18: alpar@18: % @defvr Counter foo-count alpar@18: alpar@18: \def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader} alpar@18: alpar@18: \def\defvrheader #1#2#3{\doind {vr}{\code{#2}}% alpar@18: \begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup} alpar@18: alpar@18: % @defvar == @defvr Variable alpar@18: alpar@18: \def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader} alpar@18: alpar@18: \def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index alpar@18: \begingroup\defname {#1}{\putwordDefvar}% alpar@18: \defvarargs {#2}\endgroup % alpar@18: } alpar@18: alpar@18: % @defopt == @defvr {User Option} alpar@18: alpar@18: \def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader} alpar@18: alpar@18: \def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index alpar@18: \begingroup\defname {#1}{\putwordDefopt}% alpar@18: \defvarargs {#2}\endgroup % alpar@18: } alpar@18: alpar@18: % @deftypevar int foobar alpar@18: alpar@18: \def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader} alpar@18: alpar@18: % #1 is the data type. #2 is the name, perhaps followed by text that alpar@18: % is actually part of the data type, which should not be put into the index. alpar@18: \def\deftypevarheader #1#2{% alpar@18: \dovarind#2 \relax% Make entry in variables index alpar@18: \begingroup\defname {\defheaderxcond#1\relax$.$#2}{\putwordDeftypevar}% alpar@18: \defargscommonending alpar@18: \endgroup} alpar@18: \def\dovarind#1 #2\relax{\doind{vr}{\code{#1}}} alpar@18: alpar@18: % @deftypevr {Global Flag} int enable alpar@18: alpar@18: \def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader} alpar@18: alpar@18: \def\deftypevrheader #1#2#3{\dovarind#3 \relax% alpar@18: \begingroup\defname {\defheaderxcond#2\relax$.$#3}{#1} alpar@18: \defargscommonending alpar@18: \endgroup} alpar@18: alpar@18: % Now define @deftp alpar@18: % Args are printed in bold, a slight difference from @defvar. alpar@18: alpar@18: \def\deftpargs #1{\bf \defvarargs{#1}} alpar@18: alpar@18: % @deftp Class window height width ... alpar@18: alpar@18: \def\deftp{\deftpparsebody\Edeftp\deftpx\deftpheader} alpar@18: alpar@18: \def\deftpheader #1#2#3{\doind {tp}{\code{#2}}% alpar@18: \begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup} alpar@18: alpar@18: % These definitions are used if you use @defunx (etc.) alpar@18: % anywhere other than immediately after a @defun or @defunx. alpar@18: % alpar@18: \def\defcvx#1 {\errmessage{@defcvx in invalid context}} alpar@18: \def\deffnx#1 {\errmessage{@deffnx in invalid context}} alpar@18: \def\defivarx#1 {\errmessage{@defivarx in invalid context}} alpar@18: \def\defmacx#1 {\errmessage{@defmacx in invalid context}} alpar@18: \def\defmethodx#1 {\errmessage{@defmethodx in invalid context}} alpar@18: \def\defoptx #1 {\errmessage{@defoptx in invalid context}} alpar@18: \def\defopx#1 {\errmessage{@defopx in invalid context}} alpar@18: \def\defspecx#1 {\errmessage{@defspecx in invalid context}} alpar@18: \def\deftpx#1 {\errmessage{@deftpx in invalid context}} alpar@18: \def\deftypefnx#1 {\errmessage{@deftypefnx in invalid context}} alpar@18: \def\deftypefunx#1 {\errmessage{@deftypefunx in invalid context}} alpar@18: \def\deftypeivarx#1 {\errmessage{@deftypeivarx in invalid context}} alpar@18: \def\deftypemethodx#1 {\errmessage{@deftypemethodx in invalid context}} alpar@18: \def\deftypeopx#1 {\errmessage{@deftypeopx in invalid context}} alpar@18: \def\deftypevarx#1 {\errmessage{@deftypevarx in invalid context}} alpar@18: \def\deftypevrx#1 {\errmessage{@deftypevrx in invalid context}} alpar@18: \def\defunx#1 {\errmessage{@defunx in invalid context}} alpar@18: \def\defvarx#1 {\errmessage{@defvarx in invalid context}} alpar@18: \def\defvrx#1 {\errmessage{@defvrx in invalid context}} alpar@18: alpar@18: alpar@18: \message{macros,} alpar@18: % @macro. alpar@18: alpar@18: % To do this right we need a feature of e-TeX, \scantokens, alpar@18: % which we arrange to emulate with a temporary file in ordinary TeX. alpar@18: \ifx\eTeXversion\undefined alpar@18: \newwrite\macscribble alpar@18: \def\scanmacro#1{% alpar@18: \begingroup \newlinechar`\^^M alpar@18: % Undo catcode changes of \startcontents and \doprintindex alpar@18: \catcode`\@=0 \catcode`\\=\other \escapechar=`\@ alpar@18: % Append \endinput to make sure that TeX does not see the ending newline. alpar@18: \toks0={#1\endinput}% alpar@18: \immediate\openout\macscribble=\jobname.tmp alpar@18: \immediate\write\macscribble{\the\toks0}% alpar@18: \immediate\closeout\macscribble alpar@18: \let\xeatspaces\eatspaces alpar@18: \input \jobname.tmp alpar@18: \endgroup alpar@18: } alpar@18: \else alpar@18: \def\scanmacro#1{% alpar@18: \begingroup \newlinechar`\^^M alpar@18: % Undo catcode changes of \startcontents and \doprintindex alpar@18: \catcode`\@=0 \catcode`\\=\other \escapechar=`\@ alpar@18: \let\xeatspaces\eatspaces\scantokens{#1\endinput}\endgroup} alpar@18: \fi alpar@18: alpar@18: \newcount\paramno % Count of parameters alpar@18: \newtoks\macname % Macro name alpar@18: \newif\ifrecursive % Is it recursive? alpar@18: \def\macrolist{} % List of all defined macros in the form alpar@18: % \do\macro1\do\macro2... alpar@18: alpar@18: % Utility routines. alpar@18: % Thisdoes \let #1 = #2, except with \csnames. alpar@18: \def\cslet#1#2{% alpar@18: \expandafter\expandafter alpar@18: \expandafter\let alpar@18: \expandafter\expandafter alpar@18: \csname#1\endcsname alpar@18: \csname#2\endcsname} alpar@18: alpar@18: % Trim leading and trailing spaces off a string. alpar@18: % Concepts from aro-bend problem 15 (see CTAN). alpar@18: {\catcode`\@=11 alpar@18: \gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }} alpar@18: \gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@} alpar@18: \gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @} alpar@18: \def\unbrace#1{#1} alpar@18: \unbrace{\gdef\trim@@@ #1 } #2@{#1} alpar@18: } alpar@18: alpar@18: % Trim a single trailing ^^M off a string. alpar@18: {\catcode`\^^M=\other \catcode`\Q=3% alpar@18: \gdef\eatcr #1{\eatcra #1Q^^MQ}% alpar@18: \gdef\eatcra#1^^MQ{\eatcrb#1Q}% alpar@18: \gdef\eatcrb#1Q#2Q{#1}% alpar@18: } alpar@18: alpar@18: % Macro bodies are absorbed as an argument in a context where alpar@18: % all characters are catcode 10, 11 or 12, except \ which is active alpar@18: % (as in normal texinfo). It is necessary to change the definition of \. alpar@18: alpar@18: % It's necessary to have hard CRs when the macro is executed. This is alpar@18: % done by making ^^M (\endlinechar) catcode 12 when reading the macro alpar@18: % body, and then making it the \newlinechar in \scanmacro. alpar@18: alpar@18: \def\macrobodyctxt{% alpar@18: \catcode`\~=\other alpar@18: \catcode`\^=\other alpar@18: \catcode`\_=\other alpar@18: \catcode`\|=\other alpar@18: \catcode`\<=\other alpar@18: \catcode`\>=\other alpar@18: \catcode`\+=\other alpar@18: \catcode`\{=\other alpar@18: \catcode`\}=\other alpar@18: \catcode`\@=\other alpar@18: \catcode`\^^M=\other alpar@18: \usembodybackslash} alpar@18: alpar@18: \def\macroargctxt{% alpar@18: \catcode`\~=\other alpar@18: \catcode`\^=\other alpar@18: \catcode`\_=\other alpar@18: \catcode`\|=\other alpar@18: \catcode`\<=\other alpar@18: \catcode`\>=\other alpar@18: \catcode`\+=\other alpar@18: \catcode`\@=\other alpar@18: \catcode`\\=\other} alpar@18: alpar@18: % \mbodybackslash is the definition of \ in @macro bodies. alpar@18: % It maps \foo\ => \csname macarg.foo\endcsname => #N alpar@18: % where N is the macro parameter number. alpar@18: % We define \csname macarg.\endcsname to be \realbackslash, so alpar@18: % \\ in macro replacement text gets you a backslash. alpar@18: alpar@18: {\catcode`@=0 @catcode`@\=@active alpar@18: @gdef@usembodybackslash{@let\=@mbodybackslash} alpar@18: @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname} alpar@18: } alpar@18: \expandafter\def\csname macarg.\endcsname{\realbackslash} alpar@18: alpar@18: \def\macro{\recursivefalse\parsearg\macroxxx} alpar@18: \def\rmacro{\recursivetrue\parsearg\macroxxx} alpar@18: alpar@18: \def\macroxxx#1{% alpar@18: \getargs{#1}% now \macname is the macname and \argl the arglist alpar@18: \ifx\argl\empty % no arguments alpar@18: \paramno=0% alpar@18: \else alpar@18: \expandafter\parsemargdef \argl;% alpar@18: \fi alpar@18: \if1\csname ismacro.\the\macname\endcsname alpar@18: \message{Warning: redefining \the\macname}% alpar@18: \else alpar@18: \expandafter\ifx\csname \the\macname\endcsname \relax alpar@18: \else \errmessage{Macro name \the\macname\space already defined}\fi alpar@18: \global\cslet{macsave.\the\macname}{\the\macname}% alpar@18: \global\expandafter\let\csname ismacro.\the\macname\endcsname=1% alpar@18: % Add the macroname to \macrolist alpar@18: \toks0 = \expandafter{\macrolist\do}% alpar@18: \xdef\macrolist{\the\toks0 alpar@18: \expandafter\noexpand\csname\the\macname\endcsname}% alpar@18: \fi alpar@18: \begingroup \macrobodyctxt alpar@18: \ifrecursive \expandafter\parsermacbody alpar@18: \else \expandafter\parsemacbody alpar@18: \fi} alpar@18: alpar@18: \def\unmacro{\parsearg\dounmacro} alpar@18: \def\dounmacro#1{% alpar@18: \if1\csname ismacro.#1\endcsname alpar@18: \global\cslet{#1}{macsave.#1}% alpar@18: \global\expandafter\let \csname ismacro.#1\endcsname=0% alpar@18: % Remove the macro name from \macrolist: alpar@18: \begingroup alpar@18: \expandafter\let\csname#1\endcsname \relax alpar@18: \let\do\unmacrodo alpar@18: \xdef\macrolist{\macrolist}% alpar@18: \endgroup alpar@18: \else alpar@18: \errmessage{Macro #1 not defined}% alpar@18: \fi alpar@18: } alpar@18: alpar@18: % Called by \do from \dounmacro on each macro. The idea is to omit any alpar@18: % macro definitions that have been changed to \relax. alpar@18: % alpar@18: \def\unmacrodo#1{% alpar@18: \ifx#1\relax alpar@18: % remove this alpar@18: \else alpar@18: \noexpand\do \noexpand #1% alpar@18: \fi alpar@18: } alpar@18: alpar@18: % This makes use of the obscure feature that if the last token of a alpar@18: % is #, then the preceding argument is delimited by alpar@18: % an opening brace, and that opening brace is not consumed. alpar@18: \def\getargs#1{\getargsxxx#1{}} alpar@18: \def\getargsxxx#1#{\getmacname #1 \relax\getmacargs} alpar@18: \def\getmacname #1 #2\relax{\macname={#1}} alpar@18: \def\getmacargs#1{\def\argl{#1}} alpar@18: alpar@18: % Parse the optional {params} list. Set up \paramno and \paramlist alpar@18: % so \defmacro knows what to do. Define \macarg.blah for each blah alpar@18: % in the params list, to be ##N where N is the position in that list. alpar@18: % That gets used by \mbodybackslash (above). alpar@18: alpar@18: % We need to get `macro parameter char #' into several definitions. alpar@18: % The technique used is stolen from LaTeX: let \hash be something alpar@18: % unexpandable, insert that wherever you need a #, and then redefine alpar@18: % it to # just before using the token list produced. alpar@18: % alpar@18: % The same technique is used to protect \eatspaces till just before alpar@18: % the macro is used. alpar@18: alpar@18: \def\parsemargdef#1;{\paramno=0\def\paramlist{}% alpar@18: \let\hash\relax\let\xeatspaces\relax\parsemargdefxxx#1,;,} alpar@18: \def\parsemargdefxxx#1,{% alpar@18: \if#1;\let\next=\relax alpar@18: \else \let\next=\parsemargdefxxx alpar@18: \advance\paramno by 1% alpar@18: \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname alpar@18: {\xeatspaces{\hash\the\paramno}}% alpar@18: \edef\paramlist{\paramlist\hash\the\paramno,}% alpar@18: \fi\next} alpar@18: alpar@18: % These two commands read recursive and nonrecursive macro bodies. alpar@18: % (They're different since rec and nonrec macros end differently.) alpar@18: alpar@18: \long\def\parsemacbody#1@end macro% alpar@18: {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}% alpar@18: \long\def\parsermacbody#1@end rmacro% alpar@18: {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}% alpar@18: alpar@18: % This defines the macro itself. There are six cases: recursive and alpar@18: % nonrecursive macros of zero, one, and many arguments. alpar@18: % Much magic with \expandafter here. alpar@18: % \xdef is used so that macro definitions will survive the file alpar@18: % they're defined in; @include reads the file inside a group. alpar@18: \def\defmacro{% alpar@18: \let\hash=##% convert placeholders to macro parameter chars alpar@18: \ifrecursive alpar@18: \ifcase\paramno alpar@18: % 0 alpar@18: \expandafter\xdef\csname\the\macname\endcsname{% alpar@18: \noexpand\scanmacro{\temp}}% alpar@18: \or % 1 alpar@18: \expandafter\xdef\csname\the\macname\endcsname{% alpar@18: \bgroup\noexpand\macroargctxt alpar@18: \noexpand\braceorline alpar@18: \expandafter\noexpand\csname\the\macname xxx\endcsname}% alpar@18: \expandafter\xdef\csname\the\macname xxx\endcsname##1{% alpar@18: \egroup\noexpand\scanmacro{\temp}}% alpar@18: \else % many alpar@18: \expandafter\xdef\csname\the\macname\endcsname{% alpar@18: \bgroup\noexpand\macroargctxt alpar@18: \noexpand\csname\the\macname xx\endcsname}% alpar@18: \expandafter\xdef\csname\the\macname xx\endcsname##1{% alpar@18: \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}% alpar@18: \expandafter\expandafter alpar@18: \expandafter\xdef alpar@18: \expandafter\expandafter alpar@18: \csname\the\macname xxx\endcsname alpar@18: \paramlist{\egroup\noexpand\scanmacro{\temp}}% alpar@18: \fi alpar@18: \else alpar@18: \ifcase\paramno alpar@18: % 0 alpar@18: \expandafter\xdef\csname\the\macname\endcsname{% alpar@18: \noexpand\norecurse{\the\macname}% alpar@18: \noexpand\scanmacro{\temp}\egroup}% alpar@18: \or % 1 alpar@18: \expandafter\xdef\csname\the\macname\endcsname{% alpar@18: \bgroup\noexpand\macroargctxt alpar@18: \noexpand\braceorline alpar@18: \expandafter\noexpand\csname\the\macname xxx\endcsname}% alpar@18: \expandafter\xdef\csname\the\macname xxx\endcsname##1{% alpar@18: \egroup alpar@18: \noexpand\norecurse{\the\macname}% alpar@18: \noexpand\scanmacro{\temp}\egroup}% alpar@18: \else % many alpar@18: \expandafter\xdef\csname\the\macname\endcsname{% alpar@18: \bgroup\noexpand\macroargctxt alpar@18: \expandafter\noexpand\csname\the\macname xx\endcsname}% alpar@18: \expandafter\xdef\csname\the\macname xx\endcsname##1{% alpar@18: \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}% alpar@18: \expandafter\expandafter alpar@18: \expandafter\xdef alpar@18: \expandafter\expandafter alpar@18: \csname\the\macname xxx\endcsname alpar@18: \paramlist{% alpar@18: \egroup alpar@18: \noexpand\norecurse{\the\macname}% alpar@18: \noexpand\scanmacro{\temp}\egroup}% alpar@18: \fi alpar@18: \fi} alpar@18: alpar@18: \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}} alpar@18: alpar@18: % \braceorline decides whether the next nonwhitespace character is a alpar@18: % {. If so it reads up to the closing }, if not, it reads the whole alpar@18: % line. Whatever was read is then fed to the next control sequence alpar@18: % as an argument (by \parsebrace or \parsearg) alpar@18: \def\braceorline#1{\let\next=#1\futurelet\nchar\braceorlinexxx} alpar@18: \def\braceorlinexxx{% alpar@18: \ifx\nchar\bgroup\else alpar@18: \expandafter\parsearg alpar@18: \fi \next} alpar@18: alpar@18: % We mant to disable all macros during \shipout so that they are not alpar@18: % expanded by \write. alpar@18: \def\turnoffmacros{\begingroup \def\do##1{\let\noexpand##1=\relax}% alpar@18: \edef\next{\macrolist}\expandafter\endgroup\next} alpar@18: alpar@18: alpar@18: % @alias. alpar@18: % We need some trickery to remove the optional spaces around the equal alpar@18: % sign. Just make them active and then expand them all to nothing. alpar@18: \def\alias{\begingroup\obeyspaces\parsearg\aliasxxx} alpar@18: \def\aliasxxx #1{\aliasyyy#1\relax} alpar@18: \def\aliasyyy #1=#2\relax{\ignoreactivespaces alpar@18: \edef\next{\global\let\expandafter\noexpand\csname#1\endcsname=% alpar@18: \expandafter\noexpand\csname#2\endcsname}% alpar@18: \expandafter\endgroup\next} alpar@18: alpar@18: alpar@18: \message{cross references,} alpar@18: % @xref etc. alpar@18: alpar@18: \newwrite\auxfile alpar@18: alpar@18: \newif\ifhavexrefs % True if xref values are known. alpar@18: \newif\ifwarnedxrefs % True if we warned once that they aren't known. alpar@18: alpar@18: % @inforef is relatively simple. alpar@18: \def\inforef #1{\inforefzzz #1,,,,**} alpar@18: \def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}}, alpar@18: node \samp{\ignorespaces#1{}}} alpar@18: alpar@18: % @node's job is to define \lastnode. alpar@18: \def\node{\ENVcheck\parsearg\nodezzz} alpar@18: \def\nodezzz#1{\nodexxx #1,\finishnodeparse} alpar@18: \def\nodexxx#1,#2\finishnodeparse{\gdef\lastnode{#1}} alpar@18: \let\nwnode=\node alpar@18: \let\lastnode=\relax alpar@18: alpar@18: % The sectioning commands (@chapter, etc.) call these. alpar@18: \def\donoderef{% alpar@18: \ifx\lastnode\relax\else alpar@18: \expandafter\expandafter\expandafter\setref{\lastnode}% alpar@18: {Ysectionnumberandtype}% alpar@18: \global\let\lastnode=\relax alpar@18: \fi alpar@18: } alpar@18: \def\unnumbnoderef{% alpar@18: \ifx\lastnode\relax\else alpar@18: \expandafter\expandafter\expandafter\setref{\lastnode}{Ynothing}% alpar@18: \global\let\lastnode=\relax alpar@18: \fi alpar@18: } alpar@18: \def\appendixnoderef{% alpar@18: \ifx\lastnode\relax\else alpar@18: \expandafter\expandafter\expandafter\setref{\lastnode}% alpar@18: {Yappendixletterandtype}% alpar@18: \global\let\lastnode=\relax alpar@18: \fi alpar@18: } alpar@18: alpar@18: alpar@18: % @anchor{NAME} -- define xref target at arbitrary point. alpar@18: % alpar@18: \newcount\savesfregister alpar@18: \gdef\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi} alpar@18: \gdef\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi} alpar@18: \gdef\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces} alpar@18: alpar@18: % \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an alpar@18: % anchor), namely NAME-title (the corresponding @chapter/etc. name), alpar@18: % NAME-pg (the page number), and NAME-snt (section number and type). alpar@18: % Called from \foonoderef. alpar@18: % alpar@18: % We have to set \indexdummies so commands such as @code in a section alpar@18: % title aren't expanded. It would be nicer not to expand the titles in alpar@18: % the first place, but there's so many layers that that is hard to do. alpar@18: % alpar@18: % Likewise, use \turnoffactive so that punctuation chars such as underscore alpar@18: % and backslash work in node names. alpar@18: % alpar@18: \def\setref#1#2{{% alpar@18: \atdummies alpar@18: \pdfmkdest{#1}% alpar@18: % alpar@18: \turnoffactive alpar@18: \dosetq{#1-title}{Ytitle}% alpar@18: \dosetq{#1-pg}{Ypagenumber}% alpar@18: \dosetq{#1-snt}{#2}% alpar@18: }} alpar@18: alpar@18: % @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is alpar@18: % the node name, #2 the name of the Info cross-reference, #3 the printed alpar@18: % node name, #4 the name of the Info file, #5 the name of the printed alpar@18: % manual. All but the node name can be omitted. alpar@18: % alpar@18: \def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]} alpar@18: \def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]} alpar@18: \def\ref#1{\xrefX[#1,,,,,,,]} alpar@18: \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup alpar@18: \unsepspaces alpar@18: \def\printedmanual{\ignorespaces #5}% alpar@18: \def\printednodename{\ignorespaces #3}% alpar@18: \setbox1=\hbox{\printedmanual}% alpar@18: \setbox0=\hbox{\printednodename}% alpar@18: \ifdim \wd0 = 0pt alpar@18: % No printed node name was explicitly given. alpar@18: \expandafter\ifx\csname SETxref-automatic-section-title\endcsname\relax alpar@18: % Use the node name inside the square brackets. alpar@18: \def\printednodename{\ignorespaces #1}% alpar@18: \else alpar@18: % Use the actual chapter/section title appear inside alpar@18: % the square brackets. Use the real section title if we have it. alpar@18: \ifdim \wd1 > 0pt alpar@18: % It is in another manual, so we don't have it. alpar@18: \def\printednodename{\ignorespaces #1}% alpar@18: \else alpar@18: \ifhavexrefs alpar@18: % We know the real title if we have the xref values. alpar@18: \def\printednodename{\refx{#1-title}{}}% alpar@18: \else alpar@18: % Otherwise just copy the Info node name. alpar@18: \def\printednodename{\ignorespaces #1}% alpar@18: \fi% alpar@18: \fi alpar@18: \fi alpar@18: \fi alpar@18: % alpar@18: % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not alpar@18: % insert empty discretionaries after hyphens, which means that it will alpar@18: % not find a line break at a hyphen in a node names. Since some manuals alpar@18: % are best written with fairly long node names, containing hyphens, this alpar@18: % is a loss. Therefore, we give the text of the node name again, so it alpar@18: % is as if TeX is seeing it for the first time. alpar@18: \ifpdf alpar@18: \leavevmode alpar@18: \getfilename{#4}% alpar@18: {\turnoffactive \otherbackslash alpar@18: \ifnum\filenamelength>0 alpar@18: \startlink attr{/Border [0 0 0]}% alpar@18: goto file{\the\filename.pdf} name{#1}% alpar@18: \else alpar@18: \startlink attr{/Border [0 0 0]}% alpar@18: goto name{#1}% alpar@18: \fi alpar@18: }% alpar@18: \linkcolor alpar@18: \fi alpar@18: % alpar@18: \ifdim \wd1 > 0pt alpar@18: \putwordsection{} ``\printednodename'' \putwordin{} \cite{\printedmanual}% alpar@18: \else alpar@18: % _ (for example) has to be the character _ for the purposes of the alpar@18: % control sequence corresponding to the node, but it has to expand alpar@18: % into the usual \leavevmode...\vrule stuff for purposes of alpar@18: % printing. So we \turnoffactive for the \refx-snt, back on for the alpar@18: % printing, back off for the \refx-pg. alpar@18: {\turnoffactive \otherbackslash alpar@18: % Only output a following space if the -snt ref is nonempty; for alpar@18: % @unnumbered and @anchor, it won't be. alpar@18: \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}% alpar@18: \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi alpar@18: }% alpar@18: % output the `[mynode]' via a macro. alpar@18: \xrefprintnodename\printednodename alpar@18: % alpar@18: % But we always want a comma and a space: alpar@18: ,\space alpar@18: % alpar@18: % output the `page 3'. alpar@18: \turnoffactive \otherbackslash \putwordpage\tie\refx{#1-pg}{}% alpar@18: \fi alpar@18: \endlink alpar@18: \endgroup} alpar@18: alpar@18: % This macro is called from \xrefX for the `[nodename]' part of xref alpar@18: % output. It's a separate macro only so it can be changed more easily, alpar@18: % since not square brackets don't work in some documents. Particularly alpar@18: % one that Bob is working on :). alpar@18: % alpar@18: \def\xrefprintnodename#1{[#1]} alpar@18: alpar@18: % \dosetq is called from \setref to do the actual \write (\iflinks). alpar@18: % alpar@18: \def\dosetq#1#2{% alpar@18: {\let\folio=0% alpar@18: \edef\next{\write\auxfile{\internalsetq{#1}{#2}}}% alpar@18: \iflinks \next \fi alpar@18: }% alpar@18: } alpar@18: alpar@18: % \internalsetq{foo}{page} expands into alpar@18: % CHARACTERS @xrdef{foo}{...expansion of \page...} alpar@18: \def\internalsetq#1#2{@xrdef{#1}{\csname #2\endcsname}} alpar@18: alpar@18: % Things to be expanded by \internalsetq. alpar@18: % alpar@18: \def\Ypagenumber{\folio} alpar@18: \def\Ytitle{\thissection} alpar@18: \def\Ynothing{} alpar@18: \def\Ysectionnumberandtype{% alpar@18: \ifnum\secno=0 alpar@18: \putwordChapter@tie \the\chapno alpar@18: \else \ifnum\subsecno=0 alpar@18: \putwordSection@tie \the\chapno.\the\secno alpar@18: \else \ifnum\subsubsecno=0 alpar@18: \putwordSection@tie \the\chapno.\the\secno.\the\subsecno alpar@18: \else alpar@18: \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno alpar@18: \fi\fi\fi alpar@18: } alpar@18: alpar@18: \def\Yappendixletterandtype{% alpar@18: \ifnum\secno=0 alpar@18: \putwordAppendix@tie @char\the\appendixno{}% alpar@18: \else \ifnum\subsecno=0 alpar@18: \putwordSection@tie @char\the\appendixno.\the\secno alpar@18: \else \ifnum\subsubsecno=0 alpar@18: \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno alpar@18: \else alpar@18: \putwordSection@tie alpar@18: @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno alpar@18: \fi\fi\fi alpar@18: } alpar@18: alpar@18: % Use TeX 3.0's \inputlineno to get the line number, for better error alpar@18: % messages, but if we're using an old version of TeX, don't do anything. alpar@18: % alpar@18: \ifx\inputlineno\thisisundefined alpar@18: \let\linenumber = \empty % Pre-3.0. alpar@18: \else alpar@18: \def\linenumber{\the\inputlineno:\space} alpar@18: \fi alpar@18: alpar@18: % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME. alpar@18: % If its value is nonempty, SUFFIX is output afterward. alpar@18: % alpar@18: \def\refx#1#2{% alpar@18: {% alpar@18: \indexnofonts alpar@18: \otherbackslash alpar@18: \expandafter\global\expandafter\let\expandafter\thisrefX alpar@18: \csname X#1\endcsname alpar@18: }% alpar@18: \ifx\thisrefX\relax alpar@18: % If not defined, say something at least. alpar@18: \angleleft un\-de\-fined\angleright alpar@18: \iflinks alpar@18: \ifhavexrefs alpar@18: \message{\linenumber Undefined cross reference `#1'.}% alpar@18: \else alpar@18: \ifwarnedxrefs\else alpar@18: \global\warnedxrefstrue alpar@18: \message{Cross reference values unknown; you must run TeX again.}% alpar@18: \fi alpar@18: \fi alpar@18: \fi alpar@18: \else alpar@18: % It's defined, so just use it. alpar@18: \thisrefX alpar@18: \fi alpar@18: #2% Output the suffix in any case. alpar@18: } alpar@18: alpar@18: % This is the macro invoked by entries in the aux file. alpar@18: % alpar@18: \def\xrdef#1{\expandafter\gdef\csname X#1\endcsname} alpar@18: alpar@18: % Read the last existing aux file, if any. No error if none exists. alpar@18: \def\readauxfile{\begingroup alpar@18: \catcode`\^^@=\other alpar@18: \catcode`\^^A=\other alpar@18: \catcode`\^^B=\other alpar@18: \catcode`\^^C=\other alpar@18: \catcode`\^^D=\other alpar@18: \catcode`\^^E=\other alpar@18: \catcode`\^^F=\other alpar@18: \catcode`\^^G=\other alpar@18: \catcode`\^^H=\other alpar@18: \catcode`\^^K=\other alpar@18: \catcode`\^^L=\other alpar@18: \catcode`\^^N=\other alpar@18: \catcode`\^^P=\other alpar@18: \catcode`\^^Q=\other alpar@18: \catcode`\^^R=\other alpar@18: \catcode`\^^S=\other alpar@18: \catcode`\^^T=\other alpar@18: \catcode`\^^U=\other alpar@18: \catcode`\^^V=\other alpar@18: \catcode`\^^W=\other alpar@18: \catcode`\^^X=\other alpar@18: \catcode`\^^Z=\other alpar@18: \catcode`\^^[=\other alpar@18: \catcode`\^^\=\other alpar@18: \catcode`\^^]=\other alpar@18: \catcode`\^^^=\other alpar@18: \catcode`\^^_=\other alpar@18: % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc. alpar@18: % in xref tags, i.e., node names. But since ^^e4 notation isn't alpar@18: % supported in the main text, it doesn't seem desirable. Furthermore, alpar@18: % that is not enough: for node names that actually contain a ^ alpar@18: % character, we would end up writing a line like this: 'xrdef {'hat alpar@18: % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first alpar@18: % argument, and \hat is not an expandable control sequence. It could alpar@18: % all be worked out, but why? Either we support ^^ or we don't. alpar@18: % alpar@18: % The other change necessary for this was to define \auxhat: alpar@18: % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter alpar@18: % and then to call \auxhat in \setq. alpar@18: % alpar@18: \catcode`\^=\other alpar@18: % alpar@18: % Special characters. Should be turned off anyway, but... alpar@18: \catcode`\~=\other alpar@18: \catcode`\[=\other alpar@18: \catcode`\]=\other alpar@18: \catcode`\"=\other alpar@18: \catcode`\_=\other alpar@18: \catcode`\|=\other alpar@18: \catcode`\<=\other alpar@18: \catcode`\>=\other alpar@18: \catcode`\$=\other alpar@18: \catcode`\#=\other alpar@18: \catcode`\&=\other alpar@18: \catcode`\%=\other alpar@18: \catcode`+=\other % avoid \+ for paranoia even though we've turned it off alpar@18: % alpar@18: % Make the characters 128-255 be printing characters alpar@18: {% alpar@18: \count 1=128 alpar@18: \def\loop{% alpar@18: \catcode\count 1=\other alpar@18: \advance\count 1 by 1 alpar@18: \ifnum \count 1<256 \loop \fi alpar@18: }% alpar@18: }% alpar@18: % alpar@18: % Turn off \ as an escape so we do not lose on alpar@18: % entries which were dumped with control sequences in their names. alpar@18: % For example, @xrdef{$\leq $-fun}{page ...} made by @defun ^^ alpar@18: % Reference to such entries still does not work the way one would wish, alpar@18: % but at least they do not bomb out when the aux file is read in. alpar@18: \catcode`\\=\other alpar@18: % alpar@18: % @ is our escape character in .aux files. alpar@18: \catcode`\{=1 alpar@18: \catcode`\}=2 alpar@18: \catcode`\@=0 alpar@18: % alpar@18: \openin 1 \jobname.aux alpar@18: \ifeof 1 \else alpar@18: \closein 1 alpar@18: \input \jobname.aux alpar@18: \global\havexrefstrue alpar@18: \fi alpar@18: % Open the new aux file. TeX will close it automatically at exit. alpar@18: \openout\auxfile=\jobname.aux alpar@18: \endgroup} alpar@18: alpar@18: alpar@18: % Footnotes. alpar@18: alpar@18: \newcount \footnoteno alpar@18: alpar@18: % The trailing space in the following definition for supereject is alpar@18: % vital for proper filling; pages come out unaligned when you do a alpar@18: % pagealignmacro call if that space before the closing brace is alpar@18: % removed. (Generally, numeric constants should always be followed by a alpar@18: % space to prevent strange expansion errors.) alpar@18: \def\supereject{\par\penalty -20000\footnoteno =0 } alpar@18: alpar@18: % @footnotestyle is meaningful for info output only. alpar@18: \let\footnotestyle=\comment alpar@18: alpar@18: \let\ptexfootnote=\footnote alpar@18: alpar@18: {\catcode `\@=11 alpar@18: % alpar@18: % Auto-number footnotes. Otherwise like plain. alpar@18: \gdef\footnote{% alpar@18: \let\indent=\ptexindent alpar@18: \global\advance\footnoteno by \@ne alpar@18: \edef\thisfootno{$^{\the\footnoteno}$}% alpar@18: % alpar@18: % In case the footnote comes at the end of a sentence, preserve the alpar@18: % extra spacing after we do the footnote number. alpar@18: \let\@sf\empty alpar@18: \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi alpar@18: % alpar@18: % Remove inadvertent blank space before typesetting the footnote number. alpar@18: \unskip alpar@18: \thisfootno\@sf alpar@18: \dofootnote alpar@18: }% alpar@18: alpar@18: % Don't bother with the trickery in plain.tex to not require the alpar@18: % footnote text as a parameter. Our footnotes don't need to be so general. alpar@18: % alpar@18: % Oh yes, they do; otherwise, @ifset and anything else that uses alpar@18: % \parseargline fail inside footnotes because the tokens are fixed when alpar@18: % the footnote is read. --karl, 16nov96. alpar@18: % alpar@18: % The start of the footnote looks usually like this: alpar@18: \gdef\startfootins{\insert\footins\bgroup} alpar@18: % alpar@18: % ... but this macro is redefined inside @multitable. alpar@18: % alpar@18: \gdef\dofootnote{% alpar@18: \startfootins alpar@18: % We want to typeset this text as a normal paragraph, even if the alpar@18: % footnote reference occurs in (for example) a display environment. alpar@18: % So reset some parameters. alpar@18: \hsize=\pagewidth alpar@18: \interlinepenalty\interfootnotelinepenalty alpar@18: \splittopskip\ht\strutbox % top baseline for broken footnotes alpar@18: \splitmaxdepth\dp\strutbox alpar@18: \floatingpenalty\@MM alpar@18: \leftskip\z@skip alpar@18: \rightskip\z@skip alpar@18: \spaceskip\z@skip alpar@18: \xspaceskip\z@skip alpar@18: \parindent\defaultparindent alpar@18: % alpar@18: \smallfonts \rm alpar@18: % alpar@18: % Because we use hanging indentation in footnotes, a @noindent appears alpar@18: % to exdent this text, so make it be a no-op. makeinfo does not use alpar@18: % hanging indentation so @noindent can still be needed within footnote alpar@18: % text after an @example or the like (not that this is good style). alpar@18: \let\noindent = \relax alpar@18: % alpar@18: % Hang the footnote text off the number. Use \everypar in case the alpar@18: % footnote extends for more than one paragraph. alpar@18: \everypar = {\hang}% alpar@18: \textindent{\thisfootno}% alpar@18: % alpar@18: % Don't crash into the line above the footnote text. Since this alpar@18: % expands into a box, it must come within the paragraph, lest it alpar@18: % provide a place where TeX can split the footnote. alpar@18: \footstrut alpar@18: \futurelet\next\fo@t alpar@18: } alpar@18: }%end \catcode `\@=11 alpar@18: alpar@18: % @| inserts a changebar to the left of the current line. It should alpar@18: % surround any changed text. This approach does *not* work if the alpar@18: % change spans more than two lines of output. To handle that, we would alpar@18: % have adopt a much more difficult approach (putting marks into the main alpar@18: % vertical list for the beginning and end of each change). alpar@18: % alpar@18: \def\|{% alpar@18: % \vadjust can only be used in horizontal mode. alpar@18: \leavevmode alpar@18: % alpar@18: % Append this vertical mode material after the current line in the output. alpar@18: \vadjust{% alpar@18: % We want to insert a rule with the height and depth of the current alpar@18: % leading; that is exactly what \strutbox is supposed to record. alpar@18: \vskip-\baselineskip alpar@18: % alpar@18: % \vadjust-items are inserted at the left edge of the type. So alpar@18: % the \llap here moves out into the left-hand margin. alpar@18: \llap{% alpar@18: % alpar@18: % For a thicker or thinner bar, change the `1pt'. alpar@18: \vrule height\baselineskip width1pt alpar@18: % alpar@18: % This is the space between the bar and the text. alpar@18: \hskip 12pt alpar@18: }% alpar@18: }% alpar@18: } alpar@18: alpar@18: % For a final copy, take out the rectangles alpar@18: % that mark overfull boxes (in case you have decided alpar@18: % that the text looks ok even though it passes the margin). alpar@18: % alpar@18: \def\finalout{\overfullrule=0pt} alpar@18: alpar@18: % @image. We use the macros from epsf.tex to support this. alpar@18: % If epsf.tex is not installed and @image is used, we complain. alpar@18: % alpar@18: % Check for and read epsf.tex up front. If we read it only at @image alpar@18: % time, we might be inside a group, and then its definitions would get alpar@18: % undone and the next image would fail. alpar@18: \openin 1 = epsf.tex alpar@18: \ifeof 1 \else alpar@18: \closein 1 alpar@18: % Do not bother showing banner with epsf.tex v2.7k (available in alpar@18: % doc/epsf.tex and on ctan). alpar@18: \def\epsfannounce{\toks0 = }% alpar@18: \input epsf.tex alpar@18: \fi alpar@18: % alpar@18: % We will only complain once about lack of epsf.tex. alpar@18: \newif\ifwarnednoepsf alpar@18: \newhelp\noepsfhelp{epsf.tex must be installed for images to alpar@18: work. It is also included in the Texinfo distribution, or you can get alpar@18: it from ftp://tug.org/tex/epsf.tex.} alpar@18: % alpar@18: \def\image#1{% alpar@18: \ifx\epsfbox\undefined alpar@18: \ifwarnednoepsf \else alpar@18: \errhelp = \noepsfhelp alpar@18: \errmessage{epsf.tex not found, images will be ignored}% alpar@18: \global\warnednoepsftrue alpar@18: \fi alpar@18: \else alpar@18: \imagexxx #1,,,,,\finish alpar@18: \fi alpar@18: } alpar@18: % alpar@18: % Arguments to @image: alpar@18: % #1 is (mandatory) image filename; we tack on .eps extension. alpar@18: % #2 is (optional) width, #3 is (optional) height. alpar@18: % #4 is (ignored optional) html alt text. alpar@18: % #5 is (ignored optional) extension. alpar@18: % #6 is just the usual extra ignored arg for parsing this stuff. alpar@18: \newif\ifimagevmode alpar@18: \def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup alpar@18: \catcode`\^^M = 5 % in case we're inside an example alpar@18: \normalturnoffactive % allow _ et al. in names alpar@18: % If the image is by itself, center it. alpar@18: \ifvmode alpar@18: \imagevmodetrue alpar@18: \nobreak\bigskip alpar@18: % Usually we'll have text after the image which will insert alpar@18: % \parskip glue, so insert it here too to equalize the space alpar@18: % above and below. alpar@18: \nobreak\vskip\parskip alpar@18: \nobreak alpar@18: \line\bgroup\hss alpar@18: \fi alpar@18: % alpar@18: % Output the image. alpar@18: \ifpdf alpar@18: \dopdfimage{#1}{#2}{#3}% alpar@18: \else alpar@18: % \epsfbox itself resets \epsf?size at each figure. alpar@18: \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi alpar@18: \setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi alpar@18: \epsfbox{#1.eps}% alpar@18: \fi alpar@18: % alpar@18: \ifimagevmode \hss \egroup \bigbreak \fi % space after the image alpar@18: \endgroup} alpar@18: alpar@18: alpar@18: \message{localization,} alpar@18: % and i18n. alpar@18: alpar@18: % @documentlanguage is usually given very early, just after alpar@18: % @setfilename. If done too late, it may not override everything alpar@18: % properly. Single argument is the language abbreviation. alpar@18: % It would be nice if we could set up a hyphenation file here. alpar@18: % alpar@18: \def\documentlanguage{\parsearg\dodocumentlanguage} alpar@18: \def\dodocumentlanguage#1{% alpar@18: \tex % read txi-??.tex file in plain TeX. alpar@18: % Read the file if it exists. alpar@18: \openin 1 txi-#1.tex alpar@18: \ifeof1 alpar@18: \errhelp = \nolanghelp alpar@18: \errmessage{Cannot read language file txi-#1.tex}% alpar@18: \let\temp = \relax alpar@18: \else alpar@18: \def\temp{\input txi-#1.tex }% alpar@18: \fi alpar@18: \temp alpar@18: \endgroup alpar@18: } alpar@18: \newhelp\nolanghelp{The given language definition file cannot be found or alpar@18: is empty. Maybe you need to install it? In the current directory alpar@18: should work if nowhere else does.} alpar@18: alpar@18: alpar@18: % @documentencoding should change something in TeX eventually, most alpar@18: % likely, but for now just recognize it. alpar@18: \let\documentencoding = \comment alpar@18: alpar@18: alpar@18: % Page size parameters. alpar@18: % alpar@18: \newdimen\defaultparindent \defaultparindent = 15pt alpar@18: alpar@18: \chapheadingskip = 15pt plus 4pt minus 2pt alpar@18: \secheadingskip = 12pt plus 3pt minus 2pt alpar@18: \subsecheadingskip = 9pt plus 2pt minus 2pt alpar@18: alpar@18: % Prevent underfull vbox error messages. alpar@18: \vbadness = 10000 alpar@18: alpar@18: % Don't be so finicky about underfull hboxes, either. alpar@18: \hbadness = 2000 alpar@18: alpar@18: % Following George Bush, just get rid of widows and orphans. alpar@18: \widowpenalty=10000 alpar@18: \clubpenalty=10000 alpar@18: alpar@18: % Use TeX 3.0's \emergencystretch to help line breaking, but if we're alpar@18: % using an old version of TeX, don't do anything. We want the amount of alpar@18: % stretch added to depend on the line length, hence the dependence on alpar@18: % \hsize. We call this whenever the paper size is set. alpar@18: % alpar@18: \def\setemergencystretch{% alpar@18: \ifx\emergencystretch\thisisundefined alpar@18: % Allow us to assign to \emergencystretch anyway. alpar@18: \def\emergencystretch{\dimen0}% alpar@18: \else alpar@18: \emergencystretch = .15\hsize alpar@18: \fi alpar@18: } alpar@18: alpar@18: % Parameters in order: 1) textheight; 2) textwidth; 3) voffset; alpar@18: % 4) hoffset; 5) binding offset; 6) topskip; 7) physical page height; 8) alpar@18: % physical page width. alpar@18: % alpar@18: % We also call \setleading{\textleading}, so the caller should define alpar@18: % \textleading. The caller should also set \parskip. alpar@18: % alpar@18: \def\internalpagesizes#1#2#3#4#5#6#7#8{% alpar@18: \voffset = #3\relax alpar@18: \topskip = #6\relax alpar@18: \splittopskip = \topskip alpar@18: % alpar@18: \vsize = #1\relax alpar@18: \advance\vsize by \topskip alpar@18: \outervsize = \vsize alpar@18: \advance\outervsize by 2\topandbottommargin alpar@18: \pageheight = \vsize alpar@18: % alpar@18: \hsize = #2\relax alpar@18: \outerhsize = \hsize alpar@18: \advance\outerhsize by 0.5in alpar@18: \pagewidth = \hsize alpar@18: % alpar@18: \normaloffset = #4\relax alpar@18: \bindingoffset = #5\relax alpar@18: % alpar@18: \ifpdf alpar@18: \pdfpageheight #7\relax alpar@18: \pdfpagewidth #8\relax alpar@18: \fi alpar@18: % alpar@18: \setleading{\textleading} alpar@18: % alpar@18: \parindent = \defaultparindent alpar@18: \setemergencystretch alpar@18: } alpar@18: alpar@18: % @letterpaper (the default). alpar@18: \def\letterpaper{{\globaldefs = 1 alpar@18: \parskip = 3pt plus 2pt minus 1pt alpar@18: \textleading = 13.2pt alpar@18: % alpar@18: % If page is nothing but text, make it come out even. alpar@18: \internalpagesizes{46\baselineskip}{6in}% alpar@18: {\voffset}{.25in}% alpar@18: {\bindingoffset}{36pt}% alpar@18: {11in}{8.5in}% alpar@18: }} alpar@18: alpar@18: % Use @smallbook to reset parameters for 7x9.5 (or so) format. alpar@18: \def\smallbook{{\globaldefs = 1 alpar@18: \parskip = 2pt plus 1pt alpar@18: \textleading = 12pt alpar@18: % alpar@18: \internalpagesizes{7.5in}{5in}% alpar@18: {\voffset}{.25in}% alpar@18: {\bindingoffset}{16pt}% alpar@18: {9.25in}{7in}% alpar@18: % alpar@18: \lispnarrowing = 0.3in alpar@18: \tolerance = 700 alpar@18: \hfuzz = 1pt alpar@18: \contentsrightmargin = 0pt alpar@18: \defbodyindent = .5cm alpar@18: }} alpar@18: alpar@18: % Use @afourpaper to print on European A4 paper. alpar@18: \def\afourpaper{{\globaldefs = 1 alpar@18: \parskip = 3pt plus 2pt minus 1pt alpar@18: \textleading = 13.2pt alpar@18: % alpar@18: % Double-side printing via postscript on Laserjet 4050 alpar@18: % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm. alpar@18: % To change the settings for a different printer or situation, adjust alpar@18: % \normaloffset until the front-side and back-side texts align. Then alpar@18: % do the same for \bindingoffset. You can set these for testing in alpar@18: % your texinfo source file like this: alpar@18: % @tex alpar@18: % \global\normaloffset = -6mm alpar@18: % \global\bindingoffset = 10mm alpar@18: % @end tex alpar@18: \internalpagesizes{51\baselineskip}{160mm} alpar@18: {\voffset}{\hoffset}% alpar@18: {\bindingoffset}{44pt}% alpar@18: {297mm}{210mm}% alpar@18: % alpar@18: \tolerance = 700 alpar@18: \hfuzz = 1pt alpar@18: \contentsrightmargin = 0pt alpar@18: \defbodyindent = 5mm alpar@18: }} alpar@18: alpar@18: % Use @afivepaper to print on European A5 paper. alpar@18: % From romildo@urano.iceb.ufop.br, 2 July 2000. alpar@18: % He also recommends making @example and @lisp be small. alpar@18: \def\afivepaper{{\globaldefs = 1 alpar@18: \parskip = 2pt plus 1pt minus 0.1pt alpar@18: \textleading = 12.5pt alpar@18: % alpar@18: \internalpagesizes{160mm}{120mm}% alpar@18: {\voffset}{\hoffset}% alpar@18: {\bindingoffset}{8pt}% alpar@18: {210mm}{148mm}% alpar@18: % alpar@18: \lispnarrowing = 0.2in alpar@18: \tolerance = 800 alpar@18: \hfuzz = 1.2pt alpar@18: \contentsrightmargin = 0pt alpar@18: \defbodyindent = 2mm alpar@18: \tableindent = 12mm alpar@18: }} alpar@18: alpar@18: % A specific text layout, 24x15cm overall, intended for A4 paper. alpar@18: \def\afourlatex{{\globaldefs = 1 alpar@18: \afourpaper alpar@18: \internalpagesizes{237mm}{150mm}% alpar@18: {\voffset}{4.6mm}% alpar@18: {\bindingoffset}{7mm}% alpar@18: {297mm}{210mm}% alpar@18: % alpar@18: % Must explicitly reset to 0 because we call \afourpaper. alpar@18: \globaldefs = 0 alpar@18: }} alpar@18: alpar@18: % Use @afourwide to print on A4 paper in landscape format. alpar@18: \def\afourwide{{\globaldefs = 1 alpar@18: \afourpaper alpar@18: \internalpagesizes{241mm}{165mm}% alpar@18: {\voffset}{-2.95mm}% alpar@18: {\bindingoffset}{7mm}% alpar@18: {297mm}{210mm}% alpar@18: \globaldefs = 0 alpar@18: }} alpar@18: alpar@18: % @pagesizes TEXTHEIGHT[,TEXTWIDTH] alpar@18: % Perhaps we should allow setting the margins, \topskip, \parskip, alpar@18: % and/or leading, also. Or perhaps we should compute them somehow. alpar@18: % alpar@18: \def\pagesizes{\parsearg\pagesizesxxx} alpar@18: \def\pagesizesxxx#1{\pagesizesyyy #1,,\finish} alpar@18: \def\pagesizesyyy#1,#2,#3\finish{{% alpar@18: \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi alpar@18: \globaldefs = 1 alpar@18: % alpar@18: \parskip = 3pt plus 2pt minus 1pt alpar@18: \setleading{\textleading}% alpar@18: % alpar@18: \dimen0 = #1 alpar@18: \advance\dimen0 by \voffset alpar@18: % alpar@18: \dimen2 = \hsize alpar@18: \advance\dimen2 by \normaloffset alpar@18: % alpar@18: \internalpagesizes{#1}{\hsize}% alpar@18: {\voffset}{\normaloffset}% alpar@18: {\bindingoffset}{44pt}% alpar@18: {\dimen0}{\dimen2}% alpar@18: }} alpar@18: alpar@18: % Set default to letter. alpar@18: % alpar@18: \letterpaper alpar@18: alpar@18: alpar@18: \message{and turning on texinfo input format.} alpar@18: alpar@18: % Define macros to output various characters with catcode for normal text. alpar@18: \catcode`\"=\other alpar@18: \catcode`\~=\other alpar@18: \catcode`\^=\other alpar@18: \catcode`\_=\other alpar@18: \catcode`\|=\other alpar@18: \catcode`\<=\other alpar@18: \catcode`\>=\other alpar@18: \catcode`\+=\other alpar@18: \catcode`\$=\other alpar@18: \def\normaldoublequote{"} alpar@18: \def\normaltilde{~} alpar@18: \def\normalcaret{^} alpar@18: \def\normalunderscore{_} alpar@18: \def\normalverticalbar{|} alpar@18: \def\normalless{<} alpar@18: \def\normalgreater{>} alpar@18: \def\normalplus{+} alpar@18: \def\normaldollar{$}%$ font-lock fix alpar@18: alpar@18: % This macro is used to make a character print one way in ttfont alpar@18: % where it can probably just be output, and another way in other fonts, alpar@18: % where something hairier probably needs to be done. alpar@18: % alpar@18: % #1 is what to print if we are indeed using \tt; #2 is what to print alpar@18: % otherwise. Since all the Computer Modern typewriter fonts have zero alpar@18: % interword stretch (and shrink), and it is reasonable to expect all alpar@18: % typewriter fonts to have this, we can check that font parameter. alpar@18: % alpar@18: \def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi} alpar@18: alpar@18: % Same as above, but check for italic font. Actually this also catches alpar@18: % non-italic slanted fonts since it is impossible to distinguish them from alpar@18: % italic fonts. But since this is only used by $ and it uses \sl anyway alpar@18: % this is not a problem. alpar@18: \def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi} alpar@18: alpar@18: % Turn off all special characters except @ alpar@18: % (and those which the user can use as if they were ordinary). alpar@18: % Most of these we simply print from the \tt font, but for some, we can alpar@18: % use math or other variants that look better in normal text. alpar@18: alpar@18: \catcode`\"=\active alpar@18: \def\activedoublequote{{\tt\char34}} alpar@18: \let"=\activedoublequote alpar@18: \catcode`\~=\active alpar@18: \def~{{\tt\char126}} alpar@18: \chardef\hat=`\^ alpar@18: \catcode`\^=\active alpar@18: \def^{{\tt \hat}} alpar@18: alpar@18: \catcode`\_=\active alpar@18: \def_{\ifusingtt\normalunderscore\_} alpar@18: % Subroutine for the previous macro. alpar@18: \def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em } alpar@18: alpar@18: \catcode`\|=\active alpar@18: \def|{{\tt\char124}} alpar@18: \chardef \less=`\< alpar@18: \catcode`\<=\active alpar@18: \def<{{\tt \less}} alpar@18: \chardef \gtr=`\> alpar@18: \catcode`\>=\active alpar@18: \def>{{\tt \gtr}} alpar@18: \catcode`\+=\active alpar@18: \def+{{\tt \char 43}} alpar@18: \catcode`\$=\active alpar@18: \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix alpar@18: alpar@18: % Set up an active definition for =, but don't enable it most of the time. alpar@18: {\catcode`\==\active alpar@18: \global\def={{\tt \char 61}}} alpar@18: alpar@18: \catcode`+=\active alpar@18: \catcode`\_=\active alpar@18: alpar@18: % If a .fmt file is being used, characters that might appear in a file alpar@18: % name cannot be active until we have parsed the command line. alpar@18: % So turn them off again, and have \everyjob (or @setfilename) turn them on. alpar@18: % \otherifyactive is called near the end of this file. alpar@18: \def\otherifyactive{\catcode`+=\other \catcode`\_=\other} alpar@18: alpar@18: \catcode`\@=0 alpar@18: alpar@18: % \rawbackslashxx outputs one backslash character in current font, alpar@18: % as in \char`\\. alpar@18: \global\chardef\rawbackslashxx=`\\ alpar@18: alpar@18: % \rawbackslash defines an active \ to do \rawbackslashxx. alpar@18: % \otherbackslash defines an active \ to be a literal `\' character with alpar@18: % catcode other. alpar@18: {\catcode`\\=\active alpar@18: @gdef@rawbackslash{@let\=@rawbackslashxx} alpar@18: @gdef@otherbackslash{@let\=@realbackslash} alpar@18: } alpar@18: alpar@18: % \realbackslash is an actual character `\' with catcode other. alpar@18: {\catcode`\\=\other @gdef@realbackslash{\}} alpar@18: alpar@18: % \normalbackslash outputs one backslash in fixed width font. alpar@18: \def\normalbackslash{{\tt\rawbackslashxx}} alpar@18: alpar@18: \catcode`\\=\active alpar@18: alpar@18: % Used sometimes to turn off (effectively) the active characters alpar@18: % even after parsing them. alpar@18: @def@turnoffactive{% alpar@18: @let"=@normaldoublequote alpar@18: @let\=@realbackslash alpar@18: @let~=@normaltilde alpar@18: @let^=@normalcaret alpar@18: @let_=@normalunderscore alpar@18: @let|=@normalverticalbar alpar@18: @let<=@normalless alpar@18: @let>=@normalgreater alpar@18: @let+=@normalplus alpar@18: @let$=@normaldollar %$ font-lock fix alpar@18: } alpar@18: alpar@18: % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of alpar@18: % the literal character `\'. (Thus, \ is not expandable when this is in alpar@18: % effect.) alpar@18: % alpar@18: @def@normalturnoffactive{@turnoffactive @let\=@normalbackslash} alpar@18: alpar@18: % Make _ and + \other characters, temporarily. alpar@18: % This is canceled by @fixbackslash. alpar@18: @otherifyactive alpar@18: alpar@18: % If a .fmt file is being used, we don't want the `\input texinfo' to show up. alpar@18: % That is what \eatinput is for; after that, the `\' should revert to printing alpar@18: % a backslash. alpar@18: % alpar@18: @gdef@eatinput input texinfo{@fixbackslash} alpar@18: @global@let\ = @eatinput alpar@18: alpar@18: % On the other hand, perhaps the file did not have a `\input texinfo'. Then alpar@18: % the first `\{ in the file would cause an error. This macro tries to fix alpar@18: % that, assuming it is called before the first `\' could plausibly occur. alpar@18: % Also back turn on active characters that might appear in the input alpar@18: % file name, in case not using a pre-dumped format. alpar@18: % alpar@18: @gdef@fixbackslash{% alpar@18: @ifx\@eatinput @let\ = @normalbackslash @fi alpar@18: @catcode`+=@active alpar@18: @catcode`@_=@active alpar@18: } alpar@18: alpar@18: % Say @foo, not \foo, in error messages. alpar@18: @escapechar = `@@ alpar@18: alpar@18: % These look ok in all fonts, so just make them not special. alpar@18: @catcode`@& = @other alpar@18: @catcode`@# = @other alpar@18: @catcode`@% = @other alpar@18: alpar@18: @c Set initial fonts. alpar@18: @textfonts alpar@18: @rm alpar@18: alpar@18: alpar@18: @c Local variables: alpar@18: @c eval: (add-hook 'write-file-hooks 'time-stamp) alpar@18: @c page-delimiter: "^\\\\message" alpar@18: @c time-stamp-start: "def\\\\texinfoversion{" alpar@18: @c time-stamp-format: "%:y-%02m-%02d.%02H" alpar@18: @c time-stamp-end: "}" alpar@18: @c End: