1

The following minimal example produced the desired results:

\documentclass{article}
\usepackage[usenames]{color}

\begin{document}
black {\color{red} red} black

black
\end{document}

But the following example, which is just the same, other than the fact it is RTL, does not produce the desired results:

\documentclass{article}
\usepackage[usenames]{color}
\usepackage{polyglossia}
\setmainlanguage{hebrew}
\def \hebrewFont{David CLM}
\setmainfont[Mapping=tex-text]{\hebrewFont}
\newfontfamily{\hebrewfont}{\hebrewFont}

\begin{document}
black {\color{red} red} black

black
\end{document}

Am I doing something wrong, or is it a simple bug?

3
  • What exactly is the problem here? For me (TL 2013) the red text is red and everything else is black.
    – Alan Munn
    Commented May 22, 2014 at 13:16
  • @AlanMunn - what info I should provide, then? xelatex outputs bad results on my machine. I also get the warning ** WARNING ** Color stack underflow. Just ignore..
    – Bach
    Commented May 23, 2014 at 13:16
  • I would suspect that you are using an old distribution, since there are reports of this back to 2008. Are you using Linux? Which version of XeTeX are you running? (look in the console/log file of your test document.) Also, add \listfiles at the beginning of the test document and add that to your question; you may also have outdated packages.
    – Alan Munn
    Commented May 23, 2014 at 13:29

1 Answer 1

3

That is a known e-TeX bug inherited by XeTeX (newer version of the bidi package tries to work around this in some limited cases, but it is not something that can really be fixed with macro code).

Basically what happens is that the TeX--XeT bidirectional TeX extension used by e-TeX reverses TeX’s internal node list when in RTL mode so that things are typeset from right to left. This works fine most of the time, but it breaks when paired \specials are used, like color which is reprsented internally by a pair of \special{color: push …} and \special{color pop}, as this reversal results in the pop special coming before the push one, causing the issue that have been observed.

The next version of XeTeX (0.99992) attempts to fix the root of this issue, but the code is experimental and may or may not actually end up in the released version.

4
  • Thanks! Do you think that the comment by @AlanMunn is not relevant, then?
    – Bach
    Commented Jul 22, 2014 at 19:41
  • @Bach: I guess so. Commented Jul 23, 2014 at 15:51
  • Do you offer any quick workaround?
    – Bach
    Commented Jul 29, 2014 at 8:36
  • @Bach: using a recent version of the bidi package can help to some extent. Commented Jul 29, 2014 at 13:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .