[XeTeX] ifxetex package

Will Robertson wspr81 at gmail.com
Mon Jun 19 04:06:27 CEST 2006


Hi Ross,

I think we've started off on the wrong foot.
Here's the package in its entirety:

%%%%%%%%%%%%%%%%%%%%%%%%%%
\ifdefined\ProvidesPackage
   \ProvidesPackage{ifxetex}
     [2006/06/12 v0.1 Provides ifxetex condition]
\fi

\unless\ifdefined\ifxetex
   \newif\ifxetex
\fi

\ifdefined\XeTeXversion
   \xetextrue
\fi
%%%%%%%%%%%%%%%%%%%%%%%%%%

(Your comments about \ifdefined are addressed below.)

On 19/06/2006, at 10:54 , Ross Moore wrote:

>> LaTeX itself ensures than a package is only loaded once, and for
>> Plain I've only added enough smarts that you at least shouldn't get
>> error messages.
>
> Yes, but that assumes the user tried to load using  XeLaTeX .
> Would this not also be useful for XeTeX (without LaTeX) ?
> In particular, it'd be desirable to have it working properly
> with
>    \input miniltx.tex
>    \input ifxetex.sty

Yes, as you can see it is written with this purpose in mind.

> 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.

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.

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.

> 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?

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.

All the best,
Will


More information about the XeTeX mailing list