Graphics, Figures & Tablespst-plot package

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
workerbee
Posts: 43
Joined: Sat Nov 22, 2008 1:53 am

pst-plot package

Post by workerbee »

Hi,

So I'm trying to draw a graph within Latex using the pst-plot package but I'm having trouble in a very odd place.

Here's my coding:

Code: Select all

\documentclass[11pt]{book}
\usepackage{pst-plot}
\usepackage{pstricks}

\begin{document}


\psset{unit=2cm}
\begin{pspicture}(-2.5,-1)(2.5,1)
\psline[linewidth=.5pt](-2.5,0)(2.55,0) % x-axis
\psline[linewidth=.5pt](0,-1)(0,1) % y-axis
\psplot[plotpoints=300]{-2.5}{.133}
{3 x 2 exp mul 2 x mul sub 15 x mul 2 sub div}
\psplot[plotpoints=300]{.134}{2.5}
{3 x 2 exp mul 2 x mul sub 15 x mul 2 sub div}
\end{pspicture}

\end{document} 
However, before the style package can even attempt to load, I get an error message regarding the very first line:

! LaTex Error: Two \documentclass or \documentstyle commands

The confusion is that I've used this in the preamble before and it works perfectly fine. It is only in conjunction with the attempted pst-plot package that this arises. Can someone please explain?

Any feedback would be most appreciated. Thanks!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Keta
Posts: 63
Joined: Tue Nov 25, 2008 1:00 pm

Re: pst-plot package

Post by Keta »

I get no errors with the code above :?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Re: pst-plot package

Post by Stefan Kottwitz »

I can confirm that this code is compilable without errors.
Perhaps post your log file as attachment here.

Stefan
LaTeX.org admin
workerbee
Posts: 43
Joined: Sat Nov 22, 2008 1:53 am

Re: pst-plot package

Post by workerbee »

Sure. Here's the log file.
Attachments
pstricks.log
(5.69 KiB) Downloaded 356 times
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Re: pst-plot package

Post by Stefan Kottwitz »

I can see that the name of your file is pstricks.tex, that's causing the problem. pstricks.sty loads a file pstricks.tex by \input and finds your file instead of that of the package.
Just rename your tex file.

Stefan
LaTeX.org admin
workerbee
Posts: 43
Joined: Sat Nov 22, 2008 1:53 am

pst-plot package

Post by workerbee »

Thanks, Stefan.

I was able to get past that error and ran into another one. Apparently it's got a problem with the line: \psline[linewidth=.5pt]...

The coding is exactly the same as earlier, with a new file name; "using-tricks".

Here was the error message:

Code: Select all

! Undefined control sequence.
<recently read> \c@lor@to@ps 
                             
l.10 \psline[linewidth=.5pt](
                             -2.5,0)(2.55,0) % x-axis
? h
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

Re: pst-plot package

Post by Stefan Kottwitz »

That's because you are using pdfLaTeX, use LaTeX instead. That means, compile to dvi and use dvips to produce a postscript file. If you finally want to get pdf output, use ps2pdf afterwards.

Stefan
LaTeX.org admin
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

pst-plot package

Post by localghost »

To avoid more trouble take a look at the list of frequently done errors on the PSTricks homepage.


Best regards
Thorsten
workerbee
Posts: 43
Joined: Sat Nov 22, 2008 1:53 am

Re: pst-plot package

Post by workerbee »

Thanks, Stefan. It worked!
Post Reply