summaryrefslogtreecommitdiff
path: root/language/thai/thaispec/thaispec.dtx
blob: 499dbdb2dd7de24e096b78bdcc29de1b8e26cffa (plain)
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
%\iffalse
% thaispec.dtx generated using makedtx version 1.2 (c) Nicola Talbot
% Command line args:
%   -doc "thaispec.tex"
%   -author "Ratthaprom_Promkam"
%   -src "thaispec\.sty=>thaispec.sty"
%   thaispec
% Created on 2021/3/2 0:13
%\fi
%\iffalse
%<*package>
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%</package>
%\fi
% \iffalse
% Doc-Source file to use with LaTeX2e
% Copyright (C) 2021 Ratthaprom_Promkam, all rights reserved.
% \fi
% \iffalse
%<*driver>
\documentclass{article}

\usepackage[thaispacing=false,thaicaption=false]{thaispec}
\usepackage{metalogo}
\usepackage{hyperref}
\hypersetup{
    colorlinks=true,
    linkcolor=black,
    filecolor=magenta,
    urlcolor=blue,
}
%\usepackage{listings}
\usepackage{color}
\usepackage{longtable}
\usepackage{minted}


\newcommand{\pkgname}{\texttt{thaispec}}
\newcommand{\showdefault}[1]{\par\vspace{0mm}\noindent{Default:}\par\noindent\texttt{#1}}
\newcommand{\showex}[1]{\par\vspace{0mm}\noindent{Example:}\par\noindent\texttt{#1}}
\newcommand{\printcenter}[1]{\par\begin{center}#1\end{center}\par\noindent}
\newcommand{\myoption}[4]{{\texttt{#1}}&{#2}{\showdefault{#3}}{\showex{#4}}\\}
\newcommand{\showoption}[2]{{\noindent\texttt{#1}}&{#2}\\\hline}


\newcommand{\mopt}{%
frame=single,
linenos=true,
autogobble=true,
}

%\lstdefinestyle{tex}{%
%language=[LaTeX]{TeX},
%basicstyle=\ttfamily\small\color{red},
%keywordstyle=\bfseries\color{black},
%frame=single,
%backgroundcolor=\color{white},
%extendedchars=true,
%inputencoding=utf8,
%breaklines=true,
%postbreak=\mbox{\textcolor{red}{$\hookrightarrow$}\space},
%showstringspaces=true,
%}

%\lstset{style=tex}

\newminted{latex}{frame=single}

\title{The \pkgname\ package: \\Thai language typesetting in \XeLaTeX}
\author{Ratthaprom Promkam\\{\texttt{\small ratthaprom@me.com}}}
\date{Version 2021.03.01}

\begin{document}
\DocInput{thaispec.dtx}
\end{document}
%</driver>
%\fi
%\maketitle
%
%This package allows you to input Thai characters directly to \LaTeX\ documents
%and choose any (system wide) Thai fonts for typesetting via \XeLaTeX.
%It also tries to appropriately justify paragraphs with no more external tools.
%
%\tableofcontents
%
%
%\section{Prerequisite}
%The package requires \texttt{TH Sarabun New} \footnote{Thai national fonts, a.k.a. \texttt{SIPAFonts}.
%See \url{https://github.com/epsilonxe/sipafonts}}, included in the collection of Thai national fonts, by default to typeset Thai characters.
%The following \LaTeX\ package are essentially required for the default option: \texttt{fontspec}, \texttt{uchar­classes}, \texttt{poly­glos­sia}, \texttt{setspace}, \texttt{kvop­tions}, and \texttt{xpatch}.
%
%\section{Installation}
%Although the \texttt{thaispec} packages are included in all major \LaTeX\ distributions, you may need to manually install or upgrade to the latest version.
% 
%In a case that it is neither installed nor outdated, please visit \url{https://github.com/epsilonxe/latex} to download the latest version of \texttt{thaispec.sty} and put it in your working directory.
%
%More conveniently, but require familiar to command line interface, 
%please run the following commands to install or update to the most recent version of \texttt{thaipsec} via TexLive Manager. 
%However, you may need administrator right to launch these commands.
%So consider to add \texttt{sudo} before each of the following commands.
%
%\begin{minted}{bash}
%$tlmgr install thaispec 
%$tlmgr update thaispec    
%\end{minted}
%
%\section{Recommendation}
%Install the collection of Thai national fonts said above.
%Python and \texttt{pygments} are also recommended to be installed if syntax highlight needed in the document.
%
%\section{Package loading}
%In the preamble, add the command
%\begin{minted}[frame=single]{latex}
%\usepackage{thaispec}
%\end{minted}
%then you can input Thai characters in the document and typeset the document as usual.
%This will typeset the document by choosing \texttt{TH Sarabun New} for all Thai characters.
%The package also predefines \texttt{\textbackslash today} and \texttt{\textbackslash Today}
%for today Thai date printing in short and long formats respectively.
%The Latin character will be typeseted as usual.
%% By default the package set \texttt{thaifont} to \texttt{TH Sarabun New},
%% while set \texttt{mainfont}, \texttt{sansfont} and \texttt{monofont} to \TeX\ Gyre fonts.
%
%% In case \TeX\ Gyre font family is not system wide installed, the package should be loaded
%% with the following option:
%% \begin{minted}[frame=single]{LaTeX}
%% \usepackage[texgyrefont = false]{thaispec}
%% \end{minted}
%
%
%\section{Loading options}
%This section lists additional loading options by their features.
%Multiple options can be loaded with the following command.
%\begin{minted}[frame=single]{LaTeX}
%\usepackage[option_1, option_2, ...]{thaispec}
%\end{minted}
%The below table lists available options in the latest version.
%
%\renewcommand{\arraystretch}{1.8}
%\begin{longtable}{l p{9cm}}
%\caption{Loading options in \texttt{thaispec} package.} \label{table:loading_options}\\
%\hline
%\textbf{Options}  & \textbf{Features}
%\\ \hline
%\endfirsthead
%\caption{(continued) Loading options in \texttt{thaispec} package.}\\
%\hline
%\textbf{Options}  & \textbf{Features}
%\\ \hline
%\endhead
%
%\hline
%\endfoot
%
%
%\showoption{thainum}{
%Uses Thai numbers for almost all number digits which is disable by default. 
%Use \mint{LaTeX}|\usepackage[thainum]{thaipsec}|
%to activate this option.
%}
%\showoption{math}{
%Additionally load the following packages:
%\texttt{mathtools}, \texttt{amssymb}, \texttt{amsthm}, \texttt{mathspec} orderly.
%Moreover it sets various theorem environments like definition, theorem, corollary to Thai.
%If your document consists of math objects, this option is then recommended. 
%Use \mint{LaTeX}|\usepackage[math]{thaispec}| 
%to activate this option.
%}
%\showoption{thaifont}{
%Choose the selected Thai font for Thai charaters typeseting.
%For example, use
%\mint{LaTeX}|\usepackage[thaifont = Angsana New]{thaispec}| 
%to choose font named \texttt{Angsana New}.
%Note that the selected font must be installed to the system before loading the package.
%}
%\showoption{sloppy}{
%This option is for fairly better Thai justified paragraphs which is enable by default.
%In case this option gives a bad justified output, try 
%\mint{LaTeX}|\usepackage[sloopy=false]{thaispec}| to disable this option.
%}
%\showoption{thaispacing}{
%Mostly single spacing is too tight for Thai paragraph.
%By defalut this package is loaded with one and a half spacing.
%In case this option gives a bad justified output, try 
%\mint{LaTeX}|\usepackage[thaispacing=false]{thaispec}| to disable this option, i.e., 
%This sets single spacing for all paragraphs.
%}
%\showoption{thaicaption}{
%The package sets various captions in Thai.
%This includes captions of chapter, section and table of contents.
%It is activated by default. 
%If you do not want this, use 
%\mint{LaTeX}|\usepackage[thaicaption=false]{thaispec}| to disable this option.
%}
%
%  % \texttt{thainum}
%  % & Uses Thai numbers for almost all number digits.
%  % It is untoggled by defalut.
%  % \\
%  % \texttt{math}
%  % & Additionally load the following packages:
%  % \texttt{mathtools}, \texttt{amssymb}, \texttt{amsthm}, \texttt{mathspec} orderly.
%
%  % Normally \pkgname\ package loads \texttt{fontspec}\ with \texttt{no-math}\ option.
%  % If your document consists of math objects, this option is then recommended.
%  % \\
%  % \texttt{thaifont = <SYSTEM\_FONT\_NAME>}
%  % & Choose a system font for Thai characters.
%  % \showex{thaifont = TH Sarabun New}
%  % \\
%  % \texttt{mainfont = <SYSTEM\_FONT\_NAME>}
%  % & Choose a font for \texttt{mainfont} corresponding to \texttt{fontspec} package.
%  % \showex{thaifont = TeX Gyre Termes}
%  % \\
%  % \texttt{sansfont = <SYSTEM\_FONT\_NAME>}
%  % & Choose a font for \texttt{sansfont} corresponding to \texttt{fontspec} package.
%  % \showex{thaifont = TeX Gyre Heros}
%  % \\
%  % \texttt{monofont = <SYSTEM\_FONT\_NAME>}
%  % & Choose a font for \texttt{monofont} corresponding to \texttt{fontspec} package.
%  % \showex{thaifont = TeX Gyre Cursors}
%  % \\
%  % \texttt{thaithm = <BOOL>}
%  % & After loading \texttt{amsthm} package, \texttt{thaispec} package automatically defines
%  % a set of theorem-like environments with Thai heading by default.
%  % The automatic defined environments includes
%  % \texttt{theorem}, \texttt{lemma}, \texttt{corollary},
%  % \texttt{definition}, \texttt{axiom}, \texttt{undefinedterm},
%  % \texttt{example}, \texttt{remark} and \texttt{note}.
%  % If you prefer to set them yourself, just set its value to \texttt{false}.
%  % \showex{thaithm = true}
%  % \\
%  % \texttt{thmcount = <VALUE>}
%  % & If the option \texttt{thaithm = true} is prefered,
%  % this package set the counter independently for each automatic defined environments.
%  % The value of \texttt{<VALUE>} can be one of the following:
%  % \texttt{default}, \texttt{no}, \texttt{full}, \texttt{section},
%  % \texttt{chapter}, \texttt{kind}, \texttt{kind-section}, and \texttt{kind-chapter}.
%  % \showex{thmcount = default}
%  % \\
%\end{longtable}
%
%\section{Usage Examples}
%The following example is a basic example of using \texttt{thaispec} package.
%It is loaded with the default setting for typesetting in \XeLaTeX, i.e.,
%only Thai characters are typesetted with \texttt{TH Sarabun New} font,
%other charaters are typesetted as usual,
%and paragraphs are justified by \texttt{\textbackslash sloppy} macro.
%%\begin{lstlisting}[style=tex,numbers=left]
%%\documentclass{article}
%%\usepackage{thaispec}
%%\begin{document}
%%\section{Thai ภาษาไทย}
%%Thai charaters can be input directly like this ทดสอบการพิมพ์ภาษาไทยในเอกสาร \XeLaTeX\
%%
%%\end{lstlisting}
%\begin{minted}[
%frame=single,
%linenos=true,
%autogobble=true,
%highlightlines={2}
%]{LaTeX}
%\documentclass{article}
%\usepackage{thaispec}
%\begin{document}
%\section{ภาษาไทย}
%ทดสอบการพิมพ์ภาษาไทยในเอกสาร \XeLaTeX
%
%\end{minted}
%In order to use another Thai font face for any charaters in a math document without
%\texttt{\textbackslash sloppy} macro,
%the following example can be used to achieve the goal.
%%\begin{lstlisting}[style=tex,numbers=left]
%%\documentclass{article}
%%\usepackage[math,
%%thaifont = Tahoma,
%%texgyrefont = false,
%%sloppy = false]{thaispec}
%%\begin{document}
%%\section{Math ภาษาไทย}
%%Thai charaters can be input directly like this ทดสอบการพิมพ์ภาษาไทยในเอกสาร $ax^2+bx+c=0$
%%
%%\end{lstlisting}
%\begin{minted}[%
%frame=single,
%linenos=true,
%autogobble=true,
%highlightlines={2-5}
%]{LaTeX}
%\documentclass{article}
%\usepackage[math, thaifont = Tahoma, sloppy = false]{thaispec}
%\begin{document}
%\section{Math ภาษาไทย}
%การพิมพ์ภาษาไทยในเอกสาร $ax^2+bx+c=0$
%
%\end{minted}
%
%
%\section{Known Issues}
%\subsection{Incorrect Thai characters with \texttt{listing} package}
%If you typeset some codes consisting of Thai characters in \texttt{lstlisting} environment provided by \texttt{listing} package, this will possibly cause you a problem with incorrect Thai characters.
%The recommendation is choosing \texttt{minted} package instead of \texttt{listing} package.
%However you need to additionally install \texttt{pygments} python module in order to use \texttt{minted} package.
%If you do not install \texttt{pygments}, try using
%\begin{minted}[frame=single]{shell}
%$ pip install pygments
%\end{minted}
%Moreover, you need to enable shell-escape when typeset the document.
%For example, use
%\begin{minted}[frame=single]{shell}
%$ xelatex -shell-escape your-tex-file.tex
%\end{minted}
%to typeset your tex file.
%
%\subsection{TexPad in macOS}
%As said above, the shell-escape must be enabled.
%Additionally, the \emph{Hide Intermediate Files} option must be disable and copy the pygment launcher to \texttt{/usr/local/bin}.
%The launcher can be located with the command
%\begin{minted}[frame=single]{shell}
%$ which pygments
%\end{minted}
%Instead of copying the launcher directly, one may put its symbolic link to \texttt{/usr/local/bin}.
%If there is an error due to \texttt{minted} package, we recommend to delete the minted output directory prior typesetting.
%
%\section{Credits}
%This package is motivated by a set of \LaTeX\ commands for typesetting Thai documents
%provided by Dittaya Wanvarie
%\footnote{See {\url{http://pioneer.netserv.chula.ac.th/~wdittaya/}} in \LaTeX\ section.} from Chulalongkorn University.
%
%\section{License}
%This work may be distributed and/or modified under the
%conditions of the LaTeX Project Public License, either version 1.3
%of this license of (at your option) any later version.
%The latest version of this license is in
%\printcenter{\url{http://www.latex-project.org/lppl.txt}}
%and version 1.3 or later is part of all distributions of LaTeX
%version 2005/12/01 or later.
%
%
%
%
%
%\StopEventually{}
%\section{The Code}
%\iffalse
%    \begin{macrocode}
%<*thaispec.sty>
%    \end{macrocode}
%\fi
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{thaispec}[version 2021.03.01]

\RequirePackage{kvoptions}
\RequirePackage[no-math]{fontspec}
\RequirePackage[Latin, Thai]{ucharclasses}
\RequirePackage{setspace}
\RequirePackage{polyglossia}
% \RequirePackage[calc]{datetime2}
\RequirePackage{xstring}
% \RequirePackage{afterpackage}
\RequirePackage{xpatch}

% Key-Value Options
\SetupKeyvalOptions{
family=THL,
prefix=THL@
}

\DeclareStringOption[TH Sarabun New]{thaifont}[TH Sarabun New]

\DeclareVoidOption{math}{%
\RequirePackage{mathtools}
\RequirePackage{amssymb}
\RequirePackage{amsthm}
\RequirePackage{mathspec}
}

\DeclareVoidOption{thainum}{\renewcommand{\thesection}{\thainum{section}}}

\DeclareBoolOption[true]{sloppy}
\DeclareBoolOption[true]{thaispacing}
\DeclareBoolOption[true]{thaicaption}
\DeclareBoolOption[false]{beamerthmcount}

\DeclareStringOption[default]{thmcount}[default]

\ProcessKeyvalOptions{THL}


% TeX Commands

\newcommand{\thaispecver}{2021.03.01}


% Set Thai language
\XeTeXlinebreaklocale "th"
\XeTeXlinebreakskip = 0pt plus 0pt

\ifTHL@sloppy
\sloppy
\fi

\defaultfontfeatures{Mapping=tex-text}


% Select Thai fonts
% \setmainfont[Scale=1.23]{\THL@thaifont}

% Control English/Thai Fonts
\newfontfamily{\thaifont}[Scale=MatchUppercase,Mapping=tex-text]{\THL@thaifont}

\newenvironment{thailang}
{\thaifont}
{}

\setTransitionTo{Thai}{\begin{thailang}}
\setTransitionFrom{Thai}{\end{thailang}}

\setdefaultlanguage{english}
\setotherlanguage{thai}

\ifTHL@thaicaption
\AtBeginDocument\captionsthai
\addto\captionsenglish{%
  \renewcommand{\proofname}{พิสูจน์}%
  \renewcommand{\chaptername}{บทที่}%
  \renewcommand{\contentsname}{สารบัญ}%
  \renewcommand{\listfigurename}{สารบัญรูปภาพ}%
  \renewcommand{\listtablename}{สารบัญตาราง}%
  \renewcommand{\figurename}{รูปภาพ}%
  \renewcommand{\tablename}{ตาราง}%
  \renewcommand{\refname}{เอกสารอ้างอิง}%
}
\fi


% Define Thai alpha/number/digit for enumerated items
\def\thaialph#1{\expandafter\thalph\csname c@#1\endcsname}
\def\thalph#1{%
    \ifcase#1\or ก\or ข\or ค\or ง\or จ\or ฉ\or ช\or ซ\or
    ฌ\or ญ\or ฎ\or ฏ\or ฐ\or ฑ\or ฒ\or ณ\or ด\or ต\or ถ\or ท\or ธ\or น\or
    บ\or ป\or ผ\or ฝ\or พ\or ฟ\or ภ\or ม\or ย\or ร\or ฤ\or ล\or ฦ\or ว\or
    ศ\or ษ\or ส\or ห\or ฬ\or อ\else ฮ\else\xpg@ill@value{#1}{thalph}\fi}
\def\thainum#1{\expandafter\thainumber\csname c@#1\endcsname}
\def\thainumber#1{%
    \thaidigits{\number#1}%
}
\def\thaidigits#1{\expandafter\thdigits #1@ }
\def\thdigits#1{%
    \ifx @#1% then terminate
    \else
    \ifx0#1๐\else\ifx1#1๑\else\ifx2#1๒\else\ifx3#1๓\else\ifx4#1๔\else\ifx5#1๕\else\ifx6#1๖\else\ifx7#1๗\else\ifx8#1๘\else\ifx9#1๙\else#1\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
    \expandafter\thdigits
    \fi
}

% Define Thai datetime
% \today - Print today in short format d-M-Y(BD)
% \Today - Print today in long format dow-d-M-Y(BD)

% \DTMsavenow{now}
% \newcommand{\dtdow}{\IfStrEqCase{\DTMfetchdow{now}}{{0}{วันจันทร์}
% {1}{วันอังคาร}
% {2}{วันพุธ}
% {3}{วันพฤหัสบดี}
% {4}{วันศุกร์}
% {5}{วันเสาร์}
% {6}{วันอาทิตย์}
% }}

% \newcommand{\dtmonth}{\IfStrEqCase{\DTMfetchmonth{now}}{{1}{มกราคม}
% {2}{กุมภาพันธ์}
% {3}{มีนาคม}
% {4}{เมษายน}
% {5}{พฤษภาคม}
% {6}{มิถุนายน}
% {7}{กรกฎาคม}
% {8}{สิงหาคม}
% {9}{กันยายน}
% {10}{ตุลาคม}
% {11}{พฤศจิกายน}
% {12}{ธันวาคม}
% }}

% \newcounter{yearbd}
% \setcounter{yearbd}{\DTMfetchyear{now}}
% \addtocounter{yearbd}{543}
% %\newcommand{\dtyearbd}{\FPadd{\tmpdtyearbd}{\DTMfetchyear{now}}{543}\FPclip{\rtmpdtyearbd}{\tmpdtyearbd}พ.ศ.\;\rtmpdtyearbd}
% \AtBeginDocument{
% \def\Today{\dtdow\ \DTMfetchday{now}\ \dtmonth\ พ.ศ. \theyearbd}
% \def\today{\DTMfetchday{now}\ \dtmonth\ พ.ศ. \theyearbd}
% }


% In beamer
\@ifclassloaded{beamer}
{
\let\theorem\relax
\let\c@theorem\relax
\let\lemma\relax
\let\corollary\relax
\let\definition\relax
\let\example\relax
\let\note\relax

\ifTHL@beamerthmcount
    \setbeamertemplate{theorems}[numbered]
\fi

}
{%
\ifTHL@thaispacing
\onehalfspacing
\fi
}

% In article class
\@ifclassloaded{article}
{
\renewcommand{\THL@thmcount}{section}
}
{}

% In book
\@ifclassloaded{book}
{
\renewcommand{\THL@thmcount}{chapter}
}
{}

% In report
\@ifclassloaded{report}
{
\renewcommand{\THL@thmcount}{chapter}
}
{}


% Thai theorem environments
\@ifpackageloaded{amsthm}
{%
\IfStrEqCase{\THL@thmcount}{%
{default}{%
\newtheorem{theorem}{ทฤษฎีบท}
\newtheorem{lemma}[theorem]{บทตั้ง}
\newtheorem{corollary}[theorem]{บทแทรก}
\newtheorem{proposition}[theorem]{ทฤษฎีบทประกอบ}
\theoremstyle{definition}
\newtheorem{definition}[theorem]{บทนิยาม}
\newtheorem{axiom}[theorem]{สัจพจน์}
\newtheorem{example}[theorem]{ตัวอย่าง}
\theoremstyle{remark}
\newtheorem*{remark}{หมายเหตุ}
\newtheorem*{note}{บันทึก}
}%
{no}{%
\newtheorem*{theorem}{ทฤษฎีบท}
\newtheorem*{lemma}{บทตั้ง}
\newtheorem*{corollary}{บทแทรก}
\newtheorem*{proposition}{ทฤษฎีบทประกอบ}
\theoremstyle{definition}
\newtheorem*{definition}{บทนิยาม}
\newtheorem*{axiom}{สัจพจน์}
\newtheorem*{example}{ตัวอย่าง}
\theoremstyle{remark}
\newtheorem*{remark}{หมายเหตุ}
\newtheorem*{note}{บันทึก}
}%
{full}{%
\newtheorem{theorem}{ทฤษฎีบท}
\newtheorem{lemma}[theorem]{บทตั้ง}
\newtheorem{corollary}[theorem]{บทแทรก}
\newtheorem{proposition}[theorem]{ทฤษฎีบทประกอบ}
\theoremstyle{definition}
\newtheorem{definition}[theorem]{บทนิยาม}
\newtheorem{axiom}[theorem]{สัจพจน์}
\newtheorem{example}[theorem]{ตัวอย่าง}
\theoremstyle{remark}
\newtheorem{remark}{หมายเหตุ}
\newtheorem{note}{บันทึก}
}%
{section}{%
\newtheorem{theorem}{ทฤษฎีบท}[section]
\newtheorem{lemma}[theorem]{บทตั้ง}
\newtheorem{corollary}[theorem]{บทแทรก}
\newtheorem{proposition}[theorem]{ทฤษฎีบทประกอบ}
\theoremstyle{definition}
\newtheorem{definition}[theorem]{บทนิยาม}
\newtheorem{axiom}[theorem]{สัจพจน์}
\newtheorem{example}[theorem]{ตัวอย่าง}
\theoremstyle{remark}
\newtheorem*{remark}{หมายเหตุ}
\newtheorem*{note}{บันทึก}
}%
{chapter}{%
\newtheorem{theorem}{ทฤษฎีบท}[chapter]
\newtheorem{lemma}[theorem]{บทตั้ง}
\newtheorem{corollary}[theorem]{บทแทรก}
\newtheorem{proposition}[theorem]{ทฤษฎีบทประกอบ}
\theoremstyle{definition}
\newtheorem{definition}[theorem]{บทนิยาม}
\newtheorem{axiom}[theorem]{สัจพจน์}
\newtheorem{example}[theorem]{ตัวอย่าง}
\theoremstyle{remark}
\newtheorem*{remark}{หมายเหตุ}
\newtheorem*{note}{บันทึก}
}%
{kind}{%
\newtheorem{theorem}{ทฤษฎีบท}
\newtheorem{lemma}[theorem]{บทตั้ง}
\newtheorem{corollary}[theorem]{บทแทรก}
\newtheorem{proposition}[theorem]{ทฤษฎีบทประกอบ}
\theoremstyle{definition}
\newtheorem{definition}{บทนิยาม}
\newtheorem{axiom}[definition]{สัจพจน์}
\newtheorem{example}{ตัวอย่าง}
\theoremstyle{remark}
\newtheorem{remark}{หมายเหตุ}
\newtheorem{note}{บันทึก}
}%
{kind-section}{%
\newtheorem{theorem}{ทฤษฎีบท}[section]
\newtheorem{lemma}[theorem]{บทตั้ง}
\newtheorem{corollary}[theorem]{บทแทรก}
\newtheorem{proposition}[theorem]{ทฤษฎีบทประกอบ}
\theoremstyle{definition}
\newtheorem{definition}{บทนิยาม}[section]
\newtheorem{axiom}[definition]{สัจพจน์}
\newtheorem{example}{ตัวอย่าง}
\theoremstyle{remark}
\newtheorem{remark}{หมายเหตุ}[section]
\newtheorem{note}{บันทึก}[section]
}%
{kind-chapter}{%
\newtheorem{theorem}{ทฤษฎีบท}[chapter]
\newtheorem{lemma}[theorem]{บทตั้ง}
\newtheorem{corollary}[theorem]{บทแทรก}
\newtheorem{proposition}[theorem]{ทฤษฎีบทประกอบ}
\theoremstyle{definition}
\newtheorem{definition}{บทนิยาม}[chapter]
\newtheorem{axiom}[definition]{สัจพจน์}
\newtheorem{example}{ตัวอย่าง}
\theoremstyle{remark}
\newtheorem{remark}{หมายเหตุ}[chapter]
\newtheorem{note}{บันทึก}[chapter]
}%
}%
\xpatchcmd{\@thm}{\thm@headpunct{.}}{\thm@headpunct{}}{}{}
}
{}


% \endinput
% END OF PACKAGE ----------------------------%\iffalse
%    \begin{macrocode}
%</thaispec.sty>
%    \end{macrocode}
%\fi
%\Finale
\endinput