# Incorrect page number counter in beamer using sections

I am trying to put together a beamer document put together using multiple sections where frame numbers restart at each section and I can leave certain frames at the beginning of the document and at the beginning of each section uncounted.

My master document looks like this:

\documentclass{beamer}

\mode<presentation>
{
\usetheme{default}
\usecolortheme{default}
\usefonttheme{default}
\setbeamertemplate{caption}[numbered]
\setbeamertemplate{footline}[frame number]
}

\usepackage{hyperref}

\title[MATH]{Daily Notes}
\author{Me}
\institute{My College}
\date{\today}

\begin{document}
{
\setbeamertemplate{footline}{}
\titlepage
\end{frame}
}

{
\setbeamertemplate{footline}{}
\setcounter{tocdepth}{1}
\label{ToC}
\tableofcontents
\end{frame}
}

\input{Day_1.tex}
\input{Day_2.tex}

\end{document}


I use hyperref to create links in the table of contents. The two input files are comparable except in the number of frames and that seems to be the trouble. If Day_1.tex has 4 frames like so:

\section{The First}
\subsection{Housekeeping}

{
\setbeamertemplate{footline}{}
Hello world!
\end{frame}
}

\subsection{Content}
\begin{frame}
First slide
\end{frame}

\begin{frame}
Second slide
\end{frame}

\begin{frame}
Third slide
\end{frame}

\begin{frame}
Fourth slide
\end{frame}


and Day_2.tex is the same except having only 3 frames, then the numbering for Day_1 is given as 1/3, 2/3, 3/3, 4/3. If Day_1 has fewer frames than Day_2 (say 2 for Day_1 and 3 for Day_2), then Day_1's numbering is given as 1/3, 2/3.

How can I get the correct number of frames for each section in the frame numbering?

The following answer is based on https://tex.stackexchange.com/a/279364/36296

The problem with your approach is that \totalframenumber is saved at the end of the document, so in your case it is the length of your last section. But instead you can calculate the length of each section.

\documentclass{beamer}

\usepackage{etoolbox}
\makeatletter
\newcount\beamer@sectionstartframe
\beamer@sectionstartframe=1
\AtEndDocument{\immediate\write\@auxout{\string\@writefile{nav}%
\def\beamer@startframeofsection{1}
\def\beamer@endframeofsection{1}
\def\beamer@sectionframes#1#2{%
\else%
\else%
\gdef\beamer@startframeofsection{#1}%
\gdef\beamer@endframeofsection{#2}%
\fi%
\fi%
}
\newcommand\insertsectionstartframe{\beamer@startframeofsection}
\newcommand\insertsectionendframe{\beamer@endframeofsection}
\makeatother

\usepackage{tikz}
\usetikzlibrary{calc}

\pgfmathparse{(\insertsectionendframe-\insertsectionstartframe+1)}%
\pgfmathprintnumber[fixed,precision=2]{\pgfmathresult}%
}

\pgfmathprintnumber[fixed,precision=2]{\pgfmathresult}%
}

\title[MATH]{Daily Notes}
\author{Me}
\institute{My College}
\date{\today}

\begin{document}
{
\setbeamertemplate{footline}{}
\titlepage
\end{frame}
}

{
\setbeamertemplate{footline}{}
\setcounter{tocdepth}{1}
\label{ToC}
\tableofcontents
\end{frame}
}

\section{The First}
\subsection{Housekeeping}

{
\setbeamertemplate{footline}{}
Hello world!
\end{frame}
}

\subsection{Content}
\begin{frame}
First slide
\end{frame}

\begin{frame}
Second slide
\end{frame}

\begin{frame}
Third slide
\end{frame}

\begin{frame}
Fourth slide
\end{frame}

\section{The Second}
\subsection{Housekeeping}

{
\setbeamertemplate{footline}{}
Hello world!
\end{frame}
}

\subsection{Content}
\begin{frame}
First slide
\end{frame}

\begin{frame}
Second slide
\end{frame}

\begin{frame}
Third slide
\end{frame}

\end{document}

• Thanks @samcarter. This seems like it should work but now I get an error I can't track down: Argument of \addtocontents has an extra }. <inserted text> \par – Brian Jan 5 '16 at 22:53
• @Brian Strange. I checked again and I works fine for me. I am on TeXlive2015. – samcarter_is_at_topanswers.xyz Jan 5 '16 at 23:38
• @Brian Could you solve the problem? – samcarter_is_at_topanswers.xyz Jan 11 '16 at 20:29
• Unfortunately, no. Could it be due to the fact I'm using hyperref, as in (tex.stackexchange.com/questions/194720/…)? – Brian Jan 22 '16 at 18:10
• Beamer itself should load hyperref by default. Can you check if the above code without modifications runs on your system? Or edit your question to show the code you tried? – samcarter_is_at_topanswers.xyz Jan 22 '16 at 19:59