LaTex : A document preparation system
LaTeX is a high-quality typesetting system; it includes features designed for the production of technical and scientific documentation
.
MathJax
Jupyter notebook recognizes LaTeX code written in markdown cells and renders the symbols in the browser using the MathJax JavaScript library.
Jupyter Notebook中的LaTex数学公式有两种形式:行中公式和独立行公式。
行中公式(inline) 放在行文本中与其它文字混编。 Inline (within text) formulas
独立行公式(separate) 单独成行。Displayed equations
$数学公式$
例如:
我们定义:$f(x) = \sum_{i=0}^{N}\int_{a}^{b} g(t,i) \text{ d}t$.
我们定义:$f(x) = \sum_{i=0}^{N}\int_{a}^{b} g(t,i) \text{ d}t$.
$$数学公式$$
例如:
$$J_\alpha(x) = \sum_{m=0}^\infty \frac{(-1)^m}{m! \Gamma (m + \alpha + 1)} {\left({ \frac{x}{2} }\right)}^{2m + \alpha}$$
公式行中显示:
$$J_\alpha(x) = \sum_{m=0}^\infty \frac{(-1)^m}{m! \Gamma (m + \alpha + 1)} {\left({ \frac{x}{2} }\right)}^{2m + \alpha}$$如果:
$J_\alpha(x) = \sum_{m=0}^\infty \frac{(-1)^m}{m! \Gamma (m + \alpha + 1)} {\left({ \frac{x}{2} }\right)}^{2m + \alpha}$
是只有公式的行,但仍是行内公式,因此,公式行左显示:
$J_\alpha(x) = \sum_{m=0}^\infty \frac{(-1)^m}{m! \Gamma (m + \alpha + 1)} {\left({ \frac{x}{2} }\right)}^{2m + \alpha}$
txt
$$\begin{align*}
&\frac{dS}{dt}=-\frac{\beta SI}{N}\\
&\frac{dI}{dt}=\frac{\beta SI}{N}-\gamma \\
&\frac{dR}{dt}=\frac{\gamma}{I}
\end{align*}
$$
$$\begin{align*}
&\frac{dS}{dt}=-\frac{\beta SI}{N}\\
&\frac{dI}{dt}=\frac{\beta SI}{N}-\gamma \\
&\frac{dR}{dt}=\frac{\gamma}{I}
\end{align*}
$$
^表示上标, _表示下标。如果上下标的内容多于一个字符,要用{}把这些内容括起来当成一个整体。上下标是可以嵌套的,也可以同时使用。
例如:
$x^{y^z}=(1+{\rm e}^x)^{-2xy^w}$
显示:
$x^{y^z}=(1+{\rm e}^x)^{-2xy^w}$
另外,如果要在左右两边都有上下标,可以用\sideset命令。
例如:
$\sideset{^1_2}{^3_4}\bigotimes$
显示:
$\sideset{^1_2}{^3_4}\bigotimes$
()、[]和|表示自己,\{\}
表示{}。当要显示大号的括号或分隔符时,要用\left和\right命令。
例如:
$f(x,y,z) = 3y^2z \left( 3+\frac{7x+5}{1+y^2} \right)$
显示:
$f(x,y,z) = 3y^2z \left( 3+\frac{7x+5}{1+y^2} \right)$
有时,需要 \left. 或 \right. 进行匹配而不显示本身。
例如:
$\left. \frac{{\rm d}u}{{\rm d}x} \right| _{x=0}$
显示: $\left. \frac{{\rm d}u}{{\rm d}x} \right| _{x=0}$
例如:
$\frac{1}{3}$
显示:$\frac{1}{3}$
$1 \over 3$
显示: $1 \over 3$
例如:
$\sqrt{2}$
$\sqrt[n]{3}$
显示:
$\sqrt{2}$
$\sqrt[n]{3}$
数学公式中常见的省略号有两种:
\ldots 表示与文本底线对齐的省略号;
\cdots 表示与文本中线对齐的省略号。
例如:
$f(x_1,x_2,\ldots,x_n) = x_1^2 + x_2^2 + \cdots + x_n^2$
显示:
$f(x_1,x_2,\ldots,x_n) = x_1^2 + x_2^2 + \cdots + x_n^2$
例如:
$\vec{a} \cdot \vec{b}=0$
显示:
$\vec{a} \cdot \vec{b}=0$
例如:
$\int_0^1 x^2 {\rm d}x$
显示:
$\int_0^1 x^2 {\rm d}x$
例如:
$\lim_{n \rightarrow +\infty} \frac{1}{n(n+1)}$
显示:
$\lim_{n \rightarrow +\infty} \frac{1}{n(n+1)}$
例如:
$\sum_{i=0}^n \frac{1}{i^2} 和 \prod_{i=0}^n \frac{1}{i^2}$
显示:
$\sum_{i=0}^n \frac{1}{i^2} 和 \prod_{i=0}^n \frac{1}{i^2}$
例如:
\alpha \beta \gamma \Gamma \delta \Delta \epsilon
\varepsilon \zeta \eta \theta \Theta \vartheta
\iota \kappa \lambda \Lambda \mu \nu
\xi \Xi \pi \Pi \varpi \rho
\varrho \sigma \Sigma \varsigma \tau \upsilon \Upsilon
\phi \Phi \varphi \chi X \psi \Psi \omega \Omega
显示:
$\alpha \beta \gamma \Gamma \delta \Delta \epsilon$
$\varepsilon \zeta \eta \theta \Theta \vartheta$
$\iota \kappa \lambda \Lambda \mu \nu$
$\xi \Xi \pi \Pi \varpi \rho$
$\varrho \sigma \Sigma \varsigma \tau \upsilon \Upsilon$
$\phi \Phi \varphi \chi \psi \Psi \omega \Omega$
$\pm$
$\pm$
$\times$
$\times$
$\div$
$\div$
$\mid$
$\mid$
$\nmid$
$\nmid$
$\cdot$
$\cdot$
$\circ$
$\circ$
$\ast$
$\ast$
$\bigodot$
$\bigodot$
$\bigoplus$
$\bigoplus$
$\leq$
$\leq$
$\geq$
$\geq$
$\neq$
$\neq$
$\approx$
$\approx$
$\equiv$
$\equiv$
$\sum$
$\sum$
$\prod$
$\prod$
$\coprod$
$\coprod$
$\emptyset$
$\emptyset$
$\in$
$\in$
$\notin$
$\notin$
$\subset$
$\subset$
$\supset$
$\supset$
$\subseteq$
$\subseteq$
$\supseteq$
$\supseteq$
$\bigcap$
$\bigcap$
$\bigcup$
$\bigcup$
$\bigvee$
$\bigvee$
$\bigwedge$
$\bigwedge$
$\biguplus$
$\biguplus$
$\bigsqcup$
$\bigsqcup$
$\log$
$\log$
$\lg$
$\lg$
$\ln$
$\ln$
$\bot$
$\bot$
$\angle$
$\angle$
$30^\circ$
$30^\circ$
$\sin$
$\sin$
$\cos$
$\cos$
$\tan$
$\tan$
$\cot$
$\cot$
$\sec$
$\sec$
$\csc$
$\csc$
$\prime$
$\prime$
$\int$
$\int$
$\iint$
$\iint$
$\iiint$
$\iiint$
$\iiiint$
$\iiiint$
$\oint$
$\oint$
$\lim$
$\lim$
$\infty$
$\infty$
$\nabla$
$\nabla$
$\because$
$\because$
$\therefore$
$\therefore$
$\forall$
$\forall$
$\exists$
$\exists$
$\not=$
$\not=$
$\not>$
$\not>$
$\not\subset>$
$\not\subset$
$\hat{y}$
$\hat{y}$
$\check{y}$
$\check{y}$
$\breve{y}$
$\breve{y}$
$\dot{y}$
$\dot{y}$
$\overline{a+b+c+d}$
$\overline{a+b+c+d}$
$\underline{a+b+c+d}$
$\underline{a+b+c+d}$
$\overbrace{a+\underbrace{b+c}_{1.0}+d}^{2.0}$
$\overbrace{a+\underbrace{b+c}_{1.0}+d}^{2.0}$
$\uparrow$
$\uparrow$
$\downarrow$
$\downarrow$
$\Uparrow$
$\Uparrow$
$\Downarrow$
$\Downarrow$
$\rightarrow$
$\rightarrow$
$\leftarrow$
$\leftarrow$
$\Rightarrow$
$\Rightarrow$
$\Leftarrow$
$\Leftarrow$
$\longrightarrow$
$\longrightarrow$
$\longleftarrow$
$\longleftarrow$
$\Longrightarrow$
$\Longrightarrow$
$\Longleftarrow$
$\Longleftarrow$
空格 # $ % & _ { }
用命令:
空 格
$\#
$\#$
$\$$
$$$
$\%$
$\%$
$\&$
$\&$
$\_$
$\_$
$\{$
$\{$
$\}$
$\}$
要对公式的某一部分字符进行字体转换,可以用{\rm
需转换的部分字符}命令,其中,\rm
可以参照下表选择合适的字体。一般情况下,公式默认为意大利体。
罗马体: $\rm ABC$
$\rm ABC$
意大利体: $\it ABC$
$\it ABC$
黑体: $\bf 123$
$\bf 123$
花体: $\cal ABC$
$\cal ABC$
等线体: $\sf ABC$
$\sf ABC$
数学斜体: $\mit ABC$
$\mit ABC$
打字机字体: $\tt ABC$
$\tt ABC$
使用$$\begin{array}{col style…\end{array}$$
这样的形式来创建表格.
列样式:
\hline: 在本行前加入一条直线
| :表示一条竖线
表格中各行分隔: \
表格中各列分隔: &
$$
\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}
$$$$
% 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}
$$
$$
% 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}
$$
使用 $$\begin{matrix}…\end{matrix}$$
这样的形式来表示矩阵,在\begin
与\end
之间加入矩阵中的元素即可。
\\
&
$$ At=b \tag{3}$$
$$
\left[
\begin{matrix}
4 & -1 & -1 & 0 \\
-1 & 4 & 0 & -1 \\
-1 & 0 & 4 & -1 \\
0 & -1 & -1 & 4
\end{matrix}
\right]
\left[
\begin{matrix}
node[1,1] \\
node[1,2] \\
node[2,1] \\
node[2,2]
\end{matrix}
\right]
=
\left[
\begin{matrix}
node[0,1]+node[1,0] \\
node[0,2]+node[1,3] \\
node[2,0]+node[3,1] \\
node[2,3]+node[3,2]
\end{matrix}
\right]
\tag{4}
$$
$$ At=b \tag{3}$$$$
\left[
\begin{matrix}
4 & -1 & -1 & 0 \\
-1 & 4 & 0 & -1 \\
-1 & 0 & 4 & -1 \\
0 & -1 & -1 & 4
\end{matrix}
\right]
\left[
\begin{matrix}
node[1,1] \\
node[1,2] \\
node[2,1] \\
node[2,2]
\end{matrix}
\right]
=
\left[
\begin{matrix}
node[0,1]+node[1,0] \\
node[0,2]+node[1,3] \\
node[2,0]+node[3,1] \\
node[2,3]+node[3,2]
\end{matrix}
\right]
\tag{4}
$$增广矩阵需要使用array来实现
$$ \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]
$$
Use \require{cancel}
in the first formula in your post that requires cancelling; you need it only once per page. Then use:
$\require{cancel}$
$\require{cancel}$
y+\cancel{x} $y+\cancel{x}$
\cancel{y+x} $\cancel{y+x}$
y+\bcancel{x} $y+\bcancel{x}$
y+\xcancel{x} $y+\xcancel{x}$
y+\cancelto{0}{x} $y+\cancelto{0}{x}$
\frac{1\cancel9}{\cancel95} = \frac15 $\frac{1\cancel9}{\cancel95} = \frac15$
The package xcolor, described in Colors, allows us to add color to our equations. For example,
$k = {\color{red}x} \mathbin{\color{blue}-} 2$
$k = {\color{red}x} \mathbin{\color{blue}-} 2 $
The only problem is that this disrupts the default LaTeX formatting around the -
operator. To fix this, we enclose it in a \mathbin
environment, since -
is a binary operator