我有四个方程,第二个方程与其他方程不对齐。我尝试在下面的代码中使用“对齐”,但它没有按预期工作。
\begin{equation}
\begin{aligned}
\min_{w} \quad & \frac{\mu_{s_i}^Tw - r_f}{\sqrt{w^T\sum_{s_i} w}}
+ \gamma w^T w\\
\textrm{s.t.} \quad & 1^T w = 1\\
& 0 \leq w_i \leq 0.5 \quad & \textrm{i = 1,2,..,7} \\
\end{aligned}
\end{equation}
\begin{equation}
\begin{aligned}
\max_{w} \quad & \mu_{s_i}^Tw + \gamma w^T w\\
\textrm{s.t.} \quad & \sqrt{w^T\sum_{s_i} w} = \sigma_{s_i}\\
& 1^T w = 1\\
& 0 \leq w_i \leq 0.5 \quad & \textrm{i = 1,2,..,7} \\
\end{aligned}
\end{equation}
\begin{equation}
\begin{aligned}
\min_{w} \quad & \sqrt{w^T\sum_{s_i} w} + \gamma w^T w\\
\textrm{s.t.} \quad & \mu_{s_i}^Tw = R_{s_i}\\
& 1^T w = 1\\
& 0 \leq w_i \leq 0.5 \quad & \textrm{i = 1,2,..,7} \\
\end{aligned}
\end{equation}
\begin{equation}
\begin{aligned}
\min_{w} \quad & \sqrt{w^T\sum_{s_i} w} + \gamma w^T w\\
\textrm{s.t.} \quad & 1^T w = 1\\
& 0 \leq w_i \leq 0.5 \quad & \textrm{i = 1,2,..,7} \\
\end{aligned}
\end{equation}
以下是屏幕截图:
答案1
您的方程式完全不同,并且不在一个环境中分组。方程式 15、17、18 偶然正确对齐,因为它们的宽度相等。这是一个简单的例子(还有很多技巧和方法为此):
\begin{align}
&\begin{aligned}
\min_{w} \quad & \frac{\mu_{s_i}^Tw - r_f}{\sqrt{w^T\sum_{s_i} w}}
+ \gamma w^T w\\
\textrm{s.t.} \quad & 1^T w = 1\\
& 0 \leq w_i \leq 0.5 \quad & \textrm{i = 1,2,..,7} \\
\end{aligned}\\
&\begin{aligned}
\max_{w} \quad & \mu_{s_i}^Tw + \gamma w^T w\\
\textrm{s.t.} \quad & \sqrt{w^T\sum_{s_i} w} = \sigma_{s_i}\\
& 1^T w = 1\\
& 0 \leq w_i \leq 0.5 \quad & \textrm{i = 1,2,..,7} \\
\end{aligned}
\end{align}