I have a weird numbering problem in a manuscript that uses sequentially numbered text examples. When an example demonstrates something which is e.g. wrong and later to be corrected they have suffixes a, b, and so on. In between it happens that there is text and possibly other examples which continues the original numbering, e.g:
(1) ... example ...
... text ...
(2a) ... bad example ...
... enlightening text and example:
(3) ... example ...
... after which we might return to the earlier bad example (2a) and show the correction
(2b) ... good example ...
... back to normal with more examples:
(4) ... example ...
I was asked how one would do this in a smart way in LaTeX. I have tried using the enumitem package as follows, but ran into trouble:
\documentclass{article}
\usepackage{enumitem}
\newlist{examples}{enumerate}{1}
\setlist[examples]{label=(\arabic*)}
\newlist{subexamples}{enumerate}{1}
\begin{document}
First an example, which we call 1.
\begin{examples}
\item example
\end{examples}
Then a bad example which we would like to call 2a:
\addtocounter{examplesi}{1}
\begin{subexamples}[series=aname, label=(\theexamplesi\alph*)]
\item example
\end{subexamples}
We learn something new in examples 3 and 4 (with wrong labels):
\begin{examples}[resume]
\item example
\item example
\end{examples}
And we get back to the bad example, which should be 2b:
\begin{subexamples}[resume*=aname]
\item example
\end{subexamples}
\end{document}
The above example produces the labels 1, 2a, 2, 3, 3b. The goal was 1, 2a, 3, 4, 2b.
One should be able to reference the individual items, and it should be flexible enough to have more than a single "hanging" example...