Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I created an image in Mathematica with some labels that, for some reason, refuse to be substituted when using PSFrag.

Specifically, the Mathematica code

image = Plot[Sin[x], {x, 0, 2 π}, PlotLabel-> "label"]

will create the image

enter image description here

The following PSFrag code should, in principle, substitute the label label with a nicely formatted $\sin(x)$:





Indeed, a very similar version will work on the example.eps image provided by the PSFrag package in its documentation. However, the label is not replaced by my dvips driver. What is going wrong?

share|improve this question
this looks kind of interesting, but for truly beautiful graphics you might look at pgfplots or PSTricks –  cmhughes Mar 5 '14 at 21:19
@cmhughes Those are nice, but they cannot do the heavy numerical integrations required by my thesis work. Every tool has its place. –  E.P. Mar 5 '14 at 21:22
but you can still export the heavy numerical integration results to a text file that you can then read with pgfplots or pstricks. –  pluton Mar 6 '14 at 2:55
Following your example directly within Mathematica 8.0, I receive as output the entire label (label). –  Werner Mar 6 '14 at 5:04
@Werner I'm running Mathematica 9.0.1 over Ubuntu 12.04. I'm not sure at all what different versions or OSs will do. –  E.P. Mar 6 '14 at 10:26

2 Answers 2

This turns out to be the fault of Mathematica's export protocol to EPS. If you inspect such a file directly in a text editor, the code corresponding to the label has been split up into single letters:

(l) N
3 10.5 m
(a) N
7.797 10.5 m
(b) N
13.203 10.5 m
(e) N
18 10.5 m
(l) N

That is, the string (label), which is what PSFrag hunts for, has been split into the five different single-character strings (l), (a), (b), (e) and (l).

To fix this, simply change the quoted code above with the proper (label), or change your labels to single characters.

share|improve this answer

You may also like to try MathPSFrag, which I've had lots of success with in the past.

It automatically creates (customisable) psfrag labels for every string in the image.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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