[Tex/LaTex] split and align long equation

alignequations

The following code is used to split a long in-equation.

\begin{align}
(\sum^n_{i,j=1}\frac{(S_{t})_{ij}\norm{W^T_{t+1}x_i-W^T_{t+1}x_j}_2^2}{2\norm{W^T_{t}x_i-W^T_{t}x_j}_2} - \nonumber \\
 \lambda_ttr(W^T_{t+1}XX^TW_{t+1})) \leq \nonumber \\
(\sum^n_{i,j=1}\frac{(S_{t})_{ij}\norm{W^T_tx_i-W^T_tx_j}_2^2}{2\norm{W^T_tx_i-W^T_tx_j}_2}- \nonumber \\
\lambda_ttr(W^T_tXX^TW_t))
\end{align}

The screenshot of the result is attached:
enter image description here

I'm not satisfied with the above result. Is it possible to make the
equation center aligned:

enter image description here

Best Answer

Presumably you need this number of lines because of a two column document. I would not want to center the lines because of the different operators - and \leq. Instead I would prefer a staggered output where each newline on the left of the equation starts further to the left than those after the \leq and on each side the first line is further left than the subsequent ones. One way to achieve this is:

Sample output

\documentclass[twocolumn]{article}

\usepackage{mathtools}
\DeclarePairedDelimiter{\norm}{\lVert}{\rVert}
\DeclareMathOperator{\tr}{tr}

\usepackage{lipsum} % for dummy text

\begin{document}

\lipsum[1]
\begin{equation}
  \begin{split}
    \MoveEqLeft
    \sum^n_{i,j=1}\frac{(S_{t})_{ij}\norm{W^T_{t+1}x_i-W^T_{t+1}x_j}_2^2}{2\norm{W^T_{t}x_i-W^T_{t}x_j}_2} \\
    \MoveEqLeft[1] - \lambda_t\tr(W^T_{t+1}XX^TW_{t+1})\\
    &\leq
    \sum^n_{i,j=1}\frac{(S_{t})_{ij}\norm{W^T_tx_i-W^T_tx_j}_2^2}{2\norm{W^T_tx_i-W^T_tx_j}_2} \\
    &\qquad -\lambda_t\tr(W^T_tXX^TW_t)
  \end{split}
\end{equation}

\end{document}

Other changes introduced

  • definition of \norm via \DeclarePairedDelimiter
  • definition of \tr
  • use of just equation when it is one single equation, subsequent division with split

Another possibility would be to use multiline and perhaps mulitlined for the two sides of the equation.

Related Question