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.

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?

share|improve this question
    
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? –  Love Learning 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. :( –  Love Learning 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? –  Love Learning Nov 2 '13 at 13:00
1  
\includegraphics?? –  Harish Kumar Nov 2 '13 at 13:18

2 Answers 2

up vote 3 down vote accepted

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.

enter image description here

share|improve this answer
    
Yes! That actually worked, bravo, thank you so much! –  Love Learning Nov 2 '13 at 13:45
1  
@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. –  Love Learning 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.

share|improve this answer
    
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! –  Love Learning 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? –  Love Learning 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

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.