我正在尝试使用 tikz 生成以下内容:
我已经写了:
\documentclass[border=3mm, varwidth=141mm]{standalone}
\usepackage{tikz-feynman}
\begin{document}
\begin{tikzpicture}[baseline]
\begin{feynman}
\node[] (m) at ( 0, 0) {};
\vertex (a) at ( 225:2cm) {};% <<< changed y-coordinate
\vertex (b) at ( -45:2cm) {};%<<< switched to polar: -60 deg, 1 cm radius
\vertex (c) at (135:2cm) {};
\vertex (d) at (45:2cm) {};
\diagram* {
(a) -- [photon,color=red] (m) % <<< funny bend
-- [photon,color=red] (c),
(b) -- [plain] (m) %<<< some color
-- [plain] (d),
};
\end{feynman}
\end{tikzpicture}
+
\begin{tikzpicture}[baseline]
\begin{feynman}
%\node[shape=circle,draw=black,inner sep=0pt,minimum size=20pt] (m) at (0, 0) {};
\node[shape=rectangle,fill=black,draw=black] (m) at (0, 0) {\rule{0.5cm}{0.5cm}};
\vertex (a) at (225:2cm) {};
\vertex (b) at (-45:2cm) {};
\vertex (c) at (135:2cm) {};
\vertex (d) at (45:2cm) {};
%\vertex (e) at ($(n) + (-45:2cm)$) {};
%\vertex (f) at ($(n) + (45:2cm)$) {};
\diagram*{
(a) -- [photon,color=red] (m)
-- [photon,color=red] (c),
%(n) -- [bend left=45, edge label=$\pi^-(K^-)$] (m)
% -- [bend left=45, edge label=$\pi^+(K^+)$] (n),
%(e) -- (n) -- (f),
};
\end{feynman}
\end{tikzpicture}
\end{document}
这使:
我有两个问题:
在我左侧的图中,线条没有交叉。
在我的右侧图中,我无法使红线变为水平,也无法使框内部变为白色(填充 = 白色不起作用),也无法删除框的右边缘。
任何帮助是极大的赞赏。
答案1
不要定义节点\node[] (m) at ( 0, 0) {};
而是定义\coordinate (m);
\documentclass[border=3mm, varwidth=141mm]{standalone}
\usepackage{tikz-feynman}
\begin{document}
\begin{tikzpicture}[baseline]
\begin{feynman}
\coordinate (m);
\vertex (a) at ( 225:2cm) {};% <<< changed y-coordinate
\vertex (b) at ( -45:2cm) {};%<<< switched to polar: -60 deg, 1 cm radius
\vertex (c) at (135:2cm) {};
\vertex (d) at (45:2cm) {};
\diagram* {
(a) -- [photon,color=red] (m) % <<< funny bend
-- [photon,color=red] (c),
(b) -- [plain] (m) %<<< some color
-- [plain] (d),
};
\end{feynman}
\end{tikzpicture}
+
\begin{tikzpicture}[baseline]
\begin{feynman}
%\node[shape=circle,draw=black,inner sep=0pt,minimum size=20pt] (m) at (0, 0) {};
\node[shape=rectangle,fill=black,draw=black] (m) at (0, 0) {\rule{0.5cm}{0.5cm}};
\vertex (a) at (225:2cm) {};
\vertex (b) at (-45:2cm) {};
\vertex (c) at (135:2cm) {};
\vertex (d) at (45:2cm) {};
%\vertex (e) at ($(n) + (-45:2cm)$) {};
%\vertex (f) at ($(n) + (45:2cm)$) {};
\diagram*{
(a) -- [photon,color=red] (m)
-- [photon,color=red] (c),
%(n) -- [bend left=45, edge label=$\pi^-(K^-)$] (m)
% -- [bend left=45, edge label=$\pi^+(K^+)$] (n),
%(e) -- (n) -- (f),
};
\end{feynman}
\end{tikzpicture}
\end{document}