How to put a big bracket under different parts of a equation so that I could write e.g. a text specific to that part in the equation?

For example :

f =  x^3 +  2
    |___|  |__| 
      |     |
   text 1  text 2

Since the text used in \underbrace (or \overbrace) is typically set in a different font size to not distract further from the equation, it is preferable to use amsmath's \text macro.

enter image description here

% \usepackage{amsmath}
\usepackage{mathtools}% Loads amsmath
  f(x) = 
    \underbrace{(x + 2)^3}_\text{text 1} + 
      \mathrlap{\overbrace{\phantom{(c - 2d)}}^{\text{text 2}}}
      (c - 
      \mathrlap{\underbrace{\phantom{2d) + (3e}}_{\text{text 3}}}
      2d) +
      \overbrace{(3e - 4f)}^{\text{text 4}}
    \bigr) + 
    \overbrace{(x - 3)}^\text{text 5}

The difficult overlapping braces uses math overlaps from mathtools. It follows a process of setting the \over-/\underbrace text first with a \phantom base, after which the base (or part thereof) is re-set. However, if those aren't needed, using amsmath only would suffice for usage of \text.

There are a number of ways of achieving the overlapping output. Another method of overlapping braces is discussed in section 63.2 Overlapping braces of the mathmode document.

| improve this answer | |
  • 1
    Would you still use \text if you wanted to include math? e.g., instead of "text 1" I want to have something like $g(x)$. (Also, congrats on your 1000th answer. Awesome work!) – user6967 Feb 17 '12 at 6:12
  • @MikeWierzbicki: Thanks - 1000! No, if you use math, then you would not use \text, since math will automatically size to the appropriate font size. The switching of mode (from math to text) causes default settings to be invoked, setting text in \normalsize rather than \scriptsize. amsmath's \text chooses the appropriate text font size via \mathchoice. – Werner Feb 17 '12 at 6:28
  • 1
    Perhaps the single most useful answer on this entire forum – Carlos - the Mongoose - Danger Jul 20 '16 at 1:24
  • Good, answer, but how can I add equations since \text is used. – GoingMyWay Oct 5 '19 at 14:38
  • 1
    @Tropilio: You can use a tabular, or array, or substack. – Werner Jun 9 at 18:53

What you want is

f = \underbrace{x^3}_\textrm{text 1} + \underbrace{2}_\textrm{text 2}
| improve this answer | |
  • 1
    NB syntax for overbraces, \overbrace{x^2}^\text{over} – innisfree Sep 13 '17 at 7:57

You would find it out in the mathmode manual or symbols manual.

| improve this answer | |
  • 4
    Please provide hyperlinks for the manuals. Not everybody may know where to find them. (I've added them for you.) Also you should consider providing more information. The poster may not know what to look for. – user10274 Feb 17 '12 at 7:53
  • 4
    The link to mathmode manual gives me a 404. – Reb.Cabin Mar 21 '16 at 19:56

Your Answer

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