> 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/qaadh-almarfh/127-set-main-document.md).

# تعيين المستند الرئيسي

المستند الرئيسي في Overleaf هو الملف الذي سيُطلب من LaTeX تجميعه أولًا. وهو الملف الرئيسي للمشروع، والذي ستُدرَج فيه جميع الأجزاء الأخرى (الأصناف، الحزم، الفصول، إلخ). وعندما لا يتم ضبط هذا يدويًا، سيختار Overleaf مستندًا في المشروع يتضمن **`\documentclass[...]{...}`** الأمر. ولهذا السبب، إذا كان لديك ملف منفصل للمقدمة، فمن الأفضل عدم تضمين **`\documentclass[...]{...}`** الأمر في ملف المقدمة، بل في بداية المستند الرئيسي. إذا لم تفعل ذلك، فلن يُجمَّع سوى المقدمة. لتعيين المستند الرئيسي في مشروع، ما عليك سوى النقر على القائمة في الزاوية العلوية اليسرى:

![Lefthandmenu.PNG](/files/3c80b05ba3f8625eb8cbd1e8ebe38133bef94dca)

ثم انتقل إلى **المستند الرئيسي**:

![Maindocument.PNG](/files/32836dbf41c4068bb1bbc3ac0a7d9de5383e0ccf)

انظر [هنا](/latex/ar/bnyh-almstnd/07-management-in-a-large-project.md) للتعرّف على المزيد حول إدارة المشاريع الكبيرة في LaTeX.

## تجميع عدة مستندات في المشروع نفسه

لتمكينك من تجميع مستندات مختلفة بسرعة في المشروع نفسه، سيقوم Overleaf بتجميع أي ملف يكون مفتوحًا في المحرر باعتباره المستند الرئيسي بمجرد أن يتضمن **`\documentclass[...]{...}`** الأمر. وهذا مفيد بشكل خاص عند التحرير باستخدام [**`subfiles`** الحزمة](/latex/ar/bnyh-almstnd/08-multi-file-latex-projects.md#the-subfiles-package).

## مشكلات في اختيار الملف الرئيسي

يجب أن يكون الملف الرئيسي دائمًا في الدليل الجذري (خارج أي مجلدات)، لضمان تنفيذ جميع خطوات التجميع في الدليل الصحيح ولضمان توفر الملفات المساعدة المطلوبة، على سبيل المثال، عند [إضافة فهرس](/latex/ar/bnyh-almstnd/04-indices.md). انظر بعض النصائح حول إعادة تنظيم مشروعك للتجميع على Overleaf [هنا](/latex/ar/alaselh-walajwbh/77-my-main-file-is-in-a-subfolder-but-this-is-not-allowed-on-overleaf.-but-i-don-t-want-to-change-my.md).

إذا كان الملف الرئيسي المحدد موجودًا داخل مجلد ويوجد ملف بالاسم نفسه في الدليل الجذري، فسيتم تجميع الملف الذي يحمل ذلك الاسم في الدليل الجذري بدلًا من الملف المحدد. على سبيل المثال، إذا `version1/main.tex` مُعيَّنًا كملف رئيسي ولكن `main.tex` كان موجودًا أيضًا في المشروع، `main.tex` فسيُجمَّع. وتعود هذه المشكلة إلى الطريقة التي يُشغَّل بها Latexmk على Overleaf. ولتجنب المشكلات الناتجة عن ذلك، امنح أي ملفات تريد تجميعها على Overleaf اسمًا فريدًا.


---

# 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/qaadh-almarfh/127-set-main-document.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.
