From http://meta.math.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference
-
For inline formulas, enclose the formula in
$...$
. For displayed formulas, use$$...$$
. -
ForGreek letters, use
\alpha
,\beta
, …,\omega
:α,β,…ω. For uppercase, use\Gamma
,\Delta
, …,\Omega
:Γ,Δ,…,Ω.
Formulas
-
Forsuperscripts and subscripts, use
^
and_
.
For example,x_i^2
:x_i^2
-
Groups. Superscripts, subscripts, and other operations apply only to the next “group”. A “group” is either a single symbol, or any formula surrounded by curly braces
{…}
. If you do10^10
, you will get a surprise:
10^10 But
10^{10}
gives what you probably wanted:
10^{10} Use curly braces to delimit a formula to which a superscript or subscript applies:
x^5^6
is an error;{x^y}^z
is
{x^y}^z and
x^{y^z}
is
x^{y^z} Observe the difference between
x_i^2
x_i^2 and
x_{i^2}
x_{i^2}
-
ParenthesesOrdinary symbols
()[]
make parentheses and brackets(2+3)[4+4]. Use\{
and\}
for curly braces{}.
These donotscale with the formula in between, so if you write(\frac{\sqrt x}{y^3})
the parentheses will be too small:
(\frac{\sqrt x}{y^3}) Using
\left(…\right)
.will make the sizes adjust automatically to the formula they enclose:\left(\frac{\sqrt x}{y^3}\right)
is
\left(\frac{\sqrt x}{y^3}\right)
\left
and\right
apply to all the following sorts of parentheses:(and)(x),[
and]
[x],\{
and\}
{x},|
|x|,\langle
and\rangle
⟨x⟩,\lceil
and\rceil
⌈x⌉, and\lfloor
and\rfloor
⌊x⌋. There are also invisible parentheses, denoted by.
:\left.\frac12\right\rbrace
is
\left.\frac12\right\rbrace
-
Sums and integrals
\sum
and\int
; the subscript is the lower limit and the superscript is the upper limit, so for example\sum_1^n
\sum_1^n Don't forget
{
…}
if the limits are more than a single symbol. For example,\sum_{i=0}^\infty i^2
is
\sum_{i=0}^\infty i^2 Similarly,
\prod
∏,\int
∫,\bigcup
⋃,\bigcap⋂,\iint
∬. -
FractionsThere are two ways to make these.
\frac ab
applies to the next two groups, and produces
\frac ab for more complicated numerators and enominators use
{
…}
:\frac{a+1}{b+1}
is
\frac{a+1}{b+1} If the numerator and denominator are complicated, you may prefer
\over
, which splits up the group that it is in:{a+1\over b+1}
is
{a+1\over b+1}
-
Fonts
- Use
\mathbb
or\Bbb
for "blackboard bold":
blackboard bold
- Use
\mathbf
for boldface:
boldface
- Use
\mathtt
for "typewriter" font:
typewriter
- Use
\mathrm
for roman font:
roman
- Use
\mathsf
for sans-serif font:
sans-serif font
- Use
\mathcal
for "calligraphic" letters:
calligraphic
- Use
\mathscr
for script letters:
script
- Use
\mathfrak
for "Fraktur" (old German style) letters:
Fraktur
-
Radical signsUse
sqrt
, which adjusts to the size of its argument:\sqrt{x^3}
:
\sqrt{x^3}
\sqrt[3]{\frac xy}
:
\sqrt[3]{\frac xy} For complicated expressions, consider using
{...}^{1/2}
instead. -
Somespecial functionssuch as "lim", "sin", "max", "ln", and so on are normally set in roman font instead of italic font. Use
\lim
,\sin
, etc. to make these:\sin x
\sin x not
sin x
sin x Use subscripts to attach a notation to
\lim
:\lim_{x\to 0}
\lim_{x\to 0}
-
There are a very large number ofspecial symbols and notations, too many to list here; seethis shorter listing, orthis exhaustive listing. Some of the most common include:
-
\lt
\gt
\le
\ge
\neq
<>≤≥≠. You can use\not
to put a slash through almost anything:\not\lt
≮but it often looks bad. -
\times
\div
\pm
\mp
×÷±∓.\cdot
is a centered dot:x⋅y -
\cup
\cap
\setminus
\subset
\subseteq
\subsetneq
\supset
\in
\notin
\emptyset
\varnothing
∪∩∖⊂⊆⊊⊃∈∉∅∅ -
{n+1
\choose 2k}
or\binom{n+1}{2k}
\binom{n+1}{2k}
-
\to
\rightarrow
\leftarrow
\Rightarrow
\Leftarrow
\mapsto
→→←⇒⇐ -
\land
\lor
\lnot
\forall
\exists
\top
\bot
\vdash
\vDash
∧∨¬∀∃⊤⊥⊢⊨ -
\star
\ast
\oplus
\circ
\bullet
⋆∗⊕∘∙ -
\approx
\sim
\simeq
\cong
\equiv
\prec
≈∼≃≅≡≺ -
\infty
\aleph_0
∞ℵ0\nabla
\partial
∇∂\Im
\Re
ℑℜ - For modular equivalence, use
\pmod
like this:a\equiv b\pmod n
a≡b (mod n). -
\ldots
is the dots in
\ldots an
\cdots
is the dots in
\cdots
- Some Greek letters have variant forms:\epsilon \varepsilonϵε,\phi \varphiϕφ, and others. Script lowercase l is\ellℓ.
Detexifylets you draw a symbol on a web page and then lists theTEXsymbols that seem to resemble it. These are not guaranteed to work in MathJax but are a good place to start. To check that a command is supported, note that MathJax.org maintains alist of currently supportedLATEXcommands, and one can also check Dr. Carol JVF Burns's page of[TEXCommands Available in MathJax(http://www.onemathematicalcat.org/MathJaxDocumentation/TeXSyntax.htm).
-
SpacesMathJax usually decides for itself how to space formulas, using a complex set of rules. Putting extra literal spaces into formulas will not change the amount of space MathJax puts in:
a␣b
anda␣␣␣␣b
are both
ab To add more space, use
\,
for a thin space
a b
\;
for a wider space
a b
\quad
and\qquad
are large spaces:
a b,a b To set plain text, use
\text{…}
:{x∈s∣xis extra large}. You can nest$…$
inside of\text{…}
. -
Accents and diacritical marksUse
\hat
for a single symbol
\hat
\widehat
for a larger formula
\widehat If you make it too wide, it will look silly. Similarly, there are
\bar
\bar and
\overline
\overline and
\vec
\vec and
\overrightarrow
\overrightarrow and
\overleftrightarrow
\overleftrightarrow For dots, as in
\dotand\ddot use
\dot
and\ddot
. -
Special characters used for MathJax interpreting can be escaped using the
\
character:\$
$,\{
{,\_
_, etc. If you want\
itself, you should use\backslash
∖, because\\\
is for a new line.
Examples
- Use
$$\begin{matrix}…\end{matrix}$$
In between the\begin
and\end
, put the matrix elements. End each matrix row with\\\
, and separate matrix elements with&
. For example,
$$
\begin{matrix}
1 & x & x^2 \\
1 & y & y^2 \\
1 & z & z^2 \\
\end{matrix}
$$
produces:

MathJax will adjust the sizes of the rows and columns so that everything fits.
-
To add brackets, either use
\left…\right
as in section 6 of the tutorial, or replacematrix
withpmatrix
Paste_Image.png
bmatrix
Paste_Image.png
Bmatrix
Paste_Image.png
vmatrix
Paste_Image.png
Vmatrix
Paste_Image.png
-
Use
\cdots
⋯\ddots
⋱\vdots
⋮when you want to omit some of the entries:
Paste_Image.png
-
For "augmented" matrices, put parentheses or brackets around a suitably-formatted table; seearraysbelow for details. Here is an example:
Paste_Image.png
$$ \left[
\begin{array}{cc|c}
1&2&3\\
4&5&6
\end{array}
\right] $$
Thecc|c
is the crucial part here; it says that there are three centered columns with a vertical bar between the second and third.
-
For small inline matrices use\bigl(\begin{smallmatrix} ... end{smallmatrix}\bigr), e.g.
Paste_Image.png
is produced by:
$\bigl( \begin{smallmatrix} a & b \\ c & d \end{smallmatrix} \bigr)$
-
Often people want a series of equations where the equals signs are aligned. To get this, use\begin{align}…\end{align}. Each line should end with\, and should contain an ampersand at the point to align at, typically immediately before the equals sign.
For example,
Paste_Image.png
is produced by
\begin{align}
\sqrt{37} & = \sqrt{\frac{73^2-1}{12^2}} \\
& = \sqrt{\frac{73^2}{12^2}\cdot\frac{73^2-1}{73^2}} \\
& = \sqrt{\frac{73^2}{12^2}}\sqrt{\frac{73^2-1}{73^2}} \\
& = \frac{73}{12}\sqrt{1 - \frac{1}{73^2}} \\
& \approx \frac{73}{12}\left(1 - \frac{1}{2\cdot73^2}\right)
\end{align}

by writing this:
f(n) =
\begin{cases}
n/2, & \text{if $n$ is even} \\
3n+1, & \text{if $n$ is odd}
\end{cases}
The brace can be moved to the right:

by writing this:
\left.
\begin{array}{l}
\text{if $n$ is even:}&n/2\\
\text{if $n$ is odd:}&3n+1
\end{array}
\right\}
=f(n)
To get a larger vertical space between cases we can use\\\[2ex]
instead of\\\
. For example, you get this:

by writing this:
f(n) =
\begin{cases}
\frac{n}{2}, & \text{if $n$ is even} \\[2ex]
3n+1, & \text{if $n$ is odd}
\end{cases}
网友评论