%\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
