I have a problem in getting pstool to work with \psfragfig.
I have a folder structure that looks as follows:
main.tex
images/
|
|-testeps.eps
The MWE is shown below. All the packages are included for completeness as that reflects the custom, university provided class file I use. In that class file some other commands are included but those are mostly related to the customisation of the headers and titles and therefore omitted.
\documentclass[a4paper,11pt,twoside,onecolumn,openright]{book}
% Packages found in the class (.cls) file
\RequirePackage{fncychap}
\RequirePackage{ifthen}
\RequirePackage{ifpdf}
\RequirePackage{hyperref}
\RequirePackage{colortbl}
\RequirePackage{geometry}
\RequirePackage{fancyhdr}
\RequirePackage{graphicx}
\RequirePackage{eso-pic}
\RequirePackage{psfrag}
\RequirePackage{nomencl}
\RequirePackage{subfig}
\RequirePackage{caption}
% Packages added by me
\usepackage{pdfsync} % enable tex source and pdf output syncronicity
\usepackage{natbib} % fancy citations
\usepackage{amsmath} % enables no-number equations {equations*}
\usepackage{tikz} % needed to import .tikz graphics
\usepackage{pgfplots} % needed to import .tikz graphics
\usetikzlibrary{plotmarks} % needed for tikz scatter plot
\usepackage[section]{placeins} % keeps figures from floating out of a
\usepackage{pstool} % necessary for psfrag with pdflatex
\DeclareGraphicsExtensions{.pdf,.png,.jpg,.eps} %graphicsx package set-up
\begin{document}
Text.
\psfragfig*[width=0.8\linewidth]{images/testeps}
{
\psfrag{A}{$flatplate_2$}
\psfrag{B}{$Plate_2$}
\psfrag{C}{$\gamma$}
}
\end{document}
This MWE compiles fine the first time, but when I try it a second time the output looks like this:

The log file has the following error line in it:
! LaTeX Error: Cannot determine size of graphic in testeps.pdf (no BoundingBox)
I have to manually delete all the files except for the .eps file in the images folder before it works again.
Obviously I don't want to delete all the files manually each time before every re-run, so how can I solve this problem?
I use TeXShop 3.24 on Mac OSX.
Update 1:
It seems that pstool trips over the presence of the .pdf file after it has run the first time.
After a first run the image folder contains the following files:
testeps-pstool.aux
testeps-pstool.out
testeps-pstool.pdfsync
testeps.eps
testeps.pdf
If I delete the .pdf file and rerun, all goes well.
Update 2:
It seems that the line
\DeclareGraphicsExtensions{.pdf,.png,.jpg,.eps} %graphicsx package set-up
was giving problems. Removing that line solves my problem.


\usepackage[cleanup={.tex, .dvi, .ps, .pdf, .log}]{pstool}works, but make sure which files you need before adding the extensions. – texenthusiast Oct 17 '13 at 00:51cleanupargument doesn't work. On the first run it now prints the text.dvi .ps .pdf .logafter the image, and on the second run the same error appears. – Saaru Lindestøkke Oct 17 '13 at 07:43