[XeTeX] Polyglossia problems with package lastpage

Ross Moore ross at ics.mq.edu.au
Wed Dec 16 23:42:33 CET 2009

Hi Andreas,

On 17/12/2009, at 8:01 AM, Andreas Hoenen wrote:

> Hi,
> polyglossia doesn't seem to work with package lastpage for several
> languages:
> \documentclass{minimal}
> \usepackage{polyglossia}
> \setdefaultlanguage{hebrew}
> \setmainfont{DejaVu Sans}
> \usepackage{xltxtra}
> \usepackage{lastpage}

The {lastpage} package has nothing to do with it.
  \pageref  is well defined without it, and this is where
the error occurs.
It's not dependent upon the font, except insofar as the
font needs to support Hebrew.

> \begin{document}
> \pageref{LastPage}
> \end{document}
> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
> The compilation output ends with:
> Runaway text?
> LaTeX Warning: Reference `LastPage' on page {\font \zf at basefont  
> ="Dej\ETC.
> ! Forbidden control sequence found while scanning text of \write.
> <inserted text>
>                 }
> l.10 \pageref{LastPage}
> ?
> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
> Similar problems for arabic and farsi, however it works well e.g. for
> russian.  Thus it might be related to "right to left" languages.

Yes, it seems to be somehow related to this aspect.

I can get your example to work (sort of) using:

  \let\normalsfcodes \relax

Then we see the warning:

    LaTeX Warning: Reference `LastPage' on page {\normalfont 1}  
undefined on input line 14.

So the problem appears to be with expanding that instance of   
which really does not belong within the context of a warning message,
(or any  \write  channel, for that matter).

If the \normalfont really needs to be there (e.g., to ensure the
correct font is used when the page number is placed on the page,
then in the context of a  \write  it needs to expand to
the empty string.

Alternatively, something else needs to change to avoid this kind
of error. Something within  Polyglossia  maybe?

> BTW, I'm using TeX Live 2009 as packaged in Debian/sid.

But it occurs on other systems too.

> Thanks for any ideas/hints, Andreas
> -- 
> Andreas Hoenen <andreas at hoenen-terstappen.de>

Hope this helps,


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