Debian Codegraph @

texmf-dist/doc/latex/tikz-feynman/tikz-feynman.tex

raw
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 %
3 % TikZ-Feynman
4 % Feynman Diagrams with TikZ
5 % Copyright (C) 2015 Joshua Ellis
6 %
7 %
8 % This LaTeX file is free: you can redistribute it and/or modify it under the
9 % terms of the GNU General Public License as published by the Free Software
10 % Foundation, either version 3 of the License, or (at your option) any later
11 % version.
12 %
13 % This is distributed in the hope that it will be useful, but WITHOUT ANY
14 % WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
15 % A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 %
17 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
18
19 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
20 %% HEADER
21 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22
23 \def\pgfautoxrefs{1}
24 \documentclass[a4paper,final]{ltxdoc}
25
26 \usepackage{etex}
27
28 %% Formatting
29 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
30
31 \usepackage[vmargin=4cm, hmargin=3cm]{geometry} % Customize text width, page height, margins, etc.
32 % \usepackage{multicol} % {multicols}{n} environment
33 % \usepackage{pdflscape} % {landscape} environment
34
35 %\usepackage{setspace} % Line spacing
36 %\singlespacing % 1-spacing (default)
37 %\onehalfspacing % 1,5-spacing
38 %\doublespacing % 2-spacing
39
40 \usepackage{fontspec} % Allows other fonts to be specified
41 \setmainfont{EB Garamond}[
42 Contextuals={Alternate},
43 Numbers=OldStyle,
44 ]
45 \setmonofont{Inconsolata-g}[
46 Scale=MatchLowercase,
47 ]
48 \newfontface\swshape{EB Garamond 12 Italic}[Style=Swash]
49
50 \usepackage{microtype} % Fine small typographical details
51 \usepackage{titlesec} % Change section heading font
52 \titleformat*{\section}{\huge\scshape}
53 \titleformat*{\subsection}{\Large\scshape}
54 \titleformat*{\subsubsection}{\large\scshape}
55 \titleformat*{\paragraph}{\scshape}
56
57 \usepackage[perpage]{footmisc}
58 \usepackage{enumitem} % Easily customize lists
59 \setlist[description]{font=\normalfont\scshape}
60
61 %% Change the Table of Contents fonts
62 \usepackage{tocloft}
63 \renewcommand{\cftsecfont}{\normalfont\scshape}
64 \setlength\cftbeforesecskip{0pt}
65 \setcounter{tocdepth}{2}
66
67 %% Language
68 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
69
70 \usepackage[UKenglish]{babel} % Set up the language
71 \usepackage{csquotes}
72 \usepackage{siunitx} % Provides \SI{1}{\metre}, also \ang{90}.
73 \usepackage{textcomp}
74
75 %% Graphics & Figure
76 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
77
78 \usepackage{graphicx} % Allow graphics to be included
79 \usepackage{xcolor} % Define and use colours
80 % \usepackage{subcaption} % Subfigures inside a figure
81
82 % Keep all pictures in the './img/' sub-directory.
83 \graphicspath{{./img/}}
84
85 \usepackage{tikz} % Powerful drawing language
86 \usepackage{tikz-feynman}
87 \makeatletter
88 \tikzfeynmanset{compat=\tikzfeynman@version@major.\tikzfeynman@version@minor.\tikzfeynman@version@patch}
89 \makeatother
90
91 %% TikZ pictures and plots can significantly increase the time it takes to
92 %% produce the output. The `external` TikZ library library defers the creation
93 %% of these figures to a sub-process which creates a separate PDF file which is
94 %% then simply imported into the main document. To call the sub-process, you
95 %% have to execute the appropriate makefile. If you are using LatexMk, you can
96 %% use the `.latexmkrc` to automatically do this for you.
97 %%
98 %% The following setup works on Linux, and should work on OS X too.
99 % \usetikzlibrary{external}
100 % \tikzexternalize[shell escape=-shell-escape, prefix=pgf-img/]
101 % \immediate\write18{mkdir -p pgf-img}
102 % \tikzset{
103 % external/mode=list and make,
104 % external/system call={
105 % lualatex \tikzexternalcheckshellescape -halt-on-error -interaction=batchmode -jobname="\image" "\texsource" || rm "\image.pdf"},
106 % }
107
108 %% Math Packages
109 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
110
111 \usepackage{amsmath} % The core math package
112 \usepackage{amssymb} % Defines additional math fonts
113 \usepackage{mathtools} % Various extra maths functions
114 % \usepackage{cancel} % Show cancellations with \cancel{}
115 % \usepackage{autonum} % Only number referenced equations (must be loaded after cleverref)
116 \usepackage{dsfont}
117
118 \usepackage[cmintegrals,varg]{newtxmath} % Nice math with Garamond
119
120 %% Define \withnumber which forces the line to have number
121 \newcommand{\withnumber}{\refstepcounter{equation}\tag{\theequation}}
122
123 %% Allows page breaks in math (1 = avoid if possible, 4 = whenever)
124 %% Page breaks can be avoided at particular places by using \\*
125 \allowdisplaybreaks[2]
126
127 \DeclarePairedDelimiter{\angles}{\langle}{\rangle}
128
129 %% Tables
130 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
131
132 \usepackage{array} % New column types, including >{}x<{}
133 \usepackage{booktabs} % Provides nicer horizontal lines
134 \usepackage{multirow} % Allows cells to span multiple rows
135 %\usepackage{longtable} % Allows for tables to span multiple pages
136
137 %% Define the maths version of clr columns.
138 \newcolumntype{C}{>{\(}c<{\)}}
139 \newcolumntype{L}{>{\(}l<{\)}}
140 \newcolumntype{R}{>{\(}r<{\)}}
141
142 %% Other Packages
143 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
144
145 \usepackage{listings} % Code listings
146 \usepackage{minted} % Use Pygments
147 \usepackage{fp} % Floating point arithmetics
148 \usepackage{makeidx} % Index creation
149 \usepackage{xr} % Cross-referencing
150 \usepackage[orig,UKenglish]{isodate} % Handle dates
151
152 \usepackage{hyperref} % Automatically inserts hyperlinks.
153 \usepackage{cleveref} % Use `\cref{}` to reference anything
154
155 \usepackage{autonum}
156
157 %% Bibliography
158 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
159
160 %% hyperref should be loaded first
161 \usepackage[
162 backend=biber,
163 style=phys,
164 autocite=inline,
165 biblabel=brackets,
166 eprint=true,
167 doi=true,
168 isbn=true,
169 ]{biblatex}
170
171 \addbibresource{references.bib}
172
173 %% Other modifications
174 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
175
176 % Modify the skip after each paragraph
177 \setlength{\parskip}{1ex plus 0.5ex minus 0.2ex}
178 \setlength{\parindent}{0pt}
179
180 \providecommand{\LuaTeX}{Lua\TeX}
181 \providecommand{\tikzfeynmanname}{\tikzname-Feynman}
182 \providecommand{\pgfmanual}{\href{http://mirrors.ctan.org/graphics/pgf/base/doc/pgfmanual.pdf}{\tikzname{} manual}}
183
184 \IfFileExists{pgfmanual-en-macros}{
185 \let\attribute\relax
186 \input{pgfmanual-en-macros}
187 }{
188 \PackageError{tikz-feynman-manual}{
189 This document requires the file pgfmanual-en-macros.tex (distributed
190 with pgf) to compile. Please place a copy of that file in the current
191 directory}{}}
192
193 \makeindex
194
195 \pgfkeys{
196 /pdflinks/search key prefixes in={/tikzfeynman/}
197 /pdflinks/internal link prefix=tikzfeynman,
198 %
199 /pdflinks/warnings=false,
200 % for debugging:
201 /pdflinks/show labels=false,
202 }
203
204 \makeatletter
205 %% Make table of content heading smaller
206 \renewcommand\tableofcontents{%
207 \section*{\normalfont\large\scshape\contentsname}%
208 \vspace{-1.5\baselineskip}%
209 \@starttoc{toc}%
210 }
211 \makeatother
212
213 %% Define some slightly nicer colors
214 \definecolor{link-color}{RGB}{96 0 0}
215 \definecolor{cite-color}{RGB}{0 96 0}
216 \definecolor{file-color}{RGB}{0 0 96}
217 \definecolor{url-color}{RGB}{0 0 96}
218 \definecolor{link-border-color}{RGB}{255 159 159}
219 \definecolor{cite-border-color}{RGB}{159 255 159}
220 \definecolor{file-border-color}{RGB}{159 159 255}
221 \definecolor{url-border-color}{RGB}{159 159 255}
222
223 \hypersetup{
224 pdfborder=0 0 0,
225 }
226
227 %% Change the abstract style
228 \renewenvironment{abstract}{
229 \begin{center}
230 \begin{minipage}{0.9\textwidth}
231 \begin{center}
232 \Large
233 Abstract
234 \end{center}\vspace*{-1em}
235 \rule{\textwidth}{1pt}
236 }{
237 \par\noindent
238 \rule{\textwidth}{1pt}
239 \end{minipage}
240 \end{center}
241 }
242
243 %% Put the abstract only on the arXiv version
244 \newif\ifarxiv
245 \arxivfalse
246
247 %% Acknowledgements go in two different places depending on whether it is the
248 %% arXiv version or not. Have the common code here.
249 \def\acknowledgements{
250 \subsection*{Acknowledgements}
251 \label{subsec:acknowledgements}
252
253 The original proof-of-concept for using \tikzname{} to draw Feynman diagrams
254 was done by the user `\href{http://tex.stackexchange.com/users/2552}{Jake}' on
255 the \TeX{} StackExchange. His original answer can be viewed at:
256 \url{http://tex.stackexchange.com/a/87395/26980}.
257
258 I must also thank all the people who have used the development versions of
259 \tikzfeynmanname{} and offered suggestions to improve it and found bugs for me
260 to fix.
261 }
262
263 %% Center codeexample
264 \makeatletter
265 \let\codeexample@orig=\codeexample
266 \let\endcodeexample@orig=\endcodeexample
267 \def\codeexample{
268 \begin{center}
269 \codeexample@orig
270 }
271 \def\endcodeexample{
272 \endcodeexample@orig
273 \end{center}
274 }
275
276 %% Document Information
277 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
278
279 \makeatletter
280 \newcommand{\@keywords}{}
281 \newcommand{\keywords}[1]{\renewcommand{\@keywords}{#1}}
282 \newcommand{\@institution}{}
283 \newcommand{\institution}[1]{\renewcommand{\@institution}{#1}}
284
285 \AtBeginDocument{
286 \hypersetup{
287 pdftitle={\@title},
288 pdfauthor={\@author},
289 pdfkeywords={\@keywords},
290 }
291 }
292 \makeatother
293
294 \title{\tikzfeynmanname}
295 \author{Joshua \textsc{Ellis}}
296 \institution{
297 ARC Centre of Excellence for Particle Physics at the Terascale \\
298 School of Physics, The University of Melbourne \textsc{vic} 3010, Australia
299 }
300 \keywords{Feynman diagram, TeX, LaTeX, TikZ, pgf, TikZ-Feynman}
301
302 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
303 %% DOCUMENT
304 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
305 \begin{document}
306 \pagenumbering{roman}
307
308 \begin{titlepage}
309 \makeatletter
310 \begin{center}
311 \vspace*{1em}
312 \tikz\node[scale=1.5]{%
313 \color{gray}\Huge\ttfamily \char`\{\textcolor{red!75!black}{\@title}\char`\}};
314
315
316 \vspace{0.5em}
317 {\huge Feynman diagrams with \tikzname}
318
319 \vspace{0.7em}
320 {Version \texttt{\tikzfeynman@version} \qquad \origdate\printdateTeX{\tikzfeynman@date}}
321
322 \vspace{1.3em}
323 {by \@author} \\[1em]
324 {\@institution}
325 \end{center}
326 \makeatother
327
328 \vfill
329
330 \begin{codeexample}[graphic=white]
331 \feynmandiagram [large, vertical=e to f] {
332 a -- [fermion] b -- [photon, momentum=\(k\)] c -- [fermion] d,
333 b -- [fermion, momentum'=\(p_{1}\)] e -- [fermion, momentum'=\(p_{2}\)] c,
334 e -- [gluon] f,
335 h -- [fermion] f -- [fermion] i;
336 };
337 \end{codeexample}
338
339 \vfill
340
341 \begin{multicols}{2}
342 \tableofcontents
343 \end{multicols}
344 \end{titlepage}
345
346 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
347 %% CONTENT
348 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
349 \clearpage
350 \pagenumbering{arabic}
351
352 \ifarxiv
353 \begin{abstract}
354 \tikzfeynmanname{} is a \LaTeX{} package allowing Feynman diagrams to be
355 easily generated within \LaTeX{} with minimal user instructions and without
356 the need of external programs. It builds upon the \tikzname{} package and
357 leverages the graph placement algorithms from \tikzname{} in order to automate
358 the placement of many vertices. \tikzfeynmanname{} still allows fine-tuned
359 placement of vertices so that even complex diagrams can be generated with
360 ease.
361 \end{abstract}
362 \fi
363
364 \section{Introduction}
365 \label{sec:introduction}
366
367 \tikzfeynmanname{} provides a new way to draw Feynman diagrams in \LaTeX{} that
368 does not rely on external programs and uses a clear extensible syntax.
369
370 \ifarxiv\else
371 If you use \tikzfeynmanname{} in an academic setting, please cite:
372 \begin{quote}
373 \fullcite{tikz-feynman}
374 \end{quote}
375 \fi
376
377 Feynman diagrams provide a description of interactions of subatomic particles in
378 a form that is clearer and more succinct than the corresponding mathematical
379 description. They were introduced by \citeauthor{PhysRev.76.769} and first
380 appear in his paper \citetitle{PhysRev.76.769} \cite{PhysRev.76.769}. Since
381 then, \LaTeX{} has become widely used to type-set scientific papers and
382 currently, two leading methods of drawing Feynman diagrams in \LaTeX{} are
383 \href{https://www.ctan.org/pkg/feynmf}{|feynMF|/|feynMP|} \cite{feynmf} and
384 \href{https://www.ctan.org/pkg/axodraw}{|AxoDraw|} \cite{axodraw}, with the
385 latter also featuring a \textsc{gui} front-end called
386 \href{http://jaxodraw.sourceforge.net}{|JaxoDraw|} \cite{jaxodrawV1,jaxodrawV2}.
387
388 Both |feynMF|/|feynMP| and |AxoDraw| have quite complicated syntax. As an
389 example, the code to generate an \(\ell\ell \to \ell\ell\) scattering Feynman
390 diagram in each package is:
391 \begin{center}
392 \begin{tabular}{p{0.3\linewidth} p{0.27\linewidth} p{0.34\linewidth}}
393 |AxoDraw| & |feynMF|/|feynMP| & \tikzfeynmanname{} \\[-2em]
394 \begin{codeexample}[execute code=false]
395 \begin{picture}
396 \ArrowLine(190,270)(160,300)
397 \ArrowLine(160,240)(190,270)
398 \ArrowLine(270,300)(240,270)
399 \ArrowLine(240,270)(270,240)
400 \Photon(190,270)(240,270){4}{4.5}
401 \Vertex(190,270){1.5}
402 \Vertex(240,270){1.5}
403 \end{picture}
404 \end{codeexample}
405 &
406 \begin{codeexample}[execute code=false]
407 \begin{fmfchar*}(40,30)
408 \fmfpen{thick}
409 \fmfleft{i1,i2}
410 \fmfright{o1,o2}
411 \fmf{fermion}{i1,v1,o1}
412 \fmf{fermion}{i2,v2,o2}
413 \fmf{photon,label=$q$}{v1,v2}
414 \fmfdot{v1,v2}
415 \end{fmfchar*}
416 \end{codeexample}
417 &
418 \begin{codeexample}[execute code=false]
419 \feynmandiagram [horizontal=a to b] {
420 i1 -- [fermion] a -- [fermion] i2,
421 a -- [photon] b,
422 f1 -- [fermion] b -- [fermion] f2,
423 };
424 \end{codeexample} \\[-2em]
425 \end{tabular}
426 \end{center}
427 The learning curves for both |AxoDraw| and |feynMF|/|feynMP| are quite steep,
428 and although this is partly resolved by using |JaxoDraw|, this requires an
429 external program. In addition, the creation of Feynman diagrams in
430 |feynMF|/|feynMP| requires further processing outside of \LaTeX{}.
431
432 \tikzfeynmanname{} on the other hand uses a clear syntax and delegates the
433 positioning of vertices to algorithms originally developed by
434 \citeauthor{hu2005} \cite{hu2005}, and \citeauthor{eades1991} \cite{eades1991},
435 both of which were implemented into \tikzname{} by \citeauthor{pohlmann2011}
436 \cite{pohlmann2011}. Since \tikzfeynmanname{} is built on \tikzname{}, users
437 can harness the power and extensibilty of \tikzname{} \cite{tikz} making it easy
438 to extend to accommodate individual needs. In order to produce more complicated
439 diagrams, relative or absolute positioning of vertices can also be used in
440 \tikzfeynmanname{} so that any diagram can be generated with relative ease.
441
442 \tikzfeynmanname{} is made available through the
443 \href{https://ctan.org/pkg/tikz-feynman}{Comprehensive \TeX{} Archive Network
444 (\textsc{ctan})}\footnote{\url{https://ctan.org/pkg/tikz-feynman}} and can
445 also be downloaded from the
446 \href{http://www.jpellis.me/projects/tikz-feynman}{project
447 page}\footnote{\url{http://www.jpellis.me/projects/tikz-feynman}}. The
448 project is open source and contributions are welcome. The management of bugs
449 and feature requests is done at
450 \href{https://github.com/JP-Ellis/tikz-feynman}{Github}\footnote{\url{https://github.com/JP-Ellis/tikz-feynman}}.
451
452 \tikzfeynmanname{}'s versioning will approximately follow
453 \href{http://semverg.org}{semantic versioning}. This means that changes in the
454 third number (|1.0.0| to |1.0.1|) will consist of bug fixes and very minor
455 changes but they should not change the output otherwise\footnote{That is, with
456 the exception of the bug that they are fixing.}. Changes in the second number
457 (|1.0.0| to |1.1.0|) will consist of new features but everything should be
458 backwards compatible. Finally, changes in the first number (|1.0.0| to |2.0.0|)
459 indicates a major change in the package and code written for |1.0.0| is not
460 guaranteed to work on |2.0.0|. The intended version of this package to use
461 should be indicated when the package is loaded with
462 |\usepackage[compat=x.y.z]{tikz-feynman}| so the user may be informed of any
463 discrepancyx. If needed, earlier versions may be downloaded from the
464 \href{http://www.jpellis.me/projects/tikz-feynman}{project
465 page}\footnote{\url{http://www.jpellis.me/projects/tikz-feynman}}.
466
467 \subsection*{Licence}
468 \label{subsec:licence}
469
470 This \emph{documentation} may be redistributed and/or modified under the terms
471 of the \textsc{gnu} General Public License as published by the Free Software
472 Foundation, either version 3 of the License, or (at your option) any later
473 version.
474
475 The \emph{code of this package} may be distributed and/or modified under the
476 conditions of the \LaTeX{} Project Public License, either version 1.3 of this
477 license or (at your option) any later version.
478
479 This work has the LPPL maintenance status `maintained'.
480
481 The Current Maintainer of this work is Joshua Ellis.
482
483 This package is distributed in the hope that it will be useful, but
484 \textsc{without any warranty}; without even the implied warranty of
485 \textsc{merchantability} or \textsc{fitness for a particular purpose}.
486
487 \ifarxiv\else
488 \acknowledgements
489 \fi
490
491
492 \clearpage
493 \section{Tutorial}
494 \label{sec:tutorial}
495
496 \subsection{Loading the Package}
497 \label{sibsec:loading_the_package}
498
499 After installing the package, the \tikzfeynmanname{} package can be loaded with
500 |\usepackage{tikz-feynman}| in the preamble. It is recommend that you also
501 specify the version of \tikzfeynmanname{} to use with the optional package
502 argument |compat|: |\usepackage[compat=1.1.0]{tikz-feynman}|. This ensures that
503 any new versions of \tikzfeynmanname{} do not produce any undesirable changes
504 without warning.
505
506 \subsection{A First Diagram}
507 \label{subsec:a_first_diagram}
508
509 Feynman diagrams can be declared with the |\feynmandiagram| command. It is
510 analogous to the |\tikz| command from \tikzname~and requires a final semi-colon
511 (|;|) to finish the environment. For example, a simple \(s\)-channel diagram
512 is:
513
514 \begin{codeexample}[]
515 \feynmandiagram [horizontal=a to b] {
516 i1 -- [fermion] a -- [fermion] i2,
517 a -- [photon] b,
518 f1 -- [fermion] b -- [fermion] f2,
519 };
520 \end{codeexample}
521
522 Let's go through this example line by line:
523 \begin{description}
524 \item[Line 1] |\feynmandiagram| introduces the Feynman diagram and allows for
525 optional arguments to be given in the brackets \texttt{[\meta{options}]}. In
526 this instance, |horizontal=a to b| orients the algorithm outputs such that the
527 line through vertices |a| and |b| is horizontal.
528 \item[Line 2] The left fermion line is drawn by declaring three vertices (|i1|,
529 |a| and |i2|) and connecting them with edges |--|. Just like the
530 |\feynmandiagram| command above, each edge also take optional arguments
531 specified in brackets \texttt{[\meta{options}]}. In this instance, we want
532 these edges to have arrows to indicate that they are fermion lines, so we add
533 the |fermion| style to them.
534
535 As you will see later on, optional arguments can also be given to the vertices
536 in exactly the same way.
537 \item[Line 3] This edge connects vertices |a| and |b| with an edge styled as a
538 photon. Since there is already a vertex labelled |a|, the algorithm will
539 connect it to a new vertex labeled |b|.
540 \item[Line 4] This line is analogous to line 2 and introduces two new vertices,
541 |f1| and |f2|. It re-uses the previously labelled |b| vertex.
542 \item[Line 5] Finish the declaration of the Feynman diagram. The final
543 semi-colon (|;|) is important.
544 \end{description}
545
546 The name given to each vertex in the graph does not matter. So in this example,
547 |i1|, |i2| denote the initial particles; |f1|, |f2| denotes the final particles;
548 and |a|, |b| are the end points of the propagator. The only important aspect is
549 that what we called |a| in line 2 is also |a| in line 3 so that the underlying
550 algorithm treats them as the same vertex.
551
552 The order in which vertices are declared does not matter as the default
553 algorithm re-arranges everything\footnote{It is possible for the algorithm to
554 get a litte confused in some circumstances, but these cases should be rather
555 rare. For some algorithms (such as the |layered~layout|), the order in which
556 vertices are introduces \emph{does} matter. This is documented in
557 \cref{subsubsec:diagram_keys}.}. For example, one might prefer to draw the
558 fermion lines all at once, as with the following example (note also that the way
559 we named vertices is completely different):
560
561 \begin{codeexample}[]
562 \feynmandiagram [horizontal=f2 to f3] {
563 f1 -- [fermion] f2 -- [fermion] f3 -- [fermion] f4,
564 f2 -- [photon] p1,
565 f3 -- [photon] p2,
566 };
567 \end{codeexample}
568
569 As a final remark, the calculation of where vertices should be placed is usually
570 done through an algorithm written in Lua. As a result, \LuaTeX{} is required in
571 order to make use of these algorithms. If \LuaTeX{} is not used,
572 \tikzfeynmanname{} will default to a more rudimentary algorithm and will warn
573 the user instead.
574
575 \subsection{Adding Styles}
576 \label{subsec:adding_styles}
577
578 So far, the examples have only used the |photon| and |fermion| styles. The
579 \tikzfeynmanname{} package comes with quite a few extra styles for edges and
580 vertices which are all documented over in \cref{sec:documentation}. As an
581 example, it is possible to add momentum arrows with |momentum=|\meta{text}, and
582 in the case of end vertices, the particle can be labelled with
583 |particle=|\meta{text}. As an example, we take the generic \(s\)-channel
584 diagram from \cref{subsec:a_first_diagram} and make it a \(e^{+}e^{-} \to
585 \mu^{+}\mu^{-}\) diagram:
586 \begin{codeexample}[]
587 \feynmandiagram [horizontal=a to b] {
588 i1 [particle=\(e^{-}\)] -- [fermion] a -- [fermion] i2 [particle=\(e^{+}\)],
589 a -- [photon, edge label=\(\gamma\), momentum'=\(k\)] b,
590 f1 [particle=\(\mu^{+}\)] -- [fermion] b -- [fermion] f2 [particle=\(\mu^{-}\)],
591 };
592 \end{codeexample}
593 In addition to the style keys documented below, style keys from \tikzname{} can
594 be used as well:
595 \begin{codeexample}[]
596 \feynmandiagram [horizontal=a to b] {
597 i1 [particle=\(e^{-}\)] -- [fermion, very thick] a -- [fermion, opacity=0.2] i2 [particle=\(e^{+}\)],
598 a -- [red, photon, edge label=\(\gamma\), momentum'={[arrow style=red]\(k\)}] b,
599 f1 [particle=\(\mu^{+}\)] -- [fermion, opacity=0.2] b -- [fermion, very thick] f2 [particle=\(\mu^{-}\)],
600 };
601 \end{codeexample}
602 For a list of all the various styles that \tikzname{} provides, have a look at
603 the \pgfmanual; it is extremely thorough and provides many usage examples.
604
605 \tikzfeynmanname{} also supports combining styles together which can be useful
606 in certain new models such as supersymmetry:
607 \begin{codeexample}[]
608 \feynmandiagram [horizontal=a to b] {
609 i1 [particle=\(\tilde W\)] -- [plain, boson] a -- [anti fermion] i2 [particle=\(q\)],
610 a -- [charged scalar, edge label=\(\tilde q\)] b,
611 f1 [particle=\(\tilde g\)] -- [plain, gluon] b -- [fermion] [particle=\(q\)],
612 };
613 \end{codeexample}
614
615 \subsection{When the Algorithm Isn't Enough}
616 \label{subsec:when_the_algorithm_isnt_enough}
617
618 By default, the |\feynmandiagram| and |\diagram| commands use the
619 |spring layout| algorithm to place all the edges\footnote{For more details on
620 this layout and any other graph layouts available, see
621 \cref{subsubsec:diagram_keys}}. The |spring layout| algorithm attempts to
622 `spread out' the diagram as much as possible which---for most simpler
623 diagrams---gives a satisfactory result; however in some cases, this does not
624 produce the best diagram and this section will look at alternatives. There are
625 three main alternatives:
626 \begin{description}
627 \item[Add invisible edges] While still using the default algorithm, it is
628 possible to force certain vertices to be closer together by adding extra edges
629 and making them invisible through |draw=none|. The algorithm will treat these
630 extra edges in the same way, but they are simply not drawn at the end;
631
632 \item[Use a different algorithm] In some circumstances, other algorithms may be
633 better suited. Some of the other graph layout algorithms are listed in
634 \cref{subsubsec:diagram_keys}, and an exhaustive list of all algorithms and
635 their parameters is given in the \pgfmanual;
636
637 \item[Manual placement] As a last resort, very complicated or unusual diagrams
638 will require each vertex to be manually placed.
639 \end{description}
640
641 \subsubsection{Invisible Edges}
642 \label{subsubsec:invisible_edges}
643
644 The underlying algorithm treats all edges in exactly the same way when
645 calculating where to place all the vertices, and the actual drawing of the
646 diagram (after the placements have been calculated) is done separately.
647 Consequently, it is possible to add edges to the algorithm, but prevent them
648 from being drawn by adding |draw=none| to the edge style.
649
650 This is particularly useful if you want to ensure that the initial or final
651 states remain closer together than they would have otherwise as illustrated in
652 the following example (note that |opacity=0.2| is used instead of |draw=none| to
653 illustrate where exactly the edge is located).
654
655 \begin{codeexample}[]
656 % No invisible to keep the two photons together
657 \feynmandiagram [small, horizontal=a to t1] {
658 a [particle=\(\pi^{0}\)] -- [scalar] t1 -- t2 -- t3 -- t1,
659 t2 -- [photon] p1 [particle=\(\gamma\)],
660 t3 -- [photon] p2 [particle=\(\gamma\)],
661 };
662 \end{codeexample}
663 \begin{codeexample}[]
664 % Invisible edge ensures photons are parallel
665 \feynmandiagram [small, horizontal=a to t1] {
666 a [particle=\(\pi^{0}\)] -- [scalar] t1 -- t2 -- t3 -- t1,
667 t2 -- [photon] p1 [particle=\(\gamma\)],
668 t3 -- [photon] p2 [particle=\(\gamma\)],
669 p1 -- [opacity=0.2] p2,
670 };
671 \end{codeexample}
672
673 \subsubsection{Alternative Algorithms}
674 \label{subsubsec:alternative_algorithms}
675
676 The graph drawing library from \tikzname{} has several different algorithms to
677 position the vertices\footnote{See \cref{subsubsec:diagram_keys} for some
678 alternative algorithms.} By default, |\diagram| and |\feynmandiagram| use the
679 |spring layout| algorithm to place the vertices. The |spring layout| attempts
680 to spread everything out as much as possible which, in most cases, gives a nice
681 diagram; however, there are certain cases where this does not work. A good
682 example where the |spring layout| doesn't work are decays where we have the
683 decaying particle on the left and all the daughter particles on the right.
684 \begin{codeexample}[]
685 % Using the default spring layout
686 \feynmandiagram [horizontal=a to b] {
687 a [particle=\(\mu^{-}\)] -- [fermion] b -- [fermion] f1 [particle=\(\nu_{\mu}\)],
688 b -- [boson, edge label=\(W^{-}\)] c,
689 f2 [particle=\(\overline \nu_{e}\)] -- [fermion] c -- [fermion] f3 [particle=\(e^{-}\)],
690 };
691 \end{codeexample}
692 \begin{codeexample}[]
693 % Using the layered layout
694 \feynmandiagram [layered layout, horizontal=a to b] {
695 a [particle=\(\mu^{-}\)] -- [fermion] b -- [fermion] f1 [particle=\(\nu_{\mu}\)],
696 b -- [boson, edge label'=\(W^{-}\)] c,
697 c -- [anti fermion] f2 [particle=\(\overline \nu_{e}\)],
698 c -- [fermion] f3 [particle=\(e^{-}\)],
699 };
700 \end{codeexample}
701 You may notice that in addition to adding the |layered layout| style to
702 |\feynmandiagram|, we also changed the order in which we specify the vertices.
703 This is because the |layered layout| algorithm does pay attention to the order
704 in which vertices are declared (unlike the default |spring layout|); as a
705 result, |c--f2, c--f3| has a different meaning to |f2--c--f3|. In the former
706 case, |f2| and |f3| are both on the layer below |c| as desired; whilst the
707 latter case places |f2| on the layer above |c| (that, the same layer as where
708 the \(W^{-}\) originates).
709
710 \subsubsection{Manual Placement}
711 \label{subsubsec:manual_placement}
712
713 In more complicated diagrams, it is quite likely that none of the algorithms
714 work, no matter how many invisible edges are added. In such cases, the vertices
715 have to be placed manually. \tikzfeynmanname{} allows for vertices to be
716 manually placed by using the |\vertex| command.
717
718 The |\vertex| command is available only within the |feynman| environment (which
719 itself is only available inside a |tikzpicture|). The |feynman| environment
720 loads all the relevant styles from \tikzfeynmanname{} and declares additional
721 \tikzfeynmanname-specific commands such as |\vertex| and |\diagram|. This is
722 inspired from PGFPlots and its use of the |axis| environment.
723
724 The |\vertex| command is very much analogous to the |\node| command from
725 \tikzname{}, with the notable exception that the vertex contents are optional;
726 that is, you need not have |{|\meta{text}|}| at the end. In the case where |{}|
727 is specified, the vertex automatically is given the |particle| style, and
728 otherwise it is a usual (zero-sized) vertex.
729
730 To specify where the vertices go, it is possible to give explicit coordinates
731 though it is probably easiest to use the |positioning| library from \tikzname{}
732 which allows vertices to be placed relative to existing vertices\footnote{The
733 \pgfmanual{} has some extensive documentation explaining how to use the
734 |positioning| library.}. By using relative placements, it is possible to
735 easily tweak one part of the graph and everything will adjust accordingly---the
736 alternative being to manually adjust the coordinates of every affected vertex.
737
738 Finally, once all the vertices have been specified, the |\diagram*| command is
739 used to specify all the edges. This works in much the same way as |\diagram|
740 (and also |\feynmandiagram|), except that it uses an very basic algorithm
741 to place new nodes and allows existing (named) nodes to be included. In order
742 to refer to an existing node, the node must be given in parentheses.
743
744 This whole process of specifying the nodes and then drawing the edges between
745 them is shown below for the muon decay:
746
747 \begin{codeexample}[]
748 \begin{tikzpicture}
749 \begin{feynman}
750 \vertex (a) {\(\mu^{-}\)};
751 \vertex [right=of a] (b);
752 \vertex [above right=of b] (f1) {\(\nu_{\mu}\)};
753 \vertex [below right=of b] (c);
754 \vertex [above right=of c] (f2) {\(\overline \nu_{e}\)};
755 \vertex [below right=of c] (f3) {\(e^{-}\)};
756
757 \diagram* {
758 (a) -- [fermion] (b) -- [fermion] (f1),
759 (b) -- [boson, edge label'=\(W^{-}\)] (c),
760 (c) -- [anti fermion] (f2),
761 (c) -- [fermion] (f3),
762 };
763 \end{feynman}
764 \end{tikzpicture}
765 \end{codeexample}
766
767 \clearpage
768 \section{Documentation}
769 \label{sec:documentation}
770
771 \subsection{Commands \emph{\&} Environments}
772 \label{subsec:commands}
773
774 \begin{command}{\tikzfeynmanset\marg{options}}
775 This command will process \meta{options} using |\pgfkeys| with the default
776 path set to |/tikzfeynman|. Typically, \meta{options} will be a
777 comma-separated list of the form \meta{key}|=|\meta{value}, though the full
778 power of the mechanism behind |\pgfkeys| can be used (see the \pgfmanual{} for
779 a complete description).
780
781 Typically, this is used in the preamble of the document to add or change
782 certain keys for the whole document.
783 \end{command}
784
785 \begin{command}{\feynmandiagram\opt{\oarg{TikZ options}\oarg{diagram options}}\marg{diagram instructions}}
786 This commands creates a |{tikzpicture}| and |{feynman}| environment, and
787 places a |\diagram| inside with the provided \meta{diagram instruction}.
788 Please refer to the documentation for |\diagram| for the \meta{diagram
789 instruction} syntax.
790
791 The optional arguments specified in \meta{tikz options} are passed on to the
792 |{tikzpicture}|, and the \meta{diagram options} are passed on to |\diagram|.
793 If only one optional argument is given, then the optional arguments are given
794 to both. A single optional argument will usually suffice as most keys are
795 recognized by both commands; however, in the event that a key is not
796 recognized, both options are provided.
797 \end{command}
798
799 \begin{environment}{{feynman}\opt{\oarg{options}}}
800 The |{feynman}| environment is where all the drawing of Feynman diagrams takes
801 place. It makes all the \tikzfeynmanname{} styles available and defines
802 commands such as |\vertex| and |\diagram| which are otherwise unavailable
803 outside of this environment. The |{feynman}| environment is only accessible
804 within the |{tikzpicture}| environment.
805
806 Options which are passed in \meta{options} apply for the whole environment in
807 the same way that the |{scope}| environment work in \tikzname.
808
809 \begin{command}{\vertex\opt{\oarg{options}} (\meta{name}) \opt{at (\meta{coordinate})} \opt{\marg{contents}};}
810 Defines a new vertex with the provided \meta{name}. If \meta{contents} is
811 not provided, the resulting vertex will have zero size. On the other hand,
812 if \meta{contents} is provided, the |particle=|\meta{contents} style is
813 applied. Additional styles can be applied to the vertex through
814 \meta{options}.
815
816 The final semicolon (|;|) is vital for this command since without it, the
817 \LaTeX{} engine will not know when the |\vertex| command ends.
818 Additionally, this command \emph{cannot} be chained like one can do with the
819 inbuilt \tikzname{} commands.
820
821 This command is only available with the |{feynman}| environment.
822 \end{command}
823
824 \begin{command}{\diagram\opt{\oarg{options}}\marg{diagram instructions}}
825 Begins a new diagram using the |spring layout|. Keys passed through
826 \meta{options} can include general \tikzname{} keys, graph-specific keys and
827 any applicable \tikzfeynmanname{} keys too. Other algorithms (such as |tree
828 layout|) can be passed through \meta{options} and that will override the
829 |spring layout|.
830
831 The syntax for the \meta{diagram instructions} is thoroughly described in
832 the \pgfmanual, but in the context of this package, it will usually suffice
833 to know the following:
834 \begin{itemize}
835 \item Vertices within the graph are specified with no delimiters (i.e.~no
836 parenthesis, no brackets) and only require spaces around either side. In
837 order to refer to a vertex defined outside of the |\diagram| command, its
838 name must be given in parenthesis: |(|\meta{name}|)|. Note that in order
839 to refer to external vertices, one must use |\diagram*| as most algorithms
840 (including the default |spring layout|) are incompatible with vertices
841 defined outside of the algorithm.
842
843 When a vertex name is used multiple times, the underlying algorithm will
844 consider them to be the same vertex and introduces additional edges.
845
846 Options can be given to the vertex in brackets after the name: \meta{name}
847 |[|\meta{options}|]|. For vertices defined outside of the |\diagram|
848 command, these options should be specified when the vertex is first
849 declared.
850
851 \item The edges between each pair of vertices is specified with |--|, and
852 these can be chained together: \verb|a -- b -- c|. In order to pass a
853 style to the edge, it is specified in brackets after the dashed:
854 |-- | \oarg{options}. For example, to make on edge red, one would use
855 |-- [red]|.
856
857 \item A comma (|,|)---or equivalently a semicolon (|;|)---specifies the end
858 of a sequence of edges and vertices and allows for another sequence to be
859 started. So \verb|a -- b, c -- d| will create two disconnected edges.
860
861 \item Subgroups (aking to scopes in \tikzname) are specified with braces:
862 |{|\oarg{options}\meta{diagram instructions}|}|. This can be quite
863 useful when a lot of edges or nodes share a common style. For example,
864 one could use |{[edges={fermion}]|\verb| a -- b -- c, x -- y -- z}| and
865 every edge will have the |fermion| style applied automatically.
866
867 Another useful feature of subgroups is that an edge to a group will create
868 an edge to each vertex in that subgroup as shown below. The example also
869 shows how they can be nested which in some cases (such as with a
870 |layered layout|) can be extremely useful.
871
872 \begin{codeexample}[]
873 \feynmandiagram [nodes=circle, horizontal=a1 to b3] {
874 a1 -- {b1, b2, b3 -- {c1, c2 -- d1}}
875 };
876 \end{codeexample}
877 \end{itemize}
878 \end{command}
879
880 \begin{command}{\diagram*\opt{\oarg{options}}\marg{diagram instructions}}
881 Same as |\diagram|, but instead of using the |spring layout| algorithm to
882 place the vertices, this uses the most basic algorithm. This basic
883 algorithm in most cases will not produce a satisfactory diagram, but is
884 intended to be used with vertices are declared and positioned outside of the
885 |\diagram*| command. Essentially, |\diagram*| should be used only to
886 connect existing vertices.
887 \end{command}
888 \end{environment}
889
890
891
892 \subsection{Keys \emph{\&} Styles}
893 \label{subsec:Keys}
894
895 The various styles and options that allow the Feynman diagrams to be customized
896 are defined in what \tikzname{} calls \emph{keys}. The documentation includes
897 all keys which are defined within \tikzfeynmanname{} which all begin with the
898 prefix |/tikzfeynman|. In addition, a few of the keys from \tikzname{} itself
899 which are particularly useful to \tikzfeynmanname{} are documented and these are
900 prefixed with |/tikz| or |/graph drawing|. Please refer to the \pgfmanual{} for
901 a more in thorough documentation of the \tikzname{} keys.
902
903
904 \tikzfeynmanname{} provides many |every |\meta{key} which allow every instance
905 of \meta{key} to be modified. For example, to make every diagram red except for
906 small diagrams which should be blue, then one would add to the preamble:
907 \begin{codeexample}[execute code=false]
908 \tikzfeynmanset{
909 every diagram={red},
910 every small={blue},
911 }
912 \end{codeexample}
913 If you are completely unhappy with a particular inbuilt style, you can define
914 your own style with with \meta{key}|/.style={...}| as shown in the
915 following example:
916 \begin{codeexample}[execute code=false]
917 \tikzfeynmanset{
918 myblob/.style={
919 shape=circle,
920 draw=blue,
921 fill=red,
922 }
923 }
924 \end{codeexample}
925
926 All the keys defined here are made available inside the |{feynman}| environment
927 and inside |\feynmandiagram|; but if you wish to access them outside of this
928 (say, in a regular |{tikzpicture}| environment), you will need to specify the
929 full path with the leading |/tikzfeynman|.
930
931 \subsubsection{Feynman Keys}
932 \label{subsubsec:feynman_keys}
933
934 \begin{keylist}{%
935 /tikzfeynman/execute at begin feynman=\marg{\TeX{} code},
936 /tikzfeynman/execute at end feynman=\marg{\TeX{} code}}
937 Allows for custom code to be executed at the start or end of each |{feynman}|
938 environment.
939 \end{keylist}
940
941 \begin{key}{/tikzfeynman/every feynman=\meta{styles}}
942 Set of styles which are applied to every |{feynman}| environments (and
943 consequently, every apply inside all |\feynmandiagram| too). The style also
944 applies to regular \tikzname{} commands used inside the |{feynman}|
945 environment.
946
947 \begin{codeexample}[]
948 \tikzfeynmanset{every feynman={red}}
949 \begin{tikzpicture}
950 \node at (0, 0.5) {This is not red};
951 \begin{feynman}
952 \node at (0, -0.5) {This is red};
953 \end{feynman}
954 \end{tikzpicture}
955 \end{codeexample}
956 \end{key}
957
958 \begin{stylekey}{/tikzfeynman/inline=\meta{node}}
959 A style used to display a Feynman diagram inline (typically in an equation),
960 and aligning such that its vertical placement is at the node specified. The
961 node specification must enclosed in parentheses. For nodes which contain text
962 (such as when the |particle| style is applied), it is possible to use the
963 baseline of the text inside the node to line up with the baseline of the
964 equation by using |(|\meta{node}|.base)| as demonstrated in the following
965 example. Note that this key applies additional styles to make the diagram fit
966 in an equation more nicely; if you do not wish to have these additional
967 styles, use the |baseline| key.
968
969 \begin{equation}
970 \feynmandiagram [inline=(d.base), horizontal=d to b] {
971 a -- [fermion] b -- [fermion] c,
972 b -- [boson] d [particle=\(\gamma\)],
973 };
974 = i g_{e} \gamma^{\mu}
975 \end{equation}
976
977 \begin{codeexample}[execute code=false]
978 \begin{equation}
979 \feynmandiagram [inline=(d.base), horizontal=d to b] {
980 a -- [fermion] b -- [fermion] c,
981 b -- [boson] d [particle=\(\gamma\)],
982 };
983 = i g_{e} \gamma^{\mu}
984 \end{equation}
985 \end{codeexample}
986 \end{stylekey}
987
988 \begin{key}{/tikz/baseline=\meta{node}}
989 Changes the vertical alignment of the Feynman diagram such that it diagram's
990 baseline is at the node specified. This works in the same was as
991 |inline=|\meta{node}, but it does not apply any additional styles (notice how
992 the following example is larger than the one above).
993 \begin{equation}
994 \feynmandiagram [baseline=(d.base), horizontal=d to b] {
995 a -- [fermion] b -- [fermion] c,
996 b -- [boson] d [particle=\(\gamma\)],
997 };
998 = i g_{e} \gamma^{\mu}
999 \end{equation}
1000
1001 \begin{codeexample}[execute code=false]
1002 \begin{equation}
1003 \feynmandiagram [baseline=(d.base), horizontal=d to b] {
1004 a -- [fermion] b -- [fermion] c,
1005 b -- [boson] d [particle=\(\gamma\)],
1006 };
1007 = i g_{e} \gamma^{\mu}
1008 \end{equation}
1009 \end{codeexample}
1010 \end{key}
1011
1012 \begin{keylist}{%
1013 /graph drawing/horizontal=\meta{node} to \meta{node},
1014 /graph drawing/horizontal'=\meta{node} to \meta{node},
1015 /graph drawing/vertical=\meta{node} to \meta{node},
1016 /graph drawing/vertical'=\meta{node} to \meta{node}}
1017 The underlying algorithm will arrange all the nodes relative to each other,
1018 but beyond that it has no idea how the overall graph should be oriented.
1019 By using one of the above keys, the final output of the algorithm is oriented
1020 and/or mirrored such that the two nodes specified are on the same horizontal
1021 (or vertical) line. The two nodes need not actually be connected by an edge
1022 for this to work.
1023
1024 The two \meta{node} specifications should \emph{not} be enclosed in
1025 parentheses, unlike the |inline| and |baseline| keys.
1026
1027 The |horizontal'| and |vertical'| keys work in the same was as |horizontal|
1028 and |vertical|, but with a flip.
1029
1030 \begin{codeexample}[]
1031 \feynmandiagram [inline=(b), horizontal=a to b, red] {
1032 a -- b -- {c [particle=\(c\)], d [particle=\(d\)]}
1033 };
1034 \feynmandiagram [inline=(b), horizontal'=a to b, blue] {
1035 a -- b -- {c [particle=\(c\)], d [particle=\(d\)]}
1036 };
1037 \feynmandiagram [inline=(b), vertical=a to b, green!40!black] {
1038 a -- b -- {c [particle=\(c\)], d [particle=\(d\)]}
1039 };
1040 \feynmandiagram [inline=(b), vertical=b to a, black] {
1041 a -- b -- {c [particle=\(c\)], d [particle=\(d\)]}
1042 };
1043 \end{codeexample}
1044 \end{keylist}
1045
1046 \subsubsection{Diagram Keys}
1047 \label{subsubsec:diagram_keys}
1048
1049 \begin{key}{/tikzfeynman/every diagram=\meta{styles}}
1050 Set of styles which are applied to every diagram; that is, to everything
1051 inside the |\feynmandiagram|, |\diagram| and |\diagram*| commands but not the
1052 general |{feynman}| environment (see \cref{subsubsec:feynman_keys} for that).
1053
1054 \begin{codeexample}[]
1055 \tikzfeynmanset{every diagram={red}}
1056 \feynmandiagram [small, horizontal=d to b] {
1057 a -- [fermion] b -- [fermion] c,
1058 b -- [boson] d,
1059 };
1060 \end{codeexample}
1061 \end{key}
1062
1063 \begin{keylist}{%
1064 /tikzfeynman/small,
1065 /tikzfeynman/medium,
1066 /tikzfeynman/large}
1067 Changes the default separation between the vertices and changes the size of
1068 arrows, blobs, and other shapes to fit different context. The |small| size is
1069 best used with when the diagram is quite simple and doesn't have too many
1070 annotations (such as momentum arrows and particle labels). The |medium| size
1071 is the default and is usually large enough that even diagrams with many labels
1072 and momentum arrows do not become too cluttered. Finally the |large| key is
1073 best for large illustrations as used on the title page of this document.
1074
1075 \begin{codeexample}[]
1076 \feynmandiagram [baseline=(b), small, horizontal=d to b, red] {
1077 a -- [fermion] b -- [fermion] c,
1078 b -- [boson] d,
1079 };
1080 \feynmandiagram [baseline=(b), medium, horizontal=d to b, green!40!black] {
1081 a -- [fermion] b -- [fermion] c,
1082 b -- [boson] d,
1083 };
1084 \feynmandiagram [baseline=(b), large, horizontal=d to b, blue] {
1085 a -- [fermion] b -- [fermion] c,
1086 b -- [boson] d,
1087 };
1088 \end{codeexample}
1089 \end{keylist}
1090
1091 There are several algorithms which are available to place the vertices which are
1092 all provided within the |graph drawing| library from \tikzname. Below are
1093 listed a few of these layouts which are more relevant for drawing Feynman
1094 diagrams. For a more complete description of how these algorithm work, please
1095 refer to the \pgfmanual{}. Please note that most graph drawing algorithms are
1096 implemented in Lua and thus require \LuaTeX{} in order to work. If \LuaTeX{} is
1097 not used, \tikzfeynmanname{} will default to a more rudimentary algorithm and
1098 will warn the user instead.
1099
1100 \begin{key}{/graph drawing/spring layout=\opt{\meta{string}}}
1101 Uses Hu's spring layout \cite{hu2005} as implemented by Pohlmann
1102 \cite{pohlmann2011}. This models each edge as springs and attempts to spread
1103 everything out as much as possible. This is the default layout.
1104
1105 \begin{codeexample}[]
1106 \feynmandiagram [nodes=circle, small, horizontal=c to d] {
1107 {a, b} -- c -- d -- {e, f},
1108 };
1109 \end{codeexample}
1110 \end{key}
1111
1112 \begin{key}{/graph drawing/spring electrical layout=\opt{\meta{string}}}
1113 Uses Hu's spring electrical layout \cite{hu2005} as implemented by Pohlmann
1114 \cite{pohlmann2011}. This models each edge as springs and gives each vertex a
1115 charge. This algorithm allows for the charge of a particular vertex to be
1116 adjusted using the |electric charge| key (the default is |1|).
1117
1118 \begin{codeexample}[]
1119 \feynmandiagram [nodes=circle,
1120 small, horizontal=c to d,
1121 spring electrical layout
1122 ] {
1123 {a, b [electric charge=2]} -- c -- d -- {e, f [electric charge=0.1]},
1124 };
1125 \end{codeexample}
1126 \end{key}
1127
1128 \begin{key}{/graph drawing/layered layout=\opt{\meta{string}}}
1129 Uses the Sugiyama layout algorithm \cite{eades1991} as implemented by Pohlmann
1130 \cite{pohlmann2011} in order to place the node.
1131
1132 When an edge is specified, the first vertex is always located on the layer
1133 above the second vertex. This creates a hierarchy of vertices which is
1134 particularly useful for decays.
1135
1136 Two vertices can be forced to be on the same layer with the
1137 |/graph drawing/same layer| key.
1138
1139 \begin{codeexample}[]
1140 \feynmandiagram [nodes=circle, small, horizontal=a to b, layered layout] {
1141 a -- b -- {c, d -- {e, f}},
1142 };
1143 \end{codeexample}
1144 \begin{codeexample}[]
1145 \feynmandiagram [nodes=circle, small, horizontal=a to b, layered layout] {
1146 a -- b -- {c -- {c1, c2}, d -- {d1, d2}},
1147 {[same layer] c1, d},
1148 };
1149 \end{codeexample}
1150 \end{key}
1151
1152 \begin{key}{/graph drawing/tree layout=\opt{\meta{string}}}
1153 Uses the Reingold--Tilform algorithm in order to place the node. This works
1154 in a similar way to the layered layout, but has quite a lot of additional
1155 options to handle missing children in the tree. Please refer to the
1156 \pgfmanual{} for a thorough description of these additional features.
1157
1158 When an edge is specified, the first vertex is always located on the layer
1159 above the second vertex. This creates a hierarchy of vertices which is
1160 particularly useful for decays.
1161
1162 \begin{codeexample}[]
1163 \feynmandiagram [nodes=circle, small, horizontal=a to b, tree layout] {
1164 a -- b -- {c, d -- {e, f}},
1165 };
1166 \end{codeexample}
1167 \begin{codeexample}[]
1168 \feynmandiagram [nodes=circle, small, horizontal=a to b, tree layout] {
1169 a -- b -- {c -- {c1, c2}, d -- {d1, d2}},
1170 };
1171 \end{codeexample}
1172 \end{key}
1173
1174 \begin{keylist}{%
1175 /tikz/graphs/edges=\meta{options},
1176 /tikz/graphs/nodes=\meta{options}}
1177 Just like it is possible to change the shape of every vertex or edge in the
1178 whole document, it is also possible to change the shape of every vertex or
1179 edge in a single diagram by modifying these keys and adding the desired
1180 styles.
1181 \end{keylist}
1182
1183 \subsubsection{Vertex Keys}
1184 \label{subsubsec:vertex_keys}
1185
1186 \begin{key}{/tikzfeynman/vertex}
1187 The default, base style applied to every vertex initially. Other styles
1188 are subsequently added. This sets the vertex |shape| to be a |coordinate|,
1189 that is, a null shape with no size or width.
1190 \end{key}
1191
1192 \begin{key}{/tikzfeynman/every \meta{vertex shape}=\meta{styles}}
1193 The style of specific vertices can be modified by changing the appropriate
1194 |every |\meta{vertex shape} key. For example, in order to change the style of
1195 every |dot|-styled vertex, you can modify the |every dot| key, or to modify
1196 every vertex globally, the |every vertex| key can be modified.
1197
1198 \begin{codeexample}[]
1199 \tikzfeynmanset{
1200 every vertex={red, dot},
1201 every particle={blue},
1202 every blob={draw=green!40!black, pattern color=green!40!black},
1203 }
1204 \feynmandiagram [horizontal=a to b] {
1205 a [particle={\(\gamma, Z\)}] -- [boson] b [blob],
1206 c -- [fermion] b -- [fermion] d,
1207 };
1208 \end{codeexample}
1209 \end{key}
1210
1211 \begin{key}{/tikzfeynman/dot}
1212 Modifies the vertex so that it has a small filled circle.
1213
1214 \begin{codeexample}[]
1215 \feynmandiagram [small] {
1216 a -- b [dot] -- {c, d}
1217 };
1218 \end{codeexample}
1219 \end{key}
1220
1221 \begin{key}{/tikzfeynman/square dot}
1222 Modifies the vertex so that it has a small filled square.
1223
1224 \begin{codeexample}[]
1225 \feynmandiagram [small] {
1226 a -- b [square dot] -- {c, d}
1227 };
1228 \end{codeexample}
1229 \end{key}
1230
1231 \begin{key}{/tikzfeynman/empty dot}
1232 Modifies the vertex so that it has a small empty circle.
1233
1234 \begin{codeexample}[]
1235 \feynmandiagram [small] {
1236 a -- b [empty dot] -- {c, d}
1237 };
1238 \end{codeexample}
1239 \end{key}
1240
1241 \begin{key}{/tikzfeynman/crossed dot}
1242 Modifies the vertex so that it has a small circle with a cross inside.
1243
1244 \begin{codeexample}[]
1245 \feynmandiagram [small] {
1246 a -- b [crossed dot] -- {c, d}
1247 };
1248 \end{codeexample}
1249 \end{key}
1250
1251 \begin{key}{/tikzfeynman/blob}
1252 Modifies the vertex so that it is a large blob, usually used to denote an
1253 effective operator.
1254
1255 \begin{codeexample}[]
1256 \feynmandiagram [small] {
1257 a -- b [blob] -- {c, d}
1258 };
1259 \end{codeexample}
1260 \end{key}
1261
1262 \begin{key}{/tikzfeynman/particle=\meta{name}}
1263 Modifies the vertex so that it shows \meta{name}. This is intended to label
1264 initial and final particles, but it should not be used on internal vertices as
1265 it will result in the lines at the vertex having a gap. For propagators (the
1266 |edge label| key is much more appropriate).
1267
1268 Note that if \meta{name} contains characters such as brackets (|[]|) or
1269 commas (|,|), the whole \meta{name} has to be enclosed in braces (|{}|);
1270 otherwise, the parser will interpret the comma as the end of the \meta{name}
1271 and the start of the next key, or the closing bracket as the end of all
1272 optional arguments.
1273
1274 \begin{codeexample}[]
1275 \feynmandiagram [small, horizontal=a to b] {
1276 a [particle={\(\gamma, Z\)}] -- [boson] b -- {c, d},
1277 };
1278 \end{codeexample}
1279 \end{key}
1280
1281
1282 \subsubsection{Edge Keys}
1283 \label{subsubsec:edge_keys}
1284
1285 Just like with the various vertex keys, each edge type has a corresponding
1286 |every |\meta{edge type}; however, due to the existence of very similar keys
1287 such as |scalar|, |charged scalar| and |anti charged scalar|, more specific keys
1288 inherit styles from less specific ones. For example, styles in |every scalar|
1289 will apply to |charged scalar| and |anti charged scalar|.
1290
1291 The edge styles do not override each other and instead stack. This means that
1292 an edge styled with both |boson| and |fermion| will consist of a straight line
1293 with a wavy line on top and an error. If not styles are provided, then a simple
1294 solid line is drawn.
1295
1296 \begin{key}{/tikzfeynman/every edge=\meta{styles}}
1297 A style to apply to every edge initially.
1298 \end{key}
1299
1300 \begin{stylekey}{/tikzfeynman/every \meta{edge style}=\meta{styles}}
1301 The style of specific edges can be modified by changing the appropriate
1302 |every |\meta{edge style} key. For example, in order to make a global change
1303 to every |boson|, you can modify the |every boson| key.
1304
1305 \begin{codeexample}[]
1306 \tikzfeynmanset{
1307 every edge={green},
1308 every boson={red},
1309 every photon={blue},
1310 }
1311 \feynmandiagram [small] {
1312 a [particle=\(a\)] -- [boson] o -- [photon] b [particle=\(b\)],
1313 f1 [particle=\(c\)] -- [fermion] o -- [scalar] f2 [particle=\(d\)],
1314 };
1315 \end{codeexample}
1316 \end{stylekey}
1317
1318 \begin{key}{/tikzfeynman/plain}
1319 Draws a simple solid line. This style is identical to the default style
1320 applied if no other style is used, but is provided so that it can be combined
1321 with other styles.
1322
1323 \begin{codeexample}[]
1324 \feynmandiagram [horizontal=a to b] {a -- [plain] b};
1325 \feynmandiagram [horizontal=a to b] {a -- [plain, gluon] b};
1326 \end{codeexample}
1327 \end{key}
1328
1329 \begin{key}{/tikzfeynman/boson}
1330 Draws a sinusoidal line to denote a boson.
1331
1332 \begin{codeexample}[]
1333 \feynmandiagram [horizontal=a to b] {a -- [boson] b};
1334 \end{codeexample}
1335 \end{key}
1336
1337 \begin{key}{/tikzfeynman/charged boson}
1338 Draws a sinusoidal line with an arrow to denote a charged boson.
1339
1340 \begin{codeexample}[]
1341 \feynmandiagram [horizontal=a to b] {a -- [charged boson] b};
1342 \end{codeexample}
1343 \end{key}
1344
1345 \begin{key}{/tikzfeynman/anti charged boson}
1346 Draws a sinusoidal line with an arrow pointing the other way to to denote a
1347 anti charged boson.
1348
1349 \begin{codeexample}[]
1350 \feynmandiagram [horizontal=a to b] {a -- [anti charged boson] b};
1351 \end{codeexample}
1352 \end{key}
1353
1354 \begin{key}{/tikzfeynman/photon}
1355 Draws a sinusoidal line to denote a photon.
1356
1357 \begin{codeexample}[]
1358 \feynmandiagram [horizontal=a to b] {a -- [photon] b};
1359 \end{codeexample}
1360 \end{key}
1361
1362 \begin{key}{/tikzfeynman/scalar}
1363 Draws a dashed line to denote a scalar.
1364
1365 \begin{codeexample}[]
1366 \feynmandiagram [horizontal=a to b] {a -- [scalar] b};
1367 \end{codeexample}
1368 \end{key}
1369
1370 \begin{key}{/tikzfeynman/charged scalar}
1371 Draws a dashed line with an arrow to denote a charged scalar.
1372
1373 \begin{codeexample}[]
1374 \feynmandiagram [horizontal=a to b] {a -- [charged scalar] b};
1375 \end{codeexample}
1376 \end{key}
1377
1378 \begin{key}{/tikzfeynman/anti charged scalar}
1379 Draws a dashed line with an arrow pointing the other way to denote a charged
1380 scalar antiparticle.
1381
1382 \begin{codeexample}[]
1383 \feynmandiagram [horizontal=a to b] {a -- [anti charged scalar] b};
1384 \end{codeexample}
1385 \end{key}
1386
1387 \begin{key}{/tikzfeynman/ghost}
1388 Draws a dotted line to denote a ghost.
1389
1390 \begin{codeexample}[]
1391 \feynmandiagram [horizontal=a to b] {a -- [ghost] b};
1392 \end{codeexample}
1393 \end{key}
1394
1395
1396 \begin{key}{/tikzfeynman/fermion}
1397 Draws a solid line with an arrow to denote a fermion.
1398
1399 \begin{codeexample}[]
1400 \feynmandiagram [horizontal=a to b] {a -- [fermion] b};
1401 \end{codeexample}
1402 \end{key}
1403
1404 \begin{key}{/tikzfeynman/anti fermion}
1405 Draws a solid line with an arrow pointing the other way to denote an antifermion.
1406
1407 \begin{codeexample}[]
1408 \feynmandiagram [horizontal=a to b] {a -- [anti fermion] b};
1409 \end{codeexample}
1410 \end{key}
1411
1412 \begin{key}{/tikzfeynman/majorana}
1413 Draws a solid line with two arrows pointing to the center to denote an
1414 Majorana particle.
1415
1416 \begin{codeexample}[]
1417 \feynmandiagram [horizontal=a to b] {a -- [majorana] b};
1418 \end{codeexample}
1419 \end{key}
1420
1421 \begin{key}{/tikzfeynman/anti majorana}
1422 Draws a solid line with two arrows pointing to the ends to denote a Majorana
1423 particle.
1424
1425 \begin{codeexample}[]
1426 \feynmandiagram [horizontal=a to b] {a -- [anti majorana] b};
1427 \end{codeexample}
1428 \end{key}
1429
1430 \begin{key}{/tikzfeynman/gluon}
1431 Draws a coiled line to denote a gluon.
1432
1433 \begin{codeexample}[]
1434 \feynmandiagram [horizontal=a to b] {a -- [gluon] b};
1435 \end{codeexample}
1436 \end{key}
1437
1438 \begin{keylist}{%
1439 /tikz/edge label=\meta{text},
1440 /tikz/edge label'=\meta{text}}
1441 Places a label halfway along the edge with the given text. The primed key
1442 switches which side of the edge the label is placed.
1443 \end{keylist}
1444
1445 \begin{key}{/tikzfeynman/insertion=\opt{\oarg{options}}\meta{distance}}
1446 Places an insertion (for mass or momentum insertion) along an edge. The
1447 distance specifies how far along the edge the insertion should be placed such
1448 that |0| and |1| respectively correspond to the start and the end of the edge.
1449
1450 Multiple insertions can be placed along a single edge by repeating the style
1451 key.
1452
1453 Through the \meta{options} argument, the insertion size and style can be
1454 changed.
1455
1456 \begin{codeexample}[]
1457 \feynmandiagram [horizontal=a to b] {a -- [insertion=0.33, insertion=0.67] b};
1458 \end{codeexample}
1459
1460 \begin{key}{/tikzfeynman/insertion/size=\meta{distance} (initially 3pt)}
1461 Specifies how big the insertion should be. The length of each edge starting
1462 from the center will be \(\sqrt{2} \times \meta{distance}\).
1463
1464 \begin{codeexample}[]
1465 \feynmandiagram [horizontal=a to b] {a -- [insertion={[size=10pt]0.4}] b};
1466 \end{codeexample}
1467 \end{key}
1468
1469 \begin{key}{/tikzfeynman/insertion/style=\meta{distance} (initially \normalfont empty)}
1470 Specifies additional styles to applying to the lines of the insertion.
1471
1472 \begin{codeexample}[]
1473 \feynmandiagram [horizontal=a to b] {a -- [insertion={[style=red]0.4}] b};
1474 \end{codeexample}
1475 \end{key}
1476 \end{key}
1477
1478 \subsubsection{Momentum Keys}
1479 \label{subsubsec:momentum_keys}
1480
1481 \begin{keylist}{%
1482 /tikzfeynman/momentum=\opt{\oarg{options}}\meta{text},
1483 /tikzfeynman/momentum'=\opt{\oarg{options}}\meta{text},
1484 /tikzfeynman/reversed momentum=\opt{\oarg{options}}\meta{text},
1485 /tikzfeynman/reversed momentum'=\opt{\oarg{options}}\meta{text},
1486 /tikzfeynman/rmomentum=\opt{\oarg{options}}\meta{text},
1487 /tikzfeynman/rmomentum'=\opt{\oarg{options}}\meta{text}}
1488 Places a momentum arrow on the specified edge with label given by \meta{text}.
1489 The primed (|'|) version place the momentum arrow on the other side of the
1490 edge; that is, if the momentum arrow was on the right, it will be placed on
1491 the left of the edge. The |reversed momentum| and |reversed momentum'| keys
1492 are analogous to |momentum| and |momentum'| except that the momentum arrow
1493 points in the opposite direction. Finally, the |rmomentum| and |rmomentum'|
1494 are aliases of |reversed momentum| and |reversed momentum'|.
1495
1496 Note that due to the way the arrow is drawn, it doesn't inherit styles of the
1497 edge. As a result, they have to be re-specified through \meta{options}.
1498
1499 \begin{codeexample}[]
1500 \feynmandiagram [layered layout, horizontal=a to b] {
1501 a -- [red, fermion, edge label'=\(ab\), momentum={[arrow style=red]\(p_{ab}\)}] b
1502 -- [blue, photon, edge label'=\(bc\)] c
1503 -- [green!40!black, scalar, momentum=\(p_{cd}\)] d,
1504 };
1505 \end{codeexample}
1506
1507 \begin{codeexample}[]
1508 \feynmandiagram [layered layout, horizontal=b to c] {
1509 a -- [photon, momentum=\(p\)] b
1510 -- [fermion, half left, looseness=1.5, momentum=\(k\)] c
1511 -- [fermion, half left, looseness=1.5, momentum=\(k-p\)] b,
1512 c -- [photon, momentum=\(p\)] d,
1513 };
1514 \end{codeexample}
1515
1516 The \meta{options} allows for the following options to customize the appearance
1517 of the momentum arrows. These can be either set globally with the usual
1518 |\tikzfeynmanset|, or can be set on a individual basis through the
1519 \meta{options} argument of the |momentum| key. In the latter case, only the
1520 \meta{key} in |/tikzfeynman/momentum/|\meta{key} is required.
1521
1522 \begin{key}{/tikzfeynman/momentum/label distance=\meta{distance} (initially 0pt)}
1523 Set the separation between the text and the arrow. Note that the text is
1524 still surrounded by an |inner sep=0.3333em| by default so the default
1525 distance of |0pt| will not result in the momentum label touching the arrow.
1526 \end{key}
1527
1528 \begin{key}{/tikzfeynman/momentum/arrow distance=\meta{distance} (initially 3mm)}
1529 Set the separation between the edge and the arrow.
1530 \end{key}
1531
1532 \begin{key}{/tikzfeynman/momentum/arrow shorten=\meta{distance} (initially 0.15)}
1533 Specify the fraction of the total edge length by which the momentum arrow is
1534 shortened at each end.
1535 \end{key}
1536
1537 \begin{key}{/tikzfeynman/momentum/label style=\meta{style} (initially \normalfont empty)}
1538 Define styles to apply to the momentum label node.
1539 \end{key}
1540
1541 \begin{key}{/tikzfeynman/momentum/arrow style=\meta{style} (initially \normalfont empty)}
1542 Define style to apply to the momentum arrow.
1543 \end{key}
1544 \end{keylist}
1545
1546 \subsubsection{Modifier Keys}
1547 \label{subsubsec:modifier_keys}
1548
1549 Modifier keys serve only to slightly modify a small feature of the edge.
1550
1551 \begin{keylist}{%
1552 /tikzfeynman/half left,
1553 /tikzfeynman/half right,
1554 /tikzfeynman/quarter left,
1555 /tikzfeynman/quarter right}
1556 Modifies the edge so that it bends left or right in such a way that it
1557 completes half a circle, or a quarter of a circle.
1558
1559 \begin{codeexample}[]
1560 \feynmandiagram [horizontal=a to b] {
1561 a -- [red, fermion, half left] b -- [blue, fermion, half left] a,
1562 };
1563 \end{codeexample}
1564
1565 \begin{codeexample}[]
1566 \feynmandiagram [horizontal=a to c] {
1567 a -- [red!0!blue, fermion, quarter left] b
1568 -- [red!33!blue, fermion, quarter left] c
1569 -- [red!66!blue, fermion, quarter left] d
1570 -- [red!100!blue, fermion, quarter left] a,
1571 };
1572 \end{codeexample}
1573 \end{keylist}
1574
1575 \begin{keylist}{%
1576 /tikz/out=\meta{angle},
1577 /tikz/in=\meta{angle}}
1578 Specifies the angle at which the edge leaves the first vertex in an edge and
1579 the angle at which it enters the second vertex in an edge.
1580 \end{keylist}
1581
1582 \begin{key}{/tikz/relative=\opt{\meta{true or false}} (default true)}
1583 If |relative| is set to |false|, the angle is relative to the paper whilst when
1584 |relative| is set to |true|, the angle is relative to the straight line
1585 joining the two vertices.
1586 \end{key}
1587
1588 \begin{key}{/tikz/looseness=\meta{number} (initially 1)}
1589 As the name suggests, this specifies how `loose' or `tight' a curve is
1590 connecting two vertices.
1591 \end{key}
1592
1593 \clearpage
1594 \section{Examples}
1595 \label{sec:examples}
1596
1597 Below are a few diagrams which demonstrate how the package can be used in some
1598 more practical examples..
1599
1600 \begin{description}
1601 \item[Vertex Rule] \hspace*{0pt} \newline
1602 \begin{codeexample}[]
1603 \feynmandiagram [horizontal=a to b] {
1604 a [particle=\(Z\)] -- [photon, momentum=\(p_{1}\)] b,
1605 f1 [particle=\(\overline f\)]
1606 -- [fermion, rmomentum'=\(p_{3}\)] b
1607 -- [fermion, momentum=\(p_{2}\)] f2 [particle=\(f\)],
1608 };
1609 \end{codeexample}
1610
1611 \item[Tree Level Diagrams] \hspace*{0pt} \newline
1612 \begin{codeexample}[]
1613 \feynmandiagram [horizontal=a to b] {
1614 i1 [particle=\(e^{-}\)] -- [fermion] a -- [fermion] i2 [particle=\(e^{+}\)],
1615 a -- [photon, edge label=\(\gamma\)] b,
1616 f1 [particle=\(\mu^{-}\)] -- [fermion] b -- [fermion] f2 [particle=\(\mu^{+}\)],
1617 };
1618 \end{codeexample}
1619
1620 \begin{codeexample}[]
1621 \feynmandiagram [vertical'=a to b] {
1622 i1 [particle=\(e^{-}\)]
1623 -- [fermion] a
1624 -- [fermion] f1 [particle=\(e^{-}\)],
1625 a -- [photon, edge label=\(\gamma\)] b,
1626 i2 [particle=\(e^{+}\)]
1627 -- [anti fermion] b
1628 -- [anti fermion] f2 [particle=\(e^{+}\)],
1629 };
1630 \end{codeexample}
1631
1632 \begin{codeexample}[]
1633 \begin{tikzpicture}
1634 \begin{feynman}
1635 \diagram [vertical'=a to b] {
1636 i1 [particle=\(e^{-}\)]
1637 -- [fermion] a
1638 -- [draw=none] f1 [particle=\(e^{+}\)],
1639 a -- [photon, edge label'=\(p\)] b,
1640 i2 [particle=\(e^{+}\)]
1641 -- [anti fermion] b
1642 -- [draw=none] f2 [particle=\(e^{-}\)],
1643 };
1644 \diagram* {
1645 (a) -- [fermion] (f2),
1646 (b) -- [anti fermion] (f1),
1647 };
1648 \end{feynman}
1649 \end{tikzpicture}
1650 \end{codeexample}
1651
1652 \item[Loops] \hspace*{0pt} \newline
1653 \begin{codeexample}[]
1654 \feynmandiagram [layered layout, horizontal=b to c] {
1655 a -- [photon, momentum=\(p\)] b
1656 -- [fermion, half left, momentum=\(k\)] c
1657 -- [fermion, half left, momentum=\(k-p\)] b,
1658 c -- [photon, momentum=\(p\)] d,
1659 };
1660 \end{codeexample}
1661
1662 \begin{codeexample}[]
1663 \feynmandiagram [layered layout, horizontal=a to b] [edges=gluon] {
1664 {i1, i2} -- a -- [half left] b -- [half left] a,
1665 b -- {f1, f2},
1666 };
1667 \end{codeexample}
1668
1669 \newpage
1670 \item[Box Diagrams] \hspace*{0pt} \newline
1671 \begin{codeexample}[]
1672 \feynmandiagram [layered layout, horizontal=a to b] {
1673 % Draw the top and bottom lines
1674 i1 [particle=\(d\)]
1675 -- [fermion] a
1676 -- [photon, edge label=\(W^{-}\)] b
1677 -- [fermion] f1 [particle=\(\mu^{-}\)],
1678 i2 [particle=\(\overline s\)]
1679 -- [anti fermion] c
1680 -- [photon, edge label'=\(W^{+}\)] d
1681 -- [anti fermion] f2 [particle=\(\mu^{+}\)],
1682 % Draw the two internal fermion lines
1683 { [same layer] a -- [fermion, edge label'=\(q\)] c },
1684 { [same layer] b -- [anti fermion, edge label=\(\nu_{\mu}\)] d},
1685 };
1686 \end{codeexample}
1687
1688 \newpage
1689 \item[Meson decay and mixing] \hspace*{0pt} \newline
1690 \begin{codeexample}[]
1691 \begin{tikzpicture}
1692 \begin{feynman}
1693 \vertex (a1) {\(\overline b\)};
1694 \vertex[right=1.5cm of a1] (a2);
1695 \vertex[right=1cm of a2] (a3);
1696 \vertex[right=1.5cm of a3] (a4) {\(\overline u\)};
1697
1698 \vertex[below=2em of a1] (b1) {\(d\)};
1699 \vertex[below=2em of a4] (b2) {\(d\)};
1700
1701 %% See section 13.5 of PGF/TikZ manual
1702 \vertex at ($(a2)!0.5!(a3)!0.5cm!90:(a3)$) (d);
1703 %% Equivalent way to obtain (d):
1704 % \vertex at ($(b2)!0.5!(b3) + (0, -0.5cm)$) (d);
1705 \vertex[above=of a4] (c1) {\(u\)};
1706 \vertex[above=2em of c1] (c3) {\(\overline d\)};
1707 \vertex at ($(c1)!0.5!(c3) - (1cm, 0)$) (c2);
1708
1709 \diagram* {
1710 (a4) -- [fermion] (a3) -- [fermion] (a2) -- [fermion] (a1),
1711 (b1) -- [fermion] (b2),
1712 (c3) -- [fermion, out=180, in=45] (c2) -- [fermion, out=-45, in=180] (c1),
1713 (a2) -- [boson, quarter left] (d) -- [boson, quarter left] (a3),
1714 (d) -- [boson, bend left, edge label=\(W^{+}\)] (c2),
1715 };
1716
1717 \draw [decoration={brace}, decorate] (b1.south west) -- (a1.north west)
1718 node [pos=0.5, left] {\(B^{0}\)};
1719 \draw [decoration={brace}, decorate] (c3.north east) -- (c1.south east)
1720 node [pos=0.5, right] {\(\pi^{+}\)};
1721 \draw [decoration={brace}, decorate] (a4.north east) -- (b2.south east)
1722 node [pos=0.5, right] {\(\pi^{-}\)};
1723 \end{feynman}
1724 \end{tikzpicture}
1725 \end{codeexample}
1726
1727 \newpage
1728 \begin{codeexample}[]
1729 \begin{tikzpicture}
1730 \begin{feynman}
1731 \vertex (a1) {\(\overline b\)};
1732 \vertex[right=1cm of a1] (a2);
1733 \vertex[right=1cm of a2] (a3);
1734 \vertex[right=1cm of a3] (a4) {\(b\)};
1735 \vertex[right=1cm of a4] (a5);
1736 \vertex[right=2cm of a5] (a6) {\(u\)};
1737
1738 \vertex[below=2em of a1] (b1) {\(d\)};
1739 \vertex[right=1cm of b1] (b2);
1740 \vertex[right=1cm of b2] (b3);
1741 \vertex[right=1cm of b3] (b4) {\(\overline d\)};
1742 \vertex[below=2em of a6] (b5) {\(\overline d\)};
1743
1744 \vertex[above=of a6] (c1) {\(\overline u\)};
1745 \vertex[above=2em of c1] (c3) {\(d\)};
1746 \vertex at ($(c1)!0.5!(c3) - (1cm, 0)$) (c2);
1747
1748 \diagram* {
1749 {[edges=fermion]
1750 (b1) -- (b2) -- (a2) -- (a1),
1751 (b5) -- (b4) -- (b3) -- (a3) -- (a4) -- (a5) -- (a6),
1752 },
1753 (a2) -- [boson, edge label=\(W\)] (a3),
1754 (b2) -- [boson, edge label'=\(W\)] (b3),
1755
1756 (c1) -- [fermion, out=180, in=-45] (c2) -- [fermion, out=45, in=180] (c3),
1757 (a5) -- [boson, bend left, edge label=\(W^{-}\)] (c2),
1758 };
1759
1760 \draw [decoration={brace}, decorate] (b1.south west) -- (a1.north west)
1761 node [pos=0.5, left] {\(B^{0}\)};
1762 \draw [decoration={brace}, decorate] (c3.north east) -- (c1.south east)
1763 node [pos=0.5, right] {\(\pi^{-}\)};
1764 \draw [decoration={brace}, decorate] (a6.north east) -- (b5.south east)
1765 node [pos=0.5, right] {\(\pi^{+}\)};
1766 \end{feynman}
1767 \end{tikzpicture}
1768 \end{codeexample}
1769
1770 \newpage
1771 \begin{codeexample}[]
1772 \begin{tikzpicture}
1773 \begin{feynman}
1774 \vertex (a1) {\(\overline b\)};
1775 \vertex[right=2cm of a1] (a2);
1776 \vertex[right=0.5cm of a2] (a3);
1777 \vertex[right=0.5cm of a3] (a4);
1778 \vertex[right=2cm of a4] (a5) {\(\overline s\)};
1779
1780 \vertex[below=2cm of a1] (b1) {\(d\)};
1781 \vertex[below=2cm of a5] (b2) {\(d\)};
1782
1783 \vertex[below=1.5em of a5] (c1) {\(s\)};
1784 \vertex[above=1.5em of b2] (c3) {\(\overline s\)};
1785 \vertex at ($(c1)!0.5!(c3) - (1cm, 0)$) (c2);
1786
1787 \diagram* {
1788 {[edges=fermion]
1789 (a5) -- (a4) -- (a3) -- (a2) -- (a1),
1790 },
1791 (b1) -- [fermion] (b2),
1792 (c3) -- [fermion, out=180, in=-60] (c2) -- [fermion, out=60, in=180] (c1),
1793 (a3) -- [gluon, bend right] (c2),
1794 (a4) -- [boson, out=90, in=90, looseness=2.0, edge label'=\(W^{+}\)] (a2)
1795 };
1796
1797 \draw [decoration={brace}, decorate] (b1.south west) -- (a1.north west)
1798 node [pos=0.5, left] {\(B^{0}\)};
1799 \draw [decoration={brace}, decorate] (a5.north east) -- (c1.south east)
1800 node [pos=0.5, right] {\(\phi\)};
1801 \draw [decoration={brace}, decorate] (c3.north east) -- (b2.south east)
1802 node [pos=0.5, right] {\(K^{0}\)};
1803 \end{feynman}
1804 \end{tikzpicture}
1805 \end{codeexample}
1806
1807 \end{description}
1808
1809 %% Index
1810 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1811 \clearpage
1812 \printindex
1813
1814 %% Bibliography (and acknowledgements)
1815 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1816 \clearpage
1817 \pagestyle{plain}
1818
1819 \ifarxiv
1820 \acknowledgements
1821 \fi
1822
1823 \printbibliography
1824
1825 \end{document}
1826
1827 %%% Local Variables:
1828 %%% mode: latex
1829 %%% TeX-master: t
1830 %%% End: