7

Here is a minimal working example:

\documentclass{beamer}
\usepackage{tikz}

\setbeamercolor{background canvas}{bg=black}
\setbeamercolor{normal text}{fg=white}

\begin{document}

\begin{frame}
\frametitle{Test}

Normal \textcolor{red}{Red} Normal

\begin{tikzpicture}
\node at (0,0) {Normal \textcolor{red}{Red} Normal};
\end{tikzpicture}

\end{frame}

\end{document}

Compiling this in pdflatex gives the expected output: enter image description here

But compiling this in xelatex gives the following strange behaviour: enter image description here

The text following the \textcolor{red}{Red} seems to be defaulting back to black in xelatex. Is there a way to fix this?

Ramprasad
  • 337

1 Answers1

2

There are similar questions around, for example:

The main question is that at the end of \textcolor there is a \reset@color which does not know what is the proper color to restore.


The problem evolves when comes in. Basically the story is as follows:

  1. loads pdftex.def or xetex.def according to the current compiler.
  2. pdftex.def will define \reset@color;
    xetex.def will define \reset@color@nostack and \reset@color@stack.
  3. redefines \reset@color.
  4. xetex.def will decide whether \reset@color@nostack or \reset@color@stack will be the \reset@color.

Here 1, 2, 3 happens at \documentclass{beamer} and 4 happens at \begin{document}.

Now you can see a problem: for XeLaTeX, since 4 happens after 3, reset@color is redefined to be a non-beamer version.


The following code illustrate the difference more clearly

\documentclass{beamer}
\usepackage{tikz}

\setbeamercolor{background canvas}{bg=teal}
\setbeamercolor{normal text}{fg=white}

\begin{document}

\frame{
    \tikz{
        \node[text=yellow]{
            Yellow
            \textcolor{red}{Red}
            What?
        };
    }
}

\end{document}

LaTeX gives

and XeLaTeX gives

Neither of them is expected. What we want is yellow. But reluctantly, white is better than black. And white is indeed done by the beamer version of \reset@color and black is done by the xetex.def version.

Symbol 1
  • 36,855