My standard way of including math in figures so far was to use psfrag and latex+dvips+ps2pdf.
I am now moving to pdflatex and tend to prepare my graphics in pdf format. I was wondering if there exists a way to include math in pdf graphics similar to psfrag. I am aware of auto-pst-pdf package but prefer not to use it since on large projects it runs much slower than pdflatex and I am not sure if it can handle microtype as well as pdflatex.
Best Answer
Objectives and constraints
Assumption
For the sake of best practice, I assume that you put all of your EPS images in a sub directory called
Images
. It means that the directory structure is defined as follows.You have to follow this convention as the remaining code uses this structure. Of course you can change this directory structure but you also need to modify the code a bit (not much).
main.tex
andmyextractor.sty
will be discussed shortly.You are using Windows. If you are non-Windows users, please disabled the cleaning code mentioned in
myextractor.sty
.You know that you must compile the
main.tex
withNotes: For non-Windows users, replace
#
with=
.Step 1
Create a package called
myextractor.sty
as follows. Save it as mentioned in the directory structure above.Read the comments given in the code carefully. They are as follows.
and
Step 2
Modify your
main.tex
as followsThe important notes are
myextractor
package beforegraphicx
to preventgraphicx
overridesmyextractor
definition. Asmyextractor
loadsgraphicx
internally, you actually can disablegraphicx
inmain.tex
.\graphicspath
must be specified as given above.Step 3
Compile
main.tex
withlatex-dvips-ps2pdf
explained above. Afterwards, checkImages
folder, you will find a PDF version for each EPS image. Done!