# Asymptote only generates full-page PDF output

I have a LaTeX document in which I include several asymptote images, and I can't seem to get the generated PDF to be cropped. Asymptote always generates a full-page PDF...

Here's an example:

\documentclass{article}

\usepackage[inline,attach]{asymptote}
\usepackage[dvips]{attachfile2}

\begin{asydef}
settings.embed=true;
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}
First sentence
\begin{center}
\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);
currentprojection=orthographic(camera=(0,7,7),up=Z,target=O,zoom=1);
\end{asy}
\end{center}
Second sentence

\end{document}

In the output pdf, "First sentence" and "Second sentence" show up in separate pages, because asymptote creates a full-page PDF with a small image at the upper-left part of the page.

How can I get the image to be generated in a format that can be properly included in the LaTeX document?

• Potentially relevant data: 1. Contents of your ~/.asy/config.asy? 2. Does your Asymptote executable have support for OpenGL? 3. Does passing -glOptions=-indirect to the asy command help? 4. Does omitting settings.render=1; help? – ccorn Aug 1 '16 at 20:17
• There seems to be a problem with the latest version of say where some figures aren't properly cropped. It has been reported. – Herb Schulz Aug 1 '16 at 23:45
• This is a bug (although supposedly not in Asymptote itself). Based on this discussion on the Asymptote forum, adding the line settings.tex = "latex"; might be a workaround, although that's unlikely to work with the inline option when loading the package. – Charles Staats Aug 2 '16 at 15:38