> 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-tw/wen-yu-da/05-can-i-run-plain-tex-on-overleaf.md).

# 我可以在 Overleaf 上執行 plain TeX 嗎？

是的——你可以依照下方所述的設定程序，將你的專案設定為使用 plain TeX 進行編譯。

1. 在 Overleaf 編輯器中，點選 **選單** 按鈕，並將 **編譯器** 選項設定為 `LaTeX`——從 `LaTeX` 下拉式清單中選取，如下方影片片段所示：

{% embed url="<https://www.filepicker.io/api/file/Iw9UYRbxRBy3Bk61YKqj>" %}

3. 在你的專案中新增一個空白檔案，並將其另存為 `latexmkrc`——它不應該有任何副檔名（如果你的專案已經有一個 `latexmkrc` 檔案，則你可能不需要新增這個）。
4. 將以下這一行加入你的 `latexmkrc` 檔案中：

```
$latex = 'tex %O %S';
```

#### 這個 latexmkrc 檔案到底是做什麼的？

簡單來說，Overleaf 的伺服器使用一個名為 [`latexmk`](https://mg.readthedocs.io/latexmk.html) 來執行並控制基於 TeX/LaTeX 的排版。這個 `latexmk` 程式讓 Overleaf 使用者可透過加入一個名為 `latexmkrc`。 `latexmkrc` 設定檔在 [該 `latexmk` 網站](https://mg.readthedocs.io/latexmk.html#configuration-files).

#### 範例

該 `latexmk` 程式是以 [Perl 程式語言](https://www.perl.org/) 撰寫，而它使用井字號（#）作為註解字元（就像 TeX/LaTeX 通常使用 % 字元一樣）。如果你想使用不同的 TeX 引擎嘗試 plain TeX，你可以建立一個 `latexmkrc` 檔案，並將以下文字複製/貼上到其中：

```
# $latex = 'tex %O %S'; # 使用 Knuth 的原始 TeX 引擎
# $latex = 'pdftex %O %S'; # 使用 pdfTeX 引擎
# $latex = 'luatex %O %S'; # 使用 LuaTeX 引擎
# $latex = 'xetex %O %S';  # 使用 XeTeX 引擎
```

若要使用特定的 TeX 引擎，請取消你想使用的 TeX 引擎那一行的註解（刪除開頭的「#」字元）。例如，要執行 XeTeX，你要取消最後一行的註解，這樣你的 `latexmkrc` 檔案看起來如下所示——請注意，最後一行並不是以「#」字元開頭，因此它會被執行/運行，並使用 XeTeX 來排版你的 plain TeX 文件：

```
# $latex = 'tex %O %S'; # 使用 Knuth 的原始 TeX 引擎
# $latex = 'pdftex %O %S'; # 使用 pdfTeX 引擎
# $latex = 'luatex %O %S'; # 使用 LuaTeX 引擎
$latex = 'xetex %O %S';  # 使用 XeTeX 引擎
```

以下這段短片展示了上述的 `latexmkrc` 檔案被逐一選擇性編輯，以依序執行每個 TeX 引擎——從 XeTeX 開始。此範例中使用的 plain TeX 原始碼取自 [D. R. Wilkins 的一篇文章](https://www.ntg.nl/doc/wilkins/pllong.pdf).

{% embed url="<https://www.filepicker.io/api/file/9PVmkgTSSny7gjNliTdt>" %}

### 延伸閱讀

我們還有兩篇相關的說明文章，可能會引起任何希望更深入了解 Overleaf 如何使用 `latexmk` 和 `latexmkrc`:

* [Overleaf 如何編譯我的專案？](/latex/zh-tw/zhi-shi-ku/064-how-does-overleaf-compile-my-project.md)
* [如何在 Overleaf 中使用 latexmkrc：範例與技巧](/latex/zh-tw/shen-ru-wen-zhang/28-how-to-use-latexmkrc-with-overleaf.md)


---

# 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-tw/wen-yu-da/05-can-i-run-plain-tex-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.
