> 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/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/bd8ac7e1362e87c3edd0e756567f977249d1d82c)                           |
| `\int_{i=1}^n`        | ∫ i = 1 n {\displaystyle \int \_{i=1}^{n}} ![{\displaystyle \int \_{i=1}^{n}}](/files/e64fc62c45d9c6867558a51cbc4afa507fe81582)             |
| `\sum_{i=1}^{\infty}` | ∑ i = 1 ∞ {\displaystyle \sum \_{i=1}^{\infty }} ![{\displaystyle \sum \_{i=1}^{\infty }}](/files/c84c7ff94eacf20bd931b5bd2d16f59fa3e635f3) |
| `\prod_{i=1}^n`       | ∏ i = 1 n {\displaystyle \prod \_{i=1}^{n}} ![{\displaystyle \prod \_{i=1}^{n}}](/files/d6aff4a3defefebff06692284684c0c740c147e6)           |
| `\cup_{i=1}^n`        | ∪ i = 1 n {\displaystyle \cup \_{i=1}^{n}} ![{\displaystyle \cup \_{i=1}^{n}}](/files/68110fa95101867b0f676e0f4f6e35b58519ca0a)             |
| `\cap_{i=1}^n`        | ∩ i = 1 n {\displaystyle \cap \_{i=1}^{n}} ![{\displaystyle \cap \_{i=1}^{n}}](/files/b85c1a38d74a59a10424a459c00699d5a8761f48)             |
| `\oint_{i=1}^n`       | ∮ i = 1 n {\displaystyle \oint \_{i=1}^{n}} ![{\displaystyle \oint \_{i=1}^{n}}](/files/f5f7434cd9b0c605d551ff15cdff6cdd2801a9c2)           |
| `\coprod_{i=1}^n`     | ∐ i = 1 n {\displaystyle \coprod \_{i=1}^{n}} ![{\displaystyle \coprod \_{i=1}^{n}}](/files/a392f0c12ebf2b7ffeed2f31127665e4e04b4065)       |

另外還有 `bigcup` 和 `bigcap` 與 `cup` 和 `cap` 類似的命令，但那些是用於較大的表達式。

## 延伸閱讀

更多資訊請參見

* [希臘字母與數學符號列表](/latex/zh-tw/shu-xue/11-list-of-greek-letters-and-math-symbols.md)
* [運算子](/latex/zh-tw/shu-xue/07-operators.md)
* [積分、求和與極限](/latex/zh-tw/shu-xue/09-integrals-sums-and-limits.md)
* [數學字型](/latex/zh-tw/shu-xue/12-mathematical-fonts.md)
* [中括號與小括號](/latex/zh-tw/shu-xue/03-brackets-and-parentheses.md)
* [LaTeX 符號大全](http://www.rpi.edu/dept/arc/training/latex/LaTeX_symbols.pdf) （amssymb **amssymb** 套件中的可用數學符號完整清單）
* [LaTeX2ε 不那麼簡短的入門介紹](http://www.ctan.org/tex-archive/info/lshort/)
* [使用 amsmath 對齊方程式](/latex/zh-tw/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-tw/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.
