4.2. Latex Basics#
last update: Feb 07, 2024
4.2.1. Inline equations#
You can write inline equations by using $.
Example
The equation $E=mc^2$ is the most famous equation in physics.
The equation \(E=mc^2\) is the most famous equation in physics.
4.2.2. Display equations#
You can write display equations by using $$ or \[ \].
Example
Schrodinger equation:
$$
    i\hbar\frac{\partial}{\partial t}|\psi(t)\rangle = H |\psi(t)\rangle
$$
Schrodinger equation:
Tip
You can use shorter commands with physics package.
\begin{align} i\hbar\pdv{t} \ket{\psi(t)} = H \ket{\psi(t)} \end{align}\[\begin{align} i\hbar\pdv{t} \ket{\psi(t)} = H \ket{\psi(t)} \end{align}\]
4.2.3. Basic Symbols#
Greek letters#
Command  | 
Symbol  | 
|---|---|
  | 
\(\alpha\)  | 
  | 
\(\beta\)  | 
  | 
\(\gamma\)  | 
  | 
\(\delta\)  | 
  | 
\(\epsilon\)  | 
  | 
\(\zeta\)  | 
  | 
\(\eta\)  | 
  | 
\(\theta\)  | 
  | 
\(\iota\)  | 
  | 
\(\kappa\)  | 
  | 
\(\lambda\)  | 
  | 
\(\mu\)  | 
  | 
\(\nu\)  | 
  | 
\(\xi\)  | 
  | 
\(\pi\)  | 
  | 
\(\rho\)  | 
  | 
\(\sigma\)  | 
  | 
\(\tau\)  | 
  | 
\(\upsilon\)  | 
  | 
\(\phi\)  | 
  | 
\(\chi\)  | 
  | 
\(\psi\)  | 
  | 
\(\omega\)  | 
  | 
\(\Gamma\)  | 
  | 
\(\Delta\)  | 
  | 
\(\Theta\)  | 
  | 
\(\Lambda\)  | 
  | 
\(\Xi\)  | 
  | 
\(\Pi\)  | 
  | 
\(\Sigma\)  | 
  | 
\(\Upsilon\)  | 
  | 
\(\Phi\)  | 
  | 
\(\Psi\)  | 
  | 
\(\Omega\)  | 
Operators#
Command  | 
Symbol  | 
|---|---|
  | 
\(+\)  | 
  | 
\(-\)  | 
  | 
\(=\)  | 
  | 
÷  | 
  | 
\(\frac{a}{b}\)  | 
  | 
\(\times\)  | 
  | 
\(\pm\)  | 
Note
In physics package, \div is replaced by \(\nabla\cdot\)
Big Operators#
Command  | 
Symbol  | 
|---|---|
  | 
\(\lim x\)  | 
  | 
\(\lim_{x \to \infty} x\)  | 
  | 
\(\lim\limits_{x \to \infty} x\)  | 
  | 
\(\sum x\)  | 
  | 
\(\sum_{i=1}^n x\)  | 
  | 
\(\sum\limits_{i=1}^n x\)  | 
  | 
\(\prod_{i=1}^n x\)  | 
  | 
\(\coprod_{i=1}^n x\)  | 
  | 
\(\bigcup_{i=1}^n x\)  | 
  | 
\(\bigcap_{i=1}^n x\)  | 
  | 
\(\bigvee_{i=1}^n x\)  | 
  | 
\(\bigwedge_{i=1}^n x\)  | 
  | 
\(\bigsqcup_{i=1}^n x\)  | 
  | 
\(\bigodot_{i=1}^n x\)  | 
  | 
\(\bigotimes_{i=1}^n x\)  | 
  | 
\(\int_a^b x\)  | 
  | 
\(\oint_a^b x\)  | 
  | 
\(\iint_a^b x\)  | 
  | 
\(\iiint_a^b x\)  | 
Miscellaneous#
Command  | 
Symbol  | 
|---|---|
  | 
\(\forall\)  | 
  | 
\(\exists\)  | 
  | 
\(\partial\)  | 
  | 
\(\nabla\)  | 
  | 
\(\infty\)  | 
  | 
\(\dots\)  | 
  | 
\(\cdot\)  | 
  | 
\(\cdots\)  | 
  | 
\(\vdots\)  | 
  | 
\(\ddots\)  | 
  | 
\(\therefore\)  | 
  | 
\(\because\)  | 
  | 
\(\clubsuit\)  | 
  | 
\(\diamondsuit\)  | 
  | 
