2

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
  • 1
    One way this can happen is if your font does not have the character. If you add \tracinglostchars=2 near the top of your document, do you get a warning message on the console about your font not containing the character?
    – Davislor
    Dec 23 '20 at 9:03
  • Without \tracinglostchars=2, TeX (in a bad decision decades ago that we are now stuck with) will silently log a warning message in the middle of your .log file and put a blank space where the character should be.
    – Davislor
    Dec 23 '20 at 9:05
2

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
1
  • Thank you for your answer sincerely. It solves my question in an easy way.
    – wenxi li
    Dec 24 '20 at 14:37
1

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.

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.