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.)
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
TEX.mp
?mpost --numbersystem=double --file-line-error --halt-on-error --tex=latex
.