> 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/05-double-superscript.md).

# 雙上標

## 簡介

依照慣例，LaTeX 使用抑揚符號（`^`）來排版上標，例如 `$a^b$` 會產生 $$a^b$$。如果你寫下 `$a^bcde$`，只有第一個字元 `b`會是上標，如 $$a^bcde$$，因為 LaTeX 不會 *預設* 你想要將整組字元都設為上標 `bcde`。要將多個項目（token）排成上標，你需要把它們放入一個群組中 `{...}`，例如： `$a^{bcde}$`，會產生 $$a^{bcde}$$.

## 雙重上標錯誤

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

例如，寫成 `$a^b^c$` ，並產生下列雙重上標錯誤：

![Overleaf 上顯示的雙重上標錯誤](/files/07e864f7656a828db761ea98e495062e94e751f4)

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

* `$a^{b^c}$` 排版為 $$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%5Eb%7D%5Ec%5C%29%0A%5Cend%7Bdocument%7D)

與 [雙重下標錯誤](/latex/zh-tw/latex-cuo-wu/04-double-subscript.md)一樣，解決這個問題的方法之一是加入 [`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%5Eb%7D%5Ec%5C%29%0A%5Cend%7Bdocument%7D)

#### 在上標中使用撇號

另一個常見的錯誤原因是在上標中使用撇號，這對張量記號尤其麻煩——如下所示：

```latex
\documentclass{article}
\begin{document}
\[T'_{\nu_{1}\nu_{2}\ldots\nu_{p}}^{\mu_{1}\mu_{2}\ldots\mu_{q}}\]
\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%5BT%27_%7B%5Cnu_%7B1%7D%5Cnu_%7B2%7D%5Cldots%5Cnu_%7Bp%7D%7D%5E%7B%5Cmu_%7B1%7D%5Cmu_%7B2%7D%5Cldots%5Cmu_%7Bq%7D%7D%5C%5D%0A%5Cend%7Bdocument%7D)

這個範例會觸發以下錯誤：

![由於數學模式中的撇號而造成的雙重上標錯誤](/files/ca1a097d4737860a7a06714f546c86c10efc71ee)

在數學模式中，LaTeX 會將帶撇號的符號解讀為 `T'` 寫成 `T^{\prime}`——也就是說，它會在 `T`上加上一個上標。 `^`當 LaTeX 隨後讀入抑揚符號時， `^{\mu_{1}\mu_{2}\ldots\mu_{q}}`，它會偵測到試圖再加上一個 *第二個上標* 到 `T`，因而觸發錯誤。

上面的表達式正確的寫法如下例所示：

```latex
\documentclass{article}
\begin{document}
\[T_{\nu_{1}\nu_{2}\ldots\nu_{p}}^{\prime\mu_{1}\mu_{2}\ldots\mu_{q}}\]
\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%5BT_%7B%5Cnu_%7B1%7D%5Cnu_%7B2%7D%5Cldots%5Cnu_%7Bp%7D%7D%5E%7B%5Cprime%5Cmu_%7B1%7D%5Cmu_%7B2%7D%5Cldots%5Cmu_%7Bq%7D%7D%5C%5D%0A%5Cend%7Bdocument%7D)

這個範例會產生以下輸出（已放大以便清楚顯示）：

![Overleaf 上的上標與撇號排版範例](/files/5ea7c63bcc0c7fc0715e0681cb440a7861a01731)

## 更多關於上標

可透過撰寫像是以下的 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/05-double-superscript.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.
