\documentclass[handout, t]{beamer}
\usefonttheme[onlymath]{serif}
\usepackage{lmodern}
%\usepackage[default]{sourcesanspro}
\usepackage[utf8]{inputenc}
% See mail / GitHub for discussion on fontenc.
\usepackage[T1]{fontenc} % always recommended, https://tex.stackexchange.com/questions/1774
\renewcommand*\familydefault{\sfdefault}
\usepackage{amssymb}
\usepackage{pifont}
\usepackage{multirow}
\usepackage{multicol}
\usepackage{makecell}
\usepackage{booktabs}
\usepackage{ulem}
\usepackage{lastpage}
% ...
% other imports, setup, ...
% ...
% stuff from my beamer template:
% custom header
\defbeamertemplate*{headline}{rwth}{
% distance of section from the page top
\vspace{4mm}
\hbox{%
%
\hspace*{8mm}%
%
\begin{beamercolorbox}[wd=\framelinewidth,ht=13mm]{section in head/foot}%
\ifx\subsecname\empty%
{\usebeamerfont{section in head/foot}\insertsectionhead}\
\hspace*{1em}\Large\usebeamerfont{subsection}{}\strut%
\else%
{\usebeamerfont{subsection}\Large\normalfont\insertsectionhead%
\usebeamerfont{section in head/foot}}\
% note: by intention, use section font (larger, bold) for subsection title
\hspace{1em}\usebeamerfont{section}\insertsubsectionhead\strut%
\ifnum\value{subsubsection}=0%
\else%
: \insertsubsubsectionhead\strut%
\fi%
\vspace{-2pt}
\fi%
\end{beamercolorbox}%
%
\hspace{8mm}%
%
}%
\defbeamertemplate*{footline}{rwth}{
% ...
\insertframenumbering
% ...
}
% end of beamer template stuff
% now the page number stuff
\AtBeginSection[]{%
\let\subsecname\empty%
\let\subsubsecname\empty%
\setcounter{subsection}{0}%
\setcounter{subsubsection}{0}%
\deffirstlastpagecounters{}%
}
\AtBeginSubsection[]{
\deffirstlastpagecounters{}%
\setcounter{subsubsection}{-1}%
\subsubsection{Outline}
\begin{frame}
\tableofcontents[sectionstyle=show/hide,subsectionstyle=show/shaded/hide,subsubsectionstyle=show/show/hide]
\end{frame}
\setcounter{subsubsection}{-1}%
\clearpage
\subsubsection{}
\let\subsubsecname\empty%
}
% Counter calculation not needed anymore with page numbers per subsection.
% https://tex.stackexchange.com/questions/2541/beamer-frame-numbering-in-appendix
\newcommand{\backupbegin}{
% Use it one last time.
\deffirstlastpagecounters{}
% Ref to one after last page.
\setcounterpageref{seclastpage}{LastPage}
\addtocounter{seclastpage}{1}
% Now disable it.
\let\deffirstlastpagecounters\empty%
%\newcounter{framenumberappendix}
%\setcounter{framenumberappendix}{\value{framenumber}}
}
\newcommand{\backupend}{
%\addtocounter{framenumberappendix}{-\value{framenumber}}
%\addtocounter{framenumber}{\value{framenumberappendix}}
}
% Inspired via https://tex.stackexchange.com/questions/232785/numbers-for-first-and-last-page-of-chapters
\newcounter{subsecabs} % absolute sub section
\newcounter{secfirstpage}
\newcounter{seclastpage}
\def\deffirstlastpagecounters{%
\ifnum\value{subsecabs}=0\else% If not the first chapter
\label{sec\thesubsecabs:lastpage}% Insert an end-of-chapter \label
\fi%
%\clearpage
\addtocounter{subsecabs}{1}%
\label{sec\thesubsecabs:firstpage}% Insert a start-of-chapter \label
\setcounterpageref{secfirstpage}{sec\thesubsecabs:firstpage}%
\setcounterpageref{seclastpage}{sec\thesubsecabs:lastpage}%
}
%\AtBeginSection[]{\deffirstlastpagecounters{}}
%\AtBeginSubsection[]{\deffirstlastpagecounters{}}
\AtBeginDocument{\deffirstlastpagecounters{}}
%\AtEndDocument{\label{sec\number\value{subsecabs}:lastpage}}
%\newcommand{\insertframenumbering}{\insertframenumber{} of \inserttotalframenumber}
% counters: \thepage -- \theframenumber -- \thesecfirstpage -- \theseclastpage
\newcommand{\insertframenumbering}{%
\ifnum\value{section}=1%
Introduction%
\else
\ifnum\value{subsection}=0%
Section \number\numexpr\thesection-1%
\else
Section \number\numexpr\thesection-1.\thesubsection%
\fi%
\fi,\
page \number\numexpr\thepage-\thesecfirstpage+1{} of \number\numexpr\theseclastpage-\thesecfirstpage}
% ...
% other stuff
% ...
\begin{document}
\section*{Introduction}
\input{section_introduction}
\section{Part 1: ...}
\begin{frame}
\vfill
\begin{center}
\secname
% Or sth more custom?
% Or just outline again?
\end{center}
\vfill
\end{frame}
\subsection{Sub 1 ...}
\input{section_part1_sub1}
\subsection{Conclusion}
\input{section_part1_conclusion}
\section{Part 2: ...}
\begin{frame}
\vfill
\begin{center}
\secname
\end{center}
\vfill
\end{frame}
\subsection{Introduction}
% ...
\section{Conclusion}
\input{section_conclusion}
\setbeamertemplate{final page}[rwth][Any questions?]{Thank you for your attention}
\begin{frame}[plain]
\usebeamertemplate{final page}
\end{frame}
\appendix
\backupbegin
%\section{Appendix}
% ... (in case we need any appendix)
\section{References}
\begin{frame}[allowframebreaks]
\centerline{Reference}
%\bibliographystyle{ieeetr}
\bibliographystyle{i6bibstyle}
\bibliography{references}
\end{frame}
\backupend
\end{document}
\labels. Why couldn't you do it once in\apptocmd? I use\AtBeginSection. I also use some custom counters. – Albert Oct 17 '20 at 11:07