5 TeXstudio中无法使用asymptote来绘图 悬赏已过期

发布于 2025-11-17 23:38:59

我准备在TeXstudio中使用asymptote来绘图。但pdf中无生成的图片。
Latex代码如下:

\documentclass{article}
\usepackage[pdftex]{graphicx}
\usepackage{asymptote}
\begin{document}
    Hello.  
    I like to make pics with Asymptote like this one:
    \begin{figure}[h]
        \begin{asy}
        import graph;
        size(1inch);
        filldraw(circle((0,0),1),yellow,black);
        fill(circle((-.3,.4),.1),black);
        fill(circle((.3,.4),.1),black);
        draw(arc((0,0),.5,-140,-40));
        \end{asy}
    \end{figure}
    \par It makes me happy, 
    since I can still type my normal LaTeX stuff around it: 
    \(\int_0^{\pi}{\sin{x}}\,dx=2\)
\end{document}

如果编译成功,pdf应为这样:
1.png

但我用自己的TeXstudio编译,asymptote的图却无法显示.
2.png

在文件夹中生成了一个.Asy文件
3.png

打开这个.Asy的文档,里面内容如下:

if(!settings.multipleView) settings.batchView=false;
settings.tex="pdflatex";
defaultfilename="例1-1";
if(settings.render < 0) settings.render=4;
settings.outformat="";
settings.inlineimage=true;
settings.embed=true;
settings.toolbar=false;
viewportmargin=(2,2);

import graph;
size(1inch);
filldraw(circle((0,0),1),yellow,black);
fill(circle((-.3,.4),.1),black);
fill(circle((.3,.4),.1),black);
draw(arc((0,0),.5,-140,-40));

求助大佬,有什么建议和解决方法吗?非常感谢

查看更多

关注者
0
被浏览
366
3 个回答
LaTeXer
LaTeXer 2025-11-18
这家伙很懒,什么也没写!

你看看宏包说明自然懂了,asy 需要中间步骤处理 asy 代码的,类似 bibtex 需要执行这一步,基础设置里面 texstudio 的编译链,没有这个,你需要手工选择高级才能找到。

image.png

image.png

Absinthe
Absinthe 2025-11-18
这家伙很懒,什么也没写!
  • 不建议在 asymptote 代码前面使用缩进。
  • 如果你真期望在 texstudio 运行 asy 代码,请向像上一个回答一样配置好编译路径。值得注意的是,如果你使用的发行版是 miktex,我的建议是现在就卸了,它的asy版本太旧了,会和你安装的冲突,这里涉及到环境变量的问题。
  • 关于手册中 latexmk 的配置,注意这并不适用于 windows 平台,参考tse进行配置。
  • 此外如果想方便点编译,可以尝试给asy 添加一个快捷键,例如 ctrl+alt+A
  • 关于你的代码,graph 包并没有起到作用
Sagittarius Rover
Sagittarius Rover 2025-11-18
这家伙很懒,什么也没写!

关于「LaTeXer」提到的「宏包说明」:

参见: https://ask.latexstudio.net/ask/question/17794.html

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览