# Save Feynman diagram files in a subfolder

Suppose one has a simple Feynman diagram, such as the following MWE (which has to be run with -shell-escape, I guess this is to allow compilation to "escape the shell" to run metapost).

\documentclass{article}
\usepackage{amsmath,amssymb,braket,feynmp-auto}
\newenvironment{feynman}[1]{\begin{center}\begin{fmffile}{#1}\vspace*{\baselineskip}}{\vspace*{\baselineskip}\end{fmffile}\end{center}}
\begin{document}
\begin{feynman}{01}
\begin{fmfgraph*}(110,65)
\fmfleftn{i}{2}
\fmfrightn{o}{1}
\fmf{fermion}{i1,v1,i2}
\fmf{dashes,label=$\braket{\lambda_2|T|\lambda_1}$}{v1,o1}
\fmfdotn{v}{1}
\fmfv{decoration.shape=cross,decoration.filled=empty,decoration.size=0.1w}{o1}
\fmflabel{$\lambda_2$}{i1}
\fmflabel{$\lambda_1$}{i2}
\end{fmfgraph*}
\end{feynman}
\end{document}


In the case of a large project, one wouldn't like to have all the .1, .log, .mp and .t1 files to be in the main folder, but rather in a subfolder. When the name of the diagram is changed to for example diagrams/01, by changing the 5th line to

\begin{feynman}{diagrams/01}


only the file 01.mp appears in the subfolder diagrams, the other files aren't created (it seems the second step in creating the diagram doesn't recognize the path), with as result no output in the pdf.

Question: How can we get whatever script/program that is being run to recognize the path to the .mp file? Or, more generally, how can we get the diagram files to be stored in a subfolder?

• Unfortunately, mpost doesn't obey the -output-directory that's possible to use with other TeX programs. Complain with the maintainers. Nov 19, 2015 at 13:33
• @egreg Bug report/feature request has been filed at metapost@tug.org. Thanks for pinpointing the issue. Nov 19, 2015 at 13:58
• I thought about doing that for feynmp-auto, but making mpost run in a subdirectory would introduce heavy OS dependency. Possibly a solution is using latexmk with suitable rules. Nov 19, 2015 at 14:01
• You mean contacting the maintainers of feynmp-auto about the issue? Pardon my stupidity, but how exactly would latexmk come into play here? Nov 19, 2015 at 14:08
• I'm the maintainer of feynmp-auto, so you have already contacted me. ;-) And I told you this feature can't be provided without mpost obeying the -output-directory command line option. Such a change can only be done by the maintainers of Metapost. Since latexmk can do postprocessing in a fairly general way, I believe it would be possible to adapt it to the task. Nov 19, 2015 at 14:15