1

Sums and products are usually centred vertically. However, I find the following looks a bit silly, with the big vertical space above the sum expression:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
    \max_{y\in Y} \left\{ \sum_{\substack{x\in X\colon \\ f(x) = y}} g(x,y) \right\}
\]
\end{document}

enter image description here

Is there a reasonable way to resolve this, or should I just live with the weird extra space? (I suppose this is a question about the proper way to typeset this sort of thing, as well as a technical question about LaTeX.)

2
  • I need exactly a solution to this problem without getting rid of the \left\{ bracket. Is there a way to vertically center the whole term (including the substack content)?
    – johk95
    May 17, 2023 at 11:29
  • @johk95 it might be worth asking a separate question. (This particular stack exchange is pretty lenient about duplicates in my experience - as long as you include the specifics of your case and make it clear that you're asking about vertically centring the whole term it should be considered a different question)
    – N. Virgo
    May 17, 2023 at 11:43

1 Answer 1

5

I suggest you replace the auto-sizing instructions \left and \right with \Bigl and \Bigr, respectively. Better yet, consider not using curly braces for the expression at hand. "Snugging up" the elements in the math list via \smashoperator directive -- see the third term below -- may also be a good idea.

A separate issue: Using \colon in a \substack would appear to cause some unfortunate spacing issues -- see the first two terms below. Using {:} instead of \colon -- see the third term below -- gets around the spacing issue.

enter image description here

\documentclass{article}
\usepackage{mathtools} % for \smashoperator macro
\begin{document}

\begin{align*}
  &\max_{y\in Y} 
  \left\{ 
     \sum_{\substack{x\in X\colon \\ f(x) = y}} g(x,y) 
  \right\}  \\[2\jot]
  &\max_{y\in Y} 
  \Bigl\{ 
     \sum_{\substack{x\in X\colon \\ f(x) = y}} g(x,y) 
  \Bigr\}  \\[\jot]
  &\max_{y\in Y} 
     \smashoperator{\sum_{\substack{x\in X{:} \\ f(x) = y}}} g(x,y) 
\end{align*}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .