Newsgroups: fj.comp.texhax
Path: galaxy.trc.rwcp.or.jp!coconuts.jaist!wnoc-tyo-news!spinnews!m5w114!zunet!ashizawa
From: ashizawa@zuken.co.jp (Shuji Ashizawa)
Subject: epsffile rotate style
Sender: news@zuken.co.jp
Message-ID: <ASHIZAWA.94Oct14220338@r3e23.zuken.co.jp>
Date: Fri, 14 Oct 1994 13:00:58 GMT
Distribution: fj
Nntp-Posting-Host: r3e23
Organization: ZUKEN Inc. Yokohama, JAPAN
Lines: 330
Xref: galaxy.trc.rwcp.or.jp fj.comp.texhax:5313
X-originally-archived-at: http://galaxy.rwcp.or.jp/text/cgi-bin/newsarticle2?ng=fj.comp.texhax&nb=5313&hd=a
X-reformat-date: Mon, 18 Oct 2004 15:18:22 +0900
X-reformat-comment: Tabs were expanded into 4 column tabstops by the Galaxy's archiver. See http://katsu.watanabe.name/ancientfj/galaxy-format.html for more info.


$B02_7(B@$B?^8&$G$9!#(B

epsf.sty (psfrag$BMQ(B) $B$K<j$r2C$($F!$(BEPSF$B%U%!%k$r%$%s%]!<%H$7$F(B
$B$=$l$r(B90$BEY2sE>$G$-$k$h$&$J5!G=$rIU2C$7$F$_$^$7$?!#(B

$B$7$+$7!$2sE>$O=PMh$k$N$G$9$,!$AHHG;~$K2sE>$r$7$F$+$i9T$J$C$F(B
$B$/$l$J$$0Y!$(Bwidth <= height $B$N3($O2?$H$+2sE>$7$F$b8+1I$($,NI$$(B
$B$N$G$9$,!$(Bwidth > height $B$N>l9g$K$O!$2sE>$7$F$b>.$5$J3($K$9$k(B
$B$7$+$J$/;]$/$$$-$^$;$s!#(B

$BC/$+$3$NEv$j<#$;$k?M$O$$$J$$$G$7$g$&$+!#$^$?!$$3$s$J%9%?%$%k(B
$B%U%!%$%k$,$"$k$h$G$b9=$$$^$;$s!#(B

$B8=>u$N;HMQJ}K!(B

\mbox{\def\epsfangle{90}\epsfxsize=0.5\hsize\epsfbox{test.idr}}

$B$N$h$&$K;XDj$7$^$9!#(B

dvi2ps-1.9j$B$GF0:n3NG'$7$^$7$?!#(B

BEGIN-----------------
%   EPSF.TEX macro file:
%   Written by Tomas Rokicki of Radical Eye Software, 29 Mar 1989.
%   Revised by Don Knuth, 3 Jan 1990.
%   Revised by Tomas Rokicki to accept bounding boxes with no
%      space after the colon, 18 Jul 1990.
%   Revised by Craig Barratt to support psfrag facility (changes should
%      be upward compatable), 29 Feb 1992.
%   Revised by Shuji.Ashizawa 10/14 1994 angle add
%
%   TeX macros to include an Encapsulated PostScript graphic.
%   Works by finding the bounding box comment,
%   calculating the correct scale values, and inserting a vbox
%   of the appropriate size at the current position in the TeX document.
%
%   To use with the center environment of LaTeX, preface the \epsffile
%   call with a \leavevmode.  (LaTeX should probably supply this itself
%   for the center environment.)
%
%   To use, simply say
%   \input epsf           % somewhere early on in your TeX file
%   \epsfbox{filename.ps} % where you want to insert a vbox for a figure
%
%   Alternatively, you can type
%
%   \epsfbox[0 0 30 50]{filename.ps} % to supply your own BB
%
%   which will not read in the file, and will instead use the bounding
%   box you specify.
%
%   The effect will be to typeset the figure as a TeX box, at the
%   point of your \epsfbox command. By default, the graphic will have its
%   `natural' width (namely the width of its bounding box, as described
%   in filename.ps). The TeX box will have depth zero.
%
%   You can enlarge or reduce the figure by saying
%     \epsfxsize=<dimen> \epsfbox{filename.ps}
%   (or
%     \epsfysize=<dimen> \epsfbox{filename.ps})
%   instead. Then the width of the TeX box will be \epsfxsize and its
%   height will be scaled proportionately (or the height will be
%   \epsfysize and its width will be scaled proportiontally).  The
%   width (and height) is restored to zero after each use.
%
%   A more general facility for sizing is available by defining the
%   \epsfsize macro.    Normally you can redefine this macro
%   to do almost anything.  The first parameter is the natural x size of
%   the PostScript graphic, the second parameter is the natural y size
%   of the PostScript graphic.  It must return the xsize to use, or 0 if
%   natural scaling is to be used.  Common uses include:
%
%      \epsfxsize  % just leave the old value alone
%      0pt         % use the natural sizes
%      #1          % use the natural sizes
%      \hsize      % scale to full width
%      0.5#1       % scale to 50% of natural size
%      \ifnum#1>\hsize\hsize\else#1\fi  % smaller of natural, hsize
%
%   If you want TeX to report the size of the figure (as a message
%   on your terminal when it processes each figure), say `\epsfverbosetrue'.
%
\newread\epsffilein    % file to \read
\newif\ifepsffileok    % continue looking for the bounding box?
\newif\ifepsfbbfound   % success?
\newif\ifepsfverbose   % report what you're making?
\newdimen\epsfxsize    % horizontal size after scaling
\newdimen\epsfysize    % vertical size after scaling
\newdimen\epsftsize    % horizontal size before scaling
\newdimen\epsfrsize    % vertical size before scaling
\newdimen\epsftmp      % register for arithmetic manipulation
\newdimen\pspoints     % conversion factor
\newdimen\punit        % pt unit
\newdimen\epsfcllx     % 
\newdimen\epsfclly     %
\newdimen\epsfcurx     %
\newdimen\epsfcury     %
\newdimen\epsfwidth
\newdimen\epsfheight
\newdimen\epsfd
\def\epsfzero{0}
\def\epsfrot{90}
\def\epsfangle{0}
%
% These two dimensions are computed by epsf and used by the psfrag
% macros for placing the TeX fragments.  With epsf they are always
% equal (since epsf preserves the aspect ratio).
%
\newdimen\epsfhbpsize  % size after horizontal scaling of 1bp
\newdimen\epsfvbpsize  % size after vertical scaling of 1bp
%
\pspoints=1bp          % Adobe points are `big'
\punit=1pt
\epsfxsize=0pt         % Default value, means `use natural size'
\epsfysize=0pt         % ditto
%
\def\epsfbox#1{\global\def\epsfllx{72}\global\def\epsflly{72}%
   \global\def\epsfurx{540}\global\def\epsfury{720}%
   \def\lbracket{[}\def\testit{#1}\ifx\testit\lbracket
   \let\next=\epsfgetlitbb\else\let\next=\epsfnormal\fi\next{#1}}%
%
\def\epsfgetlitbb#1#2 #3 #4 #5]#6{\epsfgrab #2 #3 #4 #5 .\\%
   \epsfsetgraph{#6}}%
%
\def\epsfnormal#1{\epsfgetbb{#1}\epsfsetgraph{#1}}%
%
\def\epsfgetbb#1{%
%
%   The first thing we need to do is to open the
%   PostScript file, if possible.
%
\openin\epsffilein=#1
\ifeof\epsffilein\errmessage{I couldn't open #1, will ignore it}\else
%
%   Okay, we got it. Now we'll scan lines until we find one that doesn't
%   start with %. We're looking for the bounding box comment.
%
   {\epsffileoktrue \chardef\other=12
    \def\do##1{\catcode`##1=\other}\dospecials \catcode`\ =10
    \loop
       \read\epsffilein to \epsffileline
       \ifeof\epsffilein\epsffileokfalse\else
%
%   We check to see if the first character is a % sign;
%   if not, we stop reading (unless the line was entirely blank);
%   if so, we look further and stop only if the line begins with
%   `%%BoundingBox:'.
%
          \expandafter\epsfaux\epsffileline:. \\%
       \fi
   \ifepsffileok\repeat
   \ifepsfbbfound\else
    \ifepsfverbose\message{No bounding box comment in #1; using defaults}\fi\fi
   }\closein\epsffilein\fi}%
%
%   Now we have to calculate the scale and offset values to use.
%   First we compute the natural sizes.
%
\def\epsfsetgraph#1{%
   \epsfrsize=\epsfury\pspoints
   \advance\epsfrsize by-\epsflly\pspoints
   \epsftsize=\epsfurx\pspoints
   \advance\epsftsize by-\epsfllx\pspoints
%
%   If `epsfxsize' is 0, we default to the natural size of the picture.
%   Otherwise we scale the graph to be \epsfxsize wide.
%
   \epsfxsize\epsfsize\epsftsize\epsfrsize
   \ifnum\epsfxsize=0 \ifnum\epsfysize=0
      \epsfxsize=\epsftsize \epsfysize=\epsfrsize
%
%   We have a sticky problem here:  TeX doesn't do floating point arithmetic!
%   Our goal is to compute y = rx/t. The following loop does this reasonably
%   fast, with an error of at most about 16 sp (about 1/4000 pt).
% 
     \else\epsftmp=\epsftsize \divide\epsftmp\epsfrsize
       \epsfxsize=\epsfysize \multiply\epsfxsize\epsftmp
       \multiply\epsftmp\epsfrsize \advance\epsftsize-\epsftmp
       \epsftmp=\epsfysize
       \loop \advance\epsftsize\epsftsize \divide\epsftmp 2
       \ifnum\epsftmp>0
          \ifnum\epsftsize<\epsfrsize\else
             \advance\epsftsize-\epsfrsize \advance\epsfxsize\epsftmp \fi
       \repeat
     \fi
   \else\epsftmp=\epsfrsize \divide\epsftmp\epsftsize
     \epsfysize=\epsfxsize \multiply\epsfysize\epsftmp   
     \multiply\epsftmp\epsftsize \advance\epsfrsize-\epsftmp
     \epsftmp=\epsfxsize
     \loop \advance\epsfrsize\epsfrsize \divide\epsftmp 2
     \ifnum\epsftmp>0
        \ifnum\epsfrsize<\epsftsize\else
           \advance\epsfrsize-\epsftsize \advance\epsfysize\epsftmp \fi
     \repeat     
   \fi
%
% Compute \epsfhbpsize and \epsfvbpsize (they're equal).  This is the
% dimen that 1 pspoint becomes after scaling.  These dimens are used
% by the psfrag macros, so we only bother to compute them if \psfrag
% is defined.
% 
   \expandafter\ifx\csname psfrag\endcsname\relax\else
       \epsftsize=\epsfurx\pspoints
       \advance\epsftsize by-\epsfllx\pspoints
       \epsfrsize=1\pspoints
       \ifnum\epsfxsize=0
    \epsfhbpsize=1\pspoints
       \else\epsftmp=\epsfrsize \divide\epsftmp\epsftsize
 \epsfhbpsize=\epsfxsize \multiply\epsfhbpsize\epsftmp   
 \multiply\epsftmp\epsftsize \advance\epsfrsize-\epsftmp
 \epsftmp=\epsfxsize
 \loop \advance\epsfrsize\epsfrsize \divide\epsftmp 2
 \ifnum\epsftmp>0
    \ifnum\epsfrsize<\epsftsize\else
       \advance\epsfrsize-\epsftsize \advance\epsfhbpsize\epsftmp \fi
 \repeat     
\fi
% same in vertical direction
\epsfvbpsize=\epsfhbpsize
    \fi
%
%  Finally, we make the vbox and stick in a \special that dvips can parse.
%
   \ifepsfverbose\message{#1: width=\the\epsfxsize, height=\the\epsfysize}\fi
   %
   % check if psfrag is defined and that we can open the psfrag file
   %
   \epsffileokfalse%
   \expandafter\ifx\csname psfrag\endcsname\relax\else%
      \openin\epsffilein=#1frag
      \ifeof\epsffilein\else%
  \closein\epsffilein%
  \epsffileoktrue%
   \fi\fi%
   \epsftmp=10\epsfxsize \divide\epsftmp\pspoints
   % add by Shuji.Ashizawa
   \epsfcllx=\epsfllx\punit
   \epsfclly=\epsflly\punit
   \epsfcurx=\epsfurx\punit
   \epsfcury=\epsfury\punit
   \ifx\epsfangle\epsfzero
      \typeout{angle=0}
      \divide\epsfcllx by \punit
      \divide\epsfclly by \punit
      \divide\epsfcurx by \punit
      \divide\epsfcury by \punit
   \else\ifx\epsfangle\epsfrot
      \typeout{angle=90}
      %\typeout{epsfllx=\epsfllx}
      %\typeout{epsflly=\epsflly}
      %\typeout{epsfurx=\epsfurx}
      %\typeout{epsfury=\epsfury}
      \epsfwidth=\epsfcurx
      \advance\epsfwidth by -\epsfcllx
      \epsfheight=\epsfcury
      \advance\epsfheight by -\epsfclly
      \epsfd=\epsfheight
      \advance\epsfd by -\epsfwidth
      \divide\epsfd by 2
      \advance\epsfclly by \epsfwidth
      \advance\epsfclly by \epsfd
      \advance\epsfcury by \epsfwidth
      \advance\epsfcury by \epsfd
      \advance\epsfcllx by -\epsfd
      \advance\epsfcurx by -\epsfd
      \divide\epsfcllx by \punit
      \divide\epsfclly by \punit
      \divide\epsfcurx by \punit
      \divide\epsfcury by \punit
      %\typeout{epsfllx=\number\epsfcllx}
      %\typeout{epsflly=\number\epsfclly}
      %\typeout{epsfurx=\number\epsfcurx}
      %\typeout{epsfury=\number\epsfcury}
   \fi\fi
   % add by Shuji.Ashizawa
   \vbox to\epsfysize{\vfil\hbox to\epsfxsize{%
      % we put our fragments and the special into two 0pt x 0pt boxes
      % so we can be sure they end up at exactly the same place.
      \typeout{[#1] import...}
      \ifepsffileok
  \def\PsFragSpecialArgs{PSfile=#1 llx=\epsfllx\space lly=\epsflly %
     \space urx=\epsfurx\space ury=\epsfury\space rwi=\number\epsftmp}%
  \input{#1frag}%
      \else
  \special{PSfile=#1 angle=\epsfangle\space llx=\number\epsfcllx\space lly=\number\epsfclly\space
      urx=\number\epsfcurx\space ury=\number\epsfcury\space rwi=\number\epsftmp}%
      \fi\hfil}}%
\epsfxsize=0pt\epsfysize=0pt\def\epsfangle{0}}%

%
%   We still need to define the tricky \epsfaux macro. This requires
%   a couple of magic constants for comparison purposes.
%
{\catcode`\%=12 \global\let\epsfpercent=%\global\def\epsfbblit{%BoundingBox}}%
%
%   So we're ready to check for `%BoundingBox:' and to grab the
%   values if they are found.
%
\long\def\epsfaux#1#2:#3\\{\ifx#1\epsfpercent
   \def\testit{#2}\ifx\testit\epsfbblit
      \epsfgrab #3 . . . \\%
      \epsffileokfalse
      \global\epsfbbfoundtrue
   \fi\else\ifx#1\par\else\epsffileokfalse\fi\fi}%
%
%   Here we grab the values and stuff them in the appropriate definitions.
%
\def\epsfgrab #1 #2 #3 #4 #5\\{%
   \global\def\epsfllx{#1}\ifx\epsfllx\empty
      \epsfgrab #2 #3 #4 #5 .\\\else
   \global\def\epsflly{#2}%
   \global\def\epsfurx{#3}\global\def\epsfury{#4}\fi}%
%
%   We default the epsfsize macro.
%
\def\epsfsize#1#2{\epsfxsize}
%
%   Finally, another definition for compatibility with older macros.
%
\let\epsffile=\epsfbox
END-----------------


--
    ~v~    ~v~   _       _
        ~s~        - _ -         
 (    (     (  (  (( o ))  )     
-- ---__----  -  _ -_-_-- _      Shuji.Ashizawa
-  --- --- --- -- -- -- -- --    E-mail ashizawa@zuken.co.jp
