[Tex/LaTex] Reference a slide in Beamer

beamercross-referencing

I have an example in my beamer presentation which I mention in another page. I want to include the page of that example in an automatic way. Here is my code. The reference to the example is on the last page.

Thank you.

\documentclass[]{beamer}
\usetheme{Madrid}

\usenavigationsymbolstemplate{}

\title{Main Title} 
\author{Jane Doe}
\institute{University A}
\date{\today}

\begin{document}

\begin{frame}
\titlepage % Print the title page as the first slide
\end{frame}

\begin{frame}
\frametitle{First Page}
\begin{exampleblock}{Example}
This is an example which will be used later.
\end{exampleblock}
\end{frame}

\begin{frame}
\frametitle{Second Page}
\begin{itemize}
\item Item 1
\item Item 2
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{Third Page}
\begin{itemize}
\item In this slide, we are going to use the sample example on page 2. % Here I want to reference the page of the example automatically.
\end{itemize}
\end{frame}

\end{document} 

Best Answer

Place a label to the frame you want to cross-reference and then use \ref:

\documentclass[]{beamer}
\usetheme{Madrid}

\usenavigationsymbolstemplate{}

\title{Main Title} 
\author{Jane Doe}
\institute{University A}
\date{\today}

\begin{document}

\begin{frame}
\titlepage % Print the title page as the first slide
\end{frame}

\begin{frame}
\frametitle{First Page}
\begin{exampleblock}{Example}
This is an example which will be used later.
\end{exampleblock}
\end{frame}

\begin{frame}[label={important}]
\frametitle{Second Page}
\begin{itemize}
\item Item 1
\item Item 2
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{Third Page}
\begin{itemize}
\item In this slide, we are going to use the sample example on slide~\ref{important}.
\end{itemize}
\end{frame}

\end{document}