[comp.text.tex] Mac generated figures in LaTex document?

choe@milton.u.washington.edu (In Jerng Choe) (06/05/91)

Hi,
Does anybody know how to put Macintosh-generated figures (postscript files
obtainded by pressing command-F during printing) into LaTex documents?
I know there is a command named "\special", but I don't know how to convert
Macintosh postscript file properly.  I am using LaTex on Unix main-frame.
I'll appreciate any comments.
Thanks in advance.

In-Jerng Choe
e-mail address: choe@u.washington.edu

almond@lisbon.stat.washington.edu (Russell Almond) (06/05/91)

In article <1991Jun5.014748.1877@milton.u.washington.edu> choe@milton.u.washington.edu (In Jerng Choe) writes:
>Hi,
>Does anybody know how to put Macintosh-generated figures (postscript files
>obtainded by pressing command-F during printing) into LaTex documents?
>I know there is a command named "\special", but I don't know how to convert
>Macintosh postscript file properly.  I am using LaTex on Unix main-frame.
>I'll appreciate any comments.
>Thanks in advance.
>
>In-Jerng Choe
>e-mail address: choe@u.washington.edu
>
>

Most sites use some version of the software dvi2ps to convert TeX (and
LaTeX) output to postscript.  This advise pertains to those systems
which use that software.  Others should check their local
documentation.  Looking at the documentation for dvi2ps (man dvi2ps)
can be quite helpful.

First, what you need to do is look at the postscript code.  Look for a
comment called %%Bounding Box:
e.g.,

%%BoundingBox:24 461 424 707

The four number you see are the co-ordinates of the box containing
your figure.  They are in Postscript points (72 points to an inch, TeX
calls them bigpoints bp).  Thus the figure producing that bounding box
statement is within the rectangle between (24,461) and (424,707).  You
will need to move the origin of your figure to the current page.  To
do this put the postscript command:

-24 -461 translate

at the top of your page.  Here -24 and -461 will be replaced by
whatever the first two numbers are in your bounding box.

Now, back in your TeX document.  You need to generate room for your
picture.  First calculate the size, in this case 400 bp (5.55 in) x
and 246 bp (3.41 in) (y).  First we need to skip down by 3.5 in to
leave room for the figure.  Then we need to skip over .5 inches to
center the figure.  Then we can issue the \special command to include
the postscript document:

\midinsert
\vspace 3.5 in
\noindent\hskip .5in\special{psfile="/fullpathname/file.ps"}
\hfill\break
\smallskip
\centerline{\it Caption}
\endinsert

Would be a typical series of TeX commands for doing this job.  LaTeX
input will vary.

The \special command takes several arguments such as hsize, vsize
whidh set a clipping region, and hscale and vscale which scale the
figure.  Read the man pages on dvi2ps for more details.  Use the full
pathname when referencing figures because I'm not sure about the rules
dvi2ps uses for finding the figure.

In a following post, I will post some macros I have for automatically
including a figure in a document.  These are in TeX.  I understand
there also exists a set of macros for LaTeX use which rely on their
being a bounding box comment in the header.

If you don't have a BoundingBox comment, I understand there is a
program which will generate one, call bbox or something like that.
Ask your system manager.

Good Luck.



	
Russell Almond			   Spring Sunshine,
U. Washington, Statistics, GN-22   The Tree-of-Cliques in Hyperbloom.
Seattle, WA  98195	           Eschew Affine Constraints!
almond@stat.washington.edu, (206) 543-4302   (future ancient Japaneese Haiku)

almond@lisbon.stat.washington.edu (Russell Almond) (06/05/91)

% Almond Figure Macros and belief function definitions.  This provides
% a package of interface routines to postsript figures.

% The routines in question use a definition called directory which
% points to the figure directory.  That should be changed in each
% program.

% The principle routine is \psfig which takes 5 arguments.  The first
% is the figure number, the second in [] is the name of the file
% (minus the .ps extension and the directory (which is taken from
% \directory)) The third is the caption for the figure, the fourth is
% hsize= horizontal dimension and the fifth is vsize= vertical
% dimension.  The whole thing is finish with a /
% For example:  \psfig3[graph]{A really stupid plot}}hsize=4in
% vsize=75pt/  This produces a figure with \directory/graph.ps as the
% postscript file.  Its caption is {\it Figure 3. A really stupid
% plot\/} and a space of 75pt will be left for it the vertical space,
% and it will be centered as if it is four inches wide.
% The horizontal and vertical size parameters are sent via the hsize
% and vsize parameters of the special command.  See dvi2ps
% documentation for more details.

