我正在尝试绘制一个相互作用场论的图表。该图本质上只需要由连接到两条外部线的环路组成。问题是我需要该环路由虚线和实线组成。到目前为止,我已经:
\documentclass{article}
\usepackage{tikz}
\usepackage[compat=1.1.0]{tikz-feynman}
\begin{document}
\feynmandiagram [horizontal=a to b, layered layout] {
a -- [scalar] b [dot] -- [out=125, in=55, loop, min distance=2cm] b -- c,
};
\end{document}
得出
我需要将循环的右半部分变为虚线。这可能吗?
答案1
您可以将另一个叠加dash pattern
在scalar
选项上(相当于dashed
。但是,您需要调整图案才能准确绘制出循环的左半部分:
\documentclass{article}
\usepackage[compat=1.1.0]{tikz-feynman}
\begin{document}
\feynmandiagram [horizontal=a to b, layered layout] {
a -- [scalar] b [dot] -- [out=125, in=55, loop, min distance=2cm, scalar, postaction={draw, dash pattern=on 1.5cm off 1.5cm}] b -- c,
};
\end{document}
也许更优雅的方法是使用装饰来重新绘制循环路径的前半部分:
\documentclass{article}
\usepackage[compat=1.1.0]{tikz-feynman}
\pgfdeclaremetadecoration{draw first half}{initial}{
\state{initial}[width={\pgfmetadecoratedpathlength/2}, next state=final]{
\decoration{curveto}
}
\state{final}{}
}
\begin{document}
\feynmandiagram [horizontal=a to b, layered layout] {
a -- [scalar] b [dot] -- [out=125, in=55, loop, min distance=2cm, scalar, postaction={decorate, draw, decoration={draw first half}}] b -- c,
};
\end{document}
这种方法的变体是在装饰中包含虚线图案:
\documentclass{article}
\usepackage[compat=1.1.0]{tikz-feynman}
\pgfdeclaremetadecoration{half dashed}{initial}{
\state{initial}[width={\pgfmetadecoratedpathlength/2}, next state=final]{
\decoration{curveto}
\afterdecoration{
\pgfusepath{stroke}
}
}
\state{final}{
\beforedecoration{
\pgfsetdash{{3pt}{3pt}}{0pt}
}
\decoration{curveto}
}
}
\begin{document}
\feynmandiagram [horizontal=a to b, layered layout] {
a -- [scalar] b [dot] -- [out=125, in=55, loop, min distance=2cm, decorate, decoration={half dashed}] b -- c,
};
\end{document}
这两个代码片段的输出与上面的相同。
答案2
一个肮脏的(?)伎俩
\pgfpathcurvebetweentime
我最近使用在不同的背景下,但我不想弄乱处理to
整体out
和in
内容的路径。\pgfpathcurvebetweentime
内部使用\pgfpathcurveto
,这就是为什么我们需要立即再次恢复它。这也会绘制两次路径,一次是前半部分,另一次是后半部分,但我们需要在代码中指定两次(这就是为什么我为升哎呀A节点上方)。
与 2 相同,但有自己的
graphs
密钥,可能有助于消除冗余。
代码
\documentclass{article}
\usepackage[compat=1.1.0]{tikz-feynman}
\makeatletter
\let\pgfpathcurveto@orig\pgfpathcurveto
\tikzset{
curve from/.code args={#1 to #2}{%
\let\pgfpathcurveto@orig\pgfpathcurveto
\def\pgfpathcurveto{\let\pgfpathcurveto\pgfpathcurveto@orig
\pgfpathcurvebetweentime{#1}{#2}{\tikz@timer@start}}}}
\makeatother
\begin{document}
\feynmandiagram [horizontal=a to b, layered layout,
la/.style={out=125, in=55, loop, min distance=2cm}]{
a -- [scalar] b [dot]
-- [la, curve from=0 to .5] b
-- [la, curve from=.5 to 1, scalar] b
-- c,
};
\feynmandiagram [horizontal=a to b, layered layout,
la/.style={out=125, in=55, loop, min distance=2cm}][
/tikz/graphs/halfsies/.style n args={6}{% #1 = start, #2 = target,
% #3 = common, #4 = "half"way point, #5 = first half, #6 = second half
parse={#1 -- [#3,curve from=0 to #4, #5] #2;
#1 -- [#3,curve from=#4 to 1, #6] #2;}}]{
a -- [scalar] b [dot] -- c,
{[halfsies=bb{la}{.5}{}{scalar}]};
};
\end{document}
输出
答案3
\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{decorations.pathmorphing}
\usepackage[compat=1.1.0]{tikz-feynman}
\begin{document}
\tikzset{
half dashed/.style={
draw=none,
postaction={draw, dashed, decoration={curveto, post=moveto, post length=1/2*\pgfmetadecoratedpathlength}, decorate},
postaction={draw, decoration={curveto, pre=moveto, pre length=1/2*\pgfmetadecoratedpathlength}, decorate},
},
}
\feynmandiagram [horizontal=a to b, layered layout] {
a -- [scalar] b [dot] -- [out=125, in=55, loop, min distance=2cm, half dashed] b -- c,
};
\end{document}