# Distance between plus/minus sign and summation symbol

I am trying to write this code. It is compiled without an error, but I want to reduce the distance between plus/minus sign and \sum sign. How can I do that? Can anyone help me?

\begin{gather}
\begin{split}
&-\sum_{\forall l\in\phi^L\mid SB(l)=n} P_l^k
+\sum_{\forall l\in\phi^L\mid RB(l)=n} P_l^k
+\sum_{\forall g\in\phi^{G-n}} P_{ng}^k +R_n^k\\
=&\bar{P}_{nd}
+\hat P_{nd}\cdot u_n^{+k}
-\hat P_{nd}\cdot u_n^{-k}~~
\forall n\in\phi^N,\forall k\in\phi^{iteration}\\
\end{split}
\end{gather}

• Welcome to TeX.SX! A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). Oct 11 '14 at 5:17
• The problem here is what is under the \sum. You can use \mathclap for the first one, but using \mathclap (from the mathtools package) for the second \sum results in the two subscripts overlapping. Perhaps using multiple lines for the subscripts -- Something like Mathtools: using substack to align limits. Oct 11 '14 at 6:26
• I don't think you need the \forall symbols in the terms below the summation symbols.
– Mico
Oct 11 '14 at 7:14
• Thanks. But my Latex did not recognize mathtools package Oct 11 '14 at 10:02
• @mostafa: Which distribution do you have? Oct 11 '14 at 12:10

Here is a way to do things. You should  have mathtools installed; it's an extension of amsmath that is quite useful for fine-tuning equations layout. I use mathclap{ … }, but you can replace it with the much more verbose \makebox[0pt]{$…$}. I also define a \widebar command (taken in the mathx font, from mathabx (which I do not load, as it redefines most mathematical symbols), and redefine \widehat, which looks better with capital letters than \hat. Finally, I replace the split environment with the multi-alignment points environment alignedat.

 \documentclass[a4paper, 11pt]{book}
\usepackage[utf8]{inputenc}
\usepackage{geometry}

\usepackage{mathtools}
\DeclareFontFamily{U}{mathx}{\hyphenchar\font45}
\DeclareFontShape{U}{mathx}{m}{n}{ <-> mathx10}{}
\DeclareSymbolFont{mathx}{U}{mathx}{m}{n}
\DeclareFontSubstitution{U}{mathx}{m}{n}
\DeclareMathAccent{\widebar}{0}{mathx}{"73}
\DeclareMathAccent{\widehat}{0}{mathx}{"70}

\begin{document}

\begin{alignedat}{2} \MoveEqLeft[8]\enspace ∑_{\substack{l ∈ ϕ^L\\ \mathclap{SB(l)=n}}} P_l^k +∑_{\substack{ l ∈ ϕ^L\\\mathclap{RB(l)=n}}} P_l^k +∑_{\mathclap{g ∈ ϕ^{G-n}}} P_{ng}^k +R_n^k\\%[-1.5ex] & = \widebar{P}_{nd} +\widehat P_{nd} · u_n^{+k} -\widehat P_{nd} · u_n^{-k} &\hspace{3em} & ∀ n ∈ ϕ^N,∀ k ∈ ϕ^{\text{iteration}} \end{alignedat}

\end{document}


I suggest you do the following:

• Load the mathtools package (this package is a superset of the well-known amsmath package

• Delete all \forall macros

• Replace the \mid in the first two subscripts with s.t. ("such that") and use the \substack macro to introduce a line break in the first two subscript expression

• Use the macro \smashoperator to let the subscript material protrude to the left and right of the summation symbols without increasing a lot of extra white space -- this addresses the request you posted in your query

• Place the explanatory terms \forall n\in\phi^N,\forall k\in\phi^{iteration} on a line below the displayed math part

• write \textit{SB}, \textit{RB}, and \textrm{iteration} to recognize that the groups of letters involved don't represents products of single-letter variables

• Optional: since the letter "l" ("ell", not the numeral 1) occurs frequently, I'd use \ell rather than just l to write it out.

With these adjustments in place, it's possible to have all the math material take up a single that can be typeset using a "plain" equation environment.

\documentclass{article}
\usepackage{mathtools}
\newcommand\st{\textrm{ s.t.}}
\begin{document}
$$-\smashoperator{\sum_{\substack{\ell\in\phi^\ell\st \\ \textit{SB}(\ell)=n}}} P_\ell^k +\smashoperator{\sum_{\substack{\ell\in\phi^\ell\st\\ \textit{RB}(\ell)=n}}} P_\ell^k +\smashoperator{\sum_{ g\in\phi^{G-n}}} P_{ng}^k +R_n^k\\ =\bar{P}_{nd} +\widehat P_{nd}\cdot u_n^{+k} -\widehat P_{nd}\cdot u_n^{-k}$$
for all $n\in\phi^N$ and $k\in\phi^{\textup{iteration}}$.
\end{document}

• In my project there is letter like n,d,g and k which occurs currently. What can i use for these letters like \ell instead of l? Oct 13 '14 at 20:14
• @mostafa - I'm afraid I don't fully understand your question. I had suggested using \ell instead of l to avoid potential confusion over whether the symbol might mean 1 ("one"). To the best of my knowledge, there's no risk of confusing the letters n, d, g, and k with any other symbols, right?
– Mico
Oct 13 '14 at 20:29
• @Mico- You are right. I though that there is alternative format for typing these letters n,d,g and k. like \ell for l or \kappa for k. Oct 13 '14 at 20:33