# Difference between revisions of "TeX Live and CJK"

The below tutorial guides you through getting your Tex to work with the Cyberbit font. If you do not much care what font you use, just make sure you have the texlive-langcjk package installed, and add this to your preamble:

\usepackage[encapsulated]{CJK}
\usepackage{ucs}
\usepackage[utf8x]{inputenc}
% use one of bsmi(trad Chinese), gbsn(simp Chinese), min(Japanese), mj(Korean); see:
% /usr/share/texmf-dist/tex/latex/cjk/texinput/UTF8/*.fd
\newcommand{\cntext}[1]{\begin{CJK}{UTF8}{gbsn}#1\end{CJK}}


and then encapsulate your CJK in \cntext.

\cntext{我的中文寫得很好。}


## Goals

This Tutorial is supposed to explain how to configure your TeXlive Installation to successfully include CJK (Chinese, Japanese and Korean) Characters in your compiled TeX-files. This tutorial is based on the Kile-HowTo on CJK Support. The problem with the kile-tutorial (which nevertheless is very good) is the loose definition of the file and folder structure (for it is, as I think, written to be used for any TeX-distribution). Long story short, using the kile-tutorial, it might take you a couple of hours to find the appropriate places to store and configure your CJK-installation (at least when using TeXlive). Hope this helps you to avoid this hassle.

## Prerequisites

First, you need a working TeXlive installation, including the texlive-langcjk package. (In case you haven't done so already, use pacman to install them) and appropriate fonts. This are the prerequisites on the TeX-part. Needless to say, you should have chosen a character encoding for your system which can deal with complex characters (like UTF8) and some kind of input method for these, like scim.

## The steps

1. Download and configure a CJK Font for your TeXlive distribution. Like done in the kile-tutorial we use the Cyberbit font. Create an empty folder, download the Zip-file and unpack it into the folder. Then rename the file named Template:Codeline to Template:Codeline and download this file into the same folder. Using the command
Template:Codeline
you create some dozens (if not hundreds) of *.tfm files and their corresponding *.enc files.
2. Now, we need folders in the TeXlive-filetree to copy the *.tfm and the *.enc files to their right places. (in the following I presume you have superuser-rights and are in the folder containing the *.tfm and *.enc files.)
Template:Codeline
3. Next, we need to install a map file connecting the *.enc files to the font. Download cyberbit.map.
1. In case the folder Template:Codeline does not exist, create it:
Template:Codeline
2. Then copy the .map file into that folder:
Template:Codeline
4. Then we need a file named c70cyberbit.fd you can download here.
1. Create an appropriate folder (again, if it does not exist):
Template:Codeline
2. And copy the file into it:
Template:Codeline
5. The font itself is still missing in the TeX-distribution tree:
Template:Codeline
6. To make sure that TeX will find the font, we have to add the truetype-folder into the TeX-config. To do so, edit Template:Codeline and look for an entry called "TTFONTS", which should look like this:
Template:Codeline
Although maybe not very elegant, I added Template:Codeline to the end of the line, so that TeX will find the font for sure:
Template:Codeline
7. Although I am not sure we really need this, I created a file called "pdftex.cfg" in the folder Template:Codeline and added a line saying:
Template:Codeline
8. TeX still does not know that it should by now be able to handle CJK input, until we edit Template:Codeline to include the following lines (if they already exist, all you have to do is to uncomment them):
Template:Codeline
9. To finish the configuration, run
Template:Codeline

Hopefully this tutorial will spare you the hours of work I spent configuring CJK in TeX.

## Remarks

This procedure was tested with the following packages:
extra/texlive-core 2008.11906-1
extra/texlive-langcjk 2008.10331-1
And simplified Chinese characters.