4

I have a long equation. I want to split and align left for that equation such that same "=" location. I used below code in latex. But it fails to display. Thanks

\documentclass[preprint,12pt, sort&compress]{elsarticle}

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

\usepackage{lipsum} % for dummy text

\begin{document}

\lipsum[1]
 \begin{equation*}\label{proof_lemma:3} 
            \begin{aligned}
            \frac{\partial E(\mu,\sigma,\theta,\beta)}{\partial \beta}=\int_\Omega \sum_{i=1}^N \frac{\partial r_i(x)}{\partial \beta}dx \\
            =-\int_\Omega \sum_{i=1}^N \left( \frac{( \mu-\sigma- \theta)}{\sigma_i}\right)dx\\
    -\int_\Omega \sum_{i=1}^N \left( \frac{( \mu-\sigma- \theta)}{\sigma_i}\right)dx-\int_\Omega \sum_{i=1}^N \left( \frac{( \mu-\sigma- \theta)}{\sigma_i}\right)dx-\int_\Omega \sum_{i=1}^N \left( \frac{( \mu-\sigma- \theta)}{\sigma_i}\right)dx
            \end{aligned}
             \end{equation*}
\end{document}

enter image description here

  • Please update the code to something that complies on its own – daleif Nov 6 '15 at 13:10
  • I updated it. Please check it – Jame Nov 6 '15 at 13:16
5

Use the ={}& trick:

\documentclass{article}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage[mathscr]{euscript}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{chngcntr}
\usepackage{apptools}
\usepackage{amsthm}
\usepackage{hyperref}

\newcommand{\diff}{\mathop{}\!d}

\begin{document}

\begin{equation*}
\begin{aligned}
\frac{\partial E(\mu,\sigma,\theta,\beta)}{\partial \beta}
={}& \int\limits_\Omega \sum_{i=1}^N \frac{\partial r_i(x)}{\partial \beta}\diff x \\
={}& -\int\limits_\Omega \sum_{i=1}^N \left( \frac{( \mu-\sigma- \theta)}{\sigma_i}\right)\diff x
     -\int\limits_\Omega \sum_{i=1}^N \left( \frac{( \mu-\sigma- \theta)}{\sigma_i}\right)\diff x\\
   & -\int\limits_\Omega \sum_{i=1}^N \left( \frac{( \mu-\sigma- \theta)}{\sigma_i}\right)\diff x
     -\int\limits_\Omega \sum_{i=1}^N \left( \frac{( \mu-\sigma- \theta)}{\sigma_i}\right)\diff x
\end{aligned}
\end{equation*}

\end{document}

Note how I defined a macro for the differential symbol and used \int\limits in order to push the Omega below the integral symbol, which is customary in this case.

Note that hyperref should be loaded last among the packages you have.

enter image description here

  • I am very thankful to you. It is very nice answer. – Jame Nov 6 '15 at 13:31
  • I just asked you a small question that is when I use \frac to show the division such as one of term above. The integration symbol appears very small. Let see that $\frac{\int\limits_\Omega \sum_{i=1}^N \left( \frac{( \mu-\sigma- \theta)}{\sigma_i}\right)\diff x}{\int\limits_\Omega \sum_{i=1}^N \left( \frac{( \mu-\sigma- \theta)}{\sigma_i}\right)\diff x}$ – Jame Nov 6 '15 at 13:59
  • And I found that your solution may be error if \left( in first line, and \right) in second line, is it correct. I just got ! Extra }, or forgotten \right.<template> }$\hfil \endtemplate ...mega} \left( \log (\sqrt{2\pi}\sigma_i)\\ – Jame Nov 6 '15 at 14:20
  • @user8430 For scaling integral sign see tex.stackexchange.com/questions/39181/big-integral-sign – Onner Irotsab Nov 6 '15 at 15:36
1

You can use the aligned environment like it follows:

\documentclass{article}

\usepackage{amsmath}


\begin{document}

\begin{equation*}
    \label{proof_lemma:3} 
    \begin{aligned}
        \frac{\partial E(\mu,\sigma,\theta,\beta)}{\partial \beta}&=\int_\Omega \sum_{i=1}^N \frac{\partial r_i(x)}{\partial \beta}dx \\[\jot]
        &=-\int_\Omega \sum_{i=1}^N \left( \frac{( \mu-\sigma- \theta)}{\sigma_i}\right)dx -\int_\Omega \sum_{i=1}^N \left( \frac{( \mu-\sigma- \theta)}{\sigma_i}\right)dx\\[\jot]
        &\quad -\int_\Omega \sum_{i=1}^N \left( \frac{( \mu-\sigma- \theta)}{\sigma_i}\right)dx
        -\int_\Omega \sum_{i=1}^N \left( \frac{( \mu-\sigma- \theta)}{\sigma_i}\right)dx 
    \end{aligned}
\end{equation*}

\end{document}             

Note &= and &\quad.

I have added \\[\jot] to leave more space between the lines, but this is matter of choice.

enter image description here

  • How about if \left ( ....\\ (first line) &\quad \right) (second line) It has error – Jame Nov 6 '15 at 14:27
  • @user8430 You have to use \right. at the end of the first line and \left. at the beginning of the second line. – Onner Irotsab Nov 6 '15 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.