5

I'm writing an equation which contains a relatively long subscritps under a summation, which is just next to a bracket. The code is the following

$$\mu_j=\E(X_j)=\E\left(
    \sum_{i\in Pa(X_j)}\lambda_{ij}X_i+W_j\right)
   =\sum_{i\in Pa(X_j)}\lambda_{ij}\mu_i+v_j.$$

With the commands \left, \right the brackets are too big and also there is too much with space between the beginning of the expression and the end of the summation. I've tried to use commands as \mathclap, \mathrlap together with \Biggl and similar in order to have a better looking equation, but I hadn't any satisfactory result. The problem is also that with these commands the alignment of the whole equation seems to decrease. Have you got any suggestions?

egreg
  • 1,121,712
Manuele
  • 121

3 Answers3

8

If you swap the terms inside the brackets, the brackets are less of an obstacle:

enter image description here

\documentclass{article}
\usepackage{mathtools}% http://ctan.org/pkg/mathtools
\usepackage{amssymb}% http://ctan.org/pkg/amssymb
\newcommand{\E}{\mathbb{E}}% Requires amssymb
\begin{document}
\[
  \mu_j=\E(X_j)=\E\bigg(
        W_j+\,\,\sum_{\mathclap{i\in Pa(X_j)}}\lambda_{ij}X_i\bigg)
       =\,\,\sum_{\mathclap{i\in Pa(X_j)}}\lambda_{ij}\mu_i+v_j.
\]
\end{document}

Also see Why is \[ … \] preferable to $$?

Werner
  • 603,163
  • 2
    Please note that \bigg( and \biggl( are different: the former builds an ordinary math atom, the latter an opening atom, which is what you want here. Of course it should also be \biggr). – egreg May 20 '12 at 10:37
5

Instead of trying to stack every information under the summation symbol, you can put extra information separately. Actually I suggest to put only the index over which the summation is carried out, under the symbol. I have put three versions one below the other for comparison:

\documentclass{article}
\usepackage{amsmath,amssymb}
\newcommand{\E}{\mathbb{E}}% Requires amssymb

\begin{document}

\[\mu_j=\E(X_j)=\E\left(
    \sum_{i\in Pa(X_j)}\lambda_{ij}X_i+W_j\right)
   =\sum_{i\in Pa(X_j)}\lambda_{ij}\mu_i+v_j\]

   Leave only the index of summation and put  more details at the end:
\[\mu_j=\E(X_j)=\E\bigg(
    \sum_{i}\lambda_{ij}X_i+W_j\bigg)
   =\sum_{i}\lambda_{ij}\mu_i+v_j, \qquad \text{where }\ i\in \underline{{Pa}}(X_{j})\]
\end{document}

enter image description here

This will make the equation more readable IMHO.

  • I really like the last idea you propose. Thank you very much – Manuele May 20 '12 at 09:44
  • I don't like \forall in that context, maybe \text{where $i\in\mathit{Pa}(X_{j})$}. But I'd like to underline the \mathit{Pa} bit, which should be used for "multiletter identifiers" such as this one. – egreg May 20 '12 at 10:42
  • @egreg: Pl. see the edit. Is that what you were indicating? –  May 20 '12 at 13:24
  • Yes, but I wouldn't use underlining. – egreg May 20 '12 at 13:27
  • In your first code there's a spurious opening brace (you wrote \{ just before \hbox) that appears in the lower limit of the first sum. – Gonzalo Medina May 20 '12 at 17:11
  • @GonzaloMedina: Well, Actually I copied it (without any hesitation) from David's answer and put it for comparison. I removed it now. –  May 20 '12 at 22:46
  • Ah, OK. I will then remove my comments shortly. – Gonzalo Medina May 20 '12 at 22:47
4

Tricky to make it look good, perhaps

\documentclass{article}
\usepackage{amssymb}
\begin{document}
\[
\mu_j= E(X_j)=E\Bigl(\,\,\sum_{\hbox to 0pt{\hss$\scriptstyle i\in Pa(X_j)$\hss}}\lambda_{ij}X_i+W_j\Bigr)=
  \,\,\sum_{\hbox to 0pt{\hss$\scriptstyle i\in Pa(X_j)$\hss}}\lambda_{ij}\mu_i+v_j.
\]

\end{document}

enter image description here

Gonzalo Medina
  • 505,128
David Carlisle
  • 757,742