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.

  • Please, make a complete example from \documentclass up to \end{document} that reproduces the issue. – egreg Jul 29 '21 at 16:36
  • Ok, I've made the corrections, thanks. – Fractal Admirer Jul 29 '21 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 '21 at 17:48
  • Oh, the problem is certainly with \usepackage{MnSymbol} Don't use it. – egreg Jul 29 '21 at 18:38
  • Werner, I'm using overleaf, it does not change with zooming. egreg, it was!!!! Thank you! – Fractal Admirer Jul 30 '21 at 18:23

2 Answers2

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

egreg
  • 1,121,712
  • Hello egreg. Can you explain a little your code? Why do two extra macros have to be used? – projetmbc Jul 29 '21 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 https://tex.stackexchange.com/a/34412/4427 – egreg Jul 29 '21 at 17:27
  • I'll try this solution here and I'll give you the feedback. – Fractal Admirer Jul 29 '21 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! – Fractal Admirer Jul 29 '21 at 17:49
3

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

citsahcots
  • 7,992