[Tex/LaTex] Issues with \psfrag, pdflatex in beamer

auto-pst-pdfbeamerpdftexpsfrag

I am using beamer to creating my presentation, I am using many Matlab generated figures and up until now, I was using \psfrag with 'auto-pst-pdf' for my articles. However, when I try to use the same technique with beamer, for some reasons it is not working returning the error as follows :

This is pdfTeX, Version 3.14159265-2.6-1.40.17 (MiKTeX 2.9 64-bit)         
(preloaded format=pdflatex 2016.7.6)  10 NOV 2016 16:07
entering extended mode
! Undefined control sequence.
<recently read> \psfrag
l.15 \end{frame}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
Overfull \hbox (117.2166pt too wide) in paragraph at lines 15--15
[]\OT1/lmss/m/n/10.95 SC[c][]Sensor
[]
Overfull \vbox (67.0767pt too high) detected at line 15
[]
[1
Non-PDF special ignored!
Non-PDF special ignored!
Non-PDF special ignored!{C:/Users/rganapat/AppData/Local/MiKTeX/2.9/pdftex/conf
ig/pdftex.map} <./test-pics.pdf>]
\tf@nav=\write6
\openout6 = `test.nav'.
\tf@toc=\write7
\openout7 = `test.toc'.
\tf@snm=\write8
\openout8 = `test.snm'.
Package atveryend Info: Empty hook `BeforeClearDocument' on input line 16.
Package atveryend Info: Empty hook `AfterLastShipout' on input line 16.
(test.aux)
Package atveryend Info: Executing hook `AtVeryEndDocument' on input line 16.
Package atveryend Info: Executing hook `AtEndAfterFileList' on input line 16.
Package rerunfilecheck Info: File `test.out' has not changed.
(rerunfilecheck) Checksum: D41D8CD98F00B204E9800998ECF8427E;0.
Package atveryend Info: Empty hook `AtVeryVeryEnd' on input line 16.
)
Here is how much of TeX's memory you used:
18442 strings out of 493335
352078 string characters out of 3128932
435874 words of memory out of 3000000
21529 multiletter control sequences out of 15000+200000
15137 words of font info for 20 fonts, out of 3000000 for 9000
1141 hyphenation exceptions out of 8191
56i,11n,55p,414b,378s stack positions out of 5000i,500n,10000p,200000b,50000s
{C:/Users/rganapat/AppData/Local/Programs/MiKTeX 2.9/fonts/enc/dvips/lm/lm-rm
.enc}<C:/Users/rganapat/AppData/Local/Programs/MiKTeX 2.9/fonts/type1/public/lm
/lmss10.pfb><C:/Users/rganapat/AppData/Local/Programs/MiKTeX 2.9/fonts/type1/pu
blic/lm/lmss12.pfb>
Output written on test.pdf (1 page, 33183 bytes).
PDF statistics:
35 PDF objects out of 1000 (max. 8388607)
3 named destinations out of 1000 (max. 500000)
41 words of extra memory for PDF output out of 10000 (max. 10000000)

Can somebody help me with this issue? Moreover, I am running my pdflatex with shell escape. In addition, I have also given a MWE for your use.

\documentclass{beamer}
\usepackage{lmodern}
\usepackage{graphicx}
\usepackage{auto-pst-pdf}
\setbeamertemplate{navigation symbols}{} 
\begin{document}
\begin{frame}
\frametitle{Circle}
\begin{figure}
   { 
   \psfragfig[width=0.3\textwidth]{images/f11.eps}
   \psfrag{SC}[c][]{Sensor carrier}
    }
\end{figure}
\end{frame}
\end{document}

Thanks in advance.

Best Answer

As the error shows \psfrag has not been defined. You can use pstool to automate this to a certain extent eg this runs without error

\documentclass{beamer}
\usepackage{lmodern}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{graphicx}
\usepackage{pstool}
\setbeamertemplate{navigation symbols}{} 
\begin{document}
\begin{frame}
\frametitle{Circle}
\begin{figure}
   \psfragfig[width=0.3\textwidth]{example-image-a}{
   \psfrag{A}[c][]{Sensor carrier}
    }
\end{figure}
\end{frame}
\end{document}

although simpler really than trying to use shell-escape tricks to use psfrag with pdflatex I would use a small self contained document with article class and latex to make a new pdf with the psfrag replacements, and then just include the new pdf into the beamer presentation with \includegraphics.

Related Question