> 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/wen-da/59-i-have-a-lot-of-.cls-.sty-.bst-files-and-i-want-to-put-them-in-a-folder-to-keep-my-project-unclut.md).

# 我有很多 .cls、.sty、.bst 文件，想把它们放进一个文件夹，以保持项目整洁。但我的项目找不到它们，无法正确编译

好消息是，我们可以通过该 `TEXINPUTS` 文件来指定自定义 `latexmkrc` 目录，这样 Overleaf 就知道需要在该目录中搜索包文件。

为此，假设你已经将这些包文件放在一个名为 `tex/`的文件夹中；相应地，参考文献样式文件放在一个名为 `bst/`:

1. 点击项目侧边栏顶部的“添加文件”。
2. 选择“空白文件”，并将文件名保存为 `latexmkrc` （如果它还不在那里）。
3. 将下面这一行放入 `latexmkrc`:

   ```
   $ENV{'TEXINPUTS'}='./tex//:' . $ENV{'TEXINPUTS'};
   $ENV{'BSTINPUTS'}='./bst//:' . $ENV{'BSTINPUTS'};
   ```

   （或者改为你项目中对应的文件夹名称）

Overleaf 现在会先搜索 `tex/` 文件夹，然后再搜索系统 `TEXINPUTS` 以定位包文件，并且 `bst/` 文件夹，然后再搜索系统 `BSTINPUTS` 以定位参考文献样式文件。

（来源： <http://tex.stackexchange.com/a/50847/226>)

**注意**：你的主文档文件和你的 `latexmkrc` 文件必须保留在项目的顶层，不能放在文件夹中。


---

# 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/wen-da/59-i-have-a-lot-of-.cls-.sty-.bst-files-and-i-want-to-put-them-in-a-folder-to-keep-my-project-unclut.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.
