# Feynmp together with beamer

How do you include a Feynman diagram in a beamer presentation?

\documentclass{beamer}
\usepackage{amsmath, amsthm, amssymb,latexsym}
\usepackage{slashed}
\usepackage{graphicx}
\usepackage{pgfplots}
\usepackage{bbm}
\usepackage{epstopdf}
\usepackage{hyperref}
\usepackage{tikz}
\usepackage{tabularx}
\usetikzlibrary{calc,decorations.markings}
\usepackage{feynmp}
\mode<presentation> {
\usetheme{Warsaw}
}
\section{Theory}
\subsection{The diagram}
\frame
{
\frametitle{the title etc}
\begin{figure}
\begin{fmffile}{Feynman1}
\fmfframe(-20,-30)(-20,-100){
\begin{fmfgraph*}(40,40)
\fmfleft{i1,i2,i3}
here is the feynmp code....\end{fmfgraph*}
}
\end{fmffile}
\end{figure}
}

\end{document}


The Feynman diagram doesn't show up for me. What am I doing wrong, any suggestions?

-
This is just a guess, but you probably have to declare your frame as fragile. –  Jubobs Nov 2 '13 at 12:38
Ok I'll try that. Ehhm how would one declare that exactly? –  Shut up and Calculate Nov 2 '13 at 12:42
@Jubobs It didn't work man, it is all white and the diagram is not shown. Although I am sure the Feynman diagram is created. This should have a widely known answer but apparently it doesn't. :( –  Shut up and Calculate Nov 2 '13 at 12:51
@Jubobs Maybe you know a way to import an already finished feynmp figure? What would that code be then? –  Shut up and Calculate Nov 2 '13 at 13:00
\includegraphics?? –  Harish Kumar Nov 2 '13 at 13:18

This works:

\documentclass{beamer}
\usepackage{feynmp-auto}

\mode<presentation> {
\usetheme{Warsaw}
}

\begin{document}

\section{Theory}
\subsection{The diagram}

\begin{frame}[fragile]
\frametitle{the title etc}

\begin{fmffile}{Feynman1}
\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{frame}

\end{document}


Compile twice.

-
Yes! That actually worked, bravo, thank you so much! –  Shut up and Calculate Nov 2 '13 at 13:45
@LoveLearning feynmp-auto is only for convenience: with it instead of feynmp you don't need to run Metapost separately. –  egreg Nov 2 '13 at 13:47
yes I read that in the manual, cool. –  Shut up and Calculate Nov 2 '13 at 13:51

I recently included a feynmp graph in a beamer presentation and it worked. I think I remember having had some trouble with this, but for me including

\DeclareGraphicsRule{*}{mps}{*}{}


in the preamble did the trick. This is also the only obvious difference between our source files. With this you can just use feynmp as usual, where "usual" for me is: compile your code, run metapost on the produced files in a terminal, then recompile. If you already produced the files it might be enough to just recompile.

-
So where do you write this and what do you do next? Do you import your already finished F-diagrams or do you rebuild them with \begin{fmffile}{}...etc? Please be more clear. Thanks! –  Shut up and Calculate Nov 2 '13 at 13:21
I put it in the preamble somewhere after the \usepackage{} stuff... Then I did the normal feynmp procedure (compile, run metapost in the terminal, compile again) and it worked. –  fifaltra Nov 2 '13 at 13:25
Do you use \begin{fmffile}{}..etc later or do you import stuff? In that case what file do you import? –  Shut up and Calculate Nov 2 '13 at 13:26
And yes, \begin{fmffile}{} and all that is still in my code. This is especially important if you have labels, because if you look at the files produced by metapost you won't find any labels there. (I think I tried to just include the file via \includegraphics at first but had to abandon the idea because of the labels) –  fifaltra Nov 2 '13 at 13:29