LaTeX Math Reference
LaTeX math notation for technical documentation. STEM integration in AsciiDoc, common notation, networking math, and formatting.
LaTeX in AsciiDoc (STEM)
AsciiDoc supports LaTeX math via the :stem: attribute. Antora renders it with MathJax or KaTeX.
Enable STEM in document header
= Page Title
:stem: latexmath
Inline math
The quadratic formula is stem:[x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}].
Block math (display mode)
[stem]
++++
\sum_{i=1}^{n} i = \frac{n(n+1)}{2}
++++
Common Notation
Fractions and exponents
\frac{a}{b} % Fraction
x^{2} % Superscript
x_{i} % Subscript
x^{n}_{i} % Both
\sqrt{x} % Square root
\sqrt[3]{x} % Cube root
Greek letters
\alpha \beta \gamma \delta \epsilon
\theta \lambda \mu \pi \sigma \tau
\phi \omega
\Gamma \Delta \Theta \Lambda \Sigma \Omega
Relations and operators
\leq \geq \neq \approx \equiv
\in \notin \subset \supset
\cup \cap \times \div \pm
\infty \partial \nabla
Networking Math
Subnet calculation
[stem]
++++
\text{Hosts} = 2^{32 - \text{prefix}} - 2
++++
CIDR example: /24 subnet
stem:[2^{32-24} - 2 = 254 \text{ usable hosts}]
Summation, Products, Limits
Summation with bounds
\sum_{i=0}^{n} a_i % Sigma sum
\prod_{i=1}^{n} a_i % Pi product
\lim_{x \to \infty} f(x) % Limit
\int_{a}^{b} f(x)\,dx % Integral
Matrices
Matrix notation
\begin{bmatrix}
a & b \\
c & d
\end{bmatrix}
\begin{pmatrix}
1 & 0 \\
0 & 1
\end{pmatrix}
Logic and Sets
Set notation and logic operators
\forall x \in A % For all
\exists x \in A % There exists
A \cup B % Union
A \cap B % Intersection
A \setminus B % Set difference
\emptyset % Empty set
\{1, 2, 3\} % Explicit set
\mathbb{R}, \mathbb{Z} % Real, Integer sets
Formatting
Text within math mode
\text{if } x > 0 % Roman text in equations
\textbf{bold} % Bold text
\mathbf{x} % Bold math variable
\mathrm{const} % Roman (upright) variable
Spacing in LaTeX
a\,b % Thin space
a\;b % Medium space
a\quad b % Quad space
a\qquad b % Double quad space
Piecewise Functions
Conditional definition
f(x) = \begin{cases}
x^2 & \text{if } x \geq 0 \\
-x & \text{if } x < 0
\end{cases}
Practical Example: Big-O Notation
Algorithm complexity in documentation
Binary search runs in stem:[O(\log n)] time.
Merge sort guarantees stem:[O(n \log n)] worst case.
Hash table lookup is stem:[O(1)] amortized.
See Also
-
AsciiDoc — enables STEM with
:stem: latexmath -
Shell Mathematics — math in the terminal