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\lbrace
and\rbrace
. For example,\{a*b\}
or\lbrace a*b \rbrace
will display as. Angle Brackets
Use
\langle
and\rangle
to represent left and right angle brackets, respectively. For example,\langle x \rangle
:. Ceil
Use
\lceil
and\rceil
for the ceiling function. For example,. Floor
Use
\lfloor
and\rfloor
for 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\frac
operates on the two groups a and b, yielding. If the numerator or denominator consists of more than one character, use {}
for grouping.Use
\over
to 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
\it
to display italics (the default font for formulas)\it{ABCDEFGHIJKLMnopqrstuvwxyz}
:Use
\mathbb
or\Bbb
to display blackboard bold (blackboard font)\mathbb{ABCDEFGHIJKLMnopqrstuvwxyz}
:Use
\mathbf
or\bf
to display bold\mathbf{ABCDEFGHIJKLMnopqrstuvwxyz}
:Use
\mathtt
or\tt
to display typewriter font\mathtt{ABCDEFGHIJKLMnopqrstuvwxyz}
:Use
\mathrm
or\rm
to display Roman font\mathrm{ABCDEFGHIJKLMnopqrstuvwxyz}
:Use
\mathsf
or\sf
to display sans-serif\mathsf{ABCDEFGHIJKLMnopqrstuvwxyz}
:Use
\mathcal
or\cal
to display calligraphic font\mathcal{ABCDEFGHIJKLMnopqrstuvwxyz}
:Use
\mathscr
or\scr
to display script font\mathscr{ABCDEFGHIJKLMnopqrstuvwxyz}
:Use
\mathfrak
or\frak
to display Fraktur (old German) font\mathfrak{ABCDEFGHIJKLMnopqrstuvwxyz}
:Use
\mit
to 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
\pmod
to indicate modular arithmetic, such asa\equiv b\pmod n
:. Use
\ldots
and\cdots
for 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
\overline
and\underline
to 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
: