# metapost pictures in pdflatex

To include metapost pictures in a latex file compiled by pdflatex I usually do something like

``````\usepackage[pdftex]{graphicx}
...
\includegraphics{filename-without-mps}
``````

but this requires all metapost output to have extension `.mps` (which is usually fine — one can just add the line `filenametemplate "%j-%c.mps";` into .mp source). Is there a way to include mps pictures with their usual filenames (`smth.1`, `smth.2` etc)?

Upd. I usually need it to recompile some old files with pdflatex — so I need some recipe that adds couple of lines in the preamble but not requires to changes everything.

I tried to invent some hack (for Windows, to be compiled with `pdflatex -enable-write18`):

``````\usepackage[pdftex]{graphics}
\DeclareGraphicsRule{.1}{pdf}{.1.pdf}{`copy #1 #1.eps && epstopdf #1.eps}
...
\includegraphics{smth.1}
``````

which indeed generates `smth.1.pdf` but fails with the error

``````! Package pdftex.def Error: File `smth-1-converted-to.1.pdf' not found.
``````

Upd2. The question was answered. But maybe someone knows how to make this hack work?

-
@vanden it's not a question about metapost — are you sure it needs `metapost` tag? –  Grigory M Aug 11 '10 at 20:38
I don't do much graphics. I took the presence of "metapost" in the title and the details about metapost extensions to indicate metapost content. But, as you as asker think not, I've reverted. –  vanden Aug 11 '10 at 20:59

Just do:

``````\DeclareGraphicsRule{.1}{mps}{*}{}
\DeclareGraphicsRule{.2}{mps}{*}{}
% etc.
``````
-
Now I'm feeling infinitely stupid –  Grigory M Aug 11 '10 at 21:49
Even "\DeclareGraphicsRule{}{mps}{}{}", maybe. But AFAIR it didn't work in some situation... –  Grigory M Aug 11 '10 at 22:32

Do you know that there's a package for encapsulating metapost figures in LaTeX? It's called emp.

-
Didn't know about it, thanks (but it certainly doesn't resolve my problem). –  Grigory M Aug 11 '10 at 20:33
Just trying add helpful information. :) –  Stefan Kottwitz Aug 11 '10 at 20:47
Does emp have any support for Luatex/mplib? –  Charles Stewart Aug 11 '10 at 21:04
LuaTeX is based on PDFTeX and has mplib baked in so there should be no need for encapsulation of MetaPost graphics. –  Sharpie Aug 11 '10 at 22:12
@Charles, @Sharpie: in luatex, emp is superceded by the 'luamplib' package, which defines an environment and makes sure the library results are correctly included in the output. –  Taco Hoekwater Aug 15 '10 at 15:44