Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there any good package for typesetting lots of Feynman diagrams?

My question arise because Feynmp: Circle with three vertices lead me take a look at the documentation for the feynmf/feynmp package, and didn't like the package very much. In my opinion this package has several draw-backs: it doesn't work with pdflatex unless you get help from @egreg (How to use kile with feynmf or feynmp?), the notation is not very intuitive (what do left=.5 mean?), etc.

I thought that there must be some better package for typesetting Feynman diagram (e.g. something that builds on TikZ rather than metapost), but CTAN gave me only this.

So do you know something better than feynmp?


EDIT:

Since @cmhughes comment suggest to use tikz rather than feynmp (and no one has suggested any other packages), the questions are this:

  • Which package is most efficient for typesetting Feynman diagrams, feynmp or tikz?

  • Which package produces the best (this means the most beautiful) results?

In order for tikz to really compete with feynmp (on this particular battlefield), the code must be approximately as simple as with feynmp, and the results must be at least as good. Below you will find some examples of Feynman diagrams made using feynmp. How can you typeset diagrams as simple as possible using tikz?

Feynman Diagrams

Code:

\documentclass{memoir}

\usepackage{feynmp}

\begin{document}
\unitlength=1mm 
\centering

\begin{fmffile}{photon} % Tree-level interaction
\begin{fmfgraph*}(40,25)
\fmfkeep{photon}
\fmfleft{i1,i2}
\fmfright{o1,o2}
\fmf{fermion}{i1,v1,i2}
\fmf{fermion}{o1,v2,o2}
\fmf{photon}{v1,v2}
\end{fmfgraph*}
\end{fmffile}
~
\begin{fmffile}{gluon}
\begin{fmfgraph*}(40,25)
\fmfleft{i1,i2}
\fmfright{o1,o2}
\fmf{fermion}{i1,v1,i2}
\fmf{fermion}{o1,v2,o2}
\fmf{gluon}{v1,v2}
\end{fmfgraph*}
\end{fmffile}

\plainbreak{1}

\begin{fmffile}{self} % Self-interaction
\begin{fmfgraph*}(40,25)
\fmfleft{i}
\fmfright{o}
\fmf{plain}{i,v1}
\fmf{fermion}{v1,v2}
\fmf{plain}{v2,o}
\fmf{photon,left}{v1,v2}
\end{fmfgraph*}
\end{fmffile}
~
\begin{fmffile}{loop} % Loop correction
\begin{fmfgraph*}(40,25)
\fmfkeep{loop}
\fmfleft{i1,i2}
\fmfright{o1,o2}
\fmf{fermion}{i1,v1,i2}
\fmf{fermion}{o1,v4,o2}
\fmf{photon}{v1,v2}
\fmf{photon}{v3,v4}
\fmf{fermion,right,tension=.2}{v2,v3,v2}
\end{fmfgraph*}
\end{fmffile}

\begin{fmffile}{penguin} % Penguin?
\begin{fmfgraph*}(70,80)
\fmftop{t1,t2}
\fmfbottom{b1,b2}
\fmf{fermion}{t1,v1}
\fmf{fermion}{v2,t2}
\fmf{fermion,tension=.5}{v1,v3,v2}
\fmf{boson,tension=.5}{v1,v2}
\fmf{gluon}{v3,v4}
\fmf{fermion}{b1,v4,b2}
\end{fmfgraph*}
\end{fmffile}

\end{document}

Please, note that Feynman Diagrams with tikz and texample: Feynman diagram do not answer this question.

share|improve this question
1  
I'd use tikz or PSTricks :) –  cmhughes Dec 12 '12 at 4:31
    
It should be possible to use only Lua for those pictures which require it using the external library from TikZ. You’ll probably need to adjust the preamble a little bit (encoding, fonts, etc.). –  Qrrbrbirlbel Jun 29 '13 at 19:40
1  
@Qrrbrbirlbel - The point should be to avoid Lua completely, since most physicists, I know, don't use Lualatex at all. Actually, I (hardly) never use it myself, and frankly I have no desire to do so, if I can avoid it (call me stubborn). –  Jesper Ipsen Jun 30 '13 at 9:17
    
I actually prefer feynmp over tikz since the feynmp diagrams look nicer (in my opinion). The syntax and compiling procedure is certainly annoying (Makefiles are good for this), but it works fine with pdflatex and lualatex. –  xvtk Jun 30 '13 at 14:51
1  
@xvtk have you ever heard about feynmp-auto package? –  giordano Jun 30 '13 at 16:55

1 Answer 1

up vote 27 down vote accepted
+250

The CVS version of TikZ contains a graph layout library, which works surprisingly well for this. Here are a couple of your examples. The syntax could be shortened (f instead of fermion, for example), this is just to show the idea:

