4

I'm using the etaremune package to create a reverse enumeration and I would like to be able to alter the counter so that an item is skipped but the enumeration still ends at 1.

\documentclass{article}

\usepackage{etaremune}
\begin{document}
\begin{etaremune}
\item the fourth
\item the third
%%\item the second
\item the first
\end{etaremune}
\end{document}
3

One way to alter the numbering is the \addtocounter command. However only using it at the location of the item being skipped will alter the items coming after it in the tex file rather than the items coming after it in the counting scheme. A solution to this inconvenience is to juggle with counters as follows.

\documentclass{article}
\usepackage{etaremune}
\begin{document}
\begin{etaremune}
\addtocounter{enumi}{1}
\item the fourth
\item the third
%%\item the second
\addtocounter{enumi}{-1}
\item the first
\end{etaremune}
\end{document}
  • 1
    An alternative to executing \addtocounter{enumi}{1} would be to change \begin{etaremune} to \begin{etaremune}[start=4]. Of course, the instruction \addtocounter{enumi}{-1} is still needed. – Mico Dec 16 '18 at 8:42
2

In addition to the normal counters for enumeration environments, which now count down, etaremune uses a second counter called EM@itemctr. This counter just counts up like normal and it is used to determine how many items the environment has so that the right starting value can be used during the next run.

You can thus skip an item in an etaremune environment by decreasing \@enumctr (= enum<i+> where <i+> stands for an appropriate number of i's) by one and increasing EM@itemctr by one. The macro \etaremuneskip, which I define below, does precisely this (and it takes an optional argument in case you want to skip multiple items).

\documentclass{article}
\pagestyle{empty}

\usepackage{etaremune}
\makeatletter %% <- make @ usable in command names
\newcommand*\etaremuneskip[1][1]{%
  \addtocounter{EM@itemctr}{#1}%
  \addtocounter{\@enumctr}{-#1}%
}
\makeatother  %% <- revert @

\begin{document}

\begin{etaremune}
  \item the fourth\label{fourth}
    \begin{etaremune}
      \item the f-th
      \item the e-th
      \etaremuneskip[3]
      \item the a-th
    \end{etaremune}
  \item the third \label{third}
  \etaremuneskip
  \item the first\label{first}
\end{etaremune}

\end{document}

output

(Apart from the fact that it is localised to the place where the item should otherwise be inserted, I don't think this has any advantages to the answer you posted yourself though.)

  • Is there an advantage to running \etaremuneskip[3] instead of, say, \addtocounter{enumii}{-3}? – Mico Dec 16 '18 at 8:46
  • 1
    @Mico: If you do the latter (without incrementing EM@itemctr), you'll also need to add \addtocounter{enumii}{3} at the top of the etaremune environment (as in the other answer). Otherwise the items will not be labelled correctly. – Circumscribe Dec 16 '18 at 8:54
  • 1
    @Mico: (Apart from that, no.) – Circumscribe Dec 16 '18 at 9:06

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.