summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/moreenum/moreenum.sty
blob: 00b93777c4dd386c9405740c6611800c04024c6c (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
  %% moreenum.sty
  %% Copyright 2011 Seamus Bradley
  %
  % 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 Seamus Bradley
  % tex@seamusbradley.net
  %
  % This work consists of the files moreenum.sty,testcase-moreenum.tex
  % and README and the derived file testcase-moreenum.pdf


\ProvidesPackage{moreenum}[2011/07/15 v1.01]


\RequirePackage{amsmath} % For Greek letters
\RequirePackage{alphalph} % For doubling Greek letters
\RequirePackage{enumitem} % The enumeration workhorse
\RequirePackage{fmtcount} % The number translation workhorse


% Previous versions relied on the following packages that have been superceded
% in the latest version.
% \input{binhex} % Replaced by fmtcount
% \RequirePackage{engord} % Replaced by fmtcount
% \@ifclassloaded{memoir}{}{\RequirePackage{numname}} % For named
% numbers if memoir isn't loaded. Replaced by fmtcount


%------------------------------
%     Lowercase Greek
%------------------------------

% Thanks to T.D.'s answer on tex.sx for the basic insight
% into how to achieve this.
% http://tex.stackexchange.com/questions/4058/greek-numbering/4063#4063
% And to Will Robertson's answer to the same question for pointing me to
% the alphalph package

\newcommand*{\single@greek}[1]{%
  \expandafter\@single@greek\csname c@#1\endcsname
}
\newcommand*{\@single@greek}[1]{%
  $\ifcase#1\or\alpha\or\beta\or\gamma\or\delta\or\varepsilon
    \or\zeta\or\eta\or\theta\or\iota\or\kappa\or\lambda
    \or\mu\or\nu\or\xi\or o\or\pi\or\varrho\or\sigma
    \or\tau\or\upsilon\or\phi\or\chi\or\psi\or\omega
    \else\@ctrerr\fi$
}

\newalphalph{\@greek}[alph]{\@single@greek}{24}
\newcommand*{\greek}[1]{%
  \expandafter\@greek\csname c@#1\endcsname
}

\AddEnumerateCounter{\greek}{\@greek}{$\omega$}

%------------------------------
%    Uppercase Greek
%------------------------------

\newcommand*{\Single@Greek}[1]{%
  \expandafter\@Single@Greek\csname c@#1\endcsname
}
\newcommand*{\@Single@Greek}[1]{%
  $\ifcase#1\or A \or B\or\Gamma\or\Delta\or E
  \or Z\or E\or\Theta\or I\or K\or\Lambda
  \or M\or N\or \Xi\or O\or\Pi\or P\or\Sigma
  \or T\or Y\or\Phi\or X\or\Psi\or\Omega
  \else\@ctrerr\fi$
}

\newalphalph{\@Greek}[alph]{\@Single@Greek}{24}
\newcommand*{\Greek}[1]{%
  \expandafter\@Greek\csname c@#1\endcsname
}

\AddEnumerateCounter{\Greek}{\@Greek}{$W$}


%------------------------------
%   Uppercase Hexadecimal
%------------------------------

% Thanks to egreg at tex.sx for telling me about binary.tex
% http://tex.stackexchange.com/questions/22234/why-does-enumitem-need-the-macro-to-exist-already/22236#22236
% Although binary.tex has now been replaced by fmtcount

\newcommand*{\enumHex}[1]{%
  \expandafter\@enumHex\csname c@#1\endcsname}
\newcommand*{\@enumHex}[1]{%
  \protect\Hexadecimalnum{\number#1}}
\AddEnumerateCounter{\enumHex}{\@enumHex}{AAAA}

\newenvironment{enumHexzero}{%
  \begin{enumerate}[label=\enumHex*,start=0]%
  }{%
  \end{enumerate}%
}


%------------------------------
%   Lowercase Hexadecimal
%------------------------------

\newcommand*{\enumhex}[1]{%
  \expandafter\@enumhex\csname c@#1\endcsname}
\newcommand*{\@enumhex}[1]{%
  \protect\hexadecimalnum{\number#1}}
\AddEnumerateCounter{\enumhex}{\@enumhex}{aaaa}

\newenvironment{enumhexzero}{%
  \begin{enumerate}[label=\enumhex*,start=0]%
  }{%
  \end{enumerate}%
}

%------------------------------
%         Binary
%------------------------------

\newcommand*{\enumbinary}[1]{%
  \expandafter\@enumbinary\csname c@#1\endcsname}
\newcommand*{\@enumbinary}[1]{%
  \protect\binarynum{\number#1}}
\AddEnumerateCounter{\enumbinary}{\@enumbinary}{0000}

\newenvironment{enumbinzero}{%
  \begin{enumerate}[label=\enumbinary*,start=0]%
  }{%
  \end{enumerate}%
}

%------------------------------
%         Binary
%------------------------------

\newcommand*{\enumoctal}[1]{%
  \expandafter\@enumoctal\csname c@#1\endcsname}
\newcommand*{\@enumoctal}[1]{%
  \protect\octalnum{\number#1}}
\AddEnumerateCounter{\enumoctal}{\@enumoctal}{0000}

\newenvironment{enumoctzero}{%
  \begin{enumerate}[label=\enumoctal*,start=0]%
  }{%
  \end{enumerate}%
}



%------------------------------
%      "nth" (raised)
%------------------------------

\newcommand*{\raisenth}[1]{%
  \expandafter\@raisenth\csname c@#1\endcsname}
\newcommand*{\@raisenth}[1]{%
  \protect\fmtcountsetoptions{fmtord=raise}%
  \protect\ordinalnum{\number#1}}
\AddEnumerateCounter{\raisenth}{\@raisenth}{~2nd}


%------------------------------
%      "nth" (level)
%------------------------------

\newcommand*{\levelnth}[1]{%
  \expandafter\@levelnth\csname c@#1\endcsname}
\newcommand*{\@levelnth}[1]{%
  \protect\fmtcountsetoptions{fmtord=level}%
  \protect\ordinalnum{\number#1}}
\AddEnumerateCounter{\levelnth}{\@levelnth}{~2nd}

%------------------------------
%      "nth" words
%------------------------------

% Thanks to egreg for fixing numname and making the numname commands
% work with labels properly.
% http://tex.stackexchange.com/q/23043/215
% This also gave me the clue I needed to get levelnth and raisenth working as
% separate labels.

  %%-----------------------------
  %% Capitalised
  %%-----------------------------

\newcommand{\Nthwords}[1]{\expandafter\@Nthwords\csname c@#1\endcsname}
\newcommand*{\@Nthwords}[1]{%
  \protect\Numberstringnum{\number#1}}
\AddEnumerateCounter{\Nthwords}{\@Nthwords}{Seventeenth}

  %%-----------------------------
  %% UPPERCASE
  %%-----------------------------

\newcommand*{\NTHWORDS}[1]{
  \expandafter\@NTHWORDS\csname c@#1\endcsname}
\newcommand*{\@NTHWORDS}[1]{
  \protect\NUMBERstringnum{\number#1}}
\AddEnumerateCounter{\NTHWORDS}{\@NTHWORDS}{FORTY-TWO}

  %%-----------------------------
  %% lowercase
  %%-----------------------------

\newcommand*{\nthwords}[1]{
  \expandafter\@nthwords\csname c@#1\endcsname}
\newcommand*{\@nthwords}[1]{
  \protect\numberstringnum{\number#1}}
\AddEnumerateCounter{\nthwords}{\@nthwords}{forty-two}



%------------------------------
%        "n" words
%------------------------------

  %%-----------------------------
  %% Capitalised
  %%-----------------------------

\newcommand{\Nwords}[1]{\expandafter\@Nwords\csname c@#1\endcsname}
\newcommand*{\@Nwords}[1]{%
  \protect\Ordinalstringnum{\number#1}}
\AddEnumerateCounter{\Nwords}{\@Nwords}{Seventeen}



  %%-----------------------------
  %% UPPERCASE
  %%-----------------------------

\newcommand{\NWORDS}[1]{\expandafter\@NWORDS\csname c@#1\endcsname}
\newcommand*{\@NWORDS}[1]{%
  \protect\ORDINALstringnum{\number#1}}
\AddEnumerateCounter{\NWORDS}{\@NWORDS}{SEVENTEEN}


  %%-----------------------------
  %% lowercase
  %%-----------------------------

\newcommand{\nwords}[1]{\expandafter\@nwords\csname c@#1\endcsname}
\newcommand*{\@nwords}[1]{%
  \protect\ordinalstringnum{\number#1}}
\AddEnumerateCounter{\nwords}{\@nwords}{seventeen}


%------------------------------
%  Here ends the file
%------------------------------