[XeTeX] fontspec and tabularx (was: Colored Arabic in Tables)
Ross Moore
ross at ics.mq.edu.au
Fri Mar 13 05:18:16 CET 2009
Hi Will,
On 12/03/2009, at 11:31 AM, Will Robertson wrote:
>> Note that the problem also occurs more generally with any font
>> mapping.
>> Any change in a given font mapping outside tabularx is simply
>> ignored by
>> fontspec:
>
> Sorry I didn't catch this thread until now.
> Yeah, it sure seems like tabularx is really weird; fontspec is usually
> fine with these sorts of grouping things.
Now I've located the real cause of this problem,
and it can be fixed within fontspec.sty alone.
That is, there's no need to devise any special
patches for other packages.
The problem is due to your use of LaTeX's \newcounter macro.
As well as doing the obvious thing of establishing a counter,
it also adds the counter name to a list macro: \cl@@ckpt
which allows coding in packages to do things to all the counters
that have been defined.
In particular, within tabularx.sty there is a command
that records the value of all counter names prior to
measuring the column widths,
viz.
\def\@elt##1{\global\value{##1}\the\value{##1}\relax}%
\edef\TX at ckpt{\cl@@ckpt}%
so that they can be reset before typesetting:
\expandafter\tabular\the\toks@
\endtabular}%
\TX at ckpt
You'll appreciate that this upsets your method for controlling
font instances with different attributes, since the
\addfontfeature is encountered first during this measurement
phase, and the counter increment that it causes will then be
nullified by \TX at ckpt .
The fix ?
Don't use LaTeX's \newcounter command, but instead use TeX's
primitive \newcount and \advance to define and increment
the font-instance counters;
viz.
\ifcsname c at zf@famc@\@tempa\endcsname
\expandafter\global\expandafter\advance
\csname c at zf@famc@\@tempa\endcsname\@ne
\else
\expandafter\global\expandafter\newcount
\csname c at zf@famc@\@tempa\endcsname
\fi
>
> Thanks, Ross, for the code to fix things up; I'm not sure yet if I
> want
> to start patching others' packages in fontspec, but maybe doing it in
> xltxtra would be okay.
No need for any of this, if you use TeX primitives
instead of higher-level LaTeX commands.
Besides, this is desirable anyway, since font-loading in XeTeX
is something that really ought to be independent of LaTeX coding;
at least of its counter structures.
>
> Cheers,
> Will
Hope this helps,
Ross
------------------------------------------------------------------------
Ross Moore ross at maths.mq.edu.au
Mathematics Department office: E7A-419
Macquarie University tel: +61 (0)2 9850 8955
Sydney, Australia 2109 fax: +61 (0)2 9850 8114
------------------------------------------------------------------------
More information about the XeTeX
mailing list