| 1 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2 |
% |
| 3 |
% Module: ZzTeX Horizontal Mode Facilities |
| 4 |
% |
| 5 |
% Synopsis: This module provides various facilities that operate in |
| 6 |
% horizontal mode, within a paragraph. See also ZZHMODEB. |
| 7 |
% |
| 8 |
% Author: Paul C. Anagnostopoulos |
| 9 |
% Created: 21 September 1989 |
| 10 |
% |
| 11 |
% Copyright 1989--2020 by Paul C. Anagnostopoulos |
| 12 |
% under The MIT License (opensource.org/licenses/MIT) |
| 13 |
% |
| 14 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 15 |
|
| 16 |
% Starting Paragraphs |
| 17 |
% -------- ---------- |
| 18 |
|
| 19 |
|
| 20 |
% The following token register is executed at the beginning of |
| 21 |
% every paragraph. |
| 22 |
|
| 23 |
\definetoks{\everyparagraph} |
| 24 |
\everyparagraph = {} |
| 25 |
|
| 26 |
% This is what we have to do at the beginning of every paragraph: |
| 27 |
|
| 28 |
\everypar = {\requiredeverypar \the\everyparagraph} |
| 29 |
|
| 30 |
% The following command ensures that we are in horizontal mode, |
| 31 |
% without doing anything if we already are. |
| 32 |
|
| 33 |
\def \ensurepar {\unhbox \voidbox} |
| 34 |
|
| 35 |
% The following command fakes up the start of a paragraph while |
| 36 |
% leaving us in vertical mode. |
| 37 |
|
| 38 |
\def \fakepar {% |
| 39 |
\endgraf |
| 40 |
\vspace{\parskip}% |
| 41 |
\requiredeverypar} |
| 42 |
|
| 43 |
% Paragraph Penalties |
| 44 |
% --------- --------- |
| 45 |
|
| 46 |
|
| 47 |
\definecount{\zclubsv}{-100000} % Overridden \clubpenalty. |
| 48 |
\definecount{\zclubct}{1} % Overridden paragraph count. |
| 49 |
|
| 50 |
|
| 51 |
\def \overrideclubpenalty #1{% {penalty} |
| 52 |
\if \eqlp{\zclubsv}{-100000}\global\zclubsv = \clubpenalty \fi |
| 53 |
\global\clubpenalty = #1\relax |
| 54 |
\global\zclubct = \if \vmodep -1\else 0\fi \relax} |
| 55 |
|
| 56 |
\declareeverypar{\zclubpar} |
| 57 |
|
| 58 |
\def \zclubpar {% |
| 59 |
\ifnum \zclubct=0 |
| 60 |
\global\clubpenalty=\zclubsv |
| 61 |
\global\zclubsv=-100000\relax |
| 62 |
\fi |
| 63 |
\global\advance \zclubct 1\relax} |
| 64 |
|
| 65 |
% Single-Character Commands |
| 66 |
% ---------------- -------- |
| 67 |
|
| 68 |
|
| 69 |
% Name Description |
| 70 |
|
| 71 |
% \<space> Control space |
| 72 |
% \! Negative sixth space; negative thin space in math; |
| 73 |
% callout in code |
| 74 |
% \" Dieresis (umlaut) accent |
| 75 |
% \# Pound sign |
| 76 |
% \$ Dollar sign |
| 77 |
% \% Percent sign |
| 78 |
% \& Ampersand |
| 79 |
% \' Acute accent |
| 80 |
% \( (reserved |
| 81 |
% \) for user) |
| 82 |
% \* \discretionary{}{}{} |
| 83 |
% \+ Hair space |
| 84 |
% \, Sixth space; thin space in math |
| 85 |
% \- Discretionary hyphen |
| 86 |
% \. Dot accent |
| 87 |
% \/ Italic correction |
| 88 |
% \0 \phantom{0} |
| 89 |
% \1 -- \9 (reserved for user) |
| 90 |
% \: List element separator |
| 91 |
% \; Third space; thick space in math |
| 92 |
% \< (reserved for user) |
| 93 |
% \= Macron accent; prefix for tag namespace |
| 94 |
% \> (reserved for user) |
| 95 |
% \? (reserved for user) |
| 96 |
% \@ At-sign |
| 97 |
% \H Hungarian umlaut accent |
| 98 |
% \L Polish suppressed L |
| 99 |
% \O Scandinavian O slash |
| 100 |
% \P Paragraph sign (pilcrow) |
| 101 |
% \S Section sign |
| 102 |
% \[ (reserved for user) |
| 103 |
% \\ Backslash |
| 104 |
% \] (reserved for user) |
| 105 |
% \^ Circumflex accent |
| 106 |
% \_ Underscore |
| 107 |
% \` Grave accent |
| 108 |
% \b Bar-under accent |
| 109 |
% \c Cedilla accent |
| 110 |
% \d Dot-under accent |
| 111 |
% \g Ogonek accent |
| 112 |
% \h Small horizontal space |
| 113 |
% \i Dotless i |
| 114 |
% \j Dotless j |
| 115 |
% \l Polish suppressed l |
| 116 |
% \o Scandinavian o slash |
| 117 |
% \r ring accent |
| 118 |
% \t Tie-after accent |
| 119 |
% \u Breve accent |
| 120 |
% \v Hacek accent |
| 121 |
% \x \ |
| 122 |
% \y } (reserved for user, for index command abbreviations) |
| 123 |
% \z / |
| 124 |
% \{ Left brace |
| 125 |
% \| Vertical bar; \Vert in math mode |
| 126 |
% \} Right brace |
| 127 |
% \~ Tilde accent |
| 128 |
|
| 129 |
% Characters |
| 130 |
% ---------- |
| 131 |
|
| 132 |
|
| 133 |
% These definitions are in alphabetical order. |
| 134 |
|
| 135 |
\def \AA {% %~ Ring A (Angstrom). %^named_char |
| 136 |
\ensurepar |
| 137 |
\if \mathmodep |
| 138 |
\mtext{\AA}% |
| 139 |
\else |
| 140 |
\r{A}% |
| 141 |
\fi} |
| 142 |
|
| 143 |
\def \aa {% %~ Ring a. %^named_char |
| 144 |
\ensurepar |
| 145 |
\if \mathmodep |
| 146 |
\mtext{\aa}% |
| 147 |
\else |
| 148 |
\r{a}% |
| 149 |
\fi} |
| 150 |
|
| 151 |
\chardef \AE = "1D %~ Scandinavian AE. |
| 152 |
|
| 153 |
\chardef \ae = "1A %~ Scandinavian ae. |
| 154 |
|
| 155 |
\chardef \ampersand = `\& %~ Ampersand. |
| 156 |
|
| 157 |
\let \& = \ampersand |
| 158 |
|
| 159 |
\chardef \atsign = `\@ %~ At sign. |
| 160 |
|
| 161 |
\let \@ = \atsign |
| 162 |
|
| 163 |
\def \backslash {% %~ Backslash. %^named_char |
| 164 |
\ensurepar |
| 165 |
\if \mathmodep |
| 166 |
\zmbackslash |
| 167 |
\else \if \monoencodingp |
| 168 |
\char "5C\relax |
| 169 |
\else |
| 170 |
\PSbackslash |
| 171 |
\fi\fi} |
| 172 |
|
| 173 |
\let \\=\backslash |
| 174 |
|
| 175 |
\def \baselinebullet #1{% {size} %~ Bullet set on baseline. |
| 176 |
\zrequiredoodad{\zdoodadfont}{#1}% |
| 177 |
\hbox{\zdoodadfont .}} |
| 178 |
|
| 179 |
\def \bullet {% %~ Bullet. %^named_char |
| 180 |
\ensurepar |
| 181 |
\if \mathmodep |
| 182 |
\zmbullet |
| 183 |
\else |
| 184 |
\PSbullet |
| 185 |
\fi} |
| 186 |
|
| 187 |
\def \cent {% %~ Cent sign. %^named_char |
| 188 |
\ensurepar |
| 189 |
\PScent} |
| 190 |
|
| 191 |
\let \cents = \cent |
| 192 |
|
| 193 |
\def \copyright {% %~ Copyright symbol. %^named_char |
| 194 |
\ensurepar |
| 195 |
\PScopyright} |
| 196 |
|
| 197 |
\def \cdquote {''} %~ Close double quote. %^named_char |
| 198 |
|
| 199 |
\def \dagger {% %~ Dagger. %^named_char |
| 200 |
\ensurepar |
| 201 |
\if \mathmodep |
| 202 |
\zmdagger |
| 203 |
\else |
| 204 |
\PSdagger |
| 205 |
\fi} |
| 206 |
|
| 207 |
\def \ddagger {% %~ Double dagger. %^named_char |
| 208 |
\ensurepar |
| 209 |
\if \mathmodep |
| 210 |
\zmddagger |
| 211 |
\else |
| 212 |
\PSddagger |
| 213 |
\fi} |
| 214 |
|
| 215 |
\def \dollar {% %~ Dollar sign. %^named_char |
| 216 |
\zprehyph{\dollarhyph}% |
| 217 |
\if \monoencodingp |
| 218 |
\char "24\relax |
| 219 |
\else |
| 220 |
\PSdollar |
| 221 |
\fi |
| 222 |
\zposthyph{\dollarhyph}} |
| 223 |
|
| 224 |
\let \$ = \dollar |
| 225 |
|
| 226 |
\def \ellipsis {% %~ Text ellipsis. |
| 227 |
\if \mathmodep |
| 228 |
\ldots |
| 229 |
\else |
| 230 |
\unbreakable\thickspace |
| 231 |
.\unbreakable\thickspace |
| 232 |
.\unbreakable\thickspace |
| 233 |
.\thickspace |
| 234 |
\ignorespaces |
| 235 |
\fi} |
| 236 |
|
| 237 |
\def \emdash {---} %~ Em dash. %^named_char |
| 238 |
|
| 239 |
\def \endash {--} %~ En dash. %^named_char |
| 240 |
|
| 241 |
\def \greater {% %~ Greater-than sign %^named_char |
| 242 |
\ensurepar |
| 243 |
\if \monoencodingp |
| 244 |
\char "3E\relax |
| 245 |
\else |
| 246 |
\PSgreater |
| 247 |
\fi} |
| 248 |
|
| 249 |
\def \>{% %~ Greater-than sign. %^named_char |
| 250 |
\relax |
| 251 |
\if \mathmodep \plainerror \else \greater \fi} |
| 252 |
|
| 253 |
\chardef \hash = `\# %~ Pound sign, hash, octothorpe. |
| 254 |
|
| 255 |
\let \# = \hash |
| 256 |
|
| 257 |
\def \hat {% %~ Hat symbol. %^named_char |
| 258 |
\ensurepar |
| 259 |
\if \mathmodep |
| 260 |
\zmhat |
| 261 |
\else |
| 262 |
\char "5E\relax |
| 263 |
\fi} |
| 264 |
|
| 265 |
\chardef \i = "10 %~ Dotless i. |
| 266 |
|
| 267 |
\chardef \j = "11 %~ Dotless j. |
| 268 |
|
| 269 |
\def \L {\PSpolishL} %~ Uppercase Polish L. %^named_char |
| 270 |
|
| 271 |
\def \l {\PSpolishl} %~ Lowercase Polish l. %^named_char |
| 272 |
|
| 273 |
% \lbrace and \rbrace cannot start with \ensurepar, because that won't |
| 274 |
% work following a \left or \right command. However, the \relax is required. |
| 275 |
|
| 276 |
\def \lbrace {% %~ Left brace. %^named_char |
| 277 |
\relax |
| 278 |
\if \mathmodep |
| 279 |
\zmlbrace |
| 280 |
\else \if \monoencodingp |
| 281 |
\char "7B\relax |
| 282 |
\else |
| 283 |
\PSbraceleft |
| 284 |
\fi\fi} |
| 285 |
|
| 286 |
\let \{ = \lbrace |
| 287 |
|
| 288 |
\def \less {% %~ Less-than sign. %^named_char |
| 289 |
\ensurepar |
| 290 |
\if \monoencodingp |
| 291 |
\char "3C\relax |
| 292 |
\else |
| 293 |
\PSless |
| 294 |
\fi} |
| 295 |
|
| 296 |
\let \< = \less |
| 297 |
|
| 298 |
\chardef \O = "1F %~ Slashed O. |
| 299 |
|
| 300 |
\chardef \o = "1C %~ Slashed o. |
| 301 |
|
| 302 |
\chardef \OE = "1E %~ OE diphthong. |
| 303 |
|
| 304 |
\chardef \oe = "1B %~ oe diphthong. |
| 305 |
|
| 306 |
\def \odquote {``} %~ Open double quote. %^named_char |
| 307 |
|
| 308 |
\def \P {% %~ Paragraph symbol (pilcrow). %^named_char |
| 309 |
\ensurepar |
| 310 |
\PSparagraph} |
| 311 |
|
| 312 |
\chardef \percent = `\% %~ Percent sign. |
| 313 |
|
| 314 |
\let \% = \percent |
| 315 |
|
| 316 |
\def \perthousand {% %~ Per thousand symbol. %^named_char |
| 317 |
\ensurepar |
| 318 |
\PSperthousand} |
| 319 |
|
| 320 |
\def \prellipsis {% %~ Text ellipsis with no left space. |
| 321 |
.\unbreakable\thickspace |
| 322 |
.\unbreakable\thickspace |
| 323 |
.\thickspace |
| 324 |
\ignorespaces} |
| 325 |
|
| 326 |
\def \rbrace {% %~ Right brace. %^named_char |
| 327 |
\relax |
| 328 |
\if \mathmodep |
| 329 |
\zmrbrace |
| 330 |
\else \if \monoencodingp |
| 331 |
\char "7D\relax |
| 332 |
\else |
| 333 |
\PSbraceright |
| 334 |
\fi\fi} |
| 335 |
|
| 336 |
\let \} = \rbrace |
| 337 |
|
| 338 |
\def \registered {% %~ Registered symbol. %^named_char |
| 339 |
\ensurepar |
| 340 |
\PSregistered} |
| 341 |
|
| 342 |
\def \S {% %~ Section sign. %^named_char |
| 343 |
\ensurepar |
| 344 |
\PSsection} |
| 345 |
|
| 346 |
\def \SS {% %~ Double section sign. %^named_char |
| 347 |
\ensurepar |
| 348 |
\PSsection\PSsection} |
| 349 |
|
| 350 |
\chardef \ss = "19 %~ German eszett. |
| 351 |
|
| 352 |
\def \sterling {% %~ Pound sterling symbol. %^named_char |
| 353 |
\ensurepar |
| 354 |
\PSsterling} |
| 355 |
|
| 356 |
\def \tilde {% %~ Tilde. %^named_char |
| 357 |
\ensurepar |
| 358 |
\if \mathmodep |
| 359 |
\zmtilde |
| 360 |
\else |
| 361 |
\char "7E\relax |
| 362 |
\fi} |
| 363 |
|
| 364 |
\def \trademark {% %~ Trademark symbol. %^named_char |
| 365 |
\ensurepar |
| 366 |
\PStrademark} |
| 367 |
|
| 368 |
\def \underscore {% %~ Underscore. %^named_char |
| 369 |
\ensurepar |
| 370 |
\zprehyph{\underscorehyph}% |
| 371 |
\if \monoencodingp |
| 372 |
\char "5F\relax |
| 373 |
\else |
| 374 |
\PSunderscore |
| 375 |
\fi |
| 376 |
\zposthyph{\underscorehyph}} |
| 377 |
|
| 378 |
\let \_ = \underscore |
| 379 |
|
| 380 |
\def \udquote {% %~ Undirected double quote. %^named_char |
| 381 |
\ensurepar |
| 382 |
\if \monoencodingp |
| 383 |
\char "22\relax |
| 384 |
\else |
| 385 |
\PSudquote |
| 386 |
\fi} |
| 387 |
|
| 388 |
\def \usquote {% %~ Undirected single quote. %^named_char |
| 389 |
\ensurepar |
| 390 |
\if \monoencodingp |
| 391 |
\char "0D\relax |
| 392 |
\else |
| 393 |
\PSusquote |
| 394 |
\fi} |
| 395 |
|
| 396 |
\def \verticalbar {% %~ Vertical bar. %^named_char |
| 397 |
\ensurepar |
| 398 |
\if \monoencodingp |
| 399 |
\char "7C\relax |
| 400 |
\else |
| 401 |
\PSbar |
| 402 |
\fi} |
| 403 |
|
| 404 |
\def \|{% %~ Vertical bar. %^named_char |
| 405 |
\relax |
| 406 |
\if \mathmodep \Vert \else \verticalbar \fi} |
| 407 |
|
| 408 |
% Accents |
| 409 |
% ------- |
| 410 |
|
| 411 |
|
| 412 |
\def \"#1{{\accent "7F #1}} %~ Umlaut accent. %^accent |
| 413 |
|
| 414 |
\def \'#1{{\accent 19 #1}} %~ Acute accent. %^accent |
| 415 |
|
| 416 |
\def \.#1{{\accent 95 #1}} %~ Dot accent. %^accent |
| 417 |
|
| 418 |
\def \=#1{{\accent 22 #1}} %~ Macron accent. %^accent |
| 419 |
|
| 420 |
\def \^#1{{\accent 94 #1}} %~ Circumflex accent. %^accent |
| 421 |
|
| 422 |
\def \`#1{{\accent 18 #1}} %~ Grave accent. %^accent |
| 423 |
|
| 424 |
\def \~#1{{\accent "7E #1}} %~ Tilde accent. %^accent |
| 425 |
|
| 426 |
\def \b #1{% %~ Bar-under accent. %^accent |
| 427 |
\ozalign{\relax #1\cr |
| 428 |
\hidewidth \vbox to .2ex {\hbox{\char 22}\vss}\hidewidth}} |
| 429 |
|
| 430 |
\def \c #1{% %~ Cedilla accent. %^accent |
| 431 |
\setbox \zboxa = \hbox{#1}% |
| 432 |
\if \dimeqlp{\ht\zboxa}{1ex}% |
| 433 |
\accent 24 #1% |
| 434 |
\else |
| 435 |
{\ooalign{\hidewidth \char 24 \hidewidth \cr |
| 436 |
\unhbox \zboxa}}% |
| 437 |
\fi} |
| 438 |
|
| 439 |
\def \d #1{% %~ Dot-under accent. %^accent |
| 440 |
\ozalign{\relax #1\cr |
| 441 |
\hidewidth.\hidewidth}} |
| 442 |
|
| 443 |
\def \g #1{% %~ Ogonek accent. %^accent |
| 444 |
\setbox \zboxa = \hbox{#1}% |
| 445 |
\if \dimeqlp{\ht\zboxa}{1ex}% |
| 446 |
\accent 154 #1% |
| 447 |
\else |
| 448 |
{\ooalign{\hidewidth \char 154 \hidewidth \cr |
| 449 |
\unhbox \zboxa}}% |
| 450 |
\fi} |
| 451 |
|
| 452 |
\def \H #1{{\accent "7D #1}} %~ Long Hungarian umlaut accent. %^accent |
| 453 |
|
| 454 |
\def \r #1{{\accent "17 #1}} %~ Ring accent. %^accent |
| 455 |
|
| 456 |
\def \t #1{% %~ Tie-after accent. %^accent |
| 457 |
{\edef \znext {\the\font}\the\textfont1 \accent "7F \znext #1}} |
| 458 |
|
| 459 |
\def \u #1{{\accent 21 #1}} %~ Breve accent. %^accent |
| 460 |
|
| 461 |
\def \v #1{{\accent 20 #1}} %~ Hacek accent. %^accent |
| 462 |
|
| 463 |
% Spaces |
| 464 |
% ------ |
| 465 |
|
| 466 |
|
| 467 |
% TeX space primitives include the following: |
| 468 |
% |
| 469 |
% <space> Produce a normal space, obeying \spacefactor. |
| 470 |
% \<space> Produce a normal space as if \spacefactor = 1000. |
| 471 |
|
| 472 |
% Here are a set of "space" commands that produce breakable space: |
| 473 |
|
| 474 |
%~ Specified amount of breakable horizontal space. |
| 475 |
|
| 476 |
\def \hspace #1{\ensurepar \hskip #1\relax}% {amount} %^hspace |
| 477 |
|
| 478 |
%~ Specified amount of unbreakable horizontal space |
| 479 |
%~ measured in tenths of a point. |
| 480 |
|
| 481 |
\def \h #1;{% tenths-points; %^hspace |
| 482 |
{\tdimena = .1pt |
| 483 |
\tdimena = #1\tdimena |
| 484 |
\kern \tdimena}} |
| 485 |
|
| 486 |
\def \fiveemspace {\ensurepar \hskip 5em\relax} %~ Breakable 5 em space. %^hspace |
| 487 |
|
| 488 |
\def \fouremspace {\ensurepar \hskip 4em\relax} %~ Breakable 4 em space. %^hspace |
| 489 |
|
| 490 |
\def \threeemspace {\ensurepar \hskip 3em\relax} %~ Breakable 3 em space. %^hspace |
| 491 |
|
| 492 |
\def \twoemspace {\ensurepar \hskip 2em\relax} %~ Breakable 2 em space. %^hspace |
| 493 |
|
| 494 |
\def \emspace {\ensurepar \hskip 1em\relax} %~ Breakable 1 em space. %^hspace |
| 495 |
|
| 496 |
\def \enspace {\ensurepar \hskip .5em\relax} %~ Breakable 1 en space. %^hspace |
| 497 |
|
| 498 |
\def \digitspace {% %~ Breakable digit space. %^hspace |
| 499 |
{\measuredigitwidth{\tdimena}% |
| 500 |
\ensurepar \hskip \tdimena}} |
| 501 |
|
| 502 |
{\catcode`\| = \catactive |
| 503 |
\gdef \digitspacebar {% |
| 504 |
\catcode`\| = \catactive |
| 505 |
\def |{\digitspace}} |
| 506 |
} |
| 507 |
|
| 508 |
\def \thirdspace {\ensurepar \hskip .333em\relax} %~ Breakable 1/3 em space. %^hspace |
| 509 |
\let \thickspace = \thirdspace |
| 510 |
\def \negthickspace {\ensurepar \hskip -.333em\relax} %~ Breakable negative 1/3 em space. %^hspace |
| 511 |
|
| 512 |
\def \space { } %~ Normal space. |
| 513 |
\def \^^M{\ } %~ Normal space. |
| 514 |
|
| 515 |
\def \fontspace {\ensurepar \hskip \fontdimen2\font} %~ Breakable font space. %^hspace |
| 516 |
|
| 517 |
\def \visiblespace {% %~ Visible space. %^hspace |
| 518 |
\ensurepar |
| 519 |
\hbox {% |
| 520 |
\measurespacewidth{\tdimena}% |
| 521 |
\kern .16ex |
| 522 |
\llap{\rule{width .08ex height .15ex depth .2ex}}% |
| 523 |
\lower .2ex \hbox{\rule{width \tdimena height .08ex depth 0pt}}% |
| 524 |
\rlap{\rule{width .08ex height .15ex depth .2ex}}% |
| 525 |
\kern .16ex}} |
| 526 |
|
| 527 |
\def \fourthspace {\ensurepar \hskip .25em\relax} %~ Breakable 1/4 em space. %^hspace |
| 528 |
|
| 529 |
\def \fifthspace {\ensurepar \hskip .2em\relax} %~ Breakable 1/5 em space. %^hspace |
| 530 |
\let \thinspace = \fifthspace |
| 531 |
\def \negfifthspace {\ensurepar \hskip -.2em\relax} %~ Breakable negative 1/3 em space. %^hspace |
| 532 |
\let \negthinspace = \negfifthspace |
| 533 |
|
| 534 |
\def \sixthspace {\ensurepar \hskip .16667em\relax} %~ Breakable 1/6 em space. %^hspace |
| 535 |
\def \negsixthspace {\ensurepar \hskip -.16667em\relax} %~ Breakable negative 1/6 em space. %^hspace |
| 536 |
|
| 537 |
\def \seventhspace {\ensurepar \hskip .14286em\relax} %~ Breakable 1/7 em space. %^hspace |
| 538 |
\let \hairspace = \seventhspace |
| 539 |
\def \negseventhspace {\ensurepar \hskip -.14286em\relax} %~ Breakable negative 1/7 em space. %^hspace |
| 540 |
|
| 541 |
\def \qqqqquad {\unbreakable\fiveemspace} %~ Unbreakable 5 em space. %^hspace |
| 542 |
\def \qqqquad {\unbreakable\fouremspace} %~ Unbreakable 4 em space. %^hspace |
| 543 |
\def \qqquad {\unbreakable\threeemspace} %~ Unbreakable 3 em space. %^hspace |
| 544 |
\def \qquad {\unbreakable\twoemspace} %~ Unbreakable 2 em space. %^hspace |
| 545 |
\def \quad {\unbreakable\emspace} %~ Unbreakable 1 em space. %^hspace |
| 546 |
\def \nut {\unbreakable\enspace} %~ Unbreakable 1 en space. %^hspace |
| 547 |
|
| 548 |
%~ Unbreakable 1/3 em space. |
| 549 |
|
| 550 |
\def \;{\relax\if \mathmodep \mthickspace \else \unbreakable\thickspace \fi} %^hspace |
| 551 |
|
| 552 |
%~ Unbreakable 1/5 em space. |
| 553 |
|
| 554 |
\def \,{\relax\if \mathmodep \mthinspace \else \unbreakable\thinspace \fi} %^hspace |
| 555 |
|
| 556 |
%~ Unbreakable negative 1/5 em space. |
| 557 |
|
| 558 |
\def \!{\relax\if \mathmodep \mnegthinspace \else \unbreakable\negthinspace\fi} %^hspace |
| 559 |
|
| 560 |
\def \+{\unbreakable\hairspace} %~ Unbreakable 1/7 em space. %^hspace |
| 561 |
|
| 562 |
%~ Specified amount of unbreakable horizontal space |
| 563 |
%~ measured in hundredths of an em. |
| 564 |
|
| 565 |
\def \k #1;{% hundredths-em; %^hspace |
| 566 |
{\tdimena = .01em |
| 567 |
\tdimena = #1\tdimena |
| 568 |
\kern \tdimena}} |
| 569 |
|
| 570 |
%~ This command retains horizontal space at the beginning of a line. |
| 571 |
%~ Such space is normally discarded. |
| 572 |
|
| 573 |
\def \retain {\vrule height 0pt depth 0pt width 0pt\relax} %^hspace |
| 574 |
|
| 575 |
%~ This declaration causes spaces to be "obeyed," so that every space |
| 576 |
%~ in the source is relevent. |
| 577 |
|
| 578 |
\def \obeyspaces {% |
| 579 |
\catcode`\ =\catactive} |
| 580 |
|
| 581 |
{\obeyspaces |
| 582 |
\global\let =\ % |
| 583 |
} |
| 584 |
|
| 585 |
% Space Factors |
| 586 |
% ----- ------- |
| 587 |
|
| 588 |
|
| 589 |
% IniTeX sets the space factor code of uppercase letters to 999 so |
| 590 |
% periods after them will not end sentences. That just gives people |
| 591 |
% one more rule to remember. |
| 592 |
|
| 593 |
\sfcode`\A=1000 \sfcode`\B=1000 \sfcode`\C=1000 \sfcode`\D=1000 |
| 594 |
\sfcode`\E=1000 \sfcode`\F=1000 \sfcode`\G=1000 \sfcode`\H=1000 |
| 595 |
\sfcode`\I=1000 \sfcode`\J=1000 \sfcode`\K=1000 \sfcode`\L=1000 |
| 596 |
\sfcode`\M=1000 \sfcode`\N=1000 \sfcode`\O=1000 \sfcode`\P=1000 |
| 597 |
\sfcode`\Q=1000 \sfcode`\R=1000 \sfcode`\S=1000 \sfcode`\T=1000 |
| 598 |
\sfcode`\U=1000 \sfcode`\V=1000 \sfcode`\W=1000 \sfcode`\X=1000 |
| 599 |
\sfcode`\Y=1000 \sfcode`\Z=1000 |
| 600 |
|
| 601 |
% A few characters should not affect the space factor. |
| 602 |
|
| 603 |
\sfcode`\'=0 |
| 604 |
\sfcode`\)=0 |
| 605 |
\sfcode`\]=0 |
| 606 |
|
| 607 |
|
| 608 |
\def \setsentencespacing #1{% {flag} |
| 609 |
\if #1% |
| 610 |
\sfcode`\. = 2250 |
| 611 |
\sfcode`\? = 2250 |
| 612 |
\sfcode`\! = 2250 |
| 613 |
\sfcode`\: = 2000 |
| 614 |
\else |
| 615 |
\sfcode`\. = 1000 |
| 616 |
\sfcode`\? = 1000 |
| 617 |
\sfcode`\! = 1000 |
| 618 |
\sfcode`\: = 1000 |
| 619 |
\fi |
| 620 |
\relax} |
| 621 |
|
| 622 |
% Numbers |
| 623 |
% ------- |
| 624 |
|
| 625 |
|
| 626 |
\let \lcromannumeral = \romannumeral |
| 627 |
|
| 628 |
%~ This command formats an integer as uppercase Roman numerals. |
| 629 |
|
| 630 |
\def \ucromannumeral #1{% {number} |
| 631 |
\uppercase\expandafter{\romannumeral#1}} |
| 632 |
|
| 633 |
%~ This command formats an integer as lowercase letters. |
| 634 |
|
| 635 |
\def \lcletter #1{% {number} |
| 636 |
\ifcase #1% |
| 637 |
0\or a\or b\or c\or d\or e\or f\or g\or h\or i\or j\or k\or l\or m\or |
| 638 |
n\or o\or p\or q\or r\or s\or t\or u\or v\or w\or x\or y\or z\else |
| 639 |
\number#1\fi} |
| 640 |
|
| 641 |
%~ This command formats an integer as uppercase letters. |
| 642 |
|
| 643 |
\def \ucletter #1{% {number} |
| 644 |
\ifcase #1% |
| 645 |
0\or A\or B\or C\or D\or E\or F\or G\or H\or I\or J\or K\or L\or M\or |
| 646 |
N\or O\or P\or Q\or R\or S\or T\or U\or V\or W\or X\or Y\or Z\else |
| 647 |
\number#1\fi} |
| 648 |
|
| 649 |
% Lines |
| 650 |
% ----- |
| 651 |
|
| 652 |
|
| 653 |
\long\def \line #1{% {text} |
| 654 |
\if \vmodep |
| 655 |
{\parfillskip = 0pt |
| 656 |
\noindent #1\retain \par}% |
| 657 |
\else |
| 658 |
\retain #1\tl |
| 659 |
\fi} |
| 660 |
|
| 661 |
\long\def \leftline #1{\line{#1\hfil}}% {text} |
| 662 |
\long\def \rightline #1{\line{\hfil#1}}% {text} |
| 663 |
\long\def \centerline #1{\line{\hfil#1\hfil}}% {text} |
| 664 |
\long\def \spreadline #1#2{\line{{#1}\hfil{#2}}}% {text1}{text2} |
| 665 |
\long\def \centerspreadline #1#2#3{% |
| 666 |
\line{\rlap{#1}\hfil #2\hfil \llap{#3}}}% {text1}{text2}{text3} |
| 667 |
|
| 668 |
|
| 669 |
% This declaration causes line breaks to be "obeyed," so that each |
| 670 |
% results in a paragraph end. |
| 671 |
|
| 672 |
{\catcode`\^^M = \catactive% |
| 673 |
\gdef \obeylines {\catcode`\^^M = \active \let ^^M = \par}% |
| 674 |
} |
| 675 |
|
| 676 |
% Line Breaks |
| 677 |
% ---- ------ |
| 678 |
|
| 679 |
|
| 680 |
\def \linebreak #1{% {penalty} |
| 681 |
\penalty #1\relax} |
| 682 |
|
| 683 |
\def \tl {\break} |
| 684 |
|
| 685 |
\def \nl {% |
| 686 |
\gluevaries{\znlvar}{\leftskip}% |
| 687 |
\if \znlvar \tl \else \hfil \break \fi} |
| 688 |
|
| 689 |
\def \blankline {\ensurepar \nl} |
| 690 |
|
| 691 |
|
| 692 |
% These commands are used to tie text on one line. |
| 693 |
|
| 694 |
\def ~{\nobreak \ } % Unbreakable space (tie). |
| 695 |
|
| 696 |
\def \tie {\ensurepar \hbox} |
| 697 |
|
| 698 |
% Indentation |
| 699 |
% ----------- |
| 700 |
|
| 701 |
|
| 702 |
% Note that this macro just sets \leftskip and \rightskip, and so |
| 703 |
% blows away any \parrag. |
| 704 |
|
| 705 |
\def \setindentation #1#2{% {left}{right} |
| 706 |
\leftskip = #1\relax |
| 707 |
\rightskip = #2\relax} |
| 708 |
|
| 709 |
|
| 710 |
\def \alterindentation #1#2{% {left-delta}{right-delta} |
| 711 |
\leftskip = 1\leftskip |
| 712 |
\advance \leftskip by #1\relax |
| 713 |
\rightskip = 1\rightskip |
| 714 |
\advance \rightskip by #2\relax} |
| 715 |
|
| 716 |
% Text Width |
| 717 |
% ---- ----- |
| 718 |
|
| 719 |
|
| 720 |
% This command must be used AFTER the indentation is established with |
| 721 |
% \setindentation or \alterindentation. |
| 722 |
|
| 723 |
\def \settextwidth #1{% {width} |
| 724 |
\if \dimneqlp{#1}{\naturalwidth}% |
| 725 |
\hsize = #1\relax |
| 726 |
\advance \hsize by \leftskip |
| 727 |
\advance \hsize by \rightskip |
| 728 |
\fi} |
| 729 |
|
| 730 |
% Paragraph Raggedness |
| 731 |
% --------- ---------- |
| 732 |
|
| 733 |
|
| 734 |
% This command must be used AFTER the indentation is established with |
| 735 |
% \setindentation or \alterindentation. |
| 736 |
|
| 737 |
\def \setparrag #1{% {rag-dimen} |
| 738 |
\gluevaries{\zrsvar}{\rightskip}% |
| 739 |
\if \notp{\zrsvar}% |
| 740 |
\tdimena = #1\relax |
| 741 |
\advance \rightskip by 0pt plus \tdimena\relax |
| 742 |
\fi} |
| 743 |
|
| 744 |
\zdeclareeveryvcontext{\setindentation{0pt}{0pt}\setparrag{0pt}} |
| 745 |
|
| 746 |
% Paragraph Shapes |
| 747 |
% --------- ------ |
| 748 |
|
| 749 |
|
| 750 |
\definecount{\zshparct}{0} |
| 751 |
\definecount{\zshparrep}{0} |
| 752 |
\definedimen{\zshpari}{0pt} |
| 753 |
\definedimen{\zshparw}{0pt} |
| 754 |
|
| 755 |
|
| 756 |
\def \nshapepar #1{% {[*repeat1,]indent1,width1,...} |
| 757 |
\if \emptyargp{#1}% |
| 758 |
\error{empshape}{The argument to \string\shapepar cannot be empty}% |
| 759 |
\fi |
| 760 |
\gdef \zshpartoks {}% |
| 761 |
\global\zshparct = 0 |
| 762 |
{\zshapeparc #1,\zmark}% |
| 763 |
\parshape = \zshparct\zshpartoks\relax} |
| 764 |
|
| 765 |
\def \zshapeparc #1#2,#3\zmark{% [*repeat],indent,... |
| 766 |
\if \codeeqlp{#1}{*}% |
| 767 |
\global\zshparrep = #2\relax |
| 768 |
\def \znext {\zshapepare #3\zmark}% |
| 769 |
\else |
| 770 |
\global\zshparrep = 1 |
| 771 |
\def \znext {\zshapepare #1#2,#3\zmark}% |
| 772 |
\fi |
| 773 |
\znext} |
| 774 |
|
| 775 |
\def \zshapepare #1,#2,#3\zmark{% indent,width,... |
| 776 |
\zshapepard #1,\false,\zshpari\zmark |
| 777 |
\global\zshpari = \tdimena |
| 778 |
\zshapepard #2,\true,\zshparw\zmark |
| 779 |
\global\zshparw = \tdimena |
| 780 |
\loop |
| 781 |
\if \posp{\zshparrep}% |
| 782 |
\xdef \zshpartoks {\zshpartoks \space \the\zshpari \space \the\zshparw}% |
| 783 |
\global\increment \zshparct |
| 784 |
\global\decrement \zshparrep |
| 785 |
\repeat |
| 786 |
\if \emptyargp{#3}% |
| 787 |
\let \znext = \relax |
| 788 |
\else |
| 789 |
\def \znext {\zshapeparc #3\zmark}% |
| 790 |
\fi |
| 791 |
\znext} |
| 792 |
|
| 793 |
\def \zshapepard #1#2,#3,#4\zmark{% dimen1 dimen-rest,width?,prev |
| 794 |
\if \codeeqlp{#1}{+}% |
| 795 |
\calculate \tdimena = {#4,+,#2}% |
| 796 |
\else\if \codeeqlp{#1}{-}% |
| 797 |
\calculate \tdimena = {#4,-,#2}% |
| 798 |
\else\if \andp{\codeeqlp{#1}{=}}{#3}% |
| 799 |
\calculate \tdimena = {\hsize,-,\zshpari}% |
| 800 |
\else |
| 801 |
\tdimena = #1#2\relax |
| 802 |
\if \dimeqlp{\tdimena}{\naturalwidth}% |
| 803 |
\calculate \tdimena = {\hsize,-,\zshpari}% |
| 804 |
\fi |
| 805 |
\fi\fi\fi |
| 806 |
\if #3% |
| 807 |
%%% Do we want to adjust the width by \leftskip or \rightskip? |
| 808 |
\fi} |
| 809 |
|
| 810 |
|
| 811 |
%%%\definecount{\zshparct}{0} |
| 812 |
\definedimen{\zshpard}{0pt} |
| 813 |
\definedimen{\zshpare}{0pt} |
| 814 |
|
| 815 |
|
| 816 |
\def \shapepar #1{% {indent1,width1,...} |
| 817 |
\if \emptyargp{#1}% |
| 818 |
\error{empshape}{The argument to \string\shapepar cannot be empty}% |
| 819 |
\fi |
| 820 |
\gdef \zshpartoks {}% |
| 821 |
\global\zshparct = 0 |
| 822 |
{\zshapepara #1,\zmark}% |
| 823 |
\parshape = \zshparct\zshpartoks\relax} |
| 824 |
|
| 825 |
\def \zshapepara #1,#2,#3\zmark{% indent,width,...\zmark |
| 826 |
\zshpard = #1\relax |
| 827 |
\xdef \zshpartoks {\zshpartoks \space \the\zshpard}% |
| 828 |
\zshpare = #2\relax |
| 829 |
\if \dimeqlp{\zshpare}{\naturalwidth}% |
| 830 |
\zshpare = \hsize |
| 831 |
\advance \zshpare by -\zshpard |
| 832 |
\else |
| 833 |
\advance \zshpare by \leftskip |
| 834 |
\advance \zshpare by \rightskip |
| 835 |
\fi |
| 836 |
\xdef \zshpartoks {\zshpartoks \space \the\zshpare}% |
| 837 |
\global\increment \zshparct |
| 838 |
\if \emptyargp{#3}% |
| 839 |
\let \znext = \relax |
| 840 |
\else |
| 841 |
\def \znext {\zshapepara #3\zmark}% |
| 842 |
\fi |
| 843 |
\znext} |
| 844 |
|
| 845 |
|
| 846 |
\def \hangalign #1#2#3{% {indent}{text1}{text2} |
| 847 |
\endgraf |
| 848 |
{\setbox \zboxa = \hbox{#2}% |
| 849 |
\tdimena = \wd\zboxa |
| 850 |
\advance \tdimena by #1\relax |
| 851 |
\shapepar{#1,\naturalwidth,\tdimena,\naturalwidth}% |
| 852 |
\noindent \box\zboxa #3\par}} |
| 853 |
|
| 854 |
\def \hindent #1{% {indent} |
| 855 |
\noindent \hspace{#1}% |
| 856 |
\ignorespaces} |
| 857 |
|
| 858 |
% Adjustments |
| 859 |
% ----------- |
| 860 |
|
| 861 |
|
| 862 |
%~ This page overrides the number of lines in a paragraph. The argument |
| 863 |
%~ specifies the number of lines and should start with a plus or |
| 864 |
%~ minus sign. TeX does not guarantee the change. |
| 865 |
|
| 866 |
\def \overrideparlength #1{% {lines} %^page_makeup |
| 867 |
\looseness = #1\relax} |
| 868 |
|
| 869 |
|
| 870 |
%~ This command is used in the middle of a paragraph, on a line by |
| 871 |
%~ itself, to make an adjustment |
| 872 |
%~ between two lines. A typical use is to force a page break: |
| 873 |
%~ \adjustpar{\fullpagebreak} |
| 874 |
%~ There is no need to put a percent sign (|%|) after the command. |
| 875 |
|
| 876 |
\long\def \adjustpar #1{% {command} %^page_makeup |
| 877 |
\vadjust{#1}% |
| 878 |
\ignorespaces} |
| 879 |
|
| 880 |
|
| 881 |
% This command is used to adjust the title of a chapter, section, etc. |
| 882 |
% The argument looks like `\loc{commands}\loc{commands}...' |
| 883 |
% where each \loc is: |
| 884 |
% \body To adjust the title in the body of the text. |
| 885 |
% \mark To adjust the title in the mark (running heads and feet). |
| 886 |
% \toc To adjust the title in the table of contents. |
| 887 |
|
| 888 |
\def \zadjloc {\body} % Normally, \adjusttitle should adjust body. |
| 889 |
|
| 890 |
\def \adjusttitle #1{% {\loc{commands}...} |
| 891 |
{\def \body ##1{}% |
| 892 |
\def \mark ##1{}% |
| 893 |
\def \toc ##1{}% |
| 894 |
\expandafter\let \zadjloc = \zadjtitleb |
| 895 |
#1}} |
| 896 |
|
| 897 |
\def \zadjtitleb #1{% |
| 898 |
#1% |
| 899 |
\def \znext {#1}% |
| 900 |
\if \tokeqlp{\znext}{\nl}% |
| 901 |
\let \znext = \ignorespaces |
| 902 |
\else |
| 903 |
\let \znext = \relax |
| 904 |
\fi |
| 905 |
\znext} |
| 906 |
|
| 907 |
% These macros use \lspspace so they do the right thing while letterspacing. |
| 908 |
|
| 909 |
\def \titlenl {\adjusttitle{\body{\nl}}\lspspace} |
| 910 |
\def \titletl {\adjusttitle{\body{\tl}}\lspspace} |
| 911 |
\def \tocnl {\adjusttitle{\toc{\nl}}\lspspace} |
| 912 |
\def \toctl {\adjusttitle{\toc{\tl}}\lspspace} |
| 913 |
|
| 914 |
|
| 915 |
% These definitions are used by the new title adjustment scheme, |
| 916 |
% but need to be present even when it is not in use. |
| 917 |
|
| 918 |
\chardef \zadjtitlenone = 0 |
| 919 |
\chardef \zadjtitlebody = 1 |
| 920 |
\chardef \zadjtitlemark = 2 |
| 921 |
\chardef \zadjtitletoc = 3 |
| 922 |
\chardef \zadjtitleminitoc = 4 |
| 923 |
|
| 924 |
\definecount{\zadjtitle}{\zadjtitlebody} |