I write papers in latex and write figures as PostScript programs. (The latter is not as crazy as it sounds, but that's a topic for elsewhere.)
My question is about the most intelligent way to get LaTeX to incorporate my homemade .ps pictures. There are several options that are short of ideal:
Use
latexthendvipsthenps2pdfand include graphics by\documentclass{amsart} \usepackage{graphicx} \begin{document} \includegraphics{my_ps_file.ps} \end{document}This works, but the
ps2pdfstep on a file with lots of figures is very time-consuming. (It has been on the order of a minute on a fast computer for some papers. Small.psfiles can have a lot in them because PostScript is a complete programming language.)Manually do
ps2pdfon each.psfileps2pdf -dEPSCrop -dNOSAFER my_ps_file.psthen use
pdflatex\documentclass{amsart} \usepackage{graphicx} \begin{document} \includegraphics{my_ps_file.pdf} \end{document}This works too, but there is the extra command-line step for every
.psfile that has been modified since your last run ofpdflatex.Use pdflatex and graphics rules
\documentclass{amsart} \usepackage{graphicx,epstopdf} \epstopdfsetup{suffix=} \DeclareGraphicsExtensions{.ps} \DeclareGraphicsRule{.ps}{pdf}{.pdf}{`ps2pdf -dEPSCrop -dNOSAFER #1 \noexpand\OutputFile} \begin{document} \includegraphics{my_ps_file} \end{document}The 5th line tells LaTeX that when it sees
\includegraphics{my_ps_file}, it should look for a filemy_ps_file.ps.The 6th line tells LaTeX how to handle
my_ps_file.ps: In order of the arguments, when (1) it sees a.psfile, it should eventually expect to have a.pdffile to insert, (3) it should read bounding box information from the.pdffile, and (4) it should run a certain command on the.psfile to get the.pdffile.The package
epstopdfis used here only so that I can use the 4th line\epstopdfsetup{suffix=}, which tells LaTeX to call the.pdffilemy_ps_file.pdfrather thanmy_ps_file-ps-converted-to.pdf.This works, and it automatically runs
ps2pdfonmy_ps_file.ps file, but only if it needs to: if it sees thatmy_ps_file.pdfalready exists, it usesmy_ps_file.pdf. (To get this feature, we used\includegraphics{my_ps_file}instead of\includegraphics{my_ps_file.ps}).This possibility eliminates the slowness of possibility (1) and eliminates the extra command-line steps of possibility (2). But unfortunately, it adds a new command-line step for every modified
.psfile: You have to manually removemy_ps_file.pdfevery time you changemy_ps_file.psor else LaTeX will keep using the oldmy_ps_file.pdfrather than making a new one.
Now for the question: The option I want, but don't know how to implement, would work just like (3), except that if my_ps_file.pdf is present and is newer than my_ps_file.ps LaTeX uses it, and otherwise runs ps2pdf on my_ps_file.ps.
Any ideas?