\(\heartsuit\)  | 
  | 
\(\spadesuit\)  | 
  | 
\(\prime\)  | 
  | 
\(f^\prime\)  | 
  | 
\(\angle\)  | 
Dots
Functions#
Command  | 
Symbol  | 
|---|---|
  | 
\(\sqrt{x}\)  | 
  | 
\(\sqrt[n]{x}\)  | 
  | 
\(\sin x\)  | 
  | 
\(\cos x\)  | 
  | 
\(\tan x\)  | 
  | 
\(\cot x\)  | 
  | 
\(\sec x\)  | 
  | 
\(\csc x\)  | 
  | 
\(\arcsin x\)  | 
  | 
\(\arccos x\)  | 
  | 
\(\arctan x\)  | 
  | 
\(\sinh x\)  | 
  | 
\(\cosh x\)  | 
  | 
\(\tanh x\)  | 
  | 
\(\coth x\)  | 
  | 
\(\log x\)  | 
  | 
\(\ln x\)  | 
  | 
\(\exp x\)  | 
  | 
\(\binom{n}{k}\)  | 
Tip
You can wirte \sum\limits_{i=1}^n x instead of \sum_{i=1}^n x to make the limits appear above and below the symbol.
You can wirte \(\sum\limits_{i=1}^n x\) instead of \(\sum_{i=1}^n x\) to make the limits appear above and below the symbol.
Relations#
Command  | 
Symbol  | 
|---|---|
  | 
\(a = b\)  | 
  | 
\(a \neq b\)  | 
  | 
\(a \approx b\)  | 
  | 
\(a \equiv b\)  | 
  | 
\(a \leq b\)  | 
  | 
\(a \geq b\)  | 
  | 
\(a \ll b\)  | 
  | 
\(a \gg b\)  | 
  | 
\(a \sim b\)  | 
  | 
\(a \propto b\)  | 
  | 
\(a \subset b\)  | 
  | 
\(a \supset b\)  | 
  | 
\(a \subseteq b\)  | 
  | 
\(a \supseteq b\)  | 
  | 
\(a \in b\)  | 
  | 
\(a \ni b\)  | 
  | 
\(a \notin b\)  | 
  | 
\(a \mapsto b\)  | 
  | 
\(a \to b\)  | 
  | 
\(a \gets b\)  | 
  | 
\(a \leftrightarrow b\)  | 
  | 
\(a \Leftrightarrow b\)  | 
  | 
\(a \implies b\)  | 
  | 
\(a \impliedby b\)  | 
  | 
\(a \iff b\)  | 
  | 
\(a \to b\)  | 
  | 
\(a \gets b\)  | 
  | 
\(a \uparrow b\)  | 
  | 
\(a \downarrow b\)  | 
  | 
\(a \updownarrow b\)  | 
  | 
\(a \Uparrow b\)  | 
  | 
\(a \Downarrow b\)  | 
  | 
\(a \Updownarrow b\)  | 
  | 
\(a \mid b\)  | 
  | 
\(a \parallel b\)  | 
  | 
\(a \perp b\)  | 
  | 
\(a \smile b\)  | 
  | 
\(a \frown b\)  | 
  | 
\(a \vdash b\)  | 
  | 
\(a \dashv b\)  | 
Spaces#
Command  | 
Symbol  | 
|---|---|
  | 
\(a \! b\)  | 
  | 
\(a \, b\)  | 
  | 
\(a \: b\)  | 
  | 
\(a \; b\)  | 
  | 
\(a \hspace{1pt} b\)  | 
  | 
\(a \hspace{1mm} b\)  | 
  | 
\(a \hspace{1ex} b\)  | 
  | 
\(a \hspace{1em} b\)  | 
  | 
\(a \quad b\)  | 
  | 
\(a \qquad b\)  | 
  | 
\(a \hspace{1cm} b\)  | 
  | 
\(a \hspace{1in} b\)  | 
Brackets and Parentheses#
Command  | 
Symbol  | 
|---|---|
  | 
\((A)\)  | 
  | 
\([A]\)  | 
  | 
\(\{A\}\)  | 
  | 
\(\langle A \rangle\)  | 
  | 
\(\vert A \vert\)  | 
  | 
\(\Vert A \Vert\)  | 
  | 
\(\lfloor A \rfloor\)  | 
  | 
\(\lceil A \rceil\)  | 
Accents#
Command  | 
Symbol  | 
|---|---|
  | 
\(\hat{a}\)  | 
  | 
