> 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/08-spacing-in-math-mode.md).

# 數學模式中的間距

本文說明如何在數學模式中插入不同寬度的空白。

## 簡介

在某些情況下，調整（La）TeX 的預設數學模式間距會很有用；讓我們看看一個範例：

```latex
\documentclass{article}
\usepackage{amssymb}
\begin{document}
假設我們有以下集合
\[
S = \{ z \in \mathbb{C}\, |\, |z| < 1 \} \quad \textrm{and} \quad S_2=\partial{S}
\]
\end{document}
```

[在 Overleaf 中開啟這個範例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Math+mode+spacing+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bamssymb%7D%0A%5Cbegin%7Bdocument%7D%0AAssume+we+have+the+next+sets%0A%5C%5B%0AS+%3D+%5C%7B+z+%5Cin+%5Cmathbb%7BC%7D%5C%2C+%7C%5C%2C+%7Cz%7C+%3C+1+%5C%7D+%5Cquad+%5Ctextrm%7Band%7D+%5Cquad+S_2%3D%5Cpartial%7BS%7D%0A%5C%5D%0A%5Cend%7Bdocument%7D)

此範例會產生以下輸出：

![顯示數學間距調整的範例](/files/7c0ab0c187991dff366e3bb3586e1f2e8f4e0a09)

如你在這個範例中所見，數學文字可以透過一些特殊指令明確地調整間距。

## 空白

以下範例包含使用各種指令插入的空白完整列表，並示範它們對排版後數學式的影響。

```latex
\documentclass{article}
\usepackage{amsmath}
\begin{document}
數學模式中的空白。

\begin{align*}
f(x) &= x^2\! +3x\! +2 \\
f(x) &= x^2+3x+2 \\
f(x) &= x^2\, +3x\, +2 \\
f(x) &= x^2\: +3x\: +2 \\
f(x) &= x^2\; +3x\; +2 \\
f(x) &= x^2\ +3x\ +2 \\
f(x) &= x^2\quad +3x\quad +2 \\
f(x) &= x^2\qquad +3x\qquad +2
\end{align*}
\end{document}
```

[在 Overleaf 中開啟這個範例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Math+mode+spacing+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bamsmath%7D%0A%5Cbegin%7Bdocument%7D%0ASpaces+in+mathematical+mode.%0A%0A%5Cbegin%7Balign%2A%7D%0Af%28x%29+%26%3D+x%5E2%5C%21+%2B3x%5C%21+%2B2+%5C%5C%0Af%28x%29+%26%3D+x%5E2%2B3x%2B2+%5C%5C%0Af%28x%29+%26%3D+x%5E2%5C%2C+%2B3x%5C%2C+%2B2+%5C%5C%0Af%28x%29+%26%3D+x%5E2%5C%3A+%2B3x%5C%3A+%2B2+%5C%5C%0Af%28x%29+%26%3D+x%5E2%5C%3B+%2B3x%5C%3B+%2B2+%5C%5C%0Af%28x%29+%26%3D+x%5E2%5C+%2B3x%5C+%2B2+%5C%5C%0Af%28x%29+%26%3D+x%5E2%5Cquad+%2B3x%5Cquad+%2B2+%5C%5C%0Af%28x%29+%26%3D+x%5E2%5Cqquad+%2B3x%5Cqquad+%2B2%0A%5Cend%7Balign%2A%7D%0A%5Cend%7Bdocument%7D)

此範例會產生以下輸出：

![更多在數學模式中調整間距的範例](/files/95481bc5074fa22f60a00dddb33882a84cd9eff8)

