How to Write Superscript and Subscript Text in LaTeX

In LaTeX, you can write superscript text using the ^ command and subscript text using the _ command.

The following examples show how to write superscript and subscript text in LaTeX.

How to Write Superscript Text

We can use the ^ command to write superscript text in LaTeX document.

Suppose we want to write superscript text in the text.

We can use the following LaTeX code to do so:

\documentclass{article}
\begin{document}

This is an example of using the superscript text: \( x^2 \).

\end{document}

Output: 👇️

This is an example of using the superscript text: x².

In this example, we use the ^ command to display the superscript text in the document.

How to Write Subscript Text

We can use the _ command to write subscript text in LaTeX document.

Suppose we want to write subscript text in the text.

We can use the following LaTeX code to do so:

\documentclass{article}
\begin{document}

This is an example of using the subscript text: \( x_2 \).

\end{document}

Output: 👇️

This is an example of using the subscript text: x₂.

In this example, we use the _ command to display the subscript text in the document.

How to Write Superscript and Subscript Text in Mathematical Expressions

For mathematical expressions, we can use the ^ and _ commands to ensure proper formatting.

Suppose we would like to write mathematical expressions that contain both superscript and subscript text.

We can use the following LaTeX code to do so:

\documentclass{article}
\begin{document}

An inline mathematical expression: \( x_2^2 \).

A displayed mathematical expression:
\[
x_2^2
\]

\end{document}

Output: 👇️

x₂²

In this example, the ^ and _ commands are used to denote both superscript and subscript text in both inline and displayed mathematical expressions.

Conclusion

We can use the ^ command for superscript text and the _ command for subscript text in both text and mathematical expressions.