From fdc5e9c25570d64b606c141c6efd67c6ec046316 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Tue, 26 Jul 2011 23:25:26 +0000 Subject: new latex package moreenum (16jul11) git-svn-id: svn://tug.org/texlive/trunk@23239 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/moreenum/README | 64 +++++ .../doc/latex/moreenum/testcase-moreenum.pdf | Bin 0 -> 147300 bytes .../doc/latex/moreenum/testcase-moreenum.tex | 184 +++++++++++++++ Master/texmf-dist/tex/latex/moreenum/moreenum.sty | 261 +++++++++++++++++++++ Master/tlpkg/bin/tlpkg-ctan-check | 2 +- Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc | 1 + Master/tlpkg/tlpsrc/moreenum.tlpsrc | 0 7 files changed, 511 insertions(+), 1 deletion(-) create mode 100644 Master/texmf-dist/doc/latex/moreenum/README create mode 100644 Master/texmf-dist/doc/latex/moreenum/testcase-moreenum.pdf create mode 100644 Master/texmf-dist/doc/latex/moreenum/testcase-moreenum.tex create mode 100644 Master/texmf-dist/tex/latex/moreenum/moreenum.sty create mode 100644 Master/tlpkg/tlpsrc/moreenum.tlpsrc diff --git a/Master/texmf-dist/doc/latex/moreenum/README b/Master/texmf-dist/doc/latex/moreenum/README new file mode 100644 index 00000000000..d5ee9956e52 --- /dev/null +++ b/Master/texmf-dist/doc/latex/moreenum/README @@ -0,0 +1,64 @@ +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.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/Master/texmf-dist/doc/latex/moreenum/testcase-moreenum.pdf b/Master/texmf-dist/doc/latex/moreenum/testcase-moreenum.pdf new file mode 100644 index 00000000000..0844f550378 Binary files /dev/null and b/Master/texmf-dist/doc/latex/moreenum/testcase-moreenum.pdf differ diff --git a/Master/texmf-dist/doc/latex/moreenum/testcase-moreenum.tex b/Master/texmf-dist/doc/latex/moreenum/testcase-moreenum.tex new file mode 100644 index 00000000000..5009a24de6a --- /dev/null +++ b/Master/texmf-dist/doc/latex/moreenum/testcase-moreenum.tex @@ -0,0 +1,184 @@ +\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} + +\newcommand\testenumerate[1]{% + \bigskip + \begin{minipage}{0.4\linewidth} + {\qquad\Large\texttt{\textbackslash #1}} + \begin{enumerate}[label=\csname #1\endcsname*] + \item Liberty + \item Equality + \item Fraternity\setcounter{enumi}{41} + \item Meaning of life + \end{enumerate} + \end{minipage} +} +\newcommand\dotest[1]{% + \let\do\testenumerate + \docsvlist} + +\begin{document} +\maketitle + + +\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| and |\nthwords|] +\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|).} + + +\section{Examples of the enumerations} +Here are examples of all the kinds of enumeration that the package defines: +% \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/Master/texmf-dist/tex/latex/moreenum/moreenum.sty b/Master/texmf-dist/tex/latex/moreenum/moreenum.sty new file mode 100644 index 00000000000..00b93777c4d --- /dev/null +++ b/Master/texmf-dist/tex/latex/moreenum/moreenum.sty @@ -0,0 +1,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 +%------------------------------ \ No newline at end of file diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check index c7471cbe0b8..de73c500fc5 100755 --- a/Master/tlpkg/bin/tlpkg-ctan-check +++ b/Master/tlpkg/bin/tlpkg-ctan-check @@ -243,7 +243,7 @@ my @TLP_working = qw( mkgrkindex mkjobtexmf mkpattern mla-paper mlist mmap mnsymbol moderncv modref modroman mongolian-babel montex - morefloats morehype moresize + moreenum morefloats morehype moresize moreverb movie15 mp3d mparhack mpgraphics mpman-ru ms msc msg mslapa msuthesis mtgreek multenum multibbl multibib multicap multirow diff --git a/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc b/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc index 67d27f654cd..c067648fc7e 100644 --- a/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc +++ b/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc @@ -412,6 +412,7 @@ depend mmap depend moderncv depend modref depend modroman +depend moreenum depend morefloats depend morehype depend moresize diff --git a/Master/tlpkg/tlpsrc/moreenum.tlpsrc b/Master/tlpkg/tlpsrc/moreenum.tlpsrc new file mode 100644 index 00000000000..e69de29bb2d -- cgit v1.2.3