Forgot password?
 Create new account
View 150|Reply 8

用了asymptote,编译不通过,提示命令已经定义

[Copy link]

418

Threads

1628

Posts

110K

Credits

Credits
11891

Show all posts

abababa Posted at 2025-3-18 15:32:07 |Read mode
  1. \documentclass[a4paper]{book}
  2. % 使用到的包
  3. \usepackage{amsmath,bm,yhmath,amssymb,etoolbox,esvect,stmaryrd,cite,enumitem,extarrows,mathtools,ifthen}
  4. % 颜色
  5. \usepackage[dvipsnames, svgnames]{xcolor}
  6. %使用索引
  7. \usepackage{makeidx}
  8. % 图片支持
  9. \usepackage[inline]{asymptote}
  10. \usepackage{tikz}
  11. \usepackage{tkz-euclide}
  12. %定理环境
  13. \usepackage[amsmath, thmmarks]{ntheorem}
  14. {
  15.         \theoremstyle{nonumberplain}
  16.         \theoremheaderfont{\indent\bfseries}
  17.         \theorembodyfont{\normalfont}
  18.         \theoremsymbol{\ensuremath{\Box}}
  19.         \newtheorem{proof}{证明}
  20.         \newtheorem{practice}{作法}
  21. }
  22. \theoremheaderfont{\indent\bfseries}
  23. \theorembodyfont{\normalfont}
  24. %环境结束符号
  25. \theoremsymbol{\ensuremath{\multimap}}
  26. \newcommand\itemautorefname{条目}
  27. \newtheorem{example}{例}[section]
  28. \newcommand\exampleautorefname{例}
  29. \usepackage[slantfont,boldfont]{xeCJK}
  30. \begin{asydef}
  31. settings.prc = true;
  32. settings.embed = true;
  33. import three;
  34. import math;
  35. import geometry;
  36. import graph3;
  37. import texcolors;
  38. \end{asydef}
  39. \begin{document}
  40. 测试一下
  41. \begin{center}
  42. \begin{asy}
  43. size(100);
  44. currentprojection = orthographic(0.6,-1,0.8);
  45. real b = 2,h = 6;
  46. triple f(pair t) {
  47.         real u = t.x;
  48.         real v = t.y;
  49.         real r = 2-cos(u);
  50.         real x = b*cos(u)*(1-sin(u))+r*cos(v)*(2*exp(-((u/2-pi)^2))-1);
  51.         real y = r*sin(v);
  52.         real z = h*sin(u)+0.5*r*sin(u)*cos(v)*exp(-((u-3*pi/2)^2));
  53.         return (x,y,z);
  54. }
  55. surface s=surface(f,(0,0),(2pi,2pi),15,15,Spline);
  56. draw(s,lightyellow, meshpen=black+thick());
  57. \end{asy}
  58. \end{center}
  59. \end{document}
Copy the Code


完整代码(my.tex)如上,编译方法:1. xelatex my,2. asy -mask *.asy,3. xelatex my
在运行第3步时,就提示了Command \itemautorefname already defined.
但如果不运行第2步,只是连续两次xelatex my,这样就没问题。

这个要怎么解决?

418

Threads

1628

Posts

110K

Credits

Credits
11891

Show all posts

 Author| abababa Posted at 2025-3-18 16:46:25
hbghlyj 发表于 2025-3-18 15:46
更改行 \newcommand\itemautorefname{条目}  至 \renewcommand\itemautorefname{条目} 怎么样? ...
以前就这样弄过,但第一次编译时没有这个命题,不能renew,最后找到\providecommand这种,没定义时new,定义过了renew,但这样做之后,其它地方有时也有问题。觉得还是找出原因,按正常的方式解决才行。

418

Threads

1628

Posts

110K

Credits

Credits
11891

Show all posts

 Author| abababa Posted at 2025-3-19 08:59:18
发现第一次运行xelatex my和asy -mask *.asy之后,生成了一堆以my-1开头的文件,其中有一个名为my-1.pre,前两行是:
  1. \usepackage{hyperref}
  2. \hypersetup{setpagesize=false,unicode,pdfborder=0 0 0}
Copy the Code

如果我删除这两行,保存,然后再运行xelatex my,就能正确生成pdf文档了,也没报错。这两行是做什么用的呢?为什么asy之后就必须要有这两行呢?

418

Threads

1628

Posts

110K

Credits

Credits
11891

Show all posts

 Author| abababa Posted at 2025-3-19 09:33:53
hbghlyj 发表于 2025-3-19 09:02
设置导言的 Asymptote 代码
import settings;
preamble="
这个可能是旧版本的,查到一个2008年的帖子:
sourceforge.net/p/asymptote/discussion/409349/thread/606ea822/
新的可能是下面这样的:
settings.prc = false;
虽然不知道是什么意思,但是改成false之后,确实能编译了。

3146

Threads

8493

Posts

610K

Credits

Credits
66158
QQ

Show all posts

hbghlyj Posted at 2025-3-19 09:43:42

418

Threads

1628

Posts

110K

Credits

Credits
11891

Show all posts

 Author| abababa Posted at 2025-3-19 09:49:06
hbghlyj 发表于 2025-3-19 09:43
settings.prc:这是 Asymptote 中的配置设置,用于控制是否将 PRC(嵌入在 PDF 文件中的 3D 格式)用于 3D ...
不明白有什么区别,settings.prc=false时,就是不生成3楼那两行了,其它的没看出有什么不同。

3146

Threads

8493

Posts

610K

Credits

Credits
66158
QQ

Show all posts

hbghlyj Posted at 2025-3-19 09:50:04
abababa 发表于 2025-3-19 01:49
不明白有什么区别,settings.prc=false时,就是不生成3楼那两行了,其它的没看出有什么不同。 ...
PRC 提供 3D 渲染,但它需要兼容的 PDF 查看器。用 Adob​​e Acrobat 打开应该会有不同吧。

3146

Threads

8493

Posts

610K

Credits

Credits
66158
QQ

Show all posts

hbghlyj Posted at 2025-3-19 09:53:11
abababa 发表于 2025-3-19 01:49
不明白有什么区别,settings.prc=false时,就是不生成3楼那两行了,其它的没看出有什么不同。 ...
configuration-file 看到
-prc                   Embed 3D PRC graphics in PDF output [false]
默认为 false

3146

Threads

8493

Posts

610K

Credits

Credits
66158
QQ

Show all posts

hbghlyj Posted at 2025-3-20 04:06:43
abababa 发表于 2025-3-19 01:33
虽然不知道是什么意思,但是改成false之后,确实能编译了。
默认是 false,所以去除这句也能编译吧

手机版Mobile version|Leisure Math Forum

2025-4-20 22:09 GMT+8

Powered by Discuz!

× Quick Reply To Top Return to the list