Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have a metapost file image.mp containing the following lines:

beginfig(0);
draw p0; 
externalfigure "/Users/dsg/tex/images/image.png" xyscaled r0 shifted r1; 
endfig;

When I run mptopdf scene.mp I get the following error:

MPtoPDF 1.4.1 : running 'mpost --mem=mpost   --tex=latex  scene.mp'
This is MetaPost, version 1.504 (kpathsea version 6.1.0)
(mpost.mp (/opt/local/share/texmf-texlive-dist/metapost/base/plain.mp
Preloading the plain mem file, version 1.004)) (./scene.mp
>> externalfigure
! Isolated expression.
<to be read again> 
                   "/Users/dsg/tex/images/image.png"
l.421 ...tex/images/image.png"
                                                   xyscaled r0 shifted r1;

I think it is being caused the new version of metapost on my new computer because this same file used to work on my old computer.

I'm not sure how to fix it. I've tried changing it to:

beginfig(0);
draw p0; 
draw externalfigure "/Users/dsg/tex/images/image.png" xyscaled r0 shifted r1; 
endfig;

But then I get:

MPtoPDF 1.4.1 : running 'mpost --mem=mpost   --tex=latex  scene.mp'
This is MetaPost, version 1.504 (kpathsea version 6.1.0)
(mpost.mp (/opt/local/share/texmf-texlive-dist/metapost/base/plain.mp
Preloading the plain mem file, version 1.004)) (./scene.mp
>> externalfigure
! Improper `addto'.
<to be read again> 
                   withpen
draw->...:also(EXPR0)else:doublepath(EXPR0)withpen
                                                  .currentpen.fi._op_
<to be read again> 
                   "/Users/dsg/tex/images/image.png"
l.421 ...images/image.png"
                                                   xyscaled r0 shifted r1;

(EDIT: added beginfig(0);)

SOLVED: you do not need draw externalfigure ... just externalfigure ..., but as @egreg put it, you need to run mptopdf -metafun

share|improve this question
1  
Could you please add a complete example, from beginfig to endfig? –  egreg Feb 16 '13 at 22:03
2  
Are you sure it is draw externalfigure and not only externalfigure? And are you running mptopdf -metafun? –  egreg Feb 16 '13 at 22:12
    
Thanks @egreg, I was not running with the -metafun flag. It now works. –  dsg Feb 16 '13 at 22:19
    
Welcome to TeX.sx! –  egreg Feb 16 '13 at 22:33
add comment

1 Answer

up vote 3 down vote accepted

You have to announce the Metapost format you want to use (your log shows you're using the default plain.mp, also known as mpost.mp). So the call should be

mptopdf -metafun file

(see the man page at Contextgarden)

According to the documentation, it's just

externalfigure "file" ...;

not with draw in front. You find something in the section "Including graphics" of the Metafun manual, pages 350ff.

share|improve this answer
    
Can you add a link to the documentation? –  dsg Feb 16 '13 at 22:34
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.