5
$\begingroup$

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.

enter image description here

$\endgroup$
10
  • 2
    $\begingroup$ 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. $\endgroup$
    – rhermans
    Jul 30, 2018 at 7:53
  • $\begingroup$ 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. $\endgroup$ Jul 30, 2018 at 8:55
  • 1
    $\begingroup$ 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. $\endgroup$
    – Hector
    Jul 30, 2018 at 10:14
  • $\begingroup$ @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. $\endgroup$ Jul 30, 2018 at 10:58
  • 3
    $\begingroup$ You might want use MaTeX. That might avoid your trip through psfrag. $\endgroup$
    – Hector
    Jul 30, 2018 at 12:51

1 Answer 1

3
$\begingroup$

This problem is SOLVED by printing the offending text components using white color. In other words, when I use

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[Style["A", White], {0.82, 0.5}], 
   Text[Style["B", White], {1.68, 1.0}]}
        ]

instead of black text as in the question, the end result (after LaTeX and psfrag have done their parts) is as expected. The ghost text is no longer visible. And, psfrag still finds the literal string in the eps source code as long as in the show command tekstit is listed before the pink regions.

$\endgroup$
1
  • $\begingroup$ I'm still interested in learning about what changed from version 9 to version 11. This thread may be related, but I cannot tell for sure. A step backwards by Wolfram if you ask me, but I guess they know something I don't. $\endgroup$ Sep 17, 2018 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.