3

Consider the following piece of code which uses the tikz-feynman package:

\feynmandiagram [baseline={(current bounding box.center)},medium, vertical=b to f] {
        a [nudge=(-30:5mm)]
        -- [photon, edge label=\(p_{1}\)] b [label=190:\(\mu_{1}\)]
        -- [fermion, edge label=\(k+p_{1}\)] c,
        d[nudge=(220:5mm)] -- [photon, edge label'=\(p_{2}\)] c [label=-30:\(\mu_{2}\)],
        c -- [fermion, edge label=\(k+p_{1}+p_{2}\)] e [label=10:\(\mu_{3}\)] -- [fermion, edge label=\(k-p_{4}\)] f [label=176:\(\mu_{4}\)] -- [ fermion, edge label=\(k\)] b,
        g [nudge=(150:5mm)] -- [photon, edge label=\(p_{3}\)] e,
        h [nudge=(30:5mm)] -- [photon, edge label'=\(p_{4}\)] f,
    };

This gives us the diagram

I would like to amend the code to flip the vertical lines to get the following diagram

whilst keeping the labels on the first diagram intact. How do I do so?

3

I have adapted the example I made in another question you asked. I didn't include the nudging here to make the code a bit clearer (but you can add it back in easily).

I also took the liberty of cleaning up the way the diagram is created, I hope you don't mind :) It should make it a bit simpler and a bit easier.

Now, the algorirthm will, be default, avoid having lines crossing over. As a result, to draw the diagram you want, you'll have to either manually specify the location of vertices or do it in two steps. I've shown below how it can be done in two steps, and I've commented the code to explain what part does what. I hope it's clear, but feel free to comment if you need some clarifications.

original, fermions lines don't cross

with fermion lines crossing

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

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

\begin{document}
\feynmandiagram [
    baseline={(current bounding box.center)},
    vertical'=a to b,
  ] {
  %% Instead of having to specify `fermion` over and over, group them
  %% together.
  {[edges={fermion}]
    a -- [edge label'=\(k_{1}\)] b [label=0:\(\mu_{2}\)]
      -- [edge label'=\(k_{2}\)] c [label=-180:\(\mu_{3}\)]
      -- [edge label'=\(k_{3}\)] d [label=-180:\(\mu_{4}\)]
      -- [edge label'=\(k_{4}\)] a [label=0:\(\mu_{1}\)],
  },
  {[edges={photon}]
    %% Sometimes, the algorithms gets stuck when trying to figure out the final
    %% layout, hence why I'm switching the order of d and c below.
    a -- ap [particle=\(p_{1}\)],
    b -- bp [particle=\(p_{2}\)],
    d -- dp [particle=\(p_{4}\)],
    c -- cp [particle=\(p_{3}\)],
  },
};

\begin{tikzpicture}[baseline={(current bounding box.center)}]
  \begin{feynman}
    %% Just like before, we create the internal box of fermion lines, but this
    %% time we use `draw=none` so they are invisible.
    \diagram [vertical'=a to b] {
      {[edges={draw=none}]
        a -- b [label=0:\(\mu_{2}\)]
          -- c [label=-180:\(\mu_{3}\)]
          -- d [label=-180:\(\mu_{4}\)]
          -- a [label=0:\(\mu_{1}\)],
      },
      {[edges={photon}]
        %% Sometimes, the algorithms gets stuck when trying to figure out the final
        %% layout, hence why I'm switching the order of d and c below.
        a -- ap [particle=\(p_{1}\)],
        b -- bp [particle=\(p_{2}\)],
        d -- dp [particle=\(p_{4}\)],
        c -- cp [particle=\(p_{3}\)],
      },
    };

    %% We now need to add in the fermion lines.  Since we just want to connect
    %% existing vertices, we use the `\diagram*` command.  The parentheses are
    %% important as it tells the algorithm that these vertices exist already
    %% (instead of trying to create new ones).
    \diagram* {
      (a) -- [fermion] (b)
          -- [fermion] (d)
          -- [fermion] (c)
          -- (a),  %% No fermion line hear as it looks weird with the two arrows
                   %% overlapping.
    };
  \end{feynman}
\end{tikzpicture}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.