Math Jax Tutorial (Math Stack Exchange)
Math Jax Tutorial (Math Stack Exchange)
1 of 68 10-04-2024, 13:03
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
To see how any formula was written in any question or answer, including this one, right-
4026
click on the expression and choose "Show Math As > TeX Commands". (When you do this,
the '$' will not display. Make sure you add these: see the next point. There are also other ways
to view the code for the formula or the whole post.)
To try formatting, visit the formatting sandbox post, select one of the answers that says “free
for editing” and use the “edit” button to edit the answer however you like. Don't forget to
change it back when you are finished, so it can be used again.
These render differently. For example, type the following to show inline mode:
$\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}$
( n 2 + n ) ( 2n + 1 )
∑ ni= 0i 2 = 6
n
(n 2 + n)(2n + 1)
∑ i2 = 6
i=0
For other Greek capital letters, use Latin $A, , B , E$ and so on: A, B, E.
Some Greek letters have variant forms: \epsilon \varepsilon ϵ, ε , \phi \varphi ϕ, φ,
and others.
3. For superscripts and subscripts, use ^ and _ . For example, x_i^2 : x 2i , \log_2 x :
log 2x. For the prime symbol, use an apostrophe x' x'' x''' : x ′ x ″ x ‴.
4. 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 do 10^10 , you will get a surprise: 10 10. But 10^{10} gives what you probably
wanted: 10 10.
5. Parentheses Ordinary symbols ()[] make parentheses and brackets (2 + 3)[4 + 4]. Use
\{ and \} for curly braces {}.
2 of 68 10-04-2024, 13:03
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
These do not scale with the formula in between, so if you write (\frac{\sqrt x}{y^3}
√x
) the parentheses will be too small: ( ). Using \left( … \right) will make the sizes
y3
adjust automatically to the formula they enclose: \left(\frac{\sqrt x}{y^3}\right) is
() √x
y3
.
\left and \right apply to all the following sorts of parentheses: ( and ) (x), [
and ] [x], \{ and \} {x}, | | x | , \vert |x|, \Vert ǁxǁ, \langle and \rangle ⟨x⟩,
\lceil and \rceil ⌈x⌉, and \lfloor and \rfloor ⌊x⌋. \middle can be used to add
additional dividers. There are also invisible parentheses, denoted by . : use
\left.x^2\right\rvert_3^5 = 5^2-3^2 to get
x2 | 5
3
= 52 − 32
6. 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 ∑ n1. Don't forget { … } if the
limits are more than a single symbol. For example, \sum_{i=0}^\infty i^2 is ∑ ∞
i=0
i 2.
7. Fractions There are three ways to make fractions. \frac ab applies to the next two
a
groups, and produces ; for more complicated numerators and denominators use { …}:
b
a+1
\frac{a+1}{b+1} is .
b+1
If the numerator and denominator are complicated, you may prefer \over , which
a+1
splits up the group that it is in: {a+1\over b+1} is b+1
.
8. Fonts
3 of 68 10-04-2024, 13:03
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
9. Radical signs / roots Use sqrt , which adjusts to the size of its argument: \sqrt{x^3}
3
x
√x 3; \sqrt[3]{\frac xy}
√ y
. For complicated expressions, consider using {...}^{1/2}
instead.
10. Some special functions such 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 sinx, not
sin x sinx. Use subscripts to attach a notation to \lim : \lim_{x\to 0}
lim
x→0
11. There are a very large number of special symbols and notations, too many to list
here; see the short listing LATEX and -LATEX Symbols prepared by Dr. Emre Sermutlu,
or the exhaustive listing The Comprehensive LATEX Symbol List by Scott Pakin. 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.
\cup \cap \setminus \subset \subseteq \subsetneq \supset \in \notin \emptyset
\varnothing ∪ , ∩ , ∖ , ⊂ , ⊆ , ⊊ , ⊃ , ∈ , ∉ , ∅, ∅
n+1
{n+1 \choose 2k} or \binom{n+1}{2k} ( 2k
)
\to \gets \rightarrow \leftarrow \Rightarrow \Leftarrow \mapsto \implies \iff →, ←,
→, ←, ⇒, ⇐, ↦, ⟹ , ⟺
For modular equivalence, use \pmod like this: a\equiv b\pmod n a ≡ b (mod n). For the
binary mod operator, use \bmod like this: a\bmod 17 a mod 17.
4 of 68 10-04-2024, 13:03
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
Detexify lets you draw a symbol on a web page and then lists the TEX symbols that seem
to resemble it. These are not guaranteed to work in MathJax, but it's a good place to
start. To check that a command is supported, note that MathJax.org maintains a list of
currently supported LATEX commands, and one can also check Dr. Carol JVF Burns's page
of TEX Commands Available in MathJax.
12. Spaces MathJax 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 and a␣␣␣␣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 ∣ x is extra large}. You can nest $…$ inside of
\text{…} , for example to access spaces.
13. Accents and diacritical marks Use \hat for a single symbol x̂, \widehat for a larger
^
formula xy. If you make it too wide, it will look silly. Similarly, there are \bar xˉ and
¯ → ↔
→
\overline xyz, and \vec x and \overrightarrow xy and \overleftrightarrow xy . For dots,
d
as in dx
xẋ = ẋ 2 + xẍ, use \dot and \ddot .
14. Special characters used for MathJax interpreting can be escaped using the \ character: \
$ $, \{ {, \} }, \_ _, \# #, \& &. If you want \ itself, you should use \backslash
(symbol) or \setminus (binary operation) for ∖, because \\ is for a new line.
It is important that this note be reasonably short and not suffer from too much bloat. To
include more topics, please create short addenda and post them as answers instead of
inserting them into this post.
Contents
Alphabetical list of links to MathJax topics, by title:
5 of 68 10-04-2024, 13:03
Long division • Math Programming • Matrices
Markov Chains • Mixing code and MathJax formatting on lines • The \newcommand
function
39
7
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
Matrices
458 1. 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:
1 x x2
1 y y2
1 z z2
MathJax will adjust the sizes of the rows and columns so that everything fits.
2. To add brackets, either use \left…\right as in section 6 of the tutorial, or replace matrix
with pmatrix
( )
1 2
3 4
, bmatrix
[ ]1 2
3 4
, Bmatrix
{ } 1
3
2
4
, vmatrix
| |1 2
3 4
, Vmatrix
1 2
ǁ ǁ.
3 4
3. Use \cdots ⋯ \ddots ⋱ \vdots ⋮ when you want to omit some of the entries:
1 a1 a 21 ⋯ a n1
1 a2 a 22 ⋯ a n2
⋮ ⋮ ⋮ ⋱ ⋮
1 a m a 2m ⋯ a nm
[ 1
4
2
5
3
6 ]
is produced by:
8 of 68 10-04-2024, 13:03
$$ \left[
\begin{array}{cc|c}
1&2&3\\
4&5&6
\end{array}
\right] $$
The cc|c is the crucial part here; it says that there are three centered columns with a vertical
bar between the second and third.
()
a b
c d
1 0
0 1
is produced by
$$
\begin{pmatrix}
a & b\\
c & d\\
\hline
1 & 0\\
0 & 1
\end{pmatrix}
$$
27
Share Edit Follow Flag edited Nov 22, 2021 at 12:27 answered Aug 28, 2012 at 4:17
Calvin Khor MJD
34.9k 1 24 46 65.4k 9 49 68
5
Share Edit Follow Flag answered Oct 14, 2013 at 20:15 community wiki
user93957
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
Aligned equations
312 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,
73 2 − 1
√37 =
√ 12 2
73 2 73 2 − 1
=
√ 12 2
⋅
73 2
73 2 73 2 − 1
=
√ √
12 2 73 2
73 1
=
12
√1− 2
73
≈
73
12(1−
1
2 ⋅ 73 2 )
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}
The usual $$ marks that delimit the display may be omitted here.
12 of 68 10-04-2024, 13:03
7
Share Edit Follow Flag edited Apr 22, 2015 at 7:36 answered Aug 28, 2012 at 4:28
MJD
65.4k 9 49 68
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
Use \begin{cases}…\end{cases} . End each case with a \\ , and use & before parts that should
be aligned.
f(n) = { n / 2,
3n + 1,
if n is even
if n is odd
by writing this:
f(n) =
\begin{cases}
n/2, & \text{if $n$ is even} \\
3n+1, & \text{if $n$ is odd}
\end{cases}
if n is even:
if n is odd:
n/2
3n + 1 } = f(n)
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:
{
n
2
, if n is even
f(n) =
3n + 1, if n is odd
14 of 68 10-04-2024, 13:03
{ ,
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}
(An ‘ex’ is a length equal to the height of the letter x ; 2ex here means the space should be two
exes high.)
4
Share Edit Follow Flag edited Jan 11 at 4:27 answered Aug 28, 2012 at 4:34
JonathanZ MJD
10.6k 1 18 31 65.4k 9 49 68
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
Arrays
It is often easier to read tables formatted in MathJax rather than plain text or a fixed width
176
font. Arrays and tables are created with the array environment. Just after \begin{array} the
format of each column should be listed, use c for a center aligned column, r for right
aligned, l for left aligned and a | for a vertical line. Just as with matrices, cells are separated
with & and rows are broken using \\ . A horizontal line spanning the array can be placed
before the current line with \hline .
For example,
$$
\begin{array}{c|lcr}
n & \text{Left} & \text{Center} & \text{Right} \\
\hline
1 & 0.24 & 1 & 125 \\
2 & -1 & 189 & -8 \\
3 & -20 & 2000 & 1+10i
\end{array}
$$
For example,
min 0 1 2 3 max 0 1 2 3
0 0 0 0 0 0 0 1 2 3
1 0 1 1 1 1 1 1 2 3
2 0 1 2 2 2 2 2 2 3
3 0 1 2 3 3 3 3 3 3
Δ 0 1 2 3
0 0 1 2 3
1 1 0 1 2
2 2 1 0 1
3 3 2 1 0
As the source for the preceding array is long, please right-click on one of the tables and choose
▸ .
16 of 68 10-04-2024, 13:03
16
Share Edit Follow Flag edited Aug 28, 2014 at 5:17 community wiki
8 revs, 6 users 47%
robjohn
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
Don't use \frac in exponents or limits of integrals; it looks bad and can be confusing, which is
why it is rarely done in professional mathematical typesetting. Write the fraction horizontally,
with a slash:
Bad Better
π iπ
ei 2 e2 e iπ / 2
π
∫ 2 π sinx dx ∫ π−/π2/ 2sinx dx
−
2
The | symbol has the wrong spacing when it is used as a divider, for example in set
comprehensions. Use \mid instead:
Bad Better
{x | x 2 ∈ Z} {x ∣ x 2 ∈ Z}
When using stretchable delimiters (i.e. with \left and \right ), it may be preferable to use
\,\middle|\, . This produces a stretchable vertical bar with a little bit of space around it.
Another alternative is to use a colon instead.
Bad Better
{ m
n
∣ m, n ∈ Z
}{ | m
n
m, n ∈ Z
}
For double and triple integrals, don't use \int\int or \int\int\int . Instead use the special
forms \iint and \iiint :
Bad Better
∫ ∫ Sf(x) dy dx ∬ Sf(x) dy dx
∫ ∫ ∫ Vf(x) dz dy dx ∭ Vf(x) dz dy dx
Use \, to insert a thin space before differentials; without this TEX will mash them together:
Bad Better
∭ Vf(x)dzdydx ∭ Vf(x) dz dy dx
18 of 68 10-04-2024, 13:03
3
Share Edit Follow Flag edited Jul 8, 2020 at 1:25 community wiki
11 revs, 4 users 79%
MJD
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
y+x
y+x
y+x
y+x
y + x0
19 1
=
95 5
x+y
x
y
x+y
x+y
x+y
\enclose can also produce enclosing boxes, circles, and other notations; see MathML
menclose documentation for a complete list.
It is worth noting that MathJax should not be used for formatting non-mathematical text. The
preferred way for striking out text is to use the HTML strikethrough tag, <s>[text to be
striken]</s> , which renders as [text to be striken].
20 of 68 10-04-2024, 13:03
25
Share Edit Follow Flag edited Sep 19, 2022 at 18:06 community wiki
5 revs, 2 users 97%
MJD
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
Additional decorations
128
¯ ¯ ¯
\overline : A AA AAA
\underline : B BB BBB
_ _ _
~ ~
\widetilde : C̃ CC CCC
^ ^
\widehat : D̂ DD DDD
\fbox : E EE EEE
abc
\underleftarrow : F FF FFF variant: \xleftarrow{} : ←
← ← ←
abc
\underrightarrow : G GG GGG variant: \xrightarrow{} : →
→ → →
\underleftrightarrow : H HH HHH
↔ ↔ ↔
→ → →
\overrightarrow AB ABAB ABABAB
⏞
\overbrace : (n − 2) + (n − 1) + (n + 0) + (n + 1) + (n + 2)
\underbrace : (n − 2) + (n − 1) + (n + 0) + (n + 1) + (n + 2)
⏟
a ⋅ a⋯a
⏟
b times
¯
Note: \varliminf : lim and \varlimsup :lim have special symbol of their own.
22 of 68 10-04-2024, 13:03
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
\acute : Jˊ
\grave : Kˊ
→
→
\vec : u AB (c.f. \overrightarrow above)
\bar : zˉ
\hat : x̂
\tilde : x̃
⃛
\dot \ddot \dddot : ẋ, ẍ, x
\mathring : Å
General stacking
If you cannot find your symbol remember that you can stack various symbols using
@ x2 ∙∘ ∘ ∙
\overset{above}{level} : ABC ⟼ T
\underset{below}{level} : ABC ⟼ T
@ x2 ∙∘∘∙
a
You can use these together too. You can type X → Y with X\overset{a}{\underset{b}{\to}}Y .
b
23 of 68 10-04-2024, 13:03
2
↑
D = E ← F
Long labels increase the length of the arrow and in this version also automatically increase
corresponding arrows.
$\require{AMScd}$
\begin{CD}
RCOHR'SO_3Na @>{\text{Hydrolysis,$\Delta, Dil.HCl$}}>> (RCOR')+NaCl+SO_2+ H_2O
\end{CD}
3
Share Edit Follow Flag edited Jul 30, 2022 at 0:39 community wiki
11 revs, 6 users 67%
Lehs
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
System of equations
Use and . For example, you get this:
124 \begin{array}…\end{array} \left\{…\right.
{
a 1x + b 1y + c 1z = d 1
a 2x + b 2y + c 2z = d 2
a 3x + b 3y + c 3z = d 3
by writing this:
$$
\left\{
\begin{array}{c}
a_1x+b_1y+c_1z=d_1 \\
a_2x+b_2y+c_2z=d_2 \\
a_3x+b_3y+c_3z=d_3
\end{array}
\right.
$$
{
a 1x + b 1y + c 1z = d 1
a 2x + b 2y + c 2z = d 2
a 3x + b 3y + c 3z = d 3
$$\begin{cases}
a_1x+b_1y+c_1z=d_1 \\
a_2x+b_2y+c_2z=d_2 \\
a_3x+b_3y+c_3z=d_3
\end{cases}
$$
{
a 1x + b 1y + c 1z = d 1 + e 1
a 2x + b 2y = d 2
a 3x + b 3y + c 3z = d 3
26 of 68 10-04-2024, 13:03
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
whose code is
$$
\left\{
\begin{aligned}
a_1x+b_1y+c_1z &=d_1+e_1 \\
a_2x+b_2y&=d_2 \\
a_3x+b_3y+c_3z &=d_3
\end{aligned}
\right.
$$
{
a 1x + b 1y + c 1z = d1 + e1
a 2x + b 2y = d2
a 3x + b 3y + c 3z = d3
use array with l (for "align left"; there are also c and r ) parameters
$$
\left\{
\begin{array}{ll}
a_1x+b_1y+c_1z &=d_1+e_1 \\
a_2x+b_2y &=d_2 \\
a_3x+b_3y+c_3z &=d_3
\end{array}
\right.
$$
p1
a 1x + b 1y + c 1z = q1
p2
a 2x + b 2y + c 2z = q2
p3
a 3x + b 3y + c 3z =
q3
27 of 68 10-04-2024, 13:03
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
$$\begin{cases}
a_1x+b_1y+c_1z=d_1 \\[2ex]
a_2x+b_2y+c_2z=d_2 \\[2ex]
a_3x+b_3y+c_3z=d_3
\end{cases}
$$
in comparison with
p1
a 1x + b 1y + c 1z = q1
p2
a 2x + b 2y + c 2z = q2
p3
a 3x + b 3y + c 3z = q3
whose code is
$$\begin{cases}
a_1x+b_1y+c_1z=\frac{p_1}{q_1} \\
a_2x+b_2y+c_2z=\frac{p_2}{q_2} \\
a_3x+b_3y+c_3z=\frac{p_3}{q_3}
\end{cases}
$$
$$ \left\{ \begin{array}{l}
0 = c_x-a_{x0}-d_{x0}\dfrac{(c_x-a_{x0})\cdot d_{x0}}{\|d_{x0}\|^2} + c_x-a_{x1}-
d_{x1}\dfrac{(c_x-a_{x1})\cdot d_{x1}}{\|d_{x1}\|^2} \\[2ex]
0 = c_y-a_{y0}-d_{y0}\dfrac{(c_y-a_{y0})\cdot d_{y0}}{\|d_{y0}\|^2} + c_y-a_{y1}-
d_{y1}\dfrac{(c_y-a_{y1})\cdot d_{y1}}{\|d_{y1}\|^2} \end{array} \right.
$$
produces
(c x − a x0) ⋅ d x0 (c x − a x1) ⋅ d x1
0 = c x − a x0 − d x0 + c x − a x1 − d x1
ǁd x0ǁ 2 ǁd x1ǁ 2
(c y − a y0) ⋅ d y0 (c y − a y1) ⋅ d y1
28 of 68 10-04-2024, 13:03
y y0 y0 y y1 y1
0 = c y − a y0 − d y0 + c y − a y1 − d y1
ǁd y0ǁ 2 ǁd y1ǁ 2
6
Share Edit Follow Flag edited Mar 16, 2017 at 16:37 community wiki
11 revs, 2 users 93%
Américo Tavares
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
Colors
Named colors are browser-dependent; if a browser doesn't know a particular color name, it
120
may render the text as black. The following colors are standard in HTML4 and CSS2 and
should be interpreted the same by most browsers:
text
text
text
text
text
text
text
text
text
text
text
text
text
text
text
text
HTML5 and CSS 3 define an additional 124 color names that will be supported on many
browsers.
Math Stack Exchange's default style uses a light-colored page background, so avoid using light
colors for text. Stick to darker colors like maroon, green, blue, and purple, and remember also
that 7–10% of men are color-blind and have difficulty distinguishing red and green. (Some
people have difficulty distinguishing other colors too, so don't rely on colors saying "the blue
part" over and over again.)
The color may also have the form #rgb where r, g, b are in the range or 0 – 9 , a – f and
represent the intensity of red, green, and blue on a scale of 0– 15, with a =10, b =11, … f =15.
For example:
text text
text text
text text
text text
30 of 68 10-04-2024, 13:03
text text text text
text text text text
text text text text
text text text text
text text text text
text text text text
text text text text
text text text text
text text text text
text text text text
text text text text
You can have a look here for quick reference on colors in HTML.
12
Share Edit Follow Flag edited Jan 31, 2023 at 12:57 community wiki
7 revs, 4 users 69%
MJD
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
Continued fractions
To make a continued fraction, use , which works just like but typesets the results
101 \cfrac \frac
differently:
12
x = a0 +
22
a1 +
32
a2 +
44
a3 +
a4 + ⋯
12
x = a0 +
22
a1 + 32
a2 + 44
a3 +
a4 + ⋯
12 22 32 44
x = a0 + ⋯
a1 + a2 + a3 + a4 +
Continued fractions are too big to put inline. Display them with $$ … $$ or use a notation like
[a 0; a 1, a 2, a 3, …].
32 of 68 10-04-2024, 13:03
3
Share Edit Follow Flag answered Aug 31, 2012 at 19:46 community wiki
MJD
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
$$ a := x^2-y^3 \tag{*}\label{*} $$
a := x 2 − y 3
(*)
a + y = x2
3
or \ref{somelabel}
Equations are usually referred to as $\eqref{*}$, but you can also use $\ref{*}$.
Equations are usually referred to as (*), but you can also use *.
As you can see, references are even turned into hyperlinks, which you can use externally as
well, e.g. like this. Note that you can also reference labels in other posts as long as they appear
on the same site, which is especially useful when referring to a question with multiple
equations, or when commenting on a post.
Due to a bug blocks containing a \label will break in preview, as a workaround you can put $
\def\label#1{}$ in your post while editing and remove that on submission - unfortunately this
means you won't spot misspelled references before submitting... Just don't forget to
remove that \def again
34 of 68 10-04-2024, 13:03
12
Share Edit Follow Flag edited Apr 13, 2017 at 12:22 community wiki
3 revs
Tobias Kienzler
Using \newcommand
93 I would like to remark that it is possible to define LaTeX commands as you do in your TeX
files. I felt so happy when I first discovered it! It's enough to insert something like
at the top of your post (remember the dollars!). Then you can just use your commands as you
are used to do: in my example typing $$ \SES{A}{B}{C} $$ will produce the following:
0→A→B→C→0
Share Edit Follow Flag edited Feb 12, 2015 at 12:43 community wiki
3 revs, 3 users 67%
Abramo
12
6
Share Edit Follow Flag edited Apr 13, 2017 at 12:34 community wiki
4 revs, 3 users 71%
leonbloy
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
Big braces
81 Use \left and \right to make braces - (round), [square] and {curly} - scale up to be the size
of their arguments. Thus
$$
f\left(
\left[
\frac{
1+\left\{x,y\right\}
}{
\left(
\frac{x}{y}+\frac{y}{x}
\right)
\left(u+1\right)
}+a
\right]^{3/2}
\right)
$$
renders as
f
([ ( x
y
1 + {x, y}
+
y
x ) (u + 1)
+a
])
3/2
.
If you start a big brace with \left and then need to match that to a \right brace that's on a
different line, use the forms \right. and \left. to make "shadow" braces. Thus,
$$
\begin{aligned}
a=&\left(1+2+3+ \cdots \right. \\
& \cdots+ \left. \infty-2+\infty-1+\infty\right)
\end{aligned}
$$
renders as
a = (1 + 2 + 3 + ⋯
⋯ + ∞ − 2 + ∞ − 1 + ∞).
There is also a \middle construct which is useful when one has a mid-expression brace which
must also scale up:
38 of 68 10-04-2024, 13:03
$$
\left\langle
q
\middle\|
\frac{\frac{x}{y}}{\frac{u}{v}}
\middle|
p
\right\rangle
$$
renders as
|
x
y
qǁ u p .
v
Note that constructs like \left\langle , \left| and \left\| are also possible.
Alternatively there also exists the \big hierarchy whose pairing is not mandatory, you can
1
type \big(\frac 1x\big) (x )
The advantage of left/right is that it dimensions automatically, but has the inconvenient of not
producing consistent results depending of the vertical extension of its inner content, instead
the big hierarchy has fixed size:
\Bigg(\bigg(\Big(\big((x)\big)\Big)\bigg)\Bigg)
( ( ( ( ) )) )
(x)
5
Share Edit Follow Flag edited Jan 21 at 22:07 community wiki
3 revs, 2 users 94%
E.P.
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
Limits
x2 − 1
77 To make a limit (like lim x−1
), use this syntax:
x→1
First, start off with $\lim . This renders as lim . The backslash is there to prevent things like
lim, where the letters are slanted.
Second, add \limits_{x \to 1} inside. The code now looks like $\lim \limits_{x \to 1}$ , and
renders as lim . The \to inside makes the right arrow, rendered as → . The _ makes the
x→1
x → 1 go underneath the lim . Finally, the pair of curly braces { } makes sure that x → 1 is
treated as a whole object, and not two separate things.
Lastly, add the function you want to apply the limit to. To make the limit mentioned above,
x2 − 1
lim , simply use $\lim\limits_{x \to 1} \frac{x^2-1}{x-1}$ .
x−1
x→1
40 of 68 10-04-2024, 13:03
28
Share Edit Follow Flag edited Jul 17, 2014 at 12:25 community wiki
2 revs, 2 users 94%
JChau
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
Arbitrary operators
65 If an operator is not available as a built-in command, use \operatorname{…} . So for things like
arsinh(x)
write \operatorname{arsinh}(x) since \arsinh(x) will give an error and arsinh(x) has wrong
font and spacing: arsinh(x).
This was already mentioned in a comment by Charles Staats. You might consider this an
addition to the FAQ section on \lim , \sin and so on.
For operators which need limits above and below the operator, use \operatorname*{…} , as in
Res
z=1 ( )1
z2 − z
=1
42 of 68 10-04-2024, 13:03
1
Share Edit Follow Flag edited Sep 15, 2022 at 5:32 community wiki
4 revs, 3 users 56%
MvG
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
Highlighting equation
64 To highlight an equation, \bbox can be used. E.g,
$$ \bbox[yellow]
{
e^x=\lim_{n\to\infty} \left( 1+\frac{x}{n} \right)^n
\qquad (1)
}
$$
produces
( )
e x = lim 1 +
n→∞
x
n
n
(1)
By default, the bounding box is "tight", so it doesn't extend beyond the characters used in the
formula. You can add a little space around the equation by adding a measurement after the
color. E.g.,
$$ \bbox[yellow,5px]
{
e^x=\lim_{n\to\infty} \left( 1+\frac{x}{n} \right)^n
\qquad (1)
}
$$
produces
( )
e x = lim 1 +
n→∞
x
n
n
(1)
produces
( )
e x = lim 1 +
n→∞
x
n
n
(2)
44 of 68 10-04-2024, 13:03
n→∞
( )
You can do both border and background, as well:
produces
( )
e x = lim 1 +
n→∞
x
n
n
(1)
3
Share Edit Follow Flag edited Jul 4, 2016 at 11:05 community wiki
4 revs, 3 users 53%
webbertiger
Absolute values and norms
59 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|.
The norm of a vector (or similar) can be denoted as \lVert v\rVert or, more generally, as
\left\lVert … \right\rVert . It renders as ǁvǁ. (You may also write \left\|…\right\| instead.)
In both cases, the rendering is better than what you'd get from |x| or ||v|| , which render
with bars that don't descend low enough and sub-optimal spacing. At least on some browsers,
so here is a screenshot how it looks for me, using Firefox 31 on OS X:
It was typeset as
Share Edit Follow Flag edited Aug 13, 2014 at 11:59 community wiki
4 revs, 3 users 89%
MvG
8
Giving reasons on each line of a sequence of equations
To produce this:
57
v+w=0 Given
−w = − w + 0 additive identity
− w + 0 = − w + (v + w) equations (1) and (2)
write this:
\begin{align}
v + w & = 0 &&\text{Given} \tag 1\\
-w & = -w + 0 && \text{additive identity} \tag 2\\
-w + 0 & = -w + (v + w) && \text{equations $(1)$ and $(2)$}
\end{align}
Share Edit Follow Flag edited Feb 15, 2016 at 18:33 community wiki
2 revs
David K
1
Pack of cards
47 If you are asking (or answering) a combinatorics question involving packs of cards you can
make it look more elegant by using \spadesuit , \heartsuit , \diamondsuit , \clubsuit in math
mode:
♠ ♡ ♢ ♣
♡ ♢
You can also enter the standard Unicode characters ( U+2660 BLACK SPADE SUIT etc.) literally, or
copy them from here:
♠ ♡ ♢ ♣♤ ♥ ♦ ♧
Share Edit Follow Flag edited May 29, 2018 at 16:09 community wiki
3 revs, 3 users 53%
David
1
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
The latter of which produces longer arrows which may be more desirable to some.
Share Edit Follow Flag edited May 6, 2014 at 22:15 community wiki
3 revs, 2 users 74%
jnh
49 of 68 10-04-2024, 13:03
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
Degree symbol
38 Standard Mathjax does not yet support a dedicated degree symbol, so here are some of the
ways to try and emulate one :
45^\text{o} renders as 45 o
45^o renders as 45 o
45^\circ renders as 45 ∘
45^{\large\circ} renders as 45 ∘
45\unicode{xB0} renders as 45° Actual Unicode character
90° renders as 90° Using keyboard entry of symbol
The degree symbol for angles is not ^\circ . Although many people use this notation, the
result looks quite different from the canonical degree symbol shipped with the font, as seen
above.
If your keyboard doesn't have a key, feel free to copy from this post here, or follow these
suggestions.
Note that comments below indicate that on some configurations at least, ° renders inferior to
^\circ . And I recently had a post of mine edited just for the sake of turning ° into ^\circ ,
indicating that someone felt rather strongly about this. So the suggestion above does seem
somewhat controversial at the moment. I maintain that from a semantic point of view, ° is
superior to ^\circ , and if the rendering suffers from this, then it's a bug in MathJax. After all,
LaTeX offers a proper degree symbol in the tex companion fonts, indicating that someone
there, too, decided that ^\circ is not perfect. But if things are broken now, I can't fault people
from pragmatically sticking with the rendering they prefer. Personally I prefer semantics, also
for the sake of screen readers.
Accessibility
Aside from appearance, one consideration in choosing which notation to use is how it will get
parsed by screen readers. For example, ChromeVox reads both 45^\circ and 45° as "forty-
five degrees", while the other two are pronounced as "forty-five oh", which may be a reason to
avoid them.
Usepackage
Commonly in Latex you can \usepackage{gensymb} to get the \degree symbol, however on
Stack Exchange this is not an option. Note that even if you can do this it will typically affect
the entire page, which may have side effects for other users. So don't rely on this approach.
50 of 68 10-04-2024, 13:03
2
Share Edit Follow Flag edited Feb 26, 2021 at 12:11 community wiki
10 revs, 6 users 47%
StephenG
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
Long division
36 $$
\require{enclose}
\begin{array}{r}
13 \\[-3pt]
4 \enclose{longdiv}{52} \\[-3pt]
\underline{4}\phantom{2} \\[-3pt]
12 \\[-3pt]
\underline{12}
\end{array}
$$
13
452
4
_
12
12
_
One important trick shown here is the use of \phantom{2} to make a blank space that is the
same size and shape as the digit 2 just above it.
52 of 68 10-04-2024, 13:03
10
Share Edit Follow Flag edited May 23, 2017 at 12:39 community wiki
6 revs, 3 users 92%
David K
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
∞ ∞
1 1 1
∑ 2
→ ∑∞
n = 1 n2
→ ∑ 2
n=1n n=1n
1
Compare lim ∫ t f(t) dt versus lim t → 0∫ 1t f(t) dt.
t→0
Do observe that the taller formulas gotten with \displaystyle distort the line spacing.
Filler text, more filler text and even more filler text, and an outrageous amount of
1
filler text. It would not occur to me to use lim
t→0
∫ t f(x) dx here. As we see, a formula
typeset in displaystyle makes it necessary to move the lines further apart. A ridiculous
amount of filler text to make a point. Not pleasing to the eye at all.
In other words, there is also a reason TeX defaults to \textstyle when typesetting inline
formulas.
54 of 68 10-04-2024, 13:03
4
Share Edit Follow Flag edited Sep 24, 2022 at 20:07 community wiki
4 revs, 3 users 70%
Alexis Olson
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
Vertical Spacing
28 ¯ ¯ ¯
Some formulas such as a + b = a ⋅ b, √a − √b, do not look quite right when it comes to vertical
spacing. Fortunately, there is more than one way to fix this. One can for instance employ the
\mathstrut command as follows:
Which yields: √a − √b. Or using \vphantom (vertical phantom) command, which measures the
height of its argument and places a math strut of that height into the formula.
$\sqrt{\vphantom{b} a} - \sqrt{b}$
Another issue is with the spacing within lines in situations like this,
1
Based on the previous technique, we can simplify , and we thus get the result
√a − √b
of the previous limit. [this text is added to show alignment with the above smashed
object]
These two lines are too far apart, but this is unnecessary since the second line is very short.
We can solve this by using the \smash command, to get:
1
Based on the previous technique, we can simplify , and we thus get the result
√ a − √b
of the previous limit. [this text is added to show alignment with the above smashed
object]
Beware - as above - the smashed text may overlap the next line if that line extends far
enough to reach the smashed object, so this solution is not always feasible (it is esp. likely to
occur in slim-width browsers, e.g. phones). Analogous overlapping may occur with any prior
lines. Note that smash can be restricted to top or bottom with an argument: \smash[t]... or
\smash[b]...
56 of 68 10-04-2024, 13:03
4
Share Edit Follow Flag edited Sep 5, 2022 at 20:06 community wiki
4 revs, 2 users 91%
Workaholic
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
Equation numbering
28 Simple equation
To give an equation a number, use the \tag{} . To refer to it later, use \label{} to label this
equation. When you want to refer to it, use \eqref{} . For example,
e = mc 2
Equation (1) is one of the greatest equations in mankind's history. Equation (1) is produced
using the following code,
$$e=mc^2 \tag{1}\label{eq1}$$
Multi-line equation
Multi-line equation is actually just one equation rather than several equations. So the correct
environment is aligned instead of align .
a= b+c
= d+e+f+g
= h+i
$$\begin{equation}\begin{aligned}
a &= b + c \\
&= d + e + f + g \\
&= h + i
\end{aligned}\end{equation}\tag{2}\label{eq2}$$
a=b+c
x = yz
l =m−n
Equation (3), (4) and (5) are multiple equations aligned together. The code to produce these
equations is,
58 of 68 10-04-2024, 13:03
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
$$\begin{align}
a &= b + c \tag{3}\label{eq3} \\
x &= yz \tag{4}\label{eq4}\\
l &= m - n \tag{5}\label{eq5}
\end{align}$$
|
Share Edit Follow Flag edited Dec 24, 2022 at 16:06 community wiki
59 of 68 10-04-2024, 13:03
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
Linear programming
20 Formulation
A theoretical LPP can be typeset as
\begin{array}{ll}
\text{maximize} & c^T x \\
\text{subject to}& d^T x = \alpha \\
&0 \le x \le 1.
\end{array}
maximize c Tx
subject to d Tx = α
0 ≤ x ≤ 1.
To input a numerical LPP, use alignat instead of align to get better alignment between
signs, variables and coefficients.
\begin{alignat}{5}
\max \quad & z = & x_1 & + & 12 x_2 & & & && \\
\mbox{s.t.} \quad & & 13 x_1 & + & x_2 & + & 12x_3 & \geq 5 && \tag{constraint
1} \\
& & x_1 & & & + & x_3 & \leq 16 && \tag{constraint
2} \\
& & 15 x_1 & + & 201 x_2 & & & = 14 && \tag{constraint
3} \\
& & \rlap{x_i \ge 0, i = 1, 2, 3}
\end{alignat}
max z= x 1 + 12x 2
s.t. 13x 1 + x 2 + 12x 3 ≥ 5
x1 + x 3 ≤ 16
15x 1 + 201x 2 = 14
x i ≥ 0, i = 1, 2, 3
We treat max , z, each variable, ± sign and RHS as one separate column, while leaving an
extra empty column on the right. Then we count the number of separators & , add one into
this number then divide it by two. (e.g. (9 + 1) ÷ 2 = 5)
\rlap is used so that the last row spans over one column.
Writing manually the LATEX code for a matrix with many rows and columns in Octave is
tedious. The Octave function
converts
A = [1 2 2; 2 3 4; 4 4 2]
A =
1 2 2
2 3 4
4 4 2
to
\begin{bmatrix}
1 & 2 & 2 \\
2 & 3 & 4 \\
4 & 4 & 2
\end{bmatrix}
[ ]
1 2 2
2 3 4 .
4 4 2
Simplex tableaux
Since the coefficient of the objective value variable z never changes, my habit is to omit the z-
column to save ink.
\begin{array}{rrrrrr|r}
& x_1 & x_2 & s_1 & s_2 & s_3 & \\ \hline
s_1 & 0 & 1 & 1 & 0 & 0 & 8 \\
s_2 & 1 & -1 & 0 & 1 & 0 & 4 \\
s_3 & 1 & 1 & 0 & 0 & 1 & 12 \\ \hline
& -1 & -1 & 0 & 0 & 0 & 0
61 of 68 10-04-2024, 13:03
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
x1 x2 s1 s2 s3
s1 0 1 1 0 0 8
s2 1 −1 0 1 0 4
s3 1 1 0 0 1 12
−1 −1 0 0 0 0
\begin{array}{rrrrrrr|rr}
& x_1 & x_2 & s_1 & s_2 & s_3 & w & & \text{ratio} \\ \hline
s_1 & 0 & 1 & 1 & 0 & 0 & 0 & 8 & - \\
w & 1^* & -1 & 0 & -1 & 0 & 1 & 4 & 4 \\
s_3 & 1 & 1 & 0 & 0 & 1 & 0 & 12 & 12 \\ \hdashline
& 1 & -1 & 0 & -1 & 0 & 0 & 4 & \\ \hline
s_1 & 0 & 1 & 1 & 0 & 0 & 0 & 8 & \\
x_1 & 1 & -1 & 0 & -1 & 0 & 1 & 4 & \\
s_3 & 0 & 2 & 0 & 2 & 1 & -1 & 8 & \\ \hdashline
& 0 & 0 & 0 & 0 & 0 & -1 & 0 &
\end{array}
x1 x2 s1 s2 s3 w ratio
s1 0 1 1 0 0 0 8 −
w 1∗ −1 0 −1 0 1 4 4
s3 1 1 0 0 1 0 12 12
1 −1 0 −1 0 0 4
s1 0 1 1 0 0 0 8
x1 1 −1 0 −1 0 1 4
s3 0 2 0 2 1 −1 8
0 0 0 0 0 −1 0
\begin{array}{rrrrrrrr|r}
& x_1 & x_2 & x_3 & x_4 & x_5 & x_6 & x_7 & \\ \hline
x_4 & 0 & -3 & 7 & 1 & 0 & 0 & 2 & 2M -4 \\
x_5 & 0 & -9 & 0 & 0 & 1 & 0 & -1 & -M -3 \\
x_6 & 0 & 6 & -1 & 0 & 0 & 1 & -4^* & -4M +8 \\
x_1 & 1 & 0 & 1 & 0 & 0 & 0 & 1 & M \\ \hline
& 0 & 1 & 1 & 0 & 0 & 0 & 2 & 2M \\
\text{ratio} & & & 1 & & & & 1/2 &
\end{array}
x1 x2 x3 x4 x5 x6 x7
62 of 68 10-04-2024, 13:03
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
x4 0 −3 7 1 0 0 2 2M − 4
x5 0 −9 0 0 1 0 −1 −M − 3
x6 0 6 −1 0 0 1 −4 ∗ − 4M + 8
x1 1 0 1 0 0 0 1 M
0 1 1 0 0 0 2 2M
ratio 1 1/2
It can be stacked up to give a theoretical illustration of what happens in the upcoming steps.
x1 x2 x3 s1 s2 s3
s1 −2 0 −2 1 0 0 − 60
s2 −2 −4 ∗ −5 0 1 0 − 70
s3 0 −3 −1 0 0 1 − 27
8 10 25 0 0 0 0
ratio −4 −5/2 −5
s1 −2 ∗ 0 −2 1 0 0 − 60
x2 1/2 1 5/4 0 −1/4 0 35 / 2
s3 3/2 0 11 / 4 0 −3/4 1 51 / 2
3 0 25 / 2 0 5/2 0 − 175
ratio − 3 / 2 25 / 4
x1 1 0 1 −1/2 0 0 30
x2 0 1 3/4 1/4 −1/4 0 5/2
Duality
A picture is worth a thousand words.
max z = c Tx duality
min v = b Ty
s.t. Ax ≤ b ⇄ s.t. A Ty ≥ c
x≥0 y≥0
( ) ( )
63 of 68 10-04-2024, 13:03
( ) ( )
add ⇃ slack var minus ⇂ surplus var
max z = c Tx duality
min v = b Ty
s.t. Ax + s = b ⇄ s.t. A Ty − t = c
x, s ≥ 0 some steps skipped
y, t ≥ 0
( ) ( )
6
Share Edit Follow Flag edited Feb 16, 2019 at 9:55 community wiki
3 revs, 2 users 100%
GNUSupporter 8964民主女神
地下教會
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
Units
While LATEX has packages that format units, MathJax does not. For visual consistency, one
20
should format units within the same string of MathJax code as the value to which it
corresponds, separating the value and unit with \ (space-backslash-space) since the BIPM
recommends a small space between the value and units. In addition, follow the below
conventions for formatting values and units:
No punctuation should be used to separate multiples of three digits on either side of the
decimal separator; instead, a small space rendered by \, should be used on both sides of the
decimal marker when the string of digits consists of more than four or five digits. For
example,
4321.1234 4321.1234
54\,321.123\,45 54 321.123 45
0.56789 0.56789
0.567\,89 0.567 89
If you use a decimal separator, you should include a digit on both sides of the separator, even
if the digit is simply 0.
Powers of 10
It is preferable to write scientific or engineering notation like this: 4.15\times10^{n} 4.15 × 10 n
. The spacing around \times × is taken care of on its own, so there is no need to insert the
spacing manually.
Nevertheless, if necessary, use an upright variant of the letter ‘E’ or ‘e’ to indicate order of
magnitude, such as
\mathrm{E}\,6 E6
\scriptsize{\mathrm{E}}\,\normalsize{6} E6
\mathrm{e}\,6 e6
65 of 68 10-04-2024, 13:03
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
Single Units
The symbol of any unit—especially SI units—should follow the form \mathrm{u} . (I have this
command saved under the keyboard shortcut usin on my devices.) For example,
\mathrm{m} m
\mathrm{kg} kg
\mathrm{ft.} ft.
Do not use a period with symbolic units; do use a period with abbreviated units.
\mathrm{N}\!\cdot\!\mathrm{m} N⋅ m
\mathrm{s}\!\cdot\!\mathrm{A} s⋅A
\left.\mathrm{J}\middle/\mathrm{s}\right. J/s
\left.\mathrm{m}\middle/\mathrm{s}^2\right. m s2/
You may include small negative spaces \! on either side of the solidus if you please.
Exponents
Exponents can be rendered with the standard MathJax markdown. The carat and number
should immediately follow the closing brace of the mathrm{} argument. For example,
\mathrm{m}^2 m2
66 of 68 10-04-2024, 13:03
\mathrm{m}^2 m
\left.\mathrm{m}\middle/\mathrm{s}^2\right. /
m s2
Parentheses
Parentheses can also be rendered with standard MathJax markdown using \left( and
\right) outside the argument of \mathrm . For example,
\left.\mathrm{kg}\!\cdot\!\mathrm{m}^2\middle/\left(\mathrm{C}\!\cdot\!\mathrm{s}\right)
\right. /
kg⋅ m 2 (C⋅ s)
\mathrm{m}\,\mathrm{s}^{-2} m s −2
\mathrm{s}^{-1}\,\mathrm{mol} s − 1 mol
Examples in Context
\mu_0=4\pi\times10^{-7} \ \left.\mathrm{\mathrm{T}\!\cdot\!\mathrm{m}}\middle/\mathrm{A}
\right.
μ 0 = 4π × 10 − 7 T ⋅ m / A
180^\circ=\pi \ \mathrm{rad}
180 ∘ = π rad
N A = 6.022 × 10 23 mol − 1
2
Share Edit Follow Flag edited Apr 6, 2023 at 7:20 community wiki
4 revs, 3 users 93%
gen-ℤ ready to perish
MathJax basic tutorial and quick reference - Mathematics Meta Stack E... https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tuto...
1 2 Next
68 of 68 10-04-2024, 13:03