> 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/shu-xue/02-subscripts-and-superscripts.md).

# 下标和上标

## 引言

上标和下标的使用在涉及指数、索引以及某些特殊运算符的数学表达式中非常常见。本文将解释如何在简单表达式、积分、求和等中编写上标和下标。

定积分是最常见的数学表达式之一，所以让我们看一个例子：

```latex
\[ \int\limits_0^1 x^2 + y^2 \ dx \]
```

[在 Overleaf 中打开此示例。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Superscripts+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%5C%5B+%5Cint%5Climits_0%5E1+x%5E2+%2B+y%5E2+%5C+dx+%5C%5D%0A%5Cend%7Bdocument%7D)

这段 LaTeX 代码生成：

$$\int\limits\_0^1 x^2 + y^2 \ dx$$

按照惯例，LaTeX 中的上标和下标分别使用字符 `^` 和 `_` 和；例如，应用于 $$x$$ 和 $$y$$ 上面的代码片段中的。那些字符也可用于数学符号，例如积分符号（`\int`），如上例所示，其中 `_` 用于设置下限，而 `^` 用于设置上限。

命令 `\limits` 会改变积分中上下限的显示方式；如果没有它，上下限会显示在积分符号旁边，而不是上下：

```latex
\[ \int_0^1 x^2 + y^2 \ dx \]
```

[在 Overleaf 中打开此示例。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Superscripts+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%5C%5B+%5Cint_0%5E1+x%5E2+%2B+y%5E2+%5C+dx+%5C%5D%0A%5Cend%7Bdocument%7D)

这段 LaTeX 代码生成：

$$\int\_0^1 x^2 + y^2 \ dx$$

## 更多详细示例

符号 `_` 和 `^` 也可以组合在同一个表达式中，例如：

```latex
\[ a_1^2 + a_2^2 = a_3^2 \]
```

[在 Overleaf 中打开此示例。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Superscripts+example+2\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%5C%5B+a_1%5E2+%2B+a_2%5E2+%3D+a_3%5E2+%5C%5D%0A%5Cend%7Bdocument%7D)

这段 LaTeX 代码生成：

$$a\_1^2 + a\_2^2 = a\_3^2$$

如果表达式包含较长的上标或下标，这些内容需要用花括号括起来，因为 LaTeX 通常只将数学命令 `^` 和 `_` 应用于后面的单个字符：

```latex
\[ x^{2 \alpha} - 1 = y_{ij} + y_{ij}  \]
```

[在 Overleaf 中打开此示例。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Superscripts+example+3\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%5C%5B+x%5E%7B2+%5Calpha%7D+-+1+%3D+y_%7Bij%7D+%2B+y_%7Bij%7D++%5C%5D%0A%5Cend%7Bdocument%7D)

这段 LaTeX 代码生成：

$$x^{2 \alpha} - 1 = y\_{ij} + y\_{ij}$$

下标和上标可以以各种方式嵌套和组合。不过，在嵌套下标/上标时，请记住每个命令都必须作用于一个单独的元素；这可以像上面的例子那样是单个字母或数字，也可以是用花括号或方括号括起来的更复杂的数学表达式。例如：

```latex
\[ (a^n)^{r+s} = a^{nr+ns}  \]
```

[在 Overleaf 中打开此示例。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Superscripts+example+4\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%5C%5B+%28a%5En%29%5E%7Br%2Bs%7D+%3D+a%5E%7Bnr%2Bns%7D++%5C%5D%0A%5Cend%7Bdocument%7D)

这段 LaTeX 代码生成：

$$(a^n)^{r+s} = a^{nr+ns}$$

## 使用下标和上标的运算符

