AMSMath 对齐破坏 feynmp-auto

AMSMath 对齐破坏 feynmp-auto

使用以下方式编译pdflatex -shell-escape,以下 MCVE(厚颜无耻地取自另一个答案并针对我的问题进行了调整)在 mp 文件为空时失败,并且 mpost 等待用户输入。我必须手动输入end才能继续编译,之​​后才会生成非空的 mp 文件,但不会针对非空文件再次自动执行 mpost。

\documentclass{article}
 \usepackage[force]{feynmp-auto}
 \usepackage{amsmath}
 \begin{document}
 \begin{align}
 \begin{fmffile}{simple_labels}
 \begin{fmfgraph*}(40,25)
 \fmfleft{i1,i2}
 \fmfright{o1,o2}
 \fmflabel{$e^-$}{i1}
 \fmflabel{$e^+$}{i2}
 \fmflabel{$e^+,\mu^+$}{o1}
 \fmflabel{$e^-,\mu^-$}{o2}
 \fmflabel{$i\sqrt{\alpha}$}{v1}
 \fmflabel{$i\sqrt{\alpha}$}{v2}
 \fmf{fermion}{i1,v1,i2}
 \fmf{fermion}{o1,v2,o2}
 \fmf{photon,label=$\gamma,,Z^0$}{v1,v2}
 \end{fmfgraph*}
 \end{fmffile}
 &=\text{foobar}\notag\\
 foo&=bar
 \end{align}
 \end{document}

屏幕上输出(此时mp文件还是空的)

(./mpFockLOE.tex [MP to PDF] (./mpFockLOE.1)This is MetaPost, version 2.000 (TeX Live 2017) (kpathsea version 6.2.3)
(/usr/local/texlive/2017/texmf-dist/metapost/base/mpost.mp
(/usr/local/texlive/2017/texmf-dist/metapost/base/plain.mp
Preloading the plain mem file, version 1.005) ) (./mpFockLOE.mp)
*

然后我输入内容end,非空mp文件就被写入了。

答案1

放置在 \fmfframe` 外面\begin{fmffile}以固定边界框。\end{fmffile}align. I added

\documentclass{article}
\usepackage[force]{feynmp-auto}
\usepackage{amsmath}

\usepackage{lipsum} % for context

\begin{document}

\lipsum[1][1-4]
\begin{fmffile}{simple_labels}
\begin{align}
\fmfframe(15,12)(30,12){%
  \begin{fmfgraph*}(80,50)
  \fmfleft{i1,i2}
  \fmfright{o1,o2}
  \fmflabel{$e^-$}{i1}
  \fmflabel{$e^+$}{i2}
  \fmflabel{$e^+,\mu^+$}{o1}
  \fmflabel{$e^-,\mu^-$}{o2}
  \fmflabel{$i\sqrt{\alpha}$}{v1}
  \fmflabel{$i\sqrt{\alpha}$}{v2}
  \fmf{fermion}{i1,v1,i2}
  \fmf{fermion}{o1,v2,o2}
  \fmf{photon,label=$\gamma,,Z^0$}{v1,v2}
  \end{fmfgraph*}%
}
 &=\text{foobar}\notag\\
 foo&=bar
\end{align}
\end{fmffile}

\end{document}

在此处输入图片描述

答案2

我认为这与 AMS 中的环境如何收集其参数有关align。我使用的临时解决方法是将其替换为aligned

\documentclass{article}
 \usepackage[force]{feynmp-auto}
 \usepackage{amsmath}
 \begin{document}
 \begin{equation}
 \begin{aligned}
 \begin{fmffile}{simple_labels}
 \begin{fmfgraph*}(40,25)
 \fmfleft{i1,i2}
 \fmfright{o1,o2}
 \fmflabel{$e^-$}{i1}
 \fmflabel{$e^+$}{i2}
 \fmflabel{$e^+,\mu^+$}{o1}
 \fmflabel{$e^-,\mu^-$}{o2}
 \fmflabel{$i\sqrt{\alpha}$}{v1}
 \fmflabel{$i\sqrt{\alpha}$}{v2}
 \fmf{fermion}{i1,v1,i2}
 \fmf{fermion}{o1,v2,o2}
 \fmf{photon,label=$\gamma,,Z^0$}{v1,v2}
 \end{fmfgraph*}
 \end{fmffile}
 &=\text{foobar}\\
 foo&=bar
 \end{aligned}
 \end{equation}
 \end{document}

另一个解决方案是修补所有相关的宏并删除\if@fmfio检查,

\documentclass{article}
 \usepackage[force]{feynmp-auto}
 \usepackage{amsmath}
 \makeatletter
\def\fmfcmd#1{%                                                                                                                                                                                             
  %\if@fmfio
    \immediate\write\@outfmf{#1}%
  %\fi
  \ignorespaces}
\def\fmffile#1{%
  \def\thefmffile{#1}%
  \equaltojobname{\thefmffile}{%
    \PackageError{feynmp}
      {The argument of \fmffile MUST NOT be identical\MessageBreak
       to the name of your main input file!  I will use fmfdefault.mf\MessageBreak
       this time around, but you'd better fix your code now!}%
      {Invalid argument to \string\fmffile!}%
    \def\thefmffile{fmfdefault}}{}%
  %\if@fmfio
    \fnmpa@gethash % Added
    \@ifundefined{ifmeasuring@}%
      {}% 
      {\def\if@fmfio{\ifmeasuring@\else}}%
    \immediate\openout\@outfmf=\thefmffile.mp\relax
    \fmfcmd{\p@rcent\space \thefmffile.mp -- do not edit, %
            generated automatically by \jobname.tex^^J%
            input feynmp^^J%
            require_RCS_revision "\fmf@revision";}%
  %\fi
  \setcounter{fmfgraph}{0}}
\def\endfmffile{%
  \fmfcmd{\p@rcent\space the end.^^J%
          end.^^J%
          endinput;}%
  %\if@fmfio
    \immediate\closeout\@outfmf
  %\fi
  \fnmpa@processmp % Added
  \let\thefmffile\relax
}
 \makeatother
 \begin{document}
 \begin{align}
 \begin{fmffile}{simple_labels}
 \begin{fmfgraph*}(40,25)
 \fmfleft{i1,i2}
 \fmfright{o1,o2}
 \fmflabel{$e^-$}{i1}
 \fmflabel{$e^+$}{i2}
 \fmflabel{$e^+,\mu^+$}{o1}
 \fmflabel{$e^-,\mu^-$}{o2}
 \fmflabel{$i\sqrt{\alpha}$}{v1}
 \fmflabel{$i\sqrt{\alpha}$}{v2}
 \fmf{fermion}{i1,v1,i2}
 \fmf{fermion}{o1,v2,o2}
 \fmf{photon,label=$\gamma,,Z^0$}{v1,v2}
 \end{fmfgraph*}
 \end{fmffile}
 &=\text{foobar}\\
 foo&=bar
 \end{align}
 \end{document}

相关内容