跳到内容

Introduction

By convention, LaTeX uses the circumflex character (^) to typeset a superscript, such as $a^b$ which produces $a^b$. If you write $a^bcde$, only the first character, b, is superscript, as in $a^bcde$, because LaTeX does not assume you want to superscript the entire set of characters bcde. To typeset multiple items (tokens) as superscripts, you need to tell LaTeX by enclosing them in a group {...}, like this: $a^{bcde}$, which produces $a^{bcde}$.

Double superscript error

The double superscript error arises when LaTeX is asked to add a superscript to a piece of mathematics which already has a superscript attached to it. This error is usually resolved through the use of braces {...}, which, within math mode, generate a so-called subformula—a term used to describe a fragment of the mathematical expression you are trying to typeset.

For example, writing $a^b^c$ generates the following double superscript error:

A double superscript error showing on Overleaf

This particular error can be fixed in several ways through the use of braces {...}—the results vary according to where the braces are positioned:

  • $a^{b^c}$ typesets $a^{b^c}$
  • ${a^b}^c$ typesets ${a^b}^c$
  • $a^{bc}$ typesets $a^{bc}$

Double superscript error: special cases

Superscripts and accents

A question on tex.stackexchange contains a surprising example of the double subscript error whose underlying cause, and solution, also applies to double superscripts. The following example fails to compile, even though braces are used:

\documentclass{article}
\begin{document}
\({\vec a^b}^c\)
\end{document}

 Open this error-generating example in Overleaf

As with the double subscript error, one way to fix the problem is to add the accents package to your document preamble (as suggested here):

\documentclass{article}
\usepackage{accents}
\begin{document}
\({\vec a^b}^c\)
\end{document}

 Open this corrected example in Overleaf

Using primes with superscripts

Another common cause of the error is the use of primes with superscripts, which is particularly troublesome for tensor notation—as shown below:

\documentclass{article}
\begin{document}
\[T'_{\nu_{1}\nu_{2}\ldots\nu_{p}}^{\mu_{1}\mu_{2}\ldots\mu_{q}}\]
\end{document}

 Open this error-generating example in Overleaf

This example triggers the following error:

Double superscript error caused by primes in math mode

In math mode, LaTeX will interpret the primed symbol T' as T^{\prime}—i.e., it adds a superscript to the T. When LaTeX subsequently inputs the circumflex character, ^, as it reads ^{\mu_{1}\mu_{2}\ldots\mu_{q}}, it detects an attempt to add a second superscript to the T, and that triggers the error.

The correct way to write the above expression is demonstrated in the next example:

\documentclass{article}
\begin{document}
\[T_{\nu_{1}\nu_{2}\ldots\nu_{p}}^{\prime\mu_{1}\mu_{2}\ldots\mu_{q}}\]
\end{document}

 Open this corrected example in Overleaf

This example produces the following output (enlarged for clarity):

Example of typesetting superscripts and primes on Overleaf

More on superscripts

Further levels of superscripts can be typeset by writing LaTeX such as a^{b^{c^{d^e}}} which typesets $a^{b^{c^{d^e}}}$. All superscripts at or above the second level are typeset using the same font size (in points), whereas first-level superscripts use a slightly larger font (point size). To learn more about superscripts, visit Overleaf's help page dedicated to that topic.

Overleaf guides

LaTeX Basics

Mathematics

Figures and tables

References and Citations

Languages

Document structure

Formatting

Fonts

Presentations

Commands

Field specific

Class files

Advanced TeX/LaTeX