latexenumeratebeamer

Latex - Refer to nested item from enumerate in beamer


I want to refer to a nested item from an enumerate, but i want to see the entire label. Example:

\documentclass{beamer}

\begin{document}

\begin{frame}
    \begin{enumerate}
        \item Top list
        \begin{enumerate}
            \item Nested item 1
            \item \label{n2} Nested item 2
        \end{enumerate}
    \end{enumerate}
    
    I refer to item \ref{n2}
    
\end{frame}

\end{document}

results in:

enter image description here

But I would like it to refer to item 1.2 instead of 2.

I know you can do this using enumitem, but that seems to be incompatible with beamer.


Solution

  • \documentclass{beamer}
    
    \setbeamertemplate{itemize/enumerate body begin}
      {\renewcommand\theenumii{\theenumi.\arabic{enumii}}}
    \setbeamertemplate{enumerate subitem}{\theenumi.\arabic{enumii}}  
    
    \begin{document}
    
    \begin{frame}
        \begin{enumerate}
            \item Top list
            \begin{enumerate}
                \item Nested item 1
                \item \label{n2} Nested item 2
            \end{enumerate}
        \end{enumerate}
        
        I refer to item \ref{n2}
        
    \end{frame}
    
    \end{document}
    

    enter image description here