# Progress bar within section/subsection for beamer

Here it was answered how to implement a progress bar for a beamer presentation. In particular, I liked the first solution. However it has one shortcoming, namely that the progress bar is valid for the entire presentation, so the main part of the code defining the size of the bar is \insertframenumber/\inserttotalframenumber.

Now, imagine I have slides with several sections and subsections, where each subsection has several/many slides (the entire document is more than 100 pages). So I would like to have a progress bar that shows progress in the current section (or even subsection). Actually, many of the default themes have this functionality (as noted here) but not in the form of a progress bar.

I could easily adapt the code in the first solution, but for this I need to find commands that would give the number of frames and the number of the first frame in the current section, if they exist.

    \definecolor{lightgr}{rgb}{0.7 0.7 0.7}
\makeatletter
\newcount\beamer@sectionstartframe
\newcount\beamer@sectionendframe

\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}

\def\beamertextwidth{\dimexpr 0.875 \textwidth\relax}
\makeatother


The above code should create a section progressbar in the footline of each slide. Note that the above code does work properly if you create new frames inside the AtBeginSection environment.