# Large space between Feynman loop diagram in tikz picture and the caption

I'm trying to put two Feynman diagrams side-by-side, but the 3-point loop diagram will not be aligned with 4-point loop diagram correctly whatever I do! Here is my code

\begin{center}
\begin{figure}[H]
\begin{tikzpicture}
\begin{feynman}
\feynmandiagram [layered layout, horizontal=b to c] {
a -- [scalar, edge label = $H$] b [dot,black]
-- [fermion, half left,edge label = $f$] c [dot,black]
-- [fermion, half left,edge label = $\bar{f}$] b,
c -- [scalar,  edge label = $H$ ] d,
};
\end{feynman}
\end{tikzpicture}
\setlength{\belowcaptionskip}{0cm}
\hspace{3.4cm}
\centering
\begin{tikzpicture}
\begin{feynman}
\feynmandiagram [layered layout, horizontal=b to c] {
a -- [scalar, edge label = $H$] b [dot,blue]
-- [scalar, min distance=3cm, edge label = $\phi_i$] b
-- [scalar,  edge label = $H$ ] c,
};
\end{feynman}
\end{tikzpicture}
\captionof{figure}{Higgs self-energy diagram}
\end{figure}

• Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See minimal working example (MWE). Commented Oct 1, 2017 at 5:32

The easiest is to put them in the same tikzpicture, and use \diagram [xshift=5cm .. for the second one. If you want to move the second one down, add ,yshift=-1cm after the xshift.

• \feynmandiagram starts its own tikzpicture environment, so don't use it inside a tikzpicture. Either use

\feynmandiagram ...


or use

\begin{tikzpicture}
\begin{feynman}
\diagram ...
\end{feynman}
\end{tikzpicture}

• Having \begin{center} .. \end{center} outside a figure environment is actually rather unhelpful. It doesn't center the figure, it adds additional vertical space, and with any other float specifier than H the figure will likely float outside it. Instead, put \centering right after \begin{figure}

• Using \captionof{figure}{..} isn't necessary when you are inside a figure environment, then \caption{..} is enough.

\documentclass{article}
\usepackage{tikz-feynman}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}
\begin{feynman}
\diagram [layered layout, horizontal=b to c] {
a -- [scalar, edge label = $H$] b [dot,black]
-- [fermion, half left,edge label = $f$] c [dot,black]
-- [fermion, half left,edge label = $\bar{f}$] b,
c -- [scalar,  edge label = $H$ ] d,
};

\diagram [xshift=5cm,layered layout, horizontal=b to c] {
a -- [scalar, edge label = $H$] b [dot,blue]
-- [scalar, min distance=3cm, edge label = $\phi_i$] b
-- [scalar,  edge label = $H$ ] c,
};
\end{feynman}
\end{tikzpicture}
\caption{Higgs self-energy diagram}
\end{figure}
\end{document}


# Separate captions

To get separate captions, use two \feynmandiagrams. For subcaptions, load the subcaption package and place each \feynmandiagram in a subfigure environment as in the example below.

If you don't want subcaptions, use basically exactly the same syntax, but replace subfigure with minipage.

\documentclass{article}
\usepackage{tikz-feynman}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\centering

\begin{subfigure}[t]{0.45\linewidth}
\centering
\feynmandiagram [layered layout, horizontal=b to c] {
a -- [scalar, edge label = $H$] b [dot,black]
-- [fermion, half left,edge label = $f$] c [dot,black]
-- [fermion, half left,edge label = $\bar{f}$] b,
c -- [scalar,  edge label = $H$ ] d,
};
\caption{Something}
\end{subfigure}
\begin{subfigure}[t]{0.45\linewidth}
\centering

\feynmandiagram [layered layout, horizontal=b to c] {
a -- [scalar, edge label = $H$] b [dot,blue]
-- [scalar, min distance=3cm, edge label = $\phi_i$] b
-- [scalar,  edge label = $H$ ] c,
};
\caption{Something else}
\end{subfigure}
\caption{Higgs self-energy diagram}
\end{figure}

\begin{figure}
\centering

\begin{minipage}[t]{0.45\linewidth}
\centering
\feynmandiagram [layered layout, horizontal=b to c] {
a -- [scalar, edge label = $H$] b [dot,black]
-- [fermion, half left,edge label = $f$] c [dot,black]
-- [fermion, half left,edge label = $\bar{f}$] b,
c -- [scalar,  edge label = $H$ ] d,
};
\caption{Something}
\end{minipage}
\begin{minipage}[t]{0.45\linewidth}
\centering

\feynmandiagram [layered layout, horizontal=b to c] {
a -- [scalar, edge label = $H$] b [dot,blue]
-- [scalar, min distance=3cm, edge label = $\phi_i$] b
-- [scalar,  edge label = $H$ ] c,
};
\caption{Something else}
\end{minipage}
\end{figure}
\end{document}

• Thanks Torbjørn T. for your answer and explanation. I appreciate it. I was also wondering if there is anyway to put caption for each diagrams! Commented Oct 1, 2017 at 19:01
• @JoydeepRoy Subcaptions (Fig 1a and 1b) or not (Fig 1 and 2)? Commented Oct 1, 2017 at 19:02
• @JoydeepRoy Answer updated. Commented Oct 1, 2017 at 19:14
• T Thanks a ton for your help. I really appreciate it. Commented Oct 5, 2017 at 5:25