Mini-HOWTO: Thai Language Support for LaTeX in Windows, using MiKTeX 2.5 (and 2.6 and 2.7)


— updated —
* MikTeX 2.6 I have tried this also on MiKTeX 2.6 and everything works just fine, except that some files have to be put on different directory, see the bottom of the article
* MikTeX 2.7 I also tried this on MikTeX 2.7 and the step is still the same as 2.6.
* I also added a figure roughly showing what you have to do, exclude the modification to the existing miktex file.

[img_assist|nid=2044|title=MikTeX Thai Font Installation Guide|desc=|link=node|align=left|width=640|height=415]

— end of update —

There are several pressing requests given to me to describe the process needed to enable Thai support on LaTeX for Windows (in MiKTeX), a topic I wish to cover in the upcoming LaTeX guide series. I will publish a quick and dirty method on the blog first and it will be refined and included in the series later.

Please note that if you are running MiKTeX version 2.4, which is now out-of-date and no longer available in the MiKTeX site, the easiest way is to use the MiKTeX Thai Extension which is extremely easy to setup. The package cannot be used in MiKTeX 2.5 nor 2.6.

For those who just want to get the thing done, I recommend you to consult this page (in Thai) at the school of physics, Suranaree University. You will find everything you need to start using Thai in TeX, described in an easy step-by-step manner.

However, if you wish to do things manually, starting from a minimal set of input and work your way to the actual installation of the font file, please read along.

These step is generic and should works on all distribution of LaTeX, providing that the file is put to there respective folder (which, sadly, differs from distro to distro).

Basically, you have to do two things.
1. Enable Thai support by patching the babel package.
2. Install Thai font to MikTeX.

First, you will need thailatex package. Please download the source package. As of May 2007, the latest version of the package is 0.4.0-1. This package includes Thai Font and babel package patching.

Optionally, you will also need sed, a stream editor. With sed, the installation process becomes much more easier.

This guide is tested against MiKTeX version 2.5 on Windows XP.

The first thing to do after obtaining the thailatex source package is to extract it somewhere, says c:\thailatex-0.4.0. After that, you have to follow these steps.

1. Enable Thai Support in Babel

Babel is a package for multilingual support in LaTeX. Sadly, the standard distribution of babel does not include Thai. Dr. Surapant Meknavin, then a researcher at NECTEC, created the first version of Thai Language Definition File to be used as a part of babel package. After that, the file is maintained by Theppitak, Poonlap and Chanop, subsequently.

To enable Thai in babel you will need the following files.


The style files (.sty) and encoding file (.def) come already with the thailatex. They should be located in c:\thailatex-0.4.0\babel. The Language Definition File (.ldf) is to be generated from the source file, thai.dtx by executing this command, in the same folder as the thai.dtx.

c:\thailatex-0.4.0\babel\>latex thai.ins

Now, you should put these files into the babel folder of your MikTex installation, presumably to be at C:\Program Files\MiKTeX 2.5\tex\generic\babel.

c:\thailatex-0.4.0\babel\>copy *.sty "C:\Program Files\MiKTeX 2.5\tex\generic\babel"
c:\thailatex-0.4.0\babel\>copy lthenc.def "C:\Program Files\MiKTeX 2.5\tex\generic\babel"
c:\thailatex-0.4.0\babel\>copy thai.ldf "C:\Program Files\MiKTeX 2.5\tex\generic\babel"

Next, we have to patch the original babel package to recognize Thai language. Edit C:\Program Files\MiKTeX 2.5\tex\generic\babel\babel.sty by your favorite text editor. Add the following line to the file.


The line should be added in the “declare option” part, i.e., it should be inserted beside the other \DeclareOption lines. Since the options in the file are originally sorted by language, it is nice to put our line next to Turkish option. Simply add the line after this line.


Now, babel package knows Thai language. The next step is to install Thai font to MikTeX.

2. Font Installation

Font installation in TeX is quite a pain. There is no one-click step that just put the font up and running like installing font in Windows. I would recommend you to read the documentation of FONTINST for an insight on the font mechanism of TeX. Let us proceed to the installation of font.

