> 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/zh-cn/zhi-shi-ku/006-can-i-choose-which-file-is-the-main-tex-file-in-a-project-on-overleaf.md).

# 我可以在 Overleaf 项目中选择哪个文件作为主 tex 文件吗？

是的，按以下步骤操作：

1. 点击 Overleaf 菜单图标（![OLmenu.png](/files/53dd3fa5f4f404ba6b4cacaba076aa9fdd911266)），位于文件列表上方。
2. 在菜单中，找到 **主文档** 选项，并将其设置为你偏好的 `.tex` 文件中：

   ![SettingMainTeX.png](/files/abb69d13616fb159dbde72046381f2604791507c)
3. 这将把该文件设置为每次你返回项目时都进行编译并预览的文件。

**注意**:

* 为确保 Overleaf 功能正常工作，我们建议将项目的主 `.tex` 文件放在项目的顶级文件夹中。例如，受影响的功能包括 [跳转到位置](/latex/zh-cn/zhi-shi-ku/022-can-t-find-jump-to-location-arrows.md), [字数统计](/latex/zh-cn/zhi-shi-ku/099-is-there-a-way-to-run-a-word-count-that-doesn-t-include-latex-commands.md) 以及类似于 [makeglossaries](/latex/zh-cn/wen-dang-jie-gou/05-glossaries.md) 等，
* 任何包含 `\documentclass` 命令的项目文件，都可以在编辑器中打开时通过选择 **重新编译** 按钮来编译。这样你就可以在不更改项目主文件设置的情况下，在一个 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/zh-cn/zhi-shi-ku/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.
