1*d5c9a868SElliott Hughes% texinfo.tex -- TeX macros to handle Texinfo files. 2*d5c9a868SElliott Hughes% 3*d5c9a868SElliott Hughes% Load plain if necessary, i.e., if running under initex. 4*d5c9a868SElliott Hughes\expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi 5*d5c9a868SElliott Hughes% 6*d5c9a868SElliott Hughes\def\texinfoversion{2022-01-02.12} 7*d5c9a868SElliott Hughes% 8*d5c9a868SElliott Hughes% Copyright 1985, 1986, 1988, 1990-2021 Free Software Foundation, Inc. 9*d5c9a868SElliott Hughes% 10*d5c9a868SElliott Hughes% This texinfo.tex file is free software: you can redistribute it and/or 11*d5c9a868SElliott Hughes% modify it under the terms of the GNU General Public License as 12*d5c9a868SElliott Hughes% published by the Free Software Foundation, either version 3 of the 13*d5c9a868SElliott Hughes% License, or (at your option) any later version. 14*d5c9a868SElliott Hughes% 15*d5c9a868SElliott Hughes% This texinfo.tex file is distributed in the hope that it will be 16*d5c9a868SElliott Hughes% useful, but WITHOUT ANY WARRANTY; without even the implied warranty 17*d5c9a868SElliott Hughes% of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18*d5c9a868SElliott Hughes% General Public License for more details. 19*d5c9a868SElliott Hughes% 20*d5c9a868SElliott Hughes% You should have received a copy of the GNU General Public License 21*d5c9a868SElliott Hughes% along with this program. If not, see <https://www.gnu.org/licenses/>. 22*d5c9a868SElliott Hughes% 23*d5c9a868SElliott Hughes% As a special exception, when this file is read by TeX when processing 24*d5c9a868SElliott Hughes% a Texinfo source document, you may use the result without 25*d5c9a868SElliott Hughes% restriction. This Exception is an additional permission under section 7 26*d5c9a868SElliott Hughes% of the GNU General Public License, version 3 ("GPLv3"). 27*d5c9a868SElliott Hughes% 28*d5c9a868SElliott Hughes% Please try the latest version of texinfo.tex before submitting bug 29*d5c9a868SElliott Hughes% reports; you can get the latest version from: 30*d5c9a868SElliott Hughes% https://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or 31*d5c9a868SElliott Hughes% https://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or 32*d5c9a868SElliott Hughes% https://www.gnu.org/software/texinfo/ (the Texinfo home page) 33*d5c9a868SElliott Hughes% The texinfo.tex in any given distribution could well be out 34*d5c9a868SElliott Hughes% of date, so if that's what you're using, please check. 35*d5c9a868SElliott Hughes% 36*d5c9a868SElliott Hughes% Send bug reports to [email protected]. Please include a 37*d5c9a868SElliott Hughes% complete document in each bug report with which we can reproduce the 38*d5c9a868SElliott Hughes% problem. Patches are, of course, greatly appreciated. 39*d5c9a868SElliott Hughes% 40*d5c9a868SElliott Hughes% To process a Texinfo manual with TeX, it's most reliable to use the 41*d5c9a868SElliott Hughes% texi2dvi shell script that comes with the distribution. For a simple 42*d5c9a868SElliott Hughes% manual foo.texi, however, you can get away with this: 43*d5c9a868SElliott Hughes% tex foo.texi 44*d5c9a868SElliott Hughes% texindex foo.?? 45*d5c9a868SElliott Hughes% tex foo.texi 46*d5c9a868SElliott Hughes% tex foo.texi 47*d5c9a868SElliott Hughes% dvips foo.dvi -o # or whatever; this makes foo.ps. 48*d5c9a868SElliott Hughes% The extra TeX runs get the cross-reference information correct. 49*d5c9a868SElliott Hughes% Sometimes one run after texindex suffices, and sometimes you need more 50*d5c9a868SElliott Hughes% than two; texi2dvi does it as many times as necessary. 51*d5c9a868SElliott Hughes% 52*d5c9a868SElliott Hughes% It is possible to adapt texinfo.tex for other languages, to some 53*d5c9a868SElliott Hughes% extent. You can get the existing language-specific files from the 54*d5c9a868SElliott Hughes% full Texinfo distribution. 55*d5c9a868SElliott Hughes% 56*d5c9a868SElliott Hughes% The GNU Texinfo home page is https://www.gnu.org/software/texinfo. 57*d5c9a868SElliott Hughes 58*d5c9a868SElliott Hughes 59*d5c9a868SElliott Hughes\message{Loading texinfo [version \texinfoversion]:} 60*d5c9a868SElliott Hughes 61*d5c9a868SElliott Hughes% If in a .fmt file, print the version number 62*d5c9a868SElliott Hughes% and turn on active characters that we couldn't do earlier because 63*d5c9a868SElliott Hughes% they might have appeared in the input file name. 64*d5c9a868SElliott Hughes\everyjob{\message{[Texinfo version \texinfoversion]}% 65*d5c9a868SElliott Hughes \catcode`+=\active \catcode`\_=\active} 66*d5c9a868SElliott Hughes 67*d5c9a868SElliott Hughes% LaTeX's \typeout. This ensures that the messages it is used for 68*d5c9a868SElliott Hughes% are identical in format to the corresponding ones from latex/pdflatex. 69*d5c9a868SElliott Hughes\def\typeout{\immediate\write17}% 70*d5c9a868SElliott Hughes 71*d5c9a868SElliott Hughes\chardef\other=12 72*d5c9a868SElliott Hughes 73*d5c9a868SElliott Hughes% We never want plain's \outer definition of \+ in Texinfo. 74*d5c9a868SElliott Hughes% For @tex, we can use \tabalign. 75*d5c9a868SElliott Hughes\let\+ = \relax 76*d5c9a868SElliott Hughes 77*d5c9a868SElliott Hughes% Save some plain tex macros whose names we will redefine. 78*d5c9a868SElliott Hughes\let\ptexb=\b 79*d5c9a868SElliott Hughes\let\ptexbullet=\bullet 80*d5c9a868SElliott Hughes\let\ptexc=\c 81*d5c9a868SElliott Hughes\let\ptexcomma=\, 82*d5c9a868SElliott Hughes\let\ptexdot=\. 83*d5c9a868SElliott Hughes\let\ptexdots=\dots 84*d5c9a868SElliott Hughes\let\ptexend=\end 85*d5c9a868SElliott Hughes\let\ptexequiv=\equiv 86*d5c9a868SElliott Hughes\let\ptexexclam=\! 87*d5c9a868SElliott Hughes\let\ptexfootnote=\footnote 88*d5c9a868SElliott Hughes\let\ptexgtr=> 89*d5c9a868SElliott Hughes\let\ptexhat=^ 90*d5c9a868SElliott Hughes\let\ptexi=\i 91*d5c9a868SElliott Hughes\let\ptexindent=\indent 92*d5c9a868SElliott Hughes\let\ptexinsert=\insert 93*d5c9a868SElliott Hughes\let\ptexlbrace=\{ 94*d5c9a868SElliott Hughes\let\ptexless=< 95*d5c9a868SElliott Hughes\let\ptexnewwrite\newwrite 96*d5c9a868SElliott Hughes\let\ptexnoindent=\noindent 97*d5c9a868SElliott Hughes\let\ptexplus=+ 98*d5c9a868SElliott Hughes\let\ptexraggedright=\raggedright 99*d5c9a868SElliott Hughes\let\ptexrbrace=\} 100*d5c9a868SElliott Hughes\let\ptexslash=\/ 101*d5c9a868SElliott Hughes\let\ptexsp=\sp 102*d5c9a868SElliott Hughes\let\ptexstar=\* 103*d5c9a868SElliott Hughes\let\ptexsup=\sup 104*d5c9a868SElliott Hughes\let\ptext=\t 105*d5c9a868SElliott Hughes\let\ptextop=\top 106*d5c9a868SElliott Hughes{\catcode`\'=\active \global\let\ptexquoteright'}% active in plain's math mode 107*d5c9a868SElliott Hughes 108*d5c9a868SElliott Hughes% If this character appears in an error message or help string, it 109*d5c9a868SElliott Hughes% starts a new line in the output. 110*d5c9a868SElliott Hughes\newlinechar = `^^J 111*d5c9a868SElliott Hughes 112*d5c9a868SElliott Hughes% Use TeX 3.0's \inputlineno to get the line number, for better error 113*d5c9a868SElliott Hughes% messages, but if we're using an old version of TeX, don't do anything. 114*d5c9a868SElliott Hughes% 115*d5c9a868SElliott Hughes\ifx\inputlineno\thisisundefined 116*d5c9a868SElliott Hughes \let\linenumber = \empty % Pre-3.0. 117*d5c9a868SElliott Hughes\else 118*d5c9a868SElliott Hughes \def\linenumber{l.\the\inputlineno:\space} 119*d5c9a868SElliott Hughes\fi 120*d5c9a868SElliott Hughes 121*d5c9a868SElliott Hughes% Set up fixed words for English if not already set. 122*d5c9a868SElliott Hughes\ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi 123*d5c9a868SElliott Hughes\ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi 124*d5c9a868SElliott Hughes\ifx\putworderror\undefined \gdef\putworderror{error}\fi 125*d5c9a868SElliott Hughes\ifx\putwordfile\undefined \gdef\putwordfile{file}\fi 126*d5c9a868SElliott Hughes\ifx\putwordin\undefined \gdef\putwordin{in}\fi 127*d5c9a868SElliott Hughes\ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi 128*d5c9a868SElliott Hughes\ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi 129*d5c9a868SElliott Hughes\ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi 130*d5c9a868SElliott Hughes\ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi 131*d5c9a868SElliott Hughes\ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi 132*d5c9a868SElliott Hughes\ifx\putwordNoTitle\undefined \gdef\putwordNoTitle{No Title}\fi 133*d5c9a868SElliott Hughes\ifx\putwordof\undefined \gdef\putwordof{of}\fi 134*d5c9a868SElliott Hughes\ifx\putwordon\undefined \gdef\putwordon{on}\fi 135*d5c9a868SElliott Hughes\ifx\putwordpage\undefined \gdef\putwordpage{page}\fi 136*d5c9a868SElliott Hughes\ifx\putwordsection\undefined \gdef\putwordsection{section}\fi 137*d5c9a868SElliott Hughes\ifx\putwordSection\undefined \gdef\putwordSection{Section}\fi 138*d5c9a868SElliott Hughes\ifx\putwordsee\undefined \gdef\putwordsee{see}\fi 139*d5c9a868SElliott Hughes\ifx\putwordSee\undefined \gdef\putwordSee{See}\fi 140*d5c9a868SElliott Hughes\ifx\putwordShortTOC\undefined \gdef\putwordShortTOC{Short Contents}\fi 141*d5c9a868SElliott Hughes\ifx\putwordTOC\undefined \gdef\putwordTOC{Table of Contents}\fi 142*d5c9a868SElliott Hughes% 143*d5c9a868SElliott Hughes\ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi 144*d5c9a868SElliott Hughes\ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi 145*d5c9a868SElliott Hughes\ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi 146*d5c9a868SElliott Hughes\ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi 147*d5c9a868SElliott Hughes\ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi 148*d5c9a868SElliott Hughes\ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi 149*d5c9a868SElliott Hughes\ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi 150*d5c9a868SElliott Hughes\ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi 151*d5c9a868SElliott Hughes\ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi 152*d5c9a868SElliott Hughes\ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi 153*d5c9a868SElliott Hughes\ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi 154*d5c9a868SElliott Hughes\ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi 155*d5c9a868SElliott Hughes% 156*d5c9a868SElliott Hughes\ifx\putwordDefmac\undefined \gdef\putwordDefmac{Macro}\fi 157*d5c9a868SElliott Hughes\ifx\putwordDefspec\undefined \gdef\putwordDefspec{Special Form}\fi 158*d5c9a868SElliott Hughes\ifx\putwordDefvar\undefined \gdef\putwordDefvar{Variable}\fi 159*d5c9a868SElliott Hughes\ifx\putwordDefopt\undefined \gdef\putwordDefopt{User Option}\fi 160*d5c9a868SElliott Hughes\ifx\putwordDeffunc\undefined \gdef\putwordDeffunc{Function}\fi 161*d5c9a868SElliott Hughes 162*d5c9a868SElliott Hughes% Give the space character the catcode for a space. 163*d5c9a868SElliott Hughes\def\spaceisspace{\catcode`\ =10\relax} 164*d5c9a868SElliott Hughes 165*d5c9a868SElliott Hughes% Likewise for ^^M, the end of line character. 166*d5c9a868SElliott Hughes\def\endlineisspace{\catcode13=10\relax} 167*d5c9a868SElliott Hughes 168*d5c9a868SElliott Hughes\chardef\dashChar = `\- 169*d5c9a868SElliott Hughes\chardef\slashChar = `\/ 170*d5c9a868SElliott Hughes\chardef\underChar = `\_ 171*d5c9a868SElliott Hughes 172*d5c9a868SElliott Hughes% Ignore a token. 173*d5c9a868SElliott Hughes% 174*d5c9a868SElliott Hughes\def\gobble#1{} 175*d5c9a868SElliott Hughes 176*d5c9a868SElliott Hughes% The following is used inside several \edef's. 177*d5c9a868SElliott Hughes\def\makecsname#1{\expandafter\noexpand\csname#1\endcsname} 178*d5c9a868SElliott Hughes 179*d5c9a868SElliott Hughes% Hyphenation fixes. 180*d5c9a868SElliott Hughes\hyphenation{ 181*d5c9a868SElliott Hughes Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script 182*d5c9a868SElliott Hughes ap-pen-dix bit-map bit-maps 183*d5c9a868SElliott Hughes data-base data-bases eshell fall-ing half-way long-est man-u-script 184*d5c9a868SElliott Hughes man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm 185*d5c9a868SElliott Hughes par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces 186*d5c9a868SElliott Hughes spell-ing spell-ings 187*d5c9a868SElliott Hughes stand-alone strong-est time-stamp time-stamps which-ever white-space 188*d5c9a868SElliott Hughes wide-spread wrap-around 189*d5c9a868SElliott Hughes} 190*d5c9a868SElliott Hughes 191*d5c9a868SElliott Hughes% Sometimes it is convenient to have everything in the transcript file 192*d5c9a868SElliott Hughes% and nothing on the terminal. We don't just call \tracingall here, 193*d5c9a868SElliott Hughes% since that produces some useless output on the terminal. We also make 194*d5c9a868SElliott Hughes% some effort to order the tracing commands to reduce output in the log 195*d5c9a868SElliott Hughes% file; cf. trace.sty in LaTeX. 196*d5c9a868SElliott Hughes% 197*d5c9a868SElliott Hughes\def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}% 198*d5c9a868SElliott Hughes\def\loggingall{% 199*d5c9a868SElliott Hughes \tracingstats2 200*d5c9a868SElliott Hughes \tracingpages1 201*d5c9a868SElliott Hughes \tracinglostchars2 % 2 gives us more in etex 202*d5c9a868SElliott Hughes \tracingparagraphs1 203*d5c9a868SElliott Hughes \tracingoutput1 204*d5c9a868SElliott Hughes \tracingmacros2 205*d5c9a868SElliott Hughes \tracingrestores1 206*d5c9a868SElliott Hughes \showboxbreadth\maxdimen \showboxdepth\maxdimen 207*d5c9a868SElliott Hughes \ifx\eTeXversion\thisisundefined\else % etex gives us more logging 208*d5c9a868SElliott Hughes \tracingscantokens1 209*d5c9a868SElliott Hughes \tracingifs1 210*d5c9a868SElliott Hughes \tracinggroups1 211*d5c9a868SElliott Hughes \tracingnesting2 212*d5c9a868SElliott Hughes \tracingassigns1 213*d5c9a868SElliott Hughes \fi 214*d5c9a868SElliott Hughes \tracingcommands3 % 3 gives us more in etex 215*d5c9a868SElliott Hughes \errorcontextlines16 216*d5c9a868SElliott Hughes}% 217*d5c9a868SElliott Hughes 218*d5c9a868SElliott Hughes% @errormsg{MSG}. Do the index-like expansions on MSG, but if things 219*d5c9a868SElliott Hughes% aren't perfect, it's not the end of the world, being an error message, 220*d5c9a868SElliott Hughes% after all. 221*d5c9a868SElliott Hughes% 222*d5c9a868SElliott Hughes\def\errormsg{\begingroup \indexnofonts \doerrormsg} 223*d5c9a868SElliott Hughes\def\doerrormsg#1{\errmessage{#1}} 224*d5c9a868SElliott Hughes 225*d5c9a868SElliott Hughes% add check for \lastpenalty to plain's definitions. If the last thing 226*d5c9a868SElliott Hughes% we did was a \nobreak, we don't want to insert more space. 227*d5c9a868SElliott Hughes% 228*d5c9a868SElliott Hughes\def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount 229*d5c9a868SElliott Hughes \removelastskip\penalty-50\smallskip\fi\fi} 230*d5c9a868SElliott Hughes\def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount 231*d5c9a868SElliott Hughes \removelastskip\penalty-100\medskip\fi\fi} 232*d5c9a868SElliott Hughes\def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount 233*d5c9a868SElliott Hughes \removelastskip\penalty-200\bigskip\fi\fi} 234*d5c9a868SElliott Hughes 235*d5c9a868SElliott Hughes% Output routine 236*d5c9a868SElliott Hughes% 237*d5c9a868SElliott Hughes 238*d5c9a868SElliott Hughes% For a final copy, take out the rectangles 239*d5c9a868SElliott Hughes% that mark overfull boxes (in case you have decided 240*d5c9a868SElliott Hughes% that the text looks ok even though it passes the margin). 241*d5c9a868SElliott Hughes% 242*d5c9a868SElliott Hughes\def\finalout{\overfullrule=0pt } 243*d5c9a868SElliott Hughes 244*d5c9a868SElliott Hughes\newdimen\outerhsize \newdimen\outervsize % set by the paper size routines 245*d5c9a868SElliott Hughes\newdimen\topandbottommargin \topandbottommargin=.75in 246*d5c9a868SElliott Hughes 247*d5c9a868SElliott Hughes% Output a mark which sets \thischapter, \thissection and \thiscolor. 248*d5c9a868SElliott Hughes% We dump everything together because we only have one kind of mark. 249*d5c9a868SElliott Hughes% This works because we only use \botmark / \topmark, not \firstmark. 250*d5c9a868SElliott Hughes% 251*d5c9a868SElliott Hughes% A mark contains a subexpression of the \ifcase ... \fi construct. 252*d5c9a868SElliott Hughes% \get*marks macros below extract the needed part using \ifcase. 253*d5c9a868SElliott Hughes% 254*d5c9a868SElliott Hughes% Another complication is to let the user choose whether \thischapter 255*d5c9a868SElliott Hughes% (\thissection) refers to the chapter (section) in effect at the top 256*d5c9a868SElliott Hughes% of a page, or that at the bottom of a page. 257*d5c9a868SElliott Hughes 258*d5c9a868SElliott Hughes% \domark is called twice inside \chapmacro, to add one 259*d5c9a868SElliott Hughes% mark before the section break, and one after. 260*d5c9a868SElliott Hughes% In the second call \prevchapterdefs is the same as \currentchapterdefs, 261*d5c9a868SElliott Hughes% and \prevsectiondefs is the same as \currentsectiondefs. 262*d5c9a868SElliott Hughes% Then if the page is not broken at the mark, some of the previous 263*d5c9a868SElliott Hughes% section appears on the page, and we can get the name of this section 264*d5c9a868SElliott Hughes% from \firstmark for @everyheadingmarks top. 265*d5c9a868SElliott Hughes% @everyheadingmarks bottom uses \botmark. 266*d5c9a868SElliott Hughes% 267*d5c9a868SElliott Hughes% See page 260 of The TeXbook. 268*d5c9a868SElliott Hughes\def\domark{% 269*d5c9a868SElliott Hughes \toks0=\expandafter{\currentchapterdefs}% 270*d5c9a868SElliott Hughes \toks2=\expandafter{\currentsectiondefs}% 271*d5c9a868SElliott Hughes \toks4=\expandafter{\prevchapterdefs}% 272*d5c9a868SElliott Hughes \toks6=\expandafter{\prevsectiondefs}% 273*d5c9a868SElliott Hughes \toks8=\expandafter{\currentcolordefs}% 274*d5c9a868SElliott Hughes \mark{% 275*d5c9a868SElliott Hughes \the\toks0 \the\toks2 % 0: marks for @everyheadingmarks top 276*d5c9a868SElliott Hughes \noexpand\or \the\toks4 \the\toks6 % 1: for @everyheadingmarks bottom 277*d5c9a868SElliott Hughes \noexpand\else \the\toks8 % 2: color marks 278*d5c9a868SElliott Hughes }% 279*d5c9a868SElliott Hughes} 280*d5c9a868SElliott Hughes 281*d5c9a868SElliott Hughes% \gettopheadingmarks, \getbottomheadingmarks, 282*d5c9a868SElliott Hughes% \getcolormarks - extract needed part of mark. 283*d5c9a868SElliott Hughes% 284*d5c9a868SElliott Hughes% \topmark doesn't work for the very first chapter (after the title 285*d5c9a868SElliott Hughes% page or the contents), so we use \firstmark there -- this gets us 286*d5c9a868SElliott Hughes% the mark with the chapter defs, unless the user sneaks in, e.g., 287*d5c9a868SElliott Hughes% @setcolor (or @url, or @link, etc.) between @contents and the very 288*d5c9a868SElliott Hughes% first @chapter. 289*d5c9a868SElliott Hughes\def\gettopheadingmarks{% 290*d5c9a868SElliott Hughes \ifcase0\the\savedtopmark\fi 291*d5c9a868SElliott Hughes \ifx\thischapter\empty \ifcase0\firstmark\fi \fi 292*d5c9a868SElliott Hughes} 293*d5c9a868SElliott Hughes\def\getbottomheadingmarks{\ifcase1\botmark\fi} 294*d5c9a868SElliott Hughes\def\getcolormarks{\ifcase2\the\savedtopmark\fi} 295*d5c9a868SElliott Hughes 296*d5c9a868SElliott Hughes% Avoid "undefined control sequence" errors. 297*d5c9a868SElliott Hughes\def\currentchapterdefs{} 298*d5c9a868SElliott Hughes\def\currentsectiondefs{} 299*d5c9a868SElliott Hughes\def\currentsection{} 300*d5c9a868SElliott Hughes\def\prevchapterdefs{} 301*d5c9a868SElliott Hughes\def\prevsectiondefs{} 302*d5c9a868SElliott Hughes\def\currentcolordefs{} 303*d5c9a868SElliott Hughes 304*d5c9a868SElliott Hughes% Margin to add to right of even pages, to left of odd pages. 305*d5c9a868SElliott Hughes\newdimen\bindingoffset 306*d5c9a868SElliott Hughes\newdimen\normaloffset 307*d5c9a868SElliott Hughes\newdimen\txipagewidth \newdimen\txipageheight 308*d5c9a868SElliott Hughes 309*d5c9a868SElliott Hughes% Main output routine. 310*d5c9a868SElliott Hughes% 311*d5c9a868SElliott Hughes\chardef\PAGE = 255 312*d5c9a868SElliott Hughes\newtoks\defaultoutput 313*d5c9a868SElliott Hughes\defaultoutput = {\savetopmark\onepageout{\pagecontents\PAGE}} 314*d5c9a868SElliott Hughes\output=\expandafter{\the\defaultoutput} 315*d5c9a868SElliott Hughes 316*d5c9a868SElliott Hughes\newbox\headlinebox 317*d5c9a868SElliott Hughes\newbox\footlinebox 318*d5c9a868SElliott Hughes 319*d5c9a868SElliott Hughes% When outputting the double column layout for indices, an output routine 320*d5c9a868SElliott Hughes% is run several times, which hides the original value of \topmark. This 321*d5c9a868SElliott Hughes% can lead to a page heading being output and duplicating the chapter heading 322*d5c9a868SElliott Hughes% of the index. Hence, save the contents of \topmark at the beginning of 323*d5c9a868SElliott Hughes% the output routine. The saved contents are valid until we actually 324*d5c9a868SElliott Hughes% \shipout a page. 325*d5c9a868SElliott Hughes% 326*d5c9a868SElliott Hughes% (We used to run a short output routine to actually set \topmark and 327*d5c9a868SElliott Hughes% \firstmark to the right values, but if this was called with an empty page 328*d5c9a868SElliott Hughes% containing whatsits for writing index entries, the whatsits would be thrown 329*d5c9a868SElliott Hughes% away and the index auxiliary file would remain empty.) 330*d5c9a868SElliott Hughes% 331*d5c9a868SElliott Hughes\newtoks\savedtopmark 332*d5c9a868SElliott Hughes\newif\iftopmarksaved 333*d5c9a868SElliott Hughes\topmarksavedtrue 334*d5c9a868SElliott Hughes\def\savetopmark{% 335*d5c9a868SElliott Hughes \iftopmarksaved\else 336*d5c9a868SElliott Hughes \global\savedtopmark=\expandafter{\topmark}% 337*d5c9a868SElliott Hughes \global\topmarksavedtrue 338*d5c9a868SElliott Hughes \fi 339*d5c9a868SElliott Hughes} 340*d5c9a868SElliott Hughes 341*d5c9a868SElliott Hughes% \onepageout takes a vbox as an argument. 342*d5c9a868SElliott Hughes% \shipout a vbox for a single page, adding an optional header, footer 343*d5c9a868SElliott Hughes% and footnote. This also causes index entries for this page to be written 344*d5c9a868SElliott Hughes% to the auxiliary files. 345*d5c9a868SElliott Hughes% 346*d5c9a868SElliott Hughes\def\onepageout#1{% 347*d5c9a868SElliott Hughes \hoffset=\normaloffset 348*d5c9a868SElliott Hughes % 349*d5c9a868SElliott Hughes \ifodd\pageno \advance\hoffset by \bindingoffset 350*d5c9a868SElliott Hughes \else \advance\hoffset by -\bindingoffset\fi 351*d5c9a868SElliott Hughes % 352*d5c9a868SElliott Hughes \checkchapterpage 353*d5c9a868SElliott Hughes % 354*d5c9a868SElliott Hughes % Retrieve the information for the headings from the marks in the page, 355*d5c9a868SElliott Hughes % and call Plain TeX's \makeheadline and \makefootline, which use the 356*d5c9a868SElliott Hughes % values in \headline and \footline. 357*d5c9a868SElliott Hughes % 358*d5c9a868SElliott Hughes % Common context changes for both heading and footing. 359*d5c9a868SElliott Hughes % Do this outside of the \shipout so @code etc. will be expanded in 360*d5c9a868SElliott Hughes % the headline as they should be, not taken literally (outputting ''code). 361*d5c9a868SElliott Hughes \def\commonheadfootline{\let\hsize=\txipagewidth \texinfochars} 362*d5c9a868SElliott Hughes % 363*d5c9a868SElliott Hughes \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi 364*d5c9a868SElliott Hughes \global\setbox\headlinebox = \vbox{\commonheadfootline \makeheadline}% 365*d5c9a868SElliott Hughes \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi 366*d5c9a868SElliott Hughes \global\setbox\footlinebox = \vbox{\commonheadfootline \makefootline}% 367*d5c9a868SElliott Hughes % 368*d5c9a868SElliott Hughes {% 369*d5c9a868SElliott Hughes % Set context for writing to auxiliary files like index files. 370*d5c9a868SElliott Hughes % Have to do this stuff outside the \shipout because we want it to 371*d5c9a868SElliott Hughes % take effect in \write's, yet the group defined by the \vbox ends 372*d5c9a868SElliott Hughes % before the \shipout runs. 373*d5c9a868SElliott Hughes % 374*d5c9a868SElliott Hughes \atdummies % don't expand commands in the output. 375*d5c9a868SElliott Hughes \turnoffactive 376*d5c9a868SElliott Hughes \shipout\vbox{% 377*d5c9a868SElliott Hughes % Do this early so pdf references go to the beginning of the page. 378*d5c9a868SElliott Hughes \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi 379*d5c9a868SElliott Hughes % 380*d5c9a868SElliott Hughes \unvbox\headlinebox 381*d5c9a868SElliott Hughes \pagebody{#1}% 382*d5c9a868SElliott Hughes \ifdim\ht\footlinebox > 0pt 383*d5c9a868SElliott Hughes % Only leave this space if the footline is nonempty. 384*d5c9a868SElliott Hughes % (We lessened \vsize for it in \oddfootingyyy.) 385*d5c9a868SElliott Hughes % The \baselineskip=24pt in plain's \makefootline has no effect. 386*d5c9a868SElliott Hughes \vskip 24pt 387*d5c9a868SElliott Hughes \unvbox\footlinebox 388*d5c9a868SElliott Hughes \fi 389*d5c9a868SElliott Hughes % 390*d5c9a868SElliott Hughes }% 391*d5c9a868SElliott Hughes }% 392*d5c9a868SElliott Hughes \global\topmarksavedfalse 393*d5c9a868SElliott Hughes \advancepageno 394*d5c9a868SElliott Hughes \ifnum\outputpenalty>-20000 \else\dosupereject\fi 395*d5c9a868SElliott Hughes} 396*d5c9a868SElliott Hughes 397*d5c9a868SElliott Hughes\newinsert\margin \dimen\margin=\maxdimen 398*d5c9a868SElliott Hughes 399*d5c9a868SElliott Hughes% Main part of page, including any footnotes 400*d5c9a868SElliott Hughes\def\pagebody#1{\vbox to\txipageheight{\boxmaxdepth=\maxdepth #1}} 401*d5c9a868SElliott Hughes{\catcode`\@ =11 402*d5c9a868SElliott Hughes\gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi 403*d5c9a868SElliott Hughes% marginal hacks, [email protected] (Juha Takala) 404*d5c9a868SElliott Hughes\ifvoid\margin\else % marginal info is present 405*d5c9a868SElliott Hughes \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi 406*d5c9a868SElliott Hughes\dimen@=\dp#1\relax \unvbox#1\relax 407*d5c9a868SElliott Hughes\ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi 408*d5c9a868SElliott Hughes\ifr@ggedbottom \kern-\dimen@ \vfil \fi} 409*d5c9a868SElliott Hughes} 410*d5c9a868SElliott Hughes 411*d5c9a868SElliott Hughes% Check if we are on the first page of a chapter. Used for printing headings. 412*d5c9a868SElliott Hughes\newif\ifchapterpage 413*d5c9a868SElliott Hughes\def\checkchapterpage{% 414*d5c9a868SElliott Hughes % Get the chapter that was current at the end of the last page 415*d5c9a868SElliott Hughes \ifcase1\the\savedtopmark\fi 416*d5c9a868SElliott Hughes \let\prevchaptername\thischaptername 417*d5c9a868SElliott Hughes % 418*d5c9a868SElliott Hughes \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi 419*d5c9a868SElliott Hughes \let\curchaptername\thischaptername 420*d5c9a868SElliott Hughes % 421*d5c9a868SElliott Hughes \ifx\curchaptername\prevchaptername 422*d5c9a868SElliott Hughes \chapterpagefalse 423*d5c9a868SElliott Hughes \else 424*d5c9a868SElliott Hughes \chapterpagetrue 425*d5c9a868SElliott Hughes \fi 426*d5c9a868SElliott Hughes} 427*d5c9a868SElliott Hughes 428*d5c9a868SElliott Hughes% Argument parsing 429*d5c9a868SElliott Hughes 430*d5c9a868SElliott Hughes% Parse an argument, then pass it to #1. The argument is the rest of 431*d5c9a868SElliott Hughes% the input line (except we remove a trailing comment). #1 should be a 432*d5c9a868SElliott Hughes% macro which expects an ordinary undelimited TeX argument. 433*d5c9a868SElliott Hughes% For example, \def\foo{\parsearg\fooxxx}. 434*d5c9a868SElliott Hughes% 435*d5c9a868SElliott Hughes\def\parsearg{\parseargusing{}} 436*d5c9a868SElliott Hughes\def\parseargusing#1#2{% 437*d5c9a868SElliott Hughes \def\argtorun{#2}% 438*d5c9a868SElliott Hughes \begingroup 439*d5c9a868SElliott Hughes \obeylines 440*d5c9a868SElliott Hughes \spaceisspace 441*d5c9a868SElliott Hughes #1% 442*d5c9a868SElliott Hughes \parseargline\empty% Insert the \empty token, see \finishparsearg below. 443*d5c9a868SElliott Hughes} 444*d5c9a868SElliott Hughes 445*d5c9a868SElliott Hughes{\obeylines % 446*d5c9a868SElliott Hughes \gdef\parseargline#1^^M{% 447*d5c9a868SElliott Hughes \endgroup % End of the group started in \parsearg. 448*d5c9a868SElliott Hughes \argremovecomment #1\comment\ArgTerm% 449*d5c9a868SElliott Hughes }% 450*d5c9a868SElliott Hughes} 451*d5c9a868SElliott Hughes 452*d5c9a868SElliott Hughes% First remove any @comment, then any @c comment. Pass the result on to 453*d5c9a868SElliott Hughes% \argcheckspaces. 454*d5c9a868SElliott Hughes\def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm} 455*d5c9a868SElliott Hughes\def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm} 456*d5c9a868SElliott Hughes 457*d5c9a868SElliott Hughes% Each occurrence of `\^^M' or `<space>\^^M' is replaced by a single space. 458*d5c9a868SElliott Hughes% 459*d5c9a868SElliott Hughes% \argremovec might leave us with trailing space, e.g., 460*d5c9a868SElliott Hughes% @end itemize @c foo 461*d5c9a868SElliott Hughes% This space token undergoes the same procedure and is eventually removed 462*d5c9a868SElliott Hughes% by \finishparsearg. 463*d5c9a868SElliott Hughes% 464*d5c9a868SElliott Hughes\def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M} 465*d5c9a868SElliott Hughes\def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M} 466*d5c9a868SElliott Hughes\def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{% 467*d5c9a868SElliott Hughes \def\temp{#3}% 468*d5c9a868SElliott Hughes \ifx\temp\empty 469*d5c9a868SElliott Hughes % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp: 470*d5c9a868SElliott Hughes \let\temp\finishparsearg 471*d5c9a868SElliott Hughes \else 472*d5c9a868SElliott Hughes \let\temp\argcheckspaces 473*d5c9a868SElliott Hughes \fi 474*d5c9a868SElliott Hughes % Put the space token in: 475*d5c9a868SElliott Hughes \temp#1 #3\ArgTerm 476*d5c9a868SElliott Hughes} 477*d5c9a868SElliott Hughes 478*d5c9a868SElliott Hughes% If a _delimited_ argument is enclosed in braces, they get stripped; so 479*d5c9a868SElliott Hughes% to get _exactly_ the rest of the line, we had to prevent such situation. 480*d5c9a868SElliott Hughes% We prepended an \empty token at the very beginning and we expand it now, 481*d5c9a868SElliott Hughes% just before passing the control to \argtorun. 482*d5c9a868SElliott Hughes% (Similarly, we have to think about #3 of \argcheckspacesY above: it is 483*d5c9a868SElliott Hughes% either the null string, or it ends with \^^M---thus there is no danger 484*d5c9a868SElliott Hughes% that a pair of braces would be stripped. 485*d5c9a868SElliott Hughes% 486*d5c9a868SElliott Hughes% But first, we have to remove the trailing space token. 487*d5c9a868SElliott Hughes% 488*d5c9a868SElliott Hughes\def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}} 489*d5c9a868SElliott Hughes 490*d5c9a868SElliott Hughes 491*d5c9a868SElliott Hughes% \parseargdef - define a command taking an argument on the line 492*d5c9a868SElliott Hughes% 493*d5c9a868SElliott Hughes% \parseargdef\foo{...} 494*d5c9a868SElliott Hughes% is roughly equivalent to 495*d5c9a868SElliott Hughes% \def\foo{\parsearg\Xfoo} 496*d5c9a868SElliott Hughes% \def\Xfoo#1{...} 497*d5c9a868SElliott Hughes\def\parseargdef#1{% 498*d5c9a868SElliott Hughes \expandafter \doparseargdef \csname\string#1\endcsname #1% 499*d5c9a868SElliott Hughes} 500*d5c9a868SElliott Hughes\def\doparseargdef#1#2{% 501*d5c9a868SElliott Hughes \def#2{\parsearg#1}% 502*d5c9a868SElliott Hughes \def#1##1% 503*d5c9a868SElliott Hughes} 504*d5c9a868SElliott Hughes 505*d5c9a868SElliott Hughes% Several utility definitions with active space: 506*d5c9a868SElliott Hughes{ 507*d5c9a868SElliott Hughes \obeyspaces 508*d5c9a868SElliott Hughes \gdef\obeyedspace{ } 509*d5c9a868SElliott Hughes 510*d5c9a868SElliott Hughes % Make each space character in the input produce a normal interword 511*d5c9a868SElliott Hughes % space in the output. Don't allow a line break at this space, as this 512*d5c9a868SElliott Hughes % is used only in environments like @example, where each line of input 513*d5c9a868SElliott Hughes % should produce a line of output anyway. 514*d5c9a868SElliott Hughes % 515*d5c9a868SElliott Hughes \gdef\sepspaces{\obeyspaces\let =\tie} 516*d5c9a868SElliott Hughes 517*d5c9a868SElliott Hughes % If an index command is used in an @example environment, any spaces 518*d5c9a868SElliott Hughes % therein should become regular spaces in the raw index file, not the 519*d5c9a868SElliott Hughes % expansion of \tie (\leavevmode \penalty \@M \ ). 520*d5c9a868SElliott Hughes \gdef\unsepspaces{\let =\space} 521*d5c9a868SElliott Hughes} 522*d5c9a868SElliott Hughes 523*d5c9a868SElliott Hughes 524*d5c9a868SElliott Hughes\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next} 525*d5c9a868SElliott Hughes 526*d5c9a868SElliott Hughes% Define the framework for environments in texinfo.tex. It's used like this: 527*d5c9a868SElliott Hughes% 528*d5c9a868SElliott Hughes% \envdef\foo{...} 529*d5c9a868SElliott Hughes% \def\Efoo{...} 530*d5c9a868SElliott Hughes% 531*d5c9a868SElliott Hughes% It's the responsibility of \envdef to insert \begingroup before the 532*d5c9a868SElliott Hughes% actual body; @end closes the group after calling \Efoo. \envdef also 533*d5c9a868SElliott Hughes% defines \thisenv, so the current environment is known; @end checks 534*d5c9a868SElliott Hughes% whether the environment name matches. The \checkenv macro can also be 535*d5c9a868SElliott Hughes% used to check whether the current environment is the one expected. 536*d5c9a868SElliott Hughes% 537*d5c9a868SElliott Hughes% Non-false conditionals (@iftex, @ifset) don't fit into this, so they 538*d5c9a868SElliott Hughes% are not treated as environments; they don't open a group. (The 539*d5c9a868SElliott Hughes% implementation of @end takes care not to call \endgroup in this 540*d5c9a868SElliott Hughes% special case.) 541*d5c9a868SElliott Hughes 542*d5c9a868SElliott Hughes 543*d5c9a868SElliott Hughes% At run-time, environments start with this: 544*d5c9a868SElliott Hughes\def\startenvironment#1{\begingroup\def\thisenv{#1}} 545*d5c9a868SElliott Hughes% initialize 546*d5c9a868SElliott Hughes\let\thisenv\empty 547*d5c9a868SElliott Hughes 548*d5c9a868SElliott Hughes% ... but they get defined via ``\envdef\foo{...}'': 549*d5c9a868SElliott Hughes\long\def\envdef#1#2{\def#1{\startenvironment#1#2}} 550*d5c9a868SElliott Hughes\def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}} 551*d5c9a868SElliott Hughes 552*d5c9a868SElliott Hughes% Check whether we're in the right environment: 553*d5c9a868SElliott Hughes\def\checkenv#1{% 554*d5c9a868SElliott Hughes \def\temp{#1}% 555*d5c9a868SElliott Hughes \ifx\thisenv\temp 556*d5c9a868SElliott Hughes \else 557*d5c9a868SElliott Hughes \badenverr 558*d5c9a868SElliott Hughes \fi 559*d5c9a868SElliott Hughes} 560*d5c9a868SElliott Hughes 561*d5c9a868SElliott Hughes% Environment mismatch, #1 expected: 562*d5c9a868SElliott Hughes\def\badenverr{% 563*d5c9a868SElliott Hughes \errhelp = \EMsimple 564*d5c9a868SElliott Hughes \errmessage{This command can appear only \inenvironment\temp, 565*d5c9a868SElliott Hughes not \inenvironment\thisenv}% 566*d5c9a868SElliott Hughes} 567*d5c9a868SElliott Hughes\def\inenvironment#1{% 568*d5c9a868SElliott Hughes \ifx#1\empty 569*d5c9a868SElliott Hughes outside of any environment% 570*d5c9a868SElliott Hughes \else 571*d5c9a868SElliott Hughes in environment \expandafter\string#1% 572*d5c9a868SElliott Hughes \fi 573*d5c9a868SElliott Hughes} 574*d5c9a868SElliott Hughes 575*d5c9a868SElliott Hughes 576*d5c9a868SElliott Hughes% @end foo calls \checkenv and executes the definition of \Efoo. 577*d5c9a868SElliott Hughes\parseargdef\end{% 578*d5c9a868SElliott Hughes \if 1\csname iscond.#1\endcsname 579*d5c9a868SElliott Hughes \else 580*d5c9a868SElliott Hughes % The general wording of \badenverr may not be ideal. 581*d5c9a868SElliott Hughes \expandafter\checkenv\csname#1\endcsname 582*d5c9a868SElliott Hughes \csname E#1\endcsname 583*d5c9a868SElliott Hughes \endgroup 584*d5c9a868SElliott Hughes \fi 585*d5c9a868SElliott Hughes} 586*d5c9a868SElliott Hughes 587*d5c9a868SElliott Hughes\newhelp\EMsimple{Press RETURN to continue.} 588*d5c9a868SElliott Hughes 589*d5c9a868SElliott Hughes 590*d5c9a868SElliott Hughes% Be sure we're in horizontal mode when doing a tie, since we make space 591*d5c9a868SElliott Hughes% equivalent to this in @example-like environments. Otherwise, a space 592*d5c9a868SElliott Hughes% at the beginning of a line will start with \penalty -- and 593*d5c9a868SElliott Hughes% since \penalty is valid in vertical mode, we'd end up putting the 594*d5c9a868SElliott Hughes% penalty on the vertical list instead of in the new paragraph. 595*d5c9a868SElliott Hughes{\catcode`@ = 11 596*d5c9a868SElliott Hughes % Avoid using \@M directly, because that causes trouble 597*d5c9a868SElliott Hughes % if the definition is written into an index file. 598*d5c9a868SElliott Hughes \global\let\tiepenalty = \@M 599*d5c9a868SElliott Hughes \gdef\tie{\leavevmode\penalty\tiepenalty\ } 600*d5c9a868SElliott Hughes} 601*d5c9a868SElliott Hughes 602*d5c9a868SElliott Hughes% @: forces normal size whitespace following. 603*d5c9a868SElliott Hughes\def\:{\spacefactor=1000 } 604*d5c9a868SElliott Hughes 605*d5c9a868SElliott Hughes% @* forces a line break. 606*d5c9a868SElliott Hughes\def\*{\unskip\hfil\break\hbox{}\ignorespaces} 607*d5c9a868SElliott Hughes 608*d5c9a868SElliott Hughes% @/ allows a line break. 609*d5c9a868SElliott Hughes\let\/=\allowbreak 610*d5c9a868SElliott Hughes 611*d5c9a868SElliott Hughes% @. is an end-of-sentence period. 612*d5c9a868SElliott Hughes\def\.{.\spacefactor=\endofsentencespacefactor\space} 613*d5c9a868SElliott Hughes 614*d5c9a868SElliott Hughes% @! is an end-of-sentence bang. 615*d5c9a868SElliott Hughes\def\!{!\spacefactor=\endofsentencespacefactor\space} 616*d5c9a868SElliott Hughes 617*d5c9a868SElliott Hughes% @? is an end-of-sentence query. 618*d5c9a868SElliott Hughes\def\?{?\spacefactor=\endofsentencespacefactor\space} 619*d5c9a868SElliott Hughes 620*d5c9a868SElliott Hughes% @frenchspacing on|off says whether to put extra space after punctuation. 621*d5c9a868SElliott Hughes% 622*d5c9a868SElliott Hughes\def\onword{on} 623*d5c9a868SElliott Hughes\def\offword{off} 624*d5c9a868SElliott Hughes% 625*d5c9a868SElliott Hughes\parseargdef\frenchspacing{% 626*d5c9a868SElliott Hughes \def\temp{#1}% 627*d5c9a868SElliott Hughes \ifx\temp\onword \plainfrenchspacing 628*d5c9a868SElliott Hughes \else\ifx\temp\offword \plainnonfrenchspacing 629*d5c9a868SElliott Hughes \else 630*d5c9a868SElliott Hughes \errhelp = \EMsimple 631*d5c9a868SElliott Hughes \errmessage{Unknown @frenchspacing option `\temp', must be on|off}% 632*d5c9a868SElliott Hughes \fi\fi 633*d5c9a868SElliott Hughes} 634*d5c9a868SElliott Hughes 635*d5c9a868SElliott Hughes% @w prevents a word break. Without the \leavevmode, @w at the 636*d5c9a868SElliott Hughes% beginning of a paragraph, when TeX is still in vertical mode, would 637*d5c9a868SElliott Hughes% produce a whole line of output instead of starting the paragraph. 638*d5c9a868SElliott Hughes\def\w#1{\leavevmode\hbox{#1}} 639*d5c9a868SElliott Hughes 640*d5c9a868SElliott Hughes% @group ... @end group forces ... to be all on one page, by enclosing 641*d5c9a868SElliott Hughes% it in a TeX vbox. We use \vtop instead of \vbox to construct the box 642*d5c9a868SElliott Hughes% to keep its height that of a normal line. According to the rules for 643*d5c9a868SElliott Hughes% \topskip (p.114 of the TeXbook), the glue inserted is 644*d5c9a868SElliott Hughes% max (\topskip - \ht (first item), 0). If that height is large, 645*d5c9a868SElliott Hughes% therefore, no glue is inserted, and the space between the headline and 646*d5c9a868SElliott Hughes% the text is small, which looks bad. 647*d5c9a868SElliott Hughes% 648*d5c9a868SElliott Hughes% Another complication is that the group might be very large. This can 649*d5c9a868SElliott Hughes% cause the glue on the previous page to be unduly stretched, because it 650*d5c9a868SElliott Hughes% does not have much material. In this case, it's better to add an 651*d5c9a868SElliott Hughes% explicit \vfill so that the extra space is at the bottom. The 652*d5c9a868SElliott Hughes% threshold for doing this is if the group is more than \vfilllimit 653*d5c9a868SElliott Hughes% percent of a page (\vfilllimit can be changed inside of @tex). 654*d5c9a868SElliott Hughes% 655*d5c9a868SElliott Hughes\newbox\groupbox 656*d5c9a868SElliott Hughes\def\vfilllimit{0.7} 657*d5c9a868SElliott Hughes% 658*d5c9a868SElliott Hughes\envdef\group{% 659*d5c9a868SElliott Hughes \ifnum\catcode`\^^M=\active \else 660*d5c9a868SElliott Hughes \errhelp = \groupinvalidhelp 661*d5c9a868SElliott Hughes \errmessage{@group invalid in context where filling is enabled}% 662*d5c9a868SElliott Hughes \fi 663*d5c9a868SElliott Hughes \startsavinginserts 664*d5c9a868SElliott Hughes % 665*d5c9a868SElliott Hughes \setbox\groupbox = \vtop\bgroup 666*d5c9a868SElliott Hughes % Do @comment since we are called inside an environment such as 667*d5c9a868SElliott Hughes % @example, where each end-of-line in the input causes an 668*d5c9a868SElliott Hughes % end-of-line in the output. We don't want the end-of-line after 669*d5c9a868SElliott Hughes % the `@group' to put extra space in the output. Since @group 670*d5c9a868SElliott Hughes % should appear on a line by itself (according to the Texinfo 671*d5c9a868SElliott Hughes % manual), we don't worry about eating any user text. 672*d5c9a868SElliott Hughes \comment 673*d5c9a868SElliott Hughes} 674*d5c9a868SElliott Hughes% 675*d5c9a868SElliott Hughes% The \vtop produces a box with normal height and large depth; thus, TeX puts 676*d5c9a868SElliott Hughes% \baselineskip glue before it, and (when the next line of text is done) 677*d5c9a868SElliott Hughes% \lineskip glue after it. Thus, space below is not quite equal to space 678*d5c9a868SElliott Hughes% above. But it's pretty close. 679*d5c9a868SElliott Hughes\def\Egroup{% 680*d5c9a868SElliott Hughes % To get correct interline space between the last line of the group 681*d5c9a868SElliott Hughes % and the first line afterwards, we have to propagate \prevdepth. 682*d5c9a868SElliott Hughes \endgraf % Not \par, as it may have been set to \lisppar. 683*d5c9a868SElliott Hughes \global\dimen1 = \prevdepth 684*d5c9a868SElliott Hughes \egroup % End the \vtop. 685*d5c9a868SElliott Hughes \addgroupbox 686*d5c9a868SElliott Hughes \prevdepth = \dimen1 687*d5c9a868SElliott Hughes \checkinserts 688*d5c9a868SElliott Hughes} 689*d5c9a868SElliott Hughes 690*d5c9a868SElliott Hughes\def\addgroupbox{ 691*d5c9a868SElliott Hughes % \dimen0 is the vertical size of the group's box. 692*d5c9a868SElliott Hughes \dimen0 = \ht\groupbox \advance\dimen0 by \dp\groupbox 693*d5c9a868SElliott Hughes % \dimen2 is how much space is left on the page (more or less). 694*d5c9a868SElliott Hughes \dimen2 = \txipageheight \advance\dimen2 by -\pagetotal 695*d5c9a868SElliott Hughes % if the group doesn't fit on the current page, and it's a big big 696*d5c9a868SElliott Hughes % group, force a page break. 697*d5c9a868SElliott Hughes \ifdim \dimen0 > \dimen2 698*d5c9a868SElliott Hughes \ifdim \pagetotal < \vfilllimit\txipageheight 699*d5c9a868SElliott Hughes \page 700*d5c9a868SElliott Hughes \fi 701*d5c9a868SElliott Hughes \fi 702*d5c9a868SElliott Hughes \box\groupbox 703*d5c9a868SElliott Hughes} 704*d5c9a868SElliott Hughes 705*d5c9a868SElliott Hughes% 706*d5c9a868SElliott Hughes% TeX puts in an \escapechar (i.e., `@') at the beginning of the help 707*d5c9a868SElliott Hughes% message, so this ends up printing `@group can only ...'. 708*d5c9a868SElliott Hughes% 709*d5c9a868SElliott Hughes\newhelp\groupinvalidhelp{% 710*d5c9a868SElliott Hughesgroup can only be used in environments such as @example,^^J% 711*d5c9a868SElliott Hugheswhere each line of input produces a line of output.} 712*d5c9a868SElliott Hughes 713*d5c9a868SElliott Hughes% @need space-in-mils 714*d5c9a868SElliott Hughes% forces a page break if there is not space-in-mils remaining. 715*d5c9a868SElliott Hughes 716*d5c9a868SElliott Hughes\newdimen\mil \mil=0.001in 717*d5c9a868SElliott Hughes 718*d5c9a868SElliott Hughes\parseargdef\need{% 719*d5c9a868SElliott Hughes % Ensure vertical mode, so we don't make a big box in the middle of a 720*d5c9a868SElliott Hughes % paragraph. 721*d5c9a868SElliott Hughes \par 722*d5c9a868SElliott Hughes % 723*d5c9a868SElliott Hughes % If the @need value is less than one line space, it's useless. 724*d5c9a868SElliott Hughes \dimen0 = #1\mil 725*d5c9a868SElliott Hughes \dimen2 = \ht\strutbox 726*d5c9a868SElliott Hughes \advance\dimen2 by \dp\strutbox 727*d5c9a868SElliott Hughes \ifdim\dimen0 > \dimen2 728*d5c9a868SElliott Hughes % 729*d5c9a868SElliott Hughes % Do a \strut just to make the height of this box be normal, so the 730*d5c9a868SElliott Hughes % normal leading is inserted relative to the preceding line. 731*d5c9a868SElliott Hughes % And a page break here is fine. 732*d5c9a868SElliott Hughes \vtop to #1\mil{\strut\vfil}% 733*d5c9a868SElliott Hughes % 734*d5c9a868SElliott Hughes % TeX does not even consider page breaks if a penalty added to the 735*d5c9a868SElliott Hughes % main vertical list is 10000 or more. But in order to see if the 736*d5c9a868SElliott Hughes % empty box we just added fits on the page, we must make it consider 737*d5c9a868SElliott Hughes % page breaks. On the other hand, we don't want to actually break the 738*d5c9a868SElliott Hughes % page after the empty box. So we use a penalty of 9999. 739*d5c9a868SElliott Hughes % 740*d5c9a868SElliott Hughes % There is an extremely small chance that TeX will actually break the 741*d5c9a868SElliott Hughes % page at this \penalty, if there are no other feasible breakpoints in 742*d5c9a868SElliott Hughes % sight. (If the user is using lots of big @group commands, which 743*d5c9a868SElliott Hughes % almost-but-not-quite fill up a page, TeX will have a hard time doing 744*d5c9a868SElliott Hughes % good page breaking, for example.) However, I could not construct an 745*d5c9a868SElliott Hughes % example where a page broke at this \penalty; if it happens in a real 746*d5c9a868SElliott Hughes % document, then we can reconsider our strategy. 747*d5c9a868SElliott Hughes \penalty9999 748*d5c9a868SElliott Hughes % 749*d5c9a868SElliott Hughes % Back up by the size of the box, whether we did a page break or not. 750*d5c9a868SElliott Hughes \kern -#1\mil 751*d5c9a868SElliott Hughes % 752*d5c9a868SElliott Hughes % Do not allow a page break right after this kern. 753*d5c9a868SElliott Hughes \nobreak 754*d5c9a868SElliott Hughes \fi 755*d5c9a868SElliott Hughes} 756*d5c9a868SElliott Hughes 757*d5c9a868SElliott Hughes% @br forces paragraph break (and is undocumented). 758*d5c9a868SElliott Hughes 759*d5c9a868SElliott Hughes\let\br = \par 760*d5c9a868SElliott Hughes 761*d5c9a868SElliott Hughes% @page forces the start of a new page. 762*d5c9a868SElliott Hughes% 763*d5c9a868SElliott Hughes\def\page{\par\vfill\supereject} 764*d5c9a868SElliott Hughes 765*d5c9a868SElliott Hughes% @exdent text.... 766*d5c9a868SElliott Hughes% outputs text on separate line in roman font, starting at standard page margin 767*d5c9a868SElliott Hughes 768*d5c9a868SElliott Hughes% This records the amount of indent in the innermost environment. 769*d5c9a868SElliott Hughes% That's how much \exdent should take out. 770*d5c9a868SElliott Hughes\newskip\exdentamount 771*d5c9a868SElliott Hughes 772*d5c9a868SElliott Hughes% This defn is used inside fill environments such as @defun. 773*d5c9a868SElliott Hughes\parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break} 774*d5c9a868SElliott Hughes 775*d5c9a868SElliott Hughes% This defn is used inside nofill environments such as @example. 776*d5c9a868SElliott Hughes\parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount 777*d5c9a868SElliott Hughes \leftline{\hskip\leftskip{\rm#1}}}} 778*d5c9a868SElliott Hughes 779*d5c9a868SElliott Hughes% @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current 780*d5c9a868SElliott Hughes% paragraph. For more general purposes, use the \margin insertion 781*d5c9a868SElliott Hughes% class. WHICH is `l' or `r'. Not documented, written for gawk manual. 782*d5c9a868SElliott Hughes% 783*d5c9a868SElliott Hughes\newskip\inmarginspacing \inmarginspacing=1cm 784*d5c9a868SElliott Hughes\def\strutdepth{\dp\strutbox} 785*d5c9a868SElliott Hughes% 786*d5c9a868SElliott Hughes\def\doinmargin#1#2{\strut\vadjust{% 787*d5c9a868SElliott Hughes \nobreak 788*d5c9a868SElliott Hughes \kern-\strutdepth 789*d5c9a868SElliott Hughes \vtop to \strutdepth{% 790*d5c9a868SElliott Hughes \baselineskip=\strutdepth 791*d5c9a868SElliott Hughes \vss 792*d5c9a868SElliott Hughes % if you have multiple lines of stuff to put here, you'll need to 793*d5c9a868SElliott Hughes % make the vbox yourself of the appropriate size. 794*d5c9a868SElliott Hughes \ifx#1l% 795*d5c9a868SElliott Hughes \llap{\ignorespaces #2\hskip\inmarginspacing}% 796*d5c9a868SElliott Hughes \else 797*d5c9a868SElliott Hughes \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}% 798*d5c9a868SElliott Hughes \fi 799*d5c9a868SElliott Hughes \null 800*d5c9a868SElliott Hughes }% 801*d5c9a868SElliott Hughes}} 802*d5c9a868SElliott Hughes\def\inleftmargin{\doinmargin l} 803*d5c9a868SElliott Hughes\def\inrightmargin{\doinmargin r} 804*d5c9a868SElliott Hughes% 805*d5c9a868SElliott Hughes% @inmargin{TEXT [, RIGHT-TEXT]} 806*d5c9a868SElliott Hughes% (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right; 807*d5c9a868SElliott Hughes% else use TEXT for both). 808*d5c9a868SElliott Hughes% 809*d5c9a868SElliott Hughes\def\inmargin#1{\parseinmargin #1,,\finish} 810*d5c9a868SElliott Hughes\def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing. 811*d5c9a868SElliott Hughes \setbox0 = \hbox{\ignorespaces #2}% 812*d5c9a868SElliott Hughes \ifdim\wd0 > 0pt 813*d5c9a868SElliott Hughes \def\lefttext{#1}% have both texts 814*d5c9a868SElliott Hughes \def\righttext{#2}% 815*d5c9a868SElliott Hughes \else 816*d5c9a868SElliott Hughes \def\lefttext{#1}% have only one text 817*d5c9a868SElliott Hughes \def\righttext{#1}% 818*d5c9a868SElliott Hughes \fi 819*d5c9a868SElliott Hughes % 820*d5c9a868SElliott Hughes \ifodd\pageno 821*d5c9a868SElliott Hughes \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin 822*d5c9a868SElliott Hughes \else 823*d5c9a868SElliott Hughes \def\temp{\inleftmargin\lefttext}% 824*d5c9a868SElliott Hughes \fi 825*d5c9a868SElliott Hughes \temp 826*d5c9a868SElliott Hughes} 827*d5c9a868SElliott Hughes 828*d5c9a868SElliott Hughes% @include FILE -- \input text of FILE. 829*d5c9a868SElliott Hughes% 830*d5c9a868SElliott Hughes\def\include{\parseargusing\filenamecatcodes\includezzz} 831*d5c9a868SElliott Hughes\def\includezzz#1{% 832*d5c9a868SElliott Hughes \pushthisfilestack 833*d5c9a868SElliott Hughes \def\thisfile{#1}% 834*d5c9a868SElliott Hughes {% 835*d5c9a868SElliott Hughes \makevalueexpandable % we want to expand any @value in FILE. 836*d5c9a868SElliott Hughes \turnoffactive % and allow special characters in the expansion 837*d5c9a868SElliott Hughes \indexnofonts % Allow `@@' and other weird things in file names. 838*d5c9a868SElliott Hughes \wlog{texinfo.tex: doing @include of #1^^J}% 839*d5c9a868SElliott Hughes \edef\temp{\noexpand\input #1 }% 840*d5c9a868SElliott Hughes % 841*d5c9a868SElliott Hughes % This trickery is to read FILE outside of a group, in case it makes 842*d5c9a868SElliott Hughes % definitions, etc. 843*d5c9a868SElliott Hughes \expandafter 844*d5c9a868SElliott Hughes }\temp 845*d5c9a868SElliott Hughes \popthisfilestack 846*d5c9a868SElliott Hughes} 847*d5c9a868SElliott Hughes\def\filenamecatcodes{% 848*d5c9a868SElliott Hughes \catcode`\\=\other 849*d5c9a868SElliott Hughes \catcode`~=\other 850*d5c9a868SElliott Hughes \catcode`^=\other 851*d5c9a868SElliott Hughes \catcode`_=\other 852*d5c9a868SElliott Hughes \catcode`|=\other 853*d5c9a868SElliott Hughes \catcode`<=\other 854*d5c9a868SElliott Hughes \catcode`>=\other 855*d5c9a868SElliott Hughes \catcode`+=\other 856*d5c9a868SElliott Hughes \catcode`-=\other 857*d5c9a868SElliott Hughes \catcode`\`=\other 858*d5c9a868SElliott Hughes \catcode`\'=\other 859*d5c9a868SElliott Hughes} 860*d5c9a868SElliott Hughes 861*d5c9a868SElliott Hughes\def\pushthisfilestack{% 862*d5c9a868SElliott Hughes \expandafter\pushthisfilestackX\popthisfilestack\StackTerm 863*d5c9a868SElliott Hughes} 864*d5c9a868SElliott Hughes\def\pushthisfilestackX{% 865*d5c9a868SElliott Hughes \expandafter\pushthisfilestackY\thisfile\StackTerm 866*d5c9a868SElliott Hughes} 867*d5c9a868SElliott Hughes\def\pushthisfilestackY #1\StackTerm #2\StackTerm {% 868*d5c9a868SElliott Hughes \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}% 869*d5c9a868SElliott Hughes} 870*d5c9a868SElliott Hughes 871*d5c9a868SElliott Hughes\def\popthisfilestack{\errthisfilestackempty} 872*d5c9a868SElliott Hughes\def\errthisfilestackempty{\errmessage{Internal error: 873*d5c9a868SElliott Hughes the stack of filenames is empty.}} 874*d5c9a868SElliott Hughes% 875*d5c9a868SElliott Hughes\def\thisfile{} 876*d5c9a868SElliott Hughes 877*d5c9a868SElliott Hughes% @center line 878*d5c9a868SElliott Hughes% outputs that line, centered. 879*d5c9a868SElliott Hughes% 880*d5c9a868SElliott Hughes\parseargdef\center{% 881*d5c9a868SElliott Hughes \ifhmode 882*d5c9a868SElliott Hughes \let\centersub\centerH 883*d5c9a868SElliott Hughes \else 884*d5c9a868SElliott Hughes \let\centersub\centerV 885*d5c9a868SElliott Hughes \fi 886*d5c9a868SElliott Hughes \centersub{\hfil \ignorespaces#1\unskip \hfil}% 887*d5c9a868SElliott Hughes \let\centersub\relax % don't let the definition persist, just in case 888*d5c9a868SElliott Hughes} 889*d5c9a868SElliott Hughes\def\centerH#1{{% 890*d5c9a868SElliott Hughes \hfil\break 891*d5c9a868SElliott Hughes \advance\hsize by -\leftskip 892*d5c9a868SElliott Hughes \advance\hsize by -\rightskip 893*d5c9a868SElliott Hughes \line{#1}% 894*d5c9a868SElliott Hughes \break 895*d5c9a868SElliott Hughes}} 896*d5c9a868SElliott Hughes% 897*d5c9a868SElliott Hughes\newcount\centerpenalty 898*d5c9a868SElliott Hughes\def\centerV#1{% 899*d5c9a868SElliott Hughes % The idea here is the same as in \startdefun, \cartouche, etc.: if 900*d5c9a868SElliott Hughes % @center is the first thing after a section heading, we need to wipe 901*d5c9a868SElliott Hughes % out the negative parskip inserted by \sectionheading, but still 902*d5c9a868SElliott Hughes % prevent a page break here. 903*d5c9a868SElliott Hughes \centerpenalty = \lastpenalty 904*d5c9a868SElliott Hughes \ifnum\centerpenalty>10000 \vskip\parskip \fi 905*d5c9a868SElliott Hughes \ifnum\centerpenalty>9999 \penalty\centerpenalty \fi 906*d5c9a868SElliott Hughes \line{\kern\leftskip #1\kern\rightskip}% 907*d5c9a868SElliott Hughes} 908*d5c9a868SElliott Hughes 909*d5c9a868SElliott Hughes% @sp n outputs n lines of vertical space 910*d5c9a868SElliott Hughes% 911*d5c9a868SElliott Hughes\parseargdef\sp{\vskip #1\baselineskip} 912*d5c9a868SElliott Hughes 913*d5c9a868SElliott Hughes% @comment ...line which is ignored... 914*d5c9a868SElliott Hughes% @c is the same as @comment 915*d5c9a868SElliott Hughes% @ignore ... @end ignore is another way to write a comment 916*d5c9a868SElliott Hughes 917*d5c9a868SElliott Hughes 918*d5c9a868SElliott Hughes\def\c{\begingroup \catcode`\^^M=\active% 919*d5c9a868SElliott Hughes\catcode`\@=\other \catcode`\{=\other \catcode`\}=\other% 920*d5c9a868SElliott Hughes\cxxx} 921*d5c9a868SElliott Hughes{\catcode`\^^M=\active \gdef\cxxx#1^^M{\endgroup}} 922*d5c9a868SElliott Hughes% 923*d5c9a868SElliott Hughes\let\comment\c 924*d5c9a868SElliott Hughes 925*d5c9a868SElliott Hughes% @paragraphindent NCHARS 926*d5c9a868SElliott Hughes% We'll use ems for NCHARS, close enough. 927*d5c9a868SElliott Hughes% NCHARS can also be the word `asis' or `none'. 928*d5c9a868SElliott Hughes% We cannot feasibly implement @paragraphindent asis, though. 929*d5c9a868SElliott Hughes% 930*d5c9a868SElliott Hughes\def\asisword{asis} % no translation, these are keywords 931*d5c9a868SElliott Hughes\def\noneword{none} 932*d5c9a868SElliott Hughes% 933*d5c9a868SElliott Hughes\parseargdef\paragraphindent{% 934*d5c9a868SElliott Hughes \def\temp{#1}% 935*d5c9a868SElliott Hughes \ifx\temp\asisword 936*d5c9a868SElliott Hughes \else 937*d5c9a868SElliott Hughes \ifx\temp\noneword 938*d5c9a868SElliott Hughes \defaultparindent = 0pt 939*d5c9a868SElliott Hughes \else 940*d5c9a868SElliott Hughes \defaultparindent = #1em 941*d5c9a868SElliott Hughes \fi 942*d5c9a868SElliott Hughes \fi 943*d5c9a868SElliott Hughes \parindent = \defaultparindent 944*d5c9a868SElliott Hughes} 945*d5c9a868SElliott Hughes 946*d5c9a868SElliott Hughes% @exampleindent NCHARS 947*d5c9a868SElliott Hughes% We'll use ems for NCHARS like @paragraphindent. 948*d5c9a868SElliott Hughes% It seems @exampleindent asis isn't necessary, but 949*d5c9a868SElliott Hughes% I preserve it to make it similar to @paragraphindent. 950*d5c9a868SElliott Hughes\parseargdef\exampleindent{% 951*d5c9a868SElliott Hughes \def\temp{#1}% 952*d5c9a868SElliott Hughes \ifx\temp\asisword 953*d5c9a868SElliott Hughes \else 954*d5c9a868SElliott Hughes \ifx\temp\noneword 955*d5c9a868SElliott Hughes \lispnarrowing = 0pt 956*d5c9a868SElliott Hughes \else 957*d5c9a868SElliott Hughes \lispnarrowing = #1em 958*d5c9a868SElliott Hughes \fi 959*d5c9a868SElliott Hughes \fi 960*d5c9a868SElliott Hughes} 961*d5c9a868SElliott Hughes 962*d5c9a868SElliott Hughes% @firstparagraphindent WORD 963*d5c9a868SElliott Hughes% If WORD is `none', then suppress indentation of the first paragraph 964*d5c9a868SElliott Hughes% after a section heading. If WORD is `insert', then do indent at such 965*d5c9a868SElliott Hughes% paragraphs. 966*d5c9a868SElliott Hughes% 967*d5c9a868SElliott Hughes% The paragraph indentation is suppressed or not by calling 968*d5c9a868SElliott Hughes% \suppressfirstparagraphindent, which the sectioning commands do. 969*d5c9a868SElliott Hughes% We switch the definition of this back and forth according to WORD. 970*d5c9a868SElliott Hughes% By default, we suppress indentation. 971*d5c9a868SElliott Hughes% 972*d5c9a868SElliott Hughes\def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent} 973*d5c9a868SElliott Hughes\def\insertword{insert} 974*d5c9a868SElliott Hughes% 975*d5c9a868SElliott Hughes\parseargdef\firstparagraphindent{% 976*d5c9a868SElliott Hughes \def\temp{#1}% 977*d5c9a868SElliott Hughes \ifx\temp\noneword 978*d5c9a868SElliott Hughes \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent 979*d5c9a868SElliott Hughes \else\ifx\temp\insertword 980*d5c9a868SElliott Hughes \let\suppressfirstparagraphindent = \relax 981*d5c9a868SElliott Hughes \else 982*d5c9a868SElliott Hughes \errhelp = \EMsimple 983*d5c9a868SElliott Hughes \errmessage{Unknown @firstparagraphindent option `\temp'}% 984*d5c9a868SElliott Hughes \fi\fi 985*d5c9a868SElliott Hughes} 986*d5c9a868SElliott Hughes 987*d5c9a868SElliott Hughes% Here is how we actually suppress indentation. Redefine \everypar to 988*d5c9a868SElliott Hughes% \kern backwards by \parindent, and then reset itself to empty. 989*d5c9a868SElliott Hughes% 990*d5c9a868SElliott Hughes% We also make \indent itself not actually do anything until the next 991*d5c9a868SElliott Hughes% paragraph. 992*d5c9a868SElliott Hughes% 993*d5c9a868SElliott Hughes\gdef\dosuppressfirstparagraphindent{% 994*d5c9a868SElliott Hughes \gdef\indent {\restorefirstparagraphindent \indent}% 995*d5c9a868SElliott Hughes \gdef\noindent{\restorefirstparagraphindent \noindent}% 996*d5c9a868SElliott Hughes \global\everypar = {\kern -\parindent \restorefirstparagraphindent}% 997*d5c9a868SElliott Hughes} 998*d5c9a868SElliott Hughes% 999*d5c9a868SElliott Hughes\gdef\restorefirstparagraphindent{% 1000*d5c9a868SElliott Hughes \global\let\indent = \ptexindent 1001*d5c9a868SElliott Hughes \global\let\noindent = \ptexnoindent 1002*d5c9a868SElliott Hughes \global\everypar = {}% 1003*d5c9a868SElliott Hughes} 1004*d5c9a868SElliott Hughes 1005*d5c9a868SElliott Hughes% leave vertical mode without cancelling any first paragraph indent 1006*d5c9a868SElliott Hughes\gdef\imageindent{% 1007*d5c9a868SElliott Hughes \toks0=\everypar 1008*d5c9a868SElliott Hughes \everypar={}% 1009*d5c9a868SElliott Hughes \ptexnoindent 1010*d5c9a868SElliott Hughes \global\everypar=\toks0 1011*d5c9a868SElliott Hughes} 1012*d5c9a868SElliott Hughes 1013*d5c9a868SElliott Hughes 1014*d5c9a868SElliott Hughes% @refill is a no-op. 1015*d5c9a868SElliott Hughes\let\refill=\relax 1016*d5c9a868SElliott Hughes 1017*d5c9a868SElliott Hughes% @setfilename INFO-FILENAME - ignored 1018*d5c9a868SElliott Hughes\let\setfilename=\comment 1019*d5c9a868SElliott Hughes 1020*d5c9a868SElliott Hughes% @bye. 1021*d5c9a868SElliott Hughes\outer\def\bye{\chappager\pagelabels\tracingstats=1\ptexend} 1022*d5c9a868SElliott Hughes 1023*d5c9a868SElliott Hughes 1024*d5c9a868SElliott Hughes\message{pdf,} 1025*d5c9a868SElliott Hughes% adobe `portable' document format 1026*d5c9a868SElliott Hughes\newcount\tempnum 1027*d5c9a868SElliott Hughes\newcount\lnkcount 1028*d5c9a868SElliott Hughes\newtoks\filename 1029*d5c9a868SElliott Hughes\newcount\filenamelength 1030*d5c9a868SElliott Hughes\newcount\pgn 1031*d5c9a868SElliott Hughes\newtoks\toksA 1032*d5c9a868SElliott Hughes\newtoks\toksB 1033*d5c9a868SElliott Hughes\newtoks\toksC 1034*d5c9a868SElliott Hughes\newtoks\toksD 1035*d5c9a868SElliott Hughes\newbox\boxA 1036*d5c9a868SElliott Hughes\newbox\boxB 1037*d5c9a868SElliott Hughes\newcount\countA 1038*d5c9a868SElliott Hughes\newif\ifpdf 1039*d5c9a868SElliott Hughes\newif\ifpdfmakepagedest 1040*d5c9a868SElliott Hughes 1041*d5c9a868SElliott Hughes% 1042*d5c9a868SElliott Hughes% For LuaTeX 1043*d5c9a868SElliott Hughes% 1044*d5c9a868SElliott Hughes 1045*d5c9a868SElliott Hughes\newif\iftxiuseunicodedestname 1046*d5c9a868SElliott Hughes\txiuseunicodedestnamefalse % For pdfTeX etc. 1047*d5c9a868SElliott Hughes 1048*d5c9a868SElliott Hughes\ifx\luatexversion\thisisundefined 1049*d5c9a868SElliott Hughes\else 1050*d5c9a868SElliott Hughes % Use Unicode destination names 1051*d5c9a868SElliott Hughes \txiuseunicodedestnametrue 1052*d5c9a868SElliott Hughes % Escape PDF strings with converting UTF-16 from UTF-8 1053*d5c9a868SElliott Hughes \begingroup 1054*d5c9a868SElliott Hughes \catcode`\%=12 1055*d5c9a868SElliott Hughes \directlua{ 1056*d5c9a868SElliott Hughes function UTF16oct(str) 1057*d5c9a868SElliott Hughes tex.sprint(string.char(0x5c) .. '376' .. string.char(0x5c) .. '377') 1058*d5c9a868SElliott Hughes for c in string.utfvalues(str) do 1059*d5c9a868SElliott Hughes if c < 0x10000 then 1060*d5c9a868SElliott Hughes tex.sprint( 1061*d5c9a868SElliott Hughes string.format(string.char(0x5c) .. string.char(0x25) .. '03o' .. 1062*d5c9a868SElliott Hughes string.char(0x5c) .. string.char(0x25) .. '03o', 1063*d5c9a868SElliott Hughes math.floor(c / 256), math.floor(c % 256))) 1064*d5c9a868SElliott Hughes else 1065*d5c9a868SElliott Hughes c = c - 0x10000 1066*d5c9a868SElliott Hughes local c_hi = c / 1024 + 0xd800 1067*d5c9a868SElliott Hughes local c_lo = c % 1024 + 0xdc00 1068*d5c9a868SElliott Hughes tex.sprint( 1069*d5c9a868SElliott Hughes string.format(string.char(0x5c) .. string.char(0x25) .. '03o' .. 1070*d5c9a868SElliott Hughes string.char(0x5c) .. string.char(0x25) .. '03o' .. 1071*d5c9a868SElliott Hughes string.char(0x5c) .. string.char(0x25) .. '03o' .. 1072*d5c9a868SElliott Hughes string.char(0x5c) .. string.char(0x25) .. '03o', 1073*d5c9a868SElliott Hughes math.floor(c_hi / 256), math.floor(c_hi % 256), 1074*d5c9a868SElliott Hughes math.floor(c_lo / 256), math.floor(c_lo % 256))) 1075*d5c9a868SElliott Hughes end 1076*d5c9a868SElliott Hughes end 1077*d5c9a868SElliott Hughes end 1078*d5c9a868SElliott Hughes } 1079*d5c9a868SElliott Hughes \endgroup 1080*d5c9a868SElliott Hughes \def\pdfescapestrutfsixteen#1{\directlua{UTF16oct('\luaescapestring{#1}')}} 1081*d5c9a868SElliott Hughes % Escape PDF strings without converting 1082*d5c9a868SElliott Hughes \begingroup 1083*d5c9a868SElliott Hughes \directlua{ 1084*d5c9a868SElliott Hughes function PDFescstr(str) 1085*d5c9a868SElliott Hughes for c in string.bytes(str) do 1086*d5c9a868SElliott Hughes if c <= 0x20 or c >= 0x80 or c == 0x28 or c == 0x29 or c == 0x5c then 1087*d5c9a868SElliott Hughes tex.sprint(-2, 1088*d5c9a868SElliott Hughes string.format(string.char(0x5c) .. string.char(0x25) .. '03o', 1089*d5c9a868SElliott Hughes c)) 1090*d5c9a868SElliott Hughes else 1091*d5c9a868SElliott Hughes tex.sprint(-2, string.char(c)) 1092*d5c9a868SElliott Hughes end 1093*d5c9a868SElliott Hughes end 1094*d5c9a868SElliott Hughes end 1095*d5c9a868SElliott Hughes } 1096*d5c9a868SElliott Hughes % The -2 in the arguments here gives all the input to TeX catcode 12 1097*d5c9a868SElliott Hughes % (other) or 10 (space), preventing undefined control sequence errors. See 1098*d5c9a868SElliott Hughes % https://lists.gnu.org/archive/html/bug-texinfo/2019-08/msg00031.html 1099*d5c9a868SElliott Hughes % 1100*d5c9a868SElliott Hughes \endgroup 1101*d5c9a868SElliott Hughes \def\pdfescapestring#1{\directlua{PDFescstr('\luaescapestring{#1}')}} 1102*d5c9a868SElliott Hughes \ifnum\luatexversion>84 1103*d5c9a868SElliott Hughes % For LuaTeX >= 0.85 1104*d5c9a868SElliott Hughes \def\pdfdest{\pdfextension dest} 1105*d5c9a868SElliott Hughes \let\pdfoutput\outputmode 1106*d5c9a868SElliott Hughes \def\pdfliteral{\pdfextension literal} 1107*d5c9a868SElliott Hughes \def\pdfcatalog{\pdfextension catalog} 1108*d5c9a868SElliott Hughes \def\pdftexversion{\numexpr\pdffeedback version\relax} 1109*d5c9a868SElliott Hughes \let\pdfximage\saveimageresource 1110*d5c9a868SElliott Hughes \let\pdfrefximage\useimageresource 1111*d5c9a868SElliott Hughes \let\pdflastximage\lastsavedimageresourceindex 1112*d5c9a868SElliott Hughes \def\pdfendlink{\pdfextension endlink\relax} 1113*d5c9a868SElliott Hughes \def\pdfoutline{\pdfextension outline} 1114*d5c9a868SElliott Hughes \def\pdfstartlink{\pdfextension startlink} 1115*d5c9a868SElliott Hughes \def\pdffontattr{\pdfextension fontattr} 1116*d5c9a868SElliott Hughes \def\pdfobj{\pdfextension obj} 1117*d5c9a868SElliott Hughes \def\pdflastobj{\numexpr\pdffeedback lastobj\relax} 1118*d5c9a868SElliott Hughes \let\pdfpagewidth\pagewidth 1119*d5c9a868SElliott Hughes \let\pdfpageheight\pageheight 1120*d5c9a868SElliott Hughes \edef\pdfhorigin{\pdfvariable horigin} 1121*d5c9a868SElliott Hughes \edef\pdfvorigin{\pdfvariable vorigin} 1122*d5c9a868SElliott Hughes \fi 1123*d5c9a868SElliott Hughes\fi 1124*d5c9a868SElliott Hughes 1125*d5c9a868SElliott Hughes% when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1 1126*d5c9a868SElliott Hughes% can be set). So we test for \relax and 0 as well as being undefined. 1127*d5c9a868SElliott Hughes\ifx\pdfoutput\thisisundefined 1128*d5c9a868SElliott Hughes\else 1129*d5c9a868SElliott Hughes \ifx\pdfoutput\relax 1130*d5c9a868SElliott Hughes \else 1131*d5c9a868SElliott Hughes \ifcase\pdfoutput 1132*d5c9a868SElliott Hughes \else 1133*d5c9a868SElliott Hughes \pdftrue 1134*d5c9a868SElliott Hughes \fi 1135*d5c9a868SElliott Hughes \fi 1136*d5c9a868SElliott Hughes\fi 1137*d5c9a868SElliott Hughes 1138*d5c9a868SElliott Hughes\newif\ifpdforxetex 1139*d5c9a868SElliott Hughes\pdforxetexfalse 1140*d5c9a868SElliott Hughes\ifpdf 1141*d5c9a868SElliott Hughes \pdforxetextrue 1142*d5c9a868SElliott Hughes\fi 1143*d5c9a868SElliott Hughes\ifx\XeTeXrevision\thisisundefined\else 1144*d5c9a868SElliott Hughes \pdforxetextrue 1145*d5c9a868SElliott Hughes\fi 1146*d5c9a868SElliott Hughes 1147*d5c9a868SElliott Hughes 1148*d5c9a868SElliott Hughes% Output page labels information. 1149*d5c9a868SElliott Hughes% See PDF reference v.1.7 p.594, section 8.3.1. 1150*d5c9a868SElliott Hughes\ifpdf 1151*d5c9a868SElliott Hughes\def\pagelabels{% 1152*d5c9a868SElliott Hughes \def\title{0 << /P (T-) /S /D >>}% 1153*d5c9a868SElliott Hughes \edef\roman{\the\romancount << /S /r >>}% 1154*d5c9a868SElliott Hughes \edef\arabic{\the\arabiccount << /S /D >>}% 1155*d5c9a868SElliott Hughes % 1156*d5c9a868SElliott Hughes % Page label ranges must be increasing. Remove any duplicates. 1157*d5c9a868SElliott Hughes % (There is a slight chance of this being wrong if e.g. there is 1158*d5c9a868SElliott Hughes % a @contents but no @titlepage, etc.) 1159*d5c9a868SElliott Hughes % 1160*d5c9a868SElliott Hughes \ifnum\romancount=0 \def\roman{}\fi 1161*d5c9a868SElliott Hughes \ifnum\arabiccount=0 \def\title{}% 1162*d5c9a868SElliott Hughes \else 1163*d5c9a868SElliott Hughes \ifnum\romancount=\arabiccount \def\roman{}\fi 1164*d5c9a868SElliott Hughes \fi 1165*d5c9a868SElliott Hughes % 1166*d5c9a868SElliott Hughes \ifnum\romancount<\arabiccount 1167*d5c9a868SElliott Hughes \pdfcatalog{/PageLabels << /Nums [\title \roman \arabic ] >> }\relax 1168*d5c9a868SElliott Hughes \else 1169*d5c9a868SElliott Hughes \pdfcatalog{/PageLabels << /Nums [\title \arabic \roman ] >> }\relax 1170*d5c9a868SElliott Hughes \fi 1171*d5c9a868SElliott Hughes} 1172*d5c9a868SElliott Hughes\else 1173*d5c9a868SElliott Hughes \let\pagelabels\relax 1174*d5c9a868SElliott Hughes\fi 1175*d5c9a868SElliott Hughes 1176*d5c9a868SElliott Hughes\newcount\pagecount \pagecount=0 1177*d5c9a868SElliott Hughes\newcount\romancount \romancount=0 1178*d5c9a868SElliott Hughes\newcount\arabiccount \arabiccount=0 1179*d5c9a868SElliott Hughes\ifpdf 1180*d5c9a868SElliott Hughes \let\ptxadvancepageno\advancepageno 1181*d5c9a868SElliott Hughes \def\advancepageno{% 1182*d5c9a868SElliott Hughes \ptxadvancepageno\global\advance\pagecount by 1 1183*d5c9a868SElliott Hughes } 1184*d5c9a868SElliott Hughes\fi 1185*d5c9a868SElliott Hughes 1186*d5c9a868SElliott Hughes 1187*d5c9a868SElliott Hughes% PDF uses PostScript string constants for the names of xref targets, 1188*d5c9a868SElliott Hughes% for display in the outlines, and in other places. Thus, we have to 1189*d5c9a868SElliott Hughes% double any backslashes. Otherwise, a name like "\node" will be 1190*d5c9a868SElliott Hughes% interpreted as a newline (\n), followed by o, d, e. Not good. 1191*d5c9a868SElliott Hughes% 1192*d5c9a868SElliott Hughes% See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and 1193*d5c9a868SElliott Hughes% related messages. The final outcome is that it is up to the TeX user 1194*d5c9a868SElliott Hughes% to double the backslashes and otherwise make the string valid, so 1195*d5c9a868SElliott Hughes% that's what we do. pdftex 1.30.0 (ca.2005) introduced a primitive to 1196*d5c9a868SElliott Hughes% do this reliably, so we use it. 1197*d5c9a868SElliott Hughes 1198*d5c9a868SElliott Hughes% #1 is a control sequence in which to do the replacements, 1199*d5c9a868SElliott Hughes% which we \xdef. 1200*d5c9a868SElliott Hughes\def\txiescapepdf#1{% 1201*d5c9a868SElliott Hughes \ifx\pdfescapestring\thisisundefined 1202*d5c9a868SElliott Hughes % No primitive available; should we give a warning or log? 1203*d5c9a868SElliott Hughes % Many times it won't matter. 1204*d5c9a868SElliott Hughes \xdef#1{#1}% 1205*d5c9a868SElliott Hughes \else 1206*d5c9a868SElliott Hughes % The expandable \pdfescapestring primitive escapes parentheses, 1207*d5c9a868SElliott Hughes % backslashes, and other special chars. 1208*d5c9a868SElliott Hughes \xdef#1{\pdfescapestring{#1}}% 1209*d5c9a868SElliott Hughes \fi 1210*d5c9a868SElliott Hughes} 1211*d5c9a868SElliott Hughes\def\txiescapepdfutfsixteen#1{% 1212*d5c9a868SElliott Hughes \ifx\pdfescapestrutfsixteen\thisisundefined 1213*d5c9a868SElliott Hughes % No UTF-16 converting macro available. 1214*d5c9a868SElliott Hughes \txiescapepdf{#1}% 1215*d5c9a868SElliott Hughes \else 1216*d5c9a868SElliott Hughes \xdef#1{\pdfescapestrutfsixteen{#1}}% 1217*d5c9a868SElliott Hughes \fi 1218*d5c9a868SElliott Hughes} 1219*d5c9a868SElliott Hughes 1220*d5c9a868SElliott Hughes\newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images 1221*d5c9a868SElliott Hugheswith PDF output, and none of those formats could be found. (.eps cannot 1222*d5c9a868SElliott Hughesbe supported due to the design of the PDF format; use regular TeX (DVI 1223*d5c9a868SElliott Hughesoutput) for that.)} 1224*d5c9a868SElliott Hughes 1225*d5c9a868SElliott Hughes\ifpdf 1226*d5c9a868SElliott Hughes % 1227*d5c9a868SElliott Hughes % Color manipulation macros using ideas from pdfcolor.tex, 1228*d5c9a868SElliott Hughes % except using rgb instead of cmyk; the latter is said to render as a 1229*d5c9a868SElliott Hughes % very dark gray on-screen and a very dark halftone in print, instead 1230*d5c9a868SElliott Hughes % of actual black. The dark red here is dark enough to print on paper as 1231*d5c9a868SElliott Hughes % nearly black, but still distinguishable for online viewing. We use 1232*d5c9a868SElliott Hughes % black by default, though. 1233*d5c9a868SElliott Hughes \def\rgbDarkRed{0.50 0.09 0.12} 1234*d5c9a868SElliott Hughes \def\rgbBlack{0 0 0} 1235*d5c9a868SElliott Hughes % 1236*d5c9a868SElliott Hughes % rg sets the color for filling (usual text, etc.); 1237*d5c9a868SElliott Hughes % RG sets the color for stroking (thin rules, e.g., normal _'s). 1238*d5c9a868SElliott Hughes \def\pdfsetcolor#1{\pdfliteral{#1 rg #1 RG}} 1239*d5c9a868SElliott Hughes % 1240*d5c9a868SElliott Hughes % Set color, and create a mark which defines \thiscolor accordingly, 1241*d5c9a868SElliott Hughes % so that \makeheadline knows which color to restore. 1242*d5c9a868SElliott Hughes \def\setcolor#1{% 1243*d5c9a868SElliott Hughes \xdef\currentcolordefs{\gdef\noexpand\thiscolor{#1}}% 1244*d5c9a868SElliott Hughes \domark 1245*d5c9a868SElliott Hughes \pdfsetcolor{#1}% 1246*d5c9a868SElliott Hughes } 1247*d5c9a868SElliott Hughes % 1248*d5c9a868SElliott Hughes \def\maincolor{\rgbBlack} 1249*d5c9a868SElliott Hughes \pdfsetcolor{\maincolor} 1250*d5c9a868SElliott Hughes \edef\thiscolor{\maincolor} 1251*d5c9a868SElliott Hughes \def\currentcolordefs{} 1252*d5c9a868SElliott Hughes % 1253*d5c9a868SElliott Hughes \def\makefootline{% 1254*d5c9a868SElliott Hughes \baselineskip24pt 1255*d5c9a868SElliott Hughes \line{\pdfsetcolor{\maincolor}\the\footline}% 1256*d5c9a868SElliott Hughes } 1257*d5c9a868SElliott Hughes % 1258*d5c9a868SElliott Hughes \def\makeheadline{% 1259*d5c9a868SElliott Hughes \vbox to 0pt{% 1260*d5c9a868SElliott Hughes \vskip-22.5pt 1261*d5c9a868SElliott Hughes \line{% 1262*d5c9a868SElliott Hughes \vbox to8.5pt{}% 1263*d5c9a868SElliott Hughes % Extract \thiscolor definition from the marks. 1264*d5c9a868SElliott Hughes \getcolormarks 1265*d5c9a868SElliott Hughes % Typeset the headline with \maincolor, then restore the color. 1266*d5c9a868SElliott Hughes \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}% 1267*d5c9a868SElliott Hughes }% 1268*d5c9a868SElliott Hughes \vss 1269*d5c9a868SElliott Hughes }% 1270*d5c9a868SElliott Hughes \nointerlineskip 1271*d5c9a868SElliott Hughes } 1272*d5c9a868SElliott Hughes % 1273*d5c9a868SElliott Hughes % 1274*d5c9a868SElliott Hughes \pdfcatalog{/PageMode /UseOutlines} 1275*d5c9a868SElliott Hughes % 1276*d5c9a868SElliott Hughes % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto). 1277*d5c9a868SElliott Hughes \def\dopdfimage#1#2#3{% 1278*d5c9a868SElliott Hughes \def\pdfimagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}% 1279*d5c9a868SElliott Hughes \def\pdfimageheight{#3}\setbox2 = \hbox{\ignorespaces #3}% 1280*d5c9a868SElliott Hughes % 1281*d5c9a868SElliott Hughes % pdftex (and the PDF format) support .pdf, .png, .jpg (among 1282*d5c9a868SElliott Hughes % others). Let's try in that order, PDF first since if 1283*d5c9a868SElliott Hughes % someone has a scalable image, presumably better to use that than a 1284*d5c9a868SElliott Hughes % bitmap. 1285*d5c9a868SElliott Hughes \let\pdfimgext=\empty 1286*d5c9a868SElliott Hughes \begingroup 1287*d5c9a868SElliott Hughes \openin 1 #1.pdf \ifeof 1 1288*d5c9a868SElliott Hughes \openin 1 #1.PDF \ifeof 1 1289*d5c9a868SElliott Hughes \openin 1 #1.png \ifeof 1 1290*d5c9a868SElliott Hughes \openin 1 #1.jpg \ifeof 1 1291*d5c9a868SElliott Hughes \openin 1 #1.jpeg \ifeof 1 1292*d5c9a868SElliott Hughes \openin 1 #1.JPG \ifeof 1 1293*d5c9a868SElliott Hughes \errhelp = \nopdfimagehelp 1294*d5c9a868SElliott Hughes \errmessage{Could not find image file #1 for pdf}% 1295*d5c9a868SElliott Hughes \else \gdef\pdfimgext{JPG}% 1296*d5c9a868SElliott Hughes \fi 1297*d5c9a868SElliott Hughes \else \gdef\pdfimgext{jpeg}% 1298*d5c9a868SElliott Hughes \fi 1299*d5c9a868SElliott Hughes \else \gdef\pdfimgext{jpg}% 1300*d5c9a868SElliott Hughes \fi 1301*d5c9a868SElliott Hughes \else \gdef\pdfimgext{png}% 1302*d5c9a868SElliott Hughes \fi 1303*d5c9a868SElliott Hughes \else \gdef\pdfimgext{PDF}% 1304*d5c9a868SElliott Hughes \fi 1305*d5c9a868SElliott Hughes \else \gdef\pdfimgext{pdf}% 1306*d5c9a868SElliott Hughes \fi 1307*d5c9a868SElliott Hughes \closein 1 1308*d5c9a868SElliott Hughes \endgroup 1309*d5c9a868SElliott Hughes % 1310*d5c9a868SElliott Hughes % without \immediate, ancient pdftex seg faults when the same image is 1311*d5c9a868SElliott Hughes % included twice. (Version 3.14159-pre-1.0-unofficial-20010704.) 1312*d5c9a868SElliott Hughes \ifnum\pdftexversion < 14 1313*d5c9a868SElliott Hughes \immediate\pdfimage 1314*d5c9a868SElliott Hughes \else 1315*d5c9a868SElliott Hughes \immediate\pdfximage 1316*d5c9a868SElliott Hughes \fi 1317*d5c9a868SElliott Hughes \ifdim \wd0 >0pt width \pdfimagewidth \fi 1318*d5c9a868SElliott Hughes \ifdim \wd2 >0pt height \pdfimageheight \fi 1319*d5c9a868SElliott Hughes \ifnum\pdftexversion<13 1320*d5c9a868SElliott Hughes #1.\pdfimgext 1321*d5c9a868SElliott Hughes \else 1322*d5c9a868SElliott Hughes {#1.\pdfimgext}% 1323*d5c9a868SElliott Hughes \fi 1324*d5c9a868SElliott Hughes \ifnum\pdftexversion < 14 \else 1325*d5c9a868SElliott Hughes \pdfrefximage \pdflastximage 1326*d5c9a868SElliott Hughes \fi} 1327*d5c9a868SElliott Hughes % 1328*d5c9a868SElliott Hughes \def\setpdfdestname#1{{% 1329*d5c9a868SElliott Hughes % We have to set dummies so commands such as @code, and characters 1330*d5c9a868SElliott Hughes % such as \, aren't expanded when present in a section title. 1331*d5c9a868SElliott Hughes \indexnofonts 1332*d5c9a868SElliott Hughes \makevalueexpandable 1333*d5c9a868SElliott Hughes \turnoffactive 1334*d5c9a868SElliott Hughes \iftxiuseunicodedestname 1335*d5c9a868SElliott Hughes \ifx \declaredencoding \latone 1336*d5c9a868SElliott Hughes % Pass through Latin-1 characters. 1337*d5c9a868SElliott Hughes % LuaTeX with byte wise I/O converts Latin-1 characters to Unicode. 1338*d5c9a868SElliott Hughes \else 1339*d5c9a868SElliott Hughes \ifx \declaredencoding \utfeight 1340*d5c9a868SElliott Hughes % Pass through Unicode characters. 1341*d5c9a868SElliott Hughes \else 1342*d5c9a868SElliott Hughes % Use ASCII approximations in destination names. 1343*d5c9a868SElliott Hughes \passthroughcharsfalse 1344*d5c9a868SElliott Hughes \fi 1345*d5c9a868SElliott Hughes \fi 1346*d5c9a868SElliott Hughes \else 1347*d5c9a868SElliott Hughes % Use ASCII approximations in destination names. 1348*d5c9a868SElliott Hughes \passthroughcharsfalse 1349*d5c9a868SElliott Hughes \fi 1350*d5c9a868SElliott Hughes \def\pdfdestname{#1}% 1351*d5c9a868SElliott Hughes \txiescapepdf\pdfdestname 1352*d5c9a868SElliott Hughes }} 1353*d5c9a868SElliott Hughes % 1354*d5c9a868SElliott Hughes \def\setpdfoutlinetext#1{{% 1355*d5c9a868SElliott Hughes \indexnofonts 1356*d5c9a868SElliott Hughes \makevalueexpandable 1357*d5c9a868SElliott Hughes \turnoffactive 1358*d5c9a868SElliott Hughes \ifx \declaredencoding \latone 1359*d5c9a868SElliott Hughes % The PDF format can use an extended form of Latin-1 in bookmark 1360*d5c9a868SElliott Hughes % strings. See Appendix D of the PDF Reference, Sixth Edition, for 1361*d5c9a868SElliott Hughes % the "PDFDocEncoding". 1362*d5c9a868SElliott Hughes \passthroughcharstrue 1363*d5c9a868SElliott Hughes % Pass through Latin-1 characters. 1364*d5c9a868SElliott Hughes % LuaTeX: Convert to Unicode 1365*d5c9a868SElliott Hughes % pdfTeX: Use Latin-1 as PDFDocEncoding 1366*d5c9a868SElliott Hughes \def\pdfoutlinetext{#1}% 1367*d5c9a868SElliott Hughes \else 1368*d5c9a868SElliott Hughes \ifx \declaredencoding \utfeight 1369*d5c9a868SElliott Hughes \ifx\luatexversion\thisisundefined 1370*d5c9a868SElliott Hughes % For pdfTeX with UTF-8. 1371*d5c9a868SElliott Hughes % TODO: the PDF format can use UTF-16 in bookmark strings, 1372*d5c9a868SElliott Hughes % but the code for this isn't done yet. 1373*d5c9a868SElliott Hughes % Use ASCII approximations. 1374*d5c9a868SElliott Hughes \passthroughcharsfalse 1375*d5c9a868SElliott Hughes \def\pdfoutlinetext{#1}% 1376*d5c9a868SElliott Hughes \else 1377*d5c9a868SElliott Hughes % For LuaTeX with UTF-8. 1378*d5c9a868SElliott Hughes % Pass through Unicode characters for title texts. 1379*d5c9a868SElliott Hughes \passthroughcharstrue 1380*d5c9a868SElliott Hughes \def\pdfoutlinetext{#1}% 1381*d5c9a868SElliott Hughes \fi 1382*d5c9a868SElliott Hughes \else 1383*d5c9a868SElliott Hughes % For non-Latin-1 or non-UTF-8 encodings. 1384*d5c9a868SElliott Hughes % Use ASCII approximations. 1385*d5c9a868SElliott Hughes \passthroughcharsfalse 1386*d5c9a868SElliott Hughes \def\pdfoutlinetext{#1}% 1387*d5c9a868SElliott Hughes \fi 1388*d5c9a868SElliott Hughes \fi 1389*d5c9a868SElliott Hughes % LuaTeX: Convert to UTF-16 1390*d5c9a868SElliott Hughes % pdfTeX: Use Latin-1 as PDFDocEncoding 1391*d5c9a868SElliott Hughes \txiescapepdfutfsixteen\pdfoutlinetext 1392*d5c9a868SElliott Hughes }} 1393*d5c9a868SElliott Hughes % 1394*d5c9a868SElliott Hughes \def\pdfmkdest#1{% 1395*d5c9a868SElliott Hughes \setpdfdestname{#1}% 1396*d5c9a868SElliott Hughes \safewhatsit{\pdfdest name{\pdfdestname} xyz}% 1397*d5c9a868SElliott Hughes } 1398*d5c9a868SElliott Hughes % 1399*d5c9a868SElliott Hughes % used to mark target names; must be expandable. 1400*d5c9a868SElliott Hughes \def\pdfmkpgn#1{#1} 1401*d5c9a868SElliott Hughes % 1402*d5c9a868SElliott Hughes % by default, use black for everything. 1403*d5c9a868SElliott Hughes \def\urlcolor{\rgbBlack} 1404*d5c9a868SElliott Hughes \def\linkcolor{\rgbBlack} 1405*d5c9a868SElliott Hughes \def\endlink{\setcolor{\maincolor}\pdfendlink} 1406*d5c9a868SElliott Hughes % 1407*d5c9a868SElliott Hughes % Adding outlines to PDF; macros for calculating structure of outlines 1408*d5c9a868SElliott Hughes % come from Petr Olsak 1409*d5c9a868SElliott Hughes \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0% 1410*d5c9a868SElliott Hughes \else \csname#1\endcsname \fi} 1411*d5c9a868SElliott Hughes \def\advancenumber#1{\tempnum=\expnumber{#1}\relax 1412*d5c9a868SElliott Hughes \advance\tempnum by 1 1413*d5c9a868SElliott Hughes \expandafter\xdef\csname#1\endcsname{\the\tempnum}} 1414*d5c9a868SElliott Hughes % 1415*d5c9a868SElliott Hughes % #1 is the section text, which is what will be displayed in the 1416*d5c9a868SElliott Hughes % outline by the pdf viewer. #2 is the pdf expression for the number 1417*d5c9a868SElliott Hughes % of subentries (or empty, for subsubsections). #3 is the node text, 1418*d5c9a868SElliott Hughes % which might be empty if this toc entry had no corresponding node. 1419*d5c9a868SElliott Hughes % #4 is the page number 1420*d5c9a868SElliott Hughes % 1421*d5c9a868SElliott Hughes \def\dopdfoutline#1#2#3#4{% 1422*d5c9a868SElliott Hughes % Generate a link to the node text if that exists; else, use the 1423*d5c9a868SElliott Hughes % page number. We could generate a destination for the section 1424*d5c9a868SElliott Hughes % text in the case where a section has no node, but it doesn't 1425*d5c9a868SElliott Hughes % seem worth the trouble, since most documents are normally structured. 1426*d5c9a868SElliott Hughes \setpdfoutlinetext{#1} 1427*d5c9a868SElliott Hughes \setpdfdestname{#3} 1428*d5c9a868SElliott Hughes \ifx\pdfdestname\empty 1429*d5c9a868SElliott Hughes \def\pdfdestname{#4}% 1430*d5c9a868SElliott Hughes \fi 1431*d5c9a868SElliott Hughes % 1432*d5c9a868SElliott Hughes \pdfoutline goto name{\pdfmkpgn{\pdfdestname}}#2{\pdfoutlinetext}% 1433*d5c9a868SElliott Hughes } 1434*d5c9a868SElliott Hughes % 1435*d5c9a868SElliott Hughes \def\pdfmakeoutlines{% 1436*d5c9a868SElliott Hughes \begingroup 1437*d5c9a868SElliott Hughes % Read toc silently, to get counts of subentries for \pdfoutline. 1438*d5c9a868SElliott Hughes \def\partentry##1##2##3##4{}% ignore parts in the outlines 1439*d5c9a868SElliott Hughes \def\numchapentry##1##2##3##4{% 1440*d5c9a868SElliott Hughes \def\thischapnum{##2}% 1441*d5c9a868SElliott Hughes \def\thissecnum{0}% 1442*d5c9a868SElliott Hughes \def\thissubsecnum{0}% 1443*d5c9a868SElliott Hughes }% 1444*d5c9a868SElliott Hughes \def\numsecentry##1##2##3##4{% 1445*d5c9a868SElliott Hughes \advancenumber{chap\thischapnum}% 1446*d5c9a868SElliott Hughes \def\thissecnum{##2}% 1447*d5c9a868SElliott Hughes \def\thissubsecnum{0}% 1448*d5c9a868SElliott Hughes }% 1449*d5c9a868SElliott Hughes \def\numsubsecentry##1##2##3##4{% 1450*d5c9a868SElliott Hughes \advancenumber{sec\thissecnum}% 1451*d5c9a868SElliott Hughes \def\thissubsecnum{##2}% 1452*d5c9a868SElliott Hughes }% 1453*d5c9a868SElliott Hughes \def\numsubsubsecentry##1##2##3##4{% 1454*d5c9a868SElliott Hughes \advancenumber{subsec\thissubsecnum}% 1455*d5c9a868SElliott Hughes }% 1456*d5c9a868SElliott Hughes \def\thischapnum{0}% 1457*d5c9a868SElliott Hughes \def\thissecnum{0}% 1458*d5c9a868SElliott Hughes \def\thissubsecnum{0}% 1459*d5c9a868SElliott Hughes % 1460*d5c9a868SElliott Hughes % use \def rather than \let here because we redefine \chapentry et 1461*d5c9a868SElliott Hughes % al. a second time, below. 1462*d5c9a868SElliott Hughes \def\appentry{\numchapentry}% 1463*d5c9a868SElliott Hughes \def\appsecentry{\numsecentry}% 1464*d5c9a868SElliott Hughes \def\appsubsecentry{\numsubsecentry}% 1465*d5c9a868SElliott Hughes \def\appsubsubsecentry{\numsubsubsecentry}% 1466*d5c9a868SElliott Hughes \def\unnchapentry{\numchapentry}% 1467*d5c9a868SElliott Hughes \def\unnsecentry{\numsecentry}% 1468*d5c9a868SElliott Hughes \def\unnsubsecentry{\numsubsecentry}% 1469*d5c9a868SElliott Hughes \def\unnsubsubsecentry{\numsubsubsecentry}% 1470*d5c9a868SElliott Hughes \readdatafile{toc}% 1471*d5c9a868SElliott Hughes % 1472*d5c9a868SElliott Hughes % Read toc second time, this time actually producing the outlines. 1473*d5c9a868SElliott Hughes % The `-' means take the \expnumber as the absolute number of 1474*d5c9a868SElliott Hughes % subentries, which we calculated on our first read of the .toc above. 1475*d5c9a868SElliott Hughes % 1476*d5c9a868SElliott Hughes % We use the node names as the destinations. 1477*d5c9a868SElliott Hughes % 1478*d5c9a868SElliott Hughes % Currently we prefix the section name with the section number 1479*d5c9a868SElliott Hughes % for chapter and appendix headings only in order to avoid too much 1480*d5c9a868SElliott Hughes % horizontal space being required in the PDF viewer. 1481*d5c9a868SElliott Hughes \def\numchapentry##1##2##3##4{% 1482*d5c9a868SElliott Hughes \dopdfoutline{##2 ##1}{count-\expnumber{chap##2}}{##3}{##4}}% 1483*d5c9a868SElliott Hughes \def\unnchapentry##1##2##3##4{% 1484*d5c9a868SElliott Hughes \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}% 1485*d5c9a868SElliott Hughes \def\numsecentry##1##2##3##4{% 1486*d5c9a868SElliott Hughes \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}% 1487*d5c9a868SElliott Hughes \def\numsubsecentry##1##2##3##4{% 1488*d5c9a868SElliott Hughes \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}% 1489*d5c9a868SElliott Hughes \def\numsubsubsecentry##1##2##3##4{% count is always zero 1490*d5c9a868SElliott Hughes \dopdfoutline{##1}{}{##3}{##4}}% 1491*d5c9a868SElliott Hughes % 1492*d5c9a868SElliott Hughes % PDF outlines are displayed using system fonts, instead of 1493*d5c9a868SElliott Hughes % document fonts. Therefore we cannot use special characters, 1494*d5c9a868SElliott Hughes % since the encoding is unknown. For example, the eogonek from 1495*d5c9a868SElliott Hughes % Latin 2 (0xea) gets translated to a | character. Info from 1496*d5c9a868SElliott Hughes % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100. 1497*d5c9a868SElliott Hughes % 1498*d5c9a868SElliott Hughes % TODO this right, we have to translate 8-bit characters to 1499*d5c9a868SElliott Hughes % their "best" equivalent, based on the @documentencoding. Too 1500*d5c9a868SElliott Hughes % much work for too little return. Just use the ASCII equivalents 1501*d5c9a868SElliott Hughes % we use for the index sort strings. 1502*d5c9a868SElliott Hughes % 1503*d5c9a868SElliott Hughes \indexnofonts 1504*d5c9a868SElliott Hughes \setupdatafile 1505*d5c9a868SElliott Hughes % We can have normal brace characters in the PDF outlines, unlike 1506*d5c9a868SElliott Hughes % Texinfo index files. So set that up. 1507*d5c9a868SElliott Hughes \def\{{\lbracecharliteral}% 1508*d5c9a868SElliott Hughes \def\}{\rbracecharliteral}% 1509*d5c9a868SElliott Hughes \catcode`\\=\active \otherbackslash 1510*d5c9a868SElliott Hughes \input \tocreadfilename 1511*d5c9a868SElliott Hughes \endgroup 1512*d5c9a868SElliott Hughes } 1513*d5c9a868SElliott Hughes {\catcode`[=1 \catcode`]=2 1514*d5c9a868SElliott Hughes \catcode`{=\other \catcode`}=\other 1515*d5c9a868SElliott Hughes \gdef\lbracecharliteral[{]% 1516*d5c9a868SElliott Hughes \gdef\rbracecharliteral[}]% 1517*d5c9a868SElliott Hughes ] 1518*d5c9a868SElliott Hughes % 1519*d5c9a868SElliott Hughes \def\skipspaces#1{\def\PP{#1}\def\D{|}% 1520*d5c9a868SElliott Hughes \ifx\PP\D\let\nextsp\relax 1521*d5c9a868SElliott Hughes \else\let\nextsp\skipspaces 1522*d5c9a868SElliott Hughes \addtokens{\filename}{\PP}% 1523*d5c9a868SElliott Hughes \advance\filenamelength by 1 1524*d5c9a868SElliott Hughes \fi 1525*d5c9a868SElliott Hughes \nextsp} 1526*d5c9a868SElliott Hughes \def\getfilename#1{% 1527*d5c9a868SElliott Hughes \filenamelength=0 1528*d5c9a868SElliott Hughes % If we don't expand the argument now, \skipspaces will get 1529*d5c9a868SElliott Hughes % snagged on things like "@value{foo}". 1530*d5c9a868SElliott Hughes \edef\temp{#1}% 1531*d5c9a868SElliott Hughes \expandafter\skipspaces\temp|\relax 1532*d5c9a868SElliott Hughes } 1533*d5c9a868SElliott Hughes \ifnum\pdftexversion < 14 1534*d5c9a868SElliott Hughes \let \startlink \pdfannotlink 1535*d5c9a868SElliott Hughes \else 1536*d5c9a868SElliott Hughes \let \startlink \pdfstartlink 1537*d5c9a868SElliott Hughes \fi 1538*d5c9a868SElliott Hughes % make a live url in pdf output. 1539*d5c9a868SElliott Hughes \def\pdfurl#1{% 1540*d5c9a868SElliott Hughes \begingroup 1541*d5c9a868SElliott Hughes % it seems we really need yet another set of dummies; have not 1542*d5c9a868SElliott Hughes % tried to figure out what each command should do in the context 1543*d5c9a868SElliott Hughes % of @url. for now, just make @/ a no-op, that's the only one 1544*d5c9a868SElliott Hughes % people have actually reported a problem with. 1545*d5c9a868SElliott Hughes % 1546*d5c9a868SElliott Hughes \normalturnoffactive 1547*d5c9a868SElliott Hughes \def\@{@}% 1548*d5c9a868SElliott Hughes \let\/=\empty 1549*d5c9a868SElliott Hughes \makevalueexpandable 1550*d5c9a868SElliott Hughes % do we want to go so far as to use \indexnofonts instead of just 1551*d5c9a868SElliott Hughes % special-casing \var here? 1552*d5c9a868SElliott Hughes \def\var##1{##1}% 1553*d5c9a868SElliott Hughes % 1554*d5c9a868SElliott Hughes \leavevmode\setcolor{\urlcolor}% 1555*d5c9a868SElliott Hughes \startlink attr{/Border [0 0 0]}% 1556*d5c9a868SElliott Hughes user{/Subtype /Link /A << /S /URI /URI (#1) >>}% 1557*d5c9a868SElliott Hughes \endgroup} 1558*d5c9a868SElliott Hughes % \pdfgettoks - Surround page numbers in #1 with @pdflink. #1 may 1559*d5c9a868SElliott Hughes % be a simple number, or a list of numbers in the case of an index 1560*d5c9a868SElliott Hughes % entry. 1561*d5c9a868SElliott Hughes \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}} 1562*d5c9a868SElliott Hughes \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks} 1563*d5c9a868SElliott Hughes \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks} 1564*d5c9a868SElliott Hughes \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}} 1565*d5c9a868SElliott Hughes \def\maketoks{% 1566*d5c9a868SElliott Hughes \expandafter\poptoks\the\toksA|ENDTOKS|\relax 1567*d5c9a868SElliott Hughes \ifx\first0\adn0 1568*d5c9a868SElliott Hughes \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3 1569*d5c9a868SElliott Hughes \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6 1570*d5c9a868SElliott Hughes \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9 1571*d5c9a868SElliott Hughes \else 1572*d5c9a868SElliott Hughes \ifnum0=\countA\else\makelink\fi 1573*d5c9a868SElliott Hughes \ifx\first.\let\next=\done\else 1574*d5c9a868SElliott Hughes \let\next=\maketoks 1575*d5c9a868SElliott Hughes \addtokens{\toksB}{\the\toksD} 1576*d5c9a868SElliott Hughes \ifx\first,\addtokens{\toksB}{\space}\fi 1577*d5c9a868SElliott Hughes \fi 1578*d5c9a868SElliott Hughes \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi 1579*d5c9a868SElliott Hughes \next} 1580*d5c9a868SElliott Hughes \def\makelink{\addtokens{\toksB}% 1581*d5c9a868SElliott Hughes {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0} 1582*d5c9a868SElliott Hughes \def\pdflink#1{% 1583*d5c9a868SElliott Hughes \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}} 1584*d5c9a868SElliott Hughes \setcolor{\linkcolor}#1\endlink} 1585*d5c9a868SElliott Hughes \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st} 1586*d5c9a868SElliott Hughes\else 1587*d5c9a868SElliott Hughes % non-pdf mode 1588*d5c9a868SElliott Hughes \let\pdfmkdest = \gobble 1589*d5c9a868SElliott Hughes \let\pdfurl = \gobble 1590*d5c9a868SElliott Hughes \let\endlink = \relax 1591*d5c9a868SElliott Hughes \let\setcolor = \gobble 1592*d5c9a868SElliott Hughes \let\pdfsetcolor = \gobble 1593*d5c9a868SElliott Hughes \let\pdfmakeoutlines = \relax 1594*d5c9a868SElliott Hughes\fi % \ifx\pdfoutput 1595*d5c9a868SElliott Hughes 1596*d5c9a868SElliott Hughes% 1597*d5c9a868SElliott Hughes% For XeTeX 1598*d5c9a868SElliott Hughes% 1599*d5c9a868SElliott Hughes\ifx\XeTeXrevision\thisisundefined 1600*d5c9a868SElliott Hughes\else 1601*d5c9a868SElliott Hughes % 1602*d5c9a868SElliott Hughes % XeTeX version check 1603*d5c9a868SElliott Hughes % 1604*d5c9a868SElliott Hughes \ifnum\strcmp{\the\XeTeXversion\XeTeXrevision}{0.99996}>-1 1605*d5c9a868SElliott Hughes % TeX Live 2016 contains XeTeX 0.99996 and xdvipdfmx 20160307. 1606*d5c9a868SElliott Hughes % It can use the `dvipdfmx:config' special (from TeX Live SVN r40941). 1607*d5c9a868SElliott Hughes % For avoiding PDF destination name replacement, we use this special 1608*d5c9a868SElliott Hughes % instead of xdvipdfmx's command line option `-C 0x0010'. 1609*d5c9a868SElliott Hughes \special{dvipdfmx:config C 0x0010} 1610*d5c9a868SElliott Hughes % XeTeX 0.99995+ comes with xdvipdfmx 20160307+. 1611*d5c9a868SElliott Hughes % It can handle Unicode destination names for PDF. 1612*d5c9a868SElliott Hughes \txiuseunicodedestnametrue 1613*d5c9a868SElliott Hughes \else 1614*d5c9a868SElliott Hughes % XeTeX < 0.99996 (TeX Live < 2016) cannot use the 1615*d5c9a868SElliott Hughes % `dvipdfmx:config' special. 1616*d5c9a868SElliott Hughes % So for avoiding PDF destination name replacement, 1617*d5c9a868SElliott Hughes % xdvipdfmx's command line option `-C 0x0010' is necessary. 1618*d5c9a868SElliott Hughes % 1619*d5c9a868SElliott Hughes % XeTeX < 0.99995 can not handle Unicode destination names for PDF 1620*d5c9a868SElliott Hughes % because xdvipdfmx 20150315 has a UTF-16 conversion issue. 1621*d5c9a868SElliott Hughes % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753). 1622*d5c9a868SElliott Hughes \txiuseunicodedestnamefalse 1623*d5c9a868SElliott Hughes \fi 1624*d5c9a868SElliott Hughes % 1625*d5c9a868SElliott Hughes % Color support 1626*d5c9a868SElliott Hughes % 1627*d5c9a868SElliott Hughes \def\rgbDarkRed{0.50 0.09 0.12} 1628*d5c9a868SElliott Hughes \def\rgbBlack{0 0 0} 1629*d5c9a868SElliott Hughes % 1630*d5c9a868SElliott Hughes \def\pdfsetcolor#1{\special{pdf:scolor [#1]}} 1631*d5c9a868SElliott Hughes % 1632*d5c9a868SElliott Hughes % Set color, and create a mark which defines \thiscolor accordingly, 1633*d5c9a868SElliott Hughes % so that \makeheadline knows which color to restore. 1634*d5c9a868SElliott Hughes \def\setcolor#1{% 1635*d5c9a868SElliott Hughes \xdef\currentcolordefs{\gdef\noexpand\thiscolor{#1}}% 1636*d5c9a868SElliott Hughes \domark 1637*d5c9a868SElliott Hughes \pdfsetcolor{#1}% 1638*d5c9a868SElliott Hughes } 1639*d5c9a868SElliott Hughes % 1640*d5c9a868SElliott Hughes \def\maincolor{\rgbBlack} 1641*d5c9a868SElliott Hughes \pdfsetcolor{\maincolor} 1642*d5c9a868SElliott Hughes \edef\thiscolor{\maincolor} 1643*d5c9a868SElliott Hughes \def\currentcolordefs{} 1644*d5c9a868SElliott Hughes % 1645*d5c9a868SElliott Hughes \def\makefootline{% 1646*d5c9a868SElliott Hughes \baselineskip24pt 1647*d5c9a868SElliott Hughes \line{\pdfsetcolor{\maincolor}\the\footline}% 1648*d5c9a868SElliott Hughes } 1649*d5c9a868SElliott Hughes % 1650*d5c9a868SElliott Hughes \def\makeheadline{% 1651*d5c9a868SElliott Hughes \vbox to 0pt{% 1652*d5c9a868SElliott Hughes \vskip-22.5pt 1653*d5c9a868SElliott Hughes \line{% 1654*d5c9a868SElliott Hughes \vbox to8.5pt{}% 1655*d5c9a868SElliott Hughes % Extract \thiscolor definition from the marks. 1656*d5c9a868SElliott Hughes \getcolormarks 1657*d5c9a868SElliott Hughes % Typeset the headline with \maincolor, then restore the color. 1658*d5c9a868SElliott Hughes \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}% 1659*d5c9a868SElliott Hughes }% 1660*d5c9a868SElliott Hughes \vss 1661*d5c9a868SElliott Hughes }% 1662*d5c9a868SElliott Hughes \nointerlineskip 1663*d5c9a868SElliott Hughes } 1664*d5c9a868SElliott Hughes % 1665*d5c9a868SElliott Hughes % PDF outline support 1666*d5c9a868SElliott Hughes % 1667*d5c9a868SElliott Hughes % Emulate pdfTeX primitive 1668*d5c9a868SElliott Hughes \def\pdfdest name#1 xyz{% 1669*d5c9a868SElliott Hughes \special{pdf:dest (#1) [@thispage /XYZ @xpos @ypos null]}% 1670*d5c9a868SElliott Hughes } 1671*d5c9a868SElliott Hughes % 1672*d5c9a868SElliott Hughes \def\setpdfdestname#1{{% 1673*d5c9a868SElliott Hughes % We have to set dummies so commands such as @code, and characters 1674*d5c9a868SElliott Hughes % such as \, aren't expanded when present in a section title. 1675*d5c9a868SElliott Hughes \indexnofonts 1676*d5c9a868SElliott Hughes \makevalueexpandable 1677*d5c9a868SElliott Hughes \turnoffactive 1678*d5c9a868SElliott Hughes \iftxiuseunicodedestname 1679*d5c9a868SElliott Hughes % Pass through Unicode characters. 1680*d5c9a868SElliott Hughes \else 1681*d5c9a868SElliott Hughes % Use ASCII approximations in destination names. 1682*d5c9a868SElliott Hughes \passthroughcharsfalse 1683*d5c9a868SElliott Hughes \fi 1684*d5c9a868SElliott Hughes \def\pdfdestname{#1}% 1685*d5c9a868SElliott Hughes \txiescapepdf\pdfdestname 1686*d5c9a868SElliott Hughes }} 1687*d5c9a868SElliott Hughes % 1688*d5c9a868SElliott Hughes \def\setpdfoutlinetext#1{{% 1689*d5c9a868SElliott Hughes \turnoffactive 1690*d5c9a868SElliott Hughes % Always use Unicode characters in title texts. 1691*d5c9a868SElliott Hughes \def\pdfoutlinetext{#1}% 1692*d5c9a868SElliott Hughes % For XeTeX, xdvipdfmx converts to UTF-16. 1693*d5c9a868SElliott Hughes % So we do not convert. 1694*d5c9a868SElliott Hughes \txiescapepdf\pdfoutlinetext 1695*d5c9a868SElliott Hughes }} 1696*d5c9a868SElliott Hughes % 1697*d5c9a868SElliott Hughes \def\pdfmkdest#1{% 1698*d5c9a868SElliott Hughes \setpdfdestname{#1}% 1699*d5c9a868SElliott Hughes \safewhatsit{\pdfdest name{\pdfdestname} xyz}% 1700*d5c9a868SElliott Hughes } 1701*d5c9a868SElliott Hughes % 1702*d5c9a868SElliott Hughes % by default, use black for everything. 1703*d5c9a868SElliott Hughes \def\urlcolor{\rgbBlack} 1704*d5c9a868SElliott Hughes \def\linkcolor{\rgbBlack} 1705*d5c9a868SElliott Hughes \def\endlink{\setcolor{\maincolor}\pdfendlink} 1706*d5c9a868SElliott Hughes % 1707*d5c9a868SElliott Hughes \def\dopdfoutline#1#2#3#4{% 1708*d5c9a868SElliott Hughes \setpdfoutlinetext{#1} 1709*d5c9a868SElliott Hughes \setpdfdestname{#3} 1710*d5c9a868SElliott Hughes \ifx\pdfdestname\empty 1711*d5c9a868SElliott Hughes \def\pdfdestname{#4}% 1712*d5c9a868SElliott Hughes \fi 1713*d5c9a868SElliott Hughes % 1714*d5c9a868SElliott Hughes \special{pdf:out [-] #2 << /Title (\pdfoutlinetext) /A 1715*d5c9a868SElliott Hughes << /S /GoTo /D (\pdfdestname) >> >> }% 1716*d5c9a868SElliott Hughes } 1717*d5c9a868SElliott Hughes % 1718*d5c9a868SElliott Hughes \def\pdfmakeoutlines{% 1719*d5c9a868SElliott Hughes \begingroup 1720*d5c9a868SElliott Hughes % 1721*d5c9a868SElliott Hughes % For XeTeX, counts of subentries are not necessary. 1722*d5c9a868SElliott Hughes % Therefore, we read toc only once. 1723*d5c9a868SElliott Hughes % 1724*d5c9a868SElliott Hughes % We use node names as destinations. 1725*d5c9a868SElliott Hughes % 1726*d5c9a868SElliott Hughes % Currently we prefix the section name with the section number 1727*d5c9a868SElliott Hughes % for chapter and appendix headings only in order to avoid too much 1728*d5c9a868SElliott Hughes % horizontal space being required in the PDF viewer. 1729*d5c9a868SElliott Hughes \def\partentry##1##2##3##4{}% ignore parts in the outlines 1730*d5c9a868SElliott Hughes \def\numchapentry##1##2##3##4{% 1731*d5c9a868SElliott Hughes \dopdfoutline{##2 ##1}{1}{##3}{##4}}% 1732*d5c9a868SElliott Hughes \def\numsecentry##1##2##3##4{% 1733*d5c9a868SElliott Hughes \dopdfoutline{##1}{2}{##3}{##4}}% 1734*d5c9a868SElliott Hughes \def\numsubsecentry##1##2##3##4{% 1735*d5c9a868SElliott Hughes \dopdfoutline{##1}{3}{##3}{##4}}% 1736*d5c9a868SElliott Hughes \def\numsubsubsecentry##1##2##3##4{% 1737*d5c9a868SElliott Hughes \dopdfoutline{##1}{4}{##3}{##4}}% 1738*d5c9a868SElliott Hughes % 1739*d5c9a868SElliott Hughes \let\appentry\numchapentry% 1740*d5c9a868SElliott Hughes \let\appsecentry\numsecentry% 1741*d5c9a868SElliott Hughes \let\appsubsecentry\numsubsecentry% 1742*d5c9a868SElliott Hughes \let\appsubsubsecentry\numsubsubsecentry% 1743*d5c9a868SElliott Hughes \def\unnchapentry##1##2##3##4{% 1744*d5c9a868SElliott Hughes \dopdfoutline{##1}{1}{##3}{##4}}% 1745*d5c9a868SElliott Hughes \let\unnsecentry\numsecentry% 1746*d5c9a868SElliott Hughes \let\unnsubsecentry\numsubsecentry% 1747*d5c9a868SElliott Hughes \let\unnsubsubsecentry\numsubsubsecentry% 1748*d5c9a868SElliott Hughes % 1749*d5c9a868SElliott Hughes % For XeTeX, xdvipdfmx converts strings to UTF-16. 1750*d5c9a868SElliott Hughes % Therefore, the encoding and the language may not be considered. 1751*d5c9a868SElliott Hughes % 1752*d5c9a868SElliott Hughes \indexnofonts 1753*d5c9a868SElliott Hughes \setupdatafile 1754*d5c9a868SElliott Hughes % We can have normal brace characters in the PDF outlines, unlike 1755*d5c9a868SElliott Hughes % Texinfo index files. So set that up. 1756*d5c9a868SElliott Hughes \def\{{\lbracecharliteral}% 1757*d5c9a868SElliott Hughes \def\}{\rbracecharliteral}% 1758*d5c9a868SElliott Hughes \catcode`\\=\active \otherbackslash 1759*d5c9a868SElliott Hughes \input \tocreadfilename 1760*d5c9a868SElliott Hughes \endgroup 1761*d5c9a868SElliott Hughes } 1762*d5c9a868SElliott Hughes {\catcode`[=1 \catcode`]=2 1763*d5c9a868SElliott Hughes \catcode`{=\other \catcode`}=\other 1764*d5c9a868SElliott Hughes \gdef\lbracecharliteral[{]% 1765*d5c9a868SElliott Hughes \gdef\rbracecharliteral[}]% 1766*d5c9a868SElliott Hughes ] 1767*d5c9a868SElliott Hughes 1768*d5c9a868SElliott Hughes \special{pdf:docview << /PageMode /UseOutlines >> } 1769*d5c9a868SElliott Hughes % ``\special{pdf:tounicode ...}'' is not necessary 1770*d5c9a868SElliott Hughes % because xdvipdfmx converts strings from UTF-8 to UTF-16 without it. 1771*d5c9a868SElliott Hughes % However, due to a UTF-16 conversion issue of xdvipdfmx 20150315, 1772*d5c9a868SElliott Hughes % ``\special{pdf:dest ...}'' cannot handle non-ASCII strings. 1773*d5c9a868SElliott Hughes % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753). 1774*d5c9a868SElliott Hughes% 1775*d5c9a868SElliott Hughes \def\skipspaces#1{\def\PP{#1}\def\D{|}% 1776*d5c9a868SElliott Hughes \ifx\PP\D\let\nextsp\relax 1777*d5c9a868SElliott Hughes \else\let\nextsp\skipspaces 1778*d5c9a868SElliott Hughes \addtokens{\filename}{\PP}% 1779*d5c9a868SElliott Hughes \advance\filenamelength by 1 1780*d5c9a868SElliott Hughes \fi 1781*d5c9a868SElliott Hughes \nextsp} 1782*d5c9a868SElliott Hughes \def\getfilename#1{% 1783*d5c9a868SElliott Hughes \filenamelength=0 1784*d5c9a868SElliott Hughes % If we don't expand the argument now, \skipspaces will get 1785*d5c9a868SElliott Hughes % snagged on things like "@value{foo}". 1786*d5c9a868SElliott Hughes \edef\temp{#1}% 1787*d5c9a868SElliott Hughes \expandafter\skipspaces\temp|\relax 1788*d5c9a868SElliott Hughes } 1789*d5c9a868SElliott Hughes % make a live url in pdf output. 1790*d5c9a868SElliott Hughes \def\pdfurl#1{% 1791*d5c9a868SElliott Hughes \begingroup 1792*d5c9a868SElliott Hughes % it seems we really need yet another set of dummies; have not 1793*d5c9a868SElliott Hughes % tried to figure out what each command should do in the context 1794*d5c9a868SElliott Hughes % of @url. for now, just make @/ a no-op, that's the only one 1795*d5c9a868SElliott Hughes % people have actually reported a problem with. 1796*d5c9a868SElliott Hughes % 1797*d5c9a868SElliott Hughes \normalturnoffactive 1798*d5c9a868SElliott Hughes \def\@{@}% 1799*d5c9a868SElliott Hughes \let\/=\empty 1800*d5c9a868SElliott Hughes \makevalueexpandable 1801*d5c9a868SElliott Hughes % do we want to go so far as to use \indexnofonts instead of just 1802*d5c9a868SElliott Hughes % special-casing \var here? 1803*d5c9a868SElliott Hughes \def\var##1{##1}% 1804*d5c9a868SElliott Hughes % 1805*d5c9a868SElliott Hughes \leavevmode\setcolor{\urlcolor}% 1806*d5c9a868SElliott Hughes \special{pdf:bann << /Border [0 0 0] 1807*d5c9a868SElliott Hughes /Subtype /Link /A << /S /URI /URI (#1) >> >>}% 1808*d5c9a868SElliott Hughes \endgroup} 1809*d5c9a868SElliott Hughes \def\endlink{\setcolor{\maincolor}\special{pdf:eann}} 1810*d5c9a868SElliott Hughes \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}} 1811*d5c9a868SElliott Hughes \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks} 1812*d5c9a868SElliott Hughes \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks} 1813*d5c9a868SElliott Hughes \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}} 1814*d5c9a868SElliott Hughes \def\maketoks{% 1815*d5c9a868SElliott Hughes \expandafter\poptoks\the\toksA|ENDTOKS|\relax 1816*d5c9a868SElliott Hughes \ifx\first0\adn0 1817*d5c9a868SElliott Hughes \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3 1818*d5c9a868SElliott Hughes \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6 1819*d5c9a868SElliott Hughes \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9 1820*d5c9a868SElliott Hughes \else 1821*d5c9a868SElliott Hughes \ifnum0=\countA\else\makelink\fi 1822*d5c9a868SElliott Hughes \ifx\first.\let\next=\done\else 1823*d5c9a868SElliott Hughes \let\next=\maketoks 1824*d5c9a868SElliott Hughes \addtokens{\toksB}{\the\toksD} 1825*d5c9a868SElliott Hughes \ifx\first,\addtokens{\toksB}{\space}\fi 1826*d5c9a868SElliott Hughes \fi 1827*d5c9a868SElliott Hughes \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi 1828*d5c9a868SElliott Hughes \next} 1829*d5c9a868SElliott Hughes \def\makelink{\addtokens{\toksB}% 1830*d5c9a868SElliott Hughes {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0} 1831*d5c9a868SElliott Hughes \def\pdflink#1{% 1832*d5c9a868SElliott Hughes \special{pdf:bann << /Border [0 0 0] 1833*d5c9a868SElliott Hughes /Type /Annot /Subtype /Link /A << /S /GoTo /D (#1) >> >>}% 1834*d5c9a868SElliott Hughes \setcolor{\linkcolor}#1\endlink} 1835*d5c9a868SElliott Hughes \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st} 1836*d5c9a868SElliott Hughes% 1837*d5c9a868SElliott Hughes % 1838*d5c9a868SElliott Hughes % @image support 1839*d5c9a868SElliott Hughes % 1840*d5c9a868SElliott Hughes % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto). 1841*d5c9a868SElliott Hughes \def\doxeteximage#1#2#3{% 1842*d5c9a868SElliott Hughes \def\xeteximagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}% 1843*d5c9a868SElliott Hughes \def\xeteximageheight{#3}\setbox2 = \hbox{\ignorespaces #3}% 1844*d5c9a868SElliott Hughes % 1845*d5c9a868SElliott Hughes % XeTeX (and the PDF format) supports .pdf, .png, .jpg (among 1846*d5c9a868SElliott Hughes % others). Let's try in that order, PDF first since if 1847*d5c9a868SElliott Hughes % someone has a scalable image, presumably better to use that than a 1848*d5c9a868SElliott Hughes % bitmap. 1849*d5c9a868SElliott Hughes \let\xeteximgext=\empty 1850*d5c9a868SElliott Hughes \begingroup 1851*d5c9a868SElliott Hughes \openin 1 #1.pdf \ifeof 1 1852*d5c9a868SElliott Hughes \openin 1 #1.PDF \ifeof 1 1853*d5c9a868SElliott Hughes \openin 1 #1.png \ifeof 1 1854*d5c9a868SElliott Hughes \openin 1 #1.jpg \ifeof 1 1855*d5c9a868SElliott Hughes \openin 1 #1.jpeg \ifeof 1 1856*d5c9a868SElliott Hughes \openin 1 #1.JPG \ifeof 1 1857*d5c9a868SElliott Hughes \errmessage{Could not find image file #1 for XeTeX}% 1858*d5c9a868SElliott Hughes \else \gdef\xeteximgext{JPG}% 1859*d5c9a868SElliott Hughes \fi 1860*d5c9a868SElliott Hughes \else \gdef\xeteximgext{jpeg}% 1861*d5c9a868SElliott Hughes \fi 1862*d5c9a868SElliott Hughes \else \gdef\xeteximgext{jpg}% 1863*d5c9a868SElliott Hughes \fi 1864*d5c9a868SElliott Hughes \else \gdef\xeteximgext{png}% 1865*d5c9a868SElliott Hughes \fi 1866*d5c9a868SElliott Hughes \else \gdef\xeteximgext{PDF}% 1867*d5c9a868SElliott Hughes \fi 1868*d5c9a868SElliott Hughes \else \gdef\xeteximgext{pdf}% 1869*d5c9a868SElliott Hughes \fi 1870*d5c9a868SElliott Hughes \closein 1 1871*d5c9a868SElliott Hughes \endgroup 1872*d5c9a868SElliott Hughes % 1873*d5c9a868SElliott Hughes % Putting an \hbox around the image can prevent an over-long line 1874*d5c9a868SElliott Hughes % after the image. 1875*d5c9a868SElliott Hughes \hbox\bgroup 1876*d5c9a868SElliott Hughes \def\xetexpdfext{pdf}% 1877*d5c9a868SElliott Hughes \ifx\xeteximgext\xetexpdfext 1878*d5c9a868SElliott Hughes \XeTeXpdffile "#1".\xeteximgext "" 1879*d5c9a868SElliott Hughes \else 1880*d5c9a868SElliott Hughes \def\xetexpdfext{PDF}% 1881*d5c9a868SElliott Hughes \ifx\xeteximgext\xetexpdfext 1882*d5c9a868SElliott Hughes \XeTeXpdffile "#1".\xeteximgext "" 1883*d5c9a868SElliott Hughes \else 1884*d5c9a868SElliott Hughes \XeTeXpicfile "#1".\xeteximgext "" 1885*d5c9a868SElliott Hughes \fi 1886*d5c9a868SElliott Hughes \fi 1887*d5c9a868SElliott Hughes \ifdim \wd0 >0pt width \xeteximagewidth \fi 1888*d5c9a868SElliott Hughes \ifdim \wd2 >0pt height \xeteximageheight \fi \relax 1889*d5c9a868SElliott Hughes \egroup 1890*d5c9a868SElliott Hughes } 1891*d5c9a868SElliott Hughes\fi 1892*d5c9a868SElliott Hughes 1893*d5c9a868SElliott Hughes 1894*d5c9a868SElliott Hughes% 1895*d5c9a868SElliott Hughes\message{fonts,} 1896*d5c9a868SElliott Hughes 1897*d5c9a868SElliott Hughes% Set the baselineskip to #1, and the lineskip and strut size 1898*d5c9a868SElliott Hughes% correspondingly. There is no deep meaning behind these magic numbers 1899*d5c9a868SElliott Hughes% used as factors; they just match (closely enough) what Knuth defined. 1900*d5c9a868SElliott Hughes% 1901*d5c9a868SElliott Hughes\def\lineskipfactor{.08333} 1902*d5c9a868SElliott Hughes\def\strutheightpercent{.70833} 1903*d5c9a868SElliott Hughes\def\strutdepthpercent {.29167} 1904*d5c9a868SElliott Hughes% 1905*d5c9a868SElliott Hughes% can get a sort of poor man's double spacing by redefining this. 1906*d5c9a868SElliott Hughes\def\baselinefactor{1} 1907*d5c9a868SElliott Hughes% 1908*d5c9a868SElliott Hughes\newdimen\textleading 1909*d5c9a868SElliott Hughes\def\setleading#1{% 1910*d5c9a868SElliott Hughes \dimen0 = #1\relax 1911*d5c9a868SElliott Hughes \normalbaselineskip = \baselinefactor\dimen0 1912*d5c9a868SElliott Hughes \normallineskip = \lineskipfactor\normalbaselineskip 1913*d5c9a868SElliott Hughes \normalbaselines 1914*d5c9a868SElliott Hughes \setbox\strutbox =\hbox{% 1915*d5c9a868SElliott Hughes \vrule width0pt height\strutheightpercent\baselineskip 1916*d5c9a868SElliott Hughes depth \strutdepthpercent \baselineskip 1917*d5c9a868SElliott Hughes }% 1918*d5c9a868SElliott Hughes} 1919*d5c9a868SElliott Hughes 1920*d5c9a868SElliott Hughes% PDF CMaps. See also LaTeX's t1.cmap. 1921*d5c9a868SElliott Hughes% 1922*d5c9a868SElliott Hughes% do nothing with this by default. 1923*d5c9a868SElliott Hughes\expandafter\let\csname cmapOT1\endcsname\gobble 1924*d5c9a868SElliott Hughes\expandafter\let\csname cmapOT1IT\endcsname\gobble 1925*d5c9a868SElliott Hughes\expandafter\let\csname cmapOT1TT\endcsname\gobble 1926*d5c9a868SElliott Hughes 1927*d5c9a868SElliott Hughes% if we are producing pdf, and we have \pdffontattr, then define cmaps. 1928*d5c9a868SElliott Hughes% (\pdffontattr was introduced many years ago, but people still run 1929*d5c9a868SElliott Hughes% older pdftex's; it's easy to conditionalize, so we do.) 1930*d5c9a868SElliott Hughes\ifpdf \ifx\pdffontattr\thisisundefined \else 1931*d5c9a868SElliott Hughes \begingroup 1932*d5c9a868SElliott Hughes \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char. 1933*d5c9a868SElliott Hughes \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap 1934*d5c9a868SElliott Hughes%%DocumentNeededResources: ProcSet (CIDInit) 1935*d5c9a868SElliott Hughes%%IncludeResource: ProcSet (CIDInit) 1936*d5c9a868SElliott Hughes%%BeginResource: CMap (TeX-OT1-0) 1937*d5c9a868SElliott Hughes%%Title: (TeX-OT1-0 TeX OT1 0) 1938*d5c9a868SElliott Hughes%%Version: 1.000 1939*d5c9a868SElliott Hughes%%EndComments 1940*d5c9a868SElliott Hughes/CIDInit /ProcSet findresource begin 1941*d5c9a868SElliott Hughes12 dict begin 1942*d5c9a868SElliott Hughesbegincmap 1943*d5c9a868SElliott Hughes/CIDSystemInfo 1944*d5c9a868SElliott Hughes<< /Registry (TeX) 1945*d5c9a868SElliott Hughes/Ordering (OT1) 1946*d5c9a868SElliott Hughes/Supplement 0 1947*d5c9a868SElliott Hughes>> def 1948*d5c9a868SElliott Hughes/CMapName /TeX-OT1-0 def 1949*d5c9a868SElliott Hughes/CMapType 2 def 1950*d5c9a868SElliott Hughes1 begincodespacerange 1951*d5c9a868SElliott Hughes<00> <7F> 1952*d5c9a868SElliott Hughesendcodespacerange 1953*d5c9a868SElliott Hughes8 beginbfrange 1954*d5c9a868SElliott Hughes<00> <01> <0393> 1955*d5c9a868SElliott Hughes<09> <0A> <03A8> 1956*d5c9a868SElliott Hughes<23> <26> <0023> 1957*d5c9a868SElliott Hughes<28> <3B> <0028> 1958*d5c9a868SElliott Hughes<3F> <5B> <003F> 1959*d5c9a868SElliott Hughes<5D> <5E> <005D> 1960*d5c9a868SElliott Hughes<61> <7A> <0061> 1961*d5c9a868SElliott Hughes<7B> <7C> <2013> 1962*d5c9a868SElliott Hughesendbfrange 1963*d5c9a868SElliott Hughes40 beginbfchar 1964*d5c9a868SElliott Hughes<02> <0398> 1965*d5c9a868SElliott Hughes<03> <039B> 1966*d5c9a868SElliott Hughes<04> <039E> 1967*d5c9a868SElliott Hughes<05> <03A0> 1968*d5c9a868SElliott Hughes<06> <03A3> 1969*d5c9a868SElliott Hughes<07> <03D2> 1970*d5c9a868SElliott Hughes<08> <03A6> 1971*d5c9a868SElliott Hughes<0B> <00660066> 1972*d5c9a868SElliott Hughes<0C> <00660069> 1973*d5c9a868SElliott Hughes<0D> <0066006C> 1974*d5c9a868SElliott Hughes<0E> <006600660069> 1975*d5c9a868SElliott Hughes<0F> <00660066006C> 1976*d5c9a868SElliott Hughes<10> <0131> 1977*d5c9a868SElliott Hughes<11> <0237> 1978*d5c9a868SElliott Hughes<12> <0060> 1979*d5c9a868SElliott Hughes<13> <00B4> 1980*d5c9a868SElliott Hughes<14> <02C7> 1981*d5c9a868SElliott Hughes<15> <02D8> 1982*d5c9a868SElliott Hughes<16> <00AF> 1983*d5c9a868SElliott Hughes<17> <02DA> 1984*d5c9a868SElliott Hughes<18> <00B8> 1985*d5c9a868SElliott Hughes<19> <00DF> 1986*d5c9a868SElliott Hughes<1A> <00E6> 1987*d5c9a868SElliott Hughes<1B> <0153> 1988*d5c9a868SElliott Hughes<1C> <00F8> 1989*d5c9a868SElliott Hughes<1D> <00C6> 1990*d5c9a868SElliott Hughes<1E> <0152> 1991*d5c9a868SElliott Hughes<1F> <00D8> 1992*d5c9a868SElliott Hughes<21> <0021> 1993*d5c9a868SElliott Hughes<22> <201D> 1994*d5c9a868SElliott Hughes<27> <2019> 1995*d5c9a868SElliott Hughes<3C> <00A1> 1996*d5c9a868SElliott Hughes<3D> <003D> 1997*d5c9a868SElliott Hughes<3E> <00BF> 1998*d5c9a868SElliott Hughes<5C> <201C> 1999*d5c9a868SElliott Hughes<5F> <02D9> 2000*d5c9a868SElliott Hughes<60> <2018> 2001*d5c9a868SElliott Hughes<7D> <02DD> 2002*d5c9a868SElliott Hughes<7E> <007E> 2003*d5c9a868SElliott Hughes<7F> <00A8> 2004*d5c9a868SElliott Hughesendbfchar 2005*d5c9a868SElliott Hughesendcmap 2006*d5c9a868SElliott HughesCMapName currentdict /CMap defineresource pop 2007*d5c9a868SElliott Hughesend 2008*d5c9a868SElliott Hughesend 2009*d5c9a868SElliott Hughes%%EndResource 2010*d5c9a868SElliott Hughes%%EOF 2011*d5c9a868SElliott Hughes }\endgroup 2012*d5c9a868SElliott Hughes \expandafter\edef\csname cmapOT1\endcsname#1{% 2013*d5c9a868SElliott Hughes \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}% 2014*d5c9a868SElliott Hughes }% 2015*d5c9a868SElliott Hughes% 2016*d5c9a868SElliott Hughes% \cmapOT1IT 2017*d5c9a868SElliott Hughes \begingroup 2018*d5c9a868SElliott Hughes \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char. 2019*d5c9a868SElliott Hughes \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap 2020*d5c9a868SElliott Hughes%%DocumentNeededResources: ProcSet (CIDInit) 2021*d5c9a868SElliott Hughes%%IncludeResource: ProcSet (CIDInit) 2022*d5c9a868SElliott Hughes%%BeginResource: CMap (TeX-OT1IT-0) 2023*d5c9a868SElliott Hughes%%Title: (TeX-OT1IT-0 TeX OT1IT 0) 2024*d5c9a868SElliott Hughes%%Version: 1.000 2025*d5c9a868SElliott Hughes%%EndComments 2026*d5c9a868SElliott Hughes/CIDInit /ProcSet findresource begin 2027*d5c9a868SElliott Hughes12 dict begin 2028*d5c9a868SElliott Hughesbegincmap 2029*d5c9a868SElliott Hughes/CIDSystemInfo 2030*d5c9a868SElliott Hughes<< /Registry (TeX) 2031*d5c9a868SElliott Hughes/Ordering (OT1IT) 2032*d5c9a868SElliott Hughes/Supplement 0 2033*d5c9a868SElliott Hughes>> def 2034*d5c9a868SElliott Hughes/CMapName /TeX-OT1IT-0 def 2035*d5c9a868SElliott Hughes/CMapType 2 def 2036*d5c9a868SElliott Hughes1 begincodespacerange 2037*d5c9a868SElliott Hughes<00> <7F> 2038*d5c9a868SElliott Hughesendcodespacerange 2039*d5c9a868SElliott Hughes8 beginbfrange 2040*d5c9a868SElliott Hughes<00> <01> <0393> 2041*d5c9a868SElliott Hughes<09> <0A> <03A8> 2042*d5c9a868SElliott Hughes<25> <26> <0025> 2043*d5c9a868SElliott Hughes<28> <3B> <0028> 2044*d5c9a868SElliott Hughes<3F> <5B> <003F> 2045*d5c9a868SElliott Hughes<5D> <5E> <005D> 2046*d5c9a868SElliott Hughes<61> <7A> <0061> 2047*d5c9a868SElliott Hughes<7B> <7C> <2013> 2048*d5c9a868SElliott Hughesendbfrange 2049*d5c9a868SElliott Hughes42 beginbfchar 2050*d5c9a868SElliott Hughes<02> <0398> 2051*d5c9a868SElliott Hughes<03> <039B> 2052*d5c9a868SElliott Hughes<04> <039E> 2053*d5c9a868SElliott Hughes<05> <03A0> 2054*d5c9a868SElliott Hughes<06> <03A3> 2055*d5c9a868SElliott Hughes<07> <03D2> 2056*d5c9a868SElliott Hughes<08> <03A6> 2057*d5c9a868SElliott Hughes<0B> <00660066> 2058*d5c9a868SElliott Hughes<0C> <00660069> 2059*d5c9a868SElliott Hughes<0D> <0066006C> 2060*d5c9a868SElliott Hughes<0E> <006600660069> 2061*d5c9a868SElliott Hughes<0F> <00660066006C> 2062*d5c9a868SElliott Hughes<10> <0131> 2063*d5c9a868SElliott Hughes<11> <0237> 2064*d5c9a868SElliott Hughes<12> <0060> 2065*d5c9a868SElliott Hughes<13> <00B4> 2066*d5c9a868SElliott Hughes<14> <02C7> 2067*d5c9a868SElliott Hughes<15> <02D8> 2068*d5c9a868SElliott Hughes<16> <00AF> 2069*d5c9a868SElliott Hughes<17> <02DA> 2070*d5c9a868SElliott Hughes<18> <00B8> 2071*d5c9a868SElliott Hughes<19> <00DF> 2072*d5c9a868SElliott Hughes<1A> <00E6> 2073*d5c9a868SElliott Hughes<1B> <0153> 2074*d5c9a868SElliott Hughes<1C> <00F8> 2075*d5c9a868SElliott Hughes<1D> <00C6> 2076*d5c9a868SElliott Hughes<1E> <0152> 2077*d5c9a868SElliott Hughes<1F> <00D8> 2078*d5c9a868SElliott Hughes<21> <0021> 2079*d5c9a868SElliott Hughes<22> <201D> 2080*d5c9a868SElliott Hughes<23> <0023> 2081*d5c9a868SElliott Hughes<24> <00A3> 2082*d5c9a868SElliott Hughes<27> <2019> 2083*d5c9a868SElliott Hughes<3C> <00A1> 2084*d5c9a868SElliott Hughes<3D> <003D> 2085*d5c9a868SElliott Hughes<3E> <00BF> 2086*d5c9a868SElliott Hughes<5C> <201C> 2087*d5c9a868SElliott Hughes<5F> <02D9> 2088*d5c9a868SElliott Hughes<60> <2018> 2089*d5c9a868SElliott Hughes<7D> <02DD> 2090*d5c9a868SElliott Hughes<7E> <007E> 2091*d5c9a868SElliott Hughes<7F> <00A8> 2092*d5c9a868SElliott Hughesendbfchar 2093*d5c9a868SElliott Hughesendcmap 2094*d5c9a868SElliott HughesCMapName currentdict /CMap defineresource pop 2095*d5c9a868SElliott Hughesend 2096*d5c9a868SElliott Hughesend 2097*d5c9a868SElliott Hughes%%EndResource 2098*d5c9a868SElliott Hughes%%EOF 2099*d5c9a868SElliott Hughes }\endgroup 2100*d5c9a868SElliott Hughes \expandafter\edef\csname cmapOT1IT\endcsname#1{% 2101*d5c9a868SElliott Hughes \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}% 2102*d5c9a868SElliott Hughes }% 2103*d5c9a868SElliott Hughes% 2104*d5c9a868SElliott Hughes% \cmapOT1TT 2105*d5c9a868SElliott Hughes \begingroup 2106*d5c9a868SElliott Hughes \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char. 2107*d5c9a868SElliott Hughes \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap 2108*d5c9a868SElliott Hughes%%DocumentNeededResources: ProcSet (CIDInit) 2109*d5c9a868SElliott Hughes%%IncludeResource: ProcSet (CIDInit) 2110*d5c9a868SElliott Hughes%%BeginResource: CMap (TeX-OT1TT-0) 2111*d5c9a868SElliott Hughes%%Title: (TeX-OT1TT-0 TeX OT1TT 0) 2112*d5c9a868SElliott Hughes%%Version: 1.000 2113*d5c9a868SElliott Hughes%%EndComments 2114*d5c9a868SElliott Hughes/CIDInit /ProcSet findresource begin 2115*d5c9a868SElliott Hughes12 dict begin 2116*d5c9a868SElliott Hughesbegincmap 2117*d5c9a868SElliott Hughes/CIDSystemInfo 2118*d5c9a868SElliott Hughes<< /Registry (TeX) 2119*d5c9a868SElliott Hughes/Ordering (OT1TT) 2120*d5c9a868SElliott Hughes/Supplement 0 2121*d5c9a868SElliott Hughes>> def 2122*d5c9a868SElliott Hughes/CMapName /TeX-OT1TT-0 def 2123*d5c9a868SElliott Hughes/CMapType 2 def 2124*d5c9a868SElliott Hughes1 begincodespacerange 2125*d5c9a868SElliott Hughes<00> <7F> 2126*d5c9a868SElliott Hughesendcodespacerange 2127*d5c9a868SElliott Hughes5 beginbfrange 2128*d5c9a868SElliott Hughes<00> <01> <0393> 2129*d5c9a868SElliott Hughes<09> <0A> <03A8> 2130*d5c9a868SElliott Hughes<21> <26> <0021> 2131*d5c9a868SElliott Hughes<28> <5F> <0028> 2132*d5c9a868SElliott Hughes<61> <7E> <0061> 2133*d5c9a868SElliott Hughesendbfrange 2134*d5c9a868SElliott Hughes32 beginbfchar 2135*d5c9a868SElliott Hughes<02> <0398> 2136*d5c9a868SElliott Hughes<03> <039B> 2137*d5c9a868SElliott Hughes<04> <039E> 2138*d5c9a868SElliott Hughes<05> <03A0> 2139*d5c9a868SElliott Hughes<06> <03A3> 2140*d5c9a868SElliott Hughes<07> <03D2> 2141*d5c9a868SElliott Hughes<08> <03A6> 2142*d5c9a868SElliott Hughes<0B> <2191> 2143*d5c9a868SElliott Hughes<0C> <2193> 2144*d5c9a868SElliott Hughes<0D> <0027> 2145*d5c9a868SElliott Hughes<0E> <00A1> 2146*d5c9a868SElliott Hughes<0F> <00BF> 2147*d5c9a868SElliott Hughes<10> <0131> 2148*d5c9a868SElliott Hughes<11> <0237> 2149*d5c9a868SElliott Hughes<12> <0060> 2150*d5c9a868SElliott Hughes<13> <00B4> 2151*d5c9a868SElliott Hughes<14> <02C7> 2152*d5c9a868SElliott Hughes<15> <02D8> 2153*d5c9a868SElliott Hughes<16> <00AF> 2154*d5c9a868SElliott Hughes<17> <02DA> 2155*d5c9a868SElliott Hughes<18> <00B8> 2156*d5c9a868SElliott Hughes<19> <00DF> 2157*d5c9a868SElliott Hughes<1A> <00E6> 2158*d5c9a868SElliott Hughes<1B> <0153> 2159*d5c9a868SElliott Hughes<1C> <00F8> 2160*d5c9a868SElliott Hughes<1D> <00C6> 2161*d5c9a868SElliott Hughes<1E> <0152> 2162*d5c9a868SElliott Hughes<1F> <00D8> 2163*d5c9a868SElliott Hughes<20> <2423> 2164*d5c9a868SElliott Hughes<27> <2019> 2165*d5c9a868SElliott Hughes<60> <2018> 2166*d5c9a868SElliott Hughes<7F> <00A8> 2167*d5c9a868SElliott Hughesendbfchar 2168*d5c9a868SElliott Hughesendcmap 2169*d5c9a868SElliott HughesCMapName currentdict /CMap defineresource pop 2170*d5c9a868SElliott Hughesend 2171*d5c9a868SElliott Hughesend 2172*d5c9a868SElliott Hughes%%EndResource 2173*d5c9a868SElliott Hughes%%EOF 2174*d5c9a868SElliott Hughes }\endgroup 2175*d5c9a868SElliott Hughes \expandafter\edef\csname cmapOT1TT\endcsname#1{% 2176*d5c9a868SElliott Hughes \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}% 2177*d5c9a868SElliott Hughes }% 2178*d5c9a868SElliott Hughes\fi\fi 2179*d5c9a868SElliott Hughes 2180*d5c9a868SElliott Hughes 2181*d5c9a868SElliott Hughes% Set the font macro #1 to the font named \fontprefix#2. 2182*d5c9a868SElliott Hughes% #3 is the font's design size, #4 is a scale factor, #5 is the CMap 2183*d5c9a868SElliott Hughes% encoding (only OT1, OT1IT and OT1TT are allowed, or empty to omit). 2184*d5c9a868SElliott Hughes% Example: 2185*d5c9a868SElliott Hughes% #1 = \textrm 2186*d5c9a868SElliott Hughes% #2 = \rmshape 2187*d5c9a868SElliott Hughes% #3 = 10 2188*d5c9a868SElliott Hughes% #4 = \mainmagstep 2189*d5c9a868SElliott Hughes% #5 = OT1 2190*d5c9a868SElliott Hughes% 2191*d5c9a868SElliott Hughes\def\setfont#1#2#3#4#5{% 2192*d5c9a868SElliott Hughes \font#1=\fontprefix#2#3 scaled #4 2193*d5c9a868SElliott Hughes \csname cmap#5\endcsname#1% 2194*d5c9a868SElliott Hughes} 2195*d5c9a868SElliott Hughes% This is what gets called when #5 of \setfont is empty. 2196*d5c9a868SElliott Hughes\let\cmap\gobble 2197*d5c9a868SElliott Hughes% 2198*d5c9a868SElliott Hughes% (end of cmaps) 2199*d5c9a868SElliott Hughes 2200*d5c9a868SElliott Hughes% Use cm as the default font prefix. 2201*d5c9a868SElliott Hughes% To specify the font prefix, you must define \fontprefix 2202*d5c9a868SElliott Hughes% before you read in texinfo.tex. 2203*d5c9a868SElliott Hughes\ifx\fontprefix\thisisundefined 2204*d5c9a868SElliott Hughes\def\fontprefix{cm} 2205*d5c9a868SElliott Hughes\fi 2206*d5c9a868SElliott Hughes% Support font families that don't use the same naming scheme as CM. 2207*d5c9a868SElliott Hughes\def\rmshape{r} 2208*d5c9a868SElliott Hughes\def\rmbshape{bx} % where the normal face is bold 2209*d5c9a868SElliott Hughes\def\bfshape{b} 2210*d5c9a868SElliott Hughes\def\bxshape{bx} 2211*d5c9a868SElliott Hughes\def\ttshape{tt} 2212*d5c9a868SElliott Hughes\def\ttbshape{tt} 2213*d5c9a868SElliott Hughes\def\ttslshape{sltt} 2214*d5c9a868SElliott Hughes\def\itshape{ti} 2215*d5c9a868SElliott Hughes\def\itbshape{bxti} 2216*d5c9a868SElliott Hughes\def\slshape{sl} 2217*d5c9a868SElliott Hughes\def\slbshape{bxsl} 2218*d5c9a868SElliott Hughes\def\sfshape{ss} 2219*d5c9a868SElliott Hughes\def\sfbshape{ss} 2220*d5c9a868SElliott Hughes\def\scshape{csc} 2221*d5c9a868SElliott Hughes\def\scbshape{csc} 2222*d5c9a868SElliott Hughes 2223*d5c9a868SElliott Hughes% Definitions for a main text size of 11pt. (The default in Texinfo.) 2224*d5c9a868SElliott Hughes% 2225*d5c9a868SElliott Hughes\def\definetextfontsizexi{% 2226*d5c9a868SElliott Hughes% Text fonts (11.2pt, magstep1). 2227*d5c9a868SElliott Hughes\def\textnominalsize{11pt} 2228*d5c9a868SElliott Hughes\edef\mainmagstep{\magstephalf} 2229*d5c9a868SElliott Hughes\setfont\textrm\rmshape{10}{\mainmagstep}{OT1} 2230*d5c9a868SElliott Hughes\setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT} 2231*d5c9a868SElliott Hughes\setfont\textbf\bfshape{10}{\mainmagstep}{OT1} 2232*d5c9a868SElliott Hughes\setfont\textit\itshape{10}{\mainmagstep}{OT1IT} 2233*d5c9a868SElliott Hughes\setfont\textsl\slshape{10}{\mainmagstep}{OT1} 2234*d5c9a868SElliott Hughes\setfont\textsf\sfshape{10}{\mainmagstep}{OT1} 2235*d5c9a868SElliott Hughes\setfont\textsc\scshape{10}{\mainmagstep}{OT1} 2236*d5c9a868SElliott Hughes\setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT} 2237*d5c9a868SElliott Hughes\font\texti=cmmi10 scaled \mainmagstep 2238*d5c9a868SElliott Hughes\font\textsy=cmsy10 scaled \mainmagstep 2239*d5c9a868SElliott Hughes\def\textecsize{1095} 2240*d5c9a868SElliott Hughes 2241*d5c9a868SElliott Hughes% A few fonts for @defun names and args. 2242*d5c9a868SElliott Hughes\setfont\defbf\bfshape{10}{\magstep1}{OT1} 2243*d5c9a868SElliott Hughes\setfont\deftt\ttshape{10}{\magstep1}{OT1TT} 2244*d5c9a868SElliott Hughes\setfont\defsl\slshape{10}{\magstep1}{OT1} 2245*d5c9a868SElliott Hughes\setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT} 2246*d5c9a868SElliott Hughes\def\df{\let\ttfont=\deftt \let\bffont = \defbf 2247*d5c9a868SElliott Hughes\let\ttslfont=\defttsl \let\slfont=\defsl \bf} 2248*d5c9a868SElliott Hughes 2249*d5c9a868SElliott Hughes% Fonts for indices, footnotes, small examples (9pt). 2250*d5c9a868SElliott Hughes\def\smallnominalsize{9pt} 2251*d5c9a868SElliott Hughes\setfont\smallrm\rmshape{9}{1000}{OT1} 2252*d5c9a868SElliott Hughes\setfont\smalltt\ttshape{9}{1000}{OT1TT} 2253*d5c9a868SElliott Hughes\setfont\smallbf\bfshape{10}{900}{OT1} 2254*d5c9a868SElliott Hughes\setfont\smallit\itshape{9}{1000}{OT1IT} 2255*d5c9a868SElliott Hughes\setfont\smallsl\slshape{9}{1000}{OT1} 2256*d5c9a868SElliott Hughes\setfont\smallsf\sfshape{9}{1000}{OT1} 2257*d5c9a868SElliott Hughes\setfont\smallsc\scshape{10}{900}{OT1} 2258*d5c9a868SElliott Hughes\setfont\smallttsl\ttslshape{10}{900}{OT1TT} 2259*d5c9a868SElliott Hughes\font\smalli=cmmi9 2260*d5c9a868SElliott Hughes\font\smallsy=cmsy9 2261*d5c9a868SElliott Hughes\def\smallecsize{0900} 2262*d5c9a868SElliott Hughes 2263*d5c9a868SElliott Hughes% Fonts for small examples (8pt). 2264*d5c9a868SElliott Hughes\def\smallernominalsize{8pt} 2265*d5c9a868SElliott Hughes\setfont\smallerrm\rmshape{8}{1000}{OT1} 2266*d5c9a868SElliott Hughes\setfont\smallertt\ttshape{8}{1000}{OT1TT} 2267*d5c9a868SElliott Hughes\setfont\smallerbf\bfshape{10}{800}{OT1} 2268*d5c9a868SElliott Hughes\setfont\smallerit\itshape{8}{1000}{OT1IT} 2269*d5c9a868SElliott Hughes\setfont\smallersl\slshape{8}{1000}{OT1} 2270*d5c9a868SElliott Hughes\setfont\smallersf\sfshape{8}{1000}{OT1} 2271*d5c9a868SElliott Hughes\setfont\smallersc\scshape{10}{800}{OT1} 2272*d5c9a868SElliott Hughes\setfont\smallerttsl\ttslshape{10}{800}{OT1TT} 2273*d5c9a868SElliott Hughes\font\smalleri=cmmi8 2274*d5c9a868SElliott Hughes\font\smallersy=cmsy8 2275*d5c9a868SElliott Hughes\def\smallerecsize{0800} 2276*d5c9a868SElliott Hughes 2277*d5c9a868SElliott Hughes% Fonts for math mode superscripts (7pt). 2278*d5c9a868SElliott Hughes\def\sevennominalsize{7pt} 2279*d5c9a868SElliott Hughes\setfont\sevenrm\rmshape{7}{1000}{OT1} 2280*d5c9a868SElliott Hughes\setfont\seventt\ttshape{10}{700}{OT1TT} 2281*d5c9a868SElliott Hughes\setfont\sevenbf\bfshape{10}{700}{OT1} 2282*d5c9a868SElliott Hughes\setfont\sevenit\itshape{7}{1000}{OT1IT} 2283*d5c9a868SElliott Hughes\setfont\sevensl\slshape{10}{700}{OT1} 2284*d5c9a868SElliott Hughes\setfont\sevensf\sfshape{10}{700}{OT1} 2285*d5c9a868SElliott Hughes\setfont\sevensc\scshape{10}{700}{OT1} 2286*d5c9a868SElliott Hughes\setfont\seventtsl\ttslshape{10}{700}{OT1TT} 2287*d5c9a868SElliott Hughes\font\seveni=cmmi7 2288*d5c9a868SElliott Hughes\font\sevensy=cmsy7 2289*d5c9a868SElliott Hughes\def\sevenecsize{0700} 2290*d5c9a868SElliott Hughes 2291*d5c9a868SElliott Hughes% Fonts for title page (20.4pt): 2292*d5c9a868SElliott Hughes\def\titlenominalsize{20pt} 2293*d5c9a868SElliott Hughes\setfont\titlerm\rmbshape{12}{\magstep3}{OT1} 2294*d5c9a868SElliott Hughes\setfont\titleit\itbshape{10}{\magstep4}{OT1IT} 2295*d5c9a868SElliott Hughes\setfont\titlesl\slbshape{10}{\magstep4}{OT1} 2296*d5c9a868SElliott Hughes\setfont\titlett\ttbshape{12}{\magstep3}{OT1TT} 2297*d5c9a868SElliott Hughes\setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT} 2298*d5c9a868SElliott Hughes\setfont\titlesf\sfbshape{17}{\magstep1}{OT1} 2299*d5c9a868SElliott Hughes\let\titlebf=\titlerm 2300*d5c9a868SElliott Hughes\setfont\titlesc\scbshape{10}{\magstep4}{OT1} 2301*d5c9a868SElliott Hughes\font\titlei=cmmi12 scaled \magstep3 2302*d5c9a868SElliott Hughes\font\titlesy=cmsy10 scaled \magstep4 2303*d5c9a868SElliott Hughes\def\titleecsize{2074} 2304*d5c9a868SElliott Hughes 2305*d5c9a868SElliott Hughes% Chapter (and unnumbered) fonts (17.28pt). 2306*d5c9a868SElliott Hughes\def\chapnominalsize{17pt} 2307*d5c9a868SElliott Hughes\setfont\chaprm\rmbshape{12}{\magstep2}{OT1} 2308*d5c9a868SElliott Hughes\setfont\chapit\itbshape{10}{\magstep3}{OT1IT} 2309*d5c9a868SElliott Hughes\setfont\chapsl\slbshape{10}{\magstep3}{OT1} 2310*d5c9a868SElliott Hughes\setfont\chaptt\ttbshape{12}{\magstep2}{OT1TT} 2311*d5c9a868SElliott Hughes\setfont\chapttsl\ttslshape{10}{\magstep3}{OT1TT} 2312*d5c9a868SElliott Hughes\setfont\chapsf\sfbshape{17}{1000}{OT1} 2313*d5c9a868SElliott Hughes\let\chapbf=\chaprm 2314*d5c9a868SElliott Hughes\setfont\chapsc\scbshape{10}{\magstep3}{OT1} 2315*d5c9a868SElliott Hughes\font\chapi=cmmi12 scaled \magstep2 2316*d5c9a868SElliott Hughes\font\chapsy=cmsy10 scaled \magstep3 2317*d5c9a868SElliott Hughes\def\chapecsize{1728} 2318*d5c9a868SElliott Hughes 2319*d5c9a868SElliott Hughes% Section fonts (14.4pt). 2320*d5c9a868SElliott Hughes\def\secnominalsize{14pt} 2321*d5c9a868SElliott Hughes\setfont\secrm\rmbshape{12}{\magstep1}{OT1} 2322*d5c9a868SElliott Hughes\setfont\secrmnotbold\rmshape{12}{\magstep1}{OT1} 2323*d5c9a868SElliott Hughes\setfont\secit\itbshape{10}{\magstep2}{OT1IT} 2324*d5c9a868SElliott Hughes\setfont\secsl\slbshape{10}{\magstep2}{OT1} 2325*d5c9a868SElliott Hughes\setfont\sectt\ttbshape{12}{\magstep1}{OT1TT} 2326*d5c9a868SElliott Hughes\setfont\secttsl\ttslshape{10}{\magstep2}{OT1TT} 2327*d5c9a868SElliott Hughes\setfont\secsf\sfbshape{12}{\magstep1}{OT1} 2328*d5c9a868SElliott Hughes\let\secbf\secrm 2329*d5c9a868SElliott Hughes\setfont\secsc\scbshape{10}{\magstep2}{OT1} 2330*d5c9a868SElliott Hughes\font\seci=cmmi12 scaled \magstep1 2331*d5c9a868SElliott Hughes\font\secsy=cmsy10 scaled \magstep2 2332*d5c9a868SElliott Hughes\def\sececsize{1440} 2333*d5c9a868SElliott Hughes 2334*d5c9a868SElliott Hughes% Subsection fonts (13.15pt). 2335*d5c9a868SElliott Hughes\def\ssecnominalsize{13pt} 2336*d5c9a868SElliott Hughes\setfont\ssecrm\rmbshape{12}{\magstephalf}{OT1} 2337*d5c9a868SElliott Hughes\setfont\ssecit\itbshape{10}{1315}{OT1IT} 2338*d5c9a868SElliott Hughes\setfont\ssecsl\slbshape{10}{1315}{OT1} 2339*d5c9a868SElliott Hughes\setfont\ssectt\ttbshape{12}{\magstephalf}{OT1TT} 2340*d5c9a868SElliott Hughes\setfont\ssecttsl\ttslshape{10}{1315}{OT1TT} 2341*d5c9a868SElliott Hughes\setfont\ssecsf\sfbshape{12}{\magstephalf}{OT1} 2342*d5c9a868SElliott Hughes\let\ssecbf\ssecrm 2343*d5c9a868SElliott Hughes\setfont\ssecsc\scbshape{10}{1315}{OT1} 2344*d5c9a868SElliott Hughes\font\sseci=cmmi12 scaled \magstephalf 2345*d5c9a868SElliott Hughes\font\ssecsy=cmsy10 scaled 1315 2346*d5c9a868SElliott Hughes\def\ssececsize{1200} 2347*d5c9a868SElliott Hughes 2348*d5c9a868SElliott Hughes% Reduced fonts for @acronym in text (10pt). 2349*d5c9a868SElliott Hughes\def\reducednominalsize{10pt} 2350*d5c9a868SElliott Hughes\setfont\reducedrm\rmshape{10}{1000}{OT1} 2351*d5c9a868SElliott Hughes\setfont\reducedtt\ttshape{10}{1000}{OT1TT} 2352*d5c9a868SElliott Hughes\setfont\reducedbf\bfshape{10}{1000}{OT1} 2353*d5c9a868SElliott Hughes\setfont\reducedit\itshape{10}{1000}{OT1IT} 2354*d5c9a868SElliott Hughes\setfont\reducedsl\slshape{10}{1000}{OT1} 2355*d5c9a868SElliott Hughes\setfont\reducedsf\sfshape{10}{1000}{OT1} 2356*d5c9a868SElliott Hughes\setfont\reducedsc\scshape{10}{1000}{OT1} 2357*d5c9a868SElliott Hughes\setfont\reducedttsl\ttslshape{10}{1000}{OT1TT} 2358*d5c9a868SElliott Hughes\font\reducedi=cmmi10 2359*d5c9a868SElliott Hughes\font\reducedsy=cmsy10 2360*d5c9a868SElliott Hughes\def\reducedecsize{1000} 2361*d5c9a868SElliott Hughes 2362*d5c9a868SElliott Hughes\textleading = 13.2pt % line spacing for 11pt CM 2363*d5c9a868SElliott Hughes\textfonts % reset the current fonts 2364*d5c9a868SElliott Hughes\rm 2365*d5c9a868SElliott Hughes} % end of 11pt text font size definitions, \definetextfontsizexi 2366*d5c9a868SElliott Hughes 2367*d5c9a868SElliott Hughes 2368*d5c9a868SElliott Hughes% Definitions to make the main text be 10pt Computer Modern, with 2369*d5c9a868SElliott Hughes% section, chapter, etc., sizes following suit. This is for the GNU 2370*d5c9a868SElliott Hughes% Press printing of the Emacs 22 manual. Maybe other manuals in the 2371*d5c9a868SElliott Hughes% future. Used with @smallbook, which sets the leading to 12pt. 2372*d5c9a868SElliott Hughes% 2373*d5c9a868SElliott Hughes\def\definetextfontsizex{% 2374*d5c9a868SElliott Hughes% Text fonts (10pt). 2375*d5c9a868SElliott Hughes\def\textnominalsize{10pt} 2376*d5c9a868SElliott Hughes\edef\mainmagstep{1000} 2377*d5c9a868SElliott Hughes\setfont\textrm\rmshape{10}{\mainmagstep}{OT1} 2378*d5c9a868SElliott Hughes\setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT} 2379*d5c9a868SElliott Hughes\setfont\textbf\bfshape{10}{\mainmagstep}{OT1} 2380*d5c9a868SElliott Hughes\setfont\textit\itshape{10}{\mainmagstep}{OT1IT} 2381*d5c9a868SElliott Hughes\setfont\textsl\slshape{10}{\mainmagstep}{OT1} 2382*d5c9a868SElliott Hughes\setfont\textsf\sfshape{10}{\mainmagstep}{OT1} 2383*d5c9a868SElliott Hughes\setfont\textsc\scshape{10}{\mainmagstep}{OT1} 2384*d5c9a868SElliott Hughes\setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT} 2385*d5c9a868SElliott Hughes\font\texti=cmmi10 scaled \mainmagstep 2386*d5c9a868SElliott Hughes\font\textsy=cmsy10 scaled \mainmagstep 2387*d5c9a868SElliott Hughes\def\textecsize{1000} 2388*d5c9a868SElliott Hughes 2389*d5c9a868SElliott Hughes% A few fonts for @defun names and args. 2390*d5c9a868SElliott Hughes\setfont\defbf\bfshape{10}{\magstephalf}{OT1} 2391*d5c9a868SElliott Hughes\setfont\deftt\ttshape{10}{\magstephalf}{OT1TT} 2392*d5c9a868SElliott Hughes\setfont\defsl\slshape{10}{\magstephalf}{OT1} 2393*d5c9a868SElliott Hughes\setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT} 2394*d5c9a868SElliott Hughes\def\df{\let\ttfont=\deftt \let\bffont = \defbf 2395*d5c9a868SElliott Hughes\let\slfont=\defsl \let\ttslfont=\defttsl \bf} 2396*d5c9a868SElliott Hughes 2397*d5c9a868SElliott Hughes% Fonts for indices, footnotes, small examples (9pt). 2398*d5c9a868SElliott Hughes\def\smallnominalsize{9pt} 2399*d5c9a868SElliott Hughes\setfont\smallrm\rmshape{9}{1000}{OT1} 2400*d5c9a868SElliott Hughes\setfont\smalltt\ttshape{9}{1000}{OT1TT} 2401*d5c9a868SElliott Hughes\setfont\smallbf\bfshape{10}{900}{OT1} 2402*d5c9a868SElliott Hughes\setfont\smallit\itshape{9}{1000}{OT1IT} 2403*d5c9a868SElliott Hughes\setfont\smallsl\slshape{9}{1000}{OT1} 2404*d5c9a868SElliott Hughes\setfont\smallsf\sfshape{9}{1000}{OT1} 2405*d5c9a868SElliott Hughes\setfont\smallsc\scshape{10}{900}{OT1} 2406*d5c9a868SElliott Hughes\setfont\smallttsl\ttslshape{10}{900}{OT1TT} 2407*d5c9a868SElliott Hughes\font\smalli=cmmi9 2408*d5c9a868SElliott Hughes\font\smallsy=cmsy9 2409*d5c9a868SElliott Hughes\def\smallecsize{0900} 2410*d5c9a868SElliott Hughes 2411*d5c9a868SElliott Hughes% Fonts for small examples (8pt). 2412*d5c9a868SElliott Hughes\def\smallernominalsize{8pt} 2413*d5c9a868SElliott Hughes\setfont\smallerrm\rmshape{8}{1000}{OT1} 2414*d5c9a868SElliott Hughes\setfont\smallertt\ttshape{8}{1000}{OT1TT} 2415*d5c9a868SElliott Hughes\setfont\smallerbf\bfshape{10}{800}{OT1} 2416*d5c9a868SElliott Hughes\setfont\smallerit\itshape{8}{1000}{OT1IT} 2417*d5c9a868SElliott Hughes\setfont\smallersl\slshape{8}{1000}{OT1} 2418*d5c9a868SElliott Hughes\setfont\smallersf\sfshape{8}{1000}{OT1} 2419*d5c9a868SElliott Hughes\setfont\smallersc\scshape{10}{800}{OT1} 2420*d5c9a868SElliott Hughes\setfont\smallerttsl\ttslshape{10}{800}{OT1TT} 2421*d5c9a868SElliott Hughes\font\smalleri=cmmi8 2422*d5c9a868SElliott Hughes\font\smallersy=cmsy8 2423*d5c9a868SElliott Hughes\def\smallerecsize{0800} 2424*d5c9a868SElliott Hughes 2425*d5c9a868SElliott Hughes% Fonts for math mode superscripts (7pt). 2426*d5c9a868SElliott Hughes\def\sevennominalsize{7pt} 2427*d5c9a868SElliott Hughes\setfont\sevenrm\rmshape{7}{1000}{OT1} 2428*d5c9a868SElliott Hughes\setfont\seventt\ttshape{10}{700}{OT1TT} 2429*d5c9a868SElliott Hughes\setfont\sevenbf\bfshape{10}{700}{OT1} 2430*d5c9a868SElliott Hughes\setfont\sevenit\itshape{7}{1000}{OT1IT} 2431*d5c9a868SElliott Hughes\setfont\sevensl\slshape{10}{700}{OT1} 2432*d5c9a868SElliott Hughes\setfont\sevensf\sfshape{10}{700}{OT1} 2433*d5c9a868SElliott Hughes\setfont\sevensc\scshape{10}{700}{OT1} 2434*d5c9a868SElliott Hughes\setfont\seventtsl\ttslshape{10}{700}{OT1TT} 2435*d5c9a868SElliott Hughes\font\seveni=cmmi7 2436*d5c9a868SElliott Hughes\font\sevensy=cmsy7 2437*d5c9a868SElliott Hughes\def\sevenecsize{0700} 2438*d5c9a868SElliott Hughes 2439*d5c9a868SElliott Hughes% Fonts for title page (20.4pt): 2440*d5c9a868SElliott Hughes\def\titlenominalsize{20pt} 2441*d5c9a868SElliott Hughes\setfont\titlerm\rmbshape{12}{\magstep3}{OT1} 2442*d5c9a868SElliott Hughes\setfont\titleit\itbshape{10}{\magstep4}{OT1IT} 2443*d5c9a868SElliott Hughes\setfont\titlesl\slbshape{10}{\magstep4}{OT1} 2444*d5c9a868SElliott Hughes\setfont\titlett\ttbshape{12}{\magstep3}{OT1TT} 2445*d5c9a868SElliott Hughes\setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT} 2446*d5c9a868SElliott Hughes\setfont\titlesf\sfbshape{17}{\magstep1}{OT1} 2447*d5c9a868SElliott Hughes\let\titlebf=\titlerm 2448*d5c9a868SElliott Hughes\setfont\titlesc\scbshape{10}{\magstep4}{OT1} 2449*d5c9a868SElliott Hughes\font\titlei=cmmi12 scaled \magstep3 2450*d5c9a868SElliott Hughes\font\titlesy=cmsy10 scaled \magstep4 2451*d5c9a868SElliott Hughes\def\titleecsize{2074} 2452*d5c9a868SElliott Hughes 2453*d5c9a868SElliott Hughes% Chapter fonts (14.4pt). 2454*d5c9a868SElliott Hughes\def\chapnominalsize{14pt} 2455*d5c9a868SElliott Hughes\setfont\chaprm\rmbshape{12}{\magstep1}{OT1} 2456*d5c9a868SElliott Hughes\setfont\chapit\itbshape{10}{\magstep2}{OT1IT} 2457*d5c9a868SElliott Hughes\setfont\chapsl\slbshape{10}{\magstep2}{OT1} 2458*d5c9a868SElliott Hughes\setfont\chaptt\ttbshape{12}{\magstep1}{OT1TT} 2459*d5c9a868SElliott Hughes\setfont\chapttsl\ttslshape{10}{\magstep2}{OT1TT} 2460*d5c9a868SElliott Hughes\setfont\chapsf\sfbshape{12}{\magstep1}{OT1} 2461*d5c9a868SElliott Hughes\let\chapbf\chaprm 2462*d5c9a868SElliott Hughes\setfont\chapsc\scbshape{10}{\magstep2}{OT1} 2463*d5c9a868SElliott Hughes\font\chapi=cmmi12 scaled \magstep1 2464*d5c9a868SElliott Hughes\font\chapsy=cmsy10 scaled \magstep2 2465*d5c9a868SElliott Hughes\def\chapecsize{1440} 2466*d5c9a868SElliott Hughes 2467*d5c9a868SElliott Hughes% Section fonts (12pt). 2468*d5c9a868SElliott Hughes\def\secnominalsize{12pt} 2469*d5c9a868SElliott Hughes\setfont\secrm\rmbshape{12}{1000}{OT1} 2470*d5c9a868SElliott Hughes\setfont\secit\itbshape{10}{\magstep1}{OT1IT} 2471*d5c9a868SElliott Hughes\setfont\secsl\slbshape{10}{\magstep1}{OT1} 2472*d5c9a868SElliott Hughes\setfont\sectt\ttbshape{12}{1000}{OT1TT} 2473*d5c9a868SElliott Hughes\setfont\secttsl\ttslshape{10}{\magstep1}{OT1TT} 2474*d5c9a868SElliott Hughes\setfont\secsf\sfbshape{12}{1000}{OT1} 2475*d5c9a868SElliott Hughes\let\secbf\secrm 2476*d5c9a868SElliott Hughes\setfont\secsc\scbshape{10}{\magstep1}{OT1} 2477*d5c9a868SElliott Hughes\font\seci=cmmi12 2478*d5c9a868SElliott Hughes\font\secsy=cmsy10 scaled \magstep1 2479*d5c9a868SElliott Hughes\def\sececsize{1200} 2480*d5c9a868SElliott Hughes 2481*d5c9a868SElliott Hughes% Subsection fonts (10pt). 2482*d5c9a868SElliott Hughes\def\ssecnominalsize{10pt} 2483*d5c9a868SElliott Hughes\setfont\ssecrm\rmbshape{10}{1000}{OT1} 2484*d5c9a868SElliott Hughes\setfont\ssecit\itbshape{10}{1000}{OT1IT} 2485*d5c9a868SElliott Hughes\setfont\ssecsl\slbshape{10}{1000}{OT1} 2486*d5c9a868SElliott Hughes\setfont\ssectt\ttbshape{10}{1000}{OT1TT} 2487*d5c9a868SElliott Hughes\setfont\ssecttsl\ttslshape{10}{1000}{OT1TT} 2488*d5c9a868SElliott Hughes\setfont\ssecsf\sfbshape{10}{1000}{OT1} 2489*d5c9a868SElliott Hughes\let\ssecbf\ssecrm 2490*d5c9a868SElliott Hughes\setfont\ssecsc\scbshape{10}{1000}{OT1} 2491*d5c9a868SElliott Hughes\font\sseci=cmmi10 2492*d5c9a868SElliott Hughes\font\ssecsy=cmsy10 2493*d5c9a868SElliott Hughes\def\ssececsize{1000} 2494*d5c9a868SElliott Hughes 2495*d5c9a868SElliott Hughes% Reduced fonts for @acronym in text (9pt). 2496*d5c9a868SElliott Hughes\def\reducednominalsize{9pt} 2497*d5c9a868SElliott Hughes\setfont\reducedrm\rmshape{9}{1000}{OT1} 2498*d5c9a868SElliott Hughes\setfont\reducedtt\ttshape{9}{1000}{OT1TT} 2499*d5c9a868SElliott Hughes\setfont\reducedbf\bfshape{10}{900}{OT1} 2500*d5c9a868SElliott Hughes\setfont\reducedit\itshape{9}{1000}{OT1IT} 2501*d5c9a868SElliott Hughes\setfont\reducedsl\slshape{9}{1000}{OT1} 2502*d5c9a868SElliott Hughes\setfont\reducedsf\sfshape{9}{1000}{OT1} 2503*d5c9a868SElliott Hughes\setfont\reducedsc\scshape{10}{900}{OT1} 2504*d5c9a868SElliott Hughes\setfont\reducedttsl\ttslshape{10}{900}{OT1TT} 2505*d5c9a868SElliott Hughes\font\reducedi=cmmi9 2506*d5c9a868SElliott Hughes\font\reducedsy=cmsy9 2507*d5c9a868SElliott Hughes\def\reducedecsize{0900} 2508*d5c9a868SElliott Hughes 2509*d5c9a868SElliott Hughes\divide\parskip by 2 % reduce space between paragraphs 2510*d5c9a868SElliott Hughes\textleading = 12pt % line spacing for 10pt CM 2511*d5c9a868SElliott Hughes\textfonts % reset the current fonts 2512*d5c9a868SElliott Hughes\rm 2513*d5c9a868SElliott Hughes} % end of 10pt text font size definitions, \definetextfontsizex 2514*d5c9a868SElliott Hughes 2515*d5c9a868SElliott Hughes% Fonts for short table of contents. 2516*d5c9a868SElliott Hughes\setfont\shortcontrm\rmshape{12}{1000}{OT1} 2517*d5c9a868SElliott Hughes\setfont\shortcontbf\bfshape{10}{\magstep1}{OT1} % no cmb12 2518*d5c9a868SElliott Hughes\setfont\shortcontsl\slshape{12}{1000}{OT1} 2519*d5c9a868SElliott Hughes\setfont\shortconttt\ttshape{12}{1000}{OT1TT} 2520*d5c9a868SElliott Hughes 2521*d5c9a868SElliott Hughes 2522*d5c9a868SElliott Hughes% We provide the user-level command 2523*d5c9a868SElliott Hughes% @fonttextsize 10 2524*d5c9a868SElliott Hughes% (or 11) to redefine the text font size. pt is assumed. 2525*d5c9a868SElliott Hughes% 2526*d5c9a868SElliott Hughes\def\xiword{11} 2527*d5c9a868SElliott Hughes\def\xword{10} 2528*d5c9a868SElliott Hughes\def\xwordpt{10pt} 2529*d5c9a868SElliott Hughes% 2530*d5c9a868SElliott Hughes\parseargdef\fonttextsize{% 2531*d5c9a868SElliott Hughes \def\textsizearg{#1}% 2532*d5c9a868SElliott Hughes %\wlog{doing @fonttextsize \textsizearg}% 2533*d5c9a868SElliott Hughes % 2534*d5c9a868SElliott Hughes % Set \globaldefs so that documents can use this inside @tex, since 2535*d5c9a868SElliott Hughes % makeinfo 4.8 does not support it, but we need it nonetheless. 2536*d5c9a868SElliott Hughes % 2537*d5c9a868SElliott Hughes \begingroup \globaldefs=1 2538*d5c9a868SElliott Hughes \ifx\textsizearg\xword \definetextfontsizex 2539*d5c9a868SElliott Hughes \else \ifx\textsizearg\xiword \definetextfontsizexi 2540*d5c9a868SElliott Hughes \else 2541*d5c9a868SElliott Hughes \errhelp=\EMsimple 2542*d5c9a868SElliott Hughes \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'} 2543*d5c9a868SElliott Hughes \fi\fi 2544*d5c9a868SElliott Hughes \endgroup 2545*d5c9a868SElliott Hughes} 2546*d5c9a868SElliott Hughes 2547*d5c9a868SElliott Hughes% 2548*d5c9a868SElliott Hughes% Change the current font style to #1, remembering it in \curfontstyle. 2549*d5c9a868SElliott Hughes% For now, we do not accumulate font styles: @b{@i{foo}} prints foo in 2550*d5c9a868SElliott Hughes% italics, not bold italics. 2551*d5c9a868SElliott Hughes% 2552*d5c9a868SElliott Hughes\def\setfontstyle#1{% 2553*d5c9a868SElliott Hughes \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd. 2554*d5c9a868SElliott Hughes \csname #1font\endcsname % change the current font 2555*d5c9a868SElliott Hughes} 2556*d5c9a868SElliott Hughes 2557*d5c9a868SElliott Hughes\def\rm{\fam=0 \setfontstyle{rm}} 2558*d5c9a868SElliott Hughes\def\it{\fam=\itfam \setfontstyle{it}} 2559*d5c9a868SElliott Hughes\def\sl{\fam=\slfam \setfontstyle{sl}} 2560*d5c9a868SElliott Hughes\def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf} 2561*d5c9a868SElliott Hughes\def\tt{\fam=\ttfam \setfontstyle{tt}}\def\ttstylename{tt} 2562*d5c9a868SElliott Hughes 2563*d5c9a868SElliott Hughes% Texinfo sort of supports the sans serif font style, which plain TeX does not. 2564*d5c9a868SElliott Hughes% So we set up a \sf. 2565*d5c9a868SElliott Hughes\newfam\sffam 2566*d5c9a868SElliott Hughes\def\sf{\fam=\sffam \setfontstyle{sf}} 2567*d5c9a868SElliott Hughes 2568*d5c9a868SElliott Hughes% We don't need math for this font style. 2569*d5c9a868SElliott Hughes\def\ttsl{\setfontstyle{ttsl}} 2570*d5c9a868SElliott Hughes 2571*d5c9a868SElliott Hughes 2572*d5c9a868SElliott Hughes% In order for the font changes to affect most math symbols and letters, 2573*d5c9a868SElliott Hughes% we have to define the \textfont of the standard families. 2574*d5c9a868SElliott Hughes% We don't bother to reset \scriptscriptfont; awaiting user need. 2575*d5c9a868SElliott Hughes% 2576*d5c9a868SElliott Hughes\def\resetmathfonts{% 2577*d5c9a868SElliott Hughes \textfont0=\rmfont \textfont1=\ifont \textfont2=\syfont 2578*d5c9a868SElliott Hughes \textfont\itfam=\itfont \textfont\slfam=\slfont \textfont\bffam=\bffont 2579*d5c9a868SElliott Hughes \textfont\ttfam=\ttfont \textfont\sffam=\sffont 2580*d5c9a868SElliott Hughes % 2581*d5c9a868SElliott Hughes % Fonts for superscript. Note that the 7pt fonts are used regardless 2582*d5c9a868SElliott Hughes % of the current font size. 2583*d5c9a868SElliott Hughes \scriptfont0=\sevenrm \scriptfont1=\seveni \scriptfont2=\sevensy 2584*d5c9a868SElliott Hughes \scriptfont\itfam=\sevenit \scriptfont\slfam=\sevensl 2585*d5c9a868SElliott Hughes \scriptfont\bffam=\sevenbf \scriptfont\ttfam=\seventt 2586*d5c9a868SElliott Hughes \scriptfont\sffam=\sevensf 2587*d5c9a868SElliott Hughes} 2588*d5c9a868SElliott Hughes 2589*d5c9a868SElliott Hughes% 2590*d5c9a868SElliott Hughes 2591*d5c9a868SElliott Hughes% The font-changing commands (all called \...fonts) redefine the meanings 2592*d5c9a868SElliott Hughes% of \STYLEfont, instead of just \STYLE. We do this because \STYLE needs 2593*d5c9a868SElliott Hughes% to also set the current \fam for math mode. Our \STYLE (e.g., \rm) 2594*d5c9a868SElliott Hughes% commands hardwire \STYLEfont to set the current font. 2595*d5c9a868SElliott Hughes% 2596*d5c9a868SElliott Hughes% The fonts used for \ifont are for "math italics" (\itfont is for italics 2597*d5c9a868SElliott Hughes% in regular text). \syfont is also used in math mode only. 2598*d5c9a868SElliott Hughes% 2599*d5c9a868SElliott Hughes% Each font-changing command also sets the names \lsize (one size lower) 2600*d5c9a868SElliott Hughes% and \lllsize (three sizes lower). These relative commands are used 2601*d5c9a868SElliott Hughes% in, e.g., the LaTeX logo and acronyms. 2602*d5c9a868SElliott Hughes% 2603*d5c9a868SElliott Hughes% This all needs generalizing, badly. 2604*d5c9a868SElliott Hughes% 2605*d5c9a868SElliott Hughes 2606*d5c9a868SElliott Hughes\def\assignfonts#1{% 2607*d5c9a868SElliott Hughes \expandafter\let\expandafter\rmfont\csname #1rm\endcsname 2608*d5c9a868SElliott Hughes \expandafter\let\expandafter\itfont\csname #1it\endcsname 2609*d5c9a868SElliott Hughes \expandafter\let\expandafter\slfont\csname #1sl\endcsname 2610*d5c9a868SElliott Hughes \expandafter\let\expandafter\bffont\csname #1bf\endcsname 2611*d5c9a868SElliott Hughes \expandafter\let\expandafter\ttfont\csname #1tt\endcsname 2612*d5c9a868SElliott Hughes \expandafter\let\expandafter\smallcaps\csname #1sc\endcsname 2613*d5c9a868SElliott Hughes \expandafter\let\expandafter\sffont \csname #1sf\endcsname 2614*d5c9a868SElliott Hughes \expandafter\let\expandafter\ifont \csname #1i\endcsname 2615*d5c9a868SElliott Hughes \expandafter\let\expandafter\syfont \csname #1sy\endcsname 2616*d5c9a868SElliott Hughes \expandafter\let\expandafter\ttslfont\csname #1ttsl\endcsname 2617*d5c9a868SElliott Hughes} 2618*d5c9a868SElliott Hughes 2619*d5c9a868SElliott Hughes\newif\ifrmisbold 2620*d5c9a868SElliott Hughes 2621*d5c9a868SElliott Hughes% Select smaller font size with the current style. Used to change font size 2622*d5c9a868SElliott Hughes% in, e.g., the LaTeX logo and acronyms. If we are using bold fonts for 2623*d5c9a868SElliott Hughes% normal roman text, also use bold fonts for roman text in the smaller size. 2624*d5c9a868SElliott Hughes\def\switchtolllsize{% 2625*d5c9a868SElliott Hughes \expandafter\assignfonts\expandafter{\lllsize}% 2626*d5c9a868SElliott Hughes \ifrmisbold 2627*d5c9a868SElliott Hughes \let\rmfont\bffont 2628*d5c9a868SElliott Hughes \fi 2629*d5c9a868SElliott Hughes \csname\curfontstyle\endcsname 2630*d5c9a868SElliott Hughes}% 2631*d5c9a868SElliott Hughes 2632*d5c9a868SElliott Hughes\def\switchtolsize{% 2633*d5c9a868SElliott Hughes \expandafter\assignfonts\expandafter{\lsize}% 2634*d5c9a868SElliott Hughes \ifrmisbold 2635*d5c9a868SElliott Hughes \let\rmfont\bffont 2636*d5c9a868SElliott Hughes \fi 2637*d5c9a868SElliott Hughes \csname\curfontstyle\endcsname 2638*d5c9a868SElliott Hughes}% 2639*d5c9a868SElliott Hughes 2640*d5c9a868SElliott Hughes\def\definefontsetatsize#1#2#3#4#5{% 2641*d5c9a868SElliott Hughes\expandafter\def\csname #1fonts\endcsname{% 2642*d5c9a868SElliott Hughes \def\curfontsize{#1}% 2643*d5c9a868SElliott Hughes \def\lsize{#2}\def\lllsize{#3}% 2644*d5c9a868SElliott Hughes \csname rmisbold#5\endcsname 2645*d5c9a868SElliott Hughes \assignfonts{#1}% 2646*d5c9a868SElliott Hughes \resetmathfonts 2647*d5c9a868SElliott Hughes \setleading{#4}% 2648*d5c9a868SElliott Hughes}} 2649*d5c9a868SElliott Hughes 2650*d5c9a868SElliott Hughes\definefontsetatsize{text} {reduced}{smaller}{\textleading}{false} 2651*d5c9a868SElliott Hughes\definefontsetatsize{title} {chap} {subsec} {27pt} {true} 2652*d5c9a868SElliott Hughes\definefontsetatsize{chap} {sec} {text} {19pt} {true} 2653*d5c9a868SElliott Hughes\definefontsetatsize{sec} {subsec} {reduced}{17pt} {true} 2654*d5c9a868SElliott Hughes\definefontsetatsize{ssec} {text} {small} {15pt} {true} 2655*d5c9a868SElliott Hughes\definefontsetatsize{reduced}{small} {smaller}{10.5pt}{false} 2656*d5c9a868SElliott Hughes\definefontsetatsize{small} {smaller}{smaller}{10.5pt}{false} 2657*d5c9a868SElliott Hughes\definefontsetatsize{smaller}{smaller}{smaller}{9.5pt} {false} 2658*d5c9a868SElliott Hughes 2659*d5c9a868SElliott Hughes\def\titlefont#1{{\titlefonts\rm #1}} 2660*d5c9a868SElliott Hughes\let\subsecfonts = \ssecfonts 2661*d5c9a868SElliott Hughes\let\subsubsecfonts = \ssecfonts 2662*d5c9a868SElliott Hughes 2663*d5c9a868SElliott Hughes% Define these just so they can be easily changed for other fonts. 2664*d5c9a868SElliott Hughes\def\angleleft{$\langle$} 2665*d5c9a868SElliott Hughes\def\angleright{$\rangle$} 2666*d5c9a868SElliott Hughes 2667*d5c9a868SElliott Hughes% Set the fonts to use with the @small... environments. 2668*d5c9a868SElliott Hughes\let\smallexamplefonts = \smallfonts 2669*d5c9a868SElliott Hughes 2670*d5c9a868SElliott Hughes% About \smallexamplefonts. If we use \smallfonts (9pt), @smallexample 2671*d5c9a868SElliott Hughes% can fit this many characters: 2672*d5c9a868SElliott Hughes% 8.5x11=86 smallbook=72 a4=90 a5=69 2673*d5c9a868SElliott Hughes% If we use \scriptfonts (8pt), then we can fit this many characters: 2674*d5c9a868SElliott Hughes% 8.5x11=90+ smallbook=80 a4=90+ a5=77 2675*d5c9a868SElliott Hughes% For me, subjectively, the few extra characters that fit aren't worth 2676*d5c9a868SElliott Hughes% the additional smallness of 8pt. So I'm making the default 9pt. 2677*d5c9a868SElliott Hughes% 2678*d5c9a868SElliott Hughes% By the way, for comparison, here's what fits with @example (10pt): 2679*d5c9a868SElliott Hughes% 8.5x11=71 smallbook=60 a4=75 a5=58 2680*d5c9a868SElliott Hughes% --karl, 24jan03. 2681*d5c9a868SElliott Hughes 2682*d5c9a868SElliott Hughes% Set up the default fonts, so we can use them for creating boxes. 2683*d5c9a868SElliott Hughes% 2684*d5c9a868SElliott Hughes\definetextfontsizexi 2685*d5c9a868SElliott Hughes 2686*d5c9a868SElliott Hughes 2687*d5c9a868SElliott Hughes% Check if we are currently using a typewriter font. Since all the 2688*d5c9a868SElliott Hughes% Computer Modern typewriter fonts have zero interword stretch (and 2689*d5c9a868SElliott Hughes% shrink), and it is reasonable to expect all typewriter fonts to have 2690*d5c9a868SElliott Hughes% this property, we can check that font parameter. 2691*d5c9a868SElliott Hughes% 2692*d5c9a868SElliott Hughes\def\ifmonospace{\ifdim\fontdimen3\font=0pt } 2693*d5c9a868SElliott Hughes 2694*d5c9a868SElliott Hughes{ 2695*d5c9a868SElliott Hughes\catcode`\'=\active 2696*d5c9a868SElliott Hughes\catcode`\`=\active 2697*d5c9a868SElliott Hughes 2698*d5c9a868SElliott Hughes\gdef\setcodequotes{\let`\codequoteleft \let'\codequoteright} 2699*d5c9a868SElliott Hughes\gdef\setregularquotes{\let`\lq \let'\rq} 2700*d5c9a868SElliott Hughes} 2701*d5c9a868SElliott Hughes 2702*d5c9a868SElliott Hughes% Allow an option to not use regular directed right quote/apostrophe 2703*d5c9a868SElliott Hughes% (char 0x27), but instead the undirected quote from cmtt (char 0x0d). 2704*d5c9a868SElliott Hughes% The undirected quote is ugly, so don't make it the default, but it 2705*d5c9a868SElliott Hughes% works for pasting with more pdf viewers (at least evince), the 2706*d5c9a868SElliott Hughes% lilypond developers report. xpdf does work with the regular 0x27. 2707*d5c9a868SElliott Hughes% 2708*d5c9a868SElliott Hughes\def\codequoteright{% 2709*d5c9a868SElliott Hughes \ifmonospace 2710*d5c9a868SElliott Hughes \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax 2711*d5c9a868SElliott Hughes \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax 2712*d5c9a868SElliott Hughes '% 2713*d5c9a868SElliott Hughes \else \char'15 \fi 2714*d5c9a868SElliott Hughes \else \char'15 \fi 2715*d5c9a868SElliott Hughes \else 2716*d5c9a868SElliott Hughes '% 2717*d5c9a868SElliott Hughes \fi 2718*d5c9a868SElliott Hughes} 2719*d5c9a868SElliott Hughes% 2720*d5c9a868SElliott Hughes% and a similar option for the left quote char vs. a grave accent. 2721*d5c9a868SElliott Hughes% Modern fonts display ASCII 0x60 as a grave accent, so some people like 2722*d5c9a868SElliott Hughes% the code environments to do likewise. 2723*d5c9a868SElliott Hughes% 2724*d5c9a868SElliott Hughes\def\codequoteleft{% 2725*d5c9a868SElliott Hughes \ifmonospace 2726*d5c9a868SElliott Hughes \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax 2727*d5c9a868SElliott Hughes \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax 2728*d5c9a868SElliott Hughes % [Knuth] pp. 380,381,391 2729*d5c9a868SElliott Hughes % \relax disables Spanish ligatures ?` and !` of \tt font. 2730*d5c9a868SElliott Hughes \relax`% 2731*d5c9a868SElliott Hughes \else \char'22 \fi 2732*d5c9a868SElliott Hughes \else \char'22 \fi 2733*d5c9a868SElliott Hughes \else 2734*d5c9a868SElliott Hughes \relax`% 2735*d5c9a868SElliott Hughes \fi 2736*d5c9a868SElliott Hughes} 2737*d5c9a868SElliott Hughes 2738*d5c9a868SElliott Hughes% Commands to set the quote options. 2739*d5c9a868SElliott Hughes% 2740*d5c9a868SElliott Hughes\parseargdef\codequoteundirected{% 2741*d5c9a868SElliott Hughes \def\temp{#1}% 2742*d5c9a868SElliott Hughes \ifx\temp\onword 2743*d5c9a868SElliott Hughes \expandafter\let\csname SETtxicodequoteundirected\endcsname 2744*d5c9a868SElliott Hughes = t% 2745*d5c9a868SElliott Hughes \else\ifx\temp\offword 2746*d5c9a868SElliott Hughes \expandafter\let\csname SETtxicodequoteundirected\endcsname 2747*d5c9a868SElliott Hughes = \relax 2748*d5c9a868SElliott Hughes \else 2749*d5c9a868SElliott Hughes \errhelp = \EMsimple 2750*d5c9a868SElliott Hughes \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}% 2751*d5c9a868SElliott Hughes \fi\fi 2752*d5c9a868SElliott Hughes} 2753*d5c9a868SElliott Hughes% 2754*d5c9a868SElliott Hughes\parseargdef\codequotebacktick{% 2755*d5c9a868SElliott Hughes \def\temp{#1}% 2756*d5c9a868SElliott Hughes \ifx\temp\onword 2757*d5c9a868SElliott Hughes \expandafter\let\csname SETtxicodequotebacktick\endcsname 2758*d5c9a868SElliott Hughes = t% 2759*d5c9a868SElliott Hughes \else\ifx\temp\offword 2760*d5c9a868SElliott Hughes \expandafter\let\csname SETtxicodequotebacktick\endcsname 2761*d5c9a868SElliott Hughes = \relax 2762*d5c9a868SElliott Hughes \else 2763*d5c9a868SElliott Hughes \errhelp = \EMsimple 2764*d5c9a868SElliott Hughes \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}% 2765*d5c9a868SElliott Hughes \fi\fi 2766*d5c9a868SElliott Hughes} 2767*d5c9a868SElliott Hughes 2768*d5c9a868SElliott Hughes% [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font. 2769*d5c9a868SElliott Hughes\def\noligaturesquoteleft{\relax\lq} 2770*d5c9a868SElliott Hughes 2771*d5c9a868SElliott Hughes% Count depth in font-changes, for error checks 2772*d5c9a868SElliott Hughes\newcount\fontdepth \fontdepth=0 2773*d5c9a868SElliott Hughes 2774*d5c9a868SElliott Hughes% Font commands. 2775*d5c9a868SElliott Hughes 2776*d5c9a868SElliott Hughes% #1 is the font command (\sl or \it), #2 is the text to slant. 2777*d5c9a868SElliott Hughes% If we are in a monospaced environment, however, 1) always use \ttsl, 2778*d5c9a868SElliott Hughes% and 2) do not add an italic correction. 2779*d5c9a868SElliott Hughes\def\dosmartslant#1#2{% 2780*d5c9a868SElliott Hughes \ifusingtt 2781*d5c9a868SElliott Hughes {{\ttsl #2}\let\next=\relax}% 2782*d5c9a868SElliott Hughes {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}% 2783*d5c9a868SElliott Hughes \next 2784*d5c9a868SElliott Hughes} 2785*d5c9a868SElliott Hughes\def\smartslanted{\dosmartslant\sl} 2786*d5c9a868SElliott Hughes\def\smartitalic{\dosmartslant\it} 2787*d5c9a868SElliott Hughes 2788*d5c9a868SElliott Hughes% Output an italic correction unless \next (presumed to be the following 2789*d5c9a868SElliott Hughes% character) is such as not to need one. 2790*d5c9a868SElliott Hughes\def\smartitaliccorrection{% 2791*d5c9a868SElliott Hughes \ifx\next,% 2792*d5c9a868SElliott Hughes \else\ifx\next-% 2793*d5c9a868SElliott Hughes \else\ifx\next.% 2794*d5c9a868SElliott Hughes \else\ifx\next\.% 2795*d5c9a868SElliott Hughes \else\ifx\next\comma% 2796*d5c9a868SElliott Hughes \else\ptexslash 2797*d5c9a868SElliott Hughes \fi\fi\fi\fi\fi 2798*d5c9a868SElliott Hughes \aftersmartic 2799*d5c9a868SElliott Hughes} 2800*d5c9a868SElliott Hughes 2801*d5c9a868SElliott Hughes% Unconditional use \ttsl, and no ic. @var is set to this for defuns. 2802*d5c9a868SElliott Hughes\def\ttslanted#1{{\ttsl #1}} 2803*d5c9a868SElliott Hughes 2804*d5c9a868SElliott Hughes% @cite is like \smartslanted except unconditionally use \sl. We never want 2805*d5c9a868SElliott Hughes% ttsl for book titles, do we? 2806*d5c9a868SElliott Hughes\def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection} 2807*d5c9a868SElliott Hughes 2808*d5c9a868SElliott Hughes\def\aftersmartic{} 2809*d5c9a868SElliott Hughes\def\var#1{% 2810*d5c9a868SElliott Hughes \let\saveaftersmartic = \aftersmartic 2811*d5c9a868SElliott Hughes \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}% 2812*d5c9a868SElliott Hughes \smartslanted{#1}% 2813*d5c9a868SElliott Hughes} 2814*d5c9a868SElliott Hughes 2815*d5c9a868SElliott Hughes\let\i=\smartitalic 2816*d5c9a868SElliott Hughes\let\slanted=\smartslanted 2817*d5c9a868SElliott Hughes\let\dfn=\smartslanted 2818*d5c9a868SElliott Hughes\let\emph=\smartitalic 2819*d5c9a868SElliott Hughes 2820*d5c9a868SElliott Hughes% Explicit font changes: @r, @sc, undocumented @ii. 2821*d5c9a868SElliott Hughes\def\r#1{{\rm #1}} % roman font 2822*d5c9a868SElliott Hughes\def\sc#1{{\smallcaps#1}} % smallcaps font 2823*d5c9a868SElliott Hughes\def\ii#1{{\it #1}} % italic font 2824*d5c9a868SElliott Hughes 2825*d5c9a868SElliott Hughes% @b, explicit bold. Also @strong. 2826*d5c9a868SElliott Hughes\def\b#1{{\bf #1}} 2827*d5c9a868SElliott Hughes\let\strong=\b 2828*d5c9a868SElliott Hughes 2829*d5c9a868SElliott Hughes% @sansserif, explicit sans. 2830*d5c9a868SElliott Hughes\def\sansserif#1{{\sf #1}} 2831*d5c9a868SElliott Hughes 2832*d5c9a868SElliott Hughes% We can't just use \exhyphenpenalty, because that only has effect at 2833*d5c9a868SElliott Hughes% the end of a paragraph. Restore normal hyphenation at the end of the 2834*d5c9a868SElliott Hughes% group within which \nohyphenation is presumably called. 2835*d5c9a868SElliott Hughes% 2836*d5c9a868SElliott Hughes\def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation} 2837*d5c9a868SElliott Hughes\def\restorehyphenation{\hyphenchar\font = `- } 2838*d5c9a868SElliott Hughes 2839*d5c9a868SElliott Hughes% Set sfcode to normal for the chars that usually have another value. 2840*d5c9a868SElliott Hughes% Can't use plain's \frenchspacing because it uses the `\x notation, and 2841*d5c9a868SElliott Hughes% sometimes \x has an active definition that messes things up. 2842*d5c9a868SElliott Hughes% 2843*d5c9a868SElliott Hughes\catcode`@=11 2844*d5c9a868SElliott Hughes \def\plainfrenchspacing{% 2845*d5c9a868SElliott Hughes \sfcode`\.=\@m \sfcode`\?=\@m \sfcode`\!=\@m 2846*d5c9a868SElliott Hughes \sfcode`\:=\@m \sfcode`\;=\@m \sfcode`\,=\@m 2847*d5c9a868SElliott Hughes \def\endofsentencespacefactor{1000}% for @. and friends 2848*d5c9a868SElliott Hughes } 2849*d5c9a868SElliott Hughes \def\plainnonfrenchspacing{% 2850*d5c9a868SElliott Hughes \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000 2851*d5c9a868SElliott Hughes \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250 2852*d5c9a868SElliott Hughes \def\endofsentencespacefactor{3000}% for @. and friends 2853*d5c9a868SElliott Hughes } 2854*d5c9a868SElliott Hughes\catcode`@=\other 2855*d5c9a868SElliott Hughes\def\endofsentencespacefactor{3000}% default 2856*d5c9a868SElliott Hughes 2857*d5c9a868SElliott Hughes% @t, explicit typewriter. 2858*d5c9a868SElliott Hughes\def\t#1{% 2859*d5c9a868SElliott Hughes {\tt \plainfrenchspacing #1}% 2860*d5c9a868SElliott Hughes \null 2861*d5c9a868SElliott Hughes} 2862*d5c9a868SElliott Hughes 2863*d5c9a868SElliott Hughes% @samp. 2864*d5c9a868SElliott Hughes\def\samp#1{{\setcodequotes\lq\tclose{#1}\rq\null}} 2865*d5c9a868SElliott Hughes 2866*d5c9a868SElliott Hughes% @indicateurl is \samp, that is, with quotes. 2867*d5c9a868SElliott Hughes\let\indicateurl=\samp 2868*d5c9a868SElliott Hughes 2869*d5c9a868SElliott Hughes% @code (and similar) prints in typewriter, but with spaces the same 2870*d5c9a868SElliott Hughes% size as normal in the surrounding text, without hyphenation, etc. 2871*d5c9a868SElliott Hughes% This is a subroutine for that. 2872*d5c9a868SElliott Hughes\def\tclose#1{% 2873*d5c9a868SElliott Hughes {% 2874*d5c9a868SElliott Hughes % Change normal interword space to be same as for the current font. 2875*d5c9a868SElliott Hughes \spaceskip = \fontdimen2\font 2876*d5c9a868SElliott Hughes % 2877*d5c9a868SElliott Hughes % Switch to typewriter. 2878*d5c9a868SElliott Hughes \tt 2879*d5c9a868SElliott Hughes % 2880*d5c9a868SElliott Hughes % But `\ ' produces the large typewriter interword space. 2881*d5c9a868SElliott Hughes \def\ {{\spaceskip = 0pt{} }}% 2882*d5c9a868SElliott Hughes % 2883*d5c9a868SElliott Hughes % Turn off hyphenation. 2884*d5c9a868SElliott Hughes \nohyphenation 2885*d5c9a868SElliott Hughes % 2886*d5c9a868SElliott Hughes \plainfrenchspacing 2887*d5c9a868SElliott Hughes #1% 2888*d5c9a868SElliott Hughes }% 2889*d5c9a868SElliott Hughes \null % reset spacefactor to 1000 2890*d5c9a868SElliott Hughes} 2891*d5c9a868SElliott Hughes 2892*d5c9a868SElliott Hughes% We *must* turn on hyphenation at `-' and `_' in @code. 2893*d5c9a868SElliott Hughes% (But see \codedashfinish below.) 2894*d5c9a868SElliott Hughes% Otherwise, it is too hard to avoid overfull hboxes 2895*d5c9a868SElliott Hughes% in the Emacs manual, the Library manual, etc. 2896*d5c9a868SElliott Hughes% 2897*d5c9a868SElliott Hughes% Unfortunately, TeX uses one parameter (\hyphenchar) to control 2898*d5c9a868SElliott Hughes% both hyphenation at - and hyphenation within words. 2899*d5c9a868SElliott Hughes% We must therefore turn them both off (\tclose does that) 2900*d5c9a868SElliott Hughes% and arrange explicitly to hyphenate at a dash. -- rms. 2901*d5c9a868SElliott Hughes{ 2902*d5c9a868SElliott Hughes \catcode`\-=\active \catcode`\_=\active 2903*d5c9a868SElliott Hughes \catcode`\'=\active \catcode`\`=\active 2904*d5c9a868SElliott Hughes \global\let'=\rq \global\let`=\lq % default definitions 2905*d5c9a868SElliott Hughes % 2906*d5c9a868SElliott Hughes \global\def\code{\begingroup 2907*d5c9a868SElliott Hughes \setcodequotes 2908*d5c9a868SElliott Hughes \catcode\dashChar=\active \catcode\underChar=\active 2909*d5c9a868SElliott Hughes \ifallowcodebreaks 2910*d5c9a868SElliott Hughes \let-\codedash 2911*d5c9a868SElliott Hughes \let_\codeunder 2912*d5c9a868SElliott Hughes \else 2913*d5c9a868SElliott Hughes \let-\normaldash 2914*d5c9a868SElliott Hughes \let_\realunder 2915*d5c9a868SElliott Hughes \fi 2916*d5c9a868SElliott Hughes % Given -foo (with a single dash), we do not want to allow a break 2917*d5c9a868SElliott Hughes % after the hyphen. 2918*d5c9a868SElliott Hughes \global\let\codedashprev=\codedash 2919*d5c9a868SElliott Hughes % 2920*d5c9a868SElliott Hughes \codex 2921*d5c9a868SElliott Hughes } 2922*d5c9a868SElliott Hughes % 2923*d5c9a868SElliott Hughes \gdef\codedash{\futurelet\next\codedashfinish} 2924*d5c9a868SElliott Hughes \gdef\codedashfinish{% 2925*d5c9a868SElliott Hughes \normaldash % always output the dash character itself. 2926*d5c9a868SElliott Hughes % 2927*d5c9a868SElliott Hughes % Now, output a discretionary to allow a line break, unless 2928*d5c9a868SElliott Hughes % (a) the next character is a -, or 2929*d5c9a868SElliott Hughes % (b) the preceding character is a -. 2930*d5c9a868SElliott Hughes % E.g., given --posix, we do not want to allow a break after either -. 2931*d5c9a868SElliott Hughes % Given --foo-bar, we do want to allow a break between the - and the b. 2932*d5c9a868SElliott Hughes \ifx\next\codedash \else 2933*d5c9a868SElliott Hughes \ifx\codedashprev\codedash 2934*d5c9a868SElliott Hughes \else \discretionary{}{}{}\fi 2935*d5c9a868SElliott Hughes \fi 2936*d5c9a868SElliott Hughes % we need the space after the = for the case when \next itself is a 2937*d5c9a868SElliott Hughes % space token; it would get swallowed otherwise. As in @code{- a}. 2938*d5c9a868SElliott Hughes \global\let\codedashprev= \next 2939*d5c9a868SElliott Hughes } 2940*d5c9a868SElliott Hughes} 2941*d5c9a868SElliott Hughes\def\normaldash{-} 2942*d5c9a868SElliott Hughes% 2943*d5c9a868SElliott Hughes\def\codex #1{\tclose{#1}\endgroup} 2944*d5c9a868SElliott Hughes 2945*d5c9a868SElliott Hughes\def\codeunder{% 2946*d5c9a868SElliott Hughes % this is all so @math{@code{var_name}+1} can work. In math mode, _ 2947*d5c9a868SElliott Hughes % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.) 2948*d5c9a868SElliott Hughes % will therefore expand the active definition of _, which is us 2949*d5c9a868SElliott Hughes % (inside @code that is), therefore an endless loop. 2950*d5c9a868SElliott Hughes \ifusingtt{\ifmmode 2951*d5c9a868SElliott Hughes \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_. 2952*d5c9a868SElliott Hughes \else\normalunderscore \fi 2953*d5c9a868SElliott Hughes \discretionary{}{}{}}% 2954*d5c9a868SElliott Hughes {\_}% 2955*d5c9a868SElliott Hughes} 2956*d5c9a868SElliott Hughes 2957*d5c9a868SElliott Hughes% An additional complication: the above will allow breaks after, e.g., 2958*d5c9a868SElliott Hughes% each of the four underscores in __typeof__. This is bad. 2959*d5c9a868SElliott Hughes% @allowcodebreaks provides a document-level way to turn breaking at - 2960*d5c9a868SElliott Hughes% and _ on and off. 2961*d5c9a868SElliott Hughes% 2962*d5c9a868SElliott Hughes\newif\ifallowcodebreaks \allowcodebreakstrue 2963*d5c9a868SElliott Hughes 2964*d5c9a868SElliott Hughes\def\keywordtrue{true} 2965*d5c9a868SElliott Hughes\def\keywordfalse{false} 2966*d5c9a868SElliott Hughes 2967*d5c9a868SElliott Hughes\parseargdef\allowcodebreaks{% 2968*d5c9a868SElliott Hughes \def\txiarg{#1}% 2969*d5c9a868SElliott Hughes \ifx\txiarg\keywordtrue 2970*d5c9a868SElliott Hughes \allowcodebreakstrue 2971*d5c9a868SElliott Hughes \else\ifx\txiarg\keywordfalse 2972*d5c9a868SElliott Hughes \allowcodebreaksfalse 2973*d5c9a868SElliott Hughes \else 2974*d5c9a868SElliott Hughes \errhelp = \EMsimple 2975*d5c9a868SElliott Hughes \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}% 2976*d5c9a868SElliott Hughes \fi\fi 2977*d5c9a868SElliott Hughes} 2978*d5c9a868SElliott Hughes 2979*d5c9a868SElliott Hughes% For @command, @env, @file, @option quotes seem unnecessary, 2980*d5c9a868SElliott Hughes% so use \code rather than \samp. 2981*d5c9a868SElliott Hughes\let\command=\code 2982*d5c9a868SElliott Hughes\let\env=\code 2983*d5c9a868SElliott Hughes\let\file=\code 2984*d5c9a868SElliott Hughes\let\option=\code 2985*d5c9a868SElliott Hughes 2986*d5c9a868SElliott Hughes% @uref (abbreviation for `urlref') aka @url takes an optional 2987*d5c9a868SElliott Hughes% (comma-separated) second argument specifying the text to display and 2988*d5c9a868SElliott Hughes% an optional third arg as text to display instead of (rather than in 2989*d5c9a868SElliott Hughes% addition to) the url itself. First (mandatory) arg is the url. 2990*d5c9a868SElliott Hughes 2991*d5c9a868SElliott Hughes% TeX-only option to allow changing PDF output to show only the second 2992*d5c9a868SElliott Hughes% arg (if given), and not the url (which is then just the link target). 2993*d5c9a868SElliott Hughes\newif\ifurefurlonlylink 2994*d5c9a868SElliott Hughes 2995*d5c9a868SElliott Hughes% The default \pretolerance setting stops the penalty inserted in 2996*d5c9a868SElliott Hughes% \urefallowbreak being a discouragement to line breaking. Set it to 2997*d5c9a868SElliott Hughes% a negative value for this paragraph only. Hopefully this does not 2998*d5c9a868SElliott Hughes% conflict with redefinitions of \par done elsewhere. 2999*d5c9a868SElliott Hughes\def\nopretolerance{% 3000*d5c9a868SElliott Hughes\pretolerance=-1 3001*d5c9a868SElliott Hughes\def\par{\endgraf\pretolerance=100 \let\par\endgraf}% 3002*d5c9a868SElliott Hughes} 3003*d5c9a868SElliott Hughes 3004*d5c9a868SElliott Hughes% The main macro is \urefbreak, which allows breaking at expected 3005*d5c9a868SElliott Hughes% places within the url. 3006*d5c9a868SElliott Hughes\def\urefbreak{\nopretolerance \begingroup \urefcatcodes \dourefbreak} 3007*d5c9a868SElliott Hughes\let\uref=\urefbreak 3008*d5c9a868SElliott Hughes% 3009*d5c9a868SElliott Hughes\def\dourefbreak#1{\urefbreakfinish #1,,,\finish} 3010*d5c9a868SElliott Hughes\def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example 3011*d5c9a868SElliott Hughes \unsepspaces 3012*d5c9a868SElliott Hughes \pdfurl{#1}% 3013*d5c9a868SElliott Hughes \setbox0 = \hbox{\ignorespaces #3}% 3014*d5c9a868SElliott Hughes \ifdim\wd0 > 0pt 3015*d5c9a868SElliott Hughes \unhbox0 % third arg given, show only that 3016*d5c9a868SElliott Hughes \else 3017*d5c9a868SElliott Hughes \setbox0 = \hbox{\ignorespaces #2}% look for second arg 3018*d5c9a868SElliott Hughes \ifdim\wd0 > 0pt 3019*d5c9a868SElliott Hughes \ifpdf 3020*d5c9a868SElliott Hughes % For pdfTeX and LuaTeX 3021*d5c9a868SElliott Hughes \ifurefurlonlylink 3022*d5c9a868SElliott Hughes % PDF plus option to not display url, show just arg 3023*d5c9a868SElliott Hughes \unhbox0 3024*d5c9a868SElliott Hughes \else 3025*d5c9a868SElliott Hughes % PDF, normally display both arg and url for consistency, 3026*d5c9a868SElliott Hughes % visibility, if the pdf is eventually used to print, etc. 3027*d5c9a868SElliott Hughes \unhbox0\ (\urefcode{#1})% 3028*d5c9a868SElliott Hughes \fi 3029*d5c9a868SElliott Hughes \else 3030*d5c9a868SElliott Hughes \ifx\XeTeXrevision\thisisundefined 3031*d5c9a868SElliott Hughes \unhbox0\ (\urefcode{#1})% DVI, always show arg and url 3032*d5c9a868SElliott Hughes \else 3033*d5c9a868SElliott Hughes % For XeTeX 3034*d5c9a868SElliott Hughes \ifurefurlonlylink 3035*d5c9a868SElliott Hughes % PDF plus option to not display url, show just arg 3036*d5c9a868SElliott Hughes \unhbox0 3037*d5c9a868SElliott Hughes \else 3038*d5c9a868SElliott Hughes % PDF, normally display both arg and url for consistency, 3039*d5c9a868SElliott Hughes % visibility, if the pdf is eventually used to print, etc. 3040*d5c9a868SElliott Hughes \unhbox0\ (\urefcode{#1})% 3041*d5c9a868SElliott Hughes \fi 3042*d5c9a868SElliott Hughes \fi 3043*d5c9a868SElliott Hughes \fi 3044*d5c9a868SElliott Hughes \else 3045*d5c9a868SElliott Hughes \urefcode{#1}% only url given, so show it 3046*d5c9a868SElliott Hughes \fi 3047*d5c9a868SElliott Hughes \fi 3048*d5c9a868SElliott Hughes \endlink 3049*d5c9a868SElliott Hughes\endgroup} 3050*d5c9a868SElliott Hughes 3051*d5c9a868SElliott Hughes% Allow line breaks around only a few characters (only). 3052*d5c9a868SElliott Hughes\def\urefcatcodes{% 3053*d5c9a868SElliott Hughes \catcode`\&=\active \catcode`\.=\active 3054*d5c9a868SElliott Hughes \catcode`\#=\active \catcode`\?=\active 3055*d5c9a868SElliott Hughes \catcode`\/=\active 3056*d5c9a868SElliott Hughes} 3057*d5c9a868SElliott Hughes{ 3058*d5c9a868SElliott Hughes \urefcatcodes 3059*d5c9a868SElliott Hughes % 3060*d5c9a868SElliott Hughes \global\def\urefcode{\begingroup 3061*d5c9a868SElliott Hughes \setcodequotes 3062*d5c9a868SElliott Hughes \urefcatcodes 3063*d5c9a868SElliott Hughes \let&\urefcodeamp 3064*d5c9a868SElliott Hughes \let.\urefcodedot 3065*d5c9a868SElliott Hughes \let#\urefcodehash 3066*d5c9a868SElliott Hughes \let?\urefcodequest 3067*d5c9a868SElliott Hughes \let/\urefcodeslash 3068*d5c9a868SElliott Hughes \codex 3069*d5c9a868SElliott Hughes } 3070*d5c9a868SElliott Hughes % 3071*d5c9a868SElliott Hughes % By default, they are just regular characters. 3072*d5c9a868SElliott Hughes \global\def&{\normalamp} 3073*d5c9a868SElliott Hughes \global\def.{\normaldot} 3074*d5c9a868SElliott Hughes \global\def#{\normalhash} 3075*d5c9a868SElliott Hughes \global\def?{\normalquest} 3076*d5c9a868SElliott Hughes \global\def/{\normalslash} 3077*d5c9a868SElliott Hughes} 3078*d5c9a868SElliott Hughes 3079*d5c9a868SElliott Hughes\def\urefcodeamp{\urefprebreak \&\urefpostbreak} 3080*d5c9a868SElliott Hughes\def\urefcodedot{\urefprebreak .\urefpostbreak} 3081*d5c9a868SElliott Hughes\def\urefcodehash{\urefprebreak \#\urefpostbreak} 3082*d5c9a868SElliott Hughes\def\urefcodequest{\urefprebreak ?\urefpostbreak} 3083*d5c9a868SElliott Hughes\def\urefcodeslash{\futurelet\next\urefcodeslashfinish} 3084*d5c9a868SElliott Hughes{ 3085*d5c9a868SElliott Hughes \catcode`\/=\active 3086*d5c9a868SElliott Hughes \global\def\urefcodeslashfinish{% 3087*d5c9a868SElliott Hughes \urefprebreak \slashChar 3088*d5c9a868SElliott Hughes % Allow line break only after the final / in a sequence of 3089*d5c9a868SElliott Hughes % slashes, to avoid line break between the slashes in http://. 3090*d5c9a868SElliott Hughes \ifx\next/\else \urefpostbreak \fi 3091*d5c9a868SElliott Hughes } 3092*d5c9a868SElliott Hughes} 3093*d5c9a868SElliott Hughes 3094*d5c9a868SElliott Hughes% By default we'll break after the special characters, but some people like to 3095*d5c9a868SElliott Hughes% break before the special chars, so allow that. Also allow no breaking at 3096*d5c9a868SElliott Hughes% all, for manual control. 3097*d5c9a868SElliott Hughes% 3098*d5c9a868SElliott Hughes\parseargdef\urefbreakstyle{% 3099*d5c9a868SElliott Hughes \def\txiarg{#1}% 3100*d5c9a868SElliott Hughes \ifx\txiarg\wordnone 3101*d5c9a868SElliott Hughes \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak} 3102*d5c9a868SElliott Hughes \else\ifx\txiarg\wordbefore 3103*d5c9a868SElliott Hughes \def\urefprebreak{\urefallowbreak}\def\urefpostbreak{\nobreak} 3104*d5c9a868SElliott Hughes \else\ifx\txiarg\wordafter 3105*d5c9a868SElliott Hughes \def\urefprebreak{\nobreak}\def\urefpostbreak{\urefallowbreak} 3106*d5c9a868SElliott Hughes \else 3107*d5c9a868SElliott Hughes \errhelp = \EMsimple 3108*d5c9a868SElliott Hughes \errmessage{Unknown @urefbreakstyle setting `\txiarg'}% 3109*d5c9a868SElliott Hughes \fi\fi\fi 3110*d5c9a868SElliott Hughes} 3111*d5c9a868SElliott Hughes\def\wordafter{after} 3112*d5c9a868SElliott Hughes\def\wordbefore{before} 3113*d5c9a868SElliott Hughes\def\wordnone{none} 3114*d5c9a868SElliott Hughes 3115*d5c9a868SElliott Hughes% Allow a ragged right output to aid breaking long URL's. There can 3116*d5c9a868SElliott Hughes% be a break at the \allowbreak with no extra glue (if the existing stretch in 3117*d5c9a868SElliott Hughes% the line is sufficient), a break at the \penalty with extra glue added 3118*d5c9a868SElliott Hughes% at the end of the line, or no break at all here. 3119*d5c9a868SElliott Hughes% Changing the value of the penalty and/or the amount of stretch affects how 3120*d5c9a868SElliott Hughes% preferable one choice is over the other. 3121*d5c9a868SElliott Hughes\def\urefallowbreak{% 3122*d5c9a868SElliott Hughes \penalty0\relax 3123*d5c9a868SElliott Hughes \hskip 0pt plus 2 em\relax 3124*d5c9a868SElliott Hughes \penalty1000\relax 3125*d5c9a868SElliott Hughes \hskip 0pt plus -2 em\relax 3126*d5c9a868SElliott Hughes} 3127*d5c9a868SElliott Hughes 3128*d5c9a868SElliott Hughes\urefbreakstyle after 3129*d5c9a868SElliott Hughes 3130*d5c9a868SElliott Hughes% @url synonym for @uref, since that's how everyone uses it. 3131*d5c9a868SElliott Hughes% 3132*d5c9a868SElliott Hughes\let\url=\uref 3133*d5c9a868SElliott Hughes 3134*d5c9a868SElliott Hughes% rms does not like angle brackets --karl, 17may97. 3135*d5c9a868SElliott Hughes% So now @email is just like @uref, unless we are pdf. 3136*d5c9a868SElliott Hughes% 3137*d5c9a868SElliott Hughes%\def\email#1{\angleleft{\tt #1}\angleright} 3138*d5c9a868SElliott Hughes\ifpdforxetex 3139*d5c9a868SElliott Hughes \def\email#1{\doemail#1,,\finish} 3140*d5c9a868SElliott Hughes \def\doemail#1,#2,#3\finish{\begingroup 3141*d5c9a868SElliott Hughes \unsepspaces 3142*d5c9a868SElliott Hughes \pdfurl{mailto:#1}% 3143*d5c9a868SElliott Hughes \setbox0 = \hbox{\ignorespaces #2}% 3144*d5c9a868SElliott Hughes \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi 3145*d5c9a868SElliott Hughes \endlink 3146*d5c9a868SElliott Hughes \endgroup} 3147*d5c9a868SElliott Hughes\else 3148*d5c9a868SElliott Hughes \let\email=\uref 3149*d5c9a868SElliott Hughes\fi 3150*d5c9a868SElliott Hughes 3151*d5c9a868SElliott Hughes% @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always), 3152*d5c9a868SElliott Hughes% `example' (@kbd uses ttsl only inside of @example and friends), 3153*d5c9a868SElliott Hughes% or `code' (@kbd uses normal tty font always). 3154*d5c9a868SElliott Hughes\parseargdef\kbdinputstyle{% 3155*d5c9a868SElliott Hughes \def\txiarg{#1}% 3156*d5c9a868SElliott Hughes \ifx\txiarg\worddistinct 3157*d5c9a868SElliott Hughes \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}% 3158*d5c9a868SElliott Hughes \else\ifx\txiarg\wordexample 3159*d5c9a868SElliott Hughes \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}% 3160*d5c9a868SElliott Hughes \else\ifx\txiarg\wordcode 3161*d5c9a868SElliott Hughes \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}% 3162*d5c9a868SElliott Hughes \else 3163*d5c9a868SElliott Hughes \errhelp = \EMsimple 3164*d5c9a868SElliott Hughes \errmessage{Unknown @kbdinputstyle setting `\txiarg'}% 3165*d5c9a868SElliott Hughes \fi\fi\fi 3166*d5c9a868SElliott Hughes} 3167*d5c9a868SElliott Hughes\def\worddistinct{distinct} 3168*d5c9a868SElliott Hughes\def\wordexample{example} 3169*d5c9a868SElliott Hughes\def\wordcode{code} 3170*d5c9a868SElliott Hughes 3171*d5c9a868SElliott Hughes% Default is `distinct'. 3172*d5c9a868SElliott Hughes\kbdinputstyle distinct 3173*d5c9a868SElliott Hughes 3174*d5c9a868SElliott Hughes% @kbd is like @code, except that if the argument is just one @key command, 3175*d5c9a868SElliott Hughes% then @kbd has no effect. 3176*d5c9a868SElliott Hughes\def\kbd#1{{\def\look{#1}\expandafter\kbdsub\look??\par}} 3177*d5c9a868SElliott Hughes 3178*d5c9a868SElliott Hughes\def\xkey{\key} 3179*d5c9a868SElliott Hughes\def\kbdsub#1#2#3\par{% 3180*d5c9a868SElliott Hughes \def\one{#1}\def\three{#3}\def\threex{??}% 3181*d5c9a868SElliott Hughes \ifx\one\xkey\ifx\threex\three \key{#2}% 3182*d5c9a868SElliott Hughes \else{\tclose{\kbdfont\setcodequotes\look}}\fi 3183*d5c9a868SElliott Hughes \else{\tclose{\kbdfont\setcodequotes\look}}\fi 3184*d5c9a868SElliott Hughes} 3185*d5c9a868SElliott Hughes 3186*d5c9a868SElliott Hughes% definition of @key that produces a lozenge. Doesn't adjust to text size. 3187*d5c9a868SElliott Hughes%\setfont\keyrm\rmshape{8}{1000}{OT1} 3188*d5c9a868SElliott Hughes%\font\keysy=cmsy9 3189*d5c9a868SElliott Hughes%\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{% 3190*d5c9a868SElliott Hughes% \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{% 3191*d5c9a868SElliott Hughes% \vbox{\hrule\kern-0.4pt 3192*d5c9a868SElliott Hughes% \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}% 3193*d5c9a868SElliott Hughes% \kern-0.4pt\hrule}% 3194*d5c9a868SElliott Hughes% \kern-.06em\raise0.4pt\hbox{\angleright}}}} 3195*d5c9a868SElliott Hughes 3196*d5c9a868SElliott Hughes% definition of @key with no lozenge. 3197*d5c9a868SElliott Hughes% 3198*d5c9a868SElliott Hughes\def\key#1{{\setregularquotes \nohyphenation \tt #1}\null} 3199*d5c9a868SElliott Hughes 3200*d5c9a868SElliott Hughes% @clicksequence{File @click{} Open ...} 3201*d5c9a868SElliott Hughes\def\clicksequence#1{\begingroup #1\endgroup} 3202*d5c9a868SElliott Hughes 3203*d5c9a868SElliott Hughes% @clickstyle @arrow (by default) 3204*d5c9a868SElliott Hughes\parseargdef\clickstyle{\def\click{#1}} 3205*d5c9a868SElliott Hughes\def\click{\arrow} 3206*d5c9a868SElliott Hughes 3207*d5c9a868SElliott Hughes% Typeset a dimension, e.g., `in' or `pt'. The only reason for the 3208*d5c9a868SElliott Hughes% argument is to make the input look right: @dmn{pt} instead of @dmn{}pt. 3209*d5c9a868SElliott Hughes% 3210*d5c9a868SElliott Hughes\def\dmn#1{\thinspace #1} 3211*d5c9a868SElliott Hughes 3212*d5c9a868SElliott Hughes% @acronym for "FBI", "NATO", and the like. 3213*d5c9a868SElliott Hughes% We print this one point size smaller, since it's intended for 3214*d5c9a868SElliott Hughes% all-uppercase. 3215*d5c9a868SElliott Hughes% 3216*d5c9a868SElliott Hughes\def\acronym#1{\doacronym #1,,\finish} 3217*d5c9a868SElliott Hughes\def\doacronym#1,#2,#3\finish{% 3218*d5c9a868SElliott Hughes {\switchtolsize #1}% 3219*d5c9a868SElliott Hughes \def\temp{#2}% 3220*d5c9a868SElliott Hughes \ifx\temp\empty \else 3221*d5c9a868SElliott Hughes \space ({\unsepspaces \ignorespaces \temp \unskip})% 3222*d5c9a868SElliott Hughes \fi 3223*d5c9a868SElliott Hughes \null % reset \spacefactor=1000 3224*d5c9a868SElliott Hughes} 3225*d5c9a868SElliott Hughes 3226*d5c9a868SElliott Hughes% @abbr for "Comput. J." and the like. 3227*d5c9a868SElliott Hughes% No font change, but don't do end-of-sentence spacing. 3228*d5c9a868SElliott Hughes% 3229*d5c9a868SElliott Hughes\def\abbr#1{\doabbr #1,,\finish} 3230*d5c9a868SElliott Hughes\def\doabbr#1,#2,#3\finish{% 3231*d5c9a868SElliott Hughes {\plainfrenchspacing #1}% 3232*d5c9a868SElliott Hughes \def\temp{#2}% 3233*d5c9a868SElliott Hughes \ifx\temp\empty \else 3234*d5c9a868SElliott Hughes \space ({\unsepspaces \ignorespaces \temp \unskip})% 3235*d5c9a868SElliott Hughes \fi 3236*d5c9a868SElliott Hughes \null % reset \spacefactor=1000 3237*d5c9a868SElliott Hughes} 3238*d5c9a868SElliott Hughes 3239*d5c9a868SElliott Hughes% @asis just yields its argument. Used with @table, for example. 3240*d5c9a868SElliott Hughes% 3241*d5c9a868SElliott Hughes\def\asis#1{#1} 3242*d5c9a868SElliott Hughes 3243*d5c9a868SElliott Hughes% @math outputs its argument in math mode. 3244*d5c9a868SElliott Hughes% 3245*d5c9a868SElliott Hughes% One complication: _ usually means subscripts, but it could also mean 3246*d5c9a868SElliott Hughes% an actual _ character, as in @math{@var{some_variable} + 1}. So make 3247*d5c9a868SElliott Hughes% _ active, and distinguish by seeing if the current family is \slfam, 3248*d5c9a868SElliott Hughes% which is what @var uses. 3249*d5c9a868SElliott Hughes{ 3250*d5c9a868SElliott Hughes \catcode`\_ = \active 3251*d5c9a868SElliott Hughes \gdef\mathunderscore{% 3252*d5c9a868SElliott Hughes \catcode`\_=\active 3253*d5c9a868SElliott Hughes \def_{\ifnum\fam=\slfam \_\else\sb\fi}% 3254*d5c9a868SElliott Hughes } 3255*d5c9a868SElliott Hughes} 3256*d5c9a868SElliott Hughes% Another complication: we want \\ (and @\) to output a math (or tt) \. 3257*d5c9a868SElliott Hughes% FYI, plain.tex uses \\ as a temporary control sequence (for no 3258*d5c9a868SElliott Hughes% particular reason), but this is not advertised and we don't care. 3259*d5c9a868SElliott Hughes% 3260*d5c9a868SElliott Hughes% The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\. 3261*d5c9a868SElliott Hughes\def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi} 3262*d5c9a868SElliott Hughes% 3263*d5c9a868SElliott Hughes\def\math{% 3264*d5c9a868SElliott Hughes \ifmmode\else % only go into math if not in math mode already 3265*d5c9a868SElliott Hughes \tex 3266*d5c9a868SElliott Hughes \mathunderscore 3267*d5c9a868SElliott Hughes \let\\ = \mathbackslash 3268*d5c9a868SElliott Hughes \mathactive 3269*d5c9a868SElliott Hughes % make the texinfo accent commands work in math mode 3270*d5c9a868SElliott Hughes \let\"=\ddot 3271*d5c9a868SElliott Hughes \let\'=\acute 3272*d5c9a868SElliott Hughes \let\==\bar 3273*d5c9a868SElliott Hughes \let\^=\hat 3274*d5c9a868SElliott Hughes \let\`=\grave 3275*d5c9a868SElliott Hughes \let\u=\breve 3276*d5c9a868SElliott Hughes \let\v=\check 3277*d5c9a868SElliott Hughes \let\~=\tilde 3278*d5c9a868SElliott Hughes \let\dotaccent=\dot 3279*d5c9a868SElliott Hughes % have to provide another name for sup operator 3280*d5c9a868SElliott Hughes \let\mathopsup=\sup 3281*d5c9a868SElliott Hughes $\expandafter\finishmath\fi 3282*d5c9a868SElliott Hughes} 3283*d5c9a868SElliott Hughes\def\finishmath#1{#1$\endgroup} % Close the group opened by \tex. 3284*d5c9a868SElliott Hughes 3285*d5c9a868SElliott Hughes% Some active characters (such as <) are spaced differently in math. 3286*d5c9a868SElliott Hughes% We have to reset their definitions in case the @math was an argument 3287*d5c9a868SElliott Hughes% to a command which sets the catcodes (such as @item or @section). 3288*d5c9a868SElliott Hughes% 3289*d5c9a868SElliott Hughes{ 3290*d5c9a868SElliott Hughes \catcode`^ = \active 3291*d5c9a868SElliott Hughes \catcode`< = \active 3292*d5c9a868SElliott Hughes \catcode`> = \active 3293*d5c9a868SElliott Hughes \catcode`+ = \active 3294*d5c9a868SElliott Hughes \catcode`' = \active 3295*d5c9a868SElliott Hughes \gdef\mathactive{% 3296*d5c9a868SElliott Hughes \let^ = \ptexhat 3297*d5c9a868SElliott Hughes \let< = \ptexless 3298*d5c9a868SElliott Hughes \let> = \ptexgtr 3299*d5c9a868SElliott Hughes \let+ = \ptexplus 3300*d5c9a868SElliott Hughes \let' = \ptexquoteright 3301*d5c9a868SElliott Hughes } 3302*d5c9a868SElliott Hughes} 3303*d5c9a868SElliott Hughes 3304*d5c9a868SElliott Hughes% for @sub and @sup, if in math mode, just do a normal sub/superscript. 3305*d5c9a868SElliott Hughes% If in text, use math to place as sub/superscript, but switch 3306*d5c9a868SElliott Hughes% into text mode, with smaller fonts. This is a different font than the 3307*d5c9a868SElliott Hughes% one used for real math sub/superscripts (8pt vs. 7pt), but let's not 3308*d5c9a868SElliott Hughes% fix it (significant additions to font machinery) until someone notices. 3309*d5c9a868SElliott Hughes% 3310*d5c9a868SElliott Hughes\def\sub{\ifmmode \expandafter\sb \else \expandafter\finishsub\fi} 3311*d5c9a868SElliott Hughes\def\finishsub#1{$\sb{\hbox{\switchtolllsize #1}}$}% 3312*d5c9a868SElliott Hughes% 3313*d5c9a868SElliott Hughes\def\sup{\ifmmode \expandafter\ptexsp \else \expandafter\finishsup\fi} 3314*d5c9a868SElliott Hughes\def\finishsup#1{$\ptexsp{\hbox{\switchtolllsize #1}}$}% 3315*d5c9a868SElliott Hughes 3316*d5c9a868SElliott Hughes% provide this command from LaTeX as it is very common 3317*d5c9a868SElliott Hughes\def\frac#1#2{{{#1}\over{#2}}} 3318*d5c9a868SElliott Hughes 3319*d5c9a868SElliott Hughes% @displaymath. 3320*d5c9a868SElliott Hughes% \globaldefs is needed to recognize the end lines in \tex and 3321*d5c9a868SElliott Hughes% \end tex. Set \thisenv as @end displaymath is seen before @end tex. 3322*d5c9a868SElliott Hughes{\obeylines 3323*d5c9a868SElliott Hughes\globaldefs=1 3324*d5c9a868SElliott Hughes\envdef\displaymath{% 3325*d5c9a868SElliott Hughes\tex% 3326*d5c9a868SElliott Hughes\def\thisenv{\displaymath}% 3327*d5c9a868SElliott Hughes\begingroup\let\end\displaymathend% 3328*d5c9a868SElliott Hughes$$% 3329*d5c9a868SElliott Hughes} 3330*d5c9a868SElliott Hughes 3331*d5c9a868SElliott Hughes\def\displaymathend{$$\endgroup\end}% 3332*d5c9a868SElliott Hughes 3333*d5c9a868SElliott Hughes\def\Edisplaymath{% 3334*d5c9a868SElliott Hughes\def\thisenv{\tex}% 3335*d5c9a868SElliott Hughes\end tex 3336*d5c9a868SElliott Hughes}} 3337*d5c9a868SElliott Hughes 3338*d5c9a868SElliott Hughes 3339*d5c9a868SElliott Hughes% @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}. 3340*d5c9a868SElliott Hughes% Ignore unless FMTNAME == tex; then it is like @iftex and @tex, 3341*d5c9a868SElliott Hughes% except specified as a normal braced arg, so no newlines to worry about. 3342*d5c9a868SElliott Hughes% 3343*d5c9a868SElliott Hughes\def\outfmtnametex{tex} 3344*d5c9a868SElliott Hughes% 3345*d5c9a868SElliott Hughes\long\def\inlinefmt#1{\doinlinefmt #1,\finish} 3346*d5c9a868SElliott Hughes\long\def\doinlinefmt#1,#2,\finish{% 3347*d5c9a868SElliott Hughes \def\inlinefmtname{#1}% 3348*d5c9a868SElliott Hughes \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi 3349*d5c9a868SElliott Hughes} 3350*d5c9a868SElliott Hughes% 3351*d5c9a868SElliott Hughes% @inlinefmtifelse{FMTNAME,THEN-TEXT,ELSE-TEXT} expands THEN-TEXT if 3352*d5c9a868SElliott Hughes% FMTNAME is tex, else ELSE-TEXT. 3353*d5c9a868SElliott Hughes\long\def\inlinefmtifelse#1{\doinlinefmtifelse #1,,,\finish} 3354*d5c9a868SElliott Hughes\long\def\doinlinefmtifelse#1,#2,#3,#4,\finish{% 3355*d5c9a868SElliott Hughes \def\inlinefmtname{#1}% 3356*d5c9a868SElliott Hughes \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\else \ignorespaces #3\fi 3357*d5c9a868SElliott Hughes} 3358*d5c9a868SElliott Hughes% 3359*d5c9a868SElliott Hughes% For raw, must switch into @tex before parsing the argument, to avoid 3360*d5c9a868SElliott Hughes% setting catcodes prematurely. Doing it this way means that, for 3361*d5c9a868SElliott Hughes% example, @inlineraw{html, foo{bar} gets a parse error instead of being 3362*d5c9a868SElliott Hughes% ignored. But this isn't important because if people want a literal 3363*d5c9a868SElliott Hughes% *right* brace they would have to use a command anyway, so they may as 3364*d5c9a868SElliott Hughes% well use a command to get a left brace too. We could re-use the 3365*d5c9a868SElliott Hughes% delimiter character idea from \verb, but it seems like overkill. 3366*d5c9a868SElliott Hughes% 3367*d5c9a868SElliott Hughes\long\def\inlineraw{\tex \doinlineraw} 3368*d5c9a868SElliott Hughes\long\def\doinlineraw#1{\doinlinerawtwo #1,\finish} 3369*d5c9a868SElliott Hughes\def\doinlinerawtwo#1,#2,\finish{% 3370*d5c9a868SElliott Hughes \def\inlinerawname{#1}% 3371*d5c9a868SElliott Hughes \ifx\inlinerawname\outfmtnametex \ignorespaces #2\fi 3372*d5c9a868SElliott Hughes \endgroup % close group opened by \tex. 3373*d5c9a868SElliott Hughes} 3374*d5c9a868SElliott Hughes 3375*d5c9a868SElliott Hughes% @inlineifset{VAR, TEXT} expands TEXT if VAR is @set. 3376*d5c9a868SElliott Hughes% 3377*d5c9a868SElliott Hughes\long\def\inlineifset#1{\doinlineifset #1,\finish} 3378*d5c9a868SElliott Hughes\long\def\doinlineifset#1,#2,\finish{% 3379*d5c9a868SElliott Hughes \def\inlinevarname{#1}% 3380*d5c9a868SElliott Hughes \expandafter\ifx\csname SET\inlinevarname\endcsname\relax 3381*d5c9a868SElliott Hughes \else\ignorespaces#2\fi 3382*d5c9a868SElliott Hughes} 3383*d5c9a868SElliott Hughes 3384*d5c9a868SElliott Hughes% @inlineifclear{VAR, TEXT} expands TEXT if VAR is not @set. 3385*d5c9a868SElliott Hughes% 3386*d5c9a868SElliott Hughes\long\def\inlineifclear#1{\doinlineifclear #1,\finish} 3387*d5c9a868SElliott Hughes\long\def\doinlineifclear#1,#2,\finish{% 3388*d5c9a868SElliott Hughes \def\inlinevarname{#1}% 3389*d5c9a868SElliott Hughes \expandafter\ifx\csname SET\inlinevarname\endcsname\relax \ignorespaces#2\fi 3390*d5c9a868SElliott Hughes} 3391*d5c9a868SElliott Hughes 3392*d5c9a868SElliott Hughes 3393*d5c9a868SElliott Hughes\message{glyphs,} 3394*d5c9a868SElliott Hughes% and logos. 3395*d5c9a868SElliott Hughes 3396*d5c9a868SElliott Hughes% @@ prints an @, as does @atchar{}. 3397*d5c9a868SElliott Hughes\def\@{\char64 } 3398*d5c9a868SElliott Hughes\let\atchar=\@ 3399*d5c9a868SElliott Hughes 3400*d5c9a868SElliott Hughes% @{ @} @lbracechar{} @rbracechar{} all generate brace characters. 3401*d5c9a868SElliott Hughes\def\lbracechar{{\ifmonospace\char123\else\ensuremath\lbrace\fi}} 3402*d5c9a868SElliott Hughes\def\rbracechar{{\ifmonospace\char125\else\ensuremath\rbrace\fi}} 3403*d5c9a868SElliott Hughes\let\{=\lbracechar 3404*d5c9a868SElliott Hughes\let\}=\rbracechar 3405*d5c9a868SElliott Hughes 3406*d5c9a868SElliott Hughes% @comma{} to avoid , parsing problems. 3407*d5c9a868SElliott Hughes\let\comma = , 3408*d5c9a868SElliott Hughes 3409*d5c9a868SElliott Hughes% Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent 3410*d5c9a868SElliott Hughes% Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H. 3411*d5c9a868SElliott Hughes\let\, = \ptexc 3412*d5c9a868SElliott Hughes\let\dotaccent = \ptexdot 3413*d5c9a868SElliott Hughes\def\ringaccent#1{{\accent23 #1}} 3414*d5c9a868SElliott Hughes\let\tieaccent = \ptext 3415*d5c9a868SElliott Hughes\let\ubaraccent = \ptexb 3416*d5c9a868SElliott Hughes\let\udotaccent = \d 3417*d5c9a868SElliott Hughes 3418*d5c9a868SElliott Hughes% Other special characters: @questiondown @exclamdown @ordf @ordm 3419*d5c9a868SElliott Hughes% Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss. 3420*d5c9a868SElliott Hughes\def\questiondown{?`} 3421*d5c9a868SElliott Hughes\def\exclamdown{!`} 3422*d5c9a868SElliott Hughes\def\ordf{\leavevmode\raise1ex\hbox{\switchtolllsize \underbar{a}}} 3423*d5c9a868SElliott Hughes\def\ordm{\leavevmode\raise1ex\hbox{\switchtolllsize \underbar{o}}} 3424*d5c9a868SElliott Hughes 3425*d5c9a868SElliott Hughes% Dotless i and dotless j, used for accents. 3426*d5c9a868SElliott Hughes\def\imacro{i} 3427*d5c9a868SElliott Hughes\def\jmacro{j} 3428*d5c9a868SElliott Hughes\def\dotless#1{% 3429*d5c9a868SElliott Hughes \def\temp{#1}% 3430*d5c9a868SElliott Hughes \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi 3431*d5c9a868SElliott Hughes \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi 3432*d5c9a868SElliott Hughes \else \errmessage{@dotless can be used only with i or j}% 3433*d5c9a868SElliott Hughes \fi\fi 3434*d5c9a868SElliott Hughes} 3435*d5c9a868SElliott Hughes 3436*d5c9a868SElliott Hughes% The \TeX{} logo, as in plain, but resetting the spacing so that a 3437*d5c9a868SElliott Hughes% period following counts as ending a sentence. (Idea found in latex.) 3438*d5c9a868SElliott Hughes% 3439*d5c9a868SElliott Hughes\edef\TeX{\TeX \spacefactor=1000 } 3440*d5c9a868SElliott Hughes 3441*d5c9a868SElliott Hughes% @LaTeX{} logo. Not quite the same results as the definition in 3442*d5c9a868SElliott Hughes% latex.ltx, since we use a different font for the raised A; it's most 3443*d5c9a868SElliott Hughes% convenient for us to use an explicitly smaller font, rather than using 3444*d5c9a868SElliott Hughes% the \scriptstyle font (since we don't reset \scriptstyle and 3445*d5c9a868SElliott Hughes% \scriptscriptstyle). 3446*d5c9a868SElliott Hughes% 3447*d5c9a868SElliott Hughes\def\LaTeX{% 3448*d5c9a868SElliott Hughes L\kern-.36em 3449*d5c9a868SElliott Hughes {\setbox0=\hbox{T}% 3450*d5c9a868SElliott Hughes \vbox to \ht0{\hbox{% 3451*d5c9a868SElliott Hughes \ifx\textnominalsize\xwordpt 3452*d5c9a868SElliott Hughes % for 10pt running text, lllsize (8pt) is too small for the A in LaTeX. 3453*d5c9a868SElliott Hughes % Revert to plain's \scriptsize, which is 7pt. 3454*d5c9a868SElliott Hughes \count255=\the\fam $\fam\count255 \scriptstyle A$% 3455*d5c9a868SElliott Hughes \else 3456*d5c9a868SElliott Hughes % For 11pt, we can use our lllsize. 3457*d5c9a868SElliott Hughes \switchtolllsize A% 3458*d5c9a868SElliott Hughes \fi 3459*d5c9a868SElliott Hughes }% 3460*d5c9a868SElliott Hughes \vss 3461*d5c9a868SElliott Hughes }}% 3462*d5c9a868SElliott Hughes \kern-.15em 3463*d5c9a868SElliott Hughes \TeX 3464*d5c9a868SElliott Hughes} 3465*d5c9a868SElliott Hughes 3466*d5c9a868SElliott Hughes% Some math mode symbols. Define \ensuremath to switch into math mode 3467*d5c9a868SElliott Hughes% unless we are already there. Expansion tricks may not be needed here, 3468*d5c9a868SElliott Hughes% but safer, and can't hurt. 3469*d5c9a868SElliott Hughes\def\ensuremath{\ifmmode \expandafter\asis \else\expandafter\ensuredmath \fi} 3470*d5c9a868SElliott Hughes\def\ensuredmath#1{$\relax#1$} 3471*d5c9a868SElliott Hughes% 3472*d5c9a868SElliott Hughes\def\bullet{\ensuremath\ptexbullet} 3473*d5c9a868SElliott Hughes\def\geq{\ensuremath\ge} 3474*d5c9a868SElliott Hughes\def\leq{\ensuremath\le} 3475*d5c9a868SElliott Hughes\def\minus{\ensuremath-} 3476*d5c9a868SElliott Hughes 3477*d5c9a868SElliott Hughes% @dots{} outputs an ellipsis using the current font. 3478*d5c9a868SElliott Hughes% We do .5em per period so that it has the same spacing in the cm 3479*d5c9a868SElliott Hughes% typewriter fonts as three actual period characters; on the other hand, 3480*d5c9a868SElliott Hughes% in other typewriter fonts three periods are wider than 1.5em. So do 3481*d5c9a868SElliott Hughes% whichever is larger. 3482*d5c9a868SElliott Hughes% 3483*d5c9a868SElliott Hughes\def\dots{% 3484*d5c9a868SElliott Hughes \leavevmode 3485*d5c9a868SElliott Hughes \setbox0=\hbox{...}% get width of three periods 3486*d5c9a868SElliott Hughes \ifdim\wd0 > 1.5em 3487*d5c9a868SElliott Hughes \dimen0 = \wd0 3488*d5c9a868SElliott Hughes \else 3489*d5c9a868SElliott Hughes \dimen0 = 1.5em 3490*d5c9a868SElliott Hughes \fi 3491*d5c9a868SElliott Hughes \hbox to \dimen0{% 3492*d5c9a868SElliott Hughes \hskip 0pt plus.25fil 3493*d5c9a868SElliott Hughes .\hskip 0pt plus1fil 3494*d5c9a868SElliott Hughes .\hskip 0pt plus1fil 3495*d5c9a868SElliott Hughes .\hskip 0pt plus.5fil 3496*d5c9a868SElliott Hughes }% 3497*d5c9a868SElliott Hughes} 3498*d5c9a868SElliott Hughes 3499*d5c9a868SElliott Hughes% @enddots{} is an end-of-sentence ellipsis. 3500*d5c9a868SElliott Hughes% 3501*d5c9a868SElliott Hughes\def\enddots{% 3502*d5c9a868SElliott Hughes \dots 3503*d5c9a868SElliott Hughes \spacefactor=\endofsentencespacefactor 3504*d5c9a868SElliott Hughes} 3505*d5c9a868SElliott Hughes 3506*d5c9a868SElliott Hughes% @point{}, @result{}, @expansion{}, @print{}, @equiv{}. 3507*d5c9a868SElliott Hughes% 3508*d5c9a868SElliott Hughes% Since these characters are used in examples, they should be an even number of 3509*d5c9a868SElliott Hughes% \tt widths. Each \tt character is 1en, so two makes it 1em. 3510*d5c9a868SElliott Hughes% 3511*d5c9a868SElliott Hughes\def\point{$\star$} 3512*d5c9a868SElliott Hughes\def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}} 3513*d5c9a868SElliott Hughes\def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}} 3514*d5c9a868SElliott Hughes\def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}} 3515*d5c9a868SElliott Hughes\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}} 3516*d5c9a868SElliott Hughes\def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}} 3517*d5c9a868SElliott Hughes 3518*d5c9a868SElliott Hughes% The @error{} command. 3519*d5c9a868SElliott Hughes% Adapted from the TeXbook's \boxit. 3520*d5c9a868SElliott Hughes% 3521*d5c9a868SElliott Hughes\newbox\errorbox 3522*d5c9a868SElliott Hughes% 3523*d5c9a868SElliott Hughes{\ttfont \global\dimen0 = 3em}% Width of the box. 3524*d5c9a868SElliott Hughes\dimen2 = .55pt % Thickness of rules 3525*d5c9a868SElliott Hughes% The text. (`r' is open on the right, `e' somewhat less so on the left.) 3526*d5c9a868SElliott Hughes\setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt} 3527*d5c9a868SElliott Hughes% 3528*d5c9a868SElliott Hughes\setbox\errorbox=\hbox to \dimen0{\hfil 3529*d5c9a868SElliott Hughes \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right. 3530*d5c9a868SElliott Hughes \advance\hsize by -2\dimen2 % Rules. 3531*d5c9a868SElliott Hughes \vbox{% 3532*d5c9a868SElliott Hughes \hrule height\dimen2 3533*d5c9a868SElliott Hughes \hbox{\vrule width\dimen2 \kern3pt % Space to left of text. 3534*d5c9a868SElliott Hughes \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below. 3535*d5c9a868SElliott Hughes \kern3pt\vrule width\dimen2}% Space to right. 3536*d5c9a868SElliott Hughes \hrule height\dimen2} 3537*d5c9a868SElliott Hughes \hfil} 3538*d5c9a868SElliott Hughes% 3539*d5c9a868SElliott Hughes\def\error{\leavevmode\lower.7ex\copy\errorbox} 3540*d5c9a868SElliott Hughes 3541*d5c9a868SElliott Hughes% @pounds{} is a sterling sign, which Knuth put in the CM italic font. 3542*d5c9a868SElliott Hughes% 3543*d5c9a868SElliott Hughes\def\pounds{\ifmonospace{\ecfont\char"BF}\else{\it\$}\fi} 3544*d5c9a868SElliott Hughes 3545*d5c9a868SElliott Hughes% @euro{} comes from a separate font, depending on the current style. 3546*d5c9a868SElliott Hughes% We use the free feym* fonts from the eurosym package by Henrik 3547*d5c9a868SElliott Hughes% Theiling, which support regular, slanted, bold and bold slanted (and 3548*d5c9a868SElliott Hughes% "outlined" (blackboard board, sort of) versions, which we don't need). 3549*d5c9a868SElliott Hughes% It is available from http://www.ctan.org/tex-archive/fonts/eurosym. 3550*d5c9a868SElliott Hughes% 3551*d5c9a868SElliott Hughes% Although only regular is the truly official Euro symbol, we ignore 3552*d5c9a868SElliott Hughes% that. The Euro is designed to be slightly taller than the regular 3553*d5c9a868SElliott Hughes% font height. 3554*d5c9a868SElliott Hughes% 3555*d5c9a868SElliott Hughes% feymr - regular 3556*d5c9a868SElliott Hughes% feymo - slanted 3557*d5c9a868SElliott Hughes% feybr - bold 3558*d5c9a868SElliott Hughes% feybo - bold slanted 3559*d5c9a868SElliott Hughes% 3560*d5c9a868SElliott Hughes% There is no good (free) typewriter version, to my knowledge. 3561*d5c9a868SElliott Hughes% A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide. 3562*d5c9a868SElliott Hughes% Hmm. 3563*d5c9a868SElliott Hughes% 3564*d5c9a868SElliott Hughes% Also doesn't work in math. Do we need to do math with euro symbols? 3565*d5c9a868SElliott Hughes% Hope not. 3566*d5c9a868SElliott Hughes% 3567*d5c9a868SElliott Hughes% 3568*d5c9a868SElliott Hughes\def\euro{{\eurofont e}} 3569*d5c9a868SElliott Hughes\def\eurofont{% 3570*d5c9a868SElliott Hughes % We set the font at each command, rather than predefining it in 3571*d5c9a868SElliott Hughes % \textfonts and the other font-switching commands, so that 3572*d5c9a868SElliott Hughes % installations which never need the symbol don't have to have the 3573*d5c9a868SElliott Hughes % font installed. 3574*d5c9a868SElliott Hughes % 3575*d5c9a868SElliott Hughes % There is only one designed size (nominal 10pt), so we always scale 3576*d5c9a868SElliott Hughes % that to the current nominal size. 3577*d5c9a868SElliott Hughes % 3578*d5c9a868SElliott Hughes % By the way, simply using "at 1em" works for cmr10 and the like, but 3579*d5c9a868SElliott Hughes % does not work for cmbx10 and other extended/shrunken fonts. 3580*d5c9a868SElliott Hughes % 3581*d5c9a868SElliott Hughes \def\eurosize{\csname\curfontsize nominalsize\endcsname}% 3582*d5c9a868SElliott Hughes % 3583*d5c9a868SElliott Hughes \ifx\curfontstyle\bfstylename 3584*d5c9a868SElliott Hughes % bold: 3585*d5c9a868SElliott Hughes \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize 3586*d5c9a868SElliott Hughes \else 3587*d5c9a868SElliott Hughes % regular: 3588*d5c9a868SElliott Hughes \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize 3589*d5c9a868SElliott Hughes \fi 3590*d5c9a868SElliott Hughes \thiseurofont 3591*d5c9a868SElliott Hughes} 3592*d5c9a868SElliott Hughes 3593*d5c9a868SElliott Hughes% Glyphs from the EC fonts. We don't use \let for the aliases, because 3594*d5c9a868SElliott Hughes% sometimes we redefine the original macro, and the alias should reflect 3595*d5c9a868SElliott Hughes% the redefinition. 3596*d5c9a868SElliott Hughes% 3597*d5c9a868SElliott Hughes% Use LaTeX names for the Icelandic letters. 3598*d5c9a868SElliott Hughes\def\DH{{\ecfont \char"D0}} % Eth 3599*d5c9a868SElliott Hughes\def\dh{{\ecfont \char"F0}} % eth 3600*d5c9a868SElliott Hughes\def\TH{{\ecfont \char"DE}} % Thorn 3601*d5c9a868SElliott Hughes\def\th{{\ecfont \char"FE}} % thorn 3602*d5c9a868SElliott Hughes% 3603*d5c9a868SElliott Hughes\def\guillemetleft{{\ecfont \char"13}} 3604*d5c9a868SElliott Hughes\def\guillemotleft{\guillemetleft} 3605*d5c9a868SElliott Hughes\def\guillemetright{{\ecfont \char"14}} 3606*d5c9a868SElliott Hughes\def\guillemotright{\guillemetright} 3607*d5c9a868SElliott Hughes\def\guilsinglleft{{\ecfont \char"0E}} 3608*d5c9a868SElliott Hughes\def\guilsinglright{{\ecfont \char"0F}} 3609*d5c9a868SElliott Hughes\def\quotedblbase{{\ecfont \char"12}} 3610*d5c9a868SElliott Hughes\def\quotesinglbase{{\ecfont \char"0D}} 3611*d5c9a868SElliott Hughes% 3612*d5c9a868SElliott Hughes\def\L{{\ecfont \char"8A}} % L with stroke 3613*d5c9a868SElliott Hughes\def\l{{\ecfont \char"AA}} % l with stroke 3614*d5c9a868SElliott Hughes% 3615*d5c9a868SElliott Hughes% This positioning is not perfect (see the ogonek LaTeX package), but 3616*d5c9a868SElliott Hughes% we have the precomposed glyphs for the most common cases. We put the 3617*d5c9a868SElliott Hughes% tests to use those glyphs in the single \ogonek macro so we have fewer 3618*d5c9a868SElliott Hughes% dummy definitions to worry about for index entries, etc. 3619*d5c9a868SElliott Hughes% 3620*d5c9a868SElliott Hughes% ogonek is also used with other letters in Lithuanian (IOU), but using 3621*d5c9a868SElliott Hughes% the precomposed glyphs for those is not so easy since they aren't in 3622*d5c9a868SElliott Hughes% the same EC font. 3623*d5c9a868SElliott Hughes\def\ogonek#1{{% 3624*d5c9a868SElliott Hughes \def\temp{#1}% 3625*d5c9a868SElliott Hughes \ifx\temp\macrocharA\Aogonek 3626*d5c9a868SElliott Hughes \else\ifx\temp\macrochara\aogonek 3627*d5c9a868SElliott Hughes \else\ifx\temp\macrocharE\Eogonek 3628*d5c9a868SElliott Hughes \else\ifx\temp\macrochare\eogonek 3629*d5c9a868SElliott Hughes \else 3630*d5c9a868SElliott Hughes \ecfont \setbox0=\hbox{#1}% 3631*d5c9a868SElliott Hughes \ifdim\ht0=1ex\accent"0C #1% 3632*d5c9a868SElliott Hughes \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}% 3633*d5c9a868SElliott Hughes \fi 3634*d5c9a868SElliott Hughes \fi\fi\fi\fi 3635*d5c9a868SElliott Hughes }% 3636*d5c9a868SElliott Hughes} 3637*d5c9a868SElliott Hughes\def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A} 3638*d5c9a868SElliott Hughes\def\aogonek{{\ecfont \char"A1}}\def\macrochara{a} 3639*d5c9a868SElliott Hughes\def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E} 3640*d5c9a868SElliott Hughes\def\eogonek{{\ecfont \char"A6}}\def\macrochare{e} 3641*d5c9a868SElliott Hughes% 3642*d5c9a868SElliott Hughes% Use the European Computer Modern fonts (cm-super in outline format) 3643*d5c9a868SElliott Hughes% for non-CM glyphs. That is ec* for regular text and tc* for the text 3644*d5c9a868SElliott Hughes% companion symbols (LaTeX TS1 encoding). Both are part of the ec 3645*d5c9a868SElliott Hughes% package and follow the same conventions. 3646*d5c9a868SElliott Hughes% 3647*d5c9a868SElliott Hughes\def\ecfont{\etcfont{e}} 3648*d5c9a868SElliott Hughes\def\tcfont{\etcfont{t}} 3649*d5c9a868SElliott Hughes% 3650*d5c9a868SElliott Hughes\def\etcfont#1{% 3651*d5c9a868SElliott Hughes % We can't distinguish serif/sans and italic/slanted, but this 3652*d5c9a868SElliott Hughes % is used for crude hacks anyway (like adding French and German 3653*d5c9a868SElliott Hughes % quotes to documents typeset with CM, where we lose kerning), so 3654*d5c9a868SElliott Hughes % hopefully nobody will notice/care. 3655*d5c9a868SElliott Hughes \edef\ecsize{\csname\curfontsize ecsize\endcsname}% 3656*d5c9a868SElliott Hughes \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}% 3657*d5c9a868SElliott Hughes \ifmonospace 3658*d5c9a868SElliott Hughes % typewriter: 3659*d5c9a868SElliott Hughes \font\thisecfont = #1ctt\ecsize \space at \nominalsize 3660*d5c9a868SElliott Hughes \else 3661*d5c9a868SElliott Hughes \ifx\curfontstyle\bfstylename 3662*d5c9a868SElliott Hughes % bold: 3663*d5c9a868SElliott Hughes \font\thisecfont = #1cb\ifusingit{i}{x}\ecsize \space at \nominalsize 3664*d5c9a868SElliott Hughes \else 3665*d5c9a868SElliott Hughes % regular: 3666*d5c9a868SElliott Hughes \font\thisecfont = #1c\ifusingit{ti}{rm}\ecsize \space at \nominalsize 3667*d5c9a868SElliott Hughes \fi 3668*d5c9a868SElliott Hughes \fi 3669*d5c9a868SElliott Hughes \thisecfont 3670*d5c9a868SElliott Hughes} 3671*d5c9a868SElliott Hughes 3672*d5c9a868SElliott Hughes% @registeredsymbol - R in a circle. The font for the R should really 3673*d5c9a868SElliott Hughes% be smaller yet, but lllsize is the best we can do for now. 3674*d5c9a868SElliott Hughes% Adapted from the plain.tex definition of \copyright. 3675*d5c9a868SElliott Hughes% 3676*d5c9a868SElliott Hughes\def\registeredsymbol{% 3677*d5c9a868SElliott Hughes $^{{\ooalign{\hfil\raise.07ex\hbox{\switchtolllsize R}% 3678*d5c9a868SElliott Hughes \hfil\crcr\Orb}}% 3679*d5c9a868SElliott Hughes }$% 3680*d5c9a868SElliott Hughes} 3681*d5c9a868SElliott Hughes 3682*d5c9a868SElliott Hughes% @textdegree - the normal degrees sign. 3683*d5c9a868SElliott Hughes% 3684*d5c9a868SElliott Hughes\def\textdegree{$^\circ$} 3685*d5c9a868SElliott Hughes 3686*d5c9a868SElliott Hughes% Laurent Siebenmann reports \Orb undefined with: 3687*d5c9a868SElliott Hughes% Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38 3688*d5c9a868SElliott Hughes% so we'll define it if necessary. 3689*d5c9a868SElliott Hughes% 3690*d5c9a868SElliott Hughes\ifx\Orb\thisisundefined 3691*d5c9a868SElliott Hughes\def\Orb{\mathhexbox20D} 3692*d5c9a868SElliott Hughes\fi 3693*d5c9a868SElliott Hughes 3694*d5c9a868SElliott Hughes% Quotes. 3695*d5c9a868SElliott Hughes\chardef\quoteleft=`\` 3696*d5c9a868SElliott Hughes\chardef\quoteright=`\' 3697*d5c9a868SElliott Hughes 3698*d5c9a868SElliott Hughes% only change font for tt for correct kerning and to avoid using 3699*d5c9a868SElliott Hughes% \ecfont unless necessary. 3700*d5c9a868SElliott Hughes\def\quotedblleft{% 3701*d5c9a868SElliott Hughes \ifmonospace{\ecfont\char"10}\else{\char"5C}\fi 3702*d5c9a868SElliott Hughes} 3703*d5c9a868SElliott Hughes 3704*d5c9a868SElliott Hughes\def\quotedblright{% 3705*d5c9a868SElliott Hughes \ifmonospace{\ecfont\char"11}\else{\char`\"}\fi 3706*d5c9a868SElliott Hughes} 3707*d5c9a868SElliott Hughes 3708*d5c9a868SElliott Hughes 3709*d5c9a868SElliott Hughes\message{page headings,} 3710*d5c9a868SElliott Hughes 3711*d5c9a868SElliott Hughes\newskip\titlepagetopglue \titlepagetopglue = 1.5in 3712*d5c9a868SElliott Hughes\newskip\titlepagebottomglue \titlepagebottomglue = 2pc 3713*d5c9a868SElliott Hughes 3714*d5c9a868SElliott Hughes% First the title page. Must do @settitle before @titlepage. 3715*d5c9a868SElliott Hughes\newif\ifseenauthor 3716*d5c9a868SElliott Hughes\newif\iffinishedtitlepage 3717*d5c9a868SElliott Hughes 3718*d5c9a868SElliott Hughes% @setcontentsaftertitlepage used to do an implicit @contents or 3719*d5c9a868SElliott Hughes% @shortcontents after @end titlepage, but it is now obsolete. 3720*d5c9a868SElliott Hughes\def\setcontentsaftertitlepage{% 3721*d5c9a868SElliott Hughes \errmessage{@setcontentsaftertitlepage has been removed as a Texinfo 3722*d5c9a868SElliott Hughes command; move your @contents command if you want the contents 3723*d5c9a868SElliott Hughes after the title page.}}% 3724*d5c9a868SElliott Hughes\def\setshortcontentsaftertitlepage{% 3725*d5c9a868SElliott Hughes \errmessage{@setshortcontentsaftertitlepage has been removed as a Texinfo 3726*d5c9a868SElliott Hughes command; move your @shortcontents and @contents commands if you 3727*d5c9a868SElliott Hughes want the contents after the title page.}}% 3728*d5c9a868SElliott Hughes 3729*d5c9a868SElliott Hughes\parseargdef\shorttitlepage{% 3730*d5c9a868SElliott Hughes \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}% 3731*d5c9a868SElliott Hughes \endgroup\page\hbox{}\page} 3732*d5c9a868SElliott Hughes 3733*d5c9a868SElliott Hughes\envdef\titlepage{% 3734*d5c9a868SElliott Hughes % Open one extra group, as we want to close it in the middle of \Etitlepage. 3735*d5c9a868SElliott Hughes \begingroup 3736*d5c9a868SElliott Hughes \parindent=0pt \textfonts 3737*d5c9a868SElliott Hughes % Leave some space at the very top of the page. 3738*d5c9a868SElliott Hughes \vglue\titlepagetopglue 3739*d5c9a868SElliott Hughes % No rule at page bottom unless we print one at the top with @title. 3740*d5c9a868SElliott Hughes \finishedtitlepagetrue 3741*d5c9a868SElliott Hughes % 3742*d5c9a868SElliott Hughes % Most title ``pages'' are actually two pages long, with space 3743*d5c9a868SElliott Hughes % at the top of the second. We don't want the ragged left on the second. 3744*d5c9a868SElliott Hughes \let\oldpage = \page 3745*d5c9a868SElliott Hughes \def\page{% 3746*d5c9a868SElliott Hughes \iffinishedtitlepage\else 3747*d5c9a868SElliott Hughes \finishtitlepage 3748*d5c9a868SElliott Hughes \fi 3749*d5c9a868SElliott Hughes \let\page = \oldpage 3750*d5c9a868SElliott Hughes \page 3751*d5c9a868SElliott Hughes \null 3752*d5c9a868SElliott Hughes }% 3753*d5c9a868SElliott Hughes} 3754*d5c9a868SElliott Hughes 3755*d5c9a868SElliott Hughes\def\Etitlepage{% 3756*d5c9a868SElliott Hughes \iffinishedtitlepage\else 3757*d5c9a868SElliott Hughes \finishtitlepage 3758*d5c9a868SElliott Hughes \fi 3759*d5c9a868SElliott Hughes % It is important to do the page break before ending the group, 3760*d5c9a868SElliott Hughes % because the headline and footline are only empty inside the group. 3761*d5c9a868SElliott Hughes % If we use the new definition of \page, we always get a blank page 3762*d5c9a868SElliott Hughes % after the title page, which we certainly don't want. 3763*d5c9a868SElliott Hughes \oldpage 3764*d5c9a868SElliott Hughes \endgroup 3765*d5c9a868SElliott Hughes % 3766*d5c9a868SElliott Hughes % Need this before the \...aftertitlepage checks so that if they are 3767*d5c9a868SElliott Hughes % in effect the toc pages will come out with page numbers. 3768*d5c9a868SElliott Hughes \HEADINGSon 3769*d5c9a868SElliott Hughes} 3770*d5c9a868SElliott Hughes 3771*d5c9a868SElliott Hughes\def\finishtitlepage{% 3772*d5c9a868SElliott Hughes \vskip4pt \hrule height 2pt width \hsize 3773*d5c9a868SElliott Hughes \vskip\titlepagebottomglue 3774*d5c9a868SElliott Hughes \finishedtitlepagetrue 3775*d5c9a868SElliott Hughes} 3776*d5c9a868SElliott Hughes 3777*d5c9a868SElliott Hughes% Settings used for typesetting titles: no hyphenation, no indentation, 3778*d5c9a868SElliott Hughes% don't worry much about spacing, ragged right. This should be used 3779*d5c9a868SElliott Hughes% inside a \vbox, and fonts need to be set appropriately first. \par should 3780*d5c9a868SElliott Hughes% be specified before the end of the \vbox, since a vbox is a group. 3781*d5c9a868SElliott Hughes% 3782*d5c9a868SElliott Hughes\def\raggedtitlesettings{% 3783*d5c9a868SElliott Hughes \rm 3784*d5c9a868SElliott Hughes \hyphenpenalty=10000 3785*d5c9a868SElliott Hughes \parindent=0pt 3786*d5c9a868SElliott Hughes \tolerance=5000 3787*d5c9a868SElliott Hughes \ptexraggedright 3788*d5c9a868SElliott Hughes} 3789*d5c9a868SElliott Hughes 3790*d5c9a868SElliott Hughes% Macros to be used within @titlepage: 3791*d5c9a868SElliott Hughes 3792*d5c9a868SElliott Hughes\let\subtitlerm=\rmfont 3793*d5c9a868SElliott Hughes\def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines} 3794*d5c9a868SElliott Hughes 3795*d5c9a868SElliott Hughes\parseargdef\title{% 3796*d5c9a868SElliott Hughes \checkenv\titlepage 3797*d5c9a868SElliott Hughes \vbox{\titlefonts \raggedtitlesettings #1\par}% 3798*d5c9a868SElliott Hughes % print a rule at the page bottom also. 3799*d5c9a868SElliott Hughes \finishedtitlepagefalse 3800*d5c9a868SElliott Hughes \vskip4pt \hrule height 4pt width \hsize \vskip4pt 3801*d5c9a868SElliott Hughes} 3802*d5c9a868SElliott Hughes 3803*d5c9a868SElliott Hughes\parseargdef\subtitle{% 3804*d5c9a868SElliott Hughes \checkenv\titlepage 3805*d5c9a868SElliott Hughes {\subtitlefont \rightline{#1}}% 3806*d5c9a868SElliott Hughes} 3807*d5c9a868SElliott Hughes 3808*d5c9a868SElliott Hughes% @author should come last, but may come many times. 3809*d5c9a868SElliott Hughes% It can also be used inside @quotation. 3810*d5c9a868SElliott Hughes% 3811*d5c9a868SElliott Hughes\parseargdef\author{% 3812*d5c9a868SElliott Hughes \def\temp{\quotation}% 3813*d5c9a868SElliott Hughes \ifx\thisenv\temp 3814*d5c9a868SElliott Hughes \def\quotationauthor{#1}% printed in \Equotation. 3815*d5c9a868SElliott Hughes \else 3816*d5c9a868SElliott Hughes \checkenv\titlepage 3817*d5c9a868SElliott Hughes \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi 3818*d5c9a868SElliott Hughes {\secfonts\rm \leftline{#1}}% 3819*d5c9a868SElliott Hughes \fi 3820*d5c9a868SElliott Hughes} 3821*d5c9a868SElliott Hughes 3822*d5c9a868SElliott Hughes 3823*d5c9a868SElliott Hughes% Set up page headings and footings. 3824*d5c9a868SElliott Hughes 3825*d5c9a868SElliott Hughes\let\thispage=\folio 3826*d5c9a868SElliott Hughes 3827*d5c9a868SElliott Hughes\newtoks\evenheadline % headline on even pages 3828*d5c9a868SElliott Hughes\newtoks\oddheadline % headline on odd pages 3829*d5c9a868SElliott Hughes\newtoks\evenchapheadline% headline on even pages with a new chapter 3830*d5c9a868SElliott Hughes\newtoks\oddchapheadline % headline on odd pages with a new chapter 3831*d5c9a868SElliott Hughes\newtoks\evenfootline % footline on even pages 3832*d5c9a868SElliott Hughes\newtoks\oddfootline % footline on odd pages 3833*d5c9a868SElliott Hughes 3834*d5c9a868SElliott Hughes% Now make \makeheadline and \makefootline in Plain TeX use those variables 3835*d5c9a868SElliott Hughes\headline={{\textfonts\rm 3836*d5c9a868SElliott Hughes \ifchapterpage 3837*d5c9a868SElliott Hughes \ifodd\pageno\the\oddchapheadline\else\the\evenchapheadline\fi 3838*d5c9a868SElliott Hughes \else 3839*d5c9a868SElliott Hughes \ifodd\pageno\the\oddheadline\else\the\evenheadline\fi 3840*d5c9a868SElliott Hughes \fi}} 3841*d5c9a868SElliott Hughes 3842*d5c9a868SElliott Hughes\footline={{\textfonts\rm \ifodd\pageno \the\oddfootline 3843*d5c9a868SElliott Hughes \else \the\evenfootline \fi}\HEADINGShook} 3844*d5c9a868SElliott Hughes\let\HEADINGShook=\relax 3845*d5c9a868SElliott Hughes 3846*d5c9a868SElliott Hughes% Commands to set those variables. 3847*d5c9a868SElliott Hughes% For example, this is what @headings on does 3848*d5c9a868SElliott Hughes% @evenheading @thistitle|@thispage|@thischapter 3849*d5c9a868SElliott Hughes% @oddheading @thischapter|@thispage|@thistitle 3850*d5c9a868SElliott Hughes% @evenfooting @thisfile|| 3851*d5c9a868SElliott Hughes% @oddfooting ||@thisfile 3852*d5c9a868SElliott Hughes 3853*d5c9a868SElliott Hughes 3854*d5c9a868SElliott Hughes\def\evenheading{\parsearg\evenheadingxxx} 3855*d5c9a868SElliott Hughes\def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish} 3856*d5c9a868SElliott Hughes\def\evenheadingyyy #1\|#2\|#3\|#4\finish{% 3857*d5c9a868SElliott Hughes \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}} 3858*d5c9a868SElliott Hughes \global\evenchapheadline=\evenheadline} 3859*d5c9a868SElliott Hughes 3860*d5c9a868SElliott Hughes\def\oddheading{\parsearg\oddheadingxxx} 3861*d5c9a868SElliott Hughes\def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish} 3862*d5c9a868SElliott Hughes\def\oddheadingyyy #1\|#2\|#3\|#4\finish{% 3863*d5c9a868SElliott Hughes \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}% 3864*d5c9a868SElliott Hughes \global\oddchapheadline=\oddheadline} 3865*d5c9a868SElliott Hughes 3866*d5c9a868SElliott Hughes\parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}% 3867*d5c9a868SElliott Hughes 3868*d5c9a868SElliott Hughes\def\evenfooting{\parsearg\evenfootingxxx} 3869*d5c9a868SElliott Hughes\def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish} 3870*d5c9a868SElliott Hughes\def\evenfootingyyy #1\|#2\|#3\|#4\finish{% 3871*d5c9a868SElliott Hughes\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} 3872*d5c9a868SElliott Hughes 3873*d5c9a868SElliott Hughes\def\oddfooting{\parsearg\oddfootingxxx} 3874*d5c9a868SElliott Hughes\def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish} 3875*d5c9a868SElliott Hughes\def\oddfootingyyy #1\|#2\|#3\|#4\finish{% 3876*d5c9a868SElliott Hughes \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}% 3877*d5c9a868SElliott Hughes % 3878*d5c9a868SElliott Hughes % Leave some space for the footline. Hopefully ok to assume 3879*d5c9a868SElliott Hughes % @evenfooting will not be used by itself. 3880*d5c9a868SElliott Hughes \global\advance\txipageheight by -12pt 3881*d5c9a868SElliott Hughes \global\advance\vsize by -12pt 3882*d5c9a868SElliott Hughes} 3883*d5c9a868SElliott Hughes 3884*d5c9a868SElliott Hughes\parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}} 3885*d5c9a868SElliott Hughes 3886*d5c9a868SElliott Hughes% @evenheadingmarks top \thischapter <- chapter at the top of a page 3887*d5c9a868SElliott Hughes% @evenheadingmarks bottom \thischapter <- chapter at the bottom of a page 3888*d5c9a868SElliott Hughes% 3889*d5c9a868SElliott Hughes% The same set of arguments for: 3890*d5c9a868SElliott Hughes% 3891*d5c9a868SElliott Hughes% @oddheadingmarks 3892*d5c9a868SElliott Hughes% @evenfootingmarks 3893*d5c9a868SElliott Hughes% @oddfootingmarks 3894*d5c9a868SElliott Hughes% @everyheadingmarks 3895*d5c9a868SElliott Hughes% @everyfootingmarks 3896*d5c9a868SElliott Hughes 3897*d5c9a868SElliott Hughes% These define \getoddheadingmarks, \getevenheadingmarks, 3898*d5c9a868SElliott Hughes% \getoddfootingmarks, and \getevenfootingmarks, each to one of 3899*d5c9a868SElliott Hughes% \gettopheadingmarks, \getbottomheadingmarks. 3900*d5c9a868SElliott Hughes% 3901*d5c9a868SElliott Hughes\def\evenheadingmarks{\headingmarks{even}{heading}} 3902*d5c9a868SElliott Hughes\def\oddheadingmarks{\headingmarks{odd}{heading}} 3903*d5c9a868SElliott Hughes\def\evenfootingmarks{\headingmarks{even}{footing}} 3904*d5c9a868SElliott Hughes\def\oddfootingmarks{\headingmarks{odd}{footing}} 3905*d5c9a868SElliott Hughes\parseargdef\everyheadingmarks{\headingmarks{even}{heading}{#1} 3906*d5c9a868SElliott Hughes \headingmarks{odd}{heading}{#1} } 3907*d5c9a868SElliott Hughes\parseargdef\everyfootingmarks{\headingmarks{even}{footing}{#1} 3908*d5c9a868SElliott Hughes \headingmarks{odd}{footing}{#1} } 3909*d5c9a868SElliott Hughes% #1 = even/odd, #2 = heading/footing, #3 = top/bottom. 3910*d5c9a868SElliott Hughes\def\headingmarks#1#2#3 {% 3911*d5c9a868SElliott Hughes \expandafter\let\expandafter\temp \csname get#3headingmarks\endcsname 3912*d5c9a868SElliott Hughes \global\expandafter\let\csname get#1#2marks\endcsname \temp 3913*d5c9a868SElliott Hughes} 3914*d5c9a868SElliott Hughes 3915*d5c9a868SElliott Hughes\everyheadingmarks bottom 3916*d5c9a868SElliott Hughes\everyfootingmarks bottom 3917*d5c9a868SElliott Hughes 3918*d5c9a868SElliott Hughes% @headings double turns headings on for double-sided printing. 3919*d5c9a868SElliott Hughes% @headings single turns headings on for single-sided printing. 3920*d5c9a868SElliott Hughes% @headings off turns them off. 3921*d5c9a868SElliott Hughes% @headings on same as @headings double, retained for compatibility. 3922*d5c9a868SElliott Hughes% @headings after turns on double-sided headings after this page. 3923*d5c9a868SElliott Hughes% @headings doubleafter turns on double-sided headings after this page. 3924*d5c9a868SElliott Hughes% @headings singleafter turns on single-sided headings after this page. 3925*d5c9a868SElliott Hughes% By default, they are off at the start of a document, 3926*d5c9a868SElliott Hughes% and turned `on' after @end titlepage. 3927*d5c9a868SElliott Hughes 3928*d5c9a868SElliott Hughes\parseargdef\headings{\csname HEADINGS#1\endcsname} 3929*d5c9a868SElliott Hughes 3930*d5c9a868SElliott Hughes\def\headingsoff{% non-global headings elimination 3931*d5c9a868SElliott Hughes \evenheadline={\hfil}\evenfootline={\hfil}\evenchapheadline={\hfil}% 3932*d5c9a868SElliott Hughes \oddheadline={\hfil}\oddfootline={\hfil}\oddchapheadline={\hfil}% 3933*d5c9a868SElliott Hughes} 3934*d5c9a868SElliott Hughes 3935*d5c9a868SElliott Hughes\def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting 3936*d5c9a868SElliott Hughes\HEADINGSoff % it's the default 3937*d5c9a868SElliott Hughes 3938*d5c9a868SElliott Hughes% When we turn headings on, set the page number to 1. 3939*d5c9a868SElliott Hughes\def\pageone{ 3940*d5c9a868SElliott Hughes \global\pageno=1 3941*d5c9a868SElliott Hughes \global\arabiccount = \pagecount 3942*d5c9a868SElliott Hughes} 3943*d5c9a868SElliott Hughes 3944*d5c9a868SElliott Hughes% For double-sided printing, put current file name in lower left corner, 3945*d5c9a868SElliott Hughes% chapter name on inside top of right hand pages, document 3946*d5c9a868SElliott Hughes% title on inside top of left hand pages, and page numbers on outside top 3947*d5c9a868SElliott Hughes% edge of all pages. 3948*d5c9a868SElliott Hughes\def\HEADINGSdouble{% 3949*d5c9a868SElliott Hughes\pageone 3950*d5c9a868SElliott Hughes\HEADINGSdoublex 3951*d5c9a868SElliott Hughes} 3952*d5c9a868SElliott Hughes\let\contentsalignmacro = \chappager 3953*d5c9a868SElliott Hughes 3954*d5c9a868SElliott Hughes% For single-sided printing, chapter title goes across top left of page, 3955*d5c9a868SElliott Hughes% page number on top right. 3956*d5c9a868SElliott Hughes\def\HEADINGSsingle{% 3957*d5c9a868SElliott Hughes\pageone 3958*d5c9a868SElliott Hughes\HEADINGSsinglex 3959*d5c9a868SElliott Hughes} 3960*d5c9a868SElliott Hughes\def\HEADINGSon{\HEADINGSdouble} 3961*d5c9a868SElliott Hughes 3962*d5c9a868SElliott Hughes\def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex} 3963*d5c9a868SElliott Hughes\let\HEADINGSdoubleafter=\HEADINGSafter 3964*d5c9a868SElliott Hughes\def\HEADINGSdoublex{% 3965*d5c9a868SElliott Hughes\global\evenfootline={\hfil} 3966*d5c9a868SElliott Hughes\global\oddfootline={\hfil} 3967*d5c9a868SElliott Hughes\global\evenheadline={\line{\folio\hfil\thistitle}} 3968*d5c9a868SElliott Hughes\global\oddheadline={\line{\thischapter\hfil\folio}} 3969*d5c9a868SElliott Hughes\global\evenchapheadline={\line{\folio\hfil}} 3970*d5c9a868SElliott Hughes\global\oddchapheadline={\line{\hfil\folio}} 3971*d5c9a868SElliott Hughes\global\let\contentsalignmacro = \chapoddpage 3972*d5c9a868SElliott Hughes} 3973*d5c9a868SElliott Hughes 3974*d5c9a868SElliott Hughes\def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex} 3975*d5c9a868SElliott Hughes\def\HEADINGSsinglex{% 3976*d5c9a868SElliott Hughes\global\evenfootline={\hfil} 3977*d5c9a868SElliott Hughes\global\oddfootline={\hfil} 3978*d5c9a868SElliott Hughes\global\evenheadline={\line{\thischapter\hfil\folio}} 3979*d5c9a868SElliott Hughes\global\oddheadline={\line{\thischapter\hfil\folio}} 3980*d5c9a868SElliott Hughes\global\evenchapheadline={\line{\hfil\folio}} 3981*d5c9a868SElliott Hughes\global\oddchapheadline={\line{\hfil\folio}} 3982*d5c9a868SElliott Hughes\global\let\contentsalignmacro = \chappager 3983*d5c9a868SElliott Hughes} 3984*d5c9a868SElliott Hughes 3985*d5c9a868SElliott Hughes% for @setchapternewpage off 3986*d5c9a868SElliott Hughes\def\HEADINGSsinglechapoff{% 3987*d5c9a868SElliott Hughes\pageone 3988*d5c9a868SElliott Hughes\global\evenfootline={\hfil} 3989*d5c9a868SElliott Hughes\global\oddfootline={\hfil} 3990*d5c9a868SElliott Hughes\global\evenheadline={\line{\thischapter\hfil\folio}} 3991*d5c9a868SElliott Hughes\global\oddheadline={\line{\thischapter\hfil\folio}} 3992*d5c9a868SElliott Hughes\global\evenchapheadline=\evenheadline 3993*d5c9a868SElliott Hughes\global\oddchapheadline=\oddheadline 3994*d5c9a868SElliott Hughes\global\let\contentsalignmacro = \chappager 3995*d5c9a868SElliott Hughes} 3996*d5c9a868SElliott Hughes 3997*d5c9a868SElliott Hughes% Subroutines used in generating headings 3998*d5c9a868SElliott Hughes% This produces Day Month Year style of output. 3999*d5c9a868SElliott Hughes% Only define if not already defined, in case a txi-??.tex file has set 4000*d5c9a868SElliott Hughes% up a different format (e.g., txi-cs.tex does this). 4001*d5c9a868SElliott Hughes\ifx\today\thisisundefined 4002*d5c9a868SElliott Hughes\def\today{% 4003*d5c9a868SElliott Hughes \number\day\space 4004*d5c9a868SElliott Hughes \ifcase\month 4005*d5c9a868SElliott Hughes \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr 4006*d5c9a868SElliott Hughes \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug 4007*d5c9a868SElliott Hughes \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec 4008*d5c9a868SElliott Hughes \fi 4009*d5c9a868SElliott Hughes \space\number\year} 4010*d5c9a868SElliott Hughes\fi 4011*d5c9a868SElliott Hughes 4012*d5c9a868SElliott Hughes% @settitle line... specifies the title of the document, for headings. 4013*d5c9a868SElliott Hughes% It generates no output of its own. 4014*d5c9a868SElliott Hughes\def\thistitle{\putwordNoTitle} 4015*d5c9a868SElliott Hughes\def\settitle{\parsearg{\gdef\thistitle}} 4016*d5c9a868SElliott Hughes 4017*d5c9a868SElliott Hughes 4018*d5c9a868SElliott Hughes\message{tables,} 4019*d5c9a868SElliott Hughes% Tables -- @table, @ftable, @vtable, @item(x). 4020*d5c9a868SElliott Hughes 4021*d5c9a868SElliott Hughes% default indentation of table text 4022*d5c9a868SElliott Hughes\newdimen\tableindent \tableindent=.8in 4023*d5c9a868SElliott Hughes% default indentation of @itemize and @enumerate text 4024*d5c9a868SElliott Hughes\newdimen\itemindent \itemindent=.3in 4025*d5c9a868SElliott Hughes% margin between end of table item and start of table text. 4026*d5c9a868SElliott Hughes\newdimen\itemmargin \itemmargin=.1in 4027*d5c9a868SElliott Hughes 4028*d5c9a868SElliott Hughes% used internally for \itemindent minus \itemmargin 4029*d5c9a868SElliott Hughes\newdimen\itemmax 4030*d5c9a868SElliott Hughes 4031*d5c9a868SElliott Hughes% Note @table, @ftable, and @vtable define @item, @itemx, etc., with 4032*d5c9a868SElliott Hughes% these defs. 4033*d5c9a868SElliott Hughes% They also define \itemindex 4034*d5c9a868SElliott Hughes% to index the item name in whatever manner is desired (perhaps none). 4035*d5c9a868SElliott Hughes 4036*d5c9a868SElliott Hughes\newif\ifitemxneedsnegativevskip 4037*d5c9a868SElliott Hughes 4038*d5c9a868SElliott Hughes\def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi} 4039*d5c9a868SElliott Hughes 4040*d5c9a868SElliott Hughes\def\internalBitem{\smallbreak \parsearg\itemzzz} 4041*d5c9a868SElliott Hughes\def\internalBitemx{\itemxpar \parsearg\itemzzz} 4042*d5c9a868SElliott Hughes 4043*d5c9a868SElliott Hughes\def\itemzzz #1{\begingroup % 4044*d5c9a868SElliott Hughes \advance\hsize by -\rightskip 4045*d5c9a868SElliott Hughes \advance\hsize by -\tableindent 4046*d5c9a868SElliott Hughes \setbox0=\hbox{\itemindicate{#1}}% 4047*d5c9a868SElliott Hughes \itemindex{#1}% 4048*d5c9a868SElliott Hughes \nobreak % This prevents a break before @itemx. 4049*d5c9a868SElliott Hughes % 4050*d5c9a868SElliott Hughes % If the item text does not fit in the space we have, put it on a line 4051*d5c9a868SElliott Hughes % by itself, and do not allow a page break either before or after that 4052*d5c9a868SElliott Hughes % line. We do not start a paragraph here because then if the next 4053*d5c9a868SElliott Hughes % command is, e.g., @kindex, the whatsit would get put into the 4054*d5c9a868SElliott Hughes % horizontal list on a line by itself, resulting in extra blank space. 4055*d5c9a868SElliott Hughes \ifdim \wd0>\itemmax 4056*d5c9a868SElliott Hughes % 4057*d5c9a868SElliott Hughes % Make this a paragraph so we get the \parskip glue and wrapping, 4058*d5c9a868SElliott Hughes % but leave it ragged-right. 4059*d5c9a868SElliott Hughes \begingroup 4060*d5c9a868SElliott Hughes \advance\leftskip by-\tableindent 4061*d5c9a868SElliott Hughes \advance\hsize by\tableindent 4062*d5c9a868SElliott Hughes \advance\rightskip by0pt plus1fil\relax 4063*d5c9a868SElliott Hughes \leavevmode\unhbox0\par 4064*d5c9a868SElliott Hughes \endgroup 4065*d5c9a868SElliott Hughes % 4066*d5c9a868SElliott Hughes % We're going to be starting a paragraph, but we don't want the 4067*d5c9a868SElliott Hughes % \parskip glue -- logically it's part of the @item we just started. 4068*d5c9a868SElliott Hughes \nobreak \vskip-\parskip 4069*d5c9a868SElliott Hughes % 4070*d5c9a868SElliott Hughes % Stop a page break at the \parskip glue coming up. However, if 4071*d5c9a868SElliott Hughes % what follows is an environment such as @example, there will be no 4072*d5c9a868SElliott Hughes % \parskip glue; then the negative vskip we just inserted would 4073*d5c9a868SElliott Hughes % cause the example and the item to crash together. So we use this 4074*d5c9a868SElliott Hughes % bizarre value of 10001 as a signal to \aboveenvbreak to insert 4075*d5c9a868SElliott Hughes % \parskip glue after all. Section titles are handled this way also. 4076*d5c9a868SElliott Hughes % 4077*d5c9a868SElliott Hughes \penalty 10001 4078*d5c9a868SElliott Hughes \endgroup 4079*d5c9a868SElliott Hughes \itemxneedsnegativevskipfalse 4080*d5c9a868SElliott Hughes \else 4081*d5c9a868SElliott Hughes % The item text fits into the space. Start a paragraph, so that the 4082*d5c9a868SElliott Hughes % following text (if any) will end up on the same line. 4083*d5c9a868SElliott Hughes \noindent 4084*d5c9a868SElliott Hughes % Do this with kerns and \unhbox so that if there is a footnote in 4085*d5c9a868SElliott Hughes % the item text, it can migrate to the main vertical list and 4086*d5c9a868SElliott Hughes % eventually be printed. 4087*d5c9a868SElliott Hughes \nobreak\kern-\tableindent 4088*d5c9a868SElliott Hughes \dimen0 = \itemmax \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0 4089*d5c9a868SElliott Hughes \unhbox0 4090*d5c9a868SElliott Hughes \nobreak\kern\dimen0 4091*d5c9a868SElliott Hughes \endgroup 4092*d5c9a868SElliott Hughes \itemxneedsnegativevskiptrue 4093*d5c9a868SElliott Hughes \fi 4094*d5c9a868SElliott Hughes} 4095*d5c9a868SElliott Hughes 4096*d5c9a868SElliott Hughes\def\item{\errmessage{@item while not in a list environment}} 4097*d5c9a868SElliott Hughes\def\itemx{\errmessage{@itemx while not in a list environment}} 4098*d5c9a868SElliott Hughes 4099*d5c9a868SElliott Hughes% @table, @ftable, @vtable. 4100*d5c9a868SElliott Hughes\envdef\table{% 4101*d5c9a868SElliott Hughes \let\itemindex\gobble 4102*d5c9a868SElliott Hughes \tablecheck{table}% 4103*d5c9a868SElliott Hughes} 4104*d5c9a868SElliott Hughes\envdef\ftable{% 4105*d5c9a868SElliott Hughes \def\itemindex ##1{\doind {fn}{\code{##1}}}% 4106*d5c9a868SElliott Hughes \tablecheck{ftable}% 4107*d5c9a868SElliott Hughes} 4108*d5c9a868SElliott Hughes\envdef\vtable{% 4109*d5c9a868SElliott Hughes \def\itemindex ##1{\doind {vr}{\code{##1}}}% 4110*d5c9a868SElliott Hughes \tablecheck{vtable}% 4111*d5c9a868SElliott Hughes} 4112*d5c9a868SElliott Hughes\def\tablecheck#1{% 4113*d5c9a868SElliott Hughes \ifnum \the\catcode`\^^M=\active 4114*d5c9a868SElliott Hughes \endgroup 4115*d5c9a868SElliott Hughes \errmessage{This command won't work in this context; perhaps the problem is 4116*d5c9a868SElliott Hughes that we are \inenvironment\thisenv}% 4117*d5c9a868SElliott Hughes \def\next{\doignore{#1}}% 4118*d5c9a868SElliott Hughes \else 4119*d5c9a868SElliott Hughes \let\next\tablex 4120*d5c9a868SElliott Hughes \fi 4121*d5c9a868SElliott Hughes \next 4122*d5c9a868SElliott Hughes} 4123*d5c9a868SElliott Hughes\def\tablex#1{% 4124*d5c9a868SElliott Hughes \def\itemindicate{#1}% 4125*d5c9a868SElliott Hughes \parsearg\tabley 4126*d5c9a868SElliott Hughes} 4127*d5c9a868SElliott Hughes\def\tabley#1{% 4128*d5c9a868SElliott Hughes {% 4129*d5c9a868SElliott Hughes \makevalueexpandable 4130*d5c9a868SElliott Hughes \edef\temp{\noexpand\tablez #1\space\space\space}% 4131*d5c9a868SElliott Hughes \expandafter 4132*d5c9a868SElliott Hughes }\temp \endtablez 4133*d5c9a868SElliott Hughes} 4134*d5c9a868SElliott Hughes\def\tablez #1 #2 #3 #4\endtablez{% 4135*d5c9a868SElliott Hughes \aboveenvbreak 4136*d5c9a868SElliott Hughes \ifnum 0#1>0 \advance \leftskip by #1\mil \fi 4137*d5c9a868SElliott Hughes \ifnum 0#2>0 \tableindent=#2\mil \fi 4138*d5c9a868SElliott Hughes \ifnum 0#3>0 \advance \rightskip by #3\mil \fi 4139*d5c9a868SElliott Hughes \itemmax=\tableindent 4140*d5c9a868SElliott Hughes \advance \itemmax by -\itemmargin 4141*d5c9a868SElliott Hughes \advance \leftskip by \tableindent 4142*d5c9a868SElliott Hughes \exdentamount=\tableindent 4143*d5c9a868SElliott Hughes \parindent = 0pt 4144*d5c9a868SElliott Hughes \parskip = \smallskipamount 4145*d5c9a868SElliott Hughes \ifdim \parskip=0pt \parskip=2pt \fi 4146*d5c9a868SElliott Hughes \let\item = \internalBitem 4147*d5c9a868SElliott Hughes \let\itemx = \internalBitemx 4148*d5c9a868SElliott Hughes} 4149*d5c9a868SElliott Hughes\def\Etable{\endgraf\afterenvbreak} 4150*d5c9a868SElliott Hughes\let\Eftable\Etable 4151*d5c9a868SElliott Hughes\let\Evtable\Etable 4152*d5c9a868SElliott Hughes\let\Eitemize\Etable 4153*d5c9a868SElliott Hughes\let\Eenumerate\Etable 4154*d5c9a868SElliott Hughes 4155*d5c9a868SElliott Hughes% This is the counter used by @enumerate, which is really @itemize 4156*d5c9a868SElliott Hughes 4157*d5c9a868SElliott Hughes\newcount \itemno 4158*d5c9a868SElliott Hughes 4159*d5c9a868SElliott Hughes\envdef\itemize{\parsearg\doitemize} 4160*d5c9a868SElliott Hughes 4161*d5c9a868SElliott Hughes\def\doitemize#1{% 4162*d5c9a868SElliott Hughes \aboveenvbreak 4163*d5c9a868SElliott Hughes \itemmax=\itemindent 4164*d5c9a868SElliott Hughes \advance\itemmax by -\itemmargin 4165*d5c9a868SElliott Hughes \advance\leftskip by \itemindent 4166*d5c9a868SElliott Hughes \exdentamount=\itemindent 4167*d5c9a868SElliott Hughes \parindent=0pt 4168*d5c9a868SElliott Hughes \parskip=\smallskipamount 4169*d5c9a868SElliott Hughes \ifdim\parskip=0pt \parskip=2pt \fi 4170*d5c9a868SElliott Hughes % 4171*d5c9a868SElliott Hughes % Try typesetting the item mark so that if the document erroneously says 4172*d5c9a868SElliott Hughes % something like @itemize @samp (intending @table), there's an error 4173*d5c9a868SElliott Hughes % right away at the @itemize. It's not the best error message in the 4174*d5c9a868SElliott Hughes % world, but it's better than leaving it to the @item. This means if 4175*d5c9a868SElliott Hughes % the user wants an empty mark, they have to say @w{} not just @w. 4176*d5c9a868SElliott Hughes \def\itemcontents{#1}% 4177*d5c9a868SElliott Hughes \setbox0 = \hbox{\itemcontents}% 4178*d5c9a868SElliott Hughes % 4179*d5c9a868SElliott Hughes % @itemize with no arg is equivalent to @itemize @bullet. 4180*d5c9a868SElliott Hughes \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi 4181*d5c9a868SElliott Hughes % 4182*d5c9a868SElliott Hughes \let\item=\itemizeitem 4183*d5c9a868SElliott Hughes} 4184*d5c9a868SElliott Hughes 4185*d5c9a868SElliott Hughes% Definition of @item while inside @itemize and @enumerate. 4186*d5c9a868SElliott Hughes% 4187*d5c9a868SElliott Hughes\def\itemizeitem{% 4188*d5c9a868SElliott Hughes \advance\itemno by 1 % for enumerations 4189*d5c9a868SElliott Hughes {\let\par=\endgraf \smallbreak}% reasonable place to break 4190*d5c9a868SElliott Hughes {% 4191*d5c9a868SElliott Hughes % If the document has an @itemize directly after a section title, a 4192*d5c9a868SElliott Hughes % \nobreak will be last on the list, and \sectionheading will have 4193*d5c9a868SElliott Hughes % done a \vskip-\parskip. In that case, we don't want to zero 4194*d5c9a868SElliott Hughes % parskip, or the item text will crash with the heading. On the 4195*d5c9a868SElliott Hughes % other hand, when there is normal text preceding the item (as there 4196*d5c9a868SElliott Hughes % usually is), we do want to zero parskip, or there would be too much 4197*d5c9a868SElliott Hughes % space. In that case, we won't have a \nobreak before. At least 4198*d5c9a868SElliott Hughes % that's the theory. 4199*d5c9a868SElliott Hughes \ifnum\lastpenalty<10000 \parskip=0in \fi 4200*d5c9a868SElliott Hughes \noindent 4201*d5c9a868SElliott Hughes \hbox to 0pt{\hss \itemcontents \kern\itemmargin}% 4202*d5c9a868SElliott Hughes % 4203*d5c9a868SElliott Hughes \ifinner\else 4204*d5c9a868SElliott Hughes \vadjust{\penalty 1200}% not good to break after first line of item. 4205*d5c9a868SElliott Hughes \fi 4206*d5c9a868SElliott Hughes % We can be in inner vertical mode in a footnote, although an 4207*d5c9a868SElliott Hughes % @itemize looks awful there. 4208*d5c9a868SElliott Hughes }% 4209*d5c9a868SElliott Hughes \flushcr 4210*d5c9a868SElliott Hughes} 4211*d5c9a868SElliott Hughes 4212*d5c9a868SElliott Hughes% \splitoff TOKENS\endmark defines \first to be the first token in 4213*d5c9a868SElliott Hughes% TOKENS, and \rest to be the remainder. 4214*d5c9a868SElliott Hughes% 4215*d5c9a868SElliott Hughes\def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}% 4216*d5c9a868SElliott Hughes 4217*d5c9a868SElliott Hughes% Allow an optional argument of an uppercase letter, lowercase letter, 4218*d5c9a868SElliott Hughes% or number, to specify the first label in the enumerated list. No 4219*d5c9a868SElliott Hughes% argument is the same as `1'. 4220*d5c9a868SElliott Hughes% 4221*d5c9a868SElliott Hughes\envparseargdef\enumerate{\enumeratey #1 \endenumeratey} 4222*d5c9a868SElliott Hughes\def\enumeratey #1 #2\endenumeratey{% 4223*d5c9a868SElliott Hughes % If we were given no argument, pretend we were given `1'. 4224*d5c9a868SElliott Hughes \def\thearg{#1}% 4225*d5c9a868SElliott Hughes \ifx\thearg\empty \def\thearg{1}\fi 4226*d5c9a868SElliott Hughes % 4227*d5c9a868SElliott Hughes % Detect if the argument is a single token. If so, it might be a 4228*d5c9a868SElliott Hughes % letter. Otherwise, the only valid thing it can be is a number. 4229*d5c9a868SElliott Hughes % (We will always have one token, because of the test we just made. 4230*d5c9a868SElliott Hughes % This is a good thing, since \splitoff doesn't work given nothing at 4231*d5c9a868SElliott Hughes % all -- the first parameter is undelimited.) 4232*d5c9a868SElliott Hughes \expandafter\splitoff\thearg\endmark 4233*d5c9a868SElliott Hughes \ifx\rest\empty 4234*d5c9a868SElliott Hughes % Only one token in the argument. It could still be anything. 4235*d5c9a868SElliott Hughes % A ``lowercase letter'' is one whose \lccode is nonzero. 4236*d5c9a868SElliott Hughes % An ``uppercase letter'' is one whose \lccode is both nonzero, and 4237*d5c9a868SElliott Hughes % not equal to itself. 4238*d5c9a868SElliott Hughes % Otherwise, we assume it's a number. 4239*d5c9a868SElliott Hughes % 4240*d5c9a868SElliott Hughes % We need the \relax at the end of the \ifnum lines to stop TeX from 4241*d5c9a868SElliott Hughes % continuing to look for a <number>. 4242*d5c9a868SElliott Hughes % 4243*d5c9a868SElliott Hughes \ifnum\lccode\expandafter`\thearg=0\relax 4244*d5c9a868SElliott Hughes \numericenumerate % a number (we hope) 4245*d5c9a868SElliott Hughes \else 4246*d5c9a868SElliott Hughes % It's a letter. 4247*d5c9a868SElliott Hughes \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax 4248*d5c9a868SElliott Hughes \lowercaseenumerate % lowercase letter 4249*d5c9a868SElliott Hughes \else 4250*d5c9a868SElliott Hughes \uppercaseenumerate % uppercase letter 4251*d5c9a868SElliott Hughes \fi 4252*d5c9a868SElliott Hughes \fi 4253*d5c9a868SElliott Hughes \else 4254*d5c9a868SElliott Hughes % Multiple tokens in the argument. We hope it's a number. 4255*d5c9a868SElliott Hughes \numericenumerate 4256*d5c9a868SElliott Hughes \fi 4257*d5c9a868SElliott Hughes} 4258*d5c9a868SElliott Hughes 4259*d5c9a868SElliott Hughes% An @enumerate whose labels are integers. The starting integer is 4260*d5c9a868SElliott Hughes% given in \thearg. 4261*d5c9a868SElliott Hughes% 4262*d5c9a868SElliott Hughes\def\numericenumerate{% 4263*d5c9a868SElliott Hughes \itemno = \thearg 4264*d5c9a868SElliott Hughes \startenumeration{\the\itemno}% 4265*d5c9a868SElliott Hughes} 4266*d5c9a868SElliott Hughes 4267*d5c9a868SElliott Hughes% The starting (lowercase) letter is in \thearg. 4268*d5c9a868SElliott Hughes\def\lowercaseenumerate{% 4269*d5c9a868SElliott Hughes \itemno = \expandafter`\thearg 4270*d5c9a868SElliott Hughes \startenumeration{% 4271*d5c9a868SElliott Hughes % Be sure we're not beyond the end of the alphabet. 4272*d5c9a868SElliott Hughes \ifnum\itemno=0 4273*d5c9a868SElliott Hughes \errmessage{No more lowercase letters in @enumerate; get a bigger 4274*d5c9a868SElliott Hughes alphabet}% 4275*d5c9a868SElliott Hughes \fi 4276*d5c9a868SElliott Hughes \char\lccode\itemno 4277*d5c9a868SElliott Hughes }% 4278*d5c9a868SElliott Hughes} 4279*d5c9a868SElliott Hughes 4280*d5c9a868SElliott Hughes% The starting (uppercase) letter is in \thearg. 4281*d5c9a868SElliott Hughes\def\uppercaseenumerate{% 4282*d5c9a868SElliott Hughes \itemno = \expandafter`\thearg 4283*d5c9a868SElliott Hughes \startenumeration{% 4284*d5c9a868SElliott Hughes % Be sure we're not beyond the end of the alphabet. 4285*d5c9a868SElliott Hughes \ifnum\itemno=0 4286*d5c9a868SElliott Hughes \errmessage{No more uppercase letters in @enumerate; get a bigger 4287*d5c9a868SElliott Hughes alphabet} 4288*d5c9a868SElliott Hughes \fi 4289*d5c9a868SElliott Hughes \char\uccode\itemno 4290*d5c9a868SElliott Hughes }% 4291*d5c9a868SElliott Hughes} 4292*d5c9a868SElliott Hughes 4293*d5c9a868SElliott Hughes% Call \doitemize, adding a period to the first argument and supplying the 4294*d5c9a868SElliott Hughes% common last two arguments. Also subtract one from the initial value in 4295*d5c9a868SElliott Hughes% \itemno, since @item increments \itemno. 4296*d5c9a868SElliott Hughes% 4297*d5c9a868SElliott Hughes\def\startenumeration#1{% 4298*d5c9a868SElliott Hughes \advance\itemno by -1 4299*d5c9a868SElliott Hughes \doitemize{#1.}\flushcr 4300*d5c9a868SElliott Hughes} 4301*d5c9a868SElliott Hughes 4302*d5c9a868SElliott Hughes 4303*d5c9a868SElliott Hughes% @multitable macros 4304*d5c9a868SElliott Hughes 4305*d5c9a868SElliott Hughes% Macros used to set up halign preamble: 4306*d5c9a868SElliott Hughes% 4307*d5c9a868SElliott Hughes\let\endsetuptable\relax 4308*d5c9a868SElliott Hughes\def\xendsetuptable{\endsetuptable} 4309*d5c9a868SElliott Hughes\let\columnfractions\relax 4310*d5c9a868SElliott Hughes\def\xcolumnfractions{\columnfractions} 4311*d5c9a868SElliott Hughes\newif\ifsetpercent 4312*d5c9a868SElliott Hughes 4313*d5c9a868SElliott Hughes% #1 is the @columnfraction, usually a decimal number like .5, but might 4314*d5c9a868SElliott Hughes% be just 1. We just use it, whatever it is. 4315*d5c9a868SElliott Hughes% 4316*d5c9a868SElliott Hughes\def\pickupwholefraction#1 {% 4317*d5c9a868SElliott Hughes \global\advance\colcount by 1 4318*d5c9a868SElliott Hughes \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}% 4319*d5c9a868SElliott Hughes \setuptable 4320*d5c9a868SElliott Hughes} 4321*d5c9a868SElliott Hughes 4322*d5c9a868SElliott Hughes\newcount\colcount 4323*d5c9a868SElliott Hughes\def\setuptable#1{% 4324*d5c9a868SElliott Hughes \def\firstarg{#1}% 4325*d5c9a868SElliott Hughes \ifx\firstarg\xendsetuptable 4326*d5c9a868SElliott Hughes \let\go = \relax 4327*d5c9a868SElliott Hughes \else 4328*d5c9a868SElliott Hughes \ifx\firstarg\xcolumnfractions 4329*d5c9a868SElliott Hughes \global\setpercenttrue 4330*d5c9a868SElliott Hughes \else 4331*d5c9a868SElliott Hughes \ifsetpercent 4332*d5c9a868SElliott Hughes \let\go\pickupwholefraction 4333*d5c9a868SElliott Hughes \else 4334*d5c9a868SElliott Hughes \global\advance\colcount by 1 4335*d5c9a868SElliott Hughes \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a 4336*d5c9a868SElliott Hughes % separator; typically that is always in the input, anyway. 4337*d5c9a868SElliott Hughes \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}% 4338*d5c9a868SElliott Hughes \fi 4339*d5c9a868SElliott Hughes \fi 4340*d5c9a868SElliott Hughes \ifx\go\pickupwholefraction 4341*d5c9a868SElliott Hughes % Put the argument back for the \pickupwholefraction call, so 4342*d5c9a868SElliott Hughes % we'll always have a period there to be parsed. 4343*d5c9a868SElliott Hughes \def\go{\pickupwholefraction#1}% 4344*d5c9a868SElliott Hughes \else 4345*d5c9a868SElliott Hughes \let\go = \setuptable 4346*d5c9a868SElliott Hughes \fi% 4347*d5c9a868SElliott Hughes \fi 4348*d5c9a868SElliott Hughes \go 4349*d5c9a868SElliott Hughes} 4350*d5c9a868SElliott Hughes 4351*d5c9a868SElliott Hughes% @headitem starts a heading row, which we typeset in bold. Assignments 4352*d5c9a868SElliott Hughes% have to be global since we are inside the implicit group of an 4353*d5c9a868SElliott Hughes% alignment entry. \everycr below resets \everytab so we don't have to 4354*d5c9a868SElliott Hughes% undo it ourselves. 4355*d5c9a868SElliott Hughes\def\headitemfont{\b}% for people to use in the template row; not changeable 4356*d5c9a868SElliott Hughes\def\headitem{% 4357*d5c9a868SElliott Hughes \checkenv\multitable 4358*d5c9a868SElliott Hughes \crcr 4359*d5c9a868SElliott Hughes \gdef\headitemcrhook{\nobreak}% attempt to avoid page break after headings 4360*d5c9a868SElliott Hughes \global\everytab={\bf}% can't use \headitemfont since the parsing differs 4361*d5c9a868SElliott Hughes \the\everytab % for the first item 4362*d5c9a868SElliott Hughes}% 4363*d5c9a868SElliott Hughes% 4364*d5c9a868SElliott Hughes% default for tables with no headings. 4365*d5c9a868SElliott Hughes\let\headitemcrhook=\relax 4366*d5c9a868SElliott Hughes% 4367*d5c9a868SElliott Hughes\def\tab{\checkenv\multitable &\the\everytab}% 4368*d5c9a868SElliott Hughes 4369*d5c9a868SElliott Hughes\newtoks\everytab % insert after every tab. 4370*d5c9a868SElliott Hughes% 4371*d5c9a868SElliott Hughes\envdef\multitable{% 4372*d5c9a868SElliott Hughes \vskip\parskip 4373*d5c9a868SElliott Hughes \startsavinginserts 4374*d5c9a868SElliott Hughes % 4375*d5c9a868SElliott Hughes % @item within a multitable starts a normal row. 4376*d5c9a868SElliott Hughes % We use \def instead of \let so that if one of the multitable entries 4377*d5c9a868SElliott Hughes % contains an @itemize, we don't choke on the \item (seen as \crcr aka 4378*d5c9a868SElliott Hughes % \endtemplate) expanding \doitemize. 4379*d5c9a868SElliott Hughes \def\item{\crcr}% 4380*d5c9a868SElliott Hughes % 4381*d5c9a868SElliott Hughes \tolerance=9500 4382*d5c9a868SElliott Hughes \hbadness=9500 4383*d5c9a868SElliott Hughes \parskip=0pt 4384*d5c9a868SElliott Hughes \parindent=6pt 4385*d5c9a868SElliott Hughes \overfullrule=0pt 4386*d5c9a868SElliott Hughes \global\colcount=0 4387*d5c9a868SElliott Hughes % 4388*d5c9a868SElliott Hughes \everycr = {% 4389*d5c9a868SElliott Hughes \noalign{% 4390*d5c9a868SElliott Hughes \global\everytab={}% Reset from possible headitem. 4391*d5c9a868SElliott Hughes \global\colcount=0 % Reset the column counter. 4392*d5c9a868SElliott Hughes % 4393*d5c9a868SElliott Hughes % Check for saved footnotes, etc.: 4394*d5c9a868SElliott Hughes \checkinserts 4395*d5c9a868SElliott Hughes % 4396*d5c9a868SElliott Hughes % Perhaps a \nobreak, then reset: 4397*d5c9a868SElliott Hughes \headitemcrhook 4398*d5c9a868SElliott Hughes \global\let\headitemcrhook=\relax 4399*d5c9a868SElliott Hughes }% 4400*d5c9a868SElliott Hughes }% 4401*d5c9a868SElliott Hughes % 4402*d5c9a868SElliott Hughes \parsearg\domultitable 4403*d5c9a868SElliott Hughes} 4404*d5c9a868SElliott Hughes\def\domultitable#1{% 4405*d5c9a868SElliott Hughes % To parse everything between @multitable and @item: 4406*d5c9a868SElliott Hughes \setuptable#1 \endsetuptable 4407*d5c9a868SElliott Hughes % 4408*d5c9a868SElliott Hughes % This preamble sets up a generic column definition, which will 4409*d5c9a868SElliott Hughes % be used as many times as user calls for columns. 4410*d5c9a868SElliott Hughes % \vtop will set a single line and will also let text wrap and 4411*d5c9a868SElliott Hughes % continue for many paragraphs if desired. 4412*d5c9a868SElliott Hughes \halign\bgroup &% 4413*d5c9a868SElliott Hughes \global\advance\colcount by 1 4414*d5c9a868SElliott Hughes \strut 4415*d5c9a868SElliott Hughes \vtop{% 4416*d5c9a868SElliott Hughes \advance\hsize by -1\leftskip 4417*d5c9a868SElliott Hughes % Find the correct column width 4418*d5c9a868SElliott Hughes \hsize=\expandafter\csname col\the\colcount\endcsname 4419*d5c9a868SElliott Hughes % 4420*d5c9a868SElliott Hughes \rightskip=0pt 4421*d5c9a868SElliott Hughes \ifnum\colcount=1 4422*d5c9a868SElliott Hughes \advance\hsize by\leftskip % Add indent of surrounding text 4423*d5c9a868SElliott Hughes \else 4424*d5c9a868SElliott Hughes % In order to keep entries from bumping into each other. 4425*d5c9a868SElliott Hughes \leftskip=12pt 4426*d5c9a868SElliott Hughes \ifsetpercent \else 4427*d5c9a868SElliott Hughes % If a template has been used 4428*d5c9a868SElliott Hughes \advance\hsize by \leftskip 4429*d5c9a868SElliott Hughes \fi 4430*d5c9a868SElliott Hughes \fi 4431*d5c9a868SElliott Hughes \noindent\ignorespaces##\unskip\strut 4432*d5c9a868SElliott Hughes }\cr 4433*d5c9a868SElliott Hughes} 4434*d5c9a868SElliott Hughes\def\Emultitable{% 4435*d5c9a868SElliott Hughes \crcr 4436*d5c9a868SElliott Hughes \egroup % end the \halign 4437*d5c9a868SElliott Hughes \global\setpercentfalse 4438*d5c9a868SElliott Hughes} 4439*d5c9a868SElliott Hughes 4440*d5c9a868SElliott Hughes 4441*d5c9a868SElliott Hughes\message{conditionals,} 4442*d5c9a868SElliott Hughes 4443*d5c9a868SElliott Hughes% @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext, 4444*d5c9a868SElliott Hughes% @ifnotxml always succeed. They currently do nothing; we don't 4445*d5c9a868SElliott Hughes% attempt to check whether the conditionals are properly nested. But we 4446*d5c9a868SElliott Hughes% have to remember that they are conditionals, so that @end doesn't 4447*d5c9a868SElliott Hughes% attempt to close an environment group. 4448*d5c9a868SElliott Hughes% 4449*d5c9a868SElliott Hughes\def\makecond#1{% 4450*d5c9a868SElliott Hughes \expandafter\let\csname #1\endcsname = \relax 4451*d5c9a868SElliott Hughes \expandafter\let\csname iscond.#1\endcsname = 1 4452*d5c9a868SElliott Hughes} 4453*d5c9a868SElliott Hughes\makecond{iftex} 4454*d5c9a868SElliott Hughes\makecond{ifnotdocbook} 4455*d5c9a868SElliott Hughes\makecond{ifnothtml} 4456*d5c9a868SElliott Hughes\makecond{ifnotinfo} 4457*d5c9a868SElliott Hughes\makecond{ifnotplaintext} 4458*d5c9a868SElliott Hughes\makecond{ifnotxml} 4459*d5c9a868SElliott Hughes 4460*d5c9a868SElliott Hughes% Ignore @ignore, @ifhtml, @ifinfo, and the like. 4461*d5c9a868SElliott Hughes% 4462*d5c9a868SElliott Hughes\def\direntry{\doignore{direntry}} 4463*d5c9a868SElliott Hughes\def\documentdescription{\doignore{documentdescription}} 4464*d5c9a868SElliott Hughes\def\docbook{\doignore{docbook}} 4465*d5c9a868SElliott Hughes\def\html{\doignore{html}} 4466*d5c9a868SElliott Hughes\def\ifdocbook{\doignore{ifdocbook}} 4467*d5c9a868SElliott Hughes\def\ifhtml{\doignore{ifhtml}} 4468*d5c9a868SElliott Hughes\def\ifinfo{\doignore{ifinfo}} 4469*d5c9a868SElliott Hughes\def\ifnottex{\doignore{ifnottex}} 4470*d5c9a868SElliott Hughes\def\ifplaintext{\doignore{ifplaintext}} 4471*d5c9a868SElliott Hughes\def\ifxml{\doignore{ifxml}} 4472*d5c9a868SElliott Hughes\def\ignore{\doignore{ignore}} 4473*d5c9a868SElliott Hughes\def\menu{\doignore{menu}} 4474*d5c9a868SElliott Hughes\def\xml{\doignore{xml}} 4475*d5c9a868SElliott Hughes 4476*d5c9a868SElliott Hughes% Ignore text until a line `@end #1', keeping track of nested conditionals. 4477*d5c9a868SElliott Hughes% 4478*d5c9a868SElliott Hughes% A count to remember the depth of nesting. 4479*d5c9a868SElliott Hughes\newcount\doignorecount 4480*d5c9a868SElliott Hughes 4481*d5c9a868SElliott Hughes\def\doignore#1{\begingroup 4482*d5c9a868SElliott Hughes % Scan in ``verbatim'' mode: 4483*d5c9a868SElliott Hughes \obeylines 4484*d5c9a868SElliott Hughes \catcode`\@ = \other 4485*d5c9a868SElliott Hughes \catcode`\{ = \other 4486*d5c9a868SElliott Hughes \catcode`\} = \other 4487*d5c9a868SElliott Hughes % 4488*d5c9a868SElliott Hughes % Make sure that spaces turn into tokens that match what \doignoretext wants. 4489*d5c9a868SElliott Hughes \spaceisspace 4490*d5c9a868SElliott Hughes % 4491*d5c9a868SElliott Hughes % Count number of #1's that we've seen. 4492*d5c9a868SElliott Hughes \doignorecount = 0 4493*d5c9a868SElliott Hughes % 4494*d5c9a868SElliott Hughes % Swallow text until we reach the matching `@end #1'. 4495*d5c9a868SElliott Hughes \dodoignore{#1}% 4496*d5c9a868SElliott Hughes} 4497*d5c9a868SElliott Hughes 4498*d5c9a868SElliott Hughes{ \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source. 4499*d5c9a868SElliott Hughes \obeylines % 4500*d5c9a868SElliott Hughes % 4501*d5c9a868SElliott Hughes \gdef\dodoignore#1{% 4502*d5c9a868SElliott Hughes % #1 contains the command name as a string, e.g., `ifinfo'. 4503*d5c9a868SElliott Hughes % 4504*d5c9a868SElliott Hughes % Define a command to find the next `@end #1'. 4505*d5c9a868SElliott Hughes \long\def\doignoretext##1^^M@end #1{% 4506*d5c9a868SElliott Hughes \doignoretextyyy##1^^M@#1\_STOP_}% 4507*d5c9a868SElliott Hughes % 4508*d5c9a868SElliott Hughes % And this command to find another #1 command, at the beginning of a 4509*d5c9a868SElliott Hughes % line. (Otherwise, we would consider a line `@c @ifset', for 4510*d5c9a868SElliott Hughes % example, to count as an @ifset for nesting.) 4511*d5c9a868SElliott Hughes \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}% 4512*d5c9a868SElliott Hughes % 4513*d5c9a868SElliott Hughes % And now expand that command. 4514*d5c9a868SElliott Hughes \doignoretext ^^M% 4515*d5c9a868SElliott Hughes }% 4516*d5c9a868SElliott Hughes} 4517*d5c9a868SElliott Hughes 4518*d5c9a868SElliott Hughes\def\doignoreyyy#1{% 4519*d5c9a868SElliott Hughes \def\temp{#1}% 4520*d5c9a868SElliott Hughes \ifx\temp\empty % Nothing found. 4521*d5c9a868SElliott Hughes \let\next\doignoretextzzz 4522*d5c9a868SElliott Hughes \else % Found a nested condition, ... 4523*d5c9a868SElliott Hughes \advance\doignorecount by 1 4524*d5c9a868SElliott Hughes \let\next\doignoretextyyy % ..., look for another. 4525*d5c9a868SElliott Hughes % If we're here, #1 ends with ^^M\ifinfo (for example). 4526*d5c9a868SElliott Hughes \fi 4527*d5c9a868SElliott Hughes \next #1% the token \_STOP_ is present just after this macro. 4528*d5c9a868SElliott Hughes} 4529*d5c9a868SElliott Hughes 4530*d5c9a868SElliott Hughes% We have to swallow the remaining "\_STOP_". 4531*d5c9a868SElliott Hughes% 4532*d5c9a868SElliott Hughes\def\doignoretextzzz#1{% 4533*d5c9a868SElliott Hughes \ifnum\doignorecount = 0 % We have just found the outermost @end. 4534*d5c9a868SElliott Hughes \let\next\enddoignore 4535*d5c9a868SElliott Hughes \else % Still inside a nested condition. 4536*d5c9a868SElliott Hughes \advance\doignorecount by -1 4537*d5c9a868SElliott Hughes \let\next\doignoretext % Look for the next @end. 4538*d5c9a868SElliott Hughes \fi 4539*d5c9a868SElliott Hughes \next 4540*d5c9a868SElliott Hughes} 4541*d5c9a868SElliott Hughes 4542*d5c9a868SElliott Hughes% Finish off ignored text. 4543*d5c9a868SElliott Hughes{ \obeylines% 4544*d5c9a868SElliott Hughes % Ignore anything after the last `@end #1'; this matters in verbatim 4545*d5c9a868SElliott Hughes % environments, where otherwise the newline after an ignored conditional 4546*d5c9a868SElliott Hughes % would result in a blank line in the output. 4547*d5c9a868SElliott Hughes \gdef\enddoignore#1^^M{\endgroup\ignorespaces}% 4548*d5c9a868SElliott Hughes} 4549*d5c9a868SElliott Hughes 4550*d5c9a868SElliott Hughes 4551*d5c9a868SElliott Hughes% @set VAR sets the variable VAR to an empty value. 4552*d5c9a868SElliott Hughes% @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE. 4553*d5c9a868SElliott Hughes% 4554*d5c9a868SElliott Hughes% Since we want to separate VAR from REST-OF-LINE (which might be 4555*d5c9a868SElliott Hughes% empty), we can't just use \parsearg; we have to insert a space of our 4556*d5c9a868SElliott Hughes% own to delimit the rest of the line, and then take it out again if we 4557*d5c9a868SElliott Hughes% didn't need it. 4558*d5c9a868SElliott Hughes% We rely on the fact that \parsearg sets \catcode`\ =10. 4559*d5c9a868SElliott Hughes% 4560*d5c9a868SElliott Hughes\parseargdef\set{\setyyy#1 \endsetyyy} 4561*d5c9a868SElliott Hughes\def\setyyy#1 #2\endsetyyy{% 4562*d5c9a868SElliott Hughes {% 4563*d5c9a868SElliott Hughes \makevalueexpandable 4564*d5c9a868SElliott Hughes \def\temp{#2}% 4565*d5c9a868SElliott Hughes \edef\next{\gdef\makecsname{SET#1}}% 4566*d5c9a868SElliott Hughes \ifx\temp\empty 4567*d5c9a868SElliott Hughes \next{}% 4568*d5c9a868SElliott Hughes \else 4569*d5c9a868SElliott Hughes \setzzz#2\endsetzzz 4570*d5c9a868SElliott Hughes \fi 4571*d5c9a868SElliott Hughes }% 4572*d5c9a868SElliott Hughes} 4573*d5c9a868SElliott Hughes% Remove the trailing space \setxxx inserted. 4574*d5c9a868SElliott Hughes\def\setzzz#1 \endsetzzz{\next{#1}} 4575*d5c9a868SElliott Hughes 4576*d5c9a868SElliott Hughes% @clear VAR clears (i.e., unsets) the variable VAR. 4577*d5c9a868SElliott Hughes% 4578*d5c9a868SElliott Hughes\parseargdef\clear{% 4579*d5c9a868SElliott Hughes {% 4580*d5c9a868SElliott Hughes \makevalueexpandable 4581*d5c9a868SElliott Hughes \global\expandafter\let\csname SET#1\endcsname=\relax 4582*d5c9a868SElliott Hughes }% 4583*d5c9a868SElliott Hughes} 4584*d5c9a868SElliott Hughes 4585*d5c9a868SElliott Hughes% @value{foo} gets the text saved in variable foo. 4586*d5c9a868SElliott Hughes\def\value{\begingroup\makevalueexpandable\valuexxx} 4587*d5c9a868SElliott Hughes\def\valuexxx#1{\expandablevalue{#1}\endgroup} 4588*d5c9a868SElliott Hughes{ 4589*d5c9a868SElliott Hughes \catcode`\-=\active \catcode`\_=\active 4590*d5c9a868SElliott Hughes % 4591*d5c9a868SElliott Hughes \gdef\makevalueexpandable{% 4592*d5c9a868SElliott Hughes \let\value = \expandablevalue 4593*d5c9a868SElliott Hughes % We don't want these characters active, ... 4594*d5c9a868SElliott Hughes \catcode`\-=\other \catcode`\_=\other 4595*d5c9a868SElliott Hughes % ..., but we might end up with active ones in the argument if 4596*d5c9a868SElliott Hughes % we're called from @code, as @code{@value{foo-bar_}}, though. 4597*d5c9a868SElliott Hughes % So \let them to their normal equivalents. 4598*d5c9a868SElliott Hughes \let-\normaldash \let_\normalunderscore 4599*d5c9a868SElliott Hughes } 4600*d5c9a868SElliott Hughes} 4601*d5c9a868SElliott Hughes 4602*d5c9a868SElliott Hughes\def\expandablevalue#1{% 4603*d5c9a868SElliott Hughes \expandafter\ifx\csname SET#1\endcsname\relax 4604*d5c9a868SElliott Hughes {[No value for ``#1'']}% 4605*d5c9a868SElliott Hughes \message{Variable `#1', used in @value, is not set.}% 4606*d5c9a868SElliott Hughes \else 4607*d5c9a868SElliott Hughes \csname SET#1\endcsname 4608*d5c9a868SElliott Hughes \fi 4609*d5c9a868SElliott Hughes} 4610*d5c9a868SElliott Hughes 4611*d5c9a868SElliott Hughes% Like \expandablevalue, but completely expandable (the \message in the 4612*d5c9a868SElliott Hughes% definition above operates at the execution level of TeX). Used when 4613*d5c9a868SElliott Hughes% writing to auxiliary files, due to the expansion that \write does. 4614*d5c9a868SElliott Hughes% If flag is undefined, pass through an unexpanded @value command: maybe it 4615*d5c9a868SElliott Hughes% will be set by the time it is read back in. 4616*d5c9a868SElliott Hughes% 4617*d5c9a868SElliott Hughes% NB flag names containing - or _ may not work here. 4618*d5c9a868SElliott Hughes\def\dummyvalue#1{% 4619*d5c9a868SElliott Hughes \expandafter\ifx\csname SET#1\endcsname\relax 4620*d5c9a868SElliott Hughes \string\value{#1}% 4621*d5c9a868SElliott Hughes \else 4622*d5c9a868SElliott Hughes \csname SET#1\endcsname 4623*d5c9a868SElliott Hughes \fi 4624*d5c9a868SElliott Hughes} 4625*d5c9a868SElliott Hughes 4626*d5c9a868SElliott Hughes% Used for @value's in index entries to form the sort key: expand the @value 4627*d5c9a868SElliott Hughes% if possible, otherwise sort late. 4628*d5c9a868SElliott Hughes\def\indexnofontsvalue#1{% 4629*d5c9a868SElliott Hughes \expandafter\ifx\csname SET#1\endcsname\relax 4630*d5c9a868SElliott Hughes ZZZZZZZ% 4631*d5c9a868SElliott Hughes \else 4632*d5c9a868SElliott Hughes \csname SET#1\endcsname 4633*d5c9a868SElliott Hughes \fi 4634*d5c9a868SElliott Hughes} 4635*d5c9a868SElliott Hughes 4636*d5c9a868SElliott Hughes% @ifset VAR ... @end ifset reads the `...' iff VAR has been defined 4637*d5c9a868SElliott Hughes% with @set. 4638*d5c9a868SElliott Hughes% 4639*d5c9a868SElliott Hughes% To get the special treatment we need for `@end ifset,' we call 4640*d5c9a868SElliott Hughes% \makecond and then redefine. 4641*d5c9a868SElliott Hughes% 4642*d5c9a868SElliott Hughes\makecond{ifset} 4643*d5c9a868SElliott Hughes\def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}} 4644*d5c9a868SElliott Hughes\def\doifset#1#2{% 4645*d5c9a868SElliott Hughes {% 4646*d5c9a868SElliott Hughes \makevalueexpandable 4647*d5c9a868SElliott Hughes \let\next=\empty 4648*d5c9a868SElliott Hughes \expandafter\ifx\csname SET#2\endcsname\relax 4649*d5c9a868SElliott Hughes #1% If not set, redefine \next. 4650*d5c9a868SElliott Hughes \fi 4651*d5c9a868SElliott Hughes \expandafter 4652*d5c9a868SElliott Hughes }\next 4653*d5c9a868SElliott Hughes} 4654*d5c9a868SElliott Hughes\def\ifsetfail{\doignore{ifset}} 4655*d5c9a868SElliott Hughes 4656*d5c9a868SElliott Hughes% @ifclear VAR ... @end executes the `...' iff VAR has never been 4657*d5c9a868SElliott Hughes% defined with @set, or has been undefined with @clear. 4658*d5c9a868SElliott Hughes% 4659*d5c9a868SElliott Hughes% The `\else' inside the `\doifset' parameter is a trick to reuse the 4660*d5c9a868SElliott Hughes% above code: if the variable is not set, do nothing, if it is set, 4661*d5c9a868SElliott Hughes% then redefine \next to \ifclearfail. 4662*d5c9a868SElliott Hughes% 4663*d5c9a868SElliott Hughes\makecond{ifclear} 4664*d5c9a868SElliott Hughes\def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}} 4665*d5c9a868SElliott Hughes\def\ifclearfail{\doignore{ifclear}} 4666*d5c9a868SElliott Hughes 4667*d5c9a868SElliott Hughes% @ifcommandisdefined CMD ... @end executes the `...' if CMD (written 4668*d5c9a868SElliott Hughes% without the @) is in fact defined. We can only feasibly check at the 4669*d5c9a868SElliott Hughes% TeX level, so something like `mathcode' is going to considered 4670*d5c9a868SElliott Hughes% defined even though it is not a Texinfo command. 4671*d5c9a868SElliott Hughes% 4672*d5c9a868SElliott Hughes\makecond{ifcommanddefined} 4673*d5c9a868SElliott Hughes\def\ifcommanddefined{\parsearg{\doifcmddefined{\let\next=\ifcmddefinedfail}}} 4674*d5c9a868SElliott Hughes% 4675*d5c9a868SElliott Hughes\def\doifcmddefined#1#2{{% 4676*d5c9a868SElliott Hughes \makevalueexpandable 4677*d5c9a868SElliott Hughes \let\next=\empty 4678*d5c9a868SElliott Hughes \expandafter\ifx\csname #2\endcsname\relax 4679*d5c9a868SElliott Hughes #1% If not defined, \let\next as above. 4680*d5c9a868SElliott Hughes \fi 4681*d5c9a868SElliott Hughes \expandafter 4682*d5c9a868SElliott Hughes }\next 4683*d5c9a868SElliott Hughes} 4684*d5c9a868SElliott Hughes\def\ifcmddefinedfail{\doignore{ifcommanddefined}} 4685*d5c9a868SElliott Hughes 4686*d5c9a868SElliott Hughes% @ifcommandnotdefined CMD ... handled similar to @ifclear above. 4687*d5c9a868SElliott Hughes\makecond{ifcommandnotdefined} 4688*d5c9a868SElliott Hughes\def\ifcommandnotdefined{% 4689*d5c9a868SElliott Hughes \parsearg{\doifcmddefined{\else \let\next=\ifcmdnotdefinedfail}}} 4690*d5c9a868SElliott Hughes\def\ifcmdnotdefinedfail{\doignore{ifcommandnotdefined}} 4691*d5c9a868SElliott Hughes 4692*d5c9a868SElliott Hughes% Set the `txicommandconditionals' variable, so documents have a way to 4693*d5c9a868SElliott Hughes% test if the @ifcommand...defined conditionals are available. 4694*d5c9a868SElliott Hughes\set txicommandconditionals 4695*d5c9a868SElliott Hughes 4696*d5c9a868SElliott Hughes% @dircategory CATEGORY -- specify a category of the dir file 4697*d5c9a868SElliott Hughes% which this file should belong to. Ignore this in TeX. 4698*d5c9a868SElliott Hughes\let\dircategory=\comment 4699*d5c9a868SElliott Hughes 4700*d5c9a868SElliott Hughes% @defininfoenclose. 4701*d5c9a868SElliott Hughes\let\definfoenclose=\comment 4702*d5c9a868SElliott Hughes 4703*d5c9a868SElliott Hughes 4704*d5c9a868SElliott Hughes\message{indexing,} 4705*d5c9a868SElliott Hughes% Index generation facilities 4706*d5c9a868SElliott Hughes 4707*d5c9a868SElliott Hughes% Define \newwrite to be identical to plain tex's \newwrite 4708*d5c9a868SElliott Hughes% except not \outer, so it can be used within macros and \if's. 4709*d5c9a868SElliott Hughes\edef\newwrite{\makecsname{ptexnewwrite}} 4710*d5c9a868SElliott Hughes 4711*d5c9a868SElliott Hughes% \newindex {foo} defines an index named IX. 4712*d5c9a868SElliott Hughes% It automatically defines \IXindex such that 4713*d5c9a868SElliott Hughes% \IXindex ...rest of line... puts an entry in the index IX. 4714*d5c9a868SElliott Hughes% It also defines \IXindfile to be the number of the output channel for 4715*d5c9a868SElliott Hughes% the file that accumulates this index. The file's extension is IX. 4716*d5c9a868SElliott Hughes% The name of an index should be no more than 2 characters long 4717*d5c9a868SElliott Hughes% for the sake of vms. 4718*d5c9a868SElliott Hughes% 4719*d5c9a868SElliott Hughes\def\newindex#1{% 4720*d5c9a868SElliott Hughes \expandafter\chardef\csname#1indfile\endcsname=0 4721*d5c9a868SElliott Hughes \expandafter\xdef\csname#1index\endcsname{% % Define @#1index 4722*d5c9a868SElliott Hughes \noexpand\doindex{#1}} 4723*d5c9a868SElliott Hughes} 4724*d5c9a868SElliott Hughes 4725*d5c9a868SElliott Hughes% @defindex foo == \newindex{foo} 4726*d5c9a868SElliott Hughes% 4727*d5c9a868SElliott Hughes\def\defindex{\parsearg\newindex} 4728*d5c9a868SElliott Hughes 4729*d5c9a868SElliott Hughes% Define @defcodeindex, like @defindex except put all entries in @code. 4730*d5c9a868SElliott Hughes% 4731*d5c9a868SElliott Hughes\def\defcodeindex{\parsearg\newcodeindex} 4732*d5c9a868SElliott Hughes% 4733*d5c9a868SElliott Hughes\def\newcodeindex#1{% 4734*d5c9a868SElliott Hughes \expandafter\chardef\csname#1indfile\endcsname=0 4735*d5c9a868SElliott Hughes \expandafter\xdef\csname#1index\endcsname{% 4736*d5c9a868SElliott Hughes \noexpand\docodeindex{#1}}% 4737*d5c9a868SElliott Hughes} 4738*d5c9a868SElliott Hughes 4739*d5c9a868SElliott Hughes% The default indices: 4740*d5c9a868SElliott Hughes\newindex{cp}% concepts, 4741*d5c9a868SElliott Hughes\newcodeindex{fn}% functions, 4742*d5c9a868SElliott Hughes\newcodeindex{vr}% variables, 4743*d5c9a868SElliott Hughes\newcodeindex{tp}% types, 4744*d5c9a868SElliott Hughes\newcodeindex{ky}% keys 4745*d5c9a868SElliott Hughes\newcodeindex{pg}% and programs. 4746*d5c9a868SElliott Hughes 4747*d5c9a868SElliott Hughes 4748*d5c9a868SElliott Hughes% @synindex foo bar makes index foo feed into index bar. 4749*d5c9a868SElliott Hughes% Do this instead of @defindex foo if you don't want it as a separate index. 4750*d5c9a868SElliott Hughes% 4751*d5c9a868SElliott Hughes% @syncodeindex foo bar similar, but put all entries made for index foo 4752*d5c9a868SElliott Hughes% inside @code. 4753*d5c9a868SElliott Hughes% 4754*d5c9a868SElliott Hughes\def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}} 4755*d5c9a868SElliott Hughes\def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}} 4756*d5c9a868SElliott Hughes 4757*d5c9a868SElliott Hughes% #1 is \doindex or \docodeindex, #2 the index getting redefined (foo), 4758*d5c9a868SElliott Hughes% #3 the target index (bar). 4759*d5c9a868SElliott Hughes\def\dosynindex#1#2#3{% 4760*d5c9a868SElliott Hughes \requireopenindexfile{#3}% 4761*d5c9a868SElliott Hughes % redefine \fooindfile: 4762*d5c9a868SElliott Hughes \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname 4763*d5c9a868SElliott Hughes \expandafter\let\csname#2indfile\endcsname=\temp 4764*d5c9a868SElliott Hughes % redefine \fooindex: 4765*d5c9a868SElliott Hughes \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}% 4766*d5c9a868SElliott Hughes} 4767*d5c9a868SElliott Hughes 4768*d5c9a868SElliott Hughes% Define \doindex, the driver for all index macros. 4769*d5c9a868SElliott Hughes% Argument #1 is generated by the calling \fooindex macro, 4770*d5c9a868SElliott Hughes% and it is the two-letter name of the index. 4771*d5c9a868SElliott Hughes 4772*d5c9a868SElliott Hughes\def\doindex#1{\edef\indexname{#1}\parsearg\doindexxxx} 4773*d5c9a868SElliott Hughes\def\doindexxxx #1{\doind{\indexname}{#1}} 4774*d5c9a868SElliott Hughes 4775*d5c9a868SElliott Hughes% like the previous two, but they put @code around the argument. 4776*d5c9a868SElliott Hughes\def\docodeindex#1{\edef\indexname{#1}\parsearg\docodeindexxxx} 4777*d5c9a868SElliott Hughes\def\docodeindexxxx #1{\docind{\indexname}{#1}} 4778*d5c9a868SElliott Hughes 4779*d5c9a868SElliott Hughes 4780*d5c9a868SElliott Hughes% Used for the aux, toc and index files to prevent expansion of Texinfo 4781*d5c9a868SElliott Hughes% commands. 4782*d5c9a868SElliott Hughes% 4783*d5c9a868SElliott Hughes\def\atdummies{% 4784*d5c9a868SElliott Hughes \definedummyletter\@% 4785*d5c9a868SElliott Hughes \definedummyletter\ % 4786*d5c9a868SElliott Hughes \definedummyletter\{% 4787*d5c9a868SElliott Hughes \definedummyletter\}% 4788*d5c9a868SElliott Hughes \definedummyletter\&% 4789*d5c9a868SElliott Hughes % 4790*d5c9a868SElliott Hughes % Do the redefinitions. 4791*d5c9a868SElliott Hughes \definedummies 4792*d5c9a868SElliott Hughes \otherbackslash 4793*d5c9a868SElliott Hughes} 4794*d5c9a868SElliott Hughes 4795*d5c9a868SElliott Hughes% \definedummyword defines \#1 as \string\#1\space, thus effectively 4796*d5c9a868SElliott Hughes% preventing its expansion. This is used only for control words, 4797*d5c9a868SElliott Hughes% not control letters, because the \space would be incorrect for 4798*d5c9a868SElliott Hughes% control characters, but is needed to separate the control word 4799*d5c9a868SElliott Hughes% from whatever follows. 4800*d5c9a868SElliott Hughes% 4801*d5c9a868SElliott Hughes% These can be used both for control words that take an argument and 4802*d5c9a868SElliott Hughes% those that do not. If it is followed by {arg} in the input, then 4803*d5c9a868SElliott Hughes% that will dutifully get written to the index (or wherever). 4804*d5c9a868SElliott Hughes% 4805*d5c9a868SElliott Hughes% For control letters, we have \definedummyletter, which omits the 4806*d5c9a868SElliott Hughes% space. 4807*d5c9a868SElliott Hughes% 4808*d5c9a868SElliott Hughes\def\definedummyword #1{\def#1{\string#1\space}}% 4809*d5c9a868SElliott Hughes\def\definedummyletter#1{\def#1{\string#1}}% 4810*d5c9a868SElliott Hughes\let\definedummyaccent\definedummyletter 4811*d5c9a868SElliott Hughes 4812*d5c9a868SElliott Hughes% Called from \atdummies to prevent the expansion of commands. 4813*d5c9a868SElliott Hughes% 4814*d5c9a868SElliott Hughes\def\definedummies{% 4815*d5c9a868SElliott Hughes % 4816*d5c9a868SElliott Hughes \let\commondummyword\definedummyword 4817*d5c9a868SElliott Hughes \let\commondummyletter\definedummyletter 4818*d5c9a868SElliott Hughes \let\commondummyaccent\definedummyaccent 4819*d5c9a868SElliott Hughes \commondummiesnofonts 4820*d5c9a868SElliott Hughes % 4821*d5c9a868SElliott Hughes \definedummyletter\_% 4822*d5c9a868SElliott Hughes \definedummyletter\-% 4823*d5c9a868SElliott Hughes % 4824*d5c9a868SElliott Hughes % Non-English letters. 4825*d5c9a868SElliott Hughes \definedummyword\AA 4826*d5c9a868SElliott Hughes \definedummyword\AE 4827*d5c9a868SElliott Hughes \definedummyword\DH 4828*d5c9a868SElliott Hughes \definedummyword\L 4829*d5c9a868SElliott Hughes \definedummyword\O 4830*d5c9a868SElliott Hughes \definedummyword\OE 4831*d5c9a868SElliott Hughes \definedummyword\TH 4832*d5c9a868SElliott Hughes \definedummyword\aa 4833*d5c9a868SElliott Hughes \definedummyword\ae 4834*d5c9a868SElliott Hughes \definedummyword\dh 4835*d5c9a868SElliott Hughes \definedummyword\exclamdown 4836*d5c9a868SElliott Hughes \definedummyword\l 4837*d5c9a868SElliott Hughes \definedummyword\o 4838*d5c9a868SElliott Hughes \definedummyword\oe 4839*d5c9a868SElliott Hughes \definedummyword\ordf 4840*d5c9a868SElliott Hughes \definedummyword\ordm 4841*d5c9a868SElliott Hughes \definedummyword\questiondown 4842*d5c9a868SElliott Hughes \definedummyword\ss 4843*d5c9a868SElliott Hughes \definedummyword\th 4844*d5c9a868SElliott Hughes % 4845*d5c9a868SElliott Hughes % Although these internal commands shouldn't show up, sometimes they do. 4846*d5c9a868SElliott Hughes \definedummyword\bf 4847*d5c9a868SElliott Hughes \definedummyword\gtr 4848*d5c9a868SElliott Hughes \definedummyword\hat 4849*d5c9a868SElliott Hughes \definedummyword\less 4850*d5c9a868SElliott Hughes \definedummyword\sf 4851*d5c9a868SElliott Hughes \definedummyword\sl 4852*d5c9a868SElliott Hughes \definedummyword\tclose 4853*d5c9a868SElliott Hughes \definedummyword\tt 4854*d5c9a868SElliott Hughes % 4855*d5c9a868SElliott Hughes \definedummyword\LaTeX 4856*d5c9a868SElliott Hughes \definedummyword\TeX 4857*d5c9a868SElliott Hughes % 4858*d5c9a868SElliott Hughes % Assorted special characters. 4859*d5c9a868SElliott Hughes \definedummyword\ampchar 4860*d5c9a868SElliott Hughes \definedummyword\atchar 4861*d5c9a868SElliott Hughes \definedummyword\arrow 4862*d5c9a868SElliott Hughes \definedummyword\backslashchar 4863*d5c9a868SElliott Hughes \definedummyword\bullet 4864*d5c9a868SElliott Hughes \definedummyword\comma 4865*d5c9a868SElliott Hughes \definedummyword\copyright 4866*d5c9a868SElliott Hughes \definedummyword\registeredsymbol 4867*d5c9a868SElliott Hughes \definedummyword\dots 4868*d5c9a868SElliott Hughes \definedummyword\enddots 4869*d5c9a868SElliott Hughes \definedummyword\entrybreak 4870*d5c9a868SElliott Hughes \definedummyword\equiv 4871*d5c9a868SElliott Hughes \definedummyword\error 4872*d5c9a868SElliott Hughes \definedummyword\euro 4873*d5c9a868SElliott Hughes \definedummyword\expansion 4874*d5c9a868SElliott Hughes \definedummyword\geq 4875*d5c9a868SElliott Hughes \definedummyword\guillemetleft 4876*d5c9a868SElliott Hughes \definedummyword\guillemetright 4877*d5c9a868SElliott Hughes \definedummyword\guilsinglleft 4878*d5c9a868SElliott Hughes \definedummyword\guilsinglright 4879*d5c9a868SElliott Hughes \definedummyword\lbracechar 4880*d5c9a868SElliott Hughes \definedummyword\leq 4881*d5c9a868SElliott Hughes \definedummyword\mathopsup 4882*d5c9a868SElliott Hughes \definedummyword\minus 4883*d5c9a868SElliott Hughes \definedummyword\ogonek 4884*d5c9a868SElliott Hughes \definedummyword\pounds 4885*d5c9a868SElliott Hughes \definedummyword\point 4886*d5c9a868SElliott Hughes \definedummyword\print 4887*d5c9a868SElliott Hughes \definedummyword\quotedblbase 4888*d5c9a868SElliott Hughes \definedummyword\quotedblleft 4889*d5c9a868SElliott Hughes \definedummyword\quotedblright 4890*d5c9a868SElliott Hughes \definedummyword\quoteleft 4891*d5c9a868SElliott Hughes \definedummyword\quoteright 4892*d5c9a868SElliott Hughes \definedummyword\quotesinglbase 4893*d5c9a868SElliott Hughes \definedummyword\rbracechar 4894*d5c9a868SElliott Hughes \definedummyword\result 4895*d5c9a868SElliott Hughes \definedummyword\sub 4896*d5c9a868SElliott Hughes \definedummyword\sup 4897*d5c9a868SElliott Hughes \definedummyword\textdegree 4898*d5c9a868SElliott Hughes % 4899*d5c9a868SElliott Hughes \definedummyword\subentry 4900*d5c9a868SElliott Hughes % 4901*d5c9a868SElliott Hughes % We want to disable all macros so that they are not expanded by \write. 4902*d5c9a868SElliott Hughes \macrolist 4903*d5c9a868SElliott Hughes \let\value\dummyvalue 4904*d5c9a868SElliott Hughes % 4905*d5c9a868SElliott Hughes \normalturnoffactive 4906*d5c9a868SElliott Hughes} 4907*d5c9a868SElliott Hughes 4908*d5c9a868SElliott Hughes% \commondummiesnofonts: common to \definedummies and \indexnofonts. 4909*d5c9a868SElliott Hughes% Define \commondummyletter, \commondummyaccent and \commondummyword before 4910*d5c9a868SElliott Hughes% using. Used for accents, font commands, and various control letters. 4911*d5c9a868SElliott Hughes% 4912*d5c9a868SElliott Hughes\def\commondummiesnofonts{% 4913*d5c9a868SElliott Hughes % Control letters and accents. 4914*d5c9a868SElliott Hughes \commondummyletter\!% 4915*d5c9a868SElliott Hughes \commondummyaccent\"% 4916*d5c9a868SElliott Hughes \commondummyaccent\'% 4917*d5c9a868SElliott Hughes \commondummyletter\*% 4918*d5c9a868SElliott Hughes \commondummyaccent\,% 4919*d5c9a868SElliott Hughes \commondummyletter\.% 4920*d5c9a868SElliott Hughes \commondummyletter\/% 4921*d5c9a868SElliott Hughes \commondummyletter\:% 4922*d5c9a868SElliott Hughes \commondummyaccent\=% 4923*d5c9a868SElliott Hughes \commondummyletter\?% 4924*d5c9a868SElliott Hughes \commondummyaccent\^% 4925*d5c9a868SElliott Hughes \commondummyaccent\`% 4926*d5c9a868SElliott Hughes \commondummyaccent\~% 4927*d5c9a868SElliott Hughes \commondummyword\u 4928*d5c9a868SElliott Hughes \commondummyword\v 4929*d5c9a868SElliott Hughes \commondummyword\H 4930*d5c9a868SElliott Hughes \commondummyword\dotaccent 4931*d5c9a868SElliott Hughes \commondummyword\ogonek 4932*d5c9a868SElliott Hughes \commondummyword\ringaccent 4933*d5c9a868SElliott Hughes \commondummyword\tieaccent 4934*d5c9a868SElliott Hughes \commondummyword\ubaraccent 4935*d5c9a868SElliott Hughes \commondummyword\udotaccent 4936*d5c9a868SElliott Hughes \commondummyword\dotless 4937*d5c9a868SElliott Hughes % 4938*d5c9a868SElliott Hughes % Texinfo font commands. 4939*d5c9a868SElliott Hughes \commondummyword\b 4940*d5c9a868SElliott Hughes \commondummyword\i 4941*d5c9a868SElliott Hughes \commondummyword\r 4942*d5c9a868SElliott Hughes \commondummyword\sansserif 4943*d5c9a868SElliott Hughes \commondummyword\sc 4944*d5c9a868SElliott Hughes \commondummyword\slanted 4945*d5c9a868SElliott Hughes \commondummyword\t 4946*d5c9a868SElliott Hughes % 4947*d5c9a868SElliott Hughes % Commands that take arguments. 4948*d5c9a868SElliott Hughes \commondummyword\abbr 4949*d5c9a868SElliott Hughes \commondummyword\acronym 4950*d5c9a868SElliott Hughes \commondummyword\anchor 4951*d5c9a868SElliott Hughes \commondummyword\cite 4952*d5c9a868SElliott Hughes \commondummyword\code 4953*d5c9a868SElliott Hughes \commondummyword\command 4954*d5c9a868SElliott Hughes \commondummyword\dfn 4955*d5c9a868SElliott Hughes \commondummyword\dmn 4956*d5c9a868SElliott Hughes \commondummyword\email 4957*d5c9a868SElliott Hughes \commondummyword\emph 4958*d5c9a868SElliott Hughes \commondummyword\env 4959*d5c9a868SElliott Hughes \commondummyword\file 4960*d5c9a868SElliott Hughes \commondummyword\image 4961*d5c9a868SElliott Hughes \commondummyword\indicateurl 4962*d5c9a868SElliott Hughes \commondummyword\inforef 4963*d5c9a868SElliott Hughes \commondummyword\kbd 4964*d5c9a868SElliott Hughes \commondummyword\key 4965*d5c9a868SElliott Hughes \commondummyword\math 4966*d5c9a868SElliott Hughes \commondummyword\option 4967*d5c9a868SElliott Hughes \commondummyword\pxref 4968*d5c9a868SElliott Hughes \commondummyword\ref 4969*d5c9a868SElliott Hughes \commondummyword\samp 4970*d5c9a868SElliott Hughes \commondummyword\strong 4971*d5c9a868SElliott Hughes \commondummyword\tie 4972*d5c9a868SElliott Hughes \commondummyword\U 4973*d5c9a868SElliott Hughes \commondummyword\uref 4974*d5c9a868SElliott Hughes \commondummyword\url 4975*d5c9a868SElliott Hughes \commondummyword\var 4976*d5c9a868SElliott Hughes \commondummyword\verb 4977*d5c9a868SElliott Hughes \commondummyword\w 4978*d5c9a868SElliott Hughes \commondummyword\xref 4979*d5c9a868SElliott Hughes} 4980*d5c9a868SElliott Hughes 4981*d5c9a868SElliott Hughes\let\indexlbrace\relax 4982*d5c9a868SElliott Hughes\let\indexrbrace\relax 4983*d5c9a868SElliott Hughes\let\indexatchar\relax 4984*d5c9a868SElliott Hughes\let\indexbackslash\relax 4985*d5c9a868SElliott Hughes 4986*d5c9a868SElliott Hughes{\catcode`\@=0 4987*d5c9a868SElliott Hughes\catcode`\\=13 4988*d5c9a868SElliott Hughes @gdef@backslashdisappear{@def\{}} 4989*d5c9a868SElliott Hughes} 4990*d5c9a868SElliott Hughes 4991*d5c9a868SElliott Hughes{ 4992*d5c9a868SElliott Hughes\catcode`\<=13 4993*d5c9a868SElliott Hughes\catcode`\-=13 4994*d5c9a868SElliott Hughes\catcode`\`=13 4995*d5c9a868SElliott Hughes \gdef\indexnonalnumdisappear{% 4996*d5c9a868SElliott Hughes \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax\else 4997*d5c9a868SElliott Hughes % @set txiindexlquoteignore makes us ignore left quotes in the sort term. 4998*d5c9a868SElliott Hughes % (Introduced for FSFS 2nd ed.) 4999*d5c9a868SElliott Hughes \let`=\empty 5000*d5c9a868SElliott Hughes \fi 5001*d5c9a868SElliott Hughes % 5002*d5c9a868SElliott Hughes \expandafter\ifx\csname SETtxiindexbackslashignore\endcsname\relax\else 5003*d5c9a868SElliott Hughes \backslashdisappear 5004*d5c9a868SElliott Hughes \fi 5005*d5c9a868SElliott Hughes % 5006*d5c9a868SElliott Hughes \expandafter\ifx\csname SETtxiindexhyphenignore\endcsname\relax\else 5007*d5c9a868SElliott Hughes \def-{}% 5008*d5c9a868SElliott Hughes \fi 5009*d5c9a868SElliott Hughes \expandafter\ifx\csname SETtxiindexlessthanignore\endcsname\relax\else 5010*d5c9a868SElliott Hughes \def<{}% 5011*d5c9a868SElliott Hughes \fi 5012*d5c9a868SElliott Hughes \expandafter\ifx\csname SETtxiindexatsignignore\endcsname\relax\else 5013*d5c9a868SElliott Hughes \def\@{}% 5014*d5c9a868SElliott Hughes \fi 5015*d5c9a868SElliott Hughes } 5016*d5c9a868SElliott Hughes 5017*d5c9a868SElliott Hughes \gdef\indexnonalnumreappear{% 5018*d5c9a868SElliott Hughes \let-\normaldash 5019*d5c9a868SElliott Hughes \let<\normalless 5020*d5c9a868SElliott Hughes } 5021*d5c9a868SElliott Hughes} 5022*d5c9a868SElliott Hughes 5023*d5c9a868SElliott Hughes 5024*d5c9a868SElliott Hughes% \indexnofonts is used when outputting the strings to sort the index 5025*d5c9a868SElliott Hughes% by, and when constructing control sequence names. It eliminates all 5026*d5c9a868SElliott Hughes% control sequences and just writes whatever the best ASCII sort string 5027*d5c9a868SElliott Hughes% would be for a given command (usually its argument). 5028*d5c9a868SElliott Hughes% 5029*d5c9a868SElliott Hughes\def\indexnofonts{% 5030*d5c9a868SElliott Hughes % Accent commands should become @asis. 5031*d5c9a868SElliott Hughes \def\commondummyaccent##1{\let##1\asis}% 5032*d5c9a868SElliott Hughes % We can just ignore other control letters. 5033*d5c9a868SElliott Hughes \def\commondummyletter##1{\let##1\empty}% 5034*d5c9a868SElliott Hughes % All control words become @asis by default; overrides below. 5035*d5c9a868SElliott Hughes \let\commondummyword\commondummyaccent 5036*d5c9a868SElliott Hughes \commondummiesnofonts 5037*d5c9a868SElliott Hughes % 5038*d5c9a868SElliott Hughes % Don't no-op \tt, since it isn't a user-level command 5039*d5c9a868SElliott Hughes % and is used in the definitions of the active chars like <, >, |, etc. 5040*d5c9a868SElliott Hughes % Likewise with the other plain tex font commands. 5041*d5c9a868SElliott Hughes %\let\tt=\asis 5042*d5c9a868SElliott Hughes % 5043*d5c9a868SElliott Hughes \def\ { }% 5044*d5c9a868SElliott Hughes \def\@{@}% 5045*d5c9a868SElliott Hughes \def\_{\normalunderscore}% 5046*d5c9a868SElliott Hughes \def\-{}% @- shouldn't affect sorting 5047*d5c9a868SElliott Hughes % 5048*d5c9a868SElliott Hughes \uccode`\1=`\{ \uppercase{\def\{{1}}% 5049*d5c9a868SElliott Hughes \uccode`\1=`\} \uppercase{\def\}{1}}% 5050*d5c9a868SElliott Hughes \let\lbracechar\{% 5051*d5c9a868SElliott Hughes \let\rbracechar\}% 5052*d5c9a868SElliott Hughes % 5053*d5c9a868SElliott Hughes % Non-English letters. 5054*d5c9a868SElliott Hughes \def\AA{AA}% 5055*d5c9a868SElliott Hughes \def\AE{AE}% 5056*d5c9a868SElliott Hughes \def\DH{DZZ}% 5057*d5c9a868SElliott Hughes \def\L{L}% 5058*d5c9a868SElliott Hughes \def\OE{OE}% 5059*d5c9a868SElliott Hughes \def\O{O}% 5060*d5c9a868SElliott Hughes \def\TH{TH}% 5061*d5c9a868SElliott Hughes \def\aa{aa}% 5062*d5c9a868SElliott Hughes \def\ae{ae}% 5063*d5c9a868SElliott Hughes \def\dh{dzz}% 5064*d5c9a868SElliott Hughes \def\exclamdown{!}% 5065*d5c9a868SElliott Hughes \def\l{l}% 5066*d5c9a868SElliott Hughes \def\oe{oe}% 5067*d5c9a868SElliott Hughes \def\ordf{a}% 5068*d5c9a868SElliott Hughes \def\ordm{o}% 5069*d5c9a868SElliott Hughes \def\o{o}% 5070*d5c9a868SElliott Hughes \def\questiondown{?}% 5071*d5c9a868SElliott Hughes \def\ss{ss}% 5072*d5c9a868SElliott Hughes \def\th{th}% 5073*d5c9a868SElliott Hughes % 5074*d5c9a868SElliott Hughes \let\do\indexnofontsdef 5075*d5c9a868SElliott Hughes % 5076*d5c9a868SElliott Hughes \do\LaTeX{LaTeX}% 5077*d5c9a868SElliott Hughes \do\TeX{TeX}% 5078*d5c9a868SElliott Hughes % 5079*d5c9a868SElliott Hughes % Assorted special characters. 5080*d5c9a868SElliott Hughes \do\atchar{@}% 5081*d5c9a868SElliott Hughes \do\arrow{->}% 5082*d5c9a868SElliott Hughes \do\bullet{bullet}% 5083*d5c9a868SElliott Hughes \do\comma{,}% 5084*d5c9a868SElliott Hughes \do\copyright{copyright}% 5085*d5c9a868SElliott Hughes \do\dots{...}% 5086*d5c9a868SElliott Hughes \do\enddots{...}% 5087*d5c9a868SElliott Hughes \do\equiv{==}% 5088*d5c9a868SElliott Hughes \do\error{error}% 5089*d5c9a868SElliott Hughes \do\euro{euro}% 5090*d5c9a868SElliott Hughes \do\expansion{==>}% 5091*d5c9a868SElliott Hughes \do\geq{>=}% 5092*d5c9a868SElliott Hughes \do\guillemetleft{<<}% 5093*d5c9a868SElliott Hughes \do\guillemetright{>>}% 5094*d5c9a868SElliott Hughes \do\guilsinglleft{<}% 5095*d5c9a868SElliott Hughes \do\guilsinglright{>}% 5096*d5c9a868SElliott Hughes \do\leq{<=}% 5097*d5c9a868SElliott Hughes \do\lbracechar{\{}% 5098*d5c9a868SElliott Hughes \do\minus{-}% 5099*d5c9a868SElliott Hughes \do\point{.}% 5100*d5c9a868SElliott Hughes \do\pounds{pounds}% 5101*d5c9a868SElliott Hughes \do\print{-|}% 5102*d5c9a868SElliott Hughes \do\quotedblbase{"}% 5103*d5c9a868SElliott Hughes \do\quotedblleft{"}% 5104*d5c9a868SElliott Hughes \do\quotedblright{"}% 5105*d5c9a868SElliott Hughes \do\quoteleft{`}% 5106*d5c9a868SElliott Hughes \do\quoteright{'}% 5107*d5c9a868SElliott Hughes \do\quotesinglbase{,}% 5108*d5c9a868SElliott Hughes \do\rbracechar{\}}% 5109*d5c9a868SElliott Hughes \do\registeredsymbol{R}% 5110*d5c9a868SElliott Hughes \do\result{=>}% 5111*d5c9a868SElliott Hughes \do\textdegree{o}% 5112*d5c9a868SElliott Hughes % 5113*d5c9a868SElliott Hughes % We need to get rid of all macros, leaving only the arguments (if present). 5114*d5c9a868SElliott Hughes % Of course this is not nearly correct, but it is the best we can do for now. 5115*d5c9a868SElliott Hughes % makeinfo does not expand macros in the argument to @deffn, which ends up 5116*d5c9a868SElliott Hughes % writing an index entry, and texindex isn't prepared for an index sort entry 5117*d5c9a868SElliott Hughes % that starts with \. 5118*d5c9a868SElliott Hughes % 5119*d5c9a868SElliott Hughes % Since macro invocations are followed by braces, we can just redefine them 5120*d5c9a868SElliott Hughes % to take a single TeX argument. The case of a macro invocation that 5121*d5c9a868SElliott Hughes % goes to end-of-line is not handled. 5122*d5c9a868SElliott Hughes % 5123*d5c9a868SElliott Hughes \macrolist 5124*d5c9a868SElliott Hughes \let\value\indexnofontsvalue 5125*d5c9a868SElliott Hughes} 5126*d5c9a868SElliott Hughes 5127*d5c9a868SElliott Hughes% Give the control sequence a definition that removes the {} that follows 5128*d5c9a868SElliott Hughes% its use, e.g. @AA{} -> AA 5129*d5c9a868SElliott Hughes\def\indexnofontsdef#1#2{\def#1##1{#2}}% 5130*d5c9a868SElliott Hughes 5131*d5c9a868SElliott Hughes 5132*d5c9a868SElliott Hughes 5133*d5c9a868SElliott Hughes 5134*d5c9a868SElliott Hughes% #1 is the index name, #2 is the entry text. 5135*d5c9a868SElliott Hughes\def\doind#1#2{% 5136*d5c9a868SElliott Hughes \iflinks 5137*d5c9a868SElliott Hughes {% 5138*d5c9a868SElliott Hughes % 5139*d5c9a868SElliott Hughes \requireopenindexfile{#1}% 5140*d5c9a868SElliott Hughes \edef\writeto{\csname#1indfile\endcsname}% 5141*d5c9a868SElliott Hughes % 5142*d5c9a868SElliott Hughes \def\indextext{#2}% 5143*d5c9a868SElliott Hughes \safewhatsit\doindwrite 5144*d5c9a868SElliott Hughes }% 5145*d5c9a868SElliott Hughes \fi 5146*d5c9a868SElliott Hughes} 5147*d5c9a868SElliott Hughes 5148*d5c9a868SElliott Hughes% Same as \doind, but for code indices 5149*d5c9a868SElliott Hughes\def\docind#1#2{% 5150*d5c9a868SElliott Hughes \iflinks 5151*d5c9a868SElliott Hughes {% 5152*d5c9a868SElliott Hughes % 5153*d5c9a868SElliott Hughes \requireopenindexfile{#1}% 5154*d5c9a868SElliott Hughes \edef\writeto{\csname#1indfile\endcsname}% 5155*d5c9a868SElliott Hughes % 5156*d5c9a868SElliott Hughes \def\indextext{#2}% 5157*d5c9a868SElliott Hughes \safewhatsit\docindwrite 5158*d5c9a868SElliott Hughes }% 5159*d5c9a868SElliott Hughes \fi 5160*d5c9a868SElliott Hughes} 5161*d5c9a868SElliott Hughes 5162*d5c9a868SElliott Hughes% Check if an index file has been opened, and if not, open it. 5163*d5c9a868SElliott Hughes\def\requireopenindexfile#1{% 5164*d5c9a868SElliott Hughes\ifnum\csname #1indfile\endcsname=0 5165*d5c9a868SElliott Hughes \expandafter\newwrite \csname#1indfile\endcsname 5166*d5c9a868SElliott Hughes \edef\suffix{#1}% 5167*d5c9a868SElliott Hughes % A .fls suffix would conflict with the file extension for the output 5168*d5c9a868SElliott Hughes % of -recorder, so use .f1s instead. 5169*d5c9a868SElliott Hughes \ifx\suffix\indexisfl\def\suffix{f1}\fi 5170*d5c9a868SElliott Hughes % Open the file 5171*d5c9a868SElliott Hughes \immediate\openout\csname#1indfile\endcsname \jobname.\suffix 5172*d5c9a868SElliott Hughes % Using \immediate above here prevents an object entering into the current 5173*d5c9a868SElliott Hughes % box, which could confound checks such as those in \safewhatsit for 5174*d5c9a868SElliott Hughes % preceding skips. 5175*d5c9a868SElliott Hughes \typeout{Writing index file \jobname.\suffix}% 5176*d5c9a868SElliott Hughes\fi} 5177*d5c9a868SElliott Hughes\def\indexisfl{fl} 5178*d5c9a868SElliott Hughes 5179*d5c9a868SElliott Hughes% Definition for writing index entry sort key. 5180*d5c9a868SElliott Hughes{ 5181*d5c9a868SElliott Hughes\catcode`\-=13 5182*d5c9a868SElliott Hughes\gdef\indexwritesortas{% 5183*d5c9a868SElliott Hughes \begingroup 5184*d5c9a868SElliott Hughes \indexnonalnumreappear 5185*d5c9a868SElliott Hughes \indexwritesortasxxx} 5186*d5c9a868SElliott Hughes\gdef\indexwritesortasxxx#1{% 5187*d5c9a868SElliott Hughes \xdef\indexsortkey{#1}\endgroup} 5188*d5c9a868SElliott Hughes} 5189*d5c9a868SElliott Hughes 5190*d5c9a868SElliott Hughes\def\indexwriteseealso#1{ 5191*d5c9a868SElliott Hughes \gdef\pagenumbertext{\string\seealso{#1}}% 5192*d5c9a868SElliott Hughes} 5193*d5c9a868SElliott Hughes\def\indexwriteseeentry#1{ 5194*d5c9a868SElliott Hughes \gdef\pagenumbertext{\string\seeentry{#1}}% 5195*d5c9a868SElliott Hughes} 5196*d5c9a868SElliott Hughes 5197*d5c9a868SElliott Hughes% The default definitions 5198*d5c9a868SElliott Hughes\def\sortas#1{}% 5199*d5c9a868SElliott Hughes\def\seealso#1{\i{\putwordSeeAlso}\ #1}% for sorted index file only 5200*d5c9a868SElliott Hughes\def\putwordSeeAlso{See also} 5201*d5c9a868SElliott Hughes\def\seeentry#1{\i{\putwordSee}\ #1}% for sorted index file only 5202*d5c9a868SElliott Hughes 5203*d5c9a868SElliott Hughes 5204*d5c9a868SElliott Hughes% Given index entry text like "aaa @subentry bbb @sortas{ZZZ}": 5205*d5c9a868SElliott Hughes% * Set \bracedtext to "{aaa}{bbb}" 5206*d5c9a868SElliott Hughes% * Set \fullindexsortkey to "aaa @subentry ZZZ" 5207*d5c9a868SElliott Hughes% * If @seealso occurs, set \pagenumbertext 5208*d5c9a868SElliott Hughes% 5209*d5c9a868SElliott Hughes\def\splitindexentry#1{% 5210*d5c9a868SElliott Hughes \gdef\fullindexsortkey{}% 5211*d5c9a868SElliott Hughes \xdef\bracedtext{}% 5212*d5c9a868SElliott Hughes \def\sep{}% 5213*d5c9a868SElliott Hughes \def\seealso##1{}% 5214*d5c9a868SElliott Hughes \def\seeentry##1{}% 5215*d5c9a868SElliott Hughes \expandafter\doindexsegment#1\subentry\finish\subentry 5216*d5c9a868SElliott Hughes} 5217*d5c9a868SElliott Hughes 5218*d5c9a868SElliott Hughes% append the results from the next segment 5219*d5c9a868SElliott Hughes\def\doindexsegment#1\subentry{% 5220*d5c9a868SElliott Hughes \def\segment{#1}% 5221*d5c9a868SElliott Hughes \ifx\segment\isfinish 5222*d5c9a868SElliott Hughes \else 5223*d5c9a868SElliott Hughes % 5224*d5c9a868SElliott Hughes % Fully expand the segment, throwing away any @sortas directives, and 5225*d5c9a868SElliott Hughes % trim spaces. 5226*d5c9a868SElliott Hughes \edef\trimmed{\segment}% 5227*d5c9a868SElliott Hughes \edef\trimmed{\expandafter\eatspaces\expandafter{\trimmed}}% 5228*d5c9a868SElliott Hughes \ifincodeindex 5229*d5c9a868SElliott Hughes \edef\trimmed{\noexpand\code{\trimmed}}% 5230*d5c9a868SElliott Hughes \fi 5231*d5c9a868SElliott Hughes % 5232*d5c9a868SElliott Hughes \xdef\bracedtext{\bracedtext{\trimmed}}% 5233*d5c9a868SElliott Hughes % 5234*d5c9a868SElliott Hughes % Get the string to sort by. Process the segment with all 5235*d5c9a868SElliott Hughes % font commands turned off. 5236*d5c9a868SElliott Hughes \bgroup 5237*d5c9a868SElliott Hughes \let\sortas\indexwritesortas 5238*d5c9a868SElliott Hughes \let\seealso\indexwriteseealso 5239*d5c9a868SElliott Hughes \let\seeentry\indexwriteseeentry 5240*d5c9a868SElliott Hughes \indexnofonts 5241*d5c9a868SElliott Hughes % The braces around the commands are recognized by texindex. 5242*d5c9a868SElliott Hughes \def\lbracechar{{\string\indexlbrace}}% 5243*d5c9a868SElliott Hughes \def\rbracechar{{\string\indexrbrace}}% 5244*d5c9a868SElliott Hughes \let\{=\lbracechar 5245*d5c9a868SElliott Hughes \let\}=\rbracechar 5246*d5c9a868SElliott Hughes \def\@{{\string\indexatchar}}% 5247*d5c9a868SElliott Hughes \def\atchar##1{\@}% 5248*d5c9a868SElliott Hughes \def\backslashchar{{\string\indexbackslash}}% 5249*d5c9a868SElliott Hughes \uccode`\~=`\\ \uppercase{\let~\backslashchar}% 5250*d5c9a868SElliott Hughes % 5251*d5c9a868SElliott Hughes \let\indexsortkey\empty 5252*d5c9a868SElliott Hughes \global\let\pagenumbertext\empty 5253*d5c9a868SElliott Hughes % Execute the segment and throw away the typeset output. This executes 5254*d5c9a868SElliott Hughes % any @sortas or @seealso commands in this segment. 5255*d5c9a868SElliott Hughes \setbox\dummybox = \hbox{\segment}% 5256*d5c9a868SElliott Hughes \ifx\indexsortkey\empty{% 5257*d5c9a868SElliott Hughes \indexnonalnumdisappear 5258*d5c9a868SElliott Hughes \xdef\trimmed{\segment}% 5259*d5c9a868SElliott Hughes \xdef\trimmed{\expandafter\eatspaces\expandafter{\trimmed}}% 5260*d5c9a868SElliott Hughes \xdef\indexsortkey{\trimmed}% 5261*d5c9a868SElliott Hughes \ifx\indexsortkey\empty\xdef\indexsortkey{ }\fi 5262*d5c9a868SElliott Hughes }\fi 5263*d5c9a868SElliott Hughes % 5264*d5c9a868SElliott Hughes % Append to \fullindexsortkey. 5265*d5c9a868SElliott Hughes \edef\tmp{\gdef\noexpand\fullindexsortkey{% 5266*d5c9a868SElliott Hughes \fullindexsortkey\sep\indexsortkey}}% 5267*d5c9a868SElliott Hughes \tmp 5268*d5c9a868SElliott Hughes \egroup 5269*d5c9a868SElliott Hughes \def\sep{\subentry}% 5270*d5c9a868SElliott Hughes % 5271*d5c9a868SElliott Hughes \expandafter\doindexsegment 5272*d5c9a868SElliott Hughes \fi 5273*d5c9a868SElliott Hughes} 5274*d5c9a868SElliott Hughes\def\isfinish{\finish}% 5275*d5c9a868SElliott Hughes\newbox\dummybox % used above 5276*d5c9a868SElliott Hughes 5277*d5c9a868SElliott Hughes\let\subentry\relax 5278*d5c9a868SElliott Hughes 5279*d5c9a868SElliott Hughes% Use \ instead of @ in index files. To support old texi2dvi and texindex. 5280*d5c9a868SElliott Hughes% This works without changing the escape character used in the toc or aux 5281*d5c9a868SElliott Hughes% files because the index entries are fully expanded here, and \string uses 5282*d5c9a868SElliott Hughes% the current value of \escapechar. 5283*d5c9a868SElliott Hughes\def\escapeisbackslash{\escapechar=`\\} 5284*d5c9a868SElliott Hughes 5285*d5c9a868SElliott Hughes% Use \ in index files by default. texi2dvi didn't support @ as the escape 5286*d5c9a868SElliott Hughes% character (as it checked for "\entry" in the files, and not "@entry"). When 5287*d5c9a868SElliott Hughes% the new version of texi2dvi has had a chance to become more prevalent, then 5288*d5c9a868SElliott Hughes% the escape character can change back to @ again. This should be an easy 5289*d5c9a868SElliott Hughes% change to make now because both @ and \ are only used as escape characters in 5290*d5c9a868SElliott Hughes% index files, never standing for themselves. 5291*d5c9a868SElliott Hughes% 5292*d5c9a868SElliott Hughes\set txiindexescapeisbackslash 5293*d5c9a868SElliott Hughes 5294*d5c9a868SElliott Hughes% Write the entry in \indextext to the index file. 5295*d5c9a868SElliott Hughes% 5296*d5c9a868SElliott Hughes 5297*d5c9a868SElliott Hughes\newif\ifincodeindex 5298*d5c9a868SElliott Hughes\def\doindwrite{\incodeindexfalse\doindwritex} 5299*d5c9a868SElliott Hughes\def\docindwrite{\incodeindextrue\doindwritex} 5300*d5c9a868SElliott Hughes 5301*d5c9a868SElliott Hughes\def\doindwritex{% 5302*d5c9a868SElliott Hughes \maybemarginindex 5303*d5c9a868SElliott Hughes % 5304*d5c9a868SElliott Hughes \atdummies 5305*d5c9a868SElliott Hughes % 5306*d5c9a868SElliott Hughes \expandafter\ifx\csname SETtxiindexescapeisbackslash\endcsname\relax\else 5307*d5c9a868SElliott Hughes \escapeisbackslash 5308*d5c9a868SElliott Hughes \fi 5309*d5c9a868SElliott Hughes % 5310*d5c9a868SElliott Hughes % For texindex which always views { and } as separators. 5311*d5c9a868SElliott Hughes \def\{{\lbracechar{}}% 5312*d5c9a868SElliott Hughes \def\}{\rbracechar{}}% 5313*d5c9a868SElliott Hughes \uccode`\~=`\\ \uppercase{\def~{\backslashchar{}}}% 5314*d5c9a868SElliott Hughes % 5315*d5c9a868SElliott Hughes % Split the entry into primary entry and any subentries, and get the index 5316*d5c9a868SElliott Hughes % sort key. 5317*d5c9a868SElliott Hughes \splitindexentry\indextext 5318*d5c9a868SElliott Hughes % 5319*d5c9a868SElliott Hughes % Set up the complete index entry, with both the sort key and 5320*d5c9a868SElliott Hughes % the original text, including any font commands. We write 5321*d5c9a868SElliott Hughes % three arguments to \entry to the .?? file (four in the 5322*d5c9a868SElliott Hughes % subentry case), texindex reduces to two when writing the .??s 5323*d5c9a868SElliott Hughes % sorted result. 5324*d5c9a868SElliott Hughes % 5325*d5c9a868SElliott Hughes \edef\temp{% 5326*d5c9a868SElliott Hughes \write\writeto{% 5327*d5c9a868SElliott Hughes \string\entry{\fullindexsortkey}% 5328*d5c9a868SElliott Hughes {\ifx\pagenumbertext\empty\noexpand\folio\else\pagenumbertext\fi}% 5329*d5c9a868SElliott Hughes \bracedtext}% 5330*d5c9a868SElliott Hughes }% 5331*d5c9a868SElliott Hughes \temp 5332*d5c9a868SElliott Hughes} 5333*d5c9a868SElliott Hughes 5334*d5c9a868SElliott Hughes% Put the index entry in the margin if desired (undocumented). 5335*d5c9a868SElliott Hughes\def\maybemarginindex{% 5336*d5c9a868SElliott Hughes \ifx\SETmarginindex\relax\else 5337*d5c9a868SElliott Hughes \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \relax\indextext}}% 5338*d5c9a868SElliott Hughes \fi 5339*d5c9a868SElliott Hughes} 5340*d5c9a868SElliott Hughes\let\SETmarginindex=\relax 5341*d5c9a868SElliott Hughes 5342*d5c9a868SElliott Hughes 5343*d5c9a868SElliott Hughes% Take care of unwanted page breaks/skips around a whatsit: 5344*d5c9a868SElliott Hughes% 5345*d5c9a868SElliott Hughes% If a skip is the last thing on the list now, preserve it 5346*d5c9a868SElliott Hughes% by backing up by \lastskip, doing the \write, then inserting 5347*d5c9a868SElliott Hughes% the skip again. Otherwise, the whatsit generated by the 5348*d5c9a868SElliott Hughes% \write or \pdfdest will make \lastskip zero. The result is that 5349*d5c9a868SElliott Hughes% sequences like this: 5350*d5c9a868SElliott Hughes% @end defun 5351*d5c9a868SElliott Hughes% @tindex whatever 5352*d5c9a868SElliott Hughes% @defun ... 5353*d5c9a868SElliott Hughes% will have extra space inserted, because the \medbreak in the 5354*d5c9a868SElliott Hughes% start of the @defun won't see the skip inserted by the @end of 5355*d5c9a868SElliott Hughes% the previous defun. 5356*d5c9a868SElliott Hughes% 5357*d5c9a868SElliott Hughes% But don't do any of this if we're not in vertical mode. We 5358*d5c9a868SElliott Hughes% don't want to do a \vskip and prematurely end a paragraph. 5359*d5c9a868SElliott Hughes% 5360*d5c9a868SElliott Hughes% Avoid page breaks due to these extra skips, too. 5361*d5c9a868SElliott Hughes% 5362*d5c9a868SElliott Hughes% But wait, there is a catch there: 5363*d5c9a868SElliott Hughes% We'll have to check whether \lastskip is zero skip. \ifdim is not 5364*d5c9a868SElliott Hughes% sufficient for this purpose, as it ignores stretch and shrink parts 5365*d5c9a868SElliott Hughes% of the skip. The only way seems to be to check the textual 5366*d5c9a868SElliott Hughes% representation of the skip. 5367*d5c9a868SElliott Hughes% 5368*d5c9a868SElliott Hughes% The following is almost like \def\zeroskipmacro{0.0pt} except that 5369*d5c9a868SElliott Hughes% the ``p'' and ``t'' characters have catcode \other, not 11 (letter). 5370*d5c9a868SElliott Hughes% 5371*d5c9a868SElliott Hughes\edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname} 5372*d5c9a868SElliott Hughes% 5373*d5c9a868SElliott Hughes\newskip\whatsitskip 5374*d5c9a868SElliott Hughes\newcount\whatsitpenalty 5375*d5c9a868SElliott Hughes% 5376*d5c9a868SElliott Hughes% ..., ready, GO: 5377*d5c9a868SElliott Hughes% 5378*d5c9a868SElliott Hughes\def\safewhatsit#1{\ifhmode 5379*d5c9a868SElliott Hughes #1% 5380*d5c9a868SElliott Hughes \else 5381*d5c9a868SElliott Hughes % \lastskip and \lastpenalty cannot both be nonzero simultaneously. 5382*d5c9a868SElliott Hughes \whatsitskip = \lastskip 5383*d5c9a868SElliott Hughes \edef\lastskipmacro{\the\lastskip}% 5384*d5c9a868SElliott Hughes \whatsitpenalty = \lastpenalty 5385*d5c9a868SElliott Hughes % 5386*d5c9a868SElliott Hughes % If \lastskip is nonzero, that means the last item was a 5387*d5c9a868SElliott Hughes % skip. And since a skip is discardable, that means this 5388*d5c9a868SElliott Hughes % -\whatsitskip glue we're inserting is preceded by a 5389*d5c9a868SElliott Hughes % non-discardable item, therefore it is not a potential 5390*d5c9a868SElliott Hughes % breakpoint, therefore no \nobreak needed. 5391*d5c9a868SElliott Hughes \ifx\lastskipmacro\zeroskipmacro 5392*d5c9a868SElliott Hughes \else 5393*d5c9a868SElliott Hughes \vskip-\whatsitskip 5394*d5c9a868SElliott Hughes \fi 5395*d5c9a868SElliott Hughes % 5396*d5c9a868SElliott Hughes #1% 5397*d5c9a868SElliott Hughes % 5398*d5c9a868SElliott Hughes \ifx\lastskipmacro\zeroskipmacro 5399*d5c9a868SElliott Hughes % If \lastskip was zero, perhaps the last item was a penalty, and 5400*d5c9a868SElliott Hughes % perhaps it was >=10000, e.g., a \nobreak. In that case, we want 5401*d5c9a868SElliott Hughes % to re-insert the same penalty (values >10000 are used for various 5402*d5c9a868SElliott Hughes % signals); since we just inserted a non-discardable item, any 5403*d5c9a868SElliott Hughes % following glue (such as a \parskip) would be a breakpoint. For example: 5404*d5c9a868SElliott Hughes % @deffn deffn-whatever 5405*d5c9a868SElliott Hughes % @vindex index-whatever 5406*d5c9a868SElliott Hughes % Description. 5407*d5c9a868SElliott Hughes % would allow a break between the index-whatever whatsit 5408*d5c9a868SElliott Hughes % and the "Description." paragraph. 5409*d5c9a868SElliott Hughes \ifnum\whatsitpenalty>9999 \penalty\whatsitpenalty \fi 5410*d5c9a868SElliott Hughes \else 5411*d5c9a868SElliott Hughes % On the other hand, if we had a nonzero \lastskip, 5412*d5c9a868SElliott Hughes % this make-up glue would be preceded by a non-discardable item 5413*d5c9a868SElliott Hughes % (the whatsit from the \write), so we must insert a \nobreak. 5414*d5c9a868SElliott Hughes \nobreak\vskip\whatsitskip 5415*d5c9a868SElliott Hughes \fi 5416*d5c9a868SElliott Hughes\fi} 5417*d5c9a868SElliott Hughes 5418*d5c9a868SElliott Hughes% The index entry written in the file actually looks like 5419*d5c9a868SElliott Hughes% \entry {sortstring}{page}{topic} 5420*d5c9a868SElliott Hughes% or 5421*d5c9a868SElliott Hughes% \entry {sortstring}{page}{topic}{subtopic} 5422*d5c9a868SElliott Hughes% The texindex program reads in these files and writes files 5423*d5c9a868SElliott Hughes% containing these kinds of lines: 5424*d5c9a868SElliott Hughes% \initial {c} 5425*d5c9a868SElliott Hughes% before the first topic whose initial is c 5426*d5c9a868SElliott Hughes% \entry {topic}{pagelist} 5427*d5c9a868SElliott Hughes% for a topic that is used without subtopics 5428*d5c9a868SElliott Hughes% \primary {topic} 5429*d5c9a868SElliott Hughes% \entry {topic}{} 5430*d5c9a868SElliott Hughes% for the beginning of a topic that is used with subtopics 5431*d5c9a868SElliott Hughes% \secondary {subtopic}{pagelist} 5432*d5c9a868SElliott Hughes% for each subtopic. 5433*d5c9a868SElliott Hughes% \secondary {subtopic}{} 5434*d5c9a868SElliott Hughes% for a subtopic with sub-subtopics 5435*d5c9a868SElliott Hughes% \tertiary {subtopic}{subsubtopic}{pagelist} 5436*d5c9a868SElliott Hughes% for each sub-subtopic. 5437*d5c9a868SElliott Hughes 5438*d5c9a868SElliott Hughes% Define the user-accessible indexing commands 5439*d5c9a868SElliott Hughes% @findex, @vindex, @kindex, @cindex. 5440*d5c9a868SElliott Hughes 5441*d5c9a868SElliott Hughes\def\findex {\fnindex} 5442*d5c9a868SElliott Hughes\def\kindex {\kyindex} 5443*d5c9a868SElliott Hughes\def\cindex {\cpindex} 5444*d5c9a868SElliott Hughes\def\vindex {\vrindex} 5445*d5c9a868SElliott Hughes\def\tindex {\tpindex} 5446*d5c9a868SElliott Hughes\def\pindex {\pgindex} 5447*d5c9a868SElliott Hughes 5448*d5c9a868SElliott Hughes% Define the macros used in formatting output of the sorted index material. 5449*d5c9a868SElliott Hughes 5450*d5c9a868SElliott Hughes% @printindex causes a particular index (the ??s file) to get printed. 5451*d5c9a868SElliott Hughes% It does not print any chapter heading (usually an @unnumbered). 5452*d5c9a868SElliott Hughes% 5453*d5c9a868SElliott Hughes\parseargdef\printindex{\begingroup 5454*d5c9a868SElliott Hughes \dobreak \chapheadingskip{10000}% 5455*d5c9a868SElliott Hughes % 5456*d5c9a868SElliott Hughes \smallfonts \rm 5457*d5c9a868SElliott Hughes \tolerance = 9500 5458*d5c9a868SElliott Hughes \plainfrenchspacing 5459*d5c9a868SElliott Hughes \everypar = {}% don't want the \kern\-parindent from indentation suppression. 5460*d5c9a868SElliott Hughes % 5461*d5c9a868SElliott Hughes % See comment in \requireopenindexfile. 5462*d5c9a868SElliott Hughes \def\indexname{#1}\ifx\indexname\indexisfl\def\indexname{f1}\fi 5463*d5c9a868SElliott Hughes % 5464*d5c9a868SElliott Hughes % See if the index file exists and is nonempty. 5465*d5c9a868SElliott Hughes \openin 1 \jobname.\indexname s 5466*d5c9a868SElliott Hughes \ifeof 1 5467*d5c9a868SElliott Hughes % \enddoublecolumns gets confused if there is no text in the index, 5468*d5c9a868SElliott Hughes % and it loses the chapter title and the aux file entries for the 5469*d5c9a868SElliott Hughes % index. The easiest way to prevent this problem is to make sure 5470*d5c9a868SElliott Hughes % there is some text. 5471*d5c9a868SElliott Hughes \putwordIndexNonexistent 5472*d5c9a868SElliott Hughes \typeout{No file \jobname.\indexname s.}% 5473*d5c9a868SElliott Hughes \else 5474*d5c9a868SElliott Hughes % If the index file exists but is empty, then \openin leaves \ifeof 5475*d5c9a868SElliott Hughes % false. We have to make TeX try to read something from the file, so 5476*d5c9a868SElliott Hughes % it can discover if there is anything in it. 5477*d5c9a868SElliott Hughes \read 1 to \thisline 5478*d5c9a868SElliott Hughes \ifeof 1 5479*d5c9a868SElliott Hughes \putwordIndexIsEmpty 5480*d5c9a868SElliott Hughes \else 5481*d5c9a868SElliott Hughes \expandafter\printindexzz\thisline\relax\relax\finish% 5482*d5c9a868SElliott Hughes \fi 5483*d5c9a868SElliott Hughes \fi 5484*d5c9a868SElliott Hughes \closein 1 5485*d5c9a868SElliott Hughes\endgroup} 5486*d5c9a868SElliott Hughes 5487*d5c9a868SElliott Hughes% If the index file starts with a backslash, forgo reading the index 5488*d5c9a868SElliott Hughes% file altogether. If somebody upgrades texinfo.tex they may still have 5489*d5c9a868SElliott Hughes% old index files using \ as the escape character. Reading this would 5490*d5c9a868SElliott Hughes% at best lead to typesetting garbage, at worst a TeX syntax error. 5491*d5c9a868SElliott Hughes\def\printindexzz#1#2\finish{% 5492*d5c9a868SElliott Hughes \expandafter\ifx\csname SETtxiindexescapeisbackslash\endcsname\relax 5493*d5c9a868SElliott Hughes \uccode`\~=`\\ \uppercase{\if\noexpand~}\noexpand#1 5494*d5c9a868SElliott Hughes \expandafter\ifx\csname SETtxiskipindexfileswithbackslash\endcsname\relax 5495*d5c9a868SElliott Hughes\errmessage{% 5496*d5c9a868SElliott HughesERROR: A sorted index file in an obsolete format was skipped. 5497*d5c9a868SElliott HughesTo fix this problem, please upgrade your version of 'texi2dvi' 5498*d5c9a868SElliott Hughesor 'texi2pdf' to that at <https://ftp.gnu.org/gnu/texinfo>. 5499*d5c9a868SElliott HughesIf you are using an old version of 'texindex' (part of the Texinfo 5500*d5c9a868SElliott Hughesdistribution), you may also need to upgrade to a newer version (at least 6.0). 5501*d5c9a868SElliott HughesYou may be able to typeset the index if you run 5502*d5c9a868SElliott Hughes'texindex \jobname.\indexname' yourself. 5503*d5c9a868SElliott HughesYou could also try setting the 'txiindexescapeisbackslash' flag by 5504*d5c9a868SElliott Hughesrunning a command like 5505*d5c9a868SElliott Hughes'texi2dvi -t "@set txiindexescapeisbackslash" \jobname.texi'. If you do 5506*d5c9a868SElliott Hughesthis, Texinfo will try to use index files in the old format. 5507*d5c9a868SElliott HughesIf you continue to have problems, deleting the index files and starting again 5508*d5c9a868SElliott Hughesmight help (with 'rm \jobname.?? \jobname.??s')% 5509*d5c9a868SElliott Hughes}% 5510*d5c9a868SElliott Hughes \else 5511*d5c9a868SElliott Hughes (Skipped sorted index file in obsolete format) 5512*d5c9a868SElliott Hughes \fi 5513*d5c9a868SElliott Hughes \else 5514*d5c9a868SElliott Hughes \begindoublecolumns 5515*d5c9a868SElliott Hughes \input \jobname.\indexname s 5516*d5c9a868SElliott Hughes \enddoublecolumns 5517*d5c9a868SElliott Hughes \fi 5518*d5c9a868SElliott Hughes \else 5519*d5c9a868SElliott Hughes \begindoublecolumns 5520*d5c9a868SElliott Hughes \catcode`\\=0\relax 5521*d5c9a868SElliott Hughes % 5522*d5c9a868SElliott Hughes % Make @ an escape character to give macros a chance to work. This 5523*d5c9a868SElliott Hughes % should work because we (hopefully) don't otherwise use @ in index files. 5524*d5c9a868SElliott Hughes %\catcode`\@=12\relax 5525*d5c9a868SElliott Hughes \catcode`\@=0\relax 5526*d5c9a868SElliott Hughes \input \jobname.\indexname s 5527*d5c9a868SElliott Hughes \enddoublecolumns 5528*d5c9a868SElliott Hughes \fi 5529*d5c9a868SElliott Hughes} 5530*d5c9a868SElliott Hughes 5531*d5c9a868SElliott Hughes% These macros are used by the sorted index file itself. 5532*d5c9a868SElliott Hughes% Change them to control the appearance of the index. 5533*d5c9a868SElliott Hughes 5534*d5c9a868SElliott Hughes{\catcode`\/=13 \catcode`\-=13 \catcode`\^=13 \catcode`\~=13 \catcode`\_=13 5535*d5c9a868SElliott Hughes\catcode`\|=13 \catcode`\<=13 \catcode`\>=13 \catcode`\+=13 \catcode`\"=13 5536*d5c9a868SElliott Hughes\catcode`\$=3 5537*d5c9a868SElliott Hughes\gdef\initialglyphs{% 5538*d5c9a868SElliott Hughes % special control sequences used in the index sort key 5539*d5c9a868SElliott Hughes \let\indexlbrace\{% 5540*d5c9a868SElliott Hughes \let\indexrbrace\}% 5541*d5c9a868SElliott Hughes \let\indexatchar\@% 5542*d5c9a868SElliott Hughes \def\indexbackslash{\math{\backslash}}% 5543*d5c9a868SElliott Hughes % 5544*d5c9a868SElliott Hughes % Some changes for non-alphabetic characters. Using the glyphs from the 5545*d5c9a868SElliott Hughes % math fonts looks more consistent than the typewriter font used elsewhere 5546*d5c9a868SElliott Hughes % for these characters. 5547*d5c9a868SElliott Hughes \uccode`\~=`\\ \uppercase{\def~{\math{\backslash}}} 5548*d5c9a868SElliott Hughes % 5549*d5c9a868SElliott Hughes % In case @\ is used for backslash 5550*d5c9a868SElliott Hughes \uppercase{\let\\=~} 5551*d5c9a868SElliott Hughes % Can't get bold backslash so don't use bold forward slash 5552*d5c9a868SElliott Hughes \catcode`\/=13 5553*d5c9a868SElliott Hughes \def/{{\secrmnotbold \normalslash}}% 5554*d5c9a868SElliott Hughes \def-{{\normaldash\normaldash}}% en dash `--' 5555*d5c9a868SElliott Hughes \def^{{\chapbf \normalcaret}}% 5556*d5c9a868SElliott Hughes \def~{{\chapbf \normaltilde}}% 5557*d5c9a868SElliott Hughes \def\_{% 5558*d5c9a868SElliott Hughes \leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }% 5559*d5c9a868SElliott Hughes \def|{$\vert$}% 5560*d5c9a868SElliott Hughes \def<{$\less$}% 5561*d5c9a868SElliott Hughes \def>{$\gtr$}% 5562*d5c9a868SElliott Hughes \def+{$\normalplus$}% 5563*d5c9a868SElliott Hughes}} 5564*d5c9a868SElliott Hughes 5565*d5c9a868SElliott Hughes\def\initial{% 5566*d5c9a868SElliott Hughes \bgroup 5567*d5c9a868SElliott Hughes \initialglyphs 5568*d5c9a868SElliott Hughes \initialx 5569*d5c9a868SElliott Hughes} 5570*d5c9a868SElliott Hughes 5571*d5c9a868SElliott Hughes\def\initialx#1{% 5572*d5c9a868SElliott Hughes % Remove any glue we may have, we'll be inserting our own. 5573*d5c9a868SElliott Hughes \removelastskip 5574*d5c9a868SElliott Hughes % 5575*d5c9a868SElliott Hughes % We like breaks before the index initials, so insert a bonus. 5576*d5c9a868SElliott Hughes % The glue before the bonus allows a little bit of space at the 5577*d5c9a868SElliott Hughes % bottom of a column to reduce an increase in inter-line spacing. 5578*d5c9a868SElliott Hughes \nobreak 5579*d5c9a868SElliott Hughes \vskip 0pt plus 5\baselineskip 5580*d5c9a868SElliott Hughes \penalty -300 5581*d5c9a868SElliott Hughes \vskip 0pt plus -5\baselineskip 5582*d5c9a868SElliott Hughes % 5583*d5c9a868SElliott Hughes % Typeset the initial. Making this add up to a whole number of 5584*d5c9a868SElliott Hughes % baselineskips increases the chance of the dots lining up from column 5585*d5c9a868SElliott Hughes % to column. It still won't often be perfect, because of the stretch 5586*d5c9a868SElliott Hughes % we need before each entry, but it's better. 5587*d5c9a868SElliott Hughes % 5588*d5c9a868SElliott Hughes % No shrink because it confuses \balancecolumns. 5589*d5c9a868SElliott Hughes \vskip 1.67\baselineskip plus 1\baselineskip 5590*d5c9a868SElliott Hughes \leftline{\secfonts \kern-0.05em \secbf #1}% 5591*d5c9a868SElliott Hughes % \secfonts is inside the argument of \leftline so that the change of 5592*d5c9a868SElliott Hughes % \baselineskip will not affect any glue inserted before the vbox that 5593*d5c9a868SElliott Hughes % \leftline creates. 5594*d5c9a868SElliott Hughes % Do our best not to break after the initial. 5595*d5c9a868SElliott Hughes \nobreak 5596*d5c9a868SElliott Hughes \vskip .33\baselineskip plus .1\baselineskip 5597*d5c9a868SElliott Hughes \egroup % \initialglyphs 5598*d5c9a868SElliott Hughes} 5599*d5c9a868SElliott Hughes 5600*d5c9a868SElliott Hughes\newdimen\entryrightmargin 5601*d5c9a868SElliott Hughes\entryrightmargin=0pt 5602*d5c9a868SElliott Hughes 5603*d5c9a868SElliott Hughes% \entry typesets a paragraph consisting of the text (#1), dot leaders, and 5604*d5c9a868SElliott Hughes% then page number (#2) flushed to the right margin. It is used for index 5605*d5c9a868SElliott Hughes% and table of contents entries. The paragraph is indented by \leftskip. 5606*d5c9a868SElliott Hughes% 5607*d5c9a868SElliott Hughes\def\entry{% 5608*d5c9a868SElliott Hughes \begingroup 5609*d5c9a868SElliott Hughes % 5610*d5c9a868SElliott Hughes % Start a new paragraph if necessary, so our assignments below can't 5611*d5c9a868SElliott Hughes % affect previous text. 5612*d5c9a868SElliott Hughes \par 5613*d5c9a868SElliott Hughes % 5614*d5c9a868SElliott Hughes % No extra space above this paragraph. 5615*d5c9a868SElliott Hughes \parskip = 0in 5616*d5c9a868SElliott Hughes % 5617*d5c9a868SElliott Hughes % When reading the text of entry, convert explicit line breaks 5618*d5c9a868SElliott Hughes % from @* into spaces. The user might give these in long section 5619*d5c9a868SElliott Hughes % titles, for instance. 5620*d5c9a868SElliott Hughes \def\*{\unskip\space\ignorespaces}% 5621*d5c9a868SElliott Hughes \def\entrybreak{\hfil\break}% An undocumented command 5622*d5c9a868SElliott Hughes % 5623*d5c9a868SElliott Hughes % Swallow the left brace of the text (first parameter): 5624*d5c9a868SElliott Hughes \afterassignment\doentry 5625*d5c9a868SElliott Hughes \let\temp = 5626*d5c9a868SElliott Hughes} 5627*d5c9a868SElliott Hughes\def\entrybreak{\unskip\space\ignorespaces}% 5628*d5c9a868SElliott Hughes\def\doentry{% 5629*d5c9a868SElliott Hughes % Save the text of the entry 5630*d5c9a868SElliott Hughes \global\setbox\boxA=\hbox\bgroup 5631*d5c9a868SElliott Hughes \bgroup % Instead of the swallowed brace. 5632*d5c9a868SElliott Hughes \noindent 5633*d5c9a868SElliott Hughes \aftergroup\finishentry 5634*d5c9a868SElliott Hughes % And now comes the text of the entry. 5635*d5c9a868SElliott Hughes % Not absorbing as a macro argument reduces the chance of problems 5636*d5c9a868SElliott Hughes % with catcodes occurring. 5637*d5c9a868SElliott Hughes} 5638*d5c9a868SElliott Hughes{\catcode`\@=11 5639*d5c9a868SElliott Hughes\gdef\finishentry#1{% 5640*d5c9a868SElliott Hughes \egroup % end box A 5641*d5c9a868SElliott Hughes \dimen@ = \wd\boxA % Length of text of entry 5642*d5c9a868SElliott Hughes \global\setbox\boxA=\hbox\bgroup 5643*d5c9a868SElliott Hughes \unhbox\boxA 5644*d5c9a868SElliott Hughes % #1 is the page number. 5645*d5c9a868SElliott Hughes % 5646*d5c9a868SElliott Hughes % Get the width of the page numbers, and only use 5647*d5c9a868SElliott Hughes % leaders if they are present. 5648*d5c9a868SElliott Hughes \global\setbox\boxB = \hbox{#1}% 5649*d5c9a868SElliott Hughes \ifdim\wd\boxB = 0pt 5650*d5c9a868SElliott Hughes \null\nobreak\hfill\ % 5651*d5c9a868SElliott Hughes \else 5652*d5c9a868SElliott Hughes % 5653*d5c9a868SElliott Hughes \null\nobreak\indexdotfill % Have leaders before the page number. 5654*d5c9a868SElliott Hughes % 5655*d5c9a868SElliott Hughes \ifpdforxetex 5656*d5c9a868SElliott Hughes \pdfgettoks#1.% 5657*d5c9a868SElliott Hughes \hskip\skip\thinshrinkable\the\toksA 5658*d5c9a868SElliott Hughes \else 5659*d5c9a868SElliott Hughes \hskip\skip\thinshrinkable #1% 5660*d5c9a868SElliott Hughes \fi 5661*d5c9a868SElliott Hughes \fi 5662*d5c9a868SElliott Hughes \egroup % end \boxA 5663*d5c9a868SElliott Hughes \ifdim\wd\boxB = 0pt 5664*d5c9a868SElliott Hughes \noindent\unhbox\boxA\par 5665*d5c9a868SElliott Hughes \nobreak 5666*d5c9a868SElliott Hughes \else\bgroup 5667*d5c9a868SElliott Hughes % We want the text of the entries to be aligned to the left, and the 5668*d5c9a868SElliott Hughes % page numbers to be aligned to the right. 5669*d5c9a868SElliott Hughes % 5670*d5c9a868SElliott Hughes \parindent = 0pt 5671*d5c9a868SElliott Hughes \advance\leftskip by 0pt plus 1fil 5672*d5c9a868SElliott Hughes \advance\leftskip by 0pt plus -1fill 5673*d5c9a868SElliott Hughes \rightskip = 0pt plus -1fil 5674*d5c9a868SElliott Hughes \advance\rightskip by 0pt plus 1fill 5675*d5c9a868SElliott Hughes % Cause last line, which could consist of page numbers on their own 5676*d5c9a868SElliott Hughes % if the list of page numbers is long, to be aligned to the right. 5677*d5c9a868SElliott Hughes \parfillskip=0pt plus -1fill 5678*d5c9a868SElliott Hughes % 5679*d5c9a868SElliott Hughes \advance\rightskip by \entryrightmargin 5680*d5c9a868SElliott Hughes % Determine how far we can stretch into the margin. 5681*d5c9a868SElliott Hughes % This allows, e.g., "Appendix H GNU Free Documentation License" to 5682*d5c9a868SElliott Hughes % fit on one line in @letterpaper format. 5683*d5c9a868SElliott Hughes \ifdim\entryrightmargin>2.1em 5684*d5c9a868SElliott Hughes \dimen@i=2.1em 5685*d5c9a868SElliott Hughes \else 5686*d5c9a868SElliott Hughes \dimen@i=0em 5687*d5c9a868SElliott Hughes \fi 5688*d5c9a868SElliott Hughes \advance \parfillskip by 0pt minus 1\dimen@i 5689*d5c9a868SElliott Hughes % 5690*d5c9a868SElliott Hughes \dimen@ii = \hsize 5691*d5c9a868SElliott Hughes \advance\dimen@ii by -1\leftskip 5692*d5c9a868SElliott Hughes \advance\dimen@ii by -1\entryrightmargin 5693*d5c9a868SElliott Hughes \advance\dimen@ii by 1\dimen@i 5694*d5c9a868SElliott Hughes \ifdim\wd\boxA > \dimen@ii % If the entry doesn't fit in one line 5695*d5c9a868SElliott Hughes \ifdim\dimen@ > 0.8\dimen@ii % due to long index text 5696*d5c9a868SElliott Hughes % Try to split the text roughly evenly. \dimen@ will be the length of 5697*d5c9a868SElliott Hughes % the first line. 5698*d5c9a868SElliott Hughes \dimen@ = 0.7\dimen@ 5699*d5c9a868SElliott Hughes \dimen@ii = \hsize 5700*d5c9a868SElliott Hughes \ifnum\dimen@>\dimen@ii 5701*d5c9a868SElliott Hughes % If the entry is too long (for example, if it needs more than 5702*d5c9a868SElliott Hughes % two lines), use all the space in the first line. 5703*d5c9a868SElliott Hughes \dimen@ = \dimen@ii 5704*d5c9a868SElliott Hughes \fi 5705*d5c9a868SElliott Hughes \advance\leftskip by 0pt plus 1fill % ragged right 5706*d5c9a868SElliott Hughes \advance \dimen@ by 1\rightskip 5707*d5c9a868SElliott Hughes \parshape = 2 0pt \dimen@ 0em \dimen@ii 5708*d5c9a868SElliott Hughes % Ideally we'd add a finite glue at the end of the first line only, 5709*d5c9a868SElliott Hughes % instead of using \parshape with explicit line lengths, but TeX 5710*d5c9a868SElliott Hughes % doesn't seem to provide a way to do such a thing. 5711*d5c9a868SElliott Hughes % 5712*d5c9a868SElliott Hughes % Indent all lines but the first one. 5713*d5c9a868SElliott Hughes \advance\leftskip by 1em 5714*d5c9a868SElliott Hughes \advance\parindent by -1em 5715*d5c9a868SElliott Hughes \fi\fi 5716*d5c9a868SElliott Hughes \indent % start paragraph 5717*d5c9a868SElliott Hughes \unhbox\boxA 5718*d5c9a868SElliott Hughes % 5719*d5c9a868SElliott Hughes % Do not prefer a separate line ending with a hyphen to fewer lines. 5720*d5c9a868SElliott Hughes \finalhyphendemerits = 0 5721*d5c9a868SElliott Hughes % 5722*d5c9a868SElliott Hughes % Word spacing - no stretch 5723*d5c9a868SElliott Hughes \spaceskip=\fontdimen2\font minus \fontdimen4\font 5724*d5c9a868SElliott Hughes % 5725*d5c9a868SElliott Hughes \linepenalty=1000 % Discourage line breaks. 5726*d5c9a868SElliott Hughes \hyphenpenalty=5000 % Discourage hyphenation. 5727*d5c9a868SElliott Hughes % 5728*d5c9a868SElliott Hughes \par % format the paragraph 5729*d5c9a868SElliott Hughes \egroup % The \vbox 5730*d5c9a868SElliott Hughes \fi 5731*d5c9a868SElliott Hughes \endgroup 5732*d5c9a868SElliott Hughes}} 5733*d5c9a868SElliott Hughes 5734*d5c9a868SElliott Hughes\newskip\thinshrinkable 5735*d5c9a868SElliott Hughes\skip\thinshrinkable=.15em minus .15em 5736*d5c9a868SElliott Hughes 5737*d5c9a868SElliott Hughes% Like plain.tex's \dotfill, except uses up at least 1 em. 5738*d5c9a868SElliott Hughes% The filll stretch here overpowers both the fil and fill stretch to push 5739*d5c9a868SElliott Hughes% the page number to the right. 5740*d5c9a868SElliott Hughes\def\indexdotfill{\cleaders 5741*d5c9a868SElliott Hughes \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1filll} 5742*d5c9a868SElliott Hughes 5743*d5c9a868SElliott Hughes 5744*d5c9a868SElliott Hughes\def\primary #1{\line{#1\hfil}} 5745*d5c9a868SElliott Hughes 5746*d5c9a868SElliott Hughes\def\secondary{\indententry{0.5cm}} 5747*d5c9a868SElliott Hughes\def\tertiary{\indententry{1cm}} 5748*d5c9a868SElliott Hughes 5749*d5c9a868SElliott Hughes\def\indententry#1#2#3{% 5750*d5c9a868SElliott Hughes \bgroup 5751*d5c9a868SElliott Hughes \leftskip=#1 5752*d5c9a868SElliott Hughes \entry{#2}{#3}% 5753*d5c9a868SElliott Hughes \egroup 5754*d5c9a868SElliott Hughes} 5755*d5c9a868SElliott Hughes 5756*d5c9a868SElliott Hughes% Define two-column mode, which we use to typeset indexes. 5757*d5c9a868SElliott Hughes% Adapted from the TeXbook, page 416, which is to say, 5758*d5c9a868SElliott Hughes% the manmac.tex format used to print the TeXbook itself. 5759*d5c9a868SElliott Hughes\catcode`\@=11 % private names 5760*d5c9a868SElliott Hughes 5761*d5c9a868SElliott Hughes\newbox\partialpage 5762*d5c9a868SElliott Hughes\newdimen\doublecolumnhsize 5763*d5c9a868SElliott Hughes 5764*d5c9a868SElliott Hughes\def\begindoublecolumns{\begingroup % ended by \enddoublecolumns 5765*d5c9a868SElliott Hughes % If not much space left on page, start a new page. 5766*d5c9a868SElliott Hughes \ifdim\pagetotal>0.8\vsize\vfill\eject\fi 5767*d5c9a868SElliott Hughes % 5768*d5c9a868SElliott Hughes % Grab any single-column material above us. 5769*d5c9a868SElliott Hughes \output = {% 5770*d5c9a868SElliott Hughes \savetopmark 5771*d5c9a868SElliott Hughes % 5772*d5c9a868SElliott Hughes \global\setbox\partialpage = \vbox{% 5773*d5c9a868SElliott Hughes % Unvbox the main output page. 5774*d5c9a868SElliott Hughes \unvbox\PAGE 5775*d5c9a868SElliott Hughes \kern-\topskip \kern\baselineskip 5776*d5c9a868SElliott Hughes }% 5777*d5c9a868SElliott Hughes }% 5778*d5c9a868SElliott Hughes \eject % run that output routine to set \partialpage 5779*d5c9a868SElliott Hughes % 5780*d5c9a868SElliott Hughes % Use the double-column output routine for subsequent pages. 5781*d5c9a868SElliott Hughes \output = {\doublecolumnout}% 5782*d5c9a868SElliott Hughes % 5783*d5c9a868SElliott Hughes % Change the page size parameters. We could do this once outside this 5784*d5c9a868SElliott Hughes % routine, in each of @smallbook, @afourpaper, and the default 8.5x11 5785*d5c9a868SElliott Hughes % format, but then we repeat the same computation. Repeating a couple 5786*d5c9a868SElliott Hughes % of assignments once per index is clearly meaningless for the 5787*d5c9a868SElliott Hughes % execution time, so we may as well do it in one place. 5788*d5c9a868SElliott Hughes % 5789*d5c9a868SElliott Hughes % First we halve the line length, less a little for the gutter between 5790*d5c9a868SElliott Hughes % the columns. We compute the gutter based on the line length, so it 5791*d5c9a868SElliott Hughes % changes automatically with the paper format. The magic constant 5792*d5c9a868SElliott Hughes % below is chosen so that the gutter has the same value (well, +-<1pt) 5793*d5c9a868SElliott Hughes % as it did when we hard-coded it. 5794*d5c9a868SElliott Hughes % 5795*d5c9a868SElliott Hughes % We put the result in a separate register, \doublecolumhsize, so we 5796*d5c9a868SElliott Hughes % can restore it in \pagesofar, after \hsize itself has (potentially) 5797*d5c9a868SElliott Hughes % been clobbered. 5798*d5c9a868SElliott Hughes % 5799*d5c9a868SElliott Hughes \doublecolumnhsize = \hsize 5800*d5c9a868SElliott Hughes \advance\doublecolumnhsize by -.04154\hsize 5801*d5c9a868SElliott Hughes \divide\doublecolumnhsize by 2 5802*d5c9a868SElliott Hughes \hsize = \doublecolumnhsize 5803*d5c9a868SElliott Hughes % 5804*d5c9a868SElliott Hughes % Get the available space for the double columns -- the normal 5805*d5c9a868SElliott Hughes % (undoubled) page height minus any material left over from the 5806*d5c9a868SElliott Hughes % previous page. 5807*d5c9a868SElliott Hughes \advance\vsize by -\ht\partialpage 5808*d5c9a868SElliott Hughes \vsize = 2\vsize 5809*d5c9a868SElliott Hughes % 5810*d5c9a868SElliott Hughes % For the benefit of balancing columns 5811*d5c9a868SElliott Hughes \advance\baselineskip by 0pt plus 0.5pt 5812*d5c9a868SElliott Hughes} 5813*d5c9a868SElliott Hughes 5814*d5c9a868SElliott Hughes% The double-column output routine for all double-column pages except 5815*d5c9a868SElliott Hughes% the last, which is done by \balancecolumns. 5816*d5c9a868SElliott Hughes% 5817*d5c9a868SElliott Hughes\def\doublecolumnout{% 5818*d5c9a868SElliott Hughes % 5819*d5c9a868SElliott Hughes \savetopmark 5820*d5c9a868SElliott Hughes \splittopskip=\topskip \splitmaxdepth=\maxdepth 5821*d5c9a868SElliott Hughes \dimen@ = \vsize 5822*d5c9a868SElliott Hughes \divide\dimen@ by 2 5823*d5c9a868SElliott Hughes % 5824*d5c9a868SElliott Hughes % box0 will be the left-hand column, box2 the right. 5825*d5c9a868SElliott Hughes \setbox0=\vsplit\PAGE to\dimen@ \setbox2=\vsplit\PAGE to\dimen@ 5826*d5c9a868SElliott Hughes \global\advance\vsize by 2\ht\partialpage 5827*d5c9a868SElliott Hughes \onepageout\pagesofar % empty except for the first time we are called 5828*d5c9a868SElliott Hughes \unvbox\PAGE 5829*d5c9a868SElliott Hughes \penalty\outputpenalty 5830*d5c9a868SElliott Hughes} 5831*d5c9a868SElliott Hughes% 5832*d5c9a868SElliott Hughes% Re-output the contents of the output page -- any previous material, 5833*d5c9a868SElliott Hughes% followed by the two boxes we just split, in box0 and box2. 5834*d5c9a868SElliott Hughes\def\pagesofar{% 5835*d5c9a868SElliott Hughes \unvbox\partialpage 5836*d5c9a868SElliott Hughes % 5837*d5c9a868SElliott Hughes \hsize = \doublecolumnhsize 5838*d5c9a868SElliott Hughes \wd0=\hsize \wd2=\hsize 5839*d5c9a868SElliott Hughes \hbox to\txipagewidth{\box0\hfil\box2}% 5840*d5c9a868SElliott Hughes} 5841*d5c9a868SElliott Hughes 5842*d5c9a868SElliott Hughes 5843*d5c9a868SElliott Hughes% Finished with double columns. 5844*d5c9a868SElliott Hughes\def\enddoublecolumns{% 5845*d5c9a868SElliott Hughes % The following penalty ensures that the page builder is exercised 5846*d5c9a868SElliott Hughes % _before_ we change the output routine. This is necessary in the 5847*d5c9a868SElliott Hughes % following situation: 5848*d5c9a868SElliott Hughes % 5849*d5c9a868SElliott Hughes % The last section of the index consists only of a single entry. 5850*d5c9a868SElliott Hughes % Before this section, \pagetotal is less than \pagegoal, so no 5851*d5c9a868SElliott Hughes % break occurs before the last section starts. However, the last 5852*d5c9a868SElliott Hughes % section, consisting of \initial and the single \entry, does not 5853*d5c9a868SElliott Hughes % fit on the page and has to be broken off. Without the following 5854*d5c9a868SElliott Hughes % penalty the page builder will not be exercised until \eject 5855*d5c9a868SElliott Hughes % below, and by that time we'll already have changed the output 5856*d5c9a868SElliott Hughes % routine to the \balancecolumns version, so the next-to-last 5857*d5c9a868SElliott Hughes % double-column page will be processed with \balancecolumns, which 5858*d5c9a868SElliott Hughes % is wrong: The two columns will go to the main vertical list, with 5859*d5c9a868SElliott Hughes % the broken-off section in the recent contributions. As soon as 5860*d5c9a868SElliott Hughes % the output routine finishes, TeX starts reconsidering the page 5861*d5c9a868SElliott Hughes % break. The two columns and the broken-off section both fit on the 5862*d5c9a868SElliott Hughes % page, because the two columns now take up only half of the page 5863*d5c9a868SElliott Hughes % goal. When TeX sees \eject from below which follows the final 5864*d5c9a868SElliott Hughes % section, it invokes the new output routine that we've set after 5865*d5c9a868SElliott Hughes % \balancecolumns below; \onepageout will try to fit the two columns 5866*d5c9a868SElliott Hughes % and the final section into the vbox of \txipageheight (see 5867*d5c9a868SElliott Hughes % \pagebody), causing an overfull box. 5868*d5c9a868SElliott Hughes % 5869*d5c9a868SElliott Hughes % Note that glue won't work here, because glue does not exercise the 5870*d5c9a868SElliott Hughes % page builder, unlike penalties (see The TeXbook, pp. 280-281). 5871*d5c9a868SElliott Hughes \penalty0 5872*d5c9a868SElliott Hughes % 5873*d5c9a868SElliott Hughes \output = {% 5874*d5c9a868SElliott Hughes % Split the last of the double-column material. 5875*d5c9a868SElliott Hughes \savetopmark 5876*d5c9a868SElliott Hughes \balancecolumns 5877*d5c9a868SElliott Hughes }% 5878*d5c9a868SElliott Hughes \eject % call the \output just set 5879*d5c9a868SElliott Hughes \ifdim\pagetotal=0pt 5880*d5c9a868SElliott Hughes % Having called \balancecolumns once, we do not 5881*d5c9a868SElliott Hughes % want to call it again. Therefore, reset \output to its normal 5882*d5c9a868SElliott Hughes % definition right away. 5883*d5c9a868SElliott Hughes \global\output=\expandafter{\the\defaultoutput} 5884*d5c9a868SElliott Hughes % 5885*d5c9a868SElliott Hughes \endgroup % started in \begindoublecolumns 5886*d5c9a868SElliott Hughes % Leave the double-column material on the current page, no automatic 5887*d5c9a868SElliott Hughes % page break. 5888*d5c9a868SElliott Hughes \box\balancedcolumns 5889*d5c9a868SElliott Hughes % 5890*d5c9a868SElliott Hughes % \pagegoal was set to the doubled \vsize above, since we restarted 5891*d5c9a868SElliott Hughes % the current page. We're now back to normal single-column 5892*d5c9a868SElliott Hughes % typesetting, so reset \pagegoal to the normal \vsize. 5893*d5c9a868SElliott Hughes \global\vsize = \txipageheight % 5894*d5c9a868SElliott Hughes \pagegoal = \txipageheight % 5895*d5c9a868SElliott Hughes \else 5896*d5c9a868SElliott Hughes % We had some left-over material. This might happen when \doublecolumnout 5897*d5c9a868SElliott Hughes % is called in \balancecolumns. Try again. 5898*d5c9a868SElliott Hughes \expandafter\enddoublecolumns 5899*d5c9a868SElliott Hughes \fi 5900*d5c9a868SElliott Hughes} 5901*d5c9a868SElliott Hughes\newbox\balancedcolumns 5902*d5c9a868SElliott Hughes\setbox\balancedcolumns=\vbox{shouldnt see this}% 5903*d5c9a868SElliott Hughes% 5904*d5c9a868SElliott Hughes% Only called for the last of the double column material. \doublecolumnout 5905*d5c9a868SElliott Hughes% does the others. 5906*d5c9a868SElliott Hughes\def\balancecolumns{% 5907*d5c9a868SElliott Hughes \setbox0 = \vbox{\unvbox\PAGE}% like \box255 but more efficient, see p.120. 5908*d5c9a868SElliott Hughes \dimen@ = \ht0 5909*d5c9a868SElliott Hughes \ifdim\dimen@<7\baselineskip 5910*d5c9a868SElliott Hughes % Don't split a short final column in two. 5911*d5c9a868SElliott Hughes \setbox2=\vbox{}% 5912*d5c9a868SElliott Hughes \global\setbox\balancedcolumns=\vbox{\pagesofar}% 5913*d5c9a868SElliott Hughes \else 5914*d5c9a868SElliott Hughes % double the leading vertical space 5915*d5c9a868SElliott Hughes \advance\dimen@ by \topskip 5916*d5c9a868SElliott Hughes \advance\dimen@ by-\baselineskip 5917*d5c9a868SElliott Hughes \divide\dimen@ by 2 % target to split to 5918*d5c9a868SElliott Hughes \dimen@ii = \dimen@ 5919*d5c9a868SElliott Hughes \splittopskip = \topskip 5920*d5c9a868SElliott Hughes % Loop until left column is at least as high as the right column. 5921*d5c9a868SElliott Hughes {% 5922*d5c9a868SElliott Hughes \vbadness = 10000 5923*d5c9a868SElliott Hughes \loop 5924*d5c9a868SElliott Hughes \global\setbox3 = \copy0 5925*d5c9a868SElliott Hughes \global\setbox1 = \vsplit3 to \dimen@ 5926*d5c9a868SElliott Hughes \ifdim\ht1<\ht3 5927*d5c9a868SElliott Hughes \global\advance\dimen@ by 1pt 5928*d5c9a868SElliott Hughes \repeat 5929*d5c9a868SElliott Hughes }% 5930*d5c9a868SElliott Hughes % Now the left column is in box 1, and the right column in box 3. 5931*d5c9a868SElliott Hughes % 5932*d5c9a868SElliott Hughes % Check whether the left column has come out higher than the page itself. 5933*d5c9a868SElliott Hughes % (Note that we have doubled \vsize for the double columns, so 5934*d5c9a868SElliott Hughes % the actual height of the page is 0.5\vsize). 5935*d5c9a868SElliott Hughes \ifdim2\ht1>\vsize 5936*d5c9a868SElliott Hughes % It appears that we have been called upon to balance too much material. 5937*d5c9a868SElliott Hughes % Output some of it with \doublecolumnout, leaving the rest on the page. 5938*d5c9a868SElliott Hughes \setbox\PAGE=\box0 5939*d5c9a868SElliott Hughes \doublecolumnout 5940*d5c9a868SElliott Hughes \else 5941*d5c9a868SElliott Hughes % Compare the heights of the two columns. 5942*d5c9a868SElliott Hughes \ifdim4\ht1>5\ht3 5943*d5c9a868SElliott Hughes % Column heights are too different, so don't make their bottoms 5944*d5c9a868SElliott Hughes % flush with each other. 5945*d5c9a868SElliott Hughes \setbox2=\vbox to \ht1 {\unvbox3\vfill}% 5946*d5c9a868SElliott Hughes \setbox0=\vbox to \ht1 {\unvbox1\vfill}% 5947*d5c9a868SElliott Hughes \else 5948*d5c9a868SElliott Hughes % Make column bottoms flush with each other. 5949*d5c9a868SElliott Hughes \setbox2=\vbox to\ht1{\unvbox3\unskip}% 5950*d5c9a868SElliott Hughes \setbox0=\vbox to\ht1{\unvbox1\unskip}% 5951*d5c9a868SElliott Hughes \fi 5952*d5c9a868SElliott Hughes \global\setbox\balancedcolumns=\vbox{\pagesofar}% 5953*d5c9a868SElliott Hughes \fi 5954*d5c9a868SElliott Hughes \fi 5955*d5c9a868SElliott Hughes % 5956*d5c9a868SElliott Hughes} 5957*d5c9a868SElliott Hughes\catcode`\@ = \other 5958*d5c9a868SElliott Hughes 5959*d5c9a868SElliott Hughes 5960*d5c9a868SElliott Hughes\message{sectioning,} 5961*d5c9a868SElliott Hughes% Chapters, sections, etc. 5962*d5c9a868SElliott Hughes 5963*d5c9a868SElliott Hughes% Let's start with @part. 5964*d5c9a868SElliott Hughes\outer\parseargdef\part{\partzzz{#1}} 5965*d5c9a868SElliott Hughes\def\partzzz#1{% 5966*d5c9a868SElliott Hughes \chapoddpage 5967*d5c9a868SElliott Hughes \null 5968*d5c9a868SElliott Hughes \vskip.3\vsize % move it down on the page a bit 5969*d5c9a868SElliott Hughes \begingroup 5970*d5c9a868SElliott Hughes \noindent \titlefonts\rm #1\par % the text 5971*d5c9a868SElliott Hughes \let\lastnode=\empty % no node to associate with 5972*d5c9a868SElliott Hughes \writetocentry{part}{#1}{}% but put it in the toc 5973*d5c9a868SElliott Hughes \headingsoff % no headline or footline on the part page 5974*d5c9a868SElliott Hughes % This outputs a mark at the end of the page that clears \thischapter 5975*d5c9a868SElliott Hughes % and \thissection, as is done in \startcontents. 5976*d5c9a868SElliott Hughes \let\pchapsepmacro\relax 5977*d5c9a868SElliott Hughes \chapmacro{}{Yomitfromtoc}{}% 5978*d5c9a868SElliott Hughes \chapoddpage 5979*d5c9a868SElliott Hughes \endgroup 5980*d5c9a868SElliott Hughes} 5981*d5c9a868SElliott Hughes 5982*d5c9a868SElliott Hughes% \unnumberedno is an oxymoron. But we count the unnumbered 5983*d5c9a868SElliott Hughes% sections so that we can refer to them unambiguously in the pdf 5984*d5c9a868SElliott Hughes% outlines by their "section number". We avoid collisions with chapter 5985*d5c9a868SElliott Hughes% numbers by starting them at 10000. (If a document ever has 10000 5986*d5c9a868SElliott Hughes% chapters, we're in trouble anyway, I'm sure.) 5987*d5c9a868SElliott Hughes\newcount\unnumberedno \unnumberedno = 10000 5988*d5c9a868SElliott Hughes\newcount\chapno 5989*d5c9a868SElliott Hughes\newcount\secno \secno=0 5990*d5c9a868SElliott Hughes\newcount\subsecno \subsecno=0 5991*d5c9a868SElliott Hughes\newcount\subsubsecno \subsubsecno=0 5992*d5c9a868SElliott Hughes 5993*d5c9a868SElliott Hughes% This counter is funny since it counts through charcodes of letters A, B, ... 5994*d5c9a868SElliott Hughes\newcount\appendixno \appendixno = `\@ 5995*d5c9a868SElliott Hughes% 5996*d5c9a868SElliott Hughes% \def\appendixletter{\char\the\appendixno} 5997*d5c9a868SElliott Hughes% We do the following ugly conditional instead of the above simple 5998*d5c9a868SElliott Hughes% construct for the sake of pdftex, which needs the actual 5999*d5c9a868SElliott Hughes% letter in the expansion, not just typeset. 6000*d5c9a868SElliott Hughes% 6001*d5c9a868SElliott Hughes\def\appendixletter{% 6002*d5c9a868SElliott Hughes \ifnum\appendixno=`A A% 6003*d5c9a868SElliott Hughes \else\ifnum\appendixno=`B B% 6004*d5c9a868SElliott Hughes \else\ifnum\appendixno=`C C% 6005*d5c9a868SElliott Hughes \else\ifnum\appendixno=`D D% 6006*d5c9a868SElliott Hughes \else\ifnum\appendixno=`E E% 6007*d5c9a868SElliott Hughes \else\ifnum\appendixno=`F F% 6008*d5c9a868SElliott Hughes \else\ifnum\appendixno=`G G% 6009*d5c9a868SElliott Hughes \else\ifnum\appendixno=`H H% 6010*d5c9a868SElliott Hughes \else\ifnum\appendixno=`I I% 6011*d5c9a868SElliott Hughes \else\ifnum\appendixno=`J J% 6012*d5c9a868SElliott Hughes \else\ifnum\appendixno=`K K% 6013*d5c9a868SElliott Hughes \else\ifnum\appendixno=`L L% 6014*d5c9a868SElliott Hughes \else\ifnum\appendixno=`M M% 6015*d5c9a868SElliott Hughes \else\ifnum\appendixno=`N N% 6016*d5c9a868SElliott Hughes \else\ifnum\appendixno=`O O% 6017*d5c9a868SElliott Hughes \else\ifnum\appendixno=`P P% 6018*d5c9a868SElliott Hughes \else\ifnum\appendixno=`Q Q% 6019*d5c9a868SElliott Hughes \else\ifnum\appendixno=`R R% 6020*d5c9a868SElliott Hughes \else\ifnum\appendixno=`S S% 6021*d5c9a868SElliott Hughes \else\ifnum\appendixno=`T T% 6022*d5c9a868SElliott Hughes \else\ifnum\appendixno=`U U% 6023*d5c9a868SElliott Hughes \else\ifnum\appendixno=`V V% 6024*d5c9a868SElliott Hughes \else\ifnum\appendixno=`W W% 6025*d5c9a868SElliott Hughes \else\ifnum\appendixno=`X X% 6026*d5c9a868SElliott Hughes \else\ifnum\appendixno=`Y Y% 6027*d5c9a868SElliott Hughes \else\ifnum\appendixno=`Z Z% 6028*d5c9a868SElliott Hughes % The \the is necessary, despite appearances, because \appendixletter is 6029*d5c9a868SElliott Hughes % expanded while writing the .toc file. \char\appendixno is not 6030*d5c9a868SElliott Hughes % expandable, thus it is written literally, thus all appendixes come out 6031*d5c9a868SElliott Hughes % with the same letter (or @) in the toc without it. 6032*d5c9a868SElliott Hughes \else\char\the\appendixno 6033*d5c9a868SElliott Hughes \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi 6034*d5c9a868SElliott Hughes \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi} 6035*d5c9a868SElliott Hughes 6036*d5c9a868SElliott Hughes% Each @chapter defines these (using marks) as the number+name, number 6037*d5c9a868SElliott Hughes% and name of the chapter. Page headings and footings can use 6038*d5c9a868SElliott Hughes% these. @section does likewise. 6039*d5c9a868SElliott Hughes\def\thischapter{} 6040*d5c9a868SElliott Hughes\def\thischapternum{} 6041*d5c9a868SElliott Hughes\def\thischaptername{} 6042*d5c9a868SElliott Hughes\def\thissection{} 6043*d5c9a868SElliott Hughes\def\thissectionnum{} 6044*d5c9a868SElliott Hughes\def\thissectionname{} 6045*d5c9a868SElliott Hughes 6046*d5c9a868SElliott Hughes\newcount\absseclevel % used to calculate proper heading level 6047*d5c9a868SElliott Hughes\newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count 6048*d5c9a868SElliott Hughes 6049*d5c9a868SElliott Hughes% @raisesections: treat @section as chapter, @subsection as section, etc. 6050*d5c9a868SElliott Hughes\def\raisesections{\global\advance\secbase by -1} 6051*d5c9a868SElliott Hughes 6052*d5c9a868SElliott Hughes% @lowersections: treat @chapter as section, @section as subsection, etc. 6053*d5c9a868SElliott Hughes\def\lowersections{\global\advance\secbase by 1} 6054*d5c9a868SElliott Hughes 6055*d5c9a868SElliott Hughes% we only have subsub. 6056*d5c9a868SElliott Hughes\chardef\maxseclevel = 3 6057*d5c9a868SElliott Hughes% 6058*d5c9a868SElliott Hughes% A numbered section within an unnumbered changes to unnumbered too. 6059*d5c9a868SElliott Hughes% To achieve this, remember the "biggest" unnum. sec. we are currently in: 6060*d5c9a868SElliott Hughes\chardef\unnlevel = \maxseclevel 6061*d5c9a868SElliott Hughes% 6062*d5c9a868SElliott Hughes% Trace whether the current chapter is an appendix or not: 6063*d5c9a868SElliott Hughes% \chapheadtype is "N" or "A", unnumbered chapters are ignored. 6064*d5c9a868SElliott Hughes\def\chapheadtype{N} 6065*d5c9a868SElliott Hughes 6066*d5c9a868SElliott Hughes% Choose a heading macro 6067*d5c9a868SElliott Hughes% #1 is heading type 6068*d5c9a868SElliott Hughes% #2 is heading level 6069*d5c9a868SElliott Hughes% #3 is text for heading 6070*d5c9a868SElliott Hughes\def\genhead#1#2#3{% 6071*d5c9a868SElliott Hughes % Compute the abs. sec. level: 6072*d5c9a868SElliott Hughes \absseclevel=#2 6073*d5c9a868SElliott Hughes \advance\absseclevel by \secbase 6074*d5c9a868SElliott Hughes % Make sure \absseclevel doesn't fall outside the range: 6075*d5c9a868SElliott Hughes \ifnum \absseclevel < 0 6076*d5c9a868SElliott Hughes \absseclevel = 0 6077*d5c9a868SElliott Hughes \else 6078*d5c9a868SElliott Hughes \ifnum \absseclevel > 3 6079*d5c9a868SElliott Hughes \absseclevel = 3 6080*d5c9a868SElliott Hughes \fi 6081*d5c9a868SElliott Hughes \fi 6082*d5c9a868SElliott Hughes % The heading type: 6083*d5c9a868SElliott Hughes \def\headtype{#1}% 6084*d5c9a868SElliott Hughes \if \headtype U% 6085*d5c9a868SElliott Hughes \ifnum \absseclevel < \unnlevel 6086*d5c9a868SElliott Hughes \chardef\unnlevel = \absseclevel 6087*d5c9a868SElliott Hughes \fi 6088*d5c9a868SElliott Hughes \else 6089*d5c9a868SElliott Hughes % Check for appendix sections: 6090*d5c9a868SElliott Hughes \ifnum \absseclevel = 0 6091*d5c9a868SElliott Hughes \edef\chapheadtype{\headtype}% 6092*d5c9a868SElliott Hughes \else 6093*d5c9a868SElliott Hughes \if \headtype A\if \chapheadtype N% 6094*d5c9a868SElliott Hughes \errmessage{@appendix... within a non-appendix chapter}% 6095*d5c9a868SElliott Hughes \fi\fi 6096*d5c9a868SElliott Hughes \fi 6097*d5c9a868SElliott Hughes % Check for numbered within unnumbered: 6098*d5c9a868SElliott Hughes \ifnum \absseclevel > \unnlevel 6099*d5c9a868SElliott Hughes \def\headtype{U}% 6100*d5c9a868SElliott Hughes \else 6101*d5c9a868SElliott Hughes \chardef\unnlevel = 3 6102*d5c9a868SElliott Hughes \fi 6103*d5c9a868SElliott Hughes \fi 6104*d5c9a868SElliott Hughes % Now print the heading: 6105*d5c9a868SElliott Hughes \if \headtype U% 6106*d5c9a868SElliott Hughes \ifcase\absseclevel 6107*d5c9a868SElliott Hughes \unnumberedzzz{#3}% 6108*d5c9a868SElliott Hughes \or \unnumberedseczzz{#3}% 6109*d5c9a868SElliott Hughes \or \unnumberedsubseczzz{#3}% 6110*d5c9a868SElliott Hughes \or \unnumberedsubsubseczzz{#3}% 6111*d5c9a868SElliott Hughes \fi 6112*d5c9a868SElliott Hughes \else 6113*d5c9a868SElliott Hughes \if \headtype A% 6114*d5c9a868SElliott Hughes \ifcase\absseclevel 6115*d5c9a868SElliott Hughes \appendixzzz{#3}% 6116*d5c9a868SElliott Hughes \or \appendixsectionzzz{#3}% 6117*d5c9a868SElliott Hughes \or \appendixsubseczzz{#3}% 6118*d5c9a868SElliott Hughes \or \appendixsubsubseczzz{#3}% 6119*d5c9a868SElliott Hughes \fi 6120*d5c9a868SElliott Hughes \else 6121*d5c9a868SElliott Hughes \ifcase\absseclevel 6122*d5c9a868SElliott Hughes \chapterzzz{#3}% 6123*d5c9a868SElliott Hughes \or \seczzz{#3}% 6124*d5c9a868SElliott Hughes \or \numberedsubseczzz{#3}% 6125*d5c9a868SElliott Hughes \or \numberedsubsubseczzz{#3}% 6126*d5c9a868SElliott Hughes \fi 6127*d5c9a868SElliott Hughes \fi 6128*d5c9a868SElliott Hughes \fi 6129*d5c9a868SElliott Hughes \suppressfirstparagraphindent 6130*d5c9a868SElliott Hughes} 6131*d5c9a868SElliott Hughes 6132*d5c9a868SElliott Hughes% an interface: 6133*d5c9a868SElliott Hughes\def\numhead{\genhead N} 6134*d5c9a868SElliott Hughes\def\apphead{\genhead A} 6135*d5c9a868SElliott Hughes\def\unnmhead{\genhead U} 6136*d5c9a868SElliott Hughes 6137*d5c9a868SElliott Hughes% @chapter, @appendix, @unnumbered. Increment top-level counter, reset 6138*d5c9a868SElliott Hughes% all lower-level sectioning counters to zero. 6139*d5c9a868SElliott Hughes% 6140*d5c9a868SElliott Hughes% Also set \chaplevelprefix, which we prepend to @float sequence numbers 6141*d5c9a868SElliott Hughes% (e.g., figures), q.v. By default (before any chapter), that is empty. 6142*d5c9a868SElliott Hughes\let\chaplevelprefix = \empty 6143*d5c9a868SElliott Hughes% 6144*d5c9a868SElliott Hughes\outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz 6145*d5c9a868SElliott Hughes\def\chapterzzz#1{% 6146*d5c9a868SElliott Hughes % section resetting is \global in case the chapter is in a group, such 6147*d5c9a868SElliott Hughes % as an @include file. 6148*d5c9a868SElliott Hughes \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 6149*d5c9a868SElliott Hughes \global\advance\chapno by 1 6150*d5c9a868SElliott Hughes % 6151*d5c9a868SElliott Hughes % Used for \float. 6152*d5c9a868SElliott Hughes \gdef\chaplevelprefix{\the\chapno.}% 6153*d5c9a868SElliott Hughes \resetallfloatnos 6154*d5c9a868SElliott Hughes % 6155*d5c9a868SElliott Hughes % \putwordChapter can contain complex things in translations. 6156*d5c9a868SElliott Hughes \toks0=\expandafter{\putwordChapter}% 6157*d5c9a868SElliott Hughes \message{\the\toks0 \space \the\chapno}% 6158*d5c9a868SElliott Hughes % 6159*d5c9a868SElliott Hughes % Write the actual heading. 6160*d5c9a868SElliott Hughes \chapmacro{#1}{Ynumbered}{\the\chapno}% 6161*d5c9a868SElliott Hughes % 6162*d5c9a868SElliott Hughes % So @section and the like are numbered underneath this chapter. 6163*d5c9a868SElliott Hughes \global\let\section = \numberedsec 6164*d5c9a868SElliott Hughes \global\let\subsection = \numberedsubsec 6165*d5c9a868SElliott Hughes \global\let\subsubsection = \numberedsubsubsec 6166*d5c9a868SElliott Hughes} 6167*d5c9a868SElliott Hughes 6168*d5c9a868SElliott Hughes\outer\parseargdef\appendix{\apphead0{#1}} % normally calls appendixzzz 6169*d5c9a868SElliott Hughes% 6170*d5c9a868SElliott Hughes\def\appendixzzz#1{% 6171*d5c9a868SElliott Hughes \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 6172*d5c9a868SElliott Hughes \global\advance\appendixno by 1 6173*d5c9a868SElliott Hughes \gdef\chaplevelprefix{\appendixletter.}% 6174*d5c9a868SElliott Hughes \resetallfloatnos 6175*d5c9a868SElliott Hughes % 6176*d5c9a868SElliott Hughes % \putwordAppendix can contain complex things in translations. 6177*d5c9a868SElliott Hughes \toks0=\expandafter{\putwordAppendix}% 6178*d5c9a868SElliott Hughes \message{\the\toks0 \space \appendixletter}% 6179*d5c9a868SElliott Hughes % 6180*d5c9a868SElliott Hughes \chapmacro{#1}{Yappendix}{\appendixletter}% 6181*d5c9a868SElliott Hughes % 6182*d5c9a868SElliott Hughes \global\let\section = \appendixsec 6183*d5c9a868SElliott Hughes \global\let\subsection = \appendixsubsec 6184*d5c9a868SElliott Hughes \global\let\subsubsection = \appendixsubsubsec 6185*d5c9a868SElliott Hughes} 6186*d5c9a868SElliott Hughes 6187*d5c9a868SElliott Hughes% normally unnmhead0 calls unnumberedzzz: 6188*d5c9a868SElliott Hughes\outer\parseargdef\unnumbered{\unnmhead0{#1}} 6189*d5c9a868SElliott Hughes\def\unnumberedzzz#1{% 6190*d5c9a868SElliott Hughes \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 6191*d5c9a868SElliott Hughes \global\advance\unnumberedno by 1 6192*d5c9a868SElliott Hughes % 6193*d5c9a868SElliott Hughes % Since an unnumbered has no number, no prefix for figures. 6194*d5c9a868SElliott Hughes \global\let\chaplevelprefix = \empty 6195*d5c9a868SElliott Hughes \resetallfloatnos 6196*d5c9a868SElliott Hughes % 6197*d5c9a868SElliott Hughes % This used to be simply \message{#1}, but TeX fully expands the 6198*d5c9a868SElliott Hughes % argument to \message. Therefore, if #1 contained @-commands, TeX 6199*d5c9a868SElliott Hughes % expanded them. For example, in `@unnumbered The @cite{Book}', TeX 6200*d5c9a868SElliott Hughes % expanded @cite (which turns out to cause errors because \cite is meant 6201*d5c9a868SElliott Hughes % to be executed, not expanded). 6202*d5c9a868SElliott Hughes % 6203*d5c9a868SElliott Hughes % Anyway, we don't want the fully-expanded definition of @cite to appear 6204*d5c9a868SElliott Hughes % as a result of the \message, we just want `@cite' itself. We use 6205*d5c9a868SElliott Hughes % \the<toks register> to achieve this: TeX expands \the<toks> only once, 6206*d5c9a868SElliott Hughes % simply yielding the contents of <toks register>. (We also do this for 6207*d5c9a868SElliott Hughes % the toc entries.) 6208*d5c9a868SElliott Hughes \toks0 = {#1}% 6209*d5c9a868SElliott Hughes \message{(\the\toks0)}% 6210*d5c9a868SElliott Hughes % 6211*d5c9a868SElliott Hughes \chapmacro{#1}{Ynothing}{\the\unnumberedno}% 6212*d5c9a868SElliott Hughes % 6213*d5c9a868SElliott Hughes \global\let\section = \unnumberedsec 6214*d5c9a868SElliott Hughes \global\let\subsection = \unnumberedsubsec 6215*d5c9a868SElliott Hughes \global\let\subsubsection = \unnumberedsubsubsec 6216*d5c9a868SElliott Hughes} 6217*d5c9a868SElliott Hughes 6218*d5c9a868SElliott Hughes% @centerchap is like @unnumbered, but the heading is centered. 6219*d5c9a868SElliott Hughes\outer\parseargdef\centerchap{% 6220*d5c9a868SElliott Hughes \let\centerparametersmaybe = \centerparameters 6221*d5c9a868SElliott Hughes \unnmhead0{#1}% 6222*d5c9a868SElliott Hughes \let\centerparametersmaybe = \relax 6223*d5c9a868SElliott Hughes} 6224*d5c9a868SElliott Hughes 6225*d5c9a868SElliott Hughes% @top is like @unnumbered. 6226*d5c9a868SElliott Hughes\let\top\unnumbered 6227*d5c9a868SElliott Hughes 6228*d5c9a868SElliott Hughes% Sections. 6229*d5c9a868SElliott Hughes% 6230*d5c9a868SElliott Hughes\outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz 6231*d5c9a868SElliott Hughes\def\seczzz#1{% 6232*d5c9a868SElliott Hughes \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 6233*d5c9a868SElliott Hughes \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}% 6234*d5c9a868SElliott Hughes} 6235*d5c9a868SElliott Hughes 6236*d5c9a868SElliott Hughes% normally calls appendixsectionzzz: 6237*d5c9a868SElliott Hughes\outer\parseargdef\appendixsection{\apphead1{#1}} 6238*d5c9a868SElliott Hughes\def\appendixsectionzzz#1{% 6239*d5c9a868SElliott Hughes \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 6240*d5c9a868SElliott Hughes \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}% 6241*d5c9a868SElliott Hughes} 6242*d5c9a868SElliott Hughes\let\appendixsec\appendixsection 6243*d5c9a868SElliott Hughes 6244*d5c9a868SElliott Hughes% normally calls unnumberedseczzz: 6245*d5c9a868SElliott Hughes\outer\parseargdef\unnumberedsec{\unnmhead1{#1}} 6246*d5c9a868SElliott Hughes\def\unnumberedseczzz#1{% 6247*d5c9a868SElliott Hughes \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 6248*d5c9a868SElliott Hughes \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}% 6249*d5c9a868SElliott Hughes} 6250*d5c9a868SElliott Hughes 6251*d5c9a868SElliott Hughes% Subsections. 6252*d5c9a868SElliott Hughes% 6253*d5c9a868SElliott Hughes% normally calls numberedsubseczzz: 6254*d5c9a868SElliott Hughes\outer\parseargdef\numberedsubsec{\numhead2{#1}} 6255*d5c9a868SElliott Hughes\def\numberedsubseczzz#1{% 6256*d5c9a868SElliott Hughes \global\subsubsecno=0 \global\advance\subsecno by 1 6257*d5c9a868SElliott Hughes \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}% 6258*d5c9a868SElliott Hughes} 6259*d5c9a868SElliott Hughes 6260*d5c9a868SElliott Hughes% normally calls appendixsubseczzz: 6261*d5c9a868SElliott Hughes\outer\parseargdef\appendixsubsec{\apphead2{#1}} 6262*d5c9a868SElliott Hughes\def\appendixsubseczzz#1{% 6263*d5c9a868SElliott Hughes \global\subsubsecno=0 \global\advance\subsecno by 1 6264*d5c9a868SElliott Hughes \sectionheading{#1}{subsec}{Yappendix}% 6265*d5c9a868SElliott Hughes {\appendixletter.\the\secno.\the\subsecno}% 6266*d5c9a868SElliott Hughes} 6267*d5c9a868SElliott Hughes 6268*d5c9a868SElliott Hughes% normally calls unnumberedsubseczzz: 6269*d5c9a868SElliott Hughes\outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}} 6270*d5c9a868SElliott Hughes\def\unnumberedsubseczzz#1{% 6271*d5c9a868SElliott Hughes \global\subsubsecno=0 \global\advance\subsecno by 1 6272*d5c9a868SElliott Hughes \sectionheading{#1}{subsec}{Ynothing}% 6273*d5c9a868SElliott Hughes {\the\unnumberedno.\the\secno.\the\subsecno}% 6274*d5c9a868SElliott Hughes} 6275*d5c9a868SElliott Hughes 6276*d5c9a868SElliott Hughes% Subsubsections. 6277*d5c9a868SElliott Hughes% 6278*d5c9a868SElliott Hughes% normally numberedsubsubseczzz: 6279*d5c9a868SElliott Hughes\outer\parseargdef\numberedsubsubsec{\numhead3{#1}} 6280*d5c9a868SElliott Hughes\def\numberedsubsubseczzz#1{% 6281*d5c9a868SElliott Hughes \global\advance\subsubsecno by 1 6282*d5c9a868SElliott Hughes \sectionheading{#1}{subsubsec}{Ynumbered}% 6283*d5c9a868SElliott Hughes {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}% 6284*d5c9a868SElliott Hughes} 6285*d5c9a868SElliott Hughes 6286*d5c9a868SElliott Hughes% normally appendixsubsubseczzz: 6287*d5c9a868SElliott Hughes\outer\parseargdef\appendixsubsubsec{\apphead3{#1}} 6288*d5c9a868SElliott Hughes\def\appendixsubsubseczzz#1{% 6289*d5c9a868SElliott Hughes \global\advance\subsubsecno by 1 6290*d5c9a868SElliott Hughes \sectionheading{#1}{subsubsec}{Yappendix}% 6291*d5c9a868SElliott Hughes {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}% 6292*d5c9a868SElliott Hughes} 6293*d5c9a868SElliott Hughes 6294*d5c9a868SElliott Hughes% normally unnumberedsubsubseczzz: 6295*d5c9a868SElliott Hughes\outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}} 6296*d5c9a868SElliott Hughes\def\unnumberedsubsubseczzz#1{% 6297*d5c9a868SElliott Hughes \global\advance\subsubsecno by 1 6298*d5c9a868SElliott Hughes \sectionheading{#1}{subsubsec}{Ynothing}% 6299*d5c9a868SElliott Hughes {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}% 6300*d5c9a868SElliott Hughes} 6301*d5c9a868SElliott Hughes 6302*d5c9a868SElliott Hughes% These macros control what the section commands do, according 6303*d5c9a868SElliott Hughes% to what kind of chapter we are in (ordinary, appendix, or unnumbered). 6304*d5c9a868SElliott Hughes% Define them by default for a numbered chapter. 6305*d5c9a868SElliott Hughes\let\section = \numberedsec 6306*d5c9a868SElliott Hughes\let\subsection = \numberedsubsec 6307*d5c9a868SElliott Hughes\let\subsubsection = \numberedsubsubsec 6308*d5c9a868SElliott Hughes 6309*d5c9a868SElliott Hughes% Define @majorheading, @heading and @subheading 6310*d5c9a868SElliott Hughes 6311*d5c9a868SElliott Hughes\def\majorheading{% 6312*d5c9a868SElliott Hughes {\advance\chapheadingskip by 10pt \chapbreak }% 6313*d5c9a868SElliott Hughes \parsearg\chapheadingzzz 6314*d5c9a868SElliott Hughes} 6315*d5c9a868SElliott Hughes 6316*d5c9a868SElliott Hughes\def\chapheading{\chapbreak \parsearg\chapheadingzzz} 6317*d5c9a868SElliott Hughes\def\chapheadingzzz#1{% 6318*d5c9a868SElliott Hughes \vbox{\chapfonts \raggedtitlesettings #1\par}% 6319*d5c9a868SElliott Hughes \nobreak\bigskip \nobreak 6320*d5c9a868SElliott Hughes \suppressfirstparagraphindent 6321*d5c9a868SElliott Hughes} 6322*d5c9a868SElliott Hughes 6323*d5c9a868SElliott Hughes% @heading, @subheading, @subsubheading. 6324*d5c9a868SElliott Hughes\parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{} 6325*d5c9a868SElliott Hughes \suppressfirstparagraphindent} 6326*d5c9a868SElliott Hughes\parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{} 6327*d5c9a868SElliott Hughes \suppressfirstparagraphindent} 6328*d5c9a868SElliott Hughes\parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{} 6329*d5c9a868SElliott Hughes \suppressfirstparagraphindent} 6330*d5c9a868SElliott Hughes 6331*d5c9a868SElliott Hughes% These macros generate a chapter, section, etc. heading only 6332*d5c9a868SElliott Hughes% (including whitespace, linebreaking, etc. around it), 6333*d5c9a868SElliott Hughes% given all the information in convenient, parsed form. 6334*d5c9a868SElliott Hughes 6335*d5c9a868SElliott Hughes% Args are the skip and penalty (usually negative) 6336*d5c9a868SElliott Hughes\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi} 6337*d5c9a868SElliott Hughes 6338*d5c9a868SElliott Hughes% Parameter controlling skip before chapter headings (if needed) 6339*d5c9a868SElliott Hughes\newskip\chapheadingskip 6340*d5c9a868SElliott Hughes 6341*d5c9a868SElliott Hughes% Define plain chapter starts, and page on/off switching for it. 6342*d5c9a868SElliott Hughes\def\chapbreak{\dobreak \chapheadingskip {-4000}} 6343*d5c9a868SElliott Hughes 6344*d5c9a868SElliott Hughes% Start a new page 6345*d5c9a868SElliott Hughes\def\chappager{\par\vfill\supereject} 6346*d5c9a868SElliott Hughes 6347*d5c9a868SElliott Hughes% \chapoddpage - start on an odd page for a new chapter 6348*d5c9a868SElliott Hughes% Because \domark is called before \chapoddpage, the filler page will 6349*d5c9a868SElliott Hughes% get the headings for the next chapter, which is wrong. But we don't 6350*d5c9a868SElliott Hughes% care -- we just disable all headings on the filler page. 6351*d5c9a868SElliott Hughes\def\chapoddpage{% 6352*d5c9a868SElliott Hughes \chappager 6353*d5c9a868SElliott Hughes \ifodd\pageno \else 6354*d5c9a868SElliott Hughes \begingroup 6355*d5c9a868SElliott Hughes \headingsoff 6356*d5c9a868SElliott Hughes \null 6357*d5c9a868SElliott Hughes \chappager 6358*d5c9a868SElliott Hughes \endgroup 6359*d5c9a868SElliott Hughes \fi 6360*d5c9a868SElliott Hughes} 6361*d5c9a868SElliott Hughes 6362*d5c9a868SElliott Hughes\parseargdef\setchapternewpage{\csname CHAPPAG#1\endcsname} 6363*d5c9a868SElliott Hughes 6364*d5c9a868SElliott Hughes\def\CHAPPAGoff{% 6365*d5c9a868SElliott Hughes\global\let\contentsalignmacro = \chappager 6366*d5c9a868SElliott Hughes\global\let\pchapsepmacro=\chapbreak 6367*d5c9a868SElliott Hughes\global\def\HEADINGSon{\HEADINGSsinglechapoff}} 6368*d5c9a868SElliott Hughes 6369*d5c9a868SElliott Hughes\def\CHAPPAGon{% 6370*d5c9a868SElliott Hughes\global\let\contentsalignmacro = \chappager 6371*d5c9a868SElliott Hughes\global\let\pchapsepmacro=\chappager 6372*d5c9a868SElliott Hughes\global\def\HEADINGSon{\HEADINGSsingle}} 6373*d5c9a868SElliott Hughes 6374*d5c9a868SElliott Hughes\def\CHAPPAGodd{% 6375*d5c9a868SElliott Hughes\global\let\contentsalignmacro = \chapoddpage 6376*d5c9a868SElliott Hughes\global\let\pchapsepmacro=\chapoddpage 6377*d5c9a868SElliott Hughes\global\def\HEADINGSon{\HEADINGSdouble}} 6378*d5c9a868SElliott Hughes 6379*d5c9a868SElliott Hughes\CHAPPAGon 6380*d5c9a868SElliott Hughes 6381*d5c9a868SElliott Hughes% \chapmacro - Chapter opening. 6382*d5c9a868SElliott Hughes% 6383*d5c9a868SElliott Hughes% #1 is the text, #2 is the section type (Ynumbered, Ynothing, 6384*d5c9a868SElliott Hughes% Yappendix, Yomitfromtoc), #3 the chapter number. 6385*d5c9a868SElliott Hughes% Not used for @heading series. 6386*d5c9a868SElliott Hughes% 6387*d5c9a868SElliott Hughes% To test against our argument. 6388*d5c9a868SElliott Hughes\def\Ynothingkeyword{Ynothing} 6389*d5c9a868SElliott Hughes\def\Yappendixkeyword{Yappendix} 6390*d5c9a868SElliott Hughes\def\Yomitfromtockeyword{Yomitfromtoc} 6391*d5c9a868SElliott Hughes% 6392*d5c9a868SElliott Hughes\def\chapmacro#1#2#3{% 6393*d5c9a868SElliott Hughes \expandafter\ifx\thisenv\titlepage\else 6394*d5c9a868SElliott Hughes \checkenv{}% chapters, etc., should not start inside an environment. 6395*d5c9a868SElliott Hughes \fi 6396*d5c9a868SElliott Hughes % Insert the first mark before the heading break (see notes for \domark). 6397*d5c9a868SElliott Hughes \let\prevchapterdefs=\currentchapterdefs 6398*d5c9a868SElliott Hughes \let\prevsectiondefs=\currentsectiondefs 6399*d5c9a868SElliott Hughes \gdef\currentsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}% 6400*d5c9a868SElliott Hughes \gdef\thissection{}}% 6401*d5c9a868SElliott Hughes % 6402*d5c9a868SElliott Hughes \def\temptype{#2}% 6403*d5c9a868SElliott Hughes \ifx\temptype\Ynothingkeyword 6404*d5c9a868SElliott Hughes \gdef\currentchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}% 6405*d5c9a868SElliott Hughes \gdef\thischapter{\thischaptername}}% 6406*d5c9a868SElliott Hughes \else\ifx\temptype\Yomitfromtockeyword 6407*d5c9a868SElliott Hughes \gdef\currentchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}% 6408*d5c9a868SElliott Hughes \gdef\thischapter{}}% 6409*d5c9a868SElliott Hughes \else\ifx\temptype\Yappendixkeyword 6410*d5c9a868SElliott Hughes \toks0={#1}% 6411*d5c9a868SElliott Hughes \xdef\currentchapterdefs{% 6412*d5c9a868SElliott Hughes \gdef\noexpand\thischaptername{\the\toks0}% 6413*d5c9a868SElliott Hughes \gdef\noexpand\thischapternum{\appendixletter}% 6414*d5c9a868SElliott Hughes % \noexpand\putwordAppendix avoids expanding indigestible 6415*d5c9a868SElliott Hughes % commands in some of the translations. 6416*d5c9a868SElliott Hughes \gdef\noexpand\thischapter{\noexpand\putwordAppendix{} 6417*d5c9a868SElliott Hughes \noexpand\thischapternum: 6418*d5c9a868SElliott Hughes \noexpand\thischaptername}% 6419*d5c9a868SElliott Hughes }% 6420*d5c9a868SElliott Hughes \else 6421*d5c9a868SElliott Hughes \toks0={#1}% 6422*d5c9a868SElliott Hughes \xdef\currentchapterdefs{% 6423*d5c9a868SElliott Hughes \gdef\noexpand\thischaptername{\the\toks0}% 6424*d5c9a868SElliott Hughes \gdef\noexpand\thischapternum{\the\chapno}% 6425*d5c9a868SElliott Hughes % \noexpand\putwordChapter avoids expanding indigestible 6426*d5c9a868SElliott Hughes % commands in some of the translations. 6427*d5c9a868SElliott Hughes \gdef\noexpand\thischapter{\noexpand\putwordChapter{} 6428*d5c9a868SElliott Hughes \noexpand\thischapternum: 6429*d5c9a868SElliott Hughes \noexpand\thischaptername}% 6430*d5c9a868SElliott Hughes }% 6431*d5c9a868SElliott Hughes \fi\fi\fi 6432*d5c9a868SElliott Hughes % 6433*d5c9a868SElliott Hughes % Output the mark. Pass it through \safewhatsit, to take care of 6434*d5c9a868SElliott Hughes % the preceding space. 6435*d5c9a868SElliott Hughes \safewhatsit\domark 6436*d5c9a868SElliott Hughes % 6437*d5c9a868SElliott Hughes % Insert the chapter heading break. 6438*d5c9a868SElliott Hughes \pchapsepmacro 6439*d5c9a868SElliott Hughes % 6440*d5c9a868SElliott Hughes % Now the second mark, after the heading break. No break points 6441*d5c9a868SElliott Hughes % between here and the heading. 6442*d5c9a868SElliott Hughes \let\prevchapterdefs=\currentchapterdefs 6443*d5c9a868SElliott Hughes \let\prevsectiondefs=\currentsectiondefs 6444*d5c9a868SElliott Hughes \domark 6445*d5c9a868SElliott Hughes % 6446*d5c9a868SElliott Hughes {% 6447*d5c9a868SElliott Hughes \chapfonts \rm 6448*d5c9a868SElliott Hughes \let\footnote=\errfootnoteheading % give better error message 6449*d5c9a868SElliott Hughes % 6450*d5c9a868SElliott Hughes % Have to define \currentsection before calling \donoderef, because the 6451*d5c9a868SElliott Hughes % xref code eventually uses it. On the other hand, it has to be called 6452*d5c9a868SElliott Hughes % after \pchapsepmacro, or the headline will change too soon. 6453*d5c9a868SElliott Hughes \gdef\currentsection{#1}% 6454*d5c9a868SElliott Hughes % 6455*d5c9a868SElliott Hughes % Only insert the separating space if we have a chapter/appendix 6456*d5c9a868SElliott Hughes % number, and don't print the unnumbered ``number''. 6457*d5c9a868SElliott Hughes \ifx\temptype\Ynothingkeyword 6458*d5c9a868SElliott Hughes \setbox0 = \hbox{}% 6459*d5c9a868SElliott Hughes \def\toctype{unnchap}% 6460*d5c9a868SElliott Hughes \else\ifx\temptype\Yomitfromtockeyword 6461*d5c9a868SElliott Hughes \setbox0 = \hbox{}% contents like unnumbered, but no toc entry 6462*d5c9a868SElliott Hughes \def\toctype{omit}% 6463*d5c9a868SElliott Hughes \else\ifx\temptype\Yappendixkeyword 6464*d5c9a868SElliott Hughes \setbox0 = \hbox{\putwordAppendix{} #3\enspace}% 6465*d5c9a868SElliott Hughes \def\toctype{app}% 6466*d5c9a868SElliott Hughes \else 6467*d5c9a868SElliott Hughes \setbox0 = \hbox{#3\enspace}% 6468*d5c9a868SElliott Hughes \def\toctype{numchap}% 6469*d5c9a868SElliott Hughes \fi\fi\fi 6470*d5c9a868SElliott Hughes % 6471*d5c9a868SElliott Hughes % Write the toc entry for this chapter. Must come before the 6472*d5c9a868SElliott Hughes % \donoderef, because we include the current node name in the toc 6473*d5c9a868SElliott Hughes % entry, and \donoderef resets it to empty. 6474*d5c9a868SElliott Hughes \writetocentry{\toctype}{#1}{#3}% 6475*d5c9a868SElliott Hughes % 6476*d5c9a868SElliott Hughes % For pdftex, we have to write out the node definition (aka, make 6477*d5c9a868SElliott Hughes % the pdfdest) after any page break, but before the actual text has 6478*d5c9a868SElliott Hughes % been typeset. If the destination for the pdf outline is after the 6479*d5c9a868SElliott Hughes % text, then jumping from the outline may wind up with the text not 6480*d5c9a868SElliott Hughes % being visible, for instance under high magnification. 6481*d5c9a868SElliott Hughes \donoderef{#2}% 6482*d5c9a868SElliott Hughes % 6483*d5c9a868SElliott Hughes % Typeset the actual heading. 6484*d5c9a868SElliott Hughes \nobreak % Avoid page breaks at the interline glue. 6485*d5c9a868SElliott Hughes \vbox{\raggedtitlesettings \hangindent=\wd0 \centerparametersmaybe 6486*d5c9a868SElliott Hughes \unhbox0 #1\par}% 6487*d5c9a868SElliott Hughes }% 6488*d5c9a868SElliott Hughes \nobreak\bigskip % no page break after a chapter title 6489*d5c9a868SElliott Hughes \nobreak 6490*d5c9a868SElliott Hughes} 6491*d5c9a868SElliott Hughes 6492*d5c9a868SElliott Hughes% @centerchap -- centered and unnumbered. 6493*d5c9a868SElliott Hughes\let\centerparametersmaybe = \relax 6494*d5c9a868SElliott Hughes\def\centerparameters{% 6495*d5c9a868SElliott Hughes \advance\rightskip by 3\rightskip 6496*d5c9a868SElliott Hughes \leftskip = \rightskip 6497*d5c9a868SElliott Hughes \parfillskip = 0pt 6498*d5c9a868SElliott Hughes} 6499*d5c9a868SElliott Hughes 6500*d5c9a868SElliott Hughes 6501*d5c9a868SElliott Hughes% Section titles. These macros combine the section number parts and 6502*d5c9a868SElliott Hughes% call the generic \sectionheading to do the printing. 6503*d5c9a868SElliott Hughes% 6504*d5c9a868SElliott Hughes\newskip\secheadingskip 6505*d5c9a868SElliott Hughes\def\secheadingbreak{\dobreak \secheadingskip{-1000}} 6506*d5c9a868SElliott Hughes 6507*d5c9a868SElliott Hughes% Subsection titles. 6508*d5c9a868SElliott Hughes\newskip\subsecheadingskip 6509*d5c9a868SElliott Hughes\def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}} 6510*d5c9a868SElliott Hughes 6511*d5c9a868SElliott Hughes% Subsubsection titles. 6512*d5c9a868SElliott Hughes\def\subsubsecheadingskip{\subsecheadingskip} 6513*d5c9a868SElliott Hughes\def\subsubsecheadingbreak{\subsecheadingbreak} 6514*d5c9a868SElliott Hughes 6515*d5c9a868SElliott Hughes 6516*d5c9a868SElliott Hughes% Print any size, any type, section title. 6517*d5c9a868SElliott Hughes% 6518*d5c9a868SElliott Hughes% #1 is the text of the title, 6519*d5c9a868SElliott Hughes% #2 is the section level (sec/subsec/subsubsec), 6520*d5c9a868SElliott Hughes% #3 is the section type (Ynumbered, Ynothing, Yappendix, Yomitfromtoc), 6521*d5c9a868SElliott Hughes% #4 is the section number. 6522*d5c9a868SElliott Hughes% 6523*d5c9a868SElliott Hughes\def\seckeyword{sec} 6524*d5c9a868SElliott Hughes% 6525*d5c9a868SElliott Hughes\def\sectionheading#1#2#3#4{% 6526*d5c9a868SElliott Hughes {% 6527*d5c9a868SElliott Hughes \def\sectionlevel{#2}% 6528*d5c9a868SElliott Hughes \def\temptype{#3}% 6529*d5c9a868SElliott Hughes % 6530*d5c9a868SElliott Hughes % It is ok for the @heading series commands to appear inside an 6531*d5c9a868SElliott Hughes % environment (it's been historically allowed, though the logic is 6532*d5c9a868SElliott Hughes % dubious), but not the others. 6533*d5c9a868SElliott Hughes \ifx\temptype\Yomitfromtockeyword\else 6534*d5c9a868SElliott Hughes \checkenv{}% non-@*heading should not be in an environment. 6535*d5c9a868SElliott Hughes \fi 6536*d5c9a868SElliott Hughes \let\footnote=\errfootnoteheading 6537*d5c9a868SElliott Hughes % 6538*d5c9a868SElliott Hughes % Switch to the right set of fonts. 6539*d5c9a868SElliott Hughes \csname #2fonts\endcsname \rm 6540*d5c9a868SElliott Hughes % 6541*d5c9a868SElliott Hughes % Insert first mark before the heading break (see notes for \domark). 6542*d5c9a868SElliott Hughes \let\prevsectiondefs=\currentsectiondefs 6543*d5c9a868SElliott Hughes \ifx\temptype\Ynothingkeyword 6544*d5c9a868SElliott Hughes \ifx\sectionlevel\seckeyword 6545*d5c9a868SElliott Hughes \gdef\currentsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}% 6546*d5c9a868SElliott Hughes \gdef\thissection{\thissectionname}}% 6547*d5c9a868SElliott Hughes \fi 6548*d5c9a868SElliott Hughes \else\ifx\temptype\Yomitfromtockeyword 6549*d5c9a868SElliott Hughes % Don't redefine \thissection. 6550*d5c9a868SElliott Hughes \else\ifx\temptype\Yappendixkeyword 6551*d5c9a868SElliott Hughes \ifx\sectionlevel\seckeyword 6552*d5c9a868SElliott Hughes \toks0={#1}% 6553*d5c9a868SElliott Hughes \xdef\currentsectiondefs{% 6554*d5c9a868SElliott Hughes \gdef\noexpand\thissectionname{\the\toks0}% 6555*d5c9a868SElliott Hughes \gdef\noexpand\thissectionnum{#4}% 6556*d5c9a868SElliott Hughes % \noexpand\putwordSection avoids expanding indigestible 6557*d5c9a868SElliott Hughes % commands in some of the translations. 6558*d5c9a868SElliott Hughes \gdef\noexpand\thissection{\noexpand\putwordSection{} 6559*d5c9a868SElliott Hughes \noexpand\thissectionnum: 6560*d5c9a868SElliott Hughes \noexpand\thissectionname}% 6561*d5c9a868SElliott Hughes }% 6562*d5c9a868SElliott Hughes \fi 6563*d5c9a868SElliott Hughes \else 6564*d5c9a868SElliott Hughes \ifx\sectionlevel\seckeyword 6565*d5c9a868SElliott Hughes \toks0={#1}% 6566*d5c9a868SElliott Hughes \xdef\currentsectiondefs{% 6567*d5c9a868SElliott Hughes \gdef\noexpand\thissectionname{\the\toks0}% 6568*d5c9a868SElliott Hughes \gdef\noexpand\thissectionnum{#4}% 6569*d5c9a868SElliott Hughes % \noexpand\putwordSection avoids expanding indigestible 6570*d5c9a868SElliott Hughes % commands in some of the translations. 6571*d5c9a868SElliott Hughes \gdef\noexpand\thissection{\noexpand\putwordSection{} 6572*d5c9a868SElliott Hughes \noexpand\thissectionnum: 6573*d5c9a868SElliott Hughes \noexpand\thissectionname}% 6574*d5c9a868SElliott Hughes }% 6575*d5c9a868SElliott Hughes \fi 6576*d5c9a868SElliott Hughes \fi\fi\fi 6577*d5c9a868SElliott Hughes % 6578*d5c9a868SElliott Hughes % Go into vertical mode. Usually we'll already be there, but we 6579*d5c9a868SElliott Hughes % don't want the following whatsit to end up in a preceding paragraph 6580*d5c9a868SElliott Hughes % if the document didn't happen to have a blank line. 6581*d5c9a868SElliott Hughes \par 6582*d5c9a868SElliott Hughes % 6583*d5c9a868SElliott Hughes % Output the mark. Pass it through \safewhatsit, to take care of 6584*d5c9a868SElliott Hughes % the preceding space. 6585*d5c9a868SElliott Hughes \safewhatsit\domark 6586*d5c9a868SElliott Hughes % 6587*d5c9a868SElliott Hughes % Insert space above the heading. 6588*d5c9a868SElliott Hughes \csname #2headingbreak\endcsname 6589*d5c9a868SElliott Hughes % 6590*d5c9a868SElliott Hughes % Now the second mark, after the heading break. No break points 6591*d5c9a868SElliott Hughes % between here and the heading. 6592*d5c9a868SElliott Hughes \global\let\prevsectiondefs=\currentsectiondefs 6593*d5c9a868SElliott Hughes \domark 6594*d5c9a868SElliott Hughes % 6595*d5c9a868SElliott Hughes % Only insert the space after the number if we have a section number. 6596*d5c9a868SElliott Hughes \ifx\temptype\Ynothingkeyword 6597*d5c9a868SElliott Hughes \setbox0 = \hbox{}% 6598*d5c9a868SElliott Hughes \def\toctype{unn}% 6599*d5c9a868SElliott Hughes \gdef\currentsection{#1}% 6600*d5c9a868SElliott Hughes \else\ifx\temptype\Yomitfromtockeyword 6601*d5c9a868SElliott Hughes % for @headings -- no section number, don't include in toc, 6602*d5c9a868SElliott Hughes % and don't redefine \currentsection. 6603*d5c9a868SElliott Hughes \setbox0 = \hbox{}% 6604*d5c9a868SElliott Hughes \def\toctype{omit}% 6605*d5c9a868SElliott Hughes \let\sectionlevel=\empty 6606*d5c9a868SElliott Hughes \else\ifx\temptype\Yappendixkeyword 6607*d5c9a868SElliott Hughes \setbox0 = \hbox{#4\enspace}% 6608*d5c9a868SElliott Hughes \def\toctype{app}% 6609*d5c9a868SElliott Hughes \gdef\currentsection{#1}% 6610*d5c9a868SElliott Hughes \else 6611*d5c9a868SElliott Hughes \setbox0 = \hbox{#4\enspace}% 6612*d5c9a868SElliott Hughes \def\toctype{num}% 6613*d5c9a868SElliott Hughes \gdef\currentsection{#1}% 6614*d5c9a868SElliott Hughes \fi\fi\fi 6615*d5c9a868SElliott Hughes % 6616*d5c9a868SElliott Hughes % Write the toc entry (before \donoderef). See comments in \chapmacro. 6617*d5c9a868SElliott Hughes \writetocentry{\toctype\sectionlevel}{#1}{#4}% 6618*d5c9a868SElliott Hughes % 6619*d5c9a868SElliott Hughes % Write the node reference (= pdf destination for pdftex). 6620*d5c9a868SElliott Hughes % Again, see comments in \chapmacro. 6621*d5c9a868SElliott Hughes \donoderef{#3}% 6622*d5c9a868SElliott Hughes % 6623*d5c9a868SElliott Hughes % Interline glue will be inserted when the vbox is completed. 6624*d5c9a868SElliott Hughes % That glue will be a valid breakpoint for the page, since it'll be 6625*d5c9a868SElliott Hughes % preceded by a whatsit (usually from the \donoderef, or from the 6626*d5c9a868SElliott Hughes % \writetocentry if there was no node). We don't want to allow that 6627*d5c9a868SElliott Hughes % break, since then the whatsits could end up on page n while the 6628*d5c9a868SElliott Hughes % section is on page n+1, thus toc/etc. are wrong. Debian bug 276000. 6629*d5c9a868SElliott Hughes \nobreak 6630*d5c9a868SElliott Hughes % 6631*d5c9a868SElliott Hughes % Output the actual section heading. 6632*d5c9a868SElliott Hughes \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright 6633*d5c9a868SElliott Hughes \hangindent=\wd0 % zero if no section number 6634*d5c9a868SElliott Hughes \unhbox0 #1}% 6635*d5c9a868SElliott Hughes }% 6636*d5c9a868SElliott Hughes % Add extra space after the heading -- half of whatever came above it. 6637*d5c9a868SElliott Hughes % Don't allow stretch, though. 6638*d5c9a868SElliott Hughes \kern .5 \csname #2headingskip\endcsname 6639*d5c9a868SElliott Hughes % 6640*d5c9a868SElliott Hughes % Do not let the kern be a potential breakpoint, as it would be if it 6641*d5c9a868SElliott Hughes % was followed by glue. 6642*d5c9a868SElliott Hughes \nobreak 6643*d5c9a868SElliott Hughes % 6644*d5c9a868SElliott Hughes % We'll almost certainly start a paragraph next, so don't let that 6645*d5c9a868SElliott Hughes % glue accumulate. (Not a breakpoint because it's preceded by a 6646*d5c9a868SElliott Hughes % discardable item.) However, when a paragraph is not started next 6647*d5c9a868SElliott Hughes % (\startdefun, \cartouche, \center, etc.), this needs to be wiped out 6648*d5c9a868SElliott Hughes % or the negative glue will cause weirdly wrong output, typically 6649*d5c9a868SElliott Hughes % obscuring the section heading with something else. 6650*d5c9a868SElliott Hughes \vskip-\parskip 6651*d5c9a868SElliott Hughes % 6652*d5c9a868SElliott Hughes % This is so the last item on the main vertical list is a known 6653*d5c9a868SElliott Hughes % \penalty > 10000, so \startdefun, etc., can recognize the situation 6654*d5c9a868SElliott Hughes % and do the needful. 6655*d5c9a868SElliott Hughes \penalty 10001 6656*d5c9a868SElliott Hughes} 6657*d5c9a868SElliott Hughes 6658*d5c9a868SElliott Hughes 6659*d5c9a868SElliott Hughes\message{toc,} 6660*d5c9a868SElliott Hughes% Table of contents. 6661*d5c9a868SElliott Hughes\newwrite\tocfile 6662*d5c9a868SElliott Hughes 6663*d5c9a868SElliott Hughes% Write an entry to the toc file, opening it if necessary. 6664*d5c9a868SElliott Hughes% Called from @chapter, etc. 6665*d5c9a868SElliott Hughes% 6666*d5c9a868SElliott Hughes% Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno} 6667*d5c9a868SElliott Hughes% We append the current node name (if any) and page number as additional 6668*d5c9a868SElliott Hughes% arguments for the \{chap,sec,...}entry macros which will eventually 6669*d5c9a868SElliott Hughes% read this. The node name is used in the pdf outlines as the 6670*d5c9a868SElliott Hughes% destination to jump to. 6671*d5c9a868SElliott Hughes% 6672*d5c9a868SElliott Hughes% We open the .toc file for writing here instead of at @setfilename (or 6673*d5c9a868SElliott Hughes% any other fixed time) so that @contents can be anywhere in the document. 6674*d5c9a868SElliott Hughes% But if #1 is `omit', then we don't do anything. This is used for the 6675*d5c9a868SElliott Hughes% table of contents chapter openings themselves. 6676*d5c9a868SElliott Hughes% 6677*d5c9a868SElliott Hughes\newif\iftocfileopened 6678*d5c9a868SElliott Hughes\def\omitkeyword{omit}% 6679*d5c9a868SElliott Hughes% 6680*d5c9a868SElliott Hughes\def\writetocentry#1#2#3{% 6681*d5c9a868SElliott Hughes \edef\writetoctype{#1}% 6682*d5c9a868SElliott Hughes \ifx\writetoctype\omitkeyword \else 6683*d5c9a868SElliott Hughes \iftocfileopened\else 6684*d5c9a868SElliott Hughes \immediate\openout\tocfile = \jobname.toc 6685*d5c9a868SElliott Hughes \global\tocfileopenedtrue 6686*d5c9a868SElliott Hughes \fi 6687*d5c9a868SElliott Hughes % 6688*d5c9a868SElliott Hughes \iflinks 6689*d5c9a868SElliott Hughes {\atdummies 6690*d5c9a868SElliott Hughes \edef\temp{% 6691*d5c9a868SElliott Hughes \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}% 6692*d5c9a868SElliott Hughes \temp 6693*d5c9a868SElliott Hughes }% 6694*d5c9a868SElliott Hughes \fi 6695*d5c9a868SElliott Hughes \fi 6696*d5c9a868SElliott Hughes % 6697*d5c9a868SElliott Hughes % Tell \shipout to create a pdf destination on each page, if we're 6698*d5c9a868SElliott Hughes % writing pdf. These are used in the table of contents. We can't 6699*d5c9a868SElliott Hughes % just write one on every page because the title pages are numbered 6700*d5c9a868SElliott Hughes % 1 and 2 (the page numbers aren't printed), and so are the first 6701*d5c9a868SElliott Hughes % two pages of the document. Thus, we'd have two destinations named 6702*d5c9a868SElliott Hughes % `1', and two named `2'. 6703*d5c9a868SElliott Hughes \ifpdforxetex 6704*d5c9a868SElliott Hughes \global\pdfmakepagedesttrue 6705*d5c9a868SElliott Hughes \fi 6706*d5c9a868SElliott Hughes} 6707*d5c9a868SElliott Hughes 6708*d5c9a868SElliott Hughes 6709*d5c9a868SElliott Hughes% These characters do not print properly in the Computer Modern roman 6710*d5c9a868SElliott Hughes% fonts, so we must take special care. This is more or less redundant 6711*d5c9a868SElliott Hughes% with the Texinfo input format setup at the end of this file. 6712*d5c9a868SElliott Hughes% 6713*d5c9a868SElliott Hughes\def\activecatcodes{% 6714*d5c9a868SElliott Hughes \catcode`\"=\active 6715*d5c9a868SElliott Hughes \catcode`\$=\active 6716*d5c9a868SElliott Hughes \catcode`\<=\active 6717*d5c9a868SElliott Hughes \catcode`\>=\active 6718*d5c9a868SElliott Hughes \catcode`\\=\active 6719*d5c9a868SElliott Hughes \catcode`\^=\active 6720*d5c9a868SElliott Hughes \catcode`\_=\active 6721*d5c9a868SElliott Hughes \catcode`\|=\active 6722*d5c9a868SElliott Hughes \catcode`\~=\active 6723*d5c9a868SElliott Hughes} 6724*d5c9a868SElliott Hughes 6725*d5c9a868SElliott Hughes 6726*d5c9a868SElliott Hughes% Read the toc file, which is essentially Texinfo input. 6727*d5c9a868SElliott Hughes\def\readtocfile{% 6728*d5c9a868SElliott Hughes \setupdatafile 6729*d5c9a868SElliott Hughes \activecatcodes 6730*d5c9a868SElliott Hughes \input \tocreadfilename 6731*d5c9a868SElliott Hughes} 6732*d5c9a868SElliott Hughes 6733*d5c9a868SElliott Hughes\newskip\contentsrightmargin \contentsrightmargin=1in 6734*d5c9a868SElliott Hughes\newcount\savepageno 6735*d5c9a868SElliott Hughes\newcount\lastnegativepageno \lastnegativepageno = -1 6736*d5c9a868SElliott Hughes 6737*d5c9a868SElliott Hughes% Prepare to read what we've written to \tocfile. 6738*d5c9a868SElliott Hughes% 6739*d5c9a868SElliott Hughes\def\startcontents#1{% 6740*d5c9a868SElliott Hughes % If @setchapternewpage on, and @headings double, the contents should 6741*d5c9a868SElliott Hughes % start on an odd page, unlike chapters. 6742*d5c9a868SElliott Hughes \contentsalignmacro 6743*d5c9a868SElliott Hughes \immediate\closeout\tocfile 6744*d5c9a868SElliott Hughes % 6745*d5c9a868SElliott Hughes % Don't need to put `Contents' or `Short Contents' in the headline. 6746*d5c9a868SElliott Hughes % It is abundantly clear what they are. 6747*d5c9a868SElliott Hughes \chapmacro{#1}{Yomitfromtoc}{}% 6748*d5c9a868SElliott Hughes % 6749*d5c9a868SElliott Hughes \savepageno = \pageno 6750*d5c9a868SElliott Hughes \begingroup % Set up to handle contents files properly. 6751*d5c9a868SElliott Hughes \raggedbottom % Worry more about breakpoints than the bottom. 6752*d5c9a868SElliott Hughes \entryrightmargin=\contentsrightmargin % Don't use the full line length. 6753*d5c9a868SElliott Hughes % 6754*d5c9a868SElliott Hughes % Roman numerals for page numbers. 6755*d5c9a868SElliott Hughes \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi 6756*d5c9a868SElliott Hughes \def\thistitle{}% no title in double-sided headings 6757*d5c9a868SElliott Hughes % Record where the Roman numerals started. 6758*d5c9a868SElliott Hughes \ifnum\romancount=0 \global\romancount=\pagecount \fi 6759*d5c9a868SElliott Hughes} 6760*d5c9a868SElliott Hughes 6761*d5c9a868SElliott Hughes% redefined for the two-volume lispref. We always output on 6762*d5c9a868SElliott Hughes% \jobname.toc even if this is redefined. 6763*d5c9a868SElliott Hughes% 6764*d5c9a868SElliott Hughes\def\tocreadfilename{\jobname.toc} 6765*d5c9a868SElliott Hughes 6766*d5c9a868SElliott Hughes% Normal (long) toc. 6767*d5c9a868SElliott Hughes% 6768*d5c9a868SElliott Hughes\def\contents{% 6769*d5c9a868SElliott Hughes \startcontents{\putwordTOC}% 6770*d5c9a868SElliott Hughes \openin 1 \tocreadfilename\space 6771*d5c9a868SElliott Hughes \ifeof 1 \else 6772*d5c9a868SElliott Hughes \readtocfile 6773*d5c9a868SElliott Hughes \fi 6774*d5c9a868SElliott Hughes \vfill \eject 6775*d5c9a868SElliott Hughes \contentsalignmacro % in case @setchapternewpage odd is in effect 6776*d5c9a868SElliott Hughes \ifeof 1 \else 6777*d5c9a868SElliott Hughes \pdfmakeoutlines 6778*d5c9a868SElliott Hughes \fi 6779*d5c9a868SElliott Hughes \closein 1 6780*d5c9a868SElliott Hughes \endgroup 6781*d5c9a868SElliott Hughes \contentsendroman 6782*d5c9a868SElliott Hughes} 6783*d5c9a868SElliott Hughes 6784*d5c9a868SElliott Hughes% And just the chapters. 6785*d5c9a868SElliott Hughes\def\summarycontents{% 6786*d5c9a868SElliott Hughes \startcontents{\putwordShortTOC}% 6787*d5c9a868SElliott Hughes % 6788*d5c9a868SElliott Hughes \let\partentry = \shortpartentry 6789*d5c9a868SElliott Hughes \let\numchapentry = \shortchapentry 6790*d5c9a868SElliott Hughes \let\appentry = \shortchapentry 6791*d5c9a868SElliott Hughes \let\unnchapentry = \shortunnchapentry 6792*d5c9a868SElliott Hughes % We want a true roman here for the page numbers. 6793*d5c9a868SElliott Hughes \secfonts 6794*d5c9a868SElliott Hughes \let\rm=\shortcontrm \let\bf=\shortcontbf 6795*d5c9a868SElliott Hughes \let\sl=\shortcontsl \let\tt=\shortconttt 6796*d5c9a868SElliott Hughes \rm 6797*d5c9a868SElliott Hughes \hyphenpenalty = 10000 6798*d5c9a868SElliott Hughes \advance\baselineskip by 1pt % Open it up a little. 6799*d5c9a868SElliott Hughes \def\numsecentry##1##2##3##4{} 6800*d5c9a868SElliott Hughes \let\appsecentry = \numsecentry 6801*d5c9a868SElliott Hughes \let\unnsecentry = \numsecentry 6802*d5c9a868SElliott Hughes \let\numsubsecentry = \numsecentry 6803*d5c9a868SElliott Hughes \let\appsubsecentry = \numsecentry 6804*d5c9a868SElliott Hughes \let\unnsubsecentry = \numsecentry 6805*d5c9a868SElliott Hughes \let\numsubsubsecentry = \numsecentry 6806*d5c9a868SElliott Hughes \let\appsubsubsecentry = \numsecentry 6807*d5c9a868SElliott Hughes \let\unnsubsubsecentry = \numsecentry 6808*d5c9a868SElliott Hughes \openin 1 \tocreadfilename\space 6809*d5c9a868SElliott Hughes \ifeof 1 \else 6810*d5c9a868SElliott Hughes \readtocfile 6811*d5c9a868SElliott Hughes \fi 6812*d5c9a868SElliott Hughes \closein 1 6813*d5c9a868SElliott Hughes \vfill \eject 6814*d5c9a868SElliott Hughes \contentsalignmacro % in case @setchapternewpage odd is in effect 6815*d5c9a868SElliott Hughes \endgroup 6816*d5c9a868SElliott Hughes \contentsendroman 6817*d5c9a868SElliott Hughes} 6818*d5c9a868SElliott Hughes\let\shortcontents = \summarycontents 6819*d5c9a868SElliott Hughes 6820*d5c9a868SElliott Hughes% Get ready to use Arabic numerals again 6821*d5c9a868SElliott Hughes\def\contentsendroman{% 6822*d5c9a868SElliott Hughes \lastnegativepageno = \pageno 6823*d5c9a868SElliott Hughes \global\pageno = \savepageno 6824*d5c9a868SElliott Hughes % 6825*d5c9a868SElliott Hughes % If \romancount > \arabiccount, the contents are at the end of the 6826*d5c9a868SElliott Hughes % document. Otherwise, advance where the Arabic numerals start for 6827*d5c9a868SElliott Hughes % the page numbers. 6828*d5c9a868SElliott Hughes \ifnum\romancount>\arabiccount\else\global\arabiccount=\pagecount\fi 6829*d5c9a868SElliott Hughes} 6830*d5c9a868SElliott Hughes 6831*d5c9a868SElliott Hughes% Typeset the label for a chapter or appendix for the short contents. 6832*d5c9a868SElliott Hughes% The arg is, e.g., `A' for an appendix, or `3' for a chapter. 6833*d5c9a868SElliott Hughes% 6834*d5c9a868SElliott Hughes\def\shortchaplabel#1{% 6835*d5c9a868SElliott Hughes % This space should be enough, since a single number is .5em, and the 6836*d5c9a868SElliott Hughes % widest letter (M) is 1em, at least in the Computer Modern fonts. 6837*d5c9a868SElliott Hughes % But use \hss just in case. 6838*d5c9a868SElliott Hughes % (This space doesn't include the extra space that gets added after 6839*d5c9a868SElliott Hughes % the label; that gets put in by \shortchapentry above.) 6840*d5c9a868SElliott Hughes % 6841*d5c9a868SElliott Hughes % We'd like to right-justify chapter numbers, but that looks strange 6842*d5c9a868SElliott Hughes % with appendix letters. And right-justifying numbers and 6843*d5c9a868SElliott Hughes % left-justifying letters looks strange when there is less than 10 6844*d5c9a868SElliott Hughes % chapters. Have to read the whole toc once to know how many chapters 6845*d5c9a868SElliott Hughes % there are before deciding ... 6846*d5c9a868SElliott Hughes \hbox to 1em{#1\hss}% 6847*d5c9a868SElliott Hughes} 6848*d5c9a868SElliott Hughes 6849*d5c9a868SElliott Hughes% These macros generate individual entries in the table of contents. 6850*d5c9a868SElliott Hughes% The first argument is the chapter or section name. 6851*d5c9a868SElliott Hughes% The last argument is the page number. 6852*d5c9a868SElliott Hughes% The arguments in between are the chapter number, section number, ... 6853*d5c9a868SElliott Hughes 6854*d5c9a868SElliott Hughes% Parts, in the main contents. Replace the part number, which doesn't 6855*d5c9a868SElliott Hughes% exist, with an empty box. Let's hope all the numbers have the same width. 6856*d5c9a868SElliott Hughes% Also ignore the page number, which is conventionally not printed. 6857*d5c9a868SElliott Hughes\def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}} 6858*d5c9a868SElliott Hughes\def\partentry#1#2#3#4{% 6859*d5c9a868SElliott Hughes % Add stretch and a bonus for breaking the page before the part heading. 6860*d5c9a868SElliott Hughes % This reduces the chance of the page being broken immediately after the 6861*d5c9a868SElliott Hughes % part heading, before a following chapter heading. 6862*d5c9a868SElliott Hughes \vskip 0pt plus 5\baselineskip 6863*d5c9a868SElliott Hughes \penalty-300 6864*d5c9a868SElliott Hughes \vskip 0pt plus -5\baselineskip 6865*d5c9a868SElliott Hughes \dochapentry{\numeralbox\labelspace#1}{}% 6866*d5c9a868SElliott Hughes} 6867*d5c9a868SElliott Hughes% 6868*d5c9a868SElliott Hughes% Parts, in the short toc. 6869*d5c9a868SElliott Hughes\def\shortpartentry#1#2#3#4{% 6870*d5c9a868SElliott Hughes \penalty-300 6871*d5c9a868SElliott Hughes \vskip.5\baselineskip plus.15\baselineskip minus.1\baselineskip 6872*d5c9a868SElliott Hughes \shortchapentry{{\bf #1}}{\numeralbox}{}{}% 6873*d5c9a868SElliott Hughes} 6874*d5c9a868SElliott Hughes 6875*d5c9a868SElliott Hughes% Chapters, in the main contents. 6876*d5c9a868SElliott Hughes\def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}} 6877*d5c9a868SElliott Hughes 6878*d5c9a868SElliott Hughes% Chapters, in the short toc. 6879*d5c9a868SElliott Hughes% See comments in \dochapentry re vbox and related settings. 6880*d5c9a868SElliott Hughes\def\shortchapentry#1#2#3#4{% 6881*d5c9a868SElliott Hughes \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}% 6882*d5c9a868SElliott Hughes} 6883*d5c9a868SElliott Hughes 6884*d5c9a868SElliott Hughes% Appendices, in the main contents. 6885*d5c9a868SElliott Hughes% Need the word Appendix, and a fixed-size box. 6886*d5c9a868SElliott Hughes% 6887*d5c9a868SElliott Hughes\def\appendixbox#1{% 6888*d5c9a868SElliott Hughes % We use M since it's probably the widest letter. 6889*d5c9a868SElliott Hughes \setbox0 = \hbox{\putwordAppendix{} M}% 6890*d5c9a868SElliott Hughes \hbox to \wd0{\putwordAppendix{} #1\hss}} 6891*d5c9a868SElliott Hughes% 6892*d5c9a868SElliott Hughes\def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\hskip.7em#1}{#4}} 6893*d5c9a868SElliott Hughes 6894*d5c9a868SElliott Hughes% Unnumbered chapters. 6895*d5c9a868SElliott Hughes\def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}} 6896*d5c9a868SElliott Hughes\def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}} 6897*d5c9a868SElliott Hughes 6898*d5c9a868SElliott Hughes% Sections. 6899*d5c9a868SElliott Hughes\def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}} 6900*d5c9a868SElliott Hughes\let\appsecentry=\numsecentry 6901*d5c9a868SElliott Hughes\def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}} 6902*d5c9a868SElliott Hughes 6903*d5c9a868SElliott Hughes% Subsections. 6904*d5c9a868SElliott Hughes\def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}} 6905*d5c9a868SElliott Hughes\let\appsubsecentry=\numsubsecentry 6906*d5c9a868SElliott Hughes\def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}} 6907*d5c9a868SElliott Hughes 6908*d5c9a868SElliott Hughes% And subsubsections. 6909*d5c9a868SElliott Hughes\def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}} 6910*d5c9a868SElliott Hughes\let\appsubsubsecentry=\numsubsubsecentry 6911*d5c9a868SElliott Hughes\def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}} 6912*d5c9a868SElliott Hughes 6913*d5c9a868SElliott Hughes% This parameter controls the indentation of the various levels. 6914*d5c9a868SElliott Hughes% Same as \defaultparindent. 6915*d5c9a868SElliott Hughes\newdimen\tocindent \tocindent = 15pt 6916*d5c9a868SElliott Hughes 6917*d5c9a868SElliott Hughes% Now for the actual typesetting. In all these, #1 is the text and #2 is the 6918*d5c9a868SElliott Hughes% page number. 6919*d5c9a868SElliott Hughes% 6920*d5c9a868SElliott Hughes% If the toc has to be broken over pages, we want it to be at chapters 6921*d5c9a868SElliott Hughes% if at all possible; hence the \penalty. 6922*d5c9a868SElliott Hughes\def\dochapentry#1#2{% 6923*d5c9a868SElliott Hughes \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip 6924*d5c9a868SElliott Hughes \begingroup 6925*d5c9a868SElliott Hughes % Move the page numbers slightly to the right 6926*d5c9a868SElliott Hughes \advance\entryrightmargin by -0.05em 6927*d5c9a868SElliott Hughes \chapentryfonts 6928*d5c9a868SElliott Hughes \tocentry{#1}{\dopageno\bgroup#2\egroup}% 6929*d5c9a868SElliott Hughes \endgroup 6930*d5c9a868SElliott Hughes \nobreak\vskip .25\baselineskip plus.1\baselineskip 6931*d5c9a868SElliott Hughes} 6932*d5c9a868SElliott Hughes 6933*d5c9a868SElliott Hughes\def\dosecentry#1#2{\begingroup 6934*d5c9a868SElliott Hughes \secentryfonts \leftskip=\tocindent 6935*d5c9a868SElliott Hughes \tocentry{#1}{\dopageno\bgroup#2\egroup}% 6936*d5c9a868SElliott Hughes\endgroup} 6937*d5c9a868SElliott Hughes 6938*d5c9a868SElliott Hughes\def\dosubsecentry#1#2{\begingroup 6939*d5c9a868SElliott Hughes \subsecentryfonts \leftskip=2\tocindent 6940*d5c9a868SElliott Hughes \tocentry{#1}{\dopageno\bgroup#2\egroup}% 6941*d5c9a868SElliott Hughes\endgroup} 6942*d5c9a868SElliott Hughes 6943*d5c9a868SElliott Hughes\def\dosubsubsecentry#1#2{\begingroup 6944*d5c9a868SElliott Hughes \subsubsecentryfonts \leftskip=3\tocindent 6945*d5c9a868SElliott Hughes \tocentry{#1}{\dopageno\bgroup#2\egroup}% 6946*d5c9a868SElliott Hughes\endgroup} 6947*d5c9a868SElliott Hughes 6948*d5c9a868SElliott Hughes% We use the same \entry macro as for the index entries. 6949*d5c9a868SElliott Hughes\let\tocentry = \entry 6950*d5c9a868SElliott Hughes 6951*d5c9a868SElliott Hughes% Space between chapter (or whatever) number and the title. 6952*d5c9a868SElliott Hughes\def\labelspace{\hskip1em \relax} 6953*d5c9a868SElliott Hughes 6954*d5c9a868SElliott Hughes\def\dopageno#1{{\rm #1}} 6955*d5c9a868SElliott Hughes\def\doshortpageno#1{{\rm #1}} 6956*d5c9a868SElliott Hughes 6957*d5c9a868SElliott Hughes\def\chapentryfonts{\secfonts \rm} 6958*d5c9a868SElliott Hughes\def\secentryfonts{\textfonts} 6959*d5c9a868SElliott Hughes\def\subsecentryfonts{\textfonts} 6960*d5c9a868SElliott Hughes\def\subsubsecentryfonts{\textfonts} 6961*d5c9a868SElliott Hughes 6962*d5c9a868SElliott Hughes 6963*d5c9a868SElliott Hughes\message{environments,} 6964*d5c9a868SElliott Hughes% @foo ... @end foo. 6965*d5c9a868SElliott Hughes 6966*d5c9a868SElliott Hughes% @tex ... @end tex escapes into raw TeX temporarily. 6967*d5c9a868SElliott Hughes% One exception: @ is still an escape character, so that @end tex works. 6968*d5c9a868SElliott Hughes% But \@ or @@ will get a plain @ character. 6969*d5c9a868SElliott Hughes 6970*d5c9a868SElliott Hughes\envdef\tex{% 6971*d5c9a868SElliott Hughes \setregularquotes 6972*d5c9a868SElliott Hughes \catcode `\\=0 \catcode `\{=1 \catcode `\}=2 6973*d5c9a868SElliott Hughes \catcode `\$=3 \catcode `\&=4 \catcode `\#=6 6974*d5c9a868SElliott Hughes \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie 6975*d5c9a868SElliott Hughes \catcode `\%=14 6976*d5c9a868SElliott Hughes \catcode `\+=\other 6977*d5c9a868SElliott Hughes \catcode `\"=\other 6978*d5c9a868SElliott Hughes \catcode `\|=\other 6979*d5c9a868SElliott Hughes \catcode `\<=\other 6980*d5c9a868SElliott Hughes \catcode `\>=\other 6981*d5c9a868SElliott Hughes \catcode `\`=\other 6982*d5c9a868SElliott Hughes \catcode `\'=\other 6983*d5c9a868SElliott Hughes % 6984*d5c9a868SElliott Hughes % ' is active in math mode (mathcode"8000). So reset it, and all our 6985*d5c9a868SElliott Hughes % other math active characters (just in case), to plain's definitions. 6986*d5c9a868SElliott Hughes \mathactive 6987*d5c9a868SElliott Hughes % 6988*d5c9a868SElliott Hughes % Inverse of the list at the beginning of the file. 6989*d5c9a868SElliott Hughes \let\b=\ptexb 6990*d5c9a868SElliott Hughes \let\bullet=\ptexbullet 6991*d5c9a868SElliott Hughes \let\c=\ptexc 6992*d5c9a868SElliott Hughes \let\,=\ptexcomma 6993*d5c9a868SElliott Hughes \let\.=\ptexdot 6994*d5c9a868SElliott Hughes \let\dots=\ptexdots 6995*d5c9a868SElliott Hughes \let\equiv=\ptexequiv 6996*d5c9a868SElliott Hughes \let\!=\ptexexclam 6997*d5c9a868SElliott Hughes \let\i=\ptexi 6998*d5c9a868SElliott Hughes \let\indent=\ptexindent 6999*d5c9a868SElliott Hughes \let\noindent=\ptexnoindent 7000*d5c9a868SElliott Hughes \let\{=\ptexlbrace 7001*d5c9a868SElliott Hughes \let\+=\tabalign 7002*d5c9a868SElliott Hughes \let\}=\ptexrbrace 7003*d5c9a868SElliott Hughes \let\/=\ptexslash 7004*d5c9a868SElliott Hughes \let\sp=\ptexsp 7005*d5c9a868SElliott Hughes \let\*=\ptexstar 7006*d5c9a868SElliott Hughes %\let\sup=\ptexsup % do not redefine, we want @sup to work in math mode 7007*d5c9a868SElliott Hughes \let\t=\ptext 7008*d5c9a868SElliott Hughes \expandafter \let\csname top\endcsname=\ptextop % we've made it outer 7009*d5c9a868SElliott Hughes \let\frenchspacing=\plainfrenchspacing 7010*d5c9a868SElliott Hughes % 7011*d5c9a868SElliott Hughes \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}% 7012*d5c9a868SElliott Hughes \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}% 7013*d5c9a868SElliott Hughes \def\@{@}% 7014*d5c9a868SElliott Hughes} 7015*d5c9a868SElliott Hughes% There is no need to define \Etex. 7016*d5c9a868SElliott Hughes 7017*d5c9a868SElliott Hughes% Define @lisp ... @end lisp. 7018*d5c9a868SElliott Hughes% @lisp environment forms a group so it can rebind things, 7019*d5c9a868SElliott Hughes% including the definition of @end lisp (which normally is erroneous). 7020*d5c9a868SElliott Hughes 7021*d5c9a868SElliott Hughes% Amount to narrow the margins by for @lisp. 7022*d5c9a868SElliott Hughes\newskip\lispnarrowing \lispnarrowing=0.4in 7023*d5c9a868SElliott Hughes 7024*d5c9a868SElliott Hughes% This is the definition that ^^M gets inside @lisp, @example, and other 7025*d5c9a868SElliott Hughes% such environments. \null is better than a space, since it doesn't 7026*d5c9a868SElliott Hughes% have any width. 7027*d5c9a868SElliott Hughes\def\lisppar{\null\endgraf} 7028*d5c9a868SElliott Hughes 7029*d5c9a868SElliott Hughes% This space is always present above and below environments. 7030*d5c9a868SElliott Hughes\newskip\envskipamount \envskipamount = 0pt 7031*d5c9a868SElliott Hughes 7032*d5c9a868SElliott Hughes% Make spacing and below environment symmetrical. We use \parskip here 7033*d5c9a868SElliott Hughes% to help in doing that, since in @example-like environments \parskip 7034*d5c9a868SElliott Hughes% is reset to zero; thus the \afterenvbreak inserts no space -- but the 7035*d5c9a868SElliott Hughes% start of the next paragraph will insert \parskip. 7036*d5c9a868SElliott Hughes% 7037*d5c9a868SElliott Hughes\def\aboveenvbreak{{% 7038*d5c9a868SElliott Hughes % =10000 instead of <10000 because of a special case in \itemzzz and 7039*d5c9a868SElliott Hughes % \sectionheading, q.v. 7040*d5c9a868SElliott Hughes \ifnum \lastpenalty=10000 \else 7041*d5c9a868SElliott Hughes \advance\envskipamount by \parskip 7042*d5c9a868SElliott Hughes \endgraf 7043*d5c9a868SElliott Hughes \ifdim\lastskip<\envskipamount 7044*d5c9a868SElliott Hughes \removelastskip 7045*d5c9a868SElliott Hughes \ifnum\lastpenalty<10000 7046*d5c9a868SElliott Hughes % Penalize breaking before the environment, because preceding text 7047*d5c9a868SElliott Hughes % often leads into it. 7048*d5c9a868SElliott Hughes \penalty100 7049*d5c9a868SElliott Hughes \fi 7050*d5c9a868SElliott Hughes \vskip\envskipamount 7051*d5c9a868SElliott Hughes \fi 7052*d5c9a868SElliott Hughes \fi 7053*d5c9a868SElliott Hughes}} 7054*d5c9a868SElliott Hughes 7055*d5c9a868SElliott Hughes\def\afterenvbreak{{% 7056*d5c9a868SElliott Hughes % =10000 instead of <10000 because of a special case in \itemzzz and 7057*d5c9a868SElliott Hughes % \sectionheading, q.v. 7058*d5c9a868SElliott Hughes \ifnum \lastpenalty=10000 \else 7059*d5c9a868SElliott Hughes \advance\envskipamount by \parskip 7060*d5c9a868SElliott Hughes \endgraf 7061*d5c9a868SElliott Hughes \ifdim\lastskip<\envskipamount 7062*d5c9a868SElliott Hughes \removelastskip 7063*d5c9a868SElliott Hughes % it's not a good place to break if the last penalty was \nobreak 7064*d5c9a868SElliott Hughes % or better ... 7065*d5c9a868SElliott Hughes \ifnum\lastpenalty<10000 \penalty-50 \fi 7066*d5c9a868SElliott Hughes \vskip\envskipamount 7067*d5c9a868SElliott Hughes \fi 7068*d5c9a868SElliott Hughes \fi 7069*d5c9a868SElliott Hughes}} 7070*d5c9a868SElliott Hughes 7071*d5c9a868SElliott Hughes% \nonarrowing is a flag. If "set", @lisp etc don't narrow margins; it will 7072*d5c9a868SElliott Hughes% also clear it, so that its embedded environments do the narrowing again. 7073*d5c9a868SElliott Hughes\let\nonarrowing=\relax 7074*d5c9a868SElliott Hughes 7075*d5c9a868SElliott Hughes% @cartouche ... @end cartouche: draw rectangle w/rounded corners around 7076*d5c9a868SElliott Hughes% environment contents. 7077*d5c9a868SElliott Hughes 7078*d5c9a868SElliott Hughes% 7079*d5c9a868SElliott Hughes\def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth 7080*d5c9a868SElliott Hughes\def\ctr{{\hskip 6pt\circle\char'010}} 7081*d5c9a868SElliott Hughes\def\cbl{{\circle\char'012\hskip -6pt}} 7082*d5c9a868SElliott Hughes\def\cbr{{\hskip 6pt\circle\char'011}} 7083*d5c9a868SElliott Hughes\def\carttop{\hbox to \cartouter{\hskip\lskip 7084*d5c9a868SElliott Hughes \ctl\leaders\hrule height\circthick\hfil\ctr 7085*d5c9a868SElliott Hughes \hskip\rskip}} 7086*d5c9a868SElliott Hughes\def\cartbot{\hbox to \cartouter{\hskip\lskip 7087*d5c9a868SElliott Hughes \cbl\leaders\hrule height\circthick\hfil\cbr 7088*d5c9a868SElliott Hughes \hskip\rskip}} 7089*d5c9a868SElliott Hughes% 7090*d5c9a868SElliott Hughes\newskip\lskip\newskip\rskip 7091*d5c9a868SElliott Hughes 7092*d5c9a868SElliott Hughes% only require the font if @cartouche is actually used 7093*d5c9a868SElliott Hughes\def\cartouchefontdefs{% 7094*d5c9a868SElliott Hughes \font\circle=lcircle10\relax 7095*d5c9a868SElliott Hughes \circthick=\fontdimen8\circle 7096*d5c9a868SElliott Hughes} 7097*d5c9a868SElliott Hughes\newdimen\circthick 7098*d5c9a868SElliott Hughes\newdimen\cartouter\newdimen\cartinner 7099*d5c9a868SElliott Hughes\newskip\normbskip\newskip\normpskip\newskip\normlskip 7100*d5c9a868SElliott Hughes 7101*d5c9a868SElliott Hughes 7102*d5c9a868SElliott Hughes\envdef\cartouche{% 7103*d5c9a868SElliott Hughes \cartouchefontdefs 7104*d5c9a868SElliott Hughes \ifhmode\par\fi % can't be in the midst of a paragraph. 7105*d5c9a868SElliott Hughes \startsavinginserts 7106*d5c9a868SElliott Hughes \lskip=\leftskip \rskip=\rightskip 7107*d5c9a868SElliott Hughes \leftskip=0pt\rightskip=0pt % we want these *outside*. 7108*d5c9a868SElliott Hughes \cartinner=\hsize \advance\cartinner by-\lskip 7109*d5c9a868SElliott Hughes \advance\cartinner by-\rskip 7110*d5c9a868SElliott Hughes \cartouter=\hsize 7111*d5c9a868SElliott Hughes \advance\cartouter by 18.4pt % allow for 3pt kerns on either 7112*d5c9a868SElliott Hughes % side, and for 6pt waste from 7113*d5c9a868SElliott Hughes % each corner char, and rule thickness 7114*d5c9a868SElliott Hughes \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip 7115*d5c9a868SElliott Hughes % 7116*d5c9a868SElliott Hughes % If this cartouche directly follows a sectioning command, we need the 7117*d5c9a868SElliott Hughes % \parskip glue (backspaced over by default) or the cartouche can 7118*d5c9a868SElliott Hughes % collide with the section heading. 7119*d5c9a868SElliott Hughes \ifnum\lastpenalty>10000 \vskip\parskip \penalty\lastpenalty \fi 7120*d5c9a868SElliott Hughes % 7121*d5c9a868SElliott Hughes \setbox\groupbox=\vbox\bgroup 7122*d5c9a868SElliott Hughes \baselineskip=0pt\parskip=0pt\lineskip=0pt 7123*d5c9a868SElliott Hughes \carttop 7124*d5c9a868SElliott Hughes \hbox\bgroup 7125*d5c9a868SElliott Hughes \hskip\lskip 7126*d5c9a868SElliott Hughes \vrule\kern3pt 7127*d5c9a868SElliott Hughes \vbox\bgroup 7128*d5c9a868SElliott Hughes \kern3pt 7129*d5c9a868SElliott Hughes \hsize=\cartinner 7130*d5c9a868SElliott Hughes \baselineskip=\normbskip 7131*d5c9a868SElliott Hughes \lineskip=\normlskip 7132*d5c9a868SElliott Hughes \parskip=\normpskip 7133*d5c9a868SElliott Hughes \vskip -\parskip 7134*d5c9a868SElliott Hughes \comment % For explanation, see the end of def\group. 7135*d5c9a868SElliott Hughes} 7136*d5c9a868SElliott Hughes\def\Ecartouche{% 7137*d5c9a868SElliott Hughes \ifhmode\par\fi 7138*d5c9a868SElliott Hughes \kern3pt 7139*d5c9a868SElliott Hughes \egroup 7140*d5c9a868SElliott Hughes \kern3pt\vrule 7141*d5c9a868SElliott Hughes \hskip\rskip 7142*d5c9a868SElliott Hughes \egroup 7143*d5c9a868SElliott Hughes \cartbot 7144*d5c9a868SElliott Hughes \egroup 7145*d5c9a868SElliott Hughes \addgroupbox 7146*d5c9a868SElliott Hughes \checkinserts 7147*d5c9a868SElliott Hughes} 7148*d5c9a868SElliott Hughes 7149*d5c9a868SElliott Hughes 7150*d5c9a868SElliott Hughes% This macro is called at the beginning of all the @example variants, 7151*d5c9a868SElliott Hughes% inside a group. 7152*d5c9a868SElliott Hughes\newdimen\nonfillparindent 7153*d5c9a868SElliott Hughes\def\nonfillstart{% 7154*d5c9a868SElliott Hughes \aboveenvbreak 7155*d5c9a868SElliott Hughes \ifdim\hfuzz < 12pt \hfuzz = 12pt \fi % Don't be fussy 7156*d5c9a868SElliott Hughes \sepspaces % Make spaces be word-separators rather than space tokens. 7157*d5c9a868SElliott Hughes \let\par = \lisppar % don't ignore blank lines 7158*d5c9a868SElliott Hughes \obeylines % each line of input is a line of output 7159*d5c9a868SElliott Hughes \parskip = 0pt 7160*d5c9a868SElliott Hughes % Turn off paragraph indentation but redefine \indent to emulate 7161*d5c9a868SElliott Hughes % the normal \indent. 7162*d5c9a868SElliott Hughes \nonfillparindent=\parindent 7163*d5c9a868SElliott Hughes \parindent = 0pt 7164*d5c9a868SElliott Hughes \let\indent\nonfillindent 7165*d5c9a868SElliott Hughes % 7166*d5c9a868SElliott Hughes \emergencystretch = 0pt % don't try to avoid overfull boxes 7167*d5c9a868SElliott Hughes \ifx\nonarrowing\relax 7168*d5c9a868SElliott Hughes \advance \leftskip by \lispnarrowing 7169*d5c9a868SElliott Hughes \exdentamount=\lispnarrowing 7170*d5c9a868SElliott Hughes \else 7171*d5c9a868SElliott Hughes \let\nonarrowing = \relax 7172*d5c9a868SElliott Hughes \fi 7173*d5c9a868SElliott Hughes \let\exdent=\nofillexdent 7174*d5c9a868SElliott Hughes} 7175*d5c9a868SElliott Hughes 7176*d5c9a868SElliott Hughes\begingroup 7177*d5c9a868SElliott Hughes\obeyspaces 7178*d5c9a868SElliott Hughes% We want to swallow spaces (but not other tokens) after the fake 7179*d5c9a868SElliott Hughes% @indent in our nonfill-environments, where spaces are normally 7180*d5c9a868SElliott Hughes% active and set to @tie, resulting in them not being ignored after 7181*d5c9a868SElliott Hughes% @indent. 7182*d5c9a868SElliott Hughes\gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}% 7183*d5c9a868SElliott Hughes\gdef\nonfillindentcheck{% 7184*d5c9a868SElliott Hughes\ifx\temp % 7185*d5c9a868SElliott Hughes\expandafter\nonfillindentgobble% 7186*d5c9a868SElliott Hughes\else% 7187*d5c9a868SElliott Hughes\leavevmode\nonfillindentbox% 7188*d5c9a868SElliott Hughes\fi% 7189*d5c9a868SElliott Hughes}% 7190*d5c9a868SElliott Hughes\endgroup 7191*d5c9a868SElliott Hughes\def\nonfillindentgobble#1{\nonfillindent} 7192*d5c9a868SElliott Hughes\def\nonfillindentbox{\hbox to \nonfillparindent{\hss}} 7193*d5c9a868SElliott Hughes 7194*d5c9a868SElliott Hughes% If you want all examples etc. small: @set dispenvsize small. 7195*d5c9a868SElliott Hughes% If you want even small examples the full size: @set dispenvsize nosmall. 7196*d5c9a868SElliott Hughes% This affects the following displayed environments: 7197*d5c9a868SElliott Hughes% @example, @display, @format, @lisp, @verbatim 7198*d5c9a868SElliott Hughes% 7199*d5c9a868SElliott Hughes\def\smallword{small} 7200*d5c9a868SElliott Hughes\def\nosmallword{nosmall} 7201*d5c9a868SElliott Hughes\let\SETdispenvsize\relax 7202*d5c9a868SElliott Hughes\def\setnormaldispenv{% 7203*d5c9a868SElliott Hughes \ifx\SETdispenvsize\smallword 7204*d5c9a868SElliott Hughes % end paragraph for sake of leading, in case document has no blank 7205*d5c9a868SElliott Hughes % line. This is redundant with what happens in \aboveenvbreak, but 7206*d5c9a868SElliott Hughes % we need to do it before changing the fonts, and it's inconvenient 7207*d5c9a868SElliott Hughes % to change the fonts afterward. 7208*d5c9a868SElliott Hughes \ifnum \lastpenalty=10000 \else \endgraf \fi 7209*d5c9a868SElliott Hughes \smallexamplefonts \rm 7210*d5c9a868SElliott Hughes \fi 7211*d5c9a868SElliott Hughes} 7212*d5c9a868SElliott Hughes\def\setsmalldispenv{% 7213*d5c9a868SElliott Hughes \ifx\SETdispenvsize\nosmallword 7214*d5c9a868SElliott Hughes \else 7215*d5c9a868SElliott Hughes \ifnum \lastpenalty=10000 \else \endgraf \fi 7216*d5c9a868SElliott Hughes \smallexamplefonts \rm 7217*d5c9a868SElliott Hughes \fi 7218*d5c9a868SElliott Hughes} 7219*d5c9a868SElliott Hughes 7220*d5c9a868SElliott Hughes% We often define two environments, @foo and @smallfoo. 7221*d5c9a868SElliott Hughes% Let's do it in one command. #1 is the env name, #2 the definition. 7222*d5c9a868SElliott Hughes\def\makedispenvdef#1#2{% 7223*d5c9a868SElliott Hughes \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}% 7224*d5c9a868SElliott Hughes \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}% 7225*d5c9a868SElliott Hughes \expandafter\let\csname E#1\endcsname \afterenvbreak 7226*d5c9a868SElliott Hughes \expandafter\let\csname Esmall#1\endcsname \afterenvbreak 7227*d5c9a868SElliott Hughes} 7228*d5c9a868SElliott Hughes 7229*d5c9a868SElliott Hughes% Define two environment synonyms (#1 and #2) for an environment. 7230*d5c9a868SElliott Hughes\def\maketwodispenvdef#1#2#3{% 7231*d5c9a868SElliott Hughes \makedispenvdef{#1}{#3}% 7232*d5c9a868SElliott Hughes \makedispenvdef{#2}{#3}% 7233*d5c9a868SElliott Hughes} 7234*d5c9a868SElliott Hughes% 7235*d5c9a868SElliott Hughes% @lisp: indented, narrowed, typewriter font; 7236*d5c9a868SElliott Hughes% @example: same as @lisp. 7237*d5c9a868SElliott Hughes% 7238*d5c9a868SElliott Hughes% @smallexample and @smalllisp: use smaller fonts. 7239*d5c9a868SElliott Hughes% Originally contributed by Pavel@xerox. 7240*d5c9a868SElliott Hughes% 7241*d5c9a868SElliott Hughes\maketwodispenvdef{lisp}{example}{% 7242*d5c9a868SElliott Hughes \nonfillstart 7243*d5c9a868SElliott Hughes \tt\setcodequotes 7244*d5c9a868SElliott Hughes \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special. 7245*d5c9a868SElliott Hughes \parsearg\gobble 7246*d5c9a868SElliott Hughes} 7247*d5c9a868SElliott Hughes% @display/@smalldisplay: same as @lisp except keep current font. 7248*d5c9a868SElliott Hughes% 7249*d5c9a868SElliott Hughes\makedispenvdef{display}{% 7250*d5c9a868SElliott Hughes \nonfillstart 7251*d5c9a868SElliott Hughes \gobble 7252*d5c9a868SElliott Hughes} 7253*d5c9a868SElliott Hughes 7254*d5c9a868SElliott Hughes% @format/@smallformat: same as @display except don't narrow margins. 7255*d5c9a868SElliott Hughes% 7256*d5c9a868SElliott Hughes\makedispenvdef{format}{% 7257*d5c9a868SElliott Hughes \let\nonarrowing = t% 7258*d5c9a868SElliott Hughes \nonfillstart 7259*d5c9a868SElliott Hughes \gobble 7260*d5c9a868SElliott Hughes} 7261*d5c9a868SElliott Hughes 7262*d5c9a868SElliott Hughes% @flushleft: same as @format, but doesn't obey \SETdispenvsize. 7263*d5c9a868SElliott Hughes\envdef\flushleft{% 7264*d5c9a868SElliott Hughes \let\nonarrowing = t% 7265*d5c9a868SElliott Hughes \nonfillstart 7266*d5c9a868SElliott Hughes \gobble 7267*d5c9a868SElliott Hughes} 7268*d5c9a868SElliott Hughes\let\Eflushleft = \afterenvbreak 7269*d5c9a868SElliott Hughes 7270*d5c9a868SElliott Hughes% @flushright. 7271*d5c9a868SElliott Hughes% 7272*d5c9a868SElliott Hughes\envdef\flushright{% 7273*d5c9a868SElliott Hughes \let\nonarrowing = t% 7274*d5c9a868SElliott Hughes \nonfillstart 7275*d5c9a868SElliott Hughes \advance\leftskip by 0pt plus 1fill\relax 7276*d5c9a868SElliott Hughes \gobble 7277*d5c9a868SElliott Hughes} 7278*d5c9a868SElliott Hughes\let\Eflushright = \afterenvbreak 7279*d5c9a868SElliott Hughes 7280*d5c9a868SElliott Hughes 7281*d5c9a868SElliott Hughes% @raggedright does more-or-less normal line breaking but no right 7282*d5c9a868SElliott Hughes% justification. From plain.tex. 7283*d5c9a868SElliott Hughes\envdef\raggedright{% 7284*d5c9a868SElliott Hughes \rightskip0pt plus2.4em \spaceskip.3333em \xspaceskip.5em\relax 7285*d5c9a868SElliott Hughes} 7286*d5c9a868SElliott Hughes\let\Eraggedright\par 7287*d5c9a868SElliott Hughes 7288*d5c9a868SElliott Hughes\envdef\raggedleft{% 7289*d5c9a868SElliott Hughes \parindent=0pt \leftskip0pt plus2em 7290*d5c9a868SElliott Hughes \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt 7291*d5c9a868SElliott Hughes \hbadness=10000 % Last line will usually be underfull, so turn off 7292*d5c9a868SElliott Hughes % badness reporting. 7293*d5c9a868SElliott Hughes} 7294*d5c9a868SElliott Hughes\let\Eraggedleft\par 7295*d5c9a868SElliott Hughes 7296*d5c9a868SElliott Hughes\envdef\raggedcenter{% 7297*d5c9a868SElliott Hughes \parindent=0pt \rightskip0pt plus1em \leftskip0pt plus1em 7298*d5c9a868SElliott Hughes \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt 7299*d5c9a868SElliott Hughes \hbadness=10000 % Last line will usually be underfull, so turn off 7300*d5c9a868SElliott Hughes % badness reporting. 7301*d5c9a868SElliott Hughes} 7302*d5c9a868SElliott Hughes\let\Eraggedcenter\par 7303*d5c9a868SElliott Hughes 7304*d5c9a868SElliott Hughes 7305*d5c9a868SElliott Hughes% @quotation does normal linebreaking (hence we can't use \nonfillstart) 7306*d5c9a868SElliott Hughes% and narrows the margins. We keep \parskip nonzero in general, since 7307*d5c9a868SElliott Hughes% we're doing normal filling. So, when using \aboveenvbreak and 7308*d5c9a868SElliott Hughes% \afterenvbreak, temporarily make \parskip 0. 7309*d5c9a868SElliott Hughes% 7310*d5c9a868SElliott Hughes\makedispenvdef{quotation}{\quotationstart} 7311*d5c9a868SElliott Hughes% 7312*d5c9a868SElliott Hughes\def\quotationstart{% 7313*d5c9a868SElliott Hughes \indentedblockstart % same as \indentedblock, but increase right margin too. 7314*d5c9a868SElliott Hughes \ifx\nonarrowing\relax 7315*d5c9a868SElliott Hughes \advance\rightskip by \lispnarrowing 7316*d5c9a868SElliott Hughes \fi 7317*d5c9a868SElliott Hughes \parsearg\quotationlabel 7318*d5c9a868SElliott Hughes} 7319*d5c9a868SElliott Hughes 7320*d5c9a868SElliott Hughes% We have retained a nonzero parskip for the environment, since we're 7321*d5c9a868SElliott Hughes% doing normal filling. 7322*d5c9a868SElliott Hughes% 7323*d5c9a868SElliott Hughes\def\Equotation{% 7324*d5c9a868SElliott Hughes \par 7325*d5c9a868SElliott Hughes \ifx\quotationauthor\thisisundefined\else 7326*d5c9a868SElliott Hughes % indent a bit. 7327*d5c9a868SElliott Hughes \leftline{\kern 2\leftskip \sl ---\quotationauthor}% 7328*d5c9a868SElliott Hughes \fi 7329*d5c9a868SElliott Hughes {\parskip=0pt \afterenvbreak}% 7330*d5c9a868SElliott Hughes} 7331*d5c9a868SElliott Hughes\def\Esmallquotation{\Equotation} 7332*d5c9a868SElliott Hughes 7333*d5c9a868SElliott Hughes% If we're given an argument, typeset it in bold with a colon after. 7334*d5c9a868SElliott Hughes\def\quotationlabel#1{% 7335*d5c9a868SElliott Hughes \def\temp{#1}% 7336*d5c9a868SElliott Hughes \ifx\temp\empty \else 7337*d5c9a868SElliott Hughes {\bf #1: }% 7338*d5c9a868SElliott Hughes \fi 7339*d5c9a868SElliott Hughes} 7340*d5c9a868SElliott Hughes 7341*d5c9a868SElliott Hughes% @indentedblock is like @quotation, but indents only on the left and 7342*d5c9a868SElliott Hughes% has no optional argument. 7343*d5c9a868SElliott Hughes% 7344*d5c9a868SElliott Hughes\makedispenvdef{indentedblock}{\indentedblockstart} 7345*d5c9a868SElliott Hughes% 7346*d5c9a868SElliott Hughes\def\indentedblockstart{% 7347*d5c9a868SElliott Hughes {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip 7348*d5c9a868SElliott Hughes \parindent=0pt 7349*d5c9a868SElliott Hughes % 7350*d5c9a868SElliott Hughes % @cartouche defines \nonarrowing to inhibit narrowing at next level down. 7351*d5c9a868SElliott Hughes \ifx\nonarrowing\relax 7352*d5c9a868SElliott Hughes \advance\leftskip by \lispnarrowing 7353*d5c9a868SElliott Hughes \exdentamount = \lispnarrowing 7354*d5c9a868SElliott Hughes \else 7355*d5c9a868SElliott Hughes \let\nonarrowing = \relax 7356*d5c9a868SElliott Hughes \fi 7357*d5c9a868SElliott Hughes} 7358*d5c9a868SElliott Hughes 7359*d5c9a868SElliott Hughes% Keep a nonzero parskip for the environment, since we're doing normal filling. 7360*d5c9a868SElliott Hughes% 7361*d5c9a868SElliott Hughes\def\Eindentedblock{% 7362*d5c9a868SElliott Hughes \par 7363*d5c9a868SElliott Hughes {\parskip=0pt \afterenvbreak}% 7364*d5c9a868SElliott Hughes} 7365*d5c9a868SElliott Hughes\def\Esmallindentedblock{\Eindentedblock} 7366*d5c9a868SElliott Hughes 7367*d5c9a868SElliott Hughes 7368*d5c9a868SElliott Hughes% LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>} 7369*d5c9a868SElliott Hughes% If we want to allow any <char> as delimiter, 7370*d5c9a868SElliott Hughes% we need the curly braces so that makeinfo sees the @verb command, eg: 7371*d5c9a868SElliott Hughes% `@verbx...x' would look like the '@verbx' command. [email protected] 7372*d5c9a868SElliott Hughes% 7373*d5c9a868SElliott Hughes% [Knuth]: Donald Ervin Knuth, 1996. The TeXbook. 7374*d5c9a868SElliott Hughes% 7375*d5c9a868SElliott Hughes% [Knuth] p.344; only we need to do the other characters Texinfo sets 7376*d5c9a868SElliott Hughes% active too. Otherwise, they get lost as the first character on a 7377*d5c9a868SElliott Hughes% verbatim line. 7378*d5c9a868SElliott Hughes\def\dospecials{% 7379*d5c9a868SElliott Hughes \do\ \do\\\do\{\do\}\do\$\do\&% 7380*d5c9a868SElliott Hughes \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~% 7381*d5c9a868SElliott Hughes \do\<\do\>\do\|\do\@\do+\do\"% 7382*d5c9a868SElliott Hughes % Don't do the quotes -- if we do, @set txicodequoteundirected and 7383*d5c9a868SElliott Hughes % @set txicodequotebacktick will not have effect on @verb and 7384*d5c9a868SElliott Hughes % @verbatim, and ?` and !` ligatures won't get disabled. 7385*d5c9a868SElliott Hughes %\do\`\do\'% 7386*d5c9a868SElliott Hughes} 7387*d5c9a868SElliott Hughes% 7388*d5c9a868SElliott Hughes% [Knuth] p. 380 7389*d5c9a868SElliott Hughes\def\uncatcodespecials{% 7390*d5c9a868SElliott Hughes \def\do##1{\catcode`##1=\other}\dospecials} 7391*d5c9a868SElliott Hughes% 7392*d5c9a868SElliott Hughes% Setup for the @verb command. 7393*d5c9a868SElliott Hughes% 7394*d5c9a868SElliott Hughes% Eight spaces for a tab 7395*d5c9a868SElliott Hughes\begingroup 7396*d5c9a868SElliott Hughes \catcode`\^^I=\active 7397*d5c9a868SElliott Hughes \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }} 7398*d5c9a868SElliott Hughes\endgroup 7399*d5c9a868SElliott Hughes% 7400*d5c9a868SElliott Hughes\def\setupverb{% 7401*d5c9a868SElliott Hughes \tt % easiest (and conventionally used) font for verbatim 7402*d5c9a868SElliott Hughes \def\par{\leavevmode\endgraf}% 7403*d5c9a868SElliott Hughes \setcodequotes 7404*d5c9a868SElliott Hughes \tabeightspaces 7405*d5c9a868SElliott Hughes % Respect line breaks, 7406*d5c9a868SElliott Hughes % print special symbols as themselves, and 7407*d5c9a868SElliott Hughes % make each space count 7408*d5c9a868SElliott Hughes % must do in this order: 7409*d5c9a868SElliott Hughes \obeylines \uncatcodespecials \sepspaces 7410*d5c9a868SElliott Hughes} 7411*d5c9a868SElliott Hughes 7412*d5c9a868SElliott Hughes% Setup for the @verbatim environment 7413*d5c9a868SElliott Hughes% 7414*d5c9a868SElliott Hughes% Real tab expansion. 7415*d5c9a868SElliott Hughes\newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount 7416*d5c9a868SElliott Hughes% 7417*d5c9a868SElliott Hughes% We typeset each line of the verbatim in an \hbox, so we can handle 7418*d5c9a868SElliott Hughes% tabs. 7419*d5c9a868SElliott Hughes\newbox\verbbox 7420*d5c9a868SElliott Hughes\def\starttabbox{\setbox\verbbox=\hbox\bgroup} 7421*d5c9a868SElliott Hughes% 7422*d5c9a868SElliott Hughes\begingroup 7423*d5c9a868SElliott Hughes \catcode`\^^I=\active 7424*d5c9a868SElliott Hughes \gdef\tabexpand{% 7425*d5c9a868SElliott Hughes \catcode`\^^I=\active 7426*d5c9a868SElliott Hughes \def^^I{\leavevmode\egroup 7427*d5c9a868SElliott Hughes \dimen\verbbox=\wd\verbbox % the width so far, or since the previous tab 7428*d5c9a868SElliott Hughes \divide\dimen\verbbox by\tabw 7429*d5c9a868SElliott Hughes \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw 7430*d5c9a868SElliott Hughes \advance\dimen\verbbox by\tabw % advance to next multiple of \tabw 7431*d5c9a868SElliott Hughes \wd\verbbox=\dimen\verbbox 7432*d5c9a868SElliott Hughes \leavevmode\box\verbbox \starttabbox 7433*d5c9a868SElliott Hughes }% 7434*d5c9a868SElliott Hughes } 7435*d5c9a868SElliott Hughes\endgroup 7436*d5c9a868SElliott Hughes 7437*d5c9a868SElliott Hughes% start the verbatim environment. 7438*d5c9a868SElliott Hughes\def\setupverbatim{% 7439*d5c9a868SElliott Hughes \let\nonarrowing = t% 7440*d5c9a868SElliott Hughes \nonfillstart 7441*d5c9a868SElliott Hughes \tt % easiest (and conventionally used) font for verbatim 7442*d5c9a868SElliott Hughes \def\par{\egroup\leavevmode\box\verbbox\endgraf\starttabbox}% 7443*d5c9a868SElliott Hughes \tabexpand 7444*d5c9a868SElliott Hughes \setcodequotes 7445*d5c9a868SElliott Hughes % Respect line breaks, 7446*d5c9a868SElliott Hughes % print special symbols as themselves, and 7447*d5c9a868SElliott Hughes % make each space count. 7448*d5c9a868SElliott Hughes % Must do in this order: 7449*d5c9a868SElliott Hughes \obeylines \uncatcodespecials \sepspaces 7450*d5c9a868SElliott Hughes} 7451*d5c9a868SElliott Hughes 7452*d5c9a868SElliott Hughes% Do the @verb magic: verbatim text is quoted by unique 7453*d5c9a868SElliott Hughes% delimiter characters. Before first delimiter expect a 7454*d5c9a868SElliott Hughes% right brace, after last delimiter expect closing brace: 7455*d5c9a868SElliott Hughes% 7456*d5c9a868SElliott Hughes% \def\doverb'{'<char>#1<char>'}'{#1} 7457*d5c9a868SElliott Hughes% 7458*d5c9a868SElliott Hughes% [Knuth] p. 382; only eat outer {} 7459*d5c9a868SElliott Hughes\begingroup 7460*d5c9a868SElliott Hughes \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other 7461*d5c9a868SElliott Hughes \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next] 7462*d5c9a868SElliott Hughes\endgroup 7463*d5c9a868SElliott Hughes% 7464*d5c9a868SElliott Hughes\def\verb{\begingroup\setupverb\doverb} 7465*d5c9a868SElliott Hughes% 7466*d5c9a868SElliott Hughes% 7467*d5c9a868SElliott Hughes% Do the @verbatim magic: define the macro \doverbatim so that 7468*d5c9a868SElliott Hughes% the (first) argument ends when '@end verbatim' is reached, ie: 7469*d5c9a868SElliott Hughes% 7470*d5c9a868SElliott Hughes% \def\doverbatim#1@end verbatim{#1} 7471*d5c9a868SElliott Hughes% 7472*d5c9a868SElliott Hughes% For Texinfo it's a lot easier than for LaTeX, 7473*d5c9a868SElliott Hughes% because texinfo's \verbatim doesn't stop at '\end{verbatim}': 7474*d5c9a868SElliott Hughes% we need not redefine '\', '{' and '}'. 7475*d5c9a868SElliott Hughes% 7476*d5c9a868SElliott Hughes% Inspired by LaTeX's verbatim command set [latex.ltx] 7477*d5c9a868SElliott Hughes% 7478*d5c9a868SElliott Hughes\begingroup 7479*d5c9a868SElliott Hughes \catcode`\ =\active 7480*d5c9a868SElliott Hughes \obeylines % 7481*d5c9a868SElliott Hughes % ignore everything up to the first ^^M, that's the newline at the end 7482*d5c9a868SElliott Hughes % of the @verbatim input line itself. Otherwise we get an extra blank 7483*d5c9a868SElliott Hughes % line in the output. 7484*d5c9a868SElliott Hughes \xdef\doverbatim#1^^M#2@end verbatim{% 7485*d5c9a868SElliott Hughes \starttabbox#2\egroup\noexpand\end\gobble verbatim}% 7486*d5c9a868SElliott Hughes % We really want {...\end verbatim} in the body of the macro, but 7487*d5c9a868SElliott Hughes % without the active space; thus we have to use \xdef and \gobble. 7488*d5c9a868SElliott Hughes % The \egroup ends the \verbbox started at the end of the last line in 7489*d5c9a868SElliott Hughes % the block. 7490*d5c9a868SElliott Hughes\endgroup 7491*d5c9a868SElliott Hughes% 7492*d5c9a868SElliott Hughes\envdef\verbatim{% 7493*d5c9a868SElliott Hughes \setnormaldispenv\setupverbatim\doverbatim 7494*d5c9a868SElliott Hughes} 7495*d5c9a868SElliott Hughes\let\Everbatim = \afterenvbreak 7496*d5c9a868SElliott Hughes 7497*d5c9a868SElliott Hughes 7498*d5c9a868SElliott Hughes% @verbatiminclude FILE - insert text of file in verbatim environment. 7499*d5c9a868SElliott Hughes% 7500*d5c9a868SElliott Hughes\def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude} 7501*d5c9a868SElliott Hughes% 7502*d5c9a868SElliott Hughes\def\doverbatiminclude#1{% 7503*d5c9a868SElliott Hughes {% 7504*d5c9a868SElliott Hughes \makevalueexpandable 7505*d5c9a868SElliott Hughes \setupverbatim 7506*d5c9a868SElliott Hughes {% 7507*d5c9a868SElliott Hughes \indexnofonts % Allow `@@' and other weird things in file names. 7508*d5c9a868SElliott Hughes \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}% 7509*d5c9a868SElliott Hughes \edef\tmp{\noexpand\input #1 } 7510*d5c9a868SElliott Hughes \expandafter 7511*d5c9a868SElliott Hughes }\expandafter\starttabbox\tmp\egroup 7512*d5c9a868SElliott Hughes \afterenvbreak 7513*d5c9a868SElliott Hughes }% 7514*d5c9a868SElliott Hughes} 7515*d5c9a868SElliott Hughes 7516*d5c9a868SElliott Hughes% @copying ... @end copying. 7517*d5c9a868SElliott Hughes% Save the text away for @insertcopying later. 7518*d5c9a868SElliott Hughes% 7519*d5c9a868SElliott Hughes% We save the uninterpreted tokens, rather than creating a box. 7520*d5c9a868SElliott Hughes% Saving the text in a box would be much easier, but then all the 7521*d5c9a868SElliott Hughes% typesetting commands (@smallbook, font changes, etc.) have to be done 7522*d5c9a868SElliott Hughes% beforehand -- and a) we want @copying to be done first in the source 7523*d5c9a868SElliott Hughes% file; b) letting users define the frontmatter in as flexible order as 7524*d5c9a868SElliott Hughes% possible is desirable. 7525*d5c9a868SElliott Hughes% 7526*d5c9a868SElliott Hughes\def\copying{\checkenv{}\begingroup\scanargctxt\docopying} 7527*d5c9a868SElliott Hughes\def\docopying#1@end copying{\endgroup\def\copyingtext{#1}} 7528*d5c9a868SElliott Hughes% 7529*d5c9a868SElliott Hughes\def\insertcopying{% 7530*d5c9a868SElliott Hughes \begingroup 7531*d5c9a868SElliott Hughes \parindent = 0pt % paragraph indentation looks wrong on title page 7532*d5c9a868SElliott Hughes \scanexp\copyingtext 7533*d5c9a868SElliott Hughes \endgroup 7534*d5c9a868SElliott Hughes} 7535*d5c9a868SElliott Hughes 7536*d5c9a868SElliott Hughes 7537*d5c9a868SElliott Hughes\message{defuns,} 7538*d5c9a868SElliott Hughes% @defun etc. 7539*d5c9a868SElliott Hughes 7540*d5c9a868SElliott Hughes\newskip\defbodyindent \defbodyindent=.4in 7541*d5c9a868SElliott Hughes\newskip\defargsindent \defargsindent=50pt 7542*d5c9a868SElliott Hughes\newskip\deflastargmargin \deflastargmargin=18pt 7543*d5c9a868SElliott Hughes\newcount\defunpenalty 7544*d5c9a868SElliott Hughes 7545*d5c9a868SElliott Hughes% Start the processing of @deffn: 7546*d5c9a868SElliott Hughes\def\startdefun{% 7547*d5c9a868SElliott Hughes \ifnum\lastpenalty<10000 7548*d5c9a868SElliott Hughes \medbreak 7549*d5c9a868SElliott Hughes \defunpenalty=10003 % Will keep this @deffn together with the 7550*d5c9a868SElliott Hughes % following @def command, see below. 7551*d5c9a868SElliott Hughes \else 7552*d5c9a868SElliott Hughes % If there are two @def commands in a row, we'll have a \nobreak, 7553*d5c9a868SElliott Hughes % which is there to keep the function description together with its 7554*d5c9a868SElliott Hughes % header. But if there's nothing but headers, we need to allow a 7555*d5c9a868SElliott Hughes % break somewhere. Check specifically for penalty 10002, inserted 7556*d5c9a868SElliott Hughes % by \printdefunline, instead of 10000, since the sectioning 7557*d5c9a868SElliott Hughes % commands also insert a nobreak penalty, and we don't want to allow 7558*d5c9a868SElliott Hughes % a break between a section heading and a defun. 7559*d5c9a868SElliott Hughes % 7560*d5c9a868SElliott Hughes % As a further refinement, we avoid "club" headers by signalling 7561*d5c9a868SElliott Hughes % with penalty of 10003 after the very first @deffn in the 7562*d5c9a868SElliott Hughes % sequence (see above), and penalty of 10002 after any following 7563*d5c9a868SElliott Hughes % @def command. 7564*d5c9a868SElliott Hughes \ifnum\lastpenalty=10002 \penalty2000 \else \defunpenalty=10002 \fi 7565*d5c9a868SElliott Hughes % 7566*d5c9a868SElliott Hughes % Similarly, after a section heading, do not allow a break. 7567*d5c9a868SElliott Hughes % But do insert the glue. 7568*d5c9a868SElliott Hughes \medskip % preceded by discardable penalty, so not a breakpoint 7569*d5c9a868SElliott Hughes \fi 7570*d5c9a868SElliott Hughes % 7571*d5c9a868SElliott Hughes \parindent=0in 7572*d5c9a868SElliott Hughes \advance\leftskip by \defbodyindent 7573*d5c9a868SElliott Hughes \exdentamount=\defbodyindent 7574*d5c9a868SElliott Hughes} 7575*d5c9a868SElliott Hughes 7576*d5c9a868SElliott Hughes\def\dodefunx#1{% 7577*d5c9a868SElliott Hughes % First, check whether we are in the right environment: 7578*d5c9a868SElliott Hughes \checkenv#1% 7579*d5c9a868SElliott Hughes % 7580*d5c9a868SElliott Hughes % As above, allow line break if we have multiple x headers in a row. 7581*d5c9a868SElliott Hughes % It's not a great place, though. 7582*d5c9a868SElliott Hughes \ifnum\lastpenalty=10002 \penalty3000 \else \defunpenalty=10002 \fi 7583*d5c9a868SElliott Hughes % 7584*d5c9a868SElliott Hughes % And now, it's time to reuse the body of the original defun: 7585*d5c9a868SElliott Hughes \expandafter\gobbledefun#1% 7586*d5c9a868SElliott Hughes} 7587*d5c9a868SElliott Hughes\def\gobbledefun#1\startdefun{} 7588*d5c9a868SElliott Hughes 7589*d5c9a868SElliott Hughes% \printdefunline \deffnheader{text} 7590*d5c9a868SElliott Hughes% 7591*d5c9a868SElliott Hughes\def\printdefunline#1#2{% 7592*d5c9a868SElliott Hughes \begingroup 7593*d5c9a868SElliott Hughes \plainfrenchspacing 7594*d5c9a868SElliott Hughes % call \deffnheader: 7595*d5c9a868SElliott Hughes #1#2 \endheader 7596*d5c9a868SElliott Hughes % common ending: 7597*d5c9a868SElliott Hughes \interlinepenalty = 10000 7598*d5c9a868SElliott Hughes \advance\rightskip by 0pt plus 1fil\relax 7599*d5c9a868SElliott Hughes \endgraf 7600*d5c9a868SElliott Hughes \nobreak\vskip -\parskip 7601*d5c9a868SElliott Hughes \penalty\defunpenalty % signal to \startdefun and \dodefunx 7602*d5c9a868SElliott Hughes % Some of the @defun-type tags do not enable magic parentheses, 7603*d5c9a868SElliott Hughes % rendering the following check redundant. But we don't optimize. 7604*d5c9a868SElliott Hughes \checkparencounts 7605*d5c9a868SElliott Hughes \endgroup 7606*d5c9a868SElliott Hughes} 7607*d5c9a868SElliott Hughes 7608*d5c9a868SElliott Hughes\def\Edefun{\endgraf\medbreak} 7609*d5c9a868SElliott Hughes 7610*d5c9a868SElliott Hughes% \makedefun{deffn} creates \deffn, \deffnx and \Edeffn; 7611*d5c9a868SElliott Hughes% the only thing remaining is to define \deffnheader. 7612*d5c9a868SElliott Hughes% 7613*d5c9a868SElliott Hughes\def\makedefun#1{% 7614*d5c9a868SElliott Hughes \expandafter\let\csname E#1\endcsname = \Edefun 7615*d5c9a868SElliott Hughes \edef\temp{\noexpand\domakedefun 7616*d5c9a868SElliott Hughes \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}% 7617*d5c9a868SElliott Hughes \temp 7618*d5c9a868SElliott Hughes} 7619*d5c9a868SElliott Hughes 7620*d5c9a868SElliott Hughes% \domakedefun \deffn \deffnx \deffnheader { (defn. of \deffnheader) } 7621*d5c9a868SElliott Hughes% 7622*d5c9a868SElliott Hughes% Define \deffn and \deffnx, without parameters. 7623*d5c9a868SElliott Hughes% \deffnheader has to be defined explicitly. 7624*d5c9a868SElliott Hughes% 7625*d5c9a868SElliott Hughes\def\domakedefun#1#2#3{% 7626*d5c9a868SElliott Hughes \envdef#1{% 7627*d5c9a868SElliott Hughes \startdefun 7628*d5c9a868SElliott Hughes \doingtypefnfalse % distinguish typed functions from all else 7629*d5c9a868SElliott Hughes \parseargusing\activeparens{\printdefunline#3}% 7630*d5c9a868SElliott Hughes }% 7631*d5c9a868SElliott Hughes \def#2{\dodefunx#1}% 7632*d5c9a868SElliott Hughes \def#3% 7633*d5c9a868SElliott Hughes} 7634*d5c9a868SElliott Hughes 7635*d5c9a868SElliott Hughes\newif\ifdoingtypefn % doing typed function? 7636*d5c9a868SElliott Hughes\newif\ifrettypeownline % typeset return type on its own line? 7637*d5c9a868SElliott Hughes 7638*d5c9a868SElliott Hughes% @deftypefnnewline on|off says whether the return type of typed functions 7639*d5c9a868SElliott Hughes% are printed on their own line. This affects @deftypefn, @deftypefun, 7640*d5c9a868SElliott Hughes% @deftypeop, and @deftypemethod. 7641*d5c9a868SElliott Hughes% 7642*d5c9a868SElliott Hughes\parseargdef\deftypefnnewline{% 7643*d5c9a868SElliott Hughes \def\temp{#1}% 7644*d5c9a868SElliott Hughes \ifx\temp\onword 7645*d5c9a868SElliott Hughes \expandafter\let\csname SETtxideftypefnnl\endcsname 7646*d5c9a868SElliott Hughes = \empty 7647*d5c9a868SElliott Hughes \else\ifx\temp\offword 7648*d5c9a868SElliott Hughes \expandafter\let\csname SETtxideftypefnnl\endcsname 7649*d5c9a868SElliott Hughes = \relax 7650*d5c9a868SElliott Hughes \else 7651*d5c9a868SElliott Hughes \errhelp = \EMsimple 7652*d5c9a868SElliott Hughes \errmessage{Unknown @txideftypefnnl value `\temp', 7653*d5c9a868SElliott Hughes must be on|off}% 7654*d5c9a868SElliott Hughes \fi\fi 7655*d5c9a868SElliott Hughes} 7656*d5c9a868SElliott Hughes 7657*d5c9a868SElliott Hughes% \dosubind {index}{topic}{subtopic} 7658*d5c9a868SElliott Hughes% 7659*d5c9a868SElliott Hughes% If SUBTOPIC is present, precede it with a space, and call \doind. 7660*d5c9a868SElliott Hughes% (At some time during the 20th century, this made a two-level entry in an 7661*d5c9a868SElliott Hughes% index such as the operation index. Nobody seemed to notice the change in 7662*d5c9a868SElliott Hughes% behaviour though.) 7663*d5c9a868SElliott Hughes\def\dosubind#1#2#3{% 7664*d5c9a868SElliott Hughes \def\thirdarg{#3}% 7665*d5c9a868SElliott Hughes \ifx\thirdarg\empty 7666*d5c9a868SElliott Hughes \doind{#1}{#2}% 7667*d5c9a868SElliott Hughes \else 7668*d5c9a868SElliott Hughes \doind{#1}{#2\space#3}% 7669*d5c9a868SElliott Hughes \fi 7670*d5c9a868SElliott Hughes} 7671*d5c9a868SElliott Hughes 7672*d5c9a868SElliott Hughes% Untyped functions: 7673*d5c9a868SElliott Hughes 7674*d5c9a868SElliott Hughes% @deffn category name args 7675*d5c9a868SElliott Hughes\makedefun{deffn}{\deffngeneral{}} 7676*d5c9a868SElliott Hughes 7677*d5c9a868SElliott Hughes% @deffn category class name args 7678*d5c9a868SElliott Hughes\makedefun{defop}#1 {\defopon{#1\ \putwordon}} 7679*d5c9a868SElliott Hughes 7680*d5c9a868SElliott Hughes% \defopon {category on}class name args 7681*d5c9a868SElliott Hughes\def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} } 7682*d5c9a868SElliott Hughes 7683*d5c9a868SElliott Hughes% \deffngeneral {subind}category name args 7684*d5c9a868SElliott Hughes% 7685*d5c9a868SElliott Hughes\def\deffngeneral#1#2 #3 #4\endheader{% 7686*d5c9a868SElliott Hughes \dosubind{fn}{\code{#3}}{#1}% 7687*d5c9a868SElliott Hughes \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}% 7688*d5c9a868SElliott Hughes} 7689*d5c9a868SElliott Hughes 7690*d5c9a868SElliott Hughes% Typed functions: 7691*d5c9a868SElliott Hughes 7692*d5c9a868SElliott Hughes% @deftypefn category type name args 7693*d5c9a868SElliott Hughes\makedefun{deftypefn}{\deftypefngeneral{}} 7694*d5c9a868SElliott Hughes 7695*d5c9a868SElliott Hughes% @deftypeop category class type name args 7696*d5c9a868SElliott Hughes\makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}} 7697*d5c9a868SElliott Hughes 7698*d5c9a868SElliott Hughes% \deftypeopon {category on}class type name args 7699*d5c9a868SElliott Hughes\def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} } 7700*d5c9a868SElliott Hughes 7701*d5c9a868SElliott Hughes% \deftypefngeneral {subind}category type name args 7702*d5c9a868SElliott Hughes% 7703*d5c9a868SElliott Hughes\def\deftypefngeneral#1#2 #3 #4 #5\endheader{% 7704*d5c9a868SElliott Hughes \dosubind{fn}{\code{#4}}{#1}% 7705*d5c9a868SElliott Hughes \doingtypefntrue 7706*d5c9a868SElliott Hughes \defname{#2}{#3}{#4}\defunargs{#5\unskip}% 7707*d5c9a868SElliott Hughes} 7708*d5c9a868SElliott Hughes 7709*d5c9a868SElliott Hughes% Typed variables: 7710*d5c9a868SElliott Hughes 7711*d5c9a868SElliott Hughes% @deftypevr category type var args 7712*d5c9a868SElliott Hughes\makedefun{deftypevr}{\deftypecvgeneral{}} 7713*d5c9a868SElliott Hughes 7714*d5c9a868SElliott Hughes% @deftypecv category class type var args 7715*d5c9a868SElliott Hughes\makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}} 7716*d5c9a868SElliott Hughes 7717*d5c9a868SElliott Hughes% \deftypecvof {category of}class type var args 7718*d5c9a868SElliott Hughes\def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} } 7719*d5c9a868SElliott Hughes 7720*d5c9a868SElliott Hughes% \deftypecvgeneral {subind}category type var args 7721*d5c9a868SElliott Hughes% 7722*d5c9a868SElliott Hughes\def\deftypecvgeneral#1#2 #3 #4 #5\endheader{% 7723*d5c9a868SElliott Hughes \dosubind{vr}{\code{#4}}{#1}% 7724*d5c9a868SElliott Hughes \defname{#2}{#3}{#4}\defunargs{#5\unskip}% 7725*d5c9a868SElliott Hughes} 7726*d5c9a868SElliott Hughes 7727*d5c9a868SElliott Hughes% Untyped variables: 7728*d5c9a868SElliott Hughes 7729*d5c9a868SElliott Hughes% @defvr category var args 7730*d5c9a868SElliott Hughes\makedefun{defvr}#1 {\deftypevrheader{#1} {} } 7731*d5c9a868SElliott Hughes 7732*d5c9a868SElliott Hughes% @defcv category class var args 7733*d5c9a868SElliott Hughes\makedefun{defcv}#1 {\defcvof{#1\ \putwordof}} 7734*d5c9a868SElliott Hughes 7735*d5c9a868SElliott Hughes% \defcvof {category of}class var args 7736*d5c9a868SElliott Hughes\def\defcvof#1#2 {\deftypecvof{#1}#2 {} } 7737*d5c9a868SElliott Hughes 7738*d5c9a868SElliott Hughes% Types: 7739*d5c9a868SElliott Hughes 7740*d5c9a868SElliott Hughes% @deftp category name args 7741*d5c9a868SElliott Hughes\makedefun{deftp}#1 #2 #3\endheader{% 7742*d5c9a868SElliott Hughes \doind{tp}{\code{#2}}% 7743*d5c9a868SElliott Hughes \defname{#1}{}{#2}\defunargs{#3\unskip}% 7744*d5c9a868SElliott Hughes} 7745*d5c9a868SElliott Hughes 7746*d5c9a868SElliott Hughes% Remaining @defun-like shortcuts: 7747*d5c9a868SElliott Hughes\makedefun{defun}{\deffnheader{\putwordDeffunc} } 7748*d5c9a868SElliott Hughes\makedefun{defmac}{\deffnheader{\putwordDefmac} } 7749*d5c9a868SElliott Hughes\makedefun{defspec}{\deffnheader{\putwordDefspec} } 7750*d5c9a868SElliott Hughes\makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} } 7751*d5c9a868SElliott Hughes\makedefun{defvar}{\defvrheader{\putwordDefvar} } 7752*d5c9a868SElliott Hughes\makedefun{defopt}{\defvrheader{\putwordDefopt} } 7753*d5c9a868SElliott Hughes\makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} } 7754*d5c9a868SElliott Hughes\makedefun{defmethod}{\defopon\putwordMethodon} 7755*d5c9a868SElliott Hughes\makedefun{deftypemethod}{\deftypeopon\putwordMethodon} 7756*d5c9a868SElliott Hughes\makedefun{defivar}{\defcvof\putwordInstanceVariableof} 7757*d5c9a868SElliott Hughes\makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof} 7758*d5c9a868SElliott Hughes 7759*d5c9a868SElliott Hughes% \defname, which formats the name of the @def (not the args). 7760*d5c9a868SElliott Hughes% #1 is the category, such as "Function". 7761*d5c9a868SElliott Hughes% #2 is the return type, if any. 7762*d5c9a868SElliott Hughes% #3 is the function name. 7763*d5c9a868SElliott Hughes% 7764*d5c9a868SElliott Hughes% We are followed by (but not passed) the arguments, if any. 7765*d5c9a868SElliott Hughes% 7766*d5c9a868SElliott Hughes\def\defname#1#2#3{% 7767*d5c9a868SElliott Hughes \par 7768*d5c9a868SElliott Hughes % Get the values of \leftskip and \rightskip as they were outside the @def... 7769*d5c9a868SElliott Hughes \advance\leftskip by -\defbodyindent 7770*d5c9a868SElliott Hughes % 7771*d5c9a868SElliott Hughes % Determine if we are typesetting the return type of a typed function 7772*d5c9a868SElliott Hughes % on a line by itself. 7773*d5c9a868SElliott Hughes \rettypeownlinefalse 7774*d5c9a868SElliott Hughes \ifdoingtypefn % doing a typed function specifically? 7775*d5c9a868SElliott Hughes % then check user option for putting return type on its own line: 7776*d5c9a868SElliott Hughes \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else 7777*d5c9a868SElliott Hughes \rettypeownlinetrue 7778*d5c9a868SElliott Hughes \fi 7779*d5c9a868SElliott Hughes \fi 7780*d5c9a868SElliott Hughes % 7781*d5c9a868SElliott Hughes % How we'll format the category name. Putting it in brackets helps 7782*d5c9a868SElliott Hughes % distinguish it from the body text that may end up on the next line 7783*d5c9a868SElliott Hughes % just below it. 7784*d5c9a868SElliott Hughes \def\temp{#1}% 7785*d5c9a868SElliott Hughes \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi} 7786*d5c9a868SElliott Hughes % 7787*d5c9a868SElliott Hughes % Figure out line sizes for the paragraph shape. We'll always have at 7788*d5c9a868SElliott Hughes % least two. 7789*d5c9a868SElliott Hughes \tempnum = 2 7790*d5c9a868SElliott Hughes % 7791*d5c9a868SElliott Hughes % The first line needs space for \box0; but if \rightskip is nonzero, 7792*d5c9a868SElliott Hughes % we need only space for the part of \box0 which exceeds it: 7793*d5c9a868SElliott Hughes \dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip 7794*d5c9a868SElliott Hughes % 7795*d5c9a868SElliott Hughes % If doing a return type on its own line, we'll have another line. 7796*d5c9a868SElliott Hughes \ifrettypeownline 7797*d5c9a868SElliott Hughes \advance\tempnum by 1 7798*d5c9a868SElliott Hughes \def\maybeshapeline{0in \hsize}% 7799*d5c9a868SElliott Hughes \else 7800*d5c9a868SElliott Hughes \def\maybeshapeline{}% 7801*d5c9a868SElliott Hughes \fi 7802*d5c9a868SElliott Hughes % 7803*d5c9a868SElliott Hughes % The continuations: 7804*d5c9a868SElliott Hughes \dimen2=\hsize \advance\dimen2 by -\defargsindent 7805*d5c9a868SElliott Hughes % 7806*d5c9a868SElliott Hughes % The final paragraph shape: 7807*d5c9a868SElliott Hughes \parshape \tempnum 0in \dimen0 \maybeshapeline \defargsindent \dimen2 7808*d5c9a868SElliott Hughes % 7809*d5c9a868SElliott Hughes % Put the category name at the right margin. 7810*d5c9a868SElliott Hughes \noindent 7811*d5c9a868SElliott Hughes \hbox to 0pt{% 7812*d5c9a868SElliott Hughes \hfil\box0 \kern-\hsize 7813*d5c9a868SElliott Hughes % \hsize has to be shortened this way: 7814*d5c9a868SElliott Hughes \kern\leftskip 7815*d5c9a868SElliott Hughes % Intentionally do not respect \rightskip, since we need the space. 7816*d5c9a868SElliott Hughes }% 7817*d5c9a868SElliott Hughes % 7818*d5c9a868SElliott Hughes % Allow all lines to be underfull without complaint: 7819*d5c9a868SElliott Hughes \tolerance=10000 \hbadness=10000 7820*d5c9a868SElliott Hughes \exdentamount=\defbodyindent 7821*d5c9a868SElliott Hughes {% 7822*d5c9a868SElliott Hughes % defun fonts. We use typewriter by default (used to be bold) because: 7823*d5c9a868SElliott Hughes % . we're printing identifiers, they should be in tt in principle. 7824*d5c9a868SElliott Hughes % . in languages with many accents, such as Czech or French, it's 7825*d5c9a868SElliott Hughes % common to leave accents off identifiers. The result looks ok in 7826*d5c9a868SElliott Hughes % tt, but exceedingly strange in rm. 7827*d5c9a868SElliott Hughes % . we don't want -- and --- to be treated as ligatures. 7828*d5c9a868SElliott Hughes % . this still does not fix the ?` and !` ligatures, but so far no 7829*d5c9a868SElliott Hughes % one has made identifiers using them :). 7830*d5c9a868SElliott Hughes \df \tt 7831*d5c9a868SElliott Hughes \def\temp{#2}% text of the return type 7832*d5c9a868SElliott Hughes \ifx\temp\empty\else 7833*d5c9a868SElliott Hughes \tclose{\temp}% typeset the return type 7834*d5c9a868SElliott Hughes \ifrettypeownline 7835*d5c9a868SElliott Hughes % put return type on its own line; prohibit line break following: 7836*d5c9a868SElliott Hughes \hfil\vadjust{\nobreak}\break 7837*d5c9a868SElliott Hughes \else 7838*d5c9a868SElliott Hughes \space % type on same line, so just followed by a space 7839*d5c9a868SElliott Hughes \fi 7840*d5c9a868SElliott Hughes \fi % no return type 7841*d5c9a868SElliott Hughes #3% output function name 7842*d5c9a868SElliott Hughes }% 7843*d5c9a868SElliott Hughes {\rm\enskip}% hskip 0.5 em of \rmfont 7844*d5c9a868SElliott Hughes % 7845*d5c9a868SElliott Hughes \boldbrax 7846*d5c9a868SElliott Hughes % arguments will be output next, if any. 7847*d5c9a868SElliott Hughes} 7848*d5c9a868SElliott Hughes 7849*d5c9a868SElliott Hughes% Print arguments in slanted roman (not ttsl), inconsistently with using 7850*d5c9a868SElliott Hughes% tt for the name. This is because literal text is sometimes needed in 7851*d5c9a868SElliott Hughes% the argument list (groff manual), and ttsl and tt are not very 7852*d5c9a868SElliott Hughes% distinguishable. Prevent hyphenation at `-' chars. 7853*d5c9a868SElliott Hughes% 7854*d5c9a868SElliott Hughes\def\defunargs#1{% 7855*d5c9a868SElliott Hughes % use sl by default (not ttsl), 7856*d5c9a868SElliott Hughes % tt for the names. 7857*d5c9a868SElliott Hughes \df \sl \hyphenchar\font=0 7858*d5c9a868SElliott Hughes % 7859*d5c9a868SElliott Hughes % On the other hand, if an argument has two dashes (for instance), we 7860*d5c9a868SElliott Hughes % want a way to get ttsl. We used to recommend @var for that, so 7861*d5c9a868SElliott Hughes % leave the code in, but it's strange for @var to lead to typewriter. 7862*d5c9a868SElliott Hughes % Nowadays we recommend @code, since the difference between a ttsl hyphen 7863*d5c9a868SElliott Hughes % and a tt hyphen is pretty tiny. @code also disables ?` !`. 7864*d5c9a868SElliott Hughes \def\var##1{{\setregularquotes\ttslanted{##1}}}% 7865*d5c9a868SElliott Hughes #1% 7866*d5c9a868SElliott Hughes \sl\hyphenchar\font=45 7867*d5c9a868SElliott Hughes} 7868*d5c9a868SElliott Hughes 7869*d5c9a868SElliott Hughes% We want ()&[] to print specially on the defun line. 7870*d5c9a868SElliott Hughes% 7871*d5c9a868SElliott Hughes\def\activeparens{% 7872*d5c9a868SElliott Hughes \catcode`\(=\active \catcode`\)=\active 7873*d5c9a868SElliott Hughes \catcode`\[=\active \catcode`\]=\active 7874*d5c9a868SElliott Hughes \catcode`\&=\active 7875*d5c9a868SElliott Hughes} 7876*d5c9a868SElliott Hughes 7877*d5c9a868SElliott Hughes% Make control sequences which act like normal parenthesis chars. 7878*d5c9a868SElliott Hughes\let\lparen = ( \let\rparen = ) 7879*d5c9a868SElliott Hughes 7880*d5c9a868SElliott Hughes% Be sure that we always have a definition for `(', etc. For example, 7881*d5c9a868SElliott Hughes% if the fn name has parens in it, \boldbrax will not be in effect yet, 7882*d5c9a868SElliott Hughes% so TeX would otherwise complain about undefined control sequence. 7883*d5c9a868SElliott Hughes{ 7884*d5c9a868SElliott Hughes \activeparens 7885*d5c9a868SElliott Hughes \global\let(=\lparen \global\let)=\rparen 7886*d5c9a868SElliott Hughes \global\let[=\lbrack \global\let]=\rbrack 7887*d5c9a868SElliott Hughes \global\let& = \& 7888*d5c9a868SElliott Hughes 7889*d5c9a868SElliott Hughes \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb} 7890*d5c9a868SElliott Hughes \gdef\magicamp{\let&=\amprm} 7891*d5c9a868SElliott Hughes} 7892*d5c9a868SElliott Hughes\let\ampchar\& 7893*d5c9a868SElliott Hughes 7894*d5c9a868SElliott Hughes\newcount\parencount 7895*d5c9a868SElliott Hughes 7896*d5c9a868SElliott Hughes% If we encounter &foo, then turn on ()-hacking afterwards 7897*d5c9a868SElliott Hughes\newif\ifampseen 7898*d5c9a868SElliott Hughes\def\amprm#1 {\ampseentrue{\bf\ }} 7899*d5c9a868SElliott Hughes 7900*d5c9a868SElliott Hughes\def\parenfont{% 7901*d5c9a868SElliott Hughes \ifampseen 7902*d5c9a868SElliott Hughes % At the first level, print parens in roman, 7903*d5c9a868SElliott Hughes % otherwise use the default font. 7904*d5c9a868SElliott Hughes \ifnum \parencount=1 \rm \fi 7905*d5c9a868SElliott Hughes \else 7906*d5c9a868SElliott Hughes % The \sf parens (in \boldbrax) actually are a little bolder than 7907*d5c9a868SElliott Hughes % the contained text. This is especially needed for [ and ] . 7908*d5c9a868SElliott Hughes \sf 7909*d5c9a868SElliott Hughes \fi 7910*d5c9a868SElliott Hughes} 7911*d5c9a868SElliott Hughes\def\infirstlevel#1{% 7912*d5c9a868SElliott Hughes \ifampseen 7913*d5c9a868SElliott Hughes \ifnum\parencount=1 7914*d5c9a868SElliott Hughes #1% 7915*d5c9a868SElliott Hughes \fi 7916*d5c9a868SElliott Hughes \fi 7917*d5c9a868SElliott Hughes} 7918*d5c9a868SElliott Hughes\def\bfafterword#1 {#1 \bf} 7919*d5c9a868SElliott Hughes 7920*d5c9a868SElliott Hughes\def\opnr{% 7921*d5c9a868SElliott Hughes \global\advance\parencount by 1 7922*d5c9a868SElliott Hughes {\parenfont(}% 7923*d5c9a868SElliott Hughes \infirstlevel \bfafterword 7924*d5c9a868SElliott Hughes} 7925*d5c9a868SElliott Hughes\def\clnr{% 7926*d5c9a868SElliott Hughes {\parenfont)}% 7927*d5c9a868SElliott Hughes \infirstlevel \sl 7928*d5c9a868SElliott Hughes \global\advance\parencount by -1 7929*d5c9a868SElliott Hughes} 7930*d5c9a868SElliott Hughes 7931*d5c9a868SElliott Hughes\newcount\brackcount 7932*d5c9a868SElliott Hughes\def\lbrb{% 7933*d5c9a868SElliott Hughes \global\advance\brackcount by 1 7934*d5c9a868SElliott Hughes {\bf[}% 7935*d5c9a868SElliott Hughes} 7936*d5c9a868SElliott Hughes\def\rbrb{% 7937*d5c9a868SElliott Hughes {\bf]}% 7938*d5c9a868SElliott Hughes \global\advance\brackcount by -1 7939*d5c9a868SElliott Hughes} 7940*d5c9a868SElliott Hughes 7941*d5c9a868SElliott Hughes\def\checkparencounts{% 7942*d5c9a868SElliott Hughes \ifnum\parencount=0 \else \badparencount \fi 7943*d5c9a868SElliott Hughes \ifnum\brackcount=0 \else \badbrackcount \fi 7944*d5c9a868SElliott Hughes} 7945*d5c9a868SElliott Hughes% these should not use \errmessage; the glibc manual, at least, actually 7946*d5c9a868SElliott Hughes% has such constructs (when documenting function pointers). 7947*d5c9a868SElliott Hughes\def\badparencount{% 7948*d5c9a868SElliott Hughes \message{Warning: unbalanced parentheses in @def...}% 7949*d5c9a868SElliott Hughes \global\parencount=0 7950*d5c9a868SElliott Hughes} 7951*d5c9a868SElliott Hughes\def\badbrackcount{% 7952*d5c9a868SElliott Hughes \message{Warning: unbalanced square brackets in @def...}% 7953*d5c9a868SElliott Hughes \global\brackcount=0 7954*d5c9a868SElliott Hughes} 7955*d5c9a868SElliott Hughes 7956*d5c9a868SElliott Hughes 7957*d5c9a868SElliott Hughes\message{macros,} 7958*d5c9a868SElliott Hughes% @macro. 7959*d5c9a868SElliott Hughes 7960*d5c9a868SElliott Hughes% To do this right we need a feature of e-TeX, \scantokens, 7961*d5c9a868SElliott Hughes% which we arrange to emulate with a temporary file in ordinary TeX. 7962*d5c9a868SElliott Hughes\ifx\eTeXversion\thisisundefined 7963*d5c9a868SElliott Hughes \newwrite\macscribble 7964*d5c9a868SElliott Hughes \def\scantokens#1{% 7965*d5c9a868SElliott Hughes \toks0={#1}% 7966*d5c9a868SElliott Hughes \immediate\openout\macscribble=\jobname.tmp 7967*d5c9a868SElliott Hughes \immediate\write\macscribble{\the\toks0}% 7968*d5c9a868SElliott Hughes \immediate\closeout\macscribble 7969*d5c9a868SElliott Hughes \input \jobname.tmp 7970*d5c9a868SElliott Hughes } 7971*d5c9a868SElliott Hughes\fi 7972*d5c9a868SElliott Hughes 7973*d5c9a868SElliott Hughes\let\E=\expandafter 7974*d5c9a868SElliott Hughes 7975*d5c9a868SElliott Hughes% Used at the time of macro expansion. 7976*d5c9a868SElliott Hughes% Argument is macro body with arguments substituted 7977*d5c9a868SElliott Hughes\def\scanmacro#1{% 7978*d5c9a868SElliott Hughes \newlinechar`\^^M 7979*d5c9a868SElliott Hughes % expand the expansion of \eatleadingcr twice to maybe remove a leading 7980*d5c9a868SElliott Hughes % newline (and \else and \fi tokens), then call \eatspaces on the result. 7981*d5c9a868SElliott Hughes \def\xeatspaces##1{% 7982*d5c9a868SElliott Hughes \E\E\E\E\E\E\E\eatspaces\E\E\E\E\E\E\E{\eatleadingcr##1% 7983*d5c9a868SElliott Hughes }}% 7984*d5c9a868SElliott Hughes \def\xempty##1{}% 7985*d5c9a868SElliott Hughes % 7986*d5c9a868SElliott Hughes % Process the macro body under the current catcode regime. 7987*d5c9a868SElliott Hughes \scantokens{#1@comment}% 7988*d5c9a868SElliott Hughes % 7989*d5c9a868SElliott Hughes % The \comment is to remove the \newlinechar added by \scantokens, and 7990*d5c9a868SElliott Hughes % can be noticed by \parsearg. Note \c isn't used because this means cedilla 7991*d5c9a868SElliott Hughes % in math mode. 7992*d5c9a868SElliott Hughes} 7993*d5c9a868SElliott Hughes 7994*d5c9a868SElliott Hughes% Used for copying and captions 7995*d5c9a868SElliott Hughes\def\scanexp#1{% 7996*d5c9a868SElliott Hughes \expandafter\scanmacro\expandafter{#1}% 7997*d5c9a868SElliott Hughes} 7998*d5c9a868SElliott Hughes 7999*d5c9a868SElliott Hughes\newcount\paramno % Count of parameters 8000*d5c9a868SElliott Hughes\newtoks\macname % Macro name 8001*d5c9a868SElliott Hughes\newif\ifrecursive % Is it recursive? 8002*d5c9a868SElliott Hughes 8003*d5c9a868SElliott Hughes% List of all defined macros in the form 8004*d5c9a868SElliott Hughes% \commondummyword\macro1\commondummyword\macro2... 8005*d5c9a868SElliott Hughes% Currently is also contains all @aliases; the list can be split 8006*d5c9a868SElliott Hughes% if there is a need. 8007*d5c9a868SElliott Hughes\def\macrolist{} 8008*d5c9a868SElliott Hughes 8009*d5c9a868SElliott Hughes% Add the macro to \macrolist 8010*d5c9a868SElliott Hughes\def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname} 8011*d5c9a868SElliott Hughes\def\addtomacrolistxxx#1{% 8012*d5c9a868SElliott Hughes \toks0 = \expandafter{\macrolist\commondummyword#1}% 8013*d5c9a868SElliott Hughes \xdef\macrolist{\the\toks0}% 8014*d5c9a868SElliott Hughes} 8015*d5c9a868SElliott Hughes 8016*d5c9a868SElliott Hughes% Utility routines. 8017*d5c9a868SElliott Hughes% This does \let #1 = #2, with \csnames; that is, 8018*d5c9a868SElliott Hughes% \let \csname#1\endcsname = \csname#2\endcsname 8019*d5c9a868SElliott Hughes% (except of course we have to play expansion games). 8020*d5c9a868SElliott Hughes% 8021*d5c9a868SElliott Hughes\def\cslet#1#2{% 8022*d5c9a868SElliott Hughes \expandafter\let 8023*d5c9a868SElliott Hughes \csname#1\expandafter\endcsname 8024*d5c9a868SElliott Hughes \csname#2\endcsname 8025*d5c9a868SElliott Hughes} 8026*d5c9a868SElliott Hughes 8027*d5c9a868SElliott Hughes% Trim leading and trailing spaces off a string. 8028*d5c9a868SElliott Hughes% Concepts from aro-bend problem 15 (see CTAN). 8029*d5c9a868SElliott Hughes{\catcode`\@=11 8030*d5c9a868SElliott Hughes\gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }} 8031*d5c9a868SElliott Hughes\gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@} 8032*d5c9a868SElliott Hughes\gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @} 8033*d5c9a868SElliott Hughes\def\unbrace#1{#1} 8034*d5c9a868SElliott Hughes\unbrace{\gdef\trim@@@ #1 } #2@{#1} 8035*d5c9a868SElliott Hughes} 8036*d5c9a868SElliott Hughes 8037*d5c9a868SElliott Hughes{\catcode`\^^M=\other% 8038*d5c9a868SElliott Hughes\gdef\eatleadingcr#1{\if\noexpand#1\noexpand^^M\else\E#1\fi}}% 8039*d5c9a868SElliott Hughes% Warning: this won't work for a delimited argument 8040*d5c9a868SElliott Hughes% or for an empty argument 8041*d5c9a868SElliott Hughes 8042*d5c9a868SElliott Hughes% Trim a single trailing ^^M off a string. 8043*d5c9a868SElliott Hughes{\catcode`\^^M=\other \catcode`\Q=3% 8044*d5c9a868SElliott Hughes\gdef\eatcr #1{\eatcra #1Q^^MQ}% 8045*d5c9a868SElliott Hughes\gdef\eatcra#1^^MQ{\eatcrb#1Q}% 8046*d5c9a868SElliott Hughes\gdef\eatcrb#1Q#2Q{#1}% 8047*d5c9a868SElliott Hughes} 8048*d5c9a868SElliott Hughes 8049*d5c9a868SElliott Hughes% Macro bodies are absorbed as an argument in a context where 8050*d5c9a868SElliott Hughes% all characters are catcode 10, 11 or 12, except \ which is active 8051*d5c9a868SElliott Hughes% (as in normal texinfo). It is necessary to change the definition of \ 8052*d5c9a868SElliott Hughes% to recognize macro arguments; this is the job of \mbodybackslash. 8053*d5c9a868SElliott Hughes% 8054*d5c9a868SElliott Hughes% Non-ASCII encodings make 8-bit characters active, so un-activate 8055*d5c9a868SElliott Hughes% them to avoid their expansion. Must do this non-globally, to 8056*d5c9a868SElliott Hughes% confine the change to the current group. 8057*d5c9a868SElliott Hughes% 8058*d5c9a868SElliott Hughes% It's necessary to have hard CRs when the macro is executed. This is 8059*d5c9a868SElliott Hughes% done by making ^^M (\endlinechar) catcode 12 when reading the macro 8060*d5c9a868SElliott Hughes% body, and then making it the \newlinechar in \scanmacro. 8061*d5c9a868SElliott Hughes% 8062*d5c9a868SElliott Hughes\def\scanctxt{% used as subroutine 8063*d5c9a868SElliott Hughes \catcode`\"=\other 8064*d5c9a868SElliott Hughes \catcode`\+=\other 8065*d5c9a868SElliott Hughes \catcode`\<=\other 8066*d5c9a868SElliott Hughes \catcode`\>=\other 8067*d5c9a868SElliott Hughes \catcode`\^=\other 8068*d5c9a868SElliott Hughes \catcode`\_=\other 8069*d5c9a868SElliott Hughes \catcode`\|=\other 8070*d5c9a868SElliott Hughes \catcode`\~=\other 8071*d5c9a868SElliott Hughes \passthroughcharstrue 8072*d5c9a868SElliott Hughes} 8073*d5c9a868SElliott Hughes 8074*d5c9a868SElliott Hughes\def\scanargctxt{% used for copying and captions, not macros. 8075*d5c9a868SElliott Hughes \scanctxt 8076*d5c9a868SElliott Hughes \catcode`\@=\other 8077*d5c9a868SElliott Hughes \catcode`\\=\other 8078*d5c9a868SElliott Hughes \catcode`\^^M=\other 8079*d5c9a868SElliott Hughes} 8080*d5c9a868SElliott Hughes 8081*d5c9a868SElliott Hughes\def\macrobodyctxt{% used for @macro definitions 8082*d5c9a868SElliott Hughes \scanctxt 8083*d5c9a868SElliott Hughes \catcode`\ =\other 8084*d5c9a868SElliott Hughes \catcode`\@=\other 8085*d5c9a868SElliott Hughes \catcode`\{=\other 8086*d5c9a868SElliott Hughes \catcode`\}=\other 8087*d5c9a868SElliott Hughes \catcode`\^^M=\other 8088*d5c9a868SElliott Hughes \usembodybackslash 8089*d5c9a868SElliott Hughes} 8090*d5c9a868SElliott Hughes 8091*d5c9a868SElliott Hughes% Used when scanning braced macro arguments. Note, however, that catcode 8092*d5c9a868SElliott Hughes% changes here are ineffectual if the macro invocation was nested inside 8093*d5c9a868SElliott Hughes% an argument to another Texinfo command. 8094*d5c9a868SElliott Hughes\def\macroargctxt{% 8095*d5c9a868SElliott Hughes \scanctxt 8096*d5c9a868SElliott Hughes \catcode`\ =\active 8097*d5c9a868SElliott Hughes \catcode`\@=\other 8098*d5c9a868SElliott Hughes \catcode`\^^M=\other 8099*d5c9a868SElliott Hughes \catcode`\\=\active 8100*d5c9a868SElliott Hughes} 8101*d5c9a868SElliott Hughes 8102*d5c9a868SElliott Hughes\def\macrolineargctxt{% used for whole-line arguments without braces 8103*d5c9a868SElliott Hughes \scanctxt 8104*d5c9a868SElliott Hughes \catcode`\@=\other 8105*d5c9a868SElliott Hughes \catcode`\{=\other 8106*d5c9a868SElliott Hughes \catcode`\}=\other 8107*d5c9a868SElliott Hughes} 8108*d5c9a868SElliott Hughes 8109*d5c9a868SElliott Hughes% \mbodybackslash is the definition of \ in @macro bodies. 8110*d5c9a868SElliott Hughes% It maps \foo\ => \csname macarg.foo\endcsname => #N 8111*d5c9a868SElliott Hughes% where N is the macro parameter number. 8112*d5c9a868SElliott Hughes% We define \csname macarg.\endcsname to be \realbackslash, so 8113*d5c9a868SElliott Hughes% \\ in macro replacement text gets you a backslash. 8114*d5c9a868SElliott Hughes% 8115*d5c9a868SElliott Hughes{\catcode`@=0 @catcode`@\=@active 8116*d5c9a868SElliott Hughes @gdef@usembodybackslash{@let\=@mbodybackslash} 8117*d5c9a868SElliott Hughes @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname} 8118*d5c9a868SElliott Hughes} 8119*d5c9a868SElliott Hughes\expandafter\def\csname macarg.\endcsname{\realbackslash} 8120*d5c9a868SElliott Hughes 8121*d5c9a868SElliott Hughes\def\margbackslash#1{\char`\#1 } 8122*d5c9a868SElliott Hughes 8123*d5c9a868SElliott Hughes\def\macro{\recursivefalse\parsearg\macroxxx} 8124*d5c9a868SElliott Hughes\def\rmacro{\recursivetrue\parsearg\macroxxx} 8125*d5c9a868SElliott Hughes 8126*d5c9a868SElliott Hughes\def\macroxxx#1{% 8127*d5c9a868SElliott Hughes \getargs{#1}% now \macname is the macname and \argl the arglist 8128*d5c9a868SElliott Hughes \ifx\argl\empty % no arguments 8129*d5c9a868SElliott Hughes \paramno=0\relax 8130*d5c9a868SElliott Hughes \else 8131*d5c9a868SElliott Hughes \expandafter\parsemargdef \argl;% 8132*d5c9a868SElliott Hughes \if\paramno>256\relax 8133*d5c9a868SElliott Hughes \ifx\eTeXversion\thisisundefined 8134*d5c9a868SElliott Hughes \errhelp = \EMsimple 8135*d5c9a868SElliott Hughes \errmessage{You need eTeX to compile a file with macros with more than 256 arguments} 8136*d5c9a868SElliott Hughes \fi 8137*d5c9a868SElliott Hughes \fi 8138*d5c9a868SElliott Hughes \fi 8139*d5c9a868SElliott Hughes \if1\csname ismacro.\the\macname\endcsname 8140*d5c9a868SElliott Hughes \message{Warning: redefining \the\macname}% 8141*d5c9a868SElliott Hughes \else 8142*d5c9a868SElliott Hughes \expandafter\ifx\csname \the\macname\endcsname \relax 8143*d5c9a868SElliott Hughes \else \errmessage{Macro name \the\macname\space already defined}\fi 8144*d5c9a868SElliott Hughes \global\cslet{macsave.\the\macname}{\the\macname}% 8145*d5c9a868SElliott Hughes \global\expandafter\let\csname ismacro.\the\macname\endcsname=1% 8146*d5c9a868SElliott Hughes \addtomacrolist{\the\macname}% 8147*d5c9a868SElliott Hughes \fi 8148*d5c9a868SElliott Hughes \begingroup \macrobodyctxt 8149*d5c9a868SElliott Hughes \ifrecursive \expandafter\parsermacbody 8150*d5c9a868SElliott Hughes \else \expandafter\parsemacbody 8151*d5c9a868SElliott Hughes \fi} 8152*d5c9a868SElliott Hughes 8153*d5c9a868SElliott Hughes\parseargdef\unmacro{% 8154*d5c9a868SElliott Hughes \if1\csname ismacro.#1\endcsname 8155*d5c9a868SElliott Hughes \global\cslet{#1}{macsave.#1}% 8156*d5c9a868SElliott Hughes \global\expandafter\let \csname ismacro.#1\endcsname=0% 8157*d5c9a868SElliott Hughes % Remove the macro name from \macrolist: 8158*d5c9a868SElliott Hughes \begingroup 8159*d5c9a868SElliott Hughes \expandafter\let\csname#1\endcsname \relax 8160*d5c9a868SElliott Hughes \let\commondummyword\unmacrodo 8161*d5c9a868SElliott Hughes \xdef\macrolist{\macrolist}% 8162*d5c9a868SElliott Hughes \endgroup 8163*d5c9a868SElliott Hughes \else 8164*d5c9a868SElliott Hughes \errmessage{Macro #1 not defined}% 8165*d5c9a868SElliott Hughes \fi 8166*d5c9a868SElliott Hughes} 8167*d5c9a868SElliott Hughes 8168*d5c9a868SElliott Hughes% Called by \do from \dounmacro on each macro. The idea is to omit any 8169*d5c9a868SElliott Hughes% macro definitions that have been changed to \relax. 8170*d5c9a868SElliott Hughes% 8171*d5c9a868SElliott Hughes\def\unmacrodo#1{% 8172*d5c9a868SElliott Hughes \ifx #1\relax 8173*d5c9a868SElliott Hughes % remove this 8174*d5c9a868SElliott Hughes \else 8175*d5c9a868SElliott Hughes \noexpand\commondummyword \noexpand#1% 8176*d5c9a868SElliott Hughes \fi 8177*d5c9a868SElliott Hughes} 8178*d5c9a868SElliott Hughes 8179*d5c9a868SElliott Hughes% \getargs -- Parse the arguments to a @macro line. Set \macname to 8180*d5c9a868SElliott Hughes% the name of the macro, and \argl to the braced argument list. 8181*d5c9a868SElliott Hughes\def\getargs#1{\getargsxxx#1{}} 8182*d5c9a868SElliott Hughes\def\getargsxxx#1#{\getmacname #1 \relax\getmacargs} 8183*d5c9a868SElliott Hughes\def\getmacname#1 #2\relax{\macname={#1}} 8184*d5c9a868SElliott Hughes\def\getmacargs#1{\def\argl{#1}} 8185*d5c9a868SElliott Hughes% This made use of the feature that if the last token of a 8186*d5c9a868SElliott Hughes% <parameter list> is #, then the preceding argument is delimited by 8187*d5c9a868SElliott Hughes% an opening brace, and that opening brace is not consumed. 8188*d5c9a868SElliott Hughes 8189*d5c9a868SElliott Hughes% Parse the optional {params} list to @macro or @rmacro. 8190*d5c9a868SElliott Hughes% Set \paramno to the number of arguments, 8191*d5c9a868SElliott Hughes% and \paramlist to a parameter text for the macro (e.g. #1,#2,#3 for a 8192*d5c9a868SElliott Hughes% three-param macro.) Define \macarg.BLAH for each BLAH in the params 8193*d5c9a868SElliott Hughes% list to some hook where the argument is to be expanded. If there are 8194*d5c9a868SElliott Hughes% less than 10 arguments that hook is to be replaced by ##N where N 8195*d5c9a868SElliott Hughes% is the position in that list, that is to say the macro arguments are to be 8196*d5c9a868SElliott Hughes% defined `a la TeX in the macro body. 8197*d5c9a868SElliott Hughes% 8198*d5c9a868SElliott Hughes% That gets used by \mbodybackslash (above). 8199*d5c9a868SElliott Hughes% 8200*d5c9a868SElliott Hughes% If there are 10 or more arguments, a different technique is used: see 8201*d5c9a868SElliott Hughes% \parsemmanyargdef. 8202*d5c9a868SElliott Hughes% 8203*d5c9a868SElliott Hughes\def\parsemargdef#1;{% 8204*d5c9a868SElliott Hughes \paramno=0\def\paramlist{}% 8205*d5c9a868SElliott Hughes \let\hash\relax 8206*d5c9a868SElliott Hughes % \hash is redefined to `#' later to get it into definitions 8207*d5c9a868SElliott Hughes \let\xeatspaces\relax 8208*d5c9a868SElliott Hughes \let\xempty\relax 8209*d5c9a868SElliott Hughes \parsemargdefxxx#1,;,% 8210*d5c9a868SElliott Hughes \ifnum\paramno<10\relax\else 8211*d5c9a868SElliott Hughes \paramno0\relax 8212*d5c9a868SElliott Hughes \parsemmanyargdef@@#1,;,% 10 or more arguments 8213*d5c9a868SElliott Hughes \fi 8214*d5c9a868SElliott Hughes} 8215*d5c9a868SElliott Hughes\def\parsemargdefxxx#1,{% 8216*d5c9a868SElliott Hughes \if#1;\let\next=\relax 8217*d5c9a868SElliott Hughes \else \let\next=\parsemargdefxxx 8218*d5c9a868SElliott Hughes \advance\paramno by 1 8219*d5c9a868SElliott Hughes \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname 8220*d5c9a868SElliott Hughes {\xeatspaces{\hash\the\paramno\noexpand\xempty{}}}% 8221*d5c9a868SElliott Hughes \edef\paramlist{\paramlist\hash\the\paramno,}% 8222*d5c9a868SElliott Hughes \fi\next} 8223*d5c9a868SElliott Hughes% the \xempty{} is to give \eatleadingcr an argument in the case of an 8224*d5c9a868SElliott Hughes% empty macro argument. 8225*d5c9a868SElliott Hughes 8226*d5c9a868SElliott Hughes% \parsemacbody, \parsermacbody 8227*d5c9a868SElliott Hughes% 8228*d5c9a868SElliott Hughes% Read recursive and nonrecursive macro bodies. (They're different since 8229*d5c9a868SElliott Hughes% rec and nonrec macros end differently.) 8230*d5c9a868SElliott Hughes% 8231*d5c9a868SElliott Hughes% We are in \macrobodyctxt, and the \xdef causes backslashshes in the macro 8232*d5c9a868SElliott Hughes% body to be transformed. 8233*d5c9a868SElliott Hughes% Set \macrobody to the body of the macro, and call \defmacro. 8234*d5c9a868SElliott Hughes% 8235*d5c9a868SElliott Hughes{\catcode`\ =\other\long\gdef\parsemacbody#1@end macro{% 8236*d5c9a868SElliott Hughes\xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}% 8237*d5c9a868SElliott Hughes{\catcode`\ =\other\long\gdef\parsermacbody#1@end rmacro{% 8238*d5c9a868SElliott Hughes\xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}% 8239*d5c9a868SElliott Hughes 8240*d5c9a868SElliott Hughes% Make @ a letter, so that we can make private-to-Texinfo macro names. 8241*d5c9a868SElliott Hughes\edef\texiatcatcode{\the\catcode`\@} 8242*d5c9a868SElliott Hughes\catcode `@=11\relax 8243*d5c9a868SElliott Hughes 8244*d5c9a868SElliott Hughes%%%%%%%%%%%%%% Code for > 10 arguments only %%%%%%%%%%%%%%%%%% 8245*d5c9a868SElliott Hughes 8246*d5c9a868SElliott Hughes% If there are 10 or more arguments, a different technique is used, where the 8247*d5c9a868SElliott Hughes% hook remains in the body, and when macro is to be expanded the body is 8248*d5c9a868SElliott Hughes% processed again to replace the arguments. 8249*d5c9a868SElliott Hughes% 8250*d5c9a868SElliott Hughes% In that case, the hook is \the\toks N-1, and we simply set \toks N-1 to the 8251*d5c9a868SElliott Hughes% argument N value and then \edef the body (nothing else will expand because of 8252*d5c9a868SElliott Hughes% the catcode regime under which the body was input). 8253*d5c9a868SElliott Hughes% 8254*d5c9a868SElliott Hughes% If you compile with TeX (not eTeX), and you have macros with 10 or more 8255*d5c9a868SElliott Hughes% arguments, no macro can have more than 256 arguments (else error). 8256*d5c9a868SElliott Hughes% 8257*d5c9a868SElliott Hughes% In case that there are 10 or more arguments we parse again the arguments 8258*d5c9a868SElliott Hughes% list to set new definitions for the \macarg.BLAH macros corresponding to 8259*d5c9a868SElliott Hughes% each BLAH argument. It was anyhow needed to parse already once this list 8260*d5c9a868SElliott Hughes% in order to count the arguments, and as macros with at most 9 arguments 8261*d5c9a868SElliott Hughes% are by far more frequent than macro with 10 or more arguments, defining 8262*d5c9a868SElliott Hughes% twice the \macarg.BLAH macros does not cost too much processing power. 8263*d5c9a868SElliott Hughes\def\parsemmanyargdef@@#1,{% 8264*d5c9a868SElliott Hughes \if#1;\let\next=\relax 8265*d5c9a868SElliott Hughes \else 8266*d5c9a868SElliott Hughes \let\next=\parsemmanyargdef@@ 8267*d5c9a868SElliott Hughes \edef\tempb{\eatspaces{#1}}% 8268*d5c9a868SElliott Hughes \expandafter\def\expandafter\tempa 8269*d5c9a868SElliott Hughes \expandafter{\csname macarg.\tempb\endcsname}% 8270*d5c9a868SElliott Hughes % Note that we need some extra \noexpand\noexpand, this is because we 8271*d5c9a868SElliott Hughes % don't want \the to be expanded in the \parsermacbody as it uses an 8272*d5c9a868SElliott Hughes % \xdef . 8273*d5c9a868SElliott Hughes \expandafter\edef\tempa 8274*d5c9a868SElliott Hughes {\noexpand\noexpand\noexpand\the\toks\the\paramno}% 8275*d5c9a868SElliott Hughes \advance\paramno by 1\relax 8276*d5c9a868SElliott Hughes \fi\next} 8277*d5c9a868SElliott Hughes 8278*d5c9a868SElliott Hughes 8279*d5c9a868SElliott Hughes\let\endargs@\relax 8280*d5c9a868SElliott Hughes\let\nil@\relax 8281*d5c9a868SElliott Hughes\def\nilm@{\nil@}% 8282*d5c9a868SElliott Hughes\long\def\nillm@{\nil@}% 8283*d5c9a868SElliott Hughes 8284*d5c9a868SElliott Hughes% This macro is expanded during the Texinfo macro expansion, not during its 8285*d5c9a868SElliott Hughes% definition. It gets all the arguments' values and assigns them to macros 8286*d5c9a868SElliott Hughes% macarg.ARGNAME 8287*d5c9a868SElliott Hughes% 8288*d5c9a868SElliott Hughes% #1 is the macro name 8289*d5c9a868SElliott Hughes% #2 is the list of argument names 8290*d5c9a868SElliott Hughes% #3 is the list of argument values 8291*d5c9a868SElliott Hughes\def\getargvals@#1#2#3{% 8292*d5c9a868SElliott Hughes \def\macargdeflist@{}% 8293*d5c9a868SElliott Hughes \def\saveparamlist@{#2}% Need to keep a copy for parameter expansion. 8294*d5c9a868SElliott Hughes \def\paramlist{#2,\nil@}% 8295*d5c9a868SElliott Hughes \def\macroname{#1}% 8296*d5c9a868SElliott Hughes \begingroup 8297*d5c9a868SElliott Hughes \macroargctxt 8298*d5c9a868SElliott Hughes \def\argvaluelist{#3,\nil@}% 8299*d5c9a868SElliott Hughes \def\@tempa{#3}% 8300*d5c9a868SElliott Hughes \ifx\@tempa\empty 8301*d5c9a868SElliott Hughes \setemptyargvalues@ 8302*d5c9a868SElliott Hughes \else 8303*d5c9a868SElliott Hughes \getargvals@@ 8304*d5c9a868SElliott Hughes \fi 8305*d5c9a868SElliott Hughes} 8306*d5c9a868SElliott Hughes\def\getargvals@@{% 8307*d5c9a868SElliott Hughes \ifx\paramlist\nilm@ 8308*d5c9a868SElliott Hughes % Some sanity check needed here that \argvaluelist is also empty. 8309*d5c9a868SElliott Hughes \ifx\argvaluelist\nillm@ 8310*d5c9a868SElliott Hughes \else 8311*d5c9a868SElliott Hughes \errhelp = \EMsimple 8312*d5c9a868SElliott Hughes \errmessage{Too many arguments in macro `\macroname'!}% 8313*d5c9a868SElliott Hughes \fi 8314*d5c9a868SElliott Hughes \let\next\macargexpandinbody@ 8315*d5c9a868SElliott Hughes \else 8316*d5c9a868SElliott Hughes \ifx\argvaluelist\nillm@ 8317*d5c9a868SElliott Hughes % No more arguments values passed to macro. Set remaining named-arg 8318*d5c9a868SElliott Hughes % macros to empty. 8319*d5c9a868SElliott Hughes \let\next\setemptyargvalues@ 8320*d5c9a868SElliott Hughes \else 8321*d5c9a868SElliott Hughes % pop current arg name into \@tempb 8322*d5c9a868SElliott Hughes \def\@tempa##1{\pop@{\@tempb}{\paramlist}##1\endargs@}% 8323*d5c9a868SElliott Hughes \expandafter\@tempa\expandafter{\paramlist}% 8324*d5c9a868SElliott Hughes % pop current argument value into \@tempc 8325*d5c9a868SElliott Hughes \def\@tempa##1{\longpop@{\@tempc}{\argvaluelist}##1\endargs@}% 8326*d5c9a868SElliott Hughes \expandafter\@tempa\expandafter{\argvaluelist}% 8327*d5c9a868SElliott Hughes % Here \@tempb is the current arg name and \@tempc is the current arg value. 8328*d5c9a868SElliott Hughes % First place the new argument macro definition into \@tempd 8329*d5c9a868SElliott Hughes \expandafter\macname\expandafter{\@tempc}% 8330*d5c9a868SElliott Hughes \expandafter\let\csname macarg.\@tempb\endcsname\relax 8331*d5c9a868SElliott Hughes \expandafter\def\expandafter\@tempe\expandafter{% 8332*d5c9a868SElliott Hughes \csname macarg.\@tempb\endcsname}% 8333*d5c9a868SElliott Hughes \edef\@tempd{\long\def\@tempe{\the\macname}}% 8334*d5c9a868SElliott Hughes \push@\@tempd\macargdeflist@ 8335*d5c9a868SElliott Hughes \let\next\getargvals@@ 8336*d5c9a868SElliott Hughes \fi 8337*d5c9a868SElliott Hughes \fi 8338*d5c9a868SElliott Hughes \next 8339*d5c9a868SElliott Hughes} 8340*d5c9a868SElliott Hughes 8341*d5c9a868SElliott Hughes\def\push@#1#2{% 8342*d5c9a868SElliott Hughes \expandafter\expandafter\expandafter\def 8343*d5c9a868SElliott Hughes \expandafter\expandafter\expandafter#2% 8344*d5c9a868SElliott Hughes \expandafter\expandafter\expandafter{% 8345*d5c9a868SElliott Hughes \expandafter#1#2}% 8346*d5c9a868SElliott Hughes} 8347*d5c9a868SElliott Hughes 8348*d5c9a868SElliott Hughes% Replace arguments by their values in the macro body, and place the result 8349*d5c9a868SElliott Hughes% in macro \@tempa. 8350*d5c9a868SElliott Hughes% 8351*d5c9a868SElliott Hughes\def\macvalstoargs@{% 8352*d5c9a868SElliott Hughes % To do this we use the property that token registers that are \the'ed 8353*d5c9a868SElliott Hughes % within an \edef expand only once. So we are going to place all argument 8354*d5c9a868SElliott Hughes % values into respective token registers. 8355*d5c9a868SElliott Hughes % 8356*d5c9a868SElliott Hughes % First we save the token context, and initialize argument numbering. 8357*d5c9a868SElliott Hughes \begingroup 8358*d5c9a868SElliott Hughes \paramno0\relax 8359*d5c9a868SElliott Hughes % Then, for each argument number #N, we place the corresponding argument 8360*d5c9a868SElliott Hughes % value into a new token list register \toks#N 8361*d5c9a868SElliott Hughes \expandafter\putargsintokens@\saveparamlist@,;,% 8362*d5c9a868SElliott Hughes % Then, we expand the body so that argument are replaced by their 8363*d5c9a868SElliott Hughes % values. The trick for values not to be expanded themselves is that they 8364*d5c9a868SElliott Hughes % are within tokens and that tokens expand only once in an \edef . 8365*d5c9a868SElliott Hughes \edef\@tempc{\csname mac.\macroname .body\endcsname}% 8366*d5c9a868SElliott Hughes % Now we restore the token stack pointer to free the token list registers 8367*d5c9a868SElliott Hughes % which we have used, but we make sure that expanded body is saved after 8368*d5c9a868SElliott Hughes % group. 8369*d5c9a868SElliott Hughes \expandafter 8370*d5c9a868SElliott Hughes \endgroup 8371*d5c9a868SElliott Hughes \expandafter\def\expandafter\@tempa\expandafter{\@tempc}% 8372*d5c9a868SElliott Hughes } 8373*d5c9a868SElliott Hughes 8374*d5c9a868SElliott Hughes% Define the named-macro outside of this group and then close this group. 8375*d5c9a868SElliott Hughes% 8376*d5c9a868SElliott Hughes\def\macargexpandinbody@{% 8377*d5c9a868SElliott Hughes \expandafter 8378*d5c9a868SElliott Hughes \endgroup 8379*d5c9a868SElliott Hughes \macargdeflist@ 8380*d5c9a868SElliott Hughes % First the replace in body the macro arguments by their values, the result 8381*d5c9a868SElliott Hughes % is in \@tempa . 8382*d5c9a868SElliott Hughes \macvalstoargs@ 8383*d5c9a868SElliott Hughes % Then we point at the \norecurse or \gobble (for recursive) macro value 8384*d5c9a868SElliott Hughes % with \@tempb . 8385*d5c9a868SElliott Hughes \expandafter\let\expandafter\@tempb\csname mac.\macroname .recurse\endcsname 8386*d5c9a868SElliott Hughes % Depending on whether it is recursive or not, we need some tailing 8387*d5c9a868SElliott Hughes % \egroup . 8388*d5c9a868SElliott Hughes \ifx\@tempb\gobble 8389*d5c9a868SElliott Hughes \let\@tempc\relax 8390*d5c9a868SElliott Hughes \else 8391*d5c9a868SElliott Hughes \let\@tempc\egroup 8392*d5c9a868SElliott Hughes \fi 8393*d5c9a868SElliott Hughes % And now we do the real job: 8394*d5c9a868SElliott Hughes \edef\@tempd{\noexpand\@tempb{\macroname}\noexpand\scanmacro{\@tempa}\@tempc}% 8395*d5c9a868SElliott Hughes \@tempd 8396*d5c9a868SElliott Hughes} 8397*d5c9a868SElliott Hughes 8398*d5c9a868SElliott Hughes\def\putargsintokens@#1,{% 8399*d5c9a868SElliott Hughes \if#1;\let\next\relax 8400*d5c9a868SElliott Hughes \else 8401*d5c9a868SElliott Hughes \let\next\putargsintokens@ 8402*d5c9a868SElliott Hughes % First we allocate the new token list register, and give it a temporary 8403*d5c9a868SElliott Hughes % alias \@tempb . 8404*d5c9a868SElliott Hughes \toksdef\@tempb\the\paramno 8405*d5c9a868SElliott Hughes % Then we place the argument value into that token list register. 8406*d5c9a868SElliott Hughes \expandafter\let\expandafter\@tempa\csname macarg.#1\endcsname 8407*d5c9a868SElliott Hughes \expandafter\@tempb\expandafter{\@tempa}% 8408*d5c9a868SElliott Hughes \advance\paramno by 1\relax 8409*d5c9a868SElliott Hughes \fi 8410*d5c9a868SElliott Hughes \next 8411*d5c9a868SElliott Hughes} 8412*d5c9a868SElliott Hughes 8413*d5c9a868SElliott Hughes% Trailing missing arguments are set to empty. 8414*d5c9a868SElliott Hughes% 8415*d5c9a868SElliott Hughes\def\setemptyargvalues@{% 8416*d5c9a868SElliott Hughes \ifx\paramlist\nilm@ 8417*d5c9a868SElliott Hughes \let\next\macargexpandinbody@ 8418*d5c9a868SElliott Hughes \else 8419*d5c9a868SElliott Hughes \expandafter\setemptyargvaluesparser@\paramlist\endargs@ 8420*d5c9a868SElliott Hughes \let\next\setemptyargvalues@ 8421*d5c9a868SElliott Hughes \fi 8422*d5c9a868SElliott Hughes \next 8423*d5c9a868SElliott Hughes} 8424*d5c9a868SElliott Hughes 8425*d5c9a868SElliott Hughes\def\setemptyargvaluesparser@#1,#2\endargs@{% 8426*d5c9a868SElliott Hughes \expandafter\def\expandafter\@tempa\expandafter{% 8427*d5c9a868SElliott Hughes \expandafter\def\csname macarg.#1\endcsname{}}% 8428*d5c9a868SElliott Hughes \push@\@tempa\macargdeflist@ 8429*d5c9a868SElliott Hughes \def\paramlist{#2}% 8430*d5c9a868SElliott Hughes} 8431*d5c9a868SElliott Hughes 8432*d5c9a868SElliott Hughes% #1 is the element target macro 8433*d5c9a868SElliott Hughes% #2 is the list macro 8434*d5c9a868SElliott Hughes% #3,#4\endargs@ is the list value 8435*d5c9a868SElliott Hughes\def\pop@#1#2#3,#4\endargs@{% 8436*d5c9a868SElliott Hughes \def#1{#3}% 8437*d5c9a868SElliott Hughes \def#2{#4}% 8438*d5c9a868SElliott Hughes} 8439*d5c9a868SElliott Hughes\long\def\longpop@#1#2#3,#4\endargs@{% 8440*d5c9a868SElliott Hughes \long\def#1{#3}% 8441*d5c9a868SElliott Hughes \long\def#2{#4}% 8442*d5c9a868SElliott Hughes} 8443*d5c9a868SElliott Hughes 8444*d5c9a868SElliott Hughes 8445*d5c9a868SElliott Hughes%%%%%%%%%%%%%% End of code for > 10 arguments %%%%%%%%%%%%%%%%%% 8446*d5c9a868SElliott Hughes 8447*d5c9a868SElliott Hughes 8448*d5c9a868SElliott Hughes% This defines a Texinfo @macro or @rmacro, called by \parsemacbody. 8449*d5c9a868SElliott Hughes% \macrobody has the body of the macro in it, with placeholders for 8450*d5c9a868SElliott Hughes% its parameters, looking like "\xeatspaces{\hash 1}". 8451*d5c9a868SElliott Hughes% \paramno is the number of parameters 8452*d5c9a868SElliott Hughes% \paramlist is a TeX parameter text, e.g. "#1,#2,#3," 8453*d5c9a868SElliott Hughes% There are four cases: macros of zero, one, up to nine, and many arguments. 8454*d5c9a868SElliott Hughes% \xdef is used so that macro definitions will survive the file 8455*d5c9a868SElliott Hughes% they're defined in: @include reads the file inside a group. 8456*d5c9a868SElliott Hughes% 8457*d5c9a868SElliott Hughes\def\defmacro{% 8458*d5c9a868SElliott Hughes \let\hash=##% convert placeholders to macro parameter chars 8459*d5c9a868SElliott Hughes \ifnum\paramno=1 8460*d5c9a868SElliott Hughes \def\xeatspaces##1{##1}% 8461*d5c9a868SElliott Hughes % This removes the pair of braces around the argument. We don't 8462*d5c9a868SElliott Hughes % use \eatspaces, because this can cause ends of lines to be lost 8463*d5c9a868SElliott Hughes % when the argument to \eatspaces is read, leading to line-based 8464*d5c9a868SElliott Hughes % commands like "@itemize" not being read correctly. 8465*d5c9a868SElliott Hughes \else 8466*d5c9a868SElliott Hughes \let\xeatspaces\relax % suppress expansion 8467*d5c9a868SElliott Hughes \fi 8468*d5c9a868SElliott Hughes \ifcase\paramno 8469*d5c9a868SElliott Hughes % 0 8470*d5c9a868SElliott Hughes \expandafter\xdef\csname\the\macname\endcsname{% 8471*d5c9a868SElliott Hughes \bgroup 8472*d5c9a868SElliott Hughes \noexpand\spaceisspace 8473*d5c9a868SElliott Hughes \noexpand\endlineisspace 8474*d5c9a868SElliott Hughes \noexpand\expandafter % skip any whitespace after the macro name. 8475*d5c9a868SElliott Hughes \expandafter\noexpand\csname\the\macname @@@\endcsname}% 8476*d5c9a868SElliott Hughes \expandafter\xdef\csname\the\macname @@@\endcsname{% 8477*d5c9a868SElliott Hughes \egroup 8478*d5c9a868SElliott Hughes \noexpand\scanmacro{\macrobody}}% 8479*d5c9a868SElliott Hughes \or % 1 8480*d5c9a868SElliott Hughes \expandafter\xdef\csname\the\macname\endcsname{% 8481*d5c9a868SElliott Hughes \bgroup 8482*d5c9a868SElliott Hughes \noexpand\braceorline 8483*d5c9a868SElliott Hughes \expandafter\noexpand\csname\the\macname @@@\endcsname}% 8484*d5c9a868SElliott Hughes \expandafter\xdef\csname\the\macname @@@\endcsname##1{% 8485*d5c9a868SElliott Hughes \egroup 8486*d5c9a868SElliott Hughes \noexpand\scanmacro{\macrobody}% 8487*d5c9a868SElliott Hughes }% 8488*d5c9a868SElliott Hughes \else % at most 9 8489*d5c9a868SElliott Hughes \ifnum\paramno<10\relax 8490*d5c9a868SElliott Hughes % @MACNAME sets the context for reading the macro argument 8491*d5c9a868SElliott Hughes % @MACNAME@@ gets the argument, processes backslashes and appends a 8492*d5c9a868SElliott Hughes % comma. 8493*d5c9a868SElliott Hughes % @MACNAME@@@ removes braces surrounding the argument list. 8494*d5c9a868SElliott Hughes % @MACNAME@@@@ scans the macro body with arguments substituted. 8495*d5c9a868SElliott Hughes \expandafter\xdef\csname\the\macname\endcsname{% 8496*d5c9a868SElliott Hughes \bgroup 8497*d5c9a868SElliott Hughes \noexpand\expandafter % This \expandafter skip any spaces after the 8498*d5c9a868SElliott Hughes \noexpand\macroargctxt % macro before we change the catcode of space. 8499*d5c9a868SElliott Hughes \noexpand\expandafter 8500*d5c9a868SElliott Hughes \expandafter\noexpand\csname\the\macname @@\endcsname}% 8501*d5c9a868SElliott Hughes \expandafter\xdef\csname\the\macname @@\endcsname##1{% 8502*d5c9a868SElliott Hughes \noexpand\passargtomacro 8503*d5c9a868SElliott Hughes \expandafter\noexpand\csname\the\macname @@@\endcsname{##1,}}% 8504*d5c9a868SElliott Hughes \expandafter\xdef\csname\the\macname @@@\endcsname##1{% 8505*d5c9a868SElliott Hughes \expandafter\noexpand\csname\the\macname @@@@\endcsname ##1}% 8506*d5c9a868SElliott Hughes \expandafter\expandafter 8507*d5c9a868SElliott Hughes \expandafter\xdef 8508*d5c9a868SElliott Hughes \expandafter\expandafter 8509*d5c9a868SElliott Hughes \csname\the\macname @@@@\endcsname\paramlist{% 8510*d5c9a868SElliott Hughes \egroup\noexpand\scanmacro{\macrobody}}% 8511*d5c9a868SElliott Hughes \else % 10 or more: 8512*d5c9a868SElliott Hughes \expandafter\xdef\csname\the\macname\endcsname{% 8513*d5c9a868SElliott Hughes \noexpand\getargvals@{\the\macname}{\argl}% 8514*d5c9a868SElliott Hughes }% 8515*d5c9a868SElliott Hughes \global\expandafter\let\csname mac.\the\macname .body\endcsname\macrobody 8516*d5c9a868SElliott Hughes \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\gobble 8517*d5c9a868SElliott Hughes \fi 8518*d5c9a868SElliott Hughes \fi} 8519*d5c9a868SElliott Hughes 8520*d5c9a868SElliott Hughes\catcode `\@\texiatcatcode\relax % end private-to-Texinfo catcodes 8521*d5c9a868SElliott Hughes 8522*d5c9a868SElliott Hughes\def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}} 8523*d5c9a868SElliott Hughes 8524*d5c9a868SElliott Hughes 8525*d5c9a868SElliott Hughes%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 8526*d5c9a868SElliott Hughes% 8527*d5c9a868SElliott Hughes{\catcode`\@=0 \catcode`\\=13 % We need to manipulate \ so use @ as escape 8528*d5c9a868SElliott Hughes@catcode`@_=11 % private names 8529*d5c9a868SElliott Hughes@catcode`@!=11 % used as argument separator 8530*d5c9a868SElliott Hughes 8531*d5c9a868SElliott Hughes% \passargtomacro#1#2 - 8532*d5c9a868SElliott Hughes% Call #1 with a list of tokens #2, with any doubled backslashes in #2 8533*d5c9a868SElliott Hughes% compressed to one. 8534*d5c9a868SElliott Hughes% 8535*d5c9a868SElliott Hughes% This implementation works by expansion, and not execution (so we cannot use 8536*d5c9a868SElliott Hughes% \def or similar). This reduces the risk of this failing in contexts where 8537*d5c9a868SElliott Hughes% complete expansion is done with no execution (for example, in writing out to 8538*d5c9a868SElliott Hughes% an auxiliary file for an index entry). 8539*d5c9a868SElliott Hughes% 8540*d5c9a868SElliott Hughes% State is kept in the input stream: the argument passed to 8541*d5c9a868SElliott Hughes% @look_ahead, @gobble_and_check_finish and @add_segment is 8542*d5c9a868SElliott Hughes% 8543*d5c9a868SElliott Hughes% THE_MACRO ARG_RESULT ! {PENDING_BS} NEXT_TOKEN (... rest of input) 8544*d5c9a868SElliott Hughes% 8545*d5c9a868SElliott Hughes% where: 8546*d5c9a868SElliott Hughes% THE_MACRO - name of the macro we want to call 8547*d5c9a868SElliott Hughes% ARG_RESULT - argument list we build to pass to that macro 8548*d5c9a868SElliott Hughes% PENDING_BS - either a backslash or nothing 8549*d5c9a868SElliott Hughes% NEXT_TOKEN - used to look ahead in the input stream to see what's coming next 8550*d5c9a868SElliott Hughes 8551*d5c9a868SElliott Hughes@gdef@passargtomacro#1#2{% 8552*d5c9a868SElliott Hughes @add_segment #1!{}@relax#2\@_finish\% 8553*d5c9a868SElliott Hughes} 8554*d5c9a868SElliott Hughes@gdef@_finish{@_finishx} @global@let@_finishx@relax 8555*d5c9a868SElliott Hughes 8556*d5c9a868SElliott Hughes% #1 - THE_MACRO ARG_RESULT 8557*d5c9a868SElliott Hughes% #2 - PENDING_BS 8558*d5c9a868SElliott Hughes% #3 - NEXT_TOKEN 8559*d5c9a868SElliott Hughes% #4 used to look ahead 8560*d5c9a868SElliott Hughes% 8561*d5c9a868SElliott Hughes% If the next token is not a backslash, process the rest of the argument; 8562*d5c9a868SElliott Hughes% otherwise, remove the next token. 8563*d5c9a868SElliott Hughes@gdef@look_ahead#1!#2#3#4{% 8564*d5c9a868SElliott Hughes @ifx#4\% 8565*d5c9a868SElliott Hughes @expandafter@gobble_and_check_finish 8566*d5c9a868SElliott Hughes @else 8567*d5c9a868SElliott Hughes @expandafter@add_segment 8568*d5c9a868SElliott Hughes @fi#1!{#2}#4#4% 8569*d5c9a868SElliott Hughes} 8570*d5c9a868SElliott Hughes 8571*d5c9a868SElliott Hughes% #1 - THE_MACRO ARG_RESULT 8572*d5c9a868SElliott Hughes% #2 - PENDING_BS 8573*d5c9a868SElliott Hughes% #3 - NEXT_TOKEN 8574*d5c9a868SElliott Hughes% #4 should be a backslash, which is gobbled. 8575*d5c9a868SElliott Hughes% #5 looks ahead 8576*d5c9a868SElliott Hughes% 8577*d5c9a868SElliott Hughes% Double backslash found. Add a single backslash, and look ahead. 8578*d5c9a868SElliott Hughes@gdef@gobble_and_check_finish#1!#2#3#4#5{% 8579*d5c9a868SElliott Hughes @add_segment#1\!{}#5#5% 8580*d5c9a868SElliott Hughes} 8581*d5c9a868SElliott Hughes 8582*d5c9a868SElliott Hughes@gdef@is_fi{@fi} 8583*d5c9a868SElliott Hughes 8584*d5c9a868SElliott Hughes% #1 - THE_MACRO ARG_RESULT 8585*d5c9a868SElliott Hughes% #2 - PENDING_BS 8586*d5c9a868SElliott Hughes% #3 - NEXT_TOKEN 8587*d5c9a868SElliott Hughes% #4 is input stream until next backslash 8588*d5c9a868SElliott Hughes% 8589*d5c9a868SElliott Hughes% Input stream is either at the start of the argument, or just after a 8590*d5c9a868SElliott Hughes% backslash sequence, either a lone backslash, or a doubled backslash. 8591*d5c9a868SElliott Hughes% NEXT_TOKEN contains the first token in the input stream: if it is \finish, 8592*d5c9a868SElliott Hughes% finish; otherwise, append to ARG_RESULT the segment of the argument up until 8593*d5c9a868SElliott Hughes% the next backslash. PENDING_BACKSLASH contains a backslash to represent 8594*d5c9a868SElliott Hughes% a backslash just before the start of the input stream that has not been 8595*d5c9a868SElliott Hughes% added to ARG_RESULT. 8596*d5c9a868SElliott Hughes@gdef@add_segment#1!#2#3#4\{% 8597*d5c9a868SElliott Hughes@ifx#3@_finish 8598*d5c9a868SElliott Hughes @call_the_macro#1!% 8599*d5c9a868SElliott Hughes@else 8600*d5c9a868SElliott Hughes % append the pending backslash to the result, followed by the next segment 8601*d5c9a868SElliott Hughes @expandafter@is_fi@look_ahead#1#2#4!{\}@fi 8602*d5c9a868SElliott Hughes % this @fi is discarded by @look_ahead. 8603*d5c9a868SElliott Hughes % we can't get rid of it with \expandafter because we don't know how 8604*d5c9a868SElliott Hughes % long #4 is. 8605*d5c9a868SElliott Hughes} 8606*d5c9a868SElliott Hughes 8607*d5c9a868SElliott Hughes% #1 - THE_MACRO 8608*d5c9a868SElliott Hughes% #2 - ARG_RESULT 8609*d5c9a868SElliott Hughes% #3 discards the res of the conditional in @add_segment, and @is_fi ends the 8610*d5c9a868SElliott Hughes% conditional. 8611*d5c9a868SElliott Hughes@gdef@call_the_macro#1#2!#3@fi{@is_fi #1{#2}} 8612*d5c9a868SElliott Hughes 8613*d5c9a868SElliott Hughes} 8614*d5c9a868SElliott Hughes%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 8615*d5c9a868SElliott Hughes 8616*d5c9a868SElliott Hughes% \braceorline MAC is used for a one-argument macro MAC. It checks 8617*d5c9a868SElliott Hughes% whether the next non-whitespace character is a {. It sets the context 8618*d5c9a868SElliott Hughes% for reading the argument (slightly different in the two cases). Then, 8619*d5c9a868SElliott Hughes% to read the argument, in the whole-line case, it then calls the regular 8620*d5c9a868SElliott Hughes% \parsearg MAC; in the lbrace case, it calls \passargtomacro MAC. 8621*d5c9a868SElliott Hughes% 8622*d5c9a868SElliott Hughes\def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx} 8623*d5c9a868SElliott Hughes\def\braceorlinexxx{% 8624*d5c9a868SElliott Hughes \ifx\nchar\bgroup 8625*d5c9a868SElliott Hughes \macroargctxt 8626*d5c9a868SElliott Hughes \expandafter\passargtomacro 8627*d5c9a868SElliott Hughes \else 8628*d5c9a868SElliott Hughes \macrolineargctxt\expandafter\parsearg 8629*d5c9a868SElliott Hughes \fi \macnamexxx} 8630*d5c9a868SElliott Hughes 8631*d5c9a868SElliott Hughes 8632*d5c9a868SElliott Hughes% @alias. 8633*d5c9a868SElliott Hughes% We need some trickery to remove the optional spaces around the equal 8634*d5c9a868SElliott Hughes% sign. Make them active and then expand them all to nothing. 8635*d5c9a868SElliott Hughes% 8636*d5c9a868SElliott Hughes\def\alias{\parseargusing\obeyspaces\aliasxxx} 8637*d5c9a868SElliott Hughes\def\aliasxxx #1{\aliasyyy#1\relax} 8638*d5c9a868SElliott Hughes\def\aliasyyy #1=#2\relax{% 8639*d5c9a868SElliott Hughes {% 8640*d5c9a868SElliott Hughes \expandafter\let\obeyedspace=\empty 8641*d5c9a868SElliott Hughes \addtomacrolist{#1}% 8642*d5c9a868SElliott Hughes \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}% 8643*d5c9a868SElliott Hughes }% 8644*d5c9a868SElliott Hughes \next 8645*d5c9a868SElliott Hughes} 8646*d5c9a868SElliott Hughes 8647*d5c9a868SElliott Hughes 8648*d5c9a868SElliott Hughes\message{cross references,} 8649*d5c9a868SElliott Hughes 8650*d5c9a868SElliott Hughes\newwrite\auxfile 8651*d5c9a868SElliott Hughes\newif\ifhavexrefs % True if xref values are known. 8652*d5c9a868SElliott Hughes\newif\ifwarnedxrefs % True if we warned once that they aren't known. 8653*d5c9a868SElliott Hughes 8654*d5c9a868SElliott Hughes% @inforef is relatively simple. 8655*d5c9a868SElliott Hughes\def\inforef #1{\inforefzzz #1,,,,**} 8656*d5c9a868SElliott Hughes\def\inforefzzz #1,#2,#3,#4**{% 8657*d5c9a868SElliott Hughes \putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}}, 8658*d5c9a868SElliott Hughes node \samp{\ignorespaces#1{}}} 8659*d5c9a868SElliott Hughes 8660*d5c9a868SElliott Hughes% @node's only job in TeX is to define \lastnode, which is used in 8661*d5c9a868SElliott Hughes% cross-references. The @node line might or might not have commas, and 8662*d5c9a868SElliott Hughes% might or might not have spaces before the first comma, like: 8663*d5c9a868SElliott Hughes% @node foo , bar , ... 8664*d5c9a868SElliott Hughes% We don't want such trailing spaces in the node name. 8665*d5c9a868SElliott Hughes% 8666*d5c9a868SElliott Hughes\parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse} 8667*d5c9a868SElliott Hughes% 8668*d5c9a868SElliott Hughes% also remove a trailing comma, in case of something like this: 8669*d5c9a868SElliott Hughes% @node Help-Cross, , , Cross-refs 8670*d5c9a868SElliott Hughes\def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse} 8671*d5c9a868SElliott Hughes\def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}\omittopnode} 8672*d5c9a868SElliott Hughes 8673*d5c9a868SElliott Hughes% Used so that the @top node doesn't have to be wrapped in an @ifnottex 8674*d5c9a868SElliott Hughes% conditional. 8675*d5c9a868SElliott Hughes% \doignore goes to more effort to skip nested conditionals but we don't need 8676*d5c9a868SElliott Hughes% that here. 8677*d5c9a868SElliott Hughes\def\omittopnode{% 8678*d5c9a868SElliott Hughes \ifx\lastnode\wordTop 8679*d5c9a868SElliott Hughes \expandafter\ignorenode\fi 8680*d5c9a868SElliott Hughes} 8681*d5c9a868SElliott Hughes\def\wordTop{Top} 8682*d5c9a868SElliott Hughes 8683*d5c9a868SElliott Hughes% Until the next @node or @bye command, divert output to a box that is not 8684*d5c9a868SElliott Hughes% output. 8685*d5c9a868SElliott Hughes\def\ignorenode{\setbox\dummybox\vbox\bgroup\def\node{\egroup\node}% 8686*d5c9a868SElliott Hughes\ignorenodebye 8687*d5c9a868SElliott Hughes} 8688*d5c9a868SElliott Hughes 8689*d5c9a868SElliott Hughes{\let\bye\relax 8690*d5c9a868SElliott Hughes\gdef\ignorenodebye{\let\bye\ignorenodebyedef} 8691*d5c9a868SElliott Hughes\gdef\ignorenodebyedef{\egroup(`Top' node ignored)\bye}} 8692*d5c9a868SElliott Hughes% The redefinition of \bye here is because it is declared \outer 8693*d5c9a868SElliott Hughes 8694*d5c9a868SElliott Hughes\let\lastnode=\empty 8695*d5c9a868SElliott Hughes 8696*d5c9a868SElliott Hughes% Write a cross-reference definition for the current node. #1 is the 8697*d5c9a868SElliott Hughes% type (Ynumbered, Yappendix, Ynothing). 8698*d5c9a868SElliott Hughes% 8699*d5c9a868SElliott Hughes\def\donoderef#1{% 8700*d5c9a868SElliott Hughes \ifx\lastnode\empty\else 8701*d5c9a868SElliott Hughes \setref{\lastnode}{#1}% 8702*d5c9a868SElliott Hughes \global\let\lastnode=\empty 8703*d5c9a868SElliott Hughes \fi 8704*d5c9a868SElliott Hughes} 8705*d5c9a868SElliott Hughes 8706*d5c9a868SElliott Hughes% @anchor{NAME} -- define xref target at arbitrary point. 8707*d5c9a868SElliott Hughes% 8708*d5c9a868SElliott Hughes\newcount\savesfregister 8709*d5c9a868SElliott Hughes% 8710*d5c9a868SElliott Hughes\def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi} 8711*d5c9a868SElliott Hughes\def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi} 8712*d5c9a868SElliott Hughes\def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces} 8713*d5c9a868SElliott Hughes 8714*d5c9a868SElliott Hughes% \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an 8715*d5c9a868SElliott Hughes% anchor), which consists of three parts: 8716*d5c9a868SElliott Hughes% 1) NAME-title - the current sectioning name taken from \currentsection, 8717*d5c9a868SElliott Hughes% or the anchor name. 8718*d5c9a868SElliott Hughes% 2) NAME-snt - section number and type, passed as the SNT arg, or 8719*d5c9a868SElliott Hughes% empty for anchors. 8720*d5c9a868SElliott Hughes% 3) NAME-pg - the page number. 8721*d5c9a868SElliott Hughes% 8722*d5c9a868SElliott Hughes% This is called from \donoderef, \anchor, and \dofloat. In the case of 8723*d5c9a868SElliott Hughes% floats, there is an additional part, which is not written here: 8724*d5c9a868SElliott Hughes% 4) NAME-lof - the text as it should appear in a @listoffloats. 8725*d5c9a868SElliott Hughes% 8726*d5c9a868SElliott Hughes\def\setref#1#2{% 8727*d5c9a868SElliott Hughes \pdfmkdest{#1}% 8728*d5c9a868SElliott Hughes \iflinks 8729*d5c9a868SElliott Hughes {% 8730*d5c9a868SElliott Hughes \requireauxfile 8731*d5c9a868SElliott Hughes \atdummies % preserve commands, but don't expand them 8732*d5c9a868SElliott Hughes % match definition in \xrdef, \refx, \xrefX. 8733*d5c9a868SElliott Hughes \def\value##1{##1}% 8734*d5c9a868SElliott Hughes \edef\writexrdef##1##2{% 8735*d5c9a868SElliott Hughes \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef 8736*d5c9a868SElliott Hughes ##1}{##2}}% these are parameters of \writexrdef 8737*d5c9a868SElliott Hughes }% 8738*d5c9a868SElliott Hughes \toks0 = \expandafter{\currentsection}% 8739*d5c9a868SElliott Hughes \immediate \writexrdef{title}{\the\toks0 }% 8740*d5c9a868SElliott Hughes \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc. 8741*d5c9a868SElliott Hughes \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout 8742*d5c9a868SElliott Hughes }% 8743*d5c9a868SElliott Hughes \fi 8744*d5c9a868SElliott Hughes} 8745*d5c9a868SElliott Hughes 8746*d5c9a868SElliott Hughes% @xrefautosectiontitle on|off says whether @section(ing) names are used 8747*d5c9a868SElliott Hughes% automatically in xrefs, if the third arg is not explicitly specified. 8748*d5c9a868SElliott Hughes% This was provided as a "secret" @set xref-automatic-section-title 8749*d5c9a868SElliott Hughes% variable, now it's official. 8750*d5c9a868SElliott Hughes% 8751*d5c9a868SElliott Hughes\parseargdef\xrefautomaticsectiontitle{% 8752*d5c9a868SElliott Hughes \def\temp{#1}% 8753*d5c9a868SElliott Hughes \ifx\temp\onword 8754*d5c9a868SElliott Hughes \expandafter\let\csname SETxref-automatic-section-title\endcsname 8755*d5c9a868SElliott Hughes = \empty 8756*d5c9a868SElliott Hughes \else\ifx\temp\offword 8757*d5c9a868SElliott Hughes \expandafter\let\csname SETxref-automatic-section-title\endcsname 8758*d5c9a868SElliott Hughes = \relax 8759*d5c9a868SElliott Hughes \else 8760*d5c9a868SElliott Hughes \errhelp = \EMsimple 8761*d5c9a868SElliott Hughes \errmessage{Unknown @xrefautomaticsectiontitle value `\temp', 8762*d5c9a868SElliott Hughes must be on|off}% 8763*d5c9a868SElliott Hughes \fi\fi 8764*d5c9a868SElliott Hughes} 8765*d5c9a868SElliott Hughes 8766*d5c9a868SElliott Hughes% 8767*d5c9a868SElliott Hughes% @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is 8768*d5c9a868SElliott Hughes% the node name, #2 the name of the Info cross-reference, #3 the printed 8769*d5c9a868SElliott Hughes% node name, #4 the name of the Info file, #5 the name of the printed 8770*d5c9a868SElliott Hughes% manual. All but the node name can be omitted. 8771*d5c9a868SElliott Hughes% 8772*d5c9a868SElliott Hughes\def\pxref{\putwordsee{} \xrefXX} 8773*d5c9a868SElliott Hughes\def\xref{\putwordSee{} \xrefXX} 8774*d5c9a868SElliott Hughes\def\ref{\xrefXX} 8775*d5c9a868SElliott Hughes 8776*d5c9a868SElliott Hughes\def\xrefXX#1{\def\xrefXXarg{#1}\futurelet\tokenafterxref\xrefXXX} 8777*d5c9a868SElliott Hughes\def\xrefXXX{\expandafter\xrefX\expandafter[\xrefXXarg,,,,,,,]} 8778*d5c9a868SElliott Hughes% 8779*d5c9a868SElliott Hughes\newbox\toprefbox 8780*d5c9a868SElliott Hughes\newbox\printedrefnamebox 8781*d5c9a868SElliott Hughes\newbox\infofilenamebox 8782*d5c9a868SElliott Hughes\newbox\printedmanualbox 8783*d5c9a868SElliott Hughes% 8784*d5c9a868SElliott Hughes\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup 8785*d5c9a868SElliott Hughes \unsepspaces 8786*d5c9a868SElliott Hughes % 8787*d5c9a868SElliott Hughes % Get args without leading/trailing spaces. 8788*d5c9a868SElliott Hughes \def\printedrefname{\ignorespaces #3}% 8789*d5c9a868SElliott Hughes \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}% 8790*d5c9a868SElliott Hughes % 8791*d5c9a868SElliott Hughes \def\infofilename{\ignorespaces #4}% 8792*d5c9a868SElliott Hughes \setbox\infofilenamebox = \hbox{\infofilename\unskip}% 8793*d5c9a868SElliott Hughes % 8794*d5c9a868SElliott Hughes \def\printedmanual{\ignorespaces #5}% 8795*d5c9a868SElliott Hughes \setbox\printedmanualbox = \hbox{\printedmanual\unskip}% 8796*d5c9a868SElliott Hughes % 8797*d5c9a868SElliott Hughes % If the printed reference name (arg #3) was not explicitly given in 8798*d5c9a868SElliott Hughes % the @xref, figure out what we want to use. 8799*d5c9a868SElliott Hughes \ifdim \wd\printedrefnamebox = 0pt 8800*d5c9a868SElliott Hughes % No printed node name was explicitly given. 8801*d5c9a868SElliott Hughes \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax 8802*d5c9a868SElliott Hughes % Not auto section-title: use node name inside the square brackets. 8803*d5c9a868SElliott Hughes \def\printedrefname{\ignorespaces #1}% 8804*d5c9a868SElliott Hughes \else 8805*d5c9a868SElliott Hughes % Auto section-title: use chapter/section title inside 8806*d5c9a868SElliott Hughes % the square brackets if we have it. 8807*d5c9a868SElliott Hughes \ifdim \wd\printedmanualbox > 0pt 8808*d5c9a868SElliott Hughes % It is in another manual, so we don't have it; use node name. 8809*d5c9a868SElliott Hughes \def\printedrefname{\ignorespaces #1}% 8810*d5c9a868SElliott Hughes \else 8811*d5c9a868SElliott Hughes \ifhavexrefs 8812*d5c9a868SElliott Hughes % We (should) know the real title if we have the xref values. 8813*d5c9a868SElliott Hughes \def\printedrefname{\refx{#1-title}}% 8814*d5c9a868SElliott Hughes \else 8815*d5c9a868SElliott Hughes % Otherwise just copy the Info node name. 8816*d5c9a868SElliott Hughes \def\printedrefname{\ignorespaces #1}% 8817*d5c9a868SElliott Hughes \fi% 8818*d5c9a868SElliott Hughes \fi 8819*d5c9a868SElliott Hughes \fi 8820*d5c9a868SElliott Hughes \fi 8821*d5c9a868SElliott Hughes % 8822*d5c9a868SElliott Hughes % Make link in pdf output. 8823*d5c9a868SElliott Hughes \ifpdf 8824*d5c9a868SElliott Hughes % For pdfTeX and LuaTeX 8825*d5c9a868SElliott Hughes {\indexnofonts 8826*d5c9a868SElliott Hughes \makevalueexpandable 8827*d5c9a868SElliott Hughes \turnoffactive 8828*d5c9a868SElliott Hughes % This expands tokens, so do it after making catcode changes, so _ 8829*d5c9a868SElliott Hughes % etc. don't get their TeX definitions. This ignores all spaces in 8830*d5c9a868SElliott Hughes % #4, including (wrongly) those in the middle of the filename. 8831*d5c9a868SElliott Hughes \getfilename{#4}% 8832*d5c9a868SElliott Hughes % 8833*d5c9a868SElliott Hughes % This (wrongly) does not take account of leading or trailing 8834*d5c9a868SElliott Hughes % spaces in #1, which should be ignored. 8835*d5c9a868SElliott Hughes \setpdfdestname{#1}% 8836*d5c9a868SElliott Hughes % 8837*d5c9a868SElliott Hughes \ifx\pdfdestname\empty 8838*d5c9a868SElliott Hughes \def\pdfdestname{Top}% no empty targets 8839*d5c9a868SElliott Hughes \fi 8840*d5c9a868SElliott Hughes % 8841*d5c9a868SElliott Hughes \leavevmode 8842*d5c9a868SElliott Hughes \startlink attr{/Border [0 0 0]}% 8843*d5c9a868SElliott Hughes \ifnum\filenamelength>0 8844*d5c9a868SElliott Hughes goto file{\the\filename.pdf} name{\pdfdestname}% 8845*d5c9a868SElliott Hughes \else 8846*d5c9a868SElliott Hughes goto name{\pdfmkpgn{\pdfdestname}}% 8847*d5c9a868SElliott Hughes \fi 8848*d5c9a868SElliott Hughes }% 8849*d5c9a868SElliott Hughes \setcolor{\linkcolor}% 8850*d5c9a868SElliott Hughes \else 8851*d5c9a868SElliott Hughes \ifx\XeTeXrevision\thisisundefined 8852*d5c9a868SElliott Hughes \else 8853*d5c9a868SElliott Hughes % For XeTeX 8854*d5c9a868SElliott Hughes {\indexnofonts 8855*d5c9a868SElliott Hughes \makevalueexpandable 8856*d5c9a868SElliott Hughes \turnoffactive 8857*d5c9a868SElliott Hughes % This expands tokens, so do it after making catcode changes, so _ 8858*d5c9a868SElliott Hughes % etc. don't get their TeX definitions. This ignores all spaces in 8859*d5c9a868SElliott Hughes % #4, including (wrongly) those in the middle of the filename. 8860*d5c9a868SElliott Hughes \getfilename{#4}% 8861*d5c9a868SElliott Hughes % 8862*d5c9a868SElliott Hughes % This (wrongly) does not take account of leading or trailing 8863*d5c9a868SElliott Hughes % spaces in #1, which should be ignored. 8864*d5c9a868SElliott Hughes \setpdfdestname{#1}% 8865*d5c9a868SElliott Hughes % 8866*d5c9a868SElliott Hughes \ifx\pdfdestname\empty 8867*d5c9a868SElliott Hughes \def\pdfdestname{Top}% no empty targets 8868*d5c9a868SElliott Hughes \fi 8869*d5c9a868SElliott Hughes % 8870*d5c9a868SElliott Hughes \leavevmode 8871*d5c9a868SElliott Hughes \ifnum\filenamelength>0 8872*d5c9a868SElliott Hughes % With default settings, 8873*d5c9a868SElliott Hughes % XeTeX (xdvipdfmx) replaces link destination names with integers. 8874*d5c9a868SElliott Hughes % In this case, the replaced destination names of 8875*d5c9a868SElliott Hughes % remote PDFs are no longer known. In order to avoid a replacement, 8876*d5c9a868SElliott Hughes % you can use xdvipdfmx's command line option `-C 0x0010'. 8877*d5c9a868SElliott Hughes % If you use XeTeX 0.99996+ (TeX Live 2016+), 8878*d5c9a868SElliott Hughes % this command line option is no longer necessary 8879*d5c9a868SElliott Hughes % because we can use the `dvipdfmx:config' special. 8880*d5c9a868SElliott Hughes \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A 8881*d5c9a868SElliott Hughes << /S /GoToR /F (\the\filename.pdf) /D (\pdfdestname) >> >>}% 8882*d5c9a868SElliott Hughes \else 8883*d5c9a868SElliott Hughes \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A 8884*d5c9a868SElliott Hughes << /S /GoTo /D (\pdfdestname) >> >>}% 8885*d5c9a868SElliott Hughes \fi 8886*d5c9a868SElliott Hughes }% 8887*d5c9a868SElliott Hughes \setcolor{\linkcolor}% 8888*d5c9a868SElliott Hughes \fi 8889*d5c9a868SElliott Hughes \fi 8890*d5c9a868SElliott Hughes {% 8891*d5c9a868SElliott Hughes % Have to otherify everything special to allow the \csname to 8892*d5c9a868SElliott Hughes % include an _ in the xref name, etc. 8893*d5c9a868SElliott Hughes \indexnofonts 8894*d5c9a868SElliott Hughes \turnoffactive 8895*d5c9a868SElliott Hughes \def\value##1{##1}% 8896*d5c9a868SElliott Hughes \expandafter\global\expandafter\let\expandafter\Xthisreftitle 8897*d5c9a868SElliott Hughes \csname XR#1-title\endcsname 8898*d5c9a868SElliott Hughes }% 8899*d5c9a868SElliott Hughes % 8900*d5c9a868SElliott Hughes % Float references are printed completely differently: "Figure 1.2" 8901*d5c9a868SElliott Hughes % instead of "[somenode], p.3". \iffloat distinguishes them by 8902*d5c9a868SElliott Hughes % \Xthisreftitle being set to a magic string. 8903*d5c9a868SElliott Hughes \iffloat\Xthisreftitle 8904*d5c9a868SElliott Hughes % If the user specified the print name (third arg) to the ref, 8905*d5c9a868SElliott Hughes % print it instead of our usual "Figure 1.2". 8906*d5c9a868SElliott Hughes \ifdim\wd\printedrefnamebox = 0pt 8907*d5c9a868SElliott Hughes \refx{#1-snt}% 8908*d5c9a868SElliott Hughes \else 8909*d5c9a868SElliott Hughes \printedrefname 8910*d5c9a868SElliott Hughes \fi 8911*d5c9a868SElliott Hughes % 8912*d5c9a868SElliott Hughes % If the user also gave the printed manual name (fifth arg), append 8913*d5c9a868SElliott Hughes % "in MANUALNAME". 8914*d5c9a868SElliott Hughes \ifdim \wd\printedmanualbox > 0pt 8915*d5c9a868SElliott Hughes \space \putwordin{} \cite{\printedmanual}% 8916*d5c9a868SElliott Hughes \fi 8917*d5c9a868SElliott Hughes \else 8918*d5c9a868SElliott Hughes % node/anchor (non-float) references. 8919*d5c9a868SElliott Hughes % 8920*d5c9a868SElliott Hughes % If we use \unhbox to print the node names, TeX does not insert 8921*d5c9a868SElliott Hughes % empty discretionaries after hyphens, which means that it will not 8922*d5c9a868SElliott Hughes % find a line break at a hyphen in a node names. Since some manuals 8923*d5c9a868SElliott Hughes % are best written with fairly long node names, containing hyphens, 8924*d5c9a868SElliott Hughes % this is a loss. Therefore, we give the text of the node name 8925*d5c9a868SElliott Hughes % again, so it is as if TeX is seeing it for the first time. 8926*d5c9a868SElliott Hughes % 8927*d5c9a868SElliott Hughes \ifdim \wd\printedmanualbox > 0pt 8928*d5c9a868SElliott Hughes % Cross-manual reference with a printed manual name. 8929*d5c9a868SElliott Hughes % 8930*d5c9a868SElliott Hughes \crossmanualxref{\cite{\printedmanual\unskip}}% 8931*d5c9a868SElliott Hughes % 8932*d5c9a868SElliott Hughes \else\ifdim \wd\infofilenamebox > 0pt 8933*d5c9a868SElliott Hughes % Cross-manual reference with only an info filename (arg 4), no 8934*d5c9a868SElliott Hughes % printed manual name (arg 5). This is essentially the same as 8935*d5c9a868SElliott Hughes % the case above; we output the filename, since we have nothing else. 8936*d5c9a868SElliott Hughes % 8937*d5c9a868SElliott Hughes \crossmanualxref{\code{\infofilename\unskip}}% 8938*d5c9a868SElliott Hughes % 8939*d5c9a868SElliott Hughes \else 8940*d5c9a868SElliott Hughes % Reference within this manual. 8941*d5c9a868SElliott Hughes % 8942*d5c9a868SElliott Hughes % Only output a following space if the -snt ref is nonempty, as the ref 8943*d5c9a868SElliott Hughes % will be empty for @unnumbered and @anchor. 8944*d5c9a868SElliott Hughes \setbox2 = \hbox{\ignorespaces \refx{#1-snt}}% 8945*d5c9a868SElliott Hughes \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi 8946*d5c9a868SElliott Hughes % 8947*d5c9a868SElliott Hughes % output the `[mynode]' via the macro below so it can be overridden. 8948*d5c9a868SElliott Hughes \xrefprintnodename\printedrefname 8949*d5c9a868SElliott Hughes % 8950*d5c9a868SElliott Hughes \expandafter\ifx\csname SETtxiomitxrefpg\endcsname\relax 8951*d5c9a868SElliott Hughes % But we always want a comma and a space: 8952*d5c9a868SElliott Hughes ,\space 8953*d5c9a868SElliott Hughes % 8954*d5c9a868SElliott Hughes % output the `page 3'. 8955*d5c9a868SElliott Hughes \turnoffactive \putwordpage\tie\refx{#1-pg}% 8956*d5c9a868SElliott Hughes % Add a , if xref followed by a space 8957*d5c9a868SElliott Hughes \if\space\noexpand\tokenafterxref ,% 8958*d5c9a868SElliott Hughes \else\ifx\ \tokenafterxref ,% @TAB 8959*d5c9a868SElliott Hughes \else\ifx\*\tokenafterxref ,% @* 8960*d5c9a868SElliott Hughes \else\ifx\ \tokenafterxref ,% @SPACE 8961*d5c9a868SElliott Hughes \else\ifx\ 8962*d5c9a868SElliott Hughes \tokenafterxref ,% @NL 8963*d5c9a868SElliott Hughes \else\ifx\tie\tokenafterxref ,% @tie 8964*d5c9a868SElliott Hughes \fi\fi\fi\fi\fi\fi 8965*d5c9a868SElliott Hughes \fi 8966*d5c9a868SElliott Hughes \fi\fi 8967*d5c9a868SElliott Hughes \fi 8968*d5c9a868SElliott Hughes \endlink 8969*d5c9a868SElliott Hughes\endgroup} 8970*d5c9a868SElliott Hughes 8971*d5c9a868SElliott Hughes% Output a cross-manual xref to #1. Used just above (twice). 8972*d5c9a868SElliott Hughes% 8973*d5c9a868SElliott Hughes% Only include the text "Section ``foo'' in" if the foo is neither 8974*d5c9a868SElliott Hughes% missing or Top. Thus, @xref{,,,foo,The Foo Manual} outputs simply 8975*d5c9a868SElliott Hughes% "see The Foo Manual", the idea being to refer to the whole manual. 8976*d5c9a868SElliott Hughes% 8977*d5c9a868SElliott Hughes% But, this being TeX, we can't easily compare our node name against the 8978*d5c9a868SElliott Hughes% string "Top" while ignoring the possible spaces before and after in 8979*d5c9a868SElliott Hughes% the input. By adding the arbitrary 7sp below, we make it much less 8980*d5c9a868SElliott Hughes% likely that a real node name would have the same width as "Top" (e.g., 8981*d5c9a868SElliott Hughes% in a monospaced font). Hopefully it will never happen in practice. 8982*d5c9a868SElliott Hughes% 8983*d5c9a868SElliott Hughes% For the same basic reason, we retypeset the "Top" at every 8984*d5c9a868SElliott Hughes% reference, since the current font is indeterminate. 8985*d5c9a868SElliott Hughes% 8986*d5c9a868SElliott Hughes\def\crossmanualxref#1{% 8987*d5c9a868SElliott Hughes \setbox\toprefbox = \hbox{Top\kern7sp}% 8988*d5c9a868SElliott Hughes \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}% 8989*d5c9a868SElliott Hughes \ifdim \wd2 > 7sp % nonempty? 8990*d5c9a868SElliott Hughes \ifdim \wd2 = \wd\toprefbox \else % same as Top? 8991*d5c9a868SElliott Hughes \putwordSection{} ``\printedrefname'' \putwordin{}\space 8992*d5c9a868SElliott Hughes \fi 8993*d5c9a868SElliott Hughes \fi 8994*d5c9a868SElliott Hughes #1% 8995*d5c9a868SElliott Hughes} 8996*d5c9a868SElliott Hughes 8997*d5c9a868SElliott Hughes% This macro is called from \xrefX for the `[nodename]' part of xref 8998*d5c9a868SElliott Hughes% output. It's a separate macro only so it can be changed more easily, 8999*d5c9a868SElliott Hughes% since square brackets don't work well in some documents. Particularly 9000*d5c9a868SElliott Hughes% one that Bob is working on :). 9001*d5c9a868SElliott Hughes% 9002*d5c9a868SElliott Hughes\def\xrefprintnodename#1{[#1]} 9003*d5c9a868SElliott Hughes 9004*d5c9a868SElliott Hughes% Things referred to by \setref. 9005*d5c9a868SElliott Hughes% 9006*d5c9a868SElliott Hughes\def\Ynothing{} 9007*d5c9a868SElliott Hughes\def\Yomitfromtoc{} 9008*d5c9a868SElliott Hughes\def\Ynumbered{% 9009*d5c9a868SElliott Hughes \ifnum\secno=0 9010*d5c9a868SElliott Hughes \putwordChapter@tie \the\chapno 9011*d5c9a868SElliott Hughes \else \ifnum\subsecno=0 9012*d5c9a868SElliott Hughes \putwordSection@tie \the\chapno.\the\secno 9013*d5c9a868SElliott Hughes \else \ifnum\subsubsecno=0 9014*d5c9a868SElliott Hughes \putwordSection@tie \the\chapno.\the\secno.\the\subsecno 9015*d5c9a868SElliott Hughes \else 9016*d5c9a868SElliott Hughes \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno 9017*d5c9a868SElliott Hughes \fi\fi\fi 9018*d5c9a868SElliott Hughes} 9019*d5c9a868SElliott Hughes\def\Yappendix{% 9020*d5c9a868SElliott Hughes \ifnum\secno=0 9021*d5c9a868SElliott Hughes \putwordAppendix@tie @char\the\appendixno{}% 9022*d5c9a868SElliott Hughes \else \ifnum\subsecno=0 9023*d5c9a868SElliott Hughes \putwordSection@tie @char\the\appendixno.\the\secno 9024*d5c9a868SElliott Hughes \else \ifnum\subsubsecno=0 9025*d5c9a868SElliott Hughes \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno 9026*d5c9a868SElliott Hughes \else 9027*d5c9a868SElliott Hughes \putwordSection@tie 9028*d5c9a868SElliott Hughes @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno 9029*d5c9a868SElliott Hughes \fi\fi\fi 9030*d5c9a868SElliott Hughes} 9031*d5c9a868SElliott Hughes 9032*d5c9a868SElliott Hughes% \refx{NAME} - reference a cross-reference string named NAME. 9033*d5c9a868SElliott Hughes\def\refx#1{% 9034*d5c9a868SElliott Hughes \requireauxfile 9035*d5c9a868SElliott Hughes {% 9036*d5c9a868SElliott Hughes \indexnofonts 9037*d5c9a868SElliott Hughes \turnoffactive 9038*d5c9a868SElliott Hughes \def\value##1{##1}% 9039*d5c9a868SElliott Hughes \expandafter\global\expandafter\let\expandafter\thisrefX 9040*d5c9a868SElliott Hughes \csname XR#1\endcsname 9041*d5c9a868SElliott Hughes }% 9042*d5c9a868SElliott Hughes \ifx\thisrefX\relax 9043*d5c9a868SElliott Hughes % If not defined, say something at least. 9044*d5c9a868SElliott Hughes \angleleft un\-de\-fined\angleright 9045*d5c9a868SElliott Hughes \iflinks 9046*d5c9a868SElliott Hughes \ifhavexrefs 9047*d5c9a868SElliott Hughes {\toks0 = {#1}% avoid expansion of possibly-complex value 9048*d5c9a868SElliott Hughes \message{\linenumber Undefined cross reference `\the\toks0'.}}% 9049*d5c9a868SElliott Hughes \else 9050*d5c9a868SElliott Hughes \ifwarnedxrefs\else 9051*d5c9a868SElliott Hughes \global\warnedxrefstrue 9052*d5c9a868SElliott Hughes \message{Cross reference values unknown; you must run TeX again.}% 9053*d5c9a868SElliott Hughes \fi 9054*d5c9a868SElliott Hughes \fi 9055*d5c9a868SElliott Hughes \fi 9056*d5c9a868SElliott Hughes \else 9057*d5c9a868SElliott Hughes % It's defined, so just use it. 9058*d5c9a868SElliott Hughes \thisrefX 9059*d5c9a868SElliott Hughes \fi 9060*d5c9a868SElliott Hughes} 9061*d5c9a868SElliott Hughes 9062*d5c9a868SElliott Hughes% This is the macro invoked by entries in the aux file. Define a control 9063*d5c9a868SElliott Hughes% sequence for a cross-reference target (we prepend XR to the control sequence 9064*d5c9a868SElliott Hughes% name to avoid collisions). The value is the page number. If this is a float 9065*d5c9a868SElliott Hughes% type, we have more work to do. 9066*d5c9a868SElliott Hughes% 9067*d5c9a868SElliott Hughes\def\xrdef#1#2{% 9068*d5c9a868SElliott Hughes {% Expand the node or anchor name to remove control sequences. 9069*d5c9a868SElliott Hughes % \turnoffactive stops 8-bit characters being changed to commands 9070*d5c9a868SElliott Hughes % like @'e. \refx does the same to retrieve the value in the definition. 9071*d5c9a868SElliott Hughes \indexnofonts 9072*d5c9a868SElliott Hughes \turnoffactive 9073*d5c9a868SElliott Hughes \def\value##1{##1}% 9074*d5c9a868SElliott Hughes \xdef\safexrefname{#1}% 9075*d5c9a868SElliott Hughes }% 9076*d5c9a868SElliott Hughes % 9077*d5c9a868SElliott Hughes \bgroup 9078*d5c9a868SElliott Hughes \expandafter\gdef\csname XR\safexrefname\endcsname{#2}% 9079*d5c9a868SElliott Hughes \egroup 9080*d5c9a868SElliott Hughes % We put the \gdef inside a group to avoid the definitions building up on 9081*d5c9a868SElliott Hughes % TeX's save stack, which can cause it to run out of space for aux files with 9082*d5c9a868SElliott Hughes % thousands of lines. \gdef doesn't use the save stack, but \csname does 9083*d5c9a868SElliott Hughes % when it defines an unknown control sequence as \relax. 9084*d5c9a868SElliott Hughes % 9085*d5c9a868SElliott Hughes % Was that xref control sequence that we just defined for a float? 9086*d5c9a868SElliott Hughes \expandafter\iffloat\csname XR\safexrefname\endcsname 9087*d5c9a868SElliott Hughes % it was a float, and we have the (safe) float type in \iffloattype. 9088*d5c9a868SElliott Hughes \expandafter\let\expandafter\floatlist 9089*d5c9a868SElliott Hughes \csname floatlist\iffloattype\endcsname 9090*d5c9a868SElliott Hughes % 9091*d5c9a868SElliott Hughes % Is this the first time we've seen this float type? 9092*d5c9a868SElliott Hughes \expandafter\ifx\floatlist\relax 9093*d5c9a868SElliott Hughes \toks0 = {\do}% yes, so just \do 9094*d5c9a868SElliott Hughes \else 9095*d5c9a868SElliott Hughes % had it before, so preserve previous elements in list. 9096*d5c9a868SElliott Hughes \toks0 = \expandafter{\floatlist\do}% 9097*d5c9a868SElliott Hughes \fi 9098*d5c9a868SElliott Hughes % 9099*d5c9a868SElliott Hughes % Remember this xref in the control sequence \floatlistFLOATTYPE, 9100*d5c9a868SElliott Hughes % for later use in \listoffloats. 9101*d5c9a868SElliott Hughes \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0 9102*d5c9a868SElliott Hughes {\safexrefname}}% 9103*d5c9a868SElliott Hughes \fi 9104*d5c9a868SElliott Hughes} 9105*d5c9a868SElliott Hughes 9106*d5c9a868SElliott Hughes% If working on a large document in chapters, it is convenient to 9107*d5c9a868SElliott Hughes% be able to disable indexing, cross-referencing, and contents, for test runs. 9108*d5c9a868SElliott Hughes% This is done with @novalidate at the beginning of the file. 9109*d5c9a868SElliott Hughes% 9110*d5c9a868SElliott Hughes\newif\iflinks \linkstrue % by default we want the aux files. 9111*d5c9a868SElliott Hughes\let\novalidate = \linksfalse 9112*d5c9a868SElliott Hughes 9113*d5c9a868SElliott Hughes% Used when writing to the aux file, or when using data from it. 9114*d5c9a868SElliott Hughes\def\requireauxfile{% 9115*d5c9a868SElliott Hughes \iflinks 9116*d5c9a868SElliott Hughes \tryauxfile 9117*d5c9a868SElliott Hughes % Open the new aux file. TeX will close it automatically at exit. 9118*d5c9a868SElliott Hughes \immediate\openout\auxfile=\jobname.aux 9119*d5c9a868SElliott Hughes \fi 9120*d5c9a868SElliott Hughes \global\let\requireauxfile=\relax % Only do this once. 9121*d5c9a868SElliott Hughes} 9122*d5c9a868SElliott Hughes 9123*d5c9a868SElliott Hughes% Read the last existing aux file, if any. No error if none exists. 9124*d5c9a868SElliott Hughes% 9125*d5c9a868SElliott Hughes\def\tryauxfile{% 9126*d5c9a868SElliott Hughes \openin 1 \jobname.aux 9127*d5c9a868SElliott Hughes \ifeof 1 \else 9128*d5c9a868SElliott Hughes \readdatafile{aux}% 9129*d5c9a868SElliott Hughes \global\havexrefstrue 9130*d5c9a868SElliott Hughes \fi 9131*d5c9a868SElliott Hughes \closein 1 9132*d5c9a868SElliott Hughes} 9133*d5c9a868SElliott Hughes 9134*d5c9a868SElliott Hughes\def\setupdatafile{% 9135*d5c9a868SElliott Hughes \catcode`\^^@=\other 9136*d5c9a868SElliott Hughes \catcode`\^^A=\other 9137*d5c9a868SElliott Hughes \catcode`\^^B=\other 9138*d5c9a868SElliott Hughes \catcode`\^^C=\other 9139*d5c9a868SElliott Hughes \catcode`\^^D=\other 9140*d5c9a868SElliott Hughes \catcode`\^^E=\other 9141*d5c9a868SElliott Hughes \catcode`\^^F=\other 9142*d5c9a868SElliott Hughes \catcode`\^^G=\other 9143*d5c9a868SElliott Hughes \catcode`\^^H=\other 9144*d5c9a868SElliott Hughes \catcode`\^^K=\other 9145*d5c9a868SElliott Hughes \catcode`\^^L=\other 9146*d5c9a868SElliott Hughes \catcode`\^^N=\other 9147*d5c9a868SElliott Hughes \catcode`\^^P=\other 9148*d5c9a868SElliott Hughes \catcode`\^^Q=\other 9149*d5c9a868SElliott Hughes \catcode`\^^R=\other 9150*d5c9a868SElliott Hughes \catcode`\^^S=\other 9151*d5c9a868SElliott Hughes \catcode`\^^T=\other 9152*d5c9a868SElliott Hughes \catcode`\^^U=\other 9153*d5c9a868SElliott Hughes \catcode`\^^V=\other 9154*d5c9a868SElliott Hughes \catcode`\^^W=\other 9155*d5c9a868SElliott Hughes \catcode`\^^X=\other 9156*d5c9a868SElliott Hughes \catcode`\^^Z=\other 9157*d5c9a868SElliott Hughes \catcode`\^^[=\other 9158*d5c9a868SElliott Hughes \catcode`\^^\=\other 9159*d5c9a868SElliott Hughes \catcode`\^^]=\other 9160*d5c9a868SElliott Hughes \catcode`\^^^=\other 9161*d5c9a868SElliott Hughes \catcode`\^^_=\other 9162*d5c9a868SElliott Hughes \catcode`\^=\other 9163*d5c9a868SElliott Hughes % 9164*d5c9a868SElliott Hughes % Special characters. Should be turned off anyway, but... 9165*d5c9a868SElliott Hughes \catcode`\~=\other 9166*d5c9a868SElliott Hughes \catcode`\[=\other 9167*d5c9a868SElliott Hughes \catcode`\]=\other 9168*d5c9a868SElliott Hughes \catcode`\"=\other 9169*d5c9a868SElliott Hughes \catcode`\_=\active 9170*d5c9a868SElliott Hughes \catcode`\|=\active 9171*d5c9a868SElliott Hughes \catcode`\<=\active 9172*d5c9a868SElliott Hughes \catcode`\>=\active 9173*d5c9a868SElliott Hughes \catcode`\$=\other 9174*d5c9a868SElliott Hughes \catcode`\#=\other 9175*d5c9a868SElliott Hughes \catcode`\&=\other 9176*d5c9a868SElliott Hughes \catcode`\%=\other 9177*d5c9a868SElliott Hughes \catcode`+=\other % avoid \+ for paranoia even though we've turned it off 9178*d5c9a868SElliott Hughes % 9179*d5c9a868SElliott Hughes \catcode`\\=\active 9180*d5c9a868SElliott Hughes % 9181*d5c9a868SElliott Hughes % @ is our escape character in .aux files, and we need braces. 9182*d5c9a868SElliott Hughes \catcode`\{=1 9183*d5c9a868SElliott Hughes \catcode`\}=2 9184*d5c9a868SElliott Hughes \catcode`\@=0 9185*d5c9a868SElliott Hughes} 9186*d5c9a868SElliott Hughes 9187*d5c9a868SElliott Hughes\def\readdatafile#1{% 9188*d5c9a868SElliott Hughes\begingroup 9189*d5c9a868SElliott Hughes \setupdatafile 9190*d5c9a868SElliott Hughes \input\jobname.#1 9191*d5c9a868SElliott Hughes\endgroup} 9192*d5c9a868SElliott Hughes 9193*d5c9a868SElliott Hughes 9194*d5c9a868SElliott Hughes\message{insertions,} 9195*d5c9a868SElliott Hughes% including footnotes. 9196*d5c9a868SElliott Hughes 9197*d5c9a868SElliott Hughes\newcount \footnoteno 9198*d5c9a868SElliott Hughes 9199*d5c9a868SElliott Hughes% The trailing space in the following definition for supereject is 9200*d5c9a868SElliott Hughes% vital for proper filling; pages come out unaligned when you do a 9201*d5c9a868SElliott Hughes% pagealignmacro call if that space before the closing brace is 9202*d5c9a868SElliott Hughes% removed. (Generally, numeric constants should always be followed by a 9203*d5c9a868SElliott Hughes% space to prevent strange expansion errors.) 9204*d5c9a868SElliott Hughes\def\supereject{\par\penalty -20000\footnoteno =0 } 9205*d5c9a868SElliott Hughes 9206*d5c9a868SElliott Hughes% @footnotestyle is meaningful for Info output only. 9207*d5c9a868SElliott Hughes\let\footnotestyle=\comment 9208*d5c9a868SElliott Hughes 9209*d5c9a868SElliott Hughes{\catcode `\@=11 9210*d5c9a868SElliott Hughes% 9211*d5c9a868SElliott Hughes% Auto-number footnotes. Otherwise like plain. 9212*d5c9a868SElliott Hughes\gdef\footnote{% 9213*d5c9a868SElliott Hughes \global\advance\footnoteno by \@ne 9214*d5c9a868SElliott Hughes \edef\thisfootno{$^{\the\footnoteno}$}% 9215*d5c9a868SElliott Hughes % 9216*d5c9a868SElliott Hughes % In case the footnote comes at the end of a sentence, preserve the 9217*d5c9a868SElliott Hughes % extra spacing after we do the footnote number. 9218*d5c9a868SElliott Hughes \let\@sf\empty 9219*d5c9a868SElliott Hughes \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi 9220*d5c9a868SElliott Hughes % 9221*d5c9a868SElliott Hughes % Remove inadvertent blank space before typesetting the footnote number. 9222*d5c9a868SElliott Hughes \unskip 9223*d5c9a868SElliott Hughes \thisfootno\@sf 9224*d5c9a868SElliott Hughes \dofootnote 9225*d5c9a868SElliott Hughes}% 9226*d5c9a868SElliott Hughes 9227*d5c9a868SElliott Hughes% Don't bother with the trickery in plain.tex to not require the 9228*d5c9a868SElliott Hughes% footnote text as a parameter. Our footnotes don't need to be so general. 9229*d5c9a868SElliott Hughes% 9230*d5c9a868SElliott Hughes% Oh yes, they do; otherwise, @ifset (and anything else that uses 9231*d5c9a868SElliott Hughes% \parseargline) fails inside footnotes because the tokens are fixed when 9232*d5c9a868SElliott Hughes% the footnote is read. --karl, 16nov96. 9233*d5c9a868SElliott Hughes% 9234*d5c9a868SElliott Hughes\gdef\dofootnote{% 9235*d5c9a868SElliott Hughes \insert\footins\bgroup 9236*d5c9a868SElliott Hughes % 9237*d5c9a868SElliott Hughes % Nested footnotes are not supported in TeX, that would take a lot 9238*d5c9a868SElliott Hughes % more work. (\startsavinginserts does not suffice.) 9239*d5c9a868SElliott Hughes \let\footnote=\errfootnotenest 9240*d5c9a868SElliott Hughes % 9241*d5c9a868SElliott Hughes % We want to typeset this text as a normal paragraph, even if the 9242*d5c9a868SElliott Hughes % footnote reference occurs in (for example) a display environment. 9243*d5c9a868SElliott Hughes % So reset some parameters. 9244*d5c9a868SElliott Hughes \hsize=\txipagewidth 9245*d5c9a868SElliott Hughes \interlinepenalty\interfootnotelinepenalty 9246*d5c9a868SElliott Hughes \splittopskip\ht\strutbox % top baseline for broken footnotes 9247*d5c9a868SElliott Hughes \splitmaxdepth\dp\strutbox 9248*d5c9a868SElliott Hughes \floatingpenalty\@MM 9249*d5c9a868SElliott Hughes \leftskip\z@skip 9250*d5c9a868SElliott Hughes \rightskip\z@skip 9251*d5c9a868SElliott Hughes \spaceskip\z@skip 9252*d5c9a868SElliott Hughes \xspaceskip\z@skip 9253*d5c9a868SElliott Hughes \parindent\defaultparindent 9254*d5c9a868SElliott Hughes % 9255*d5c9a868SElliott Hughes \smallfonts \rm 9256*d5c9a868SElliott Hughes % 9257*d5c9a868SElliott Hughes % Because we use hanging indentation in footnotes, a @noindent appears 9258*d5c9a868SElliott Hughes % to exdent this text, so make it be a no-op. makeinfo does not use 9259*d5c9a868SElliott Hughes % hanging indentation so @noindent can still be needed within footnote 9260*d5c9a868SElliott Hughes % text after an @example or the like (not that this is good style). 9261*d5c9a868SElliott Hughes \let\noindent = \relax 9262*d5c9a868SElliott Hughes % 9263*d5c9a868SElliott Hughes % Hang the footnote text off the number. Use \everypar in case the 9264*d5c9a868SElliott Hughes % footnote extends for more than one paragraph. 9265*d5c9a868SElliott Hughes \everypar = {\hang}% 9266*d5c9a868SElliott Hughes \textindent{\thisfootno}% 9267*d5c9a868SElliott Hughes % 9268*d5c9a868SElliott Hughes % Don't crash into the line above the footnote text. Since this 9269*d5c9a868SElliott Hughes % expands into a box, it must come within the paragraph, lest it 9270*d5c9a868SElliott Hughes % provide a place where TeX can split the footnote. 9271*d5c9a868SElliott Hughes \footstrut 9272*d5c9a868SElliott Hughes % 9273*d5c9a868SElliott Hughes % Invoke rest of plain TeX footnote routine. 9274*d5c9a868SElliott Hughes \futurelet\next\fo@t 9275*d5c9a868SElliott Hughes} 9276*d5c9a868SElliott Hughes}%end \catcode `\@=11 9277*d5c9a868SElliott Hughes 9278*d5c9a868SElliott Hughes\def\errfootnotenest{% 9279*d5c9a868SElliott Hughes \errhelp=\EMsimple 9280*d5c9a868SElliott Hughes \errmessage{Nested footnotes not supported in texinfo.tex, 9281*d5c9a868SElliott Hughes even though they work in makeinfo; sorry} 9282*d5c9a868SElliott Hughes} 9283*d5c9a868SElliott Hughes 9284*d5c9a868SElliott Hughes\def\errfootnoteheading{% 9285*d5c9a868SElliott Hughes \errhelp=\EMsimple 9286*d5c9a868SElliott Hughes \errmessage{Footnotes in chapters, sections, etc., are not supported} 9287*d5c9a868SElliott Hughes} 9288*d5c9a868SElliott Hughes 9289*d5c9a868SElliott Hughes% In case a @footnote appears in a vbox, save the footnote text and create 9290*d5c9a868SElliott Hughes% the real \insert just after the vbox finished. Otherwise, the insertion 9291*d5c9a868SElliott Hughes% would be lost. 9292*d5c9a868SElliott Hughes% Similarly, if a @footnote appears inside an alignment, save the footnote 9293*d5c9a868SElliott Hughes% text to a box and make the \insert when a row of the table is finished. 9294*d5c9a868SElliott Hughes% And the same can be done for other insert classes. --kasal, 16nov03. 9295*d5c9a868SElliott Hughes% 9296*d5c9a868SElliott Hughes% Replace the \insert primitive by a cheating macro. 9297*d5c9a868SElliott Hughes% Deeper inside, just make sure that the saved insertions are not spilled 9298*d5c9a868SElliott Hughes% out prematurely. 9299*d5c9a868SElliott Hughes% 9300*d5c9a868SElliott Hughes\def\startsavinginserts{% 9301*d5c9a868SElliott Hughes \ifx \insert\ptexinsert 9302*d5c9a868SElliott Hughes \let\insert\saveinsert 9303*d5c9a868SElliott Hughes \else 9304*d5c9a868SElliott Hughes \let\checkinserts\relax 9305*d5c9a868SElliott Hughes \fi 9306*d5c9a868SElliott Hughes} 9307*d5c9a868SElliott Hughes 9308*d5c9a868SElliott Hughes% This \insert replacement works for both \insert\footins{foo} and 9309*d5c9a868SElliott Hughes% \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}. 9310*d5c9a868SElliott Hughes% 9311*d5c9a868SElliott Hughes\def\saveinsert#1{% 9312*d5c9a868SElliott Hughes \edef\next{\noexpand\savetobox \makeSAVEname#1}% 9313*d5c9a868SElliott Hughes \afterassignment\next 9314*d5c9a868SElliott Hughes % swallow the left brace 9315*d5c9a868SElliott Hughes \let\temp = 9316*d5c9a868SElliott Hughes} 9317*d5c9a868SElliott Hughes\def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}} 9318*d5c9a868SElliott Hughes\def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1} 9319*d5c9a868SElliott Hughes 9320*d5c9a868SElliott Hughes\def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi} 9321*d5c9a868SElliott Hughes 9322*d5c9a868SElliott Hughes\def\placesaveins#1{% 9323*d5c9a868SElliott Hughes \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname 9324*d5c9a868SElliott Hughes {\box#1}% 9325*d5c9a868SElliott Hughes} 9326*d5c9a868SElliott Hughes 9327*d5c9a868SElliott Hughes% eat @SAVE -- beware, all of them have catcode \other: 9328*d5c9a868SElliott Hughes{ 9329*d5c9a868SElliott Hughes \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials % ;-) 9330*d5c9a868SElliott Hughes \gdef\gobblesave @SAVE{} 9331*d5c9a868SElliott Hughes} 9332*d5c9a868SElliott Hughes 9333*d5c9a868SElliott Hughes% initialization: 9334*d5c9a868SElliott Hughes\def\newsaveins #1{% 9335*d5c9a868SElliott Hughes \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}% 9336*d5c9a868SElliott Hughes \next 9337*d5c9a868SElliott Hughes} 9338*d5c9a868SElliott Hughes\def\newsaveinsX #1{% 9339*d5c9a868SElliott Hughes \csname newbox\endcsname #1% 9340*d5c9a868SElliott Hughes \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts 9341*d5c9a868SElliott Hughes \checksaveins #1}% 9342*d5c9a868SElliott Hughes} 9343*d5c9a868SElliott Hughes 9344*d5c9a868SElliott Hughes% initialize: 9345*d5c9a868SElliott Hughes\let\checkinserts\empty 9346*d5c9a868SElliott Hughes\newsaveins\footins 9347*d5c9a868SElliott Hughes\newsaveins\margin 9348*d5c9a868SElliott Hughes 9349*d5c9a868SElliott Hughes 9350*d5c9a868SElliott Hughes% @image. We use the macros from epsf.tex to support this. 9351*d5c9a868SElliott Hughes% If epsf.tex is not installed and @image is used, we complain. 9352*d5c9a868SElliott Hughes% 9353*d5c9a868SElliott Hughes% Check for and read epsf.tex up front. If we read it only at @image 9354*d5c9a868SElliott Hughes% time, we might be inside a group, and then its definitions would get 9355*d5c9a868SElliott Hughes% undone and the next image would fail. 9356*d5c9a868SElliott Hughes\openin 1 = epsf.tex 9357*d5c9a868SElliott Hughes\ifeof 1 \else 9358*d5c9a868SElliott Hughes % Do not bother showing banner with epsf.tex v2.7k (available in 9359*d5c9a868SElliott Hughes % doc/epsf.tex and on ctan). 9360*d5c9a868SElliott Hughes \def\epsfannounce{\toks0 = }% 9361*d5c9a868SElliott Hughes \input epsf.tex 9362*d5c9a868SElliott Hughes\fi 9363*d5c9a868SElliott Hughes\closein 1 9364*d5c9a868SElliott Hughes% 9365*d5c9a868SElliott Hughes% We will only complain once about lack of epsf.tex. 9366*d5c9a868SElliott Hughes\newif\ifwarnednoepsf 9367*d5c9a868SElliott Hughes\newhelp\noepsfhelp{epsf.tex must be installed for images to 9368*d5c9a868SElliott Hughes work. It is also included in the Texinfo distribution, or you can get 9369*d5c9a868SElliott Hughes it from https://ctan.org/texarchive/macros/texinfo/texinfo/doc/epsf.tex.} 9370*d5c9a868SElliott Hughes% 9371*d5c9a868SElliott Hughes\def\image#1{% 9372*d5c9a868SElliott Hughes \ifx\epsfbox\thisisundefined 9373*d5c9a868SElliott Hughes \ifwarnednoepsf \else 9374*d5c9a868SElliott Hughes \errhelp = \noepsfhelp 9375*d5c9a868SElliott Hughes \errmessage{epsf.tex not found, images will be ignored}% 9376*d5c9a868SElliott Hughes \global\warnednoepsftrue 9377*d5c9a868SElliott Hughes \fi 9378*d5c9a868SElliott Hughes \else 9379*d5c9a868SElliott Hughes \imagexxx #1,,,,,\finish 9380*d5c9a868SElliott Hughes \fi 9381*d5c9a868SElliott Hughes} 9382*d5c9a868SElliott Hughes% 9383*d5c9a868SElliott Hughes% Arguments to @image: 9384*d5c9a868SElliott Hughes% #1 is (mandatory) image filename; we tack on .eps extension. 9385*d5c9a868SElliott Hughes% #2 is (optional) width, #3 is (optional) height. 9386*d5c9a868SElliott Hughes% #4 is (ignored optional) html alt text. 9387*d5c9a868SElliott Hughes% #5 is (ignored optional) extension. 9388*d5c9a868SElliott Hughes% #6 is just the usual extra ignored arg for parsing stuff. 9389*d5c9a868SElliott Hughes\newif\ifimagevmode 9390*d5c9a868SElliott Hughes\def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup 9391*d5c9a868SElliott Hughes \catcode`\^^M = 5 % in case we're inside an example 9392*d5c9a868SElliott Hughes \normalturnoffactive % allow _ et al. in names 9393*d5c9a868SElliott Hughes \makevalueexpandable 9394*d5c9a868SElliott Hughes % If the image is by itself, center it. 9395*d5c9a868SElliott Hughes \ifvmode 9396*d5c9a868SElliott Hughes \imagevmodetrue 9397*d5c9a868SElliott Hughes \else \ifx\centersub\centerV 9398*d5c9a868SElliott Hughes % for @center @image, we need a vbox so we can have our vertical space 9399*d5c9a868SElliott Hughes \imagevmodetrue 9400*d5c9a868SElliott Hughes \vbox\bgroup % vbox has better behavior than vtop herev 9401*d5c9a868SElliott Hughes \fi\fi 9402*d5c9a868SElliott Hughes % 9403*d5c9a868SElliott Hughes \ifimagevmode 9404*d5c9a868SElliott Hughes \medskip 9405*d5c9a868SElliott Hughes % Usually we'll have text after the image which will insert 9406*d5c9a868SElliott Hughes % \parskip glue, so insert it here too to equalize the space 9407*d5c9a868SElliott Hughes % above and below. 9408*d5c9a868SElliott Hughes \nobreak\vskip\parskip 9409*d5c9a868SElliott Hughes \nobreak 9410*d5c9a868SElliott Hughes \fi 9411*d5c9a868SElliott Hughes % 9412*d5c9a868SElliott Hughes % Leave vertical mode so that indentation from an enclosing 9413*d5c9a868SElliott Hughes % environment such as @quotation is respected. 9414*d5c9a868SElliott Hughes % However, if we're at the top level, we don't want the 9415*d5c9a868SElliott Hughes % normal paragraph indentation. 9416*d5c9a868SElliott Hughes % On the other hand, if we are in the case of @center @image, we don't 9417*d5c9a868SElliott Hughes % want to start a paragraph, which will create a hsize-width box and 9418*d5c9a868SElliott Hughes % eradicate the centering. 9419*d5c9a868SElliott Hughes \ifx\centersub\centerV \else \imageindent \fi 9420*d5c9a868SElliott Hughes % 9421*d5c9a868SElliott Hughes % Output the image. 9422*d5c9a868SElliott Hughes \ifpdf 9423*d5c9a868SElliott Hughes % For pdfTeX and LuaTeX <= 0.80 9424*d5c9a868SElliott Hughes \dopdfimage{#1}{#2}{#3}% 9425*d5c9a868SElliott Hughes \else 9426*d5c9a868SElliott Hughes \ifx\XeTeXrevision\thisisundefined 9427*d5c9a868SElliott Hughes % For epsf.tex 9428*d5c9a868SElliott Hughes % \epsfbox itself resets \epsf?size at each figure. 9429*d5c9a868SElliott Hughes \setbox0 = \hbox{\ignorespaces #2}% 9430*d5c9a868SElliott Hughes \ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi 9431*d5c9a868SElliott Hughes \setbox0 = \hbox{\ignorespaces #3}% 9432*d5c9a868SElliott Hughes \ifdim\wd0 > 0pt \epsfysize=#3\relax \fi 9433*d5c9a868SElliott Hughes \epsfbox{#1.eps}% 9434*d5c9a868SElliott Hughes \else 9435*d5c9a868SElliott Hughes % For XeTeX 9436*d5c9a868SElliott Hughes \doxeteximage{#1}{#2}{#3}% 9437*d5c9a868SElliott Hughes \fi 9438*d5c9a868SElliott Hughes \fi 9439*d5c9a868SElliott Hughes % 9440*d5c9a868SElliott Hughes \ifimagevmode 9441*d5c9a868SElliott Hughes \medskip % space after a standalone image 9442*d5c9a868SElliott Hughes \fi 9443*d5c9a868SElliott Hughes \ifx\centersub\centerV \egroup \fi 9444*d5c9a868SElliott Hughes\endgroup} 9445*d5c9a868SElliott Hughes 9446*d5c9a868SElliott Hughes 9447*d5c9a868SElliott Hughes% @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables, 9448*d5c9a868SElliott Hughes% etc. We don't actually implement floating yet, we always include the 9449*d5c9a868SElliott Hughes% float "here". But it seemed the best name for the future. 9450*d5c9a868SElliott Hughes% 9451*d5c9a868SElliott Hughes\envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish} 9452*d5c9a868SElliott Hughes 9453*d5c9a868SElliott Hughes% There may be a space before second and/or third parameter; delete it. 9454*d5c9a868SElliott Hughes\def\eatcommaspace#1, {#1,} 9455*d5c9a868SElliott Hughes 9456*d5c9a868SElliott Hughes% #1 is the optional FLOATTYPE, the text label for this float, typically 9457*d5c9a868SElliott Hughes% "Figure", "Table", "Example", etc. Can't contain commas. If omitted, 9458*d5c9a868SElliott Hughes% this float will not be numbered and cannot be referred to. 9459*d5c9a868SElliott Hughes% 9460*d5c9a868SElliott Hughes% #2 is the optional xref label. Also must be present for the float to 9461*d5c9a868SElliott Hughes% be referable. 9462*d5c9a868SElliott Hughes% 9463*d5c9a868SElliott Hughes% #3 is the optional positioning argument; for now, it is ignored. It 9464*d5c9a868SElliott Hughes% will somehow specify the positions allowed to float to (here, top, bottom). 9465*d5c9a868SElliott Hughes% 9466*d5c9a868SElliott Hughes% We keep a separate counter for each FLOATTYPE, which we reset at each 9467*d5c9a868SElliott Hughes% chapter-level command. 9468*d5c9a868SElliott Hughes\let\resetallfloatnos=\empty 9469*d5c9a868SElliott Hughes% 9470*d5c9a868SElliott Hughes\def\dofloat#1,#2,#3,#4\finish{% 9471*d5c9a868SElliott Hughes \let\thiscaption=\empty 9472*d5c9a868SElliott Hughes \let\thisshortcaption=\empty 9473*d5c9a868SElliott Hughes % 9474*d5c9a868SElliott Hughes % don't lose footnotes inside @float. 9475*d5c9a868SElliott Hughes % 9476*d5c9a868SElliott Hughes % BEWARE: when the floats start float, we have to issue warning whenever an 9477*d5c9a868SElliott Hughes % insert appears inside a float which could possibly float. --kasal, 26may04 9478*d5c9a868SElliott Hughes % 9479*d5c9a868SElliott Hughes \startsavinginserts 9480*d5c9a868SElliott Hughes % 9481*d5c9a868SElliott Hughes % We can't be used inside a paragraph. 9482*d5c9a868SElliott Hughes \par 9483*d5c9a868SElliott Hughes % 9484*d5c9a868SElliott Hughes \vtop\bgroup 9485*d5c9a868SElliott Hughes \def\floattype{#1}% 9486*d5c9a868SElliott Hughes \def\floatlabel{#2}% 9487*d5c9a868SElliott Hughes \def\floatloc{#3}% we do nothing with this yet. 9488*d5c9a868SElliott Hughes % 9489*d5c9a868SElliott Hughes \ifx\floattype\empty 9490*d5c9a868SElliott Hughes \let\safefloattype=\empty 9491*d5c9a868SElliott Hughes \else 9492*d5c9a868SElliott Hughes {% 9493*d5c9a868SElliott Hughes % the floattype might have accents or other special characters, 9494*d5c9a868SElliott Hughes % but we need to use it in a control sequence name. 9495*d5c9a868SElliott Hughes \indexnofonts 9496*d5c9a868SElliott Hughes \turnoffactive 9497*d5c9a868SElliott Hughes \xdef\safefloattype{\floattype}% 9498*d5c9a868SElliott Hughes }% 9499*d5c9a868SElliott Hughes \fi 9500*d5c9a868SElliott Hughes % 9501*d5c9a868SElliott Hughes % If label is given but no type, we handle that as the empty type. 9502*d5c9a868SElliott Hughes \ifx\floatlabel\empty \else 9503*d5c9a868SElliott Hughes % We want each FLOATTYPE to be numbered separately (Figure 1, 9504*d5c9a868SElliott Hughes % Table 1, Figure 2, ...). (And if no label, no number.) 9505*d5c9a868SElliott Hughes % 9506*d5c9a868SElliott Hughes \expandafter\getfloatno\csname\safefloattype floatno\endcsname 9507*d5c9a868SElliott Hughes \global\advance\floatno by 1 9508*d5c9a868SElliott Hughes % 9509*d5c9a868SElliott Hughes {% 9510*d5c9a868SElliott Hughes % This magic value for \currentsection is output by \setref as the 9511*d5c9a868SElliott Hughes % XREFLABEL-title value. \xrefX uses it to distinguish float 9512*d5c9a868SElliott Hughes % labels (which have a completely different output format) from 9513*d5c9a868SElliott Hughes % node and anchor labels. And \xrdef uses it to construct the 9514*d5c9a868SElliott Hughes % lists of floats. 9515*d5c9a868SElliott Hughes % 9516*d5c9a868SElliott Hughes \edef\currentsection{\floatmagic=\safefloattype}% 9517*d5c9a868SElliott Hughes \setref{\floatlabel}{Yfloat}% 9518*d5c9a868SElliott Hughes }% 9519*d5c9a868SElliott Hughes \fi 9520*d5c9a868SElliott Hughes % 9521*d5c9a868SElliott Hughes % start with \parskip glue, I guess. 9522*d5c9a868SElliott Hughes \vskip\parskip 9523*d5c9a868SElliott Hughes % 9524*d5c9a868SElliott Hughes % Don't suppress indentation if a float happens to start a section. 9525*d5c9a868SElliott Hughes \restorefirstparagraphindent 9526*d5c9a868SElliott Hughes} 9527*d5c9a868SElliott Hughes 9528*d5c9a868SElliott Hughes% we have these possibilities: 9529*d5c9a868SElliott Hughes% @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap 9530*d5c9a868SElliott Hughes% @float Foo,lbl & no caption: Foo 1.1 9531*d5c9a868SElliott Hughes% @float Foo & @caption{Cap}: Foo: Cap 9532*d5c9a868SElliott Hughes% @float Foo & no caption: Foo 9533*d5c9a868SElliott Hughes% @float ,lbl & Caption{Cap}: 1.1: Cap 9534*d5c9a868SElliott Hughes% @float ,lbl & no caption: 1.1 9535*d5c9a868SElliott Hughes% @float & @caption{Cap}: Cap 9536*d5c9a868SElliott Hughes% @float & no caption: 9537*d5c9a868SElliott Hughes% 9538*d5c9a868SElliott Hughes\def\Efloat{% 9539*d5c9a868SElliott Hughes \let\floatident = \empty 9540*d5c9a868SElliott Hughes % 9541*d5c9a868SElliott Hughes % In all cases, if we have a float type, it comes first. 9542*d5c9a868SElliott Hughes \ifx\floattype\empty \else \def\floatident{\floattype}\fi 9543*d5c9a868SElliott Hughes % 9544*d5c9a868SElliott Hughes % If we have an xref label, the number comes next. 9545*d5c9a868SElliott Hughes \ifx\floatlabel\empty \else 9546*d5c9a868SElliott Hughes \ifx\floattype\empty \else % if also had float type, need tie first. 9547*d5c9a868SElliott Hughes \appendtomacro\floatident{\tie}% 9548*d5c9a868SElliott Hughes \fi 9549*d5c9a868SElliott Hughes % the number. 9550*d5c9a868SElliott Hughes \appendtomacro\floatident{\chaplevelprefix\the\floatno}% 9551*d5c9a868SElliott Hughes \fi 9552*d5c9a868SElliott Hughes % 9553*d5c9a868SElliott Hughes % Start the printed caption with what we've constructed in 9554*d5c9a868SElliott Hughes % \floatident, but keep it separate; we need \floatident again. 9555*d5c9a868SElliott Hughes \let\captionline = \floatident 9556*d5c9a868SElliott Hughes % 9557*d5c9a868SElliott Hughes \ifx\thiscaption\empty \else 9558*d5c9a868SElliott Hughes \ifx\floatident\empty \else 9559*d5c9a868SElliott Hughes \appendtomacro\captionline{: }% had ident, so need a colon between 9560*d5c9a868SElliott Hughes \fi 9561*d5c9a868SElliott Hughes % 9562*d5c9a868SElliott Hughes % caption text. 9563*d5c9a868SElliott Hughes \appendtomacro\captionline{\scanexp\thiscaption}% 9564*d5c9a868SElliott Hughes \fi 9565*d5c9a868SElliott Hughes % 9566*d5c9a868SElliott Hughes % If we have anything to print, print it, with space before. 9567*d5c9a868SElliott Hughes % Eventually this needs to become an \insert. 9568*d5c9a868SElliott Hughes \ifx\captionline\empty \else 9569*d5c9a868SElliott Hughes \vskip.5\parskip 9570*d5c9a868SElliott Hughes \captionline 9571*d5c9a868SElliott Hughes % 9572*d5c9a868SElliott Hughes % Space below caption. 9573*d5c9a868SElliott Hughes \vskip\parskip 9574*d5c9a868SElliott Hughes \fi 9575*d5c9a868SElliott Hughes % 9576*d5c9a868SElliott Hughes % If have an xref label, write the list of floats info. Do this 9577*d5c9a868SElliott Hughes % after the caption, to avoid chance of it being a breakpoint. 9578*d5c9a868SElliott Hughes \ifx\floatlabel\empty \else 9579*d5c9a868SElliott Hughes % Write the text that goes in the lof to the aux file as 9580*d5c9a868SElliott Hughes % \floatlabel-lof. Besides \floatident, we include the short 9581*d5c9a868SElliott Hughes % caption if specified, else the full caption if specified, else nothing. 9582*d5c9a868SElliott Hughes {% 9583*d5c9a868SElliott Hughes \requireauxfile 9584*d5c9a868SElliott Hughes \atdummies 9585*d5c9a868SElliott Hughes % 9586*d5c9a868SElliott Hughes \ifx\thisshortcaption\empty 9587*d5c9a868SElliott Hughes \def\gtemp{\thiscaption}% 9588*d5c9a868SElliott Hughes \else 9589*d5c9a868SElliott Hughes \def\gtemp{\thisshortcaption}% 9590*d5c9a868SElliott Hughes \fi 9591*d5c9a868SElliott Hughes \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident 9592*d5c9a868SElliott Hughes \ifx\gtemp\empty \else : \gtemp \fi}}% 9593*d5c9a868SElliott Hughes }% 9594*d5c9a868SElliott Hughes \fi 9595*d5c9a868SElliott Hughes \egroup % end of \vtop 9596*d5c9a868SElliott Hughes % 9597*d5c9a868SElliott Hughes \checkinserts 9598*d5c9a868SElliott Hughes} 9599*d5c9a868SElliott Hughes 9600*d5c9a868SElliott Hughes% Append the tokens #2 to the definition of macro #1, not expanding either. 9601*d5c9a868SElliott Hughes% 9602*d5c9a868SElliott Hughes\def\appendtomacro#1#2{% 9603*d5c9a868SElliott Hughes \expandafter\def\expandafter#1\expandafter{#1#2}% 9604*d5c9a868SElliott Hughes} 9605*d5c9a868SElliott Hughes 9606*d5c9a868SElliott Hughes% @caption, @shortcaption 9607*d5c9a868SElliott Hughes% 9608*d5c9a868SElliott Hughes\def\caption{\docaption\thiscaption} 9609*d5c9a868SElliott Hughes\def\shortcaption{\docaption\thisshortcaption} 9610*d5c9a868SElliott Hughes\def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption} 9611*d5c9a868SElliott Hughes\def\defcaption#1#2{\egroup \def#1{#2}} 9612*d5c9a868SElliott Hughes 9613*d5c9a868SElliott Hughes% The parameter is the control sequence identifying the counter we are 9614*d5c9a868SElliott Hughes% going to use. Create it if it doesn't exist and assign it to \floatno. 9615*d5c9a868SElliott Hughes\def\getfloatno#1{% 9616*d5c9a868SElliott Hughes \ifx#1\relax 9617*d5c9a868SElliott Hughes % Haven't seen this figure type before. 9618*d5c9a868SElliott Hughes \csname newcount\endcsname #1% 9619*d5c9a868SElliott Hughes % 9620*d5c9a868SElliott Hughes % Remember to reset this floatno at the next chap. 9621*d5c9a868SElliott Hughes \expandafter\gdef\expandafter\resetallfloatnos 9622*d5c9a868SElliott Hughes \expandafter{\resetallfloatnos #1=0 }% 9623*d5c9a868SElliott Hughes \fi 9624*d5c9a868SElliott Hughes \let\floatno#1% 9625*d5c9a868SElliott Hughes} 9626*d5c9a868SElliott Hughes 9627*d5c9a868SElliott Hughes% \setref calls this to get the XREFLABEL-snt value. We want an @xref 9628*d5c9a868SElliott Hughes% to the FLOATLABEL to expand to "Figure 3.1". We call \setref when we 9629*d5c9a868SElliott Hughes% first read the @float command. 9630*d5c9a868SElliott Hughes% 9631*d5c9a868SElliott Hughes\def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}% 9632*d5c9a868SElliott Hughes 9633*d5c9a868SElliott Hughes% Magic string used for the XREFLABEL-title value, so \xrefX can 9634*d5c9a868SElliott Hughes% distinguish floats from other xref types. 9635*d5c9a868SElliott Hughes\def\floatmagic{!!float!!} 9636*d5c9a868SElliott Hughes 9637*d5c9a868SElliott Hughes% #1 is the control sequence we are passed; we expand into a conditional 9638*d5c9a868SElliott Hughes% which is true if #1 represents a float ref. That is, the magic 9639*d5c9a868SElliott Hughes% \currentsection value which we \setref above. 9640*d5c9a868SElliott Hughes% 9641*d5c9a868SElliott Hughes\def\iffloat#1{\expandafter\doiffloat#1==\finish} 9642*d5c9a868SElliott Hughes% 9643*d5c9a868SElliott Hughes% #1 is (maybe) the \floatmagic string. If so, #2 will be the 9644*d5c9a868SElliott Hughes% (safe) float type for this float. We set \iffloattype to #2. 9645*d5c9a868SElliott Hughes% 9646*d5c9a868SElliott Hughes\def\doiffloat#1=#2=#3\finish{% 9647*d5c9a868SElliott Hughes \def\temp{#1}% 9648*d5c9a868SElliott Hughes \def\iffloattype{#2}% 9649*d5c9a868SElliott Hughes \ifx\temp\floatmagic 9650*d5c9a868SElliott Hughes} 9651*d5c9a868SElliott Hughes 9652*d5c9a868SElliott Hughes% @listoffloats FLOATTYPE - print a list of floats like a table of contents. 9653*d5c9a868SElliott Hughes% 9654*d5c9a868SElliott Hughes\parseargdef\listoffloats{% 9655*d5c9a868SElliott Hughes \def\floattype{#1}% floattype 9656*d5c9a868SElliott Hughes {% 9657*d5c9a868SElliott Hughes % the floattype might have accents or other special characters, 9658*d5c9a868SElliott Hughes % but we need to use it in a control sequence name. 9659*d5c9a868SElliott Hughes \indexnofonts 9660*d5c9a868SElliott Hughes \turnoffactive 9661*d5c9a868SElliott Hughes \xdef\safefloattype{\floattype}% 9662*d5c9a868SElliott Hughes }% 9663*d5c9a868SElliott Hughes % 9664*d5c9a868SElliott Hughes % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE. 9665*d5c9a868SElliott Hughes \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax 9666*d5c9a868SElliott Hughes \ifhavexrefs 9667*d5c9a868SElliott Hughes % if the user said @listoffloats foo but never @float foo. 9668*d5c9a868SElliott Hughes \message{\linenumber No `\safefloattype' floats to list.}% 9669*d5c9a868SElliott Hughes \fi 9670*d5c9a868SElliott Hughes \else 9671*d5c9a868SElliott Hughes \begingroup 9672*d5c9a868SElliott Hughes \leftskip=\tocindent % indent these entries like a toc 9673*d5c9a868SElliott Hughes \let\do=\listoffloatsdo 9674*d5c9a868SElliott Hughes \csname floatlist\safefloattype\endcsname 9675*d5c9a868SElliott Hughes \endgroup 9676*d5c9a868SElliott Hughes \fi 9677*d5c9a868SElliott Hughes} 9678*d5c9a868SElliott Hughes 9679*d5c9a868SElliott Hughes% This is called on each entry in a list of floats. We're passed the 9680*d5c9a868SElliott Hughes% xref label, in the form LABEL-title, which is how we save it in the 9681*d5c9a868SElliott Hughes% aux file. We strip off the -title and look up \XRLABEL-lof, which 9682*d5c9a868SElliott Hughes% has the text we're supposed to typeset here. 9683*d5c9a868SElliott Hughes% 9684*d5c9a868SElliott Hughes% Figures without xref labels will not be included in the list (since 9685*d5c9a868SElliott Hughes% they won't appear in the aux file). 9686*d5c9a868SElliott Hughes% 9687*d5c9a868SElliott Hughes\def\listoffloatsdo#1{\listoffloatsdoentry#1\finish} 9688*d5c9a868SElliott Hughes\def\listoffloatsdoentry#1-title\finish{{% 9689*d5c9a868SElliott Hughes % Can't fully expand XR#1-lof because it can contain anything. Just 9690*d5c9a868SElliott Hughes % pass the control sequence. On the other hand, XR#1-pg is just the 9691*d5c9a868SElliott Hughes % page number, and we want to fully expand that so we can get a link 9692*d5c9a868SElliott Hughes % in pdf output. 9693*d5c9a868SElliott Hughes \toksA = \expandafter{\csname XR#1-lof\endcsname}% 9694*d5c9a868SElliott Hughes % 9695*d5c9a868SElliott Hughes % use the same \entry macro we use to generate the TOC and index. 9696*d5c9a868SElliott Hughes \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}% 9697*d5c9a868SElliott Hughes \writeentry 9698*d5c9a868SElliott Hughes}} 9699*d5c9a868SElliott Hughes 9700*d5c9a868SElliott Hughes 9701*d5c9a868SElliott Hughes\message{localization,} 9702*d5c9a868SElliott Hughes 9703*d5c9a868SElliott Hughes% For single-language documents, @documentlanguage is usually given very 9704*d5c9a868SElliott Hughes% early, just after @documentencoding. Single argument is the language 9705*d5c9a868SElliott Hughes% (de) or locale (de_DE) abbreviation. 9706*d5c9a868SElliott Hughes% 9707*d5c9a868SElliott Hughes{ 9708*d5c9a868SElliott Hughes \catcode`\_ = \active 9709*d5c9a868SElliott Hughes \globaldefs=1 9710*d5c9a868SElliott Hughes\parseargdef\documentlanguage{% 9711*d5c9a868SElliott Hughes \tex % read txi-??.tex file in plain TeX. 9712*d5c9a868SElliott Hughes % Read the file by the name they passed if it exists. 9713*d5c9a868SElliott Hughes \let_ = \normalunderscore % normal _ character for filename test 9714*d5c9a868SElliott Hughes \openin 1 txi-#1.tex 9715*d5c9a868SElliott Hughes \ifeof 1 9716*d5c9a868SElliott Hughes \documentlanguagetrywithoutunderscore #1_\finish 9717*d5c9a868SElliott Hughes \else 9718*d5c9a868SElliott Hughes \globaldefs = 1 % everything in the txi-LL files needs to persist 9719*d5c9a868SElliott Hughes \input txi-#1.tex 9720*d5c9a868SElliott Hughes \fi 9721*d5c9a868SElliott Hughes \closein 1 9722*d5c9a868SElliott Hughes \endgroup % end raw TeX 9723*d5c9a868SElliott Hughes} 9724*d5c9a868SElliott Hughes% 9725*d5c9a868SElliott Hughes% If they passed de_DE, and txi-de_DE.tex doesn't exist, 9726*d5c9a868SElliott Hughes% try txi-de.tex. 9727*d5c9a868SElliott Hughes% 9728*d5c9a868SElliott Hughes\gdef\documentlanguagetrywithoutunderscore#1_#2\finish{% 9729*d5c9a868SElliott Hughes \openin 1 txi-#1.tex 9730*d5c9a868SElliott Hughes \ifeof 1 9731*d5c9a868SElliott Hughes \errhelp = \nolanghelp 9732*d5c9a868SElliott Hughes \errmessage{Cannot read language file txi-#1.tex}% 9733*d5c9a868SElliott Hughes \else 9734*d5c9a868SElliott Hughes \globaldefs = 1 % everything in the txi-LL files needs to persist 9735*d5c9a868SElliott Hughes \input txi-#1.tex 9736*d5c9a868SElliott Hughes \fi 9737*d5c9a868SElliott Hughes \closein 1 9738*d5c9a868SElliott Hughes} 9739*d5c9a868SElliott Hughes}% end of special _ catcode 9740*d5c9a868SElliott Hughes% 9741*d5c9a868SElliott Hughes\newhelp\nolanghelp{The given language definition file cannot be found or 9742*d5c9a868SElliott Hughesis empty. Maybe you need to install it? Putting it in the current 9743*d5c9a868SElliott Hughesdirectory should work if nowhere else does.} 9744*d5c9a868SElliott Hughes 9745*d5c9a868SElliott Hughes% This macro is called from txi-??.tex files; the first argument is the 9746*d5c9a868SElliott Hughes% \language name to set (without the "\lang@" prefix), the second and 9747*d5c9a868SElliott Hughes% third args are \{left,right}hyphenmin. 9748*d5c9a868SElliott Hughes% 9749*d5c9a868SElliott Hughes% The language names to pass are determined when the format is built. 9750*d5c9a868SElliott Hughes% See the etex.log file created at that time, e.g., 9751*d5c9a868SElliott Hughes% /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log. 9752*d5c9a868SElliott Hughes% 9753*d5c9a868SElliott Hughes% With TeX Live 2008, etex now includes hyphenation patterns for all 9754*d5c9a868SElliott Hughes% available languages. This means we can support hyphenation in 9755*d5c9a868SElliott Hughes% Texinfo, at least to some extent. (This still doesn't solve the 9756*d5c9a868SElliott Hughes% accented characters problem.) 9757*d5c9a868SElliott Hughes% 9758*d5c9a868SElliott Hughes\catcode`@=11 9759*d5c9a868SElliott Hughes\def\txisetlanguage#1#2#3{% 9760*d5c9a868SElliott Hughes % do not set the language if the name is undefined in the current TeX. 9761*d5c9a868SElliott Hughes \expandafter\ifx\csname lang@#1\endcsname \relax 9762*d5c9a868SElliott Hughes \message{no patterns for #1}% 9763*d5c9a868SElliott Hughes \else 9764*d5c9a868SElliott Hughes \global\language = \csname lang@#1\endcsname 9765*d5c9a868SElliott Hughes \fi 9766*d5c9a868SElliott Hughes % but there is no harm in adjusting the hyphenmin values regardless. 9767*d5c9a868SElliott Hughes \global\lefthyphenmin = #2\relax 9768*d5c9a868SElliott Hughes \global\righthyphenmin = #3\relax 9769*d5c9a868SElliott Hughes} 9770*d5c9a868SElliott Hughes 9771*d5c9a868SElliott Hughes% XeTeX and LuaTeX can handle Unicode natively. 9772*d5c9a868SElliott Hughes% Their default I/O uses UTF-8 sequences instead of a byte-wise operation. 9773*d5c9a868SElliott Hughes% Other TeX engines' I/O (pdfTeX, etc.) is byte-wise. 9774*d5c9a868SElliott Hughes% 9775*d5c9a868SElliott Hughes\newif\iftxinativeunicodecapable 9776*d5c9a868SElliott Hughes\newif\iftxiusebytewiseio 9777*d5c9a868SElliott Hughes 9778*d5c9a868SElliott Hughes\ifx\XeTeXrevision\thisisundefined 9779*d5c9a868SElliott Hughes \ifx\luatexversion\thisisundefined 9780*d5c9a868SElliott Hughes \txinativeunicodecapablefalse 9781*d5c9a868SElliott Hughes \txiusebytewiseiotrue 9782*d5c9a868SElliott Hughes \else 9783*d5c9a868SElliott Hughes \txinativeunicodecapabletrue 9784*d5c9a868SElliott Hughes \txiusebytewiseiofalse 9785*d5c9a868SElliott Hughes \fi 9786*d5c9a868SElliott Hughes\else 9787*d5c9a868SElliott Hughes \txinativeunicodecapabletrue 9788*d5c9a868SElliott Hughes \txiusebytewiseiofalse 9789*d5c9a868SElliott Hughes\fi 9790*d5c9a868SElliott Hughes 9791*d5c9a868SElliott Hughes% Set I/O by bytes instead of UTF-8 sequence for XeTeX and LuaTex 9792*d5c9a868SElliott Hughes% for non-UTF-8 (byte-wise) encodings. 9793*d5c9a868SElliott Hughes% 9794*d5c9a868SElliott Hughes\def\setbytewiseio{% 9795*d5c9a868SElliott Hughes \ifx\XeTeXrevision\thisisundefined 9796*d5c9a868SElliott Hughes \else 9797*d5c9a868SElliott Hughes \XeTeXdefaultencoding "bytes" % For subsequent files to be read 9798*d5c9a868SElliott Hughes \XeTeXinputencoding "bytes" % For document root file 9799*d5c9a868SElliott Hughes % Unfortunately, there seems to be no corresponding XeTeX command for 9800*d5c9a868SElliott Hughes % output encoding. This is a problem for auxiliary index and TOC files. 9801*d5c9a868SElliott Hughes % The only solution would be perhaps to write out @U{...} sequences in 9802*d5c9a868SElliott Hughes % place of non-ASCII characters. 9803*d5c9a868SElliott Hughes \fi 9804*d5c9a868SElliott Hughes 9805*d5c9a868SElliott Hughes \ifx\luatexversion\thisisundefined 9806*d5c9a868SElliott Hughes \else 9807*d5c9a868SElliott Hughes \directlua{ 9808*d5c9a868SElliott Hughes local utf8_char, byte, gsub = unicode.utf8.char, string.byte, string.gsub 9809*d5c9a868SElliott Hughes local function convert_char (char) 9810*d5c9a868SElliott Hughes return utf8_char(byte(char)) 9811*d5c9a868SElliott Hughes end 9812*d5c9a868SElliott Hughes 9813*d5c9a868SElliott Hughes local function convert_line (line) 9814*d5c9a868SElliott Hughes return gsub(line, ".", convert_char) 9815*d5c9a868SElliott Hughes end 9816*d5c9a868SElliott Hughes 9817*d5c9a868SElliott Hughes callback.register("process_input_buffer", convert_line) 9818*d5c9a868SElliott Hughes 9819*d5c9a868SElliott Hughes local function convert_line_out (line) 9820*d5c9a868SElliott Hughes local line_out = "" 9821*d5c9a868SElliott Hughes for c in string.utfvalues(line) do 9822*d5c9a868SElliott Hughes line_out = line_out .. string.char(c) 9823*d5c9a868SElliott Hughes end 9824*d5c9a868SElliott Hughes return line_out 9825*d5c9a868SElliott Hughes end 9826*d5c9a868SElliott Hughes 9827*d5c9a868SElliott Hughes callback.register("process_output_buffer", convert_line_out) 9828*d5c9a868SElliott Hughes } 9829*d5c9a868SElliott Hughes \fi 9830*d5c9a868SElliott Hughes 9831*d5c9a868SElliott Hughes \txiusebytewiseiotrue 9832*d5c9a868SElliott Hughes} 9833*d5c9a868SElliott Hughes 9834*d5c9a868SElliott Hughes 9835*d5c9a868SElliott Hughes% Helpers for encodings. 9836*d5c9a868SElliott Hughes% Set the catcode of characters 128 through 255 to the specified number. 9837*d5c9a868SElliott Hughes% 9838*d5c9a868SElliott Hughes\def\setnonasciicharscatcode#1{% 9839*d5c9a868SElliott Hughes \count255=128 9840*d5c9a868SElliott Hughes \loop\ifnum\count255<256 9841*d5c9a868SElliott Hughes \global\catcode\count255=#1\relax 9842*d5c9a868SElliott Hughes \advance\count255 by 1 9843*d5c9a868SElliott Hughes \repeat 9844*d5c9a868SElliott Hughes} 9845*d5c9a868SElliott Hughes 9846*d5c9a868SElliott Hughes\def\setnonasciicharscatcodenonglobal#1{% 9847*d5c9a868SElliott Hughes \count255=128 9848*d5c9a868SElliott Hughes \loop\ifnum\count255<256 9849*d5c9a868SElliott Hughes \catcode\count255=#1\relax 9850*d5c9a868SElliott Hughes \advance\count255 by 1 9851*d5c9a868SElliott Hughes \repeat 9852*d5c9a868SElliott Hughes} 9853*d5c9a868SElliott Hughes 9854*d5c9a868SElliott Hughes% @documentencoding sets the definition of non-ASCII characters 9855*d5c9a868SElliott Hughes% according to the specified encoding. 9856*d5c9a868SElliott Hughes% 9857*d5c9a868SElliott Hughes\def\documentencoding{\parseargusing\filenamecatcodes\documentencodingzzz} 9858*d5c9a868SElliott Hughes\def\documentencodingzzz#1{% 9859*d5c9a868SElliott Hughes % 9860*d5c9a868SElliott Hughes % Encoding being declared for the document. 9861*d5c9a868SElliott Hughes \def\declaredencoding{\csname #1.enc\endcsname}% 9862*d5c9a868SElliott Hughes % 9863*d5c9a868SElliott Hughes % Supported encodings: names converted to tokens in order to be able 9864*d5c9a868SElliott Hughes % to compare them with \ifx. 9865*d5c9a868SElliott Hughes \def\ascii{\csname US-ASCII.enc\endcsname}% 9866*d5c9a868SElliott Hughes \def\latnine{\csname ISO-8859-15.enc\endcsname}% 9867*d5c9a868SElliott Hughes \def\latone{\csname ISO-8859-1.enc\endcsname}% 9868*d5c9a868SElliott Hughes \def\lattwo{\csname ISO-8859-2.enc\endcsname}% 9869*d5c9a868SElliott Hughes \def\utfeight{\csname UTF-8.enc\endcsname}% 9870*d5c9a868SElliott Hughes % 9871*d5c9a868SElliott Hughes \ifx \declaredencoding \ascii 9872*d5c9a868SElliott Hughes \asciichardefs 9873*d5c9a868SElliott Hughes % 9874*d5c9a868SElliott Hughes \else \ifx \declaredencoding \lattwo 9875*d5c9a868SElliott Hughes \iftxinativeunicodecapable 9876*d5c9a868SElliott Hughes \setbytewiseio 9877*d5c9a868SElliott Hughes \fi 9878*d5c9a868SElliott Hughes \setnonasciicharscatcode\active 9879*d5c9a868SElliott Hughes \lattwochardefs 9880*d5c9a868SElliott Hughes % 9881*d5c9a868SElliott Hughes \else \ifx \declaredencoding \latone 9882*d5c9a868SElliott Hughes \iftxinativeunicodecapable 9883*d5c9a868SElliott Hughes \setbytewiseio 9884*d5c9a868SElliott Hughes \fi 9885*d5c9a868SElliott Hughes \setnonasciicharscatcode\active 9886*d5c9a868SElliott Hughes \latonechardefs 9887*d5c9a868SElliott Hughes % 9888*d5c9a868SElliott Hughes \else \ifx \declaredencoding \latnine 9889*d5c9a868SElliott Hughes \iftxinativeunicodecapable 9890*d5c9a868SElliott Hughes \setbytewiseio 9891*d5c9a868SElliott Hughes \fi 9892*d5c9a868SElliott Hughes \setnonasciicharscatcode\active 9893*d5c9a868SElliott Hughes \latninechardefs 9894*d5c9a868SElliott Hughes % 9895*d5c9a868SElliott Hughes \else \ifx \declaredencoding \utfeight 9896*d5c9a868SElliott Hughes \iftxinativeunicodecapable 9897*d5c9a868SElliott Hughes % For native Unicode handling (XeTeX and LuaTeX) 9898*d5c9a868SElliott Hughes \nativeunicodechardefs 9899*d5c9a868SElliott Hughes \else 9900*d5c9a868SElliott Hughes % For treating UTF-8 as byte sequences (TeX, eTeX and pdfTeX) 9901*d5c9a868SElliott Hughes \setnonasciicharscatcode\active 9902*d5c9a868SElliott Hughes % since we already invoked \utfeightchardefs at the top level 9903*d5c9a868SElliott Hughes % (below), do not re-invoke it, otherwise our check for duplicated 9904*d5c9a868SElliott Hughes % definitions gets triggered. Making non-ascii chars active is 9905*d5c9a868SElliott Hughes % sufficient. 9906*d5c9a868SElliott Hughes \fi 9907*d5c9a868SElliott Hughes % 9908*d5c9a868SElliott Hughes \else 9909*d5c9a868SElliott Hughes \message{Ignoring unknown document encoding: #1.}% 9910*d5c9a868SElliott Hughes % 9911*d5c9a868SElliott Hughes \fi % utfeight 9912*d5c9a868SElliott Hughes \fi % latnine 9913*d5c9a868SElliott Hughes \fi % latone 9914*d5c9a868SElliott Hughes \fi % lattwo 9915*d5c9a868SElliott Hughes \fi % ascii 9916*d5c9a868SElliott Hughes % 9917*d5c9a868SElliott Hughes \ifx\XeTeXrevision\thisisundefined 9918*d5c9a868SElliott Hughes \else 9919*d5c9a868SElliott Hughes \ifx \declaredencoding \utfeight 9920*d5c9a868SElliott Hughes \else 9921*d5c9a868SElliott Hughes \ifx \declaredencoding \ascii 9922*d5c9a868SElliott Hughes \else 9923*d5c9a868SElliott Hughes \message{Warning: XeTeX with non-UTF-8 encodings cannot handle % 9924*d5c9a868SElliott Hughes non-ASCII characters in auxiliary files.}% 9925*d5c9a868SElliott Hughes \fi 9926*d5c9a868SElliott Hughes \fi 9927*d5c9a868SElliott Hughes \fi 9928*d5c9a868SElliott Hughes} 9929*d5c9a868SElliott Hughes 9930*d5c9a868SElliott Hughes% emacs-page 9931*d5c9a868SElliott Hughes% A message to be logged when using a character that isn't available 9932*d5c9a868SElliott Hughes% the default font encoding (OT1). 9933*d5c9a868SElliott Hughes% 9934*d5c9a868SElliott Hughes\def\missingcharmsg#1{\message{Character missing, sorry: #1.}} 9935*d5c9a868SElliott Hughes 9936*d5c9a868SElliott Hughes% Take account of \c (plain) vs. \, (Texinfo) difference. 9937*d5c9a868SElliott Hughes\def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi} 9938*d5c9a868SElliott Hughes 9939*d5c9a868SElliott Hughes% First, make active non-ASCII characters in order for them to be 9940*d5c9a868SElliott Hughes% correctly categorized when TeX reads the replacement text of 9941*d5c9a868SElliott Hughes% macros containing the character definitions. 9942*d5c9a868SElliott Hughes\setnonasciicharscatcode\active 9943*d5c9a868SElliott Hughes% 9944*d5c9a868SElliott Hughes 9945*d5c9a868SElliott Hughes\def\gdefchar#1#2{% 9946*d5c9a868SElliott Hughes\gdef#1{% 9947*d5c9a868SElliott Hughes \ifpassthroughchars 9948*d5c9a868SElliott Hughes \string#1% 9949*d5c9a868SElliott Hughes \else 9950*d5c9a868SElliott Hughes #2% 9951*d5c9a868SElliott Hughes \fi 9952*d5c9a868SElliott Hughes}} 9953*d5c9a868SElliott Hughes 9954*d5c9a868SElliott Hughes% Latin1 (ISO-8859-1) character definitions. 9955*d5c9a868SElliott Hughes\def\latonechardefs{% 9956*d5c9a868SElliott Hughes \gdefchar^^a0{\tie} 9957*d5c9a868SElliott Hughes \gdefchar^^a1{\exclamdown} 9958*d5c9a868SElliott Hughes \gdefchar^^a2{{\tcfont \char162}} % cent 9959*d5c9a868SElliott Hughes \gdefchar^^a3{\pounds{}} 9960*d5c9a868SElliott Hughes \gdefchar^^a4{{\tcfont \char164}} % currency 9961*d5c9a868SElliott Hughes \gdefchar^^a5{{\tcfont \char165}} % yen 9962*d5c9a868SElliott Hughes \gdefchar^^a6{{\tcfont \char166}} % broken bar 9963*d5c9a868SElliott Hughes \gdefchar^^a7{\S} 9964*d5c9a868SElliott Hughes \gdefchar^^a8{\"{}} 9965*d5c9a868SElliott Hughes \gdefchar^^a9{\copyright{}} 9966*d5c9a868SElliott Hughes \gdefchar^^aa{\ordf} 9967*d5c9a868SElliott Hughes \gdefchar^^ab{\guillemetleft{}} 9968*d5c9a868SElliott Hughes \gdefchar^^ac{\ensuremath\lnot} 9969*d5c9a868SElliott Hughes \gdefchar^^ad{\-} 9970*d5c9a868SElliott Hughes \gdefchar^^ae{\registeredsymbol{}} 9971*d5c9a868SElliott Hughes \gdefchar^^af{\={}} 9972*d5c9a868SElliott Hughes % 9973*d5c9a868SElliott Hughes \gdefchar^^b0{\textdegree} 9974*d5c9a868SElliott Hughes \gdefchar^^b1{$\pm$} 9975*d5c9a868SElliott Hughes \gdefchar^^b2{$^2$} 9976*d5c9a868SElliott Hughes \gdefchar^^b3{$^3$} 9977*d5c9a868SElliott Hughes \gdefchar^^b4{\'{}} 9978*d5c9a868SElliott Hughes \gdefchar^^b5{$\mu$} 9979*d5c9a868SElliott Hughes \gdefchar^^b6{\P} 9980*d5c9a868SElliott Hughes \gdefchar^^b7{\ensuremath\cdot} 9981*d5c9a868SElliott Hughes \gdefchar^^b8{\cedilla\ } 9982*d5c9a868SElliott Hughes \gdefchar^^b9{$^1$} 9983*d5c9a868SElliott Hughes \gdefchar^^ba{\ordm} 9984*d5c9a868SElliott Hughes \gdefchar^^bb{\guillemetright{}} 9985*d5c9a868SElliott Hughes \gdefchar^^bc{$1\over4$} 9986*d5c9a868SElliott Hughes \gdefchar^^bd{$1\over2$} 9987*d5c9a868SElliott Hughes \gdefchar^^be{$3\over4$} 9988*d5c9a868SElliott Hughes \gdefchar^^bf{\questiondown} 9989*d5c9a868SElliott Hughes % 9990*d5c9a868SElliott Hughes \gdefchar^^c0{\`A} 9991*d5c9a868SElliott Hughes \gdefchar^^c1{\'A} 9992*d5c9a868SElliott Hughes \gdefchar^^c2{\^A} 9993*d5c9a868SElliott Hughes \gdefchar^^c3{\~A} 9994*d5c9a868SElliott Hughes \gdefchar^^c4{\"A} 9995*d5c9a868SElliott Hughes \gdefchar^^c5{\ringaccent A} 9996*d5c9a868SElliott Hughes \gdefchar^^c6{\AE} 9997*d5c9a868SElliott Hughes \gdefchar^^c7{\cedilla C} 9998*d5c9a868SElliott Hughes \gdefchar^^c8{\`E} 9999*d5c9a868SElliott Hughes \gdefchar^^c9{\'E} 10000*d5c9a868SElliott Hughes \gdefchar^^ca{\^E} 10001*d5c9a868SElliott Hughes \gdefchar^^cb{\"E} 10002*d5c9a868SElliott Hughes \gdefchar^^cc{\`I} 10003*d5c9a868SElliott Hughes \gdefchar^^cd{\'I} 10004*d5c9a868SElliott Hughes \gdefchar^^ce{\^I} 10005*d5c9a868SElliott Hughes \gdefchar^^cf{\"I} 10006*d5c9a868SElliott Hughes % 10007*d5c9a868SElliott Hughes \gdefchar^^d0{\DH} 10008*d5c9a868SElliott Hughes \gdefchar^^d1{\~N} 10009*d5c9a868SElliott Hughes \gdefchar^^d2{\`O} 10010*d5c9a868SElliott Hughes \gdefchar^^d3{\'O} 10011*d5c9a868SElliott Hughes \gdefchar^^d4{\^O} 10012*d5c9a868SElliott Hughes \gdefchar^^d5{\~O} 10013*d5c9a868SElliott Hughes \gdefchar^^d6{\"O} 10014*d5c9a868SElliott Hughes \gdefchar^^d7{$\times$} 10015*d5c9a868SElliott Hughes \gdefchar^^d8{\O} 10016*d5c9a868SElliott Hughes \gdefchar^^d9{\`U} 10017*d5c9a868SElliott Hughes \gdefchar^^da{\'U} 10018*d5c9a868SElliott Hughes \gdefchar^^db{\^U} 10019*d5c9a868SElliott Hughes \gdefchar^^dc{\"U} 10020*d5c9a868SElliott Hughes \gdefchar^^dd{\'Y} 10021*d5c9a868SElliott Hughes \gdefchar^^de{\TH} 10022*d5c9a868SElliott Hughes \gdefchar^^df{\ss} 10023*d5c9a868SElliott Hughes % 10024*d5c9a868SElliott Hughes \gdefchar^^e0{\`a} 10025*d5c9a868SElliott Hughes \gdefchar^^e1{\'a} 10026*d5c9a868SElliott Hughes \gdefchar^^e2{\^a} 10027*d5c9a868SElliott Hughes \gdefchar^^e3{\~a} 10028*d5c9a868SElliott Hughes \gdefchar^^e4{\"a} 10029*d5c9a868SElliott Hughes \gdefchar^^e5{\ringaccent a} 10030*d5c9a868SElliott Hughes \gdefchar^^e6{\ae} 10031*d5c9a868SElliott Hughes \gdefchar^^e7{\cedilla c} 10032*d5c9a868SElliott Hughes \gdefchar^^e8{\`e} 10033*d5c9a868SElliott Hughes \gdefchar^^e9{\'e} 10034*d5c9a868SElliott Hughes \gdefchar^^ea{\^e} 10035*d5c9a868SElliott Hughes \gdefchar^^eb{\"e} 10036*d5c9a868SElliott Hughes \gdefchar^^ec{\`{\dotless i}} 10037*d5c9a868SElliott Hughes \gdefchar^^ed{\'{\dotless i}} 10038*d5c9a868SElliott Hughes \gdefchar^^ee{\^{\dotless i}} 10039*d5c9a868SElliott Hughes \gdefchar^^ef{\"{\dotless i}} 10040*d5c9a868SElliott Hughes % 10041*d5c9a868SElliott Hughes \gdefchar^^f0{\dh} 10042*d5c9a868SElliott Hughes \gdefchar^^f1{\~n} 10043*d5c9a868SElliott Hughes \gdefchar^^f2{\`o} 10044*d5c9a868SElliott Hughes \gdefchar^^f3{\'o} 10045*d5c9a868SElliott Hughes \gdefchar^^f4{\^o} 10046*d5c9a868SElliott Hughes \gdefchar^^f5{\~o} 10047*d5c9a868SElliott Hughes \gdefchar^^f6{\"o} 10048*d5c9a868SElliott Hughes \gdefchar^^f7{$\div$} 10049*d5c9a868SElliott Hughes \gdefchar^^f8{\o} 10050*d5c9a868SElliott Hughes \gdefchar^^f9{\`u} 10051*d5c9a868SElliott Hughes \gdefchar^^fa{\'u} 10052*d5c9a868SElliott Hughes \gdefchar^^fb{\^u} 10053*d5c9a868SElliott Hughes \gdefchar^^fc{\"u} 10054*d5c9a868SElliott Hughes \gdefchar^^fd{\'y} 10055*d5c9a868SElliott Hughes \gdefchar^^fe{\th} 10056*d5c9a868SElliott Hughes \gdefchar^^ff{\"y} 10057*d5c9a868SElliott Hughes} 10058*d5c9a868SElliott Hughes 10059*d5c9a868SElliott Hughes% Latin9 (ISO-8859-15) encoding character definitions. 10060*d5c9a868SElliott Hughes\def\latninechardefs{% 10061*d5c9a868SElliott Hughes % Encoding is almost identical to Latin1. 10062*d5c9a868SElliott Hughes \latonechardefs 10063*d5c9a868SElliott Hughes % 10064*d5c9a868SElliott Hughes \gdefchar^^a4{\euro{}} 10065*d5c9a868SElliott Hughes \gdefchar^^a6{\v S} 10066*d5c9a868SElliott Hughes \gdefchar^^a8{\v s} 10067*d5c9a868SElliott Hughes \gdefchar^^b4{\v Z} 10068*d5c9a868SElliott Hughes \gdefchar^^b8{\v z} 10069*d5c9a868SElliott Hughes \gdefchar^^bc{\OE} 10070*d5c9a868SElliott Hughes \gdefchar^^bd{\oe} 10071*d5c9a868SElliott Hughes \gdefchar^^be{\"Y} 10072*d5c9a868SElliott Hughes} 10073*d5c9a868SElliott Hughes 10074*d5c9a868SElliott Hughes% Latin2 (ISO-8859-2) character definitions. 10075*d5c9a868SElliott Hughes\def\lattwochardefs{% 10076*d5c9a868SElliott Hughes \gdefchar^^a0{\tie} 10077*d5c9a868SElliott Hughes \gdefchar^^a1{\ogonek{A}} 10078*d5c9a868SElliott Hughes \gdefchar^^a2{\u{}} 10079*d5c9a868SElliott Hughes \gdefchar^^a3{\L} 10080*d5c9a868SElliott Hughes \gdefchar^^a4{\missingcharmsg{CURRENCY SIGN}} 10081*d5c9a868SElliott Hughes \gdefchar^^a5{\v L} 10082*d5c9a868SElliott Hughes \gdefchar^^a6{\'S} 10083*d5c9a868SElliott Hughes \gdefchar^^a7{\S} 10084*d5c9a868SElliott Hughes \gdefchar^^a8{\"{}} 10085*d5c9a868SElliott Hughes \gdefchar^^a9{\v S} 10086*d5c9a868SElliott Hughes \gdefchar^^aa{\cedilla S} 10087*d5c9a868SElliott Hughes \gdefchar^^ab{\v T} 10088*d5c9a868SElliott Hughes \gdefchar^^ac{\'Z} 10089*d5c9a868SElliott Hughes \gdefchar^^ad{\-} 10090*d5c9a868SElliott Hughes \gdefchar^^ae{\v Z} 10091*d5c9a868SElliott Hughes \gdefchar^^af{\dotaccent Z} 10092*d5c9a868SElliott Hughes % 10093*d5c9a868SElliott Hughes \gdefchar^^b0{\textdegree{}} 10094*d5c9a868SElliott Hughes \gdefchar^^b1{\ogonek{a}} 10095*d5c9a868SElliott Hughes \gdefchar^^b2{\ogonek{ }} 10096*d5c9a868SElliott Hughes \gdefchar^^b3{\l} 10097*d5c9a868SElliott Hughes \gdefchar^^b4{\'{}} 10098*d5c9a868SElliott Hughes \gdefchar^^b5{\v l} 10099*d5c9a868SElliott Hughes \gdefchar^^b6{\'s} 10100*d5c9a868SElliott Hughes \gdefchar^^b7{\v{}} 10101*d5c9a868SElliott Hughes \gdefchar^^b8{\cedilla\ } 10102*d5c9a868SElliott Hughes \gdefchar^^b9{\v s} 10103*d5c9a868SElliott Hughes \gdefchar^^ba{\cedilla s} 10104*d5c9a868SElliott Hughes \gdefchar^^bb{\v t} 10105*d5c9a868SElliott Hughes \gdefchar^^bc{\'z} 10106*d5c9a868SElliott Hughes \gdefchar^^bd{\H{}} 10107*d5c9a868SElliott Hughes \gdefchar^^be{\v z} 10108*d5c9a868SElliott Hughes \gdefchar^^bf{\dotaccent z} 10109*d5c9a868SElliott Hughes % 10110*d5c9a868SElliott Hughes \gdefchar^^c0{\'R} 10111*d5c9a868SElliott Hughes \gdefchar^^c1{\'A} 10112*d5c9a868SElliott Hughes \gdefchar^^c2{\^A} 10113*d5c9a868SElliott Hughes \gdefchar^^c3{\u A} 10114*d5c9a868SElliott Hughes \gdefchar^^c4{\"A} 10115*d5c9a868SElliott Hughes \gdefchar^^c5{\'L} 10116*d5c9a868SElliott Hughes \gdefchar^^c6{\'C} 10117*d5c9a868SElliott Hughes \gdefchar^^c7{\cedilla C} 10118*d5c9a868SElliott Hughes \gdefchar^^c8{\v C} 10119*d5c9a868SElliott Hughes \gdefchar^^c9{\'E} 10120*d5c9a868SElliott Hughes \gdefchar^^ca{\ogonek{E}} 10121*d5c9a868SElliott Hughes \gdefchar^^cb{\"E} 10122*d5c9a868SElliott Hughes \gdefchar^^cc{\v E} 10123*d5c9a868SElliott Hughes \gdefchar^^cd{\'I} 10124*d5c9a868SElliott Hughes \gdefchar^^ce{\^I} 10125*d5c9a868SElliott Hughes \gdefchar^^cf{\v D} 10126*d5c9a868SElliott Hughes % 10127*d5c9a868SElliott Hughes \gdefchar^^d0{\DH} 10128*d5c9a868SElliott Hughes \gdefchar^^d1{\'N} 10129*d5c9a868SElliott Hughes \gdefchar^^d2{\v N} 10130*d5c9a868SElliott Hughes \gdefchar^^d3{\'O} 10131*d5c9a868SElliott Hughes \gdefchar^^d4{\^O} 10132*d5c9a868SElliott Hughes \gdefchar^^d5{\H O} 10133*d5c9a868SElliott Hughes \gdefchar^^d6{\"O} 10134*d5c9a868SElliott Hughes \gdefchar^^d7{$\times$} 10135*d5c9a868SElliott Hughes \gdefchar^^d8{\v R} 10136*d5c9a868SElliott Hughes \gdefchar^^d9{\ringaccent U} 10137*d5c9a868SElliott Hughes \gdefchar^^da{\'U} 10138*d5c9a868SElliott Hughes \gdefchar^^db{\H U} 10139*d5c9a868SElliott Hughes \gdefchar^^dc{\"U} 10140*d5c9a868SElliott Hughes \gdefchar^^dd{\'Y} 10141*d5c9a868SElliott Hughes \gdefchar^^de{\cedilla T} 10142*d5c9a868SElliott Hughes \gdefchar^^df{\ss} 10143*d5c9a868SElliott Hughes % 10144*d5c9a868SElliott Hughes \gdefchar^^e0{\'r} 10145*d5c9a868SElliott Hughes \gdefchar^^e1{\'a} 10146*d5c9a868SElliott Hughes \gdefchar^^e2{\^a} 10147*d5c9a868SElliott Hughes \gdefchar^^e3{\u a} 10148*d5c9a868SElliott Hughes \gdefchar^^e4{\"a} 10149*d5c9a868SElliott Hughes \gdefchar^^e5{\'l} 10150*d5c9a868SElliott Hughes \gdefchar^^e6{\'c} 10151*d5c9a868SElliott Hughes \gdefchar^^e7{\cedilla c} 10152*d5c9a868SElliott Hughes \gdefchar^^e8{\v c} 10153*d5c9a868SElliott Hughes \gdefchar^^e9{\'e} 10154*d5c9a868SElliott Hughes \gdefchar^^ea{\ogonek{e}} 10155*d5c9a868SElliott Hughes \gdefchar^^eb{\"e} 10156*d5c9a868SElliott Hughes \gdefchar^^ec{\v e} 10157*d5c9a868SElliott Hughes \gdefchar^^ed{\'{\dotless{i}}} 10158*d5c9a868SElliott Hughes \gdefchar^^ee{\^{\dotless{i}}} 10159*d5c9a868SElliott Hughes \gdefchar^^ef{\v d} 10160*d5c9a868SElliott Hughes % 10161*d5c9a868SElliott Hughes \gdefchar^^f0{\dh} 10162*d5c9a868SElliott Hughes \gdefchar^^f1{\'n} 10163*d5c9a868SElliott Hughes \gdefchar^^f2{\v n} 10164*d5c9a868SElliott Hughes \gdefchar^^f3{\'o} 10165*d5c9a868SElliott Hughes \gdefchar^^f4{\^o} 10166*d5c9a868SElliott Hughes \gdefchar^^f5{\H o} 10167*d5c9a868SElliott Hughes \gdefchar^^f6{\"o} 10168*d5c9a868SElliott Hughes \gdefchar^^f7{$\div$} 10169*d5c9a868SElliott Hughes \gdefchar^^f8{\v r} 10170*d5c9a868SElliott Hughes \gdefchar^^f9{\ringaccent u} 10171*d5c9a868SElliott Hughes \gdefchar^^fa{\'u} 10172*d5c9a868SElliott Hughes \gdefchar^^fb{\H u} 10173*d5c9a868SElliott Hughes \gdefchar^^fc{\"u} 10174*d5c9a868SElliott Hughes \gdefchar^^fd{\'y} 10175*d5c9a868SElliott Hughes \gdefchar^^fe{\cedilla t} 10176*d5c9a868SElliott Hughes \gdefchar^^ff{\dotaccent{}} 10177*d5c9a868SElliott Hughes} 10178*d5c9a868SElliott Hughes 10179*d5c9a868SElliott Hughes% UTF-8 character definitions. 10180*d5c9a868SElliott Hughes% 10181*d5c9a868SElliott Hughes% This code to support UTF-8 is based on LaTeX's utf8.def, with some 10182*d5c9a868SElliott Hughes% changes for Texinfo conventions. It is included here under the GPL by 10183*d5c9a868SElliott Hughes% permission from Frank Mittelbach and the LaTeX team. 10184*d5c9a868SElliott Hughes% 10185*d5c9a868SElliott Hughes\newcount\countUTFx 10186*d5c9a868SElliott Hughes\newcount\countUTFy 10187*d5c9a868SElliott Hughes\newcount\countUTFz 10188*d5c9a868SElliott Hughes 10189*d5c9a868SElliott Hughes\gdef\UTFviiiTwoOctets#1#2{\expandafter 10190*d5c9a868SElliott Hughes \UTFviiiDefined\csname u8:#1\string #2\endcsname} 10191*d5c9a868SElliott Hughes% 10192*d5c9a868SElliott Hughes\gdef\UTFviiiThreeOctets#1#2#3{\expandafter 10193*d5c9a868SElliott Hughes \UTFviiiDefined\csname u8:#1\string #2\string #3\endcsname} 10194*d5c9a868SElliott Hughes% 10195*d5c9a868SElliott Hughes\gdef\UTFviiiFourOctets#1#2#3#4{\expandafter 10196*d5c9a868SElliott Hughes \UTFviiiDefined\csname u8:#1\string #2\string #3\string #4\endcsname} 10197*d5c9a868SElliott Hughes 10198*d5c9a868SElliott Hughes\gdef\UTFviiiDefined#1{% 10199*d5c9a868SElliott Hughes \ifx #1\relax 10200*d5c9a868SElliott Hughes \message{\linenumber Unicode char \string #1 not defined for Texinfo}% 10201*d5c9a868SElliott Hughes \else 10202*d5c9a868SElliott Hughes \expandafter #1% 10203*d5c9a868SElliott Hughes \fi 10204*d5c9a868SElliott Hughes} 10205*d5c9a868SElliott Hughes 10206*d5c9a868SElliott Hughes% Give non-ASCII bytes the active definitions for processing UTF-8 sequences 10207*d5c9a868SElliott Hughes\begingroup 10208*d5c9a868SElliott Hughes \catcode`\~13 10209*d5c9a868SElliott Hughes \catcode`\$12 10210*d5c9a868SElliott Hughes \catcode`\"12 10211*d5c9a868SElliott Hughes 10212*d5c9a868SElliott Hughes % Loop from \countUTFx to \countUTFy, performing \UTFviiiTmp 10213*d5c9a868SElliott Hughes % substituting ~ and $ with a character token of that value. 10214*d5c9a868SElliott Hughes \def\UTFviiiLoop{% 10215*d5c9a868SElliott Hughes \global\catcode\countUTFx\active 10216*d5c9a868SElliott Hughes \uccode`\~\countUTFx 10217*d5c9a868SElliott Hughes \uccode`\$\countUTFx 10218*d5c9a868SElliott Hughes \uppercase\expandafter{\UTFviiiTmp}% 10219*d5c9a868SElliott Hughes \advance\countUTFx by 1 10220*d5c9a868SElliott Hughes \ifnum\countUTFx < \countUTFy 10221*d5c9a868SElliott Hughes \expandafter\UTFviiiLoop 10222*d5c9a868SElliott Hughes \fi} 10223*d5c9a868SElliott Hughes 10224*d5c9a868SElliott Hughes % For bytes other than the first in a UTF-8 sequence. Not expected to 10225*d5c9a868SElliott Hughes % be expanded except when writing to auxiliary files. 10226*d5c9a868SElliott Hughes \countUTFx = "80 10227*d5c9a868SElliott Hughes \countUTFy = "C2 10228*d5c9a868SElliott Hughes \def\UTFviiiTmp{% 10229*d5c9a868SElliott Hughes \gdef~{% 10230*d5c9a868SElliott Hughes \ifpassthroughchars $\fi}}% 10231*d5c9a868SElliott Hughes \UTFviiiLoop 10232*d5c9a868SElliott Hughes 10233*d5c9a868SElliott Hughes \countUTFx = "C2 10234*d5c9a868SElliott Hughes \countUTFy = "E0 10235*d5c9a868SElliott Hughes \def\UTFviiiTmp{% 10236*d5c9a868SElliott Hughes \gdef~{% 10237*d5c9a868SElliott Hughes \ifpassthroughchars $% 10238*d5c9a868SElliott Hughes \else\expandafter\UTFviiiTwoOctets\expandafter$\fi}}% 10239*d5c9a868SElliott Hughes \UTFviiiLoop 10240*d5c9a868SElliott Hughes 10241*d5c9a868SElliott Hughes \countUTFx = "E0 10242*d5c9a868SElliott Hughes \countUTFy = "F0 10243*d5c9a868SElliott Hughes \def\UTFviiiTmp{% 10244*d5c9a868SElliott Hughes \gdef~{% 10245*d5c9a868SElliott Hughes \ifpassthroughchars $% 10246*d5c9a868SElliott Hughes \else\expandafter\UTFviiiThreeOctets\expandafter$\fi}}% 10247*d5c9a868SElliott Hughes \UTFviiiLoop 10248*d5c9a868SElliott Hughes 10249*d5c9a868SElliott Hughes \countUTFx = "F0 10250*d5c9a868SElliott Hughes \countUTFy = "F4 10251*d5c9a868SElliott Hughes \def\UTFviiiTmp{% 10252*d5c9a868SElliott Hughes \gdef~{% 10253*d5c9a868SElliott Hughes \ifpassthroughchars $% 10254*d5c9a868SElliott Hughes \else\expandafter\UTFviiiFourOctets\expandafter$\fi 10255*d5c9a868SElliott Hughes }}% 10256*d5c9a868SElliott Hughes \UTFviiiLoop 10257*d5c9a868SElliott Hughes\endgroup 10258*d5c9a868SElliott Hughes 10259*d5c9a868SElliott Hughes\def\globallet{\global\let} % save some \expandafter's below 10260*d5c9a868SElliott Hughes 10261*d5c9a868SElliott Hughes% @U{xxxx} to produce U+xxxx, if we support it. 10262*d5c9a868SElliott Hughes\def\U#1{% 10263*d5c9a868SElliott Hughes \expandafter\ifx\csname uni:#1\endcsname \relax 10264*d5c9a868SElliott Hughes \iftxinativeunicodecapable 10265*d5c9a868SElliott Hughes % All Unicode characters can be used if native Unicode handling is 10266*d5c9a868SElliott Hughes % active. However, if the font does not have the glyph, 10267*d5c9a868SElliott Hughes % letters are missing. 10268*d5c9a868SElliott Hughes \begingroup 10269*d5c9a868SElliott Hughes \uccode`\.="#1\relax 10270*d5c9a868SElliott Hughes \uppercase{.} 10271*d5c9a868SElliott Hughes \endgroup 10272*d5c9a868SElliott Hughes \else 10273*d5c9a868SElliott Hughes \errhelp = \EMsimple 10274*d5c9a868SElliott Hughes \errmessage{Unicode character U+#1 not supported, sorry}% 10275*d5c9a868SElliott Hughes \fi 10276*d5c9a868SElliott Hughes \else 10277*d5c9a868SElliott Hughes \csname uni:#1\endcsname 10278*d5c9a868SElliott Hughes \fi 10279*d5c9a868SElliott Hughes} 10280*d5c9a868SElliott Hughes 10281*d5c9a868SElliott Hughes% These macros are used here to construct the name of a control 10282*d5c9a868SElliott Hughes% sequence to be defined. 10283*d5c9a868SElliott Hughes\def\UTFviiiTwoOctetsName#1#2{% 10284*d5c9a868SElliott Hughes \csname u8:#1\string #2\endcsname}% 10285*d5c9a868SElliott Hughes\def\UTFviiiThreeOctetsName#1#2#3{% 10286*d5c9a868SElliott Hughes \csname u8:#1\string #2\string #3\endcsname}% 10287*d5c9a868SElliott Hughes\def\UTFviiiFourOctetsName#1#2#3#4{% 10288*d5c9a868SElliott Hughes \csname u8:#1\string #2\string #3\string #4\endcsname}% 10289*d5c9a868SElliott Hughes 10290*d5c9a868SElliott Hughes% For UTF-8 byte sequences (TeX, e-TeX and pdfTeX), 10291*d5c9a868SElliott Hughes% provide a definition macro to replace a Unicode character; 10292*d5c9a868SElliott Hughes% this gets used by the @U command 10293*d5c9a868SElliott Hughes% 10294*d5c9a868SElliott Hughes\begingroup 10295*d5c9a868SElliott Hughes \catcode`\"=12 10296*d5c9a868SElliott Hughes \catcode`\<=12 10297*d5c9a868SElliott Hughes \catcode`\.=12 10298*d5c9a868SElliott Hughes \catcode`\,=12 10299*d5c9a868SElliott Hughes \catcode`\;=12 10300*d5c9a868SElliott Hughes \catcode`\!=12 10301*d5c9a868SElliott Hughes \catcode`\~=13 10302*d5c9a868SElliott Hughes \gdef\DeclareUnicodeCharacterUTFviii#1#2{% 10303*d5c9a868SElliott Hughes \countUTFz = "#1\relax 10304*d5c9a868SElliott Hughes \begingroup 10305*d5c9a868SElliott Hughes \parseXMLCharref 10306*d5c9a868SElliott Hughes 10307*d5c9a868SElliott Hughes % Give \u8:... its definition. The sequence of seven \expandafter's 10308*d5c9a868SElliott Hughes % expands after the \gdef three times, e.g. 10309*d5c9a868SElliott Hughes % 10310*d5c9a868SElliott Hughes % 1. \UTFviiTwoOctetsName B1 B2 10311*d5c9a868SElliott Hughes % 2. \csname u8:B1 \string B2 \endcsname 10312*d5c9a868SElliott Hughes % 3. \u8: B1 B2 (a single control sequence token) 10313*d5c9a868SElliott Hughes % 10314*d5c9a868SElliott Hughes \expandafter\expandafter 10315*d5c9a868SElliott Hughes \expandafter\expandafter 10316*d5c9a868SElliott Hughes \expandafter\expandafter 10317*d5c9a868SElliott Hughes \expandafter\gdef \UTFviiiTmp{#2}% 10318*d5c9a868SElliott Hughes % 10319*d5c9a868SElliott Hughes \expandafter\ifx\csname uni:#1\endcsname \relax \else 10320*d5c9a868SElliott Hughes \message{Internal error, already defined: #1}% 10321*d5c9a868SElliott Hughes \fi 10322*d5c9a868SElliott Hughes % 10323*d5c9a868SElliott Hughes % define an additional control sequence for this code point. 10324*d5c9a868SElliott Hughes \expandafter\globallet\csname uni:#1\endcsname \UTFviiiTmp 10325*d5c9a868SElliott Hughes \endgroup} 10326*d5c9a868SElliott Hughes % 10327*d5c9a868SElliott Hughes % Given the value in \countUTFz as a Unicode code point, set \UTFviiiTmp 10328*d5c9a868SElliott Hughes % to the corresponding UTF-8 sequence. 10329*d5c9a868SElliott Hughes \gdef\parseXMLCharref{% 10330*d5c9a868SElliott Hughes \ifnum\countUTFz < "A0\relax 10331*d5c9a868SElliott Hughes \errhelp = \EMsimple 10332*d5c9a868SElliott Hughes \errmessage{Cannot define Unicode char value < 00A0}% 10333*d5c9a868SElliott Hughes \else\ifnum\countUTFz < "800\relax 10334*d5c9a868SElliott Hughes \parseUTFviiiA,% 10335*d5c9a868SElliott Hughes \parseUTFviiiB C\UTFviiiTwoOctetsName.,% 10336*d5c9a868SElliott Hughes \else\ifnum\countUTFz < "10000\relax 10337*d5c9a868SElliott Hughes \parseUTFviiiA;% 10338*d5c9a868SElliott Hughes \parseUTFviiiA,% 10339*d5c9a868SElliott Hughes \parseUTFviiiB E\UTFviiiThreeOctetsName.{,;}% 10340*d5c9a868SElliott Hughes \else 10341*d5c9a868SElliott Hughes \parseUTFviiiA;% 10342*d5c9a868SElliott Hughes \parseUTFviiiA,% 10343*d5c9a868SElliott Hughes \parseUTFviiiA!% 10344*d5c9a868SElliott Hughes \parseUTFviiiB F\UTFviiiFourOctetsName.{!,;}% 10345*d5c9a868SElliott Hughes \fi\fi\fi 10346*d5c9a868SElliott Hughes } 10347*d5c9a868SElliott Hughes 10348*d5c9a868SElliott Hughes % Extract a byte from the end of the UTF-8 representation of \countUTFx. 10349*d5c9a868SElliott Hughes % It must be a non-initial byte in the sequence. 10350*d5c9a868SElliott Hughes % Change \uccode of #1 for it to be used in \parseUTFviiiB as one 10351*d5c9a868SElliott Hughes % of the bytes. 10352*d5c9a868SElliott Hughes \gdef\parseUTFviiiA#1{% 10353*d5c9a868SElliott Hughes \countUTFx = \countUTFz 10354*d5c9a868SElliott Hughes \divide\countUTFz by 64 10355*d5c9a868SElliott Hughes \countUTFy = \countUTFz % Save to be the future value of \countUTFz. 10356*d5c9a868SElliott Hughes \multiply\countUTFz by 64 10357*d5c9a868SElliott Hughes 10358*d5c9a868SElliott Hughes % \countUTFz is now \countUTFx with the last 5 bits cleared. Subtract 10359*d5c9a868SElliott Hughes % in order to get the last five bits. 10360*d5c9a868SElliott Hughes \advance\countUTFx by -\countUTFz 10361*d5c9a868SElliott Hughes 10362*d5c9a868SElliott Hughes % Convert this to the byte in the UTF-8 sequence. 10363*d5c9a868SElliott Hughes \advance\countUTFx by 128 10364*d5c9a868SElliott Hughes \uccode `#1\countUTFx 10365*d5c9a868SElliott Hughes \countUTFz = \countUTFy} 10366*d5c9a868SElliott Hughes 10367*d5c9a868SElliott Hughes % Used to put a UTF-8 byte sequence into \UTFviiiTmp 10368*d5c9a868SElliott Hughes % #1 is the increment for \countUTFz to yield a the first byte of the UTF-8 10369*d5c9a868SElliott Hughes % sequence. 10370*d5c9a868SElliott Hughes % #2 is one of the \UTFviii*OctetsName macros. 10371*d5c9a868SElliott Hughes % #3 is always a full stop (.) 10372*d5c9a868SElliott Hughes % #4 is a template for the other bytes in the sequence. The values for these 10373*d5c9a868SElliott Hughes % bytes is substituted in here with \uppercase using the \uccode's. 10374*d5c9a868SElliott Hughes \gdef\parseUTFviiiB#1#2#3#4{% 10375*d5c9a868SElliott Hughes \advance\countUTFz by "#10\relax 10376*d5c9a868SElliott Hughes \uccode `#3\countUTFz 10377*d5c9a868SElliott Hughes \uppercase{\gdef\UTFviiiTmp{#2#3#4}}} 10378*d5c9a868SElliott Hughes\endgroup 10379*d5c9a868SElliott Hughes 10380*d5c9a868SElliott Hughes% For native Unicode handling (XeTeX and LuaTeX), 10381*d5c9a868SElliott Hughes% provide a definition macro that sets a catcode to `other' non-globally 10382*d5c9a868SElliott Hughes% 10383*d5c9a868SElliott Hughes\def\DeclareUnicodeCharacterNativeOther#1#2{% 10384*d5c9a868SElliott Hughes \catcode"#1=\other 10385*d5c9a868SElliott Hughes} 10386*d5c9a868SElliott Hughes 10387*d5c9a868SElliott Hughes% https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_M 10388*d5c9a868SElliott Hughes% U+0000..U+007F = https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block) 10389*d5c9a868SElliott Hughes% U+0080..U+00FF = https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block) 10390*d5c9a868SElliott Hughes% U+0100..U+017F = https://en.wikipedia.org/wiki/Latin_Extended-A 10391*d5c9a868SElliott Hughes% U+0180..U+024F = https://en.wikipedia.org/wiki/Latin_Extended-B 10392*d5c9a868SElliott Hughes% 10393*d5c9a868SElliott Hughes% Many of our renditions are less than wonderful, and all the missing 10394*d5c9a868SElliott Hughes% characters are available somewhere. Loading the necessary fonts 10395*d5c9a868SElliott Hughes% awaits user request. We can't truly support Unicode without 10396*d5c9a868SElliott Hughes% reimplementing everything that's been done in LaTeX for many years, 10397*d5c9a868SElliott Hughes% plus probably using luatex or xetex, and who knows what else. 10398*d5c9a868SElliott Hughes% We won't be doing that here in this simple file. But we can try to at 10399*d5c9a868SElliott Hughes% least make most of the characters not bomb out. 10400*d5c9a868SElliott Hughes% 10401*d5c9a868SElliott Hughes\def\unicodechardefs{% 10402*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00A0}{\tie}% 10403*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00A1}{\exclamdown}% 10404*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00A2}{{\tcfont \char162}}% 0242=cent 10405*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00A3}{\pounds{}}% 10406*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00A4}{{\tcfont \char164}}% 0244=currency 10407*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00A5}{{\tcfont \char165}}% 0245=yen 10408*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00A6}{{\tcfont \char166}}% 0246=brokenbar 10409*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00A7}{\S}% 10410*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00A8}{\"{ }}% 10411*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00A9}{\copyright{}}% 10412*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00AA}{\ordf}% 10413*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00AB}{\guillemetleft{}}% 10414*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00AC}{\ensuremath\lnot}% 10415*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00AD}{\-}% 10416*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00AE}{\registeredsymbol{}}% 10417*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00AF}{\={ }}% 10418*d5c9a868SElliott Hughes % 10419*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00B0}{\ringaccent{ }}% 10420*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00B1}{\ensuremath\pm}% 10421*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00B2}{$^2$}% 10422*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00B3}{$^3$}% 10423*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00B4}{\'{ }}% 10424*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00B5}{$\mu$}% 10425*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00B6}{\P}% 10426*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00B7}{\ensuremath\cdot}% 10427*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00B8}{\cedilla{ }}% 10428*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00B9}{$^1$}% 10429*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00BA}{\ordm}% 10430*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00BB}{\guillemetright{}}% 10431*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00BC}{$1\over4$}% 10432*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00BD}{$1\over2$}% 10433*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00BE}{$3\over4$}% 10434*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00BF}{\questiondown}% 10435*d5c9a868SElliott Hughes % 10436*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00C0}{\`A}% 10437*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00C1}{\'A}% 10438*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00C2}{\^A}% 10439*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00C3}{\~A}% 10440*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00C4}{\"A}% 10441*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00C5}{\AA}% 10442*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00C6}{\AE}% 10443*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00C7}{\cedilla{C}}% 10444*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00C8}{\`E}% 10445*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00C9}{\'E}% 10446*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00CA}{\^E}% 10447*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00CB}{\"E}% 10448*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00CC}{\`I}% 10449*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00CD}{\'I}% 10450*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00CE}{\^I}% 10451*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00CF}{\"I}% 10452*d5c9a868SElliott Hughes % 10453*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00D0}{\DH}% 10454*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00D1}{\~N}% 10455*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00D2}{\`O}% 10456*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00D3}{\'O}% 10457*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00D4}{\^O}% 10458*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00D5}{\~O}% 10459*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00D6}{\"O}% 10460*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00D7}{\ensuremath\times}% 10461*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00D8}{\O}% 10462*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00D9}{\`U}% 10463*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00DA}{\'U}% 10464*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00DB}{\^U}% 10465*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00DC}{\"U}% 10466*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00DD}{\'Y}% 10467*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00DE}{\TH}% 10468*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00DF}{\ss}% 10469*d5c9a868SElliott Hughes % 10470*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00E0}{\`a}% 10471*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00E1}{\'a}% 10472*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00E2}{\^a}% 10473*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00E3}{\~a}% 10474*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00E4}{\"a}% 10475*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00E5}{\aa}% 10476*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00E6}{\ae}% 10477*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00E7}{\cedilla{c}}% 10478*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00E8}{\`e}% 10479*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00E9}{\'e}% 10480*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00EA}{\^e}% 10481*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00EB}{\"e}% 10482*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}}% 10483*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}}% 10484*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}}% 10485*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}}% 10486*d5c9a868SElliott Hughes % 10487*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00F0}{\dh}% 10488*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00F1}{\~n}% 10489*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00F2}{\`o}% 10490*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00F3}{\'o}% 10491*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00F4}{\^o}% 10492*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00F5}{\~o}% 10493*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00F6}{\"o}% 10494*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00F7}{\ensuremath\div}% 10495*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00F8}{\o}% 10496*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00F9}{\`u}% 10497*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00FA}{\'u}% 10498*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00FB}{\^u}% 10499*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00FC}{\"u}% 10500*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00FD}{\'y}% 10501*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00FE}{\th}% 10502*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{00FF}{\"y}% 10503*d5c9a868SElliott Hughes % 10504*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0100}{\=A}% 10505*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0101}{\=a}% 10506*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0102}{\u{A}}% 10507*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0103}{\u{a}}% 10508*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0104}{\ogonek{A}}% 10509*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0105}{\ogonek{a}}% 10510*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0106}{\'C}% 10511*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0107}{\'c}% 10512*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0108}{\^C}% 10513*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0109}{\^c}% 10514*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{010A}{\dotaccent{C}}% 10515*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{010B}{\dotaccent{c}}% 10516*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{010C}{\v{C}}% 10517*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{010D}{\v{c}}% 10518*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{010E}{\v{D}}% 10519*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{010F}{d'}% 10520*d5c9a868SElliott Hughes % 10521*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0110}{\DH}% 10522*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0111}{\dh}% 10523*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0112}{\=E}% 10524*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0113}{\=e}% 10525*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0114}{\u{E}}% 10526*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0115}{\u{e}}% 10527*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0116}{\dotaccent{E}}% 10528*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0117}{\dotaccent{e}}% 10529*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0118}{\ogonek{E}}% 10530*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0119}{\ogonek{e}}% 10531*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{011A}{\v{E}}% 10532*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{011B}{\v{e}}% 10533*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{011C}{\^G}% 10534*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{011D}{\^g}% 10535*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{011E}{\u{G}}% 10536*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{011F}{\u{g}}% 10537*d5c9a868SElliott Hughes % 10538*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0120}{\dotaccent{G}}% 10539*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0121}{\dotaccent{g}}% 10540*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0122}{\cedilla{G}}% 10541*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0123}{\cedilla{g}}% 10542*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0124}{\^H}% 10543*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0125}{\^h}% 10544*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0126}{\missingcharmsg{H WITH STROKE}}% 10545*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0127}{\missingcharmsg{h WITH STROKE}}% 10546*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0128}{\~I}% 10547*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}}% 10548*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{012A}{\=I}% 10549*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{012B}{\={\dotless{i}}}% 10550*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{012C}{\u{I}}% 10551*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}}% 10552*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{012E}{\ogonek{I}}% 10553*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{012F}{\ogonek{i}}% 10554*d5c9a868SElliott Hughes % 10555*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0130}{\dotaccent{I}}% 10556*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0131}{\dotless{i}}% 10557*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0132}{IJ}% 10558*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0133}{ij}% 10559*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0134}{\^J}% 10560*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}}% 10561*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0136}{\cedilla{K}}% 10562*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0137}{\cedilla{k}}% 10563*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0138}{\ensuremath\kappa}% 10564*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0139}{\'L}% 10565*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{013A}{\'l}% 10566*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{013B}{\cedilla{L}}% 10567*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{013C}{\cedilla{l}}% 10568*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{013D}{L'}% should kern 10569*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{013E}{l'}% should kern 10570*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{013F}{L\U{00B7}}% 10571*d5c9a868SElliott Hughes % 10572*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0140}{l\U{00B7}}% 10573*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0141}{\L}% 10574*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0142}{\l}% 10575*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0143}{\'N}% 10576*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0144}{\'n}% 10577*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0145}{\cedilla{N}}% 10578*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0146}{\cedilla{n}}% 10579*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0147}{\v{N}}% 10580*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0148}{\v{n}}% 10581*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0149}{'n}% 10582*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{014A}{\missingcharmsg{ENG}}% 10583*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{014B}{\missingcharmsg{eng}}% 10584*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{014C}{\=O}% 10585*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{014D}{\=o}% 10586*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{014E}{\u{O}}% 10587*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{014F}{\u{o}}% 10588*d5c9a868SElliott Hughes % 10589*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0150}{\H{O}}% 10590*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0151}{\H{o}}% 10591*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0152}{\OE}% 10592*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0153}{\oe}% 10593*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0154}{\'R}% 10594*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0155}{\'r}% 10595*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0156}{\cedilla{R}}% 10596*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0157}{\cedilla{r}}% 10597*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0158}{\v{R}}% 10598*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0159}{\v{r}}% 10599*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{015A}{\'S}% 10600*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{015B}{\'s}% 10601*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{015C}{\^S}% 10602*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{015D}{\^s}% 10603*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{015E}{\cedilla{S}}% 10604*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{015F}{\cedilla{s}}% 10605*d5c9a868SElliott Hughes % 10606*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0160}{\v{S}}% 10607*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0161}{\v{s}}% 10608*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0162}{\cedilla{T}}% 10609*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0163}{\cedilla{t}}% 10610*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0164}{\v{T}}% 10611*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0165}{\v{t}}% 10612*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0166}{\missingcharmsg{H WITH STROKE}}% 10613*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0167}{\missingcharmsg{h WITH STROKE}}% 10614*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0168}{\~U}% 10615*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0169}{\~u}% 10616*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{016A}{\=U}% 10617*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{016B}{\=u}% 10618*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{016C}{\u{U}}% 10619*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{016D}{\u{u}}% 10620*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{016E}{\ringaccent{U}}% 10621*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{016F}{\ringaccent{u}}% 10622*d5c9a868SElliott Hughes % 10623*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0170}{\H{U}}% 10624*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0171}{\H{u}}% 10625*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0172}{\ogonek{U}}% 10626*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0173}{\ogonek{u}}% 10627*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0174}{\^W}% 10628*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0175}{\^w}% 10629*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0176}{\^Y}% 10630*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0177}{\^y}% 10631*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0178}{\"Y}% 10632*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0179}{\'Z}% 10633*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{017A}{\'z}% 10634*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{017B}{\dotaccent{Z}}% 10635*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{017C}{\dotaccent{z}}% 10636*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{017D}{\v{Z}}% 10637*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{017E}{\v{z}}% 10638*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{017F}{\missingcharmsg{LONG S}}% 10639*d5c9a868SElliott Hughes % 10640*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01C4}{D\v{Z}}% 10641*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01C5}{D\v{z}}% 10642*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01C6}{d\v{z}}% 10643*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01C7}{LJ}% 10644*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01C8}{Lj}% 10645*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01C9}{lj}% 10646*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01CA}{NJ}% 10647*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01CB}{Nj}% 10648*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01CC}{nj}% 10649*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01CD}{\v{A}}% 10650*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01CE}{\v{a}}% 10651*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01CF}{\v{I}}% 10652*d5c9a868SElliott Hughes % 10653*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}}% 10654*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01D1}{\v{O}}% 10655*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01D2}{\v{o}}% 10656*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01D3}{\v{U}}% 10657*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01D4}{\v{u}}% 10658*d5c9a868SElliott Hughes % 10659*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01E2}{\={\AE}}% 10660*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01E3}{\={\ae}}% 10661*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01E6}{\v{G}}% 10662*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01E7}{\v{g}}% 10663*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01E8}{\v{K}}% 10664*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01E9}{\v{k}}% 10665*d5c9a868SElliott Hughes % 10666*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}}% 10667*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01F1}{DZ}% 10668*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01F2}{Dz}% 10669*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01F3}{dz}% 10670*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01F4}{\'G}% 10671*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01F5}{\'g}% 10672*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01F8}{\`N}% 10673*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01F9}{\`n}% 10674*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01FC}{\'{\AE}}% 10675*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01FD}{\'{\ae}}% 10676*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01FE}{\'{\O}}% 10677*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{01FF}{\'{\o}}% 10678*d5c9a868SElliott Hughes % 10679*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{021E}{\v{H}}% 10680*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{021F}{\v{h}}% 10681*d5c9a868SElliott Hughes % 10682*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0226}{\dotaccent{A}}% 10683*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0227}{\dotaccent{a}}% 10684*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0228}{\cedilla{E}}% 10685*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0229}{\cedilla{e}}% 10686*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{022E}{\dotaccent{O}}% 10687*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{022F}{\dotaccent{o}}% 10688*d5c9a868SElliott Hughes % 10689*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0232}{\=Y}% 10690*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0233}{\=y}% 10691*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0237}{\dotless{j}}% 10692*d5c9a868SElliott Hughes % 10693*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{02BC}{'}% 10694*d5c9a868SElliott Hughes % 10695*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{02DB}{\ogonek{ }}% 10696*d5c9a868SElliott Hughes % 10697*d5c9a868SElliott Hughes % Greek letters upper case 10698*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0391}{{\it A}}% 10699*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0392}{{\it B}}% 10700*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0393}{\ensuremath{\mit\Gamma}}% 10701*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0394}{\ensuremath{\mit\Delta}}% 10702*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0395}{{\it E}}% 10703*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0396}{{\it Z}}% 10704*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0397}{{\it H}}% 10705*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0398}{\ensuremath{\mit\Theta}}% 10706*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0399}{{\it I}}% 10707*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{039A}{{\it K}}% 10708*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{039B}{\ensuremath{\mit\Lambda}}% 10709*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{039C}{{\it M}}% 10710*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{039D}{{\it N}}% 10711*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{039E}{\ensuremath{\mit\Xi}}% 10712*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{039F}{{\it O}}% 10713*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03A0}{\ensuremath{\mit\Pi}}% 10714*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03A1}{{\it P}}% 10715*d5c9a868SElliott Hughes %\DeclareUnicodeCharacter{03A2}{} % none - corresponds to final sigma 10716*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03A3}{\ensuremath{\mit\Sigma}}% 10717*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03A4}{{\it T}}% 10718*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03A5}{\ensuremath{\mit\Upsilon}}% 10719*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03A6}{\ensuremath{\mit\Phi}}% 10720*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03A7}{{\it X}}% 10721*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03A8}{\ensuremath{\mit\Psi}}% 10722*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03A9}{\ensuremath{\mit\Omega}}% 10723*d5c9a868SElliott Hughes % 10724*d5c9a868SElliott Hughes % Vowels with accents 10725*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0390}{\ensuremath{\ddot{\acute\iota}}}% 10726*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03AC}{\ensuremath{\acute\alpha}}% 10727*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03AD}{\ensuremath{\acute\epsilon}}% 10728*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03AE}{\ensuremath{\acute\eta}}% 10729*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03AF}{\ensuremath{\acute\iota}}% 10730*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03B0}{\ensuremath{\acute{\ddot\upsilon}}}% 10731*d5c9a868SElliott Hughes % 10732*d5c9a868SElliott Hughes % Standalone accent 10733*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{0384}{\ensuremath{\acute{\ }}}% 10734*d5c9a868SElliott Hughes % 10735*d5c9a868SElliott Hughes % Greek letters lower case 10736*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03B1}{\ensuremath\alpha}% 10737*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03B2}{\ensuremath\beta}% 10738*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03B3}{\ensuremath\gamma}% 10739*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03B4}{\ensuremath\delta}% 10740*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03B5}{\ensuremath\epsilon}% 10741*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03B6}{\ensuremath\zeta}% 10742*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03B7}{\ensuremath\eta}% 10743*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03B8}{\ensuremath\theta}% 10744*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03B9}{\ensuremath\iota}% 10745*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03BA}{\ensuremath\kappa}% 10746*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03BB}{\ensuremath\lambda}% 10747*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03BC}{\ensuremath\mu}% 10748*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03BD}{\ensuremath\nu}% 10749*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03BE}{\ensuremath\xi}% 10750*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03BF}{{\it o}}% omicron 10751*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03C0}{\ensuremath\pi}% 10752*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03C1}{\ensuremath\rho}% 10753*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03C2}{\ensuremath\varsigma}% 10754*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03C3}{\ensuremath\sigma}% 10755*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03C4}{\ensuremath\tau}% 10756*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03C5}{\ensuremath\upsilon}% 10757*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03C6}{\ensuremath\phi}% 10758*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03C7}{\ensuremath\chi}% 10759*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03C8}{\ensuremath\psi}% 10760*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03C9}{\ensuremath\omega}% 10761*d5c9a868SElliott Hughes % 10762*d5c9a868SElliott Hughes % More Greek vowels with accents 10763*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03CA}{\ensuremath{\ddot\iota}}% 10764*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03CB}{\ensuremath{\ddot\upsilon}}% 10765*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03CC}{\ensuremath{\acute o}}% 10766*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03CD}{\ensuremath{\acute\upsilon}}% 10767*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03CE}{\ensuremath{\acute\omega}}% 10768*d5c9a868SElliott Hughes % 10769*d5c9a868SElliott Hughes % Variant Greek letters 10770*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03D1}{\ensuremath\vartheta}% 10771*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03D6}{\ensuremath\varpi}% 10772*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{03F1}{\ensuremath\varrho}% 10773*d5c9a868SElliott Hughes % 10774*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E02}{\dotaccent{B}}% 10775*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E03}{\dotaccent{b}}% 10776*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E04}{\udotaccent{B}}% 10777*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E05}{\udotaccent{b}}% 10778*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}}% 10779*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}}% 10780*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}}% 10781*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}}% 10782*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}}% 10783*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}}% 10784*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}}% 10785*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}}% 10786*d5c9a868SElliott Hughes % 10787*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}}% 10788*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}}% 10789*d5c9a868SElliott Hughes % 10790*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E20}{\=G}% 10791*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E21}{\=g}% 10792*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E22}{\dotaccent{H}}% 10793*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E23}{\dotaccent{h}}% 10794*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E24}{\udotaccent{H}}% 10795*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E25}{\udotaccent{h}}% 10796*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E26}{\"H}% 10797*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E27}{\"h}% 10798*d5c9a868SElliott Hughes % 10799*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E30}{\'K}% 10800*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E31}{\'k}% 10801*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E32}{\udotaccent{K}}% 10802*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E33}{\udotaccent{k}}% 10803*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}}% 10804*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}}% 10805*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E36}{\udotaccent{L}}% 10806*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E37}{\udotaccent{l}}% 10807*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}}% 10808*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}}% 10809*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E3E}{\'M}% 10810*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E3F}{\'m}% 10811*d5c9a868SElliott Hughes % 10812*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E40}{\dotaccent{M}}% 10813*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E41}{\dotaccent{m}}% 10814*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E42}{\udotaccent{M}}% 10815*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E43}{\udotaccent{m}}% 10816*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E44}{\dotaccent{N}}% 10817*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E45}{\dotaccent{n}}% 10818*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E46}{\udotaccent{N}}% 10819*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E47}{\udotaccent{n}}% 10820*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}}% 10821*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}}% 10822*d5c9a868SElliott Hughes % 10823*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E54}{\'P}% 10824*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E55}{\'p}% 10825*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E56}{\dotaccent{P}}% 10826*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E57}{\dotaccent{p}}% 10827*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E58}{\dotaccent{R}}% 10828*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E59}{\dotaccent{r}}% 10829*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}}% 10830*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}}% 10831*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}}% 10832*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}}% 10833*d5c9a868SElliott Hughes % 10834*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E60}{\dotaccent{S}}% 10835*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E61}{\dotaccent{s}}% 10836*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E62}{\udotaccent{S}}% 10837*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E63}{\udotaccent{s}}% 10838*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}}% 10839*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}}% 10840*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}}% 10841*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}}% 10842*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}}% 10843*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}}% 10844*d5c9a868SElliott Hughes % 10845*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E7C}{\~V}% 10846*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E7D}{\~v}% 10847*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}}% 10848*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}}% 10849*d5c9a868SElliott Hughes % 10850*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E80}{\`W}% 10851*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E81}{\`w}% 10852*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E82}{\'W}% 10853*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E83}{\'w}% 10854*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E84}{\"W}% 10855*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E85}{\"w}% 10856*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E86}{\dotaccent{W}}% 10857*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E87}{\dotaccent{w}}% 10858*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E88}{\udotaccent{W}}% 10859*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E89}{\udotaccent{w}}% 10860*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}}% 10861*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}}% 10862*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E8C}{\"X}% 10863*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E8D}{\"x}% 10864*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}}% 10865*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}}% 10866*d5c9a868SElliott Hughes % 10867*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E90}{\^Z}% 10868*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E91}{\^z}% 10869*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}}% 10870*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E93}{\udotaccent{z}}% 10871*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}}% 10872*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}}% 10873*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}}% 10874*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E97}{\"t}% 10875*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E98}{\ringaccent{w}}% 10876*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1E99}{\ringaccent{y}}% 10877*d5c9a868SElliott Hughes % 10878*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}}% 10879*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}}% 10880*d5c9a868SElliott Hughes % 10881*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}}% 10882*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}}% 10883*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1EBC}{\~E}% 10884*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1EBD}{\~e}% 10885*d5c9a868SElliott Hughes % 10886*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}}% 10887*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}}% 10888*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}}% 10889*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}}% 10890*d5c9a868SElliott Hughes % 10891*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}}% 10892*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}}% 10893*d5c9a868SElliott Hughes % 10894*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1EF2}{\`Y}% 10895*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1EF3}{\`y}% 10896*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}}% 10897*d5c9a868SElliott Hughes % 10898*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1EF8}{\~Y}% 10899*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{1EF9}{\~y}% 10900*d5c9a868SElliott Hughes % 10901*d5c9a868SElliott Hughes % Punctuation 10902*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2013}{--}% 10903*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2014}{---}% 10904*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2018}{\quoteleft{}}% 10905*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2019}{\quoteright{}}% 10906*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{201A}{\quotesinglbase{}}% 10907*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{201C}{\quotedblleft{}}% 10908*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{201D}{\quotedblright{}}% 10909*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{201E}{\quotedblbase{}}% 10910*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2020}{\ensuremath\dagger}% 10911*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2021}{\ensuremath\ddagger}% 10912*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2022}{\bullet{}}% 10913*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{202F}{\thinspace}% 10914*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2026}{\dots{}}% 10915*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2039}{\guilsinglleft{}}% 10916*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{203A}{\guilsinglright{}}% 10917*d5c9a868SElliott Hughes % 10918*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{20AC}{\euro{}}% 10919*d5c9a868SElliott Hughes % 10920*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2192}{\expansion{}}% 10921*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{21D2}{\result{}}% 10922*d5c9a868SElliott Hughes % 10923*d5c9a868SElliott Hughes % Mathematical symbols 10924*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2200}{\ensuremath\forall}% 10925*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2203}{\ensuremath\exists}% 10926*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2208}{\ensuremath\in}% 10927*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2212}{\minus{}}% 10928*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2217}{\ast}% 10929*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{221E}{\ensuremath\infty}% 10930*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2225}{\ensuremath\parallel}% 10931*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2227}{\ensuremath\wedge}% 10932*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2229}{\ensuremath\cap}% 10933*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2261}{\equiv{}}% 10934*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2264}{\ensuremath\leq}% 10935*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2265}{\ensuremath\geq}% 10936*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2282}{\ensuremath\subset}% 10937*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2287}{\ensuremath\supseteq}% 10938*d5c9a868SElliott Hughes % 10939*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2016}{\ensuremath\Vert}% 10940*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2032}{\ensuremath\prime}% 10941*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{210F}{\ensuremath\hbar}% 10942*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2111}{\ensuremath\Im}% 10943*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2113}{\ensuremath\ell}% 10944*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2118}{\ensuremath\wp}% 10945*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{211C}{\ensuremath\Re}% 10946*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2135}{\ensuremath\aleph}% 10947*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2190}{\ensuremath\leftarrow}% 10948*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2191}{\ensuremath\uparrow}% 10949*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2193}{\ensuremath\downarrow}% 10950*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2194}{\ensuremath\leftrightarrow}% 10951*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2195}{\ensuremath\updownarrow}% 10952*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2196}{\ensuremath\nwarrow}% 10953*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2197}{\ensuremath\nearrow}% 10954*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2198}{\ensuremath\searrow}% 10955*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2199}{\ensuremath\swarrow}% 10956*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{21A6}{\ensuremath\mapsto}% 10957*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{21A9}{\ensuremath\hookleftarrow}% 10958*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{21AA}{\ensuremath\hookrightarrow}% 10959*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{21BC}{\ensuremath\leftharpoonup}% 10960*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{21BD}{\ensuremath\leftharpoondown}% 10961*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{21C0}{\ensuremath\rightharpoonup}% 10962*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{21C1}{\ensuremath\rightharpoondown}% 10963*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{21CC}{\ensuremath\rightleftharpoons}% 10964*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{21D0}{\ensuremath\Leftarrow}% 10965*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{21D1}{\ensuremath\Uparrow}% 10966*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{21D3}{\ensuremath\Downarrow}% 10967*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{21D4}{\ensuremath\Leftrightarrow}% 10968*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{21D5}{\ensuremath\Updownarrow}% 10969*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2202}{\ensuremath\partial}% 10970*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2205}{\ensuremath\emptyset}% 10971*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2207}{\ensuremath\nabla}% 10972*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2209}{\ensuremath\notin}% 10973*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{220B}{\ensuremath\owns}% 10974*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{220F}{\ensuremath\prod}% 10975*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2210}{\ensuremath\coprod}% 10976*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2211}{\ensuremath\sum}% 10977*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2213}{\ensuremath\mp}% 10978*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2218}{\ensuremath\circ}% 10979*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{221A}{\ensuremath\surd}% 10980*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{221D}{\ensuremath\propto}% 10981*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2220}{\ensuremath\angle}% 10982*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2223}{\ensuremath\mid}% 10983*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2228}{\ensuremath\vee}% 10984*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{222A}{\ensuremath\cup}% 10985*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{222B}{\ensuremath\smallint}% 10986*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{222E}{\ensuremath\oint}% 10987*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{223C}{\ensuremath\sim}% 10988*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2240}{\ensuremath\wr}% 10989*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2243}{\ensuremath\simeq}% 10990*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2245}{\ensuremath\cong}% 10991*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2248}{\ensuremath\approx}% 10992*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{224D}{\ensuremath\asymp}% 10993*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2250}{\ensuremath\doteq}% 10994*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2260}{\ensuremath\neq}% 10995*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{226A}{\ensuremath\ll}% 10996*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{226B}{\ensuremath\gg}% 10997*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{227A}{\ensuremath\prec}% 10998*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{227B}{\ensuremath\succ}% 10999*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2283}{\ensuremath\supset}% 11000*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2286}{\ensuremath\subseteq}% 11001*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{228E}{\ensuremath\uplus}% 11002*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2291}{\ensuremath\sqsubseteq}% 11003*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2292}{\ensuremath\sqsupseteq}% 11004*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2293}{\ensuremath\sqcap}% 11005*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2294}{\ensuremath\sqcup}% 11006*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2295}{\ensuremath\oplus}% 11007*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2296}{\ensuremath\ominus}% 11008*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2297}{\ensuremath\otimes}% 11009*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2298}{\ensuremath\oslash}% 11010*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2299}{\ensuremath\odot}% 11011*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{22A2}{\ensuremath\vdash}% 11012*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{22A3}{\ensuremath\dashv}% 11013*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{22A4}{\ensuremath\ptextop}% 11014*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{22A5}{\ensuremath\bot}% 11015*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{22A8}{\ensuremath\models}% 11016*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{22C0}{\ensuremath\bigwedge}% 11017*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{22C1}{\ensuremath\bigvee}% 11018*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{22C2}{\ensuremath\bigcap}% 11019*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{22C3}{\ensuremath\bigcup}% 11020*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{22C4}{\ensuremath\diamond}% 11021*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{22C5}{\ensuremath\cdot}% 11022*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{22C6}{\ensuremath\star}% 11023*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{22C8}{\ensuremath\bowtie}% 11024*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2308}{\ensuremath\lceil}% 11025*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2309}{\ensuremath\rceil}% 11026*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{230A}{\ensuremath\lfloor}% 11027*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{230B}{\ensuremath\rfloor}% 11028*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2322}{\ensuremath\frown}% 11029*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2323}{\ensuremath\smile}% 11030*d5c9a868SElliott Hughes % 11031*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{25B3}{\ensuremath\triangle}% 11032*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{25B7}{\ensuremath\triangleright}% 11033*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{25BD}{\ensuremath\bigtriangledown}% 11034*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{25C1}{\ensuremath\triangleleft}% 11035*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{25C7}{\ensuremath\diamond}% 11036*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2660}{\ensuremath\spadesuit}% 11037*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2661}{\ensuremath\heartsuit}% 11038*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2662}{\ensuremath\diamondsuit}% 11039*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2663}{\ensuremath\clubsuit}% 11040*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{266D}{\ensuremath\flat}% 11041*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{266E}{\ensuremath\natural}% 11042*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{266F}{\ensuremath\sharp}% 11043*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{26AA}{\ensuremath\bigcirc}% 11044*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{27B9}{\ensuremath\rangle}% 11045*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{27C2}{\ensuremath\perp}% 11046*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{27E8}{\ensuremath\langle}% 11047*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{27F5}{\ensuremath\longleftarrow}% 11048*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{27F6}{\ensuremath\longrightarrow}% 11049*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{27F7}{\ensuremath\longleftrightarrow}% 11050*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{27FC}{\ensuremath\longmapsto}% 11051*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{29F5}{\ensuremath\setminus}% 11052*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2A00}{\ensuremath\bigodot}% 11053*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2A01}{\ensuremath\bigoplus}% 11054*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2A02}{\ensuremath\bigotimes}% 11055*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2A04}{\ensuremath\biguplus}% 11056*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2A06}{\ensuremath\bigsqcup}% 11057*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2A3F}{\ensuremath\amalg}% 11058*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2AAF}{\ensuremath\preceq}% 11059*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2AB0}{\ensuremath\succeq}% 11060*d5c9a868SElliott Hughes % 11061*d5c9a868SElliott Hughes \global\mathchardef\checkmark="1370% actually the square root sign 11062*d5c9a868SElliott Hughes \DeclareUnicodeCharacter{2713}{\ensuremath\checkmark}% 11063*d5c9a868SElliott Hughes}% end of \unicodechardefs 11064*d5c9a868SElliott Hughes 11065*d5c9a868SElliott Hughes% UTF-8 byte sequence (pdfTeX) definitions (replacing and @U command) 11066*d5c9a868SElliott Hughes% It makes the setting that replace UTF-8 byte sequence. 11067*d5c9a868SElliott Hughes\def\utfeightchardefs{% 11068*d5c9a868SElliott Hughes \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterUTFviii 11069*d5c9a868SElliott Hughes \unicodechardefs 11070*d5c9a868SElliott Hughes} 11071*d5c9a868SElliott Hughes 11072*d5c9a868SElliott Hughes% Whether the active definitions of non-ASCII characters expand to 11073*d5c9a868SElliott Hughes% non-active tokens with the same character code. This is used to 11074*d5c9a868SElliott Hughes% write characters literally, instead of using active definitions for 11075*d5c9a868SElliott Hughes% printing the correct glyphs. 11076*d5c9a868SElliott Hughes\newif\ifpassthroughchars 11077*d5c9a868SElliott Hughes\passthroughcharsfalse 11078*d5c9a868SElliott Hughes 11079*d5c9a868SElliott Hughes% For native Unicode handling (XeTeX and LuaTeX), 11080*d5c9a868SElliott Hughes% provide a definition macro to replace/pass-through a Unicode character 11081*d5c9a868SElliott Hughes% 11082*d5c9a868SElliott Hughes\def\DeclareUnicodeCharacterNative#1#2{% 11083*d5c9a868SElliott Hughes \catcode"#1=\active 11084*d5c9a868SElliott Hughes \def\dodeclareunicodecharacternative##1##2##3{% 11085*d5c9a868SElliott Hughes \begingroup 11086*d5c9a868SElliott Hughes \uccode`\~="##2\relax 11087*d5c9a868SElliott Hughes \uppercase{\gdef~}{% 11088*d5c9a868SElliott Hughes \ifpassthroughchars 11089*d5c9a868SElliott Hughes ##1% 11090*d5c9a868SElliott Hughes \else 11091*d5c9a868SElliott Hughes ##3% 11092*d5c9a868SElliott Hughes \fi 11093*d5c9a868SElliott Hughes } 11094*d5c9a868SElliott Hughes \endgroup 11095*d5c9a868SElliott Hughes } 11096*d5c9a868SElliott Hughes \begingroup 11097*d5c9a868SElliott Hughes \uccode`\.="#1\relax 11098*d5c9a868SElliott Hughes \uppercase{\def\UTFNativeTmp{.}}% 11099*d5c9a868SElliott Hughes \expandafter\dodeclareunicodecharacternative\UTFNativeTmp{#1}{#2}% 11100*d5c9a868SElliott Hughes \endgroup 11101*d5c9a868SElliott Hughes} 11102*d5c9a868SElliott Hughes 11103*d5c9a868SElliott Hughes% Native Unicode handling (XeTeX and LuaTeX) character replacing definition. 11104*d5c9a868SElliott Hughes% It activates the setting that replaces Unicode characters. 11105*d5c9a868SElliott Hughes\def\nativeunicodechardefs{% 11106*d5c9a868SElliott Hughes \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNative 11107*d5c9a868SElliott Hughes \unicodechardefs 11108*d5c9a868SElliott Hughes} 11109*d5c9a868SElliott Hughes 11110*d5c9a868SElliott Hughes% For native Unicode handling (XeTeX and LuaTeX), 11111*d5c9a868SElliott Hughes% make the character token expand 11112*d5c9a868SElliott Hughes% to the sequences given in \unicodechardefs for printing. 11113*d5c9a868SElliott Hughes\def\DeclareUnicodeCharacterNativeAtU#1#2{% 11114*d5c9a868SElliott Hughes \def\UTFAtUTmp{#2} 11115*d5c9a868SElliott Hughes \expandafter\globallet\csname uni:#1\endcsname \UTFAtUTmp 11116*d5c9a868SElliott Hughes} 11117*d5c9a868SElliott Hughes 11118*d5c9a868SElliott Hughes% @U command definitions for native Unicode handling (XeTeX and LuaTeX). 11119*d5c9a868SElliott Hughes\def\nativeunicodechardefsatu{% 11120*d5c9a868SElliott Hughes \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNativeAtU 11121*d5c9a868SElliott Hughes \unicodechardefs 11122*d5c9a868SElliott Hughes} 11123*d5c9a868SElliott Hughes 11124*d5c9a868SElliott Hughes% US-ASCII character definitions. 11125*d5c9a868SElliott Hughes\def\asciichardefs{% nothing need be done 11126*d5c9a868SElliott Hughes \relax 11127*d5c9a868SElliott Hughes} 11128*d5c9a868SElliott Hughes 11129*d5c9a868SElliott Hughes% Define all Unicode characters we know about. This makes UTF-8 the default 11130*d5c9a868SElliott Hughes% input encoding and allows @U to work. 11131*d5c9a868SElliott Hughes\iftxinativeunicodecapable 11132*d5c9a868SElliott Hughes \nativeunicodechardefsatu 11133*d5c9a868SElliott Hughes\else 11134*d5c9a868SElliott Hughes \utfeightchardefs 11135*d5c9a868SElliott Hughes\fi 11136*d5c9a868SElliott Hughes 11137*d5c9a868SElliott Hughes\message{formatting,} 11138*d5c9a868SElliott Hughes 11139*d5c9a868SElliott Hughes\newdimen\defaultparindent \defaultparindent = 15pt 11140*d5c9a868SElliott Hughes 11141*d5c9a868SElliott Hughes\chapheadingskip = 15pt plus 4pt minus 2pt 11142*d5c9a868SElliott Hughes\secheadingskip = 12pt plus 3pt minus 2pt 11143*d5c9a868SElliott Hughes\subsecheadingskip = 9pt plus 2pt minus 2pt 11144*d5c9a868SElliott Hughes 11145*d5c9a868SElliott Hughes% Prevent underfull vbox error messages. 11146*d5c9a868SElliott Hughes\vbadness = 10000 11147*d5c9a868SElliott Hughes 11148*d5c9a868SElliott Hughes% Don't be very finicky about underfull hboxes, either. 11149*d5c9a868SElliott Hughes\hbadness = 6666 11150*d5c9a868SElliott Hughes 11151*d5c9a868SElliott Hughes% Following George Bush, get rid of widows and orphans. 11152*d5c9a868SElliott Hughes\widowpenalty=10000 11153*d5c9a868SElliott Hughes\clubpenalty=10000 11154*d5c9a868SElliott Hughes 11155*d5c9a868SElliott Hughes% Use TeX 3.0's \emergencystretch to help line breaking, but if we're 11156*d5c9a868SElliott Hughes% using an old version of TeX, don't do anything. We want the amount of 11157*d5c9a868SElliott Hughes% stretch added to depend on the line length, hence the dependence on 11158*d5c9a868SElliott Hughes% \hsize. We call this whenever the paper size is set. 11159*d5c9a868SElliott Hughes% 11160*d5c9a868SElliott Hughes\def\setemergencystretch{% 11161*d5c9a868SElliott Hughes \ifx\emergencystretch\thisisundefined 11162*d5c9a868SElliott Hughes % Allow us to assign to \emergencystretch anyway. 11163*d5c9a868SElliott Hughes \def\emergencystretch{\dimen0}% 11164*d5c9a868SElliott Hughes \else 11165*d5c9a868SElliott Hughes \emergencystretch = .15\hsize 11166*d5c9a868SElliott Hughes \fi 11167*d5c9a868SElliott Hughes} 11168*d5c9a868SElliott Hughes 11169*d5c9a868SElliott Hughes% Parameters in order: 1) textheight; 2) textwidth; 11170*d5c9a868SElliott Hughes% 3) voffset; 4) hoffset; 5) binding offset; 6) topskip; 11171*d5c9a868SElliott Hughes% 7) physical page height; 8) physical page width. 11172*d5c9a868SElliott Hughes% 11173*d5c9a868SElliott Hughes% We also call \setleading{\textleading}, so the caller should define 11174*d5c9a868SElliott Hughes% \textleading. The caller should also set \parskip. 11175*d5c9a868SElliott Hughes% 11176*d5c9a868SElliott Hughes\def\internalpagesizes#1#2#3#4#5#6#7#8{% 11177*d5c9a868SElliott Hughes \voffset = #3\relax 11178*d5c9a868SElliott Hughes \topskip = #6\relax 11179*d5c9a868SElliott Hughes \splittopskip = \topskip 11180*d5c9a868SElliott Hughes % 11181*d5c9a868SElliott Hughes \vsize = #1\relax 11182*d5c9a868SElliott Hughes \advance\vsize by \topskip 11183*d5c9a868SElliott Hughes \outervsize = \vsize 11184*d5c9a868SElliott Hughes \advance\outervsize by 2\topandbottommargin 11185*d5c9a868SElliott Hughes \txipageheight = \vsize 11186*d5c9a868SElliott Hughes % 11187*d5c9a868SElliott Hughes \hsize = #2\relax 11188*d5c9a868SElliott Hughes \outerhsize = \hsize 11189*d5c9a868SElliott Hughes \advance\outerhsize by 0.5in 11190*d5c9a868SElliott Hughes \txipagewidth = \hsize 11191*d5c9a868SElliott Hughes % 11192*d5c9a868SElliott Hughes \normaloffset = #4\relax 11193*d5c9a868SElliott Hughes \bindingoffset = #5\relax 11194*d5c9a868SElliott Hughes % 11195*d5c9a868SElliott Hughes \ifpdf 11196*d5c9a868SElliott Hughes \pdfpageheight #7\relax 11197*d5c9a868SElliott Hughes \pdfpagewidth #8\relax 11198*d5c9a868SElliott Hughes % if we don't reset these, they will remain at "1 true in" of 11199*d5c9a868SElliott Hughes % whatever layout pdftex was dumped with. 11200*d5c9a868SElliott Hughes \pdfhorigin = 1 true in 11201*d5c9a868SElliott Hughes \pdfvorigin = 1 true in 11202*d5c9a868SElliott Hughes \else 11203*d5c9a868SElliott Hughes \ifx\XeTeXrevision\thisisundefined 11204*d5c9a868SElliott Hughes \special{papersize=#8,#7}% 11205*d5c9a868SElliott Hughes \else 11206*d5c9a868SElliott Hughes \pdfpageheight #7\relax 11207*d5c9a868SElliott Hughes \pdfpagewidth #8\relax 11208*d5c9a868SElliott Hughes % XeTeX does not have \pdfhorigin and \pdfvorigin. 11209*d5c9a868SElliott Hughes \fi 11210*d5c9a868SElliott Hughes \fi 11211*d5c9a868SElliott Hughes % 11212*d5c9a868SElliott Hughes \setleading{\textleading} 11213*d5c9a868SElliott Hughes % 11214*d5c9a868SElliott Hughes \parindent = \defaultparindent 11215*d5c9a868SElliott Hughes \setemergencystretch 11216*d5c9a868SElliott Hughes} 11217*d5c9a868SElliott Hughes 11218*d5c9a868SElliott Hughes% @letterpaper (the default). 11219*d5c9a868SElliott Hughes\def\letterpaper{{\globaldefs = 1 11220*d5c9a868SElliott Hughes \parskip = 3pt plus 2pt minus 1pt 11221*d5c9a868SElliott Hughes \textleading = 13.2pt 11222*d5c9a868SElliott Hughes % 11223*d5c9a868SElliott Hughes % If page is nothing but text, make it come out even. 11224*d5c9a868SElliott Hughes \internalpagesizes{607.2pt}{6in}% that's 46 lines 11225*d5c9a868SElliott Hughes {\voffset}{.25in}% 11226*d5c9a868SElliott Hughes {\bindingoffset}{36pt}% 11227*d5c9a868SElliott Hughes {11in}{8.5in}% 11228*d5c9a868SElliott Hughes}} 11229*d5c9a868SElliott Hughes 11230*d5c9a868SElliott Hughes% Use @smallbook to reset parameters for 7x9.25 trim size. 11231*d5c9a868SElliott Hughes\def\smallbook{{\globaldefs = 1 11232*d5c9a868SElliott Hughes \parskip = 2pt plus 1pt 11233*d5c9a868SElliott Hughes \textleading = 12pt 11234*d5c9a868SElliott Hughes % 11235*d5c9a868SElliott Hughes \internalpagesizes{7.5in}{5in}% 11236*d5c9a868SElliott Hughes {-.2in}{0in}% 11237*d5c9a868SElliott Hughes {\bindingoffset}{16pt}% 11238*d5c9a868SElliott Hughes {9.25in}{7in}% 11239*d5c9a868SElliott Hughes % 11240*d5c9a868SElliott Hughes \lispnarrowing = 0.3in 11241*d5c9a868SElliott Hughes \tolerance = 700 11242*d5c9a868SElliott Hughes \contentsrightmargin = 0pt 11243*d5c9a868SElliott Hughes \defbodyindent = .5cm 11244*d5c9a868SElliott Hughes}} 11245*d5c9a868SElliott Hughes 11246*d5c9a868SElliott Hughes% Use @afourpaper to print on European A4 paper. 11247*d5c9a868SElliott Hughes\def\afourpaper{{\globaldefs = 1 11248*d5c9a868SElliott Hughes \parskip = 3pt plus 2pt minus 1pt 11249*d5c9a868SElliott Hughes \textleading = 13.2pt 11250*d5c9a868SElliott Hughes % 11251*d5c9a868SElliott Hughes % Double-side printing via postscript on Laserjet 4050 11252*d5c9a868SElliott Hughes % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm. 11253*d5c9a868SElliott Hughes % To change the settings for a different printer or situation, adjust 11254*d5c9a868SElliott Hughes % \normaloffset until the front-side and back-side texts align. Then 11255*d5c9a868SElliott Hughes % do the same for \bindingoffset. You can set these for testing in 11256*d5c9a868SElliott Hughes % your texinfo source file like this: 11257*d5c9a868SElliott Hughes % @tex 11258*d5c9a868SElliott Hughes % \global\normaloffset = -6mm 11259*d5c9a868SElliott Hughes % \global\bindingoffset = 10mm 11260*d5c9a868SElliott Hughes % @end tex 11261*d5c9a868SElliott Hughes \internalpagesizes{673.2pt}{160mm}% that's 51 lines 11262*d5c9a868SElliott Hughes {\voffset}{\hoffset}% 11263*d5c9a868SElliott Hughes {\bindingoffset}{44pt}% 11264*d5c9a868SElliott Hughes {297mm}{210mm}% 11265*d5c9a868SElliott Hughes % 11266*d5c9a868SElliott Hughes \tolerance = 700 11267*d5c9a868SElliott Hughes \contentsrightmargin = 0pt 11268*d5c9a868SElliott Hughes \defbodyindent = 5mm 11269*d5c9a868SElliott Hughes}} 11270*d5c9a868SElliott Hughes 11271*d5c9a868SElliott Hughes% Use @afivepaper to print on European A5 paper. 11272*d5c9a868SElliott Hughes% From [email protected], 2 July 2000. 11273*d5c9a868SElliott Hughes% He also recommends making @example and @lisp be small. 11274*d5c9a868SElliott Hughes\def\afivepaper{{\globaldefs = 1 11275*d5c9a868SElliott Hughes \parskip = 2pt plus 1pt minus 0.1pt 11276*d5c9a868SElliott Hughes \textleading = 12.5pt 11277*d5c9a868SElliott Hughes % 11278*d5c9a868SElliott Hughes \internalpagesizes{160mm}{120mm}% 11279*d5c9a868SElliott Hughes {\voffset}{\hoffset}% 11280*d5c9a868SElliott Hughes {\bindingoffset}{8pt}% 11281*d5c9a868SElliott Hughes {210mm}{148mm}% 11282*d5c9a868SElliott Hughes % 11283*d5c9a868SElliott Hughes \lispnarrowing = 0.2in 11284*d5c9a868SElliott Hughes \tolerance = 800 11285*d5c9a868SElliott Hughes \contentsrightmargin = 0pt 11286*d5c9a868SElliott Hughes \defbodyindent = 2mm 11287*d5c9a868SElliott Hughes \tableindent = 12mm 11288*d5c9a868SElliott Hughes}} 11289*d5c9a868SElliott Hughes 11290*d5c9a868SElliott Hughes% A specific text layout, 24x15cm overall, intended for A4 paper. 11291*d5c9a868SElliott Hughes\def\afourlatex{{\globaldefs = 1 11292*d5c9a868SElliott Hughes \afourpaper 11293*d5c9a868SElliott Hughes \internalpagesizes{237mm}{150mm}% 11294*d5c9a868SElliott Hughes {\voffset}{4.6mm}% 11295*d5c9a868SElliott Hughes {\bindingoffset}{7mm}% 11296*d5c9a868SElliott Hughes {297mm}{210mm}% 11297*d5c9a868SElliott Hughes % 11298*d5c9a868SElliott Hughes % Must explicitly reset to 0 because we call \afourpaper. 11299*d5c9a868SElliott Hughes \globaldefs = 0 11300*d5c9a868SElliott Hughes}} 11301*d5c9a868SElliott Hughes 11302*d5c9a868SElliott Hughes% Use @afourwide to print on A4 paper in landscape format. 11303*d5c9a868SElliott Hughes\def\afourwide{{\globaldefs = 1 11304*d5c9a868SElliott Hughes \afourpaper 11305*d5c9a868SElliott Hughes \internalpagesizes{241mm}{165mm}% 11306*d5c9a868SElliott Hughes {\voffset}{-2.95mm}% 11307*d5c9a868SElliott Hughes {\bindingoffset}{7mm}% 11308*d5c9a868SElliott Hughes {297mm}{210mm}% 11309*d5c9a868SElliott Hughes \globaldefs = 0 11310*d5c9a868SElliott Hughes}} 11311*d5c9a868SElliott Hughes 11312*d5c9a868SElliott Hughes\def\bsixpaper{{\globaldefs = 1 11313*d5c9a868SElliott Hughes \afourpaper 11314*d5c9a868SElliott Hughes \internalpagesizes{140mm}{100mm}% 11315*d5c9a868SElliott Hughes {-6.35mm}{-12.7mm}% 11316*d5c9a868SElliott Hughes {\bindingoffset}{14pt}% 11317*d5c9a868SElliott Hughes {176mm}{125mm}% 11318*d5c9a868SElliott Hughes \let\SETdispenvsize=\smallword 11319*d5c9a868SElliott Hughes \lispnarrowing = 0.2in 11320*d5c9a868SElliott Hughes \globaldefs = 0 11321*d5c9a868SElliott Hughes}} 11322*d5c9a868SElliott Hughes 11323*d5c9a868SElliott Hughes 11324*d5c9a868SElliott Hughes% @pagesizes TEXTHEIGHT[,TEXTWIDTH] 11325*d5c9a868SElliott Hughes% Perhaps we should allow setting the margins, \topskip, \parskip, 11326*d5c9a868SElliott Hughes% and/or leading, also. Or perhaps we should compute them somehow. 11327*d5c9a868SElliott Hughes% 11328*d5c9a868SElliott Hughes\parseargdef\pagesizes{\pagesizesyyy #1,,\finish} 11329*d5c9a868SElliott Hughes\def\pagesizesyyy#1,#2,#3\finish{{% 11330*d5c9a868SElliott Hughes \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi 11331*d5c9a868SElliott Hughes \globaldefs = 1 11332*d5c9a868SElliott Hughes % 11333*d5c9a868SElliott Hughes \parskip = 3pt plus 2pt minus 1pt 11334*d5c9a868SElliott Hughes \setleading{\textleading}% 11335*d5c9a868SElliott Hughes % 11336*d5c9a868SElliott Hughes \dimen0 = #1\relax 11337*d5c9a868SElliott Hughes \advance\dimen0 by 2.5in % default 1in margin above heading line 11338*d5c9a868SElliott Hughes % and 1.5in to include heading, footing and 11339*d5c9a868SElliott Hughes % bottom margin 11340*d5c9a868SElliott Hughes % 11341*d5c9a868SElliott Hughes \dimen2 = \hsize 11342*d5c9a868SElliott Hughes \advance\dimen2 by 2in % default to 1 inch margin on each side 11343*d5c9a868SElliott Hughes % 11344*d5c9a868SElliott Hughes \internalpagesizes{#1}{\hsize}% 11345*d5c9a868SElliott Hughes {\voffset}{\normaloffset}% 11346*d5c9a868SElliott Hughes {\bindingoffset}{44pt}% 11347*d5c9a868SElliott Hughes {\dimen0}{\dimen2}% 11348*d5c9a868SElliott Hughes}} 11349*d5c9a868SElliott Hughes 11350*d5c9a868SElliott Hughes% Set default to letter. 11351*d5c9a868SElliott Hughes% 11352*d5c9a868SElliott Hughes\letterpaper 11353*d5c9a868SElliott Hughes 11354*d5c9a868SElliott Hughes% Default value of \hfuzz, for suppressing warnings about overfull hboxes. 11355*d5c9a868SElliott Hughes\hfuzz = 1pt 11356*d5c9a868SElliott Hughes 11357*d5c9a868SElliott Hughes 11358*d5c9a868SElliott Hughes\message{and turning on texinfo input format.} 11359*d5c9a868SElliott Hughes 11360*d5c9a868SElliott Hughes\def^^L{\par} % remove \outer, so ^L can appear in an @comment 11361*d5c9a868SElliott Hughes 11362*d5c9a868SElliott Hughes% DEL is a comment character, in case @c does not suffice. 11363*d5c9a868SElliott Hughes\catcode`\^^? = 14 11364*d5c9a868SElliott Hughes 11365*d5c9a868SElliott Hughes% Define macros to output various characters with catcode for normal text. 11366*d5c9a868SElliott Hughes\catcode`\"=\other \def\normaldoublequote{"} 11367*d5c9a868SElliott Hughes\catcode`\$=\other \def\normaldollar{$}%$ font-lock fix 11368*d5c9a868SElliott Hughes\catcode`\+=\other \def\normalplus{+} 11369*d5c9a868SElliott Hughes\catcode`\<=\other \def\normalless{<} 11370*d5c9a868SElliott Hughes\catcode`\>=\other \def\normalgreater{>} 11371*d5c9a868SElliott Hughes\catcode`\^=\other \def\normalcaret{^} 11372*d5c9a868SElliott Hughes\catcode`\_=\other \def\normalunderscore{_} 11373*d5c9a868SElliott Hughes\catcode`\|=\other \def\normalverticalbar{|} 11374*d5c9a868SElliott Hughes\catcode`\~=\other \def\normaltilde{~} 11375*d5c9a868SElliott Hughes 11376*d5c9a868SElliott Hughes% This macro is used to make a character print one way in \tt 11377*d5c9a868SElliott Hughes% (where it can probably be output as-is), and another way in other fonts, 11378*d5c9a868SElliott Hughes% where something hairier probably needs to be done. 11379*d5c9a868SElliott Hughes% 11380*d5c9a868SElliott Hughes% #1 is what to print if we are indeed using \tt; #2 is what to print 11381*d5c9a868SElliott Hughes% otherwise. Since all the Computer Modern typewriter fonts have zero 11382*d5c9a868SElliott Hughes% interword stretch (and shrink), and it is reasonable to expect all 11383*d5c9a868SElliott Hughes% typewriter fonts to have this, we can check that font parameter. 11384*d5c9a868SElliott Hughes% 11385*d5c9a868SElliott Hughes\def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi} 11386*d5c9a868SElliott Hughes 11387*d5c9a868SElliott Hughes% Same as above, but check for italic font. Actually this also catches 11388*d5c9a868SElliott Hughes% non-italic slanted fonts since it is impossible to distinguish them from 11389*d5c9a868SElliott Hughes% italic fonts. But since this is only used by $ and it uses \sl anyway 11390*d5c9a868SElliott Hughes% this is not a problem. 11391*d5c9a868SElliott Hughes\def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi} 11392*d5c9a868SElliott Hughes 11393*d5c9a868SElliott Hughes% Set catcodes for Texinfo file 11394*d5c9a868SElliott Hughes 11395*d5c9a868SElliott Hughes% Active characters for printing the wanted glyph. 11396*d5c9a868SElliott Hughes% Most of these we simply print from the \tt font, but for some, we can 11397*d5c9a868SElliott Hughes% use math or other variants that look better in normal text. 11398*d5c9a868SElliott Hughes% 11399*d5c9a868SElliott Hughes\catcode`\"=\active 11400*d5c9a868SElliott Hughes\def\activedoublequote{{\tt\char34}} 11401*d5c9a868SElliott Hughes\let"=\activedoublequote 11402*d5c9a868SElliott Hughes\catcode`\~=\active \def\activetilde{{\tt\char126}} \let~ = \activetilde 11403*d5c9a868SElliott Hughes\chardef\hatchar=`\^ 11404*d5c9a868SElliott Hughes\catcode`\^=\active \def\activehat{{\tt \hatchar}} \let^ = \activehat 11405*d5c9a868SElliott Hughes 11406*d5c9a868SElliott Hughes\catcode`\_=\active 11407*d5c9a868SElliott Hughes\def_{\ifusingtt\normalunderscore\_} 11408*d5c9a868SElliott Hughes\def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em } 11409*d5c9a868SElliott Hughes\let\realunder=_ 11410*d5c9a868SElliott Hughes 11411*d5c9a868SElliott Hughes\catcode`\|=\active \def|{{\tt\char124}} 11412*d5c9a868SElliott Hughes 11413*d5c9a868SElliott Hughes\chardef \less=`\< 11414*d5c9a868SElliott Hughes\catcode`\<=\active \def\activeless{{\tt \less}}\let< = \activeless 11415*d5c9a868SElliott Hughes\chardef \gtr=`\> 11416*d5c9a868SElliott Hughes\catcode`\>=\active \def\activegtr{{\tt \gtr}}\let> = \activegtr 11417*d5c9a868SElliott Hughes\catcode`\+=\active \def+{{\tt \char 43}} 11418*d5c9a868SElliott Hughes\catcode`\$=\active \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix 11419*d5c9a868SElliott Hughes\catcode`\-=\active \let-=\normaldash 11420*d5c9a868SElliott Hughes 11421*d5c9a868SElliott Hughes 11422*d5c9a868SElliott Hughes% used for headline/footline in the output routine, in case the page 11423*d5c9a868SElliott Hughes% breaks in the middle of an @tex block. 11424*d5c9a868SElliott Hughes\def\texinfochars{% 11425*d5c9a868SElliott Hughes \let< = \activeless 11426*d5c9a868SElliott Hughes \let> = \activegtr 11427*d5c9a868SElliott Hughes \let~ = \activetilde 11428*d5c9a868SElliott Hughes \let^ = \activehat 11429*d5c9a868SElliott Hughes \setregularquotes 11430*d5c9a868SElliott Hughes \let\b = \strong 11431*d5c9a868SElliott Hughes \let\i = \smartitalic 11432*d5c9a868SElliott Hughes % in principle, all other definitions in \tex have to be undone too. 11433*d5c9a868SElliott Hughes} 11434*d5c9a868SElliott Hughes 11435*d5c9a868SElliott Hughes% Used sometimes to turn off (effectively) the active characters even after 11436*d5c9a868SElliott Hughes% parsing them. 11437*d5c9a868SElliott Hughes\def\turnoffactive{% 11438*d5c9a868SElliott Hughes \normalturnoffactive 11439*d5c9a868SElliott Hughes \otherbackslash 11440*d5c9a868SElliott Hughes} 11441*d5c9a868SElliott Hughes 11442*d5c9a868SElliott Hughes\catcode`\@=0 11443*d5c9a868SElliott Hughes 11444*d5c9a868SElliott Hughes% \backslashcurfont outputs one backslash character in current font, 11445*d5c9a868SElliott Hughes% as in \char`\\. 11446*d5c9a868SElliott Hughes\global\chardef\backslashcurfont=`\\ 11447*d5c9a868SElliott Hughes 11448*d5c9a868SElliott Hughes% \realbackslash is an actual character `\' with catcode other. 11449*d5c9a868SElliott Hughes{\catcode`\\=\other @gdef@realbackslash{\}} 11450*d5c9a868SElliott Hughes 11451*d5c9a868SElliott Hughes% In Texinfo, backslash is an active character; it prints the backslash 11452*d5c9a868SElliott Hughes% in fixed width font. 11453*d5c9a868SElliott Hughes\catcode`\\=\active % @ for escape char from now on. 11454*d5c9a868SElliott Hughes 11455*d5c9a868SElliott Hughes% Print a typewriter backslash. For math mode, we can't simply use 11456*d5c9a868SElliott Hughes% \backslashcurfont: the story here is that in math mode, the \char 11457*d5c9a868SElliott Hughes% of \backslashcurfont ends up printing the roman \ from the math symbol 11458*d5c9a868SElliott Hughes% font (because \char in math mode uses the \mathcode, and plain.tex 11459*d5c9a868SElliott Hughes% sets \mathcode`\\="026E). Hence we use an explicit \mathchar, 11460*d5c9a868SElliott Hughes% which is the decimal equivalent of "715c (class 7, e.g., use \fam; 11461*d5c9a868SElliott Hughes% ignored family value; char position "5C). We can't use " for the 11462*d5c9a868SElliott Hughes% usual hex value because it has already been made active. 11463*d5c9a868SElliott Hughes 11464*d5c9a868SElliott Hughes@def@ttbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}} 11465*d5c9a868SElliott Hughes@let@backslashchar = @ttbackslash % @backslashchar{} is for user documents. 11466*d5c9a868SElliott Hughes 11467*d5c9a868SElliott Hughes% \otherbackslash defines an active \ to be a literal `\' character with 11468*d5c9a868SElliott Hughes% catcode other. 11469*d5c9a868SElliott Hughes@gdef@otherbackslash{@let\=@realbackslash} 11470*d5c9a868SElliott Hughes 11471*d5c9a868SElliott Hughes% Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of 11472*d5c9a868SElliott Hughes% the literal character `\'. 11473*d5c9a868SElliott Hughes% 11474*d5c9a868SElliott Hughes{@catcode`- = @active 11475*d5c9a868SElliott Hughes @gdef@normalturnoffactive{% 11476*d5c9a868SElliott Hughes @passthroughcharstrue 11477*d5c9a868SElliott Hughes @let-=@normaldash 11478*d5c9a868SElliott Hughes @let"=@normaldoublequote 11479*d5c9a868SElliott Hughes @let$=@normaldollar %$ font-lock fix 11480*d5c9a868SElliott Hughes @let+=@normalplus 11481*d5c9a868SElliott Hughes @let<=@normalless 11482*d5c9a868SElliott Hughes @let>=@normalgreater 11483*d5c9a868SElliott Hughes @let^=@normalcaret 11484*d5c9a868SElliott Hughes @let_=@normalunderscore 11485*d5c9a868SElliott Hughes @let|=@normalverticalbar 11486*d5c9a868SElliott Hughes @let~=@normaltilde 11487*d5c9a868SElliott Hughes @let\=@ttbackslash 11488*d5c9a868SElliott Hughes @setregularquotes 11489*d5c9a868SElliott Hughes @unsepspaces 11490*d5c9a868SElliott Hughes } 11491*d5c9a868SElliott Hughes} 11492*d5c9a868SElliott Hughes 11493*d5c9a868SElliott Hughes% If a .fmt file is being used, characters that might appear in a file 11494*d5c9a868SElliott Hughes% name cannot be active until we have parsed the command line. 11495*d5c9a868SElliott Hughes% So turn them off again, and have @fixbackslash turn them back on. 11496*d5c9a868SElliott Hughes@catcode`+=@other @catcode`@_=@other 11497*d5c9a868SElliott Hughes 11498*d5c9a868SElliott Hughes% \enablebackslashhack - allow file to begin `\input texinfo' 11499*d5c9a868SElliott Hughes% 11500*d5c9a868SElliott Hughes% If a .fmt file is being used, we don't want the `\input texinfo' to show up. 11501*d5c9a868SElliott Hughes% That is what \eatinput is for; after that, the `\' should revert to printing 11502*d5c9a868SElliott Hughes% a backslash. 11503*d5c9a868SElliott Hughes% If the file did not have a `\input texinfo', then it is turned off after 11504*d5c9a868SElliott Hughes% the first line; otherwise the first `\' in the file would cause an error. 11505*d5c9a868SElliott Hughes% This is used on the very last line of this file, texinfo.tex. 11506*d5c9a868SElliott Hughes% We also use @c to call @fixbackslash, in case ends of lines are hidden. 11507*d5c9a868SElliott Hughes{ 11508*d5c9a868SElliott Hughes@catcode`@^=7 11509*d5c9a868SElliott Hughes@catcode`@^^M=13@gdef@enablebackslashhack{% 11510*d5c9a868SElliott Hughes @global@let\ = @eatinput% 11511*d5c9a868SElliott Hughes @catcode`@^^M=13% 11512*d5c9a868SElliott Hughes @def@c{@fixbackslash@c}% 11513*d5c9a868SElliott Hughes % Definition for the newline at the end of this file. 11514*d5c9a868SElliott Hughes @def ^^M{@let^^M@secondlinenl}% 11515*d5c9a868SElliott Hughes % Definition for a newline in the main Texinfo file. 11516*d5c9a868SElliott Hughes @gdef @secondlinenl{@fixbackslash}% 11517*d5c9a868SElliott Hughes % In case the first line has a whole-line command on it 11518*d5c9a868SElliott Hughes @let@originalparsearg@parsearg 11519*d5c9a868SElliott Hughes @def@parsearg{@fixbackslash@originalparsearg} 11520*d5c9a868SElliott Hughes}} 11521*d5c9a868SElliott Hughes 11522*d5c9a868SElliott Hughes{@catcode`@^=7 @catcode`@^^M=13% 11523*d5c9a868SElliott Hughes@gdef@eatinput input texinfo#1^^M{@fixbackslash}} 11524*d5c9a868SElliott Hughes 11525*d5c9a868SElliott Hughes% Emergency active definition of newline, in case an active newline token 11526*d5c9a868SElliott Hughes% appears by mistake. 11527*d5c9a868SElliott Hughes{@catcode`@^=7 @catcode13=13% 11528*d5c9a868SElliott Hughes@gdef@enableemergencynewline{% 11529*d5c9a868SElliott Hughes @gdef^^M{% 11530*d5c9a868SElliott Hughes @par% 11531*d5c9a868SElliott Hughes %<warning: active newline>@par% 11532*d5c9a868SElliott Hughes}}} 11533*d5c9a868SElliott Hughes 11534*d5c9a868SElliott Hughes 11535*d5c9a868SElliott Hughes@gdef@fixbackslash{% 11536*d5c9a868SElliott Hughes @ifx\@eatinput @let\ = @ttbackslash @fi 11537*d5c9a868SElliott Hughes @catcode13=5 % regular end of line 11538*d5c9a868SElliott Hughes @enableemergencynewline 11539*d5c9a868SElliott Hughes @let@c=@comment 11540*d5c9a868SElliott Hughes @let@parsearg@originalparsearg 11541*d5c9a868SElliott Hughes % Also turn back on active characters that might appear in the input 11542*d5c9a868SElliott Hughes % file name, in case not using a pre-dumped format. 11543*d5c9a868SElliott Hughes @catcode`+=@active 11544*d5c9a868SElliott Hughes @catcode`@_=@active 11545*d5c9a868SElliott Hughes % 11546*d5c9a868SElliott Hughes % If texinfo.cnf is present on the system, read it. 11547*d5c9a868SElliott Hughes % Useful for site-wide @afourpaper, etc. This macro, @fixbackslash, gets 11548*d5c9a868SElliott Hughes % called at the beginning of every Texinfo file. Not opening texinfo.cnf 11549*d5c9a868SElliott Hughes % directly in this file, texinfo.tex, makes it possible to make a format 11550*d5c9a868SElliott Hughes % file for Texinfo. 11551*d5c9a868SElliott Hughes % 11552*d5c9a868SElliott Hughes @openin 1 texinfo.cnf 11553*d5c9a868SElliott Hughes @ifeof 1 @else @input texinfo.cnf @fi 11554*d5c9a868SElliott Hughes @closein 1 11555*d5c9a868SElliott Hughes} 11556*d5c9a868SElliott Hughes 11557*d5c9a868SElliott Hughes 11558*d5c9a868SElliott Hughes% Say @foo, not \foo, in error messages. 11559*d5c9a868SElliott Hughes@escapechar = `@@ 11560*d5c9a868SElliott Hughes 11561*d5c9a868SElliott Hughes% These (along with & and #) are made active for url-breaking, so need 11562*d5c9a868SElliott Hughes% active definitions as the normal characters. 11563*d5c9a868SElliott Hughes@def@normaldot{.} 11564*d5c9a868SElliott Hughes@def@normalquest{?} 11565*d5c9a868SElliott Hughes@def@normalslash{/} 11566*d5c9a868SElliott Hughes 11567*d5c9a868SElliott Hughes% These look ok in all fonts, so just make them not special. 11568*d5c9a868SElliott Hughes% @hashchar{} gets its own user-level command, because of #line. 11569*d5c9a868SElliott Hughes@catcode`@& = @other @def@normalamp{&} 11570*d5c9a868SElliott Hughes@catcode`@# = @other @def@normalhash{#} 11571*d5c9a868SElliott Hughes@catcode`@% = @other @def@normalpercent{%} 11572*d5c9a868SElliott Hughes 11573*d5c9a868SElliott Hughes@let @hashchar = @normalhash 11574*d5c9a868SElliott Hughes 11575*d5c9a868SElliott Hughes@c Finally, make ` and ' active, so that txicodequoteundirected and 11576*d5c9a868SElliott Hughes@c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}. If we 11577*d5c9a868SElliott Hughes@c don't make ` and ' active, @code will not get them as active chars. 11578*d5c9a868SElliott Hughes@c Do this last of all since we use ` in the previous @catcode assignments. 11579*d5c9a868SElliott Hughes@catcode`@'=@active 11580*d5c9a868SElliott Hughes@catcode`@`=@active 11581*d5c9a868SElliott Hughes@setregularquotes 11582*d5c9a868SElliott Hughes 11583*d5c9a868SElliott Hughes@c Local variables: 11584*d5c9a868SElliott Hughes@c eval: (add-hook 'before-save-hook 'time-stamp nil t) 11585*d5c9a868SElliott Hughes@c time-stamp-pattern: "texinfoversion{%Y-%02m-%02d.%02H}" 11586*d5c9a868SElliott Hughes@c page-delimiter: "^\\\\message\\|emacs-page" 11587*d5c9a868SElliott Hughes@c End: 11588*d5c9a868SElliott Hughes 11589*d5c9a868SElliott Hughes@c vim:sw=2: 11590*d5c9a868SElliott Hughes 11591*d5c9a868SElliott Hughes@enablebackslashhack 11592*d5c9a868SElliott Hughes 11593