\(\check{a}\)  | 
  | 
\(\tilde{a}\)  | 
  | 
\(\acute{a}\)  | 
  | 
\(\grave{a}\)  | 
  | 
\(\dot{a}\)  | 
  | 
\(\ddot{a}\)  | 
  | 
\(\breve{a}\)  | 
  | 
\(\bar{a}\)  | 
  | 
\(\vec{a}\)  | 
Styles#
Command  | 
Example  | 
|---|---|
  | 
\(\mathit{A\,B\,C\,D\,E\,F\,G\,H\,I\,J\,K\,L\,M\,N\,O\,P\,Q\,R\,S\,T\,U\,V\,W\,X\,Y\,Z}\)  | 
  | 
\(\mathrm{A\,B\,C\,D\,E\,F\,G\,H\,I\,J\,K\,L\,M\,N\,O\,P\,Q\,R\,S\,T\,U\,V\,W\,X\,Y\,Z}\)  | 
  | 
\(\mathsf{A\,B\,C\,D\,E\,F\,G\,H\,I\,J\,K\,L\,M\,N\,O\,P\,Q\,R\,S\,T\,U\,V\,W\,X\,Y\,Z}\)  | 
  | 
\(\mathbf{A\,B\,C\,D\,E\,F\,G\,H\,I\,J\,K\,L\,M\,N\,O\,P\,Q\,R\,S\,T\,U\,V\,W\,X\,Y\,Z}\)  | 
  | 
\(\mathcal{A\,B\,C\,D\,E\,F\,G\,H\,I\,J\,K\,L\,M\,N\,O\,P\,Q\,R\,S\,T\,U\,V\,W\,X\,Y\,Z}\)  | 
  | 
\(\mathfrak{A\,B\,C\,D\,E\,F\,G\,H\,I\,J\,K\,L\,M\,N\,O\,P\,Q\,R\,S\,T\,U\,V\,W\,X\,Y\,Z}\)  | 
  | 
\(\mathbb{A\,B\,C\,D\,E\,F\,G\,H\,I\,J\,K\,L\,M\,N\,O\,P\,Q\,R\,S\,T\,U\,V\,W\,X\,Y\,Z}\)  | 
Matrices#
Symbol  | 
Command  | 
|---|---|
  | 
\(\begin{pmatrix} a \\ b \end{pmatrix}\)  | 
  | 
\(\begin{pmatrix} a & b \\ c & d \end{pmatrix}\)  | 
  | 
\(\begin{bmatrix} a & b \\ c & d \end{bmatrix}\)  | 
  | 
\(\begin{vmatrix} a & b \\ c & d \end{vmatrix}\)  | 
  | 
