2

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

5 Answers 5

4

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.

2

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.

enter image description here

\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 \\
&\qquad \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{align}

\end{document}
1

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}

enter image description here

1
  • 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. Commented Oct 26, 2014 at 14:09
0

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{equation}\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}\end{equation}
\lipsum[4]
\begin{equation}
\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{equation}

\end{document} 

enter image description here

0

Can anyone tell show me how can I write this expression in multiple lines? as it is not fitting in page. \begin{split} \frac{\partial \tau}{\partial \beta} =\frac{d n (a-c) \left(2 \left(n^3+n-2\right) \left(-2 \beta +\gamma +n \left(\beta +\gamma +\beta n^2+n\right)+1\right)\left(d n \left(\beta (n-1)^2-\gamma (n+1) n-1\right) \left(-2 \beta +\gamma +n \left(\beta +\gamma +\beta n^2+n\right)+1\right)+ \gamma (\gamma +n (\gamma (n+2)-3 n-4)-5)\right)-\left((n-1)^2 \left(2 \beta \left(n^3+n-2\right)+2 n^2+n+3\right)-\gamma \left(n^4+2 n^2-3\right)\right) \left(8 \gamma +n \left(8 \gamma +d \left(-2 \beta +\gamma +n \left(\beta +\gamma +\beta n^2+n\right)+1\right)^2+\gamma (\gamma +n (2 \gamma +n (\gamma +n+2)+5))-n (n+2)-5\right)-4\right)\right)}{\left(8 \gamma +n \left(8 \gamma +d \left(-2 \beta +\gamma +n \left(\beta +\gamma +\beta n^2+n\right)+1\right)^2+\gamma (\gamma +n (2 \gamma +n (\gamma +n+2)+5))-n (n+2)-5\right)-4\right)^2} \end{split}

2
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented May 21, 2022 at 13:27
  • If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From Review Commented May 21, 2022 at 13:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .