[Tex/LaTex] auto-pst-pdf and TeXstudio under MacTeX

auto-pst-pdfmactextexshoptexstudio

I use pdflatex to compile source files that contain EPS figures as well as PSTricks. My standard way of handling this is to use auto-pst-pdf. I have been using TeXstudio to compile files under Windows with no problem. Recently, I have tried the same under MacTeX 2013 with TeXstudio 2.6.4 with no success and the error message

sh: latex: command not found.

I know that auto-pst-pdf runs latex+dvips+ps2pdf first, but I do not understand why running latex runs into trouble.

By the way, TeXShop runs the file with no problem.

Minimal Example: This code runs fine under windows (with MikTeX) when I use Winedt or Texstudio. It also runs fine with MacTex if I use Texshop, but gives me errors if I run it with texstudio on Mac. It returns a pdf file that instead of the figure has a blank square in it.

\documentclass{article}
\usepackage{graphicx}
\usepackage{microtype}
\usepackage{auto-pst-pdf}
\begin{document}
This is a test. The following figure should be processed OK when PdfLaTeX is run.

\bigskip

\includegraphics[width=5in]{fig4.eps}
\end{document}

Best Answer

To diagnose your problem, try this with pdflatex -shell-escape filename.tex.

% this input file name is filename.tex
% compile it with pdflatex -shell-escape filename.tex

\documentclass[preview,border=12pt]{standalone}

\usepackage{filecontents}

\begin{filecontents*}{temporary.tex}
\documentclass[pstricks,border=12pt]{standalone}
\usepackage{graphicx}
\newsavebox\IBox
\savebox\IBox{\includegraphics{example-image-a.eps}}
\psset{xunit=\wd\IBox,yunit=\ht\IBox}
\begin{document}
\begin{pspicture}[showgrid=top](1,1)
    \rput[bl](0,0){\usebox\IBox}
\end{pspicture}
\end{document}
\end{filecontents*}

\usepackage{graphicx,pgffor}
\edef\AutoRotateOff{-dAutoRotatePages=/None}

\foreach \compiler/\ext in {latex/tex,dvips/dvi,ps2pdf \AutoRotateOff/ps}{\immediate\write18{\compiler\space temporary.\ext}}

\begin{document}
This is a test. The following figure should be processed OK when PdfLaTeX is run.

\bigskip

\includegraphics{temporary.pdf}% extension is not necessary
\end{document}

If you can get the following, there is a problem with your editor.

enter image description here

Related Question