# No support for Asymptote in AUCTeX

I got a problem with my Emacs/AUCTeX setup. I'm using a lot of Asymptote graphics in my TeX documents, but there is a big problem to compile such documents inside of Emacs with AUCTeX. However I can compile those document from within Kile.

For Emacs/AUCTeX this workaround works:

1. call from Emacs pdflatex(compile latex)
2. manually from the shell: `asy filename-1.asy`
3. call from Emacs pdflatex(compile latex)

How can I tell AUCTeX to call the `asy` compiler automatically if needed?

-

You can call `latexmk` via AUCTeX which with some minor configuration can compile LaTeX with Asymptote figures.

According to the Asymptote manual you can use `latexmk` to compile LaTeX files containing Asymptote figures with a single command (§7):

An even better method for processing a `LaTeX` file with embedded `Asymptote` code is to use the `latexmk` utility from http://www.ctan.org/tex-archive/support/latexmk/ after putting the contents of http://asymptote.svn.sourceforge.net/viewvc/asymptote/trunk/asymptote/doc/latexmkrc in a file `latexmkrc` in the same directory. The command

``````latexmk -pdf latexusage
``````

will then call `Asymptote` automatically, recompiling only the figures that have changed. Since each figure is compiled in a separate system process, this method also tends to use less memory.

What this means is that if you add the following to your latexmkrc

``````\$pdf_mode = 1;
sub asy {return system("asy '\$_[0]'");}
``````latexmk your_document
it will do all the necessary steps to produce a PDF of your LaTeX document with Asymptote figures. Such a command can be invoked via AUCTeX to do what you want, i.e. `latexmk` can be called from AUCTeX.