The latexmkrc file

A project can include a latexmkrc file to customize how the LaTeX compile process is run.

Overleaf uses a Perl-based tool called LatexMk (LaTeX make) to compile your project. This tool allows you to provide a special file named latexmkrc that can customize how the compile process is run.

In some cases, a latexmkrc file is needed in a project in order to set a variable value for the LatexMk process, or to add extra steps to the compile process.

Example: setting the time zone

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 time zone, you can change the TZ (time zone) 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:

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

    or whichever time zone is 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.

Example: setting the TEXINPUTS variable

Another practical use of the latexmkrc file is to add additional paths to the TEXINPUTS environment variable, see: Adding LaTeX dependencies.

Overleaf’s LatexMk file

Overleaf’s “system-wide” configuration file follows LatexMk conventions (for Linux): it is named LatexMk and is located in the folder /usr/local/share/latexmk/. Note: this file is read before any user-level configuration files.

User-level configuration files must be named latexmkrc and added to your Overleaf project to provide custom rules addressing the specific requirements of your Overleaf LaTeX project/document.

Overleaf’s LatexMk file contains code for Overleaf-specific processing plus rules for glossaries, nomenclature, and other commonly used packages. Overleaf’s LatexMk file may show some variation between releases of TeX Live to accommodate changes and updates made to packages and software tools within TeX Live itself.

How to view a copy of Overleaf’s LatexMk file

The following link opens a project to typeset the Overleaf LatexMk file being used with your project’s LaTeX compiler and TeX Live version and also makes it available for download:

\documentclass[a4paper]{article}
\usepackage[margin=1cm]{geometry}
\usepackage{verbatim,shellesc}
\ShellEscape{cp /usr/local/share/latexmk/LatexMk ./LatexMk}
\begin{document}
\section*{About this project}
This project provides access to the system \texttt{LatexMk} initialization (configuration) file used by Overleaf.  \texttt{LatexMk} is a Perl script which may vary slightly according to the \TeX{} Live version and compiler chosen for the project. If you need to be 100\% certain which  \texttt{LatexMk} is being used, add code from this project to your project and compile to typeset a listing of \texttt{LatexMk} and make it available for download as one of the output files.
\section*{Listing the \texttt{LatexMk} file}
\verbatiminput{./LatexMk}
\end{document}

Open this code in Overleaf. After compiling the project above, the LatexMk file can be downloaded via the Logs and output files, see: Generated files.

Last updated

Was this helpful?