# How to typeset rare Chinese characters?

While the around 6,000 common Chinese characters can be supported by the CJK package (or the ctex family of documentclasses) well, what if I want to type some (relatively) rare Chinese characters (it is said that there are about 60,000 Chinese characters in total) which, for example, appeared in ancient poems and documents?

For instance, today I tried typesetting the following characters

in a poem under the CJK environment (later I changed my documentclass to ctexbook), I can't see them in the output pdf document.

I believe there probably are some ways to handle this issue in LaTeX, but I don't know how to carry out these potential solutions to get my missing (but important) characters printed out.

A google search leads me to a reference aiming to solve this problem. The solution therein looks promising in theory, however, I was not able to find the HanGlyph package described in this paper from CTAN so the implementation is still a problem.

It would be greatly appreciated if anyone could provide me with some guidelines (I am making a document that collects Chinese ancient poems. Therefore, the chance that I met these rare characters is pretty high.).

My code:

\documentclass[12pt]{ctexart}

\usepackage{xeCJK}

\begin{document}

\end{document}


My output:

• ShareLaTeX, now Overleaf, can compile with pdftex, xetex, or luatex. If you have a font that supports the characters (try DejaVu, Noto, etc.), you can use it with xetex or luatex. – Thérèse Jan 27 '18 at 4:54
• Later I learned that too. Now I am compiling with XeLaTeX. In the meantime, I changed to the ctexbook document class. However, the main problem, as stated in the question, still persists. – Zhanxiong Jan 27 '18 at 5:29
• I tried CJK package with pdfLaTeX and ctexbook class with XeLaTeX, and both produced those characters in the output. Could you show us a minimum working example to help us help you? – yudai-nkt Jan 27 '18 at 6:14
• @yudai-nkt Sure, please see my edited question. Again, I used ShareLaTeX as my compiler. – Zhanxiong Jan 27 '18 at 6:39
• I confirmed the issue using Overleaf here, but your MWE gave the desired PDF on my Mac. The difference is the fonts in use (FandolSong in Overleaf and STSong on Mac), so the problem is that FandolSong does not have glyphs for these characters. So you need to use an appropriate font as @Thérèse says, but I don't know how to do that in ShareLaTeX because for example STSong and Source Han Serif are not shipped with TeX Live. – yudai-nkt Jan 27 '18 at 8:14

I don’t know whether any fonts available for use with pdftex contain the characters you need. But if you compile with luatex or xetex rather than pdftex, then you can choose any .otf or .ttf font with these characters and load it with fontspec. This Unicode Character Search can help you find appropriate fonts; if you’re interested in purchasing a commercial typeface, myfonts.com allows you to search by character, as explained here.

Having chosen a typeface, you can either install it on your system or, if you are compiling on-line at Overleaf, upload it as described in Overleaf’s help pages. Unless it is one of the many fonts already available on Overleaf, you will then refer to the font by its file name when you invoke fontspec, as in Mico’s example.

I guess you need a font that provides all needed glyphs. SimHei may just be such a font. The font features a bit more than 28,000 glyphs, the vast majority of which would appear to be Chinese characters.

% !TEX TS-program = lualatex
\documentclass[12pt]{article}

\usepackage{fontspec}
\setmainfont{SimHei.ttf}

\begin{document}

\end{document}

• SimHei is available only on Windows among major platforms, and is unusable on ShareLaTeX unfortunately. – yudai-nkt Jan 27 '18 at 8:26
• @yudai-nkt - Thanks for this information. FWIW, I compiled the code above on a MacOS 10.13.3 system running MacTeX2017. The font file is located at /Library/Fonts/Microsoft/SimHei.ttf. – Mico Jan 27 '18 at 8:32
• Thanks, I didn't know that because I still use El Capitan and some Linux. Maybe Apple added SimHei in Sierra or High Sierra. – yudai-nkt Jan 27 '18 at 8:37