![如何使用 feynmp 创建费曼图?](https://linux22.com/image/443291/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%20feynmp%20%E5%88%9B%E5%BB%BA%E8%B4%B9%E6%9B%BC%E5%9B%BE%EF%BC%9F.png)
我从来没有使用过这个包并且我不知道如何使用它来绘制图表。
尝试绘制我找到的一些示例,但它们甚至没有出现在我的 pdf 文件中。
我在其他论坛上看到我必须运行 mpost 文件,但我不知道在哪里可以找到或如何运行此文件。以下是我的尝试:
\documentclass[10pt,a4paper]{article}
\usepackage[margin=2.4cm]{geometry} % margins
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{feynmp}
\usepackage{feynmp-auto}
% 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}
\begin{figure}[h]
\vspace{10mm}
\centering
\begin{fmffile}{attemp 1}
\begin{fmfgraph*}(150,100)
\fmfleft{i1}%%determina o termos da esquerda
\fmfright{o2} %% determina o termo da direita
\fmflabel{$e^-$}{i1}%% um e- que vem da esquerda
\fmflabel{$e^-$}{o2}%% um e- que vai pra direita
\fmf{photon}{v1,v2}%% foton vai do vértice 1 para o 2
\fmf{fermion}{i1,v1,o2} %fermion vem do termo i1, da esquerda, entra no vertice v1, vai de v1 para v2, e de v2 para o termo o2.
\fmf{photon}{v1,o1} %% foton vem do vértice de baixo pra direita, o2
\end{fmfgraph*}
\end{fmffile}
\vspace{5mm}
\caption{Feynman diagram for Compton scattering} %\label{compton}
\end{figure}
\large
\begin{fmffile}{feyngraph}
\begin{fmfgraph*}(110,60)
\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}
\newcommand{\marrow}[5]{%
\fmfcmd{style_def marrow#1
expr p = drawarrow subpath (1/4, 3/4) of p shifted 6 #2 withpen pencircle scaled 0.4;
label.#3(btex #4 etex, point 0.5 of p shifted 6 #2);
enddef;}
\fmf{marrow#1,tension=0}{#5}}
\begin{fmffile}{diagram with arrows}
\begin{fmfgraph*}(110,60)
\fmfleft{i1,i2}
\fmfright{o1,o2}
\fmflabel{$e^-$}{i2}
\fmflabel{$e^-$}{o2}
\fmflabel{$\mu^-$}{i1}
\fmflabel{$\mu^-$}{o1}
\fmf{fermion}{i2,v2,o2}
\marrow{ea}{ up }{top}{$p_1$}{i2,v2}
\marrow{eb}{down}{bot}{$p_3$}{v2,o2}
\fmf{fermion}{i1,v1,o1}
\marrow{ma}{down}{bot}{$p_2$}{i1,v1}
\marrow{mb}{ up }{top}{$p_4$}{v1,o1}
\fmf{photon,label=$\gamma$}{v2,v1}
\end{fmfgraph*}
\end{fmffile}
\end{document}
答案1
抱歉,我回复晚了,但我只是清理了你的代码,并对其进行了更好的修复,因为有很多错误。我很难一步步解释我的改进。
这里是我的MWE工作:
\documentclass[10pt,a4paper]{article}
\usepackage[margin=2.4cm]{geometry} % margins
\usepackage{amsmath,amssymb}
\usepackage{graphicx}
\usepackage{feynmp-auto}
\begin{document}
\begin{figure}[h]
\vspace{10mm}
\centering
\begin{fmffile}{zxc}
\begin{fmfgraph*}(150,100)
\fmfleft{i1}%%determina o termos da esquerda
\fmfright{o2} %% determina o termo da direita
\fmflabel{$e^-$}{i1}%% um e- que vem da esquerda
\fmflabel{$e^-$}{o2}%% um e- que vai pra direita
\fmf{photon}{v1,v2}%% foton vai do vértice 1 para o 2
\fmf{fermion}{i1,v1,o2} %fermion vem do termo i1, da esquerda, entra no vertice v1, vai de v1 para v2, e de v2 para o termo o.
\fmf{photon}{v1,o1} %% foton vem do vértice de baixo pra direita, o2
\end{fmfgraph*}
\end{fmffile}
\vspace{5mm}
\caption{Feynman diagram for Compton scattering} %\label{compton}
\end{figure}
\large
\[\begin{fmffile}{feyngraph}
\begin{fmfgraph*}(110,60)
\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}\qquad
\newcommand{\marrow}[5]{%
\fmfcmd{style_def marrow#1
expr p = drawarrow subpath (1/4, 3/4) of p shifted 6 #2 withpen pencircle scaled 0.4;
label.#3(btex #4 etex, point 0.5 of p shifted 6 #2);
enddef;}
\fmf{marrow#1,tension=0}{#5}}
\begin{fmffile}{dgs}
\begin{fmfgraph*}(110,60)
\fmfleft{i1,i2}
\fmfright{o1,o2}
\fmflabel{$e^-$}{i2}
\fmflabel{$e^-$}{o2}
\fmflabel{$\mu^-$}{i1}
\fmflabel{$\mu^-$}{o1}
\fmf{fermion}{i2,v2,o2}
\marrow{ea}{ up }{top}{$p_1$}{i2,v2}
\marrow{eb}{down}{bot}{$p_3$}{v2,o2}
\fmf{fermion}{i1,v1,o1}
\marrow{ma}{down}{bot}{$p_2$}{i1,v1}
\marrow{mb}{ up }{top}{$p_4$}{v1,o1}
\fmf{photon,label=$\gamma$}{v2,v1}
\end{fmfgraph*}
\end{fmffile}\]
\end{document}