TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 28 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

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

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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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