# Beginners Guide to PSTricks for TeXShop users for math functions

I am looking to get help to plot tangent function. I find TikZ insufficient capability on TeXShop.

I am thinking about PSTricks and TeXShop. Is there any useful documentation or tutorial on packages involved to start plotting math trig function plots.

-
PSTricks is a set of packages; TeXShop is an editor. As such the two are really independent of each other. The following question might be of help if you are intending to use PSTricks with TeXShop, though: How to run PSTricks in TeXShop. – Alan Munn Aug 9 '12 at 3:39

Have a look at the pst-plot package- the following example is taken from page 28 of the documentation

\documentclass{article}

\usepackage{pst-plot}

\begin{document}

\begin{pspicture}(-6.5,-4)(6.5,7.5)
\psaxes[trigLabelBase=2,dx=\psPiH,xunit=\psPi,trigLabels]%
{->}(0,0)(-1.7,-3.5)(1.77,6.5)[$x$,0][$y$,90]
\psset{algebraic=true}
\psplot[yMaxValue=6,yMinValue=-3,linewidth=1.6pt,plotpoints=2000,
linecolor=red]{-4.55}{4.55}{tan(x)}
\end{pspicture}

\end{document}

-
I have some issues compiling to pdf file./article.tex:24: Undefined control sequence. <recently read> \c@lor@to@ps l.24 {->}(0,0)(-1.7,-3.5)(1.77,6.5)[$x$,0][$y$,90] – mark Aug 9 '12 at 3:49
How do you compile it from source .tex code to .pdf on TeXShop.Any settings on TeXShop I use LateX but I cannot see the desired graphics. I am new to PS tricks although I have used tikz for diagrams. – mark Aug 9 '12 at 3:56
@mark If you are using PSTricks you need to compile via "LaTeX=>PS=>PDF". PSTricks doesn't work with pdflatex directly. – percusse Aug 9 '12 at 10:34
or use xelatex instead of pdflatex – Herbert Aug 9 '12 at 14:48
@mark The question I linked to in my comment to your question shows you how to run the code in TeXShop. – Alan Munn Aug 9 '12 at 16:37

see http://tug.org/PSTricks/main.cgi?file=pdf/pdfoutput#TS for configuring TeXShop for using latex->dvips->ps2pdf

Alternetively use

\usepackage[pdf]{pstricks}


and run your document with pdflatex -shell-escape. The above page show how shell-escape can be enabled.

-
Apart from the fact that the linked image shows the German localisation of TeXShop, it's not terribly helpful: the issue is not setting up TeXShop to use latex->divps->ps2pdf (which it is set up to do out of the box) but how to tell TeXShop to do that for a particular document. See How to run PSTricks in TeXShop. – Alan Munn Aug 9 '12 at 16:42
Does that mean I removed the 'file-line error' statements in the window: Latex(default:pdflatex). – mark Aug 10 '12 at 6:32

Another method, compile it with pdflatex --shell-escape filename.

\documentclass{article}

\usepackage{filecontents}
\begin{filecontents*}{dummy.tex}
\documentclass[border=12pt,pstricks]{standalone}
\usepackage{pst-plot}
\begin{document}
\begin{pspicture}(-6.5,-4)(6.5,7.5)
\psaxes[trigLabelBase=2,dx=\psPiH,xunit=\psPi,trigLabels]%
{->}(0,0)(-1.7,-3.5)(1.77,6.5)[$x$,0][$y$,90]
\psset{algebraic=true}
\psplot[yMaxValue=6,yMinValue=-3,linewidth=1.6pt,plotpoints=2000,
linecolor=red]{-4.55}{4.55}{tan(x)}
\end{pspicture}
\end{document}
\end{filecontents*}

\usepackage{graphicx}

\def\GetImage#1{%
\immediate\write18{latex dummy}%
\immediate\write18{dvips dummy}%
\immediate\write18{ps2pdf dummy.ps}%
\includegraphics[scale=#1]{dummy}%
}

\begin{document}
\noindent
\fbox{\GetImage{1}}

\end{document}

-