Base Syntax
TIP
Note
This site uses the MathJax rendering engine by default, so the following syntax is written according to MathJax. The Katex syntax is mostly similar to MathJax, with only a few differences. In case of errors, consult the official documentation of both.
$, and display formulas, wrapped in a pair of $$.
Inline Formula:
Example of an inline formula:
, written as $E=mc^2$.Display Formula:
Written as:
$$\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}$$
Greek Letters
| Display | Input | Display | Input |
|---|---|---|---|
\alpha A | \nu N | ||
\beta B | \xi \Xi | ||
\gamma \Gamma | o O | ||
\delta \Delta | \pi \Pi | ||
\epsilon \varepsilon E | \rho \varrho P | ||
\zeta Z | \sigma \Sigma | ||
\eta H | \tau T | ||
\theta \vartheta \Theta | \upsilon \Upsilon | ||
\iota I | \phi \varphi \Phi | ||
\kappa K | \chi X | ||
\lambda \Lambda | \psi \Psi | ||
\mu M | \omega \Omega |
Superscripts and Subscripts
Use ^ for superscripts and _ for subscripts. For example, x_i^2: \log_2 x:
By default, superscripts and subscripts only apply to the next character or group enclosed in {}. For example, 10^10 gives 10^{10} gives
Curly braces can also help avoid ambiguity. For instance, x^5^6 would result in an error, so you need to use braces to clarify as in {x^5}^6$: x^{5^6}:
Be mindful of the difference between
x_i^2: x_{i^2}:
You can also use \sideset to have superscripts and subscripts on both sides of a symbol, such as \sideset{^1_2}{^3_4}\bigotimes:
Brackets
Parentheses and Square Brackets
Use
()and[]as they are. For example,(2+3)[4+4]:. Curly Braces
Since curly braces
{}are used for grouping, you need to use\{and\}to display them. Alternatively, you can use\lbraceand\rbrace. For example,\{a*b\}or\lbrace a*b \rbracewill display as. Angle Brackets
Use
\langleand\rangleto represent left and right angle brackets, respectively. For example,\langle x \rangle:. Ceil
Use
\lceiland\rceilfor the ceiling function. For example,. Floor
Use
\lfloorand\rfloorfor the floor function. For example,.
Note
Original parentheses do not scale with formula size.
For example, (\frac12) renders as \left( ... \right) to automatically adjust the size of the parentheses. For example, \left( \frac12 \right) renders as
It is clear that the parentheses in the second formula have been scaled.
Summation and Integration
Use \sum for the summation symbol. The upper and lower limits of the summation are specified by subscripts and superscripts. For example, \sum_1^n:
Use \int for the integral symbol, with limits represented similarly. For example, \int_1^\infty:
Other similar symbols include \prod: \bigcup: \bigcap: \iint:
Fractions and Roots
There are two ways to write fractions:
Use
\frac ab, where\fracoperates on the two groups a and b, yielding. If the numerator or denominator consists of more than one character, use {}for grouping.Use
\overto split the expression into two parts, as in{a+1\over b+1}:.
Roots are written using \sqrt[a]b, where the value in square brackets represents the root index. If omitted, it represents a square root. For example, \sqrt[4]{\frac xy}: \sqrt{x^3}:
Fonts
Use
\itto display italics (the default font for formulas)\it{ABCDEFGHIJKLMnopqrstuvwxyz}:Use
\mathbbor\Bbbto display blackboard bold (blackboard font)\mathbb{ABCDEFGHIJKLMnopqrstuvwxyz}:Use
\mathbfor\bfto display bold\mathbf{ABCDEFGHIJKLMnopqrstuvwxyz}:Use
\mathttor\ttto display typewriter font\mathtt{ABCDEFGHIJKLMnopqrstuvwxyz}:Use
\mathrmor\rmto display Roman font\mathrm{ABCDEFGHIJKLMnopqrstuvwxyz}:Use
\mathsfor\sfto display sans-serif\mathsf{ABCDEFGHIJKLMnopqrstuvwxyz}:Use
\mathcalor\calto display calligraphic font\mathcal{ABCDEFGHIJKLMnopqrstuvwxyz}:Use
\mathscror\scrto display script font\mathscr{ABCDEFGHIJKLMnopqrstuvwxyz}:Use
\mathfrakor\frakto display Fraktur (old German) font\mathfrak{ABCDEFGHIJKLMnopqrstuvwxyz}:Use
\mitto display italicized numbers\mit{1234567890}:
Special Functions and Symbols
Relational Operators
Input Display Input Display Input Display Input Display \pm \mp \times \div \mid \nmid \circ \bullet \cdot \ast \odot \bigodot \otimes \bigotimes \oplus \bigoplus \lt \gt \leq \geq \neq \approx \equiv \sim \simeq \cong \prec \lhd \sum \prod \coprod Set Operators
Input Display Input Display Input Display Input Display \emptyset \varnothing \in \notin \subset \supset \cup \cap \subseteq \supseteq \subsetneq \supsetneq \bigcup \bigcap \bigvee \bigwedge \uplus \biguplus \sqcup \bigsqcup Logarithmic Operators
Input Display Input Display Input Display \log \lg \ln Trigonometric Operators
Input Display Input Display Input Display \bot \angle 30^\circ \sin \cos \tan \cot \sec \csc Calculus Operators
Input Display Input Display Input Display \prime \int \iint \iiint \iiiint \oint \lim \infty \nabla Logical Operators
Input Display Input Display Input Display Input Display \because \therefore \forall \exists \not \lnot \vdash \vDash \land \lor \top \bot Arrow Symbols
Input Display Input Display Input Display Input Display \uparrow \downarrow \rightarrow(\to) \leftarrow \Uparrow \Downarrow \Rightarrow \Leftarrow \longrightarrow \longleftarrow \Longrightarrow \Longleftarrow \mapsto Use
{n+1 \choose 2k}or\binom{n+1}{2k}to denote combinations:. Use
\pmodto indicate modular arithmetic, such asa\equiv b\pmod n:. Use
\ldotsand\cdotsfor ellipses. The difference between them is the position of the dots. ldots is slightly lower, as ina_1,a_2\ldots,a_n:; cdots is centered, as in a_1+a_2+\cdots+a_n:. Use
\overlineand\underlineto denote overlines and underlines, such as\overline{a+b+c+d}:, and \underline{x+y+z}:. Other special characters include
\star:, \aleph_0:, \partial:, \Im:, \Re:. Some Greek letters have variant forms, such as
\epsilon \varepsilon:, and \phi \varphi:. Note that some special characters can be escaped to their original meanings using
\, such as\$representing, and \_representing.
Spaces
When writing formulas, no matter how many spaces are entered between "a" and "b", the output will always be "ab". To insert a small space between them, you can add \, between "a" and "b", as in a\,b: \; increases the space more, as in a\;b: \quad and \qquad create even larger spaces, such as a \quad b: a \qquad b:
Top Symbols
For single characters, you can use \hat x: \widehat {xy}:
Other similar symbols include \check x: \breve x: \bar x: \overline {xyz}: \vec x: \overrightarrow x: \overleftrightarrow {xyz}: \dot x: \ddot x: