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?


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.


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

  • 3
    ifpdf just detects pdf or dvi modes, you can not detect engine with it. – IRAN Mar 12 '11 at 2:00

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.

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.