(Deutsch: MathJax: LaTeX Basic Tutorial und Referenz [1])
To see how any formula was written in any question or answer, including this one, right-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 [2] to view the code for the formula or the whole post.)
To try formatting, visit the formatting sandbox [3] 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.
For inline formulas, enclose the formula in $
…$
. For displayed formulas, use $$
…$$
.
$\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}$
$$\sum_{i=0}^n i^2 = \frac{(n^2+n)(2n+1)}{6}$$
For Greek letters, use \alpha
, \beta
, …, \omega
: $\alpha$, $\beta$, …, $\omega$.
\Gamma
, \Delta
, …, \Omega
: $\Gamma$, $\Delta$, …, $\Omega$.A,B,E,Z
and so on: $A, B, E, Z$….\epsilon \varepsilon
$\epsilon$, $\varepsilon$, \phi \varphi
$\phi$, $\varphi$, and others.For superscripts and subscripts, use ^
and _
. For example, x_i^2
: $x_i^2$, \log_2 x
: $\log_2 x$. For the prime symbol, use an apostrophe x' x'' x'''
: $x'\ x''\ x'''$.
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 {
…}
.
10^10
, you will get a surprise: $10^10$. But 10^{10}
gives what you probably wanted: $10^{10}$.x^y^z
is an error; {x^y}^z
is ${x^y}^z$, and x^{y^z}
is $x^{y^z}$. Observe the differences between x_i^2
$x_i^2$, x_{i^2}
$x_{i^2}$ and {x_i}^2
${x_i}^2$.Parentheses Ordinary symbols ()[]
make parentheses and brackets $(2+3)[4+4]$. Use \{
and \}
for curly braces $\{\}$.
These do not scale 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|$, \vert
$\vert x \vert$, \Vert
$\Vert x \Vert$, \langle
and \rangle
$\langle x \rangle$, \lceil
and \rceil
$\lceil x \rceil$, and \lfloor
and \rfloor
$\lfloor x \rfloor$. \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 $$\left.x^2\right\rvert_3^5 = 5^2-3^2$$
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$.
\prod
$\prod$, \int
$\int$, \bigcup
$\bigcup$, \bigcap
$\bigcap$, \iint
$\iint$, \iiint
$\iiint$, \idotsint
$\idotsint$.Fractions There are
three ways to make fractions
[4]. \frac ab
applies to the next two groups, and produces $\frac ab$; for more complicated numerators and denominators use {
…}
: \frac{a+1}{b+1}
is $\frac{a+1}{b+1}$.
\over
, which splits up the group that it is in: {a+1\over b+1}
is ${a+1\over b+1}$.
\cfrac
instead of
\frac
[5].Fonts
\mathbb
or \Bbb
for "blackboard bold": $\mathbb{CHNQRZ}$.\mathbf
for boldface: $\mathbf{CHNQRZ}$ $\mathbf{chnqrz}$.
\boldsymbol
instead: $\boldsymbol{\alpha}$\mathit
for italics: $\mathit{CHNQRZ}$ $\mathit{chnqrz}$.\pmb
for boldfaced italics: $\pmb{CHNQRZ}$ $\pmb{chnqrz}$.\mathtt
for "typewriter" font: $\mathtt{CHNQRZ}$ $\mathtt{chnqrz}$.\mathrm
for roman font: $\mathrm{CHNQRZ}$ $\mathrm{chnqrz}$.\mathsf
for sans-serif font: $\mathsf{CHNQRZ}$ $\mathsf{chnqrz}$.\mathcal
for "calligraphic" letters: $\mathcal{CHNQRZ}$ (Uppercase only.)\mathscr
for script letters: $\mathscr{CHNQRZ}$ $\mathscr{chnqrz}$\mathfrak
for "Fraktur" (old German style) letters: $\mathfrak{CHNQRZ}$ $\mathfrak{chnqrz}$.Radical signs / roots Use 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.
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
$\sin x$, not sin x
$sin x$. Use subscripts to attach a notation to \lim
: \lim_{x\to 0}
$$\lim_{x\to 0}$$ Nonstandard function names can be set with \operatorname{foo}(x)
$\operatorname{foo}(x)$.
There are a very large number of special symbols and notations, too many to list here; see the short listing $\LaTeX$ and $\mathcal{A}_{\Large\mathcal{M}}\mathcal{S}$ - $\LaTeX$ Symbols [6] prepared by Dr. Emre Sermutlu, or the exhaustive listing The Comprehensive $\LaTeX$ Symbol List [7] by Scott Pakin. Some of the most common include:
\lt \gt \le \ge \neq
$\lt$, $\gt$, $\le$, $\ge$,$\neq$. You can use \not
to put a slash through almost anything: \not\lt
$\not\lt$ but it often looks bad.
\times \div \pm \mp
$\times$, $\div$, $\pm$, $\mp$. \cdot
is a centered dot: $x\cdot y$
\cup \cap \setminus \subset \subseteq \subsetneq \supset \in \notin \emptyset \varnothing
$\cup$, $\cap$, $\setminus$, $\subset$, $\subseteq$, $\subsetneq$, $\supset$, $\in$, $\notin$, $\emptyset$, $\varnothing$
{n+1 \choose 2k}
or \binom{n+1}{2k}
${n+1 \choose 2k}$
\to \gets \rightarrow \leftarrow \Rightarrow \Leftarrow \mapsto \implies \iff
$\to$, $\gets$, $\rightarrow$, $\leftarrow$, $\Rightarrow$, $\Leftarrow$, $\mapsto$, $\implies$, $\iff$
\land \lor \lnot \forall \exists \top \bot \vdash \vDash
$\land$, $\lor$, $\lnot$, $\forall$, $\exists$, $\top$, $\bot$, $\vdash$, $\vDash$
\star \ast \oplus \circ \bullet
$\star$, $\ast$, $\oplus$, $\circ$, $\bullet$
\approx \sim \simeq \cong \equiv \prec \lhd
$\approx$, $\sim $, $\simeq$, $\cong$, $\equiv$, $\prec$, $\lhd$
\infty \aleph_0
$\infty\, \aleph_0$ \nabla \partial
$\nabla$, $\partial$ \Im \Re
$\Im$, $\Re$
For modular equivalence, use \pmod
like this: a\equiv b\pmod n
$a\equiv b\pmod n$. For the binary mod operator, use \bmod
like this: a\bmod 17
$a\bmod 17$.
Use \dots
for the triple dots in $a_1, a_2, \dots, a_n$ and $a_1+a_2+\dots+a_n$
Script lowercase l is \ell
$\ell$.
Detexify [8] 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 [9], and one can also check Dr. Carol JVF Burns's page of $\TeX$ Commands Available in MathJax [10].
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 $a b$. To add more space, use \,
for a thin space $a\,b$; \;
for a wider space $a\;b$. \quad
and \qquad
are large spaces: $a\quad b$, $a\qquad b$.
To set plain text, use \text{…}
: $\{x\in s\mid x\text{ is extra large}\}$. You can nest $…$
inside of \text{…}
, for example to access spaces.
Accents and diacritical marks Use \hat
for a single symbol $\hat x$, \widehat
for a larger formula $\widehat{xy}$. If you make it too wide, it will look silly. Similarly, there are \bar
$\bar x$ and \overline
$\overline{xyz}$, and \vec
$\vec x$ and \overrightarrow
$\overrightarrow{xy}$ and \overleftrightarrow
$\overleftrightarrow{xy}$. For dots, as in $\frac d{dx}x\dot x = \dot x^2 + x\ddot x$, use \dot
and \ddot
.
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
[11]) for $\backslash$, because \\
is for a new line.
(Tutorial ends here.)
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.
Alphabetical list of links to MathJax topics, by title:
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:
$$ \begin{matrix} 1 & x & x^2 \\ 1 & y & y^2 \\ 1 & z & z^2 \\ \end{matrix} $$
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 replace matrix
with pmatrix
$\begin{pmatrix}1&2\\3&4\\ \end{pmatrix}$, bmatrix
$\begin{bmatrix}1&2\\3&4\\ \end{bmatrix}$, Bmatrix
$\begin{Bmatrix}1&2\\3&4\\ \end{Bmatrix}$, vmatrix
$\begin{vmatrix}1&2\\3&4\\ \end{vmatrix}$, Vmatrix
$\begin{Vmatrix}1&2\\3&4\\ \end{Vmatrix}$.
Use \cdots
$\cdots$ \ddots
$\ddots$ \vdots
$\vdots$ when you want to omit some of the entries:
$$\begin{pmatrix} 1 & a_1 & a_1^2 & \cdots & a_1^n \\ 1 & a_2 & a_2^2 & \cdots & a_2^n \\ \vdots & \vdots& \vdots & \ddots & \vdots \\ 1 & a_m & a_m^2 & \cdots & a_m^n \end{pmatrix}$$
For horizontally "augmented" matrices, put parentheses or brackets around a suitably-formatted table; see arrays [1] below for details. Here is an example:
$$ \left[\begin{array}{cc|c} 1&2&3\\ 4&5&6 \end{array}\right] $$
is produced by:
$$ \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.
\hline
. For example$$ \begin{pmatrix} a & b \\ c & d\\ \hline 1 & 0\\ 0 & 1 \end{pmatrix} $$ is produced by
$$
\begin{pmatrix}
a & b\\
c & d\\
\hline
1 & 0\\
0 & 1
\end{pmatrix}
$$
For small inline matrices use \bigl(\begin{smallmatrix} ... \end{smallmatrix}\bigr)
, e.g. $\bigl( \begin{smallmatrix} a & b \\ c & d \end{smallmatrix} \bigr)$ is produced by:
$\bigl( \begin{smallmatrix} a & b \\ c & d \end{smallmatrix} \bigr)$
as in section 6 of the tutorial
... Which tutorial? Is there a link to this tutorial section? - Tom Hale
vmatrix
does not show the vertical bar. - alhelal
vmatrix
does not show the vertical bar. (\begin{vmatrix}0 & 3 & 2x+7\\ 2 & 7x & 9+5x\\ 0 & 0 & 2x+5\\ \end{vmatrix}=0) হলে x এর মান- - alhelal
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script> <script type="text/javascript" id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"> </script>
- alhelal
\ddots
that run from SW to NE this answer on mathematics meta works: \newcommand\iddots{\mathinner{ \kern1mu\raise1pt{.} \kern2mu\raise4pt{.} \kern2mu\raise7pt{\Rule{0pt}{7pt}{0pt}.} \kern1mu }}
- Manfred Weis
In general, you have to search in long tables about a specific symbol you're looking for, things like $\Psi$, $\delta$, $\zeta$, $\ge$, $\subseteq$ ... And it turns out that this operation can be frustrating and time consuming, which can cause the buddy to abandon writing the complete $\LaTeX$ sentence in his answer, or in some cases, the complete answer itself.
That's why the tool that I will present you in this post was conceived. Basically, it is a $\LaTeX$ handwritten symbol recognition. Example in image:
Here is the website: Detexify² [1] No more frustration.
[1] http://detexify.kirelabs.org/classify.htmlusepackage
? I'd like to have \iddots
from package mathdots
available. - Gottfried Helms
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,
\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}
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.
align
environment over eqnarray
in LaTeX. In MathJax the spacing seems to be the same , but align
requires one less ampersand per line. - user856
eqnarray
is in this article. - MJD
align
then? - user856
\\[1ex]
instead of \\
. (And of course the 1
can be changed to another value such as 1.5
or .7
in order to get enough space but not too much.) - David K
&=
, you have two instances of \left(
in a row, and one of them is not closed. Removing one of them, I get: $\begin{align} f(x)&=\left(x^3\right)+\left(x^3+x^2+x^1\right)+\left(x^3+x^2\right)\\ f'(x)&=\left(3x^2+2x+1\right)+\left(3x^2+2x\right)\\ f''(x)&=\left(6x+2\right)\\ \end{align}$ Is that what you expected? - Dan Henderson
aligned
and align
environment. Equation above are just one equation with different representations, rather than multiple aligned equations. I think the correct environment is aligned
. - jdhao
align*
variation does two things differently: left-aligns the equations and omits equation numbers; the regular align
environment centers the equations and puts an equation number on each line, at least in my version of Jupyter notebooks. - Reb.Cabin
Warning: If you make certain kinds of errors while entering code using this environment, you can easily screw-up live update, and your only recourse is to abandon your edit and refresh the page. Clearing out the code and re-entering it will not fix things - you will have to refresh the page. If you are learning how to use this feature it is recommended that you cut-and-paste a working example from here, and modify it bit-by-bit to the text you want.
Use \begin{cases}…\end{cases}
. End each case with a \\
, and use &
before parts that should be aligned.
For example, you get this:
$$f(n) = \begin{cases} n/2, & \text{if $n$ is even} \\ 3n+1, & \text{if $n$ is odd} \end{cases}$$
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: $$ \left. \begin{array}{l} \text{if $n$ is even:}&n/2\\ \text{if $n$ is odd:}&3n+1 \end{array} \right\} =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:
$$f(n) = \begin{cases} \frac{n}{2}, & \text{if $n$ is even} \\[2ex] 3n+1, & \text{if $n$ is odd} \end{cases}$$
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.)
\displaystyle
when the formulas displayed are more complex ? - jibe
\displaystyle
is enabled automatically in displays, for example between $$…$$
. You should not ever have to use it. - MJD
{
notation is just wrong anyways). - yo'
It is often easier to read tables formatted in MathJax rather than plain text or a fixed width 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} $$
$$
\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}
$$
Arrays can be nested to make an array of tables.
For example, $$ % outer vertical array of arrays \begin{array}{c} % inner horizontal array of arrays \begin{array}{cc} % inner array of minimum values \begin{array}{c|cccc} \text{min} & 0 & 1 & 2 & 3\\ \hline 0 & 0 & 0 & 0 & 0\\ 1 & 0 & 1 & 1 & 1\\ 2 & 0 & 1 & 2 & 2\\ 3 & 0 & 1 & 2 & 3 \end{array} & % inner array of maximum values \begin{array}{c|cccc} \text{max}&0&1&2&3\\ \hline 0 & 0 & 1 & 2 & 3\\ 1 & 1 & 1 & 2 & 3\\ 2 & 2 & 2 & 2 & 3\\ 3 & 3 & 3 & 3 & 3 \end{array} \end{array} \\ % inner array of delta values \begin{array}{c|cccc} \Delta&0&1&2&3\\ \hline 0 & 0 & 1 & 2 & 3\\ 1 & 1 & 0 & 1 & 2\\ 2 & 2 & 1 & 0 & 1\\ 3 & 3 & 2 & 1 & 0 \end{array} \end{array} $$
As the source for the preceding array is long, please right-click on one of the tables and choose $\mathsf{Show\ Math\ As\ }\blacktriangleright\mathsf{\ TeX\ Commands}$.
\text
if you don't want $all italics, weird-looking spacing, an' odd apostrophes$. - user856
\vert
gives $\vert$ and \mid
gives $\mid$, but neither works in the column spec for an array. If you cannot type it on your keyboard, you can alwaays copy and paste it from another document. - robjohn
{cc|c}
part in the array code is confusing. - Тyma Gaidash
These are issues that won't affect the correctness of formulas, but might make them look significantly better or worse. Beginners should feel free to ignore this advice; someone else will correct it for them, or more likely nobody will care.
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:
$$\begin{array}{cc} \mathrm{Bad} & \mathrm{Better} \\ \hline \\ e^{i\frac{\pi}2} \quad e^{\frac{i\pi}2}& e^{i\pi/2} \\ \int_{-\frac\pi2}^\frac\pi2 \sin x\,dx & \int_{-\pi/2}^{\pi/2}\sin x\,dx \\ \end{array}$$
The |
symbol has the wrong spacing when it is used as a divider, for example in set comprehensions. Use \mid
instead:
$$\begin{array}{cc} \mathrm{Bad} & \mathrm{Better} \\ \hline \\ \{x|x^2\in\Bbb Z\} & \{x\mid x^2\in\Bbb Z\} \\ \end{array}$$
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.
$$\begin{array}{cc} \mathrm{Bad} & \mathrm{Better} \\ \hline \\ \left\{\dfrac{m}{n} \mid m,n\in\Bbb Z\right\} & \left\{\dfrac{m}{n} \,\middle|\, m,n\in\Bbb Z\right\} \\ \end{array}$$
For double and triple integrals, don't use \int\int
or \int\int\int
. Instead use the special forms \iint
and \iiint
:
$$\begin{array}{cc}
\mathrm{Bad} & \mathrm{Better} \\
\hline \\
\int\int_S f(x)\,dy\,dx & \iint_S f(x)\,dy\,dx \\
\int\int\int_V f(x)\,dz\,dy\,dx & \iiint_V f(x)\,dz\,dy\,dx
\end{array}$$
Use \,
to insert a thin space before differentials; without this $\TeX$ will mash them together:
$$\begin{array}{cc} \mathrm{Bad} & \mathrm{Better} \\ \hline \\ \iiint_V f(x)dz dy dx & \iiint_V f(x)\,dz\,dy\,dx \end{array}$$
When using a function (e.g. $f$, $\sin$, etc) followed by arguments with larger parentheses, insert negative space before the parentheses using \!
:
$$\begin{array}{cc} \mathrm{Bad} & \mathrm{Better} \\ \hline \\ f\left( \dfrac{1}{x} \right) & f\!\left(\dfrac{1}{x}\right) \end{array}$$
When using absolute value, use \lvert ... \rvert
instead of a pair of pipes |...|
.
$$\begin{array}{cc} \mathrm{Bad} & \mathrm{Better} \\ \hline \\ |\sin x| & \lvert\sin x\rvert \end{array}$$
\middle
with | to get it to work with \left
and \right
, like \left\{x\middle | \frac{x^2}{2} \in \mathbb{z}\right\}
: $\left\{x\middle | \frac{x^2}{2} \in \mathbb{z}\right\}$ - asmeurer
\middle \mid
doesn't work. What is the correct way to get the right spacing with automatic vertical resizing? - asmeurer
\left\{\, ... \,\middle|\, ... \,\right\}
like in $\left\{\,x\in\Bbb R\,\middle|\, \frac{x^2}{2}\in\Bbb Z\,\right\}$. - Christoph
\;
and \:
along with \,
, and I think they have different spacing, so it's pretty versatile but can get you stuck on formatting an answer for ages because you were trying to get the spaces to match on the scale of pixels :\ - sreysus
Use \require{cancel}
in the first formula in your post that requires cancelling; you need it only once per page. Then use:
$$\require{cancel}\begin{array}{rl} \verb|y+\cancel{x}| & y+\cancel{x}\\ \verb|\cancel{y+x}| & \cancel{y+x}\\ \verb|y+\bcancel{x}| & y+\bcancel{x}\\ \verb|y+\xcancel{x}| & y+\xcancel{x}\\ \verb|y+\cancelto{0}{x}| & y+\cancelto{0}{x}\\ \verb+\frac{1\cancel9}{\cancel95} = \frac15+& \frac{1\cancel9}{\cancel95} = \frac15 \\ \end{array} $$
Use \require{enclose}
for the following:
$$\require{enclose}\begin{array}{rl} \verb|\enclose{horizontalstrike}{x+y}| & \enclose{horizontalstrike}{x+y}\\ \verb|\enclose{verticalstrike}{\frac xy}| & \enclose{verticalstrike}{\frac xy}\\ \verb|\enclose{updiagonalstrike}{x+y}| & \enclose{updiagonalstrike}{x+y}\\ \verb|\enclose{downdiagonalstrike}{x+y}| & \enclose{downdiagonalstrike}{x+y}\\ \verb|\enclose{horizontalstrike,updiagonalstrike}{x+y}| & \enclose{horizontalstrike,updiagonalstrike}{x+y}\\ \end{array} $$
\enclose
can also produce enclosing boxes, circles, and other notations; see
MathML
menclose
documentation
[1] 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].
\enclose{counterstrike}
? :P - Akiva Weinberger
enclose
a $\LaTeX$ package, or only a MathML option? - Tim Thayer
\cancelto{}{}
- user803596
$\def\demo#1#2{#1{#2}\ #1{#2#2}\ #1{#2#2#2}}$
\overline
: $\demo\overline A$
\underline
: $\demo\underline B$
\widetilde
: $\demo\widetilde C$
\widehat
: $\demo\widehat D$
\fbox
: $\demo\fbox {$E$}$
\underleftarrow
: $\demo\underleftarrow{F}\qquad$ variant: \xleftarrow{}
: $\xleftarrow{abc}$
\underrightarrow
: $\demo\underrightarrow{G}\qquad$ variant: \xrightarrow{}
: $\xrightarrow{abc}$
\underleftrightarrow
: $\demo\underleftrightarrow{H}$
\overrightarrow
$\demo\overrightarrow{AB}$
\overbrace
: $\overbrace{(n - 2) + (n - 1) + (n + 0) + (n + 1) + (n + 2)}$
\underbrace
: $\underbrace{(n - 2) + (n - 1) + (n + 0) + (n + 1) + (n + 2)}$
\underbrace
: underbraces can be nested, like this: $\underbrace{(n - 2) + \underbrace{(n - 1) + \underbrace{(n + 0)} + (n + 1)} + (n + 2)}$
\overbrace
and \underbrace
accept a superscript or a subscript, respectively, to annotate the brace. For example, \underbrace{a\cdot a\cdots a}_{b\text{ times}}
is $$\underbrace{a\cdot a\cdots a}_{b\text{ times}}$$
Note: \varliminf
: $\varliminf$ and \varlimsup
:$\varlimsup$ have special symbol of their own.
\check
: $\check{I}$
\acute
: $\acute{J}$
\grave
: $\grave{K}$
\vec
: $\vec u\ \vec{AB}$ (c.f. \overrightarrow
above)
\bar
: $\bar z$
\hat
: $\hat x$
\tilde
: $\tilde x$
\dot \ddot \dddot
: $\dot x,\ddot x,\dddot x$
\mathring
: $\mathring A$
If you cannot find your symbol remember that you can stack various symbols using
\overset{above}{level}
: $\overset{@}{ABC}\ \overset{x^2}{\longmapsto}\ \overset{\bullet\circ\circ\bullet}{T}$
\underset{below}{level}
: $\underset{@}{ABC}\ \underset{x^2}{\longmapsto}\ \underset{\bullet\circ\circ\bullet}{T}$
You can use these together too. You can type $X \overset{a}{\underset{b}{\to}} Y$ with X\overset{a}{\underset{b}{\to}}Y
.
\overset{ \huge\frown}{PQ}
: $\overset{ \huge\frown}{PQ}$ denotes the arc over points $P$ and $Q$ (As per comment of @Calvin Khor to @Paul Sinclair's question)
$\fbox$
, you could also use $\boxed{...}$
- Mr Pie
stackrel
also seems to work well, as in \stackrel{\text{def}}{=}
$\longrightarrow\stackrel{\text{def}}{=}$ - Reb.Cabin
\widearc {PQ}
doesn't seem to work. - Paul Sinclair
\overset{\frown}{PQ}
: $\overset{\frown}{PQ}$. But since \frown
doesn't adjust in size, it doesn't look right. Does anyone know how get a properly sized arc? - Paul Sinclair
\overset{\frown}{AB}\overset{ \large\frown}{CD}\overset{\Large\frown}{EF}\overset{ \huge\frown}{GH}\overset{\Huge\frown}{ABC}
$\overset{\frown}{AB}\overset{ \large\frown}{CD}\overset{\Large\frown}{EF}\overset{ \huge\frown}{GH}\overset{\Huge\frown}{ABC}$ - Calvin Khor
(For more examples, see this meta question [1].)
AMScd diagrams must start with a "require":
$\require{AMScd}$
\begin{CD}
A @>a>> B\\
@V b V V= @VV c V\\
C @>>d> D
\end{CD}
to get this diagram: $\require{AMScd}$ \begin{CD} A @>a>> B\\ @V b V V= @VV c V\\ C @>>d> D \end{CD}
@>>>
is used for arrow right
@<<<
is used for arrow left
@VVV
is used for arrow down
@AAA
is used for arrow up
@=
is used for horizontal double line
@|
is used for vertical double line
@.
is used for no arrow
Another example:
\begin{CD}
A @>>> B @>{\text{very long label}}>> C \\
@. @AAA @| \\
D @= E @<<< F
\end{CD}
\begin{CD} A @>>> B @>{\text{very long label}}>> C \\ @. @AAA @| \\ D @= E @<<< F \end{CD}
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}
$\require{AMScd}$ \begin{CD} \text{RCOHR'SO$_3$Na} @>{\text{Hydrolysis, $\Delta,$ Dil. HCl}}>> \text{(RCOR')+NaCl+SO$_2$+ H$_2$O} \end{CD}
[1] https://math.meta.stackexchange.com/q/2324/\begin{array}…\end{array}
and \left\{…\right.
. For example, you get 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. $$
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.
$$
\begin{cases}…\end{cases}
. The same system$$ \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} $$
is produced by the following code
$$\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}
$$
=
signs use \begin{aligned}...\end{aligned}
and \left\{…\right.
(see asmeurer's comment)
$$\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. $$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.
$$
=
signs and the terms as in
$$\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.$$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.
$$
\\[2ex]
instead of \\
. The system$$\begin{cases} a_1x+b_1y+c_1z=\frac{p_1}{q_1} \\[2ex] a_2x+b_2y+c_2z=\frac{p_2}{q_2} \\[2ex] a_3x+b_3y+c_3z=\frac{p_3}{q_3} \end{cases} $$
is generated by the following code
$$\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
$$\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} $$
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}
$$
In response to elect's comment [2]. The following code
$$ \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
$$ \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. $$
[1] https://math.meta.stackexchange.com/a/5025/752Named colors are browser-dependent; if a browser doesn't know a particular color name, it may render the text as black. The following colors are standard in HTML4 and CSS2 and should be interpreted the same by most browsers: $$\begin{array}{|rc|} \hline \verb+\color{black}{text}+ & \color{black}{text} \\ \verb+\color{gray}{text}+ & \color{gray}{text} \\ \verb+\color{silver}{text}+ & \color{silver}{text} \\ \verb+\color{white}{text}+ & \color{white}{text} \\ \hline \verb+\color{maroon}{text}+ & \color{maroon}{text} \\ \verb+\color{red}{text}+ & \color{red}{text} \\ \verb+\color{yellow}{text}+ & \color{yellow}{text} \\ \verb+\color{lime}{text}+ & \color{lime}{text} \\ \verb+\color{olive}{text}+ & \color{olive}{text} \\ \verb+\color{green}{text}+ & \color{green}{text} \\ \verb+\color{teal}{text}+ & \color{teal}{text} \\ \verb+\color{aqua}{text}+ & \color{aqua}{text} \\ \verb+\color{blue}{text}+ & \color{blue}{text} \\ \verb+\color{navy}{text}+ & \color{navy}{text} \\ \verb+\color{purple}{text}+ & \color{purple}{text} \\ \verb+\color{fuchsia}{text}+ & \color{magenta}{text} \\ \hline \end{array}$$
HTML5 and CSS 3 [1] define an additional 124 color names that will be supported on many browsers [2].
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:
$$\begin{array}{|rrrrrrrr|}\hline \verb+#000+ & \color{#000}{text} & & & \verb+#00F+ & \color{#00F}{text} & & \\ & & \verb+#0F0+ & \color{#0F0}{text} & & & \verb+#0FF+ & \color{#0FF}{text}\\ \verb+#F00+ & \color{#F00}{text} & & & \verb+#F0F+ & \color{#F0F}{text} & & \\ & & \verb+#FF0+ & \color{#FF0}{text} & & & \verb+#FFF+ & \color{#FFF}{text}\\ \hline \end{array} $$
$$\begin{array}{|rrrrrrrr|} \hline \verb+#000+ & \color{#000}{text} & \verb+#005+ & \color{#005}{text} & \verb+#00A+ & \color{#00A}{text} & \verb+#00F+ & \color{#00F}{text} \\ \verb+#500+ & \color{#500}{text} & \verb+#505+ & \color{#505}{text} & \verb+#50A+ & \color{#50A}{text} & \verb+#50F+ & \color{#50F}{text} \\ \verb+#A00+ & \color{#A00}{text} & \verb+#A05+ & \color{#A05}{text} & \verb+#A0A+ & \color{#A0A}{text} & \verb+#A0F+ & \color{#A0F}{text} \\ \verb+#F00+ & \color{#F00}{text} & \verb+#F05+ & \color{#F05}{text} & \verb+#F0A+ & \color{#F0A}{text} & \verb+#F0F+ & \color{#F0F}{text} \\ \hline \verb+#080+ & \color{#080}{text} & \verb+#085+ & \color{#085}{text} & \verb+#08A+ & \color{#08A}{text} & \verb+#08F+ & \color{#08F}{text} \\ \verb+#580+ & \color{#580}{text} & \verb+#585+ & \color{#585}{text} & \verb+#58A+ & \color{#58A}{text} & \verb+#58F+ & \color{#58F}{text} \\ \verb+#A80+ & \color{#A80}{text} & \verb+#A85+ & \color{#A85}{text} & \verb+#A8A+ & \color{#A8A}{text} & \verb+#A8F+ & \color{#A8F}{text} \\ \verb+#F80+ & \color{#F80}{text} & \verb+#F85+ & \color{#F85}{text} & \verb+#F8A+ & \color{#F8A}{text} & \verb+#F8F+ & \color{#F8F}{text} \\ \hline \verb+#0F0+ & \color{#0F0}{text} & \verb+#0F5+ & \color{#0F5}{text} & \verb+#0FA+ & \color{#0FA}{text} & \verb+#0FF+ & \color{#0FF}{text} \\ \verb+#5F0+ & \color{#5F0}{text} & \verb+#5F5+ & \color{#5F5}{text} & \verb+#5FA+ & \color{#5FA}{text} & \verb+#5FF+ & \color{#5FF}{text} \\ \verb+#AF0+ & \color{#AF0}{text} & \verb+#AF5+ & \color{#AF5}{text} & \verb+#AFA+ & \color{#AFA}{text} & \verb+#AFF+ & \color{#AFF}{text} \\ \verb+#FF0+ & \color{#FF0}{text} & \verb+#FF5+ & \color{#FF5}{text} & \verb+#FFA+ & \color{#FFA}{text} & \verb+#FFF+ & \color{#FFF}{text} \\ \hline \end{array}$$
You can have a look here for quick reference on colors in HTML [3].
[1] http://en.wikipedia.org/wiki/Cascading_Style_Sheets#CSS_3rgb
, rgba
, hsl
, and hsla
colours. (I'd edit the answer, but have no time now. Maybe later, if nobody else beats me to it.) - Harald Hanche-Olsen
For longer calculations (or referring to other post's results) it is convenient to use the tagging/labelling/referencing system. To tag an equation use \tag{yourtag}
, and if you want to refer to that tag later on, add \label{somelabel}
right after the \tag
. It is not necessary that yourtag
and somelabel
are the same, but it usually is more convenient to do so:
$$ a := x^2-y^3 \tag{*}\label{*} $$
$$ a := x^2-y^3 \tag{*}\label{*} $$
In order to refer to an equation, just use \eqref{somelabel}
$$ a+y^3 \stackrel{\eqref{*}}= x^2 $$
$$ a+y^3 \stackrel{\eqref{*}}= x^2 $$
or \ref{somelabel}
Equations are usually referred to as $\eqref{*}$, but you can also use $\ref{*}$.
Equations are usually referred to as $\eqref{*}$, but you can also use $\ref{*}$.
As you can see, references are even turned into hyperlinks, which you can use externally as well, e.g. like this [1]. 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
[2], as
a workaround you can put
$\def\label#1{}$
in your post while editing and remove that on submission
[3] - unfortunately this means you won't spot misspelled references before submitting... Just don't forget to remove that \def
again
\eqref{*}
yields a clickable $\eqref{*}$ - Tobias Kienzler
\begin{align}
etc.... Though personally I'd agree with this - Tobias Kienzler
\begin{array}{lc}
or similar. - Tobias Kienzler
\tag{*}\label{*}
work—when I use it, the equation is never rendered into an image and in the code that is displayed in place of the image this show up as "\tag{}\label{}". \tag{1}\label{1}
on the other hand does work. - HelloGoodbye
To make a continued fraction, use \cfrac
, which works just like \frac
but typesets the results differently:
$$ x = a_0 + \cfrac{1^2}{a_1 + \cfrac{2^2}{a_2 + \cfrac{3^2}{a_3 + \cfrac{4^4}{a_4 + \cdots}}}}$$
Don't use regular \frac
or \over
, or it will look awful:
$$ x = a_0 + \frac{1^2}{a_1 + \frac{2^2}{a_2 + \frac{3^2}{a_3 + \frac{4^4}{a_4 + \cdots}}}}$$
You can of course use \frac
for the compact notation:
$$ x = a_0 + \frac{1^2}{a_1+} \frac{2^2}{a_2+} \frac{3^2}{a_3 +} \frac{4^4}{a_4 +} \cdots$$
Continued fractions are too big to put inline. Display them with $$
…$$
or use a notation like $[a_0; a_1, a_2, a_3, \ldots]$.
\frac12{\vphantom{1}\atop+}\frac34
) - MJD
\underset{j=1}{\overset{\infty}{\LARGE\mathrm K}}\frac{a_j}{b_j}=\cfrac{a_1}{b_1+\cfrac{a_2}{b_2+\cfrac{a_3}{b_3+\ddots}}}
to get $$\underset{j=1}{\overset{\infty}{\LARGE\mathrm K}}\frac{a_j}{b_j}=\cfrac{a_1}{b_1+\cfrac{a_2}{b_2+\cfrac{a_3}{b_3+\ddots}}}.$$ - Américo Tavares
\mathop
instead of \overset
and \underset
: \mathop{\LARGE\mathrm K}_{i=1}^\infty \frac{a_i}{b_i}
$$\mathop{\LARGE\mathrm K}_{i=1}^\infty \frac{a_i}{b_i}$$ - AlexR
\newcommand
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
$ \newcommand{\SES}[3]{ 0 \to #1 \to #2 \to #3 \to 0 } $
$ \newcommand{\SES}[3]{ 0 \to #1 \to #2 \to #3 \to 0 }$
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:
$$ \SES{A}{B}{C} $$
It's also possible to use plain \def
:
\def\ses#1#2#3{0 \to #1 \to #2 \to #3 \to 0}
and then $\ses{A}{B}{C}$
will produce the same output.
\implies
($\implies$) is a
marginally preferable
[1] alternative to \Rightarrow
($\Rightarrow$) for implication.
There's also \iff
$\iff$ and \impliedby
$\impliedby$.
\to
($\to$) is preferable to \rightarrow
or \longrightarrow
for things like $f\colon A \to B$. The reverse is \gets
($\gets$).
\to
and \mapsto
as in $T:\mathbb R\to \mathbb R,\; x\mapsto x+1$ produced by T:\mathbb R\to \mathbb R,\; x\mapsto x+1
- yo'
\to
when it appears as part of a larger propositional formula, rather than at the top level, i.e. $p\land((q\lor r)\to s)$, because the spacing is similar to that of other binary operators. \implies
is better for sentence- or clause-level implications, or in displays, i.e. $$x+2=4-x\implies x=1.$$ - Mario Carneiro
\overset{3.1415}{\underset{26535}{\implies}}
produces $$\overset{3.1415}{\underset{26535}{\implies}}$$ - user645636
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\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). $$
Note that curly braces need to be escaped as \{ \}
.
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 $$ \begin{aligned} a=&\left(1+2+3+ \cdots \right. \\ & \cdots+ \left. \infty-2+\infty-1+\infty\right). \end{aligned} $$
There is also a \middle
construct which is useful when one has a mid-expression brace which must also scale up:
$$
\left\langle
q
\middle\|
\frac{\frac{x}{y}}{\frac{u}{v}}
\middle|
p
\right\rangle
$$
renders as $$ \left\langle q\middle\|\frac{\frac{x}{y}}{\frac{u}{v}} \middle| p \right\rangle. $$
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 type \big(\frac 1x\big)
$\big(\frac 1x\big)$
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)
$\Bigg(\bigg(\Big(\big((x)\big)\Big)\bigg)\Bigg)$
\Big( ... \Big)
produces $\Big(\dots\Big)$ but this bracket size is fixed in all situations unlike \left( ... \right)
which varies in size with its contents. \Big
can be useful in various situations. - Nick
To make a limit (like $\lim \limits_{x \to 1} \frac{x^2-1}{x-1}$), use this syntax:
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 \limits_{x \to 1}$. The \to
inside makes the right arrow, rendered as $\to$. The _
makes the $x \to 1$ go underneath the $\lim$. Finally, the pair of curly braces { }
makes sure that $x \to 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, $\lim \limits_{x \to 1} \frac{x^2-1}{x-1}$, simply use $\lim\limits_{x \to 1} \frac{x^2-1}{x-1}$
.
And that is how you make a limit using MathJax.
\lim_{x\to 1}
$$\lim_{x\to 1}?$$ As I understand it \limits
is only needed for operations that don't already understand limits, for example if you want to use +
and get $$\mathop{+}\limits_{i=1}^k\text{ instead of }+_{i=1}^k$$ When used inline, your suggestion will produce $\lim\limits_{x\to 1}$ instead of the more compact form $\lim_{x\to 1}$ that mathjax normally chooses. Are you sure this is good advice? - MJD
$\lim_{x\to 1}
renders to $\lim_{x\to 1}$, and $\lim\limits_{x\to 1
renders as $lim\limits_{x\to 1}$. Note how the $x\to 1$ is separated from the first limit, and not directly underneath. We do not write limits like that in real life, so we use \limits
. - Anonymous Computer
\lim\limits_{x\mapsto 1}\dfrac1x
: $\lim\limits_{x\mapsto 1}\dfrac1x$. On the other hand, when I let $\TeX$ do what it wants to do, using \lim_{x\mapsto 1}\frac1x
, the spacing between the lines stays the same, which is much neater: $\lim_{x\mapsto 1}\frac1x$. This is much easier on the eyes. If you want to make your math mode more prominent then take a new line using $$-$$
- user1729
If an operator is not available as a built-in command, use \operatorname{…}
. So for things like $$\operatorname{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
[1] by
Charles Staats
[2]. 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
$$
\operatorname*{Res}_{z=1}\left(\frac1{z^2-z}\right)=1
$$
New operators may also be defined using the \DeclareMathOperator
syntax: \DeclareMathOperator{newOperatorCommand}{newOperator}
$\DeclareMathOperator{newOperatorCommand}{newOperator}$ defines a new operator. On the page where this code occurs, \newOperatorCommand
will be rendered as $\newOperatorCommand$.
\rm
will change the font but not the spacing. \operatorname{arsinh}x
renders as “$\operatorname{arsinh}x$” while {\rm arsinh}x
renders as “${\rm arsinh}x$”. Notice the added space between operator and operand in the first example, which is missing in the second. On the whole, I'd say that operatorname
is a lot more in the spirit of semantic markup, declaring what you want to write instead of how you want to write it, so I'd strongly suggest using this. - MvG
\operatorname
in the main post, and decided to leave it out. The reason is simple: If a beginner omits \operatorname
, the resulting formula will still be perfectly clear, and a more experienced user will have no trouble inserting the \operatorname
where it is needed. So including it in the main post would not be a good use of space. - MJD
\DeclareMathOperator{\arsinh}{arsinh}
at the post's top. Never tried it though… - MickG
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
$$ \bbox[yellow] { e^x=\lim_{n\to\infty} \left( 1+\frac{x}{n} \right)^n \qquad (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
$$ \bbox[yellow,5px] { e^x=\lim_{n\to\infty} \left( 1+\frac{x}{n} \right)^n \qquad (1) } $$
To add a border, use
$$ \bbox[5px,border:2px solid red]
{
e^x=\lim_{n\to\infty} \left( 1+\frac{x}{n} \right)^n
\qquad (2)
}
$$
produces
$$ \bbox[5px,border:2px solid red] { e^x=\lim_{n\to\infty} \left( 1+\frac{x}{n} \right)^n \qquad (2) } $$
You can do both border and background, as well:
$$ \bbox[yellow,5px,border:2px solid red]
{
e^x=\lim_{n\to\infty} \left( 1+\frac{x}{n} \right)^n
\qquad (1)
}
$$
produces
$$ \bbox[yellow,5px,border:2px solid red] { e^x=\lim_{n\to\infty} \left( 1+\frac{x}{n} \right)^n \qquad (1) } $$
The absolute value of some expression can be denoted as \lvert x\rvert
or, more generally, as \left\lvert … \right\rvert
. It renders as $\lvert x\rvert$.
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 $\lVert v\rVert$. (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:
And here is the same formula rendered by your browser:
$$|x|, ||v|| \quad\longrightarrow\quad \lvert x\rvert, \lVert v\rVert$$
It was typeset as
$$|x|, ||v|| \quad\longrightarrow\quad \lvert x\rvert, \lVert v\rVert$$
\|x\|
instead of \lVert x \rVert
; $\|x\|$ and $\lVert x \rVert$. (I don't think that there is a difference between them. I've tried [asking on SE](tex.stackexchange.com/questions/77767/whats-the-correct-way-to-write-norm).) - Martin Sleziak
|x|
and \lvert x\rvert
($|x|$ and $\lvert x\rvert$) look identical, contrary to your claim. Perhaps you need to show an example more complicated than just 'x'? - MJD
||
version. On Linux they looked the same. - MJD
|
in STIX doesn't descend below the baseline, while in the MathJax TeX fonts it does. - Davide Cervone
To produce 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}
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}
\tag
commands in my equations causes them to break. It only takes one tag per equation and it labels the entire thing instead of allowing tagging on a per-line basis. Any ideas? - code_dredd
\tag
is meant for. It puts the (1) exactly where it should be, at the right margin. Second, if you have an equation like 0 = ax^2+bx+c
and you just use (1)
on it instead of \tag1
, you end up with $0 = ax^2+bx+c(1)$. To fix this, instead of \tag
you have to insert other commands to make enough blank space. Not a net gain, in my opinion. - David K
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:
$$\spadesuit\quad\heartsuit\quad\diamondsuit\quad\clubsuit$$
Or if you're really fussy:
\color{red}{\heartsuit}
and \color{red}{\diamondsuit}
$$\color{red}{\heartsuit}\quad\color{red}{\diamondsuit}$$
You can also enter the standard Unicode characters (U+2660 BLACK SPADE SUIT
etc.) literally, or copy them from here:
$$♠\quad♡\quad♢\quad♣\\ ♤\quad♥\quad♦\quad♧ $$
$$\color{yellow}♥\!\!\!\color{blue}♡$$
but you will need to fiddle with the number of \!
s depending on where you put it, because I don't think there is a command in mathJax to place characters on top of each other. Another example,$$\Huge \color{green}\Huge \color{green}♥\!\!\!\!\!\!\!\!\!\!\,\color{red}♡$$
gives $$\Huge \color{green}♥\!\!\!\!\!\!\!\!\!\!\,\color{red}♡ $$ - Calvin Khor
Another way to display the arrows for right and left implication instead of using
$\Rightarrow$
, $\Leftarrow$
and $\Leftrightarrow$
which produces $\Rightarrow$, $\Leftarrow$ and $\Leftrightarrow$ respectively, you can use
$\implies$
for $\implies$, $\impliedby$
for $\impliedby$ and $\iff$
for $\iff$
The latter of which produces longer arrows which may be more desirable to some.
Standard Mathjax does not yet support a dedicated degree symbol, so here are some of the ways to try and emulate one :
$$ \begin{array} \\ \text{45^\text{o}} & \text{renders as} & 45^\text{o} \\ \text{45^o} & \text{renders as} & 45^o \\ \text{45^\circ} & \text{renders as} & 45^\circ \\ \text{45^{\large\circ}} & \text{renders as} & 45^{\large\circ}\\ \text{45\unicode{xB0}} & \text{renders as} & 45\unicode{xB0} & \text{Actual Unicode character}\\ \text{90°} & \text{renders as} & 90° & \text{Using keyboard entry of symbol} % % Use the following line as a template for additional entries % % \text{} & \text{renders as} & \\ \end{array} $$
The degree symbol for angles is not ^\circ
. Although many people use this notation, the result looks quite different from the canonical
degree symbol
[1] 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 [2].
Note that comments below indicate that on some configurations at least, °
renders inferior to ^\circ
. And I recently had
a post of mine edited
[3] 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
[4] 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.
\degree
macro. There should be one, imho. - MvG
^\circ
looks good: a.pomf.se/xnlfyg.png - MJD
Alt
and typing 0176
on the numeric keypad. °
(I don't know how international the actual number is). The leading zero is required. - Joffan
^o
imho), or to mention a LaTeX approach just to say it won't work. You deleted the example for 45°
, but kept the sentence talking about it, including the colon. I'm reluctant to revert your edit on a CW page without a conversation, but as it stands I see the edit as a change for the worse. Can we find a combined solution? - MvG
\degree
symbol, since I believe it would be technically easy and conceptually beneficial to have such a symbol defined for the whole site. - MvG
\mathring
and hence there is a further variant a\mathring{}
$a\mathring{}$ which is neither circ
$a^\circ$ nor the actual unicode symbol $a°$ - Calvin Khor
$$
\require{enclose}
\begin{array}{r}
13 \\[-3pt]
4 \enclose{longdiv}{52} \\[-3pt]
\underline{4}\phantom{2} \\[-3pt]
12 \\[-3pt]
\underline{12}
\end{array}
$$
$$ \require{enclose} \begin{array}{r} 13 \\[-3pt] 4 \enclose{longdiv}{52} \\[-3pt] \underline{4}\phantom{2} \\[-3pt] 12 \\[-3pt] \underline{12} \end{array} $$
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.
This is adapted from https://stackoverflow.com/a/22871404/3466415 (which uses slightly different but not less valid formatting).
\begin{array}{c|rrrr}& x^3 & x^2 & x^1 & x^0\\ & 1 & -6 & 11 & -6\\ {\color{red}1} & \downarrow & 1 & -5 & 6\\ \hline & 1 & -5 & 6 & |\phantom{-} {\color{blue}0} \end{array}
- Américo Tavares
\begin{array}{rrrr|ll} x^3 & -6x^2 & +11x & -6 & x - 1 \\ -x^3 & +x^2 & & & x^2-5x+6 \\ \hline & -5x^2 & +11x & -6\\ & \phantom{-}5x^2 & -5x & & & & \\ \hline & & +6x & -6 \\ & & -6x & +6 \\ \hline & & 0 & 0 \end{array}
- Américo Tavares
Many things like fractions, sums, limits, and integrals display differently when written inline versus in a displayed formula. You can switch styles back and forth with \displaystyle
and \textstyle
in order to achieve the desired appearance.
Here's an example switching back and forth in a displayed equation:
$$\sum_{n=1}^\infty \frac{1}{n^2} \to \textstyle \sum_{n=1}^\infty \frac{1}{n^2} \to \displaystyle \sum_{n=1}^\infty \frac{1}{n^2}$$
$$\sum_{n=1}^\infty \frac{1}{n^2} \to \textstyle \sum_{n=1}^\infty \frac{1}{n^2} \to \displaystyle \sum_{n=1}^\infty \frac{1}{n^2}$$
It is possible to switch style inline as well:
Compare $\displaystyle \lim_{t \to 0} \int_t^1 f(t)\, dt$ versus $\lim_{t \to 0} \int_t^1 f(t)\, dt$.
Compare $\displaystyle \lim_{t \to 0} \int_t^1 f(t)\, dt$ versus $\lim_{t \to 0} \int_t^1 f(t)\, dt$.
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 filler text. It would not occur to me to use $\displaystyle \lim_{t \to 0} \int_t^1 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.
\displaystyle
. - Simply Beautiful Art
$\scriptstyle{AbC}$
and $\scriptscriptstyle{AbC}$ $\scriptscriptstyle{AbC}$
. - emacs drives me nuts
Some formulas such as $\overline a+\overline b=\overline {a\cdot b}$, $\sqrt{a}-\sqrt{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:
$\sqrt{\mathstrut a} - \sqrt{\mathstrut b}$
Which yields: $\sqrt{\mathstrut a} - \sqrt{\mathstrut 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}$
Which renders as: $\sqrt{\vphantom{b} a} - \sqrt{b}$.
Another issue is with the spacing within lines in situations like this,
Based on the previous technique, we can simplify $\dfrac{1}{\sqrt{\vphantom{b} a} - \sqrt{b}}$, and we thus get the result 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:
Based on the previous technique, we can simplify $\smash{\dfrac{1}{\sqrt{\vphantom{b} a} - \sqrt{b}}}$, and we thus get the result 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]...
\rule{0pt}{2ex}
, as explained here. - on4aa
\smash
look awful. The formula overlaps the text. - dfeuer
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 \tag{1}\label{eq1}$$
Equation $\eqref{eq1}$ is one of the greatest equations in mankind's history. Equation $\eqref{eq1}$ is produced using the following code,
$$e=mc^2 \tag{1}\label{eq1}$$
To refer to it, use \eqref{eq1}
.
Multi-line equation is actually just one equation rather than several equations. So the correct environment is aligned
instead of align
.
$$\begin{equation}\begin{aligned} a &= b + c \\ &= d + e + f + g \\ &= h + i \end{aligned}\end{equation}\tag{2}\label{eq2}$$
Equation $\eqref{eq2}$ is a multi-line equation. The code to produce equation $\eqref{eq2}$ is
$$\begin{equation}\begin{aligned}
a &= b + c \\
&= d + e + f + g \\
&= h + i
\end{aligned}\end{equation}\tag{2}\label{eq2}$$
For multiple aligned equations, we use the align
environment.
$$\begin{align} a &= b + c \tag{3}\label{eq3} \\ x &= yz \tag{4}\label{eq4}\\ l &= m - n \tag{5}\label{eq5} \end{align}$$
Equation $\eqref{eq3}$, $\eqref{eq4}$ and $\eqref{eq5}$ are multiple equations aligned together. The code to produce these equations is,
$$\begin{align}
a &= b + c \tag{3}\label{eq3} \\
x &= yz \tag{4}\label{eq4}\\
l &= m - n \tag{5}\label{eq5}
\end{align}$$
\tag{1}
for line 1, \tag{2}
for line 2, etc? If I use the \tag{...}
commands, I can only use one per equation and it labels the entire equation, not each line. - code_dredd
align*
instead of align
- user173262
$$
and \begin{equation}
with aligned
? I noticed that when I omitted \begin{equation}
that I did not get an equation number, but that does not happen when I use only $$
without any other environments inside. - Randy Cragun
aligned
and align
? (I understand they should be used with single equations and multiple equations respectively.) I've checked the link mentioned in an earlier comment which shows several examples of differences, but none of them seem to apply when using Mathjax here on Math Stack Exchange; they use environments like tabular
or list
or enumerate
, none of which are recognized by Mathjax. Also, is there any reason to use \begin{equation}
and \end{equation}
if equations are not being numbered? - A.J.
\label{ }
for reference. To align multiple equations, we need to escape twice like: \begin{align} a &= b + c \tag{Eq.3}\\\\ x &= yz \tag{Eq.4}\\\\ l &= m - n \tag{Eq.5} \end{align}
. Also, you don't need $$
, which is for a single equation and it is equivalent to \begin{equation}
- Leon Chang
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}
\begin{array}{ll} \text{maximize} & c^T x \\ \text{subject to}& d^T x = \alpha \\ &0 \le x \le 1. \end{array}
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}
\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}
We treat $\max$, $z$, each variable, $\pm$ 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.
Optional: \tag
is used to label the constraints.
To get fractions, execute format rat
at the beginning.
Writing manually the $\rm\LaTeX$ code for a matrix with many rows and columns in Octave is tedious. The Octave function
strcat("\\begin{bmatrix}\n",strrep(strrep(mat2str(A)," "," & "), ...
";"," \\\\\n")(2:end-1),"\n\\end{bmatrix}\n")
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}
so that pasting the generated code gives
$$ \begin{bmatrix} 1 & 2 & 2 \\ 2 & 3 & 4 \\ 4 & 4 & 2 \end{bmatrix}. $$
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
\end{array}
\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 \end{array}
It can be stacked up to give an illustration of the entering of variables at different stages.
\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}
\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}
\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}
\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}
It can be stacked up to give a theoretical illustration of what happens in the upcoming steps.
\begin{array}{rrrrrrr|r} & x_1 & x_2 & x_3 & s_1 & s_2 & s_3 & \\ \hline s_1 & -2 & 0 & -2 & 1 & 0 & 0 & -60 \\ s_2 & -2 & -4^* & -5 & 0 & 1 & 0 & -70 \\ s_3 & 0 & -3 & -1 & 0 & 0 & 1 & -27 \\ \hdashline & 8 & 10 & 25 & 0 & 0 & 0 & 0 \\ \text{ratio} & -4 & -5/2 & -5 & & & & \\ \hline s_1 & -2^* & 0 & -2 & 1 & 0 & 0 & -60 \\ x_2 & 1/2 & 1 & 5/4 & 0 & -1/4 & 0 & 35/2 \\ s_3 & 3/2 & 0 & 11/4 & 0 & -3/4 & 1 & 51/2 \\ \hdashline & 3 & 0 & 25/2 & 0 & 5/2 & 0 & -175 \\ \text{ratio} & -3/2 & & 25/4 & & & & \\ \hline x_1 & 1 & 0 & 1 & -1/2 & 0 & 0 & 30 \\ x_2 & 0 & 1 & 3/4 & 1/4 & -1/4 & 0 & 5/2 \\ s_3 & 0 & 0 & 5/4 & 3/4 & -3/4^* & 1 & -39/2 \\ \hdashline & 0 & 0 & 19/2 & 3/2 & 5/2 & 0 & -265 \\ \text{ratio} & & & & & \dots & & \\ \hline x_1 & 1 & 0 & 1 & -1/2 & 0 & 0 & 30 \\ x_2 & 0 & 1 & 1/3 & 0 & 0 & -1/3 & 9 \\ s_2 & 0 & 0 & -5/3 & -1 & 1 & -4/3 & 26 \\ \hdashline & 0 & 0 & 41/3 & 4 & 0 & 10/3 & -330 \end{array}
A picture is worth a thousand words [1].
$$ \require{extpfeil} % produce extensible horizontal arrows \begin{array}{ccc} % arrange LPPs % first row % first LPP \begin{array}{ll} \max & z = c^T x \\ \text{s.t.} & A x \le b \\ & x \ge 0 \end{array} & \xtofrom{\text{duality}} & % second LPP \begin{array}{ll} \min & v = b^T y \\ \text{s.t.} & A^T y \ge c \\ & y \ge 0 \end{array} \\ ({\cal PC}) & & ({\cal DC}) \\ \text{add } {\Large \downharpoonleft} \text{slack var} & & \text{minus } {\Large \downharpoonright} \text{surplus var}\\ % Change to your favorite arrow style % % second row % third LPP \begin{array}{ll} \max & z = c^T x \\ \text{s.t.} & A x + s = b \\ & x,s \ge 0 \end{array} & \xtofrom[\text{some steps skipped}]{\text{duality}} & % fourth LPP \begin{array}{ll} \min & v = b^T y \\ \text{s.t.} & A^T y - t = c \\ & y,t \ge 0 \end{array} \\ ({\cal PS}) & & ({\cal DS}) % \end{array} $$
[1] https://math.stackexchange.com/q/2572928/290189While $\LaTeX$ has packages that format units, MathJax does not. For visual consistency, one 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
[1] recommends a small space between the value and units. In addition, follow the below conventions for formatting values and units:
Following the conventions of the English-speaking world, a period .
should be used to separate the decimal part of a number from the integral part, not a comma ,
as is common in some languages. This is because commas are already reserved for separating mathematical notation such as arguments of multivariate functions, elements of a set, and the coordinates of ordered tuples.
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$.
It is preferable to write scientific or engineering notation like this: 4.15\times10^{n}
$4.15 \times10^{n}$. The spacing around \times
$\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
$\mathrm{E}\,6$\scriptsize{\mathrm{E}}\,\normalsize{6}
$\scriptsize{\mathrm{E}}\,\normalsize{6}$\mathrm{e}\,6
$\mathrm{e}\,6$A small space on either side is perfectly fine and recommended.
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}
$\mathrm{m}$\mathrm{kg}
$\mathrm{kg}$\mathrm{ft.}
$\mathrm{ft.}$Do not use a period with symbolic units; do use a period with abbreviated units.
Multiplied units conjoined by a dot should follow the form \mathrm{u}\!\cdot\!\mathrm{v}
$\mathrm{u}\!\cdot\!\mathrm{v}$. (I have this sequence of commands saved under the keyboard shortcut umul
on my devices.) Because of how \cdot
is designed (i.e., to separate numbers), the small negative space \!
on either side maintains uniform spacing throughout the whole compound unit. For example,
\mathrm{N}\!\cdot\!\mathrm{m}
$\mathrm{N}\!\cdot\!\mathrm{m}$\mathrm{s}\!\cdot\!\mathrm{A}
$\mathrm{s}\!\cdot\!\mathrm{A}$Do not use \times
$\times$ as a separator.
Divided units conjoined by a solidus should follow the form \left.\mathrm{u}\middle/\mathrm{v}\right.
$\left.\mathrm{u}\middle/\mathrm{v}\right.$. (I have this sequence of commands saved under the keyboard shortcut udiv
on my devices.) The extra markdown is to ensure that solidus stretches the entire height of the unit, especially when exponents are involved. For example,
\left.\mathrm{J}\middle/\mathrm{s}\right.
$\left.\mathrm{J}\middle/\mathrm{s}\right.$\left.\mathrm{m}\middle/\mathrm{s}^2\right.
$\left.\mathrm{m}\middle/\mathrm{s}^2\right.$You may include small negative spaces \!
on either side of the solidus if you please.
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
$\mathrm{m}^2$\left.\mathrm{m}\middle/\mathrm{s}^2\right.
$\left.\mathrm{m}\middle/\mathrm{s}^2\right.$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.
$\left.\mathrm{kg}\!\cdot\!\mathrm{m}^2\middle/\left(\mathrm{C}\!\cdot\!\mathrm{s}\right)\right.$If you prefer to use no separators and only powers, separator each single \mathrm{}
with a small space \,
and use exponents as necessary. For example,
\mathrm{m}\,\mathrm{s}^{-2}
$\mathrm{m}\,\mathrm{s}^{-2}$\mathrm{s}^{-1}\,\mathrm{mol}
$\mathrm{s}^{-1}\,\mathrm{mol}$\mu_0=4\pi\times10^{-7} \ \left.\mathrm{\mathrm{T}\!\cdot\!\mathrm{m}}\middle/\mathrm{A}\right.
$$\mu_0=4\pi\times10^{-7} \ \left.\mathrm{\mathrm{T}\!\cdot\!\mathrm{m}}\middle/\mathrm{A}\right.$$
180^\circ=\pi \ \mathrm{rad}
$$180^\circ=\pi \ \mathrm{rad}$$
N_A = 6.022\times10^{23} \ \mathrm{mol}^{-1}
$$N_A = 6.022\times10^{23} \ \mathrm{mol}^{-1}$$
[1] https://www.bipm.org/en/publications/si-brochure/\mathcal{MathJax}
to write MathJax
. - The Amplitwist
To give an example of how this might be useful, I wanted to express an algorithm in more or less the same indentation and symbolic way it appears in a paper.
On my desktop browsers (Chrome, Firefox) the following appears reasonably well spaced and indented, but loses indentation on my Android smartphone:
Input: positive integer $n$
Output: Tangent numbers $T_1,\ldots,T_n$
$T_1\gets 1$
for
$k$ from
$2$ to
$n$
$T_k\gets (k−1)T_{k−1}$
for
$k$ from
$2$ to
$n$
for
$j$ from
$k$ to
$n$
$T_j\gets (j −k)T_{j−1} + (j −k+2)T_j$
return
$\;T_1,T_2,\ldots,T_n$.
The source can be examined for specific techniques, but the basic trick is that a MathJax dollar-delimiter can follow a closing back-tick code delimiter, but an opening back-tick should be preceded by a space when following the (closing) dollar-sign delimiter.
Here is a version using \phantom
rather than code monospacing to produce indents and tweaking the spacing between code and MathJax expressions with \;
, so that the results appear clear on Android browsers:
Input: positive integer $n$
Output: Tangent numbers $T_1,\ldots,T_n$
$T_1\gets 1$
for
$\;k\;$ from
$2\;$ to
$\;n$
$\phantom{{}++{}}$ $T_k\gets (k−1)T_{k−1}$
for
$\;k\;$ from
$2\;$ to
$\;n$
$\phantom{{}++{}}$ for
$\;j\;$ from
$\;k\;$ to
$\;n$
$\phantom{{}++{}}$ $\phantom{{}++{}}$ $T_j\gets (j −k)T_{j−1} + (j −k+2)T_j$
return
$\;T_1,T_2,\ldots,T_n$.
\space
, \quad
, and \qquad
- Simply Beautiful Art
code
and MathJax formatting on a line. - hardmath
\texttt
if I were you. Regardless, this answer probably does not belong here. - pzp
<code></code>
spacers a bit by writing <codde/>
, at least in my Jupyter notebooks in Chrome. - Reb.Cabin
This is a heuristic solution for coding Markov chains in Mathjax using a combination of commutative diagrams, the encircle tool and font sizes. There are a few minor issues with this method, for instance the arrows' ends should be attached closer to their targets. Also, it lacks double-headed diagonal arrows and it is difficult to attach probabilities to diagonal arrows. Therefore, it's mostly useful for small chains.
$$ \require{enclose} \begin{array}{ccccccccc} \Large{\enclose{circle}{A}} & \xrightarrow{0.1} & \Large{\enclose{circle}{B}} & \xrightarrow{0.2} & \Large{\enclose{circle}{C}} & \xleftarrow{0.3} & \Large{\enclose{circle}{D}} & \xleftarrow{0.4} & \Large{\enclose{circle}{E}}\\\ \scriptsize{0.5}\large{\downarrow} & \scriptsize{0.6}\large{\searrow} & \scriptsize{0.7}\large{\downarrow} & \scriptsize{0.8}\large{\nearrow} & \scriptsize{0.9}\large{\downarrow} & \scriptsize{0.1}\large{\swarrow} & \scriptsize{0.2}\large{\downarrow} & \scriptsize{0.3}\large{\nwarrow} & \scriptsize{0.4}\large{\downarrow}\\\ \Large{\enclose{circle}{F}} & \xrightarrow[0.5]{} & \Large{\enclose{circle}{G}} & \xrightarrow[0.6]{} & \Large{\enclose{circle}{H}} & \xleftarrow[0.7]{} & \Large{\enclose{circle}{I}} & \xleftarrow[0.8]{} & \Large{\enclose{circle}{J}}\\ \circlearrowright\tfrac12\\ \end{array} $$
\require{enclose}
\begin{array}{ccccccccc}
\Large{\enclose{circle}{A}} & \xrightarrow{0.1} & \Large{\enclose{circle}{B}} & \xrightarrow{0.2} & \Large{\enclose{circle}{C}} & \xleftarrow{0.3} & \Large{\enclose{circle}{D}} & \xleftarrow{0.4} & \Large{\enclose{circle}{E}}\\\
\scriptsize{0.5}\large{\downarrow} & \scriptsize{0.6}\large{\searrow} & \scriptsize{0.7}\large{\downarrow} & \scriptsize{0.8}\large{\nearrow} & \scriptsize{0.9}\large{\downarrow} & \scriptsize{0.1}\large{\swarrow} & \scriptsize{0.2}\large{\downarrow} & \scriptsize{0.3}\large{\nwarrow} & \scriptsize{0.4}\large{\downarrow}\\\
\Large{\enclose{circle}{F}} & \xrightarrow[0.5]{} & \Large{\enclose{circle}{G}} & \xrightarrow[0.6]{} & \Large{\enclose{circle}{H}} & \xleftarrow[0.7]{} & \Large{\enclose{circle}{I}} & \xleftarrow[0.8]{} & \Large{\enclose{circle}{J}}\\
\circlearrowright\tfrac12\\
\end{array}
Credit to Zev Chonoles [1] for the commutative diagram.
[1] https://math.meta.stackexchange.com/a/2325/161490W/ Sub-Variables
After spending too much time searching for a way to make tables of this form (to no avail), I spent even longer searching for the pieces (of which most were found here [1]) to Frankenstein my own. I made this table for a combinatorics q [2] on MSE...
$$ \begin{array}{l} \begin{array}{c|c} \hskip36.5pt & \hskip42.5pt\style{font-family:inherit}{\text{Ordering}} \end{array} \\[-7pt]\hline\hskip-5.5pt \begin{array}{c|c|c} \style{font-family:inherit}{\text{Repetition}} & \style{font-family:inherit}{\text{w/}} & \style{font-family:inherit}{\text{w/o}} \\\hline \style{font-family:inherit}{\text{w/}} & P_r^n=n^r & C_r^n=\left(\!\left(\begin{smallmatrix} n \\ r \end{smallmatrix}\right)\!\right)=\left(\begin{smallmatrix} n+r-1 \\ r \end{smallmatrix}\right) \\[0pt]\hline \style{font-family:inherit}{\text{w/o}} & nPr=\frac{n!}{(n-r)!} & nCr=\left(\begin{smallmatrix} n \\ r \end{smallmatrix}\right)=\frac{n!}{r!(n-r)!} \end{array}\hskip-5.5pt \end{array} $$
W/o Sub-Variables
While searching, I found several tables of this form...
$$ \begin{array}{c|c|c|c} \style{font-family:inherit}{\text{Day}} & \style{font-family:inherit}{\text{Credit}} & \style{font-family:inherit}{\text{Debit}} & \style{font-family:inherit}{\text{Total}}\\\hline 0 & 0 & 0 & 10000 \\\hline 1 & 100 & 500 & 9600 \\\hline 2 & 0 & 400 & 10000 \\\hline 3 & 1000 & 500 & 10500 \end{array} $$
[1] https://math.meta.stackexchange.com/q/5020/490122(using negative spacing)
To overlay the $\wedge$ \wedge
and the $\bigcirc$ \bigcirc
, to make the
Kulkarni Nomizu Product
[1]:
$$\mathbin{\rlap{\,\wedge}\bigcirc}$$
Which is \mathbin{\rlap{\,\wedge}\bigcirc}
.
Just for another example: Overlaying of $\}$ \}
and $\div$ \div
:
$$\rlap{\,\,\}}\div$$
Which is \rlap{\,\,\}}\div
.
The command \rlap{c1}c2
prints the character c1
with zero-width on the right-hand side of the current position, so that c2
overlaps with c1
. In practice, you might want to
c2
c1
with extra horizontal space \,
.\mathbin
so that MathJax treats the symbol like an operator, and the spacing around the symbol is correct.As you can see, the number of \!
is different, for exact overlaying of each symbol. \!
makes the characters left and right to it move a little bit closer.
e.g, the code ab
produces $ab$.
And the code a\!b
produces $a\!b$
\overset{\bullet}{\smash{cup}}
. This introduces a possibly device dependent vertical offset that cannot be adjusted, but I think(??) is always perfectly horizontally centered which is sometimes better. Using mathbin
one can get $A\mathbin{\overset{\bullet}{\smash\cup}}B$ for instance. Somehow a further nesting is needed for a \bigcup
version: \operatorname*{\overset{\bullet}{\smash{\overset{}{\bigcup}}}}_1^\infty U_i
$\operatorname*{\overset{\bullet}{\smash{\overset{}{\bigcup}}}}_1^\infty U_i$ - Calvin Khor
T^{\alpha\beta}{}_{\gamma\delta}
$T^{\alpha\beta}{}_{\gamma\delta}$
T^{\alpha \beta}{}_{\gamma\delta}{}^{\lambda}
$T^{\alpha \beta}{}_{\gamma\delta}{}^{\lambda}$
So for instance, a $(2,2)$-tensor would act on two covectors ($\omega$, $\varphi$) and two vectors ($v$,$w$) to produce a real number like this:
$$[T^{\alpha \beta}{}_{\gamma\delta}e_\alpha\otimes e_\beta\otimes e^\gamma \otimes e^\delta](\omega,\varphi,v,w).$$
{}^t\! A
yields ${}^t\! A$ - Calvin Khor
Is there a way to make the Greek letters displayed upright (non-italic)?
Asked in comment. There is a way using unicode characters, for which one can search here: http://unicode-table.com/en.
Normal use of phi is $\phi = ...$
, which gives $\phi = ...$.
Looking up phi on the above site gives a couple of results, if one uses 'Greek Capital Letter Phi' and copy it with the button below its picture, and use it like
$Φ = ...$
, the result is $Φ = ...$.
One might need to experiment which symbol(s) look(s) right.
Is there a tool to visually edit (prepare) the formulas with pre-defined symbols and paste here?
For some of the formulas one can use a word processor app that supports formula edition. E.g. one can use MS Word to construct the formula, or even better use the existing pre-defined ones, like I did with the Binomial theorem, then simply select it, and copy-paste here between the desired number of $'s:
$$ \left(x+a\right)^n=\sum_{k=0}^{n}{\binom{n}{k}x^ka^{n-k}} $$
If it does not look right, it might still be less time to adjust the expression than starting it from scratch, or trying to draw by hand such a thing like the above.
To get a vertical bar to the right of an expression with the limits of integration, expressions such as $\Big |$
$\Big |$ result in one-size-fits-all outputs.
\left. \right|_{}^{}
works well as in the made up expression below to illustrate this feature:
$$\left. \left(3x\left(\frac{\left(\log(\frac{3x^2}{6}\right)^{\frac{-x^2}{8}}}{3x^{1/2}} \right) \right) \right|_{\;x=2}^{\;x=8}$$
As mentioned before, you can write $\mathtt{. . .}$
to generate fonts like $\mathtt{A}$, $\mathtt{B}$, $\mathtt{C}$ and etc.
You can also produce these fonts writing $\verb|. . .|$
which generates the same fonts $\verb|A|$, $\verb|B|$, $\verb|C|$ and etc.
And concerning different “angle fonts”, $\angle$
generates $\angle$, $\measuredangle$
generates $\measuredangle$ and last but not least, $\sphericalangle$
generates $\sphericalangle$. Also, $\langle...\rangle$
generates $\langle...\rangle$.
Concerning different “approximation fonts”, $\approx$
generates $\approx$ with $\thickapprox$
generating $\thickapprox$. In addition to that, $\sim$
generates $\sim$ and $\thicksim$
generates $\thicksim$ with $\backsim$
generating $\backsim$.
For a symbol of contradiction, you can write $\Rightarrow\Leftarrow$
to generate $\Rightarrow\Leftarrow$ or you can write $\unicode{x21af}$
to generate $\unicode{x21af}$, which is read as Scar (short for Harry Potter's scar, explaining why it looks like a lightning bolt).
$$***$$
You can write $\lt$
or $<$
to generate $<$ and $\gt$
or $>$
to generate $>$, with $\le$
or $\leq$
to generate $\leq$.
You can also produce similar less than inequality signs with $\leqslant$
to generate $\leqslant$ and $\leqq$
to generate $\leqq$. The same applies for greater than inequality signs, for which we just rewrite the command as $\g...$
instead of $\l...$
which produces $\geq$, $\geqslant$ and $\geqq$.
By putting in an n
, we could form commands like $\ngtr$
to generate $\ngtr$ and $\nless$
to generate $\nless$ as opposed to $\not>$
and $\not<$
.
Also, $\ngeq$
= $\not\geq$
which generates $\ngeq$ and $\nleq$
= $\not\leq$
, generating $\nleq$.
Furthermore, putting slant
at the end of strictly the previous two commands generates $\ngeqslant$ and $\nleqslant$.
$$***$$
You could write $\not\subseteq$
to generate $\not\subseteq$ or $\not\supseteq$
to generate $\not\supseteq$.
You can write $\subsetneq$
to generate $\subsetneq$ and $\supsetneq$
to generate $\supsetneq$.
Or, you can write $\subsetneqq$
to generate $\subsetneqq$ and $\supsetneqq$
to generate $\supsetneqq$.
By striking out the n
in the previous commands with qq
at the end, we can generate $\subseteqq$ and $\supseteqq$.
Instead of $\left\{. . .\right\}$
to generate $\left\{...\right\}$, you can write $\lbrace...\rbrace$
to generate the exact same thing. For sets that contain element(s) with a single number or letter, you can also write $\{. . .\}$
to generate strictly $\{. . .\}$ with no other smaller or larger brace sizes.
As another alternative to denoting the difference of two sets $A$ and $B$, you can write $\diagdown$
to generate $\diagdown$ in the set expression, $A\diagdown B$. This command though is mainly used for sets $A^n$ and $B^n$. There also exists $\diagup$
= $\diagup$ by the way to denote the division operation as opposed to the ordinary / or $\div$
= $\div$.
$$***$$
For old-style notation, you can write $\eqslantless$
to generate $\eqslantless$ and $\eqslantgtr$
to generate $\eqslantgtr$. These notations can be used to mean the same as $\leqslant$ and $\geqslant$ which is also the same as $\leq$ and $\geq$, but if used today, they commonly represent a not much less than or not much greater than inequality sign.
If you want to write that the statement, $x > y$ and thus $x\neq y$, without any words, then you can write $x \gvertneqq y$
to generate $x \gvertneqq y$. If, on the other hand, you want to then write the same statement for $x < y$ then you can write $x \lvertneqq y$
to generate $x \lvertneqq y$.
Suppose you have that $x\in \mathbb{R}$ but $x \neq 0$ $(\star)$ for example (like in
this question
[1]), one could write it as follows: $x\in\mathbb{R}\setminus\{0\}$ with $\setminus$
to generate $\backslash$. There is an alternative way of writing $(\star)$, nonetheless.
You can write $\gtrless$
to generate $\gtrless$ which means less than and greater than. If $x\gtrless y$ then $x$ is equal to a number greater than $y$ or less than $y$. Therefore, $x \in\mathbb{R}\setminus\{0\}$ can also be written as $x\gtrless 0$. You can also write $\lessgtr$
to generate $\lessgtr$ which essentially means the same thing. The following commands and notation is unnecessary, for their definition is obvious.
$\gtreqless$
generates $\gtreqless$ and $\lesseqgtr$
generates $\lesseqgtr$.
$\gtreqqless$
generates $\gtreqqless$ and $\lesseqgtr$
generates $\lesseqqgtr$.
\backslash
, as it is different from \setminus
. The command \setminus
is a binary operation, which means that it has spacing designed for things like $A\setminus B$, while \backslash
is just the symbol itself, so $A\backslash B$ is more squashed. See here for more details. - user1729
$\diagdown$
really recommended for difference of sets? 'I'd highly recommend $\setminus$
instead, both for semantic reasons and for type setting reasons. Shouödn't we adjust this recommendation? - emacs drives me nuts
I'd like to also expound upon bullet 6 in the question, about parenthesis. I originally put my edit into the question there, but the primary editor of the question reverted my edits. I and others need this information and a good example, so here it is:
There are also invisible parentheses, denoted by .
, as in \left.
or \right.
. These can take the place of any type of parenthesis whether it be (
, [
, or something else. Ex: \left.\frac12\right\rbrace
is $\left.\frac12\right\rbrace$, and \left.\frac12\right)
is $\left.\frac12\right)$.
To stretch a vertical bar to be tall, such as to plug in upper and lower limit values into a definite integral's antiderivative, add an invisible vertical bar on the left with \left.
, and a visible vertical bar on the right with \right|
. For lower and upper limits of 0
and 4
, respectively, the lower limit is set with _{\;0}
, and the upper limit with ^{\;4}
, where the \;
is a wider space to shift the numbers to the right of the vertical bar.
Example: $$\left.{\left[\cfrac{x}{\cfrac{a+b}{c}}\right]}\right|_{\;0}^{\;4}$$
produces:
$$\left.{\left[\cfrac{x}{\cfrac{a+b}{c}}\right]}\right|_{\;0}^{\;4}$$
\mathrm{B}
: $\mathrm{B}$ - robjohn\operatorname
: e.g.,\operatorname{Spec} A
gives $\operatorname{Spec} A$. - Charles Staats_5C_3
$_5C_3$. You could also mention\frac
vs\dfrac
. - axblount{}
count as formulas and can appear anywhere that any other formula can. I think\dfrac
is a refinement that doesn't need to be mentioned in the main post. - MJD\big
,\left
, and\right
for this reason, and trimming the section on spacing. - MJD(
and)
automatically resizeable. I can in LaTeX. - Andrew Staceystmaryrd
like\inplus
,\boxast
,\owedge
. - Willie Wongempheq
package (Link) whose functions are, best as I can tell, not replicated in MathJax. And just for fun I give a MathJax expression that won't render in LaTeX: try$$ \begin{align} ... \end{align} $$
. - Willie Wongalignat
environment is for when aligning stuff when you are already in a mathematical environment and would have been a better choice for MathJaX to use here. But it's an important example of the limitations of MathJaX: it is only for mathematical formatting. - Andrew Stacey(faq)
but it's stuck on(faq-proposed)
. - user53153\frac
to\over
? - MJD\over
complicates the design of macros is completely irrelevant to us here. - MJD\mathrm
. I can see the value of mentioning\text
, because beginners often write things like $\{ x | x is hyperellipically constrained \}$, but\mathrm
doesn't help here, and I'm not sure why it is a good use of space in the tutorial. Is it important for some reason I don't appreciate? - MJD\mathrm
in many places; e.g. $\mathrm{d}x$ in integrals and derivatives and for operator names that don't need the full force of\operatorname
.\mathrm
was intended for roman symbols in math mode;\text
was intended for text because of the way it spaces things. See this TEX thread. Since I don't believe we can use preambles in MathJax, we can't use\DeclareMathOperator
, though we can use\newcommand
, but that is orthogonal to the use of\mathrm
vs\text
for math symbols. - robjohn\lhd
$\lhd$. I've added this to section 12. - MJDTeX
Commands available inMathJax
. onemathematicalcat.org/MathJaxDocumentation/TeXSyntax.htm - Sebastiano\backslash
instead of\setminus
for, well, the operation of setminus. The spacing is different: compare $A\backslash B$ with $A\setminus B$, and\setminus
is designed for this use. I edited the tutorial to mention this, and also added a link to a TeX.SE question about this. - user1729$\uparrow$
and$\downarrow$
, $\uparrow$ and $\downarrow$ could be added too in the section of arrows - Weronika\because
)? - iBug\odot,\otimes
$\odot,\otimes$ that are more common in my experience. - Calvin Khor\ldots
, and in any case in your example it renders the same as\dots
? I can see\lhd
being used but why put it with the euivalence relations? (similar question for\prec
but IDK when that was added) (And while I'm at it a better edit description would be nice. Even the default one beats your apple) - Calvin Khor\dots
(where there used to be only\ldots
). Same for\lhd
which was already there and I only added\rhd
and an explanation. - iBug\ldots
and\cdots
- Calvin Khor\lt
without\gt
(just for example). Sure I'll remove\ldots
but I'd keep\rhd
though. Same reasoning when I previously added\gets
and\impliedby
. - iBug\dots
tries to intelligently choose between\ldots
(l for lower) and\cdots
(c for center) depending on the surrounding text e.g.a+\ldots+b
$a+\ldots+b$ vsa+\dots+b
$a+\dots+b$. - Calvin Khor\cdots
. - MJD\leqslant
and\leqq
. - MJD\left
and\right
are good enough for all possible Math SE uses. I think there's no unclear formula anyone could write that would become clear by using\biggl
. - MJD\iff
there is also $\leftrightarrow$\leftrightarrow
for a tidier look. - Evan Schwartzentruber\Leftrightarrow
- Тyma Gaidash\neq
with\ne
and the\mathscr
on lowercase letters does not work - Тyma Gaidash