The physics package is like a special set of commands that makes writing math and physics equations in LaTeX much easier. It was created by Sergio C. de la Barrera to help scientists and students write complicated formulas without all the usual LaTeX headaches.
Instead of typing out long, confusing commands, this package gives you simple shortcuts that actually make sense.
Automatic Bracing
The automatic bracing commands simplify the typesetting of delimiters like parentheses, brackets, and vertical bars by dynamically adjusting their size based on the enclosed content.
These commands eliminate the need for manual sizing adjustments (e.g., \big
, \Big
) and ensure consistency in mathematical expressions.
Command | Example | Description |
---|---|---|
\qty() |
\qty(a) |
Automatic parentheses |
\qty[] |
\qty[a] |
Automatic square brackets |
\qty\|\| |
\qty\|a\| |
Automatic vertical bars |
\qty{} |
\qty{a} |
Automatic curly braces |
\abs{} |
\abs{a} |
Automatic absolute value |
\norm{} |
\norm{a} |
Automatic norm |
\eval{} |
\eval{x}_0^\infty |
Evaluation bar with limits |
Vector Notation
The vector notation commands standardize the representation of vectors and differential operators, offering flexibility in styling (bold, arrow, or hat notation).
Command | Example Usage | Description |
---|---|---|
\vb{} |
\vb{a} |
Bold vector |
\va{} |
\va{a} |
Vector with arrow |
\vu{} |
\vu{a} |
Unit vector |
\dotproduct |
\vb{a} \dotproduct \vb{b} |
Dot product |
\crossproduct |
\vb{a} \crossproduct \vb{b} |
Cross product |
\grad |
\grad{\psi} |
Gradient |
\div |
\div{\vb{a}} |
Divergence |
\curl |
\curl{\vb{a}} |
Curl |
\laplacian |
\laplacian{\psi} |
Laplacian |
Operators
The operator commands redefine standard functions (e.g., trigonometric, exponential) with automatic bracing and optional power arguments. They also include physics-specific operators like trace and determinant.
Command | Example Usage | Description |
---|---|---|
\sin |
\sin(x) |
Sine function with auto bracing |
\cos |
\cos[2](x) |
Cosine with optional power |
\exp |
\exp(x) |
Exponential function |
\log |
\log(x) |
Logarithm |
\det |
\det(M) |
Determinant |
\tr |
\tr(\rho) |
Trace |
\Tr |
\Tr(\rho) |
Big trace |
\erf |
\erf(x) |
Error function |
Quick Quad Text
These commands insert text within equations while maintaining proper spacing, avoiding clashes with mathematical symbols.
Command | Example Usage | Description |
---|---|---|
\qq{} |
A \qq{and} B |
Text with quads on both sides |
\qif |
x \qif y>0 |
“if” with spacing |
\qthen |
x \qthen y |
“then” with spacing |
\qcomma |
x \qcomma y |
Comma with right quad |
Derivatives
The derivative commands streamline the notation for ordinary, partial, and functional derivatives, with options for inline or fraction forms.
Command | Example Usage | Description |
---|---|---|
\dd |
\dd{x} |
Differential |
\dd[3]{x} |
\dd[3]{x} |
Higher order differential |
\dv{f}{x} |
\dv{f}{x} |
Derivative |
\dv[n]{f}{x} |
\dv[n]{f}{x} |
nth derivative |
\pdv{f}{x} |
\pdv{f}{x} |
Partial derivative |
\fdv{F}{g} |
\fdv{F}{g} |
Functional derivative |
Dirac Bra-Ket Notation
These commands typeset quantum mechanical states and operators with automatic sizing and contractions.
Command | Example Usage | Description |
---|---|---|
\ket{} |
\ket{\psi} |
Ket |
\bra{} |
\bra{\phi} |
Bra |
\braket{} |
\braket{\phi}{\psi} |
Braket |
\dyad{} |
\dyad{\psi} |
Dyad |
\expval{} |
\expval{A} |
Expectation value |
\matrixel{} |
\matrixel{n}{A}{m} |
Matrix element |
Matrix Macros
These macros simplify matrix construction, including special matrices (identity, diagonal) and block matrices.
Command | Example Usage | Description |
---|---|---|
\mqty() |
\mqty(a & b \\ c & d) |
Matrix with parentheses |
\mqty[] |
\mqty[a & b \\ c & d] |
Matrix with brackets |
\imat{n} |
\imat{2} |
Identity matrix |
\xmat{x}{n}{m} |
\xmat{1}{2}{2} |
Matrix filled with x |
\dmat{a,b,c} |
\dmat{1,2,3} |
Diagonal matrix |