2

I just write the long equation and it is wider than the page, so LaTex doesn't carry over on the next line and i need it to do somehow.For example,how can I do it with my long equation:

\begin{equation}
 min J = P(0)m_0^2+P(0) \cdot D_0^x+P(1)\cdot R_1(0)+P(2)\cdot R_1(1)+P(3)R_1(2)+ 
    \Gamma (0) L^T(0)\cdot(B^T(0)\cdotP(1)B(0)+Q)\cdot L(0)+ 
    \Gamma (1) L^T(1)\cdot(B^T(1)\cdot P(2)B(1)+Q(1))\cdot L(1)+
    \Gamma (2) L^T(2)\cdot(B^T(2)\cdotP(3)B(2)+Q(2))\cdot L(2) 
\end{equation}

The \newline cmd and \\ don't work

leandriis
  • 62,593

3 Answers3

5

I propose this solution with aligned (without any ampersand, it is right-aligned). I took the liberty to replace Q in the second line with Q(0) (I thought you had mistyped it, but maybe I'm wrong). Also, I think the final + look better at the beginning of the following line

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{equation} \begin{aligned} \min J =P(0)m_0^2+P(0) \cdot D_0^x+P(1)\cdot R_1(0)+P(2)\cdot R_1(1)+P(3)R_1(2) \ {} + \Gamma (0) L^T(0)\cdot\bigl(B^T(0)\cdot P(1)B(0)+Q(0)\bigr)\cdot L(0) \ {} + \Gamma (1) L^T(1)\cdot\bigl(B^T(1)\cdot P(2)B(1)+Q(1)\bigr)\cdot L(1) \ {} + \Gamma (2) L^T(2)\cdot\bigl(B^T(2)\cdot P(3)B(2)+Q(2)\bigr)\cdot L(2) \end{aligned} \end{equation}

\end{document}

enter image description here

Bernard
  • 271,350
4

You may use the IEEEeqnarray environment from the IEEEtrantools package.

\documentclass{article}
\usepackage{amsmath}
\usepackage{IEEEtrantools}
\usepackage{showframe}
\begin{document}
\begin{IEEEeqnarray*}{rCl}
 \min J &=& P(0)m_0^2+P(0) \cdot D_0^x+P(1)\cdot R_1(0)+P(2)\cdot R_1(1)+P(3)R_1(2)\\
       & & \negmedspace {}+\Gamma (0) L^T(0)\cdot(B^T(0)\cdot P(1)B(0)+Q)\cdot L(0)\\
       & & \negmedspace {}+\Gamma (1) L^T(1)\cdot(B^T(1)\cdot P(2)B(1)+Q(1))\cdot L(1)\\
       & & \negmedspace {}+\Gamma (2) L^T(2)\cdot(B^T(2)\cdot P(3)B(2)+Q(2))\cdot L(2)\IEEEyesnumber\\
\end{IEEEeqnarray*}
\end{document}  

enter image description here

Black line shows page margin.

Imran
  • 3,096
2

If conserving (vertical) space is important to you, you could place the equation in a \parbox directive and employ \linebreak directives where needed.

Oh, and I would get rid of the \cdot "crutches". If making the long expression easily parsable is an objective, I can suggest replacing the "outer" round parentheses in lines 2 to 4 with square brackets.

enter image description here

\documentclass{article}
\begin{document}
\begin{equation}
\min J = \parbox[t]{0.75\textwidth}{$
P(0)m_0^2+P(0)D_0^x + P(1)R_1(0) + P(2)R_1(1) + P(3)R_1(2)+ 
    \linebreak\Gamma(0) L^T(0)[B^T(0) P(1)B(0)+Q(0)] L(0)+ 
    \linebreak\Gamma(1) L^T(1)[B^T(1) P(2)B(1)+Q(1)] L(1)+
    \linebreak\Gamma(2) L^T(2)[B^T(2) P(3)B(2)+Q(2)] L(2)$}
\end{equation}
\end{document}
Bernard
  • 271,350
Mico
  • 506,678