# How can I carry over my equation?

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

• Dec 29, 2021 at 12:59
• multiline doesn't work correctly either Dec 29, 2021 at 13:27
• multline works correctly if it is used as intended, if you don't show how you are using it or what output you got, it is hard to help Dec 29, 2021 at 14:31
• @DavidCarlisle My thoughts exactly, Overleaf recommends it. Dec 30, 2021 at 5:12

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} • Thank you! @Bernard, why compiler says "undefined control sequence"? I use amsmath package...Don't get it Dec 29, 2021 at 13:56
• @Programmer1988: I have no such message. Can you see from the .log file what the ‘undefined control sequence’ is? Dec 29, 2021 at 14:00
• it's my fault, I typed \cdotP instead of \cdot P Dec 29, 2021 at 14:07
• Thanks a lot, i accepted your answer Dec 29, 2021 at 14:07

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} Black line shows page margin.

• it is not the array, you're wrong Dec 29, 2021 at 13:46
• @Programmer1988 Sorry, I didn't understand your comment. What is "not the array"? Dec 29, 2021 at 13:51
• @Programmer1988 ieeeeqnarray os an improved version of the standard eqnarray and is a viable alternative to the amsmath alignments. Your first comment here is wrong. Dec 29, 2021 at 14:33
• +1. I would also replace min J with \min J.
– Mico
Dec 29, 2021 at 15:54

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. \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 - Thanks for the edit!
– Mico
Dec 29, 2021 at 23:36
• You're welcome. You're not not the only one to have typos – some days I have almost as many as pips in a mandarin! Dec 30, 2021 at 10:28