| 1 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2 |
% |
| 3 |
% Module: ZzTeX Page Facilities |
| 4 |
% |
| 5 |
% Synopsis: This module contains all the user facilities for |
| 6 |
% specifying things about the page layout. It also |
| 7 |
% contains the output routines. |
| 8 |
% |
| 9 |
% Author: Paul C. Anagnostopoulos |
| 10 |
% Created: 7 March 1990 |
| 11 |
% |
| 12 |
% Copyright 1989--2020 by Paul C. Anagnostopoulos |
| 13 |
% under The MIT License (opensource.org/licenses/MIT) |
| 14 |
% |
| 15 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 16 |
|
| 17 |
% Tracing Page Makeup |
| 18 |
% ------- ---- ------ |
| 19 |
|
| 20 |
|
| 21 |
\def \tracepagemakeup #1{% |
| 22 |
\if \posp{\tracingpagemakeup}% |
| 23 |
\writelog{ZzTeX page \the\pagenumber: #1}% |
| 24 |
\fi} |
| 25 |
|
| 26 |
% Initialize Page Parameters |
| 27 |
% ---------- ---- ---------- |
| 28 |
|
| 29 |
|
| 30 |
% Here we assume that the type area width is the same on both pages. |
| 31 |
|
| 32 |
\def \zpageinit {% |
| 33 |
\gcalculate \trimplusbleedheight = {\standardbleed,+,\trimheight,+,% |
| 34 |
\standardbleed}% |
| 35 |
\gcalculate \trimplusbleedwidth = {\standardbleed,+,\trimwidth,+,% |
| 36 |
\standardbleed}% |
| 37 |
\gcalculate \typeareawidth = {\oddlefttextmargin,+,\textmeasure,+,% |
| 38 |
\oddrighttextmargin}% |
| 39 |
\gcalculate \evenoutermargin = {\trimwidth,-,\typeareawidth,-,% |
| 40 |
\eveninnermargin}% |
| 41 |
\gcalculate \evenbleedshift = {-\evenlefttextmargin,-,\evenoutermargin,-,% |
| 42 |
\standardbleed}% |
| 43 |
\gcalculate \oddoutermargin = {\trimwidth,-,\typeareawidth,-,% |
| 44 |
\oddinnermargin}% |
| 45 |
\gcalculate \oddbleedshift = {-\oddlefttextmargin,-,\oddinnermargin,-,% |
| 46 |
\standardbleed}} |
| 47 |
|
| 48 |
% Page Number |
| 49 |
% ---- ------ |
| 50 |
|
| 51 |
|
| 52 |
\countdef \pagenumber = 0 |
| 53 |
|
| 54 |
\declaresnapitem{\pagenumber} |
| 55 |
|
| 56 |
\def \setpagenumber #1{% {number} |
| 57 |
\global\pagenumber = #1\relax |
| 58 |
\setcolumnnumber{1}} |
| 59 |
|
| 60 |
\def \evenpagep {\evenp{\pagenumber}} |
| 61 |
\def \oddpagep {\oddp{\pagenumber}} |
| 62 |
|
| 63 |
\def \folio {} |
| 64 |
|
| 65 |
\def \setfoliostyle #1{% {\style} |
| 66 |
\ztoksa = \expandaftertwice{\name{#1folio}}% |
| 67 |
\xdef \folio {\the\ztoksa}} |
| 68 |
|
| 69 |
\def \chapterpagefolio {\the\chaptercomptext-\number\pagenumber} |
| 70 |
\def \arabicfolio {\number\pagenumber} |
| 71 |
\let \decimalfolio = \arabicfolio |
| 72 |
\def \letterfolio {\ucletter\pagenumber} |
| 73 |
\def \partpagefolio {\the\partcomptext-\number\pagenumber} |
| 74 |
\def \romanfolio {\romannumeral\pagenumber} |
| 75 |
|
| 76 |
% Marks |
| 77 |
% ----- |
| 78 |
|
| 79 |
|
| 80 |
% These macros hold the five parts of the current mark, each part having |
| 81 |
% three subparts. When a part is saved, the first subpart is expanded and |
| 82 |
% the second and third subparts are not. |
| 83 |
|
| 84 |
\definetoks{\zmarki} \zmarki = {{???}{???}{???}} |
| 85 |
\definetoks{\zmarkii} \zmarkii = {{???}{???}{???}} |
| 86 |
\definetoks{\zmarkiii} \zmarkiii = {{???}{???}{???}} |
| 87 |
\definetoks{\zmarkiv} \zmarkiv = {{???}{???}{???}} |
| 88 |
\definetoks{\zmarkv} \zmarkv = {{???}{???}{???}} |
| 89 |
|
| 90 |
|
| 91 |
\def \setmarkinfothree #1#2#3#4{% {part}{text1}{text2}{text3} |
| 92 |
{\tcounta = #1\relax |
| 93 |
\edef \znext {{#2}}% |
| 94 |
\global\name{\zmark\romannumeral\tcounta} = \expandafter{\znext{#3}{#4}}% |
| 95 |
\mark{\noexpand\or \the\zmarki \noexpand\or \the\zmarkii |
| 96 |
\noexpand\or \the\zmarkiii \noexpand\or \the\zmarkiv |
| 97 |
\noexpand\or \the\zmarkv}}% |
| 98 |
\if \vmodep \repeatpenalty \fi} % In case glue follows the mark. |
| 99 |
|
| 100 |
\def \setmarkinfo #1#2#3{% {part}{text1}{text2} |
| 101 |
\setmarkinfothree{#1}{#2}{#3}{???}} |
| 102 |
|
| 103 |
|
| 104 |
\let \firstnewmark = \firstmark |
| 105 |
\let \bottommark = \botmark |
| 106 |
|
| 107 |
\def \markinfo #1#2#3{% {mark}{part}{subpart} |
| 108 |
\ifcase #3% |
| 109 |
\relax |
| 110 |
\or |
| 111 |
\expandafter\zoneofthree |
| 112 |
\ifcase #2\expandafter\relax #1\else {???}{???}{???}\fi |
| 113 |
\or |
| 114 |
\expandafter\ztwoofthree |
| 115 |
\ifcase #2\expandafter\relax #1\else {???}{???}{???}\fi |
| 116 |
\or |
| 117 |
\expandafter\zthreeofthree |
| 118 |
\ifcase #2\expandafter\relax #1\else {???}{???}{???}\fi |
| 119 |
\else |
| 120 |
\error{invsubpart}{The subpart `#3' is invalid}% |
| 121 |
\fi} |
| 122 |
|
| 123 |
% Page Screen |
| 124 |
% ---- ------ |
| 125 |
|
| 126 |
|
| 127 |
\def \fullpagescreen #1{% {color} |
| 128 |
\if \inbackground |
| 129 |
\vskip -\standardbleed |
| 130 |
\moveleft \standardbleed \vbox{% |
| 131 |
\colorrule{#1}{width \trimplusbleedwidth height \trimplusbleedheight}}% |
| 132 |
\else |
| 133 |
\hrule width 0pt |
| 134 |
\vsinkfromtrim{-\standardbleed} |
| 135 |
\smashbox{% |
| 136 |
\colorparrule{#1} |
| 137 |
{\if \evenp{\pagenumber}\evenbleedshift \else \oddbleedshift \fi} |
| 138 |
{width \trimplusbleedwidth height 0pt depth \trimplusbleedheight}}% |
| 139 |
\fi} |
| 140 |
|
| 141 |
% New Headers & Footers Scheme |
| 142 |
% --- ------- - ------- ------ |
| 143 |
|
| 144 |
|
| 145 |
% Most of the definitions are in zzrunner.tex, but these need to be in |
| 146 |
% here so they can be used in design files. |
| 147 |
|
| 148 |
|
| 149 |
\def \headerblindformat {} |
| 150 |
|
| 151 |
\def \footerblindformat {} |
| 152 |
|
| 153 |
\def \headercornermarkformat {% |
| 154 |
\line{\vrule height .5pt depth 0pt width 6pt \hfil |
| 155 |
\vrule height .5pt depth 0pt width 6pt}% |
| 156 |
\nointerlineskip |
| 157 |
\line{\vrule height 6pt depth 0pt width .5pt \hfil |
| 158 |
\vrule height 6pt depth 0pt width .5pt}% |
| 159 |
\vfil} |
| 160 |
|
| 161 |
\def \footercornermarkformat {% |
| 162 |
\vfil |
| 163 |
\line{\vrule height 6pt depth 0pt width .5pt \hfil |
| 164 |
\vrule height 6pt depth 0pt width .5pt}% |
| 165 |
\nointerlineskip |
| 166 |
\line{\vrule height .5pt width 6pt \hfil |
| 167 |
\vrule height .5pt width 6pt}} |
| 168 |
|
| 169 |
% Old Headers & Footers Scheme |
| 170 |
% --- ------- - ------- ------ |
| 171 |
|
| 172 |
|
| 173 |
\def \zcurheader{\normalheader} |
| 174 |
\def \zcurfooter{\normalfooter} |
| 175 |
|
| 176 |
\setflag \zoverrunners = \false |
| 177 |
\let \zsaveheader = \relax |
| 178 |
\let \zsavefooter = \relax |
| 179 |
|
| 180 |
|
| 181 |
\def \setrunners #1#2{% {header}{footer} |
| 182 |
\if \zoverrunners |
| 183 |
\gdef \zsaveheader {#1}% |
| 184 |
\gdef \zsavefooter {#2}% |
| 185 |
\else |
| 186 |
\gdef \zcurheader {#1}% |
| 187 |
\gdef \zcurfooter {#2}% |
| 188 |
\fi} |
| 189 |
|
| 190 |
\def \overriderunners #1#2{% {header}{footer} |
| 191 |
\if \notp{\zoverrunners}% |
| 192 |
\global\let \zsaveheader = \zcurheader |
| 193 |
\global\let \zsavefooter = \zcurfooter |
| 194 |
\global\setflag \zoverrunners = \true |
| 195 |
\fi |
| 196 |
\gdef \zcurheader {#1}% |
| 197 |
\gdef \zcurfooter {#2}} |
| 198 |
|
| 199 |
\def \blindrunners {% |
| 200 |
\overriderunners{\blindheader}{\blindfooter}} |
| 201 |
|
| 202 |
\def \zsetrunnerstoks #1{% {tokens} |
| 203 |
\expandafter\overriderunners \the#1} |
| 204 |
|
| 205 |
\def \zoverriderunnerstoks #1{% {tokens} |
| 206 |
\expandafter\overriderunners \the#1} |
| 207 |
|
| 208 |
% The following macro is used to initialize the \runners parameter. |
| 209 |
|
| 210 |
\def \zoldrunners #1{% |
| 211 |
\runners = {#1}} |
| 212 |
|
| 213 |
% The following macro is called from the output routine. |
| 214 |
|
| 215 |
\def \znextpagerunners {% |
| 216 |
\if \zoverrunners |
| 217 |
\global\let \zcurheader = \zsaveheader |
| 218 |
\global\let \zcurfooter = \zsavefooter |
| 219 |
\global\setflag \zoverrunners = \false |
| 220 |
\fi} |
| 221 |
|
| 222 |
|
| 223 |
% The following macros provide some standard, simple header and footer |
| 224 |
% formats. |
| 225 |
|
| 226 |
\def \blindheader {} |
| 227 |
|
| 228 |
\def \blindfooter {} |
| 229 |
|
| 230 |
\def \cornermarkheader {\headercornermarkformat} |
| 231 |
|
| 232 |
\def \cornermarkfooter {\footercornermarkformat} |
| 233 |
|
| 234 |
% The following header and footer formats are provided by the design. |
| 235 |
% Just in case they are forgotten: |
| 236 |
|
| 237 |
\def \normalheader {% |
| 238 |
\warning{noheadfoot}{No normal header format has been specified}} |
| 239 |
\def \normalfooter {% |
| 240 |
\warning{noheadfoot}{No normal footer format has been specified}} |
| 241 |
\def \chapterheader {% |
| 242 |
\warning{noheadfoot}{No chapter header format has been specified}} |
| 243 |
\def \chapterfooter {% |
| 244 |
\warning{noheadfoot}{No chapter footer format has been specified}} |
| 245 |
|
| 246 |
% Multiple Columns |
| 247 |
% -------- ------- |
| 248 |
|
| 249 |
|
| 250 |
% The following parameters are calculated by the \setpagecolumns command: |
| 251 |
|
| 252 |
\setflag \zdofullbreak = \false % True if doing a full break. |
| 253 |
\setflag \zusetypewidth = \false % True if using type area width. |
| 254 |
|
| 255 |
\definecount{\columncount}{0} % Number of columns on page. |
| 256 |
\definecount{\columnnumber}{0} % Current column number. |
| 257 |
% \hsize |
| 258 |
% \vsize |
| 259 |
|
| 260 |
|
| 261 |
% The \setpagecolumns command accepts the following options: |
| 262 |
% |
| 263 |
% \fullbreak |
| 264 |
% \shortbreak |
| 265 |
% \usetextmeasure |
| 266 |
% \usetextwidth |
| 267 |
% \usetypewidth |
| 268 |
|
| 269 |
\def \setpagecolumns #1#2#3{% {options}{columns}{gutter-width} |
| 270 |
\endgraf |
| 271 |
{\def \fullbreak {\global\setflag \zdofullbreak = \true}% |
| 272 |
\def \shortbreak {\global\setflag \zdofullbreak = \false}% |
| 273 |
\def \usetextmeasure {\global\setflag \zutw = \false}% |
| 274 |
\def \usetextwidth {\global\setflag \zutw = \false}% |
| 275 |
\def \usetypewidth {\global\setflag \zutw = \true}% |
| 276 |
\global\setflag \zdofullbreak = \false |
| 277 |
\global\setflag \zutw = \false |
| 278 |
#1}% |
| 279 |
\if \andp{\zusetypewidth}{\notp{\zutw}}% |
| 280 |
\zejectcolpage |
| 281 |
\else\if \onep{\columncount}% |
| 282 |
\if \orp{\gtrp{#2}{1}}{\zutw}\penalty \zpenoneton \fi |
| 283 |
\else\if \neqlp{#2}{\columncount}% |
| 284 |
\zejectcolpage |
| 285 |
\fi\fi\fi |
| 286 |
\global\columncount = #2\relax |
| 287 |
\global\setflag \zusetypewidth = \zutw |
| 288 |
\tdimena = \if \zusetypewidth \typeareawidth \else \textmeasure \fi |
| 289 |
\calculate \tdimenb = {-#3,*,\columncount,+,#3,+,\tdimena,/,\columncount}% |
| 290 |
\settextwidth{\tdimenb}% |
| 291 |
\global\hsize = \hsize % Make these two parameters global. |
| 292 |
\global\parfillskip = \parfillskip |
| 293 |
\setcolumnnumber{1}% |
| 294 |
\tracepagemakeup{Columns: \the\columncount; width: \the\hsize; gutter: #3.}} |
| 295 |
|
| 296 |
\def \zejectcolpage {% |
| 297 |
\if \zdofullbreak |
| 298 |
\freshpage{\full\floats\any}% |
| 299 |
\else |
| 300 |
\freshpage{\short\floats\any}% |
| 301 |
\fi |
| 302 |
\global\vsize = \textareaheight} % Needed even if no page eject. |
| 303 |
|
| 304 |
|
| 305 |
\def \setcolumnnumber #1{% {number} |
| 306 |
\global\columnnumber = #1\relax |
| 307 |
\if \andp{\oddpagep}{\lastcolumnp}% |
| 308 |
\global\brokenpenalty = \oddbrokenpenalty |
| 309 |
\else |
| 310 |
\global\brokenpenalty = \evenbrokenpenalty |
| 311 |
\fi} |
| 312 |
|
| 313 |
\def \firstcolumnp {\eqlp{\columnnumber}{1}} |
| 314 |
\def \lastcolumnp {\eqlp{\columnnumber}{\columncount}} |
| 315 |
|
| 316 |
|
| 317 |
%----------------------------------------------------------------------------- |
| 318 |
% |
| 319 |
% This old command is deprecated, although it will work forever. |
| 320 |
|
| 321 |
|
| 322 |
\def \setcolumns #1#2#3{% {count}{gutter-width}{use-type-area} |
| 323 |
\endgraf |
| 324 |
\if \andp{\zusetypewidth}{\notp{#3}}% |
| 325 |
\freshpage{\short\floats\any}% |
| 326 |
\global\vsize = \textareaheight % Needed even if no page eject. |
| 327 |
\else \if \eqlp{\columncount}{1}% |
| 328 |
\if \orp{\gtrp{#1}{1}}{#3}% |
| 329 |
\penalty \zpenoneton |
| 330 |
\fi |
| 331 |
\else \if \neqlp{#1}{\columncount}% |
| 332 |
\freshpage{\short\floats\any}% |
| 333 |
\global\vsize = \textareaheight % Needed even if no page eject. |
| 334 |
\fi\fi\fi |
| 335 |
\global\columncount = #1\relax |
| 336 |
\global\setflag \zusetypewidth = #3\relax |
| 337 |
{\zpageinit |
| 338 |
\tdimena = #2\relax |
| 339 |
\multiply \tdimena by \columncount |
| 340 |
\advance \tdimena by -#2\relax |
| 341 |
\if \zusetypewidth |
| 342 |
\advance \tdimena by -\typeareawidth |
| 343 |
\else |
| 344 |
\advance \tdimena by -\textmeasure |
| 345 |
\fi |
| 346 |
\divide \tdimena by -\columncount |
| 347 |
\settextwidth{\tdimena}% |
| 348 |
\global\hsize = \hsize % Make these two parameters global. |
| 349 |
\global\parfillskip = \parfillskip}% |
| 350 |
\setcolumnnumber{1}% |
| 351 |
\tracepagemakeup{Columns: \the\columncount; width: \the\hsize; gutter: #2.}} |
| 352 |
|
| 353 |
% Column Breaks |
| 354 |
% ------ ------ |
| 355 |
|
| 356 |
|
| 357 |
\def \columnbreak #1{% {penalty} |
| 358 |
\penalty #1\relax} |
| 359 |
|
| 360 |
\def \freshcolumn #1{% {options} |
| 361 |
{\let \zfill = \relax |
| 362 |
\let \full = \relax \def \short {\def \zfill {\vfill}}% |
| 363 |
#1\relax% |
| 364 |
\if \notp{\dimzerop{\lastskip}}\vskip -\lastskip \fi |
| 365 |
\zfill |
| 366 |
\penalty \zpenfreshcol}} |
| 367 |
|
| 368 |
\def \fullcolumnbreak {\freshcolumn{\full}} |
| 369 |
\def \shortcolumnbreak {\freshcolumn{\short}} |
| 370 |
|
| 371 |
\def \blankcolumn {% |
| 372 |
\line{}% |
| 373 |
\shortcolumnbreak} |
| 374 |
|
| 375 |
% Page Breaks |
| 376 |
% ---- ------ |
| 377 |
|
| 378 |
|
| 379 |
%~ This command starts a new page. The options specify the |
| 380 |
%~ exact behavior: |
| 381 |
%~ & |\any|& Start an even or odd page. |
| 382 |
%~ & |\even|& Start an even page. |
| 383 |
%~ & |\floats|& Place all floats before new page. |
| 384 |
%~ & |\full|& Current page is bottomed out. |
| 385 |
%~ & |\nofloats|& No need to place all floats. |
| 386 |
%~ & |\odd|& Start an odd page. |
| 387 |
%~ & |\short|& Run current page short. |
| 388 |
%~ &. |
| 389 |
|
| 390 |
\def \freshpage #1{% {options} %^page_makeup |
| 391 |
\if \vmodep |
| 392 |
{\let \zfill = \vfill |
| 393 |
\let \short = \relax \def \full {\let \zfill = \relax}% |
| 394 |
\let \zflush = \zpenfreshpage |
| 395 |
\let \nofloats = \relax \def \floats {\let \zflush = \zpenflushpage}% |
| 396 |
\let \zpage = \relax |
| 397 |
\let \any = \relax |
| 398 |
\def \odd {\def \zpage {\if \evenpagep \blankpage \fi}}% |
| 399 |
\def \even {\def \zpage {\if \oddpagep \blankpage \fi}}% |
| 400 |
#1\relax% |
| 401 |
\if \notp{\dimzerop{\lastskip}}\vskip -\lastskip \fi |
| 402 |
\zfill |
| 403 |
\if \notp{\lastcolumnp}% |
| 404 |
\penalty \zpenfreshcol |
| 405 |
\if \notp{\lastcolumnp}% |
| 406 |
\loop |
| 407 |
\blankcolumn |
| 408 |
\if \notp{\lastcolumnp}\repeat |
| 409 |
\fi |
| 410 |
\line{}% |
| 411 |
\vfill |
| 412 |
\fi |
| 413 |
\penalty \zflush |
| 414 |
\zpage}% |
| 415 |
\else |
| 416 |
\error{pagepar}{Page break requested in the middle of a paragraph}% |
| 417 |
\fi} |
| 418 |
|
| 419 |
%~ This command starts a new page, bottoming out the current page. |
| 420 |
|
| 421 |
\def \fullpagebreak {\freshpage{\full\nofloats\any}} %^page_makeup |
| 422 |
|
| 423 |
%~ This command starts a new page, leaving the current page short. |
| 424 |
%~ The argument specifies the number of lines short, or, if |
| 425 |
%~ specified as |\asap|, runs the page as short as possible. |
| 426 |
|
| 427 |
\def \shortpagebreak #1{% {lines} %^page_makeup |
| 428 |
{\def \zarg {#1}\def \zasap {\asap}% |
| 429 |
\if \tokeqlp{\zarg}{\zasap}% |
| 430 |
\freshpage{\short\nofloats\any}% |
| 431 |
\else |
| 432 |
\kern -\dp\strutbox |
| 433 |
\kern #1\baselineskip |
| 434 |
\fullpagebreak |
| 435 |
\fi}} |
| 436 |
|
| 437 |
\def \blankpage {% |
| 438 |
\blindrunners |
| 439 |
\pagehint{(blank)}% |
| 440 |
\hrule width 0pt |
| 441 |
\freshpage{\short\nofloats\any}} |
| 442 |
|
| 443 |
\def \blankleaf {% |
| 444 |
\freshpage{\short\floats\odd} |
| 445 |
\blankpage |
| 446 |
\freshpage{\short\even} |
| 447 |
\blankpage} |
| 448 |
|
| 449 |
% Overriding Text Area Height |
| 450 |
% ---------- ---- ---- ------ |
| 451 |
|
| 452 |
|
| 453 |
\definedimen{\zortahsave}{0pt} % Saved normal text area height. |
| 454 |
\definecount{\zortahcount}{0} % Number of overridden pages. |
| 455 |
|
| 456 |
|
| 457 |
%~ This command changes the number of lines on the specified number |
| 458 |
%~ of pages, beginning with the current page. The nominal line count |
| 459 |
%~ is increased or decreased by the specified number of lines, |
| 460 |
%~ which should be coded with a plus or minus sign. A fractional |
| 461 |
%~ number of lines is allowed. It is best to change two pages (a spread) |
| 462 |
%~ with each command. |
| 463 |
|
| 464 |
\def \overridetextareaheight #1#2{% {pages}{lines} %^page_makeup |
| 465 |
\if \posp{\zortahcount}% |
| 466 |
\warning{overortah}{Text area height overridden during previous override}% |
| 467 |
\zresetortah |
| 468 |
\fi |
| 469 |
{\global\zortahsave = \textareaheight |
| 470 |
\global\zortahcount = #1\relax |
| 471 |
\global\advance \textareaheight by #2\baselineskip |
| 472 |
\global\vsize = \textareaheight |
| 473 |
\if \dimneqlp{\pagegoal}{\maxdimen}% |
| 474 |
\tdimena = \textareaheight |
| 475 |
\advance \tdimena by -\zortahsave |
| 476 |
\advance \tdimena by \pagegoal |
| 477 |
\global\pagegoal = \tdimena |
| 478 |
\fi}% |
| 479 |
\tracepagemakeup{Overriding text area height: pages: #1, vsize: \the\vsize, |
| 480 |
goal: \the\pagegoal.}} |
| 481 |
|
| 482 |
\def \zresetortah {% |
| 483 |
\global\zortahcount = 0 |
| 484 |
\global\textareaheight = \zortahsave |
| 485 |
\global\vsize = \textareaheight |
| 486 |
%%% \global\pagegoal = \vsize |
| 487 |
\tracepagemakeup{Un-overriding text area height: vsize: \the\vsize.}} |
| 488 |
|
| 489 |
\def \zortahdivfinal {% |
| 490 |
\if \posp{\zortahcount}% |
| 491 |
\warning{divortah}{Text area height overridden across a division}% |
| 492 |
\zresetortah |
| 493 |
\fi} |
| 494 |
|
| 495 |
% Text Margins |
| 496 |
% ---- ------- |
| 497 |
|
| 498 |
|
| 499 |
% The following two macros are really bogus, because TeX doesn't |
| 500 |
% always know what page it's on, except in the output routine. |
| 501 |
|
| 502 |
\def \thislefttextmargin {% |
| 503 |
\if \evenpagep \evenlefttextmargin \else \oddlefttextmargin \fi} |
| 504 |
|
| 505 |
\def \thisrighttextmargin {% |
| 506 |
\if \evenpagep \evenrighttextmargin \else \oddrighttextmargin \fi} |
| 507 |
|
| 508 |
\definedimen{\typeareashift}{0pt} |
| 509 |
\definecount{\ztaspage}{0} |
| 510 |
|
| 511 |
\def \determinetypeareashift #1{% {page} |
| 512 |
\global\typeareashift = \if \evenp{#1}-\evenlefttextmargin \else |
| 513 |
-\oddlefttextmargin \fi} |
| 514 |
|
| 515 |
% Layout Summary |
| 516 |
% ------ ------- |
| 517 |
|
| 518 |
|
| 519 |
{\catcode`\_ = \catactive |
| 520 |
|
| 521 |
\gdef \zlayoutsummary {% |
| 522 |
{\def _{\space}% |
| 523 |
\writelog{}% |
| 524 |
\writelog{Layout:}% |
| 525 |
\writelog{}% |
| 526 |
\tdimena = .013837\trimwidth |
| 527 |
\tdimenb = .013837\trimheight |
| 528 |
\writelog{Trim: \thefactor\tdimena"_x_\thefactor\tdimenb"}% |
| 529 |
\tdimena = .013837\headmargin |
| 530 |
\writelog{Head margin: \thefactor\tdimena"}% |
| 531 |
\tdimena = .083333\typeareawidth |
| 532 |
\tdimenb = .083333\typeareaheight |
| 533 |
\writelog{Type area: \thefactor\tdimena pc_x_\thefactor\tdimenb pc}% |
| 534 |
\tdimena = .013837\eveninnermargin |
| 535 |
\tdimenb = .013837\oddinnermargin |
| 536 |
\writelog{Inside margins: even \thefactor\tdimena", odd \thefactor\tdimenb"}% |
| 537 |
\tdimena = .013837\evenoutermargin |
| 538 |
\tdimenb = .013837\oddoutermargin |
| 539 |
\writelog{Outside margins: even \thefactor\tdimena", odd \thefactor\tdimenb"}% |
| 540 |
\tdimena = .083333\evenlefttextmargin |
| 541 |
\tdimenb = .083333\oddlefttextmargin |
| 542 |
\writelog{Left text margins: even \thefactor\tdimena pc, |
| 543 |
odd \thefactor \tdimenb pc}% |
| 544 |
\tdimena = .083333\evenrighttextmargin |
| 545 |
\tdimenb = .083333\oddrighttextmargin |
| 546 |
\writelog{Right text margins: even \thefactor\tdimena pc, |
| 547 |
odd \thefactor\tdimenb pc}% |
| 548 |
\tdimena = .083333\textmeasure |
| 549 |
\tdimenb = .083333\textareaheight |
| 550 |
\writelog{Text area: \thefactor\tdimena pc_x_\thefactor\tdimenb pc}% |
| 551 |
\writelog{Top skip: \the\topskip, delta: \the\topdelta}% |
| 552 |
\writelog{}}} |
| 553 |
|
| 554 |
}% \catcode |
| 555 |
|
| 556 |
% Debugging |
| 557 |
% --------- |
| 558 |
|
| 559 |
|
| 560 |
\def \zlogoutf {-1} % First page to log. |
| 561 |
\def \zlogoutl {-1} % Last page to log. |
| 562 |
|
| 563 |
|
| 564 |
\def \logoutput #1#2{% {first-page}{last-page} |
| 565 |
\global\def \zlogoutf {#1}% |
| 566 |
\global\def \zlogoutl {#2}} |
| 567 |
|
| 568 |
% Output Routine |
| 569 |
% ------ ------- |
| 570 |
|
| 571 |
|
| 572 |
% The following definitions are for special penalties that control |
| 573 |
% page makeup: |
| 574 |
|
| 575 |
\def \zpennormal {-10000\relax} % Normal page break. |
| 576 |
\def \zpenoneton {-10001\relax} % Switch from 1 to n columns. |
| 577 |
\def \zpenfreshcol {-10002\relax} % Fresh column. |
| 578 |
\def \zpenfreshpage {-10003\relax} % Fresh page. |
| 579 |
\def \zpenflushpage {-10004\relax} % Fresh page, and flush floats. |
| 580 |
\def \zpenfloatpage {-10005\relax} % Page of floats scheduled. |
| 581 |
|
| 582 |
% We need to put the depth of box 255 in a convenient place. |
| 583 |
|
| 584 |
\definedimen{\zoutputcoldepth}{0pt} |
| 585 |
|
| 586 |
% We must save \mathdisplayprevgraf across the output routine. |
| 587 |
|
| 588 |
\definecount{\zsavemdpg}{0} |
| 589 |
|
| 590 |
% The following boxes hold parts of the page: |
| 591 |
|
| 592 |
\definebox{\zcolbox} % One column's worth. |
| 593 |
\definebox{\zbodybox} % The body, multiple columns' worth. |
| 594 |
\definebox{\zonetonbox} % Stuff preceding 1- to n-column switch. |
| 595 |
\setflag \zonetontype = \false % True if 1-to-n text uses type area width. |
| 596 |
|
| 597 |
% This toks register is invoked at the beginning of every column, so that |
| 598 |
% things like index carryovers can be performed. |
| 599 |
|
| 600 |
\definetoks{\everycolumn} |
| 601 |
\everycolumn = {\relax} |
| 602 |
|
| 603 |
|
| 604 |
\output = {\zoutput} |
| 605 |
|
| 606 |
\def \zoutput {% |
| 607 |
\if \andp{\notp{\lssp{\pagenumber}{\zlogoutf}}}% |
| 608 |
{\notp{\gtrp{\pagenumber}{\zlogoutl}}}% |
| 609 |
\tracingoutput = 1 |
| 610 |
\showboxdepth = 1000 \showboxbreadth = 1000\relax |
| 611 |
\fi |
| 612 |
\tracepagemakeup{[Output routine invoked for column \the\columnnumber; |
| 613 |
penalty: \the\outputpenalty.}% |
| 614 |
\tracepagemakeup{Vsize: \the\vsize; |
| 615 |
Box 255: \the\ht255+\the\dp255 \space x \the\wd255.}% |
| 616 |
\zoutputcoldepth = \dp255\relax |
| 617 |
\let \zsavewith = \zwith % Save these items across the |
| 618 |
\let \zsavevariant = \zvariant % output routine in case they |
| 619 |
\zsavemdpg = \mathdisplayprevgraf % are altered within it. |
| 620 |
\normalbaselines |
| 621 |
\let \par = \endgraf |
| 622 |
\everyparagraph = {}% |
| 623 |
\spaceskip = 0pt |
| 624 |
\tcounta = \outputpenalty |
| 625 |
\if \eqlp{\tcounta}{-'10000000000}\tcounta = \zpenflushpage \fi |
| 626 |
\if \gtrp{\tcounta}{-10000}\tcounta = -10000\relax \fi |
| 627 |
\negate \tcounta |
| 628 |
\advance \tcounta by -10000\relax |
| 629 |
\ifcase \tcounta |
| 630 |
\zpagenormal \or |
| 631 |
\zpageoneton \or |
| 632 |
\zpagefreshcol \or |
| 633 |
\zpagefreshpage \or |
| 634 |
\zpageflushpage \or |
| 635 |
\zpagefloatpage \else |
| 636 |
\zzerror{Invalid page break penalty: \the\outputpenalty}% |
| 637 |
\fi |
| 638 |
\global\let \zvariant = \zsavevariant |
| 639 |
\global\let \zwith = \zsavewith |
| 640 |
\global\mathdisplayprevgraf = \zsavemdpg |
| 641 |
\tracepagemakeup{Output routine complete.]}} |
| 642 |
|
| 643 |
\def \zpagenormal {% |
| 644 |
\tracepagemakeup{Process normal column.}% |
| 645 |
\zcolumnsave |
| 646 |
\if \lastcolumnp |
| 647 |
\zpagecontents |
| 648 |
\setcolumnnumber{1}% |
| 649 |
\else |
| 650 |
\tcounta = \columnnumber \increment \tcounta |
| 651 |
\setcolumnnumber{\tcounta}% |
| 652 |
\fi |
| 653 |
\zfloatinit |
| 654 |
\zschedulefloats{\zfloatcount}{\true}{\false}% |
| 655 |
\if \gtrp{\zfloatcount}{99}% |
| 656 |
\zfltpage{\zpenfloatpage}% |
| 657 |
\else |
| 658 |
\zeverycol |
| 659 |
\fi} |
| 660 |
|
| 661 |
\def \zpageoneton {% |
| 662 |
\tracepagemakeup{Process 1- to n-column transition.}% |
| 663 |
\zonetoncolumnbody |
| 664 |
\global\setflag \zonetontype = \zusetypewidth |
| 665 |
\global\advance \vsize by -\ht\zonetonbox |
| 666 |
\global\advance \vsize by -\dp\zonetonbox |
| 667 |
\tracepagemakeup{Space remaining on page: \the\vsize.}} |
| 668 |
|
| 669 |
\def \zpagefreshcol {% |
| 670 |
\tracepagemakeup{Process `fresh column' request.}% |
| 671 |
\zpagenormal} |
| 672 |
|
| 673 |
\def \zpagefreshpage {% |
| 674 |
\tracepagemakeup{Process `fresh page' request.}% |
| 675 |
\zpagenormal} |
| 676 |
|
| 677 |
\def \zpageflushpage {% |
| 678 |
\tracepagemakeup{Process `fresh page, flush floats' request.}% |
| 679 |
\zcolumnsave |
| 680 |
\if \lastcolumnp |
| 681 |
\zpagecontents |
| 682 |
\setcolumnnumber{1}% |
| 683 |
\else |
| 684 |
\tcounta = \columnnumber \increment \tcounta |
| 685 |
\setcolumnnumber{\tcounta}% |
| 686 |
\fi |
| 687 |
\zfloatinit |
| 688 |
\zschedulefloats{\zfloatcount}{\true}{\true}% |
| 689 |
\if \posp{\zfloatcount}% |
| 690 |
\zfltpage{\zpenflushpage}% |
| 691 |
\else |
| 692 |
\zeverycol |
| 693 |
\fi} |
| 694 |
|
| 695 |
\def \zpagefloatpage {% |
| 696 |
\tracepagemakeup{Process page of floats.}% |
| 697 |
\zcolumnsave |
| 698 |
\if \lastcolumnp |
| 699 |
\zpagecontents |
| 700 |
\setcolumnnumber{1}% |
| 701 |
\else |
| 702 |
\tcounta = \columnnumber \increment \tcounta |
| 703 |
\setcolumnnumber{\tcounta}% |
| 704 |
\fi |
| 705 |
\zfloatinit |
| 706 |
\zschedulefloats{\zfloatcount}{\true}{\false}% |
| 707 |
\if \gtrp{\zfloatcount}{99}% |
| 708 |
\zfltpage{\zpenfloatpage}% |
| 709 |
\fi} |
| 710 |
|
| 711 |
\def \zfltpage #1{% {penalty} |
| 712 |
\if \notp{\emptytoksp{\zfltrunners}}% |
| 713 |
\zoverriderunnerstoks{\zfltrunners}% |
| 714 |
\fi |
| 715 |
{\leftskip = 0pt \rightskip = 0pt |
| 716 |
\line{}}% |
| 717 |
\kern -\topskip % Why bother to do this? |
| 718 |
\nobreak \vfill |
| 719 |
\penalty #1} |
| 720 |
|
| 721 |
\def \zeverycol {% |
| 722 |
{\zadjtitle = \zadjtitlemark % \adjusttitle should adjust mark. |
| 723 |
\def \zadjloc {\mark}% |
| 724 |
\the\everycolumn}} |
| 725 |
|
| 726 |
% Page Makeup: Column |
| 727 |
% ---- ------- ------ |
| 728 |
|
| 729 |
|
| 730 |
\def \zcolumnsave {% |
| 731 |
\zcolumnbody |
| 732 |
\if \firstcolumnp |
| 733 |
\global\setbox \zbodybox = \hbox to \zbodyboxwidth {\box\zcolbox \hss}% |
| 734 |
\ztoksa = \expandafter{\topmark}% |
| 735 |
\xdef \topmarki {\the\ztoksa}% |
| 736 |
\ztoksa = \expandafter{\firstnewmark}% |
| 737 |
\xdef \firstnewmarki {\the\ztoksa}% |
| 738 |
\ztoksa = \expandafter{\bottommark}% |
| 739 |
\xdef \bottommarki {\the\ztoksa}% |
| 740 |
\else |
| 741 |
\global\setbox \zbodybox = \hbox to \zbodyboxwidth {% |
| 742 |
\unhbox\zbodybox \hfill \box\zcolbox}% |
| 743 |
\fi} |
| 744 |
|
| 745 |
\def \zbodyboxwidth {% |
| 746 |
\if \zusetypewidth \typeareawidth \else \textmeasure \fi} |
| 747 |
|
| 748 |
\def \zcolumnbody {% |
| 749 |
\tracepagemakeup{Wrapping up the column; hsize: \the\hsize.}% |
| 750 |
{\vbadness = 10000\relax |
| 751 |
\global\setbox \zcolbox = \vbox to \vsize {% |
| 752 |
\setindentation{0pt}{0pt}% |
| 753 |
\boxmaxdepth = \maxdepth |
| 754 |
\if \notp{\voidboxp{\ztopcolinsert}}\unvbox \ztopcolinsert \fi |
| 755 |
\unvbox 255 % Page built by TeX. |
| 756 |
\if \risingfootnotes |
| 757 |
\if \notp{\voidboxp{\zfninsert}}\zfootnoteformat{\zoutputcoldepth}\fi |
| 758 |
\fi |
| 759 |
\if \risingbottomfloats |
| 760 |
\if \notp{\voidboxp{\zbotcolinsert}}\unvbox \zbotcolinsert \fi |
| 761 |
\fi |
| 762 |
\if \raggedbottom |
| 763 |
\kern -\zoutputcoldepth \vfill |
| 764 |
\fi |
| 765 |
\if \notp{\risingfootnotes}% |
| 766 |
\if \notp{\voidboxp{\zfninsert}}\zfootnoteformat{\zoutputcoldepth}\fi |
| 767 |
\fi |
| 768 |
\if \notp{\risingbottomfloats}% |
| 769 |
\if \notp{\voidboxp{\zbotcolinsert}}\unvbox \zbotcolinsert \fi |
| 770 |
\fi}}} |
| 771 |
|
| 772 |
% This is a special version of \zcolumnbody for the 1- to n-column |
| 773 |
% transition. |
| 774 |
|
| 775 |
\def \zonetoncolumnbody {% |
| 776 |
\global\setbox \zonetonbox = \vbox{% |
| 777 |
\setindentation{0pt}{0pt}% |
| 778 |
\boxmaxdepth = \maxdepth |
| 779 |
\if \notp{\voidboxp{\ztopcolinsert}}\unvbox \ztopcolinsert \fi |
| 780 |
\unvbox 255 % Page built by TeX. |
| 781 |
\vskip \baselineskip |
| 782 |
\vskip -\topskip |
| 783 |
% Ignore footnotes. |
| 784 |
% Ignore bottom style. |
| 785 |
% Ignore bottom floats. |
| 786 |
% Don't produce text area bottom rule. |
| 787 |
}} |
| 788 |
|
| 789 |
% Page Makeup: Page |
| 790 |
% ---- ------- ---- |
| 791 |
|
| 792 |
|
| 793 |
\def \zpagecontents {% |
| 794 |
\tracepagemakeup{Shipping out the final page.}% |
| 795 |
\shipout \vbox to \trimheight {% |
| 796 |
\parskip = 0pt \parindent = 0pt |
| 797 |
\setindentation{0pt}{0pt}% |
| 798 |
\zpageheadmargin |
| 799 |
\nointerlineskip |
| 800 |
\zpagetypearea |
| 801 |
\vfil |
| 802 |
\nointerlineskip |
| 803 |
\zpageoverlay}% |
| 804 |
\if \posp{\zortahcount}% % If overriding text area height: |
| 805 |
\global\decrement \zortahcount |
| 806 |
\if \zerop{\zortahcount}\zresetortah \fi |
| 807 |
\fi |
| 808 |
\tcounta = \pagenumber \increment \tcounta |
| 809 |
\setpagenumber{\tcounta}% |
| 810 |
\global\vsize = \textareaheight % In case it was reset for this page. |
| 811 |
\znextpagerunners} |
| 812 |
|
| 813 |
\def \zpagelengthmarks {% |
| 814 |
\tdimena = \headmargin |
| 815 |
\advance \tdimena by \typeareaheight |
| 816 |
\advance \tdimena by -\footerheight |
| 817 |
\vskip \tdimena |
| 818 |
\vbox to 0pt{% |
| 819 |
\hbox to \trimwidth{% |
| 820 |
\llap{\vrule height .5pt width .75pc}\hfil |
| 821 |
\rlap{\vrule height .5pt width .75pc}}% |
| 822 |
\vss} |
| 823 |
\vskip -\tdimena |
| 824 |
\nointerlineskip} |
| 825 |
|
| 826 |
\setflag \inbackground = \false |
| 827 |
|
| 828 |
\def \zpageheadmargin {% |
| 829 |
\vbox to \headmargin {% |
| 830 |
\hrule height 0pt width \trimwidth |
| 831 |
\nointerlineskip |
| 832 |
\smashbox{% |
| 833 |
\setflag \inbackground = \true |
| 834 |
\zcurback}% |
| 835 |
\nointerlineskip |
| 836 |
\vfil |
| 837 |
\zmakeuprule{\trimwidth}{.5pt}}} |
| 838 |
|
| 839 |
\def \zpagetypearea {% |
| 840 |
\if \evenpagep |
| 841 |
\negate \eveninnermargin |
| 842 |
\advance \eveninnermargin by \trimwidth |
| 843 |
\advance \eveninnermargin by -\evenlefttextmargin |
| 844 |
\advance \eveninnermargin by -\textmeasure |
| 845 |
\advance \eveninnermargin by -\evenrighttextmargin |
| 846 |
\fi |
| 847 |
\moveright \if \oddpagep \oddinnermargin \else \eveninnermargin \fi |
| 848 |
\vbox to \typeareaheight {% |
| 849 |
\zadjtitle = \zadjtitlemark % \adjusttitle should adjust mark. |
| 850 |
\def \zadjloc {\mark}% |
| 851 |
\zpageheader |
| 852 |
\nointerlineskip |
| 853 |
\ztextandmargins |
| 854 |
\zmakeuprule{\typeareawidth}{.5pt}% |
| 855 |
\vss % Allows text area height to vary. |
| 856 |
\vbox to \footerheight{% |
| 857 |
\vss |
| 858 |
\zpagefooter}}} |
| 859 |
|
| 860 |
\def \zpageheader {% |
| 861 |
\vbox to \headerheight {% |
| 862 |
\hsize = \typeareawidth |
| 863 |
\zoutputbeginblack |
| 864 |
\zcurheader |
| 865 |
\zoutputendblack |
| 866 |
\vfil |
| 867 |
\zmakeuprule{\typeareawidth}{.5pt}}} |
| 868 |
|
| 869 |
\def \ztextandmargins {% |
| 870 |
\hbox to \typeareawidth {% |
| 871 |
\if \notp{\zusetypewidth}% |
| 872 |
\hbox to \thislefttextmargin{\hss}% |
| 873 |
\fi |
| 874 |
\vbox{% |
| 875 |
\boxmaxdepth = \maxdepth |
| 876 |
\if \andp{\zusetypewidth}{\notp{\zonetontype}}% |
| 877 |
\moveright \thislefttextmargin |
| 878 |
\fi |
| 879 |
\box\zonetonbox |
| 880 |
\nointerlineskip |
| 881 |
\vbox{\box\zbodybox}}% |
| 882 |
\hss}} |
| 883 |
|
| 884 |
\def \zpagefooter {% |
| 885 |
\hsize = \typeareawidth |
| 886 |
\zoutputbeginblack |
| 887 |
\zcurfooter |
| 888 |
\zoutputendblack |
| 889 |
\if \PDFhyperlinks \PDFmark{P:\folio}\fi} |
| 890 |
|
| 891 |
% This macro invokes the page overlay after positioning to the |
| 892 |
% upper-left corner of the trim. |
| 893 |
|
| 894 |
\def \zpageoverlay {% |
| 895 |
\vbox to 0pt{% |
| 896 |
\offinterlineskip |
| 897 |
\kern -\trimheight |
| 898 |
\name{\pageoverlay\the\zoverlay}% |
| 899 |
\vss}} |
| 900 |
|
| 901 |
\def \zmakeuprule #1#2{% {width}{height} |
| 902 |
\if \DVIWindoinuse |
| 903 |
\colorspecial{ifview color push rgb 0 1 0}% |
| 904 |
\tdimena = #1\tcounta = \tdimena |
| 905 |
\tdimena = #2\tcountb = \tdimena |
| 906 |
\special{viewrule: \the\tcounta\space \the\tcountb}% |
| 907 |
\colorspecial{ifview color pop}% |
| 908 |
\fi} |