[Tex/LaTex] Redefining enumerate counters in beamer

#enumeratebeamercross-referencinglists

I'd like to do two things with the enumerate environment in beamer.

  1. I'd like to reformat it so that it shows up as

    (1) An item
      a. A subitem
      b. Another subitem
    
  2. I'd like to be able to refer to these items with the usual \ref tags. Unfortunately, the only way I've found of getting the display of items inside of the environment right doesn't deliver the correct result for the references.

Here's a minimal working example.

\documentclass{beamer}

\setbeamertemplate{enumerate item}{(\insertenumlabel)}
\setbeamertemplate{enumerate subitem}{\alph{enumii}.}

\begin{document}

\begin{enumerate}
\item Foo\label{item:1}
  \begin{enumerate}
  \item Bar\label{item:2}
  \item Zip\label{item:3}
  \end{enumerate}
\end{enumerate}

Reference to ``Foo'': (\ref{item:1}).

Reference to ``bar'': (\ref{item:2}). 

Reference to ``zip'': (\ref{item:3}).
\end{document}

Unfortunately, that results in all three references in arabic numbers, i.e., (1), (1), and (2) for the three \ref's, in that order.

The desired output is for (\ref{item:3}) to be rendered as (1b).

Best Answer

redefine the begin of an enumerate

\documentclass{beamer}   
\setbeamertemplate{itemize/enumerate body begin}
  {\renewcommand\theenumii{\theenumi\alph{enumii}}}
\setbeamertemplate{enumerate item}{(\insertenumlabel)}
\setbeamertemplate{enumerate subitem}{\alph{enumii}.}

\begin{document}

\begin{frame}{}
\begin{enumerate}
\item Foo\label{item:1}
  \begin{enumerate}
  \item Bar\label{item:2}
  \item Zip\label{item:3}
  \end{enumerate}
\end{enumerate}

Reference to ``Foo'': (\ref{item:1}).

Reference to ``bar'': (\ref{item:2}). 

Reference to ``zip'': (\ref{item:3}).
\end{frame}
\end{document}

enter image description here