I am trying to use matlabfrag package in order to use pdflatex along with pstool. There is some kind of a strange issue which I could not understand. I exported some figures from MATLAB with the matlabfrag script.

And I downloaded the matlabfrag script on gitbub which seems to include some fixes, I also ended up with this script through this thread: Matlabfrag figure in latex

Here is my MWE

% MWE 

% figure 1

% figure 2


There are no problems with figure 2 but I am experiencing a similar problem as explained in the above thread with a red error box. And if I look inside the log file as explained there, I can see:

! Missing $ inserted.
<inserted text> 
l.23 ...hics [width=\textwidth ] {test_matlabfrag}

Update/Edit: This might be maybe useful for some other people in the future.

The general problem was in the tex file there was an error as mentioned in the accepted answer from David. I deleted the original files.

Links were here.

Any pointers on the source of error for the first file/figure inclusion is appreciated.

1 Answer 1


The TeX file has

\psfrag{008}[rc][rc]{\matlabtextB 10^{-4}}%
\psfrag{009}[rc][rc]{\matlabtextB 10^{-3}}%
\psfrag{010}[rc][rc]{\matlabtextB 10^{-2}}%
\psfrag{011}[rc][rc]{\matlabtextB 10^{-1}}%
\psfrag{012}[rc][rc]{\matlabtextB 10^{0}}%
\psfrag{013}[rc][rc]{\matlabtextB 10^{1}}%

which is inserting a TeX syntax error as it should be in math mode

\psfrag{008}[rc][rc]{\matlabtextB $10^{-4}$}%
\psfrag{009}[rc][rc]{\matlabtextB $10^{-3}$}%
\psfrag{010}[rc][rc]{\matlabtextB $10^{-2}$}%
\psfrag{011}[rc][rc]{\matlabtextB $10^{-1}$}%
\psfrag{012}[rc][rc]{\matlabtextB $10^{0}$}%
\psfrag{013}[rc][rc]{\matlabtextB $10^{1}$}%
  • Indeed thanks, I was so blind to see this ;-)
    – Umut Tabak
    Commented Mar 2, 2017 at 22:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .