How to draw Feynman diagrams with LaTeXiT on Mac OS X

You can draw Feynman diagrams using LaTeXiT. This is an easy way to put diagrams in Keynote slides, etc..

1. Required software

You need to have the following items installed.

2. Preparation

  1. Launch LaTeXiT. In the LaTeXiT > Preferences... > Typesetting panel, press the pull-down menu next to "Configuration" and select "Edit the configurations ...".
  2. Press "+" button, rename "Copy of default" to "feynmp", and press "OK".
    [LaTeXiT Configuration pane]
  3. In the same Preferences > Typesetting > Behaviour panel, choose "latex + dvipdf".
    [LaTeXiT Preferences panel]
  4. Press "Additional scripts" button, enable "Middle-processing", and enter a 3-line scipt as shown below. [Additional scripts]
  5. Close the Preferences panel.

3. How to draw Feynman diagrams

  1. In the LaTeXiT panel to enter LaTeX source code, pull down a knob in the middle to disclose preamble. Add
    \usepackage{feynmp}
    					
    in the preamble. Write the feynmf/feynmp source code in the usual editing area underneath. You can copy and paste from here, too.
    \begin{fmffile}{feyngraph}
      \begin{fmfgraph}(110,60)
        \fmfleft{i1,i2}
        \fmfright{o1,o2}
        \fmf{fermion}{i1,v1,o1}
        \fmf{fermion}{i2,v2,o2}
        \fmf{photon}{v1,v2}
      \end{fmfgraph}
    \end{fmffile}
    					
    Make sure you start with
    	\begin{fmffile}{feyngraph}
    					
    because "feyngraph" is the file name you specified in the middle-processing script for "feynmp" configuration. (You can use this same name for different diagrams, since it is just a temporary file name.)
    [LaTeXiT editing panel]
  2. From the LaTeXiT pulldown menu at the top, select "Palettes > Composition configurations". Select "feynmp" configuration that we just created.
  3. Choose "Text" mode, and press "LaTeX it!" button.
  4. You can drag the Feynman diagram to Keynote or other applications, or keep it in LaTeXiT Library for future use.
  5. If you have multiple \begin{fmffile}{...} in your source, use the following middle-processing script, provided by Pierre Chatelier (father of LateXiT). In this case, use different filename for each diagram.
    #first, extract all fmffiles of the input text file
    FMFFILES=`cat "${INPUTTEXFILE}" | grep "begin{fmffile}" | sed "s/.*\\begin{fmffile}{\([^}]*\)}/\1/g"`
    
    #run mpost for each fmffile
    for i in ${FMFFILES}; do
    mpost $i
    done
    
    #re-run latex now that mpost has been run
    latex ${INPUTTEXFILE}
    dvipdf ${OUTPUTDVIFILE}
    					
  6. To go back to normal equations, just select "default" from the "Composition configuration" panel.

4. More on feynmp


Updated 2013-12-09, Taku Yamanaka