1

I want to create a Feynman diagram using LaTeXiT. I have followed the instructions here http://osksn2.hep.sci.osaka-u.ac.jp/~taku/osx/feynmp.html to install feynmp and the instructions here http://osksn2.hep.sci.osaka-u.ac.jp/~taku/osx/feynmp_latexit.html to set up LaTeXiT to produce Feynman diagrams but when I run the preamble:

\documentclass[10pt]{article}
\usepackage[usenames]{color} %used for font color
\usepackage{amssymb} %maths%\usepackage{amsmath} %maths
\usepackage[utf8]{inputenc} %useful to type directly diacritic characters
\usepackage{feynmp}

and the code:

\begin{fmffile}{feyngraph}
  \begin{fmfgraph}(110,60)
    \fmfleft{i1,i2}
    \fmfright{o1,o2}
    \fmf{fermion}{i1,v1,o1}
    \fmf{fermion}{i2,v2,o2}
    \fmf{photon}{v1,v2}
  \end{fmfgraph}
\end{fmffile}

I get a blank picture as the output. No error, just no picture. I'm working on MacOS Catalina with LaTeXiT Version 2.13.2. Can someone tell me the best way to get this to work?

Beth Long
  • 297
  • 1
  • 10

4 Answers4

1

I haven't used particular setup but fenymp package doesn't try to run mpost for you, your build system should be doing this as part of the process and will need to detect that an .mp has been created or updated and it should therefore run that step as well.

The other option if you do want the main build to run mpost is to use the feynmp-auto package which should then run mpost for you (at which point --shell-escape becomes relevant as mentioned in comments on the question). Your build system will still need to notice that some of the input has changed and re-run the build or you will need to re-run the build.

1

Taking the information from the answer above

% !TEX program = pdflatexmk
% !TEX parameter = -shell-escape 
% !TEX encoding = UTF-8 Unicode
\documentclass[10pt]{article}
\usepackage[usenames]{color} %used for font color
\usepackage{amssymb} %maths%\usepackage{amsmath} %maths
\usepackage[utf8]{inputenc} %useful to type directly diacritic characters
\usepackage{feynmp-auto}
\begin{document}
\begin{fmffile}{feyngraph}
  \begin{fmfgraph}(110,60)
    \fmfleft{i1,i2}
    \fmfright{o1,o2}
    \fmf{fermion}{i1,v1,o1}
    \fmf{fermion}{i2,v2,o2}
    \fmf{photon}{v1,v2}
  \end{fmfgraph}
\end{fmffile}
\end{document}

will work fine in TeXShop. The pdflatexmk engine used will automatically make the second run of pdflatex and note the use of feynmp-auto package to do the mpost run.

Herb Schulz
  • 3,410
  • I can confirm this works. Any idea why the sepdflatexmk engine wasn't doing this before? Obviously the !TEX parameter = -shell-escape is necessary, but I thought that's what the se stood for. – LaTeXereXeTaL Oct 17 '20 at 18:29
  • @LaTeXereXeTaL: the engine was sepdflatex which just runs pdflatex with --shell-escape enabled as apposed to sepdflatexmk which is a latexmk based engine. The two lines % !TEX program = pdflatexmk and % !TEX parameter = -shell-escape are equivalent to using sepdflatexmk. Note also that feymp-auto is used instead of feynmp. – Herb Schulz Oct 17 '20 at 19:12
  • I tried using feymp-auto yesterday and I still had to manually run Metapost. Must be something specific to my setup. – LaTeXereXeTaL Oct 17 '20 at 19:29
  • When you run the pdflatexmk engine does the Console show that --shell-escape is added to the pdflatex command line? What version of TeXShop are you using? If you've been using TeXShop for a long time you may have to update the latexmk engines. Just move the updated versions from ~/Library/TeXShop/Engines/Inactive/Latexmk up two levels to ~/Library/TeXShop/Engines replacing the versions already there? The updated engnes understand that % !TEX parameter = -shell-escape line. – Herb Schulz Oct 17 '20 at 20:48
  • It does now (and I'm using the latest TeXShop). I moved the sepdflatex engine from the Inactive folder last night, but for some reason it still didn't work unless I manually ran Metapost AND deleted the blank PDF file. Now it even works without the % !TEX parameter = -shell-escape line. I'm thoroughly confused but it does work now. – LaTeXereXeTaL Oct 17 '20 at 21:50
1

Modifying Herb Schulz's answer above, I find the following works in LaTeXiT: Preamble:

\documentclass[10pt]{article}
\usepackage[usenames]{color} %used for font color
% !TEX program = pdflatexmk
\usepackage{amssymb} %maths
\usepackage{amsmath} %maths
\usepackage[utf8]{inputenc} %useful to type directly diacritic characters
\usepackage{feynmp-auto}

Figure:

\begin{fmffile}{feyngraph}
  \begin{fmfgraph}(110,60)
    \fmfleft{i1,i2}
    \fmfright{o1,o2}
    \fmf{fermion}{i1,v1,o1}
    \fmf{fermion}{i2,v2,o2}
    \fmf{photon}{v1,v2}
  \end{fmfgraph}
\end{fmffile}
Beth Long
  • 297
  • 1
  • 10
1

None of the proposed solutions with feynmp-auto here worked for me in LaTeXiT 2.14.5. It turned out something got scrambled when updating TeX Live on macOS Mojave (10.14.6). I had to install a separate version of GhostScript, see e.g. this thread. After that I followed the usual instructions by Taku Yamanaka, and updated the paths for dvipdf, gs and ps2pdf under Preferences > Typesetting > Behavior, which were all three available from /usr/local/Cellar/ghostscript/9.54.0/bin/.

IWN
  • 101
  • 1
  • 2