2

I'm trying to use text labels in MetaPost with TeX. The problem is that -tex=... option of MetaPost does not work.

This example works with mpost test.mp:

prologues := 3;
beginfig(1);
label.lrt("e", (0,0));
endfig;
end

This example does not work with mpost -tex=csplain test.mp:

prologues := 3;
beginfig(1);
label.lrt("é", (0,0));
endfig;
end

(csplain is provided by texlive-lang-czechslovak package)

Why -tex=... option of MetaPost does not work?

  • Use btex é etex or see 8.2 “Font Map Files” of the manual. – Henri Menke Nov 16 '18 at 3:05
  • @HenriMenke btex ... etex works. Is it possible to use pk fonts? (I get this warning: Warning: font lhr10 cannot be found in any fontmapfile!) – Igor Liferenko Nov 16 '18 at 3:32
  • I'm not a font expert but don't pk fonts only have 128 slots? I don't think they have é encoded. Also if you're not using btex ... etex MetaPost does not need a TeX engine and the parameter -tex=csplain is ignored. – Henri Menke Nov 16 '18 at 3:52
  • @HenriMenke pk fonts can use 256 slots; for example, to use pk-variant of é, run csplain test.tex + dvips test with the following ~/.dvipsrc: p /dev/null – Igor Liferenko Nov 16 '18 at 5:13
  • @HenriMenke The number of slots is just a function of the encoding. T1 has 256. OT1 has 128. (Just examples.) That's just the TFM stuff. What kind of thing tells TeX what goes in the boxes the TFM describes is another matter. – cfr Nov 16 '18 at 23:47
3

If you don't want to escape to TeX you have to use a font which has this glyph, e.g. texnansi-lmr10. It is important that the input file is encoded in ISO Latin 1.

prologues := 3;
defaultfont := "texnansi-lmr10";
beginfig(1);
label.lrt("é", (0,0));
endfig;
end

It is probably easier to just typeset the labels with TeX by using (as you showed in the question) mpost -tex=csplain test.mp. In this case the file must be encoded in UTF-8.

prologues := 3;
beginfig(1);
label.lrt(btex é etex, (0,0));
endfig;
end

For more info see chapter 9 “Traditional labels and annotations” of Toby Thurston's excellent “Drawing with MetaPost” (PDF).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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