Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
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
! 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
–
`elsif (/^-xelatex$/) { $pdf_mode = 1; $pdflatex = 'xelatex %O %S'; $pdf_previewer =
'start evince %O %S';}`
above (or near) the line
`elsif (/^-pdf$/) { $pdf_mode = 1; }`
Then you can call latexmk -xelatex file.tex
. Works, but I didn't test it extensively. Should work similarly with lualatex
.
–
–
In version: 4.65 (18 June 2019), there is a difference between using the -xelatex
option and setting -pdflatex
as suggested by one of the comments.
Option 1: -xelatex
$ latexmk -xelatex file.tex
With the -xelatex
option, or the -pdfxe
option, the tex file is first typeset to an xdv
(extended DVI) file. Then, xdvipdfmx
is called to convert the xdv
file to a pdf
file.
In latexmk
, $xelatex_default_switches
is set to -no-pdf
(line 395) to have xelatex
produce an xdv
file instead of the default PDF file.
Hence the -xelatex
option is equivalent to:
$ xelatex -no-pdf file.tex # called one or more times to produce file.xdv
$ xdvipdfmx file.xdv # called only once in the end
Option 2: -pdflatex=xelatex
A second option is to set pdflatex
as follows along with turning on the -pdf
option:
# %O is a substitution for options and %S is for source file
$ latexmk -pdflatex='xelatex %O %S' -pdf file.tex
In this approach, xelatex
is used to generate the PDF file directly, without generating an intermediate output file. Note that, today, xelatex
first generates an xdv
stream and internally pipes it to xdvipdfmx
to produce a PDF file.
Hence this approach is equivalent to:
$ xelatex file.tex # called one or more times to produce file.pdf
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.