LaTeX 中的 Asymptote 执行出现问题:“无法创建目录 /.asy。”

问题描述 投票:0回答:1

注意:我最初在 TeX Stack Exchange 上问过这个问题,但不幸的是,我没有收到回复。我将其重新发布到此处以获得更广泛社区的帮助。

这是原始帖子的链接:https://tex.stackexchange.com/questions/700578/asymptote-code-generates-asy-files-but-asymptote-execution-fails

这个问题进一步探讨了我之前在 TeX.SE 上的一项查询中解决过的问题: https://tex.stackexchange.com/questions/700514/asymptote-error-missing-pdf-file-during-compilation

在使用包含 Asymptote 代码的 LaTeX 文档时,我遇到了一个特殊问题。 LaTeX 编译似乎生成了必要的

.asy
文件,但是当我尝试对这些文件单独执行 Asymptote 时,我遇到了困难。

这是我所采取的设置和步骤:

  • 我使用的是 Windows 操作系统。
  • 我已成功安装 LaTeX、Asymptote 和 Ghostscript,并已验证所有这三个都包含在我的系统的 PATH 中。
  • 我在编译 LaTeX 文档时使用 -shell-escape 选项。

LaTeX 编译日志表明 Asymptote 代码正在正确执行,因为我观察到 PDF 文件的生成

(asymptote-latex-1.pdf)
。但是,当我尝试在生成的
.asy
文件上手动运行 Asymptote 时,它不起作用。

我尝试使用以下命令来运行 Asymptote:

  1. asy "C:\Users\twill\OneDrive\Desktop\ASYMPTOTE\output-directory\asymptote-latex-1.asy"
  2. asy C:\Users\twill\asymptote-latex-*.asy

尽管如此,我还是遇到了问题,Asymptote 似乎无法正确处理文件。我面临的具体错误消息是:

failed to create directory /.asy.
。 LaTeX 编译的日志没有提供任何与 Asymptote 相关的错误消息。

有没有人遇到过类似的问题,LaTeX 编译生成

.asy
文件,但对这些文件执行 Asymptote 失败?我将非常感谢任何见解、故障排除步骤或解决方案,以确保 Asymptote 代码正确处理
.asy
文件。

感谢您的协助。

MWE:(来源:https://tex.stackexchange.com/questions/537967/filename-1-pdf-not-found-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)
latex pdflatex miktex asymptote
1个回答
0
投票

在我大学教授的帮助下,问题已经解决了!

以下是我采取的步骤(供将来自我参考以及其他遇到同样问题的人)。

第1步:卸载ghostscript和miktex

第2步:安装miktex和最新的ghostscript。

第3步:全局搜索mgs并将其更改为其他内容(我使用mgstemp)

第四步:全局搜索gswin64.exe并将其名称更改为mgs

第5步:任何时候你更新MikTeX,它都会创建一个新的mgs文件(在MikTex目录!!!!!!)。您每次都需要将其更改为其他名称。

第 6 步:命令

pdflatex test
然后
asy test-1.asy
然后
pdflatex test
将生成您的文档!

© www.soinside.com 2019 - 2024. All rights reserved.