3

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?

  • Will there be slides in between part 1 and part 2? – Herr K. Dec 6 '13 at 20:39
  • @KevinC: Not for the moment, but I'd like the titles to be "renumbered" when I add frames between them in the future. – Jeroen Dec 6 '13 at 20:44
3

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

  • Absolutely perfect and very elegant! Thanks a lot! – Jeroen Dec 6 '13 at 21:00
  • If you get the occasion, perhaps you should post an output of the updated code, so as not to confuse future visitors of this page. – jub0bs Dec 6 '13 at 21:13
  • @Jubobs: Done. Thanks for making the edits :) It takes an experienced TeXnician to notice that spurious space ;) – Herr K. Dec 6 '13 at 21:29
  • @KevinC Thanks, but I'm more an "aspiring TeXnician". One day, maybe. No problem. Keep up the good work. – jub0bs Dec 6 '13 at 21:37
  • @HerrK. there is any way to do this if exists pages between the slides? There is not insertsubsectionstartframe. – Arturo Volpe May 10 '15 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.