\graph [spring layout, nodes=coordinate, horizontal'=c to d]
{
c -- [fermion] a,
b --[fermion] c -- [photon] d,
e -- [fermion] d -- [fermion] f;
};


\graph [spring layout, nodes=coordinate, horizontal'=c to d]
{
c -- [fermion] a,
b --[fermion] c -- [gluon] d,
e -- [fermion] d -- [fermion] f;
};


\graph [spring layout, anchor at={(0,-4)}, nodes=coordinate, horizontal'= b to d]
{
a -- [fermion] b -- [fermion] c,
b -- [photon] d -- [left, fermion] e -- [left, fermion] d,
e -- [photon] f -- [fermion] g,
h -- [fermion] f;
};


\graph [spring layout, anchor at={(0,-5)}, nodes=coordinate, vertical= e to f]
{
a -- [fermion] b -- [photon] c -- [fermion] d,
b -- [fermion] e -- [fermion] c,
e -- [gluon]  f,
h -- [fermion] f -- [fermion] i
};


There are some issues with decorating curved paths using waves, and the coils decoration sometimes ends with a straight path segment, but that could be fixed.

Here's the complete code (requires lualatex).

\documentclass[a4paper,12pt, border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations, decorations.markings, decorations.pathmorphing, arrows, graphs, graphdrawing, shapes.geometric, snakes}
\usegdlibrary{trees,force, layered}

\pgfdeclaredecoration{complete sines}{initial}
{
    \state{initial}[
        width=+0pt,
        next state=sine,
        persistent precomputation={\pgfmathsetmacro\matchinglength{
            \pgfdecoratedinputsegmentlength / int(\pgfdecoratedinputsegmentlength/\pgfdecorationsegmentlength)}
            \setlength{\pgfdecorationsegmentlength}{\matchinglength pt}
        }] {}
    \state{sine}[width=\pgfdecorationsegmentlength]{
        \pgfpathsine{\pgfpoint{0.25\pgfdecorationsegmentlength}{0.5\pgfdecorationsegmentamplitude}}
        \pgfpathcosine{\pgfpoint{0.25\pgfdecorationsegmentlength}{-0.5\pgfdecorationsegmentamplitude}}
        \pgfpathsine{\pgfpoint{0.25\pgfdecorationsegmentlength}{-0.5\pgfdecorationsegmentamplitude}}
        \pgfpathcosine{\pgfpoint{0.25\pgfdecorationsegmentlength}{0.5\pgfdecorationsegmentamplitude}}
}
    \state{final}{}
}

\tikzset{
    photon/.style={
        decoration={complete sines, amplitude=0.15cm, segment length=0.2cm},
        decorate    
    },
    fermion/.style={
        decoration={
            markings,
            mark=at position 0.5 with {\node[transform shape, xshift=-0.5mm, fill=black, inner sep=1pt, draw, isosceles triangle]{};}
        },
        postaction=decorate
    },
    gluon/.style={
        decoration={coil, aspect=0.75, mirror, segment length=1.5mm},
        decorate
    }, 
    left/.style={
        bend left=90,
        looseness=1.75
    }
}

\begin{document}%
\begin{tikzpicture}
\graph [spring layout, nodes=coordinate, horizontal'=c to d]
{
c -- [fermion] a,
b --[fermion] c -- [photon] d,
e -- [fermion] d -- [fermion] f;
};

\graph [spring layout, anchor at={(0,-2)}, nodes=coordinate, horizontal'=c to d]
{
c -- [fermion] a,
b --[fermion] c -- [gluon] d,
e -- [fermion] d -- [fermion] f;
};

\graph [spring layout, anchor at={(0,-4)}, nodes=coordinate, horizontal'= b to d]
{
a -- [fermion] b -- [fermion] c,
b -- [photon] d -- [left, fermion] e -- [left, fermion] d,
e -- [photon] f -- [fermion] g,
h -- [fermion] f;
};

\graph [spring layout, anchor at={(0,-5)}, nodes=coordinate, vertical= e to f]
{
a -- [fermion] b -- [photon] c -- [fermion] d,
b -- [fermion] e -- [fermion] c,
e -- [gluon]  f,
h -- [fermion] f -- [fermion] i
};
\end{tikzpicture}
\end{document}

share|improve this answer
1  
Thanks, okay I guess I'll just wait for the next release of tikz and use manual labour until then. I was able to create a diagram using code like here. However, I failed to create a diagram with a semicircle over a straight line. Like here. I tried arc, but it doesn't connect to the correct node. Do you know a good reference for that? I don't have too much time in the moment. But, otherwise I'll make a proper question of that issue when I have time. –  Lemming Apr 26 '13 at 8:03
3  
@Jake, when I try to run your example I get a memoization table filled incorrectly error from Path.lua. Any idea what the problem is? –  user545424 Apr 10 '14 at 15:42
1  
I've also tried with latest in TeXLive and CVS and it doesn't work. Something about using node=coordinate breaks it (although not using this option looks ugly). –  Nathanael Farley Sep 15 '14 at 9:40
1  
Looking further into it, it seems to be a result of the following bug: sourceforge.net/p/pgf/bugs/319 –  Nathanael Farley Sep 29 '14 at 18:35
2  
I have found a fix for this bug, and I have created a small package based on this answer if anyone is interested: tikz-feynman. PS: I have tried contacting the developers behind TikZ in many different ways, but none of them have responded regarding this fix... –  Josh May 3 at 12:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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