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 the 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 a0
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,creates an enumerate environment with item labels
Up01.
,Up02.
, ... whereascreates an enumerate environment with item labels
Down10.
,Down09.
, ...The following code prodcuces the OP's requested output:
For good measure, the code above defines an
etaremune
enviroment with thenosep
option. This is possibly misleading, however, because the decreasing counters are given by setting the label tolabel=\PaddingDown*.
Above, this is done usingsetlist
. Note that it is necessay to explicitly set the starting value of the item counters in anetaremune
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 andQ
's you would write: