TransWikia.com

Some Chinese characters can no show using ctex

TeX - LaTeX Asked by wenxi li on March 31, 2021

I use overleaf to edit my CV, but I find a character "珅" in Chinese cannot be shown in the compiled PDF. I also try XeCJK, but it doesn’t work too.
Here is my code:

documentclass[a4paper]{article}
usepackage[UTF8]{ctex}
begin{document}
珅
end{document}

2 Answers

The default fontset (fandol) loaded by ctex and xeCJK may not have glyphs for many archaic Chinese characters. If you're compiling this on Overleaf, you can use the fontset=ubuntu option to load Noto Serif CJK SC:

usepackage[UTF8,fontset=ubuntu]{ctex}

Or if you prefer to load the font explicitly:

usepackage{ctex}
setCJKmainfont{Noto Serif CJK SC} % or some other font that has the glyph

Answered by imnothere on March 31, 2021

I’m going to expand on imnothere’s fine answer with a few best practices.

documentclass[a4paper]{article}
tracinglostchars=2
usepackage[UTF8, fontset=none]{ctex}

defaultfontfeatures{ Scale=MatchUppercase,
                      Ligatures=TeX,
                      Renderer=HarfBuzz }

%% Noto CJK fonts available at
%%  https://www.google.com/get/noto/help/cjk/
setmainfont{Latin Modern Roman}[Scale=1.0]
setCJKmainfont{Noto Serif CJK SC}
setCJKsansfont{Noto Sans CJK SC}
setCJKmonofont{Noto Sans Mono CJK SC}

begin{document}
珅
end{document}
  • You want tracinglostchars=2 so that TeX will give you a warning when your font is missing a character. Without this command, the warning will be silently buried in the middle of your .log file.
  • In LuaLaTeX as of 2020, you need to load your CJK fonts with the Renderer=HarfBuzz, or you will get an out-of-memory error. XeTeX uses HarfBuzz by default and works fine. XeLaTeX should give you a benign warning if it sees Renderer=.
  • You probably want a Scale= option if you are mixing different fonts.
  • You might wish to set sans-serif and monospace fonts as well.
  • If you would be overloading the font set from the package anyway, you can skip loading one with fontset=none.

Answered by Davislor on March 31, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP