Summation subscript under summation symbol (\limits not working)

equationssubscripts

I am trying to get the subscript in both summations in the following equation centered under the summation symbol:
summation_indices_not_centered

\displaystyle \Phi(H) = \min { \sum_{\substack{i \in S \\ j \notin S}} w_{ij}  \over {\sum_{\substack{i \in S}} \pi_i} }

I have reached the above syntax result, which compiles without error but doesn't output what I am looking for, by following the links below:

Sums in math mode: how to display index under the sigma sign?

Separate long math text under sum symbol into different lines?

\limits doesn't seem to work, i.e the expression:

\[ \displaystyle \Phi(H) = \min { \sum_{\limits{\substack{i \in S \\ j \notin S}}} w_{ij}  \over {\sum_{\limits{i \in S}} \pi_i} } \]

gives the following error message: Limit controls must follow a math operator

If possible, I would like this to work for both inline and displayed formulas

Best Answer

Put the \displaystyle in front of the \sums.

enter image description here

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\[
  \Phi(H) = \min \frac{\displaystyle\sum_{\substack{i \in S \\ j \notin S}} w_{ij}}
                      {\displaystyle\sum_{\substack{i \in S}} \pi_i}
\]
\end{document}

I recommend to put the sums into one line: enter image description here

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\[
  \Phi(H) = \min \bigg(\sum_{\substack{i \in S \\ j \notin S}} w_{ij} \Big/
                       \sum_{\substack{i \in S}} \pi_i\bigg)    
\]
\end{document}