[Tex/LaTex] Beamer total slides counter

beamercounters

Thanks to Change the page number of slides in notes when using | handout: command I can count the slides in a frame.

What I would also like is a counter for the total number of slides in a frame. Something like this:

\documentclass{beamer}

\makeatletter
\def\c@slideinframe{\beamer@slideinframe}
\makeatother

\begin{document}

\begin{frame}{Frame 1}
This is slide \arabic{slideinframe} of %here I'd like the total number of slides, 2 in this case
\pause
\end{frame}

\end{document}

Is it possible to have a counter for the total number of slides in a frame?

Best Answer

To calculate the total number of slides in each frame, you can use

\insertframeendpage - \insertframestartpage + 1

Full Code:

\documentclass{beamer}

\makeatletter
\def\c@slideinframe{\beamer@slideinframe}
\makeatother

\newcounter{totalslideinframe}

\begin{document}

\begin{frame}{Frame 1}

\setcounter{totalslideinframe}{\insertframeendpage}
\addtocounter{totalslideinframe}{-\insertframestartpage}
\addtocounter{totalslideinframe}{1}

This is slide \arabic{slideinframe} of \arabic{totalslideinframe}%here I'd like the total number of slides, 2 in this case
\pause
\end{frame}

\end{document}