Multiple counters in the same list
Mark up with \itema
and \itemb
:
\documentclass{article}
\usepackage{enumitem}
\newenvironment{enumerateab}[1][]
{\enumerate[label=\theEABII,before=\setcounter{EABI}{0},#1]}
{\endenumerate}
\newcounter{EABI}
\newcounter{EABII}[EABI]
\makeatletter
\renewcommand{\theEABII}{\arabic{EABI}\@alph{\numexpr\c@EABII+1}}
\makeatother
\newcommand\itema{\stepcounter{EABI}\item}
\newcommand\itemb{\stepcounter{EABII}\item}
\begin{document}
\begin{enumerateab}
\itema item 1a
\itemb item 1b
\itema\label{foo} item 2a
\itemb item 2b
\end{enumerateab}
Item \ref{foo} is nice.
\end{document}
Alternative, if you always alternate “a” and “b”:
\documentclass{article}
\usepackage{enumitem}
\newenvironment{enumerateab}[1][]
{\enumerate[label=\theEABII,before=\setcounter{EABI}{0}\itematrue,#1]%
\let\latexitem\item\let\item\itemab}
{\endenumerate}
\newif\ifitema
\newcounter{EABI}
\newcounter{EABII}[EABI]
\makeatletter
\renewcommand{\theEABII}{\arabic{EABI}\@alph{\numexpr\c@EABII+1}}
\makeatother
\newcommand\itemab{%
\ifitema
\stepcounter{EABI}\itemafalse\latexitem
\else
\stepcounter{EABII}\itematrue\latexitem
\fi
}
\begin{document}
\begin{enumerateab}
\item item 1a
\item item 1b
\item\label{foo} item 2a
\item item 2b
\end{enumerateab}
Item \ref{foo} is nice.
\end{document}
Define your own representation
\documentclass{article}
\usepackage{enumitem}
\usepackage{xparse}
\ExplSyntaxOn\makeatletter
\NewDocumentCommand\arabicalph{ m }
{ \int_if_odd:nTF { \the\value{#1}}
{ \int_eval:n {(\the\value{#1} + 1)/2 }a}
{ \int_eval:n {\the\value{#1} / 2 } b}}
\ExplSyntaxOff
\begin{document}
\begin{enumerate}[label=\arabicalph{enumi}]
\item item 1a
\item item 1b
\item item 2a
\item item 2b
\end{enumerate}
\end{document}
Remark: The syntax label= \arabicalph*
doesn't work here, but it is now to late to try to find out why ...
Here is an implementation using an additional counter pairitem
, and setting the representation of the item numbering manually:
\documentclass{article}
\newcounter{pairitem}
\newenvironment{pairenumerate}
{\begin{enumerate}% Regular enumerate
\let\olditem\item% Store \item
\renewcommand{\theenumi}{\thepairitem\ifodd\value{enumi}a\else b\fi}% \item counter + reference
\renewcommand{\labelenumi}{(\theenumi)}% Counter representation in list
\setcounter{pairitem}{0}% Restart numbering
\renewcommand{\item}{% Update \item to check whether enumi is odd (for 'a'/'b' suffic
\ifodd\value{enumi}\else\stepcounter{pairitem}\fi
\olditem
}}
{\end{enumerate}}
\begin{document}
\begin{pairenumerate}
\item item 1a
\item item 1b
\item\label{foo} item 2a
\item item 2b
\end{pairenumerate}
Item~\ref{foo} is nice.
\end{document}