Tikzfeynman 中的全局集合插入样式

Tikzfeynman 中的全局集合插入样式

如何使用全局设置插入样式tikzfeynmanset

我试过

\tikzfeynmanset{
    every insertion/.style={
        /insertion/style={thick},
    },
}

但它不起作用。

梅威瑟:

我期望的效果是这样的:

\documentclass{standalone}
\usepackage{tikz-feynman}
\begin{document}
\begin{tikzpicture}[baseline=($(a)!0.5!(b)$)]
    \begin{feynman}
        \vertex (a);
        \vertex[right=1cm of a] (b);
        \diagram*{ (a) --[insertion={[style=thick]0.5}] (b);};
    \end{feynman}
\end{tikzpicture}
\end{document}

这是我期望的代码,无需style=thick在每次出现时添加insertion

\documentclass{standalone}
\usepackage{tikz-feynman}
\tikzfeynmanset{
    every insertion/.style={
        /insertion/style={thick},
    },
}
\begin{document}
\begin{tikzpicture}[baseline=($(a)!0.5!(b)$)]
    \begin{feynman}
        \vertex (a);
        \vertex[right=1cm of a] (b);
        \diagram*{ (a) --[insertion=0.5] (b);};
    \end{feynman}
\end{tikzpicture}
\end{document}

但它不起作用。

答案1

我认为没有预定义的方法可以做到这一点,但如果你愿意稍微重新定义风格insertion@@,你可以这样做

\documentclass{standalone}
\usepackage{tikz-feynman}
\makeatletter
\tikzfeynmanset{  insertion@@/.style args={[#1]#2}{
    /tikz/decoration={
      markings,
      mark=at position #2 with {
        \tikzfeynmanset{insertion/.cd,#1}
        \draw [/tikzfeynman/every insertion,\tikzfeynman@insertion@style] (-\tikzfeynman@insertion@size, -\tikzfeynman@insertion@size) -- (\tikzfeynman@insertion@size, \tikzfeynman@insertion@size);
        \draw [/tikzfeynman/every insertion,\tikzfeynman@insertion@style] (-\tikzfeynman@insertion@size, \tikzfeynman@insertion@size) -- (\tikzfeynman@insertion@size, -\tikzfeynman@insertion@size);
      },
    },
    /tikz/postaction={
      /tikz/decorate=true,
    }  
}}
\makeatother    

\begin{document}
\tikzfeynmanset{every insertion/.style={thick,red}}
\begin{tikzpicture}[baseline=($(a)!0.5!(b)$)]
    \begin{feynman}
        \vertex (a);
        \vertex[right=1cm of a] (b);
        \diagram*{ (a) --[insertion={0.5}] (b);};
    \end{feynman}
\end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容