請查看 [參考指南](#reference-guide) 以了解這些指令的說明。

**注意**：以查看下列內容的說明 `align*` 環境請參見 [使用 amsmath 對齊方程式](/latex/zh-tw/shu-xue/06-aligning-equations-with-amsmath.md)

## 運算子間距

數學模式中運算子與關係符號周圍的間距由特定的跳距控制：

* `\thinmuskip` （預設為 3 mu）
* `\medmuskip` （預設為 4 mu）
* `\thickmuskip` （預設為 5 mu）

```latex
\begin{align*}
3ax+4by=5cz\\
3ax<4by+5cz
\end{align*}
```

[在 Overleaf 中開啟這個範例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Math+mode+operator+spacing+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bamsmath%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cbegin%7Balign%2A%7D%0A3ax%2B4by%3D5cz%5C%5C%0A3ax%3C4by%2B5cz%0A%5Cend%7Balign%2A%7D%0A%5Cend%7Bdocument%7D)

此範例會產生以下輸出：

![LaTeX 中的運算子間距](/files/3a30a7d6dc1fde9707c508273419086056c3a0b4)

對於關係運算子，例如 $$<$$, $$>$$ 和 $$=$$，LaTeX 會設定 `\thickmuskip` 間距。不過對於二元運算子，例如 $$+$$, $$-$$ 和 $$\times$$，而 `\medmuskip` 會設定間距。差異幾乎難以察覺。

## 使用者自訂的二元與關係運算子

你可以強制二元或關係運算子的間距，因此你可以 [定義你自己的](/latex/zh-tw/zhi-ling/01-commands.md).

```latex
\begin{align*}
34x^2a \mathbin{\#} 13bc \\
34x^2a \mathrel{\#} 13bc
\end{align*}
```

[在 Overleaf 中開啟這個範例](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Defining+your+own+math+operators\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bamsmath%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cbegin%7Balign%2A%7D%0A34x%5E2a+%5Cmathbin%7B%5C%23%7D+13bc+%5C%5C%0A34x%5E2a+%5Cmathrel%7B%5C%23%7D+13bc%0A%5Cend%7Balign%2A%7D%0A%5Cend%7Bdocument%7D)

此範例會產生以下輸出：

![定義你自己的二元或關係運算子](/files/5c3983671ceb102ab498e6d6f969e977aa658c52)

前一個範例透過在 `#` 使用 `\mathrel` （關係）與 `\mathbin` （二元）指令。

## 參考指南

**間距指令說明**

| LaTeX 程式碼       | 說明                                                                     |
| --------------- | ---------------------------------------------------------------------- |
| `\quad`         | 等於目前字體大小的空白（= 18 [mu](/latex/zh-tw/ge-shi-hua/01-lengths-in-latex.md)) |
| `\,`            | 相當於 3/18 的 `\quad` （= 3 mu）                                            |
| `\:`            | 相當於 4/18 的 `\quad` （= 4 mu）                                            |
| `\;`            | 相當於 5/18 的 `\quad` （= 5 mu）                                            |
| `\!`            | 相當於 -3/18 的 `\quad` （= -3 mu）                                          |
| `\\` （反斜線後的空白！） | 與一般文字中的空白等效                                                            |
| `\qquad`        | 兩倍的 `\quad` （= 36 mu）                                                  |

## 延伸閱讀

更多資訊請參見

* [數學表達式](/latex/zh-tw/shu-xue/01-mathematical-expressions.md)
* [中括號與小括號](/latex/zh-tw/shu-xue/03-brackets-and-parentheses.md)
* [使用 amsmath 對齊方程式](/latex/zh-tw/shu-xue/06-aligning-equations-with-amsmath.md)
* [數學模式中的顯示樣式](/latex/zh-tw/shu-xue/10-display-style-in-math-mode.md)
* [希臘字母與數學符號列表](/latex/zh-tw/shu-xue/11-list-of-greek-letters-and-math-symbols.md)
* [數學字型](/latex/zh-tw/shu-xue/12-mathematical-fonts.md)
* [LaTeX2ε 不那麼簡短的入門介紹](http://www.ctan.org/tex-archive/info/lshort/)


---

# 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/08-spacing-in-math-mode.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.
