I can't see any situation where I would want to compile a dvi file. Therefore I'd like to have latexmk default to giving me a pdf via pdflatex, so I don't have to type -pdf every time. I've tried adding the following to my latexmkrc file without success:


$pdflatex = 'pdflatex --shell-escape %O %S';

and even


I'm on windows, so I can't just add it to my alias file. Is there a way to set up latexmk to make me a pdf unless I specify otherwise?

  • 5
    $pdf_mode = 1; !? Commented Jul 8, 2013 at 22:34
  • @Hans-PeterE.Kristiansen Yep, that was it. Want to make that an answer? For the record: I feel dumb for missing that in the manual.
    – Canageek
    Commented Jul 8, 2013 at 22:36
  • 1
    If you add -synctex=1' after %O %S, you can use forward and inverse search in your pdf viewer if it has that feature.
    – dustin
    Commented Jul 8, 2013 at 22:49
  • Noob question, but a couple of hours of Googling has led me nowhere: What do %O, %S and %B signify here?
    – Thriveth
    Commented Jan 25, 2019 at 15:06
  • @Thriveth - I had the same issue and finally found it. %O is options and %S is the source file. Full list is here: manpages.debian.org/testing/latexmk/… (the man page for latexmk, under "Format of Command Specifications")
    – Miles
    Commented May 16, 2021 at 22:42

2 Answers 2


On Windows, latexmk looks for the file .latexmkrc in the directory specified by the USERPROFILE environment variable. This usually is C:\Users\[user name]\

If you add:

$pdf_mode = 1;

to this file, latexmk will default to create a PDF file.


You need $pdf_mode = 1; to enable pdf mode. The manual says it is the same as the option:


Equivalent to the -pdf-, -pdf, -pdfdvi, -pdfps options.

As of 17 August 2016, latexmk follows the XDG Base Directory Specification and looks for its configuration file in $XDG_CONFIG_HOME/latexmk/latexmkrc (or $HOME/.config/latexmk/latexmkrc if the $XDG_CONFIG_HOME environment variable is empty or unset). It will also check $HOME/.latexmkrc for compatibility with older versions.

Here is my complete .latexmkrc file:

$recorder = 1;
$pdf_mode = 1;
$bibtex_use = 2;
$pdflatex = "pdflatex --shell-escape %O %S";
$pdf_previewer = "start open -a preview %O %S";

add_cus_dep('glo', 'gls', 0, 'run_makeglossaries');
add_cus_dep('acn', 'acr', 0, 'run_makeglossaries');

sub run_makeglossaries {
  if ( $silent ) {
    system "makeglossaries -q '$_[0]'";
  else {
    system "makeglossaries '$_[0]'";

push @generated_exts, 'glo', 'gls', 'glg';
push @generated_exts, 'acn', 'acr', 'alg';
$clean_ext .= ' %R.ist %R.xdy';

For more latexmk example_rcfiles and extra-scripts :



  • 1
    Dumb question: What is the Home directory on Windows?
    – Canageek
    Commented Mar 19, 2015 at 19:27
  • 1
    @Canageek: I do not know. Juan A. Navarro wrote this, but I agree. I only have bad childhood memories of trying to use windows for anything other than games and fun. The best solution(seen from my perspective) would be to install Linux(Ubuntu,...), OSX or some other Unix. I guess that this solution is too extreme for most windows users. Commented Mar 19, 2015 at 20:54
  • 1
    It would be, as a lot of software I need for work only runs on Windows, and my home P.C. is for gaming.
    – Canageek
    Commented Mar 22, 2015 at 23:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .