[NTG-context] Commands with arguments with MetaPost

Alan BRASLAU alan.braslau at cea.fr
Wed Apr 25 18:45:22 CEST 2012

On Wed, 25 Apr 2012 11:15:10 -0500
Troy Henderson <thenders at gmail.com> wrote:

> I would like to be able to do something like this
> \def\foo#1{
>     \startMPcode
>         fill (0,0)--(598,0)--(598,50)--(0,50)--cycle withcolor green;
>         label.rt(btex #1 etex),(50,25);
>   \stopMPcode
> }
> and then use this in my ConTeXt document by
> \foo{Some text}
> However, my syntax seems to be incorrect, and I would appreciate any
> help in fixing it.

\framed [frame=off,background=color,backgroundcolor=green,width=598,height=50]
	{Some text}

(Of course, you need to put correct dimensions for the width and height
and also set an offset.)

Untested, so the syntax may be not quite correct.

You might want to use
if you will be doing this often.
There is probably also a way to define a named framed text.


More information about the ntg-context mailing list