[pdftex] Including \textcolor in metapost in pdf

Jens-Uwe Morawski morawski at gmx.net
Sun Sep 28 20:55:12 CEST 2003

On Fri, 26 Sep 2003 18:40:39 +0200
Jean-Christophe Dubacq <jean-christophe.dubacq at ens-lyon.org> wrote:

> I would like to include colored text in metapost, but dvitomp does not
> manage color.
> I saw solutions using ConTexT --- but I do not know ConTexT (not this
> year, maybe next year). I use only the mptopdf macros from ConTexT
> (loaded automatically by the pdfdriver).

even ConTeXt cannot do this. The problem is dvitomp that does not
support the specials.
> Do people out ther know how to do that ?
> (btw, my metapost is something like
> label(btex The answer is \textcolor{\teacheronly}{42} etex,(0,0));

I have written a MetaPost package called latexMP. The main purpose
of that package is to ease LaTeX based typesetting in MP and to provide
a compatible alternative to ConTeXt/MetaFun's textext() macro based
on LaTeX for stand-alone graphics.
One additional feature of that package is exactly what you request.
It is an ugly but working hack around the special-problem, but compared
to Hans' solution it even works for text with linebreaks (\vbox/\parbox).
The MP code using latexMP looks like:

input latexmp ;
setupLaTeXMP(textextlabel=true,multicolor=true) ;

color teacheronly ; teacheronly := .7red ;

label("The answer is \textcolor{teacheronly}{42}" , origin ) ;
% or
label("The answer is \textcolor[rgb]{0.7,0,0}{42}" , origin ) ;

As you can see, the syntax is similar to LaTeX's color package.
I have to finish the documentation first, thus in some days you should find
the package on CTAN.

BTW, since your question is not related to pdftex please join the MP-ML for
further discussion:


More information about the pdftex mailing list