# [NTG-context] ConTeXt + asymptote

John Bowman bowman at math.ualberta.ca
Thu Jun 29 15:40:39 CEST 2006

In regard to adding support for ConTeXt or plain TeX to Asymptote, it
should be no problem to do this, but perhaps someone on this list can help
provide some preliminary information, particularly regarding item 1 below
on how best to rotate text at an arbitrary angle. Also, since I am not sure
what the precise planned use of a plain tex/ConTeXt engine here is, it isn't
clear to me whether the miniltx solution below would be an acceptable solution.

Perhaps someone can also explain why so many context users are interested in
this feature? Why exactly can't they let Asymptote do its typesetting with
latex behind the scenes and then import the resulting ps or pdf files in
context? Is the issue just that latex might not be installed? If so, the
miniltx style file (which appears to be part of plain tex) seems like a
viable and simple solution.

In regard to the remark I saw posted about "monster eps" files, use the
-aZ option and you will see that Asymptote output files are as compact as
those of MetaPost. If you want tex labels, you have to process MetaPost output
through dvips, etc. Asymptote simply does this automatically, perhaps giving
some users the illusion that Asymptote files are bigger. In other words, you
should compare the final postscript files that MetaPost produces, not the
intermediate ones (I recall that there is a MetaPost command for running
MetaPost output through dvips too).

Another issue I would be happy to discuss sometime is the need for implicit
equation solving. We could add it, given an appropriate syntax, but the
majority of uses I have seen for it are covered by the extension function
in math.asy. I find the latter more explicit and less confusing to new
users. But we could be persuaded to add something similar if someone can
justify the need. Asymptote already includes an explicit linear solver that
uses LU decomposition.

Anyway here are the two features we would need from a plain tex/ConTeXt engine:

1. We will need to replace pstricks (which is used only for rotating text)
with PostScript or PDF \special commands. There is a rotate.tex package in
dvips but it would have to be modified to typeset at arbitrary angles...

2. We could use epsf to include PostScript figures or else the miniltx
package. I see from some posts that some ConTeXt users are thinking
of using \epsfbox instead of \includegraphics. Any preferences here?
Alternatively, here is the miniltx solution, which would be trivial to
provide support for in an upcoming release of Asymptote:

Here's an example:

asy -k venn

Edit venn_.tex to look like this (then tex+dvips):

\input miniltx
\input graphicx
\input pstricks
\newbox\ASYbox
\newdimen\ASYdimen
\def\ASYbase#1#2{\setbox\ASYbox=\hbox{#1}\ASYdimen=\ht\ASYbox%
\setbox\ASYbox=\hbox{#2}\lower\ASYdimen\box\ASYbox}
\def\ASYalign(#1,#2)(#3,#4)#5#6{%
\setbox\ASYbox=\hbox{#6}%
\rput[lB]{#5}(#1,#2){\ASYdimen=\ht\ASYbox%
\def\ASYscale(#1,#2)(#3,#4)(#5,#6)#7#8{%
\ASYalign(#1,#2)(#3,#4){#7}{\scalebox{#5}[#6]{#8}}}%
\psset{unit=1pt}
\includegraphics[bb=228.608356 320.125000 382.391644 470.875000]{venn_0.eps}%
\ASYalign(-104.955775,75.657656)(-0.500000,-0.500000){0.000000}{$A$}
\ASYalign(-49.404200,75.657656)(-0.500000,-0.500000){0.000000}{$B$}
\ASYalign(-77.179988,134.822731)(-0.500000,0.000000){0.000000}{$A\cap B$}
\ASYalign(-77.179988,16.492581)(-0.500000,-1.000000){0.000000}{$A\cup B$}
\bye

-- John Bowman
Department of Mathematical and Statistical Sciences
University of Alberta