I would like to make 3d pictures and put them side-by-side. I can do that nicely creating a file example.asy
:
settings.render=1;
import graph;
import graph3;
import contour3;
material reds = material(diffusepen=0.7red,ambientpen=red,emissivepen=0.3*red,specularpen=0.95white,shininess=0.95);
material blues = material(diffusepen=0.7blue,ambientpen=blue,emissivepen=0.3*blue,specularpen=0.95white,shininess=0.95);
int numberlines=8;
defaultrender.merge=true;
defaultrender.tessellate=true;
defaultrender.compression=Low;
picture p1,p2;
size(p1,100);
size(p2,100);
real f(real x, real y, real z) {return y^2+x-2;}
real c(real x, real y, real z) {return 2*x+2*z -2;}
draw(p1,surface(contour3(f,(-3,-3,-3),(3,3,3),numberlines)),reds);
draw(p1,surface(contour3(c,(-3,-3,-3),(3,3,3),numberlines)),blues);
draw(p2,surface(contour3(f,(-3,-3,-3),(3,3,3),numberlines)),reds);
draw(p2,surface(contour3(c,(-3,-3,-3),(3,3,3),numberlines)),blues);
currentprojection=orthographic(camera=(9,10,4),up=Z,target=O,zoom=1);
add(p2.fit(currentprojection),(0,0),W);
currentprojection=orthographic(camera=(0,7,7),up=Z,target=O,zoom=1);
add(p1.fit(currentprojection),(0,0),30E);
The result is the same 3d image from two different points of view:
However, if I try to reproduce that in a LaTeX document, I get two repeated copies of the second image (in this case the projection with camera at (0,7,7)):
This is the LaTeX code I'm using:
\documentclass{article}
\usepackage[inline]{asymptote}
\begin{asydef}
settings.outformat="png";
settings.render=1;
import graph;
import graph3;
import contour3;
material reds = material(diffusepen=0.7red,ambientpen=red,emissivepen=0.3*red,specularpen=0.95white,shininess=0.95);
material blues = material(diffusepen=0.7blue,ambientpen=blue,emissivepen=0.3*blue,specularpen=0.95white,shininess=0.95);
int numberlines=8;
defaultrender.merge=true;
defaultrender.tessellate=true;
defaultrender.compression=Low;
\end{asydef}
\begin{document}
\begin{asy}
picture p1,p2;
size(p1,100);
size(p2,100);
real f(real x, real y, real z) {return y^2+x-2;}
real c(real x, real y, real z) {return 2*x+2*z -2;}
draw(p1,surface(contour3(f,(-3,-3,-3),(3,3,3),numberlines)),reds);
draw(p1,surface(contour3(c,(-3,-3,-3),(3,3,3),numberlines)),blues);
draw(p2,surface(contour3(f,(-3,-3,-3),(3,3,3),numberlines)),reds);
draw(p2,surface(contour3(c,(-3,-3,-3),(3,3,3),numberlines)),blues);
currentprojection=orthographic(camera=(9,10,4),up=Z,target=O,zoom=1);
add(p2.fit(currentprojection),(0,0),W);
currentprojection=orthographic(camera=(0,7,7),up=Z,target=O,zoom=1);
add(p1.fit(currentprojection),(0,0),30E);
\end{asy}
\end{document}
This is with asymptote 2.15.2.
How can I get, from LaTeX, the same output I got by running asy -V
from the command line?
settings.outformat="pdf"
from yourasydef
environment? That's the only difference I see, and usually theasy
file actually output by theasymptote
package will automatically include an appropriatesettings.outformat=
statement. (Actually, it's not the only difference--you might also try omitting theinline
option when you call the package.)settings.outformat
makes no difference, but remving theinline
option fixes the problem. I suppose, then, that this is a bug in asymptote (or more precisely, in its interface with LaTeX), right?filename-number.asy
file that is actually produced after running LaTeX with theinline
option.\usepackage[inline,attach]{asymptote}
with\usepackage[dvips]{attachfile2}
, andsettings.embed=true
in myasydef
, it works!