![我怎样才能让东西在 align* 内居中](https://linux22.com/image/407921/%E6%88%91%E6%80%8E%E6%A0%B7%E6%89%8D%E8%83%BD%E8%AE%A9%E4%B8%9C%E8%A5%BF%E5%9C%A8%20align*%20%E5%86%85%E5%B1%85%E4%B8%AD.png)
我的代码是这样的:
\begin{center}
\begin{align*}
& \min_{w,b,\xi,\xi'}\ \ \ \ \frac{1}{2}\boldsymbol{w}^T\boldsymbol{w} + C\sum_{i=1}^l (\xi_i + \xi'_i) \\
& subject\ to \\
& \boldsymbol{w}^t\phi(\boldsymbol{x_i}) + b - y_i \leq \epsilon + \xi_i \\
& y_i - \boldsymbol{w}^T\phi(\boldsymbol{x_i}) - b \leq \epsilon + \xi'_i \\
& \xi_i, \xi'_i \geq 0,\ \ i = 1,\dots, l \\
\end{align*}
\end{center}
我希望“受制于”下的内容居中,位于第一行下方,而不是左对齐。我尝试将它们放在\begin{center}
...内,\end{center}
但它给了我很多错误
答案1
使用聚集
\documentclass{article}
\usepackage{amsmath}
\usepackage{showframe} % just for the example
\begin{document}
\begin{gather*}
% \begin{align}
\min_{w,b,\xi,\xi'}\ \ \ \ \frac{1}{2}\boldsymbol{w}^T\boldsymbol{w} +
C\sum_{i=1}^l (\xi_i + \xi'_i) \\
subject\ to \\
\boldsymbol{w}^t\phi(\boldsymbol{x_i}) + b - y_i \leq \epsilon + \xi_i \\
y_i - \boldsymbol{w}^T\phi(\boldsymbol{x_i}) - b \leq \epsilon + \xi'_i \\
\xi_i, \xi'_i \geq 0,\ \ i = 1,\dots, l
% \end{align}
\end{gather*}
\end{document}
答案2
我建议使用专用包进行布局,optidef
::
\documentclass{article}
\usepackage{optidef}
\begin{document}
\begin{mini*}|s|
{w,b,\xi,\xi'}{\frac{1}{2}\boldsymbol{w}^T\boldsymbol{w} + C\sum_{i=1}^l (\xi_i + \xi'_i)}
{}{}
\addConstraint{\boldsymbol{w}^t\phi(\boldsymbol{x_i}) + b - y_i}{\leq \epsilon + \xi_i}
\addConstraint{y_i - \boldsymbol{w}^T\phi(\boldsymbol{x_i}) - b}{\leq \epsilon + \xi’_i}
\addConstraint{ \xi_i, \xi'_i}{\geq 0,}{\quad i = 1,\dots, l}
\end{mini*}
\end{document}