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

# الكسور والثنائيات

## مقدمة

تشرح هذه المقالة كيفية تنضيد الكسور ومعاملات ثنائي الحدين، بدءًا بالمثال التالي الذي يستخدم [`amsmath` الحزمة](https://ctan.org/pkg/amsmath?lang=en):

```latex
\documentclass{article}
\usepackage{amsmath}
\begin{document}
يُعرَّف معامل ثنائي الحدين، \(\binom{n}{k}\)، بالصيغة:
\[
    \binom{n}{k} = \frac{n!}{k!(n-k)!}
\]
\end{document}
```

[افتح هذا المثال في 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)

ال [`amsmath` الحزمة](https://ctan.org/pkg/amsmath?lang=en) يُحمَّل بإضافة السطر التالي إلى مقدمة المستند:

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

هذا هو الناتج المُنتَج:

![صورة تُظهر تنضيد LaTeX لمعامل ثنائي الحدين](/files/56a62fefbe48a590daee8ff135b52fbdc793391e)

## عرض الكسور

يتغير المظهر البصري للكسور بحسب ما إذا ظهرت ضمن السطر، أو كجزء من فقرة، أو نُضِّدت كمادة مستقلة معروضة في سطر خاص بها. يوضح المثال التالي هذه التغييرات في المظهر البصري:

```latex
\documentclass{article}
% استخدام حزمة geometry لتقليل
% عرض رسومات مقال المساعدة
\usepackage[textwidth=8cm]{geometry}
\begin{document}
يمكن استخدام الكسور ضمن السطر داخل نص الفقرة، على سبيل
المثال \(\frac{1}{2}\)، أو عرضها في سطر مستقل،
مثل هذا:
\[\frac{1}{2}\]
\end{document}
```

[افتح هذا المثال في 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)

ينتج هذا المثال المخرجات التالية:

![عرض أوضاع الرياضيات المضمنة والمستقلة في LaTeX](/files/300e755461f2bcd794aefed395dd1f7bfb500a1f)

* **ملاحظة**: يمكن العثور على مزيد من المعلومات حول النسخ المضمنة ونسخ العرض من الرياضيات في مقال Overleaf [النمط المعروض في وضع الرياضيات](/latex/ar/alryadhyat/10-display-style-in-math-mode.md).

يُضبَط مثال الكسر لدينا باستخدام `\frac` الأمر (`\frac{1}{2}`) الذي له الشكل العام `\frac{*البسط*}{*المقام*}`.

## كسور بأسلوب النص

يوضح المثال التالي تنضيد الكسور النصية فقط باستخدام `\text{...}` الأمر الموفَّر من `amsmath` ، `\text{...}` يُستخدم هذا الأمر لمنع LaTeX من تنضيد النص كمحتوى رياضي عادي.

```latex
\documentclass{article}
% استخدام حزمة geometry لتقليل
% عرض رسومات مقال المساعدة
\usepackage[textwidth=8cm]{geometry}
\usepackage{amsmath}% للأمر \text{...}
\begin{document}
نستخدم أمر الحزمة \texttt{amsmath}
\verb|\text{...}| لإنشاء كسور نصية فقط
بهذا الشكل:

\[\frac{\text{numerator}}{\text{denominator}}\]

من دون الأمر \verb|\text{...}| تكون النتيجة
تبدو هكذا:

\[\frac{numerator}{denominator}\]
\end{document}
```

[افتح هذا المثال في 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)

ينتج هذا المثال المخرجات التالية:

![كسور نصية](/files/2977a7bc763dc57271672906c8384aa7ed2410dd)

## الحجم والتباعد داخل الرياضيات المنضدة

يُحدَّد حجم وتباعد المادة الرياضية التي ينضدها LaTeX [بواسطة خوارزميات](https://tug.org/TUGboat/tb27-1/tb86jackowski.pdf) تطبّق بيانات الحجم والموضع الموجودة داخل الخطوط المستخدمة في تنضيد الرياضيات.

قد يكون من الضروري، أو من المستحسن أحيانًا، تجاوز الأنماط الرياضية الافتراضية — حجم وعرض عناصر الرياضيات — التي يختارها LaTeX، وهو موضوع نوقش في مقال مساعدة Overleaf [النمط المعروض في وضع الرياضيات](/latex/ar/alryadhyat/10-display-style-in-math-mode.md#overriding-default-mathematical-styles).

خلاصة القول، يمكن تغيير النمط الافتراضي/الأنماط الافتراضية المستخدمة لتنضيد الرياضيات بواسطة الأوامر التالية:

* `\textstyle`: تطبّق النمط المستخدم للرياضيات المنضدة داخل الفقرات؛
* `\displaystyle`: تطبّق النمط المستخدم للرياضيات المنضدة في أسطر مستقلة؛
* `\scriptstyle`: تطبّق النمط المستخدم للرموز السفلية أو العلوية؛
* `\scriptscriptstyle`: تطبّق النمط المستخدم للرموز السفلية أو العلوية من الدرجة الثانية؛

والتي تُعرض في المثال التالي.

```latex
\documentclass{article}
% استخدام حزمة geometry لتقليل
% عرض رسومات مقال المساعدة
\usepackage[textwidth=9.5cm]{geometry}
\begin{document}

تبدو الكسور المنضدة داخل فقرة عادةً هكذا: \(\frac{3x}{2}\). يمكنك إجبار \LaTeX{} على استخدام نمط العرض الأكبر، مثل \( \displaystyle \frac{3x}{2} \)، وهو ما يؤثر أيضًا في تباعد الأسطر. ويمكن أيضًا تقليل حجم الرياضيات داخل فقرة: \(\scriptstyle \frac{3x}{2}\) أو \(\scriptscriptstyle \frac{3x}{2}\). وفي مثال \verb|\scriptscriptstyle|، لاحظ تقليل التباعد: إذ تُقرَّب الأحرف من \textit{vinculum} (الخط الفاصل بين البسط والمقام).

وبالمثل، يمكنك تغيير نمط الرياضيات المنضدة عادةً بأسلوب العرض:

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

[افتح هذا المثال في 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)

ينتج هذا المثال المخرجات التالية:

![صورة تُظهر تغييرات أنماط الرياضيات الافتراضية في LaTeX](/files/53ca3689efe7077283406d75af7bb290751a0ee6)

## الكسور المتواصلة

يمكن تضمين الكسور داخل بعضها للحصول على تعبيرات أكثر تعقيدًا. يستخدم زوج الكسور الثاني المعروض في المثال التالي كلاهما `\cfrac` الأمر، وهو مُصمَّم خصيصًا لإنتاج الكسور المتواصلة. لاستخدام `\cfrac` هذا الأمر عليك تحميل [`amsmath` الحزمة](https://ctan.org/pkg/amsmath?lang=en) في مقدمة المستند.

```latex
\documentclass{article}
% استخدام حزمة geometry لتقليل
% عرض رسومات مقال المساعدة
\usepackage[textwidth=9.5cm]{geometry}
% تحميل amsmath للوصول إلى الأمر \cfrac{...}{...}
\usepackage{amsmath}
\begin{document}
يمكن تضمين الكسور داخل بعضها، لكن في هذا المثال، لاحظ كيف أن الأنماط الرياضية الافتراضية، كما تُستخدم في المقام، لا تعطي نتائج مثالية...

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

\noindent ...لذلك نستخدم \verb|\displaystyle| لتحسين التنضيد:

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

هذا مثال يستخدم أمر \texttt{amsmath} \verb|\cfrac|:

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

هذا مثال آخر، مستمد من توثيق \texttt{amsmath}، يوضح المحاذاة إلى اليسار
وإلى اليمين للبسط باستخدام \verb|\cfrac[l]| و\verb|\cfrac[r]| على التوالي:
\[
\cfrac[l]{1}{\sqrt{2}+
\cfrac[r]{1}{\sqrt{2}+
\cfrac{1}{\sqrt{2}+\dotsb}}}
\]
\end{document}
```

[افتح هذا المثال في 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)

ينتج هذا المثال المخرجات التالية:

![رسم يوضح الكسور المتداخلة المنضدة في LaTeX](/files/aa92d5f6c07c2422bf95dd14fa2ea345debfae16)

## مثال أخير

يوضح هذا المثال كسرًا متواصلًا أكثر تعقيدًا:

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

[افتح هذا المثال في 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)

ينتج هذا المثال المخرجات التالية:

![صورة لكسر متواصل متقدم منضد بواسطة LaTeX](/files/5c50feeaf6db453f2ecf9922abc191709b5c1570)

## قراءة إضافية

لمزيد من المعلومات، انظر:

* [التعابير الرياضية](/latex/ar/alryadhyat/01-mathematical-expressions.md)
* [الأسس السفلية والعليا](/latex/ar/alryadhyat/02-subscripts-and-superscripts.md)
* [الأقواس والقوسان](/latex/ar/alryadhyat/03-brackets-and-parentheses.md)
* [محاذاة المعادلات باستخدام amsmath](/latex/ar/alryadhyat/06-aligning-equations-with-amsmath.md)
* [المؤثرات](/latex/ar/alryadhyat/07-operators.md)
* [الخطوط الرياضية](/latex/ar/alryadhyat/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/ar/alryadhyat/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.
