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 |
|---|---|---|
|
2cm |
Horizontal spacing between columns |
|
0.5cm |
Vertical spacing between vertices in a column |
|
0.7cm |
Horizontal offset for intermediate vertices ( |
|
0.3cm |
Vertical offset for intermediate vertices ( |
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 |
|---|---|---|
|
2em |
Horizontal spacing between columns |
|
0.1ex |
Vertical spacing between vertices |
|
0.6em |
Horizontal offset for intermediate vertices |
|
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 |
|---|---|---|
|
2em |
Horizontal spacing between columns |
|
1ex |
Vertical spacing between vertices |
|
0.6em |
Horizontal offset for intermediate vertices |
|
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 |
|---|---|
|
Optional coordinate offset for the entire column |
|
Comma-separated list of vertex names |
|
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 |
|---|---|
|
Particle style and/or TikZ options (e.g., |
|
List of vertices defining the path |
|
Positioning for intermediate vertices ( |
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 |
|
Solid line with arrow |
|
Photon |
|
Wavy line (sine wave) |
|
W Boson |
|
Coiled double line (1pt spacing) |
|
Z Boson |
|
Coiled double line (2pt spacing) |
|
Higgs |
|
Dotted line |
|
Gluon |
|
Coiled line |
|
Graviton |
|
Double coiled line |
|
Loop Style
Style |
Description |
Usage |
|---|---|---|
|
Creates a looping arc between vertices |
|
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 |
|---|---|---|
|
Small filled circle for interaction vertices |
|
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 |
|---|---|
|
Place vertex to the right (offset by |
|
Place vertex to the left (offset by |
|
Place vertex upward (offset by |
|
Place vertex downward (offset by |
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: