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

# 雙下標

## 簡介

按照慣例，LaTeX 使用底線字元（`_`）來排版下標，例如 `$a_b$` 會產生 $$a\_b$$。如果你寫下 `$a_bcde$` 只有第一個字元 `b`，是下標， $$a\_bcde$$，因為 LaTeX 不會 *預設* 你想把整組字元都設為下標 `bcde`。若要將多個項目（token）排成下標，你需要透過將它們括在一個群組中來告訴 LaTeX `{...}`，例如： `$a_{bcde}$`，會產生 $$a\_{bcde}$$.

## 雙重下標錯誤

當 LaTeX 被要求為某段已經 *已經* 帶有下標的數學式再加上下標時，就會出現雙重下標錯誤。這個錯誤通常可透過使用大括號來解決 `{...}` ，它在數學模式中會產生所謂的 *子公式*——用來描述你嘗試排版的數學表達式片段的術語。

例如，寫成 `$a_b_c$` 會產生以下雙重下標錯誤：

![Overleaf 上顯示的雙重下標錯誤](/files/10f77498f8c0ada34f6a66b15667382fee2df407)

這個特定錯誤可透過使用大括號以多種方式修正 `{...}`——結果會依大括號的位置而有所不同：

* `$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-tw/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-tw/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.
