I wonder if someone can explain what follows to me and how to remedy it. The following piece of Asymptote code:

import graph;
import graph3;


real f(pair z) {return z.x^2-z.y^2;}
triple c(real t) {return (cos(t),sin(t),f((cos(t),sin(t))));}
triple n(real t) {triple w=cross((1,0,2*cos(t)),(0,1,-2*sin(t))); return unit(w);}

picture pic;


draw(pic,graph(c,0,2*pi,operator ..),red+2);

picture pic2;


draw(pic2,graph(n,0,2*pi,operator ..),red+2);

int antal=10;
for(int i=0;i < antal;++i){
real t=2*pi*i/antal;




works fine when I run it through Asymptote. It gives me two pictures, call them A and B, side by side.

If I now include the code in an asy-environment in my LaTeX-document a peculiar thing happens: I get two copies of B side by side. If I change the order of the add-commands at the end I get two copies of A instead.

Why do I not get A and B, as when I run it alone?

The code above is inserted into a LaTeX-file that looks like

\title{A test example}
Some introductory text.  
More text  
  • 1
    It might be helpful to see a complete (non)-working .tex file. For instance, do you use the inline option when including the asymptote package? – Charles Staats May 19 '15 at 15:37
  • \documentclass[12pt,a4paper]{article} \usepackage[inline]{asymptote} \title{A test example} \author{Me} \date{\today} \begin{document} \maketitle \section{Introduction} Some introductory text. \begin{center} \begin{asy}[inline=true] – Anders Källén May 20 '15 at 9:40
  • sorry CODE\end{asy} \end{center} More text \end{document} – Anders Källén May 20 '15 at 9:42
  • You should be able to edit the question itself. – Charles Staats May 20 '15 at 16:17
  • If you remove the two instances of inline, it will solve this problem. (Of course, there may be other reasons you want to use inline, which is why I'm making this a comment rather than an answer.) – Charles Staats May 21 '15 at 15:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.