Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am working on a document preamble that allows me to compile a document with pdlatex and with xelatex. I found that the \ifetex condition to check whether the document is going through e-tex is always true, independent of the engine that I use.

Below is a minimal example. The eTeX used ... part is in all result documents independent of the engine that I use: pdflatex, xelatex, and latex. The "PDF used..." part is only in the document that ran through pdflatex.

Any ideas? Is there a general mistake in my thoughts?

The documentation of \ifetex says it simply tests for the \eTeXversion. Who sets this?

I am on a Fedora 19 installation and also tried it on a Fedora 20 without the etex stuff installed at all -- same behavior. Can somebody test this at a different installation, i.e., whether the behavior is the same?

Is there a 'best-practice' to do the engine selection in a document preamble if I want (need) to be able to run the document through any of the major engines? So I mean to construct a if(pdf)-elsif(etex)-elsif(latex)-fi chain.

\documentclass{article}

\usepackage{ifpdf}
\usepackage{ifetex}

\begin{document}

Hello World

\ifpdf
    PDF used
\fi

\ifetex
    eTeX used; version is \the\eTeXversion \the\eTeXversion
\fi

\end{document}
share|improve this question
5  
You seem to confuse etex and xetex. etex (expanded tex commands) is used by all current engines. –  Ulrike Fischer Jan 2 at 14:18
    
Great! ... so simple :-) That's it ... Thanks! –  Bernd Gloss Jan 2 at 14:23
1  
Note also that ifpdf checks if PDFTeX is run in PDF mode, not whether the engine is PDFTeX or not and it will return true for LuaTeX as well. –  Khaled Hosny Jan 2 at 14:48

2 Answers 2

The e-TeX extensions were finalised in 1999 and are available in the common engines: pdfTeX, LuaTeX and XeTeX. With a recent-ish TeX system (say anything released in the last 5-8 years), the extensions are enabled in the LaTeX format files as standard. The only 'common' case where the extensions are not enabled is when using 'classical' TeX:

tex <filename>

as they are not part of Knuth's original design and tex always invokes that.

It is quite possible to build a format without the extensions, or to run across an older TeX system which either requires they be asked for explicitly (elatex, etc.) or doesn't have them at all (some proprietary systems, for example).

The extensions themselves are still maintained as a patch against Knuth's TeX, so they have a version independent of the engine (pdfTeX, etc.) in use. All of the systems which enable the e-TeX primitives include the version string for the e-TeX extensions. Thus this primitive is a good test for the extensions being available. (Note: with LuaTeX it is possible to enable the extensions without \eTeXversion, but extremely unlikely in practice and is not really worth worrying about.)

share|improve this answer
    
Actually the LuaTeX situation is a little more complex as it doesn't provide \TeXXeTstate and other e-TeX bidirectional primitives (it uses a different model). However, if this is an issue a specific LuaTeX test is also available. –  Joseph Wright Jan 2 at 14:24
    
Josehp, thanks for the explanation. As Ulrike pointed out, my mistake was to be confused about e-TeX and XeLaTex. –  Bernd Gloss Jan 2 at 14:41
up vote 1 down vote accepted

Okay, the solution is simple.

\usepackage{ifetex} -> \usepackage{if**x**etex}

\ifetex -> \ifxetex

Sorry for the confusion :-)

share|improve this answer

Your Answer

 
discard

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.