This is an old revision of the document!
You may need to compile the LaTeX file with -shell-escape
.
If you use TeXShop for macOS, you can include the following at the top of your document to compile with pdflatexmk -shell-escape
:
% !TEX program = pdflatexmk % !TEX parameter = -shell-escape
Load the feynmp-auto
package, documented here.
\usepackage{feynmp-auto}
Add this macro to the preamble:
\usepackage{feynmp} % macro to compile Feynman graphs without extra scripts \DeclareGraphicsRule{*}{mps}{*}{} \makeatletter \def\endfmffile{ \fmfcmd{\p@rcent\space the end.^^J end.^^J endinput;} \if@fmfio \immediate\closeout\@outfmf \fi \ifnum\pdfshellescape>\z@ \immediate\write18{mpost \thefmffile} \fi} \makeatother
The file contains a handy macro that allows you to compile Feynman graphs in LaTeX documents, without the need for extra scripts (source). Simply include the macro in the preamble. (Tested only in TeXShop on a Mac.) For Mac users however, feynmp in LaTeXiT is a better option to quickly build of Feynman diagrams as standalone images.
\documentclass[10pt,a4paper]{article} \usepackage[margin=2.4cm]{geometry} % margins \usepackage{amsmath} \usepackage{graphicx} \usepackage{feynmp} % macro to compile Feynman graphs without extra scripts \DeclareGraphicsRule{*}{mps}{*}{} \makeatletter \def\endfmffile{ \fmfcmd{\p@rcent\space the end.^^J end.^^J endinput;} \if@fmfio \immediate\closeout\@outfmf \fi %\ifnum\pdfshellescape=\@ne \ifnum\pdfshellescape>\z@ \immediate\write18{mpost \thefmffile} \fi} \makeatother \begin{document} This is a test file for Feynman diagrams. You need to compile twice: once to compile and save the Feynman diagrams, twice to include them in the typeset PDF file. \begin{figure}[h] \vspace{10mm} \centering \begin{fmffile}{compton} \begin{fmfgraph*}(150,100) \fmfleft{i1,i2} \fmfright{o1,o2} \fmflabel{$\gamma$}{i2} \fmflabel{$e^-$}{i1} \fmflabel{$\gamma$}{o1} \fmflabel{$e^-$}{o2} \fmf{photon}{i2,v2} \fmf{fermion}{i1,v1,v2,o2} \fmf{photon}{v1,o1} \end{fmfgraph*} \end{fmffile} \vspace{5mm} \caption{Feynman diagram for Compton scattering} %\label{compton} \end{figure} \end{document}