Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 1 | % texinfo.tex -- TeX macros to handle Texinfo files. |
| 2 | % |
| 3 | % Load plain if necessary, i.e., if running under initex. |
| 4 | \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi |
| 5 | % |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 6 | \def\texinfoversion{2022-01-02.12} |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 7 | % |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 8 | % Copyright 1985, 1986, 1988, 1990-2021 Free Software Foundation, Inc. |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 9 | % |
| 10 | % This texinfo.tex file is free software: you can redistribute it and/or |
| 11 | % modify it under the terms of the GNU General Public License as |
| 12 | % published by the Free Software Foundation, either version 3 of the |
| 13 | % License, or (at your option) any later version. |
| 14 | % |
| 15 | % This texinfo.tex file is distributed in the hope that it will be |
| 16 | % useful, but WITHOUT ANY WARRANTY; without even the implied warranty |
| 17 | % of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 18 | % General Public License for more details. |
| 19 | % |
| 20 | % You should have received a copy of the GNU General Public License |
| 21 | % along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 22 | % |
| 23 | % As a special exception, when this file is read by TeX when processing |
| 24 | % a Texinfo source document, you may use the result without |
| 25 | % restriction. This Exception is an additional permission under section 7 |
| 26 | % of the GNU General Public License, version 3 ("GPLv3"). |
| 27 | % |
| 28 | % Please try the latest version of texinfo.tex before submitting bug |
| 29 | % reports; you can get the latest version from: |
| 30 | % https://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or |
| 31 | % https://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or |
| 32 | % https://www.gnu.org/software/texinfo/ (the Texinfo home page) |
| 33 | % The texinfo.tex in any given distribution could well be out |
| 34 | % of date, so if that's what you're using, please check. |
| 35 | % |
| 36 | % Send bug reports to bug-texinfo@gnu.org. Please include a |
| 37 | % complete document in each bug report with which we can reproduce the |
| 38 | % problem. Patches are, of course, greatly appreciated. |
| 39 | % |
| 40 | % To process a Texinfo manual with TeX, it's most reliable to use the |
| 41 | % texi2dvi shell script that comes with the distribution. For a simple |
| 42 | % manual foo.texi, however, you can get away with this: |
| 43 | % tex foo.texi |
| 44 | % texindex foo.?? |
| 45 | % tex foo.texi |
| 46 | % tex foo.texi |
| 47 | % dvips foo.dvi -o # or whatever; this makes foo.ps. |
| 48 | % The extra TeX runs get the cross-reference information correct. |
| 49 | % Sometimes one run after texindex suffices, and sometimes you need more |
| 50 | % than two; texi2dvi does it as many times as necessary. |
| 51 | % |
| 52 | % It is possible to adapt texinfo.tex for other languages, to some |
| 53 | % extent. You can get the existing language-specific files from the |
| 54 | % full Texinfo distribution. |
| 55 | % |
| 56 | % The GNU Texinfo home page is https://www.gnu.org/software/texinfo. |
| 57 | |
| 58 | |
| 59 | \message{Loading texinfo [version \texinfoversion]:} |
| 60 | |
| 61 | % If in a .fmt file, print the version number |
| 62 | % and turn on active characters that we couldn't do earlier because |
| 63 | % they might have appeared in the input file name. |
| 64 | \everyjob{\message{[Texinfo version \texinfoversion]}% |
| 65 | \catcode`+=\active \catcode`\_=\active} |
| 66 | |
| 67 | % LaTeX's \typeout. This ensures that the messages it is used for |
| 68 | % are identical in format to the corresponding ones from latex/pdflatex. |
| 69 | \def\typeout{\immediate\write17}% |
| 70 | |
| 71 | \chardef\other=12 |
| 72 | |
| 73 | % We never want plain's \outer definition of \+ in Texinfo. |
| 74 | % For @tex, we can use \tabalign. |
| 75 | \let\+ = \relax |
| 76 | |
| 77 | % Save some plain tex macros whose names we will redefine. |
| 78 | \let\ptexb=\b |
| 79 | \let\ptexbullet=\bullet |
| 80 | \let\ptexc=\c |
| 81 | \let\ptexcomma=\, |
| 82 | \let\ptexdot=\. |
| 83 | \let\ptexdots=\dots |
| 84 | \let\ptexend=\end |
| 85 | \let\ptexequiv=\equiv |
| 86 | \let\ptexexclam=\! |
| 87 | \let\ptexfootnote=\footnote |
| 88 | \let\ptexgtr=> |
| 89 | \let\ptexhat=^ |
| 90 | \let\ptexi=\i |
| 91 | \let\ptexindent=\indent |
| 92 | \let\ptexinsert=\insert |
| 93 | \let\ptexlbrace=\{ |
| 94 | \let\ptexless=< |
| 95 | \let\ptexnewwrite\newwrite |
| 96 | \let\ptexnoindent=\noindent |
| 97 | \let\ptexplus=+ |
| 98 | \let\ptexraggedright=\raggedright |
| 99 | \let\ptexrbrace=\} |
| 100 | \let\ptexslash=\/ |
| 101 | \let\ptexsp=\sp |
| 102 | \let\ptexstar=\* |
| 103 | \let\ptexsup=\sup |
| 104 | \let\ptext=\t |
| 105 | \let\ptextop=\top |
| 106 | {\catcode`\'=\active \global\let\ptexquoteright'}% active in plain's math mode |
| 107 | |
| 108 | % If this character appears in an error message or help string, it |
| 109 | % starts a new line in the output. |
| 110 | \newlinechar = `^^J |
| 111 | |
| 112 | % Use TeX 3.0's \inputlineno to get the line number, for better error |
| 113 | % messages, but if we're using an old version of TeX, don't do anything. |
| 114 | % |
| 115 | \ifx\inputlineno\thisisundefined |
| 116 | \let\linenumber = \empty % Pre-3.0. |
| 117 | \else |
| 118 | \def\linenumber{l.\the\inputlineno:\space} |
| 119 | \fi |
| 120 | |
| 121 | % Set up fixed words for English if not already set. |
| 122 | \ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi |
| 123 | \ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi |
| 124 | \ifx\putworderror\undefined \gdef\putworderror{error}\fi |
| 125 | \ifx\putwordfile\undefined \gdef\putwordfile{file}\fi |
| 126 | \ifx\putwordin\undefined \gdef\putwordin{in}\fi |
| 127 | \ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi |
| 128 | \ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi |
| 129 | \ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi |
| 130 | \ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi |
| 131 | \ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi |
| 132 | \ifx\putwordNoTitle\undefined \gdef\putwordNoTitle{No Title}\fi |
| 133 | \ifx\putwordof\undefined \gdef\putwordof{of}\fi |
| 134 | \ifx\putwordon\undefined \gdef\putwordon{on}\fi |
| 135 | \ifx\putwordpage\undefined \gdef\putwordpage{page}\fi |
| 136 | \ifx\putwordsection\undefined \gdef\putwordsection{section}\fi |
| 137 | \ifx\putwordSection\undefined \gdef\putwordSection{Section}\fi |
| 138 | \ifx\putwordsee\undefined \gdef\putwordsee{see}\fi |
| 139 | \ifx\putwordSee\undefined \gdef\putwordSee{See}\fi |
| 140 | \ifx\putwordShortTOC\undefined \gdef\putwordShortTOC{Short Contents}\fi |
| 141 | \ifx\putwordTOC\undefined \gdef\putwordTOC{Table of Contents}\fi |
| 142 | % |
| 143 | \ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi |
| 144 | \ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi |
| 145 | \ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi |
| 146 | \ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi |
| 147 | \ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi |
| 148 | \ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi |
| 149 | \ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi |
| 150 | \ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi |
| 151 | \ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi |
| 152 | \ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi |
| 153 | \ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi |
| 154 | \ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi |
| 155 | % |
| 156 | \ifx\putwordDefmac\undefined \gdef\putwordDefmac{Macro}\fi |
| 157 | \ifx\putwordDefspec\undefined \gdef\putwordDefspec{Special Form}\fi |
| 158 | \ifx\putwordDefvar\undefined \gdef\putwordDefvar{Variable}\fi |
| 159 | \ifx\putwordDefopt\undefined \gdef\putwordDefopt{User Option}\fi |
| 160 | \ifx\putwordDeffunc\undefined \gdef\putwordDeffunc{Function}\fi |
| 161 | |
| 162 | % Give the space character the catcode for a space. |
| 163 | \def\spaceisspace{\catcode`\ =10\relax} |
| 164 | |
| 165 | % Likewise for ^^M, the end of line character. |
| 166 | \def\endlineisspace{\catcode13=10\relax} |
| 167 | |
| 168 | \chardef\dashChar = `\- |
| 169 | \chardef\slashChar = `\/ |
| 170 | \chardef\underChar = `\_ |
| 171 | |
| 172 | % Ignore a token. |
| 173 | % |
| 174 | \def\gobble#1{} |
| 175 | |
| 176 | % The following is used inside several \edef's. |
| 177 | \def\makecsname#1{\expandafter\noexpand\csname#1\endcsname} |
| 178 | |
| 179 | % Hyphenation fixes. |
| 180 | \hyphenation{ |
| 181 | Flor-i-da Ghost-script Ghost-view Mac-OS Post-Script |
| 182 | ap-pen-dix bit-map bit-maps |
| 183 | data-base data-bases eshell fall-ing half-way long-est man-u-script |
| 184 | man-u-scripts mini-buf-fer mini-buf-fers over-view par-a-digm |
| 185 | par-a-digms rath-er rec-tan-gu-lar ro-bot-ics se-vere-ly set-up spa-ces |
| 186 | spell-ing spell-ings |
| 187 | stand-alone strong-est time-stamp time-stamps which-ever white-space |
| 188 | wide-spread wrap-around |
| 189 | } |
| 190 | |
| 191 | % Sometimes it is convenient to have everything in the transcript file |
| 192 | % and nothing on the terminal. We don't just call \tracingall here, |
| 193 | % since that produces some useless output on the terminal. We also make |
| 194 | % some effort to order the tracing commands to reduce output in the log |
| 195 | % file; cf. trace.sty in LaTeX. |
| 196 | % |
| 197 | \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}% |
| 198 | \def\loggingall{% |
| 199 | \tracingstats2 |
| 200 | \tracingpages1 |
| 201 | \tracinglostchars2 % 2 gives us more in etex |
| 202 | \tracingparagraphs1 |
| 203 | \tracingoutput1 |
| 204 | \tracingmacros2 |
| 205 | \tracingrestores1 |
| 206 | \showboxbreadth\maxdimen \showboxdepth\maxdimen |
| 207 | \ifx\eTeXversion\thisisundefined\else % etex gives us more logging |
| 208 | \tracingscantokens1 |
| 209 | \tracingifs1 |
| 210 | \tracinggroups1 |
| 211 | \tracingnesting2 |
| 212 | \tracingassigns1 |
| 213 | \fi |
| 214 | \tracingcommands3 % 3 gives us more in etex |
| 215 | \errorcontextlines16 |
| 216 | }% |
| 217 | |
| 218 | % @errormsg{MSG}. Do the index-like expansions on MSG, but if things |
| 219 | % aren't perfect, it's not the end of the world, being an error message, |
| 220 | % after all. |
| 221 | % |
| 222 | \def\errormsg{\begingroup \indexnofonts \doerrormsg} |
| 223 | \def\doerrormsg#1{\errmessage{#1}} |
| 224 | |
| 225 | % add check for \lastpenalty to plain's definitions. If the last thing |
| 226 | % we did was a \nobreak, we don't want to insert more space. |
| 227 | % |
| 228 | \def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount |
| 229 | \removelastskip\penalty-50\smallskip\fi\fi} |
| 230 | \def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount |
| 231 | \removelastskip\penalty-100\medskip\fi\fi} |
| 232 | \def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount |
| 233 | \removelastskip\penalty-200\bigskip\fi\fi} |
| 234 | |
| 235 | % Output routine |
| 236 | % |
| 237 | |
| 238 | % For a final copy, take out the rectangles |
| 239 | % that mark overfull boxes (in case you have decided |
| 240 | % that the text looks ok even though it passes the margin). |
| 241 | % |
| 242 | \def\finalout{\overfullrule=0pt } |
| 243 | |
| 244 | \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines |
| 245 | \newdimen\topandbottommargin \topandbottommargin=.75in |
| 246 | |
| 247 | % Output a mark which sets \thischapter, \thissection and \thiscolor. |
| 248 | % We dump everything together because we only have one kind of mark. |
| 249 | % This works because we only use \botmark / \topmark, not \firstmark. |
| 250 | % |
| 251 | % A mark contains a subexpression of the \ifcase ... \fi construct. |
| 252 | % \get*marks macros below extract the needed part using \ifcase. |
| 253 | % |
| 254 | % Another complication is to let the user choose whether \thischapter |
| 255 | % (\thissection) refers to the chapter (section) in effect at the top |
| 256 | % of a page, or that at the bottom of a page. |
| 257 | |
| 258 | % \domark is called twice inside \chapmacro, to add one |
| 259 | % mark before the section break, and one after. |
| 260 | % In the second call \prevchapterdefs is the same as \currentchapterdefs, |
| 261 | % and \prevsectiondefs is the same as \currentsectiondefs. |
| 262 | % Then if the page is not broken at the mark, some of the previous |
| 263 | % section appears on the page, and we can get the name of this section |
| 264 | % from \firstmark for @everyheadingmarks top. |
| 265 | % @everyheadingmarks bottom uses \botmark. |
| 266 | % |
| 267 | % See page 260 of The TeXbook. |
| 268 | \def\domark{% |
| 269 | \toks0=\expandafter{\currentchapterdefs}% |
| 270 | \toks2=\expandafter{\currentsectiondefs}% |
| 271 | \toks4=\expandafter{\prevchapterdefs}% |
| 272 | \toks6=\expandafter{\prevsectiondefs}% |
| 273 | \toks8=\expandafter{\currentcolordefs}% |
| 274 | \mark{% |
| 275 | \the\toks0 \the\toks2 % 0: marks for @everyheadingmarks top |
| 276 | \noexpand\or \the\toks4 \the\toks6 % 1: for @everyheadingmarks bottom |
| 277 | \noexpand\else \the\toks8 % 2: color marks |
| 278 | }% |
| 279 | } |
| 280 | |
| 281 | % \gettopheadingmarks, \getbottomheadingmarks, |
| 282 | % \getcolormarks - extract needed part of mark. |
| 283 | % |
| 284 | % \topmark doesn't work for the very first chapter (after the title |
| 285 | % page or the contents), so we use \firstmark there -- this gets us |
| 286 | % the mark with the chapter defs, unless the user sneaks in, e.g., |
| 287 | % @setcolor (or @url, or @link, etc.) between @contents and the very |
| 288 | % first @chapter. |
| 289 | \def\gettopheadingmarks{% |
| 290 | \ifcase0\the\savedtopmark\fi |
| 291 | \ifx\thischapter\empty \ifcase0\firstmark\fi \fi |
| 292 | } |
| 293 | \def\getbottomheadingmarks{\ifcase1\botmark\fi} |
| 294 | \def\getcolormarks{\ifcase2\the\savedtopmark\fi} |
| 295 | |
| 296 | % Avoid "undefined control sequence" errors. |
| 297 | \def\currentchapterdefs{} |
| 298 | \def\currentsectiondefs{} |
| 299 | \def\currentsection{} |
| 300 | \def\prevchapterdefs{} |
| 301 | \def\prevsectiondefs{} |
| 302 | \def\currentcolordefs{} |
| 303 | |
| 304 | % Margin to add to right of even pages, to left of odd pages. |
| 305 | \newdimen\bindingoffset |
| 306 | \newdimen\normaloffset |
| 307 | \newdimen\txipagewidth \newdimen\txipageheight |
| 308 | |
| 309 | % Main output routine. |
| 310 | % |
| 311 | \chardef\PAGE = 255 |
| 312 | \newtoks\defaultoutput |
| 313 | \defaultoutput = {\savetopmark\onepageout{\pagecontents\PAGE}} |
| 314 | \output=\expandafter{\the\defaultoutput} |
| 315 | |
| 316 | \newbox\headlinebox |
| 317 | \newbox\footlinebox |
| 318 | |
| 319 | % When outputting the double column layout for indices, an output routine |
| 320 | % is run several times, which hides the original value of \topmark. This |
| 321 | % can lead to a page heading being output and duplicating the chapter heading |
| 322 | % of the index. Hence, save the contents of \topmark at the beginning of |
| 323 | % the output routine. The saved contents are valid until we actually |
| 324 | % \shipout a page. |
| 325 | % |
| 326 | % (We used to run a short output routine to actually set \topmark and |
| 327 | % \firstmark to the right values, but if this was called with an empty page |
| 328 | % containing whatsits for writing index entries, the whatsits would be thrown |
| 329 | % away and the index auxiliary file would remain empty.) |
| 330 | % |
| 331 | \newtoks\savedtopmark |
| 332 | \newif\iftopmarksaved |
| 333 | \topmarksavedtrue |
| 334 | \def\savetopmark{% |
| 335 | \iftopmarksaved\else |
| 336 | \global\savedtopmark=\expandafter{\topmark}% |
| 337 | \global\topmarksavedtrue |
| 338 | \fi |
| 339 | } |
| 340 | |
| 341 | % \onepageout takes a vbox as an argument. |
| 342 | % \shipout a vbox for a single page, adding an optional header, footer |
| 343 | % and footnote. This also causes index entries for this page to be written |
| 344 | % to the auxiliary files. |
| 345 | % |
| 346 | \def\onepageout#1{% |
| 347 | \hoffset=\normaloffset |
| 348 | % |
| 349 | \ifodd\pageno \advance\hoffset by \bindingoffset |
| 350 | \else \advance\hoffset by -\bindingoffset\fi |
| 351 | % |
| 352 | \checkchapterpage |
| 353 | % |
| 354 | % Retrieve the information for the headings from the marks in the page, |
| 355 | % and call Plain TeX's \makeheadline and \makefootline, which use the |
| 356 | % values in \headline and \footline. |
| 357 | % |
| 358 | % Common context changes for both heading and footing. |
| 359 | % Do this outside of the \shipout so @code etc. will be expanded in |
| 360 | % the headline as they should be, not taken literally (outputting ''code). |
| 361 | \def\commonheadfootline{\let\hsize=\txipagewidth \texinfochars} |
| 362 | % |
| 363 | \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi |
| 364 | \global\setbox\headlinebox = \vbox{\commonheadfootline \makeheadline}% |
| 365 | \ifodd\pageno \getoddfootingmarks \else \getevenfootingmarks \fi |
| 366 | \global\setbox\footlinebox = \vbox{\commonheadfootline \makefootline}% |
| 367 | % |
| 368 | {% |
| 369 | % Set context for writing to auxiliary files like index files. |
| 370 | % Have to do this stuff outside the \shipout because we want it to |
| 371 | % take effect in \write's, yet the group defined by the \vbox ends |
| 372 | % before the \shipout runs. |
| 373 | % |
| 374 | \atdummies % don't expand commands in the output. |
| 375 | \turnoffactive |
| 376 | \shipout\vbox{% |
| 377 | % Do this early so pdf references go to the beginning of the page. |
| 378 | \ifpdfmakepagedest \pdfdest name{\the\pageno} xyz\fi |
| 379 | % |
| 380 | \unvbox\headlinebox |
| 381 | \pagebody{#1}% |
| 382 | \ifdim\ht\footlinebox > 0pt |
| 383 | % Only leave this space if the footline is nonempty. |
| 384 | % (We lessened \vsize for it in \oddfootingyyy.) |
| 385 | % The \baselineskip=24pt in plain's \makefootline has no effect. |
| 386 | \vskip 24pt |
| 387 | \unvbox\footlinebox |
| 388 | \fi |
| 389 | % |
| 390 | }% |
| 391 | }% |
| 392 | \global\topmarksavedfalse |
| 393 | \advancepageno |
| 394 | \ifnum\outputpenalty>-20000 \else\dosupereject\fi |
| 395 | } |
| 396 | |
| 397 | \newinsert\margin \dimen\margin=\maxdimen |
| 398 | |
| 399 | % Main part of page, including any footnotes |
| 400 | \def\pagebody#1{\vbox to\txipageheight{\boxmaxdepth=\maxdepth #1}} |
| 401 | {\catcode`\@ =11 |
| 402 | \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi |
| 403 | % marginal hacks, juha@viisa.uucp (Juha Takala) |
| 404 | \ifvoid\margin\else % marginal info is present |
| 405 | \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\fi |
| 406 | \dimen@=\dp#1\relax \unvbox#1\relax |
| 407 | \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi |
| 408 | \ifr@ggedbottom \kern-\dimen@ \vfil \fi} |
| 409 | } |
| 410 | |
| 411 | % Check if we are on the first page of a chapter. Used for printing headings. |
| 412 | \newif\ifchapterpage |
| 413 | \def\checkchapterpage{% |
| 414 | % Get the chapter that was current at the end of the last page |
| 415 | \ifcase1\the\savedtopmark\fi |
| 416 | \let\prevchaptername\thischaptername |
| 417 | % |
| 418 | \ifodd\pageno \getoddheadingmarks \else \getevenheadingmarks \fi |
| 419 | \let\curchaptername\thischaptername |
| 420 | % |
| 421 | \ifx\curchaptername\prevchaptername |
| 422 | \chapterpagefalse |
| 423 | \else |
| 424 | \chapterpagetrue |
| 425 | \fi |
| 426 | } |
| 427 | |
| 428 | % Argument parsing |
| 429 | |
| 430 | % Parse an argument, then pass it to #1. The argument is the rest of |
| 431 | % the input line (except we remove a trailing comment). #1 should be a |
| 432 | % macro which expects an ordinary undelimited TeX argument. |
| 433 | % For example, \def\foo{\parsearg\fooxxx}. |
| 434 | % |
| 435 | \def\parsearg{\parseargusing{}} |
| 436 | \def\parseargusing#1#2{% |
| 437 | \def\argtorun{#2}% |
| 438 | \begingroup |
| 439 | \obeylines |
| 440 | \spaceisspace |
| 441 | #1% |
| 442 | \parseargline\empty% Insert the \empty token, see \finishparsearg below. |
| 443 | } |
| 444 | |
| 445 | {\obeylines % |
| 446 | \gdef\parseargline#1^^M{% |
| 447 | \endgroup % End of the group started in \parsearg. |
| 448 | \argremovecomment #1\comment\ArgTerm% |
| 449 | }% |
| 450 | } |
| 451 | |
| 452 | % First remove any @comment, then any @c comment. Pass the result on to |
| 453 | % \argcheckspaces. |
| 454 | \def\argremovecomment#1\comment#2\ArgTerm{\argremovec #1\c\ArgTerm} |
| 455 | \def\argremovec#1\c#2\ArgTerm{\argcheckspaces#1\^^M\ArgTerm} |
| 456 | |
| 457 | % Each occurrence of `\^^M' or `<space>\^^M' is replaced by a single space. |
| 458 | % |
| 459 | % \argremovec might leave us with trailing space, e.g., |
| 460 | % @end itemize @c foo |
| 461 | % This space token undergoes the same procedure and is eventually removed |
| 462 | % by \finishparsearg. |
| 463 | % |
| 464 | \def\argcheckspaces#1\^^M{\argcheckspacesX#1\^^M \^^M} |
| 465 | \def\argcheckspacesX#1 \^^M{\argcheckspacesY#1\^^M} |
| 466 | \def\argcheckspacesY#1\^^M#2\^^M#3\ArgTerm{% |
| 467 | \def\temp{#3}% |
| 468 | \ifx\temp\empty |
| 469 | % Do not use \next, perhaps the caller of \parsearg uses it; reuse \temp: |
| 470 | \let\temp\finishparsearg |
| 471 | \else |
| 472 | \let\temp\argcheckspaces |
| 473 | \fi |
| 474 | % Put the space token in: |
| 475 | \temp#1 #3\ArgTerm |
| 476 | } |
| 477 | |
| 478 | % If a _delimited_ argument is enclosed in braces, they get stripped; so |
| 479 | % to get _exactly_ the rest of the line, we had to prevent such situation. |
| 480 | % We prepended an \empty token at the very beginning and we expand it now, |
| 481 | % just before passing the control to \argtorun. |
| 482 | % (Similarly, we have to think about #3 of \argcheckspacesY above: it is |
| 483 | % either the null string, or it ends with \^^M---thus there is no danger |
| 484 | % that a pair of braces would be stripped. |
| 485 | % |
| 486 | % But first, we have to remove the trailing space token. |
| 487 | % |
| 488 | \def\finishparsearg#1 \ArgTerm{\expandafter\argtorun\expandafter{#1}} |
| 489 | |
| 490 | |
| 491 | % \parseargdef - define a command taking an argument on the line |
| 492 | % |
| 493 | % \parseargdef\foo{...} |
| 494 | % is roughly equivalent to |
| 495 | % \def\foo{\parsearg\Xfoo} |
| 496 | % \def\Xfoo#1{...} |
| 497 | \def\parseargdef#1{% |
| 498 | \expandafter \doparseargdef \csname\string#1\endcsname #1% |
| 499 | } |
| 500 | \def\doparseargdef#1#2{% |
| 501 | \def#2{\parsearg#1}% |
| 502 | \def#1##1% |
| 503 | } |
| 504 | |
| 505 | % Several utility definitions with active space: |
| 506 | { |
| 507 | \obeyspaces |
| 508 | \gdef\obeyedspace{ } |
| 509 | |
| 510 | % Make each space character in the input produce a normal interword |
| 511 | % space in the output. Don't allow a line break at this space, as this |
| 512 | % is used only in environments like @example, where each line of input |
| 513 | % should produce a line of output anyway. |
| 514 | % |
| 515 | \gdef\sepspaces{\obeyspaces\let =\tie} |
| 516 | |
| 517 | % If an index command is used in an @example environment, any spaces |
| 518 | % therein should become regular spaces in the raw index file, not the |
| 519 | % expansion of \tie (\leavevmode \penalty \@M \ ). |
| 520 | \gdef\unsepspaces{\let =\space} |
| 521 | } |
| 522 | |
| 523 | |
| 524 | \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next} |
| 525 | |
| 526 | % Define the framework for environments in texinfo.tex. It's used like this: |
| 527 | % |
| 528 | % \envdef\foo{...} |
| 529 | % \def\Efoo{...} |
| 530 | % |
| 531 | % It's the responsibility of \envdef to insert \begingroup before the |
| 532 | % actual body; @end closes the group after calling \Efoo. \envdef also |
| 533 | % defines \thisenv, so the current environment is known; @end checks |
| 534 | % whether the environment name matches. The \checkenv macro can also be |
| 535 | % used to check whether the current environment is the one expected. |
| 536 | % |
| 537 | % Non-false conditionals (@iftex, @ifset) don't fit into this, so they |
| 538 | % are not treated as environments; they don't open a group. (The |
| 539 | % implementation of @end takes care not to call \endgroup in this |
| 540 | % special case.) |
| 541 | |
| 542 | |
| 543 | % At run-time, environments start with this: |
| 544 | \def\startenvironment#1{\begingroup\def\thisenv{#1}} |
| 545 | % initialize |
| 546 | \let\thisenv\empty |
| 547 | |
| 548 | % ... but they get defined via ``\envdef\foo{...}'': |
| 549 | \long\def\envdef#1#2{\def#1{\startenvironment#1#2}} |
| 550 | \def\envparseargdef#1#2{\parseargdef#1{\startenvironment#1#2}} |
| 551 | |
| 552 | % Check whether we're in the right environment: |
| 553 | \def\checkenv#1{% |
| 554 | \def\temp{#1}% |
| 555 | \ifx\thisenv\temp |
| 556 | \else |
| 557 | \badenverr |
| 558 | \fi |
| 559 | } |
| 560 | |
| 561 | % Environment mismatch, #1 expected: |
| 562 | \def\badenverr{% |
| 563 | \errhelp = \EMsimple |
| 564 | \errmessage{This command can appear only \inenvironment\temp, |
| 565 | not \inenvironment\thisenv}% |
| 566 | } |
| 567 | \def\inenvironment#1{% |
| 568 | \ifx#1\empty |
| 569 | outside of any environment% |
| 570 | \else |
| 571 | in environment \expandafter\string#1% |
| 572 | \fi |
| 573 | } |
| 574 | |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 575 | |
| 576 | % @end foo calls \checkenv and executes the definition of \Efoo. |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 577 | \parseargdef\end{% |
| 578 | \if 1\csname iscond.#1\endcsname |
| 579 | \else |
| 580 | % The general wording of \badenverr may not be ideal. |
| 581 | \expandafter\checkenv\csname#1\endcsname |
| 582 | \csname E#1\endcsname |
| 583 | \endgroup |
| 584 | \fi |
| 585 | } |
| 586 | |
| 587 | \newhelp\EMsimple{Press RETURN to continue.} |
| 588 | |
| 589 | |
| 590 | % Be sure we're in horizontal mode when doing a tie, since we make space |
| 591 | % equivalent to this in @example-like environments. Otherwise, a space |
| 592 | % at the beginning of a line will start with \penalty -- and |
| 593 | % since \penalty is valid in vertical mode, we'd end up putting the |
| 594 | % penalty on the vertical list instead of in the new paragraph. |
| 595 | {\catcode`@ = 11 |
| 596 | % Avoid using \@M directly, because that causes trouble |
| 597 | % if the definition is written into an index file. |
| 598 | \global\let\tiepenalty = \@M |
| 599 | \gdef\tie{\leavevmode\penalty\tiepenalty\ } |
| 600 | } |
| 601 | |
| 602 | % @: forces normal size whitespace following. |
| 603 | \def\:{\spacefactor=1000 } |
| 604 | |
| 605 | % @* forces a line break. |
| 606 | \def\*{\unskip\hfil\break\hbox{}\ignorespaces} |
| 607 | |
| 608 | % @/ allows a line break. |
| 609 | \let\/=\allowbreak |
| 610 | |
| 611 | % @. is an end-of-sentence period. |
| 612 | \def\.{.\spacefactor=\endofsentencespacefactor\space} |
| 613 | |
| 614 | % @! is an end-of-sentence bang. |
| 615 | \def\!{!\spacefactor=\endofsentencespacefactor\space} |
| 616 | |
| 617 | % @? is an end-of-sentence query. |
| 618 | \def\?{?\spacefactor=\endofsentencespacefactor\space} |
| 619 | |
| 620 | % @frenchspacing on|off says whether to put extra space after punctuation. |
| 621 | % |
| 622 | \def\onword{on} |
| 623 | \def\offword{off} |
| 624 | % |
| 625 | \parseargdef\frenchspacing{% |
| 626 | \def\temp{#1}% |
| 627 | \ifx\temp\onword \plainfrenchspacing |
| 628 | \else\ifx\temp\offword \plainnonfrenchspacing |
| 629 | \else |
| 630 | \errhelp = \EMsimple |
| 631 | \errmessage{Unknown @frenchspacing option `\temp', must be on|off}% |
| 632 | \fi\fi |
| 633 | } |
| 634 | |
| 635 | % @w prevents a word break. Without the \leavevmode, @w at the |
| 636 | % beginning of a paragraph, when TeX is still in vertical mode, would |
| 637 | % produce a whole line of output instead of starting the paragraph. |
| 638 | \def\w#1{\leavevmode\hbox{#1}} |
| 639 | |
| 640 | % @group ... @end group forces ... to be all on one page, by enclosing |
| 641 | % it in a TeX vbox. We use \vtop instead of \vbox to construct the box |
| 642 | % to keep its height that of a normal line. According to the rules for |
| 643 | % \topskip (p.114 of the TeXbook), the glue inserted is |
| 644 | % max (\topskip - \ht (first item), 0). If that height is large, |
| 645 | % therefore, no glue is inserted, and the space between the headline and |
| 646 | % the text is small, which looks bad. |
| 647 | % |
| 648 | % Another complication is that the group might be very large. This can |
| 649 | % cause the glue on the previous page to be unduly stretched, because it |
| 650 | % does not have much material. In this case, it's better to add an |
| 651 | % explicit \vfill so that the extra space is at the bottom. The |
| 652 | % threshold for doing this is if the group is more than \vfilllimit |
| 653 | % percent of a page (\vfilllimit can be changed inside of @tex). |
| 654 | % |
| 655 | \newbox\groupbox |
| 656 | \def\vfilllimit{0.7} |
| 657 | % |
| 658 | \envdef\group{% |
| 659 | \ifnum\catcode`\^^M=\active \else |
| 660 | \errhelp = \groupinvalidhelp |
| 661 | \errmessage{@group invalid in context where filling is enabled}% |
| 662 | \fi |
| 663 | \startsavinginserts |
| 664 | % |
| 665 | \setbox\groupbox = \vtop\bgroup |
| 666 | % Do @comment since we are called inside an environment such as |
| 667 | % @example, where each end-of-line in the input causes an |
| 668 | % end-of-line in the output. We don't want the end-of-line after |
| 669 | % the `@group' to put extra space in the output. Since @group |
| 670 | % should appear on a line by itself (according to the Texinfo |
| 671 | % manual), we don't worry about eating any user text. |
| 672 | \comment |
| 673 | } |
| 674 | % |
| 675 | % The \vtop produces a box with normal height and large depth; thus, TeX puts |
| 676 | % \baselineskip glue before it, and (when the next line of text is done) |
| 677 | % \lineskip glue after it. Thus, space below is not quite equal to space |
| 678 | % above. But it's pretty close. |
| 679 | \def\Egroup{% |
| 680 | % To get correct interline space between the last line of the group |
| 681 | % and the first line afterwards, we have to propagate \prevdepth. |
| 682 | \endgraf % Not \par, as it may have been set to \lisppar. |
| 683 | \global\dimen1 = \prevdepth |
| 684 | \egroup % End the \vtop. |
| 685 | \addgroupbox |
| 686 | \prevdepth = \dimen1 |
| 687 | \checkinserts |
| 688 | } |
| 689 | |
| 690 | \def\addgroupbox{ |
| 691 | % \dimen0 is the vertical size of the group's box. |
| 692 | \dimen0 = \ht\groupbox \advance\dimen0 by \dp\groupbox |
| 693 | % \dimen2 is how much space is left on the page (more or less). |
| 694 | \dimen2 = \txipageheight \advance\dimen2 by -\pagetotal |
| 695 | % if the group doesn't fit on the current page, and it's a big big |
| 696 | % group, force a page break. |
| 697 | \ifdim \dimen0 > \dimen2 |
| 698 | \ifdim \pagetotal < \vfilllimit\txipageheight |
| 699 | \page |
| 700 | \fi |
| 701 | \fi |
| 702 | \box\groupbox |
| 703 | } |
| 704 | |
| 705 | % |
| 706 | % TeX puts in an \escapechar (i.e., `@') at the beginning of the help |
| 707 | % message, so this ends up printing `@group can only ...'. |
| 708 | % |
| 709 | \newhelp\groupinvalidhelp{% |
| 710 | group can only be used in environments such as @example,^^J% |
| 711 | where each line of input produces a line of output.} |
| 712 | |
| 713 | % @need space-in-mils |
| 714 | % forces a page break if there is not space-in-mils remaining. |
| 715 | |
| 716 | \newdimen\mil \mil=0.001in |
| 717 | |
| 718 | \parseargdef\need{% |
| 719 | % Ensure vertical mode, so we don't make a big box in the middle of a |
| 720 | % paragraph. |
| 721 | \par |
| 722 | % |
| 723 | % If the @need value is less than one line space, it's useless. |
| 724 | \dimen0 = #1\mil |
| 725 | \dimen2 = \ht\strutbox |
| 726 | \advance\dimen2 by \dp\strutbox |
| 727 | \ifdim\dimen0 > \dimen2 |
| 728 | % |
| 729 | % Do a \strut just to make the height of this box be normal, so the |
| 730 | % normal leading is inserted relative to the preceding line. |
| 731 | % And a page break here is fine. |
| 732 | \vtop to #1\mil{\strut\vfil}% |
| 733 | % |
| 734 | % TeX does not even consider page breaks if a penalty added to the |
| 735 | % main vertical list is 10000 or more. But in order to see if the |
| 736 | % empty box we just added fits on the page, we must make it consider |
| 737 | % page breaks. On the other hand, we don't want to actually break the |
| 738 | % page after the empty box. So we use a penalty of 9999. |
| 739 | % |
| 740 | % There is an extremely small chance that TeX will actually break the |
| 741 | % page at this \penalty, if there are no other feasible breakpoints in |
| 742 | % sight. (If the user is using lots of big @group commands, which |
| 743 | % almost-but-not-quite fill up a page, TeX will have a hard time doing |
| 744 | % good page breaking, for example.) However, I could not construct an |
| 745 | % example where a page broke at this \penalty; if it happens in a real |
| 746 | % document, then we can reconsider our strategy. |
| 747 | \penalty9999 |
| 748 | % |
| 749 | % Back up by the size of the box, whether we did a page break or not. |
| 750 | \kern -#1\mil |
| 751 | % |
| 752 | % Do not allow a page break right after this kern. |
| 753 | \nobreak |
| 754 | \fi |
| 755 | } |
| 756 | |
| 757 | % @br forces paragraph break (and is undocumented). |
| 758 | |
| 759 | \let\br = \par |
| 760 | |
| 761 | % @page forces the start of a new page. |
| 762 | % |
| 763 | \def\page{\par\vfill\supereject} |
| 764 | |
| 765 | % @exdent text.... |
| 766 | % outputs text on separate line in roman font, starting at standard page margin |
| 767 | |
| 768 | % This records the amount of indent in the innermost environment. |
| 769 | % That's how much \exdent should take out. |
| 770 | \newskip\exdentamount |
| 771 | |
| 772 | % This defn is used inside fill environments such as @defun. |
| 773 | \parseargdef\exdent{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break} |
| 774 | |
| 775 | % This defn is used inside nofill environments such as @example. |
| 776 | \parseargdef\nofillexdent{{\advance \leftskip by -\exdentamount |
| 777 | \leftline{\hskip\leftskip{\rm#1}}}} |
| 778 | |
| 779 | % @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current |
| 780 | % paragraph. For more general purposes, use the \margin insertion |
| 781 | % class. WHICH is `l' or `r'. Not documented, written for gawk manual. |
| 782 | % |
| 783 | \newskip\inmarginspacing \inmarginspacing=1cm |
| 784 | \def\strutdepth{\dp\strutbox} |
| 785 | % |
| 786 | \def\doinmargin#1#2{\strut\vadjust{% |
| 787 | \nobreak |
| 788 | \kern-\strutdepth |
| 789 | \vtop to \strutdepth{% |
| 790 | \baselineskip=\strutdepth |
| 791 | \vss |
| 792 | % if you have multiple lines of stuff to put here, you'll need to |
| 793 | % make the vbox yourself of the appropriate size. |
| 794 | \ifx#1l% |
| 795 | \llap{\ignorespaces #2\hskip\inmarginspacing}% |
| 796 | \else |
| 797 | \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}% |
| 798 | \fi |
| 799 | \null |
| 800 | }% |
| 801 | }} |
| 802 | \def\inleftmargin{\doinmargin l} |
| 803 | \def\inrightmargin{\doinmargin r} |
| 804 | % |
| 805 | % @inmargin{TEXT [, RIGHT-TEXT]} |
| 806 | % (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right; |
| 807 | % else use TEXT for both). |
| 808 | % |
| 809 | \def\inmargin#1{\parseinmargin #1,,\finish} |
| 810 | \def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing. |
| 811 | \setbox0 = \hbox{\ignorespaces #2}% |
| 812 | \ifdim\wd0 > 0pt |
| 813 | \def\lefttext{#1}% have both texts |
| 814 | \def\righttext{#2}% |
| 815 | \else |
| 816 | \def\lefttext{#1}% have only one text |
| 817 | \def\righttext{#1}% |
| 818 | \fi |
| 819 | % |
| 820 | \ifodd\pageno |
| 821 | \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin |
| 822 | \else |
| 823 | \def\temp{\inleftmargin\lefttext}% |
| 824 | \fi |
| 825 | \temp |
| 826 | } |
| 827 | |
| 828 | % @include FILE -- \input text of FILE. |
| 829 | % |
| 830 | \def\include{\parseargusing\filenamecatcodes\includezzz} |
| 831 | \def\includezzz#1{% |
| 832 | \pushthisfilestack |
| 833 | \def\thisfile{#1}% |
| 834 | {% |
| 835 | \makevalueexpandable % we want to expand any @value in FILE. |
| 836 | \turnoffactive % and allow special characters in the expansion |
| 837 | \indexnofonts % Allow `@@' and other weird things in file names. |
| 838 | \wlog{texinfo.tex: doing @include of #1^^J}% |
| 839 | \edef\temp{\noexpand\input #1 }% |
| 840 | % |
| 841 | % This trickery is to read FILE outside of a group, in case it makes |
| 842 | % definitions, etc. |
| 843 | \expandafter |
| 844 | }\temp |
| 845 | \popthisfilestack |
| 846 | } |
| 847 | \def\filenamecatcodes{% |
| 848 | \catcode`\\=\other |
| 849 | \catcode`~=\other |
| 850 | \catcode`^=\other |
| 851 | \catcode`_=\other |
| 852 | \catcode`|=\other |
| 853 | \catcode`<=\other |
| 854 | \catcode`>=\other |
| 855 | \catcode`+=\other |
| 856 | \catcode`-=\other |
| 857 | \catcode`\`=\other |
| 858 | \catcode`\'=\other |
| 859 | } |
| 860 | |
| 861 | \def\pushthisfilestack{% |
| 862 | \expandafter\pushthisfilestackX\popthisfilestack\StackTerm |
| 863 | } |
| 864 | \def\pushthisfilestackX{% |
| 865 | \expandafter\pushthisfilestackY\thisfile\StackTerm |
| 866 | } |
| 867 | \def\pushthisfilestackY #1\StackTerm #2\StackTerm {% |
| 868 | \gdef\popthisfilestack{\gdef\thisfile{#1}\gdef\popthisfilestack{#2}}% |
| 869 | } |
| 870 | |
| 871 | \def\popthisfilestack{\errthisfilestackempty} |
| 872 | \def\errthisfilestackempty{\errmessage{Internal error: |
| 873 | the stack of filenames is empty.}} |
| 874 | % |
| 875 | \def\thisfile{} |
| 876 | |
| 877 | % @center line |
| 878 | % outputs that line, centered. |
| 879 | % |
| 880 | \parseargdef\center{% |
| 881 | \ifhmode |
| 882 | \let\centersub\centerH |
| 883 | \else |
| 884 | \let\centersub\centerV |
| 885 | \fi |
| 886 | \centersub{\hfil \ignorespaces#1\unskip \hfil}% |
| 887 | \let\centersub\relax % don't let the definition persist, just in case |
| 888 | } |
| 889 | \def\centerH#1{{% |
| 890 | \hfil\break |
| 891 | \advance\hsize by -\leftskip |
| 892 | \advance\hsize by -\rightskip |
| 893 | \line{#1}% |
| 894 | \break |
| 895 | }} |
| 896 | % |
| 897 | \newcount\centerpenalty |
| 898 | \def\centerV#1{% |
| 899 | % The idea here is the same as in \startdefun, \cartouche, etc.: if |
| 900 | % @center is the first thing after a section heading, we need to wipe |
| 901 | % out the negative parskip inserted by \sectionheading, but still |
| 902 | % prevent a page break here. |
| 903 | \centerpenalty = \lastpenalty |
| 904 | \ifnum\centerpenalty>10000 \vskip\parskip \fi |
| 905 | \ifnum\centerpenalty>9999 \penalty\centerpenalty \fi |
| 906 | \line{\kern\leftskip #1\kern\rightskip}% |
| 907 | } |
| 908 | |
| 909 | % @sp n outputs n lines of vertical space |
| 910 | % |
| 911 | \parseargdef\sp{\vskip #1\baselineskip} |
| 912 | |
| 913 | % @comment ...line which is ignored... |
| 914 | % @c is the same as @comment |
| 915 | % @ignore ... @end ignore is another way to write a comment |
| 916 | |
| 917 | |
| 918 | \def\c{\begingroup \catcode`\^^M=\active% |
| 919 | \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other% |
| 920 | \cxxx} |
| 921 | {\catcode`\^^M=\active \gdef\cxxx#1^^M{\endgroup}} |
| 922 | % |
| 923 | \let\comment\c |
| 924 | |
| 925 | % @paragraphindent NCHARS |
| 926 | % We'll use ems for NCHARS, close enough. |
| 927 | % NCHARS can also be the word `asis' or `none'. |
| 928 | % We cannot feasibly implement @paragraphindent asis, though. |
| 929 | % |
| 930 | \def\asisword{asis} % no translation, these are keywords |
| 931 | \def\noneword{none} |
| 932 | % |
| 933 | \parseargdef\paragraphindent{% |
| 934 | \def\temp{#1}% |
| 935 | \ifx\temp\asisword |
| 936 | \else |
| 937 | \ifx\temp\noneword |
| 938 | \defaultparindent = 0pt |
| 939 | \else |
| 940 | \defaultparindent = #1em |
| 941 | \fi |
| 942 | \fi |
| 943 | \parindent = \defaultparindent |
| 944 | } |
| 945 | |
| 946 | % @exampleindent NCHARS |
| 947 | % We'll use ems for NCHARS like @paragraphindent. |
| 948 | % It seems @exampleindent asis isn't necessary, but |
| 949 | % I preserve it to make it similar to @paragraphindent. |
| 950 | \parseargdef\exampleindent{% |
| 951 | \def\temp{#1}% |
| 952 | \ifx\temp\asisword |
| 953 | \else |
| 954 | \ifx\temp\noneword |
| 955 | \lispnarrowing = 0pt |
| 956 | \else |
| 957 | \lispnarrowing = #1em |
| 958 | \fi |
| 959 | \fi |
| 960 | } |
| 961 | |
| 962 | % @firstparagraphindent WORD |
| 963 | % If WORD is `none', then suppress indentation of the first paragraph |
| 964 | % after a section heading. If WORD is `insert', then do indent at such |
| 965 | % paragraphs. |
| 966 | % |
| 967 | % The paragraph indentation is suppressed or not by calling |
| 968 | % \suppressfirstparagraphindent, which the sectioning commands do. |
| 969 | % We switch the definition of this back and forth according to WORD. |
| 970 | % By default, we suppress indentation. |
| 971 | % |
| 972 | \def\suppressfirstparagraphindent{\dosuppressfirstparagraphindent} |
| 973 | \def\insertword{insert} |
| 974 | % |
| 975 | \parseargdef\firstparagraphindent{% |
| 976 | \def\temp{#1}% |
| 977 | \ifx\temp\noneword |
| 978 | \let\suppressfirstparagraphindent = \dosuppressfirstparagraphindent |
| 979 | \else\ifx\temp\insertword |
| 980 | \let\suppressfirstparagraphindent = \relax |
| 981 | \else |
| 982 | \errhelp = \EMsimple |
| 983 | \errmessage{Unknown @firstparagraphindent option `\temp'}% |
| 984 | \fi\fi |
| 985 | } |
| 986 | |
| 987 | % Here is how we actually suppress indentation. Redefine \everypar to |
| 988 | % \kern backwards by \parindent, and then reset itself to empty. |
| 989 | % |
| 990 | % We also make \indent itself not actually do anything until the next |
| 991 | % paragraph. |
| 992 | % |
| 993 | \gdef\dosuppressfirstparagraphindent{% |
| 994 | \gdef\indent {\restorefirstparagraphindent \indent}% |
| 995 | \gdef\noindent{\restorefirstparagraphindent \noindent}% |
| 996 | \global\everypar = {\kern -\parindent \restorefirstparagraphindent}% |
| 997 | } |
| 998 | % |
| 999 | \gdef\restorefirstparagraphindent{% |
| 1000 | \global\let\indent = \ptexindent |
| 1001 | \global\let\noindent = \ptexnoindent |
| 1002 | \global\everypar = {}% |
| 1003 | } |
| 1004 | |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 1005 | % leave vertical mode without cancelling any first paragraph indent |
| 1006 | \gdef\imageindent{% |
| 1007 | \toks0=\everypar |
| 1008 | \everypar={}% |
| 1009 | \ptexnoindent |
| 1010 | \global\everypar=\toks0 |
| 1011 | } |
| 1012 | |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 1013 | |
| 1014 | % @refill is a no-op. |
| 1015 | \let\refill=\relax |
| 1016 | |
| 1017 | % @setfilename INFO-FILENAME - ignored |
| 1018 | \let\setfilename=\comment |
| 1019 | |
| 1020 | % @bye. |
| 1021 | \outer\def\bye{\chappager\pagelabels\tracingstats=1\ptexend} |
| 1022 | |
| 1023 | |
| 1024 | \message{pdf,} |
| 1025 | % adobe `portable' document format |
| 1026 | \newcount\tempnum |
| 1027 | \newcount\lnkcount |
| 1028 | \newtoks\filename |
| 1029 | \newcount\filenamelength |
| 1030 | \newcount\pgn |
| 1031 | \newtoks\toksA |
| 1032 | \newtoks\toksB |
| 1033 | \newtoks\toksC |
| 1034 | \newtoks\toksD |
| 1035 | \newbox\boxA |
| 1036 | \newbox\boxB |
| 1037 | \newcount\countA |
| 1038 | \newif\ifpdf |
| 1039 | \newif\ifpdfmakepagedest |
| 1040 | |
| 1041 | % |
| 1042 | % For LuaTeX |
| 1043 | % |
| 1044 | |
| 1045 | \newif\iftxiuseunicodedestname |
| 1046 | \txiuseunicodedestnamefalse % For pdfTeX etc. |
| 1047 | |
| 1048 | \ifx\luatexversion\thisisundefined |
| 1049 | \else |
| 1050 | % Use Unicode destination names |
| 1051 | \txiuseunicodedestnametrue |
| 1052 | % Escape PDF strings with converting UTF-16 from UTF-8 |
| 1053 | \begingroup |
| 1054 | \catcode`\%=12 |
| 1055 | \directlua{ |
| 1056 | function UTF16oct(str) |
| 1057 | tex.sprint(string.char(0x5c) .. '376' .. string.char(0x5c) .. '377') |
| 1058 | for c in string.utfvalues(str) do |
| 1059 | if c < 0x10000 then |
| 1060 | tex.sprint( |
| 1061 | string.format(string.char(0x5c) .. string.char(0x25) .. '03o' .. |
| 1062 | string.char(0x5c) .. string.char(0x25) .. '03o', |
| 1063 | math.floor(c / 256), math.floor(c % 256))) |
| 1064 | else |
| 1065 | c = c - 0x10000 |
| 1066 | local c_hi = c / 1024 + 0xd800 |
| 1067 | local c_lo = c % 1024 + 0xdc00 |
| 1068 | tex.sprint( |
| 1069 | string.format(string.char(0x5c) .. string.char(0x25) .. '03o' .. |
| 1070 | string.char(0x5c) .. string.char(0x25) .. '03o' .. |
| 1071 | string.char(0x5c) .. string.char(0x25) .. '03o' .. |
| 1072 | string.char(0x5c) .. string.char(0x25) .. '03o', |
| 1073 | math.floor(c_hi / 256), math.floor(c_hi % 256), |
| 1074 | math.floor(c_lo / 256), math.floor(c_lo % 256))) |
| 1075 | end |
| 1076 | end |
| 1077 | end |
| 1078 | } |
| 1079 | \endgroup |
| 1080 | \def\pdfescapestrutfsixteen#1{\directlua{UTF16oct('\luaescapestring{#1}')}} |
| 1081 | % Escape PDF strings without converting |
| 1082 | \begingroup |
| 1083 | \directlua{ |
| 1084 | function PDFescstr(str) |
| 1085 | for c in string.bytes(str) do |
| 1086 | if c <= 0x20 or c >= 0x80 or c == 0x28 or c == 0x29 or c == 0x5c then |
| 1087 | tex.sprint(-2, |
| 1088 | string.format(string.char(0x5c) .. string.char(0x25) .. '03o', |
| 1089 | c)) |
| 1090 | else |
| 1091 | tex.sprint(-2, string.char(c)) |
| 1092 | end |
| 1093 | end |
| 1094 | end |
| 1095 | } |
| 1096 | % The -2 in the arguments here gives all the input to TeX catcode 12 |
| 1097 | % (other) or 10 (space), preventing undefined control sequence errors. See |
| 1098 | % https://lists.gnu.org/archive/html/bug-texinfo/2019-08/msg00031.html |
| 1099 | % |
| 1100 | \endgroup |
| 1101 | \def\pdfescapestring#1{\directlua{PDFescstr('\luaescapestring{#1}')}} |
| 1102 | \ifnum\luatexversion>84 |
| 1103 | % For LuaTeX >= 0.85 |
| 1104 | \def\pdfdest{\pdfextension dest} |
| 1105 | \let\pdfoutput\outputmode |
| 1106 | \def\pdfliteral{\pdfextension literal} |
| 1107 | \def\pdfcatalog{\pdfextension catalog} |
| 1108 | \def\pdftexversion{\numexpr\pdffeedback version\relax} |
| 1109 | \let\pdfximage\saveimageresource |
| 1110 | \let\pdfrefximage\useimageresource |
| 1111 | \let\pdflastximage\lastsavedimageresourceindex |
| 1112 | \def\pdfendlink{\pdfextension endlink\relax} |
| 1113 | \def\pdfoutline{\pdfextension outline} |
| 1114 | \def\pdfstartlink{\pdfextension startlink} |
| 1115 | \def\pdffontattr{\pdfextension fontattr} |
| 1116 | \def\pdfobj{\pdfextension obj} |
| 1117 | \def\pdflastobj{\numexpr\pdffeedback lastobj\relax} |
| 1118 | \let\pdfpagewidth\pagewidth |
| 1119 | \let\pdfpageheight\pageheight |
| 1120 | \edef\pdfhorigin{\pdfvariable horigin} |
| 1121 | \edef\pdfvorigin{\pdfvariable vorigin} |
| 1122 | \fi |
| 1123 | \fi |
| 1124 | |
| 1125 | % when pdftex is run in dvi mode, \pdfoutput is defined (so \pdfoutput=1 |
| 1126 | % can be set). So we test for \relax and 0 as well as being undefined. |
| 1127 | \ifx\pdfoutput\thisisundefined |
| 1128 | \else |
| 1129 | \ifx\pdfoutput\relax |
| 1130 | \else |
| 1131 | \ifcase\pdfoutput |
| 1132 | \else |
| 1133 | \pdftrue |
| 1134 | \fi |
| 1135 | \fi |
| 1136 | \fi |
| 1137 | |
| 1138 | \newif\ifpdforxetex |
| 1139 | \pdforxetexfalse |
| 1140 | \ifpdf |
| 1141 | \pdforxetextrue |
| 1142 | \fi |
| 1143 | \ifx\XeTeXrevision\thisisundefined\else |
| 1144 | \pdforxetextrue |
| 1145 | \fi |
| 1146 | |
| 1147 | |
| 1148 | % Output page labels information. |
| 1149 | % See PDF reference v.1.7 p.594, section 8.3.1. |
| 1150 | \ifpdf |
| 1151 | \def\pagelabels{% |
| 1152 | \def\title{0 << /P (T-) /S /D >>}% |
| 1153 | \edef\roman{\the\romancount << /S /r >>}% |
| 1154 | \edef\arabic{\the\arabiccount << /S /D >>}% |
| 1155 | % |
| 1156 | % Page label ranges must be increasing. Remove any duplicates. |
| 1157 | % (There is a slight chance of this being wrong if e.g. there is |
| 1158 | % a @contents but no @titlepage, etc.) |
| 1159 | % |
| 1160 | \ifnum\romancount=0 \def\roman{}\fi |
| 1161 | \ifnum\arabiccount=0 \def\title{}% |
| 1162 | \else |
| 1163 | \ifnum\romancount=\arabiccount \def\roman{}\fi |
| 1164 | \fi |
| 1165 | % |
| 1166 | \ifnum\romancount<\arabiccount |
| 1167 | \pdfcatalog{/PageLabels << /Nums [\title \roman \arabic ] >> }\relax |
| 1168 | \else |
| 1169 | \pdfcatalog{/PageLabels << /Nums [\title \arabic \roman ] >> }\relax |
| 1170 | \fi |
| 1171 | } |
| 1172 | \else |
| 1173 | \let\pagelabels\relax |
| 1174 | \fi |
| 1175 | |
| 1176 | \newcount\pagecount \pagecount=0 |
| 1177 | \newcount\romancount \romancount=0 |
| 1178 | \newcount\arabiccount \arabiccount=0 |
| 1179 | \ifpdf |
| 1180 | \let\ptxadvancepageno\advancepageno |
| 1181 | \def\advancepageno{% |
| 1182 | \ptxadvancepageno\global\advance\pagecount by 1 |
| 1183 | } |
| 1184 | \fi |
| 1185 | |
| 1186 | |
| 1187 | % PDF uses PostScript string constants for the names of xref targets, |
| 1188 | % for display in the outlines, and in other places. Thus, we have to |
| 1189 | % double any backslashes. Otherwise, a name like "\node" will be |
| 1190 | % interpreted as a newline (\n), followed by o, d, e. Not good. |
| 1191 | % |
| 1192 | % See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and |
| 1193 | % related messages. The final outcome is that it is up to the TeX user |
| 1194 | % to double the backslashes and otherwise make the string valid, so |
| 1195 | % that's what we do. pdftex 1.30.0 (ca.2005) introduced a primitive to |
| 1196 | % do this reliably, so we use it. |
| 1197 | |
| 1198 | % #1 is a control sequence in which to do the replacements, |
| 1199 | % which we \xdef. |
| 1200 | \def\txiescapepdf#1{% |
| 1201 | \ifx\pdfescapestring\thisisundefined |
| 1202 | % No primitive available; should we give a warning or log? |
| 1203 | % Many times it won't matter. |
| 1204 | \xdef#1{#1}% |
| 1205 | \else |
| 1206 | % The expandable \pdfescapestring primitive escapes parentheses, |
| 1207 | % backslashes, and other special chars. |
| 1208 | \xdef#1{\pdfescapestring{#1}}% |
| 1209 | \fi |
| 1210 | } |
| 1211 | \def\txiescapepdfutfsixteen#1{% |
| 1212 | \ifx\pdfescapestrutfsixteen\thisisundefined |
| 1213 | % No UTF-16 converting macro available. |
| 1214 | \txiescapepdf{#1}% |
| 1215 | \else |
| 1216 | \xdef#1{\pdfescapestrutfsixteen{#1}}% |
| 1217 | \fi |
| 1218 | } |
| 1219 | |
| 1220 | \newhelp\nopdfimagehelp{Texinfo supports .png, .jpg, .jpeg, and .pdf images |
| 1221 | with PDF output, and none of those formats could be found. (.eps cannot |
| 1222 | be supported due to the design of the PDF format; use regular TeX (DVI |
| 1223 | output) for that.)} |
| 1224 | |
| 1225 | \ifpdf |
| 1226 | % |
| 1227 | % Color manipulation macros using ideas from pdfcolor.tex, |
| 1228 | % except using rgb instead of cmyk; the latter is said to render as a |
| 1229 | % very dark gray on-screen and a very dark halftone in print, instead |
| 1230 | % of actual black. The dark red here is dark enough to print on paper as |
| 1231 | % nearly black, but still distinguishable for online viewing. We use |
| 1232 | % black by default, though. |
| 1233 | \def\rgbDarkRed{0.50 0.09 0.12} |
| 1234 | \def\rgbBlack{0 0 0} |
| 1235 | % |
| 1236 | % rg sets the color for filling (usual text, etc.); |
| 1237 | % RG sets the color for stroking (thin rules, e.g., normal _'s). |
| 1238 | \def\pdfsetcolor#1{\pdfliteral{#1 rg #1 RG}} |
| 1239 | % |
| 1240 | % Set color, and create a mark which defines \thiscolor accordingly, |
| 1241 | % so that \makeheadline knows which color to restore. |
| 1242 | \def\setcolor#1{% |
| 1243 | \xdef\currentcolordefs{\gdef\noexpand\thiscolor{#1}}% |
| 1244 | \domark |
| 1245 | \pdfsetcolor{#1}% |
| 1246 | } |
| 1247 | % |
| 1248 | \def\maincolor{\rgbBlack} |
| 1249 | \pdfsetcolor{\maincolor} |
| 1250 | \edef\thiscolor{\maincolor} |
| 1251 | \def\currentcolordefs{} |
| 1252 | % |
| 1253 | \def\makefootline{% |
| 1254 | \baselineskip24pt |
| 1255 | \line{\pdfsetcolor{\maincolor}\the\footline}% |
| 1256 | } |
| 1257 | % |
| 1258 | \def\makeheadline{% |
| 1259 | \vbox to 0pt{% |
| 1260 | \vskip-22.5pt |
| 1261 | \line{% |
| 1262 | \vbox to8.5pt{}% |
| 1263 | % Extract \thiscolor definition from the marks. |
| 1264 | \getcolormarks |
| 1265 | % Typeset the headline with \maincolor, then restore the color. |
| 1266 | \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}% |
| 1267 | }% |
| 1268 | \vss |
| 1269 | }% |
| 1270 | \nointerlineskip |
| 1271 | } |
| 1272 | % |
| 1273 | % |
| 1274 | \pdfcatalog{/PageMode /UseOutlines} |
| 1275 | % |
| 1276 | % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto). |
| 1277 | \def\dopdfimage#1#2#3{% |
| 1278 | \def\pdfimagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}% |
| 1279 | \def\pdfimageheight{#3}\setbox2 = \hbox{\ignorespaces #3}% |
| 1280 | % |
| 1281 | % pdftex (and the PDF format) support .pdf, .png, .jpg (among |
| 1282 | % others). Let's try in that order, PDF first since if |
| 1283 | % someone has a scalable image, presumably better to use that than a |
| 1284 | % bitmap. |
| 1285 | \let\pdfimgext=\empty |
| 1286 | \begingroup |
| 1287 | \openin 1 #1.pdf \ifeof 1 |
| 1288 | \openin 1 #1.PDF \ifeof 1 |
| 1289 | \openin 1 #1.png \ifeof 1 |
| 1290 | \openin 1 #1.jpg \ifeof 1 |
| 1291 | \openin 1 #1.jpeg \ifeof 1 |
| 1292 | \openin 1 #1.JPG \ifeof 1 |
| 1293 | \errhelp = \nopdfimagehelp |
| 1294 | \errmessage{Could not find image file #1 for pdf}% |
| 1295 | \else \gdef\pdfimgext{JPG}% |
| 1296 | \fi |
| 1297 | \else \gdef\pdfimgext{jpeg}% |
| 1298 | \fi |
| 1299 | \else \gdef\pdfimgext{jpg}% |
| 1300 | \fi |
| 1301 | \else \gdef\pdfimgext{png}% |
| 1302 | \fi |
| 1303 | \else \gdef\pdfimgext{PDF}% |
| 1304 | \fi |
| 1305 | \else \gdef\pdfimgext{pdf}% |
| 1306 | \fi |
| 1307 | \closein 1 |
| 1308 | \endgroup |
| 1309 | % |
| 1310 | % without \immediate, ancient pdftex seg faults when the same image is |
| 1311 | % included twice. (Version 3.14159-pre-1.0-unofficial-20010704.) |
| 1312 | \ifnum\pdftexversion < 14 |
| 1313 | \immediate\pdfimage |
| 1314 | \else |
| 1315 | \immediate\pdfximage |
| 1316 | \fi |
| 1317 | \ifdim \wd0 >0pt width \pdfimagewidth \fi |
| 1318 | \ifdim \wd2 >0pt height \pdfimageheight \fi |
| 1319 | \ifnum\pdftexversion<13 |
| 1320 | #1.\pdfimgext |
| 1321 | \else |
| 1322 | {#1.\pdfimgext}% |
| 1323 | \fi |
| 1324 | \ifnum\pdftexversion < 14 \else |
| 1325 | \pdfrefximage \pdflastximage |
| 1326 | \fi} |
| 1327 | % |
| 1328 | \def\setpdfdestname#1{{% |
| 1329 | % We have to set dummies so commands such as @code, and characters |
| 1330 | % such as \, aren't expanded when present in a section title. |
| 1331 | \indexnofonts |
| 1332 | \makevalueexpandable |
| 1333 | \turnoffactive |
| 1334 | \iftxiuseunicodedestname |
| 1335 | \ifx \declaredencoding \latone |
| 1336 | % Pass through Latin-1 characters. |
| 1337 | % LuaTeX with byte wise I/O converts Latin-1 characters to Unicode. |
| 1338 | \else |
| 1339 | \ifx \declaredencoding \utfeight |
| 1340 | % Pass through Unicode characters. |
| 1341 | \else |
| 1342 | % Use ASCII approximations in destination names. |
| 1343 | \passthroughcharsfalse |
| 1344 | \fi |
| 1345 | \fi |
| 1346 | \else |
| 1347 | % Use ASCII approximations in destination names. |
| 1348 | \passthroughcharsfalse |
| 1349 | \fi |
| 1350 | \def\pdfdestname{#1}% |
| 1351 | \txiescapepdf\pdfdestname |
| 1352 | }} |
| 1353 | % |
| 1354 | \def\setpdfoutlinetext#1{{% |
| 1355 | \indexnofonts |
| 1356 | \makevalueexpandable |
| 1357 | \turnoffactive |
| 1358 | \ifx \declaredencoding \latone |
| 1359 | % The PDF format can use an extended form of Latin-1 in bookmark |
| 1360 | % strings. See Appendix D of the PDF Reference, Sixth Edition, for |
| 1361 | % the "PDFDocEncoding". |
| 1362 | \passthroughcharstrue |
| 1363 | % Pass through Latin-1 characters. |
| 1364 | % LuaTeX: Convert to Unicode |
| 1365 | % pdfTeX: Use Latin-1 as PDFDocEncoding |
| 1366 | \def\pdfoutlinetext{#1}% |
| 1367 | \else |
| 1368 | \ifx \declaredencoding \utfeight |
| 1369 | \ifx\luatexversion\thisisundefined |
| 1370 | % For pdfTeX with UTF-8. |
| 1371 | % TODO: the PDF format can use UTF-16 in bookmark strings, |
| 1372 | % but the code for this isn't done yet. |
| 1373 | % Use ASCII approximations. |
| 1374 | \passthroughcharsfalse |
| 1375 | \def\pdfoutlinetext{#1}% |
| 1376 | \else |
| 1377 | % For LuaTeX with UTF-8. |
| 1378 | % Pass through Unicode characters for title texts. |
| 1379 | \passthroughcharstrue |
| 1380 | \def\pdfoutlinetext{#1}% |
| 1381 | \fi |
| 1382 | \else |
| 1383 | % For non-Latin-1 or non-UTF-8 encodings. |
| 1384 | % Use ASCII approximations. |
| 1385 | \passthroughcharsfalse |
| 1386 | \def\pdfoutlinetext{#1}% |
| 1387 | \fi |
| 1388 | \fi |
| 1389 | % LuaTeX: Convert to UTF-16 |
| 1390 | % pdfTeX: Use Latin-1 as PDFDocEncoding |
| 1391 | \txiescapepdfutfsixteen\pdfoutlinetext |
| 1392 | }} |
| 1393 | % |
| 1394 | \def\pdfmkdest#1{% |
| 1395 | \setpdfdestname{#1}% |
| 1396 | \safewhatsit{\pdfdest name{\pdfdestname} xyz}% |
| 1397 | } |
| 1398 | % |
| 1399 | % used to mark target names; must be expandable. |
| 1400 | \def\pdfmkpgn#1{#1} |
| 1401 | % |
| 1402 | % by default, use black for everything. |
| 1403 | \def\urlcolor{\rgbBlack} |
| 1404 | \def\linkcolor{\rgbBlack} |
| 1405 | \def\endlink{\setcolor{\maincolor}\pdfendlink} |
| 1406 | % |
| 1407 | % Adding outlines to PDF; macros for calculating structure of outlines |
| 1408 | % come from Petr Olsak |
| 1409 | \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0% |
| 1410 | \else \csname#1\endcsname \fi} |
| 1411 | \def\advancenumber#1{\tempnum=\expnumber{#1}\relax |
| 1412 | \advance\tempnum by 1 |
| 1413 | \expandafter\xdef\csname#1\endcsname{\the\tempnum}} |
| 1414 | % |
| 1415 | % #1 is the section text, which is what will be displayed in the |
| 1416 | % outline by the pdf viewer. #2 is the pdf expression for the number |
| 1417 | % of subentries (or empty, for subsubsections). #3 is the node text, |
| 1418 | % which might be empty if this toc entry had no corresponding node. |
| 1419 | % #4 is the page number |
| 1420 | % |
| 1421 | \def\dopdfoutline#1#2#3#4{% |
| 1422 | % Generate a link to the node text if that exists; else, use the |
| 1423 | % page number. We could generate a destination for the section |
| 1424 | % text in the case where a section has no node, but it doesn't |
| 1425 | % seem worth the trouble, since most documents are normally structured. |
| 1426 | \setpdfoutlinetext{#1} |
| 1427 | \setpdfdestname{#3} |
| 1428 | \ifx\pdfdestname\empty |
| 1429 | \def\pdfdestname{#4}% |
| 1430 | \fi |
| 1431 | % |
| 1432 | \pdfoutline goto name{\pdfmkpgn{\pdfdestname}}#2{\pdfoutlinetext}% |
| 1433 | } |
| 1434 | % |
| 1435 | \def\pdfmakeoutlines{% |
| 1436 | \begingroup |
| 1437 | % Read toc silently, to get counts of subentries for \pdfoutline. |
| 1438 | \def\partentry##1##2##3##4{}% ignore parts in the outlines |
| 1439 | \def\numchapentry##1##2##3##4{% |
| 1440 | \def\thischapnum{##2}% |
| 1441 | \def\thissecnum{0}% |
| 1442 | \def\thissubsecnum{0}% |
| 1443 | }% |
| 1444 | \def\numsecentry##1##2##3##4{% |
| 1445 | \advancenumber{chap\thischapnum}% |
| 1446 | \def\thissecnum{##2}% |
| 1447 | \def\thissubsecnum{0}% |
| 1448 | }% |
| 1449 | \def\numsubsecentry##1##2##3##4{% |
| 1450 | \advancenumber{sec\thissecnum}% |
| 1451 | \def\thissubsecnum{##2}% |
| 1452 | }% |
| 1453 | \def\numsubsubsecentry##1##2##3##4{% |
| 1454 | \advancenumber{subsec\thissubsecnum}% |
| 1455 | }% |
| 1456 | \def\thischapnum{0}% |
| 1457 | \def\thissecnum{0}% |
| 1458 | \def\thissubsecnum{0}% |
| 1459 | % |
| 1460 | % use \def rather than \let here because we redefine \chapentry et |
| 1461 | % al. a second time, below. |
| 1462 | \def\appentry{\numchapentry}% |
| 1463 | \def\appsecentry{\numsecentry}% |
| 1464 | \def\appsubsecentry{\numsubsecentry}% |
| 1465 | \def\appsubsubsecentry{\numsubsubsecentry}% |
| 1466 | \def\unnchapentry{\numchapentry}% |
| 1467 | \def\unnsecentry{\numsecentry}% |
| 1468 | \def\unnsubsecentry{\numsubsecentry}% |
| 1469 | \def\unnsubsubsecentry{\numsubsubsecentry}% |
| 1470 | \readdatafile{toc}% |
| 1471 | % |
| 1472 | % Read toc second time, this time actually producing the outlines. |
| 1473 | % The `-' means take the \expnumber as the absolute number of |
| 1474 | % subentries, which we calculated on our first read of the .toc above. |
| 1475 | % |
| 1476 | % We use the node names as the destinations. |
| 1477 | % |
| 1478 | % Currently we prefix the section name with the section number |
| 1479 | % for chapter and appendix headings only in order to avoid too much |
| 1480 | % horizontal space being required in the PDF viewer. |
| 1481 | \def\numchapentry##1##2##3##4{% |
| 1482 | \dopdfoutline{##2 ##1}{count-\expnumber{chap##2}}{##3}{##4}}% |
| 1483 | \def\unnchapentry##1##2##3##4{% |
| 1484 | \dopdfoutline{##1}{count-\expnumber{chap##2}}{##3}{##4}}% |
| 1485 | \def\numsecentry##1##2##3##4{% |
| 1486 | \dopdfoutline{##1}{count-\expnumber{sec##2}}{##3}{##4}}% |
| 1487 | \def\numsubsecentry##1##2##3##4{% |
| 1488 | \dopdfoutline{##1}{count-\expnumber{subsec##2}}{##3}{##4}}% |
| 1489 | \def\numsubsubsecentry##1##2##3##4{% count is always zero |
| 1490 | \dopdfoutline{##1}{}{##3}{##4}}% |
| 1491 | % |
| 1492 | % PDF outlines are displayed using system fonts, instead of |
| 1493 | % document fonts. Therefore we cannot use special characters, |
| 1494 | % since the encoding is unknown. For example, the eogonek from |
| 1495 | % Latin 2 (0xea) gets translated to a | character. Info from |
| 1496 | % Staszek Wawrykiewicz, 19 Jan 2004 04:09:24 +0100. |
| 1497 | % |
| 1498 | % TODO this right, we have to translate 8-bit characters to |
| 1499 | % their "best" equivalent, based on the @documentencoding. Too |
| 1500 | % much work for too little return. Just use the ASCII equivalents |
| 1501 | % we use for the index sort strings. |
| 1502 | % |
| 1503 | \indexnofonts |
| 1504 | \setupdatafile |
| 1505 | % We can have normal brace characters in the PDF outlines, unlike |
| 1506 | % Texinfo index files. So set that up. |
| 1507 | \def\{{\lbracecharliteral}% |
| 1508 | \def\}{\rbracecharliteral}% |
| 1509 | \catcode`\\=\active \otherbackslash |
| 1510 | \input \tocreadfilename |
| 1511 | \endgroup |
| 1512 | } |
| 1513 | {\catcode`[=1 \catcode`]=2 |
| 1514 | \catcode`{=\other \catcode`}=\other |
| 1515 | \gdef\lbracecharliteral[{]% |
| 1516 | \gdef\rbracecharliteral[}]% |
| 1517 | ] |
| 1518 | % |
| 1519 | \def\skipspaces#1{\def\PP{#1}\def\D{|}% |
| 1520 | \ifx\PP\D\let\nextsp\relax |
| 1521 | \else\let\nextsp\skipspaces |
| 1522 | \addtokens{\filename}{\PP}% |
| 1523 | \advance\filenamelength by 1 |
| 1524 | \fi |
| 1525 | \nextsp} |
| 1526 | \def\getfilename#1{% |
| 1527 | \filenamelength=0 |
| 1528 | % If we don't expand the argument now, \skipspaces will get |
| 1529 | % snagged on things like "@value{foo}". |
| 1530 | \edef\temp{#1}% |
| 1531 | \expandafter\skipspaces\temp|\relax |
| 1532 | } |
| 1533 | \ifnum\pdftexversion < 14 |
| 1534 | \let \startlink \pdfannotlink |
| 1535 | \else |
| 1536 | \let \startlink \pdfstartlink |
| 1537 | \fi |
| 1538 | % make a live url in pdf output. |
| 1539 | \def\pdfurl#1{% |
| 1540 | \begingroup |
| 1541 | % it seems we really need yet another set of dummies; have not |
| 1542 | % tried to figure out what each command should do in the context |
| 1543 | % of @url. for now, just make @/ a no-op, that's the only one |
| 1544 | % people have actually reported a problem with. |
| 1545 | % |
| 1546 | \normalturnoffactive |
| 1547 | \def\@{@}% |
| 1548 | \let\/=\empty |
| 1549 | \makevalueexpandable |
| 1550 | % do we want to go so far as to use \indexnofonts instead of just |
| 1551 | % special-casing \var here? |
| 1552 | \def\var##1{##1}% |
| 1553 | % |
| 1554 | \leavevmode\setcolor{\urlcolor}% |
| 1555 | \startlink attr{/Border [0 0 0]}% |
| 1556 | user{/Subtype /Link /A << /S /URI /URI (#1) >>}% |
| 1557 | \endgroup} |
| 1558 | % \pdfgettoks - Surround page numbers in #1 with @pdflink. #1 may |
| 1559 | % be a simple number, or a list of numbers in the case of an index |
| 1560 | % entry. |
| 1561 | \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}} |
| 1562 | \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks} |
| 1563 | \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks} |
| 1564 | \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}} |
| 1565 | \def\maketoks{% |
| 1566 | \expandafter\poptoks\the\toksA|ENDTOKS|\relax |
| 1567 | \ifx\first0\adn0 |
| 1568 | \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3 |
| 1569 | \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6 |
| 1570 | \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9 |
| 1571 | \else |
| 1572 | \ifnum0=\countA\else\makelink\fi |
| 1573 | \ifx\first.\let\next=\done\else |
| 1574 | \let\next=\maketoks |
| 1575 | \addtokens{\toksB}{\the\toksD} |
| 1576 | \ifx\first,\addtokens{\toksB}{\space}\fi |
| 1577 | \fi |
| 1578 | \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi |
| 1579 | \next} |
| 1580 | \def\makelink{\addtokens{\toksB}% |
| 1581 | {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0} |
| 1582 | \def\pdflink#1{% |
| 1583 | \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}} |
| 1584 | \setcolor{\linkcolor}#1\endlink} |
| 1585 | \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st} |
| 1586 | \else |
| 1587 | % non-pdf mode |
| 1588 | \let\pdfmkdest = \gobble |
| 1589 | \let\pdfurl = \gobble |
| 1590 | \let\endlink = \relax |
| 1591 | \let\setcolor = \gobble |
| 1592 | \let\pdfsetcolor = \gobble |
| 1593 | \let\pdfmakeoutlines = \relax |
| 1594 | \fi % \ifx\pdfoutput |
| 1595 | |
| 1596 | % |
| 1597 | % For XeTeX |
| 1598 | % |
| 1599 | \ifx\XeTeXrevision\thisisundefined |
| 1600 | \else |
| 1601 | % |
| 1602 | % XeTeX version check |
| 1603 | % |
| 1604 | \ifnum\strcmp{\the\XeTeXversion\XeTeXrevision}{0.99996}>-1 |
| 1605 | % TeX Live 2016 contains XeTeX 0.99996 and xdvipdfmx 20160307. |
| 1606 | % It can use the `dvipdfmx:config' special (from TeX Live SVN r40941). |
| 1607 | % For avoiding PDF destination name replacement, we use this special |
| 1608 | % instead of xdvipdfmx's command line option `-C 0x0010'. |
| 1609 | \special{dvipdfmx:config C 0x0010} |
| 1610 | % XeTeX 0.99995+ comes with xdvipdfmx 20160307+. |
| 1611 | % It can handle Unicode destination names for PDF. |
| 1612 | \txiuseunicodedestnametrue |
| 1613 | \else |
| 1614 | % XeTeX < 0.99996 (TeX Live < 2016) cannot use the |
| 1615 | % `dvipdfmx:config' special. |
| 1616 | % So for avoiding PDF destination name replacement, |
| 1617 | % xdvipdfmx's command line option `-C 0x0010' is necessary. |
| 1618 | % |
| 1619 | % XeTeX < 0.99995 can not handle Unicode destination names for PDF |
| 1620 | % because xdvipdfmx 20150315 has a UTF-16 conversion issue. |
| 1621 | % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753). |
| 1622 | \txiuseunicodedestnamefalse |
| 1623 | \fi |
| 1624 | % |
| 1625 | % Color support |
| 1626 | % |
| 1627 | \def\rgbDarkRed{0.50 0.09 0.12} |
| 1628 | \def\rgbBlack{0 0 0} |
| 1629 | % |
| 1630 | \def\pdfsetcolor#1{\special{pdf:scolor [#1]}} |
| 1631 | % |
| 1632 | % Set color, and create a mark which defines \thiscolor accordingly, |
| 1633 | % so that \makeheadline knows which color to restore. |
| 1634 | \def\setcolor#1{% |
| 1635 | \xdef\currentcolordefs{\gdef\noexpand\thiscolor{#1}}% |
| 1636 | \domark |
| 1637 | \pdfsetcolor{#1}% |
| 1638 | } |
| 1639 | % |
| 1640 | \def\maincolor{\rgbBlack} |
| 1641 | \pdfsetcolor{\maincolor} |
| 1642 | \edef\thiscolor{\maincolor} |
| 1643 | \def\currentcolordefs{} |
| 1644 | % |
| 1645 | \def\makefootline{% |
| 1646 | \baselineskip24pt |
| 1647 | \line{\pdfsetcolor{\maincolor}\the\footline}% |
| 1648 | } |
| 1649 | % |
| 1650 | \def\makeheadline{% |
| 1651 | \vbox to 0pt{% |
| 1652 | \vskip-22.5pt |
| 1653 | \line{% |
| 1654 | \vbox to8.5pt{}% |
| 1655 | % Extract \thiscolor definition from the marks. |
| 1656 | \getcolormarks |
| 1657 | % Typeset the headline with \maincolor, then restore the color. |
| 1658 | \pdfsetcolor{\maincolor}\the\headline\pdfsetcolor{\thiscolor}% |
| 1659 | }% |
| 1660 | \vss |
| 1661 | }% |
| 1662 | \nointerlineskip |
| 1663 | } |
| 1664 | % |
| 1665 | % PDF outline support |
| 1666 | % |
| 1667 | % Emulate pdfTeX primitive |
| 1668 | \def\pdfdest name#1 xyz{% |
| 1669 | \special{pdf:dest (#1) [@thispage /XYZ @xpos @ypos null]}% |
| 1670 | } |
| 1671 | % |
| 1672 | \def\setpdfdestname#1{{% |
| 1673 | % We have to set dummies so commands such as @code, and characters |
| 1674 | % such as \, aren't expanded when present in a section title. |
| 1675 | \indexnofonts |
| 1676 | \makevalueexpandable |
| 1677 | \turnoffactive |
| 1678 | \iftxiuseunicodedestname |
| 1679 | % Pass through Unicode characters. |
| 1680 | \else |
| 1681 | % Use ASCII approximations in destination names. |
| 1682 | \passthroughcharsfalse |
| 1683 | \fi |
| 1684 | \def\pdfdestname{#1}% |
| 1685 | \txiescapepdf\pdfdestname |
| 1686 | }} |
| 1687 | % |
| 1688 | \def\setpdfoutlinetext#1{{% |
| 1689 | \turnoffactive |
| 1690 | % Always use Unicode characters in title texts. |
| 1691 | \def\pdfoutlinetext{#1}% |
| 1692 | % For XeTeX, xdvipdfmx converts to UTF-16. |
| 1693 | % So we do not convert. |
| 1694 | \txiescapepdf\pdfoutlinetext |
| 1695 | }} |
| 1696 | % |
| 1697 | \def\pdfmkdest#1{% |
| 1698 | \setpdfdestname{#1}% |
| 1699 | \safewhatsit{\pdfdest name{\pdfdestname} xyz}% |
| 1700 | } |
| 1701 | % |
| 1702 | % by default, use black for everything. |
| 1703 | \def\urlcolor{\rgbBlack} |
| 1704 | \def\linkcolor{\rgbBlack} |
| 1705 | \def\endlink{\setcolor{\maincolor}\pdfendlink} |
| 1706 | % |
| 1707 | \def\dopdfoutline#1#2#3#4{% |
| 1708 | \setpdfoutlinetext{#1} |
| 1709 | \setpdfdestname{#3} |
| 1710 | \ifx\pdfdestname\empty |
| 1711 | \def\pdfdestname{#4}% |
| 1712 | \fi |
| 1713 | % |
| 1714 | \special{pdf:out [-] #2 << /Title (\pdfoutlinetext) /A |
| 1715 | << /S /GoTo /D (\pdfdestname) >> >> }% |
| 1716 | } |
| 1717 | % |
| 1718 | \def\pdfmakeoutlines{% |
| 1719 | \begingroup |
| 1720 | % |
| 1721 | % For XeTeX, counts of subentries are not necessary. |
| 1722 | % Therefore, we read toc only once. |
| 1723 | % |
| 1724 | % We use node names as destinations. |
| 1725 | % |
| 1726 | % Currently we prefix the section name with the section number |
| 1727 | % for chapter and appendix headings only in order to avoid too much |
| 1728 | % horizontal space being required in the PDF viewer. |
| 1729 | \def\partentry##1##2##3##4{}% ignore parts in the outlines |
| 1730 | \def\numchapentry##1##2##3##4{% |
| 1731 | \dopdfoutline{##2 ##1}{1}{##3}{##4}}% |
| 1732 | \def\numsecentry##1##2##3##4{% |
| 1733 | \dopdfoutline{##1}{2}{##3}{##4}}% |
| 1734 | \def\numsubsecentry##1##2##3##4{% |
| 1735 | \dopdfoutline{##1}{3}{##3}{##4}}% |
| 1736 | \def\numsubsubsecentry##1##2##3##4{% |
| 1737 | \dopdfoutline{##1}{4}{##3}{##4}}% |
| 1738 | % |
| 1739 | \let\appentry\numchapentry% |
| 1740 | \let\appsecentry\numsecentry% |
| 1741 | \let\appsubsecentry\numsubsecentry% |
| 1742 | \let\appsubsubsecentry\numsubsubsecentry% |
| 1743 | \def\unnchapentry##1##2##3##4{% |
| 1744 | \dopdfoutline{##1}{1}{##3}{##4}}% |
| 1745 | \let\unnsecentry\numsecentry% |
| 1746 | \let\unnsubsecentry\numsubsecentry% |
| 1747 | \let\unnsubsubsecentry\numsubsubsecentry% |
| 1748 | % |
| 1749 | % For XeTeX, xdvipdfmx converts strings to UTF-16. |
| 1750 | % Therefore, the encoding and the language may not be considered. |
| 1751 | % |
| 1752 | \indexnofonts |
| 1753 | \setupdatafile |
| 1754 | % We can have normal brace characters in the PDF outlines, unlike |
| 1755 | % Texinfo index files. So set that up. |
| 1756 | \def\{{\lbracecharliteral}% |
| 1757 | \def\}{\rbracecharliteral}% |
| 1758 | \catcode`\\=\active \otherbackslash |
| 1759 | \input \tocreadfilename |
| 1760 | \endgroup |
| 1761 | } |
| 1762 | {\catcode`[=1 \catcode`]=2 |
| 1763 | \catcode`{=\other \catcode`}=\other |
| 1764 | \gdef\lbracecharliteral[{]% |
| 1765 | \gdef\rbracecharliteral[}]% |
| 1766 | ] |
| 1767 | |
| 1768 | \special{pdf:docview << /PageMode /UseOutlines >> } |
| 1769 | % ``\special{pdf:tounicode ...}'' is not necessary |
| 1770 | % because xdvipdfmx converts strings from UTF-8 to UTF-16 without it. |
| 1771 | % However, due to a UTF-16 conversion issue of xdvipdfmx 20150315, |
| 1772 | % ``\special{pdf:dest ...}'' cannot handle non-ASCII strings. |
| 1773 | % It is fixed by xdvipdfmx 20160106 (TeX Live SVN r39753). |
| 1774 | % |
| 1775 | \def\skipspaces#1{\def\PP{#1}\def\D{|}% |
| 1776 | \ifx\PP\D\let\nextsp\relax |
| 1777 | \else\let\nextsp\skipspaces |
| 1778 | \addtokens{\filename}{\PP}% |
| 1779 | \advance\filenamelength by 1 |
| 1780 | \fi |
| 1781 | \nextsp} |
| 1782 | \def\getfilename#1{% |
| 1783 | \filenamelength=0 |
| 1784 | % If we don't expand the argument now, \skipspaces will get |
| 1785 | % snagged on things like "@value{foo}". |
| 1786 | \edef\temp{#1}% |
| 1787 | \expandafter\skipspaces\temp|\relax |
| 1788 | } |
| 1789 | % make a live url in pdf output. |
| 1790 | \def\pdfurl#1{% |
| 1791 | \begingroup |
| 1792 | % it seems we really need yet another set of dummies; have not |
| 1793 | % tried to figure out what each command should do in the context |
| 1794 | % of @url. for now, just make @/ a no-op, that's the only one |
| 1795 | % people have actually reported a problem with. |
| 1796 | % |
| 1797 | \normalturnoffactive |
| 1798 | \def\@{@}% |
| 1799 | \let\/=\empty |
| 1800 | \makevalueexpandable |
| 1801 | % do we want to go so far as to use \indexnofonts instead of just |
| 1802 | % special-casing \var here? |
| 1803 | \def\var##1{##1}% |
| 1804 | % |
| 1805 | \leavevmode\setcolor{\urlcolor}% |
| 1806 | \special{pdf:bann << /Border [0 0 0] |
| 1807 | /Subtype /Link /A << /S /URI /URI (#1) >> >>}% |
| 1808 | \endgroup} |
| 1809 | \def\endlink{\setcolor{\maincolor}\special{pdf:eann}} |
| 1810 | \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}} |
| 1811 | \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks} |
| 1812 | \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks} |
| 1813 | \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}} |
| 1814 | \def\maketoks{% |
| 1815 | \expandafter\poptoks\the\toksA|ENDTOKS|\relax |
| 1816 | \ifx\first0\adn0 |
| 1817 | \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3 |
| 1818 | \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6 |
| 1819 | \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9 |
| 1820 | \else |
| 1821 | \ifnum0=\countA\else\makelink\fi |
| 1822 | \ifx\first.\let\next=\done\else |
| 1823 | \let\next=\maketoks |
| 1824 | \addtokens{\toksB}{\the\toksD} |
| 1825 | \ifx\first,\addtokens{\toksB}{\space}\fi |
| 1826 | \fi |
| 1827 | \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi |
| 1828 | \next} |
| 1829 | \def\makelink{\addtokens{\toksB}% |
| 1830 | {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0} |
| 1831 | \def\pdflink#1{% |
| 1832 | \special{pdf:bann << /Border [0 0 0] |
| 1833 | /Type /Annot /Subtype /Link /A << /S /GoTo /D (#1) >> >>}% |
| 1834 | \setcolor{\linkcolor}#1\endlink} |
| 1835 | \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st} |
| 1836 | % |
| 1837 | % |
| 1838 | % @image support |
| 1839 | % |
| 1840 | % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto). |
| 1841 | \def\doxeteximage#1#2#3{% |
| 1842 | \def\xeteximagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}% |
| 1843 | \def\xeteximageheight{#3}\setbox2 = \hbox{\ignorespaces #3}% |
| 1844 | % |
| 1845 | % XeTeX (and the PDF format) supports .pdf, .png, .jpg (among |
| 1846 | % others). Let's try in that order, PDF first since if |
| 1847 | % someone has a scalable image, presumably better to use that than a |
| 1848 | % bitmap. |
| 1849 | \let\xeteximgext=\empty |
| 1850 | \begingroup |
| 1851 | \openin 1 #1.pdf \ifeof 1 |
| 1852 | \openin 1 #1.PDF \ifeof 1 |
| 1853 | \openin 1 #1.png \ifeof 1 |
| 1854 | \openin 1 #1.jpg \ifeof 1 |
| 1855 | \openin 1 #1.jpeg \ifeof 1 |
| 1856 | \openin 1 #1.JPG \ifeof 1 |
| 1857 | \errmessage{Could not find image file #1 for XeTeX}% |
| 1858 | \else \gdef\xeteximgext{JPG}% |
| 1859 | \fi |
| 1860 | \else \gdef\xeteximgext{jpeg}% |
| 1861 | \fi |
| 1862 | \else \gdef\xeteximgext{jpg}% |
| 1863 | \fi |
| 1864 | \else \gdef\xeteximgext{png}% |
| 1865 | \fi |
| 1866 | \else \gdef\xeteximgext{PDF}% |
| 1867 | \fi |
| 1868 | \else \gdef\xeteximgext{pdf}% |
| 1869 | \fi |
| 1870 | \closein 1 |
| 1871 | \endgroup |
| 1872 | % |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 1873 | % Putting an \hbox around the image can prevent an over-long line |
| 1874 | % after the image. |
| 1875 | \hbox\bgroup |
| 1876 | \def\xetexpdfext{pdf}% |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 1877 | \ifx\xeteximgext\xetexpdfext |
| 1878 | \XeTeXpdffile "#1".\xeteximgext "" |
| 1879 | \else |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 1880 | \def\xetexpdfext{PDF}% |
| 1881 | \ifx\xeteximgext\xetexpdfext |
| 1882 | \XeTeXpdffile "#1".\xeteximgext "" |
| 1883 | \else |
| 1884 | \XeTeXpicfile "#1".\xeteximgext "" |
| 1885 | \fi |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 1886 | \fi |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 1887 | \ifdim \wd0 >0pt width \xeteximagewidth \fi |
| 1888 | \ifdim \wd2 >0pt height \xeteximageheight \fi \relax |
| 1889 | \egroup |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 1890 | } |
| 1891 | \fi |
| 1892 | |
| 1893 | |
| 1894 | % |
| 1895 | \message{fonts,} |
| 1896 | |
| 1897 | % Set the baselineskip to #1, and the lineskip and strut size |
| 1898 | % correspondingly. There is no deep meaning behind these magic numbers |
| 1899 | % used as factors; they just match (closely enough) what Knuth defined. |
| 1900 | % |
| 1901 | \def\lineskipfactor{.08333} |
| 1902 | \def\strutheightpercent{.70833} |
| 1903 | \def\strutdepthpercent {.29167} |
| 1904 | % |
| 1905 | % can get a sort of poor man's double spacing by redefining this. |
| 1906 | \def\baselinefactor{1} |
| 1907 | % |
| 1908 | \newdimen\textleading |
| 1909 | \def\setleading#1{% |
| 1910 | \dimen0 = #1\relax |
| 1911 | \normalbaselineskip = \baselinefactor\dimen0 |
| 1912 | \normallineskip = \lineskipfactor\normalbaselineskip |
| 1913 | \normalbaselines |
| 1914 | \setbox\strutbox =\hbox{% |
| 1915 | \vrule width0pt height\strutheightpercent\baselineskip |
| 1916 | depth \strutdepthpercent \baselineskip |
| 1917 | }% |
| 1918 | } |
| 1919 | |
| 1920 | % PDF CMaps. See also LaTeX's t1.cmap. |
| 1921 | % |
| 1922 | % do nothing with this by default. |
| 1923 | \expandafter\let\csname cmapOT1\endcsname\gobble |
| 1924 | \expandafter\let\csname cmapOT1IT\endcsname\gobble |
| 1925 | \expandafter\let\csname cmapOT1TT\endcsname\gobble |
| 1926 | |
| 1927 | % if we are producing pdf, and we have \pdffontattr, then define cmaps. |
| 1928 | % (\pdffontattr was introduced many years ago, but people still run |
| 1929 | % older pdftex's; it's easy to conditionalize, so we do.) |
| 1930 | \ifpdf \ifx\pdffontattr\thisisundefined \else |
| 1931 | \begingroup |
| 1932 | \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char. |
| 1933 | \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap |
| 1934 | %%DocumentNeededResources: ProcSet (CIDInit) |
| 1935 | %%IncludeResource: ProcSet (CIDInit) |
| 1936 | %%BeginResource: CMap (TeX-OT1-0) |
| 1937 | %%Title: (TeX-OT1-0 TeX OT1 0) |
| 1938 | %%Version: 1.000 |
| 1939 | %%EndComments |
| 1940 | /CIDInit /ProcSet findresource begin |
| 1941 | 12 dict begin |
| 1942 | begincmap |
| 1943 | /CIDSystemInfo |
| 1944 | << /Registry (TeX) |
| 1945 | /Ordering (OT1) |
| 1946 | /Supplement 0 |
| 1947 | >> def |
| 1948 | /CMapName /TeX-OT1-0 def |
| 1949 | /CMapType 2 def |
| 1950 | 1 begincodespacerange |
| 1951 | <00> <7F> |
| 1952 | endcodespacerange |
| 1953 | 8 beginbfrange |
| 1954 | <00> <01> <0393> |
| 1955 | <09> <0A> <03A8> |
| 1956 | <23> <26> <0023> |
| 1957 | <28> <3B> <0028> |
| 1958 | <3F> <5B> <003F> |
| 1959 | <5D> <5E> <005D> |
| 1960 | <61> <7A> <0061> |
| 1961 | <7B> <7C> <2013> |
| 1962 | endbfrange |
| 1963 | 40 beginbfchar |
| 1964 | <02> <0398> |
| 1965 | <03> <039B> |
| 1966 | <04> <039E> |
| 1967 | <05> <03A0> |
| 1968 | <06> <03A3> |
| 1969 | <07> <03D2> |
| 1970 | <08> <03A6> |
| 1971 | <0B> <00660066> |
| 1972 | <0C> <00660069> |
| 1973 | <0D> <0066006C> |
| 1974 | <0E> <006600660069> |
| 1975 | <0F> <00660066006C> |
| 1976 | <10> <0131> |
| 1977 | <11> <0237> |
| 1978 | <12> <0060> |
| 1979 | <13> <00B4> |
| 1980 | <14> <02C7> |
| 1981 | <15> <02D8> |
| 1982 | <16> <00AF> |
| 1983 | <17> <02DA> |
| 1984 | <18> <00B8> |
| 1985 | <19> <00DF> |
| 1986 | <1A> <00E6> |
| 1987 | <1B> <0153> |
| 1988 | <1C> <00F8> |
| 1989 | <1D> <00C6> |
| 1990 | <1E> <0152> |
| 1991 | <1F> <00D8> |
| 1992 | <21> <0021> |
| 1993 | <22> <201D> |
| 1994 | <27> <2019> |
| 1995 | <3C> <00A1> |
| 1996 | <3D> <003D> |
| 1997 | <3E> <00BF> |
| 1998 | <5C> <201C> |
| 1999 | <5F> <02D9> |
| 2000 | <60> <2018> |
| 2001 | <7D> <02DD> |
| 2002 | <7E> <007E> |
| 2003 | <7F> <00A8> |
| 2004 | endbfchar |
| 2005 | endcmap |
| 2006 | CMapName currentdict /CMap defineresource pop |
| 2007 | end |
| 2008 | end |
| 2009 | %%EndResource |
| 2010 | %%EOF |
| 2011 | }\endgroup |
| 2012 | \expandafter\edef\csname cmapOT1\endcsname#1{% |
| 2013 | \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}% |
| 2014 | }% |
| 2015 | % |
| 2016 | % \cmapOT1IT |
| 2017 | \begingroup |
| 2018 | \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char. |
| 2019 | \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap |
| 2020 | %%DocumentNeededResources: ProcSet (CIDInit) |
| 2021 | %%IncludeResource: ProcSet (CIDInit) |
| 2022 | %%BeginResource: CMap (TeX-OT1IT-0) |
| 2023 | %%Title: (TeX-OT1IT-0 TeX OT1IT 0) |
| 2024 | %%Version: 1.000 |
| 2025 | %%EndComments |
| 2026 | /CIDInit /ProcSet findresource begin |
| 2027 | 12 dict begin |
| 2028 | begincmap |
| 2029 | /CIDSystemInfo |
| 2030 | << /Registry (TeX) |
| 2031 | /Ordering (OT1IT) |
| 2032 | /Supplement 0 |
| 2033 | >> def |
| 2034 | /CMapName /TeX-OT1IT-0 def |
| 2035 | /CMapType 2 def |
| 2036 | 1 begincodespacerange |
| 2037 | <00> <7F> |
| 2038 | endcodespacerange |
| 2039 | 8 beginbfrange |
| 2040 | <00> <01> <0393> |
| 2041 | <09> <0A> <03A8> |
| 2042 | <25> <26> <0025> |
| 2043 | <28> <3B> <0028> |
| 2044 | <3F> <5B> <003F> |
| 2045 | <5D> <5E> <005D> |
| 2046 | <61> <7A> <0061> |
| 2047 | <7B> <7C> <2013> |
| 2048 | endbfrange |
| 2049 | 42 beginbfchar |
| 2050 | <02> <0398> |
| 2051 | <03> <039B> |
| 2052 | <04> <039E> |
| 2053 | <05> <03A0> |
| 2054 | <06> <03A3> |
| 2055 | <07> <03D2> |
| 2056 | <08> <03A6> |
| 2057 | <0B> <00660066> |
| 2058 | <0C> <00660069> |
| 2059 | <0D> <0066006C> |
| 2060 | <0E> <006600660069> |
| 2061 | <0F> <00660066006C> |
| 2062 | <10> <0131> |
| 2063 | <11> <0237> |
| 2064 | <12> <0060> |
| 2065 | <13> <00B4> |
| 2066 | <14> <02C7> |
| 2067 | <15> <02D8> |
| 2068 | <16> <00AF> |
| 2069 | <17> <02DA> |
| 2070 | <18> <00B8> |
| 2071 | <19> <00DF> |
| 2072 | <1A> <00E6> |
| 2073 | <1B> <0153> |
| 2074 | <1C> <00F8> |
| 2075 | <1D> <00C6> |
| 2076 | <1E> <0152> |
| 2077 | <1F> <00D8> |
| 2078 | <21> <0021> |
| 2079 | <22> <201D> |
| 2080 | <23> <0023> |
| 2081 | <24> <00A3> |
| 2082 | <27> <2019> |
| 2083 | <3C> <00A1> |
| 2084 | <3D> <003D> |
| 2085 | <3E> <00BF> |
| 2086 | <5C> <201C> |
| 2087 | <5F> <02D9> |
| 2088 | <60> <2018> |
| 2089 | <7D> <02DD> |
| 2090 | <7E> <007E> |
| 2091 | <7F> <00A8> |
| 2092 | endbfchar |
| 2093 | endcmap |
| 2094 | CMapName currentdict /CMap defineresource pop |
| 2095 | end |
| 2096 | end |
| 2097 | %%EndResource |
| 2098 | %%EOF |
| 2099 | }\endgroup |
| 2100 | \expandafter\edef\csname cmapOT1IT\endcsname#1{% |
| 2101 | \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}% |
| 2102 | }% |
| 2103 | % |
| 2104 | % \cmapOT1TT |
| 2105 | \begingroup |
| 2106 | \catcode`\^^M=\active \def^^M{^^J}% Output line endings as the ^^J char. |
| 2107 | \catcode`\%=12 \immediate\pdfobj stream {%!PS-Adobe-3.0 Resource-CMap |
| 2108 | %%DocumentNeededResources: ProcSet (CIDInit) |
| 2109 | %%IncludeResource: ProcSet (CIDInit) |
| 2110 | %%BeginResource: CMap (TeX-OT1TT-0) |
| 2111 | %%Title: (TeX-OT1TT-0 TeX OT1TT 0) |
| 2112 | %%Version: 1.000 |
| 2113 | %%EndComments |
| 2114 | /CIDInit /ProcSet findresource begin |
| 2115 | 12 dict begin |
| 2116 | begincmap |
| 2117 | /CIDSystemInfo |
| 2118 | << /Registry (TeX) |
| 2119 | /Ordering (OT1TT) |
| 2120 | /Supplement 0 |
| 2121 | >> def |
| 2122 | /CMapName /TeX-OT1TT-0 def |
| 2123 | /CMapType 2 def |
| 2124 | 1 begincodespacerange |
| 2125 | <00> <7F> |
| 2126 | endcodespacerange |
| 2127 | 5 beginbfrange |
| 2128 | <00> <01> <0393> |
| 2129 | <09> <0A> <03A8> |
| 2130 | <21> <26> <0021> |
| 2131 | <28> <5F> <0028> |
| 2132 | <61> <7E> <0061> |
| 2133 | endbfrange |
| 2134 | 32 beginbfchar |
| 2135 | <02> <0398> |
| 2136 | <03> <039B> |
| 2137 | <04> <039E> |
| 2138 | <05> <03A0> |
| 2139 | <06> <03A3> |
| 2140 | <07> <03D2> |
| 2141 | <08> <03A6> |
| 2142 | <0B> <2191> |
| 2143 | <0C> <2193> |
| 2144 | <0D> <0027> |
| 2145 | <0E> <00A1> |
| 2146 | <0F> <00BF> |
| 2147 | <10> <0131> |
| 2148 | <11> <0237> |
| 2149 | <12> <0060> |
| 2150 | <13> <00B4> |
| 2151 | <14> <02C7> |
| 2152 | <15> <02D8> |
| 2153 | <16> <00AF> |
| 2154 | <17> <02DA> |
| 2155 | <18> <00B8> |
| 2156 | <19> <00DF> |
| 2157 | <1A> <00E6> |
| 2158 | <1B> <0153> |
| 2159 | <1C> <00F8> |
| 2160 | <1D> <00C6> |
| 2161 | <1E> <0152> |
| 2162 | <1F> <00D8> |
| 2163 | <20> <2423> |
| 2164 | <27> <2019> |
| 2165 | <60> <2018> |
| 2166 | <7F> <00A8> |
| 2167 | endbfchar |
| 2168 | endcmap |
| 2169 | CMapName currentdict /CMap defineresource pop |
| 2170 | end |
| 2171 | end |
| 2172 | %%EndResource |
| 2173 | %%EOF |
| 2174 | }\endgroup |
| 2175 | \expandafter\edef\csname cmapOT1TT\endcsname#1{% |
| 2176 | \pdffontattr#1{/ToUnicode \the\pdflastobj\space 0 R}% |
| 2177 | }% |
| 2178 | \fi\fi |
| 2179 | |
| 2180 | |
| 2181 | % Set the font macro #1 to the font named \fontprefix#2. |
| 2182 | % #3 is the font's design size, #4 is a scale factor, #5 is the CMap |
| 2183 | % encoding (only OT1, OT1IT and OT1TT are allowed, or empty to omit). |
| 2184 | % Example: |
| 2185 | % #1 = \textrm |
| 2186 | % #2 = \rmshape |
| 2187 | % #3 = 10 |
| 2188 | % #4 = \mainmagstep |
| 2189 | % #5 = OT1 |
| 2190 | % |
| 2191 | \def\setfont#1#2#3#4#5{% |
| 2192 | \font#1=\fontprefix#2#3 scaled #4 |
| 2193 | \csname cmap#5\endcsname#1% |
| 2194 | } |
| 2195 | % This is what gets called when #5 of \setfont is empty. |
| 2196 | \let\cmap\gobble |
| 2197 | % |
| 2198 | % (end of cmaps) |
| 2199 | |
| 2200 | % Use cm as the default font prefix. |
| 2201 | % To specify the font prefix, you must define \fontprefix |
| 2202 | % before you read in texinfo.tex. |
| 2203 | \ifx\fontprefix\thisisundefined |
| 2204 | \def\fontprefix{cm} |
| 2205 | \fi |
| 2206 | % Support font families that don't use the same naming scheme as CM. |
| 2207 | \def\rmshape{r} |
| 2208 | \def\rmbshape{bx} % where the normal face is bold |
| 2209 | \def\bfshape{b} |
| 2210 | \def\bxshape{bx} |
| 2211 | \def\ttshape{tt} |
| 2212 | \def\ttbshape{tt} |
| 2213 | \def\ttslshape{sltt} |
| 2214 | \def\itshape{ti} |
| 2215 | \def\itbshape{bxti} |
| 2216 | \def\slshape{sl} |
| 2217 | \def\slbshape{bxsl} |
| 2218 | \def\sfshape{ss} |
| 2219 | \def\sfbshape{ss} |
| 2220 | \def\scshape{csc} |
| 2221 | \def\scbshape{csc} |
| 2222 | |
| 2223 | % Definitions for a main text size of 11pt. (The default in Texinfo.) |
| 2224 | % |
| 2225 | \def\definetextfontsizexi{% |
| 2226 | % Text fonts (11.2pt, magstep1). |
| 2227 | \def\textnominalsize{11pt} |
| 2228 | \edef\mainmagstep{\magstephalf} |
| 2229 | \setfont\textrm\rmshape{10}{\mainmagstep}{OT1} |
| 2230 | \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT} |
| 2231 | \setfont\textbf\bfshape{10}{\mainmagstep}{OT1} |
| 2232 | \setfont\textit\itshape{10}{\mainmagstep}{OT1IT} |
| 2233 | \setfont\textsl\slshape{10}{\mainmagstep}{OT1} |
| 2234 | \setfont\textsf\sfshape{10}{\mainmagstep}{OT1} |
| 2235 | \setfont\textsc\scshape{10}{\mainmagstep}{OT1} |
| 2236 | \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT} |
| 2237 | \font\texti=cmmi10 scaled \mainmagstep |
| 2238 | \font\textsy=cmsy10 scaled \mainmagstep |
| 2239 | \def\textecsize{1095} |
| 2240 | |
| 2241 | % A few fonts for @defun names and args. |
| 2242 | \setfont\defbf\bfshape{10}{\magstep1}{OT1} |
| 2243 | \setfont\deftt\ttshape{10}{\magstep1}{OT1TT} |
| 2244 | \setfont\defsl\slshape{10}{\magstep1}{OT1} |
| 2245 | \setfont\defttsl\ttslshape{10}{\magstep1}{OT1TT} |
| 2246 | \def\df{\let\ttfont=\deftt \let\bffont = \defbf |
| 2247 | \let\ttslfont=\defttsl \let\slfont=\defsl \bf} |
| 2248 | |
| 2249 | % Fonts for indices, footnotes, small examples (9pt). |
| 2250 | \def\smallnominalsize{9pt} |
| 2251 | \setfont\smallrm\rmshape{9}{1000}{OT1} |
| 2252 | \setfont\smalltt\ttshape{9}{1000}{OT1TT} |
| 2253 | \setfont\smallbf\bfshape{10}{900}{OT1} |
| 2254 | \setfont\smallit\itshape{9}{1000}{OT1IT} |
| 2255 | \setfont\smallsl\slshape{9}{1000}{OT1} |
| 2256 | \setfont\smallsf\sfshape{9}{1000}{OT1} |
| 2257 | \setfont\smallsc\scshape{10}{900}{OT1} |
| 2258 | \setfont\smallttsl\ttslshape{10}{900}{OT1TT} |
| 2259 | \font\smalli=cmmi9 |
| 2260 | \font\smallsy=cmsy9 |
| 2261 | \def\smallecsize{0900} |
| 2262 | |
| 2263 | % Fonts for small examples (8pt). |
| 2264 | \def\smallernominalsize{8pt} |
| 2265 | \setfont\smallerrm\rmshape{8}{1000}{OT1} |
| 2266 | \setfont\smallertt\ttshape{8}{1000}{OT1TT} |
| 2267 | \setfont\smallerbf\bfshape{10}{800}{OT1} |
| 2268 | \setfont\smallerit\itshape{8}{1000}{OT1IT} |
| 2269 | \setfont\smallersl\slshape{8}{1000}{OT1} |
| 2270 | \setfont\smallersf\sfshape{8}{1000}{OT1} |
| 2271 | \setfont\smallersc\scshape{10}{800}{OT1} |
| 2272 | \setfont\smallerttsl\ttslshape{10}{800}{OT1TT} |
| 2273 | \font\smalleri=cmmi8 |
| 2274 | \font\smallersy=cmsy8 |
| 2275 | \def\smallerecsize{0800} |
| 2276 | |
| 2277 | % Fonts for math mode superscripts (7pt). |
| 2278 | \def\sevennominalsize{7pt} |
| 2279 | \setfont\sevenrm\rmshape{7}{1000}{OT1} |
| 2280 | \setfont\seventt\ttshape{10}{700}{OT1TT} |
| 2281 | \setfont\sevenbf\bfshape{10}{700}{OT1} |
| 2282 | \setfont\sevenit\itshape{7}{1000}{OT1IT} |
| 2283 | \setfont\sevensl\slshape{10}{700}{OT1} |
| 2284 | \setfont\sevensf\sfshape{10}{700}{OT1} |
| 2285 | \setfont\sevensc\scshape{10}{700}{OT1} |
| 2286 | \setfont\seventtsl\ttslshape{10}{700}{OT1TT} |
| 2287 | \font\seveni=cmmi7 |
| 2288 | \font\sevensy=cmsy7 |
| 2289 | \def\sevenecsize{0700} |
| 2290 | |
| 2291 | % Fonts for title page (20.4pt): |
| 2292 | \def\titlenominalsize{20pt} |
| 2293 | \setfont\titlerm\rmbshape{12}{\magstep3}{OT1} |
| 2294 | \setfont\titleit\itbshape{10}{\magstep4}{OT1IT} |
| 2295 | \setfont\titlesl\slbshape{10}{\magstep4}{OT1} |
| 2296 | \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT} |
| 2297 | \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT} |
| 2298 | \setfont\titlesf\sfbshape{17}{\magstep1}{OT1} |
| 2299 | \let\titlebf=\titlerm |
| 2300 | \setfont\titlesc\scbshape{10}{\magstep4}{OT1} |
| 2301 | \font\titlei=cmmi12 scaled \magstep3 |
| 2302 | \font\titlesy=cmsy10 scaled \magstep4 |
| 2303 | \def\titleecsize{2074} |
| 2304 | |
| 2305 | % Chapter (and unnumbered) fonts (17.28pt). |
| 2306 | \def\chapnominalsize{17pt} |
| 2307 | \setfont\chaprm\rmbshape{12}{\magstep2}{OT1} |
| 2308 | \setfont\chapit\itbshape{10}{\magstep3}{OT1IT} |
| 2309 | \setfont\chapsl\slbshape{10}{\magstep3}{OT1} |
| 2310 | \setfont\chaptt\ttbshape{12}{\magstep2}{OT1TT} |
| 2311 | \setfont\chapttsl\ttslshape{10}{\magstep3}{OT1TT} |
| 2312 | \setfont\chapsf\sfbshape{17}{1000}{OT1} |
| 2313 | \let\chapbf=\chaprm |
| 2314 | \setfont\chapsc\scbshape{10}{\magstep3}{OT1} |
| 2315 | \font\chapi=cmmi12 scaled \magstep2 |
| 2316 | \font\chapsy=cmsy10 scaled \magstep3 |
| 2317 | \def\chapecsize{1728} |
| 2318 | |
| 2319 | % Section fonts (14.4pt). |
| 2320 | \def\secnominalsize{14pt} |
| 2321 | \setfont\secrm\rmbshape{12}{\magstep1}{OT1} |
| 2322 | \setfont\secrmnotbold\rmshape{12}{\magstep1}{OT1} |
| 2323 | \setfont\secit\itbshape{10}{\magstep2}{OT1IT} |
| 2324 | \setfont\secsl\slbshape{10}{\magstep2}{OT1} |
| 2325 | \setfont\sectt\ttbshape{12}{\magstep1}{OT1TT} |
| 2326 | \setfont\secttsl\ttslshape{10}{\magstep2}{OT1TT} |
| 2327 | \setfont\secsf\sfbshape{12}{\magstep1}{OT1} |
| 2328 | \let\secbf\secrm |
| 2329 | \setfont\secsc\scbshape{10}{\magstep2}{OT1} |
| 2330 | \font\seci=cmmi12 scaled \magstep1 |
| 2331 | \font\secsy=cmsy10 scaled \magstep2 |
| 2332 | \def\sececsize{1440} |
| 2333 | |
| 2334 | % Subsection fonts (13.15pt). |
| 2335 | \def\ssecnominalsize{13pt} |
| 2336 | \setfont\ssecrm\rmbshape{12}{\magstephalf}{OT1} |
| 2337 | \setfont\ssecit\itbshape{10}{1315}{OT1IT} |
| 2338 | \setfont\ssecsl\slbshape{10}{1315}{OT1} |
| 2339 | \setfont\ssectt\ttbshape{12}{\magstephalf}{OT1TT} |
| 2340 | \setfont\ssecttsl\ttslshape{10}{1315}{OT1TT} |
| 2341 | \setfont\ssecsf\sfbshape{12}{\magstephalf}{OT1} |
| 2342 | \let\ssecbf\ssecrm |
| 2343 | \setfont\ssecsc\scbshape{10}{1315}{OT1} |
| 2344 | \font\sseci=cmmi12 scaled \magstephalf |
| 2345 | \font\ssecsy=cmsy10 scaled 1315 |
| 2346 | \def\ssececsize{1200} |
| 2347 | |
| 2348 | % Reduced fonts for @acronym in text (10pt). |
| 2349 | \def\reducednominalsize{10pt} |
| 2350 | \setfont\reducedrm\rmshape{10}{1000}{OT1} |
| 2351 | \setfont\reducedtt\ttshape{10}{1000}{OT1TT} |
| 2352 | \setfont\reducedbf\bfshape{10}{1000}{OT1} |
| 2353 | \setfont\reducedit\itshape{10}{1000}{OT1IT} |
| 2354 | \setfont\reducedsl\slshape{10}{1000}{OT1} |
| 2355 | \setfont\reducedsf\sfshape{10}{1000}{OT1} |
| 2356 | \setfont\reducedsc\scshape{10}{1000}{OT1} |
| 2357 | \setfont\reducedttsl\ttslshape{10}{1000}{OT1TT} |
| 2358 | \font\reducedi=cmmi10 |
| 2359 | \font\reducedsy=cmsy10 |
| 2360 | \def\reducedecsize{1000} |
| 2361 | |
| 2362 | \textleading = 13.2pt % line spacing for 11pt CM |
| 2363 | \textfonts % reset the current fonts |
| 2364 | \rm |
| 2365 | } % end of 11pt text font size definitions, \definetextfontsizexi |
| 2366 | |
| 2367 | |
| 2368 | % Definitions to make the main text be 10pt Computer Modern, with |
| 2369 | % section, chapter, etc., sizes following suit. This is for the GNU |
| 2370 | % Press printing of the Emacs 22 manual. Maybe other manuals in the |
| 2371 | % future. Used with @smallbook, which sets the leading to 12pt. |
| 2372 | % |
| 2373 | \def\definetextfontsizex{% |
| 2374 | % Text fonts (10pt). |
| 2375 | \def\textnominalsize{10pt} |
| 2376 | \edef\mainmagstep{1000} |
| 2377 | \setfont\textrm\rmshape{10}{\mainmagstep}{OT1} |
| 2378 | \setfont\texttt\ttshape{10}{\mainmagstep}{OT1TT} |
| 2379 | \setfont\textbf\bfshape{10}{\mainmagstep}{OT1} |
| 2380 | \setfont\textit\itshape{10}{\mainmagstep}{OT1IT} |
| 2381 | \setfont\textsl\slshape{10}{\mainmagstep}{OT1} |
| 2382 | \setfont\textsf\sfshape{10}{\mainmagstep}{OT1} |
| 2383 | \setfont\textsc\scshape{10}{\mainmagstep}{OT1} |
| 2384 | \setfont\textttsl\ttslshape{10}{\mainmagstep}{OT1TT} |
| 2385 | \font\texti=cmmi10 scaled \mainmagstep |
| 2386 | \font\textsy=cmsy10 scaled \mainmagstep |
| 2387 | \def\textecsize{1000} |
| 2388 | |
| 2389 | % A few fonts for @defun names and args. |
| 2390 | \setfont\defbf\bfshape{10}{\magstephalf}{OT1} |
| 2391 | \setfont\deftt\ttshape{10}{\magstephalf}{OT1TT} |
| 2392 | \setfont\defsl\slshape{10}{\magstephalf}{OT1} |
| 2393 | \setfont\defttsl\ttslshape{10}{\magstephalf}{OT1TT} |
| 2394 | \def\df{\let\ttfont=\deftt \let\bffont = \defbf |
| 2395 | \let\slfont=\defsl \let\ttslfont=\defttsl \bf} |
| 2396 | |
| 2397 | % Fonts for indices, footnotes, small examples (9pt). |
| 2398 | \def\smallnominalsize{9pt} |
| 2399 | \setfont\smallrm\rmshape{9}{1000}{OT1} |
| 2400 | \setfont\smalltt\ttshape{9}{1000}{OT1TT} |
| 2401 | \setfont\smallbf\bfshape{10}{900}{OT1} |
| 2402 | \setfont\smallit\itshape{9}{1000}{OT1IT} |
| 2403 | \setfont\smallsl\slshape{9}{1000}{OT1} |
| 2404 | \setfont\smallsf\sfshape{9}{1000}{OT1} |
| 2405 | \setfont\smallsc\scshape{10}{900}{OT1} |
| 2406 | \setfont\smallttsl\ttslshape{10}{900}{OT1TT} |
| 2407 | \font\smalli=cmmi9 |
| 2408 | \font\smallsy=cmsy9 |
| 2409 | \def\smallecsize{0900} |
| 2410 | |
| 2411 | % Fonts for small examples (8pt). |
| 2412 | \def\smallernominalsize{8pt} |
| 2413 | \setfont\smallerrm\rmshape{8}{1000}{OT1} |
| 2414 | \setfont\smallertt\ttshape{8}{1000}{OT1TT} |
| 2415 | \setfont\smallerbf\bfshape{10}{800}{OT1} |
| 2416 | \setfont\smallerit\itshape{8}{1000}{OT1IT} |
| 2417 | \setfont\smallersl\slshape{8}{1000}{OT1} |
| 2418 | \setfont\smallersf\sfshape{8}{1000}{OT1} |
| 2419 | \setfont\smallersc\scshape{10}{800}{OT1} |
| 2420 | \setfont\smallerttsl\ttslshape{10}{800}{OT1TT} |
| 2421 | \font\smalleri=cmmi8 |
| 2422 | \font\smallersy=cmsy8 |
| 2423 | \def\smallerecsize{0800} |
| 2424 | |
| 2425 | % Fonts for math mode superscripts (7pt). |
| 2426 | \def\sevennominalsize{7pt} |
| 2427 | \setfont\sevenrm\rmshape{7}{1000}{OT1} |
| 2428 | \setfont\seventt\ttshape{10}{700}{OT1TT} |
| 2429 | \setfont\sevenbf\bfshape{10}{700}{OT1} |
| 2430 | \setfont\sevenit\itshape{7}{1000}{OT1IT} |
| 2431 | \setfont\sevensl\slshape{10}{700}{OT1} |
| 2432 | \setfont\sevensf\sfshape{10}{700}{OT1} |
| 2433 | \setfont\sevensc\scshape{10}{700}{OT1} |
| 2434 | \setfont\seventtsl\ttslshape{10}{700}{OT1TT} |
| 2435 | \font\seveni=cmmi7 |
| 2436 | \font\sevensy=cmsy7 |
| 2437 | \def\sevenecsize{0700} |
| 2438 | |
| 2439 | % Fonts for title page (20.4pt): |
| 2440 | \def\titlenominalsize{20pt} |
| 2441 | \setfont\titlerm\rmbshape{12}{\magstep3}{OT1} |
| 2442 | \setfont\titleit\itbshape{10}{\magstep4}{OT1IT} |
| 2443 | \setfont\titlesl\slbshape{10}{\magstep4}{OT1} |
| 2444 | \setfont\titlett\ttbshape{12}{\magstep3}{OT1TT} |
| 2445 | \setfont\titlettsl\ttslshape{10}{\magstep4}{OT1TT} |
| 2446 | \setfont\titlesf\sfbshape{17}{\magstep1}{OT1} |
| 2447 | \let\titlebf=\titlerm |
| 2448 | \setfont\titlesc\scbshape{10}{\magstep4}{OT1} |
| 2449 | \font\titlei=cmmi12 scaled \magstep3 |
| 2450 | \font\titlesy=cmsy10 scaled \magstep4 |
| 2451 | \def\titleecsize{2074} |
| 2452 | |
| 2453 | % Chapter fonts (14.4pt). |
| 2454 | \def\chapnominalsize{14pt} |
| 2455 | \setfont\chaprm\rmbshape{12}{\magstep1}{OT1} |
| 2456 | \setfont\chapit\itbshape{10}{\magstep2}{OT1IT} |
| 2457 | \setfont\chapsl\slbshape{10}{\magstep2}{OT1} |
| 2458 | \setfont\chaptt\ttbshape{12}{\magstep1}{OT1TT} |
| 2459 | \setfont\chapttsl\ttslshape{10}{\magstep2}{OT1TT} |
| 2460 | \setfont\chapsf\sfbshape{12}{\magstep1}{OT1} |
| 2461 | \let\chapbf\chaprm |
| 2462 | \setfont\chapsc\scbshape{10}{\magstep2}{OT1} |
| 2463 | \font\chapi=cmmi12 scaled \magstep1 |
| 2464 | \font\chapsy=cmsy10 scaled \magstep2 |
| 2465 | \def\chapecsize{1440} |
| 2466 | |
| 2467 | % Section fonts (12pt). |
| 2468 | \def\secnominalsize{12pt} |
| 2469 | \setfont\secrm\rmbshape{12}{1000}{OT1} |
| 2470 | \setfont\secit\itbshape{10}{\magstep1}{OT1IT} |
| 2471 | \setfont\secsl\slbshape{10}{\magstep1}{OT1} |
| 2472 | \setfont\sectt\ttbshape{12}{1000}{OT1TT} |
| 2473 | \setfont\secttsl\ttslshape{10}{\magstep1}{OT1TT} |
| 2474 | \setfont\secsf\sfbshape{12}{1000}{OT1} |
| 2475 | \let\secbf\secrm |
| 2476 | \setfont\secsc\scbshape{10}{\magstep1}{OT1} |
| 2477 | \font\seci=cmmi12 |
| 2478 | \font\secsy=cmsy10 scaled \magstep1 |
| 2479 | \def\sececsize{1200} |
| 2480 | |
| 2481 | % Subsection fonts (10pt). |
| 2482 | \def\ssecnominalsize{10pt} |
| 2483 | \setfont\ssecrm\rmbshape{10}{1000}{OT1} |
| 2484 | \setfont\ssecit\itbshape{10}{1000}{OT1IT} |
| 2485 | \setfont\ssecsl\slbshape{10}{1000}{OT1} |
| 2486 | \setfont\ssectt\ttbshape{10}{1000}{OT1TT} |
| 2487 | \setfont\ssecttsl\ttslshape{10}{1000}{OT1TT} |
| 2488 | \setfont\ssecsf\sfbshape{10}{1000}{OT1} |
| 2489 | \let\ssecbf\ssecrm |
| 2490 | \setfont\ssecsc\scbshape{10}{1000}{OT1} |
| 2491 | \font\sseci=cmmi10 |
| 2492 | \font\ssecsy=cmsy10 |
| 2493 | \def\ssececsize{1000} |
| 2494 | |
| 2495 | % Reduced fonts for @acronym in text (9pt). |
| 2496 | \def\reducednominalsize{9pt} |
| 2497 | \setfont\reducedrm\rmshape{9}{1000}{OT1} |
| 2498 | \setfont\reducedtt\ttshape{9}{1000}{OT1TT} |
| 2499 | \setfont\reducedbf\bfshape{10}{900}{OT1} |
| 2500 | \setfont\reducedit\itshape{9}{1000}{OT1IT} |
| 2501 | \setfont\reducedsl\slshape{9}{1000}{OT1} |
| 2502 | \setfont\reducedsf\sfshape{9}{1000}{OT1} |
| 2503 | \setfont\reducedsc\scshape{10}{900}{OT1} |
| 2504 | \setfont\reducedttsl\ttslshape{10}{900}{OT1TT} |
| 2505 | \font\reducedi=cmmi9 |
| 2506 | \font\reducedsy=cmsy9 |
| 2507 | \def\reducedecsize{0900} |
| 2508 | |
| 2509 | \divide\parskip by 2 % reduce space between paragraphs |
| 2510 | \textleading = 12pt % line spacing for 10pt CM |
| 2511 | \textfonts % reset the current fonts |
| 2512 | \rm |
| 2513 | } % end of 10pt text font size definitions, \definetextfontsizex |
| 2514 | |
| 2515 | % Fonts for short table of contents. |
| 2516 | \setfont\shortcontrm\rmshape{12}{1000}{OT1} |
| 2517 | \setfont\shortcontbf\bfshape{10}{\magstep1}{OT1} % no cmb12 |
| 2518 | \setfont\shortcontsl\slshape{12}{1000}{OT1} |
| 2519 | \setfont\shortconttt\ttshape{12}{1000}{OT1TT} |
| 2520 | |
| 2521 | |
| 2522 | % We provide the user-level command |
| 2523 | % @fonttextsize 10 |
| 2524 | % (or 11) to redefine the text font size. pt is assumed. |
| 2525 | % |
| 2526 | \def\xiword{11} |
| 2527 | \def\xword{10} |
| 2528 | \def\xwordpt{10pt} |
| 2529 | % |
| 2530 | \parseargdef\fonttextsize{% |
| 2531 | \def\textsizearg{#1}% |
| 2532 | %\wlog{doing @fonttextsize \textsizearg}% |
| 2533 | % |
| 2534 | % Set \globaldefs so that documents can use this inside @tex, since |
| 2535 | % makeinfo 4.8 does not support it, but we need it nonetheless. |
| 2536 | % |
| 2537 | \begingroup \globaldefs=1 |
| 2538 | \ifx\textsizearg\xword \definetextfontsizex |
| 2539 | \else \ifx\textsizearg\xiword \definetextfontsizexi |
| 2540 | \else |
| 2541 | \errhelp=\EMsimple |
| 2542 | \errmessage{@fonttextsize only supports `10' or `11', not `\textsizearg'} |
| 2543 | \fi\fi |
| 2544 | \endgroup |
| 2545 | } |
| 2546 | |
| 2547 | % |
| 2548 | % Change the current font style to #1, remembering it in \curfontstyle. |
| 2549 | % For now, we do not accumulate font styles: @b{@i{foo}} prints foo in |
| 2550 | % italics, not bold italics. |
| 2551 | % |
| 2552 | \def\setfontstyle#1{% |
| 2553 | \def\curfontstyle{#1}% not as a control sequence, because we are \edef'd. |
| 2554 | \csname #1font\endcsname % change the current font |
| 2555 | } |
| 2556 | |
| 2557 | \def\rm{\fam=0 \setfontstyle{rm}} |
| 2558 | \def\it{\fam=\itfam \setfontstyle{it}} |
| 2559 | \def\sl{\fam=\slfam \setfontstyle{sl}} |
| 2560 | \def\bf{\fam=\bffam \setfontstyle{bf}}\def\bfstylename{bf} |
| 2561 | \def\tt{\fam=\ttfam \setfontstyle{tt}}\def\ttstylename{tt} |
| 2562 | |
| 2563 | % Texinfo sort of supports the sans serif font style, which plain TeX does not. |
| 2564 | % So we set up a \sf. |
| 2565 | \newfam\sffam |
| 2566 | \def\sf{\fam=\sffam \setfontstyle{sf}} |
| 2567 | |
| 2568 | % We don't need math for this font style. |
| 2569 | \def\ttsl{\setfontstyle{ttsl}} |
| 2570 | |
| 2571 | |
| 2572 | % In order for the font changes to affect most math symbols and letters, |
| 2573 | % we have to define the \textfont of the standard families. |
| 2574 | % We don't bother to reset \scriptscriptfont; awaiting user need. |
| 2575 | % |
| 2576 | \def\resetmathfonts{% |
| 2577 | \textfont0=\rmfont \textfont1=\ifont \textfont2=\syfont |
| 2578 | \textfont\itfam=\itfont \textfont\slfam=\slfont \textfont\bffam=\bffont |
| 2579 | \textfont\ttfam=\ttfont \textfont\sffam=\sffont |
| 2580 | % |
| 2581 | % Fonts for superscript. Note that the 7pt fonts are used regardless |
| 2582 | % of the current font size. |
| 2583 | \scriptfont0=\sevenrm \scriptfont1=\seveni \scriptfont2=\sevensy |
| 2584 | \scriptfont\itfam=\sevenit \scriptfont\slfam=\sevensl |
| 2585 | \scriptfont\bffam=\sevenbf \scriptfont\ttfam=\seventt |
| 2586 | \scriptfont\sffam=\sevensf |
| 2587 | } |
| 2588 | |
| 2589 | % |
| 2590 | |
| 2591 | % The font-changing commands (all called \...fonts) redefine the meanings |
| 2592 | % of \STYLEfont, instead of just \STYLE. We do this because \STYLE needs |
| 2593 | % to also set the current \fam for math mode. Our \STYLE (e.g., \rm) |
| 2594 | % commands hardwire \STYLEfont to set the current font. |
| 2595 | % |
| 2596 | % The fonts used for \ifont are for "math italics" (\itfont is for italics |
| 2597 | % in regular text). \syfont is also used in math mode only. |
| 2598 | % |
| 2599 | % Each font-changing command also sets the names \lsize (one size lower) |
| 2600 | % and \lllsize (three sizes lower). These relative commands are used |
| 2601 | % in, e.g., the LaTeX logo and acronyms. |
| 2602 | % |
| 2603 | % This all needs generalizing, badly. |
| 2604 | % |
| 2605 | |
| 2606 | \def\assignfonts#1{% |
| 2607 | \expandafter\let\expandafter\rmfont\csname #1rm\endcsname |
| 2608 | \expandafter\let\expandafter\itfont\csname #1it\endcsname |
| 2609 | \expandafter\let\expandafter\slfont\csname #1sl\endcsname |
| 2610 | \expandafter\let\expandafter\bffont\csname #1bf\endcsname |
| 2611 | \expandafter\let\expandafter\ttfont\csname #1tt\endcsname |
| 2612 | \expandafter\let\expandafter\smallcaps\csname #1sc\endcsname |
| 2613 | \expandafter\let\expandafter\sffont \csname #1sf\endcsname |
| 2614 | \expandafter\let\expandafter\ifont \csname #1i\endcsname |
| 2615 | \expandafter\let\expandafter\syfont \csname #1sy\endcsname |
| 2616 | \expandafter\let\expandafter\ttslfont\csname #1ttsl\endcsname |
| 2617 | } |
| 2618 | |
| 2619 | \newif\ifrmisbold |
| 2620 | |
| 2621 | % Select smaller font size with the current style. Used to change font size |
| 2622 | % in, e.g., the LaTeX logo and acronyms. If we are using bold fonts for |
| 2623 | % normal roman text, also use bold fonts for roman text in the smaller size. |
| 2624 | \def\switchtolllsize{% |
| 2625 | \expandafter\assignfonts\expandafter{\lllsize}% |
| 2626 | \ifrmisbold |
| 2627 | \let\rmfont\bffont |
| 2628 | \fi |
| 2629 | \csname\curfontstyle\endcsname |
| 2630 | }% |
| 2631 | |
| 2632 | \def\switchtolsize{% |
| 2633 | \expandafter\assignfonts\expandafter{\lsize}% |
| 2634 | \ifrmisbold |
| 2635 | \let\rmfont\bffont |
| 2636 | \fi |
| 2637 | \csname\curfontstyle\endcsname |
| 2638 | }% |
| 2639 | |
| 2640 | \def\definefontsetatsize#1#2#3#4#5{% |
| 2641 | \expandafter\def\csname #1fonts\endcsname{% |
| 2642 | \def\curfontsize{#1}% |
| 2643 | \def\lsize{#2}\def\lllsize{#3}% |
| 2644 | \csname rmisbold#5\endcsname |
| 2645 | \assignfonts{#1}% |
| 2646 | \resetmathfonts |
| 2647 | \setleading{#4}% |
| 2648 | }} |
| 2649 | |
| 2650 | \definefontsetatsize{text} {reduced}{smaller}{\textleading}{false} |
| 2651 | \definefontsetatsize{title} {chap} {subsec} {27pt} {true} |
| 2652 | \definefontsetatsize{chap} {sec} {text} {19pt} {true} |
| 2653 | \definefontsetatsize{sec} {subsec} {reduced}{17pt} {true} |
| 2654 | \definefontsetatsize{ssec} {text} {small} {15pt} {true} |
| 2655 | \definefontsetatsize{reduced}{small} {smaller}{10.5pt}{false} |
| 2656 | \definefontsetatsize{small} {smaller}{smaller}{10.5pt}{false} |
| 2657 | \definefontsetatsize{smaller}{smaller}{smaller}{9.5pt} {false} |
| 2658 | |
| 2659 | \def\titlefont#1{{\titlefonts\rm #1}} |
| 2660 | \let\subsecfonts = \ssecfonts |
| 2661 | \let\subsubsecfonts = \ssecfonts |
| 2662 | |
| 2663 | % Define these just so they can be easily changed for other fonts. |
| 2664 | \def\angleleft{$\langle$} |
| 2665 | \def\angleright{$\rangle$} |
| 2666 | |
| 2667 | % Set the fonts to use with the @small... environments. |
| 2668 | \let\smallexamplefonts = \smallfonts |
| 2669 | |
| 2670 | % About \smallexamplefonts. If we use \smallfonts (9pt), @smallexample |
| 2671 | % can fit this many characters: |
| 2672 | % 8.5x11=86 smallbook=72 a4=90 a5=69 |
| 2673 | % If we use \scriptfonts (8pt), then we can fit this many characters: |
| 2674 | % 8.5x11=90+ smallbook=80 a4=90+ a5=77 |
| 2675 | % For me, subjectively, the few extra characters that fit aren't worth |
| 2676 | % the additional smallness of 8pt. So I'm making the default 9pt. |
| 2677 | % |
| 2678 | % By the way, for comparison, here's what fits with @example (10pt): |
| 2679 | % 8.5x11=71 smallbook=60 a4=75 a5=58 |
| 2680 | % --karl, 24jan03. |
| 2681 | |
| 2682 | % Set up the default fonts, so we can use them for creating boxes. |
| 2683 | % |
| 2684 | \definetextfontsizexi |
| 2685 | |
| 2686 | |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 2687 | % Check if we are currently using a typewriter font. Since all the |
| 2688 | % Computer Modern typewriter fonts have zero interword stretch (and |
| 2689 | % shrink), and it is reasonable to expect all typewriter fonts to have |
| 2690 | % this property, we can check that font parameter. |
| 2691 | % |
| 2692 | \def\ifmonospace{\ifdim\fontdimen3\font=0pt } |
| 2693 | |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 2694 | { |
| 2695 | \catcode`\'=\active |
| 2696 | \catcode`\`=\active |
| 2697 | |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 2698 | \gdef\setcodequotes{\let`\codequoteleft \let'\codequoteright} |
| 2699 | \gdef\setregularquotes{\let`\lq \let'\rq} |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 2700 | } |
| 2701 | |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 2702 | % Allow an option to not use regular directed right quote/apostrophe |
| 2703 | % (char 0x27), but instead the undirected quote from cmtt (char 0x0d). |
| 2704 | % The undirected quote is ugly, so don't make it the default, but it |
| 2705 | % works for pasting with more pdf viewers (at least evince), the |
| 2706 | % lilypond developers report. xpdf does work with the regular 0x27. |
| 2707 | % |
| 2708 | \def\codequoteright{% |
| 2709 | \ifmonospace |
| 2710 | \expandafter\ifx\csname SETtxicodequoteundirected\endcsname\relax |
| 2711 | \expandafter\ifx\csname SETcodequoteundirected\endcsname\relax |
| 2712 | '% |
| 2713 | \else \char'15 \fi |
| 2714 | \else \char'15 \fi |
| 2715 | \else |
| 2716 | '% |
| 2717 | \fi |
| 2718 | } |
| 2719 | % |
| 2720 | % and a similar option for the left quote char vs. a grave accent. |
| 2721 | % Modern fonts display ASCII 0x60 as a grave accent, so some people like |
| 2722 | % the code environments to do likewise. |
| 2723 | % |
| 2724 | \def\codequoteleft{% |
| 2725 | \ifmonospace |
| 2726 | \expandafter\ifx\csname SETtxicodequotebacktick\endcsname\relax |
| 2727 | \expandafter\ifx\csname SETcodequotebacktick\endcsname\relax |
| 2728 | % [Knuth] pp. 380,381,391 |
| 2729 | % \relax disables Spanish ligatures ?` and !` of \tt font. |
| 2730 | \relax`% |
| 2731 | \else \char'22 \fi |
| 2732 | \else \char'22 \fi |
| 2733 | \else |
| 2734 | \relax`% |
| 2735 | \fi |
| 2736 | } |
| 2737 | |
| 2738 | % Commands to set the quote options. |
| 2739 | % |
| 2740 | \parseargdef\codequoteundirected{% |
| 2741 | \def\temp{#1}% |
| 2742 | \ifx\temp\onword |
| 2743 | \expandafter\let\csname SETtxicodequoteundirected\endcsname |
| 2744 | = t% |
| 2745 | \else\ifx\temp\offword |
| 2746 | \expandafter\let\csname SETtxicodequoteundirected\endcsname |
| 2747 | = \relax |
| 2748 | \else |
| 2749 | \errhelp = \EMsimple |
| 2750 | \errmessage{Unknown @codequoteundirected value `\temp', must be on|off}% |
| 2751 | \fi\fi |
| 2752 | } |
| 2753 | % |
| 2754 | \parseargdef\codequotebacktick{% |
| 2755 | \def\temp{#1}% |
| 2756 | \ifx\temp\onword |
| 2757 | \expandafter\let\csname SETtxicodequotebacktick\endcsname |
| 2758 | = t% |
| 2759 | \else\ifx\temp\offword |
| 2760 | \expandafter\let\csname SETtxicodequotebacktick\endcsname |
| 2761 | = \relax |
| 2762 | \else |
| 2763 | \errhelp = \EMsimple |
| 2764 | \errmessage{Unknown @codequotebacktick value `\temp', must be on|off}% |
| 2765 | \fi\fi |
| 2766 | } |
| 2767 | |
| 2768 | % [Knuth] pp. 380,381,391, disable Spanish ligatures ?` and !` of \tt font. |
| 2769 | \def\noligaturesquoteleft{\relax\lq} |
| 2770 | |
| 2771 | % Count depth in font-changes, for error checks |
| 2772 | \newcount\fontdepth \fontdepth=0 |
| 2773 | |
| 2774 | % Font commands. |
| 2775 | |
| 2776 | % #1 is the font command (\sl or \it), #2 is the text to slant. |
| 2777 | % If we are in a monospaced environment, however, 1) always use \ttsl, |
| 2778 | % and 2) do not add an italic correction. |
| 2779 | \def\dosmartslant#1#2{% |
| 2780 | \ifusingtt |
| 2781 | {{\ttsl #2}\let\next=\relax}% |
| 2782 | {\def\next{{#1#2}\futurelet\next\smartitaliccorrection}}% |
| 2783 | \next |
| 2784 | } |
| 2785 | \def\smartslanted{\dosmartslant\sl} |
| 2786 | \def\smartitalic{\dosmartslant\it} |
| 2787 | |
| 2788 | % Output an italic correction unless \next (presumed to be the following |
| 2789 | % character) is such as not to need one. |
| 2790 | \def\smartitaliccorrection{% |
| 2791 | \ifx\next,% |
| 2792 | \else\ifx\next-% |
| 2793 | \else\ifx\next.% |
| 2794 | \else\ifx\next\.% |
| 2795 | \else\ifx\next\comma% |
| 2796 | \else\ptexslash |
| 2797 | \fi\fi\fi\fi\fi |
| 2798 | \aftersmartic |
| 2799 | } |
| 2800 | |
| 2801 | % Unconditional use \ttsl, and no ic. @var is set to this for defuns. |
| 2802 | \def\ttslanted#1{{\ttsl #1}} |
| 2803 | |
| 2804 | % @cite is like \smartslanted except unconditionally use \sl. We never want |
| 2805 | % ttsl for book titles, do we? |
| 2806 | \def\cite#1{{\sl #1}\futurelet\next\smartitaliccorrection} |
| 2807 | |
| 2808 | \def\aftersmartic{} |
| 2809 | \def\var#1{% |
| 2810 | \let\saveaftersmartic = \aftersmartic |
| 2811 | \def\aftersmartic{\null\let\aftersmartic=\saveaftersmartic}% |
| 2812 | \smartslanted{#1}% |
| 2813 | } |
| 2814 | |
| 2815 | \let\i=\smartitalic |
| 2816 | \let\slanted=\smartslanted |
| 2817 | \let\dfn=\smartslanted |
| 2818 | \let\emph=\smartitalic |
| 2819 | |
| 2820 | % Explicit font changes: @r, @sc, undocumented @ii. |
| 2821 | \def\r#1{{\rm #1}} % roman font |
| 2822 | \def\sc#1{{\smallcaps#1}} % smallcaps font |
| 2823 | \def\ii#1{{\it #1}} % italic font |
| 2824 | |
| 2825 | % @b, explicit bold. Also @strong. |
| 2826 | \def\b#1{{\bf #1}} |
| 2827 | \let\strong=\b |
| 2828 | |
| 2829 | % @sansserif, explicit sans. |
| 2830 | \def\sansserif#1{{\sf #1}} |
| 2831 | |
| 2832 | % We can't just use \exhyphenpenalty, because that only has effect at |
| 2833 | % the end of a paragraph. Restore normal hyphenation at the end of the |
| 2834 | % group within which \nohyphenation is presumably called. |
| 2835 | % |
| 2836 | \def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation} |
| 2837 | \def\restorehyphenation{\hyphenchar\font = `- } |
| 2838 | |
| 2839 | % Set sfcode to normal for the chars that usually have another value. |
| 2840 | % Can't use plain's \frenchspacing because it uses the `\x notation, and |
| 2841 | % sometimes \x has an active definition that messes things up. |
| 2842 | % |
| 2843 | \catcode`@=11 |
| 2844 | \def\plainfrenchspacing{% |
| 2845 | \sfcode`\.=\@m \sfcode`\?=\@m \sfcode`\!=\@m |
| 2846 | \sfcode`\:=\@m \sfcode`\;=\@m \sfcode`\,=\@m |
| 2847 | \def\endofsentencespacefactor{1000}% for @. and friends |
| 2848 | } |
| 2849 | \def\plainnonfrenchspacing{% |
| 2850 | \sfcode`\.3000\sfcode`\?3000\sfcode`\!3000 |
| 2851 | \sfcode`\:2000\sfcode`\;1500\sfcode`\,1250 |
| 2852 | \def\endofsentencespacefactor{3000}% for @. and friends |
| 2853 | } |
| 2854 | \catcode`@=\other |
| 2855 | \def\endofsentencespacefactor{3000}% default |
| 2856 | |
| 2857 | % @t, explicit typewriter. |
| 2858 | \def\t#1{% |
| 2859 | {\tt \plainfrenchspacing #1}% |
| 2860 | \null |
| 2861 | } |
| 2862 | |
| 2863 | % @samp. |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 2864 | \def\samp#1{{\setcodequotes\lq\tclose{#1}\rq\null}} |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 2865 | |
| 2866 | % @indicateurl is \samp, that is, with quotes. |
| 2867 | \let\indicateurl=\samp |
| 2868 | |
| 2869 | % @code (and similar) prints in typewriter, but with spaces the same |
| 2870 | % size as normal in the surrounding text, without hyphenation, etc. |
| 2871 | % This is a subroutine for that. |
| 2872 | \def\tclose#1{% |
| 2873 | {% |
| 2874 | % Change normal interword space to be same as for the current font. |
| 2875 | \spaceskip = \fontdimen2\font |
| 2876 | % |
| 2877 | % Switch to typewriter. |
| 2878 | \tt |
| 2879 | % |
| 2880 | % But `\ ' produces the large typewriter interword space. |
| 2881 | \def\ {{\spaceskip = 0pt{} }}% |
| 2882 | % |
| 2883 | % Turn off hyphenation. |
| 2884 | \nohyphenation |
| 2885 | % |
| 2886 | \plainfrenchspacing |
| 2887 | #1% |
| 2888 | }% |
| 2889 | \null % reset spacefactor to 1000 |
| 2890 | } |
| 2891 | |
| 2892 | % We *must* turn on hyphenation at `-' and `_' in @code. |
| 2893 | % (But see \codedashfinish below.) |
| 2894 | % Otherwise, it is too hard to avoid overfull hboxes |
| 2895 | % in the Emacs manual, the Library manual, etc. |
| 2896 | % |
| 2897 | % Unfortunately, TeX uses one parameter (\hyphenchar) to control |
| 2898 | % both hyphenation at - and hyphenation within words. |
| 2899 | % We must therefore turn them both off (\tclose does that) |
| 2900 | % and arrange explicitly to hyphenate at a dash. -- rms. |
| 2901 | { |
| 2902 | \catcode`\-=\active \catcode`\_=\active |
| 2903 | \catcode`\'=\active \catcode`\`=\active |
| 2904 | \global\let'=\rq \global\let`=\lq % default definitions |
| 2905 | % |
| 2906 | \global\def\code{\begingroup |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 2907 | \setcodequotes |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 2908 | \catcode\dashChar=\active \catcode\underChar=\active |
| 2909 | \ifallowcodebreaks |
| 2910 | \let-\codedash |
| 2911 | \let_\codeunder |
| 2912 | \else |
| 2913 | \let-\normaldash |
| 2914 | \let_\realunder |
| 2915 | \fi |
| 2916 | % Given -foo (with a single dash), we do not want to allow a break |
| 2917 | % after the hyphen. |
| 2918 | \global\let\codedashprev=\codedash |
| 2919 | % |
| 2920 | \codex |
| 2921 | } |
| 2922 | % |
| 2923 | \gdef\codedash{\futurelet\next\codedashfinish} |
| 2924 | \gdef\codedashfinish{% |
| 2925 | \normaldash % always output the dash character itself. |
| 2926 | % |
| 2927 | % Now, output a discretionary to allow a line break, unless |
| 2928 | % (a) the next character is a -, or |
| 2929 | % (b) the preceding character is a -. |
| 2930 | % E.g., given --posix, we do not want to allow a break after either -. |
| 2931 | % Given --foo-bar, we do want to allow a break between the - and the b. |
| 2932 | \ifx\next\codedash \else |
| 2933 | \ifx\codedashprev\codedash |
| 2934 | \else \discretionary{}{}{}\fi |
| 2935 | \fi |
| 2936 | % we need the space after the = for the case when \next itself is a |
| 2937 | % space token; it would get swallowed otherwise. As in @code{- a}. |
| 2938 | \global\let\codedashprev= \next |
| 2939 | } |
| 2940 | } |
| 2941 | \def\normaldash{-} |
| 2942 | % |
| 2943 | \def\codex #1{\tclose{#1}\endgroup} |
| 2944 | |
| 2945 | \def\codeunder{% |
| 2946 | % this is all so @math{@code{var_name}+1} can work. In math mode, _ |
| 2947 | % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.) |
| 2948 | % will therefore expand the active definition of _, which is us |
| 2949 | % (inside @code that is), therefore an endless loop. |
| 2950 | \ifusingtt{\ifmmode |
| 2951 | \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_. |
| 2952 | \else\normalunderscore \fi |
| 2953 | \discretionary{}{}{}}% |
| 2954 | {\_}% |
| 2955 | } |
| 2956 | |
| 2957 | % An additional complication: the above will allow breaks after, e.g., |
| 2958 | % each of the four underscores in __typeof__. This is bad. |
| 2959 | % @allowcodebreaks provides a document-level way to turn breaking at - |
| 2960 | % and _ on and off. |
| 2961 | % |
| 2962 | \newif\ifallowcodebreaks \allowcodebreakstrue |
| 2963 | |
| 2964 | \def\keywordtrue{true} |
| 2965 | \def\keywordfalse{false} |
| 2966 | |
| 2967 | \parseargdef\allowcodebreaks{% |
| 2968 | \def\txiarg{#1}% |
| 2969 | \ifx\txiarg\keywordtrue |
| 2970 | \allowcodebreakstrue |
| 2971 | \else\ifx\txiarg\keywordfalse |
| 2972 | \allowcodebreaksfalse |
| 2973 | \else |
| 2974 | \errhelp = \EMsimple |
| 2975 | \errmessage{Unknown @allowcodebreaks option `\txiarg', must be true|false}% |
| 2976 | \fi\fi |
| 2977 | } |
| 2978 | |
| 2979 | % For @command, @env, @file, @option quotes seem unnecessary, |
| 2980 | % so use \code rather than \samp. |
| 2981 | \let\command=\code |
| 2982 | \let\env=\code |
| 2983 | \let\file=\code |
| 2984 | \let\option=\code |
| 2985 | |
| 2986 | % @uref (abbreviation for `urlref') aka @url takes an optional |
| 2987 | % (comma-separated) second argument specifying the text to display and |
| 2988 | % an optional third arg as text to display instead of (rather than in |
| 2989 | % addition to) the url itself. First (mandatory) arg is the url. |
| 2990 | |
| 2991 | % TeX-only option to allow changing PDF output to show only the second |
| 2992 | % arg (if given), and not the url (which is then just the link target). |
| 2993 | \newif\ifurefurlonlylink |
| 2994 | |
| 2995 | % The default \pretolerance setting stops the penalty inserted in |
| 2996 | % \urefallowbreak being a discouragement to line breaking. Set it to |
| 2997 | % a negative value for this paragraph only. Hopefully this does not |
| 2998 | % conflict with redefinitions of \par done elsewhere. |
| 2999 | \def\nopretolerance{% |
| 3000 | \pretolerance=-1 |
| 3001 | \def\par{\endgraf\pretolerance=100 \let\par\endgraf}% |
| 3002 | } |
| 3003 | |
| 3004 | % The main macro is \urefbreak, which allows breaking at expected |
| 3005 | % places within the url. |
| 3006 | \def\urefbreak{\nopretolerance \begingroup \urefcatcodes \dourefbreak} |
| 3007 | \let\uref=\urefbreak |
| 3008 | % |
| 3009 | \def\dourefbreak#1{\urefbreakfinish #1,,,\finish} |
| 3010 | \def\urefbreakfinish#1,#2,#3,#4\finish{% doesn't work in @example |
| 3011 | \unsepspaces |
| 3012 | \pdfurl{#1}% |
| 3013 | \setbox0 = \hbox{\ignorespaces #3}% |
| 3014 | \ifdim\wd0 > 0pt |
| 3015 | \unhbox0 % third arg given, show only that |
| 3016 | \else |
| 3017 | \setbox0 = \hbox{\ignorespaces #2}% look for second arg |
| 3018 | \ifdim\wd0 > 0pt |
| 3019 | \ifpdf |
| 3020 | % For pdfTeX and LuaTeX |
| 3021 | \ifurefurlonlylink |
| 3022 | % PDF plus option to not display url, show just arg |
| 3023 | \unhbox0 |
| 3024 | \else |
| 3025 | % PDF, normally display both arg and url for consistency, |
| 3026 | % visibility, if the pdf is eventually used to print, etc. |
| 3027 | \unhbox0\ (\urefcode{#1})% |
| 3028 | \fi |
| 3029 | \else |
| 3030 | \ifx\XeTeXrevision\thisisundefined |
| 3031 | \unhbox0\ (\urefcode{#1})% DVI, always show arg and url |
| 3032 | \else |
| 3033 | % For XeTeX |
| 3034 | \ifurefurlonlylink |
| 3035 | % PDF plus option to not display url, show just arg |
| 3036 | \unhbox0 |
| 3037 | \else |
| 3038 | % PDF, normally display both arg and url for consistency, |
| 3039 | % visibility, if the pdf is eventually used to print, etc. |
| 3040 | \unhbox0\ (\urefcode{#1})% |
| 3041 | \fi |
| 3042 | \fi |
| 3043 | \fi |
| 3044 | \else |
| 3045 | \urefcode{#1}% only url given, so show it |
| 3046 | \fi |
| 3047 | \fi |
| 3048 | \endlink |
| 3049 | \endgroup} |
| 3050 | |
| 3051 | % Allow line breaks around only a few characters (only). |
| 3052 | \def\urefcatcodes{% |
| 3053 | \catcode`\&=\active \catcode`\.=\active |
| 3054 | \catcode`\#=\active \catcode`\?=\active |
| 3055 | \catcode`\/=\active |
| 3056 | } |
| 3057 | { |
| 3058 | \urefcatcodes |
| 3059 | % |
| 3060 | \global\def\urefcode{\begingroup |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 3061 | \setcodequotes |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 3062 | \urefcatcodes |
| 3063 | \let&\urefcodeamp |
| 3064 | \let.\urefcodedot |
| 3065 | \let#\urefcodehash |
| 3066 | \let?\urefcodequest |
| 3067 | \let/\urefcodeslash |
| 3068 | \codex |
| 3069 | } |
| 3070 | % |
| 3071 | % By default, they are just regular characters. |
| 3072 | \global\def&{\normalamp} |
| 3073 | \global\def.{\normaldot} |
| 3074 | \global\def#{\normalhash} |
| 3075 | \global\def?{\normalquest} |
| 3076 | \global\def/{\normalslash} |
| 3077 | } |
| 3078 | |
| 3079 | \def\urefcodeamp{\urefprebreak \&\urefpostbreak} |
| 3080 | \def\urefcodedot{\urefprebreak .\urefpostbreak} |
| 3081 | \def\urefcodehash{\urefprebreak \#\urefpostbreak} |
| 3082 | \def\urefcodequest{\urefprebreak ?\urefpostbreak} |
| 3083 | \def\urefcodeslash{\futurelet\next\urefcodeslashfinish} |
| 3084 | { |
| 3085 | \catcode`\/=\active |
| 3086 | \global\def\urefcodeslashfinish{% |
| 3087 | \urefprebreak \slashChar |
| 3088 | % Allow line break only after the final / in a sequence of |
| 3089 | % slashes, to avoid line break between the slashes in http://. |
| 3090 | \ifx\next/\else \urefpostbreak \fi |
| 3091 | } |
| 3092 | } |
| 3093 | |
| 3094 | % By default we'll break after the special characters, but some people like to |
| 3095 | % break before the special chars, so allow that. Also allow no breaking at |
| 3096 | % all, for manual control. |
| 3097 | % |
| 3098 | \parseargdef\urefbreakstyle{% |
| 3099 | \def\txiarg{#1}% |
| 3100 | \ifx\txiarg\wordnone |
| 3101 | \def\urefprebreak{\nobreak}\def\urefpostbreak{\nobreak} |
| 3102 | \else\ifx\txiarg\wordbefore |
| 3103 | \def\urefprebreak{\urefallowbreak}\def\urefpostbreak{\nobreak} |
| 3104 | \else\ifx\txiarg\wordafter |
| 3105 | \def\urefprebreak{\nobreak}\def\urefpostbreak{\urefallowbreak} |
| 3106 | \else |
| 3107 | \errhelp = \EMsimple |
| 3108 | \errmessage{Unknown @urefbreakstyle setting `\txiarg'}% |
| 3109 | \fi\fi\fi |
| 3110 | } |
| 3111 | \def\wordafter{after} |
| 3112 | \def\wordbefore{before} |
| 3113 | \def\wordnone{none} |
| 3114 | |
| 3115 | % Allow a ragged right output to aid breaking long URL's. There can |
| 3116 | % be a break at the \allowbreak with no extra glue (if the existing stretch in |
| 3117 | % the line is sufficient), a break at the \penalty with extra glue added |
| 3118 | % at the end of the line, or no break at all here. |
| 3119 | % Changing the value of the penalty and/or the amount of stretch affects how |
| 3120 | % preferable one choice is over the other. |
| 3121 | \def\urefallowbreak{% |
| 3122 | \penalty0\relax |
| 3123 | \hskip 0pt plus 2 em\relax |
| 3124 | \penalty1000\relax |
| 3125 | \hskip 0pt plus -2 em\relax |
| 3126 | } |
| 3127 | |
| 3128 | \urefbreakstyle after |
| 3129 | |
| 3130 | % @url synonym for @uref, since that's how everyone uses it. |
| 3131 | % |
| 3132 | \let\url=\uref |
| 3133 | |
| 3134 | % rms does not like angle brackets --karl, 17may97. |
| 3135 | % So now @email is just like @uref, unless we are pdf. |
| 3136 | % |
| 3137 | %\def\email#1{\angleleft{\tt #1}\angleright} |
| 3138 | \ifpdforxetex |
| 3139 | \def\email#1{\doemail#1,,\finish} |
| 3140 | \def\doemail#1,#2,#3\finish{\begingroup |
| 3141 | \unsepspaces |
| 3142 | \pdfurl{mailto:#1}% |
| 3143 | \setbox0 = \hbox{\ignorespaces #2}% |
| 3144 | \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi |
| 3145 | \endlink |
| 3146 | \endgroup} |
| 3147 | \else |
| 3148 | \let\email=\uref |
| 3149 | \fi |
| 3150 | |
| 3151 | % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always), |
| 3152 | % `example' (@kbd uses ttsl only inside of @example and friends), |
| 3153 | % or `code' (@kbd uses normal tty font always). |
| 3154 | \parseargdef\kbdinputstyle{% |
| 3155 | \def\txiarg{#1}% |
| 3156 | \ifx\txiarg\worddistinct |
| 3157 | \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}% |
| 3158 | \else\ifx\txiarg\wordexample |
| 3159 | \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}% |
| 3160 | \else\ifx\txiarg\wordcode |
| 3161 | \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}% |
| 3162 | \else |
| 3163 | \errhelp = \EMsimple |
| 3164 | \errmessage{Unknown @kbdinputstyle setting `\txiarg'}% |
| 3165 | \fi\fi\fi |
| 3166 | } |
| 3167 | \def\worddistinct{distinct} |
| 3168 | \def\wordexample{example} |
| 3169 | \def\wordcode{code} |
| 3170 | |
| 3171 | % Default is `distinct'. |
| 3172 | \kbdinputstyle distinct |
| 3173 | |
| 3174 | % @kbd is like @code, except that if the argument is just one @key command, |
| 3175 | % then @kbd has no effect. |
| 3176 | \def\kbd#1{{\def\look{#1}\expandafter\kbdsub\look??\par}} |
| 3177 | |
| 3178 | \def\xkey{\key} |
| 3179 | \def\kbdsub#1#2#3\par{% |
| 3180 | \def\one{#1}\def\three{#3}\def\threex{??}% |
| 3181 | \ifx\one\xkey\ifx\threex\three \key{#2}% |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 3182 | \else{\tclose{\kbdfont\setcodequotes\look}}\fi |
| 3183 | \else{\tclose{\kbdfont\setcodequotes\look}}\fi |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 3184 | } |
| 3185 | |
| 3186 | % definition of @key that produces a lozenge. Doesn't adjust to text size. |
| 3187 | %\setfont\keyrm\rmshape{8}{1000}{OT1} |
| 3188 | %\font\keysy=cmsy9 |
| 3189 | %\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{% |
| 3190 | % \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{% |
| 3191 | % \vbox{\hrule\kern-0.4pt |
| 3192 | % \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}% |
| 3193 | % \kern-0.4pt\hrule}% |
| 3194 | % \kern-.06em\raise0.4pt\hbox{\angleright}}}} |
| 3195 | |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 3196 | % definition of @key with no lozenge. |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 3197 | % |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 3198 | \def\key#1{{\setregularquotes \nohyphenation \tt #1}\null} |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 3199 | |
| 3200 | % @clicksequence{File @click{} Open ...} |
| 3201 | \def\clicksequence#1{\begingroup #1\endgroup} |
| 3202 | |
| 3203 | % @clickstyle @arrow (by default) |
| 3204 | \parseargdef\clickstyle{\def\click{#1}} |
| 3205 | \def\click{\arrow} |
| 3206 | |
| 3207 | % Typeset a dimension, e.g., `in' or `pt'. The only reason for the |
| 3208 | % argument is to make the input look right: @dmn{pt} instead of @dmn{}pt. |
| 3209 | % |
| 3210 | \def\dmn#1{\thinspace #1} |
| 3211 | |
| 3212 | % @acronym for "FBI", "NATO", and the like. |
| 3213 | % We print this one point size smaller, since it's intended for |
| 3214 | % all-uppercase. |
| 3215 | % |
| 3216 | \def\acronym#1{\doacronym #1,,\finish} |
| 3217 | \def\doacronym#1,#2,#3\finish{% |
| 3218 | {\switchtolsize #1}% |
| 3219 | \def\temp{#2}% |
| 3220 | \ifx\temp\empty \else |
| 3221 | \space ({\unsepspaces \ignorespaces \temp \unskip})% |
| 3222 | \fi |
| 3223 | \null % reset \spacefactor=1000 |
| 3224 | } |
| 3225 | |
| 3226 | % @abbr for "Comput. J." and the like. |
| 3227 | % No font change, but don't do end-of-sentence spacing. |
| 3228 | % |
| 3229 | \def\abbr#1{\doabbr #1,,\finish} |
| 3230 | \def\doabbr#1,#2,#3\finish{% |
| 3231 | {\plainfrenchspacing #1}% |
| 3232 | \def\temp{#2}% |
| 3233 | \ifx\temp\empty \else |
| 3234 | \space ({\unsepspaces \ignorespaces \temp \unskip})% |
| 3235 | \fi |
| 3236 | \null % reset \spacefactor=1000 |
| 3237 | } |
| 3238 | |
| 3239 | % @asis just yields its argument. Used with @table, for example. |
| 3240 | % |
| 3241 | \def\asis#1{#1} |
| 3242 | |
| 3243 | % @math outputs its argument in math mode. |
| 3244 | % |
| 3245 | % One complication: _ usually means subscripts, but it could also mean |
| 3246 | % an actual _ character, as in @math{@var{some_variable} + 1}. So make |
| 3247 | % _ active, and distinguish by seeing if the current family is \slfam, |
| 3248 | % which is what @var uses. |
| 3249 | { |
| 3250 | \catcode`\_ = \active |
| 3251 | \gdef\mathunderscore{% |
| 3252 | \catcode`\_=\active |
| 3253 | \def_{\ifnum\fam=\slfam \_\else\sb\fi}% |
| 3254 | } |
| 3255 | } |
| 3256 | % Another complication: we want \\ (and @\) to output a math (or tt) \. |
| 3257 | % FYI, plain.tex uses \\ as a temporary control sequence (for no |
| 3258 | % particular reason), but this is not advertised and we don't care. |
| 3259 | % |
| 3260 | % The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\. |
| 3261 | \def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi} |
| 3262 | % |
| 3263 | \def\math{% |
| 3264 | \ifmmode\else % only go into math if not in math mode already |
| 3265 | \tex |
| 3266 | \mathunderscore |
| 3267 | \let\\ = \mathbackslash |
| 3268 | \mathactive |
| 3269 | % make the texinfo accent commands work in math mode |
| 3270 | \let\"=\ddot |
| 3271 | \let\'=\acute |
| 3272 | \let\==\bar |
| 3273 | \let\^=\hat |
| 3274 | \let\`=\grave |
| 3275 | \let\u=\breve |
| 3276 | \let\v=\check |
| 3277 | \let\~=\tilde |
| 3278 | \let\dotaccent=\dot |
| 3279 | % have to provide another name for sup operator |
| 3280 | \let\mathopsup=\sup |
| 3281 | $\expandafter\finishmath\fi |
| 3282 | } |
| 3283 | \def\finishmath#1{#1$\endgroup} % Close the group opened by \tex. |
| 3284 | |
| 3285 | % Some active characters (such as <) are spaced differently in math. |
| 3286 | % We have to reset their definitions in case the @math was an argument |
| 3287 | % to a command which sets the catcodes (such as @item or @section). |
| 3288 | % |
| 3289 | { |
| 3290 | \catcode`^ = \active |
| 3291 | \catcode`< = \active |
| 3292 | \catcode`> = \active |
| 3293 | \catcode`+ = \active |
| 3294 | \catcode`' = \active |
| 3295 | \gdef\mathactive{% |
| 3296 | \let^ = \ptexhat |
| 3297 | \let< = \ptexless |
| 3298 | \let> = \ptexgtr |
| 3299 | \let+ = \ptexplus |
| 3300 | \let' = \ptexquoteright |
| 3301 | } |
| 3302 | } |
| 3303 | |
| 3304 | % for @sub and @sup, if in math mode, just do a normal sub/superscript. |
| 3305 | % If in text, use math to place as sub/superscript, but switch |
| 3306 | % into text mode, with smaller fonts. This is a different font than the |
| 3307 | % one used for real math sub/superscripts (8pt vs. 7pt), but let's not |
| 3308 | % fix it (significant additions to font machinery) until someone notices. |
| 3309 | % |
| 3310 | \def\sub{\ifmmode \expandafter\sb \else \expandafter\finishsub\fi} |
| 3311 | \def\finishsub#1{$\sb{\hbox{\switchtolllsize #1}}$}% |
| 3312 | % |
| 3313 | \def\sup{\ifmmode \expandafter\ptexsp \else \expandafter\finishsup\fi} |
| 3314 | \def\finishsup#1{$\ptexsp{\hbox{\switchtolllsize #1}}$}% |
| 3315 | |
| 3316 | % provide this command from LaTeX as it is very common |
| 3317 | \def\frac#1#2{{{#1}\over{#2}}} |
| 3318 | |
| 3319 | % @displaymath. |
| 3320 | % \globaldefs is needed to recognize the end lines in \tex and |
| 3321 | % \end tex. Set \thisenv as @end displaymath is seen before @end tex. |
| 3322 | {\obeylines |
| 3323 | \globaldefs=1 |
| 3324 | \envdef\displaymath{% |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 3325 | \tex% |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 3326 | \def\thisenv{\displaymath}% |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 3327 | \begingroup\let\end\displaymathend% |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 3328 | $$% |
| 3329 | } |
| 3330 | |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 3331 | \def\displaymathend{$$\endgroup\end}% |
| 3332 | |
| 3333 | \def\Edisplaymath{% |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 3334 | \def\thisenv{\tex}% |
| 3335 | \end tex |
| 3336 | }} |
| 3337 | |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 3338 | |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 3339 | % @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}. |
| 3340 | % Ignore unless FMTNAME == tex; then it is like @iftex and @tex, |
| 3341 | % except specified as a normal braced arg, so no newlines to worry about. |
| 3342 | % |
| 3343 | \def\outfmtnametex{tex} |
| 3344 | % |
| 3345 | \long\def\inlinefmt#1{\doinlinefmt #1,\finish} |
| 3346 | \long\def\doinlinefmt#1,#2,\finish{% |
| 3347 | \def\inlinefmtname{#1}% |
| 3348 | \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\fi |
| 3349 | } |
| 3350 | % |
| 3351 | % @inlinefmtifelse{FMTNAME,THEN-TEXT,ELSE-TEXT} expands THEN-TEXT if |
| 3352 | % FMTNAME is tex, else ELSE-TEXT. |
| 3353 | \long\def\inlinefmtifelse#1{\doinlinefmtifelse #1,,,\finish} |
| 3354 | \long\def\doinlinefmtifelse#1,#2,#3,#4,\finish{% |
| 3355 | \def\inlinefmtname{#1}% |
| 3356 | \ifx\inlinefmtname\outfmtnametex \ignorespaces #2\else \ignorespaces #3\fi |
| 3357 | } |
| 3358 | % |
| 3359 | % For raw, must switch into @tex before parsing the argument, to avoid |
| 3360 | % setting catcodes prematurely. Doing it this way means that, for |
| 3361 | % example, @inlineraw{html, foo{bar} gets a parse error instead of being |
| 3362 | % ignored. But this isn't important because if people want a literal |
| 3363 | % *right* brace they would have to use a command anyway, so they may as |
| 3364 | % well use a command to get a left brace too. We could re-use the |
| 3365 | % delimiter character idea from \verb, but it seems like overkill. |
| 3366 | % |
| 3367 | \long\def\inlineraw{\tex \doinlineraw} |
| 3368 | \long\def\doinlineraw#1{\doinlinerawtwo #1,\finish} |
| 3369 | \def\doinlinerawtwo#1,#2,\finish{% |
| 3370 | \def\inlinerawname{#1}% |
| 3371 | \ifx\inlinerawname\outfmtnametex \ignorespaces #2\fi |
| 3372 | \endgroup % close group opened by \tex. |
| 3373 | } |
| 3374 | |
| 3375 | % @inlineifset{VAR, TEXT} expands TEXT if VAR is @set. |
| 3376 | % |
| 3377 | \long\def\inlineifset#1{\doinlineifset #1,\finish} |
| 3378 | \long\def\doinlineifset#1,#2,\finish{% |
| 3379 | \def\inlinevarname{#1}% |
| 3380 | \expandafter\ifx\csname SET\inlinevarname\endcsname\relax |
| 3381 | \else\ignorespaces#2\fi |
| 3382 | } |
| 3383 | |
| 3384 | % @inlineifclear{VAR, TEXT} expands TEXT if VAR is not @set. |
| 3385 | % |
| 3386 | \long\def\inlineifclear#1{\doinlineifclear #1,\finish} |
| 3387 | \long\def\doinlineifclear#1,#2,\finish{% |
| 3388 | \def\inlinevarname{#1}% |
| 3389 | \expandafter\ifx\csname SET\inlinevarname\endcsname\relax \ignorespaces#2\fi |
| 3390 | } |
| 3391 | |
| 3392 | |
| 3393 | \message{glyphs,} |
| 3394 | % and logos. |
| 3395 | |
| 3396 | % @@ prints an @, as does @atchar{}. |
| 3397 | \def\@{\char64 } |
| 3398 | \let\atchar=\@ |
| 3399 | |
| 3400 | % @{ @} @lbracechar{} @rbracechar{} all generate brace characters. |
| 3401 | \def\lbracechar{{\ifmonospace\char123\else\ensuremath\lbrace\fi}} |
| 3402 | \def\rbracechar{{\ifmonospace\char125\else\ensuremath\rbrace\fi}} |
| 3403 | \let\{=\lbracechar |
| 3404 | \let\}=\rbracechar |
| 3405 | |
| 3406 | % @comma{} to avoid , parsing problems. |
| 3407 | \let\comma = , |
| 3408 | |
| 3409 | % Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent |
| 3410 | % Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H. |
| 3411 | \let\, = \ptexc |
| 3412 | \let\dotaccent = \ptexdot |
| 3413 | \def\ringaccent#1{{\accent23 #1}} |
| 3414 | \let\tieaccent = \ptext |
| 3415 | \let\ubaraccent = \ptexb |
| 3416 | \let\udotaccent = \d |
| 3417 | |
| 3418 | % Other special characters: @questiondown @exclamdown @ordf @ordm |
| 3419 | % Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss. |
| 3420 | \def\questiondown{?`} |
| 3421 | \def\exclamdown{!`} |
| 3422 | \def\ordf{\leavevmode\raise1ex\hbox{\switchtolllsize \underbar{a}}} |
| 3423 | \def\ordm{\leavevmode\raise1ex\hbox{\switchtolllsize \underbar{o}}} |
| 3424 | |
| 3425 | % Dotless i and dotless j, used for accents. |
| 3426 | \def\imacro{i} |
| 3427 | \def\jmacro{j} |
| 3428 | \def\dotless#1{% |
| 3429 | \def\temp{#1}% |
| 3430 | \ifx\temp\imacro \ifmmode\imath \else\ptexi \fi |
| 3431 | \else\ifx\temp\jmacro \ifmmode\jmath \else\j \fi |
| 3432 | \else \errmessage{@dotless can be used only with i or j}% |
| 3433 | \fi\fi |
| 3434 | } |
| 3435 | |
| 3436 | % The \TeX{} logo, as in plain, but resetting the spacing so that a |
| 3437 | % period following counts as ending a sentence. (Idea found in latex.) |
| 3438 | % |
| 3439 | \edef\TeX{\TeX \spacefactor=1000 } |
| 3440 | |
| 3441 | % @LaTeX{} logo. Not quite the same results as the definition in |
| 3442 | % latex.ltx, since we use a different font for the raised A; it's most |
| 3443 | % convenient for us to use an explicitly smaller font, rather than using |
| 3444 | % the \scriptstyle font (since we don't reset \scriptstyle and |
| 3445 | % \scriptscriptstyle). |
| 3446 | % |
| 3447 | \def\LaTeX{% |
| 3448 | L\kern-.36em |
| 3449 | {\setbox0=\hbox{T}% |
| 3450 | \vbox to \ht0{\hbox{% |
| 3451 | \ifx\textnominalsize\xwordpt |
| 3452 | % for 10pt running text, lllsize (8pt) is too small for the A in LaTeX. |
| 3453 | % Revert to plain's \scriptsize, which is 7pt. |
| 3454 | \count255=\the\fam $\fam\count255 \scriptstyle A$% |
| 3455 | \else |
| 3456 | % For 11pt, we can use our lllsize. |
| 3457 | \switchtolllsize A% |
| 3458 | \fi |
| 3459 | }% |
| 3460 | \vss |
| 3461 | }}% |
| 3462 | \kern-.15em |
| 3463 | \TeX |
| 3464 | } |
| 3465 | |
| 3466 | % Some math mode symbols. Define \ensuremath to switch into math mode |
| 3467 | % unless we are already there. Expansion tricks may not be needed here, |
| 3468 | % but safer, and can't hurt. |
| 3469 | \def\ensuremath{\ifmmode \expandafter\asis \else\expandafter\ensuredmath \fi} |
| 3470 | \def\ensuredmath#1{$\relax#1$} |
| 3471 | % |
| 3472 | \def\bullet{\ensuremath\ptexbullet} |
| 3473 | \def\geq{\ensuremath\ge} |
| 3474 | \def\leq{\ensuremath\le} |
| 3475 | \def\minus{\ensuremath-} |
| 3476 | |
| 3477 | % @dots{} outputs an ellipsis using the current font. |
| 3478 | % We do .5em per period so that it has the same spacing in the cm |
| 3479 | % typewriter fonts as three actual period characters; on the other hand, |
| 3480 | % in other typewriter fonts three periods are wider than 1.5em. So do |
| 3481 | % whichever is larger. |
| 3482 | % |
| 3483 | \def\dots{% |
| 3484 | \leavevmode |
| 3485 | \setbox0=\hbox{...}% get width of three periods |
| 3486 | \ifdim\wd0 > 1.5em |
| 3487 | \dimen0 = \wd0 |
| 3488 | \else |
| 3489 | \dimen0 = 1.5em |
| 3490 | \fi |
| 3491 | \hbox to \dimen0{% |
| 3492 | \hskip 0pt plus.25fil |
| 3493 | .\hskip 0pt plus1fil |
| 3494 | .\hskip 0pt plus1fil |
| 3495 | .\hskip 0pt plus.5fil |
| 3496 | }% |
| 3497 | } |
| 3498 | |
| 3499 | % @enddots{} is an end-of-sentence ellipsis. |
| 3500 | % |
| 3501 | \def\enddots{% |
| 3502 | \dots |
| 3503 | \spacefactor=\endofsentencespacefactor |
| 3504 | } |
| 3505 | |
| 3506 | % @point{}, @result{}, @expansion{}, @print{}, @equiv{}. |
| 3507 | % |
| 3508 | % Since these characters are used in examples, they should be an even number of |
| 3509 | % \tt widths. Each \tt character is 1en, so two makes it 1em. |
| 3510 | % |
| 3511 | \def\point{$\star$} |
| 3512 | \def\arrow{\leavevmode\raise.05ex\hbox to 1em{\hfil$\rightarrow$\hfil}} |
| 3513 | \def\result{\leavevmode\raise.05ex\hbox to 1em{\hfil$\Rightarrow$\hfil}} |
| 3514 | \def\expansion{\leavevmode\hbox to 1em{\hfil$\mapsto$\hfil}} |
| 3515 | \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}} |
| 3516 | \def\equiv{\leavevmode\hbox to 1em{\hfil$\ptexequiv$\hfil}} |
| 3517 | |
| 3518 | % The @error{} command. |
| 3519 | % Adapted from the TeXbook's \boxit. |
| 3520 | % |
| 3521 | \newbox\errorbox |
| 3522 | % |
| 3523 | {\ttfont \global\dimen0 = 3em}% Width of the box. |
| 3524 | \dimen2 = .55pt % Thickness of rules |
| 3525 | % The text. (`r' is open on the right, `e' somewhat less so on the left.) |
| 3526 | \setbox0 = \hbox{\kern-.75pt \reducedsf \putworderror\kern-1.5pt} |
| 3527 | % |
| 3528 | \setbox\errorbox=\hbox to \dimen0{\hfil |
| 3529 | \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right. |
| 3530 | \advance\hsize by -2\dimen2 % Rules. |
| 3531 | \vbox{% |
| 3532 | \hrule height\dimen2 |
| 3533 | \hbox{\vrule width\dimen2 \kern3pt % Space to left of text. |
| 3534 | \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below. |
| 3535 | \kern3pt\vrule width\dimen2}% Space to right. |
| 3536 | \hrule height\dimen2} |
| 3537 | \hfil} |
| 3538 | % |
| 3539 | \def\error{\leavevmode\lower.7ex\copy\errorbox} |
| 3540 | |
| 3541 | % @pounds{} is a sterling sign, which Knuth put in the CM italic font. |
| 3542 | % |
| 3543 | \def\pounds{\ifmonospace{\ecfont\char"BF}\else{\it\$}\fi} |
| 3544 | |
| 3545 | % @euro{} comes from a separate font, depending on the current style. |
| 3546 | % We use the free feym* fonts from the eurosym package by Henrik |
| 3547 | % Theiling, which support regular, slanted, bold and bold slanted (and |
| 3548 | % "outlined" (blackboard board, sort of) versions, which we don't need). |
| 3549 | % It is available from http://www.ctan.org/tex-archive/fonts/eurosym. |
| 3550 | % |
| 3551 | % Although only regular is the truly official Euro symbol, we ignore |
| 3552 | % that. The Euro is designed to be slightly taller than the regular |
| 3553 | % font height. |
| 3554 | % |
| 3555 | % feymr - regular |
| 3556 | % feymo - slanted |
| 3557 | % feybr - bold |
| 3558 | % feybo - bold slanted |
| 3559 | % |
| 3560 | % There is no good (free) typewriter version, to my knowledge. |
| 3561 | % A feymr10 euro is ~7.3pt wide, while a normal cmtt10 char is ~5.25pt wide. |
| 3562 | % Hmm. |
| 3563 | % |
| 3564 | % Also doesn't work in math. Do we need to do math with euro symbols? |
| 3565 | % Hope not. |
| 3566 | % |
| 3567 | % |
| 3568 | \def\euro{{\eurofont e}} |
| 3569 | \def\eurofont{% |
| 3570 | % We set the font at each command, rather than predefining it in |
| 3571 | % \textfonts and the other font-switching commands, so that |
| 3572 | % installations which never need the symbol don't have to have the |
| 3573 | % font installed. |
| 3574 | % |
| 3575 | % There is only one designed size (nominal 10pt), so we always scale |
| 3576 | % that to the current nominal size. |
| 3577 | % |
| 3578 | % By the way, simply using "at 1em" works for cmr10 and the like, but |
| 3579 | % does not work for cmbx10 and other extended/shrunken fonts. |
| 3580 | % |
| 3581 | \def\eurosize{\csname\curfontsize nominalsize\endcsname}% |
| 3582 | % |
| 3583 | \ifx\curfontstyle\bfstylename |
| 3584 | % bold: |
| 3585 | \font\thiseurofont = \ifusingit{feybo10}{feybr10} at \eurosize |
| 3586 | \else |
| 3587 | % regular: |
| 3588 | \font\thiseurofont = \ifusingit{feymo10}{feymr10} at \eurosize |
| 3589 | \fi |
| 3590 | \thiseurofont |
| 3591 | } |
| 3592 | |
| 3593 | % Glyphs from the EC fonts. We don't use \let for the aliases, because |
| 3594 | % sometimes we redefine the original macro, and the alias should reflect |
| 3595 | % the redefinition. |
| 3596 | % |
| 3597 | % Use LaTeX names for the Icelandic letters. |
| 3598 | \def\DH{{\ecfont \char"D0}} % Eth |
| 3599 | \def\dh{{\ecfont \char"F0}} % eth |
| 3600 | \def\TH{{\ecfont \char"DE}} % Thorn |
| 3601 | \def\th{{\ecfont \char"FE}} % thorn |
| 3602 | % |
| 3603 | \def\guillemetleft{{\ecfont \char"13}} |
| 3604 | \def\guillemotleft{\guillemetleft} |
| 3605 | \def\guillemetright{{\ecfont \char"14}} |
| 3606 | \def\guillemotright{\guillemetright} |
| 3607 | \def\guilsinglleft{{\ecfont \char"0E}} |
| 3608 | \def\guilsinglright{{\ecfont \char"0F}} |
| 3609 | \def\quotedblbase{{\ecfont \char"12}} |
| 3610 | \def\quotesinglbase{{\ecfont \char"0D}} |
| 3611 | % |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 3612 | \def\L{{\ecfont \char"8A}} % L with stroke |
| 3613 | \def\l{{\ecfont \char"AA}} % l with stroke |
| 3614 | % |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 3615 | % This positioning is not perfect (see the ogonek LaTeX package), but |
| 3616 | % we have the precomposed glyphs for the most common cases. We put the |
| 3617 | % tests to use those glyphs in the single \ogonek macro so we have fewer |
| 3618 | % dummy definitions to worry about for index entries, etc. |
| 3619 | % |
| 3620 | % ogonek is also used with other letters in Lithuanian (IOU), but using |
| 3621 | % the precomposed glyphs for those is not so easy since they aren't in |
| 3622 | % the same EC font. |
| 3623 | \def\ogonek#1{{% |
| 3624 | \def\temp{#1}% |
| 3625 | \ifx\temp\macrocharA\Aogonek |
| 3626 | \else\ifx\temp\macrochara\aogonek |
| 3627 | \else\ifx\temp\macrocharE\Eogonek |
| 3628 | \else\ifx\temp\macrochare\eogonek |
| 3629 | \else |
| 3630 | \ecfont \setbox0=\hbox{#1}% |
| 3631 | \ifdim\ht0=1ex\accent"0C #1% |
| 3632 | \else\ooalign{\unhbox0\crcr\hidewidth\char"0C \hidewidth}% |
| 3633 | \fi |
| 3634 | \fi\fi\fi\fi |
| 3635 | }% |
| 3636 | } |
| 3637 | \def\Aogonek{{\ecfont \char"81}}\def\macrocharA{A} |
| 3638 | \def\aogonek{{\ecfont \char"A1}}\def\macrochara{a} |
| 3639 | \def\Eogonek{{\ecfont \char"86}}\def\macrocharE{E} |
| 3640 | \def\eogonek{{\ecfont \char"A6}}\def\macrochare{e} |
| 3641 | % |
| 3642 | % Use the European Computer Modern fonts (cm-super in outline format) |
| 3643 | % for non-CM glyphs. That is ec* for regular text and tc* for the text |
| 3644 | % companion symbols (LaTeX TS1 encoding). Both are part of the ec |
| 3645 | % package and follow the same conventions. |
| 3646 | % |
| 3647 | \def\ecfont{\etcfont{e}} |
| 3648 | \def\tcfont{\etcfont{t}} |
| 3649 | % |
| 3650 | \def\etcfont#1{% |
| 3651 | % We can't distinguish serif/sans and italic/slanted, but this |
| 3652 | % is used for crude hacks anyway (like adding French and German |
| 3653 | % quotes to documents typeset with CM, where we lose kerning), so |
| 3654 | % hopefully nobody will notice/care. |
| 3655 | \edef\ecsize{\csname\curfontsize ecsize\endcsname}% |
| 3656 | \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}% |
| 3657 | \ifmonospace |
| 3658 | % typewriter: |
| 3659 | \font\thisecfont = #1ctt\ecsize \space at \nominalsize |
| 3660 | \else |
| 3661 | \ifx\curfontstyle\bfstylename |
| 3662 | % bold: |
| 3663 | \font\thisecfont = #1cb\ifusingit{i}{x}\ecsize \space at \nominalsize |
| 3664 | \else |
| 3665 | % regular: |
| 3666 | \font\thisecfont = #1c\ifusingit{ti}{rm}\ecsize \space at \nominalsize |
| 3667 | \fi |
| 3668 | \fi |
| 3669 | \thisecfont |
| 3670 | } |
| 3671 | |
| 3672 | % @registeredsymbol - R in a circle. The font for the R should really |
| 3673 | % be smaller yet, but lllsize is the best we can do for now. |
| 3674 | % Adapted from the plain.tex definition of \copyright. |
| 3675 | % |
| 3676 | \def\registeredsymbol{% |
| 3677 | $^{{\ooalign{\hfil\raise.07ex\hbox{\switchtolllsize R}% |
| 3678 | \hfil\crcr\Orb}}% |
| 3679 | }$% |
| 3680 | } |
| 3681 | |
| 3682 | % @textdegree - the normal degrees sign. |
| 3683 | % |
| 3684 | \def\textdegree{$^\circ$} |
| 3685 | |
| 3686 | % Laurent Siebenmann reports \Orb undefined with: |
| 3687 | % Textures 1.7.7 (preloaded format=plain 93.10.14) (68K) 16 APR 2004 02:38 |
| 3688 | % so we'll define it if necessary. |
| 3689 | % |
| 3690 | \ifx\Orb\thisisundefined |
| 3691 | \def\Orb{\mathhexbox20D} |
| 3692 | \fi |
| 3693 | |
| 3694 | % Quotes. |
| 3695 | \chardef\quoteleft=`\` |
| 3696 | \chardef\quoteright=`\' |
| 3697 | |
| 3698 | % only change font for tt for correct kerning and to avoid using |
| 3699 | % \ecfont unless necessary. |
| 3700 | \def\quotedblleft{% |
| 3701 | \ifmonospace{\ecfont\char"10}\else{\char"5C}\fi |
| 3702 | } |
| 3703 | |
| 3704 | \def\quotedblright{% |
| 3705 | \ifmonospace{\ecfont\char"11}\else{\char`\"}\fi |
| 3706 | } |
| 3707 | |
| 3708 | |
| 3709 | \message{page headings,} |
| 3710 | |
| 3711 | \newskip\titlepagetopglue \titlepagetopglue = 1.5in |
| 3712 | \newskip\titlepagebottomglue \titlepagebottomglue = 2pc |
| 3713 | |
| 3714 | % First the title page. Must do @settitle before @titlepage. |
| 3715 | \newif\ifseenauthor |
| 3716 | \newif\iffinishedtitlepage |
| 3717 | |
| 3718 | % @setcontentsaftertitlepage used to do an implicit @contents or |
| 3719 | % @shortcontents after @end titlepage, but it is now obsolete. |
| 3720 | \def\setcontentsaftertitlepage{% |
| 3721 | \errmessage{@setcontentsaftertitlepage has been removed as a Texinfo |
| 3722 | command; move your @contents command if you want the contents |
| 3723 | after the title page.}}% |
| 3724 | \def\setshortcontentsaftertitlepage{% |
| 3725 | \errmessage{@setshortcontentsaftertitlepage has been removed as a Texinfo |
| 3726 | command; move your @shortcontents and @contents commands if you |
| 3727 | want the contents after the title page.}}% |
| 3728 | |
| 3729 | \parseargdef\shorttitlepage{% |
| 3730 | \begingroup \hbox{}\vskip 1.5in \chaprm \centerline{#1}% |
| 3731 | \endgroup\page\hbox{}\page} |
| 3732 | |
| 3733 | \envdef\titlepage{% |
| 3734 | % Open one extra group, as we want to close it in the middle of \Etitlepage. |
| 3735 | \begingroup |
| 3736 | \parindent=0pt \textfonts |
| 3737 | % Leave some space at the very top of the page. |
| 3738 | \vglue\titlepagetopglue |
| 3739 | % No rule at page bottom unless we print one at the top with @title. |
| 3740 | \finishedtitlepagetrue |
| 3741 | % |
| 3742 | % Most title ``pages'' are actually two pages long, with space |
| 3743 | % at the top of the second. We don't want the ragged left on the second. |
| 3744 | \let\oldpage = \page |
| 3745 | \def\page{% |
| 3746 | \iffinishedtitlepage\else |
| 3747 | \finishtitlepage |
| 3748 | \fi |
| 3749 | \let\page = \oldpage |
| 3750 | \page |
| 3751 | \null |
| 3752 | }% |
| 3753 | } |
| 3754 | |
| 3755 | \def\Etitlepage{% |
| 3756 | \iffinishedtitlepage\else |
| 3757 | \finishtitlepage |
| 3758 | \fi |
| 3759 | % It is important to do the page break before ending the group, |
| 3760 | % because the headline and footline are only empty inside the group. |
| 3761 | % If we use the new definition of \page, we always get a blank page |
| 3762 | % after the title page, which we certainly don't want. |
| 3763 | \oldpage |
| 3764 | \endgroup |
| 3765 | % |
| 3766 | % Need this before the \...aftertitlepage checks so that if they are |
| 3767 | % in effect the toc pages will come out with page numbers. |
| 3768 | \HEADINGSon |
| 3769 | } |
| 3770 | |
| 3771 | \def\finishtitlepage{% |
| 3772 | \vskip4pt \hrule height 2pt width \hsize |
| 3773 | \vskip\titlepagebottomglue |
| 3774 | \finishedtitlepagetrue |
| 3775 | } |
| 3776 | |
| 3777 | % Settings used for typesetting titles: no hyphenation, no indentation, |
| 3778 | % don't worry much about spacing, ragged right. This should be used |
| 3779 | % inside a \vbox, and fonts need to be set appropriately first. \par should |
| 3780 | % be specified before the end of the \vbox, since a vbox is a group. |
| 3781 | % |
| 3782 | \def\raggedtitlesettings{% |
| 3783 | \rm |
| 3784 | \hyphenpenalty=10000 |
| 3785 | \parindent=0pt |
| 3786 | \tolerance=5000 |
| 3787 | \ptexraggedright |
| 3788 | } |
| 3789 | |
| 3790 | % Macros to be used within @titlepage: |
| 3791 | |
| 3792 | \let\subtitlerm=\rmfont |
| 3793 | \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines} |
| 3794 | |
| 3795 | \parseargdef\title{% |
| 3796 | \checkenv\titlepage |
| 3797 | \vbox{\titlefonts \raggedtitlesettings #1\par}% |
| 3798 | % print a rule at the page bottom also. |
| 3799 | \finishedtitlepagefalse |
| 3800 | \vskip4pt \hrule height 4pt width \hsize \vskip4pt |
| 3801 | } |
| 3802 | |
| 3803 | \parseargdef\subtitle{% |
| 3804 | \checkenv\titlepage |
| 3805 | {\subtitlefont \rightline{#1}}% |
| 3806 | } |
| 3807 | |
| 3808 | % @author should come last, but may come many times. |
| 3809 | % It can also be used inside @quotation. |
| 3810 | % |
| 3811 | \parseargdef\author{% |
| 3812 | \def\temp{\quotation}% |
| 3813 | \ifx\thisenv\temp |
| 3814 | \def\quotationauthor{#1}% printed in \Equotation. |
| 3815 | \else |
| 3816 | \checkenv\titlepage |
| 3817 | \ifseenauthor\else \vskip 0pt plus 1filll \seenauthortrue \fi |
| 3818 | {\secfonts\rm \leftline{#1}}% |
| 3819 | \fi |
| 3820 | } |
| 3821 | |
| 3822 | |
| 3823 | % Set up page headings and footings. |
| 3824 | |
| 3825 | \let\thispage=\folio |
| 3826 | |
| 3827 | \newtoks\evenheadline % headline on even pages |
| 3828 | \newtoks\oddheadline % headline on odd pages |
| 3829 | \newtoks\evenchapheadline% headline on even pages with a new chapter |
| 3830 | \newtoks\oddchapheadline % headline on odd pages with a new chapter |
| 3831 | \newtoks\evenfootline % footline on even pages |
| 3832 | \newtoks\oddfootline % footline on odd pages |
| 3833 | |
| 3834 | % Now make \makeheadline and \makefootline in Plain TeX use those variables |
| 3835 | \headline={{\textfonts\rm |
| 3836 | \ifchapterpage |
| 3837 | \ifodd\pageno\the\oddchapheadline\else\the\evenchapheadline\fi |
| 3838 | \else |
| 3839 | \ifodd\pageno\the\oddheadline\else\the\evenheadline\fi |
| 3840 | \fi}} |
| 3841 | |
| 3842 | \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline |
| 3843 | \else \the\evenfootline \fi}\HEADINGShook} |
| 3844 | \let\HEADINGShook=\relax |
| 3845 | |
| 3846 | % Commands to set those variables. |
| 3847 | % For example, this is what @headings on does |
| 3848 | % @evenheading @thistitle|@thispage|@thischapter |
| 3849 | % @oddheading @thischapter|@thispage|@thistitle |
| 3850 | % @evenfooting @thisfile|| |
| 3851 | % @oddfooting ||@thisfile |
| 3852 | |
| 3853 | |
| 3854 | \def\evenheading{\parsearg\evenheadingxxx} |
| 3855 | \def\evenheadingxxx #1{\evenheadingyyy #1\|\|\|\|\finish} |
| 3856 | \def\evenheadingyyy #1\|#2\|#3\|#4\finish{% |
| 3857 | \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}} |
| 3858 | \global\evenchapheadline=\evenheadline} |
| 3859 | |
| 3860 | \def\oddheading{\parsearg\oddheadingxxx} |
| 3861 | \def\oddheadingxxx #1{\oddheadingyyy #1\|\|\|\|\finish} |
| 3862 | \def\oddheadingyyy #1\|#2\|#3\|#4\finish{% |
| 3863 | \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}% |
| 3864 | \global\oddchapheadline=\oddheadline} |
| 3865 | |
| 3866 | \parseargdef\everyheading{\oddheadingxxx{#1}\evenheadingxxx{#1}}% |
| 3867 | |
| 3868 | \def\evenfooting{\parsearg\evenfootingxxx} |
| 3869 | \def\evenfootingxxx #1{\evenfootingyyy #1\|\|\|\|\finish} |
| 3870 | \def\evenfootingyyy #1\|#2\|#3\|#4\finish{% |
| 3871 | \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} |
| 3872 | |
| 3873 | \def\oddfooting{\parsearg\oddfootingxxx} |
| 3874 | \def\oddfootingxxx #1{\oddfootingyyy #1\|\|\|\|\finish} |
| 3875 | \def\oddfootingyyy #1\|#2\|#3\|#4\finish{% |
| 3876 | \global\oddfootline = {\rlap{\centerline{#2}}\line{#1\hfil#3}}% |
| 3877 | % |
| 3878 | % Leave some space for the footline. Hopefully ok to assume |
| 3879 | % @evenfooting will not be used by itself. |
| 3880 | \global\advance\txipageheight by -12pt |
| 3881 | \global\advance\vsize by -12pt |
| 3882 | } |
| 3883 | |
| 3884 | \parseargdef\everyfooting{\oddfootingxxx{#1}\evenfootingxxx{#1}} |
| 3885 | |
| 3886 | % @evenheadingmarks top \thischapter <- chapter at the top of a page |
| 3887 | % @evenheadingmarks bottom \thischapter <- chapter at the bottom of a page |
| 3888 | % |
| 3889 | % The same set of arguments for: |
| 3890 | % |
| 3891 | % @oddheadingmarks |
| 3892 | % @evenfootingmarks |
| 3893 | % @oddfootingmarks |
| 3894 | % @everyheadingmarks |
| 3895 | % @everyfootingmarks |
| 3896 | |
| 3897 | % These define \getoddheadingmarks, \getevenheadingmarks, |
| 3898 | % \getoddfootingmarks, and \getevenfootingmarks, each to one of |
| 3899 | % \gettopheadingmarks, \getbottomheadingmarks. |
| 3900 | % |
| 3901 | \def\evenheadingmarks{\headingmarks{even}{heading}} |
| 3902 | \def\oddheadingmarks{\headingmarks{odd}{heading}} |
| 3903 | \def\evenfootingmarks{\headingmarks{even}{footing}} |
| 3904 | \def\oddfootingmarks{\headingmarks{odd}{footing}} |
| 3905 | \parseargdef\everyheadingmarks{\headingmarks{even}{heading}{#1} |
| 3906 | \headingmarks{odd}{heading}{#1} } |
| 3907 | \parseargdef\everyfootingmarks{\headingmarks{even}{footing}{#1} |
| 3908 | \headingmarks{odd}{footing}{#1} } |
| 3909 | % #1 = even/odd, #2 = heading/footing, #3 = top/bottom. |
| 3910 | \def\headingmarks#1#2#3 {% |
| 3911 | \expandafter\let\expandafter\temp \csname get#3headingmarks\endcsname |
| 3912 | \global\expandafter\let\csname get#1#2marks\endcsname \temp |
| 3913 | } |
| 3914 | |
| 3915 | \everyheadingmarks bottom |
| 3916 | \everyfootingmarks bottom |
| 3917 | |
| 3918 | % @headings double turns headings on for double-sided printing. |
| 3919 | % @headings single turns headings on for single-sided printing. |
| 3920 | % @headings off turns them off. |
| 3921 | % @headings on same as @headings double, retained for compatibility. |
| 3922 | % @headings after turns on double-sided headings after this page. |
| 3923 | % @headings doubleafter turns on double-sided headings after this page. |
| 3924 | % @headings singleafter turns on single-sided headings after this page. |
| 3925 | % By default, they are off at the start of a document, |
| 3926 | % and turned `on' after @end titlepage. |
| 3927 | |
| 3928 | \parseargdef\headings{\csname HEADINGS#1\endcsname} |
| 3929 | |
| 3930 | \def\headingsoff{% non-global headings elimination |
| 3931 | \evenheadline={\hfil}\evenfootline={\hfil}\evenchapheadline={\hfil}% |
| 3932 | \oddheadline={\hfil}\oddfootline={\hfil}\oddchapheadline={\hfil}% |
| 3933 | } |
| 3934 | |
| 3935 | \def\HEADINGSoff{{\globaldefs=1 \headingsoff}} % global setting |
| 3936 | \HEADINGSoff % it's the default |
| 3937 | |
| 3938 | % When we turn headings on, set the page number to 1. |
| 3939 | \def\pageone{ |
| 3940 | \global\pageno=1 |
| 3941 | \global\arabiccount = \pagecount |
| 3942 | } |
| 3943 | |
| 3944 | % For double-sided printing, put current file name in lower left corner, |
| 3945 | % chapter name on inside top of right hand pages, document |
| 3946 | % title on inside top of left hand pages, and page numbers on outside top |
| 3947 | % edge of all pages. |
| 3948 | \def\HEADINGSdouble{% |
| 3949 | \pageone |
| 3950 | \HEADINGSdoublex |
| 3951 | } |
| 3952 | \let\contentsalignmacro = \chappager |
| 3953 | |
| 3954 | % For single-sided printing, chapter title goes across top left of page, |
| 3955 | % page number on top right. |
| 3956 | \def\HEADINGSsingle{% |
| 3957 | \pageone |
| 3958 | \HEADINGSsinglex |
| 3959 | } |
| 3960 | \def\HEADINGSon{\HEADINGSdouble} |
| 3961 | |
| 3962 | \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex} |
| 3963 | \let\HEADINGSdoubleafter=\HEADINGSafter |
| 3964 | \def\HEADINGSdoublex{% |
| 3965 | \global\evenfootline={\hfil} |
| 3966 | \global\oddfootline={\hfil} |
| 3967 | \global\evenheadline={\line{\folio\hfil\thistitle}} |
| 3968 | \global\oddheadline={\line{\thischapter\hfil\folio}} |
| 3969 | \global\evenchapheadline={\line{\folio\hfil}} |
| 3970 | \global\oddchapheadline={\line{\hfil\folio}} |
| 3971 | \global\let\contentsalignmacro = \chapoddpage |
| 3972 | } |
| 3973 | |
| 3974 | \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex} |
| 3975 | \def\HEADINGSsinglex{% |
| 3976 | \global\evenfootline={\hfil} |
| 3977 | \global\oddfootline={\hfil} |
| 3978 | \global\evenheadline={\line{\thischapter\hfil\folio}} |
| 3979 | \global\oddheadline={\line{\thischapter\hfil\folio}} |
| 3980 | \global\evenchapheadline={\line{\hfil\folio}} |
| 3981 | \global\oddchapheadline={\line{\hfil\folio}} |
| 3982 | \global\let\contentsalignmacro = \chappager |
| 3983 | } |
| 3984 | |
| 3985 | % for @setchapternewpage off |
| 3986 | \def\HEADINGSsinglechapoff{% |
| 3987 | \pageone |
| 3988 | \global\evenfootline={\hfil} |
| 3989 | \global\oddfootline={\hfil} |
| 3990 | \global\evenheadline={\line{\thischapter\hfil\folio}} |
| 3991 | \global\oddheadline={\line{\thischapter\hfil\folio}} |
| 3992 | \global\evenchapheadline=\evenheadline |
| 3993 | \global\oddchapheadline=\oddheadline |
| 3994 | \global\let\contentsalignmacro = \chappager |
| 3995 | } |
| 3996 | |
| 3997 | % Subroutines used in generating headings |
| 3998 | % This produces Day Month Year style of output. |
| 3999 | % Only define if not already defined, in case a txi-??.tex file has set |
| 4000 | % up a different format (e.g., txi-cs.tex does this). |
| 4001 | \ifx\today\thisisundefined |
| 4002 | \def\today{% |
| 4003 | \number\day\space |
| 4004 | \ifcase\month |
| 4005 | \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr |
| 4006 | \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug |
| 4007 | \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec |
| 4008 | \fi |
| 4009 | \space\number\year} |
| 4010 | \fi |
| 4011 | |
| 4012 | % @settitle line... specifies the title of the document, for headings. |
| 4013 | % It generates no output of its own. |
| 4014 | \def\thistitle{\putwordNoTitle} |
| 4015 | \def\settitle{\parsearg{\gdef\thistitle}} |
| 4016 | |
| 4017 | |
| 4018 | \message{tables,} |
| 4019 | % Tables -- @table, @ftable, @vtable, @item(x). |
| 4020 | |
| 4021 | % default indentation of table text |
| 4022 | \newdimen\tableindent \tableindent=.8in |
| 4023 | % default indentation of @itemize and @enumerate text |
| 4024 | \newdimen\itemindent \itemindent=.3in |
| 4025 | % margin between end of table item and start of table text. |
| 4026 | \newdimen\itemmargin \itemmargin=.1in |
| 4027 | |
| 4028 | % used internally for \itemindent minus \itemmargin |
| 4029 | \newdimen\itemmax |
| 4030 | |
| 4031 | % Note @table, @ftable, and @vtable define @item, @itemx, etc., with |
| 4032 | % these defs. |
| 4033 | % They also define \itemindex |
| 4034 | % to index the item name in whatever manner is desired (perhaps none). |
| 4035 | |
| 4036 | \newif\ifitemxneedsnegativevskip |
| 4037 | |
| 4038 | \def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi} |
| 4039 | |
| 4040 | \def\internalBitem{\smallbreak \parsearg\itemzzz} |
| 4041 | \def\internalBitemx{\itemxpar \parsearg\itemzzz} |
| 4042 | |
| 4043 | \def\itemzzz #1{\begingroup % |
| 4044 | \advance\hsize by -\rightskip |
| 4045 | \advance\hsize by -\tableindent |
| 4046 | \setbox0=\hbox{\itemindicate{#1}}% |
| 4047 | \itemindex{#1}% |
| 4048 | \nobreak % This prevents a break before @itemx. |
| 4049 | % |
| 4050 | % If the item text does not fit in the space we have, put it on a line |
| 4051 | % by itself, and do not allow a page break either before or after that |
| 4052 | % line. We do not start a paragraph here because then if the next |
| 4053 | % command is, e.g., @kindex, the whatsit would get put into the |
| 4054 | % horizontal list on a line by itself, resulting in extra blank space. |
| 4055 | \ifdim \wd0>\itemmax |
| 4056 | % |
| 4057 | % Make this a paragraph so we get the \parskip glue and wrapping, |
| 4058 | % but leave it ragged-right. |
| 4059 | \begingroup |
| 4060 | \advance\leftskip by-\tableindent |
| 4061 | \advance\hsize by\tableindent |
| 4062 | \advance\rightskip by0pt plus1fil\relax |
| 4063 | \leavevmode\unhbox0\par |
| 4064 | \endgroup |
| 4065 | % |
| 4066 | % We're going to be starting a paragraph, but we don't want the |
| 4067 | % \parskip glue -- logically it's part of the @item we just started. |
| 4068 | \nobreak \vskip-\parskip |
| 4069 | % |
| 4070 | % Stop a page break at the \parskip glue coming up. However, if |
| 4071 | % what follows is an environment such as @example, there will be no |
| 4072 | % \parskip glue; then the negative vskip we just inserted would |
| 4073 | % cause the example and the item to crash together. So we use this |
| 4074 | % bizarre value of 10001 as a signal to \aboveenvbreak to insert |
| 4075 | % \parskip glue after all. Section titles are handled this way also. |
| 4076 | % |
| 4077 | \penalty 10001 |
| 4078 | \endgroup |
| 4079 | \itemxneedsnegativevskipfalse |
| 4080 | \else |
| 4081 | % The item text fits into the space. Start a paragraph, so that the |
| 4082 | % following text (if any) will end up on the same line. |
| 4083 | \noindent |
| 4084 | % Do this with kerns and \unhbox so that if there is a footnote in |
| 4085 | % the item text, it can migrate to the main vertical list and |
| 4086 | % eventually be printed. |
| 4087 | \nobreak\kern-\tableindent |
| 4088 | \dimen0 = \itemmax \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0 |
| 4089 | \unhbox0 |
| 4090 | \nobreak\kern\dimen0 |
| 4091 | \endgroup |
| 4092 | \itemxneedsnegativevskiptrue |
| 4093 | \fi |
| 4094 | } |
| 4095 | |
| 4096 | \def\item{\errmessage{@item while not in a list environment}} |
| 4097 | \def\itemx{\errmessage{@itemx while not in a list environment}} |
| 4098 | |
| 4099 | % @table, @ftable, @vtable. |
| 4100 | \envdef\table{% |
| 4101 | \let\itemindex\gobble |
| 4102 | \tablecheck{table}% |
| 4103 | } |
| 4104 | \envdef\ftable{% |
| 4105 | \def\itemindex ##1{\doind {fn}{\code{##1}}}% |
| 4106 | \tablecheck{ftable}% |
| 4107 | } |
| 4108 | \envdef\vtable{% |
| 4109 | \def\itemindex ##1{\doind {vr}{\code{##1}}}% |
| 4110 | \tablecheck{vtable}% |
| 4111 | } |
| 4112 | \def\tablecheck#1{% |
| 4113 | \ifnum \the\catcode`\^^M=\active |
| 4114 | \endgroup |
| 4115 | \errmessage{This command won't work in this context; perhaps the problem is |
| 4116 | that we are \inenvironment\thisenv}% |
| 4117 | \def\next{\doignore{#1}}% |
| 4118 | \else |
| 4119 | \let\next\tablex |
| 4120 | \fi |
| 4121 | \next |
| 4122 | } |
| 4123 | \def\tablex#1{% |
| 4124 | \def\itemindicate{#1}% |
| 4125 | \parsearg\tabley |
| 4126 | } |
| 4127 | \def\tabley#1{% |
| 4128 | {% |
| 4129 | \makevalueexpandable |
| 4130 | \edef\temp{\noexpand\tablez #1\space\space\space}% |
| 4131 | \expandafter |
| 4132 | }\temp \endtablez |
| 4133 | } |
| 4134 | \def\tablez #1 #2 #3 #4\endtablez{% |
| 4135 | \aboveenvbreak |
| 4136 | \ifnum 0#1>0 \advance \leftskip by #1\mil \fi |
| 4137 | \ifnum 0#2>0 \tableindent=#2\mil \fi |
| 4138 | \ifnum 0#3>0 \advance \rightskip by #3\mil \fi |
| 4139 | \itemmax=\tableindent |
| 4140 | \advance \itemmax by -\itemmargin |
| 4141 | \advance \leftskip by \tableindent |
| 4142 | \exdentamount=\tableindent |
| 4143 | \parindent = 0pt |
| 4144 | \parskip = \smallskipamount |
| 4145 | \ifdim \parskip=0pt \parskip=2pt \fi |
| 4146 | \let\item = \internalBitem |
| 4147 | \let\itemx = \internalBitemx |
| 4148 | } |
| 4149 | \def\Etable{\endgraf\afterenvbreak} |
| 4150 | \let\Eftable\Etable |
| 4151 | \let\Evtable\Etable |
| 4152 | \let\Eitemize\Etable |
| 4153 | \let\Eenumerate\Etable |
| 4154 | |
| 4155 | % This is the counter used by @enumerate, which is really @itemize |
| 4156 | |
| 4157 | \newcount \itemno |
| 4158 | |
| 4159 | \envdef\itemize{\parsearg\doitemize} |
| 4160 | |
| 4161 | \def\doitemize#1{% |
| 4162 | \aboveenvbreak |
| 4163 | \itemmax=\itemindent |
| 4164 | \advance\itemmax by -\itemmargin |
| 4165 | \advance\leftskip by \itemindent |
| 4166 | \exdentamount=\itemindent |
| 4167 | \parindent=0pt |
| 4168 | \parskip=\smallskipamount |
| 4169 | \ifdim\parskip=0pt \parskip=2pt \fi |
| 4170 | % |
| 4171 | % Try typesetting the item mark so that if the document erroneously says |
| 4172 | % something like @itemize @samp (intending @table), there's an error |
| 4173 | % right away at the @itemize. It's not the best error message in the |
| 4174 | % world, but it's better than leaving it to the @item. This means if |
| 4175 | % the user wants an empty mark, they have to say @w{} not just @w. |
| 4176 | \def\itemcontents{#1}% |
| 4177 | \setbox0 = \hbox{\itemcontents}% |
| 4178 | % |
| 4179 | % @itemize with no arg is equivalent to @itemize @bullet. |
| 4180 | \ifx\itemcontents\empty\def\itemcontents{\bullet}\fi |
| 4181 | % |
| 4182 | \let\item=\itemizeitem |
| 4183 | } |
| 4184 | |
| 4185 | % Definition of @item while inside @itemize and @enumerate. |
| 4186 | % |
| 4187 | \def\itemizeitem{% |
| 4188 | \advance\itemno by 1 % for enumerations |
| 4189 | {\let\par=\endgraf \smallbreak}% reasonable place to break |
| 4190 | {% |
| 4191 | % If the document has an @itemize directly after a section title, a |
| 4192 | % \nobreak will be last on the list, and \sectionheading will have |
| 4193 | % done a \vskip-\parskip. In that case, we don't want to zero |
| 4194 | % parskip, or the item text will crash with the heading. On the |
| 4195 | % other hand, when there is normal text preceding the item (as there |
| 4196 | % usually is), we do want to zero parskip, or there would be too much |
| 4197 | % space. In that case, we won't have a \nobreak before. At least |
| 4198 | % that's the theory. |
| 4199 | \ifnum\lastpenalty<10000 \parskip=0in \fi |
| 4200 | \noindent |
| 4201 | \hbox to 0pt{\hss \itemcontents \kern\itemmargin}% |
| 4202 | % |
| 4203 | \ifinner\else |
| 4204 | \vadjust{\penalty 1200}% not good to break after first line of item. |
| 4205 | \fi |
| 4206 | % We can be in inner vertical mode in a footnote, although an |
| 4207 | % @itemize looks awful there. |
| 4208 | }% |
| 4209 | \flushcr |
| 4210 | } |
| 4211 | |
| 4212 | % \splitoff TOKENS\endmark defines \first to be the first token in |
| 4213 | % TOKENS, and \rest to be the remainder. |
| 4214 | % |
| 4215 | \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}% |
| 4216 | |
| 4217 | % Allow an optional argument of an uppercase letter, lowercase letter, |
| 4218 | % or number, to specify the first label in the enumerated list. No |
| 4219 | % argument is the same as `1'. |
| 4220 | % |
| 4221 | \envparseargdef\enumerate{\enumeratey #1 \endenumeratey} |
| 4222 | \def\enumeratey #1 #2\endenumeratey{% |
| 4223 | % If we were given no argument, pretend we were given `1'. |
| 4224 | \def\thearg{#1}% |
| 4225 | \ifx\thearg\empty \def\thearg{1}\fi |
| 4226 | % |
| 4227 | % Detect if the argument is a single token. If so, it might be a |
| 4228 | % letter. Otherwise, the only valid thing it can be is a number. |
| 4229 | % (We will always have one token, because of the test we just made. |
| 4230 | % This is a good thing, since \splitoff doesn't work given nothing at |
| 4231 | % all -- the first parameter is undelimited.) |
| 4232 | \expandafter\splitoff\thearg\endmark |
| 4233 | \ifx\rest\empty |
| 4234 | % Only one token in the argument. It could still be anything. |
| 4235 | % A ``lowercase letter'' is one whose \lccode is nonzero. |
| 4236 | % An ``uppercase letter'' is one whose \lccode is both nonzero, and |
| 4237 | % not equal to itself. |
| 4238 | % Otherwise, we assume it's a number. |
| 4239 | % |
| 4240 | % We need the \relax at the end of the \ifnum lines to stop TeX from |
| 4241 | % continuing to look for a <number>. |
| 4242 | % |
| 4243 | \ifnum\lccode\expandafter`\thearg=0\relax |
| 4244 | \numericenumerate % a number (we hope) |
| 4245 | \else |
| 4246 | % It's a letter. |
| 4247 | \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax |
| 4248 | \lowercaseenumerate % lowercase letter |
| 4249 | \else |
| 4250 | \uppercaseenumerate % uppercase letter |
| 4251 | \fi |
| 4252 | \fi |
| 4253 | \else |
| 4254 | % Multiple tokens in the argument. We hope it's a number. |
| 4255 | \numericenumerate |
| 4256 | \fi |
| 4257 | } |
| 4258 | |
| 4259 | % An @enumerate whose labels are integers. The starting integer is |
| 4260 | % given in \thearg. |
| 4261 | % |
| 4262 | \def\numericenumerate{% |
| 4263 | \itemno = \thearg |
| 4264 | \startenumeration{\the\itemno}% |
| 4265 | } |
| 4266 | |
| 4267 | % The starting (lowercase) letter is in \thearg. |
| 4268 | \def\lowercaseenumerate{% |
| 4269 | \itemno = \expandafter`\thearg |
| 4270 | \startenumeration{% |
| 4271 | % Be sure we're not beyond the end of the alphabet. |
| 4272 | \ifnum\itemno=0 |
| 4273 | \errmessage{No more lowercase letters in @enumerate; get a bigger |
| 4274 | alphabet}% |
| 4275 | \fi |
| 4276 | \char\lccode\itemno |
| 4277 | }% |
| 4278 | } |
| 4279 | |
| 4280 | % The starting (uppercase) letter is in \thearg. |
| 4281 | \def\uppercaseenumerate{% |
| 4282 | \itemno = \expandafter`\thearg |
| 4283 | \startenumeration{% |
| 4284 | % Be sure we're not beyond the end of the alphabet. |
| 4285 | \ifnum\itemno=0 |
| 4286 | \errmessage{No more uppercase letters in @enumerate; get a bigger |
| 4287 | alphabet} |
| 4288 | \fi |
| 4289 | \char\uccode\itemno |
| 4290 | }% |
| 4291 | } |
| 4292 | |
| 4293 | % Call \doitemize, adding a period to the first argument and supplying the |
| 4294 | % common last two arguments. Also subtract one from the initial value in |
| 4295 | % \itemno, since @item increments \itemno. |
| 4296 | % |
| 4297 | \def\startenumeration#1{% |
| 4298 | \advance\itemno by -1 |
| 4299 | \doitemize{#1.}\flushcr |
| 4300 | } |
| 4301 | |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 4302 | |
| 4303 | % @multitable macros |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 4304 | |
| 4305 | % Macros used to set up halign preamble: |
| 4306 | % |
| 4307 | \let\endsetuptable\relax |
| 4308 | \def\xendsetuptable{\endsetuptable} |
| 4309 | \let\columnfractions\relax |
| 4310 | \def\xcolumnfractions{\columnfractions} |
| 4311 | \newif\ifsetpercent |
| 4312 | |
| 4313 | % #1 is the @columnfraction, usually a decimal number like .5, but might |
| 4314 | % be just 1. We just use it, whatever it is. |
| 4315 | % |
| 4316 | \def\pickupwholefraction#1 {% |
| 4317 | \global\advance\colcount by 1 |
| 4318 | \expandafter\xdef\csname col\the\colcount\endcsname{#1\hsize}% |
| 4319 | \setuptable |
| 4320 | } |
| 4321 | |
| 4322 | \newcount\colcount |
| 4323 | \def\setuptable#1{% |
| 4324 | \def\firstarg{#1}% |
| 4325 | \ifx\firstarg\xendsetuptable |
| 4326 | \let\go = \relax |
| 4327 | \else |
| 4328 | \ifx\firstarg\xcolumnfractions |
| 4329 | \global\setpercenttrue |
| 4330 | \else |
| 4331 | \ifsetpercent |
| 4332 | \let\go\pickupwholefraction |
| 4333 | \else |
| 4334 | \global\advance\colcount by 1 |
| 4335 | \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a |
| 4336 | % separator; typically that is always in the input, anyway. |
| 4337 | \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}% |
| 4338 | \fi |
| 4339 | \fi |
| 4340 | \ifx\go\pickupwholefraction |
| 4341 | % Put the argument back for the \pickupwholefraction call, so |
| 4342 | % we'll always have a period there to be parsed. |
| 4343 | \def\go{\pickupwholefraction#1}% |
| 4344 | \else |
| 4345 | \let\go = \setuptable |
| 4346 | \fi% |
| 4347 | \fi |
| 4348 | \go |
| 4349 | } |
| 4350 | |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 4351 | % @headitem starts a heading row, which we typeset in bold. Assignments |
| 4352 | % have to be global since we are inside the implicit group of an |
| 4353 | % alignment entry. \everycr below resets \everytab so we don't have to |
| 4354 | % undo it ourselves. |
| 4355 | \def\headitemfont{\b}% for people to use in the template row; not changeable |
| 4356 | \def\headitem{% |
| 4357 | \checkenv\multitable |
| 4358 | \crcr |
| 4359 | \gdef\headitemcrhook{\nobreak}% attempt to avoid page break after headings |
| 4360 | \global\everytab={\bf}% can't use \headitemfont since the parsing differs |
| 4361 | \the\everytab % for the first item |
| 4362 | }% |
| 4363 | % |
| 4364 | % default for tables with no headings. |
| 4365 | \let\headitemcrhook=\relax |
| 4366 | % |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 4367 | \def\tab{\checkenv\multitable &\the\everytab}% |
| 4368 | |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 4369 | \newtoks\everytab % insert after every tab. |
| 4370 | % |
| 4371 | \envdef\multitable{% |
| 4372 | \vskip\parskip |
| 4373 | \startsavinginserts |
| 4374 | % |
| 4375 | % @item within a multitable starts a normal row. |
| 4376 | % We use \def instead of \let so that if one of the multitable entries |
| 4377 | % contains an @itemize, we don't choke on the \item (seen as \crcr aka |
| 4378 | % \endtemplate) expanding \doitemize. |
| 4379 | \def\item{\crcr}% |
| 4380 | % |
| 4381 | \tolerance=9500 |
| 4382 | \hbadness=9500 |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 4383 | \parskip=0pt |
| 4384 | \parindent=6pt |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 4385 | \overfullrule=0pt |
| 4386 | \global\colcount=0 |
| 4387 | % |
| 4388 | \everycr = {% |
| 4389 | \noalign{% |
| 4390 | \global\everytab={}% Reset from possible headitem. |
| 4391 | \global\colcount=0 % Reset the column counter. |
| 4392 | % |
| 4393 | % Check for saved footnotes, etc.: |
| 4394 | \checkinserts |
| 4395 | % |
| 4396 | % Perhaps a \nobreak, then reset: |
| 4397 | \headitemcrhook |
| 4398 | \global\let\headitemcrhook=\relax |
| 4399 | }% |
| 4400 | }% |
| 4401 | % |
| 4402 | \parsearg\domultitable |
| 4403 | } |
| 4404 | \def\domultitable#1{% |
| 4405 | % To parse everything between @multitable and @item: |
| 4406 | \setuptable#1 \endsetuptable |
| 4407 | % |
| 4408 | % This preamble sets up a generic column definition, which will |
| 4409 | % be used as many times as user calls for columns. |
| 4410 | % \vtop will set a single line and will also let text wrap and |
| 4411 | % continue for many paragraphs if desired. |
| 4412 | \halign\bgroup &% |
| 4413 | \global\advance\colcount by 1 |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 4414 | \strut |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 4415 | \vtop{% |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 4416 | \advance\hsize by -1\leftskip |
| 4417 | % Find the correct column width |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 4418 | \hsize=\expandafter\csname col\the\colcount\endcsname |
| 4419 | % |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 4420 | \rightskip=0pt |
| 4421 | \ifnum\colcount=1 |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 4422 | \advance\hsize by\leftskip % Add indent of surrounding text |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 4423 | \else |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 4424 | % In order to keep entries from bumping into each other. |
| 4425 | \leftskip=12pt |
| 4426 | \ifsetpercent \else |
| 4427 | % If a template has been used |
| 4428 | \advance\hsize by \leftskip |
| 4429 | \fi |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 4430 | \fi |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 4431 | \noindent\ignorespaces##\unskip\strut |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 4432 | }\cr |
| 4433 | } |
| 4434 | \def\Emultitable{% |
| 4435 | \crcr |
| 4436 | \egroup % end the \halign |
| 4437 | \global\setpercentfalse |
| 4438 | } |
| 4439 | |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 4440 | |
| 4441 | \message{conditionals,} |
| 4442 | |
| 4443 | % @iftex, @ifnotdocbook, @ifnothtml, @ifnotinfo, @ifnotplaintext, |
| 4444 | % @ifnotxml always succeed. They currently do nothing; we don't |
| 4445 | % attempt to check whether the conditionals are properly nested. But we |
| 4446 | % have to remember that they are conditionals, so that @end doesn't |
| 4447 | % attempt to close an environment group. |
| 4448 | % |
| 4449 | \def\makecond#1{% |
| 4450 | \expandafter\let\csname #1\endcsname = \relax |
| 4451 | \expandafter\let\csname iscond.#1\endcsname = 1 |
| 4452 | } |
| 4453 | \makecond{iftex} |
| 4454 | \makecond{ifnotdocbook} |
| 4455 | \makecond{ifnothtml} |
| 4456 | \makecond{ifnotinfo} |
| 4457 | \makecond{ifnotplaintext} |
| 4458 | \makecond{ifnotxml} |
| 4459 | |
| 4460 | % Ignore @ignore, @ifhtml, @ifinfo, and the like. |
| 4461 | % |
| 4462 | \def\direntry{\doignore{direntry}} |
| 4463 | \def\documentdescription{\doignore{documentdescription}} |
| 4464 | \def\docbook{\doignore{docbook}} |
| 4465 | \def\html{\doignore{html}} |
| 4466 | \def\ifdocbook{\doignore{ifdocbook}} |
| 4467 | \def\ifhtml{\doignore{ifhtml}} |
| 4468 | \def\ifinfo{\doignore{ifinfo}} |
| 4469 | \def\ifnottex{\doignore{ifnottex}} |
| 4470 | \def\ifplaintext{\doignore{ifplaintext}} |
| 4471 | \def\ifxml{\doignore{ifxml}} |
| 4472 | \def\ignore{\doignore{ignore}} |
| 4473 | \def\menu{\doignore{menu}} |
| 4474 | \def\xml{\doignore{xml}} |
| 4475 | |
| 4476 | % Ignore text until a line `@end #1', keeping track of nested conditionals. |
| 4477 | % |
| 4478 | % A count to remember the depth of nesting. |
| 4479 | \newcount\doignorecount |
| 4480 | |
| 4481 | \def\doignore#1{\begingroup |
| 4482 | % Scan in ``verbatim'' mode: |
| 4483 | \obeylines |
| 4484 | \catcode`\@ = \other |
| 4485 | \catcode`\{ = \other |
| 4486 | \catcode`\} = \other |
| 4487 | % |
| 4488 | % Make sure that spaces turn into tokens that match what \doignoretext wants. |
| 4489 | \spaceisspace |
| 4490 | % |
| 4491 | % Count number of #1's that we've seen. |
| 4492 | \doignorecount = 0 |
| 4493 | % |
| 4494 | % Swallow text until we reach the matching `@end #1'. |
| 4495 | \dodoignore{#1}% |
| 4496 | } |
| 4497 | |
| 4498 | { \catcode`_=11 % We want to use \_STOP_ which cannot appear in texinfo source. |
| 4499 | \obeylines % |
| 4500 | % |
| 4501 | \gdef\dodoignore#1{% |
| 4502 | % #1 contains the command name as a string, e.g., `ifinfo'. |
| 4503 | % |
| 4504 | % Define a command to find the next `@end #1'. |
| 4505 | \long\def\doignoretext##1^^M@end #1{% |
| 4506 | \doignoretextyyy##1^^M@#1\_STOP_}% |
| 4507 | % |
| 4508 | % And this command to find another #1 command, at the beginning of a |
| 4509 | % line. (Otherwise, we would consider a line `@c @ifset', for |
| 4510 | % example, to count as an @ifset for nesting.) |
| 4511 | \long\def\doignoretextyyy##1^^M@#1##2\_STOP_{\doignoreyyy{##2}\_STOP_}% |
| 4512 | % |
| 4513 | % And now expand that command. |
| 4514 | \doignoretext ^^M% |
| 4515 | }% |
| 4516 | } |
| 4517 | |
| 4518 | \def\doignoreyyy#1{% |
| 4519 | \def\temp{#1}% |
| 4520 | \ifx\temp\empty % Nothing found. |
| 4521 | \let\next\doignoretextzzz |
| 4522 | \else % Found a nested condition, ... |
| 4523 | \advance\doignorecount by 1 |
| 4524 | \let\next\doignoretextyyy % ..., look for another. |
| 4525 | % If we're here, #1 ends with ^^M\ifinfo (for example). |
| 4526 | \fi |
| 4527 | \next #1% the token \_STOP_ is present just after this macro. |
| 4528 | } |
| 4529 | |
| 4530 | % We have to swallow the remaining "\_STOP_". |
| 4531 | % |
| 4532 | \def\doignoretextzzz#1{% |
| 4533 | \ifnum\doignorecount = 0 % We have just found the outermost @end. |
| 4534 | \let\next\enddoignore |
| 4535 | \else % Still inside a nested condition. |
| 4536 | \advance\doignorecount by -1 |
| 4537 | \let\next\doignoretext % Look for the next @end. |
| 4538 | \fi |
| 4539 | \next |
| 4540 | } |
| 4541 | |
| 4542 | % Finish off ignored text. |
| 4543 | { \obeylines% |
| 4544 | % Ignore anything after the last `@end #1'; this matters in verbatim |
| 4545 | % environments, where otherwise the newline after an ignored conditional |
| 4546 | % would result in a blank line in the output. |
| 4547 | \gdef\enddoignore#1^^M{\endgroup\ignorespaces}% |
| 4548 | } |
| 4549 | |
| 4550 | |
| 4551 | % @set VAR sets the variable VAR to an empty value. |
| 4552 | % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE. |
| 4553 | % |
| 4554 | % Since we want to separate VAR from REST-OF-LINE (which might be |
| 4555 | % empty), we can't just use \parsearg; we have to insert a space of our |
| 4556 | % own to delimit the rest of the line, and then take it out again if we |
| 4557 | % didn't need it. |
| 4558 | % We rely on the fact that \parsearg sets \catcode`\ =10. |
| 4559 | % |
| 4560 | \parseargdef\set{\setyyy#1 \endsetyyy} |
| 4561 | \def\setyyy#1 #2\endsetyyy{% |
| 4562 | {% |
| 4563 | \makevalueexpandable |
| 4564 | \def\temp{#2}% |
| 4565 | \edef\next{\gdef\makecsname{SET#1}}% |
| 4566 | \ifx\temp\empty |
| 4567 | \next{}% |
| 4568 | \else |
| 4569 | \setzzz#2\endsetzzz |
| 4570 | \fi |
| 4571 | }% |
| 4572 | } |
| 4573 | % Remove the trailing space \setxxx inserted. |
| 4574 | \def\setzzz#1 \endsetzzz{\next{#1}} |
| 4575 | |
| 4576 | % @clear VAR clears (i.e., unsets) the variable VAR. |
| 4577 | % |
| 4578 | \parseargdef\clear{% |
| 4579 | {% |
| 4580 | \makevalueexpandable |
| 4581 | \global\expandafter\let\csname SET#1\endcsname=\relax |
| 4582 | }% |
| 4583 | } |
| 4584 | |
| 4585 | % @value{foo} gets the text saved in variable foo. |
| 4586 | \def\value{\begingroup\makevalueexpandable\valuexxx} |
| 4587 | \def\valuexxx#1{\expandablevalue{#1}\endgroup} |
| 4588 | { |
| 4589 | \catcode`\-=\active \catcode`\_=\active |
| 4590 | % |
| 4591 | \gdef\makevalueexpandable{% |
| 4592 | \let\value = \expandablevalue |
| 4593 | % We don't want these characters active, ... |
| 4594 | \catcode`\-=\other \catcode`\_=\other |
| 4595 | % ..., but we might end up with active ones in the argument if |
| 4596 | % we're called from @code, as @code{@value{foo-bar_}}, though. |
| 4597 | % So \let them to their normal equivalents. |
| 4598 | \let-\normaldash \let_\normalunderscore |
| 4599 | } |
| 4600 | } |
| 4601 | |
| 4602 | \def\expandablevalue#1{% |
| 4603 | \expandafter\ifx\csname SET#1\endcsname\relax |
| 4604 | {[No value for ``#1'']}% |
| 4605 | \message{Variable `#1', used in @value, is not set.}% |
| 4606 | \else |
| 4607 | \csname SET#1\endcsname |
| 4608 | \fi |
| 4609 | } |
| 4610 | |
| 4611 | % Like \expandablevalue, but completely expandable (the \message in the |
| 4612 | % definition above operates at the execution level of TeX). Used when |
| 4613 | % writing to auxiliary files, due to the expansion that \write does. |
| 4614 | % If flag is undefined, pass through an unexpanded @value command: maybe it |
| 4615 | % will be set by the time it is read back in. |
| 4616 | % |
| 4617 | % NB flag names containing - or _ may not work here. |
| 4618 | \def\dummyvalue#1{% |
| 4619 | \expandafter\ifx\csname SET#1\endcsname\relax |
| 4620 | \string\value{#1}% |
| 4621 | \else |
| 4622 | \csname SET#1\endcsname |
| 4623 | \fi |
| 4624 | } |
| 4625 | |
| 4626 | % Used for @value's in index entries to form the sort key: expand the @value |
| 4627 | % if possible, otherwise sort late. |
| 4628 | \def\indexnofontsvalue#1{% |
| 4629 | \expandafter\ifx\csname SET#1\endcsname\relax |
| 4630 | ZZZZZZZ% |
| 4631 | \else |
| 4632 | \csname SET#1\endcsname |
| 4633 | \fi |
| 4634 | } |
| 4635 | |
| 4636 | % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined |
| 4637 | % with @set. |
| 4638 | % |
| 4639 | % To get the special treatment we need for `@end ifset,' we call |
| 4640 | % \makecond and then redefine. |
| 4641 | % |
| 4642 | \makecond{ifset} |
| 4643 | \def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}} |
| 4644 | \def\doifset#1#2{% |
| 4645 | {% |
| 4646 | \makevalueexpandable |
| 4647 | \let\next=\empty |
| 4648 | \expandafter\ifx\csname SET#2\endcsname\relax |
| 4649 | #1% If not set, redefine \next. |
| 4650 | \fi |
| 4651 | \expandafter |
| 4652 | }\next |
| 4653 | } |
| 4654 | \def\ifsetfail{\doignore{ifset}} |
| 4655 | |
| 4656 | % @ifclear VAR ... @end executes the `...' iff VAR has never been |
| 4657 | % defined with @set, or has been undefined with @clear. |
| 4658 | % |
| 4659 | % The `\else' inside the `\doifset' parameter is a trick to reuse the |
| 4660 | % above code: if the variable is not set, do nothing, if it is set, |
| 4661 | % then redefine \next to \ifclearfail. |
| 4662 | % |
| 4663 | \makecond{ifclear} |
| 4664 | \def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}} |
| 4665 | \def\ifclearfail{\doignore{ifclear}} |
| 4666 | |
| 4667 | % @ifcommandisdefined CMD ... @end executes the `...' if CMD (written |
| 4668 | % without the @) is in fact defined. We can only feasibly check at the |
| 4669 | % TeX level, so something like `mathcode' is going to considered |
| 4670 | % defined even though it is not a Texinfo command. |
| 4671 | % |
| 4672 | \makecond{ifcommanddefined} |
| 4673 | \def\ifcommanddefined{\parsearg{\doifcmddefined{\let\next=\ifcmddefinedfail}}} |
| 4674 | % |
| 4675 | \def\doifcmddefined#1#2{{% |
| 4676 | \makevalueexpandable |
| 4677 | \let\next=\empty |
| 4678 | \expandafter\ifx\csname #2\endcsname\relax |
| 4679 | #1% If not defined, \let\next as above. |
| 4680 | \fi |
| 4681 | \expandafter |
| 4682 | }\next |
| 4683 | } |
| 4684 | \def\ifcmddefinedfail{\doignore{ifcommanddefined}} |
| 4685 | |
| 4686 | % @ifcommandnotdefined CMD ... handled similar to @ifclear above. |
| 4687 | \makecond{ifcommandnotdefined} |
| 4688 | \def\ifcommandnotdefined{% |
| 4689 | \parsearg{\doifcmddefined{\else \let\next=\ifcmdnotdefinedfail}}} |
| 4690 | \def\ifcmdnotdefinedfail{\doignore{ifcommandnotdefined}} |
| 4691 | |
| 4692 | % Set the `txicommandconditionals' variable, so documents have a way to |
| 4693 | % test if the @ifcommand...defined conditionals are available. |
| 4694 | \set txicommandconditionals |
| 4695 | |
| 4696 | % @dircategory CATEGORY -- specify a category of the dir file |
| 4697 | % which this file should belong to. Ignore this in TeX. |
| 4698 | \let\dircategory=\comment |
| 4699 | |
| 4700 | % @defininfoenclose. |
| 4701 | \let\definfoenclose=\comment |
| 4702 | |
| 4703 | |
| 4704 | \message{indexing,} |
| 4705 | % Index generation facilities |
| 4706 | |
| 4707 | % Define \newwrite to be identical to plain tex's \newwrite |
| 4708 | % except not \outer, so it can be used within macros and \if's. |
| 4709 | \edef\newwrite{\makecsname{ptexnewwrite}} |
| 4710 | |
| 4711 | % \newindex {foo} defines an index named IX. |
| 4712 | % It automatically defines \IXindex such that |
| 4713 | % \IXindex ...rest of line... puts an entry in the index IX. |
| 4714 | % It also defines \IXindfile to be the number of the output channel for |
| 4715 | % the file that accumulates this index. The file's extension is IX. |
| 4716 | % The name of an index should be no more than 2 characters long |
| 4717 | % for the sake of vms. |
| 4718 | % |
| 4719 | \def\newindex#1{% |
| 4720 | \expandafter\chardef\csname#1indfile\endcsname=0 |
| 4721 | \expandafter\xdef\csname#1index\endcsname{% % Define @#1index |
| 4722 | \noexpand\doindex{#1}} |
| 4723 | } |
| 4724 | |
| 4725 | % @defindex foo == \newindex{foo} |
| 4726 | % |
| 4727 | \def\defindex{\parsearg\newindex} |
| 4728 | |
| 4729 | % Define @defcodeindex, like @defindex except put all entries in @code. |
| 4730 | % |
| 4731 | \def\defcodeindex{\parsearg\newcodeindex} |
| 4732 | % |
| 4733 | \def\newcodeindex#1{% |
| 4734 | \expandafter\chardef\csname#1indfile\endcsname=0 |
| 4735 | \expandafter\xdef\csname#1index\endcsname{% |
| 4736 | \noexpand\docodeindex{#1}}% |
| 4737 | } |
| 4738 | |
| 4739 | % The default indices: |
| 4740 | \newindex{cp}% concepts, |
| 4741 | \newcodeindex{fn}% functions, |
| 4742 | \newcodeindex{vr}% variables, |
| 4743 | \newcodeindex{tp}% types, |
| 4744 | \newcodeindex{ky}% keys |
| 4745 | \newcodeindex{pg}% and programs. |
| 4746 | |
| 4747 | |
| 4748 | % @synindex foo bar makes index foo feed into index bar. |
| 4749 | % Do this instead of @defindex foo if you don't want it as a separate index. |
| 4750 | % |
| 4751 | % @syncodeindex foo bar similar, but put all entries made for index foo |
| 4752 | % inside @code. |
| 4753 | % |
| 4754 | \def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}} |
| 4755 | \def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}} |
| 4756 | |
| 4757 | % #1 is \doindex or \docodeindex, #2 the index getting redefined (foo), |
| 4758 | % #3 the target index (bar). |
| 4759 | \def\dosynindex#1#2#3{% |
| 4760 | \requireopenindexfile{#3}% |
| 4761 | % redefine \fooindfile: |
| 4762 | \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname |
| 4763 | \expandafter\let\csname#2indfile\endcsname=\temp |
| 4764 | % redefine \fooindex: |
| 4765 | \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}% |
| 4766 | } |
| 4767 | |
| 4768 | % Define \doindex, the driver for all index macros. |
| 4769 | % Argument #1 is generated by the calling \fooindex macro, |
| 4770 | % and it is the two-letter name of the index. |
| 4771 | |
| 4772 | \def\doindex#1{\edef\indexname{#1}\parsearg\doindexxxx} |
| 4773 | \def\doindexxxx #1{\doind{\indexname}{#1}} |
| 4774 | |
| 4775 | % like the previous two, but they put @code around the argument. |
| 4776 | \def\docodeindex#1{\edef\indexname{#1}\parsearg\docodeindexxxx} |
| 4777 | \def\docodeindexxxx #1{\docind{\indexname}{#1}} |
| 4778 | |
| 4779 | |
| 4780 | % Used for the aux, toc and index files to prevent expansion of Texinfo |
| 4781 | % commands. |
| 4782 | % |
| 4783 | \def\atdummies{% |
| 4784 | \definedummyletter\@% |
| 4785 | \definedummyletter\ % |
| 4786 | \definedummyletter\{% |
| 4787 | \definedummyletter\}% |
| 4788 | \definedummyletter\&% |
| 4789 | % |
| 4790 | % Do the redefinitions. |
| 4791 | \definedummies |
| 4792 | \otherbackslash |
| 4793 | } |
| 4794 | |
| 4795 | % \definedummyword defines \#1 as \string\#1\space, thus effectively |
| 4796 | % preventing its expansion. This is used only for control words, |
| 4797 | % not control letters, because the \space would be incorrect for |
| 4798 | % control characters, but is needed to separate the control word |
| 4799 | % from whatever follows. |
| 4800 | % |
| 4801 | % These can be used both for control words that take an argument and |
| 4802 | % those that do not. If it is followed by {arg} in the input, then |
| 4803 | % that will dutifully get written to the index (or wherever). |
| 4804 | % |
| 4805 | % For control letters, we have \definedummyletter, which omits the |
| 4806 | % space. |
| 4807 | % |
| 4808 | \def\definedummyword #1{\def#1{\string#1\space}}% |
| 4809 | \def\definedummyletter#1{\def#1{\string#1}}% |
| 4810 | \let\definedummyaccent\definedummyletter |
| 4811 | |
| 4812 | % Called from \atdummies to prevent the expansion of commands. |
| 4813 | % |
| 4814 | \def\definedummies{% |
| 4815 | % |
| 4816 | \let\commondummyword\definedummyword |
| 4817 | \let\commondummyletter\definedummyletter |
| 4818 | \let\commondummyaccent\definedummyaccent |
| 4819 | \commondummiesnofonts |
| 4820 | % |
| 4821 | \definedummyletter\_% |
| 4822 | \definedummyletter\-% |
| 4823 | % |
| 4824 | % Non-English letters. |
| 4825 | \definedummyword\AA |
| 4826 | \definedummyword\AE |
| 4827 | \definedummyword\DH |
| 4828 | \definedummyword\L |
| 4829 | \definedummyword\O |
| 4830 | \definedummyword\OE |
| 4831 | \definedummyword\TH |
| 4832 | \definedummyword\aa |
| 4833 | \definedummyword\ae |
| 4834 | \definedummyword\dh |
| 4835 | \definedummyword\exclamdown |
| 4836 | \definedummyword\l |
| 4837 | \definedummyword\o |
| 4838 | \definedummyword\oe |
| 4839 | \definedummyword\ordf |
| 4840 | \definedummyword\ordm |
| 4841 | \definedummyword\questiondown |
| 4842 | \definedummyword\ss |
| 4843 | \definedummyword\th |
| 4844 | % |
| 4845 | % Although these internal commands shouldn't show up, sometimes they do. |
| 4846 | \definedummyword\bf |
| 4847 | \definedummyword\gtr |
| 4848 | \definedummyword\hat |
| 4849 | \definedummyword\less |
| 4850 | \definedummyword\sf |
| 4851 | \definedummyword\sl |
| 4852 | \definedummyword\tclose |
| 4853 | \definedummyword\tt |
| 4854 | % |
| 4855 | \definedummyword\LaTeX |
| 4856 | \definedummyword\TeX |
| 4857 | % |
| 4858 | % Assorted special characters. |
| 4859 | \definedummyword\ampchar |
| 4860 | \definedummyword\atchar |
| 4861 | \definedummyword\arrow |
| 4862 | \definedummyword\backslashchar |
| 4863 | \definedummyword\bullet |
| 4864 | \definedummyword\comma |
| 4865 | \definedummyword\copyright |
| 4866 | \definedummyword\registeredsymbol |
| 4867 | \definedummyword\dots |
| 4868 | \definedummyword\enddots |
| 4869 | \definedummyword\entrybreak |
| 4870 | \definedummyword\equiv |
| 4871 | \definedummyword\error |
| 4872 | \definedummyword\euro |
| 4873 | \definedummyword\expansion |
| 4874 | \definedummyword\geq |
| 4875 | \definedummyword\guillemetleft |
| 4876 | \definedummyword\guillemetright |
| 4877 | \definedummyword\guilsinglleft |
| 4878 | \definedummyword\guilsinglright |
| 4879 | \definedummyword\lbracechar |
| 4880 | \definedummyword\leq |
| 4881 | \definedummyword\mathopsup |
| 4882 | \definedummyword\minus |
| 4883 | \definedummyword\ogonek |
| 4884 | \definedummyword\pounds |
| 4885 | \definedummyword\point |
| 4886 | \definedummyword\print |
| 4887 | \definedummyword\quotedblbase |
| 4888 | \definedummyword\quotedblleft |
| 4889 | \definedummyword\quotedblright |
| 4890 | \definedummyword\quoteleft |
| 4891 | \definedummyword\quoteright |
| 4892 | \definedummyword\quotesinglbase |
| 4893 | \definedummyword\rbracechar |
| 4894 | \definedummyword\result |
| 4895 | \definedummyword\sub |
| 4896 | \definedummyword\sup |
| 4897 | \definedummyword\textdegree |
| 4898 | % |
| 4899 | \definedummyword\subentry |
| 4900 | % |
| 4901 | % We want to disable all macros so that they are not expanded by \write. |
| 4902 | \macrolist |
| 4903 | \let\value\dummyvalue |
| 4904 | % |
| 4905 | \normalturnoffactive |
| 4906 | } |
| 4907 | |
| 4908 | % \commondummiesnofonts: common to \definedummies and \indexnofonts. |
| 4909 | % Define \commondummyletter, \commondummyaccent and \commondummyword before |
| 4910 | % using. Used for accents, font commands, and various control letters. |
| 4911 | % |
| 4912 | \def\commondummiesnofonts{% |
| 4913 | % Control letters and accents. |
| 4914 | \commondummyletter\!% |
| 4915 | \commondummyaccent\"% |
| 4916 | \commondummyaccent\'% |
| 4917 | \commondummyletter\*% |
| 4918 | \commondummyaccent\,% |
| 4919 | \commondummyletter\.% |
| 4920 | \commondummyletter\/% |
| 4921 | \commondummyletter\:% |
| 4922 | \commondummyaccent\=% |
| 4923 | \commondummyletter\?% |
| 4924 | \commondummyaccent\^% |
| 4925 | \commondummyaccent\`% |
| 4926 | \commondummyaccent\~% |
| 4927 | \commondummyword\u |
| 4928 | \commondummyword\v |
| 4929 | \commondummyword\H |
| 4930 | \commondummyword\dotaccent |
| 4931 | \commondummyword\ogonek |
| 4932 | \commondummyword\ringaccent |
| 4933 | \commondummyword\tieaccent |
| 4934 | \commondummyword\ubaraccent |
| 4935 | \commondummyword\udotaccent |
| 4936 | \commondummyword\dotless |
| 4937 | % |
| 4938 | % Texinfo font commands. |
| 4939 | \commondummyword\b |
| 4940 | \commondummyword\i |
| 4941 | \commondummyword\r |
| 4942 | \commondummyword\sansserif |
| 4943 | \commondummyword\sc |
| 4944 | \commondummyword\slanted |
| 4945 | \commondummyword\t |
| 4946 | % |
| 4947 | % Commands that take arguments. |
| 4948 | \commondummyword\abbr |
| 4949 | \commondummyword\acronym |
| 4950 | \commondummyword\anchor |
| 4951 | \commondummyword\cite |
| 4952 | \commondummyword\code |
| 4953 | \commondummyword\command |
| 4954 | \commondummyword\dfn |
| 4955 | \commondummyword\dmn |
| 4956 | \commondummyword\email |
| 4957 | \commondummyword\emph |
| 4958 | \commondummyword\env |
| 4959 | \commondummyword\file |
| 4960 | \commondummyword\image |
| 4961 | \commondummyword\indicateurl |
| 4962 | \commondummyword\inforef |
| 4963 | \commondummyword\kbd |
| 4964 | \commondummyword\key |
| 4965 | \commondummyword\math |
| 4966 | \commondummyword\option |
| 4967 | \commondummyword\pxref |
| 4968 | \commondummyword\ref |
| 4969 | \commondummyword\samp |
| 4970 | \commondummyword\strong |
| 4971 | \commondummyword\tie |
| 4972 | \commondummyword\U |
| 4973 | \commondummyword\uref |
| 4974 | \commondummyword\url |
| 4975 | \commondummyword\var |
| 4976 | \commondummyword\verb |
| 4977 | \commondummyword\w |
| 4978 | \commondummyword\xref |
| 4979 | } |
| 4980 | |
| 4981 | \let\indexlbrace\relax |
| 4982 | \let\indexrbrace\relax |
| 4983 | \let\indexatchar\relax |
| 4984 | \let\indexbackslash\relax |
| 4985 | |
| 4986 | {\catcode`\@=0 |
| 4987 | \catcode`\\=13 |
| 4988 | @gdef@backslashdisappear{@def\{}} |
| 4989 | } |
| 4990 | |
| 4991 | { |
| 4992 | \catcode`\<=13 |
| 4993 | \catcode`\-=13 |
| 4994 | \catcode`\`=13 |
| 4995 | \gdef\indexnonalnumdisappear{% |
| 4996 | \expandafter\ifx\csname SETtxiindexlquoteignore\endcsname\relax\else |
| 4997 | % @set txiindexlquoteignore makes us ignore left quotes in the sort term. |
| 4998 | % (Introduced for FSFS 2nd ed.) |
| 4999 | \let`=\empty |
| 5000 | \fi |
| 5001 | % |
| 5002 | \expandafter\ifx\csname SETtxiindexbackslashignore\endcsname\relax\else |
| 5003 | \backslashdisappear |
| 5004 | \fi |
| 5005 | % |
| 5006 | \expandafter\ifx\csname SETtxiindexhyphenignore\endcsname\relax\else |
| 5007 | \def-{}% |
| 5008 | \fi |
| 5009 | \expandafter\ifx\csname SETtxiindexlessthanignore\endcsname\relax\else |
| 5010 | \def<{}% |
| 5011 | \fi |
| 5012 | \expandafter\ifx\csname SETtxiindexatsignignore\endcsname\relax\else |
| 5013 | \def\@{}% |
| 5014 | \fi |
| 5015 | } |
| 5016 | |
| 5017 | \gdef\indexnonalnumreappear{% |
| 5018 | \let-\normaldash |
| 5019 | \let<\normalless |
| 5020 | } |
| 5021 | } |
| 5022 | |
| 5023 | |
| 5024 | % \indexnofonts is used when outputting the strings to sort the index |
| 5025 | % by, and when constructing control sequence names. It eliminates all |
| 5026 | % control sequences and just writes whatever the best ASCII sort string |
| 5027 | % would be for a given command (usually its argument). |
| 5028 | % |
| 5029 | \def\indexnofonts{% |
| 5030 | % Accent commands should become @asis. |
| 5031 | \def\commondummyaccent##1{\let##1\asis}% |
| 5032 | % We can just ignore other control letters. |
| 5033 | \def\commondummyletter##1{\let##1\empty}% |
| 5034 | % All control words become @asis by default; overrides below. |
| 5035 | \let\commondummyword\commondummyaccent |
| 5036 | \commondummiesnofonts |
| 5037 | % |
| 5038 | % Don't no-op \tt, since it isn't a user-level command |
| 5039 | % and is used in the definitions of the active chars like <, >, |, etc. |
| 5040 | % Likewise with the other plain tex font commands. |
| 5041 | %\let\tt=\asis |
| 5042 | % |
| 5043 | \def\ { }% |
| 5044 | \def\@{@}% |
| 5045 | \def\_{\normalunderscore}% |
| 5046 | \def\-{}% @- shouldn't affect sorting |
| 5047 | % |
| 5048 | \uccode`\1=`\{ \uppercase{\def\{{1}}% |
| 5049 | \uccode`\1=`\} \uppercase{\def\}{1}}% |
| 5050 | \let\lbracechar\{% |
| 5051 | \let\rbracechar\}% |
| 5052 | % |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 5053 | % Non-English letters. |
| 5054 | \def\AA{AA}% |
| 5055 | \def\AE{AE}% |
| 5056 | \def\DH{DZZ}% |
| 5057 | \def\L{L}% |
| 5058 | \def\OE{OE}% |
| 5059 | \def\O{O}% |
| 5060 | \def\TH{TH}% |
| 5061 | \def\aa{aa}% |
| 5062 | \def\ae{ae}% |
| 5063 | \def\dh{dzz}% |
| 5064 | \def\exclamdown{!}% |
| 5065 | \def\l{l}% |
| 5066 | \def\oe{oe}% |
| 5067 | \def\ordf{a}% |
| 5068 | \def\ordm{o}% |
| 5069 | \def\o{o}% |
| 5070 | \def\questiondown{?}% |
| 5071 | \def\ss{ss}% |
| 5072 | \def\th{th}% |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 5073 | % |
| 5074 | \let\do\indexnofontsdef |
| 5075 | % |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 5076 | \do\LaTeX{LaTeX}% |
| 5077 | \do\TeX{TeX}% |
| 5078 | % |
| 5079 | % Assorted special characters. |
| 5080 | \do\atchar{@}% |
| 5081 | \do\arrow{->}% |
| 5082 | \do\bullet{bullet}% |
| 5083 | \do\comma{,}% |
| 5084 | \do\copyright{copyright}% |
| 5085 | \do\dots{...}% |
| 5086 | \do\enddots{...}% |
| 5087 | \do\equiv{==}% |
| 5088 | \do\error{error}% |
| 5089 | \do\euro{euro}% |
| 5090 | \do\expansion{==>}% |
| 5091 | \do\geq{>=}% |
| 5092 | \do\guillemetleft{<<}% |
| 5093 | \do\guillemetright{>>}% |
| 5094 | \do\guilsinglleft{<}% |
| 5095 | \do\guilsinglright{>}% |
| 5096 | \do\leq{<=}% |
| 5097 | \do\lbracechar{\{}% |
| 5098 | \do\minus{-}% |
| 5099 | \do\point{.}% |
| 5100 | \do\pounds{pounds}% |
| 5101 | \do\print{-|}% |
| 5102 | \do\quotedblbase{"}% |
| 5103 | \do\quotedblleft{"}% |
| 5104 | \do\quotedblright{"}% |
| 5105 | \do\quoteleft{`}% |
| 5106 | \do\quoteright{'}% |
| 5107 | \do\quotesinglbase{,}% |
| 5108 | \do\rbracechar{\}}% |
| 5109 | \do\registeredsymbol{R}% |
| 5110 | \do\result{=>}% |
| 5111 | \do\textdegree{o}% |
| 5112 | % |
| 5113 | % We need to get rid of all macros, leaving only the arguments (if present). |
| 5114 | % Of course this is not nearly correct, but it is the best we can do for now. |
| 5115 | % makeinfo does not expand macros in the argument to @deffn, which ends up |
| 5116 | % writing an index entry, and texindex isn't prepared for an index sort entry |
| 5117 | % that starts with \. |
| 5118 | % |
| 5119 | % Since macro invocations are followed by braces, we can just redefine them |
| 5120 | % to take a single TeX argument. The case of a macro invocation that |
| 5121 | % goes to end-of-line is not handled. |
| 5122 | % |
| 5123 | \macrolist |
| 5124 | \let\value\indexnofontsvalue |
| 5125 | } |
| 5126 | |
| 5127 | % Give the control sequence a definition that removes the {} that follows |
| 5128 | % its use, e.g. @AA{} -> AA |
| 5129 | \def\indexnofontsdef#1#2{\def#1##1{#2}}% |
| 5130 | |
| 5131 | |
| 5132 | |
| 5133 | |
| 5134 | % #1 is the index name, #2 is the entry text. |
| 5135 | \def\doind#1#2{% |
| 5136 | \iflinks |
| 5137 | {% |
| 5138 | % |
| 5139 | \requireopenindexfile{#1}% |
| 5140 | \edef\writeto{\csname#1indfile\endcsname}% |
| 5141 | % |
| 5142 | \def\indextext{#2}% |
| 5143 | \safewhatsit\doindwrite |
| 5144 | }% |
| 5145 | \fi |
| 5146 | } |
| 5147 | |
| 5148 | % Same as \doind, but for code indices |
| 5149 | \def\docind#1#2{% |
| 5150 | \iflinks |
| 5151 | {% |
| 5152 | % |
| 5153 | \requireopenindexfile{#1}% |
| 5154 | \edef\writeto{\csname#1indfile\endcsname}% |
| 5155 | % |
| 5156 | \def\indextext{#2}% |
| 5157 | \safewhatsit\docindwrite |
| 5158 | }% |
| 5159 | \fi |
| 5160 | } |
| 5161 | |
| 5162 | % Check if an index file has been opened, and if not, open it. |
| 5163 | \def\requireopenindexfile#1{% |
| 5164 | \ifnum\csname #1indfile\endcsname=0 |
| 5165 | \expandafter\newwrite \csname#1indfile\endcsname |
| 5166 | \edef\suffix{#1}% |
| 5167 | % A .fls suffix would conflict with the file extension for the output |
| 5168 | % of -recorder, so use .f1s instead. |
| 5169 | \ifx\suffix\indexisfl\def\suffix{f1}\fi |
| 5170 | % Open the file |
| 5171 | \immediate\openout\csname#1indfile\endcsname \jobname.\suffix |
| 5172 | % Using \immediate above here prevents an object entering into the current |
| 5173 | % box, which could confound checks such as those in \safewhatsit for |
| 5174 | % preceding skips. |
| 5175 | \typeout{Writing index file \jobname.\suffix}% |
| 5176 | \fi} |
| 5177 | \def\indexisfl{fl} |
| 5178 | |
| 5179 | % Definition for writing index entry sort key. |
| 5180 | { |
| 5181 | \catcode`\-=13 |
| 5182 | \gdef\indexwritesortas{% |
| 5183 | \begingroup |
| 5184 | \indexnonalnumreappear |
| 5185 | \indexwritesortasxxx} |
| 5186 | \gdef\indexwritesortasxxx#1{% |
| 5187 | \xdef\indexsortkey{#1}\endgroup} |
| 5188 | } |
| 5189 | |
| 5190 | \def\indexwriteseealso#1{ |
| 5191 | \gdef\pagenumbertext{\string\seealso{#1}}% |
| 5192 | } |
| 5193 | \def\indexwriteseeentry#1{ |
| 5194 | \gdef\pagenumbertext{\string\seeentry{#1}}% |
| 5195 | } |
| 5196 | |
| 5197 | % The default definitions |
| 5198 | \def\sortas#1{}% |
| 5199 | \def\seealso#1{\i{\putwordSeeAlso}\ #1}% for sorted index file only |
| 5200 | \def\putwordSeeAlso{See also} |
| 5201 | \def\seeentry#1{\i{\putwordSee}\ #1}% for sorted index file only |
| 5202 | |
| 5203 | |
| 5204 | % Given index entry text like "aaa @subentry bbb @sortas{ZZZ}": |
| 5205 | % * Set \bracedtext to "{aaa}{bbb}" |
| 5206 | % * Set \fullindexsortkey to "aaa @subentry ZZZ" |
| 5207 | % * If @seealso occurs, set \pagenumbertext |
| 5208 | % |
| 5209 | \def\splitindexentry#1{% |
| 5210 | \gdef\fullindexsortkey{}% |
| 5211 | \xdef\bracedtext{}% |
| 5212 | \def\sep{}% |
| 5213 | \def\seealso##1{}% |
| 5214 | \def\seeentry##1{}% |
| 5215 | \expandafter\doindexsegment#1\subentry\finish\subentry |
| 5216 | } |
| 5217 | |
| 5218 | % append the results from the next segment |
| 5219 | \def\doindexsegment#1\subentry{% |
| 5220 | \def\segment{#1}% |
| 5221 | \ifx\segment\isfinish |
| 5222 | \else |
| 5223 | % |
| 5224 | % Fully expand the segment, throwing away any @sortas directives, and |
| 5225 | % trim spaces. |
| 5226 | \edef\trimmed{\segment}% |
| 5227 | \edef\trimmed{\expandafter\eatspaces\expandafter{\trimmed}}% |
| 5228 | \ifincodeindex |
| 5229 | \edef\trimmed{\noexpand\code{\trimmed}}% |
| 5230 | \fi |
| 5231 | % |
| 5232 | \xdef\bracedtext{\bracedtext{\trimmed}}% |
| 5233 | % |
| 5234 | % Get the string to sort by. Process the segment with all |
| 5235 | % font commands turned off. |
| 5236 | \bgroup |
| 5237 | \let\sortas\indexwritesortas |
| 5238 | \let\seealso\indexwriteseealso |
| 5239 | \let\seeentry\indexwriteseeentry |
| 5240 | \indexnofonts |
| 5241 | % The braces around the commands are recognized by texindex. |
| 5242 | \def\lbracechar{{\string\indexlbrace}}% |
| 5243 | \def\rbracechar{{\string\indexrbrace}}% |
| 5244 | \let\{=\lbracechar |
| 5245 | \let\}=\rbracechar |
| 5246 | \def\@{{\string\indexatchar}}% |
| 5247 | \def\atchar##1{\@}% |
| 5248 | \def\backslashchar{{\string\indexbackslash}}% |
| 5249 | \uccode`\~=`\\ \uppercase{\let~\backslashchar}% |
| 5250 | % |
| 5251 | \let\indexsortkey\empty |
| 5252 | \global\let\pagenumbertext\empty |
| 5253 | % Execute the segment and throw away the typeset output. This executes |
| 5254 | % any @sortas or @seealso commands in this segment. |
| 5255 | \setbox\dummybox = \hbox{\segment}% |
| 5256 | \ifx\indexsortkey\empty{% |
| 5257 | \indexnonalnumdisappear |
| 5258 | \xdef\trimmed{\segment}% |
| 5259 | \xdef\trimmed{\expandafter\eatspaces\expandafter{\trimmed}}% |
| 5260 | \xdef\indexsortkey{\trimmed}% |
| 5261 | \ifx\indexsortkey\empty\xdef\indexsortkey{ }\fi |
| 5262 | }\fi |
| 5263 | % |
| 5264 | % Append to \fullindexsortkey. |
| 5265 | \edef\tmp{\gdef\noexpand\fullindexsortkey{% |
| 5266 | \fullindexsortkey\sep\indexsortkey}}% |
| 5267 | \tmp |
| 5268 | \egroup |
| 5269 | \def\sep{\subentry}% |
| 5270 | % |
| 5271 | \expandafter\doindexsegment |
| 5272 | \fi |
| 5273 | } |
| 5274 | \def\isfinish{\finish}% |
| 5275 | \newbox\dummybox % used above |
| 5276 | |
| 5277 | \let\subentry\relax |
| 5278 | |
| 5279 | % Use \ instead of @ in index files. To support old texi2dvi and texindex. |
| 5280 | % This works without changing the escape character used in the toc or aux |
| 5281 | % files because the index entries are fully expanded here, and \string uses |
| 5282 | % the current value of \escapechar. |
| 5283 | \def\escapeisbackslash{\escapechar=`\\} |
| 5284 | |
| 5285 | % Use \ in index files by default. texi2dvi didn't support @ as the escape |
| 5286 | % character (as it checked for "\entry" in the files, and not "@entry"). When |
| 5287 | % the new version of texi2dvi has had a chance to become more prevalent, then |
| 5288 | % the escape character can change back to @ again. This should be an easy |
| 5289 | % change to make now because both @ and \ are only used as escape characters in |
| 5290 | % index files, never standing for themselves. |
| 5291 | % |
| 5292 | \set txiindexescapeisbackslash |
| 5293 | |
| 5294 | % Write the entry in \indextext to the index file. |
| 5295 | % |
| 5296 | |
| 5297 | \newif\ifincodeindex |
| 5298 | \def\doindwrite{\incodeindexfalse\doindwritex} |
| 5299 | \def\docindwrite{\incodeindextrue\doindwritex} |
| 5300 | |
| 5301 | \def\doindwritex{% |
| 5302 | \maybemarginindex |
| 5303 | % |
| 5304 | \atdummies |
| 5305 | % |
| 5306 | \expandafter\ifx\csname SETtxiindexescapeisbackslash\endcsname\relax\else |
| 5307 | \escapeisbackslash |
| 5308 | \fi |
| 5309 | % |
| 5310 | % For texindex which always views { and } as separators. |
| 5311 | \def\{{\lbracechar{}}% |
| 5312 | \def\}{\rbracechar{}}% |
| 5313 | \uccode`\~=`\\ \uppercase{\def~{\backslashchar{}}}% |
| 5314 | % |
| 5315 | % Split the entry into primary entry and any subentries, and get the index |
| 5316 | % sort key. |
| 5317 | \splitindexentry\indextext |
| 5318 | % |
| 5319 | % Set up the complete index entry, with both the sort key and |
| 5320 | % the original text, including any font commands. We write |
| 5321 | % three arguments to \entry to the .?? file (four in the |
| 5322 | % subentry case), texindex reduces to two when writing the .??s |
| 5323 | % sorted result. |
| 5324 | % |
| 5325 | \edef\temp{% |
| 5326 | \write\writeto{% |
| 5327 | \string\entry{\fullindexsortkey}% |
| 5328 | {\ifx\pagenumbertext\empty\noexpand\folio\else\pagenumbertext\fi}% |
| 5329 | \bracedtext}% |
| 5330 | }% |
| 5331 | \temp |
| 5332 | } |
| 5333 | |
| 5334 | % Put the index entry in the margin if desired (undocumented). |
| 5335 | \def\maybemarginindex{% |
| 5336 | \ifx\SETmarginindex\relax\else |
| 5337 | \insert\margin{\hbox{\vrule height8pt depth3pt width0pt \relax\indextext}}% |
| 5338 | \fi |
| 5339 | } |
| 5340 | \let\SETmarginindex=\relax |
| 5341 | |
| 5342 | |
| 5343 | % Take care of unwanted page breaks/skips around a whatsit: |
| 5344 | % |
| 5345 | % If a skip is the last thing on the list now, preserve it |
| 5346 | % by backing up by \lastskip, doing the \write, then inserting |
| 5347 | % the skip again. Otherwise, the whatsit generated by the |
| 5348 | % \write or \pdfdest will make \lastskip zero. The result is that |
| 5349 | % sequences like this: |
| 5350 | % @end defun |
| 5351 | % @tindex whatever |
| 5352 | % @defun ... |
| 5353 | % will have extra space inserted, because the \medbreak in the |
| 5354 | % start of the @defun won't see the skip inserted by the @end of |
| 5355 | % the previous defun. |
| 5356 | % |
| 5357 | % But don't do any of this if we're not in vertical mode. We |
| 5358 | % don't want to do a \vskip and prematurely end a paragraph. |
| 5359 | % |
| 5360 | % Avoid page breaks due to these extra skips, too. |
| 5361 | % |
| 5362 | % But wait, there is a catch there: |
| 5363 | % We'll have to check whether \lastskip is zero skip. \ifdim is not |
| 5364 | % sufficient for this purpose, as it ignores stretch and shrink parts |
| 5365 | % of the skip. The only way seems to be to check the textual |
| 5366 | % representation of the skip. |
| 5367 | % |
| 5368 | % The following is almost like \def\zeroskipmacro{0.0pt} except that |
| 5369 | % the ``p'' and ``t'' characters have catcode \other, not 11 (letter). |
| 5370 | % |
| 5371 | \edef\zeroskipmacro{\expandafter\the\csname z@skip\endcsname} |
| 5372 | % |
| 5373 | \newskip\whatsitskip |
| 5374 | \newcount\whatsitpenalty |
| 5375 | % |
| 5376 | % ..., ready, GO: |
| 5377 | % |
| 5378 | \def\safewhatsit#1{\ifhmode |
| 5379 | #1% |
| 5380 | \else |
| 5381 | % \lastskip and \lastpenalty cannot both be nonzero simultaneously. |
| 5382 | \whatsitskip = \lastskip |
| 5383 | \edef\lastskipmacro{\the\lastskip}% |
| 5384 | \whatsitpenalty = \lastpenalty |
| 5385 | % |
| 5386 | % If \lastskip is nonzero, that means the last item was a |
| 5387 | % skip. And since a skip is discardable, that means this |
| 5388 | % -\whatsitskip glue we're inserting is preceded by a |
| 5389 | % non-discardable item, therefore it is not a potential |
| 5390 | % breakpoint, therefore no \nobreak needed. |
| 5391 | \ifx\lastskipmacro\zeroskipmacro |
| 5392 | \else |
| 5393 | \vskip-\whatsitskip |
| 5394 | \fi |
| 5395 | % |
| 5396 | #1% |
| 5397 | % |
| 5398 | \ifx\lastskipmacro\zeroskipmacro |
| 5399 | % If \lastskip was zero, perhaps the last item was a penalty, and |
| 5400 | % perhaps it was >=10000, e.g., a \nobreak. In that case, we want |
| 5401 | % to re-insert the same penalty (values >10000 are used for various |
| 5402 | % signals); since we just inserted a non-discardable item, any |
| 5403 | % following glue (such as a \parskip) would be a breakpoint. For example: |
| 5404 | % @deffn deffn-whatever |
| 5405 | % @vindex index-whatever |
| 5406 | % Description. |
| 5407 | % would allow a break between the index-whatever whatsit |
| 5408 | % and the "Description." paragraph. |
| 5409 | \ifnum\whatsitpenalty>9999 \penalty\whatsitpenalty \fi |
| 5410 | \else |
| 5411 | % On the other hand, if we had a nonzero \lastskip, |
| 5412 | % this make-up glue would be preceded by a non-discardable item |
| 5413 | % (the whatsit from the \write), so we must insert a \nobreak. |
| 5414 | \nobreak\vskip\whatsitskip |
| 5415 | \fi |
| 5416 | \fi} |
| 5417 | |
| 5418 | % The index entry written in the file actually looks like |
| 5419 | % \entry {sortstring}{page}{topic} |
| 5420 | % or |
| 5421 | % \entry {sortstring}{page}{topic}{subtopic} |
| 5422 | % The texindex program reads in these files and writes files |
| 5423 | % containing these kinds of lines: |
| 5424 | % \initial {c} |
| 5425 | % before the first topic whose initial is c |
| 5426 | % \entry {topic}{pagelist} |
| 5427 | % for a topic that is used without subtopics |
| 5428 | % \primary {topic} |
| 5429 | % \entry {topic}{} |
| 5430 | % for the beginning of a topic that is used with subtopics |
| 5431 | % \secondary {subtopic}{pagelist} |
| 5432 | % for each subtopic. |
| 5433 | % \secondary {subtopic}{} |
| 5434 | % for a subtopic with sub-subtopics |
| 5435 | % \tertiary {subtopic}{subsubtopic}{pagelist} |
| 5436 | % for each sub-subtopic. |
| 5437 | |
| 5438 | % Define the user-accessible indexing commands |
| 5439 | % @findex, @vindex, @kindex, @cindex. |
| 5440 | |
| 5441 | \def\findex {\fnindex} |
| 5442 | \def\kindex {\kyindex} |
| 5443 | \def\cindex {\cpindex} |
| 5444 | \def\vindex {\vrindex} |
| 5445 | \def\tindex {\tpindex} |
| 5446 | \def\pindex {\pgindex} |
| 5447 | |
| 5448 | % Define the macros used in formatting output of the sorted index material. |
| 5449 | |
| 5450 | % @printindex causes a particular index (the ??s file) to get printed. |
| 5451 | % It does not print any chapter heading (usually an @unnumbered). |
| 5452 | % |
| 5453 | \parseargdef\printindex{\begingroup |
| 5454 | \dobreak \chapheadingskip{10000}% |
| 5455 | % |
| 5456 | \smallfonts \rm |
| 5457 | \tolerance = 9500 |
| 5458 | \plainfrenchspacing |
| 5459 | \everypar = {}% don't want the \kern\-parindent from indentation suppression. |
| 5460 | % |
| 5461 | % See comment in \requireopenindexfile. |
| 5462 | \def\indexname{#1}\ifx\indexname\indexisfl\def\indexname{f1}\fi |
| 5463 | % |
| 5464 | % See if the index file exists and is nonempty. |
| 5465 | \openin 1 \jobname.\indexname s |
| 5466 | \ifeof 1 |
| 5467 | % \enddoublecolumns gets confused if there is no text in the index, |
| 5468 | % and it loses the chapter title and the aux file entries for the |
| 5469 | % index. The easiest way to prevent this problem is to make sure |
| 5470 | % there is some text. |
| 5471 | \putwordIndexNonexistent |
| 5472 | \typeout{No file \jobname.\indexname s.}% |
| 5473 | \else |
| 5474 | % If the index file exists but is empty, then \openin leaves \ifeof |
| 5475 | % false. We have to make TeX try to read something from the file, so |
| 5476 | % it can discover if there is anything in it. |
| 5477 | \read 1 to \thisline |
| 5478 | \ifeof 1 |
| 5479 | \putwordIndexIsEmpty |
| 5480 | \else |
| 5481 | \expandafter\printindexzz\thisline\relax\relax\finish% |
| 5482 | \fi |
| 5483 | \fi |
| 5484 | \closein 1 |
| 5485 | \endgroup} |
| 5486 | |
| 5487 | % If the index file starts with a backslash, forgo reading the index |
| 5488 | % file altogether. If somebody upgrades texinfo.tex they may still have |
| 5489 | % old index files using \ as the escape character. Reading this would |
| 5490 | % at best lead to typesetting garbage, at worst a TeX syntax error. |
| 5491 | \def\printindexzz#1#2\finish{% |
| 5492 | \expandafter\ifx\csname SETtxiindexescapeisbackslash\endcsname\relax |
| 5493 | \uccode`\~=`\\ \uppercase{\if\noexpand~}\noexpand#1 |
| 5494 | \expandafter\ifx\csname SETtxiskipindexfileswithbackslash\endcsname\relax |
| 5495 | \errmessage{% |
| 5496 | ERROR: A sorted index file in an obsolete format was skipped. |
| 5497 | To fix this problem, please upgrade your version of 'texi2dvi' |
| 5498 | or 'texi2pdf' to that at <https://ftp.gnu.org/gnu/texinfo>. |
| 5499 | If you are using an old version of 'texindex' (part of the Texinfo |
| 5500 | distribution), you may also need to upgrade to a newer version (at least 6.0). |
| 5501 | You may be able to typeset the index if you run |
| 5502 | 'texindex \jobname.\indexname' yourself. |
| 5503 | You could also try setting the 'txiindexescapeisbackslash' flag by |
| 5504 | running a command like |
| 5505 | 'texi2dvi -t "@set txiindexescapeisbackslash" \jobname.texi'. If you do |
| 5506 | this, Texinfo will try to use index files in the old format. |
| 5507 | If you continue to have problems, deleting the index files and starting again |
| 5508 | might help (with 'rm \jobname.?? \jobname.??s')% |
| 5509 | }% |
| 5510 | \else |
| 5511 | (Skipped sorted index file in obsolete format) |
| 5512 | \fi |
| 5513 | \else |
| 5514 | \begindoublecolumns |
| 5515 | \input \jobname.\indexname s |
| 5516 | \enddoublecolumns |
| 5517 | \fi |
| 5518 | \else |
| 5519 | \begindoublecolumns |
| 5520 | \catcode`\\=0\relax |
| 5521 | % |
| 5522 | % Make @ an escape character to give macros a chance to work. This |
| 5523 | % should work because we (hopefully) don't otherwise use @ in index files. |
| 5524 | %\catcode`\@=12\relax |
| 5525 | \catcode`\@=0\relax |
| 5526 | \input \jobname.\indexname s |
| 5527 | \enddoublecolumns |
| 5528 | \fi |
| 5529 | } |
| 5530 | |
| 5531 | % These macros are used by the sorted index file itself. |
| 5532 | % Change them to control the appearance of the index. |
| 5533 | |
| 5534 | {\catcode`\/=13 \catcode`\-=13 \catcode`\^=13 \catcode`\~=13 \catcode`\_=13 |
| 5535 | \catcode`\|=13 \catcode`\<=13 \catcode`\>=13 \catcode`\+=13 \catcode`\"=13 |
| 5536 | \catcode`\$=3 |
| 5537 | \gdef\initialglyphs{% |
| 5538 | % special control sequences used in the index sort key |
| 5539 | \let\indexlbrace\{% |
| 5540 | \let\indexrbrace\}% |
| 5541 | \let\indexatchar\@% |
| 5542 | \def\indexbackslash{\math{\backslash}}% |
| 5543 | % |
| 5544 | % Some changes for non-alphabetic characters. Using the glyphs from the |
| 5545 | % math fonts looks more consistent than the typewriter font used elsewhere |
| 5546 | % for these characters. |
| 5547 | \uccode`\~=`\\ \uppercase{\def~{\math{\backslash}}} |
| 5548 | % |
| 5549 | % In case @\ is used for backslash |
| 5550 | \uppercase{\let\\=~} |
| 5551 | % Can't get bold backslash so don't use bold forward slash |
| 5552 | \catcode`\/=13 |
| 5553 | \def/{{\secrmnotbold \normalslash}}% |
| 5554 | \def-{{\normaldash\normaldash}}% en dash `--' |
| 5555 | \def^{{\chapbf \normalcaret}}% |
| 5556 | \def~{{\chapbf \normaltilde}}% |
| 5557 | \def\_{% |
| 5558 | \leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em }% |
| 5559 | \def|{$\vert$}% |
| 5560 | \def<{$\less$}% |
| 5561 | \def>{$\gtr$}% |
| 5562 | \def+{$\normalplus$}% |
| 5563 | }} |
| 5564 | |
| 5565 | \def\initial{% |
| 5566 | \bgroup |
| 5567 | \initialglyphs |
| 5568 | \initialx |
| 5569 | } |
| 5570 | |
| 5571 | \def\initialx#1{% |
| 5572 | % Remove any glue we may have, we'll be inserting our own. |
| 5573 | \removelastskip |
| 5574 | % |
| 5575 | % We like breaks before the index initials, so insert a bonus. |
| 5576 | % The glue before the bonus allows a little bit of space at the |
| 5577 | % bottom of a column to reduce an increase in inter-line spacing. |
| 5578 | \nobreak |
| 5579 | \vskip 0pt plus 5\baselineskip |
| 5580 | \penalty -300 |
| 5581 | \vskip 0pt plus -5\baselineskip |
| 5582 | % |
| 5583 | % Typeset the initial. Making this add up to a whole number of |
| 5584 | % baselineskips increases the chance of the dots lining up from column |
| 5585 | % to column. It still won't often be perfect, because of the stretch |
| 5586 | % we need before each entry, but it's better. |
| 5587 | % |
| 5588 | % No shrink because it confuses \balancecolumns. |
| 5589 | \vskip 1.67\baselineskip plus 1\baselineskip |
| 5590 | \leftline{\secfonts \kern-0.05em \secbf #1}% |
| 5591 | % \secfonts is inside the argument of \leftline so that the change of |
| 5592 | % \baselineskip will not affect any glue inserted before the vbox that |
| 5593 | % \leftline creates. |
| 5594 | % Do our best not to break after the initial. |
| 5595 | \nobreak |
| 5596 | \vskip .33\baselineskip plus .1\baselineskip |
| 5597 | \egroup % \initialglyphs |
| 5598 | } |
| 5599 | |
| 5600 | \newdimen\entryrightmargin |
| 5601 | \entryrightmargin=0pt |
| 5602 | |
| 5603 | % \entry typesets a paragraph consisting of the text (#1), dot leaders, and |
| 5604 | % then page number (#2) flushed to the right margin. It is used for index |
| 5605 | % and table of contents entries. The paragraph is indented by \leftskip. |
| 5606 | % |
| 5607 | \def\entry{% |
| 5608 | \begingroup |
| 5609 | % |
| 5610 | % Start a new paragraph if necessary, so our assignments below can't |
| 5611 | % affect previous text. |
| 5612 | \par |
| 5613 | % |
| 5614 | % No extra space above this paragraph. |
| 5615 | \parskip = 0in |
| 5616 | % |
| 5617 | % When reading the text of entry, convert explicit line breaks |
| 5618 | % from @* into spaces. The user might give these in long section |
| 5619 | % titles, for instance. |
| 5620 | \def\*{\unskip\space\ignorespaces}% |
| 5621 | \def\entrybreak{\hfil\break}% An undocumented command |
| 5622 | % |
| 5623 | % Swallow the left brace of the text (first parameter): |
| 5624 | \afterassignment\doentry |
| 5625 | \let\temp = |
| 5626 | } |
| 5627 | \def\entrybreak{\unskip\space\ignorespaces}% |
| 5628 | \def\doentry{% |
| 5629 | % Save the text of the entry |
| 5630 | \global\setbox\boxA=\hbox\bgroup |
| 5631 | \bgroup % Instead of the swallowed brace. |
| 5632 | \noindent |
| 5633 | \aftergroup\finishentry |
| 5634 | % And now comes the text of the entry. |
| 5635 | % Not absorbing as a macro argument reduces the chance of problems |
| 5636 | % with catcodes occurring. |
| 5637 | } |
| 5638 | {\catcode`\@=11 |
| 5639 | \gdef\finishentry#1{% |
| 5640 | \egroup % end box A |
| 5641 | \dimen@ = \wd\boxA % Length of text of entry |
| 5642 | \global\setbox\boxA=\hbox\bgroup |
| 5643 | \unhbox\boxA |
| 5644 | % #1 is the page number. |
| 5645 | % |
| 5646 | % Get the width of the page numbers, and only use |
| 5647 | % leaders if they are present. |
| 5648 | \global\setbox\boxB = \hbox{#1}% |
| 5649 | \ifdim\wd\boxB = 0pt |
| 5650 | \null\nobreak\hfill\ % |
| 5651 | \else |
| 5652 | % |
| 5653 | \null\nobreak\indexdotfill % Have leaders before the page number. |
| 5654 | % |
| 5655 | \ifpdforxetex |
| 5656 | \pdfgettoks#1.% |
| 5657 | \hskip\skip\thinshrinkable\the\toksA |
| 5658 | \else |
| 5659 | \hskip\skip\thinshrinkable #1% |
| 5660 | \fi |
| 5661 | \fi |
| 5662 | \egroup % end \boxA |
| 5663 | \ifdim\wd\boxB = 0pt |
| 5664 | \noindent\unhbox\boxA\par |
| 5665 | \nobreak |
| 5666 | \else\bgroup |
| 5667 | % We want the text of the entries to be aligned to the left, and the |
| 5668 | % page numbers to be aligned to the right. |
| 5669 | % |
| 5670 | \parindent = 0pt |
| 5671 | \advance\leftskip by 0pt plus 1fil |
| 5672 | \advance\leftskip by 0pt plus -1fill |
| 5673 | \rightskip = 0pt plus -1fil |
| 5674 | \advance\rightskip by 0pt plus 1fill |
| 5675 | % Cause last line, which could consist of page numbers on their own |
| 5676 | % if the list of page numbers is long, to be aligned to the right. |
| 5677 | \parfillskip=0pt plus -1fill |
| 5678 | % |
| 5679 | \advance\rightskip by \entryrightmargin |
| 5680 | % Determine how far we can stretch into the margin. |
| 5681 | % This allows, e.g., "Appendix H GNU Free Documentation License" to |
| 5682 | % fit on one line in @letterpaper format. |
| 5683 | \ifdim\entryrightmargin>2.1em |
| 5684 | \dimen@i=2.1em |
| 5685 | \else |
| 5686 | \dimen@i=0em |
| 5687 | \fi |
| 5688 | \advance \parfillskip by 0pt minus 1\dimen@i |
| 5689 | % |
| 5690 | \dimen@ii = \hsize |
| 5691 | \advance\dimen@ii by -1\leftskip |
| 5692 | \advance\dimen@ii by -1\entryrightmargin |
| 5693 | \advance\dimen@ii by 1\dimen@i |
| 5694 | \ifdim\wd\boxA > \dimen@ii % If the entry doesn't fit in one line |
| 5695 | \ifdim\dimen@ > 0.8\dimen@ii % due to long index text |
| 5696 | % Try to split the text roughly evenly. \dimen@ will be the length of |
| 5697 | % the first line. |
| 5698 | \dimen@ = 0.7\dimen@ |
| 5699 | \dimen@ii = \hsize |
| 5700 | \ifnum\dimen@>\dimen@ii |
| 5701 | % If the entry is too long (for example, if it needs more than |
| 5702 | % two lines), use all the space in the first line. |
| 5703 | \dimen@ = \dimen@ii |
| 5704 | \fi |
| 5705 | \advance\leftskip by 0pt plus 1fill % ragged right |
| 5706 | \advance \dimen@ by 1\rightskip |
| 5707 | \parshape = 2 0pt \dimen@ 0em \dimen@ii |
| 5708 | % Ideally we'd add a finite glue at the end of the first line only, |
| 5709 | % instead of using \parshape with explicit line lengths, but TeX |
| 5710 | % doesn't seem to provide a way to do such a thing. |
| 5711 | % |
| 5712 | % Indent all lines but the first one. |
| 5713 | \advance\leftskip by 1em |
| 5714 | \advance\parindent by -1em |
| 5715 | \fi\fi |
| 5716 | \indent % start paragraph |
| 5717 | \unhbox\boxA |
| 5718 | % |
| 5719 | % Do not prefer a separate line ending with a hyphen to fewer lines. |
| 5720 | \finalhyphendemerits = 0 |
| 5721 | % |
| 5722 | % Word spacing - no stretch |
| 5723 | \spaceskip=\fontdimen2\font minus \fontdimen4\font |
| 5724 | % |
| 5725 | \linepenalty=1000 % Discourage line breaks. |
| 5726 | \hyphenpenalty=5000 % Discourage hyphenation. |
| 5727 | % |
| 5728 | \par % format the paragraph |
| 5729 | \egroup % The \vbox |
| 5730 | \fi |
| 5731 | \endgroup |
| 5732 | }} |
| 5733 | |
| 5734 | \newskip\thinshrinkable |
| 5735 | \skip\thinshrinkable=.15em minus .15em |
| 5736 | |
| 5737 | % Like plain.tex's \dotfill, except uses up at least 1 em. |
| 5738 | % The filll stretch here overpowers both the fil and fill stretch to push |
| 5739 | % the page number to the right. |
| 5740 | \def\indexdotfill{\cleaders |
| 5741 | \hbox{$\mathsurround=0pt \mkern1.5mu.\mkern1.5mu$}\hskip 1em plus 1filll} |
| 5742 | |
| 5743 | |
| 5744 | \def\primary #1{\line{#1\hfil}} |
| 5745 | |
| 5746 | \def\secondary{\indententry{0.5cm}} |
| 5747 | \def\tertiary{\indententry{1cm}} |
| 5748 | |
| 5749 | \def\indententry#1#2#3{% |
| 5750 | \bgroup |
| 5751 | \leftskip=#1 |
| 5752 | \entry{#2}{#3}% |
| 5753 | \egroup |
| 5754 | } |
| 5755 | |
| 5756 | % Define two-column mode, which we use to typeset indexes. |
| 5757 | % Adapted from the TeXbook, page 416, which is to say, |
| 5758 | % the manmac.tex format used to print the TeXbook itself. |
| 5759 | \catcode`\@=11 % private names |
| 5760 | |
| 5761 | \newbox\partialpage |
| 5762 | \newdimen\doublecolumnhsize |
| 5763 | |
| 5764 | \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns |
| 5765 | % If not much space left on page, start a new page. |
| 5766 | \ifdim\pagetotal>0.8\vsize\vfill\eject\fi |
| 5767 | % |
| 5768 | % Grab any single-column material above us. |
| 5769 | \output = {% |
| 5770 | \savetopmark |
| 5771 | % |
| 5772 | \global\setbox\partialpage = \vbox{% |
| 5773 | % Unvbox the main output page. |
| 5774 | \unvbox\PAGE |
| 5775 | \kern-\topskip \kern\baselineskip |
| 5776 | }% |
| 5777 | }% |
| 5778 | \eject % run that output routine to set \partialpage |
| 5779 | % |
| 5780 | % Use the double-column output routine for subsequent pages. |
| 5781 | \output = {\doublecolumnout}% |
| 5782 | % |
| 5783 | % Change the page size parameters. We could do this once outside this |
| 5784 | % routine, in each of @smallbook, @afourpaper, and the default 8.5x11 |
| 5785 | % format, but then we repeat the same computation. Repeating a couple |
| 5786 | % of assignments once per index is clearly meaningless for the |
| 5787 | % execution time, so we may as well do it in one place. |
| 5788 | % |
| 5789 | % First we halve the line length, less a little for the gutter between |
| 5790 | % the columns. We compute the gutter based on the line length, so it |
| 5791 | % changes automatically with the paper format. The magic constant |
| 5792 | % below is chosen so that the gutter has the same value (well, +-<1pt) |
| 5793 | % as it did when we hard-coded it. |
| 5794 | % |
| 5795 | % We put the result in a separate register, \doublecolumhsize, so we |
| 5796 | % can restore it in \pagesofar, after \hsize itself has (potentially) |
| 5797 | % been clobbered. |
| 5798 | % |
| 5799 | \doublecolumnhsize = \hsize |
| 5800 | \advance\doublecolumnhsize by -.04154\hsize |
| 5801 | \divide\doublecolumnhsize by 2 |
| 5802 | \hsize = \doublecolumnhsize |
| 5803 | % |
| 5804 | % Get the available space for the double columns -- the normal |
| 5805 | % (undoubled) page height minus any material left over from the |
| 5806 | % previous page. |
| 5807 | \advance\vsize by -\ht\partialpage |
| 5808 | \vsize = 2\vsize |
| 5809 | % |
| 5810 | % For the benefit of balancing columns |
| 5811 | \advance\baselineskip by 0pt plus 0.5pt |
| 5812 | } |
| 5813 | |
| 5814 | % The double-column output routine for all double-column pages except |
| 5815 | % the last, which is done by \balancecolumns. |
| 5816 | % |
| 5817 | \def\doublecolumnout{% |
| 5818 | % |
| 5819 | \savetopmark |
| 5820 | \splittopskip=\topskip \splitmaxdepth=\maxdepth |
| 5821 | \dimen@ = \vsize |
| 5822 | \divide\dimen@ by 2 |
| 5823 | % |
| 5824 | % box0 will be the left-hand column, box2 the right. |
| 5825 | \setbox0=\vsplit\PAGE to\dimen@ \setbox2=\vsplit\PAGE to\dimen@ |
| 5826 | \global\advance\vsize by 2\ht\partialpage |
| 5827 | \onepageout\pagesofar % empty except for the first time we are called |
| 5828 | \unvbox\PAGE |
| 5829 | \penalty\outputpenalty |
| 5830 | } |
| 5831 | % |
| 5832 | % Re-output the contents of the output page -- any previous material, |
| 5833 | % followed by the two boxes we just split, in box0 and box2. |
| 5834 | \def\pagesofar{% |
| 5835 | \unvbox\partialpage |
| 5836 | % |
| 5837 | \hsize = \doublecolumnhsize |
| 5838 | \wd0=\hsize \wd2=\hsize |
| 5839 | \hbox to\txipagewidth{\box0\hfil\box2}% |
| 5840 | } |
| 5841 | |
| 5842 | |
| 5843 | % Finished with double columns. |
| 5844 | \def\enddoublecolumns{% |
| 5845 | % The following penalty ensures that the page builder is exercised |
| 5846 | % _before_ we change the output routine. This is necessary in the |
| 5847 | % following situation: |
| 5848 | % |
| 5849 | % The last section of the index consists only of a single entry. |
| 5850 | % Before this section, \pagetotal is less than \pagegoal, so no |
| 5851 | % break occurs before the last section starts. However, the last |
| 5852 | % section, consisting of \initial and the single \entry, does not |
| 5853 | % fit on the page and has to be broken off. Without the following |
| 5854 | % penalty the page builder will not be exercised until \eject |
| 5855 | % below, and by that time we'll already have changed the output |
| 5856 | % routine to the \balancecolumns version, so the next-to-last |
| 5857 | % double-column page will be processed with \balancecolumns, which |
| 5858 | % is wrong: The two columns will go to the main vertical list, with |
| 5859 | % the broken-off section in the recent contributions. As soon as |
| 5860 | % the output routine finishes, TeX starts reconsidering the page |
| 5861 | % break. The two columns and the broken-off section both fit on the |
| 5862 | % page, because the two columns now take up only half of the page |
| 5863 | % goal. When TeX sees \eject from below which follows the final |
| 5864 | % section, it invokes the new output routine that we've set after |
| 5865 | % \balancecolumns below; \onepageout will try to fit the two columns |
| 5866 | % and the final section into the vbox of \txipageheight (see |
| 5867 | % \pagebody), causing an overfull box. |
| 5868 | % |
| 5869 | % Note that glue won't work here, because glue does not exercise the |
| 5870 | % page builder, unlike penalties (see The TeXbook, pp. 280-281). |
| 5871 | \penalty0 |
| 5872 | % |
| 5873 | \output = {% |
| 5874 | % Split the last of the double-column material. |
| 5875 | \savetopmark |
| 5876 | \balancecolumns |
| 5877 | }% |
| 5878 | \eject % call the \output just set |
| 5879 | \ifdim\pagetotal=0pt |
| 5880 | % Having called \balancecolumns once, we do not |
| 5881 | % want to call it again. Therefore, reset \output to its normal |
| 5882 | % definition right away. |
| 5883 | \global\output=\expandafter{\the\defaultoutput} |
| 5884 | % |
| 5885 | \endgroup % started in \begindoublecolumns |
| 5886 | % Leave the double-column material on the current page, no automatic |
| 5887 | % page break. |
| 5888 | \box\balancedcolumns |
| 5889 | % |
| 5890 | % \pagegoal was set to the doubled \vsize above, since we restarted |
| 5891 | % the current page. We're now back to normal single-column |
| 5892 | % typesetting, so reset \pagegoal to the normal \vsize. |
| 5893 | \global\vsize = \txipageheight % |
| 5894 | \pagegoal = \txipageheight % |
| 5895 | \else |
| 5896 | % We had some left-over material. This might happen when \doublecolumnout |
| 5897 | % is called in \balancecolumns. Try again. |
| 5898 | \expandafter\enddoublecolumns |
| 5899 | \fi |
| 5900 | } |
| 5901 | \newbox\balancedcolumns |
| 5902 | \setbox\balancedcolumns=\vbox{shouldnt see this}% |
| 5903 | % |
| 5904 | % Only called for the last of the double column material. \doublecolumnout |
| 5905 | % does the others. |
| 5906 | \def\balancecolumns{% |
| 5907 | \setbox0 = \vbox{\unvbox\PAGE}% like \box255 but more efficient, see p.120. |
| 5908 | \dimen@ = \ht0 |
| 5909 | \ifdim\dimen@<7\baselineskip |
| 5910 | % Don't split a short final column in two. |
| 5911 | \setbox2=\vbox{}% |
| 5912 | \global\setbox\balancedcolumns=\vbox{\pagesofar}% |
| 5913 | \else |
| 5914 | % double the leading vertical space |
| 5915 | \advance\dimen@ by \topskip |
| 5916 | \advance\dimen@ by-\baselineskip |
| 5917 | \divide\dimen@ by 2 % target to split to |
| 5918 | \dimen@ii = \dimen@ |
| 5919 | \splittopskip = \topskip |
| 5920 | % Loop until left column is at least as high as the right column. |
| 5921 | {% |
| 5922 | \vbadness = 10000 |
| 5923 | \loop |
| 5924 | \global\setbox3 = \copy0 |
| 5925 | \global\setbox1 = \vsplit3 to \dimen@ |
| 5926 | \ifdim\ht1<\ht3 |
| 5927 | \global\advance\dimen@ by 1pt |
| 5928 | \repeat |
| 5929 | }% |
| 5930 | % Now the left column is in box 1, and the right column in box 3. |
| 5931 | % |
| 5932 | % Check whether the left column has come out higher than the page itself. |
| 5933 | % (Note that we have doubled \vsize for the double columns, so |
| 5934 | % the actual height of the page is 0.5\vsize). |
| 5935 | \ifdim2\ht1>\vsize |
| 5936 | % It appears that we have been called upon to balance too much material. |
| 5937 | % Output some of it with \doublecolumnout, leaving the rest on the page. |
| 5938 | \setbox\PAGE=\box0 |
| 5939 | \doublecolumnout |
| 5940 | \else |
| 5941 | % Compare the heights of the two columns. |
| 5942 | \ifdim4\ht1>5\ht3 |
| 5943 | % Column heights are too different, so don't make their bottoms |
| 5944 | % flush with each other. |
| 5945 | \setbox2=\vbox to \ht1 {\unvbox3\vfill}% |
| 5946 | \setbox0=\vbox to \ht1 {\unvbox1\vfill}% |
| 5947 | \else |
| 5948 | % Make column bottoms flush with each other. |
| 5949 | \setbox2=\vbox to\ht1{\unvbox3\unskip}% |
| 5950 | \setbox0=\vbox to\ht1{\unvbox1\unskip}% |
| 5951 | \fi |
| 5952 | \global\setbox\balancedcolumns=\vbox{\pagesofar}% |
| 5953 | \fi |
| 5954 | \fi |
| 5955 | % |
| 5956 | } |
| 5957 | \catcode`\@ = \other |
| 5958 | |
| 5959 | |
| 5960 | \message{sectioning,} |
| 5961 | % Chapters, sections, etc. |
| 5962 | |
| 5963 | % Let's start with @part. |
| 5964 | \outer\parseargdef\part{\partzzz{#1}} |
| 5965 | \def\partzzz#1{% |
| 5966 | \chapoddpage |
| 5967 | \null |
| 5968 | \vskip.3\vsize % move it down on the page a bit |
| 5969 | \begingroup |
| 5970 | \noindent \titlefonts\rm #1\par % the text |
| 5971 | \let\lastnode=\empty % no node to associate with |
| 5972 | \writetocentry{part}{#1}{}% but put it in the toc |
| 5973 | \headingsoff % no headline or footline on the part page |
| 5974 | % This outputs a mark at the end of the page that clears \thischapter |
| 5975 | % and \thissection, as is done in \startcontents. |
| 5976 | \let\pchapsepmacro\relax |
| 5977 | \chapmacro{}{Yomitfromtoc}{}% |
| 5978 | \chapoddpage |
| 5979 | \endgroup |
| 5980 | } |
| 5981 | |
| 5982 | % \unnumberedno is an oxymoron. But we count the unnumbered |
| 5983 | % sections so that we can refer to them unambiguously in the pdf |
| 5984 | % outlines by their "section number". We avoid collisions with chapter |
| 5985 | % numbers by starting them at 10000. (If a document ever has 10000 |
| 5986 | % chapters, we're in trouble anyway, I'm sure.) |
| 5987 | \newcount\unnumberedno \unnumberedno = 10000 |
| 5988 | \newcount\chapno |
| 5989 | \newcount\secno \secno=0 |
| 5990 | \newcount\subsecno \subsecno=0 |
| 5991 | \newcount\subsubsecno \subsubsecno=0 |
| 5992 | |
| 5993 | % This counter is funny since it counts through charcodes of letters A, B, ... |
| 5994 | \newcount\appendixno \appendixno = `\@ |
| 5995 | % |
| 5996 | % \def\appendixletter{\char\the\appendixno} |
| 5997 | % We do the following ugly conditional instead of the above simple |
| 5998 | % construct for the sake of pdftex, which needs the actual |
| 5999 | % letter in the expansion, not just typeset. |
| 6000 | % |
| 6001 | \def\appendixletter{% |
| 6002 | \ifnum\appendixno=`A A% |
| 6003 | \else\ifnum\appendixno=`B B% |
| 6004 | \else\ifnum\appendixno=`C C% |
| 6005 | \else\ifnum\appendixno=`D D% |
| 6006 | \else\ifnum\appendixno=`E E% |
| 6007 | \else\ifnum\appendixno=`F F% |
| 6008 | \else\ifnum\appendixno=`G G% |
| 6009 | \else\ifnum\appendixno=`H H% |
| 6010 | \else\ifnum\appendixno=`I I% |
| 6011 | \else\ifnum\appendixno=`J J% |
| 6012 | \else\ifnum\appendixno=`K K% |
| 6013 | \else\ifnum\appendixno=`L L% |
| 6014 | \else\ifnum\appendixno=`M M% |
| 6015 | \else\ifnum\appendixno=`N N% |
| 6016 | \else\ifnum\appendixno=`O O% |
| 6017 | \else\ifnum\appendixno=`P P% |
| 6018 | \else\ifnum\appendixno=`Q Q% |
| 6019 | \else\ifnum\appendixno=`R R% |
| 6020 | \else\ifnum\appendixno=`S S% |
| 6021 | \else\ifnum\appendixno=`T T% |
| 6022 | \else\ifnum\appendixno=`U U% |
| 6023 | \else\ifnum\appendixno=`V V% |
| 6024 | \else\ifnum\appendixno=`W W% |
| 6025 | \else\ifnum\appendixno=`X X% |
| 6026 | \else\ifnum\appendixno=`Y Y% |
| 6027 | \else\ifnum\appendixno=`Z Z% |
| 6028 | % The \the is necessary, despite appearances, because \appendixletter is |
| 6029 | % expanded while writing the .toc file. \char\appendixno is not |
| 6030 | % expandable, thus it is written literally, thus all appendixes come out |
| 6031 | % with the same letter (or @) in the toc without it. |
| 6032 | \else\char\the\appendixno |
| 6033 | \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi |
| 6034 | \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi} |
| 6035 | |
| 6036 | % Each @chapter defines these (using marks) as the number+name, number |
| 6037 | % and name of the chapter. Page headings and footings can use |
| 6038 | % these. @section does likewise. |
| 6039 | \def\thischapter{} |
| 6040 | \def\thischapternum{} |
| 6041 | \def\thischaptername{} |
| 6042 | \def\thissection{} |
| 6043 | \def\thissectionnum{} |
| 6044 | \def\thissectionname{} |
| 6045 | |
| 6046 | \newcount\absseclevel % used to calculate proper heading level |
| 6047 | \newcount\secbase\secbase=0 % @raisesections/@lowersections modify this count |
| 6048 | |
| 6049 | % @raisesections: treat @section as chapter, @subsection as section, etc. |
| 6050 | \def\raisesections{\global\advance\secbase by -1} |
| 6051 | |
| 6052 | % @lowersections: treat @chapter as section, @section as subsection, etc. |
| 6053 | \def\lowersections{\global\advance\secbase by 1} |
| 6054 | |
| 6055 | % we only have subsub. |
| 6056 | \chardef\maxseclevel = 3 |
| 6057 | % |
| 6058 | % A numbered section within an unnumbered changes to unnumbered too. |
| 6059 | % To achieve this, remember the "biggest" unnum. sec. we are currently in: |
| 6060 | \chardef\unnlevel = \maxseclevel |
| 6061 | % |
| 6062 | % Trace whether the current chapter is an appendix or not: |
| 6063 | % \chapheadtype is "N" or "A", unnumbered chapters are ignored. |
| 6064 | \def\chapheadtype{N} |
| 6065 | |
| 6066 | % Choose a heading macro |
| 6067 | % #1 is heading type |
| 6068 | % #2 is heading level |
| 6069 | % #3 is text for heading |
| 6070 | \def\genhead#1#2#3{% |
| 6071 | % Compute the abs. sec. level: |
| 6072 | \absseclevel=#2 |
| 6073 | \advance\absseclevel by \secbase |
| 6074 | % Make sure \absseclevel doesn't fall outside the range: |
| 6075 | \ifnum \absseclevel < 0 |
| 6076 | \absseclevel = 0 |
| 6077 | \else |
| 6078 | \ifnum \absseclevel > 3 |
| 6079 | \absseclevel = 3 |
| 6080 | \fi |
| 6081 | \fi |
| 6082 | % The heading type: |
| 6083 | \def\headtype{#1}% |
| 6084 | \if \headtype U% |
| 6085 | \ifnum \absseclevel < \unnlevel |
| 6086 | \chardef\unnlevel = \absseclevel |
| 6087 | \fi |
| 6088 | \else |
| 6089 | % Check for appendix sections: |
| 6090 | \ifnum \absseclevel = 0 |
| 6091 | \edef\chapheadtype{\headtype}% |
| 6092 | \else |
| 6093 | \if \headtype A\if \chapheadtype N% |
| 6094 | \errmessage{@appendix... within a non-appendix chapter}% |
| 6095 | \fi\fi |
| 6096 | \fi |
| 6097 | % Check for numbered within unnumbered: |
| 6098 | \ifnum \absseclevel > \unnlevel |
| 6099 | \def\headtype{U}% |
| 6100 | \else |
| 6101 | \chardef\unnlevel = 3 |
| 6102 | \fi |
| 6103 | \fi |
| 6104 | % Now print the heading: |
| 6105 | \if \headtype U% |
| 6106 | \ifcase\absseclevel |
| 6107 | \unnumberedzzz{#3}% |
| 6108 | \or \unnumberedseczzz{#3}% |
| 6109 | \or \unnumberedsubseczzz{#3}% |
| 6110 | \or \unnumberedsubsubseczzz{#3}% |
| 6111 | \fi |
| 6112 | \else |
| 6113 | \if \headtype A% |
| 6114 | \ifcase\absseclevel |
| 6115 | \appendixzzz{#3}% |
| 6116 | \or \appendixsectionzzz{#3}% |
| 6117 | \or \appendixsubseczzz{#3}% |
| 6118 | \or \appendixsubsubseczzz{#3}% |
| 6119 | \fi |
| 6120 | \else |
| 6121 | \ifcase\absseclevel |
| 6122 | \chapterzzz{#3}% |
| 6123 | \or \seczzz{#3}% |
| 6124 | \or \numberedsubseczzz{#3}% |
| 6125 | \or \numberedsubsubseczzz{#3}% |
| 6126 | \fi |
| 6127 | \fi |
| 6128 | \fi |
| 6129 | \suppressfirstparagraphindent |
| 6130 | } |
| 6131 | |
| 6132 | % an interface: |
| 6133 | \def\numhead{\genhead N} |
| 6134 | \def\apphead{\genhead A} |
| 6135 | \def\unnmhead{\genhead U} |
| 6136 | |
| 6137 | % @chapter, @appendix, @unnumbered. Increment top-level counter, reset |
| 6138 | % all lower-level sectioning counters to zero. |
| 6139 | % |
| 6140 | % Also set \chaplevelprefix, which we prepend to @float sequence numbers |
| 6141 | % (e.g., figures), q.v. By default (before any chapter), that is empty. |
| 6142 | \let\chaplevelprefix = \empty |
| 6143 | % |
| 6144 | \outer\parseargdef\chapter{\numhead0{#1}} % normally numhead0 calls chapterzzz |
| 6145 | \def\chapterzzz#1{% |
| 6146 | % section resetting is \global in case the chapter is in a group, such |
| 6147 | % as an @include file. |
| 6148 | \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 |
| 6149 | \global\advance\chapno by 1 |
| 6150 | % |
| 6151 | % Used for \float. |
| 6152 | \gdef\chaplevelprefix{\the\chapno.}% |
| 6153 | \resetallfloatnos |
| 6154 | % |
| 6155 | % \putwordChapter can contain complex things in translations. |
| 6156 | \toks0=\expandafter{\putwordChapter}% |
| 6157 | \message{\the\toks0 \space \the\chapno}% |
| 6158 | % |
| 6159 | % Write the actual heading. |
| 6160 | \chapmacro{#1}{Ynumbered}{\the\chapno}% |
| 6161 | % |
| 6162 | % So @section and the like are numbered underneath this chapter. |
| 6163 | \global\let\section = \numberedsec |
| 6164 | \global\let\subsection = \numberedsubsec |
| 6165 | \global\let\subsubsection = \numberedsubsubsec |
| 6166 | } |
| 6167 | |
| 6168 | \outer\parseargdef\appendix{\apphead0{#1}} % normally calls appendixzzz |
| 6169 | % |
| 6170 | \def\appendixzzz#1{% |
| 6171 | \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 |
| 6172 | \global\advance\appendixno by 1 |
| 6173 | \gdef\chaplevelprefix{\appendixletter.}% |
| 6174 | \resetallfloatnos |
| 6175 | % |
| 6176 | % \putwordAppendix can contain complex things in translations. |
| 6177 | \toks0=\expandafter{\putwordAppendix}% |
| 6178 | \message{\the\toks0 \space \appendixletter}% |
| 6179 | % |
| 6180 | \chapmacro{#1}{Yappendix}{\appendixletter}% |
| 6181 | % |
| 6182 | \global\let\section = \appendixsec |
| 6183 | \global\let\subsection = \appendixsubsec |
| 6184 | \global\let\subsubsection = \appendixsubsubsec |
| 6185 | } |
| 6186 | |
| 6187 | % normally unnmhead0 calls unnumberedzzz: |
| 6188 | \outer\parseargdef\unnumbered{\unnmhead0{#1}} |
| 6189 | \def\unnumberedzzz#1{% |
| 6190 | \global\secno=0 \global\subsecno=0 \global\subsubsecno=0 |
| 6191 | \global\advance\unnumberedno by 1 |
| 6192 | % |
| 6193 | % Since an unnumbered has no number, no prefix for figures. |
| 6194 | \global\let\chaplevelprefix = \empty |
| 6195 | \resetallfloatnos |
| 6196 | % |
| 6197 | % This used to be simply \message{#1}, but TeX fully expands the |
| 6198 | % argument to \message. Therefore, if #1 contained @-commands, TeX |
| 6199 | % expanded them. For example, in `@unnumbered The @cite{Book}', TeX |
| 6200 | % expanded @cite (which turns out to cause errors because \cite is meant |
| 6201 | % to be executed, not expanded). |
| 6202 | % |
| 6203 | % Anyway, we don't want the fully-expanded definition of @cite to appear |
| 6204 | % as a result of the \message, we just want `@cite' itself. We use |
| 6205 | % \the<toks register> to achieve this: TeX expands \the<toks> only once, |
| 6206 | % simply yielding the contents of <toks register>. (We also do this for |
| 6207 | % the toc entries.) |
| 6208 | \toks0 = {#1}% |
| 6209 | \message{(\the\toks0)}% |
| 6210 | % |
| 6211 | \chapmacro{#1}{Ynothing}{\the\unnumberedno}% |
| 6212 | % |
| 6213 | \global\let\section = \unnumberedsec |
| 6214 | \global\let\subsection = \unnumberedsubsec |
| 6215 | \global\let\subsubsection = \unnumberedsubsubsec |
| 6216 | } |
| 6217 | |
| 6218 | % @centerchap is like @unnumbered, but the heading is centered. |
| 6219 | \outer\parseargdef\centerchap{% |
| 6220 | \let\centerparametersmaybe = \centerparameters |
| 6221 | \unnmhead0{#1}% |
| 6222 | \let\centerparametersmaybe = \relax |
| 6223 | } |
| 6224 | |
| 6225 | % @top is like @unnumbered. |
| 6226 | \let\top\unnumbered |
| 6227 | |
| 6228 | % Sections. |
| 6229 | % |
| 6230 | \outer\parseargdef\numberedsec{\numhead1{#1}} % normally calls seczzz |
| 6231 | \def\seczzz#1{% |
| 6232 | \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 |
| 6233 | \sectionheading{#1}{sec}{Ynumbered}{\the\chapno.\the\secno}% |
| 6234 | } |
| 6235 | |
| 6236 | % normally calls appendixsectionzzz: |
| 6237 | \outer\parseargdef\appendixsection{\apphead1{#1}} |
| 6238 | \def\appendixsectionzzz#1{% |
| 6239 | \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 |
| 6240 | \sectionheading{#1}{sec}{Yappendix}{\appendixletter.\the\secno}% |
| 6241 | } |
| 6242 | \let\appendixsec\appendixsection |
| 6243 | |
| 6244 | % normally calls unnumberedseczzz: |
| 6245 | \outer\parseargdef\unnumberedsec{\unnmhead1{#1}} |
| 6246 | \def\unnumberedseczzz#1{% |
| 6247 | \global\subsecno=0 \global\subsubsecno=0 \global\advance\secno by 1 |
| 6248 | \sectionheading{#1}{sec}{Ynothing}{\the\unnumberedno.\the\secno}% |
| 6249 | } |
| 6250 | |
| 6251 | % Subsections. |
| 6252 | % |
| 6253 | % normally calls numberedsubseczzz: |
| 6254 | \outer\parseargdef\numberedsubsec{\numhead2{#1}} |
| 6255 | \def\numberedsubseczzz#1{% |
| 6256 | \global\subsubsecno=0 \global\advance\subsecno by 1 |
| 6257 | \sectionheading{#1}{subsec}{Ynumbered}{\the\chapno.\the\secno.\the\subsecno}% |
| 6258 | } |
| 6259 | |
| 6260 | % normally calls appendixsubseczzz: |
| 6261 | \outer\parseargdef\appendixsubsec{\apphead2{#1}} |
| 6262 | \def\appendixsubseczzz#1{% |
| 6263 | \global\subsubsecno=0 \global\advance\subsecno by 1 |
| 6264 | \sectionheading{#1}{subsec}{Yappendix}% |
| 6265 | {\appendixletter.\the\secno.\the\subsecno}% |
| 6266 | } |
| 6267 | |
| 6268 | % normally calls unnumberedsubseczzz: |
| 6269 | \outer\parseargdef\unnumberedsubsec{\unnmhead2{#1}} |
| 6270 | \def\unnumberedsubseczzz#1{% |
| 6271 | \global\subsubsecno=0 \global\advance\subsecno by 1 |
| 6272 | \sectionheading{#1}{subsec}{Ynothing}% |
| 6273 | {\the\unnumberedno.\the\secno.\the\subsecno}% |
| 6274 | } |
| 6275 | |
| 6276 | % Subsubsections. |
| 6277 | % |
| 6278 | % normally numberedsubsubseczzz: |
| 6279 | \outer\parseargdef\numberedsubsubsec{\numhead3{#1}} |
| 6280 | \def\numberedsubsubseczzz#1{% |
| 6281 | \global\advance\subsubsecno by 1 |
| 6282 | \sectionheading{#1}{subsubsec}{Ynumbered}% |
| 6283 | {\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno}% |
| 6284 | } |
| 6285 | |
| 6286 | % normally appendixsubsubseczzz: |
| 6287 | \outer\parseargdef\appendixsubsubsec{\apphead3{#1}} |
| 6288 | \def\appendixsubsubseczzz#1{% |
| 6289 | \global\advance\subsubsecno by 1 |
| 6290 | \sectionheading{#1}{subsubsec}{Yappendix}% |
| 6291 | {\appendixletter.\the\secno.\the\subsecno.\the\subsubsecno}% |
| 6292 | } |
| 6293 | |
| 6294 | % normally unnumberedsubsubseczzz: |
| 6295 | \outer\parseargdef\unnumberedsubsubsec{\unnmhead3{#1}} |
| 6296 | \def\unnumberedsubsubseczzz#1{% |
| 6297 | \global\advance\subsubsecno by 1 |
| 6298 | \sectionheading{#1}{subsubsec}{Ynothing}% |
| 6299 | {\the\unnumberedno.\the\secno.\the\subsecno.\the\subsubsecno}% |
| 6300 | } |
| 6301 | |
| 6302 | % These macros control what the section commands do, according |
| 6303 | % to what kind of chapter we are in (ordinary, appendix, or unnumbered). |
| 6304 | % Define them by default for a numbered chapter. |
| 6305 | \let\section = \numberedsec |
| 6306 | \let\subsection = \numberedsubsec |
| 6307 | \let\subsubsection = \numberedsubsubsec |
| 6308 | |
| 6309 | % Define @majorheading, @heading and @subheading |
| 6310 | |
| 6311 | \def\majorheading{% |
| 6312 | {\advance\chapheadingskip by 10pt \chapbreak }% |
| 6313 | \parsearg\chapheadingzzz |
| 6314 | } |
| 6315 | |
| 6316 | \def\chapheading{\chapbreak \parsearg\chapheadingzzz} |
| 6317 | \def\chapheadingzzz#1{% |
| 6318 | \vbox{\chapfonts \raggedtitlesettings #1\par}% |
| 6319 | \nobreak\bigskip \nobreak |
| 6320 | \suppressfirstparagraphindent |
| 6321 | } |
| 6322 | |
| 6323 | % @heading, @subheading, @subsubheading. |
| 6324 | \parseargdef\heading{\sectionheading{#1}{sec}{Yomitfromtoc}{} |
| 6325 | \suppressfirstparagraphindent} |
| 6326 | \parseargdef\subheading{\sectionheading{#1}{subsec}{Yomitfromtoc}{} |
| 6327 | \suppressfirstparagraphindent} |
| 6328 | \parseargdef\subsubheading{\sectionheading{#1}{subsubsec}{Yomitfromtoc}{} |
| 6329 | \suppressfirstparagraphindent} |
| 6330 | |
| 6331 | % These macros generate a chapter, section, etc. heading only |
| 6332 | % (including whitespace, linebreaking, etc. around it), |
| 6333 | % given all the information in convenient, parsed form. |
| 6334 | |
| 6335 | % Args are the skip and penalty (usually negative) |
| 6336 | \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi} |
| 6337 | |
| 6338 | % Parameter controlling skip before chapter headings (if needed) |
| 6339 | \newskip\chapheadingskip |
| 6340 | |
| 6341 | % Define plain chapter starts, and page on/off switching for it. |
| 6342 | \def\chapbreak{\dobreak \chapheadingskip {-4000}} |
| 6343 | |
| 6344 | % Start a new page |
| 6345 | \def\chappager{\par\vfill\supereject} |
| 6346 | |
| 6347 | % \chapoddpage - start on an odd page for a new chapter |
| 6348 | % Because \domark is called before \chapoddpage, the filler page will |
| 6349 | % get the headings for the next chapter, which is wrong. But we don't |
| 6350 | % care -- we just disable all headings on the filler page. |
| 6351 | \def\chapoddpage{% |
| 6352 | \chappager |
| 6353 | \ifodd\pageno \else |
| 6354 | \begingroup |
| 6355 | \headingsoff |
| 6356 | \null |
| 6357 | \chappager |
| 6358 | \endgroup |
| 6359 | \fi |
| 6360 | } |
| 6361 | |
| 6362 | \parseargdef\setchapternewpage{\csname CHAPPAG#1\endcsname} |
| 6363 | |
| 6364 | \def\CHAPPAGoff{% |
| 6365 | \global\let\contentsalignmacro = \chappager |
| 6366 | \global\let\pchapsepmacro=\chapbreak |
| 6367 | \global\def\HEADINGSon{\HEADINGSsinglechapoff}} |
| 6368 | |
| 6369 | \def\CHAPPAGon{% |
| 6370 | \global\let\contentsalignmacro = \chappager |
| 6371 | \global\let\pchapsepmacro=\chappager |
| 6372 | \global\def\HEADINGSon{\HEADINGSsingle}} |
| 6373 | |
| 6374 | \def\CHAPPAGodd{% |
| 6375 | \global\let\contentsalignmacro = \chapoddpage |
| 6376 | \global\let\pchapsepmacro=\chapoddpage |
| 6377 | \global\def\HEADINGSon{\HEADINGSdouble}} |
| 6378 | |
| 6379 | \CHAPPAGon |
| 6380 | |
| 6381 | % \chapmacro - Chapter opening. |
| 6382 | % |
| 6383 | % #1 is the text, #2 is the section type (Ynumbered, Ynothing, |
| 6384 | % Yappendix, Yomitfromtoc), #3 the chapter number. |
| 6385 | % Not used for @heading series. |
| 6386 | % |
| 6387 | % To test against our argument. |
| 6388 | \def\Ynothingkeyword{Ynothing} |
| 6389 | \def\Yappendixkeyword{Yappendix} |
| 6390 | \def\Yomitfromtockeyword{Yomitfromtoc} |
| 6391 | % |
| 6392 | \def\chapmacro#1#2#3{% |
| 6393 | \expandafter\ifx\thisenv\titlepage\else |
| 6394 | \checkenv{}% chapters, etc., should not start inside an environment. |
| 6395 | \fi |
| 6396 | % Insert the first mark before the heading break (see notes for \domark). |
| 6397 | \let\prevchapterdefs=\currentchapterdefs |
| 6398 | \let\prevsectiondefs=\currentsectiondefs |
| 6399 | \gdef\currentsectiondefs{\gdef\thissectionname{}\gdef\thissectionnum{}% |
| 6400 | \gdef\thissection{}}% |
| 6401 | % |
| 6402 | \def\temptype{#2}% |
| 6403 | \ifx\temptype\Ynothingkeyword |
| 6404 | \gdef\currentchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}% |
| 6405 | \gdef\thischapter{\thischaptername}}% |
| 6406 | \else\ifx\temptype\Yomitfromtockeyword |
| 6407 | \gdef\currentchapterdefs{\gdef\thischaptername{#1}\gdef\thischapternum{}% |
| 6408 | \gdef\thischapter{}}% |
| 6409 | \else\ifx\temptype\Yappendixkeyword |
| 6410 | \toks0={#1}% |
| 6411 | \xdef\currentchapterdefs{% |
| 6412 | \gdef\noexpand\thischaptername{\the\toks0}% |
| 6413 | \gdef\noexpand\thischapternum{\appendixletter}% |
| 6414 | % \noexpand\putwordAppendix avoids expanding indigestible |
| 6415 | % commands in some of the translations. |
| 6416 | \gdef\noexpand\thischapter{\noexpand\putwordAppendix{} |
| 6417 | \noexpand\thischapternum: |
| 6418 | \noexpand\thischaptername}% |
| 6419 | }% |
| 6420 | \else |
| 6421 | \toks0={#1}% |
| 6422 | \xdef\currentchapterdefs{% |
| 6423 | \gdef\noexpand\thischaptername{\the\toks0}% |
| 6424 | \gdef\noexpand\thischapternum{\the\chapno}% |
| 6425 | % \noexpand\putwordChapter avoids expanding indigestible |
| 6426 | % commands in some of the translations. |
| 6427 | \gdef\noexpand\thischapter{\noexpand\putwordChapter{} |
| 6428 | \noexpand\thischapternum: |
| 6429 | \noexpand\thischaptername}% |
| 6430 | }% |
| 6431 | \fi\fi\fi |
| 6432 | % |
| 6433 | % Output the mark. Pass it through \safewhatsit, to take care of |
| 6434 | % the preceding space. |
| 6435 | \safewhatsit\domark |
| 6436 | % |
| 6437 | % Insert the chapter heading break. |
| 6438 | \pchapsepmacro |
| 6439 | % |
| 6440 | % Now the second mark, after the heading break. No break points |
| 6441 | % between here and the heading. |
| 6442 | \let\prevchapterdefs=\currentchapterdefs |
| 6443 | \let\prevsectiondefs=\currentsectiondefs |
| 6444 | \domark |
| 6445 | % |
| 6446 | {% |
| 6447 | \chapfonts \rm |
| 6448 | \let\footnote=\errfootnoteheading % give better error message |
| 6449 | % |
| 6450 | % Have to define \currentsection before calling \donoderef, because the |
| 6451 | % xref code eventually uses it. On the other hand, it has to be called |
| 6452 | % after \pchapsepmacro, or the headline will change too soon. |
| 6453 | \gdef\currentsection{#1}% |
| 6454 | % |
| 6455 | % Only insert the separating space if we have a chapter/appendix |
| 6456 | % number, and don't print the unnumbered ``number''. |
| 6457 | \ifx\temptype\Ynothingkeyword |
| 6458 | \setbox0 = \hbox{}% |
| 6459 | \def\toctype{unnchap}% |
| 6460 | \else\ifx\temptype\Yomitfromtockeyword |
| 6461 | \setbox0 = \hbox{}% contents like unnumbered, but no toc entry |
| 6462 | \def\toctype{omit}% |
| 6463 | \else\ifx\temptype\Yappendixkeyword |
| 6464 | \setbox0 = \hbox{\putwordAppendix{} #3\enspace}% |
| 6465 | \def\toctype{app}% |
| 6466 | \else |
| 6467 | \setbox0 = \hbox{#3\enspace}% |
| 6468 | \def\toctype{numchap}% |
| 6469 | \fi\fi\fi |
| 6470 | % |
| 6471 | % Write the toc entry for this chapter. Must come before the |
| 6472 | % \donoderef, because we include the current node name in the toc |
| 6473 | % entry, and \donoderef resets it to empty. |
| 6474 | \writetocentry{\toctype}{#1}{#3}% |
| 6475 | % |
| 6476 | % For pdftex, we have to write out the node definition (aka, make |
| 6477 | % the pdfdest) after any page break, but before the actual text has |
| 6478 | % been typeset. If the destination for the pdf outline is after the |
| 6479 | % text, then jumping from the outline may wind up with the text not |
| 6480 | % being visible, for instance under high magnification. |
| 6481 | \donoderef{#2}% |
| 6482 | % |
| 6483 | % Typeset the actual heading. |
| 6484 | \nobreak % Avoid page breaks at the interline glue. |
| 6485 | \vbox{\raggedtitlesettings \hangindent=\wd0 \centerparametersmaybe |
| 6486 | \unhbox0 #1\par}% |
| 6487 | }% |
| 6488 | \nobreak\bigskip % no page break after a chapter title |
| 6489 | \nobreak |
| 6490 | } |
| 6491 | |
| 6492 | % @centerchap -- centered and unnumbered. |
| 6493 | \let\centerparametersmaybe = \relax |
| 6494 | \def\centerparameters{% |
| 6495 | \advance\rightskip by 3\rightskip |
| 6496 | \leftskip = \rightskip |
| 6497 | \parfillskip = 0pt |
| 6498 | } |
| 6499 | |
| 6500 | |
| 6501 | % Section titles. These macros combine the section number parts and |
| 6502 | % call the generic \sectionheading to do the printing. |
| 6503 | % |
| 6504 | \newskip\secheadingskip |
| 6505 | \def\secheadingbreak{\dobreak \secheadingskip{-1000}} |
| 6506 | |
| 6507 | % Subsection titles. |
| 6508 | \newskip\subsecheadingskip |
| 6509 | \def\subsecheadingbreak{\dobreak \subsecheadingskip{-500}} |
| 6510 | |
| 6511 | % Subsubsection titles. |
| 6512 | \def\subsubsecheadingskip{\subsecheadingskip} |
| 6513 | \def\subsubsecheadingbreak{\subsecheadingbreak} |
| 6514 | |
| 6515 | |
| 6516 | % Print any size, any type, section title. |
| 6517 | % |
| 6518 | % #1 is the text of the title, |
| 6519 | % #2 is the section level (sec/subsec/subsubsec), |
| 6520 | % #3 is the section type (Ynumbered, Ynothing, Yappendix, Yomitfromtoc), |
| 6521 | % #4 is the section number. |
| 6522 | % |
| 6523 | \def\seckeyword{sec} |
| 6524 | % |
| 6525 | \def\sectionheading#1#2#3#4{% |
| 6526 | {% |
| 6527 | \def\sectionlevel{#2}% |
| 6528 | \def\temptype{#3}% |
| 6529 | % |
| 6530 | % It is ok for the @heading series commands to appear inside an |
| 6531 | % environment (it's been historically allowed, though the logic is |
| 6532 | % dubious), but not the others. |
| 6533 | \ifx\temptype\Yomitfromtockeyword\else |
| 6534 | \checkenv{}% non-@*heading should not be in an environment. |
| 6535 | \fi |
| 6536 | \let\footnote=\errfootnoteheading |
| 6537 | % |
| 6538 | % Switch to the right set of fonts. |
| 6539 | \csname #2fonts\endcsname \rm |
| 6540 | % |
| 6541 | % Insert first mark before the heading break (see notes for \domark). |
| 6542 | \let\prevsectiondefs=\currentsectiondefs |
| 6543 | \ifx\temptype\Ynothingkeyword |
| 6544 | \ifx\sectionlevel\seckeyword |
| 6545 | \gdef\currentsectiondefs{\gdef\thissectionname{#1}\gdef\thissectionnum{}% |
| 6546 | \gdef\thissection{\thissectionname}}% |
| 6547 | \fi |
| 6548 | \else\ifx\temptype\Yomitfromtockeyword |
| 6549 | % Don't redefine \thissection. |
| 6550 | \else\ifx\temptype\Yappendixkeyword |
| 6551 | \ifx\sectionlevel\seckeyword |
| 6552 | \toks0={#1}% |
| 6553 | \xdef\currentsectiondefs{% |
| 6554 | \gdef\noexpand\thissectionname{\the\toks0}% |
| 6555 | \gdef\noexpand\thissectionnum{#4}% |
| 6556 | % \noexpand\putwordSection avoids expanding indigestible |
| 6557 | % commands in some of the translations. |
| 6558 | \gdef\noexpand\thissection{\noexpand\putwordSection{} |
| 6559 | \noexpand\thissectionnum: |
| 6560 | \noexpand\thissectionname}% |
| 6561 | }% |
| 6562 | \fi |
| 6563 | \else |
| 6564 | \ifx\sectionlevel\seckeyword |
| 6565 | \toks0={#1}% |
| 6566 | \xdef\currentsectiondefs{% |
| 6567 | \gdef\noexpand\thissectionname{\the\toks0}% |
| 6568 | \gdef\noexpand\thissectionnum{#4}% |
| 6569 | % \noexpand\putwordSection avoids expanding indigestible |
| 6570 | % commands in some of the translations. |
| 6571 | \gdef\noexpand\thissection{\noexpand\putwordSection{} |
| 6572 | \noexpand\thissectionnum: |
| 6573 | \noexpand\thissectionname}% |
| 6574 | }% |
| 6575 | \fi |
| 6576 | \fi\fi\fi |
| 6577 | % |
| 6578 | % Go into vertical mode. Usually we'll already be there, but we |
| 6579 | % don't want the following whatsit to end up in a preceding paragraph |
| 6580 | % if the document didn't happen to have a blank line. |
| 6581 | \par |
| 6582 | % |
| 6583 | % Output the mark. Pass it through \safewhatsit, to take care of |
| 6584 | % the preceding space. |
| 6585 | \safewhatsit\domark |
| 6586 | % |
| 6587 | % Insert space above the heading. |
| 6588 | \csname #2headingbreak\endcsname |
| 6589 | % |
| 6590 | % Now the second mark, after the heading break. No break points |
| 6591 | % between here and the heading. |
| 6592 | \global\let\prevsectiondefs=\currentsectiondefs |
| 6593 | \domark |
| 6594 | % |
| 6595 | % Only insert the space after the number if we have a section number. |
| 6596 | \ifx\temptype\Ynothingkeyword |
| 6597 | \setbox0 = \hbox{}% |
| 6598 | \def\toctype{unn}% |
| 6599 | \gdef\currentsection{#1}% |
| 6600 | \else\ifx\temptype\Yomitfromtockeyword |
| 6601 | % for @headings -- no section number, don't include in toc, |
| 6602 | % and don't redefine \currentsection. |
| 6603 | \setbox0 = \hbox{}% |
| 6604 | \def\toctype{omit}% |
| 6605 | \let\sectionlevel=\empty |
| 6606 | \else\ifx\temptype\Yappendixkeyword |
| 6607 | \setbox0 = \hbox{#4\enspace}% |
| 6608 | \def\toctype{app}% |
| 6609 | \gdef\currentsection{#1}% |
| 6610 | \else |
| 6611 | \setbox0 = \hbox{#4\enspace}% |
| 6612 | \def\toctype{num}% |
| 6613 | \gdef\currentsection{#1}% |
| 6614 | \fi\fi\fi |
| 6615 | % |
| 6616 | % Write the toc entry (before \donoderef). See comments in \chapmacro. |
| 6617 | \writetocentry{\toctype\sectionlevel}{#1}{#4}% |
| 6618 | % |
| 6619 | % Write the node reference (= pdf destination for pdftex). |
| 6620 | % Again, see comments in \chapmacro. |
| 6621 | \donoderef{#3}% |
| 6622 | % |
| 6623 | % Interline glue will be inserted when the vbox is completed. |
| 6624 | % That glue will be a valid breakpoint for the page, since it'll be |
| 6625 | % preceded by a whatsit (usually from the \donoderef, or from the |
| 6626 | % \writetocentry if there was no node). We don't want to allow that |
| 6627 | % break, since then the whatsits could end up on page n while the |
| 6628 | % section is on page n+1, thus toc/etc. are wrong. Debian bug 276000. |
| 6629 | \nobreak |
| 6630 | % |
| 6631 | % Output the actual section heading. |
| 6632 | \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright |
| 6633 | \hangindent=\wd0 % zero if no section number |
| 6634 | \unhbox0 #1}% |
| 6635 | }% |
| 6636 | % Add extra space after the heading -- half of whatever came above it. |
| 6637 | % Don't allow stretch, though. |
| 6638 | \kern .5 \csname #2headingskip\endcsname |
| 6639 | % |
| 6640 | % Do not let the kern be a potential breakpoint, as it would be if it |
| 6641 | % was followed by glue. |
| 6642 | \nobreak |
| 6643 | % |
| 6644 | % We'll almost certainly start a paragraph next, so don't let that |
| 6645 | % glue accumulate. (Not a breakpoint because it's preceded by a |
| 6646 | % discardable item.) However, when a paragraph is not started next |
| 6647 | % (\startdefun, \cartouche, \center, etc.), this needs to be wiped out |
| 6648 | % or the negative glue will cause weirdly wrong output, typically |
| 6649 | % obscuring the section heading with something else. |
| 6650 | \vskip-\parskip |
| 6651 | % |
| 6652 | % This is so the last item on the main vertical list is a known |
| 6653 | % \penalty > 10000, so \startdefun, etc., can recognize the situation |
| 6654 | % and do the needful. |
| 6655 | \penalty 10001 |
| 6656 | } |
| 6657 | |
| 6658 | |
| 6659 | \message{toc,} |
| 6660 | % Table of contents. |
| 6661 | \newwrite\tocfile |
| 6662 | |
| 6663 | % Write an entry to the toc file, opening it if necessary. |
| 6664 | % Called from @chapter, etc. |
| 6665 | % |
| 6666 | % Example usage: \writetocentry{sec}{Section Name}{\the\chapno.\the\secno} |
| 6667 | % We append the current node name (if any) and page number as additional |
| 6668 | % arguments for the \{chap,sec,...}entry macros which will eventually |
| 6669 | % read this. The node name is used in the pdf outlines as the |
| 6670 | % destination to jump to. |
| 6671 | % |
| 6672 | % We open the .toc file for writing here instead of at @setfilename (or |
| 6673 | % any other fixed time) so that @contents can be anywhere in the document. |
| 6674 | % But if #1 is `omit', then we don't do anything. This is used for the |
| 6675 | % table of contents chapter openings themselves. |
| 6676 | % |
| 6677 | \newif\iftocfileopened |
| 6678 | \def\omitkeyword{omit}% |
| 6679 | % |
| 6680 | \def\writetocentry#1#2#3{% |
| 6681 | \edef\writetoctype{#1}% |
| 6682 | \ifx\writetoctype\omitkeyword \else |
| 6683 | \iftocfileopened\else |
| 6684 | \immediate\openout\tocfile = \jobname.toc |
| 6685 | \global\tocfileopenedtrue |
| 6686 | \fi |
| 6687 | % |
| 6688 | \iflinks |
| 6689 | {\atdummies |
| 6690 | \edef\temp{% |
| 6691 | \write\tocfile{@#1entry{#2}{#3}{\lastnode}{\noexpand\folio}}}% |
| 6692 | \temp |
| 6693 | }% |
| 6694 | \fi |
| 6695 | \fi |
| 6696 | % |
| 6697 | % Tell \shipout to create a pdf destination on each page, if we're |
| 6698 | % writing pdf. These are used in the table of contents. We can't |
| 6699 | % just write one on every page because the title pages are numbered |
| 6700 | % 1 and 2 (the page numbers aren't printed), and so are the first |
| 6701 | % two pages of the document. Thus, we'd have two destinations named |
| 6702 | % `1', and two named `2'. |
| 6703 | \ifpdforxetex |
| 6704 | \global\pdfmakepagedesttrue |
| 6705 | \fi |
| 6706 | } |
| 6707 | |
| 6708 | |
| 6709 | % These characters do not print properly in the Computer Modern roman |
| 6710 | % fonts, so we must take special care. This is more or less redundant |
| 6711 | % with the Texinfo input format setup at the end of this file. |
| 6712 | % |
| 6713 | \def\activecatcodes{% |
| 6714 | \catcode`\"=\active |
| 6715 | \catcode`\$=\active |
| 6716 | \catcode`\<=\active |
| 6717 | \catcode`\>=\active |
| 6718 | \catcode`\\=\active |
| 6719 | \catcode`\^=\active |
| 6720 | \catcode`\_=\active |
| 6721 | \catcode`\|=\active |
| 6722 | \catcode`\~=\active |
| 6723 | } |
| 6724 | |
| 6725 | |
| 6726 | % Read the toc file, which is essentially Texinfo input. |
| 6727 | \def\readtocfile{% |
| 6728 | \setupdatafile |
| 6729 | \activecatcodes |
| 6730 | \input \tocreadfilename |
| 6731 | } |
| 6732 | |
| 6733 | \newskip\contentsrightmargin \contentsrightmargin=1in |
| 6734 | \newcount\savepageno |
| 6735 | \newcount\lastnegativepageno \lastnegativepageno = -1 |
| 6736 | |
| 6737 | % Prepare to read what we've written to \tocfile. |
| 6738 | % |
| 6739 | \def\startcontents#1{% |
| 6740 | % If @setchapternewpage on, and @headings double, the contents should |
| 6741 | % start on an odd page, unlike chapters. |
| 6742 | \contentsalignmacro |
| 6743 | \immediate\closeout\tocfile |
| 6744 | % |
| 6745 | % Don't need to put `Contents' or `Short Contents' in the headline. |
| 6746 | % It is abundantly clear what they are. |
| 6747 | \chapmacro{#1}{Yomitfromtoc}{}% |
| 6748 | % |
| 6749 | \savepageno = \pageno |
| 6750 | \begingroup % Set up to handle contents files properly. |
| 6751 | \raggedbottom % Worry more about breakpoints than the bottom. |
| 6752 | \entryrightmargin=\contentsrightmargin % Don't use the full line length. |
| 6753 | % |
| 6754 | % Roman numerals for page numbers. |
| 6755 | \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi |
| 6756 | \def\thistitle{}% no title in double-sided headings |
| 6757 | % Record where the Roman numerals started. |
| 6758 | \ifnum\romancount=0 \global\romancount=\pagecount \fi |
| 6759 | } |
| 6760 | |
| 6761 | % redefined for the two-volume lispref. We always output on |
| 6762 | % \jobname.toc even if this is redefined. |
| 6763 | % |
| 6764 | \def\tocreadfilename{\jobname.toc} |
| 6765 | |
| 6766 | % Normal (long) toc. |
| 6767 | % |
| 6768 | \def\contents{% |
| 6769 | \startcontents{\putwordTOC}% |
| 6770 | \openin 1 \tocreadfilename\space |
| 6771 | \ifeof 1 \else |
| 6772 | \readtocfile |
| 6773 | \fi |
| 6774 | \vfill \eject |
| 6775 | \contentsalignmacro % in case @setchapternewpage odd is in effect |
| 6776 | \ifeof 1 \else |
| 6777 | \pdfmakeoutlines |
| 6778 | \fi |
| 6779 | \closein 1 |
| 6780 | \endgroup |
| 6781 | \contentsendroman |
| 6782 | } |
| 6783 | |
| 6784 | % And just the chapters. |
| 6785 | \def\summarycontents{% |
| 6786 | \startcontents{\putwordShortTOC}% |
| 6787 | % |
| 6788 | \let\partentry = \shortpartentry |
| 6789 | \let\numchapentry = \shortchapentry |
| 6790 | \let\appentry = \shortchapentry |
| 6791 | \let\unnchapentry = \shortunnchapentry |
| 6792 | % We want a true roman here for the page numbers. |
| 6793 | \secfonts |
| 6794 | \let\rm=\shortcontrm \let\bf=\shortcontbf |
| 6795 | \let\sl=\shortcontsl \let\tt=\shortconttt |
| 6796 | \rm |
| 6797 | \hyphenpenalty = 10000 |
| 6798 | \advance\baselineskip by 1pt % Open it up a little. |
| 6799 | \def\numsecentry##1##2##3##4{} |
| 6800 | \let\appsecentry = \numsecentry |
| 6801 | \let\unnsecentry = \numsecentry |
| 6802 | \let\numsubsecentry = \numsecentry |
| 6803 | \let\appsubsecentry = \numsecentry |
| 6804 | \let\unnsubsecentry = \numsecentry |
| 6805 | \let\numsubsubsecentry = \numsecentry |
| 6806 | \let\appsubsubsecentry = \numsecentry |
| 6807 | \let\unnsubsubsecentry = \numsecentry |
| 6808 | \openin 1 \tocreadfilename\space |
| 6809 | \ifeof 1 \else |
| 6810 | \readtocfile |
| 6811 | \fi |
| 6812 | \closein 1 |
| 6813 | \vfill \eject |
| 6814 | \contentsalignmacro % in case @setchapternewpage odd is in effect |
| 6815 | \endgroup |
| 6816 | \contentsendroman |
| 6817 | } |
| 6818 | \let\shortcontents = \summarycontents |
| 6819 | |
| 6820 | % Get ready to use Arabic numerals again |
| 6821 | \def\contentsendroman{% |
| 6822 | \lastnegativepageno = \pageno |
| 6823 | \global\pageno = \savepageno |
| 6824 | % |
| 6825 | % If \romancount > \arabiccount, the contents are at the end of the |
| 6826 | % document. Otherwise, advance where the Arabic numerals start for |
| 6827 | % the page numbers. |
| 6828 | \ifnum\romancount>\arabiccount\else\global\arabiccount=\pagecount\fi |
| 6829 | } |
| 6830 | |
| 6831 | % Typeset the label for a chapter or appendix for the short contents. |
| 6832 | % The arg is, e.g., `A' for an appendix, or `3' for a chapter. |
| 6833 | % |
| 6834 | \def\shortchaplabel#1{% |
| 6835 | % This space should be enough, since a single number is .5em, and the |
| 6836 | % widest letter (M) is 1em, at least in the Computer Modern fonts. |
| 6837 | % But use \hss just in case. |
| 6838 | % (This space doesn't include the extra space that gets added after |
| 6839 | % the label; that gets put in by \shortchapentry above.) |
| 6840 | % |
| 6841 | % We'd like to right-justify chapter numbers, but that looks strange |
| 6842 | % with appendix letters. And right-justifying numbers and |
| 6843 | % left-justifying letters looks strange when there is less than 10 |
| 6844 | % chapters. Have to read the whole toc once to know how many chapters |
| 6845 | % there are before deciding ... |
| 6846 | \hbox to 1em{#1\hss}% |
| 6847 | } |
| 6848 | |
| 6849 | % These macros generate individual entries in the table of contents. |
| 6850 | % The first argument is the chapter or section name. |
| 6851 | % The last argument is the page number. |
| 6852 | % The arguments in between are the chapter number, section number, ... |
| 6853 | |
| 6854 | % Parts, in the main contents. Replace the part number, which doesn't |
| 6855 | % exist, with an empty box. Let's hope all the numbers have the same width. |
| 6856 | % Also ignore the page number, which is conventionally not printed. |
| 6857 | \def\numeralbox{\setbox0=\hbox{8}\hbox to \wd0{\hfil}} |
| 6858 | \def\partentry#1#2#3#4{% |
| 6859 | % Add stretch and a bonus for breaking the page before the part heading. |
| 6860 | % This reduces the chance of the page being broken immediately after the |
| 6861 | % part heading, before a following chapter heading. |
| 6862 | \vskip 0pt plus 5\baselineskip |
| 6863 | \penalty-300 |
| 6864 | \vskip 0pt plus -5\baselineskip |
| 6865 | \dochapentry{\numeralbox\labelspace#1}{}% |
| 6866 | } |
| 6867 | % |
| 6868 | % Parts, in the short toc. |
| 6869 | \def\shortpartentry#1#2#3#4{% |
| 6870 | \penalty-300 |
| 6871 | \vskip.5\baselineskip plus.15\baselineskip minus.1\baselineskip |
| 6872 | \shortchapentry{{\bf #1}}{\numeralbox}{}{}% |
| 6873 | } |
| 6874 | |
| 6875 | % Chapters, in the main contents. |
| 6876 | \def\numchapentry#1#2#3#4{\dochapentry{#2\labelspace#1}{#4}} |
| 6877 | |
| 6878 | % Chapters, in the short toc. |
| 6879 | % See comments in \dochapentry re vbox and related settings. |
| 6880 | \def\shortchapentry#1#2#3#4{% |
| 6881 | \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#4\egroup}% |
| 6882 | } |
| 6883 | |
| 6884 | % Appendices, in the main contents. |
| 6885 | % Need the word Appendix, and a fixed-size box. |
| 6886 | % |
| 6887 | \def\appendixbox#1{% |
| 6888 | % We use M since it's probably the widest letter. |
| 6889 | \setbox0 = \hbox{\putwordAppendix{} M}% |
| 6890 | \hbox to \wd0{\putwordAppendix{} #1\hss}} |
| 6891 | % |
| 6892 | \def\appentry#1#2#3#4{\dochapentry{\appendixbox{#2}\hskip.7em#1}{#4}} |
| 6893 | |
| 6894 | % Unnumbered chapters. |
| 6895 | \def\unnchapentry#1#2#3#4{\dochapentry{#1}{#4}} |
| 6896 | \def\shortunnchapentry#1#2#3#4{\tocentry{#1}{\doshortpageno\bgroup#4\egroup}} |
| 6897 | |
| 6898 | % Sections. |
| 6899 | \def\numsecentry#1#2#3#4{\dosecentry{#2\labelspace#1}{#4}} |
| 6900 | \let\appsecentry=\numsecentry |
| 6901 | \def\unnsecentry#1#2#3#4{\dosecentry{#1}{#4}} |
| 6902 | |
| 6903 | % Subsections. |
| 6904 | \def\numsubsecentry#1#2#3#4{\dosubsecentry{#2\labelspace#1}{#4}} |
| 6905 | \let\appsubsecentry=\numsubsecentry |
| 6906 | \def\unnsubsecentry#1#2#3#4{\dosubsecentry{#1}{#4}} |
| 6907 | |
| 6908 | % And subsubsections. |
| 6909 | \def\numsubsubsecentry#1#2#3#4{\dosubsubsecentry{#2\labelspace#1}{#4}} |
| 6910 | \let\appsubsubsecentry=\numsubsubsecentry |
| 6911 | \def\unnsubsubsecentry#1#2#3#4{\dosubsubsecentry{#1}{#4}} |
| 6912 | |
| 6913 | % This parameter controls the indentation of the various levels. |
| 6914 | % Same as \defaultparindent. |
| 6915 | \newdimen\tocindent \tocindent = 15pt |
| 6916 | |
| 6917 | % Now for the actual typesetting. In all these, #1 is the text and #2 is the |
| 6918 | % page number. |
| 6919 | % |
| 6920 | % If the toc has to be broken over pages, we want it to be at chapters |
| 6921 | % if at all possible; hence the \penalty. |
| 6922 | \def\dochapentry#1#2{% |
| 6923 | \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip |
| 6924 | \begingroup |
| 6925 | % Move the page numbers slightly to the right |
| 6926 | \advance\entryrightmargin by -0.05em |
| 6927 | \chapentryfonts |
| 6928 | \tocentry{#1}{\dopageno\bgroup#2\egroup}% |
| 6929 | \endgroup |
| 6930 | \nobreak\vskip .25\baselineskip plus.1\baselineskip |
| 6931 | } |
| 6932 | |
| 6933 | \def\dosecentry#1#2{\begingroup |
| 6934 | \secentryfonts \leftskip=\tocindent |
| 6935 | \tocentry{#1}{\dopageno\bgroup#2\egroup}% |
| 6936 | \endgroup} |
| 6937 | |
| 6938 | \def\dosubsecentry#1#2{\begingroup |
| 6939 | \subsecentryfonts \leftskip=2\tocindent |
| 6940 | \tocentry{#1}{\dopageno\bgroup#2\egroup}% |
| 6941 | \endgroup} |
| 6942 | |
| 6943 | \def\dosubsubsecentry#1#2{\begingroup |
| 6944 | \subsubsecentryfonts \leftskip=3\tocindent |
| 6945 | \tocentry{#1}{\dopageno\bgroup#2\egroup}% |
| 6946 | \endgroup} |
| 6947 | |
| 6948 | % We use the same \entry macro as for the index entries. |
| 6949 | \let\tocentry = \entry |
| 6950 | |
| 6951 | % Space between chapter (or whatever) number and the title. |
| 6952 | \def\labelspace{\hskip1em \relax} |
| 6953 | |
| 6954 | \def\dopageno#1{{\rm #1}} |
| 6955 | \def\doshortpageno#1{{\rm #1}} |
| 6956 | |
| 6957 | \def\chapentryfonts{\secfonts \rm} |
| 6958 | \def\secentryfonts{\textfonts} |
| 6959 | \def\subsecentryfonts{\textfonts} |
| 6960 | \def\subsubsecentryfonts{\textfonts} |
| 6961 | |
| 6962 | |
| 6963 | \message{environments,} |
| 6964 | % @foo ... @end foo. |
| 6965 | |
| 6966 | % @tex ... @end tex escapes into raw TeX temporarily. |
| 6967 | % One exception: @ is still an escape character, so that @end tex works. |
| 6968 | % But \@ or @@ will get a plain @ character. |
| 6969 | |
| 6970 | \envdef\tex{% |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 6971 | \setregularquotes |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 6972 | \catcode `\\=0 \catcode `\{=1 \catcode `\}=2 |
| 6973 | \catcode `\$=3 \catcode `\&=4 \catcode `\#=6 |
| 6974 | \catcode `\^=7 \catcode `\_=8 \catcode `\~=\active \let~=\tie |
| 6975 | \catcode `\%=14 |
| 6976 | \catcode `\+=\other |
| 6977 | \catcode `\"=\other |
| 6978 | \catcode `\|=\other |
| 6979 | \catcode `\<=\other |
| 6980 | \catcode `\>=\other |
| 6981 | \catcode `\`=\other |
| 6982 | \catcode `\'=\other |
| 6983 | % |
| 6984 | % ' is active in math mode (mathcode"8000). So reset it, and all our |
| 6985 | % other math active characters (just in case), to plain's definitions. |
| 6986 | \mathactive |
| 6987 | % |
| 6988 | % Inverse of the list at the beginning of the file. |
| 6989 | \let\b=\ptexb |
| 6990 | \let\bullet=\ptexbullet |
| 6991 | \let\c=\ptexc |
| 6992 | \let\,=\ptexcomma |
| 6993 | \let\.=\ptexdot |
| 6994 | \let\dots=\ptexdots |
| 6995 | \let\equiv=\ptexequiv |
| 6996 | \let\!=\ptexexclam |
| 6997 | \let\i=\ptexi |
| 6998 | \let\indent=\ptexindent |
| 6999 | \let\noindent=\ptexnoindent |
| 7000 | \let\{=\ptexlbrace |
| 7001 | \let\+=\tabalign |
| 7002 | \let\}=\ptexrbrace |
| 7003 | \let\/=\ptexslash |
| 7004 | \let\sp=\ptexsp |
| 7005 | \let\*=\ptexstar |
| 7006 | %\let\sup=\ptexsup % do not redefine, we want @sup to work in math mode |
| 7007 | \let\t=\ptext |
| 7008 | \expandafter \let\csname top\endcsname=\ptextop % we've made it outer |
| 7009 | \let\frenchspacing=\plainfrenchspacing |
| 7010 | % |
| 7011 | \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}% |
| 7012 | \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}% |
| 7013 | \def\@{@}% |
| 7014 | } |
| 7015 | % There is no need to define \Etex. |
| 7016 | |
| 7017 | % Define @lisp ... @end lisp. |
| 7018 | % @lisp environment forms a group so it can rebind things, |
| 7019 | % including the definition of @end lisp (which normally is erroneous). |
| 7020 | |
| 7021 | % Amount to narrow the margins by for @lisp. |
| 7022 | \newskip\lispnarrowing \lispnarrowing=0.4in |
| 7023 | |
| 7024 | % This is the definition that ^^M gets inside @lisp, @example, and other |
| 7025 | % such environments. \null is better than a space, since it doesn't |
| 7026 | % have any width. |
| 7027 | \def\lisppar{\null\endgraf} |
| 7028 | |
| 7029 | % This space is always present above and below environments. |
| 7030 | \newskip\envskipamount \envskipamount = 0pt |
| 7031 | |
| 7032 | % Make spacing and below environment symmetrical. We use \parskip here |
| 7033 | % to help in doing that, since in @example-like environments \parskip |
| 7034 | % is reset to zero; thus the \afterenvbreak inserts no space -- but the |
| 7035 | % start of the next paragraph will insert \parskip. |
| 7036 | % |
| 7037 | \def\aboveenvbreak{{% |
| 7038 | % =10000 instead of <10000 because of a special case in \itemzzz and |
| 7039 | % \sectionheading, q.v. |
| 7040 | \ifnum \lastpenalty=10000 \else |
| 7041 | \advance\envskipamount by \parskip |
| 7042 | \endgraf |
| 7043 | \ifdim\lastskip<\envskipamount |
| 7044 | \removelastskip |
| 7045 | \ifnum\lastpenalty<10000 |
| 7046 | % Penalize breaking before the environment, because preceding text |
| 7047 | % often leads into it. |
| 7048 | \penalty100 |
| 7049 | \fi |
| 7050 | \vskip\envskipamount |
| 7051 | \fi |
| 7052 | \fi |
| 7053 | }} |
| 7054 | |
| 7055 | \def\afterenvbreak{{% |
| 7056 | % =10000 instead of <10000 because of a special case in \itemzzz and |
| 7057 | % \sectionheading, q.v. |
| 7058 | \ifnum \lastpenalty=10000 \else |
| 7059 | \advance\envskipamount by \parskip |
| 7060 | \endgraf |
| 7061 | \ifdim\lastskip<\envskipamount |
| 7062 | \removelastskip |
| 7063 | % it's not a good place to break if the last penalty was \nobreak |
| 7064 | % or better ... |
| 7065 | \ifnum\lastpenalty<10000 \penalty-50 \fi |
| 7066 | \vskip\envskipamount |
| 7067 | \fi |
| 7068 | \fi |
| 7069 | }} |
| 7070 | |
| 7071 | % \nonarrowing is a flag. If "set", @lisp etc don't narrow margins; it will |
| 7072 | % also clear it, so that its embedded environments do the narrowing again. |
| 7073 | \let\nonarrowing=\relax |
| 7074 | |
| 7075 | % @cartouche ... @end cartouche: draw rectangle w/rounded corners around |
| 7076 | % environment contents. |
| 7077 | |
| 7078 | % |
| 7079 | \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth |
| 7080 | \def\ctr{{\hskip 6pt\circle\char'010}} |
| 7081 | \def\cbl{{\circle\char'012\hskip -6pt}} |
| 7082 | \def\cbr{{\hskip 6pt\circle\char'011}} |
| 7083 | \def\carttop{\hbox to \cartouter{\hskip\lskip |
| 7084 | \ctl\leaders\hrule height\circthick\hfil\ctr |
| 7085 | \hskip\rskip}} |
| 7086 | \def\cartbot{\hbox to \cartouter{\hskip\lskip |
| 7087 | \cbl\leaders\hrule height\circthick\hfil\cbr |
| 7088 | \hskip\rskip}} |
| 7089 | % |
| 7090 | \newskip\lskip\newskip\rskip |
| 7091 | |
| 7092 | % only require the font if @cartouche is actually used |
| 7093 | \def\cartouchefontdefs{% |
| 7094 | \font\circle=lcircle10\relax |
| 7095 | \circthick=\fontdimen8\circle |
| 7096 | } |
| 7097 | \newdimen\circthick |
| 7098 | \newdimen\cartouter\newdimen\cartinner |
| 7099 | \newskip\normbskip\newskip\normpskip\newskip\normlskip |
| 7100 | |
| 7101 | |
| 7102 | \envdef\cartouche{% |
| 7103 | \cartouchefontdefs |
| 7104 | \ifhmode\par\fi % can't be in the midst of a paragraph. |
| 7105 | \startsavinginserts |
| 7106 | \lskip=\leftskip \rskip=\rightskip |
| 7107 | \leftskip=0pt\rightskip=0pt % we want these *outside*. |
| 7108 | \cartinner=\hsize \advance\cartinner by-\lskip |
| 7109 | \advance\cartinner by-\rskip |
| 7110 | \cartouter=\hsize |
| 7111 | \advance\cartouter by 18.4pt % allow for 3pt kerns on either |
| 7112 | % side, and for 6pt waste from |
| 7113 | % each corner char, and rule thickness |
| 7114 | \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip |
| 7115 | % |
| 7116 | % If this cartouche directly follows a sectioning command, we need the |
| 7117 | % \parskip glue (backspaced over by default) or the cartouche can |
| 7118 | % collide with the section heading. |
| 7119 | \ifnum\lastpenalty>10000 \vskip\parskip \penalty\lastpenalty \fi |
| 7120 | % |
| 7121 | \setbox\groupbox=\vbox\bgroup |
| 7122 | \baselineskip=0pt\parskip=0pt\lineskip=0pt |
| 7123 | \carttop |
| 7124 | \hbox\bgroup |
| 7125 | \hskip\lskip |
| 7126 | \vrule\kern3pt |
| 7127 | \vbox\bgroup |
| 7128 | \kern3pt |
| 7129 | \hsize=\cartinner |
| 7130 | \baselineskip=\normbskip |
| 7131 | \lineskip=\normlskip |
| 7132 | \parskip=\normpskip |
| 7133 | \vskip -\parskip |
| 7134 | \comment % For explanation, see the end of def\group. |
| 7135 | } |
| 7136 | \def\Ecartouche{% |
| 7137 | \ifhmode\par\fi |
| 7138 | \kern3pt |
| 7139 | \egroup |
| 7140 | \kern3pt\vrule |
| 7141 | \hskip\rskip |
| 7142 | \egroup |
| 7143 | \cartbot |
| 7144 | \egroup |
| 7145 | \addgroupbox |
| 7146 | \checkinserts |
| 7147 | } |
| 7148 | |
| 7149 | |
| 7150 | % This macro is called at the beginning of all the @example variants, |
| 7151 | % inside a group. |
| 7152 | \newdimen\nonfillparindent |
| 7153 | \def\nonfillstart{% |
| 7154 | \aboveenvbreak |
| 7155 | \ifdim\hfuzz < 12pt \hfuzz = 12pt \fi % Don't be fussy |
| 7156 | \sepspaces % Make spaces be word-separators rather than space tokens. |
| 7157 | \let\par = \lisppar % don't ignore blank lines |
| 7158 | \obeylines % each line of input is a line of output |
| 7159 | \parskip = 0pt |
| 7160 | % Turn off paragraph indentation but redefine \indent to emulate |
| 7161 | % the normal \indent. |
| 7162 | \nonfillparindent=\parindent |
| 7163 | \parindent = 0pt |
| 7164 | \let\indent\nonfillindent |
| 7165 | % |
| 7166 | \emergencystretch = 0pt % don't try to avoid overfull boxes |
| 7167 | \ifx\nonarrowing\relax |
| 7168 | \advance \leftskip by \lispnarrowing |
| 7169 | \exdentamount=\lispnarrowing |
| 7170 | \else |
| 7171 | \let\nonarrowing = \relax |
| 7172 | \fi |
| 7173 | \let\exdent=\nofillexdent |
| 7174 | } |
| 7175 | |
| 7176 | \begingroup |
| 7177 | \obeyspaces |
| 7178 | % We want to swallow spaces (but not other tokens) after the fake |
| 7179 | % @indent in our nonfill-environments, where spaces are normally |
| 7180 | % active and set to @tie, resulting in them not being ignored after |
| 7181 | % @indent. |
| 7182 | \gdef\nonfillindent{\futurelet\temp\nonfillindentcheck}% |
| 7183 | \gdef\nonfillindentcheck{% |
| 7184 | \ifx\temp % |
| 7185 | \expandafter\nonfillindentgobble% |
| 7186 | \else% |
| 7187 | \leavevmode\nonfillindentbox% |
| 7188 | \fi% |
| 7189 | }% |
| 7190 | \endgroup |
| 7191 | \def\nonfillindentgobble#1{\nonfillindent} |
| 7192 | \def\nonfillindentbox{\hbox to \nonfillparindent{\hss}} |
| 7193 | |
| 7194 | % If you want all examples etc. small: @set dispenvsize small. |
| 7195 | % If you want even small examples the full size: @set dispenvsize nosmall. |
| 7196 | % This affects the following displayed environments: |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 7197 | % @example, @display, @format, @lisp, @verbatim |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 7198 | % |
| 7199 | \def\smallword{small} |
| 7200 | \def\nosmallword{nosmall} |
| 7201 | \let\SETdispenvsize\relax |
| 7202 | \def\setnormaldispenv{% |
| 7203 | \ifx\SETdispenvsize\smallword |
| 7204 | % end paragraph for sake of leading, in case document has no blank |
| 7205 | % line. This is redundant with what happens in \aboveenvbreak, but |
| 7206 | % we need to do it before changing the fonts, and it's inconvenient |
| 7207 | % to change the fonts afterward. |
| 7208 | \ifnum \lastpenalty=10000 \else \endgraf \fi |
| 7209 | \smallexamplefonts \rm |
| 7210 | \fi |
| 7211 | } |
| 7212 | \def\setsmalldispenv{% |
| 7213 | \ifx\SETdispenvsize\nosmallword |
| 7214 | \else |
| 7215 | \ifnum \lastpenalty=10000 \else \endgraf \fi |
| 7216 | \smallexamplefonts \rm |
| 7217 | \fi |
| 7218 | } |
| 7219 | |
| 7220 | % We often define two environments, @foo and @smallfoo. |
| 7221 | % Let's do it in one command. #1 is the env name, #2 the definition. |
| 7222 | \def\makedispenvdef#1#2{% |
| 7223 | \expandafter\envdef\csname#1\endcsname {\setnormaldispenv #2}% |
| 7224 | \expandafter\envdef\csname small#1\endcsname {\setsmalldispenv #2}% |
| 7225 | \expandafter\let\csname E#1\endcsname \afterenvbreak |
| 7226 | \expandafter\let\csname Esmall#1\endcsname \afterenvbreak |
| 7227 | } |
| 7228 | |
| 7229 | % Define two environment synonyms (#1 and #2) for an environment. |
| 7230 | \def\maketwodispenvdef#1#2#3{% |
| 7231 | \makedispenvdef{#1}{#3}% |
| 7232 | \makedispenvdef{#2}{#3}% |
| 7233 | } |
| 7234 | % |
| 7235 | % @lisp: indented, narrowed, typewriter font; |
| 7236 | % @example: same as @lisp. |
| 7237 | % |
| 7238 | % @smallexample and @smalllisp: use smaller fonts. |
| 7239 | % Originally contributed by Pavel@xerox. |
| 7240 | % |
| 7241 | \maketwodispenvdef{lisp}{example}{% |
| 7242 | \nonfillstart |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 7243 | \tt\setcodequotes |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 7244 | \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special. |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 7245 | \parsearg\gobble |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 7246 | } |
| 7247 | % @display/@smalldisplay: same as @lisp except keep current font. |
| 7248 | % |
| 7249 | \makedispenvdef{display}{% |
| 7250 | \nonfillstart |
| 7251 | \gobble |
| 7252 | } |
| 7253 | |
| 7254 | % @format/@smallformat: same as @display except don't narrow margins. |
| 7255 | % |
| 7256 | \makedispenvdef{format}{% |
| 7257 | \let\nonarrowing = t% |
| 7258 | \nonfillstart |
| 7259 | \gobble |
| 7260 | } |
| 7261 | |
| 7262 | % @flushleft: same as @format, but doesn't obey \SETdispenvsize. |
| 7263 | \envdef\flushleft{% |
| 7264 | \let\nonarrowing = t% |
| 7265 | \nonfillstart |
| 7266 | \gobble |
| 7267 | } |
| 7268 | \let\Eflushleft = \afterenvbreak |
| 7269 | |
| 7270 | % @flushright. |
| 7271 | % |
| 7272 | \envdef\flushright{% |
| 7273 | \let\nonarrowing = t% |
| 7274 | \nonfillstart |
| 7275 | \advance\leftskip by 0pt plus 1fill\relax |
| 7276 | \gobble |
| 7277 | } |
| 7278 | \let\Eflushright = \afterenvbreak |
| 7279 | |
| 7280 | |
| 7281 | % @raggedright does more-or-less normal line breaking but no right |
| 7282 | % justification. From plain.tex. |
| 7283 | \envdef\raggedright{% |
| 7284 | \rightskip0pt plus2.4em \spaceskip.3333em \xspaceskip.5em\relax |
| 7285 | } |
| 7286 | \let\Eraggedright\par |
| 7287 | |
| 7288 | \envdef\raggedleft{% |
| 7289 | \parindent=0pt \leftskip0pt plus2em |
| 7290 | \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt |
| 7291 | \hbadness=10000 % Last line will usually be underfull, so turn off |
| 7292 | % badness reporting. |
| 7293 | } |
| 7294 | \let\Eraggedleft\par |
| 7295 | |
| 7296 | \envdef\raggedcenter{% |
| 7297 | \parindent=0pt \rightskip0pt plus1em \leftskip0pt plus1em |
| 7298 | \spaceskip.3333em \xspaceskip.5em \parfillskip=0pt |
| 7299 | \hbadness=10000 % Last line will usually be underfull, so turn off |
| 7300 | % badness reporting. |
| 7301 | } |
| 7302 | \let\Eraggedcenter\par |
| 7303 | |
| 7304 | |
| 7305 | % @quotation does normal linebreaking (hence we can't use \nonfillstart) |
| 7306 | % and narrows the margins. We keep \parskip nonzero in general, since |
| 7307 | % we're doing normal filling. So, when using \aboveenvbreak and |
| 7308 | % \afterenvbreak, temporarily make \parskip 0. |
| 7309 | % |
| 7310 | \makedispenvdef{quotation}{\quotationstart} |
| 7311 | % |
| 7312 | \def\quotationstart{% |
| 7313 | \indentedblockstart % same as \indentedblock, but increase right margin too. |
| 7314 | \ifx\nonarrowing\relax |
| 7315 | \advance\rightskip by \lispnarrowing |
| 7316 | \fi |
| 7317 | \parsearg\quotationlabel |
| 7318 | } |
| 7319 | |
| 7320 | % We have retained a nonzero parskip for the environment, since we're |
| 7321 | % doing normal filling. |
| 7322 | % |
| 7323 | \def\Equotation{% |
| 7324 | \par |
| 7325 | \ifx\quotationauthor\thisisundefined\else |
| 7326 | % indent a bit. |
| 7327 | \leftline{\kern 2\leftskip \sl ---\quotationauthor}% |
| 7328 | \fi |
| 7329 | {\parskip=0pt \afterenvbreak}% |
| 7330 | } |
| 7331 | \def\Esmallquotation{\Equotation} |
| 7332 | |
| 7333 | % If we're given an argument, typeset it in bold with a colon after. |
| 7334 | \def\quotationlabel#1{% |
| 7335 | \def\temp{#1}% |
| 7336 | \ifx\temp\empty \else |
| 7337 | {\bf #1: }% |
| 7338 | \fi |
| 7339 | } |
| 7340 | |
| 7341 | % @indentedblock is like @quotation, but indents only on the left and |
| 7342 | % has no optional argument. |
| 7343 | % |
| 7344 | \makedispenvdef{indentedblock}{\indentedblockstart} |
| 7345 | % |
| 7346 | \def\indentedblockstart{% |
| 7347 | {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip |
| 7348 | \parindent=0pt |
| 7349 | % |
| 7350 | % @cartouche defines \nonarrowing to inhibit narrowing at next level down. |
| 7351 | \ifx\nonarrowing\relax |
| 7352 | \advance\leftskip by \lispnarrowing |
| 7353 | \exdentamount = \lispnarrowing |
| 7354 | \else |
| 7355 | \let\nonarrowing = \relax |
| 7356 | \fi |
| 7357 | } |
| 7358 | |
| 7359 | % Keep a nonzero parskip for the environment, since we're doing normal filling. |
| 7360 | % |
| 7361 | \def\Eindentedblock{% |
| 7362 | \par |
| 7363 | {\parskip=0pt \afterenvbreak}% |
| 7364 | } |
| 7365 | \def\Esmallindentedblock{\Eindentedblock} |
| 7366 | |
| 7367 | |
| 7368 | % LaTeX-like @verbatim...@end verbatim and @verb{<char>...<char>} |
| 7369 | % If we want to allow any <char> as delimiter, |
| 7370 | % we need the curly braces so that makeinfo sees the @verb command, eg: |
| 7371 | % `@verbx...x' would look like the '@verbx' command. --janneke@gnu.org |
| 7372 | % |
| 7373 | % [Knuth]: Donald Ervin Knuth, 1996. The TeXbook. |
| 7374 | % |
| 7375 | % [Knuth] p.344; only we need to do the other characters Texinfo sets |
| 7376 | % active too. Otherwise, they get lost as the first character on a |
| 7377 | % verbatim line. |
| 7378 | \def\dospecials{% |
| 7379 | \do\ \do\\\do\{\do\}\do\$\do\&% |
| 7380 | \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~% |
| 7381 | \do\<\do\>\do\|\do\@\do+\do\"% |
| 7382 | % Don't do the quotes -- if we do, @set txicodequoteundirected and |
| 7383 | % @set txicodequotebacktick will not have effect on @verb and |
| 7384 | % @verbatim, and ?` and !` ligatures won't get disabled. |
| 7385 | %\do\`\do\'% |
| 7386 | } |
| 7387 | % |
| 7388 | % [Knuth] p. 380 |
| 7389 | \def\uncatcodespecials{% |
| 7390 | \def\do##1{\catcode`##1=\other}\dospecials} |
| 7391 | % |
| 7392 | % Setup for the @verb command. |
| 7393 | % |
| 7394 | % Eight spaces for a tab |
| 7395 | \begingroup |
| 7396 | \catcode`\^^I=\active |
| 7397 | \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }} |
| 7398 | \endgroup |
| 7399 | % |
| 7400 | \def\setupverb{% |
| 7401 | \tt % easiest (and conventionally used) font for verbatim |
| 7402 | \def\par{\leavevmode\endgraf}% |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 7403 | \setcodequotes |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 7404 | \tabeightspaces |
| 7405 | % Respect line breaks, |
| 7406 | % print special symbols as themselves, and |
| 7407 | % make each space count |
| 7408 | % must do in this order: |
| 7409 | \obeylines \uncatcodespecials \sepspaces |
| 7410 | } |
| 7411 | |
| 7412 | % Setup for the @verbatim environment |
| 7413 | % |
| 7414 | % Real tab expansion. |
| 7415 | \newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount |
| 7416 | % |
| 7417 | % We typeset each line of the verbatim in an \hbox, so we can handle |
| 7418 | % tabs. |
| 7419 | \newbox\verbbox |
| 7420 | \def\starttabbox{\setbox\verbbox=\hbox\bgroup} |
| 7421 | % |
| 7422 | \begingroup |
| 7423 | \catcode`\^^I=\active |
| 7424 | \gdef\tabexpand{% |
| 7425 | \catcode`\^^I=\active |
| 7426 | \def^^I{\leavevmode\egroup |
| 7427 | \dimen\verbbox=\wd\verbbox % the width so far, or since the previous tab |
| 7428 | \divide\dimen\verbbox by\tabw |
| 7429 | \multiply\dimen\verbbox by\tabw % compute previous multiple of \tabw |
| 7430 | \advance\dimen\verbbox by\tabw % advance to next multiple of \tabw |
| 7431 | \wd\verbbox=\dimen\verbbox |
| 7432 | \leavevmode\box\verbbox \starttabbox |
| 7433 | }% |
| 7434 | } |
| 7435 | \endgroup |
| 7436 | |
| 7437 | % start the verbatim environment. |
| 7438 | \def\setupverbatim{% |
| 7439 | \let\nonarrowing = t% |
| 7440 | \nonfillstart |
| 7441 | \tt % easiest (and conventionally used) font for verbatim |
| 7442 | \def\par{\egroup\leavevmode\box\verbbox\endgraf\starttabbox}% |
| 7443 | \tabexpand |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 7444 | \setcodequotes |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 7445 | % Respect line breaks, |
| 7446 | % print special symbols as themselves, and |
| 7447 | % make each space count. |
| 7448 | % Must do in this order: |
| 7449 | \obeylines \uncatcodespecials \sepspaces |
| 7450 | } |
| 7451 | |
| 7452 | % Do the @verb magic: verbatim text is quoted by unique |
| 7453 | % delimiter characters. Before first delimiter expect a |
| 7454 | % right brace, after last delimiter expect closing brace: |
| 7455 | % |
| 7456 | % \def\doverb'{'<char>#1<char>'}'{#1} |
| 7457 | % |
| 7458 | % [Knuth] p. 382; only eat outer {} |
| 7459 | \begingroup |
| 7460 | \catcode`[=1\catcode`]=2\catcode`\{=\other\catcode`\}=\other |
| 7461 | \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next] |
| 7462 | \endgroup |
| 7463 | % |
| 7464 | \def\verb{\begingroup\setupverb\doverb} |
| 7465 | % |
| 7466 | % |
| 7467 | % Do the @verbatim magic: define the macro \doverbatim so that |
| 7468 | % the (first) argument ends when '@end verbatim' is reached, ie: |
| 7469 | % |
| 7470 | % \def\doverbatim#1@end verbatim{#1} |
| 7471 | % |
| 7472 | % For Texinfo it's a lot easier than for LaTeX, |
| 7473 | % because texinfo's \verbatim doesn't stop at '\end{verbatim}': |
| 7474 | % we need not redefine '\', '{' and '}'. |
| 7475 | % |
| 7476 | % Inspired by LaTeX's verbatim command set [latex.ltx] |
| 7477 | % |
| 7478 | \begingroup |
| 7479 | \catcode`\ =\active |
| 7480 | \obeylines % |
| 7481 | % ignore everything up to the first ^^M, that's the newline at the end |
| 7482 | % of the @verbatim input line itself. Otherwise we get an extra blank |
| 7483 | % line in the output. |
| 7484 | \xdef\doverbatim#1^^M#2@end verbatim{% |
| 7485 | \starttabbox#2\egroup\noexpand\end\gobble verbatim}% |
| 7486 | % We really want {...\end verbatim} in the body of the macro, but |
| 7487 | % without the active space; thus we have to use \xdef and \gobble. |
| 7488 | % The \egroup ends the \verbbox started at the end of the last line in |
| 7489 | % the block. |
| 7490 | \endgroup |
| 7491 | % |
| 7492 | \envdef\verbatim{% |
| 7493 | \setnormaldispenv\setupverbatim\doverbatim |
| 7494 | } |
| 7495 | \let\Everbatim = \afterenvbreak |
| 7496 | |
| 7497 | |
| 7498 | % @verbatiminclude FILE - insert text of file in verbatim environment. |
| 7499 | % |
| 7500 | \def\verbatiminclude{\parseargusing\filenamecatcodes\doverbatiminclude} |
| 7501 | % |
| 7502 | \def\doverbatiminclude#1{% |
| 7503 | {% |
| 7504 | \makevalueexpandable |
| 7505 | \setupverbatim |
| 7506 | {% |
| 7507 | \indexnofonts % Allow `@@' and other weird things in file names. |
| 7508 | \wlog{texinfo.tex: doing @verbatiminclude of #1^^J}% |
| 7509 | \edef\tmp{\noexpand\input #1 } |
| 7510 | \expandafter |
| 7511 | }\expandafter\starttabbox\tmp\egroup |
| 7512 | \afterenvbreak |
| 7513 | }% |
| 7514 | } |
| 7515 | |
| 7516 | % @copying ... @end copying. |
| 7517 | % Save the text away for @insertcopying later. |
| 7518 | % |
| 7519 | % We save the uninterpreted tokens, rather than creating a box. |
| 7520 | % Saving the text in a box would be much easier, but then all the |
| 7521 | % typesetting commands (@smallbook, font changes, etc.) have to be done |
| 7522 | % beforehand -- and a) we want @copying to be done first in the source |
| 7523 | % file; b) letting users define the frontmatter in as flexible order as |
| 7524 | % possible is desirable. |
| 7525 | % |
| 7526 | \def\copying{\checkenv{}\begingroup\scanargctxt\docopying} |
| 7527 | \def\docopying#1@end copying{\endgroup\def\copyingtext{#1}} |
| 7528 | % |
| 7529 | \def\insertcopying{% |
| 7530 | \begingroup |
| 7531 | \parindent = 0pt % paragraph indentation looks wrong on title page |
| 7532 | \scanexp\copyingtext |
| 7533 | \endgroup |
| 7534 | } |
| 7535 | |
| 7536 | |
| 7537 | \message{defuns,} |
| 7538 | % @defun etc. |
| 7539 | |
| 7540 | \newskip\defbodyindent \defbodyindent=.4in |
| 7541 | \newskip\defargsindent \defargsindent=50pt |
| 7542 | \newskip\deflastargmargin \deflastargmargin=18pt |
| 7543 | \newcount\defunpenalty |
| 7544 | |
| 7545 | % Start the processing of @deffn: |
| 7546 | \def\startdefun{% |
| 7547 | \ifnum\lastpenalty<10000 |
| 7548 | \medbreak |
| 7549 | \defunpenalty=10003 % Will keep this @deffn together with the |
| 7550 | % following @def command, see below. |
| 7551 | \else |
| 7552 | % If there are two @def commands in a row, we'll have a \nobreak, |
| 7553 | % which is there to keep the function description together with its |
| 7554 | % header. But if there's nothing but headers, we need to allow a |
| 7555 | % break somewhere. Check specifically for penalty 10002, inserted |
| 7556 | % by \printdefunline, instead of 10000, since the sectioning |
| 7557 | % commands also insert a nobreak penalty, and we don't want to allow |
| 7558 | % a break between a section heading and a defun. |
| 7559 | % |
| 7560 | % As a further refinement, we avoid "club" headers by signalling |
| 7561 | % with penalty of 10003 after the very first @deffn in the |
| 7562 | % sequence (see above), and penalty of 10002 after any following |
| 7563 | % @def command. |
| 7564 | \ifnum\lastpenalty=10002 \penalty2000 \else \defunpenalty=10002 \fi |
| 7565 | % |
| 7566 | % Similarly, after a section heading, do not allow a break. |
| 7567 | % But do insert the glue. |
| 7568 | \medskip % preceded by discardable penalty, so not a breakpoint |
| 7569 | \fi |
| 7570 | % |
| 7571 | \parindent=0in |
| 7572 | \advance\leftskip by \defbodyindent |
| 7573 | \exdentamount=\defbodyindent |
| 7574 | } |
| 7575 | |
| 7576 | \def\dodefunx#1{% |
| 7577 | % First, check whether we are in the right environment: |
| 7578 | \checkenv#1% |
| 7579 | % |
| 7580 | % As above, allow line break if we have multiple x headers in a row. |
| 7581 | % It's not a great place, though. |
| 7582 | \ifnum\lastpenalty=10002 \penalty3000 \else \defunpenalty=10002 \fi |
| 7583 | % |
| 7584 | % And now, it's time to reuse the body of the original defun: |
| 7585 | \expandafter\gobbledefun#1% |
| 7586 | } |
| 7587 | \def\gobbledefun#1\startdefun{} |
| 7588 | |
| 7589 | % \printdefunline \deffnheader{text} |
| 7590 | % |
| 7591 | \def\printdefunline#1#2{% |
| 7592 | \begingroup |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 7593 | \plainfrenchspacing |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 7594 | % call \deffnheader: |
| 7595 | #1#2 \endheader |
| 7596 | % common ending: |
| 7597 | \interlinepenalty = 10000 |
| 7598 | \advance\rightskip by 0pt plus 1fil\relax |
| 7599 | \endgraf |
| 7600 | \nobreak\vskip -\parskip |
| 7601 | \penalty\defunpenalty % signal to \startdefun and \dodefunx |
| 7602 | % Some of the @defun-type tags do not enable magic parentheses, |
| 7603 | % rendering the following check redundant. But we don't optimize. |
| 7604 | \checkparencounts |
| 7605 | \endgroup |
| 7606 | } |
| 7607 | |
| 7608 | \def\Edefun{\endgraf\medbreak} |
| 7609 | |
| 7610 | % \makedefun{deffn} creates \deffn, \deffnx and \Edeffn; |
| 7611 | % the only thing remaining is to define \deffnheader. |
| 7612 | % |
| 7613 | \def\makedefun#1{% |
| 7614 | \expandafter\let\csname E#1\endcsname = \Edefun |
| 7615 | \edef\temp{\noexpand\domakedefun |
| 7616 | \makecsname{#1}\makecsname{#1x}\makecsname{#1header}}% |
| 7617 | \temp |
| 7618 | } |
| 7619 | |
| 7620 | % \domakedefun \deffn \deffnx \deffnheader { (defn. of \deffnheader) } |
| 7621 | % |
| 7622 | % Define \deffn and \deffnx, without parameters. |
| 7623 | % \deffnheader has to be defined explicitly. |
| 7624 | % |
| 7625 | \def\domakedefun#1#2#3{% |
| 7626 | \envdef#1{% |
| 7627 | \startdefun |
| 7628 | \doingtypefnfalse % distinguish typed functions from all else |
| 7629 | \parseargusing\activeparens{\printdefunline#3}% |
| 7630 | }% |
| 7631 | \def#2{\dodefunx#1}% |
| 7632 | \def#3% |
| 7633 | } |
| 7634 | |
| 7635 | \newif\ifdoingtypefn % doing typed function? |
| 7636 | \newif\ifrettypeownline % typeset return type on its own line? |
| 7637 | |
| 7638 | % @deftypefnnewline on|off says whether the return type of typed functions |
| 7639 | % are printed on their own line. This affects @deftypefn, @deftypefun, |
| 7640 | % @deftypeop, and @deftypemethod. |
| 7641 | % |
| 7642 | \parseargdef\deftypefnnewline{% |
| 7643 | \def\temp{#1}% |
| 7644 | \ifx\temp\onword |
| 7645 | \expandafter\let\csname SETtxideftypefnnl\endcsname |
| 7646 | = \empty |
| 7647 | \else\ifx\temp\offword |
| 7648 | \expandafter\let\csname SETtxideftypefnnl\endcsname |
| 7649 | = \relax |
| 7650 | \else |
| 7651 | \errhelp = \EMsimple |
| 7652 | \errmessage{Unknown @txideftypefnnl value `\temp', |
| 7653 | must be on|off}% |
| 7654 | \fi\fi |
| 7655 | } |
| 7656 | |
| 7657 | % \dosubind {index}{topic}{subtopic} |
| 7658 | % |
| 7659 | % If SUBTOPIC is present, precede it with a space, and call \doind. |
| 7660 | % (At some time during the 20th century, this made a two-level entry in an |
| 7661 | % index such as the operation index. Nobody seemed to notice the change in |
| 7662 | % behaviour though.) |
| 7663 | \def\dosubind#1#2#3{% |
| 7664 | \def\thirdarg{#3}% |
| 7665 | \ifx\thirdarg\empty |
| 7666 | \doind{#1}{#2}% |
| 7667 | \else |
| 7668 | \doind{#1}{#2\space#3}% |
| 7669 | \fi |
| 7670 | } |
| 7671 | |
| 7672 | % Untyped functions: |
| 7673 | |
| 7674 | % @deffn category name args |
| 7675 | \makedefun{deffn}{\deffngeneral{}} |
| 7676 | |
| 7677 | % @deffn category class name args |
| 7678 | \makedefun{defop}#1 {\defopon{#1\ \putwordon}} |
| 7679 | |
| 7680 | % \defopon {category on}class name args |
| 7681 | \def\defopon#1#2 {\deffngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} } |
| 7682 | |
| 7683 | % \deffngeneral {subind}category name args |
| 7684 | % |
| 7685 | \def\deffngeneral#1#2 #3 #4\endheader{% |
| 7686 | \dosubind{fn}{\code{#3}}{#1}% |
| 7687 | \defname{#2}{}{#3}\magicamp\defunargs{#4\unskip}% |
| 7688 | } |
| 7689 | |
| 7690 | % Typed functions: |
| 7691 | |
| 7692 | % @deftypefn category type name args |
| 7693 | \makedefun{deftypefn}{\deftypefngeneral{}} |
| 7694 | |
| 7695 | % @deftypeop category class type name args |
| 7696 | \makedefun{deftypeop}#1 {\deftypeopon{#1\ \putwordon}} |
| 7697 | |
| 7698 | % \deftypeopon {category on}class type name args |
| 7699 | \def\deftypeopon#1#2 {\deftypefngeneral{\putwordon\ \code{#2}}{#1\ \code{#2}} } |
| 7700 | |
| 7701 | % \deftypefngeneral {subind}category type name args |
| 7702 | % |
| 7703 | \def\deftypefngeneral#1#2 #3 #4 #5\endheader{% |
| 7704 | \dosubind{fn}{\code{#4}}{#1}% |
| 7705 | \doingtypefntrue |
| 7706 | \defname{#2}{#3}{#4}\defunargs{#5\unskip}% |
| 7707 | } |
| 7708 | |
| 7709 | % Typed variables: |
| 7710 | |
| 7711 | % @deftypevr category type var args |
| 7712 | \makedefun{deftypevr}{\deftypecvgeneral{}} |
| 7713 | |
| 7714 | % @deftypecv category class type var args |
| 7715 | \makedefun{deftypecv}#1 {\deftypecvof{#1\ \putwordof}} |
| 7716 | |
| 7717 | % \deftypecvof {category of}class type var args |
| 7718 | \def\deftypecvof#1#2 {\deftypecvgeneral{\putwordof\ \code{#2}}{#1\ \code{#2}} } |
| 7719 | |
| 7720 | % \deftypecvgeneral {subind}category type var args |
| 7721 | % |
| 7722 | \def\deftypecvgeneral#1#2 #3 #4 #5\endheader{% |
| 7723 | \dosubind{vr}{\code{#4}}{#1}% |
| 7724 | \defname{#2}{#3}{#4}\defunargs{#5\unskip}% |
| 7725 | } |
| 7726 | |
| 7727 | % Untyped variables: |
| 7728 | |
| 7729 | % @defvr category var args |
| 7730 | \makedefun{defvr}#1 {\deftypevrheader{#1} {} } |
| 7731 | |
| 7732 | % @defcv category class var args |
| 7733 | \makedefun{defcv}#1 {\defcvof{#1\ \putwordof}} |
| 7734 | |
| 7735 | % \defcvof {category of}class var args |
| 7736 | \def\defcvof#1#2 {\deftypecvof{#1}#2 {} } |
| 7737 | |
| 7738 | % Types: |
| 7739 | |
| 7740 | % @deftp category name args |
| 7741 | \makedefun{deftp}#1 #2 #3\endheader{% |
| 7742 | \doind{tp}{\code{#2}}% |
| 7743 | \defname{#1}{}{#2}\defunargs{#3\unskip}% |
| 7744 | } |
| 7745 | |
| 7746 | % Remaining @defun-like shortcuts: |
| 7747 | \makedefun{defun}{\deffnheader{\putwordDeffunc} } |
| 7748 | \makedefun{defmac}{\deffnheader{\putwordDefmac} } |
| 7749 | \makedefun{defspec}{\deffnheader{\putwordDefspec} } |
| 7750 | \makedefun{deftypefun}{\deftypefnheader{\putwordDeffunc} } |
| 7751 | \makedefun{defvar}{\defvrheader{\putwordDefvar} } |
| 7752 | \makedefun{defopt}{\defvrheader{\putwordDefopt} } |
| 7753 | \makedefun{deftypevar}{\deftypevrheader{\putwordDefvar} } |
| 7754 | \makedefun{defmethod}{\defopon\putwordMethodon} |
| 7755 | \makedefun{deftypemethod}{\deftypeopon\putwordMethodon} |
| 7756 | \makedefun{defivar}{\defcvof\putwordInstanceVariableof} |
| 7757 | \makedefun{deftypeivar}{\deftypecvof\putwordInstanceVariableof} |
| 7758 | |
| 7759 | % \defname, which formats the name of the @def (not the args). |
| 7760 | % #1 is the category, such as "Function". |
| 7761 | % #2 is the return type, if any. |
| 7762 | % #3 is the function name. |
| 7763 | % |
| 7764 | % We are followed by (but not passed) the arguments, if any. |
| 7765 | % |
| 7766 | \def\defname#1#2#3{% |
| 7767 | \par |
| 7768 | % Get the values of \leftskip and \rightskip as they were outside the @def... |
| 7769 | \advance\leftskip by -\defbodyindent |
| 7770 | % |
| 7771 | % Determine if we are typesetting the return type of a typed function |
| 7772 | % on a line by itself. |
| 7773 | \rettypeownlinefalse |
| 7774 | \ifdoingtypefn % doing a typed function specifically? |
| 7775 | % then check user option for putting return type on its own line: |
| 7776 | \expandafter\ifx\csname SETtxideftypefnnl\endcsname\relax \else |
| 7777 | \rettypeownlinetrue |
| 7778 | \fi |
| 7779 | \fi |
| 7780 | % |
| 7781 | % How we'll format the category name. Putting it in brackets helps |
| 7782 | % distinguish it from the body text that may end up on the next line |
| 7783 | % just below it. |
| 7784 | \def\temp{#1}% |
| 7785 | \setbox0=\hbox{\kern\deflastargmargin \ifx\temp\empty\else [\rm\temp]\fi} |
| 7786 | % |
| 7787 | % Figure out line sizes for the paragraph shape. We'll always have at |
| 7788 | % least two. |
| 7789 | \tempnum = 2 |
| 7790 | % |
| 7791 | % The first line needs space for \box0; but if \rightskip is nonzero, |
| 7792 | % we need only space for the part of \box0 which exceeds it: |
| 7793 | \dimen0=\hsize \advance\dimen0 by -\wd0 \advance\dimen0 by \rightskip |
| 7794 | % |
| 7795 | % If doing a return type on its own line, we'll have another line. |
| 7796 | \ifrettypeownline |
| 7797 | \advance\tempnum by 1 |
| 7798 | \def\maybeshapeline{0in \hsize}% |
| 7799 | \else |
| 7800 | \def\maybeshapeline{}% |
| 7801 | \fi |
| 7802 | % |
| 7803 | % The continuations: |
| 7804 | \dimen2=\hsize \advance\dimen2 by -\defargsindent |
| 7805 | % |
| 7806 | % The final paragraph shape: |
| 7807 | \parshape \tempnum 0in \dimen0 \maybeshapeline \defargsindent \dimen2 |
| 7808 | % |
| 7809 | % Put the category name at the right margin. |
| 7810 | \noindent |
| 7811 | \hbox to 0pt{% |
| 7812 | \hfil\box0 \kern-\hsize |
| 7813 | % \hsize has to be shortened this way: |
| 7814 | \kern\leftskip |
| 7815 | % Intentionally do not respect \rightskip, since we need the space. |
| 7816 | }% |
| 7817 | % |
| 7818 | % Allow all lines to be underfull without complaint: |
| 7819 | \tolerance=10000 \hbadness=10000 |
| 7820 | \exdentamount=\defbodyindent |
| 7821 | {% |
| 7822 | % defun fonts. We use typewriter by default (used to be bold) because: |
| 7823 | % . we're printing identifiers, they should be in tt in principle. |
| 7824 | % . in languages with many accents, such as Czech or French, it's |
| 7825 | % common to leave accents off identifiers. The result looks ok in |
| 7826 | % tt, but exceedingly strange in rm. |
| 7827 | % . we don't want -- and --- to be treated as ligatures. |
| 7828 | % . this still does not fix the ?` and !` ligatures, but so far no |
| 7829 | % one has made identifiers using them :). |
| 7830 | \df \tt |
| 7831 | \def\temp{#2}% text of the return type |
| 7832 | \ifx\temp\empty\else |
| 7833 | \tclose{\temp}% typeset the return type |
| 7834 | \ifrettypeownline |
| 7835 | % put return type on its own line; prohibit line break following: |
| 7836 | \hfil\vadjust{\nobreak}\break |
| 7837 | \else |
| 7838 | \space % type on same line, so just followed by a space |
| 7839 | \fi |
| 7840 | \fi % no return type |
| 7841 | #3% output function name |
| 7842 | }% |
| 7843 | {\rm\enskip}% hskip 0.5 em of \rmfont |
| 7844 | % |
| 7845 | \boldbrax |
| 7846 | % arguments will be output next, if any. |
| 7847 | } |
| 7848 | |
| 7849 | % Print arguments in slanted roman (not ttsl), inconsistently with using |
| 7850 | % tt for the name. This is because literal text is sometimes needed in |
| 7851 | % the argument list (groff manual), and ttsl and tt are not very |
| 7852 | % distinguishable. Prevent hyphenation at `-' chars. |
| 7853 | % |
| 7854 | \def\defunargs#1{% |
| 7855 | % use sl by default (not ttsl), |
| 7856 | % tt for the names. |
| 7857 | \df \sl \hyphenchar\font=0 |
| 7858 | % |
| 7859 | % On the other hand, if an argument has two dashes (for instance), we |
| 7860 | % want a way to get ttsl. We used to recommend @var for that, so |
| 7861 | % leave the code in, but it's strange for @var to lead to typewriter. |
| 7862 | % Nowadays we recommend @code, since the difference between a ttsl hyphen |
| 7863 | % and a tt hyphen is pretty tiny. @code also disables ?` !`. |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 7864 | \def\var##1{{\setregularquotes\ttslanted{##1}}}% |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 7865 | #1% |
| 7866 | \sl\hyphenchar\font=45 |
| 7867 | } |
| 7868 | |
| 7869 | % We want ()&[] to print specially on the defun line. |
| 7870 | % |
| 7871 | \def\activeparens{% |
| 7872 | \catcode`\(=\active \catcode`\)=\active |
| 7873 | \catcode`\[=\active \catcode`\]=\active |
| 7874 | \catcode`\&=\active |
| 7875 | } |
| 7876 | |
| 7877 | % Make control sequences which act like normal parenthesis chars. |
| 7878 | \let\lparen = ( \let\rparen = ) |
| 7879 | |
| 7880 | % Be sure that we always have a definition for `(', etc. For example, |
| 7881 | % if the fn name has parens in it, \boldbrax will not be in effect yet, |
| 7882 | % so TeX would otherwise complain about undefined control sequence. |
| 7883 | { |
| 7884 | \activeparens |
| 7885 | \global\let(=\lparen \global\let)=\rparen |
| 7886 | \global\let[=\lbrack \global\let]=\rbrack |
| 7887 | \global\let& = \& |
| 7888 | |
| 7889 | \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb} |
| 7890 | \gdef\magicamp{\let&=\amprm} |
| 7891 | } |
| 7892 | \let\ampchar\& |
| 7893 | |
| 7894 | \newcount\parencount |
| 7895 | |
| 7896 | % If we encounter &foo, then turn on ()-hacking afterwards |
| 7897 | \newif\ifampseen |
| 7898 | \def\amprm#1 {\ampseentrue{\bf\ }} |
| 7899 | |
| 7900 | \def\parenfont{% |
| 7901 | \ifampseen |
| 7902 | % At the first level, print parens in roman, |
| 7903 | % otherwise use the default font. |
| 7904 | \ifnum \parencount=1 \rm \fi |
| 7905 | \else |
| 7906 | % The \sf parens (in \boldbrax) actually are a little bolder than |
| 7907 | % the contained text. This is especially needed for [ and ] . |
| 7908 | \sf |
| 7909 | \fi |
| 7910 | } |
| 7911 | \def\infirstlevel#1{% |
| 7912 | \ifampseen |
| 7913 | \ifnum\parencount=1 |
| 7914 | #1% |
| 7915 | \fi |
| 7916 | \fi |
| 7917 | } |
| 7918 | \def\bfafterword#1 {#1 \bf} |
| 7919 | |
| 7920 | \def\opnr{% |
| 7921 | \global\advance\parencount by 1 |
| 7922 | {\parenfont(}% |
| 7923 | \infirstlevel \bfafterword |
| 7924 | } |
| 7925 | \def\clnr{% |
| 7926 | {\parenfont)}% |
| 7927 | \infirstlevel \sl |
| 7928 | \global\advance\parencount by -1 |
| 7929 | } |
| 7930 | |
| 7931 | \newcount\brackcount |
| 7932 | \def\lbrb{% |
| 7933 | \global\advance\brackcount by 1 |
| 7934 | {\bf[}% |
| 7935 | } |
| 7936 | \def\rbrb{% |
| 7937 | {\bf]}% |
| 7938 | \global\advance\brackcount by -1 |
| 7939 | } |
| 7940 | |
| 7941 | \def\checkparencounts{% |
| 7942 | \ifnum\parencount=0 \else \badparencount \fi |
| 7943 | \ifnum\brackcount=0 \else \badbrackcount \fi |
| 7944 | } |
| 7945 | % these should not use \errmessage; the glibc manual, at least, actually |
| 7946 | % has such constructs (when documenting function pointers). |
| 7947 | \def\badparencount{% |
| 7948 | \message{Warning: unbalanced parentheses in @def...}% |
| 7949 | \global\parencount=0 |
| 7950 | } |
| 7951 | \def\badbrackcount{% |
| 7952 | \message{Warning: unbalanced square brackets in @def...}% |
| 7953 | \global\brackcount=0 |
| 7954 | } |
| 7955 | |
| 7956 | |
| 7957 | \message{macros,} |
| 7958 | % @macro. |
| 7959 | |
| 7960 | % To do this right we need a feature of e-TeX, \scantokens, |
| 7961 | % which we arrange to emulate with a temporary file in ordinary TeX. |
| 7962 | \ifx\eTeXversion\thisisundefined |
| 7963 | \newwrite\macscribble |
| 7964 | \def\scantokens#1{% |
| 7965 | \toks0={#1}% |
| 7966 | \immediate\openout\macscribble=\jobname.tmp |
| 7967 | \immediate\write\macscribble{\the\toks0}% |
| 7968 | \immediate\closeout\macscribble |
| 7969 | \input \jobname.tmp |
| 7970 | } |
| 7971 | \fi |
| 7972 | |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 7973 | \let\E=\expandafter |
| 7974 | |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 7975 | % Used at the time of macro expansion. |
| 7976 | % Argument is macro body with arguments substituted |
| 7977 | \def\scanmacro#1{% |
| 7978 | \newlinechar`\^^M |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 7979 | % expand the expansion of \eatleadingcr twice to maybe remove a leading |
| 7980 | % newline (and \else and \fi tokens), then call \eatspaces on the result. |
| 7981 | \def\xeatspaces##1{% |
| 7982 | \E\E\E\E\E\E\E\eatspaces\E\E\E\E\E\E\E{\eatleadingcr##1% |
| 7983 | }}% |
| 7984 | \def\xempty##1{}% |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 7985 | % |
| 7986 | % Process the macro body under the current catcode regime. |
| 7987 | \scantokens{#1@comment}% |
| 7988 | % |
| 7989 | % The \comment is to remove the \newlinechar added by \scantokens, and |
| 7990 | % can be noticed by \parsearg. Note \c isn't used because this means cedilla |
| 7991 | % in math mode. |
| 7992 | } |
| 7993 | |
| 7994 | % Used for copying and captions |
| 7995 | \def\scanexp#1{% |
| 7996 | \expandafter\scanmacro\expandafter{#1}% |
| 7997 | } |
| 7998 | |
| 7999 | \newcount\paramno % Count of parameters |
| 8000 | \newtoks\macname % Macro name |
| 8001 | \newif\ifrecursive % Is it recursive? |
| 8002 | |
| 8003 | % List of all defined macros in the form |
| 8004 | % \commondummyword\macro1\commondummyword\macro2... |
| 8005 | % Currently is also contains all @aliases; the list can be split |
| 8006 | % if there is a need. |
| 8007 | \def\macrolist{} |
| 8008 | |
| 8009 | % Add the macro to \macrolist |
| 8010 | \def\addtomacrolist#1{\expandafter \addtomacrolistxxx \csname#1\endcsname} |
| 8011 | \def\addtomacrolistxxx#1{% |
| 8012 | \toks0 = \expandafter{\macrolist\commondummyword#1}% |
| 8013 | \xdef\macrolist{\the\toks0}% |
| 8014 | } |
| 8015 | |
| 8016 | % Utility routines. |
| 8017 | % This does \let #1 = #2, with \csnames; that is, |
| 8018 | % \let \csname#1\endcsname = \csname#2\endcsname |
| 8019 | % (except of course we have to play expansion games). |
| 8020 | % |
| 8021 | \def\cslet#1#2{% |
| 8022 | \expandafter\let |
| 8023 | \csname#1\expandafter\endcsname |
| 8024 | \csname#2\endcsname |
| 8025 | } |
| 8026 | |
| 8027 | % Trim leading and trailing spaces off a string. |
| 8028 | % Concepts from aro-bend problem 15 (see CTAN). |
| 8029 | {\catcode`\@=11 |
| 8030 | \gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }} |
| 8031 | \gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@} |
| 8032 | \gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @} |
| 8033 | \def\unbrace#1{#1} |
| 8034 | \unbrace{\gdef\trim@@@ #1 } #2@{#1} |
| 8035 | } |
| 8036 | |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 8037 | {\catcode`\^^M=\other% |
| 8038 | \gdef\eatleadingcr#1{\if\noexpand#1\noexpand^^M\else\E#1\fi}}% |
| 8039 | % Warning: this won't work for a delimited argument |
| 8040 | % or for an empty argument |
| 8041 | |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 8042 | % Trim a single trailing ^^M off a string. |
| 8043 | {\catcode`\^^M=\other \catcode`\Q=3% |
| 8044 | \gdef\eatcr #1{\eatcra #1Q^^MQ}% |
| 8045 | \gdef\eatcra#1^^MQ{\eatcrb#1Q}% |
| 8046 | \gdef\eatcrb#1Q#2Q{#1}% |
| 8047 | } |
| 8048 | |
| 8049 | % Macro bodies are absorbed as an argument in a context where |
| 8050 | % all characters are catcode 10, 11 or 12, except \ which is active |
| 8051 | % (as in normal texinfo). It is necessary to change the definition of \ |
| 8052 | % to recognize macro arguments; this is the job of \mbodybackslash. |
| 8053 | % |
| 8054 | % Non-ASCII encodings make 8-bit characters active, so un-activate |
| 8055 | % them to avoid their expansion. Must do this non-globally, to |
| 8056 | % confine the change to the current group. |
| 8057 | % |
| 8058 | % It's necessary to have hard CRs when the macro is executed. This is |
| 8059 | % done by making ^^M (\endlinechar) catcode 12 when reading the macro |
| 8060 | % body, and then making it the \newlinechar in \scanmacro. |
| 8061 | % |
| 8062 | \def\scanctxt{% used as subroutine |
| 8063 | \catcode`\"=\other |
| 8064 | \catcode`\+=\other |
| 8065 | \catcode`\<=\other |
| 8066 | \catcode`\>=\other |
| 8067 | \catcode`\^=\other |
| 8068 | \catcode`\_=\other |
| 8069 | \catcode`\|=\other |
| 8070 | \catcode`\~=\other |
| 8071 | \passthroughcharstrue |
| 8072 | } |
| 8073 | |
| 8074 | \def\scanargctxt{% used for copying and captions, not macros. |
| 8075 | \scanctxt |
| 8076 | \catcode`\@=\other |
| 8077 | \catcode`\\=\other |
| 8078 | \catcode`\^^M=\other |
| 8079 | } |
| 8080 | |
| 8081 | \def\macrobodyctxt{% used for @macro definitions |
| 8082 | \scanctxt |
| 8083 | \catcode`\ =\other |
| 8084 | \catcode`\@=\other |
| 8085 | \catcode`\{=\other |
| 8086 | \catcode`\}=\other |
| 8087 | \catcode`\^^M=\other |
| 8088 | \usembodybackslash |
| 8089 | } |
| 8090 | |
| 8091 | % Used when scanning braced macro arguments. Note, however, that catcode |
| 8092 | % changes here are ineffectual if the macro invocation was nested inside |
| 8093 | % an argument to another Texinfo command. |
| 8094 | \def\macroargctxt{% |
| 8095 | \scanctxt |
| 8096 | \catcode`\ =\active |
| 8097 | \catcode`\@=\other |
| 8098 | \catcode`\^^M=\other |
| 8099 | \catcode`\\=\active |
| 8100 | } |
| 8101 | |
| 8102 | \def\macrolineargctxt{% used for whole-line arguments without braces |
| 8103 | \scanctxt |
| 8104 | \catcode`\@=\other |
| 8105 | \catcode`\{=\other |
| 8106 | \catcode`\}=\other |
| 8107 | } |
| 8108 | |
| 8109 | % \mbodybackslash is the definition of \ in @macro bodies. |
| 8110 | % It maps \foo\ => \csname macarg.foo\endcsname => #N |
| 8111 | % where N is the macro parameter number. |
| 8112 | % We define \csname macarg.\endcsname to be \realbackslash, so |
| 8113 | % \\ in macro replacement text gets you a backslash. |
| 8114 | % |
| 8115 | {\catcode`@=0 @catcode`@\=@active |
| 8116 | @gdef@usembodybackslash{@let\=@mbodybackslash} |
| 8117 | @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname} |
| 8118 | } |
| 8119 | \expandafter\def\csname macarg.\endcsname{\realbackslash} |
| 8120 | |
| 8121 | \def\margbackslash#1{\char`\#1 } |
| 8122 | |
| 8123 | \def\macro{\recursivefalse\parsearg\macroxxx} |
| 8124 | \def\rmacro{\recursivetrue\parsearg\macroxxx} |
| 8125 | |
| 8126 | \def\macroxxx#1{% |
| 8127 | \getargs{#1}% now \macname is the macname and \argl the arglist |
| 8128 | \ifx\argl\empty % no arguments |
| 8129 | \paramno=0\relax |
| 8130 | \else |
| 8131 | \expandafter\parsemargdef \argl;% |
| 8132 | \if\paramno>256\relax |
| 8133 | \ifx\eTeXversion\thisisundefined |
| 8134 | \errhelp = \EMsimple |
| 8135 | \errmessage{You need eTeX to compile a file with macros with more than 256 arguments} |
| 8136 | \fi |
| 8137 | \fi |
| 8138 | \fi |
| 8139 | \if1\csname ismacro.\the\macname\endcsname |
| 8140 | \message{Warning: redefining \the\macname}% |
| 8141 | \else |
| 8142 | \expandafter\ifx\csname \the\macname\endcsname \relax |
| 8143 | \else \errmessage{Macro name \the\macname\space already defined}\fi |
| 8144 | \global\cslet{macsave.\the\macname}{\the\macname}% |
| 8145 | \global\expandafter\let\csname ismacro.\the\macname\endcsname=1% |
| 8146 | \addtomacrolist{\the\macname}% |
| 8147 | \fi |
| 8148 | \begingroup \macrobodyctxt |
| 8149 | \ifrecursive \expandafter\parsermacbody |
| 8150 | \else \expandafter\parsemacbody |
| 8151 | \fi} |
| 8152 | |
| 8153 | \parseargdef\unmacro{% |
| 8154 | \if1\csname ismacro.#1\endcsname |
| 8155 | \global\cslet{#1}{macsave.#1}% |
| 8156 | \global\expandafter\let \csname ismacro.#1\endcsname=0% |
| 8157 | % Remove the macro name from \macrolist: |
| 8158 | \begingroup |
| 8159 | \expandafter\let\csname#1\endcsname \relax |
| 8160 | \let\commondummyword\unmacrodo |
| 8161 | \xdef\macrolist{\macrolist}% |
| 8162 | \endgroup |
| 8163 | \else |
| 8164 | \errmessage{Macro #1 not defined}% |
| 8165 | \fi |
| 8166 | } |
| 8167 | |
| 8168 | % Called by \do from \dounmacro on each macro. The idea is to omit any |
| 8169 | % macro definitions that have been changed to \relax. |
| 8170 | % |
| 8171 | \def\unmacrodo#1{% |
| 8172 | \ifx #1\relax |
| 8173 | % remove this |
| 8174 | \else |
| 8175 | \noexpand\commondummyword \noexpand#1% |
| 8176 | \fi |
| 8177 | } |
| 8178 | |
| 8179 | % \getargs -- Parse the arguments to a @macro line. Set \macname to |
| 8180 | % the name of the macro, and \argl to the braced argument list. |
| 8181 | \def\getargs#1{\getargsxxx#1{}} |
| 8182 | \def\getargsxxx#1#{\getmacname #1 \relax\getmacargs} |
| 8183 | \def\getmacname#1 #2\relax{\macname={#1}} |
| 8184 | \def\getmacargs#1{\def\argl{#1}} |
| 8185 | % This made use of the feature that if the last token of a |
| 8186 | % <parameter list> is #, then the preceding argument is delimited by |
| 8187 | % an opening brace, and that opening brace is not consumed. |
| 8188 | |
| 8189 | % Parse the optional {params} list to @macro or @rmacro. |
| 8190 | % Set \paramno to the number of arguments, |
| 8191 | % and \paramlist to a parameter text for the macro (e.g. #1,#2,#3 for a |
| 8192 | % three-param macro.) Define \macarg.BLAH for each BLAH in the params |
| 8193 | % list to some hook where the argument is to be expanded. If there are |
| 8194 | % less than 10 arguments that hook is to be replaced by ##N where N |
| 8195 | % is the position in that list, that is to say the macro arguments are to be |
| 8196 | % defined `a la TeX in the macro body. |
| 8197 | % |
| 8198 | % That gets used by \mbodybackslash (above). |
| 8199 | % |
| 8200 | % If there are 10 or more arguments, a different technique is used: see |
| 8201 | % \parsemmanyargdef. |
| 8202 | % |
| 8203 | \def\parsemargdef#1;{% |
| 8204 | \paramno=0\def\paramlist{}% |
| 8205 | \let\hash\relax |
| 8206 | % \hash is redefined to `#' later to get it into definitions |
| 8207 | \let\xeatspaces\relax |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 8208 | \let\xempty\relax |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 8209 | \parsemargdefxxx#1,;,% |
| 8210 | \ifnum\paramno<10\relax\else |
| 8211 | \paramno0\relax |
| 8212 | \parsemmanyargdef@@#1,;,% 10 or more arguments |
| 8213 | \fi |
| 8214 | } |
| 8215 | \def\parsemargdefxxx#1,{% |
| 8216 | \if#1;\let\next=\relax |
| 8217 | \else \let\next=\parsemargdefxxx |
| 8218 | \advance\paramno by 1 |
| 8219 | \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 8220 | {\xeatspaces{\hash\the\paramno\noexpand\xempty{}}}% |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 8221 | \edef\paramlist{\paramlist\hash\the\paramno,}% |
| 8222 | \fi\next} |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 8223 | % the \xempty{} is to give \eatleadingcr an argument in the case of an |
| 8224 | % empty macro argument. |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 8225 | |
| 8226 | % \parsemacbody, \parsermacbody |
| 8227 | % |
| 8228 | % Read recursive and nonrecursive macro bodies. (They're different since |
| 8229 | % rec and nonrec macros end differently.) |
| 8230 | % |
| 8231 | % We are in \macrobodyctxt, and the \xdef causes backslashshes in the macro |
| 8232 | % body to be transformed. |
| 8233 | % Set \macrobody to the body of the macro, and call \defmacro. |
| 8234 | % |
| 8235 | {\catcode`\ =\other\long\gdef\parsemacbody#1@end macro{% |
| 8236 | \xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}% |
| 8237 | {\catcode`\ =\other\long\gdef\parsermacbody#1@end rmacro{% |
| 8238 | \xdef\macrobody{\eatcr{#1}}\endgroup\defmacro}}% |
| 8239 | |
| 8240 | % Make @ a letter, so that we can make private-to-Texinfo macro names. |
| 8241 | \edef\texiatcatcode{\the\catcode`\@} |
| 8242 | \catcode `@=11\relax |
| 8243 | |
| 8244 | %%%%%%%%%%%%%% Code for > 10 arguments only %%%%%%%%%%%%%%%%%% |
| 8245 | |
| 8246 | % If there are 10 or more arguments, a different technique is used, where the |
| 8247 | % hook remains in the body, and when macro is to be expanded the body is |
| 8248 | % processed again to replace the arguments. |
| 8249 | % |
| 8250 | % In that case, the hook is \the\toks N-1, and we simply set \toks N-1 to the |
| 8251 | % argument N value and then \edef the body (nothing else will expand because of |
| 8252 | % the catcode regime under which the body was input). |
| 8253 | % |
| 8254 | % If you compile with TeX (not eTeX), and you have macros with 10 or more |
| 8255 | % arguments, no macro can have more than 256 arguments (else error). |
| 8256 | % |
| 8257 | % In case that there are 10 or more arguments we parse again the arguments |
| 8258 | % list to set new definitions for the \macarg.BLAH macros corresponding to |
| 8259 | % each BLAH argument. It was anyhow needed to parse already once this list |
| 8260 | % in order to count the arguments, and as macros with at most 9 arguments |
| 8261 | % are by far more frequent than macro with 10 or more arguments, defining |
| 8262 | % twice the \macarg.BLAH macros does not cost too much processing power. |
| 8263 | \def\parsemmanyargdef@@#1,{% |
| 8264 | \if#1;\let\next=\relax |
| 8265 | \else |
| 8266 | \let\next=\parsemmanyargdef@@ |
| 8267 | \edef\tempb{\eatspaces{#1}}% |
| 8268 | \expandafter\def\expandafter\tempa |
| 8269 | \expandafter{\csname macarg.\tempb\endcsname}% |
| 8270 | % Note that we need some extra \noexpand\noexpand, this is because we |
| 8271 | % don't want \the to be expanded in the \parsermacbody as it uses an |
| 8272 | % \xdef . |
| 8273 | \expandafter\edef\tempa |
| 8274 | {\noexpand\noexpand\noexpand\the\toks\the\paramno}% |
| 8275 | \advance\paramno by 1\relax |
| 8276 | \fi\next} |
| 8277 | |
| 8278 | |
| 8279 | \let\endargs@\relax |
| 8280 | \let\nil@\relax |
| 8281 | \def\nilm@{\nil@}% |
| 8282 | \long\def\nillm@{\nil@}% |
| 8283 | |
| 8284 | % This macro is expanded during the Texinfo macro expansion, not during its |
| 8285 | % definition. It gets all the arguments' values and assigns them to macros |
| 8286 | % macarg.ARGNAME |
| 8287 | % |
| 8288 | % #1 is the macro name |
| 8289 | % #2 is the list of argument names |
| 8290 | % #3 is the list of argument values |
| 8291 | \def\getargvals@#1#2#3{% |
| 8292 | \def\macargdeflist@{}% |
| 8293 | \def\saveparamlist@{#2}% Need to keep a copy for parameter expansion. |
| 8294 | \def\paramlist{#2,\nil@}% |
| 8295 | \def\macroname{#1}% |
| 8296 | \begingroup |
| 8297 | \macroargctxt |
| 8298 | \def\argvaluelist{#3,\nil@}% |
| 8299 | \def\@tempa{#3}% |
| 8300 | \ifx\@tempa\empty |
| 8301 | \setemptyargvalues@ |
| 8302 | \else |
| 8303 | \getargvals@@ |
| 8304 | \fi |
| 8305 | } |
| 8306 | \def\getargvals@@{% |
| 8307 | \ifx\paramlist\nilm@ |
| 8308 | % Some sanity check needed here that \argvaluelist is also empty. |
| 8309 | \ifx\argvaluelist\nillm@ |
| 8310 | \else |
| 8311 | \errhelp = \EMsimple |
| 8312 | \errmessage{Too many arguments in macro `\macroname'!}% |
| 8313 | \fi |
| 8314 | \let\next\macargexpandinbody@ |
| 8315 | \else |
| 8316 | \ifx\argvaluelist\nillm@ |
| 8317 | % No more arguments values passed to macro. Set remaining named-arg |
| 8318 | % macros to empty. |
| 8319 | \let\next\setemptyargvalues@ |
| 8320 | \else |
| 8321 | % pop current arg name into \@tempb |
| 8322 | \def\@tempa##1{\pop@{\@tempb}{\paramlist}##1\endargs@}% |
| 8323 | \expandafter\@tempa\expandafter{\paramlist}% |
| 8324 | % pop current argument value into \@tempc |
| 8325 | \def\@tempa##1{\longpop@{\@tempc}{\argvaluelist}##1\endargs@}% |
| 8326 | \expandafter\@tempa\expandafter{\argvaluelist}% |
| 8327 | % Here \@tempb is the current arg name and \@tempc is the current arg value. |
| 8328 | % First place the new argument macro definition into \@tempd |
| 8329 | \expandafter\macname\expandafter{\@tempc}% |
| 8330 | \expandafter\let\csname macarg.\@tempb\endcsname\relax |
| 8331 | \expandafter\def\expandafter\@tempe\expandafter{% |
| 8332 | \csname macarg.\@tempb\endcsname}% |
| 8333 | \edef\@tempd{\long\def\@tempe{\the\macname}}% |
| 8334 | \push@\@tempd\macargdeflist@ |
| 8335 | \let\next\getargvals@@ |
| 8336 | \fi |
| 8337 | \fi |
| 8338 | \next |
| 8339 | } |
| 8340 | |
| 8341 | \def\push@#1#2{% |
| 8342 | \expandafter\expandafter\expandafter\def |
| 8343 | \expandafter\expandafter\expandafter#2% |
| 8344 | \expandafter\expandafter\expandafter{% |
| 8345 | \expandafter#1#2}% |
| 8346 | } |
| 8347 | |
| 8348 | % Replace arguments by their values in the macro body, and place the result |
| 8349 | % in macro \@tempa. |
| 8350 | % |
| 8351 | \def\macvalstoargs@{% |
| 8352 | % To do this we use the property that token registers that are \the'ed |
| 8353 | % within an \edef expand only once. So we are going to place all argument |
| 8354 | % values into respective token registers. |
| 8355 | % |
| 8356 | % First we save the token context, and initialize argument numbering. |
| 8357 | \begingroup |
| 8358 | \paramno0\relax |
| 8359 | % Then, for each argument number #N, we place the corresponding argument |
| 8360 | % value into a new token list register \toks#N |
| 8361 | \expandafter\putargsintokens@\saveparamlist@,;,% |
| 8362 | % Then, we expand the body so that argument are replaced by their |
| 8363 | % values. The trick for values not to be expanded themselves is that they |
| 8364 | % are within tokens and that tokens expand only once in an \edef . |
| 8365 | \edef\@tempc{\csname mac.\macroname .body\endcsname}% |
| 8366 | % Now we restore the token stack pointer to free the token list registers |
| 8367 | % which we have used, but we make sure that expanded body is saved after |
| 8368 | % group. |
| 8369 | \expandafter |
| 8370 | \endgroup |
| 8371 | \expandafter\def\expandafter\@tempa\expandafter{\@tempc}% |
| 8372 | } |
| 8373 | |
| 8374 | % Define the named-macro outside of this group and then close this group. |
| 8375 | % |
| 8376 | \def\macargexpandinbody@{% |
| 8377 | \expandafter |
| 8378 | \endgroup |
| 8379 | \macargdeflist@ |
| 8380 | % First the replace in body the macro arguments by their values, the result |
| 8381 | % is in \@tempa . |
| 8382 | \macvalstoargs@ |
| 8383 | % Then we point at the \norecurse or \gobble (for recursive) macro value |
| 8384 | % with \@tempb . |
| 8385 | \expandafter\let\expandafter\@tempb\csname mac.\macroname .recurse\endcsname |
| 8386 | % Depending on whether it is recursive or not, we need some tailing |
| 8387 | % \egroup . |
| 8388 | \ifx\@tempb\gobble |
| 8389 | \let\@tempc\relax |
| 8390 | \else |
| 8391 | \let\@tempc\egroup |
| 8392 | \fi |
| 8393 | % And now we do the real job: |
| 8394 | \edef\@tempd{\noexpand\@tempb{\macroname}\noexpand\scanmacro{\@tempa}\@tempc}% |
| 8395 | \@tempd |
| 8396 | } |
| 8397 | |
| 8398 | \def\putargsintokens@#1,{% |
| 8399 | \if#1;\let\next\relax |
| 8400 | \else |
| 8401 | \let\next\putargsintokens@ |
| 8402 | % First we allocate the new token list register, and give it a temporary |
| 8403 | % alias \@tempb . |
| 8404 | \toksdef\@tempb\the\paramno |
| 8405 | % Then we place the argument value into that token list register. |
| 8406 | \expandafter\let\expandafter\@tempa\csname macarg.#1\endcsname |
| 8407 | \expandafter\@tempb\expandafter{\@tempa}% |
| 8408 | \advance\paramno by 1\relax |
| 8409 | \fi |
| 8410 | \next |
| 8411 | } |
| 8412 | |
| 8413 | % Trailing missing arguments are set to empty. |
| 8414 | % |
| 8415 | \def\setemptyargvalues@{% |
| 8416 | \ifx\paramlist\nilm@ |
| 8417 | \let\next\macargexpandinbody@ |
| 8418 | \else |
| 8419 | \expandafter\setemptyargvaluesparser@\paramlist\endargs@ |
| 8420 | \let\next\setemptyargvalues@ |
| 8421 | \fi |
| 8422 | \next |
| 8423 | } |
| 8424 | |
| 8425 | \def\setemptyargvaluesparser@#1,#2\endargs@{% |
| 8426 | \expandafter\def\expandafter\@tempa\expandafter{% |
| 8427 | \expandafter\def\csname macarg.#1\endcsname{}}% |
| 8428 | \push@\@tempa\macargdeflist@ |
| 8429 | \def\paramlist{#2}% |
| 8430 | } |
| 8431 | |
| 8432 | % #1 is the element target macro |
| 8433 | % #2 is the list macro |
| 8434 | % #3,#4\endargs@ is the list value |
| 8435 | \def\pop@#1#2#3,#4\endargs@{% |
| 8436 | \def#1{#3}% |
| 8437 | \def#2{#4}% |
| 8438 | } |
| 8439 | \long\def\longpop@#1#2#3,#4\endargs@{% |
| 8440 | \long\def#1{#3}% |
| 8441 | \long\def#2{#4}% |
| 8442 | } |
| 8443 | |
| 8444 | |
| 8445 | %%%%%%%%%%%%%% End of code for > 10 arguments %%%%%%%%%%%%%%%%%% |
| 8446 | |
| 8447 | |
| 8448 | % This defines a Texinfo @macro or @rmacro, called by \parsemacbody. |
| 8449 | % \macrobody has the body of the macro in it, with placeholders for |
| 8450 | % its parameters, looking like "\xeatspaces{\hash 1}". |
| 8451 | % \paramno is the number of parameters |
| 8452 | % \paramlist is a TeX parameter text, e.g. "#1,#2,#3," |
| 8453 | % There are four cases: macros of zero, one, up to nine, and many arguments. |
| 8454 | % \xdef is used so that macro definitions will survive the file |
| 8455 | % they're defined in: @include reads the file inside a group. |
| 8456 | % |
| 8457 | \def\defmacro{% |
| 8458 | \let\hash=##% convert placeholders to macro parameter chars |
| 8459 | \ifnum\paramno=1 |
| 8460 | \def\xeatspaces##1{##1}% |
| 8461 | % This removes the pair of braces around the argument. We don't |
| 8462 | % use \eatspaces, because this can cause ends of lines to be lost |
| 8463 | % when the argument to \eatspaces is read, leading to line-based |
| 8464 | % commands like "@itemize" not being read correctly. |
| 8465 | \else |
| 8466 | \let\xeatspaces\relax % suppress expansion |
| 8467 | \fi |
| 8468 | \ifcase\paramno |
| 8469 | % 0 |
| 8470 | \expandafter\xdef\csname\the\macname\endcsname{% |
| 8471 | \bgroup |
| 8472 | \noexpand\spaceisspace |
| 8473 | \noexpand\endlineisspace |
| 8474 | \noexpand\expandafter % skip any whitespace after the macro name. |
| 8475 | \expandafter\noexpand\csname\the\macname @@@\endcsname}% |
| 8476 | \expandafter\xdef\csname\the\macname @@@\endcsname{% |
| 8477 | \egroup |
| 8478 | \noexpand\scanmacro{\macrobody}}% |
| 8479 | \or % 1 |
| 8480 | \expandafter\xdef\csname\the\macname\endcsname{% |
| 8481 | \bgroup |
| 8482 | \noexpand\braceorline |
| 8483 | \expandafter\noexpand\csname\the\macname @@@\endcsname}% |
| 8484 | \expandafter\xdef\csname\the\macname @@@\endcsname##1{% |
| 8485 | \egroup |
| 8486 | \noexpand\scanmacro{\macrobody}% |
| 8487 | }% |
| 8488 | \else % at most 9 |
| 8489 | \ifnum\paramno<10\relax |
| 8490 | % @MACNAME sets the context for reading the macro argument |
| 8491 | % @MACNAME@@ gets the argument, processes backslashes and appends a |
| 8492 | % comma. |
| 8493 | % @MACNAME@@@ removes braces surrounding the argument list. |
| 8494 | % @MACNAME@@@@ scans the macro body with arguments substituted. |
| 8495 | \expandafter\xdef\csname\the\macname\endcsname{% |
| 8496 | \bgroup |
| 8497 | \noexpand\expandafter % This \expandafter skip any spaces after the |
| 8498 | \noexpand\macroargctxt % macro before we change the catcode of space. |
| 8499 | \noexpand\expandafter |
| 8500 | \expandafter\noexpand\csname\the\macname @@\endcsname}% |
| 8501 | \expandafter\xdef\csname\the\macname @@\endcsname##1{% |
| 8502 | \noexpand\passargtomacro |
| 8503 | \expandafter\noexpand\csname\the\macname @@@\endcsname{##1,}}% |
| 8504 | \expandafter\xdef\csname\the\macname @@@\endcsname##1{% |
| 8505 | \expandafter\noexpand\csname\the\macname @@@@\endcsname ##1}% |
| 8506 | \expandafter\expandafter |
| 8507 | \expandafter\xdef |
| 8508 | \expandafter\expandafter |
| 8509 | \csname\the\macname @@@@\endcsname\paramlist{% |
| 8510 | \egroup\noexpand\scanmacro{\macrobody}}% |
| 8511 | \else % 10 or more: |
| 8512 | \expandafter\xdef\csname\the\macname\endcsname{% |
| 8513 | \noexpand\getargvals@{\the\macname}{\argl}% |
| 8514 | }% |
| 8515 | \global\expandafter\let\csname mac.\the\macname .body\endcsname\macrobody |
| 8516 | \global\expandafter\let\csname mac.\the\macname .recurse\endcsname\gobble |
| 8517 | \fi |
| 8518 | \fi} |
| 8519 | |
| 8520 | \catcode `\@\texiatcatcode\relax % end private-to-Texinfo catcodes |
| 8521 | |
| 8522 | \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}} |
| 8523 | |
| 8524 | |
| 8525 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8526 | % |
| 8527 | {\catcode`\@=0 \catcode`\\=13 % We need to manipulate \ so use @ as escape |
| 8528 | @catcode`@_=11 % private names |
| 8529 | @catcode`@!=11 % used as argument separator |
| 8530 | |
| 8531 | % \passargtomacro#1#2 - |
| 8532 | % Call #1 with a list of tokens #2, with any doubled backslashes in #2 |
| 8533 | % compressed to one. |
| 8534 | % |
| 8535 | % This implementation works by expansion, and not execution (so we cannot use |
| 8536 | % \def or similar). This reduces the risk of this failing in contexts where |
| 8537 | % complete expansion is done with no execution (for example, in writing out to |
| 8538 | % an auxiliary file for an index entry). |
| 8539 | % |
| 8540 | % State is kept in the input stream: the argument passed to |
| 8541 | % @look_ahead, @gobble_and_check_finish and @add_segment is |
| 8542 | % |
| 8543 | % THE_MACRO ARG_RESULT ! {PENDING_BS} NEXT_TOKEN (... rest of input) |
| 8544 | % |
| 8545 | % where: |
| 8546 | % THE_MACRO - name of the macro we want to call |
| 8547 | % ARG_RESULT - argument list we build to pass to that macro |
| 8548 | % PENDING_BS - either a backslash or nothing |
| 8549 | % NEXT_TOKEN - used to look ahead in the input stream to see what's coming next |
| 8550 | |
| 8551 | @gdef@passargtomacro#1#2{% |
| 8552 | @add_segment #1!{}@relax#2\@_finish\% |
| 8553 | } |
| 8554 | @gdef@_finish{@_finishx} @global@let@_finishx@relax |
| 8555 | |
| 8556 | % #1 - THE_MACRO ARG_RESULT |
| 8557 | % #2 - PENDING_BS |
| 8558 | % #3 - NEXT_TOKEN |
| 8559 | % #4 used to look ahead |
| 8560 | % |
| 8561 | % If the next token is not a backslash, process the rest of the argument; |
| 8562 | % otherwise, remove the next token. |
| 8563 | @gdef@look_ahead#1!#2#3#4{% |
| 8564 | @ifx#4\% |
| 8565 | @expandafter@gobble_and_check_finish |
| 8566 | @else |
| 8567 | @expandafter@add_segment |
| 8568 | @fi#1!{#2}#4#4% |
| 8569 | } |
| 8570 | |
| 8571 | % #1 - THE_MACRO ARG_RESULT |
| 8572 | % #2 - PENDING_BS |
| 8573 | % #3 - NEXT_TOKEN |
| 8574 | % #4 should be a backslash, which is gobbled. |
| 8575 | % #5 looks ahead |
| 8576 | % |
| 8577 | % Double backslash found. Add a single backslash, and look ahead. |
| 8578 | @gdef@gobble_and_check_finish#1!#2#3#4#5{% |
| 8579 | @add_segment#1\!{}#5#5% |
| 8580 | } |
| 8581 | |
| 8582 | @gdef@is_fi{@fi} |
| 8583 | |
| 8584 | % #1 - THE_MACRO ARG_RESULT |
| 8585 | % #2 - PENDING_BS |
| 8586 | % #3 - NEXT_TOKEN |
| 8587 | % #4 is input stream until next backslash |
| 8588 | % |
| 8589 | % Input stream is either at the start of the argument, or just after a |
| 8590 | % backslash sequence, either a lone backslash, or a doubled backslash. |
| 8591 | % NEXT_TOKEN contains the first token in the input stream: if it is \finish, |
| 8592 | % finish; otherwise, append to ARG_RESULT the segment of the argument up until |
| 8593 | % the next backslash. PENDING_BACKSLASH contains a backslash to represent |
| 8594 | % a backslash just before the start of the input stream that has not been |
| 8595 | % added to ARG_RESULT. |
| 8596 | @gdef@add_segment#1!#2#3#4\{% |
| 8597 | @ifx#3@_finish |
| 8598 | @call_the_macro#1!% |
| 8599 | @else |
| 8600 | % append the pending backslash to the result, followed by the next segment |
| 8601 | @expandafter@is_fi@look_ahead#1#2#4!{\}@fi |
| 8602 | % this @fi is discarded by @look_ahead. |
| 8603 | % we can't get rid of it with \expandafter because we don't know how |
| 8604 | % long #4 is. |
| 8605 | } |
| 8606 | |
| 8607 | % #1 - THE_MACRO |
| 8608 | % #2 - ARG_RESULT |
| 8609 | % #3 discards the res of the conditional in @add_segment, and @is_fi ends the |
| 8610 | % conditional. |
| 8611 | @gdef@call_the_macro#1#2!#3@fi{@is_fi #1{#2}} |
| 8612 | |
| 8613 | } |
| 8614 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 8615 | |
| 8616 | % \braceorline MAC is used for a one-argument macro MAC. It checks |
| 8617 | % whether the next non-whitespace character is a {. It sets the context |
| 8618 | % for reading the argument (slightly different in the two cases). Then, |
| 8619 | % to read the argument, in the whole-line case, it then calls the regular |
| 8620 | % \parsearg MAC; in the lbrace case, it calls \passargtomacro MAC. |
| 8621 | % |
| 8622 | \def\braceorline#1{\let\macnamexxx=#1\futurelet\nchar\braceorlinexxx} |
| 8623 | \def\braceorlinexxx{% |
| 8624 | \ifx\nchar\bgroup |
| 8625 | \macroargctxt |
| 8626 | \expandafter\passargtomacro |
| 8627 | \else |
| 8628 | \macrolineargctxt\expandafter\parsearg |
| 8629 | \fi \macnamexxx} |
| 8630 | |
| 8631 | |
| 8632 | % @alias. |
| 8633 | % We need some trickery to remove the optional spaces around the equal |
| 8634 | % sign. Make them active and then expand them all to nothing. |
| 8635 | % |
| 8636 | \def\alias{\parseargusing\obeyspaces\aliasxxx} |
| 8637 | \def\aliasxxx #1{\aliasyyy#1\relax} |
| 8638 | \def\aliasyyy #1=#2\relax{% |
| 8639 | {% |
| 8640 | \expandafter\let\obeyedspace=\empty |
| 8641 | \addtomacrolist{#1}% |
| 8642 | \xdef\next{\global\let\makecsname{#1}=\makecsname{#2}}% |
| 8643 | }% |
| 8644 | \next |
| 8645 | } |
| 8646 | |
| 8647 | |
| 8648 | \message{cross references,} |
| 8649 | |
| 8650 | \newwrite\auxfile |
| 8651 | \newif\ifhavexrefs % True if xref values are known. |
| 8652 | \newif\ifwarnedxrefs % True if we warned once that they aren't known. |
| 8653 | |
| 8654 | % @inforef is relatively simple. |
| 8655 | \def\inforef #1{\inforefzzz #1,,,,**} |
| 8656 | \def\inforefzzz #1,#2,#3,#4**{% |
| 8657 | \putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}}, |
| 8658 | node \samp{\ignorespaces#1{}}} |
| 8659 | |
| 8660 | % @node's only job in TeX is to define \lastnode, which is used in |
| 8661 | % cross-references. The @node line might or might not have commas, and |
| 8662 | % might or might not have spaces before the first comma, like: |
| 8663 | % @node foo , bar , ... |
| 8664 | % We don't want such trailing spaces in the node name. |
| 8665 | % |
| 8666 | \parseargdef\node{\checkenv{}\donode #1 ,\finishnodeparse} |
| 8667 | % |
| 8668 | % also remove a trailing comma, in case of something like this: |
| 8669 | % @node Help-Cross, , , Cross-refs |
| 8670 | \def\donode#1 ,#2\finishnodeparse{\dodonode #1,\finishnodeparse} |
| 8671 | \def\dodonode#1,#2\finishnodeparse{\gdef\lastnode{#1}\omittopnode} |
| 8672 | |
| 8673 | % Used so that the @top node doesn't have to be wrapped in an @ifnottex |
| 8674 | % conditional. |
| 8675 | % \doignore goes to more effort to skip nested conditionals but we don't need |
| 8676 | % that here. |
| 8677 | \def\omittopnode{% |
| 8678 | \ifx\lastnode\wordTop |
| 8679 | \expandafter\ignorenode\fi |
| 8680 | } |
| 8681 | \def\wordTop{Top} |
| 8682 | |
| 8683 | % Until the next @node or @bye command, divert output to a box that is not |
| 8684 | % output. |
| 8685 | \def\ignorenode{\setbox\dummybox\vbox\bgroup\def\node{\egroup\node}% |
| 8686 | \ignorenodebye |
| 8687 | } |
| 8688 | |
| 8689 | {\let\bye\relax |
| 8690 | \gdef\ignorenodebye{\let\bye\ignorenodebyedef} |
| 8691 | \gdef\ignorenodebyedef{\egroup(`Top' node ignored)\bye}} |
| 8692 | % The redefinition of \bye here is because it is declared \outer |
| 8693 | |
| 8694 | \let\lastnode=\empty |
| 8695 | |
| 8696 | % Write a cross-reference definition for the current node. #1 is the |
| 8697 | % type (Ynumbered, Yappendix, Ynothing). |
| 8698 | % |
| 8699 | \def\donoderef#1{% |
| 8700 | \ifx\lastnode\empty\else |
| 8701 | \setref{\lastnode}{#1}% |
| 8702 | \global\let\lastnode=\empty |
| 8703 | \fi |
| 8704 | } |
| 8705 | |
| 8706 | % @anchor{NAME} -- define xref target at arbitrary point. |
| 8707 | % |
| 8708 | \newcount\savesfregister |
| 8709 | % |
| 8710 | \def\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi} |
| 8711 | \def\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi} |
| 8712 | \def\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces} |
| 8713 | |
| 8714 | % \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an |
| 8715 | % anchor), which consists of three parts: |
| 8716 | % 1) NAME-title - the current sectioning name taken from \currentsection, |
| 8717 | % or the anchor name. |
| 8718 | % 2) NAME-snt - section number and type, passed as the SNT arg, or |
| 8719 | % empty for anchors. |
| 8720 | % 3) NAME-pg - the page number. |
| 8721 | % |
| 8722 | % This is called from \donoderef, \anchor, and \dofloat. In the case of |
| 8723 | % floats, there is an additional part, which is not written here: |
| 8724 | % 4) NAME-lof - the text as it should appear in a @listoffloats. |
| 8725 | % |
| 8726 | \def\setref#1#2{% |
| 8727 | \pdfmkdest{#1}% |
| 8728 | \iflinks |
| 8729 | {% |
| 8730 | \requireauxfile |
| 8731 | \atdummies % preserve commands, but don't expand them |
| 8732 | % match definition in \xrdef, \refx, \xrefX. |
| 8733 | \def\value##1{##1}% |
| 8734 | \edef\writexrdef##1##2{% |
| 8735 | \write\auxfile{@xrdef{#1-% #1 of \setref, expanded by the \edef |
| 8736 | ##1}{##2}}% these are parameters of \writexrdef |
| 8737 | }% |
| 8738 | \toks0 = \expandafter{\currentsection}% |
| 8739 | \immediate \writexrdef{title}{\the\toks0 }% |
| 8740 | \immediate \writexrdef{snt}{\csname #2\endcsname}% \Ynumbered etc. |
| 8741 | \safewhatsit{\writexrdef{pg}{\folio}}% will be written later, at \shipout |
| 8742 | }% |
| 8743 | \fi |
| 8744 | } |
| 8745 | |
| 8746 | % @xrefautosectiontitle on|off says whether @section(ing) names are used |
| 8747 | % automatically in xrefs, if the third arg is not explicitly specified. |
| 8748 | % This was provided as a "secret" @set xref-automatic-section-title |
| 8749 | % variable, now it's official. |
| 8750 | % |
| 8751 | \parseargdef\xrefautomaticsectiontitle{% |
| 8752 | \def\temp{#1}% |
| 8753 | \ifx\temp\onword |
| 8754 | \expandafter\let\csname SETxref-automatic-section-title\endcsname |
| 8755 | = \empty |
| 8756 | \else\ifx\temp\offword |
| 8757 | \expandafter\let\csname SETxref-automatic-section-title\endcsname |
| 8758 | = \relax |
| 8759 | \else |
| 8760 | \errhelp = \EMsimple |
| 8761 | \errmessage{Unknown @xrefautomaticsectiontitle value `\temp', |
| 8762 | must be on|off}% |
| 8763 | \fi\fi |
| 8764 | } |
| 8765 | |
| 8766 | % |
| 8767 | % @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is |
| 8768 | % the node name, #2 the name of the Info cross-reference, #3 the printed |
| 8769 | % node name, #4 the name of the Info file, #5 the name of the printed |
| 8770 | % manual. All but the node name can be omitted. |
| 8771 | % |
| 8772 | \def\pxref{\putwordsee{} \xrefXX} |
| 8773 | \def\xref{\putwordSee{} \xrefXX} |
| 8774 | \def\ref{\xrefXX} |
| 8775 | |
| 8776 | \def\xrefXX#1{\def\xrefXXarg{#1}\futurelet\tokenafterxref\xrefXXX} |
| 8777 | \def\xrefXXX{\expandafter\xrefX\expandafter[\xrefXXarg,,,,,,,]} |
| 8778 | % |
| 8779 | \newbox\toprefbox |
| 8780 | \newbox\printedrefnamebox |
| 8781 | \newbox\infofilenamebox |
| 8782 | \newbox\printedmanualbox |
| 8783 | % |
| 8784 | \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup |
| 8785 | \unsepspaces |
| 8786 | % |
| 8787 | % Get args without leading/trailing spaces. |
| 8788 | \def\printedrefname{\ignorespaces #3}% |
| 8789 | \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}% |
| 8790 | % |
| 8791 | \def\infofilename{\ignorespaces #4}% |
| 8792 | \setbox\infofilenamebox = \hbox{\infofilename\unskip}% |
| 8793 | % |
| 8794 | \def\printedmanual{\ignorespaces #5}% |
| 8795 | \setbox\printedmanualbox = \hbox{\printedmanual\unskip}% |
| 8796 | % |
| 8797 | % If the printed reference name (arg #3) was not explicitly given in |
| 8798 | % the @xref, figure out what we want to use. |
| 8799 | \ifdim \wd\printedrefnamebox = 0pt |
| 8800 | % No printed node name was explicitly given. |
| 8801 | \expandafter\ifx\csname SETxref-automatic-section-title\endcsname \relax |
| 8802 | % Not auto section-title: use node name inside the square brackets. |
| 8803 | \def\printedrefname{\ignorespaces #1}% |
| 8804 | \else |
| 8805 | % Auto section-title: use chapter/section title inside |
| 8806 | % the square brackets if we have it. |
| 8807 | \ifdim \wd\printedmanualbox > 0pt |
| 8808 | % It is in another manual, so we don't have it; use node name. |
| 8809 | \def\printedrefname{\ignorespaces #1}% |
| 8810 | \else |
| 8811 | \ifhavexrefs |
| 8812 | % We (should) know the real title if we have the xref values. |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 8813 | \def\printedrefname{\refx{#1-title}}% |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 8814 | \else |
| 8815 | % Otherwise just copy the Info node name. |
| 8816 | \def\printedrefname{\ignorespaces #1}% |
| 8817 | \fi% |
| 8818 | \fi |
| 8819 | \fi |
| 8820 | \fi |
| 8821 | % |
| 8822 | % Make link in pdf output. |
| 8823 | \ifpdf |
| 8824 | % For pdfTeX and LuaTeX |
| 8825 | {\indexnofonts |
| 8826 | \makevalueexpandable |
| 8827 | \turnoffactive |
| 8828 | % This expands tokens, so do it after making catcode changes, so _ |
| 8829 | % etc. don't get their TeX definitions. This ignores all spaces in |
| 8830 | % #4, including (wrongly) those in the middle of the filename. |
| 8831 | \getfilename{#4}% |
| 8832 | % |
| 8833 | % This (wrongly) does not take account of leading or trailing |
| 8834 | % spaces in #1, which should be ignored. |
| 8835 | \setpdfdestname{#1}% |
| 8836 | % |
| 8837 | \ifx\pdfdestname\empty |
| 8838 | \def\pdfdestname{Top}% no empty targets |
| 8839 | \fi |
| 8840 | % |
| 8841 | \leavevmode |
| 8842 | \startlink attr{/Border [0 0 0]}% |
| 8843 | \ifnum\filenamelength>0 |
| 8844 | goto file{\the\filename.pdf} name{\pdfdestname}% |
| 8845 | \else |
| 8846 | goto name{\pdfmkpgn{\pdfdestname}}% |
| 8847 | \fi |
| 8848 | }% |
| 8849 | \setcolor{\linkcolor}% |
| 8850 | \else |
| 8851 | \ifx\XeTeXrevision\thisisundefined |
| 8852 | \else |
| 8853 | % For XeTeX |
| 8854 | {\indexnofonts |
| 8855 | \makevalueexpandable |
| 8856 | \turnoffactive |
| 8857 | % This expands tokens, so do it after making catcode changes, so _ |
| 8858 | % etc. don't get their TeX definitions. This ignores all spaces in |
| 8859 | % #4, including (wrongly) those in the middle of the filename. |
| 8860 | \getfilename{#4}% |
| 8861 | % |
| 8862 | % This (wrongly) does not take account of leading or trailing |
| 8863 | % spaces in #1, which should be ignored. |
| 8864 | \setpdfdestname{#1}% |
| 8865 | % |
| 8866 | \ifx\pdfdestname\empty |
| 8867 | \def\pdfdestname{Top}% no empty targets |
| 8868 | \fi |
| 8869 | % |
| 8870 | \leavevmode |
| 8871 | \ifnum\filenamelength>0 |
| 8872 | % With default settings, |
| 8873 | % XeTeX (xdvipdfmx) replaces link destination names with integers. |
| 8874 | % In this case, the replaced destination names of |
| 8875 | % remote PDFs are no longer known. In order to avoid a replacement, |
| 8876 | % you can use xdvipdfmx's command line option `-C 0x0010'. |
| 8877 | % If you use XeTeX 0.99996+ (TeX Live 2016+), |
| 8878 | % this command line option is no longer necessary |
| 8879 | % because we can use the `dvipdfmx:config' special. |
| 8880 | \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A |
| 8881 | << /S /GoToR /F (\the\filename.pdf) /D (\pdfdestname) >> >>}% |
| 8882 | \else |
| 8883 | \special{pdf:bann << /Border [0 0 0] /Type /Annot /Subtype /Link /A |
| 8884 | << /S /GoTo /D (\pdfdestname) >> >>}% |
| 8885 | \fi |
| 8886 | }% |
| 8887 | \setcolor{\linkcolor}% |
| 8888 | \fi |
| 8889 | \fi |
| 8890 | {% |
| 8891 | % Have to otherify everything special to allow the \csname to |
| 8892 | % include an _ in the xref name, etc. |
| 8893 | \indexnofonts |
| 8894 | \turnoffactive |
| 8895 | \def\value##1{##1}% |
| 8896 | \expandafter\global\expandafter\let\expandafter\Xthisreftitle |
| 8897 | \csname XR#1-title\endcsname |
| 8898 | }% |
| 8899 | % |
| 8900 | % Float references are printed completely differently: "Figure 1.2" |
| 8901 | % instead of "[somenode], p.3". \iffloat distinguishes them by |
| 8902 | % \Xthisreftitle being set to a magic string. |
| 8903 | \iffloat\Xthisreftitle |
| 8904 | % If the user specified the print name (third arg) to the ref, |
| 8905 | % print it instead of our usual "Figure 1.2". |
| 8906 | \ifdim\wd\printedrefnamebox = 0pt |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 8907 | \refx{#1-snt}% |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 8908 | \else |
| 8909 | \printedrefname |
| 8910 | \fi |
| 8911 | % |
| 8912 | % If the user also gave the printed manual name (fifth arg), append |
| 8913 | % "in MANUALNAME". |
| 8914 | \ifdim \wd\printedmanualbox > 0pt |
| 8915 | \space \putwordin{} \cite{\printedmanual}% |
| 8916 | \fi |
| 8917 | \else |
| 8918 | % node/anchor (non-float) references. |
| 8919 | % |
| 8920 | % If we use \unhbox to print the node names, TeX does not insert |
| 8921 | % empty discretionaries after hyphens, which means that it will not |
| 8922 | % find a line break at a hyphen in a node names. Since some manuals |
| 8923 | % are best written with fairly long node names, containing hyphens, |
| 8924 | % this is a loss. Therefore, we give the text of the node name |
| 8925 | % again, so it is as if TeX is seeing it for the first time. |
| 8926 | % |
| 8927 | \ifdim \wd\printedmanualbox > 0pt |
| 8928 | % Cross-manual reference with a printed manual name. |
| 8929 | % |
| 8930 | \crossmanualxref{\cite{\printedmanual\unskip}}% |
| 8931 | % |
| 8932 | \else\ifdim \wd\infofilenamebox > 0pt |
| 8933 | % Cross-manual reference with only an info filename (arg 4), no |
| 8934 | % printed manual name (arg 5). This is essentially the same as |
| 8935 | % the case above; we output the filename, since we have nothing else. |
| 8936 | % |
| 8937 | \crossmanualxref{\code{\infofilename\unskip}}% |
| 8938 | % |
| 8939 | \else |
| 8940 | % Reference within this manual. |
| 8941 | % |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 8942 | % Only output a following space if the -snt ref is nonempty, as the ref |
| 8943 | % will be empty for @unnumbered and @anchor. |
| 8944 | \setbox2 = \hbox{\ignorespaces \refx{#1-snt}}% |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 8945 | \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi |
| 8946 | % |
| 8947 | % output the `[mynode]' via the macro below so it can be overridden. |
| 8948 | \xrefprintnodename\printedrefname |
| 8949 | % |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 8950 | \expandafter\ifx\csname SETtxiomitxrefpg\endcsname\relax |
| 8951 | % But we always want a comma and a space: |
| 8952 | ,\space |
| 8953 | % |
| 8954 | % output the `page 3'. |
| 8955 | \turnoffactive \putwordpage\tie\refx{#1-pg}% |
| 8956 | % Add a , if xref followed by a space |
| 8957 | \if\space\noexpand\tokenafterxref ,% |
| 8958 | \else\ifx\ \tokenafterxref ,% @TAB |
| 8959 | \else\ifx\*\tokenafterxref ,% @* |
| 8960 | \else\ifx\ \tokenafterxref ,% @SPACE |
| 8961 | \else\ifx\ |
| 8962 | \tokenafterxref ,% @NL |
| 8963 | \else\ifx\tie\tokenafterxref ,% @tie |
| 8964 | \fi\fi\fi\fi\fi\fi |
| 8965 | \fi |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 8966 | \fi\fi |
| 8967 | \fi |
| 8968 | \endlink |
| 8969 | \endgroup} |
| 8970 | |
| 8971 | % Output a cross-manual xref to #1. Used just above (twice). |
| 8972 | % |
| 8973 | % Only include the text "Section ``foo'' in" if the foo is neither |
| 8974 | % missing or Top. Thus, @xref{,,,foo,The Foo Manual} outputs simply |
| 8975 | % "see The Foo Manual", the idea being to refer to the whole manual. |
| 8976 | % |
| 8977 | % But, this being TeX, we can't easily compare our node name against the |
| 8978 | % string "Top" while ignoring the possible spaces before and after in |
| 8979 | % the input. By adding the arbitrary 7sp below, we make it much less |
| 8980 | % likely that a real node name would have the same width as "Top" (e.g., |
| 8981 | % in a monospaced font). Hopefully it will never happen in practice. |
| 8982 | % |
| 8983 | % For the same basic reason, we retypeset the "Top" at every |
| 8984 | % reference, since the current font is indeterminate. |
| 8985 | % |
| 8986 | \def\crossmanualxref#1{% |
| 8987 | \setbox\toprefbox = \hbox{Top\kern7sp}% |
| 8988 | \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}% |
| 8989 | \ifdim \wd2 > 7sp % nonempty? |
| 8990 | \ifdim \wd2 = \wd\toprefbox \else % same as Top? |
| 8991 | \putwordSection{} ``\printedrefname'' \putwordin{}\space |
| 8992 | \fi |
| 8993 | \fi |
| 8994 | #1% |
| 8995 | } |
| 8996 | |
| 8997 | % This macro is called from \xrefX for the `[nodename]' part of xref |
| 8998 | % output. It's a separate macro only so it can be changed more easily, |
| 8999 | % since square brackets don't work well in some documents. Particularly |
| 9000 | % one that Bob is working on :). |
| 9001 | % |
| 9002 | \def\xrefprintnodename#1{[#1]} |
| 9003 | |
| 9004 | % Things referred to by \setref. |
| 9005 | % |
| 9006 | \def\Ynothing{} |
| 9007 | \def\Yomitfromtoc{} |
| 9008 | \def\Ynumbered{% |
| 9009 | \ifnum\secno=0 |
| 9010 | \putwordChapter@tie \the\chapno |
| 9011 | \else \ifnum\subsecno=0 |
| 9012 | \putwordSection@tie \the\chapno.\the\secno |
| 9013 | \else \ifnum\subsubsecno=0 |
| 9014 | \putwordSection@tie \the\chapno.\the\secno.\the\subsecno |
| 9015 | \else |
| 9016 | \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno |
| 9017 | \fi\fi\fi |
| 9018 | } |
| 9019 | \def\Yappendix{% |
| 9020 | \ifnum\secno=0 |
| 9021 | \putwordAppendix@tie @char\the\appendixno{}% |
| 9022 | \else \ifnum\subsecno=0 |
| 9023 | \putwordSection@tie @char\the\appendixno.\the\secno |
| 9024 | \else \ifnum\subsubsecno=0 |
| 9025 | \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno |
| 9026 | \else |
| 9027 | \putwordSection@tie |
| 9028 | @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno |
| 9029 | \fi\fi\fi |
| 9030 | } |
| 9031 | |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 9032 | % \refx{NAME} - reference a cross-reference string named NAME. |
| 9033 | \def\refx#1{% |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 9034 | \requireauxfile |
| 9035 | {% |
| 9036 | \indexnofonts |
| 9037 | \turnoffactive |
| 9038 | \def\value##1{##1}% |
| 9039 | \expandafter\global\expandafter\let\expandafter\thisrefX |
| 9040 | \csname XR#1\endcsname |
| 9041 | }% |
| 9042 | \ifx\thisrefX\relax |
| 9043 | % If not defined, say something at least. |
| 9044 | \angleleft un\-de\-fined\angleright |
| 9045 | \iflinks |
| 9046 | \ifhavexrefs |
| 9047 | {\toks0 = {#1}% avoid expansion of possibly-complex value |
| 9048 | \message{\linenumber Undefined cross reference `\the\toks0'.}}% |
| 9049 | \else |
| 9050 | \ifwarnedxrefs\else |
| 9051 | \global\warnedxrefstrue |
| 9052 | \message{Cross reference values unknown; you must run TeX again.}% |
| 9053 | \fi |
| 9054 | \fi |
| 9055 | \fi |
| 9056 | \else |
| 9057 | % It's defined, so just use it. |
| 9058 | \thisrefX |
| 9059 | \fi |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 9060 | } |
| 9061 | |
| 9062 | % This is the macro invoked by entries in the aux file. Define a control |
| 9063 | % sequence for a cross-reference target (we prepend XR to the control sequence |
| 9064 | % name to avoid collisions). The value is the page number. If this is a float |
| 9065 | % type, we have more work to do. |
| 9066 | % |
| 9067 | \def\xrdef#1#2{% |
| 9068 | {% Expand the node or anchor name to remove control sequences. |
| 9069 | % \turnoffactive stops 8-bit characters being changed to commands |
| 9070 | % like @'e. \refx does the same to retrieve the value in the definition. |
| 9071 | \indexnofonts |
| 9072 | \turnoffactive |
| 9073 | \def\value##1{##1}% |
| 9074 | \xdef\safexrefname{#1}% |
| 9075 | }% |
| 9076 | % |
| 9077 | \bgroup |
| 9078 | \expandafter\gdef\csname XR\safexrefname\endcsname{#2}% |
| 9079 | \egroup |
| 9080 | % We put the \gdef inside a group to avoid the definitions building up on |
| 9081 | % TeX's save stack, which can cause it to run out of space for aux files with |
| 9082 | % thousands of lines. \gdef doesn't use the save stack, but \csname does |
| 9083 | % when it defines an unknown control sequence as \relax. |
| 9084 | % |
| 9085 | % Was that xref control sequence that we just defined for a float? |
| 9086 | \expandafter\iffloat\csname XR\safexrefname\endcsname |
| 9087 | % it was a float, and we have the (safe) float type in \iffloattype. |
| 9088 | \expandafter\let\expandafter\floatlist |
| 9089 | \csname floatlist\iffloattype\endcsname |
| 9090 | % |
| 9091 | % Is this the first time we've seen this float type? |
| 9092 | \expandafter\ifx\floatlist\relax |
| 9093 | \toks0 = {\do}% yes, so just \do |
| 9094 | \else |
| 9095 | % had it before, so preserve previous elements in list. |
| 9096 | \toks0 = \expandafter{\floatlist\do}% |
| 9097 | \fi |
| 9098 | % |
| 9099 | % Remember this xref in the control sequence \floatlistFLOATTYPE, |
| 9100 | % for later use in \listoffloats. |
| 9101 | \expandafter\xdef\csname floatlist\iffloattype\endcsname{\the\toks0 |
| 9102 | {\safexrefname}}% |
| 9103 | \fi |
| 9104 | } |
| 9105 | |
| 9106 | % If working on a large document in chapters, it is convenient to |
| 9107 | % be able to disable indexing, cross-referencing, and contents, for test runs. |
| 9108 | % This is done with @novalidate at the beginning of the file. |
| 9109 | % |
| 9110 | \newif\iflinks \linkstrue % by default we want the aux files. |
| 9111 | \let\novalidate = \linksfalse |
| 9112 | |
| 9113 | % Used when writing to the aux file, or when using data from it. |
| 9114 | \def\requireauxfile{% |
| 9115 | \iflinks |
| 9116 | \tryauxfile |
| 9117 | % Open the new aux file. TeX will close it automatically at exit. |
| 9118 | \immediate\openout\auxfile=\jobname.aux |
| 9119 | \fi |
| 9120 | \global\let\requireauxfile=\relax % Only do this once. |
| 9121 | } |
| 9122 | |
| 9123 | % Read the last existing aux file, if any. No error if none exists. |
| 9124 | % |
| 9125 | \def\tryauxfile{% |
| 9126 | \openin 1 \jobname.aux |
| 9127 | \ifeof 1 \else |
| 9128 | \readdatafile{aux}% |
| 9129 | \global\havexrefstrue |
| 9130 | \fi |
| 9131 | \closein 1 |
| 9132 | } |
| 9133 | |
| 9134 | \def\setupdatafile{% |
| 9135 | \catcode`\^^@=\other |
| 9136 | \catcode`\^^A=\other |
| 9137 | \catcode`\^^B=\other |
| 9138 | \catcode`\^^C=\other |
| 9139 | \catcode`\^^D=\other |
| 9140 | \catcode`\^^E=\other |
| 9141 | \catcode`\^^F=\other |
| 9142 | \catcode`\^^G=\other |
| 9143 | \catcode`\^^H=\other |
| 9144 | \catcode`\^^K=\other |
| 9145 | \catcode`\^^L=\other |
| 9146 | \catcode`\^^N=\other |
| 9147 | \catcode`\^^P=\other |
| 9148 | \catcode`\^^Q=\other |
| 9149 | \catcode`\^^R=\other |
| 9150 | \catcode`\^^S=\other |
| 9151 | \catcode`\^^T=\other |
| 9152 | \catcode`\^^U=\other |
| 9153 | \catcode`\^^V=\other |
| 9154 | \catcode`\^^W=\other |
| 9155 | \catcode`\^^X=\other |
| 9156 | \catcode`\^^Z=\other |
| 9157 | \catcode`\^^[=\other |
| 9158 | \catcode`\^^\=\other |
| 9159 | \catcode`\^^]=\other |
| 9160 | \catcode`\^^^=\other |
| 9161 | \catcode`\^^_=\other |
| 9162 | \catcode`\^=\other |
| 9163 | % |
| 9164 | % Special characters. Should be turned off anyway, but... |
| 9165 | \catcode`\~=\other |
| 9166 | \catcode`\[=\other |
| 9167 | \catcode`\]=\other |
| 9168 | \catcode`\"=\other |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 9169 | \catcode`\_=\active |
| 9170 | \catcode`\|=\active |
| 9171 | \catcode`\<=\active |
| 9172 | \catcode`\>=\active |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 9173 | \catcode`\$=\other |
| 9174 | \catcode`\#=\other |
| 9175 | \catcode`\&=\other |
| 9176 | \catcode`\%=\other |
| 9177 | \catcode`+=\other % avoid \+ for paranoia even though we've turned it off |
| 9178 | % |
| 9179 | \catcode`\\=\active |
| 9180 | % |
| 9181 | % @ is our escape character in .aux files, and we need braces. |
| 9182 | \catcode`\{=1 |
| 9183 | \catcode`\}=2 |
| 9184 | \catcode`\@=0 |
| 9185 | } |
| 9186 | |
| 9187 | \def\readdatafile#1{% |
| 9188 | \begingroup |
| 9189 | \setupdatafile |
| 9190 | \input\jobname.#1 |
| 9191 | \endgroup} |
| 9192 | |
| 9193 | |
| 9194 | \message{insertions,} |
| 9195 | % including footnotes. |
| 9196 | |
| 9197 | \newcount \footnoteno |
| 9198 | |
| 9199 | % The trailing space in the following definition for supereject is |
| 9200 | % vital for proper filling; pages come out unaligned when you do a |
| 9201 | % pagealignmacro call if that space before the closing brace is |
| 9202 | % removed. (Generally, numeric constants should always be followed by a |
| 9203 | % space to prevent strange expansion errors.) |
| 9204 | \def\supereject{\par\penalty -20000\footnoteno =0 } |
| 9205 | |
| 9206 | % @footnotestyle is meaningful for Info output only. |
| 9207 | \let\footnotestyle=\comment |
| 9208 | |
| 9209 | {\catcode `\@=11 |
| 9210 | % |
| 9211 | % Auto-number footnotes. Otherwise like plain. |
| 9212 | \gdef\footnote{% |
| 9213 | \global\advance\footnoteno by \@ne |
| 9214 | \edef\thisfootno{$^{\the\footnoteno}$}% |
| 9215 | % |
| 9216 | % In case the footnote comes at the end of a sentence, preserve the |
| 9217 | % extra spacing after we do the footnote number. |
| 9218 | \let\@sf\empty |
| 9219 | \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\ptexslash\fi |
| 9220 | % |
| 9221 | % Remove inadvertent blank space before typesetting the footnote number. |
| 9222 | \unskip |
| 9223 | \thisfootno\@sf |
| 9224 | \dofootnote |
| 9225 | }% |
| 9226 | |
| 9227 | % Don't bother with the trickery in plain.tex to not require the |
| 9228 | % footnote text as a parameter. Our footnotes don't need to be so general. |
| 9229 | % |
| 9230 | % Oh yes, they do; otherwise, @ifset (and anything else that uses |
| 9231 | % \parseargline) fails inside footnotes because the tokens are fixed when |
| 9232 | % the footnote is read. --karl, 16nov96. |
| 9233 | % |
| 9234 | \gdef\dofootnote{% |
| 9235 | \insert\footins\bgroup |
| 9236 | % |
| 9237 | % Nested footnotes are not supported in TeX, that would take a lot |
| 9238 | % more work. (\startsavinginserts does not suffice.) |
| 9239 | \let\footnote=\errfootnotenest |
| 9240 | % |
| 9241 | % We want to typeset this text as a normal paragraph, even if the |
| 9242 | % footnote reference occurs in (for example) a display environment. |
| 9243 | % So reset some parameters. |
| 9244 | \hsize=\txipagewidth |
| 9245 | \interlinepenalty\interfootnotelinepenalty |
| 9246 | \splittopskip\ht\strutbox % top baseline for broken footnotes |
| 9247 | \splitmaxdepth\dp\strutbox |
| 9248 | \floatingpenalty\@MM |
| 9249 | \leftskip\z@skip |
| 9250 | \rightskip\z@skip |
| 9251 | \spaceskip\z@skip |
| 9252 | \xspaceskip\z@skip |
| 9253 | \parindent\defaultparindent |
| 9254 | % |
| 9255 | \smallfonts \rm |
| 9256 | % |
| 9257 | % Because we use hanging indentation in footnotes, a @noindent appears |
| 9258 | % to exdent this text, so make it be a no-op. makeinfo does not use |
| 9259 | % hanging indentation so @noindent can still be needed within footnote |
| 9260 | % text after an @example or the like (not that this is good style). |
| 9261 | \let\noindent = \relax |
| 9262 | % |
| 9263 | % Hang the footnote text off the number. Use \everypar in case the |
| 9264 | % footnote extends for more than one paragraph. |
| 9265 | \everypar = {\hang}% |
| 9266 | \textindent{\thisfootno}% |
| 9267 | % |
| 9268 | % Don't crash into the line above the footnote text. Since this |
| 9269 | % expands into a box, it must come within the paragraph, lest it |
| 9270 | % provide a place where TeX can split the footnote. |
| 9271 | \footstrut |
| 9272 | % |
| 9273 | % Invoke rest of plain TeX footnote routine. |
| 9274 | \futurelet\next\fo@t |
| 9275 | } |
| 9276 | }%end \catcode `\@=11 |
| 9277 | |
| 9278 | \def\errfootnotenest{% |
| 9279 | \errhelp=\EMsimple |
| 9280 | \errmessage{Nested footnotes not supported in texinfo.tex, |
| 9281 | even though they work in makeinfo; sorry} |
| 9282 | } |
| 9283 | |
| 9284 | \def\errfootnoteheading{% |
| 9285 | \errhelp=\EMsimple |
| 9286 | \errmessage{Footnotes in chapters, sections, etc., are not supported} |
| 9287 | } |
| 9288 | |
| 9289 | % In case a @footnote appears in a vbox, save the footnote text and create |
| 9290 | % the real \insert just after the vbox finished. Otherwise, the insertion |
| 9291 | % would be lost. |
| 9292 | % Similarly, if a @footnote appears inside an alignment, save the footnote |
| 9293 | % text to a box and make the \insert when a row of the table is finished. |
| 9294 | % And the same can be done for other insert classes. --kasal, 16nov03. |
| 9295 | % |
| 9296 | % Replace the \insert primitive by a cheating macro. |
| 9297 | % Deeper inside, just make sure that the saved insertions are not spilled |
| 9298 | % out prematurely. |
| 9299 | % |
| 9300 | \def\startsavinginserts{% |
| 9301 | \ifx \insert\ptexinsert |
| 9302 | \let\insert\saveinsert |
| 9303 | \else |
| 9304 | \let\checkinserts\relax |
| 9305 | \fi |
| 9306 | } |
| 9307 | |
| 9308 | % This \insert replacement works for both \insert\footins{foo} and |
| 9309 | % \insert\footins\bgroup foo\egroup, but it doesn't work for \insert27{foo}. |
| 9310 | % |
| 9311 | \def\saveinsert#1{% |
| 9312 | \edef\next{\noexpand\savetobox \makeSAVEname#1}% |
| 9313 | \afterassignment\next |
| 9314 | % swallow the left brace |
| 9315 | \let\temp = |
| 9316 | } |
| 9317 | \def\makeSAVEname#1{\makecsname{SAVE\expandafter\gobble\string#1}} |
| 9318 | \def\savetobox#1{\global\setbox#1 = \vbox\bgroup \unvbox#1} |
| 9319 | |
| 9320 | \def\checksaveins#1{\ifvoid#1\else \placesaveins#1\fi} |
| 9321 | |
| 9322 | \def\placesaveins#1{% |
| 9323 | \ptexinsert \csname\expandafter\gobblesave\string#1\endcsname |
| 9324 | {\box#1}% |
| 9325 | } |
| 9326 | |
| 9327 | % eat @SAVE -- beware, all of them have catcode \other: |
| 9328 | { |
| 9329 | \def\dospecials{\do S\do A\do V\do E} \uncatcodespecials % ;-) |
| 9330 | \gdef\gobblesave @SAVE{} |
| 9331 | } |
| 9332 | |
| 9333 | % initialization: |
| 9334 | \def\newsaveins #1{% |
| 9335 | \edef\next{\noexpand\newsaveinsX \makeSAVEname#1}% |
| 9336 | \next |
| 9337 | } |
| 9338 | \def\newsaveinsX #1{% |
| 9339 | \csname newbox\endcsname #1% |
| 9340 | \expandafter\def\expandafter\checkinserts\expandafter{\checkinserts |
| 9341 | \checksaveins #1}% |
| 9342 | } |
| 9343 | |
| 9344 | % initialize: |
| 9345 | \let\checkinserts\empty |
| 9346 | \newsaveins\footins |
| 9347 | \newsaveins\margin |
| 9348 | |
| 9349 | |
| 9350 | % @image. We use the macros from epsf.tex to support this. |
| 9351 | % If epsf.tex is not installed and @image is used, we complain. |
| 9352 | % |
| 9353 | % Check for and read epsf.tex up front. If we read it only at @image |
| 9354 | % time, we might be inside a group, and then its definitions would get |
| 9355 | % undone and the next image would fail. |
| 9356 | \openin 1 = epsf.tex |
| 9357 | \ifeof 1 \else |
| 9358 | % Do not bother showing banner with epsf.tex v2.7k (available in |
| 9359 | % doc/epsf.tex and on ctan). |
| 9360 | \def\epsfannounce{\toks0 = }% |
| 9361 | \input epsf.tex |
| 9362 | \fi |
| 9363 | \closein 1 |
| 9364 | % |
| 9365 | % We will only complain once about lack of epsf.tex. |
| 9366 | \newif\ifwarnednoepsf |
| 9367 | \newhelp\noepsfhelp{epsf.tex must be installed for images to |
| 9368 | work. It is also included in the Texinfo distribution, or you can get |
| 9369 | it from https://ctan.org/texarchive/macros/texinfo/texinfo/doc/epsf.tex.} |
| 9370 | % |
| 9371 | \def\image#1{% |
| 9372 | \ifx\epsfbox\thisisundefined |
| 9373 | \ifwarnednoepsf \else |
| 9374 | \errhelp = \noepsfhelp |
| 9375 | \errmessage{epsf.tex not found, images will be ignored}% |
| 9376 | \global\warnednoepsftrue |
| 9377 | \fi |
| 9378 | \else |
| 9379 | \imagexxx #1,,,,,\finish |
| 9380 | \fi |
| 9381 | } |
| 9382 | % |
| 9383 | % Arguments to @image: |
| 9384 | % #1 is (mandatory) image filename; we tack on .eps extension. |
| 9385 | % #2 is (optional) width, #3 is (optional) height. |
| 9386 | % #4 is (ignored optional) html alt text. |
| 9387 | % #5 is (ignored optional) extension. |
| 9388 | % #6 is just the usual extra ignored arg for parsing stuff. |
| 9389 | \newif\ifimagevmode |
| 9390 | \def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup |
| 9391 | \catcode`\^^M = 5 % in case we're inside an example |
| 9392 | \normalturnoffactive % allow _ et al. in names |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 9393 | \makevalueexpandable |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 9394 | % If the image is by itself, center it. |
| 9395 | \ifvmode |
| 9396 | \imagevmodetrue |
| 9397 | \else \ifx\centersub\centerV |
| 9398 | % for @center @image, we need a vbox so we can have our vertical space |
| 9399 | \imagevmodetrue |
| 9400 | \vbox\bgroup % vbox has better behavior than vtop herev |
| 9401 | \fi\fi |
| 9402 | % |
| 9403 | \ifimagevmode |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 9404 | \medskip |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 9405 | % Usually we'll have text after the image which will insert |
| 9406 | % \parskip glue, so insert it here too to equalize the space |
| 9407 | % above and below. |
| 9408 | \nobreak\vskip\parskip |
| 9409 | \nobreak |
| 9410 | \fi |
| 9411 | % |
| 9412 | % Leave vertical mode so that indentation from an enclosing |
| 9413 | % environment such as @quotation is respected. |
| 9414 | % However, if we're at the top level, we don't want the |
| 9415 | % normal paragraph indentation. |
| 9416 | % On the other hand, if we are in the case of @center @image, we don't |
| 9417 | % want to start a paragraph, which will create a hsize-width box and |
| 9418 | % eradicate the centering. |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 9419 | \ifx\centersub\centerV \else \imageindent \fi |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 9420 | % |
| 9421 | % Output the image. |
| 9422 | \ifpdf |
| 9423 | % For pdfTeX and LuaTeX <= 0.80 |
| 9424 | \dopdfimage{#1}{#2}{#3}% |
| 9425 | \else |
| 9426 | \ifx\XeTeXrevision\thisisundefined |
| 9427 | % For epsf.tex |
| 9428 | % \epsfbox itself resets \epsf?size at each figure. |
| 9429 | \setbox0 = \hbox{\ignorespaces #2}% |
| 9430 | \ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi |
| 9431 | \setbox0 = \hbox{\ignorespaces #3}% |
| 9432 | \ifdim\wd0 > 0pt \epsfysize=#3\relax \fi |
| 9433 | \epsfbox{#1.eps}% |
| 9434 | \else |
| 9435 | % For XeTeX |
| 9436 | \doxeteximage{#1}{#2}{#3}% |
| 9437 | \fi |
| 9438 | \fi |
| 9439 | % |
| 9440 | \ifimagevmode |
| 9441 | \medskip % space after a standalone image |
| 9442 | \fi |
| 9443 | \ifx\centersub\centerV \egroup \fi |
| 9444 | \endgroup} |
| 9445 | |
| 9446 | |
| 9447 | % @float FLOATTYPE,LABEL,LOC ... @end float for displayed figures, tables, |
| 9448 | % etc. We don't actually implement floating yet, we always include the |
| 9449 | % float "here". But it seemed the best name for the future. |
| 9450 | % |
| 9451 | \envparseargdef\float{\eatcommaspace\eatcommaspace\dofloat#1, , ,\finish} |
| 9452 | |
| 9453 | % There may be a space before second and/or third parameter; delete it. |
| 9454 | \def\eatcommaspace#1, {#1,} |
| 9455 | |
| 9456 | % #1 is the optional FLOATTYPE, the text label for this float, typically |
| 9457 | % "Figure", "Table", "Example", etc. Can't contain commas. If omitted, |
| 9458 | % this float will not be numbered and cannot be referred to. |
| 9459 | % |
| 9460 | % #2 is the optional xref label. Also must be present for the float to |
| 9461 | % be referable. |
| 9462 | % |
| 9463 | % #3 is the optional positioning argument; for now, it is ignored. It |
| 9464 | % will somehow specify the positions allowed to float to (here, top, bottom). |
| 9465 | % |
| 9466 | % We keep a separate counter for each FLOATTYPE, which we reset at each |
| 9467 | % chapter-level command. |
| 9468 | \let\resetallfloatnos=\empty |
| 9469 | % |
| 9470 | \def\dofloat#1,#2,#3,#4\finish{% |
| 9471 | \let\thiscaption=\empty |
| 9472 | \let\thisshortcaption=\empty |
| 9473 | % |
| 9474 | % don't lose footnotes inside @float. |
| 9475 | % |
| 9476 | % BEWARE: when the floats start float, we have to issue warning whenever an |
| 9477 | % insert appears inside a float which could possibly float. --kasal, 26may04 |
| 9478 | % |
| 9479 | \startsavinginserts |
| 9480 | % |
| 9481 | % We can't be used inside a paragraph. |
| 9482 | \par |
| 9483 | % |
| 9484 | \vtop\bgroup |
| 9485 | \def\floattype{#1}% |
| 9486 | \def\floatlabel{#2}% |
| 9487 | \def\floatloc{#3}% we do nothing with this yet. |
| 9488 | % |
| 9489 | \ifx\floattype\empty |
| 9490 | \let\safefloattype=\empty |
| 9491 | \else |
| 9492 | {% |
| 9493 | % the floattype might have accents or other special characters, |
| 9494 | % but we need to use it in a control sequence name. |
| 9495 | \indexnofonts |
| 9496 | \turnoffactive |
| 9497 | \xdef\safefloattype{\floattype}% |
| 9498 | }% |
| 9499 | \fi |
| 9500 | % |
| 9501 | % If label is given but no type, we handle that as the empty type. |
| 9502 | \ifx\floatlabel\empty \else |
| 9503 | % We want each FLOATTYPE to be numbered separately (Figure 1, |
| 9504 | % Table 1, Figure 2, ...). (And if no label, no number.) |
| 9505 | % |
| 9506 | \expandafter\getfloatno\csname\safefloattype floatno\endcsname |
| 9507 | \global\advance\floatno by 1 |
| 9508 | % |
| 9509 | {% |
| 9510 | % This magic value for \currentsection is output by \setref as the |
| 9511 | % XREFLABEL-title value. \xrefX uses it to distinguish float |
| 9512 | % labels (which have a completely different output format) from |
| 9513 | % node and anchor labels. And \xrdef uses it to construct the |
| 9514 | % lists of floats. |
| 9515 | % |
| 9516 | \edef\currentsection{\floatmagic=\safefloattype}% |
| 9517 | \setref{\floatlabel}{Yfloat}% |
| 9518 | }% |
| 9519 | \fi |
| 9520 | % |
| 9521 | % start with \parskip glue, I guess. |
| 9522 | \vskip\parskip |
| 9523 | % |
| 9524 | % Don't suppress indentation if a float happens to start a section. |
| 9525 | \restorefirstparagraphindent |
| 9526 | } |
| 9527 | |
| 9528 | % we have these possibilities: |
| 9529 | % @float Foo,lbl & @caption{Cap}: Foo 1.1: Cap |
| 9530 | % @float Foo,lbl & no caption: Foo 1.1 |
| 9531 | % @float Foo & @caption{Cap}: Foo: Cap |
| 9532 | % @float Foo & no caption: Foo |
| 9533 | % @float ,lbl & Caption{Cap}: 1.1: Cap |
| 9534 | % @float ,lbl & no caption: 1.1 |
| 9535 | % @float & @caption{Cap}: Cap |
| 9536 | % @float & no caption: |
| 9537 | % |
| 9538 | \def\Efloat{% |
| 9539 | \let\floatident = \empty |
| 9540 | % |
| 9541 | % In all cases, if we have a float type, it comes first. |
| 9542 | \ifx\floattype\empty \else \def\floatident{\floattype}\fi |
| 9543 | % |
| 9544 | % If we have an xref label, the number comes next. |
| 9545 | \ifx\floatlabel\empty \else |
| 9546 | \ifx\floattype\empty \else % if also had float type, need tie first. |
| 9547 | \appendtomacro\floatident{\tie}% |
| 9548 | \fi |
| 9549 | % the number. |
| 9550 | \appendtomacro\floatident{\chaplevelprefix\the\floatno}% |
| 9551 | \fi |
| 9552 | % |
| 9553 | % Start the printed caption with what we've constructed in |
| 9554 | % \floatident, but keep it separate; we need \floatident again. |
| 9555 | \let\captionline = \floatident |
| 9556 | % |
| 9557 | \ifx\thiscaption\empty \else |
| 9558 | \ifx\floatident\empty \else |
| 9559 | \appendtomacro\captionline{: }% had ident, so need a colon between |
| 9560 | \fi |
| 9561 | % |
| 9562 | % caption text. |
| 9563 | \appendtomacro\captionline{\scanexp\thiscaption}% |
| 9564 | \fi |
| 9565 | % |
| 9566 | % If we have anything to print, print it, with space before. |
| 9567 | % Eventually this needs to become an \insert. |
| 9568 | \ifx\captionline\empty \else |
| 9569 | \vskip.5\parskip |
| 9570 | \captionline |
| 9571 | % |
| 9572 | % Space below caption. |
| 9573 | \vskip\parskip |
| 9574 | \fi |
| 9575 | % |
| 9576 | % If have an xref label, write the list of floats info. Do this |
| 9577 | % after the caption, to avoid chance of it being a breakpoint. |
| 9578 | \ifx\floatlabel\empty \else |
| 9579 | % Write the text that goes in the lof to the aux file as |
| 9580 | % \floatlabel-lof. Besides \floatident, we include the short |
| 9581 | % caption if specified, else the full caption if specified, else nothing. |
| 9582 | {% |
| 9583 | \requireauxfile |
| 9584 | \atdummies |
| 9585 | % |
| 9586 | \ifx\thisshortcaption\empty |
| 9587 | \def\gtemp{\thiscaption}% |
| 9588 | \else |
| 9589 | \def\gtemp{\thisshortcaption}% |
| 9590 | \fi |
| 9591 | \immediate\write\auxfile{@xrdef{\floatlabel-lof}{\floatident |
| 9592 | \ifx\gtemp\empty \else : \gtemp \fi}}% |
| 9593 | }% |
| 9594 | \fi |
| 9595 | \egroup % end of \vtop |
| 9596 | % |
| 9597 | \checkinserts |
| 9598 | } |
| 9599 | |
| 9600 | % Append the tokens #2 to the definition of macro #1, not expanding either. |
| 9601 | % |
| 9602 | \def\appendtomacro#1#2{% |
| 9603 | \expandafter\def\expandafter#1\expandafter{#1#2}% |
| 9604 | } |
| 9605 | |
| 9606 | % @caption, @shortcaption |
| 9607 | % |
| 9608 | \def\caption{\docaption\thiscaption} |
| 9609 | \def\shortcaption{\docaption\thisshortcaption} |
| 9610 | \def\docaption{\checkenv\float \bgroup\scanargctxt\defcaption} |
| 9611 | \def\defcaption#1#2{\egroup \def#1{#2}} |
| 9612 | |
| 9613 | % The parameter is the control sequence identifying the counter we are |
| 9614 | % going to use. Create it if it doesn't exist and assign it to \floatno. |
| 9615 | \def\getfloatno#1{% |
| 9616 | \ifx#1\relax |
| 9617 | % Haven't seen this figure type before. |
| 9618 | \csname newcount\endcsname #1% |
| 9619 | % |
| 9620 | % Remember to reset this floatno at the next chap. |
| 9621 | \expandafter\gdef\expandafter\resetallfloatnos |
| 9622 | \expandafter{\resetallfloatnos #1=0 }% |
| 9623 | \fi |
| 9624 | \let\floatno#1% |
| 9625 | } |
| 9626 | |
| 9627 | % \setref calls this to get the XREFLABEL-snt value. We want an @xref |
| 9628 | % to the FLOATLABEL to expand to "Figure 3.1". We call \setref when we |
| 9629 | % first read the @float command. |
| 9630 | % |
| 9631 | \def\Yfloat{\floattype@tie \chaplevelprefix\the\floatno}% |
| 9632 | |
| 9633 | % Magic string used for the XREFLABEL-title value, so \xrefX can |
| 9634 | % distinguish floats from other xref types. |
| 9635 | \def\floatmagic{!!float!!} |
| 9636 | |
| 9637 | % #1 is the control sequence we are passed; we expand into a conditional |
| 9638 | % which is true if #1 represents a float ref. That is, the magic |
| 9639 | % \currentsection value which we \setref above. |
| 9640 | % |
| 9641 | \def\iffloat#1{\expandafter\doiffloat#1==\finish} |
| 9642 | % |
| 9643 | % #1 is (maybe) the \floatmagic string. If so, #2 will be the |
| 9644 | % (safe) float type for this float. We set \iffloattype to #2. |
| 9645 | % |
| 9646 | \def\doiffloat#1=#2=#3\finish{% |
| 9647 | \def\temp{#1}% |
| 9648 | \def\iffloattype{#2}% |
| 9649 | \ifx\temp\floatmagic |
| 9650 | } |
| 9651 | |
| 9652 | % @listoffloats FLOATTYPE - print a list of floats like a table of contents. |
| 9653 | % |
| 9654 | \parseargdef\listoffloats{% |
| 9655 | \def\floattype{#1}% floattype |
| 9656 | {% |
| 9657 | % the floattype might have accents or other special characters, |
| 9658 | % but we need to use it in a control sequence name. |
| 9659 | \indexnofonts |
| 9660 | \turnoffactive |
| 9661 | \xdef\safefloattype{\floattype}% |
| 9662 | }% |
| 9663 | % |
| 9664 | % \xrdef saves the floats as a \do-list in \floatlistSAFEFLOATTYPE. |
| 9665 | \expandafter\ifx\csname floatlist\safefloattype\endcsname \relax |
| 9666 | \ifhavexrefs |
| 9667 | % if the user said @listoffloats foo but never @float foo. |
| 9668 | \message{\linenumber No `\safefloattype' floats to list.}% |
| 9669 | \fi |
| 9670 | \else |
| 9671 | \begingroup |
| 9672 | \leftskip=\tocindent % indent these entries like a toc |
| 9673 | \let\do=\listoffloatsdo |
| 9674 | \csname floatlist\safefloattype\endcsname |
| 9675 | \endgroup |
| 9676 | \fi |
| 9677 | } |
| 9678 | |
| 9679 | % This is called on each entry in a list of floats. We're passed the |
| 9680 | % xref label, in the form LABEL-title, which is how we save it in the |
| 9681 | % aux file. We strip off the -title and look up \XRLABEL-lof, which |
| 9682 | % has the text we're supposed to typeset here. |
| 9683 | % |
| 9684 | % Figures without xref labels will not be included in the list (since |
| 9685 | % they won't appear in the aux file). |
| 9686 | % |
| 9687 | \def\listoffloatsdo#1{\listoffloatsdoentry#1\finish} |
| 9688 | \def\listoffloatsdoentry#1-title\finish{{% |
| 9689 | % Can't fully expand XR#1-lof because it can contain anything. Just |
| 9690 | % pass the control sequence. On the other hand, XR#1-pg is just the |
| 9691 | % page number, and we want to fully expand that so we can get a link |
| 9692 | % in pdf output. |
| 9693 | \toksA = \expandafter{\csname XR#1-lof\endcsname}% |
| 9694 | % |
| 9695 | % use the same \entry macro we use to generate the TOC and index. |
| 9696 | \edef\writeentry{\noexpand\entry{\the\toksA}{\csname XR#1-pg\endcsname}}% |
| 9697 | \writeentry |
| 9698 | }} |
| 9699 | |
| 9700 | |
| 9701 | \message{localization,} |
| 9702 | |
| 9703 | % For single-language documents, @documentlanguage is usually given very |
| 9704 | % early, just after @documentencoding. Single argument is the language |
| 9705 | % (de) or locale (de_DE) abbreviation. |
| 9706 | % |
| 9707 | { |
| 9708 | \catcode`\_ = \active |
| 9709 | \globaldefs=1 |
| 9710 | \parseargdef\documentlanguage{% |
| 9711 | \tex % read txi-??.tex file in plain TeX. |
| 9712 | % Read the file by the name they passed if it exists. |
| 9713 | \let_ = \normalunderscore % normal _ character for filename test |
| 9714 | \openin 1 txi-#1.tex |
| 9715 | \ifeof 1 |
| 9716 | \documentlanguagetrywithoutunderscore #1_\finish |
| 9717 | \else |
| 9718 | \globaldefs = 1 % everything in the txi-LL files needs to persist |
| 9719 | \input txi-#1.tex |
| 9720 | \fi |
| 9721 | \closein 1 |
| 9722 | \endgroup % end raw TeX |
| 9723 | } |
| 9724 | % |
| 9725 | % If they passed de_DE, and txi-de_DE.tex doesn't exist, |
| 9726 | % try txi-de.tex. |
| 9727 | % |
| 9728 | \gdef\documentlanguagetrywithoutunderscore#1_#2\finish{% |
| 9729 | \openin 1 txi-#1.tex |
| 9730 | \ifeof 1 |
| 9731 | \errhelp = \nolanghelp |
| 9732 | \errmessage{Cannot read language file txi-#1.tex}% |
| 9733 | \else |
| 9734 | \globaldefs = 1 % everything in the txi-LL files needs to persist |
| 9735 | \input txi-#1.tex |
| 9736 | \fi |
| 9737 | \closein 1 |
| 9738 | } |
| 9739 | }% end of special _ catcode |
| 9740 | % |
| 9741 | \newhelp\nolanghelp{The given language definition file cannot be found or |
| 9742 | is empty. Maybe you need to install it? Putting it in the current |
| 9743 | directory should work if nowhere else does.} |
| 9744 | |
| 9745 | % This macro is called from txi-??.tex files; the first argument is the |
| 9746 | % \language name to set (without the "\lang@" prefix), the second and |
| 9747 | % third args are \{left,right}hyphenmin. |
| 9748 | % |
| 9749 | % The language names to pass are determined when the format is built. |
| 9750 | % See the etex.log file created at that time, e.g., |
| 9751 | % /usr/local/texlive/2008/texmf-var/web2c/pdftex/etex.log. |
| 9752 | % |
| 9753 | % With TeX Live 2008, etex now includes hyphenation patterns for all |
| 9754 | % available languages. This means we can support hyphenation in |
| 9755 | % Texinfo, at least to some extent. (This still doesn't solve the |
| 9756 | % accented characters problem.) |
| 9757 | % |
| 9758 | \catcode`@=11 |
| 9759 | \def\txisetlanguage#1#2#3{% |
| 9760 | % do not set the language if the name is undefined in the current TeX. |
| 9761 | \expandafter\ifx\csname lang@#1\endcsname \relax |
| 9762 | \message{no patterns for #1}% |
| 9763 | \else |
| 9764 | \global\language = \csname lang@#1\endcsname |
| 9765 | \fi |
| 9766 | % but there is no harm in adjusting the hyphenmin values regardless. |
| 9767 | \global\lefthyphenmin = #2\relax |
| 9768 | \global\righthyphenmin = #3\relax |
| 9769 | } |
| 9770 | |
| 9771 | % XeTeX and LuaTeX can handle Unicode natively. |
| 9772 | % Their default I/O uses UTF-8 sequences instead of a byte-wise operation. |
| 9773 | % Other TeX engines' I/O (pdfTeX, etc.) is byte-wise. |
| 9774 | % |
| 9775 | \newif\iftxinativeunicodecapable |
| 9776 | \newif\iftxiusebytewiseio |
| 9777 | |
| 9778 | \ifx\XeTeXrevision\thisisundefined |
| 9779 | \ifx\luatexversion\thisisundefined |
| 9780 | \txinativeunicodecapablefalse |
| 9781 | \txiusebytewiseiotrue |
| 9782 | \else |
| 9783 | \txinativeunicodecapabletrue |
| 9784 | \txiusebytewiseiofalse |
| 9785 | \fi |
| 9786 | \else |
| 9787 | \txinativeunicodecapabletrue |
| 9788 | \txiusebytewiseiofalse |
| 9789 | \fi |
| 9790 | |
| 9791 | % Set I/O by bytes instead of UTF-8 sequence for XeTeX and LuaTex |
| 9792 | % for non-UTF-8 (byte-wise) encodings. |
| 9793 | % |
| 9794 | \def\setbytewiseio{% |
| 9795 | \ifx\XeTeXrevision\thisisundefined |
| 9796 | \else |
| 9797 | \XeTeXdefaultencoding "bytes" % For subsequent files to be read |
| 9798 | \XeTeXinputencoding "bytes" % For document root file |
| 9799 | % Unfortunately, there seems to be no corresponding XeTeX command for |
| 9800 | % output encoding. This is a problem for auxiliary index and TOC files. |
| 9801 | % The only solution would be perhaps to write out @U{...} sequences in |
| 9802 | % place of non-ASCII characters. |
| 9803 | \fi |
| 9804 | |
| 9805 | \ifx\luatexversion\thisisundefined |
| 9806 | \else |
| 9807 | \directlua{ |
| 9808 | local utf8_char, byte, gsub = unicode.utf8.char, string.byte, string.gsub |
| 9809 | local function convert_char (char) |
| 9810 | return utf8_char(byte(char)) |
| 9811 | end |
| 9812 | |
| 9813 | local function convert_line (line) |
| 9814 | return gsub(line, ".", convert_char) |
| 9815 | end |
| 9816 | |
| 9817 | callback.register("process_input_buffer", convert_line) |
| 9818 | |
| 9819 | local function convert_line_out (line) |
| 9820 | local line_out = "" |
| 9821 | for c in string.utfvalues(line) do |
| 9822 | line_out = line_out .. string.char(c) |
| 9823 | end |
| 9824 | return line_out |
| 9825 | end |
| 9826 | |
| 9827 | callback.register("process_output_buffer", convert_line_out) |
| 9828 | } |
| 9829 | \fi |
| 9830 | |
| 9831 | \txiusebytewiseiotrue |
| 9832 | } |
| 9833 | |
| 9834 | |
| 9835 | % Helpers for encodings. |
| 9836 | % Set the catcode of characters 128 through 255 to the specified number. |
| 9837 | % |
| 9838 | \def\setnonasciicharscatcode#1{% |
| 9839 | \count255=128 |
| 9840 | \loop\ifnum\count255<256 |
| 9841 | \global\catcode\count255=#1\relax |
| 9842 | \advance\count255 by 1 |
| 9843 | \repeat |
| 9844 | } |
| 9845 | |
| 9846 | \def\setnonasciicharscatcodenonglobal#1{% |
| 9847 | \count255=128 |
| 9848 | \loop\ifnum\count255<256 |
| 9849 | \catcode\count255=#1\relax |
| 9850 | \advance\count255 by 1 |
| 9851 | \repeat |
| 9852 | } |
| 9853 | |
| 9854 | % @documentencoding sets the definition of non-ASCII characters |
| 9855 | % according to the specified encoding. |
| 9856 | % |
| 9857 | \def\documentencoding{\parseargusing\filenamecatcodes\documentencodingzzz} |
| 9858 | \def\documentencodingzzz#1{% |
| 9859 | % |
| 9860 | % Encoding being declared for the document. |
| 9861 | \def\declaredencoding{\csname #1.enc\endcsname}% |
| 9862 | % |
| 9863 | % Supported encodings: names converted to tokens in order to be able |
| 9864 | % to compare them with \ifx. |
| 9865 | \def\ascii{\csname US-ASCII.enc\endcsname}% |
| 9866 | \def\latnine{\csname ISO-8859-15.enc\endcsname}% |
| 9867 | \def\latone{\csname ISO-8859-1.enc\endcsname}% |
| 9868 | \def\lattwo{\csname ISO-8859-2.enc\endcsname}% |
| 9869 | \def\utfeight{\csname UTF-8.enc\endcsname}% |
| 9870 | % |
| 9871 | \ifx \declaredencoding \ascii |
| 9872 | \asciichardefs |
| 9873 | % |
| 9874 | \else \ifx \declaredencoding \lattwo |
| 9875 | \iftxinativeunicodecapable |
| 9876 | \setbytewiseio |
| 9877 | \fi |
| 9878 | \setnonasciicharscatcode\active |
| 9879 | \lattwochardefs |
| 9880 | % |
| 9881 | \else \ifx \declaredencoding \latone |
| 9882 | \iftxinativeunicodecapable |
| 9883 | \setbytewiseio |
| 9884 | \fi |
| 9885 | \setnonasciicharscatcode\active |
| 9886 | \latonechardefs |
| 9887 | % |
| 9888 | \else \ifx \declaredencoding \latnine |
| 9889 | \iftxinativeunicodecapable |
| 9890 | \setbytewiseio |
| 9891 | \fi |
| 9892 | \setnonasciicharscatcode\active |
| 9893 | \latninechardefs |
| 9894 | % |
| 9895 | \else \ifx \declaredencoding \utfeight |
| 9896 | \iftxinativeunicodecapable |
| 9897 | % For native Unicode handling (XeTeX and LuaTeX) |
| 9898 | \nativeunicodechardefs |
| 9899 | \else |
| 9900 | % For treating UTF-8 as byte sequences (TeX, eTeX and pdfTeX) |
| 9901 | \setnonasciicharscatcode\active |
| 9902 | % since we already invoked \utfeightchardefs at the top level |
| 9903 | % (below), do not re-invoke it, otherwise our check for duplicated |
| 9904 | % definitions gets triggered. Making non-ascii chars active is |
| 9905 | % sufficient. |
| 9906 | \fi |
| 9907 | % |
| 9908 | \else |
| 9909 | \message{Ignoring unknown document encoding: #1.}% |
| 9910 | % |
| 9911 | \fi % utfeight |
| 9912 | \fi % latnine |
| 9913 | \fi % latone |
| 9914 | \fi % lattwo |
| 9915 | \fi % ascii |
| 9916 | % |
| 9917 | \ifx\XeTeXrevision\thisisundefined |
| 9918 | \else |
| 9919 | \ifx \declaredencoding \utfeight |
| 9920 | \else |
| 9921 | \ifx \declaredencoding \ascii |
| 9922 | \else |
| 9923 | \message{Warning: XeTeX with non-UTF-8 encodings cannot handle % |
| 9924 | non-ASCII characters in auxiliary files.}% |
| 9925 | \fi |
| 9926 | \fi |
| 9927 | \fi |
| 9928 | } |
| 9929 | |
| 9930 | % emacs-page |
| 9931 | % A message to be logged when using a character that isn't available |
| 9932 | % the default font encoding (OT1). |
| 9933 | % |
| 9934 | \def\missingcharmsg#1{\message{Character missing, sorry: #1.}} |
| 9935 | |
| 9936 | % Take account of \c (plain) vs. \, (Texinfo) difference. |
| 9937 | \def\cedilla#1{\ifx\c\ptexc\c{#1}\else\,{#1}\fi} |
| 9938 | |
| 9939 | % First, make active non-ASCII characters in order for them to be |
| 9940 | % correctly categorized when TeX reads the replacement text of |
| 9941 | % macros containing the character definitions. |
| 9942 | \setnonasciicharscatcode\active |
| 9943 | % |
| 9944 | |
| 9945 | \def\gdefchar#1#2{% |
| 9946 | \gdef#1{% |
| 9947 | \ifpassthroughchars |
| 9948 | \string#1% |
| 9949 | \else |
| 9950 | #2% |
| 9951 | \fi |
| 9952 | }} |
| 9953 | |
| 9954 | % Latin1 (ISO-8859-1) character definitions. |
| 9955 | \def\latonechardefs{% |
| 9956 | \gdefchar^^a0{\tie} |
| 9957 | \gdefchar^^a1{\exclamdown} |
| 9958 | \gdefchar^^a2{{\tcfont \char162}} % cent |
| 9959 | \gdefchar^^a3{\pounds{}} |
| 9960 | \gdefchar^^a4{{\tcfont \char164}} % currency |
| 9961 | \gdefchar^^a5{{\tcfont \char165}} % yen |
| 9962 | \gdefchar^^a6{{\tcfont \char166}} % broken bar |
| 9963 | \gdefchar^^a7{\S} |
| 9964 | \gdefchar^^a8{\"{}} |
| 9965 | \gdefchar^^a9{\copyright{}} |
| 9966 | \gdefchar^^aa{\ordf} |
| 9967 | \gdefchar^^ab{\guillemetleft{}} |
| 9968 | \gdefchar^^ac{\ensuremath\lnot} |
| 9969 | \gdefchar^^ad{\-} |
| 9970 | \gdefchar^^ae{\registeredsymbol{}} |
| 9971 | \gdefchar^^af{\={}} |
| 9972 | % |
| 9973 | \gdefchar^^b0{\textdegree} |
| 9974 | \gdefchar^^b1{$\pm$} |
| 9975 | \gdefchar^^b2{$^2$} |
| 9976 | \gdefchar^^b3{$^3$} |
| 9977 | \gdefchar^^b4{\'{}} |
| 9978 | \gdefchar^^b5{$\mu$} |
| 9979 | \gdefchar^^b6{\P} |
| 9980 | \gdefchar^^b7{\ensuremath\cdot} |
| 9981 | \gdefchar^^b8{\cedilla\ } |
| 9982 | \gdefchar^^b9{$^1$} |
| 9983 | \gdefchar^^ba{\ordm} |
| 9984 | \gdefchar^^bb{\guillemetright{}} |
| 9985 | \gdefchar^^bc{$1\over4$} |
| 9986 | \gdefchar^^bd{$1\over2$} |
| 9987 | \gdefchar^^be{$3\over4$} |
| 9988 | \gdefchar^^bf{\questiondown} |
| 9989 | % |
| 9990 | \gdefchar^^c0{\`A} |
| 9991 | \gdefchar^^c1{\'A} |
| 9992 | \gdefchar^^c2{\^A} |
| 9993 | \gdefchar^^c3{\~A} |
| 9994 | \gdefchar^^c4{\"A} |
| 9995 | \gdefchar^^c5{\ringaccent A} |
| 9996 | \gdefchar^^c6{\AE} |
| 9997 | \gdefchar^^c7{\cedilla C} |
| 9998 | \gdefchar^^c8{\`E} |
| 9999 | \gdefchar^^c9{\'E} |
| 10000 | \gdefchar^^ca{\^E} |
| 10001 | \gdefchar^^cb{\"E} |
| 10002 | \gdefchar^^cc{\`I} |
| 10003 | \gdefchar^^cd{\'I} |
| 10004 | \gdefchar^^ce{\^I} |
| 10005 | \gdefchar^^cf{\"I} |
| 10006 | % |
| 10007 | \gdefchar^^d0{\DH} |
| 10008 | \gdefchar^^d1{\~N} |
| 10009 | \gdefchar^^d2{\`O} |
| 10010 | \gdefchar^^d3{\'O} |
| 10011 | \gdefchar^^d4{\^O} |
| 10012 | \gdefchar^^d5{\~O} |
| 10013 | \gdefchar^^d6{\"O} |
| 10014 | \gdefchar^^d7{$\times$} |
| 10015 | \gdefchar^^d8{\O} |
| 10016 | \gdefchar^^d9{\`U} |
| 10017 | \gdefchar^^da{\'U} |
| 10018 | \gdefchar^^db{\^U} |
| 10019 | \gdefchar^^dc{\"U} |
| 10020 | \gdefchar^^dd{\'Y} |
| 10021 | \gdefchar^^de{\TH} |
| 10022 | \gdefchar^^df{\ss} |
| 10023 | % |
| 10024 | \gdefchar^^e0{\`a} |
| 10025 | \gdefchar^^e1{\'a} |
| 10026 | \gdefchar^^e2{\^a} |
| 10027 | \gdefchar^^e3{\~a} |
| 10028 | \gdefchar^^e4{\"a} |
| 10029 | \gdefchar^^e5{\ringaccent a} |
| 10030 | \gdefchar^^e6{\ae} |
| 10031 | \gdefchar^^e7{\cedilla c} |
| 10032 | \gdefchar^^e8{\`e} |
| 10033 | \gdefchar^^e9{\'e} |
| 10034 | \gdefchar^^ea{\^e} |
| 10035 | \gdefchar^^eb{\"e} |
| 10036 | \gdefchar^^ec{\`{\dotless i}} |
| 10037 | \gdefchar^^ed{\'{\dotless i}} |
| 10038 | \gdefchar^^ee{\^{\dotless i}} |
| 10039 | \gdefchar^^ef{\"{\dotless i}} |
| 10040 | % |
| 10041 | \gdefchar^^f0{\dh} |
| 10042 | \gdefchar^^f1{\~n} |
| 10043 | \gdefchar^^f2{\`o} |
| 10044 | \gdefchar^^f3{\'o} |
| 10045 | \gdefchar^^f4{\^o} |
| 10046 | \gdefchar^^f5{\~o} |
| 10047 | \gdefchar^^f6{\"o} |
| 10048 | \gdefchar^^f7{$\div$} |
| 10049 | \gdefchar^^f8{\o} |
| 10050 | \gdefchar^^f9{\`u} |
| 10051 | \gdefchar^^fa{\'u} |
| 10052 | \gdefchar^^fb{\^u} |
| 10053 | \gdefchar^^fc{\"u} |
| 10054 | \gdefchar^^fd{\'y} |
| 10055 | \gdefchar^^fe{\th} |
| 10056 | \gdefchar^^ff{\"y} |
| 10057 | } |
| 10058 | |
| 10059 | % Latin9 (ISO-8859-15) encoding character definitions. |
| 10060 | \def\latninechardefs{% |
| 10061 | % Encoding is almost identical to Latin1. |
| 10062 | \latonechardefs |
| 10063 | % |
| 10064 | \gdefchar^^a4{\euro{}} |
| 10065 | \gdefchar^^a6{\v S} |
| 10066 | \gdefchar^^a8{\v s} |
| 10067 | \gdefchar^^b4{\v Z} |
| 10068 | \gdefchar^^b8{\v z} |
| 10069 | \gdefchar^^bc{\OE} |
| 10070 | \gdefchar^^bd{\oe} |
| 10071 | \gdefchar^^be{\"Y} |
| 10072 | } |
| 10073 | |
| 10074 | % Latin2 (ISO-8859-2) character definitions. |
| 10075 | \def\lattwochardefs{% |
| 10076 | \gdefchar^^a0{\tie} |
| 10077 | \gdefchar^^a1{\ogonek{A}} |
| 10078 | \gdefchar^^a2{\u{}} |
| 10079 | \gdefchar^^a3{\L} |
| 10080 | \gdefchar^^a4{\missingcharmsg{CURRENCY SIGN}} |
| 10081 | \gdefchar^^a5{\v L} |
| 10082 | \gdefchar^^a6{\'S} |
| 10083 | \gdefchar^^a7{\S} |
| 10084 | \gdefchar^^a8{\"{}} |
| 10085 | \gdefchar^^a9{\v S} |
| 10086 | \gdefchar^^aa{\cedilla S} |
| 10087 | \gdefchar^^ab{\v T} |
| 10088 | \gdefchar^^ac{\'Z} |
| 10089 | \gdefchar^^ad{\-} |
| 10090 | \gdefchar^^ae{\v Z} |
| 10091 | \gdefchar^^af{\dotaccent Z} |
| 10092 | % |
| 10093 | \gdefchar^^b0{\textdegree{}} |
| 10094 | \gdefchar^^b1{\ogonek{a}} |
| 10095 | \gdefchar^^b2{\ogonek{ }} |
| 10096 | \gdefchar^^b3{\l} |
| 10097 | \gdefchar^^b4{\'{}} |
| 10098 | \gdefchar^^b5{\v l} |
| 10099 | \gdefchar^^b6{\'s} |
| 10100 | \gdefchar^^b7{\v{}} |
| 10101 | \gdefchar^^b8{\cedilla\ } |
| 10102 | \gdefchar^^b9{\v s} |
| 10103 | \gdefchar^^ba{\cedilla s} |
| 10104 | \gdefchar^^bb{\v t} |
| 10105 | \gdefchar^^bc{\'z} |
| 10106 | \gdefchar^^bd{\H{}} |
| 10107 | \gdefchar^^be{\v z} |
| 10108 | \gdefchar^^bf{\dotaccent z} |
| 10109 | % |
| 10110 | \gdefchar^^c0{\'R} |
| 10111 | \gdefchar^^c1{\'A} |
| 10112 | \gdefchar^^c2{\^A} |
| 10113 | \gdefchar^^c3{\u A} |
| 10114 | \gdefchar^^c4{\"A} |
| 10115 | \gdefchar^^c5{\'L} |
| 10116 | \gdefchar^^c6{\'C} |
| 10117 | \gdefchar^^c7{\cedilla C} |
| 10118 | \gdefchar^^c8{\v C} |
| 10119 | \gdefchar^^c9{\'E} |
| 10120 | \gdefchar^^ca{\ogonek{E}} |
| 10121 | \gdefchar^^cb{\"E} |
| 10122 | \gdefchar^^cc{\v E} |
| 10123 | \gdefchar^^cd{\'I} |
| 10124 | \gdefchar^^ce{\^I} |
| 10125 | \gdefchar^^cf{\v D} |
| 10126 | % |
| 10127 | \gdefchar^^d0{\DH} |
| 10128 | \gdefchar^^d1{\'N} |
| 10129 | \gdefchar^^d2{\v N} |
| 10130 | \gdefchar^^d3{\'O} |
| 10131 | \gdefchar^^d4{\^O} |
| 10132 | \gdefchar^^d5{\H O} |
| 10133 | \gdefchar^^d6{\"O} |
| 10134 | \gdefchar^^d7{$\times$} |
| 10135 | \gdefchar^^d8{\v R} |
| 10136 | \gdefchar^^d9{\ringaccent U} |
| 10137 | \gdefchar^^da{\'U} |
| 10138 | \gdefchar^^db{\H U} |
| 10139 | \gdefchar^^dc{\"U} |
| 10140 | \gdefchar^^dd{\'Y} |
| 10141 | \gdefchar^^de{\cedilla T} |
| 10142 | \gdefchar^^df{\ss} |
| 10143 | % |
| 10144 | \gdefchar^^e0{\'r} |
| 10145 | \gdefchar^^e1{\'a} |
| 10146 | \gdefchar^^e2{\^a} |
| 10147 | \gdefchar^^e3{\u a} |
| 10148 | \gdefchar^^e4{\"a} |
| 10149 | \gdefchar^^e5{\'l} |
| 10150 | \gdefchar^^e6{\'c} |
| 10151 | \gdefchar^^e7{\cedilla c} |
| 10152 | \gdefchar^^e8{\v c} |
| 10153 | \gdefchar^^e9{\'e} |
| 10154 | \gdefchar^^ea{\ogonek{e}} |
| 10155 | \gdefchar^^eb{\"e} |
| 10156 | \gdefchar^^ec{\v e} |
| 10157 | \gdefchar^^ed{\'{\dotless{i}}} |
| 10158 | \gdefchar^^ee{\^{\dotless{i}}} |
| 10159 | \gdefchar^^ef{\v d} |
| 10160 | % |
| 10161 | \gdefchar^^f0{\dh} |
| 10162 | \gdefchar^^f1{\'n} |
| 10163 | \gdefchar^^f2{\v n} |
| 10164 | \gdefchar^^f3{\'o} |
| 10165 | \gdefchar^^f4{\^o} |
| 10166 | \gdefchar^^f5{\H o} |
| 10167 | \gdefchar^^f6{\"o} |
| 10168 | \gdefchar^^f7{$\div$} |
| 10169 | \gdefchar^^f8{\v r} |
| 10170 | \gdefchar^^f9{\ringaccent u} |
| 10171 | \gdefchar^^fa{\'u} |
| 10172 | \gdefchar^^fb{\H u} |
| 10173 | \gdefchar^^fc{\"u} |
| 10174 | \gdefchar^^fd{\'y} |
| 10175 | \gdefchar^^fe{\cedilla t} |
| 10176 | \gdefchar^^ff{\dotaccent{}} |
| 10177 | } |
| 10178 | |
| 10179 | % UTF-8 character definitions. |
| 10180 | % |
| 10181 | % This code to support UTF-8 is based on LaTeX's utf8.def, with some |
| 10182 | % changes for Texinfo conventions. It is included here under the GPL by |
| 10183 | % permission from Frank Mittelbach and the LaTeX team. |
| 10184 | % |
| 10185 | \newcount\countUTFx |
| 10186 | \newcount\countUTFy |
| 10187 | \newcount\countUTFz |
| 10188 | |
| 10189 | \gdef\UTFviiiTwoOctets#1#2{\expandafter |
| 10190 | \UTFviiiDefined\csname u8:#1\string #2\endcsname} |
| 10191 | % |
| 10192 | \gdef\UTFviiiThreeOctets#1#2#3{\expandafter |
| 10193 | \UTFviiiDefined\csname u8:#1\string #2\string #3\endcsname} |
| 10194 | % |
| 10195 | \gdef\UTFviiiFourOctets#1#2#3#4{\expandafter |
| 10196 | \UTFviiiDefined\csname u8:#1\string #2\string #3\string #4\endcsname} |
| 10197 | |
| 10198 | \gdef\UTFviiiDefined#1{% |
| 10199 | \ifx #1\relax |
| 10200 | \message{\linenumber Unicode char \string #1 not defined for Texinfo}% |
| 10201 | \else |
| 10202 | \expandafter #1% |
| 10203 | \fi |
| 10204 | } |
| 10205 | |
| 10206 | % Give non-ASCII bytes the active definitions for processing UTF-8 sequences |
| 10207 | \begingroup |
| 10208 | \catcode`\~13 |
| 10209 | \catcode`\$12 |
| 10210 | \catcode`\"12 |
| 10211 | |
| 10212 | % Loop from \countUTFx to \countUTFy, performing \UTFviiiTmp |
| 10213 | % substituting ~ and $ with a character token of that value. |
| 10214 | \def\UTFviiiLoop{% |
| 10215 | \global\catcode\countUTFx\active |
| 10216 | \uccode`\~\countUTFx |
| 10217 | \uccode`\$\countUTFx |
| 10218 | \uppercase\expandafter{\UTFviiiTmp}% |
| 10219 | \advance\countUTFx by 1 |
| 10220 | \ifnum\countUTFx < \countUTFy |
| 10221 | \expandafter\UTFviiiLoop |
| 10222 | \fi} |
| 10223 | |
| 10224 | % For bytes other than the first in a UTF-8 sequence. Not expected to |
| 10225 | % be expanded except when writing to auxiliary files. |
| 10226 | \countUTFx = "80 |
| 10227 | \countUTFy = "C2 |
| 10228 | \def\UTFviiiTmp{% |
| 10229 | \gdef~{% |
| 10230 | \ifpassthroughchars $\fi}}% |
| 10231 | \UTFviiiLoop |
| 10232 | |
| 10233 | \countUTFx = "C2 |
| 10234 | \countUTFy = "E0 |
| 10235 | \def\UTFviiiTmp{% |
| 10236 | \gdef~{% |
| 10237 | \ifpassthroughchars $% |
| 10238 | \else\expandafter\UTFviiiTwoOctets\expandafter$\fi}}% |
| 10239 | \UTFviiiLoop |
| 10240 | |
| 10241 | \countUTFx = "E0 |
| 10242 | \countUTFy = "F0 |
| 10243 | \def\UTFviiiTmp{% |
| 10244 | \gdef~{% |
| 10245 | \ifpassthroughchars $% |
| 10246 | \else\expandafter\UTFviiiThreeOctets\expandafter$\fi}}% |
| 10247 | \UTFviiiLoop |
| 10248 | |
| 10249 | \countUTFx = "F0 |
| 10250 | \countUTFy = "F4 |
| 10251 | \def\UTFviiiTmp{% |
| 10252 | \gdef~{% |
| 10253 | \ifpassthroughchars $% |
| 10254 | \else\expandafter\UTFviiiFourOctets\expandafter$\fi |
| 10255 | }}% |
| 10256 | \UTFviiiLoop |
| 10257 | \endgroup |
| 10258 | |
| 10259 | \def\globallet{\global\let} % save some \expandafter's below |
| 10260 | |
| 10261 | % @U{xxxx} to produce U+xxxx, if we support it. |
| 10262 | \def\U#1{% |
| 10263 | \expandafter\ifx\csname uni:#1\endcsname \relax |
| 10264 | \iftxinativeunicodecapable |
| 10265 | % All Unicode characters can be used if native Unicode handling is |
| 10266 | % active. However, if the font does not have the glyph, |
| 10267 | % letters are missing. |
| 10268 | \begingroup |
| 10269 | \uccode`\.="#1\relax |
| 10270 | \uppercase{.} |
| 10271 | \endgroup |
| 10272 | \else |
| 10273 | \errhelp = \EMsimple |
| 10274 | \errmessage{Unicode character U+#1 not supported, sorry}% |
| 10275 | \fi |
| 10276 | \else |
| 10277 | \csname uni:#1\endcsname |
| 10278 | \fi |
| 10279 | } |
| 10280 | |
| 10281 | % These macros are used here to construct the name of a control |
| 10282 | % sequence to be defined. |
| 10283 | \def\UTFviiiTwoOctetsName#1#2{% |
| 10284 | \csname u8:#1\string #2\endcsname}% |
| 10285 | \def\UTFviiiThreeOctetsName#1#2#3{% |
| 10286 | \csname u8:#1\string #2\string #3\endcsname}% |
| 10287 | \def\UTFviiiFourOctetsName#1#2#3#4{% |
| 10288 | \csname u8:#1\string #2\string #3\string #4\endcsname}% |
| 10289 | |
| 10290 | % For UTF-8 byte sequences (TeX, e-TeX and pdfTeX), |
| 10291 | % provide a definition macro to replace a Unicode character; |
| 10292 | % this gets used by the @U command |
| 10293 | % |
| 10294 | \begingroup |
| 10295 | \catcode`\"=12 |
| 10296 | \catcode`\<=12 |
| 10297 | \catcode`\.=12 |
| 10298 | \catcode`\,=12 |
| 10299 | \catcode`\;=12 |
| 10300 | \catcode`\!=12 |
| 10301 | \catcode`\~=13 |
| 10302 | \gdef\DeclareUnicodeCharacterUTFviii#1#2{% |
| 10303 | \countUTFz = "#1\relax |
| 10304 | \begingroup |
| 10305 | \parseXMLCharref |
| 10306 | |
| 10307 | % Give \u8:... its definition. The sequence of seven \expandafter's |
| 10308 | % expands after the \gdef three times, e.g. |
| 10309 | % |
| 10310 | % 1. \UTFviiTwoOctetsName B1 B2 |
| 10311 | % 2. \csname u8:B1 \string B2 \endcsname |
| 10312 | % 3. \u8: B1 B2 (a single control sequence token) |
| 10313 | % |
| 10314 | \expandafter\expandafter |
| 10315 | \expandafter\expandafter |
| 10316 | \expandafter\expandafter |
| 10317 | \expandafter\gdef \UTFviiiTmp{#2}% |
| 10318 | % |
| 10319 | \expandafter\ifx\csname uni:#1\endcsname \relax \else |
| 10320 | \message{Internal error, already defined: #1}% |
| 10321 | \fi |
| 10322 | % |
| 10323 | % define an additional control sequence for this code point. |
| 10324 | \expandafter\globallet\csname uni:#1\endcsname \UTFviiiTmp |
| 10325 | \endgroup} |
| 10326 | % |
| 10327 | % Given the value in \countUTFz as a Unicode code point, set \UTFviiiTmp |
| 10328 | % to the corresponding UTF-8 sequence. |
| 10329 | \gdef\parseXMLCharref{% |
| 10330 | \ifnum\countUTFz < "A0\relax |
| 10331 | \errhelp = \EMsimple |
| 10332 | \errmessage{Cannot define Unicode char value < 00A0}% |
| 10333 | \else\ifnum\countUTFz < "800\relax |
| 10334 | \parseUTFviiiA,% |
| 10335 | \parseUTFviiiB C\UTFviiiTwoOctetsName.,% |
| 10336 | \else\ifnum\countUTFz < "10000\relax |
| 10337 | \parseUTFviiiA;% |
| 10338 | \parseUTFviiiA,% |
| 10339 | \parseUTFviiiB E\UTFviiiThreeOctetsName.{,;}% |
| 10340 | \else |
| 10341 | \parseUTFviiiA;% |
| 10342 | \parseUTFviiiA,% |
| 10343 | \parseUTFviiiA!% |
| 10344 | \parseUTFviiiB F\UTFviiiFourOctetsName.{!,;}% |
| 10345 | \fi\fi\fi |
| 10346 | } |
| 10347 | |
| 10348 | % Extract a byte from the end of the UTF-8 representation of \countUTFx. |
| 10349 | % It must be a non-initial byte in the sequence. |
| 10350 | % Change \uccode of #1 for it to be used in \parseUTFviiiB as one |
| 10351 | % of the bytes. |
| 10352 | \gdef\parseUTFviiiA#1{% |
| 10353 | \countUTFx = \countUTFz |
| 10354 | \divide\countUTFz by 64 |
| 10355 | \countUTFy = \countUTFz % Save to be the future value of \countUTFz. |
| 10356 | \multiply\countUTFz by 64 |
| 10357 | |
| 10358 | % \countUTFz is now \countUTFx with the last 5 bits cleared. Subtract |
| 10359 | % in order to get the last five bits. |
| 10360 | \advance\countUTFx by -\countUTFz |
| 10361 | |
| 10362 | % Convert this to the byte in the UTF-8 sequence. |
| 10363 | \advance\countUTFx by 128 |
| 10364 | \uccode `#1\countUTFx |
| 10365 | \countUTFz = \countUTFy} |
| 10366 | |
| 10367 | % Used to put a UTF-8 byte sequence into \UTFviiiTmp |
| 10368 | % #1 is the increment for \countUTFz to yield a the first byte of the UTF-8 |
| 10369 | % sequence. |
| 10370 | % #2 is one of the \UTFviii*OctetsName macros. |
| 10371 | % #3 is always a full stop (.) |
| 10372 | % #4 is a template for the other bytes in the sequence. The values for these |
| 10373 | % bytes is substituted in here with \uppercase using the \uccode's. |
| 10374 | \gdef\parseUTFviiiB#1#2#3#4{% |
| 10375 | \advance\countUTFz by "#10\relax |
| 10376 | \uccode `#3\countUTFz |
| 10377 | \uppercase{\gdef\UTFviiiTmp{#2#3#4}}} |
| 10378 | \endgroup |
| 10379 | |
| 10380 | % For native Unicode handling (XeTeX and LuaTeX), |
| 10381 | % provide a definition macro that sets a catcode to `other' non-globally |
| 10382 | % |
| 10383 | \def\DeclareUnicodeCharacterNativeOther#1#2{% |
| 10384 | \catcode"#1=\other |
| 10385 | } |
| 10386 | |
| 10387 | % https://en.wikipedia.org/wiki/Plane_(Unicode)#Basic_M |
| 10388 | % U+0000..U+007F = https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block) |
| 10389 | % U+0080..U+00FF = https://en.wikipedia.org/wiki/Latin-1_Supplement_(Unicode_block) |
| 10390 | % U+0100..U+017F = https://en.wikipedia.org/wiki/Latin_Extended-A |
| 10391 | % U+0180..U+024F = https://en.wikipedia.org/wiki/Latin_Extended-B |
| 10392 | % |
| 10393 | % Many of our renditions are less than wonderful, and all the missing |
| 10394 | % characters are available somewhere. Loading the necessary fonts |
| 10395 | % awaits user request. We can't truly support Unicode without |
| 10396 | % reimplementing everything that's been done in LaTeX for many years, |
| 10397 | % plus probably using luatex or xetex, and who knows what else. |
| 10398 | % We won't be doing that here in this simple file. But we can try to at |
| 10399 | % least make most of the characters not bomb out. |
| 10400 | % |
| 10401 | \def\unicodechardefs{% |
| 10402 | \DeclareUnicodeCharacter{00A0}{\tie}% |
| 10403 | \DeclareUnicodeCharacter{00A1}{\exclamdown}% |
| 10404 | \DeclareUnicodeCharacter{00A2}{{\tcfont \char162}}% 0242=cent |
| 10405 | \DeclareUnicodeCharacter{00A3}{\pounds{}}% |
| 10406 | \DeclareUnicodeCharacter{00A4}{{\tcfont \char164}}% 0244=currency |
| 10407 | \DeclareUnicodeCharacter{00A5}{{\tcfont \char165}}% 0245=yen |
| 10408 | \DeclareUnicodeCharacter{00A6}{{\tcfont \char166}}% 0246=brokenbar |
| 10409 | \DeclareUnicodeCharacter{00A7}{\S}% |
| 10410 | \DeclareUnicodeCharacter{00A8}{\"{ }}% |
| 10411 | \DeclareUnicodeCharacter{00A9}{\copyright{}}% |
| 10412 | \DeclareUnicodeCharacter{00AA}{\ordf}% |
| 10413 | \DeclareUnicodeCharacter{00AB}{\guillemetleft{}}% |
| 10414 | \DeclareUnicodeCharacter{00AC}{\ensuremath\lnot}% |
| 10415 | \DeclareUnicodeCharacter{00AD}{\-}% |
| 10416 | \DeclareUnicodeCharacter{00AE}{\registeredsymbol{}}% |
| 10417 | \DeclareUnicodeCharacter{00AF}{\={ }}% |
| 10418 | % |
| 10419 | \DeclareUnicodeCharacter{00B0}{\ringaccent{ }}% |
| 10420 | \DeclareUnicodeCharacter{00B1}{\ensuremath\pm}% |
| 10421 | \DeclareUnicodeCharacter{00B2}{$^2$}% |
| 10422 | \DeclareUnicodeCharacter{00B3}{$^3$}% |
| 10423 | \DeclareUnicodeCharacter{00B4}{\'{ }}% |
| 10424 | \DeclareUnicodeCharacter{00B5}{$\mu$}% |
| 10425 | \DeclareUnicodeCharacter{00B6}{\P}% |
| 10426 | \DeclareUnicodeCharacter{00B7}{\ensuremath\cdot}% |
| 10427 | \DeclareUnicodeCharacter{00B8}{\cedilla{ }}% |
| 10428 | \DeclareUnicodeCharacter{00B9}{$^1$}% |
| 10429 | \DeclareUnicodeCharacter{00BA}{\ordm}% |
| 10430 | \DeclareUnicodeCharacter{00BB}{\guillemetright{}}% |
| 10431 | \DeclareUnicodeCharacter{00BC}{$1\over4$}% |
| 10432 | \DeclareUnicodeCharacter{00BD}{$1\over2$}% |
| 10433 | \DeclareUnicodeCharacter{00BE}{$3\over4$}% |
| 10434 | \DeclareUnicodeCharacter{00BF}{\questiondown}% |
| 10435 | % |
| 10436 | \DeclareUnicodeCharacter{00C0}{\`A}% |
| 10437 | \DeclareUnicodeCharacter{00C1}{\'A}% |
| 10438 | \DeclareUnicodeCharacter{00C2}{\^A}% |
| 10439 | \DeclareUnicodeCharacter{00C3}{\~A}% |
| 10440 | \DeclareUnicodeCharacter{00C4}{\"A}% |
| 10441 | \DeclareUnicodeCharacter{00C5}{\AA}% |
| 10442 | \DeclareUnicodeCharacter{00C6}{\AE}% |
| 10443 | \DeclareUnicodeCharacter{00C7}{\cedilla{C}}% |
| 10444 | \DeclareUnicodeCharacter{00C8}{\`E}% |
| 10445 | \DeclareUnicodeCharacter{00C9}{\'E}% |
| 10446 | \DeclareUnicodeCharacter{00CA}{\^E}% |
| 10447 | \DeclareUnicodeCharacter{00CB}{\"E}% |
| 10448 | \DeclareUnicodeCharacter{00CC}{\`I}% |
| 10449 | \DeclareUnicodeCharacter{00CD}{\'I}% |
| 10450 | \DeclareUnicodeCharacter{00CE}{\^I}% |
| 10451 | \DeclareUnicodeCharacter{00CF}{\"I}% |
| 10452 | % |
| 10453 | \DeclareUnicodeCharacter{00D0}{\DH}% |
| 10454 | \DeclareUnicodeCharacter{00D1}{\~N}% |
| 10455 | \DeclareUnicodeCharacter{00D2}{\`O}% |
| 10456 | \DeclareUnicodeCharacter{00D3}{\'O}% |
| 10457 | \DeclareUnicodeCharacter{00D4}{\^O}% |
| 10458 | \DeclareUnicodeCharacter{00D5}{\~O}% |
| 10459 | \DeclareUnicodeCharacter{00D6}{\"O}% |
| 10460 | \DeclareUnicodeCharacter{00D7}{\ensuremath\times}% |
| 10461 | \DeclareUnicodeCharacter{00D8}{\O}% |
| 10462 | \DeclareUnicodeCharacter{00D9}{\`U}% |
| 10463 | \DeclareUnicodeCharacter{00DA}{\'U}% |
| 10464 | \DeclareUnicodeCharacter{00DB}{\^U}% |
| 10465 | \DeclareUnicodeCharacter{00DC}{\"U}% |
| 10466 | \DeclareUnicodeCharacter{00DD}{\'Y}% |
| 10467 | \DeclareUnicodeCharacter{00DE}{\TH}% |
| 10468 | \DeclareUnicodeCharacter{00DF}{\ss}% |
| 10469 | % |
| 10470 | \DeclareUnicodeCharacter{00E0}{\`a}% |
| 10471 | \DeclareUnicodeCharacter{00E1}{\'a}% |
| 10472 | \DeclareUnicodeCharacter{00E2}{\^a}% |
| 10473 | \DeclareUnicodeCharacter{00E3}{\~a}% |
| 10474 | \DeclareUnicodeCharacter{00E4}{\"a}% |
| 10475 | \DeclareUnicodeCharacter{00E5}{\aa}% |
| 10476 | \DeclareUnicodeCharacter{00E6}{\ae}% |
| 10477 | \DeclareUnicodeCharacter{00E7}{\cedilla{c}}% |
| 10478 | \DeclareUnicodeCharacter{00E8}{\`e}% |
| 10479 | \DeclareUnicodeCharacter{00E9}{\'e}% |
| 10480 | \DeclareUnicodeCharacter{00EA}{\^e}% |
| 10481 | \DeclareUnicodeCharacter{00EB}{\"e}% |
| 10482 | \DeclareUnicodeCharacter{00EC}{\`{\dotless{i}}}% |
| 10483 | \DeclareUnicodeCharacter{00ED}{\'{\dotless{i}}}% |
| 10484 | \DeclareUnicodeCharacter{00EE}{\^{\dotless{i}}}% |
| 10485 | \DeclareUnicodeCharacter{00EF}{\"{\dotless{i}}}% |
| 10486 | % |
| 10487 | \DeclareUnicodeCharacter{00F0}{\dh}% |
| 10488 | \DeclareUnicodeCharacter{00F1}{\~n}% |
| 10489 | \DeclareUnicodeCharacter{00F2}{\`o}% |
| 10490 | \DeclareUnicodeCharacter{00F3}{\'o}% |
| 10491 | \DeclareUnicodeCharacter{00F4}{\^o}% |
| 10492 | \DeclareUnicodeCharacter{00F5}{\~o}% |
| 10493 | \DeclareUnicodeCharacter{00F6}{\"o}% |
| 10494 | \DeclareUnicodeCharacter{00F7}{\ensuremath\div}% |
| 10495 | \DeclareUnicodeCharacter{00F8}{\o}% |
| 10496 | \DeclareUnicodeCharacter{00F9}{\`u}% |
| 10497 | \DeclareUnicodeCharacter{00FA}{\'u}% |
| 10498 | \DeclareUnicodeCharacter{00FB}{\^u}% |
| 10499 | \DeclareUnicodeCharacter{00FC}{\"u}% |
| 10500 | \DeclareUnicodeCharacter{00FD}{\'y}% |
| 10501 | \DeclareUnicodeCharacter{00FE}{\th}% |
| 10502 | \DeclareUnicodeCharacter{00FF}{\"y}% |
| 10503 | % |
| 10504 | \DeclareUnicodeCharacter{0100}{\=A}% |
| 10505 | \DeclareUnicodeCharacter{0101}{\=a}% |
| 10506 | \DeclareUnicodeCharacter{0102}{\u{A}}% |
| 10507 | \DeclareUnicodeCharacter{0103}{\u{a}}% |
| 10508 | \DeclareUnicodeCharacter{0104}{\ogonek{A}}% |
| 10509 | \DeclareUnicodeCharacter{0105}{\ogonek{a}}% |
| 10510 | \DeclareUnicodeCharacter{0106}{\'C}% |
| 10511 | \DeclareUnicodeCharacter{0107}{\'c}% |
| 10512 | \DeclareUnicodeCharacter{0108}{\^C}% |
| 10513 | \DeclareUnicodeCharacter{0109}{\^c}% |
| 10514 | \DeclareUnicodeCharacter{010A}{\dotaccent{C}}% |
| 10515 | \DeclareUnicodeCharacter{010B}{\dotaccent{c}}% |
| 10516 | \DeclareUnicodeCharacter{010C}{\v{C}}% |
| 10517 | \DeclareUnicodeCharacter{010D}{\v{c}}% |
| 10518 | \DeclareUnicodeCharacter{010E}{\v{D}}% |
| 10519 | \DeclareUnicodeCharacter{010F}{d'}% |
| 10520 | % |
| 10521 | \DeclareUnicodeCharacter{0110}{\DH}% |
| 10522 | \DeclareUnicodeCharacter{0111}{\dh}% |
| 10523 | \DeclareUnicodeCharacter{0112}{\=E}% |
| 10524 | \DeclareUnicodeCharacter{0113}{\=e}% |
| 10525 | \DeclareUnicodeCharacter{0114}{\u{E}}% |
| 10526 | \DeclareUnicodeCharacter{0115}{\u{e}}% |
| 10527 | \DeclareUnicodeCharacter{0116}{\dotaccent{E}}% |
| 10528 | \DeclareUnicodeCharacter{0117}{\dotaccent{e}}% |
| 10529 | \DeclareUnicodeCharacter{0118}{\ogonek{E}}% |
| 10530 | \DeclareUnicodeCharacter{0119}{\ogonek{e}}% |
| 10531 | \DeclareUnicodeCharacter{011A}{\v{E}}% |
| 10532 | \DeclareUnicodeCharacter{011B}{\v{e}}% |
| 10533 | \DeclareUnicodeCharacter{011C}{\^G}% |
| 10534 | \DeclareUnicodeCharacter{011D}{\^g}% |
| 10535 | \DeclareUnicodeCharacter{011E}{\u{G}}% |
| 10536 | \DeclareUnicodeCharacter{011F}{\u{g}}% |
| 10537 | % |
| 10538 | \DeclareUnicodeCharacter{0120}{\dotaccent{G}}% |
| 10539 | \DeclareUnicodeCharacter{0121}{\dotaccent{g}}% |
| 10540 | \DeclareUnicodeCharacter{0122}{\cedilla{G}}% |
| 10541 | \DeclareUnicodeCharacter{0123}{\cedilla{g}}% |
| 10542 | \DeclareUnicodeCharacter{0124}{\^H}% |
| 10543 | \DeclareUnicodeCharacter{0125}{\^h}% |
| 10544 | \DeclareUnicodeCharacter{0126}{\missingcharmsg{H WITH STROKE}}% |
| 10545 | \DeclareUnicodeCharacter{0127}{\missingcharmsg{h WITH STROKE}}% |
| 10546 | \DeclareUnicodeCharacter{0128}{\~I}% |
| 10547 | \DeclareUnicodeCharacter{0129}{\~{\dotless{i}}}% |
| 10548 | \DeclareUnicodeCharacter{012A}{\=I}% |
| 10549 | \DeclareUnicodeCharacter{012B}{\={\dotless{i}}}% |
| 10550 | \DeclareUnicodeCharacter{012C}{\u{I}}% |
| 10551 | \DeclareUnicodeCharacter{012D}{\u{\dotless{i}}}% |
| 10552 | \DeclareUnicodeCharacter{012E}{\ogonek{I}}% |
| 10553 | \DeclareUnicodeCharacter{012F}{\ogonek{i}}% |
| 10554 | % |
| 10555 | \DeclareUnicodeCharacter{0130}{\dotaccent{I}}% |
| 10556 | \DeclareUnicodeCharacter{0131}{\dotless{i}}% |
| 10557 | \DeclareUnicodeCharacter{0132}{IJ}% |
| 10558 | \DeclareUnicodeCharacter{0133}{ij}% |
| 10559 | \DeclareUnicodeCharacter{0134}{\^J}% |
| 10560 | \DeclareUnicodeCharacter{0135}{\^{\dotless{j}}}% |
| 10561 | \DeclareUnicodeCharacter{0136}{\cedilla{K}}% |
| 10562 | \DeclareUnicodeCharacter{0137}{\cedilla{k}}% |
| 10563 | \DeclareUnicodeCharacter{0138}{\ensuremath\kappa}% |
| 10564 | \DeclareUnicodeCharacter{0139}{\'L}% |
| 10565 | \DeclareUnicodeCharacter{013A}{\'l}% |
| 10566 | \DeclareUnicodeCharacter{013B}{\cedilla{L}}% |
| 10567 | \DeclareUnicodeCharacter{013C}{\cedilla{l}}% |
| 10568 | \DeclareUnicodeCharacter{013D}{L'}% should kern |
| 10569 | \DeclareUnicodeCharacter{013E}{l'}% should kern |
| 10570 | \DeclareUnicodeCharacter{013F}{L\U{00B7}}% |
| 10571 | % |
| 10572 | \DeclareUnicodeCharacter{0140}{l\U{00B7}}% |
| 10573 | \DeclareUnicodeCharacter{0141}{\L}% |
| 10574 | \DeclareUnicodeCharacter{0142}{\l}% |
| 10575 | \DeclareUnicodeCharacter{0143}{\'N}% |
| 10576 | \DeclareUnicodeCharacter{0144}{\'n}% |
| 10577 | \DeclareUnicodeCharacter{0145}{\cedilla{N}}% |
| 10578 | \DeclareUnicodeCharacter{0146}{\cedilla{n}}% |
| 10579 | \DeclareUnicodeCharacter{0147}{\v{N}}% |
| 10580 | \DeclareUnicodeCharacter{0148}{\v{n}}% |
| 10581 | \DeclareUnicodeCharacter{0149}{'n}% |
| 10582 | \DeclareUnicodeCharacter{014A}{\missingcharmsg{ENG}}% |
| 10583 | \DeclareUnicodeCharacter{014B}{\missingcharmsg{eng}}% |
| 10584 | \DeclareUnicodeCharacter{014C}{\=O}% |
| 10585 | \DeclareUnicodeCharacter{014D}{\=o}% |
| 10586 | \DeclareUnicodeCharacter{014E}{\u{O}}% |
| 10587 | \DeclareUnicodeCharacter{014F}{\u{o}}% |
| 10588 | % |
| 10589 | \DeclareUnicodeCharacter{0150}{\H{O}}% |
| 10590 | \DeclareUnicodeCharacter{0151}{\H{o}}% |
| 10591 | \DeclareUnicodeCharacter{0152}{\OE}% |
| 10592 | \DeclareUnicodeCharacter{0153}{\oe}% |
| 10593 | \DeclareUnicodeCharacter{0154}{\'R}% |
| 10594 | \DeclareUnicodeCharacter{0155}{\'r}% |
| 10595 | \DeclareUnicodeCharacter{0156}{\cedilla{R}}% |
| 10596 | \DeclareUnicodeCharacter{0157}{\cedilla{r}}% |
| 10597 | \DeclareUnicodeCharacter{0158}{\v{R}}% |
| 10598 | \DeclareUnicodeCharacter{0159}{\v{r}}% |
| 10599 | \DeclareUnicodeCharacter{015A}{\'S}% |
| 10600 | \DeclareUnicodeCharacter{015B}{\'s}% |
| 10601 | \DeclareUnicodeCharacter{015C}{\^S}% |
| 10602 | \DeclareUnicodeCharacter{015D}{\^s}% |
| 10603 | \DeclareUnicodeCharacter{015E}{\cedilla{S}}% |
| 10604 | \DeclareUnicodeCharacter{015F}{\cedilla{s}}% |
| 10605 | % |
| 10606 | \DeclareUnicodeCharacter{0160}{\v{S}}% |
| 10607 | \DeclareUnicodeCharacter{0161}{\v{s}}% |
| 10608 | \DeclareUnicodeCharacter{0162}{\cedilla{T}}% |
| 10609 | \DeclareUnicodeCharacter{0163}{\cedilla{t}}% |
| 10610 | \DeclareUnicodeCharacter{0164}{\v{T}}% |
| 10611 | \DeclareUnicodeCharacter{0165}{\v{t}}% |
| 10612 | \DeclareUnicodeCharacter{0166}{\missingcharmsg{H WITH STROKE}}% |
| 10613 | \DeclareUnicodeCharacter{0167}{\missingcharmsg{h WITH STROKE}}% |
| 10614 | \DeclareUnicodeCharacter{0168}{\~U}% |
| 10615 | \DeclareUnicodeCharacter{0169}{\~u}% |
| 10616 | \DeclareUnicodeCharacter{016A}{\=U}% |
| 10617 | \DeclareUnicodeCharacter{016B}{\=u}% |
| 10618 | \DeclareUnicodeCharacter{016C}{\u{U}}% |
| 10619 | \DeclareUnicodeCharacter{016D}{\u{u}}% |
| 10620 | \DeclareUnicodeCharacter{016E}{\ringaccent{U}}% |
| 10621 | \DeclareUnicodeCharacter{016F}{\ringaccent{u}}% |
| 10622 | % |
| 10623 | \DeclareUnicodeCharacter{0170}{\H{U}}% |
| 10624 | \DeclareUnicodeCharacter{0171}{\H{u}}% |
| 10625 | \DeclareUnicodeCharacter{0172}{\ogonek{U}}% |
| 10626 | \DeclareUnicodeCharacter{0173}{\ogonek{u}}% |
| 10627 | \DeclareUnicodeCharacter{0174}{\^W}% |
| 10628 | \DeclareUnicodeCharacter{0175}{\^w}% |
| 10629 | \DeclareUnicodeCharacter{0176}{\^Y}% |
| 10630 | \DeclareUnicodeCharacter{0177}{\^y}% |
| 10631 | \DeclareUnicodeCharacter{0178}{\"Y}% |
| 10632 | \DeclareUnicodeCharacter{0179}{\'Z}% |
| 10633 | \DeclareUnicodeCharacter{017A}{\'z}% |
| 10634 | \DeclareUnicodeCharacter{017B}{\dotaccent{Z}}% |
| 10635 | \DeclareUnicodeCharacter{017C}{\dotaccent{z}}% |
| 10636 | \DeclareUnicodeCharacter{017D}{\v{Z}}% |
| 10637 | \DeclareUnicodeCharacter{017E}{\v{z}}% |
| 10638 | \DeclareUnicodeCharacter{017F}{\missingcharmsg{LONG S}}% |
| 10639 | % |
| 10640 | \DeclareUnicodeCharacter{01C4}{D\v{Z}}% |
| 10641 | \DeclareUnicodeCharacter{01C5}{D\v{z}}% |
| 10642 | \DeclareUnicodeCharacter{01C6}{d\v{z}}% |
| 10643 | \DeclareUnicodeCharacter{01C7}{LJ}% |
| 10644 | \DeclareUnicodeCharacter{01C8}{Lj}% |
| 10645 | \DeclareUnicodeCharacter{01C9}{lj}% |
| 10646 | \DeclareUnicodeCharacter{01CA}{NJ}% |
| 10647 | \DeclareUnicodeCharacter{01CB}{Nj}% |
| 10648 | \DeclareUnicodeCharacter{01CC}{nj}% |
| 10649 | \DeclareUnicodeCharacter{01CD}{\v{A}}% |
| 10650 | \DeclareUnicodeCharacter{01CE}{\v{a}}% |
| 10651 | \DeclareUnicodeCharacter{01CF}{\v{I}}% |
| 10652 | % |
| 10653 | \DeclareUnicodeCharacter{01D0}{\v{\dotless{i}}}% |
| 10654 | \DeclareUnicodeCharacter{01D1}{\v{O}}% |
| 10655 | \DeclareUnicodeCharacter{01D2}{\v{o}}% |
| 10656 | \DeclareUnicodeCharacter{01D3}{\v{U}}% |
| 10657 | \DeclareUnicodeCharacter{01D4}{\v{u}}% |
| 10658 | % |
| 10659 | \DeclareUnicodeCharacter{01E2}{\={\AE}}% |
| 10660 | \DeclareUnicodeCharacter{01E3}{\={\ae}}% |
| 10661 | \DeclareUnicodeCharacter{01E6}{\v{G}}% |
| 10662 | \DeclareUnicodeCharacter{01E7}{\v{g}}% |
| 10663 | \DeclareUnicodeCharacter{01E8}{\v{K}}% |
| 10664 | \DeclareUnicodeCharacter{01E9}{\v{k}}% |
| 10665 | % |
| 10666 | \DeclareUnicodeCharacter{01F0}{\v{\dotless{j}}}% |
| 10667 | \DeclareUnicodeCharacter{01F1}{DZ}% |
| 10668 | \DeclareUnicodeCharacter{01F2}{Dz}% |
| 10669 | \DeclareUnicodeCharacter{01F3}{dz}% |
| 10670 | \DeclareUnicodeCharacter{01F4}{\'G}% |
| 10671 | \DeclareUnicodeCharacter{01F5}{\'g}% |
| 10672 | \DeclareUnicodeCharacter{01F8}{\`N}% |
| 10673 | \DeclareUnicodeCharacter{01F9}{\`n}% |
| 10674 | \DeclareUnicodeCharacter{01FC}{\'{\AE}}% |
| 10675 | \DeclareUnicodeCharacter{01FD}{\'{\ae}}% |
| 10676 | \DeclareUnicodeCharacter{01FE}{\'{\O}}% |
| 10677 | \DeclareUnicodeCharacter{01FF}{\'{\o}}% |
| 10678 | % |
| 10679 | \DeclareUnicodeCharacter{021E}{\v{H}}% |
| 10680 | \DeclareUnicodeCharacter{021F}{\v{h}}% |
| 10681 | % |
| 10682 | \DeclareUnicodeCharacter{0226}{\dotaccent{A}}% |
| 10683 | \DeclareUnicodeCharacter{0227}{\dotaccent{a}}% |
| 10684 | \DeclareUnicodeCharacter{0228}{\cedilla{E}}% |
| 10685 | \DeclareUnicodeCharacter{0229}{\cedilla{e}}% |
| 10686 | \DeclareUnicodeCharacter{022E}{\dotaccent{O}}% |
| 10687 | \DeclareUnicodeCharacter{022F}{\dotaccent{o}}% |
| 10688 | % |
| 10689 | \DeclareUnicodeCharacter{0232}{\=Y}% |
| 10690 | \DeclareUnicodeCharacter{0233}{\=y}% |
| 10691 | \DeclareUnicodeCharacter{0237}{\dotless{j}}% |
| 10692 | % |
| 10693 | \DeclareUnicodeCharacter{02BC}{'}% |
| 10694 | % |
| 10695 | \DeclareUnicodeCharacter{02DB}{\ogonek{ }}% |
| 10696 | % |
| 10697 | % Greek letters upper case |
| 10698 | \DeclareUnicodeCharacter{0391}{{\it A}}% |
| 10699 | \DeclareUnicodeCharacter{0392}{{\it B}}% |
| 10700 | \DeclareUnicodeCharacter{0393}{\ensuremath{\mit\Gamma}}% |
| 10701 | \DeclareUnicodeCharacter{0394}{\ensuremath{\mit\Delta}}% |
| 10702 | \DeclareUnicodeCharacter{0395}{{\it E}}% |
| 10703 | \DeclareUnicodeCharacter{0396}{{\it Z}}% |
| 10704 | \DeclareUnicodeCharacter{0397}{{\it H}}% |
| 10705 | \DeclareUnicodeCharacter{0398}{\ensuremath{\mit\Theta}}% |
| 10706 | \DeclareUnicodeCharacter{0399}{{\it I}}% |
| 10707 | \DeclareUnicodeCharacter{039A}{{\it K}}% |
| 10708 | \DeclareUnicodeCharacter{039B}{\ensuremath{\mit\Lambda}}% |
| 10709 | \DeclareUnicodeCharacter{039C}{{\it M}}% |
| 10710 | \DeclareUnicodeCharacter{039D}{{\it N}}% |
| 10711 | \DeclareUnicodeCharacter{039E}{\ensuremath{\mit\Xi}}% |
| 10712 | \DeclareUnicodeCharacter{039F}{{\it O}}% |
| 10713 | \DeclareUnicodeCharacter{03A0}{\ensuremath{\mit\Pi}}% |
| 10714 | \DeclareUnicodeCharacter{03A1}{{\it P}}% |
| 10715 | %\DeclareUnicodeCharacter{03A2}{} % none - corresponds to final sigma |
| 10716 | \DeclareUnicodeCharacter{03A3}{\ensuremath{\mit\Sigma}}% |
| 10717 | \DeclareUnicodeCharacter{03A4}{{\it T}}% |
| 10718 | \DeclareUnicodeCharacter{03A5}{\ensuremath{\mit\Upsilon}}% |
| 10719 | \DeclareUnicodeCharacter{03A6}{\ensuremath{\mit\Phi}}% |
| 10720 | \DeclareUnicodeCharacter{03A7}{{\it X}}% |
| 10721 | \DeclareUnicodeCharacter{03A8}{\ensuremath{\mit\Psi}}% |
| 10722 | \DeclareUnicodeCharacter{03A9}{\ensuremath{\mit\Omega}}% |
| 10723 | % |
| 10724 | % Vowels with accents |
| 10725 | \DeclareUnicodeCharacter{0390}{\ensuremath{\ddot{\acute\iota}}}% |
| 10726 | \DeclareUnicodeCharacter{03AC}{\ensuremath{\acute\alpha}}% |
| 10727 | \DeclareUnicodeCharacter{03AD}{\ensuremath{\acute\epsilon}}% |
| 10728 | \DeclareUnicodeCharacter{03AE}{\ensuremath{\acute\eta}}% |
| 10729 | \DeclareUnicodeCharacter{03AF}{\ensuremath{\acute\iota}}% |
| 10730 | \DeclareUnicodeCharacter{03B0}{\ensuremath{\acute{\ddot\upsilon}}}% |
| 10731 | % |
| 10732 | % Standalone accent |
| 10733 | \DeclareUnicodeCharacter{0384}{\ensuremath{\acute{\ }}}% |
| 10734 | % |
| 10735 | % Greek letters lower case |
| 10736 | \DeclareUnicodeCharacter{03B1}{\ensuremath\alpha}% |
| 10737 | \DeclareUnicodeCharacter{03B2}{\ensuremath\beta}% |
| 10738 | \DeclareUnicodeCharacter{03B3}{\ensuremath\gamma}% |
| 10739 | \DeclareUnicodeCharacter{03B4}{\ensuremath\delta}% |
| 10740 | \DeclareUnicodeCharacter{03B5}{\ensuremath\epsilon}% |
| 10741 | \DeclareUnicodeCharacter{03B6}{\ensuremath\zeta}% |
| 10742 | \DeclareUnicodeCharacter{03B7}{\ensuremath\eta}% |
| 10743 | \DeclareUnicodeCharacter{03B8}{\ensuremath\theta}% |
| 10744 | \DeclareUnicodeCharacter{03B9}{\ensuremath\iota}% |
| 10745 | \DeclareUnicodeCharacter{03BA}{\ensuremath\kappa}% |
| 10746 | \DeclareUnicodeCharacter{03BB}{\ensuremath\lambda}% |
| 10747 | \DeclareUnicodeCharacter{03BC}{\ensuremath\mu}% |
| 10748 | \DeclareUnicodeCharacter{03BD}{\ensuremath\nu}% |
| 10749 | \DeclareUnicodeCharacter{03BE}{\ensuremath\xi}% |
| 10750 | \DeclareUnicodeCharacter{03BF}{{\it o}}% omicron |
| 10751 | \DeclareUnicodeCharacter{03C0}{\ensuremath\pi}% |
| 10752 | \DeclareUnicodeCharacter{03C1}{\ensuremath\rho}% |
| 10753 | \DeclareUnicodeCharacter{03C2}{\ensuremath\varsigma}% |
| 10754 | \DeclareUnicodeCharacter{03C3}{\ensuremath\sigma}% |
| 10755 | \DeclareUnicodeCharacter{03C4}{\ensuremath\tau}% |
| 10756 | \DeclareUnicodeCharacter{03C5}{\ensuremath\upsilon}% |
| 10757 | \DeclareUnicodeCharacter{03C6}{\ensuremath\phi}% |
| 10758 | \DeclareUnicodeCharacter{03C7}{\ensuremath\chi}% |
| 10759 | \DeclareUnicodeCharacter{03C8}{\ensuremath\psi}% |
| 10760 | \DeclareUnicodeCharacter{03C9}{\ensuremath\omega}% |
| 10761 | % |
| 10762 | % More Greek vowels with accents |
| 10763 | \DeclareUnicodeCharacter{03CA}{\ensuremath{\ddot\iota}}% |
| 10764 | \DeclareUnicodeCharacter{03CB}{\ensuremath{\ddot\upsilon}}% |
| 10765 | \DeclareUnicodeCharacter{03CC}{\ensuremath{\acute o}}% |
| 10766 | \DeclareUnicodeCharacter{03CD}{\ensuremath{\acute\upsilon}}% |
| 10767 | \DeclareUnicodeCharacter{03CE}{\ensuremath{\acute\omega}}% |
| 10768 | % |
| 10769 | % Variant Greek letters |
| 10770 | \DeclareUnicodeCharacter{03D1}{\ensuremath\vartheta}% |
| 10771 | \DeclareUnicodeCharacter{03D6}{\ensuremath\varpi}% |
| 10772 | \DeclareUnicodeCharacter{03F1}{\ensuremath\varrho}% |
| 10773 | % |
| 10774 | \DeclareUnicodeCharacter{1E02}{\dotaccent{B}}% |
| 10775 | \DeclareUnicodeCharacter{1E03}{\dotaccent{b}}% |
| 10776 | \DeclareUnicodeCharacter{1E04}{\udotaccent{B}}% |
| 10777 | \DeclareUnicodeCharacter{1E05}{\udotaccent{b}}% |
| 10778 | \DeclareUnicodeCharacter{1E06}{\ubaraccent{B}}% |
| 10779 | \DeclareUnicodeCharacter{1E07}{\ubaraccent{b}}% |
| 10780 | \DeclareUnicodeCharacter{1E0A}{\dotaccent{D}}% |
| 10781 | \DeclareUnicodeCharacter{1E0B}{\dotaccent{d}}% |
| 10782 | \DeclareUnicodeCharacter{1E0C}{\udotaccent{D}}% |
| 10783 | \DeclareUnicodeCharacter{1E0D}{\udotaccent{d}}% |
| 10784 | \DeclareUnicodeCharacter{1E0E}{\ubaraccent{D}}% |
| 10785 | \DeclareUnicodeCharacter{1E0F}{\ubaraccent{d}}% |
| 10786 | % |
| 10787 | \DeclareUnicodeCharacter{1E1E}{\dotaccent{F}}% |
| 10788 | \DeclareUnicodeCharacter{1E1F}{\dotaccent{f}}% |
| 10789 | % |
| 10790 | \DeclareUnicodeCharacter{1E20}{\=G}% |
| 10791 | \DeclareUnicodeCharacter{1E21}{\=g}% |
| 10792 | \DeclareUnicodeCharacter{1E22}{\dotaccent{H}}% |
| 10793 | \DeclareUnicodeCharacter{1E23}{\dotaccent{h}}% |
| 10794 | \DeclareUnicodeCharacter{1E24}{\udotaccent{H}}% |
| 10795 | \DeclareUnicodeCharacter{1E25}{\udotaccent{h}}% |
| 10796 | \DeclareUnicodeCharacter{1E26}{\"H}% |
| 10797 | \DeclareUnicodeCharacter{1E27}{\"h}% |
| 10798 | % |
| 10799 | \DeclareUnicodeCharacter{1E30}{\'K}% |
| 10800 | \DeclareUnicodeCharacter{1E31}{\'k}% |
| 10801 | \DeclareUnicodeCharacter{1E32}{\udotaccent{K}}% |
| 10802 | \DeclareUnicodeCharacter{1E33}{\udotaccent{k}}% |
| 10803 | \DeclareUnicodeCharacter{1E34}{\ubaraccent{K}}% |
| 10804 | \DeclareUnicodeCharacter{1E35}{\ubaraccent{k}}% |
| 10805 | \DeclareUnicodeCharacter{1E36}{\udotaccent{L}}% |
| 10806 | \DeclareUnicodeCharacter{1E37}{\udotaccent{l}}% |
| 10807 | \DeclareUnicodeCharacter{1E3A}{\ubaraccent{L}}% |
| 10808 | \DeclareUnicodeCharacter{1E3B}{\ubaraccent{l}}% |
| 10809 | \DeclareUnicodeCharacter{1E3E}{\'M}% |
| 10810 | \DeclareUnicodeCharacter{1E3F}{\'m}% |
| 10811 | % |
| 10812 | \DeclareUnicodeCharacter{1E40}{\dotaccent{M}}% |
| 10813 | \DeclareUnicodeCharacter{1E41}{\dotaccent{m}}% |
| 10814 | \DeclareUnicodeCharacter{1E42}{\udotaccent{M}}% |
| 10815 | \DeclareUnicodeCharacter{1E43}{\udotaccent{m}}% |
| 10816 | \DeclareUnicodeCharacter{1E44}{\dotaccent{N}}% |
| 10817 | \DeclareUnicodeCharacter{1E45}{\dotaccent{n}}% |
| 10818 | \DeclareUnicodeCharacter{1E46}{\udotaccent{N}}% |
| 10819 | \DeclareUnicodeCharacter{1E47}{\udotaccent{n}}% |
| 10820 | \DeclareUnicodeCharacter{1E48}{\ubaraccent{N}}% |
| 10821 | \DeclareUnicodeCharacter{1E49}{\ubaraccent{n}}% |
| 10822 | % |
| 10823 | \DeclareUnicodeCharacter{1E54}{\'P}% |
| 10824 | \DeclareUnicodeCharacter{1E55}{\'p}% |
| 10825 | \DeclareUnicodeCharacter{1E56}{\dotaccent{P}}% |
| 10826 | \DeclareUnicodeCharacter{1E57}{\dotaccent{p}}% |
| 10827 | \DeclareUnicodeCharacter{1E58}{\dotaccent{R}}% |
| 10828 | \DeclareUnicodeCharacter{1E59}{\dotaccent{r}}% |
| 10829 | \DeclareUnicodeCharacter{1E5A}{\udotaccent{R}}% |
| 10830 | \DeclareUnicodeCharacter{1E5B}{\udotaccent{r}}% |
| 10831 | \DeclareUnicodeCharacter{1E5E}{\ubaraccent{R}}% |
| 10832 | \DeclareUnicodeCharacter{1E5F}{\ubaraccent{r}}% |
| 10833 | % |
| 10834 | \DeclareUnicodeCharacter{1E60}{\dotaccent{S}}% |
| 10835 | \DeclareUnicodeCharacter{1E61}{\dotaccent{s}}% |
| 10836 | \DeclareUnicodeCharacter{1E62}{\udotaccent{S}}% |
| 10837 | \DeclareUnicodeCharacter{1E63}{\udotaccent{s}}% |
| 10838 | \DeclareUnicodeCharacter{1E6A}{\dotaccent{T}}% |
| 10839 | \DeclareUnicodeCharacter{1E6B}{\dotaccent{t}}% |
| 10840 | \DeclareUnicodeCharacter{1E6C}{\udotaccent{T}}% |
| 10841 | \DeclareUnicodeCharacter{1E6D}{\udotaccent{t}}% |
| 10842 | \DeclareUnicodeCharacter{1E6E}{\ubaraccent{T}}% |
| 10843 | \DeclareUnicodeCharacter{1E6F}{\ubaraccent{t}}% |
| 10844 | % |
| 10845 | \DeclareUnicodeCharacter{1E7C}{\~V}% |
| 10846 | \DeclareUnicodeCharacter{1E7D}{\~v}% |
| 10847 | \DeclareUnicodeCharacter{1E7E}{\udotaccent{V}}% |
| 10848 | \DeclareUnicodeCharacter{1E7F}{\udotaccent{v}}% |
| 10849 | % |
| 10850 | \DeclareUnicodeCharacter{1E80}{\`W}% |
| 10851 | \DeclareUnicodeCharacter{1E81}{\`w}% |
| 10852 | \DeclareUnicodeCharacter{1E82}{\'W}% |
| 10853 | \DeclareUnicodeCharacter{1E83}{\'w}% |
| 10854 | \DeclareUnicodeCharacter{1E84}{\"W}% |
| 10855 | \DeclareUnicodeCharacter{1E85}{\"w}% |
| 10856 | \DeclareUnicodeCharacter{1E86}{\dotaccent{W}}% |
| 10857 | \DeclareUnicodeCharacter{1E87}{\dotaccent{w}}% |
| 10858 | \DeclareUnicodeCharacter{1E88}{\udotaccent{W}}% |
| 10859 | \DeclareUnicodeCharacter{1E89}{\udotaccent{w}}% |
| 10860 | \DeclareUnicodeCharacter{1E8A}{\dotaccent{X}}% |
| 10861 | \DeclareUnicodeCharacter{1E8B}{\dotaccent{x}}% |
| 10862 | \DeclareUnicodeCharacter{1E8C}{\"X}% |
| 10863 | \DeclareUnicodeCharacter{1E8D}{\"x}% |
| 10864 | \DeclareUnicodeCharacter{1E8E}{\dotaccent{Y}}% |
| 10865 | \DeclareUnicodeCharacter{1E8F}{\dotaccent{y}}% |
| 10866 | % |
| 10867 | \DeclareUnicodeCharacter{1E90}{\^Z}% |
| 10868 | \DeclareUnicodeCharacter{1E91}{\^z}% |
| 10869 | \DeclareUnicodeCharacter{1E92}{\udotaccent{Z}}% |
| 10870 | \DeclareUnicodeCharacter{1E93}{\udotaccent{z}}% |
| 10871 | \DeclareUnicodeCharacter{1E94}{\ubaraccent{Z}}% |
| 10872 | \DeclareUnicodeCharacter{1E95}{\ubaraccent{z}}% |
| 10873 | \DeclareUnicodeCharacter{1E96}{\ubaraccent{h}}% |
| 10874 | \DeclareUnicodeCharacter{1E97}{\"t}% |
| 10875 | \DeclareUnicodeCharacter{1E98}{\ringaccent{w}}% |
| 10876 | \DeclareUnicodeCharacter{1E99}{\ringaccent{y}}% |
| 10877 | % |
| 10878 | \DeclareUnicodeCharacter{1EA0}{\udotaccent{A}}% |
| 10879 | \DeclareUnicodeCharacter{1EA1}{\udotaccent{a}}% |
| 10880 | % |
| 10881 | \DeclareUnicodeCharacter{1EB8}{\udotaccent{E}}% |
| 10882 | \DeclareUnicodeCharacter{1EB9}{\udotaccent{e}}% |
| 10883 | \DeclareUnicodeCharacter{1EBC}{\~E}% |
| 10884 | \DeclareUnicodeCharacter{1EBD}{\~e}% |
| 10885 | % |
| 10886 | \DeclareUnicodeCharacter{1ECA}{\udotaccent{I}}% |
| 10887 | \DeclareUnicodeCharacter{1ECB}{\udotaccent{i}}% |
| 10888 | \DeclareUnicodeCharacter{1ECC}{\udotaccent{O}}% |
| 10889 | \DeclareUnicodeCharacter{1ECD}{\udotaccent{o}}% |
| 10890 | % |
| 10891 | \DeclareUnicodeCharacter{1EE4}{\udotaccent{U}}% |
| 10892 | \DeclareUnicodeCharacter{1EE5}{\udotaccent{u}}% |
| 10893 | % |
| 10894 | \DeclareUnicodeCharacter{1EF2}{\`Y}% |
| 10895 | \DeclareUnicodeCharacter{1EF3}{\`y}% |
| 10896 | \DeclareUnicodeCharacter{1EF4}{\udotaccent{Y}}% |
| 10897 | % |
| 10898 | \DeclareUnicodeCharacter{1EF8}{\~Y}% |
| 10899 | \DeclareUnicodeCharacter{1EF9}{\~y}% |
| 10900 | % |
| 10901 | % Punctuation |
| 10902 | \DeclareUnicodeCharacter{2013}{--}% |
| 10903 | \DeclareUnicodeCharacter{2014}{---}% |
| 10904 | \DeclareUnicodeCharacter{2018}{\quoteleft{}}% |
| 10905 | \DeclareUnicodeCharacter{2019}{\quoteright{}}% |
| 10906 | \DeclareUnicodeCharacter{201A}{\quotesinglbase{}}% |
| 10907 | \DeclareUnicodeCharacter{201C}{\quotedblleft{}}% |
| 10908 | \DeclareUnicodeCharacter{201D}{\quotedblright{}}% |
| 10909 | \DeclareUnicodeCharacter{201E}{\quotedblbase{}}% |
| 10910 | \DeclareUnicodeCharacter{2020}{\ensuremath\dagger}% |
| 10911 | \DeclareUnicodeCharacter{2021}{\ensuremath\ddagger}% |
| 10912 | \DeclareUnicodeCharacter{2022}{\bullet{}}% |
| 10913 | \DeclareUnicodeCharacter{202F}{\thinspace}% |
| 10914 | \DeclareUnicodeCharacter{2026}{\dots{}}% |
| 10915 | \DeclareUnicodeCharacter{2039}{\guilsinglleft{}}% |
| 10916 | \DeclareUnicodeCharacter{203A}{\guilsinglright{}}% |
| 10917 | % |
| 10918 | \DeclareUnicodeCharacter{20AC}{\euro{}}% |
| 10919 | % |
| 10920 | \DeclareUnicodeCharacter{2192}{\expansion{}}% |
| 10921 | \DeclareUnicodeCharacter{21D2}{\result{}}% |
| 10922 | % |
| 10923 | % Mathematical symbols |
| 10924 | \DeclareUnicodeCharacter{2200}{\ensuremath\forall}% |
| 10925 | \DeclareUnicodeCharacter{2203}{\ensuremath\exists}% |
| 10926 | \DeclareUnicodeCharacter{2208}{\ensuremath\in}% |
| 10927 | \DeclareUnicodeCharacter{2212}{\minus{}}% |
| 10928 | \DeclareUnicodeCharacter{2217}{\ast}% |
| 10929 | \DeclareUnicodeCharacter{221E}{\ensuremath\infty}% |
| 10930 | \DeclareUnicodeCharacter{2225}{\ensuremath\parallel}% |
| 10931 | \DeclareUnicodeCharacter{2227}{\ensuremath\wedge}% |
| 10932 | \DeclareUnicodeCharacter{2229}{\ensuremath\cap}% |
| 10933 | \DeclareUnicodeCharacter{2261}{\equiv{}}% |
| 10934 | \DeclareUnicodeCharacter{2264}{\ensuremath\leq}% |
| 10935 | \DeclareUnicodeCharacter{2265}{\ensuremath\geq}% |
| 10936 | \DeclareUnicodeCharacter{2282}{\ensuremath\subset}% |
| 10937 | \DeclareUnicodeCharacter{2287}{\ensuremath\supseteq}% |
| 10938 | % |
| 10939 | \DeclareUnicodeCharacter{2016}{\ensuremath\Vert}% |
| 10940 | \DeclareUnicodeCharacter{2032}{\ensuremath\prime}% |
| 10941 | \DeclareUnicodeCharacter{210F}{\ensuremath\hbar}% |
| 10942 | \DeclareUnicodeCharacter{2111}{\ensuremath\Im}% |
| 10943 | \DeclareUnicodeCharacter{2113}{\ensuremath\ell}% |
| 10944 | \DeclareUnicodeCharacter{2118}{\ensuremath\wp}% |
| 10945 | \DeclareUnicodeCharacter{211C}{\ensuremath\Re}% |
| 10946 | \DeclareUnicodeCharacter{2135}{\ensuremath\aleph}% |
| 10947 | \DeclareUnicodeCharacter{2190}{\ensuremath\leftarrow}% |
| 10948 | \DeclareUnicodeCharacter{2191}{\ensuremath\uparrow}% |
| 10949 | \DeclareUnicodeCharacter{2193}{\ensuremath\downarrow}% |
| 10950 | \DeclareUnicodeCharacter{2194}{\ensuremath\leftrightarrow}% |
| 10951 | \DeclareUnicodeCharacter{2195}{\ensuremath\updownarrow}% |
| 10952 | \DeclareUnicodeCharacter{2196}{\ensuremath\nwarrow}% |
| 10953 | \DeclareUnicodeCharacter{2197}{\ensuremath\nearrow}% |
| 10954 | \DeclareUnicodeCharacter{2198}{\ensuremath\searrow}% |
| 10955 | \DeclareUnicodeCharacter{2199}{\ensuremath\swarrow}% |
| 10956 | \DeclareUnicodeCharacter{21A6}{\ensuremath\mapsto}% |
| 10957 | \DeclareUnicodeCharacter{21A9}{\ensuremath\hookleftarrow}% |
| 10958 | \DeclareUnicodeCharacter{21AA}{\ensuremath\hookrightarrow}% |
| 10959 | \DeclareUnicodeCharacter{21BC}{\ensuremath\leftharpoonup}% |
| 10960 | \DeclareUnicodeCharacter{21BD}{\ensuremath\leftharpoondown}% |
| 10961 | \DeclareUnicodeCharacter{21C0}{\ensuremath\rightharpoonup}% |
| 10962 | \DeclareUnicodeCharacter{21C1}{\ensuremath\rightharpoondown}% |
| 10963 | \DeclareUnicodeCharacter{21CC}{\ensuremath\rightleftharpoons}% |
| 10964 | \DeclareUnicodeCharacter{21D0}{\ensuremath\Leftarrow}% |
| 10965 | \DeclareUnicodeCharacter{21D1}{\ensuremath\Uparrow}% |
| 10966 | \DeclareUnicodeCharacter{21D3}{\ensuremath\Downarrow}% |
| 10967 | \DeclareUnicodeCharacter{21D4}{\ensuremath\Leftrightarrow}% |
| 10968 | \DeclareUnicodeCharacter{21D5}{\ensuremath\Updownarrow}% |
| 10969 | \DeclareUnicodeCharacter{2202}{\ensuremath\partial}% |
| 10970 | \DeclareUnicodeCharacter{2205}{\ensuremath\emptyset}% |
| 10971 | \DeclareUnicodeCharacter{2207}{\ensuremath\nabla}% |
| 10972 | \DeclareUnicodeCharacter{2209}{\ensuremath\notin}% |
| 10973 | \DeclareUnicodeCharacter{220B}{\ensuremath\owns}% |
| 10974 | \DeclareUnicodeCharacter{220F}{\ensuremath\prod}% |
| 10975 | \DeclareUnicodeCharacter{2210}{\ensuremath\coprod}% |
| 10976 | \DeclareUnicodeCharacter{2211}{\ensuremath\sum}% |
| 10977 | \DeclareUnicodeCharacter{2213}{\ensuremath\mp}% |
| 10978 | \DeclareUnicodeCharacter{2218}{\ensuremath\circ}% |
| 10979 | \DeclareUnicodeCharacter{221A}{\ensuremath\surd}% |
| 10980 | \DeclareUnicodeCharacter{221D}{\ensuremath\propto}% |
| 10981 | \DeclareUnicodeCharacter{2220}{\ensuremath\angle}% |
| 10982 | \DeclareUnicodeCharacter{2223}{\ensuremath\mid}% |
| 10983 | \DeclareUnicodeCharacter{2228}{\ensuremath\vee}% |
| 10984 | \DeclareUnicodeCharacter{222A}{\ensuremath\cup}% |
| 10985 | \DeclareUnicodeCharacter{222B}{\ensuremath\smallint}% |
| 10986 | \DeclareUnicodeCharacter{222E}{\ensuremath\oint}% |
| 10987 | \DeclareUnicodeCharacter{223C}{\ensuremath\sim}% |
| 10988 | \DeclareUnicodeCharacter{2240}{\ensuremath\wr}% |
| 10989 | \DeclareUnicodeCharacter{2243}{\ensuremath\simeq}% |
| 10990 | \DeclareUnicodeCharacter{2245}{\ensuremath\cong}% |
| 10991 | \DeclareUnicodeCharacter{2248}{\ensuremath\approx}% |
| 10992 | \DeclareUnicodeCharacter{224D}{\ensuremath\asymp}% |
| 10993 | \DeclareUnicodeCharacter{2250}{\ensuremath\doteq}% |
| 10994 | \DeclareUnicodeCharacter{2260}{\ensuremath\neq}% |
| 10995 | \DeclareUnicodeCharacter{226A}{\ensuremath\ll}% |
| 10996 | \DeclareUnicodeCharacter{226B}{\ensuremath\gg}% |
| 10997 | \DeclareUnicodeCharacter{227A}{\ensuremath\prec}% |
| 10998 | \DeclareUnicodeCharacter{227B}{\ensuremath\succ}% |
| 10999 | \DeclareUnicodeCharacter{2283}{\ensuremath\supset}% |
| 11000 | \DeclareUnicodeCharacter{2286}{\ensuremath\subseteq}% |
| 11001 | \DeclareUnicodeCharacter{228E}{\ensuremath\uplus}% |
| 11002 | \DeclareUnicodeCharacter{2291}{\ensuremath\sqsubseteq}% |
| 11003 | \DeclareUnicodeCharacter{2292}{\ensuremath\sqsupseteq}% |
| 11004 | \DeclareUnicodeCharacter{2293}{\ensuremath\sqcap}% |
| 11005 | \DeclareUnicodeCharacter{2294}{\ensuremath\sqcup}% |
| 11006 | \DeclareUnicodeCharacter{2295}{\ensuremath\oplus}% |
| 11007 | \DeclareUnicodeCharacter{2296}{\ensuremath\ominus}% |
| 11008 | \DeclareUnicodeCharacter{2297}{\ensuremath\otimes}% |
| 11009 | \DeclareUnicodeCharacter{2298}{\ensuremath\oslash}% |
| 11010 | \DeclareUnicodeCharacter{2299}{\ensuremath\odot}% |
| 11011 | \DeclareUnicodeCharacter{22A2}{\ensuremath\vdash}% |
| 11012 | \DeclareUnicodeCharacter{22A3}{\ensuremath\dashv}% |
| 11013 | \DeclareUnicodeCharacter{22A4}{\ensuremath\ptextop}% |
| 11014 | \DeclareUnicodeCharacter{22A5}{\ensuremath\bot}% |
| 11015 | \DeclareUnicodeCharacter{22A8}{\ensuremath\models}% |
| 11016 | \DeclareUnicodeCharacter{22C0}{\ensuremath\bigwedge}% |
| 11017 | \DeclareUnicodeCharacter{22C1}{\ensuremath\bigvee}% |
| 11018 | \DeclareUnicodeCharacter{22C2}{\ensuremath\bigcap}% |
| 11019 | \DeclareUnicodeCharacter{22C3}{\ensuremath\bigcup}% |
| 11020 | \DeclareUnicodeCharacter{22C4}{\ensuremath\diamond}% |
| 11021 | \DeclareUnicodeCharacter{22C5}{\ensuremath\cdot}% |
| 11022 | \DeclareUnicodeCharacter{22C6}{\ensuremath\star}% |
| 11023 | \DeclareUnicodeCharacter{22C8}{\ensuremath\bowtie}% |
| 11024 | \DeclareUnicodeCharacter{2308}{\ensuremath\lceil}% |
| 11025 | \DeclareUnicodeCharacter{2309}{\ensuremath\rceil}% |
| 11026 | \DeclareUnicodeCharacter{230A}{\ensuremath\lfloor}% |
| 11027 | \DeclareUnicodeCharacter{230B}{\ensuremath\rfloor}% |
| 11028 | \DeclareUnicodeCharacter{2322}{\ensuremath\frown}% |
| 11029 | \DeclareUnicodeCharacter{2323}{\ensuremath\smile}% |
| 11030 | % |
| 11031 | \DeclareUnicodeCharacter{25B3}{\ensuremath\triangle}% |
| 11032 | \DeclareUnicodeCharacter{25B7}{\ensuremath\triangleright}% |
| 11033 | \DeclareUnicodeCharacter{25BD}{\ensuremath\bigtriangledown}% |
| 11034 | \DeclareUnicodeCharacter{25C1}{\ensuremath\triangleleft}% |
| 11035 | \DeclareUnicodeCharacter{25C7}{\ensuremath\diamond}% |
| 11036 | \DeclareUnicodeCharacter{2660}{\ensuremath\spadesuit}% |
| 11037 | \DeclareUnicodeCharacter{2661}{\ensuremath\heartsuit}% |
| 11038 | \DeclareUnicodeCharacter{2662}{\ensuremath\diamondsuit}% |
| 11039 | \DeclareUnicodeCharacter{2663}{\ensuremath\clubsuit}% |
| 11040 | \DeclareUnicodeCharacter{266D}{\ensuremath\flat}% |
| 11041 | \DeclareUnicodeCharacter{266E}{\ensuremath\natural}% |
| 11042 | \DeclareUnicodeCharacter{266F}{\ensuremath\sharp}% |
| 11043 | \DeclareUnicodeCharacter{26AA}{\ensuremath\bigcirc}% |
| 11044 | \DeclareUnicodeCharacter{27B9}{\ensuremath\rangle}% |
| 11045 | \DeclareUnicodeCharacter{27C2}{\ensuremath\perp}% |
| 11046 | \DeclareUnicodeCharacter{27E8}{\ensuremath\langle}% |
| 11047 | \DeclareUnicodeCharacter{27F5}{\ensuremath\longleftarrow}% |
| 11048 | \DeclareUnicodeCharacter{27F6}{\ensuremath\longrightarrow}% |
| 11049 | \DeclareUnicodeCharacter{27F7}{\ensuremath\longleftrightarrow}% |
| 11050 | \DeclareUnicodeCharacter{27FC}{\ensuremath\longmapsto}% |
| 11051 | \DeclareUnicodeCharacter{29F5}{\ensuremath\setminus}% |
| 11052 | \DeclareUnicodeCharacter{2A00}{\ensuremath\bigodot}% |
| 11053 | \DeclareUnicodeCharacter{2A01}{\ensuremath\bigoplus}% |
| 11054 | \DeclareUnicodeCharacter{2A02}{\ensuremath\bigotimes}% |
| 11055 | \DeclareUnicodeCharacter{2A04}{\ensuremath\biguplus}% |
| 11056 | \DeclareUnicodeCharacter{2A06}{\ensuremath\bigsqcup}% |
| 11057 | \DeclareUnicodeCharacter{2A3F}{\ensuremath\amalg}% |
| 11058 | \DeclareUnicodeCharacter{2AAF}{\ensuremath\preceq}% |
| 11059 | \DeclareUnicodeCharacter{2AB0}{\ensuremath\succeq}% |
| 11060 | % |
| 11061 | \global\mathchardef\checkmark="1370% actually the square root sign |
| 11062 | \DeclareUnicodeCharacter{2713}{\ensuremath\checkmark}% |
| 11063 | }% end of \unicodechardefs |
| 11064 | |
| 11065 | % UTF-8 byte sequence (pdfTeX) definitions (replacing and @U command) |
| 11066 | % It makes the setting that replace UTF-8 byte sequence. |
| 11067 | \def\utfeightchardefs{% |
| 11068 | \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterUTFviii |
| 11069 | \unicodechardefs |
| 11070 | } |
| 11071 | |
| 11072 | % Whether the active definitions of non-ASCII characters expand to |
| 11073 | % non-active tokens with the same character code. This is used to |
| 11074 | % write characters literally, instead of using active definitions for |
| 11075 | % printing the correct glyphs. |
| 11076 | \newif\ifpassthroughchars |
| 11077 | \passthroughcharsfalse |
| 11078 | |
| 11079 | % For native Unicode handling (XeTeX and LuaTeX), |
| 11080 | % provide a definition macro to replace/pass-through a Unicode character |
| 11081 | % |
| 11082 | \def\DeclareUnicodeCharacterNative#1#2{% |
| 11083 | \catcode"#1=\active |
| 11084 | \def\dodeclareunicodecharacternative##1##2##3{% |
| 11085 | \begingroup |
| 11086 | \uccode`\~="##2\relax |
| 11087 | \uppercase{\gdef~}{% |
| 11088 | \ifpassthroughchars |
| 11089 | ##1% |
| 11090 | \else |
| 11091 | ##3% |
| 11092 | \fi |
| 11093 | } |
| 11094 | \endgroup |
| 11095 | } |
| 11096 | \begingroup |
| 11097 | \uccode`\.="#1\relax |
| 11098 | \uppercase{\def\UTFNativeTmp{.}}% |
| 11099 | \expandafter\dodeclareunicodecharacternative\UTFNativeTmp{#1}{#2}% |
| 11100 | \endgroup |
| 11101 | } |
| 11102 | |
| 11103 | % Native Unicode handling (XeTeX and LuaTeX) character replacing definition. |
| 11104 | % It activates the setting that replaces Unicode characters. |
| 11105 | \def\nativeunicodechardefs{% |
| 11106 | \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNative |
| 11107 | \unicodechardefs |
| 11108 | } |
| 11109 | |
| 11110 | % For native Unicode handling (XeTeX and LuaTeX), |
| 11111 | % make the character token expand |
| 11112 | % to the sequences given in \unicodechardefs for printing. |
| 11113 | \def\DeclareUnicodeCharacterNativeAtU#1#2{% |
| 11114 | \def\UTFAtUTmp{#2} |
| 11115 | \expandafter\globallet\csname uni:#1\endcsname \UTFAtUTmp |
| 11116 | } |
| 11117 | |
| 11118 | % @U command definitions for native Unicode handling (XeTeX and LuaTeX). |
| 11119 | \def\nativeunicodechardefsatu{% |
| 11120 | \let\DeclareUnicodeCharacter\DeclareUnicodeCharacterNativeAtU |
| 11121 | \unicodechardefs |
| 11122 | } |
| 11123 | |
| 11124 | % US-ASCII character definitions. |
| 11125 | \def\asciichardefs{% nothing need be done |
| 11126 | \relax |
| 11127 | } |
| 11128 | |
| 11129 | % Define all Unicode characters we know about. This makes UTF-8 the default |
| 11130 | % input encoding and allows @U to work. |
| 11131 | \iftxinativeunicodecapable |
| 11132 | \nativeunicodechardefsatu |
| 11133 | \else |
| 11134 | \utfeightchardefs |
| 11135 | \fi |
| 11136 | |
| 11137 | \message{formatting,} |
| 11138 | |
| 11139 | \newdimen\defaultparindent \defaultparindent = 15pt |
| 11140 | |
| 11141 | \chapheadingskip = 15pt plus 4pt minus 2pt |
| 11142 | \secheadingskip = 12pt plus 3pt minus 2pt |
| 11143 | \subsecheadingskip = 9pt plus 2pt minus 2pt |
| 11144 | |
| 11145 | % Prevent underfull vbox error messages. |
| 11146 | \vbadness = 10000 |
| 11147 | |
| 11148 | % Don't be very finicky about underfull hboxes, either. |
| 11149 | \hbadness = 6666 |
| 11150 | |
| 11151 | % Following George Bush, get rid of widows and orphans. |
| 11152 | \widowpenalty=10000 |
| 11153 | \clubpenalty=10000 |
| 11154 | |
| 11155 | % Use TeX 3.0's \emergencystretch to help line breaking, but if we're |
| 11156 | % using an old version of TeX, don't do anything. We want the amount of |
| 11157 | % stretch added to depend on the line length, hence the dependence on |
| 11158 | % \hsize. We call this whenever the paper size is set. |
| 11159 | % |
| 11160 | \def\setemergencystretch{% |
| 11161 | \ifx\emergencystretch\thisisundefined |
| 11162 | % Allow us to assign to \emergencystretch anyway. |
| 11163 | \def\emergencystretch{\dimen0}% |
| 11164 | \else |
| 11165 | \emergencystretch = .15\hsize |
| 11166 | \fi |
| 11167 | } |
| 11168 | |
| 11169 | % Parameters in order: 1) textheight; 2) textwidth; |
| 11170 | % 3) voffset; 4) hoffset; 5) binding offset; 6) topskip; |
| 11171 | % 7) physical page height; 8) physical page width. |
| 11172 | % |
| 11173 | % We also call \setleading{\textleading}, so the caller should define |
| 11174 | % \textleading. The caller should also set \parskip. |
| 11175 | % |
| 11176 | \def\internalpagesizes#1#2#3#4#5#6#7#8{% |
| 11177 | \voffset = #3\relax |
| 11178 | \topskip = #6\relax |
| 11179 | \splittopskip = \topskip |
| 11180 | % |
| 11181 | \vsize = #1\relax |
| 11182 | \advance\vsize by \topskip |
| 11183 | \outervsize = \vsize |
| 11184 | \advance\outervsize by 2\topandbottommargin |
| 11185 | \txipageheight = \vsize |
| 11186 | % |
| 11187 | \hsize = #2\relax |
| 11188 | \outerhsize = \hsize |
| 11189 | \advance\outerhsize by 0.5in |
| 11190 | \txipagewidth = \hsize |
| 11191 | % |
| 11192 | \normaloffset = #4\relax |
| 11193 | \bindingoffset = #5\relax |
| 11194 | % |
| 11195 | \ifpdf |
| 11196 | \pdfpageheight #7\relax |
| 11197 | \pdfpagewidth #8\relax |
| 11198 | % if we don't reset these, they will remain at "1 true in" of |
| 11199 | % whatever layout pdftex was dumped with. |
| 11200 | \pdfhorigin = 1 true in |
| 11201 | \pdfvorigin = 1 true in |
| 11202 | \else |
| 11203 | \ifx\XeTeXrevision\thisisundefined |
| 11204 | \special{papersize=#8,#7}% |
| 11205 | \else |
| 11206 | \pdfpageheight #7\relax |
| 11207 | \pdfpagewidth #8\relax |
| 11208 | % XeTeX does not have \pdfhorigin and \pdfvorigin. |
| 11209 | \fi |
| 11210 | \fi |
| 11211 | % |
| 11212 | \setleading{\textleading} |
| 11213 | % |
| 11214 | \parindent = \defaultparindent |
| 11215 | \setemergencystretch |
| 11216 | } |
| 11217 | |
| 11218 | % @letterpaper (the default). |
| 11219 | \def\letterpaper{{\globaldefs = 1 |
| 11220 | \parskip = 3pt plus 2pt minus 1pt |
| 11221 | \textleading = 13.2pt |
| 11222 | % |
| 11223 | % If page is nothing but text, make it come out even. |
| 11224 | \internalpagesizes{607.2pt}{6in}% that's 46 lines |
| 11225 | {\voffset}{.25in}% |
| 11226 | {\bindingoffset}{36pt}% |
| 11227 | {11in}{8.5in}% |
| 11228 | }} |
| 11229 | |
| 11230 | % Use @smallbook to reset parameters for 7x9.25 trim size. |
| 11231 | \def\smallbook{{\globaldefs = 1 |
| 11232 | \parskip = 2pt plus 1pt |
| 11233 | \textleading = 12pt |
| 11234 | % |
| 11235 | \internalpagesizes{7.5in}{5in}% |
| 11236 | {-.2in}{0in}% |
| 11237 | {\bindingoffset}{16pt}% |
| 11238 | {9.25in}{7in}% |
| 11239 | % |
| 11240 | \lispnarrowing = 0.3in |
| 11241 | \tolerance = 700 |
| 11242 | \contentsrightmargin = 0pt |
| 11243 | \defbodyindent = .5cm |
| 11244 | }} |
| 11245 | |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 11246 | % Use @afourpaper to print on European A4 paper. |
| 11247 | \def\afourpaper{{\globaldefs = 1 |
| 11248 | \parskip = 3pt plus 2pt minus 1pt |
| 11249 | \textleading = 13.2pt |
| 11250 | % |
| 11251 | % Double-side printing via postscript on Laserjet 4050 |
| 11252 | % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm. |
| 11253 | % To change the settings for a different printer or situation, adjust |
| 11254 | % \normaloffset until the front-side and back-side texts align. Then |
| 11255 | % do the same for \bindingoffset. You can set these for testing in |
| 11256 | % your texinfo source file like this: |
| 11257 | % @tex |
| 11258 | % \global\normaloffset = -6mm |
| 11259 | % \global\bindingoffset = 10mm |
| 11260 | % @end tex |
| 11261 | \internalpagesizes{673.2pt}{160mm}% that's 51 lines |
| 11262 | {\voffset}{\hoffset}% |
| 11263 | {\bindingoffset}{44pt}% |
| 11264 | {297mm}{210mm}% |
| 11265 | % |
| 11266 | \tolerance = 700 |
| 11267 | \contentsrightmargin = 0pt |
| 11268 | \defbodyindent = 5mm |
| 11269 | }} |
| 11270 | |
| 11271 | % Use @afivepaper to print on European A5 paper. |
| 11272 | % From romildo@urano.iceb.ufop.br, 2 July 2000. |
| 11273 | % He also recommends making @example and @lisp be small. |
| 11274 | \def\afivepaper{{\globaldefs = 1 |
| 11275 | \parskip = 2pt plus 1pt minus 0.1pt |
| 11276 | \textleading = 12.5pt |
| 11277 | % |
| 11278 | \internalpagesizes{160mm}{120mm}% |
| 11279 | {\voffset}{\hoffset}% |
| 11280 | {\bindingoffset}{8pt}% |
| 11281 | {210mm}{148mm}% |
| 11282 | % |
| 11283 | \lispnarrowing = 0.2in |
| 11284 | \tolerance = 800 |
| 11285 | \contentsrightmargin = 0pt |
| 11286 | \defbodyindent = 2mm |
| 11287 | \tableindent = 12mm |
| 11288 | }} |
| 11289 | |
| 11290 | % A specific text layout, 24x15cm overall, intended for A4 paper. |
| 11291 | \def\afourlatex{{\globaldefs = 1 |
| 11292 | \afourpaper |
| 11293 | \internalpagesizes{237mm}{150mm}% |
| 11294 | {\voffset}{4.6mm}% |
| 11295 | {\bindingoffset}{7mm}% |
| 11296 | {297mm}{210mm}% |
| 11297 | % |
| 11298 | % Must explicitly reset to 0 because we call \afourpaper. |
| 11299 | \globaldefs = 0 |
| 11300 | }} |
| 11301 | |
| 11302 | % Use @afourwide to print on A4 paper in landscape format. |
| 11303 | \def\afourwide{{\globaldefs = 1 |
| 11304 | \afourpaper |
| 11305 | \internalpagesizes{241mm}{165mm}% |
| 11306 | {\voffset}{-2.95mm}% |
| 11307 | {\bindingoffset}{7mm}% |
| 11308 | {297mm}{210mm}% |
| 11309 | \globaldefs = 0 |
| 11310 | }} |
| 11311 | |
| 11312 | \def\bsixpaper{{\globaldefs = 1 |
| 11313 | \afourpaper |
| 11314 | \internalpagesizes{140mm}{100mm}% |
| 11315 | {-6.35mm}{-12.7mm}% |
| 11316 | {\bindingoffset}{14pt}% |
| 11317 | {176mm}{125mm}% |
| 11318 | \let\SETdispenvsize=\smallword |
| 11319 | \lispnarrowing = 0.2in |
| 11320 | \globaldefs = 0 |
| 11321 | }} |
| 11322 | |
| 11323 | |
| 11324 | % @pagesizes TEXTHEIGHT[,TEXTWIDTH] |
| 11325 | % Perhaps we should allow setting the margins, \topskip, \parskip, |
| 11326 | % and/or leading, also. Or perhaps we should compute them somehow. |
| 11327 | % |
| 11328 | \parseargdef\pagesizes{\pagesizesyyy #1,,\finish} |
| 11329 | \def\pagesizesyyy#1,#2,#3\finish{{% |
| 11330 | \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi |
| 11331 | \globaldefs = 1 |
| 11332 | % |
| 11333 | \parskip = 3pt plus 2pt minus 1pt |
| 11334 | \setleading{\textleading}% |
| 11335 | % |
| 11336 | \dimen0 = #1\relax |
| 11337 | \advance\dimen0 by 2.5in % default 1in margin above heading line |
| 11338 | % and 1.5in to include heading, footing and |
| 11339 | % bottom margin |
| 11340 | % |
| 11341 | \dimen2 = \hsize |
| 11342 | \advance\dimen2 by 2in % default to 1 inch margin on each side |
| 11343 | % |
| 11344 | \internalpagesizes{#1}{\hsize}% |
| 11345 | {\voffset}{\normaloffset}% |
| 11346 | {\bindingoffset}{44pt}% |
| 11347 | {\dimen0}{\dimen2}% |
| 11348 | }} |
| 11349 | |
| 11350 | % Set default to letter. |
| 11351 | % |
| 11352 | \letterpaper |
| 11353 | |
| 11354 | % Default value of \hfuzz, for suppressing warnings about overfull hboxes. |
| 11355 | \hfuzz = 1pt |
| 11356 | |
| 11357 | |
| 11358 | \message{and turning on texinfo input format.} |
| 11359 | |
| 11360 | \def^^L{\par} % remove \outer, so ^L can appear in an @comment |
| 11361 | |
| 11362 | % DEL is a comment character, in case @c does not suffice. |
| 11363 | \catcode`\^^? = 14 |
| 11364 | |
| 11365 | % Define macros to output various characters with catcode for normal text. |
| 11366 | \catcode`\"=\other \def\normaldoublequote{"} |
| 11367 | \catcode`\$=\other \def\normaldollar{$}%$ font-lock fix |
| 11368 | \catcode`\+=\other \def\normalplus{+} |
| 11369 | \catcode`\<=\other \def\normalless{<} |
| 11370 | \catcode`\>=\other \def\normalgreater{>} |
| 11371 | \catcode`\^=\other \def\normalcaret{^} |
| 11372 | \catcode`\_=\other \def\normalunderscore{_} |
| 11373 | \catcode`\|=\other \def\normalverticalbar{|} |
| 11374 | \catcode`\~=\other \def\normaltilde{~} |
| 11375 | |
| 11376 | % This macro is used to make a character print one way in \tt |
| 11377 | % (where it can probably be output as-is), and another way in other fonts, |
| 11378 | % where something hairier probably needs to be done. |
| 11379 | % |
| 11380 | % #1 is what to print if we are indeed using \tt; #2 is what to print |
| 11381 | % otherwise. Since all the Computer Modern typewriter fonts have zero |
| 11382 | % interword stretch (and shrink), and it is reasonable to expect all |
| 11383 | % typewriter fonts to have this, we can check that font parameter. |
| 11384 | % |
| 11385 | \def\ifusingtt#1#2{\ifdim \fontdimen3\font=0pt #1\else #2\fi} |
| 11386 | |
| 11387 | % Same as above, but check for italic font. Actually this also catches |
| 11388 | % non-italic slanted fonts since it is impossible to distinguish them from |
| 11389 | % italic fonts. But since this is only used by $ and it uses \sl anyway |
| 11390 | % this is not a problem. |
| 11391 | \def\ifusingit#1#2{\ifdim \fontdimen1\font>0pt #1\else #2\fi} |
| 11392 | |
| 11393 | % Set catcodes for Texinfo file |
| 11394 | |
| 11395 | % Active characters for printing the wanted glyph. |
| 11396 | % Most of these we simply print from the \tt font, but for some, we can |
| 11397 | % use math or other variants that look better in normal text. |
| 11398 | % |
| 11399 | \catcode`\"=\active |
| 11400 | \def\activedoublequote{{\tt\char34}} |
| 11401 | \let"=\activedoublequote |
| 11402 | \catcode`\~=\active \def\activetilde{{\tt\char126}} \let~ = \activetilde |
| 11403 | \chardef\hatchar=`\^ |
| 11404 | \catcode`\^=\active \def\activehat{{\tt \hatchar}} \let^ = \activehat |
| 11405 | |
| 11406 | \catcode`\_=\active |
| 11407 | \def_{\ifusingtt\normalunderscore\_} |
| 11408 | \def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em } |
| 11409 | \let\realunder=_ |
| 11410 | |
| 11411 | \catcode`\|=\active \def|{{\tt\char124}} |
| 11412 | |
| 11413 | \chardef \less=`\< |
| 11414 | \catcode`\<=\active \def\activeless{{\tt \less}}\let< = \activeless |
| 11415 | \chardef \gtr=`\> |
| 11416 | \catcode`\>=\active \def\activegtr{{\tt \gtr}}\let> = \activegtr |
| 11417 | \catcode`\+=\active \def+{{\tt \char 43}} |
| 11418 | \catcode`\$=\active \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix |
| 11419 | \catcode`\-=\active \let-=\normaldash |
| 11420 | |
| 11421 | |
| 11422 | % used for headline/footline in the output routine, in case the page |
| 11423 | % breaks in the middle of an @tex block. |
| 11424 | \def\texinfochars{% |
| 11425 | \let< = \activeless |
| 11426 | \let> = \activegtr |
| 11427 | \let~ = \activetilde |
| 11428 | \let^ = \activehat |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 11429 | \setregularquotes |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 11430 | \let\b = \strong |
| 11431 | \let\i = \smartitalic |
| 11432 | % in principle, all other definitions in \tex have to be undone too. |
| 11433 | } |
| 11434 | |
| 11435 | % Used sometimes to turn off (effectively) the active characters even after |
| 11436 | % parsing them. |
| 11437 | \def\turnoffactive{% |
| 11438 | \normalturnoffactive |
| 11439 | \otherbackslash |
| 11440 | } |
| 11441 | |
| 11442 | \catcode`\@=0 |
| 11443 | |
| 11444 | % \backslashcurfont outputs one backslash character in current font, |
| 11445 | % as in \char`\\. |
| 11446 | \global\chardef\backslashcurfont=`\\ |
| 11447 | |
| 11448 | % \realbackslash is an actual character `\' with catcode other. |
| 11449 | {\catcode`\\=\other @gdef@realbackslash{\}} |
| 11450 | |
| 11451 | % In Texinfo, backslash is an active character; it prints the backslash |
| 11452 | % in fixed width font. |
| 11453 | \catcode`\\=\active % @ for escape char from now on. |
| 11454 | |
| 11455 | % Print a typewriter backslash. For math mode, we can't simply use |
| 11456 | % \backslashcurfont: the story here is that in math mode, the \char |
| 11457 | % of \backslashcurfont ends up printing the roman \ from the math symbol |
| 11458 | % font (because \char in math mode uses the \mathcode, and plain.tex |
| 11459 | % sets \mathcode`\\="026E). Hence we use an explicit \mathchar, |
| 11460 | % which is the decimal equivalent of "715c (class 7, e.g., use \fam; |
| 11461 | % ignored family value; char position "5C). We can't use " for the |
| 11462 | % usual hex value because it has already been made active. |
| 11463 | |
| 11464 | @def@ttbackslash{{@tt @ifmmode @mathchar29020 @else @backslashcurfont @fi}} |
| 11465 | @let@backslashchar = @ttbackslash % @backslashchar{} is for user documents. |
| 11466 | |
| 11467 | % \otherbackslash defines an active \ to be a literal `\' character with |
| 11468 | % catcode other. |
| 11469 | @gdef@otherbackslash{@let\=@realbackslash} |
| 11470 | |
| 11471 | % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of |
| 11472 | % the literal character `\'. |
| 11473 | % |
| 11474 | {@catcode`- = @active |
| 11475 | @gdef@normalturnoffactive{% |
| 11476 | @passthroughcharstrue |
| 11477 | @let-=@normaldash |
| 11478 | @let"=@normaldoublequote |
| 11479 | @let$=@normaldollar %$ font-lock fix |
| 11480 | @let+=@normalplus |
| 11481 | @let<=@normalless |
| 11482 | @let>=@normalgreater |
| 11483 | @let^=@normalcaret |
| 11484 | @let_=@normalunderscore |
| 11485 | @let|=@normalverticalbar |
| 11486 | @let~=@normaltilde |
| 11487 | @let\=@ttbackslash |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 11488 | @setregularquotes |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 11489 | @unsepspaces |
| 11490 | } |
| 11491 | } |
| 11492 | |
| 11493 | % If a .fmt file is being used, characters that might appear in a file |
| 11494 | % name cannot be active until we have parsed the command line. |
| 11495 | % So turn them off again, and have @fixbackslash turn them back on. |
| 11496 | @catcode`+=@other @catcode`@_=@other |
| 11497 | |
| 11498 | % \enablebackslashhack - allow file to begin `\input texinfo' |
| 11499 | % |
| 11500 | % If a .fmt file is being used, we don't want the `\input texinfo' to show up. |
| 11501 | % That is what \eatinput is for; after that, the `\' should revert to printing |
| 11502 | % a backslash. |
| 11503 | % If the file did not have a `\input texinfo', then it is turned off after |
| 11504 | % the first line; otherwise the first `\' in the file would cause an error. |
| 11505 | % This is used on the very last line of this file, texinfo.tex. |
| 11506 | % We also use @c to call @fixbackslash, in case ends of lines are hidden. |
| 11507 | { |
| 11508 | @catcode`@^=7 |
| 11509 | @catcode`@^^M=13@gdef@enablebackslashhack{% |
| 11510 | @global@let\ = @eatinput% |
| 11511 | @catcode`@^^M=13% |
| 11512 | @def@c{@fixbackslash@c}% |
| 11513 | % Definition for the newline at the end of this file. |
| 11514 | @def ^^M{@let^^M@secondlinenl}% |
| 11515 | % Definition for a newline in the main Texinfo file. |
| 11516 | @gdef @secondlinenl{@fixbackslash}% |
| 11517 | % In case the first line has a whole-line command on it |
| 11518 | @let@originalparsearg@parsearg |
| 11519 | @def@parsearg{@fixbackslash@originalparsearg} |
| 11520 | }} |
| 11521 | |
| 11522 | {@catcode`@^=7 @catcode`@^^M=13% |
| 11523 | @gdef@eatinput input texinfo#1^^M{@fixbackslash}} |
| 11524 | |
| 11525 | % Emergency active definition of newline, in case an active newline token |
| 11526 | % appears by mistake. |
| 11527 | {@catcode`@^=7 @catcode13=13% |
| 11528 | @gdef@enableemergencynewline{% |
| 11529 | @gdef^^M{% |
| 11530 | @par% |
| 11531 | %<warning: active newline>@par% |
| 11532 | }}} |
| 11533 | |
| 11534 | |
| 11535 | @gdef@fixbackslash{% |
| 11536 | @ifx\@eatinput @let\ = @ttbackslash @fi |
| 11537 | @catcode13=5 % regular end of line |
| 11538 | @enableemergencynewline |
| 11539 | @let@c=@comment |
| 11540 | @let@parsearg@originalparsearg |
| 11541 | % Also turn back on active characters that might appear in the input |
| 11542 | % file name, in case not using a pre-dumped format. |
| 11543 | @catcode`+=@active |
| 11544 | @catcode`@_=@active |
| 11545 | % |
| 11546 | % If texinfo.cnf is present on the system, read it. |
| 11547 | % Useful for site-wide @afourpaper, etc. This macro, @fixbackslash, gets |
| 11548 | % called at the beginning of every Texinfo file. Not opening texinfo.cnf |
| 11549 | % directly in this file, texinfo.tex, makes it possible to make a format |
| 11550 | % file for Texinfo. |
| 11551 | % |
| 11552 | @openin 1 texinfo.cnf |
| 11553 | @ifeof 1 @else @input texinfo.cnf @fi |
| 11554 | @closein 1 |
| 11555 | } |
| 11556 | |
| 11557 | |
| 11558 | % Say @foo, not \foo, in error messages. |
| 11559 | @escapechar = `@@ |
| 11560 | |
| 11561 | % These (along with & and #) are made active for url-breaking, so need |
| 11562 | % active definitions as the normal characters. |
| 11563 | @def@normaldot{.} |
| 11564 | @def@normalquest{?} |
| 11565 | @def@normalslash{/} |
| 11566 | |
| 11567 | % These look ok in all fonts, so just make them not special. |
| 11568 | % @hashchar{} gets its own user-level command, because of #line. |
| 11569 | @catcode`@& = @other @def@normalamp{&} |
| 11570 | @catcode`@# = @other @def@normalhash{#} |
| 11571 | @catcode`@% = @other @def@normalpercent{%} |
| 11572 | |
| 11573 | @let @hashchar = @normalhash |
| 11574 | |
| 11575 | @c Finally, make ` and ' active, so that txicodequoteundirected and |
| 11576 | @c txicodequotebacktick work right in, e.g., @w{@code{`foo'}}. If we |
| 11577 | @c don't make ` and ' active, @code will not get them as active chars. |
| 11578 | @c Do this last of all since we use ` in the previous @catcode assignments. |
| 11579 | @catcode`@'=@active |
| 11580 | @catcode`@`=@active |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 11581 | @setregularquotes |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 11582 | |
| 11583 | @c Local variables: |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 11584 | @c eval: (add-hook 'before-save-hook 'time-stamp nil t) |
| 11585 | @c time-stamp-pattern: "texinfoversion{%Y-%02m-%02d.%02H}" |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 11586 | @c page-delimiter: "^\\\\message\\|emacs-page" |
Alistair Delva | beaee83 | 2021-02-24 11:27:23 -0800 | [diff] [blame] | 11587 | @c End: |
| 11588 | |
| 11589 | @c vim:sw=2: |
| 11590 | |
| 11591 | @enablebackslashhack |
Yi Kong | 39bbd96 | 2022-01-09 19:41:38 +0800 | [diff] [blame] | 11592 | |