Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have the following equation, where there is a lot of stuff under the sum symbol:

\begin{equation}
d(\vec{x},\vec{y})=
  \sum_{Z_{xy}\in\vec{Z}_{xy},\forall x\in\vec{x},\forall y\in\vec{y}} 
    f(Z_{xy})
\end{equation}

In the resulting document, I find it kind of hard to read. Is there a way to write the equation to make the result more readable, e.g. putting the stuff under the sum symbol on different lines?

share|improve this question
    
Why write under Sum, when mathematical correct is write to right. \begin{equation} d(\vec{x},\vec{y})= \sum_{Z_{xy}\in\vec{Z}_{xy}} f(Z_{xy}),\forall x\in\vec{x},\forall y\in\vec{y} \end{equation} –  MiMo Jun 10 '12 at 10:34
    
I agree with you but without the correct spacing, it is as bad as OP's. To be super-picky about it, forall is not the same as over all. With forall the author is relying on the reader's understanding for bad notation. –  percusse Jun 10 '12 at 13:18
2  
This is mathematically incorrect (if the notation has not introduced formally). But the \forall is definitely misused. –  egreg Jun 10 '12 at 13:33

2 Answers 2

up vote 46 down vote accepted

You can use the \substack command from the \amsmath package, like this:

\begin{equation}
  d(\vec{x},\vec{y}) =
  \sum_{\substack{Z_{xy}\in\vec{Z}_{xy}\\
                  \forall x\in\vec{x}\\
                  \forall y\in\vec{y}}}
        f(Z_{xy}) 
\end{equation}

However, the result still doesn’t look good, because of the extra spacing around the sum symbol:

Image showing the result of the ‘\substack’ command

To fix this, you can use the \mathclap command from the mathtools package, like this:

\begin{equation}
 d(\vec{x},\vec{y}) =
    \sum_{\mathclap{\substack{Z_{xy}\in\vec{Z}_{xy}\\
                   \forall x\in\vec{x}\\
                   \forall y\in\vec{y}}}} f(Z_{xy}) 
\end{equation}

Image showing the result of the ‘\mathclap’ and ‘\substack’ commands

But perhaps you might be happy using only \mathclap, and not \substack. The result looks good as long as the subscript is not too wide.

\begin{equation}
  d(\vec{x},\vec{y}) =
    \sum_{\mathclap{{Z_{xy}\in\vec{Z}_{xy},
          \forall x\in\vec{x},
          \forall y\in\vec{y}}}} f(Z_{xy})
\end{equation}

Image showing the result of the ‘\mathclap’ command

The mathtools package also have several other useful commands for typesetting mathematics, including more commands for improving the display of subscripts and superscripts. I very much recommend taking a look at its documentation.

share|improve this answer
5  
The \forall symbols should be omitted. –  egreg Jun 10 '12 at 13:34
3  
@egreg: Maybe one should just write three sums in total, the first two over x\in\vec{x} and y\in\vec{y}? –  Hendrik Vogt Jun 10 '12 at 13:51
1  
@HendrikVogt I'd use a two line \substack: \sum_{\substack{Z_{xy}\in\vec{Z}_{xy}\\x\in\vec{x},y\in\vec{y}}} –  egreg Jun 10 '12 at 13:56

Try the \substack command from the amsmath package, details of which are found here

share|improve this answer

Your Answer

 
discard

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.