# Centering Feynman diagrams in equations

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{tikz-feynman}
\begin{document}
\begin{align*}
\feynmandiagram [inline=(b.base), horizontal=f1 to f2, layered layout] {
f1 [particle=$$p$$] -- [fermion] b [blob] -- [fermion] f2 [particle=$$p$$]
};
&=
\vcenter{\hbox{%
\begin{tikzpicture}
\begin{feynman}
\vertex (a1) at (-1,0) {$$p$$};
\vertex (a3) at (1,0) {$$p$$};
\diagram* {
(a1) -- [fermion] (a3),
};
\end{feynman}
\end{tikzpicture}
}}
+
\vcenter{\hbox{%
\begin{tikzpicture}
\begin{feynman}
\vertex (a1) {$$p$$};
\vertex[right=1cm of a1] (a2);
\vertex[right=0.5cm of a2] (a3);
\vertex[right=0.25cm of a3] (a4);
\vertex[right=1cm of a4] (a5) {$$p$$};
\diagram* {
{
(a1) -- [fermion] (a2) -- (a3) --  (a4) -- [fermion] (a5),
},
(a2) -- [photon, out=90, in=90, looseness=2.0] (a4)
};
\end{feynman}
\end{tikzpicture}
}}
\end{align*}
\end{document}


I would like to have the equal and the plus signs vertically aligned with the fermion lines. With the code above I get this:

which is okay for the one in the middle but not for the other two.

• Unrelated but you declare an align* environment and end it with align. Do you really need the align environment or would it be ok to write everything in a single tikzpicture? May 8, 2021 at 9:37
• align instead of align* was a typo. I need the align environment because I have = and + May 8, 2021 at 9:44

Probably the following is closer to the expected output:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usepackage{tikz-feynman}
\begin{document}
\begin{align*}
\feynmandiagram [inline=(f1.base), horizontal=f1 to f2, layered layout] {
f1 [particle=$$p$$] -- [fermion] b [blob] -- [fermion] f2 [particle=$$p$$]
};
&=
\begin{tikzpicture}[baseline=(a1.base)]
\begin{feynman}[inline=(a1.base)]
\vertex (a1) at (-1,0) {$$p$$};
\vertex (a3) at (1,0) {$$p$$};
\diagram* {
(a1) -- [fermion] (a3),
};
\end{feynman}
\end{tikzpicture}
+
\begin{tikzpicture}[baseline=(a1.base)]
\begin{feynman}[inline=a1.base)]
\vertex (a1) {$$p$$};
\vertex[right=1cm of a1] (a2);
\vertex[right=0.5cm of a2] (a3);
\vertex[right=0.25cm of a3] (a4);
\vertex[right=1cm of a4] (a5) {$$p$$};
\diagram* {
{
(a1) -- [fermion] (a2) -- (a3) --  (a4) -- [fermion] (a5),
},
(a2) -- [photon, out=90, in=90, looseness=2.0] (a4)
};
\end{feynman}
\end{tikzpicture}
\end{align*}
\end{document}

• Much better, thank you! What's the difference between baseline and inline? May 8, 2021 at 9:54

I, on the other hand, took a different path from the competent user @leandriis. In fact I have used feyn package, off-topic, with the tag, even if the language used is cryptic, you can create a more restricted code. I remind you that feyn package is its own package created to create equations with Feynmann diagrams.

\documentclass[a4paper,12pt]{article}
\usepackage{feyn}
\begin{document}
\begin{eqnarray}
p\,\feyn{fsafspfsafs}\,p &=& p\,\feyn{faf}\,p + p\,\feyn{{fA}fglf{fA}}\,p
\end{eqnarray}
\end{document}


PS: Look the arrows and the alignment with + and =.