[Tex/LaTex] Asymptote code integration into Beamer format

asymptotebeamer

I'm wondering anyone else has experienced compatibility issues between Asymptote and Beamer format, and what the fixes are. For example, I'm able to get a pdf output when I compile the following:

\documentclass{beamer}
\usepackage{amsmath,amssymb,amsthm,asymptote,graphicx}
\mode<presentation>

\begin{document}

\begin{frame}
\frametitle{Outline}
\begin{itemize}
\pause\item Something something something something.
\pause\item Something else something else.
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{Diagram}
%\begin{center}
%\begin{asy}
%import graph;
%size(150,150,Aspect);
%scale(true);
%draw((-2,-2)--(2,2),gray);
%dot("$(-2,-2)$",Scale((-2,-2)),S);
%dot("$(2,2)$",Scale((2,2)),N);
%\end{asy}
%\end{center}
\end{frame}

\end{document}

But not when I take out the comments on the Asymptote portion.

I found useful the "Beamer All The Way" presentation, where I noticed near the end of the presentation he included an Asymptote animation of a drawing of a polar graph. I also currently have my version of TeXnicCenter 2 Alpha set up the way described in the Advanced Configuration of the Art of Problem Solving Wiki.

I'd also like to point out that (I think…) the Asymptote compiler in LaTeX needs the \end{asy} argument to not be indented. The error I'm getting has to do with the "scanning error of \next", which is typically some violation of environment rules in compilation. Is it true that the Beamer installation "needs" the \end{frame} to not be indented, and this is where the error is occurring? Thanks ahead of time for your input.

Best Answer

you have to use

\begin{frame}[fragile]


for the asy source code and a pdflatex run with the option -shell-escape if you want to run asy from within the LaTeX source.