Spacing between superscript and left parenthesis

I'm wondering why Latex adds an extra space between a superscript and the left parenthesis as in this case

\documentclass{article}
\usepackage{amsmath}
\let\originalleft\left
\let\originalright\right
\renewcommand{\left}{\mathopen{}\mathclose\bgroup\originalleft}
\renewcommand{\right}{\aftergroup\egroup\originalright}
\begin{document}
$\mathscr{P}^{N}\left(\mathscr{K}\right)$
\end{document}


The formula is showed with an unwanted space between the superscript N and the left parenthesis. I've tried the solution drafted in Spacing around \left and \right , however it doesn't work in this case. Any idea?

• Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – Adam Liter Jul 23 '14 at 6:02
• Don't use \left( and \right) unless it's really necessary. In this case, it's not, so just use \mathscr{P}^N(\mathscr{K}). – Werner Jul 23 '14 at 6:04
• @Werner, same happens without \left command... – guillermo Jul 23 '14 at 6:21
• The definition of \left\right looks very brave to me, many constructs will expect these not to expand. – David Carlisle Jul 23 '14 at 8:28
• Instead of that redefinition you might try the mleftright package; however, I'd simply prefer using \left and \right only when really necessary. For example, in $\mathscr{P}^{N}\left(\mathscr{K}\right)$ they are unnecessary. – egreg Jul 23 '14 at 8:48

As has already been noted in some of the comments, don't use \left and \right indiscrimately.

• If you do not want the extra spacing around the automatically sized parentheses but, for some reason, want automatically sized parentheses, load the mleftright package and use \mleft and \mright. (A direct redefinition of \left and \right of the type you're envisioning can lead to very odd results...)

• For the example at hand, automatic sizing isn't required to begin with. Observe that the size of the parentheses produced by \left(, \mleft(, and ( are all the same. Why clutter up the code unnecessarily?

\documentclass{article}
\usepackage{mathrsfs}   % for \mathscr macro
\usepackage{mleftright} % for \mleft and \mright macros
\begin{document}
\obeylines % just for this example
$\mathscr{P}^{N}\left(\mathscr{K}\right)$
$\mathscr{P}^{N}\mleft(\mathscr{K}\mright)$
$\mathscr{P}^{N}(\mathscr{K})$

\medskip
$\mathcal{P}^{N}\left(\mathcal{K}\right)$
$\mathcal{P}^{N}\mleft(\mathcal{K}\mright)$
$\mathcal{P}^{N}(\mathcal{K})$
\end{document}


This has nothing to do with parentheses following the superscripted symbol:

\documentclass{article}
\usepackage{amsmath}

\let\originalleft\left
\let\originalright\right
\renewcommand{\left}{\mathopen{}\mathclose\bgroup\originalleft}
\renewcommand{\right}{\aftergroup\egroup\originalright}

\begin{document}

$P^{N}\!\originalleft(K\originalright)$

$P^{N}\left(K\right)$

$P^{N}(K)$

$P^{N}K$

\end{document}


The \! in the first case is for removing the thin space normally inserted by \left. As you can clearly see, the spacing is exactly the same in all four cases. It depends on the \scriptspace feature: after a subscripted or superscripted symbol, TeX adds horizontal space in the amount of \scriptspace, default 0.5pt.

If you also consider that math letters are slanted and the left parenthesis has a “hole” in the left upper corner, the space appears to be bigger than it really is. But there are very good reasons for this.

You can have a fairer comparison by using upright characters and, for the superscript, something that has no sidebearings:

\documentclass{article}

\newcommand{\thinbar}{{\vphantom{|}\vrule width .2pt}}

\begin{document}

$\mathrm{I}^{\thinbar}\thinbar\mathrm{I}$ $\mathrm{I}^{\mathrm{I}}\mathrm{I}$

\setlength{\scriptspace}{0pt}

$\mathrm{I}^{\thinbar}\thinbar\mathrm{I}$ $\mathrm{I}^{\mathrm{I}}\mathrm{I}$

\end{document}


In the left column you clearly see the effect of \scriptspace; in the right column you can compare the effect with “real” superscripts. The purpose of \scriptspace is exactly that of slightly detaching symbols for better reading.

Important note

I left your redefinition of \left and \right, but I can't recommend it in any way. There's already a package doing it much better, mleftright.

• @Mico It's not mine, I just left the OP's one (which I don't recommend, by the way). I added a final note. – egreg Nov 14 '15 at 15:53