[XeTeX] ifxetex package

Ross Moore ross at ics.mq.edu.au
Mon Jun 19 07:22:02 CEST 2006

Hi Will,

On 19/06/2006, at 12:06 PM, Will Robertson wrote:

>> Be careful here.
>> \ifdefined is *not* a LaTeX command, nor a TeX one.
> No, it's an eTeX command :)


> I've bitten the bullet to state that anyone using this package will
> be using an eTeX-based "TeX" -- because all distributions are now
> shipping with pdfeTeX configured for everything, I feel this a
> reasonable assumption.

  ... clearly I've not bitten that particular bullet yet
--- I don't like the taste of lead ...

    ... or depleted uranium.    :-)

> Anyway, pg 13 of etex-man (`texdoc etex`) has some nice goodies along
> these lines:
> "For ε-TEX there are these additional conditionals:
> • \ifdefined<token> (test if token is defined)
> True if <token> is defined; creates no new hash table entry.
> • \ifcsname...\endcsname (test if control sequence is defined)
> True if the control sequence \csname...\endcsname would be defined;
> creates
> no new hash table entry.
>   ...
> These are ε-TEX’s additional expandable commands:
> • \unless.
> The next (unexpanded) token must be a boolean conditional (i.e., not
> \ifcase); the truth value of that conditional is reversed."
> I don't know if there's much point using
>    \unless\ifdefined\XeTeXversion
> compare to
>    \ifdefined\XeTeXversion\else
> but I don't mind the syntax so I've tried it out.

With  XeTeX being built on top of eTeX, then yes it is OK
to define tests in terms of these primitives.
Indeed, they should stick to (e)TeX primitives, so as
to be useful tests for XeLaTeX, XeConTeXt, XeTeX (plain)
and whatever might emerge in future.

Howver, I think there is an important point that you
are missing.  (See below.)

> There's more in eTeX that I don't fully understand (e.g., when
> \unexpanded would be useful) but its extras are well worth
> investigating.

Hmm; something to look at.

>> Even better still (why ?) is:
>>    \begingroup
>>     \expandafter\ifx\csname XeTeXversion\endcsname\relax
>>      \aftergroup\endinput\fi
>>    \endgroup
> Erm, something about not retaining the \XeTeXversion macro that's
> equivalent to \relax? Hang on...\endinput?

If \XeTeXversion  isn't defined, so that it begets \relax
  thereby \ifx returns \iftrue , then is there any point
in reading further through the file ?
Just  \endinput .
OK, better is to write a message first.

Indeed, before doing such a test there should be


so that  \ifxetex <--- \iffalse  initially.
This remains even after the package ends early.

This then allows an author to write documents that can
be compiled with different processors, allowing blocks:


to do the correct thing according to the typesetting
engine; e.g., employ different font-loading mechanisms.

Think about an author wishing to make HTML pages from
his/her document. All the font-loading becomes irrelevant.
You still want the UTF8 text to be read natively by the
web-browser, and rendered in whatever font is available.

Whole sections of a (LaTeX) preamble could be protected
by \ifxetex ... \fi  so as to be ignored by the HTML engine
(whichever it is: latex4ht , latex2html , or other.)

> Anyway, the requirement for such convoluted stuff was the reason
> \ifdefined was created, as I understand it.
> So anyway, given how easy it is to write \ifdefined\XeTeXversion, I'm
> not sure there's much point in having an ifxetex package.

Surely the purpose is more for when XeTeX is *not* the engine
--- hence it may not be e-TeX based either ---
than for when it *is* the engine.

> All the best,
> Will



Ross Moore                                         ross at maths.mq.edu.au
Mathematics Department                             office: E7A-419
Macquarie University                               tel: +61 +2 9850 8955
Sydney, Australia  2109                            fax: +61 +2 9850 8114

More information about the XeTeX mailing list