我是 PStricks 的新手。我的 miktek 库已安装 pstricks 包。
当我运行此代码时
\documentclass{article}
\usepackage{graphicx}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{pstricks}
\begin{document}
\begin{pspicture}(5,5)
\psline(1,1)(5,1)(1,4)(1,1)
\pscircle[linestyle=dotted](3,2.5){2.5}
\pscircle[fillstyle=solid,fillcolor=lightgray](2,2){1}
\end{pspicture}
\end{document}
它给我一个错误,说未定义的控制序列。
这是错误的完整版本:
! Undefined control sequence.
<recently read> \c@lor@to@ps
l.9 \psline(
1,1)(5,1)(1,4)(1,1)
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.
! Undefined control sequence.
\XC@usec@lor ...string \color@ #1#2\endcsname \@@
\fi \space
l.9 \psline(
1,1)(5,1)(1,4)(1,1)
The control sequence at the end of the top line
of your error message was never \def'ed.
答案1
您可以使用pdflatex
来编译带有pstricks
代码的文件,但由于 .pdf 格式( 的一个子集postscript
)没有用于 PostScript 所需计算的计算引擎,因此必须将这些计算外包。这是通过auto-pst-pdf
包完成的。
它将在您使用MiKTeX 下、 TeX Live 或 MacTeX 下的pdflatex
开关启动的情况下工作。--enable-write18
-shell-escape
我借此机会稍微缩短并改进了您的代码:
\documentclass{article}
\usepackage{graphicx}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{pstricks}
\usepackage{auto-pst-pdf}
\begin{document}
\begin{pspicture}(5,5)
\pspolygon[linejoin = 1](1,1)(5,1)(1,4)
\pscircle[linestyle=dotted](3,2.5){2.5}
\pscircle[fillstyle=solid,fillcolor=lightgray](2,2){1}
\end{pspicture}
\end{document}