I would like to have an unusual numbering aAa going as follows:

 0 -> *
 1 -> a
 2 -> b
25 -> y
26 -> z
27 -> A
28 -> B
51 -> Y
52 -> Z
53 -> 1
54 -> 2
55 -> 3

Since it might be used in page numbering or similar sensitive contexts, the command \@aAa should be introduced so that \pagenumbering{aAa} works (I'm not going to use it this way but I still need it). As well, a fully expandable solution is welcomed.

  • 1
    Remark: I have an answer myself, but it is quite heavy and definitely not expandable. I'm searching for a simpler solution. – yo' Jan 1 '13 at 19:14

With the use of the already defined macros that return the alphabetical expression of a counter, this seems pretty straightforward.

Why \aAa and \@aAa?

Firstly, what is the difference between \<number style> and \@<number style>?

Whereas the argument of \@<number style> is a “number” which can be a counter, a \numexpr or just 42 , the argument of \<number style> has to be the name of a LaTeX counter, to be more precise, a name of a counter defined by \newcounter{<name>} (which defines a TeX counter named \c@<name>).

It must not be a <number> unless, of course, someone defined a counter named \c@<number>, but then we could get the <number style> expression of \c@<number> but not of <number>!


The usual definition of \<number style> is:

\def\<number style>#1{\expandafter\@<number style>\csname c@#1\endcsname

I have defined \aAa in the same way, which brings us to \@aAa.


The pretty straightforward part is that I have used a few simple if-conditions, in pseudo code:

if counter = 0 then
else if counter < 27
  alph(counter - 26)
else if counter < 53
  Alph(counter - 52)
  counter - 52
end if

where alph(arg)/Alph(arg) returns a/A for arg = 1, b/B for arg = 2, and so on.

Which “function” (read: macro) in LaTeX does this? The \@<number style> ones do. \<number style>{<arg>} would return the value of a counter named \c@<arg> (which probably doesn’t even exist).

(The macro \pagenumbering{<arg>} redefines \thepage as \@<arg>\c@page.)


\def\aAa#1{\expandafter\@aAa\csname c@#1\endcsname}% LaTeX

\usepackage{pgffor}% for the \foreach loop
%\renewcommand*{\theaAatest}{{\fboxsep=0pt\fbox{\aAa{aAatest}}}}% test for spurious spaces
\usepackage[T1]{fontenc}% for correct \meaning output
0: \theaAatest\par\setcounter{aAatest}{3}
3: \theaAatest\par\setcounter{aAatest}{51}
51: \theaAatest\par\setcounter{aAatest}{55}
55: \theaAatest

\edef\x{\theaAatest}% expansion?
\meaning\x% gives:
\show\x% gives:
% > \x=macro:
% ->3.
% l.33 \show\x

\foreach \i in {0,...,59}{
  \setcounter{aAatest}{\i} \i: \theaAatest\par



enter image description here

  • 1
    You have some spurious spaces in there... It is expandable: try \edef\x{\theaAatest}\show\x – clemens Jan 1 '13 at 20:14
  • +1 I had something similar, but I was just using \alph, \Alph (with no @); could you say why you used \@alph? – cmhughes Jan 1 '13 at 20:52
  • @cmhughes Quite simple: \@alph return the alphabetical expression of its argument (counter, numexpr, or a number), not the alphabetical expression of a LaTeX counter. See my updated answer for a hopefully more helpful explanation. – Qrrbrbirlbel Jan 1 '13 at 21:29
  • @cmhughes the point is that to define \@aAa you have to use \@alph and friends. To define \aAa directly you could use \alph and friends, but why to copy the code twice while the provided definition is the correctly desinged one, you see ... – yo' Jan 1 '13 at 21:34
  • 1
    @6rt4uu That is a property of the command \show: It shows the value of \x and interrupts the compilation process. To continue, simply press <enter>. Anyways, you only need the first 20 lines of the code, the rest is only a test that it works correctly. – yo' Jan 19 '13 at 23:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.