I'm writing a document in mixed English and Chinese (with the xeCJK package. I want to add some fake bold headlines using the font Kaiti SC. When I do this using the AutoFakeBold option, this makes it unable to copy the characters in the resulting PDF. How can I fix this?

It seems like xeCJK is loading fontspec behind the curtains, so the issue might be related to it.

Here's a MWE.

%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode

\documentclass[12pt, a4paper]{article}

\setCJKmainfont[Scale=1.2, AutoFakeBold=true]{Kaiti SC} % removing the bold makes the output copyable





Malipivo provided a solution using \pdfliteral, and that technique works for XeTeX too. This technique is used in zhmCJK package. You can read the documented source code of zhmCJK if you are interested in it.

However, it is quite tricky to apply this technique properly in xeCJK:

% !TeX program = XeLaTeX
% !TeX encoding = UTF-8


% value > 0

% hack into xeCJK, you don't need to understand it

% save old definition of \CJKsymbol and \CJKpunctsymbol for CJK output

% apply pdf literal fake bold
  \special{pdf:literal direct 2 Tr \xeCJKembold\space w}%
  \special{pdf:literal direct 0 Tr}%
  \special{pdf:literal direct 2 Tr \xeCJKembold\space w}%
  \special{pdf:literal direct 0 Tr}%


正常汉字。\CJKfakebold{可复制“伪粗体”汉字。English unchanged. 粗体汉字。}正常汉字。


enter image description here

Note that the non-CJK characters are unchanged in \CJKfakebold command. This is a feature by design. You should use \textbf or \bfseries as usual for English.

And note that the code above is not at all complete for xeCJK, puctuation kerning is wrong for example. It should be implemented more carefully (maybe in a very different way) if we add this feature into the package.

| improve this answer | |
  • Interesting. I'm not making a professional document so the kerning is not so important. Is there a way to combine this with the AutoFakeBold setting or should I just adjust the \xeCJKembold value manually? – pg-robban May 26 '14 at 16:22
  • @pg-robban: Well, I think you can set it manually. – Leo Liu May 26 '14 at 17:06
  • Alright, I have one more question before I mark the question as answered: Suppose I have a macro which does something with bold text, currently I do this with \textbf{#1} on that part. Is there any way I can find out if the argument consists of only Chinese characters so that I can apply the correct bold function (\textbf vs \CJKfakebold) or do I need to make separate macros? – pg-robban May 26 '14 at 18:48
  • @pg-robban: \textbf does not change Chinese characters, if you don't set BoldFont feature. And maybe you didn't notice that \CJKfakebold does not change Latin characters, as is shown above. You can use \CJKfakebold{\textbf{正确的粗体 Bold}} safely. – Leo Liu May 27 '14 at 10:45
  • Aha, I got it now :) 麻烦您了,thank you so much. – pg-robban May 27 '14 at 13:51

This is a know XeTeX bug, I don’t think there is currently a way to fix it.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.