Last weekend I did the heretofore-thought-impossible: I installed Chinese writing capabilities on my LaTeX system. Previously, I had been about 75% sure that this could never, ever, happen, but with some effort I did manage to get it up and running. And now that it works, it's extremely nice to have: I can run a nice GUI LaTeX editor like Kile, paste in some Chinese text in the middle of the file, click the quick build button and get a .pdf with Chinese characters.

In the interest of helping other people get to this point, and because there are only five thousand of these sites already existing so clearly we need more, I present here my version of the guide to set up Chinese fonts and Chinese writing in LaTeX.

Written 27 January 2006. Comments and questions welcome: kirchner "at" ucsc "dot" edu.

1. Prerequisites: Things you need, obviously: a working (La)TeX system; knowledge of where your (La)TeX files are stored; permissions to mess around with files in the (La)TeX tree; knowledge of how to install new (La)TeX packages; and knowledge about how to use the console/terminal/command/whatever on your system.

Specifically, you need: the CJK package for LaTeX. It is developed by the excellent Werner Lemberg and you can download it right here: CJK extensions for LaTeX. Currently the file you'd want is called "cjk-4.6.0.tar.gz", but that will change when new package versions are released. Download and install that package as per the usual.

You need a truetype font with information about Chinese fonts. The font I used is called cyberbit. It looks like the correct place to download this font is now here: Titus Unicode Font Download Page. The copyright status of this font seems to be uncertain right now so this link might change. It's not necessary that you use this font; you can use anyone that you want, as long as it's a truetype font (the filename should end in .ttf) and it has information on Chinese characters. In the rest of this page, I assume you are starting from a file called "cyberbit.ttf". If you're using something else, replace "cyberbit" everywhere it occurs in my instructions with the name of your font. Note that this is case sensitive, so if your file is Cyberbit.ttf, either rename it or type Cyberbit everywhere I have cyberbit.

You also need these files: ttf2tfm and ttf2pk. They were already there on my linux box and on my windows laptop, so you probably have them too. I'm sure you can find them online if you don't have them already.

Those are the prerequisites. All set? Cool. Open up your terminal and go to the root of your TeX tree. I'll assume this is .../texmf . Adjust all the following references to that file to whatever your local configuration is.

2. Find your TeX fonts directory. This is probably something like: .../texmf/fonts . Go in there, and there should be a "truetype" directory. Go in there, or if it doesn't exist, create it and go in there. Now make a directory called "chinese". Go into that and copy cyberbit.ttf to that directory.

3. Run this line: "ttf2tfm cyberbit.ttf cyberbit@Unicode@". Now watch fun columns of characters scroll by on your screen for a while.

4. Run this line: "mkdir cyberbit"

5. Run this line: "mv *.tfm cyberbit/"

6. Go back to the root of your TeX tree, and then descend to find where your Unicode .fd files are. For me, this was .../texmf/tex/latex/CJK/UTF8 . In that directory, create a file called C70cyberbit.fd . The text of this file should be the following:

\DeclareFontFamily{C70}{cyberbit}{\hyphenchar \font\m@ne}
\DeclareFontShape{C70}{cyberbit}{m}{n}{<-> CJK * cyberbit}{}
\DeclareFontShape{C70}{cyberbit}{bx}{n}{<-> CJKb * cyberbit}{\CJKbold}

7. Find ttfonts.map . For me, this was in .../texmf/ttf2tfm/base . Open ttfonts.map and make sure it has this line:

cyberbit@Unicode@ cyberbit.ttf

8. Run:
"mktexlsr"
"updmap"
"texhash"

Now you can make LaTeX documents with Chinese! Hooray! You're all done!
... except not quite. Here's the deal: the good news is that you can make LaTeX documents with Chinese just this easily:

In the package declarations, include

\usepackage{CJK}

In your document, introduce a Chinese text section with

\begin{CJK}{UTF8}{cyberbit}

and close it with

\end{CJK}

You can also put regular Latin characters in that textblock and they look just fine. I just put the \begin command at the top of my document and the \end at the very bottom, and type everything in between them so I don't even have to worry about it, I can just drop in Chinese wherever, and the English comes out looking just fine.

However, there is bad news: you can't yet see these documents. For some reason, the fonts for writing Chinese from LaTeX are not the same as the fonts for displaying those fonts in a dvi viewer or converting them to postscript. I don't know why. The short of it is, you need to make some .pk files too from your fonts.
I have to be honest here: I got these fonts working on my linux machine, but I still have not got them working right on my laptop. Hopefully what I have here will help, but be thusly warned.

Go back into your fonts directory, where you descended earlier to put the truetype font. You should have a "pk" directory here. Enter it, or make it and enter it if need be. Make a "chinese" directory, enter it, make a "cyberbit" directory and enter it. The old-fashioned way is to run ttf2pk here, to convert all your fonts over. Oddly, I couldn't run this for all the files, so I had to run it about 100 times to make all the files I needed here. That was no good; so for your benefit, I have zipped them all together and put them here: cyberbit pk package. If you're using the cyberbit font, you should be able to download this file, extract all of the compressed files into your pk/chinese/cyberbit directory, then again run "mktexlsr", "updmap" and "texhash". I hope this will work for you! If it does, then you are all set for CJK LaTeXing! Try it out.

If this doesn't work, or if you aren't using the cyberbit font, then you still have a little way to go. I recommend trying "ttf2pk --help" to get started; from that, I was able to figure out what I needed to do on my linux machine, after minimal mucking around. I think this should get you up and CJKing with only a little more work.

Finally, I know that no single CJK-latex help site was completely correct or useful for my own setup. So I expect that this page will not be perfect for you either. I recommend comparing, contrasting, borrowing and experimenting with this page and with these other pages, which were very helpful for me:

Japanese Font and (CJK-)LaTeX

Setting up CJK-LaTeX on linux

How to make LaTeX (teTeX) handle unicode and CJK in MacOSX

Using unicode postscript fonts with CJK LaTeX (Windows cygwin instructions)

CJK support (for Kile, which is a fairly great program)