# [XeTeX] geometry.sty FIX for XeTeX 0.994

Bruno Voisin bvoisin at mac.com
Wed Jun 7 11:05:13 CEST 2006

Le 7 juin 06 à 10:01, Ralf Stubner a écrit :

> Will Robertson <wspr81 at gmail.com> writes:
>
>> Use the following to temporarily fix the problem until geometry is
>> updated; note that it works whether the document is typeset using
>> either the XeTeX or pdfTeX backends:
>>
>>    \ifdefined\XeTeXversion
>>      \newcount\pdfoutput
>>      \pdfoutput0\relax
>>    \fi
>>    \usepackage[dvipdfm]{geometry}
>
> The most appropriate place for something like this is probably the
> geometry.cfg that is shipped with XeTeX's TEXMF tree.

I don't think that's enough. The "controversial" part of geometry.sty
is:

\def\Gm at checkdrivers{%
\ifx\pdfpagewidth\@undefined\else
\ifnum\pdfoutput=\@ne
\Gm at setdriver{pdftex}%
\fi
\fi
\ifx\VTeXversion\@undefined\else
\ifnum\OpMode=\@ne
\Gm at setdriver{vtex}%
\else
\ifnum\OpMode=\tw@
\Gm at setdriver{vtex}%
\fi
\fi
\fi
\ifx\Gm at driver\Gm at dvips
\Gm at specialtrue
\else
\ifx\Gm at driver\Gm at dvipdfm
\Gm at specialtrue
\fi
\fi}%

It seems to add to the explicit choice of driver, either through an
option such as \usepackage[dvipdfm]{geometry} or in the config file
geometry.cfg, another implicit check inside the package geometry.sty
itself. Specifically, the above code sets the driver to [pdftex] if
\pdfoutput is 1, and to [vtex] if \OpMode is 1 or 2; it's only
afterwards that the driver setting (either explicit or implicit) is
taken into account, with \Gm at special set to true in case the driver
is either [dvips] or [dvipdfm]. And because of the way this works,
the implicit driver setting, when it applies, seems to take over any
explicit setting.

Thus, in this case, I think the config file geometry.cfg provided by
Jonathan is not enough: the package file geometry.sty itself must be
changed. I think that geometry.sty should replace its implicit checks
for [pdftex] and [vtex] by calls for ifpdf.sty and ifvtex.sty:

\RequirePackage{ifpdf}
\RequirePackage{ifvtex}

and then use the switches \ifpdf and \ifvtex that these packages
provide.

An alternative, possibly more viable in the long term, is the
preparation of a package ifxetex.sty, based on the code in ifpdf.sty
and ifvtex.sty and taking into account the introduction and/or
evolution in time of the command \XeTeXversion.

Bruno Voisin