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
.
Some comments:
\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 \feynmandiagram
s. 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}