> 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/zh-cn/latex-cuo-wu/04-double-subscript.md).

# 双重下标

## 简介

按照惯例，LaTeX 使用下划线字符（`_`）来排版下标，例如 `$a_b$` 这会生成 $$a\_b$$。如果你写 `$a_bcde$` 只有第一个字符， `b`，是下标， $$a\_bcde$$，因为 LaTeX 不会 *假定* 你想对整组字符设置下标 `bcde`。要将多个项（标记）排版为下标，你需要通过将它们括在一个组中来告诉 LaTeX `{...}`，像这样： `$a_{bcde}$`，这会生成 $$a\_{bcde}$$.

## 双重下标错误

当 LaTeX 被要求为某个数学表达式添加下标，而该表达式 *已经有* 一个下标附在其上时，就会出现双重下标错误。通常可以通过使用花括号来解决这个错误 `{...}` ，在数学模式中，花括号会生成所谓的 *子公式*——用于描述你试图排版的数学表达式片段的术语。

例如，写 `$a_b_c$` 会产生如下双重下标错误：

![Overleaf 中显示的双重下标错误](/files/bfef6beef0881cfc8fa086865cf0ed3e70e07d0d)

这个特定错误可以通过使用花括号以几种方式修复 `{...}`——结果会根据花括号的位置而有所不同：

* `$a_{b_c}$` 排版为 $$\displaystyle a\_{b\_c}$$
* `${a_b}_c$` 排版为 $${a\_b}\_c$$
* `$a_{bc}$` 排版为 $$a\_{bc}$$

### 双重下标错误：一个特殊情况

一个关于 `tex.stackexchange` 凸显了 [一个令人惊讶的双重下标错误示例](https://tex.stackexchange.com/questions/253080/why-am-i-getting-a-double-subscript-error)，其成因及相应的修复方法值得了解。我们在此重现该示例。

下面的示例即使使用了花括号，也无法编译：

```latex
\documentclass{article}
\begin{document}
\({\vec a_b}_c\)
\end{document}
```

[打开此 ***会产生错误的*** 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)

解决这个问题的一种方法是将 [`accents` 宏包](https://ctan.org/pkg/accents?lang=en) 添加到文档导言区（如 [此处](https://tex.stackexchange.com/a/253094)):

```latex
\documentclass{article}
\usepackage{accents}
\begin{document}
\({\vec a_b}_c\)
\end{document}
```

[在 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)

## 更多关于下标

可以通过编写类似以下的 LaTeX 来排版更深层级的下标 `$a_{b_{c_{d_e}}}$` 这会排版为 $$a\_{b\_{c\_{d\_e}}}$$。所有处于第二层及以下的下标（即子下标）都使用相同的字号（以磅为单位）排版，而第一层下标则使用稍大一点的字号（磅值）。要了解更多关于下标的信息，请访问 Overleaf 的 [专门介绍该主题的帮助页面](/latex/zh-cn/shu-xue/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/zh-cn/latex-cuo-wu/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.
