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

# Khoảng cách trong chế độ toán học

Bài viết này giải thích cách chèn các khoảng trắng với độ rộng khác nhau trong chế độ toán.

## Giới thiệu

Điều chỉnh khoảng cách mặc định trong chế độ toán của (La)TeX có thể hữu ích trong một số tình huống; hãy xem một ví dụ:

```latex
\documentclass{article}
\usepackage{amssymb}
\begin{document}
Giả sử ta có các tập sau
\[
S = \{ z \in \mathbb{C}\, |\, |z| < 1 \} \quad \textrm{và} \quad S_2=\partial{S}
\]
\end{document}
```

[Mở ví dụ này trong 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)

Ví dụ này tạo ra kết quả sau:

![Ví dụ minh họa việc điều chỉnh khoảng cách trong toán học](/files/7f81a017734904090daada88dfe5bca6f08a1b18)

Như bạn thấy trong ví dụ này, một văn bản toán học có thể được chèn khoảng cách một cách rõ ràng bằng một số lệnh đặc biệt.

## Khoảng trắng

Ví dụ dưới đây chứa một danh sách đầy đủ các khoảng trắng được chèn bằng các lệnh khác nhau và minh họa tác dụng của chúng trên công thức toán được dàn trang.

```latex
\documentclass{article}
\usepackage{amsmath}
\begin{document}
Các khoảng trắng trong chế độ toán.

\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}
```

[Mở ví dụ này trong 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)

Ví dụ này tạo ra kết quả sau:

![Thêm nhiều ví dụ về điều chỉnh khoảng cách trong chế độ toán](/files/b1ab06e8739ee2634d7673f8cef43f0294b4a07e)

Hãy xem [hướng dẫn tham khảo](#reference-guide) để biết mô tả về các lệnh.

**Lưu ý**: để xem mô tả về `align*` môi trường, xem [Căn chỉnh các phương trình bằng amsmath](/latex/vi/toan-hoc/06-aligning-equations-with-amsmath.md)

## Khoảng cách toán tử

Khoảng cách xung quanh các toán tử và quan hệ trong chế độ toán được quy định bởi các độ chèn cụ thể:

* `\thinmuskip` (mặc định bằng 3 mu)
* `\medmuskip` (mặc định bằng 4 mu)
* `\thickmuskip` (mặc định bằng 5 mu)

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

[Mở ví dụ này trong 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)

Ví dụ này tạo ra kết quả sau:

![Khoảng cách toán tử trong LaTeX](/files/e3e059373d011218e5f936edec31b991563b29b8)

Đối với các toán tử quan hệ, chẳng hạn như $$<$$, $$>$$ và $$=$$, LaTeX thiết lập `\thickmuskip` khoảng trắng. Nhưng đối với các toán tử nhị phân như $$+$$, $$-$$ và $$\times$$, còn `\medmuskip` khoảng trắng được thiết lập. Sự khác biệt gần như không nhận thấy được.

## Các toán tử nhị phân và quan hệ do người dùng định nghĩa

Bạn có thể ép buộc khoảng cách dùng trong các toán tử nhị phân hoặc quan hệ, vì vậy bạn có thể [định nghĩa toán tử riêng của mình](/latex/vi/cac-lenh/01-commands.md).

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

[Mở ví dụ này trong 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)

Ví dụ này tạo ra kết quả sau:

![Định nghĩa toán tử nhị phân hoặc quan hệ của riêng bạn](/files/e0b8aaec9d0625973c02a36d3328cb03243fcf97)

Ví dụ trước thiết lập một khoảng cách cụ thể trước và sau `#` bằng cách sử dụng `\mathrel` (quan hệ) và `\mathbin` (nhị phân) các lệnh.

## Hướng dẫn tham khảo

**Mô tả các lệnh khoảng cách**

| Mã LaTeX                                    | Mô tả                                                                                           |
| ------------------------------------------- | ----------------------------------------------------------------------------------------------- |
| `\quad`                                     | khoảng trắng bằng với cỡ phông hiện tại (= 18 [mu](/latex/vi/dinh-dang/01-lengths-in-latex.md)) |
| `\,`                                        | 3/18 của `\quad` (= 3 mu)                                                                       |
| `\:`                                        | 4/18 của `\quad` (= 4 mu)                                                                       |
| `\;`                                        | 5/18 của `\quad` (= 5 mu)                                                                       |
| `\!`                                        | -3/18 của `\quad` (= -3 mu)                                                                     |
| `\` (khoảng trắng sau dấu gạch chéo ngược!) | tương đương với khoảng trắng trong văn bản thường                                               |
| `\qquad`                                    | gấp đôi `\quad` (= 36 mu)                                                                       |

## Đọc thêm

Để biết thêm thông tin, xem

* [Biểu thức toán học](/latex/vi/toan-hoc/01-mathematical-expressions.md)
* [Dấu ngoặc và ngoặc tròn](/latex/vi/toan-hoc/03-brackets-and-parentheses.md)
* [Căn chỉnh các phương trình bằng amsmath](/latex/vi/toan-hoc/06-aligning-equations-with-amsmath.md)
* [Kiểu hiển thị trong chế độ toán học](/latex/vi/toan-hoc/10-display-style-in-math-mode.md)
* [Danh sách các chữ cái Hy Lạp và ký hiệu toán học](/latex/vi/toan-hoc/11-list-of-greek-letters-and-math-symbols.md)
* [Phông chữ toán học](/latex/vi/toan-hoc/12-mathematical-fonts.md)
* [Phần giới thiệu về LaTeX2ε không quá ngắn](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/vi/toan-hoc/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.