%%%%%%%%%%%Collosally important note:  There are at least three
% versions of dvi2ps running around (I've seen two on the Statistics
% Dept. machines).  They use different units for passing hsize, vsize
% commands (most use bp, some use inches).  This may need to be set
% for your local machine.


%% Figure insertion macros

\newdimen\fighoffset
\newdimen\figwidth
\newdimen\figheight
\newcount\countdimen
\newcount\countunit
\newdimen\dimenscratch

%% To turn off figure processing use \specialdofalse
\newif\ifspecialdo %include special commands or just leave space
\specialdotrue

%% To suppress the word Figure in captions (for two column papers)
%% reste this variable.
\def\Fig{Figure }

% Rescaling macros
\def\dividedimen#1/#2/{\dimenscratch=#1%
\countdimen=\dimenscratch\dimenscratch=#2%
\countunit=\dimenscratch \divide\countdimen by\countunit
%\the\countdimen
}
%%%%% Machine dependent
\def\psunit{1bp} % Was 1bp is now 1in, documentation has not changed. 



% \psfig -- inserts a single figure with caption and leaving space as
% indicated. 
\outer\def\psfig#1[#2]#3hsize=#4 vsize=#5/{
\midinsert
\figwidth= #4%
\fighoffset=\hsize \advance\fighoffset -\figwidth
\divide\fighoffset by 2%
\figheight= #5%
\vskip\figheight
\hskip\fighoffset
\dividedimen\figheight/\psunit/\edef\vs/{\the\countdimen}%
\dividedimen\figwidth/\psunit/\edef\hs/{\the\countdimen}%
\edef\specialcommand{psfile="\directory/#2.ps" hsize=\hs/
vsize=\vs/ }%
\ifspecialdo
\special\expandafter{\specialcommand}%
\fi\hfil\break
\centerline{\it \Fig #1. #3\/}
\endinsert
}

% twopsfig -- produces a,b figures (from files #2a.ps and #2b.ps) side
% by side.  #3 and #4 are the two captions, hsize is the width of a
% single figure 
\outer\def\twopsfig#1[#2]#3#4hsize=#5 vsize=#6/{
\midinsert
\figwidth= #5%
\fighoffset=\hsize \divide\fighoffset by 2%
\advance\fighoffset -\figwidth
\divide\fighoffset by 2%
\figheight= #6%
\vbox{
\settabs2\columns
\vskip\figheight
\dividedimen\figheight/\psunit/\edef\vs/{\the\countdimen}%
\dividedimen\figwidth/\psunit/\edef\hs/{\the\countdimen}%
\tabalign\hskip\fighoffset
\edef\specialcommand{psfile="\directory/#2a.ps" hsize=\hs/
vsize=\vs/ }%
\ifspecialdo
\special\expandafter{\specialcommand}%
\fi
&\hskip\fighoffset
\edef\specialcommand{psfile="\directory/#2b.ps" hsize=\hs/
vsize=\vs/ }%
\ifspecialdo
\special\expandafter{\specialcommand}%
\fi\cr
\medskip
\tabalign\hfill{\it \Fig #1a. #3\/}\hfill
&\hfill{\it \Fig #1b. #4\/}\hfill\cr
}
\endinsert
}

% This macro inserts a figure with no caption and no tag definition.  
% arguments are interpreted the same was as in \psfig.
\def\innerpsfig[#1]hsize=#2 vsize=#3/{
\figwidth= #2%
\fighoffset=\hsize \advance\fighoffset -\figwidth
\divide\fighoffset by 2%
\figheight= #3%
\vskip\figheight
\hskip\fighoffset
\dividedimen\figheight/\psunit/\edef\vs/{\the\countdimen}%
\dividedimen\figwidth/\psunit/\edef\hs/{\the\countdimen}%
\edef\specialcommand{psfile="\directory/#1.ps" hsize=\hs/
vsize=\vs/ }%
\ifspecialdo
\special\expandafter{\specialcommand}%
\fi
}

Russell Almond			   Spring Sunshine,
U. Washington, Statistics, GN-22   The Tree-of-Cliques in Hyperbloom.
Seattle, WA  98195	           Eschew Affine Constraints!
almond@stat.washington.edu, (206) 543-4302   (future ancient Japaneese Haiku)

woobin@milton.u.washington.edu (Woobin Lee) (06/05/91)

In article <1991Jun5.014748.1877@milton.u.washington.edu> choe@milton.u.washington.edu (In Jerng Choe) writes:
>Hi,
>Does anybody know how to put Macintosh-generated figures (postscript files
>obtainded by pressing command-F during printing) into LaTex documents?
>I know there is a command named "\special", but I don't know how to convert
>Macintosh postscript file properly.  I am using LaTex on Unix main-frame.
>I'll appreciate any comments.
>Thanks in advance.

You just reminded me of a question that I have been wondering for a long time.
Does anybody know why I can't dump Mac figures into a postscript file?
I tried pressing command-F (I hope the command key is the one with propeller)
right after clicking OK in the print menu. I always get a printout, but
the postscript file is never created. Our two Macs and a Laserwriter are
connected to each other through Apple Talk, and we use TOPS to access a Mac
from the other one.

Woobin Lee -----------------------------------------------------------------
				||
Image Computing System Lab	||	woobin@u.washington.edu
University of Washington	||
Seattle, WA 98195		||	(206) 543 - 1017
-- 

Woobin Lee -----------------------------------------------------------------
				||
Image Computing System Lab	||	woobin@u.washington.edu

wjin@hermes.cs.uh.edu (Woochang Jin) (06/05/91)

In article <1991Jun5.051514.6873@lisbon.stat.washington.edu> almond@lisbon.stat.washington.edu (Russell Almond) writes:
>
> a long and nice explanation ....... (deleted)
>

There's an easier way to do it.

1) bbfig -m mac.ps > macbb.ps     (So, you need bbfig)
2) In your LaTeX file,
   ...[12pt,psfig]....          % (you need psfig.sty/tex also)
   
   \psfig{figure=macbb.ps}
   ....


