## Mathematica EPS graphics and psfrag in $\LaTeX$

5

1

I used to to use MathPSFrag in Mathematica to export graphics to EPS for inclusion in $\LaTeX$ files.

However, with recent versions of Mathematica this does not seem to work very well anymore, see for example mathematica 8.0 and psfrag or LATEX and Mathematica.

In the latter thread it was suggested to use Mathematica's native Export function and then replace text, labels etc. using the pstool package.

However, when I create and export a simple plot via

plot = Plot[x, {x, 0, 1}, AxesLabel -> {"x", "y"}]
Export[NotebookDirectory[] <> "plot.eps", plot]

and then run pdflatex --shell-escape on the file

\documentclass{article}
\usepackage{pstool}
\begin{document}
\psfragfig{plot}
{
\psfrag{x}{$\xi$}
\psfrag{y}{$\phi$}
}
\end{document}

I obtain a two-page PDF document with the lower part of the plot on the top of the second page and the top part missing; the first page is completely empty.

I'd be grateful if somebody could point out what's going on. Also, the restriction to one-letter labels can be quite problematic. Have there been any developments since the two quoted threads about the best way to export graphics from Mathematica into $\LaTeX$?

Edit: What I described above applies to Mma 9.0 on a 64-bit Linux Mint 15.

When I export the plot on a Windows 7 computer, the PDF is created correctly. From this I infer that the problem does not lie with my latex installation, but with the way Mathematica exports the plot to EPS. Is this known to be platform-dependent?

In version 10 psfrag is completely dead, since even one letter symbols do not help, which is also acknowledged by WRI. However, in version 10 pdf export itself has improved significantly and treats latex quality fonts relatively smoothly, with a possible exception of linux users. – Alexey Bobrick – 2015-02-18T22:14:08.470

This is not a direct solution to your problem, but you might be interested in exporting the data in a csv, dat or txt file and have it read by $\LaTeX$ using tikz, pgfplots and/or even Asymptote. This has many advantages and the workflow is usually smoother and simpler. – anderstood – 2015-02-18T22:29:35.583

2

Have you tried converting the eps to pdf first? The epstopdf package is nice for this.

\documentclass{article}

\usepackage{graphicx}
\usepackage{epstopdf}

\begin{document}

\includegraphics{plot.eps}

\end{document}

I've run into the same sort of problem. I can't currently confirm for your set up because I'm not running a Linux box at the moment. I believe what's going on is not an issue with Mathematica at all. I think it might still be an issue with your LaTeX distribution. MikTeX (the Windows LaTeX distribution) includes an eps converter that will automatically convert the eps to pdf and then include it in the PDFLaTeX document. As hinted at in the articles you yourself referenced it's really only an issue with EPS and PDFLaTeX.

If that's not the case then it might be that your EPS bounding boxes are too big. For a solution to that problem see the second answer in this article.

Another useful article is here.