Asymptote:3D 图片破坏内联模式

Asymptote:3D 图片破坏内联模式

在 2D 图片中,内联模式效果很好;标签采用正确的字体排版。在 3D 图片中,我得到的标签采用 Computer Modern 字体。

这里有什么问题?

梅威瑟:

% LuaLaTeX
\documentclass[12pt]{article}

\usepackage[math-style=upright]{unicode-math}
\setmainfont{Tex Gyre Pagella}
\setmathfont{Tex Gyre Pagella Math}


\usepackage[inline]{asymptote}


\begin{document}

Labels in Computer Modern (bad):
\begin{asy}
import three;
import graph3;
currentprojection=orthographic(8,4,2,center=true);
size(10cm);
size3(3cm,5cm,8cm);
draw(unitbox,dashed);
dot(unitbox,red);
xaxis3(Label("$x$",1),xmax=1.25,Arrow3);
yaxis3(Label("$y$",1),ymax=1.25,Arrow3);
zaxis3(Label("$z$",1),zmax=1.25,Arrow3);
xaxis3(Label("$\hat x$",.5),xmax=.5,Arrow3);
yaxis3(Label("$\hat y$",.5),ymax=.5,Arrow3);
zaxis3(Label("$\hat z$",.5),zmax=.5,Arrow3);
label("$O$",(0,0,0),NW);
draw ((0,0,0) --(1,1,1),Arrow3);
draw(arc(c=O,0.5*X,X+Y+Z), L = Label("$a$", position=MidPoint,align=(0,1)));
draw(arc(c=O,0.5*Y,X+Y+Z), L = Label("$b$", position=MidPoint,align=(0,1)));
draw(arc(c=O,0.5*Z,X+Y+Z), L = Label("$c$", position=MidPoint,align=(0,1)));
\end{asy}
\vskip\baselineskip
Labels in Pagella (good):
\begin{asy}
settings.render = 4;
size(4cm,0);
pen colour1=red;
pen colour2=green;
pair z0=(0,0);
pair z1=(-1,0);
pair z2=(1,0);
real r=1.5;
path c1=circle(z1,r);
path c2=circle(z2,r);
fill(c1,colour1);
fill(c2,colour2);
picture intersection=new picture;
fill(intersection,c1,colour1+colour2);
clip(intersection,c2);
add(intersection);
draw(c1);
draw(c2);
draw("$A$",box,z1); // Requires [inline] package option.
draw("$B$",box,z2); // Requires [inline] package option.
pair z=(0,-2);
real m=3;
margin BigMargin=Margin(0,m*dot(unit(z1-z),unit(z0-z)));
draw(Label("$A\cap B$",0),conj(z)--z0,Arrow,BigMargin);
draw(Label("$A\cup B$",0),z--z0,Arrow,BigMargin);
draw(z--z1,Arrow,Margin(0,m));
draw(z--z2,Arrow,Margin(0,m));
shipout(bbox(0.25cm));
\end{asy}

\end{document}

在此处输入图片描述

答案1

您需要在 3D asy 代码的开头(或某一节内)告诉 Asymptote 您的非标准字体\begin{asydef}\end{asydef};否则它无法了解它们(2D 字体的排版通过内联选项委托给 TeX,但 TeX 对 3D 一无所知):

 texpreamble("\usepackage[math-style=upright]{unicode-math}");
 defaultpen(fontcommand("\setmainfont{Tex Gyre Pagella}"));
 defaultpen(fontcommand("\setmathfont{Tex Gyre Pagella Math}"));

相关内容