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.

Im triying to learn how to draw Feynman diagrams by using feynMF which I installed from this link and compiled. however even in this simple example which I took from manual it gave me ! I detected a fmfgraph environment outside of fmffile. ! I detected a fmfgraph environment outside of fmffile. these errors. how can I fix this problem? thanks

\documentclass[11pt]{article}    
\usepackage{feynmf}
\begin{document}
\begin{fmfgraph}(40,25)
\fmfpen{thick}
\fmfleft{i1,i2}
\fmfright{o1,o2}
\fmf{fermion}{i1,v1,v3,o1}
\fmf{fermion}{o2,v4,v2,i2}
\fmf{photon}{v1,v2}
\fmf{photon}{v3,v4}
\fmfdotn{v}{4}
\end{fmfgraph}
\end{document}
share|improve this question
1  
Every fmfgraph environment must be enclosed inside an fmffile environment. –  egreg May 31 at 12:42
    
Im sorry but I don't know what does this mean –  jackaraz May 31 at 12:47
    
I see. I used following code but this time it draws nothing: \begin{fmffile}{simple} \begin{fmfgraph}(40,25) \fmfleft{i1,i2} \fmfright{o1,o2} \fmf{fermion}{i1,v1,o1} \fmf{fermion}{i2,v2,o2} \fmf{photon}{v1,v2} \end{fmfgraph} \end{fmffile} –  jackaraz May 31 at 12:56
    
You have to run Metafont or Metapost (depending on whether you load feynmf or feynmp). See my answer. –  egreg May 31 at 12:57

1 Answer 1

up vote 4 down vote accepted

Nowadays it's better using feynmp rather than feynmf, because it's easier to produce the pictures. feynmp also has the distinct feature of using Metapost, which produces EPS vector graphics, while FeynMF uses Metafont, which produces bitmaps. According to Thorsten Ohl, the creator of this package, feynmf is outdated.

In any case you have to tell the package the name of the auxiliary file where the Metapost code is to be written, which is done by opening a fmffile environment.

\documentclass[11pt]{article}
\usepackage{feynmp}
\DeclareGraphicsRule{*}{mps}{*}{} % for being able to read the produced file

\begin{document}

\begin{fmffile}{afilename}% choose something better!
\begin{fmfgraph}(40,25)
\fmfpen{thick}
\fmfleft{i1,i2}
\fmfright{o1,o2}
\fmf{fermion}{i1,v1,v3,o1}
\fmf{fermion}{o2,v4,v2,i2}
\fmf{photon}{v1,v2}
\fmf{photon}{v3,v4}
\fmfdotn{v}{4}
\end{fmfgraph}
\end{fmffile}

\end{document}

After running LaTeX, you have to run mpost afilename and then recompile. If you have a fairly recent TeX distribution, you can use feynmp-auto:

\documentclass[11pt]{article}
\usepackage{feynmp-auto}

\begin{document}

\begin{fmffile}{afilename}% choose something better!
\begin{fmfgraph}(40,25)
\fmfpen{thick}
\fmfleft{i1,i2}
\fmfright{o1,o2}
\fmf{fermion}{i1,v1,v3,o1}
\fmf{fermion}{o2,v4,v2,i2}
\fmf{photon}{v1,v2}
\fmf{photon}{v3,v4}
\fmfdotn{v}{4}
\end{fmfgraph}
\end{fmffile}

\end{document}

and you'll just have to compile twice (the second LaTeX run is needed only if the code for a Feynman diagram has changed or some new diagram has been added).

share|improve this answer
    
I did the first one after mpost afilename comment it gave ! LaTeX Error: Unknown graphics extension: .1. error for \begin{fmfgraph}(40,25). for the second one I couldn't install feynmp-auto.sty –  jackaraz May 31 at 13:52
1  
@jackaraz Did you add the \DeclareGraphicsRule line? –  egreg May 31 at 13:52
    
it gave me very very small diagram –  jackaraz May 31 at 13:55
    
@jackaraz Yes, it's small, because that's what the code produces. –  egreg May 31 at 13:56
1  
Let us continue this discussion in chat. –  egreg May 31 at 14:19

Your Answer

 
discard

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.