Difference between revisions of "Asymptote: Macintosh"

(Usage)
(Usage)
Line 26: Line 26:
 
Here is a sample file:
 
Here is a sample file:
  
<code>\documentclass[letterpaper,12pt]{article}
+
<code>
\usepackage{amsmath}
+
\documentclass[letterpaper,12pt]{article}
\usepackage{amssymb}
+
\usepackage{amsmath}
\usepackage{asymptote}
+
\usepackage{amssymb}
 
+
\usepackage{asymptote}
\begin{document}
+
\begin{asy}
+
\begin{document}
    size(300);
+
\begin{asy}
    draw((0,0)--(1,1),blue);
+
    size(300);
\end{asy}
+
    draw((0,0)--(1,1),blue);
\end{document}</code>
+
\end{asy}
 +
\end{document}</code>
  
 
Use whatever LaTeX editor to compile the file. It'll return an error that looks something like this:
 
Use whatever LaTeX editor to compile the file. It'll return an error that looks something like this:
  
<code>Package asymptote Warning: file asyfile_1.pdf does not exist on input line 17.</code>
+
<code>
 +
Package asymptote Warning: file asyfile_1.pdf does not exist on input line 17.
 +
</code>
  
Terminal again. Run: ''cd ~/Desktop''
+
Terminal again.
  
then ''asy asyfile''
+
<code>
 +
cd ~/Desktop
 +
asy asyfile
 +
</code>
  
 
That will run asymptote on the file '''asyfile.asy,''' (created when the tex file was compiled) producing '''asyfile_1.pdf.'''
 
That will run asymptote on the file '''asyfile.asy,''' (created when the tex file was compiled) producing '''asyfile_1.pdf.'''

Revision as of 00:15, 25 September 2008

Installing Asymptote on a Mac

This tutorial was tested on Mac OS 10.5 "Leopard," but should work for most older systems.


Download the Asymptote source here (at the time of writing, it is version 1.43).

Follow directions in the INSTALL file. The process is summarized here. "x.xx" represents the Asymptote version number (e.g., 1.43), and terminal commands are italicized.

  1. Open Terminal (located in /Applications/Utilities/Terminal.app)
  2. Run: cd ~/Desktop
  3. gunzip asymptote-x.xx.src.tgz
  4. tar -xf asymptote-x.xx.src.tar
  5. cd asymptote-x.xx
  6. wget http://www.hpl.hp.com/personal/Hans_Boehm/gc/gc_source/gc-7.1.tar.gz or manually download and put this file in the current directory (don't extract it!). (wget is a commandline file downloader that is not installed in Mac OS by default. You can download and install it here if you prefer the utility.)
  7. ./configure
  8. make all
  9. sudo make install

You have finished installing Asymptote.

Usage

Suppose that on the Desktop, you have a file named asyfile.tex

Here is a sample file:

\documentclass[letterpaper,12pt]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{asymptote}

\begin{document}
\begin{asy}
    size(300);
    draw((0,0)--(1,1),blue);
\end{asy}
\end{document}

Use whatever LaTeX editor to compile the file. It'll return an error that looks something like this:

Package asymptote Warning: file asyfile_1.pdf does not exist on input line 17.

Terminal again.

cd ~/Desktop
asy asyfile

That will run asymptote on the file asyfile.asy, (created when the tex file was compiled) producing asyfile_1.pdf.

Now run latex on asyfile.tex again, and with any luck, it should compile with no errors. (The image produces a diagonal blue line.)


Automation

This post describes a shell script that automates the compilation process.

Troubleshooting