# Using Asymptote with MiKTeX

Asymptote is shipped out with TeX Live, but not with MiKTeX, not even with a full installation.

Do you nonetheless know a way for manual installation? MiKTeX needs to know the path of the sty files, and the Asymptote binary file needs to know the path of the asy scripts. Thought of adding the Asymptote folder to the list of registered root directories in MiKTeX, but MiKTeX complains, that this would be “Not a TDS-compliant root directory”.

There is already a similar question: Using MikTex Portable, TexMaker, and Asymptote from a USB drive.

-

# For winedt users:

Install asymptote as explained by speravir.

Copy asycolors.sty, asymptote.sty and ocg.sty from asymptote installation folder (C:\Program Files\Asymptote) to your localtexmf folder (for me it is - C:\Local\texmf\tex\latex\asymptote).

Run a file name database refresh (FNDB).

Create a config.asy for gswinc32 as explained by speravir. Note that the asymtote.bat file won't be necessary.

Download and install the winedt macro asymptote. You will get a toolbar button and menu item under TeX.

You are good to go.

-
+1 we can see asy posts from now on :) , I think arara can automate asy and pdflatex sequences. – texenthusiast Apr 3 '13 at 1:39
Upvoted. And I added a link to your answer in mine. – Speravir Apr 3 '13 at 1:50
@texenthusiast: Idea is to learn asymptote first :-). Arara can certainly automate this with ease. – Harish Kumar Apr 3 '13 at 2:17

First, there is a description in the Art of Problem Solving Wiki, Asymptote: Advanced Configuration – Using Asymptote in LaTeX (also linked in the question regarding portable use), we can partly adapt, but in one point I want to strongly discourage you following this: Instead you should install the sty files in a local texmf tree, about the reasons you can read in Purpose of local texmf trees.

This will be successful (WinEdt users read Harish Kumar’s answer first, please):

• Download Asymptote from http://sourceforge.net/projects/asymptote/files/ and install, where you want. I will use here C:\Program Files\Asymptote.

The binary in TeX Live is newly built from sources, has some dependencies of other TeX Live binaries and find its asy scripts with the builtin kpsewhich mechanism. Hence in difference to How to use Xindy with MiKTeX? the installation from TeX Live files is not recommended.

• If not already done Create a local texmf tree in MiKTeX.

• Create a subfolder <localtexmf>\tex\latex\asymptote and copy the three sty files from the Asymptote main directory in it.

• Create an empty file in <localtexmf>\bin\ with the name asymptote.bat (or with extension .cmd).

Copy the following, paste it into the batch file and adjust the path according to your setting:

@echo off
SETLOCAL

SET AsyPATH=C:\Program Files\Asymptote
SET PATH=%AsyPATH%;%PATH%

asy.exe %*


This will also ensure, that the Asymptote binary finds the preshipped script files. A remark: When you save the file in Notepad or Wordpad, make sure, that there is no automatic appending of TXT extension – save the file name with double quotes: "asymptote.bat".

• Refresh the file name database (FNDB). BTW I assume here, that you followed the instructions and added <localtexmf>\bin to the system path. Actually the batch script could be put elsewhere, as long as it was in the system path.

• Asymptote needs also Ghostscript. You have 3 specific opportunities to make it known (adjust path, of course):

• Directly adding the command line option
-gs="<path\to\ghostscript>\bin\gswinc32.exe".
• Adding the environment variable

ASYMPTOTE_GS=<path\to\ghostscript>\bin\gswinc32.exe.
(Note, that this did actually not work in my computer, but I didn’t restart.)

• The preferred variant for frequent users: Create a file config.asy in Asymptote’s main directory with following content

import settings;
gs="<path\to\ghostscript>\bin\gswinc32.exe";


Now you can execute Asymptote in your actual work folder. Let’s make a test: Copy the file latexusage.tex from Asymptote’s examples subfolder into a test folder, I will use c:\test here. Open the Command Prompt and execute

cd /d c:\test,

the /d switch ensures, that you can also change in one step to another drive.

Then compile with your TeX editor or execute

latex latexusage.

This will create 3 asy script files. These 3 files must now be executed with

asymptote latexusage-1.asy

(you could also omit the file extension) and so on for the others.

Then again compile with your TeX editor or execute

latex latexusage.

The result must look as shown below (I cropped it a bit). In Adobe Reader the interactive example works fine as well.

-
Harish, please read carefully: I created a batch file asymptote.bat and this is called with asymptote. In this batch you can find the call of asy.exe. – Speravir Dec 2 '12 at 5:09
OOps! Sorry. It means the batch file did not work for me. Hence I kept getting the error. I went blind Sorry :-) – Harish Kumar Dec 2 '12 at 5:11
Then either the batch is not in the system path or there is something wrong in the batch file itself. – Speravir Dec 2 '12 at 18:40