> For the complete documentation index, see [llms.txt](https://ayakaleaf-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://ayakaleaf-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`。要将多个项目（token）排版为上标，你需要通过将它们括在一组中来告诉 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 中的示例](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 中的示例](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/5a1fe332cd5b922c3bc32fffa28d7f4d1ac86fa7)

在数学模式下，LaTeX 会将带撇号的符号 `T'` as `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/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://ayakaleaf-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.
