我需要用 tikz 生成以下内容:
我已经写了:
\documentclass[border=3mm, varwidth=141mm]{standalone}
\usepackage{tikz-feynman}
\begin{document}
\begin{tikzpicture}[baseline]
\begin{feynman}
\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) {};
\diagram*{
(a) -- [photon,color=red] (m)
-- [photon,color=red] (c),
};
\end{feynman}
\end{tikzpicture}
\end{document}
这使:
有几个问题。fill = white 无法使矩形内部变成白色。另外,我无法使红线水平并删除框的右边缘。
任何帮助都值得赞赏。ti
答案1
\documentclass[border=3mm, varwidth=141mm]{standalone}
\usepackage{tikz-feynman}
\usetikzlibrary{positioning}
\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[rectangle, minimum size=1cm] (m) {};
\draw[semithick] (m.north east) -| (m.south west) -- (m.south east);
%
\vertex (a) [left=of m.north west] {};
\vertex (b) [left=of m.south west] {};
\diagram*{
(a) -- [photon,color=red] (m.north west),
(b) -- [photon,color=red] (m.south west),
};
\end{feynman}
\end{tikzpicture}
\end{document}
通过将第二个费曼图的代码与您的代码进行比较,您应该观察到:
- 矩形的代码应该是
\node[rectangle, draw, minimum size=1cm] (m) {};
,即您应该\rule
从节点内容中删除,删除fill=black
,并在选项中添加节点大小(minimum size=1c
)和命令“绘制”。 - 线条
photon
是直线,您需要相应地设置顶点的坐标。在 MWE 中,我使用相对定位left=of m.north west
和left=of m.south west
- 线
photon
是直线,从(a)
到(m.north west)
等画出。参见 MWE。