![使用“tikz-feynman”时为“feynman”环境中的所有元素设置颜色](https://linux22.com/image/460761/%E4%BD%BF%E7%94%A8%E2%80%9Ctikz-feynman%E2%80%9D%E6%97%B6%E4%B8%BA%E2%80%9Cfeynman%E2%80%9D%E7%8E%AF%E5%A2%83%E4%B8%AD%E7%9A%84%E6%89%80%E6%9C%89%E5%85%83%E7%B4%A0%E8%AE%BE%E7%BD%AE%E9%A2%9C%E8%89%B2.png)
我正在尝试绘制一组颜色编码的费曼图。如果我为整个tikzpicture
环境设置颜色,一切都会顺利。但是,如果我将颜色传递给环境feynman
,似乎没有任何效果。我也尝试过传递/tikz/<color>
,以及使用/tikzfeynman/every vertex={<color>}
语法,但都无济于事。
根据feynman-tikz
文档,将选项传递给\begin{feynman}
应该与将选项传递给 相同\begin{scope}
:
传入的选项
〈options〉
适用于整个环境,其方式与{scope}
TikZ 中的环境工作方式相同。
梅威瑟:
\documentclass[]{standalone}
\usepackage{tikz}
\usepackage{tikz-feynman}
\begin{document}
\begin{tikzpicture}[baseline=(Abase),scale=0.85,transform shape]
\useasboundingbox (-0.25,-0.25) rectangle (2.75,2.25);
\coordinate (base) at (-0.5,1);
\draw[help lines] (0,0) grid[step=0.25] (2.5,2);
\begin{feynman}[blue] %% <---- this diagram should be blue
\coordinate [right=1.5 of base] (Abase);
\vertex [on grid,below=1 of Abase] (Ai1);
\vertex [on grid,above=1 of Abase] (Ao1);
\vertex [on grid,below=1/3 of Abase, dot] (Av1) {};
\vertex [on grid,above=1/3 of Abase, dot] (Av2) {};
\vertex [on grid,left=1/3 of Abase] (Avp);
\vertex [on grid,left=1 of Abase] (Ap1);
\diagram*[small,horizontal=Ai1 to Ai2]{
(Ai1) -- (Av1) -- (Av2) -- (Ao1),
(Av1) -- [scalar, quarter left] (Avp) -- [scalar, quarter left] (Av2),
(Ap1) -- [photon] (Avp),
};
\end{feynman}
\begin{feynman}[red] %% <---- this diagram should be red
\coordinate [right=1.5 of Abase] (Dbase);
\vertex [on grid,below=1 of Dbase] (Di1);
\vertex [on grid,above=1 of Dbase] (Do1);
\vertex [on grid,below=1/3 of Dbase, dot] (Dv1) {};
\vertex [on grid,above=1/3 of Dbase, dot] (Dv2) {};
\vertex [on grid,left=1/3 of Dbase] (Dvp);
\vertex [on grid,left=1 of Dbase] (Dp1);
\diagram*[small,horizontal=Di1 to Di2]{
(Di1) -- (Dv1) -- (Dv2) -- (Do1),
(Dv1) -- [scalar, quarter left] (Dvp) -- [scalar, quarter left] (Dv2),
(Dp1) -- [photon] (Dvp),
};
\end{feynman}
\end{tikzpicture}
\end{document}