forked from TouchySarun/penhwangDocument
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththaixelatex.sty
102 lines (91 loc) · 2.03 KB
/
thaixelatex.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
\ProvidesPackage{thaixelatex}
\DeclareOption{english}{\englishtrue}
% Package options:
%
% english: set English as primary language
%
\newif\ifenglish\englishfalse
\ProcessOptions
%% font setup
\RequirePackage{fontspec}
\defaultfontfeatures{Mapping=tex-text}
%% Thai language setup
\XeTeXlinebreaklocale 'th_TH'
\XeTeXlinebreakskip = 0pt plus 0.2pt minus 0.2pt
\newfontfamily\thaifont[
Script=Thai,
Scale=MatchLowercase,
Extension=.otf,
ItalicFont=*-Italic,
BoldFont=*-Bold,
BoldItalicFont=*-BoldItalic,
% FakeBold=1.5,
]{Laksaman}
\newfontfamily\thaifonttt[
% Script=Thai,
Scale=MatchLowercase,
FakeBold=2,
]{Arundina Sans Mono}
\ifenglish
\setmainfont{TeX Gyre Termes}
\setmonofont[
Mapping=,
Scale=MatchLowercase,
Extension=.otf,
UprightFont=*zi4-Regular,
BoldFont=*zi4-Bold,
AutoFakeSlant
]{Inconsolata}
\else
\newfontfamily\engfont{TeX Gyre Termes}
\newfontfamily\engfonttt[
Mapping=,
Scale=MatchLowercase,
Extension=.otf,
UprightFont=*zi4-Regular,
BoldFont=*zi4-Bold,
AutoFakeSlant
]{Inconsolata}
\fi
%% math setup
\RequirePackage{amsmath}
\RequirePackage{unicode-math}
\setmathfont{TeX Gyre Termes Math}
\setmathfontface\mathrm{TeX Gyre Termes}
\setmathfontface\mathbf{TeX Gyre Termes Bold}
\setmathfontface\mathit{TeX Gyre Termes Italic}
\RequirePackage{ifthen}
\ifenglish
\newenvironment{thailang}{%
% \hyphenrules{thai}%
\ifthenelse{\equal{\f@family}{\ttdefault}}{\thaifonttt}{\thaifont}%
}
{}
\else
\newenvironment{englang}{%
% \hyphenrules{english}%
\ifthenelse{\equal{\f@family}{ArundinaSansMono(0)}}{\engfonttt}{\engfont}%
}
{}
\fi
\RequirePackage[Latin,Thai]{ucharclasses}
\ifenglish
\setTransitionsFor{Thai}{\begin{thailang}}{\end{thailang}}
\else
\setTransitionsForLatin{\begin{englang}}{\end{englang}}
\fi
\RequirePackage{polyglossia}
\ifenglish
\setdefaultlanguage{english}
\setotherlanguage{thai}
\else
\setdefaultlanguage{thai}
\setotherlanguage{english}
\frenchspacing
\fi
%% spacing
\RequirePackage{setspace}
\ifenglish
\else
\setstretch{1.35}
\fi