This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| latex:feynman_file [2023/02/04 15:25] – [Generating Feynman diagrams in a LaTeX file] iwn | latex:feynman_file [2023/02/04 16:45] (current) – iwn | ||
|---|---|---|---|
| Line 3: | Line 3: | ||
| You may need to compile the LaTeX file twice with '' | You may need to compile the LaTeX file twice with '' | ||
| - | If you use TeXShop for macOS, you can include the following at the top of your document to compile with '' | + | If you use TeXShop for macOS, you can include the following at the top of your document to automatically |
| <code latex> | <code latex> | ||
| % !TEX program = pdflatexmk | % !TEX program = pdflatexmk | ||
| % !TEX parameter = -shell-escape | % !TEX parameter = -shell-escape | ||
| </ | </ | ||
| + | However, for Mac users however, [[http:// | ||
| ===== Method 1: feynmp-auto ===== | ===== Method 1: feynmp-auto ===== | ||
| Line 16: | Line 17: | ||
| </ | </ | ||
| - | ===== Method 2: Macro ===== | ||
| - | Add this macro to the preamble: | + | <code latex feynman_auto.tex> |
| + | % !TEX program = pdflatexmk | ||
| + | % !TEX parameter = -shell-escape | ||
| + | % https:// | ||
| + | % https:// | ||
| + | \documentclass[a4paper, | ||
| + | \usepackage[margin=2.4cm]{geometry} % margins | ||
| + | \usepackage{amsmath} | ||
| + | \usepackage{graphicx} | ||
| + | \usepackage{feynmp-auto} | ||
| + | |||
| + | \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}{feynman-compton} | ||
| + | \begin{fmfgraph*}(150, | ||
| + | \fmfleft{i1, | ||
| + | \fmfright{o1, | ||
| + | \fmflabel{$\gamma$}{i2} | ||
| + | \fmflabel{$e^-$}{i1} | ||
| + | \fmflabel{$\gamma$}{o1} | ||
| + | \fmflabel{$e^-$}{o2} | ||
| + | \fmf{photon}{i2, | ||
| + | \fmf{fermion}{i1, | ||
| + | \fmf{photon}{v1, | ||
| + | \end{fmfgraph*} | ||
| + | \end{fmffile} | ||
| + | \vspace{5mm} | ||
| + | \caption{Feynman diagram for Compton scattering} %\label{compton} | ||
| + | \end{figure} | ||
| + | |||
| + | \end{document} | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== Method 2: feynmp-auto (standalone) ===== | ||
| + | |||
| + | To create a standalone Feynman diagram, use the '' | ||
| + | |||
| + | <code latex feynman_standalone.tex> | ||
| + | % !TEX program = pdflatexmk | ||
| + | % !TEX parameter = -shell-escape | ||
| + | % Author: Izaak Neutelings (February 2023) | ||
| + | \documentclass[10pt, | ||
| + | \usepackage{amsmath} | ||
| + | \usepackage{feynmp-auto} | ||
| + | |||
| + | \begin{document} | ||
| + | |||
| + | \fmfframe(0, | ||
| + | \begin{fmffile}{feynman-compton} | ||
| + | \begin{fmfgraph*}(110, | ||
| + | \fmfleft{i1, | ||
| + | \fmfright{o1, | ||
| + | \fmflabel{$\gamma$}{i2} | ||
| + | \fmflabel{$e^-$}{i1} | ||
| + | \fmflabel{$\gamma$}{o1} | ||
| + | \fmflabel{$e^-$}{o2} | ||
| + | \fmf{photon}{i2, | ||
| + | \fmf{fermion}{i1, | ||
| + | \fmf{photon}{v1, | ||
| + | \end{fmfgraph*} | ||
| + | \end{fmffile} | ||
| + | } | ||
| + | |||
| + | \end{document} | ||
| + | </ | ||
| + | |||
| + | To create one multiple PDF with one Feynman diagram per page, add the option '' | ||
| + | <code latex> | ||
| + | % !TEX program = pdflatexmk | ||
| + | % !TEX parameter = -shell-escape | ||
| + | % Author: Izaak Neutelings (February 2023) | ||
| + | \documentclass[10pt, | ||
| + | \usepackage{amsmath} | ||
| + | \usepackage{graphicx} | ||
| + | \usepackage{feynmp-auto} | ||
| + | |||
| + | \begin{document} | ||
| + | |||
| + | \begin{page} | ||
| + | \fmfframe(0, | ||
| + | \begin{fmffile}{feynman-compton} | ||
| + | \begin{fmfgraph*}(110, | ||
| + | \fmfleft{i1, | ||
| + | \fmfright{o1, | ||
| + | \fmflabel{$\gamma$}{i2} | ||
| + | \fmflabel{$e^-$}{i1} | ||
| + | \fmflabel{$\gamma$}{o1} | ||
| + | \fmflabel{$e^-$}{o2} | ||
| + | \fmf{photon}{i2, | ||
| + | \fmf{fermion}{i1, | ||
| + | \fmf{photon}{v1, | ||
| + | \end{fmfgraph*} | ||
| + | \end{fmffile} | ||
| + | } | ||
| + | \end{page} | ||
| + | |||
| + | \begin{page} | ||
| + | \fmfframe(0, | ||
| + | \begin{fmffile}{feynman-scat} | ||
| + | \begin{fmfgraph*}(110, | ||
| + | \fmfleft{i1, | ||
| + | \fmfright{o1, | ||
| + | \fmflabel{$\mu^-$}{i1} | ||
| + | \fmflabel{$e^-$}{i2} | ||
| + | \fmflabel{$\mu^-$}{o1} | ||
| + | \fmflabel{$e^-$}{o2} | ||
| + | \fmf{fermion}{i1, | ||
| + | \fmf{fermion}{i2, | ||
| + | \fmf{photon, | ||
| + | \end{fmfgraph*} | ||
| + | \end{fmffile} | ||
| + | } | ||
| + | \end{page} | ||
| + | |||
| + | \end{document} | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== Method 3: Macro ===== | ||
| + | |||
| + | This is a handy macro that allows you to compile Feynman graphs in LaTeX documents, without | ||
| <code latex> | <code latex> | ||
| \usepackage{feynmp} | \usepackage{feynmp} | ||
| Line 36: | Line 163: | ||
| </ | </ | ||
| + | Simply include the macro in the preamble. (Tested only in TeXShop on a Mac.) | ||
| - | The file contains a handy macro that allows you to compile Feynman graphs in LaTeX documents, without the need for extra scripts ([[https:// | + | <code latex feynman_macro.tex> |
| - | + | ||
| - | {{ latex: | + | |
| - | + | ||
| - | <code latex feynman.tex> | + | |
| % !TEX program = pdflatexmk | % !TEX program = pdflatexmk | ||
| % !TEX parameter = -shell-escape | % !TEX parameter = -shell-escape | ||
| % https:// | % https:// | ||
| % https:// | % https:// | ||
| - | \documentclass[a4paper, | + | \documentclass[a4paper, |
| \usepackage[margin=2.4cm]{geometry} % margins | \usepackage[margin=2.4cm]{geometry} % margins | ||
| \usepackage{amsmath} | \usepackage{amsmath} | ||
| Line 71: | Line 195: | ||
| \begin{figure}[h] | \begin{figure}[h] | ||
| - | | + | \vspace{10mm} |
| - | \centering | + | \centering |
| - | \begin{fmffile}{feynman-compton} | + | \begin{fmffile}{feynman-compton} |
| \begin{fmfgraph*}(150, | \begin{fmfgraph*}(150, | ||
| \fmfleft{i1, | \fmfleft{i1, | ||
| - | \fmfright{o1, | + | |
| - | \fmflabel{$\gamma$}{i2} | + | \fmflabel{$\gamma$}{i2} |
| - | \fmflabel{$e^-$}{i1} | + | \fmflabel{$e^-$}{i1} |
| - | \fmflabel{$\gamma$}{o1} | + | \fmflabel{$\gamma$}{o1} |
| - | \fmflabel{$e^-$}{o2} | + | \fmflabel{$e^-$}{o2} |
| - | \fmf{photon}{i2, | + | \fmf{photon}{i2, |
| - | \fmf{fermion}{i1, | + | \fmf{fermion}{i1, |
| - | \fmf{photon}{v1, | + | \fmf{photon}{v1, |
| \end{fmfgraph*} | \end{fmfgraph*} | ||
| - | | + | \end{fmffile} |
| - | \vspace{5mm} | + | \vspace{5mm} |
| - | \caption{Feynman diagram for Compton scattering} %\label{compton} | + | \caption{Feynman diagram for Compton scattering} %\label{compton} |
| \end{figure} | \end{figure} | ||
| \end{document} | \end{document} | ||
| </ | </ | ||
| + | |||
| + | |||
| + | ===== Output ===== | ||
| + | |||
| + | {{ latex: | ||