# Exporting graphics in eps-format. A change from version 9 to version 11 made it less useful for LaTeX

Recently I ran into this problem when trying to use EPS-images produced by Mathematic in my TeX-documents.

The friendly people at TeX.SE took a look at my eps, and discovered the following "feature" of the eps-file produced by version 11. My image had a text string on a monocolor pink background. This was apparently included into the eps both as a string as well as outlined in some "purely" graphical form. I don't see it with GhostView, apparently the people at TeX.SE used more powerful methods. Anyway, when I used the psfrag package to substitute the string with a snippet of TeX, the literal string was substituted all right, but graphical "copy" stayed. Resulting in a less than pleasing image in my document.

Q: How do I coerce Mathematica to save a piece of Graphics in an EPS-file in such a way that a textual component on colored background is only saved as a string and not also as outlined graphics? I don't care if the colored component obscures the text in, for example GhostView, as long as psfrag can find the text string.

This could be a feature, but...

• Two years ago I had produced a very similar eps with Mathematica v.9. Back then this graphical ghost was not there. I looked at that eps-file in GhostView, and the black text on pink background was nowhere to be seen - except that the literal string was part of the eps code because psfrag could replace it all right!
• When I regenerated that two year old image using the version 9 notebook/source, things changed. Now I can see the black text in GhostView, psfrag leaves that part, and my typeset document is not so nice.

Below please find a minimal set of Mathematica commands to create the problem.

pinkki2 = ParametricPlot[u {Cos[t], Sin[t]}, {u, 1.8, 2.2},
{t, 0.35, 0.7}, Mesh -> False, PlotStyle -> Pink];
pinkki1 = ParametricPlot[u {Cos[t], Sin[t]}, {u, 0.8, 1.2},
{t, 0.35, 0.7}, Mesh -> False, PlotStyle -> Pink];
tekstit = Graphics[{
Text["df", {0.4, 0.23}],
Text["dr", {1.5, 1.35}], Text["dr", {0.75, 0.7}],
Text["r1df", {0.6, 0.32}], Text["r2df", {1.43, 0.85}],
Text["A", {0.82, 0.5}], Text["B", {1.68, 1.0}]}
];
Show[{tekstit, pinkki1, pinkki2}, AspectRatio -> Automatic,
Ticks -> None, AxesLabel -> {"X", "Y"}]

What changed in Mathematica's handling of eps from version 9 to version 11?

How can I go back to version 9 behavior?

I have tried tinkering with the order of the graphics-components in Show. If I use Show[{pinkki1,pinkki2,tekstit}] instead, then psfrag will not find the string, and won't do the substitution at all.

Below you see what it looks like psfrag+LaTeX have replaced one of the "A" strings with $dA_1$ and one of the "B"-strings with $dA_2$. The non-textual version of the string shows through - see the part with a magnifying glass.

• Where is the code used to produce the graphs then and now? How can we detect the presence of the undesirable feature? I'm afraid that asking "What changed in Mathematica's handling of eps from version 9 to version 11?" is too broad of a question. And should be constrained to your particular problem, of which you haven't provided enough information to reproduce it. – rhermans Jul 30 '18 at 7:53
• Very sorry about that @rhermans. Mathematica commands now included. The eps-file was created by selecting the appropriate cell and using the Save Graphics as -interface. – Jyrki Lahtonen Jul 30 '18 at 8:55
• There is too much noise in that code. Please provide a minimal working example. You are combining 15 plots. Do the following: create the image with the first 8 plots. Export it and check if the error persist. If it does, pick the first 4 plots. If it does not, pick the last 8 plots … you get the idea … do a binary search. Once you got the absolute minimum to reproduce the error, post again. – Hector Jul 30 '18 at 10:14
• @Hector Now only the necessary three commands are listed. Sorry about the clutter earlier. I also added a link to the generated eps-file as well as the psfrag+LaTeX output. – Jyrki Lahtonen Jul 30 '18 at 10:58
• You might want use MaTeX. That might avoid your trip through psfrag. – Hector Jul 30 '18 at 12:51