I am trying to come up with a new enumerated list environment "stepslist" such that the items are marked with "Step k of n", where n is the total number of items in one stepslist environment, and k is the kth item in it. Thus e.g. the code
\begin{stepslist}
\item A
\item B
\item C
\end{stepslist}
ought to render as:
Step 1 of 3: A
Step 2 of 3: B
Step 3 of 3: C
and
\begin{stepslist}
\item A
\item B
\item C
\item D
\end{stepslist}
ought to render as:
Step 1 of 4: A
Step 2 of 4: B
Step 3 of 4: C
Step 4 of 4: D
I don't want to define the variable n myself; I want its value to be determined automatically by the macro. Conversations with GPT4 suggest a "two-pass approach" (which makes sense, since as I understand it LaTeX does not know at the beginning of a list environment how many items there are in it).
I am unaware if this can even be done, but if it can then I would appreciate a method that would work in Overleaf.

etaremunepackage solves this by writing a line per list to the aux file (i.e. the two-pass approach). Similar to the answers of Q33748 one might typeset the list twice, once just for counting the items. – Qrrbrbirlbel Aug 14 '23 at 19:35