> For the complete documentation index, see [llms.txt](https://ayakaleaf-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://ayakaleaf-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://ayakaleaf-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.
