Resonance production in FeynMF

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












How could I make the picture:



enter image description here



using FeynMF?










share|improve this question



















  • 4




    Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with documentclass... and ending with enddocument.
    – albert
    Aug 15 at 13:58






  • 1




    Take a look at this example: texample.net/tikz/examples/feynman-diagram
    – sporc
    Aug 15 at 14:15






  • 1




    Thanks for the answers. My figure was pretty crazy @albert, because of this I didn't show the code (next time I'll do it).
    – Marcos
    Aug 15 at 14:59










  • Always show your effort, people can always point you to the problematic part (and you and others can learn from the problems).
    – albert
    Aug 15 at 16:01














up vote
2
down vote

favorite












How could I make the picture:



enter image description here



using FeynMF?










share|improve this question



















  • 4




    Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with documentclass... and ending with enddocument.
    – albert
    Aug 15 at 13:58






  • 1




    Take a look at this example: texample.net/tikz/examples/feynman-diagram
    – sporc
    Aug 15 at 14:15






  • 1




    Thanks for the answers. My figure was pretty crazy @albert, because of this I didn't show the code (next time I'll do it).
    – Marcos
    Aug 15 at 14:59










  • Always show your effort, people can always point you to the problematic part (and you and others can learn from the problems).
    – albert
    Aug 15 at 16:01












up vote
2
down vote

favorite









up vote
2
down vote

favorite











How could I make the picture:



enter image description here



using FeynMF?










share|improve this question















How could I make the picture:



enter image description here



using FeynMF?







feynmf feynman






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 15 at 14:49

























asked Aug 15 at 13:55









Marcos

162




162







  • 4




    Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with documentclass... and ending with enddocument.
    – albert
    Aug 15 at 13:58






  • 1




    Take a look at this example: texample.net/tikz/examples/feynman-diagram
    – sporc
    Aug 15 at 14:15






  • 1




    Thanks for the answers. My figure was pretty crazy @albert, because of this I didn't show the code (next time I'll do it).
    – Marcos
    Aug 15 at 14:59










  • Always show your effort, people can always point you to the problematic part (and you and others can learn from the problems).
    – albert
    Aug 15 at 16:01












  • 4




    Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with documentclass... and ending with enddocument.
    – albert
    Aug 15 at 13:58






  • 1




    Take a look at this example: texample.net/tikz/examples/feynman-diagram
    – sporc
    Aug 15 at 14:15






  • 1




    Thanks for the answers. My figure was pretty crazy @albert, because of this I didn't show the code (next time I'll do it).
    – Marcos
    Aug 15 at 14:59










  • Always show your effort, people can always point you to the problematic part (and you and others can learn from the problems).
    – albert
    Aug 15 at 16:01







4




4




Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with documentclass... and ending with enddocument.
– albert
Aug 15 at 13:58




Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with documentclass... and ending with enddocument.
– albert
Aug 15 at 13:58




1




1




Take a look at this example: texample.net/tikz/examples/feynman-diagram
– sporc
Aug 15 at 14:15




Take a look at this example: texample.net/tikz/examples/feynman-diagram
– sporc
Aug 15 at 14:15




1




1




Thanks for the answers. My figure was pretty crazy @albert, because of this I didn't show the code (next time I'll do it).
– Marcos
Aug 15 at 14:59




Thanks for the answers. My figure was pretty crazy @albert, because of this I didn't show the code (next time I'll do it).
– Marcos
Aug 15 at 14:59












Always show your effort, people can always point you to the problematic part (and you and others can learn from the problems).
– albert
Aug 15 at 16:01




Always show your effort, people can always point you to the problematic part (and you and others can learn from the problems).
– albert
Aug 15 at 16:01










3 Answers
3






active

oldest

votes

















up vote
8
down vote













You mention feynmf in the title but are tagging the question with almost everything... Here a feynmf working start point, to run with latex + mf + latex. (There is surely room for improvement.) It works the same way with feynmp and METAPOST, of course.



documentclassarticle

usepackagefeynmf

begindocument

beginfmffilediagram
beginfmfgraph*(100,80)
fmfstraight
fmfleftni5
fmfrightno5
fmffermioni5,vt,o5
fmfphantomi1,vb,o1
fmfphoton,label=$W$vt,vb
fmffreeze
fmffermioni1,vb
fmffermion,label=$Delta^++$vb,vr
fmffermionvr,o2
fmffermionvr,o1
fmflabel$nu_1$i5
fmflabelpi1
fmflabelpo1
fmflabel$mu^-$o5
fmflabel$pi^+$o2
endfmfgraph*
endfmffile
enddocument


enter image description here






