summaryrefslogtreecommitdiff
path: root/macros/generic/psbox/psbox.tex
diff options
context:
space:
mode:
Diffstat (limited to 'macros/generic/psbox/psbox.tex')
-rw-r--r--macros/generic/psbox/psbox.tex649
1 files changed, 649 insertions, 0 deletions
diff --git a/macros/generic/psbox/psbox.tex b/macros/generic/psbox/psbox.tex
new file mode 100644
index 0000000000..b666251327
--- /dev/null
+++ b/macros/generic/psbox/psbox.tex
@@ -0,0 +1,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}%
+ \advance\pswdincr by \drawingwd
+ \advance\pshtincr by \drawinght
+ \divide\pswdincr by 1000
+ \divide\pshtincr by 1000
+ \d@mx=#1
+ \ifdim\d@mx=0pt\xscale=1000
+ \else \xscale=\d@mx \divide \xscale by \pswdincr\fi
+ \d@my=#2
+ \ifdim\d@my=0pt\yscale=1000
+ \else \yscale=\d@my \divide \yscale by \pshtincr\fi
+ \ifnum\yscale=1000
+ \else\ifnum\xscale=1000\xscale=\yscale
+ \else\ifnum\yscale<\xscale\xscale=\yscale\fi
+ \fi
+ \fi
+ \divide\drawingwd by1000 \multiply\drawingwd by\xscale
+ \divide\drawinght by1000 \multiply\drawinght 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\pswdincr by\xscale \multiply\pshtincr by\xscale
+ \ifdim\d@mx=0pt\d@mx=\pswdincr\fi
+ \ifdim\d@my=0pt\d@my=\pshtincr\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}%
+ \global\wd\drawingBox=\the\pswdincr
+ \global\ht\drawingBox=\the\pshtincr
+ \global\drawingwd=\pswdincr
+ \global\drawinght=\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
+}}%
+%
+% \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}%
+ \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
+ \global\drawingwd=\pswdincr
+ \global\drawinght=\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
+}}%
+%
+% \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{\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).