[metapost] Get started

source liu sourceonly at gmail.com
Mon Jan 16 02:56:55 CET 2012


On Mon, Jan 16, 2012 at 6:26 AM, Franck Pastor <franck.pastor at mac.com> wrote:
>
> Le 15 janv. 2012 à 15:30, abewayer a écrit :
>
>
>> I don't have questions about the code but I need a help about tecnical
>> use of a mp file.
>>
>> Exemple:
>>
>> I got a file like this:
>>
>> drow (20,20)--(0,0)
>>
>> Just a simple istruction, just a line.
>> How can I visualize this line?
>>
>> I have tried with the command $ mpost file.mp
>>
>> But I obtain an output like this:
>>
>> abeplace:/home/abewayer# mpost prova.mp
>> This is MetaPost, version 1.208 (kpathsea version 5.0.0)
>> (./prova.mp
>>>> drow
>> ! Isolated expression.
>> <to be read again>
>>                   (
>> l.1 drow (
>>          20,20)--(0,0)
>> ?
>
>
> You must enter "draw", not "drow", and with a semicolon at the end of the line:
>
> draw (20, 20) -- (0,0);
agree, it should be draw rather than "drow" in yours as the compiler indicated.

and you need to type the command in such structure

beginfig(1);

%draw command goes here  * this is just comment*

draw (20, 0) --(0,1);
endfig;

we assume the file is test.mp.
after you run
$mpost test.mp
you would get a file called "test.1".

It's a eps file, either view or convert it to pdf as well as include
it directly in TeX.  enjoy.


of course, the output format could be highly customized, just a simple
example to illustrate the usage.

Hope it would help you.


Liu An
Institution of modern physics, Shanghai, China



More information about the metapost mailing list