> 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/knowledge-base/006-can-i-choose-which-file-is-the-main-tex-file-in-a-project-on-overleaf.md).

# Can I choose which file is the main tex file in a project on Overleaf?

Yes, by following these steps:

1. Click on the Overleaf menu icon (![OLmenu.png](/files/ygHi0KdCwVA2CEEJS4Fe)), located above the file list.
2. Within the menu, locate the **Main document** option and set it to your preferred `.tex` file:

   ![SettingMainTeX.png](/files/zhJtl0j0HXCixgkVkHRD)
3. This will set the file to be compiled and previewed each time you return to your project.

**Notes**:

* To ensure Overleaf features work correctly, we recommend placing the project's main `.tex` file in the project's top-level folder. For example, features affected include [jump-to-location](/latex/knowledge-base/022-can-t-find-jump-to-location-arrows.md), [word count](/latex/knowledge-base/099-is-there-a-way-to-run-a-word-count-that-doesn-t-include-latex-commands.md) and scripts like [makeglossaries](/latex/document-structure/05-glossaries.md) etc,
* Any project file that contains a `\documentclass` command can be compiled when opened in the editor by selecting the **Recompile** button. This allows you to compile multiple documents inside one Overleaf project without changing the project's main file setting.


---

# 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/knowledge-base/006-can-i-choose-which-file-is-the-main-tex-file-in-a-project-on-overleaf.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.
