# Subscript and Superscript in LaTeX

In mathematics, it is common to use as part of the language notation small symbols written at the top or bottom of a given symbol. These are called subscript and superscript, respectively. In this short tutorial, we will learn how to do subscript and superscript in LaTeX!

## Superscript in LaTeX

The most usual example of superscript we all learn in school is when we want to square a number $$2^2 = 4$$, cube it $$2^3 = 8$$, or, in general, raise it to the power of $$n$$, $$2^n$$. Superscripts can be done in LaTeX using the symbol ^. For example, $2^2=4$ produces the output $$2^2 = 4$$.

## How to do subscript in LaTeX

Subscripts are mainly used when we want to list certain elements, like let $$x_1,x_2,…,x_n$$ be rational numbers. Subscript in LaTeX can be created easily using the symbol _ (underscore). For example, $x_1,x_2,\ldots,x_n$ produces the list $$x_1,x_2, \ldots ,x_n$$.

## Subscript with more than one element

When we want to include more than one element in the subscript we will have to enclose those elements inside braces. For example, you can check the output produced by the following code:

$x_{12345} \quad x_12$

which is:

$$x_{12345} \quad x_12$$

You can see the difference between using the braces and not using them. The same goes for the superscripts!

## Subscript and superscript (combined)

Subscripts and superscripts can be both used at the same time, as in the equation:

$a_{ij}b_{kl}=\delta_{i}^{l}$

which produces the output:

$$a_{ij}b_{kl}=\delta_{i}^{l}$$

And they can even be nested (e.g. double subscript), for example:

x^{y^{z}}=a_{b_{c_{d}}}

produces:

$$x^{y^{z}}=a_{b_{c_{d}}}$$

It is a bit subtle, but observe that the first nested subscripts or superscript has a slightly smaller size than the previous one. However, from that point on, all nested subscripts or superscripts will have the same size as the second level.

## Math operator with subscript and superscript

Certain mathematical operators require subscripts, superscripts, or both. These sub and superscripts are also inserted using the _ and ^ symbols; LaTeX automatically knows where to typeset them depending on the kind of operator that is being used. Some of the most common ones are the following:

$\int_{-\infty}^{\infty} \quad \sum_{n=1}^{\infty} \quad \prod_{j=1}^{n} \quad \bigcup_{i \in I} \quad \bigcap_{i \in I} \quad \coprod_{k=1}^{\infty} \quad \lim_{n\to \infty}$

which are produced with the code:

% Math Operators with subscripts and superscripts
$\int_{-\infty}^{\infty} \quad \sum_{n=1}^{\infty} \quad \prod_{j=1}^{n} \quad \bigcup_{i \in I} \quad \bigcap_{i \in I} \quad \coprod_{k=1}^{\infty} \quad \lim_{n\to \infty}$

Most subscript and superscript, also called limits, in the case of the operators will be printed differently when used inline, mainly by positioning them at the top or bottom right. For instance, the first two operators of the previous example are: $$\int_{-\infty}^{\infty}$$ and $$\sum_{n=1}^{\infty}$$

If you don’t like this new behavior and prefer for legibility that they take up a larger amount of space than a normal line, you can use the command \displaystyle inside math mode. For example:

$\displaystyle \int_{-\infty}^{\infty}$

produces the output $$\displaystyle \int_{-\infty}^{\infty}$$ compared to the previous one: $$\int_{-\infty}^{\infty}$$.

We reached the end of this tutorial, If you have any remarks or suggestions, please feel free to reach us via email at admin@latex-tutorial.com 