Difference between revisions of "Asymptote: Macintosh"
Undefined117 (talk | contribs) (→Installing Asymptote on a Mac) |
(fix endline) |
||
(16 intermediate revisions by 8 users not shown) | |||
Line 1: | Line 1: | ||
− | == | + | {| 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> | ||
− | + | == Installing Asymptote on a Mac/Linux == | |
+ | '''The first two installations were tested on Mac OS 10.15.7 "Catalina," but should work for most older systems as well as other Unix systems. The third was tested on Mac OS 11.3 "Big Sur"''' | ||
− | Download the Asymptote source [http://sourceforge.net/project/showfiles.php?group_id=120000 here] (at the time of | + | Download the Asymptote source [http://sourceforge.net/project/showfiles.php?group_id=120000 here] (at the time of this edit, it is version 2.86) 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.86.src.tgz, you would replace x.xx with 2.86). | ||
− | + | There are three ways to actually install Asymptote: using the AsyIntaller written by PrintrBot, installing it manually via terminal, or using Homebrew. | |
+ | |||
+ | ===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 ~/ | + | # Run: ''cd ~/Downloads'' (or wherever you put the asymptote-x.xx.src.tgz file) |
# ''tar -xvzf asymptote-x.xx.src.tgz'' | # ''tar -xvzf asymptote-x.xx.src.tgz'' | ||
# ''cd asymptote-x.xx'' | # ''cd asymptote-x.xx'' | ||
− | |||
# ''./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 the Xcode Command Line tools<br /><br /> | ||
+ | You have finished installing Asymptote. | ||
+ | |||
+ | ===Installing via Homebrew=== | ||
− | + | 1. To download homebrew, run | |
+ | cd <nowiki>/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"</nowiki> | ||
+ | in the terminal window. | ||
+ | |||
+ | 2. Run | ||
+ | brew install --cask mactex | ||
+ | |||
+ | 3. Then run | ||
+ | brew install asymptote | ||
+ | both in the terminal window. | ||
== Usage == | == Usage == | ||
Line 25: | Line 56: | ||
Here is a sample file: | Here is a sample file: | ||
− | |||
\documentclass[letterpaper,12pt]{article} | \documentclass[letterpaper,12pt]{article} | ||
\usepackage{amsmath} | \usepackage{amsmath} | ||
Line 36: | Line 66: | ||
draw((0,0)--(1,1),blue); | draw((0,0)--(1,1),blue); | ||
\end{asy} | \end{asy} | ||
− | \end{document} | + | \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. | Package asymptote Warning: file asyfile_1.pdf does not exist on input line 17. | ||
− | |||
− | + | To compile this into PDF form, in the terminal, run: | |
− | + | cd | |
− | + | cd ~/Desktop | |
+ | pdflatex asyfile | ||
+ | asy asyfile-*.asy | ||
+ | pdflatex asyfile | ||
+ | To only compile the code, run: | ||
+ | cd | ||
cd ~/Desktop | cd ~/Desktop | ||
− | + | latex asyfile | |
− | + | asy asyfile-*.asy | |
− | + | latex asyfile | |
− | + | (Only use one or the other). | |
− | + | The first latex compilation creates the latex file needed to run asy in the 4th command. The asy command compiles the asymptote code in '''asyfile.asy''', and the final latex compilation completes the file with the asy code. | |
− | + | If done correctly, the file will produce a diagonal blue line. | |
− | |||
− | |||
− | |||
− | + | == Automation == | |
− | + | If you don't want to run those 3 commands (the last three are what you really need to compile it - the first 2 are to get into the correct folder), in the terminal, run: | |
+ | vi ~/.zshrc | ||
+ | Then click "i" to "insert" into the file. | ||
+ | Copy and paste this code into the file: | ||
+ | <nowiki>asytex () { pdflatex $1.tex; asy $1-*.asy; pdflatex $1.tex }</nowiki> | ||
+ | Press esc + :wq + return. Quit the terminal, and restart it. You may now compile the file above by running: | ||
+ | asytex asyfile | ||
+ | If you wish to not use "asytex", you can rename it via following the steps above, except, instead of copy and pasting the code above, change the "asytex" at the start of the copy and pasted command. For example, if you want to rename it as "texasy", then the line will look like: | ||
+ | <nowiki>texasy () { pdflatex $1.tex; asy $1-*.asy; pdflatex $1.tex }</nowiki> | ||
+ | And if you wish to only compile it with latex, and not into a pdf, simply replace "pdflatex" with "latex", like so: | ||
+ | <nowiki>asytex () { latex $1.tex; asy $1-*.asy; latex $1.tex }</nowiki> |
Latest revision as of 14:18, 5 July 2024
Asymptote (Vector Graphics Language) |
Getting Started - Basics - Reference - Examples - Macros and Packages - Advanced Asymptote - Help |
Contents
Installing Asymptote on a Mac/Linux
The first two installations were tested on Mac OS 10.15.7 "Catalina," but should work for most older systems as well as other Unix systems. The third was tested on Mac OS 11.3 "Big Sur"
Download the Asymptote source here (at the time of this edit, it is version 2.86) 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.86.src.tgz, you would replace x.xx with 2.86).
There are three ways to actually install Asymptote: using the AsyIntaller written by PrintrBot, installing it manually via terminal, or using Homebrew.
Installing via the AsyInstaller
- Download the code from GitHub 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.
Installing Manually
Terminal commands are italicized.
- Open Terminal (located in /Applications/Utilities/Terminal.app)
- Run: cd ~/Downloads (or wherever you put the asymptote-x.xx.src.tgz file)
- tar -xvzf asymptote-x.xx.src.tgz
- cd asymptote-x.xx
- ./configure
- make all
- 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 the Xcode Command Line tools
You have finished installing Asymptote.
Installing via Homebrew
1. To download homebrew, run
cd /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
in the terminal window.
2. Run
brew install --cask mactex
3. Then run
brew install asymptote
both in the terminal window.
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.
To compile this into PDF form, in the terminal, run:
cd cd ~/Desktop pdflatex asyfile asy asyfile-*.asy pdflatex asyfile
To only compile the code, run:
cd cd ~/Desktop latex asyfile asy asyfile-*.asy latex asyfile
(Only use one or the other). The first latex compilation creates the latex file needed to run asy in the 4th command. The asy command compiles the asymptote code in asyfile.asy, and the final latex compilation completes the file with the asy code. If done correctly, the file will produce a diagonal blue line.
Automation
If you don't want to run those 3 commands (the last three are what you really need to compile it - the first 2 are to get into the correct folder), in the terminal, run:
vi ~/.zshrc
Then click "i" to "insert" into the file. Copy and paste this code into the file:
asytex () { pdflatex $1.tex; asy $1-*.asy; pdflatex $1.tex }
Press esc + :wq + return. Quit the terminal, and restart it. You may now compile the file above by running:
asytex asyfile
If you wish to not use "asytex", you can rename it via following the steps above, except, instead of copy and pasting the code above, change the "asytex" at the start of the copy and pasted command. For example, if you want to rename it as "texasy", then the line will look like:
texasy () { pdflatex $1.tex; asy $1-*.asy; pdflatex $1.tex }
And if you wish to only compile it with latex, and not into a pdf, simply replace "pdflatex" with "latex", like so:
asytex () { latex $1.tex; asy $1-*.asy; latex $1.tex }