# How to build one efficient alpha numbering?

Seeing this post, I'm looking for one good solution for alpha numbering. For my point of view, the way the numbering must be displayed depends on the maximum of the numbers.

1. If MAX = 26, then the alpha numbering must be a, b, c, ..., z.
2. If MAX = 26^2, then the alpha numbering must be aa, ab, ac, ..., az, ba, bb, bc, ..., bz, ..., za, zb, zc, ..., zz.
3. If MAX = 26^n, then the alpha numbering must be similar but with n letters instead of two.

How this features can be obtained by using one command with one constant to indicate the numbers n of letters to use for the alpha numbering ?

• I assume that you specify MAX (or n) before the counter is used, or should this numbering style automagically figure out how many letters to use? – Werner Dec 7 '11 at 23:04
• If I have to give MAX when I call the "alpha-numbering" command, it's not a problem. – projetmbc Dec 7 '11 at 23:21

\documentclass{article}
\usepackage{expl3,xparse}
\ExplSyntaxOn
\DeclareDocumentCommand {\alphanumbering} { O{3} m } {
\exp_last_unbraced:Nf \use_none:n {
\int_to_alph:n {
\exp_args:Nf \int_from_alph:n { \prg_replicate:nn {#1} {z} }
+ #2 } } }
\ExplSyntaxOff
\begin{document}
\alphanumbering{1}, \alphanumbering{2}, \ldots{}, \alphanumbering{26},
\alphanumbering{27}, \ldots{}, \alphanumbering{2*26},
\ldots{}, \alphanumbering{26*26}, \ldots{}, \alphanumbering{26*26*26},
\alphanumbering{26*26*26+1}.

\alphanumbering{12345}
\end{document}