|
From: John H. <jdh...@ac...> - 2005-05-17 22:44:43
|
In honor of Darren trying to get his thesis printed using mpl figures,
and encountering a lot of pain with fonts and mathtext, I added a
psfrag latex backend today. psfrag is a latex package that enables
you to substitute sentinel strings in an eps figure with latex
expressions (eg as in xfig). You create an eps with a bunch of marker
strings like "psmarker0" or "psmarker1" and then write a latex file
that does the substitutions
\psfrag{psmarker0}[bl][bl][2.000000][0.000000]{\TeX\ is Number $e^{-i\pi}$!}
\psfrag{psmarker1}[bl][bl][1.000000][0.000000]{0}
The LaTeX backend generates a *.eps file and a *.tex file. You can
then latex and dvips the tex file to get a true ps, or just embed the
generated latex commands directly into your document. This uses latex
for all text elements, giving a unified font look and feel.
Here is an example
> python examples/tex_demo.py -dLaTeX
> latex tex_demo.tex
> dvips -o tex_demo.ps tex_demo.dvi
> ggv tex_demo.ps
There are a few problems
* the page width and figure placement in the latex document are off
center
* the text color is not being respected
* to get the width and height of the string, I tex the individual
strings separately, run dvips on them, and get the bounding box
from the generated file. This all happens with caching in
matplotlib.texmanager. Right now the fontsize is being ignored in
this process so the layout will be off for nonstandard font sizes
-- anything other than the default design size of latex which
defaults to 10pt I think.
* the text doesn't scale right if you provide a size arg to
includegraphics, eg [width=4.in]
I'm sure these details can be worked out by someone who has the
patience to read the psfrag manual closely and knows a bit about tex
and dvips -- the backend is only 180 lines of code. I'm kind of busy
right now with other work, so I was hoping some enterprising soul
would like to take this and run with it, polish it, fix it and test
it.... Darren? If not, I'll get to it as I can.
Changes in CVS
JDH
|