# Using psfrag with pdflatex

Is there any way of using psfrag with pdflatex? It seems fairly similar to the problem of using pstricks with pdflatex. Do they both depend on the same things, or does psfrag include pstricks?

Can I assume that if I use one of the workarounds to make pstricks work, the same workaround would do for psfrag? Is there an equivalent of \usepackage[pdf]{pstricks} that will work for psfrag?

I realise there are a few questions here rather than just one, but they all share the overall question of how to use psfrag with pdflatex. Thank you.

-
@lockstep: Sorry, I just see that I reverted your capitalization. (You were so keen on that capitalization that you missed the typo in the title :-)) As I see it, if we talk about the program pdflatex, we don't use capitalization. –  Hendrik Vogt Mar 1 '11 at 10:33
@Hendrik: Thanks for correcting the typos! –  lockstep Mar 1 '11 at 11:48
I will also thank you both, as they were originally my typos. –  Dom Mar 1 '11 at 12:12

I recommend (disclaimer, I wrote them both) either of the pstool or the auto-pst-pdf packages. The latter is more useful when you have other PSTricks material; pstool is better when you only have psfrag material only. (One day I'd like to extend pstool to handle both cases.)

They both use the -shell-escape feature to process the psfrag graphics separately before inserting them into the document.

-
Thanks for the suggestions, I put auto-pst-pdf in for using pstricks and used the --shell-escape feature. Does this mean that I can just include psfrag as well as pstricks after including the auto-pst-pdf package? p.s. did you not include links because you wrote them? –  Dom Feb 23 '11 at 14:41
@Dom — it's late and I'm too lazy to include links :) If you're using a recent MiKTeX or TeX Live you should have the packages installed already. For psfrag usage in auto-pst-pdf, you must surround the graphics with \begin{postscript}...\end{postscript}. See the pst-pdf (no auto-) documentation for further information. –  Will Robertson Feb 23 '11 at 14:46
Thanks, this worked very well. Only thing I will say is it is very slow with large eps files (approx 2Mb) and Ghostscript maxed out my cpu for around 5 mins! I like it though, makes everything much easier. –  Dom Feb 25 '11 at 20:12
@Dom that sounds about right. Do you need such big eps files though? Sounds like possibly you've got big bitmaps which would be better off in PNG from the start, or very highly sampled plots that could be decimated. What sorts of figures are they? –  Will Robertson Feb 26 '11 at 1:43
It's highly sampled plots, Plot3d generated by mathematica. I don't need it, and I'm thinking about removing the 3d plot in favour of a clearer contour version anyway. –  Dom Feb 28 '11 at 11:53

After some further googling I found something potentially useful. It seems someone has written a bourne-shell script and package that work together, it's called pdfrack.

After a quick read of the instructions, it seems you create your document and run the shell script first to generate pdf pictures of the eps files with the psfrag replacements. Then you run pdflatex normally on your document, to build the pdf including the pdf pictures already generated by the pdfrack package.

Disclaimer: I haven't tried this yet, and to be honest, Will Robertson's answer seems to be the easier solution.

-

I just wrote an answer to the similar question psfrag substitute when using pdflatex.

I am doing Latex marking on .pdf with Inkscape. Basically when saving a picture into pdf, you can select an option "filter all text and write it in an ancillary file". Then Inkscape creates two outputs, the pdf image without any text and a tex file you include, which places text on the pdf image. There is nothing much more to do than open-and-save your pdf, then replace \includegraphics{mypix.pdf} by \include{mypix.pdf-tex}, the file created by inkscape.

-
I don't know how this solves the problem. Could you show some example? –  Christian Hupfer Dec 12 at 16:01
Some more help and examples on the online documentation Note that here you first load your pdf file with "recognise text fields" before the steps described –  clemlaflemme Dec 15 at 9:06