Shihui Guo

Ubuntu + Latex + CJK + UTF8/GBK

It is always a bit mess to re-install these packages, so I decide to write a short tutorial for myself, also for anyone this might benefit.

Start from scratch, then you need to install latex (or texlive) and cjk package

sudo apt-get install texlive latex-cjk-all

After this, you should be able to compile a file using UTF-8 encoding. However, since the character library using UTF-8 encoding is far less than GBK, I went further to add GBK support.

There are two points you need to take care
- save your file in GBK encoding, easiest and most likely to ignore
- install GBK fonts, gives you most trouble here

Then let's install GBK fonts then. First download the program called gbkfonts (you may downlaod from CTEX website, in case it fails, download from this gbkfonts).

Make sure you got Chinese fonts installed on your system, if not, install some free fonts

sudo apt-get install ttf-wqy-zenhei ttf-wqy-microhei

Unzip, make executable and move it to /usr/bin/

gunzip gbkfonts.gz
chmod +x gbkfonts
sudo mv gbkfonts /usr/bin/

Make a folder under your home folder, and generate the gbkfonts inside this folder

mdkir ~/texmf
cd ~/texmf
gbkfonts /usr/share/fonts/truetype/wqy/wqy-zenhei.ttc hei

Then update the system paths to search for the fonts

sudo mktexlsr
sudo updmap

In some cases, you might want to try adding "Map cjk.map" to the following file before updmap command:

sudo vim /var/lib/texmf/web2c/updmap.cfg

By far you will be able to compile the latex files in GBK encoding

点击查看评论