> 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/akhtaa-latex/16-latex-error-missing-begin-document.md).

# خطأ LaTeX: \begin document مفقود

يظهر هذا الخطأ عندما تنسى تضمين **`\begin{document}`** في مستندك. وقد يظهر أيضًا إذا لم تكتب **`\documentclass[...]{...}`** في بداية مستندك الرئيسي.

## الأسباب الشائعة

**نسيان تضمين \begin{document}:**

يحدث السبب الأساسي لهذا الخطأ عندما تنسى كتابة **`\begin{document}`** بعد المقدمة في مستندك الرئيسي. إذا ارتكبت هذا الخطأ، فستظهر لك رسالة الخطأ الموضحة أدناه:

main.tex، السطر 5

خطأ LaTeX: ‏\begin{document} مفقود.

راجع دليل LaTeX أو LaTeX Companion للتفسير. اكتب H للحصول على مساعدة فورية. ... أنت في ورطة هنا. حاول الكتابة للمتابعة. إذا لم ينجح ذلك، فاكتب X للخروج.

لحل هذا الخطأ، ما عليك سوى التأكد من أنك قد أدرجت **`\begin{document}`** بعد المقدمة في مستندك الرئيسي. راجع [هنا](/latex/ar/asasyat-latex/01-learn-latex-in-30-minutes.md) للتعرّف على المزيد حول كيفية هيكلة المستندات في LaTeX.

**\documentclass\[...]{...} في المكان الخطأ:**

سبب شائع آخر لهذا الخطأ هو إذا **`\documentclass[...]{...}`** مكتوبة في المكان الخطأ. يجب أن تُكتب في بداية المستند الرئيسي. إذا كان لديك ملف منفصل للمقدمة، فلا يمكنك **لا يمكنك** تضمين **`\documentclass[...]{...}`** في ذلك الملف. يجب أن تظهر مع ذلك في أعلى ملف المشروع الرئيسي، وإلا فسيتم تجميع ملف المقدمة فقط.

**تم تعيين المستند الرئيسي بشكل غير صحيح:**

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

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

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

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


---

# 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/akhtaa-latex/16-latex-error-missing-begin-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.