share|improve this answer



























    up vote
    6
    down vote













    Very similar to campa's nice answer but with a scalar propagator for the pion. I only post the code of the Feynman diagram.



    beginfmfgraph*(50,40)
    fmflefti1,i2
    fmfrightf1,f2
    fmffermion,label=i1,v1,f1
    fmffermion,label=i2,v2,f2
    fmfphoton,label=$W$v1,v2
    fmffreeze
    fmfphantomf1,f3,h1,h2,h3,f2
    fmfphantomv1,h4,h5,v3,f1
    fmffreeze
    fmfphantomh1,pi,f3
    fmfphantom,label=$Delta^++$v1,v3
    fmfdashesv3,f3
    fmflabel$p$i1
    fmflabel$nu_1$i2
    fmflabel$p$f1
    fmflabel$pi^+$pi
    fmflabel$mu^-$f2
    endfmfgraph*


    enter image description here






    share|improve this answer
















    • 3




      +1 Indeed, I did say in my answer "There is surely room for improvement ;-).
      – campa
      Aug 15 at 14:52


















    up vote
    3
    down vote













    Using usepackagefeynman, https://ctan.org/tex-archive/macros/latex209/contrib/feynman



    documentclass[a4paper,12pt]article

    usepackagemathtools
    usepackagefeynman
    usetikzlibrarypatterns, arrows, decorations.pathreplacing, decorations.markings
    begindocument

    beginfeynman
    fermion6.20, 1.207.20, 2.20
    fermion0.20, 5.203.20, 4.20
    electroweak3.20, 2.203.20, 4.20
    fermion3.20, 2.206.20, 1.20
    fermion3.20, 4.206.20, 5.20
    fermion[lineWidth=2]6.20, 1.207.20, 2.20
    fermion0.20, 1.203.20, 2.20
    fermion[showArrow=true, flip=true]7.20, 0.206.20, 1.20
    text5.00,2.20Delta^++
    text1.00,0.90p
    text5.60,4.60mu^-
    text6.60,0.20p
    text0.90,4.50v_1
    text6.70,2.20pi^+
    endfeynman

    enddocument


    Here I have added feynman.sty (to save as .sty).



    NeedsTeXFormatLaTeX2e
    ProvidesPackagefeynman
    [2015/02/01 v0.8 LaTeX package for drawing feynman diagrams with an interface similar to the one found at feynman.aivazis.com]

    RequirePackagexcolor
    RequirePackagetikz
    RequirePackagexifthen
    RequirePackagekvoptions
    RequirePackagefp

    usetikzlibrarypatterns, arrows, decorations.pathreplacing, decorations.markings

    % turn off the fp messages
    FPmessagesfalse

    % treat @ like a normal letter
    makeatletter


    %------------------------------------------------------------------------------
    % configuration parameters
    %------------------------------------------------------------------------------

    % define the diagram configuration settings family
    SetupKeyvalOptionsfamily=diagram, prefix=diagram@
    DeclareStringOption[in]unit
    DeclareStringOption[An Example Feynman Diagram]title

    % define the propagator configuration settings family
    SetupKeyvalOptionsfamily=style, prefix=style@
    DeclareStringOption[000000]color
    DeclareStringOption[2]lineWidth
    DeclareBoolOption[true]endcaps
    DeclareStringOption[1/3]gluonWidth
    DeclareStringOption[center]location
    DeclareStringOptionlabel
    DeclareStringOption[0.5]labelDistance
    DeclareStringOption[0.5]labelLocation
    DeclareBoolOption[true]showArrow
    DeclareBoolOption[false]flip


    %------------------------------------------------------------------------------
    % the feynman diagram environment
    %------------------------------------------------------------------------------

    % define an enviroment to encompass a single diagram
    newenvironmentfeynman[1]
    % before the content

    % load the diagram configuration settings
    setkeysdiagram#1
    % start the tikz environment
    begintikzpicture[x=1diagram@unit, y=1diagram@unit]

    % after the content

    % close the tikz environment
    endtikzpicture



    %------------------------------------------------------------------------------
    % utility macros
    %------------------------------------------------------------------------------

    % convert a particular length to the designated unit
    % i.e. converttomm1pt
    newcommand*convertto[2]strip@ptdimexpr #2*65536/numberdimexpr 1#1

    % compute the length between two points
    defcalcLength(#1,#2)#3
    % compute the delta between two points
    pgfpointdiffpgfpointanchor#1center
    pgfpointanchor#2center
    pgf@xa=pgf@x
    pgf@ya=pgf@y
    % cast the deltas in the appropriate unit system
    FPeval@temp@apgfmath@tonumberpgf@xa/72.27
    FPeval@temp@bpgfmath@tonumberpgf@ya/72.27

    % store the sum of the squares
    FPeval@temp@sum(@temp@a*@temp@a+@temp@b*@temp@b)
    % take the square root of the result
    FProotFPMathLen@temp@sum2
    % cut off at 5 decimal places
    FProundFPMathLenFPMathLen9relax
    % set the value of the macro we were given
    expandafteredefcsname #3endcsnameFPMathLen


    % compute the angle between two points
    defcalcAngle(#1,#2)#3
    % compute the difference between the two points
    pgfpointdiffpgfpointanchor#1center
    pgfpointanchor#2center
    % extract the delta between the two points
    pgf@xa=pgf@x
    pgf@ya=pgf@y
    % cast the deltas as numbers
    FPevaldeltaXpgfmath@tonumberpgf@xa
    FPevaldeltaYpgfmath@tonumberpgf@ya
    % use pgf to compute atan2
    pgfmathparseatan2(deltaY, deltaX)
    % set the angle to the result
    FPevalangleround(pgfmathresult , 5)

    % set the value of the macro we were given
    expandafteredefcsname #3endcsnameangle


    % shortcut macro to print an expression to the console
    newcommand*print[1]typeout#1


    %------------------------------------------------------------------------------
    % patterns and colors
    %------------------------------------------------------------------------------

    % declare the parameters for the pattern
    tikzset
    hatch distance/.store in=hatchdistance,
    hatch distance=10pt,
    hatch thickness/.store in=hatchthickness,
    hatch thickness=1pt

    % define the parton fill pattern
    pgfdeclarepatternformonly[hatchdistance,hatchthickness]parton
    % declare the origin
    pgfqpoint0pt0pt
    % define the variables in this coordinate system
    pgfqpointhatchdistancehatchdistance
    pgfpointhatchdistance-1pthatchdistance-1pt
    % set up the pattern

    pgfsetcolortikz@pattern@color
    pgfsetlinewidthhatchthickness
    pgfpathmovetopgfqpoint0pt0pt
    pgfpathlinetopgfqpointhatchdistancehatchdistance
    pgfusepathstroke



    % define the arrow style
    tikzset
    arrow/.style=
    decoration=
    markings,
    mark=at position .5 with
    arrow[#1, scale=1.5]latex

    ,
    postaction=decorate,


    tikzset
    arrow flipped/.style=
    decoration=
    markings,
    mark=at position .5 with
    arrow[#1, scale=1.5]latex reversed

    ,
    postaction=decorate,




    % define a light gray to be used as a fill color for partons
    definecolorlight-graygray.7

    %------------------------------------------------------------------------------
    % text macros
    %------------------------------------------------------------------------------

    % overline with variable width (the second brace)
    newcommand*anti[2][1.0]
    overline#2


    % overline with variable width (the second brace)
    newcommand*txt[1]
    textrm#1


    %------------------------------------------------------------------------------
    % propagator styles
    %------------------------------------------------------------------------------

    % fermions
    newcommand*fermion[3]
    % scope the configuration options
    begingroup
    % load the configuration parameters
    setkeysstyle#1

    % parse the color of the line
    definecolorlineColorHTMLstyle@color

    % if they asked to draw the arrow
    ifstyle@showArrow
    ifstyle@flip
    % draw the line with an arrow
    draw[color=lineColor, line width = style@lineWidth, arrow flipped] (#2) -- (#3);
    else
    % draw the line with an arrow
    draw[color=lineColor, line width = style@lineWidth, arrow] (#2) -- (#3);
    fi
    % otherwise they did not ask to draw the arrow
    else
    % draw the line
    draw[color=lineColor, line width = style@lineWidth] (#2) -- (#3);
    fi

    % draw the label
    drawLabel#2#3
    endgroup



    % dashed propagators
    newcommand*dashed[3]
    % scope the configuration options
    begingroup
    % load the configuration parameters
    setkeysstyle#1

    % parse the color of the line
    definecolorlineColorHTMLstyle@color

    % if they asked to draw the arrow
    ifstyle@showArrow
    ifstyle@flip
    % draw the line with an arrow
    draw[dashed, color=lineColor, line width = style@lineWidth, arrow flipped=lineColor] (#2) -- (#3);
    else
    % draw the line with an arrow
    draw[dashed, color=lineColor, line width = style@lineWidth, arrow=lineColor] (#2) -- (#3);
    fi
    % otherwise they did not ask to draw the arrow
    else
    % draw the line
    draw[dashed, color=lineColor, line width = style@lineWidth] (#2) -- (#3);
    fi

    % draw the label
    drawLabel#2#3
    endgroup



    % gluons
    newcommand*gluon[3]
    % scope the configuration options
    begingroup
    % load the configuration parameters
    setkeysstyle#1

    % create TikZ coordinates at the end points
    coordinate (start) at (#2);
    coordinate (finish) at (#3);
    % store the distance between the two points
    calcLength(start,finish)length % stores it in a macro called length
    % store the angle between the two points
    calcAngle(start,finish)angle % stores it in a macro called angle

    % turn the start coordinate into a pgf point
    pgfpointanchorstartcenter
    FPevalstartXpgfmath@tonumberpgf@x
    FPevalstartYpgfmath@tonumberpgf@y

    FPevalgluonWidthstyle@gluonWidth
    % store a value for half of the gluonWidth
    FPevalhalfWidthgluonWidth/2
    % store the closest whole number of full periods
    FPevalnLoopsround((length / gluonWidth ) - 1, 0)
    FPevaltotalLength(nLoops+1) * gluonWidth
    FPevalscalelength / totalLength
    % parse the color of the line
    definecolorlineColorHTMLstyle@color

    % if we dont fit a whole loop between the two points
    ifthenelseequalnLoops0
    % use a fermion line instead
    fermion#2#3

    % we fit at least one loop between the two points


    % if they want the end caps (to draw the right kind of line)
    ifstyle@endcaps
    % if they asked to flip the loops
    ifstyle@flip
    % set the maximum value to be positive
    FPevalymaxhalfWidth
    FPevalymin0-halfWidth
    % otherwise draw the loops right side up
    else
    % set the maximum value to be negative
    FPevalymax0-halfWidth
    FPevalyminhalfWidth
    fi

    % style the opening end cap
    draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
    rotate=angle, xscale=scale, yscale=scale]
    % draw the opening end cap
    (0,0) .. controls (halfWidth, 0) and (0, ymin) .. (halfWidth, ymin);
    % for each loop that we have to draw
    foreach loopNumber in 1,...,nLoops
    % compute the starting location of the loop
    FPevalxloopNumber * gluonWidth - halfWidth
    % compute the half way point of the loop
    FPevalxMidhalfWidth + x
    % compute the endpoint of the loop
    FPevalxFinalgluonWidth + x

    % style the first half of the loop
    draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
    rotate=angle, xscale=scale, yscale=scale]
    % draw the first half of the loop
    (x, ymin) .. controls (xFinal, ymin) and (xFinal, ymax) .. (xMid, ymax);
    % style the second half of the loop
    draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
    rotate=angle, xscale=scale, yscale=scale]
    % draw the second half of the loop
    (xMid, ymax) .. controls (x, ymax) and (x, ymin) .. (xFinal, ymin);


    % compute the locations for the closing end cap
    FPevalfinalStart(nLoops+1) * gluonWidth - halfWidth
    FPevalfinalHalffinalStart + halfWidth
    FPevalfinalStopfinalStart + halfWidth
    % style the closing end cap
    draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
    rotate=angle, xscale=scale, yscale=scale]
    % draw the closing end cap
    (finalStart, ymin) .. controls (finalStop, ymin) and (finalStart, 0) .. (finalStop, 0);

    % they did not want end caps
    else
    % if they asked for the gluons to be flipped
    ifstyle@flip
    % store a value for the height of the gluon loop
    FPevalheight0-gluonWidth
    else
    % store a value for the height of the gluon loop
    FPevalheightgluonWidth
    fi

    % for each loop that we have to draw
    foreach loopNumber in 0,...,nLoops
    % compute the starting location of the loop
    FPevalxloopNumber * gluonWidth
    % compute the midpoint of the loop
    FPevalxMidhalfWidth + x
    % compute the endpoint of the loop
    FPevalxFinalgluonWidth + x
    % style the first half of the loop
    draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
    rotate=angle, xscale=scale, yscale=scale]
    % draw the first half of the loop
    (x,0) .. controls (xFinal, 0) and (xFinal, height) .. (xMid, height);
    % style the second half of the loop
    draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
    rotate=angle, xscale=scale, yscale=scale]
    % draw the second half of the loop
    (xMid,height) .. controls (x, height) and (x, 0) .. (xFinal, 0);

    fi

    % draw the label
    drawLabel#2#3
    endgroup



    % electroweak lines
    newcommand*electroweak[3]
    % scope the configuration options
    begingroup
    % load the configuration parameters
    setkeysstyle#1

    % create TikZ coordinates at the end points
    coordinate (start) at (#2);
    coordinate (finish) at (#3);
    % store the distance between the two points
    calcLength(start,finish)length % stores it in a macro called length
    % store the angle between the two points
    calcAngle(start,finish)angle % stores it in a macro called angle

    % turn the start coordinate into a pgf point
    pgfpointanchorstartcenter
    FPevalstartXpgfmath@tonumberpgf@x
    FPevalstartYpgfmath@tonumberpgf@y

    FPevalperiodstyle@gluonWidth
    % store a value for half of the gluonWidth
    FPevalhalfPeriodperiod/2
    % store the closest whole number of full periods
    FPevalnLoopsround((length / period ) - 1, 0)
    FPevaltotalLength(nLoops+1) * period
    FPevalscalelength / totalLength
    % parse the color of the line
    definecolorlineColorHTMLstyle@color

    % if we dont fit a whole loop between the two points
    ifthenelseequalnLoops0
    % use a fermion line instead
    fermion#2#3

    % we fit at least one loop between the two points

    % store the amplitude of the curve
    FPevalamplitudeperiod * 3 / 2

    % if they asked for the gluons to be flipped
    ifstyle@flip
    % save the maximum height of the curve
    FPevalymaxamplitude
    % save the minimum value of the curve
    FPevalymin0-amplitude
    else
    % save the maximum height of the curve
    FPevalymax0-amplitude
    % save the minimum value of the curve
    FPevalyminamplitude
    fi

    % store the minimum height
    % for each period that we have to draw
    foreach loopNumber in 0,...,nLoops
    % compute the starting location
    FPevalxloopNumber * period
    % compute the midpoint
    FPevalxMidhalfPeriod + x
    % compute the endpoint
    FPevalxFinalperiod + x
    % style the period
    draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
    rotate=angle, xscale=scale, yscale=scale]
    % place the period
    (x,0) .. controls (xMid, ymin) and (xMid, ymax) .. (xFinal, 0);


    % draw the label
    drawLabel#2#3
    endgroup



    % gluinos
    newcommand*gluino[3]
    % scope the configuration options
    begingroup
    % load the configuration parameters
    setkeysstyle#1
    % enforce that endcaps is true
    setkeysstyleendcaps=true
    % draw a fermion between the two points
    fermion#2#3
    % draw a gluon between the two points
    gluon#2#3
    % draw the label
    drawLabel#2#3
    endgroup



    % sfermions
    newcommand*sfermion[3]
    % scope the configuration options
    begingroup
    % load the configuration parameters
    setkeysstyle#1
    % enforce that endcaps is true
    setkeysstyleendcaps=true
    % draw a fermion between the two points
    fermion#2#3
    % draw a gluon between the two points
    electroweak#2#3
    % draw the label
    drawLabel#2#3
    endgroup



    %------------------------------------------------------------------------------
    % other objects
    %------------------------------------------------------------------------------

    % circle centered at #2 with radius #3
    newcommand*parton[3]
    % scope the configuration options
    begingroup
    % load the configuration parameters
    setkeysstyle#1
    % parse the color of the line
    definecolorlineColorHTMLstyle@color
    % style the circle
    draw[color=lineColor, line width = style@lineWidth, pattern=parton,
    pattern color=light-gray]
    % draw the circle
    (#2) circle (#3 diagram@unit);
    endgroup



    % text a located at #2 with content #3
    newcommand*text[3]
    % scope the configuration options
    begingroup
    % load the configuration parameters
    setkeysstyle#1
    % parse the color of the line
    definecolorcolorHTMLstyle@color
    % create a node at the location with the given contents
    draw[text=color, anchor=style@location] (#2) node huge #3;
    endgroup



    % draw a label using the coordinate system along the line joining #1 and #2
    newcommand*drawLabel[2]

    % if they provided a value for the label
    ifthenelseequalstyle@label

    % create TikZ coordinates at the end points
    coordinate (start) at (#1);
    coordinate (finish) at (#2);

    % compute the difference between the two points
    pgfpointdiffpgfpointanchorstartcenter
    pgfpointanchorfinishcenter
    pgf@xa=pgf@x
    pgf@ya=pgf@y
    % cast the deltas in the appropriate unit system
    FPevaldXpgfmath@tonumberpgf@xa/72.27
    FPevaldYpgfmath@tonumberpgf@ya/72.27

    % compute the location of the starting coordinate
    pgfpointanchorstartcenter
    pgf@xa=pgf@x
    pgf@ya=pgf@y
    FPevalstartXround(pgfmath@tonumberpgf@xa/72.27, 5)
    FPevalstartYround(pgfmath@tonumberpgf@ya/72.27, 5)

    % store local copies of the target position
    FPevallabelLocationstyle@labelLocation
    FPevallabelDistance0+style@labelDistance

    % compute the location along the line where we belong
    FPeval@temp@locXround(startX + labelLocation * dX, 5)
    FPeval@temp@locYround(startY + labelLocation * dY, 5)

    % if the change in y is zero (infinite slope)
    ifthenelseequaldY0
    FPevallabelX@temp@locX
    FPevallabelY@temp@locY+labelDistance
    % otherwise we are safe to compute the slope

    % compute the slope of the perpendicular line
    FPevalperpSlope0 - dX/dY

    % the points that are perpedicular to the line a distance r away satisfy
    % y = mx
    % x^2 + y^2 = r

    % compute the x that satisfies this equation
    % note: macro can start with because it can never be negative
    FPevalx2(0+labelDistance) * (0+labelDistance) / (1 + (perpSlope * perpSlope))
    FProotxx22
    % compute the y that satisfies this equation
    FPevalyx * perpSlope

    newdimen distance
    distance = labelDistance pt
    newdimen slope
    slope = perpSlope pt

    % if the perpendicular line has positive slope
    ifthenelseslope > 0 pt OR slope = 0 pt
    % if they are a positive distance away
    ifthenelsedistance > 0 pt
    FPevallabelX@temp@locX + x
    FPevallabelY@temp@locY + y
    % otherwise they are a negative distance away

    FPevallabelX@temp@locX - x
    FPevallabelY@temp@locY - y

    % otherwise the perpendicular line as negative slope

    % if the label is a positive distance away
    ifthenelsedistance > 0 pt
    FPevallabelX@temp@locX - x
    % note: the y is negative so we subtract even though we want to add
    FPevallabelY@temp@locY - y
    % otherwise the label is a negative distance from the line

    FPevallabelX@temp@locX + x
    % note: the y is negative so we add even though we want to subtract
    FPevallabelY@temp@locY + y




    % place the label on the right of the coordinates
    deflocright

    % draw the label
    draw[loc] (labelX,labelY) node huge style@label;



    %------------------------------------------------------------------------------
    % cleanup
    %------------------------------------------------------------------------------

    % turn @ back into a special character
    makeatother

    endinput


    % end of file





    share|improve this answer




















      Your Answer







      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "85"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      convertImagesToLinks: false,
      noModals: false,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













       

      draft saved


      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f446144%2fresonance-production-in-feynmf%23new-answer', 'question_page');

      );

      Post as a guest






























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes








      up vote
      8
      down vote













      You mention feynmf in the title but are tagging the question with almost everything... Here a feynmf working start point, to run with latex + mf + latex. (There is surely room for improvement.) It works the same way with feynmp and METAPOST, of course.



      documentclassarticle

      usepackagefeynmf

      begindocument

      beginfmffilediagram
      beginfmfgraph*(100,80)
      fmfstraight
      fmfleftni5
      fmfrightno5
      fmffermioni5,vt,o5
      fmfphantomi1,vb,o1
      fmfphoton,label=$W$vt,vb
      fmffreeze
      fmffermioni1,vb
      fmffermion,label=$Delta^++$vb,vr
      fmffermionvr,o2
      fmffermionvr,o1
      fmflabel$nu_1$i5
      fmflabelpi1
      fmflabelpo1
      fmflabel$mu^-$o5
      fmflabel$pi^+$o2
      endfmfgraph*
      endfmffile
      enddocument


      enter image description here






      share|improve this answer
























        up vote
        8
        down vote













        You mention feynmf in the title but are tagging the question with almost everything... Here a feynmf working start point, to run with latex + mf + latex. (There is surely room for improvement.) It works the same way with feynmp and METAPOST, of course.



        documentclassarticle

        usepackagefeynmf

        begindocument

        beginfmffilediagram
        beginfmfgraph*(100,80)
        fmfstraight
        fmfleftni5
        fmfrightno5
        fmffermioni5,vt,o5
        fmfphantomi1,vb,o1
        fmfphoton,label=$W$vt,vb
        fmffreeze
        fmffermioni1,vb
        fmffermion,label=$Delta^++$vb,vr
        fmffermionvr,o2
        fmffermionvr,o1
        fmflabel$nu_1$i5
        fmflabelpi1
        fmflabelpo1
        fmflabel$mu^-$o5
        fmflabel$pi^+$o2
        endfmfgraph*
        endfmffile
        enddocument


        enter image description here






        share|improve this answer






















          up vote
          8
          down vote










          up vote
          8
          down vote









          You mention feynmf in the title but are tagging the question with almost everything... Here a feynmf working start point, to run with latex + mf + latex. (There is surely room for improvement.) It works the same way with feynmp and METAPOST, of course.



          documentclassarticle

          usepackagefeynmf

          begindocument

          beginfmffilediagram
          beginfmfgraph*(100,80)
          fmfstraight
          fmfleftni5
          fmfrightno5
          fmffermioni5,vt,o5
          fmfphantomi1,vb,o1
          fmfphoton,label=$W$vt,vb
          fmffreeze
          fmffermioni1,vb
          fmffermion,label=$Delta^++$vb,vr
          fmffermionvr,o2
          fmffermionvr,o1
          fmflabel$nu_1$i5
          fmflabelpi1
          fmflabelpo1
          fmflabel$mu^-$o5
          fmflabel$pi^+$o2
          endfmfgraph*
          endfmffile
          enddocument


          enter image description here






          share|improve this answer












          You mention feynmf in the title but are tagging the question with almost everything... Here a feynmf working start point, to run with latex + mf + latex. (There is surely room for improvement.) It works the same way with feynmp and METAPOST, of course.



          documentclassarticle

          usepackagefeynmf

          begindocument

          beginfmffilediagram
          beginfmfgraph*(100,80)
          fmfstraight
          fmfleftni5
          fmfrightno5
          fmffermioni5,vt,o5
          fmfphantomi1,vb,o1
          fmfphoton,label=$W$vt,vb
          fmffreeze
          fmffermioni1,vb
          fmffermion,label=$Delta^++$vb,vr
          fmffermionvr,o2
          fmffermionvr,o1
          fmflabel$nu_1$i5
          fmflabelpi1
          fmflabelpo1
          fmflabel$mu^-$o5
          fmflabel$pi^+$o2
          endfmfgraph*
          endfmffile
          enddocument


          enter image description here







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Aug 15 at 14:29









          campa

          5,91021337




          5,91021337




















              up vote
              6
              down vote













              Very similar to campa's nice answer but with a scalar propagator for the pion. I only post the code of the Feynman diagram.



              beginfmfgraph*(50,40)
              fmflefti1,i2
              fmfrightf1,f2
              fmffermion,label=i1,v1,f1
              fmffermion,label=i2,v2,f2
              fmfphoton,label=$W$v1,v2
              fmffreeze
              fmfphantomf1,f3,h1,h2,h3,f2
              fmfphantomv1,h4,h5,v3,f1
              fmffreeze
              fmfphantomh1,pi,f3
              fmfphantom,label=$Delta^++$v1,v3
              fmfdashesv3,f3
              fmflabel$p$i1
              fmflabel$nu_1$i2
              fmflabel$p$f1
              fmflabel$pi^+$pi
              fmflabel$mu^-$f2
              endfmfgraph*


              enter image description here






              share|improve this answer
















              • 3




                +1 Indeed, I did say in my answer "There is surely room for improvement ;-).
                – campa
                Aug 15 at 14:52















              up vote
              6
              down vote













              Very similar to campa's nice answer but with a scalar propagator for the pion. I only post the code of the Feynman diagram.



              beginfmfgraph*(50,40)
              fmflefti1,i2
              fmfrightf1,f2
              fmffermion,label=i1,v1,f1
              fmffermion,label=i2,v2,f2
              fmfphoton,label=$W$v1,v2
              fmffreeze
              fmfphantomf1,f3,h1,h2,h3,f2
              fmfphantomv1,h4,h5,v3,f1
              fmffreeze
              fmfphantomh1,pi,f3
              fmfphantom,label=$Delta^++$v1,v3
              fmfdashesv3,f3
              fmflabel$p$i1
              fmflabel$nu_1$i2
              fmflabel$p$f1
              fmflabel$pi^+$pi
              fmflabel$mu^-$f2
              endfmfgraph*


              enter image description here






              share|improve this answer
















              • 3




                +1 Indeed, I did say in my answer "There is surely room for improvement ;-).
                – campa
                Aug 15 at 14:52













              up vote
              6
              down vote










              up vote
              6
              down vote









              Very similar to campa's nice answer but with a scalar propagator for the pion. I only post the code of the Feynman diagram.



              beginfmfgraph*(50,40)
              fmflefti1,i2
              fmfrightf1,f2
              fmffermion,label=i1,v1,f1
              fmffermion,label=i2,v2,f2
              fmfphoton,label=$W$v1,v2
              fmffreeze
              fmfphantomf1,f3,h1,h2,h3,f2
              fmfphantomv1,h4,h5,v3,f1
              fmffreeze
              fmfphantomh1,pi,f3
              fmfphantom,label=$Delta^++$v1,v3
              fmfdashesv3,f3
              fmflabel$p$i1
              fmflabel$nu_1$i2
              fmflabel$p$f1
              fmflabel$pi^+$pi
              fmflabel$mu^-$f2
              endfmfgraph*


              enter image description here






              share|improve this answer












              Very similar to campa's nice answer but with a scalar propagator for the pion. I only post the code of the Feynman diagram.



              beginfmfgraph*(50,40)
              fmflefti1,i2
              fmfrightf1,f2
              fmffermion,label=i1,v1,f1
              fmffermion,label=i2,v2,f2
              fmfphoton,label=$W$v1,v2
              fmffreeze
              fmfphantomf1,f3,h1,h2,h3,f2
              fmfphantomv1,h4,h5,v3,f1
              fmffreeze
              fmfphantomh1,pi,f3
              fmfphantom,label=$Delta^++$v1,v3
              fmfdashesv3,f3
              fmflabel$p$i1
              fmflabel$nu_1$i2
              fmflabel$p$f1
              fmflabel$pi^+$pi
              fmflabel$mu^-$f2
              endfmfgraph*


              enter image description here







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Aug 15 at 14:39









              marmot

              58.3k463126




              58.3k463126







              • 3




                +1 Indeed, I did say in my answer "There is surely room for improvement ;-).
                – campa
                Aug 15 at 14:52













              • 3




                +1 Indeed, I did say in my answer "There is surely room for improvement ;-).
                – campa
                Aug 15 at 14:52








              3




              3




              +1 Indeed, I did say in my answer "There is surely room for improvement ;-).
              – campa
              Aug 15 at 14:52





              +1 Indeed, I did say in my answer "There is surely room for improvement ;-).
              – campa
              Aug 15 at 14:52











              up vote
              3
              down vote













              Using usepackagefeynman, https://ctan.org/tex-archive/macros/latex209/contrib/feynman



              documentclass[a4paper,12pt]article

              usepackagemathtools
              usepackagefeynman
              usetikzlibrarypatterns, arrows, decorations.pathreplacing, decorations.markings
              begindocument

              beginfeynman
              fermion6.20, 1.207.20, 2.20
              fermion0.20, 5.203.20, 4.20
              electroweak3.20, 2.203.20, 4.20
              fermion3.20, 2.206.20, 1.20
              fermion3.20, 4.206.20, 5.20
              fermion[lineWidth=2]6.20, 1.207.20, 2.20
              fermion0.20, 1.203.20, 2.20
              fermion[showArrow=true, flip=true]7.20, 0.206.20, 1.20
              text5.00,2.20Delta^++
              text1.00,0.90p
              text5.60,4.60mu^-
              text6.60,0.20p
              text0.90,4.50v_1
              text6.70,2.20pi^+
              endfeynman

              enddocument


              Here I have added feynman.sty (to save as .sty).



              NeedsTeXFormatLaTeX2e
              ProvidesPackagefeynman
              [2015/02/01 v0.8 LaTeX package for drawing feynman diagrams with an interface similar to the one found at feynman.aivazis.com]

              RequirePackagexcolor
              RequirePackagetikz
              RequirePackagexifthen
              RequirePackagekvoptions
              RequirePackagefp

              usetikzlibrarypatterns, arrows, decorations.pathreplacing, decorations.markings

              % turn off the fp messages
              FPmessagesfalse

              % treat @ like a normal letter
              makeatletter


              %------------------------------------------------------------------------------
              % configuration parameters
              %------------------------------------------------------------------------------

              % define the diagram configuration settings family
              SetupKeyvalOptionsfamily=diagram, prefix=diagram@
              DeclareStringOption[in]unit
              DeclareStringOption[An Example Feynman Diagram]title

              % define the propagator configuration settings family
              SetupKeyvalOptionsfamily=style, prefix=style@
              DeclareStringOption[000000]color
              DeclareStringOption[2]lineWidth
              DeclareBoolOption[true]endcaps
              DeclareStringOption[1/3]gluonWidth
              DeclareStringOption[center]location
              DeclareStringOptionlabel
              DeclareStringOption[0.5]labelDistance
              DeclareStringOption[0.5]labelLocation
              DeclareBoolOption[true]showArrow
              DeclareBoolOption[false]flip


              %------------------------------------------------------------------------------
              % the feynman diagram environment
              %------------------------------------------------------------------------------

              % define an enviroment to encompass a single diagram
              newenvironmentfeynman[1]
              % before the content

              % load the diagram configuration settings
              setkeysdiagram#1
              % start the tikz environment
              begintikzpicture[x=1diagram@unit, y=1diagram@unit]

              % after the content

              % close the tikz environment
              endtikzpicture



              %------------------------------------------------------------------------------
              % utility macros
              %------------------------------------------------------------------------------

              % convert a particular length to the designated unit
              % i.e. converttomm1pt
              newcommand*convertto[2]strip@ptdimexpr #2*65536/numberdimexpr 1#1

              % compute the length between two points
              defcalcLength(#1,#2)#3
              % compute the delta between two points
              pgfpointdiffpgfpointanchor#1center
              pgfpointanchor#2center
              pgf@xa=pgf@x
              pgf@ya=pgf@y
              % cast the deltas in the appropriate unit system
              FPeval@temp@apgfmath@tonumberpgf@xa/72.27
              FPeval@temp@bpgfmath@tonumberpgf@ya/72.27

              % store the sum of the squares
              FPeval@temp@sum(@temp@a*@temp@a+@temp@b*@temp@b)
              % take the square root of the result
              FProotFPMathLen@temp@sum2
              % cut off at 5 decimal places
              FProundFPMathLenFPMathLen9relax
              % set the value of the macro we were given
              expandafteredefcsname #3endcsnameFPMathLen


              % compute the angle between two points
              defcalcAngle(#1,#2)#3
              % compute the difference between the two points
              pgfpointdiffpgfpointanchor#1center
              pgfpointanchor#2center
              % extract the delta between the two points
              pgf@xa=pgf@x
              pgf@ya=pgf@y
              % cast the deltas as numbers
              FPevaldeltaXpgfmath@tonumberpgf@xa
              FPevaldeltaYpgfmath@tonumberpgf@ya
              % use pgf to compute atan2
              pgfmathparseatan2(deltaY, deltaX)
              % set the angle to the result
              FPevalangleround(pgfmathresult , 5)

              % set the value of the macro we were given
              expandafteredefcsname #3endcsnameangle


              % shortcut macro to print an expression to the console
              newcommand*print[1]typeout#1


              %------------------------------------------------------------------------------
              % patterns and colors
              %------------------------------------------------------------------------------

              % declare the parameters for the pattern
              tikzset
              hatch distance/.store in=hatchdistance,
              hatch distance=10pt,
              hatch thickness/.store in=hatchthickness,
              hatch thickness=1pt

              % define the parton fill pattern
              pgfdeclarepatternformonly[hatchdistance,hatchthickness]parton
              % declare the origin
              pgfqpoint0pt0pt
              % define the variables in this coordinate system
              pgfqpointhatchdistancehatchdistance
              pgfpointhatchdistance-1pthatchdistance-1pt
              % set up the pattern

              pgfsetcolortikz@pattern@color
              pgfsetlinewidthhatchthickness
              pgfpathmovetopgfqpoint0pt0pt
              pgfpathlinetopgfqpointhatchdistancehatchdistance
              pgfusepathstroke



              % define the arrow style
              tikzset
              arrow/.style=
              decoration=
              markings,
              mark=at position .5 with
              arrow[#1, scale=1.5]latex

              ,
              postaction=decorate,


              tikzset
              arrow flipped/.style=
              decoration=
              markings,
              mark=at position .5 with
              arrow[#1, scale=1.5]latex reversed

              ,
              postaction=decorate,




              % define a light gray to be used as a fill color for partons
              definecolorlight-graygray.7

              %------------------------------------------------------------------------------
              % text macros
              %------------------------------------------------------------------------------

              % overline with variable width (the second brace)
              newcommand*anti[2][1.0]
              overline#2


              % overline with variable width (the second brace)
              newcommand*txt[1]
              textrm#1


              %------------------------------------------------------------------------------
              % propagator styles
              %------------------------------------------------------------------------------

              % fermions
              newcommand*fermion[3]
              % scope the configuration options
              begingroup
              % load the configuration parameters
              setkeysstyle#1

              % parse the color of the line
              definecolorlineColorHTMLstyle@color

              % if they asked to draw the arrow
              ifstyle@showArrow
              ifstyle@flip
              % draw the line with an arrow
              draw[color=lineColor, line width = style@lineWidth, arrow flipped] (#2) -- (#3);
              else
              % draw the line with an arrow
              draw[color=lineColor, line width = style@lineWidth, arrow] (#2) -- (#3);
              fi
              % otherwise they did not ask to draw the arrow
              else
              % draw the line
              draw[color=lineColor, line width = style@lineWidth] (#2) -- (#3);
              fi

              % draw the label
              drawLabel#2#3
              endgroup



              % dashed propagators
              newcommand*dashed[3]
              % scope the configuration options
              begingroup
              % load the configuration parameters
              setkeysstyle#1

              % parse the color of the line
              definecolorlineColorHTMLstyle@color

              % if they asked to draw the arrow
              ifstyle@showArrow
              ifstyle@flip
              % draw the line with an arrow
              draw[dashed, color=lineColor, line width = style@lineWidth, arrow flipped=lineColor] (#2) -- (#3);
              else
              % draw the line with an arrow
              draw[dashed, color=lineColor, line width = style@lineWidth, arrow=lineColor] (#2) -- (#3);
              fi
              % otherwise they did not ask to draw the arrow
              else
              % draw the line
              draw[dashed, color=lineColor, line width = style@lineWidth] (#2) -- (#3);
              fi

              % draw the label
              drawLabel#2#3
              endgroup



              % gluons
              newcommand*gluon[3]
              % scope the configuration options
              begingroup
              % load the configuration parameters
              setkeysstyle#1

              % create TikZ coordinates at the end points
              coordinate (start) at (#2);
              coordinate (finish) at (#3);
              % store the distance between the two points
              calcLength(start,finish)length % stores it in a macro called length
              % store the angle between the two points
              calcAngle(start,finish)angle % stores it in a macro called angle

              % turn the start coordinate into a pgf point
              pgfpointanchorstartcenter
              FPevalstartXpgfmath@tonumberpgf@x
              FPevalstartYpgfmath@tonumberpgf@y

              FPevalgluonWidthstyle@gluonWidth
              % store a value for half of the gluonWidth
              FPevalhalfWidthgluonWidth/2
              % store the closest whole number of full periods
              FPevalnLoopsround((length / gluonWidth ) - 1, 0)
              FPevaltotalLength(nLoops+1) * gluonWidth
              FPevalscalelength / totalLength
              % parse the color of the line
              definecolorlineColorHTMLstyle@color

              % if we dont fit a whole loop between the two points
              ifthenelseequalnLoops0
              % use a fermion line instead
              fermion#2#3

              % we fit at least one loop between the two points


              % if they want the end caps (to draw the right kind of line)
              ifstyle@endcaps
              % if they asked to flip the loops
              ifstyle@flip
              % set the maximum value to be positive
              FPevalymaxhalfWidth
              FPevalymin0-halfWidth
              % otherwise draw the loops right side up
              else
              % set the maximum value to be negative
              FPevalymax0-halfWidth
              FPevalyminhalfWidth
              fi

              % style the opening end cap
              draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
              rotate=angle, xscale=scale, yscale=scale]
              % draw the opening end cap
              (0,0) .. controls (halfWidth, 0) and (0, ymin) .. (halfWidth, ymin);
              % for each loop that we have to draw
              foreach loopNumber in 1,...,nLoops
              % compute the starting location of the loop
              FPevalxloopNumber * gluonWidth - halfWidth
              % compute the half way point of the loop
              FPevalxMidhalfWidth + x
              % compute the endpoint of the loop
              FPevalxFinalgluonWidth + x

              % style the first half of the loop
              draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
              rotate=angle, xscale=scale, yscale=scale]
              % draw the first half of the loop
              (x, ymin) .. controls (xFinal, ymin) and (xFinal, ymax) .. (xMid, ymax);
              % style the second half of the loop
              draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
              rotate=angle, xscale=scale, yscale=scale]
              % draw the second half of the loop
              (xMid, ymax) .. controls (x, ymax) and (x, ymin) .. (xFinal, ymin);


              % compute the locations for the closing end cap
              FPevalfinalStart(nLoops+1) * gluonWidth - halfWidth
              FPevalfinalHalffinalStart + halfWidth
              FPevalfinalStopfinalStart + halfWidth
              % style the closing end cap
              draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
              rotate=angle, xscale=scale, yscale=scale]
              % draw the closing end cap
              (finalStart, ymin) .. controls (finalStop, ymin) and (finalStart, 0) .. (finalStop, 0);

              % they did not want end caps
              else
              % if they asked for the gluons to be flipped
              ifstyle@flip
              % store a value for the height of the gluon loop
              FPevalheight0-gluonWidth
              else
              % store a value for the height of the gluon loop
              FPevalheightgluonWidth
              fi

              % for each loop that we have to draw
              foreach loopNumber in 0,...,nLoops
              % compute the starting location of the loop
              FPevalxloopNumber * gluonWidth
              % compute the midpoint of the loop
              FPevalxMidhalfWidth + x
              % compute the endpoint of the loop
              FPevalxFinalgluonWidth + x
              % style the first half of the loop
              draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
              rotate=angle, xscale=scale, yscale=scale]
              % draw the first half of the loop
              (x,0) .. controls (xFinal, 0) and (xFinal, height) .. (xMid, height);
              % style the second half of the loop
              draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
              rotate=angle, xscale=scale, yscale=scale]
              % draw the second half of the loop
              (xMid,height) .. controls (x, height) and (x, 0) .. (xFinal, 0);

              fi

              % draw the label
              drawLabel#2#3
              endgroup



              % electroweak lines
              newcommand*electroweak[3]
              % scope the configuration options
              begingroup
              % load the configuration parameters
              setkeysstyle#1

              % create TikZ coordinates at the end points
              coordinate (start) at (#2);
              coordinate (finish) at (#3);
              % store the distance between the two points
              calcLength(start,finish)length % stores it in a macro called length
              % store the angle between the two points
              calcAngle(start,finish)angle % stores it in a macro called angle

              % turn the start coordinate into a pgf point
              pgfpointanchorstartcenter
              FPevalstartXpgfmath@tonumberpgf@x
              FPevalstartYpgfmath@tonumberpgf@y

              FPevalperiodstyle@gluonWidth
              % store a value for half of the gluonWidth
              FPevalhalfPeriodperiod/2
              % store the closest whole number of full periods
              FPevalnLoopsround((length / period ) - 1, 0)
              FPevaltotalLength(nLoops+1) * period
              FPevalscalelength / totalLength
              % parse the color of the line
              definecolorlineColorHTMLstyle@color

              % if we dont fit a whole loop between the two points
              ifthenelseequalnLoops0
              % use a fermion line instead
              fermion#2#3

              % we fit at least one loop between the two points

              % store the amplitude of the curve
              FPevalamplitudeperiod * 3 / 2

              % if they asked for the gluons to be flipped
              ifstyle@flip
              % save the maximum height of the curve
              FPevalymaxamplitude
              % save the minimum value of the curve
              FPevalymin0-amplitude
              else
              % save the maximum height of the curve
              FPevalymax0-amplitude
              % save the minimum value of the curve
              FPevalyminamplitude
              fi

              % store the minimum height
              % for each period that we have to draw
              foreach loopNumber in 0,...,nLoops
              % compute the starting location
              FPevalxloopNumber * period
              % compute the midpoint
              FPevalxMidhalfPeriod + x
              % compute the endpoint
              FPevalxFinalperiod + x
              % style the period
              draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
              rotate=angle, xscale=scale, yscale=scale]
              % place the period
              (x,0) .. controls (xMid, ymin) and (xMid, ymax) .. (xFinal, 0);


              % draw the label
              drawLabel#2#3
              endgroup



              % gluinos
              newcommand*gluino[3]
              % scope the configuration options
              begingroup
              % load the configuration parameters
              setkeysstyle#1
              % enforce that endcaps is true
              setkeysstyleendcaps=true
              % draw a fermion between the two points
              fermion#2#3
              % draw a gluon between the two points
              gluon#2#3
              % draw the label
              drawLabel#2#3
              endgroup



              % sfermions
              newcommand*sfermion[3]
              % scope the configuration options
              begingroup
              % load the configuration parameters
              setkeysstyle#1
              % enforce that endcaps is true
              setkeysstyleendcaps=true
              % draw a fermion between the two points
              fermion#2#3
              % draw a gluon between the two points
              electroweak#2#3
              % draw the label
              drawLabel#2#3
              endgroup



              %------------------------------------------------------------------------------
              % other objects
              %------------------------------------------------------------------------------

              % circle centered at #2 with radius #3
              newcommand*parton[3]
              % scope the configuration options
              begingroup
              % load the configuration parameters
              setkeysstyle#1
              % parse the color of the line
              definecolorlineColorHTMLstyle@color
              % style the circle
              draw[color=lineColor, line width = style@lineWidth, pattern=parton,
              pattern color=light-gray]
              % draw the circle
              (#2) circle (#3 diagram@unit);
              endgroup



              % text a located at #2 with content #3
              newcommand*text[3]
              % scope the configuration options
              begingroup
              % load the configuration parameters
              setkeysstyle#1
              % parse the color of the line
              definecolorcolorHTMLstyle@color
              % create a node at the location with the given contents
              draw[text=color, anchor=style@location] (#2) node huge #3;
              endgroup



              % draw a label using the coordinate system along the line joining #1 and #2
              newcommand*drawLabel[2]

              % if they provided a value for the label
              ifthenelseequalstyle@label

              % create TikZ coordinates at the end points
              coordinate (start) at (#1);
              coordinate (finish) at (#2);

              % compute the difference between the two points
              pgfpointdiffpgfpointanchorstartcenter
              pgfpointanchorfinishcenter
              pgf@xa=pgf@x
              pgf@ya=pgf@y
              % cast the deltas in the appropriate unit system
              FPevaldXpgfmath@tonumberpgf@xa/72.27
              FPevaldYpgfmath@tonumberpgf@ya/72.27

              % compute the location of the starting coordinate
              pgfpointanchorstartcenter
              pgf@xa=pgf@x
              pgf@ya=pgf@y
              FPevalstartXround(pgfmath@tonumberpgf@xa/72.27, 5)
              FPevalstartYround(pgfmath@tonumberpgf@ya/72.27, 5)

              % store local copies of the target position
              FPevallabelLocationstyle@labelLocation
              FPevallabelDistance0+style@labelDistance

              % compute the location along the line where we belong
              FPeval@temp@locXround(startX + labelLocation * dX, 5)
              FPeval@temp@locYround(startY + labelLocation * dY, 5)

              % if the change in y is zero (infinite slope)
              ifthenelseequaldY0
              FPevallabelX@temp@locX
              FPevallabelY@temp@locY+labelDistance
              % otherwise we are safe to compute the slope

              % compute the slope of the perpendicular line
              FPevalperpSlope0 - dX/dY

              % the points that are perpedicular to the line a distance r away satisfy
              % y = mx
              % x^2 + y^2 = r

              % compute the x that satisfies this equation
              % note: macro can start with because it can never be negative
              FPevalx2(0+labelDistance) * (0+labelDistance) / (1 + (perpSlope * perpSlope))
              FProotxx22
              % compute the y that satisfies this equation
              FPevalyx * perpSlope

              newdimen distance
              distance = labelDistance pt
              newdimen slope
              slope = perpSlope pt

              % if the perpendicular line has positive slope
              ifthenelseslope > 0 pt OR slope = 0 pt
              % if they are a positive distance away
              ifthenelsedistance > 0 pt
              FPevallabelX@temp@locX + x
              FPevallabelY@temp@locY + y
              % otherwise they are a negative distance away

              FPevallabelX@temp@locX - x
              FPevallabelY@temp@locY - y

              % otherwise the perpendicular line as negative slope

              % if the label is a positive distance away
              ifthenelsedistance > 0 pt
              FPevallabelX@temp@locX - x
              % note: the y is negative so we subtract even though we want to add
              FPevallabelY@temp@locY - y
              % otherwise the label is a negative distance from the line

              FPevallabelX@temp@locX + x
              % note: the y is negative so we add even though we want to subtract
              FPevallabelY@temp@locY + y




              % place the label on the right of the coordinates
              deflocright

              % draw the label
              draw[loc] (labelX,labelY) node huge style@label;



              %------------------------------------------------------------------------------
              % cleanup
              %------------------------------------------------------------------------------

              % turn @ back into a special character
              makeatother

              endinput


              % end of file





              share|improve this answer
























                up vote
                3
                down vote













                Using usepackagefeynman, https://ctan.org/tex-archive/macros/latex209/contrib/feynman



                documentclass[a4paper,12pt]article

                usepackagemathtools
                usepackagefeynman
                usetikzlibrarypatterns, arrows, decorations.pathreplacing, decorations.markings
                begindocument

                beginfeynman
                fermion6.20, 1.207.20, 2.20
                fermion0.20, 5.203.20, 4.20
                electroweak3.20, 2.203.20, 4.20
                fermion3.20, 2.206.20, 1.20
                fermion3.20, 4.206.20, 5.20
                fermion[lineWidth=2]6.20, 1.207.20, 2.20
                fermion0.20, 1.203.20, 2.20
                fermion[showArrow=true, flip=true]7.20, 0.206.20, 1.20
                text5.00,2.20Delta^++
                text1.00,0.90p
                text5.60,4.60mu^-
                text6.60,0.20p
                text0.90,4.50v_1
                text6.70,2.20pi^+
                endfeynman

                enddocument


                Here I have added feynman.sty (to save as .sty).



                NeedsTeXFormatLaTeX2e
                ProvidesPackagefeynman
                [2015/02/01 v0.8 LaTeX package for drawing feynman diagrams with an interface similar to the one found at feynman.aivazis.com]

                RequirePackagexcolor
                RequirePackagetikz
                RequirePackagexifthen
                RequirePackagekvoptions
                RequirePackagefp

                usetikzlibrarypatterns, arrows, decorations.pathreplacing, decorations.markings

                % turn off the fp messages
                FPmessagesfalse

                % treat @ like a normal letter
                makeatletter


                %------------------------------------------------------------------------------
                % configuration parameters
                %------------------------------------------------------------------------------

                % define the diagram configuration settings family
                SetupKeyvalOptionsfamily=diagram, prefix=diagram@
                DeclareStringOption[in]unit
                DeclareStringOption[An Example Feynman Diagram]title

                % define the propagator configuration settings family
                SetupKeyvalOptionsfamily=style, prefix=style@
                DeclareStringOption[000000]color
                DeclareStringOption[2]lineWidth
                DeclareBoolOption[true]endcaps
                DeclareStringOption[1/3]gluonWidth
                DeclareStringOption[center]location
                DeclareStringOptionlabel
                DeclareStringOption[0.5]labelDistance
                DeclareStringOption[0.5]labelLocation
                DeclareBoolOption[true]showArrow
                DeclareBoolOption[false]flip


                %------------------------------------------------------------------------------
                % the feynman diagram environment
                %------------------------------------------------------------------------------

                % define an enviroment to encompass a single diagram
                newenvironmentfeynman[1]
                % before the content

                % load the diagram configuration settings
                setkeysdiagram#1
                % start the tikz environment
                begintikzpicture[x=1diagram@unit, y=1diagram@unit]

                % after the content

                % close the tikz environment
                endtikzpicture



                %------------------------------------------------------------------------------
                % utility macros
                %------------------------------------------------------------------------------

                % convert a particular length to the designated unit
                % i.e. converttomm1pt
                newcommand*convertto[2]strip@ptdimexpr #2*65536/numberdimexpr 1#1

                % compute the length between two points
                defcalcLength(#1,#2)#3
                % compute the delta between two points
                pgfpointdiffpgfpointanchor#1center
                pgfpointanchor#2center
                pgf@xa=pgf@x
                pgf@ya=pgf@y
                % cast the deltas in the appropriate unit system
                FPeval@temp@apgfmath@tonumberpgf@xa/72.27
                FPeval@temp@bpgfmath@tonumberpgf@ya/72.27

                % store the sum of the squares
                FPeval@temp@sum(@temp@a*@temp@a+@temp@b*@temp@b)
                % take the square root of the result
                FProotFPMathLen@temp@sum2
                % cut off at 5 decimal places
                FProundFPMathLenFPMathLen9relax
                % set the value of the macro we were given
                expandafteredefcsname #3endcsnameFPMathLen


                % compute the angle between two points
                defcalcAngle(#1,#2)#3
                % compute the difference between the two points
                pgfpointdiffpgfpointanchor#1center
                pgfpointanchor#2center
                % extract the delta between the two points
                pgf@xa=pgf@x
                pgf@ya=pgf@y
                % cast the deltas as numbers
                FPevaldeltaXpgfmath@tonumberpgf@xa
                FPevaldeltaYpgfmath@tonumberpgf@ya
                % use pgf to compute atan2
                pgfmathparseatan2(deltaY, deltaX)
                % set the angle to the result
                FPevalangleround(pgfmathresult , 5)

                % set the value of the macro we were given
                expandafteredefcsname #3endcsnameangle


                % shortcut macro to print an expression to the console
                newcommand*print[1]typeout#1


                %------------------------------------------------------------------------------
                % patterns and colors
                %------------------------------------------------------------------------------

                % declare the parameters for the pattern
                tikzset
                hatch distance/.store in=hatchdistance,
                hatch distance=10pt,
                hatch thickness/.store in=hatchthickness,
                hatch thickness=1pt

                % define the parton fill pattern
                pgfdeclarepatternformonly[hatchdistance,hatchthickness]parton
                % declare the origin
                pgfqpoint0pt0pt
                % define the variables in this coordinate system
                pgfqpointhatchdistancehatchdistance
                pgfpointhatchdistance-1pthatchdistance-1pt
                % set up the pattern

                pgfsetcolortikz@pattern@color
                pgfsetlinewidthhatchthickness
                pgfpathmovetopgfqpoint0pt0pt
                pgfpathlinetopgfqpointhatchdistancehatchdistance
                pgfusepathstroke



                % define the arrow style
                tikzset
                arrow/.style=
                decoration=
                markings,
                mark=at position .5 with
                arrow[#1, scale=1.5]latex

                ,
                postaction=decorate,


                tikzset
                arrow flipped/.style=
                decoration=
                markings,
                mark=at position .5 with
                arrow[#1, scale=1.5]latex reversed

                ,
                postaction=decorate,




                % define a light gray to be used as a fill color for partons
                definecolorlight-graygray.7

                %------------------------------------------------------------------------------
                % text macros
                %------------------------------------------------------------------------------

                % overline with variable width (the second brace)
                newcommand*anti[2][1.0]
                overline#2


                % overline with variable width (the second brace)
                newcommand*txt[1]
                textrm#1


                %------------------------------------------------------------------------------
                % propagator styles
                %------------------------------------------------------------------------------

                % fermions
                newcommand*fermion[3]
                % scope the configuration options
                begingroup
                % load the configuration parameters
                setkeysstyle#1

                % parse the color of the line
                definecolorlineColorHTMLstyle@color

                % if they asked to draw the arrow
                ifstyle@showArrow
                ifstyle@flip
                % draw the line with an arrow
                draw[color=lineColor, line width = style@lineWidth, arrow flipped] (#2) -- (#3);
                else
                % draw the line with an arrow
                draw[color=lineColor, line width = style@lineWidth, arrow] (#2) -- (#3);
                fi
                % otherwise they did not ask to draw the arrow
                else
                % draw the line
                draw[color=lineColor, line width = style@lineWidth] (#2) -- (#3);
                fi

                % draw the label
                drawLabel#2#3
                endgroup



                % dashed propagators
                newcommand*dashed[3]
                % scope the configuration options
                begingroup
                % load the configuration parameters
                setkeysstyle#1

                % parse the color of the line
                definecolorlineColorHTMLstyle@color

                % if they asked to draw the arrow
                ifstyle@showArrow
                ifstyle@flip
                % draw the line with an arrow
                draw[dashed, color=lineColor, line width = style@lineWidth, arrow flipped=lineColor] (#2) -- (#3);
                else
                % draw the line with an arrow
                draw[dashed, color=lineColor, line width = style@lineWidth, arrow=lineColor] (#2) -- (#3);
                fi
                % otherwise they did not ask to draw the arrow
                else
                % draw the line
                draw[dashed, color=lineColor, line width = style@lineWidth] (#2) -- (#3);
                fi

                % draw the label
                drawLabel#2#3
                endgroup



                % gluons
                newcommand*gluon[3]
                % scope the configuration options
                begingroup
                % load the configuration parameters
                setkeysstyle#1

                % create TikZ coordinates at the end points
                coordinate (start) at (#2);
                coordinate (finish) at (#3);
                % store the distance between the two points
                calcLength(start,finish)length % stores it in a macro called length
                % store the angle between the two points
                calcAngle(start,finish)angle % stores it in a macro called angle

                % turn the start coordinate into a pgf point
                pgfpointanchorstartcenter
                FPevalstartXpgfmath@tonumberpgf@x
                FPevalstartYpgfmath@tonumberpgf@y

                FPevalgluonWidthstyle@gluonWidth
                % store a value for half of the gluonWidth
                FPevalhalfWidthgluonWidth/2
                % store the closest whole number of full periods
                FPevalnLoopsround((length / gluonWidth ) - 1, 0)
                FPevaltotalLength(nLoops+1) * gluonWidth
                FPevalscalelength / totalLength
                % parse the color of the line
                definecolorlineColorHTMLstyle@color

                % if we dont fit a whole loop between the two points
                ifthenelseequalnLoops0
                % use a fermion line instead
                fermion#2#3

                % we fit at least one loop between the two points


                % if they want the end caps (to draw the right kind of line)
                ifstyle@endcaps
                % if they asked to flip the loops
                ifstyle@flip
                % set the maximum value to be positive
                FPevalymaxhalfWidth
                FPevalymin0-halfWidth
                % otherwise draw the loops right side up
                else
                % set the maximum value to be negative
                FPevalymax0-halfWidth
                FPevalyminhalfWidth
                fi

                % style the opening end cap
                draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
                rotate=angle, xscale=scale, yscale=scale]
                % draw the opening end cap
                (0,0) .. controls (halfWidth, 0) and (0, ymin) .. (halfWidth, ymin);
                % for each loop that we have to draw
                foreach loopNumber in 1,...,nLoops
                % compute the starting location of the loop
                FPevalxloopNumber * gluonWidth - halfWidth
                % compute the half way point of the loop
                FPevalxMidhalfWidth + x
                % compute the endpoint of the loop
                FPevalxFinalgluonWidth + x

                % style the first half of the loop
                draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
                rotate=angle, xscale=scale, yscale=scale]
                % draw the first half of the loop
                (x, ymin) .. controls (xFinal, ymin) and (xFinal, ymax) .. (xMid, ymax);
                % style the second half of the loop
                draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
                rotate=angle, xscale=scale, yscale=scale]
                % draw the second half of the loop
                (xMid, ymax) .. controls (x, ymax) and (x, ymin) .. (xFinal, ymin);


                % compute the locations for the closing end cap
                FPevalfinalStart(nLoops+1) * gluonWidth - halfWidth
                FPevalfinalHalffinalStart + halfWidth
                FPevalfinalStopfinalStart + halfWidth
                % style the closing end cap
                draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
                rotate=angle, xscale=scale, yscale=scale]
                % draw the closing end cap
                (finalStart, ymin) .. controls (finalStop, ymin) and (finalStart, 0) .. (finalStop, 0);

                % they did not want end caps
                else
                % if they asked for the gluons to be flipped
                ifstyle@flip
                % store a value for the height of the gluon loop
                FPevalheight0-gluonWidth
                else
                % store a value for the height of the gluon loop
                FPevalheightgluonWidth
                fi

                % for each loop that we have to draw
                foreach loopNumber in 0,...,nLoops
                % compute the starting location of the loop
                FPevalxloopNumber * gluonWidth
                % compute the midpoint of the loop
                FPevalxMidhalfWidth + x
                % compute the endpoint of the loop
                FPevalxFinalgluonWidth + x
                % style the first half of the loop
                draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
                rotate=angle, xscale=scale, yscale=scale]
                % draw the first half of the loop
                (x,0) .. controls (xFinal, 0) and (xFinal, height) .. (xMid, height);
                % style the second half of the loop
                draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
                rotate=angle, xscale=scale, yscale=scale]
                % draw the second half of the loop
                (xMid,height) .. controls (x, height) and (x, 0) .. (xFinal, 0);

                fi

                % draw the label
                drawLabel#2#3
                endgroup



                % electroweak lines
                newcommand*electroweak[3]
                % scope the configuration options
                begingroup
                % load the configuration parameters
                setkeysstyle#1

                % create TikZ coordinates at the end points
                coordinate (start) at (#2);
                coordinate (finish) at (#3);
                % store the distance between the two points
                calcLength(start,finish)length % stores it in a macro called length
                % store the angle between the two points
                calcAngle(start,finish)angle % stores it in a macro called angle

                % turn the start coordinate into a pgf point
                pgfpointanchorstartcenter
                FPevalstartXpgfmath@tonumberpgf@x
                FPevalstartYpgfmath@tonumberpgf@y

                FPevalperiodstyle@gluonWidth
                % store a value for half of the gluonWidth
                FPevalhalfPeriodperiod/2
                % store the closest whole number of full periods
                FPevalnLoopsround((length / period ) - 1, 0)
                FPevaltotalLength(nLoops+1) * period
                FPevalscalelength / totalLength
                % parse the color of the line
                definecolorlineColorHTMLstyle@color

                % if we dont fit a whole loop between the two points
                ifthenelseequalnLoops0
                % use a fermion line instead
                fermion#2#3

                % we fit at least one loop between the two points

                % store the amplitude of the curve
                FPevalamplitudeperiod * 3 / 2

                % if they asked for the gluons to be flipped
                ifstyle@flip
                % save the maximum height of the curve
                FPevalymaxamplitude
                % save the minimum value of the curve
                FPevalymin0-amplitude
                else
                % save the maximum height of the curve
                FPevalymax0-amplitude
                % save the minimum value of the curve
                FPevalyminamplitude
                fi

                % store the minimum height
                % for each period that we have to draw
                foreach loopNumber in 0,...,nLoops
                % compute the starting location
                FPevalxloopNumber * period
                % compute the midpoint
                FPevalxMidhalfPeriod + x
                % compute the endpoint
                FPevalxFinalperiod + x
                % style the period
                draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
                rotate=angle, xscale=scale, yscale=scale]
                % place the period
                (x,0) .. controls (xMid, ymin) and (xMid, ymax) .. (xFinal, 0);


                % draw the label
                drawLabel#2#3
                endgroup



                % gluinos
                newcommand*gluino[3]
                % scope the configuration options
                begingroup
                % load the configuration parameters
                setkeysstyle#1
                % enforce that endcaps is true
                setkeysstyleendcaps=true
                % draw a fermion between the two points
                fermion#2#3
                % draw a gluon between the two points
                gluon#2#3
                % draw the label
                drawLabel#2#3
                endgroup



                % sfermions
                newcommand*sfermion[3]
                % scope the configuration options
                begingroup
                % load the configuration parameters
                setkeysstyle#1
                % enforce that endcaps is true
                setkeysstyleendcaps=true
                % draw a fermion between the two points
                fermion#2#3
                % draw a gluon between the two points
                electroweak#2#3
                % draw the label
                drawLabel#2#3
                endgroup



                %------------------------------------------------------------------------------
                % other objects
                %------------------------------------------------------------------------------

                % circle centered at #2 with radius #3
                newcommand*parton[3]
                % scope the configuration options
                begingroup
                % load the configuration parameters
                setkeysstyle#1
                % parse the color of the line
                definecolorlineColorHTMLstyle@color
                % style the circle
                draw[color=lineColor, line width = style@lineWidth, pattern=parton,
                pattern color=light-gray]
                % draw the circle
                (#2) circle (#3 diagram@unit);
                endgroup



                % text a located at #2 with content #3
                newcommand*text[3]
                % scope the configuration options
                begingroup
                % load the configuration parameters
                setkeysstyle#1
                % parse the color of the line
                definecolorcolorHTMLstyle@color
                % create a node at the location with the given contents
                draw[text=color, anchor=style@location] (#2) node huge #3;
                endgroup



                % draw a label using the coordinate system along the line joining #1 and #2
                newcommand*drawLabel[2]

                % if they provided a value for the label
                ifthenelseequalstyle@label

                % create TikZ coordinates at the end points
                coordinate (start) at (#1);
                coordinate (finish) at (#2);

                % compute the difference between the two points
                pgfpointdiffpgfpointanchorstartcenter
                pgfpointanchorfinishcenter
                pgf@xa=pgf@x
                pgf@ya=pgf@y
                % cast the deltas in the appropriate unit system
                FPevaldXpgfmath@tonumberpgf@xa/72.27
                FPevaldYpgfmath@tonumberpgf@ya/72.27

                % compute the location of the starting coordinate
                pgfpointanchorstartcenter
                pgf@xa=pgf@x
                pgf@ya=pgf@y
                FPevalstartXround(pgfmath@tonumberpgf@xa/72.27, 5)
                FPevalstartYround(pgfmath@tonumberpgf@ya/72.27, 5)

                % store local copies of the target position
                FPevallabelLocationstyle@labelLocation
                FPevallabelDistance0+style@labelDistance

                % compute the location along the line where we belong
                FPeval@temp@locXround(startX + labelLocation * dX, 5)
                FPeval@temp@locYround(startY + labelLocation * dY, 5)

                % if the change in y is zero (infinite slope)
                ifthenelseequaldY0
                FPevallabelX@temp@locX
                FPevallabelY@temp@locY+labelDistance
                % otherwise we are safe to compute the slope

                % compute the slope of the perpendicular line
                FPevalperpSlope0 - dX/dY

                % the points that are perpedicular to the line a distance r away satisfy
                % y = mx
                % x^2 + y^2 = r

                % compute the x that satisfies this equation
                % note: macro can start with because it can never be negative
                FPevalx2(0+labelDistance) * (0+labelDistance) / (1 + (perpSlope * perpSlope))
                FProotxx22
                % compute the y that satisfies this equation
                FPevalyx * perpSlope

                newdimen distance
                distance = labelDistance pt
                newdimen slope
                slope = perpSlope pt

                % if the perpendicular line has positive slope
                ifthenelseslope > 0 pt OR slope = 0 pt
                % if they are a positive distance away
                ifthenelsedistance > 0 pt
                FPevallabelX@temp@locX + x
                FPevallabelY@temp@locY + y
                % otherwise they are a negative distance away

                FPevallabelX@temp@locX - x
                FPevallabelY@temp@locY - y

                % otherwise the perpendicular line as negative slope

                % if the label is a positive distance away
                ifthenelsedistance > 0 pt
                FPevallabelX@temp@locX - x
                % note: the y is negative so we subtract even though we want to add
                FPevallabelY@temp@locY - y
                % otherwise the label is a negative distance from the line

                FPevallabelX@temp@locX + x
                % note: the y is negative so we add even though we want to subtract
                FPevallabelY@temp@locY + y




                % place the label on the right of the coordinates
                deflocright

                % draw the label
                draw[loc] (labelX,labelY) node huge style@label;



                %------------------------------------------------------------------------------
                % cleanup
                %------------------------------------------------------------------------------

                % turn @ back into a special character
                makeatother

                endinput


                % end of file





                share|improve this answer






















                  up vote
                  3
                  down vote










                  up vote
                  3
                  down vote









                  Using usepackagefeynman, https://ctan.org/tex-archive/macros/latex209/contrib/feynman



                  documentclass[a4paper,12pt]article

                  usepackagemathtools
                  usepackagefeynman
                  usetikzlibrarypatterns, arrows, decorations.pathreplacing, decorations.markings
                  begindocument

                  beginfeynman
                  fermion6.20, 1.207.20, 2.20
                  fermion0.20, 5.203.20, 4.20
                  electroweak3.20, 2.203.20, 4.20
                  fermion3.20, 2.206.20, 1.20
                  fermion3.20, 4.206.20, 5.20
                  fermion[lineWidth=2]6.20, 1.207.20, 2.20
                  fermion0.20, 1.203.20, 2.20
                  fermion[showArrow=true, flip=true]7.20, 0.206.20, 1.20
                  text5.00,2.20Delta^++
                  text1.00,0.90p
                  text5.60,4.60mu^-
                  text6.60,0.20p
                  text0.90,4.50v_1
                  text6.70,2.20pi^+
                  endfeynman

                  enddocument


                  Here I have added feynman.sty (to save as .sty).



                  NeedsTeXFormatLaTeX2e
                  ProvidesPackagefeynman
                  [2015/02/01 v0.8 LaTeX package for drawing feynman diagrams with an interface similar to the one found at feynman.aivazis.com]

                  RequirePackagexcolor
                  RequirePackagetikz
                  RequirePackagexifthen
                  RequirePackagekvoptions
                  RequirePackagefp

                  usetikzlibrarypatterns, arrows, decorations.pathreplacing, decorations.markings

                  % turn off the fp messages
                  FPmessagesfalse

                  % treat @ like a normal letter
                  makeatletter


                  %------------------------------------------------------------------------------
                  % configuration parameters
                  %------------------------------------------------------------------------------

                  % define the diagram configuration settings family
                  SetupKeyvalOptionsfamily=diagram, prefix=diagram@
                  DeclareStringOption[in]unit
                  DeclareStringOption[An Example Feynman Diagram]title

                  % define the propagator configuration settings family
                  SetupKeyvalOptionsfamily=style, prefix=style@
                  DeclareStringOption[000000]color
                  DeclareStringOption[2]lineWidth
                  DeclareBoolOption[true]endcaps
                  DeclareStringOption[1/3]gluonWidth
                  DeclareStringOption[center]location
                  DeclareStringOptionlabel
                  DeclareStringOption[0.5]labelDistance
                  DeclareStringOption[0.5]labelLocation
                  DeclareBoolOption[true]showArrow
                  DeclareBoolOption[false]flip


                  %------------------------------------------------------------------------------
                  % the feynman diagram environment
                  %------------------------------------------------------------------------------

                  % define an enviroment to encompass a single diagram
                  newenvironmentfeynman[1]
                  % before the content

                  % load the diagram configuration settings
                  setkeysdiagram#1
                  % start the tikz environment
                  begintikzpicture[x=1diagram@unit, y=1diagram@unit]

                  % after the content

                  % close the tikz environment
                  endtikzpicture



                  %------------------------------------------------------------------------------
                  % utility macros
                  %------------------------------------------------------------------------------

                  % convert a particular length to the designated unit
                  % i.e. converttomm1pt
                  newcommand*convertto[2]strip@ptdimexpr #2*65536/numberdimexpr 1#1

                  % compute the length between two points
                  defcalcLength(#1,#2)#3
                  % compute the delta between two points
                  pgfpointdiffpgfpointanchor#1center
                  pgfpointanchor#2center
                  pgf@xa=pgf@x
                  pgf@ya=pgf@y
                  % cast the deltas in the appropriate unit system
                  FPeval@temp@apgfmath@tonumberpgf@xa/72.27
                  FPeval@temp@bpgfmath@tonumberpgf@ya/72.27

                  % store the sum of the squares
                  FPeval@temp@sum(@temp@a*@temp@a+@temp@b*@temp@b)
                  % take the square root of the result
                  FProotFPMathLen@temp@sum2
                  % cut off at 5 decimal places
                  FProundFPMathLenFPMathLen9relax
                  % set the value of the macro we were given
                  expandafteredefcsname #3endcsnameFPMathLen


                  % compute the angle between two points
                  defcalcAngle(#1,#2)#3
                  % compute the difference between the two points
                  pgfpointdiffpgfpointanchor#1center
                  pgfpointanchor#2center
                  % extract the delta between the two points
                  pgf@xa=pgf@x
                  pgf@ya=pgf@y
                  % cast the deltas as numbers
                  FPevaldeltaXpgfmath@tonumberpgf@xa
                  FPevaldeltaYpgfmath@tonumberpgf@ya
                  % use pgf to compute atan2
                  pgfmathparseatan2(deltaY, deltaX)
                  % set the angle to the result
                  FPevalangleround(pgfmathresult , 5)

                  % set the value of the macro we were given
                  expandafteredefcsname #3endcsnameangle


                  % shortcut macro to print an expression to the console
                  newcommand*print[1]typeout#1


                  %------------------------------------------------------------------------------
                  % patterns and colors
                  %------------------------------------------------------------------------------

                  % declare the parameters for the pattern
                  tikzset
                  hatch distance/.store in=hatchdistance,
                  hatch distance=10pt,
                  hatch thickness/.store in=hatchthickness,
                  hatch thickness=1pt

                  % define the parton fill pattern
                  pgfdeclarepatternformonly[hatchdistance,hatchthickness]parton
                  % declare the origin
                  pgfqpoint0pt0pt
                  % define the variables in this coordinate system
                  pgfqpointhatchdistancehatchdistance
                  pgfpointhatchdistance-1pthatchdistance-1pt
                  % set up the pattern

                  pgfsetcolortikz@pattern@color
                  pgfsetlinewidthhatchthickness
                  pgfpathmovetopgfqpoint0pt0pt
                  pgfpathlinetopgfqpointhatchdistancehatchdistance
                  pgfusepathstroke



                  % define the arrow style
                  tikzset
                  arrow/.style=
                  decoration=
                  markings,
                  mark=at position .5 with
                  arrow[#1, scale=1.5]latex

                  ,
                  postaction=decorate,


                  tikzset
                  arrow flipped/.style=
                  decoration=
                  markings,
                  mark=at position .5 with
                  arrow[#1, scale=1.5]latex reversed

                  ,
                  postaction=decorate,




                  % define a light gray to be used as a fill color for partons
                  definecolorlight-graygray.7

                  %------------------------------------------------------------------------------
                  % text macros
                  %------------------------------------------------------------------------------

                  % overline with variable width (the second brace)
                  newcommand*anti[2][1.0]
                  overline#2


                  % overline with variable width (the second brace)
                  newcommand*txt[1]
                  textrm#1


                  %------------------------------------------------------------------------------
                  % propagator styles
                  %------------------------------------------------------------------------------

                  % fermions
                  newcommand*fermion[3]
                  % scope the configuration options
                  begingroup
                  % load the configuration parameters
                  setkeysstyle#1

                  % parse the color of the line
                  definecolorlineColorHTMLstyle@color

                  % if they asked to draw the arrow
                  ifstyle@showArrow
                  ifstyle@flip
                  % draw the line with an arrow
                  draw[color=lineColor, line width = style@lineWidth, arrow flipped] (#2) -- (#3);
                  else
                  % draw the line with an arrow
                  draw[color=lineColor, line width = style@lineWidth, arrow] (#2) -- (#3);
                  fi
                  % otherwise they did not ask to draw the arrow
                  else
                  % draw the line
                  draw[color=lineColor, line width = style@lineWidth] (#2) -- (#3);
                  fi

                  % draw the label
                  drawLabel#2#3
                  endgroup



                  % dashed propagators
                  newcommand*dashed[3]
                  % scope the configuration options
                  begingroup
                  % load the configuration parameters
                  setkeysstyle#1

                  % parse the color of the line
                  definecolorlineColorHTMLstyle@color

                  % if they asked to draw the arrow
                  ifstyle@showArrow
                  ifstyle@flip
                  % draw the line with an arrow
                  draw[dashed, color=lineColor, line width = style@lineWidth, arrow flipped=lineColor] (#2) -- (#3);
                  else
                  % draw the line with an arrow
                  draw[dashed, color=lineColor, line width = style@lineWidth, arrow=lineColor] (#2) -- (#3);
                  fi
                  % otherwise they did not ask to draw the arrow
                  else
                  % draw the line
                  draw[dashed, color=lineColor, line width = style@lineWidth] (#2) -- (#3);
                  fi

                  % draw the label
                  drawLabel#2#3
                  endgroup



                  % gluons
                  newcommand*gluon[3]
                  % scope the configuration options
                  begingroup
                  % load the configuration parameters
                  setkeysstyle#1

                  % create TikZ coordinates at the end points
                  coordinate (start) at (#2);
                  coordinate (finish) at (#3);
                  % store the distance between the two points
                  calcLength(start,finish)length % stores it in a macro called length
                  % store the angle between the two points
                  calcAngle(start,finish)angle % stores it in a macro called angle

                  % turn the start coordinate into a pgf point
                  pgfpointanchorstartcenter
                  FPevalstartXpgfmath@tonumberpgf@x
                  FPevalstartYpgfmath@tonumberpgf@y

                  FPevalgluonWidthstyle@gluonWidth
                  % store a value for half of the gluonWidth
                  FPevalhalfWidthgluonWidth/2
                  % store the closest whole number of full periods
                  FPevalnLoopsround((length / gluonWidth ) - 1, 0)
                  FPevaltotalLength(nLoops+1) * gluonWidth
                  FPevalscalelength / totalLength
                  % parse the color of the line
                  definecolorlineColorHTMLstyle@color

                  % if we dont fit a whole loop between the two points
                  ifthenelseequalnLoops0
                  % use a fermion line instead
                  fermion#2#3

                  % we fit at least one loop between the two points


                  % if they want the end caps (to draw the right kind of line)
                  ifstyle@endcaps
                  % if they asked to flip the loops
                  ifstyle@flip
                  % set the maximum value to be positive
                  FPevalymaxhalfWidth
                  FPevalymin0-halfWidth
                  % otherwise draw the loops right side up
                  else
                  % set the maximum value to be negative
                  FPevalymax0-halfWidth
                  FPevalyminhalfWidth
                  fi

                  % style the opening end cap
                  draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
                  rotate=angle, xscale=scale, yscale=scale]
                  % draw the opening end cap
                  (0,0) .. controls (halfWidth, 0) and (0, ymin) .. (halfWidth, ymin);
                  % for each loop that we have to draw
                  foreach loopNumber in 1,...,nLoops
                  % compute the starting location of the loop
                  FPevalxloopNumber * gluonWidth - halfWidth
                  % compute the half way point of the loop
                  FPevalxMidhalfWidth + x
                  % compute the endpoint of the loop
                  FPevalxFinalgluonWidth + x

                  % style the first half of the loop
                  draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
                  rotate=angle, xscale=scale, yscale=scale]
                  % draw the first half of the loop
                  (x, ymin) .. controls (xFinal, ymin) and (xFinal, ymax) .. (xMid, ymax);
                  % style the second half of the loop
                  draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
                  rotate=angle, xscale=scale, yscale=scale]
                  % draw the second half of the loop
                  (xMid, ymax) .. controls (x, ymax) and (x, ymin) .. (xFinal, ymin);


                  % compute the locations for the closing end cap
                  FPevalfinalStart(nLoops+1) * gluonWidth - halfWidth
                  FPevalfinalHalffinalStart + halfWidth
                  FPevalfinalStopfinalStart + halfWidth
                  % style the closing end cap
                  draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
                  rotate=angle, xscale=scale, yscale=scale]
                  % draw the closing end cap
                  (finalStart, ymin) .. controls (finalStop, ymin) and (finalStart, 0) .. (finalStop, 0);

                  % they did not want end caps
                  else
                  % if they asked for the gluons to be flipped
                  ifstyle@flip
                  % store a value for the height of the gluon loop
                  FPevalheight0-gluonWidth
                  else
                  % store a value for the height of the gluon loop
                  FPevalheightgluonWidth
                  fi

                  % for each loop that we have to draw
                  foreach loopNumber in 0,...,nLoops
                  % compute the starting location of the loop
                  FPevalxloopNumber * gluonWidth
                  % compute the midpoint of the loop
                  FPevalxMidhalfWidth + x
                  % compute the endpoint of the loop
                  FPevalxFinalgluonWidth + x
                  % style the first half of the loop
                  draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
                  rotate=angle, xscale=scale, yscale=scale]
                  % draw the first half of the loop
                  (x,0) .. controls (xFinal, 0) and (xFinal, height) .. (xMid, height);
                  % style the second half of the loop
                  draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
                  rotate=angle, xscale=scale, yscale=scale]
                  % draw the second half of the loop
                  (xMid,height) .. controls (x, height) and (x, 0) .. (xFinal, 0);

                  fi

                  % draw the label
                  drawLabel#2#3
                  endgroup



                  % electroweak lines
                  newcommand*electroweak[3]
                  % scope the configuration options
                  begingroup
                  % load the configuration parameters
                  setkeysstyle#1

                  % create TikZ coordinates at the end points
                  coordinate (start) at (#2);
                  coordinate (finish) at (#3);
                  % store the distance between the two points
                  calcLength(start,finish)length % stores it in a macro called length
                  % store the angle between the two points
                  calcAngle(start,finish)angle % stores it in a macro called angle

                  % turn the start coordinate into a pgf point
                  pgfpointanchorstartcenter
                  FPevalstartXpgfmath@tonumberpgf@x
                  FPevalstartYpgfmath@tonumberpgf@y

                  FPevalperiodstyle@gluonWidth
                  % store a value for half of the gluonWidth
                  FPevalhalfPeriodperiod/2
                  % store the closest whole number of full periods
                  FPevalnLoopsround((length / period ) - 1, 0)
                  FPevaltotalLength(nLoops+1) * period
                  FPevalscalelength / totalLength
                  % parse the color of the line
                  definecolorlineColorHTMLstyle@color

                  % if we dont fit a whole loop between the two points
                  ifthenelseequalnLoops0
                  % use a fermion line instead
                  fermion#2#3

                  % we fit at least one loop between the two points

                  % store the amplitude of the curve
                  FPevalamplitudeperiod * 3 / 2

                  % if they asked for the gluons to be flipped
                  ifstyle@flip
                  % save the maximum height of the curve
                  FPevalymaxamplitude
                  % save the minimum value of the curve
                  FPevalymin0-amplitude
                  else
                  % save the maximum height of the curve
                  FPevalymax0-amplitude
                  % save the minimum value of the curve
                  FPevalyminamplitude
                  fi

                  % store the minimum height
                  % for each period that we have to draw
                  foreach loopNumber in 0,...,nLoops
                  % compute the starting location
                  FPevalxloopNumber * period
                  % compute the midpoint
                  FPevalxMidhalfPeriod + x
                  % compute the endpoint
                  FPevalxFinalperiod + x
                  % style the period
                  draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
                  rotate=angle, xscale=scale, yscale=scale]
                  % place the period
                  (x,0) .. controls (xMid, ymin) and (xMid, ymax) .. (xFinal, 0);


                  % draw the label
                  drawLabel#2#3
                  endgroup



                  % gluinos
                  newcommand*gluino[3]
                  % scope the configuration options
                  begingroup
                  % load the configuration parameters
                  setkeysstyle#1
                  % enforce that endcaps is true
                  setkeysstyleendcaps=true
                  % draw a fermion between the two points
                  fermion#2#3
                  % draw a gluon between the two points
                  gluon#2#3
                  % draw the label
                  drawLabel#2#3
                  endgroup



                  % sfermions
                  newcommand*sfermion[3]
                  % scope the configuration options
                  begingroup
                  % load the configuration parameters
                  setkeysstyle#1
                  % enforce that endcaps is true
                  setkeysstyleendcaps=true
                  % draw a fermion between the two points
                  fermion#2#3
                  % draw a gluon between the two points
                  electroweak#2#3
                  % draw the label
                  drawLabel#2#3
                  endgroup



                  %------------------------------------------------------------------------------
                  % other objects
                  %------------------------------------------------------------------------------

                  % circle centered at #2 with radius #3
                  newcommand*parton[3]
                  % scope the configuration options
                  begingroup
                  % load the configuration parameters
                  setkeysstyle#1
                  % parse the color of the line
                  definecolorlineColorHTMLstyle@color
                  % style the circle
                  draw[color=lineColor, line width = style@lineWidth, pattern=parton,
                  pattern color=light-gray]
                  % draw the circle
                  (#2) circle (#3 diagram@unit);
                  endgroup



                  % text a located at #2 with content #3
                  newcommand*text[3]
                  % scope the configuration options
                  begingroup
                  % load the configuration parameters
                  setkeysstyle#1
                  % parse the color of the line
                  definecolorcolorHTMLstyle@color
                  % create a node at the location with the given contents
                  draw[text=color, anchor=style@location] (#2) node huge #3;
                  endgroup



                  % draw a label using the coordinate system along the line joining #1 and #2
                  newcommand*drawLabel[2]

                  % if they provided a value for the label
                  ifthenelseequalstyle@label

                  % create TikZ coordinates at the end points
                  coordinate (start) at (#1);
                  coordinate (finish) at (#2);

                  % compute the difference between the two points
                  pgfpointdiffpgfpointanchorstartcenter
                  pgfpointanchorfinishcenter
                  pgf@xa=pgf@x
                  pgf@ya=pgf@y
                  % cast the deltas in the appropriate unit system
                  FPevaldXpgfmath@tonumberpgf@xa/72.27
                  FPevaldYpgfmath@tonumberpgf@ya/72.27

                  % compute the location of the starting coordinate
                  pgfpointanchorstartcenter
                  pgf@xa=pgf@x
                  pgf@ya=pgf@y
                  FPevalstartXround(pgfmath@tonumberpgf@xa/72.27, 5)
                  FPevalstartYround(pgfmath@tonumberpgf@ya/72.27, 5)

                  % store local copies of the target position
                  FPevallabelLocationstyle@labelLocation
                  FPevallabelDistance0+style@labelDistance

                  % compute the location along the line where we belong
                  FPeval@temp@locXround(startX + labelLocation * dX, 5)
                  FPeval@temp@locYround(startY + labelLocation * dY, 5)

                  % if the change in y is zero (infinite slope)
                  ifthenelseequaldY0
                  FPevallabelX@temp@locX
                  FPevallabelY@temp@locY+labelDistance
                  % otherwise we are safe to compute the slope

                  % compute the slope of the perpendicular line
                  FPevalperpSlope0 - dX/dY

                  % the points that are perpedicular to the line a distance r away satisfy
                  % y = mx
                  % x^2 + y^2 = r

                  % compute the x that satisfies this equation
                  % note: macro can start with because it can never be negative
                  FPevalx2(0+labelDistance) * (0+labelDistance) / (1 + (perpSlope * perpSlope))
                  FProotxx22
                  % compute the y that satisfies this equation
                  FPevalyx * perpSlope

                  newdimen distance
                  distance = labelDistance pt
                  newdimen slope
                  slope = perpSlope pt

                  % if the perpendicular line has positive slope
                  ifthenelseslope > 0 pt OR slope = 0 pt
                  % if they are a positive distance away
                  ifthenelsedistance > 0 pt
                  FPevallabelX@temp@locX + x
                  FPevallabelY@temp@locY + y
                  % otherwise they are a negative distance away

                  FPevallabelX@temp@locX - x
                  FPevallabelY@temp@locY - y

                  % otherwise the perpendicular line as negative slope

                  % if the label is a positive distance away
                  ifthenelsedistance > 0 pt
                  FPevallabelX@temp@locX - x
                  % note: the y is negative so we subtract even though we want to add
                  FPevallabelY@temp@locY - y
                  % otherwise the label is a negative distance from the line

                  FPevallabelX@temp@locX + x
                  % note: the y is negative so we add even though we want to subtract
                  FPevallabelY@temp@locY + y




                  % place the label on the right of the coordinates
                  deflocright

                  % draw the label
                  draw[loc] (labelX,labelY) node huge style@label;



                  %------------------------------------------------------------------------------
                  % cleanup
                  %------------------------------------------------------------------------------

                  % turn @ back into a special character
                  makeatother

                  endinput


                  % end of file





                  share|improve this answer












                  Using usepackagefeynman, https://ctan.org/tex-archive/macros/latex209/contrib/feynman



                  documentclass[a4paper,12pt]article

                  usepackagemathtools
                  usepackagefeynman
                  usetikzlibrarypatterns, arrows, decorations.pathreplacing, decorations.markings
                  begindocument

                  beginfeynman
                  fermion6.20, 1.207.20, 2.20
                  fermion0.20, 5.203.20, 4.20
                  electroweak3.20, 2.203.20, 4.20
                  fermion3.20, 2.206.20, 1.20
                  fermion3.20, 4.206.20, 5.20
                  fermion[lineWidth=2]6.20, 1.207.20, 2.20
                  fermion0.20, 1.203.20, 2.20
                  fermion[showArrow=true, flip=true]7.20, 0.206.20, 1.20
                  text5.00,2.20Delta^++
                  text1.00,0.90p
                  text5.60,4.60mu^-
                  text6.60,0.20p
                  text0.90,4.50v_1
                  text6.70,2.20pi^+
                  endfeynman

                  enddocument


                  Here I have added feynman.sty (to save as .sty).



                  NeedsTeXFormatLaTeX2e
                  ProvidesPackagefeynman
                  [2015/02/01 v0.8 LaTeX package for drawing feynman diagrams with an interface similar to the one found at feynman.aivazis.com]

                  RequirePackagexcolor
                  RequirePackagetikz
                  RequirePackagexifthen
                  RequirePackagekvoptions
                  RequirePackagefp

                  usetikzlibrarypatterns, arrows, decorations.pathreplacing, decorations.markings

                  % turn off the fp messages
                  FPmessagesfalse

                  % treat @ like a normal letter
                  makeatletter


                  %------------------------------------------------------------------------------
                  % configuration parameters
                  %------------------------------------------------------------------------------

                  % define the diagram configuration settings family
                  SetupKeyvalOptionsfamily=diagram, prefix=diagram@
                  DeclareStringOption[in]unit
                  DeclareStringOption[An Example Feynman Diagram]title

                  % define the propagator configuration settings family
                  SetupKeyvalOptionsfamily=style, prefix=style@
                  DeclareStringOption[000000]color
                  DeclareStringOption[2]lineWidth
                  DeclareBoolOption[true]endcaps
                  DeclareStringOption[1/3]gluonWidth
                  DeclareStringOption[center]location
                  DeclareStringOptionlabel
                  DeclareStringOption[0.5]labelDistance
                  DeclareStringOption[0.5]labelLocation
                  DeclareBoolOption[true]showArrow
                  DeclareBoolOption[false]flip


                  %------------------------------------------------------------------------------
                  % the feynman diagram environment
                  %------------------------------------------------------------------------------

                  % define an enviroment to encompass a single diagram
                  newenvironmentfeynman[1]
                  % before the content

                  % load the diagram configuration settings
                  setkeysdiagram#1
                  % start the tikz environment
                  begintikzpicture[x=1diagram@unit, y=1diagram@unit]

                  % after the content

                  % close the tikz environment
                  endtikzpicture



                  %------------------------------------------------------------------------------
                  % utility macros
                  %------------------------------------------------------------------------------

                  % convert a particular length to the designated unit
                  % i.e. converttomm1pt
                  newcommand*convertto[2]strip@ptdimexpr #2*65536/numberdimexpr 1#1

                  % compute the length between two points
                  defcalcLength(#1,#2)#3
                  % compute the delta between two points
                  pgfpointdiffpgfpointanchor#1center
                  pgfpointanchor#2center
                  pgf@xa=pgf@x
                  pgf@ya=pgf@y
                  % cast the deltas in the appropriate unit system
                  FPeval@temp@apgfmath@tonumberpgf@xa/72.27
                  FPeval@temp@bpgfmath@tonumberpgf@ya/72.27

                  % store the sum of the squares
                  FPeval@temp@sum(@temp@a*@temp@a+@temp@b*@temp@b)
                  % take the square root of the result
                  FProotFPMathLen@temp@sum2
                  % cut off at 5 decimal places
                  FProundFPMathLenFPMathLen9relax
                  % set the value of the macro we were given
                  expandafteredefcsname #3endcsnameFPMathLen


                  % compute the angle between two points
                  defcalcAngle(#1,#2)#3
                  % compute the difference between the two points
                  pgfpointdiffpgfpointanchor#1center
                  pgfpointanchor#2center
                  % extract the delta between the two points
                  pgf@xa=pgf@x
                  pgf@ya=pgf@y
                  % cast the deltas as numbers
                  FPevaldeltaXpgfmath@tonumberpgf@xa
                  FPevaldeltaYpgfmath@tonumberpgf@ya
                  % use pgf to compute atan2
                  pgfmathparseatan2(deltaY, deltaX)
                  % set the angle to the result
                  FPevalangleround(pgfmathresult , 5)

                  % set the value of the macro we were given
                  expandafteredefcsname #3endcsnameangle


                  % shortcut macro to print an expression to the console
                  newcommand*print[1]typeout#1


                  %------------------------------------------------------------------------------
                  % patterns and colors
                  %------------------------------------------------------------------------------

                  % declare the parameters for the pattern
                  tikzset
                  hatch distance/.store in=hatchdistance,
                  hatch distance=10pt,
                  hatch thickness/.store in=hatchthickness,
                  hatch thickness=1pt

                  % define the parton fill pattern
                  pgfdeclarepatternformonly[hatchdistance,hatchthickness]parton
                  % declare the origin
                  pgfqpoint0pt0pt
                  % define the variables in this coordinate system
                  pgfqpointhatchdistancehatchdistance
                  pgfpointhatchdistance-1pthatchdistance-1pt
                  % set up the pattern

                  pgfsetcolortikz@pattern@color
                  pgfsetlinewidthhatchthickness
                  pgfpathmovetopgfqpoint0pt0pt
                  pgfpathlinetopgfqpointhatchdistancehatchdistance
                  pgfusepathstroke



                  % define the arrow style
                  tikzset
                  arrow/.style=
                  decoration=
                  markings,
                  mark=at position .5 with
                  arrow[#1, scale=1.5]latex

                  ,
                  postaction=decorate,


                  tikzset
                  arrow flipped/.style=
                  decoration=
                  markings,
                  mark=at position .5 with
                  arrow[#1, scale=1.5]latex reversed

                  ,
                  postaction=decorate,




                  % define a light gray to be used as a fill color for partons
                  definecolorlight-graygray.7

                  %------------------------------------------------------------------------------
                  % text macros
                  %------------------------------------------------------------------------------

                  % overline with variable width (the second brace)
                  newcommand*anti[2][1.0]
                  overline#2


                  % overline with variable width (the second brace)
                  newcommand*txt[1]
                  textrm#1


                  %------------------------------------------------------------------------------
                  % propagator styles
                  %------------------------------------------------------------------------------

                  % fermions
                  newcommand*fermion[3]
                  % scope the configuration options
                  begingroup
                  % load the configuration parameters
                  setkeysstyle#1

                  % parse the color of the line
                  definecolorlineColorHTMLstyle@color

                  % if they asked to draw the arrow
                  ifstyle@showArrow
                  ifstyle@flip
                  % draw the line with an arrow
                  draw[color=lineColor, line width = style@lineWidth, arrow flipped] (#2) -- (#3);
                  else
                  % draw the line with an arrow
                  draw[color=lineColor, line width = style@lineWidth, arrow] (#2) -- (#3);
                  fi
                  % otherwise they did not ask to draw the arrow
                  else
                  % draw the line
                  draw[color=lineColor, line width = style@lineWidth] (#2) -- (#3);
                  fi

                  % draw the label
                  drawLabel#2#3
                  endgroup



                  % dashed propagators
                  newcommand*dashed[3]
                  % scope the configuration options
                  begingroup
                  % load the configuration parameters
                  setkeysstyle#1

                  % parse the color of the line
                  definecolorlineColorHTMLstyle@color

                  % if they asked to draw the arrow
                  ifstyle@showArrow
                  ifstyle@flip
                  % draw the line with an arrow
                  draw[dashed, color=lineColor, line width = style@lineWidth, arrow flipped=lineColor] (#2) -- (#3);
                  else
                  % draw the line with an arrow
                  draw[dashed, color=lineColor, line width = style@lineWidth, arrow=lineColor] (#2) -- (#3);
                  fi
                  % otherwise they did not ask to draw the arrow
                  else
                  % draw the line
                  draw[dashed, color=lineColor, line width = style@lineWidth] (#2) -- (#3);
                  fi

                  % draw the label
                  drawLabel#2#3
                  endgroup



                  % gluons
                  newcommand*gluon[3]
                  % scope the configuration options
                  begingroup
                  % load the configuration parameters
                  setkeysstyle#1

                  % create TikZ coordinates at the end points
                  coordinate (start) at (#2);
                  coordinate (finish) at (#3);
                  % store the distance between the two points
                  calcLength(start,finish)length % stores it in a macro called length
                  % store the angle between the two points
                  calcAngle(start,finish)angle % stores it in a macro called angle

                  % turn the start coordinate into a pgf point
                  pgfpointanchorstartcenter
                  FPevalstartXpgfmath@tonumberpgf@x
                  FPevalstartYpgfmath@tonumberpgf@y

                  FPevalgluonWidthstyle@gluonWidth
                  % store a value for half of the gluonWidth
                  FPevalhalfWidthgluonWidth/2
                  % store the closest whole number of full periods
                  FPevalnLoopsround((length / gluonWidth ) - 1, 0)
                  FPevaltotalLength(nLoops+1) * gluonWidth
                  FPevalscalelength / totalLength
                  % parse the color of the line
                  definecolorlineColorHTMLstyle@color

                  % if we dont fit a whole loop between the two points
                  ifthenelseequalnLoops0
                  % use a fermion line instead
                  fermion#2#3

                  % we fit at least one loop between the two points


                  % if they want the end caps (to draw the right kind of line)
                  ifstyle@endcaps
                  % if they asked to flip the loops
                  ifstyle@flip
                  % set the maximum value to be positive
                  FPevalymaxhalfWidth
                  FPevalymin0-halfWidth
                  % otherwise draw the loops right side up
                  else
                  % set the maximum value to be negative
                  FPevalymax0-halfWidth
                  FPevalyminhalfWidth
                  fi

                  % style the opening end cap
                  draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
                  rotate=angle, xscale=scale, yscale=scale]
                  % draw the opening end cap
                  (0,0) .. controls (halfWidth, 0) and (0, ymin) .. (halfWidth, ymin);
                  % for each loop that we have to draw
                  foreach loopNumber in 1,...,nLoops
                  % compute the starting location of the loop
                  FPevalxloopNumber * gluonWidth - halfWidth
                  % compute the half way point of the loop
                  FPevalxMidhalfWidth + x
                  % compute the endpoint of the loop
                  FPevalxFinalgluonWidth + x

                  % style the first half of the loop
                  draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
                  rotate=angle, xscale=scale, yscale=scale]
                  % draw the first half of the loop
                  (x, ymin) .. controls (xFinal, ymin) and (xFinal, ymax) .. (xMid, ymax);
                  % style the second half of the loop
                  draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
                  rotate=angle, xscale=scale, yscale=scale]
                  % draw the second half of the loop
                  (xMid, ymax) .. controls (x, ymax) and (x, ymin) .. (xFinal, ymin);


                  % compute the locations for the closing end cap
                  FPevalfinalStart(nLoops+1) * gluonWidth - halfWidth
                  FPevalfinalHalffinalStart + halfWidth
                  FPevalfinalStopfinalStart + halfWidth
                  % style the closing end cap
                  draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
                  rotate=angle, xscale=scale, yscale=scale]
                  % draw the closing end cap
                  (finalStart, ymin) .. controls (finalStop, ymin) and (finalStart, 0) .. (finalStop, 0);

                  % they did not want end caps
                  else
                  % if they asked for the gluons to be flipped
                  ifstyle@flip
                  % store a value for the height of the gluon loop
                  FPevalheight0-gluonWidth
                  else
                  % store a value for the height of the gluon loop
                  FPevalheightgluonWidth
                  fi

                  % for each loop that we have to draw
                  foreach loopNumber in 0,...,nLoops
                  % compute the starting location of the loop
                  FPevalxloopNumber * gluonWidth
                  % compute the midpoint of the loop
                  FPevalxMidhalfWidth + x
                  % compute the endpoint of the loop
                  FPevalxFinalgluonWidth + x
                  % style the first half of the loop
                  draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
                  rotate=angle, xscale=scale, yscale=scale]
                  % draw the first half of the loop
                  (x,0) .. controls (xFinal, 0) and (xFinal, height) .. (xMid, height);
                  % style the second half of the loop
                  draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
                  rotate=angle, xscale=scale, yscale=scale]
                  % draw the second half of the loop
                  (xMid,height) .. controls (x, height) and (x, 0) .. (xFinal, 0);

                  fi

                  % draw the label
                  drawLabel#2#3
                  endgroup



                  % electroweak lines
                  newcommand*electroweak[3]
                  % scope the configuration options
                  begingroup
                  % load the configuration parameters
                  setkeysstyle#1

                  % create TikZ coordinates at the end points
                  coordinate (start) at (#2);
                  coordinate (finish) at (#3);
                  % store the distance between the two points
                  calcLength(start,finish)length % stores it in a macro called length
                  % store the angle between the two points
                  calcAngle(start,finish)angle % stores it in a macro called angle

                  % turn the start coordinate into a pgf point
                  pgfpointanchorstartcenter
                  FPevalstartXpgfmath@tonumberpgf@x
                  FPevalstartYpgfmath@tonumberpgf@y

                  FPevalperiodstyle@gluonWidth
                  % store a value for half of the gluonWidth
                  FPevalhalfPeriodperiod/2
                  % store the closest whole number of full periods
                  FPevalnLoopsround((length / period ) - 1, 0)
                  FPevaltotalLength(nLoops+1) * period
                  FPevalscalelength / totalLength
                  % parse the color of the line
                  definecolorlineColorHTMLstyle@color

                  % if we dont fit a whole loop between the two points
                  ifthenelseequalnLoops0
                  % use a fermion line instead
                  fermion#2#3

                  % we fit at least one loop between the two points

                  % store the amplitude of the curve
                  FPevalamplitudeperiod * 3 / 2

                  % if they asked for the gluons to be flipped
                  ifstyle@flip
                  % save the maximum height of the curve
                  FPevalymaxamplitude
                  % save the minimum value of the curve
                  FPevalymin0-amplitude
                  else
                  % save the maximum height of the curve
                  FPevalymax0-amplitude
                  % save the minimum value of the curve
                  FPevalyminamplitude
                  fi

                  % store the minimum height
                  % for each period that we have to draw
                  foreach loopNumber in 0,...,nLoops
                  % compute the starting location
                  FPevalxloopNumber * period
                  % compute the midpoint
                  FPevalxMidhalfPeriod + x
                  % compute the endpoint
                  FPevalxFinalperiod + x
                  % style the period
                  draw[color=lineColor, line width = style@lineWidth, yshift=startY, xshift=startX,
                  rotate=angle, xscale=scale, yscale=scale]
                  % place the period
                  (x,0) .. controls (xMid, ymin) and (xMid, ymax) .. (xFinal, 0);


                  % draw the label
                  drawLabel#2#3
                  endgroup



                  % gluinos
                  newcommand*gluino[3]
                  % scope the configuration options
                  begingroup
                  % load the configuration parameters
                  setkeysstyle#1
                  % enforce that endcaps is true
                  setkeysstyleendcaps=true
                  % draw a fermion between the two points
                  fermion#2#3
                  % draw a gluon between the two points
                  gluon#2#3
                  % draw the label
                  drawLabel#2#3
                  endgroup



                  % sfermions
                  newcommand*sfermion[3]
                  % scope the configuration options
                  begingroup
                  % load the configuration parameters
                  setkeysstyle#1
                  % enforce that endcaps is true
                  setkeysstyleendcaps=true
                  % draw a fermion between the two points
                  fermion#2#3
                  % draw a gluon between the two points
                  electroweak#2#3
                  % draw the label
                  drawLabel#2#3
                  endgroup



                  %------------------------------------------------------------------------------
                  % other objects
                  %------------------------------------------------------------------------------

                  % circle centered at #2 with radius #3
                  newcommand*parton[3]
                  % scope the configuration options
                  begingroup
                  % load the configuration parameters
                  setkeysstyle#1
                  % parse the color of the line
                  definecolorlineColorHTMLstyle@color
                  % style the circle
                  draw[color=lineColor, line width = style@lineWidth, pattern=parton,
                  pattern color=light-gray]
                  % draw the circle
                  (#2) circle (#3 diagram@unit);
                  endgroup



                  % text a located at #2 with content #3
                  newcommand*text[3]
                  % scope the configuration options
                  begingroup
                  % load the configuration parameters
                  setkeysstyle#1
                  % parse the color of the line
                  definecolorcolorHTMLstyle@color
                  % create a node at the location with the given contents
                  draw[text=color, anchor=style@location] (#2) node huge #3;
                  endgroup



                  % draw a label using the coordinate system along the line joining #1 and #2
                  newcommand*drawLabel[2]

                  % if they provided a value for the label
                  ifthenelseequalstyle@label

                  % create TikZ coordinates at the end points
                  coordinate (start) at (#1);
                  coordinate (finish) at (#2);

                  % compute the difference between the two points
                  pgfpointdiffpgfpointanchorstartcenter
                  pgfpointanchorfinishcenter
                  pgf@xa=pgf@x
                  pgf@ya=pgf@y
                  % cast the deltas in the appropriate unit system
                  FPevaldXpgfmath@tonumberpgf@xa/72.27
                  FPevaldYpgfmath@tonumberpgf@ya/72.27

                  % compute the location of the starting coordinate
                  pgfpointanchorstartcenter
                  pgf@xa=pgf@x
                  pgf@ya=pgf@y
                  FPevalstartXround(pgfmath@tonumberpgf@xa/72.27, 5)
                  FPevalstartYround(pgfmath@tonumberpgf@ya/72.27, 5)

                  % store local copies of the target position
                  FPevallabelLocationstyle@labelLocation
                  FPevallabelDistance0+style@labelDistance

                  % compute the location along the line where we belong
                  FPeval@temp@locXround(startX + labelLocation * dX, 5)
                  FPeval@temp@locYround(startY + labelLocation * dY, 5)

                  % if the change in y is zero (infinite slope)
                  ifthenelseequaldY0
                  FPevallabelX@temp@locX
                  FPevallabelY@temp@locY+labelDistance
                  % otherwise we are safe to compute the slope

                  % compute the slope of the perpendicular line
                  FPevalperpSlope0 - dX/dY

                  % the points that are perpedicular to the line a distance r away satisfy
                  % y = mx
                  % x^2 + y^2 = r

                  % compute the x that satisfies this equation
                  % note: macro can start with because it can never be negative
                  FPevalx2(0+labelDistance) * (0+labelDistance) / (1 + (perpSlope * perpSlope))
                  FProotxx22
                  % compute the y that satisfies this equation
                  FPevalyx * perpSlope

                  newdimen distance
                  distance = labelDistance pt
                  newdimen slope
                  slope = perpSlope pt

                  % if the perpendicular line has positive slope
                  ifthenelseslope > 0 pt OR slope = 0 pt
                  % if they are a positive distance away
                  ifthenelsedistance > 0 pt
                  FPevallabelX@temp@locX + x
                  FPevallabelY@temp@locY + y
                  % otherwise they are a negative distance away

                  FPevallabelX@temp@locX - x
                  FPevallabelY@temp@locY - y

                  % otherwise the perpendicular line as negative slope

                  % if the label is a positive distance away
                  ifthenelsedistance > 0 pt
                  FPevallabelX@temp@locX - x
                  % note: the y is negative so we subtract even though we want to add
                  FPevallabelY@temp@locY - y
                  % otherwise the label is a negative distance from the line

                  FPevallabelX@temp@locX + x
                  % note: the y is negative so we add even though we want to subtract
                  FPevallabelY@temp@locY + y




                  % place the label on the right of the coordinates
                  deflocright

                  % draw the label
                  draw[loc] (labelX,labelY) node huge style@label;



                  %------------------------------------------------------------------------------
                  % cleanup
                  %------------------------------------------------------------------------------

                  % turn @ back into a special character
                  makeatother

                  endinput


                  % end of file






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Aug 15 at 14:31









                  Sebastiano

                  7,69331554




                  7,69331554



























                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f446144%2fresonance-production-in-feynmf%23new-answer', 'question_page');

                      );

                      Post as a guest













































































                      Popular posts from this blog

                      How to check contact read email or not when send email to Individual?

                      Displaying single band from multi-band raster using QGIS

                      How many registers does an x86_64 CPU actually have?