> For the complete documentation index, see [llms.txt](https://overleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://overleaf-pro.ayaka.space/latex/latex-errors/05-double-superscript.md).

# Double superscript

## 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](/files/6pEvIEUhVfF69O7YdPJY)

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](https://tex.stackexchange.com/questions/253080/why-am-i-getting-a-double-subscript-error) whose underlying cause, and solution, also applies to double superscripts. The following example fails to compile, even though braces are used:

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

[Open this ***error-generating*** example in Overleaf](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=accents+package+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%5C%28%7B%5Cvec+a%5Eb%7D%5Ec%5C%29%0A%5Cend%7Bdocument%7D)

As with the [double subscript error](/latex/latex-errors/04-double-subscript.md), one way to fix the problem is to add the [`accents` package](https://ctan.org/pkg/accents?lang=en) to your document preamble (as suggested [here](https://tex.stackexchange.com/a/253094)):

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

[Open this ***corrected*** example in Overleaf](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=accents+package+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Baccents%7D%0A%5Cbegin%7Bdocument%7D%0A%5C%28%7B%5Cvec+a%5Eb%7D%5Ec%5C%29%0A%5Cend%7Bdocument%7D)

#### 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:

```latex
\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](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=accents+package+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%5C%5BT%27_%7B%5Cnu_%7B1%7D%5Cnu_%7B2%7D%5Cldots%5Cnu_%7Bp%7D%7D%5E%7B%5Cmu_%7B1%7D%5Cmu_%7B2%7D%5Cldots%5Cmu_%7Bq%7D%7D%5C%5D%0A%5Cend%7Bdocument%7D)

This example triggers the following error:

![Double superscript error caused by primes in math mode](/files/4bFNdNcCMPk6ahPuKFPk)

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:

```latex
\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](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=accents+package+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%5C%5BT_%7B%5Cnu_%7B1%7D%5Cnu_%7B2%7D%5Cldots%5Cnu_%7Bp%7D%7D%5E%7B%5Cprime%5Cmu_%7B1%7D%5Cmu_%7B2%7D%5Cldots%5Cmu_%7Bq%7D%7D%5C%5D%0A%5Cend%7Bdocument%7D)

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

![Example of typesetting superscripts and primes on Overleaf](/files/x8fNYQOxwQ5uZ7L78GbE)

## 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](/latex/mathematics/02-subscripts-and-superscripts.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://overleaf-pro.ayaka.space/latex/latex-errors/05-double-superscript.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
