
這是一個最小的工作範例:
\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}
後面的文字\textcolor{red}{Red}
似乎默認返回黑色xelatex
。有沒有辦法解決這個問題?
答案1
周圍也有類似的問題,例如:
主要問題是,最後\textcolor
有一個\reset@color
不知道要恢復的正確顏色是什麼。
當問題出現時投影儀進來了。
- 圖形載入
pdftex.def
或xetex.def
根據當前編譯器。 pdftex.def
將定義\reset@color
;
xetex.def
將定義\reset@color@nostack
和\reset@color@stack
。- 投影儀重新定義
\reset@color
. xetex.def
將決定是否\reset@color@nostack
或\reset@color@stack
將是\reset@color
。
這裡1,2,3發生在\documentclass{beamer}
和4發生在\begin{document}
.
現在你可以看到一個問題:對於XeLaTeX,因為4發生在之後3,reset@color
被重新定義為非投影機版本。
下面的程式碼更清楚地說明了區別
\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 給出
XeLaTeX 給出
他們倆都不被期望。我們想要的是黃色。但無奈,白色比黑色好。白色確實是由 Beamer 版本完成的\reset@color
,黑色是由xetex.def
版本完成的。