CTeX-org / ctex-kit

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

AutoFakeBold 错误的加粗了 eps 内的文本 #509

Closed sjx95 closed 4 years ago

sjx95 commented 4 years ago

从 TeX Live 2019 Final 切换至 2020 并 Update 到最新(2020/05/11)后,发现 CTeX 的 AutoFakeBold 选项会把 eps 内的文本一起加粗,现象如下: image

而 TeX Live 2019 Final 可以正常加粗: image

进一步测试发现此问题还存在于: TeX Live 2018 Final (Debian 10 WSL repo) TeX Live 2019 ISO (Windows, http://ftp.math.utah.edu/pub/tex/historic/systems/texlive/2019/texlive2019-20190410.iso) TeX Live 2020 (Windows, tlnet-20200510) 但是 TeX Live 2019 Final (Windows, http://ftp.math.utah.edu/pub/tex/historic/systems/texlive/2019/tlnet-final/ ) 就没事,这就让人很郁闷了。现在我重新安装了 2019 Final,总算能继续改大论文了。

根据现象,由于第二个图显示正常,所以我猜测可能是 xeCJK 没有正确结束伪加粗?不知这一问题应当如何解决?

TeX:

\documentclass[AutoFakeBold]{ctexart}
\usepackage{graphicx}
\setCJKmainfont{SimSun}
\begin{document}

测\textbf{试}
\includegraphics[scale=0.5]{figure}

我\textbf{傻}了
\includegraphics[scale=0.5]{figure}

\textbf{这样不行}{}\relax
\includegraphics[scale=0.5]{figure}

\end{document}

测试样例: test-eps.zip

qinglee commented 4 years ago

这是底层 dvipdfmx 驱动的问题,已经被报告过多次了,如本项目中的 #353, #362, #440

这个问题在 TeX Live 2019 中修复了,但是根据 @aminophen 在 https://github.com/pgf-tikz/pgf/issues/692#issuecomment-592883450 提供的信息:

In r53973, dvipdfmx restored the previous behavior due to

so the fake-bold problem reappeared.

因为某些原因,TeX Live 2020 中的 dvipdfmx 恢复了之前的修改,导致这个问题又重现了。

总之,这个问题是由上游引起的,本项目无能为力。你可以报告给 TeX Livedvipdfmx 的邮件列表。

muzimuzhi commented 4 years ago

提供一个临时方案,思路是在插图命令前后添加 pdf literal,局部修改 text rendering mode (0 Tr)。(还有很少用的 \includegraphics* 语法没有兼顾,理论上可以通过 patch \includegraphics 的某个内部宏来实现,先这样吧。)

\makeatletter
\let\includegraphics@backup\includegraphics
\renewcommand\includegraphics[2][]{%
  \special{pdf:code q 0 Tr}%
  \includegraphics@backup[#1]{#2}%
  \special{pdf:code Q}%
}
\makeatother

效果测试

% 故意设置很大的 AutoFakeBold,突出效果
\documentclass[AutoFakeBold=10]{ctexart}
\usepackage{graphicx}
% 使用某个没有粗体的字体,macOS 可以用 STSong
\setCJKmainfont{SimSun}

\begin{document}

% 使用 mwe 宏包提供的 eps 文件
默认效果测\textbf{试}
\includegraphics[scale=0.5]{example-image.eps}

\makeatletter
\let\includegraphics@backup\includegraphics
\renewcommand\includegraphics[2][]{%
  \special{pdf:code q 0 Tr}%
  \includegraphics@backup[#1]{#2}%
  \special{pdf:code Q}%
}
\makeatother

临时方案效果测\textbf{试}
\includegraphics[scale=0.5]{example-image.eps}

\end{document}

image

sjx95 commented 4 years ago

很抱歉没有仔细搜索历史 issue,并十分感谢两位前辈提供的信息。 由于我已经把 TL2020 换成了 TL2019 Final,在论文完稿前应该暂时不会去折腾了,等后面结题了再仔细研究一下。

inbzab123 commented 4 years ago

你可以改变eps文件的文字为通道,这样就不会被加粗了,Inkscape,可以导出为文字通道格式的eps文件

FrankSFLYS commented 4 years ago

我的问题类似,是与 tcolorbox 的兼容性,在 \section 之后紧接着一个 tcolorbox,后面的段落会被加粗,如果 \section 之后先出现一个段落,再放 tcolorbox 就不会有问题。

我下载了一个粗体的字体,暂时解决了问题,但是感觉有点不舒服

FrankSFLYS commented 4 years ago

muzimuzhi commented 4 years ago

@FrankSFLYS 1) 新问题,请发新 issue 提问 2) 提问时提供 MWE