Take the 2-minute tour ×
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.

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.

share|improve this question
add comment

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

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer

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):



\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}


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:

enter image description here ps2pdf tmp-pics.ps

share|improve this answer
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
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.