我在对齐环境中有一个方程式,用于将等号对齐。但是,最后一个方程式太长,我想将其拆分。当我插入换行符时,最后一个方程式上方的所有方程式都会向右移动。代码:
\begin{equation}
\begin{aligned}
\log\left(p\left(s|\alpha\right)\right) & = \sum\limits_{i=1}^O\left(\log\left(\frac{1}{\prod\limits_{k=1}^K\Gamma\left(\hat{\mathcal{S}}_k^i+1\right)}\right) + \log\left(\frac{\Gamma\left(\alpha_0\right)}{\Gamma\left(\sum\limits_{k=1}^K\left(\hat{\mathcal{S}}_k^i+a_k\right)\right)}\right) + \log\left(\prod\limits_{k=1}^K \frac{\Gamma\left(\hat{\mathcal{S}}_k^i+\alpha_k\right)}{\Gamma\left(\alpha_k\right)}\right)\right) \\
&= \sum\limits_{i=1}^O\left(-\log\left(\prod\limits_{k=1}^K\Gamma\left(\hat{\mathcal{S}}_k^i+1\right)\right) + \log\left(\frac{\Gamma\left(\alpha_0\right)}{\Gamma\left(\sum\limits_{k=1}^K\left(\hat{\mathcal{S}}_k^i+a_k\right)\right)}\right) + \log\left(\prod\limits_{k=1}^K \frac{\Gamma\left(\hat{\mathcal{S}}_k^i+\alpha_k\right)}{\Gamma\left(\alpha_k\right)}\right)\right) \\
&= \sum\limits_{i=1}^O\left(\sum\limits_{k=1}^K\left(-\log\left(\Gamma\left(\hat{\mathcal{S}}_k^i+1\right)\right)\right) + \log\left(\frac{\Gamma\left(\alpha_0\right)}{\Gamma\left(\sum\limits_{k=1}^K\left(\hat{\mathcal{S}}_k^i+a_k\right)\right)}\right) + \log\left(\prod\limits_{k=1}^K \frac{\Gamma\left(\hat{\mathcal{S}}_k^i+\alpha_k\right)}{\Gamma\left(\alpha_k\right)}\right)\right) \\
&= \sum\limits_{i=1}^O\left(\sum\limits_{k=1}^K\left(-\log\left(\Gamma\left(\hat{\mathcal{S}}_k^i+1\right)\right)\right) + \log\left(\Gamma\left(\alpha_0\right)\right) -\log\left(\Gamma\left(\sum\limits_{k=1}^K\left(\hat{\mathcal{S}}_k^i+a_k\right)\right)\right) + \log\left(\prod\limits_{k=1}^K \frac{\Gamma\left(\hat{\mathcal{S}}_k^i+\alpha_k\right)}{\Gamma\left(\alpha_k\right)}\right)\right)
\end{aligned}
\end{equation}
我想要的是
\begin{equation}
\begin{aligned}
\log\left(p\left(s|\alpha\right)\right) & = \sum\limits_{i=1}^O\left(\log\left(\frac{1}{\prod\limits_{k=1}^K\Gamma\left(\hat{\mathcal{S}}_k^i+1\right)}\right) + \log\left(\frac{\Gamma\left(\alpha_0\right)}{\Gamma\left(\sum\limits_{k=1}^K\left(\hat{\mathcal{S}}_k^i+a_k\right)\right)}\right) + \log\left(\prod\limits_{k=1}^K \frac{\Gamma\left(\hat{\mathcal{S}}_k^i+\alpha_k\right)}{\Gamma\left(\alpha_k\right)}\right)\right) \\
&= \sum\limits_{i=1}^O\left(-\log\left(\prod\limits_{k=1}^K\Gamma\left(\hat{\mathcal{S}}_k^i+1\right)\right) + \log\left(\frac{\Gamma\left(\alpha_0\right)}{\Gamma\left(\sum\limits_{k=1}^K\left(\hat{\mathcal{S}}_k^i+a_k\right)\right)}\right) + \log\left(\prod\limits_{k=1}^K \frac{\Gamma\left(\hat{\mathcal{S}}_k^i+\alpha_k\right)}{\Gamma\left(\alpha_k\right)}\right)\right) \\
&= \sum\limits_{i=1}^O\left(\sum\limits_{k=1}^K\left(-\log\left(\Gamma\left(\hat{\mathcal{S}}_k^i+1\right)\right)\right) + \log\left(\frac{\Gamma\left(\alpha_0\right)}{\Gamma\left(\sum\limits_{k=1}^K\left(\hat{\mathcal{S}}_k^i+a_k\right)\right)}\right) + \log\left(\prod\limits_{k=1}^K \frac{\Gamma\left(\hat{\mathcal{S}}_k^i+\alpha_k\right)}{\Gamma\left(\alpha_k\right)}\right)\right) \\
&= \sum\limits_{i=1}^O\left(\sum\limits_{k=1}^K\left(-\log\left(\Gamma\left(\hat{\mathcal{S}}_k^i+1\right)\right)\right) + \log\left(\Gamma\left(\alpha_0\right)\right) -\log\left(\Gamma\left(\sum\limits_{k=1}^K\left(\hat{\mathcal{S}}_k^i+a_k\right)\right)\right) \\
\qquad\qquad + \log\left(\prod\limits_{k=1}^K \frac{\Gamma\left(\hat{\mathcal{S}}_k^i+\alpha_k\right)}{\Gamma\left(\alpha_k\right)}\right)\right)
\end{aligned}
\end{equation}
我不想使用 &+,因为这样它会与等号对齐,而且我希望它缩进得更远一些。
答案1
&\qquad\qquad
但请记住,\left...\right
不能被打破,因此必须重写最后一行以说明
&=
\sum\limits_{i=1}^O\Bigl(\sum\limits_{k=1}^K\left(-\log\left(\Gamma \left(\hat{\mathcal{S}}_k^i+1\right)\right)\right)
+ \log\left(\Gamma\left(\alpha_0\right)\right)
-\log\left(\Gamma\left(\sum\limits_{k=1}^K \left(\hat{\mathcal{S}}_k^i+a_k\right)\right)\right)
\\
&\qquad\qquad + \log\left(\prod\limits_{k=1}^K
\frac{\Gamma\left(\hat{\mathcal{S}}_k^i+\alpha_k\right)}{\Gamma \left(\alpha_k\right)}\right)\Bigr)
还有更合适的尺寸。
此外,那些庞大的()真的需要吗?对我来说,它们在准备公式时没有多大帮助,相反,它们真的很烦人。
此外,我甚至会使用mathtools
下面的代码。没有必要使用所有这些自动缩放功能,因为最终看起来很糟糕。也不需要那些\limits
。
\begin{equation}
\begin{aligned}
\MoveEqLeft
\log\bigl(p(s|\alpha)\bigr)
\\
& =
\sum\limits_{i=1}^O\left(
\log\Bigl(
\frac{1}{\prod_{k=1}^K
\Gamma(\hat{\mathcal{S}}_k^i+1)}
\Bigr)
+
\log\Bigl(
\frac{
\Gamma(\alpha_0)
}{
\Gamma\bigl(
\sum_{k=1}^K(\hat{\mathcal{S}}_k^i+a_k)
\bigr)
}
\Bigr)
+ \log\Bigl(
\prod_{k=1}^K
\frac{
\Gamma(\hat{\mathcal{S}}_k^i+\alpha_k)
}{
\Gamma(\alpha_k)
}
\Bigr)
\right)
\\
&=
\sum\limits_{i=1}^O
\left(
-\log\Bigl(
\prod_{k=1}^K
\Gamma(\hat{\mathcal{S}}_k^i+1)
\Bigr)
+
\log\Bigl(
\frac{
\Gamma(\alpha_0)
}{
\Gamma\bigl(
\sum_{k=1}^K
(\hat{\mathcal{S}}_k^i+a_k)
\bigr)
}
\Bigr)
+ \log\Bigl(
\prod_{k=1}^K
\frac{
\Gamma(\hat{\mathcal{S}}_k^i+\alpha_k)
}{
\Gamma(\alpha_k)
}
\Bigr)
\right)
\\
&=
\sum_{i=1}^O
\left(
\sum_{k=1}^K
\Bigl(
-\log
\bigl(\Gamma(\hat{\mathcal{S}}_k^i+1) \bigr)
\Bigr)
+
\log\Bigl(
\frac{
\Gamma(\alpha_0)
}{
\Gamma\bigl(
\sum_{k=1}^K
(\hat{\mathcal{S}}_k^i+a_k)
\bigr)
}
\Bigr)
+ \log\Bigl(
\prod_{k=1}^K
\frac{
\Gamma(\hat{\mathcal{S}}_k^i+\alpha_k)
}{
\Gamma(\alpha_k)
}
\Bigr)
\right)
\\
&=
\sum_{i=1}^O\Biggl(
\sum_{k=1}^K
\Bigl(
-\log\bigl(
\Gamma(\hat{\mathcal{S}}_k^i+1)
\bigr)
\Bigr)
+ \log\left(
\Gamma(\alpha_0 )
\right)
-\log\biggl(
\Gamma\Bigl(
\sum_{k=1}^K
(\hat{\mathcal{S}}_k^i+a_k)
\Bigr
)
\biggr)
\\
&\qquad\qquad + \log\Bigl(
\prod_{k=1}^K
\frac{
\Gamma(\hat{\mathcal{S}}_k^i+\alpha_k)
}{
\Gamma(\alpha_k)
}
\Bigr)
\Biggr)
\end{aligned}
\end{equation}
或者更好的办法是,不要把所有内容都写出来。这样对读者没有帮助。定义助手:
So ease notation, we define:
\begin{align*}
A &= \prod_{k=1}^K \Gamma(\hat{\mathcal{S}}_k^i+1) \\
B &= \sum_{k=1}^K(\hat{\mathcal{S}}_k^i+a_k)\\
C &= \prod_{k=1}^K \frac{ \Gamma(\hat{\mathcal{S}}_k^i+\alpha_k)}{ \Gamma(\alpha_k) }
\end{align*}
\begin{equation}
\begin{aligned}
\MoveEqLeft
\log\bigl(p(s|\alpha)\bigr)
\\
& =
\sum\limits_{i=1}^O\left(
\log\Bigl( \frac{1}{A} \Bigr)
+
\log\Bigl(
\frac{
\Gamma(\alpha_0)
}{
\Gamma\bigl(
B
\bigr)
}
\Bigr)
+ \log(C)
\right)
\\
&=
\sum\limits_{i=1}^O
\left(
-\log( A )
+
\log\Bigl(
\frac{ \Gamma(\alpha_0) }{ \Gamma( B ) }
\Bigr)
+ \log( C )
\right)
\\
&=
\sum_{i=1}^O
\left(
\sum_{k=1}^K
\Bigl(
-\log
\bigl(\Gamma(\hat{\mathcal{S}}_k^i+1) \bigr)
\Bigr)
+
\log\Bigl(
\frac{ \Gamma(\alpha_0) }{ \Gamma( B ) }
\Bigr)
+ \log( C )
\right)
\\
&=
\sum_{i=1}^O\biggl(
\sum_{k=1}^K
\Bigl(
-\log\bigl(
\Gamma(\hat{\mathcal{S}}_k^i+1)
\bigr)
\Bigr)
+ \log\left(
\Gamma(\alpha_0 )
\right)
-\log\bigl(
\Gamma( B )
\bigr)
+ \log( C )
\biggr)
\end{aligned}
\end{equation}