1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649
|
%
% %%%%%%% %%%%% %%%%%% %%%%% % %
% % % % % % % % % %
% % % % % % % % % %
% %%%%%%% %%%%% %%%%%% % % %
% % % % % % % % %
% % % % % % % % %
% % %%%%%% %%%%%% %%%%% % %
%
% By Jean Orloff
% Comments & suggestions by e-mail: ORLOFF@surya11.cern.ch
% No modification of this file allowed if not e-sent to me.
%
% WHAT IS IT:
% psbox is a set of machine-independent TeX macros to
% 1) allow (Encapsulated) PostScript figure inclusion in all versions
% of TeX (Plain, LaTeX) on all machines using a PostScript printer
% 2) facilitate the communication (e-mail, ftp, ...) of all the files
% (text, macros, figs) needed to reproduce a TeX document by grouping
% them together into a single, TeXable file.
% For more info, get the file pub/TeX/psbox/PSBOXALL.TEX by anonymous
% ftp from cs.nyu.edu(=128.122.140.24)
%
% History:
% 1.34 \readfilename=final fix for all filename scans; try \psforptips
% 1.33: corrects \psnewinput for LaTeX (still fails if fname=a{b}c)
% 1.32: corrects \psfordvialw and adds .TEX to PSBOXALL(!)
% 1.31: adds \psfordvialw(?)
% 1.30: adds \splitfile & \joinfiles for multi-file management
% 1.24: fix error handling & add \psonlyboxes
% 1.22: makes \drawingBox \global for use in Phyzzx
% 1.21: accepts %%BoundingBox: (atend)
% 1.20: tries to add \psfordvitps for the TeXPS package.
% 1.10: adds \psforoztex, error handling...
%2345678 1 2345678 2 2345678 3 2345678 4 2345678 5 2345678 6 2345678 7 23456789
%
% Checking version no to avoid multiple loadings
\def\temp{1.34}%
\let\tempp=\relax
\expandafter\ifx\csname psboxversion\endcsname\relax
\message{PSBOX(\temp) loading}%
\else
\ifdim\temp cm>\psboxversion cm
\message{PSBOX(\temp) loading}%
\else
\message{PSBOX(\psboxversion) is already loaded: I won't load
PSBOX(\temp)!}%
\let\temp=\psboxversion
\let\tempp=\endinput
\fi
\fi
\tempp
\let\psboxversion=\temp
\catcode`\@=11
% Every macro likes a little privacy...
%
%Trying to tame the variety of \special commands for Postscript: the
% universal internal command \PSspeci@l##1##2 takes ##1 to be the
% filename and ##2 to be the integer scale factor*1000 (as for usual
% TeX \scale commands)
%
\def\psfortextures{% For TeXtures on the Macintosh
%-----------------
\def\PSspeci@l##1##2{%
\special{illustration ##1\space scaled ##2}%
}}%
\def\psfordvitops{% For the DVItoPS converter on IBM mainframes
%----------------
\def\PSspeci@l##1##2{%
\special{dvitops: import ##1\space \the\drawingwd \the\drawinght}%
}}%
\def\psfordvips{% For DVIPS converter on VAX, UNIX and PC's
%--------------
\def\PSspeci@l##1##2{%
% \special{/@scaleunit 1000 def}% never read dox without trying!
\d@my=0.1bp \d@mx=\drawingwd \divide\d@mx by\d@my% BUG! for large \drawingwd
\special{PSfile=##1\space llx=\psllx\space lly=\pslly\space%
urx=\psurx\space ury=\psury\space rwi=\number\d@mx
}}}%
\def\psforoztex{% For the OzTeX shareware on the Macintosh
%--------------
\def\PSspeci@l##1##2{%
\special{##1 \space
##2 1000 div dup scale
\number-\psllx\space \number-\pslly\space translate
}}}%
\def\psfordvitps{% From the UNIX TeXPS package, vers.>3.12
%---------------
% Convert a dimension into the number \psn@sp (in scaled points)
\def\psdimt@n@sp##1{\d@mx=##1\relax\edef\psn@sp{\number\d@mx}}
\def\PSspeci@l##1##2{%
% psfig.psr contains the def of "startTexFig": if you can locate it
% and include the correct pathname, it should work
\special{dvitps: Include0 "psfig.psr"}% contains def of "startTexFig"
\psdimt@n@sp{\drawingwd}
\special{dvitps: Literal "\psn@sp\space"}
\psdimt@n@sp{\drawinght}
\special{dvitps: Literal "\psn@sp\space"}
\psdimt@n@sp{\psllx bp}
\special{dvitps: Literal "\psn@sp\space"}
\psdimt@n@sp{\pslly bp}
\special{dvitps: Literal "\psn@sp\space"}
\psdimt@n@sp{\psurx bp}
\special{dvitps: Literal "\psn@sp\space"}
\psdimt@n@sp{\psury bp}
\special{dvitps: Literal "\psn@sp\space startTexFig\space"}
\special{dvitps: Include1 "##1"}
\special{dvitps: Literal "endTexFig\space"}
}}%
\def\psfordvialw{% Try for dvialw, a UNIX public domain
%---------------
\def\PSspeci@l##1##2{
\special{language "PostScript",
position = "bottom left",
literal " \psllx\space \pslly\space translate
##2 1000 div dup scale
-\psllx\space -\pslly\space translate",
include "##1"}
}}%
\def\psforptips{% For MS-DOS; LUOMA@brandeis.bitnet
%---------------
\def\PSspeci@l##1##2{{
\d@mx=\psurx bp
\advance \d@mx by -\psllx bp
\divide \d@mx by 1000\multiply\d@mx by \xscale
\incm{\d@mx}
\let\tmpx\dimincm
\d@my=\psury bp
\advance \d@my by -\pslly bp
\divide \d@my by 1000\multiply\d@my by \xscale
\incm{\d@my}
\let\tmpy\dimincm
\d@mx=-\psllx bp
\divide \d@mx by 1000\multiply\d@mx by \xscale
\d@my=-\pslly bp
\divide \d@my by 1000\multiply\d@my by \xscale
\at(\d@mx;\d@my){\special{ps:##1 x=\tmpx, y=\tmpy}}
}}}%
\def\psonlyboxes{% Draft-like behaviour if none of the others works
%---------------
\def\PSspeci@l##1##2{%
\at(0cm;0cm){\boxit{\vbox to\drawinght
{\vss\hbox to\drawingwd{\at(0cm;0cm){\hbox{({\tt##1})}}\hss}}}}
}}%
\def\psloc@lerr#1{%
\let\savedPSspeci@l=\PSspeci@l%
\def\PSspeci@l##1##2{%
\at(0cm;0cm){\boxit{\vbox to\drawinght
{\vss\hbox to\drawingwd{\at(0cm;0cm){\hbox{({\tt##1}) #1}}\hss}}}}
\let\PSspeci@l=\savedPSspeci@l% restore normal output for other figs!
}}%
%\def\psfor... add your own!
%
% Some common defs
%
\newread\pst@mpin
\newdimen\drawinght\newdimen\drawingwd
\newdimen\psxoffset\newdimen\psyoffset
\newbox\drawingBox
\newcount\xscale \newcount\yscale \newdimen\pscm\pscm=1cm
\newdimen\d@mx \newdimen\d@my
\newdimen\pswdincr \newdimen\pshtincr
\let\ps@nnotation=\relax
{\catcode`\|=0 |catcode`|\=12 |catcode`|%=12 |catcode`~=12
|catcode`#=12 |catcode`*=14
|xdef|backslashother{\}*
|xdef|percentother{%}*
|xdef|tildeother{~}*
|xdef|sharpother{#}*
}%
% useful to display special chars in \tt; fails for \,#,%
\def\R@moveMeaningHeader#1:->{}%
\def\uncatcode#1{%
\edef#1{\expandafter\R@moveMeaningHeader\meaning#1}}%
%
\def\execute#1{#1}% NOT stupid: cs in #1 are then identified BEFORE execution
\def\psm@keother#1{\catcode`#112\relax}% borrowed from latex
\def\executeinspecs#1{%
\execute{\begingroup\let\do\psm@keother\dospecials\catcode`\^^M=9#1\endgroup}}%
\def\@mpty{}%
% \if\matchin#1#2<=> \iftrue if #1 contains #2, <=>\iffalse otherwise:
% \if\matchexpin: idem, but #1 & #2 are first fully expanded (no \if
% inside!)
% \tmpa & \tmpb contain what's before and after the occurence of #2
\def\matchexpin#1#2{
\fi%
%\message{(#1>#2)}
\edef\tmpb{{#2}}%
\expandafter\makem@tchtmp\tmpb%
\edef\tmpa{#1}\edef\tmpb{#2}%
\expandafter\expandafter\expandafter\m@tchtmp\expandafter\tmpa\tmpb\endm@tch%
\if\match%
}%
\def\matchin#1#2{%
\fi%
\makem@tchtmp{#2}%
\m@tchtmp#1#2\endm@tch%
\if\match%
}%
\def\makem@tchtmp#1{\def\m@tchtmp##1#1##2\endm@tch{%
\def\tmpa{##1}\def\tmpb{##2}\let\m@tchtmp=\relax%
\ifx\tmpb\@mpty\def\match{YN}%
\else\def\match{YY}\fi%
}}%
% converts any dimen in cm, with 1E-4 cm precision
\def\incm#1{{\psxoffset=1cm\d@my=#1
\d@mx=\d@my
\divide\d@mx by \psxoffset
\xdef\dimincm{\number\d@mx.}
\advance\d@my by -\number\d@mx cm
\multiply\d@my by 100
\d@mx=\d@my
\divide\d@mx by \psxoffset
\edef\dimincm{\dimincm\number\d@mx}
\advance\d@my by -\number\d@mx cm
\multiply\d@my by 100
\d@mx=\d@my
\divide\d@mx by \psxoffset
\xdef\dimincm{\dimincm\number\d@mx}
}}%
%
% \ReadPSize{PSfilename} reads the dimensions of a PostScript drawing
% and stores it in \drawinght(wd)
\newif\ifNotB@undingBox
\newhelp\PShelp{Proceed: you'll have a 5cm square blank box instead of
your graphics (Jean Orloff).}%
\def\s@tsize#1 #2 #3 #4\@ndsize{
\def\psllx{#1}\def\pslly{#2}%
\def\psurx{#3}\def\psury{#4}% needed by a crazyness of dvips!
\ifx\psurx\@mpty\NotB@undingBoxtrue% this is not a valid one!
\else
\drawinght=#4bp\advance\drawinght by-#2bp
\drawingwd=#3bp\advance\drawingwd by-#1bp
% !Units related by crazy factors as bp/pt=72.27/72 should be BANNED!
\fi
}%
\def\sc@nBBline#1:#2\@ndBBline{\edef\p@rameter{#1}\edef\v@lue{#2}}%
\def\g@bblefirstblank#1#2:{\ifx#1 \else#1\fi#2}%
{\catcode`\%=12
\xdef\B@undingBox{%%BoundingBox}}%
%% is not a true comment in PostScript, even if % is!
\def\ReadPSize#1{
\readfilename#1\relax
\let\PSfilename=\lastreadfilename
\openin\pst@mpin=#1\relax
\ifeof\pst@mpin \errhelp=\PShelp
\errmessage{I haven't found your postscript file (\PSfilename)}%
\psloc@lerr{was not found}%
\s@tsize 0 0 142 142\@ndsize
\closein\pst@mpin
\else
% each entry in \GlobalInputList should be unique
\if\matchexpin{\GlobalInputList}{, \lastreadfilename}%
\else\xdef\GlobalInputList{\GlobalInputList, \lastreadfilename}%
\immediate\write\psbj@inaux{\lastreadfilename,}%
\fi%
\loop
\executeinspecs{\catcode`\ =10\global\read\pst@mpin to\n@xtline}%
\ifeof\pst@mpin
\errhelp=\PShelp
\errmessage{(\PSfilename) is not an Encapsulated PostScript File:
I could not find any \B@undingBox: line.}%
\edef\v@lue{0 0 142 142:}%
\psloc@lerr{is not an EPSFile}%
\NotB@undingBoxfalse
\else
\expandafter\sc@nBBline\n@xtline:\@ndBBline
\ifx\p@rameter\B@undingBox\NotB@undingBoxfalse
\edef\t@mp{%
\expandafter\g@bblefirstblank\v@lue\space\space\space}%
\expandafter\s@tsize\t@mp\@ndsize
\else\NotB@undingBoxtrue
\fi
\fi
\ifNotB@undingBox\repeat
\closein\pst@mpin
\fi
\message{#1}%
}%
%
% \psboxto(xdim;ydim){psfilename}: you specify the dimensions and
% TeX uniformly scales to fit the largest one. If xdim=0pt, the
% scale is fully determined by ydim and vice versa.
% Notice: psboxes are a real vboxes; couldn't take hbox otherwise all
% indentation and all cr's would be interpreted as spaces (hugh!).
%
\def\psboxto(#1;#2)#3{\vbox{
\ReadPSize{#3}%
\divide\drawingwd by 1000
\divide\drawinght by 1000
\d@mx=#1
\ifdim\d@mx=0pt\xscale=1000
\else \xscale=\d@mx \divide \xscale by \drawingwd\fi
\d@my=#2
\ifdim\d@my=0pt\yscale=1000
\else \yscale=\d@my \divide \yscale by \drawinght\fi
\ifnum\yscale=1000
\else\ifnum\xscale=1000\xscale=\yscale
\else\ifnum\yscale<\xscale\xscale=\yscale\fi
\fi
\fi
\divide\pswdincr by 1000 \multiply\pswdincr by \xscale
\divide\pshtincr by 1000 \multiply\pshtincr by \xscale
\divide\psxoffset by1000 \multiply\psxoffset by\xscale
\divide\psyoffset by1000 \multiply\psyoffset by\xscale
\global\divide\pscm by 1000
\global\multiply\pscm by\xscale
\multiply\drawingwd by\xscale \multiply\drawinght by\xscale
\ifdim\d@mx=0pt\d@mx=\drawingwd\fi
\ifdim\d@my=0pt\d@my=\drawinght\fi
\message{scaled \the\xscale}%
\hbox to\d@mx{\hss\vbox to\d@my{\vss
\global\setbox\drawingBox=\hbox to 0pt{\kern\psxoffset\vbox to 0pt{
\kern-\psyoffset
\PSspeci@l{\PSfilename}{\the\xscale}%
\vss}\hss\ps@nnotation}%
\advance\pswdincr by \drawingwd
\advance\pshtincr by \drawinght
\global\wd\drawingBox=\the\pswdincr
\global\ht\drawingBox=\the\pshtincr
\baselineskip=0pt
\copy\drawingBox
\vss}\hss}%
\global\psxoffset=0pt
\global\psyoffset=0pt
\global\pswdincr=0pt
\global\pshtincr=0pt % These are local to one figure
\global\pscm=1cm %should not be necessary
\global\drawingwd=\drawingwd
\global\drawinght=\drawinght
}}%
%
% \psboxscaled{scalefactor*1000}{PSfilename} allows to bypass the
% rounding errors of TeX integer divisions for situations where the
% TeX box should fit the original BoundingBox with a precision better
% than 1/1000.
%
\def\psboxscaled#1#2{\vbox{
\ReadPSize{#2}%
\xscale=#1
\message{scaled \the\xscale}%
\advance\drawingwd by\pswdincr\advance\drawinght by\pshtincr
\divide\pswdincr by 1000 \multiply\pswdincr by \xscale
\divide\pshtincr by 1000 \multiply\pshtincr by \xscale
\divide\psxoffset by1000 \multiply\psxoffset by\xscale
\divide\psyoffset by1000 \multiply\psyoffset by\xscale
\divide\drawingwd by1000 \multiply\drawingwd by\xscale
\divide\drawinght by1000 \multiply\drawinght by\xscale
\global\divide\pscm by 1000
\global\multiply\pscm by\xscale
\global\setbox\drawingBox=\hbox to 0pt{\kern\psxoffset\vbox to 0pt{
\kern-\psyoffset
\PSspeci@l{\PSfilename}{\the\xscale}%
\vss}\hss\ps@nnotation}%
\advance\pswdincr by \drawingwd
\advance\pshtincr by \drawinght
\global\wd\drawingBox=\the\pswdincr
\global\ht\drawingBox=\the\pshtincr
\baselineskip=0pt
\copy\drawingBox
\global\psxoffset=0pt
\global\psyoffset=0pt
\global\pswdincr=0pt
\global\pshtincr=0pt % These are local to one figure
\global\pscm=1cm
\global\drawingwd=\drawingwd
\global\drawinght=\drawinght
}}%
%
% \psbox{PSfilename} makes a TeX box having the minimal size to
% enclose the picture
\def\psbox#1{\psboxscaled{1000}{#1}}%
%------------------------------------------------------
% \joinfiles file1, file2, ...n \into joinedfilename .
% makes one file out of many
% \splitfile joinedfilename
% the opposite
\newif\ifn@teof\n@teoftrue
\newif\ifc@ntrolline
\newif\ifmatch
\newread\j@insplitin
\newwrite\j@insplitout
\newwrite\psbj@inaux
\immediate\openout\psbj@inaux=psbjoin.aux
\immediate\write\psbj@inaux{\string\joinfiles}%
\immediate\write\psbj@inaux{\jobname,}%
%
% INPUT REDEFINITION
%
% works if #1 is a single character
\def\toother#1{\ifcat\relax#1\else\expandafter%
\toother@ux\meaning#1\endtoother@ux\fi}%
\def\toother@ux#1 #2#3\endtoother@ux{\def\tmp{#3}%
\ifx\tmp\@mpty\def\tmp{#2}\let\next=\relax%
\else\def\next{\toother@ux#2#3\endtoother@ux}\fi%
\next}%
%
% \readfilename defs:
%
\let\readfilenamehook=\relax
\def\re@d{\expandafter\re@daux}% spares typing 10 \expandafter's...
\def\re@daux{\futurelet\nextchar\stopre@dtest}%
\def\re@dnext{\xdef\lastreadfilename{\lastreadfilename\nextchar}%
\afterassignment\re@d\let\nextchar}%
\def\stopre@d{\egroup\readfilenamehook}%
\def\stopre@dtest{%
\ifcat\nextchar\relax\let\nextread\stopre@d
\else
\ifcat\nextchar\space\def\nextread{%
\afterassignment\stopre@d\chardef\nextchar=`}%
\else\let\nextread=\re@dnext
\toother\nextchar
\edef\nextchar{\tmp}%
\fi
\fi\nextread}%
\def\readfilename{\vbox\bgroup%
\let\\=\backslashother \let\%=\percentother \let\~=\tildeother
\let\#=\sharpother \xdef\lastreadfilename{}%
\re@d}%
%
% redefines \input using \readfilename
%
\xdef\GlobalInputList{\jobname}%
\def\psnewinput{%
\def\readfilenamehook{% each entry in \GlobalInputList should be unique
\if\matchexpin{\GlobalInputList}{, \lastreadfilename}%
\else\xdef\GlobalInputList{\GlobalInputList, \lastreadfilename}%
\immediate\write\psbj@inaux{\lastreadfilename,}%
\fi%
\ps@ldinput\lastreadfilename\relax%
\let\readfilenamehook=\relax%
}\readfilename%
}%
\expandafter\ifx\csname @@input\endcsname\relax % then Plain
\immediate\let\ps@ldinput=\input\def\input{\psnewinput}%
\else
\immediate\let\ps@ldinput=\@@input
\def\@@input{\psnewinput}%
\fi%
%
\def\nowarnopenout{%
\def\warnopenout##1##2{%
\readfilename##2\relax
\message{\lastreadfilename}%
\immediate\openout##1=\lastreadfilename\relax}}%
\def\warnopenout#1#2{%
\readfilename#2\relax
\def\t@mp{TrashMe,psbjoin.aux,psbjoint.tex,}\uncatcode\t@mp
\if\matchexpin{\t@mp}{\lastreadfilename,}%
\else
\immediate\openin\pst@mpin=\lastreadfilename\relax
\ifeof\pst@mpin
\else
\errhelp{If the content of this file is so precious to you, abort (ie
press x or e) and rename it before retrying.}%
\errmessage{I'm just about to replace your file named \lastreadfilename}%
\fi
\immediate\closein\pst@mpin
\fi
\message{\lastreadfilename}%
\immediate\openout#1=\lastreadfilename\relax}%
% % will have an unusual catcode below; use * instead
%\vbox
{\catcode`\%=12\catcode`\*=14
\gdef\splitfile#1{*
\readfilename#1\relax
\immediate\openin\j@insplitin=\lastreadfilename\relax
\ifeof\j@insplitin
\message{! I couldn't find and split \lastreadfilename!}*
\else
\immediate\openout\j@insplitout=TrashMe
\message{< Splitting \lastreadfilename\space into}*
\loop
\ifeof\j@insplitin
\immediate\closein\j@insplitin\n@teoffalse
\else
\n@teoftrue
\executeinspecs{\global\read\j@insplitin to\spl@tinline\expandafter
\ch@ckbeginnewfile\spl@tinline%Beginning-Of-File-Named:%\endcheck}*
\ifc@ntrolline
\else
\toks0=\expandafter{\spl@tinline}*
\immediate\write\j@insplitout{\the\toks0}*
\fi
\fi
\ifn@teof\repeat
\immediate\closeout\j@insplitout
\fi\message{>}*
}*
\gdef\ch@ckbeginnewfile#1%Beginning-Of-File-Named:#2%#3\endcheck{*
\def\t@mp{#1}*
\ifx\@mpty\t@mp
\def\t@mp{#3}*
\ifx\@mpty\t@mp
\global\c@ntrollinefalse
\else
\immediate\closeout\j@insplitout
\warnopenout\j@insplitout{#2}*
\global\c@ntrollinetrue
\fi
\else
\global\c@ntrollinefalse
\fi}*
\gdef\joinfiles#1\into#2{*
\message{< Joining following files into}*
\warnopenout\j@insplitout{#2}*
\message{:}*
{*
\edef\w@##1{\immediate\write\j@insplitout{##1}}*
\w@{% This collection of files was produced with CERN psbox package}*
\w@{% To decompose and tex it:}*
\w@{%-save this with a filename CONTAINING ONLY LETTERS and a .TEX}*
\w@{% extension (say, JOINTFIL.TEX), in some uncrowded directory;}*
\w@{%-make sure you can \string\input\space psbox.tex (version>=1.3);}*
\w@{% (else ftp cs.nyu.edu(=128.122.140.24):pub/TeX/psbox/, then get}*
\w@{% and tex the file psboxall.tex; more info in psbREAD.ME)}*
\w@{%-tex JOINTFIL.TEX using Plain, or LaTeX, or whatever is needed by}*
\w@{% the first file in the joining (after splitting JOINTFIL.TEX into}*
\w@{% it's constituents, TeX will try to process it as it stands).}*
\w@{\string\input\space psbox.tex}*
\w@{\string\splitfile{\string\jobname}}*
\w@{\string\let\string\autojoin=\string\relax}*
}*
\expandafter\tre@tfilelist#1, \endtre@t
\immediate\closeout\j@insplitout
\message{>}*
}*
\gdef\tre@tfilelist#1, #2\endtre@t{*
\readfilename#1\relax
\ifx\@mpty\lastreadfilename
\else
\immediate\openin\j@insplitin=\lastreadfilename\relax
\ifeof\j@insplitin
\errmessage{I couldn't find file \lastreadfilename}*
\else
\message{\lastreadfilename}*
\immediate\write\j@insplitout{%Beginning-Of-File-Named:\lastreadfilename}*
\executeinspecs{\global\read\j@insplitin to\oldj@ininline}*
\loop
\ifeof\j@insplitin\immediate\closein\j@insplitin\n@teoffalse
\else\n@teoftrue
\executeinspecs{\global\read\j@insplitin to\j@ininline}*
\toks0=\expandafter{\oldj@ininline}*
\let\oldj@ininline=\j@ininline
\immediate\write\j@insplitout{\the\toks0}*
\fi
\ifn@teof
\repeat
\immediate\closein\j@insplitin
\fi
\tre@tfilelist#2, \endtre@t
\fi}*
}%
% To be put at the end of a file, for making a tar-like file containing
% everything it used.
\def\autojoin{%
\immediate\write\psbj@inaux{\string\into{psbjoint.tex}}%
\immediate\closeout\psbj@inaux
\expandafter\joinfiles\GlobalInputList\into{psbjoint.tex}%
}%
%----------------------------------------------------------------
% Annotations & Captions etc...
%
%
% \centinsert{anybox} is just a centered \midinsert, but is included as
% people barely use the original inserts from TeX.
%
\def\centinsert#1{\midinsert\line{\hss#1\hss}\endinsert}%
\def\psannotate#1#2{\vbox{%
\def\ps@nnotation{#2\global\let\ps@nnotation=\relax}#1}}%
\def\pscaption#1#2{\vbox{%
\setbox\drawingBox=#1
\copy\drawingBox
\vskip\baselineskip
\vbox{\hsize=\wd\drawingBox\setbox0=\hbox{#2}%
\ifdim\wd0>\hsize
\noindent\unhbox0\tolerance=5000
\else\centerline{\box0}%
\fi
}}}%
% for compatibility with older versions, but \psfig is a bad name!
%\def\psfig#1#2#3{\pscaption{\psannotate{#1}{#2}}{#3}}
%\def\psfigurebox#1#2#3{\pscaption{\psannotate{\psbox{#1}}{#2}}{#3}}
%
% \at(#1;#2)#3 puts #3 at #1-higher and #2-right of the current
% position without moving it (to be used in annotations).
\def\at(#1;#2)#3{\setbox0=\hbox{#3}\ht0=0pt\dp0=0pt
\rlap{\kern#1\vbox to0pt{\kern-#2\box0\vss}}}%
%
% \gridfill(ht;wd) makes a 1cm*1cm grid of ht by wd whose lower-left
% corner is the current point
\newdimen\gridht \newdimen\gridwd
\def\gridfill(#1;#2){%
\setbox0=\hbox to 1\pscm
{\vrule height1\pscm width.4pt\leaders\hrule\hfill}%
\gridht=#1
\divide\gridht by \ht0
\multiply\gridht by \ht0
\gridwd=#2
\divide\gridwd by \wd0
\multiply\gridwd by \wd0
\advance \gridwd by \wd0
\vbox to \gridht{\leaders\hbox to\gridwd{\leaders\box0\hfill}\vfill}}%
%
% Useful to measure where to put annotations
\def\fillinggrid{\at(0cm;0cm){\vbox{%
\gridfill(\drawinght;\drawingwd)}}}%
%
% \textleftof\anybox: Sample text\endtext
% inserts "Sample text" on the left of \anybox ie \vbox, \psbox.
% \textrightof is the symmetric (not documented, too uggly)
% Welcome any suggestion about clean wraparound macros from
% TeXhackers reading this
%
\def\textleftof#1:{%
\setbox1=#1
\setbox0=\vbox\bgroup
\advance\hsize by -\wd1 \advance\hsize by -2em}%
\def\textrightof#1:{%
\setbox0=#1
\setbox1=\vbox\bgroup
\advance\hsize by -\wd0 \advance\hsize by -2em}%
\def\endtext{%
\egroup
\hbox to \hsize{\valign{\vfil##\vfil\cr%
\box0\cr%
\noalign{\hss}\box1\cr}}}%
%
% \frameit{\thick}{\skip}{\anybox}
% draws with thickness \thick a box around \anybox, leaving \skip of
% blank around it. eg \frameit{0.5pt}{1pt}{\hbox{hello}}
% \boxit{\anybox} is a shortcut.
\def\frameit#1#2#3{\hbox{\vrule width#1\vbox{%
\hrule height#1\vskip#2\hbox{\hskip#2\vbox{#3}\hskip#2}%
\vskip#2\hrule height#1}\vrule width#1}}%
\def\boxit#1{\frameit{0.4pt}{0pt}{#1}}%
%
%
\catcode`\@=12 % cs containing @ are unreachable
%
% CUSTOMIZE YOUR DEFAULT DRIVER:
% Uncomment the line corresponding to your TeX system:
%\psfortextures% For TeXtures on the Macintosh
%\psforoztex % For OzTeX shareware on the Macintosh
%\psfordvitops % For the DVItoPS converter for TeX on IBM mainframes
\psfordvips % For DVIPS converter on VAX and UNIX
%\psfordvitps % For dvitps from TeXPS package under UNIX
%\psfordvialw % For dvialw, UNIX public domain
%\psonlyboxes % Blank Boxes (when all else fails).
|