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

# Hoofddocument instellen

Het hoofddocument in Overleaf is het bestand dat LaTeX als eerste zal krijgen om te compileren. Het is het hoofdbestand van het project, waarin alle andere onderdelen (klassen, pakketten, hoofdstukken enz.) worden ingevoerd. Wanneer dit niet handmatig is ingesteld, kiest Overleaf een document in het project dat de **`\documentclass[...]{...}`** commando. Om die reden, als je een apart bestand hebt voor je preambule, is het beter om het **`\documentclass[...]{...}`** commando niet in het preambulebestand op te nemen, maar eerder aan het begin van het hoofddocument. Als je dit niet doet, wordt alleen de preambule gecompileerd. Om het hoofddocument in een project in te stellen, klik je gewoon op het menu in de linkerbovenhoek:

![Linkermenu.PNG](/files/62d2d6986770810ab2235dec28499285017952ea)

en ga naar **Hoofddocument**:

![Maindocument.PNG](/files/ceb2e7f0290b26d1a6cd676e8e98e73fc5eb31c2)

Zie [hier](/latex/nl/documentstructuur/07-management-in-a-large-project.md) om meer te weten te komen over het beheren van grote projecten in LaTeX.

## Meerdere documenten in hetzelfde project compileren

Om je in staat te stellen snel verschillende documenten in hetzelfde project te compileren, zal Overleaf het bestand dat in de editor openstaat als hoofddocument compileren zodra het de **`\documentclass[...]{...}`** commando. Dit is vooral handig bij het bewerken met de [**`subfiles`** pakket](/latex/nl/documentstructuur/08-multi-file-latex-projects.md#the-subfiles-package).

## Problemen met de keuze van het hoofdbestand

Het hoofdbestand moet altijd in de hoofdmap staan (buiten alle mappen), om ervoor te zorgen dat alle compilatiestappen in de juiste map worden uitgevoerd en om ervoor te zorgen dat de vereiste hulpbestanden beschikbaar zijn, bijvoorbeeld bij het [een index toevoegen](/latex/nl/documentstructuur/04-indices.md). Zie enkele tips voor het herorganiseren van je project om op Overleaf te compileren [hier](/latex/nl/vragen-en-antwoorden/77-my-main-file-is-in-a-subfolder-but-this-is-not-allowed-on-overleaf.-but-i-don-t-want-to-change-my.md).

Als het geselecteerde hoofdbestand zich in een map bevindt en er een bestand met dezelfde naam in de hoofdmap staat, zal het bestand met die naam in de hoofdmap worden gecompileerd in plaats van de selectie. Bijvoorbeeld, als `version1/main.tex` is ingesteld als het hoofdbestand, maar `main.tex` ook in het project staat, `main.tex` zal worden gecompileerd. Dit probleem komt door de manier waarop Latexmk op Overleaf wordt uitgevoerd. Om problemen hierdoor te voorkomen, geef elk bestand dat je op Overleaf wilt compileren een unieke naam.


---

# 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/nl/kennisbank/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.