____   ____  ____ ____________________________________________________________
|  |   |  |  |  |  Woochang Jin (wjin@cs.uh.edu)     Office - PGH574, PGH592
|  |   |  |__|  |  Grad, System Administration.      Wed,Fri:  9:00-1:00
|  |   |        |  Department of Computer Science    713-749-1748 (office) 
\  |---|  |--|  |  University of Houston             713-747-2130 (home)
 \____/|__|  |__| ____________________________________________________________

jumper@spf.trw.com (Greg Jumper) (06/05/91)

In article <1991Jun5.055927.8117@milton.u.washington.edu> woobin@milton.u.washington.edu (Woobin Lee) writes:

>You just reminded me of a question that I have been wondering for a long time.
>Does anybody know why I can't dump Mac figures into a postscript file?
>I tried pressing command-F ...

Be sure you turn *off* background printing in the chooser before you try to
generate a PostScript file via Command-F or Command-K.


                                       Hope this helps,

                                       Greg Jumper
                                       TRW Data Systems Center

                                       jumper@spf.trw.com

edgar@function.mps.ohio-state.edu (Gerald Edgar) (06/06/91)

>Does anybody know why I can't dump Mac figures into a postscript file?

You must turn off Background Printing for this to work.


--
  Gerald A. Edgar                Internet:  edgar@mps.ohio-state.edu
  Department of Mathematics      Bitnet:    EDGAR@OHSTPY
  The Ohio State University      telephone: 614-292-0395 (Office)
  Columbus, OH 43210              -292-4975 (Math. Dept.) -292-1479 (Dept. Fax)

shen@kovic.IRO.UMontreal.CA (Yu Shen) (06/07/91)

In article <1991Jun5.074946.14675@menudo.uh.edu> wjin@hermes.cs.uh.edu (Woochang Jin) writes:

> In article <1991Jun5.051514.6873@lisbon.stat.washington.edu> almond@lisbon.stat.washington.edu (Russell Almond) writes:
>
> a long and nice explanation ....... (deleted)
>

> There's an easier way to do it.

1) bbfig -m mac.ps > macbb.ps     (So, you need bbfig)
2) In your LaTeX file,
>    ...[12pt,psfig]....          % (you need psfig.sty/tex also)
>    
>    \psfig{figure=macbb.ps}
>    ....

So where could I found bbfig?
--
Yu Shen

PhD Student
Dept. d'Informatique et Recherche Operationnelle
University de Montreal
C.P. 6128 Succ. A.
Montreal, Que. 
Canada
H3C 3J7

(514) 342-7089 (H)
shen.iro.umontreal.ca