Is there a way to programatically test whether the current document is being compiled by (pdf)LaTeX or XeLaTeX?

   \setmainfont[Ligatures=TeX]{TeX Gyre Termes}

There's also ifluatex. These packages define also \RequireXeTeX and \RequireLuaTeX respectively, that throw an error if the corresponding engine is not used.

As Martin remarks, the iftex package does the work of both defining different conditionals. This package is automatically loaded with bidi.

  • 15
    There is also the general iftex package: "which works both for Plain TeX and for LaTeX, defines the \ifPDFTeX, \ifXeTeX, and \ifLuaTeX conditionals for testing which engine is being used for typesetting. The package also provides the \RequirePDFTeX, \RequireXeTeX, and \RequireLuaTeX commands which throw an error if pdfTeX, XeTeX or LuaTeX (respectively) is not the engine in use." (Thanks goes to Andrey Vihrov for pointing this out to me recently) – Martin Scharrer Jul 14 '11 at 10:50
  • @egreg: This only works if we assume there are only two engines (xetex and pdftex). – user9783 Jul 16 '11 at 7:40
  • Very similar: tex.stackexchange.com/a/13175/8666 – Ioannis Filippidis Jul 31 '15 at 8:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.