4

I would like to display braces under and over the text to have such display: What I want

However, when I use \underbrace and \overbrace, I get this result (MWE under): What I have

\documentclass[12pt,letterpaper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}

\begin{document}
\begin{equation}
 \underbrace{AB}_{AB = ax^2 + bx +c}C + D\overbrace{E}^{E = d x^3 + ex^2 + fx + g}FG = HI\underbrace{J}_{J = \ln{2x}}K
\end{equation}
\end{document}

With these two functions, when the over/under formula is longer than the element of the main formula, some space is added in the main formula, which I don't want.

The second thing that would be nice would be to vertically centre the brace on the first character of the secondary formula (so for instance the tip of the brace would be centred with the E of E = d x^3 + ex^2 + fx + g, as can be seen in the first figure).

(If you have any idea to enhance the title, don't hesitate to comment and/or edit my question)

3
  • 1
    As you are using mathtools, you can put the text in a \mathrlap. What do you mean exactly by "vertically centre the brace on the first character of the secondary formula"?
    – campa
    Oct 24, 2016 at 13:57
  • Never mind, I think I understand: you mean that the tip of the brace should be centred with, respectively, AB, E, and J, right?
    – campa
    Oct 24, 2016 at 14:04
  • Yes, the tip of the brace should ideally be centred with what is before the equal sign of the sub formula. This is however secondary, the most important for me would be not to have these spaces inside the main formula.
    – Togh
    Oct 24, 2016 at 14:08

1 Answer 1

4

Overbrace and underbrace have a minimum width that would make the display quite bad anyway; squeezing them like in the picture is even worse.

I suggest arrows pointing to a single letter, the brace for multiple letters. Using \mathrlap and \mathclap provides the other trick.

\documentclass[12pt,letterpaper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}

\begin{document}
\begin{equation}
\underbrace{AB}_{%
AB\mathrlap{{} = ax^2 + bx +c}
}
C + D
\overset{
  \substack{E\mathrlap{{} = d x^3 + ex^2 + fx + g}\\\downarrow}
}{E}
FG = HI
\underset{\substack{\uparrow\\\mathclap{J = \ln 2x}}}{J}
K
\end{equation}
\end{document}

enter image description here

6
  • \mathrlap does all for the AB case. That's really the command I was missing. In deed, the brace also have a minimal size and it may not be a good idea to try going under (ie use single character), but the arrows are a good workaround.
    – Togh
    Oct 24, 2016 at 15:10
  • @Togh Possibly the arrow also in the AB case would be good, as the letters are repeated below anyway. By the way, \ln 2x doesn't need braces; neither \sin x does and so on.
    – egreg
    Oct 24, 2016 at 15:15
  • I should have added it to the MWE, but I also have several layer of under/overbrace. The display remains nice with the arrows, but with the brace, the main formula of the brace is always in normal script size. Display can be enhanced thanks to \scriptstyle: \overbrace{level1}^{ level1 \mathrlap{= ax + \overbrace{\scriptstyle level2}^{ level2 \mathrlap{= something}}}}
    – Togh
    Oct 24, 2016 at 15:16
  • right, or at the opposite, remove the repetition. I think the way you answered the example is good because it allows to chose the way to display. \ln x do not need the brace, but putting some gives brace highlighting in the editor, which makes easier to find the beginning and the end with longer formula without outputting anything in the pdf.
    – Togh
    Oct 24, 2016 at 15:22
  • \underbracket looks better than \underbrace for short items, in my opinion.
    – Bernard
    Oct 24, 2016 at 19:43

You must log in to answer this question.

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