Without knowing anything about the feynmp
or METAPOST, I removed the fbox
and I just tried to put everyting in a TikZ node. Then I did the centering with respect to the baseline of the bounding box of the tikzpicture
and the result is centered. So remaining question is, How robust is this?, and I have no clue. But seemingly, there is no bad box complaints etc. I regret that it's up to you and other proficient METAPOST users to test and try to break this.
\documentclass{article}
\usepackage{feynmp,tikz}
% Needed to interpret generated *.1, *.2 etc. as ps files.
\DeclareGraphicsRule{*}{mps}{*}{}
\setlength{\fboxsep}{0pt}
\begin{document}
To populate this line and to see how far is the equation spacing.
\begin{fmffile}{fgraphs}
\begin{equation}
5\times
\begin{tikzpicture}[baseline=(current bounding box.center)]
\node {
\fmfframe(5,17)(20,17){ % 2: Had to manually guess these.
\begin{fmfgraph*}(40,30)
% Note that the size is given in normal parentheses
% instead of curly brackets in units of \unitlength
% (1pt by default)
\fmfleft{i1,i2} % Define external vertices from bottom to top
\fmfright{o1,o2}
\fmf{fermion}{i1,v1,o1}
\fmf{fermion}{i2,v2,o2}
\fmf{photon,tension=0.3}{v1,v2}
% 3: Blank lines not allowed in fmfframe!
\fmflabel{$\vec{p}$}{i1}
\fmflabel{$\vec{q}$}{i2}
\fmflabel{$\vec{p}+\vec{k}$}{o1}
\fmflabel{$\vec{p}-\vec{k}$}{o2}
\end{fmfgraph*}
}
};
\end{tikzpicture}
= 5i V_k.
\end{equation}
\end{fmffile}
\end{document}
Because I don't know anything I can also try stupid things such as putting the fmffile
environment completely inside the node in other words, nest it inside the tikzpicture
. And that gives the same result. But I feel that the second one is more robust.
Coming back to the manual guessing of the parameters of the \fmfframe
, I can see that if you omit the manually set lines, the bounding box only covers the drawing but not the p,q,p+k
etc. vectors. Hence I just put a invisible rectangle to set the bounding box enlarged by 2.5ex
. Not a wonderful solution but gives you at least a prediction power how much is left out. So I just chose to have 2.5ex
since I know that only a letter with an arrow is sticking out.
\documentclass{article}
\usepackage{feynmp,tikz}
% Needed to interpret generated *.1, *.2 etc. as ps files.
\DeclareGraphicsRule{*}{mps}{*}{}
\begin{document}
To populate this line and to see how far is the equation spacing.
\begin{equation}
5\times
\begin{tikzpicture}[baseline=(current bounding box.center)]
\node {\begin{fmffile}{fgraphs}
\begin{fmfgraph*}(40,30)
\fmfleft{i1,i2} % Define external vertices from bottom to top
\fmfright{o1,o2}
\fmf{fermion}{i1,v1,o1}
\fmf{fermion}{i2,v2,o2}
\fmf{photon,tension=0.3}{v1,v2}
%
\fmflabel{$\vec{p}$}{i1}
\fmflabel{$\vec{q}$}{i2}
\fmflabel{$\vec{p}+\vec{k}$}{o1}
\fmflabel{$\vec{p}-\vec{k}$}{o2}
\end{fmfgraph*}
\end{fmffile}
};
\path[use as bounding box] ([shift={(2.5ex,2.5ex)}]current bounding box.north east) rectangle ([shift={(-2.5ex,-2.5ex)}]current bounding box.south west);
\end{tikzpicture}
= 5i V_k.
\end{equation}
Same thing here... To populate this line and protect it at all costs. Now fmffile is inside the TikZ picture...
\end{document}
As you can see from the image below, I forgot to take into account the horizontal effect so the equal sign is a little to the left than where it should have been. If there is a handle on the bounding box of the Feynman drawing, TikZ can do centering and all other fancy things with ease. Otherwise at least you don't have to recompile the Feynman drawing since the bounding box computation is now on TikZ side and easier to tune since you only add extra shifts instead of hard coding numbers.
The syntax of the fmffile
environment is
\begin{fmffile}{<filename>}
so with your code the file name is fmfile
and LaTeX doesn't know what to do with {simple_tree}
and so tries to typeset it.
The file name is that of the output Metapost file; if you want to call it simple_tree
, say
\begin{fmffile}{simple_tree}
There's an error also in the following line, which should be
\begin{fmfgraph}(50,35)
with parentheses rather than braces.
Finally, \end{fmfgraph}
is missing. Correct code:
\documentclass{article}
\usepackage{feynmp}
\begin{document}
\setlength{\unitlength}{1mm}
% determine the unit for the size of diagram.
\begin{fmffile}{simple_tree}
\begin{fmfgraph}(50,35)
\fmfleft{i1,i2}
\fmfright{o1,o2,o3,o4,o5,o6,o7,o8,o9,o10,o11}
\fmf{fermion}{i1,v1,o1}
\fmf{gluon}{v1,v2}
\fmf{fermion}{o2,v2,v3}
\fmf{fermion}{v3,v4,v5,o3}
\fmf{fermion}{v5,v6}
\fmf{fermion}{o4,o5}
\end{fmfgraph}
\end{fmffile}
\end{document}
Note
Compiling this with Metapost gives errors:
feynmf: warning: dangling vertex `v6' colliding with `v5'.
feynmf: Have you seen the warning messages above?
They are usually caused by misspelling a vertex'
name and can trigger errors further below!
Fix the typos and run LaTeX and Metafont again.
Fix the code before trying.
Suggestion
If you have an up-to-date TeX distribution you can change
\usepackage{feynmp}
into
\usepackage{feynmp-auto}
that will take care of the Metapost run (two LaTeX runs are necessary anyway if the code in the fmffile
environment is changed).
Best Answer
Use the starred form
\begin{fmfgraph*}
.