[Tex/LaTex] How to insert the subsection frame number in the frametitle

beamernumberingtitles

Let's say this is my presentation:

\documentclass{beamer}

\usetheme{Berlin}

\begin{document}

\section{Section}
\subsection{The beginning}
\frame{\frametitle{Begin}
    some text
}

\frame{\frametitle{Begin}
    some text
}

\frame{\frametitle{Begin}
    some text
}

\end{document}

I'd like the first slide's title to be Begin (part 1), the second slide's title Begin (part 2) and the third one Begin (part 3). I can simply type the extra (part x) with only 3 frames, but it gets quite a lot of work when one's working with a lot more frames.

How can I do this?

Best Answer

If there are no slides between part x and part (x+1), then you can use the current page number minus the page where subsection starts plus 1. The following macro does the calculation:

\newcommand\subsectnum{%
  (part~\number\numexpr \insertpagenumber-\insertsubsectionstartpage+1\relax)%
}

Full Code

\documentclass{beamer}

\usetheme{Berlin}

\newcommand\subsectnum{%
  (part~\number\numexpr \insertpagenumber-\insertsubsectionstartpage+1\relax)%
}

\begin{document}

\section{Section}
\subsection{The beginning}
\frame{\frametitle{Begin \subsectnum}
    some text
}

\frame{\frametitle{Begin \subsectnum}
    some text
}

\frame{\frametitle{Begin \subsectnum}
    some text
}

\end{document}

Output

enter image description here