Command Reference

This section provides detailed documentation for all tikz-feyn commands and environments.

Environments

tfeyn

Display-style environment for standalone Feynman diagrams.

Syntax:

\begin{tfeyn}[colsep][rowsep][hintsep][vintsep]
  % diagram commands
\end{tfeyn}

Parameters:

Parameter

Default

Description

colsep

2cm

Horizontal spacing between columns

rowsep

0.5cm

Vertical spacing between vertices in a column

hintsep

0.7cm

Horizontal offset for intermediate vertices (r/l)

vintsep

0.3cm

Vertical offset for intermediate vertices (u/d)

Example:

\begin{tfeyn}[3cm][1cm][1cm][0.5cm]
  \tfcol{i,o}
  \tfcol{a,b}
  \tf[f]{i,a}
  \tf[f]{o,b}
\end{tfeyn}

tfeynin

Inline environment for diagrams within text.

Syntax:

\begin{tfeynin}[colsep][rowsep][hintsep][vintsep]
  % diagram commands
\end{tfeynin}

Parameters:

Parameter

Default

Description

colsep

2em

Horizontal spacing between columns

rowsep

0.1ex

Vertical spacing between vertices

hintsep

0.6em

Horizontal offset for intermediate vertices

vintsep

0.05ex

Vertical offset for intermediate vertices

Example:

Consider the diagram
\begin{tfeynin}
  \tfcol{i}\tfcol{o}
  \tf[f]{i,o}
\end{tfeynin}
in the calculation.

tfeynma

Math-mode environment for diagrams in equations.

Syntax:

\begin{tfeynma}[colsep][rowsep][hintsep][vintsep]
  % diagram commands
\end{tfeynma}

Parameters:

Parameter

Default

Description

colsep

2em

Horizontal spacing between columns

rowsep

1ex

Vertical spacing between vertices

hintsep

0.6em

Horizontal offset for intermediate vertices

vintsep

0.3em

Vertical offset for intermediate vertices

Example:

\begin{equation}
  \mathcal{M} =
  \begin{tfeynma}
    \tfcol{i}\tfcol{o}
    \tf[f]{i,o}
  \end{tfeynma}
\end{equation}

Commands

\tfcol

Creates a column of vertices.

Syntax:

\tfcol(xoffset,yoffset){vertex1, vertex2, ...}[spacing]

Parameters:

Parameter

Description

(xoffset,yoffset)

Optional coordinate offset for the entire column

{vertex1, ...}

Comma-separated list of vertex names

[spacing]

Optional vertical spacing between vertices (overrides environment default)

Examples:

\tfcol{i1, i2, i3}              % Three vertices with default spacing
\tfcol{v1, v2}[1.5cm]           % Custom 1.5cm spacing
\tfcol(0, 0.5cm){m1, m2}        % Column shifted up by 0.5cm
\tfcol(0.2cm, -0.3cm){a}[2cm]   % All parameters

Notes:

  • Vertex names can be any valid LaTeX identifier

  • Vertices are positioned vertically from bottom to top

  • First vertex is at the bottom of the column

\tf

Draws an edge (particle propagator) between vertices.

Syntax:

\tf[styles]{vertex1, vertex2, ...}[directions]

Parameters:

Parameter

Description

[styles]

Particle style and/or TikZ options (e.g., f, p, red, thick)

{vertex1, ...}

List of vertices defining the path

[directions]

Positioning for intermediate vertices (r, l, u, d)

Examples:

\tf[f]{i,o}                     % Simple fermion from i to o
\tf[p]{a,b}                     % Photon from a to b
\tf[f]{i, v, o}[r]              % Fermion with intermediate vertex v to the right
\tf[g, red, thick]{v1, v2}      % Thick red gluon
\tf[p, l]{i, o}                 % Photon loop from i to o

Intermediate Vertices:

When more than two vertices are listed, intermediate vertices are created automatically:

\tf[f]{a, b, c}[r]

Creates vertex b to the right of the line between a and c.

Multiple intermediate vertices:

\tf[f]{a, b, c, d}[r, u]

Creates b to the right and c upward along the path from a to d.

Particle Styles

Built-in Styles

Particle

Style Names

Visual

Usage

Fermion

f, fermion

Solid line with arrow

\tf[f]{i,o}

