[metapost] Automatic labeling (fwd)

Boguslaw Jackowski B_Jackowski at GUST.org.pl
Tue Nov 14 19:41:44 CET 2006


I wrote:
>> \starttext
>> \startMPcode
>> pair v[];
>> v[1]=origin;
>> v[2]=(1cm,2cm);
>> 
>> for i=1 upto 2:
>>    label(textext(decimal i), v[i]); % could be label(textext("abc"))
>> endfor;
>> \stopMPcode
>> \stoptext

>If you remove backslashed commands and add the command
>
>  end.
>
>at the end, the script should work with mpost.

I was too quick, sorry. You should drop also textext function. Moreover,
you shoud enclose the code with beginfig ... endfig pair:

   beginfig(100)
     pair v[];
     v[1]=origin;
     v[2]=(1cm,2cm);

     for i=1 upto 2: label(decimal i, v[i]); endfor;
   endfig;

   end.

A bit more tricky is the placement of the value of the running variable
(in this case `i') as a part of math formula, say, as a lower or upper 
index.

-- Jacko



More information about the metapost mailing list