TransWikia.com

Asymptote: 3D pictures clobber inline mode

TeX - LaTeX Asked by Weißer Kater on November 7, 2020

In 2D pictures the inline mode works well; the labels are typeset with the right font. In 3D pictures
I get labels in Computer Modern.

What is wrong here?

MWE:

% 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}
vskipbaselineskip
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("$Acap B$",0),conj(z)--z0,Arrow,BigMargin);
draw(Label("$Acup 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}

enter image description here

One Answer

You need to tell Asymptote about your non-standard fonts at the beginning of your 3D asy code (or within a begin{asydef}end{asydef} section); otherwise it has no way of knowing about them (the typesetting of the 2D fonts is delegated to TeX via the inline option, but TeX knows nothing about 3D):

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

Correct answer by John Bowman on November 7, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP