> 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/in-depth-articles/28-how-to-use-latexmkrc-with-overleaf.md).

# How to use latexmkrc with Overleaf

Hands up if you've heard of a `latexmkrc` file? Now keep your hands up if you know what it does. Now keep your hands up if you've ever written your own. Anyone with their hands still up—you probably don't need to read the rest of this post.

Why the interest in `latexmkrc`? We've recently had a number of users get in touch to ask how to do certain things with Overleaf, to which our answer has begun: "Firstly, create a custom `latexmkrc` file in your project...". Given that this isn't the most intuitive part of LaTeX, and documentation on the web (and examples in particular) are quite sparse, we thought we'd explore it here in a bit more detail.

### What is a latexmkrc file?

If you've never seen it before, a `latexmkrc` file is a configuration / initialization (RC) file for the [`Latexmk` package](https://www.ctan.org/pkg/latexmk). `Latexmk` is used by Overleaf to control the compilation of your source LaTeX document into the final typeset PDF file. By using a customized configuration file called *`Latexmk`* you can override the default compilation commands to allow Overleaf to compile your document in a special way.

### Why would I want to use a latexmkrc file?

Well, as an example, did you know that all the dates and times in the PDF compiled on Overleaf are the dates and times of the server’s by default. What if instead you'd like to use your local date/time?

To display the date/time local to your timezone, you can change the `TZ` (timezone) environment variable using a custom `latexmkrc` file:

1. In your project editor window, click on the “Upload” icon on the top of the file tree panel.
2. Select “New file”, and name the file `latexmkrc`.
3. Add the following line to the file `latexmkrc`:

   ```perl
   $ENV{'TZ'}='Canada/Central';
   ```

   or whichever timezone required. Here's a [list of supported time zones for reference](http://php.net/manual/en/timezones.php).

Dates and times (e.g. `\today` and `\currenttime` from the `datetime` package) in the PDF should then give values local to the specified time zone.

A `latexmkrc` file is very useful used to debug a project that has fatal errors; read more about that in the [Compile timeout help page](/latex/knowledge-base/038-fixing-and-preventing-compile-timeouts.md#fatal-compile-errors-blocking-the-compilation).

### Where can I find more examples of latexmkrc commands?

As a start, check out the following examples from our help pages:

* [How does Overleaf compile my project?](/latex/knowledge-base/064-how-does-overleaf-compile-my-project.md)
* [Can I run plain TeX on Overleaf?](/latex/questions-and-answers/05-can-i-run-plain-tex-on-overleaf.md)
* [Does Overleaf support pTeX?](/latex/questions-and-answers/09-does-overleaf-support-ptex.md)
* [Find fatal compile errors blocking the compilation](/latex/knowledge-base/038-fixing-and-preventing-compile-timeouts.md#fatal-compile-errors-blocking-the-compilation)
* [I have a lot of .cls, .sty, .bst files, and I want to put them in a folder to keep my project uncluttered. But my project is not finding them to compile correctly.](/latex/questions-and-answers/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)
* [How can I make the xr package work on Overleaf?](/latex/knowledge-base/033-cross-referencing-with-the-xr-package-in-overleaf.md)
* [How do I make \today display the date according to my time zone?](/latex/questions-and-answers/32-how-do-i-make-today-display-the-date-according-to-my-time-zone.md) (that example is re-used above)

If those don't help, please feel free to [contact us page](https://www.overleaf.com/contact) or try the popular [TeXStackExchange](http://tex.stackexchange.com) and [LaTeXCommunity](http://latex-community.org/) forums.


---

# 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/in-depth-articles/28-how-to-use-latexmkrc-with-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.
