Take the 2-minute tour ×

How can I detect inside a TeX file which engine (pdftex/xetex/luatex) is used to compile the file? Is there a LaTeX package that provides this functionality?

share|improve this question
add comment

3 Answers

up vote 18 down vote accepted

Yes, there is — iftex. There are also ifxetex and ifluatex packages.

Internally these packages rely on checking if engine-specific primitives exist, such as \XeTeXversion.

share|improve this answer
add comment

Packages ifxetex, ifluatex, ifpdf. You can also look e.g. in hyperref to check how it detect which driver it should use.

share|improve this answer
ifpdf just detects pdf or dvi modes, you can not detect engine with it. –  IRAN Mar 12 '11 at 2:00
add comment

I am using the following code:

%% Macros specific for latex / pdflatex / xetex compilers 
    \typeout{^^J *** PDF mode *** } 
    \typeout{^^J *** DVI mode ***} 
    \typeout{ *** LuaLaTeX *** ^^J}
    % patch \typein
    % see http://tex.stackexchange.com/questions/12435/incompatibilities-between-lualatex-and-typein
        \read\@inputcheck to#1%
    % LuaLaTeX specific code
    \typeout{ *** XeLaTeX *** ^^J} 
    % XeLaTeX specific code
    \typeout{ *** LaTeX *** ^^J} 
\typein{} % pause to watch result

LuaLaTeX can run both in DVI and PDF modes.

share|improve this answer
add comment

Your Answer


