# How do put \overbrace across an (aligned) equals sign?

I want to have several equations aligned by their equals signs. At the same time, I want to put an overbrace (or bracket) over the left- and right-hand sides of the first equal sign to write a reference to some other equations (this is to explain where this equality comes from). But I get an error if I do both at the same time.

This works but it's not aligned:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{flalign}
\overbrace{ f = \sum_{i\in I} a_i  }^{\text{ my notes }} \\
g &= blabla \\
h &= blabla
\end{flalign}
\end{document}


I would like something like:

  \overbrace{ f &= \sum_{i\in I} a_i  }^{\text{ my notes }} \\


but the "&" produces an error. Is there a way to achieve what I want?

Not quite elegant but works

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{flalign}
\rlap{$\displaystyle\overbrace{\phantom{f = \sum_{i\in I} a_i}}^{\text{ my notes }}$}
f &= \sum_{i\in I} a_i  \\
g &= blabla \\
h &= blabla
\end{flalign}
\end{document} Basically you put the expression with the \overbrace in a box and print it first. Using \rlap the expression is printed without taking any horizontal place. Then you print the expression, this time with the alignment &.

The same result can be obtained with \mathrlap from the mathtools package

\documentclass{article}
\begin{document}
\begin{flalign}
\mathrlap{\overbrace{\phantom{f = \sum_{i\in I} a_i}}^{\text{ my notes }}}
f &= \sum_{i\in I} a_i  \\
g &= blabla \\
h &= blabla
\end{flalign}
\end{document}

• Thanks a lot! The second one worked best for me (I mean, both work, but I must have made some mistake trying the first one since the real equations I'm using are long and complicated) Nov 16, 2019 at 17:33

After 20 minutes I have created this MWE, more ugly ( :-) ) than the answer of @campa ...but also it works. \documentclass[a4paper,12pt]{article}
\usepackage{mathtools}

\begin{document}
$\begin{matrix} \mathclap{\overbrace{f = \displaystyle \sum_{i\in I} a_i }^{\text{my notes}}} \\[2ex] g= \phantom\sum_{i\in I} a_i} \hspace{-3.5\tabcolsep}\text{abc} \\ h=\phantom\sum_{i\in I} a_i} \hspace{-3.5\tabcolsep}\text{abc} \end{matrix}$
\end{document}