Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to create Feynman diagrams with LaTeX/MetaPost and feynmp seems like the perfect package to do so. I had no problems with the tutorial and can generate the diagram itself in .eps without problems. But once I started labeling each diagram, the edges of the diagram get cropped off like this:

Feynman diagram with weird size issues

What am I doing wrong? Here's my code:

% feynman.tex
\documentclass{article}
\usepackage{feynmp}
\usepackage{amsmath}
\begin{document}

\unitlength = 1mm

\begin{fmffile}{diagram}
\gdef\P#1#2{%
  \begin{fmfgraph*}(70,20)
    \fmfi{#1}{#2}
    \def\L##1##2{\fmfiv{%
      dec.shape=circle,dec.size=3thin,
      dec.fill=1,lab.dist=5thick,
      lab=\noexpand\texttt{%
        \noexpand\scriptsize ##1}}{##2}}
    \L{sw}{sw}\L{.3[nw,,ne]}{.3[nw,ne]}
   \L{ne}{ne}\L{.7[sw,,se]}{.7[sw,se]}
  \end{fmfgraph*}}
\P{plain}{sw .. .3[nw,ne]  
 .. .7[sw,se] .. ne}
\end{fmffile}

\end{document}
share|improve this question
1  
I don't know Metapost, but it looks like you're filling the background of the text labels (dec.fill=1), and this (white) fill covers the lines. –  Torbjørn T. Apr 19 at 21:28
1  
Redefining \P is not a good idea, in my opinion. However, I get the full output with this code. Also, the two \noexpand commands are wrong, because they annihilate the effect of \texttt and of \scriptsize. –  egreg Apr 19 at 21:31
1  
@elleciel Yes, it does. As I remarked, the two \noexpand commands are wrong, but even with them I see the whole curve. How are you compiling the example? With latex+dvips+ps2pdf? –  egreg Apr 19 at 21:34
1  
@elleciel Yes, with dvipdfm it doesn't work. Why aren't you using pdflatex? –  egreg Apr 19 at 21:40
1  
Try changing \usepackage{feynmp-auto} instead of \usepackage{feynmp}, which doesn't require running mpost (just the two pdflatex runs are sufficient). If you have an up-to-date TeX distribution it should work. –  egreg Apr 19 at 21:45

1 Answer 1

up vote 6 down vote accepted

Indeed, compiling the example file with latex and dvipdfm gives the wrong result; I don't know why, but the support of EPS files within dvipdfm is not really good and also in other cases I had problems. For instance, when I was developing gmp, in order to get compatibility with XeLaTeX, that uses xdvipdfmx internally (which in turn is based on dvipdfm(x)), I resorted to convert the files output by Metapost to PDF before inclusion.

So I'd recommend using pdflatex for this job. The problem of including the MPS file output by Metapost is easily solved by adding

\DeclareGraphicsRule{*}{mps}{*}{}

to your preamble. Another way, which is even better, is to use feynmp-auto that does two things:

  1. it includes the line above
  2. it avoids the need to run Metapost separately

The only thing that's needed is to run pdflatex twice (the second run is needed only if Feynman diagrams in the document have been changed).

Another thing to note is that the code is wrong in two respects: it's a bad idea to globally redefine \P just for that job, because you will incur into problems when using the normal \P command. You can redefine it locally, but it's better not doing it. The same holds for \L. Note also that \noexpand in that code is wrong.

\documentclass{article}
\usepackage{feynmp-auto}
\usepackage{amsmath}
\begin{document}

\unitlength = 1mm

\begin{fmffile}{diagram}
\newcommand\fdP[2]{%
  \begin{fmfgraph*}(70,20)
    \fmfi{#1}{#2}
    \newcommand\fdL[2]{\fmfiv{%
      dec.shape=circle,dec.size=3thin,
      dec.fill=1,lab.dist=5thick,
      lab=\texttt{%
        \scriptsize ##1}}{##2}}
    \fdL{sw}{sw}\fdL{.3[nw,,ne]}{.3[nw,ne]}
   \fdL{ne}{ne}\fdL{.7[sw,,se]}{.7[sw,se]}
  \end{fmfgraph*}}
\fdP{plain}{sw .. .3[nw,ne]  
 .. .7[sw,se] .. ne}
\end{fmffile}

\end{document}

enter image description here

share|improve this answer
    
Excellent answer, thank you so much @egreg. Accepted and upvoted. –  elleciel Apr 19 at 23:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.