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
beginfig
toendfig
?draw externalfigure
and not onlyexternalfigure
? And are you runningmptopdf -metafun
?-metafun
flag. It now works.