Physicists write quantum states as kets, such as |ψ⟩, and inner products as brackets, such as ⟨φ|ψ⟩. Paul Dirac introduced this bra-ket notation, and it appears throughout quantum mechanics. The commands below cover the symbols typed by hand, and then the shorter forms from the physics package.
The symbols
Three shapes cover most uses:
- Ket, |ψ⟩: a state.
- Bra, ⟨φ|: the dual of a state.
- Bra-ket, ⟨φ|ψ⟩: an inner product of two states.
Typesetting without extra packages
Base LaTeX provides \langle (⟨), \rangle (⟩) and \vert (|). amsmath adds \lvert and \rvert, which set the bar with the spacing a delimiter needs:
$\lvert \psi \rangle$ % ket
$\langle \phi \rvert$ % bra
$\langle \phi \vert \psi \rangle$ % inner product
These commands work, but they are long to type in a document with many states. The physics package shortens them.
With the physics package
The physics package provides short commands for the same shapes:
\usepackage{physics}
\ket{\psi} % ket
\bra{\phi} % bra
\braket{\phi}{\psi} % inner product
\ketbra{\psi}{\phi} % outer product
For \bra and \ket, the argument goes inside the bar and the angle bracket. \braket takes two arguments: the bra first, then the ket. The package also has shortcuts for expectation values and matrix elements. Its documentation lists them, and texdoc physics opens it. Some authors use the braket package instead, which also provides \braket.
Operators and expectation values
An operator sits between the bra and the ket. Write the operator with \hat{...}:
\[
\langle \psi \rvert \hat{H} \lvert \psi \rangle
\]
The commutator of two operators uses square brackets:
\[
[\hat{A}, \hat{B}] = \hat{A}\hat{B} - \hat{B}\hat{A}
\]
A worked example: the Schrödinger equation
The time-dependent Schrödinger equation has a bra-ket form that many textbooks use:
\[
i \hbar \frac{\partial}{\partial t} \lvert \psi(t) \rangle = \hat{H} \lvert \psi(t) \rangle
\]
With the physics package loaded, the same line becomes \ket{\psi(t)} on both sides.
For states with an index, such as $|\psi_1\rangle$, add the subscript as you would anywhere else. How to use subscript in LaTeX explains the rules.
Common errors
- Undefined control sequence for
\ketor\braket: the package is not loaded. Add\usepackage{physics}or\usepackage{braket}. - Undefined control sequence for
\rvertor\lvert:amsmathis not loaded. - Missing $ inserted: bra-ket commands are math commands, so write them inside
$...$or\[...\]. - Mismatched bars: a ket is
\lvert ... \rangleand a bra is\langle ... \rvert. Pairing the wrong bar with the wrong angle bracket gives an odd-looking symbol.
For a broader list of packages that support physics notation, see packages for mathematics in LaTeX. The advanced mathematics guide covers other math topics in this cluster.