> 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/06-aligning-equations-with-amsmath.md).

# محاذاة المعادلات

## مقدمة

ال `amsmath` توفّر الحزمة مجموعة من الخيارات لعرض المعادلات. يمكنك اختيار التخطيط الذي يناسب مستندك بشكل أفضل، حتى لو كانت المعادلات طويلة جدًا، أو إذا كان عليك تضمين عدة معادلات في السطر نفسه.

قد تفتقر أدوات LaTeX القياسية للمعادلات إلى بعض المرونة، مما يؤدي إلى تداخل أو حتى اقتطاع جزء من المعادلة عندما تكون طويلة جدًا. يمكننا تجاوز مثل هذه الصعوبات باستخدام `amsmath` الحزمة، والتي يمكن إضافتها إلى مقدمة مستندك باستخدام `\usepackage{amsmath}`.

لنبدأ بمثال بسيط:

```latex
\begin{equation} \label{eq1}
\begin{split}
A & = \frac{\pi r^2}{2} \\
 & = \frac{1}{2} \pi r^2
\end{split}
\end{equation}
```

[افتح هذا `amsmath` المقتطف في Overleaf](https://www.overleaf.com/docs?engine=\&snip_name=amsmath+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bamsmath%7D%0A%5Ctitle%7BAmsmath+example%7D%0A%5Cauthor%7BOverleaf%7D%0A%5Cdate%7BMay+2021%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cmaketitle%0A%5Csection%7BIntroduction%7D%0A%5Cbegin%7Bequation%7D+%5Clabel%7Beq1%7D%0A%5Cbegin%7Bsplit%7D%0AA+%26+%3D+%5Cfrac%7B%5Cpi+r%5E2%7D%7B2%7D+%5C%5C%0A+%26+%3D+%5Cfrac%7B1%7D%7B2%7D+%5Cpi+r%5E2%0A%5Cend%7Bsplit%7D%0A%5Cend%7Bequation%7D%0A%5Cend%7Bdocument%7D)

يوضح الرسم التالي الناتج الذي ينتجه كود LaTeX:

![Amsmath-eqn1.png](/files/7c3c4f428c795ad474930339d09815375054b5af)

عليك أن تضع معادلتك داخل `equation` البيئة إذا كنت تريد أن تكون مرقمة، واستخدم `equation*` (مع نجمة) خلاف ذلك. داخل `equation` البيئة، استخدم `split` البيئة لتقسيم المعادلات إلى أجزاء أصغر، وستتم محاذاة هذه الأجزاء الأصغر وفقًا لذلك. يعمل الرمز المزدوج للشرطة المائلة العكسية كسطر جديد. استخدم الرمز & `&`، لتحديد النقاط التي تتم فيها محاذاة المعادلات عموديًا.

## كتابة معادلة واحدة

لعرض معادلة واحدة، كما ذُكر في المقدمة، عليك استخدام `equation*` أو `equation` البيئة، وذلك حسب ما إذا كنت تريد أن تكون المعادلة مرقمة أم لا. بالإضافة إلى ذلك، يمكنك إضافة تسمية للرجوع إليها لاحقًا داخل المستند.

```latex
\begin{equation} \label{eu_eqn}
e^{\pi i} + 1 = 0
\end{equation}

المعادلة الجميلة \ref{eu_eqn} تُعرف باسم معادلة أويلر.
```

[افتح هذا `amsmath` المقتطف في Overleaf](https://www.overleaf.com/docs?engine=\&snip_name=amsmath+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bamsmath%7D%0A%5Ctitle%7BAmsmath+example%7D%0A%5Cauthor%7BOverleaf%7D%0A%5Cdate%7BMay+2021%7D%0A%5Cbegin%7Bdocument%7D%0A%25%5Cmaketitle%0A%25%5Csection%7BIntroduction%7D%0A%5Cbegin%7Bequation%7D+%5Clabel%7Beu_eqn%7D%0Ae%5E%7B%5Cpi+i%7D+%2B+1+%3D+0%0A%5Cend%7Bequation%7D%0A%0AThe+beautiful+equation+%5Cref%7Beu_eqn%7D+is+known+as+the+Euler+equation.%0A%5Cend%7Bdocument%7D)

يوضح الرسم التالي الناتج الذي ينتجه كود LaTeX:

![Neweuler1.png](/files/d1813b74a2e6a8ac806c650a620b129dbda20fef)

يمكنك أيضًا [افتح مثالًا أكثر اكتمالًا لـ `amsmath` الحزمة في Overleaf.](https://www.overleaf.com/project/new/template/19716?id=66719097\&templateName=Amsmath+example\&latexEngine=pdflatex\&texImage=texlive-full%3A2020.1\&mainFile=)

## عرض المعادلات الطويلة

بالنسبة إلى المعادلات الأطول من سطر واحد، استخدم `multline` البيئة. أدخل شرطة مائلة عكسية مزدوجة لتحديد نقطة تقسيم المعادلة. سيُحاذى الجزء الأول إلى اليسار، وسيُعرض الجزء الثاني في السطر التالي ومحاذيًا إلى اليمين.

مرة أخرى، يحدد استخدام النجمة \* في اسم البيئة ما إذا كانت المعادلة مرقمة أم لا.

```latex
\begin{multline*}
p(x) = 3x^6 + 14x^5y + 590x^4y^2 + 19x^3y^3\\
- 12x^2y^4 - 12xy^5 + 2y^6 - a^3b^3
\end{multline*}
```

[افتح هذه المعادلة متعددة الأسطر `amsmath` المقتطف في Overleaf](https://www.overleaf.com/docs?engine=\&snip_name=amsmath+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bamsmath%7D%0A%5Ctitle%7BAmsmath+example%7D%0A%5Cauthor%7BOverleaf%7D%0A%5Cdate%7BMay+2021%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cmaketitle%0A%5Csection%7BIntroduction%7D%0A%5Cbegin%7Bmultline%2A%7D%0Ap%28x%29+%3D+3x%5E6+%2B+14x%5E5y+%2B+590x%5E4y%5E2+%2B+19x%5E3y%5E3%5C%5C+%0A-+12x%5E2y%5E4+-+12xy%5E5+%2B+2y%5E6+-+a%5E3b%5E3%0A%5Cend%7Bmultline%2A%7D%0A%5Cend%7Bdocument%7D)

يوضح الرسم التالي الناتج الذي ينتجه كود LaTeX:

![Amsmath-eqn3.png](/files/051127dc52c69e50468c3895a6745d9243ba9bf3)

يمكنك أيضًا [افتح مثالًا أكثر اكتمالًا لـ `amsmath` الحزمة في Overleaf.](https://www.overleaf.com/project/new/template/19716?id=66719097\&templateName=Amsmath+example\&latexEngine=pdflatex\&texImage=texlive-full%3A2020.1\&mainFile=)

## تقسيم ومحاذاة معادلة

*Split* يشبه إلى حد كبير *multline*. استخدم *split* البيئة لتقسيم معادلة ومحاذاتها في أعمدة، كما لو كانت أجزاء المعادلة داخل جدول. يجب استخدام هذه البيئة داخل *equation* البيئة. وللاطلاع على مثال، راجع مقدمة هذا المستند.

## محاذاة عدة معادلات

إذا كانت هناك عدة معادلات تحتاج إلى محاذاتها عموديًا، فإن *align* البيئة ستفعل ذلك:

```latex
\begin{align*}
2x - 5y &=  8 \\
3x + 9y &=  -12
\end{align*}
```

[افتح هذا `amsmath` المقتطف في Overleaf](https://www.overleaf.com/docs?engine=\&snip_name=amsmath+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bamsmath%7D%0A%5Ctitle%7BAmsmath+example%7D%0A%5Cauthor%7BOverleaf%7D%0A%5Cdate%7BMay+2021%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cmaketitle%0A%5Csection%7BIntroduction%7D%0A%5Cbegin%7Balign%2A%7D+%0A2x+-+5y+%26%3D++8+%5C%5C+%0A3x+%2B+9y+%26%3D++-12%0A%5Cend%7Balign%2A%7D%0A%5Cend%7Bdocument%7D)

يوضح الرسم التالي الناتج الذي ينتجه كود LaTeX:

![Amsmatheqn4OLV2.png](/files/b9b7fb69797cdc9c6bd558d94637ba9eb7adc9b6)

عادةً ما تكون المعاملات الثنائية (`>`, `<` و `=`) هي التي تتم محاذاتها للحصول على مستند بمظهر جميل.

كما ذُكر سابقًا، فإن الرمز & `&` يحدد مواضع محاذاة المعادلات. لنلقِ نظرة على مثال أكثر تعقيدًا:

```latex
\begin{align*}
x&=y           &  w &=z              &  a&=b+c\\
2x&=-y         &  3w&=\frac{1}{2}z   &  a&=b\\
-4 + 5x&=2+y   &  w+2&=-1+w          &  ab&=cb
\end{align*}
```

[افتح هذا `amsmath` المقتطف في Overleaf](https://www.overleaf.com/docs?engine=\&snip_name=amsmath+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bamsmath%7D%0A%5Ctitle%7BAmsmath+example%7D%0A%5Cauthor%7BOverleaf%7D%0A%5Cdate%7BMay+2021%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cmaketitle%0A%5Csection%7BIntroduction%7D%0A%5Cbegin%7Balign%2A%7D%0Ax%26%3Dy+++++++++++%26++w+%26%3Dz++++++++++++++%26++a%26%3Db%2Bc%5C%5C%0A2x%26%3D-y+++++++++%26++3w%26%3D%5Cfrac%7B1%7D%7B2%7Dz+++%26++a%26%3Db%5C%5C%0A-4+%2B+5x%26%3D2%2By+++%26++w%2B2%26%3D-1%2Bw++++++++++%26++ab%26%3Dcb%0A%5Cend%7Balign%2A%7D%0A%5Cend%7Bdocument%7D)

يوضح الرسم التالي الناتج الذي ينتجه كود LaTeX:

![Amsmath-eqn6OLV2.png](/files/b0f9e7f6c96397f43fcbff27d0a80e2de1a95299)

هنا نرتب المعادلات في ثلاثة أعمدة. يفترض LaTeX أن كل معادلة تتكوّن من جزأين يفصل بينهما `&` وأن كل معادلة مفصولة عن السابقة بواسطة `&`.

مرة أخرى، استخدم \* للتبديل بين ترقيم المعادلة وعدم ترقيمها. عندما يكون الترقيم مسموحًا، يمكنك وضع تسمية لكل سطر على حدة.

## تجميع المعادلات وتوسيطها

إذا كنت تحتاج فقط إلى عرض مجموعة من المعادلات المتتالية، في وسط الصفحة ومن دون أي محاذاة على الإطلاق، فاستخدم `gather` البيئة. كما يعمل هنا أيضًا أسلوب النجمة لتفعيل/إلغاء تفعيل ترقيم المعادلات.

```latex
\begin{gather*}
2x - 5y =  8 \\
3x^2 + 9y =  3a + c
\end{gather*}
```

[افتح هذا `amsmath` المقتطف في Overleaf](https://www.overleaf.com/docs?engine=\&snip_name=amsmath+example\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%7Bamsmath%7D%0A%5Ctitle%7BAmsmath+example%7D%0A%5Cauthor%7BOverleaf%7D%0A%5Cdate%7BMay+2021%7D%0A%5Cbegin%7Bdocument%7D%0A%5Cmaketitle%0A%5Csection%7BIntroduction%7D%0A%5Cbegin%7Bgather%2A%7D+%0A2x+-+5y+%3D++8+%5C%5C+%0A3x%5E2+%2B+9y+%3D++3a+%2B+c%0A%5Cend%7Bgather%2A%7D%0A%5Cend%7Bdocument%7D)

يوضح الرسم التالي الناتج الذي ينتجه كود LaTeX:

![Amsmath-eqn5.png](/files/95116a806a9c11426f1a7389c68038ad744a84e3)

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

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

* [التعابير الرياضية](/latex/ar/alryadhyat/01-mathematical-expressions.md)
* [الأقواس والقوسان](/latex/ar/alryadhyat/03-brackets-and-parentheses.md)
* [الأسس السفلية والعليا](/latex/ar/alryadhyat/02-subscripts-and-superscripts.md)
* [التباعد في وضع الرياضيات](/latex/ar/alryadhyat/08-spacing-in-math-mode.md)
* [النمط المعروض في وضع الرياضيات](/latex/ar/alryadhyat/10-display-style-in-math-mode.md)
* [الخطوط الرياضية](/latex/ar/alryadhyat/12-mathematical-fonts.md)
* [قائمة الحروف اليونانية والرموز الرياضية](/latex/ar/alryadhyat/11-list-of-greek-letters-and-math-symbols.md)
* [المؤثرات](/latex/ar/alryadhyat/07-operators.md)
* [الكسور والحدود الثنائية](/latex/ar/alryadhyat/05-fractions-and-binomials.md)
* [توثيق حزمة amsmath](http://mirrors.ctan.org/macros/latex/required/amsmath/amsmath.pdf)


---

# 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/06-aligning-equations-with-amsmath.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.
