2

How can I change the edges' arrow style? For example with a fermion line:

\RequirePackage{luatex85}
\documentclass[tikz]{standalone}
\usepackage{tikz-feynman}
\begin{document}
\tikzfeynmanset{ fermion/.style = {???} }
\begin{tikzpicture}
\begin{feynman}
    \vertex (a);
    \vertex [right of a] (b);
    \diagram*{ (a) -- [fermion](b) };
\end{feynman}
\end{tikzpicture}
\end{document}
1
  • 2
    While code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. This is especially important for tikz as there are numerous libraries May 5, 2017 at 11:16

3 Answers 3

3

Internally, TikZ-Feynman (CTAN) does not use 'arrows' in the sense of the 'arrows' library from TikZ; instead, it decorates the path using a triangle:

/tikz/decoration={
  markings,
  mark=at position 0.5 with {
    \node[
      transform shape,
      xshift=-0.5mm,
      fill,
      inner sep=〈some distance〉,
      draw=none,
      isosceles triangle
    ] { };
  },
},
/tikz/decorate=true,

In particular, you can change the shape from isosceles triangle to whatever you want. Alternatively, it is also possible to use the \arrow command within the decoration (refer to the TikZ manual for the exact details).

I have illustrated two cases below.

\RequirePackage{luatex85}
\documentclass[tikz, border=10pt]{standalone}

\usepackage[compat=1.1.0]{tikz-feynman}

\tikzfeynmanset{
  fermion1/.style={
    /tikz/postaction={
      /tikz/decoration={
        markings,
        mark=at position 0.5 with {
          \node[
            transform shape,
            xshift=-0.5mm,
            fill,
            dart tail angle=100,
            inner sep=1.3pt,
            draw=none,
            dart
          ] { };
        },
      },
      /tikz/decorate=true,
    },
  },
  fermion2/.style={
    /tikz/postaction={
      /tikz/decoration={
        markings,
        mark=at position 0.5 with {
          \arrow{>[length=6pt, width=5pt]};
        },
      },
      /tikz/decorate=true,
    },
  },
}

\begin{document}
\feynmandiagram [horizontal=a to b] {
  a -- [fermion1] b -- [fermion2] {c, d},
};
\end{document}

output

Since you probably want to change the fermion style completely, then I would recommend creating a new fermion style instead of overwriting the default one. Having said that, have a look at Torbjørn T.'s answer as he is going even more general than I am in this answer! He is modifying one of the underlying styles in TikZ-Feynman (the with arrow style) so that the arrows are changed for all particles.

1
  • This is also a great starting point for further customizations! Thank you. May 5, 2017 at 14:34
4

The arrow tip in the middle of the lines are placed using a decoration from the decoration.markings library. I think you need to specify a new decoration altogether, for example:

enter image description here

\documentclass{article}
\usepackage{tikz-feynman}
\usetikzlibrary{positioning,arrows.meta}
\tikzfeynmanset{ fermion/.style = {
   decoration={
     markings,
     mark=at position 0.5
          with {\arrow[xshift=2mm]{Stealth[red,width=3mm,length=4mm]}}
     },
   postaction=decorate}
}

\begin{document}
\begin{tikzpicture}
\begin{feynman}
    \vertex (a);
    \vertex [right=of a] (b);
    \diagram*{ (a) -- [fermion](b) };
\end{feynman}
\end{tikzpicture}
\end{document}

More generally, fermion and other styles with an arrow in the middle use a style called with arrow, that is defined by tikz-feynman. If you want the same arrow tip for all of these, you could modify that style instead. Not sure if JP-Ellis, the package author, intended for people to do that though.

enter image description here

\documentclass[review]{article}
\usepackage{tikz-feynman}
\usetikzlibrary{positioning,arrows.meta}
\tikzfeynmanset{ with arrow/.style = {
   decoration={
     markings,
     mark=at position 0.5
          with {\arrow[xshift=2mm]{Stealth[red,width=3mm,length=4mm]}}
     },
   postaction=decorate}
}

\begin{document}
\begin{tikzpicture}
\begin{feynman}
    \vertex (a);
    \vertex [right=of a] (b);
    \diagram*{ (a) -- [fermion](b) };
\end{feynman}
\end{tikzpicture}
\begin{tikzpicture}
\begin{feynman}
    \vertex (a);
    \vertex [right=of a] (b);
    \diagram*{ (a) -- [charged boson](b) };
\end{feynman}
\end{tikzpicture}
\end{document}
4
  • 2
    Great answer! I didn't see it until I posted my answer :) My personal preference is to avoid overwriting the default style too much; however, I realize people might want to change things and it is up to them ultimately. Nice modification of with arrow!
    – JP-Ellis
    May 5, 2017 at 12:17
  • I finally chose the @JP-Ellis approach to create a new style instead of overwriting the existing, it's a matter of personal preference, I guess. Anyway thank you for your detailed answer! May 5, 2017 at 14:32
  • How would the command for anti fermion look like?
    – mavzolej
    Jul 24 at 2:31
  • @mavzolej Does that mean the arrow direction is flipped? Did you see Níckolas Alves' answer? Jul 25 at 7:52
0

I've changed a little of Torbjørn T.'s answer to include antiparticles, as they seem to be built upon with reversed arrow instead of with arrow (please correct me if I'm mistaken).

\documentclass[review]{article}
\usepackage{tikz-feynman}
\usetikzlibrary{positioning,arrows.meta}

\tikzfeynmanset{ with arrow/.style = {
   decoration={
     markings,
     mark=at position 0.5
          with {\arrow[xshift=2mm]{Stealth[red,width=3mm,length=4mm]}}
     },
   postaction=decorate},
   with reversed arrow/.style = {
   decoration={
     markings,
     mark=at position 0.5
          with {\arrowreversed[xshift=-2mm]{Stealth[red,width=3mm,length=4mm]}}
     },
   postaction=decorate}
}

\begin{document}
\begin{tikzpicture}
\begin{feynman}
    \vertex (a);
    \vertex [right=of a] (b);
    \diagram*{ (a) -- [fermion](b) };
\end{feynman}
\end{tikzpicture}
\begin{tikzpicture}
\begin{feynman}
    \vertex (a);
    \vertex [right=of a] (b);
    \diagram*{ (a) -- [charged boson](b) };
\end{feynman}
\end{tikzpicture}
\begin{tikzpicture}
\begin{feynman}
    \vertex (a);
    \vertex [right=of a] (b);
    \diagram*{ (a) -- [anti fermion](b) };
\end{feynman}
\end{tikzpicture}
\begin{tikzpicture}
\begin{feynman}
    \vertex (a);
    \vertex [right=of a] (b);
    \diagram*{ (a) -- [anti charged boson](b) };
\end{feynman}
\end{tikzpicture}
\end{document}

This yields the following diagrams:

fermion charged boson

anti fermion anti charged boson

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .