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

# Subscripts and superscripts

## Introduction

The use of superscripts and subscripts is very common in mathematical expressions involving exponents, indexes, and in some special operators. This article explains how to write superscripts and subscripts in simple expressions, integrals, summations and so forth.

Definite integrals are some of the most common mathematical expressions, so let's see an example:

```latex
\[ \int\limits_0^1 x^2 + y^2 \ dx \]
```

[Open this example in Overleaf.](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Superscripts+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%5C%5B+%5Cint%5Climits_0%5E1+x%5E2+%2B+y%5E2+%5C+dx+%5C%5D%0A%5Cend%7Bdocument%7D)

This LaTeX code produces:

$$\int\limits\_0^1 x^2 + y^2 \ dx$$

By convention, superscripts and subscripts in LaTeX are created using the characters `^` and `_` respectively; for example, the exponents applied to $$x$$ and $$y$$ in the code fragment above. Those characters can also be used with mathematical symbols, such as the integral (`\int`) included in the example above where `_` is used to set the lower limit and the `^` for the upper limit.

The command `\limits` changes the way the limits are displayed in the integral, if not present the limits would be next to the integral symbol instead of being on top and bottom:

```latex
\[ \int_0^1 x^2 + y^2 \ dx \]
```

[Open this example in Overleaf.](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Superscripts+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%5C%5B+%5Cint_0%5E1+x%5E2+%2B+y%5E2+%5C+dx+%5C%5D%0A%5Cend%7Bdocument%7D)

This LaTeX code produces:

$$\int\_0^1 x^2 + y^2 \ dx$$

## More detailed examples

The symbols `_` and `^` can also be combined in the same expression, for example:

```latex
\[ a_1^2 + a_2^2 = a_3^2 \]
```

[Open this example in Overleaf.](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Superscripts+example+2\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%5C%5B+a_1%5E2+%2B+a_2%5E2+%3D+a_3%5E2+%5C%5D%0A%5Cend%7Bdocument%7D)

This LaTeX code produces:

$$a\_1^2 + a\_2^2 = a\_3^2$$

If the expression contains long superscripts or subscripts, these need to be collected in braces, as LaTeX normally applies the mathematical commands `^` and `_` only to the following character:

```latex
\[ x^{2 \alpha} - 1 = y_{ij} + y_{ij}  \]
```

[Open this example in Overleaf.](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Superscripts+example+3\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%5C%5B+x%5E%7B2+%5Calpha%7D+-+1+%3D+y_%7Bij%7D+%2B+y_%7Bij%7D++%5C%5D%0A%5Cend%7Bdocument%7D)

This LaTeX code produces:

$$x^{2 \alpha} - 1 = y\_{ij} + y\_{ij}$$

Subscripts and superscripts can be nested and combined in various ways. When nesting subscripts/superscripts, however, remember that each command must refer to a single element; this can be a single letter or number, as in the examples above, or a more complex mathematical expression collected in braces or brackets. For example:

```latex
\[ (a^n)^{r+s} = a^{nr+ns}  \]
```

[Open this example in Overleaf.](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Superscripts+example+4\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%5C%5B+%28a%5En%29%5E%7Br%2Bs%7D+%3D+a%5E%7Bnr%2Bns%7D++%5C%5D%0A%5Cend%7Bdocument%7D)

This LaTeX code produces:

$$(a^n)^{r+s} = a^{nr+ns}$$

## Operators using subscripts and superscripts

