6

I have a multiline subscript in multiline sum which I realize via an align:

\begin{align}
P(a|b) =  
\sum_{\substack{c, d, \\ e, f}}  \quad\quad 
      &P(a,b) \\
\cdot &P(b,c) \\
\cdot &P(c,d) \\
\cdot &P(d,e) \\
\cdot &P(e,f)
\end{align}

which renders as:

enter image description here

I would like to use the space between P(a,b) and P(b,c) so that the subscript doesn't force the net line to start any farther down than if there wasn't any subscript. I tried parbox instead of substack, but it didn't work.

7

I can think of two ways, either use a negative space between the first and second row, or ignore the space of the sum. I prefer the second alternative.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
P(a|b) =  
\sum_{\substack{c, d, \\ e, f}}  \quad\quad 
      &P(a,b) \\[-1.9em]
\cdot &P(b,c) \\
\cdot &P(c,d) \\
\cdot &P(d,e) \\
\cdot &P(e,f)
\end{align}

\begin{align}
P(a|b) =  
\smash[b]{\sum_{\substack{c, d, \\ e, f}}}  \quad\quad 
      &P(a,b) \\
\cdot &P(b,c) \\
\cdot &P(c,d) \\
\cdot &P(d,e) \\
\cdot &P(e,f)
\end{align}

\end{document}

enter image description here

|improve this answer|||||
  • \smash[b]{...} just removes the depth. I'd avoid the manual adjustment: the second way is the right one. – egreg Mar 31 '17 at 9:52
  • @egreg: Thanks, I have updated. I agree, the second is preferred. – StefanH Mar 31 '17 at 10:07
6

Assuming you don't want to number each row, you can use an aligned subblock:

Sample output

\documentclass{article}

\usepackage{amsmath}

\begin{document}
\begin{align}
  P(a|b) &=
  \sum_{\substack{c, d, \\ e, f}}
  \begin{aligned}[t]
    \quad &P(a,b) \\
    \cdot{} &P(b,c) \\
    \cdot{} &P(c,d) \\
    \cdot{} &P(d,e) \\
    \cdot{} &P(e,f)
  \end{aligned}\\
  &= x+y.
\end{align}
\end{document}

However, I would prefer to offset the following lines as follows:

Second sample

\documentclass{article}

\usepackage{amsmath}

\begin{document}
\begin{align}
  P(a|b) &=
  \sum_{\substack{c, d, \\ e, f}}
  \begin{aligned}[t]
    &P(a,b) \\
    &\quad \cdot P(b,c) \\
    &\quad \cdot P(c,d) \\
    &\quad \cdot P(d,e) \\
    &\quad \cdot P(e,f)
  \end{aligned}\\
  &= x+y.
\end{align}
\end{document}
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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