Per Ola Kristensson | Unicode in Latex

Impact / Press
Other Stuff

Sometimes you need to do something Latex isn't designed to do. Like make Latex render arbitrary Unicode code points (characters) into your final document. You may for example want to render a few Chinese, Japanese or Korean characters into your document.

I recently had the need to enter Korean jamo/Hangul characters into a journal article. What I initially regarded as something that should be rather straight-forward turned out to be a huge mess. However, there is an elegant solution to the problem.

The easy way

There are other approaches but this is by far the easiest solution.

Make sure XeTeX is installed. It is installed in all the major Latex distributions for all the major platforms (Windows, Mac OS X, Linux). XeTeX is a reengineered version of the TeX typesetting engine. The main difference is that XeTeX reads and understands (UTF-8 encoded) Unicode text. No hacks necessary to do that anymore. It also makes any fonts installed on your system automatically accessible to you in Latex, eliminating the need to run complicated scripts and what not.

You can test if you have XeTeX installed by issuing the following command:


You should get a response like this:

This is XeTeX, Version 3.141592-2.2-0.997 (MiKTeX 2.7)

Now let's enter a brief test document (you need a Korean font installed to see the characters in the code):

% filename: test.tex:


% We use this command to define a new environment "koreanfont".
% Whenever we are in this environment the font temporarily changes
% to Gulim (a font capable of rendering Hangul).

\section{Unicode in Latex Test}
This is English text with the standard font intermixed with a couple of Korean Hangul characters here: {\koreanfont 나무}, and here we continue with the standard font.


Run it with:

xelatex test

(note: xelatex, not xetex) and the resulting PDF will look something like this:

ACM Transactions template conflict with XeTeX

There is a glitch in the ACM Transactions class file with the bottomstuff command. It appears the bottomstuff environment is manipulating a counter it shouldn't touch. To resolve it, define a dummy counter:


That's about everything I can think of. I am putting this page up in the hope that Google will rescue someone else. Good luck!