% !TEX program = pdflatexmk
% !TEX parameter = -shell-escape
% Author: Izaak Neutelings (March 2026)
% Instructions: To compile via command line, run the following twice
%   pdflatex -shell-escape tension.tex
\documentclass[11pt,border=-2pt,multi=page,crop]{standalone}
\usepackage{feynmp-auto}
\usepackage{pgffor} % for \foreach
\usepackage{xcolor} % for \color

% DEFINE fmfpicture ENVIRONMENT
\usepackage{environ} % for \NewEnviron
\NewEnviron{fmfpicture}[3]{%
  \begin{page}% to create standalone page
    \fmfframe(#1)(#2){% padding (L,T)(R,B)
    \begin{fmffile}{feynmp-#3}% auxiliary files (use unique name!)
      \BODY % main code
    \end{fmffile}%
    }% close \fmfframe
  \end{page}%
}

% INDICATE VERTICES
\newcommand{\showvertices}[1]{%
  \foreach \v/\a in {#1}{%
    \begingroup\edef\tmpcmd{\endgroup\noexpand\fmfv{%
      d.sh=circle,d.f=full,d.si=4,f=(.9,,.2,,.2),l.d=5,%
      label=\noexpand\color{red}\noexpand\small\v,l.a=\a}{\v}}%
    \tmpcmd% excute
  }% close \foreach
}

% HELP MACROS
\newcommand{\drawframe}{%
  \fmfcmd{fill ne--nw--sw--se--cycle withcolor (0.95,0.95,0.99);}%
  \fmfcmd{draw ne--nw--sw--se--cycle withcolor (0.5,0.5,0.7)
    withpen pencircle scaled 0.5pt;}%
  %\fmfcmd{draw (-0.02w,-0.02h)--(-0.02w,1.02h)--(1.02w,1.02h)--(1.02w,-0.02h)--cycle
  %        withpen pencircle scaled 0.5pt;}%
}
%\newcommand{\drawline}[4]{%
%  \fmfcmd{draw vloc(__#1)..vloc(__#2)..vloc(__#3)..vloc(__#4)
%   withpen pencircle scaled 1.6pt withcolor (0.4,0,0);}%
%}
\newcommand{\drawline}[1]{%
  \def\tmppath{}%
  \foreach \x [count=\i from 1] in {#1}{%
    \xdef\tmppath{\tmppath \ifnum\i=1\else..\fi vloc(__\x)}
  }
  \message{^^Jtmppath=\tmppath}
  \fmfcmd{draw \tmppath\space withpen pencircle scaled 1.6pt withcolor (0.4,0,0);}
}

\begin{document}

% VERTICES: \fmfleft, \fmfright, \fmfcurved
\begin{fmfpicture}{3,6}{6,6}{vtx-left-right} % padding (LTRB)
  \begin{fmfgraph*}(100,80) % dimensions (WH)
    % rectangle
    \drawframe
    % external vertices
    \fmfcurved % redundant
    \fmfleft{l1,l2,l3,l4}
    \fmfright{r1,r2,r3,r4}
    % lines connecting points
    \drawline{l1,l2,l3,l4}
    \drawline{r1,r2,r3,r4}
    % indicate vertices
    \showvertices{l1/45,l2/0,l3/0,l4/-45}
    \showvertices{r1/135,r2/180,r3/180,r4/-135}
  \end{fmfgraph*}
\end{fmfpicture}

% VERTICES: \fmfleft, \fmfright, \fmfcurved (5)
\begin{fmfpicture}{3,6}{6,6}{vtx-left-right-5} % padding (LTRB)
  \begin{fmfgraph*}(100,80) % dimensions (WH)
    % rectangle
    \drawframe
    % external vertices
    \fmfcurved % redundant
    \fmfleft{l1,l2,l3,l4,l5}
    \fmfright{r1,r2,r3,r4,r5}
    % lines connecting points
    \drawline{l1,l2,l3,l4,l5}
    \drawline{r1,r2,r3,r4,r5}
    % indicate vertices
    \showvertices{l1/45,l2/10,l3/0,l4/-10,l5/-45}
    \showvertices{r1/135,r2/170,r3/180,r4/-170,r5/-135}
  \end{fmfgraph*}
\end{fmfpicture}

% VERTICES: \fmftop, \fmfbottom, \fmfcurved
\begin{fmfpicture}{3,6}{6,6}{vtx-top-bottom} % padding (LTRB)
  \begin{fmfgraph*}(100,80) % dimensions (WH)
    % rectangle
    \drawframe
    % external vertices
    \fmfcurved % redundant
    \fmftop{t1,t2,t3,t4}
    \fmfbottom{b1,b2,b3,b4}
    % lines connecting points
    \drawline{t1,t2,t3,t4}
    \drawline{b1,b2,b3,b4}
    % indicate vertices
    \showvertices{t1/-45,t2/-90,t3/-90,t4/-135}
    \showvertices{b1/45,b2/90,b3/90,b4/135}
  \end{fmfgraph*}
\end{fmfpicture}

% VERTICES: \fmfsurround, \fmfcurved
\begin{fmfpicture}{3,6}{6,6}{vtx-surround} % padding (LTRB)
  \begin{fmfgraph*}(100,80) % dimensions (WH)
    % rectangle
    \drawframe
    % external vertices
    \fmfcurved % redundant
    \fmfsurround{v1,v2,v3,v4,v5,v6,v7}
    % lines connecting points
    \fmfcmd{%
      draw vloc(__v1)..tension 1.2..vloc(__v2)..tension 1.4..vloc(__v3)
                     ..tension 1.2..vloc(__v4)..tension 1.3..vloc(__v5)
                     ..tension 1.2..vloc(__v6)..tension 1.3..vloc(__v7)
      withpen pencircle scaled 1.6pt withcolor (0.4,0,0);
    }%
    % indicate vertices
    \showvertices{v1/180,v2/-130,v3/-50,v4/-20,v5/20,v6/80,v7/120}
  \end{fmfgraph*}
\end{fmfpicture}

% VERTICES: \fmfleft, \fmfright, \fmfstraight
\begin{fmfpicture}{3,6}{6,6}{vtx-left-right-straight} % padding (LTRB)
  \begin{fmfgraph*}(100,80) % dimensions (WH)
    % rectangle
    \drawframe
    % external vertices
    \fmfstraight
    \fmfleft{l1,l2,l3,l4}
    \fmfright{r1,r2,r3,r4}
    % lines connecting points
    \drawline{l1,l2,l3,l4}
    \drawline{r1,r2,r3,r4}
    % indicate vertices
    \showvertices{l1/45,l2/0,l3/0,l4/-45}
    \showvertices{r1/135,r2/180,r3/180,r4/-135}
  \end{fmfgraph*}
\end{fmfpicture}

% VERTICES: \fmftop, \fmfbottom, \fmfstraight
\begin{fmfpicture}{3,6}{6,6}{vtx-top-bottom-straight} % padding (LTRB)
  \begin{fmfgraph*}(100,80) % dimensions (WH)
    % rectangle
    \drawframe
    % external vertices
    \fmfstraight
    \fmftop{t1,t2,t3,t4}
    \fmfbottom{b1,b2,b3,b4}
    % lines connecting points
    \drawline{t1,t2,t3,t4}
    \drawline{b1,b2,b3,b4}
    % indicate vertices
    \showvertices{t1/-45,t2/-90,t3/-90,t4/-135}
    \showvertices{b1/45,b2/90,b3/90,b4/135}
  \end{fmfgraph*}
\end{fmfpicture}

% VERTICES: \fmfsurround, \fmfstraight
\begin{fmfpicture}{3,6}{6,6}{vtx-surround-straight} % padding (LTRB)
  \begin{fmfgraph*}(100,80) % dimensions (WH)
    % rectangle
    \drawframe
    % external vertices
    \fmfstraight
    \fmfsurround{v1,v2,v3,v4,v5,v6,v7}
    % lines connecting points
    \fmfcmd{%
      draw vloc(__v1)--ne--nw--sw--vloc(__v7)
      withpen pencircle scaled 1.6pt withcolor (0.4,0,0);
    }%
    % indicate vertices
    \showvertices{v1/180,v2/-130,v3/-50,v4/-20,v5/20,v6/80,v7/120}
  \end{fmfgraph*}
\end{fmfpicture}

\end{document}