1

How can I make an overbrace on powers without it being buggy. Example:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{amstext}
\usepackage[brazil]{babel}
\usepackage{natbib}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{subfigure}
\usepackage{latexsym}
\usepackage[normalem]{ulem}
\usepackage[all]{xy}
\usepackage{epsfig}
\usepackage{pgf}
\usepackage{yhmath}
\usepackage{mathdots}
\usepackage{MnSymbol}

\begin{document}
$$
\begin{array}{ccc}
    (x^{m+1})^n &=& \underbrace{x^{m+1} \cdots x^{m+1}}_{n} \\[.8cm]
    &=& x^{\overbrace{(m+1)+\cdots+(m+1)}^{n}} \\[.8cm]
    &=& x^{\overbrace{(m+\cdots+m)}^{n}+\overbrace{(1+\cdots+1)}^{n}}
\end{array}
$$
\end{document}

The image below ilustrate the code above.

Output for the code above

Anyone knows how to solve this issue?

Thanks in advance.

Edit: I've included all the packages used in my document as well as made it "ctrl+c ctrl+v"-able.

5
  • Please, make a complete example from \documentclass up to \end{document} that reproduces the issue.
    – egreg
    Jul 29 at 16:36
  • Ok, I've made the corrections, thanks. Jul 29 at 17:42
  • What PDF viewer are you using? Does the vertical alignment change when you zoom in/out? I'm of the opinion that this is browser/viewer based, not (La)TeX based. The two answers provided suggested that as well as the problem can't be replicated.
    – Werner
    Jul 29 at 17:48
  • Oh, the problem is certainly with \usepackage{MnSymbol} Don't use it.
    – egreg
    Jul 29 at 18:38
  • Werner, I'm using overleaf, it does not change with zooming. egreg, it was!!!! Thank you! Jul 30 at 18:23
5

I cannot reproduce your issue, but the commands \underbrace and \overbrace cannot really be used in subscripts or superscripts, because they force the material to be in display style.

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\newcommand{\ubrace}[2]{{\mathpalette\ubrace@{{#1}{#2}}}}
\newcommand{\ubrace@}[2]{\ubrace@@{#1}#2}
\newcommand{\ubrace@@}[3]{\underbrace{#1#2}_{#3}}
\newcommand{\obrace}[2]{{\mathpalette\obrace@{{#1}{#2}}}}
\newcommand{\obrace@}[2]{\obrace@@{#1}#2}
\newcommand{\obrace@@}[3]{\overbrace{#1#2}^{#3}}
\makeatother

\begin{document}

\[
\begin{aligned}
  (x^{m+1})^n
  &=\ubrace{x^{m+1} \cdots x^{m+1}}{n} \\
  &= x^{\obrace{(m+1)+\cdots+(m+1)}{n}} \\
  &= x^{\obrace{(m+\cdots+m)}{n}+\obrace{(1+\cdots+1)}{n}}
\end{aligned}
\]

\end{document}

enter image description here

4
  • Hello egreg. Can you explain a little your code? Why do two extra macros have to be used?
    – projetmbc
    Jul 29 at 17:23
  • 1
    @projetmbc I need to pass three arguments to \mathpalette, but it only accepts two: \mathpalette wants as arguments a two-argument macro and the material to be processed. The first argument to the two-argument macro is automatically supplied and is \displaystyle and so on. So I delegate the job to a three-argument macro. See tex.stackexchange.com/a/34412/4427
    – egreg
    Jul 29 at 17:27
  • I'll try this solution here and I'll give you the feedback. Jul 29 at 17:45
  • Unfortunately, it didn't work. I'll leave it like that because it is just a solutions file I'm making for myself. Thank you very much for the time spent trying to help me, the effort is greatly apreciated! Jul 29 at 17:49
3

I cannot reproduce your picture. Below is my picture generated from your example: enter image description here

5
  • To be fair, on close examination, I do see a discontinuity between the linear portion and the curved part of the brace also in your example (although consistent in all three cases). But that may just be dependent on the pdf-reader. Jul 29 at 16:46
  • 1
    But the output is very wrong, don't you agree?
    – egreg
    Jul 29 at 16:46
  • Thank you very much for the feedback! I don't know why it is so broken in my compilation. Jul 29 at 17:39
  • @MatthiasArras, Sharp eyes!! The discontinuity is probably caused by my pdf-reader. It disappeared when I further magnified the picture.
    – citsahcots
    Jul 29 at 21:14
  • @egreg, Indeed. Your answer is much better.
    – citsahcots
    Jul 29 at 21:14

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.