> 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/questions-and-answers/05-can-i-run-plain-tex-on-overleaf.md).

# Can I run plain TeX on Overleaf?

Yes—you can configure your project to be compiled using plain TeX by following the setup procedure described below.

1. In the Overleaf editor, click on the **Menu** button and set the **Compiler** option to `LaTeX`—select `LaTeX` from the dropdown list as shown in the following video clip:

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

3. Add a blank file to your project, and save it as `latexmkrc`—it should not have any file extension (you may not need to add this if your project already has a `latexmkrc` file).
4. Add the following line to your `latexmkrc` file:

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

#### What does this file latexmkrc actually do?

Without going into detail, Overleaf's servers use a program called [`latexmk`](https://mg.readthedocs.io/latexmk.html) to run and control TeX/LaTeX-based typesetting. The `latexmk` program allows Overleaf users to influence typesetting of their projects by adding a configuration file called `latexmkrc`. Readers wishing to further explore this can read about the `latexmkrc` configuration file on [the `latexmk` web site](https://mg.readthedocs.io/latexmk.html#configuration-files).

#### Examples

The `latexmk` program is written in the [Perl programming language](https://www.perl.org/) which uses the hash character (#) as the comment character (much like TeX/LaTeX typically use the % character). If you wish to experiment with plain TeX using different TeX engines you can create a `latexmkrc` file and copy/paste the following text into it:

```
# $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
```

To use a particular TeX engine, uncomment the line (delete the initial '#' character) for the TeX engine you want to use. For example, to run XeTeX you uncomment the last line so that your `latexmkrc` file looks like the following—note that the last line does not start with a '#' character, thus it gets executed/run to typeset your plain TeX document using XeTeX:

```
# $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
```

The following short video shows the above `latexmkrc` file being selectively edited to run each TeX engine in turn—starting with XeTeX. The plain TeX source code used in this example was borrowed from [an article by D. R. Wilkins](https://www.ntg.nl/doc/wilkins/pllong.pdf).

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

### Further reading

We have two related help items which may be of interest to any reader wishing to better understand Overleaf's use of `latexmk` and `latexmkrc`:

* [How does Overleaf compile my project?](/latex/knowledge-base/064-how-does-overleaf-compile-my-project.md)
* [How to use latexmkrc with Overleaf: examples and techniques](/latex/in-depth-articles/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/questions-and-answers/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.
