summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/moreenum
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/moreenum
Initial commit
Diffstat (limited to 'macros/latex/contrib/moreenum')
-rw-r--r--macros/latex/contrib/moreenum/README69
-rw-r--r--macros/latex/contrib/moreenum/moreenum-doc.pdfbin0 -> 216731 bytes
-rw-r--r--macros/latex/contrib/moreenum/moreenum-doc.tex201
-rw-r--r--macros/latex/contrib/moreenum/moreenum.sty263
4 files changed, 533 insertions, 0 deletions
diff --git a/macros/latex/contrib/moreenum/README b/macros/latex/contrib/moreenum/README
new file mode 100644
index 0000000000..72063c144a
--- /dev/null
+++ b/macros/latex/contrib/moreenum/README
@@ -0,0 +1,69 @@
+This is the README for moreenum.sty
+The author/maintainer of this work is Seamus Bradley.
+tex@seamusbradley.net
+
+This provides the following new enumerate styles.
+
+ - \greek for lowercase Greek letters
+ - \Greek for uppercase Greek letters
+ - \enumHex for uppercase hexadecimal enumeration
+ - \enumhex for lowercase hexadecimal enumeration
+ - \enumbinary for binary enumeration
+ - \enumoctal for octal enumeration
+ - \raisenth for 1st, 2nd, 3rd etc with raised "th"s
+ - \levelnth for 1st, 2nd 3rd with level "th"s
+ - \Nthwords for "First", "Second", "Third" etc
+ - \nthwords for "first", "second", "third" etc
+ - \NTHWORDS for "FIRST", "SECOND", "THIRD" etc
+ - \Nwords for "One", "Two", "Three" etc
+ - \nwords for "one", "two", "three" etc
+ - \NWORDS for "ONE", "TWO", "THREE" etc
+
+Each of these works with enumitem's "starred variant" feature.
+So \begin{enumerate}[label=\Hex*] will output a hex enumerated list.
+Enumitem provides a start=0 option for starting your enumerations at
+0.
+A binzero environment is provided for binary starting at zero enumeration.
+Likewise enumoctzero, enumHexzero and enumhexzero for the hex enumerations.
+
+Currently requires amsmath, alphalph, enumitem and fmtcount
+all of which should be part of any modern TeX distribution.
+
+This isn't so much a package designed for use as a list of recipes for
+creating your own new kinds of enumeration.
+All of the work is really done by the various packages loaded.
+
+TWO WARNINGS:
+
+ - You probably don't want to use uppercase greek numbering. Ever.
+ - Be careful with uppercase Hex numbering for sections if you also
+ have appendices.
+ - (A more general version of the last point) Don't mix \Alph and
+ \enumHex, or \alph and \enumhex
+
+TO DO:
+
+ - Properly namespace the internal macros.
+ - Make consistent the way the macros for counters and numbers are
+ treated.
+ - Test spacing of enumerations.
+
+
+CHANGELOG
+See https://github.com/scmbradley/moreenum for a full changelog
+
+v1.02
+ Spacing issues fixed
+ \nwords and friends and \nthwords and friends are now the right way round.
+v1.01
+ NWORDS and friends now supported
+v1.0
+ levelnth and raisenth work with fmtcount
+ fmtcount also replaces binhex.tex
+ fmtcount also replaces numname
+v0.95
+ levelnth and raisenth work through environments with engord's switch
+ numname used for nwords and nthwords
+v0.9
+ Initial version
+
diff --git a/macros/latex/contrib/moreenum/moreenum-doc.pdf b/macros/latex/contrib/moreenum/moreenum-doc.pdf
new file mode 100644
index 0000000000..f2e82e180a
--- /dev/null
+++ b/macros/latex/contrib/moreenum/moreenum-doc.pdf
Binary files differ
diff --git a/macros/latex/contrib/moreenum/moreenum-doc.tex b/macros/latex/contrib/moreenum/moreenum-doc.tex
new file mode 100644
index 0000000000..a8d8849770
--- /dev/null
+++ b/macros/latex/contrib/moreenum/moreenum-doc.tex
@@ -0,0 +1,201 @@
+\documentclass[paper=A4,fontsize=12]{scrartcl}
+\usepackage[T1]{fontenc}
+\usepackage[utf8]{inputenc}
+\usepackage{url}
+\usepackage{etoolbox}
+\usepackage{multicol}
+\usepackage{listings}
+\lstloadlanguages{[LaTeX]TeX} % I need to tell listings how I want code typeset. Here come some options:
+\lstset{%
+ basicstyle=\ttfamily\small,
+ commentstyle=\itshape\ttfamily\small,
+ showspaces=false,
+ showstringspaces=false,
+ breaklines=true,
+ breakautoindent=true,
+ captionpos=t,
+ frame=single,
+ escapeinside={(*}{*)},
+}
+\catcode`|=\active
+\def|{\lstinline|}
+
+\usepackage{moreenum}
+\usepackage{etoolbox}
+\author{Seamus Bradley}
+\title{\texttt{moreenum}}
+\usepackage{tgpagella}
+\usepackage{tgheros}
+%\usepackage{tgcursor}
+\usepackage[ocr-a]{ocr}
+
+\newcounter{namespacer}
+\newcommand\namespace{\the\value{namespacer}}
+
+\newcommand\testenumerate[1]{%
+ \bigskip\stepcounter{namespacer}
+ \begin{minipage}{0.4\linewidth}
+ {\qquad\Large\texttt{\textbackslash #1}}
+ \begin{enumerate}[label={\csname #1\endcsname*.}]
+ \item Liberty: \expandafter\ref{\namespace}
+ \item Equality
+ \item Fraternity\expandafter\label{\namespace}
+ \setcounter{enumi}{41}
+ \item Meaning of life
+ \end{enumerate}
+ \end{minipage}
+}
+\newcommand\dotest[1]{%
+ \let\do\testenumerate
+ \docsvlist}
+
+\begin{document}
+\maketitle
+
+\begin{abstract}
+ This package provides more enumeration styles for |enumerate| environments.
+ The styles are supposed to work with |enumitem|.
+ This is |moreenum| version 1.03.
+\end{abstract}
+\section{Basic procedure}
+
+At the heart of each new enumeration is the following procedure:
+
+\begin{lstlisting}
+ \newcommand*{\macro}[1]{%
+ \expandafter\@macro\csname c@#1\endcsname}
+ \newcommand*{\@macro}[1]{%
+ \translate{#1}}
+ \AddEnumerateCounter{\macro}{\@macro}{distance}
+\end{lstlisting}
+
+From a user perspective, \lstinline+\macro+ takes a counter as its
+argument and outputs, say, a
+binary number or whatever you want.
+Actually, what it really does is turn a counter into a number and pass
+the number to \lstinline+\@macro+ which does the real work.
+It takes a number and translates it into the final representation.
+
+Most of the cleverness is done by \lstinline+\translate+ and these are
+mostly macros I've borrowed from other packages.
+
+The |distance| is the widest entry in the enumeration.
+|moreenum| hasn't been tested much with this parameter:
+I've just guessed a bit at what's the widest enumerations are likely
+to get.
+Enumerations can \emph{theoretically} get up to 2147483647 items long.
+Which would be rather a long number.\footnote{%
+ |fmcount| doesn't seem to work with numbers that big, actually.
+ But even 131071 is \binarynum{131071}}
+
+The |\greek| macro is a little more involved because it involves first
+defining a macro that turns numbers into Greek letters.
+
+\begin{lstlisting}
+\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$
+}
+\end{lstlisting}
+
+Then you need to define what to do when you run out of letters.
+You start again at $\alpha\alpha$.
+The clever work there is done by the |alphalph| package.
+
+\begin{lstlisting}
+\newalphalph{\@greek}[alph]{\@single@greek}{24}
+\newcommand*{\greek}[1]{%
+ \expandafter\@greek\csname c@#1\endcsname
+}
+
+\AddEnumerateCounter{\greek}{\@greek}{$\omega$}
+\end{lstlisting}
+
+Some sophistication is required to get the |\translate|-style macros
+to play nice with |\label| and |\ref| facilities.
+This can be seen in the following example.
+
+\begin{lstlisting}
+\newcommand*{\enumHex}[1]{%
+ \expandafter\@enumHex\csname c@#1\endcsname}
+\newcommand*{\@enumHex}[1]{%
+ \protect\Hexadecimalnum{\number#1}}
+\AddEnumerateCounter{\enumHex}{\@enumHex}{AAAA}
+\end{lstlisting}
+
+The |\protect| makes sure the |\Hexadecimalnum| get written to the
+|.aux| file, rather than expanded first.
+The |\number| makes sure the number \emph{is} written to the |.aux|
+file.\footnote{I'm actually guessing here.
+ I have no idea.
+ I got the clue from |egreg| here:
+ \url{http://tex.stackexchange.com/q/22234/215}}
+
+\section{Limitations}
+
+The biggest number TeX can handle is 2147483647.
+I can't imagine this ever being a serious limitation to your
+enumerating.
+
+There are, however, some further limitations.
+Certain |fmtcount| macros seem to break before they hit this
+fundamental limit.
+In brackets are the |moreenum|-defined enumerations affected.
+\begin{itemize}
+\item |\binary| and friends break at 131072 [|\enumbinary|]
+\item |\hexadecimal| and friends break at 1048576 [|\enumhex| and |\enumHex|]
+\item |\numberstring| and friends break at 100000 [|\nwords|,
+ |\nthwords| and friends]
+\end{itemize}
+
+None of these is a serious limitation.
+If you desperately need bigger enumerations, they are fairly
+straightforward to define yourself using |binhex| for the numbers and
+|numname| for the words: these packages don't have these
+limitations.\footnote{%
+ Why don't I just use those packages instead?
+ Because having |fmtcount| do most of the work means only loading one
+ package instead of 3 (|numname|, |binhex| and |nth| or |engord|).
+ Also, |fmtcount| can speak different languages,
+ and in future releases I'm tempted to try to get that working here.}
+
+
+\section{Examples of the enumerations}
+Here are examples of all the kinds of enumeration that the package
+defines.
+The first item contains a reference to the third.
+This is to test if the referencing is working.
+The labels have dots after them, to check whether errant spaces are
+being added after the labels.\footnote{Thanks to Kevin Klement for
+ pointing this issue out to me.}
+% \dotest{greek,Greek,enumHex,enumhex,enumbinary,raisenth,levelnth,nthwords,nwords}
+
+\small\noindent
+\testenumerate{greek}\hfil
+\testenumerate{Greek}
+\testenumerate{enumHex}\hfil
+\testenumerate{enumhex}
+\testenumerate{enumbinary}\hfil
+\testenumerate{enumoctal}
+\testenumerate{raisenth}\hfil
+\testenumerate{levelnth}
+\testenumerate{Nthwords}\hfil
+\testenumerate{Nwords}
+\testenumerate{NTHWORDS}\hfil
+\testenumerate{NWORDS}
+\testenumerate{nthwords}\hfil
+\testenumerate{nwords}
+
+
+\end{document}
+
+%%% Local Variables:
+%%% mode: latex
+%%% TeX-master: t
+%%% End:
diff --git a/macros/latex/contrib/moreenum/moreenum.sty b/macros/latex/contrib/moreenum/moreenum.sty
new file mode 100644
index 0000000000..4b486656fe
--- /dev/null
+++ b/macros/latex/contrib/moreenum/moreenum.sty
@@ -0,0 +1,263 @@
+ %% 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
+
+
+% 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}
+
+
+%------------------------------
+% Here ends the file
+%------------------------------ \ No newline at end of file