| 1 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2 |
% |
| 3 |
% Module: ZzTeX Art Facilities |
| 4 |
% |
| 5 |
% Synopsis: This module provides facilities to deal with external art. |
| 6 |
% |
| 7 |
% Author: Paul C. Anagnostopoulos |
| 8 |
% Created: 7 June 1991 |
| 9 |
% |
| 10 |
% Copyright 1989--2020 by Paul C. Anagnostopoulos |
| 11 |
% under The MIT License (opensource.org/licenses/MIT) |
| 12 |
% |
| 13 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 14 |
|
| 15 |
% Art File Root & Placing Control |
| 16 |
% --- ---- ---- - ------- ------- |
| 17 |
|
| 18 |
|
| 19 |
\def \zartroot {} |
| 20 |
\setflag \zplaceart = \true |
| 21 |
|
| 22 |
|
| 23 |
\def \setartroot #1{% {root/} |
| 24 |
\gdef \zartroot {#1}} |
| 25 |
|
| 26 |
\def \zprependartroot #1#2{% {\name}{filespec} |
| 27 |
\edef #1{\zartroot#2}} |
| 28 |
|
| 29 |
\def \placeart #1{% |
| 30 |
\setflag \zplaceart = #1} |
| 31 |
|
| 32 |
% Imported Art |
| 33 |
% -------- --- |
| 34 |
|
| 35 |
|
| 36 |
\defineblock{\art}{\endart}{\false}{} |
| 37 |
|
| 38 |
%~block art Type |
| 39 |
% \abovepenalty = integer % Penalty above block. |
| 40 |
% \aboveskip = glue % Space b/b above block. |
| 41 |
% \belowpenalty = integer % Penalty below block. |
| 42 |
% \belowskip = glue % Space b/b below block. |
| 43 |
% \setflag \cliptobb = flag % Clip art to its bounding box? |
| 44 |
% \hfuzz = dimen % Horizontal fuzz. |
| 45 |
% \hscale = dimen % Horizontal scale (in points). |
| 46 |
% \leftindent = glue % Left indentation. |
| 47 |
% \rightindent = glue % Right indentation. |
| 48 |
% \vscale = dimen % Vertical scale (in points). |
| 49 |
% \vshift = dimen % Vertical shift. |
| 50 |
%~end |
| 51 |
|
| 52 |
\definedimen{\artwidth}{0pt} |
| 53 |
\definedimen{\artheight}{0pt} |
| 54 |
\definedimen{\hscale}{0pt} |
| 55 |
\definedimen{\vscale}{0pt} |
| 56 |
|
| 57 |
|
| 58 |
%~ The format of the *file-info* argument is: |
| 59 |
%~ *file*,*width*,*height*,*scale*[,*gutter*,*file*,...]&/ |
| 60 |
%~ The *file* is a file name preceded by |!| or |=|. |
| 61 |
|
| 62 |
\def \art #1#2{% {type}{file-info} |
| 63 |
\beginblockscope{art}% |
| 64 |
\global\increment \artdepth |
| 65 |
\abovepenalty = \breakgood %~default hard |
| 66 |
\belowpenalty = \breakgood %~default hard |
| 67 |
\setflag \cliptobb = \false %~default soft |
| 68 |
\hfuzz = 1pt %~default soft |
| 69 |
\hscale = 1.0pt %~default hard |
| 70 |
\vscale = 1.0pt %~default hard |
| 71 |
\vshift = \mindimen %~default soft |
| 72 |
\processdesign{\art}{#1}% |
| 73 |
\global\increment \artnumber |
| 74 |
\global\artwidth = 0pt |
| 75 |
\global\artheight = 0pt |
| 76 |
\artformat{#2}% |
| 77 |
\endart} |
| 78 |
|
| 79 |
\def \endart {% |
| 80 |
\global\decrement \artdepth |
| 81 |
\endblockscope{art}} |
| 82 |
|
| 83 |
\def \artformat #1{% {info} |
| 84 |
\endgraf |
| 85 |
\bbskipabove{\abovepenalty}{\aboveskip}% |
| 86 |
\alterindentation{\leftindent}{\rightindent}% |
| 87 |
\noindent \zbldartline 0pt,#1,\zmark \endgraf |
| 88 |
\prevdepth = 0pt % Nothing better to do. |
| 89 |
\bbskipbelow{\belowpenalty}{\belowskip}} |
| 90 |
|
| 91 |
\def \zbldartline #1,#2,#3,#4,#5,#6\zmark{% gutter,file,width,height,scale,...,\zmark |
| 92 |
\zbuildartlineb{#1}{#2}{#3}{#4}{#5}% |
| 93 |
\zwriteartinfo{#2}{#3}{#4}{#5}% |
| 94 |
\if \notp{\emptyargp{#6}}\zbldartline #6\zmark \fi} |
| 95 |
|
| 96 |
% Place Art File |
| 97 |
% ----- --- ---- |
| 98 |
|
| 99 |
|
| 100 |
\definedimen{\zleftslop}{0pt} |
| 101 |
\definedimen{\zrightslop}{0pt} |
| 102 |
\definedimen{\ztopslop}{0pt} |
| 103 |
\definedimen{\zbottomslop}{0pt} |
| 104 |
\definedimen{\zartwidth}{0pt} |
| 105 |
\definedimen{\zartheight}{0pt} |
| 106 |
\definedimen{\zartscale}{0pt} |
| 107 |
|
| 108 |
|
| 109 |
\def \zbuildartlineb #1#2#3#4#5{% {gutter}{file}{width}{height}{scale} |
| 110 |
\kern #1\relax |
| 111 |
\zparseartfile #2,0pt,0pt,0pt,0pt,\zmark |
| 112 |
\zchkartfile{\zgotart}% |
| 113 |
\zcalcartdimens{#3}{#4}{#5}% |
| 114 |
\zbuildartlinec{\zartfile}% |
| 115 |
\gcalculate \artwidth = {\artwidth,+,#1,+,\zartwidth}% |
| 116 |
\if \dimgtrp{\zartheight}{\artheight}\global\artheight = \zartheight \fi} |
| 117 |
|
| 118 |
\def \zparseartfile #1,#2,#3,#4,#5,#6\zmark{% spec,left,right,top,bottom\zmark |
| 119 |
\zparseartspec #1.eps.\zmark |
| 120 |
\zleftslop = #2% |
| 121 |
\zrightslop = #3% |
| 122 |
\ztopslop = #4% |
| 123 |
\zbottomslop = #5\relax} |
| 124 |
|
| 125 |
\def \zcalcartdimens #1#2#3{% {width}{height}{scale} |
| 126 |
\if \orp{\andp{\dimzerop{#1}}{\dimzerop{#2}}} |
| 127 |
{\forceepsbb}% |
| 128 |
\if \zgotart |
| 129 |
\zreadepsbb{\zartwidth}{\zartheight}{\zartfile}% |
| 130 |
\else |
| 131 |
\zartwidth = 20pc \zartheight = 10pc |
| 132 |
\fi |
| 133 |
\else |
| 134 |
\calculate \zartwidth = {#1,-,\zleftslop,-,\zrightslop}% |
| 135 |
\calculate \zartheight = {#2,-,\ztopslop,-,\zbottomslop}% |
| 136 |
\fi |
| 137 |
\zcalcartscale #3\zmark |
| 138 |
\calculate \zartwidth = {\zartwidth,S,\zartscale,S,\hscale}% |
| 139 |
\calculate \zartheight = {\zartheight,S,\zartscale,S,\vscale}% |
| 140 |
\calculate \zleftslop = {\zleftslop,S,\zartscale,S,\hscale}% |
| 141 |
\calculate \zbottomslop = {\zbottomslop,S,\zartscale,S,\vscale}% |
| 142 |
\if \forceepsbb |
| 143 |
\advance \zleftslop by \zbbxorigin |
| 144 |
\advance \zbottomslop by \zbbyorigin |
| 145 |
\fi} |
| 146 |
|
| 147 |
\def \zcalcartscale #1#2\zmark{% scale\zmark |
| 148 |
\if \codeeqlp{#1}{=}% |
| 149 |
\if \emptyargp{#2}% |
| 150 |
\calculate \zartscale = {\hsize,R,\zartwidth}% |
| 151 |
\else |
| 152 |
\calculate \zartscale = {#2,R,\zartwidth}% |
| 153 |
\fi |
| 154 |
\else |
| 155 |
\calculate \zartscale = {#1#2pt,/,100}% |
| 156 |
\fi} |
| 157 |
|
| 158 |
\def \zbuildartlinec #1{% {title} |
| 159 |
\if \dimeqlp{\vshift}{\mindimen}% |
| 160 |
\measureascenderheight{\vshift}% |
| 161 |
\fi |
| 162 |
\vtop {% % Place art in a vbox. |
| 163 |
\offinterlineskip |
| 164 |
\rule{height \vshift width 0pt}% % Force the height of the |
| 165 |
\kern -\vshift % box to match ascenders. |
| 166 |
\rule{height 0pt width \zartwidth}% % Force the width of the box. |
| 167 |
\if \andp{\zplaceart}{\zgotart}% |
| 168 |
\rule{height 0pt depth \zartheight width 0pt}% % Force its depth. |
| 169 |
\zplaceartfile |
| 170 |
\vss |
| 171 |
\else |
| 172 |
\vbox to \zartheight{% % Force its depth. |
| 173 |
\topcornermarks{\zartwidth}{.5pc}{.25pt}% |
| 174 |
\vss |
| 175 |
\hbox to \zartwidth {\hss \zannofont #1\hss}% |
| 176 |
\hbox to \zartwidth {\hss \zannofont |
| 177 |
\if \notp{\zplaceart}[not placing]\fi |
| 178 |
\if \notp{\zgotart}[to come]\fi |
| 179 |
\hss}% |
| 180 |
\vss |
| 181 |
\bottomcornermarks{\zartwidth}{.5pc}{.25pt}}% |
| 182 |
\fi}} |
| 183 |
|
| 184 |
\def \zplaceartfile {% |
| 185 |
\kern \zbottomslop |
| 186 |
\moveleft \zleftslop \vbox{% |
| 187 |
\special{CTM: push}% |
| 188 |
\special{CTM: scale \thefactor\hscale \space \thefactor\vscale}% |
| 189 |
\specialplaceepsfile{\zartfile}{\zartscale}{\cliptobb}% |
| 190 |
\special{CTM: pop}}% |
| 191 |
\kern -\zbottomslop} |
| 192 |
|
| 193 |
% Duplicates and Missing Art |
| 194 |
% ---------- --- ------- --- |
| 195 |
|
| 196 |
|
| 197 |
% Write an art entry into the cross-reference file. |
| 198 |
|
| 199 |
\def \zwriteartinfo #1#2#3#4{% {file}{width}{height}{scale} |
| 200 |
\zbeginhidewrite |
| 201 |
\edef \znext {\noexpand\xref{art}{\noexpand\folio}% |
| 202 |
{#1}% |
| 203 |
{#2,#3} |
| 204 |
{#4}}% |
| 205 |
\znext |
| 206 |
\zendhidewrite} |
| 207 |
|
| 208 |
% This macro is invoked by \xref. In copy mode, it checks to make sure |
| 209 |
% that no art file is used twice. |
| 210 |
|
| 211 |
\def \xrefart #1#2#3#4{% {page}{number}{title}{tag} |
| 212 |
\ifnum \xrefmode=\xrefcopymode |
| 213 |
\zxrefarta #2,\zmark |
| 214 |
\fi} |
| 215 |
|
| 216 |
\def \zxrefarta #1#2,#3\zmark{% |
| 217 |
\if \notp{\orp{\codeeqlp{#1}{!}}{\codeeqlp{#1}{=}}}% |
| 218 |
\if \definedp{\zart:#1#2}% |
| 219 |
\warning{dupart}{Art file `#1#2' is used more than once in the book}% |
| 220 |
\fi |
| 221 |
\withname\gdef{\zart:#1#2}{}% |
| 222 |
\fi} |
| 223 |
|
| 224 |
% This macro is invoked at the end of the run. |
| 225 |
|
| 226 |
\def \zmissingartmsg {% |
| 227 |
\if \posp{\zmissingart}% |
| 228 |
\remark{Number of missing art files in this run: \number\zmissingart.}% |
| 229 |
\fi} |
| 230 |
|
| 231 |
% Built-In Art Blocks |
| 232 |
% -------- --- ------ |
| 233 |
|
| 234 |
\def \fullpagegraphic #1{% {art-spec} |
| 235 |
\vsinkfromtrim{-\standardbleed} |
| 236 |
\smashbox{% |
| 237 |
\with{\hfuzz=99pc% |
| 238 |
\leftindent=\if \evenpagep \evenbleedshift \else \oddbleedshift \fi} |
| 239 |
\art{graphic}{#1}}} |
| 240 |
|
| 241 |
\def \artgraphicdesign {% |
| 242 |
\aboveskip = \noskip |
| 243 |
\belowskip = \noskip |
| 244 |
\setflag \cliptobb = \false |
| 245 |
\hfuzz = 1pt |
| 246 |
\leftindent = 0pt |
| 247 |
\rightindent = 0pt |
| 248 |
\vshift = 0pt} |
| 249 |
|
| 250 |
% Glyph Definitions |
| 251 |
% ----- ----------- |
| 252 |
|
| 253 |
|
| 254 |
% This macro allows the user to define a "glyph," which is an EPS file |
| 255 |
% that is treated like a fancy character. The bounding box must be |
| 256 |
% perfect. |
| 257 |
|
| 258 |
\def \defineglyph #1#2#3{% {\name}{spec,width,height,scale}{raise} |
| 259 |
\gdef #1{\zglyph #2,#3\zmark}} |
| 260 |
|
| 261 |
\def \zglyph #1,#2,#3,#4,#5\zmark{% spec,width,height,scale,raise\zmark |
| 262 |
{\zparseartspec #1.eps.\zmark |
| 263 |
\zchkartfile{\zgotart}% |
| 264 |
\zartwidth = #2% |
| 265 |
\zartheight = #3% |
| 266 |
\tdimena = #4\typesize % \tdimena = final scale in points. |
| 267 |
\divide \tdimena by 10 |
| 268 |
\calculate \zartwidth = {\zartwidth,P,\thefactor\tdimena}% |
| 269 |
\calculate \zartheight = {\zartheight,P,\thefactor\tdimena}% |
| 270 |
\raise #5 \hbox to \zartwidth{% |
| 271 |
\rule{height \zartheight depth 0pt width 0pt}% |
| 272 |
\if \zgotart |
| 273 |
\specialplaceglyph{\zartfile}{\tdimena}{\false}% |
| 274 |
\fi |
| 275 |
\hfil}}} |
| 276 |
|
| 277 |
\defineglyph{\acidfree}{!acidfree,2pc,2pc,35}{-1.5pt} |
| 278 |
|
| 279 |
% Panel Label Block |
| 280 |
% ----- ----- ----- |
| 281 |
|
| 282 |
|
| 283 |
\defineblock{\panellabel}{\endpanellabel}{\false}{} |
| 284 |
|
| 285 |
%~block panellabel Type |
| 286 |
% \aboveskip = glue % Space b/b above block. |
| 287 |
% \belowskip = glue % Space b/b below block. |
| 288 |
% \bodyfont = {...} % Font for text. |
| 289 |
% \style = {...} % Label style. |
| 290 |
% \vshift = dimen % Vertical shift. |
| 291 |
%~end |
| 292 |
|
| 293 |
\def \panellabel #1#2{% {type}{label-list} |
| 294 |
\beginblockscope{panellabel}% |
| 295 |
\global\increment \panellabeldepth |
| 296 |
\style = {letter in parens}% %~default soft |
| 297 |
\vshift = 0pt %~default soft |
| 298 |
\processdesign{\panellabel}{#1}% |
| 299 |
\global\increment \panellabelnumber |
| 300 |
\panellabelformat{#2}% |
| 301 |
\endpanellabel} |
| 302 |
|
| 303 |
\def \endpanellabel {% |
| 304 |
\global\decrement \panellabeldepth |
| 305 |
\endblockscope{panellabel}} |
| 306 |
|
| 307 |
\def \panellabelformat #1{% {panel-list} |
| 308 |
\endgraf |
| 309 |
\bbskipabove{\breaknever}{\aboveskip}% |
| 310 |
\the\bodyfont |
| 311 |
\noindent |
| 312 |
\zdolabel #1,\zmark |
| 313 |
\endgraf |
| 314 |
\bbskipbelow{\breakallowed}{\belowskip}} |
| 315 |
|
| 316 |
\def \zdolabel #1,#2,#3\zmark{% shift,label,... |
| 317 |
\rlap{% |
| 318 |
\hspace{#1}% |
| 319 |
\smash{\lower \vshift \hbox{#2}}}% |
| 320 |
\if \notp{\emptyargp{#3}}\zdolabel #3\zmark \fi} |
| 321 |
|
| 322 |
% Frames |
| 323 |
% ------ |
| 324 |
|
| 325 |
|
| 326 |
\defineblock{\frame}{\endframe}{\false}{} |
| 327 |
|
| 328 |
%~block frame Type |
| 329 |
% \abovepenalty = integer % Penalty above block. |
| 330 |
% \aboveskip = glue % Space b/b above block. |
| 331 |
% \def \backgroundformat ##1{...} % Background formatter. |
| 332 |
% \belowpenalty = integer % Penalty below block. |
| 333 |
% \belowskip = glue % Space b/b below block. |
| 334 |
% \deferredparams = {...} % Deferred parameter calculations. |
| 335 |
% \framecolor = {color} % Color of frame. |
| 336 |
% \framewidths = {left,right,top,bot} % Widths of frame segments. |
| 337 |
% \framegaps = {left,right,top,bot} % Gaps between frame and material. |
| 338 |
% \leftindent = glue % Left indentation of enclosed material. |
| 339 |
% \screencolor = {color} % Background screen color. |
| 340 |
% \width = dimen % Width of enclosed material. |
| 341 |
%~end |
| 342 |
|
| 343 |
% Together, \leftindent and \width specify the position of the enclosed |
| 344 |
% text within the text box, not of the frame itself. |
| 345 |
|
| 346 |
|
| 347 |
\definetoks{\deferredparams} |
| 348 |
\definetoks{\framecolor} |
| 349 |
\definetoks{\framewidths} |
| 350 |
\definetoks{\framegaps} |
| 351 |
\definetoks{\screencolor} |
| 352 |
|
| 353 |
\definecount{\framepage}{0} |
| 354 |
|
| 355 |
\definecount{\zdivframecounter}{0} |
| 356 |
|
| 357 |
\def \frame #1{% {type} |
| 358 |
\beginblockscope{frame}% |
| 359 |
\global\increment \framedepth |
| 360 |
\global\increment \zdivframecounter |
| 361 |
\whichpage{\framepage}{zE:\the\divisionname-\the\zdivframecounter}% |
| 362 |
\abovepenalty = \breakgood %~default hard |
| 363 |
\def \backgroundformat ##1{}% %~default soft |
| 364 |
\belowpenalty = \breakgood %~default hard |
| 365 |
\deferredparams = {}% %~default soft |
| 366 |
\framecolor = {black}% %~default soft |
| 367 |
\leftindent = 0pt %~default soft |
| 368 |
\screencolor = {}% %~default soft |
| 369 |
\width = \naturalwidth %~default soft |
| 370 |
\processdesign{\frame}{#1}% |
| 371 |
\global\increment \framenumber |
| 372 |
\setbox\zboxa = \vtop \bgroup |
| 373 |
\zpushvcontext} |
| 374 |
|
| 375 |
\def \endframe {% |
| 376 |
\endgraf |
| 377 |
\unskip |
| 378 |
\zpopvcontext |
| 379 |
\egroup % \vtop |
| 380 |
\the\deferredparams |
| 381 |
\setbox\zboxb = \hbox to \width{% |
| 382 |
\hspace{-\leftindent}\box\zboxa \hss}% |
| 383 |
\edef \zcolorrule {\noexpand\colorrule{\the\framecolor}}% |
| 384 |
\def \zarga ##1,##2,##3,##4\zmark{##1\relax}% |
| 385 |
\def \zargb ##1,##2,##3,##4\zmark{##2\relax}% |
| 386 |
\def \zargc ##1,##2,##3,##4\zmark{##3\relax}% |
| 387 |
\def \zargd ##1,##2,##3,##4\zmark{##4\relax}% |
| 388 |
\tdimenc = \expandafter\zargc\the\framegaps\zmark |
| 389 |
\advance \tdimenc by \ht\zboxb |
| 390 |
\advance \tdimenc by \dp\zboxb |
| 391 |
\advance \tdimenc by \expandafter\zargd\the\framegaps\zmark |
| 392 |
\setbox\zboxa = \vtop {% |
| 393 |
\offinterlineskip |
| 394 |
\measureascenderheight{\tdimena}% % Force the height of the |
| 395 |
\rule{width 0pt height \tdimena}% % box to match ascenders. |
| 396 |
\kern -\tdimena |
| 397 |
\smashbox{\backgroundformat{\tdimenc}}% |
| 398 |
\if \notp{\emptytoksp{\screencolor}}% |
| 399 |
\tdimend = \expandafter\zarga\the\framegaps\zmark |
| 400 |
\advance \tdimend by \wd\zboxb |
| 401 |
\advance \tdimend by \expandafter\zargb\the\framegaps\zmark |
| 402 |
\smashbox{% |
| 403 |
%%% \moveright \expandafter\zarga\the\framewidths\zmark \smashbox{% |
| 404 |
\colorrule{\the\screencolor}{width \tdimend height \tdimenc}}% |
| 405 |
\fi |
| 406 |
\zcolorrule{height \expandafter\zargc\the\framewidths\zmark}% |
| 407 |
\kern -\expandafter\zargc\the\framewidths\zmark |
| 408 |
\hbox {% |
| 409 |
\rlap{\zcolorrule{height \tdimenc |
| 410 |
width \expandafter\zarga\the\framewidths\zmark}}% |
| 411 |
\hskip \expandafter\zarga\the\framegaps\zmark |
| 412 |
\vbox {% |
| 413 |
\vskip \expandafter\zargc\the\framegaps\zmark |
| 414 |
\box\zboxb |
| 415 |
\vskip \expandafter\zargd\the\framegaps\zmark}% |
| 416 |
\hskip \expandafter\zargb\the\framegaps\zmark |
| 417 |
\llap{\zcolorrule{height \tdimenc |
| 418 |
width \expandafter\zargb\the\framewidths\zmark}}}% |
| 419 |
\kern -\expandafter\zargd\the\framewidths\zmark |
| 420 |
\zcolorrule{height \expandafter\zargd\the\framewidths\zmark}% |
| 421 |
\tagpageonly{\uniquetag{zE}{\the\zdivframecounter}}}% |
| 422 |
\advance \leftindent by -\expandafter\zarga\the\framewidths\zmark |
| 423 |
\advance \leftindent by -\expandafter\zarga\the\framegaps\zmark |
| 424 |
\frameformat |
| 425 |
\global\decrement \framedepth |
| 426 |
\endblockscope{frame}} |
| 427 |
|
| 428 |
\def \frameformat {% |
| 429 |
\bbskipabove{\abovepenalty}{\aboveskip}% |
| 430 |
\hindent{\leftindent} \rlap{\box\zboxa}\par |
| 431 |
\prevdepth = 0pt % Last thing in box is rule. |
| 432 |
\bbskipbelow{\belowpenalty}{\belowskip}} |
| 433 |
|
| 434 |
% This macro is invoked at the beginning of each division. |
| 435 |
|
| 436 |
\def \zframedivinit {% |
| 437 |
\global\zdivframecounter = 0\relax} |
| 438 |
|
| 439 |
% Margin Rules |
| 440 |
% ------ ----- |
| 441 |
|
| 442 |
|
| 443 |
\defineblock{\marginrule}{\endmarginrule}{\false}{} |
| 444 |
|
| 445 |
%~block marginrule Type |
| 446 |
% \artspec = {...} % Art spec for graphic above rule. |
| 447 |
% \leftshift = dimen % Horizontal shift for rule in left margin. |
| 448 |
% \position = {...} % Position options. |
| 449 |
% \rightshift = dimen % Horizonal shift for rule in right margin. |
| 450 |
% \rulecolor = {...} % Color of rule. |
| 451 |
% \rulewidth = dimen % Width of rule. |
| 452 |
% \vshift = dimen % Vertical shift for note. |
| 453 |
%~end |
| 454 |
|
| 455 |
\definetoks{\artspec} |
| 456 |
\definedimen{\leftshift}{0pt} |
| 457 |
\definedimen{\rightshift}{0pt} |
| 458 |
|
| 459 |
\definecount{\marginrulepage}{0} |
| 460 |
|
| 461 |
\definecount{\zdivmrcounter}{0} |
| 462 |
\definedimen{\zmrshift}{0pt} |
| 463 |
\definedimen{\zmrprevdepth}{0pt} |
| 464 |
|
| 465 |
\def \marginrule #1#2{% {type}{height,depth} |
| 466 |
\blockcantbein{\marginrule}{\marginrule}% |
| 467 |
\beginblockscope{marginrule}% |
| 468 |
\global\increment \marginruledepth |
| 469 |
\global\increment \zdivmrcounter |
| 470 |
\whichpage{\marginrulepage}{zR:\the\divisionname-\the\zdivmrcounter}% |
| 471 |
\rulecolor = {black} %~default soft |
| 472 |
\vshift = 0pt %~default soft |
| 473 |
\processdesign{\marginrule}{#1}% |
| 474 |
\zparsemrpos{\the\position}% |
| 475 |
\marginruleformat{#2}% |
| 476 |
\endmarginrule} |
| 477 |
|
| 478 |
\def \endmarginrule {% |
| 479 |
\global\decrement \marginruledepth |
| 480 |
\endblockscope{marginrule}} |
| 481 |
|
| 482 |
\def \marginruleformat #1{% {height,depth} |
| 483 |
\if \vmodep |
| 484 |
\zmrprevdepth = \prevdepth |
| 485 |
\nointerlineskip |
| 486 |
\else |
| 487 |
\vadjust |
| 488 |
\fi |
| 489 |
\bgroup |
| 490 |
\topskip = 0pt |
| 491 |
\moveright \zmrshift \vtop to 0pt{% |
| 492 |
\vskip \vshift |
| 493 |
\zmrgraphic |
| 494 |
\zmrrule #1\zmark |
| 495 |
\vss |
| 496 |
\tagpageonly{\uniquetag{zR}{\the\zdivmrcounter}}}% |
| 497 |
\egroup |
| 498 |
\if \vmodep \prevdepth = \zmrprevdepth \fi} |
| 499 |
|
| 500 |
% This macro sets up variables that specify the position of a margin rule |
| 501 |
% according to the \position design parameter: |
| 502 |
% |
| 503 |
% \ifevenpage Use next position only on even page. |
| 504 |
% \ifoddpage Use next position only on odd page. |
| 505 |
% \leftmargin Shift note to left margin. |
| 506 |
% \outsidemargin Shift note to outside margin. |
| 507 |
% \rightmargin Shift note to right margin. |
| 508 |
|
| 509 |
\definecount{\zmrhpos}{0} |
| 510 |
|
| 511 |
\def \zparsemrpos #1{% {options...} |
| 512 |
\global\zmrhpos = 0 |
| 513 |
{\def \ifevenpage ##1{\if \evenp{\marginrulepage}##1\fi}% |
| 514 |
\def \ifoddpage ##1{\if \oddp{\marginrulepage}##1\fi}% |
| 515 |
\def \leftmargin {\global\zmrhpos=1\relax}% |
| 516 |
\def \outsidemargin{\ifevenpage{\leftmargin}\ifoddpage{\rightmargin}}% |
| 517 |
\def \rightmargin {\global\zmrhpos=2\relax}% |
| 518 |
#1\relax}% |
| 519 |
\ifcase \zmrhpos |
| 520 |
\error{nomrpos} |
| 521 |
{No horizontal position has been specified for a margin rule}% |
| 522 |
\or |
| 523 |
\if \negp{\leftshift}% |
| 524 |
\zmrshift = \leftshift |
| 525 |
\else |
| 526 |
\if \evenp{\marginrulepage}% |
| 527 |
\calculate \zmrshift = {-\evenlefttextmargin,+,\leftshift}% |
| 528 |
\else |
| 529 |
\calculate \zmrshift = {-\oddlefttextmargin,+,\leftshift}% |
| 530 |
\fi |
| 531 |
\fi |
| 532 |
\or |
| 533 |
\calculate \zmrshift = {\textmeasure,+,\rightshift}% |
| 534 |
\fi} |
| 535 |
|
| 536 |
\def \zmrgraphic {% |
| 537 |
\if \emptytoksp{\artspec}% |
| 538 |
\artheight = 0pt |
| 539 |
\else |
| 540 |
\xdef \znext {\noexpand\art{zmarginrule}{\the\artspec}}% |
| 541 |
\znext |
| 542 |
\kern -1pt |
| 543 |
\fi} |
| 544 |
|
| 545 |
\definedimen{\zmrdepth}{0pt} |
| 546 |
|
| 547 |
\def \zmrrule #1,#2\zmark{% height,depth\zmark |
| 548 |
\calculate \zmrdepth = {#2,-,\artheight}% |
| 549 |
\setbox \zboxa = \hbox{\vrule width 0pt height #1 depth \zmrdepth}% |
| 550 |
\vskip -\ht\zboxa |
| 551 |
\colorrule{\the\rulecolor}{width \rulewidth height #1 depth \zmrdepth}} |
| 552 |
|
| 553 |
\def \artzmarginruledesign {% |
| 554 |
\aboveskip = \noskip |
| 555 |
\belowskip = \noskip |
| 556 |
\setflag \cliptobb = \false |
| 557 |
\hfuzz = 999pc |
| 558 |
\leftindent = 0pt |
| 559 |
\rightindent = 0pt |
| 560 |
\vshift = \mindimen} |
| 561 |
|
| 562 |
% This macro is invoked at the beginning of each division. |
| 563 |
|
| 564 |
\def \zmrdivinit {% |
| 565 |
\global\zdivmrcounter = 0\relax} |
| 566 |
|
| 567 |
% Corner Marks |
| 568 |
% ------ ----- |
| 569 |
|
| 570 |
|
| 571 |
\def \topcornermarks #1#2#3{% {box-width}{length}{thickness} |
| 572 |
\hbox to #1{\vrule height #3 depth 0pt width #2 \hss |
| 573 |
\vrule height #3 depth 0pt width #2}% |
| 574 |
\nointerlineskip |
| 575 |
\hbox to #1{\vrule height #2 depth 0pt width #3 \hss |
| 576 |
\vrule height #2 depth 0pt width #3}} |
| 577 |
|
| 578 |
\def \bottomcornermarks #1#2#3{% {box-width}{length}{thickness} |
| 579 |
\hbox to #1{\vrule height #2 depth 0pt width #3 \hss |
| 580 |
\vrule height #2 depth 0pt width #3}% |
| 581 |
\nointerlineskip |
| 582 |
\hbox to #1{\vrule height #3 depth 0pt width #2 \hss |
| 583 |
\vrule height #3 depth 0pt width #2}} |
| 584 |
|
| 585 |
% Utilities |
| 586 |
% --------- |
| 587 |
|
| 588 |
|
| 589 |
\definecount{\zmissingart}{0} % Count of missing art files. |
| 590 |
|
| 591 |
|
| 592 |
% Check that the art file exists and issue remark if not. |
| 593 |
|
| 594 |
\def \zchkartfile #1{% {\flag} |
| 595 |
\setflag #1= \true |
| 596 |
\checkfile{\znext}{\zartfile}% |
| 597 |
\if \notp{\znext}% |
| 598 |
\remark{Art file `\zartfile' is missing; ignored for now}% |
| 599 |
\global\increment \zmissingart |
| 600 |
\setflag #1= \false |
| 601 |
\fi} |
| 602 |
|
| 603 |
\def \zparseartspec #1#2.#3.#4\zmark{% name.ext.\zmark |
| 604 |
\def \zartfile {???}% % Why do this? |
| 605 |
\if \codeeqlp{#1}{!}% |
| 606 |
\def \zartfile{#2.#3}% |
| 607 |
\else\if \codeeqlp{#1}{=}% |
| 608 |
\zprependartroot{\zartfile}{#2.#3}% |
| 609 |
\else |
| 610 |
\zprependartroot{\zartfile}{#1#2.#3}% |
| 611 |
\fi\fi} |