# split and align long equation

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:

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

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:

\documentclass[twocolumn]{article}

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

\usepackage{lipsum} % for dummy text

\begin{document}

\lipsum[1]
$$\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{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.

I don't think it's necessary to break up the equation across four lines; it looks like the equation fits comfortably inside the text block if it's broken up only once. I suggest you use a multline environment to typeset the equation.

If you want a less pronounced horizontal offset between the two lines of the equation, you could use an align environment instead, inserting \qquad at the start of the second line. Both solutions are shown below.

Using two instead of four lines also permits getting rid of two pairs of parentheses that don't seem to be necessary from a mathematical point of view. Incidentally, your code snippet doesn't mention how the macro \norm is defined; in the code below, I use a setup made possible by the mathtools package.

\documentclass{article}

\usepackage{mathtools} % see http://ctan.org/pkg/mathtools
\DeclarePairedDelimiter\norm{\lVert}{\rVert}
\DeclareMathOperator{\tr}{tr}

\begin{document}

\begin{multline}
\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}
-\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}
-\lambda_t\tr(W^T_tXX^TW_t)
\end{multline}

\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}
-\lambda_t \tr(W^T_{t+1}XX^TW_{t+1}) \nonumber \\
-\lambda_t\tr(W^T_tXX^TW_t)
\end{align}

\end{document}


It may be done via gather. Some additional corrections (not all needed): bigger parentheses, upright trace and addidional minus signs were added. Because \norm was undefined, my definition is added.

However, linking the lines by two would give a better aesthetic effect.

\documentclass{article}

\usepackage{amsmath}

\def\norm#1{\left\|#1\right\|}
\DeclareMathOperator{\tr}{tr}

\begin{document}

\begin{gather}
\Bigl(\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_t \tr(W^T_{t+1}XX^TW_{t+1})\Bigr) \leq \nonumber \\
\Bigl(\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_t\tr(W^T_tXX^TW_t)\Bigr)
\end{gather}

\end{document}


• it's traditional (in western european typesetting) to put the sign of relation (\leq) at the beginning of the continuation line where it will likely be seen more readily. – barbara beeton Oct 26 '14 at 14:09

Two variants in two-column: one with aligned and the medisze environment, fromm nccmath allows for writing the equation on two lines, at the cost of equation number on the line below. The medsize environment makes formulae about 80 % of display style.

The other solution uses both aligned and multlined.

\documentclass[twocolumn]{article}

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

\usepackage{lipsum} % for dummy text \MoveEqLeft[1]

\begin{document}

\lipsum[4]
\begin{medsize} \begin{aligned} & \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}% - λ_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}% -λ_t\tr(W^T_litXX^TW_t) \end{aligned} \end{medsize}
\lipsum[4]
\begin{aligned} & \begin{multlined} \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} \\ - λ_t\tr(W^T_{t+1}XX^TW_{t+1}) \end{multlined} \\ & \leq\!\begin{multlined} \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} \\ -λ_t\tr(W^T_litXX^TW_t) \end{multlined} \end{aligned}

\end{document}