Compile XeLaTeX tex file with latexmk

Brian M. Hunt picture Brian M. Hunt · Jun 26, 2010 · Viewed 20.6k times · Source

How can one compile a XeLaTeX tex document using latexmk on Mac OS X?

At present I am running latexmk job.tex and getting an error:

! 
 ********************************************
 * XeTeX is required to compile this document.
 * Sorry!
 ********************************************.
\RequireXeTeX ...********************************}
                                                  \endgroup \fi 
l.18 \RequireXeTeX

? ^D
! Emergency stop.
\RequireXeTeX ...********************************}
                                                  \endgroup \fi 
l.18 \RequireXeTeX

The first line of my tex file is (as suggested by this post):

% !TEX TS-program = xelatexmk

and I've tried others (e.g. program=xelatex), but to no avail.

latexmk describes its commands as follows:

$ latexmk -commands xelatex job
Commands used by latexmk:
   To run latex, I use "latex %O %S"
   To run pdflatex, I use "pdflatex %O %S"
   ...

There doesn't appear bo be any logical mechanism for selecting a tex program from the command line, and it's not clear from the source how one would do this, either.

I've also looked atrubber, but it doesn't seem to work either.

I appreciate any insight you may be able to provide.

Brian

Answer

Kay Smarczewski picture Kay Smarczewski · Jun 13, 2011
latexmk -v
Latexmk, John Collins, 16 January 2010. Version 4.13a

I put

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

in my .latexmkrc file. This is a workaround, of course. But it works for me when I call

latexmk -pvc -pdf MyXetexFile