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

# 双重上标

## 引言

按惯例，LaTeX 使用抑扬符号（`^`）来排版上标，例如 `$a^b$` 这会生成 $$a^b$$。如果你写 `$a^bcde$`，只有第一个字符， `b`是上标，如 $$a^bcde$$，因为 LaTeX 不会 *假定* 如果你想将整组字符都设为上标 `bcde`。要将多个项（标记）排版为上标，你需要通过把它们括在一个组中来告诉 LaTeX `{...}`，像这样： `$a^{bcde}$`，这会生成 $$a^{bcde}$$.

## 双重上标错误

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

例如，写 `$a^b^c$` 会产生如下双重上标错误：

![Overleaf 上显示的双重上标错误](/files/1f6caf77addb4e66a8aec6af6055398beff0f666)

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

* `$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 中打开此 ***会产生错误的*** 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-cn/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 中打开此 ***已更正*** 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 中打开此 ***会产生错误的*** 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/5a1fe332cd5b922c3bc32fffa28d7f4d1ac86fa7)

在数学模式中，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 中打开此 ***已更正*** 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/71fa7e7118685e11ec0ccb310833641cc44f48a0)

## 更多关于上标的内容

可以通过编写如下 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/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.
