LuaTeX comes from pdfTeX, it also knows the same modes for PDF and DVI and provides nearly all PDF features of pdfTeX. It knows even \pdftexversion and \pdftexrevision.
Thus \ifpdf has the same semantics here.
The test \ifpdf is not for testing for an engine. Even if \ifpdf is false, then you can have pdfTeX, but pdfTeX in DVI mode. Usually TeX Live and MiKTeX are also using pdfTeX
for the command latex, but generating DVI with pdfTeX in DVI mode.
If you want to know, if pdfTeX and not LuaTeX is running, then you can exclude luatex by
\ifluatex of package ifluatex and then testing for \pdftexversion, for example:
\usepackage{ifluatex}
\usepackage{ifpdf}
\ifluatex
\typeout{This is LuaTeX}%
\else
\begingroup\expandafter\expandafter\expandafter\endgroup
\expandafter\ifx\csname pdftexversion\endcsname\relax
\typeout{This is neither LuaTeX nor pdfTeX}%
\else
\typeout{This is pdfTeX in \ifpdf PDF \else DVI \fi mode}%
\fi
\fi
Testing for package driver options and …
Some TeX engines and modes can be detected at TeX macro level and the packages (or its configuration files) are automatically loading the right drivers, e.g.:
- pdfTeX and LuaTeX in PDF mode
- XeTeX
DVI drivers are different. The DVI driver program is running after the TeX run, thus there is no way of knowing the future. The default is often dvips.
Therefore in many cases you won't need complicate switch structures to differentiate between the different TeX compilers, just loading the package is enough:
\usepackage{color}
\usepackage{graphicx}
\usepackage{hyperref}
In case of package fontspec you need to test for the Unicode aware TeX compilers,
for example:
\usepackage{ifluatex}
\usepackage{ifxetex}
\ifluatex
\usepackage{fontspec}
% other LuaTeX setup
\else
\ifxetex
\usepackage{fontspec}
% other XeTeX setup
\else
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage{lmodern}
% other font setup
\fi
\fi
.xdv(extended DVI) format, and the PDF is actually made byxdvipdfmxwhich is normally as part of the XeTeX run.\ifpdfis about the driver, and in the pdfTeX and LuaTeX cases the 'driver' is direct PDF output. – Joseph Wright Oct 06 '12 at 18:36ifluatexinstead with\ifluatex ... \else ... \fi– Oct 06 '12 at 18:37