xcolor 与 xelatex 中可能存在的错误

xcolor 与 xelatex 中可能存在的错误

该命令\pagecolor{white}使用 pdflatex 和 lualatex 会生成纯白色背景,但使用 xelatex 会生成透明背景。

一个简单的例子:

\documentclass{article}

\usepackage[svgnames]{xcolor}
\usepackage{lipsum}

\begin{document}
    \lipsum[1-3]
    \newpage\pagecolor{white}
    \lipsum[1-3]
\end{document}

使用 pdflatex 和 lualatex 时,第一页具有透明背景,第二页为纯白色,但使用 xelatex 时,两个页面都具有透明背景。使用其他颜色时,所有颜色似乎都按预期工作(包括 xelatex)。

如果这确实是一个错误,应该向哪里报告?谢谢。

答案1

使用 xetex 时,背景颜色是用 创建的\special。在您的情况下,这将插入到输出中:

 \special{background gray 1}

通常,这会创建第二个内容流,其中有一个填充颜色的矩形,但如果值为 1(或1,1,1使用 rgb),xetex (xdvipdfmx) 似乎会对此进行优化。这可能不是错误,而是故意的,但如果您无论如何都想报告,请写信给 dvipdfmx 邮件列表:https://tug.org/mailman/listinfo/dvipdfmx

您可以使用“近乎白色”的颜色来欺骗 xetex:

\documentclass{article}

\usepackage{xcolor}
\usepackage{lipsum}
%\definecolor{nearlywhite}{rgb}{0.999999,0.999999,0.999999}
\definecolor{nearlywhite}{gray}{0.999999}
\begin{document}
    a
    \newpage\pagecolor{nearlywhite}
    b
\end{document}

xetex 不会删除这个数字,而是将数字四舍五入为 1,因此您实际上会得到真正的白色。

相关内容