Skip to content

Latest commit

 

History

History
137 lines (127 loc) · 3.36 KB

多行公式.md

File metadata and controls

137 lines (127 loc) · 3.36 KB

每行居中对齐

$$ \begin{gather} a + b = b + a + c + d \\ a \times b = b \times a \end{gather} $$

\begin{gather}
a + b = b + a + c + d \\
a \times b = b \times a
\end{gather}

按等号或其他关系符对齐

$$ \begin{align} % 自动编号(按顺序) x &= t + \cos t + 1 \\ y &= 2 \sin 5 \end{align} $$

\begin{align}
x &= t + \cos t + 1\\
y &= 2 \sin 5
\end{align}

align还允许排列多列对齐的公式,列于列之间仍使用&分隔 $$ \begin{align} x &=t & x &= \cos t & x &= t\ y &=25 & y &= \sin(t+1) & y &= \sin t \end{align} $$

\begin{align}
x &=t   & x &= \cos t    & x &= t\\
y &=25  & y &= \sin(t+1) & y &= \sin t 
\end{align}

$$ \begin{align} & (a+b)(a^2 -ab + b^2) \\ ={} & a^3 -a^2b + ab^2 + a^2b - ab^2 + b^2 \\ ={} & a^3 + b^3 \end{align} $$

\begin{align}
	& (a+b)(a^2 -ab + b^2) \\
={} & a^3 -a^2b + ab^2 + a^2b - ab^2 + b^2 \\
={} & a^3 + b^3
\end{align}

将公式组合成块

$$ D(x)=\begin{cases} % 不自动编号 1, & \text{if} \quad x \in \mathbb{Q} \\ 0, & \text{if} \quad x \in \mathbb{R} \setminus \mathbb{Q} \end{cases} $$

\begin{equation}
D(x)=\begin{cases}
		1, & \text{if} \quad  x \in \mathbb{Q} \\
        0, & \text{if} \quad  x \in \mathbb{R} \setminus \mathbb{Q}
     \end{cases}
\end{equation}

多行公式对齐(居中对齐c,左对齐l,右对齐r)

$$ \begin{array}{lcl} z & = & a \\ f(x,y,z) & = & x + y + z \end{array} $$

\begin{array}{lcl}
z        & = & a \\
f(x,y,z) & = & x + y + z 
\end{array}

$$ \begin{array}{rcl} z & = & a & = & x+b \\ f(x,y,z) & = & x + y + z & = & x^5+3x-b+y \end{array} $$

\begin{array}{rcl} % 第一列右对齐r,第二列居中对齐c,第三列左对齐l 
z        & = & a          & = & x+b \\
f(x,y,z) & = & x + y + z  & = & x^5+3x-b+y  
\end{array}

$$ \begin{array}{rcr} z & = & a \\ f(x,y,z) & = & x + y + z \end{array} $$

\begin{array}{rcr}
z        & = & a \\
f(x,y,z) & = & x + y + z    
\end{array}

复杂公式组合

$$ \begin{array}{ccc} \frac{\partial f_l(\mathbf{a}^l) }{\partial \mathbf{a}^l} &=& \begin{bmatrix} \frac{ \partial f_l(a^l_{1})}{\partial a^l_1} & \frac{ \partial f_l(a^l_{2})}{\partial a^l_1} & \cdots & \frac{ \partial f_l(a^l_{N_l -1})}{\partial a^l_1} & \frac{ \partial f_l(1)}{\partial a^l_1} \\ \frac{ \partial f_l(a^l_{1})}{\partial a^l_2} & \frac{ \partial f_l(a^l_{2})}{\partial a^l_2} & \cdots & \frac{ \partial f_l(a^l_{N_l -1})}{\partial a^l_2} & \frac{ \partial f_l(1)}{\partial a^l_2} \\ \vdots& \vdots & \ddots & \vdots & \vdots \\ \frac{ \partial f_l(a^l_{1})}{\partial a^l_{N_l -1}} & \frac{ \partial f_l(a^l_{2})}{\partial a^l_{N_l -1}} & \cdots & \frac{ \partial f_l(a^l_{N_l -1})}{\partial a^l_{N_l -1}} & \frac{ \partial f_l(1)}{\partial a^l_{N_l -1}} \\ \frac{ \partial f_l(a^l_{1})}{\partial 1} & \frac{ \partial f_l(a^l_{2})}{\partial 1} & \cdots & \frac{ \partial f_l(a^l_{N_l -1})}{\partial 1} & \frac{ \partial f_l(1)}{\partial 1} \end{bmatrix} \\ &=& \begin{bmatrix} \frac{ \partial f_l(a^l_{1})}{\partial a^l_1} & 0 & \cdots & 0 & 0 \\ 0 & \frac{ \partial f_l(a^l_{2})}{\partial a^l_2} & \cdots & 0 & 0\\ \vdots& \vdots & \ddots & \vdots & \vdots \\ 0 & 0 & \cdots & \frac{ \partial f_l(a^l_{N_l -1})}{\partial a^l_{N_l -1}} & 0 \\ 0 & 0 & \cdots & 0 & 0 \end{bmatrix} \\ &=& A^l \end{array} $$