Difference between revisions of "Asymptote: Macintosh"

(Usage)
(Installing Asymptote on a Mac/Linux)
(8 intermediate revisions by 5 users not shown)
Line 1: Line 1:
== Installing Asymptote on a Mac ==
+
{| class="wikitable" style="border:1px solid black; background:#CEE0F2;text-align:center;"
 +
|-
 +
|style="background:#B0C4DE;"|'''[[Asymptote (Vector Graphics Language)]]'''
 +
|-
 +
|[[Asymptote: Getting Started|Getting Started]] - [[Asymptote: Basics|Basics]] - [[Asymptote: Reference|Reference]] - [[Asymptote: Useful commands and their Output|Examples]] - [[Asymptote: Macros and Packages|Macros and Packages]] - [[Asymptote: Advanced | Advanced Asymptote]] - [[Asymptote: Help|Help]]
 +
[[Asymptote: Useful functions|Useful functions]] - [[Asymptote: CSE5|CSE5 Package]]
 +
[[Category:Asymptote]]
 +
|}<noinclude>
  
'''This tutorial was tested on Mac OS 10.5 "Leopard," but should work for most older systems.'''
+
== Installing Asymptote on a Mac/Linux ==
  
 +
'''This tutorial was tested on Mac OS 10.15.7 "Catalina," but should work for most older systems as well as other Unix systems'''
  
Download the Asymptote source [http://sourceforge.net/project/showfiles.php?group_id=120000 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.
+
Download the Asymptote source [http://sourceforge.net/project/showfiles.php?group_id=120000 here] (at the time of this edit, it is version 2.68) by selecting the latest version and downloading the asymptote-x.xx.src.tgz file.<br />
 +
Download and install [https://www.tug.org/mactex/ MacTeX].<br />
 +
Note that anywhere you see "x.xx", replace it with the Asymptote version number (e.g. If the file name was asymptote-2.68.src.tgz, you would replace x.xx with 2.68).
 +
 
 +
There are two ways to actually install Asymptote: using the AsyIntaller written by PrintrBot, or installing it manually.
 +
 
 +
===Installing via the AsyInstaller===
 +
#Download the code from GitHub [https://github.com/Rotorwing/AsyInstaller here]
 +
#Unzip the folder if it was not automatically.
 +
#Double click the asyinstaller file and follow the instructions in the installer.
 +
If all went well, Asymptote should be installed.
 +
<br />
 +
===Installing Manually===
 +
Terminal commands are italicized.
  
 
# Open Terminal (located in /Applications/Utilities/Terminal.app)
 
# Open Terminal (located in /Applications/Utilities/Terminal.app)
# Run: ''cd ~/Desktop''
+
# Run: ''cd ~/Downloads # or wherever you put the asymptote-x.xx.src.tgz file''
# ''gunzip asymptote-x.xx.src.tgz''
+
# ''tar -xvzf asymptote-x.xx.src.tgz''
# ''tar -xf asymptote-x.xx.src.tar''
 
 
# ''cd asymptote-x.xx''
 
# ''cd asymptote-x.xx''
# ''wget <nowiki>http://www.hpl.hp.com/personal/Hans_Boehm/gc/gc_source/gc-7.1.tar.gz</nowiki>'' or manually download and put [http://www.hpl.hp.com/personal/Hans_Boehm/gc/gc_source/gc-7.1.tar.gz 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 [http://wget.darwinports.com/download/ here] if you prefer the utility.)
 
 
# ''./configure''
 
# ''./configure''
 
# ''make all''
 
# ''make all''
 
# ''sudo make install''
 
# ''sudo make install''
 
+
If you get an error at the./configure step, stating that there is no acceptable C compiler found in $PATH, a solution is to download and install Xcode (you can get it on the app store.) or Xcode tools<br /><br />
 
You have finished installing Asymptote.
 
You have finished installing Asymptote.
  
Line 26: Line 44:
 
Here is a sample file:
 
Here is a sample file:
  
<code>
 
 
  \documentclass[letterpaper,12pt]{article}
 
  \documentclass[letterpaper,12pt]{article}
 
  \usepackage{amsmath}
 
  \usepackage{amsmath}
Line 37: Line 54:
 
     draw((0,0)--(1,1),blue);
 
     draw((0,0)--(1,1),blue);
 
  \end{asy}
 
  \end{asy}
  \end{document}</code>
+
  \end{document}
  
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 will return a warning that looks something like this:
  
<code>
 
 
  Package asymptote Warning: file asyfile_1.pdf does not exist on input line 17.
 
  Package asymptote Warning: file asyfile_1.pdf does not exist on input line 17.
</code>
 
  
 
Terminal again.
 
Terminal again.
  
<code>
 
 
  cd ~/Desktop
 
  cd ~/Desktop
 
  asy asyfile
 
  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.'''
Line 60: Line 73:
  
 
[http://www.artofproblemsolving.com/Forum/viewtopic.php?p=1241236#1241236 This post] describes a shell script that automates the compilation process.
 
[http://www.artofproblemsolving.com/Forum/viewtopic.php?p=1241236#1241236 This post] describes a shell script that automates the compilation process.
 
== Troubleshooting ==
 

Revision as of 16:31, 24 November 2020

Asymptote (Vector Graphics Language)
Getting Started - Basics - Reference - Examples - Macros and Packages - Advanced Asymptote - Help

Useful functions - CSE5 Package

Installing Asymptote on a Mac/Linux

This tutorial was tested on Mac OS 10.15.7 "Catalina," but should work for most older systems as well as other Unix systems


Download the Asymptote source here (at the time of this edit, it is version 2.68) by selecting the latest version and downloading the asymptote-x.xx.src.tgz file.
Download and install MacTeX.
Note that anywhere you see "x.xx", replace it with the Asymptote version number (e.g. If the file name was asymptote-2.68.src.tgz, you would replace x.xx with 2.68).

There are two ways to actually install Asymptote: using the AsyIntaller written by PrintrBot, or installing it manually.

Installing via the AsyInstaller

  1. Download the code from GitHub here
  2. Unzip the folder if it was not automatically.
  3. Double click the asyinstaller file and follow the instructions in the installer.

If all went well, Asymptote should be installed.

Installing Manually

Terminal commands are italicized.

  1. Open Terminal (located in /Applications/Utilities/Terminal.app)
  2. Run: cd ~/Downloads # or wherever you put the asymptote-x.xx.src.tgz file
  3. tar -xvzf asymptote-x.xx.src.tgz
  4. cd asymptote-x.xx
  5. ./configure
  6. make all
  7. sudo make install

If you get an error at the./configure step, stating that there is no acceptable C compiler found in $PATH, a solution is to download and install Xcode (you can get it on the app store.) or Xcode tools

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 will return a warning 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.