7

I am currently updating my workflow from the old tex2ps2dvi workflow (needs a lot of time and matplotlib and other stuff etc. hasn't a EPS output (only PDF, SVG, PS, PNG, etc...).

I am trying to adopt the font in my picture to the rest of my document. Normally I use:

\psfrag{old text in old font}[l][l]{new text in new font}
\psfrag{old text in old font}[90][l][l]{90 deg rot new text in new font}

But I always have to save it as pdf and then open it with Illustrator and modify it and save it as EPS then include it...

Is there a native implementation of psfrag in LaTeX, which can handle the text-replacement with pdflatex?

  • 3
    Related, or possibly a duplicate: Why is there no pdffrag package? – Werner Jul 24 '12 at 07:00
  • mhh, simply not possible? well that's bad news! Are there any plans to implement it to pdf?? A kind of a pdffrag thing? – user1536844 Jul 24 '12 at 07:14
  • @user1536844 No, because as you say this is not possible: it's not a question of implementing 'something'. – Joseph Wright Jul 24 '12 at 07:50
  • 1
    I think more explicit than the other linked question is the discussion of psfrag in the answer here: http://tex.stackexchange.com/questions/60778/fundamental-differences-pstricks-tikz-pgf-and-others/60797#60797 – David Carlisle Jul 24 '12 at 12:34
  • ok, thank you guys, you made the psfrag thing a lot clearer to understand. I think i will try this approach http://tex.stackexchange.com/a/64483/16894. Thank you. – user1536844 Jul 24 '12 at 17:52
  • Did you mean matplotlib when you said mytplotlib? If so, try using the usetex feature: I have had success generating figures matching my LaTeX fonts. If this is the case, let me know: I could be persuaded to detail the process I use. – mforbes Jul 24 '12 at 20:33
  • yes sorry i mean matplotlib... (spelling error). I think usetex only writes latex to the figures, but i would like to include only the figure itself the font (axis labels, ticks etc.) in my native latex document font (font size etc.) A more detailed explanation would be great... thanks – user1536844 Jul 27 '12 at 02:45

4 Answers4

10

No pdffrag as you learned. I suggest the following "solution":

  1. Create a minimal tex document which uses psfrag to insert the appropiate labels and fonts, and use it to include all your eps figures. Use also preview package which will produce a document with a single figure per page, and with a page size fitted to the figure size.
  2. Compile that document with your habitual chain latex->dvips
  3. Convert the resulting PostScript file to pdf. Let say that the result is the file myfigures.pdf
  4. In your main document, include each figure at the appropriate point with \includegraphics[page=n]{myfigures.pdf}, being n 1, 2, 3... for each figure.

Alternatively, and I'm not joking, you may consider using TikZ to redo all your figures, specially if they are few and simple.

JLDiaz
  • 55,732
  • 5
    This is basically what the pst-pdf, auto-pst-pdf, and pstool packages all do internally :). You're right; there is no other alternative. – Will Robertson Jul 24 '12 at 07:43
  • The best solution is my answer below https://tex.stackexchange.com/a/579145/164392 (using the overpic package) or psfrag with auto-pst-pdf and pstool described also in my answer: https://tex.stackexchange.com/a/434761 – BOSKRI Abdelkarim Jan 01 '23 at 20:23
2

It's an old question and I'm not sure if this is an alternative in all the aspects, but it may be interesting to add the following:

I was able to do the replacement using the package pstool and the command \psfragfig{}{}

\documentclass{article}  
\usepackage{pstool}
\begin{document}
\psfragfig{fileinepsformat}{%
 \psfrag{a}{$\alpha$}
 \psfrag{b}{$\beta$}}  
\end{document} 

This compiles with pdflatex --shell-escape filename.tex

See also: https://mathematica.stackexchange.com/questions/736/latex-and-mathematica

altroware
  • 141
0

Maybe fragmaster may help ? It is an automated Perl script doing the same. See the home page of the project for a detailed procedure of how to use the Perl script in order to automate the procedure explained in the starred answer of this post.

Gim
  • 135
  • Welcome to TeX.SX! A full example would be of more use here, in my point of view. Just elaborate a little bit on your answer, please –  Oct 31 '14 at 09:35
0

The best solution is to use psfrag with pdflatex, I was resolved this problem in my answer for another question with the same problem in https://tex.stackexchange.com/a/434761

Also you can use OVERPIC like as :

\usepackage[percent]{overpic}

\begin{figure}[h!] \centering \begin{overpic}[width=0.5\textwidth]{Image} \put(0,1){texte} \put(10,20){$\alpha + \beta$} \end{overpic} \end{figure}

You can use grid option to put the tag in the right position, for example :

\begin{overpic}[ grid,width=0.5\textwidth]{Image}

And after you can remove the grid to show the pdf with all the tags
good look