2

I am trying to change some text inside some figures of extension .EPS using the package psfrag. Unfortunately, one of the software which I am using to prepare these figures, the cad CATIA, has not an EPS output (only DXF, PDF, SVG, PS, PNG, JPG, TIFF, etc...). Then, I saved the figure as pdf and I converted the obtained file to EPS using Adobe Acrobat. But psfrag does not seem to work on this final file.

The other software that I am using, SigmaPlot, has an EPS output, however psfrag cannot operate neither on this output. It seems that there are different EPS formats, or codes maybe, and the ones that I get are not usable by psfrag. I have read a lot of posts on this argument thus excuse me please if this is yet another duplicate of things already explained. I have to confess however that I have not really understood the answers provided, probably because I am a beginner on Latex.

Then, I would like to ask: are there different EPS formats? How can I get the one usable by psfrag? From which file is better to pass, I mean it is better to generate first a PDF and then convert this in EPS, or maybe it is better to have firstly a JPG? How can I obtain the EPS from the firstly-generated file? Or in alternative, what is the best way to handle this problem in Latex. Many thanks in advance

3
  • 1
    Welcome to TeX.SX! Did you make psfrag work at all, i.e. with another EPS file? Maybe first try this, to make sure the error really stems from the other EPS files. Jul 12, 2022 at 11:15
  • 1
    Your best chance is probably to output to ps and then use ps2eps to add a bounding box (thus creating an eps file). However, it may not work even then. I will add a detailed answer... Jul 12, 2022 at 11:35
  • @JasperHabicht, it works with an .eps file I managed to produce using matlab. Thank you.
    – umby
    Jul 12, 2022 at 12:43

2 Answers 2

1

In general, an encapsulated postscript (eps) file is a set of geometrical instructions describing how a figure is drawn. If the eps file contains instructions which translate to something like:

Use this font, put the label 'y=x' here

then psfrag can intercept the instruction and change y=x to something else. Spaces around the label can sometimes make trouble, though (see below). However, some eps files (notably those exported from Maple) contain geometrical instructions to draw the characaters themselves. The psfrag package cannot work in this case. A third case (the worst of all) is that an eps file can contain bitmaps (collections of coloured dots). If the labels are stored in this way, then they can't be replaced by psfrag, and they will distort if the figure is resized.

For your CATIA figures, the best approach is to export to postscript (ps), and then use ps2eps to add a bounding box to the file (this presence/absence of a bounding box is the only difference between postscript and encapsulated postscript). Then try psfrag again.

For cases where psfrag fails, try opening the file using your favourite text editor, and searching for a label. Let's say you used the label y=x. If you are lucky, the postscript code will contain an instruction such as

(y=x ) CShow 

There are many variations of this, but the key point is that you can delete any spaces you find around y=x to make psfrag work. If you don't find the label anywhere, then either the characters have been drawn individually or they have been bitmapped. Unless you can find an option to change the way in which your figure drawing software exports postscript code, I'm afraid you are then stuck up a well-known creek without a paddle.

18
  • 1
    @umby --- What platform are you using (Windows/Mac OS/linux)? Jul 12, 2022 at 14:36
  • 2
    @umby ps2eps is a program, not a latex package, but I would concentrate on the main suggestion in this answer, look in the eps file for your label make a test eps with label xyz then look for (xyz) in the eps. If it is not there psfrag can not work. If (x) and (y) and (z) appear then it is writing labels one letter at a time, so use single letter labels and replace using psfrag with real text Jul 12, 2022 at 14:38
  • 1
    oh then normally psfrag will work (make sure you are using latex/dvips not pdflatex) Jul 12, 2022 at 14:59
  • 1
    @umby if you make a small test eps you could share it using google drive or overleaf or dropbox etc, we could have a look.... Jul 12, 2022 at 15:02
  • 1
    @umby --- You might already have ps2eps. Unfortunately I'm not that familiar with how these things work on windows, but you can try opening a dos prompt (or whatever it's called these days) and entering ps2eps. Does it recognise the command? Jul 12, 2022 at 15:04
0

Summarizing the answer and the comments:

In Catia, you first save the image as .pdf, then in Adobe you resize and save as .eps, but you need to use single letter labels.

In SigmaPlot, you first export the image as .emf (enhanced metafile), then in Adobe you resize and save as .eps, but you need to use single letter labels. (Unfortunately, psfrag does not seem to recognize labels in an .eps file directly produced by SigmaPlot)

Many thanks to David Carlisle and Ian Thompson.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .