Appendix G — Writing Math in LaTeX

This appendix provides a guide on how to write mathematical expressions in LaTeX. This guide can also be used for writing Markdown documents and Jupyter notebooks, as they support LaTeX syntax for mathematical expressions.

G.1 align Environment

The align environment is used to align multiple equations. It is particularly useful for writing systems of equations or long derivations where you want to align the equals signs or other relation symbols.

The following is an example of how to use the align environment in LaTeX. See that all the equations are aligned at the equals sign.

\begin{align}
    a &= b + c \\
    &= d + e + f \\
    &= g + h
\end{align}

\begin{align} a &= b + c \\ &= d + e + f \\ &= g + h \end{align}

G.1.1 Optimization Problem Example

The following is an example of how to write an optimization problem in LaTeX using the align environment.

\begin{align}
    \text{minimize} \quad & f(x) \\
    \text{subject to} \quad & g_i(x) \leq 0, \quad i = 1, \ldots, m \\
    & h_j(x) = 0, \quad j = 1, \ldots, p
\end{align}

\begin{align} \text{minimize} \quad & f(x) \\ \text{subject to} \quad & g_i(x) \leq 0, \quad i = 1, \ldots, m \\ & h_j(x) = 0, \quad j = 1, \ldots, p \end{align}

Sometimes, we prefer to explicitly write the decision variables under the \min or \max sign. In that case, we can use the substack command to write the decision variables under the \min or \max sign.

\begin{align}
    \min_{\substack{\mathbf{x}}} \quad & f(\mathbf{x}) \\
    \text{subject to} \quad & g_i(\mathbf{x}) \leq 0, \quad i = 1, \ldots, m \\
    & h_j(\mathbf{x}) = 0, \quad j = 1, \ldots, p
\end{align}

\begin{align} \min_{\substack{\mathbf{x}}} \quad & f(\mathbf{x}) \\ \text{s.t.} \quad & g_i(\mathbf{x}) \leq 0, \quad i = 1, \ldots, m \\ & h_j(\mathbf{x}) = 0, \quad j = 1, \ldots, p \end{align}