# Enumerated list, labels like 1/3, 2/3, 3/3

I'd like to have an enumerated list that ① supports resume and ② uses the notation n of N, e.g. (in ASCII)

1/4. Bla.
2/4. Bla bla.

3/4. from my balcone.
4/4. Bla bla.


I imagine that I could use a counter and possibly a two pass compilation (but I don't know how exactly do that), but I wonder if that some package already provides the requested features.

• The totcount package should be able to do that. #2, at least. Jul 3 at 10:46
• @user574859 Questions in a written test? Jul 3 at 13:59
• Note that the label has to fit into \labelwidth-\labelsep, so 10/11 will probably cause problems. Jul 3 at 15:35

With enumitem you can save the final value of the counter.

\documentclass{article}
\usepackage{enumitem}

\newlist{gbenumerate}{enumerate}{1}
\setlist[gbenumerate]{
wide,
label=\arabic*/\gbenumall.,
}

\providecommand\gbenumall{0}% initial value

\makeatletter
\AtEndDocument{%
\write\@auxout{\gdef\string\gbenumall{\the\value{gbenumeratei}}}%
}
\makeatother

\begin{document}

\begin{gbenumerate}
\item this is the first item
\item this is the second item
\end{gbenumerate}

Some text in between

\begin{gbenumerate}[resume]
\item this is the third item
\item this is the fourth item
\end{gbenumerate}

\end{document}


A bit more complex if you want to use gbenumerate several times with reset. In this case you have to say when to reset and to save the last value. I suggest enclosing the parts in a suitable environment.

\documentclass{article}
\usepackage{enumitem}

\newlist{gbenumerate}{enumerate}{1}
\setlist[gbenumerate]{
wide,
label=\arabic*/\unexpanded{\gbenum{\thesubgbenumerate}}.,
resume
}
\newcounter{subgbenumerate}

\makeatletter
\newenvironment{subgbenumerate}
{%
\stepcounter{subgbenumerate}%
}
{\immediate\write\@auxout{\string\storegbenum{\thesubgbenumerate}{\the\value{gbenumeratei}}}}
\newcommand{\storegbenum}[2]{%
\expandafter\xdef\csname gbenum@#1\endcsname{#2}%
}
\newcommand{\gbenum}[1]{\ifcsname gbenum@#1\endcsname\csname gbenum@#1\endcsname\else 0\fi}
\makeatother

\AtEndDocument{%
}
\makeatother

\begin{document}

\begin{subgbenumerate}
\begin{gbenumerate}
\item this is the first item
\item this is the second item
\end{gbenumerate}

Some text in between

\begin{gbenumerate}
\item this is the third item
\item this is the fourth item
\end{gbenumerate}
\end{subgbenumerate}

Some text in between.

\begin{subgbenumerate}
\begin{gbenumerate}
\item this is the first item
\item this is the second item
\end{gbenumerate}

Some text in between

\begin{gbenumerate}
\item this is the third item
\item this is the fourth item
\item this is the fifth item
\end{gbenumerate}
\end{subgbenumerate}

\end{document}


• Should the OP realize that what they really want is, using the gbenumerate environment many times in the same document, resetting the counter… should they ask a new question, or they can count on your benevolence? Jul 3 at 14:14
• @gboffi I added the code Jul 3 at 14:51
• Shouldn't enumitem already be saving the last value for use with [resume]? Jul 3 at 15:41
• @JohnKormylo But not in the aux file, just in memory. Jul 3 at 15:45
• @gboffi Depending on your use case, you might be able to embed the subgbenumerate code in another environment you use. Jul 3 at 18:51