4

Based on the suggestion here How to add an underbrace and overbrace to a term in a equation or here What causes the problem when compiling a displayed equation with \overbrace and \underbrace? for instance, is it possible we have a "small" and the same size the symbols for underbrace and overbrace together?

I was trying to use the code below. Thank you.

\documentclass{article}
\usepackage{amsmath}
\usepackage[x11names, table]{xcolor}

\begin{document}

\[
\begingroup
\color{red}\underbrace{\overbrace{\color{black}=}^{\mathrm{over over over over over}}}_{\mathrm{under}}
\endgroup
\]
\end{document}

enter image description here

2
  • 2
    What is the full code that you use, please?
    – Sebastiano
    Commented Jun 15, 2019 at 22:44
  • 1
    @Sebastiano, I put a MWE above. Thanks
    – Moura
    Commented Jun 16, 2019 at 13:50

1 Answer 1

6

The use of \mathclap (mathtools package) allows the horizontal width of the content to be ignored.

In the 2nd example, arising from an OP comment, I use stackengine to reverse the sense of the braces. There, I also use \renewcommand\useanchorwidth{T} to ignore the width of the over/under text relative to the equation.

\documentclass{article}
\usepackage{mathtools,stackengine}
\usepackage[x11names, table]{xcolor}
\stackMath
\begin{document}

\[
\begingroup
\color{red}
\underbrace{\overbrace{\color{black}=}^{\mathclap{%
\mathrm{over over over over over}}}}_{\mathrm{under}}
\endgroup
\]
\[
x
\mathrel{
\renewcommand\useanchorwidth{T}
\stackunder{\stackon{=}{\color{red}\underbrace{\scriptscriptstyle\mathrm{
  over over over over over}}}}{\color{red}\overbrace{\scriptscriptstyle
  \mathrm{under}}}
}
y
\]
\end{document}

enter image description here

4
  • just by the challenge, is it possible to invert the position symbols?
    – Moura
    Commented Jun 16, 2019 at 15:35
  • 1
    @Moura Do you mean for the braces to embrace the word, rather than the equal sign? Commented Jun 16, 2019 at 17:53
  • Your code is perfect. But if we'll use, for example in the code below, the braces get space of integer symbol. [ \int 2x\sqrt{x^2+1}\ dx \mathrel{ \renewcommand\useanchorwidth{T} \stackunder{\stackon{=}{\color{red}\underbrace{\text{$u=x^2+1$}}}}{\color{red}\overbrace{ \text{$du=2xdx$}}} } \int \sqrt{u}\ du]
    – Moura
    Commented Jun 17, 2019 at 14:11
  • 1
    @Moura Both \stackunder and \stackon take an optional argument that, in this case, denotes the separation gap between stacked elements. So change \stackunder to \stackunder[8pt] and likewise for \stackon. Commented Jun 17, 2019 at 15:02

You must log in to answer this question.

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