TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 3 down vote accepted

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]'");}

and run

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.