On 20/08/2010 5:57 AM, Pascal Francq wrote:
Hi,
I use the pstool package to combine psfrag and pdflatex and it works well. In
practice, to include a graphic I need a 'file.eps' and I use the \psfragfig
command of the form :
        \psfragfig[some options such as those of graphicx]{file.eps}{psfrag 
code}
I use the latex insets to add this graphic. Of course, I cannot see the file
in Lyx. My question is : is it possible to configure Lyx in such a way that,
when a graphic is included, it uses the psfragfig. In particular, in Lyx 2.0,
it seems to add some "external objects" such as xfig files. Where can I found
some information to create such an external object ?
Thanks.

Hi,

This solution is not using the external objects, but you could give it a try (only partially tested on a minimal example, but I got it to work):

1) Add, at the *end* of your preamble ("Document > Settings > LaTeX Preamble") [1]:

\usepackage{pstool}
\EndPreamble
\let\includegraphics\pstool

2) Use the usual mechanism for graphic insertion in LyX, specify your .eps file.

3) Put the {psfrag code} part in TeX code right after the graphic [2].

4) Define a new file format: In "Tools > Preferences > File Handling > File Format"

Click "New..." and enter the following
Format: PDF (pstool)
Doc format: yes
Vector graphics format: yes
Short name: pdf4
Extension: pdf
Viewer: auto
Click Apply

5) Define a new converter: In "Tools > Preferences > File Handling > Converters"

Select these:
From format: LaTeX (plain)
To format: PDF (pstool)
Enter this:
Converter: pdflatex -shell-escape $$i
Extra flag: latex
Click Add, then Apply

Cheers,
Julien

[1] Note that something more robust could be done, to cope with cases where you would forget to add {} in TeX code when there are no psfrag replacements for that figure. Left as an exercise.

[2] Activate the "View > View Source" option in LyX to help you out while doing that. Make sure the LaTeX code corresponds to what you want to achieve.

Reply via email to