home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fonts 1 / freshfonts1.bin / programs / amiga / pastex / macros / latex2e / contrib / supported / feynmf / feynmf.dtx (.txt) < prev    next >
LaTeX Document  |  1994-05-28  |  111KB  |  3,030 lines

  1. % \iffalse % feynmf.dtx - Feynman diagrams with METAFONT for LaTeX(2e)
  2. % Copyright (C) 1989, 1990, 1992-1994 by Thorsten.Ohl@Physik.TH-Darmstadt.de
  3. % /home/sources/ohl/tex/feynmf/feynmf.dtx,v 1.5 1994/05/28 12:10:04 ohl Exp
  4. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  5. % Feynmf is free software; you can redistribute it and/or modify it
  6. % under the terms of the GNU General Public License as published by 
  7. % the Free Software Foundation; either version 2, or (at your option)
  8. % any later version.
  9. % Feynmf is distributed in the hope that it will be useful, but
  10. % WITHOUT ANY WARRANTY; without even the implied warranty of
  11. % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
  12. % GNU General Public License for more details.
  13. % You should have received a copy of the GNU General Public License
  14. % along with this program; if not, write to the Free Software
  15. % Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  17. % \fi
  18. %% \CheckSum{425}
  19. %% \CharacterTable
  20. %%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
  21. %%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
  22. %%   Digits        \0\1\2\3\4\5\6\7\8\9
  23. %%   Exclamation   \!     Double quote  \"     Hash (number) \#
  24. %%   Dollar        \$     Percent       \%     Ampersand     \&
  25. %%   Acute accent  \'     Left paren    \(     Right paren   \)
  26. %%   Asterisk      \*     Plus          \+     Comma         \,
  27. %%   Minus         \-     Point         \.     Solidus       \/
  28. %%   Colon         \:     Semicolon     \;     Less than     \<
  29. %%   Equals        \=     Greater than  \>     Question mark \?
  30. %%   Commercial at \@     Left bracket  \[     Backslash     \\
  31. %%   Right bracket \]     Circumflex    \^     Underscore    \_
  32. %%   Grave accent  \`     Left brace    \{     Vertical bar  \|
  33. %%   Right brace   \}     Tilde         \~}
  34. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  35. % \MakeShortVerb{\|}
  36. % \title{%
  37. %   \FMF: \\
  38. %   Drawing Feynman Diagrams \\
  39. %   with \LaTeX{} and \MF}
  40. % \author{%
  41. %   Thorsten Ohl\thanks{e-mail:
  42. %     {\tt Thorsten.Ohl@Physik.TH-Darmstadt.de}}\\
  43. %   \hfil \\
  44. %   Technische Hochschule Darmstadt \\
  45. %   Schlo\ss gartenstr. 9 \\
  46. %   D-64289 Darmstadt \\
  47. %   Germany}
  48. % \maketitle
  49. % \begin{abstract}
  50. %   \FMF{} is a \LaTeX{} package for easy drawing of professional
  51. %   quality Feynman diagrams with \MF.  \FMF{} lays out most
  52. %   diagrams satisfactorily from the structure of the graph without
  53. %   any need for manual intervention.  Nevertheless all the power of
  54. %   \MF{} is available for the most obscure cases.
  55. % \end{abstract}
  56. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  57. % \tableofcontents
  58. % \begin{fmffile}{fmfsampl}
  59. % \def\bottomfraction{0}
  60. % \unitlength=1mm
  61. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  62. % \section{Introduction}
  63. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  64. % \subsection{Purpose and scope}
  65. % In recent years, \TeX\footnote{\TeX{} is a trademark of the American
  66. %   Mathematical Society.}~\cite{TeX}
  67. % and \LaTeX\footnote{\LaTeX{} might be a trademark of Addison Wesley
  68. %   Publishing Company.}~\cite{LaTeX}
  69. % have revolutionized the way
  70. % we share information in theoretical physics (and other areas).  Not
  71. % only does \TeX{} provide typographical capabilities, which transcend
  72. % those of commercial ``wordprocessors'' substantially, \TeX{} documents
  73. % are also completely portable.  Since implementations are available
  74. % on essentially all computers in use in the community, documents can
  75. % be shared without the usual restrictions of proprietary data
  76. % formats.  This has enabled us to collaborate on papers with
  77. % colleagues on the other side of the globe, to replace the mailing of
  78. % hard copy preprints by electronic transmission and to submit these
  79. % papers electronically to the publisher.
  80. % This portability comes with a price, though.  \TeX{} (and \LaTeX)
  81. % do not address the issue of graphical information, apart from the
  82. % rudimentary (but very useful) capabilities of the \LaTeX{} |picture|
  83. % environment and similar
  84. % packages~\cite{LaTeX-Companion}, which provide line drawings like
  85. % the one in figure~\ref{fig:flow}.  As an de facto standard for the
  86. % inclusion of more complex graphics has emerged the inclusion of
  87. % PostScript~\footnote{PostScript is a trademark of Adobe Systems
  88. %   Inc.} 
  89. % files.  The complete document can then
  90. % be printed on any PostScript device.
  91. % Still there are areas, where complementary approaches seem worth
  92. % pursuing.  In particular this is the case, if the graphical
  93. % information is highly formalized, like the case at hand.  Feynman
  94. % diagrams are specified by their topology and the type of particles
  95. % connecting the vertices.  Thus a given diagram can be reproduced
  96. % from a very concise specification, if the software is able to choose
  97. % a reasonable layout (semi-)automatically.
  98. % \MF\footnote{\MF{} is a trademark of Addison Wesley Publishing
  99. %   Company.}~\cite{MF}
  100. % appears to be the perfect tool for such a purpose\footnote{%
  101. %   Another perfect tool is \MP~\protect\cite{MetaPost}, which is
  102. %   unfortunately not available without signing a non disclosure
  103. %   agreement with AT\&T.  It is however hoped that \MP{} will be
  104. %   freed in the near future.  \FMF{} supports \MF{} as
  105. %   well as \MP{} (under the names \texttt{feynmp.sty} and
  106. %   \texttt{feynmp.mp}).},
  107. % since
  108. % \begin{enumerate}
  109. %   \item{} it is part of any (reasonable) \TeX{} installation, thus
  110. %     available to all potential users,
  111. %   \item{} it has very powerful graphics primitivs, which allow high
  112. %     quality output, and
  113. %   \item{} it has builtin linear algebra, which allows us to choose a
  114. %     layout automatically.
  115. % \end{enumerate}
  116. % Still, providing at least the basic interface in \LaTeX{} macros
  117. % seems appropriate for boosting the acceptance among the less
  118. % technically oriented parts of the audience.
  119. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  120. % \subsection{Relation to similar packages}
  121. % Before we start, a couple of words about some complementary packages
  122. % on the market are in order.  First of all: I failed to do my
  123. % homework and didn't try hard enough to find~\cite{hoenig} in a
  124. % library.  I'm sure that in there is a smarter way of returning
  125. % information from \MF{} to \TeX{}.  Those who don't know the
  126. % literature are doomed to reinvent the wheel.  But this isn't a
  127. % scholarly work and reinventing the wheel was \emph{fun!}
  128. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  129. % \subsubsection{Feynman}
  130. % Micheal Levine's |feynman| package~\cite{levine} is
  131. % implemented on top of the standard \LaTeX{} |picture|
  132. % environment~\cite{LaTeX}.  This makes it completely portable (no
  133. % need for a correct \MF{} installation), but it requires manual
  134. % layout and the graphics output is (though very useful) less than
  135. % perfect.
  136. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  137. % \subsubsection{Axodraw}
  138. % Jos Vermaseren's |axodraw| package~\cite{axodraw} uses
  139. % |\special|s to access PostScript primitives for drawing diagrams.
  140. % This approach is inherently not portable (though the ubiquity of
  141. % PostScript printers makes this a minor point) but at least as
  142. % flexible as the present one.  It still requires manual layout,
  143. % though.
  144. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  145. % \subsection{Historical note}
  146. % This code has a rather long history\footnote{Which is a partial
  147. % explanation, if not excuse, for its slightly incoherent structure.}.
  148. % Most of the sections~\ref{sec:mf-basics}, \ref{sec:pictures},
  149. % \ref{sec:shading}, and~\ref{sec:drawing} started in 1989 as
  150. % |feynman.mf|, a library of \MF{} macros for drawing Feynman
  151. % diagrams in my thesis.  The layout had to be chossen completely
  152. % manually, which required a long edit-process-preview cycle and made
  153. % |feynman.mf| awkward to use.
  154. % Nevertheless, it survived for five years without major
  155. % modifications, only slight enhancements had been made.  Early in
  156. % 1994, I became aware of Thomas Leathrum's |mfpic|~\cite{mfpic}.
  157. % This inspired me to shift the user interface from \MF{} to
  158. % \LaTeX, because this allows a smoother blending of the \LaTeX{}
  159. % |picture| environment with \FMF{}.  While doing this and after
  160. % having been taught by Tim Stelzer's and Bill Long's
  161. % \texttt{MADGRAPH}~\cite{madgraph} that minimizing the length of the
  162. % graph gives surprisingly good results for tree graphs\footnote{I had
  163. % thought about this earlier myself, but foolishly discarded the idea.
  164. % I didn't expect such a ``too simple'' method to give esthetically
  165. % pleasing results for loop graphs, which were my main concern.}, I
  166. % added the graph manipulation code in section~\ref{sec:graphs}.
  167. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  168. % \subsection{Projects}
  169. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  170. % \subsubsection{Virtual Graphs}
  171. % \label{sec:virtual-pictures}
  172. % In a future version, \FMF{} will be able to draw ``virtual''
  173. % graphs, i.e.~graphs which are larger than the current limit enforced
  174. % by numeric overflow at higher resolutions.  This can be implemented
  175. % by calculating the layout of a miniature graph and afterwards
  176. % distributing the full graph among several \MF{} characters.
  177. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  178. % \subsection{Conclusion}
  179. % It goes without saying that \FMF{} is not perfect.  There are
  180. % cases where using a graphical drawing tool with a mouse will give
  181. % more pleasing results in less time.  But in most cases, \FMF{}
  182. % will give satisfactory results without any fine tuning.  These will
  183. % be reproducible and independent from the computer it is running on.
  184. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  185. % \section{Usage}
  186. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  187. % \subsection{Invocation}
  188. % Instructing \LaTeX{} to use \FMF{} is as simple as\footnote{As
  189. % given, this applies to \LaTeXe.  Adapting \FMF{} to \LaTeX{} v2.09
  190. % should be simple.}
  191. % \begin{verbatim}
  192. %   \usepackage{feynmf}
  193. % \end{verbatim}
  194. % and calling \MF{} should not be harder as
  195. % \begin{verbatim}
  196. %   mf '\mode:=localmode; input foobar'
  197. % \end{verbatim}
  198. % where |foobar| is the name of your \MF{} output file.
  199. % The hard part usually lies in instructing \TeX{} and your favorite
  200. % |dvi|-driver how to find the generated |tfm| and |gf| (resp.~|pk|)
  201. % files.  This is highly system dependent and can be trivial (as in
  202. % the standard UNIX\footnote{UNIX was a trademark of UNIX Systems
  203. %   Laboratory, but is rumored to have been donored to X/Open.}
  204. % \TeX{} installations) or almost impossible (as
  205. % under MVS).  Please consult your local guide or local ``\TeX{}
  206. % Wizards'' on this point.
  207. % If you have \MP, then you can use it by placing
  208. % \begin{verbatim}
  209. %   \usepackage[dvips]{feynmp}
  210. % \end{verbatim}
  211. % in your \LaTeX{} source.  Here |dvips| is an option for the
  212. % \LaTeXe{} |egraphics| package which is used for including the
  213. % generated PostScript files.  It should be replaced by your local
  214. % supported |dvi| driver.  Calling \MP{} is usually even simpler
  215. % \begin{verbatim}
  216. %   mp foobar
  217. % \end{verbatim}
  218. % since there is no mode to be picked.
  219. % Currently, \FMF{} will work only with \LaTeXe{}.  Porting to
  220. % \LaTeX2.09 should be a trivial exercise of replacing some
  221. % convenience macros which are new with \LaTeXe\footnote{But who is
  222. %   still using \LaTeX2.09, anyway?}  Porting to plain \TeX{} macro
  223. % packages will require more work, because the |picture| environment
  224. % is used.  Anyway, it should be simple if the label mechanism is
  225. % implemented on top
  226. % {P\kern-.12em\lower.5ex\hbox{I}\kern-.075emC\kern-.11em\TeX}, |epic|
  227. % or similar packages.
  228. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  229. % \begin{figure}
  230. %   \begin{center}
  231. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  232. % \setlength{\unitlength}{0.012500in}%
  233. % \begingroup\makeatletter\ifx\SetFigFont\undefined
  234. % \def\x#1#2#3#4#5#6#7\relax{\def\x{#1#2#3#4#5#6}}%
  235. % \expandafter\x\fmtname xxxxxx\relax \def\y{splain}%
  236. % \ifx\x\y   % LaTeX or SliTeX?
  237. % \gdef\SetFigFont#1#2#3{%
  238. %   \ifnum #1<17\tiny\else \ifnum #1<20\small\else
  239. %   \ifnum #1<24\normalsize\else \ifnum #1<29\large\else
  240. %   \ifnum #1<34\Large\else \ifnum #1<41\LARGE\else
  241. %      \huge\fi\fi\fi\fi\fi\fi
  242. %   \csname #3\endcsname}%
  243. % \else
  244. % \gdef\SetFigFont#1#2#3{\begingroup
  245. %   \count@#1\relax \ifnum 25<\count@\count@25\fi
  246. %   \def\x{\endgroup\@setsize\SetFigFont{#2pt}}%
  247. %   \expandafter\x
  248. %     \csname \romannumeral\the\count@ pt\expandafter\endcsname
  249. %     \csname @\romannumeral\the\count@ pt\endcsname
  250. %   \csname #3\endcsname}%
  251. % \fi
  252. % \fi\endgroup
  253. % \begin{picture}(377,400)(3,420)
  254. % \thinlines
  255. % \put( 40,740){\framebox(80,80){}}
  256. % \put( 55,795){\makebox(0,0)[lb]{\smash{\SetFigFont{12}{14.4}{tt}foo.tex}}}
  257. % \put(280,760){\framebox(60,40){}}
  258. % \put(295,780){\makebox(0,0)[lb]{\smash{\SetFigFont{12}{14.4}{tt}fd.mf}}}
  259. % \put(160,680){\framebox(60,40){}}
  260. % \put(170,705){\makebox(0,0)[lb]{\smash{\SetFigFont{12}{14.4}{tt}fd.log}}}
  261. % \put(320,640){\framebox(60,40){}}
  262. % \put(323,664){\makebox(0,0)[lb]{\smash{\SetFigFont{12}{14.4}{tt}fd.300gf}}}
  263. % \put(100,600){\framebox(60,40){}}
  264. % \put(110,620){\makebox(0,0)[lb]{\smash{\SetFigFont{12}{14.4}{tt}fd.t1}}}
  265. % \put(180,600){\framebox(60,40){}}
  266. % \put(185,622){\makebox(0,0)[lb]{\smash{\SetFigFont{12}{14.4}{tt}fd.t2}}}
  267. % \put(260,560){\framebox(60,40){}}
  268. % \put(270,585){\makebox(0,0)[lb]{\smash{\SetFigFont{12}{14.4}{tt}fd.tfm}}}
  269. % \put( 40,420){\framebox(80,80){}}
  270. % \put( 50,485){\makebox(0,0)[lb]{\smash{\SetFigFont{12}{14.4}{tt}foo.dvi}}}
  271. % \put(290,463){\oval(130,74)}
  272. % \put(260,470){\makebox(0,0)[lb]{\smash{\SetFigFont{12}{14.4}{tt}lpr}}}
  273. % \thicklines
  274. % \put(295,760){\vector(-3,-1){106.500}}
  275. % \put(325,760){\vector( 1,-3){ 26.500}}
  276. % \put(310,760){\vector(-1,-4){ 39.118}}
  277. % \multiput(120,780)(11.85185,0.00000){14}{\line( 1, 0){  5.926}}
  278. % \put(280,780){\vector( 1, 0){0}}
  279. % \put( 60,500){\vector( 0,-1){0}}
  280. % \multiput( 60,740)(0.00000,-4.52830){53}{\makebox(0.4444,0.6667){\SetFigFont{10}{12}{rm}.}}
  281. % \put( 80,500){\vector(-1,-2){0}}
  282. % \multiput(130,600)(-2.00000,-4.00000){25}{\makebox(0.4444,0.6667){\SetFigFont{10}{12}{rm}.}}
  283. % \put(120,480){\vector(-2,-1){0}}
  284. % \multiput(280,560)(-4.00000,-2.00000){40}{\makebox(0.4444,0.6667){\SetFigFont{10}{12}{rm}.}}
  285. % \put(210,640){\vector( 1,-4){0}}
  286. % \multiput(200,680)(1.11764,-4.47058){9}{\makebox(0.4444,0.6667){\SetFigFont{10}{12}{rm}.}}
  287. % \put(129,642){\vector(-4,-3){0}}
  288. % \multiput(180,680)(-3.65714,-2.74286){14}{\makebox(0.4444,0.6667){\SetFigFont{10}{12}{rm}.}}
  289. % \thinlines
  290. % \put(120,460){\vector( 1, 0){105}}
  291. % \put(300,560){\vector( 0,-1){ 60}}
  292. % \put(350,640){\vector( 0,-1){145}}
  293. % \thicklines
  294. % \put(105,494){\vector(-1,-1){0}}
  295. % \multiput(211,600)(-3.19697,-3.19697){33}{\makebox(0.4444,0.6667){\SetFigFont{10}{12}{rm}.}}
  296. % \put(160,790){\makebox(0,0)[lb]{\smash{\SetFigFont{12}{14.4}{rm}\LaTeX{} \#1}}}
  297. % \put(360,535){\makebox(0,0)[lb]{\smash{\SetFigFont{12}{14.4}{rm}dvi2xxx}}}
  298. % \put(350,725){\makebox(0,0)[lb]{\smash{\SetFigFont{12}{14.4}{rm}\MF}}}
  299. % \put(  3,663){\makebox(0,0)[lb]{\smash{\SetFigFont{12}{14.4}{rm}\LaTeX{} \#2}}}
  300. % \end{picture}
  301. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  302. %   \end{center}
  303. %   \caption{Flow of information in a \FMF{} application:  The
  304. %      first \LaTeX{} pass is shown with a dashed line.  The \MF{}
  305. %      pass is shown with the full lines and the second \LaTeX{} pass
  306. %      with dotted lines.  The final dvi translation step is shown with
  307. %      thin lines.}
  308. %   \label{fig:flow}
  309. % \end{figure}
  310. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  311. % The flow of information depicted in figure~\ref{fig:flow} looks much
  312. % more complicated than it is.  The important feature is that there a
  313. % two sets of files which can be used to distribute a document:
  314. % \begin{enumerate}
  315. %   \item{} Iff the recipient has a working \MF{} installation
  316. %     (which shouldn't be a problem, except for some impoverished
  317. %     commercial implementations), the document can be typset from the
  318. %     \LaTeX{} source \emph{alone}, by running \LaTeX{}, \MF{}
  319. %     and \LaTeX{} again (the latter step might have to be repeated to
  320. %     get cross references right).
  321. %   \item{} Another possibility (which doesn't require \MF{} on
  322. %     the recipient's side), is to distribute the \LaTeX{} source, the
  323. %     |tfm| and |gf| files (or |pk| files respectively) along with the
  324. %     label files with extension |t|$n$ (where $n$ as an integer).
  325. %     Distributing the \MF{} |log| files is a possible alternative
  326. %     for the latter, but discouraged, because these are prone to be
  327. %     erased accidentally.
  328. % \end{enumerate}
  329. % I should add one caveat here: some |dvi| file previewers
  330. % (e.g.~xdvi(1) under UNIX) do \emph{not} reread font information if
  331. % the |tfm| or |pk| files have changed, even though they reread the
  332. % |dvi| file if it has changed.  Thus you have to restart such
  333. % previewers if you have made changes in diagrams to see these changes
  334. % on the screen.
  335. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  336. % \begin{figure}
  337. %   \begin{center}
  338. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  339. % \setlength{\unitlength}{0.012500in}%
  340. % \begingroup\makeatletter\ifx\SetFigFont\undefined
  341. % \def\x#1#2#3#4#5#6#7\relax{\def\x{#1#2#3#4#5#6}}%
  342. % \expandafter\x\fmtname xxxxxx\relax \def\y{splain}%
  343. % \ifx\x\y   % LaTeX or SliTeX?
  344. % \gdef\SetFigFont#1#2#3{%
  345. %   \ifnum #1<17\tiny\else \ifnum #1<20\small\else
  346. %   \ifnum #1<24\normalsize\else \ifnum #1<29\large\else
  347. %   \ifnum #1<34\Large\else \ifnum #1<41\LARGE\else
  348. %      \huge\fi\fi\fi\fi\fi\fi
  349. %   \csname #3\endcsname}%
  350. % \else
  351. % \gdef\SetFigFont#1#2#3{\begingroup
  352. %   \count@#1\relax \ifnum 25<\count@\count@25\fi
  353. %   \def\x{\endgroup\@setsize\SetFigFont{#2pt}}%
  354. %   \expandafter\x
  355. %     \csname \romannumeral\the\count@ pt\expandafter\endcsname
  356. %     \csname @\romannumeral\the\count@ pt\endcsname
  357. %   \csname #3\endcsname}%
  358. % \fi
  359. % \fi\endgroup
  360. % \begin{picture}(357,400)(3,420)
  361. % \thinlines
  362. % \put( 40,740){\framebox(80,80){}}
  363. % \put( 55,795){\makebox(0,0)[lb]{\smash{\SetFigFont{12}{14.4}{tt}foo.tex}}}
  364. % \put( 40,420){\framebox(80,80){}}
  365. % \put( 50,485){\makebox(0,0)[lb]{\smash{\SetFigFont{12}{14.4}{tt}foo.dvi}}}
  366. % \put(290,463){\oval(130,74)}
  367. % \put(260,470){\makebox(0,0)[lb]{\smash{\SetFigFont{12}{14.4}{tt}lpr}}}
  368. % \put(100,640){\framebox(60,40){}}
  369. % \put(110,660){\makebox(0,0)[lb]{\smash{\SetFigFont{12}{14.4}{tt}fd.t1}}}
  370. % \put(180,640){\framebox(60,40){}}
  371. % \put(185,662){\makebox(0,0)[lb]{\smash{\SetFigFont{12}{14.4}{tt}fd.t2}}}
  372. % \put(220,580){\framebox(60,40){}}
  373. % \put(230,605){\makebox(0,0)[lb]{\smash{\SetFigFont{12}{14.4}{tt}fd.1}}}
  374. % \put(300,580){\framebox(60,40){}}
  375. % \put(303,604){\makebox(0,0)[lb]{\smash{\SetFigFont{12}{14.4}{tt}fd.2}}}
  376. % \put(280,760){\framebox(60,40){}}
  377. % \put(295,780){\makebox(0,0)[lb]{\smash{\SetFigFont{12}{14.4}{tt}fd.mp}}}
  378. % \thicklines
  379. % \put(325,760){\vector( 0,-1){140}}
  380. % \put(310,760){\vector(-1,-2){ 69}}
  381. % \multiput(120,780)(11.85185,0.00000){14}{\line( 1, 0){  5.926}}
  382. % \put(280,780){\vector( 1, 0){0}}
  383. % \put( 60,500){\vector( 0,-1){0}}
  384. % \multiput( 60,740)(0.00000,-4.52830){53}{\makebox(0.4444,0.6667){\SetFigFont{10}{12}{rm}.}}
  385. % \put( 83,499){\vector(-1,-3){0}}
  386. % \multiput(130,640)(-1.42424,-4.27273){33}{\makebox(0.4444,0.6667){\SetFigFont{10}{12}{rm}.}}
  387. % \put(115,486){\vector(-4,-3){0}}
  388. % \multiput(240,580)(-3.56571,-2.67429){35}{\makebox(0.4444,0.6667){\SetFigFont{10}{12}{rm}.}}
  389. % \thinlines
  390. % \put(120,460){\vector( 1, 0){105}}
  391. % \put(260,580){\vector( 1,-2){ 40}}
  392. % \thicklines
  393. % \put(104,497){\vector(-3,-4){0}}
  394. % \multiput(211,640)(-2.67900,-3.57200){40}{\makebox(0.4444,0.6667){\SetFigFont{10}{12}{rm}.}}
  395. % \thinlines
  396. % \put(345,580){\vector(-1,-2){ 40}}
  397. % \thicklines
  398. % \put(295,760){\vector(-1,-1){ 82}}
  399. % \put(295,760){\vector(-2,-1){164}}
  400. % \put(120,480){\vector(-2,-1){0}}
  401. % \multiput(320,580)(-4.00000,-2.00000){50}{\makebox(0.4444,0.6667){\SetFigFont{10}{12}{rm}.}}
  402. % \put(160,790){\makebox(0,0)[lb]{\smash{\SetFigFont{12}{14.4}{rm}\LaTeX \#1}}}
  403. % \put(  3,663){\makebox(0,0)[lb]{\smash{\SetFigFont{12}{14.4}{rm}\LaTeX \#2}}}
  404. % \put(345,520){\makebox(0,0)[lb]{\smash{\SetFigFont{12}{14.4}{rm}dvips}}}
  405. % \put(340,685){\makebox(0,0)[lb]{\smash{\SetFigFont{12}{14.4}{rm}\MP}}}
  406. % \end{picture}
  407. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  408. %   \end{center}
  409. %   \caption{Flow of information in a \FMF{} application if \MP{} is
  410. %      used instead of \MF.}
  411. %   \label{fig:flowp}
  412. % \end{figure}
  413. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  414. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  415. % \subsection{Basic usage}
  416. % The basic features of \FMF{} are (or rather ``should be'')
  417. % available through the \LaTeX{} interface.  Not knowledge of
  418. % \MF{} is necessary.
  419. % \DescribeEnv{fmffile}
  420. % Upto 255 characters can be placed into one \MF{} file, they are
  421. % enclosed in a single |fmffile| environment.  The environment
  422. % takes the filename as argument.  Currently \FMF{} does \emph{not}
  423. % check that the 255 character limit per file is not overrun.
  424. % \begin{verbatim}
  425. %   \begin{fmffile}{foobar}
  426. %     ...
  427. %   \end{fmffile}
  428. % \end{verbatim}
  429. % \DescribeEnv{fmfchar}
  430. % Draw one character and place it here.  Arguments are
  431. % |(|\meta{width}|,|\meta{height}|)| as in:
  432. % \begin{verbatim}
  433. %   \begin{fmfchar}(40,25)
  434. %     ...
  435. %   \end{fmfchar}
  436. % \end{verbatim}
  437. % \DescribeEnv{fmfchar*}
  438. % Same as |fmfchar|, but enclosed in a |picture| environment of the
  439. % same size and supporting \LaTeX{} labels.
  440. % \begin{verbatim}
  441. %   \begin{fmfchar*}(40,25)
  442. %     ...
  443. %   \end{fmfchar*}
  444. % \end{verbatim}
  445. % \DescribeMacro{\fmfincoming}
  446. % \DescribeMacro{\fmfoutgoing}
  447. % \DescribeMacro{\fmfsurround}
  448. % Positioning of
  449. % external vertices has to done explicitely.  The technical reason is
  450. % that they would otherwise collapse with their neighbors, but
  451. % practical reasons also suggest to give the user full control here.
  452. % |\fmfincoming{|\meta{v1}$[$|,|\ldots$]$|}| places the
  453. % vertices in the comma separated list \meta{v1},\ldots
  454. % equidistantly on a smooth path on the left side of the diagram.
  455. % |\fmfoutgoing{|\meta{v1}$[$|,|\ldots$]$|}| does the same
  456. % thing on the right.
  457. % |\fmfsurround{|\meta{v1}$[$|,|\ldots$]$|}|
  458. % places its arguments on smooth path
  459. % surrounding the diagram:
  460. % \begin{center}
  461. %   \label{p:galleries}
  462. %   \fbox{\begin{fmfchar}(25,20)
  463. %     \fmfpen{thick}%
  464. %     \fmfincoming{i1,i2,i3,i4}%
  465. %     \fmfdot{i1,i2,i3,i4}%
  466. %     \fmfcmd{draw (in_gallery);}
  467. %   \end{fmfchar}}\qquad
  468. %   \fbox{\begin{fmfchar}(25,20)
  469. %     \fmfpen{thick}%
  470. %     \fmfoutgoing{o1,o2,o3,o4}%
  471. %     \fmfdot{o1,o2,o3,o4}%
  472. %     \fmfcmd{draw (out_gallery);}
  473. %   \end{fmfchar}}\qquad
  474. %   \fbox{\begin{fmfchar}(25,20)
  475. %     \fmfpen{thick}%
  476. %     \fmfsurround{e1,e2,e3,e4,e5,e6,e7}%
  477. %     \fmfdot{e1,e2,e3,e4,e5,e6,e7}%
  478. %     \fmfcmd{draw (surround_gallery);}
  479. %   \end{fmfchar}}
  480. % \end{center}
  481. % The former two are more useful in the
  482. % context of diagrams for scattering matrix elements, while the latter
  483. % can be used for general Green's functions.
  484. % \DescribeMacro{\fmfpen}
  485. % Pick up a pen of the specified size.  |\fmfpen{|\meta{weight}|}|
  486. % is used for changing the weight (i.e.~thickness) of the lines.
  487. % Predefined sizes are |thin| and |thick|.
  488. % \def\linesample#1{%
  489. %   \begin{fmfchar}(30,4)
  490. %     \fmfincoming{i1,i2}
  491. %     \fmfoutgoing{o1,o2}
  492. %     \fmf{#1}{i1,o1}
  493. %   \end{fmfchar}}
  494. % \begin{table}
  495. %   \begin{tabular}{rcp{60mm}}
  496. %     Name        & Example               & Notes \\\hline
  497. %     |boson|     & \linesample{boson}    &
  498. %                       |wiggly_len| gives distance of wiggles  \\
  499. %     |dashes|    & \linesample{dashes}   & 
  500. %                       |dash_len| gives length of dashes  \\
  501. %     |dots|      & \linesample{dots}   & 
  502. %                       |dot_len| gives distance of dashes  \\
  503. %     |double|    & \linesample{double}   & \\
  504. %     |electron|  & \linesample{electron} & \\
  505. %     |fermion|   & \linesample{fermion}  & \\
  506. %     |ghost|     & \linesample{ghost}    & \\
  507. %     |gluon|     & \linesample{gluon}    &
  508. %                       |curly_len| gives distance of curls.\hfil\goodbreak
  509. %                       See also figure~\ref{fig:gluons} \\
  510. %     |heavy|     & \linesample{heavy}    & heavy quarks (HQET) \\
  511. %     |phantom|   & \linesample{phantom}  &
  512. %                       (yes, this \emph{is} empty!) \\
  513. %     |photon|    & \linesample{photon}   &
  514. %                       |wiggly_len| gives distance of wiggles  \\
  515. %     |plain|     & \linesample{plain}    & \\
  516. %     |quark|     & \linesample{quark}    & \\
  517. %     |scalar|    & \linesample{scalar}   &
  518. %                       |dash_len| gives length of dashes  \\
  519. %     |vanilla|   & \linesample{vanilla}  &
  520. %   \end{tabular}
  521. %   \caption{Available line styles}
  522. %   \label{tab:line-styles}
  523. % \end{table}
  524. % \begin{table}
  525. %   \begin{tabular}{rp{60mm}}
  526. %     Name        & Explanation \\\hline
  527. %     |tension|   & draw a tighter ($>1$) or looser ($<1$) arc \\
  528. %     |left|      & draw on a halfcircle on the left \\
  529. %     |right|     & draw on a halfcircle on the right \\
  530. %     |straight|  & draw on a straight line \\
  531. %     |label|     & \TeX{} text for labeling the arc \\
  532. %     |side|      & force placement of the label on the |left| or
  533. %                   |right| \\
  534. %     |dist|      & place label at a distance |dist|
  535. %   \end{tabular}
  536. %   \caption{Available line options}
  537. %   \label{tab:line-options}
  538. % \end{table}
  539. % \DescribeMacro{\fmf}
  540. % This is the the most frequently used macro in \FMF{} applications.
  541. % |\fmf{|\meta{style}\allowbreak
  542. %   $[$|,|\meta{opt}\allowbreak
  543. %   $[$|=|\meta{val}$]$|,|\ldots$]$|}{|\meta{v1}|,|\meta{v2}\allowbreak
  544. %   $[$|,|\ldots$]$|}|
  545. % connects the vertices \textit{v1,v2,\ldots} with a line of style
  546. % \meta{style}, using a set of options \meta{opt} with (optional)
  547. % value \meta{val}.  If a vertex is not
  548. % known yet, it is added to the diagram.  Note that the actual drawing
  549. % is not done immediately, because the positions can only be
  550. % calculated when \emph{all} vertices are known. The currently
  551. % available styles are collected in table~\ref{tab:line-styles}.  Most
  552. % names should be self explanatory\footnote{At least for the likely
  553. % users of \FMF!} and are not discussed further.  The |phantom|
  554. % style is special, because it
  555. % only enters the vertices and does \emph{not} cause a line to be
  556. % drawn.  This is extremely useful for advanced layout features, as
  557. % explained below.
  558. % The supported options are collected in
  559. % table~\ref{tab:line-options}\footnote{%
  560. %   \begin{dubious}
  561. %     One particulary useful further option would be \texttt{smooth},
  562. %     allowing for several lines joined smoothly.  Early
  563. %     experimentation has shown however, that the results are not
  564. %     always what one expects and that there is a lot of room for
  565. %     abuse.
  566. %   \end{dubious}}.
  567. % \begin{table}
  568. %   \begin{tabular}{rp{60mm}}
  569. %     Name        & Explanation \\\hline
  570. %     |blob|      & draw a shaded blob of the given diameter at the
  571. %                   vertex \\
  572. %     |dot|       & draw a dot at the vertex
  573. %   \end{tabular}
  574. %   \caption{Available vertex shapes}
  575. %   \label{tab:vertex-shapes}
  576. % \end{table}
  577. % \begin{table}
  578. %   \begin{tabular}{rp{60mm}}
  579. %     Name        & Explanation \\\hline
  580. %     |label|     & \TeX{} text for labeling the vertex \\
  581. %     |angle|     & force placement of the label at the given angle from
  582. %                   the vertex \\
  583. %     |dist|      & place label at a distance |dist|
  584. %   \end{tabular}
  585. %   \caption{Available vertex options}
  586. %   \label{tab:vertex-options}
  587. % \end{table}
  588. % \DescribeMacro{\fmfv}
  589. % Declare vertices with options:
  590. % |\fmfv{|\meta{shape}$[$|=|\meta{val}$]$\allowbreak
  591. %   $[$|,|\meta{opt}\allowbreak
  592. %   $[$|=|\meta{val}$]$|,|\ldots$]$|}{|\meta{v1}\allowbreak
  593. %   $[$|,|\ldots$]$|}|
  594. % Currently it is only used for adding labels to a vertex.  Supported
  595. % shapes are listed in table~\ref{tab:vertex-shapes}, and supported
  596. % options are collected in table~\ref{tab:vertex-options}\footnote{%
  597. %   \begin{dubious}
  598. %      This will be generalized to give more shapes.
  599. %     Apart from predefined shapes, we will have userdefined paths
  600. %     specifying arbitrary shapes.
  601. %   \end{dubious}}.
  602. % \DescribeMacro{\fmfblob}
  603. % Draw a blob of the specified diameter at the vertices.
  604. % |\fmfblob{|\meta{diameter}|}{|\meta{v1}\allowbreak
  605. %   $[$|,|\ldots$]$|}| is equivalent to
  606. % |\fmfv{blob=|\meta{diameter}\allowbreak
  607. %   $[$|,|\meta{opt}\allowbreak
  608. %   $[$|=|\meta{val}$]$|,|\ldots$]$|}{|\meta{v1}\allowbreak
  609. %   $[$|,|\ldots$]$|}|
  610. % \DescribeMacro{\fmfdot}
  611. % Draw a dot at the vertices given as arguments.
  612. % |\fmfdot{|\meta{v1}\allowbreak
  613. %   $[$|,|\ldots$]$|}| is equivalent to
  614. % |\fmfv{dot|$[$|,|\meta{opt}\allowbreak
  615. %   $[$|=|\meta{val}$]$|,|\ldots$]$|}{|\meta{v1}\allowbreak
  616. %   $[$|,|\ldots$]$|}|
  617. % \DescribeMacro{\fmfposition}
  618. % Calculate the positions of the vertices based on the arcs which are
  619. % defined up to this point.  Usually this calculation is performed
  620. % automatically at the end of the |fmfchar| environment. Calling it
  621. % explicitely, is useful for adding arcs which should not enter the
  622. % calculation.
  623. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  624. % \subsection{Examples}
  625. % As an example, consider drawing a straightforward box diagram,
  626. % familier from $K$-$\bar K$, $D$-$\bar D$, and  $B$-$\bar B$ mixing.
  627. % The commands for the labels are not shown here, they are discussed
  628. % in section~\ref{sec:labels}
  629. % \vspace*{\baselineskip}
  630. % \begin{minipage}{0.6\linewidth}
  631. %   We start the diagram and pick up a thick pen:
  632. %   \begin{verbatim}
  633. %   \begin{fmfchar}(40,25)
  634. %     \fmfpen{thick}
  635. %   \end{verbatim}
  636. %   The incoming and outcoming vertices are placed on the left and
  637. %   right hand side, respectively:
  638. %   \begin{verbatim}
  639. %     \fmfincoming{i1,i2}
  640. %     \fmfoutgoing{o1,o2}
  641. %   \end{verbatim}
  642. %   Now we tell \FMF{} how the arcs are connected.
  643. %   \begin{verbatim}
  644. %     \fmf{fermion}{i1,v1,v3,o1}
  645. %     \fmf{fermion}{o2,v4,v2,i2}
  646. %     \fmf{photon}{v1,v2}
  647. %     \fmf{photon}{v3,v4}
  648. %   \end{verbatim}
  649. %   Finally we tell \FMF{} to draw dots at the vertices and we're
  650. %   done.
  651. %   \begin{verbatim}
  652. %     \fmfdot{v1,v2,v3,v4}
  653. %   \end{fmfchar}
  654. %   \end{verbatim}
  655. % \end{minipage}
  656. % \hfill
  657. % \begin{minipage}{0.35\linewidth}
  658. %   \begin{center}
  659. %     \begin{fmfchar*}(40,25)
  660. %       \fmfpen{thick}
  661. %       \fmfincoming{i1,i2}
  662. %       \fmflabel{$\noexpand\bar b$}{i1}
  663. %       \fmflabel{$d$}{i2}
  664. %       \fmfoutgoing{o1,o2}
  665. %       \fmflabel{$\noexpand\bar d$}{o1}
  666. %       \fmflabel{$b$}{o2}
  667. %       \fmf{fermion}{i1,v1}
  668. %       \fmf{fermion,label=$\noexpand\bar t,,\noexpand\bar c,,
  669. %                           \noexpand\bar u$,side=right}{v1,v3}
  670. %       \fmf{fermion}{v3,o1}
  671. %       \fmf{fermion}{o2,v4}
  672. %       \fmf{fermion,label=$t,,c,,u$,side=right}{v4,v2}
  673. %       \fmf{fermion}{v2,i2}
  674. %       \fmf{photon,label=$W^+$,side=left}{v1,v2}
  675. %       \fmf{photon,label=$W^-$,side=right}{v3,v4}
  676. %       \fmfdot{v1,v2,v3,v4}
  677. %     \end{fmfchar*}
  678. %   \end{center}
  679. % \end{minipage}
  680. % \label{page:simple-examples}
  681. % Here is the resonant $s$-channel contribution to $e^+e^-\to 4f$.
  682. % (From now on, we do no longer display the
  683. % |\begin{fmfchar}(40,25)|, |\fmfpen{thick}|, \ldots,
  684. % |\end{fmfchar}| surrounding all pictures.)
  685. % \vspace*{\baselineskip}
  686. % \begin{minipage}{0.6\linewidth}
  687. %   \begin{verbatim}
  688. %     \fmfincoming{i1,i2}
  689. %     \fmfoutgoing{o1,o2,o3,o4}
  690. %       \fmf{fermion}{i1,v1,i2}
  691. %     \fmf{photon}{v1,v2}
  692. %     \fmfblob{.15w}{v2}
  693. %       \fmf{photon}{v2,v3}
  694. %         \fmf{fermion}{o1,v3,o2}
  695. %       \fmf{photon}{v2,v4}
  696. %         \fmf{fermion}{o4,v4,o3}
  697. %   \end{verbatim}
  698. % \end{minipage}
  699. % \hfill
  700. % \begin{minipage}{0.38\linewidth}
  701. %   \begin{center}
  702. %     \fmfframe(0,5)(5,7){%
  703. %       \begin{fmfchar*}(40,25)
  704. %         \fmfpen{thick}
  705. %         \fmfincoming{i1,i2}
  706. %         \fmfoutgoing{o1,o2,o3,o4}
  707. %           \fmflabel{$e_-$}{i1}
  708. %           \fmflabel{$e_+$}{i2}
  709. %           \fmf{fermion}{i1,v1,i2}
  710. %         \fmf{photon}{v1,v2}
  711. %         \fmfblob{.15w}{v2}
  712. %           \fmf{photon}{v2,v3}
  713. %             \fmflabel{$\noexpand\mu_+$}{o1}
  714. %             \fmflabel{$\noexpand\nu_{\noexpand\mu}$}{o2}
  715. %             \fmf{fermion}{o1,v3,o2}
  716. %           \fmf{photon}{v2,v4}
  717. %             \fmflabel{$\noexpand\bar c$}{o4}
  718. %             \fmflabel{$s$}{o3}
  719. %             \fmf{fermion}{o4,v4,o3}
  720. %       \end{fmfchar*}}
  721. %   \end{center}
  722. % \end{minipage}
  723. % And the resonant $t$-channel contribution:
  724. % \vspace*{\baselineskip}
  725. % \begin{minipage}{0.6\linewidth}
  726. %   \begin{verbatim}
  727. %     \fmfincoming{i1,i2}
  728. %     \fmfoutgoing{o1,o2,o3,o4}
  729. %     \fmf{fermion}{i1,v1,v2,i2}
  730. %       \fmf{photon}{v1,v3}
  731. %         \fmf{fermion}{o1,v3,o2}
  732. %       \fmf{photon}{v2,v4}
  733. %         \fmf{fermion}{o4,v4,o3}
  734. %   \end{verbatim}
  735. % \end{minipage}
  736. % \hfill
  737. % \begin{minipage}{0.38\linewidth}
  738. %   \begin{center}
  739. %     \fmfframe(0,5)(5,7){%
  740. %       \begin{fmfchar*}(40,25)
  741. %         \fmfpen{thick}
  742. %         \fmfincoming{i1,i2}
  743. %         \fmfoutgoing{o1,o2,o3,o4}
  744. %         \fmflabel{$e_-$}{i1}
  745. %         \fmflabel{$e_+$}{i2}
  746. %         \fmf{fermion}{i1,v1,v2,i2}
  747. %           \fmf{photon}{v1,v3}
  748. %             \fmflabel{$\noexpand\mu_+$}{o1}
  749. %             \fmflabel{$\noexpand\nu_{\noexpand\mu}$}{o2}
  750. %             \fmf{fermion}{o1,v3,o2}
  751. %           \fmf{photon}{v2,v4}
  752. %             \fmflabel{$\noexpand\bar c$}{o4}
  753. %             \fmflabel{$s$}{o3}
  754. %             \fmf{fermion}{o4,v4,o3}
  755. %       \end{fmfchar*}}
  756. %   \end{center}
  757. % \end{minipage}
  758. % Actually, these three diagrams can be improved slightly by using
  759. % |phantom| arcs, which will be discussed in the next section.
  760. % Two point loop diagrams pose another set of problems.  We
  761. % must have a way of specifying that one or more of the lines
  762. % connecting the two vertices are \emph{not} connected by a straight
  763. % line.  The options |left|, |right| and |straight| offer the
  764. % possibility to connect two vertices by a semicircle detour, either
  765. % on the left or on the right.  Since by default all lines contribute
  766. % to the tension between two vertices, the |tension| option allows us
  767. % to reduce this tension.  The next examples shows both options in
  768. % action.  The lower fermion line is given an tension of~$1/3$ to
  769. % make is symmetrical with the upper line with consists of three parts.
  770. % The loop photon is using a detour on the right and does not
  771. % contribute any tension.
  772. % \vspace*{\baselineskip}
  773. % \begin{minipage}{0.6\linewidth}
  774. %   \begin{verbatim}
  775. %     \fmfincoming{i1,i2}
  776. %     \fmfoutgoing{o1}
  777. %     \fmf{fermion,tension=1/3}{i1,v1}
  778. %     \fmf{plain}{v1,v2}
  779. %     \fmf{fermion}{v2,v3}
  780. %     \fmf{photon,right,tension=0}{v2,v3}
  781. %     \fmf{plain}{v3,i2}
  782. %     \fmf{photon}{v1,o1}
  783. %   \end{verbatim}
  784. % \end{minipage}
  785. % \hfill
  786. % \begin{minipage}{0.35\linewidth}
  787. %   \begin{center}
  788. %     \begin{fmfchar*}(40,25)
  789. %       \fmfpen{thick}
  790. %       \fmfincoming{i1,i2}
  791. %       \fmflabel{$p^{\noexpand\prime}$}{i1}
  792. %       \fmflabel{$p$}{i2}
  793. %       \fmfoutgoing{o1}
  794. %       \fmflabel{$p+p^{\noexpand\prime}$}{o1}
  795. %       \fmf{fermion,tension=1/3}{i1,v1}
  796. %       \fmf{plain}{v1,v2}
  797. %       \fmf{fermion,label=$p-k$,side=left}{v2,v3}
  798. %       \fmf{photon,right,tension=0,label=$k$}{v2,v3}
  799. %       \fmf{plain}{v3,i2}
  800. %       \fmf{photon}{v1,o1}
  801. %     \end{fmfchar*}
  802. %   \end{center}
  803. % \end{minipage}
  804. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  805. % \subsection{Labels}
  806. % \label{sec:labels}
  807. % Let us now come back to the examples on
  808. % page~\pageref{page:simple-examples} and discuss how to add the
  809. % labels.
  810. % \DescribeMacro{\fmflabel}
  811. % The macro |\fmflabel{|\meta{label}|}{|\meta{v}|}| adds the label
  812. % \meta{label} to the vertex \meta{v}.  In the current implementation,
  813. % there can be only a single label for each vertex.  Thus earlier
  814. % calls to |\fmflabel| for the same vertex will be overwritten.
  815. % \meta{label} will be placed with the |\put| command of the \LaTeX{}
  816. % |picture| environment.  \emph{It is absolutely necessary to quote
  817. % \emph{each} \TeX{} control sequence appearing in \meta{label} with}
  818. % |\noexpand|.  \emph{Otherwise all kinds of disasters are bound to
  819. % happen, causing at the very least some obscure error messages!}
  820. % |\fmflabel| gives the user \emph{no} control on the placement of
  821. % the the label (see below for a more fine-grained control provided by
  822. % the options to the |\fmfv| macro).  The label is placed using the
  823. % following algorithm:
  824. % \begin{enumerate}
  825. %   \item{} The reference point of the box containing \meta{label} is
  826. %     placed at the distance |3thick| on the continuation of the
  827. %     straight line connecting the center of the picture with the
  828. %     vertex \meta{v}.
  829. %   \item{} The reference point of the box is chosen such that the
  830. %     contents of the box is on the outside of the vertex (with
  831. %     respect to the center of the diagram).  It is chosen from the
  832. %     four corners and the four midpoints of the sides.
  833. % \end{enumerate}
  834. % Therefore the four external particles in the~$B$-$\bar B$ mixing
  835. % diagram on page~\pageref{page:simple-examples} are labelled simply
  836. % by:
  837. % \begin{verbatim}
  838. %   \fmflabel{$\noexpand\bar b$}{i1}
  839. %   \fmflabel{$d$}{i2}
  840. %   \fmflabel{$\noexpand\bar d$}{o1}
  841. %   \fmflabel{$b$}{o2}
  842. % \end{verbatim}
  843. % \begin{dubious}
  844. %   Explain more of the |label| option and the default placement rules.
  845. % \end{dubious}
  846. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  847. % \subsection{Advanced usage}
  848. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  849. % \subsubsection{Tight arcs}
  850. % If you add to any arc one or more |phantom| arcs they will cause
  851. % a tighter bonding between the vertices involved
  852. % \begin{verbatim}
  853. %   \fmf{fermion}{v1,v2}
  854. %   \fmf{phantom}{v1,v2}
  855. % \end{verbatim}
  856. % which is equivalent to
  857. % \begin{verbatim}
  858. %   \fmf{fermion,tension=2}{v1,v2}
  859. % \end{verbatim}
  860. % The |phantom| arc has to be added \emph{before} any |\fmfposition|
  861. % involving these vertices, of course.  Here is an example from deep
  862. % inelastic scattering.  (We do not show the |\fmfcmd{}|s in this
  863. % example which are used for decorating the incoming proton and do not
  864. % affect \FMF's layout decisions.)
  865. % \vspace*{\baselineskip}
  866. % \begin{minipage}{0.6\linewidth}
  867. %   \begin{verbatim}
  868. %     \fmfincoming{ip,il}
  869. %     \fmfoutgoing{oq1,oq2,d1,oq3,d2,d3,ol}
  870. %     \fmf{fermion}{ip,vp,vq,oq3}
  871. %     \fmf{fermion}{vp,oq1}
  872. %     \fmf{fermion}{vp,oq2}
  873. %     \fmf{photon}{vl,vq}
  874. %     \fmf{fermion}{il,vl,ol}
  875. %     \fmfblob{.15w}{vp}
  876. %     \fmfdot{vq}
  877. %   \end{verbatim}
  878. % \end{minipage}
  879. % \hfill
  880. % \begin{minipage}{0.35\linewidth}
  881. %   \begin{center}
  882. %     \begin{fmfchar}(40,25)
  883. %       \fmfpen{thick}
  884. %       \fmfincoming{ip,il}
  885. %       \fmfoutgoing{oq1,oq2,d1,oq3,d2,d3,ol}
  886. %       \fmf{fermion}{ip,vp,vq,oq3}
  887. %       \fmf{fermion}{vp,oq1}
  888. %       \fmf{fermion}{vp,oq2}
  889. %       \fmf{photon}{vl,vq}
  890. %       \fmf{fermion}{il,vl,ol}
  891. %       \fmfposition
  892. %       \fmfforce{vloc ip+(0,2thick)}{ipp}
  893. %       \fmfforce{vloc ip-(0,2thick)}{ipm}
  894. %       \fmfforce{vloc vp+(0,2thick)}{vpp}
  895. %       \fmfforce{vloc vp-(0,2thick)}{vpm}
  896. %       \fmfshift{0.12 (vloc ip - vloc vp)}{vpp}
  897. %       \fmfshift{0.10 (vloc ip - vloc vp)}{vpm}
  898. %       \fmf{plain}{ipp,vpp}
  899. %       \fmf{plain}{ipm,vpm}
  900. %       \fmfblob{.15w}{vp}
  901. %       \fmfdot{vq}
  902. %     \end{fmfchar}
  903. %   \end{center}
  904. % \end{minipage}
  905. % As it stands, all vertices come out too far to the right, because
  906. % the greater number of outgoing lines pulls them over.  Adding
  907. % |\fmf{phantom}| makes the bond between the incoming vertices and the
  908. % interactions tighter and produces a better balanced picture:
  909. % \vspace*{\baselineskip}
  910. % \begin{minipage}{0.6\linewidth}
  911. %   \begin{verbatim}
  912. %     \fmfincoming{ip,il}
  913. %     \fmfoutgoing{oq1,oq2,d1,oq3,d2,d3,ol}
  914. %     \fmf{fermion}{ip,vp,vq,oq3}
  915. %     \fmf{phantom}{ip,vp}
  916. %     \fmf{fermion}{vp,oq1}
  917. %     \fmf{fermion}{vp,oq2}
  918. %     \fmf{photon}{vl,vq}
  919. %     \fmf{fermion}{il,vl,ol}
  920. %     \fmf{phantom}{il,vl}
  921. %     \fmfblob{.15w}{vp}
  922. %     \fmfdot{vq}
  923. %   \end{verbatim}
  924. % \end{minipage}
  925. % \hfill
  926. % \begin{minipage}{0.35\linewidth}
  927. %   \begin{center}
  928. %     \begin{fmfchar}(40,25)
  929. %       \fmfpen{thick}
  930. %       \fmfincoming{ip,il}
  931. %       \fmfoutgoing{oq1,oq2,d1,oq3,d2,d3,ol}
  932. %       \fmf{fermion}{ip,vp,vq,oq3}
  933. %       \fmf{phantom}{ip,vp}
  934. %       \fmf{fermion}{vp,oq1}
  935. %       \fmf{fermion}{vp,oq2}
  936. %       \fmf{photon}{vl,vq}
  937. %       \fmf{fermion}{il,vl,ol}
  938. %       \fmf{phantom}{il,vl}
  939. %       \fmfposition
  940. %       \fmfforce{vloc ip+(0,2thick)}{ipp}
  941. %       \fmfforce{vloc ip-(0,2thick)}{ipm}
  942. %       \fmfforce{vloc vp+(0,2thick)}{vpp}
  943. %       \fmfforce{vloc vp-(0,2thick)}{vpm}
  944. %       \fmfshift{0.16 (vloc ip - vloc vp)}{vpp}
  945. %       \fmfshift{0.14 (vloc ip - vloc vp)}{vpm}
  946. %       \fmf{plain}{ipp,vpp}
  947. %       \fmf{plain}{ipm,vpm}
  948. %       \fmfblob{.15w}{vp}
  949. %       \fmfdot{vq}
  950. %     \end{fmfchar}
  951. %   \end{center}
  952. % \end{minipage}
  953. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  954. % \subsubsection{Loose arcs}
  955. % Adding arcs \emph{after} any |\fmfposition| involving these
  956. % vertices will make these arcs loose, i.e.~they will not contribute
  957. % to the bonding between the vertices.
  958. % Consider the following example: suppose we want to draw a ladder
  959. % diagram contributing to the quark form factor.  Simply linking in
  960. % the gluons does not produce a satisfactory result:
  961. % \vspace*{\baselineskip}
  962. % \begin{minipage}{0.6\linewidth}
  963. %   \begin{verbatim}
  964. %     \fmfincoming{i1} \fmfoutgoing{o1,o2}
  965. %     \fmf{photon}{i1,v4}
  966. %     \fmf{quark}{o1,v1,v2,v3,v4,v5,v6,v7,o2}
  967. %     \fmf{gluon}{v1,v7}
  968. %     \fmf{gluon}{v2,v6}
  969. %     \fmf{gluon}{v3,v5}
  970. %   \end{verbatim}
  971. % \end{minipage}
  972. % \hfill
  973. % \begin{minipage}{0.35\linewidth}
  974. %   \begin{center}
  975. %    \begin{fmfchar}(40,25)
  976. %      \fmfpen{thick}
  977. %      \fmfincoming{i1} \fmfoutgoing{o1,o2}
  978. %      \fmf{photon}{v4,i1}
  979. %      \fmf{quark}{o1,v1,v2,v3,v4,v5,v6,v7,o2}
  980. %      \fmf{gluon}{v1,v7}
  981. %      \fmf{gluon}{v2,v6}
  982. %      \fmf{gluon}{v3,v5}
  983. %    \end{fmfchar}
  984. %   \end{center}
  985. % \end{minipage}
  986. % What went wrong?  Obviously the gluons are bonding the quark lines
  987. % too strongly.  The fix is simple: just exclude the gluons from the
  988. % calculation and add them later as infinitely stretchable:
  989. % \vspace*{\baselineskip}
  990. % \begin{minipage}{0.6\linewidth}
  991. %   \begin{verbatim}
  992. %     \fmfincoming{i1} \fmfoutgoing{o1,o2}
  993. %     \fmf{photon}{i1,v4}
  994. %     \fmf{quark}{o1,v1,v2,v3,v4,v5,v6,v7,o2}
  995. %     \fmfposition
  996. %     \fmf{gluon}{v1,v7}
  997. %     \fmf{gluon}{v2,v6}
  998. %     \fmf{gluon}{v3,v5}
  999. %   \end{verbatim}
  1000. % \end{minipage}
  1001. % \hfill
  1002. % \begin{minipage}{0.35\linewidth}
  1003. %   \begin{center}
  1004. %    \begin{fmfchar}(40,25)
  1005. %      \fmfpen{thick}
  1006. %      \fmfincoming{i1} \fmfoutgoing{o1,o2}
  1007. %      \fmf{photon}{v4,i1}
  1008. %      \fmf{quark}{o1,v1,v2,v3,v4,v5,v6,v7,o2}
  1009. %      \fmfposition
  1010. %      \fmf{gluon}{v1,v7}
  1011. %      \fmf{gluon}{v2,v6}
  1012. %      \fmf{gluon}{v3,v5}
  1013. %    \end{fmfchar}
  1014. %   \end{center}
  1015. % \end{minipage}
  1016. % Another instructive example is the following: imagine you want to
  1017. % draw a typical non-resonant contribution to~$e^+e^-\to 4f$.  The
  1018. % obvious solution doesn's look right.
  1019. % \vspace*{\baselineskip}
  1020. % \begin{minipage}{0.6\linewidth}
  1021. %   \begin{verbatim}
  1022. %     \fmfincoming{i1,i2}
  1023. %     \fmfoutgoing{o1,o2,o3,o4}
  1024. %     \fmf{fermion}{i1,v1,i2}
  1025. %     \fmf{photon}{v1,v2}
  1026. %     \fmf{fermion}{o1,v2,v3,o4}
  1027. %     \fmf{photon}{v3,v4}
  1028. %     \fmf{fermion}{o3,v4,o2}
  1029. %   \end{verbatim}
  1030. % \end{minipage}
  1031. % \hfill
  1032. % \begin{minipage}{0.35\linewidth}
  1033. %   \begin{center}
  1034. %     \begin{fmfchar}(40,25)
  1035. %       \fmfpen{thick}
  1036. %       \fmfincoming{i1,i2}
  1037. %       \fmfoutgoing{o1,o2,o3,o4}
  1038. %       \fmf{fermion}{i1,v1,i2}
  1039. %       \fmf{photon}{v1,v2}
  1040. %       \fmf{fermion}{o1,v2,v3,o4}
  1041. %       \fmf{photon}{v3,v4}
  1042. %       \fmf{fermion}{o3,v4,o2}
  1043. %     \end{fmfchar}
  1044. %   \end{center}
  1045. % \end{minipage}
  1046. % One way to fix it is to |\fmfshift| the three rightmost vertices by
  1047. % hand:
  1048. % \vspace*{\baselineskip}
  1049. % \begin{minipage}{0.6\linewidth}
  1050. %   \begin{verbatim}
  1051. %     \fmfincoming{i1,i2}
  1052. %     \fmfoutgoing{o1,o2,o3,o4}
  1053. %     \fmf{fermion}{i1,v1,i2}
  1054. %     \fmf{photon}{v1,v2}
  1055. %     \fmf{fermion}{o1,v2,v3,o4}
  1056. %     \fmf{photon}{v3,v4}
  1057. %     \fmf{fermion}{o3,v4,o2}
  1058. %     \fmfposition
  1059. %     \fmfshift{-.1w,0}{v2,v3,v4}
  1060. %   \end{verbatim}
  1061. % \end{minipage}
  1062. % \hfill
  1063. % \begin{minipage}{0.35\linewidth}
  1064. %   \begin{center}
  1065. %     \begin{fmfchar}(40,25)
  1066. %       \fmfpen{thick}
  1067. %       \fmfincoming{i1,i2}
  1068. %       \fmfoutgoing{o1,o2,o3,o4}
  1069. %       \fmf{fermion}{i1,v1,i2}
  1070. %       \fmf{photon}{v1,v2}
  1071. %       \fmf{fermion}{o1,v2,v3,o4}
  1072. %       \fmf{photon}{v3,v4}
  1073. %       \fmf{fermion}{o3,v4,o2}
  1074. %       \fmfposition
  1075. %       \fmfshift{-.1w,0}{v2,v3,v4}
  1076. %     \end{fmfchar}
  1077. %   \end{center}
  1078. % \end{minipage}
  1079. % A smarter solution is again to make certain arcs stretchable:
  1080. % \vspace*{\baselineskip}
  1081. % \begin{minipage}{0.6\linewidth}
  1082. %   \begin{verbatim}
  1083. %     \fmfincoming{i1,i2}
  1084. %     \fmfoutgoing{o1,o2,o3,o4}
  1085. %     \fmf{fermion}{i1,v1,i2}
  1086. %     \fmf{photon}{v1,v2}
  1087. %     \fmf{fermion}{o1,v2,v3,o4}
  1088. %     \fmfposition
  1089. %     \fmf{photon}{v3,v4}
  1090. %     \fmf{fermion}{o3,v4,o2}
  1091. %   \end{verbatim}
  1092. % \end{minipage}
  1093. % \hfill
  1094. % \begin{minipage}{0.35\linewidth}
  1095. %   \begin{center}
  1096. %     \begin{fmfchar}(40,25)
  1097. %       \fmfpen{thick}
  1098. %       \fmfincoming{i1,i2}
  1099. %       \fmfoutgoing{o1,o2,o3,o4}
  1100. %       \fmf{fermion}{i1,v1,i2}
  1101. %       \fmf{photon}{v1,v2}
  1102. %       \fmf{fermion}{o1,v2,v3,o4}
  1103. %       \fmfposition
  1104. %       \fmf{photon}{v3,v4}
  1105. %       \fmf{fermion}{o3,v4,o2}
  1106. %     \end{fmfchar}
  1107. %   \end{center}
  1108. % \end{minipage}
  1109. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1110. % \subsubsection{Avoiding continuously tight and loose}
  1111. % I have been very reluctant to implement continuously tight and loose
  1112. % arcs in \FMF, because it introduces to much opportunity for
  1113. % ``fiddling'' on the user's part.  However, since the present
  1114. % implementation blends rather nicely with the options syntax, I have
  1115. % decided to add it anyway.  I hope that most diagrams will be created
  1116. % without too much ``fiddling''.
  1117. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1118. % \subsubsection{Raw \MF}
  1119. % Some more advanced features of \FMF{} are more conveniently
  1120. % accessed through raw \MF{} commands.  This can either be
  1121. % achieved by preparing a \MF{} input file or by using |\fmfcmd|
  1122. % extensively.  The latter apprach is usally more convenient.
  1123. % \DescribeMacro{\fmfcmd}
  1124. % The |\fmfcmd| macro writes its argument into the \MF{} input
  1125. % file generated by \FMF.  While some experience in using
  1126. % \MF{} doesn't hurt here, this approach can simplify the
  1127. % production of complex diagrams considerably.  
  1128. % An advanced application of the \MF{} features is shown in
  1129. % figure~\ref{fig:euler-heisenberg}, which is generated by calling
  1130. % the \TeX{} macro
  1131. % \begin{verbatim}
  1132. %   \def\EulerHeisenberg#1{%
  1133. %      \begin{fmfchar}(40,25)
  1134. %        \fmfpen{thick}
  1135. %        \fmfcmd{vsurroundn (e,#1);}
  1136. %        \fmfcmd{for n = 1 upto #1: vconnect ("photon", e[n], i[n]); endfor}
  1137. %        \fmfcmd{vcycle ("fermion,tension=#1/8", i, #1);}
  1138. %      \end{fmfchar}}
  1139. % \end{verbatim}
  1140. % with the arguments 4, 6, 8, and 10, respectively.  These features
  1141. % are currently not
  1142. % available from \TeX, \MF{} has to be called explicitely through
  1143. % |\fmfcmd|.
  1144. % \def\EulerHeisenberg#1{%
  1145. %    \begin{fmfchar}(40,25)
  1146. %      \fmfpen{thick}
  1147. %      \fmfcmd{vsurroundn (e,#1);}
  1148. %      \fmfcmd{for n = 1 upto #1: vconnect ("photon", e[n], i[n]); endfor}
  1149. %      \fmfcmd{vcycle ("fermion,tension=#1/8", i, #1);}
  1150. %    \end{fmfchar}}
  1151. % \begin{figure}
  1152. %   \begin{center}
  1153. %     \EulerHeisenberg{4} \qquad \EulerHeisenberg{6}
  1154. %   \end{center}
  1155. %   \begin{center}
  1156. %       \EulerHeisenberg{8} \qquad \EulerHeisenberg{10}
  1157. %   \end{center}
  1158. %   \caption{Higher order terms in the Euler-Heisenberg lagrangian.}
  1159. %   \label{fig:euler-heisenberg}
  1160. % \end{figure}
  1161. % Finally, for the curious, here is how to draw the circular gluons in
  1162. % figure~\ref{fig:gluons}:
  1163. % \begin{verbatim}
  1164. %   \fmfcmd{draw_gluon (fullcircle scaled .5w shifted (.5w,.5h));}
  1165. %   \fmfcmd{draw_gluon (reverse fullcircle scaled .5w shifted (.5w,.5h));}
  1166. % \end{verbatim}
  1167. % \begin{figure}
  1168. %   \begin{center}
  1169. %     \begin{fmfchar}(40,40)
  1170. %       \fmfcmd{draw_gluon (fullcircle scaled .5w shifted (.5w,.5h));}
  1171. %     \end{fmfchar}
  1172. %     \qquad
  1173. %     \begin{fmfchar}(40,40)
  1174. %       \fmfcmd{draw_gluon (reverse fullcircle scaled .5w shifted (.5w,.5h));}
  1175. %     \end{fmfchar}
  1176. %   \end{center}
  1177. %   \caption{Circular gluons.}
  1178. %   \label{fig:gluons}
  1179. % \end{figure}
  1180. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1181. % \subsection{Limitations}
  1182. % Currently the most severe limitation lies in the size of the
  1183. % generated pictures.  The largest number \MF{} can represent
  1184. % internally is~4095.99998 and this is also the largest value any
  1185. % coordinate measured in pixels can assume.  At the most popular
  1186. % laserprinter resolution of~300 dots per inch (dpi), this corresponds
  1187. % to a horizontal and vertical extension of about~346mm, which is
  1188. % plenty and we're more likely to hit the internal limits on the
  1189. % complexity of a picture.  However, at the proof mode resolution
  1190. % of~2601.72dpi, this is reduced to slightly less than~40mm and we're
  1191. % running the risk of arithmetic overflow in internal calculations much
  1192. % earlier.
  1193. % There are two potential solutions of different scope and complexity:
  1194. % \begin{itemize}
  1195. %   \item{} Once John Hobby's \MP{} is available without a
  1196. %     non-disclosure agreement, a solution is to replace \MF{} by
  1197. %     \MP, which doesn't suffer from the size
  1198. %     limitations\footnote{%
  1199. %       Right now, \FMF's \MP{} support is still
  1200. %       somewhat kludged, but the functionality is there.}
  1201. %     This comes with a small price paid in reduced portability of the
  1202. %     generated output, but as already stated above in the case of
  1203. %     |axodraw|, the ubiquity of PostScript printers (and the free
  1204. %     GhostScript interpreter) makes this a minor point.
  1205. %   \item{} The more ambitious solutions will be ``virtual pictures''
  1206. %     (see section~\ref{sec:virtual-pictures}).
  1207. % \end{itemize}
  1208. % \end{fmffile}
  1209. % \StopEventually{}
  1210. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1211. % \section{\TeX{} macros}
  1212. % It's is good practice to identify this version of the document style
  1213. % option.  We do this by parsing an RCS |Id| string and storing the
  1214. % result in the conventional \TeX{} control sequences:
  1215. % \changes{1.1}{1994/05/19}{%
  1216. %   Don't loose on {\tt RCS} strings even iff the dollar signs have
  1217. %   been removed.}
  1218. %    \begin{macrocode}
  1219. %<*style>
  1220. \NeedsTeXFormat{LaTeX2e}
  1221. {\def\RCS#1#2\endRCS{%
  1222.   \ifx$#1%
  1223.     \@RCS $#2 \endRCS
  1224.   \else
  1225.     \@RCS $*: #1#2$ \endRCS
  1226.   \fi}%
  1227.  \def\@RCS $#1: #2,v #3 #4 #5 #6$ \endRCS{%
  1228.    \gdef\filename{#2}%
  1229.    \gdef\fileversion{v#3}%
  1230.    \gdef\filedate{#4}%
  1231.    \gdef\docdate{#4}}%
  1232. \RCS feynmf.dtx,v 1.5 1994/05/28 12:10:04 ohl Exp \endRCS}%
  1233. %    \end{macrocode}
  1234. % And now the standard procedure:
  1235. % \changes{1.4}{1994/05/27}{%
  1236. %   \MP{} support: identification part, include
  1237. %   \texttt{egraphics} and pass options.}
  1238. %    \begin{macrocode}
  1239. %<*!mp>
  1240. \ProvidesPackage{feynmf}[\filedate\space LaTeX2e package]
  1241. \typeout{Package: `feynmf'
  1242.    \fileversion\space <\filedate> (tho) PRELIMINARY TEST RELEASE}
  1243. \wlog{English documentation \@spaces<\docdate> (tho)}
  1244. %</!mp>
  1245. %<*mp>
  1246. \ProvidesPackage{feynmp}[\filedate\space LaTeX2e package]
  1247. \typeout{Package: `feynmp'
  1248.    \fileversion\space <\filedate> (tho) PRELIMINARY TEST RELEASE}
  1249. \wlog{English documentation \@spaces<\docdate> (tho)}
  1250. %    \end{macrocode}
  1251. % Every option we don't understand (that is \emph{every} option) is
  1252. % sent down to |egraphics|:
  1253. %    \begin{macrocode}
  1254. \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{egraphics}}
  1255. \ProcessOptions
  1256. %    \end{macrocode}
  1257. % For the sake of Portabilitical Correctness, we use \LaTeX's
  1258. % |egraphics| for including PostScript, instead of the simpler |epsf|
  1259. % which comes with |dvips| and would have sufficed
  1260. %    \begin{macrocode}
  1261. \RequirePackage{egraphics}
  1262. %</mp>
  1263. %    \end{macrocode}
  1264. % \begin{dubious}
  1265. %   We should |\||mdqon| at the end only if the German extensions are
  1266. %   really active, not just loaded.
  1267. % \end{dubious}
  1268. %    \begin{macrocode}
  1269. \let\mdqrestore\relax
  1270. \@ifundefined{mdqoff}{}{%
  1271.   \mdqoff
  1272.   \let\mdqrestore\mdqon}
  1273. %    \end{macrocode}
  1274. % \begin{macro}{\fmfcmd}
  1275. % The entrance through which our commands enter the world of
  1276. % \MF.  Note the |\ignorespaces|: we need to avoid spurious
  1277. % blanks in the output list.
  1278. %    \begin{macrocode}
  1279. \newwrite\@outfmf
  1280. \def\fmfcmd#1{%
  1281.   \immediate\write\@outfmf{#1}\ignorespaces}
  1282. %    \end{macrocode}
  1283. % \end{macro}
  1284. % \begin{macro}{\fmffile}
  1285. % This environment encloses each \MF{} input file.  The single
  1286. % argument gives the name of the file.
  1287. % \changes{1.1}{1994/05/16}{%
  1288. %   Stupid: {\tt fileversion} can be reset by other packages, store
  1289. %   the current value in {\tt fmf@fileversion} and use this one.}
  1290. % \changes{1.1}{1994/05/20}{%
  1291. %   Pass RCS revision in a string.}
  1292. % \changes{1.4}{1994/05/27}{\MP{} support: write \MP{} file.}
  1293. %    \begin{macrocode}
  1294. {\catcode`\%=11\gdef\p@rcent{%}}
  1295. \edef\fmf@fileversion{\fileversion}
  1296. \def\fmffile#1{%
  1297.   \def\thefmffile{#1}%
  1298. %<*!mp>
  1299.   \immediate\openout\@outfmf=\thefmffile.mf\relax
  1300.   \fmfcmd{\p@rcent\space \thefmffile.mf -- do not edit, %
  1301.           generated automatically by \jobname.tex^^J%
  1302.           input feynmf^^J%
  1303.           \p@rcent\space tracingonline:=tracingtitles:=1;^^J%
  1304.           require_RCS_revision "\expandafter\@gobble\fmf@fileversion";}%
  1305. %</!mp>
  1306. %<*mp>
  1307.   \immediate\openout\@outfmf=\thefmffile.mp\relax
  1308.   \fmfcmd{\p@rcent\space \thefmffile.mp -- do not edit, %
  1309.           generated automatically by \jobname.tex^^J%
  1310.           input feynmp^^J%
  1311.           \p@rcent\space tracingonline:=tracingtitles:=1;^^J%
  1312.           require_RCS_revision "\expandafter\@gobble\fmf@fileversion";}%
  1313. %</mp>
  1314. %    \end{macrocode}
  1315. % The following trick has been taken from |mfpic|~\cite{mfpic}:
  1316. % proceed even if the font is not available yet, because we have to
  1317. % write the \MF{} file first.
  1318. % \changes{1.4}{1994/05/27}{\MP{} support: don't open \texttt{tfm} file.}
  1319. %    \begin{macrocode}
  1320. %<*!mp>
  1321.   \batchmode
  1322.   \font\f@ynmf=\thefmffile
  1323.   \errorstopmode
  1324. %    \end{macrocode}
  1325. % Inform the user:
  1326. %    \begin{macrocode}
  1327.   \ifx\f@ynmf\nullfont
  1328.     \def\f@ynmf{feynmf character:}%
  1329.     \typeout{%
  1330.       feynmf: File \thefmffile.tfm not found:^^J%
  1331.       feynmf: Process \thefmffile.mf with METAFONT and then %
  1332.               reprocess this file.}%
  1333.   \else
  1334.     \typeout{%
  1335.       feynmf: File \thefmffile.tfm found.^^J%
  1336.       feynmf: Nevertheless, if the picture has changed, %
  1337.               reprocess \thefmffile.mf.^^J%
  1338.       feynmf: If dimension have changed, reprocess \thefmffile.mf %
  1339.               and \jobname.tex.}%
  1340.   \fi
  1341. %</!mp>
  1342. %    \end{macrocode}
  1343. % Count the characters
  1344. %    \begin{macrocode}
  1345.   \setcounter{fmfchar}{0}}
  1346. \let\thefmffile\relax
  1347. \newcounter{fmfchar}
  1348. %    \end{macrocode}
  1349. % \end{macro}
  1350. % \begin{macro}{\endfmffile}
  1351. % And here is how we close the |fmffile| environment:
  1352. %    \begin{macrocode}
  1353. \def\endfmffile{%
  1354.   \fmfcmd{\p@rcent\space the end.^^J%
  1355.           end.^^J%
  1356.           endinput;}%
  1357.   \let\thefmffile\relax
  1358.   \immediate\closeout\@outfmf}
  1359. %    \end{macrocode}
  1360. % \end{macro}
  1361. % \begin{macro}{\fmf@char}
  1362. % This is the bulk of the environment used for each ``character''
  1363. % drawn by \MF.
  1364. %    \begin{macrocode}
  1365. {\catcode`\#=11\gdef\sh@rp{#}}
  1366. \let\sharp\sh@rp
  1367. \def\fmf@char#1#2{%
  1368. %    \end{macrocode}
  1369. % Make sure that a \MF{} file is open, otherwise \emph{really}
  1370. % obscure error messages are possible:
  1371. % \changes{1.3}{1994/05/23}{%
  1372. %   Make sure that a \MF{} file is open, otherwise \emph{really}
  1373. %   obscure error messages are possible.}
  1374. %    \begin{macrocode}
  1375.   \ifx\thefmffile\relax
  1376.     \errhelp={Outside a fmffile environment, I have no clue as to where^^J%
  1377.               the METAFONT commands should go.   I will use fmfdeflt.mf^^J%
  1378.               for this character, but you'd better fix your code!}         
  1379.     \errmessage{I detected a fmfchar environment outside of fmffile}
  1380.     \fmffile{fmfdeflt}
  1381.   \fi
  1382.   \stepcounter{fmfchar}%
  1383. %    \end{macrocode}
  1384. % Start \MF{} character:
  1385. %    \begin{macrocode}
  1386.   \fmfcmd{beginchar(\thefmfchar, #1*\the\unitlength\sh@rp, %
  1387.                                  #2*\the\unitlength\sh@rp, 0);^^J%
  1388.             "feynmf: \thefmfchar";}%
  1389.   \fmfcmd{LaTeX_unitlength:=\the\unitlength;}%
  1390.   \fmfinit
  1391.   \fmfpen{thin}}
  1392. %    \end{macrocode}
  1393. % \end{macro}
  1394. % \begin{macro}{\fmfchar}
  1395. % The plain version, no labels, no enclosing |picture| environment
  1396. %    \begin{macrocode}
  1397. \def\fmfchar(#1,#2){%
  1398.   \fmf@char{#1}{#2}%
  1399. %    \end{macrocode}
  1400. % Place the character:
  1401. % \changes{1.4}{1994/05/27}{\MP{} support: include PostScript file.}
  1402. %    \begin{macrocode}
  1403. %<!mp>{\f@ynmf \char\value{fmfchar}}%
  1404. %<*mp>
  1405.   \leavevmode
  1406.   \IfFileExists{\thefmffile.\thefmfchar}%
  1407.    {\includegraphics[type=eps,ext=\thefmfchar,read=\thefmfchar]%
  1408.       {\thefmffile}}%
  1409.    {\typeout{%
  1410.       feynmp: File \thefmffile.\thefmfchar\space not found:^^J%
  1411.       feynmp: Process \thefmffile.mf with MetaPost and then %
  1412.               reprocess this file.}}%
  1413. %</mp>
  1414.   \ignorespaces}
  1415. %    \end{macrocode}
  1416. % \end{macro}
  1417. % \begin{macro}{\endfmfchar}
  1418. %    \begin{macrocode}
  1419. \def\endfmfchar{%
  1420.   \fmfposition
  1421.   \fmfdraw
  1422.   \fmfcmd{endchar;}}
  1423. %    \end{macrocode}
  1424. % \end{macro}
  1425. % \begin{macro}{\fmfchar*}
  1426. % The extended version, with labels and |picture| environment.
  1427. %    \begin{macrocode}
  1428. \@namedef{fmfchar*}(#1,#2){%
  1429.   \begin{picture}(#1,#2)
  1430.     \fmf@char{#1}{#2}%
  1431. %    \end{macrocode}
  1432. % Process the \MF{} output for labels (if any), enforcing |%| as
  1433. % comment character.
  1434. %    \begin{macrocode}
  1435. %<*!mp>
  1436.     {\catcode`\%=14\relax
  1437.       \grepfile{%
  1438.         \thefmffile.\thefmfchar}{%
  1439.         \thefmffile.log}{%
  1440.         \thefmffile.t\thefmfchar}}%
  1441. %</!mp>
  1442. %    \end{macrocode}
  1443. % Place the character:
  1444. % \changes{1.4}{1994/05/27}{\MP{} support: include PostScript file.}
  1445. %    \begin{macrocode}
  1446. %<!mp>\put(0,0){{\f@ynmf \char\value{fmfchar}}}%
  1447. %<*mp>
  1448.   \IfFileExists{\thefmffile.\thefmfchar}%
  1449.    {\put(0,0){\includegraphics[type=eps,ext=\thefmfchar,read=\thefmfchar]%
  1450.                 {\thefmffile}}}%
  1451.    {\typeout{%
  1452.       feynmp: File \thefmffile.\thefmfchar\space not found:^^J%
  1453.       feynmp: Process \thefmffile.mf with MetaPost and then %
  1454.               reprocess this file.}}%
  1455. %</mp>
  1456.       \ignorespaces}
  1457. %    \end{macrocode}
  1458. % \end{macro}
  1459. % \begin{macro}{\endfmfchar*}
  1460. %    \begin{macrocode}
  1461. \@namedef{endfmfchar*}{%
  1462.     \endfmfchar
  1463. %    \end{macrocode}
  1464. % Enforce |%| as comment character:
  1465. %    \begin{macrocode}
  1466.     {\catcode`\%=14\relax
  1467.       \InputIfFileExists{\thefmffile.t\thefmfchar}{}{%
  1468.         \typeout{%
  1469.           feynmf: Label file \thefmffile.t\thefmfchar\space not found:^^J%
  1470.           feynmf: Process \thefmffile.mf with METAFONT and then %
  1471.                   reprocess this file.}}}%
  1472.   \end{picture}}
  1473. %    \end{macrocode}
  1474. % \end{macro}
  1475. % \begin{macro}{\fmfframe}
  1476. % This is used to allocate additional space around a |fmfchar*|, since
  1477. % the labels (or the diagram itself) might overshoot.
  1478. % |\fmfchar(|\meta{left}|,|\meta{top}|)(|\meta{right}|,|\meta{bottom}|){|%
  1479. % \meta{box}|}| puts an invisible frame of the given dimensions
  1480. % (measured in |\unitlength|) around \meta{box}.
  1481. %    \begin{macrocode}
  1482. \def\fmfframe(#1,#2)(#3,#4)#5{%
  1483.   \leavevmode
  1484.   \hbox{\vbox{\vskip#2\unitlength\par
  1485.               \hbox{\hskip#1\unitlength#5\hskip#3\unitlength}\par
  1486.               \vskip#4\unitlength}}}
  1487. %    \end{macrocode}
  1488. % \end{macro}
  1489. % \begin{macro}{\fmfpen}
  1490. % Picup a |pencircle| scaled by the argument.
  1491. %    \begin{macrocode}
  1492. \def\fmfpen#1{\fmfcmd{pickup pencircle scaled #1;}}
  1493. %    \end{macrocode}
  1494. % \end{macro}
  1495. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1496. % \subsection{Grep}
  1497. % \label{sec:grep}
  1498. % \begin{macro}{\grepfile}
  1499. % The macro |\grepfile{|\meta{pattern}|}{|\meta{in}|}{|\meta{out}|}|
  1500. % writes all lines matching |:|\meta{pattern}|:| from file \meta{in}
  1501. % to file \meta{out} after stripping off the pattern.
  1502. % \begin{dubious}
  1503. %   Pattern matching on lines with a single leading colon fails.
  1504. % \end{dubious}
  1505. % \changes{1.4}{1994/05/28}{%
  1506. %   Don't include the \texttt{grep} macros in the \MP{} version.
  1507. %   \texttt{write} makes them obsolete.}
  1508. %    \begin{macrocode}
  1509. %<*!mp>
  1510. \def\grepfile#1#2#3{%
  1511.   \begingroup
  1512. %    \end{macrocode}
  1513. % Hash the pattern and open the input and output streams:
  1514. %    \begin{macrocode}
  1515.     \edef\pattern{\csname*grep*#1*\endcsname}%
  1516.     \immediate\openin\grep@infile #2\relax
  1517.     \ifeof\grep@infile
  1518.     \else
  1519.       \grep@outopenfalse
  1520. %    \end{macrocode}
  1521. % Don't add anything at the end of input lines and don't expand
  1522. % anything we've read from the file:
  1523. %    \begin{macrocode}
  1524.       \endlinechar=-1
  1525.       \catcode`\\=12\relax
  1526. %    \end{macrocode}
  1527. % Loop over the input lines until end of file occurs:
  1528. %    \begin{macrocode}
  1529.       \loop
  1530.         \read\grep@infile to \grep@lbuf
  1531.         \ifeof\grep@infile
  1532.           \grep@contfalse
  1533.         \else
  1534.           \grep@conttrue
  1535. %    \end{macrocode}
  1536. % Iff the input line is not empty, use |\grep@aline| to examine its
  1537. % contents and, iff the pattern matched, write a line to the output file.
  1538. %    \begin{macrocode}
  1539.           \ifx\grep@lbuf\empty
  1540.           \else
  1541.             \expandafter\grep@aline\grep@lbuf\sentinel
  1542.             \ifx\pattern\grep@tag
  1543. %    \end{macrocode}
  1544. % Delayed open (this avoids empty files):
  1545. %    \begin{macrocode}
  1546.               \ifgrep@outopen
  1547.               \else
  1548.                  \immediate\openout\grep@outfile #3\relax
  1549.                  \immediate\write\grep@outfile{\p@rcent\space #3 %
  1550.                     -- generated automatically from #2}%
  1551.                  \immediate\write\grep@outfile{\p@rcent\space
  1552.                     Think twice before editing THIS file!}%
  1553.                  \grep@outopentrue
  1554.               \fi
  1555.               \immediate\write\grep@outfile{\grep@val}%
  1556.             \fi
  1557.           \fi
  1558.         \fi
  1559.       \ifgrep@cont
  1560.       \repeat
  1561. %    \end{macrocode}
  1562. % Close the files after we're done.
  1563. % \changes{1.1}{1994/05/16}{%
  1564. %   Stupid: {\tt closein} the input stream, don't use {\tt closeout} on it.}
  1565. %    \begin{macrocode}
  1566.       \ifgrep@outopen
  1567.         \immediate\closeout\grep@outfile
  1568.       \fi
  1569.     \fi
  1570.     \immediate\closein\grep@infile
  1571.   \endgroup}
  1572. %    \end{macrocode}
  1573. % \end{macro}
  1574. % \begin{macro}{\grep@infile}
  1575. %  \begin{macro}{\grep@outfile}
  1576. % The I/O streams for the grep facility
  1577. %    \begin{macrocode}
  1578. \newread\grep@infile
  1579. \newwrite\grep@outfile
  1580. %    \end{macrocode}
  1581. %  \end{macro}
  1582. % \end{macro}
  1583. % \begin{macro}{\ifgrep@cont}
  1584. %   \begin{macro}{\ifgrep@outopen}
  1585. % and flags for the same 
  1586. %    \begin{macrocode}
  1587. \newif\ifgrep@cont
  1588. \newif\ifgrep@outopen
  1589. %    \end{macrocode}
  1590. %   \end{macro}
  1591. % \end{macro}
  1592. % \begin{macro}{\grep@aline}
  1593. % Examine one line and set the variables |\grep@tag| and |\grep@val|
  1594. % iff the line starts with a colon.  Subtle point here: |\ifx#1:| will
  1595. % \emph{not} work if |#1| starts with a |{| followed by two identical
  1596. % characters.
  1597. %    \begin{macrocode}
  1598. \def\grep@aline#1#2\sentinel{%
  1599.   \ifx:#1%
  1600.     \grep@splitlbuf#2\sentinel
  1601.   \else
  1602.     \edef\grep@tag{\csname*grep*\endcsname}%
  1603.     \def\grep@val{}%
  1604.   \fi}
  1605. %    \end{macrocode}
  1606. % \end{macro}
  1607. % \begin{macro}{\grep@splitlbuf}
  1608. % Split the line buffer at the remaining colon, hashing the first part.
  1609. %    \begin{macrocode}
  1610. \def\grep@splitlbuf#1:#2\sentinel{%
  1611.   \edef\grep@tag{\csname*grep*#1*\endcsname}%
  1612.   \def\grep@val{#2}}
  1613. %</!mp>
  1614. %    \end{macrocode}
  1615. % \end{macro}
  1616. % The other \TeX{} command sequences are defined below, along with the
  1617. % \MF{} macros they are in one-to-one correspondence to.
  1618. %    \begin{macrocode}
  1619. %</style>
  1620. %    \end{macrocode}
  1621. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1622. % \section{\MF{} macros}
  1623. % \label{sec:mf-code}
  1624. % Now we turn our attention to the \MF{}
  1625. % macros.
  1626. % \begin{dubious}
  1627. %   We should find a way (a hack) to index the
  1628. %   \MF{} macros with the |doc| option.
  1629. % \end{dubious}
  1630. % Make the RCS revision number available for feature testing:
  1631. % \changes{1.1}{1994/05/20}{%
  1632. %   Handle arbitrary RCS revision strings.}
  1633. %    \begin{macrocode}
  1634. %<*base>
  1635. vardef parse_RCS (suffix RCS) (expr s) =
  1636.   save n, c;
  1637.   numeric n, RCS[];
  1638.   string c;
  1639.   RCS[0] := 0;
  1640.   for n = 1 upto length (s):
  1641.     c := substring (n-1,n) of s;
  1642.     exitif ((RCS[0] > 0) and (c = " "));
  1643.     if ((c = "0") or (c = "1") or (c = "2")
  1644.         or (c = "3") or (c = "4") or (c = "5")
  1645.         or (c = "6") or (c = "7") or (c = "8")
  1646.         or (c = "9")):
  1647.       if RCS[0] = 0:
  1648.         RCS[0] := 1;
  1649.         RCS[RCS[0]] := 0;
  1650.       fi
  1651.       RCS[RCS[0]] := 10 * RCS[RCS[0]] + scantokens (c);
  1652.     elseif c = ".":
  1653.       RCS[0] := RCS[0] + 1;
  1654.       RCS[RCS[0]] := 0;
  1655.     else:
  1656.     fi
  1657.   endfor
  1658. enddef;
  1659. %    \end{macrocode}
  1660. % Check that \LaTeX{} style and \MF{} macros are in sync:
  1661. %    \begin{macrocode}
  1662. vardef require_RCS_revision expr s =
  1663.   numeric n;
  1664.   save TeX_rev, mf_rev;
  1665.   parse_RCS (TeX_rev, s);
  1666.   parse_RCS (mf_rev, "1.5");
  1667.   for n = 1 upto min (2, TeX_rev[0], mf_rev[0]):
  1668.     if TeX_rev[n] > mf_rev[n]:
  1669.       errhelp
  1670.         "Your version of `feynmf.sty' is higher that of your `feynmf.mf'.";
  1671.       errmessage "feynmf: Metafont macros out of date";
  1672.     elseif TeX_rev[n] < mf_rev[n]:
  1673.       errhelp
  1674.         "Your version of `feynmf.mf' is higher that of your `feynmf.sty'.";
  1675.       errmessage "feynmf: LaTeX style out of date";
  1676.     fi
  1677.     exitif (TeX_rev[n] <> mf_rev[n]);
  1678.   endfor
  1679. enddef;
  1680. %    \end{macrocode}
  1681. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1682. % \subsection{\MP{} Kludges}
  1683. % This is not \MP{} support yet, just trying to prove a point.
  1684. % \changes{1.4}{1994/05/27}{Preliminary \MP{} support: mimic \MF.}
  1685. %    \begin{macrocode}
  1686. %<*mp>
  1687. vardef cullit = \ enddef;
  1688. %    \end{macrocode}
  1689. %    \begin{macrocode}
  1690. vardef beginchar (expr c, wd, ht, dp) =
  1691.   LaTeX_file := "";
  1692.   beginfig(c);
  1693.     w:=wd;
  1694.     h:=ht;
  1695. enddef;
  1696. string LaTeX_file;
  1697. %    \end{macrocode}
  1698. %    \begin{macrocode}
  1699. vardef endchar =
  1700.   setbounds currentpicture to (0,0)--(w,0)--(w,h)--(0,h)--cycle;
  1701.   if LaTeX_file <> "":
  1702.     write EOF to LaTeX_file;
  1703.     LaTeX_file := "";
  1704.   endfig
  1705. enddef;
  1706. %    \end{macrocode}
  1707. % Sharped dimensions are useless with \MP.  We define them anyway
  1708. % with trivial translation, so that the \MF{} code can be used
  1709. % unchanged.
  1710. %    \begin{macrocode}
  1711. bp# := bp;
  1712. cc# := cc;
  1713. cm# := cm;
  1714. dd# := dd;
  1715. in# := in;
  1716. mm# := mm;
  1717. pc# := pc;
  1718. pt# := pt;
  1719. %    \end{macrocode}
  1720. % As I said: trivial translation.
  1721. %    \begin{macrocode}
  1722. vardef define_blacker_pixels(text t) =
  1723.   forsuffixes $=t:
  1724.     $:=$.#;
  1725.   endfor
  1726. enddef;
  1727. %</mp>
  1728. %    \end{macrocode}
  1729. %    \begin{macrocode}
  1730. %<!mp>mode_setup;
  1731. %    \end{macrocode}
  1732. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1733. % \subsection{Basics}
  1734. % \label{sec:mf-basics}
  1735. % Default values of style parameters:
  1736. %    \begin{macrocode}
  1737. thin#:=1pt#; % dimension of the lines
  1738. thick#:=2thin#;
  1739. arrow_width#:=3thick#; % arrows
  1740. arrow_height#:=2arrow_width#;
  1741. curly_len#:=3mm#;
  1742. dash_len#:=3mm#; % 'photon' lines
  1743. dot_len#:=2mm#; % 'photon' lines
  1744. wiggly_len#:=4mm#; % 'photon' lines
  1745. wiggly_slope:=60;
  1746. shade_black#:=1pt#; % shading
  1747. shade_white#:=2shade_black#;
  1748. shade_angle:=60;
  1749. %    \end{macrocode}
  1750. % Convert ``sharp'' units:
  1751. %    \begin{macrocode}
  1752. define_blacker_pixels (thick, thin, shade_black, shade_white,
  1753.   dash_len, dot_len, wiggly_len, curly_len,
  1754.   arrow_height, arrow_width);
  1755. %    \end{macrocode}
  1756. % Default to metric units, but this will be reset by |\begin{fmfchar}|
  1757. % anyway.
  1758. %    \begin {macrocode}
  1759. LaTeX_unitlength := mm;
  1760. %    \end{macrocode}
  1761. % Count the number of tokens in the argument:
  1762. %    \begin {macrocode}
  1763. vardef count (text list) =
  1764.   forsuffixes $ = list: + 1 endfor
  1765. enddef;
  1766. %    \end{macrocode}
  1767. % Parse the string |s| into comma separated tokens |opt[]|, ignoring
  1768. % blanks before |=|'s. Double commas are passed as a single comma.
  1769. %    \begin {macrocode}
  1770. vardef getopt (suffix opt) (expr s) =
  1771.   numeric opt.first, opt.last, n;
  1772.   string opt[], opt[]arg, c;
  1773.   boolean argp, escape;
  1774.   opt.first := 0;
  1775.   opt.last := 0;
  1776.   opt[opt.last] := "";
  1777.   argp := false;
  1778.   escape := false;
  1779.   for n = 1 upto length (s):
  1780.     c := substring (n-1,n) of s;
  1781. %    \end{macrocode}
  1782. % If we see a comma which has not been escaped, check for a second
  1783. % comma and set the |escape| flag or reset the |argp| flag, as
  1784. % appropriate:
  1785. %    \begin {macrocode}
  1786.     if not escape and (c = ","):
  1787.       if substring (n,n+1) of s = ",":
  1788.         escape := true;
  1789.       else:
  1790.         opt.last := opt.last + 1;
  1791.         opt[opt.last] := "";
  1792.         argp := false;
  1793.       fi
  1794. %    \end{macrocode}
  1795. % Start as argument and ignore |=|'s until the next option:
  1796. %    \begin {macrocode}
  1797.     elseif not argp and (c = "="):
  1798.       opt[opt.last]arg := "";
  1799.       argp := true;
  1800. %    \end{macrocode}
  1801. % Accept the next character (either option or argument) and reset the
  1802. % |escape| flag:
  1803. %    \begin {macrocode}
  1804.     elseif argp or (c <> " "):
  1805.       if argp:
  1806.         opt[opt.last]arg := opt[opt.last]arg & c;
  1807.       else:
  1808.         opt[opt.last] := opt[opt.last] & c;
  1809.       fi
  1810.       escape := false;
  1811.     fi
  1812.   endfor
  1813. enddef;
  1814. %    \end{macrocode}
  1815. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1816. % \subsection{Manipulating \texttt{picture}s}
  1817. % \label{sec:pictures}
  1818. % |save_picture (list_of_pictures)| |save|'s each member of
  1819. % |list_of_pictures| inside a group and reinitializes them as nullpictures.
  1820. %    \begin{macrocode}
  1821. def save_picture text t =
  1822.  save t; picture t; forsuffixes p=t: p:=nullpicture; endfor
  1823. enddef;
  1824. %    \end{macrocode}
  1825. % |begin_sketch| pushes the sketchpad stack and perform the following
  1826. % drawing commands (upto the next |end_sketch|) on the new sketchpad.
  1827. %    \begin{macrocode}
  1828. def begin_sketch =
  1829.  begingroup save_picture currentpicture;
  1830.  sketchlevel := sketchlevel+1;
  1831. enddef;
  1832. %    \end{macrocode}
  1833. % |end_sketch| pops the sketchpad stack.
  1834. %    \begin{macrocode}
  1835. def end_sketch =
  1836.  sketchlevel := sketchlevel-1;
  1837.  sketchpad[sketchlevel] := currentpicture;
  1838.  endgroup
  1839. enddef;
  1840. picture sketchpad[];
  1841. sketchlevel := 1;
  1842. %    \end{macrocode}
  1843. % |use_sketch (transformation)| copies the transformed sketchpad into
  1844. % the current picture.
  1845. %    \begin{macrocode}
  1846. vardef use_sketch text t =
  1847.  addto currentpicture also (sketchpad[sketchlevel] t)
  1848. enddef;
  1849. %    \end{macrocode}
  1850. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1851. % \subsection{Shading}
  1852. % \label{sec:shading}
  1853. % |shade (path_arg)| shades the interior of |path_arg|.  This shading is
  1854. % controlled by the global variables |shade_black|, |shade_white|, and
  1855. % |shade_angle|.
  1856. % Caveat:  The procedure is only guaranteed to work for convex paths.
  1857. % \begin{dubious}
  1858. %   \MP{} has nice primitives to aid in finding bounding boxes, in
  1859. %   \MF{} we have to rely on heuristics.
  1860. % \end{dubious}
  1861. %    \begin{macrocode}
  1862. vardef shade expr p_arg =
  1863.  save x,y,d,p,currentpen; path p; pen currentpen;    % push pen!
  1864.  pickup pencircle scaled shade_black;
  1865.  p = p_arg rotated - shade_angle;  % calculate enclosing rectangle
  1866.  x2' = x3' = xpart directionpoint up of p; % (rotated by |shade_angle|).
  1867.  x1' = x4' = xpart directionpoint down of p;
  1868.  y1' = y2' = ypart directionpoint right of p;
  1869.  y3' = y4' = ypart directionpoint left of p;
  1870.  forsuffixes $=1,2,3,4: z$ = z$' rotated shade_angle; endfor
  1871.  d = abs(z1-z4); % height.
  1872.  begin_sketch % fill rectangle with lines.
  1873.   for k=shade_white/d step (shade_white+shade_black)/d
  1874.     until 1 - shade_white/d:
  1875.    cutdraw k[z1,z4] -- k[z2,z3];
  1876.   endfor
  1877. %    \end{macrocode}
  1878. % \MF{} has no clipping operation, but since we know the bounding box,
  1879. % we can use \MF's pixel arithmetic for calculating the set
  1880. % theoretical intersection of the interior of |p_arg| and the diagonal
  1881. % lines in the bounding box:
  1882. %    \begin{macrocode}
  1883. %<*!mp>
  1884.   cullit;
  1885.   fill p_arg;
  1886.   unfill z1--z2--z3--z4--cycle;
  1887.   cullit;
  1888. %</!mp>
  1889. %    \end{macrocode}
  1890. % \MP{} has clipping build in but no pixel arithmetic:
  1891. % \changes{1.4}{1994/05/28}{\MP{} support: shading.}
  1892. %    \begin{macrocode}
  1893. %<*mp>
  1894.   clip currentpicture to p_arg;
  1895. %</mp>
  1896.  end_sketch;
  1897.  use_sketch;
  1898. enddef;
  1899. %    \end{macrocode}
  1900. % \begin{dubious}
  1901. %   Fix the placement of arrows on curved arcs.  John Hobby has a
  1902. %   particulary nice idea in plain \MP.
  1903. % \end{dubious}
  1904. % |arrow| expands to the standard arrowhead for fermions etc.
  1905. %    \begin{macrocode}
  1906. vardef arrow =
  1907.  clearxy; % push 'em!
  1908.  x1 - x2 = arrow_height; y2 - y3 = arrow_width;
  1909.  x1 = -3x2; x2 = x3; y1 = y2 + y3 = 0; % center it!
  1910.  z1--z2--z3--cycle
  1911. enddef;
  1912. %    \end{macrocode}
  1913. % |cut_circles| expands to a subpath of |path_arg|, excluding circles of
  1914. % |diam_a| (resp. |diam_b|) centered at the beginning (resp.~end) of
  1915. % |path_arg|.
  1916. %    \begin{macrocode}
  1917. vardef cut_circles (expr diam_a, p_arg, diam_b) =
  1918.  subpath (xpart(p_arg intersectiontimes fullcircle scaled diam_a
  1919.           shifted point 0 of p_arg),
  1920.       xpart(p_arg intersectiontimes fullcircle scaled diam_b
  1921.           shifted point infinity of p_arg))
  1922.    of p_arg
  1923. enddef;
  1924. %    \end{macrocode}
  1925. % The function |make_blob| is the working horse of |draw_blob|.
  1926. %    \begin{macrocode}
  1927. vardef make_blob (expr z_arg, diameter) =
  1928.  save p,currentpen; path p; pen currentpen;
  1929.  pickup pencircle scaled thick;
  1930.  p = fullcircle scaled diameter shifted z_arg;
  1931.  draw p; shade p;
  1932. enddef;
  1933. %    \end{macrocode}
  1934. % |draw_blob (pair_arg, diameter)| draws a shaded blob of diameter
  1935. % |diameter| centered at |pair_arg|. The thickness of the border is
  1936. % controlled by the global variable |thick|.
  1937. % Hint: It saves time to draw blobs of the same size in sequence.
  1938. %    \begin{macrocode}
  1939. vardef draw_blob (expr z_arg, diameter) =
  1940.  if sketched_blob_diameter <> diameter: % drawn lately?
  1941.   begin_sketch make_blob (origin, diameter); end_sketch; % redo hard work!
  1942.   sketched_blob_diameter:= diameter;  % record it
  1943.  use_sketch shifted z_arg; % the easy way ...
  1944. enddef;
  1945. %    \end{macrocode}
  1946. % |force_new_blob| forces the redrawing of a blob of the same diameter
  1947. % (in case you only changed the shading parameters).
  1948. %    \begin{macrocode}
  1949. def force_new_blob = sketched_blob_diameter := -1; enddef;
  1950. force_new_blob;                                 % initialize it.
  1951. %    \end{macrocode}
  1952. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1953. % \subsection{Drawing}
  1954. % \label{sec:drawing}
  1955. % |put_on_path (object, path_arg)| returns the |path_arg| after having
  1956. % drawn |object| (suitably rotated) at its mid point.
  1957. %    \begin{macrocode}
  1958. vardef put_on_path (expr o_arg, p_arg) =
  1959.  fill o_arg rotated angle direction length(p_arg)/2 of p_arg
  1960.         shifted point length(p_arg)/2 of p_arg;
  1961.  p_arg
  1962. enddef;
  1963. %    \end{macrocode}
  1964. % Easier than
  1965. % \begin{equation}
  1966. %   \int_0^1 dt \left\vert\frac{dx(t)}{dt}\right\vert
  1967. % \end{equation}
  1968. % with the integrand the square root of a fourth order polynomial, but
  1969. % sufficient for all practical purposes is
  1970. %    \begin{macrocode}
  1971. vardef pixlen (expr p, n) =
  1972.   for k=1 upto length(p): + segment_pixlen (subpath (k-1,k) of p, n) endfor
  1973. enddef;
  1974. %    \end{macrocode}
  1975. %    \begin{macrocode}
  1976. vardef segment_pixlen (expr p, n) =
  1977.   for k=1 upto n: + abs (point k/n of p - point (k-1)/n of p) endfor
  1978. enddef;
  1979. %    \end{macrocode}
  1980. % |wiggly (path_arg)| expands to a ``wiggled'' version of |path_arg|. The
  1981. % slope of the wiggles is controlled by the global variable |wiggle_slope|,
  1982. % the length of the wiggles by the global variable |wiggly_len|.
  1983. %    \begin{macrocode}
  1984. vardef wiggly (expr p_arg) =
  1985.  numeric wpp;
  1986.  wpp := ceiling (pixlen (p_arg, 10) / (wiggly_len * length(p_arg)));
  1987.  for k=0 upto wpp*length(p_arg) - 1:
  1988.   point k/wpp of p_arg
  1989.        {direction k/wpp of p_arg rotated wiggly_slope} ..
  1990.   point (k+.5)/wpp of p_arg
  1991.        {direction (k+.5)/wpp of p_arg rotated - wiggly_slope} ..
  1992.  endfor
  1993.  if cycle p_arg: cycle else: point infinity of p_arg fi
  1994. enddef;
  1995. %    \end{macrocode}
  1996. % |curly (path_arg)| expands to a ``curly'' version of |path_arg|. The
  1997. % the length of the curls is controlled  by the global variable
  1998. % |curly_len|.
  1999. %    \begin{macrocode}
  2000. vardef curly (expr p_arg) =
  2001.  numeric cpp;
  2002.  cpp := ceiling (pixlen (p_arg, 10) / (curly_len * length(p_arg)));
  2003.  if cycle p_arg:
  2004.    for k=0 upto cpp*length(p_arg) - 1:
  2005.      point (k+.33)/cpp of p_arg
  2006.            {direction (k+.33)/cpp of p_arg rotated 90} ..
  2007.      point (k-.33)/cpp of p_arg
  2008.            {direction (k-.33)/cpp of p_arg rotated -90} ..
  2009.    endfor
  2010.    cycle
  2011.  else:
  2012.    point 0 of p_arg
  2013.          {direction 0 of p_arg rotated -90} ..
  2014.    for k=1 upto cpp*length(p_arg) - 1:
  2015.      point (k+.33)/cpp of p_arg
  2016.            {direction (k+.33)/cpp of p_arg rotated 90} ..
  2017.      point (k-.33)/cpp of p_arg
  2018.            {direction (k-.33)/cpp of p_arg rotated -90} ..
  2019.    endfor
  2020.    point infinity of p_arg
  2021.          {direction infinity of p_arg rotated 90}
  2022. enddef;
  2023. %    \end{macrocode}
  2024. % |fermion (path_arg)| returns a fermion line (straight line with an arrow
  2025. % at the midpoint) on |path_arg|.
  2026. % |photon (path_arg)| returns a photon line (wiggled) on |path_arg|.
  2027. %    \begin{macrocode}
  2028. vardef fermion expr path_arg = put_on_path (arrow, path_arg) enddef;
  2029. vardef photon expr path_arg = wiggly (path_arg) enddef;
  2030. vardef gluon expr path_arg = curly (path_arg) enddef;
  2031. %    \end{macrocode}
  2032. % An inventory of valid line styles is implemented as a hash table:
  2033. %    \begin{macrocode}
  2034. save vsty_hash;
  2035. %    \end{macrocode}
  2036. % This is a bit like |mode_def| in plain \MF{} but doesn't use an
  2037. % array of available modes: |style_def "foo"| will define a macro
  2038. % |draw_foo| drawing a line of a certain style along any given path:
  2039. %    \begin{macrocode}
  2040. def style_def suffix s =
  2041.   vsty_hash.s := 1;
  2042.   expandafter quote vardef scantokens ("draw_" & str s)
  2043. enddef;
  2044. %    \end{macrocode}
  2045. % Let \MF{} do the lookup: suffices
  2046. %    \begin{macrocode}
  2047. vardef vsty_exists suffix s =
  2048.   known vsty_hash.s
  2049. enddef;
  2050. %    \end{macrocode}
  2051. % an strings
  2052. %    \begin{macrocode}
  2053. vardef valid_style expr s =
  2054.   expandafter vsty_exists scantokens (s)
  2055. enddef;
  2056. %    \end{macrocode}
  2057. % |phantom| lines are simple:
  2058. %    \begin{macrocode}
  2059. style_def phantom expr path_arg = \ enddef;
  2060. %    \end{macrocode}
  2061. % |plain| lines aren't harder and we allow |vanilla| as an alias:
  2062. %    \begin{macrocode}
  2063. style_def plain expr p_arg = draw p_arg enddef;
  2064. style_def vanilla expr p_arg = draw p_arg enddef;
  2065. %    \end{macrocode}
  2066. % And some more:
  2067. %    \begin{macrocode}
  2068. style_def fermion (expr p_arg) = draw fermion (p_arg) enddef;
  2069. style_def quark (expr p_arg) = draw fermion (p_arg) enddef;
  2070. style_def electron (expr p_arg) = draw fermion (p_arg) enddef;
  2071. style_def photon (expr p_arg) = draw photon (p_arg) enddef;
  2072. style_def boson (expr p_arg) = draw photon (p_arg) enddef;
  2073. style_def gluon (expr p_arg) = draw gluon (p_arg) enddef;
  2074. %    \end{macrocode}
  2075. % |draw_dashes (expr p_arg)| draws a scalar line (dashed line)
  2076. % on |path_arg|
  2077. % \changes{1.4}{1994/05/27}{%
  2078. %   Rename the line style \texttt{dashed} to \texttt{dashes}, to avoid
  2079. %   a name clash with \MP.}
  2080. %    \begin{macrocode}
  2081. style_def dashes (expr p_arg) =
  2082.  numeric dpp;
  2083.  dpp := ceiling (pixlen (p_arg, 10) / (dash_len * length(p_arg)));
  2084.  for k=0 upto dpp*length(p_arg) - 1:
  2085.   draw point k/dpp of p_arg ..
  2086.    point (k+.5)/dpp of p_arg;
  2087.  endfor
  2088. enddef;
  2089. %    \end{macrocode}
  2090. %    \begin{macrocode}
  2091. style_def scalar (expr p_arg) =
  2092.   draw_dashes (put_on_path (arrow, p_arg))
  2093. enddef;
  2094. %    \end{macrocode}
  2095. % |draw_dots (expr p_arg)| draws a dotted line on |path_arg|
  2096. % \changes{1.4}{1994/05/27}{%
  2097. %   Rename the line style \texttt{dotted} to \texttt{dots}, to be
  2098. %   consistent with \texttt{dashes}.}
  2099. %    \begin{macrocode}
  2100. style_def dots (expr p_arg) =
  2101.  numeric dpp;
  2102.  dpp := ceiling (pixlen (p_arg, 10) / (dot_len * length(p_arg)));
  2103.  for k=0 upto dpp*length(p_arg):
  2104.   drawdot point k/dpp of p_arg;
  2105.  endfor
  2106. enddef;
  2107. %    \end{macrocode}
  2108. %    \begin{macrocode}
  2109. style_def ghost (expr p_arg) =
  2110.   draw_dots (put_on_path (arrow, p_arg))
  2111. enddef;
  2112. %    \end{macrocode}
  2113. % |draw_double (expr p_arg)| draws a double line.
  2114. %    \begin{macrocode}
  2115. style_def double (expr p_arg) =
  2116.   begingroup
  2117.     pen oldpen;
  2118.     oldpen := currentpen;
  2119.     pickup oldpen scaled 3; % draw a thick linn
  2120.     draw p_arg;
  2121.     pickup oldpen;
  2122.     cullit; undraw p_arg; cullit; % and remove the stuffing
  2123.   endgroup;
  2124. enddef;
  2125. %    \end{macrocode}
  2126. % |draw_heavy (expr p_arg)| draws a heavy line (double line with an
  2127. % arrow at the midpoint).  |draw_double (fermion (..))| is an
  2128. % interesting alternative, but not very useful.
  2129. %    \begin{macrocode}
  2130. style_def heavy (expr p_arg) =
  2131.   begingroup
  2132.     path discard;
  2133.     draw_double (p_arg);
  2134.     discard = fermion (p_arg);
  2135.   endgroup
  2136. enddef;
  2137. %    \end{macrocode}
  2138. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2139. % \subsection{Graphs of vertices}
  2140. % \label{sec:graphs}
  2141. % Here is the fun part of \FMF: \emph{automagic} placement of
  2142. % vertices.
  2143. %    \begin{macrocode}
  2144. %tracingmacros:=1;
  2145. %tracingonline:=1;
  2146. tracingstats:=1;
  2147. %    \end{macrocode}
  2148. % You can say |vtracing:=true| too see what's going on.
  2149. %    \begin{macrocode}
  2150. boolean vtracing;
  2151. vtracing := false; % true
  2152. %    \end{macrocode}
  2153. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2154. % \subsubsection{Data structures}
  2155. % \begin{table}
  2156. %   \begin{tabular}{rll}
  2157. %     Type      & Name          & Purpose \\\hline
  2158. %     |numeric| & |vlist.first| & pointer to first vertex (usually 1) \\
  2159. %     |numeric| & |vlist.last|  & pointer to last vertex (starts with 0) \\
  2160. %     |string|  & |vlist[|$i$|]name|          & symbolic name of the vertex\\
  2161. %     |pair|    & |vlist[|$i$|]loc|           & position of the vertex \\
  2162. %     |string|  & |vlist[|$i$|]lbl|           & label \\
  2163. %     |numeric| & |vlist[|$i$|]lbl.ang|       & angle \\
  2164. %     |numeric| & |vlist[|$i$|]lbl.dist|      & distance \\
  2165. %     |numeric| & |vlist[|$i$|]arc.first|     & pointer to first arc \\
  2166. %     |numeric| & |vlist[|$i$|]arc.last|      & pointer to last arc \\
  2167. %     |numeric| & |vlist[|$i$|]arc[|$j$|]|    & $j$th arc of the $i$th vertex \\
  2168. %     |string|  & |vlist[|$i$|]arc[|$j$|]sty| & style of the arc\\
  2169. %     |numeric| & |vlist[|$i$|]arc[|$j$|]tns| & tension of the arc\\
  2170. %     |string|  & |vlist[|$i$|]arc[|$j$|]lsr| & left, straight, right\\
  2171. %     |string|  & |vlist[|$i$|]arc[|$j$|]lbl| & label\\
  2172. %     |string|  & |vlist[|$i$|]arc[|$j$|]lbl.side|& side of the label\\
  2173. %     |numeric| & |vlist[|$i$|]arc[|$j$|]lbl.dist|& distance of the label\\
  2174. %     |numeric| & |vlist[|$i$|]blob|          & diameter of the ``blob''\\
  2175. %     |numeric| & |vlist[|$i$|]dot|           & whether to draw
  2176. %                                 a dot at the vertex
  2177. %   \end{tabular}
  2178. %   \caption{Vertex data structure}
  2179. %   \label{tab:VDS}
  2180. % \end{table}
  2181. % The data structure for our graph is shown in
  2182. % table~\ref{tab:VDS}\footnote{%
  2183. %   \begin{dubious}
  2184. %     \texttt{boolean vlist[i]arc[j]smooth} will indicate that this
  2185. %     arc belongs to a set of arcs which are to be smoothly connected.
  2186. %     The implementation will start by going to the strt of this set,
  2187. %     define a long smooth path and finally do the drawing on the
  2188. %     various subpaths.
  2189. %   \end{dubious}}.
  2190. % \MF{} turns out to be quite powerful, providing such constructs
  2191. % in an unconventional, but flexible and concise way.  While we use
  2192. % |save vhash| to forget all previously defined vertices, we leave
  2193. % |vlist| alone, because we will know from $|vlist.last| <
  2194. % |vlist.first|$ that it's empty.  Note that we can't |vardef| this
  2195. % because then the |save| would go inside a group.
  2196. %    \begin{macrocode}
  2197. def vinit =
  2198.   save vhash;
  2199.   numeric vlist.first, vlist.last;
  2200.   vlist.first := 1;
  2201.   vlist.last := 0;
  2202.   pair vlist[]loc;
  2203.   numeric vlist[]arc.first, vlist[]arc.last, vlist[]arc[],
  2204.     vlist[]arc[]tns, vlist[]arc[]lbl.dist;
  2205.   string vlist[]name, vlist[]lbl, vlist[]arc[]sty, vlist[]arc[]lsr,
  2206.     vlist[]arc[]lbl, vlist[]arc[]lbl.side;
  2207.   numeric vlist[]lbl.ang, vlist[]lbl.side, vlist[]blob, vlist[]dot;
  2208. enddef;
  2209. %</base>
  2210. %    \end{macrocode}
  2211. % \begin{macro}{\fmfinit}
  2212. % We can also ask for initialization explicitely from \TeX{} (usually
  2213. % it is called implicitely by |\begin{fmfchar}|).  This flushes the
  2214. % vertex table. 
  2215. %    \begin{macrocode}
  2216. %<style>\def\fmfinit{\fmfcmd{vinit;}}
  2217. %    \end{macrocode}
  2218. % \end{macro}
  2219. % Useful abstractions are: first for looping over all vertices
  2220. %    \begin{macrocode}
  2221. %<*base>
  2222. def vertices =
  2223.   vlist.first upto vlist.last
  2224. enddef;
  2225. %    \end{macrocode}
  2226. % and second for looping over all arcs of vertex |i|
  2227. %    \begin{macrocode}
  2228. def varcs (text i) =
  2229.   vlist[i]arc.first upto vlist[i]arc.last
  2230. enddef;
  2231. %    \end{macrocode}
  2232. % Entering vertices is simple, but note that we have to make
  2233. % |vlist[|$i$|]loc| undefined, because it might be around from an
  2234. % earlier character still.
  2235. %    \begin{macrocode}
  2236. vardef venter suffix v =
  2237.   if not vexists v:
  2238.     vlist.last := vlist.last + 1;
  2239.     vhash.v := vlist.last;
  2240.     vlist[vhash.v]name := str v;
  2241.     vlist[vhash.v]loc := (whatever,whatever);
  2242.     vlist[vhash.v]arc.first := 1;
  2243.     vlist[vhash.v]arc.last := 0;
  2244.     vlist[vhash.v]lbl := "";
  2245.     vlist[vhash.v]lbl.ang := whatever;
  2246.     vlist[vhash.v]lbl.dist := 3;
  2247.     vlist[vhash.v]blob := 0;
  2248.     vlist[vhash.v]dot := 0;
  2249. enddef;
  2250. %    \end{macrocode}
  2251. % The next three \emph{are} trivial. Existence
  2252. %    \begin{macrocode}
  2253. vardef vexists suffix v =
  2254.   if known vhash.v: true else: false fi
  2255. enddef;
  2256. %    \end{macrocode}
  2257. % index
  2258. %    \begin{macrocode}
  2259. vardef vlookup suffix v =
  2260.   if vexists v: vhash.v else: 0 fi
  2261. enddef;
  2262. %    \end{macrocode}
  2263. % and location
  2264. %    \begin{macrocode}
  2265. vardef vloc suffix v =
  2266.   vlist[vlookup v]loc
  2267. enddef;
  2268. %    \end{macrocode}
  2269. % of vertices.  We use |vhash.v| instead of |v| so that we can clear
  2270. % the whole hash table with |save vhash|.
  2271. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2272. % \subsubsection{Constructing the Graph}
  2273. % Connect the vertices in the list |vl| with lines of style |style|,
  2274. % allocating them if necessary.
  2275. % \begin{dubious}
  2276. %   Be more flexible about whether adding arrows
  2277. %   or not.  This should be implemented using the options and devising
  2278. %   a path filter mechanism.
  2279. % \end{dubious}
  2280. %    \begin{macrocode}
  2281. vardef vconnect (expr linesty) (text vl) =
  2282.   save from, nfrom, nto, nopt, sty;
  2283.   numeric from, nfrom, nto, nopt;
  2284.   string sty;
  2285.   getopt (opt, linesty);
  2286.   sty := opt[opt.first];
  2287.   if known opt[opt.first]arg:
  2288.     message "feynmf: line styles don't take arguments.  "
  2289.              & "Argument `" & opt[opt.first]arg & "' ignored.";
  2290.   opt.first := opt.first + 1;
  2291.   forsuffixes to = vl:
  2292.     venter to;
  2293.     nto := vlookup to;
  2294.     if known nfrom:
  2295.       vlist[nfrom]arc.last := vlist[nfrom]arc.last + 1;
  2296.       vlist[nto]arc.last := vlist[nto]arc.last + 1;
  2297.       vlist[nfrom]arc[vlist[nfrom]arc.last] := nto;
  2298.       vlist[nto]arc[vlist[nto]arc.last] := nfrom;
  2299.       vlist[nfrom]arc[vlist[nfrom]arc.last]tns := 1;
  2300.       vlist[nto]arc[vlist[nto]arc.last]tns := 1;
  2301.       vlist[nfrom]arc[vlist[nfrom]arc.last]lsr := "s";
  2302.       vlist[nfrom]arc[vlist[nfrom]arc.last]lbl := "";
  2303.       vlist[nfrom]arc[vlist[nfrom]arc.last]lbl.side := "";
  2304.       vlist[nfrom]arc[vlist[nfrom]arc.last]lbl.dist := 3;
  2305. %    \end{macrocode}
  2306. % Handle options, starting with an option |tension|:
  2307. %    \begin{macrocode}
  2308.       for nopt = opt.first upto opt.last:
  2309.         if opt[nopt] = "tension":
  2310.           get_argument (opt[nopt], scantokens (opt[nopt]arg),
  2311.                         vlist[nfrom]arc[vlist[nfrom]arc.last]tns);
  2312.           get_argument (opt[nopt], scantokens (opt[nopt]arg),
  2313.                         vlist[nto]arc[vlist[nto]arc.last]tns);
  2314. %    \end{macrocode}
  2315. % Handle |left|, |straight| and |right|, which ask for making a
  2316. % halfcircle detour on the specified side or going straight:
  2317. %    \begin{macrocode}
  2318.         elseif opt[nopt] = "left":
  2319.           vlist[nfrom]arc[vlist[nfrom]arc.last]lsr := "l";
  2320.           ignore_argument (opt[nopt], opt[nopt]arg);
  2321.         elseif opt[nopt] = "straight":
  2322.           vlist[nfrom]arc[vlist[nfrom]arc.last]lsr := "s";
  2323.           ignore_argument (opt[nopt], opt[nopt]arg);
  2324.         elseif opt[nopt] = "right":
  2325.           vlist[nfrom]arc[vlist[nfrom]arc.last]lsr := "r";
  2326.           ignore_argument (opt[nopt], opt[nopt]arg);
  2327. %    \end{macrocode}
  2328. % Labels and which side they're on:
  2329. %    \begin{macrocode}
  2330.         elseif opt[nopt] = "label":
  2331.           get_argument (opt[nopt], opt[nopt]arg,
  2332.                         vlist[nfrom]arc[vlist[nfrom]arc.last]lbl);
  2333.         elseif opt[nopt] = "side":
  2334.           get_argument (opt[nopt], opt[nopt]arg,
  2335.                         vlist[nfrom]arc[vlist[nfrom]arc.last]lbl.side);
  2336.         elseif opt[nopt] = "dist":
  2337.           get_argument (opt[nopt], scantokens (opt[nopt]arg),
  2338.                         vlist[nfrom]arc[vlist[nfrom]arc.last]lbl.dist);
  2339. %    \end{macrocode}
  2340. % Ignore bogus options:
  2341. %    \begin{macrocode}
  2342.         else:
  2343.           ignore_option (opt[nopt], opt[nopt]arg);
  2344.         fi
  2345.       endfor
  2346. %    \end{macrocode}
  2347. % Avoid entering invalid linestyles into the tables, because the
  2348. % delayed evaluation will make errors harder to find (line numbers
  2349. % will be wrong):
  2350. %    \begin{macrocode}
  2351.       if valid_style sty:
  2352.         vlist[nfrom]arc[vlist[nfrom]arc.last]sty := sty;
  2353.       else:
  2354.         errhelp "feynmf: your linestyle is not recognizable, "
  2355.               & "check spelling and reprocess!";
  2356.         errmessage "feynmf: line style `" & sty & "' not known, "
  2357.                  & "replaced by `vanilla'"; 
  2358.         vlist[nfrom]arc[vlist[nfrom]arc.last]sty := "vanilla";
  2359.       fi
  2360. %    \end{macrocode}
  2361. % The other end of the arc gets an empty style, which will ensure that
  2362. % the arc is only drawn once and on the correct direction.
  2363. %    \begin{macrocode}
  2364.       vlist[nto]arc[vlist[nto]arc.last]sty := "";
  2365.     fi
  2366. %    \end{macrocode}
  2367. % Restart the loop:
  2368. %    \begin{macrocode}
  2369.     nfrom := nto;
  2370.   endfor
  2371. enddef;
  2372. %    \end{macrocode}
  2373. %    \begin{macrocode}
  2374. vardef get_argument (expr opt, arg) (suffix variable) =
  2375.   if known arg:
  2376.     variable := arg;
  2377.   else:
  2378.     message "feynmf: option `" & opt & "' needs an argument.  Ignored.";
  2379. enddef;
  2380. %    \end{macrocode}
  2381. %    \begin{macrocode}
  2382. vardef ignore_argument (expr opt, arg) =
  2383.   if known arg:
  2384.     message "feynmf: option `" & opt & "' doesn't take an argument.  "
  2385.           & "Argument `" & arg & "' ignored.";
  2386. enddef;
  2387. %    \end{macrocode}
  2388. %    \begin{macrocode}
  2389. vardef ignore_option (expr opt, arg)=
  2390.   if known arg:
  2391.     message "feynmf: ignoring option " & opt & "=" & arg & ".";
  2392.   else:
  2393.     message "feynmf: ignoring option " & opt & ".";
  2394. enddef;
  2395. %</base>
  2396. %    \end{macrocode}
  2397. % \begin{macro}{\fmf}
  2398. % Since |vconnect| wil be the most frequent macro, we give it the
  2399. % shortest \TeX{} command sequence:
  2400. %    \begin{macrocode}
  2401. %<style>\def\fmf#1#2{\fmfcmd{vconnect ("#1", #2);}}
  2402. %    \end{macrocode}
  2403. % \end{macro}
  2404. %    \begin{macrocode}
  2405. %<*base>
  2406. vardef vcycle (expr sty) (suffix v) (expr n) =
  2407.   for $ = 1 upto n - 1:
  2408.     vconnect (sty, v[$], v[$+1]);
  2409.   endfor
  2410.   vconnect (sty, v[n], v[1]);
  2411. enddef;
  2412. %    \end{macrocode}
  2413. % A half circle to the left of the straight line from vertex |a| to
  2414. % vertex |b|
  2415. %    \begin{macrocode}
  2416. vardef circle_left (expr a, b) =
  2417.   reverse halfcircle
  2418.     rotated angle (b - a)
  2419.     scaled abs (a - b)
  2420.     shifted .5[a, b]
  2421. enddef;
  2422. vardef vcircle_left (suffix a, b) =
  2423.   circle_left (vloc a, vloc b) =
  2424. enddef;
  2425. %    \end{macrocode}
  2426. % and again on the right:
  2427. %    \begin{macrocode}
  2428. vardef circle_right (expr a, b) =
  2429.   halfcircle
  2430.     rotated angle (a - b)
  2431.     scaled abs (a - b)
  2432.     shifted .5[a, b]
  2433. enddef;
  2434. vardef vcircle_right (suffix a, b) =
  2435.   circle_right (vloc a, vloc b) =
  2436. enddef;
  2437. %</base>
  2438. %    \end{macrocode}
  2439. % \begin{macro}{\fmfforce}
  2440. %   \begin{macro}{\fmfshift}
  2441. % Explicit placement and shifting of vertices is handled in \TeX{} with
  2442. %    \begin{macrocode}
  2443. %<style>\def\fmfforce#1#2{\fmfcmd{vforce ((#1),#2);}}
  2444. %<style>\def\fmfshift#1#2{\fmfcmd{vshift((#1),#2);}}
  2445. %    \end{macrocode}
  2446. %   \end{macro}
  2447. % \end{macro}
  2448. % Force the vertex |v| to be placed at position |z|:
  2449. %    \begin{macrocode}
  2450. %<*base>
  2451. vardef vforce (expr z) (suffix v) =
  2452.   venter v;
  2453.   vlist[vlookup v]loc := z;
  2454. enddef;
  2455. %    \end{macrocode}
  2456. % Shift the vertex |v| by |z|:
  2457. %    \begin{macrocode}
  2458. vardef vshift (expr z) (text vl) =
  2459.   forsuffixes $=vl:
  2460.     if vexists $:
  2461.       vlist[vlookup $]loc := vlist[vlookup $]loc + z;
  2462.     fi
  2463.   endfor
  2464. enddef;
  2465. %</base>
  2466. %    \end{macrocode}
  2467. % \begin{macro}{\fmflabel}
  2468. %    \begin{macrocode}
  2469. %<style>\def\fmflabel#1#2{\fmfcmd{vlabel ("#1", #2);}}
  2470. %    \end{macrocode}
  2471. % \end{macro}
  2472. %    \begin{macrocode}
  2473. %<*base>
  2474. vardef vlabel (expr s) (suffix v) =
  2475.   venter v;
  2476.   vlist[vlookup v]lbl := s;
  2477. enddef;
  2478. %</base>
  2479. %    \end{macrocode}
  2480. % \begin{macro}{\fmfv}
  2481. %    \begin{macrocode}
  2482. %<style>\def\fmfv#1#2{\fmfcmd{vvertex ("#1", #2);}}
  2483. %    \end{macrocode}
  2484. % \end{macro}
  2485. %    \begin{macrocode}
  2486. %<*base>
  2487. vardef vvertex (expr vtxsty) (text vl) =
  2488.   save nopt, sty, arg;
  2489.   numeric nopt, arg;
  2490.   string sty;
  2491.   getopt (opt, vtxsty);
  2492.   sty := opt[opt.first];
  2493.   if known opt[opt.first]arg:
  2494.     arg := scantokens (opt[opt.first]arg):
  2495.   else:
  2496.     arg := .2w;
  2497.   opt.first := opt.first + 1;
  2498.   forsuffixes v = vl:
  2499.     venter v;
  2500.     n := vlookup v;
  2501.     if sty = "blob":
  2502.       vlist[n]blob := arg;
  2503.       vlist[n]dot := 0;
  2504.     elseif sty = "dot":
  2505.       vlist[n]blob := 0;
  2506.       vlist[n]dot := 1;
  2507.     fi
  2508.     for nopt = opt.first upto opt.last:
  2509.       if opt[nopt] = "label":
  2510.         get_argument (opt[nopt], opt[nopt]arg, vlist[n]lbl);
  2511.       elseif opt[nopt] = "angle":
  2512.         get_argument (opt[nopt], scantokens (opt[nopt]arg),
  2513.                       vlist[n]lbl.ang);
  2514.       elseif opt[nopt] = "dist":
  2515.         get_argument (opt[nopt], scantokens (opt[nopt]arg),
  2516.                       vlist[n]lbl.dist);
  2517. %    \end{macrocode}
  2518. % Ignore bogus options:
  2519. %    \begin{macrocode}
  2520.       else:
  2521.         ignore_option (opt[nopt], opt[nopt]arg);
  2522.       fi
  2523.     endfor
  2524.   endfor
  2525. enddef;
  2526. %</base>
  2527. %    \end{macrocode}
  2528. % \begin{macro}{\fmfblob}
  2529. %   \begin{macro}{\fmfdot}
  2530. % We can decorate vertices with ``blobs'' and dots from \TeX{} with
  2531. % the command sequences:
  2532. %    \begin{macrocode}
  2533. %<style>\def\fmfblob#1#2{\fmfcmd{vblob ((#1),#2);}}
  2534. %<style>\def\fmfdot#1{\fmfcmd{vdot (#1);}}
  2535. %    \end{macrocode}
  2536. %   \end{macro}
  2537. % \end{macro}
  2538. % The vertices in the list |vl| will be drawn with a blob of diameter
  2539. % |bd|:
  2540. % \begin{dubious}
  2541. %   Be more flexible about decorated vertices.
  2542. %   In addition to dots and blobs, add squares, triangles, etc.  Also
  2543. %   allow them to be filled or open.  Then even Wolfgang's thesis can
  2544. %   be produced using the documented interface exclusively.
  2545. % \end{dubious}
  2546. %    \begin{macrocode}
  2547. %<*base>
  2548. vardef vblob (expr bd) (text vl)=
  2549.   forsuffixes $=vl:
  2550.     if not vexists $: venter $; fi
  2551.     vlist[vlookup $]blob := bd;
  2552.     vlist[vlookup $]dot := 0;
  2553.  endfor
  2554. enddef;
  2555. %    \end{macrocode}
  2556. % The vertices in the list |vl| will be drawn with a dot.
  2557. %    \begin{macrocode}
  2558. vardef vdot (text vl)=
  2559.   forsuffixes $=vl:
  2560.     if not vexists $: venter $; fi
  2561.     vlist[vlookup $]dot := 1;
  2562.     vlist[vlookup $]blob := 0;
  2563.  endfor
  2564. enddef;
  2565. %</base>
  2566. %    \end{macrocode}
  2567. % \begin{macro}{\fmfincoming}
  2568. %   \begin{macro}{\fmfoutgoing}
  2569. %     \begin{macro}{\fmfsurround}
  2570. % External vertices are positioned thusly in \TeX{}:
  2571. %    \begin{macrocode}
  2572. %<style>\def\fmfincoming#1{\fmfcmd{vincoming(#1);}}
  2573. %<style>\def\fmfoutgoing#1{\fmfcmd{voutgoing(#1);}}
  2574. %<style>\def\fmfsurround#1{\fmfcmd{vsurround(#1);}}
  2575. %    \end{macrocode}
  2576. %     \end{macro}
  2577. %   \end{macro}
  2578. % \end{macro}
  2579. % Here are the ``galleries'' we're hooking our external vertices on
  2580. % (see also the pictures on page~\pageref{p:galleries}):
  2581. %    \begin{macrocode}
  2582. %<*base>
  2583. vardef in_gallery = (.1w,0)..(0,.5h)..(.1w,h) enddef;
  2584. vardef out_gallery = (.9w,0)..(w,.5h)..(.9w,h) enddef;
  2585. vardef surround_gallery =
  2586.   superellipse ((w,.5h), (.5w,h), (0,.5h), (.5w,0), .75)
  2587. enddef;
  2588. %    \end{macrocode}
  2589. % and the \MF{} code which does the hard work for the above
  2590. % \TeX{} macros
  2591. %    \begin{macrocode}
  2592. vardef vincoming (text vl) = vdistribute (in_gallery, vl) enddef;
  2593. vardef voutgoing (text vl) = vdistribute (out_gallery, vl) enddef;
  2594. vardef vsurround (text vl) = vdistribute (surround_gallery, vl) enddef;
  2595. %    \end{macrocode}
  2596. % Distribute the vertices in the list |vl| evenly along the path |p|:
  2597. %    \begin{macrocode}
  2598. vardef vdistribute (expr p) (text vl) =
  2599.   numeric numv, len, off;
  2600.   numv := count (vl);
  2601. %    \end{macrocode}
  2602. % If the path is cyclic, place the first vertex twice:
  2603. %    \begin{macrocode}
  2604.   if cycle p: numv := numv + 1; fi
  2605.   len := length (p);
  2606.   if numv = 1:
  2607.     vforce (point len/2 of p, vl);
  2608.   else:
  2609.     off := 0;
  2610.     forsuffixes $ = vl:
  2611.       vforce (point off of p, $);
  2612.       off := off + len/(numv-1);
  2613.     endfor
  2614. enddef;
  2615. %</base>
  2616. %    \end{macrocode}
  2617. % \begin{macro}{\fmfincomingn}
  2618. %   \begin{macro}{\fmfoutgoingn}
  2619. %     \begin{macro}{\fmfsurroundn}
  2620. % A short cut:
  2621. %    \begin{macrocode}
  2622. %<style>\def\fmfincomingn#1#2{\fmfcmd{vincomingn(#1,#2);}}
  2623. %<style>\def\fmfoutgoingn#1#2{\fmfcmd{voutgoingn(#1,#2);}}
  2624. %<style>\def\fmfsurroundn#1#2{\fmfcmd{vsurroundn(#1,#2);}}
  2625. %    \end{macrocode}
  2626. %     \end{macro}
  2627. %   \end{macro}
  2628. % \end{macro}
  2629. %    \begin{macrocode}
  2630. %<*base>
  2631. def vmklist (suffix v) (expr n) =
  2632.   for $ = 1 upto n-1: v[$], endfor v[n]
  2633. enddef;
  2634. %    \end{macrocode}
  2635. %    \begin{macrocode}
  2636. vardef vincomingn (suffix v) (expr n) =
  2637.   vincoming (vmklist (v, n));
  2638. enddef;
  2639. %    \end{macrocode}
  2640. %    \begin{macrocode}
  2641. vardef voutgoingn (suffix v) (expr n) =
  2642.   voutgoing (vmklist (v, n));
  2643. enddef;
  2644. %    \end{macrocode}
  2645. %    \begin{macrocode}
  2646. vardef vsurroundn (suffix v) (expr n) =
  2647.   vsurround (vmklist (v, n));
  2648. enddef;
  2649. %    \end{macrocode}
  2650. %    \begin{macrocode}
  2651. vardef vdistributen (expr p) (suffix v) (expr n) =
  2652.   vdistribute (p, vmklist (v, n))
  2653. enddef;
  2654. %    \end{macrocode}
  2655. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2656. % \subsubsection{Choosing a Layout for the Graph}
  2657. % The procedure |vposition| is called near the end and
  2658. % chooses ``optimal'' vertex positions by minimizing the combined
  2659. % length of the arcs.  Since the quantity to be optimized is quadratic
  2660. % in the vertices
  2661. % \begin{equation}
  2662. %   L = \sum_{v_i,v_j\in\mbox{\scriptsize arcs}}(v_i - v_j)^2,
  2663. % \end{equation}
  2664. % we just have to solve a system of linear equations:
  2665. % \begin{equation}
  2666. %   0 = \frac{1}{2} \nabla L
  2667. %     = \sum_{v_j\in\mbox{\scriptsize arcs}(v_i)}(v_i - v_j).
  2668. % \end{equation}
  2669. % The implementation is simple: loop over all vertices in |vlist[]|
  2670. %    \begin{macrocode}
  2671. vardef vposition =
  2672.   for i = vertices:
  2673. %    \end{macrocode}
  2674. % and iff the position of the vertex has not been fixed yet, add
  2675. % another equation:
  2676. %    \begin{macrocode}
  2677.     if unknown vlist[i]loc:
  2678.       origin = origin
  2679.       for j = varcs (i):
  2680.         + vlist[i]arc[j]tns * (vlist[i]loc - vlist[vlist[i]arc[j]]loc)
  2681.       endfor;
  2682.     fi
  2683.   endfor
  2684. %    \end{macrocode}
  2685. % Inquiring minds might want to see the result in numbers:
  2686. %    \begin{macrocode}
  2687.   if vtracing: vdump; fi
  2688. enddef;
  2689. %</base>
  2690. %    \end{macrocode}
  2691. % \begin{macro}{\fmfposition}
  2692. % Again, we can ask for positioning and drawing explicitely from \TeX
  2693. % (usually called implicitely by |\end{fmfchar}|).  This is useful for
  2694. % subsequent fine tuning.
  2695. %    \begin{macrocode}
  2696. %<style>\def\fmfposition{\fmfcmd{vposition;}}
  2697. %    \end{macrocode}
  2698. % \end{macro}
  2699. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2700. % \subsubsection{Drawing the Graph}
  2701. % \begin{macro}{\fmfdraw}
  2702. %    \begin{macrocode}
  2703. %<style>\def\fmfdraw{\fmfcmd{vdraw;}}
  2704. %    \end{macrocode}
  2705. % \end{macro}
  2706. % And here's the actual \MF{} implementation of |vdraw|:
  2707. %    \begin{macrocode}
  2708. %<*base>
  2709. vardef vdraw =
  2710. %    \end{macrocode}
  2711. % Check that all vertices are known before attempting to draw the
  2712. % diagram.
  2713. %    \begin{macrocode}
  2714.   for i = vertices:
  2715.     if not known vlist[i]loc:
  2716.       errhelp "Your graph specification was not complete (probably a "
  2717.             & "lone vertex).            Check logic and reprocess!";
  2718.       errmessage "feynmf: vertex `" & vlist[i]name & "' not determined, "
  2719.                & "replaced by `(0,0)'."; 
  2720.       vlist[i]loc := origin;
  2721.     fi
  2722.   endfor
  2723. %    \end{macrocode}
  2724. % Now do the actual drawing, looping over vertices and arcs.
  2725. %    \begin{macrocode}
  2726.   for i = vertices:
  2727.     for j = varcs (i):
  2728.       if vlist[i]arc[j]sty <> "":
  2729. %    \end{macrocode}
  2730. % This could be cleaned up a little bit:
  2731. %    \begin{macrocode}
  2732.         vdraw_arc (vlist[i]arc[j]sty,
  2733.                    cut_circles (vlist[i]blob,
  2734.                                 if vlist[i]arc[j]lsr = "l":
  2735.                                   circle_left (vlist[i]loc,
  2736.                                                vlist[vlist[i]arc[j]]loc)
  2737.                                 elseif vlist[i]arc[j]lsr = "s":
  2738.                                   vlist[i]loc .. vlist[vlist[i]arc[j]]loc
  2739.                                 elseif vlist[i]arc[j]lsr = "r":
  2740.                                   circle_right (vlist[i]loc,
  2741.                                                 vlist[vlist[i]arc[j]]loc)
  2742.                                 fi,
  2743.                                 vlist[vlist[i]arc[j]]blob),
  2744.                    vlist[i]arc[j]lbl,
  2745.                    vlist[i]arc[j]lbl.side,
  2746.                    vlist[i]arc[j]lbl.dist);
  2747.       fi
  2748.     endfor;
  2749.     vdraw_vertex_label (vlist[i]loc, vlist[i]lbl,
  2750.                         vlist[i]lbl.ang, vlist[i]lbl.dist);
  2751.     vdraw_vertex_blob (vlist[i]loc, vlist[i]blob);
  2752.   endfor
  2753. %    \end{macrocode}
  2754. % Do the dots in a separate pass, so we can save multiple |pickup|s
  2755. %    \begin{macrocode}
  2756.   begingroup
  2757.     save currentpen;
  2758.     pen currentpen;
  2759.     pickup pencircle scaled 2thick;
  2760.     for i = vertices:
  2761.       vdraw_vertex_dot (vlist[i]loc, vlist[i]dot);
  2762.     endfor
  2763.   endgroup;
  2764. enddef;
  2765. %    \end{macrocode}
  2766. %    \begin{macrocode}
  2767. vardef vdraw_arc (expr sty, arc, lbl, side, dist) =
  2768.   scantokens ("draw_" & sty) (arc);
  2769.   vdraw_arc_label (arc, lbl, side, dist);
  2770. enddef;
  2771. %    \end{macrocode}
  2772. %    \begin{macrocode}
  2773. vardef vdraw_arc_label (expr arc, lbl, side, d) =
  2774.   if lbl <> "":
  2775.     numeric _a;
  2776.     pair _z, _zz, _r;
  2777.     _z := point .5 length (arc) of arc;
  2778.     _r := direction .5 length (arc) of arc rotated - 90;
  2779.     if side = "left":
  2780.       _a := angle (-_r);
  2781.     elseif side = "right":
  2782.       _a := angle (_r);
  2783.     else:
  2784. %    \end{macrocode}
  2785. % Normalize to avoid overflow in |dotprod|:
  2786. %    \begin{macrocode}
  2787.       _zz = _z - .5[point 0 of arc, point infinity of arc];
  2788.       if ((_zz/length (_zz)) dotprod _r) >= 0:
  2789.         _a := angle (_r);
  2790.       else:
  2791.         _a := angle (-_r);
  2792.       fi
  2793.     fi
  2794.     LaTeX_text (_z + d * thick * dir _a, _a, lbl);
  2795. enddef;
  2796. %    \end{macrocode}
  2797. %    \begin{macrocode}
  2798. vardef vdraw_vertex_label (expr z, lbl, a, d) =
  2799.   if lbl <> "":
  2800.     numeric _a;
  2801.     if unknown a:
  2802.       _a := angle (z - .5(w,h));
  2803.     else:
  2804.       _a := a;
  2805.     fi
  2806.     LaTeX_text (z + d * thick * dir _a, _a, lbl);
  2807. enddef;
  2808. %    \end{macrocode}
  2809. %    \begin{macrocode}
  2810. vardef vdraw_vertex_blob (expr z, blob) =
  2811.   if blob > 0:
  2812.     draw_blob (z, blob);
  2813. enddef;
  2814. %    \end{macrocode}
  2815. %    \begin{macrocode}
  2816. vardef vdraw_vertex_dot (expr z, dot) =
  2817.   if dot > 0:
  2818.     drawdot z;
  2819. enddef;
  2820. %    \end{macrocode}
  2821. % Unfortunately, enclosing the |message| in a |batchmode|
  2822. % |errorstopmode| pair doesn't work.  The label information isn't
  2823. % written to the terminal, but an empty line is anyway \ldots
  2824. % \changes{1.4}{1994/05/28}{%
  2825. %   \MP: \texttt{write} the label files directly.}
  2826. %    \begin{macrocode}
  2827. vardef LaTeX expr text =
  2828. %<*!mp>
  2829.   message (":" & jobname & "." & decimal charcode & ":" & text & "%%%")
  2830. %</!mp>
  2831. %<*mp>
  2832.   if LaTeX_file = "":
  2833.     LaTeX_file := jobname & ".t" & decimal charcode;
  2834.     write ("% " & LaTeX_file & " -- generated from " & jobname & ".mp")
  2835.       to LaTeX_file;
  2836.   write (text & "%%%") to LaTeX_file
  2837. %</mp>
  2838. enddef;
  2839. vardef LaTeX_text (expr z, a, txt) =
  2840.   LaTeX "\fmfL(" & (decimal (xpart z/LaTeX_unitlength)) & ","
  2841.       & (decimal (ypart z/LaTeX_unitlength)) & ","
  2842.       & (voctant a) & "){" & txt & "}";
  2843. enddef;
  2844. %</base>
  2845. %    \end{macrocode}
  2846. % \begin{macro}{\fmfL}
  2847. % This is an internal macro for squeezing more text into \MF's
  2848. % 80 character wide output.
  2849. %    \begin{macrocode}
  2850. %<style>\def\fmfL(#1,#2,#3)#4{\put(#1,#2){\makebox(0,0)[#3]{#4}}}
  2851. %    \end{macrocode}
  2852. % \end{macro}
  2853. % This will only be used with $\vert|a|\vert\le180$:
  2854. %    \begin{macrocode}
  2855. %<*base>
  2856. vardef voctant expr a =
  2857.   voctant_list[floor (a/45 + .5)]
  2858. enddef;
  2859. string voctant_list[];
  2860. voctant_list[-4] := "r";
  2861. voctant_list[-3] := "rt";
  2862. voctant_list[-2] := "t";
  2863. voctant_list[-1] := "lt";
  2864. voctant_list[0] := "l";
  2865. voctant_list[1] := "lb";
  2866. voctant_list[2] := "b";
  2867. voctant_list[3] := "rb";
  2868. voctant_list[4] := "r";
  2869. %    \end{macrocode}
  2870. %    \begin{macrocode}
  2871. vardef vdump =
  2872.   message ">>>>> Vertices and arcs for diagram #" & decimal charcode
  2873.         & " of " & jobname & ".mf:";
  2874.   for i = vertices:
  2875.     message "> " & vlist[i]name & "=" & decimal_pair (vlist[i]loc)
  2876.           & ": #lines="
  2877.           & decimal (vlist[i]arc.last - vlist[i]arc.first + 1)
  2878.           if vlist[i]blob <> 0:
  2879.             & ", blob=" & decimal_ (vlist[i]blob)
  2880.           fi
  2881.           if vlist[i]dot <> 0:
  2882.             & ", dot=" & decimal_ (vlist[i]dot)
  2883.           fi
  2884.           if vlist[i]lbl <> "":
  2885.             & ", lbl=" & vlist[i]lbl
  2886.             & ", angle=" & decimal_ (vlist[i]lbl.ang)
  2887.             & ", dist=" & decimal_ (vlist[i]lbl.dist)
  2888.           fi
  2889.           & ".";
  2890.   endfor
  2891.   for i = vertices:
  2892.     for j = varcs (i):
  2893.       if vlist[i]arc[j]sty <> "":
  2894.         message "> " & vlist[i]name & "*" & vlist[vlist[i]arc[j]]name
  2895.                 & ": " & vlist[i]arc[j]sty
  2896.                 & ", tns=" & decimal_ (vlist[i]arc[j]tns)
  2897.                 & ", lsr=" & vlist[i]arc[j]lsr
  2898.                 if vlist[i]arc[j]lbl <> "":
  2899.                   & ", lbl=" & vlist[i]arc[j]lbl
  2900.                   & ", side=" & vlist[i]arc[j]lbl.side
  2901.                   & ", dist=" & decimal_ (vlist[i]arc[j]lbl.dist)
  2902.                 fi
  2903.                 & ".";
  2904.       fi
  2905.     endfor
  2906.   endfor
  2907. enddef;
  2908. %    \end{macrocode}
  2909. %    \begin{macrocode}
  2910. vardef decimal_ (text n) =
  2911.   if known n: decimal n else: "?" fi
  2912. enddef;
  2913. %    \end{macrocode}
  2914. %    \begin{macrocode}
  2915. vardef decimal_pair (text z) =
  2916.   "(" & decimal_ (xpart z) & "," & decimal_ (ypart z) & ")"
  2917. enddef;
  2918. %    \end{macrocode}
  2919. % Now we're done with the \MF{} macros
  2920. %    \begin{macrocode}
  2921. endinput;
  2922. %</base>
  2923. %    \end{macrocode}
  2924. % and the \TeX{} macros too:
  2925. %    \begin{macrocode}
  2926. %<*style>
  2927. \mdqrestore
  2928. %</style>
  2929. %    \end{macrocode}
  2930. % \Finale
  2931. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2932. % \begin{thebibliography}{99}
  2933. %   \bibitem{TeX} Donald E.~Knuth, \textit{The \TeX{}book},
  2934. %      Addison-Wesley, Reading, 1986.
  2935. %   \bibitem{LaTeX} Leslie Lambort, \textit{\LaTeX{} --- A
  2936. %     Documentation Preparation System},
  2937. %     Addison-Wesley, Reading, 1985.
  2938. %   \bibitem{LaTeX-Companion} Michel Goosens, Frank Mittelbach, and
  2939. %     Alexander Samarin, \textit{The \LaTeX{} Companion},
  2940. %     Addison-Wesley, Reading, 1994.
  2941. %   \bibitem{MF} Donald E.~Knuth, \textit{The \MF{}book},
  2942. %      Addison-Wesley, Reading, 1986.
  2943. %   \bibitem{MetaPost} John D.~Hobby, \textit{A User's Manual for
  2944. %     \MP}, Computer Science Report \#162, AT\&T Bell
  2945. %     Laboratories, April 1992.
  2946. %   \bibitem{hoenig} Alan Hoenig, \textit{When \TeX{} and \MF{}
  2947. %     Work Together}, in \textit{Proceedings of the 7th European
  2948. %     \TeX{} Conference, Prague}, p.~1, September 1992.
  2949. %   \bibitem{levine} Micheal J.~S.~Levine,
  2950. %     Comp.~Phys.~Comm.~\textbf{58} (1990) 181.
  2951. %   \bibitem{axodraw} Jos Vermaseren, \texttt{axodraw}.
  2952. %   \bibitem{mfpic} Thomas E.~Leathrum, \texttt{mfpic}.
  2953. %   \bibitem{madgraph} Tim Stelzer and Bill Long, \texttt{MADGRAPH},
  2954. %     hep-ph/93mmxxx.
  2955. % \end{thebibliography}
  2956. % \PrintIndex
  2957. % \PrintChanges
  2958. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2959. % \appendix
  2960. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2961. % \section{Driver file}
  2962. %    \begin{macrocode}
  2963. %<*driver>
  2964. \documentclass{article}
  2965. \usepackage{doc}
  2966. %    \end{macrocode}
  2967. % The \MF{} and \MP{} logos come out much nicer if you have |mflogo|
  2968. % installed:
  2969. %    \begin{macrocode}
  2970. \IfFileExists{mflogo.sty}%
  2971.   {\usepackage{mflogo}%
  2972.    \def\FMF{\texttt{feyn}\textlogo{MF}}}%
  2973.   {\def\MF{\textsf{META}\-\textsf{FONT}}%
  2974.    \def\MP{\textsf{META}\-\textsf{POST}}%
  2975.    \def\FMF{\texttt{feyn}\textsf{MF}}}
  2976. %    \end{macrocode}
  2977. % Here is the place to declare your own PostScript aware |dvi| driver
  2978. % option:
  2979. %    \begin{macrocode}
  2980. %<mp>\usepackage[dvips]{feynmp}
  2981. %<!mp>\usepackage{feynmf}
  2982. \font\manfnt=manfnt
  2983. \def\dangerousbend/{{\manfnt\char"7F}}
  2984. \def\dubious{\begin{itemize}\item[\dangerousbend/]}
  2985. \def\enddubious{\end{itemize}}
  2986. \parindent0pt
  2987. \EnableCrossrefs
  2988. \RecordChanges
  2989. \CodelineIndex
  2990. \DoNotIndex{\def,\gdef,\long,\let,\begin,\end,\if,\ifx,\else,\fi}
  2991. \DoNotIndex{\immediate,\write,\newwrite,\openout,\closeout,\typeout}
  2992. \DoNotIndex{\font,\nullfont,\jobname,\documentclass}
  2993. \DoNotIndex{\batchmode,\errorstopmode,\char,\catcode,\ }
  2994. \DoNotIndex{\CodelineIndex,\docdate,\DocInput,\DoNotIndex,\EnableCrossrefs}
  2995. \DoNotIndex{\filedate,\filename,\fileversion,\logo,\manfnt}
  2996. \DoNotIndex{\NeedsTeXFormat,\ProvidesPackage,\RecordChanges,\space}
  2997. \DoNotIndex{\usepackage,\wlog,\@gobble,\@ifundefined,\@namedef,\@spaces}
  2998. \DoNotIndex{\begingroup,\csname,\edef,\endcsname,\expandafter,\hbox}
  2999. \DoNotIndex{\hskip,\ifeof,\ignorespaces,\item,\leavevmode,\loop,\makebox}
  3000. \DoNotIndex{\newcounter,\newif,\newread,\openin,\par,\parindent,\put}
  3001. \DoNotIndex{\read,\relax,\repeat,\setcounter,\stepcounter,\the}
  3002. \DoNotIndex{\value,\vbox,\vskip}
  3003. \DoNotIndex{}
  3004. \begin{document}
  3005.   \DocInput{feynmf.dtx}
  3006. \end{document}
  3007. %</driver>
  3008. %    \end{macrocode}
  3009. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3010. % \section{Copying}
  3011. % \label{sec:GPL}
  3012. % \FMF{} is free software; you can redistribute it and/or modify it
  3013. % under the terms of the GNU General Public License as published by 
  3014. % the Free Software Foundation; either version 2, or (at your option)
  3015. % any later version.
  3016. % \FMF{} is distributed in the hope that it will be useful, but
  3017. % \emph{without any warranty}; without even the implied warranty of
  3018. % \emph{merchantability} or \emph{fitness for a particular purpose}.
  3019. % See the GNU General Public License for more details.
  3020. % You should have received a copy of the GNU General Public License
  3021. % along with this program; if not, write to the Free Software
  3022. % Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  3023. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3024. \endinput
  3025. Local Variables:
  3026. mode:LaTeX
  3027. change-log-default-name:"TODO"
  3028. fill-prefix:"% "
  3029. page-delimiter:"^% %%%%%%%%%*\n"
  3030.