[NTG-context] Asymptote in Context

Aditya Mahajan adityam at umich.edu
Tue Jan 20 04:39:48 CET 2015


On Fri, 2 Jan 2015, Context NTG wrote:

> Here is an Asymptote example
>
> unitsize(1cm);
> draw((-.1,0) -- (2,0),
> arrow=Arrow(TeXHead));
> draw((0,-.1) -- (0,2), arrow =
> Arrow(TeXHead));
> draw((0,0) .. (1,1) .. (2,sqrt(2)));
>
>
> Below is how I have started setting this up in Context. This creates a pdf
> file with the drawing, but it is not included in the final docuement.

Sorry for the late reply. You just need to change a few options:

\usemodule[filter]

\defineexternalfilter
   [ASY]
   [
     filter={asy -tex "context" -outformat pdf
             -outname \externalfilteroutputfile},
     output=\externalfilterbasefile.pdf,
     cache=yes,
     readcommand=\ReadImage,
   ]

\define[1]\ReadImage{\externalfigure[#1]}

\starttext
   Testing if we can include an asymptote image
   \startplacefigure[location={here}, title={An Asymptote figure}]
     \startASY
       unitsize(1cm);
       draw((-.1,0) -- (2,0), arrow=Arrow(TeXHead));
       draw((0,-.1) -- (0,2), arrow=Arrow(TeXHead));
       draw((0,0) .. (1,1) .. (2,sqrt(2)));
     \stopASY
   \stopplacefigure
\stoptext

Here \startASY behaves similar to \startMPcode. To get something similar 
to \startMPenvironment in mkii, you can use beforebuffer.

Aditya


More information about the ntg-context mailing list