shares
 

Examples, techniques and tips on how to use latexmkrc with Overleaf

By Lian Tze Lim

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, but if you fancy sharing your latexmkrc examples please do so via the comments at the bottom of the page!

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) is 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. 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, 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 “Add file” on the top of the project sidebar.
  2. Select “Blank file”, and name the file latexmkrc.
  3. Add the following line to the file latexmkrc:
    $ENV{'TZ'}='Canada/Central';
    
    or whichever timezone required. Here's a list of supported time zones for reference.

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.

Where can I find more examples of latexmkrc commands?

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

If those don't help, please feel free to send us a message or try the popular TeXStackExchange and LaTeXCommunity forums.

Lian Tze Lim

Lian Tze Lim

Community TeXpert

Computer scientist, once-lecturer, trainer. Enjoys tinkering with LaTeX in the name of productive procrastination (ahem). Personal motto: "all research students are insane at one time or another".