Markdown菜鸟教程
Author:Yuan’s Q
目录
[TOC]
一、字体、格式类
1.1字体与颜色设置
浅红色文字:<font color="#dd0000">浅红色文字:</font><br />
深红色文字:<font color="#660000">深红色文字</font><br />
浅绿色文字:<font color="#00dd00">浅绿色文字</font><br />
深绿色文字:<font color="#006600">深绿色文字</font><br />
浅蓝色文字:<font color="#0000dd">浅蓝色文字</font><br />
深蓝色文字:<font color="#000066">深蓝色文字</font><br />
浅黄色文字:<font color="#dddd00">浅黄色文字</font><br />
深黄色文字:<font color="#666600">深黄色文字</font><br />
浅青色文字:<font color="#00dddd">浅青色文字</font><br />
深青色文字:<font color="#006666">深青色文字</font><br />
浅紫色文字:<font color="#dd00dd">浅紫色文字</font><br />
深紫色文字:<font color="#660066">深紫色文字</font><br />
浅红色文字:浅红色文字:
深红色文字:深红色文字
浅绿色文字:浅绿色文字
深绿色文字:深绿色文字
浅蓝色文字:浅蓝色文字
深蓝色文字:深蓝色文字
浅黄色文字:浅黄色文字
深黄色文字:深黄色文字
浅青色文字:浅青色文字
深青色文字:深青色文字
浅紫色文字:浅紫色文字
深紫色文字:深紫色文字
二、大小
size为1:<font size="1">size为1</font><br />
size为2:<font size="2">size为2</font><br />
size为3:<font size="3">size为3</font><br />
size为4:<font size="4">size为4</font><br />
size为10:<font size="10">size为10</font><br />
123456
size为1:size为1
size为2:size为2
size为3:size为3
size为4:size为4
size为10:size为10
1.2标题与目录
1.2段落、间距设置
1.3超链接与参考文献
1.4插入外部数据(图片)
二、表格、区块、代码块
1.1 插入表格
1.2 插入代码块
二、数学公式类
1.1 常用符号
1.To see how any formula was written in any question or answer, including this one, right-click on the expression it and choose “Show Math As > TeX Commands”. (When you do this, the ‘$’ will not display. Make sure you add these. See the next point.)
2.For inline formulas,enclose the formula in $...$
. For display formulars,use** $$...$$
.These render differently.For example,type$\sum_{i=0}^n i^2=\frac{(n^2+n)(2n+1)}{6}$
to show (which is inline mode) or type$$\sum_{i=0}^n i^2=\frac{(n^2+n)(2n+1)}{6}$$
$$(which is display mode).
3.For Greek letters, use \alpha
, \beta
, …, \omega
: α,β,…ω. For uppercase, use \Gamma
, \Delta
, …, \Omega
: Γ,Δ,…,Ω.
若需要斜体,\varSigma
。
显示 | 命令 | 显示 | 命令 |
---|---|---|---|
\alpha | \beta | ||
\gamma | \delta | ||
\epsilon | \zeta | ||
\eta | \theta | ||
\iota | \kappa | ||
\lambda | \mu | ||
\nu | \xi | ||
\pi | \rho | ||
\sigma | \tau | ||
\upsilon | \phi | ||
\chi | \psi | ||
\omega |
4.For superscripts and subscripts, use ^
and _
. For example,x_i^2
: , \log_2 x
: $log2x $.
5.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: . But 10^{10}
gives what you probably wanted: . Use curly braces to delimit a formula to which a superscript or subscript applies: x^5^6
is an error; {x^y}^z
is , and x^{y^z}
is . Observe the difference between x_i^2
and x_{i^2}
.
6.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: . \left(
…\right)
will make the sizes adjust automatically to the formula they enclose: .\left\{x\middle | \frac{x^2}{2} \in \mathbb{z}\right\}
,f_{comp}(y_{obs},y_{mis})=f_m(y_{mis})\cdot f_{o|m}(y_{obs},y_{mis})
\left
and \right
apply to all the following sorts of parenttheses:( and ) , |
, \vert
,\Vert
, \langle
and \rangle
$ \left\langle x \right\rangle$,\lceil
and \rceil
,and \lfoor
andrfloor
.\middle
can be used to add additional dividers.
There are also invisible parentheses, denoted by .
: \left.\frac12\right\rbrace
is .
If manual size adjustments are required: \Biggl(\biggl(\Bigl(\bigl((x)\bigr)\Bigr)\biggr)\Biggr)
gives $\Biggl(\biggl(\Bigl(\bigl((x)\bigr)\Bigr)\biggr)\Biggr) $.
\underbrace{a\cdot a\cdots a}_{b\text{ times}}
.
\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}}}
.
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)
$$
$\lim\limits_{x \to 1} \frac{x^2-1}{x-1}$
$$ \bbox[yellow,5px]
{
e^x=\lim_{n\to\infty} \left( 1+\frac{x}{n} \right)^n
\qquad (1)
}
$$
$$ \bbox[yellow,5px]{e^x=\lim_{n\to\infty} \left( 1+\frac{x}{n} \right)^n\qquad (1)}$$
$$ \bbox[yellow,5px,border:2px solid red]
{
e^x=\lim_{n\to\infty} \left( 1+\frac{x}{n} \right)^n
\qquad (1)
}
$$
$$ \bbox[yellow,5px,border:2px solid red]{e^x=\lim_{n\to\infty} \left( 1+\frac{x}{n} \right)^n\qquad (1)}$$.
7.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
. Don’t forget {
…}
if the limits are more than a single symbol. For example, \sum_{i=0}^\infty i^2
is . Similarly, \prod
, \int
\bigcup
, \bigcap
, \iint
, \iiint
.
8.Fractions There are two ways to make these. \frac ab
applies to the next two groups, and produces ab; for more complicated numerators and denominators use {
…}
: \frac{a+1}{b+1}
is . If the numerator and denominator are complicated, you may prefer \over
, which splits up the group that it is in: {a+1\over b+1}
is .
9.Fonts
- Use
\mathbb
or\Bbb
for “blackboard bold”: . - Use
\mathbf
for boldface: - Use
\mathtt
for “typewriter” font: - Use
\mathrm
for roman font: - Use
\mathsf
for sans-serif font: - Use
\mathcal
for “calligraphic” letters: - Use
\mathscr
for script letters: . - Use
\mathfrak
for “Fraktur” (old German style) letters:
10.Radical signs Use sqrt
, which adjusts to the size of its argument: \sqrt{x^3}
; \sqrt[3]{\frac xy}
. For complicated expressions, consider using {...}^{1/2}
instead.
11.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 \infty}
,.
12.There are a very large number of special symbols and notations, too many to list here; see this shorter listing, or this exhaustive listing. Some of the most common include:
\lt \gt \le \leq\leqq \leqslant \ge \geq \geqq \geqslant \neq
.You can use\not
to put a slash through almost anything:\not\lt
but it often looks bad.\times \div \pm \mp
.cdot
is a centered dot:\cup \cat \setminus\subset \subseqeq \subsetneq \supset \in \notin \emptyset \varnothing
.{n+1 \choose 2k}
or\binom{n+1}{2k}
\to \rightarrow \leftarrow \Rightarrow \Leftarrow \mapsto
\land \lor \lnot \forall \exists \top \bot \vdash \vDash \propto
\star \ast \oplus \otimes \odot \circ \bullet
\tilde{a} \hat{a} \vec{a} \bar{a}
\approx \sim \simeq \cong \equiv \prec \lhd
.\infty \aleph_0
\nabla \partial\frac{y}{x}
\Im \Re
- For modular equivalence, use
\pmod
like this:a\equiv b\pmod n
\ldots
is the dots incdots
is the dots in .
13.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 . To add more space, use \,
for a thin space ; \;
for a wider space . \quad
and \qquad
are large spaces: , .
14.Accents and diacritical marks Use \hat
for a single symbol , \widehat
for a larger formula . If you make it too wide, it will look silly. Similarly, there are \bar
and \overline
, and \vec
and \overrightarrow
$ \overrightarrow{}$ and .For dots, as in , use \dot
and \ddot
.
15.Special characters used for MathJax interpreting can be escaped using the \
character: \$
$ $$, \{
, \_
etc. If you want \
itself , you should use \backslash
, because \\
is for a new line.
16.Named 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: \color{red}{text}
or use #rgb text
1.2矩阵与数组
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}
$$
produce:
$$
\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.
2.TO add brackets,either use \left...\right
as in section 6 of the tutorial, or replace matrix
with pmatrix
,bmatrix
,Bmatrix
,vmatrix
,Vmatrix
.
3.Usecdots
\ddots
vdots
when you want to omit some of the entries:
$$.
4.For horizontally “augmented” matrices, put parentheses or brackets around a suitably-formatted table; see arrays below for details. Here is an example:
$$
\left[
\begin{array} {cc|c}
1&2&3\\ 4&5&6
\end{array}
\right]
$$
$$
\left[
\begin{array} {cc|c}
1&2&3\ 4&5&6
\end{array}
\right]
$$
5.For vertically “augmented” matrices, use \hline
. For example
$$
\begin{pmatrix}
a & b\\
c & d\\
\hline
1 & 0\\
0 & 1
\end{pmatrix}
$$
$$
\begin{pmatrix}
a & b\
c & d\
\hline
1 & 0\
0 & 1
\end{pmatrix}
$$
6.数组
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}
1.3方程(组)
1.Aligned equaltions
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}}\cdot\sqrt{\frac{73^2-1}{73^2}}\
&\approx \frac{73}{12} \left ( 1-\frac{1}{{2.73}^2}\right)
\end{align}\
$$
is produced by:
```\begin{align}\sqrt{37} &=\sqrt{\frac{73^2-1}{12^2}} \
\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}}\cdot\sqrt{\frac{73^2-1}{73^2}}\
&\approx \frac{73}{12} \left ( 1-\frac{1}{{2.73}^2}\right)
\end{align}\
1.2 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}$
is produced by:
f(n) =
\begin{cases}
n/2, & \text{if is even} \
3n+1, & \text{if 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 is even:}&n/2\
\text{if is odd:}&3n+1
\end{array}
\right}
=f(n)
3.**multi-line equation**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 [(2)](https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference?page=1&tab=votes#mjx-eqn-eq2) is a multi-line equation. The code to produce equation [(2)](https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference?page=1&tab=votes#mjx-eqn-eq2) is
$$
$$
```
.
4