我正在尝试使用 TikZ 绘制一些费曼图,但似乎遇到了麻烦,因为父级的箭头也应用于子级,导致一条线上有两个箭头。(我一直在使用示例这里作为我自己创作的基础)
这是我的输出(我知道这个图不正确):
如您所见,位置线有两个重叠的箭头,似乎只有箭头是继承的。
代码:
\documentclass[10pt]{revtex4-1}
\usepackage{tikz}
\begin{document}
\usetikzlibrary{decorations.pathmorphing,decorations.markings,trees,positioning,arrows}
\tikzset{
photon/.style={,decorate, decoration={snake}, draw=red},
particle/.style={,draw=blue, postaction={decorate},
decoration={markings,mark=at position 0.5 with {\arrow[draw=blue]{>}}}},
antiparticle/.style={,draw=blue, postaction={decorate},
decoration={markings,mark=at position 0.5 with {\arrow[draw=blue]{<}}}},
gluon/.style={,decorate, draw=black,
decoration={snake,amplitude=4pt, segment length=5pt}}
}
\begin{tikzpicture}[
thick,
level/.style={level distance=2cm},
level 2/.style={sibling distance=2cm},
]
\begin{scope}
\node{}
child[grow=right]{
edge from parent [particle]
child []{
edge from parent [photon]
node [above=2pt, anchor=south,shift={(0.2,0)}] {$\gamma$};
}
child[] {
edge from parent [antiparticle]
node [above=2pt, anchor=south] {$e^+$};
}
node [above=3pt](gam) {$e^-$}
};
\end{scope}
\end{tikzpicture}
\end{document}
答案1
在每个样式的decoration
对应部分中包含每个选项:postaction
\documentclass[10pt]{revtex4-1}
\usepackage{tikz}
\begin{document}
\usetikzlibrary{decorations.pathmorphing,decorations.markings,trees,positioning,arrows}
\tikzset{
photon/.style={decorate, decoration={snake}, draw=red},
particle/.style={draw=blue,postaction={decorate,
decoration={markings,mark=at position 0.5 with {\arrow[draw=blue]{>}}}}},
antiparticle/.style={draw=blue,postaction={decorate,
decoration={markings,mark=at position 0.5 with {\arrow[draw=blue]{<}}}}},
gluon/.style={decorate, draw=black,
decoration={snake,amplitude=4pt, segment length=5pt}}
}
\begin{tikzpicture}[
thick,
level/.style={level distance=2cm},
level 2/.style={sibling distance=2cm},
]
\begin{scope}
\node{}
child[grow=right]{
edge from parent [particle]
child []{
edge from parent [photon]
node [above=2pt, anchor=south,shift={(0.2,0)}] {$\gamma$};
}
child[] {
edge from parent [antiparticle]
node [above=2pt, anchor=south] {$e^+$};
}
node [above=3pt](gam) {$e^-$}
};
\end{scope}
\end{tikzpicture}
\end{document}
答案2
对 Claudio Fiandrino 给出的解决方案仅作两点补充/评论:
如果装饰箭头的颜色与装饰线的颜色相同,则无需定义箭头的颜色,即只需
\arrow[draw=blue] {>}
说即可\arrow{>}
。对于与线(边)方向相反的箭头,您也可以使用
\arrowreversed{>}
。如果您想声明箭头的尖端(例如\arrowreversed{latex}
,等等),这很方便。