使用 \begin{split} 和 \end{split} 对齐方程时出错

使用 \begin{split} 和 \end{split} 对齐方程时出错

以下代码完全符合我的要求,如图所示。但是运行时会显示错误消息。如何消除显示的错误?以下是代码和公式。

\documentclass{article}
\usepackage{amsmath}
\begin{document}
 \begin{equation*}
\begin{split}
{\alpha}^{(k+1)}&=\frac{-n}{\sum\limits_{i=1}^{m}\ln\left( 
e^{{\lambda}^{(k)}/x_i^{\beta^{(k)}}}-1\right)-2\sum\limits_{i=1}^{m} \cfrac{\left( 
e^{{\lambda}^{(k)}/x_i^{\beta^{(k)}}}-1\right)^{\alpha^{(k+1)}}\ln\left( 
e^{{\lambda}^{(k)}/x_i^{\beta^{(k)}}}-1\right)}{\left( 
e^{{\lambda}^{(k)}/x_i^{\beta^{(k)}}}-1\right)^{\alpha^{(k+1)}}+1}  \\&+\sum\limits_{i=1}^{m} 
{R_i} C(x_i;{\alpha}^{(k)},{\beta}^{(k)},{\lambda}^{(k)} )        }
 \end{split}
\end{equation*}
\end{document}

! Missing } inserted.
<inserted text> 
                }
l.12  \end{split}
                 
? 

在此处输入图片描述

答案1

在更正代码后,我还将equation*/split环境更改为align*。代码结构稍微合理一些,以便更好地了解编译后发生的情况以及代码的各部分如何与结果相对应。您还可以考虑使用中间项,因为方程太长,无法容纳一页

在此处输入图片描述

\documentclass{article}
\usepackage{mathtools}

\begin{document}
\begin{align*}
    \alpha^{(k+1)} &= \frac{-n}{A - 2B + C}
    \intertext{with}
     A &= \sum\limits_{i=1}^{m}
             \ln\Bigl(
                 e^{\lambda^{(k)}/x_i^{\beta^{(k)}}} - 1
             \Bigr) \\
     B &= \sum\limits_{i=1}^{m}
             \cfrac{
                 \Bigl(
                     e^{{\lambda}^{(k)}/x_i^{\beta^{(k)}}} - 1
                 \Bigr)^{\alpha^{(k+1)}}
                 \ln \Bigl(
                     e^{{\lambda}^{(k)}/x_i^{\beta^{(k)}}} - 1
                 \Bigr)
             }{
                 \Bigl(
                     e^{{\lambda}^{(k)}/x_i^{\beta^{(k)}}} - 1
                 \Bigr)^{\alpha^{(k+1)}} + 1
             } \\
     C &= \sum\limits_{i=1}^{m}
             R_i
             C\Bigl(
                x_i;\alpha^{(k)},\beta^{(k)},\lambda^{(k)}
             \Bigr)
\end{align*}
\end{document}

答案2

我建议您按照以下方式简化符号。实际上,由于您的代码包含一些语法错误,我无法确定以下两个等式中哪一个是\alpha^{(k+1)}正确的。

在此处输入图片描述

\documentclass{article}
\usepackage{mathtools} % for \coloneqq macro
\begin{document}
\noindent
Put $U_i\coloneqq\exp\bigl( \lambda^{(k)}/x_i^{\beta^{(k)}} \bigr) -1$ 
and $V_i\coloneqq U_i^{\alpha^{(k+1)}}$. 
Then either
\begin{equation*}
\alpha^{(k+1)}
=-n\bigg/ \biggl(\,
    \sum_{i=1}^{m}\ln U_i 
  -2\sum_{i=1}^{m} \frac{V_i\ln U_i}{V_i+1}\biggr)
   +\sum_{i=1}^{m} R_i C\bigl(x_i;\alpha^{(k)},\beta^{(k)},\lambda^{(k)}\bigr)\,.
\end{equation*}
or
\begin{equation*}
\alpha^{(k+1)}
=-n\bigg/ \biggl(\,
    \sum_{i=1}^{m}\ln U_i 
  -2\sum_{i=1}^{m} \frac{V_i\ln U_i}{V_i+1}
   +\sum_{i=1}^{m} R_i C\bigl(x_i;\alpha^{(k)},\beta^{(k)},\lambda^{(k)}\bigr) \biggr) \,.
\end{equation*}
\end{document}

答案3

当我使用 mathjax 和包含空格的嵌套方程时遇到了同样的错误。

错误实例引发\begin{aligned} ended with \end{split}


$$\begin{aligned}
& \,\,\,\, -   {\partial \over \partial m}  \log \sum_z q_e(z|x) q_r(y|z) 
\\

&= \sum_z  q_w(z|x)  \left[ \begin{aligned}
\log {q_e(z|x) q_r(y|z)  \over q_w(z|x)} 
  {\partial \over \partial m}  \log q_w(z|x)  \\
 +  {\partial \over \partial m}  \log q_e(z|x) q_r(y|z) \\
 - {\partial \over \partial m}\log q_w(z|x)  \end{aligned} 
\right]  -   {\partial \over \partial m}  l  \\

&= \sum_z {\partial \over \partial m}\left[ 
 q_w(z|x) \log {q_e(z|x) q_r(y|z)  \over q_w(z|x)} 
    \right ]
   -   {\partial \over \partial m}  l  \\
&= {\partial \over \partial m} \sum_z \left[ 
 q_w(z|x) \log {q_e(z|x) q_r(y|z)  \over q_w(z|x)} 
    \right ]
   -   {\partial \over \partial m}  l  \\
-{\partial \over \partial m} D_{KL} &= {\partial \over \partial m} ELBO
   -   {\partial \over \partial m}  l 
\end{aligned}$$

删除所有换行符将消除错误,产生

$$\begin{aligned}
& \,\,\,\, -   {\partial \over \partial m}  \log \sum_z q_e(z|x) q_r(y|z) 
\\
&= \sum_z  q_w(z|x)  \left[ \begin{aligned}
\log {q_e(z|x) q_r(y|z)  \over q_w(z|x)} 
  {\partial \over \partial m}  \log q_w(z|x)  \\
 +  {\partial \over \partial m}  \log q_e(z|x) q_r(y|z) \\
 - {\partial \over \partial m}\log q_w(z|x)  \end{aligned} 
\right]  -   {\partial \over \partial m}  l  \\
&= \sum_z {\partial \over \partial m} \left[ 
 q_w(z|x) \log {q_e(z|x) q_r(y|z)  \over q_w(z|x)} 
    \right ] -   {\partial \over \partial m}  l  \\
&= {\partial \over \partial m} \sum_z \left[ 
 q_w(z|x) \log {q_e(z|x) q_r(y|z)  \over q_w(z|x)} 
    \right ]  -   {\partial \over \partial m}  l  \\
-{\partial \over \partial m} D_{KL} &= {\partial \over \partial m} ELBO
   -   {\partial \over \partial m}  l 
\end{aligned}$$

不确定具体哪个换行符导致了问题,但可能与 mathjax 插入 {split} 环境有关,

相关内容