Font comes in various format, most notably, Type 1 Font and True Type font. For Windows users, True Type is ubiquitous. However, TeX was created in *nix platform where Type 1 is more common. Type 1 is usually distributed into two files, .pfb file (sometime disguised as .pfa) and .afm file. The .pfb is the actual Type 1 font containing the description of a font in terms of a Bezier curve, while .afm is an Adobe Font Matric which contain information about size, ligature, of each curve.

Starting from these two files, we will construct .tfm (TeX Font Metrics) which is used by TeX and .vf (virtual font) which is used by DVI driver to actually render the font. To create a .vf file, we need immediate format .vpl (virtual property list). The .vpl is not need by TeX and can be deleted afterward.

Apart from the font itself, we still requires more information about the font. We need LaTeX encoding file and font encoding file. The first one maps TeX character into a slot, or a numbered representation of a glyph and the latter maps slot into an actual glyph in the font. Both type of files come already with thailatex package. The LaTeX encoding file is available in c:\thailatex-0.4.0\fonts\ and c:\thailatex-0.4.0\babel\ as lthenc.def while font encoding files are available at <code>c:\thailatex-0.4.0\fonts\*.fd.

At this stage, we know what we need and what we have. We then proceed to produce what we need from what we have and then put everything required into its proper place in the MiKTeX distribution. Here is the procedure for doing so.

2.1 Create a .vpl file and .tfm file
2.2 Create a .vf file
2.3 Put the generated font files into the appropriate directories
2.4 Put the encoding file into the appropriate directory
2.5 Put the font definition file for babel package
2.6 Create a font mapping file and put it into appropriate directory
2.7 Update MiKTeX database.

For our illustrative purpose, we will assume that our type 1 font file is norasi.afm. Be noted that we must do all of these on every type 1 font file.

2.1 Create a .vpl file and .tfm file

First, we construct a “raw” TeX font metrics file and a virtual property list from Type 1 file. Then, we construct a mapped TeX font metrics file and a property list file from a virtual property list file. We will use norasi font for our example. Run the following command in c:\thailatex-0.4.0\fonts\ folder.

afm2tfm norasi.afm -v norasi.vpl -T lthuni.enc rnorasi.tfm

The -T argument indicates the font encoding file used to create the output file. Be noted that the raw .tfm file begins with letter r. The font encoding file lthuni.enc is already available with the thailatex at c:\thailatex-0.4.0\fonts\, for your convenience.

2.2 Create a .vf file

Next, we construct the virtual font file and a mapped TeX font metrics file. Execute the following command in the same folder.

vptovf norasi.vpl norasi.vf norasi.tfm

2.3 Put the generated font files into the appropriate directories

Now, we have all font files we need. Let put them into the appropriate place. First, put all font files in their respective folder.

copy norasi.afm "C:\Program Files\MiKTeX 2.5\fonts\afm\public\thai"
copy norasi.vf  "C:\Program Files\MiKTeX 2.5\fonts\vf\public\thai"
copy norasi.tfm "C:\Program Files\MiKTeX 2.5\fonts\tfm\public\thai"
copy rnorasi.tfm "C:\Program Files\MiKTeX 2.5\fonts\tfm\public\thai"
copy norasi.pfb "C:\Program Files\MiKTeX 2.5\fonts\type1\public\thai"

2.4 Put the encoding file into the appropriate directory

Next, we put an encoding file to their respective folder also.

copy lthuni.enc "C:\Program Files\MiKTeX 2.5\fonts\map\dvips\thai"

2.5 Put the font definition file for babel package

We also need to put the font definition file to the babel package folder. The font definition which involves in LaTeX encoding is already given in the thailatex package and is located in c:\thailatex-0.4.0\babel\.

cd c:\thailatex-0.4.0\babel\
copy lthnorasi.fd "C:\Program Files\MiKTeX 2.5\tex\generic\babel"

2.6 Create a font mapping file and put it into appropriate directory

The last thing is to tell dvips that we have the font for it and it is mapped with the specific TeX font. This involves several step. To do this, we create a text file using any text editor and name it as The file should have this line.

rnorasi Norasi " LTHEncoding ReEncodeFont " &gt;

This line will create a file which contain the line we need.

WARNING!!!! be noted that sed that is built natively for windows might produce *nix style end of line which render the line to be incorrect. I recommend using sed that comes with cygwin. A quick work around would be using the last words in the line instead of end-of-line symbol.

