[Tex/LaTex] Aligning aligned equations

alignamsmath

I have a list of equations and some of which have multiple steps which I have managed to align in their individual environments. But I would like each set of equations to also align by "=", while the comments to the right of the equations also stay aligned with eachother.

\documentclass[11pt]{article}
\usepackage{amsmath}    
\usepackage[makeroom]{cancel}
\begin{document}

\begin{align*} \tag{a}
Y = f(x_0) + \epsilon_0
    && \text{By assumptions}
\end{align*}
\begin{align*} \tag{c}
E\big[Y\big] & = E\big[f(x_0)+\epsilon_0\big]
    && \text{By (a)}
\\& = E\big[f(x_0)\big] + \cancel{E\big[\epsilon_0\big]}
    && \text{By Linearity}
\\&= E\big[f(x_0)\big]
    && \text{By Expectation of $\epsilon$}
\end{align*}
\begin{align*} \tag{e.i}
&E\big[f(x_0)] = f(x_0)
    && \text{As $x_0$ is fixed and deterministic}
\\&\text{$f(x_0)$ is constant.} \tag{e.ii}
\\&\text{$f(x_0)$ and $\hat{f}(x_0)$ are independent.} \tag{e.iii}
\end{align*}

\end{document}

I am still learning LateX so I'm sorry if this is obvious. I would really appreciate any help and don't be afraid to explain minor steps as this really helps my understanding! Thank you in advance for your time and help.

Best Answer

In order to maintain alignment throughout each equation set, considering using the same align structure:

enter image description here

\documentclass{article}

\usepackage{amsmath}
\usepackage[makeroom]{cancel}

\begin{document}

\begin{align}
  Y &= f(x_0) + \epsilon_0
      && \text{Assumption} \tag{a}\label{eq:a} \\
  E\bigl[ Y \bigr] &= E\bigl[ f(x_0) + \epsilon_0 \bigr]
      && \text{by \eqref{eq:a}} \tag{c} \\
    &= E\bigl[ f(x_0) \bigr] + \cancel{E\bigl[ \epsilon_0 \bigr]}
      && \text{by linearity} \notag \\
    &= E\bigl[ f(x_0) \bigr]
      && \text{by expectation of $\epsilon$} \notag \\
  E\bigl[ f(x_0) \bigr] &= f(x_0)
      && \text{$x_0$ is fixed \& deterministic} \tag{e.i} \\
  \makebox[0pt][l]{$f(x_0)$ is constant.}
    \phantom{E\bigl[ f(x_0) \bigr]} \tag{e.ii} \\
  \makebox[0pt][l]{$f(x_0)$ and $\hat{f}(x_0)$ are independent.}
    \phantom{E\bigl[ f(x_o) \bigr]} \tag{e.iii}
\end{align}

\end{document}

Setting the last two lines in zero-width boxes provides a little extra room since they don't have descriptions on the right.