169626Sru% texinfo.tex -- TeX macros to handle Texinfo files. 269626Sru% 369626Sru% Load plain if necessary, i.e., if running under initex. 469626Sru\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi 569626Sru% 6151497Sru\def\texinfoversion{2004-11-25.16} 769626Sru% 8114402Sru% Copyright (C) 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995, 9151497Sru% 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software 10151497Sru% Foundation, Inc. 1169626Sru% 1269626Sru% This texinfo.tex file is free software; you can redistribute it and/or 1369626Sru% modify it under the terms of the GNU General Public License as 1469626Sru% published by the Free Software Foundation; either version 2, or (at 1569626Sru% your option) any later version. 1669626Sru% 1769626Sru% This texinfo.tex file is distributed in the hope that it will be 1869626Sru% useful, but WITHOUT ANY WARRANTY; without even the implied warranty 1969626Sru% of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 2069626Sru% General Public License for more details. 2169626Sru% 2269626Sru% You should have received a copy of the GNU General Public License 2369626Sru% along with this texinfo.tex file; see the file COPYING. If not, write 24151497Sru% to the Free Software Foundation, Inc., 51 Franklin St - Fifth Floor, 25151497Sru% Boston, MA 02110-1301, USA. 2669626Sru% 27151497Sru% As a special exception, when this file is read by TeX when processing 28151497Sru% a Texinfo source document, you may use the result without 29151497Sru% restriction. (This has been our intent since Texinfo was invented.) 3069626Sru% 3169626Sru% Please try the latest version of texinfo.tex before submitting bug 3269626Sru% reports; you can get the latest version from: 33151497Sru% http://www.gnu.org/software/texinfo/ (the Texinfo home page), or 34104862Sru% ftp://tug.org/tex/texinfo.tex 35151497Sru% (and all CTAN mirrors, see http://www.ctan.org). 36151497Sru% The texinfo.tex in any given distribution could well be out 3769626Sru% of date, so if that's what you're using, please check. 38151497Sru% 3969626Sru% Send bug reports to bug-texinfo@gnu.org. Please include including a 4069626Sru% complete document in each bug report with which we can reproduce the 4169626Sru% problem. Patches are, of course, greatly appreciated. 4269626Sru% 4369626Sru% To process a Texinfo manual with TeX, it's most reliable to use the 4469626Sru% texi2dvi shell script that comes with the distribution. For a simple 4569626Sru% manual foo.texi, however, you can get away with this: 4669626Sru% tex foo.texi 4769626Sru% texindex foo.?? 4869626Sru% tex foo.texi 4969626Sru% tex foo.texi 50104862Sru% dvips foo.dvi -o # or whatever; this makes foo.ps. 51104862Sru% The extra TeX runs get the cross-reference information correct. 5269626Sru% Sometimes one run after texindex suffices, and sometimes you need more 5369626Sru% than two; texi2dvi does it as many times as necessary. 54151497Sru% 55114402Sru% It is possible to adapt texinfo.tex for other languages, to some 56114402Sru% extent. You can get the existing language-specific files from the 57114402Sru% full Texinfo distribution. 58151497Sru% 59151497Sru% The GNU Texinfo home page is http://www.gnu.org/software/texinfo. 6069626Sru 61151497Sru 6269626Sru\message{Loading texinfo [version \texinfoversion]:} 6369626Sru 6469626Sru% If in a .fmt file, print the version number 6569626Sru% and turn on active characters that we couldn't do earlier because 6669626Sru% they might have appeared in the input file name. 6769626Sru\everyjob{\message{[Texinfo version \texinfoversion]}% 6869626Sru \catcode`+=\active \catcode`\_=\active} 6969626Sru 70114402Sru\message{Basics,} 71114402Sru\chardef\other=12 72114402Sru 73151497Sru% We never want plain's \outer definition of \+ in Texinfo. 74114402Sru% For @tex, we can use \tabalign. 75114402Sru\let\+ = \relax 76114402Sru 77151497Sru% Save some plain tex macros whose names we will redefine. 7869626Sru\let\ptexb=\b 7969626Sru\let\ptexbullet=\bullet 8069626Sru\let\ptexc=\c 8169626Sru\let\ptexcomma=\, 8269626Sru\let\ptexdot=\. 8369626Sru\let\ptexdots=\dots 8469626Sru\let\ptexend=\end 8569626Sru\let\ptexequiv=\equiv 8669626Sru\let\ptexexclam=\! 87151497Sru\let\ptexfootnote=\footnote 88114402Sru\let\ptexgtr=> 89114402Sru\let\ptexhat=^ 9069626Sru\let\ptexi=\i 91151497Sru\let\ptexindent=\indent 92151497Sru\let\ptexinsert=\insert 9369626Sru\let\ptexlbrace=\{ 94114402Sru\let\ptexless=< 95151497Sru\let\ptexnewwrite\newwrite 96151497Sru\let\ptexnoindent=\noindent 97114402Sru\let\ptexplus=+ 9869626Sru\let\ptexrbrace=\} 99151497Sru\let\ptexslash=\/ 10069626Sru\let\ptexstar=\* 10169626Sru\let\ptext=\t 10269626Sru 10369626Sru% If this character appears in an error message or help string, it 10469626Sru% starts a new line in the output. 10569626Sru\newlinechar = `^^J 10669626Sru 107151497Sru% Use TeX 3.0's \inputlineno to get the line number, for better error 108151497Sru% messages, but if we're using an old version of TeX, don't do anything. 109151497Sru% 110151497Sru\ifx\inputlineno\thisisundefined 111151497Sru \let\linenumber = \empty % Pre-3.0. 112151497Sru\else 113151497Sru \def\linenumber{l.\the\inputlineno:\space} 114151497Sru\fi 115151497Sru 11669626Sru% Set up fixed words for English if not already set. 11769626Sru\ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi 11869626Sru\ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi 11969626Sru\ifx\putwordfile\undefined \gdef\putwordfile{file}\fi 12069626Sru\ifx\putwordin\undefined \gdef\putwordin{in}\fi 12169626Sru\ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi 12269626Sru\ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi 12369626Sru\ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi 12469626Sru\ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi 12569626Sru\ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi 12669626Sru\ifx\putwordNoTitle\undefined \gdef\putwordNoTitle{No Title}\fi 12769626Sru\ifx\putwordof\undefined \gdef\putwordof{of}\fi 12869626Sru\ifx\putwordon\undefined \gdef\putwordon{on}\fi 12969626Sru\ifx\putwordpage\undefined \gdef\putwordpage{page}\fi 13069626Sru\ifx\putwordsection\undefined \gdef\putwordsection{section}\fi 13169626Sru\ifx\putwordSection\undefined \gdef\putwordSection{Section}\fi 13269626Sru\ifx\putwordsee\undefined \gdef\putwordsee{see}\fi 13369626Sru\ifx\putwordSee\undefined \gdef\putwordSee{See}\fi 13469626Sru\ifx\putwordShortTOC\undefined \gdef\putwordShortTOC{Short Contents}\fi 13569626Sru\ifx\putwordTOC\undefined \gdef\putwordTOC{Table of Contents}\fi 13669626Sru% 13769626Sru\ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi 13869626Sru\ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi 13969626Sru\ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi 14069626Sru\ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi 14169626Sru\ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi 14269626Sru\ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi 14369626Sru\ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi 14469626Sru\ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi 14569626Sru\ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi 14669626Sru\ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi 14769626Sru\ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi 14869626Sru\ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi 14969626Sru% 15069626Sru\ifx\putwordDefmac\undefined \gdef\putwordDefmac{Macro}\fi 15169626Sru\ifx\putwordDefspec\undefined \gdef\putwordDefspec{Special Form}\fi 15269626Sru\ifx\putwordDefvar\undefined \gdef\putwordDefvar{Variable}\fi 15369626Sru\ifx\putwordDefopt\undefined \gdef\putwordDefopt{User Option}\fi 15469626Sru\ifx\putwordDeffunc\undefined \gdef\putwordDeffunc{Function}\fi 15569626Sru 156114402Sru% In some macros, we cannot use the `\? notation---the left quote is 157114402Sru% in some cases the escape char. 158114402Sru\chardef\colonChar = `\: 159114402Sru\chardef\commaChar = `\, 160114402Sru\chardef\dotChar = `\. 161114402Sru\chardef\exclamChar= `\! 162114402Sru\chardef\questChar = `\? 163114402Sru\chardef\semiChar = `\; 164114402Sru\chardef\underChar = `\_ 165114402Sru 166151497Sru\chardef\spaceChar = `\ % 167151497Sru\chardef\spacecat = 10 168151497Sru\def\spaceisspace{\catcode\spaceChar=\spacecat} 169151497Sru 17069626Sru% Ignore a token. 17169626Sru% 17269626Sru\def\gobble#1{} 17369626Sru 174151497Sru% The following is used inside several \edef's. 175151497Sru\def\makecsname#1{\expandafter\noexpand\csname#1\endcsname} 176114402Sru 177114402Sru% Hyphenation fixes. 178151497Sru\hyphenation{ 179151497Sru Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script 180151497Sru ap-pen-dix bit-map bit-maps 181151497Sru data-base data-bases eshell fall-ing half-way long-est man-u-script 182151497Sru man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm 183151497Sru par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces 184151497Sru spell-ing spell-ings 185151497Sru stand-alone strong-est time-stamp time-stamps which-ever white-space 186151497Sru wide-spread wrap-around 187151497Sru} 18869626Sru 18969626Sru% Margin to add to right of even pages, to left of odd pages. 190114402Sru\newdimen\bindingoffset 191114402Sru\newdimen\normaloffset 19269626Sru\newdimen\pagewidth \newdimen\pageheight 19369626Sru 194151497Sru% For a final copy, take out the rectangles 195151497Sru% that mark overfull boxes (in case you have decided 196151497Sru% that the text looks ok even though it passes the margin). 197151497Sru% 198151497Sru\def\finalout{\overfullrule=0pt} 199151497Sru 200151497Sru% @| inserts a changebar to the left of the current line. It should 201151497Sru% surround any changed text. This approach does *not* work if the 202151497Sru% change spans more than two lines of output. To handle that, we would 203151497Sru% have adopt a much more difficult approach (putting marks into the main 204151497Sru% vertical list for the beginning and end of each change). 205151497Sru% 206151497Sru\def\|{% 207151497Sru % \vadjust can only be used in horizontal mode. 208151497Sru \leavevmode 209151497Sru % 210151497Sru % Append this vertical mode material after the current line in the output. 211151497Sru \vadjust{% 212151497Sru % We want to insert a rule with the height and depth of the current 213151497Sru % leading; that is exactly what \strutbox is supposed to record. 214151497Sru \vskip-\baselineskip 215151497Sru % 216151497Sru % \vadjust-items are inserted at the left edge of the type. So 217151497Sru % the \llap here moves out into the left-hand margin. 218151497Sru \llap{% 219151497Sru % 220151497Sru % For a thicker or thinner bar, change the `1pt'. 221151497Sru \vrule height\baselineskip width1pt 222151497Sru % 223151497Sru % This is the space between the bar and the text. 224151497Sru \hskip 12pt 225151497Sru }% 226151497Sru }% 227151497Sru} 228151497Sru 22969626Sru% Sometimes it is convenient to have everything in the transcript file 23069626Sru% and nothing on the terminal. We don't just call \tracingall here, 231114402Sru% since that produces some useless output on the terminal. We also make 232114402Sru% some effort to order the tracing commands to reduce output in the log 233114402Sru% file; cf. trace.sty in LaTeX. 23469626Sru% 23569626Sru\def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}% 236114402Sru\def\loggingall{% 237114402Sru \tracingstats2 238114402Sru \tracingpages1 239114402Sru \tracinglostchars2 % 2 gives us more in etex 240114402Sru \tracingparagraphs1 241114402Sru \tracingoutput1 242114402Sru \tracingmacros2 243114402Sru \tracingrestores1 244114402Sru \showboxbreadth\maxdimen \showboxdepth\maxdimen 245114402Sru \ifx\eTeXversion\undefined\else % etex gives us more logging 246114402Sru \tracingscantokens1 247114402Sru \tracingifs1 248114402Sru \tracinggroups1 249114402Sru \tracingnesting2 250114402Sru \tracingassigns1 251114402Sru \fi 252114402Sru \tracingcommands3 % 3 gives us more in etex 253151497Sru \errorcontextlines16 25469626Sru}% 25569626Sru 256104862Sru% add check for \lastpenalty to plain's definitions. If the last thing 257104862Sru% we did was a \nobreak, we don't want to insert more space. 258151497Sru% 259104862Sru\def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount 260104862Sru \removelastskip\penalty-50\smallskip\fi\fi} 261104862Sru\def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount 262104862Sru \removelastskip\penalty-100\medskip\fi\fi} 263104862Sru\def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount 264104862Sru \removelastskip\penalty-200\bigskip\fi\fi} 265104862Sru 26669626Sru% For @cropmarks command. 26769626Sru% Do @cropmarks to get crop marks. 26869626Sru% 26969626Sru\newif\ifcropmarks 27069626Sru\let\cropmarks = \cropmarkstrue 27169626Sru% 27269626Sru% Dimensions to add cropmarks at corners. 27369626Sru% Added by P. A. MacKay, 12 Nov. 1986 27469626Sru% 27569626Sru\newdimen\outerhsize \newdimen\outervsize % set by the paper size routines 27669626Sru\newdimen\cornerlong \cornerlong=1pc 27769626Sru\newdimen\cornerthick \cornerthick=.3pt 27869626Sru\newdimen\topandbottommargin \topandbottommargin=.75in 27969626Sru 28069626Sru% Main output routine. 28169626Sru\chardef\PAGE = 255 28269626Sru\output = {\onepageout{\pagecontents\PAGE}} 28369626Sru 28469626Sru\newbox\headlinebox 28569626Sru\newbox\footlinebox 28669626Sru 28769626Sru% \onepageout takes a vbox as an argument. Note that \pagecontents 28869626Sru% does insertions, but you have to call it yourself. 28969626Sru\def\onepageout#1{% 29069626Sru \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi 29169626Sru % 29269626Sru \ifodd\pageno \advance\hoffset by \bindingoffset 29369626Sru \else \advance\hoffset by -\bindingoffset\fi 29469626Sru % 29569626Sru % Do this outside of the \shipout so @code etc. will be expanded in 29669626Sru % the headline as they should be, not taken literally (outputting ''code). 29769626Sru \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}% 29869626Sru \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}% 29969626Sru % 30069626Sru {% 30169626Sru % Have to do this stuff outside the \shipout because we want it to 30269626Sru % take effect in \write's, yet the group defined by the \vbox ends 30369626Sru % before the \shipout runs. 30469626Sru % 30569626Sru \escapechar = `\\ % use backslash in output files. 30669626Sru \indexdummies % don't expand commands in the output. 30769626Sru \normalturnoffactive % \ in index entries must not stay \, e.g., if 30869626Sru % the page break happens to be in the middle of an example. 30969626Sru \shipout\vbox{% 31069626Sru % Do this early so pdf references go to the beginning of the page. 311151497Sru \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi 31269626Sru % 31369626Sru \ifcropmarks \vbox to \outervsize\bgroup 31469626Sru \hsize = \outerhsize 31569626Sru \vskip-\topandbottommargin 31669626Sru \vtop to0pt{% 31769626Sru \line{\ewtop\hfil\ewtop}% 31869626Sru \nointerlineskip 31969626Sru \line{% 32069626Sru \vbox{\moveleft\cornerthick\nstop}% 32169626Sru \hfill 32269626Sru \vbox{\moveright\cornerthick\nstop}% 32369626Sru }% 32469626Sru \vss}% 32569626Sru \vskip\topandbottommargin 32669626Sru \line\bgroup 32769626Sru \hfil % center the page within the outer (page) hsize. 32869626Sru \ifodd\pageno\hskip\bindingoffset\fi 32969626Sru \vbox\bgroup 33069626Sru \fi 33169626Sru % 33269626Sru \unvbox\headlinebox 33369626Sru \pagebody{#1}% 33469626Sru \ifdim\ht\footlinebox > 0pt 33569626Sru % Only leave this space if the footline is nonempty. 33669626Sru % (We lessened \vsize for it in \oddfootingxxx.) 33769626Sru % The \baselineskip=24pt in plain's \makefootline has no effect. 33869626Sru \vskip 2\baselineskip 33969626Sru \unvbox\footlinebox 34069626Sru \fi 34169626Sru % 34269626Sru \ifcropmarks 34369626Sru \egroup % end of \vbox\bgroup 34469626Sru \hfil\egroup % end of (centering) \line\bgroup 34569626Sru \vskip\topandbottommargin plus1fill minus1fill 34669626Sru \boxmaxdepth = \cornerthick 34769626Sru \vbox to0pt{\vss 34869626Sru \line{% 34969626Sru \vbox{\moveleft\cornerthick\nsbot}% 35069626Sru \hfill 35169626Sru \vbox{\moveright\cornerthick\nsbot}% 35269626Sru }% 35369626Sru \nointerlineskip 35469626Sru \line{\ewbot\hfil\ewbot}% 35569626Sru }% 35669626Sru \egroup % \vbox from first cropmarks clause 35769626Sru \fi 35869626Sru }% end of \shipout\vbox 359114402Sru }% end of group with \normalturnoffactive 36069626Sru \advancepageno 36169626Sru \ifnum\outputpenalty>-20000 \else\dosupereject\fi 36269626Sru} 36369626Sru 36469626Sru\newinsert\margin \dimen\margin=\maxdimen 36569626Sru 36669626Sru\def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}} 36769626Sru{\catcode`\@ =11 36869626Sru\gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi 36969626Sru% marginal hacks, juha@viisa.uucp (Juha Takala) 37069626Sru\ifvoid\margin\else % marginal info is present 37169626Sru \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi 37269626Sru\dimen@=\dp#1 \unvbox#1 37369626Sru\ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi 37469626Sru\ifr@ggedbottom \kern-\dimen@ \vfil \fi} 37569626Sru} 37669626Sru 37769626Sru% Here are the rules for the cropmarks. Note that they are 37869626Sru% offset so that the space between them is truly \outerhsize or \outervsize 37969626Sru% (P. A. MacKay, 12 November, 1986) 38069626Sru% 38169626Sru\def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong} 38269626Sru\def\nstop{\vbox 38369626Sru {\hrule height\cornerthick depth\cornerlong width\cornerthick}} 38469626Sru\def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong} 38569626Sru\def\nsbot{\vbox 38669626Sru {\hrule height\cornerlong depth\cornerthick width\cornerthick}} 38769626Sru 38869626Sru% Parse an argument, then pass it to #1. The argument is the rest of 38969626Sru% the input line (except we remove a trailing comment). #1 should be a 39069626Sru% macro which expects an ordinary undelimited TeX argument. 39169626Sru% 392151497Sru\def\parsearg{\parseargusing{}} 393151497Sru\def\parseargusing#1#2{% 394151497Sru \def\next{#2}% 39569626Sru \begingroup 39669626Sru \obeylines 397151497Sru \spaceisspace 398151497Sru #1% 399151497Sru \parseargline\empty% Insert the \empty token, see \finishparsearg below. 40069626Sru} 40169626Sru 40269626Sru{\obeylines % 40369626Sru \gdef\parseargline#1^^M{% 40469626Sru \endgroup % End of the group started in \parsearg. 405151497Sru \argremovecomment #1\comment\ArgTerm% 40669626Sru }% 40769626Sru} 40869626Sru 409151497Sru% First remove any @comment, then any @c comment. 410151497Sru\def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm} 411151497Sru\def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm} 41269626Sru 413151497Sru% Each occurence of `\^^M' or `<space>\^^M' is replaced by a single space. 414151497Sru% 415151497Sru% \argremovec might leave us with trailing space, e.g., 41669626Sru% @end itemize @c foo 417151497Sru% This space token undergoes the same procedure and is eventually removed 418151497Sru% by \finishparsearg. 41969626Sru% 420151497Sru\def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M} 421151497Sru\def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M} 422151497Sru\def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{% 423151497Sru \def\temp{#3}% 424151497Sru \ifx\temp\empty 425151497Sru % We cannot use \next here, as it holds the macro to run; 426151497Sru % thus we reuse \temp. 427151497Sru \let\temp\finishparsearg 428151497Sru \else 429151497Sru \let\temp\argcheckspaces 430151497Sru \fi 431151497Sru % Put the space token in: 432151497Sru \temp#1 #3\ArgTerm 433151497Sru} 434151497Sru 435151497Sru% If a _delimited_ argument is enclosed in braces, they get stripped; so 436151497Sru% to get _exactly_ the rest of the line, we had to prevent such situation. 437151497Sru% We prepended an \empty token at the very beginning and we expand it now, 438151497Sru% just before passing the control to \next. 439151497Sru% (Similarily, we have to think about #3 of \argcheckspacesY above: it is 440151497Sru% either the null string, or it ends with \^^M---thus there is no danger 441151497Sru% that a pair of braces would be stripped. 44269626Sru% 443151497Sru% But first, we have to remove the trailing space token. 444151497Sru% 445151497Sru\def\finishparsearg#1 \ArgTerm{\expandafter\next\expandafter{#1}} 446151497Sru 447151497Sru% \parseargdef\foo{...} 448151497Sru% is roughly equivalent to 449151497Sru% \def\foo{\parsearg\Xfoo} 450151497Sru% \def\Xfoo#1{...} 451151497Sru% 452151497Sru% Actually, I use \csname\string\foo\endcsname, ie. \\foo, as it is my 453151497Sru% favourite TeX trick. --kasal, 16nov03 454151497Sru 455151497Sru\def\parseargdef#1{% 456151497Sru \expandafter \doparseargdef \csname\string#1\endcsname #1% 45769626Sru} 458151497Sru\def\doparseargdef#1#2{% 459151497Sru \def#2{\parsearg#1}% 460151497Sru \def#1##1% 461151497Sru} 46269626Sru 463151497Sru% Several utility definitions with active space: 464151497Sru{ 46569626Sru \obeyspaces 466151497Sru \gdef\obeyedspace{ } 46769626Sru 468151497Sru % Make each space character in the input produce a normal interword 469151497Sru % space in the output. Don't allow a line break at this space, as this 470151497Sru % is used only in environments like @example, where each line of input 471151497Sru % should produce a line of output anyway. 472151497Sru % 473151497Sru \gdef\sepspaces{\obeyspaces\let =\tie} 47469626Sru 475151497Sru % If an index command is used in an @example environment, any spaces 476151497Sru % therein should become regular spaces in the raw index file, not the 477151497Sru % expansion of \tie (\leavevmode \penalty \@M \ ). 478151497Sru \gdef\unsepspaces{\let =\space} 479151497Sru} 480151497Sru 481151497Sru 48269626Sru\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next} 48369626Sru 484151497Sru% Define the framework for environments in texinfo.tex. It's used like this: 485151497Sru% 486151497Sru% \envdef\foo{...} 487151497Sru% \def\Efoo{...} 488151497Sru% 489151497Sru% It's the responsibility of \envdef to insert \begingroup before the 490151497Sru% actual body; @end closes the group after calling \Efoo. \envdef also 491151497Sru% defines \thisenv, so the current environment is known; @end checks 492151497Sru% whether the environment name matches. The \checkenv macro can also be 493151497Sru% used to check whether the current environment is the one expected. 494151497Sru% 495151497Sru% Non-false conditionals (@iftex, @ifset) don't fit into this, so they 496151497Sru% are not treated as enviroments; they don't open a group. (The 497151497Sru% implementation of @end takes care not to call \endgroup in this 498151497Sru% special case.) 49969626Sru 50069626Sru 501151497Sru% At runtime, environments start with this: 502151497Sru\def\startenvironment#1{\begingroup\def\thisenv{#1}} 503151497Sru% initialize 504151497Sru\let\thisenv\empty 50569626Sru 506151497Sru% ... but they get defined via ``\envdef\foo{...}'': 507151497Sru\long\def\envdef#1#2{\def#1{\startenvironment#1#2}} 508151497Sru\def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}} 50969626Sru 510151497Sru% Check whether we're in the right environment: 511151497Sru\def\checkenv#1{% 512151497Sru \def\temp{#1}% 513151497Sru \ifx\thisenv\temp 51469626Sru \else 515151497Sru \badenverr 51669626Sru \fi 51769626Sru} 51869626Sru 519151497Sru% Evironment mismatch, #1 expected: 520151497Sru\def\badenverr{% 52169626Sru \errhelp = \EMsimple 522151497Sru \errmessage{This command can appear only \inenvironment\temp, 523151497Sru not \inenvironment\thisenv}% 52469626Sru} 525151497Sru\def\inenvironment#1{% 526151497Sru \ifx#1\empty 527151497Sru out of any environment% 528151497Sru \else 529151497Sru in environment \expandafter\string#1% 530151497Sru \fi 531151497Sru} 53269626Sru 533151497Sru% @end foo executes the definition of \Efoo. 534151497Sru% But first, it executes a specialized version of \checkenv 53569626Sru% 536151497Sru\parseargdef\end{% 537151497Sru \if 1\csname iscond.#1\endcsname 538151497Sru \else 539151497Sru % The general wording of \badenverr may not be ideal, but... --kasal, 06nov03 540151497Sru \expandafter\checkenv\csname#1\endcsname 541151497Sru \csname E#1\endcsname 542151497Sru \endgroup 543151497Sru \fi 54469626Sru} 54569626Sru 546151497Sru\newhelp\EMsimple{Press RETURN to continue.} 54769626Sru 548151497Sru 54969626Sru%% Simple single-character @ commands 55069626Sru 55169626Sru% @@ prints an @ 55269626Sru% Kludge this until the fonts are right (grr). 55369626Sru\def\@{{\tt\char64}} 55469626Sru 55569626Sru% This is turned off because it was never documented 55669626Sru% and you can use @w{...} around a quote to suppress ligatures. 55769626Sru%% Define @` and @' to be the same as ` and ' 55869626Sru%% but suppressing ligatures. 55969626Sru%\def\`{{`}} 56069626Sru%\def\'{{'}} 56169626Sru 56269626Sru% Used to generate quoted braces. 56369626Sru\def\mylbrace {{\tt\char123}} 56469626Sru\def\myrbrace {{\tt\char125}} 56569626Sru\let\{=\mylbrace 56669626Sru\let\}=\myrbrace 56769626Sru\begingroup 568114402Sru % Definitions to produce \{ and \} commands for indices, 569114402Sru % and @{ and @} for the aux file. 570114402Sru \catcode`\{ = \other \catcode`\} = \other 57169626Sru \catcode`\[ = 1 \catcode`\] = 2 572114402Sru \catcode`\! = 0 \catcode`\\ = \other 573114402Sru !gdef!lbracecmd[\{]% 574114402Sru !gdef!rbracecmd[\}]% 575114402Sru !gdef!lbraceatcmd[@{]% 576114402Sru !gdef!rbraceatcmd[@}]% 577114402Sru!endgroup 57869626Sru 579151497Sru% @comma{} to avoid , parsing problems. 580151497Sru\let\comma = , 581151497Sru 58269626Sru% Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent 583114402Sru% Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H. 58469626Sru\let\, = \c 58569626Sru\let\dotaccent = \. 58669626Sru\def\ringaccent#1{{\accent23 #1}} 58769626Sru\let\tieaccent = \t 58869626Sru\let\ubaraccent = \b 58969626Sru\let\udotaccent = \d 59069626Sru 591151497Sru% Other special characters: @questiondown @exclamdown @ordf @ordm 592114402Sru% Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss. 59369626Sru\def\questiondown{?`} 59469626Sru\def\exclamdown{!`} 595151497Sru\def\ordf{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{a}}} 596151497Sru\def\ordm{\leavevmode\raise1ex\hbox{\selectfonts\lllsize \underbar{o}}} 59769626Sru 59869626Sru% Dotless i and dotless j, used for accents. 59969626Sru\def\imacro{i} 60069626Sru\def\jmacro{j} 60169626Sru\def\dotless#1{% 60269626Sru \def\temp{#1}% 60369626Sru \ifx\temp\imacro \ptexi 60469626Sru \else\ifx\temp\jmacro \j 60569626Sru \else \errmessage{@dotless can be used only with i or j}% 60669626Sru \fi\fi 60769626Sru} 60869626Sru 609151497Sru% The \TeX{} logo, as in plain, but resetting the spacing so that a 610151497Sru% period following counts as ending a sentence. (Idea found in latex.) 611151497Sru% 612151497Sru\edef\TeX{\TeX \spacefactor=1000 } 613151497Sru 614151497Sru% @LaTeX{} logo. Not quite the same results as the definition in 615151497Sru% latex.ltx, since we use a different font for the raised A; it's most 616151497Sru% convenient for us to use an explicitly smaller font, rather than using 617151497Sru% the \scriptstyle font (since we don't reset \scriptstyle and 618151497Sru% \scriptscriptstyle). 619151497Sru% 620151497Sru\def\LaTeX{% 621151497Sru L\kern-.36em 622151497Sru {\setbox0=\hbox{T}% 623151497Sru \vbox to \ht0{\hbox{\selectfonts\lllsize A}\vss}}% 624151497Sru \kern-.15em 625151497Sru \TeX 626151497Sru} 627151497Sru 62869626Sru% Be sure we're in horizontal mode when doing a tie, since we make space 62969626Sru% equivalent to this in @example-like environments. Otherwise, a space 63069626Sru% at the beginning of a line will start with \penalty -- and 63169626Sru% since \penalty is valid in vertical mode, we'd end up putting the 63269626Sru% penalty on the vertical list instead of in the new paragraph. 63369626Sru{\catcode`@ = 11 63469626Sru % Avoid using \@M directly, because that causes trouble 63569626Sru % if the definition is written into an index file. 63669626Sru \global\let\tiepenalty = \@M 63769626Sru \gdef\tie{\leavevmode\penalty\tiepenalty\ } 63869626Sru} 63969626Sru 64069626Sru% @: forces normal size whitespace following. 64169626Sru\def\:{\spacefactor=1000 } 64269626Sru 64369626Sru% @* forces a line break. 64469626Sru\def\*{\hfil\break\hbox{}\ignorespaces} 64569626Sru 646151497Sru% @/ allows a line break. 647151497Sru\let\/=\allowbreak 648151497Sru 64969626Sru% @. is an end-of-sentence period. 65069626Sru\def\.{.\spacefactor=3000 } 65169626Sru 65269626Sru% @! is an end-of-sentence bang. 65369626Sru\def\!{!\spacefactor=3000 } 65469626Sru 65569626Sru% @? is an end-of-sentence query. 65669626Sru\def\?{?\spacefactor=3000 } 65769626Sru 65869626Sru% @w prevents a word break. Without the \leavevmode, @w at the 65969626Sru% beginning of a paragraph, when TeX is still in vertical mode, would 66069626Sru% produce a whole line of output instead of starting the paragraph. 66169626Sru\def\w#1{\leavevmode\hbox{#1}} 66269626Sru 66369626Sru% @group ... @end group forces ... to be all on one page, by enclosing 66469626Sru% it in a TeX vbox. We use \vtop instead of \vbox to construct the box 66569626Sru% to keep its height that of a normal line. According to the rules for 66669626Sru% \topskip (p.114 of the TeXbook), the glue inserted is 66769626Sru% max (\topskip - \ht (first item), 0). If that height is large, 66869626Sru% therefore, no glue is inserted, and the space between the headline and 66969626Sru% the text is small, which looks bad. 67069626Sru% 671114402Sru% Another complication is that the group might be very large. This can 672114402Sru% cause the glue on the previous page to be unduly stretched, because it 673114402Sru% does not have much material. In this case, it's better to add an 674114402Sru% explicit \vfill so that the extra space is at the bottom. The 675114402Sru% threshold for doing this is if the group is more than \vfilllimit 676114402Sru% percent of a page (\vfilllimit can be changed inside of @tex). 677151497Sru% 678114402Sru\newbox\groupbox 679114402Sru\def\vfilllimit{0.7} 680114402Sru% 681151497Sru\envdef\group{% 682151497Sru \ifnum\catcode`\^^M=\active \else 68369626Sru \errhelp = \groupinvalidhelp 68469626Sru \errmessage{@group invalid in context where filling is enabled}% 68569626Sru \fi 686151497Sru \startsavinginserts 68769626Sru % 688114402Sru \setbox\groupbox = \vtop\bgroup 68969626Sru % Do @comment since we are called inside an environment such as 69069626Sru % @example, where each end-of-line in the input causes an 69169626Sru % end-of-line in the output. We don't want the end-of-line after 69269626Sru % the `@group' to put extra space in the output. Since @group 69369626Sru % should appear on a line by itself (according to the Texinfo 69469626Sru % manual), we don't worry about eating any user text. 69569626Sru \comment 69669626Sru} 69769626Sru% 698151497Sru% The \vtop produces a box with normal height and large depth; thus, TeX puts 699151497Sru% \baselineskip glue before it, and (when the next line of text is done) 700151497Sru% \lineskip glue after it. Thus, space below is not quite equal to space 701151497Sru% above. But it's pretty close. 702151497Sru\def\Egroup{% 703151497Sru % To get correct interline space between the last line of the group 704151497Sru % and the first line afterwards, we have to propagate \prevdepth. 705151497Sru \endgraf % Not \par, as it may have been set to \lisppar. 706151497Sru \global\dimen1 = \prevdepth 707151497Sru \egroup % End the \vtop. 708151497Sru % \dimen0 is the vertical size of the group's box. 709151497Sru \dimen0 = \ht\groupbox \advance\dimen0 by \dp\groupbox 710151497Sru % \dimen2 is how much space is left on the page (more or less). 711151497Sru \dimen2 = \pageheight \advance\dimen2 by -\pagetotal 712151497Sru % if the group doesn't fit on the current page, and it's a big big 713151497Sru % group, force a page break. 714151497Sru \ifdim \dimen0 > \dimen2 715151497Sru \ifdim \pagetotal < \vfilllimit\pageheight 716151497Sru \page 717151497Sru \fi 718151497Sru \fi 719151497Sru \box\groupbox 720151497Sru \prevdepth = \dimen1 721151497Sru \checkinserts 722151497Sru} 723151497Sru% 72469626Sru% TeX puts in an \escapechar (i.e., `@') at the beginning of the help 72569626Sru% message, so this ends up printing `@group can only ...'. 72669626Sru% 72769626Sru\newhelp\groupinvalidhelp{% 72869626Srugroup can only be used in environments such as @example,^^J% 72969626Sruwhere each line of input produces a line of output.} 73069626Sru 73169626Sru% @need space-in-mils 73269626Sru% forces a page break if there is not space-in-mils remaining. 73369626Sru 73469626Sru\newdimen\mil \mil=0.001in 73569626Sru 73669626Sru% Old definition--didn't work. 737151497Sru%\parseargdef\need{\par % 73869626Sru%% This method tries to make TeX break the page naturally 73969626Sru%% if the depth of the box does not fit. 74069626Sru%{\baselineskip=0pt% 74169626Sru%\vtop to #1\mil{\vfil}\kern -#1\mil\nobreak 74269626Sru%\prevdepth=-1000pt 74369626Sru%}} 74469626Sru 745151497Sru\parseargdef\need{% 74669626Sru % Ensure vertical mode, so we don't make a big box in the middle of a 74769626Sru % paragraph. 74869626Sru \par 74969626Sru % 75069626Sru % If the @need value is less than one line space, it's useless. 75169626Sru \dimen0 = #1\mil 75269626Sru \dimen2 = \ht\strutbox 75369626Sru \advance\dimen2 by \dp\strutbox 75469626Sru \ifdim\dimen0 > \dimen2 75569626Sru % 75669626Sru % Do a \strut just to make the height of this box be normal, so the 75769626Sru % normal leading is inserted relative to the preceding line. 75869626Sru % And a page break here is fine. 75969626Sru \vtop to #1\mil{\strut\vfil}% 76069626Sru % 76169626Sru % TeX does not even consider page breaks if a penalty added to the 76269626Sru % main vertical list is 10000 or more. But in order to see if the 76369626Sru % empty box we just added fits on the page, we must make it consider 76469626Sru % page breaks. On the other hand, we don't want to actually break the 76569626Sru % page after the empty box. So we use a penalty of 9999. 76669626Sru % 76769626Sru % There is an extremely small chance that TeX will actually break the 76869626Sru % page at this \penalty, if there are no other feasible breakpoints in 76969626Sru % sight. (If the user is using lots of big @group commands, which 77069626Sru % almost-but-not-quite fill up a page, TeX will have a hard time doing 77169626Sru % good page breaking, for example.) However, I could not construct an 77269626Sru % example where a page broke at this \penalty; if it happens in a real 77369626Sru % document, then we can reconsider our strategy. 77469626Sru \penalty9999 77569626Sru % 77669626Sru % Back up by the size of the box, whether we did a page break or not. 77769626Sru \kern -#1\mil 77869626Sru % 77969626Sru % Do not allow a page break right after this kern. 78069626Sru \nobreak 78169626Sru \fi 78269626Sru} 78369626Sru 784151497Sru% @br forces paragraph break (and is undocumented). 78569626Sru 78669626Sru\let\br = \par 78769626Sru 788114402Sru% @page forces the start of a new page. 78969626Sru% 79069626Sru\def\page{\par\vfill\supereject} 79169626Sru 79269626Sru% @exdent text.... 79369626Sru% outputs text on separate line in roman font, starting at standard page margin 79469626Sru 79569626Sru% This records the amount of indent in the innermost environment. 79669626Sru% That's how much \exdent should take out. 79769626Sru\newskip\exdentamount 79869626Sru 79969626Sru% This defn is used inside fill environments such as @defun. 800151497Sru\parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break} 80169626Sru 80269626Sru% This defn is used inside nofill environments such as @example. 803151497Sru\parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount 804151497Sru \leftline{\hskip\leftskip{\rm#1}}}} 80569626Sru 806104862Sru% @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current 807104862Sru% paragraph. For more general purposes, use the \margin insertion 808104862Sru% class. WHICH is `l' or `r'. 809104862Sru% 81069626Sru\newskip\inmarginspacing \inmarginspacing=1cm 81169626Sru\def\strutdepth{\dp\strutbox} 812104862Sru% 813104862Sru\def\doinmargin#1#2{\strut\vadjust{% 814104862Sru \nobreak 815104862Sru \kern-\strutdepth 816104862Sru \vtop to \strutdepth{% 817104862Sru \baselineskip=\strutdepth 818104862Sru \vss 819104862Sru % if you have multiple lines of stuff to put here, you'll need to 820104862Sru % make the vbox yourself of the appropriate size. 821104862Sru \ifx#1l% 822104862Sru \llap{\ignorespaces #2\hskip\inmarginspacing}% 823104862Sru \else 824104862Sru \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}% 825104862Sru \fi 826104862Sru \null 827104862Sru }% 828104862Sru}} 829104862Sru\def\inleftmargin{\doinmargin l} 830104862Sru\def\inrightmargin{\doinmargin r} 831104862Sru% 832104862Sru% @inmargin{TEXT [, RIGHT-TEXT]} 833104862Sru% (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right; 834104862Sru% else use TEXT for both). 835151497Sru% 836104862Sru\def\inmargin#1{\parseinmargin #1,,\finish} 837104862Sru\def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing. 838151497Sru \setbox0 = \hbox{\ignorespaces #2}% 839104862Sru \ifdim\wd0 > 0pt 840104862Sru \def\lefttext{#1}% have both texts 841104862Sru \def\righttext{#2}% 842104862Sru \else 843104862Sru \def\lefttext{#1}% have only one text 844104862Sru \def\righttext{#1}% 845104862Sru \fi 846104862Sru % 847104862Sru \ifodd\pageno 848104862Sru \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin 849104862Sru \else 850104862Sru \def\temp{\inleftmargin\lefttext}% 851104862Sru \fi 852104862Sru \temp 853104862Sru} 85469626Sru 85569626Sru% @include file insert text of that file as input. 856151497Sru% 857151497Sru\def\include{\parseargusing\filenamecatcodes\includezzz} 858151497Sru\def\includezzz#1{% 859151497Sru \pushthisfilestack 860151497Sru \def\thisfile{#1}% 861151497Sru {% 862151497Sru \makevalueexpandable 863151497Sru \def\temp{\input #1 }% 864151497Sru \expandafter 865151497Sru }\temp 866151497Sru \popthisfilestack 867151497Sru} 868151497Sru\def\filenamecatcodes{% 869114402Sru \catcode`\\=\other 870114402Sru \catcode`~=\other 871114402Sru \catcode`^=\other 872114402Sru \catcode`_=\other 873114402Sru \catcode`|=\other 874114402Sru \catcode`<=\other 875114402Sru \catcode`>=\other 876114402Sru \catcode`+=\other 877151497Sru \catcode`-=\other 878151497Sru} 87969626Sru 880151497Sru\def\pushthisfilestack{% 881151497Sru \expandafter\pushthisfilestackX\popthisfilestack\StackTerm 882151497Sru} 883151497Sru\def\pushthisfilestackX{% 884151497Sru \expandafter\pushthisfilestackY\thisfile\StackTerm 885151497Sru} 886151497Sru\def\pushthisfilestackY #1\StackTerm #2\StackTerm {% 887151497Sru \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}% 888151497Sru} 889151497Sru 890151497Sru\def\popthisfilestack{\errthisfilestackempty} 891151497Sru\def\errthisfilestackempty{\errmessage{Internal error: 892151497Sru the stack of filenames is empty.}} 893151497Sru 89469626Sru\def\thisfile{} 89569626Sru 896114402Sru% @center line 897114402Sru% outputs that line, centered. 898114402Sru% 899151497Sru\parseargdef\center{% 900151497Sru \ifhmode 901151497Sru \let\next\centerH 902151497Sru \else 903151497Sru \let\next\centerV 904151497Sru \fi 905151497Sru \next{\hfil \ignorespaces#1\unskip \hfil}% 906151497Sru} 907151497Sru\def\centerH#1{% 908151497Sru {% 909151497Sru \hfil\break 910151497Sru \advance\hsize by -\leftskip 911151497Sru \advance\hsize by -\rightskip 912151497Sru \line{#1}% 913151497Sru \break 914151497Sru }% 915151497Sru} 916151497Sru\def\centerV#1{\line{\kern\leftskip #1\kern\rightskip}} 91769626Sru 91869626Sru% @sp n outputs n lines of vertical space 91969626Sru 920151497Sru\parseargdef\sp{\vskip #1\baselineskip} 92169626Sru 92269626Sru% @comment ...line which is ignored... 92369626Sru% @c is the same as @comment 92469626Sru% @ignore ... @end ignore is another way to write a comment 92569626Sru 92669626Sru\def\comment{\begingroup \catcode`\^^M=\other% 92769626Sru\catcode`\@=\other \catcode`\{=\other \catcode`\}=\other% 92869626Sru\commentxxx} 92969626Sru{\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}} 93069626Sru 93169626Sru\let\c=\comment 93269626Sru 93369626Sru% @paragraphindent NCHARS 93469626Sru% We'll use ems for NCHARS, close enough. 935151497Sru% NCHARS can also be the word `asis' or `none'. 936151497Sru% We cannot feasibly implement @paragraphindent asis, though. 937151497Sru% 93869626Sru\def\asisword{asis} % no translation, these are keywords 93969626Sru\def\noneword{none} 94069626Sru% 941151497Sru\parseargdef\paragraphindent{% 94269626Sru \def\temp{#1}% 94369626Sru \ifx\temp\asisword 94469626Sru \else 94569626Sru \ifx\temp\noneword 94669626Sru \defaultparindent = 0pt 94769626Sru \else 94869626Sru \defaultparindent = #1em 94969626Sru \fi 95069626Sru \fi 95169626Sru \parindent = \defaultparindent 95269626Sru} 95369626Sru 95469626Sru% @exampleindent NCHARS 95569626Sru% We'll use ems for NCHARS like @paragraphindent. 95669626Sru% It seems @exampleindent asis isn't necessary, but 95769626Sru% I preserve it to make it similar to @paragraphindent. 958151497Sru\parseargdef\exampleindent{% 95969626Sru \def\temp{#1}% 96069626Sru \ifx\temp\asisword 96169626Sru \else 96269626Sru \ifx\temp\noneword 96369626Sru \lispnarrowing = 0pt 96469626Sru \else 96569626Sru \lispnarrowing = #1em 96669626Sru \fi 96769626Sru \fi 96869626Sru} 96969626Sru 970151497Sru% @firstparagraphindent WORD 971151497Sru% If WORD is `none', then suppress indentation of the first paragraph 972151497Sru% after a section heading. If WORD is `insert', then do indent at such 973151497Sru% paragraphs. 974151497Sru% 975151497Sru% The paragraph indentation is suppressed or not by calling 976151497Sru% \suppressfirstparagraphindent, which the sectioning commands do. 977151497Sru% We switch the definition of this back and forth according to WORD. 978151497Sru% By default, we suppress indentation. 979151497Sru% 980151497Sru\def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent} 981151497Sru\def\insertword{insert} 982151497Sru% 983151497Sru\parseargdef\firstparagraphindent{% 984151497Sru \def\temp{#1}% 985151497Sru \ifx\temp\noneword 986151497Sru \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent 987151497Sru \else\ifx\temp\insertword 988151497Sru \let\suppressfirstparagraphindent = \relax 989151497Sru \else 990151497Sru \errhelp = \EMsimple 991151497Sru \errmessage{Unknown @firstparagraphindent option `\temp'}% 992151497Sru \fi\fi 993151497Sru} 994151497Sru 995151497Sru% Here is how we actually suppress indentation. Redefine \everypar to 996151497Sru% \kern backwards by \parindent, and then reset itself to empty. 997151497Sru% 998151497Sru% We also make \indent itself not actually do anything until the next 999151497Sru% paragraph. 1000151497Sru% 1001151497Sru\gdef\dosuppressfirstparagraphindent{% 1002151497Sru \gdef\indent{% 1003151497Sru \restorefirstparagraphindent 1004151497Sru \indent 1005151497Sru }% 1006151497Sru \gdef\noindent{% 1007151497Sru \restorefirstparagraphindent 1008151497Sru \noindent 1009151497Sru }% 1010151497Sru \global\everypar = {% 1011151497Sru \kern -\parindent 1012151497Sru \restorefirstparagraphindent 1013151497Sru }% 1014151497Sru} 1015151497Sru 1016151497Sru\gdef\restorefirstparagraphindent{% 1017151497Sru \global \let \indent = \ptexindent 1018151497Sru \global \let \noindent = \ptexnoindent 1019151497Sru \global \everypar = {}% 1020151497Sru} 1021151497Sru 1022151497Sru 102369626Sru% @asis just yields its argument. Used with @table, for example. 102469626Sru% 102569626Sru\def\asis#1{#1} 102669626Sru 1027104862Sru% @math outputs its argument in math mode. 102869626Sru% 1029104862Sru% One complication: _ usually means subscripts, but it could also mean 1030104862Sru% an actual _ character, as in @math{@var{some_variable} + 1}. So make 1031151497Sru% _ active, and distinguish by seeing if the current family is \slfam, 1032151497Sru% which is what @var uses. 1033151497Sru{ 1034151497Sru \catcode\underChar = \active 1035151497Sru \gdef\mathunderscore{% 1036151497Sru \catcode\underChar=\active 1037151497Sru \def_{\ifnum\fam=\slfam \_\else\sb\fi}% 1038151497Sru } 1039151497Sru} 1040104862Sru% Another complication: we want \\ (and @\) to output a \ character. 1041104862Sru% FYI, plain.tex uses \\ as a temporary control sequence (why?), but 1042104862Sru% this is not advertised and we don't care. Texinfo does not 1043104862Sru% otherwise define @\. 1044151497Sru% 1045104862Sru% The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\. 1046104862Sru\def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi} 1047104862Sru% 1048104862Sru\def\math{% 1049104862Sru \tex 1050151497Sru \mathunderscore 1051104862Sru \let\\ = \mathbackslash 1052114402Sru \mathactive 1053151497Sru $\finishmath 1054151497Sru} 1055151497Sru\def\finishmath#1{#1$\endgroup} % Close the group opened by \tex. 105669626Sru 1057114402Sru% Some active characters (such as <) are spaced differently in math. 1058151497Sru% We have to reset their definitions in case the @math was an argument 1059151497Sru% to a command which sets the catcodes (such as @item or @section). 1060151497Sru% 1061114402Sru{ 1062114402Sru \catcode`^ = \active 1063114402Sru \catcode`< = \active 1064114402Sru \catcode`> = \active 1065114402Sru \catcode`+ = \active 1066114402Sru \gdef\mathactive{% 1067114402Sru \let^ = \ptexhat 1068114402Sru \let< = \ptexless 1069114402Sru \let> = \ptexgtr 1070114402Sru \let+ = \ptexplus 1071114402Sru } 1072114402Sru} 1073114402Sru 107469626Sru% @bullet and @minus need the same treatment as @math, just above. 1075151497Sru\def\bullet{$\ptexbullet$} 1076151497Sru\def\minus{$-$} 107769626Sru 1078151497Sru% @dots{} outputs an ellipsis using the current font. 1079151497Sru% We do .5em per period so that it has the same spacing in a typewriter 1080151497Sru% font as three actual period characters. 1081151497Sru% 1082151497Sru\def\dots{% 1083151497Sru \leavevmode 1084151497Sru \hbox to 1.5em{% 1085151497Sru \hskip 0pt plus 0.25fil 1086151497Sru .\hfil.\hfil.% 1087151497Sru \hskip 0pt plus 0.5fil 1088151497Sru }% 1089151497Sru} 1090151497Sru 1091151497Sru% @enddots{} is an end-of-sentence ellipsis. 1092151497Sru% 1093151497Sru\def\enddots{% 1094151497Sru \dots 1095151497Sru \spacefactor=3000 1096151497Sru} 1097151497Sru 1098151497Sru% @comma{} is so commas can be inserted into text without messing up 1099151497Sru% Texinfo's parsing. 1100151497Sru% 1101151497Sru\let\comma = , 1102151497Sru 110369626Sru% @refill is a no-op. 110469626Sru\let\refill=\relax 110569626Sru 110669626Sru% If working on a large document in chapters, it is convenient to 110769626Sru% be able to disable indexing, cross-referencing, and contents, for test runs. 110869626Sru% This is done with @novalidate (before @setfilename). 110969626Sru% 111069626Sru\newif\iflinks \linkstrue % by default we want the aux files. 111169626Sru\let\novalidate = \linksfalse 111269626Sru 111369626Sru% @setfilename is done at the beginning of every texinfo file. 111469626Sru% So open here the files we need to have open while reading the input. 111569626Sru% This makes it possible to make a .fmt file for texinfo. 111669626Sru\def\setfilename{% 1117151497Sru \fixbackslash % Turn off hack to swallow `\input texinfo'. 111869626Sru \iflinks 1119151497Sru \tryauxfile 1120151497Sru % Open the new aux file. TeX will close it automatically at exit. 1121151497Sru \immediate\openout\auxfile=\jobname.aux 112269626Sru \fi % \openindices needs to do some work in any case. 112369626Sru \openindices 1124151497Sru \let\setfilename=\comment % Ignore extra @setfilename cmds. 112569626Sru % 112669626Sru % If texinfo.cnf is present on the system, read it. 112769626Sru % Useful for site-wide @afourpaper, etc. 112869626Sru \openin 1 texinfo.cnf 1129151497Sru \ifeof 1 \else \input texinfo.cnf \fi 1130151497Sru \closein 1 113169626Sru % 113269626Sru \comment % Ignore the actual filename. 113369626Sru} 113469626Sru 113569626Sru% Called from \setfilename. 113669626Sru% 113769626Sru\def\openindices{% 113869626Sru \newindex{cp}% 113969626Sru \newcodeindex{fn}% 114069626Sru \newcodeindex{vr}% 114169626Sru \newcodeindex{tp}% 114269626Sru \newcodeindex{ky}% 114369626Sru \newcodeindex{pg}% 114469626Sru} 114569626Sru 114669626Sru% @bye. 114769626Sru\outer\def\bye{\pagealignmacro\tracingstats=1\ptexend} 114869626Sru 114969626Sru 115069626Sru\message{pdf,} 115169626Sru% adobe `portable' document format 115269626Sru\newcount\tempnum 115369626Sru\newcount\lnkcount 115469626Sru\newtoks\filename 115569626Sru\newcount\filenamelength 115669626Sru\newcount\pgn 115769626Sru\newtoks\toksA 115869626Sru\newtoks\toksB 115969626Sru\newtoks\toksC 116069626Sru\newtoks\toksD 116169626Sru\newbox\boxA 116269626Sru\newcount\countA 116369626Sru\newif\ifpdf 116469626Sru\newif\ifpdfmakepagedest 116569626Sru 1166151497Sru% when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1 1167151497Sru% can be set). So we test for \relax and 0 as well as \undefined, 1168151497Sru% borrowed from ifpdf.sty. 116969626Sru\ifx\pdfoutput\undefined 117069626Sru\else 1171151497Sru \ifx\pdfoutput\relax 1172151497Sru \else 1173151497Sru \ifcase\pdfoutput 1174151497Sru \else 1175151497Sru \pdftrue 1176151497Sru \fi 1177151497Sru \fi 1178151497Sru\fi 1179151497Sru% 1180151497Sru\ifpdf 118169626Sru \input pdfcolor 1182151497Sru \pdfcatalog{/PageMode /UseOutlines}% 118369626Sru \def\dopdfimage#1#2#3{% 118469626Sru \def\imagewidth{#2}% 118569626Sru \def\imageheight{#3}% 1186104862Sru % without \immediate, pdftex seg faults when the same image is 1187104862Sru % included twice. (Version 3.14159-pre-1.0-unofficial-20010704.) 118869626Sru \ifnum\pdftexversion < 14 1189104862Sru \immediate\pdfimage 119069626Sru \else 1191104862Sru \immediate\pdfximage 119269626Sru \fi 119369626Sru \ifx\empty\imagewidth\else width \imagewidth \fi 119469626Sru \ifx\empty\imageheight\else height \imageheight \fi 1195104862Sru \ifnum\pdftexversion<13 1196114402Sru #1.pdf% 1197104862Sru \else 1198104862Sru {#1.pdf}% 1199104862Sru \fi 120069626Sru \ifnum\pdftexversion < 14 \else 120169626Sru \pdfrefximage \pdflastximage 120269626Sru \fi} 1203151497Sru \def\pdfmkdest#1{{% 1204151497Sru % We have to set dummies so commands such as @code in a section title 1205151497Sru % aren't expanded. 1206151497Sru \atdummies 1207151497Sru \normalturnoffactive 1208151497Sru \pdfdest name{#1} xyz% 1209151497Sru }} 1210104862Sru \def\pdfmkpgn#1{#1} 121169626Sru \let\linkcolor = \Blue % was Cyan, but that seems light? 121269626Sru \def\endlink{\Black\pdfendlink} 121369626Sru % Adding outlines to PDF; macros for calculating structure of outlines 121469626Sru % come from Petr Olsak 121569626Sru \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0% 121669626Sru \else \csname#1\endcsname \fi} 121769626Sru \def\advancenumber#1{\tempnum=\expnumber{#1}\relax 1218151497Sru \advance\tempnum by 1 121969626Sru \expandafter\xdef\csname#1\endcsname{\the\tempnum}} 1220151497Sru % 1221151497Sru % #1 is the section text. #2 is the pdf expression for the number 1222151497Sru % of subentries (or empty, for subsubsections). #3 is the node 1223151497Sru % text, which might be empty if this toc entry had no 1224151497Sru % corresponding node. #4 is the page number. 1225151497Sru % 1226151497Sru \def\dopdfoutline#1#2#3#4{% 1227151497Sru % Generate a link to the node text if that exists; else, use the 1228151497Sru % page number. We could generate a destination for the section 1229151497Sru % text in the case where a section has no node, but it doesn't 1230151497Sru % seem worthwhile, since most documents are normally structured. 1231151497Sru \def\pdfoutlinedest{#3}% 1232151497Sru \ifx\pdfoutlinedest\empty \def\pdfoutlinedest{#4}\fi 1233151497Sru % 1234151497Sru \pdfoutline goto name{\pdfmkpgn{\pdfoutlinedest}}#2{#1}% 1235151497Sru } 1236151497Sru % 1237151497Sru \def\pdfmakeoutlines{% 1238151497Sru \begingroup 1239151497Sru % Thanh's hack / proper braces in bookmarks 124069626Sru \edef\mylbrace{\iftrue \string{\else}\fi}\let\{=\mylbrace 124169626Sru \edef\myrbrace{\iffalse{\else\string}\fi}\let\}=\myrbrace 124269626Sru % 1243151497Sru % Read toc silently, to get counts of subentries for \pdfoutline. 1244151497Sru \def\numchapentry##1##2##3##4{% 1245151497Sru \def\thischapnum{##2}% 1246151497Sru \def\thissecnum{0}% 1247151497Sru \def\thissubsecnum{0}% 1248151497Sru }% 1249151497Sru \def\numsecentry##1##2##3##4{% 1250151497Sru \advancenumber{chap\thischapnum}% 1251151497Sru \def\thissecnum{##2}% 1252151497Sru \def\thissubsecnum{0}% 1253151497Sru }% 1254151497Sru \def\numsubsecentry##1##2##3##4{% 1255151497Sru \advancenumber{sec\thissecnum}% 1256151497Sru \def\thissubsecnum{##2}% 1257151497Sru }% 1258151497Sru \def\numsubsubsecentry##1##2##3##4{% 1259151497Sru \advancenumber{subsec\thissubsecnum}% 1260151497Sru }% 1261151497Sru \def\thischapnum{0}% 1262151497Sru \def\thissecnum{0}% 1263151497Sru \def\thissubsecnum{0}% 1264151497Sru % 1265151497Sru % use \def rather than \let here because we redefine \chapentry et 1266151497Sru % al. a second time, below. 1267151497Sru \def\appentry{\numchapentry}% 1268151497Sru \def\appsecentry{\numsecentry}% 1269151497Sru \def\appsubsecentry{\numsubsecentry}% 1270151497Sru \def\appsubsubsecentry{\numsubsubsecentry}% 1271151497Sru \def\unnchapentry{\numchapentry}% 1272151497Sru \def\unnsecentry{\numsecentry}% 1273151497Sru \def\unnsubsecentry{\numsubsecentry}% 1274151497Sru \def\unnsubsubsecentry{\numsubsubsecentry}% 127569626Sru \input \jobname.toc 1276114402Sru % 1277151497Sru % Read toc second time, this time actually producing the outlines. 1278151497Sru % The `-' means take the \expnumber as the absolute number of 1279151497Sru % subentries, which we calculated on our first read of the .toc above. 1280151497Sru % 1281151497Sru % We use the node names as the destinations. 1282151497Sru \def\numchapentry##1##2##3##4{% 1283151497Sru \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}% 1284151497Sru \def\numsecentry##1##2##3##4{% 1285151497Sru \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}% 1286151497Sru \def\numsubsecentry##1##2##3##4{% 1287151497Sru \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}% 1288151497Sru \def\numsubsubsecentry##1##2##3##4{% count is always zero 1289151497Sru \dopdfoutline{##1}{}{##3}{##4}}% 1290151497Sru % 1291151497Sru % PDF outlines are displayed using system fonts, instead of 1292151497Sru % document fonts. Therefore we cannot use special characters, 1293151497Sru % since the encoding is unknown. For example, the eogonek from 1294151497Sru % Latin 2 (0xea) gets translated to a | character. Info from 1295151497Sru % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100. 1296151497Sru % 1297151497Sru % xx to do this right, we have to translate 8-bit characters to 1298151497Sru % their "best" equivalent, based on the @documentencoding. Right 1299151497Sru % now, I guess we'll just let the pdf reader have its way. 1300114402Sru \indexnofonts 1301114402Sru \turnoffactive 130269626Sru \input \jobname.toc 1303151497Sru \endgroup 1304151497Sru } 1305151497Sru % 130669626Sru \def\makelinks #1,{% 130769626Sru \def\params{#1}\def\E{END}% 130869626Sru \ifx\params\E 130969626Sru \let\nextmakelinks=\relax 131069626Sru \else 131169626Sru \let\nextmakelinks=\makelinks 131269626Sru \ifnum\lnkcount>0,\fi 131369626Sru \picknum{#1}% 1314151497Sru \startlink attr{/Border [0 0 0]} 131569626Sru goto name{\pdfmkpgn{\the\pgn}}% 131669626Sru \linkcolor #1% 131769626Sru \advance\lnkcount by 1% 131869626Sru \endlink 131969626Sru \fi 132069626Sru \nextmakelinks 132169626Sru } 132269626Sru \def\picknum#1{\expandafter\pn#1} 132369626Sru \def\pn#1{% 132469626Sru \def\p{#1}% 132569626Sru \ifx\p\lbrace 132669626Sru \let\nextpn=\ppn 132769626Sru \else 132869626Sru \let\nextpn=\ppnn 132969626Sru \def\first{#1} 133069626Sru \fi 133169626Sru \nextpn 133269626Sru } 133369626Sru \def\ppn#1{\pgn=#1\gobble} 133469626Sru \def\ppnn{\pgn=\first} 133569626Sru \def\pdfmklnk#1{\lnkcount=0\makelinks #1,END,} 133669626Sru \def\skipspaces#1{\def\PP{#1}\def\D{|}% 133769626Sru \ifx\PP\D\let\nextsp\relax 133869626Sru \else\let\nextsp\skipspaces 133969626Sru \ifx\p\space\else\addtokens{\filename}{\PP}% 134069626Sru \advance\filenamelength by 1 134169626Sru \fi 134269626Sru \fi 134369626Sru \nextsp} 134469626Sru \def\getfilename#1{\filenamelength=0\expandafter\skipspaces#1|\relax} 134569626Sru \ifnum\pdftexversion < 14 134669626Sru \let \startlink \pdfannotlink 134769626Sru \else 134869626Sru \let \startlink \pdfstartlink 134969626Sru \fi 135069626Sru \def\pdfurl#1{% 135169626Sru \begingroup 135269626Sru \normalturnoffactive\def\@{@}% 1353151497Sru \makevalueexpandable 135469626Sru \leavevmode\Red 135569626Sru \startlink attr{/Border [0 0 0]}% 135669626Sru user{/Subtype /Link /A << /S /URI /URI (#1) >>}% 135769626Sru \endgroup} 135869626Sru \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}} 135969626Sru \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks} 136069626Sru \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks} 136169626Sru \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}} 136269626Sru \def\maketoks{% 1363151497Sru \expandafter\poptoks\the\toksA|ENDTOKS|\relax 136469626Sru \ifx\first0\adn0 136569626Sru \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3 136669626Sru \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6 1367151497Sru \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9 136869626Sru \else 136969626Sru \ifnum0=\countA\else\makelink\fi 137069626Sru \ifx\first.\let\next=\done\else 137169626Sru \let\next=\maketoks 137269626Sru \addtokens{\toksB}{\the\toksD} 137369626Sru \ifx\first,\addtokens{\toksB}{\space}\fi 137469626Sru \fi 137569626Sru \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi 137669626Sru \next} 137769626Sru \def\makelink{\addtokens{\toksB}% 137869626Sru {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0} 137969626Sru \def\pdflink#1{% 1380104862Sru \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}} 138169626Sru \linkcolor #1\endlink} 138269626Sru \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st} 1383151497Sru\else 1384151497Sru \let\pdfmkdest = \gobble 1385151497Sru \let\pdfurl = \gobble 1386151497Sru \let\endlink = \relax 1387151497Sru \let\linkcolor = \relax 1388151497Sru \let\pdfmakeoutlines = \relax 1389151497Sru\fi % \ifx\pdfoutput 139069626Sru 139169626Sru 139269626Sru\message{fonts,} 139369626Sru 1394151497Sru% Change the current font style to #1, remembering it in \curfontstyle. 1395151497Sru% For now, we do not accumulate font styles: @b{@i{foo}} prints foo in 1396151497Sru% italics, not bold italics. 1397151497Sru% 1398151497Sru\def\setfontstyle#1{% 1399151497Sru \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd. 1400151497Sru \csname ten#1\endcsname % change the current font 1401151497Sru} 1402151497Sru 1403151497Sru% Select #1 fonts with the current style. 1404151497Sru% 1405151497Sru\def\selectfonts#1{\csname #1fonts\endcsname \csname\curfontstyle\endcsname} 1406151497Sru 1407151497Sru\def\rm{\fam=0 \setfontstyle{rm}} 1408151497Sru\def\it{\fam=\itfam \setfontstyle{it}} 1409151497Sru\def\sl{\fam=\slfam \setfontstyle{sl}} 1410151497Sru\def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf} 1411151497Sru\def\tt{\fam=\ttfam \setfontstyle{tt}} 1412151497Sru 141369626Sru% Texinfo sort of supports the sans serif font style, which plain TeX does not. 1414151497Sru% So we set up a \sf. 141569626Sru\newfam\sffam 1416151497Sru\def\sf{\fam=\sffam \setfontstyle{sf}} 141769626Sru\let\li = \sf % Sometimes we call it \li, not \sf. 141869626Sru 1419151497Sru% We don't need math for this font style. 1420151497Sru\def\ttsl{\setfontstyle{ttsl}} 142169626Sru 1422104862Sru% Default leading. 1423104862Sru\newdimen\textleading \textleading = 13.2pt 142469626Sru 1425104862Sru% Set the baselineskip to #1, and the lineskip and strut size 1426104862Sru% correspondingly. There is no deep meaning behind these magic numbers 1427104862Sru% used as factors; they just match (closely enough) what Knuth defined. 1428104862Sru% 1429104862Sru\def\lineskipfactor{.08333} 1430104862Sru\def\strutheightpercent{.70833} 1431104862Sru\def\strutdepthpercent {.29167} 1432104862Sru% 1433104862Sru\def\setleading#1{% 1434104862Sru \normalbaselineskip = #1\relax 1435104862Sru \normallineskip = \lineskipfactor\normalbaselineskip 1436104862Sru \normalbaselines 1437104862Sru \setbox\strutbox =\hbox{% 1438104862Sru \vrule width0pt height\strutheightpercent\baselineskip 1439104862Sru depth \strutdepthpercent \baselineskip 1440104862Sru }% 1441104862Sru} 1442104862Sru 144369626Sru% Set the font macro #1 to the font named #2, adding on the 144469626Sru% specified font prefix (normally `cm'). 144569626Sru% #3 is the font's design size, #4 is a scale factor 144669626Sru\def\setfont#1#2#3#4{\font#1=\fontprefix#2#3 scaled #4} 144769626Sru 144869626Sru% Use cm as the default font prefix. 144969626Sru% To specify the font prefix, you must define \fontprefix 145069626Sru% before you read in texinfo.tex. 145169626Sru\ifx\fontprefix\undefined 145269626Sru\def\fontprefix{cm} 145369626Sru\fi 145469626Sru% Support font families that don't use the same naming scheme as CM. 145569626Sru\def\rmshape{r} 145669626Sru\def\rmbshape{bx} %where the normal face is bold 145769626Sru\def\bfshape{b} 145869626Sru\def\bxshape{bx} 145969626Sru\def\ttshape{tt} 146069626Sru\def\ttbshape{tt} 146169626Sru\def\ttslshape{sltt} 146269626Sru\def\itshape{ti} 146369626Sru\def\itbshape{bxti} 146469626Sru\def\slshape{sl} 146569626Sru\def\slbshape{bxsl} 146669626Sru\def\sfshape{ss} 146769626Sru\def\sfbshape{ss} 146869626Sru\def\scshape{csc} 146969626Sru\def\scbshape{csc} 147069626Sru 1471151497Sru% Text fonts (11.2pt, magstep1). 1472151497Sru\def\textnominalsize{11pt} 1473151497Sru\edef\mainmagstep{\magstephalf} 1474151497Sru\setfont\textrm\rmshape{10}{\mainmagstep} 1475151497Sru\setfont\texttt\ttshape{10}{\mainmagstep} 147669626Sru\setfont\textbf\bfshape{10}{\mainmagstep} 147769626Sru\setfont\textit\itshape{10}{\mainmagstep} 147869626Sru\setfont\textsl\slshape{10}{\mainmagstep} 147969626Sru\setfont\textsf\sfshape{10}{\mainmagstep} 148069626Sru\setfont\textsc\scshape{10}{\mainmagstep} 148169626Sru\setfont\textttsl\ttslshape{10}{\mainmagstep} 148269626Sru\font\texti=cmmi10 scaled \mainmagstep 148369626Sru\font\textsy=cmsy10 scaled \mainmagstep 148469626Sru 1485151497Sru% A few fonts for @defun names and args. 1486151497Sru\setfont\defbf\bfshape{10}{\magstep1} 148769626Sru\setfont\deftt\ttshape{10}{\magstep1} 1488151497Sru\setfont\defttsl\ttslshape{10}{\magstep1} 1489151497Sru\def\df{\let\tentt=\deftt \let\tenbf = \defbf \let\tenttsl=\defttsl \bf} 149069626Sru 149169626Sru% Fonts for indices, footnotes, small examples (9pt). 1492151497Sru\def\smallnominalsize{9pt} 149369626Sru\setfont\smallrm\rmshape{9}{1000} 149469626Sru\setfont\smalltt\ttshape{9}{1000} 149569626Sru\setfont\smallbf\bfshape{10}{900} 149669626Sru\setfont\smallit\itshape{9}{1000} 149769626Sru\setfont\smallsl\slshape{9}{1000} 149869626Sru\setfont\smallsf\sfshape{9}{1000} 149969626Sru\setfont\smallsc\scshape{10}{900} 150069626Sru\setfont\smallttsl\ttslshape{10}{900} 150169626Sru\font\smalli=cmmi9 150269626Sru\font\smallsy=cmsy9 150369626Sru 1504104862Sru% Fonts for small examples (8pt). 1505151497Sru\def\smallernominalsize{8pt} 1506104862Sru\setfont\smallerrm\rmshape{8}{1000} 1507104862Sru\setfont\smallertt\ttshape{8}{1000} 1508104862Sru\setfont\smallerbf\bfshape{10}{800} 1509104862Sru\setfont\smallerit\itshape{8}{1000} 1510104862Sru\setfont\smallersl\slshape{8}{1000} 1511104862Sru\setfont\smallersf\sfshape{8}{1000} 1512104862Sru\setfont\smallersc\scshape{10}{800} 1513104862Sru\setfont\smallerttsl\ttslshape{10}{800} 1514104862Sru\font\smalleri=cmmi8 1515104862Sru\font\smallersy=cmsy8 1516104862Sru 1517151497Sru% Fonts for title page (20.4pt): 1518151497Sru\def\titlenominalsize{20pt} 151969626Sru\setfont\titlerm\rmbshape{12}{\magstep3} 152069626Sru\setfont\titleit\itbshape{10}{\magstep4} 152169626Sru\setfont\titlesl\slbshape{10}{\magstep4} 152269626Sru\setfont\titlett\ttbshape{12}{\magstep3} 152369626Sru\setfont\titlettsl\ttslshape{10}{\magstep4} 152469626Sru\setfont\titlesf\sfbshape{17}{\magstep1} 152569626Sru\let\titlebf=\titlerm 152669626Sru\setfont\titlesc\scbshape{10}{\magstep4} 152769626Sru\font\titlei=cmmi12 scaled \magstep3 152869626Sru\font\titlesy=cmsy10 scaled \magstep4 152969626Sru\def\authorrm{\secrm} 1530104862Sru\def\authortt{\sectt} 153169626Sru 153269626Sru% Chapter (and unnumbered) fonts (17.28pt). 1533151497Sru\def\chapnominalsize{17pt} 153469626Sru\setfont\chaprm\rmbshape{12}{\magstep2} 153569626Sru\setfont\chapit\itbshape{10}{\magstep3} 153669626Sru\setfont\chapsl\slbshape{10}{\magstep3} 153769626Sru\setfont\chaptt\ttbshape{12}{\magstep2} 153869626Sru\setfont\chapttsl\ttslshape{10}{\magstep3} 153969626Sru\setfont\chapsf\sfbshape{17}{1000} 154069626Sru\let\chapbf=\chaprm 154169626Sru\setfont\chapsc\scbshape{10}{\magstep3} 154269626Sru\font\chapi=cmmi12 scaled \magstep2 154369626Sru\font\chapsy=cmsy10 scaled \magstep3 154469626Sru 154569626Sru% Section fonts (14.4pt). 1546151497Sru\def\secnominalsize{14pt} 154769626Sru\setfont\secrm\rmbshape{12}{\magstep1} 154869626Sru\setfont\secit\itbshape{10}{\magstep2} 154969626Sru\setfont\secsl\slbshape{10}{\magstep2} 155069626Sru\setfont\sectt\ttbshape{12}{\magstep1} 155169626Sru\setfont\secttsl\ttslshape{10}{\magstep2} 155269626Sru\setfont\secsf\sfbshape{12}{\magstep1} 155369626Sru\let\secbf\secrm 155469626Sru\setfont\secsc\scbshape{10}{\magstep2} 155569626Sru\font\seci=cmmi12 scaled \magstep1 155669626Sru\font\secsy=cmsy10 scaled \magstep2 155769626Sru 155869626Sru% Subsection fonts (13.15pt). 1559151497Sru\def\ssecnominalsize{13pt} 156069626Sru\setfont\ssecrm\rmbshape{12}{\magstephalf} 156169626Sru\setfont\ssecit\itbshape{10}{1315} 156269626Sru\setfont\ssecsl\slbshape{10}{1315} 156369626Sru\setfont\ssectt\ttbshape{12}{\magstephalf} 156469626Sru\setfont\ssecttsl\ttslshape{10}{1315} 156569626Sru\setfont\ssecsf\sfbshape{12}{\magstephalf} 156669626Sru\let\ssecbf\ssecrm 1567151497Sru\setfont\ssecsc\scbshape{10}{1315} 156869626Sru\font\sseci=cmmi12 scaled \magstephalf 156969626Sru\font\ssecsy=cmsy10 scaled 1315 157069626Sru 1571151497Sru% Reduced fonts for @acro in text (10pt). 1572151497Sru\def\reducednominalsize{10pt} 1573151497Sru\setfont\reducedrm\rmshape{10}{1000} 1574151497Sru\setfont\reducedtt\ttshape{10}{1000} 1575151497Sru\setfont\reducedbf\bfshape{10}{1000} 1576151497Sru\setfont\reducedit\itshape{10}{1000} 1577151497Sru\setfont\reducedsl\slshape{10}{1000} 1578151497Sru\setfont\reducedsf\sfshape{10}{1000} 1579151497Sru\setfont\reducedsc\scshape{10}{1000} 1580151497Sru\setfont\reducedttsl\ttslshape{10}{1000} 1581151497Sru\font\reducedi=cmmi10 1582151497Sru\font\reducedsy=cmsy10 1583151497Sru 158469626Sru% In order for the font changes to affect most math symbols and letters, 158569626Sru% we have to define the \textfont of the standard families. Since 1586104862Sru% texinfo doesn't allow for producing subscripts and superscripts except 1587104862Sru% in the main text, we don't bother to reset \scriptfont and 1588104862Sru% \scriptscriptfont (which would also require loading a lot more fonts). 158969626Sru% 159069626Sru\def\resetmathfonts{% 1591104862Sru \textfont0=\tenrm \textfont1=\teni \textfont2=\tensy 1592104862Sru \textfont\itfam=\tenit \textfont\slfam=\tensl \textfont\bffam=\tenbf 1593104862Sru \textfont\ttfam=\tentt \textfont\sffam=\tensf 159469626Sru} 159569626Sru 159669626Sru% The font-changing commands redefine the meanings of \tenSTYLE, instead 1597151497Sru% of just \STYLE. We do this because \STYLE needs to also set the 1598151497Sru% current \fam for math mode. Our \STYLE (e.g., \rm) commands hardwire 1599151497Sru% \tenSTYLE to set the current font. 1600151497Sru% 1601151497Sru% Each font-changing command also sets the names \lsize (one size lower) 1602151497Sru% and \lllsize (three sizes lower). These relative commands are used in 1603151497Sru% the LaTeX logo and acronyms. 1604151497Sru% 1605151497Sru% This all needs generalizing, badly. 1606151497Sru% 160769626Sru\def\textfonts{% 160869626Sru \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl 160969626Sru \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc 1610151497Sru \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy 1611151497Sru \let\tenttsl=\textttsl 1612151497Sru \def\curfontsize{text}% 1613151497Sru \def\lsize{reduced}\def\lllsize{smaller}% 1614104862Sru \resetmathfonts \setleading{\textleading}} 161569626Sru\def\titlefonts{% 161669626Sru \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl 161769626Sru \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc 161869626Sru \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy 161969626Sru \let\tenttsl=\titlettsl 1620151497Sru \def\curfontsize{title}% 1621151497Sru \def\lsize{chap}\def\lllsize{subsec}% 162269626Sru \resetmathfonts \setleading{25pt}} 162369626Sru\def\titlefont#1{{\titlefonts\rm #1}} 162469626Sru\def\chapfonts{% 162569626Sru \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl 162669626Sru \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc 1627151497Sru \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy 1628151497Sru \let\tenttsl=\chapttsl 1629151497Sru \def\curfontsize{chap}% 1630151497Sru \def\lsize{sec}\def\lllsize{text}% 163169626Sru \resetmathfonts \setleading{19pt}} 163269626Sru\def\secfonts{% 163369626Sru \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl 163469626Sru \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc 1635151497Sru \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy 1636151497Sru \let\tenttsl=\secttsl 1637151497Sru \def\curfontsize{sec}% 1638151497Sru \def\lsize{subsec}\def\lllsize{reduced}% 163969626Sru \resetmathfonts \setleading{16pt}} 164069626Sru\def\subsecfonts{% 164169626Sru \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl 164269626Sru \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc 1643151497Sru \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy 1644151497Sru \let\tenttsl=\ssecttsl 1645151497Sru \def\curfontsize{ssec}% 1646151497Sru \def\lsize{text}\def\lllsize{small}% 164769626Sru \resetmathfonts \setleading{15pt}} 1648151497Sru\let\subsubsecfonts = \subsecfonts 1649151497Sru\def\reducedfonts{% 1650151497Sru \let\tenrm=\reducedrm \let\tenit=\reducedit \let\tensl=\reducedsl 1651151497Sru \let\tenbf=\reducedbf \let\tentt=\reducedtt \let\reducedcaps=\reducedsc 1652151497Sru \let\tensf=\reducedsf \let\teni=\reducedi \let\tensy=\reducedsy 1653151497Sru \let\tenttsl=\reducedttsl 1654151497Sru \def\curfontsize{reduced}% 1655151497Sru \def\lsize{small}\def\lllsize{smaller}% 1656151497Sru \resetmathfonts \setleading{10.5pt}} 165769626Sru\def\smallfonts{% 165869626Sru \let\tenrm=\smallrm \let\tenit=\smallit \let\tensl=\smallsl 165969626Sru \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc 166069626Sru \let\tensf=\smallsf \let\teni=\smalli \let\tensy=\smallsy 166169626Sru \let\tenttsl=\smallttsl 1662151497Sru \def\curfontsize{small}% 1663151497Sru \def\lsize{smaller}\def\lllsize{smaller}% 1664104862Sru \resetmathfonts \setleading{10.5pt}} 1665104862Sru\def\smallerfonts{% 1666104862Sru \let\tenrm=\smallerrm \let\tenit=\smallerit \let\tensl=\smallersl 1667104862Sru \let\tenbf=\smallerbf \let\tentt=\smallertt \let\smallcaps=\smallersc 1668104862Sru \let\tensf=\smallersf \let\teni=\smalleri \let\tensy=\smallersy 1669104862Sru \let\tenttsl=\smallerttsl 1670151497Sru \def\curfontsize{smaller}% 1671151497Sru \def\lsize{smaller}\def\lllsize{smaller}% 1672104862Sru \resetmathfonts \setleading{9.5pt}} 167369626Sru 1674114402Sru% Set the fonts to use with the @small... environments. 1675114402Sru\let\smallexamplefonts = \smallfonts 1676114402Sru 1677114402Sru% About \smallexamplefonts. If we use \smallfonts (9pt), @smallexample 1678114402Sru% can fit this many characters: 1679114402Sru% 8.5x11=86 smallbook=72 a4=90 a5=69 1680151497Sru% If we use \scriptfonts (8pt), then we can fit this many characters: 1681114402Sru% 8.5x11=90+ smallbook=80 a4=90+ a5=77 1682114402Sru% For me, subjectively, the few extra characters that fit aren't worth 1683114402Sru% the additional smallness of 8pt. So I'm making the default 9pt. 1684151497Sru% 1685114402Sru% By the way, for comparison, here's what fits with @example (10pt): 1686114402Sru% 8.5x11=71 smallbook=60 a4=75 a5=58 1687151497Sru% 1688151497Sru% I wish the USA used A4 paper. 1689114402Sru% --karl, 24jan03. 1690114402Sru 1691114402Sru 169269626Sru% Set up the default fonts, so we can use them for creating boxes. 169369626Sru% 1694151497Sru\textfonts \rm 169569626Sru 169669626Sru% Define these so they can be easily changed for other fonts. 169769626Sru\def\angleleft{$\langle$} 169869626Sru\def\angleright{$\rangle$} 169969626Sru 170069626Sru% Count depth in font-changes, for error checks 170169626Sru\newcount\fontdepth \fontdepth=0 170269626Sru 170369626Sru% Fonts for short table of contents. 170469626Sru\setfont\shortcontrm\rmshape{12}{1000} 1705151497Sru\setfont\shortcontbf\bfshape{10}{\magstep1} % no cmb12 170669626Sru\setfont\shortcontsl\slshape{12}{1000} 1707104862Sru\setfont\shortconttt\ttshape{12}{1000} 170869626Sru 170969626Sru%% Add scribe-like font environments, plus @l for inline lisp (usually sans 171069626Sru%% serif) and @ii for TeX italic 171169626Sru 171269626Sru% \smartitalic{ARG} outputs arg in italics, followed by an italic correction 171369626Sru% unless the following character is such as not to need one. 1714151497Sru\def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else 1715151497Sru \ptexslash\fi\fi\fi} 1716114402Sru\def\smartslanted#1{{\ifusingtt\ttsl\sl #1}\futurelet\next\smartitalicx} 1717114402Sru\def\smartitalic#1{{\ifusingtt\ttsl\it #1}\futurelet\next\smartitalicx} 171869626Sru 1719151497Sru% like \smartslanted except unconditionally uses \ttsl. 1720151497Sru% @var is set to this for defun arguments. 1721151497Sru\def\ttslanted#1{{\ttsl #1}\futurelet\next\smartitalicx} 1722151497Sru 1723151497Sru% like \smartslanted except unconditionally use \sl. We never want 1724151497Sru% ttsl for book titles, do we? 1725151497Sru\def\cite#1{{\sl #1}\futurelet\next\smartitalicx} 1726151497Sru 172769626Sru\let\i=\smartitalic 1728151497Sru\let\slanted=\smartslanted 172969626Sru\let\var=\smartslanted 173069626Sru\let\dfn=\smartslanted 173169626Sru\let\emph=\smartitalic 173269626Sru 1733151497Sru% @b, explicit bold. 173469626Sru\def\b#1{{\bf #1}} 173569626Sru\let\strong=\b 173669626Sru 1737151497Sru% @sansserif, explicit sans. 1738151497Sru\def\sansserif#1{{\sf #1}} 1739151497Sru 174069626Sru% We can't just use \exhyphenpenalty, because that only has effect at 174169626Sru% the end of a paragraph. Restore normal hyphenation at the end of the 174269626Sru% group within which \nohyphenation is presumably called. 174369626Sru% 174469626Sru\def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation} 174569626Sru\def\restorehyphenation{\hyphenchar\font = `- } 174669626Sru 1747114402Sru% Set sfcode to normal for the chars that usually have another value. 1748114402Sru% Can't use plain's \frenchspacing because it uses the `\x notation, and 1749114402Sru% sometimes \x has an active definition that messes things up. 1750151497Sru% 1751114402Sru\catcode`@=11 1752114402Sru \def\frenchspacing{% 1753114402Sru \sfcode\dotChar =\@m \sfcode\questChar=\@m \sfcode\exclamChar=\@m 1754114402Sru \sfcode\colonChar=\@m \sfcode\semiChar =\@m \sfcode\commaChar =\@m 1755114402Sru } 1756114402Sru\catcode`@=\other 1757114402Sru 175869626Sru\def\t#1{% 175969626Sru {\tt \rawbackslash \frenchspacing #1}% 176069626Sru \null 176169626Sru} 176269626Sru\def\samp#1{`\tclose{#1}'\null} 176369626Sru\setfont\keyrm\rmshape{8}{1000} 176469626Sru\font\keysy=cmsy9 176569626Sru\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{% 176669626Sru \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{% 176769626Sru \vbox{\hrule\kern-0.4pt 176869626Sru \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}% 176969626Sru \kern-0.4pt\hrule}% 177069626Sru \kern-.06em\raise0.4pt\hbox{\angleright}}}} 177169626Sru% The old definition, with no lozenge: 177269626Sru%\def\key #1{{\ttsl \nohyphenation \uppercase{#1}}\null} 177369626Sru\def\ctrl #1{{\tt \rawbackslash \hat}#1} 177469626Sru 177569626Sru% @file, @option are the same as @samp. 177669626Sru\let\file=\samp 177769626Sru\let\option=\samp 177869626Sru 177969626Sru% @code is a modification of @t, 178069626Sru% which makes spaces the same size as normal in the surrounding text. 178169626Sru\def\tclose#1{% 178269626Sru {% 178369626Sru % Change normal interword space to be same as for the current font. 178469626Sru \spaceskip = \fontdimen2\font 178569626Sru % 178669626Sru % Switch to typewriter. 178769626Sru \tt 178869626Sru % 178969626Sru % But `\ ' produces the large typewriter interword space. 179069626Sru \def\ {{\spaceskip = 0pt{} }}% 179169626Sru % 179269626Sru % Turn off hyphenation. 179369626Sru \nohyphenation 179469626Sru % 179569626Sru \rawbackslash 179669626Sru \frenchspacing 179769626Sru #1% 179869626Sru }% 179969626Sru \null 180069626Sru} 180169626Sru 1802151497Sru% We *must* turn on hyphenation at `-' and `_' in @code. 180369626Sru% Otherwise, it is too hard to avoid overfull hboxes 180469626Sru% in the Emacs manual, the Library manual, etc. 180569626Sru 180669626Sru% Unfortunately, TeX uses one parameter (\hyphenchar) to control 180769626Sru% both hyphenation at - and hyphenation within words. 180869626Sru% We must therefore turn them both off (\tclose does that) 180969626Sru% and arrange explicitly to hyphenate at a dash. 181069626Sru% -- rms. 181169626Sru{ 181269626Sru \catcode`\-=\active 181369626Sru \catcode`\_=\active 181469626Sru % 181569626Sru \global\def\code{\begingroup 181669626Sru \catcode`\-=\active \let-\codedash 181769626Sru \catcode`\_=\active \let_\codeunder 181869626Sru \codex 181969626Sru } 182069626Sru} 182169626Sru 182269626Sru\def\realdash{-} 182369626Sru\def\codedash{-\discretionary{}{}{}} 1824104862Sru\def\codeunder{% 1825104862Sru % this is all so @math{@code{var_name}+1} can work. In math mode, _ 1826104862Sru % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.) 1827104862Sru % will therefore expand the active definition of _, which is us 1828104862Sru % (inside @code that is), therefore an endless loop. 1829104862Sru \ifusingtt{\ifmmode 1830104862Sru \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_. 1831104862Sru \else\normalunderscore \fi 1832104862Sru \discretionary{}{}{}}% 1833104862Sru {\_}% 1834104862Sru} 183569626Sru\def\codex #1{\tclose{#1}\endgroup} 183669626Sru 183769626Sru% @kbd is like @code, except that if the argument is just one @key command, 183869626Sru% then @kbd has no effect. 183969626Sru 184069626Sru% @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always), 184169626Sru% `example' (@kbd uses ttsl only inside of @example and friends), 184269626Sru% or `code' (@kbd uses normal tty font always). 1843151497Sru\parseargdef\kbdinputstyle{% 184469626Sru \def\arg{#1}% 184569626Sru \ifx\arg\worddistinct 184669626Sru \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}% 184769626Sru \else\ifx\arg\wordexample 184869626Sru \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}% 184969626Sru \else\ifx\arg\wordcode 185069626Sru \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}% 1851114402Sru \else 1852114402Sru \errhelp = \EMsimple 1853151497Sru \errmessage{Unknown @kbdinputstyle option `\arg'}% 185469626Sru \fi\fi\fi 185569626Sru} 185669626Sru\def\worddistinct{distinct} 185769626Sru\def\wordexample{example} 185869626Sru\def\wordcode{code} 185969626Sru 1860114402Sru% Default is `distinct.' 1861114402Sru\kbdinputstyle distinct 186269626Sru 186369626Sru\def\xkey{\key} 186469626Sru\def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}% 186569626Sru\ifx\one\xkey\ifx\threex\three \key{#2}% 186669626Sru\else{\tclose{\kbdfont\look}}\fi 186769626Sru\else{\tclose{\kbdfont\look}}\fi} 186869626Sru 1869151497Sru% For @indicateurl, @env, @command quotes seem unnecessary, so use \code. 1870151497Sru\let\indicateurl=\code 187169626Sru\let\env=\code 187269626Sru\let\command=\code 187369626Sru 187469626Sru% @uref (abbreviation for `urlref') takes an optional (comma-separated) 187569626Sru% second argument specifying the text to display and an optional third 187669626Sru% arg as text to display instead of (rather than in addition to) the url 187769626Sru% itself. First (mandatory) arg is the url. Perhaps eventually put in 187869626Sru% a hypertex \special here. 187969626Sru% 188069626Sru\def\uref#1{\douref #1,,,\finish} 188169626Sru\def\douref#1,#2,#3,#4\finish{\begingroup 188269626Sru \unsepspaces 188369626Sru \pdfurl{#1}% 188469626Sru \setbox0 = \hbox{\ignorespaces #3}% 188569626Sru \ifdim\wd0 > 0pt 188669626Sru \unhbox0 % third arg given, show only that 188769626Sru \else 188869626Sru \setbox0 = \hbox{\ignorespaces #2}% 188969626Sru \ifdim\wd0 > 0pt 189069626Sru \ifpdf 189169626Sru \unhbox0 % PDF: 2nd arg given, show only it 189269626Sru \else 189369626Sru \unhbox0\ (\code{#1})% DVI: 2nd arg given, show both it and url 189469626Sru \fi 189569626Sru \else 189669626Sru \code{#1}% only url given, so show it 189769626Sru \fi 189869626Sru \fi 189969626Sru \endlink 190069626Sru\endgroup} 190169626Sru 1902151497Sru% @url synonym for @uref, since that's how everyone uses it. 1903151497Sru% 1904151497Sru\let\url=\uref 1905151497Sru 190669626Sru% rms does not like angle brackets --karl, 17may97. 190769626Sru% So now @email is just like @uref, unless we are pdf. 1908151497Sru% 190969626Sru%\def\email#1{\angleleft{\tt #1}\angleright} 191069626Sru\ifpdf 191169626Sru \def\email#1{\doemail#1,,\finish} 191269626Sru \def\doemail#1,#2,#3\finish{\begingroup 191369626Sru \unsepspaces 191469626Sru \pdfurl{mailto:#1}% 191569626Sru \setbox0 = \hbox{\ignorespaces #2}% 191669626Sru \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi 191769626Sru \endlink 191869626Sru \endgroup} 191969626Sru\else 192069626Sru \let\email=\uref 192169626Sru\fi 192269626Sru 192369626Sru% Check if we are currently using a typewriter font. Since all the 192469626Sru% Computer Modern typewriter fonts have zero interword stretch (and 192569626Sru% shrink), and it is reasonable to expect all typewriter fonts to have 192669626Sru% this property, we can check that font parameter. 192769626Sru% 192869626Sru\def\ifmonospace{\ifdim\fontdimen3\font=0pt } 192969626Sru 193069626Sru% Typeset a dimension, e.g., `in' or `pt'. The only reason for the 193169626Sru% argument is to make the input look right: @dmn{pt} instead of @dmn{}pt. 193269626Sru% 193369626Sru\def\dmn#1{\thinspace #1} 193469626Sru 193569626Sru\def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par} 193669626Sru 193769626Sru% @l was never documented to mean ``switch to the Lisp font'', 193869626Sru% and it is not used as such in any manual I can find. We need it for 193969626Sru% Polish suppressed-l. --karl, 22sep96. 194069626Sru%\def\l#1{{\li #1}\null} 194169626Sru 194269626Sru% Explicit font changes: @r, @sc, undocumented @ii. 194369626Sru\def\r#1{{\rm #1}} % roman font 194469626Sru\def\sc#1{{\smallcaps#1}} % smallcaps font 194569626Sru\def\ii#1{{\it #1}} % italic font 194669626Sru 1947151497Sru% @acronym for "FBI", "NATO", and the like. 1948151497Sru% We print this one point size smaller, since it's intended for 1949151497Sru% all-uppercase. 1950151497Sru% 1951151497Sru\def\acronym#1{\doacronym #1,,\finish} 1952151497Sru\def\doacronym#1,#2,#3\finish{% 1953151497Sru {\selectfonts\lsize #1}% 1954151497Sru \def\temp{#2}% 1955151497Sru \ifx\temp\empty \else 1956151497Sru \space ({\unsepspaces \ignorespaces \temp \unskip})% 1957151497Sru \fi 1958151497Sru} 195969626Sru 1960151497Sru% @abbr for "Comput. J." and the like. 1961151497Sru% No font change, but don't do end-of-sentence spacing. 1962151497Sru% 1963151497Sru\def\abbr#1{\doabbr #1,,\finish} 1964151497Sru\def\doabbr#1,#2,#3\finish{% 1965151497Sru {\frenchspacing #1}% 1966151497Sru \def\temp{#2}% 1967151497Sru \ifx\temp\empty \else 1968151497Sru \space ({\unsepspaces \ignorespaces \temp \unskip})% 1969151497Sru \fi 1970151497Sru} 1971151497Sru 1972151497Sru% @pounds{} is a sterling sign, which Knuth put in the CM italic font. 1973151497Sru% 197469626Sru\def\pounds{{\it\$}} 197569626Sru 1976151497Sru% @euro{} comes from a separate font, depending on the current style. 1977151497Sru% We use the free feym* fonts from the eurosym package by Henrik 1978151497Sru% Theiling, which support regular, slanted, bold and bold slanted (and 1979151497Sru% "outlined" (blackboard board, sort of) versions, which we don't need). 1980151497Sru% It is available from http://www.ctan.org/tex-archive/fonts/eurosym. 1981151497Sru% 1982151497Sru% Although only regular is the truly official Euro symbol, we ignore 1983151497Sru% that. The Euro is designed to be slightly taller than the regular 1984151497Sru% font height. 1985151497Sru% 1986151497Sru% feymr - regular 1987151497Sru% feymo - slanted 1988151497Sru% feybr - bold 1989151497Sru% feybo - bold slanted 1990151497Sru% 1991151497Sru% There is no good (free) typewriter version, to my knowledge. 1992151497Sru% A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide. 1993151497Sru% Hmm. 1994151497Sru% 1995151497Sru% Also doesn't work in math. Do we need to do math with euro symbols? 1996151497Sru% Hope not. 1997151497Sru% 1998151497Sru% 1999151497Sru\def\euro{{\eurofont e}} 2000151497Sru\def\eurofont{% 2001151497Sru % We set the font at each command, rather than predefining it in 2002151497Sru % \textfonts and the other font-switching commands, so that 2003151497Sru % installations which never need the symbold don't have to have the 2004151497Sru % font installed. 2005151497Sru % 2006151497Sru % There is only one designed size (nominal 10pt), so we always scale 2007151497Sru % that to the current nominal size. 2008151497Sru % 2009151497Sru % By the way, simply using "at 1em" works for cmr10 and the like, but 2010151497Sru % does not work for cmbx10 and other extended/shrunken fonts. 2011151497Sru % 2012151497Sru \def\eurosize{\csname\curfontsize nominalsize\endcsname}% 2013151497Sru % 2014151497Sru \ifx\curfontstyle\bfstylename 2015151497Sru % bold: 2016151497Sru \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize 2017151497Sru \else 2018151497Sru % regular: 2019151497Sru \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize 2020151497Sru \fi 2021151497Sru \thiseurofont 2022151497Sru} 2023151497Sru 2024151497Sru% @registeredsymbol - R in a circle. The font for the R should really 2025151497Sru% be smaller yet, but lllsize is the best we can do for now. 2026114402Sru% Adapted from the plain.tex definition of \copyright. 2027151497Sru% 2028114402Sru\def\registeredsymbol{% 2029151497Sru $^{{\ooalign{\hfil\raise.07ex\hbox{\selectfonts\lllsize R}% 2030151497Sru \hfil\crcr\Orb}}% 2031114402Sru }$% 2032114402Sru} 203369626Sru 2034151497Sru% Laurent Siebenmann reports \Orb undefined with: 2035151497Sru% Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38 2036151497Sru% so we'll define it if necessary. 2037151497Sru% 2038151497Sru\ifx\Orb\undefined 2039151497Sru\def\Orb{\mathhexbox20D} 2040151497Sru\fi 2041114402Sru 2042151497Sru 204369626Sru\message{page headings,} 204469626Sru 204569626Sru\newskip\titlepagetopglue \titlepagetopglue = 1.5in 204669626Sru\newskip\titlepagebottomglue \titlepagebottomglue = 2pc 204769626Sru 204869626Sru% First the title page. Must do @settitle before @titlepage. 204969626Sru\newif\ifseenauthor 205069626Sru\newif\iffinishedtitlepage 205169626Sru 205269626Sru% Do an implicit @contents or @shortcontents after @end titlepage if the 205369626Sru% user says @setcontentsaftertitlepage or @setshortcontentsaftertitlepage. 205469626Sru% 205569626Sru\newif\ifsetcontentsaftertitlepage 205669626Sru \let\setcontentsaftertitlepage = \setcontentsaftertitlepagetrue 205769626Sru\newif\ifsetshortcontentsaftertitlepage 205869626Sru \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue 205969626Sru 2060151497Sru\parseargdef\shorttitlepage{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}% 206169626Sru \endgroup\page\hbox{}\page} 206269626Sru 2063151497Sru\envdef\titlepage{% 2064151497Sru % Open one extra group, as we want to close it in the middle of \Etitlepage. 2065151497Sru \begingroup 2066151497Sru \parindent=0pt \textfonts 2067151497Sru % Leave some space at the very top of the page. 2068151497Sru \vglue\titlepagetopglue 2069151497Sru % No rule at page bottom unless we print one at the top with @title. 2070151497Sru \finishedtitlepagetrue 2071151497Sru % 2072151497Sru % Most title ``pages'' are actually two pages long, with space 2073151497Sru % at the top of the second. We don't want the ragged left on the second. 2074151497Sru \let\oldpage = \page 2075151497Sru \def\page{% 207669626Sru \iffinishedtitlepage\else 2077151497Sru \finishtitlepage 207869626Sru \fi 207969626Sru \let\page = \oldpage 2080151497Sru \page 2081151497Sru \null 2082151497Sru }% 208369626Sru} 208469626Sru 208569626Sru\def\Etitlepage{% 2086151497Sru \iffinishedtitlepage\else 2087151497Sru \finishtitlepage 2088151497Sru \fi 2089151497Sru % It is important to do the page break before ending the group, 2090151497Sru % because the headline and footline are only empty inside the group. 2091151497Sru % If we use the new definition of \page, we always get a blank page 2092151497Sru % after the title page, which we certainly don't want. 2093151497Sru \oldpage 2094151497Sru \endgroup 2095151497Sru % 2096151497Sru % Need this before the \...aftertitlepage checks so that if they are 2097151497Sru % in effect the toc pages will come out with page numbers. 2098151497Sru \HEADINGSon 2099151497Sru % 2100151497Sru % If they want short, they certainly want long too. 2101151497Sru \ifsetshortcontentsaftertitlepage 2102151497Sru \shortcontents 2103151497Sru \contents 2104151497Sru \global\let\shortcontents = \relax 2105151497Sru \global\let\contents = \relax 2106151497Sru \fi 2107151497Sru % 2108151497Sru \ifsetcontentsaftertitlepage 2109151497Sru \contents 2110151497Sru \global\let\contents = \relax 2111151497Sru \global\let\shortcontents = \relax 2112151497Sru \fi 211369626Sru} 211469626Sru 211569626Sru\def\finishtitlepage{% 2116151497Sru \vskip4pt \hrule height 2pt width \hsize 2117151497Sru \vskip\titlepagebottomglue 2118151497Sru \finishedtitlepagetrue 211969626Sru} 212069626Sru 2121151497Sru%%% Macros to be used within @titlepage: 2122151497Sru 2123151497Sru\let\subtitlerm=\tenrm 2124151497Sru\def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines} 2125151497Sru 2126151497Sru\def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines 2127151497Sru \let\tt=\authortt} 2128151497Sru 2129151497Sru\parseargdef\title{% 2130151497Sru \checkenv\titlepage 2131151497Sru \leftline{\titlefonts\rm #1} 2132151497Sru % print a rule at the page bottom also. 2133151497Sru \finishedtitlepagefalse 2134151497Sru \vskip4pt \hrule height 4pt width \hsize \vskip4pt 2135151497Sru} 2136151497Sru 2137151497Sru\parseargdef\subtitle{% 2138151497Sru \checkenv\titlepage 2139151497Sru {\subtitlefont \rightline{#1}}% 2140151497Sru} 2141151497Sru 2142151497Sru% @author should come last, but may come many times. 2143151497Sru% It can also be used inside @quotation. 2144151497Sru% 2145151497Sru\parseargdef\author{% 2146151497Sru \def\temp{\quotation}% 2147151497Sru \ifx\thisenv\temp 2148151497Sru \def\quotationauthor{#1}% printed in \Equotation. 2149151497Sru \else 2150151497Sru \checkenv\titlepage 2151151497Sru \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi 2152151497Sru {\authorfont \leftline{#1}}% 2153151497Sru \fi 2154151497Sru} 2155151497Sru 2156151497Sru 215769626Sru%%% Set up page headings and footings. 215869626Sru 215969626Sru\let\thispage=\folio 216069626Sru 216169626Sru\newtoks\evenheadline % headline on even pages 216269626Sru\newtoks\oddheadline % headline on odd pages 216369626Sru\newtoks\evenfootline % footline on even pages 216469626Sru\newtoks\oddfootline % footline on odd pages 216569626Sru 2166151497Sru% Now make TeX use those variables 216769626Sru\headline={{\textfonts\rm \ifodd\pageno \the\oddheadline 216869626Sru \else \the\evenheadline \fi}} 216969626Sru\footline={{\textfonts\rm \ifodd\pageno \the\oddfootline 217069626Sru \else \the\evenfootline \fi}\HEADINGShook} 217169626Sru\let\HEADINGShook=\relax 217269626Sru 217369626Sru% Commands to set those variables. 217469626Sru% For example, this is what @headings on does 217569626Sru% @evenheading @thistitle|@thispage|@thischapter 217669626Sru% @oddheading @thischapter|@thispage|@thistitle 217769626Sru% @evenfooting @thisfile|| 217869626Sru% @oddfooting ||@thisfile 217969626Sru 2180151497Sru 218169626Sru\def\evenheading{\parsearg\evenheadingxxx} 2182151497Sru\def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish} 2183151497Sru\def\evenheadingyyy #1\|#2\|#3\|#4\finish{% 218469626Sru\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} 218569626Sru 2186151497Sru\def\oddheading{\parsearg\oddheadingxxx} 2187151497Sru\def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish} 2188151497Sru\def\oddheadingyyy #1\|#2\|#3\|#4\finish{% 218969626Sru\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} 219069626Sru 2191151497Sru\parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}% 219269626Sru 2193151497Sru\def\evenfooting{\parsearg\evenfootingxxx} 2194151497Sru\def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish} 2195151497Sru\def\evenfootingyyy #1\|#2\|#3\|#4\finish{% 219669626Sru\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} 219769626Sru 2198151497Sru\def\oddfooting{\parsearg\oddfootingxxx} 2199151497Sru\def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish} 2200151497Sru\def\oddfootingyyy #1\|#2\|#3\|#4\finish{% 220169626Sru \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}% 220269626Sru % 220369626Sru % Leave some space for the footline. Hopefully ok to assume 220469626Sru % @evenfooting will not be used by itself. 220569626Sru \global\advance\pageheight by -\baselineskip 220669626Sru \global\advance\vsize by -\baselineskip 220769626Sru} 220869626Sru 2209151497Sru\parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}} 221069626Sru 2211151497Sru 221269626Sru% @headings double turns headings on for double-sided printing. 221369626Sru% @headings single turns headings on for single-sided printing. 221469626Sru% @headings off turns them off. 221569626Sru% @headings on same as @headings double, retained for compatibility. 221669626Sru% @headings after turns on double-sided headings after this page. 221769626Sru% @headings doubleafter turns on double-sided headings after this page. 221869626Sru% @headings singleafter turns on single-sided headings after this page. 221969626Sru% By default, they are off at the start of a document, 222069626Sru% and turned `on' after @end titlepage. 222169626Sru 222269626Sru\def\headings #1 {\csname HEADINGS#1\endcsname} 222369626Sru 2224151497Sru\def\HEADINGSoff{% 222569626Sru\global\evenheadline={\hfil} \global\evenfootline={\hfil} 222669626Sru\global\oddheadline={\hfil} \global\oddfootline={\hfil}} 222769626Sru\HEADINGSoff 222869626Sru% When we turn headings on, set the page number to 1. 222969626Sru% For double-sided printing, put current file name in lower left corner, 223069626Sru% chapter name on inside top of right hand pages, document 223169626Sru% title on inside top of left hand pages, and page numbers on outside top 223269626Sru% edge of all pages. 2233151497Sru\def\HEADINGSdouble{% 223469626Sru\global\pageno=1 223569626Sru\global\evenfootline={\hfil} 223669626Sru\global\oddfootline={\hfil} 223769626Sru\global\evenheadline={\line{\folio\hfil\thistitle}} 223869626Sru\global\oddheadline={\line{\thischapter\hfil\folio}} 223969626Sru\global\let\contentsalignmacro = \chapoddpage 224069626Sru} 224169626Sru\let\contentsalignmacro = \chappager 224269626Sru 224369626Sru% For single-sided printing, chapter title goes across top left of page, 224469626Sru% page number on top right. 2245151497Sru\def\HEADINGSsingle{% 224669626Sru\global\pageno=1 224769626Sru\global\evenfootline={\hfil} 224869626Sru\global\oddfootline={\hfil} 224969626Sru\global\evenheadline={\line{\thischapter\hfil\folio}} 225069626Sru\global\oddheadline={\line{\thischapter\hfil\folio}} 225169626Sru\global\let\contentsalignmacro = \chappager 225269626Sru} 225369626Sru\def\HEADINGSon{\HEADINGSdouble} 225469626Sru 225569626Sru\def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex} 225669626Sru\let\HEADINGSdoubleafter=\HEADINGSafter 225769626Sru\def\HEADINGSdoublex{% 225869626Sru\global\evenfootline={\hfil} 225969626Sru\global\oddfootline={\hfil} 226069626Sru\global\evenheadline={\line{\folio\hfil\thistitle}} 226169626Sru\global\oddheadline={\line{\thischapter\hfil\folio}} 226269626Sru\global\let\contentsalignmacro = \chapoddpage 226369626Sru} 226469626Sru 226569626Sru\def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex} 226669626Sru\def\HEADINGSsinglex{% 226769626Sru\global\evenfootline={\hfil} 226869626Sru\global\oddfootline={\hfil} 226969626Sru\global\evenheadline={\line{\thischapter\hfil\folio}} 227069626Sru\global\oddheadline={\line{\thischapter\hfil\folio}} 227169626Sru\global\let\contentsalignmacro = \chappager 227269626Sru} 227369626Sru 227469626Sru% Subroutines used in generating headings 227569626Sru% This produces Day Month Year style of output. 227669626Sru% Only define if not already defined, in case a txi-??.tex file has set 227769626Sru% up a different format (e.g., txi-cs.tex does this). 227869626Sru\ifx\today\undefined 227969626Sru\def\today{% 228069626Sru \number\day\space 228169626Sru \ifcase\month 228269626Sru \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr 228369626Sru \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug 228469626Sru \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec 228569626Sru \fi 228669626Sru \space\number\year} 228769626Sru\fi 228869626Sru 228969626Sru% @settitle line... specifies the title of the document, for headings. 229069626Sru% It generates no output of its own. 229169626Sru\def\thistitle{\putwordNoTitle} 2292151497Sru\def\settitle{\parsearg{\gdef\thistitle}} 229369626Sru 229469626Sru 229569626Sru\message{tables,} 2296151497Sru% Tables -- @table, @ftable, @vtable, @item(x). 229769626Sru 229869626Sru% default indentation of table text 229969626Sru\newdimen\tableindent \tableindent=.8in 230069626Sru% default indentation of @itemize and @enumerate text 230169626Sru\newdimen\itemindent \itemindent=.3in 230269626Sru% margin between end of table item and start of table text. 230369626Sru\newdimen\itemmargin \itemmargin=.1in 230469626Sru 230569626Sru% used internally for \itemindent minus \itemmargin 230669626Sru\newdimen\itemmax 230769626Sru 2308151497Sru% Note @table, @ftable, and @vtable define @item, @itemx, etc., with 230969626Sru% these defs. 231069626Sru% They also define \itemindex 231169626Sru% to index the item name in whatever manner is desired (perhaps none). 231269626Sru 231369626Sru\newif\ifitemxneedsnegativevskip 231469626Sru 231569626Sru\def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi} 231669626Sru 231769626Sru\def\internalBitem{\smallbreak \parsearg\itemzzz} 231869626Sru\def\internalBitemx{\itemxpar \parsearg\itemzzz} 231969626Sru 232069626Sru\def\itemzzz #1{\begingroup % 232169626Sru \advance\hsize by -\rightskip 232269626Sru \advance\hsize by -\tableindent 2323151497Sru \setbox0=\hbox{\itemindicate{#1}}% 232469626Sru \itemindex{#1}% 232569626Sru \nobreak % This prevents a break before @itemx. 232669626Sru % 232769626Sru % If the item text does not fit in the space we have, put it on a line 232869626Sru % by itself, and do not allow a page break either before or after that 232969626Sru % line. We do not start a paragraph here because then if the next 233069626Sru % command is, e.g., @kindex, the whatsit would get put into the 233169626Sru % horizontal list on a line by itself, resulting in extra blank space. 233269626Sru \ifdim \wd0>\itemmax 233369626Sru % 233469626Sru % Make this a paragraph so we get the \parskip glue and wrapping, 233569626Sru % but leave it ragged-right. 233669626Sru \begingroup 233769626Sru \advance\leftskip by-\tableindent 233869626Sru \advance\hsize by\tableindent 233969626Sru \advance\rightskip by0pt plus1fil 234069626Sru \leavevmode\unhbox0\par 234169626Sru \endgroup 234269626Sru % 234369626Sru % We're going to be starting a paragraph, but we don't want the 234469626Sru % \parskip glue -- logically it's part of the @item we just started. 234569626Sru \nobreak \vskip-\parskip 234669626Sru % 2347151497Sru % Stop a page break at the \parskip glue coming up. However, if 2348151497Sru % what follows is an environment such as @example, there will be no 2349151497Sru % \parskip glue; then the negative vskip we just inserted would 2350151497Sru % cause the example and the item to crash together. So we use this 2351151497Sru % bizarre value of 10001 as a signal to \aboveenvbreak to insert 2352151497Sru % \parskip glue after all. Section titles are handled this way also. 2353151497Sru % 2354114402Sru \penalty 10001 235569626Sru \endgroup 235669626Sru \itemxneedsnegativevskipfalse 235769626Sru \else 235869626Sru % The item text fits into the space. Start a paragraph, so that the 235969626Sru % following text (if any) will end up on the same line. 236069626Sru \noindent 236169626Sru % Do this with kerns and \unhbox so that if there is a footnote in 236269626Sru % the item text, it can migrate to the main vertical list and 236369626Sru % eventually be printed. 236469626Sru \nobreak\kern-\tableindent 236569626Sru \dimen0 = \itemmax \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0 236669626Sru \unhbox0 236769626Sru \nobreak\kern\dimen0 236869626Sru \endgroup 236969626Sru \itemxneedsnegativevskiptrue 237069626Sru \fi 237169626Sru} 237269626Sru 2373151497Sru\def\item{\errmessage{@item while not in a list environment}} 2374151497Sru\def\itemx{\errmessage{@itemx while not in a list environment}} 237569626Sru 237669626Sru% @table, @ftable, @vtable. 2377151497Sru\envdef\table{% 2378151497Sru \let\itemindex\gobble 2379151497Sru \tablecheck{table}% 238069626Sru} 2381151497Sru\envdef\ftable{% 2382151497Sru \def\itemindex ##1{\doind {fn}{\code{##1}}}% 2383151497Sru \tablecheck{ftable}% 2384151497Sru} 2385151497Sru\envdef\vtable{% 2386151497Sru \def\itemindex ##1{\doind {vr}{\code{##1}}}% 2387151497Sru \tablecheck{vtable}% 2388151497Sru} 2389151497Sru\def\tablecheck#1{% 2390151497Sru \ifnum \the\catcode`\^^M=\active 2391151497Sru \endgroup 2392151497Sru \errmessage{This command won't work in this context; perhaps the problem is 2393151497Sru that we are \inenvironment\thisenv}% 2394151497Sru \def\next{\doignore{#1}}% 2395151497Sru \else 2396151497Sru \let\next\tablex 2397151497Sru \fi 2398151497Sru \next 2399151497Sru} 2400151497Sru\def\tablex#1{% 2401151497Sru \def\itemindicate{#1}% 2402151497Sru \parsearg\tabley 2403151497Sru} 2404151497Sru\def\tabley#1{% 2405151497Sru {% 2406151497Sru \makevalueexpandable 2407151497Sru \edef\temp{\noexpand\tablez #1\space\space\space}% 2408151497Sru \expandafter 2409151497Sru }\temp \endtablez 2410151497Sru} 2411151497Sru\def\tablez #1 #2 #3 #4\endtablez{% 2412151497Sru \aboveenvbreak 2413151497Sru \ifnum 0#1>0 \advance \leftskip by #1\mil \fi 2414151497Sru \ifnum 0#2>0 \tableindent=#2\mil \fi 2415151497Sru \ifnum 0#3>0 \advance \rightskip by #3\mil \fi 2416151497Sru \itemmax=\tableindent 2417151497Sru \advance \itemmax by -\itemmargin 2418151497Sru \advance \leftskip by \tableindent 2419151497Sru \exdentamount=\tableindent 2420151497Sru \parindent = 0pt 2421151497Sru \parskip = \smallskipamount 2422151497Sru \ifdim \parskip=0pt \parskip=2pt \fi 2423151497Sru \let\item = \internalBitem 2424151497Sru \let\itemx = \internalBitemx 2425151497Sru} 2426151497Sru\def\Etable{\endgraf\afterenvbreak} 2427151497Sru\let\Eftable\Etable 2428151497Sru\let\Evtable\Etable 2429151497Sru\let\Eitemize\Etable 2430151497Sru\let\Eenumerate\Etable 243169626Sru 243269626Sru% This is the counter used by @enumerate, which is really @itemize 243369626Sru 243469626Sru\newcount \itemno 243569626Sru 2436151497Sru\envdef\itemize{\parsearg\doitemize} 243769626Sru 2438151497Sru\def\doitemize#1{% 2439151497Sru \aboveenvbreak 2440151497Sru \itemmax=\itemindent 2441151497Sru \advance\itemmax by -\itemmargin 2442151497Sru \advance\leftskip by \itemindent 2443151497Sru \exdentamount=\itemindent 2444151497Sru \parindent=0pt 2445151497Sru \parskip=\smallskipamount 2446151497Sru \ifdim\parskip=0pt \parskip=2pt \fi 2447151497Sru \def\itemcontents{#1}% 2448151497Sru % @itemize with no arg is equivalent to @itemize @bullet. 2449151497Sru \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi 2450151497Sru \let\item=\itemizeitem 245169626Sru} 245269626Sru 2453151497Sru% Definition of @item while inside @itemize and @enumerate. 2454151497Sru% 2455151497Sru\def\itemizeitem{% 2456151497Sru \advance\itemno by 1 % for enumerations 2457151497Sru {\let\par=\endgraf \smallbreak}% reasonable place to break 2458151497Sru {% 2459151497Sru % If the document has an @itemize directly after a section title, a 2460151497Sru % \nobreak will be last on the list, and \sectionheading will have 2461151497Sru % done a \vskip-\parskip. In that case, we don't want to zero 2462151497Sru % parskip, or the item text will crash with the heading. On the 2463151497Sru % other hand, when there is normal text preceding the item (as there 2464151497Sru % usually is), we do want to zero parskip, or there would be too much 2465151497Sru % space. In that case, we won't have a \nobreak before. At least 2466151497Sru % that's the theory. 2467151497Sru \ifnum\lastpenalty<10000 \parskip=0in \fi 2468151497Sru \noindent 2469151497Sru \hbox to 0pt{\hss \itemcontents \kern\itemmargin}% 2470151497Sru \vadjust{\penalty 1200}}% not good to break after first line of item. 2471151497Sru \flushcr 2472151497Sru} 247369626Sru 247469626Sru% \splitoff TOKENS\endmark defines \first to be the first token in 247569626Sru% TOKENS, and \rest to be the remainder. 247669626Sru% 247769626Sru\def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}% 247869626Sru 247969626Sru% Allow an optional argument of an uppercase letter, lowercase letter, 248069626Sru% or number, to specify the first label in the enumerated list. No 248169626Sru% argument is the same as `1'. 248269626Sru% 2483151497Sru\envparseargdef\enumerate{\enumeratey #1 \endenumeratey} 248469626Sru\def\enumeratey #1 #2\endenumeratey{% 248569626Sru % If we were given no argument, pretend we were given `1'. 248669626Sru \def\thearg{#1}% 248769626Sru \ifx\thearg\empty \def\thearg{1}\fi 248869626Sru % 248969626Sru % Detect if the argument is a single token. If so, it might be a 249069626Sru % letter. Otherwise, the only valid thing it can be is a number. 249169626Sru % (We will always have one token, because of the test we just made. 249269626Sru % This is a good thing, since \splitoff doesn't work given nothing at 249369626Sru % all -- the first parameter is undelimited.) 249469626Sru \expandafter\splitoff\thearg\endmark 249569626Sru \ifx\rest\empty 249669626Sru % Only one token in the argument. It could still be anything. 249769626Sru % A ``lowercase letter'' is one whose \lccode is nonzero. 249869626Sru % An ``uppercase letter'' is one whose \lccode is both nonzero, and 249969626Sru % not equal to itself. 250069626Sru % Otherwise, we assume it's a number. 250169626Sru % 250269626Sru % We need the \relax at the end of the \ifnum lines to stop TeX from 250369626Sru % continuing to look for a <number>. 250469626Sru % 250569626Sru \ifnum\lccode\expandafter`\thearg=0\relax 250669626Sru \numericenumerate % a number (we hope) 250769626Sru \else 250869626Sru % It's a letter. 250969626Sru \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax 251069626Sru \lowercaseenumerate % lowercase letter 251169626Sru \else 251269626Sru \uppercaseenumerate % uppercase letter 251369626Sru \fi 251469626Sru \fi 251569626Sru \else 251669626Sru % Multiple tokens in the argument. We hope it's a number. 251769626Sru \numericenumerate 251869626Sru \fi 251969626Sru} 252069626Sru 252169626Sru% An @enumerate whose labels are integers. The starting integer is 252269626Sru% given in \thearg. 252369626Sru% 252469626Sru\def\numericenumerate{% 252569626Sru \itemno = \thearg 252669626Sru \startenumeration{\the\itemno}% 252769626Sru} 252869626Sru 252969626Sru% The starting (lowercase) letter is in \thearg. 253069626Sru\def\lowercaseenumerate{% 253169626Sru \itemno = \expandafter`\thearg 253269626Sru \startenumeration{% 253369626Sru % Be sure we're not beyond the end of the alphabet. 253469626Sru \ifnum\itemno=0 253569626Sru \errmessage{No more lowercase letters in @enumerate; get a bigger 253669626Sru alphabet}% 253769626Sru \fi 253869626Sru \char\lccode\itemno 253969626Sru }% 254069626Sru} 254169626Sru 254269626Sru% The starting (uppercase) letter is in \thearg. 254369626Sru\def\uppercaseenumerate{% 254469626Sru \itemno = \expandafter`\thearg 254569626Sru \startenumeration{% 254669626Sru % Be sure we're not beyond the end of the alphabet. 254769626Sru \ifnum\itemno=0 254869626Sru \errmessage{No more uppercase letters in @enumerate; get a bigger 254969626Sru alphabet} 255069626Sru \fi 255169626Sru \char\uccode\itemno 255269626Sru }% 255369626Sru} 255469626Sru 2555151497Sru% Call \doitemize, adding a period to the first argument and supplying the 255669626Sru% common last two arguments. Also subtract one from the initial value in 255769626Sru% \itemno, since @item increments \itemno. 255869626Sru% 255969626Sru\def\startenumeration#1{% 256069626Sru \advance\itemno by -1 2561151497Sru \doitemize{#1.}\flushcr 256269626Sru} 256369626Sru 256469626Sru% @alphaenumerate and @capsenumerate are abbreviations for giving an arg 256569626Sru% to @enumerate. 256669626Sru% 256769626Sru\def\alphaenumerate{\enumerate{a}} 256869626Sru\def\capsenumerate{\enumerate{A}} 256969626Sru\def\Ealphaenumerate{\Eenumerate} 257069626Sru\def\Ecapsenumerate{\Eenumerate} 257169626Sru 257269626Sru 257369626Sru% @multitable macros 257469626Sru% Amy Hendrickson, 8/18/94, 3/6/96 257569626Sru% 257669626Sru% @multitable ... @end multitable will make as many columns as desired. 257769626Sru% Contents of each column will wrap at width given in preamble. Width 257869626Sru% can be specified either with sample text given in a template line, 257969626Sru% or in percent of \hsize, the current width of text on page. 258069626Sru 258169626Sru% Table can continue over pages but will only break between lines. 258269626Sru 258369626Sru% To make preamble: 258469626Sru% 258569626Sru% Either define widths of columns in terms of percent of \hsize: 258669626Sru% @multitable @columnfractions .25 .3 .45 258769626Sru% @item ... 258869626Sru% 258969626Sru% Numbers following @columnfractions are the percent of the total 259069626Sru% current hsize to be used for each column. You may use as many 259169626Sru% columns as desired. 259269626Sru 259369626Sru 259469626Sru% Or use a template: 259569626Sru% @multitable {Column 1 template} {Column 2 template} {Column 3 template} 259669626Sru% @item ... 259769626Sru% using the widest term desired in each column. 259869626Sru 259969626Sru% Each new table line starts with @item, each subsequent new column 260069626Sru% starts with @tab. Empty columns may be produced by supplying @tab's 260169626Sru% with nothing between them for as many times as empty columns are needed, 260269626Sru% ie, @tab@tab@tab will produce two empty columns. 260369626Sru 2604151497Sru% @item, @tab do not need to be on their own lines, but it will not hurt 2605151497Sru% if they are. 260669626Sru 260769626Sru% Sample multitable: 260869626Sru 260969626Sru% @multitable {Column 1 template} {Column 2 template} {Column 3 template} 261069626Sru% @item first col stuff @tab second col stuff @tab third col 261169626Sru% @item 261269626Sru% first col stuff 261369626Sru% @tab 261469626Sru% second col stuff 261569626Sru% @tab 261669626Sru% third col 261769626Sru% @item first col stuff @tab second col stuff 261869626Sru% @tab Many paragraphs of text may be used in any column. 261969626Sru% 262069626Sru% They will wrap at the width determined by the template. 262169626Sru% @item@tab@tab This will be in third column. 262269626Sru% @end multitable 262369626Sru 262469626Sru% Default dimensions may be reset by user. 262569626Sru% @multitableparskip is vertical space between paragraphs in table. 262669626Sru% @multitableparindent is paragraph indent in table. 262769626Sru% @multitablecolmargin is horizontal space to be left between columns. 262869626Sru% @multitablelinespace is space to leave between table items, baseline 262969626Sru% to baseline. 263069626Sru% 0pt means it depends on current normal line spacing. 263169626Sru% 263269626Sru\newskip\multitableparskip 263369626Sru\newskip\multitableparindent 263469626Sru\newdimen\multitablecolspace 263569626Sru\newskip\multitablelinespace 263669626Sru\multitableparskip=0pt 263769626Sru\multitableparindent=6pt 263869626Sru\multitablecolspace=12pt 263969626Sru\multitablelinespace=0pt 264069626Sru 264169626Sru% Macros used to set up halign preamble: 264269626Sru% 264369626Sru\let\endsetuptable\relax 264469626Sru\def\xendsetuptable{\endsetuptable} 264569626Sru\let\columnfractions\relax 264669626Sru\def\xcolumnfractions{\columnfractions} 264769626Sru\newif\ifsetpercent 264869626Sru 2649151497Sru% #1 is the @columnfraction, usually a decimal number like .5, but might 2650151497Sru% be just 1. We just use it, whatever it is. 2651151497Sru% 2652151497Sru\def\pickupwholefraction#1 {% 265369626Sru \global\advance\colcount by 1 2654151497Sru \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}% 265569626Sru \setuptable 265669626Sru} 265769626Sru 265869626Sru\newcount\colcount 265969626Sru\def\setuptable#1{% 266069626Sru \def\firstarg{#1}% 266169626Sru \ifx\firstarg\xendsetuptable 266269626Sru \let\go = \relax 266369626Sru \else 266469626Sru \ifx\firstarg\xcolumnfractions 266569626Sru \global\setpercenttrue 266669626Sru \else 266769626Sru \ifsetpercent 266869626Sru \let\go\pickupwholefraction 266969626Sru \else 267069626Sru \global\advance\colcount by 1 2671114402Sru \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a 2672114402Sru % separator; typically that is always in the input, anyway. 267369626Sru \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}% 267469626Sru \fi 267569626Sru \fi 267669626Sru \ifx\go\pickupwholefraction 267769626Sru % Put the argument back for the \pickupwholefraction call, so 267869626Sru % we'll always have a period there to be parsed. 267969626Sru \def\go{\pickupwholefraction#1}% 268069626Sru \else 268169626Sru \let\go = \setuptable 268269626Sru \fi% 268369626Sru \fi 268469626Sru \go 268569626Sru} 268669626Sru 2687151497Sru% multitable-only commands. 2688151497Sru% 2689151497Sru% @headitem starts a heading row, which we typeset in bold. 2690151497Sru% Assignments have to be global since we are inside the implicit group 2691151497Sru% of an alignment entry. Note that \everycr resets \everytab. 2692151497Sru\def\headitem{\checkenv\multitable \crcr \global\everytab={\bf}\the\everytab}% 2693151497Sru% 2694151497Sru% A \tab used to include \hskip1sp. But then the space in a template 2695151497Sru% line is not enough. That is bad. So let's go back to just `&' until 2696151497Sru% we encounter the problem it was intended to solve again. 2697151497Sru% --karl, nathan@acm.org, 20apr99. 2698151497Sru\def\tab{\checkenv\multitable &\the\everytab}% 2699151497Sru 270069626Sru% @multitable ... @end multitable definitions: 270169626Sru% 2702151497Sru\newtoks\everytab % insert after every tab. 2703151497Sru% 2704151497Sru\envdef\multitable{% 270569626Sru \vskip\parskip 2706151497Sru \startsavinginserts 2707151497Sru % 2708151497Sru % @item within a multitable starts a normal row. 2709151497Sru % We use \def instead of \let so that if one of the multitable entries 2710151497Sru % contains an @itemize, we don't choke on the \item (seen as \crcr aka 2711151497Sru % \endtemplate) expanding \doitemize. 2712151497Sru \def\item{\crcr}% 2713151497Sru % 271469626Sru \tolerance=9500 271569626Sru \hbadness=9500 271669626Sru \setmultitablespacing 271769626Sru \parskip=\multitableparskip 271869626Sru \parindent=\multitableparindent 271969626Sru \overfullrule=0pt 272069626Sru \global\colcount=0 2721151497Sru % 2722151497Sru \everycr = {% 2723151497Sru \noalign{% 2724151497Sru \global\everytab={}% 2725151497Sru \global\colcount=0 % Reset the column counter. 2726151497Sru % Check for saved footnotes, etc. 2727151497Sru \checkinserts 2728151497Sru % Keeps underfull box messages off when table breaks over pages. 2729151497Sru %\filbreak 2730151497Sru % Maybe so, but it also creates really weird page breaks when the 2731151497Sru % table breaks over pages. Wouldn't \vfil be better? Wait until the 2732151497Sru % problem manifests itself, so it can be fixed for real --karl. 2733151497Sru }% 2734114402Sru }% 273569626Sru % 2736151497Sru \parsearg\domultitable 2737151497Sru} 2738151497Sru\def\domultitable#1{% 273969626Sru % To parse everything between @multitable and @item: 274069626Sru \setuptable#1 \endsetuptable 274169626Sru % 274269626Sru % This preamble sets up a generic column definition, which will 274369626Sru % be used as many times as user calls for columns. 274469626Sru % \vtop will set a single line and will also let text wrap and 274569626Sru % continue for many paragraphs if desired. 2746151497Sru \halign\bgroup &% 2747151497Sru \global\advance\colcount by 1 2748151497Sru \multistrut 2749151497Sru \vtop{% 2750151497Sru % Use the current \colcount to find the correct column width: 2751151497Sru \hsize=\expandafter\csname col\the\colcount\endcsname 2752151497Sru % 2753151497Sru % In order to keep entries from bumping into each other 2754151497Sru % we will add a \leftskip of \multitablecolspace to all columns after 2755151497Sru % the first one. 2756151497Sru % 2757151497Sru % If a template has been used, we will add \multitablecolspace 2758151497Sru % to the width of each template entry. 2759151497Sru % 2760151497Sru % If the user has set preamble in terms of percent of \hsize we will 2761151497Sru % use that dimension as the width of the column, and the \leftskip 2762151497Sru % will keep entries from bumping into each other. Table will start at 2763151497Sru % left margin and final column will justify at right margin. 2764151497Sru % 2765151497Sru % Make sure we don't inherit \rightskip from the outer environment. 2766151497Sru \rightskip=0pt 2767151497Sru \ifnum\colcount=1 2768151497Sru % The first column will be indented with the surrounding text. 2769151497Sru \advance\hsize by\leftskip 2770151497Sru \else 2771151497Sru \ifsetpercent \else 2772151497Sru % If user has not set preamble in terms of percent of \hsize 2773151497Sru % we will advance \hsize by \multitablecolspace. 2774151497Sru \advance\hsize by \multitablecolspace 2775151497Sru \fi 2776151497Sru % In either case we will make \leftskip=\multitablecolspace: 2777151497Sru \leftskip=\multitablecolspace 2778151497Sru \fi 2779151497Sru % Ignoring space at the beginning and end avoids an occasional spurious 2780151497Sru % blank line, when TeX decides to break the line at the space before the 2781151497Sru % box from the multistrut, so the strut ends up on a line by itself. 2782151497Sru % For example: 2783151497Sru % @multitable @columnfractions .11 .89 2784151497Sru % @item @code{#} 2785151497Sru % @tab Legal holiday which is valid in major parts of the whole country. 2786151497Sru % Is automatically provided with highlighting sequences respectively 2787151497Sru % marking characters. 2788151497Sru \noindent\ignorespaces##\unskip\multistrut 2789151497Sru }\cr 279069626Sru} 2791151497Sru\def\Emultitable{% 2792151497Sru \crcr 2793151497Sru \egroup % end the \halign 2794151497Sru \global\setpercentfalse 2795151497Sru} 279669626Sru 2797151497Sru\def\setmultitablespacing{% 2798151497Sru \def\multistrut{\strut}% just use the standard line spacing 2799151497Sru % 2800151497Sru % Compute \multitablelinespace (if not defined by user) for use in 2801151497Sru % \multitableparskip calculation. We used define \multistrut based on 2802151497Sru % this, but (ironically) that caused the spacing to be off. 2803151497Sru % See bug-texinfo report from Werner Lemberg, 31 Oct 2004 12:52:20 +0100. 280469626Sru\ifdim\multitablelinespace=0pt 280569626Sru\setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip 280669626Sru\global\advance\multitablelinespace by-\ht0 2807151497Sru\fi 280869626Sru%% Test to see if parskip is larger than space between lines of 280969626Sru%% table. If not, do nothing. 281069626Sru%% If so, set to same dimension as multitablelinespace. 281169626Sru\ifdim\multitableparskip>\multitablelinespace 281269626Sru\global\multitableparskip=\multitablelinespace 281369626Sru\global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller 281469626Sru %% than skip between lines in the table. 281569626Sru\fi% 281669626Sru\ifdim\multitableparskip=0pt 281769626Sru\global\multitableparskip=\multitablelinespace 281869626Sru\global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller 281969626Sru %% than skip between lines in the table. 282069626Sru\fi} 282169626Sru 282269626Sru 282369626Sru\message{conditionals,} 282469626Sru 2825151497Sru% @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext, 2826151497Sru% @ifnotxml always succeed. They currently do nothing; we don't 2827151497Sru% attempt to check whether the conditionals are properly nested. But we 2828151497Sru% have to remember that they are conditionals, so that @end doesn't 2829151497Sru% attempt to close an environment group. 283069626Sru% 2831151497Sru\def\makecond#1{% 2832151497Sru \expandafter\let\csname #1\endcsname = \relax 2833151497Sru \expandafter\let\csname iscond.#1\endcsname = 1 283469626Sru} 2835151497Sru\makecond{iftex} 2836151497Sru\makecond{ifnotdocbook} 2837151497Sru\makecond{ifnothtml} 2838151497Sru\makecond{ifnotinfo} 2839151497Sru\makecond{ifnotplaintext} 2840151497Sru\makecond{ifnotxml} 284169626Sru 2842114402Sru% Ignore @ignore, @ifhtml, @ifinfo, and the like. 284369626Sru% 2844114402Sru\def\direntry{\doignore{direntry}} 2845114402Sru\def\documentdescription{\doignore{documentdescription}} 2846151497Sru\def\docbook{\doignore{docbook}} 2847114402Sru\def\html{\doignore{html}} 2848151497Sru\def\ifdocbook{\doignore{ifdocbook}} 2849104862Sru\def\ifhtml{\doignore{ifhtml}} 285069626Sru\def\ifinfo{\doignore{ifinfo}} 2851114402Sru\def\ifnottex{\doignore{ifnottex}} 2852104862Sru\def\ifplaintext{\doignore{ifplaintext}} 2853114402Sru\def\ifxml{\doignore{ifxml}} 2854114402Sru\def\ignore{\doignore{ignore}} 285569626Sru\def\menu{\doignore{menu}} 2856114402Sru\def\xml{\doignore{xml}} 285769626Sru 2858151497Sru% Ignore text until a line `@end #1', keeping track of nested conditionals. 2859151497Sru% 2860151497Sru% A count to remember the depth of nesting. 2861151497Sru\newcount\doignorecount 286269626Sru 286369626Sru\def\doignore#1{\begingroup 2864151497Sru % Scan in ``verbatim'' mode: 2865151497Sru \catcode`\@ = \other 2866151497Sru \catcode`\{ = \other 2867151497Sru \catcode`\} = \other 286869626Sru % 286969626Sru % Make sure that spaces turn into tokens that match what \doignoretext wants. 2870151497Sru \spaceisspace 287169626Sru % 2872151497Sru % Count number of #1's that we've seen. 2873151497Sru \doignorecount = 0 287469626Sru % 2875151497Sru % Swallow text until we reach the matching `@end #1'. 2876151497Sru \dodoignore{#1}% 2877151497Sru} 2878151497Sru 2879151497Sru{ \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source. 2880151497Sru \obeylines % 288169626Sru % 2882151497Sru \gdef\dodoignore#1{% 2883151497Sru % #1 contains the command name as a string, e.g., `ifinfo'. 2884151497Sru % 2885151497Sru % Define a command to find the next `@end #1', which must be on a line 2886151497Sru % by itself. 2887151497Sru \long\def\doignoretext##1^^M@end #1{\doignoretextyyy##1^^M@#1\_STOP_}% 2888151497Sru % And this command to find another #1 command, at the beginning of a 2889151497Sru % line. (Otherwise, we would consider a line `@c @ifset', for 2890151497Sru % example, to count as an @ifset for nesting.) 2891151497Sru \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}% 2892151497Sru % 2893151497Sru % And now expand that command. 2894151497Sru \obeylines % 2895151497Sru \doignoretext ^^M% 2896151497Sru }% 2897151497Sru} 2898151497Sru 2899151497Sru\def\doignoreyyy#1{% 2900151497Sru \def\temp{#1}% 2901151497Sru \ifx\temp\empty % Nothing found. 2902151497Sru \let\next\doignoretextzzz 2903151497Sru \else % Found a nested condition, ... 2904151497Sru \advance\doignorecount by 1 2905151497Sru \let\next\doignoretextyyy % ..., look for another. 2906151497Sru % If we're here, #1 ends with ^^M\ifinfo (for example). 2907104862Sru \fi 2908151497Sru \next #1% the token \_STOP_ is present just after this macro. 290969626Sru} 291069626Sru 2911151497Sru% We have to swallow the remaining "\_STOP_". 291269626Sru% 2913151497Sru\def\doignoretextzzz#1{% 2914151497Sru \ifnum\doignorecount = 0 % We have just found the outermost @end. 2915151497Sru \let\next\enddoignore 2916151497Sru \else % Still inside a nested condition. 2917151497Sru \advance\doignorecount by -1 2918151497Sru \let\next\doignoretext % Look for the next @end. 2919151497Sru \fi 2920151497Sru \next 292169626Sru} 292269626Sru 2923151497Sru% Finish off ignored text. 2924151497Sru\def\enddoignore{\endgroup\ignorespaces} 292569626Sru 292669626Sru 292769626Sru% @set VAR sets the variable VAR to an empty value. 292869626Sru% @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE. 292969626Sru% 293069626Sru% Since we want to separate VAR from REST-OF-LINE (which might be 293169626Sru% empty), we can't just use \parsearg; we have to insert a space of our 293269626Sru% own to delimit the rest of the line, and then take it out again if we 2933151497Sru% didn't need it. 2934151497Sru% We rely on the fact that \parsearg sets \catcode`\ =10. 293569626Sru% 2936151497Sru\parseargdef\set{\setyyy#1 \endsetyyy} 293769626Sru\def\setyyy#1 #2\endsetyyy{% 2938151497Sru {% 2939151497Sru \makevalueexpandable 2940151497Sru \def\temp{#2}% 2941151497Sru \edef\next{\gdef\makecsname{SET#1}}% 2942151497Sru \ifx\temp\empty 2943151497Sru \next{}% 2944151497Sru \else 2945151497Sru \setzzz#2\endsetzzz 2946151497Sru \fi 2947151497Sru }% 294869626Sru} 2949151497Sru% Remove the trailing space \setxxx inserted. 2950151497Sru\def\setzzz#1 \endsetzzz{\next{#1}} 295169626Sru 295269626Sru% @clear VAR clears (i.e., unsets) the variable VAR. 295369626Sru% 2954151497Sru\parseargdef\clear{% 2955151497Sru {% 2956151497Sru \makevalueexpandable 2957151497Sru \global\expandafter\let\csname SET#1\endcsname=\relax 2958151497Sru }% 2959151497Sru} 296069626Sru 296169626Sru% @value{foo} gets the text saved in variable foo. 2962151497Sru\def\value{\begingroup\makevalueexpandable\valuexxx} 2963151497Sru\def\valuexxx#1{\expandablevalue{#1}\endgroup} 296469626Sru{ 2965151497Sru \catcode`\- = \active \catcode`\_ = \active 296669626Sru % 2967151497Sru \gdef\makevalueexpandable{% 2968151497Sru \let\value = \expandablevalue 2969151497Sru % We don't want these characters active, ... 2970114402Sru \catcode`\-=\other \catcode`\_=\other 2971151497Sru % ..., but we might end up with active ones in the argument if 2972151497Sru % we're called from @code, as @code{@value{foo-bar_}}, though. 2973151497Sru % So \let them to their normal equivalents. 2974151497Sru \let-\realdash \let_\normalunderscore 2975151497Sru } 297669626Sru} 297769626Sru 297869626Sru% We have this subroutine so that we can handle at least some @value's 2979151497Sru% properly in indexes (we call \makevalueexpandable in \indexdummies). 2980151497Sru% The command has to be fully expandable (if the variable is set), since 2981151497Sru% the result winds up in the index file. This means that if the 2982151497Sru% variable's value contains other Texinfo commands, it's almost certain 2983151497Sru% it will fail (although perhaps we could fix that with sufficient work 2984151497Sru% to do a one-level expansion on the result, instead of complete). 298569626Sru% 298669626Sru\def\expandablevalue#1{% 298769626Sru \expandafter\ifx\csname SET#1\endcsname\relax 298869626Sru {[No value for ``#1'']}% 2989114402Sru \message{Variable `#1', used in @value, is not set.}% 299069626Sru \else 299169626Sru \csname SET#1\endcsname 299269626Sru \fi 299369626Sru} 299469626Sru 299569626Sru% @ifset VAR ... @end ifset reads the `...' iff VAR has been defined 299669626Sru% with @set. 299769626Sru% 2998151497Sru% To get special treatment of `@end ifset,' call \makeond and the redefine. 2999151497Sru% 3000151497Sru\makecond{ifset} 3001151497Sru\def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}} 3002151497Sru\def\doifset#1#2{% 3003151497Sru {% 3004151497Sru \makevalueexpandable 3005151497Sru \let\next=\empty 3006151497Sru \expandafter\ifx\csname SET#2\endcsname\relax 3007151497Sru #1% If not set, redefine \next. 3008151497Sru \fi 3009151497Sru \expandafter 3010151497Sru }\next 301169626Sru} 3012151497Sru\def\ifsetfail{\doignore{ifset}} 301369626Sru 301469626Sru% @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been 301569626Sru% defined with @set, or has been undefined with @clear. 301669626Sru% 3017151497Sru% The `\else' inside the `\doifset' parameter is a trick to reuse the 3018151497Sru% above code: if the variable is not set, do nothing, if it is set, 3019151497Sru% then redefine \next to \ifclearfail. 302069626Sru% 3021151497Sru\makecond{ifclear} 3022151497Sru\def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}} 3023151497Sru\def\ifclearfail{\doignore{ifclear}} 302469626Sru 3025151497Sru% @dircategory CATEGORY -- specify a category of the dir file 3026151497Sru% which this file should belong to. Ignore this in TeX. 3027151497Sru\let\dircategory=\comment 302869626Sru 302969626Sru% @defininfoenclose. 303069626Sru\let\definfoenclose=\comment 303169626Sru 303269626Sru 303369626Sru\message{indexing,} 303469626Sru% Index generation facilities 303569626Sru 303669626Sru% Define \newwrite to be identical to plain tex's \newwrite 3037151497Sru% except not \outer, so it can be used within macros and \if's. 3038151497Sru\edef\newwrite{\makecsname{ptexnewwrite}} 303969626Sru 304069626Sru% \newindex {foo} defines an index named foo. 304169626Sru% It automatically defines \fooindex such that 304269626Sru% \fooindex ...rest of line... puts an entry in the index foo. 304369626Sru% It also defines \fooindfile to be the number of the output channel for 304469626Sru% the file that accumulates this index. The file's extension is foo. 304569626Sru% The name of an index should be no more than 2 characters long 304669626Sru% for the sake of vms. 304769626Sru% 304869626Sru\def\newindex#1{% 304969626Sru \iflinks 305069626Sru \expandafter\newwrite \csname#1indfile\endcsname 305169626Sru \openout \csname#1indfile\endcsname \jobname.#1 % Open the file 305269626Sru \fi 305369626Sru \expandafter\xdef\csname#1index\endcsname{% % Define @#1index 305469626Sru \noexpand\doindex{#1}} 305569626Sru} 305669626Sru 305769626Sru% @defindex foo == \newindex{foo} 3058104862Sru% 305969626Sru\def\defindex{\parsearg\newindex} 306069626Sru 306169626Sru% Define @defcodeindex, like @defindex except put all entries in @code. 3062104862Sru% 3063104862Sru\def\defcodeindex{\parsearg\newcodeindex} 3064104862Sru% 306569626Sru\def\newcodeindex#1{% 306669626Sru \iflinks 306769626Sru \expandafter\newwrite \csname#1indfile\endcsname 306869626Sru \openout \csname#1indfile\endcsname \jobname.#1 306969626Sru \fi 307069626Sru \expandafter\xdef\csname#1index\endcsname{% 3071104862Sru \noexpand\docodeindex{#1}}% 307269626Sru} 307369626Sru 307469626Sru 307569626Sru% @synindex foo bar makes index foo feed into index bar. 307669626Sru% Do this instead of @defindex foo if you don't want it as a separate index. 3077151497Sru% 307869626Sru% @syncodeindex foo bar similar, but put all entries made for index foo 307969626Sru% inside @code. 3080151497Sru% 3081104862Sru\def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}} 3082104862Sru\def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}} 3083104862Sru 3084104862Sru% #1 is \doindex or \docodeindex, #2 the index getting redefined (foo), 3085104862Sru% #3 the target index (bar). 3086104862Sru\def\dosynindex#1#2#3{% 3087104862Sru % Only do \closeout if we haven't already done it, else we'll end up 3088104862Sru % closing the target index. 3089104862Sru \expandafter \ifx\csname donesynindex#2\endcsname \undefined 3090104862Sru % The \closeout helps reduce unnecessary open files; the limit on the 3091104862Sru % Acorn RISC OS is a mere 16 files. 3092104862Sru \expandafter\closeout\csname#2indfile\endcsname 3093104862Sru \expandafter\let\csname\donesynindex#2\endcsname = 1 3094104862Sru \fi 3095104862Sru % redefine \fooindfile: 3096104862Sru \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname 3097104862Sru \expandafter\let\csname#2indfile\endcsname=\temp 3098104862Sru % redefine \fooindex: 3099104862Sru \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}% 310069626Sru} 310169626Sru 310269626Sru% Define \doindex, the driver for all \fooindex macros. 310369626Sru% Argument #1 is generated by the calling \fooindex macro, 310469626Sru% and it is "foo", the name of the index. 310569626Sru 310669626Sru% \doindex just uses \parsearg; it calls \doind for the actual work. 310769626Sru% This is because \doind is more useful to call from other macros. 310869626Sru 310969626Sru% There is also \dosubind {index}{topic}{subtopic} 311069626Sru% which makes an entry in a two-level index such as the operation index. 311169626Sru 311269626Sru\def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer} 311369626Sru\def\singleindexer #1{\doind{\indexname}{#1}} 311469626Sru 311569626Sru% like the previous two, but they put @code around the argument. 311669626Sru\def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer} 311769626Sru\def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}} 311869626Sru 3119114402Sru% Take care of Texinfo commands that can appear in an index entry. 3120114402Sru% Since there are some commands we want to expand, and others we don't, 3121114402Sru% we have to laboriously prevent expansion for those that we don't. 3122151497Sru% 312369626Sru\def\indexdummies{% 3124114402Sru \def\@{@}% change to @@ when we switch to @ as escape char in index files. 3125114402Sru \def\ {\realbackslash\space }% 3126114402Sru % Need these in case \tex is in effect and \{ is a \delimiter again. 3127114402Sru % But can't use \lbracecmd and \rbracecmd because texindex assumes 3128151497Sru % braces and backslashes are used only as delimiters. 3129114402Sru \let\{ = \mylbrace 3130114402Sru \let\} = \myrbrace 3131114402Sru % 3132114402Sru % \definedummyword defines \#1 as \realbackslash #1\space, thus 3133114402Sru % effectively preventing its expansion. This is used only for control 3134114402Sru % words, not control letters, because the \space would be incorrect 3135114402Sru % for control characters, but is needed to separate the control word 3136114402Sru % from whatever follows. 3137151497Sru % 3138114402Sru % For control letters, we have \definedummyletter, which omits the 3139114402Sru % space. 3140151497Sru % 3141114402Sru % These can be used both for control words that take an argument and 3142114402Sru % those that do not. If it is followed by {arg} in the input, then 3143114402Sru % that will dutifully get written to the index (or wherever). 3144151497Sru % 3145114402Sru \def\definedummyword##1{% 3146114402Sru \expandafter\def\csname ##1\endcsname{\realbackslash ##1\space}% 3147114402Sru }% 3148114402Sru \def\definedummyletter##1{% 3149114402Sru \expandafter\def\csname ##1\endcsname{\realbackslash ##1}% 3150114402Sru }% 3151151497Sru \let\definedummyaccent\definedummyletter 3152114402Sru % 3153114402Sru % Do the redefinitions. 3154114402Sru \commondummies 315569626Sru} 315669626Sru 3157114402Sru% For the aux file, @ is the escape character. So we want to redefine 3158151497Sru% everything using @ instead of \realbackslash. When everything uses 3159114402Sru% @, this will be simpler. 3160151497Sru% 3161114402Sru\def\atdummies{% 3162114402Sru \def\@{@@}% 3163114402Sru \def\ {@ }% 3164114402Sru \let\{ = \lbraceatcmd 3165114402Sru \let\} = \rbraceatcmd 3166114402Sru % 3167114402Sru % (See comments in \indexdummies.) 3168114402Sru \def\definedummyword##1{% 3169114402Sru \expandafter\def\csname ##1\endcsname{@##1\space}% 3170114402Sru }% 3171114402Sru \def\definedummyletter##1{% 3172114402Sru \expandafter\def\csname ##1\endcsname{@##1}% 3173114402Sru }% 3174151497Sru \let\definedummyaccent\definedummyletter 3175114402Sru % 3176114402Sru % Do the redefinitions. 3177114402Sru \commondummies 3178114402Sru} 3179114402Sru 3180114402Sru% Called from \indexdummies and \atdummies. \definedummyword and 3181114402Sru% \definedummyletter must be defined first. 3182151497Sru% 3183114402Sru\def\commondummies{% 3184114402Sru % 3185114402Sru \normalturnoffactive 3186114402Sru % 3187151497Sru \commondummiesnofonts 3188151497Sru % 3189114402Sru \definedummyletter{_}% 3190114402Sru % 3191151497Sru % Non-English letters. 3192114402Sru \definedummyword{AA}% 3193114402Sru \definedummyword{AE}% 3194114402Sru \definedummyword{L}% 3195114402Sru \definedummyword{OE}% 3196114402Sru \definedummyword{O}% 3197114402Sru \definedummyword{aa}% 3198114402Sru \definedummyword{ae}% 3199114402Sru \definedummyword{l}% 3200114402Sru \definedummyword{oe}% 3201114402Sru \definedummyword{o}% 3202114402Sru \definedummyword{ss}% 3203151497Sru \definedummyword{exclamdown}% 3204151497Sru \definedummyword{questiondown}% 3205151497Sru \definedummyword{ordf}% 3206151497Sru \definedummyword{ordm}% 3207114402Sru % 3208114402Sru % Although these internal commands shouldn't show up, sometimes they do. 3209114402Sru \definedummyword{bf}% 3210114402Sru \definedummyword{gtr}% 3211114402Sru \definedummyword{hat}% 3212114402Sru \definedummyword{less}% 3213114402Sru \definedummyword{sf}% 3214114402Sru \definedummyword{sl}% 3215114402Sru \definedummyword{tclose}% 3216114402Sru \definedummyword{tt}% 3217114402Sru % 3218151497Sru \definedummyword{LaTeX}% 3219114402Sru \definedummyword{TeX}% 3220114402Sru % 3221114402Sru % Assorted special characters. 3222114402Sru \definedummyword{bullet}% 3223151497Sru \definedummyword{comma}% 3224114402Sru \definedummyword{copyright}% 3225151497Sru \definedummyword{registeredsymbol}% 3226114402Sru \definedummyword{dots}% 3227114402Sru \definedummyword{enddots}% 3228114402Sru \definedummyword{equiv}% 3229114402Sru \definedummyword{error}% 3230151497Sru \definedummyword{euro}% 3231114402Sru \definedummyword{expansion}% 3232114402Sru \definedummyword{minus}% 3233114402Sru \definedummyword{pounds}% 3234114402Sru \definedummyword{point}% 3235114402Sru \definedummyword{print}% 3236114402Sru \definedummyword{result}% 3237114402Sru % 3238151497Sru % Handle some cases of @value -- where it does not contain any 3239114402Sru % (non-fully-expandable) commands. 3240151497Sru \makevalueexpandable 3241114402Sru % 3242114402Sru % Normal spaces, not active ones. 3243114402Sru \unsepspaces 3244114402Sru % 3245114402Sru % No macro expansion. 3246114402Sru \turnoffmacros 3247114402Sru} 3248114402Sru 3249151497Sru% \commondummiesnofonts: common to \commondummies and \indexnofonts. 3250151497Sru% 3251151497Sru% Better have this without active chars. 3252151497Sru{ 3253151497Sru \catcode`\~=\other 3254151497Sru \gdef\commondummiesnofonts{% 3255151497Sru % Control letters and accents. 3256151497Sru \definedummyletter{!}% 3257151497Sru \definedummyaccent{"}% 3258151497Sru \definedummyaccent{'}% 3259151497Sru \definedummyletter{*}% 3260151497Sru \definedummyaccent{,}% 3261151497Sru \definedummyletter{.}% 3262151497Sru \definedummyletter{/}% 3263151497Sru \definedummyletter{:}% 3264151497Sru \definedummyaccent{=}% 3265151497Sru \definedummyletter{?}% 3266151497Sru \definedummyaccent{^}% 3267151497Sru \definedummyaccent{`}% 3268151497Sru \definedummyaccent{~}% 3269151497Sru \definedummyword{u}% 3270151497Sru \definedummyword{v}% 3271151497Sru \definedummyword{H}% 3272151497Sru \definedummyword{dotaccent}% 3273151497Sru \definedummyword{ringaccent}% 3274151497Sru \definedummyword{tieaccent}% 3275151497Sru \definedummyword{ubaraccent}% 3276151497Sru \definedummyword{udotaccent}% 3277151497Sru \definedummyword{dotless}% 3278151497Sru % 3279151497Sru % Texinfo font commands. 3280151497Sru \definedummyword{b}% 3281151497Sru \definedummyword{i}% 3282151497Sru \definedummyword{r}% 3283151497Sru \definedummyword{sc}% 3284151497Sru \definedummyword{t}% 3285151497Sru % 3286151497Sru % Commands that take arguments. 3287151497Sru \definedummyword{acronym}% 3288151497Sru \definedummyword{cite}% 3289151497Sru \definedummyword{code}% 3290151497Sru \definedummyword{command}% 3291151497Sru \definedummyword{dfn}% 3292151497Sru \definedummyword{emph}% 3293151497Sru \definedummyword{env}% 3294151497Sru \definedummyword{file}% 3295151497Sru \definedummyword{kbd}% 3296151497Sru \definedummyword{key}% 3297151497Sru \definedummyword{math}% 3298151497Sru \definedummyword{option}% 3299151497Sru \definedummyword{samp}% 3300151497Sru \definedummyword{strong}% 3301151497Sru \definedummyword{tie}% 3302151497Sru \definedummyword{uref}% 3303151497Sru \definedummyword{url}% 3304151497Sru \definedummyword{var}% 3305151497Sru \definedummyword{verb}% 3306151497Sru \definedummyword{w}% 3307151497Sru } 3308151497Sru} 330969626Sru 3310114402Sru% \indexnofonts is used when outputting the strings to sort the index 3311114402Sru% by, and when constructing control sequence names. It eliminates all 3312114402Sru% control sequences and just writes whatever the best ASCII sort string 3313114402Sru% would be for a given command (usually its argument). 3314114402Sru% 331569626Sru\def\indexnofonts{% 3316151497Sru % Accent commands should become @asis. 3317151497Sru \def\definedummyaccent##1{% 3318151497Sru \expandafter\let\csname ##1\endcsname\asis 3319151497Sru }% 3320151497Sru % We can just ignore other control letters. 3321151497Sru \def\definedummyletter##1{% 3322151497Sru \expandafter\def\csname ##1\endcsname{}% 3323151497Sru }% 3324151497Sru % Hopefully, all control words can become @asis. 3325151497Sru \let\definedummyword\definedummyaccent 3326151497Sru % 3327151497Sru \commondummiesnofonts 3328151497Sru % 3329151497Sru % Don't no-op \tt, since it isn't a user-level command 3330151497Sru % and is used in the definitions of the active chars like <, >, |, etc. 3331151497Sru % Likewise with the other plain tex font commands. 3332151497Sru %\let\tt=\asis 3333151497Sru % 3334114402Sru \def\ { }% 3335114402Sru \def\@{@}% 3336114402Sru % how to handle braces? 3337114402Sru \def\_{\normalunderscore}% 3338114402Sru % 3339151497Sru % Non-English letters. 3340114402Sru \def\AA{AA}% 3341114402Sru \def\AE{AE}% 3342114402Sru \def\L{L}% 3343114402Sru \def\OE{OE}% 3344114402Sru \def\O{O}% 3345114402Sru \def\aa{aa}% 3346114402Sru \def\ae{ae}% 3347114402Sru \def\l{l}% 3348114402Sru \def\oe{oe}% 3349114402Sru \def\o{o}% 3350114402Sru \def\ss{ss}% 3351114402Sru \def\exclamdown{!}% 3352114402Sru \def\questiondown{?}% 3353151497Sru \def\ordf{a}% 3354151497Sru \def\ordm{o}% 3355114402Sru % 3356151497Sru \def\LaTeX{LaTeX}% 3357151497Sru \def\TeX{TeX}% 3358114402Sru % 3359151497Sru % Assorted special characters. 3360151497Sru % (The following {} will end up in the sort string, but that's ok.) 3361151497Sru \def\bullet{bullet}% 3362151497Sru \def\comma{,}% 3363151497Sru \def\copyright{copyright}% 3364151497Sru \def\registeredsymbol{R}% 3365151497Sru \def\dots{...}% 3366151497Sru \def\enddots{...}% 3367151497Sru \def\equiv{==}% 3368151497Sru \def\error{error}% 3369151497Sru \def\euro{euro}% 3370151497Sru \def\expansion{==>}% 3371151497Sru \def\minus{-}% 3372151497Sru \def\pounds{pounds}% 3373151497Sru \def\point{.}% 3374151497Sru \def\print{-|}% 3375151497Sru \def\result{=>}% 3376114402Sru % 3377151497Sru % Don't write macro names. 3378151497Sru \emptyusermacros 337969626Sru} 338069626Sru 338169626Sru\let\indexbackslash=0 %overridden during \printindex. 338269626Sru\let\SETmarginindex=\relax % put index entries in margin (undocumented)? 338369626Sru 338469626Sru% Most index entries go through here, but \dosubind is the general case. 3385151497Sru% #1 is the index name, #2 is the entry text. 3386151497Sru\def\doind#1#2{\dosubind{#1}{#2}{}} 338769626Sru 338869626Sru% Workhorse for all \fooindexes. 338969626Sru% #1 is name of index, #2 is stuff to put there, #3 is subentry -- 3390151497Sru% empty if called from \doind, as we usually are (the main exception 3391151497Sru% is with most defuns, which call us directly). 339269626Sru% 339369626Sru\def\dosubind#1#2#3{% 3394151497Sru \iflinks 3395151497Sru {% 3396151497Sru % Store the main index entry text (including the third arg). 3397151497Sru \toks0 = {#2}% 3398151497Sru % If third arg is present, precede it with a space. 3399151497Sru \def\thirdarg{#3}% 3400151497Sru \ifx\thirdarg\empty \else 3401151497Sru \toks0 = \expandafter{\the\toks0 \space #3}% 3402151497Sru \fi 3403151497Sru % 3404151497Sru \edef\writeto{\csname#1indfile\endcsname}% 3405151497Sru % 3406151497Sru \ifvmode 3407151497Sru \dosubindsanitize 3408151497Sru \else 3409151497Sru \dosubindwrite 3410151497Sru \fi 3411151497Sru }% 3412151497Sru \fi 3413151497Sru} 3414151497Sru 3415151497Sru% Write the entry in \toks0 to the index file: 3416151497Sru% 3417151497Sru\def\dosubindwrite{% 341869626Sru % Put the index entry in the margin if desired. 341969626Sru \ifx\SETmarginindex\relax\else 3420151497Sru \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \the\toks0}}% 342169626Sru \fi 3422151497Sru % 3423151497Sru % Remember, we are within a group. 3424151497Sru \indexdummies % Must do this here, since \bf, etc expand at this stage 3425151497Sru \escapechar=`\\ 3426151497Sru \def\backslashcurfont{\indexbackslash}% \indexbackslash isn't defined now 3427151497Sru % so it will be output as is; and it will print as backslash. 3428151497Sru % 3429151497Sru % Process the index entry with all font commands turned off, to 3430151497Sru % get the string to sort by. 3431151497Sru {\indexnofonts 3432151497Sru \edef\temp{\the\toks0}% need full expansion 3433151497Sru \xdef\indexsorttmp{\temp}% 343469626Sru }% 3435151497Sru % 3436151497Sru % Set up the complete index entry, with both the sort key and 3437151497Sru % the original text, including any font commands. We write 3438151497Sru % three arguments to \entry to the .?? file (four in the 3439151497Sru % subentry case), texindex reduces to two when writing the .??s 3440151497Sru % sorted result. 3441151497Sru \edef\temp{% 3442151497Sru \write\writeto{% 3443151497Sru \string\entry{\indexsorttmp}{\noexpand\folio}{\the\toks0}}% 3444151497Sru }% 3445151497Sru \temp 344669626Sru} 344769626Sru 3448151497Sru% Take care of unwanted page breaks: 3449151497Sru% 3450151497Sru% If a skip is the last thing on the list now, preserve it 3451151497Sru% by backing up by \lastskip, doing the \write, then inserting 3452151497Sru% the skip again. Otherwise, the whatsit generated by the 3453151497Sru% \write will make \lastskip zero. The result is that sequences 3454151497Sru% like this: 3455151497Sru% @end defun 3456151497Sru% @tindex whatever 3457151497Sru% @defun ... 3458151497Sru% will have extra space inserted, because the \medbreak in the 3459151497Sru% start of the @defun won't see the skip inserted by the @end of 3460151497Sru% the previous defun. 3461151497Sru% 3462151497Sru% But don't do any of this if we're not in vertical mode. We 3463151497Sru% don't want to do a \vskip and prematurely end a paragraph. 3464151497Sru% 3465151497Sru% Avoid page breaks due to these extra skips, too. 3466151497Sru% 3467151497Sru% But wait, there is a catch there: 3468151497Sru% We'll have to check whether \lastskip is zero skip. \ifdim is not 3469151497Sru% sufficient for this purpose, as it ignores stretch and shrink parts 3470151497Sru% of the skip. The only way seems to be to check the textual 3471151497Sru% representation of the skip. 3472151497Sru% 3473151497Sru% The following is almost like \def\zeroskipmacro{0.0pt} except that 3474151497Sru% the ``p'' and ``t'' characters have catcode \other, not 11 (letter). 3475151497Sru% 3476151497Sru\edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname} 3477151497Sru% 3478151497Sru% ..., ready, GO: 3479151497Sru% 3480151497Sru\def\dosubindsanitize{% 3481151497Sru % \lastskip and \lastpenalty cannot both be nonzero simultaneously. 3482151497Sru \skip0 = \lastskip 3483151497Sru \edef\lastskipmacro{\the\lastskip}% 3484151497Sru \count255 = \lastpenalty 3485151497Sru % 3486151497Sru % If \lastskip is nonzero, that means the last item was a 3487151497Sru % skip. And since a skip is discardable, that means this 3488151497Sru % -\skip0 glue we're inserting is preceded by a 3489151497Sru % non-discardable item, therefore it is not a potential 3490151497Sru % breakpoint, therefore no \nobreak needed. 3491151497Sru \ifx\lastskipmacro\zeroskipmacro 3492151497Sru \else 3493151497Sru \vskip-\skip0 3494151497Sru \fi 3495151497Sru % 3496151497Sru \dosubindwrite 3497151497Sru % 3498151497Sru \ifx\lastskipmacro\zeroskipmacro 3499151497Sru % If \lastskip was zero, perhaps the last item was a penalty, and 3500151497Sru % perhaps it was >=10000, e.g., a \nobreak. In that case, we want 3501151497Sru % to re-insert the same penalty (values >10000 are used for various 3502151497Sru % signals); since we just inserted a non-discardable item, any 3503151497Sru % following glue (such as a \parskip) would be a breakpoint. For example: 3504151497Sru % 3505151497Sru % @deffn deffn-whatever 3506151497Sru % @vindex index-whatever 3507151497Sru % Description. 3508151497Sru % would allow a break between the index-whatever whatsit 3509151497Sru % and the "Description." paragraph. 3510151497Sru \ifnum\count255>9999 \penalty\count255 \fi 3511151497Sru \else 3512151497Sru % On the other hand, if we had a nonzero \lastskip, 3513151497Sru % this make-up glue would be preceded by a non-discardable item 3514151497Sru % (the whatsit from the \write), so we must insert a \nobreak. 3515151497Sru \nobreak\vskip\skip0 3516151497Sru \fi 3517151497Sru} 3518151497Sru 351969626Sru% The index entry written in the file actually looks like 352069626Sru% \entry {sortstring}{page}{topic} 352169626Sru% or 352269626Sru% \entry {sortstring}{page}{topic}{subtopic} 352369626Sru% The texindex program reads in these files and writes files 352469626Sru% containing these kinds of lines: 352569626Sru% \initial {c} 352669626Sru% before the first topic whose initial is c 352769626Sru% \entry {topic}{pagelist} 352869626Sru% for a topic that is used without subtopics 352969626Sru% \primary {topic} 353069626Sru% for the beginning of a topic that is used with subtopics 353169626Sru% \secondary {subtopic}{pagelist} 353269626Sru% for each subtopic. 353369626Sru 353469626Sru% Define the user-accessible indexing commands 353569626Sru% @findex, @vindex, @kindex, @cindex. 353669626Sru 353769626Sru\def\findex {\fnindex} 353869626Sru\def\kindex {\kyindex} 353969626Sru\def\cindex {\cpindex} 354069626Sru\def\vindex {\vrindex} 354169626Sru\def\tindex {\tpindex} 354269626Sru\def\pindex {\pgindex} 354369626Sru 354469626Sru\def\cindexsub {\begingroup\obeylines\cindexsub} 354569626Sru{\obeylines % 354669626Sru\gdef\cindexsub "#1" #2^^M{\endgroup % 354769626Sru\dosubind{cp}{#2}{#1}}} 354869626Sru 354969626Sru% Define the macros used in formatting output of the sorted index material. 355069626Sru 355169626Sru% @printindex causes a particular index (the ??s file) to get printed. 355269626Sru% It does not print any chapter heading (usually an @unnumbered). 355369626Sru% 3554151497Sru\parseargdef\printindex{\begingroup 355569626Sru \dobreak \chapheadingskip{10000}% 355669626Sru % 355769626Sru \smallfonts \rm 355869626Sru \tolerance = 9500 3559151497Sru \everypar = {}% don't want the \kern\-parindent from indentation suppression. 356069626Sru % 356169626Sru % See if the index file exists and is nonempty. 356269626Sru % Change catcode of @ here so that if the index file contains 356369626Sru % \initial {@} 356469626Sru % as its first line, TeX doesn't complain about mismatched braces 356569626Sru % (because it thinks @} is a control sequence). 356669626Sru \catcode`\@ = 11 356769626Sru \openin 1 \jobname.#1s 356869626Sru \ifeof 1 356969626Sru % \enddoublecolumns gets confused if there is no text in the index, 357069626Sru % and it loses the chapter title and the aux file entries for the 357169626Sru % index. The easiest way to prevent this problem is to make sure 357269626Sru % there is some text. 357369626Sru \putwordIndexNonexistent 357469626Sru \else 357569626Sru % 357669626Sru % If the index file exists but is empty, then \openin leaves \ifeof 357769626Sru % false. We have to make TeX try to read something from the file, so 357869626Sru % it can discover if there is anything in it. 357969626Sru \read 1 to \temp 358069626Sru \ifeof 1 358169626Sru \putwordIndexIsEmpty 358269626Sru \else 358369626Sru % Index files are almost Texinfo source, but we use \ as the escape 358469626Sru % character. It would be better to use @, but that's too big a change 358569626Sru % to make right now. 3586151497Sru \def\indexbackslash{\backslashcurfont}% 358769626Sru \catcode`\\ = 0 358869626Sru \escapechar = `\\ 358969626Sru \begindoublecolumns 359069626Sru \input \jobname.#1s 359169626Sru \enddoublecolumns 359269626Sru \fi 359369626Sru \fi 359469626Sru \closein 1 359569626Sru\endgroup} 359669626Sru 359769626Sru% These macros are used by the sorted index file itself. 359869626Sru% Change them to control the appearance of the index. 359969626Sru 360069626Sru\def\initial#1{{% 360169626Sru % Some minor font changes for the special characters. 360269626Sru \let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt 360369626Sru % 360469626Sru % Remove any glue we may have, we'll be inserting our own. 360569626Sru \removelastskip 360669626Sru % 360769626Sru % We like breaks before the index initials, so insert a bonus. 3608151497Sru \nobreak 3609151497Sru \vskip 0pt plus 3\baselineskip 3610151497Sru \penalty 0 3611151497Sru \vskip 0pt plus -3\baselineskip 361269626Sru % 361369626Sru % Typeset the initial. Making this add up to a whole number of 361469626Sru % baselineskips increases the chance of the dots lining up from column 361569626Sru % to column. It still won't often be perfect, because of the stretch 361669626Sru % we need before each entry, but it's better. 361769626Sru % 361869626Sru % No shrink because it confuses \balancecolumns. 361969626Sru \vskip 1.67\baselineskip plus .5\baselineskip 362069626Sru \leftline{\secbf #1}% 362169626Sru % Do our best not to break after the initial. 362269626Sru \nobreak 3623151497Sru \vskip .33\baselineskip plus .1\baselineskip 362469626Sru}} 362569626Sru 3626151497Sru% \entry typesets a paragraph consisting of the text (#1), dot leaders, and 3627151497Sru% then page number (#2) flushed to the right margin. It is used for index 3628151497Sru% and table of contents entries. The paragraph is indented by \leftskip. 362969626Sru% 3630151497Sru% A straightforward implementation would start like this: 3631151497Sru% \def\entry#1#2{... 3632151497Sru% But this frozes the catcodes in the argument, and can cause problems to 3633151497Sru% @code, which sets - active. This problem was fixed by a kludge--- 3634151497Sru% ``-'' was active throughout whole index, but this isn't really right. 3635151497Sru% 3636151497Sru% The right solution is to prevent \entry from swallowing the whole text. 3637151497Sru% --kasal, 21nov03 3638151497Sru\def\entry{% 3639151497Sru \begingroup 364069626Sru % 3641151497Sru % Start a new paragraph if necessary, so our assignments below can't 3642151497Sru % affect previous text. 3643151497Sru \par 364469626Sru % 3645151497Sru % Do not fill out the last line with white space. 3646151497Sru \parfillskip = 0in 3647151497Sru % 3648151497Sru % No extra space above this paragraph. 3649151497Sru \parskip = 0in 3650151497Sru % 3651151497Sru % Do not prefer a separate line ending with a hyphen to fewer lines. 3652151497Sru \finalhyphendemerits = 0 3653151497Sru % 3654151497Sru % \hangindent is only relevant when the entry text and page number 3655151497Sru % don't both fit on one line. In that case, bob suggests starting the 3656151497Sru % dots pretty far over on the line. Unfortunately, a large 3657151497Sru % indentation looks wrong when the entry text itself is broken across 3658151497Sru % lines. So we use a small indentation and put up with long leaders. 3659151497Sru % 3660151497Sru % \hangafter is reset to 1 (which is the value we want) at the start 3661151497Sru % of each paragraph, so we need not do anything with that. 3662151497Sru \hangindent = 2em 3663151497Sru % 3664151497Sru % When the entry text needs to be broken, just fill out the first line 3665151497Sru % with blank space. 3666151497Sru \rightskip = 0pt plus1fil 3667151497Sru % 3668151497Sru % A bit of stretch before each entry for the benefit of balancing 3669151497Sru % columns. 3670151497Sru \vskip 0pt plus1pt 3671151497Sru % 3672151497Sru % Swallow the left brace of the text (first parameter): 3673151497Sru \afterassignment\doentry 3674151497Sru \let\temp = 3675151497Sru} 3676151497Sru\def\doentry{% 3677151497Sru \bgroup % Instead of the swallowed brace. 3678151497Sru \noindent 3679151497Sru \aftergroup\finishentry 3680151497Sru % And now comes the text of the entry. 3681151497Sru} 3682151497Sru\def\finishentry#1{% 3683151497Sru % #1 is the page number. 3684151497Sru % 3685151497Sru % The following is kludged to not output a line of dots in the index if 3686151497Sru % there are no page numbers. The next person who breaks this will be 3687151497Sru % cursed by a Unix daemon. 3688151497Sru \def\tempa{{\rm }}% 3689151497Sru \def\tempb{#1}% 3690151497Sru \edef\tempc{\tempa}% 3691151497Sru \edef\tempd{\tempb}% 3692151497Sru \ifx\tempc\tempd 3693151497Sru \ % 369469626Sru \else 3695151497Sru % 3696151497Sru % If we must, put the page number on a line of its own, and fill out 3697151497Sru % this line with blank space. (The \hfil is overwhelmed with the 3698151497Sru % fill leaders glue in \indexdotfill if the page number does fit.) 3699151497Sru \hfil\penalty50 3700151497Sru \null\nobreak\indexdotfill % Have leaders before the page number. 3701151497Sru % 3702151497Sru % The `\ ' here is removed by the implicit \unskip that TeX does as 3703151497Sru % part of (the primitive) \par. Without it, a spurious underfull 3704151497Sru % \hbox ensues. 3705151497Sru \ifpdf 3706151497Sru \pdfgettoks#1.% 3707151497Sru \ \the\toksA 3708151497Sru \else 3709151497Sru \ #1% 3710151497Sru \fi 371169626Sru \fi 3712151497Sru \par 3713151497Sru \endgroup 3714151497Sru} 371569626Sru 371669626Sru% Like \dotfill except takes at least 1 em. 371769626Sru\def\indexdotfill{\cleaders 371869626Sru \hbox{$\mathsurround=0pt \mkern1.5mu ${\it .}$ \mkern1.5mu$}\hskip 1em plus 1fill} 371969626Sru 372069626Sru\def\primary #1{\line{#1\hfil}} 372169626Sru 372269626Sru\newskip\secondaryindent \secondaryindent=0.5cm 3723104862Sru\def\secondary#1#2{{% 3724104862Sru \parfillskip=0in 3725104862Sru \parskip=0in 3726104862Sru \hangindent=1in 3727104862Sru \hangafter=1 3728104862Sru \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill 3729104862Sru \ifpdf 3730104862Sru \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph. 3731104862Sru \else 3732104862Sru #2 3733104862Sru \fi 3734104862Sru \par 373569626Sru}} 373669626Sru 373769626Sru% Define two-column mode, which we use to typeset indexes. 373869626Sru% Adapted from the TeXbook, page 416, which is to say, 373969626Sru% the manmac.tex format used to print the TeXbook itself. 374069626Sru\catcode`\@=11 374169626Sru 374269626Sru\newbox\partialpage 374369626Sru\newdimen\doublecolumnhsize 374469626Sru 374569626Sru\def\begindoublecolumns{\begingroup % ended by \enddoublecolumns 374669626Sru % Grab any single-column material above us. 374769626Sru \output = {% 374869626Sru % 374969626Sru % Here is a possibility not foreseen in manmac: if we accumulate a 375069626Sru % whole lot of material, we might end up calling this \output 375169626Sru % routine twice in a row (see the doublecol-lose test, which is 375269626Sru % essentially a couple of indexes with @setchapternewpage off). In 375369626Sru % that case we just ship out what is in \partialpage with the normal 375469626Sru % output routine. Generally, \partialpage will be empty when this 375569626Sru % runs and this will be a no-op. See the indexspread.tex test case. 375669626Sru \ifvoid\partialpage \else 375769626Sru \onepageout{\pagecontents\partialpage}% 375869626Sru \fi 375969626Sru % 376069626Sru \global\setbox\partialpage = \vbox{% 376169626Sru % Unvbox the main output page. 376269626Sru \unvbox\PAGE 376369626Sru \kern-\topskip \kern\baselineskip 376469626Sru }% 376569626Sru }% 376669626Sru \eject % run that output routine to set \partialpage 376769626Sru % 376869626Sru % Use the double-column output routine for subsequent pages. 376969626Sru \output = {\doublecolumnout}% 377069626Sru % 377169626Sru % Change the page size parameters. We could do this once outside this 377269626Sru % routine, in each of @smallbook, @afourpaper, and the default 8.5x11 377369626Sru % format, but then we repeat the same computation. Repeating a couple 377469626Sru % of assignments once per index is clearly meaningless for the 377569626Sru % execution time, so we may as well do it in one place. 377669626Sru % 377769626Sru % First we halve the line length, less a little for the gutter between 377869626Sru % the columns. We compute the gutter based on the line length, so it 377969626Sru % changes automatically with the paper format. The magic constant 378069626Sru % below is chosen so that the gutter has the same value (well, +-<1pt) 378169626Sru % as it did when we hard-coded it. 378269626Sru % 378369626Sru % We put the result in a separate register, \doublecolumhsize, so we 378469626Sru % can restore it in \pagesofar, after \hsize itself has (potentially) 378569626Sru % been clobbered. 378669626Sru % 378769626Sru \doublecolumnhsize = \hsize 378869626Sru \advance\doublecolumnhsize by -.04154\hsize 378969626Sru \divide\doublecolumnhsize by 2 379069626Sru \hsize = \doublecolumnhsize 379169626Sru % 379269626Sru % Double the \vsize as well. (We don't need a separate register here, 379369626Sru % since nobody clobbers \vsize.) 379469626Sru \vsize = 2\vsize 379569626Sru} 379669626Sru 379769626Sru% The double-column output routine for all double-column pages except 379869626Sru% the last. 379969626Sru% 380069626Sru\def\doublecolumnout{% 380169626Sru \splittopskip=\topskip \splitmaxdepth=\maxdepth 380269626Sru % Get the available space for the double columns -- the normal 380369626Sru % (undoubled) page height minus any material left over from the 380469626Sru % previous page. 380569626Sru \dimen@ = \vsize 380669626Sru \divide\dimen@ by 2 3807104862Sru \advance\dimen@ by -\ht\partialpage 380869626Sru % 380969626Sru % box0 will be the left-hand column, box2 the right. 381069626Sru \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@ 381169626Sru \onepageout\pagesofar 381269626Sru \unvbox255 381369626Sru \penalty\outputpenalty 381469626Sru} 3815104862Sru% 3816104862Sru% Re-output the contents of the output page -- any previous material, 3817104862Sru% followed by the two boxes we just split, in box0 and box2. 381869626Sru\def\pagesofar{% 381969626Sru \unvbox\partialpage 382069626Sru % 382169626Sru \hsize = \doublecolumnhsize 382269626Sru \wd0=\hsize \wd2=\hsize 382369626Sru \hbox to\pagewidth{\box0\hfil\box2}% 382469626Sru} 3825151497Sru% 3826104862Sru% All done with double columns. 382769626Sru\def\enddoublecolumns{% 382869626Sru \output = {% 382969626Sru % Split the last of the double-column material. Leave it on the 383069626Sru % current page, no automatic page break. 383169626Sru \balancecolumns 383269626Sru % 383369626Sru % If we end up splitting too much material for the current page, 383469626Sru % though, there will be another page break right after this \output 383569626Sru % invocation ends. Having called \balancecolumns once, we do not 383669626Sru % want to call it again. Therefore, reset \output to its normal 383769626Sru % definition right away. (We hope \balancecolumns will never be 383869626Sru % called on to balance too much material, but if it is, this makes 383969626Sru % the output somewhat more palatable.) 384069626Sru \global\output = {\onepageout{\pagecontents\PAGE}}% 384169626Sru }% 384269626Sru \eject 384369626Sru \endgroup % started in \begindoublecolumns 384469626Sru % 384569626Sru % \pagegoal was set to the doubled \vsize above, since we restarted 384669626Sru % the current page. We're now back to normal single-column 384769626Sru % typesetting, so reset \pagegoal to the normal \vsize (after the 384869626Sru % \endgroup where \vsize got restored). 384969626Sru \pagegoal = \vsize 385069626Sru} 3851104862Sru% 3852104862Sru% Called at the end of the double column material. 385369626Sru\def\balancecolumns{% 385469626Sru \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120. 385569626Sru \dimen@ = \ht0 385669626Sru \advance\dimen@ by \topskip 385769626Sru \advance\dimen@ by-\baselineskip 385869626Sru \divide\dimen@ by 2 % target to split to 385969626Sru %debug\message{final 2-column material height=\the\ht0, target=\the\dimen@.}% 386069626Sru \splittopskip = \topskip 386169626Sru % Loop until we get a decent breakpoint. 386269626Sru {% 386369626Sru \vbadness = 10000 386469626Sru \loop 386569626Sru \global\setbox3 = \copy0 386669626Sru \global\setbox1 = \vsplit3 to \dimen@ 386769626Sru \ifdim\ht3>\dimen@ 386869626Sru \global\advance\dimen@ by 1pt 386969626Sru \repeat 387069626Sru }% 387169626Sru %debug\message{split to \the\dimen@, column heights: \the\ht1, \the\ht3.}% 387269626Sru \setbox0=\vbox to\dimen@{\unvbox1}% 387369626Sru \setbox2=\vbox to\dimen@{\unvbox3}% 387469626Sru % 387569626Sru \pagesofar 387669626Sru} 387769626Sru\catcode`\@ = \other 387869626Sru 387969626Sru 388069626Sru\message{sectioning,} 388169626Sru% Chapters, sections, etc. 388269626Sru 3883151497Sru% \unnumberedno is an oxymoron, of course. But we count the unnumbered 3884151497Sru% sections so that we can refer to them unambiguously in the pdf 3885151497Sru% outlines by their "section number". We avoid collisions with chapter 3886151497Sru% numbers by starting them at 10000. (If a document ever has 10000 3887151497Sru% chapters, we're in trouble anyway, I'm sure.) 3888151497Sru\newcount\unnumberedno \unnumberedno = 10000 388969626Sru\newcount\chapno 389069626Sru\newcount\secno \secno=0 389169626Sru\newcount\subsecno \subsecno=0 389269626Sru\newcount\subsubsecno \subsubsecno=0 389369626Sru 389469626Sru% This counter is funny since it counts through charcodes of letters A, B, ... 389569626Sru\newcount\appendixno \appendixno = `\@ 3896151497Sru% 389769626Sru% \def\appendixletter{\char\the\appendixno} 3898151497Sru% We do the following ugly conditional instead of the above simple 3899151497Sru% construct for the sake of pdftex, which needs the actual 390069626Sru% letter in the expansion, not just typeset. 3901151497Sru% 390269626Sru\def\appendixletter{% 390369626Sru \ifnum\appendixno=`A A% 390469626Sru \else\ifnum\appendixno=`B B% 390569626Sru \else\ifnum\appendixno=`C C% 390669626Sru \else\ifnum\appendixno=`D D% 390769626Sru \else\ifnum\appendixno=`E E% 390869626Sru \else\ifnum\appendixno=`F F% 390969626Sru \else\ifnum\appendixno=`G G% 391069626Sru \else\ifnum\appendixno=`H H% 391169626Sru \else\ifnum\appendixno=`I I% 391269626Sru \else\ifnum\appendixno=`J J% 391369626Sru \else\ifnum\appendixno=`K K% 391469626Sru \else\ifnum\appendixno=`L L% 391569626Sru \else\ifnum\appendixno=`M M% 391669626Sru \else\ifnum\appendixno=`N N% 391769626Sru \else\ifnum\appendixno=`O O% 391869626Sru \else\ifnum\appendixno=`P P% 391969626Sru \else\ifnum\appendixno=`Q Q% 392069626Sru \else\ifnum\appendixno=`R R% 392169626Sru \else\ifnum\appendixno=`S S% 392269626Sru \else\ifnum\appendixno=`T T% 392369626Sru \else\ifnum\appendixno=`U U% 392469626Sru \else\ifnum\appendixno=`V V% 392569626Sru \else\ifnum\appendixno=`W W% 392669626Sru \else\ifnum\appendixno=`X X% 392769626Sru \else\ifnum\appendixno=`Y Y% 392869626Sru \else\ifnum\appendixno=`Z Z% 392969626Sru % The \the is necessary, despite appearances, because \appendixletter is 393069626Sru % expanded while writing the .toc file. \char\appendixno is not 393169626Sru % expandable, thus it is written literally, thus all appendixes come out 393269626Sru % with the same letter (or @) in the toc without it. 393369626Sru \else\char\the\appendixno 393469626Sru \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi 393569626Sru \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi} 393669626Sru 393769626Sru% Each @chapter defines this as the name of the chapter. 393869626Sru% page headings and footings can use it. @section does likewise. 3939151497Sru% However, they are not reliable, because we don't use marks. 394069626Sru\def\thischapter{} 394169626Sru\def\thissection{} 394269626Sru 394369626Sru\newcount\absseclevel % used to calculate proper heading level 3944151497Sru\newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count 394569626Sru 394669626Sru% @raisesections: treat @section as chapter, @subsection as section, etc. 394769626Sru\def\raisesections{\global\advance\secbase by -1} 394869626Sru\let\up=\raisesections % original BFox name 394969626Sru 395069626Sru% @lowersections: treat @chapter as section, @section as subsection, etc. 395169626Sru\def\lowersections{\global\advance\secbase by 1} 395269626Sru\let\down=\lowersections % original BFox name 395369626Sru 3954151497Sru% we only have subsub. 3955151497Sru\chardef\maxseclevel = 3 3956151497Sru% 3957151497Sru% A numbered section within an unnumbered changes to unnumbered too. 3958151497Sru% To achive this, remember the "biggest" unnum. sec. we are currently in: 3959151497Sru\chardef\unmlevel = \maxseclevel 3960151497Sru% 3961151497Sru% Trace whether the current chapter is an appendix or not: 3962151497Sru% \chapheadtype is "N" or "A", unnumbered chapters are ignored. 3963151497Sru\def\chapheadtype{N} 3964151497Sru 3965151497Sru% Choose a heading macro 3966151497Sru% #1 is heading type 3967151497Sru% #2 is heading level 3968151497Sru% #3 is text for heading 3969151497Sru\def\genhead#1#2#3{% 3970151497Sru % Compute the abs. sec. level: 3971151497Sru \absseclevel=#2 3972151497Sru \advance\absseclevel by \secbase 3973151497Sru % Make sure \absseclevel doesn't fall outside the range: 3974151497Sru \ifnum \absseclevel < 0 3975151497Sru \absseclevel = 0 397669626Sru \else 3977151497Sru \ifnum \absseclevel > 3 3978151497Sru \absseclevel = 3 3979151497Sru \fi 398069626Sru \fi 3981151497Sru % The heading type: 3982151497Sru \def\headtype{#1}% 3983151497Sru \if \headtype U% 3984151497Sru \ifnum \absseclevel < \unmlevel 3985151497Sru \chardef\unmlevel = \absseclevel 3986151497Sru \fi 398769626Sru \else 3988151497Sru % Check for appendix sections: 3989151497Sru \ifnum \absseclevel = 0 3990151497Sru \edef\chapheadtype{\headtype}% 3991151497Sru \else 3992151497Sru \if \headtype A\if \chapheadtype N% 3993151497Sru \errmessage{@appendix... within a non-appendix chapter}% 3994151497Sru \fi\fi 3995151497Sru \fi 3996151497Sru % Check for numbered within unnumbered: 3997151497Sru \ifnum \absseclevel > \unmlevel 3998151497Sru \def\headtype{U}% 3999151497Sru \else 4000151497Sru \chardef\unmlevel = 3 4001151497Sru \fi 400269626Sru \fi 4003151497Sru % Now print the heading: 4004151497Sru \if \headtype U% 4005151497Sru \ifcase\absseclevel 4006151497Sru \unnumberedzzz{#3}% 4007151497Sru \or \unnumberedseczzz{#3}% 4008151497Sru \or \unnumberedsubseczzz{#3}% 4009151497Sru \or \unnumberedsubsubseczzz{#3}% 4010151497Sru \fi 401169626Sru \else 4012151497Sru \if \headtype A% 4013151497Sru \ifcase\absseclevel 4014151497Sru \appendixzzz{#3}% 4015151497Sru \or \appendixsectionzzz{#3}% 4016151497Sru \or \appendixsubseczzz{#3}% 4017151497Sru \or \appendixsubsubseczzz{#3}% 4018151497Sru \fi 4019151497Sru \else 4020151497Sru \ifcase\absseclevel 4021151497Sru \chapterzzz{#3}% 4022151497Sru \or \seczzz{#3}% 4023151497Sru \or \numberedsubseczzz{#3}% 4024151497Sru \or \numberedsubsubseczzz{#3}% 4025151497Sru \fi 4026151497Sru \fi 402769626Sru \fi 4028151497Sru \suppressfirstparagraphindent 402969626Sru} 403069626Sru 4031151497Sru% an interface: 4032151497Sru\def\numhead{\genhead N} 4033151497Sru\def\apphead{\genhead A} 4034151497Sru\def\unnmhead{\genhead U} 4035151497Sru 4036151497Sru% @chapter, @appendix, @unnumbered. Increment top-level counter, reset 4037151497Sru% all lower-level sectioning counters to zero. 4038151497Sru% 4039151497Sru% Also set \chaplevelprefix, which we prepend to @float sequence numbers 4040151497Sru% (e.g., figures), q.v. By default (before any chapter), that is empty. 4041151497Sru\let\chaplevelprefix = \empty 4042151497Sru% 4043151497Sru\outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz 4044151497Sru\def\chapterzzz#1{% 4045151497Sru % section resetting is \global in case the chapter is in a group, such 4046151497Sru % as an @include file. 4047151497Sru \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 4048151497Sru \global\advance\chapno by 1 4049151497Sru % 4050151497Sru % Used for \float. 4051151497Sru \gdef\chaplevelprefix{\the\chapno.}% 4052151497Sru \resetallfloatnos 4053151497Sru % 4054151497Sru \message{\putwordChapter\space \the\chapno}% 4055151497Sru % 4056151497Sru % Write the actual heading. 4057151497Sru \chapmacro{#1}{Ynumbered}{\the\chapno}% 4058151497Sru % 4059151497Sru % So @section and the like are numbered underneath this chapter. 4060114402Sru \global\let\section = \numberedsec 4061114402Sru \global\let\subsection = \numberedsubsec 4062114402Sru \global\let\subsubsection = \numberedsubsubsec 406369626Sru} 406469626Sru 4065151497Sru\outer\parseargdef\appendix{\apphead0{#1}} % normally apphead0 calls appendixzzz 4066151497Sru\def\appendixzzz#1{% 4067151497Sru \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 4068151497Sru \global\advance\appendixno by 1 4069151497Sru \gdef\chaplevelprefix{\appendixletter.}% 4070151497Sru \resetallfloatnos 4071151497Sru % 4072151497Sru \def\appendixnum{\putwordAppendix\space \appendixletter}% 4073151497Sru \message{\appendixnum}% 4074151497Sru % 4075151497Sru \chapmacro{#1}{Yappendix}{\appendixletter}% 4076151497Sru % 4077114402Sru \global\let\section = \appendixsec 4078114402Sru \global\let\subsection = \appendixsubsec 4079114402Sru \global\let\subsubsection = \appendixsubsubsec 408069626Sru} 408169626Sru 4082151497Sru\outer\parseargdef\unnumbered{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz 4083151497Sru\def\unnumberedzzz#1{% 4084151497Sru \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 4085151497Sru \global\advance\unnumberedno by 1 4086114402Sru % 4087151497Sru % Since an unnumbered has no number, no prefix for figures. 4088151497Sru \global\let\chaplevelprefix = \empty 4089151497Sru \resetallfloatnos 4090151497Sru % 4091114402Sru % This used to be simply \message{#1}, but TeX fully expands the 4092114402Sru % argument to \message. Therefore, if #1 contained @-commands, TeX 4093114402Sru % expanded them. For example, in `@unnumbered The @cite{Book}', TeX 4094114402Sru % expanded @cite (which turns out to cause errors because \cite is meant 4095114402Sru % to be executed, not expanded). 4096114402Sru % 4097114402Sru % Anyway, we don't want the fully-expanded definition of @cite to appear 4098114402Sru % as a result of the \message, we just want `@cite' itself. We use 4099114402Sru % \the<toks register> to achieve this: TeX expands \the<toks> only once, 4100114402Sru % simply yielding the contents of <toks register>. (We also do this for 4101114402Sru % the toc entries.) 4102151497Sru \toks0 = {#1}% 4103151497Sru \message{(\the\toks0)}% 4104114402Sru % 4105151497Sru \chapmacro{#1}{Ynothing}{\the\unnumberedno}% 4106151497Sru % 4107114402Sru \global\let\section = \unnumberedsec 4108114402Sru \global\let\subsection = \unnumberedsubsec 4109114402Sru \global\let\subsubsection = \unnumberedsubsubsec 411069626Sru} 411169626Sru 4112151497Sru% @centerchap is like @unnumbered, but the heading is centered. 4113151497Sru\outer\parseargdef\centerchap{% 4114151497Sru % Well, we could do the following in a group, but that would break 4115151497Sru % an assumption that \chapmacro is called at the outermost level. 4116151497Sru % Thus we are safer this way: --kasal, 24feb04 4117151497Sru \let\centerparametersmaybe = \centerparameters 4118151497Sru \unnmhead0{#1}% 4119151497Sru \let\centerparametersmaybe = \relax 4120151497Sru} 4121151497Sru 4122151497Sru% @top is like @unnumbered. 4123151497Sru\let\top\unnumbered 4124151497Sru 412569626Sru% Sections. 4126151497Sru\outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz 4127151497Sru\def\seczzz#1{% 4128151497Sru \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 4129151497Sru \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}% 413069626Sru} 413169626Sru 4132151497Sru\outer\parseargdef\appendixsection{\apphead1{#1}} % normally calls appendixsectionzzz 4133151497Sru\def\appendixsectionzzz#1{% 4134151497Sru \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 4135151497Sru \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}% 413669626Sru} 4137151497Sru\let\appendixsec\appendixsection 413869626Sru 4139151497Sru\outer\parseargdef\unnumberedsec{\unnmhead1{#1}} % normally calls unnumberedseczzz 4140151497Sru\def\unnumberedseczzz#1{% 4141151497Sru \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 4142151497Sru \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}% 414369626Sru} 414469626Sru 414569626Sru% Subsections. 4146151497Sru\outer\parseargdef\numberedsubsec{\numhead2{#1}} % normally calls numberedsubseczzz 4147151497Sru\def\numberedsubseczzz#1{% 4148151497Sru \global\subsubsecno=0 \global\advance\subsecno by 1 4149151497Sru \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}% 415069626Sru} 415169626Sru 4152151497Sru\outer\parseargdef\appendixsubsec{\apphead2{#1}} % normally calls appendixsubseczzz 4153151497Sru\def\appendixsubseczzz#1{% 4154151497Sru \global\subsubsecno=0 \global\advance\subsecno by 1 4155151497Sru \sectionheading{#1}{subsec}{Yappendix}% 4156151497Sru {\appendixletter.\the\secno.\the\subsecno}% 415769626Sru} 415869626Sru 4159151497Sru\outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}} %normally calls unnumberedsubseczzz 4160151497Sru\def\unnumberedsubseczzz#1{% 4161151497Sru \global\subsubsecno=0 \global\advance\subsecno by 1 4162151497Sru \sectionheading{#1}{subsec}{Ynothing}% 4163151497Sru {\the\unnumberedno.\the\secno.\the\subsecno}% 416469626Sru} 416569626Sru 416669626Sru% Subsubsections. 4167151497Sru\outer\parseargdef\numberedsubsubsec{\numhead3{#1}} % normally numberedsubsubseczzz 4168151497Sru\def\numberedsubsubseczzz#1{% 4169151497Sru \global\advance\subsubsecno by 1 4170151497Sru \sectionheading{#1}{subsubsec}{Ynumbered}% 4171151497Sru {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}% 417269626Sru} 417369626Sru 4174151497Sru\outer\parseargdef\appendixsubsubsec{\apphead3{#1}} % normally appendixsubsubseczzz 4175151497Sru\def\appendixsubsubseczzz#1{% 4176151497Sru \global\advance\subsubsecno by 1 4177151497Sru \sectionheading{#1}{subsubsec}{Yappendix}% 4178151497Sru {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}% 417969626Sru} 418069626Sru 4181151497Sru\outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}} %normally unnumberedsubsubseczzz 4182151497Sru\def\unnumberedsubsubseczzz#1{% 4183151497Sru \global\advance\subsubsecno by 1 4184151497Sru \sectionheading{#1}{subsubsec}{Ynothing}% 4185151497Sru {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}% 418669626Sru} 418769626Sru 418869626Sru% These macros control what the section commands do, according 418969626Sru% to what kind of chapter we are in (ordinary, appendix, or unnumbered). 419069626Sru% Define them by default for a numbered chapter. 4191151497Sru\let\section = \numberedsec 4192151497Sru\let\subsection = \numberedsubsec 4193151497Sru\let\subsubsection = \numberedsubsubsec 419469626Sru 419569626Sru% Define @majorheading, @heading and @subheading 419669626Sru 419769626Sru% NOTE on use of \vbox for chapter headings, section headings, and such: 419869626Sru% 1) We use \vbox rather than the earlier \line to permit 419969626Sru% overlong headings to fold. 420069626Sru% 2) \hyphenpenalty is set to 10000 because hyphenation in a 420169626Sru% heading is obnoxious; this forbids it. 420269626Sru% 3) Likewise, headings look best if no \parindent is used, and 420369626Sru% if justification is not attempted. Hence \raggedright. 420469626Sru 420569626Sru 4206151497Sru\def\majorheading{% 4207114402Sru {\advance\chapheadingskip by 10pt \chapbreak }% 4208151497Sru \parsearg\chapheadingzzz 4209151497Sru} 421069626Sru 4211151497Sru\def\chapheading{\chapbreak \parsearg\chapheadingzzz} 4212151497Sru\def\chapheadingzzz#1{% 4213114402Sru {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 4214114402Sru \parindent=0pt\raggedright 4215151497Sru \rm #1\hfill}}% 4216151497Sru \bigskip \par\penalty 200\relax 4217151497Sru \suppressfirstparagraphindent 4218151497Sru} 421969626Sru 422069626Sru% @heading, @subheading, @subsubheading. 4221151497Sru\parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{} 4222151497Sru \suppressfirstparagraphindent} 4223151497Sru\parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{} 4224151497Sru \suppressfirstparagraphindent} 4225151497Sru\parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{} 4226151497Sru \suppressfirstparagraphindent} 422769626Sru 422869626Sru% These macros generate a chapter, section, etc. heading only 422969626Sru% (including whitespace, linebreaking, etc. around it), 423069626Sru% given all the information in convenient, parsed form. 423169626Sru 423269626Sru%%% Args are the skip and penalty (usually negative) 423369626Sru\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi} 423469626Sru 423569626Sru%%% Define plain chapter starts, and page on/off switching for it 423669626Sru% Parameter controlling skip before chapter headings (if needed) 423769626Sru 423869626Sru\newskip\chapheadingskip 423969626Sru 424069626Sru\def\chapbreak{\dobreak \chapheadingskip {-4000}} 424169626Sru\def\chappager{\par\vfill\supereject} 424269626Sru\def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi} 424369626Sru 424469626Sru\def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname} 424569626Sru 424669626Sru\def\CHAPPAGoff{% 424769626Sru\global\let\contentsalignmacro = \chappager 424869626Sru\global\let\pchapsepmacro=\chapbreak 424969626Sru\global\let\pagealignmacro=\chappager} 425069626Sru 425169626Sru\def\CHAPPAGon{% 425269626Sru\global\let\contentsalignmacro = \chappager 425369626Sru\global\let\pchapsepmacro=\chappager 425469626Sru\global\let\pagealignmacro=\chappager 425569626Sru\global\def\HEADINGSon{\HEADINGSsingle}} 425669626Sru 4257151497Sru\def\CHAPPAGodd{% 425869626Sru\global\let\contentsalignmacro = \chapoddpage 425969626Sru\global\let\pchapsepmacro=\chapoddpage 426069626Sru\global\let\pagealignmacro=\chapoddpage 426169626Sru\global\def\HEADINGSon{\HEADINGSdouble}} 426269626Sru 426369626Sru\CHAPPAGon 426469626Sru 4265151497Sru% Chapter opening. 4266151497Sru% 4267151497Sru% #1 is the text, #2 is the section type (Ynumbered, Ynothing, 4268151497Sru% Yappendix, Yomitfromtoc), #3 the chapter number. 4269151497Sru% 4270151497Sru% To test against our argument. 4271151497Sru\def\Ynothingkeyword{Ynothing} 4272151497Sru\def\Yomitfromtockeyword{Yomitfromtoc} 4273151497Sru\def\Yappendixkeyword{Yappendix} 4274151497Sru% 4275151497Sru\def\chapmacro#1#2#3{% 427669626Sru \pchapsepmacro 427769626Sru {% 427869626Sru \chapfonts \rm 4279151497Sru % 4280151497Sru % Have to define \thissection before calling \donoderef, because the 4281151497Sru % xref code eventually uses it. On the other hand, it has to be called 4282151497Sru % after \pchapsepmacro, or the headline will change too soon. 4283151497Sru \gdef\thissection{#1}% 4284151497Sru \gdef\thischaptername{#1}% 4285151497Sru % 4286151497Sru % Only insert the separating space if we have a chapter/appendix 4287151497Sru % number, and don't print the unnumbered ``number''. 4288151497Sru \def\temptype{#2}% 4289151497Sru \ifx\temptype\Ynothingkeyword 4290151497Sru \setbox0 = \hbox{}% 4291151497Sru \def\toctype{unnchap}% 4292151497Sru \def\thischapter{#1}% 4293151497Sru \else\ifx\temptype\Yomitfromtockeyword 4294151497Sru \setbox0 = \hbox{}% contents like unnumbered, but no toc entry 4295151497Sru \def\toctype{omit}% 4296151497Sru \xdef\thischapter{}% 4297151497Sru \else\ifx\temptype\Yappendixkeyword 4298151497Sru \setbox0 = \hbox{\putwordAppendix{} #3\enspace}% 4299151497Sru \def\toctype{app}% 4300151497Sru % We don't substitute the actual chapter name into \thischapter 4301151497Sru % because we don't want its macros evaluated now. And we don't 4302151497Sru % use \thissection because that changes with each section. 4303151497Sru % 4304151497Sru \xdef\thischapter{\putwordAppendix{} \appendixletter: 4305151497Sru \noexpand\thischaptername}% 4306151497Sru \else 4307151497Sru \setbox0 = \hbox{#3\enspace}% 4308151497Sru \def\toctype{numchap}% 4309151497Sru \xdef\thischapter{\putwordChapter{} \the\chapno: 4310151497Sru \noexpand\thischaptername}% 4311151497Sru \fi\fi\fi 4312151497Sru % 4313151497Sru % Write the toc entry for this chapter. Must come before the 4314151497Sru % \donoderef, because we include the current node name in the toc 4315151497Sru % entry, and \donoderef resets it to empty. 4316151497Sru \writetocentry{\toctype}{#1}{#3}% 4317151497Sru % 4318151497Sru % For pdftex, we have to write out the node definition (aka, make 4319151497Sru % the pdfdest) after any page break, but before the actual text has 4320151497Sru % been typeset. If the destination for the pdf outline is after the 4321151497Sru % text, then jumping from the outline may wind up with the text not 4322151497Sru % being visible, for instance under high magnification. 4323151497Sru \donoderef{#2}% 4324151497Sru % 4325151497Sru % Typeset the actual heading. 432669626Sru \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright 4327151497Sru \hangindent=\wd0 \centerparametersmaybe 432869626Sru \unhbox0 #1\par}% 432969626Sru }% 433069626Sru \nobreak\bigskip % no page break after a chapter title 433169626Sru \nobreak 433269626Sru} 433369626Sru 433469626Sru% @centerchap -- centered and unnumbered. 433569626Sru\let\centerparametersmaybe = \relax 4336151497Sru\def\centerparameters{% 4337151497Sru \advance\rightskip by 3\rightskip 4338151497Sru \leftskip = \rightskip 4339151497Sru \parfillskip = 0pt 4340151497Sru} 434169626Sru 434269626Sru 4343151497Sru% I don't think this chapter style is supported any more, so I'm not 4344151497Sru% updating it with the new noderef stuff. We'll see. --karl, 11aug03. 4345151497Sru% 4346151497Sru\def\setchapterstyle #1 {\csname CHAPF#1\endcsname} 4347151497Sru% 434869626Sru\def\unnchfopen #1{% 434969626Sru\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 435069626Sru \parindent=0pt\raggedright 435169626Sru \rm #1\hfill}}\bigskip \par\nobreak 435269626Sru} 435369626Sru\def\chfopen #1#2{\chapoddpage {\chapfonts 435469626Sru\vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}% 435569626Sru\par\penalty 5000 % 435669626Sru} 435769626Sru\def\centerchfopen #1{% 435869626Sru\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 435969626Sru \parindent=0pt 436069626Sru \hfill {\rm #1}\hfill}}\bigskip \par\nobreak 436169626Sru} 4362151497Sru\def\CHAPFopen{% 4363151497Sru \global\let\chapmacro=\chfopen 4364151497Sru \global\let\centerchapmacro=\centerchfopen} 436569626Sru 436669626Sru 4367151497Sru% Section titles. These macros combine the section number parts and 4368151497Sru% call the generic \sectionheading to do the printing. 4369151497Sru% 437069626Sru\newskip\secheadingskip 4371151497Sru\def\secheadingbreak{\dobreak \secheadingskip{-1000}} 437269626Sru 437369626Sru% Subsection titles. 4374151497Sru\newskip\subsecheadingskip 4375151497Sru\def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}} 437669626Sru 437769626Sru% Subsubsection titles. 4378151497Sru\def\subsubsecheadingskip{\subsecheadingskip} 4379151497Sru\def\subsubsecheadingbreak{\subsecheadingbreak} 438069626Sru 438169626Sru 4382151497Sru% Print any size, any type, section title. 438369626Sru% 4384151497Sru% #1 is the text, #2 is the section level (sec/subsec/subsubsec), #3 is 4385151497Sru% the section type for xrefs (Ynumbered, Ynothing, Yappendix), #4 is the 4386151497Sru% section number. 4387151497Sru% 4388151497Sru\def\sectionheading#1#2#3#4{% 438969626Sru {% 439069626Sru % Switch to the right set of fonts. 4391151497Sru \csname #2fonts\endcsname \rm 439269626Sru % 4393151497Sru % Insert space above the heading. 4394151497Sru \csname #2headingbreak\endcsname 439569626Sru % 4396151497Sru % Only insert the space after the number if we have a section number. 4397151497Sru \def\sectionlevel{#2}% 4398151497Sru \def\temptype{#3}% 4399151497Sru % 4400151497Sru \ifx\temptype\Ynothingkeyword 4401151497Sru \setbox0 = \hbox{}% 4402151497Sru \def\toctype{unn}% 4403151497Sru \gdef\thissection{#1}% 4404151497Sru \else\ifx\temptype\Yomitfromtockeyword 4405151497Sru % for @headings -- no section number, don't include in toc, 4406151497Sru % and don't redefine \thissection. 4407151497Sru \setbox0 = \hbox{}% 4408151497Sru \def\toctype{omit}% 4409151497Sru \let\sectionlevel=\empty 4410151497Sru \else\ifx\temptype\Yappendixkeyword 4411151497Sru \setbox0 = \hbox{#4\enspace}% 4412151497Sru \def\toctype{app}% 4413151497Sru \gdef\thissection{#1}% 4414151497Sru \else 4415151497Sru \setbox0 = \hbox{#4\enspace}% 4416151497Sru \def\toctype{num}% 4417151497Sru \gdef\thissection{#1}% 4418151497Sru \fi\fi\fi 4419151497Sru % 4420151497Sru % Write the toc entry (before \donoderef). See comments in \chfplain. 4421151497Sru \writetocentry{\toctype\sectionlevel}{#1}{#4}% 4422151497Sru % 4423151497Sru % Write the node reference (= pdf destination for pdftex). 4424151497Sru % Again, see comments in \chfplain. 4425151497Sru \donoderef{#3}% 4426151497Sru % 4427151497Sru % Output the actual section heading. 442869626Sru \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright 4429151497Sru \hangindent=\wd0 % zero if no section number 4430151497Sru \unhbox0 #1}% 443169626Sru }% 4432151497Sru % Add extra space after the heading -- half of whatever came above it. 4433151497Sru % Don't allow stretch, though. 4434151497Sru \kern .5 \csname #2headingskip\endcsname 4435151497Sru % 4436151497Sru % Do not let the kern be a potential breakpoint, as it would be if it 4437151497Sru % was followed by glue. 4438114402Sru \nobreak 4439151497Sru % 4440151497Sru % We'll almost certainly start a paragraph next, so don't let that 4441151497Sru % glue accumulate. (Not a breakpoint because it's preceded by a 4442151497Sru % discardable item.) 4443151497Sru \vskip-\parskip 4444151497Sru % 4445151497Sru % This is purely so the last item on the list is a known \penalty > 4446151497Sru % 10000. This is so \startdefun can avoid allowing breakpoints after 4447151497Sru % section headings. Otherwise, it would insert a valid breakpoint between: 4448151497Sru % 4449151497Sru % @section sec-whatever 4450151497Sru % @deffn def-whatever 4451151497Sru \penalty 10001 445269626Sru} 445369626Sru 445469626Sru 445569626Sru\message{toc,} 445669626Sru% Table of contents. 445769626Sru\newwrite\tocfile 445869626Sru 445969626Sru% Write an entry to the toc file, opening it if necessary. 4460151497Sru% Called from @chapter, etc. 446169626Sru% 4462151497Sru% Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno} 4463151497Sru% We append the current node name (if any) and page number as additional 4464151497Sru% arguments for the \{chap,sec,...}entry macros which will eventually 4465151497Sru% read this. The node name is used in the pdf outlines as the 4466151497Sru% destination to jump to. 4467151497Sru% 4468114402Sru% We open the .toc file for writing here instead of at @setfilename (or 4469114402Sru% any other fixed time) so that @contents can be anywhere in the document. 4470151497Sru% But if #1 is `omit', then we don't do anything. This is used for the 4471151497Sru% table of contents chapter openings themselves. 447269626Sru% 447369626Sru\newif\iftocfileopened 4474151497Sru\def\omitkeyword{omit}% 4475151497Sru% 4476114402Sru\def\writetocentry#1#2#3{% 4477151497Sru \edef\writetoctype{#1}% 4478151497Sru \ifx\writetoctype\omitkeyword \else 4479151497Sru \iftocfileopened\else 4480151497Sru \immediate\openout\tocfile = \jobname.toc 4481151497Sru \global\tocfileopenedtrue 4482151497Sru \fi 4483151497Sru % 4484151497Sru \iflinks 4485151497Sru \toks0 = {#2}% 4486151497Sru \toks2 = \expandafter{\lastnode}% 4487151497Sru \edef\temp{\write\tocfile{\realbackslash #1entry{\the\toks0}{#3}% 4488151497Sru {\the\toks2}{\noexpand\folio}}}% 4489151497Sru \temp 4490151497Sru \fi 449169626Sru \fi 4492104862Sru % 4493151497Sru % Tell \shipout to create a pdf destination on each page, if we're 4494151497Sru % writing pdf. These are used in the table of contents. We can't 4495151497Sru % just write one on every page because the title pages are numbered 4496151497Sru % 1 and 2 (the page numbers aren't printed), and so are the first 4497151497Sru % two pages of the document. Thus, we'd have two destinations named 4498151497Sru % `1', and two named `2'. 4499151497Sru \ifpdf \global\pdfmakepagedesttrue \fi 450069626Sru} 450169626Sru 450269626Sru\newskip\contentsrightmargin \contentsrightmargin=1in 450369626Sru\newcount\savepageno 450469626Sru\newcount\lastnegativepageno \lastnegativepageno = -1 450569626Sru 4506151497Sru% Prepare to read what we've written to \tocfile. 450769626Sru% 450869626Sru\def\startcontents#1{% 4509151497Sru % If @setchapternewpage on, and @headings double, the contents should 4510151497Sru % start on an odd page, unlike chapters. Thus, we maintain 4511151497Sru % \contentsalignmacro in parallel with \pagealignmacro. 4512151497Sru % From: Torbjorn Granlund <tege@matematik.su.se> 4513151497Sru \contentsalignmacro 4514151497Sru \immediate\closeout\tocfile 4515151497Sru % 4516151497Sru % Don't need to put `Contents' or `Short Contents' in the headline. 4517151497Sru % It is abundantly clear what they are. 4518151497Sru \def\thischapter{}% 4519151497Sru \chapmacro{#1}{Yomitfromtoc}{}% 4520151497Sru % 4521151497Sru \savepageno = \pageno 4522151497Sru \begingroup % Set up to handle contents files properly. 4523151497Sru \catcode`\\=0 \catcode`\{=1 \catcode`\}=2 \catcode`\@=11 4524151497Sru % We can't do this, because then an actual ^ in a section 4525151497Sru % title fails, e.g., @chapter ^ -- exponentiation. --karl, 9jul97. 4526151497Sru %\catcode`\^=7 % to see ^^e4 as \"a etc. juha@piuha.ydi.vtt.fi 4527151497Sru \raggedbottom % Worry more about breakpoints than the bottom. 4528151497Sru \advance\hsize by -\contentsrightmargin % Don't use the full line length. 4529151497Sru % 4530151497Sru % Roman numerals for page numbers. 4531151497Sru \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi 453269626Sru} 453369626Sru 453469626Sru 453569626Sru% Normal (long) toc. 453669626Sru\def\contents{% 4537151497Sru \startcontents{\putwordTOC}% 4538151497Sru \openin 1 \jobname.toc 4539151497Sru \ifeof 1 \else 4540151497Sru \input \jobname.toc 4541151497Sru \fi 4542151497Sru \vfill \eject 4543151497Sru \contentsalignmacro % in case @setchapternewpage odd is in effect 4544151497Sru \ifeof 1 \else 4545151497Sru \pdfmakeoutlines 4546151497Sru \fi 4547151497Sru \closein 1 4548151497Sru \endgroup 4549151497Sru \lastnegativepageno = \pageno 4550151497Sru \global\pageno = \savepageno 455169626Sru} 455269626Sru 455369626Sru% And just the chapters. 455469626Sru\def\summarycontents{% 4555151497Sru \startcontents{\putwordShortTOC}% 4556151497Sru % 4557151497Sru \let\numchapentry = \shortchapentry 4558151497Sru \let\appentry = \shortchapentry 4559151497Sru \let\unnchapentry = \shortunnchapentry 4560151497Sru % We want a true roman here for the page numbers. 4561151497Sru \secfonts 4562151497Sru \let\rm=\shortcontrm \let\bf=\shortcontbf 4563151497Sru \let\sl=\shortcontsl \let\tt=\shortconttt 4564151497Sru \rm 4565151497Sru \hyphenpenalty = 10000 4566151497Sru \advance\baselineskip by 1pt % Open it up a little. 4567151497Sru \def\numsecentry##1##2##3##4{} 4568151497Sru \let\appsecentry = \numsecentry 4569151497Sru \let\unnsecentry = \numsecentry 4570151497Sru \let\numsubsecentry = \numsecentry 4571151497Sru \let\appsubsecentry = \numsecentry 4572151497Sru \let\unnsubsecentry = \numsecentry 4573151497Sru \let\numsubsubsecentry = \numsecentry 4574151497Sru \let\appsubsubsecentry = \numsecentry 4575151497Sru \let\unnsubsubsecentry = \numsecentry 4576151497Sru \openin 1 \jobname.toc 4577151497Sru \ifeof 1 \else 4578151497Sru \input \jobname.toc 4579151497Sru \fi 4580151497Sru \closein 1 4581151497Sru \vfill \eject 4582151497Sru \contentsalignmacro % in case @setchapternewpage odd is in effect 4583151497Sru \endgroup 4584151497Sru \lastnegativepageno = \pageno 4585151497Sru \global\pageno = \savepageno 458669626Sru} 458769626Sru\let\shortcontents = \summarycontents 458869626Sru 4589151497Sru% Typeset the label for a chapter or appendix for the short contents. 4590151497Sru% The arg is, e.g., `A' for an appendix, or `3' for a chapter. 4591151497Sru% 4592151497Sru\def\shortchaplabel#1{% 4593151497Sru % This space should be enough, since a single number is .5em, and the 4594151497Sru % widest letter (M) is 1em, at least in the Computer Modern fonts. 4595151497Sru % But use \hss just in case. 4596151497Sru % (This space doesn't include the extra space that gets added after 4597151497Sru % the label; that gets put in by \shortchapentry above.) 4598151497Sru % 4599151497Sru % We'd like to right-justify chapter numbers, but that looks strange 4600151497Sru % with appendix letters. And right-justifying numbers and 4601151497Sru % left-justifying letters looks strange when there is less than 10 4602151497Sru % chapters. Have to read the whole toc once to know how many chapters 4603151497Sru % there are before deciding ... 4604151497Sru \hbox to 1em{#1\hss}% 4605151497Sru} 460669626Sru 460769626Sru% These macros generate individual entries in the table of contents. 460869626Sru% The first argument is the chapter or section name. 460969626Sru% The last argument is the page number. 461069626Sru% The arguments in between are the chapter number, section number, ... 461169626Sru 4612104862Sru% Chapters, in the main contents. 4613151497Sru\def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}} 4614104862Sru% 4615104862Sru% Chapters, in the short toc. 4616104862Sru% See comments in \dochapentry re vbox and related settings. 4617151497Sru\def\shortchapentry#1#2#3#4{% 4618151497Sru \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}% 461969626Sru} 462069626Sru 4621104862Sru% Appendices, in the main contents. 4622151497Sru% Need the word Appendix, and a fixed-size box. 4623104862Sru% 4624151497Sru\def\appendixbox#1{% 4625151497Sru % We use M since it's probably the widest letter. 4626151497Sru \setbox0 = \hbox{\putwordAppendix{} M}% 4627151497Sru \hbox to \wd0{\putwordAppendix{} #1\hss}} 462869626Sru% 4629151497Sru\def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\labelspace#1}{#4}} 463069626Sru 4631104862Sru% Unnumbered chapters. 4632151497Sru\def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}} 4633151497Sru\def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}} 463469626Sru 463569626Sru% Sections. 4636151497Sru\def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}} 4637151497Sru\let\appsecentry=\numsecentry 4638151497Sru\def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}} 463969626Sru 464069626Sru% Subsections. 4641151497Sru\def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}} 4642151497Sru\let\appsubsecentry=\numsubsecentry 4643151497Sru\def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}} 464469626Sru 464569626Sru% And subsubsections. 4646151497Sru\def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}} 4647151497Sru\let\appsubsubsecentry=\numsubsubsecentry 4648151497Sru\def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}} 464969626Sru 465069626Sru% This parameter controls the indentation of the various levels. 4651151497Sru% Same as \defaultparindent. 4652151497Sru\newdimen\tocindent \tocindent = 15pt 465369626Sru 465469626Sru% Now for the actual typesetting. In all these, #1 is the text and #2 is the 465569626Sru% page number. 465669626Sru% 465769626Sru% If the toc has to be broken over pages, we want it to be at chapters 465869626Sru% if at all possible; hence the \penalty. 465969626Sru\def\dochapentry#1#2{% 466069626Sru \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip 466169626Sru \begingroup 466269626Sru \chapentryfonts 466369626Sru \tocentry{#1}{\dopageno\bgroup#2\egroup}% 466469626Sru \endgroup 466569626Sru \nobreak\vskip .25\baselineskip plus.1\baselineskip 466669626Sru} 466769626Sru 466869626Sru\def\dosecentry#1#2{\begingroup 466969626Sru \secentryfonts \leftskip=\tocindent 467069626Sru \tocentry{#1}{\dopageno\bgroup#2\egroup}% 467169626Sru\endgroup} 467269626Sru 467369626Sru\def\dosubsecentry#1#2{\begingroup 467469626Sru \subsecentryfonts \leftskip=2\tocindent 467569626Sru \tocentry{#1}{\dopageno\bgroup#2\egroup}% 467669626Sru\endgroup} 467769626Sru 467869626Sru\def\dosubsubsecentry#1#2{\begingroup 467969626Sru \subsubsecentryfonts \leftskip=3\tocindent 468069626Sru \tocentry{#1}{\dopageno\bgroup#2\egroup}% 468169626Sru\endgroup} 468269626Sru 4683151497Sru% We use the same \entry macro as for the index entries. 4684151497Sru\let\tocentry = \entry 468569626Sru 468669626Sru% Space between chapter (or whatever) number and the title. 468769626Sru\def\labelspace{\hskip1em \relax} 468869626Sru 468969626Sru\def\dopageno#1{{\rm #1}} 469069626Sru\def\doshortpageno#1{{\rm #1}} 469169626Sru 469269626Sru\def\chapentryfonts{\secfonts \rm} 469369626Sru\def\secentryfonts{\textfonts} 4694151497Sru\def\subsecentryfonts{\textfonts} 4695151497Sru\def\subsubsecentryfonts{\textfonts} 469669626Sru 469769626Sru 469869626Sru\message{environments,} 469969626Sru% @foo ... @end foo. 470069626Sru 4701104862Sru% @point{}, @result{}, @expansion{}, @print{}, @equiv{}. 4702151497Sru% 470369626Sru% Since these characters are used in examples, it should be an even number of 470469626Sru% \tt widths. Each \tt character is 1en, so two makes it 1em. 4705104862Sru% 470669626Sru\def\point{$\star$} 470769626Sru\def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}} 470869626Sru\def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}} 470969626Sru\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}} 471069626Sru\def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}} 471169626Sru 4712104862Sru% The @error{} command. 471369626Sru% Adapted from the TeXbook's \boxit. 4714151497Sru% 4715104862Sru\newbox\errorbox 4716104862Sru% 471769626Sru{\tentt \global\dimen0 = 3em}% Width of the box. 471869626Sru\dimen2 = .55pt % Thickness of rules 471969626Sru% The text. (`r' is open on the right, `e' somewhat less so on the left.) 472069626Sru\setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt} 4721104862Sru% 4722151497Sru\setbox\errorbox=\hbox to \dimen0{\hfil 472369626Sru \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right. 472469626Sru \advance\hsize by -2\dimen2 % Rules. 4725151497Sru \vbox{% 472669626Sru \hrule height\dimen2 472769626Sru \hbox{\vrule width\dimen2 \kern3pt % Space to left of text. 472869626Sru \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below. 472969626Sru \kern3pt\vrule width\dimen2}% Space to right. 473069626Sru \hrule height\dimen2} 473169626Sru \hfil} 4732104862Sru% 473369626Sru\def\error{\leavevmode\lower.7ex\copy\errorbox} 473469626Sru 473569626Sru% @tex ... @end tex escapes into raw Tex temporarily. 473669626Sru% One exception: @ is still an escape character, so that @end tex works. 473769626Sru% But \@ or @@ will get a plain tex @ character. 473869626Sru 4739151497Sru\envdef\tex{% 474069626Sru \catcode `\\=0 \catcode `\{=1 \catcode `\}=2 474169626Sru \catcode `\$=3 \catcode `\&=4 \catcode `\#=6 4742114402Sru \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie 474369626Sru \catcode `\%=14 4744114402Sru \catcode `\+=\other 4745114402Sru \catcode `\"=\other 4746114402Sru \catcode `\|=\other 4747114402Sru \catcode `\<=\other 4748114402Sru \catcode `\>=\other 474969626Sru \escapechar=`\\ 475069626Sru % 475169626Sru \let\b=\ptexb 475269626Sru \let\bullet=\ptexbullet 475369626Sru \let\c=\ptexc 475469626Sru \let\,=\ptexcomma 475569626Sru \let\.=\ptexdot 475669626Sru \let\dots=\ptexdots 475769626Sru \let\equiv=\ptexequiv 475869626Sru \let\!=\ptexexclam 475969626Sru \let\i=\ptexi 4760151497Sru \let\indent=\ptexindent 4761151497Sru \let\noindent=\ptexnoindent 476269626Sru \let\{=\ptexlbrace 476369626Sru \let\+=\tabalign 476469626Sru \let\}=\ptexrbrace 4765151497Sru \let\/=\ptexslash 476669626Sru \let\*=\ptexstar 476769626Sru \let\t=\ptext 476869626Sru % 476969626Sru \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}% 477069626Sru \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}% 477169626Sru \def\@{@}% 4772151497Sru} 4773151497Sru% There is no need to define \Etex. 477469626Sru 4775104862Sru% Define @lisp ... @end lisp. 4776151497Sru% @lisp environment forms a group so it can rebind things, 4777104862Sru% including the definition of @end lisp (which normally is erroneous). 477869626Sru 477969626Sru% Amount to narrow the margins by for @lisp. 478069626Sru\newskip\lispnarrowing \lispnarrowing=0.4in 478169626Sru 478269626Sru% This is the definition that ^^M gets inside @lisp, @example, and other 478369626Sru% such environments. \null is better than a space, since it doesn't 478469626Sru% have any width. 478569626Sru\def\lisppar{\null\endgraf} 478669626Sru 478769626Sru% This space is always present above and below environments. 478869626Sru\newskip\envskipamount \envskipamount = 0pt 478969626Sru 479069626Sru% Make spacing and below environment symmetrical. We use \parskip here 479169626Sru% to help in doing that, since in @example-like environments \parskip 479269626Sru% is reset to zero; thus the \afterenvbreak inserts no space -- but the 4793114402Sru% start of the next paragraph will insert \parskip. 479469626Sru% 4795104862Sru\def\aboveenvbreak{{% 4796151497Sru % =10000 instead of <10000 because of a special case in \itemzzz and 4797151497Sru % \sectionheading, q.v. 4798114402Sru \ifnum \lastpenalty=10000 \else 4799104862Sru \advance\envskipamount by \parskip 4800104862Sru \endgraf 4801104862Sru \ifdim\lastskip<\envskipamount 4802104862Sru \removelastskip 4803114402Sru % it's not a good place to break if the last penalty was \nobreak 4804114402Sru % or better ... 4805151497Sru \ifnum\lastpenalty<10000 \penalty-50 \fi 4806104862Sru \vskip\envskipamount 4807104862Sru \fi 4808104862Sru \fi 4809104862Sru}} 481069626Sru 481169626Sru\let\afterenvbreak = \aboveenvbreak 481269626Sru 481369626Sru% \nonarrowing is a flag. If "set", @lisp etc don't narrow margins. 481469626Sru\let\nonarrowing=\relax 481569626Sru 481669626Sru% @cartouche ... @end cartouche: draw rectangle w/rounded corners around 481769626Sru% environment contents. 481869626Sru\font\circle=lcircle10 481969626Sru\newdimen\circthick 482069626Sru\newdimen\cartouter\newdimen\cartinner 482169626Sru\newskip\normbskip\newskip\normpskip\newskip\normlskip 482269626Sru\circthick=\fontdimen8\circle 482369626Sru% 482469626Sru\def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth 482569626Sru\def\ctr{{\hskip 6pt\circle\char'010}} 482669626Sru\def\cbl{{\circle\char'012\hskip -6pt}} 482769626Sru\def\cbr{{\hskip 6pt\circle\char'011}} 482869626Sru\def\carttop{\hbox to \cartouter{\hskip\lskip 482969626Sru \ctl\leaders\hrule height\circthick\hfil\ctr 483069626Sru \hskip\rskip}} 483169626Sru\def\cartbot{\hbox to \cartouter{\hskip\lskip 483269626Sru \cbl\leaders\hrule height\circthick\hfil\cbr 483369626Sru \hskip\rskip}} 483469626Sru% 483569626Sru\newskip\lskip\newskip\rskip 483669626Sru 4837151497Sru\envdef\cartouche{% 4838151497Sru \ifhmode\par\fi % can't be in the midst of a paragraph. 4839151497Sru \startsavinginserts 4840151497Sru \lskip=\leftskip \rskip=\rightskip 4841151497Sru \leftskip=0pt\rightskip=0pt % we want these *outside*. 4842151497Sru \cartinner=\hsize \advance\cartinner by-\lskip 4843151497Sru \advance\cartinner by-\rskip 4844151497Sru \cartouter=\hsize 4845151497Sru \advance\cartouter by 18.4pt % allow for 3pt kerns on either 4846151497Sru % side, and for 6pt waste from 4847151497Sru % each corner char, and rule thickness 4848151497Sru \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip 4849151497Sru % Flag to tell @lisp, etc., not to narrow margin. 4850151497Sru \let\nonarrowing=\comment 4851151497Sru \vbox\bgroup 4852151497Sru \baselineskip=0pt\parskip=0pt\lineskip=0pt 4853151497Sru \carttop 4854151497Sru \hbox\bgroup 4855151497Sru \hskip\lskip 4856151497Sru \vrule\kern3pt 4857151497Sru \vbox\bgroup 4858151497Sru \kern3pt 4859151497Sru \hsize=\cartinner 4860151497Sru \baselineskip=\normbskip 4861151497Sru \lineskip=\normlskip 4862151497Sru \parskip=\normpskip 4863151497Sru \vskip -\parskip 4864151497Sru \comment % For explanation, see the end of \def\group. 4865151497Sru} 486669626Sru\def\Ecartouche{% 4867151497Sru \ifhmode\par\fi 4868151497Sru \kern3pt 4869151497Sru \egroup 4870151497Sru \kern3pt\vrule 4871151497Sru \hskip\rskip 4872151497Sru \egroup 4873151497Sru \cartbot 4874151497Sru \egroup 4875151497Sru \checkinserts 4876151497Sru} 487769626Sru 487869626Sru 487969626Sru% This macro is called at the beginning of all the @example variants, 488069626Sru% inside a group. 488169626Sru\def\nonfillstart{% 488269626Sru \aboveenvbreak 488369626Sru \hfuzz = 12pt % Don't be fussy 488469626Sru \sepspaces % Make spaces be word-separators rather than space tokens. 488569626Sru \let\par = \lisppar % don't ignore blank lines 488669626Sru \obeylines % each line of input is a line of output 488769626Sru \parskip = 0pt 488869626Sru \parindent = 0pt 488969626Sru \emergencystretch = 0pt % don't try to avoid overfull boxes 489069626Sru % @cartouche defines \nonarrowing to inhibit narrowing 489169626Sru % at next level down. 489269626Sru \ifx\nonarrowing\relax 489369626Sru \advance \leftskip by \lispnarrowing 489469626Sru \exdentamount=\lispnarrowing 489569626Sru \fi 4896151497Sru \let\exdent=\nofillexdent 489769626Sru} 489869626Sru 4899151497Sru% If you want all examples etc. small: @set dispenvsize small. 4900151497Sru% If you want even small examples the full size: @set dispenvsize nosmall. 4901151497Sru% This affects the following displayed environments: 4902151497Sru% @example, @display, @format, @lisp 490369626Sru% 4904151497Sru\def\smallword{small} 4905151497Sru\def\nosmallword{nosmall} 4906151497Sru\let\SETdispenvsize\relax 4907151497Sru\def\setnormaldispenv{% 4908151497Sru \ifx\SETdispenvsize\smallword 4909151497Sru \smallexamplefonts \rm 4910151497Sru \fi 4911151497Sru} 4912151497Sru\def\setsmalldispenv{% 4913151497Sru \ifx\SETdispenvsize\nosmallword 4914151497Sru \else 4915151497Sru \smallexamplefonts \rm 4916151497Sru \fi 4917151497Sru} 491869626Sru 4919151497Sru% We often define two environments, @foo and @smallfoo. 4920151497Sru% Let's do it by one command: 4921151497Sru\def\makedispenv #1#2{ 4922151497Sru \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2} 4923151497Sru \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2} 4924151497Sru \expandafter\let\csname E#1\endcsname \afterenvbreak 4925151497Sru \expandafter\let\csname Esmall#1\endcsname \afterenvbreak 492669626Sru} 492769626Sru 4928151497Sru% Define two synonyms: 4929151497Sru\def\maketwodispenvs #1#2#3{ 4930151497Sru \makedispenv{#1}{#3} 4931151497Sru \makedispenv{#2}{#3} 4932151497Sru} 493369626Sru 4934151497Sru% @lisp: indented, narrowed, typewriter font; @example: same as @lisp. 4935151497Sru% 4936114402Sru% @smallexample and @smalllisp: use smaller fonts. 493769626Sru% Originally contributed by Pavel@xerox. 4938151497Sru% 4939151497Sru\maketwodispenvs {lisp}{example}{% 4940151497Sru \nonfillstart 4941151497Sru \tt 4942151497Sru \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special. 4943151497Sru \gobble % eat return 494469626Sru} 494569626Sru 4946151497Sru% @display/@smalldisplay: same as @lisp except keep current font. 494769626Sru% 4948151497Sru\makedispenv {display}{% 494969626Sru \nonfillstart 495069626Sru \gobble 495169626Sru} 4952151497Sru 4953151497Sru% @format/@smallformat: same as @display except don't narrow margins. 4954104862Sru% 4955151497Sru\makedispenv{format}{% 4956151497Sru \let\nonarrowing = t% 4957151497Sru \nonfillstart 4958151497Sru \gobble 495969626Sru} 496069626Sru 4961151497Sru% @flushleft: same as @format, but doesn't obey \SETdispenvsize. 4962151497Sru\envdef\flushleft{% 4963151497Sru \let\nonarrowing = t% 496469626Sru \nonfillstart 496569626Sru \gobble 496669626Sru} 4967151497Sru\let\Eflushleft = \afterenvbreak 496869626Sru 496969626Sru% @flushright. 497069626Sru% 4971151497Sru\envdef\flushright{% 4972151497Sru \let\nonarrowing = t% 497369626Sru \nonfillstart 497469626Sru \advance\leftskip by 0pt plus 1fill 497569626Sru \gobble 497669626Sru} 4977151497Sru\let\Eflushright = \afterenvbreak 497869626Sru 4979104862Sru 498069626Sru% @quotation does normal linebreaking (hence we can't use \nonfillstart) 4981151497Sru% and narrows the margins. We keep \parskip nonzero in general, since 4982151497Sru% we're doing normal filling. So, when using \aboveenvbreak and 4983151497Sru% \afterenvbreak, temporarily make \parskip 0. 498469626Sru% 4985151497Sru\envdef\quotation{% 498669626Sru {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip 498769626Sru \parindent=0pt 498869626Sru % 498969626Sru % @cartouche defines \nonarrowing to inhibit narrowing at next level down. 499069626Sru \ifx\nonarrowing\relax 499169626Sru \advance\leftskip by \lispnarrowing 499269626Sru \advance\rightskip by \lispnarrowing 499369626Sru \exdentamount = \lispnarrowing 499469626Sru \let\nonarrowing = \relax 499569626Sru \fi 4996151497Sru \parsearg\quotationlabel 499769626Sru} 499869626Sru 4999151497Sru% We have retained a nonzero parskip for the environment, since we're 5000151497Sru% doing normal filling. 5001151497Sru% 5002151497Sru\def\Equotation{% 5003151497Sru \par 5004151497Sru \ifx\quotationauthor\undefined\else 5005151497Sru % indent a bit. 5006151497Sru \leftline{\kern 2\leftskip \sl ---\quotationauthor}% 5007151497Sru \fi 5008151497Sru {\parskip=0pt \afterenvbreak}% 5009151497Sru} 501069626Sru 5011151497Sru% If we're given an argument, typeset it in bold with a colon after. 5012151497Sru\def\quotationlabel#1{% 5013151497Sru \def\temp{#1}% 5014151497Sru \ifx\temp\empty \else 5015151497Sru {\bf #1: }% 5016151497Sru \fi 5017151497Sru} 5018151497Sru 5019151497Sru 5020104862Sru% LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>} 5021151497Sru% If we want to allow any <char> as delimiter, 5022104862Sru% we need the curly braces so that makeinfo sees the @verb command, eg: 5023104862Sru% `@verbx...x' would look like the '@verbx' command. --janneke@gnu.org 5024104862Sru% 5025104862Sru% [Knuth]: Donald Ervin Knuth, 1996. The TeXbook. 5026104862Sru% 5027114402Sru% [Knuth] p.344; only we need to do the other characters Texinfo sets 5028114402Sru% active too. Otherwise, they get lost as the first character on a 5029114402Sru% verbatim line. 5030104862Sru\def\dospecials{% 5031114402Sru \do\ \do\\\do\{\do\}\do\$\do\&% 5032114402Sru \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~% 5033114402Sru \do\<\do\>\do\|\do\@\do+\do\"% 5034114402Sru} 5035104862Sru% 5036104862Sru% [Knuth] p. 380 5037104862Sru\def\uncatcodespecials{% 5038151497Sru \def\do##1{\catcode`##1=\other}\dospecials} 5039104862Sru% 5040104862Sru% [Knuth] pp. 380,381,391 5041104862Sru% Disable Spanish ligatures ?` and !` of \tt font 5042104862Sru\begingroup 5043104862Sru \catcode`\`=\active\gdef`{\relax\lq} 5044104862Sru\endgroup 5045104862Sru% 5046104862Sru% Setup for the @verb command. 5047104862Sru% 5048104862Sru% Eight spaces for a tab 5049104862Sru\begingroup 5050104862Sru \catcode`\^^I=\active 5051104862Sru \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }} 5052104862Sru\endgroup 5053104862Sru% 5054104862Sru\def\setupverb{% 5055104862Sru \tt % easiest (and conventionally used) font for verbatim 5056104862Sru \def\par{\leavevmode\endgraf}% 5057104862Sru \catcode`\`=\active 5058104862Sru \tabeightspaces 5059104862Sru % Respect line breaks, 5060104862Sru % print special symbols as themselves, and 5061104862Sru % make each space count 5062104862Sru % must do in this order: 5063104862Sru \obeylines \uncatcodespecials \sepspaces 5064104862Sru} 5065104862Sru 5066104862Sru% Setup for the @verbatim environment 5067104862Sru% 5068104862Sru% Real tab expansion 5069104862Sru\newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount 5070104862Sru% 5071104862Sru\def\starttabbox{\setbox0=\hbox\bgroup} 5072104862Sru\begingroup 5073104862Sru \catcode`\^^I=\active 5074104862Sru \gdef\tabexpand{% 5075104862Sru \catcode`\^^I=\active 5076104862Sru \def^^I{\leavevmode\egroup 5077104862Sru \dimen0=\wd0 % the width so far, or since the previous tab 5078104862Sru \divide\dimen0 by\tabw 5079104862Sru \multiply\dimen0 by\tabw % compute previous multiple of \tabw 5080104862Sru \advance\dimen0 by\tabw % advance to next multiple of \tabw 5081104862Sru \wd0=\dimen0 \box0 \starttabbox 5082104862Sru }% 5083104862Sru } 5084104862Sru\endgroup 5085104862Sru\def\setupverbatim{% 5086151497Sru \nonfillstart 5087151497Sru \advance\leftskip by -\defbodyindent 5088104862Sru % Easiest (and conventionally used) font for verbatim 5089104862Sru \tt 5090104862Sru \def\par{\leavevmode\egroup\box0\endgraf}% 5091104862Sru \catcode`\`=\active 5092104862Sru \tabexpand 5093104862Sru % Respect line breaks, 5094104862Sru % print special symbols as themselves, and 5095104862Sru % make each space count 5096104862Sru % must do in this order: 5097104862Sru \obeylines \uncatcodespecials \sepspaces 5098104862Sru \everypar{\starttabbox}% 5099104862Sru} 5100104862Sru 5101151497Sru% Do the @verb magic: verbatim text is quoted by unique 5102151497Sru% delimiter characters. Before first delimiter expect a 5103104862Sru% right brace, after last delimiter expect closing brace: 5104104862Sru% 5105104862Sru% \def\doverb'{'<char>#1<char>'}'{#1} 5106104862Sru% 5107104862Sru% [Knuth] p. 382; only eat outer {} 5108104862Sru\begingroup 5109151497Sru \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other 5110104862Sru \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next] 5111104862Sru\endgroup 5112104862Sru% 5113104862Sru\def\verb{\begingroup\setupverb\doverb} 5114104862Sru% 5115104862Sru% 5116104862Sru% Do the @verbatim magic: define the macro \doverbatim so that 5117104862Sru% the (first) argument ends when '@end verbatim' is reached, ie: 5118104862Sru% 5119104862Sru% \def\doverbatim#1@end verbatim{#1} 5120104862Sru% 5121151497Sru% For Texinfo it's a lot easier than for LaTeX, 5122104862Sru% because texinfo's \verbatim doesn't stop at '\end{verbatim}': 5123114402Sru% we need not redefine '\', '{' and '}'. 5124104862Sru% 5125104862Sru% Inspired by LaTeX's verbatim command set [latex.ltx] 5126114402Sru% 5127104862Sru\begingroup 5128104862Sru \catcode`\ =\active 5129114402Sru \obeylines % 5130114402Sru % ignore everything up to the first ^^M, that's the newline at the end 5131114402Sru % of the @verbatim input line itself. Otherwise we get an extra blank 5132114402Sru % line in the output. 5133151497Sru \xdef\doverbatim#1^^M#2@end verbatim{#2\noexpand\end\gobble verbatim}% 5134151497Sru % We really want {...\end verbatim} in the body of the macro, but 5135151497Sru % without the active space; thus we have to use \xdef and \gobble. 5136104862Sru\endgroup 5137104862Sru% 5138151497Sru\envdef\verbatim{% 5139151497Sru \setupverbatim\doverbatim 5140104862Sru} 5141151497Sru\let\Everbatim = \afterenvbreak 5142104862Sru 5143151497Sru 5144104862Sru% @verbatiminclude FILE - insert text of file in verbatim environment. 5145104862Sru% 5146151497Sru\def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude} 5147104862Sru% 5148104862Sru\def\doverbatiminclude#1{% 5149151497Sru {% 5150151497Sru \makevalueexpandable 5151151497Sru \setupverbatim 5152151497Sru \input #1 5153151497Sru \afterenvbreak 5154151497Sru }% 5155104862Sru} 5156104862Sru 5157104862Sru% @copying ... @end copying. 5158151497Sru% Save the text away for @insertcopying later. 5159151497Sru% 5160114402Sru% We save the uninterpreted tokens, rather than creating a box. 5161114402Sru% Saving the text in a box would be much easier, but then all the 5162114402Sru% typesetting commands (@smallbook, font changes, etc.) have to be done 5163114402Sru% beforehand -- and a) we want @copying to be done first in the source 5164114402Sru% file; b) letting users define the frontmatter in as flexible order as 5165114402Sru% possible is very desirable. 5166114402Sru% 5167151497Sru\def\copying{\checkenv{}\begingroup\scanargctxt\docopying} 5168151497Sru\def\docopying#1@end copying{\endgroup\def\copyingtext{#1}} 5169114402Sru% 5170151497Sru\def\insertcopying{% 5171151497Sru \begingroup 5172151497Sru \parindent = 0pt % paragraph indentation looks wrong on title page 5173151497Sru \scanexp\copyingtext 5174151497Sru \endgroup 5175114402Sru} 5176104862Sru 517769626Sru\message{defuns,} 517869626Sru% @defun etc. 517969626Sru 518069626Sru\newskip\defbodyindent \defbodyindent=.4in 518169626Sru\newskip\defargsindent \defargsindent=50pt 518269626Sru\newskip\deflastargmargin \deflastargmargin=18pt 518369626Sru 5184151497Sru% Start the processing of @deffn: 5185151497Sru\def\startdefun{% 5186151497Sru \ifnum\lastpenalty<10000 5187151497Sru \medbreak 5188114402Sru \else 5189151497Sru % If there are two @def commands in a row, we'll have a \nobreak, 5190151497Sru % which is there to keep the function description together with its 5191151497Sru % header. But if there's nothing but headers, we need to allow a 5192151497Sru % break somewhere. Check specifically for penalty 10002, inserted 5193151497Sru % by \defargscommonending, instead of 10000, since the sectioning 5194151497Sru % commands also insert a nobreak penalty, and we don't want to allow 5195151497Sru % a break between a section heading and a defun. 5196151497Sru % 5197151497Sru \ifnum\lastpenalty=10002 \penalty2000 \fi 5198151497Sru % 5199151497Sru % Similarly, after a section heading, do not allow a break. 5200151497Sru % But do insert the glue. 5201151497Sru \medskip % preceded by discardable penalty, so not a breakpoint 5202114402Sru \fi 5203114402Sru % 5204114402Sru \parindent=0in 5205114402Sru \advance\leftskip by \defbodyindent 5206114402Sru \exdentamount=\defbodyindent 520769626Sru} 520869626Sru 5209151497Sru\def\dodefunx#1{% 5210151497Sru % First, check whether we are in the right environment: 5211151497Sru \checkenv#1% 5212114402Sru % 5213151497Sru % As above, allow line break if we have multiple x headers in a row. 5214151497Sru % It's not a great place, though. 5215151497Sru \ifnum\lastpenalty=10002 \penalty3000 \fi 5216151497Sru % 5217151497Sru % And now, it's time to reuse the body of the original defun: 5218151497Sru \expandafter\gobbledefun#1% 5219114402Sru} 5220151497Sru\def\gobbledefun#1\startdefun{} 522169626Sru 5222151497Sru% \printdefunline \deffnheader{text} 5223114402Sru% 5224151497Sru\def\printdefunline#1#2{% 5225151497Sru \begingroup 5226151497Sru % call \deffnheader: 5227151497Sru #1#2 \endheader 5228151497Sru % common ending: 5229151497Sru \interlinepenalty = 10000 5230151497Sru \advance\rightskip by 0pt plus 1fil 5231151497Sru \endgraf 5232151497Sru \nobreak\vskip -\parskip 5233151497Sru \penalty 10002 % signal to \startdefun and \dodefunx 5234151497Sru % Some of the @defun-type tags do not enable magic parentheses, 5235151497Sru % rendering the following check redundant. But we don't optimize. 5236151497Sru \checkparencounts 5237151497Sru \endgroup 5238114402Sru} 523969626Sru 5240151497Sru\def\Edefun{\endgraf\medbreak} 524169626Sru 5242151497Sru% \makedefun{deffn} creates \deffn, \deffnx and \Edeffn; 5243151497Sru% the only thing remainnig is to define \deffnheader. 524469626Sru% 5245151497Sru\def\makedefun#1{% 5246151497Sru \expandafter\let\csname E#1\endcsname = \Edefun 5247151497Sru \edef\temp{\noexpand\domakedefun 5248151497Sru \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}% 5249151497Sru \temp 5250114402Sru} 525169626Sru 5252151497Sru% \domakedefun \deffn \deffnx \deffnheader 525369626Sru% 5254151497Sru% Define \deffn and \deffnx, without parameters. 5255151497Sru% \deffnheader has to be defined explicitly. 525669626Sru% 5257151497Sru\def\domakedefun#1#2#3{% 5258151497Sru \envdef#1{% 5259151497Sru \startdefun 5260151497Sru \parseargusing\activeparens{\printdefunline#3}% 5261151497Sru }% 5262151497Sru \def#2{\dodefunx#1}% 5263151497Sru \def#3% 526469626Sru} 526569626Sru 5266151497Sru%%% Untyped functions: 526769626Sru 5268151497Sru% @deffn category name args 5269151497Sru\makedefun{deffn}{\deffngeneral{}} 527069626Sru 5271151497Sru% @deffn category class name args 5272151497Sru\makedefun{defop}#1 {\defopon{#1\ \putwordon}} 527369626Sru 5274151497Sru% \defopon {category on}class name args 5275151497Sru\def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} } 527669626Sru 5277151497Sru% \deffngeneral {subind}category name args 5278114402Sru% 5279151497Sru\def\deffngeneral#1#2 #3 #4\endheader{% 5280151497Sru % Remember that \dosubind{fn}{foo}{} is equivalent to \doind{fn}{foo}. 5281151497Sru \dosubind{fn}{\code{#3}}{#1}% 5282151497Sru \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}% 5283114402Sru} 528469626Sru 5285151497Sru%%% Typed functions: 528669626Sru 5287151497Sru% @deftypefn category type name args 5288151497Sru\makedefun{deftypefn}{\deftypefngeneral{}} 528969626Sru 5290151497Sru% @deftypeop category class type name args 5291151497Sru\makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}} 529269626Sru 5293151497Sru% \deftypeopon {category on}class type name args 5294151497Sru\def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} } 529569626Sru 5296151497Sru% \deftypefngeneral {subind}category type name args 5297151497Sru% 5298151497Sru\def\deftypefngeneral#1#2 #3 #4 #5\endheader{% 5299151497Sru \dosubind{fn}{\code{#4}}{#1}% 5300151497Sru \defname{#2}{#3}{#4}\defunargs{#5\unskip}% 530169626Sru} 530269626Sru 5303151497Sru%%% Typed variables: 530469626Sru 5305151497Sru% @deftypevr category type var args 5306151497Sru\makedefun{deftypevr}{\deftypecvgeneral{}} 530769626Sru 5308151497Sru% @deftypecv category class type var args 5309151497Sru\makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}} 531069626Sru 5311151497Sru% \deftypecvof {category of}class type var args 5312151497Sru\def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} } 531369626Sru 5314151497Sru% \deftypecvgeneral {subind}category type var args 5315151497Sru% 5316151497Sru\def\deftypecvgeneral#1#2 #3 #4 #5\endheader{% 5317151497Sru \dosubind{vr}{\code{#4}}{#1}% 5318151497Sru \defname{#2}{#3}{#4}\defunargs{#5\unskip}% 531969626Sru} 532069626Sru 5321151497Sru%%% Untyped variables: 532269626Sru 5323151497Sru% @defvr category var args 5324151497Sru\makedefun{defvr}#1 {\deftypevrheader{#1} {} } 532569626Sru 5326151497Sru% @defcv category class var args 5327151497Sru\makedefun{defcv}#1 {\defcvof{#1\ \putwordof}} 532869626Sru 5329151497Sru% \defcvof {category of}class var args 5330151497Sru\def\defcvof#1#2 {\deftypecvof{#1}#2 {} } 533169626Sru 5332151497Sru%%% Type: 5333151497Sru% @deftp category name args 5334151497Sru\makedefun{deftp}#1 #2 #3\endheader{% 5335151497Sru \doind{tp}{\code{#2}}% 5336151497Sru \defname{#1}{}{#2}\defunargs{#3\unskip}% 533769626Sru} 533869626Sru 5339151497Sru% Remaining @defun-like shortcuts: 5340151497Sru\makedefun{defun}{\deffnheader{\putwordDeffunc} } 5341151497Sru\makedefun{defmac}{\deffnheader{\putwordDefmac} } 5342151497Sru\makedefun{defspec}{\deffnheader{\putwordDefspec} } 5343151497Sru\makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} } 5344151497Sru\makedefun{defvar}{\defvrheader{\putwordDefvar} } 5345151497Sru\makedefun{defopt}{\defvrheader{\putwordDefopt} } 5346151497Sru\makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} } 5347151497Sru\makedefun{defmethod}{\defopon\putwordMethodon} 5348151497Sru\makedefun{deftypemethod}{\deftypeopon\putwordMethodon} 5349151497Sru\makedefun{defivar}{\defcvof\putwordInstanceVariableof} 5350151497Sru\makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof} 535169626Sru 5352151497Sru% \defname, which formats the name of the @def (not the args). 5353151497Sru% #1 is the category, such as "Function". 5354151497Sru% #2 is the return type, if any. 5355151497Sru% #3 is the function name. 535669626Sru% 5357151497Sru% We are followed by (but not passed) the arguments, if any. 535869626Sru% 5359151497Sru\def\defname#1#2#3{% 5360151497Sru % Get the values of \leftskip and \rightskip as they were outside the @def... 5361151497Sru \advance\leftskip by -\defbodyindent 5362151497Sru % 5363151497Sru % How we'll format the type name. Putting it in brackets helps 5364151497Sru % distinguish it from the body text that may end up on the next line 5365151497Sru % just below it. 5366151497Sru \def\temp{#1}% 5367151497Sru \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi} 5368151497Sru % 5369151497Sru % Figure out line sizes for the paragraph shape. 5370151497Sru % The first line needs space for \box0; but if \rightskip is nonzero, 5371151497Sru % we need only space for the part of \box0 which exceeds it: 5372151497Sru \dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip 5373151497Sru % The continuations: 5374151497Sru \dimen2=\hsize \advance\dimen2 by -\defargsindent 5375151497Sru % (plain.tex says that \dimen1 should be used only as global.) 5376151497Sru \parshape 2 0in \dimen0 \defargsindent \dimen2 5377151497Sru % 5378151497Sru % Put the type name to the right margin. 5379151497Sru \noindent 5380151497Sru \hbox to 0pt{% 5381151497Sru \hfil\box0 \kern-\hsize 5382151497Sru % \hsize has to be shortened this way: 5383151497Sru \kern\leftskip 5384151497Sru % Intentionally do not respect \rightskip, since we need the space. 5385151497Sru }% 5386151497Sru % 5387151497Sru % Allow all lines to be underfull without complaint: 5388151497Sru \tolerance=10000 \hbadness=10000 5389151497Sru \exdentamount=\defbodyindent 5390151497Sru {% 5391151497Sru % defun fonts. We use typewriter by default (used to be bold) because: 5392151497Sru % . we're printing identifiers, they should be in tt in principle. 5393151497Sru % . in languages with many accents, such as Czech or French, it's 5394151497Sru % common to leave accents off identifiers. The result looks ok in 5395151497Sru % tt, but exceedingly strange in rm. 5396151497Sru % . we don't want -- and --- to be treated as ligatures. 5397151497Sru % . this still does not fix the ?` and !` ligatures, but so far no 5398151497Sru % one has made identifiers using them :). 5399151497Sru \df \tt 5400151497Sru \def\temp{#2}% return value type 5401151497Sru \ifx\temp\empty\else \tclose{\temp} \fi 5402151497Sru #3% output function name 5403151497Sru }% 5404151497Sru {\rm\enskip}% hskip 0.5 em of \tenrm 5405151497Sru % 5406151497Sru \boldbrax 5407151497Sru % arguments will be output next, if any. 540869626Sru} 540969626Sru 5410151497Sru% Print arguments in slanted roman (not ttsl), inconsistently with using 5411151497Sru% tt for the name. This is because literal text is sometimes needed in 5412151497Sru% the argument list (groff manual), and ttsl and tt are not very 5413151497Sru% distinguishable. Prevent hyphenation at `-' chars. 541469626Sru% 5415151497Sru\def\defunargs#1{% 5416151497Sru % use sl by default (not ttsl), 5417151497Sru % tt for the names. 5418151497Sru \df \sl \hyphenchar\font=0 5419151497Sru % 5420151497Sru % On the other hand, if an argument has two dashes (for instance), we 5421151497Sru % want a way to get ttsl. Let's try @var for that. 5422151497Sru \let\var=\ttslanted 5423151497Sru #1% 5424151497Sru \sl\hyphenchar\font=45 542569626Sru} 542669626Sru 5427151497Sru% We want ()&[] to print specially on the defun line. 542869626Sru% 5429151497Sru\def\activeparens{% 5430151497Sru \catcode`\(=\active \catcode`\)=\active 5431151497Sru \catcode`\[=\active \catcode`\]=\active 5432151497Sru \catcode`\&=\active 543369626Sru} 543469626Sru 5435151497Sru% Make control sequences which act like normal parenthesis chars. 5436151497Sru\let\lparen = ( \let\rparen = ) 543769626Sru 5438151497Sru% Be sure that we always have a definition for `(', etc. For example, 5439151497Sru% if the fn name has parens in it, \boldbrax will not be in effect yet, 5440151497Sru% so TeX would otherwise complain about undefined control sequence. 5441151497Sru{ 5442151497Sru \activeparens 5443151497Sru \global\let(=\lparen \global\let)=\rparen 5444151497Sru \global\let[=\lbrack \global\let]=\rbrack 5445151497Sru \global\let& = \& 5446151497Sru 5447151497Sru \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb} 5448151497Sru \gdef\magicamp{\let&=\amprm} 544969626Sru} 545069626Sru 5451151497Sru\newcount\parencount 545269626Sru 5453151497Sru% If we encounter &foo, then turn on ()-hacking afterwards 5454151497Sru\newif\ifampseen 5455151497Sru\def\amprm#1 {\ampseentrue{\bf\ }} 545669626Sru 5457151497Sru\def\parenfont{% 5458151497Sru \ifampseen 5459151497Sru % At the first level, print parens in roman, 5460151497Sru % otherwise use the default font. 5461151497Sru \ifnum \parencount=1 \rm \fi 5462151497Sru \else 5463151497Sru % The \sf parens (in \boldbrax) actually are a little bolder than 5464151497Sru % the contained text. This is especially needed for [ and ] . 5465151497Sru \sf 5466151497Sru \fi 546769626Sru} 5468151497Sru\def\infirstlevel#1{% 5469151497Sru \ifampseen 5470151497Sru \ifnum\parencount=1 5471151497Sru #1% 5472151497Sru \fi 5473151497Sru \fi 547469626Sru} 5475151497Sru\def\bfafterword#1 {#1 \bf} 547669626Sru 5477151497Sru\def\opnr{% 5478151497Sru \global\advance\parencount by 1 5479151497Sru {\parenfont(}% 5480151497Sru \infirstlevel \bfafterword 5481114402Sru} 5482151497Sru\def\clnr{% 5483151497Sru {\parenfont)}% 5484151497Sru \infirstlevel \sl 5485151497Sru \global\advance\parencount by -1 5486151497Sru} 548769626Sru 5488151497Sru\newcount\brackcount 5489151497Sru\def\lbrb{% 5490151497Sru \global\advance\brackcount by 1 5491151497Sru {\bf[}% 549269626Sru} 5493151497Sru\def\rbrb{% 5494151497Sru {\bf]}% 5495151497Sru \global\advance\brackcount by -1 5496151497Sru} 549769626Sru 5498151497Sru\def\checkparencounts{% 5499151497Sru \ifnum\parencount=0 \else \badparencount \fi 5500151497Sru \ifnum\brackcount=0 \else \badbrackcount \fi 550169626Sru} 5502151497Sru\def\badparencount{% 5503151497Sru \errmessage{Unbalanced parentheses in @def}% 5504151497Sru \global\parencount=0 5505151497Sru} 5506151497Sru\def\badbrackcount{% 5507151497Sru \errmessage{Unbalanced square braces in @def}% 5508151497Sru \global\brackcount=0 5509151497Sru} 551069626Sru 551169626Sru 551269626Sru\message{macros,} 551369626Sru% @macro. 551469626Sru 551569626Sru% To do this right we need a feature of e-TeX, \scantokens, 551669626Sru% which we arrange to emulate with a temporary file in ordinary TeX. 551769626Sru\ifx\eTeXversion\undefined 5518151497Sru \newwrite\macscribble 5519151497Sru \def\scantokens#1{% 5520151497Sru \toks0={#1}% 5521151497Sru \immediate\openout\macscribble=\jobname.tmp 5522151497Sru \immediate\write\macscribble{\the\toks0}% 5523151497Sru \immediate\closeout\macscribble 5524151497Sru \input \jobname.tmp 5525151497Sru } 552669626Sru\fi 552769626Sru 5528151497Sru\def\scanmacro#1{% 5529151497Sru \begingroup 5530151497Sru \newlinechar`\^^M 5531151497Sru \let\xeatspaces\eatspaces 5532151497Sru % Undo catcode changes of \startcontents and \doprintindex 5533151497Sru % When called from @insertcopying or (short)caption, we need active 5534151497Sru % backslash to get it printed correctly. Previously, we had 5535151497Sru % \catcode`\\=\other instead. We'll see whether a problem appears 5536151497Sru % with macro expansion. --kasal, 19aug04 5537151497Sru \catcode`\@=0 \catcode`\\=\active \escapechar=`\@ 5538151497Sru % ... and \example 5539151497Sru \spaceisspace 5540151497Sru % 5541151497Sru % Append \endinput to make sure that TeX does not see the ending newline. 5542151497Sru % 5543151497Sru % I've verified that it is necessary both for e-TeX and for ordinary TeX 5544151497Sru % --kasal, 29nov03 5545151497Sru \scantokens{#1\endinput}% 5546151497Sru \endgroup 5547151497Sru} 5548151497Sru 5549151497Sru\def\scanexp#1{% 5550151497Sru \edef\temp{\noexpand\scanmacro{#1}}% 5551151497Sru \temp 5552151497Sru} 5553151497Sru 555469626Sru\newcount\paramno % Count of parameters 555569626Sru\newtoks\macname % Macro name 555669626Sru\newif\ifrecursive % Is it recursive? 555769626Sru\def\macrolist{} % List of all defined macros in the form 555869626Sru % \do\macro1\do\macro2... 555969626Sru 556069626Sru% Utility routines. 5561151497Sru% This does \let #1 = #2, with \csnames; that is, 5562151497Sru% \let \csname#1\endcsname = \csname#2\endcsname 5563151497Sru% (except of course we have to play expansion games). 5564151497Sru% 556569626Sru\def\cslet#1#2{% 5566151497Sru \expandafter\let 5567151497Sru \csname#1\expandafter\endcsname 5568151497Sru \csname#2\endcsname 5569151497Sru} 557069626Sru 557169626Sru% Trim leading and trailing spaces off a string. 557269626Sru% Concepts from aro-bend problem 15 (see CTAN). 557369626Sru{\catcode`\@=11 557469626Sru\gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }} 557569626Sru\gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@} 557669626Sru\gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @} 557769626Sru\def\unbrace#1{#1} 557869626Sru\unbrace{\gdef\trim@@@ #1 } #2@{#1} 557969626Sru} 558069626Sru 558169626Sru% Trim a single trailing ^^M off a string. 5582114402Sru{\catcode`\^^M=\other \catcode`\Q=3% 558369626Sru\gdef\eatcr #1{\eatcra #1Q^^MQ}% 558469626Sru\gdef\eatcra#1^^MQ{\eatcrb#1Q}% 558569626Sru\gdef\eatcrb#1Q#2Q{#1}% 558669626Sru} 558769626Sru 558869626Sru% Macro bodies are absorbed as an argument in a context where 558969626Sru% all characters are catcode 10, 11 or 12, except \ which is active 559069626Sru% (as in normal texinfo). It is necessary to change the definition of \. 559169626Sru 559269626Sru% It's necessary to have hard CRs when the macro is executed. This is 559369626Sru% done by making ^^M (\endlinechar) catcode 12 when reading the macro 559469626Sru% body, and then making it the \newlinechar in \scanmacro. 559569626Sru 5596151497Sru\def\scanctxt{% 5597151497Sru \catcode`\"=\other 5598151497Sru \catcode`\+=\other 5599151497Sru \catcode`\<=\other 5600151497Sru \catcode`\>=\other 5601151497Sru \catcode`\@=\other 5602114402Sru \catcode`\^=\other 5603114402Sru \catcode`\_=\other 5604114402Sru \catcode`\|=\other 5605151497Sru \catcode`\~=\other 5606151497Sru} 5607151497Sru 5608151497Sru\def\scanargctxt{% 5609151497Sru \scanctxt 5610151497Sru \catcode`\\=\other 5611151497Sru \catcode`\^^M=\other 5612151497Sru} 5613151497Sru 5614151497Sru\def\macrobodyctxt{% 5615151497Sru \scanctxt 5616114402Sru \catcode`\{=\other 5617114402Sru \catcode`\}=\other 5618114402Sru \catcode`\^^M=\other 5619151497Sru \usembodybackslash 5620151497Sru} 562169626Sru 562269626Sru\def\macroargctxt{% 5623151497Sru \scanctxt 5624151497Sru \catcode`\\=\other 5625151497Sru} 562669626Sru 562769626Sru% \mbodybackslash is the definition of \ in @macro bodies. 562869626Sru% It maps \foo\ => \csname macarg.foo\endcsname => #N 562969626Sru% where N is the macro parameter number. 563069626Sru% We define \csname macarg.\endcsname to be \realbackslash, so 563169626Sru% \\ in macro replacement text gets you a backslash. 563269626Sru 563369626Sru{\catcode`@=0 @catcode`@\=@active 563469626Sru @gdef@usembodybackslash{@let\=@mbodybackslash} 563569626Sru @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname} 563669626Sru} 563769626Sru\expandafter\def\csname macarg.\endcsname{\realbackslash} 563869626Sru 563969626Sru\def\macro{\recursivefalse\parsearg\macroxxx} 564069626Sru\def\rmacro{\recursivetrue\parsearg\macroxxx} 564169626Sru 564269626Sru\def\macroxxx#1{% 564369626Sru \getargs{#1}% now \macname is the macname and \argl the arglist 564469626Sru \ifx\argl\empty % no arguments 564569626Sru \paramno=0% 564669626Sru \else 564769626Sru \expandafter\parsemargdef \argl;% 564869626Sru \fi 564969626Sru \if1\csname ismacro.\the\macname\endcsname 565069626Sru \message{Warning: redefining \the\macname}% 565169626Sru \else 565269626Sru \expandafter\ifx\csname \the\macname\endcsname \relax 5653104862Sru \else \errmessage{Macro name \the\macname\space already defined}\fi 565469626Sru \global\cslet{macsave.\the\macname}{\the\macname}% 565569626Sru \global\expandafter\let\csname ismacro.\the\macname\endcsname=1% 565669626Sru % Add the macroname to \macrolist 565769626Sru \toks0 = \expandafter{\macrolist\do}% 565869626Sru \xdef\macrolist{\the\toks0 565969626Sru \expandafter\noexpand\csname\the\macname\endcsname}% 566069626Sru \fi 566169626Sru \begingroup \macrobodyctxt 566269626Sru \ifrecursive \expandafter\parsermacbody 566369626Sru \else \expandafter\parsemacbody 566469626Sru \fi} 566569626Sru 5666151497Sru\parseargdef\unmacro{% 566769626Sru \if1\csname ismacro.#1\endcsname 566869626Sru \global\cslet{#1}{macsave.#1}% 566969626Sru \global\expandafter\let \csname ismacro.#1\endcsname=0% 5670114402Sru % Remove the macro name from \macrolist: 567169626Sru \begingroup 5672114402Sru \expandafter\let\csname#1\endcsname \relax 5673114402Sru \let\do\unmacrodo 5674114402Sru \xdef\macrolist{\macrolist}% 567569626Sru \endgroup 567669626Sru \else 567769626Sru \errmessage{Macro #1 not defined}% 567869626Sru \fi 567969626Sru} 568069626Sru 5681114402Sru% Called by \do from \dounmacro on each macro. The idea is to omit any 5682114402Sru% macro definitions that have been changed to \relax. 5683151497Sru% 5684114402Sru\def\unmacrodo#1{% 5685114402Sru \ifx#1\relax 5686114402Sru % remove this 5687114402Sru \else 5688114402Sru \noexpand\do \noexpand #1% 5689114402Sru \fi 5690114402Sru} 5691114402Sru 569269626Sru% This makes use of the obscure feature that if the last token of a 569369626Sru% <parameter list> is #, then the preceding argument is delimited by 569469626Sru% an opening brace, and that opening brace is not consumed. 569569626Sru\def\getargs#1{\getargsxxx#1{}} 569669626Sru\def\getargsxxx#1#{\getmacname #1 \relax\getmacargs} 569769626Sru\def\getmacname #1 #2\relax{\macname={#1}} 569869626Sru\def\getmacargs#1{\def\argl{#1}} 569969626Sru 570069626Sru% Parse the optional {params} list. Set up \paramno and \paramlist 570169626Sru% so \defmacro knows what to do. Define \macarg.blah for each blah 570269626Sru% in the params list, to be ##N where N is the position in that list. 570369626Sru% That gets used by \mbodybackslash (above). 570469626Sru 570569626Sru% We need to get `macro parameter char #' into several definitions. 570669626Sru% The technique used is stolen from LaTeX: let \hash be something 570769626Sru% unexpandable, insert that wherever you need a #, and then redefine 570869626Sru% it to # just before using the token list produced. 570969626Sru% 571069626Sru% The same technique is used to protect \eatspaces till just before 571169626Sru% the macro is used. 571269626Sru 571369626Sru\def\parsemargdef#1;{\paramno=0\def\paramlist{}% 571469626Sru \let\hash\relax\let\xeatspaces\relax\parsemargdefxxx#1,;,} 571569626Sru\def\parsemargdefxxx#1,{% 571669626Sru \if#1;\let\next=\relax 571769626Sru \else \let\next=\parsemargdefxxx 571869626Sru \advance\paramno by 1% 571969626Sru \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname 572069626Sru {\xeatspaces{\hash\the\paramno}}% 572169626Sru \edef\paramlist{\paramlist\hash\the\paramno,}% 572269626Sru \fi\next} 572369626Sru 572469626Sru% These two commands read recursive and nonrecursive macro bodies. 572569626Sru% (They're different since rec and nonrec macros end differently.) 572669626Sru 572769626Sru\long\def\parsemacbody#1@end macro% 572869626Sru{\xdef\temp{\eatcr{#1}}\endgroup\defmacro}% 572969626Sru\long\def\parsermacbody#1@end rmacro% 573069626Sru{\xdef\temp{\eatcr{#1}}\endgroup\defmacro}% 573169626Sru 573269626Sru% This defines the macro itself. There are six cases: recursive and 573369626Sru% nonrecursive macros of zero, one, and many arguments. 573469626Sru% Much magic with \expandafter here. 573569626Sru% \xdef is used so that macro definitions will survive the file 573669626Sru% they're defined in; @include reads the file inside a group. 573769626Sru\def\defmacro{% 573869626Sru \let\hash=##% convert placeholders to macro parameter chars 573969626Sru \ifrecursive 574069626Sru \ifcase\paramno 574169626Sru % 0 574269626Sru \expandafter\xdef\csname\the\macname\endcsname{% 574369626Sru \noexpand\scanmacro{\temp}}% 574469626Sru \or % 1 574569626Sru \expandafter\xdef\csname\the\macname\endcsname{% 574669626Sru \bgroup\noexpand\macroargctxt 574769626Sru \noexpand\braceorline 574869626Sru \expandafter\noexpand\csname\the\macname xxx\endcsname}% 574969626Sru \expandafter\xdef\csname\the\macname xxx\endcsname##1{% 575069626Sru \egroup\noexpand\scanmacro{\temp}}% 575169626Sru \else % many 575269626Sru \expandafter\xdef\csname\the\macname\endcsname{% 575369626Sru \bgroup\noexpand\macroargctxt 575469626Sru \noexpand\csname\the\macname xx\endcsname}% 575569626Sru \expandafter\xdef\csname\the\macname xx\endcsname##1{% 575669626Sru \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}% 575769626Sru \expandafter\expandafter 575869626Sru \expandafter\xdef 575969626Sru \expandafter\expandafter 576069626Sru \csname\the\macname xxx\endcsname 576169626Sru \paramlist{\egroup\noexpand\scanmacro{\temp}}% 576269626Sru \fi 576369626Sru \else 576469626Sru \ifcase\paramno 576569626Sru % 0 576669626Sru \expandafter\xdef\csname\the\macname\endcsname{% 576769626Sru \noexpand\norecurse{\the\macname}% 576869626Sru \noexpand\scanmacro{\temp}\egroup}% 576969626Sru \or % 1 577069626Sru \expandafter\xdef\csname\the\macname\endcsname{% 577169626Sru \bgroup\noexpand\macroargctxt 577269626Sru \noexpand\braceorline 577369626Sru \expandafter\noexpand\csname\the\macname xxx\endcsname}% 577469626Sru \expandafter\xdef\csname\the\macname xxx\endcsname##1{% 577569626Sru \egroup 577669626Sru \noexpand\norecurse{\the\macname}% 577769626Sru \noexpand\scanmacro{\temp}\egroup}% 577869626Sru \else % many 577969626Sru \expandafter\xdef\csname\the\macname\endcsname{% 578069626Sru \bgroup\noexpand\macroargctxt 578169626Sru \expandafter\noexpand\csname\the\macname xx\endcsname}% 578269626Sru \expandafter\xdef\csname\the\macname xx\endcsname##1{% 578369626Sru \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}% 578469626Sru \expandafter\expandafter 578569626Sru \expandafter\xdef 578669626Sru \expandafter\expandafter 578769626Sru \csname\the\macname xxx\endcsname 578869626Sru \paramlist{% 578969626Sru \egroup 579069626Sru \noexpand\norecurse{\the\macname}% 579169626Sru \noexpand\scanmacro{\temp}\egroup}% 579269626Sru \fi 579369626Sru \fi} 579469626Sru 579569626Sru\def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}} 579669626Sru 579769626Sru% \braceorline decides whether the next nonwhitespace character is a 579869626Sru% {. If so it reads up to the closing }, if not, it reads the whole 579969626Sru% line. Whatever was read is then fed to the next control sequence 580069626Sru% as an argument (by \parsebrace or \parsearg) 580169626Sru\def\braceorline#1{\let\next=#1\futurelet\nchar\braceorlinexxx} 580269626Sru\def\braceorlinexxx{% 580369626Sru \ifx\nchar\bgroup\else 580469626Sru \expandafter\parsearg 580569626Sru \fi \next} 580669626Sru 5807151497Sru% We want to disable all macros during \shipout so that they are not 580869626Sru% expanded by \write. 580969626Sru\def\turnoffmacros{\begingroup \def\do##1{\let\noexpand##1=\relax}% 581069626Sru \edef\next{\macrolist}\expandafter\endgroup\next} 581169626Sru 5812151497Sru% For \indexnofonts, we need to get rid of all macros, leaving only the 5813151497Sru% arguments (if present). Of course this is not nearly correct, but it 5814151497Sru% is the best we can do for now. makeinfo does not expand macros in the 5815151497Sru% argument to @deffn, which ends up writing an index entry, and texindex 5816151497Sru% isn't prepared for an index sort entry that starts with \. 5817151497Sru% 5818151497Sru% Since macro invocations are followed by braces, we can just redefine them 5819151497Sru% to take a single TeX argument. The case of a macro invocation that 5820151497Sru% goes to end-of-line is not handled. 5821151497Sru% 5822151497Sru\def\emptyusermacros{\begingroup 5823151497Sru \def\do##1{\let\noexpand##1=\noexpand\asis}% 5824151497Sru \edef\next{\macrolist}\expandafter\endgroup\next} 582569626Sru 5826151497Sru 582769626Sru% @alias. 582869626Sru% We need some trickery to remove the optional spaces around the equal 582969626Sru% sign. Just make them active and then expand them all to nothing. 5830151497Sru\def\alias{\parseargusing\obeyspaces\aliasxxx} 583169626Sru\def\aliasxxx #1{\aliasyyy#1\relax} 5832151497Sru\def\aliasyyy #1=#2\relax{% 5833151497Sru {% 5834151497Sru \expandafter\let\obeyedspace=\empty 5835151497Sru \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}% 5836151497Sru }% 5837151497Sru \next 5838151497Sru} 583969626Sru 584069626Sru 584169626Sru\message{cross references,} 584269626Sru 584369626Sru\newwrite\auxfile 584469626Sru 584569626Sru\newif\ifhavexrefs % True if xref values are known. 584669626Sru\newif\ifwarnedxrefs % True if we warned once that they aren't known. 584769626Sru 584869626Sru% @inforef is relatively simple. 584969626Sru\def\inforef #1{\inforefzzz #1,,,,**} 585069626Sru\def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}}, 585169626Sru node \samp{\ignorespaces#1{}}} 585269626Sru 5853151497Sru% @node's only job in TeX is to define \lastnode, which is used in 5854151497Sru% cross-references. The @node line might or might not have commas, and 5855151497Sru% might or might not have spaces before the first comma, like: 5856151497Sru% @node foo , bar , ... 5857151497Sru% We don't want such trailing spaces in the node name. 5858151497Sru% 5859151497Sru\parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse} 5860151497Sru% 5861151497Sru% also remove a trailing comma, in case of something like this: 5862151497Sru% @node Help-Cross, , , Cross-refs 5863151497Sru\def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse} 5864151497Sru\def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}} 5865151497Sru 586669626Sru\let\nwnode=\node 5867151497Sru\let\lastnode=\empty 586869626Sru 5869151497Sru% Write a cross-reference definition for the current node. #1 is the 5870151497Sru% type (Ynumbered, Yappendix, Ynothing). 5871151497Sru% 5872151497Sru\def\donoderef#1{% 5873151497Sru \ifx\lastnode\empty\else 5874151497Sru \setref{\lastnode}{#1}% 5875151497Sru \global\let\lastnode=\empty 587669626Sru \fi 587769626Sru} 587869626Sru 587969626Sru% @anchor{NAME} -- define xref target at arbitrary point. 588069626Sru% 588169626Sru\newcount\savesfregister 5882151497Sru% 5883151497Sru\def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi} 5884151497Sru\def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi} 5885151497Sru\def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces} 588669626Sru 5887114402Sru% \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an 5888151497Sru% anchor), which consists of three parts: 5889151497Sru% 1) NAME-title - the current sectioning name taken from \thissection, 5890151497Sru% or the anchor name. 5891151497Sru% 2) NAME-snt - section number and type, passed as the SNT arg, or 5892151497Sru% empty for anchors. 5893151497Sru% 3) NAME-pg - the page number. 589469626Sru% 5895151497Sru% This is called from \donoderef, \anchor, and \dofloat. In the case of 5896151497Sru% floats, there is an additional part, which is not written here: 5897151497Sru% 4) NAME-lof - the text as it should appear in a @listoffloats. 5898151497Sru% 5899151497Sru\def\setref#1#2{% 590069626Sru \pdfmkdest{#1}% 5901151497Sru \iflinks 5902151497Sru {% 5903151497Sru \atdummies % preserve commands, but don't expand them 5904151497Sru \turnoffactive 5905151497Sru \otherbackslash 5906151497Sru \edef\writexrdef##1##2{% 5907151497Sru \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef 5908151497Sru ##1}{##2}}% these are parameters of \writexrdef 5909151497Sru }% 5910151497Sru \toks0 = \expandafter{\thissection}% 5911151497Sru \immediate \writexrdef{title}{\the\toks0 }% 5912151497Sru \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc. 5913151497Sru \writexrdef{pg}{\folio}% will be written later, during \shipout 5914151497Sru }% 5915151497Sru \fi 5916151497Sru} 591769626Sru 591869626Sru% @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is 591969626Sru% the node name, #2 the name of the Info cross-reference, #3 the printed 592069626Sru% node name, #4 the name of the Info file, #5 the name of the printed 592169626Sru% manual. All but the node name can be omitted. 592269626Sru% 592369626Sru\def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]} 592469626Sru\def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]} 592569626Sru\def\ref#1{\xrefX[#1,,,,,,,]} 592669626Sru\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup 592769626Sru \unsepspaces 592869626Sru \def\printedmanual{\ignorespaces #5}% 5929151497Sru \def\printedrefname{\ignorespaces #3}% 5930151497Sru \setbox1=\hbox{\printedmanual\unskip}% 5931151497Sru \setbox0=\hbox{\printedrefname\unskip}% 593269626Sru \ifdim \wd0 = 0pt 593369626Sru % No printed node name was explicitly given. 593469626Sru \expandafter\ifx\csname SETxref-automatic-section-title\endcsname\relax 593569626Sru % Use the node name inside the square brackets. 5936151497Sru \def\printedrefname{\ignorespaces #1}% 593769626Sru \else 593869626Sru % Use the actual chapter/section title appear inside 593969626Sru % the square brackets. Use the real section title if we have it. 594069626Sru \ifdim \wd1 > 0pt 594169626Sru % It is in another manual, so we don't have it. 5942151497Sru \def\printedrefname{\ignorespaces #1}% 594369626Sru \else 594469626Sru \ifhavexrefs 594569626Sru % We know the real title if we have the xref values. 5946151497Sru \def\printedrefname{\refx{#1-title}{}}% 594769626Sru \else 594869626Sru % Otherwise just copy the Info node name. 5949151497Sru \def\printedrefname{\ignorespaces #1}% 595069626Sru \fi% 595169626Sru \fi 595269626Sru \fi 595369626Sru \fi 595469626Sru % 5955151497Sru % Make link in pdf output. 595669626Sru \ifpdf 595769626Sru \leavevmode 595869626Sru \getfilename{#4}% 5959114402Sru {\turnoffactive \otherbackslash 5960104862Sru \ifnum\filenamelength>0 5961104862Sru \startlink attr{/Border [0 0 0]}% 5962104862Sru goto file{\the\filename.pdf} name{#1}% 5963104862Sru \else 5964104862Sru \startlink attr{/Border [0 0 0]}% 5965151497Sru goto name{\pdfmkpgn{#1}}% 5966104862Sru \fi 5967104862Sru }% 596869626Sru \linkcolor 596969626Sru \fi 597069626Sru % 5971151497Sru % Float references are printed completely differently: "Figure 1.2" 5972151497Sru % instead of "[somenode], p.3". We distinguish them by the 5973151497Sru % LABEL-title being set to a magic string. 5974151497Sru {% 5975151497Sru % Have to otherify everything special to allow the \csname to 5976151497Sru % include an _ in the xref name, etc. 5977151497Sru \indexnofonts 5978151497Sru \turnoffactive 5979151497Sru \otherbackslash 5980151497Sru \expandafter\global\expandafter\let\expandafter\Xthisreftitle 5981151497Sru \csname XR#1-title\endcsname 5982151497Sru }% 5983151497Sru \iffloat\Xthisreftitle 5984151497Sru % If the user specified the print name (third arg) to the ref, 5985151497Sru % print it instead of our usual "Figure 1.2". 5986151497Sru \ifdim\wd0 = 0pt 5987151497Sru \refx{#1-snt}% 5988151497Sru \else 5989151497Sru \printedrefname 5990151497Sru \fi 5991151497Sru % 5992151497Sru % if the user also gave the printed manual name (fifth arg), append 5993151497Sru % "in MANUALNAME". 5994151497Sru \ifdim \wd1 > 0pt 5995151497Sru \space \putwordin{} \cite{\printedmanual}% 5996151497Sru \fi 599769626Sru \else 5998151497Sru % node/anchor (non-float) references. 5999151497Sru % 6000151497Sru % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not 6001151497Sru % insert empty discretionaries after hyphens, which means that it will 6002151497Sru % not find a line break at a hyphen in a node names. Since some manuals 6003151497Sru % are best written with fairly long node names, containing hyphens, this 6004151497Sru % is a loss. Therefore, we give the text of the node name again, so it 6005151497Sru % is as if TeX is seeing it for the first time. 6006151497Sru \ifdim \wd1 > 0pt 6007151497Sru \putwordsection{} ``\printedrefname'' \putwordin{} \cite{\printedmanual}% 6008151497Sru \else 6009151497Sru % _ (for example) has to be the character _ for the purposes of the 6010151497Sru % control sequence corresponding to the node, but it has to expand 6011151497Sru % into the usual \leavevmode...\vrule stuff for purposes of 6012151497Sru % printing. So we \turnoffactive for the \refx-snt, back on for the 6013151497Sru % printing, back off for the \refx-pg. 6014151497Sru {\turnoffactive \otherbackslash 6015151497Sru % Only output a following space if the -snt ref is nonempty; for 6016151497Sru % @unnumbered and @anchor, it won't be. 6017151497Sru \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}% 6018151497Sru \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi 6019151497Sru }% 6020151497Sru % output the `[mynode]' via a macro so it can be overridden. 6021151497Sru \xrefprintnodename\printedrefname 6022151497Sru % 6023151497Sru % But we always want a comma and a space: 6024151497Sru ,\space 6025151497Sru % 6026151497Sru % output the `page 3'. 6027151497Sru \turnoffactive \otherbackslash \putwordpage\tie\refx{#1-pg}{}% 6028151497Sru \fi 602969626Sru \fi 603069626Sru \endlink 603169626Sru\endgroup} 603269626Sru 6033151497Sru% This macro is called from \xrefX for the `[nodename]' part of xref 6034151497Sru% output. It's a separate macro only so it can be changed more easily, 6035151497Sru% since square brackets don't work well in some documents. Particularly 6036151497Sru% one that Bob is working on :). 6037114402Sru% 6038151497Sru\def\xrefprintnodename#1{[#1]} 603969626Sru 6040151497Sru% Things referred to by \setref. 6041151497Sru% 604269626Sru\def\Ynothing{} 6043151497Sru\def\Yomitfromtoc{} 6044151497Sru\def\Ynumbered{% 6045114402Sru \ifnum\secno=0 6046114402Sru \putwordChapter@tie \the\chapno 6047114402Sru \else \ifnum\subsecno=0 6048114402Sru \putwordSection@tie \the\chapno.\the\secno 6049114402Sru \else \ifnum\subsubsecno=0 6050114402Sru \putwordSection@tie \the\chapno.\the\secno.\the\subsecno 6051114402Sru \else 6052114402Sru \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno 6053114402Sru \fi\fi\fi 6054114402Sru} 6055151497Sru\def\Yappendix{% 6056114402Sru \ifnum\secno=0 6057114402Sru \putwordAppendix@tie @char\the\appendixno{}% 6058114402Sru \else \ifnum\subsecno=0 6059114402Sru \putwordSection@tie @char\the\appendixno.\the\secno 6060114402Sru \else \ifnum\subsubsecno=0 6061114402Sru \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno 6062114402Sru \else 6063114402Sru \putwordSection@tie 6064114402Sru @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno 6065114402Sru \fi\fi\fi 6066114402Sru} 606769626Sru 606869626Sru% Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME. 606969626Sru% If its value is nonempty, SUFFIX is output afterward. 6070114402Sru% 607169626Sru\def\refx#1#2{% 6072114402Sru {% 6073114402Sru \indexnofonts 6074114402Sru \otherbackslash 6075114402Sru \expandafter\global\expandafter\let\expandafter\thisrefX 6076151497Sru \csname XR#1\endcsname 6077114402Sru }% 6078114402Sru \ifx\thisrefX\relax 607969626Sru % If not defined, say something at least. 608069626Sru \angleleft un\-de\-fined\angleright 608169626Sru \iflinks 608269626Sru \ifhavexrefs 608369626Sru \message{\linenumber Undefined cross reference `#1'.}% 608469626Sru \else 608569626Sru \ifwarnedxrefs\else 608669626Sru \global\warnedxrefstrue 608769626Sru \message{Cross reference values unknown; you must run TeX again.}% 608869626Sru \fi 608969626Sru \fi 609069626Sru \fi 609169626Sru \else 609269626Sru % It's defined, so just use it. 6093114402Sru \thisrefX 609469626Sru \fi 609569626Sru #2% Output the suffix in any case. 609669626Sru} 609769626Sru 6098151497Sru% This is the macro invoked by entries in the aux file. Usually it's 6099151497Sru% just a \def (we prepend XR to the control sequence name to avoid 6100151497Sru% collisions). But if this is a float type, we have more work to do. 610169626Sru% 6102151497Sru\def\xrdef#1#2{% 6103151497Sru \expandafter\gdef\csname XR#1\endcsname{#2}% remember this xref value. 6104151497Sru % 6105151497Sru % Was that xref control sequence that we just defined for a float? 6106151497Sru \expandafter\iffloat\csname XR#1\endcsname 6107151497Sru % it was a float, and we have the (safe) float type in \iffloattype. 6108151497Sru \expandafter\let\expandafter\floatlist 6109151497Sru \csname floatlist\iffloattype\endcsname 6110151497Sru % 6111151497Sru % Is this the first time we've seen this float type? 6112151497Sru \expandafter\ifx\floatlist\relax 6113151497Sru \toks0 = {\do}% yes, so just \do 6114151497Sru \else 6115151497Sru % had it before, so preserve previous elements in list. 6116151497Sru \toks0 = \expandafter{\floatlist\do}% 6117151497Sru \fi 6118151497Sru % 6119151497Sru % Remember this xref in the control sequence \floatlistFLOATTYPE, 6120151497Sru % for later use in \listoffloats. 6121151497Sru \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0{#1}}% 6122151497Sru \fi 6123151497Sru} 612469626Sru 612569626Sru% Read the last existing aux file, if any. No error if none exists. 6126151497Sru% 6127151497Sru\def\tryauxfile{% 6128151497Sru \openin 1 \jobname.aux 6129151497Sru \ifeof 1 \else 6130151497Sru \readauxfile 6131151497Sru \global\havexrefstrue 6132151497Sru \fi 6133151497Sru \closein 1 6134151497Sru} 6135151497Sru 613669626Sru\def\readauxfile{\begingroup 613769626Sru \catcode`\^^@=\other 613869626Sru \catcode`\^^A=\other 613969626Sru \catcode`\^^B=\other 614069626Sru \catcode`\^^C=\other 614169626Sru \catcode`\^^D=\other 614269626Sru \catcode`\^^E=\other 614369626Sru \catcode`\^^F=\other 614469626Sru \catcode`\^^G=\other 614569626Sru \catcode`\^^H=\other 614669626Sru \catcode`\^^K=\other 614769626Sru \catcode`\^^L=\other 614869626Sru \catcode`\^^N=\other 614969626Sru \catcode`\^^P=\other 615069626Sru \catcode`\^^Q=\other 615169626Sru \catcode`\^^R=\other 615269626Sru \catcode`\^^S=\other 615369626Sru \catcode`\^^T=\other 615469626Sru \catcode`\^^U=\other 615569626Sru \catcode`\^^V=\other 615669626Sru \catcode`\^^W=\other 615769626Sru \catcode`\^^X=\other 615869626Sru \catcode`\^^Z=\other 615969626Sru \catcode`\^^[=\other 616069626Sru \catcode`\^^\=\other 616169626Sru \catcode`\^^]=\other 616269626Sru \catcode`\^^^=\other 616369626Sru \catcode`\^^_=\other 6164114402Sru % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc. 616569626Sru % in xref tags, i.e., node names. But since ^^e4 notation isn't 616669626Sru % supported in the main text, it doesn't seem desirable. Furthermore, 616769626Sru % that is not enough: for node names that actually contain a ^ 616869626Sru % character, we would end up writing a line like this: 'xrdef {'hat 616969626Sru % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first 617069626Sru % argument, and \hat is not an expandable control sequence. It could 617169626Sru % all be worked out, but why? Either we support ^^ or we don't. 617269626Sru % 617369626Sru % The other change necessary for this was to define \auxhat: 617469626Sru % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter 617569626Sru % and then to call \auxhat in \setq. 617669626Sru % 6177114402Sru \catcode`\^=\other 6178114402Sru % 6179114402Sru % Special characters. Should be turned off anyway, but... 618069626Sru \catcode`\~=\other 618169626Sru \catcode`\[=\other 618269626Sru \catcode`\]=\other 618369626Sru \catcode`\"=\other 618469626Sru \catcode`\_=\other 618569626Sru \catcode`\|=\other 618669626Sru \catcode`\<=\other 618769626Sru \catcode`\>=\other 618869626Sru \catcode`\$=\other 618969626Sru \catcode`\#=\other 619069626Sru \catcode`\&=\other 6191114402Sru \catcode`\%=\other 619269626Sru \catcode`+=\other % avoid \+ for paranoia even though we've turned it off 6193114402Sru % 6194151497Sru % This is to support \ in node names and titles, since the \ 6195151497Sru % characters end up in a \csname. It's easier than 6196151497Sru % leaving it active and making its active definition an actual \ 6197151497Sru % character. What I don't understand is why it works in the *value* 6198151497Sru % of the xrdef. Seems like it should be a catcode12 \, and that 6199151497Sru % should not typeset properly. But it works, so I'm moving on for 6200151497Sru % now. --karl, 15jan04. 6201151497Sru \catcode`\\=\other 6202151497Sru % 6203151497Sru % Make the characters 128-255 be printing characters. 620469626Sru {% 620569626Sru \count 1=128 620669626Sru \def\loop{% 620769626Sru \catcode\count 1=\other 620869626Sru \advance\count 1 by 1 620969626Sru \ifnum \count 1<256 \loop \fi 621069626Sru }% 621169626Sru }% 6212114402Sru % 6213151497Sru % @ is our escape character in .aux files, and we need braces. 621469626Sru \catcode`\{=1 621569626Sru \catcode`\}=2 6216114402Sru \catcode`\@=0 621769626Sru % 6218151497Sru \input \jobname.aux 621969626Sru\endgroup} 622069626Sru 622169626Sru 6222151497Sru\message{insertions,} 6223151497Sru% including footnotes. 622469626Sru 622569626Sru\newcount \footnoteno 622669626Sru 622769626Sru% The trailing space in the following definition for supereject is 622869626Sru% vital for proper filling; pages come out unaligned when you do a 622969626Sru% pagealignmacro call if that space before the closing brace is 623069626Sru% removed. (Generally, numeric constants should always be followed by a 623169626Sru% space to prevent strange expansion errors.) 623269626Sru\def\supereject{\par\penalty -20000\footnoteno =0 } 623369626Sru 623469626Sru% @footnotestyle is meaningful for info output only. 623569626Sru\let\footnotestyle=\comment 623669626Sru 623769626Sru{\catcode `\@=11 623869626Sru% 623969626Sru% Auto-number footnotes. Otherwise like plain. 624069626Sru\gdef\footnote{% 6241151497Sru \let\indent=\ptexindent 6242151497Sru \let\noindent=\ptexnoindent 624369626Sru \global\advance\footnoteno by \@ne 624469626Sru \edef\thisfootno{$^{\the\footnoteno}$}% 624569626Sru % 624669626Sru % In case the footnote comes at the end of a sentence, preserve the 624769626Sru % extra spacing after we do the footnote number. 624869626Sru \let\@sf\empty 6249151497Sru \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi 625069626Sru % 625169626Sru % Remove inadvertent blank space before typesetting the footnote number. 625269626Sru \unskip 625369626Sru \thisfootno\@sf 6254114402Sru \dofootnote 625569626Sru}% 625669626Sru 625769626Sru% Don't bother with the trickery in plain.tex to not require the 625869626Sru% footnote text as a parameter. Our footnotes don't need to be so general. 625969626Sru% 6260151497Sru% Oh yes, they do; otherwise, @ifset (and anything else that uses 6261151497Sru% \parseargline) fails inside footnotes because the tokens are fixed when 626269626Sru% the footnote is read. --karl, 16nov96. 626369626Sru% 6264114402Sru\gdef\dofootnote{% 6265151497Sru \insert\footins\bgroup 626669626Sru % We want to typeset this text as a normal paragraph, even if the 626769626Sru % footnote reference occurs in (for example) a display environment. 626869626Sru % So reset some parameters. 6269114402Sru \hsize=\pagewidth 627069626Sru \interlinepenalty\interfootnotelinepenalty 627169626Sru \splittopskip\ht\strutbox % top baseline for broken footnotes 627269626Sru \splitmaxdepth\dp\strutbox 627369626Sru \floatingpenalty\@MM 627469626Sru \leftskip\z@skip 627569626Sru \rightskip\z@skip 627669626Sru \spaceskip\z@skip 627769626Sru \xspaceskip\z@skip 627869626Sru \parindent\defaultparindent 627969626Sru % 628069626Sru \smallfonts \rm 628169626Sru % 6282104862Sru % Because we use hanging indentation in footnotes, a @noindent appears 6283104862Sru % to exdent this text, so make it be a no-op. makeinfo does not use 6284104862Sru % hanging indentation so @noindent can still be needed within footnote 6285104862Sru % text after an @example or the like (not that this is good style). 6286104862Sru \let\noindent = \relax 6287104862Sru % 6288104862Sru % Hang the footnote text off the number. Use \everypar in case the 6289104862Sru % footnote extends for more than one paragraph. 6290104862Sru \everypar = {\hang}% 629169626Sru \textindent{\thisfootno}% 629269626Sru % 629369626Sru % Don't crash into the line above the footnote text. Since this 629469626Sru % expands into a box, it must come within the paragraph, lest it 629569626Sru % provide a place where TeX can split the footnote. 629669626Sru \footstrut 629769626Sru \futurelet\next\fo@t 629869626Sru} 629969626Sru}%end \catcode `\@=11 630069626Sru 6301151497Sru% In case a @footnote appears in a vbox, save the footnote text and create 6302151497Sru% the real \insert just after the vbox finished. Otherwise, the insertion 6303151497Sru% would be lost. 6304151497Sru% Similarily, if a @footnote appears inside an alignment, save the footnote 6305151497Sru% text to a box and make the \insert when a row of the table is finished. 6306151497Sru% And the same can be done for other insert classes. --kasal, 16nov03. 6307151497Sru 6308151497Sru% Replace the \insert primitive by a cheating macro. 6309151497Sru% Deeper inside, just make sure that the saved insertions are not spilled 6310151497Sru% out prematurely. 631169626Sru% 6312151497Sru\def\startsavinginserts{% 6313151497Sru \ifx \insert\ptexinsert 6314151497Sru \let\insert\saveinsert 6315151497Sru \else 6316151497Sru \let\checkinserts\relax 6317151497Sru \fi 631869626Sru} 631969626Sru 6320151497Sru% This \insert replacement works for both \insert\footins{foo} and 6321151497Sru% \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}. 632269626Sru% 6323151497Sru\def\saveinsert#1{% 6324151497Sru \edef\next{\noexpand\savetobox \makeSAVEname#1}% 6325151497Sru \afterassignment\next 6326151497Sru % swallow the left brace 6327151497Sru \let\temp = 6328151497Sru} 6329151497Sru\def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}} 6330151497Sru\def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1} 633169626Sru 6332151497Sru\def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi} 6333151497Sru 6334151497Sru\def\placesaveins#1{% 6335151497Sru \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname 6336151497Sru {\box#1}% 6337151497Sru} 6338151497Sru 6339151497Sru% eat @SAVE -- beware, all of them have catcode \other: 6340151497Sru{ 6341151497Sru \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials % ;-) 6342151497Sru \gdef\gobblesave @SAVE{} 6343151497Sru} 6344151497Sru 6345151497Sru% initialization: 6346151497Sru\def\newsaveins #1{% 6347151497Sru \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}% 6348151497Sru \next 6349151497Sru} 6350151497Sru\def\newsaveinsX #1{% 6351151497Sru \csname newbox\endcsname #1% 6352151497Sru \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts 6353151497Sru \checksaveins #1}% 6354151497Sru} 6355151497Sru 6356151497Sru% initialize: 6357151497Sru\let\checkinserts\empty 6358151497Sru\newsaveins\footins 6359151497Sru\newsaveins\margin 6360151497Sru 6361151497Sru 636269626Sru% @image. We use the macros from epsf.tex to support this. 636369626Sru% If epsf.tex is not installed and @image is used, we complain. 636469626Sru% 636569626Sru% Check for and read epsf.tex up front. If we read it only at @image 636669626Sru% time, we might be inside a group, and then its definitions would get 636769626Sru% undone and the next image would fail. 636869626Sru\openin 1 = epsf.tex 636969626Sru\ifeof 1 \else 6370114402Sru % Do not bother showing banner with epsf.tex v2.7k (available in 6371114402Sru % doc/epsf.tex and on ctan). 637269626Sru \def\epsfannounce{\toks0 = }% 637369626Sru \input epsf.tex 637469626Sru\fi 6375151497Sru\closein 1 637669626Sru% 637769626Sru% We will only complain once about lack of epsf.tex. 637869626Sru\newif\ifwarnednoepsf 637969626Sru\newhelp\noepsfhelp{epsf.tex must be installed for images to 638069626Sru work. It is also included in the Texinfo distribution, or you can get 638169626Sru it from ftp://tug.org/tex/epsf.tex.} 638269626Sru% 638369626Sru\def\image#1{% 638469626Sru \ifx\epsfbox\undefined 638569626Sru \ifwarnednoepsf \else 638669626Sru \errhelp = \noepsfhelp 638769626Sru \errmessage{epsf.tex not found, images will be ignored}% 638869626Sru \global\warnednoepsftrue 638969626Sru \fi 639069626Sru \else 6391104862Sru \imagexxx #1,,,,,\finish 639269626Sru \fi 639369626Sru} 639469626Sru% 639569626Sru% Arguments to @image: 639669626Sru% #1 is (mandatory) image filename; we tack on .eps extension. 639769626Sru% #2 is (optional) width, #3 is (optional) height. 6398104862Sru% #4 is (ignored optional) html alt text. 6399104862Sru% #5 is (ignored optional) extension. 6400104862Sru% #6 is just the usual extra ignored arg for parsing this stuff. 6401104862Sru\newif\ifimagevmode 6402104862Sru\def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup 6403104862Sru \catcode`\^^M = 5 % in case we're inside an example 6404104862Sru \normalturnoffactive % allow _ et al. in names 6405104862Sru % If the image is by itself, center it. 6406104862Sru \ifvmode 6407104862Sru \imagevmodetrue 6408104862Sru \nobreak\bigskip 6409104862Sru % Usually we'll have text after the image which will insert 6410104862Sru % \parskip glue, so insert it here too to equalize the space 6411151497Sru % above and below. 6412104862Sru \nobreak\vskip\parskip 6413104862Sru \nobreak 6414104862Sru \line\bgroup\hss 6415104862Sru \fi 6416104862Sru % 6417104862Sru % Output the image. 641869626Sru \ifpdf 6419104862Sru \dopdfimage{#1}{#2}{#3}% 642069626Sru \else 642169626Sru % \epsfbox itself resets \epsf?size at each figure. 642269626Sru \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi 642369626Sru \setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi 6424104862Sru \epsfbox{#1.eps}% 642569626Sru \fi 6426104862Sru % 6427104862Sru \ifimagevmode \hss \egroup \bigbreak \fi % space after the image 6428104862Sru\endgroup} 642969626Sru 643069626Sru 6431151497Sru% @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables, 6432151497Sru% etc. We don't actually implement floating yet, we always include the 6433151497Sru% float "here". But it seemed the best name for the future. 6434151497Sru% 6435151497Sru\envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish} 6436151497Sru 6437151497Sru% There may be a space before second and/or third parameter; delete it. 6438151497Sru\def\eatcommaspace#1, {#1,} 6439151497Sru 6440151497Sru% #1 is the optional FLOATTYPE, the text label for this float, typically 6441151497Sru% "Figure", "Table", "Example", etc. Can't contain commas. If omitted, 6442151497Sru% this float will not be numbered and cannot be referred to. 6443151497Sru% 6444151497Sru% #2 is the optional xref label. Also must be present for the float to 6445151497Sru% be referable. 6446151497Sru% 6447151497Sru% #3 is the optional positioning argument; for now, it is ignored. It 6448151497Sru% will somehow specify the positions allowed to float to (here, top, bottom). 6449151497Sru% 6450151497Sru% We keep a separate counter for each FLOATTYPE, which we reset at each 6451151497Sru% chapter-level command. 6452151497Sru\let\resetallfloatnos=\empty 6453151497Sru% 6454151497Sru\def\dofloat#1,#2,#3,#4\finish{% 6455151497Sru \let\thiscaption=\empty 6456151497Sru \let\thisshortcaption=\empty 6457151497Sru % 6458151497Sru % don't lose footnotes inside @float. 6459151497Sru % 6460151497Sru % BEWARE: when the floats start float, we have to issue warning whenever an 6461151497Sru % insert appears inside a float which could possibly float. --kasal, 26may04 6462151497Sru % 6463151497Sru \startsavinginserts 6464151497Sru % 6465151497Sru % We can't be used inside a paragraph. 6466151497Sru \par 6467151497Sru % 6468151497Sru \vtop\bgroup 6469151497Sru \def\floattype{#1}% 6470151497Sru \def\floatlabel{#2}% 6471151497Sru \def\floatloc{#3}% we do nothing with this yet. 6472151497Sru % 6473151497Sru \ifx\floattype\empty 6474151497Sru \let\safefloattype=\empty 6475151497Sru \else 6476151497Sru {% 6477151497Sru % the floattype might have accents or other special characters, 6478151497Sru % but we need to use it in a control sequence name. 6479151497Sru \indexnofonts 6480151497Sru \turnoffactive 6481151497Sru \xdef\safefloattype{\floattype}% 6482151497Sru }% 6483151497Sru \fi 6484151497Sru % 6485151497Sru % If label is given but no type, we handle that as the empty type. 6486151497Sru \ifx\floatlabel\empty \else 6487151497Sru % We want each FLOATTYPE to be numbered separately (Figure 1, 6488151497Sru % Table 1, Figure 2, ...). (And if no label, no number.) 6489151497Sru % 6490151497Sru \expandafter\getfloatno\csname\safefloattype floatno\endcsname 6491151497Sru \global\advance\floatno by 1 6492151497Sru % 6493151497Sru {% 6494151497Sru % This magic value for \thissection is output by \setref as the 6495151497Sru % XREFLABEL-title value. \xrefX uses it to distinguish float 6496151497Sru % labels (which have a completely different output format) from 6497151497Sru % node and anchor labels. And \xrdef uses it to construct the 6498151497Sru % lists of floats. 6499151497Sru % 6500151497Sru \edef\thissection{\floatmagic=\safefloattype}% 6501151497Sru \setref{\floatlabel}{Yfloat}% 6502151497Sru }% 6503151497Sru \fi 6504151497Sru % 6505151497Sru % start with \parskip glue, I guess. 6506151497Sru \vskip\parskip 6507151497Sru % 6508151497Sru % Don't suppress indentation if a float happens to start a section. 6509151497Sru \restorefirstparagraphindent 6510151497Sru} 6511151497Sru 6512151497Sru% we have these possibilities: 6513151497Sru% @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap 6514151497Sru% @float Foo,lbl & no caption: Foo 1.1 6515151497Sru% @float Foo & @caption{Cap}: Foo: Cap 6516151497Sru% @float Foo & no caption: Foo 6517151497Sru% @float ,lbl & Caption{Cap}: 1.1: Cap 6518151497Sru% @float ,lbl & no caption: 1.1 6519151497Sru% @float & @caption{Cap}: Cap 6520151497Sru% @float & no caption: 6521151497Sru% 6522151497Sru\def\Efloat{% 6523151497Sru \let\floatident = \empty 6524151497Sru % 6525151497Sru % In all cases, if we have a float type, it comes first. 6526151497Sru \ifx\floattype\empty \else \def\floatident{\floattype}\fi 6527151497Sru % 6528151497Sru % If we have an xref label, the number comes next. 6529151497Sru \ifx\floatlabel\empty \else 6530151497Sru \ifx\floattype\empty \else % if also had float type, need tie first. 6531151497Sru \appendtomacro\floatident{\tie}% 6532151497Sru \fi 6533151497Sru % the number. 6534151497Sru \appendtomacro\floatident{\chaplevelprefix\the\floatno}% 6535151497Sru \fi 6536151497Sru % 6537151497Sru % Start the printed caption with what we've constructed in 6538151497Sru % \floatident, but keep it separate; we need \floatident again. 6539151497Sru \let\captionline = \floatident 6540151497Sru % 6541151497Sru \ifx\thiscaption\empty \else 6542151497Sru \ifx\floatident\empty \else 6543151497Sru \appendtomacro\captionline{: }% had ident, so need a colon between 6544151497Sru \fi 6545151497Sru % 6546151497Sru % caption text. 6547151497Sru \appendtomacro\captionline{\scanexp\thiscaption}% 6548151497Sru \fi 6549151497Sru % 6550151497Sru % If we have anything to print, print it, with space before. 6551151497Sru % Eventually this needs to become an \insert. 6552151497Sru \ifx\captionline\empty \else 6553151497Sru \vskip.5\parskip 6554151497Sru \captionline 6555151497Sru % 6556151497Sru % Space below caption. 6557151497Sru \vskip\parskip 6558151497Sru \fi 6559151497Sru % 6560151497Sru % If have an xref label, write the list of floats info. Do this 6561151497Sru % after the caption, to avoid chance of it being a breakpoint. 6562151497Sru \ifx\floatlabel\empty \else 6563151497Sru % Write the text that goes in the lof to the aux file as 6564151497Sru % \floatlabel-lof. Besides \floatident, we include the short 6565151497Sru % caption if specified, else the full caption if specified, else nothing. 6566151497Sru {% 6567151497Sru \atdummies \turnoffactive \otherbackslash 6568151497Sru % since we read the caption text in the macro world, where ^^M 6569151497Sru % is turned into a normal character, we have to scan it back, so 6570151497Sru % we don't write the literal three characters "^^M" into the aux file. 6571151497Sru \scanexp{% 6572151497Sru \xdef\noexpand\gtemp{% 6573151497Sru \ifx\thisshortcaption\empty 6574151497Sru \thiscaption 6575151497Sru \else 6576151497Sru \thisshortcaption 6577151497Sru \fi 6578151497Sru }% 6579151497Sru }% 6580151497Sru \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident 6581151497Sru \ifx\gtemp\empty \else : \gtemp \fi}}% 6582151497Sru }% 6583151497Sru \fi 6584151497Sru \egroup % end of \vtop 6585151497Sru % 6586151497Sru % place the captured inserts 6587151497Sru % 6588151497Sru % BEWARE: when the floats start float, we have to issue warning whenever an 6589151497Sru % insert appears inside a float which could possibly float. --kasal, 26may04 6590151497Sru % 6591151497Sru \checkinserts 6592151497Sru} 6593151497Sru 6594151497Sru% Append the tokens #2 to the definition of macro #1, not expanding either. 6595151497Sru% 6596151497Sru\def\appendtomacro#1#2{% 6597151497Sru \expandafter\def\expandafter#1\expandafter{#1#2}% 6598151497Sru} 6599151497Sru 6600151497Sru% @caption, @shortcaption 6601151497Sru% 6602151497Sru\def\caption{\docaption\thiscaption} 6603151497Sru\def\shortcaption{\docaption\thisshortcaption} 6604151497Sru\def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption} 6605151497Sru\def\defcaption#1#2{\egroup \def#1{#2}} 6606151497Sru 6607151497Sru% The parameter is the control sequence identifying the counter we are 6608151497Sru% going to use. Create it if it doesn't exist and assign it to \floatno. 6609151497Sru\def\getfloatno#1{% 6610151497Sru \ifx#1\relax 6611151497Sru % Haven't seen this figure type before. 6612151497Sru \csname newcount\endcsname #1% 6613151497Sru % 6614151497Sru % Remember to reset this floatno at the next chap. 6615151497Sru \expandafter\gdef\expandafter\resetallfloatnos 6616151497Sru \expandafter{\resetallfloatnos #1=0 }% 6617151497Sru \fi 6618151497Sru \let\floatno#1% 6619151497Sru} 6620151497Sru 6621151497Sru% \setref calls this to get the XREFLABEL-snt value. We want an @xref 6622151497Sru% to the FLOATLABEL to expand to "Figure 3.1". We call \setref when we 6623151497Sru% first read the @float command. 6624151497Sru% 6625151497Sru\def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}% 6626151497Sru 6627151497Sru% Magic string used for the XREFLABEL-title value, so \xrefX can 6628151497Sru% distinguish floats from other xref types. 6629151497Sru\def\floatmagic{!!float!!} 6630151497Sru 6631151497Sru% #1 is the control sequence we are passed; we expand into a conditional 6632151497Sru% which is true if #1 represents a float ref. That is, the magic 6633151497Sru% \thissection value which we \setref above. 6634151497Sru% 6635151497Sru\def\iffloat#1{\expandafter\doiffloat#1==\finish} 6636151497Sru% 6637151497Sru% #1 is (maybe) the \floatmagic string. If so, #2 will be the 6638151497Sru% (safe) float type for this float. We set \iffloattype to #2. 6639151497Sru% 6640151497Sru\def\doiffloat#1=#2=#3\finish{% 6641151497Sru \def\temp{#1}% 6642151497Sru \def\iffloattype{#2}% 6643151497Sru \ifx\temp\floatmagic 6644151497Sru} 6645151497Sru 6646151497Sru% @listoffloats FLOATTYPE - print a list of floats like a table of contents. 6647151497Sru% 6648151497Sru\parseargdef\listoffloats{% 6649151497Sru \def\floattype{#1}% floattype 6650151497Sru {% 6651151497Sru % the floattype might have accents or other special characters, 6652151497Sru % but we need to use it in a control sequence name. 6653151497Sru \indexnofonts 6654151497Sru \turnoffactive 6655151497Sru \xdef\safefloattype{\floattype}% 6656151497Sru }% 6657151497Sru % 6658151497Sru % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE. 6659151497Sru \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax 6660151497Sru \ifhavexrefs 6661151497Sru % if the user said @listoffloats foo but never @float foo. 6662151497Sru \message{\linenumber No `\safefloattype' floats to list.}% 6663151497Sru \fi 6664151497Sru \else 6665151497Sru \begingroup 6666151497Sru \leftskip=\tocindent % indent these entries like a toc 6667151497Sru \let\do=\listoffloatsdo 6668151497Sru \csname floatlist\safefloattype\endcsname 6669151497Sru \endgroup 6670151497Sru \fi 6671151497Sru} 6672151497Sru 6673151497Sru% This is called on each entry in a list of floats. We're passed the 6674151497Sru% xref label, in the form LABEL-title, which is how we save it in the 6675151497Sru% aux file. We strip off the -title and look up \XRLABEL-lof, which 6676151497Sru% has the text we're supposed to typeset here. 6677151497Sru% 6678151497Sru% Figures without xref labels will not be included in the list (since 6679151497Sru% they won't appear in the aux file). 6680151497Sru% 6681151497Sru\def\listoffloatsdo#1{\listoffloatsdoentry#1\finish} 6682151497Sru\def\listoffloatsdoentry#1-title\finish{{% 6683151497Sru % Can't fully expand XR#1-lof because it can contain anything. Just 6684151497Sru % pass the control sequence. On the other hand, XR#1-pg is just the 6685151497Sru % page number, and we want to fully expand that so we can get a link 6686151497Sru % in pdf output. 6687151497Sru \toksA = \expandafter{\csname XR#1-lof\endcsname}% 6688151497Sru % 6689151497Sru % use the same \entry macro we use to generate the TOC and index. 6690151497Sru \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}% 6691151497Sru \writeentry 6692151497Sru}} 6693151497Sru 669469626Sru\message{localization,} 669569626Sru% and i18n. 669669626Sru 669769626Sru% @documentlanguage is usually given very early, just after 669869626Sru% @setfilename. If done too late, it may not override everything 669969626Sru% properly. Single argument is the language abbreviation. 670069626Sru% It would be nice if we could set up a hyphenation file here. 670169626Sru% 6702151497Sru\parseargdef\documentlanguage{% 670369626Sru \tex % read txi-??.tex file in plain TeX. 6704151497Sru % Read the file if it exists. 6705151497Sru \openin 1 txi-#1.tex 6706151497Sru \ifeof 1 6707151497Sru \errhelp = \nolanghelp 6708151497Sru \errmessage{Cannot read language file txi-#1.tex}% 6709151497Sru \else 6710151497Sru \input txi-#1.tex 6711151497Sru \fi 6712151497Sru \closein 1 671369626Sru \endgroup 671469626Sru} 671569626Sru\newhelp\nolanghelp{The given language definition file cannot be found or 671669626Sruis empty. Maybe you need to install it? In the current directory 671769626Srushould work if nowhere else does.} 671869626Sru 671969626Sru 672069626Sru% @documentencoding should change something in TeX eventually, most 672169626Sru% likely, but for now just recognize it. 672269626Sru\let\documentencoding = \comment 672369626Sru 672469626Sru 672569626Sru% Page size parameters. 672669626Sru% 672769626Sru\newdimen\defaultparindent \defaultparindent = 15pt 672869626Sru 672969626Sru\chapheadingskip = 15pt plus 4pt minus 2pt 673069626Sru\secheadingskip = 12pt plus 3pt minus 2pt 673169626Sru\subsecheadingskip = 9pt plus 2pt minus 2pt 673269626Sru 673369626Sru% Prevent underfull vbox error messages. 673469626Sru\vbadness = 10000 673569626Sru 673669626Sru% Don't be so finicky about underfull hboxes, either. 673769626Sru\hbadness = 2000 673869626Sru 673969626Sru% Following George Bush, just get rid of widows and orphans. 674069626Sru\widowpenalty=10000 674169626Sru\clubpenalty=10000 674269626Sru 674369626Sru% Use TeX 3.0's \emergencystretch to help line breaking, but if we're 674469626Sru% using an old version of TeX, don't do anything. We want the amount of 674569626Sru% stretch added to depend on the line length, hence the dependence on 674669626Sru% \hsize. We call this whenever the paper size is set. 674769626Sru% 674869626Sru\def\setemergencystretch{% 674969626Sru \ifx\emergencystretch\thisisundefined 675069626Sru % Allow us to assign to \emergencystretch anyway. 675169626Sru \def\emergencystretch{\dimen0}% 675269626Sru \else 675369626Sru \emergencystretch = .15\hsize 675469626Sru \fi 675569626Sru} 675669626Sru 675769626Sru% Parameters in order: 1) textheight; 2) textwidth; 3) voffset; 6758114402Sru% 4) hoffset; 5) binding offset; 6) topskip; 7) physical page height; 8) 6759114402Sru% physical page width. 6760151497Sru% 6761114402Sru% We also call \setleading{\textleading}, so the caller should define 6762114402Sru% \textleading. The caller should also set \parskip. 676369626Sru% 6764104862Sru\def\internalpagesizes#1#2#3#4#5#6#7#8{% 676569626Sru \voffset = #3\relax 676669626Sru \topskip = #6\relax 676769626Sru \splittopskip = \topskip 676869626Sru % 676969626Sru \vsize = #1\relax 677069626Sru \advance\vsize by \topskip 677169626Sru \outervsize = \vsize 677269626Sru \advance\outervsize by 2\topandbottommargin 677369626Sru \pageheight = \vsize 677469626Sru % 677569626Sru \hsize = #2\relax 677669626Sru \outerhsize = \hsize 677769626Sru \advance\outerhsize by 0.5in 677869626Sru \pagewidth = \hsize 677969626Sru % 678069626Sru \normaloffset = #4\relax 678169626Sru \bindingoffset = #5\relax 678269626Sru % 6783114402Sru \ifpdf 6784114402Sru \pdfpageheight #7\relax 6785114402Sru \pdfpagewidth #8\relax 6786114402Sru \fi 6787114402Sru % 6788104862Sru \setleading{\textleading} 6789104862Sru % 679069626Sru \parindent = \defaultparindent 679169626Sru \setemergencystretch 679269626Sru} 679369626Sru 679469626Sru% @letterpaper (the default). 679569626Sru\def\letterpaper{{\globaldefs = 1 679669626Sru \parskip = 3pt plus 2pt minus 1pt 6797104862Sru \textleading = 13.2pt 679869626Sru % 679969626Sru % If page is nothing but text, make it come out even. 6800104862Sru \internalpagesizes{46\baselineskip}{6in}% 6801104862Sru {\voffset}{.25in}% 6802104862Sru {\bindingoffset}{36pt}% 6803104862Sru {11in}{8.5in}% 680469626Sru}} 680569626Sru 680669626Sru% Use @smallbook to reset parameters for 7x9.5 (or so) format. 680769626Sru\def\smallbook{{\globaldefs = 1 680869626Sru \parskip = 2pt plus 1pt 6809104862Sru \textleading = 12pt 681069626Sru % 6811114402Sru \internalpagesizes{7.5in}{5in}% 6812104862Sru {\voffset}{.25in}% 6813104862Sru {\bindingoffset}{16pt}% 6814104862Sru {9.25in}{7in}% 681569626Sru % 681669626Sru \lispnarrowing = 0.3in 681769626Sru \tolerance = 700 681869626Sru \hfuzz = 1pt 681969626Sru \contentsrightmargin = 0pt 682069626Sru \defbodyindent = .5cm 682169626Sru}} 682269626Sru 682369626Sru% Use @afourpaper to print on European A4 paper. 682469626Sru\def\afourpaper{{\globaldefs = 1 682569626Sru \parskip = 3pt plus 2pt minus 1pt 6826114402Sru \textleading = 13.2pt 682769626Sru % 6828151497Sru % Double-side printing via postscript on Laserjet 4050 6829114402Sru % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm. 6830114402Sru % To change the settings for a different printer or situation, adjust 6831114402Sru % \normaloffset until the front-side and back-side texts align. Then 6832114402Sru % do the same for \bindingoffset. You can set these for testing in 6833114402Sru % your texinfo source file like this: 6834114402Sru % @tex 6835114402Sru % \global\normaloffset = -6mm 6836114402Sru % \global\bindingoffset = 10mm 6837114402Sru % @end tex 6838114402Sru \internalpagesizes{51\baselineskip}{160mm} 6839114402Sru {\voffset}{\hoffset}% 6840104862Sru {\bindingoffset}{44pt}% 6841104862Sru {297mm}{210mm}% 684269626Sru % 684369626Sru \tolerance = 700 684469626Sru \hfuzz = 1pt 6845114402Sru \contentsrightmargin = 0pt 6846114402Sru \defbodyindent = 5mm 684769626Sru}} 684869626Sru 6849104862Sru% Use @afivepaper to print on European A5 paper. 6850104862Sru% From romildo@urano.iceb.ufop.br, 2 July 2000. 6851104862Sru% He also recommends making @example and @lisp be small. 6852104862Sru\def\afivepaper{{\globaldefs = 1 6853104862Sru \parskip = 2pt plus 1pt minus 0.1pt 6854104862Sru \textleading = 12.5pt 6855104862Sru % 6856114402Sru \internalpagesizes{160mm}{120mm}% 6857114402Sru {\voffset}{\hoffset}% 6858104862Sru {\bindingoffset}{8pt}% 6859104862Sru {210mm}{148mm}% 6860104862Sru % 6861104862Sru \lispnarrowing = 0.2in 6862104862Sru \tolerance = 800 6863104862Sru \hfuzz = 1.2pt 6864114402Sru \contentsrightmargin = 0pt 6865104862Sru \defbodyindent = 2mm 6866104862Sru \tableindent = 12mm 6867104862Sru}} 6868104862Sru 6869151497Sru% A specific text layout, 24x15cm overall, intended for A4 paper. 687069626Sru\def\afourlatex{{\globaldefs = 1 687169626Sru \afourpaper 6872104862Sru \internalpagesizes{237mm}{150mm}% 6873114402Sru {\voffset}{4.6mm}% 6874114402Sru {\bindingoffset}{7mm}% 6875104862Sru {297mm}{210mm}% 687669626Sru % 6877114402Sru % Must explicitly reset to 0 because we call \afourpaper. 687869626Sru \globaldefs = 0 687969626Sru}} 688069626Sru 6881114402Sru% Use @afourwide to print on A4 paper in landscape format. 6882114402Sru\def\afourwide{{\globaldefs = 1 688369626Sru \afourpaper 6884114402Sru \internalpagesizes{241mm}{165mm}% 6885114402Sru {\voffset}{-2.95mm}% 6886104862Sru {\bindingoffset}{7mm}% 6887104862Sru {297mm}{210mm}% 6888114402Sru \globaldefs = 0 6889114402Sru}} 689069626Sru 689169626Sru% @pagesizes TEXTHEIGHT[,TEXTWIDTH] 689269626Sru% Perhaps we should allow setting the margins, \topskip, \parskip, 689369626Sru% and/or leading, also. Or perhaps we should compute them somehow. 689469626Sru% 6895151497Sru\parseargdef\pagesizes{\pagesizesyyy #1,,\finish} 689669626Sru\def\pagesizesyyy#1,#2,#3\finish{{% 689769626Sru \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi 689869626Sru \globaldefs = 1 689969626Sru % 690069626Sru \parskip = 3pt plus 2pt minus 1pt 6901104862Sru \setleading{\textleading}% 690269626Sru % 6903114402Sru \dimen0 = #1 6904114402Sru \advance\dimen0 by \voffset 6905114402Sru % 6906114402Sru \dimen2 = \hsize 6907114402Sru \advance\dimen2 by \normaloffset 6908114402Sru % 6909104862Sru \internalpagesizes{#1}{\hsize}% 6910104862Sru {\voffset}{\normaloffset}% 6911104862Sru {\bindingoffset}{44pt}% 6912114402Sru {\dimen0}{\dimen2}% 691369626Sru}} 691469626Sru 691569626Sru% Set default to letter. 691669626Sru% 691769626Sru\letterpaper 691869626Sru 691969626Sru 692069626Sru\message{and turning on texinfo input format.} 692169626Sru 692269626Sru% Define macros to output various characters with catcode for normal text. 692369626Sru\catcode`\"=\other 692469626Sru\catcode`\~=\other 692569626Sru\catcode`\^=\other 692669626Sru\catcode`\_=\other 692769626Sru\catcode`\|=\other 692869626Sru\catcode`\<=\other 692969626Sru\catcode`\>=\other 693069626Sru\catcode`\+=\other 693169626Sru\catcode`\$=\other 693269626Sru\def\normaldoublequote{"} 693369626Sru\def\normaltilde{~} 693469626Sru\def\normalcaret{^} 693569626Sru\def\normalunderscore{_} 693669626Sru\def\normalverticalbar{|} 693769626Sru\def\normalless{<} 693869626Sru\def\normalgreater{>} 693969626Sru\def\normalplus{+} 6940104862Sru\def\normaldollar{$}%$ font-lock fix 694169626Sru 6942151497Sru% This macro is used to make a character print one way in \tt 6943151497Sru% (where it can probably be output as-is), and another way in other fonts, 694469626Sru% where something hairier probably needs to be done. 694569626Sru% 694669626Sru% #1 is what to print if we are indeed using \tt; #2 is what to print 694769626Sru% otherwise. Since all the Computer Modern typewriter fonts have zero 694869626Sru% interword stretch (and shrink), and it is reasonable to expect all 694969626Sru% typewriter fonts to have this, we can check that font parameter. 695069626Sru% 695169626Sru\def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi} 695269626Sru 695369626Sru% Same as above, but check for italic font. Actually this also catches 695469626Sru% non-italic slanted fonts since it is impossible to distinguish them from 695569626Sru% italic fonts. But since this is only used by $ and it uses \sl anyway 695669626Sru% this is not a problem. 695769626Sru\def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi} 695869626Sru 695969626Sru% Turn off all special characters except @ 696069626Sru% (and those which the user can use as if they were ordinary). 696169626Sru% Most of these we simply print from the \tt font, but for some, we can 696269626Sru% use math or other variants that look better in normal text. 696369626Sru 696469626Sru\catcode`\"=\active 696569626Sru\def\activedoublequote{{\tt\char34}} 696669626Sru\let"=\activedoublequote 696769626Sru\catcode`\~=\active 696869626Sru\def~{{\tt\char126}} 696969626Sru\chardef\hat=`\^ 697069626Sru\catcode`\^=\active 697169626Sru\def^{{\tt \hat}} 697269626Sru 697369626Sru\catcode`\_=\active 697469626Sru\def_{\ifusingtt\normalunderscore\_} 697569626Sru% Subroutine for the previous macro. 6976114402Sru\def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em } 697769626Sru 697869626Sru\catcode`\|=\active 697969626Sru\def|{{\tt\char124}} 698069626Sru\chardef \less=`\< 698169626Sru\catcode`\<=\active 698269626Sru\def<{{\tt \less}} 698369626Sru\chardef \gtr=`\> 698469626Sru\catcode`\>=\active 698569626Sru\def>{{\tt \gtr}} 698669626Sru\catcode`\+=\active 698769626Sru\def+{{\tt \char 43}} 698869626Sru\catcode`\$=\active 6989104862Sru\def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix 699069626Sru 699169626Sru% If a .fmt file is being used, characters that might appear in a file 699269626Sru% name cannot be active until we have parsed the command line. 699369626Sru% So turn them off again, and have \everyjob (or @setfilename) turn them on. 699469626Sru% \otherifyactive is called near the end of this file. 699569626Sru\def\otherifyactive{\catcode`+=\other \catcode`\_=\other} 699669626Sru 699769626Sru\catcode`\@=0 699869626Sru 6999151497Sru% \backslashcurfont outputs one backslash character in current font, 7000114402Sru% as in \char`\\. 7001151497Sru\global\chardef\backslashcurfont=`\\ 7002151497Sru\global\let\rawbackslashxx=\backslashcurfont % let existing .??s files work 700369626Sru 7004151497Sru% \rawbackslash defines an active \ to do \backslashcurfont. 7005114402Sru% \otherbackslash defines an active \ to be a literal `\' character with 7006114402Sru% catcode other. 700769626Sru{\catcode`\\=\active 7008151497Sru @gdef@rawbackslash{@let\=@backslashcurfont} 7009114402Sru @gdef@otherbackslash{@let\=@realbackslash} 7010114402Sru} 701169626Sru 7012114402Sru% \realbackslash is an actual character `\' with catcode other. 7013114402Sru{\catcode`\\=\other @gdef@realbackslash{\}} 7014114402Sru 701569626Sru% \normalbackslash outputs one backslash in fixed width font. 7016151497Sru\def\normalbackslash{{\tt\backslashcurfont}} 701769626Sru 701869626Sru\catcode`\\=\active 701969626Sru 702069626Sru% Used sometimes to turn off (effectively) the active characters 702169626Sru% even after parsing them. 7022114402Sru@def@turnoffactive{% 7023114402Sru @let"=@normaldoublequote 7024114402Sru @let\=@realbackslash 7025114402Sru @let~=@normaltilde 7026114402Sru @let^=@normalcaret 7027114402Sru @let_=@normalunderscore 7028114402Sru @let|=@normalverticalbar 7029114402Sru @let<=@normalless 7030114402Sru @let>=@normalgreater 7031114402Sru @let+=@normalplus 7032114402Sru @let$=@normaldollar %$ font-lock fix 7033151497Sru @unsepspaces 7034114402Sru} 703569626Sru 7036114402Sru% Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of 7037114402Sru% the literal character `\'. (Thus, \ is not expandable when this is in 7038114402Sru% effect.) 7039151497Sru% 7040114402Sru@def@normalturnoffactive{@turnoffactive @let\=@normalbackslash} 704169626Sru 704269626Sru% Make _ and + \other characters, temporarily. 704369626Sru% This is canceled by @fixbackslash. 704469626Sru@otherifyactive 704569626Sru 704669626Sru% If a .fmt file is being used, we don't want the `\input texinfo' to show up. 704769626Sru% That is what \eatinput is for; after that, the `\' should revert to printing 704869626Sru% a backslash. 704969626Sru% 705069626Sru@gdef@eatinput input texinfo{@fixbackslash} 705169626Sru@global@let\ = @eatinput 705269626Sru 705369626Sru% On the other hand, perhaps the file did not have a `\input texinfo'. Then 705469626Sru% the first `\{ in the file would cause an error. This macro tries to fix 705569626Sru% that, assuming it is called before the first `\' could plausibly occur. 705669626Sru% Also back turn on active characters that might appear in the input 705769626Sru% file name, in case not using a pre-dumped format. 705869626Sru% 705969626Sru@gdef@fixbackslash{% 706069626Sru @ifx\@eatinput @let\ = @normalbackslash @fi 706169626Sru @catcode`+=@active 706269626Sru @catcode`@_=@active 706369626Sru} 706469626Sru 706569626Sru% Say @foo, not \foo, in error messages. 706669626Sru@escapechar = `@@ 706769626Sru 7068151497Sru% These look ok in all fonts, so just make them not special. 706969626Sru@catcode`@& = @other 707069626Sru@catcode`@# = @other 707169626Sru@catcode`@% = @other 707269626Sru 707369626Sru 707469626Sru@c Local variables: 707569626Sru@c eval: (add-hook 'write-file-hooks 'time-stamp) 707669626Sru@c page-delimiter: "^\\\\message" 707769626Sru@c time-stamp-start: "def\\\\texinfoversion{" 707869626Sru@c time-stamp-format: "%:y-%02m-%02d.%02H" 707969626Sru@c time-stamp-end: "}" 708069626Sru@c End: 7081151497Sru 7082151497Sru@c vim:sw=2: 7083151497Sru 7084151497Sru@ignore 7085151497Sru arch-tag: e1b36e32-c96e-4135-a41a-0b2efa2ea115 7086151497Sru@end ignore 7087