Is there a way to programatically test whether the current document is being compiled by (pdf)LaTeX or XeLaTeX?
Asked
Active
Viewed 4,790 times
1 Answers
31
\usepackage{ifxetex}
\ifxetex
\usepackage{fontspec}
\setmainfont[Ligatures=TeX]{TeX Gyre Termes}
\else
\usepackage{tgtermes}
\fi
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.
egreg
- 1,121,712
iftexpackage: "which works both for Plain TeX and for LaTeX, defines the\ifPDFTeX,\ifXeTeX, and\ifLuaTeXconditionals for testing which engine is being used for typesetting.The package also provides the
– Martin Scharrer Jul 14 '11 at 10:50\RequirePDFTeX,\RequireXeTeX, and\RequireLuaTeXcommands 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)