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