Some mathematical operators may require subscripts and superscripts. The most frequent cases are those of the integral `\int` (check the [introduction](#introduction)) and the summation (`\sum`) operators, whose bounds are typeset precisely with subscripts and superscripts.

```latex
\[ \sum_{n=1}^{\infty} \frac{1}{n^s}
= \prod_p \frac{1}{1 - p^{-s}} \]
```

[Open this example in Overleaf.](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Superscripts+example+5\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%5C%5B+%5Csum_%7Bn%3D1%7D%5E%7B%5Cinfty%7D+%5Cfrac%7B1%7D%7Bn%5Es%7D+%0A%3D+%5Cprod_p+%5Cfrac%7B1%7D%7B1+-+p%5E%7B-s%7D%7D+%5C%5D%0A%5Cend%7Bdocument%7D)

This LaTeX code produces:

$$\sum\_{n=1}^{\infty} \frac{1}{n^s} = \prod\_p \frac{1}{1 - p^{-s}}$$

For other frequently used operators that require subscripts/superscripts check the [reference guide](#reference-guide).

## Open all code fragments in Overleaf

Use the link provided below to open all the examples above as a single Overleaf project:

```latex
Here are some examples of simple usage of subscripts and superscripts:

\[ \int\limits_0^1 x^2 + y^2 \ dx \]

\vspace{1cm}

Using superscript and subscripts in the same expression

\[ a_1^2 + a_2^2 = a_3^2 \]

\vspace{1cm}

Longer subscripts and superscripts:

\[ x^{2 \alpha} - 1 = y_{ij} + y_{ij}  \]

\vspace{1cm}

Nested subscripts and superscripts

\[ (a^n)^{r+s} = a^{nr+ns} \]

\vspace{1cm}

Example of a mathematical equation with subscripts and superscripts

\[ \sum_{i=1}^{\infty} \frac{1}{n^s} = \prod_p \frac{1}{1 - p^{-s}} \]

\vspace{1cm}

Squared root usage

\[ \sqrt[4]{4ac} = \sqrt{4ac}\sqrt{4ac} \]
```

[Open all the examples above as a single Overleaf project.](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Superscripts+example+6\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Ctitle%7BSubscripts+and+Superscripts%7D%0A%5Cauthor%7BExamples+from+Overleaf%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cmaketitle%0AHere+are+some+examples+of+simple+usage+of+subscripts+and+superscripts%3A%0A%0A%5C%5B+%5Cint%5Climits_0%5E1+x%5E2+%2B+y%5E2+%5C+dx+%5C%5D%0A%0A%5Cvspace%7B1cm%7D%0A%0AUsing+superscript+and+subscripts+in+the+same+expression%0A%0A%5C%5B+a_1%5E2+%2B+a_2%5E2+%3D+a_3%5E2+%5C%5D%0A%0A%5Cvspace%7B1cm%7D%0A%0ALonger+subscripts+and+superscripts%3A%0A%0A%5C%5B+x%5E%7B2+%5Calpha%7D+-+1+%3D+y_%7Bij%7D+%2B+y_%7Bij%7D++%5C%5D%0A%0A%5Cvspace%7B1cm%7D%0A%0ANested+subscripts+and+superscripts%0A%0A%5C%5B+%28a%5En%29%5E%7Br%2Bs%7D+%3D+a%5E%7Bnr%2Bns%7D+%5C%5D%0A%0A%5Cvspace%7B1cm%7D%0A%0AExample+of+a+mathematical+equation+with+subscripts+and+superscripts%0A%0A%5C%5B+%5Csum_%7Bi%3D1%7D%5E%7B%5Cinfty%7D+%5Cfrac%7B1%7D%7Bn%5Es%7D+%3D+%5Cprod_p+%5Cfrac%7B1%7D%7B1+-+p%5E%7B-s%7D%7D+%5C%5D%0A%0A%5Cvspace%7B1cm%7D%0A%0ASquared+root+usage%0A%0A%5C%5B+%5Csqrt%5B4%5D%7B4ac%7D+%3D+%5Csqrt%7B4ac%7D%5Csqrt%7B4ac%7D+%5C%5D%0A%5Cend%7Bdocument%7D)

## Reference guide

Additional examples and operators

| LaTeX markup          | Renders as                                                                                                              |
| --------------------- | ----------------------------------------------------------------------------------------------------------------------- |
| `a_{n_i}`             | a n i {\displaystyle a\_{n\_{i}}} ![{\displaystyle a\_{n\_{i}}}](/files/na4umExb00q7WhfuQ24p)                           |
| `\int_{i=1}^n`        | ∫ i = 1 n {\displaystyle \int \_{i=1}^{n}} ![{\displaystyle \int \_{i=1}^{n}}](/files/QEbE6ZZPCFIHVkYLWozw)             |
| `\sum_{i=1}^{\infty}` | ∑ i = 1 ∞ {\displaystyle \sum \_{i=1}^{\infty }} ![{\displaystyle \sum \_{i=1}^{\infty }}](/files/1PRwQVH0G5qsR6kG1kah) |
| `\prod_{i=1}^n`       | ∏ i = 1 n {\displaystyle \prod \_{i=1}^{n}} ![{\displaystyle \prod \_{i=1}^{n}}](/files/ePWiSalFHZxr9qfEJPuz)           |
| `\cup_{i=1}^n`        | ∪ i = 1 n {\displaystyle \cup \_{i=1}^{n}} ![{\displaystyle \cup \_{i=1}^{n}}](/files/u2zCFusd1S2M97sHWGI1)             |
| `\cap_{i=1}^n`        | ∩ i = 1 n {\displaystyle \cap \_{i=1}^{n}} ![{\displaystyle \cap \_{i=1}^{n}}](/files/36YBj1IuFRA2tQfx1S7M)             |
| `\oint_{i=1}^n`       | ∮ i = 1 n {\displaystyle \oint \_{i=1}^{n}} ![{\displaystyle \oint \_{i=1}^{n}}](/files/G8KSTShVCgDh2jODq205)           |
| `\coprod_{i=1}^n`     | ∐ i = 1 n {\displaystyle \coprod \_{i=1}^{n}} ![{\displaystyle \coprod \_{i=1}^{n}}](/files/UfmhumvmhhYjfKcbLFYY)       |

There are also `bigcup` and `bigcap` commands similar to `cup` and `cap` but those are used for larger expressions.

## Further reading

For more information see

* [List of Greek letters and math symbols](/latex/mathematics/11-list-of-greek-letters-and-math-symbols.md)
* [Operators](/latex/mathematics/07-operators.md)
* [Integrals, sums and limits](/latex/mathematics/09-integrals-sums-and-limits.md)
* [Mathematical fonts](/latex/mathematics/12-mathematical-fonts.md)
* [Brackets and Parentheses](/latex/mathematics/03-brackets-and-parentheses.md)
* [The Great, Big list of LaTeX Symbols](http://www.rpi.edu/dept/arc/training/latex/LaTeX_symbols.pdf) (a full list of available mathematical symbols in the **amssymb** package)
* [The not so short introduction to LaTeX2ε](http://www.ctan.org/tex-archive/info/lshort/)
* [Aligning equations with amsmath](/latex/mathematics/06-aligning-equations-with-amsmath.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/mathematics/02-subscripts-and-superscripts.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.
