Introduction

Welcome back to Writing Math in LaTeX! In the previous lesson, you learned how to enter math mode with $...$ for inline expressions and \[...\] for display expressions. That was the essential first step, and now — in this second lesson of the course — we are ready to build on that foundation. Here, you will learn how to create subscripts and superscripts, two of the most frequently used elements in mathematical and scientific writing. By the end, you will know exactly how to position notation above and below a base character with confidence.

The Role of Subscripts and Superscripts

Before we look at any syntax, let's appreciate just how often subscripts and superscripts show up in real-world notation. Superscripts give us exponents like x2x^2 in algebra and powers like 10610^6 in scientific notation, while subscripts let us label related variables like v0v_0 for initial velocity in physics. You will find them in chemistry (), in sequences (), and across virtually every technical discipline.

Writing Subscripts with the Underscore

To create a subscript in math mode, place an underscore character (_) right after the base element, followed by the subscript content. For example:

This produces xnx_n, where the letter n appears slightly below and to the right of x. The underscore tells LaTeX: "take what comes next and set it as a subscript." Here are a few more examples:

  • $a_1$ renders as a1a_1
Writing Superscripts with the Caret

Superscripts work the same way, but instead of an underscore we use the caret character (^). Placing ^ after a base element raises the next character:

This gives us x2x^2. The caret tells LaTeX to set what follows as a superscript — the standard way to write exponents, powers, and similar raised notation. A few more examples:

  • $a^3$ renders as a3a^3
  • $e^x$ renders as
Grouping Multi-character Expressions with Braces

Here is one of the most common mistakes new LaTeX writers make. Suppose we want to write x raised to the power of 10. It might seem natural to type:

However, LaTeX only raises the first character after ^, producing x10x^10 — an xx with a superscript 1 followed by a regular-sized 0. That is clearly not what we intended.

The fix is to wrap multi-character subscripts or superscripts in curly braces {}. Braces tell LaTeX to treat everything inside them as a single group:

Now LaTeX correctly renders x10x^{10}. The same rule applies to subscripts:

Combining Subscripts and Superscripts

In many real-world formulas, a single base element carries both a subscript and a superscript at the same time. LaTeX handles this naturally — simply attach both _ and ^ to the same base:

This renders as x12x_1^2, with the subscript 1 and superscript 2 neatly arranged around x. The order does not matter: $x^2_1$ produces the exact same output. LaTeX recognizes that both belong to the same base regardless of which you write first.

Illustration of a base element with superscript above-right and subscript below-right, showing their positions

When either part has multiple characters, use braces just as before. For example, $a_n^{k+1}$ produces . Let's look at a slightly more involved example from physics. The change in kinetic energy can be written as:

Quick Reference

Here is a compact summary of the rules covered in this lesson:

SyntaxPurposeExample InputRendered
_Subscript (single char)$x_n$xnx_n
^Superscript (single char)$x^2$x2x^2
Conclusion and Next Steps

In this lesson, you learned how to use the underscore (_) for subscripts and the caret (^) for superscripts in LaTeX math mode. You saw that curly braces {} are essential for grouping multi-character content, and that both a subscript and a superscript can be attached to the same base element in either order. These two small characters will appear in nearly every mathematical expression you write going forward.

Now it is time to put this knowledge into action. Head over to the practice exercises, where you will write subscripts, superscripts, and combined expressions step by step — including a real physics formula that ties everything together. In the next lesson, we will tackle fractions, giving you yet another essential building block for typesetting math.

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal