[Tex/LaTex] Add leading zero to the items listed by a custom etaremune and enumerate

#enumeratelists

How can I add leading zeros in the items that are listed by the packages etaremune and enumerate? For example, I would like to have the labels to be:

A01, A02, A03, ..., A09, A10

Here is an example code. How can I add the leading zeros locally and globally?

\documentclass{article}

\usepackage{etaremune}
\usepackage{enumitem}
\setlist[enumerate]{nosep} % To remove the spacing


\begin{document}
First list

\renewcommand*{\labelenumi}{A\theenumi.}
\begin{etaremune}[topsep=0pt,itemsep=0pt,partopsep=0pt,parsep=0pt,] 
    \item item 10
    \item item 09
    \item item 08
    \item item 07
    \item item 06
    \item item 05
    \item item 04
    \item item 03
    \item item 02
    \item item 01
\end{etaremune}

Second list
\begin{enumerate}[label={M\arabic*.}]
    \item item 01
    \item item 02
\end{enumerate}

Third list
\begin{enumerate}[label={M\arabic*.}, resume]
    \item item 03
    \item item 04
\end{enumerate}

\end{document}

Here is enter image description herethe output:

Best Answer

[Edit I'm editting this to make the solution clearer, inlight of the evolution of the both the question and its solution. As a result, the comments below may not make much sense...]

The code below makes it possible to do what you want using just the enumitem package. In particular, etaremune is no longer needed because we trick enumerate into behaving like an etaremune environment using enumitem.

The code uses enumitem's \AddEnumerateCounter command to define two new counters: \PaddingUp and \PaddingDown. Both counters pad item numbers with a 0 if the counter is less than 10. The \PaddingDown counter has the extra feature of surreptitiously decreasing the item counter by one (it actually decreases it by two so that when the counter is next incremented the net effect is that it will have decreased by one).

The \PaddingUp and \PaddingDown counters can be used like any of the standard enumitem counter macros. Consequently,

\begin{enumerate}[label=Up\PaddingUp*.]
...
\end{enumerate}

creates an enumerate environment with item labels Up01., Up02., ... whereas

\begin{enumerate}[label=Down\PaddingDown*.,start=10]
...
\end{enumerate}

creates an enumerate environment with item labels Down10., Down09., ...

The following code prodcuces the OP's requested output:

\documentclass{article}
\usepackage{enumitem}

\makeatletter
\AddEnumerateCounter{\PaddingUp}{\two@digits}{A00}
\AddEnumerateCounter{\PaddingDown}{\two@digits}{A00}
\newcommand\PaddingUp[1]{\expandafter\two@digits\csname c@#1\endcsname}
\newcommand\PaddingDown[1]{\PaddingUp{#1}\addtocounter{#1}{-2}}
\makeatother

\setlist[enumerate]{nosep,label=M\PaddingUp*.} % To remove the spacing
\newlist{etaremune}{enumerate}{1}% one level of nesting
\setlist[etaremune]{nosep,label=A\PaddingDown*.}

\begin{document}

First list
\begin{etaremune}[start=10]
    \item item 10
    \item item 09
    \item item 08
    \item item 07
    \item item 06
    \item item 05
    \item item 04
    \item item 03
    \item item 02
    \item item 01
\end{etaremune}

Second list
\begin{enumerate}
    \item item 01
    \item item 02
\end{enumerate}

Third list
\begin{enumerate}[resume]
    \item item 03
    \item item 04
\end{enumerate}

\end{document}

For good measure, the code above defines an etaremune enviroment with the nosep option. This is possibly misleading, however, because the decreasing counters are given by setting the label to label=\PaddingDown*. Above, this is done using setlist. Note that it is necessay to explicitly set the starting value of the item counters in an etaremune environment. If you don't set a starting value then they will start from 1, which is probably not what you want.

Finally, perhaps I should point out that it is easy to change the letters etc labelling these environments as you use them. For example, to change them to use P's and Q's you would write:

\begin{enumerate}[label=P\PaddingDown*.]% item -> P#. going up
    \item item 01 \item item 02
\end{enumerate}

\begin{enumerate}[label=Q\PaddingUp*.]% item -> P#. going down
    \item item 01 \item item 02
\end{enumerate}