5

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?

9

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}

enter image description here

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}
\usepackage{mathtools} % loads also amsmath
\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}
1
  • 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) – user2059990 Nov 16 '19 at 17:33
2

After 20 minutes I have created this MWE, more ugly ( :-) ) than the answer of @campa ...but also it works.

enter image description here

\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{\displaystyle \sum_{i\in I} a_i} \hspace{-3.5\tabcolsep}\text{abc}  \\
          h=\phantom{\displaystyle \sum_{i\in I} a_i} \hspace{-3.5\tabcolsep}\text{abc}  
      \end{matrix}
      \]
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.