我在 .asy 文件中绘制了许多渐近线,生成的 pdf 包含在 中main.tex
。我有许多用户定义的命令,例如\vec
或,\vxi
我在当前的 main.tex 中使用它们,我也想在渐近线绘制中使用它们。例如,这条曲线使用它们
settings.outformat = "pdf";
size(6.5cm);
import graph;
// here I want to import my commands
defaultpen(font("T1", "fut\textfamilyextension","m","n"));
defaultpen(fontsize(10pt));
void pathlabel(picture pic = currentpicture, Label L, path g,
real position=0.5, align align=NoAlign, bool sloped=false,
pen p=currentpen, filltype filltype=NoFill) {
Label L2 = Label(L, align, p, filltype, position=Relative(position));
if (sloped) {
pair direction = dir(g, reltime(g, position));
real angle = degrees(atan2(direction.y, direction.x));
L2 = rotate(angle)*L2;
}
label(pic, L2, g);
}
pair F(real s) { return (s, 0.1 + s^4-3*s^3+2*s^2+s); }
path g = graph(F, 0.1, 1.9);
draw((-.1,0) -- (2.3,0), arrow=Arrow(TeXHead));
draw((0,-.1) -- (0,1.9), arrow=Arrow(TeXHead));
draw(g);
draw((0,0) -- (0.5,0.7875), arrow=ArcArrow(), lightgreen);
draw((0,0) -- (1.5,1.0375), arrow=ArcArrow(), lightgreen);
draw((0,0) -- (1.9,1.6751), arrow=ArcArrow(), lightgreen);
draw((0,0) -- (0.1,0.2171), arrow=ArcArrow(), lightgreen);
dot((0.1,0.2171), red);
dot((1.9,1.6751), red);
dot((0.5,0.7875), heavygreen);
dot((1.5,1.0375), heavygreen);
pathlabel("$\vxi^k(0,t) = \vec{x}_1^{(k)}(t)$", g, (0.01));
pathlabel("$\vxi^k(1,t)= \vec{x}_n^{(k)}(t)$", g, (1.9));
pathlabel("$\vxi^k(s,t)$", g, (0.6));
pathlabel("$\vec{x}_i^{(k)}(t)$", g, (0.28), deepgreen);
pathlabel("$\vec{x}_j^{(k)}(t)$", g, (0.74), deepgreen);
我已经将命令从 main.tex 分离到名为 command.tex 的文件中,因此例如main.tex
我使用它include{commands}
来加载它们。我应该怎么做才能将命令导入 .asy?
答案1
好吧,我来回答这个问题。在我的 asymptote 文件中,在最开始的几行,我按照建议添加了一个引言其中包括我的自定义命令,例如
settings.outformat = "pdf";
size(6.5cm);
import graph;
texpreamble("\include{commands}");
defaultpen(font("T1", "fut\textfamilyextension","m","n"));
defaultpen(fontsize(10pt));
// ... more lines