# Aligned block misaligned with leading extra white space

I often use aligned inside other math environments like equation, align, gather, but there's sometimes (always?) an extra white space in front of the aligned block, no matter where the aligned block is: at the very beginning of a line, or right after an equal sign.

Here's My Question, explanation comes after the figure:

What is the proper way of dealing with this extra white space? If I shouldn't use aligned to achieve such layout (shown below), what is the proper alternative?

There seems to be a split approach that works in certain cases, but not for me most of the time.

The extra white space seems to have exactly the same width as the negative space \! like shown below:

Please note the misaligned F_H( eta ).

The same aligned block appears twice, as Eq.(39) and Eq.(40). The first time (tagged with red) is the whole line being the aligned block, whereas Eq.(40) is the effect I want but I had to cheat a bit by inserting a single \! in front of aligned.

Here I want to align all the equations at the beginning, but in many other cases the desired alignment point is in the middle.

Now, this tiny extra white space is an issue because

1. I often use aligned block right around the & inside an align environment.
2. In the example shown above, I cannot start aligned around the equal sign at the integral but have to do the whole line as an aligned because this is the only way to use the optional [b] to allow the equation numbering appear at the right place (last line of the aligned block).

The posts I found here that address aligned issues are not helpful to me, since they are mostly about what I already know very well: the alternating right-left alignment and the additional n-1 & one should place in-between the n & align points as column divider.

I hope I have stated my question in a comprehensive way, and any input would be appreciated. Thank you.

Here's the code to generate the equations above:

\begin{align}
& F_{XH}(x, \eta) = F_p(x) \cdot p  + F_q(x) \cdot ( 1 - p ) \\
& F_X(x) = \sum_{\eta = -1}^{1} F_{XH}(x, \eta) = p F_p(x) + (1 - p) F_q(x)  \\
& \begin{aligned}[b]% plain version
F_H(\eta) = \Pr{ H = \eta } &= \int F_{XH}(x, \eta) \dd x \\
&= p  + ( 1 - p )
\end{aligned} \quad \text{\color{red}without \textbackslash !} \\
& \!\begin{aligned}[b]% with negative space
F_H(\eta) = \Pr{ H = \eta } &= \int F_{XH}(x, \eta) \dd x \\
&= p  + ( 1 - p )
\end{aligned} \quad \text{\color{blue}with \textbackslash !} \\
& F_{X \mid H}(x\, ;\, \eta_0) = \frac{ p F_p(x) }{ F_X(x) }
+ \frac{ (1-p) F_q(x) }{ F_X(x) }
\end{align}


With an up to date amsmath release you get

To get the output that you show you need to use the compatibility option [alignedleftspaceyes]

\documentclass{article}

\usepackage
%[alignedleftspaceyes]
{amsmath}
\usepackage{color}

\newcommand\dd{\mathrm{d}}

\begin{document}
\begin{align}
& F_{XH}(x, \eta) = F_p(x) \cdot p  + F_q(x) \cdot ( 1 - p ) \\
& F_X(x) = \sum_{\eta = -1}^{1} F_{XH}(x, \eta) = p F_p(x) + (1 - p) F_q(x)  \\
& \begin{aligned}[b]% plain version
F_H(\eta) = \Pr{ H = \eta } &= \int F_{XH}(x, \eta) \dd x \\
&= p  + ( 1 - p )
\end{aligned} \quad \text{\color{red}without \textbackslash !} \\
& \!\begin{aligned}[b]% with negative space
F_H(\eta) = \Pr{ H = \eta } &= \int F_{XH}(x, \eta) \dd x \\
&= p  + ( 1 - p )
\end{aligned} \quad \text{\color{blue}with \textbackslash !} \\
& F_{X \mid H}(x\, ;\, \eta_0) = \frac{ p F_p(x) }{ F_X(x) }
+ \frac{ (1-p) F_q(x) }{ F_X(x) }
\end{align}
\end{document}

• After using for some days the 11/05/2016 release, I noticed that in align and equation environment it works fine, but in gather or alignat or flalign there's now extra negative white space (\!). I wonder if I'm mistaken or there's something wrong with my TeXShop (even though full updated). – Lee David Chung Lin Feb 20 '17 at 4:19
• @LeeDavidChungLin sorry I do not know exactly what you mean. Old versions of aligned and gather had a spurious \, in their definition so needed \! as noted here, new versions should not need it, however this was a surprisingly delicate block of code to change so it is not impossible that a bug was introduced. If you think the new code is doing the wrong thing please open a new question with an example, and I'll see what I can do. – David Carlisle Feb 20 '17 at 7:42
• @LeeDavidChungLin I experimented with gather, alignat and flalign, but saw no negative space. – egreg Feb 20 '17 at 11:52
• @DavidCarlisle Thanks for the response. Actually I wasn't even sure if there is a new problem cuz it appeared inconsistent to me (sometimes there's the overcorrection of extra negative space, sometimes there isn't). It turns out to be the interaction between how any math environment align symbols from DeclareMathOperator or \newcommand*. I might post a new question, but this has become rather specific to personal habit now so I might not. – Lee David Chung Lin Feb 20 '17 at 15:36
• @egreg I appreciate it. Basically I needed some confirmation to nail down what's going on. – Lee David Chung Lin Feb 20 '17 at 15:37