# What is the command to add newline linebreak in \sum \prod? [duplicate]

I am sure this question or similar has been asked but I cannot find it by searching so adding it to make it more accessible: what is the command/environment to add newline linebreak in \sum \prod so the expression is on two rows instead of one line hard to read?

MWE

\documentclass{article}
\usepackage{amsmath,amsfonts}

\begin{document}

$$\sum^{N_{cut}}_{i=1,\newline e_1\in C_i,e_2\not\in C_i} \prod_{j\in C_i} p_j-\sum^{N_{cut}}_{i=1,e_2\in C_i,e_1\not\in C_i} \prod_{j\in C_i} p_j\geq 0$$

\end{document}

• Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
– user31729
Jul 19 '15 at 16:50
• By the way, don't use $$...$$ in LaTeX documents. See tex.stackexchange.com/q/503/3954 Jul 19 '15 at 16:53
• $\sum_{\substack{x<0\\ y>7}}^{8}$ Jul 19 '15 at 16:54

You shouldn't use $$…$$ for display equations: this is a plain tex syntax, and it can give inconsistent vertical spacing. Use $…$ instead.

The command you're looking for is \substack from amsmath. I replaced amsmath with mathtools, an extension of the latter. It has, among many features, commands for not taking into account the width of the indices in sums, products and the like: \mathclap and, more globally, \smashoperator. I show how to use both. Also, don't write \N_{cut}: the word ‘cut’ is considered by latex as the product of three variables, typed in italics and spaced accordingly. The \text command results in the correct typing.

\documentclass{article}
\usepackage{mathtools,amsfonts}

\begin{document}

$\smashoperator{\sum^{N_\text{cut}}_{\substack{i=1,\\ e_1\in C_i,\\e_2\notin C_i}}} \prod_{j\in C_i} p_j-\sum^{N_\text{cut}}_{\substack{i=1,\\\mathclap{e_2\in C_i,}\\\mathclap{e_1\notin C_i}}} \prod_{j\in C_i} p_j\geq 0$

\end{document}


    \documentclass{article}
\usepackage{amsmath,amsfonts}

\begin{document}

\begin{multline}
\sum^{N_{cut}}_{i=1,\newline e_1\in C_i,e_2\not\in C_i} \prod_{j\in C_i} p_j
\\
-\sum^{N_{cut}}_{i=1,e_2\in C_i,e_1\not\in C_i} \prod_{j\in C_i} p_j\geq 0
\end{multline}

\end{document}

• This doesn't answer the question. OP's asking for line breaks inside the subscripts (as in the question I linked in comments for duplicate) not for multiple line equations. Jul 19 '15 at 17:27
• That's not the way I read the question. It's ambiguous.
– JPi
Jul 19 '15 at 17:44

Bernard is correct about substack. I provide here MWE so easy to get things working also in the future when forgetting this again.

$$\sum^{N_{cut}}_ { \substack{ i=1 \\ e_1\in C_i,e_2\not\in C_i } } \prod_{j\in C_i}p_j - \sum^{N_{cut}}_ { \substack{ i=1 \\ e_2\in C_i,e_1\not\in C_i} } \prod_{j\in C_i}p_j \geq 0$$


This feature is offered by the amsmath package. If you run texdoc amsmath you will get a pdf with the manual. In the index you will find Section 7 "Integrals and Sums" and the first subsection is "Multiline subscripts". Following the instructions you get

$\sum^{N_{cut}}_{\substack{i=1,\\ e_1\in C_i,e_2\not\in C_i}} \prod_{j\in C_i} p_j-\sum^{N_{cut}}_{i=1,e_2\in C_i,e_1\not\in C_i} \prod_{j\in C_i} p_j\geq 0$


that is to say, you use \substack to indicate that you want a multiline subscript and \\ to indicate where to break the line in its argument.