![PSTricks 无法正常工作](https://linux22.com/image/447076/PSTricks%20%E6%97%A0%E6%B3%95%E6%AD%A3%E5%B8%B8%E5%B7%A5%E4%BD%9C.png)
我尝试使用 PSTricks 绘制如下所示的图形
这是通过以下代码完成的(实际上这来自 arXiv 物理论文1410.4540):
\documentclass[margin=10pt]{standalone}
\usepackage{amsmath}
\usepackage{pst-all}
\begin{document}
$\displaystyle
\pspicture[shift=-0.95](-0.2,-0.35)(1.2,1.75)
\small
%%%%% Small oval:
\psarc[linewidth=0.9pt,linecolor=black,border=0pt] (0.8,0.7){0.4}{120}{240}
\psarc[linewidth=0.9pt,linecolor=black,arrows=<-,arrowscale=1.4,
arrowinset=0.15] (0.8,0.7){0.4}{165}{240}
\psarc[linewidth=0.9pt,linecolor=black,border=0pt] (0.4,0.7){0.4}{-60}{60}
\psarc[linewidth=0.9pt,linecolor=black,arrows=->,arrowscale=1.4,
arrowinset=0.15] (0.4,0.7){0.4}{-60}{15}
%%%%% Lines:
\psset{linewidth=0.9pt,linecolor=black,arrowscale=1.5,arrowinset=0.15}
\psline(0.6,1.05)(0.6,1.55)
\psline{->}(0.6,1.05)(0.6,1.45)
\psline(0.6,-0.15)(0.6,0.35)
\psline{->}(0.6,-0.15)(0.6,0.25)
%%%%% Labels:
\rput[bl]{0}(0.07,0.55){$a$}
\rput[bl]{0}(0.94,0.55){$b$}
\rput[bl]{0}(0.26,1.25){$c$}
\rput[bl]{0}(0.24,-0.05){$c'$}
\scriptsize
\rput[bl]{0}(0.7,1.05){$\mu$}
\rput[bl]{0}(0.7,0.15){$\mu'$}
\endpspicture
$
\end{document}
但是,当我使用 VS Code 用 XeLaTeX 编译此代码时(使用LaTeX 研讨会扩展名(extension)只产生了字母,直线和曲线全部缺失:
如何解决这个问题呢?
附加信息:我通过 Homebrew ( brew install --cask mactex-no-gui
) 安装了 MacTeX (2021.0328)。
编辑:根据@user187802的回答,我将LaTeX-Workshop(v.8.23.0)配置更改为:
"latex-workshop.latex.recipes": [
{
"name": "xelatex",
"tools": [
"xelatex"
]
},
],
"latex-workshop.latex.tools": [
{
"name": "xelatex",
"command":"xelatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"--shell-escape",
"-output-driver=\"xdvipdfmx -i dvipdfmx-unsafe.cfg -q -E\"",
"%DOC%"
]
},
],
但后来我收到错误(文件名是braid.tex
):
This is XeTeX, Version 3.141592653-2.6-0.999993 (TeX Live 2021) (preloaded format=xelatex)
\write18 enabled.
entering extended mode
(/path/to/braid.tex
LaTeX2e <2020-10-01> patch level 4
L3 programming layer <2021-02-18> (/usr/local/texlive/2021/texmf-dist/tex/latex/standalone/standalone.cls
Document Class: standalone 2018/03/26 v1.3a Class to compile TeX sub-files standalone
(/usr/local/texlive/2021/texmf-dist/tex/latex/tools/shellesc.sty) (/usr/local/texlive/2021/texmf-dist/tex/generic/iftex/ifluatex.sty (/usr/local/texlive/2021/texmf-dist/tex/generic/iftex/iftex.sty)) (/usr/local/texlive/2021/texmf-dist/tex/latex/xkeyval/xkeyval.sty (/usr/local/texlive/2021/texmf-dist/tex/generic/xkeyval/xkeyval.tex (/usr/local/texlive/2021/texmf-dist/tex/generic/xkeyval/xkvutils.tex (/usr/local/texlive/2021/texmf-dist/tex/generic/xkeyval/keyval.tex)))) (/usr/local/texlive/2021/texmf-dist/tex/latex/standalone/standalone.cfg) (/usr/local/texlive/2021/texmf-dist/tex/latex/base/article.cls
Document Class: article 2020/04/10 v1.4m Standard LaTeX document class
(/usr/local/texlive/2021/texmf-dist/tex/latex/base/size10.clo))) (/usr/local/texlive/2021/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/local/texlive/2021/texmf-dist/tex/latex/amsmath/amstext.sty (/usr/local/texlive/2021/texmf-dist/tex/latex/amsmath/amsgen.sty)) (/usr/local/texlive/2021/texmf-dist/tex/latex/amsmath/amsbsy.sty) (/usr/local/texlive/2021/texmf-dist/tex/latex/amsmath/amsopn.sty)) (/usr/local/texlive/2021/texmf-dist/tex/latex/pstricks/pst-all.sty (/usr/local/texlive/2021/texmf-dist/tex/latex/pstricks/pstricks.sty (/usr/local/texlive/2021/texmf-dist/tex/latex/xcolor/xcolor.sty (/usr/local/texlive/2021/texmf-dist/tex/latex/graphics-cfg/color.cfg) (/usr/local/texlive/2021/texmf-dist/tex/latex/graphics-def/xetex.def)) (/usr/local/texlive/2021/texmf-dist/tex/generic/xkeyval/pst-xkey.tex) (/usr/local/texlive/2021/texmf-dist/tex/generic/pstricks/pstricks.tex (/usr/local/texlive/2021/texmf-dist/tex/generic/pstricks/pst-fp.tex `pst-fp' v0.05, 2010/01/17 (hv)) (/usr/local/texlive/2021/texmf-dist/tex/generic/pgf/utilities/pgfutil-common.tex (/usr/local/texlive/2021/texmf-dist/tex/generic/pgf/utilities/pgfutil-common-lists.tex)) (/usr/local/texlive/2021/texmf-dist/tex/generic/pgf/utilities/pgfkeys.code.tex (/usr/local/texlive/2021/texmf-dist/tex/generic/pgf/utilities/pgfkeysfiltered.code.tex)) (/usr/local/texlive/2021/texmf-dist/tex/generic/pgf/utilities/pgffor.code.tex
Loading pgffor.code.tex
(/usr/local/texlive/2021/texmf-dist/tex/generic/pgf/math/pgfmath.code.tex (/usr/local/texlive/2021/texmf-dist/tex/generic/pgf/math/pgfmathcalc.code.tex (/usr/local/texlive/2021/texmf-dist/tex/generic/pgf/math/pgfmathutil.code.tex) (/usr/local/texlive/2021/texmf-dist/tex/generic/pgf/math/pgfmathparser.code.tex) (/usr/local/texlive/2021/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.code.tex (/usr/local/texlive/2021/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.basic.code.tex) (/usr/local/texlive/2021/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.trigonometric.code.tex) (/usr/local/texlive/2021/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.random.code.tex) (/usr/local/texlive/2021/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.comparison.code.tex) (/usr/local/texlive/2021/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.base.code.tex) (/usr/local/texlive/2021/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.round.code.tex) (/usr/local/texlive/2021/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.misc.code.tex) (/usr/local/texlive/2021/texmf-dist/tex/generic/pgf/math/pgfmathfunctions.integerarithmetics.code.tex))) (/usr/local/texlive/2021/texmf-dist/tex/generic/pgf/math/pgfmathfloat.code.tex)))
`PSTricks' v3.01 <2020/09/18> (tvz,hv)
(/usr/local/texlive/2021/texmf-dist/tex/xelatex/xetex-pstricks/pstricks.con (/usr/local/texlive/2021/texmf-dist/tex/generic/pstricks/config/xdvipdfmx.cfg)) (/usr/local/texlive/2021/texmf-dist/tex/xelatex/xetex-pstricks/pstricks.con (/usr/local/texlive/2021/texmf-dist/tex/generic/pstricks/config/xdvipdfmx.cfg
Using PSTricks configuration for XeTeX+xdvipdfmx
))) (/usr/local/texlive/2021/texmf-dist/tex/generic/pstricks/pst-fp.tex)
>>> Loading XeTeX special macros
(/usr/local/texlive/2021/texmf-dist/tex/generic/pstricks/pstricks-xetex.def)) (/usr/local/texlive/2021/texmf-dist/tex/latex/pst-plot/pst-plot.sty (/usr/local/texlive/2021/texmf-dist/tex/latex/xkeyval/pst-xkey.sty) (/usr/local/texlive/2021/texmf-dist/tex/latex/multido/multido.sty (/usr/local/texlive/2021/texmf-dist/tex/generic/multido/multido.tex v1.42, 2010/05/14 <tvz>)) (/usr/local/texlive/2021/texmf-dist/tex/generic/pst-plot/pst-plot.tex (/usr/local/texlive/2021/texmf-dist/tex/generic/pst-tools/pst-tools.tex `PST-tools' v0.10, 2020/03/24 (hv)) (/usr/local/texlive/2021/texmf-dist/tex/generic/pstricks-add/pstricks-add.tex (/usr/local/texlive/2021/texmf-dist/tex/generic/pst-node/pst-node.tex v1.42a, 2020/04/01) (/usr/local/texlive/2021/texmf-dist/tex/generic/pst-arrow/pst-arrow.tex `pst-arrow' v0.01, 2016/09/01 (dr,hv)) (/usr/local/texlive/2021/texmf-dist/tex/generic/pst-3d/pst-3d.tex `PST-3d' v1.11, 2010/02/14 (tvz)) (/usr/local/texlive/2021/texmf-dist/tex/generic/pst-math/pst-math.tex `pst-math' v0.64 , (CJ,hv)) `pstricks-add' v3.89a, 2020/02/12 (dr,hv)) v1.92, 2019/05/16 (tvz,hv))) (/usr/local/texlive/2021/texmf-dist/tex/latex/pst-node/pst-node.sty (/usr/local/texlive/2021/texmf-dist/tex/generic/pst-node/pst-node.tex)) (/usr/local/texlive/2021/texmf-dist/tex/latex/pst-tree/pst-tree.sty (/usr/local/texlive/2021/texmf-dist/tex/generic/pst-tree/pst-tree.tex v1.13, 2017/02/18(tvz,dg,hv))) (/usr/local/texlive/2021/texmf-dist/tex/latex/pst-grad/pst-grad.sty (/usr/local/texlive/2021/texmf-dist/tex/generic/pst-grad/pst-grad.tex `pst-grad' v1.06, 2006/11/27 (tvz,dg,hv))) (/usr/local/texlive/2021/texmf-dist/tex/latex/pst-coil/pst-coil.sty (/usr/local/texlive/2021/texmf-dist/tex/generic/pst-coil/pst-coil.tex v1.06, 2006/11/27 (/usr/local/texlive/2021/texmf-dist/tex/generic/pst-node/pst-node.tex))) (/usr/local/texlive/2021/texmf-dist/tex/latex/pst-text/pst-text.sty (/usr/local/texlive/2021/texmf-dist/tex/generic/pst-text/pst-text.tex v1.01, 2018/12/22(tvz,hv))) (/usr/local/texlive/2021/texmf-dist/tex/latex/pst-3d/pst-3d.sty (/usr/local/texlive/2021/texmf-dist/tex/generic/pst-3d/pst-3d.tex)) (/usr/local/texlive/2021/texmf-dist/tex/latex/pst-eps/pst-eps.sty (/usr/local/texlive/2021/texmf-dist/tex/generic/pst-eps/pst-eps.tex v1.00, 2006/11/04)) (/usr/local/texlive/2021/texmf-dist/tex/latex/pst-fill/pst-fill.sty (/usr/local/texlive/2021/texmf-dist/tex/generic/pst-fill/pst-fill.tex `PST-Fill' v1.01, 2007/03/10 (tvz,dg,hv))) (/usr/local/texlive/2021/texmf-dist/tex/latex/pstricks-add/pstricks-add.sty (/usr/local/texlive/2021/texmf-dist/tex/latex/pst-math/pst-math.sty (/usr/local/texlive/2021/texmf-dist/tex/latex/pst-calculate/pst-calculate.sty (/usr/local/texlive/2021/texmf-dist/tex/latex/l3packages/xparse/xparse.sty (/usr/local/texlive/2021/texmf-dist/tex/latex/l3kernel/expl3.sty (/usr/local/texlive/2021/texmf-dist/tex/latex/l3backend/l3backend-xetex.def (|extractbb --version))) (/usr/local/texlive/2021/texmf-dist/tex/latex/l3packages/xparse/xparse-2020-10-01.sty (/usr/local/texlive/2021/texmf-dist/tex/latex/l3packages/xparse/xparse-generic.tex))) (/usr/local/texlive/2021/texmf-dist/tex/latex/siunitx/siunitx.sty (/usr/local/texlive/2021/texmf-dist/tex/latex/tools/array.sty) (/usr/local/texlive/2021/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty) (/usr/local/texlive/2021/texmf-dist/tex/latex/translator/translator.sty))) (/usr/local/texlive/2021/texmf-dist/tex/generic/xstring/xstring.sty (/usr/local/texlive/2021/texmf-dist/tex/generic/xstring/xstring.tex)) (/usr/local/texlive/2021/texmf-dist/tex/generic/pst-math/pst-math.tex)) (/usr/local/texlive/2021/texmf-dist/tex/generic/pstricks-add/pstricks-add.tex)))
No file braid.aux.
(/usr/local/texlive/2021/texmf-dist/tex/latex/base/ts1cmr.fd) (/usr/local/texlive/2021/texmf-dist/tex/latex/siunitx/siunitx-abbreviations.cfg) (/usr/local/texlive/2021/texmf-dist/tex/latex/translator/translator-basic-dictionary-English.dict) [1] (./braid.aux)sh: /usr/local/texlive/2021/bin/universal-darwin/xdvipdfmx -i dvipdfmx-unsafe.cfg -q -E: No such file or directory
)
(see the transcript file for additional information)
Error 32512 (driver return code) generating output;
file braid.pdf may not be valid.
SyncTeX written on braid.synctex.gz.
Transcript written on braid.log.
答案1
不使用 brew 安装 macTeX 更有意义:
https://tug.org/mactex/
看起来你缺少 Ghostscript 或者没有使用正确的调用xelatex
xelatex -synctex=1 -interaction=nonstopmode --shell-escape -output-driver="xdvipdfmx -i dvipdfmx-unsafe.cfg -q -E" %.tex
lualatex
然而,如果您有最新的系统,您也可以使用。
答案2
将 pstricks 与 xelatex 和最新版本的 Ghostscript 一起使用需要在命令行上使用一组特殊的选项:
xelatex -output-driver="xdvipdfmx -i dvipdfmx-unsafe.cfg -q -E" -synctex=1 file.tex