TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to get stacked indices using subarray/substack using the following snippet, but I am not seeing stacking beneath the sum symbol. This is the type of output I am expecting, good output

but this is what I am getting:

bad output

Here is the code:

\usepackage{amsmath, amsfonts, amssymb}
          \frac{\sum_{\begin{subarray}{l}\forall x \\
          \mathcal{D}(x)=\mathcal{D}_i\end{subarray}} \sum_{\substack{\forall
              y\in\Omega(x) \\
   \mathcal{D}(y)=\mathcal{D}_j}} 1}
    {\sum_{\forall x }\mathcal{D}(x)}

What should I do to get proper stacking?

share|improve this question
So you are after output that resembles this? Issue \displaystyle in the numerator and denominator of \frac. – Werner Aug 25 '14 at 17:39
@werner, thanks. wish it's possible to accept a solution in a comment too :) – Jey Aug 25 '14 at 18:16
up vote 4 down vote accepted

You need to add the directive \displaystyle at the start of both the numerator and denominator. I would also add \, (thinspace) between the two main terms in the numerator.

enter image description here

\usepackage{amsmath, amsfonts, amssymb}
   \frac{\displaystyle\sum_{\begin{subarray}{l}\forall x \\
                             \mathcal{D}(x)=\mathcal{D}_i\end{subarray}}  \, 
      \sum_{\substack{\forall y\in\Omega(x) \\ \mathcal{D}(y)=\mathcal{D}_j}} 1}
   {\displaystyle\sum_{\forall x }\mathcal{D}(x)}

For more on this subject, you may want to consult the posting Fractions with large elements.

share|improve this answer
Or \limits, but perhaps in this case \displaystyle is better. – egreg Aug 25 '14 at 18:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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