我使用了以下代码的变体,以便使用以下答案在 latex 中创建类似费曼的图表 使用 TikZ 绘制散射费曼图 但是,我想将图表包裹在圆形或椭圆形内?有人能建议我该怎么做吗?
\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{decorations.markings}
\begin{document}
\tikzset{
particle/.style={thick,draw=blue, postaction={decorate},
decoration={markings,mark=at position .5 with {\arrow[blue]{triangle 45}}}},
gluon/.style={decorate, draw=black,
decoration={coil,aspect=0}}
}
\begin{tikzpicture}[node distance=1cm and 1.5cm]
\coordinate[label=left:$e^{-}$] (e1);
\coordinate[below right=of e1] (aux1);
\coordinate[above right=of aux1,label=right:$e^{-}$] (e2);
\coordinate[below=1.25cm of aux1] (aux2);
\coordinate[below left=of aux2,label=left:$e^{-}$] (e3);
\coordinate[below right=of aux2,label=right:$e^{-}$] (e4);
\draw[particle] (e1) -- (aux1);
\draw[particle] (aux1) -- (e2);
\draw[particle] (e3) -- (aux2);
\draw[particle] (aux2) -- (e4);
\draw[gluon] (aux1) -- node[label=right:$\gamma$] {} (aux2);
\end{tikzpicture}
\end{document}
答案1
一种选择是使用fit
库;要使用椭圆,您还需要该shapes
库:
\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows,fit}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{decorations.markings}
\begin{document}
\tikzset{
particle/.style={thick,draw=blue, postaction={decorate},
decoration={markings,mark=at position .5 with {\arrow[blue]{triangle 45}}}},
gluon/.style={decorate, draw=black,
decoration={coil,aspect=0}}
}
\begin{tikzpicture}[node distance=1cm and 1.5cm]
\coordinate[label={[xshift=-3pt]left:$e^{-}$}] (e1);
\coordinate[below right=of e1] (aux1);
\coordinate[above right=of aux1,label={[xshift=6pt]right:$e^{-}$}] (e2);
\coordinate[below=1.25cm of aux1] (aux2);
\coordinate[below left=of aux2,label={[xshift=-6pt]left:$e^{-}$}] (e3);
\coordinate[below right=of aux2,label={[xshift=3pt]right:$e^{-}$}] (e4);
\draw[particle] (e1) -- (aux1);
\draw[particle] (aux1) -- (e2);
\draw[particle] (e3) -- (aux2);
\draw[particle] (aux2) -- (e4);
\draw[gluon] (aux1) -- node[label=right:$\gamma$] {} (aux2);
\node[draw,line width=3pt,circle,fit=(e1) (e4),inner sep=.5\pgflinewidth] {};
\end{tikzpicture}
\end{document}
除了ultra thick
,您还可以使用thick
或 ,line width=<length>
以实现更精细的控制:
\node[draw,line width=3pt,circle,fit=(e1) (e4),inner sep=0pt] {};
评论中提出了新的请求:
...“分解”内部胶子。换句话说,我想将内部的胶子线分成两条直线,两条直线都在同一点(可以是左边也可以是右边,但要好看)与圆接触。
在这种情况下,可以使用交叉点库来定位圆与水平直径的交点,然后使用这个新点来绘制附加线:
\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,arrows,fit,intersections,decorations.pathmorphing,decorations.markings}
\begin{document}
\tikzset{
particle/.style={thick,draw=blue, postaction={decorate},
decoration={markings,mark=at position .5 with {\arrow[blue]{triangle 45}}}},
gluon/.style={decorate, draw=black,
decoration={coil,aspect=0}}
}
\begin{tikzpicture}[node distance=1cm and 1.5cm]
\coordinate[label={[xshift=-3pt]left:$e^{-}$}] (e1);
\coordinate[below right=of e1] (aux1);
\coordinate[above right=of aux1,label={[xshift=6pt]right:$e^{-}$}] (e2);
\coordinate[below=1.25cm of aux1] (aux2);
\coordinate[below left=of aux2,label={[xshift=-6pt]left:$e^{-}$}] (e3);
\coordinate[below right=of aux2,label={[xshift=3pt]right:$e^{-}$}] (e4);
\draw[particle] (e1) -- (aux1);
\draw[particle] (aux1) -- (e2);
\draw[particle] (e3) -- (aux2);
\draw[particle] (aux2) -- (e4);
\draw[gluon] (aux1) -- node[label=right:$\gamma$] {} (aux2);
\node[draw,name path=circle,line width=3pt,circle,fit=(e1) (e4),inner sep=.5\pgflinewidth] {};
\path[name path=diameter] let \p1=(aux1), \p2=(aux2)
in (aux1|-0,0.5*\y2+0.5*\y1) -- ++(-3cm,0);% horizontal line from the center to the left
\path[name intersections={of=circle and diameter, by={aux3}}];% find the intersection
\draw[particle] (aux2) -- (aux3);
\draw[particle] (aux3) -- (aux1);
\node[label={[xshift=3pt]left:$m$}] at (aux3) {};
\end{tikzpicture}
\end{document}
答案2
使用新的tikz-feynman
包(另请参阅项目页面), 基于这个答案。使用自动定位顶点的唯一要求是使用以下内容编译文档lualatex
:
\documentclass[tikz]{standalone}
\usepackage[compat=1.1.0]{tikz-feynman}
\tikzfeynmanset{
every fermion={blue},
every anti fermion={blue},
}
\begin{document}
\begin{tikzpicture}
\begin{feynman}
\diagram [vertical=b to a]{
i1 [particle=\(\textup{e}^{-}\)] -- [fermion] a,
i2 [particle=\(\textup{e}^{-}\)] -- [anti fermion] a,
a -- [photon,edge label'=\(\gamma\)] b,
b -- [anti fermion] f1 [particle=\(\textup{e}^{-}\)],
b -- [fermion] f2 [particle=\(\textup{e}^{-}\)],
};
\draw[red,thick] ($(a)!0.5!(b)$) circle (1.85);
\end{feynman}
\end{tikzpicture}
\end{document}