9

I'm trying to write Chinese using pdfLaTeX. But currently I can only write Simplified Chinese Characters, If I try writing Traditional Chinese then the text wont show up.

This is what I have:

\documentclass{article}
\usepackage{CJKutf8}
\begin{document}
\begin{CJK*}{UTF8}{gbsn}
文章内容。
\clearpage\end{CJK*}
\end{document}

What would I need to do to get Traditional Chinese?

2

2 Answers 2

10

You must change the font.

gbsn is AR PL SungtiL GB (文鼎简报宋), a font using GB2312 character set. There's no glyphs for Traditional Chinese.

For CJK package, bsmi and bkai are possible choices of CJK font families for Traditional Chinese. Say, you can use

%!TeX program = pdfLaTeX
\documentclass{article}
\usepackage{CJKutf8}
\begin{document}
\begin{CJK*}{UTF8}{bsmi}
老闆來碗麵條。

{\CJKfamily{bkai}老闆來碗麵條。}
\clearpage\end{CJK*}
\end{document}

enter image description here

There may be more fonts if you use a special TeX distribution. For example cwTeX.

However, I think it is always preferred to use modern TeX engines like XeTeX. And it is easier to use any fonts you want to use. An example:

%!TeX program = XeLaTeX
\documentclass{article}
\usepackage{xeCJK}
\setCJKmainfont{MingLiU}
\setCJKsansfont{Microsoft JhengHei}
\begin{document}
老闆來碗麵條。

\textsf{老闆來碗麵條。}
\end{document}

enter image description here

0

Background and why I disagree with most answers available

I struggled around 15 hours because I could not find an all-encompassing answer to the original question:

"How to write Chinese with pdfLatex"

I did not like the general answer "switch to XeTeX" because of 2 reasons:

a) I have a very lengthy document (>800 pages) and I depend on microtype for my specific document, and microtype is not available on XeTeX/XeLaTex/LuaTex b) I am using several languages (greek, arabic, english, spanish, german, chinese and japanese) so it has been, to say the least, a nightmare to establish a working file that is in constant shambles if I add a new package.

If I was not 800 pages deep in my microtype dependence (it is a stylization I am doing with \textls) I would be fine with switching to a modern engine. Nonetheless, a lot of deprecated classes still depend on PdfLatex and, therefore, I think it is important to be able to acommodate to specific questions.

The solution

For macOS Catalina (10.15.7):

  1. Install macTex: https://tug.org/mactex/mactex-download.html I used the version from 15 March 2023. I assume that using MikTeX should work equally but I did not bother to revert my package manager to MikTeX, but I want to believe that either package manager should work. Nonetheless, MacTex did the job for me.
  2. Get zhmetrics: https://ctan.org/pkg/zhmetrics?lang=de Here the core problem is that zhmetrics DOES NOT provide the fonts. Rather, in the README, you can see that they suggest to find a few fonts: (simsun.ttc, simhei.ttf, simfang.ttf, simkai,ttf, simli.ttf and simyou.ttf). The fonts are Microsoft fonts, and therefore, they cannot be distributed with zhmetrics. Nonetheless, they can be found in reputable places online (I omit where but a simple search engine search gives the proper results).
  3. Install the fonts: I simply opened the files in the Mac Finder after download. I am not sure if this did the trick, but I also copied the fonts in the texmf folders (I put them in texmf-config, texmf-dist, texmf-var and the user texmf texmf-local). 3.1. This is a step that I am not sure how efficient it was, but for sure you are welcome to try one-by-one: User folder should be sufficient (find it by typing kpsewhich --var-value TEXMFLOCAL in a bash terminal), but I was desperate so I spread it in all folders. I also added a copy of the fonts to the working folder (e.g. where your root "file.text" which you are compiling is located. 3.1.1. This is an exaggeration but feel free to test one by one, starting with the user folder only and system installation of the fonts.
  4. The rest of the steps are part of the mactex instructions to install fonts (https://tug.org/fonts/fontinstall.html) but in short:
  5. copy the zhmetrics folder to the user folder (the zhmetrics package already has the proper format for Mactex/LiveTex, but be careful not to replace the folder instead of merging)
  6. run sudo -H mktexlsr
  7. run updmap-sys --force --enable Map=ttfonts.map --> This was copied in step 5
  8. run sudo -H mktexlsr again

I have a shortcut in my code:

\usepackage{ifplatform}
\usepackage{CJKutf8} %Added bottom ones for possible compat with arabic
\newcommand{\textcn}[1]{\begin{CJK}{UTF8}{gbsn}#1\end{CJK}}
\ifwindows
        \newcommand{\textjp}[1]{\begin{CJK}{UTF8}{MS Mincho}#1\end{CJK}}
        \else
            \newcommand{\textjp}[1]{\begin{CJK}{UTF8}{min}#1\end{CJK}}
    \fi   

The specific error I was getting was:

!pdfTeX error: /Library/TeX/texbin/pdflatex (file cyberb59): unexpected eof in pk file

I kept looking online and it seems that sometimes the pk´s are not generated properly. I was using "ipaex" for japanese and this problem showed up. by changing to "min" (as seen above). For chinese, I have successfully used bkai and bsmi with the aforementioned steps. Since I am also working on 2 different laptops (mac at home, PC at work) I added the ifplatform which works well with the "else" clause (\ifmacosx was not behaving as expected unfortunately).

Maybe someone runs into this problem in the future, let me know if any of the former conditions help.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .