234

I have an equation long enough to occupy two lines. I want to break it to improve readability. How can I break it?

\begin{equation}
F = \{F_{x} \in  F_{c} : (|S| > |C|) \cap 
(minPixels  < |S| < maxPixels) \cap 
(|S_{connected}| > |S| - \epsilon)
  \}
\end{equation}

I want to break it in 3 lines after \cap. But \\ or \n didn't work.

LukasFun
  • 117
nacho4d
  • 11,093

5 Answers5

232

Use split environment provided by amsmath package.

\begin{equation}
\begin{split}
F = \{F_{x} \in  F_{c} &: (|S| > |C|) \\
 &\quad \cap (\text{minPixels}  < |S| < \text{maxPixels}) \\
 &\quad \cap (|S_{\text{conected}}| > |S| - \epsilon) \}
\end{split}
\end{equation}
David Carlisle
  • 757,742
Leo Liu
  • 77,365
  • 1
    And it would look even nicer with a \mathrm{minPixels} and \mathrm{maxPixels} and \mathrm{connected}. – Bruno Le Floch Jan 14 '11 at 12:12
  • 1
    @Bruno: I agree. I edited the answer to use \text. – Leo Liu Jan 14 '11 at 15:44
  • 10
    Be aware that \text inherits formatting from the surrounding text (which might be italic in a theorem environment). – Caramdir Jan 14 '11 at 16:58
  • 9
    When using \right( and \left) or similar, one should be careful. The \left. and \right. should be used in order to avoid splitting of brackets pairs. For example a line should have the form \left( \ldots \right. \\ when it involves this kind of brackets. – Dror Jan 09 '12 at 11:15
  • 2
    I get an error when using \left{ and \right} instead of { and }. – AlwaysLearning Apr 21 '17 at 13:00
  • 1
    Can split be used with displaymath (that is between $$ $$) instead of using it with equation? I tried and it always gives me an error of the form missing } inserted, even if I don't write anything between begin and end, that is even just $$ \begin{split} \end{split} $$ does not work. – GeekInDisguise May 14 '19 at 18:53
  • 5
    Why is the syntax for this so unnecessarily complicated? – Chiel Jul 29 '20 at 11:13
59

The aligned environment from amsmath is also a good option:

\begin{equation}
\begin{aligned}
F ={} & \{F_{x} \in  F_{c} : (|S| > |C|) \\
      & \cap (\mathrm{minPixels}  < |S| < \mathrm{maxPixels}) \\
      & \cap (|S_{\mathrm{conected}}| > |S| - \epsilon)\}
\end{aligned}
\end{equation}

enter image description here

AboAmmar
  • 46,352
  • 4
  • 58
  • 127
  • 6
    What does the empty {} do? – Tyler Crompton Jul 11 '16 at 01:23
  • 26
    @TylerCrompton - The empty {} works as a math atom to keep the correct spacing around the = symbol, because = is a binary operator just like the + and the - symbols. When you type $-5$ and $x-5$, the first - is a unary operator and is close to the 5, but the second - is a binary operator with larger and equal distances from both x and 5--the same logic holds here. – AboAmmar Jul 12 '16 at 12:54
43

For simple multi-line equations without alignment, use the multline environment:

\begin{multline}
F = \{F_{x} \in  F_{c} : (|S| > |C|) \cap 
(minPixels  < |S| < maxPixels) \\ \cap 
(|S_{conected}| > |S| - \epsilon)
  \}
\end{multline}
Philipp
  • 17,641
19

The mathtools package provides the multlined environment.

\begin{equation}
\begin{multlined}
F = \{F_{x} \in  F_{c} : (|S| > |C|) \\
\shoveleft[1cm]{\cap (\mathrm{minPixels}  < |S| < \mathrm{maxPixels})} \\
\cap (|S_{\mathrm{connected}}| > |S| - \epsilon) \}
\end{multlined}
\end{equation}
David Carlisle
  • 757,742
  • 1
    I checked the latest version of the mathtools package (1.17) and it has no such environment. Perhaps it's been removed since you posted your answer. – Psychonaut Nov 07 '15 at 20:39
  • 9
    @Psychonaut It does indeed have that environment, and has had that all along. Just make sure you are typing multlined (mult without i, i.e. not multilined). – sodd Mar 22 '16 at 13:43
-6
\begin{eqnarray}
  F = \{F_{x} \in  F_{c} : (|S| > |C|) \cap \nonumber \\
  (minPixels  < |S| < maxPixels) \cap \nonumber \\
  (|S_{conected}| > |S| - \epsilon)
  \\}
\end{eqnarray}
Moriambar
  • 11,466
user26789
  • 5
  • 2
  • 16
    Don't use {eqnarray}: eqnarray vs align – cgnieder Mar 03 '13 at 12:50
  • 3
    Isn't using eqnarray a bit pointless if no alignment ponts are employed? (The fact eqnarray is badly deprecated is another strike against it.) – Mico Nov 18 '14 at 07:37
  • @Mico A point would be that it is the only way the LaTeX kernel provides; the other display math environments do not support several equation lines. But, of course, a package like amsmath is the preferred way. – Heiko Oberdiek Jul 15 '17 at 13:11