Formula is more expressive than natrual language for abstract concepts.
MathJax
MathJax is a JavaScript display engine for mathematics that works in all browsers. No more setup for readers. It just works.
Basics
When inserting formulas, add math: true
into the meta configuration for the posts first, e.g.
---
layout: post
title: "MathJax Cheatsheet"
author: Xu Chi
toc: true
math: true
tags: [Tech, Markdown, MathJax]
---
For inline formulas, enclose the formula in pair of $
. For displayed formulas, use $$
.
Cheat sheet
Absolute
The absolute value of some expression can be denoted as \lvert x\rvert
or, more generally, as \left\lvert … \right\rvert
. It renders as |x|
.
\lvert x \rvert
\left\lVert x \right\rVert
Definitions by cases
Use \begin{cases}…\end{cases}
. End each case with a \\
, and use &
before parts that should be aligned.
To get a larger vertical space between cases, we can use \\[2ex]
instead of \\
.
Left side:
f(n) =
\begin{cases}
n/2, & \text{if $n$ is even} \\
3n+1, & \text{if $n$ is odd}
\end{cases}
Right side:
\left.
\begin{array}{l}
\text{if $n$ is even:}&n/2\\
\text{if $n$ is odd:}&3n+1
\end{array}
\right\}
=f(n)
Fraction
Nomral fraction
\frac{(1+n)}{n}
Greek letters
# Greek letters
\alpha, \beta, …, \omega
# For uppercase
\Gamma, \Delta, …, \Omega
Mean
\overline A
Spaces and break line
space: \
break line: \\
Sum
\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}
Superscripts and subscripts
For superscripts and subscripts, use ^ and _
x_i^2, \log_2
Symbols and notations
\lt \gt \le \leq \leqq \leqslant \ge \geq \geqq \geqslant \neq
or
<>≤≤≦⩽≥≥≧⩾≠