home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fonts 1
/
freshfonts1.bin
/
bbs
/
programs
/
amiga
/
mma2latex.lha
/
MMA2LTX
/
MMATEXT.STY
< prev
next >
Wrap
Text File
|
1994-07-18
|
10KB
|
281 lines
%
% macros for picture produced by "mma2ltx"
% version 1.2 - 18 July 1994
%
% Copyright (C) 1994 by Giuseppe Ghib\`o (<ghibo@galileo.polito.it>)
%
% ----------------------------------------------------------------------------
%
\typeout{Document Style `mmatext' - v1.2 (18/7/94) - (C) 1994 by Giuseppe Ghibo`}
%
%
\gdef\mma@prologue{texmma22.pro}% Mathematica v2.2 PostScript prologue file.
%
%
\newdimen\mma@tmpdima
\newdimen\mma@tmpdimb
\newdimen\mma@tmpdimc
\newdimen\mma@tmpdimd
\newbox\mma@tmpbox
%
%
% \mmaheaderprotrue = include the prologue file \mma@prologue (once) using
% the \special{header=...}.
% \mmaheaderprofalse = don't include the prologue file \mma@prologue.
% \mma@proloadedtrue = the prologue \mma@prologue has been already loaded.
% \mma@proloadedfalse = the prologue \mma@prologue has not been loaded.
% \mma@whitebgtrue = the object will have a white background
% \mma@whitebgfalse = the object will have a transparent background
\newif\ifmmaheaderpro \mmaheaderprotrue
\newif\ifmma@proloaded \mma@proloadedfalse
\newif\ifmma@whitebg
%
%
% \@nameedef is similar to the LaTeX command \@namedef, but it uses \edef
% instead of \def.
\def\@nameedef#1{\expandafter\edef\csname #1\endcsname}
%
\let\ccd=\catcode
\ccd`\p=12\ccd`\t=12
\def\del@dim#1pt{#1}%
\ccd`\p=11\ccd`\t=11
%
\def\deldim#1{\expandafter\del@dim\the#1}%trash the trailing 'pt'
\def\dimtomac#1#2#3{%
% \dimtomac (expands a dimension register into a macro)
% #1 = a dimension register (e.g., \mydim, \dimen0, ...)
% #2 = conversion factor from pt to a choosed unit or
% one of mm, cm, pt, bp, pc, in, dd, cc, sp, dbp.
% #3 = macro to which assign the converted value.
\lowercase{\edef\convfactor{#2}}
\def\unit@mm{mm}\def\unit@cm{cm}\def\unit@pt{pt}\def\unit@bp{bp}%
\def\unit@pc{pc}\def\unit@in{in}\def\unit@dd{dd}\def\unit@cc{cc}%
\def\unit@sp{sp}\def\unit@dbp{dbp}%
\ifx\convfactor\unit@mm\def\convfactor{0.3514598035146}\else
\ifx\convfactor\unit@cm\def\convfactor{0.03514598035146}\else
\ifx\convfactor\unit@pt\def\convfactor{1}\else
\ifx\convfactor\unit@bp\def\convfactor{0.99626400996264}\else
\ifx\convfactor\unit@dbp\def\convfactor{9.962640996264}\else
\ifx\convfactor\unit@pc\def\convfactor{0.08333333333333}\else
\ifx\convfactor\unit@in\def\convfactor{0.01383700013837}\else
\ifx\convfactor\unit@dd\def\convfactor{0.9345718901454}\else
\ifx\convfactor\unit@cc\def\convfactor{0.077880990845450}\else
\fi\fi\fi\fi\fi\fi\fi\fi\fi
\mma@tmpdima=#1%
\ifx\convfactor\unit@sp\@nameedef{#3}{\number\mma@tmpdima}\else
\mma@tmpdimb=\convfactor\mma@tmpdima%
\@nameedef{#3}{\deldim\mma@tmpdimb}\fi
}% end of dimtomac definition
%
%
\newdimen\mma@dimunit \mma@dimunit=1bp
\newdimen\mma@llx \newdimen\mma@urx \newdimen\mma@width \newdimen\mma@oldwd
\newdimen\mma@lly \newdimen\mma@ury \newdimen\mma@height \newdimen\mma@oldht
\newdimen\mma@x \newdimen\mma@y
\newdimen\mma@deltax \newdimen\mma@deltay
%
\gdef\mma@wd{161}% default width in bp
\gdef\mma@ht{100}% default height in bp
\gdef\mma@unit{bp}% default unit = bp
\mma@width=\mma@wd bp
\mma@height=\mma@ht bp
\mma@llx=\z@ \mma@urx=\mma@width
\mma@lly=\z@ \mma@ury=\mma@height
\mma@deltax=\z@ \mma@deltay=\z@
%
%
% *************
% * *
% * mmasetpic *
% * *
% *************
\def\mmasetpic(#1,#2){\@ifnextchar({\mma@oldsetpic(#1,#2)}{%
\mma@setpic(#1,#2)}}
\def\mma@setpic(#1,#2)[#3]#4{%
% #1 = width of Mathematica PostScript picture
% #2 = height of Mathematica PostScript picture
% #3 = unit of measure
% #4 = PostScript filename
\lowercase{\edef\mma@unit{#3}}
\mma@dimunit=1\mma@unit
\mma@llx=\z@ \mma@urx=#1\mma@dimunit
\mma@lly=\z@ \mma@ury=#2\mma@dimunit
\mma@width=#1\mma@dimunit \mma@height=#2\mma@dimunit
\mma@oldwd=\mma@width \mma@oldht=\mma@height
\dimtomac{\mma@oldwd}{bp}{mma@wd}
\dimtomac{\mma@oldht}{bp}{mma@ht}
\def\mma@psname{#4}
%
% include the prologue file \mma@prologue at most once.
\ifmma@proloaded\else
\ifmmaheaderpro\special{header=texmma22.pro}\global\mma@proloadedtrue\fi
\fi
}
%
%
% ***************
% * *
% * mmatextfits *
% * *
% ***************
\def\mmatextfits(#1,#2)(#3,#4){\@ifnextchar({\mma@textfits(#1,#2)(#3,#4)}{%
\mma@textfits(#1,#2)(#3,#4)(0,0)}}
%
\def\mma@textfits(#1,#2)(#3,#4)(#5,#6)#7{%
% #1 = x coord.
% #2 = y coord.
% #3 = sdx (bounding box x offs., like the Mathematica command "Text")
% #4 = sdx (bounding box y offs., like the Mathematica command "Text")
% #5 = offset to the x coord.
% #6 = offset to the y coord.
% #7 = text to fit.
\setbox\mma@tmpbox=\hbox{#7}
%
% tmpllx = x - 1/2*wd*(sdx+1)
\mma@tmpdima=#1\mma@dimunit \advance\mma@tmpdima by #5\mma@dimunit
\mma@tmpdimb=#3\wd\mma@tmpbox
\advance\mma@tmpdimb by \wd\mma@tmpbox
\divide\mma@tmpdimb by 2
\advance\mma@tmpdima by -\mma@tmpdimb
\ifdim\mma@tmpdima < \mma@llx \mma@llx=\mma@tmpdima\fi
%
% tmplly = y - 1/2*(ht+dp)*(sdy+1)
\mma@tmpdima=#2\mma@dimunit \advance\mma@tmpdima by #6\mma@dimunit
\mma@tmpdimb=\ht\mma@tmpbox
\advance\mma@tmpdimb by \dp\mma@tmpbox
\mma@tmpdimb=#4\mma@tmpdimb
\advance\mma@tmpdimb by \ht\mma@tmpbox
\advance\mma@tmpdimb by \dp\mma@tmpbox
\divide\mma@tmpdimb by 2
\advance\mma@tmpdima by -\mma@tmpdimb
\ifdim\mma@tmpdima < \mma@lly \mma@lly=\mma@tmpdima\fi
%
% tmpurx = x - 1/2*wd*(sdx-1)
\mma@tmpdima=#1\mma@dimunit \advance\mma@tmpdima by #5\mma@dimunit
\mma@tmpdimb=#3\wd\mma@tmpbox
\advance\mma@tmpdimb by -\wd\mma@tmpbox
\divide\mma@tmpdimb by 2
\advance\mma@tmpdima by -\mma@tmpdimb
\ifdim\mma@tmpdima > \mma@urx \mma@urx=\mma@tmpdima\fi
%
% tmpury = y - 1/2*(ht+dp)*(sdy-1)
\mma@tmpdima=#2\mma@dimunit \advance\mma@tmpdima by #6\mma@dimunit
\mma@tmpdimb=\ht\mma@tmpbox
\advance\mma@tmpdimb by \dp\mma@tmpbox
\mma@tmpdimb=#4\mma@tmpdimb
\advance\mma@tmpdimb by -\ht\mma@tmpbox
\advance\mma@tmpdimb by -\dp\mma@tmpbox
\divide\mma@tmpdimb by 2
\advance\mma@tmpdima by -\mma@tmpdimb
\ifdim\mma@tmpdima > \mma@ury \mma@ury=\mma@tmpdima\fi
%
% Recalculate new picture size
\mma@width=\mma@urx \advance\mma@width by -\mma@llx
\mma@height=\mma@ury \advance\mma@height by -\mma@lly
\mma@deltax=\mma@width \advance\mma@deltax by -\mma@oldwd
\mma@deltay=\mma@height \advance\mma@deltay by -\mma@oldht
}% end of \mmatextfits definition
%
%
% **************
% * *
% * mmapicture *
% * *
% **************
\def\mmapicture{%
\bgroup
\unitlength=1sp% so we can use the command \number
\dimtomac{\mma@width}{\mma@unit}{mma@truewd}
\dimtomac{\mma@height}{\mma@unit}{mma@trueht}
\dimtomac{\mma@deltax}{\mma@unit}{mma@dx}
\dimtomac{\mma@deltay}{\mma@unit}{mma@dy}
\typeout{Mathematica picture:\space'\mma@psname'\space%
size=(\mma@truewd\space x\space\mma@trueht\space\mma@unit)}
\ifdim\mma@deltax > 0pt
\typeout{Mathematica picture:\space'\mma@psname'\space%
deltax=\mma@dx\space\mma@unit}
\fi
\ifdim\mma@deltay > 0pt
\typeout{Mathematica picture:\space'\mma@psname'\space%
deltay=\mma@dy\space\mma@unit}
\fi
\@killglue
\begin{picture}(\number\mma@width,\number\mma@height)(\number\mma@llx,\number\mma@lly)
\put(0,0){\special{psfile=\mma@psname\space hsize=\mma@wd\space vsize=\mma@ht}}}
%
\def\endmmapicture{\end{picture}\egroup}
%
%
% **************
% * *
% * mmaputtext *
% * *
% **************
\def\mmaputtext{\@ifstar{\mma@whitebgtrue\mma@puttext}{\mma@whitebgfalse%
\mma@puttext}}
\def\mma@puttext(#1,#2)(#3,#4){\@ifnextchar({\mma@@puttext(#1,#2)(#3,#4)}{%
\mma@@puttext(#1,#2)(#3,#4)(0,0)}}
%
\def\mma@@puttext(#1,#2)(#3,#4)(#5,#6)#7{%
% #1 = x coord.
% #2 = y coord.
% #3 = sdx (bounding box x offs., like the command "Text" of Mathematica)
% #4 = sdx (bounding box y offs., like the command "Text" of Mathematica)
% #5 = offset to the x coord.
% #6 = offset to the y coord.
% #7 = text (or object) to put.
%
\setbox\mma@tmpbox=\hbox{#7}
\mma@x=#1\mma@dimunit \advance\mma@x by #5\mma@dimunit
\mma@y=#2\mma@dimunit \advance\mma@y by #6\mma@dimunit
%
% xp = x - 1/2 * wd * (sdx + 1)
\mma@tmpdima=#3\wd\mma@tmpbox
\advance\mma@tmpdima by \wd\mma@tmpbox
\divide\mma@tmpdima by 2
\advance\mma@x by -\mma@tmpdima
%
% yp = y - 1/2*(sdy*htot + ht - dp)
\mma@tmpdima=\ht\mma@tmpbox
\advance\mma@tmpdima by \dp\mma@tmpbox
\mma@tmpdima=#4\mma@tmpdima
\