[NTG-context] emp.sty and metapost

Aditya Mahajan adityam at umich.edu
Wed Jun 28 06:23:00 CEST 2006


On Tue, 27 Jun 2006, David Arnold wrote:

> All,
>
> Not strictly a context question, but it has to do with Metapost, so
> maybe someone can help.
>
> I have a file of macros called qdftools.mp:
>
> numeric s; s=0.2;
> color gridlines; gridlines:=(s,s,s);
>
> def openbluedot(expr pos)=
> fill fullcircle scaled 4pt withcolor white;
> draw fullcircle scaed 4pt withcolor blue;
> enddef;
>
> def openreddot(expr pos)=
> fill fullcircle scaled 4pt withcolor white;
> draw fullcircle scaed 4pt withcolor red;
> enddef;
>
> def filledreddot(expr pos)=
> fill fullcircle scaled 4pt withcolor red;
> draw fullcircle scaed 4pt withcolor red;
> enddef;
>
> def filledbluedot(expr pos)=
> fill fullcircle scaled 4pt withcolor blue;
> draw fullcircle scaed 4pt withcolor blue;
> enddef;
>
> def vtick(expr pos)=
> draw ((0,-3)--(0,3)) shifted pos;
> enddef;
>
> def htick(expr pos)=
> draw ((-3,0)--(3,0)) shifted pos;
> enddef;
>
> def gridfivefive =
> for k=-5u step 1u until 5u:
>   draw (-5u,k)--(5u,k) withcolor gridlines;
>   draw (k,-5u)--(k,5u) withcolor gridlines;
> endfor;
> enddef;
>
> def xyaxesfivefive=
> drawdblarrow (-5u,0)--(5u,0);
> label.rt(btex $x$ etex, (5u,0));
> label.bot(btex $5$ etex, (5u,0));
> drawdblarrow (0,-5u)--(0,5u);
> label.top(btex $y$ etex, (0,5u));
> label.lft(btex $5$ etex, (0,5u));
> enddef;
>
> endinput;
>
> In the same directory as qdftools.mp, I have a file useemp.tex. Note
> that I am using the emp package.
>
> \documentclass{article}
> \usepackage{amsmath}
> \usepackage{emp,ifpdf}
>
> \ifpdf
> \DeclareGraphicsRule{*}{mps}{*}{}
> \fi
>
> \setlength{\unitlength}{1cm}
>
> \begin{document}
>
> Now is the time for all good men to come to the aid of their country.
>
> \empprelude{input qdftools}
>
> \begin{empfile}
> \begin{empdef}[david](4,4)
> numeric u; 10u=3in;
> gridfivefive;
> xyaxesfivefive;
> \end{empdef}
> \end{empfile}
>
> \immediate\write18{mpost  \jobname}
>
> \empuse{david}
>
> Now is the time for all good men to come to the aid of their country.
>
> \end{document}
>
> Now, here is what I fail to understand. If I compile useemp.tex with:
>
> pdflatex --shell-escape useemp
>
> Then all is well. I get a nice pdf file.
>
> However, if I change one line in the file useemp.tex, namely
>
> \immediate\write18{mpost  \jobname}
>
> to:
>
> \immediate\write18{mpost  -tex=latex \jobname}
>
> Then if I remove the file qdftools.mpx and compile useemp.tex with:
>
> pdflatex --shell-escape useemp
>
> Then I get:
>
> loading : Context Support Macros / PDF (2004.03.26)
> )This is MetaPost, Version 0.901 (Web2C 7.5.5)
> (useemp.mp (qdftools.mpnewer: target file `qdftools.mpx' doesn't exist.
> /usr/local/teTeX/bin/powerpc-apple-darwin-current/makempx: Command
> failed: latex mpxerr.tex; see mpxerr.log
>
> >> qdftools.mp
> >> qdftools.mpx
> ! Unable to make mpx file.
> l.41  label.rt(btex
>                     $x$ etex, (5u,0));
> Transcript written on useemp.log.
>
> Can anyone tell how to work around this problem? I know Context has
> much better support for labels, but I need to write this in Latex for
> our online testing system. http://scinux.redwoods.edu/cgi-bin/
> online_s06/testing.cgi/

I have faced this problem in the past, but was never sure why it 
occured or how to rectify it. Try the command

mpost --tex=latex useemp.mp

on your shell. Do you get the same error message as before (you 
should). Now try,

makempx --tex=latex useemp.mp useemp.mpx

Does this create an mpx file? If it does, then atleast a workaround 
for the problem is to have

\immediate\write18{makempx --tex=latex \jobname.mp \jobname.mpx} 
before
\immediate\write18{mpost --tex=latex \jobname}.

If makempx fails, look at the output of

makempx --verbose --tex=latex useemp.mp useemp.mpx

What do you get?

Aditya



More information about the ntg-context mailing list