Closed MrLmath closed 3 years ago
和 ctex 无关,是 dvipdfmx 的问题。这个问题已报告多次,最接近的是 #440,相关小结见 https://github.com/CTeX-org/ctex-kit/issues/509#issuecomment-627260331 。
从生成的 PDF 看,实际是 text rendering mode (pdf 运算符 Tr
) 的作用范围溢出。从现象上看,就是
0.4pt
绘制了;https://github.com/CTeX-org/ctex-kit/issues/509#issuecomment-627475541 提供了一种临时方案(保护下方内容不被加粗),下面的 \markLocalGraphicsState
提供另一种方案(限制伪粗的作用范围)。
\documentclass{ctexart}
\newCJKfontfamily\st{FandolSong}[AutoFakeBold]
\usepackage{tikz}
\newcommand\markLocalGraphicsState[1]{%
\special{pdf:code q}%
#1%
\special{pdf:code Q}%
}
\begin{document}
\markLocalGraphicsState{\textbf{\st 测试}}
\begin{tikzpicture}
\draw (0,0) node [left] {$A$} --(1,0) node [right] {$A$};
\end{tikzpicture}
\end{document}
可以把相应代码 patch 进 \textbf
,这样自动一些。
\documentclass{ctexart}
\newCJKfontfamily\st{FandolSong}[AutoFakeBold]
\usepackage{tikz}
\usepackage{xpatch}
\expandafter\xpretocmd\csname textbf \endcsname
{\special{pdf:code q}}
{}{\fail}
\expandafter\xapptocmd\csname textbf \endcsname
{\special{pdf:code Q}}
{}{\fail}
\begin{document}
\textbf{\st 测试}
\begin{tikzpicture}
\draw (0,0) node [left] {$A$} --(1,0) node [right] {$A$};
\end{tikzpicture}
\end{document}
用您的方案完美解决了问题,感谢,我应该先搜索下同类问题的。
开启伪粗后,当\textbf命令后紧跟tikzpicture环境会造成图片中的文本及此后所有文本都被加粗
最小示例代码