CTeX-org / ctex-kit

Macro Packages and Scripts for Chinese TeX users
976 stars 124 forks source link

xpinyin: 不能正确处理颜色 #537

Closed stone-zeng closed 3 years ago

stone-zeng commented 4 years ago
\documentclass{article}
\usepackage{xeCJK,xcolor,xpinyin}
\begin{document}
\textcolor{red}{\xpinyin{拼}{pin1}音}
\textcolor{red}{\xpinyin[format=\color{red}]{拼}{pin1}音}
\end{document}

image

之前 xpinyin 会将拼音与文本显示为相同的颜色,是不是因为 LaTeX kernel 修改了颜色分组有关定义?

stone-zeng commented 4 years ago

说起来,latex3 的颜色和 xcolor 是兼容的吗?

\documentclass{article}
\usepackage{xcolor}
\begin{document}
\textcolor{red}{
  \expandafter\show\csname l__color_current_tl\endcsname
}
\end{document}

输出:

> \l__color_current_tl=macro:
->{gray}{0}.
<recently read> \l__color_current_tl
muzimuzhi commented 4 years ago

https://github.com/CTeX-org/ctex-kit/blob/6405ee14065c022ea9c2f030df727b20f7150c0c/xpinyin/xpinyin.dtx#L595-L612 里 604 行的 \color_ensure_current: 删去,问题就好了。但我不知道为什么。overleaf 上的 texlive 2019,问题不复现。

以及,上面的 \color_group_begin:\color_group_end: 是多余的,可以删去,因为 \hbox_set:Nn 自带了一层 group。见提交 https://github.com/latex3/latex3/commit/a3fef0fe81ce1980943b924e09a5d6f354945653