> 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/05-fractions-and-binomials.md).

# Phân số và nhị thức

## Giới thiệu

Bài viết này giải thích cách dàn trang các phân số và hệ số nhị thức, bắt đầu với ví dụ sau sử dụng [`amsmath` gói](https://ctan.org/pkg/amsmath?lang=en):

```latex
\documentclass{article}
\usepackage{amsmath}
\begin{document}
Hệ số nhị thức, \(\binom{n}{k}\), được định nghĩa bởi biểu thức:
\[
    \binom{n}{k} = \frac{n!}{k!(n-k)!}
\]
\end{document}
```

[Mở ví dụ này trong Overleaf.](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Fractions+and+Binomials\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bamsmath%7D%0A%5Cbegin%7Bdocument%7D%0AThe+binomial+coefficient%2C+%5C%28%5Cbinom%7Bn%7D%7Bk%7D%5C%29%2C+is+defined+by+the+expression%3A%0A%5C%5B%0A++++%5Cbinom%7Bn%7D%7Bk%7D+%3D+%5Cfrac%7Bn%21%7D%7Bk%21%28n-k%29%21%7D%0A%5C%5D%0A%5Cend%7Bdocument%7D)

Tính năng [`amsmath` gói](https://ctan.org/pkg/amsmath?lang=en) được nạp bằng cách thêm dòng sau vào phần tiền định của tài liệu:

```latex
\usepackage{amsmath}
```

Đây là kết quả được tạo ra:

![Hình ảnh cho thấy cách dàn trang LaTeX của hệ số nhị thức](/files/f9ff9c6a8f3128f981fdc42e0b9ce14b25f151e8)

## Hiển thị phân số

Hình thức hiển thị của các phân số sẽ thay đổi tùy theo việc chúng xuất hiện trong dòng, như một phần của một đoạn văn, hay được dàn trang như nội dung độc lập hiển thị trên dòng riêng. Ví dụ tiếp theo minh họa những thay đổi đó về hình thức hiển thị:

```latex
\documentclass{article}
% Sử dụng gói geometry để giảm
% chiều rộng của đồ họa trong bài viết trợ giúp
\usepackage[textwidth=8cm]{geometry}
\begin{document}
Phân số có thể được dùng trong dòng ngay trong văn bản đoạn, chẳng hạn
ví dụ \(\frac{1}{2}\), hoặc hiển thị trên dòng riêng,
như thế này:
\[\frac{1}{2}\]
\end{document}
```

[Mở ví dụ này trong Overleaf.](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Inline+and+display+of+fractions+and+binomials\&snip=%5Cdocumentclass%7Barticle%7D%0A%25+Using+the+geometry+package+to+reduce%0A%25+the+width+of+help+article+graphics%0A%5Cusepackage%5Btextwidth%3D8cm%5D%7Bgeometry%7D%0A%5Cbegin%7Bdocument%7D%0AFractions+can+be+used+inline+within+the+paragraph+text%2C+for+%0Aexample+%5C%28%5Cfrac%7B1%7D%7B2%7D%5C%29%2C+or+displayed+on+their+own+line%2C+%0Asuch+as+this%3A%0A%5C%5B%5Cfrac%7B1%7D%7B2%7D%5C%5D%0A%5Cend%7Bdocument%7D)

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

![Minh họa các chế độ toán học trong dòng và hiển thị trong LaTeX](/files/fab921602bdf1d7da50b78fd088bfbd585a3d0a9)

* **Lưu ý**: Thông tin thêm về các phiên bản toán học trong dòng và hiển thị có thể được tìm thấy trong bài viết Overleaf [Kiểu hiển thị trong chế độ toán học](/latex/vi/toan-hoc/10-display-style-in-math-mode.md).

Phân số ví dụ của chúng ta được dàn trang bằng `\frac` lệnh (`\frac{1}{2}`) có dạng tổng quát `\frac{*tử số*}{*mẫu số*}`.

## Phân số kiểu văn bản

Ví dụ sau minh họa việc dàn trang các phân số chỉ dùng văn bản bằng cách sử dụng `\text{...}` lệnh do `amsmath` gói. Tùy chọn `\text{...}` lệnh này được dùng để ngăn LaTeX dàn trang văn bản như nội dung toán học thông thường.

```latex
\documentclass{article}
% Sử dụng gói geometry để giảm
% chiều rộng của đồ họa trong bài viết trợ giúp
\usepackage[textwidth=8cm]{geometry}
\usepackage{amsmath}% For the \text{...} command
\begin{document}
Chúng ta dùng lệnh gói \texttt{amsmath}
\verb|\text{...}| để tạo các phân số chỉ dùng văn bản
như sau:

\[\frac{\text{tử số}}{\text{mẫu số}}\]

Không có lệnh \verb|\text{...}| thì kết quả
trông như sau:

\[\frac{tử số}{mẫu số}\]
\end{document}
```

[Mở ví dụ này trong Overleaf.](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Text+fractions\&snip=%5Cdocumentclass%7Barticle%7D%0A%25+Using+the+geometry+package+to+reduce%0A%25+the+width+of+help+article+graphics%0A%5Cusepackage%5Btextwidth%3D8cm%5D%7Bgeometry%7D%0A%5Cusepackage%7Bamsmath%7D%25+For+the+%5Ctext%7B...%7D+command%0A%5Cbegin%7Bdocument%7D%0AWe+use+the+%5Ctexttt%7Bamsmath%7D+package+command%0A%5Cverb%7C%5Ctext%7B...%7D%7C+to+create+text-only+fractions%0Alike+this%3A%0A%0A%5C%5B%5Cfrac%7B%5Ctext%7Bnumerator%7D%7D%7B%5Ctext%7Bdenominator%7D%7D%5C%5D%0A%0AWithout+the+%5Cverb%7C%5Ctext%7B...%7D%7C+command+the+result+%0Alooks+like+this%3A%0A%0A%5C%5B%5Cfrac%7Bnumerator%7D%7Bdenominator%7D%5C%5D%0A%5Cend%7Bdocument%7D)

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

![Phân số dạng văn bản](/files/ccd936afe36f574f49ae3e6c1fe1aa6dbe31b8de)

## Kích thước và khoảng cách trong toán học đã dàn trang

Kích thước và khoảng cách của nội dung toán học do LaTeX dàn trang [được xác định bởi các thuật toán](https://tug.org/TUGboat/tb27-1/tb86jackowski.pdf) áp dụng dữ liệu về kích thước và vị trí chứa trong các phông chữ dùng để dàn trang toán học.

Đôi khi, có thể cần hoặc muốn ghi đè các kiểu toán học mặc định—kích thước và khoảng cách của các phần tử toán học—do LaTeX chọn, một chủ đề được thảo luận trong bài viết trợ giúp Overleaf [Kiểu hiển thị trong chế độ toán học](/latex/vi/toan-hoc/10-display-style-in-math-mode.md#overriding-default-mathematical-styles).

Tóm lại, các kiểu mặc định dùng để dàn trang toán học có thể được thay đổi bằng các lệnh sau:

* `\textstyle`: áp dụng kiểu dùng cho toán học được dàn trang trong các đoạn văn;
* `\displaystyle`: áp dụng kiểu dùng cho toán học được dàn trang trên các dòng riêng;
* `\scriptstyle`: áp dụng kiểu dùng cho chỉ số dưới hoặc chỉ số trên;
* `\scriptscriptstyle`: áp dụng kiểu dùng cho chỉ số dưới hoặc chỉ số trên bậc hai;

được minh họa trong ví dụ tiếp theo.

```latex
\documentclass{article}
% Sử dụng gói geometry để giảm
% chiều rộng của đồ họa trong bài viết trợ giúp
\usepackage[textwidth=9.5cm]{geometry}
\begin{document}

Phân số được dàn trang trong một đoạn văn thường trông như thế này: \(\frac{3x}{2}\). Bạn có thể buộc \LaTeX{} dùng kiểu hiển thị lớn hơn, chẳng hạn \( \displaystyle \frac{3x}{2} \), điều này cũng ảnh hưởng đến khoảng cách dòng. Kích thước của toán học trong một đoạn văn cũng có thể được giảm xuống: \(\scriptstyle \frac{3x}{2}\) hoặc \(\scriptscriptstyle \frac{3x}{2}\). Với ví dụ \verb|\scriptscriptstyle|, hãy chú ý sự giảm khoảng cách: các ký tự được đưa gần hơn tới \textit{vinculum} (đường gạch phân số phân tách tử số và mẫu số).

Tương tự, bạn có thể thay đổi kiểu của toán học vốn thường được dàn trang theo kiểu hiển thị:

\[f(x)=\frac{P(x)}{Q(x)}\quad \textrm{và}\quad \textstyle f(x)=\frac{P(x)}{Q(x)}\quad \textrm{và}\quad \scriptstyle f(x)=\frac{P(x)}{Q(x)}\]
\end{document}
```

[Mở ví dụ này trong Overleaf](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Changing+default+math+styles\&snip=%5Cdocumentclass%7Barticle%7D%0A%25+Using+the+geometry+package+to+reduce%0A%25+the+width+of+help+article+graphics%0A%5Cusepackage%5Btextwidth%3D9.5cm%5D%7Bgeometry%7D%0A%5Cbegin%7Bdocument%7D%0A%0AFractions+typeset+within+a+paragraph+typically+look+like+this%3A+%5C%28%5Cfrac%7B3x%7D%7B2%7D%5C%29.+You+can+force+%5CLaTeX%7B%7D+to+use+the+larger+display+style%2C+such+as+%5C%28+%5Cdisplaystyle+%5Cfrac%7B3x%7D%7B2%7D+%5C%29%2C+which+also+has+an+effect+on+line+spacing.+The+size+of+maths+in+a+paragraph+can+also+be+reduced%3A+%5C%28%5Cscriptstyle+%5Cfrac%7B3x%7D%7B2%7D%5C%29+or+%5C%28%5Cscriptscriptstyle+%5Cfrac%7B3x%7D%7B2%7D%5C%29.+For+the+%5Cverb%7C%5Cscriptscriptstyle%7C+example+note+the+reduction+in+spacing%3A+characters+are+moved+closer+to+the+%5Ctextit%7Bvinculum%7D+%28the+line+separating+numerator+and+denominator%29.%0A%0AEqually%2C+you+can+change+the+style+of+mathematics+normally+typeset+in+display+style%3A%0A%0A%5C%5Bf%28x%29%3D%5Cfrac%7BP%28x%29%7D%7BQ%28x%29%7D%5Cquad+%5Ctextrm%7Band%7D%5Cquad+%5Ctextstyle+f%28x%29%3D%5Cfrac%7BP%28x%29%7D%7BQ%28x%29%7D%5Cquad+%5Ctextrm%7Band%7D%5Cquad+%5Cscriptstyle+f%28x%29%3D%5Cfrac%7BP%28x%29%7D%7BQ%28x%29%7D%5C%5D%0A%5Cend%7Bdocument%7D)

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

![Hình ảnh cho thấy các thay đổi đối với kiểu toán học mặc định của LaTeX](/files/c0a78e9abfe9cf5ce4ca61a6946cf564355bec8e)

## Phân số liên tục

Phân số có thể lồng nhau để có được các biểu thức phức tạp hơn. Cặp phân số thứ hai được hiển thị trong ví dụ sau đều dùng `\cfrac` lệnh, được thiết kế đặc biệt để tạo ra các phân số liên tục. Để sử dụng `\cfrac` bạn phải nạp [`amsmath` gói](https://ctan.org/pkg/amsmath?lang=en) trong phần tiền định của tài liệu.

```latex
\documentclass{article}
% Sử dụng gói geometry để giảm
% chiều rộng của đồ họa trong bài viết trợ giúp
\usepackage[textwidth=9.5cm]{geometry}
% Nạp amsmath để truy cập lệnh \cfrac{...}{...}
\usepackage{amsmath}
\begin{document}
Phân số có thể lồng nhau nhưng, trong ví dụ này, hãy lưu ý rằng các kiểu toán học mặc định, như được dùng trong mẫu số, không cho kết quả lý tưởng...

\[ \frac{1+\frac{a}{b}}{1+\frac{1}{1+\frac{1}{a}}} \]

\noindent ...vì vậy chúng ta dùng \verb|\displaystyle| để cải thiện cách dàn trang:

\[ \frac{1+\frac{a}{b}} {\displaystyle 1+\frac{1}{1+\frac{1}{a}}} \]

Đây là một ví dụ sử dụng lệnh \texttt{amsmath} \verb|\cfrac|:

\[
  a_0+\cfrac{1}{a_1+\cfrac{1}{a_2+\cfrac{1}{a_3+\cdots}}}
\]

Đây là một ví dụ khác, được lấy từ tài liệu \texttt{amsmath}, minh họa việc căn trái
và căn phải của tử số bằng cách dùng lần lượt \verb|\cfrac[l]| và \verb|\cfrac[r]|:
\[
\cfrac[l]{1}{\sqrt{2}+
\cfrac[r]{1}{\sqrt{2}+
\cfrac{1}{\sqrt{2}+\dotsb}}}
\]
\end{document}
```

[Mở ví dụ này trong Overleaf.](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Example+of+continued+fractions\&snip=%5Cdocumentclass%7Barticle%7D%0A%25+Using+the+geometry+package+to+reduce%0A%25+the+width+of+help+article+graphics%0A%5Cusepackage%5Btextwidth%3D9.5cm%5D%7Bgeometry%7D%0A%25+Load+amsmath+to+access+the+%5Ccfrac%7B...%7D%7B...%7D+command%0A%5Cusepackage%7Bamsmath%7D%0A%5Cbegin%7Bdocument%7D%0AFractions+can+be+nested+but%2C+in+this+example%2C+note+how+the+default+math+styles%2C+as+used+in+the+denominator%2C+don%27t+produce+ideal+results...%0A%0A%5C%5B+%5Cfrac%7B1%2B%5Cfrac%7Ba%7D%7Bb%7D%7D%7B1%2B%5Cfrac%7B1%7D%7B1%2B%5Cfrac%7B1%7D%7Ba%7D%7D%7D+%5C%5D%0A%0A%5Cnoindent+...so+we+use+%5Cverb%7C%5Cdisplaystyle%7C+to+improve+typesetting%3A%0A%0A%5C%5B+%5Cfrac%7B1%2B%5Cfrac%7Ba%7D%7Bb%7D%7D+%7B%5Cdisplaystyle+1%2B%5Cfrac%7B1%7D%7B1%2B%5Cfrac%7B1%7D%7Ba%7D%7D%7D+%5C%5D%0A%0AHere+is+an+example+which+uses+the+%5Ctexttt%7Bamsmath%7D+%5Cverb%7C%5Ccfrac%7C+command%3A%0A%0A%5C%5B%0A++a_0%2B%5Ccfrac%7B1%7D%7Ba_1%2B%5Ccfrac%7B1%7D%7Ba_2%2B%5Ccfrac%7B1%7D%7Ba_3%2B%5Ccdots%7D%7D%7D%0A%5C%5D%0A%0AHere+is+another+example%2C+derived+from+the+%5Ctexttt%7Bamsmath%7D+documentation%2C+which+demonstrates+left%0Aand+right+placement+of+the+numerator+using+%5Cverb%7C%5Ccfrac%5Bl%5D%7C+and+%5Cverb%7C%5Ccfrac%5Br%5D%7C+respectively%3A%0A%5C%5B%0A%5Ccfrac%5Bl%5D%7B1%7D%7B%5Csqrt%7B2%7D%2B%0A%5Ccfrac%5Br%5D%7B1%7D%7B%5Csqrt%7B2%7D%2B%0A%5Ccfrac%7B1%7D%7B%5Csqrt%7B2%7D%2B%5Cdotsb%7D%7D%7D%0A%5C%5D%0A%5Cend%7Bdocument%7D)

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

![Đồ họa minh họa các phân số lồng nhau được dàn trang bằng LaTeX](/files/1e030dd0b1e23fd70b6cac8f8865b2dc8b83150d)

## Một ví dụ cuối cùng

Ví dụ này minh họa một phân số liên tục phức tạp hơn:

```latex
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\newcommand*{\contfrac}[2]{%
{
  \rlap{$\dfrac{1}{\phantom{#1}}$}%
  \genfrac{}{}{0pt}{0}{}{#1+#2}%
}
}
\[
  a_0 +
  \contfrac{a_1}{
  \contfrac{a_2}{
  \contfrac{a_3}{
  \genfrac{}{}{0pt}{0}{}{\ddots}
  }}}
\]

\end{document}
```

[Mở ví dụ này trong Overleaf.](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=A+more+complex+continued+fraction\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bamsmath%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cnewcommand%2A%7B%5Ccontfrac%7D%5B2%5D%7B%25%0A%7B%0A++%5Crlap%7B%24%5Cdfrac%7B1%7D%7B%5Cphantom%7B%231%7D%7D%24%7D%25%0A++%5Cgenfrac%7B%7D%7B%7D%7B0pt%7D%7B0%7D%7B%7D%7B%231%2B%232%7D%25%0A%7D%0A%7D%0A%5C%5B%0A++a_0+%2B%0A++%5Ccontfrac%7Ba_1%7D%7B%0A++%5Ccontfrac%7Ba_2%7D%7B%0A++%5Ccontfrac%7Ba_3%7D%7B%0A++%5Cgenfrac%7B%7D%7B%7D%7B0pt%7D%7B0%7D%7B%7D%7B%5Cddots%7D%0A++%7D%7D%7D%0A%5C%5D%0A%0A%5Cend%7Bdocument%7D)

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

![Hình ảnh của phân số liên tục nâng cao được dàn trang bằng LaTeX](/files/8ac6743534163a206a2eacb71aa4a575b7a38c98)

## Đọ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)
* [Chỉ số dưới và chỉ số trên](/latex/vi/toan-hoc/02-subscripts-and-superscripts.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)
* [Các toán tử](/latex/vi/toan-hoc/07-operators.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/05-fractions-and-binomials.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.
