> 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/wen-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'; # to use Knuth's original TeX engine
# $latex = 'pdftex %O %S'; # to use the pdfTeX engine
# $latex = 'luatex %O %S'; # to use the LuaTeX engine
# $latex = 'xetex %O %S';  # to use the XeTeX engine
```

要使用特定的 TeX 引擎，请取消你想使用的 TeX 引擎对应行的注释（删除开头的“#”字符）。例如，要运行 XeTeX，你需要取消最后一行的注释，这样你的 `latexmkrc` 文件会如下所示——注意最后一行并不是以“#”字符开头，因此它会被执行/运行，以使用 XeTeX 对你的 plain TeX 文档进行排版：

```
# $latex = 'tex %O %S'; # to use Knuth's original TeX engine
# $latex = 'pdftex %O %S'; # to use the pdfTeX engine
# $latex = 'luatex %O %S'; # to use the LuaTeX engine
$latex = 'xetex %O %S';  # to use the XeTeX engine
```

下面这段短视频展示了上述 `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-cn/zhi-shi-ku/064-how-does-overleaf-compile-my-project.md)
* [如何在 Overleaf 中使用 latexmkrc：示例与技巧](/latex/zh-cn/shen-du-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://ayakaleaf-pro.ayaka.space/latex/zh-cn/wen-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.
