[Tex/LaTex] Generating PDF from xelatex

latexmkxdvipdfmxxetex

Given a LaTeX file, foo.tex, that requires xelatex, one can convert it to PDF in the following two ways:

  1. Run xelatex foo (which directly generates foo.pdf)
  2. Run xelatex -no-pdf foo (which generates foo.xdv) followed by xdvipdfmx foo (which converts the xdv file to foo.pdf)

Do the two approaches, in effect, produce the same pdf file? Or is there some advantage to (1) (or indeed (2))?

(The context for this is that in the past I had always assumed that with a latex file that does not require xelatex it was preferable to call pdflatex rather than calling latex and converting the DVI to PDF. Indeed, in the past latexmk with the -xelatex argument would follow route (1), however newer versions follow (2), which initially concerned me, in analogy with my pdflatex comment above. Having found "latexmk with xelatex xdv mode" I suspect that (1) and (2) are essentially equivalent, but I wanted to confirm this. In particular I want to be sure the two routes are equivalent even if one is using packages such as microtype or hyperref.)

Best Answer

The approaches are identical because xetex calls xdvipdfmx unless you specify -no-pdf.

xetex is not like pdftex or luatex that have a modified back end that generates pdf, it always generates (extended) dvi but it runs xdvipdfmx at the end and deletes the intermediate files unless --no-pdf option is given.