TL;DR : my question is in bold below.

Preamble: I'm pretty new to Latex. Been fiddling around with both MikTex and TexLive for a few days. Have got a working setup on Windows (with ghostscript, Image Magick, WinEdt9, TexLive, asymptote, asypictureB).

Using PDFTeXify from WinEdt, with an added -shell-escape command line parameter, I can produce a correct PDF from this (great looking) example. (This example is actually the reason I'm diving into Latex at all)

I'm trying to get the above asymptote script exported as SVG.

If I set settings.outformat = "svg"; in the .tex file (twice), it does produce an svg, but with rendered contents (About 120 external png files arranged by the svg). I want it to be pure vector (like in the PDF). How do I do that?

http://asymptote.sourceforge.net/doc/Options.html mentions:

To produce SVG output, you will need dvisvgm (version 0.8.7 or later) from http://dvisvgm.sourceforge.net and must use the latex or tex tex engine. You might need to adjust the configuration variable libgs to point to the location of your Ghostscript library libgs.so (or to an empty string, depending on how dvisvgm was configured).

I checked, and it seems all my dependencies are okay.

Sidenote: if I do settings.outformat = "eps"; , I do get a *-sphere.eps and a *-cilinder.eps, but not an end result of the two eps files combined. Those eps files are indeed pure vector. I could combine these manually and convert them to svg. Needless to say, I want it in one go.

  • 1
    Asymptote's SVG driver can't create a pure vector image from the example you mentioned. Thus, you probably have to post-process the PDF file (e.g. with pdf2svg) to get a proper SVG file.
    – Martin
    Commented Sep 15, 2014 at 7:35
  • @Martin Thank you, that helps. I tried pdf2svg but that renders as well. Opening the svg from inkscape worked better, and gave pure vectors. It does have some small artefacts, among which losing transparency and no pure gradients, but nonetheless useful. Could you elaborate a little bit on why Asymptote's SVG driver can't handle this? Does it do special commands (like pstricks)? If you put this in an answer I can accept that ofcourse. Commented Sep 15, 2014 at 9:46
  • As far as I can tell, in SVG mode, Asymptote creates bitmaps for all parts of the graphic that can't be expressed by SVG elements properly. Compared to PDF, SVG has only limited support for shading patterns aka gradient fills for example. The pre-rendered bitmaps are forwarded to dvisvgm (using specials) in order to arrange them together with the text. That's probably not the most satisfying solution. It should be possible to approximate things in SVG completely even if the result is not perfect. I'm working on shading patterns for one of the next dvisvgm releases.
    – Martin
    Commented Sep 15, 2014 at 13:21
  • Thanks. SVG has pretty elaborate support for gradient fills though. I think the main fault behind my expectation was, that asymptote works with pdflatex, and a pdf is not what I need. Would it be fair to say that it would have to be written for a new kind of exec, say svglatex? Or perhaps for lualatex? Sorry if these are silly questions, I'm an experienced programmer in several languages but have no knowledge of latex prior to the last few days. I did notice that I could not get Asymptote to work with other WinEdt execution modes, like TeXify, LateX, AMSteX, ConteXt or LuaTeX. Commented Sep 15, 2014 at 15:29
  • You're right, SVG supports gradient fills but compared to PDF or PostScript they are pretty limited. It's hard to map arbitrary function-, cone or tensor-based shading patterns to the linear/radial fills offered by SVG. Asymptote works with pdflatex and the classic latex which produces DVI files as well. I guess it should be possible to approximate the results you're looking for if Asymptote called the proper post-processors rather than referencing bitmaps. However, I'm not an Asymptote expert and don't know how complicated that would be.
    – Martin
    Commented Sep 15, 2014 at 17:05

1 Answer 1


Martin provided plenty of info on why this is (at least currently) impossible.

So I'll answer this as unsolvable.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .