Sign up ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

The following example displays the English text alright, but not the Thai text. It is simply left blank in the PDF result.


\setmainfont{Times New Roman}


Here comes some Thai: สารบัญ

{\sffamily Here comes some Thai: สารบัญ}

If I change the \setdefaultlanguage to thai, it works, but that's not the idea as this is an English document.

Any suggestions?

share|improve this question

2 Answers 2

up vote 4 down vote accepted

You are nowhere telling xelatex that you wish to switch to thai. Use either \setotherlanguage{thai} and \selectlanguage{thai}, or at least use the \thaifont command.

share|improve this answer
I thought the whole idea of Unicode input in XeLaTeX was that XeLaTeX "just works" with that. In any case, I've added the \setotherlanguage{thai} line but that has no effect. Your other suggestions require that I know in advance that the following text actually will be in Thai. In my case, that's not practical as I process unknown text automatically. –  kongo09 Aug 3 '11 at 14:11
Sorry, I misunderstood you. \setotherlanguage{thai} obviously only works together with \selectlanguage{thai}. Yes, that works. But unfortunately leaves me with the problem that I would have to know where in the text the Thai script is sitting. I guess the solution would be to find a rather complete unicode font that has the scripts like Thai covered and use that as main font. –  kongo09 Aug 3 '11 at 14:17
It is possible (with \XeTeXintercharclass/\XeTeXinterchartoks) to setup things so that XeTeX automatically switch to another font. –  Ulrike Fischer Aug 3 '11 at 14:27
That's interesting! This lead me to the ucharclasses package, which doesn't seem to be part of the large standard distributions. A simple \setTransitionTo{Thai}{\fontspec{Norasi}} does the trick. Unfortunately, the package seems to be very computationally intensive as it makes the whole process quite slow. –  kongo09 Aug 3 '11 at 15:18

Thanks for this! It helped me a lot, but it still required some experiments to get it working. Hence, I would like to contribute a functional example here:

File letter-preamble-th.tex

%%% IMPORTANT --- must be compiled with XeLaTeX!!! %%%



\setmainfont{Times New Roman}



\usepackage[breaklinks=true, linkcolor=darkblue, menucolor=darkblue, urlcolor=darkblue]{hyperref}


% Zum Testen


      \vspace*{0.46cm} % offset for align the top border with the head of the wizard

    \texttt{1CB2 35C8 F3B0 236A C46D}\\ 
    \texttt{38FB 289F 1C57 2BA1 020C}\\

% Header for all other pages

    Example footer | {\selectlanguage{thai}ติดต่อ ประชาสัมพันธ์มหาวิทยาลัยเชียงใหม่} \\
    And some more Thai: {\selectlanguage{thai}มหาวิทยาลัยเชียงใหม่} |  More nonsense: TH 245\,111\,222\\
    Some people or companies put their bank coordinates here in the footer -- hence this example\\

% Sender
\setkomavar{fromaddress}{{\selectlanguage{thai}239 ถนนห้วยแก้ว}\\{\selectlanguage{thai}ต.สุเทพ อ.เมือง}\\{\selectlanguage{thai}จ.เชียงใหม่ 50200}\\Thailand}

% \setkomavar{fromlogo}{\adjustbox{valign=t}{
%   \hspace{-1.1cm} % Offset for align the center of the wizard with the text
%   \includegraphics[height=2.5cm]{img/logo.png}}}
\setkomavar{fromname}{Marco {\selectlanguage{thai}หงุ่ยตระกูล}}

File example-letter-th.tex

%%% IMPORTANT --- must be compiled with XeLaTeX!!! %%%


\setkomavar{date}{ 2015-04-27 }

\setkomavar{subject}{Example letter English/{\selectlanguage{thai}ไทย} (Thai)}

\newcommand{\openingText}{Dear Ladies, dear Sirs,}

\newcommand{\closingText}{Yours sincerely,}
\setkomavar{signature}{Marco {\selectlanguage{thai}หงุ่ยตระกูล}-Schulze}

  \begin{letter}{#2 #1\\#3}

this is an example letter using English and Thai -- mixed {\selectlanguage{thai}พสกนิกรสุดปลื้มปีติ} like this.

Unfortunately, it is necessary to switch explicitly to Thai using:
``\{\textbackslash{}selectlanguage\{thai\}XXX\}'' where ``XXX''
are Thai letters. I read some hints that XeLaTeX is able to switch the language (and thus the font!) automatically,
but I didn't want to invest more time into this topic -- and this solution works fine (at least for now).




% Multiple entries can be used to easily create a serial letter
% Only last name, first name and address are currently used
\adrentry{{\selectlanguage{thai}รอยัล  ออร์คิด พลัส\\บริษัท การบินไทย จำกัด (มหาชน)}}{}{{\selectlanguage{thai}ตู้ปณ. 567 ไปรษณีย์ สามเสนใน\\กรุงเทพฯ 10400}}{Telefon}{F1}{F2}{Kommentar}{ADDR}

Just in case, the above code was not pasted correctly, I uploaded it for you -- both the sources and the generated PDF:

I hope this is helpful!

share|improve this answer
Is that a question, or an answer? Why is there so much code? The example is muddled. –  Johannes_B May 6 at 8:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.