1

The way I normally handle Feynman diagrams is just to include \usepackage{feynmf-auto} and to write the whole fmffile code int he main tex file.

However, I saw that some people manage to create a separate tex file for each graph, and to somehow produce a pdf-picture of that graph. Later they embed these pdf-pictures into the main file using includegraphics.

My question is how to produce these standalone pdfs with feynman graphs using feynmp?

Consider for example the following code

\documentclass[10pt]{article}
\usepackage[usenames]{color} %used for font color
\usepackage{amssymb} %maths
\usepackage{amsmath} %maths
\usepackage[utf8]{inputenc} %useful to type directly diacritic characters
\usepackage{feynmp} %Feynman diagrams
\begin{document}
\begin{align*}\begin{fmffile}{feyngraph}
  \begin{fmfgraph*}(110,80)
    \fmfleft{l1,l2}
    \fmfright{r1}
    \fmf{fermion,label=$k_1$}{l2,v1}
    \fmf{fermion,label=$k_2$}{v1,l1}
    \fmflabel{$j$}{l1}
    \fmflabel{$i$}{l2}
    \fmf{photon,label=$k_3$}{v1,r1}
    \fmflabel{$b, \mu$}{r1}
  \end{fmfgraph*}
\end{fmffile}
\end{align*}
\end{document}

Somehow this gets converted into a picture with only the diagram, but if I try to compile it, I get an A4 page with the graph at the bottom

  • 2
    When I compile your code I have an empty pdf with no errors. With that said, is it possible to use \documentclass[10pt]{standalone}? – Pouya Jun 10 '15 at 13:01
  • 3
    If I replace article with standalone, load feynmp-auto instead of feynmp and remove the align* environment, I get what seems to be the expected result (after the second LaTeX run, of course). – egreg Jun 10 '15 at 14:18
2

Comments to this post helped me to come up with this template for producing standalone feynmf graphs

\RequirePackage[l2tabu, orthodox]{nag} % Issues warnings if deprecated packages are used
\documentclass{standalone}

% my standard packages
\usepackage{mathtools,amsfonts}
\usepackage{xcolor}
\usepackage[UKenglish]{babel}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{microtype}

\usepackage{feynmp-auto}

\newcommand{\fmfinclude}{%
% new style definitions come here
}

% commas in feynmp sometimes lead to strange errors, use \comma instead
\DeclareMathSymbol{\comma}{\mathpunct}{letters}{"3B}

\begin{document}
\begin{fmffile}{fmf_temp_file}
\fmfframe(5,20)(10,15){% adjust the padding here to avoid labels being out of bounds
\begin{fmfgraph*}(100,100)
% the actual graph
\end{fmfgraph*}
}
\end{fmffile}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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