User Tools

Site Tools


latex:feynman_file

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
latex:feynman_file [2023/02/04 15:30] iwnlatex:feynman_file [2023/02/04 16:44] – [Method 2: feynmp-auto (standalone)] iwn
Line 8: Line 8:
 % !TEX parameter = -shell-escape % !TEX parameter = -shell-escape
 </code> </code>
 +However, for Mac users however, [[http://osksn2.hep.sci.osaka-u.ac.jp/~taku/osx/feynmp_latexit.html|feynmp in LaTeXiT]] is a better option to quickly build of Feynman diagrams as standalone images and use ''\includegraphics''.
  
 ===== Method 1: feynmp-auto ===== ===== Method 1: feynmp-auto =====
Line 17: Line 18:
  
  
- +<code latex feynman_auto.tex>
 % !TEX program = pdflatexmk % !TEX program = pdflatexmk
 % !TEX parameter = -shell-escape % !TEX parameter = -shell-escape
Line 33: Line 33:
 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. 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.
  
-<code latex feynman_auto.tex> 
 \begin{figure}[h] \begin{figure}[h]
-  \vspace{10mm} +\vspace{10mm} 
-  \centering +\centering 
-  \begin{fmffile}{feynman-compton}+\begin{fmffile}{feynman-compton}
   \begin{fmfgraph*}(150,100)   \begin{fmfgraph*}(150,100)
     \fmfleft{i1,i2}     \fmfleft{i1,i2}
- \fmfright{o1,o2} +    \fmfright{o1,o2} 
- \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,v2} +    \fmf{photon}{i2,v2} 
- \fmf{fermion}{i1,v1,v2,o2} +    \fmf{fermion}{i1,v1,v2,o2} 
- \fmf{photon}{v1,o1}+    \fmf{photon}{v1,o1}
   \end{fmfgraph*}   \end{fmfgraph*}
-  \end{fmffile} +\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}
  
Line 57: Line 56:
 </code> </code>
  
-===== Method 2: Macro ===== 
  
-Add this macro to the preamble:+===== Method 2: feynmp-auto (standalone) ===== 
 + 
 +To create a standalone Feynman diagram, use the ''standalone'' class: 
 + 
 +<code latex feynman_standalone.tex> 
 +% !TEX program = pdflatexmk 
 +% !TEX parameter = -shell-escape 
 +% Author: Izaak Neutelings (February 2023) 
 +\documentclass[10pt,border=2pt]{standalone} 
 +\usepackage{amsmath} 
 +\usepackage{feynmp-auto} 
 + 
 +\begin{document} 
 + 
 +\fmfframe(0,15)(0,15){ % padding (LTRB) 
 +\begin{fmffile}{feynman-compton} 
 +  \begin{fmfgraph*}(110,80) 
 +    \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} 
 +
 + 
 +\end{document} 
 +</code> 
 + 
 +To create one multiple PDF with one Feynman diagram per page, use the option 
 +<code latex feynman_standalone2.tex> 
 +\documentclass[10pt,border=2pt,multi=page,crop]{standalone} 
 +</code> 
 +and wrap each ''fmffile'' around the ''page'' environment: 
 +<code latex> 
 +% !TEX program = pdflatexmk 
 +% !TEX parameter = -shell-escape 
 +% Author: Izaak Neutelings (February 2023) 
 +\documentclass[10pt,border=2pt,multi=page,crop]{standalone} 
 +\usepackage{amsmath} 
 +\usepackage{graphicx} 
 +\usepackage{feynmp-auto} 
 + 
 +\begin{document} 
 + 
 +\begin{page} 
 +\fmfframe(0,15)(0,15){ % padding (LTRB) 
 +\begin{fmffile}{feynman-compton} 
 +  \begin{fmfgraph*}(110,80) 
 +    \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} 
 +
 +\end{page} 
 + 
 +\begin{page} 
 +\fmfframe(0,15)(0,15){ % padding (LTRB) 
 +\begin{fmffile}{feynman-scat} 
 +  \begin{fmfgraph*}(110,80) 
 +    \fmfleft{i1,i2} 
 +    \fmfright{o1,o2} 
 +    \fmflabel{$\mu^-$}{i1} 
 +    \fmflabel{$e^-$}{i2} 
 +    \fmflabel{$\mu^-$}{o1} 
 +    \fmflabel{$e^-$}{o2} 
 +    \fmf{fermion}{i1,v1,o1} 
 +    \fmf{fermion}{i2,v2,o2} 
 +    \fmf{photon,label=$\gamma$}{v1,v2} 
 +  \end{fmfgraph*} 
 +\end{fmffile} 
 +
 +\end{page} 
 + 
 +\end{document} 
 +</code> 
 + 
 + 
 +===== Method 3: Macro ===== 
 + 
 +This is a handy macro that allows you to compile Feynman graphs in LaTeX documents, without the need for extra scripts ([[https://tex.stackexchange.com/questions/20241/how-to-use-kile-with-feynmf-or-feynmp|source]]).  
 <code latex> <code latex>
 \usepackage{feynmp} \usepackage{feynmp}
Line 77: Line 167:
 </code> </code>
  
 +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://tex.stackexchange.com/questions/20241/how-to-use-kile-with-feynmf-or-feynmp|source]]). Simply include the macro in the preamble. (Tested only in TeXShop on a Mac.) For Mac users however, [[http://osksn2.hep.sci.osaka-u.ac.jp/~taku/osx/feynmp_latexit.html|feynmp in LaTeXiT]] is a better option to quickly build of Feynman diagrams as standalone images. +<code latex feynman_macro.tex>
- +
-<code latex feynman_script.tex>+
 % !TEX program = pdflatexmk % !TEX program = pdflatexmk
 % !TEX parameter = -shell-escape % !TEX parameter = -shell-escape
Line 110: Line 199:
  
 \begin{figure}[h] \begin{figure}[h]
-  \vspace{10mm} +\vspace{10mm} 
-  \centering +\centering 
-  \begin{fmffile}{feynman-compton}+\begin{fmffile}{feynman-compton}
   \begin{fmfgraph*}(150,100)   \begin{fmfgraph*}(150,100)
     \fmfleft{i1,i2}     \fmfleft{i1,i2}
- \fmfright{o1,o2} +    \fmfright{o1,o2} 
- \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,v2} +    \fmf{photon}{i2,v2} 
- \fmf{fermion}{i1,v1,v2,o2} +    \fmf{fermion}{i1,v1,v2,o2} 
- \fmf{photon}{v1,o1}+    \fmf{photon}{v1,o1}
   \end{fmfgraph*}   \end{fmfgraph*}
-  \end{fmffile} +\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}
  
Line 135: Line 224:
 ===== Output ===== ===== Output =====
  
-{{ latex:feynman.png ? 2000 }}+{{ latex:feynman:feynman-auto.png ? 2000 }}
latex/feynman_file.txt · Last modified: 2023/02/04 16:45 by iwn