Sometimes I want to describe portions of an equation using \underbrace and \overbrace in such a way that the portions are not completely distinct, for example:

x = A + B + C + D + E
    \-------/   \---/

What is the best way to do this?


6 Answers 6


One can use commands \phantom and \lefteqn.

Simple example: \[\lefteqn{\overbrace{\phantom{1+2+3}}}1+\underbrace{2+3+4}\].

More complicated example:


Caveat: \lefteqn switches font to \displaystyle so one has to use something like \lefteqn{\textstyle... in inline formulas.

P.S. The recipe is taken from the excellent book by S.Lvovski (http://www.mccme.ru/free-books/llang/newllang.pdf, in Russian).

  • This does help, but as far as I can tell only in the case where you want the first brace to start at the beginning of the line and you only want two braces that overlap. Am I correct, or is there a way to generalize this more? Jul 27, 2010 at 13:41
  • 1
    @Michael No, why? Anything like $$0+ \lefteqn{\overbrace{\phantom{1+2+3}}}1+ \underbrace{2+3+\overbrace{x+y+z}+ \lefteqn{\overbrace{\phantom{4+5}}}4}+5$$ works just fine.
    – Grigory M
    Jul 27, 2010 at 16:31
  • The only caveat is that one should be careful when using it in inline math: \lefteqn switches font to \displaystyle so one has to use \lefteqn{\textstyle ...}.
    – Grigory M
    Jul 27, 2010 at 16:33
  • Thanks, Grigory! Could you please edit your answer to include an example such as this, and a short explanation of how to construct it? I think that would be really helpful here. Jul 27, 2010 at 16:44
  • @Michael I've updated the answer to include some useful info from comments. As for explanation of how to construct such things (it seems I can't make it short and easy to understand so) I hope that everything will be clear from examples.
    – Grigory M
    Jul 27, 2010 at 17:07

This may not be the best solution, due to the overhead, but this is quite simple using TikZ. You insert invisible nodes at the points where you want the under and over braces to anchor to and then draw the braces between them. In my preamble, I have:

\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}

(Obviously, the name can be shortened if this is to be used a lot. I'm not sure off the top of my head which of the decorations library is needed; the calc one is optional but extremely useful.) Then, I would typeset your example using:

x = \tikzmark{ubl} A + \tikzmark{obl} B + C \tikzmark{ubr} + \tikzmark{ubll} D \tikzmark{obr} + E \tikzmark{ubrr}

\begin{tikzpicture}[overlay, remember picture]
\draw[decoration={brace,amplitude=10},decorate,thick] ($(ubl)+(-0.25,-1)$) -- ($(ubr)+(-0.25,1.2)$);

Reversing the order of the nodes flips the brace, so if that's the wrong way up then simply swap them. The stuff with the dollars is from the calc tikz library. What the above does is specify an offset from the node, so that if you find the default position of the braces a little off (which it probably is), it is simple to adjust them.

I use this a lot in lectures: for adding strike-outs to things, for better-looking brackets on huge matrices, for all sorts of things where you want to add a little graphical decoration afterwards.

For more details, search for 'remember picture' in the TikZ manual, and browse the examples at http://texample.net.

  • Thanks Andrew, I hadn't actually seen tikz before so that's a neat introduction to something I probably want to look into more now. It is a little cumbersome though for this particular application, since you'd then also have to place the text next to the brace manually. Also, the braces seem quite a bit taller than the ones generated in math mode by \underbrace and just don't look quite 'right' -- although that's subjective, and possibly just because I'm already used to the other ones. Jul 27, 2010 at 16:57
  • You can change the amplitude and thickness to suit, though I don't know if it's possible to get them exactly the same as LaTeX would do. When you say "place the text next to the brace manually", do you mean that you want to be able to add text at the point of the brace? (I didn't spot that this was in the spec) If so, that's really easy. Would you like me to add that to my answer? Jul 27, 2010 at 17:52

Use the package oubraces. You should get

enter image description here


\[ x=\overunderbraces{&&\br{3}{}}%
{&\br{2}{}& &\br{2}{}}

Check out "LaTeX Mathmode" by Herbert Voß. The manual can be found on CTAN (PDF).

Skip down to section 63.2 "Overlapping braces". He also gives examples of other tricks you may want to pull using braces.


For future reference: this overlaps with How to have overlapping under-braces and over-braces both in the question above and in the answers below ;-)

(I would have posted this as a comment, but don't have enough reputation.)


There is also the underoverlap package. An example from that package:

\[ a + \UOLoverbrace{b +}[c + d]ˆx \UOLunderbrace{+ e}_y + f \]

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .