6

I am trying to build the image on this page:

enter image description here

When I execute "tex Cartesian_coordinates_2D.tex" eventually I get the error:

! Undefined control sequence.
\psaxes@vii ... \pst@dimd {#6}\pst@dima =\dimexpr
                                              \pst@dima -\pst@dimg \rela...
<to be read again>
               \psset
l.8 \psset
      {linewidth=.4pt}
?

This is the first time I've used Tex so I don't know what to do.

This is TeX, Version 3.14159265 (MiKTeX 2.9.6100 64-bit) Windows 7 Pro x64

[edit]

Alternately, when I try to run the script in Texworks I get the following error:

! Package xkeyval Error: xkeyval loaded before \documentclass.
See the xkeyval package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.62 ...yval loaded before \protect\documentclass}
                                              %
? 
  • Welcome to TeX.SX! What's the file you're trying to compile (ideally in the form of a minimal (non-)working example (MWE). Are you sure you are/want to be running tex rather than pdflatex? – Dai Bowen Nov 27 '16 at 1:17
  • 2
    @DaiBowen It is pstricks source, so pdfTeX is not going to work, and it is certainly not a LaTeX document. – cfr Nov 27 '16 at 1:27
  • @cfr Ah I see, I'd followed the link to the image but missed that there was tex code beneath the image. – Dai Bowen Nov 27 '16 at 1:30
  • You can make it work with pdflatex if you also load auto-pst-pdf (to be loaded after pstricks) and use the switch --enable-write18 (under MiKTeX) or -shell-escape (TeX Live, MacTeX). Alternatively, compile with xelatex. – Bernard Nov 27 '16 at 1:33
  • 1
    @posfan12 The instructions tell you how to convert to SVG. To compile with LaTeX, you have to add the document environment and \documentclass etc. as in Werner's answer. TeXWorks is probably trying to use latex or pdflatex. – cfr Nov 27 '16 at 2:01
5

You need to compile this with either latex > dvips > ps2pdf or xelatex:

enter image description here

\documentclass{article}

\usepackage{pst-node,pst-plot}

\begin{document}

\psset{linecolor=black,linewidth=1pt,arrowsize=8pt,unit=0.29cm}
\begin{pspicture}(-15.3,-15.3)(17.4,15.3)

  % Axes
  \psaxes[Dx=5,Dy=5]{<->}(0,0)(-14.5,-14.5)(14.5,14.5)
  \psset{linewidth=.4pt}
  \psaxes[Dx=1,Dy=1,labels=none,ticksize=1.5pt](0,0)(-13,-13)(13,13)
  \uput{10pt}[0](0,14){\psscalebox{1.25}{\itshape y-axis}}
  \uput{10pt}[70](14,0){\psscalebox{1.25}{\itshape x-axis}}

  % Origin
  \pnode(0,0){O}
  \uput{35pt}[310](0,0){\rnode{Ot}{\psscalebox{1.1}{
          \vbox{\halign{\hfil#\hfil\cr$(0,0)$\cr\itshape origin\cr}}}}}
  \nccurve[angleA=315,angleB=145,arrowsize=4pt,
          nodesepA=2pt,nodesepB=-3pt,linecolor=gray]{<-}{O}{Ot}

  % Point
  \psdots[dotstyle=*,dotscale=1.2](3,5)
  \psline[linestyle=dotted,linewidth=.8pt](3,0)(3,5)(0,5)
  \uput{2.5pt}[53](3,5){\psscalebox{1.1}{$P(3,5)$}}

  % Quadrants
  \uput{3cm}[45](0,0){\psscalebox{1.6}{\bfseries I}}
  \uput{3cm}[135](0,0){\psscalebox{1.6}{\bfseries II}}
  \uput{3cm}[225](0,0){\psscalebox{1.6}{\bfseries III}}
  \uput{3cm}[315](0,0){\psscalebox{1.6}{\bfseries IV}}

\end{pspicture}

\end{document}
  • @Werner: Or load auto-pst-pdf` (see my comment above). – Bernard Nov 27 '16 at 1:35
  • Can you tell me how to compile it? This is the first time I've used Tex or Texworks. – posfan12 Nov 27 '16 at 1:54
  • I get the same error with Werner's code, if I wasn't being clear. – posfan12 Nov 27 '16 at 2:05
  • Never mind. I figured it out. @posfan12: that's odd. I haven't tested the LaTeX code yet. I've fixed the original to work with tex, though. – cfr Nov 27 '16 at 2:16
  • @posfan12 I do get Werner's output, but Okular doesn't display the intermediate files correctly. – cfr Nov 27 '16 at 2:45
7

This code, slightly simplified from Werner's, compiles with pdflatex:

\documentclass[border=4pt]{standalone}

\usepackage{pst-node, pst-plot, auto-pst-pdf}
\newcounter{quadrant}

\begin{document}

\psset{linewidth=1pt, linejoin=1, arrowsize=8pt,unit=0.29cm}
\begin{pspicture}%
\setcounter{quadrant}{0}
  % Axes
  \psaxes[Dx=5, Dy=5, subticks=5, subticksize=0.5, labelsep=10pt, label]{<->}(0,0)(-14.5,-14.5)(14.5,14.5)[\itshape x-axis, 90][\itshape y-axis, -10]
  \psset{linewidth=.4pt}

  % Origin
  \pnode(0,0){O}
  \uput{35pt}[310](O){\rnode{Ot}{\begin{tabular}{c}
         $(0,0)$\\[-0.7ex]\itshape origin\end{tabular}}}
  \nccurve[angleA=315,angleB=145,arrowsize=4pt,
          nodesepA=2pt,nodesepB=-3pt,linecolor=gray]{<-}{O}{Ot}

  % Point
  \dotnode[dotstyle=*,dotscale=1.2](3,5){P}
 \psline[linestyle=dotted,linewidth=.8pt](3,0)(3,5)(0,5)
  \uput{2.5pt}[53](3,5){\psscalebox{1.1}{$P(3,5)$}}

  % Quadrants
    \multido{\I=45+90}{4}{\stepcounter{quadrant}\nput[labelsep=3cm]{\I}{O}{\psscalebox{1.6}\expandafter\textbf{\Roman{quadrant}}}}
\end{pspicture}

\end{document}

enter image description here

5

The issue is, I think, that pst-plot.tex has been updated to rely on \dimexpr. This works in a pspicture in LaTeX, but not with plain TeX. To compile with plain TeX, you need to substitute pst-plot97 for pst-plot.

% original source: https://commons.wikimedia.org/wiki/File:Cartesian_coordinates_2D.svg
% licence: CC Attribution-Share Alike Unported 3.0: https://creativecommons.org/licenses/by-sa/3.0/deed.en
\input pst-eps\input pst-plot97\input pst-node
\TeXtoEPS
\psset{linecolor=black,linewidth=1pt,arrowsize=8pt,unit=0.29cm}
\pspicture*(-15.3,-15.3)(17.4,15.3)

% Axes
\psaxes[Dx=5,Dy=5]{<->}(0,0)(-14.5,-14.5)(14.5,14.5)
\psset{linewidth=.4pt}
\psaxes[Dx=1,Dy=1,labels=none,ticksize=1.5pt](0,0)(-13,-13)(13,13)
\uput{10pt}[0](0,14){\psscalebox{1.25}{\it y-axis}}
\uput{10pt}[70](14,0){\psscalebox{1.25}{\it x-axis}}

% Origin
\pnode(0,0){O}
\uput{35pt}[310](0,0){\rnode{Ot}{\psscalebox{1.1}{
        \vbox{\halign{\hfil#\hfil\cr$(0,0)$\cr\it origin\cr}}}}}
\nccurve[angleA=315,angleB=145,arrowsize=4pt,
        nodesepA=2pt,nodesepB=-3pt,linecolor=gray]{<-}{O}{Ot}

% Point
\psdots[dotstyle=*,dotscale=1.2](3,5)
\psline[linestyle=dotted,linewidth=.8pt](3,0)(3,5)(0,5)
\uput{2.5pt}[53](3,5){\psscalebox{1.1}{$P(3,5)$}}


% Quadrants
\uput{3cm}[45](0,0){\psscalebox{1.6}{\bf I}}
\uput{3cm}[135](0,0){\psscalebox{1.6}{\bf II}}
\uput{3cm}[225](0,0){\psscalebox{1.6}{\bf III}}
\uput{3cm}[315](0,0){\psscalebox{1.6}{\bf IV}}

\endpspicture
\endTeXtoEPS
\nopagenumbers
\end

I tried compiling using the instructions on the linked page, but I have no idea what skconvert is or where to get it. In any case, it seems a very circuitous way of going about it. Instead, I used Werner's instructions to convert the DVI to PS and then PDF:

tex Cartesian_coordinates_2D.tex
dvips Cartesian_coordinates_2D.dvi
ps2pdf Cartesian_coordinates_2D.ps

PDF result

To convert the PDF to SVG, I used

pdf2svg Cartesian_coordinates_2D.pdf  Cartesian_coordinates_2D.svg

which produced a result which displayed correctly in Inkscape.

  • Did you crop the image? The original Wikimedia commands do some automatic cropping and such, I think. – posfan12 Nov 27 '16 at 3:33
  • 1
    @posfan12 No, I didn't bother. I would probably use standalone or something to crop. I can't use the Wikimedia commands without skconvert and I don't have that. – cfr Nov 27 '16 at 4:35
  • simply use etex. No need to use the original tex program – user2478 Nov 27 '16 at 19:02
  • @Herbert I just meant to show how the original instructions were intended to work. But I didn't actually realise that tex is not now etex by default - thanks. – cfr Nov 27 '16 at 22:48
1

Without loss of useful contents, your diagram can be simplified as follows.

\documentclass[pstricks,preview,margin=5mm]{standalone}
\usepackage{pst-plot,pst-eucl}

\psset{unit=2mm,arrowscale=1.25}

\begin{document}
\begin{pspicture}(-15,-15)(17,17)
  \psaxes[Dx=5,Dy=5,tickwidth=.8pt,ticksize=4pt -4pt,subticks=5,subtickwidth=.4pt,subticksize=.4]{<->}(0,0)(-15,-15)(15,15)[$x$,0][$y$,90]
  \pstGeonode[PointName={P{(3,5)},O},PointNameSep={18pt,10pt},PosAngle={0,-45}](3,5){P}(0,0){O}
  \psCoordinates[showpoints=false,linestyle=dashed,dash=2pt 2pt](P)
  \foreach \i/\j in {45/I,135/II,225/III,315/IV}{\uput{11}[\i](0,0){\bfseries\j}}
\end{pspicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.