某些数学运算符可能需要下标和上标。最常见的情况是积分 `\int` （请查看 [引言](#introduction)）和求和（`\sum`）运算符，它们的上下限正是通过下标和上标排版的。

```latex
\[ \sum_{n=1}^{\infty} \frac{1}{n^s}
= \prod_p \frac{1}{1 - p^{-s}} \]
```

[在 Overleaf 中打开此示例。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Superscripts+example+5\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cbegin%7Bdocument%7D%0A%5C%5B+%5Csum_%7Bn%3D1%7D%5E%7B%5Cinfty%7D+%5Cfrac%7B1%7D%7Bn%5Es%7D+%0A%3D+%5Cprod_p+%5Cfrac%7B1%7D%7B1+-+p%5E%7B-s%7D%7D+%5C%5D%0A%5Cend%7Bdocument%7D)

这段 LaTeX 代码生成：

$$\sum\_{n=1}^{\infty} \frac{1}{n^s} = \prod\_p \frac{1}{1 - p^{-s}}$$

对于其他需要下标/上标的常用运算符，请查看 [参考指南](#reference-guide).

## 在 Overleaf 中打开所有代码片段

使用下方提供的链接，将上面的所有示例作为一个 Overleaf 项目打开：

```latex
下面是一些下标和上标简单用法的示例：

\[ \int\limits_0^1 x^2 + y^2 \ dx \]

\vspace{1cm}

在同一个表达式中使用上标和下标

\[ a_1^2 + a_2^2 = a_3^2 \]

\vspace{1cm}

更长的下标和上标：

\[ x^{2 \alpha} - 1 = y_{ij} + y_{ij}  \]

\vspace{1cm}

嵌套的下标和上标

\[ (a^n)^{r+s} = a^{nr+ns} \]

\vspace{1cm}

带有下标和上标的数学方程示例

\[ \sum_{i=1}^{\infty} \frac{1}{n^s} = \prod_p \frac{1}{1 - p^{-s}} \]

\vspace{1cm}

平方根的用法

\[ \sqrt[4]{4ac} = \sqrt{4ac}\sqrt{4ac} \]
```

[将上面的所有示例作为一个 Overleaf 项目打开。](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Superscripts+example+6\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Ctitle%7BSubscripts+and+Superscripts%7D%0A%5Cauthor%7BExamples+from+Overleaf%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cmaketitle%0AHere+are+some+examples+of+simple+usage+of+subscripts+and+superscripts%3A%0A%0A%5C%5B+%5Cint%5Climits_0%5E1+x%5E2+%2B+y%5E2+%5C+dx+%5C%5D%0A%0A%5Cvspace%7B1cm%7D%0A%0AUsing+superscript+and+subscripts+in+the+same+expression%0A%0A%5C%5B+a_1%5E2+%2B+a_2%5E2+%3D+a_3%5E2+%5C%5D%0A%0A%5Cvspace%7B1cm%7D%0A%0ALonger+subscripts+and+superscripts%3A%0A%0A%5C%5B+x%5E%7B2+%5Calpha%7D+-+1+%3D+y_%7Bij%7D+%2B+y_%7Bij%7D++%5C%5D%0A%0A%5Cvspace%7B1cm%7D%0A%0ANested+subscripts+and+superscripts%0A%0A%5C%5B+%28a%5En%29%5E%7Br%2Bs%7D+%3D+a%5E%7Bnr%2Bns%7D+%5C%5D%0A%0A%5Cvspace%7B1cm%7D%0A%0AExample+of+a+mathematical+equation+with+subscripts+and+superscripts%0A%0A%5C%5B+%5Csum_%7Bi%3D1%7D%5E%7B%5Cinfty%7D+%5Cfrac%7B1%7D%7Bn%5Es%7D+%3D+%5Cprod_p+%5Cfrac%7B1%7D%7B1+-+p%5E%7B-s%7D%7D+%5C%5D%0A%0A%5Cvspace%7B1cm%7D%0A%0ASquared+root+usage%0A%0A%5C%5B+%5Csqrt%5B4%5D%7B4ac%7D+%3D+%5Csqrt%7B4ac%7D%5Csqrt%7B4ac%7D+%5C%5D%0A%5Cend%7Bdocument%7D)

## 参考指南

其他示例和运算符

| LaTeX 标记              | 显示为                                                                                                                                         |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| `a_{n_i}`             | a n i {\displaystyle a\_{n\_{i}}} ![{\displaystyle a\_{n\_{i}}}](/files/c60ceb8ae31d67d1005f5d694e21312898980189)                           |
| `\int_{i=1}^n`        | ∫ i = 1 n {\displaystyle \int \_{i=1}^{n}} ![{\displaystyle \int \_{i=1}^{n}}](/files/f52ba27f6877f05470d909d30acacb675ebf896a)             |
| `\sum_{i=1}^{\infty}` | ∑ i = 1 ∞ {\displaystyle \sum \_{i=1}^{\infty }} ![{\displaystyle \sum \_{i=1}^{\infty }}](/files/5e72244e243318aacdf3f3e22f0e91b9bd3a1bb2) |
| `\prod_{i=1}^n`       | ∏ i = 1 n {\displaystyle \prod \_{i=1}^{n}} ![{\displaystyle \prod \_{i=1}^{n}}](/files/218894b245df7a0ebb4a757c2729bff9b0f50e71)           |
| `\cup_{i=1}^n`        | ∪ i = 1 n {\displaystyle \cup \_{i=1}^{n}} ![{\displaystyle \cup \_{i=1}^{n}}](/files/32c638bf197ca10bf815cdc1be1f6552dda1734f)             |
| `\cap_{i=1}^n`        | ∩ i = 1 n {\displaystyle \cap \_{i=1}^{n}} ![{\displaystyle \cap \_{i=1}^{n}}](/files/41baa876dbb08ff15122a435fca2840319e6a4e4)             |
| `\oint_{i=1}^n`       | ∮ i = 1 n {\displaystyle \oint \_{i=1}^{n}} ![{\displaystyle \oint \_{i=1}^{n}}](/files/3c5e4d637fc560dfcad25bec85d1946bb131d2dc)           |
| `\coprod_{i=1}^n`     | ∐ i = 1 n {\displaystyle \coprod \_{i=1}^{n}} ![{\displaystyle \coprod \_{i=1}^{n}}](/files/e014902e5aae3cb7ef216eea1ccaa31994c7d277)       |

还有 `bigcup` 和 `bigcap` 类似于 `cup` 和 `cap` 但这些用于更大的表达式。

## 进一步阅读

更多信息请参见

* [希腊字母和数学符号列表](/latex/zh-cn/shu-xue/11-list-of-greek-letters-and-math-symbols.md)
* [运算符](/latex/zh-cn/shu-xue/07-operators.md)
* [积分、求和与极限](/latex/zh-cn/shu-xue/09-integrals-sums-and-limits.md)
* [数学字体](/latex/zh-cn/shu-xue/12-mathematical-fonts.md)
* [括号](/latex/zh-cn/shu-xue/03-brackets-and-parentheses.md)
* [LaTeX 符号大全](http://www.rpi.edu/dept/arc/training/latex/LaTeX_symbols.pdf) （在 **amssymb** 宏包中可用的数学符号完整列表）
* [LaTeX2ε 不那么简短的介绍](http://www.ctan.org/tex-archive/info/lshort/)
* [使用 amsmath 对齐方程](/latex/zh-cn/shu-xue/06-aligning-equations-with-amsmath.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/shu-xue/02-subscripts-and-superscripts.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.
