0

I would like to find a solution to generate items with a reverse counting of the numbering like this

  1. Blablabla
  2. Blablabla
  3. Blablabla
  • 4
    Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Jun 29 '22 at 14:09
  • 7
    The counting in your example is not reversed. But does not begin with 1. Please clarify what you wish to achieve. – Ulrich Diez Jun 29 '22 at 14:12

1 Answers1

0

Perhaps something like this does the trick—it requires at least two compilations to work out:

\documentclass{article}
\usepackage[colorlinks=true]{hyperref}
\usepackage[user]{zref}

\makeatletter \zref@newprop{ItemNo}{}% \newcommand\my@caseselect[2]{#2}% \newcommand\ItemNumberlabel[1]{% \bsphack \begingroup \let\my@caseselect=@firstoftwo \zref@setcurrent{ItemNo}{\number\value{enum\romannumeral@enumdepth}}% \zref@labelbyprops{#1}{ItemNo}% \endgroup \esphack }% \newcommand\revertcounting[2]{% \expandafter@revertcounting \expandafter{\romannumeral\the\numexpr@enumdepth+1\expandafter\relax\expandafter}% \expandafter{\romannumeral\the@enumdepth}% {#1}{#2}% \ignorespaces }% \newcommand@revertcounting[4]{% @namedef{theenum#1}{% \my@caseselect{% \csname @#4\endcsname{\csname c@enum#1\endcsname}% }{% \zref@ifrefundefined{#3}% {\csname @#4\endcsname{\csname c@enum#1\endcsname}}% {% \csname @#4\endcsname{% \the\numexpr \zref@extractdefault{#3}{ItemNo}{0} - % \number\value{enum#1} + 1% \relax }% }% }% }% }% \makeatother

\begin{document}

\null\par\kern-3cm

\begin{enumerate} \item text A \item text B \item \begin{enumerate} \item text One \item \label{itA}text Two \item text Three \item text Four \end{enumerate} \item text D \end{enumerate}

\bigskip\hrule\bigskip

\begingroup \revertcounting{lastitemA}{arabic}% \begin{enumerate} \item text A \item text B \item \begingroup \revertcounting{lastitemB}{alph}% \begin{enumerate} \item text One \item \label{itB}text Two \item text Three \item \ItemNumberlabel{lastitemB}text Four \end{enumerate} \endgroup \item \ItemNumberlabel{lastitemA}text D \end{enumerate} \endgroup

\bigskip\hrule\bigskip

\begingroup \revertcounting{lastitemC}{arabic}% \begin{enumerate} \item text A \item text B \item \begin{enumerate} \item text One \item \label{itC}text Two \item text Three \item text Four \end{enumerate} \item \ItemNumberlabel{lastitemC}text D \end{enumerate} \endgroup

\bigskip\hrule\bigskip

\begin{enumerate} \item text A \item text B \item \begingroup \revertcounting{lastitemD}{alph}% \begin{enumerate} \item text One \item \label{itD}text Two \item text Three \item \ItemNumberlabel{lastitemD}text Four \end{enumerate} \endgroup \item text D \end{enumerate}

Cross-referencing:

\verb|\ref{itA}|: \ref{itA}

\verb|\ref{itB}|: \ref{itB}

\verb|\ref{itC}|: \ref{itC}

\verb|\ref{itD}|: \ref{itD}

\end{document}

enter image description here

Ulrich Diez
  • 28,770