Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: c41d7b47f1
Fetching contributors…

Cannot retrieve contributors at this time

283 lines (222 sloc) 8.063 kB
%% 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/11/03 v1.03]
\RequirePackage{amsmath} % For Greek letters
\RequirePackage{alphalph} % For doubling Greek letters
\RequirePackage{enumitem} % The enumeration workhorse
\RequirePackage{fmtcount} % The number translation workhorse
\RequirePackage{epsdice} % For dicecount
% 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
% Thanks to Kevin Klement for pointing out a spacing problem
% with the Greek commands that is now fixed.
\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}%
}
%------------------------------
% Octal
%------------------------------
\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\Ordinalstringnum{\number#1}}
\AddEnumerateCounter{\Nthwords}{\@Nthwords}{Seventeenth}
%%-----------------------------
%% UPPERCASE
%%-----------------------------
\newcommand*{\NTHWORDS}[1]{
\expandafter\@NTHWORDS\csname c@#1\endcsname}
\newcommand*{\@NTHWORDS}[1]{
\protect\ORDINALstringnum{\number#1}}
\AddEnumerateCounter{\NTHWORDS}{\@NTHWORDS}{FORTY-TWO}
%%-----------------------------
%% lowercase
%%-----------------------------
\newcommand*{\nthwords}[1]{
\expandafter\@nthwords\csname c@#1\endcsname}
\newcommand*{\@nthwords}[1]{
\protect\ordinalstringnum{\number#1}}
\AddEnumerateCounter{\nthwords}{\@nthwords}{forty-two}
%------------------------------
% "n" words
%------------------------------
%%-----------------------------
%% Capitalised
%%-----------------------------
\newcommand{\Nwords}[1]{\expandafter\@Nwords\csname c@#1\endcsname}
\newcommand*{\@Nwords}[1]{%
\protect\Numberstringnum{\number#1}}
\AddEnumerateCounter{\Nwords}{\@Nwords}{Seventeen}
%%-----------------------------
%% UPPERCASE
%%-----------------------------
\newcommand{\NWORDS}[1]{\expandafter\@NWORDS\csname c@#1\endcsname}
\newcommand*{\@NWORDS}[1]{%
\protect\NUMBERstringnum{\number#1}}
\AddEnumerateCounter{\NWORDS}{\@NWORDS}{SEVENTEEN}
%%-----------------------------
%% lowercase
%%-----------------------------
\newcommand{\nwords}[1]{\expandafter\@nwords\csname c@#1\endcsname}
\newcommand*{\@nwords}[1]{%
\protect\numberstringnum{\number#1}}
\AddEnumerateCounter{\nwords}{\@nwords}{seventeen}
%------------------------------
% Dice (up to 12)
%------------------------------
\newcommand*{\dicecount}[1]{%
\expandafter\@dicecount\csname c@#1\endcsname%
}
\newcommand*{\@dicecount}[1]{%
\ifcase#1\or\epsdice{1}\or\epsdice{2}\or\epsdice{3}%
\or\epsdice{4}\or\epsdice{5}\or\epsdice{6}%
\or\epsdice{3}\epsdice{4}%
\or\epsdice{6}\epsdice{2}%
\or\epsdice{5}\epsdice{4}%
\or\epsdice{5}\epsdice{5}%
\or\epsdice{6}\epsdice{5}%
\or\epsdice{6}\epsdice{6}%
\else\@ctrerr\fi%
}
\AddEnumerateCounter{\dicecount}{\@dicecount}{\epsdice{6}\epsdice{6}}
%------------------------------
% Here ends the file
%------------------------------
Jump to Line
Something went wrong with that request. Please try again.