> 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/04-double-subscript.md).

# Double subscript

## Introduction

By convention, LaTeX uses the underscore character (`_`) to typeset a subscript, such as `$a_b$` which produces $$a\_b$$. If you write `$a_bcde$` only the first character, `b`, is subscript, $$a\_bcde$$, because LaTeX does not *assume* you want to subscript the entire set of characters `bcde`. To typeset multiple items (tokens) as subscripts, you need to tell LaTeX by enclosing them in a group `{...}`, like this: `$a_{bcde}$`, which produces $$a\_{bcde}$$.

## Double subscript error

The double subscript error arises when LaTeX is asked to add a subscript to a piece of mathematics which *already has* a subscript 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 subscript error:

![A double subscript error showing on Overleaf](/files/qtM1KaCUMcytjN6lgOOI)

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 $$\displaystyle a\_{b\_c}$$
* `${a_b}_c$` typesets $${a\_b}\_c$$
* `$a_{bc}$` typesets $$a\_{bc}$$

### Double subscript error: a special case

A question on `tex.stackexchange` highlights [a surprising example of the double subscript error](https://tex.stackexchange.com/questions/253080/why-am-i-getting-a-double-subscript-error), one whose cause and corresponding fix may be worth knowing about. We reproduce the example here.

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_b%7D_c%5C%29%0A%5Cend%7Bdocument%7D)

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 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_b%7D_c%5C%29%0A%5Cend%7Bdocument%7D)

## More on subscripts

Further levels of subscripts can be typeset by writing LaTeX such as `$a_{b_{c_{d_e}}}$` which typesets $$a\_{b\_{c\_{d\_e}}}$$. All subscripts at or below the second level (sub-subscript) are typeset using the same font size (in points), whereas first-level subscripts are typeset using a slightly larger font (point size). To learn more about subscripts, 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/04-double-subscript.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.
