# feynmf with pdflatex [duplicate]

Possible Duplicate:
How to use kile with feynmf or feynmp?

I would like to use feynmf, or better feynmp, with pdflatex. My first idea was to replace all the files file.[0-9]* which are produced after running mpost on file.mp corresponding to a \fmffile{file} environment by their PDF version obtained with epstopdf. But unfortunately pdflatex complains

! LaTeX Error: Unknown graphics extension: .1.


Obviously it does not know the filetype from this extension. How can I tell LaTeX that these are PDF files? The names of the files do of course not appear explicitly in my LaTeX source. Note that I looked at How to use kile with feynmf or feynmp? which does not seem to work for me. Also I would prefer a solution which allows me to be able to compile with both latex and pdflatex (of course after generating the corresponding feynmf graph files). I do not mind running feynmf and mpost by hand.

-

## marked as duplicate by egreg, Marco Daniel, Paulo Cereda, Jake, Joseph Wright♦Apr 15 '12 at 13:01

This question was marked as an exact duplicate of an existing question.

Metapost creates postscript files, so to include them in a pdflatex-processed document, you need to make an extra step. One of the ways of doing it is to use the package pst-pdf. Here is an example.

First, here is the document (tmp.tex):

\documentclass{article}
\usepackage{feynmp}
\usepackage{pst-pdf}
\pagestyle{empty}

\begin{document}

\begin{postscript}
\begin{fmffile}{t}
\begin{fmfgraph*}(40,30) \fmfpen{thick}
\fmfleft{i1,i2} \fmfright{o1,o2}
\fmf{fermion}{i1,v1,o1} \fmf{fermion}{i2,v2,o2}
\fmf{photon,label=$q$}{v1,v2} \fmfdot{v1,v2}
\end{fmfgraph*}
\end{fmffile}
\end{postscript}

\end{document}


As you see, the stuff in postscript is inside postscript environment.

Now the workflow

latex tmp                 # Produces the metapost input
mpost t.mp                # Produces t.1 and t.t1.  Can be repeated
# for several Feynman diagrams
latex tmp                 # Creates the dvi file with figures
dvips -o tmp-pics.ps tmp  # Creates the ps file with figures
ps2pdf tmp-pics.ps        # Creates the pdf file with figures
pdflatex tmp              # Compiles the result


And the result:

ps2pdf tmp-pics.ps

-
There is no need to do all those steps: what's sufficient is adding \DeclareGraphicsRule{*}{mps}{*}{} to the document and running mpost t. – egreg Apr 13 '12 at 22:01
hmmm... I agree. – Boris Apr 14 '12 at 0:44
Or just do \usepackage{feynmp-auto} instead of \usepackage{feynmp} – Stan Jun 10 '15 at 11:35