\(\begin{Vmatrix} a & b \\ c & d \end{Vmatrix}\)  | 
4.2.4. amsmath package#
You can use amsmath package to use more commands, such as cases and align.
cases#
You can use cases environment to write piecewise functions.
\begin{align} f(x) = \begin{cases} 0 & (x < 0) \\ 1 & (x \geq 0) \end{cases} \end{align}\[\begin{split}\begin{align} f(x) = \begin{cases} 0 & (x < 0) \\ 1 & (x \geq 0) \end{cases} \end{align}\end{split}\]
align#
You can align equations by using align environment. You can align equations by &.
\begin{align} f(x) &= \int_{0}^{x} \left( \frac{1}{2}t^3 - 3t^2 + 4t + 7 \right) dt \\ &= \left[ \frac{1}{8}t^4 - t^3 + 2t^2 + 7t \right]_{0}^{x} \\ &= \frac{1}{8}x^4 - x^3 + 2x^2 + 7x \end{align}\[\begin{split}\begin{align} f(x) &= \int_{0}^{x} \left( \frac{1}{2}t^3 - 3t^2 + 4t + 7 \right) dt \\ &= \left[ \frac{1}{8}t^4 - t^3 + 2t^2 + 7t \right]_{0}^{x} \\ &= \frac{1}{8}x^4 - x^3 + 2x^2 + 7x \end{align}\end{split}\]
4.2.5. physics package#
You can use physics package to use more commands, such as \qty, \dv, pdv, \eval, \order, \abs, \norm, \commutator [or \comm], \anticommutator [or \acomm]
\qty#
You can use \qty command to write adaptive parentheses instead of \left and \right.
\begin{align} \qty( \frac{1}{2} ) \quad \qty[ \frac{1}{2} ] \quad \qty{ \frac{1}{2} } \end{align}\[\begin{align} \qty( \frac{1}{2} ) \quad \qty[ \frac{1}{2} ] \quad \qty{ \frac{1}{2} } \end{align}\]
dv#
You can use dv command to write derivatives easily.
\begin{align} \dv{x} \sin{x} = \cos{x} \end{align}\[\begin{align} \dv{x} \sin{x} = \cos{x} \end{align}\]
pdv#
You can use pdv command to write partial derivatives easily.
\begin{align} \pdv{x} f(x, y), \quad \pdv{f}{x}, \quad \pdv{f}{x}{y}, \quad \pdv[2]{f}{x} \end{align}\[\begin{align} \pdv{x} f(x, y), \quad \pdv{f}{x}, \quad \pdv{f}{x}{y}, \quad \pdv[2]{f}{x} \end{align}\]
\eval#
You can use \eval command to write evaluation easily.
\begin{align} \eval{x^2}_{x=1}, \quad \eval{x^{-2}}_{1}^{\infty} \end{align}\[\begin{align} \eval{x^2}_{x=1}, \quad \eval{x^{-2}}_{1}^{\infty} \end{align}\]
\order#
You can use \order command to write order easily.
\begin{align} \order{x^2}, \quad \order{\frac{1}{x^2}} \end{align}\[\begin{align} \order{x^2}, \quad \order{\frac{1}{x^2}} \end{align}\]
\abs#
You can use \abs command to write absolute value easily.
\begin{align} \abs{x}, \quad \abs{\frac{1}{x}} \end{align}\[\begin{align} \abs{x}, \quad \abs{\frac{1}{x}} \end{align}\]
\norm#
You can use \norm command to write norm easily.
\begin{align} \norm{x}, \quad \norm{\frac{1}{x}} \end{align}\[\begin{align} \norm{x}, \quad \norm{\frac{1}{x}} \end{align}\]
\commutator [or \comm]#
You can use \commutator command to write commutator easily.
\begin{align} \commutator{A}{B}, \quad \comm{A}{B} \end{align}\[\begin{align} \commutator{A}{B}, \quad \comm{A}{B} \end{align}\]
\anticommutator [or \acomm]#
You can use \anticommutator command to write anticommutator easily.
\begin{align} \anticommutator{A}{B}, \quad \acomm{A}{B} \end{align}\[\begin{align} \anticommutator{A}{B}, \quad \acomm{A}{B} \end{align}\]
Vector notation#
Command  | 
Output  | 
|---|---|
  | 
\(\va{a}\)  | 
  | 
\(\vb{a}\)  | 
  | 
\(\grad{a}\)  | 
  | 
\(\curl{a}\)  | 
  | 
\(\div{a}\)  | 
  | 
\(\laplacian{a}\)  | 
Operators#
Command  | 
Output  | 
|---|---|
  | 
\(\tr[A]\)  | 
  | 
\(\Tr[A]\)  | 
  | 
\(\rank M\)  | 
  | 
\(\erf\)  | 
  | 
\(\Res\)  | 
  | 
\(\pv{\int f(z) \dd{z}}\)  | 
  | 
\(\Re\)  | 
  | 
\(\Im\)  | 
Dirac bra-ket notation#
Command  | 
Output  | 
|---|---|
  | 
\(\ket{a}\)  | 
  | 
\(\bra{a}\)  | 
  | 
\(\braket{a}\)  | 
  | 
\(\braket{a}{b}\)  | 
  | 
\(\dyad{a}\)  | 
  | 
\(\dyad{a}{b}\)  | 
  | 
\(\expval{A}\)  | 
  | 
\(\ev{A}\)  | 
  | 
\(\expval{A}{a}\)  | 
  | 
\(\ev{A}{a}\)  | 
  | 
\(\mel{a}{A}{b}\)  | 
Matrices#
Command  | 
Output  | 
|---|---|
  | 
\(\mqty(a & b \\ c & d)\)  | 
  | 
\(\mqty[ a & b \\ c & d ]\)  | 
  | 
\(\vmqty{a & b \\ c & d}\)  | 
  | 
\(\mqty[\imat{2}]\)  | 
  | 
\(\mqty[\pmat{0}]\)  | 
  | 
\(\mqty[\pmat{1}]\)  | 
  | 
\(\mqty[\pmat{2}]\)  | 
  | 
\(\mqty[\pmat{3}]\)  | 
  | 
\(\mqty(\dmat{1,2,3})\)  | 
  | 
\(\mqty(\admat{1,2,3})\)  |