Documentation/Specialized Notation/How to Write Braket Notation and Feynman Diagrams in LaTeX
Specialized Notation

How to Write Braket Notation and Feynman Diagrams in LaTeX

Quantum mechanics and quantum field theory require specialized notation: Dirac bra-ket notation for states and operators, and Feynman diagrams for particle interactions. LaTeX has excellent packages for both — the physics/braket packages for notation and tikz-feynman for diagrams. This tutorial covers the full workflow for typesetting physics papers. Bibby AI renders Feynman diagrams in real time, which is crucial for getting vertex positions and propagator routing right — a task that's painfully slow with Overleaf's compile cycle.

Typeset Braket Notation with the physics Package

Use the physics package for Dirac notation, operators, derivatives, and other quantum mechanics typesetting:

\documentclass{article}
\usepackage{physics}  % Comprehensive physics notation
\usepackage{amsmath}

\begin{document}

\section{Dirac Notation}

% Bras, kets, and brakets
$\ket{\psi}$ \quad $\bra{\phi}$ \quad $\braket{\phi}{\psi}$ \quad $\ip{\phi}{\psi}$

% Matrix elements and expectation values
$\mel{\phi}{\hat{H}}{\psi}$ \quad $\ev{\hat{A}}{\psi}$ \quad $\ev{\hat{A}}$

% Outer product and projection
$\op{\psi}{\psi}$ \quad $\dyad{n}{m}$

% Commutators and anti-commutators
$\comm{\hat{A}}{\hat{B}}$ \quad $\acomm{\hat{x}}{\hat{p}}$

\section{Derivatives and Operators}

% Derivatives
$\dv{f}{x}$ \quad $\dv[2]{f}{x}$ \quad $\pdv{f}{x}$ \quad $\pdv{f}{x}{y}$

% Vector operators
$\grad{\phi}$ \quad $\div{\vb{F}}$ \quad $\curl{\vb{F}}$ \quad $\laplacian{\psi}$

% Schrödinger equation
\[
i\hbar \pdv{t} \ket{\psi(t)} = \hat{H} \ket{\psi(t)}
\]

\end{document}

Draw Feynman Diagrams with tikz-feynman

Use the tikz-feynman package to create publication-quality Feynman diagrams for QED, QCD, and other field theories:

% Requires LuaLaTeX for automatic layout
\documentclass{article}
\usepackage{tikz-feynman}
\tikzfeynmanset{compat=1.1.0}

\begin{document}

% QED vertex: electron-photon interaction
\[
\feynmandiagram [horizontal=a to b] {
    i1 [particle=$e^-$] -- [fermion] a -- [fermion] i2 [particle=$e^-$],
    a -- [photon, edge label=$\gamma$] b [particle={}],
};
\]

% Electron-positron annihilation: e+e- → γγ
\[
\feynmandiagram [horizontal=a to b] {
    i1 [particle=$e^-$] -- [fermion] a -- [fermion] b -- [fermion] i2 [particle=$e^+$],
    a -- [photon, momentum=$k_1$] f1 [particle=$\gamma$],
    b -- [photon, momentum=$k_2$] f2 [particle=$\gamma$],
};
\]

% Compton scattering with manual positioning
\[
\begin{tikzpicture}
\begin{feynman}
    \vertex (a);
    \vertex [right=of a] (b);
    \vertex [above left=of a] (i1) {$e^-$};
    \vertex [below left=of a] (i2) {$\gamma$};
    \vertex [above right=of b] (f1) {$e^-$};
    \vertex [below right=of b] (f2) {$\gamma$};

    \diagram* {
        (i1) -- [fermion] (a) -- [fermion] (b) -- [fermion] (f1),
        (i2) -- [photon] (a),
        (b) -- [photon] (f2),
    };
\end{feynman}
\end{tikzpicture}
\]

\end{document}

💡 Tips

  • The physics package overrides some amsmath commands — load it after amsmath to get the physics versions.
  • tikz-feynman's automatic layout requires LuaLaTeX. For pdfLaTeX, use manual vertex positioning.
  • Use \feynmandiagram for simple diagrams and the feynman environment inside tikzpicture for complex ones.
  • For the braket package alone (without the full physics package), use \usepackage{braket} for just \Bra, \Ket, \Braket commands.

Try This in Bibby AI

Write LaTeX faster with AI auto-complete and instant compilation.

Start Writing Free

Related Tutorials

How to Write Braket Notation and Feynman Diagrams in LaTeX | Bibby AI