[metapost] Different colours in a label

Aditya Mahajan adityam at umich.edu
Mon Nov 12 15:39:39 CET 2007


On Mon, 12 Nov 2007, Pétiard François wrote:

> No, I want also a blue sqrt symbol, but even this file:
>
> %%%%% file test.mp
> prologues:=3;
> filenametemplate "%j.mps";
> input latexmp ;
> setupLaTeXMP(textextlabel=enable,multicolor=enable,
> class="article",fontencoding="T1");
>
> beginfig(1);
> label("$\sqrt{\color{blue}2}$",(0,0));
> label(btex $\sqrt{2}$ etex,(0,12));
> endfig;
> end;
> %%%%% end of file test.mp

Sorry, I can't help you with latex, but if you can work with a pdf file, 
then ConTeXt seems to handle colors fine. To get just a blue square root 
symbol, you can use

\setupcolors[state=start]

\starttext

\startMPpage
label(\sometxt{$\color[blue]{\sqrt{\color[black] 2}}$},(0,0));
label(\sometxt{$\sqrt{2}$},(100,100));
\stopMPpage

\stoptext


You need to have both ConTeXt and ruby installed. Compile this with
texexec <filename> and it will give you a pdf file.

So you can generate your figures through context, and include the 
resulting pdf file in the latex document.

Aditya


More information about the metapost mailing list