# Configuring Texmaker to run mpost for FeynMP Graphics

This question led to a new package:
feynmp-auto

What is the command line to be placed in the User

Quick Build Command of Texmaker to get:

LaTeX + mpost + dvips + ps2pdf + ViewPDF

That's to say, in order to avoid manually running mpost run on file.mp every time I run LaTeX command, is there anyway TeXMaker will do it for me?

I used TexMaker's own Wizard, which produced following command line:

latex -interaction=nonstopmode %.tex|mpost --interaction nonstopmode |dvips -o %.ps %.dvi|ps2pdf %.ps|"C:/Program Files (x86)/Adobe/Reader 10.0/Reader/AcroRd32.exe" %.pdf


It looks fine, but when I run a file.tex file it takes indefinite time with no result.

-
Hello, anyone to help? – Laura Sep 26 '12 at 20:44
I thought I will get an answer quickly. – Laura Sep 27 '12 at 13:18
Would you please add a simple example of a file you want to process? – egreg Oct 1 '12 at 15:32

With an updated TeX Live 2012 there's no need to call mpost from the command line, since this program is allowed to be called during the LaTeX run. Just modify the definition of \endfmffile to do the Metapost run.

\documentclass{article}
\usepackage{feynmp}

\usepackage{ifpdf}
\ifpdf
\DeclareGraphicsRule{*}{mps}{*}{}
\fi

\makeatletter
\def\endfmffile{%
\fmfcmd{\p@rcent\space the end.^^J%
end.^^J%
endinput;}%
\if@fmfio
\immediate\closeout\@outfmf
\fi
\IfFileExists{\thefmffile.mp}{\immediate\write18{mpost \thefmffile}}{}
\let\thefmffile\relax
}
\makeatother

\begin{document}

\begin{fmffile}{abc}
\begin{fmfgraph}(40,25)
\fmfpen{thick}
\fmfleft{i1,i2}
\fmfright{o1,o2}
\fmf{fermion}{i1,v1,v3,o1}
\fmf{fermion}{o2,v4,v2,i2}
\fmf{photon}{v1,v2}
\fmf{photon}{v3,v4}
\fmfdotn{v}{4}
\end{fmfgraph}
\end{fmffile}

\end{document}


This will produce abc.1 that will be included on the next run, with the usual command line call.

With MiKTeX it might not work, depending if mpost is allowed in the "restricted shell".

-
I don't know why the package link in question, ctan.org/pkg/feynmp-auto does not work above – texenthusiast Mar 12 '13 at 18:38
@texenthusiast Well, wait until it's activated; I just uploaded it, but knowing myself, I'd forget this annotation if not made immediately. ;-) – egreg Mar 12 '13 at 18:41
sorry i thought it was old question and mistook it. thanks – texenthusiast Mar 12 '13 at 18:43