[metapost] Faster SVG Generation with Metapost?

Colin Fraizer metapost at cfraizer.com
Mon Sep 23 17:58:03 CEST 2013


[I’m not sure what etiquette exists for cross-posting questions from TeX.SE
and here, but I was hoping someone could answer without expending
significant effort.]

I am generating some diagrams with METAPOST. I need the output in SVG
format. My labels are generated by calls to LaTeX via Tex.mp and
its TEX METAPOST definition (also called a macro).

My complaint: it is pretty slow to constantly write stuff to a file and fire
off an instance of latex.

Is there a faster way to achieve the same result? (As I recall, I can use
METAPOST inside a TeX document with the package luamplib, which is fast, but
it generates PDF, not SVG.)

Using MetaPost 1.802 (TeX Live 2013/W32TeX).
Command: mpost --numbersystem=double --file-line-error --halt-on-error
--tex=latex foo.mp

Thanks!
--Colin Fraizer
Indiana, United States

Minimal example:
prologues:=3;
input TEX;

outputformat := "svg";
outputtemplate:="%j.%{outputformat}";

string texpre;
% texpre = "%&latex" & char(10) &
texpre = 
  "\documentclass{article}" & char(10) &
  "\begin{document}  " & char(10);

TEXPRE(texpre);
TEXPOST("\end{document}");

beginfig(1)
  draw fullcircle scaled 1in;
  string l;
  l = "Foo";
  dotlabel.bot(TEX("Label is " & l), origin);
endfig;
end





More information about the metapost mailing list