TransWikia.com

Separate long math text under sum symbol into different lines?

TeX - LaTeX Asked on March 30, 2021

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}invec{Z}_{xy},forall xinvec{x},forall yinvec{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?

3 Answers

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

begin{equation}
  d(vec{x},vec{y}) =
  sum_{substack{Z_{xy}invec{Z}_{xy}
                  forall xinvec{x}
                  forall yinvec{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}invec{Z}_{xy}
                              forall xinvec{x}
                               forall yinvec{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}invec{Z}_{xy},
          forall xinvec{x},
          forall yinvec{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.

Correct answer by Karl Ove Hufthammer on March 30, 2021

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

Answered by Ian Thompson on March 30, 2021

I think it can be done without substack as

sum_{a=b  b=c  c=a}

wich results in

enter image description here

Answered by VIVID on March 30, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP