[Tex/LaTex] Feynmp graphs as standalone pdfs

feynmanfeynmffeynmp-auto

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

Best Answer

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}
Related Question