# Unable to get PSTricks to work as expected in Texmaker

I am trying to get PSTricks to work with PDFLaTeX in order to create scientific diagrams in the report I am producing.

My document is currently as follows (I've included potentially extraneous packages because I'm not sure what could have an impact on PSTricks):

\documentclass{article}
\usepackage{fullpage}
\usepackage{amssymb,amsmath}
\usepackage{concmath}
\usepackage[euler-digits,euler-hat-accent]{eulervm}
\usepackage{url}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{float}
\usepackage{url}

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

\makeatletter
\makeatother

\DeclareGraphicsExtensions{.pdf,.png,.jpg}

\begin{document}

\title{Rotational Dynamics}
\author{Thomas Russell}
\date{March 2014}
\maketitle

\begin{pspicture}(5,5)
%% Triangle in red:
\psline[linecolor=red](1,1)(5,1)(1,4)(1,1)
%% Bezier curve in green:
\pscurve[linecolor=green,linewidth=2pt,%
showpoints=true](5,5)(3,2)(4,4)(2,3)
%% Circle in blue with radius 1:
\pscircle[linecolor=blue,linestyle=dashed](3,2.5){1}
\end{pspicture}

\end{document}


And this compiles fine, but rather than embedding the image in the target PDF file, it creates a PostScript file: rotational-dynamics-autopp.ps and then embeds it in rotational-dynamics-autopp.pdf.

I am compiling the LaTeX file with the following build option in Texmaker:

pdflatex -synctex=1 -interaction=nonstopmode -shell-escape %.tex

• Compile your code with XeLaTeX not with pdflatex. – ferahfeza Mar 4 '14 at 11:58

That file runs fine in my up-to-date TeXLive 2013. However, try

\usepackage[crop=off]{auto-pst-pdf}


and, by the way, use

\usepackage[T1]{fontenc}%%%%%    use T1 encoded fonts
\usepackage{concmath}
\usepackage[euler-digits,euler-hat-accent]{eulervm}

• Thank you, adding the crop=off option seems to have fixed it! – Thomas Russell Mar 4 '14 at 11:43
• Not to be pedantic but the name of the LaTeX distribution is "TeX Live", not "TeXLive". (See tug.org/texlive/.) – Svend Tveskæg Mar 4 '14 at 12:05

Use the following packages in the preamble:

2. \usepackage{auto-pst-pdf}
3. \usepackage{pst-pdf}

Before you run the file using Quick Build (usually F1 button), go to the Texmaker Options-> Configure Texmaker-> Quick Build and change the quick build command to "Latex+dvips+ps2pdf+viewpdf".

Now you are done. Oh but there may be one more problem cropping up. Something like "Enable Write 18" or "shell escape disabled". You can sort out that problem by the beautiful answer given in this link: How can I enable write 18 on a MikTeX installation.

I am providing a sample tex file for drawing a simple graph:

\documentclass[10pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{auto-pst-pdf}
\usepackage{pst-pdf}
\begin{document}
\begin{figure}[h]
\begin{center}
\psscalebox{0.5 0.5} % Change this value to rescale the drawing.
{
\begin{pspicture}(0,-2.195)(7.73,2.195)
\psline[linecolor=black, linewidth=0.04, dotsize=0.07055cm 6.0]{-*}(3.2,1.805)(1.2,-0.595)
\psline[linecolor=black, linewidth=0.04, dotsize=0.07055cm 6.0]{-*}(3.2,1.805)(2.4,-1.395)
\psline[linecolor=black, linewidth=0.04, dotsize=0.07055cm 6.0]{-*}(3.2,1.805)(4.0,-1.395)
\psline[linecolor=black, linewidth=0.04, dotsize=0.07055cm 6.0]{*-*}(3.2,1.805)(5.6,-0.195)
\rput{66.6232}(2.6010673,-3.5480006){\psarc[linecolor=black, linewidth=0.04, linestyle=dashed, dash=0.17638889cm 0.10583334cm, dimen=outer](4.0,0.205){1.6}{208.56584}{270.0}}
\rput[bl](3.6,1.805){\Huge{$u$}}
\rput[bl](0.0,-1.395){\Large{ 1($\beta$)}}
\rput[bl](2.0,-2.195){\Large{ 2($\beta$)}}
\rput[bl](4.0,-2.195){\Large{ 3($\beta$)}}
\rput[bl](6.0,-0.595){\Large{ $n-1(\beta)$}}
\end{pspicture}
}
\end{center}
\caption{Graph of type - I matrix}\label{t1}
\end{figure}
\end{document}


The output in the pdf is :

Now, how to write these PStricks codes ?? Do we have to remember all the commands ?? No !! not at all !! Its very easy to generate these codes automatically by drawing the figures using Latex Draw. You can get this amazing free software at this link: http://latexdraw.sourceforge.net/

Thats all you need to know about using PStricks codes !!!