I recently updated from mathematica 7.0 to 8.0, and have now encountered problem with replacing my plot labels with LaTeX code using the psfrag package. Everything worked perfectly with the earlier version and the exact same plots, but now psfrag leaves all the labels unchanged. I use Kile on Ubuntu 11.04 for LaTeX editing.
For example, in Mathematica:
plot = Plot[x, {x, -0.1, 0.1},
AxesLabel -> {eps, SUM}, BaseStyle -> {FontSize -> 10}]
Export["plot.eps", plot]
and then in LaTeX:
\begin{figure}
\psfrag{eps}{$\epsilon$}
\psfrag{SUM}{$\Sigma$}
\includegraphics{plot.eps}
\end{figure}
This should now replace labels with LaTeX typesetting, but nothing happens. Any suggestions how to solve this? Does anyone know if there is a difference in how Mathematica 8 encodes text in eps files compared to earlier versions?
There's no difference in how the EPS is encoded. The problem is that the PS code that makes the text in the v7 output (note that Mma uses bind def
to create shortcuts for a lot of PS code, see the top of the generated EPS files for details):
%%IncludeResource: font Times-Roman-MISO
%%IncludeFont: Times-Roman-MISO
10 /Times-Roman-MISO Msf
0 8 m
(SUM) N
has been replaced in v8 with
%%IncludeResource: font Times-Roman-MISO
%%IncludeFont: Times-Roman-MISO
10 /Times-Roman-MISO Msf
p
0.75 9 m
(S) N
P
p
6 9 m
(U) N
P
p
14.25 9 m
(M) N
This means that psfrag
can not grab hold of the tags.
I can't find how to fix this in the Mma export options.
At the moment, the only work-around I can think of (and I've tested that works) is to use single letter tags for the axes labels, e.g.
plot = Plot[x, {x, -0.1, 0.1}, AxesLabel -> {"e", "s"},
BaseStyle -> {FontSize -> 10}]
Export["plot8.eps", plot]
\begin{figure}[h]
\psfrag{e}{$\epsilon$}
\psfrag{s}{$\Sigma$}
\includegraphics{plot8.eps}
\end{figure}
The reasons for maybe wanting to use psfrag
are well stated in http://www.reimeika.ca/marco/prettyplots/
Now, those tags don’t look too good (and make little sense to boot). However the idea is to ultimately include the plot in a paper or report made with LaTeX, and so the real point to the tags is to use them as markers for the psfrag package which allows to replace text within EPS graphs. This way of labeling has three big advantages over hardcoding the tags into the figure. First is consistency, as the fonts will be the same as those in the article. Second is the fact that LaTeX's mathematical engine can be used to the fullest extent within the plot. Last but not least, it allows changing notation easily within the .tex file, as opposed to having to recreate the plot from scratch.
The package psfrag
only works with EPS
graphics and thus only with latex
.
If you want to use psfrag
and pdflatex
, then see the tex.SE question
Using psfrag with pdflatex