[XeTeX] Conflicts between AMS document classes and polyglossia

David M. Jones dmj at ams.org
Mon Dec 29 19:17:08 CET 2008

> From: Ross Moore <ross at ics.mq.edu.au>
> Date: Fri, 26 Dec 2008 16:26:37 +1100
> Reply-To: Unicode-based TeX for Mac OS X and other platforms <xetex at tug.org>

> It occurs because  polyglossia  scans the contents of the
> left & right header marks, inserting \protect commands
> to allow safer expansion within macros.

Just to clarify, polyglossia doesn't intentionally try to insert
\protect's, per se.  It simply redefines \markright and \markboth so
that they subject their arguments to an extra round of expansion via
\unrestored at protected@xdef at a time when this causes \\ to expand to
the two tokens "\protect\\".

> However, there is a piece of coding that  AMS  classes use
> which is not safe against this strategy.
> lines 622--626 of  amsart.cls  are as follows:
>    \toks4{\def\\{ \ignorespaces}}% defend against questionable usage
>    \edef\@tempa{%
>      \@nx\markboth{\the\toks4
>        \@nx\MakeUppercase{\the\toks@}}{\the\@temptokena}}%
>    \@tempa

Correct.  The argument to \markboth here is a token list that is not
invariant under repeated applications of protected edefs.

> These are more robustly written as:
> %  \toks4{\def\\{ \ignorespaces}}% defend against questionable usage
>    \edef\@tempa{%
>      \@nx\markboth{\@nx\protect at backslash
>        \@nx\MakeUppercase{\the\toks@}}{\the\@temptokena}}%
>    \@tempa
> using a new internal macro \protect at backslash  defined as:
> %% RRM --- added 2008/12/26
> \def\protect at backslash{%
>   \expandafter\def\noexpand\\{ \ignorespaces}}

But neither is this.  This will survives a single round of expansion
(which is admittedly good enough for the case at hand), but not a

A safer implementation is

    \DeclareRobustCommand\redefine at backslash{\def\\{ \ignorespaces}}

    \protected at edef\@tempa{%
            \redefine at backslash

which takes advantage of LaTeX 2e's apparatus for dealing with these

David M. Jones
Publications Technical Specialist
American Mathematical Society

More information about the XeTeX mailing list