| 1 |
\documentclass[paper=A4,fontsize=12]{scrartcl} |
| 2 |
\usepackage[T1]{fontenc} |
| 3 |
\usepackage[utf8]{inputenc} |
| 4 |
\usepackage{url} |
| 5 |
\usepackage{etoolbox} |
| 6 |
\usepackage{multicol} |
| 7 |
\usepackage{listings} |
| 8 |
\lstloadlanguages{[LaTeX]TeX} % I need to tell listings how I want code typeset. Here come some options: |
| 9 |
\lstset{% |
| 10 |
basicstyle=\ttfamily\small, |
| 11 |
commentstyle=\itshape\ttfamily\small, |
| 12 |
showspaces=false, |
| 13 |
showstringspaces=false, |
| 14 |
breaklines=true, |
| 15 |
breakautoindent=true, |
| 16 |
captionpos=t, |
| 17 |
frame=single, |
| 18 |
escapeinside={(*}{*)}, |
| 19 |
} |
| 20 |
\catcode`|=\active |
| 21 |
\def|{\lstinline|} |
| 22 |
|
| 23 |
\usepackage{moreenum} |
| 24 |
\usepackage{etoolbox} |
| 25 |
\author{Seamus Bradley} |
| 26 |
\title{\texttt{moreenum}} |
| 27 |
\usepackage{tgpagella} |
| 28 |
\usepackage{tgheros} |
| 29 |
%\usepackage{tgcursor} |
| 30 |
\usepackage[ocr-a]{ocr} |
| 31 |
|
| 32 |
\newcounter{namespacer} |
| 33 |
\newcommand\namespace{\the\value{namespacer}} |
| 34 |
|
| 35 |
\newcommand\testenumerate[1]{% |
| 36 |
\bigskip\stepcounter{namespacer} |
| 37 |
\begin{minipage}{0.4\linewidth} |
| 38 |
{\qquad\Large\texttt{\textbackslash #1}} |
| 39 |
\begin{enumerate}[label={\csname #1\endcsname*.}] |
| 40 |
\item Liberty: \expandafter\ref{\namespace} |
| 41 |
\item Equality |
| 42 |
\item Fraternity\expandafter\label{\namespace} |
| 43 |
\setcounter{enumi}{41} |
| 44 |
\item Meaning of life |
| 45 |
\end{enumerate} |
| 46 |
\end{minipage} |
| 47 |
} |
| 48 |
\newcommand\dotest[1]{% |
| 49 |
\let\do\testenumerate |
| 50 |
\docsvlist} |
| 51 |
|
| 52 |
\begin{document} |
| 53 |
\maketitle |
| 54 |
|
| 55 |
\begin{abstract} |
| 56 |
This package provides more enumeration styles for |enumerate| environments. |
| 57 |
The styles are supposed to work with |enumitem|. |
| 58 |
This is |moreenum| version 1.03. |
| 59 |
\end{abstract} |
| 60 |
\section{Basic procedure} |
| 61 |
|
| 62 |
At the heart of each new enumeration is the following procedure: |
| 63 |
|
| 64 |
\begin{lstlisting} |
| 65 |
\newcommand*{\macro}[1]{% |
| 66 |
\expandafter\@macro\csname c@#1\endcsname} |
| 67 |
\newcommand*{\@macro}[1]{% |
| 68 |
\translate{#1}} |
| 69 |
\AddEnumerateCounter{\macro}{\@macro}{distance} |
| 70 |
\end{lstlisting} |
| 71 |
|
| 72 |
From a user perspective, \lstinline+\macro+ takes a counter as its |
| 73 |
argument and outputs, say, a |
| 74 |
binary number or whatever you want. |
| 75 |
Actually, what it really does is turn a counter into a number and pass |
| 76 |
the number to \lstinline+\@macro+ which does the real work. |
| 77 |
It takes a number and translates it into the final representation. |
| 78 |
|
| 79 |
Most of the cleverness is done by \lstinline+\translate+ and these are |
| 80 |
mostly macros I've borrowed from other packages. |
| 81 |
|
| 82 |
The |distance| is the widest entry in the enumeration. |
| 83 |
|moreenum| hasn't been tested much with this parameter: |
| 84 |
I've just guessed a bit at what's the widest enumerations are likely |
| 85 |
to get. |
| 86 |
Enumerations can \emph{theoretically} get up to 2147483647 items long. |
| 87 |
Which would be rather a long number.\footnote{% |
| 88 |
|fmcount| doesn't seem to work with numbers that big, actually. |
| 89 |
But even 131071 is \binarynum{131071}} |
| 90 |
|
| 91 |
The |\greek| macro is a little more involved because it involves first |
| 92 |
defining a macro that turns numbers into Greek letters. |
| 93 |
|
| 94 |
\begin{lstlisting} |
| 95 |
\newcommand*{\single@greek}[1]{% |
| 96 |
\expandafter\@single@greek\csname c@#1\endcsname |
| 97 |
} |
| 98 |
\newcommand*{\@single@greek}[1]{% |
| 99 |
$\ifcase#1\or\alpha\or\beta\or\gamma\or\delta\or\varepsilon |
| 100 |
\or\zeta\or\eta\or\theta\or\iota\or\kappa\or\lambda |
| 101 |
\or\mu\or\nu\or\xi\or o\or\pi\or\varrho\or\sigma |
| 102 |
\or\tau\or\upsilon\or\phi\or\chi\or\psi\or\omega |
| 103 |
\else\@ctrerr\fi$ |
| 104 |
} |
| 105 |
\end{lstlisting} |
| 106 |
|
| 107 |
Then you need to define what to do when you run out of letters. |
| 108 |
You start again at $\alpha\alpha$. |
| 109 |
The clever work there is done by the |alphalph| package. |
| 110 |
|
| 111 |
\begin{lstlisting} |
| 112 |
\newalphalph{\@greek}[alph]{\@single@greek}{24} |
| 113 |
\newcommand*{\greek}[1]{% |
| 114 |
\expandafter\@greek\csname c@#1\endcsname |
| 115 |
} |
| 116 |
|
| 117 |
\AddEnumerateCounter{\greek}{\@greek}{$\omega$} |
| 118 |
\end{lstlisting} |
| 119 |
|
| 120 |
Some sophistication is required to get the |\translate|-style macros |
| 121 |
to play nice with |\label| and |\ref| facilities. |
| 122 |
This can be seen in the following example. |
| 123 |
|
| 124 |
\begin{lstlisting} |
| 125 |
\newcommand*{\enumHex}[1]{% |
| 126 |
\expandafter\@enumHex\csname c@#1\endcsname} |
| 127 |
\newcommand*{\@enumHex}[1]{% |
| 128 |
\protect\Hexadecimalnum{\number#1}} |
| 129 |
\AddEnumerateCounter{\enumHex}{\@enumHex}{AAAA} |
| 130 |
\end{lstlisting} |
| 131 |
|
| 132 |
The |\protect| makes sure the |\Hexadecimalnum| get written to the |
| 133 |
|.aux| file, rather than expanded first. |
| 134 |
The |\number| makes sure the number \emph{is} written to the |.aux| |
| 135 |
file.\footnote{I'm actually guessing here. |
| 136 |
I have no idea. |
| 137 |
I got the clue from |egreg| here: |
| 138 |
\url{http://tex.stackexchange.com/q/22234/215}} |
| 139 |
|
| 140 |
\section{Limitations} |
| 141 |
|
| 142 |
The biggest number TeX can handle is 2147483647. |
| 143 |
I can't imagine this ever being a serious limitation to your |
| 144 |
enumerating. |
| 145 |
|
| 146 |
There are, however, some further limitations. |
| 147 |
Certain |fmtcount| macros seem to break before they hit this |
| 148 |
fundamental limit. |
| 149 |
In brackets are the |moreenum|-defined enumerations affected. |
| 150 |
\begin{itemize} |
| 151 |
\item |\binary| and friends break at 131072 [|\enumbinary|] |
| 152 |
\item |\hexadecimal| and friends break at 1048576 [|\enumhex| and |\enumHex|] |
| 153 |
\item |\numberstring| and friends break at 100000 [|\nwords|, |
| 154 |
|\nthwords| and friends] |
| 155 |
\end{itemize} |
| 156 |
|
| 157 |
None of these is a serious limitation. |
| 158 |
If you desperately need bigger enumerations, they are fairly |
| 159 |
straightforward to define yourself using |binhex| for the numbers and |
| 160 |
|numname| for the words: these packages don't have these |
| 161 |
limitations.\footnote{% |
| 162 |
Why don't I just use those packages instead? |
| 163 |
Because having |fmtcount| do most of the work means only loading one |
| 164 |
package instead of 3 (|numname|, |binhex| and |nth| or |engord|). |
| 165 |
Also, |fmtcount| can speak different languages, |
| 166 |
and in future releases I'm tempted to try to get that working here.} |
| 167 |
|
| 168 |
|
| 169 |
\section{Examples of the enumerations} |
| 170 |
Here are examples of all the kinds of enumeration that the package |
| 171 |
defines. |
| 172 |
The first item contains a reference to the third. |
| 173 |
This is to test if the referencing is working. |
| 174 |
The labels have dots after them, to check whether errant spaces are |
| 175 |
being added after the labels.\footnote{Thanks to Kevin Klement for |
| 176 |
pointing this issue out to me.} |
| 177 |
% \dotest{greek,Greek,enumHex,enumhex,enumbinary,raisenth,levelnth,nthwords,nwords} |
| 178 |
|
| 179 |
\small\noindent |
| 180 |
\testenumerate{greek}\hfil |
| 181 |
\testenumerate{Greek} |
| 182 |
\testenumerate{enumHex}\hfil |
| 183 |
\testenumerate{enumhex} |
| 184 |
\testenumerate{enumbinary}\hfil |
| 185 |
\testenumerate{enumoctal} |
| 186 |
\testenumerate{raisenth}\hfil |
| 187 |
\testenumerate{levelnth} |
| 188 |
\testenumerate{Nthwords}\hfil |
| 189 |
\testenumerate{Nwords} |
| 190 |
\testenumerate{NTHWORDS}\hfil |
| 191 |
\testenumerate{NWORDS} |
| 192 |
\testenumerate{nthwords}\hfil |
| 193 |
\testenumerate{nwords} |
| 194 |
|
| 195 |
|
| 196 |
\end{document} |
| 197 |
|
| 198 |
%%% Local Variables: |
| 199 |
%%% mode: latex |
| 200 |
%%% TeX-master: t |
| 201 |
%%% End: |