> 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/texlive/zh-tw/ji-neng/xin-zeng-latex-xiang-yi-xiang-mu.md).

# 新增 LaTeX 相依項目

如果你有 `.cls`, `.sty`, `.bst` 專案中的檔案，除非它們放在頂層，否則 Overleaf 的編譯程序將無法找到這些檔案。

然而，為了整理你的專案，你可能會想把這些檔案放進資料夾中，這樣更容易找到，也能讓專案頂層不那麼雜亂。

好消息是，我們可以指定自訂的 `TEXINPUTS` 目錄，使用 `latexmkrc` 檔案，讓 Overleaf 知道需要在該目錄中搜尋套件檔案。

要這麼做，假設你已將這些套件檔案放在一個名為 `tex/`；以及將參考文獻樣式檔分別放在一個名為 `bst/`:

1. 點擊專案側邊欄頂端的「新增檔案」。
2. 選擇「空白檔案」，並將檔名儲存為 `latexmkrc` （如果尚未存在）。
3. 在以下位置加入這一行： `latexmkrc`:

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

   （或改成你專案中對應的資料夾名稱）

Overleaf 現在會先搜尋 `tex/` 資料夾，然後才搜尋系統 `TEXINPUTS` 以定位套件檔案，並且 `bst/` 資料夾，然後才搜尋系統 `BSTINPUTS` 以定位參考文獻樣式檔。

（來源： <https://tex.stackexchange.com/a/50847>)

{% hint style="info" %}
你的主文件檔以及你的 `latexmkrc` 檔案必須保留在專案頂層，而不是放在資料夾中。
{% endhint %}


---

# 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/texlive/zh-tw/ji-neng/xin-zeng-latex-xiang-yi-xiang-mu.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.
