TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:

input TEX;

outputformat := "svg";

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


  draw fullcircle scaled 1in;
  string l;
  l = "Foo";
  dotlabel.bot(TEX("Label is " & l), origin);
share|improve this question
Could you make a small example where you use TEX.mp? – egreg Sep 23 '13 at 15:15
@egreg, better? – Colin Fraizer Sep 23 '13 at 15:30
Well, the output I get is completely mangled. – egreg Sep 23 '13 at 15:40
@egreg, I am using MetaPost 1.802 (TeX Live 2013/W32TeX) with command line: mpost --numbersystem=double --file-line-error --halt-on-error --tex=latex. – Colin Fraizer Sep 23 '13 at 15:44
I too, but the output gets mangled, at least when opened with Firefox or Safari. Oh, and the same if I use PS output and convert to PDF – egreg Sep 23 '13 at 15:51

Are you looking for the latexmp package? To quote:

The MetaPost pack­age la­texMP im­ple­ments a user-friendly in­ter­face to ac­cess LaTeX-based type­set­ting ca­pa­bil­i­ties in MetaPost. The text to be type­set is given as string. This al­lows even dy­namic text el­e­ments, for ex­am­ple coun­ters, to be used in la­bels. Com­pared to other im­ple­men­ta­tions it is much more flex­i­ble, since it can be used as di­rect re­place­ment for btex..etex, and much faster, com­pared for ex­am­ple to the so­lu­tion pro­vided by tex.mp

share|improve this answer
It seems not to work well with svg output, though. – cfr May 2 '14 at 1:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.