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}
The size of the diagram is controlled by \unitlength
; you can also issue a font size changing command for increasing the size of the letters.
\documentclass{article}
\usepackage{feynmp-auto}
\begin{document}
\begin{enumerate}
\item Feynman diagram:
\begin{fmffile}{fgraph_tau}
\setlength{\unitlength}{1cm}
\begin{fmfgraph*}(8,5)
\fmfleft{i1,i0}
\fmfright{o1,o0}
\fmf{fermion,label=$e^+$}{i1,w1}
\fmf{fermion,label=$\overline\nu_e$}{w1,o1}
\fmf{boson,label=$W$}{w0,w1}
\fmf{fermion,label=$\overline\nu_\mu$}{i0,w0}
\fmf{fermion,label=$\mu^+$}{w0,o0}
\end{fmfgraph*}
\end{fmffile}
\item Smaller Feynman diagram:
\begin{fmffile}{fgraph_tau2}
\setlength{\unitlength}{.75cm}\large
\begin{fmfgraph*}(8,5)
\fmfleft{i1,i0}
\fmfright{o1,o0}
\fmf{fermion,label=$e^+$}{i1,w1}
\fmf{fermion,label=$\overline\nu_e$}{w1,o1}
\fmf{boson,label=$W$}{w0,w1}
\fmf{fermion,label=$\overline\nu_\mu$}{i0,w0}
\fmf{fermion,label=$\mu^+$}{w0,o0}
\end{fmfgraph*}
\end{fmffile}
\end{enumerate}
\end{document}
Best Answer
You want to add some dummy nodes on the right so that
o1
ando2
are nearer the middle, then freeze the automatic layout withfmffreeze
and finally pushv2
andv3
apart withfmfshift
. Like this:Notice I've added a couple of other small tweaks to make it a bit neater. Adding
tension=2
to the dashed arrow makes it balance the two gluons better. And I've pushed one of the quark labels to the other side of the arrow.