Integrating Asymptote and TeXShop for Mac OS X

Vishaal Rajani & Cole Zmurchok University of Alberta

June 19, 2011

1. Download Asymptote and place the asymptote-x.xx.src.tgz file on the desktop.

2. Open Terminal and type the following. Note that you will have to enter the root password for the final command.

cd Desktop
gunzip asymptote-x.xx.src.tgz
tar -xf asymptote-x.xx.src.tar
cd asymptote-x.xx
./configure
make all
sudo make install

If you get an error at the ./configure step, stating that you there is no acceptable C compiler found in $PATH, a solution is to download and install Xcode here:

http://developer.apple.com/TOOLS/Xcode/.

3. We now create the engine that will typeset Asymptote in TeXShop. The easiest way to create this engine, which we will call asyEngine.engine, is to navigate to ~/Library/TeXShop/Engines and duplicate one of the existing .engine files. Open the duplicate file and delete the code there. Type the following:

#!/bin/sh
location=$(dirname "$1")
basename="${1%.tex}"
#process
cd $location
pdflatex "$1"
asy "${basename}"-*.asy
pdflatex "$1"

Save this file as asyEngine.engine.

4. Now we set our engine to be executable. In the terminal, navigate to the Engines directory and type:

     chmod +x asyEngine.engine

5. Finally, in the terminal, type:

     defaults write TeXShop OtherTeXExtensions -array-add "asy"

This last command allows you choose the asyEngine option from the drop-down menu when you wish to typeset a document that includes asymptote.

Now, if you wish to typeset something simple, like the following red line, create a new document in TeXShop and type:

\documentclass[letterpaper,12pt]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{asymptote}
\begin{document}
\begin{asy}
   size(300);
   draw((0,0)--(1,1),red);
\end{asy}
\end{document}

Choose the asyEngine option from the drop-down menu and press Typeset. Your red line will be created in a PDF Document.

On a final note, it is best to avoid using filenames with spaces in them. For example, avoid filenames such as asy test.tex and instead use filenames without spaces, such as

asyTest.tex.