Tell me more ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have recently started using LaTeX and have found it amazing. I now use LaTeX for all my documents :). However, now that I need to include some graphs and diagrams in my documents, I have found the Asymptote package, and seen that it is very powerful. I am having some issues using it though.

Firstly I would like to know the syntax for embedding asymptote code into LaTeX, and secondly if there is any convenient way to compile the whole document, in one command, I used to do my diagrams in mathematica, where I would import the picture and compile the whole document with a single pdflatex command.

share|improve this question
Welcome to TeX.sx! It's not necessary to sign your questions (as there is already a box with your username below it) or to begin them with a greeting. – doncherry Nov 28 '11 at 12:12

3 Answers

up vote 8 down vote accepted

For embedding Asymptote code in a LaTeX file, you can use the asymptote LaTeX package:

\usepackage[inline]{asymptote}

For document global Asymptote definitions use the asydef environment:

\begin{asydef}
...
\end{asydef}

For your Asymptote code use the asy environment, possibly within a figure environment with caption:

\begin{asy}
...
\end{asy}

Run (pdf)LaTeX, then Asymptote, then (pdf)LaTeX again, such as:

pdflatex filename
asy filename-1.asy
pdflatex filename

For a convenient way, you can use latexmk.

For more information, have a look at 7 LaTeX usage in the Asymptote documentation. There's a complete LaTeX example with several Asymptote graphs and a How-to for compiling and using latexmk.

share|improve this answer

You will find a guide to using Asymptote in LaTeX documents at Art of Problem Solving Wiki. They also have an Asymptote forum which allows you to render Asymptote code in the posts.

share|improve this answer

If you don't must use asymptote you can find many other solution to use graphics in LaTeX. Please check TikZ and PSTricks. I think you'll find many useful examples and packages.

share|improve this answer

Your Answer

 
discard

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.