[Tex/LaTex] PSTricks at LyX (via pdflatex)

auto-pst-pdflyxpdftexpstricks

I'm using LyX (at Windows) and I'm trying to get pdf file output while I have PSTricks code (I put as \ERT.
I Try to write at the preamble things like: \usepackage[off]{auto-pst-pdf}
and \usepackage[pdf]{pstricks}, but it still don't compile to pdf file output. (also ps4pdf doesn't help…).

Can you tell me how can I do it?

Thank you!


Here is the code:

 % Preview source code

%% LyX 2.0.5.1 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[twocolumn,english,hebrew]{article}
\renewcommand{\familydefault}{\rmdefault}
\usepackage[T1]{fontenc}
\usepackage[cp1255]{inputenc}
\setlength{\parindent}{0bp}

\makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
\def\@outputdblcol{%
  \if@firstcolumn
    \global \@firstcolumnfalse
    \global \setbox\@leftcolumn \box\@outputbox
  \else
    \global \@firstcolumntrue
    \setbox\@outputbox \vbox {%
      \hb@xt@\textwidth {%
      \kern\textwidth \kern-\columnwidth %**
      \hb@xt@\columnwidth {%
         \box\@leftcolumn \hss}%
      \kern-\textwidth %**
      \hfil
      {\normalcolor\vrule \@width\columnseprule}%
      \hfil
      \kern-\textwidth  %**
      \hb@xt@\columnwidth {%
         \box\@outputbox \hss}%
      \kern-\columnwidth \kern\textwidth %**
    }%
  }%
  \@combinedblfloats
  \@outputpage
  \begingroup
  \@dblfloatplacement
  \@startdblcolumn
  \@whilesw\if@fcolmade \fi
  {\@outputpage
    \@startdblcolumn}%
  \endgroup
  \fi
}
\@mparswitchtrue

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Textclass specific LaTeX commands.
\usepackage{theorem}
\theorembodyfont{\upshape}
\newtheorem{theorem}{\R{משפט}}[section]
\AtBeginDocument{\make@lr\thetheorem}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage[crop=off]{auto-pst-pdf}
\usepackage{pstricks}

\makeatother

\usepackage{babel}
\begin{document}
\pscircle(0,0){1}
\end{document}

Best Answer

the problem is the missing optional argument -shell-escape for pdflatex. You can add it with Tools->Setup->File->Converter->LaTeX (pdflatex)

enter image description here

Then you need only in the preamble

\usepackage{auto-pst-pdf}
\usepackage{pstricks}

and, of course, but the PSTricks stuff into the pspicture environment:

\begin{pspicture}(-1,-1)(1,1)
\pscircle(0,0){1}
\end{pspicture}

However, using xelatex instead makes it easier, no need for package auto-pst-pdf

Related Question