24

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.

1
  • 1
    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, 2011 at 12:12

3 Answers 3

25

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.

3
  • could you please elaborate on how to configure latexmk for smooth compilation? It seems the links to latexmkrc are broken.
    – juliohm
    Oct 22, 2013 at 10:57
  • @juliohm Perhaps post it as a new question - I don't use latexmk myself.
    – Stefan Kottwitz
    Oct 22, 2013 at 12:05
  • My mistake, the file latexmkrc is still there in the repository under the doc/ directory. All the user has to do is copy it to the project directory.
    – juliohm
    Oct 22, 2013 at 22:04
5

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.

0

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.

Your Answer

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

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