Photon

p, photon

Wavy line (sine wave)

\tf[p]{i,o}

W Boson

w, wboson

Coiled double line (1pt spacing)

\tf[w]{i,o}

Z Boson

z, zboson

Coiled double line (2pt spacing)

\tf[z]{i,o}

Higgs

h, higgs

Dotted line

\tf[h]{i,o}

Gluon

g, gluon

Coiled line

\tf[g]{i,o}

Graviton

G, graviton

Double coiled line

\tf[G]{i,o}

Loop Style

Style

Description

Usage

l, loop

Creates a looping arc between vertices

\tf[f,l]{i,o}

Combine with looseness for control:

\tf[f, l, looseness=1]{i,o}   % Tighter loop
\tf[f, l, looseness=3]{i,o}   % Looser loop

Vertex Style

Style

Description

Usage

vertex

Small filled circle for interaction vertices

\node[vertex] at (v) {};

Example:

\begin{tfeyn}
  \tfcol{i}\tfcol{m}\tfcol{o}
  \tf[f]{i,m}
  \tf[f]{m,o}
  \node[vertex] at (m) {};  % Draw vertex at interaction point
\end{tfeyn}

Custom Styles

Define your own particle styles using \tikzset:

\tikzset{
  scalar/.style={
    dashed,
    thick
  },
  s/.style={scalar}
}

% Use in diagram
\tf[s]{i,o}  % Scalar propagator

Combining Styles

Combine multiple styles and TikZ options:

\tf[f, red]{i,o}                    % Red fermion
\tf[p, blue, thick]{a,b}            % Thick blue photon
\tf[g, green!50!black, ->]{v1,v2}   % Green gluon with arrow
\tf[f, dashed, line width=2pt]{i,o} % Custom dashed line

Direction Specifiers

For intermediate vertices in \tf:

Direction

Description

r

Place vertex to the right (offset by hintsep)

l

Place vertex to the left (offset by hintsep)

u

Place vertex upward (offset by vintsep)

d

Place vertex downward (offset by vintsep)

Example:

\begin{tfeyn}
  \tfcol{a1, a2}
  \tfcol{b1, b2}
  \tf[f]{a1, v1, a2}[r]  % v1 placed to the right
  \tf[f]{b1, v2, b2}[l]  % v2 placed to the left
  \tf[p]{v1, v2}         % Connect the vertices
\end{tfeyn}

Error Handling

tikz-feyn includes validation and helpful error messages:

Insufficient Vertices

\tf[f]{a}  % Error: requires at least 2 vertices

Error Message:

! Package tikz-feyn Error: Insufficient vertices in \tf
(tikz-feyn)                The \tf command requires at least 2 vertices

Undefined Vertex

\tf[f]{a, nonexistent}  % Error: vertex not defined

Error Message:

! Package tikz-feyn Error: Undefined vertex 'nonexistent'
(tikz-feyn)                Vertex 'nonexistent' has not been defined.
(tikz-feyn)                Check your vertex names.

Best Practices

Naming Conventions

Use consistent, descriptive vertex names:

% Good
\tfcol{in1, in2}      % Incoming particles
\tfcol{v1, v2}        % Interaction vertices
\tfcol{out1, out2}    % Outgoing particles

% Avoid
\tfcol{a, b, c, d, e}  % Non-descriptive

Organization

Group related diagram elements:

\begin{tfeyn}
  % Define columns
  \tfcol{i1, i2}
  \tfcol{m1, m2}
  \tfcol{o1, o2}

  % Draw edges
  \tf[f]{i1, m1}
  \tf[f]{i2, m2}
  \tf[p]{m1, m2}
  \tf[f]{m1, o1}
  \tf[f]{m2, o2}
\end{tfeyn}

Comments

Add comments for complex diagrams:

\begin{tfeyn}
  \tfcol{i1, i2}        % Initial state
  \tfcol{v1, v2}        % Interaction vertices
  \tfcol{o1, o2}        % Final state

  \tf[f]{i1, v1}        % Incoming electron
  \tf[f]{i2, v2}        % Incoming positron
  \tf[p]{v1, v2}        % Photon exchange
  \tf[f]{v1, o1}        % Outgoing electron
  \tf[f]{v2, o2}        % Outgoing positron
\end{tfeyn}