% Merging PostScript Illustrations

% These TeX macros enable easy insertion of PostScript
% illustrations into documents produced by TeX and LaTeX.
% The illustrations are automatically sized when the
% PostScript file has a
%    BoundingBox: llx lly urx ury
% line in it.  The units of measurement for lower-left-x (llx),
% lower-left-y (lly), upper-right-x (urx), and
% upper-right-y (ury) are 1/72 of an inch (a PostScript unit).

% Source locations at the MIT AI Laboratory
%   Canonical Source
%     Trix      /homes/glr/tex/psadobe/psadobe.tex
%
% Available on Athena: /mit/postscript/psadobe.tex

% References
%   Adobe Systems, Inc
%     PostScript Language Reference Manual
%     Addison-Wesley, 1986
%     Appendix C, pages 279-286
%   DVILASER/PS User Manual
%     ArborText, Inc, 1987

% Copyright Gerald Roylance 1987, 1989
%   This file may be copied or distributed as long as this
%   copyright notice is not removed.

% PostScript is a trademark of Adobe Systems Incorporated.

% Bugs and Fixes
%   bulletproof reading the postscript file [GLR, 11/89]
%     reads only the headercomments, demands %! and %%
%   add ArborText support [GLR, 3/89]
%   clear out some junk [GLR, 3/89]
%   convert \mag to a float at runtime [Rich, 12/87]
%   removed spurious cr's in psadobeextract, -bb, -header [Rich, 11/87]
%   make psfile switch to horizontal mode 
%     now LaTeX \leavevmode isn't needed [GLR, 11/87]
%   changed \errmessage to \message for file not found
%     in \psadobeheader [Rich, 12/87]
%   added \psadobepercent [Rich, 12/87]
%   added \xpsadobe and \xpsadobepercent [Rich, 2/22]


% Usage

% To load the macros, use
%       \input{psadobe}
% The macros are read from TeX's default input area.

% To insert an illustration, use
%       \psadobe{filename.ps}
% The expression is treated exactly like a character.
% You will probably want to center it or use other positioning
% commands.  The illustration is also magnified by the \mag
% parameter.  If you don't want this magnification, then
% use
%       \psadobenomag{filename.ps}

% The filename may present some difficulty because
% both TeX and the dvi converter use the filename.
% You may have to provide a fully qualified filename.

% The illustrations to be inserted with autosizing must use
% the Adobe PostScript File Structuring Conventions (PFSC).
% These macros do automatic sizing of the inserted illustation
% by reading the PFSC header comment of the PostScript file.
% The Lisp Machine program Illustrate produces the correct format.
% Most MacIntosh programs do not provide a tight bounding box.

% In order to insert a PostScript file, the .dvi to PostScript
% converter must implement \special{PSFILE...} or use ArborText's
% \special{ps:...} commands.  The MIT AI Lab uses the Unix program
% dvi2ps (available from ???) and a Lisp Machine dvi converter
% (available from the Symbolics LispMachine Users' Group).

% If your converter cannot understand a set of special commands,
% then after loading psadobe turn off the appropriate set of specials:
%       \dvitopsfalse
%       \ArborTextfalse

% For further information, see MIT AI Laboratory Working Paper 299a.


%%%% TeX Macros for Merging PostScript Illustrations

%%% Gerald Roylance 1987
% Available on Athena: /mit/postscript/psbox.tex

\newbox\psboxvoid  % An empty box for a LaTeX hack

% psbox (width, height, filename)
%   puts the origin at the lower left corner of the box

\def\psbox#1#2#3{%
   \unhbox\psboxvoid%  demand horizontal mode
   \hbox to #1{\vbox to #2{\vfil}\special{psfile=#3}\hfil}}

% illustratefile(width, height, filename)
%   aligns the center of the box with the center of the
%   PostScript letter size page (4.25, 5.5).
%
%    8.5/2 = 4.25in = 306 PostScript Points
%     11/2 = 5.50in = 396 PostScript Points
%
\def\illustratefile#1#2#3{%
   \unhbox\psboxvoid%  demand horizontal mode
   \hbox to #1{%
     \hfil%
     \vbox to #2{%
       \vfil%
       \special{psfile=#3 hoffset=-306 voffset=-396}%
       \vfil}%
     \hfil}}

\endinput

