使用Latex错误集
1、写公式的函数——align(最怕空行)
(1)align用法示例
\begin{align}
& \left\{
\begin{array}{ll} \sup\limits_{\tilde{\mu}} & \sum\limits_{i = 1}^N \mu_i \cdot ( \eta_i + (1-\alpha_i)^{-1}\mathbb{E}[(F-\eta_i)_+] )\\ s.t. & \mu \in \mathbb{B}_r(\mu_0) \end{array}
\right. \label{4.1}\\
=& \left\{
\begin{array}{ll} \sup\limits_{\tilde{\mu},\Pi} &\sum\limits_{i = 1}^N \mu_i \cdot ( \eta_i + (1-\alpha_i)^{-1}\mathbb{E}[(F-\eta_i)_+] ) \\
s.t. &\int_{[0,1]^2}|\alpha-\alpha_0|\Pi(d\alpha,d\alpha_0) \leq r\\
& \mu_i = \int_{\alpha_{i-1}}^{\alpha_i}\mu(d \alpha),i = 1,\dots,N \\ \end{array}
\right. \tag{\ref{4.1}{a}}\label{4.1a}
\end{align}
%红色代码是给每行公式标号,超高级,好用!
(2)align中公式的两行之间不能有空行,会报错;
(3)align前后不能有空行,要不然pdf会有大片空白;
(4)如果是公式代码写错了,latex会说是align出错了,千万别信!!!抓紧检查公式代码(latex报错:Paragraph ended before \align was complete)
(5)align不能和\begin{equation}\end{equation}互相套用,各用个的。
2、写公式的函数——aligned(是个奶娃娃,没有独立性,必须在数学环境下使用,$$或\begin{equation}\end{equation}都行)
(1)aligned示例
$$
\begin{aligned}
& \left\{
\begin{array}{lll}
\inf\limits_{\lambda \geq 0} & \lambda r + \frac{1}{M}\sum\limits_{k=1}{M}\sum\limits_{i=1}{N}(\eta_i + \frac{1}{1-\alpha_i}s_i - \lambda t_k)& \\
s.t.& s_i \geq (F-\eta_i)_+ & 1 \leq i \leq N \\
& t_k \geq \sup\limits_{\alpha \in [0,1]} |\alpha-\mu_0^k| & 1 \leq k \leq M
\end{array}
\right.\\ %\tag{\ref{4.1}{h}}\label{4.1h}\\
=& \left\{
\begin{array}{lll}
\inf\limits_{\lambda,s_i,t_k} & \lambda r + \frac{1}{M}\sum\limits_{k=1}{M}\sum\limits_{i=1}{N}(\eta_i + \frac{1}{1-\alpha_i}s_i - \lambda t_k)& \\
s.t.& \lambda \geq 0 & \\
& s_i \geq F-\eta_i & 1 \leq i \leq N \\
& s_i \geq 0 & 1 \leq i \leq N \\
& t_k + \mu_0^k \geq 1 & 1 \leq k \leq M\\
&\mu_0^k - t_k \leq 0 & 1 \leq k \leq M
\end{array}
\right.%\tag{\ref{4.1}{i}}\label{4.1i}
\end{aligned}
$$
(2)aligned不能用\tag,按理说不应该呀,可是刚才确实报错了,说:Package amsmath Error: \tag not allowed here
latex报错:Paragraph ended before \align was complete