[metapost] macros with text argument

Yasir Malik ymalik at stevens.edu
Thu Dec 23 03:26:57 CET 2010


> How can I define a macro that take a text as argument and put it in a
> label? Something like this
>
> %---------
>
> def assi(text labeltext) =
> label(btex labeltext etex, (0,0));
> enddef
>
> %---------
>
You can try the following:
input TEX;

def assi(text labeltext) =
label(TEX(labeltext))
enddef

With the TEX macro, you can pass strings, numbers, and construct equations 
using $$.  Check out page 65 of the MetaPost manual for more info.

Regards,
Yasir


More information about the metapost mailing list