3

In the package enumerate I can set the label using \begin{enumerate}[label={[\arabic*]}]. However, if I try this in etaremune (provides a reverse list) I get the following error

  • Package xkeyval Error: ``label' undefined in families `template'. \begin{etaremune}[label={[\arabic*]}]

How can I set the label in etaremune? The documentation tells me I can use the same labels, but it does not work for me. Below is an MWE that shows this issue.

\documentclass[12pt,letterpaper]{article}
\usepackage{enumitem}           % added for adjusting the indent of publications. adjusted locally at each list
\usepackage{etaremune}          % added for reverse numbering of enumerated lists
\begin{document}


  \section{A list with etaremune and label (returns an error)}
  \begin{etaremune}[label={[\arabic*]}]
    \item An item in a list
    \item An item in a list
    \item An item in a list
  \end{etaremune}


  \section{A list with enumerate and label (no error)}
  \begin{enumerate}[label={[\arabic*]}]
    \item An item in a list
    \item An item in a list
    \item An item in a list
  \end{enumerate}

\end{document}
1

1 Answer 1

3

Here's a reimplementation of etaremune using enumitem.

The idea is to set, at the end, a label that points to the last used number. This can be used for doing the necessary arithmetic with the help of \getrefnumber.

Two runs are obviously needed to get the counters in synch.

\documentclass{article}
\usepackage{enumitem}
\usepackage{refcount}

\makeatletter
\AddEnumerateCounter*{\reversearabic}{\@reversearabic}{2}
\newcommand{\reversearabic}[1]{\expandafter\@reversearabic\csname c@#1\endcsname}
\newcommand{\@reversearabic}[1]{%
  \number\numexpr\getrefnumber{this@etaremune@\romannumeral\c@etaremune}-#1+1\relax
}
\newcounter{etaremune}
\newenvironment{etaremune}[1][]{%
  \stepcounter{etaremune}%
  \begin{enumerate}[label=\reversearabic*.,#1]%
}{%
  \edef\@currentlabel{\the\csname c@\@enumctr\endcsname}%
  \label{this@etaremune@\romannumeral\c@etaremune}%
  \end{enumerate}%
}
\makeatother

\begin{document}

\begin{enumerate}[label={[\arabic*]}]
\item one
\item two
\item three
\item four
\end{enumerate}

\begin{etaremune}[label={[\reversearabic*]}]
\item one
\item two
\item three
\item four
\end{etaremune}

\begin{etaremune}
\item one
\item two
\item three
\item four
\end{etaremune}

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .