考虑以下使用 tikz-feynman 包的代码:
\feynmandiagram [baseline={(current bounding box.center)},medium, vertical=b to f] {
a [nudge=(-30:5mm)]
-- [photon, edge label=\(p_{1}\)] b [label=190:\(\mu_{1}\)]
-- [fermion, edge label=\(k+p_{1}\)] c,
d[nudge=(220:5mm)] -- [photon, edge label'=\(p_{2}\)] c [label=-30:\(\mu_{2}\)],
c -- [fermion, edge label=\(k+p_{1}+p_{2}\)] e [label=10:\(\mu_{3}\)] -- [fermion, edge label=\(k-p_{4}\)] f [label=176:\(\mu_{4}\)] -- [ fermion, edge label=\(k\)] b,
g [nudge=(150:5mm)] -- [photon, edge label=\(p_{3}\)] e,
h [nudge=(30:5mm)] -- [photon, edge label'=\(p_{4}\)] f,
};
这给了我们图表
我想修改代码来翻转垂直线以获得下图
同时保持第一张图上的标签完好无损。我该怎么做?
答案1
我已经调整了我制作的示例你问的另一个问题。我没有在这里添加推动以使代码更清晰一些(但您可以轻松地将其添加回来)。
我还擅自清理了图表的创建方式,希望您不介意:)这应该会使它更简单、更容易。
现在,该算法默认会避免线条交叉。因此,要绘制所需的图表,您必须手动指定顶点的位置或分两步完成。我在下面展示了如何分两步完成,并且我在代码中进行了注释以解释各部分的作用。我希望这很清楚,但如果您需要一些说明,请随时发表评论。
\documentclass[tikz,border=10pt]{standalone}
\usepackage[compat=1.1.0]{tikz-feynman}
\begin{document}
\feynmandiagram [
baseline={(current bounding box.center)},
vertical'=a to b,
] {
%% Instead of having to specify `fermion` over and over, group them
%% together.
{[edges={fermion}]
a -- [edge label'=\(k_{1}\)] b [label=0:\(\mu_{2}\)]
-- [edge label'=\(k_{2}\)] c [label=-180:\(\mu_{3}\)]
-- [edge label'=\(k_{3}\)] d [label=-180:\(\mu_{4}\)]
-- [edge label'=\(k_{4}\)] a [label=0:\(\mu_{1}\)],
},
{[edges={photon}]
%% Sometimes, the algorithms gets stuck when trying to figure out the final
%% layout, hence why I'm switching the order of d and c below.
a -- ap [particle=\(p_{1}\)],
b -- bp [particle=\(p_{2}\)],
d -- dp [particle=\(p_{4}\)],
c -- cp [particle=\(p_{3}\)],
},
};
\begin{tikzpicture}[baseline={(current bounding box.center)}]
\begin{feynman}
%% Just like before, we create the internal box of fermion lines, but this
%% time we use `draw=none` so they are invisible.
\diagram [vertical'=a to b] {
{[edges={draw=none}]
a -- b [label=0:\(\mu_{2}\)]
-- c [label=-180:\(\mu_{3}\)]
-- d [label=-180:\(\mu_{4}\)]
-- a [label=0:\(\mu_{1}\)],
},
{[edges={photon}]
%% Sometimes, the algorithms gets stuck when trying to figure out the final
%% layout, hence why I'm switching the order of d and c below.
a -- ap [particle=\(p_{1}\)],
b -- bp [particle=\(p_{2}\)],
d -- dp [particle=\(p_{4}\)],
c -- cp [particle=\(p_{3}\)],
},
};
%% We now need to add in the fermion lines. Since we just want to connect
%% existing vertices, we use the `\diagram*` command. The parentheses are
%% important as it tells the algorithm that these vertices exist already
%% (instead of trying to create new ones).
\diagram* {
(a) -- [fermion] (b)
-- [fermion] (d)
-- [fermion] (c)
-- (a), %% No fermion line hear as it looks weird with the two arrows
%% overlapping.
};
\end{feynman}
\end{tikzpicture}
\end{document}