我正在尝试建立本页上的图像:
当我执行“tex Cartesian_coordinates_2D.tex”最终时,我收到错误:
! 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}
?
这是我第一次使用 Tex,所以我不知道该怎么做。
这是 TeX,版本 3.14159265(MiKTeX 2.9.6100 64 位)Windows 7 Pro x64
[编辑]
或者,当我尝试在 Texworks 中运行脚本时出现以下错误:
! 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}
%
?
答案1
您需要使用latex
> dvips
>ps2pdf
或 来编译它xelatex
:
\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}
答案2
该代码比 Werner 的代码稍微简化了一些,可以通过以下方式编译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}
答案3
我认为,问题在于pst-plot.tex
已更新为依赖\dimexpr
。这在pspicture
LaTeX 中有效,但在纯 TeX 中无效。要使用纯 TeX 进行编译,您需要pst-plot97
替换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
我尝试按照链接页面上的说明进行编译,但我不知道该怎么做skconvert
是什么或在哪里可以找到它。无论如何,这似乎是一种非常迂回的方法。相反,我使用了沃纳的指示将 DVI 转换为 PS,然后转换为 PDF:
tex Cartesian_coordinates_2D.tex
dvips Cartesian_coordinates_2D.dvi
ps2pdf Cartesian_coordinates_2D.ps
为了将 PDF 转换为 SVG,我使用了
pdf2svg Cartesian_coordinates_2D.pdf Cartesian_coordinates_2D.svg
其产生的结果在 Inkscape 中正确显示。
答案4
在不丢失有用内容的情况下,您的图表可以简化如下。
\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}