The generating of each required file is necessary for every font. Please make sure that all font files have undergo
ne this step, so that includes all information. The following batch file would run the script on all font files and utilize sed. You still need to copy each font file to the appropriate location.

FOR %%I IN (*.afm) DO afm2tfm %%I -v %%~nI.vpl -T lthuni.enc r%%~nI.tfm | sed -e "s/enc/enc &lt;%%~nI.pfb/"  &gt;&gt;
FOR %%I IN (*.vpl) DO vptovf %%I %%~nI.vf %%~nI.tfm

OPTION2: for non-sed user

Even without sed, we could do that by running a batch file containing these lines.

FOR %%I IN (*.afm) DO afm2tfm %%I -v %%~nI.vpl -T lthuni.enc r%%~nI.tfm &gt;&gt;
FOR %%I IN (*.vpl) DO vptovf %%I %%~nI.vf %%~nI.tfm

This is almost the same as in the OPTION_1 except that the “sed” part is omitted. So, we have to do this manually. For every line in the generated from the above batch file, you have to append xxx.tfm where xxx is the name of the original font file. If you happen to have any text editor that supports regex you could do find&replace using the following regex command.

FIND strings

(r(.+)\ .+\ \"\ .+


by Chaiwat on Sun, 17/06/2007 - 23:53

I have a question about the topic of enable thai support in babel. I follow your instruction until the line

c:\thailatex-0.4.0\babel\>latex thai.ins

I type in this command and the error occurs. It seemed not to recognize the command ‘latex’. However, I have already had my MikTex 2.5 installed. So can you help me solve it please? Thank you in advance.

by dae on Mon, 18/06/2007 - 00:57

please be sure that latex is in your path. I mean, you must be sure that you can run latex from your command prompt. Just try c:\>latex. This should produce something not the

'latex' is not recognized as an internal or external command,
operable program or batch file.

by Jaime H. Barrera on Fri, 06/07/2007 - 04:25

Sawatdee Khrap,

I was trying to get Thai characters into my document, so I followed your instructions. (BTW, thanks for the very well-detailed guide!) I have some questions. The last one of them is unrelated to this preamble: 1) Can you think of any way that the procedure outlined in your instructions could have messed up LyX’s menu fonts? After following it, LyX’s menu fonts shrank to an unreadable size. I don’t know how to get them back to normal. Any suggestions? I searched all over the Internet for some clues but I found no leads. If you could even provide some keywords to use in a search that would be helpful, but “lyx menu fonts” in Google produced nothing of use. 2) Can you show how to add some Thai characters to be displayed as part of an equation? You see, I use gawgaay in my mathematics notes and would like to reproduce this in digital print. So, on this second front, I could really use your help. Thanks,

by Gareth on Sat, 21/07/2007 - 21:00

To my surprise I seem to have managed to get the Thai latex working with Miktex 2.6. What I am having problems with is the word separator. I have tried to use the Swath2.0.1 package. I went as far as moving my input file into the swath folder and typing the command given while in that directory. All I got in the output file was a string of characters which appeared to be trying to tell me the syntax of the command, but I could not make any sense of it. There are 2 of us here now who have tried, both with the same result.

I have a query about some of the labeling in the new Thai latex. This new version gives the words ‘Figure’ and ‘Table’ in Thai. This is what you want if the majority of the document is in Thai. However if the bulk of the document is in English with a few words in Thai, we should have these words in English. Is there any way to select which language these3 words come up in, given that the document contains 2 languages?

by Garethy on Mon, 27/08/2007 - 16:17

Any suggestions anyone? Particularly those who wrote the MikTeX Thai plug-ins??

by Gareth on Mon, 27/08/2007 - 16:24

The solution to my query a month ago is the order of languages in the \usepackage command - english second gives the table and figure labels in english. In the book documentclass it gives the word chopter, contents, table of figures, table of contents in English. Just one problem the contents of these sections are not shown. Go back to the [english, thai] order and the contents are displayed, but the section headings are in Thai.
Any suggestions anyone? Particularly those who wrote the MikTeX Thai plug-ins??

by BradleyAlyssa32 on Thu, 15/08/2013 - 03:40

Look here in order to get a great possibility to order essay online and make a difference in your student’s career due to our professional term paper help.


Subscribe to Syndicate
© 2014 Nattee Niparnan. Drupal theme by Kiwi Themes.