summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/thaienum/thaienum.sty
blob: e6bf05887fb898e970a0d09ad58e0bce66b96ce9 (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
%% thaienum.sty
%% Copyright 2017 Abhabongse Janthong
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   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.
%
% This work has the LPPL maintenance status `maintained'.
% The Current Maintainer of this work is Abhabongse Janthong.
% This work consists of all files in the repository, including
% thaienum.sty and thaienum.tex.
%
% This package provides Thai enumeration labels to the 'enumitem' package.
% It was heavily inspired by the package 'moreenum'.
%
\ProvidesPackage{thaienum}[2017/04/30 v0.2]
\RequirePackage{alphalph}     % For doubling characters

%%------------------------------------------------------------------
%%  Expectes 'enumitem' and 'babel-thai' to be loaded.
%%------------------------------------------------------------------
\@ifpackageloaded{enumitem}{}{%
\RequirePackage{enumitem}%
\PackageWarning{thaienum}{Package 'enumitem' not loaded before 'thaienum' %
(please load 'enumitem' package before 'thaienum')}%
}
\@ifpackageloaded{babel}{}{%
\PackageError{thaienum}{Package 'babel' not loaded before 'thaienum' %
(please load 'babel' package before 'thaienum')}%
{Please load 'babel' package before 'thaienum'}%
}
\@ifpackagewith{babel}{thai}{}{%
\PackageWarning{thaienum}{Package 'babel' not loaded with option 'thai' %
(please load 'babel' package with option 'thai')}%
}

%%------------------------------------------------------------------
%%  Reuses the counter defined by 'babel-thai' package.
%%      How convenient is that!
%%  However, note that \thaialph and \thaiAlph will run
%%      out of counters once it reaches 41 and 44, respectively.
%%------------------------------------------------------------------
\AddEnumerateCounter{\thaialph}{\@thaialph}{\thaiNoNen}
\AddEnumerateCounter{\thaiAlph}{\@thaiAlph}{\thaiNoNen}
\AddEnumerateCounter{\thainum}{\@thainum}{\thainine}
\AddEnumerateCounter{\thaibracenum}{\@thaibracenum}{\thainine}

%%-----------------------------------------------------------------
%%  \thaimultialph and \thaimultiAlph are the multi-character
%%      version of \thaialph and \thaiAlph, respectively.
%%  Once the counter reaches \thaiHoNokhuk, it continues with
%%      \thaiKoKai\thaiKoKai, \thaiKoKai\thaiKhoKhai,
%%      \thaiKoKai\thaiKhoKhwai, etc.
%%-----------------------------------------------------------------
\newalphalph{\@thaimultialph}[alph]{\@thaialph}{41}
\newcommand*{\thaimultialph}[1]{%
\expandafter\@thaimultialph\csname c@#1\endcsname%
}
\AddEnumerateCounter{\thaimultialph}{\@thaimultialph}{\thaiNoNen}

\newalphalph{\@thaimultiAlph}[alph]{\@thaiAlph}{41}
\newcommand*{\thaimultiAlph}[1]{%
\expandafter\@thaimultiAlph\csname c@#1\endcsname%
}
\AddEnumerateCounter{\thaimultiAlph}{\@thaimultiAlph}{\thaiNoNen}

\endinput