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

# Error de LaTeX: falta \begin{document}

Este error aparece cuando has olvidado incluir **`\begin{document}`** en tu documento. También puede aparecer si no has escrito **`\documentclass[...]{...}`** al principio de tu documento principal.

## Causas comunes

**Olvidar incluir \begin{document}:**

La causa más básica de este error ocurre cuando has olvidado escribir **`\begin{document}`** después del preámbulo en tu documento principal. Si cometes este error, generarás el mensaje de error que se muestra a continuación:

main.tex, línea 5

Error de LaTeX: falta \begin{document}.

Consulta el manual de LaTeX o LaTeX Companion para una explicación. Escribe H para obtener ayuda inmediata. ... Aquí estás en apuros. Intenta escribir para continuar. Si eso no funciona, escribe X para salir.

Para resolver este error, simplemente asegúrate de que has incluido **`\begin{document}`** después del preámbulo en tu documento principal. Consulta [aquí](/latex/es/conceptos-basicos-de-latex/01-learn-latex-in-30-minutes.md) para aprender más sobre cómo estructurar documentos en LaTeX.

**\documentclass\[...]{...} en el lugar incorrecto:**

Otra causa común de este error es si **`\documentclass[...]{...}`** está escrito en el lugar incorrecto. Debe escribirse al inicio del documento principal. Si tienes un archivo separado para tu preámbulo, no puedes **no puedes** incluir **`\documentclass[...]{...}`** en ese archivo. Aun así debe aparecer en la parte superior del archivo principal del proyecto, o de lo contrario solo se compilará el archivo del preámbulo.

**Documento principal configurado incorrectamente:**

Este error también puede aparecer si has configurado incorrectamente el documento principal en el menú de la izquierda. Esto puede ocurrir si **`\documentclass[...]{...}`** está escrito en el lugar incorrecto, así que deberías corregir esto primero si es necesario. Para cambiar la elección del documento principal, abre el menú de la izquierda:

![Lefthandmenu.PNG](/files/317076d24795179f1a742e8323e3221e070ba25c)

y ve al *Documento principal* menú desplegable:

![Maindocument.PNG](/files/8616f6490b130264c6182e5d429d3743f23caadd)


---

# 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/es/errores-de-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.
