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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is an example from mpgraphics package documentation:

draw (20,20)--(0,0)--(0,30)--(30,0)--(0,0)

I am getting something like this: enter image description here

I'm using:
- mpost version 1.504 (MiKTeX 2.9)
- pdfTeX, Version 3.1415926-2.3-1.40.12 (MiKTeX 2.9)
- MiKTeX EPS-to-PDF Converter 2.9.3275 (MiKTeX 2.9)

I compile using wrige using TexMaker and compile by means of:
latexmk -e "$pdflatex=q/pdflatex -synctex=1 -shell-escape -interaction=nonstopmode/" -pdf %.tex


pdflatex -interaction=nonstopmode -synctex=1 -shell-escape %.tex (result is the same)

What am I doing wrong?

You can find the log file here. Example compiled by: pdflatex -interaction=nonstopmode -enable-write18 -synctex=1 -shell-escape %.tex

Resulting pdf: link

I tried to compile it by a command line. This is what I got: The whole folder with source and logs

share|improve this question
You are using MikTeX. So you have to call --enable-write18 ... see: docs.miktex.org/manual/pdftex.html or simple texdoc pdftex – Marco Daniel May 28 '12 at 19:02
I tried latexmk -e "$pdflatex=q/pdflatex -synctex=1 -shell-escape --enable-write18 -interaction=nonstopmode/" -pdf %.tex and it still does not work. – Ichibann May 28 '12 at 19:05
--shell-escape isn't available for MikTeX. Please test it with pdflatex --enable-write18 --synctex=1 %.tex. – Marco Daniel May 28 '12 at 19:06
How can --shell-escape not be avaliable when I do use it (without it my project wouldn't even compile)? Just tried pdflatex --enable-write18 --synctex=1 %.tex. No change. – Ichibann May 28 '12 at 19:07
I read that in MikTeX 2.9 shell-escape may work. tex.stackexchange.com/questions/37570/… (Comment of @egreg). Whatever earlier MikTeX versions don't support shell-escape. – Marco Daniel May 28 '12 at 19:13
up vote 3 down vote accepted

As I said in a previous comment, your example compiled without problem in my OSX box, so I was guessing the problem was in your Windows setup.

Looking carefully at your _COMMAND_LINE_.txt file, I noticed the following, in line 72:

Preloading the plain mem file, version 1.004))epstopdf: -o: unknown option

Note the error at the end of the line. Your epstopdf program is refusing -o option, and thus it is not producing the pdf output. mpgraphics package issues a Warning, which somehow, instead of appearing in the standard output or in the .log file, appears in the final pdf. This is why your documment contains the strange text mpgrahphics******** etc. (this could be considered a bug in mpgraphics implementation.)

Nevertheless, the problem is with your epstopdf program. mpgraphics package recommends a "recent" version of epstopdf. I don't know if the problem is that your epstopdf version is not recent enough or whether epstopdf is broken in Windows.

You can try to execute epstopdf --help in command line and learn which switch it uses instead of -o (which is for setting the name of the resulting pdf). Once you know this, you can hack the file mpgraphics.sty (search for the string -o in that file, in my version is at line 77), and change it appropiately.

share|improve this answer
epstopdf is a Perl script, so it should be platform independent. There may be a different version lying around that's used in preference of the "official" one. – egreg Jun 5 '12 at 9:45
Thanks a lot! In my version of epstopdf there is --outfile= instead of -o. I was able to change it in mpgraphics.sty as you suggested. – Ichibann Jun 7 '12 at 10:30
@VafaKhalighi Can you give a look to this? – egreg Jun 7 '12 at 20:18

On a Unix system I get the desired result with

latexmk -pdf -pdflatex='pdflatex --shell-escape --interaction=nonstopmode %O %S' filename.tex

Probably on Windows the quotes should be ", so I suggest to try giving Texmaker the instruction

latexmk -pdf -pdflatex="pdflatex --shell-escape --interaction=nonstopmode %O %S" %.tex

If --shell-escape doesn't work you should try --enable-write18

You may try with gmp, which doesn't use epstopdf, instead of mpgraphics:

draw (20,20)--(0,0)--(0,30)--(30,0)--(0,0)

I tested it with the former call of latexmk and it seems to work.

Disclosure: I'm the author of gmp.

share|improve this answer
Still doesn't work. I tried to compile by command line. I posted result in my question, – Ichibann May 28 '12 at 21:23
I compiled your example under OSX, and got the desired result using the simple command line pdflatex -shell-escape tmp.tex. So if it doesn't work in Windows I guess that the problem is in the implementation of the mpgraphics package, which makes some assummptions which are not true for Windows. I'll try to dig into mpgraphics code and report my conclusions – JLDiaz Jun 5 '12 at 7:55
@egreg It seems that hacking the mpgraphics.sty does the trick according to the user above. Is there a possibility to update the package mpgraphics to address this issue? – azetina Jun 7 '12 at 15:04
@azetina Ask the author of mpgraphics – egreg Jun 7 '12 at 15:10
@egreg The authors email or weblink seems not to be working. Hmmmmm – azetina Jun 7 '12 at 20:04

The problem as user JLDiaz said, is because of the optional argument of -o of epstopdf program. I am sure that epstopdf program in TeXLive on any platform behaves the same. I tried this on Windows with TeXLive 2012 and it worked but it did not work with epstopdf that MiKTeX 2.9 provides. As for now there is no need to hack anything, your minimal working example just needs to be changed into:

\renewcommand*{\mpg@cmd@epstopdf}[2]{epstopdf \mpg@epstopdf@opts\space --outfile "#2" "#1"}
draw (20,20)--(0,0)--(0,30)--(30,0)--(0,0)

That is the epstopdf in MiKTeX 2.9 accepts --outfile whereas epstopdf in TeXLive 2012 accepts -o. I try my best to fix this in mpgraphics and release a new version of that to CTAN. But I do not think that one could implement an \ifMiKTeX conditional, so I think the only thing I could do is adding MiKTeX option to the package. But if you use TeXLive instead MiKTeX, you should have no problem with the current version of the package.

Update: The new version is now on CTAN. The TDS can be obtained here.

share|improve this answer
Since epstopdf in TeX Live accepts the --outfile option, wouldn't it be better to use this one in all cases? – egreg Jun 8 '12 at 13:12
@egreg: Yes, you are right. I then change -o to --outfile. Thanks for the suggestion. – Vafa Khalighi Jun 8 '12 at 13:15

Your Answer


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.