Style and content

LaTeX

A course on a LaTeX + vim Kung Fu:

Feynman diagrams

An important tool used often in the context of quantum field theory is Feynman's pictorial representation of formulas. However, there is no established standard for compiling Feynman diagrams into PDFs. One useful option is to use the TikZ environment within LaTeX. There are several reasons for using TikZ to create Feynman diagrams:

  • LaTeX is used by most of our colleagues.
  • The TikZ environment is exceptionally well documented.
  • The TikZ environment is very versatile and can be used for many different purposes. Knowing about its basic functions opens up many possibilities for creating graphics in general and graphics embedded in scientific documents in particular.
  • Graphics created using TikZ are very small. Since they are coded within the TeX document, sending the raw .tex file to a colleague does not require additional files alongside; everything is contained in the tiny TeX document. Further, the compiled PDF document is also small.
  • The specific knowledge required to create Feynman diagrams can be acquired in a short amount of time.

Example

Let us recreate Fig. 2 of Krien et al., PRB 100, 155149 (2019). Use the following headers:

\usepackage{tikz}

\usetikzlibrary{calc}
\usetikzlibrary{decorations.pathmorphing}
\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{shapes.misc}
\usetikzlibrary{shapes}
\usetikzlibrary{positioning}
\usetikzlibrary{snakes}
\usetikzlibrary{arrows}
\usetikzlibrary{fadings}
\usetikzlibrary{arrows}
\tikzstyle{decision} = [diamond, draw, fill=blue!20, text width=4.5em, text badly centered, node distance=3cm, inner sep=0pt]
\tikzstyle{block} = [rectangle, draw, fill=blue!20, text width=7em, text centered, rounded corners, minimum height=5em]
\tikzstyle{line} = [draw, -latex']
\tikzstyle{cloud} = [draw, ellipse,fill=red!20, node distance=3cm, minimum height=2em]
\tikzstyle{overbrace style}=[decorate,decoration={brace,raise=2mm,amplitude=3pt}]
\tikzstyle{overbrace text style}=[font=\footnotesize, above, pos=.5, yshift=3mm]
\tikzset{snake it/.style={decorate, decoration=snake}}
\usetikzlibrary{3d}

\tikzset{middlearrow/.style={
                decoration={markings, mark= at position 0.65 with {\arrow{#1}} ,                            },
                postaction={decorate}
                }
}


Within the document, create the figure as follows:

\begin{figure}

    \begin{center}

    \begin{tikzpicture}

        \begin{scope}[shift={(0,0)}]

        \draw[thick,middlearrow={>}] (-.3,.5) -- (0,.5);

        \draw[thick,middlearrow={<}] (-.3,-.5) -- (0,-.5);

        \draw[thick] (0,-.5) -- (0,.5) -- (.8,0) -- cycle;

        \draw (-.15,.75) node{\scriptsize$\nu$};

        \draw (-.15,-.75) node{\scriptsize$\nu+\omega$};

        \draw [decorate,decoration={snake,amplitude=1pt, segment length=9pt},very thick] (0.8,0) -- (1.8,0) ;

        \draw (1.3,.25) node{\scriptsize$\omega$};

        \draw (.9,-1) node{(a)};

        \draw[thick] (.26,0) node{$\bar{\lambda}$};

        \end{scope}

        \begin{scope}[shift={(2.8,-.2)}]

        \draw[thick,middlearrow={>}] (-.3,1.2) -- (0,1.2);

        \draw[thick,middlearrow={>}] (1,1.2) -- (1.3,1.2);

        \draw[thick] (0,1.2) -- (1,1.2) -- (.5,.4) -- cycle;

        \draw (-.15,1.5) node{\scriptsize$\nu$};

        \draw (1.15,1.5) node{\scriptsize$\nu'$};

        \draw [decorate,decoration={snake,amplitude=1pt, segment length=9pt},very thick] (.5,.4) -- (.5,-.4) ;

        \draw (.75,0) node[rotate=-90]{\scriptsize$\nu'-\nu$};

            \draw (.6,-.8) node{(b)};

        \draw[thick] (.5,.9) node{$\bar{\lambda}$};

        \end{scope}

        \begin{scope}[shift={(5,0)}]

        \draw[thick,middlearrow={>}] (-.3,.5) -- (0,.5);

        \draw[thick,middlearrow={>}] (-.3,-.5) -- (0,-.5);

        \draw (-.15,.75) node{\scriptsize$\nu$};

        \draw (-.15,-.75) node{\scriptsize$\nu'+\omega$};

        \draw[thick] (0,-.5) -- (0,.5) -- (.8,0) -- cycle;

        \draw (1.35,.25) node{\scriptsize$\omega+\nu+\nu'$};

        \draw [decorate,decoration={snake,amplitude=1pt, segment length=9pt},very thick] (0.8,0) -- (1.8,0) ;

            \draw (.9,-1) node{(c)};

        \draw[thick] (.26,0) node{$\bar{\lambda}$};

        \end{scope}

    \end{tikzpicture}

\end{center}

    \caption{\label{fig:events} Boson exchanges of the SBE decomposition in Fig. 1.

    (a) Particle-hole annihilation.

    (b) Particle propagation and boson exchange with a hole.

    (c) Particle-particle annihilation.

    }

\end{figure}

Post-processing

Some journals (e.g. PRB) do not accept coded graphics during the production stage (during the review stage PRB does accept them, also arXiv has no problem with TikZ figures). In this case, the TikZ figures need to be compiled into separate PDF files and sent alongside the TeX document like any other figure. This can be done as follows. Add the following lines to the header of your TeX document:

\usetikzlibrary{external}
\tikzexternalize[shell escape=-shell-escape,prefix=./figs]

Then compile your TeX document with the following flags:

pdflatex --shell-escape --enable-write18 your_document.tex

After compilation you will find all your TikZ figures saved as separate PDF documents (here they will have the prefix "figs").

This works very well, however, I am aware of one potential issue concerning arrowheads at the edge of the figure (which unfortunately occur often in Feynman diagrams), which may be cut off. In this case you need to code additional white space into the TikZ figure, enclosing the arrowheads, so that it is not cropped during the compilation. It is enough to add an additional node{...} into your TikZ figure to ensure that white space is not cropped here.

Table of contents

  • No labels