![更新](https://linux22.com/image/470716/%E6%9B%B4%E6%96%B0.png)
更新
根据 Stack Overflow 上一位用户的建议,https://stackoverflow.com/questions/77449192/issue-with-asymptote-execution-in-latex-failed-to-create-directory-asy,我升级了所有 MikTeX 软件包,并将所有与 LaTeX 相关的文件移至一个文件夹。即 %USERPROFILE% 目录,因为这是 Asymptote 的起始目录。asy 命令仍然无法用于这些文件。我甚至尝试在 %USERPROFILE% 目录中预先构建一个 .asy 文件夹并将 .asy 文件放在那里,但即使这样它仍然不起作用。可能是因为 Windows 不允许您以 (句号/点/“。”) 结尾文件夹。我还尝试运行asy -f pdf asymptote-latex.asy
当它位于 %USERPROFILE% 目录中时,会出现以下错误消息:
C:\Users\twill>asy C:\Users\twill\asymptote-latex-1.asy
failed to create directory /.asy.
Error: /undefined in .setfillconstantalpha
Operand stack:
1
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 2015 1 3 %oparray_pop 2014 1 3 %oparray_pop --nostringval-- 1998 1 3 %oparray_pop 1884 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval--
Dictionary stack:
--dict:980/1684(ro)(G)-- --dict:0/20(G)-- --dict:82/200(L)--
Current allocation mode is local
Current file position is 602
MiKTeX GPL Ghostscript 9.25: Unrecoverable error, exit code 1
_shipout(prefix,f,currentpatterns,format,wait,view,t);
^
C:\Users\twill\AppData\Local\Programs\MiKTeX/asymptote/plain_shipout.asy: 116.11: runtime: shipout failed
这是当它位于预建的 .asy 文件夹中时出现的错误消息:
C:\Users\twill>asy C:\Users\twill\.asy\asymptote-latex-1.asy
failed to create directory /.asy.
Error: /undefined in .setfillconstantalpha
Operand stack:
1
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 2015 1 3 %oparray_pop 2014 1 3 %oparray_pop --nostringval-- 1998 1 3 %oparray_pop 1884 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval--
Dictionary stack:
--dict:980/1684(ro)(G)-- --dict:0/20(G)-- --dict:82/200(L)--
Current allocation mode is local
Current file position is 602
MiKTeX GPL Ghostscript 9.25: Unrecoverable error, exit code 1
_shipout(prefix,f,currentpatterns,format,wait,view,t);
^
C:\Users\twill\AppData\Local\Programs\MiKTeX/asymptote/plain_shipout.asy: 116.11: runtime: shipout failed
主要内容
这个问题进一步探讨了我之前的一个调查中涉及的一个问题: 渐近线错误:编译期间缺少 PDF 文件
我在处理包含 Asymptote 代码的 LaTeX 文档时遇到了一个奇怪的问题。LaTeX 编译似乎生成了必要的.asy
文件,但当我尝试对这些文件单独执行 Asymptote 时,我遇到了困难。
以下是我的设置和采取的步骤:
- 我正在使用 Windows 操作系统。
- 我已经成功安装了 LaTeX、Asymptote 和 Ghostscript,并且已验证这三个都包含在我的系统 PATH 中。
- 编译我的 LaTeX 文档时,我使用 -shell-escape 选项。
当我观察到 PDF 文件的生成时,LaTeX 编译日志表明 Asymptote 代码正在正确执行(asymptote-latex-1.pdf)
。但是,当我尝试在生成的.asy
文件上手动运行 Asymptote 时,它不起作用。
我尝试使用以下命令来运行 Asymptote:
asy "C:\Users\twill\OneDrive\Desktop\ASYMPTOTE\output-directory\asymptote-latex-1.asy"
asy C:\Users\twill\asymptote-latex-*.asy
尽管如此,我还是遇到了问题,Asymptote 似乎无法正确处理文件。我遇到的具体错误消息是:failed to create directory /.asy.
。LaTeX 编译的日志没有提供任何与 Asymptote 相关的错误消息。
是否有人遇到过类似的问题,即 LaTeX 编译生成.asy
文件,但 Asymptote 对这些文件的执行失败?我将不胜感激任何见解、故障排除步骤或解决方案,以确保 Asymptote 代码.asy
正确处理文件。
谢谢您的帮助。
MWE:(来源:未找到“filename-1.pdf” Asymptote)
\documentclass{article}
\usepackage{graphicx}
\usepackage{asymptote}
\begin{document}
\begin{asy}
size(200);
pen[] p={red,green,blue,magenta};
path g=(0,0){dir(45)}..(1,0)..(1,1)..(0,1)..cycle;
tensorshade(g,p);
dot(g);
\end{asy}
\end{document}
日志:
This is pdfTeX, Version 3.141592653-2.6-1.40.25 (MiKTeX 23.5) (preloaded format=pdflatex 2023.8.22) 6 NOV 2023 10:25
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
**C:/Users/twill/OneDrive/Desktop/ASYMPTOTE/asymptote-latex.tex
(C:/Users/twill/OneDrive/Desktop/ASYMPTOTE/asymptote-latex.tex
LaTeX2e <2023-06-01> patch level 1
L3 programming layer <2023-08-11>
(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/latex/base\article.cls
Document Class: article 2023/05/17 v1.4n Standard LaTeX document class
(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/latex/base\size10.clo
File: size10.clo 2023/05/17 v1.4n Standard LaTeX file (size option)
)
\c@part=\count185
\c@section=\count186
\c@subsection=\count187
\c@subsubsection=\count188
\c@paragraph=\count189
\c@subparagraph=\count190
\c@figure=\count191
\c@table=\count192
\abovecaptionskip=\skip48
\belowcaptionskip=\skip49
\bibindent=\dimen140
)
(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/latex/graphics\graphicx.sty
Package: graphicx 2021/09/16 v1.2d Enhanced LaTeX Graphics (DPC,SPQR)
(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/latex/graphics\keyval.sty
Package: keyval 2022/05/29 v1.15 key=value parser (DPC)
\KV@toks@=\toks17
)
(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/latex/graphics\graphics.sty
Package: graphics 2022/03/10 v1.4e Standard LaTeX Graphics (DPC,SPQR)
(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/latex/graphics\trig.sty
Package: trig 2021/08/11 v1.11 sin cos tan (DPC)
)
(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/latex/graphics-cfg\graphics.c
fg
File: graphics.cfg 2016/06/04 v1.11 sample graphics configuration
)
Package graphics Info: Driver file: pdftex.def on input line 107.
(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/latex/graphics-def\pdftex.def
File: pdftex.def 2022/09/22 v1.2b Graphics/color driver for pdftex
))
\Gin@req@height=\dimen141
\Gin@req@width=\dimen142
)
(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/latex/asymptote\asymptote.sty
Package: asymptote 2021/12/29 v1.37 Asymptote style file for LaTeX
(asymptote-latex.pre)
\ASYbox=\box51
\ASYdimen=\dimen143
\c@asy=\count193
\AsyStream=\write3
\AsyPreStream=\write4
(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/latex/base\ifthen.sty
Package: ifthen 2022/04/13 v1.1d Standard LaTeX ifthen package (DPC)
)
(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/generic/iftex\ifpdf.sty
Package: ifpdf 2019/10/25 v3.4 ifpdf legacy package. Use iftex instead.
(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/generic/iftex\iftex.sty
Package: iftex 2022/02/03 v1.0f TeX engine tests
))
(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/generic/iftex\ifxetex.sty
Package: ifxetex 2019/10/25 v0.7 ifxetex legacy package. Use iftex instead.
)
(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/generic/catchfile\catchfile.s
ty
Package: catchfile 2019/12/09 v1.8 Catch the contents of a file (HO)
(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/generic/infwarerr\infwarerr.s
ty
Package: infwarerr 2019/12/03 v1.5 Providing info/warning/error messages (HO)
)
(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/generic/ltxcmds\ltxcmds.sty
Package: ltxcmds 2020-05-10 v1.25 LaTeX kernel commands for general use (HO)
)
(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/generic/etexcmds\etexcmds.sty
Package: etexcmds 2019/12/15 v1.7 Avoid name clashes with e-TeX commands (HO)
))
\openout4 = `asymptote-latex.pre'.
)
(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/latex/l3backend\l3backend-pdf
tex.def
File: l3backend-pdftex.def 2023-04-19 L3 backend support: PDF output (pdfTeX)
\l__color_backend_stack_int=\count194
\l__pdf_internal_box=\box52
) (asymptote-latex.aux)
\openout1 = `asymptote-latex.aux'.
LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 4.
LaTeX Font Info: ... okay on input line 4.
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 4.
LaTeX Font Info: ... okay on input line 4.
LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 4.
LaTeX Font Info: ... okay on input line 4.
LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 4.
LaTeX Font Info: ... okay on input line 4.
LaTeX Font Info: Checking defaults for TS1/cmr/m/n on input line 4.
LaTeX Font Info: ... okay on input line 4.
LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 4.
LaTeX Font Info: ... okay on input line 4.
LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 4.
LaTeX Font Info: ... okay on input line 4.
(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/context/base/mkii\supp-pdf.mk
ii
[Loading MPS to PDF converter (version 2006.09.02).]
\scratchcounter=\count195
\scratchdimen=\dimen144
\scratchbox=\box53
\nofMPsegments=\count196
\nofMParguments=\count197
\everyMPshowfont=\toks18
\MPscratchCnt=\count198
\MPscratchDim=\dimen145
\MPnumerator=\count199
\makeMPintoPDFobject=\count266
\everyMPtoPDFconversion=\toks19
)
(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/latex/epstopdf-pkg\epstopdf-b
ase.sty
Package: epstopdf-base 2020-01-24 v2.11 Base part for package epstopdf
Package epstopdf-base Info: Redefining graphics rule for `.eps' on input line 4
85.
(C:\Users\twill\AppData\Local\Programs\MiKTeX\tex/latex/00miktex\epstopdf-sys.c
fg
File: epstopdf-sys.cfg 2021/03/18 v2.0 Configuration of epstopdf for MiKTeX
))
\openout3 = `asymptote-latex-1.asy'.
<asymptote-latex-1.pdf, id=1, 200.75pt x 131.06967pt>
File: asymptote-latex-1.pdf Graphic file (type pdf)
<use asymptote-latex-1.pdf>
Package pdftex.def Info: asymptote-latex-1.pdf used on input line 11.
(pdftex.def) Requested size: 200.7495pt x 131.06934pt.
[1
{C:/Users/twill/AppData/Local/MiKTeX/fonts/map/pdftex/pdftex.map} <./asymptote-
latex-1.pdf>] (asymptote-latex.aux)
***********
LaTeX2e <2023-06-01> patch level 1
L3 programming layer <2023-08-11>
***********
)
Here is how much of TeX's memory you used:
1800 strings out of 475503
31543 string characters out of 5761834
1916248 words of memory out of 12000000
23078 multiletter control sequences out of 15000+600000
558069 words of font info for 36 fonts, out of 8000000 for 9000
1141 hyphenation exceptions out of 8191
62i,5n,65p,256b,139s stack positions out of 10000i,1000n,20000p,200000b,200000s
<C:/Users/twill/AppData/Local/Programs/MiKTeX/fonts/type1/public/amsfonts/cm/
cmr10.pfb>
Output written on asymptote-latex.pdf (1 page, 9798 bytes).
PDF statistics:
13 PDF objects out of 1000 (max. 8388607)
0 named destinations out of 1000 (max. 500000)
6 words of extra memory for PDF output out of 10000 (max. 10000000)
答案1
在我校一位教授的帮助下,这个问题已经解决了!
以下是我采取的步骤(供将来自己参考以及其他遇到同样问题的人参考)。
步骤 1:卸载 ghostscript 和 miktex
第 2 步:安装 miktex 和最新的 ghostscript。
步骤 3:全局搜索 mgs(在 MikTeX 目录中)并将其更改为其他内容(我使用了 mgstemp)
第四步:全局搜索gswin64.exe(在ghostscript目录下)并将其改名为mgs
步骤 5:每次更新 MikTeX 时,它都会创建一个新的 mgs 文件(在 MikTex 目录中!!!!!)。每次都需要将其更改为其他名称。
pdflatex test
第 6 步:然后命令asy test-1.asy
将pdflatex test
生成您的文档!