This paper was converted on www.awesomepapers.org from LaTeX by an anonymous user.
Want to know more? Visit the Converter page.

The iftex package

The  Project Team https://github.com/latex3/iftex
(2018/12/01)

1 Introduction

This original iftex was written as part of the bidi collection (by the Persian TeX Group / Vafa Khalighi) and provided checks for whether a document was being processed with PDF, or Xe, or Lua. This version recodes the package and incorporates similar tests from the ifetex package by Martin Scharrer, the ifxetex package by Will Robertson, the ifluatex and ifvtex packages from Heiko Oberdiek and parts of ifptex by Takayuki Yato.

For each  variant engine supported two commands are provided:

  • a conditional, \iffootex that is true if the (footex) engine (or a compatible extension) is being used.

    For compatibility with earlier packages which did not all use the same naming convention all these conditionals are provided in two forms, a lowercase name \iffootex and a mixed case name \iffooTeX.

  • a command RequireFooTeX which checks that footex is being used, and stops the run with an error message if a different engine is detected.

2 Loading the package

The package can be loaded in the usual way in both Plain  and .

2.1 Loading the package in plain

\input iftex.sty

2.2 Loading the package in

\usepackage{iftex}

2.3 Loading the package in ini

The package assumes no existing macros and may be loaded during format setup in a format without the plain  or  format being loaded. From an initial ini setup the package may be loaded as for plain .

3 Engine test conditionals

All the conditionals defined here are used in the same way:

\ifluatex
  luatex specific code
\else
  code for other engines
\fi
\ifetex, \ifeTeX

True if an e enabled format is in use. (This is necessarily true in all  variants.)

\ifpdftex, \ifPDFTeX

True if PDF is in use (whether writing PDF or DVI), so this is true for documents processed with both the latex and pdflatex commands.

\ifxetex, \ifXeTeX

True if Xe is in use.

\ifluatex, \ifLuaTeX

True if Lua and extensions such as LuaHB are in use.

\ifluahbtex, \ifLuaHBTeX

True if the luaharftex Lua module is available. This will be true in luahbtex and may be true in luatex if a binary Lua luaharftex module has been compiled and is available in Lua’s search path.

\ifptex, \ifpTeX

True if any of the p variants are in use.

\ifuptex, \ifupTeX

True if any of the up variants are in use. (\ifetex could be used in addition to distinguish uptex and euptex.)

\ifptexng, \ifpTeXng

True if p-ng (Asiatic p) is in use.

\ifvtex, \ifVTeX

True if V is in use.

\ifalephtex, \ifAlephTeX

True if Aleph is in use. (The aleph-based  command is lamed.)

\iftutex, \ifTUTeX

This is not strictly an engine variant, but it is true if \Umathchardef is available, which essentially means that it is true for Lua and Xe, allowing constructs such as

\iftutex
  \usepackage{fontspec}
  \setmainfont{TeX Gyre Termes}
  \usepackage{unicode-math}
  \setmathfont{Stix Two Math}
\else
  \usepackage{newtxtext,newtxmath}
\fi

4 Requiring specific engines

For each supported engine, the package provides a command \Require... which checks that the document is being processed with a suitable engine, and stops with an error message if not.

\RequireeTeX
\RequirePDFTeX
\RequireXeTeX
\RequireLuaTeX
\RequireLuaHBTeX
\RequirepTeX
\RequireupTeX
\RequirepTeXng
\RequireVTeX
\RequireAlephTeX
\RequireTUTeX

5 Output mode conditional

This package also provides an \ifpdf conditional that is true if the format is set up to output in PDF mode rather than DVI. This is equivalent to the test in the existing ifpdf package.

Unlike the engine tests above this is defined as if by \newif with user-documented commands \pdftrue and \pdffalse that can change the boolean value. These would be needed to reset the boolean if the output mode is reset (for example by setting \pdfoutput=0 in PDF).

Unlike the original ifpdf package, the version here also detects PDF output mode if running in V.

6 Additional packages

This extended iftex is designed to replace the original iftex and also the packages ifetex, ifluatex, ifvtex, ifxetex, ifpdf.

This collection includes small packages with these names that include the main iftex package, and in some cases define additional commands for increased compatibility. These packages should mean that authors do not need to change existing documents, although it is recommended that new documents use the iftex package directly.

Note that while this package provides basic support for detecting p (Japanese ) variants and is broadly compatible with the ifptex package, the ifptex package has many more detailed tests for p variants and this package does not replace the ifptex (or ifxptex) packages, which are maintained by their original authors and recommended for Japanese documents that need fine control over the Japanese  system in use.

7 Compatibility with scrbase

The scrbase package (which is automatically included in the popular KOMA-Script classes) by default defines \ifpdftex and \ifVTeX with a different syntax. If you use the scrbase option internalonly then scrbase will not define these and the definitions as described here will take effect. This is recommended and will not affect any scrbase package code as internally scrbase uses private versions of those commands prefixed with \scr@. However this package detects if the scrbase definitions are in effect and if so does not redefine them, for compatibility with existing documents. The iftex versions will still be available under the names \ifPDFTeX and \ifvtex.