# Fonts in math expressions in Metapost

I try to create a Metapost figure that contains math fonts, like:

beginfig(1);

label.urt(btex $\mathfrak{b}$ etex,(100,0));

label(btex $\mathcal{X}_{\eta}$ etex,(-15,55));

endfig;

end

Running "mpost filename" produces "Unable to make mpx file". The reason is the included fonts. What should I do to make it work? Thanks, Eilon

Another way: using the latexmp package and its textext macro. Contrary to the classical btex…etex flags, it allows you to use loops inside your labels.

input latexmp;
setupLaTeXMP(packages="amssymb");
beginfig(1);
label.urt(textext("$\mathfrak{b}$"),(100,0));
for i = 1 upto 5:
label(textext("$\mathcal{X}_{" & decimal i & "\eta}$"),(-15i,55));
endfor
endfig;
end.

The drawback is the fact you have to run the program twice to make the labels appear. To avoid that, you can set the package variable mode to rerun:

setupLaTeXMP(packages="amssymb", mode=rerun);

with some restrictions which are detailed in the very well-made documentation.

• I probably do something completely wrong. I copy-paste the code you provided into the file figure.mp, and then I write in the command line "mpost figure". I keep on getting an error "Unable to make mpx file" with both codes you provided. What do I do wrong? – Eilon Jul 14 '15 at 10:08
• @Eilon What if you enforce the use of LaTeX as TeX typesetter? I.e. try mpost --tex=latex figure.mp (it shouldn't be necessary with latexmp nor with the classical verbatimtex %&latex... etex approach on most systems, but maybe your system is an exception.) – Franck Pastor Jul 14 '15 at 11:14
• Many thanks, all! This works, with the only exception that I did not include the line "setupLaTeXMP(packages="amssymb");". When I included all math symbols appeared as the word "LaTeXMP" with a serial number... – Eilon Jul 15 '15 at 5:49
• @Eilon Yes, as I said, with LaTeXMP you have to run twice to make the labels appear, and you can automatize this double run by adding mode=rerun to the argument of setupLaTeXMP. – Franck Pastor Jul 15 '15 at 6:19

Try

verbatimtex
%&latex
\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\begin{document}
etex;
prologues:=3;
beginfig(1);
label.urt(btex $\mathfrak{b}$ etex,(100,0));
label(btex $\mathcal{X}_{\eta}$ etex,(-15,55));
endfig;
end.
• Many people write as verbatimtex \end{document} etex; when they choose latex in MetaPost. However those lines are not needed because intermediate TeX file for MetaPost always ends with \end{document}, even in the case of plain TeX. – Akira Kakuto Jul 14 '15 at 6:05