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.

I want to create a Feynman diagram, with the feynmf package. While compiling, no error occurs, but no diagram is produced.

I have searched through the net, and I found that I have to create an mf file.

The code I am using is

    \documentclass{article}
    \usepackage{feynmf}
    \begin{document}
    \unitlength = 1mm
    % determine the unit for the size of diagram.
    ... here comes an example with feynmf
     \begin{fmffile}{one}   %one.mf will be created for this feynman diagram  
       \fmfframe(1,7)(1,7){     %Sets dimension of Diagram
       \begin{fmfgraph*}(110,62) %Sets size of Diagram
        \fmfleft{i1,i2} %Sets there to be 2 sources 
        \fmfright{o1,o2}    %Sets there to be 2  outputs
        \fmflabel{$e^-$}{i1} %Labels one of the left sources
        \fmflabel{$e^+$}{i2} %Labels one of the left sources
        \fmflabel{${\ensuremath{\erlpm}}$}{o1} %Labels one of the right outputs
        \fmflabel{${\ensuremath{\erlpm}}$}{o2} %Labels one of the right outputs
        \fmf{fermion}{i1,v1,i2} %Connects the sources with a vertex.
        \fmf{fermion}{o1,v2,o2} %Connects the outputs with a vertex.
        \fmf{photon,label=$\gamma/Z^0$}{v1,v2} %Labels the conneting line.
       \end{fmfgraph*}
      }
    \end{fmffile}

The thing is that I have to create one.mf file, run LaTeX, run one.mf and run LaTeX again.

How am I supposed to run and create run.mf?

share|improve this question
    
The file one.mf is created when you compile the document with LaTeX; then you open a command shell in the same directory as the document and type mf one followed by the "return" key. –  egreg Mar 26 '12 at 13:57
    
That's the point! How can I find TXC's command shell? –  Thanos Mar 26 '12 at 14:02
    
Not TeXnicCenter's: it's the standard DOS command shell. –  egreg Mar 26 '12 at 14:03
    
A guy I was talking to uses WinEdit. He has his own command prompt. I thought it's the same with TXC. I don't know how to use the DOS shell... Any help could be of vital importance! –  Thanos Mar 26 '12 at 14:08
1  
I suggest you read up in the feynmf manual which states the order of operations in order to accomplish diagrams. Then read up on TeXnicCenter on how to create profiles, for instance here: Metapost profile. –  zeroth Mar 27 '12 at 12:46

3 Answers 3

up vote 5 down vote accepted

egreg's suggestion of using MetaPost instead of MetaFont is the way to go. If you are not used to the command line, I'll suggest an easy way to convert your file in Windows.

Open Notepad and add the following line:

mpost %1

Then, when saving, use Drop MF file here.cmd as the name (don't forget to add the .cmd extension) and select All files (*.*) in the Type option. The follow figure illustrates this step: (Sorry, my Windows is in Portuguese, but the idea is the same)

Notepad

Now I have the following files in my folder:

Files

Compile mydoc.tex (where the .tex file is the one egreg suggested you to use) and the other files will be generated:

Generation

Now, time for the magic. Select one.mp and drag it over drop MF file here.cmd and release it:

Drag and drop

Wait some seconds and there we go!

Final

Now, compile mydoc.tex again and your diagram will be there:

Screenshot

Hope it helps. :)

share|improve this answer
    
Thank's a lot for your advice... But it didn't work...I get two errors.1.Cannot include graphics of type: mps, 2. Emergency Stop... –  Thanos Mar 27 '12 at 14:33
    
@Thanos: egreg updated his answer, could you try the new code? :) –  Paulo Cereda Mar 27 '12 at 14:47
    
Either eps or mps isn't working... –  Thanos Mar 27 '12 at 15:14
    
@Thanos: Which TeX distro do you use? –  Paulo Cereda Mar 28 '12 at 10:52
    
MikTex 2.8. My editor is TXC –  Thanos Mar 28 '12 at 11:23

It's better to use feynmp in place of feynmf, nowadays. It's almost the same input, but it requires to run mpost instead of mp:

\documentclass{article}
\usepackage{feynmp} % <- change here
\DeclareGraphicsRule{.1}{mps}{.1}{} % <- line to be added if using pdflatex
%\DeclareGraphicsRule{.1}{eps}{.1}{} % <- line to be added if using pdflatex
\begin{document}
\unitlength = 1mm
% determine the unit for the size of diagram.
... here comes an example with feynmf
 \begin{fmffile}{one}   %one.mf will be created for this feynman diagram  
   \fmfframe(1,7)(1,7){     %Sets dimension of Diagram
   \begin{fmfgraph*}(110,62) %Sets size of Diagram
    \fmfleft{i1,i2} %Sets there to be 2 sources 
    \fmfright{o1,o2}    %Sets there to be 2  outputs
    \fmflabel{$e^-$}{i1} %Labels one of the left sources
    \fmflabel{$e^+$}{i2} %Labels one of the left sources
    \fmflabel{${\ensuremath{\erlpm}}$}{o1} %Labels one of the right outputs
    \fmflabel{${\ensuremath{\erlpm}}$}{o2} %Labels one of the right outputs
    \fmf{fermion}{i1,v1,i2} %Connects the sources with a vertex.
    \fmf{fermion}{o1,v2,o2} %Connects the outputs with a vertex.
    \fmf{photon,label=$\gamma/Z^0$}{v1,v2} %Labels the conneting line.
   \end{fmfgraph*}
  }
\end{fmffile}
\end{document}

When the picture changes one has to run from a shell mpost one and at the next run of LaTeX the correct picture will be included.

In some minutes some suggestions about how to run Metapost will be added

share|improve this answer
    
I have already tried feynmp but it didn't work either. The whole point is how to run mpost one, or one.mf or one.mp! I cannot find TXC's commant prompt or shell or window! –  Thanos Mar 27 '12 at 14:01

Solved!!!

I added the following "script" after

    \DeclareGraphicsRule{.1}{mps}{.1}{}

and before

    \begin{document}

The code is

    \makeatletter
    \def\endfmffile{%
      \fmfcmd{\p@rcent\space the end.^^J%
      end.^^J%
      endinput;}%
      \if@fmfio
        \immediate\closeout\@outfmf
      \fi
      \ifnum\pdfshellescape=\@ne
        \immediate\write18{mpost \thefmffile}%
      \fi}
    \makeatother

The feynman shows up like charm!!! I also used another code insted of the first one posted my me

    \begin{fmffile}{oneone}
    \begin{fmfgraph}(40,25)
    % Note that the size is given in normal parentheses
    % instead of curly brackets.
    % Define external vertices from bottom to top
    \fmfleft{i1,i2}
    \fmfright{o1,o2}
    \fmf{fermion}{i1,v1,o1}
    \fmf{fermion}{i2,v2,o2}
    \fmf{photon}{v1,v2}
    \end{fmfgraph}
    \end{fmffile}

Both codes produce nice diagrams. Thank you a lot guys for you effort and patience! For anyone who is to use this package: In order to make corrections to the diagrams, someone has to delete all files (.mp, .1, .t1, .txt) and do the proccess that Paulo described!

share|improve this answer

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.