CJK Support

Adding support for ideographic languages is quite tricky. However, once you are done with it, it will work quite well. Other than installing packages, there is some extra configuration work to do.


Your Linux® distribution might already have a CJK (Chinese, Japanese, Korean) package ready for you, so you might be saved the hassle of manually installing everything. Do check before going forward!

There is the possibility of using the ucs package in order to write short snippets of CJK text, but that option is seriously limited as it does not handle, among other things, newlines. Instead, we will install the complete CJK-LATEX package and make it work for both LATEX and PDFLATEX. A lot of this material has been inspired by Pai H. Chou's page about how to setup PDFLATEX.

  1. Download the CJK package. Copy its unpacked files to an appropriate subfolder of $TEXMF, just as you did with the ucs package before (see The ucs Package). The files will be unpacked in a CJK/X_Y.Z folder; it is not important that you take them out, though it will probably be tidier and easier for you to maintain.

  2. Now you have to download a font that supports all the CJK characters you need. You can choose any *.ttf file that covers them, but in this walkthrough we will use Cyberbit. Unzip the file and rename Cyberbit.ttf to cyberbit.ttf, since uppercase might confuse your system.

    Place cyberbit.ttf in a folder together with Unicode.sfd, and generate the *.tfm and *.enc files with the command $ ttf2tfm cyberbit.ttf -w cyberbit@Unicode@. For some reason, sometimes this does not produce the hundreds of files it should. Should that happen in your case, you can download both *.tfm and *.enc files.

    Place the *.tfm files in an appropriate folder, say $TEXMF/fonts/tfm/bitstream/cyberbit/; the *.enc files may be installed in $TEXMF/pdftex/enc/cyberbit/.

  3. Now we need a map file to connect the *.enc files to the font. Download cyberbit.map and install it in $TEXMF/pdftex/config/.

  4. Download another file, c70cyberbit.fd, and place it in an appropriate folder. You may choose, for example, $TEXMF/tex/misc/.

  5. The last file we have to generate is a PostScript® Type 1 font, necessary to read DVI files generated with LATEX. Run the command $ ttf2pfb cyberbit.ttf -o cyberbit.pfb, and copy the resulting cyberbit.pfb to a folder such as $TEXMF/fonts/type1/cyberbit/.

  6. Let's now place cyberbit.ttf among the fonts where LATEX can find it. You could place it in a folder named $TEXMF/fonts/truetype/.

  7. Check the configuration file you find at $TEXMF/web2c/texmf.cnf, and make sure that the line mentioning TTFONTS is uncommented and points to the folder where you saved cyberbit.ttf.

  8. To make it possible for PDFLATEX to use your CJK fonts, it is necessary that you add a line in the configuration file $TEXMF/pdftex/config/pdftex.cfg. Add map +cyberbit.map in the file to complete the configuration for PDFLATEX.

  9. To configure LATEX so that you can produce DVI files with CJK characters, you have to add a line in file ttfonts.map. The file might be in a folder named $TEXMF/ttf2pk/, but you will probably have to look for it. Append the line cyberbit@Unicode@ cyberbit.ttf to it.

  10. Now, you only have to run texhash and the system should be ready.

To test whether your configuration is correct, you can try to compile this test file.

CJK Troubleshooting

There are many things that can go wrong when adding CJK support manually. If something seems not to work, the following checklist might help you.

  • Obviously, since you run LATEX as a user and not as root, you must allow ordinary users to access the new files. Make sure all folders and files are accessible using the chmod command.

  • If LATEX writes a DVI without problems, but you cannot view it, it is almost certainly because of some problems in the automatic generation of *.pk fonts. They are supposed to be generated on the fly when viewing a DVI file, but this might fail for a number of reasons: double-check ttfonts.map for your custom line first. However, it might happen that your ttf2pk command, which is usually invoked by the DVI viewer, has been compiled without support for the kpathsea libraries. If this is the case, ttf2pk --version will make no mention of kpathsea. As support for these libraries is necessary, you might have to find a new package, or recompile FreeType 1 yourself.

How do I input CJK in Unicode?

There are a number of different input engines, and the choice can depend also on personal preference. The author uses Skim, a port to KDE of the Scim engine. Refer to your distribution's documentation to learn how to install these programs. Configuration of such programs can be tricky too, in the case of Skim you will have to define an environment variable XMODIFIERS="@im=SCIM" before starting X.