Posts Tagged ‘utf8’

大成功! Japanese in LaTeX

Friday, July 29th, 2011

Urgh… today is a proud day for finally I got Japanese working in LaTeX files! Can’t believe I got to live to see this day!

If you need to get this working, too, follow these simple steps in Ubuntu:

1) Install the following packages:
texlive
texlive-latex-extra
latex-cjk-common
latex-cjk-japanese-wadalab

2) Download this tex example file:
http://pastebin.com/tasDkhZ3

3) Compile the using the following command:
pdflatex <file>.tex

4) Rejoice!

Some explanations:
texlive is of course the basic TeX distribution. The additional packages provide stylesheet files required by the example file (e.g. ucs.sty). Trying to compile without the package latex-cjk-japanese-wadalab results in the following messages in the log file:

LaTeX Font Warning: Font shape `C70/min/m/n’ undefined
(Font)              using `C70/song/m/n’ instead on input line 20.

! Undefined control sequence.
try@size@range …extract@rangefontinfo font@info
<-*>@nil <@nnil

Reason is, tex cannot find an appropriate font. Thus, the last package latex-cjk-japanese-wadalab must be installed which provides additional fonts for Japanese in tex.

One neat trick I learned during the process is the following:
If you get some warnings or error message about missing files in a tex log file, you can search for these file names on the Ubuntu packages page. Make sure you search in the content of packages! Sometimes this helps you to find which additional packages have to be installed!

But is it really worth it? Check out the following screenshot:

Comparison between TeX and PDF from LibreOffice

The pdf in the back is the compiled tex file, the one in front is a pdf file exported from LibreOffice. To be honest, the Japanese part look absolutely the same to me. Ergo: If you don’t have to deal with large documents and mixed texts, LO should do the trick as well.

Many thanks to Lucas for his help and the link to the example file! His article on TeX can be read in the 50th issue of the Ubuntu magazine “Full Circle
Thanks also to Simon whose help on TeX is always invaluable.