Tuesday, July 1, 2014

Typesetting Thai

Make Texshop aware of Thai encoding

add the following two lines
before \begin{document}

%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode

From: http://poonlap.blogspot.com/2012/03/tex-mac-os-x.html

Thai hyphenation 

\usepackage{polyglossia}
\XeTeXlinebreaklocale "th_TH"
\XeTeXlinebreakskip = 0pt plus 1pt

Use different fonts for different languages

http://tex.stackexchange.com/questions/183424/xelatex-how-to-specify-a-different-font-family-for-latin-text-within-non-latin

The package ucharclasses does this. For short insertions of text in other alphabets hyphenation shouldn't be a concern; for longer parts, using the various features of polyglossia is recommended.
\documentclass{article}

\usepackage{polyglossia}
\usepackage{fontspec}
\setmainlanguage{thai}

\newfontfamily\thaifont{Thonburi}
\newfontfamily\englishfont{TeX Gyre Bonum} % just to get a distinctive font

\usepackage[Latin,Thai]{ucharclasses}

\setTransitionsForLatin
  {\begingroup\englishfont}
  {\endgroup}

\begin{document}

ดาวพุธมีหลุมอุกกาบาตจำนวนมากจนดูคล้ายดวงจันทร์ ภูมิลักษณ์ที่เด่นที่สุดบนดาวพุธ คือ
แอ่งแคลอริส (Caloris Basin) ดาวพุธมีหลุมอุกกาบาตจำนวนมากจนดูคล้ายดวงจันทร์
ภูมิลักษณ์ที่เด่นที่สุดบนดาวพุธ คือ แอ่งแคลอริส

\end{document}

enter image description here

No comments:

Post a Comment