173

My equation is very long. How do I get it to continue on the next line rather than go off the page?

2
  • I would question if you really want to do that. Multi-line equations will be very difficult to read. Is it possible to break up your equation into multiple (shorter) equations?
    – pkaeding
    May 18, 2010 at 18:58
  • Use \notag \\ Check relevant answers here: tex.stackexchange.com/questions/74819/… Oct 16, 2020 at 10:23

13 Answers 13

161

If your equation does not fit on a single line, then the multline (note that that's multline without an "i", not "multiline") environment probably is what you need:

\begin{multline}
    first part of the equation \\
    = second part of the equation
\end{multline}

If you also need some alignment respect to the first part, you can use split:

\begin{equation}
    \begin{split}
        first part &= second part #1 \\
        &= second part #2
    \end{split}
\end{equation}

Both environments require the amsmath package.

See also aligned as pointed out in an answer below.

3
  • In my experience there can't be a newline inside multline en equation environments
    – LEDfan
    Dec 5, 2015 at 9:18
  • ! Package amsmath Error: \begin{multline} allowed only in paragraph mode.
    – Welgriv
    Aug 24, 2022 at 12:16
  • @Welgriv are you putting the multline environment inside the equation environment Jun 20 at 8:57
25

Not yet mentioned here, another choice is environment aligned, again from package amsmath:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{equation}
  \begin{aligned}
    A & = B + C\\
      & = D + E + F\\
      & = G
  \end{aligned}
\end{equation}

\end{document}

This outputs:

screenshot of output (detail)

0
13

Without configuring your math environment to clip, you could force a new line with two backslashes in a sequence like this:

Bla Bla \\ Bla Bla in another line

The problem with this is that you will need to determine where a line is likely to end and force to always have a line break there. With equations, rather than text, I prefer this manual way.

You could also use \\* to prevent a new page from being started.

10

If it is inline equation, then use \allowbreak. Use it like:

$x_1,x_2,x_3,\allowbreak x_4,x_5$.

Latex will break equation in this place only if necessary.

1
  • 1
    that didn't work for me
    – nafrtiti
    Nov 8, 2022 at 20:04
6

I used the \begin{matrix}

\begin{equation}
\begin{matrix}
    line_1 \\ 
    line_2 \\ 
    line_3
\end{matrix}
\end{equation}
6

There are a couple ways you can deal with this. First, and perhaps best, is to rework your equation so that it is not so long; it is likely unreadable if it is that long.

If it must be so, check out the AMS Short Math Guide for some ways to handle it. (on the second page)

Personally, I'd use an align environment, so that the breaking and alignment can be precisely controlled. e.g.

\begin{align*}
   x&+y+\dots+\dots+x_100000000\\
   &+x_100000001+\dots+\dots
\end{align*}

which would line up the first plus signs of each line... but obviously, you can set the alignments wherever you like.

2
  • 1
    What is the align* environment good for, with respect to the align environment (with versus without asterisk) ? Feb 13, 2019 at 19:51
  • 2
    the asterisk tells it to omit numbers for the equation lines.
    – TJ Ellis
    Feb 14, 2019 at 16:41
5

I think I usually used eqnarray or something. It lets you say

\begin{eqnarray*}
    x &=& blah blah blah \\ 
      & & more blah blah blah \\
      & & even more blah blah
\end{eqnarray*}

and it will be aligned by the & &... As pkaeding mentioned, it's hard to read, but when you've got an equation thats that long, it's gonna be hard to read no matter what... (The * makes it not have an equation number, IIRC)

2
  • 4
    f.y.i. the AMS recommends not using eqnarray environments because they "produce inconsistent spacing of the equal signs and make no attempt to prevent overprinting of the equation body and equation number." -- not really applicable here, but good to know; a good ol' align environment can take care of most such circumstances.
    – TJ Ellis
    May 18, 2010 at 21:01
  • Is there a way to make this one number the equation also? If I insert a label, I can reference it by number, but it's not printed on the right side of the equation. Oct 4, 2017 at 21:11
4

multline is best to use. Instead, you can use dmath, split as well.

Here is an example:

\begin{multline}
  {\text {\bf \emph {T(u)}}} ={  \alpha *}{\frac{\sum_{i=1}^{\text{\bf \emph {I(u)}}}{{\text{\bf \emph {S(u,i)}}}* {\text {\bf \emph {Cr(P(u,i))}}} * {\text {\bf \emph {TF(u,i)}}}}}{\text {\bf \emph {I(u)}}}}  \\
   +{  \beta *}{\frac{\sum_{i=1}^{\text{\bf \emph {$I_h$(u)}}}{{\text{\bf \emph {S(u,i)}}}* {\text {\bf \emph {Cr(P(u,i))}}} * {\text {\bf \emph {TF(u,i)}}}}}{\text {\bf \emph {$I_h$(u)}}}}
\end{multline}
3

This worked for me while using mathtools package.

\documentclass{article}
\usepackage{mathtools}
\begin{document}
    \begin{equation}
        \begin{multlined}
            first term \\
            second term                 
        \end{multlined}
    \end{equation}
\end{document}
0
2

Use eqnarray and \nonumber

example:

\begin{eqnarray}
    sample = R(s,\pi(s),s') + \gamma V^{\pi} (s') \nonumber \\
    \label{eq:temporal-difference}
     V^{\pi}_{k+1}(s) = (1-\alpha)V^{\pi}(s) - \alpha[sample]
\end{eqnarray}
1

SIMPLE ANSWER HERE

\begin{equation}
\begin{split}

equation \\
here

\end{split}
\end{equation}
1
  • This is what worked the best for me. The {split} function was the key. Feb 24, 2020 at 0:21
1

You do not need any extra package to do this:

\begin{equation}
  \begin{gathered}
     first formula\\
     second formula
  \end{gathered}
\end{equation}
0

To solve this issue, I used the array environment inside the equation environment like this:

\begin{equation}
    \begin{array}{r c l}
       first Term&=&Second Term\\
                 &=&Third Term
    \end{array}
\end{equation}

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