0

My code is this:

\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}

and it produces this output: enter image description here

I would like for the things under "subject to" to be centered, under the first row and not aligned on the left. I tried putting them inside a \begin{center}...\end{center} but it gave me a lot of errors

Bernard
  • 271,350

2 Answers2

2

I suggest making the layout with the dedicated package, 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} 

enter image description here

Bernard
  • 271,350
1

enter image description here

Use gather

\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}
js bibra
  • 21,280
  • 3
    "subject to" is really text, not math. If it should follow the general style of the enclosing environment (upright in ordinary text, italic in a theorem), then enclose it in \text{subject to}. If it should always be italic, then \text{\itshape ...} is more appropriate. – barbara beeton Feb 12 '20 at 17:52